angular-formly-templates-bootstrap.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. // angular-formly-templates-bootstrap version 6.0.0 built with ♥ by Astrism <astrisms@gmail.com>, Kent C. Dodds <kent@doddsfamily.us> (ó ì_í)=óò=(ì_í ò)
  2. (function webpackUniversalModuleDefinition(root, factory) {
  3. if(typeof exports === 'object' && typeof module === 'object')
  4. module.exports = factory(require("angular-formly"), require("api-check"), require("angular"));
  5. else if(typeof define === 'function' && define.amd)
  6. define(["angular-formly", "api-check", "angular"], factory);
  7. else if(typeof exports === 'object')
  8. exports["ngFormlyTemplatesBootstrap"] = factory(require("angular-formly"), require("api-check"), require("angular"));
  9. else
  10. root["ngFormlyTemplatesBootstrap"] = factory(root["ngFormly"], root["apiCheck"], root["angular"]);
  11. })(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_3__, __WEBPACK_EXTERNAL_MODULE_8__) {
  12. return /******/ (function(modules) { // webpackBootstrap
  13. /******/ // The module cache
  14. /******/ var installedModules = {};
  15. /******/
  16. /******/ // The require function
  17. /******/ function __webpack_require__(moduleId) {
  18. /******/
  19. /******/ // Check if module is in cache
  20. /******/ if(installedModules[moduleId])
  21. /******/ return installedModules[moduleId].exports;
  22. /******/
  23. /******/ // Create a new module (and put it into the cache)
  24. /******/ var module = installedModules[moduleId] = {
  25. /******/ exports: {},
  26. /******/ id: moduleId,
  27. /******/ loaded: false
  28. /******/ };
  29. /******/
  30. /******/ // Execute the module function
  31. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  32. /******/
  33. /******/ // Flag the module as loaded
  34. /******/ module.loaded = true;
  35. /******/
  36. /******/ // Return the exports of the module
  37. /******/ return module.exports;
  38. /******/ }
  39. /******/
  40. /******/
  41. /******/ // expose the modules object (__webpack_modules__)
  42. /******/ __webpack_require__.m = modules;
  43. /******/
  44. /******/ // expose the module cache
  45. /******/ __webpack_require__.c = installedModules;
  46. /******/
  47. /******/ // __webpack_public_path__
  48. /******/ __webpack_require__.p = "";
  49. /******/
  50. /******/ // Load entry module and return exports
  51. /******/ return __webpack_require__(0);
  52. /******/ })
  53. /************************************************************************/
  54. /******/ ([
  55. /* 0 */
  56. /***/ function(module, exports, __webpack_require__) {
  57. 'use strict';
  58. module.exports = __webpack_require__(11);
  59. /***/ },
  60. /* 1 */
  61. /***/ function(module, exports, __webpack_require__) {
  62. 'use strict';
  63. Object.defineProperty(exports, '__esModule', {
  64. value: true
  65. });
  66. exports['default'] = function (ngModule) {
  67. ngModule.config(addCheckboxType);
  68. function addCheckboxType(formlyConfigProvider) {
  69. formlyConfigProvider.setType({
  70. name: 'multiCheckbox',
  71. template: __webpack_require__(21),
  72. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  73. apiCheck: function apiCheck(check) {
  74. return {
  75. templateOptions: {
  76. options: check.arrayOf(check.object),
  77. labelProp: check.string.optional,
  78. valueProp: check.string.optional
  79. }
  80. };
  81. },
  82. defaultOptions: {
  83. noFormControl: false,
  84. ngModelAttrs: {
  85. required: {
  86. attribute: '',
  87. bound: ''
  88. }
  89. }
  90. },
  91. controller: /* @ngInject */["$scope", function controller($scope) {
  92. var to = $scope.to;
  93. var opts = $scope.options;
  94. $scope.multiCheckbox = {
  95. checked: [],
  96. change: setModel
  97. };
  98. // initialize the checkboxes check property
  99. $scope.$watch('model', function modelWatcher(newModelValue) {
  100. var modelValue, valueProp;
  101. if (Object.keys(newModelValue).length) {
  102. modelValue = newModelValue[opts.key];
  103. $scope.$watch('to.options', function optionsWatcher(newOptionsValues) {
  104. if (newOptionsValues && Array.isArray(newOptionsValues) && Array.isArray(modelValue)) {
  105. valueProp = to.valueProp || 'value';
  106. for (var index = 0; index < newOptionsValues.length; index++) {
  107. $scope.multiCheckbox.checked[index] = modelValue.indexOf(newOptionsValues[index][valueProp]) !== -1;
  108. }
  109. }
  110. });
  111. }
  112. }, true);
  113. function checkValidity(expressionValue) {
  114. var valid;
  115. if ($scope.to.required) {
  116. valid = angular.isArray($scope.model[opts.key]) && $scope.model[opts.key].length > 0 && expressionValue;
  117. $scope.fc.$setValidity('required', valid);
  118. }
  119. }
  120. function setModel() {
  121. $scope.model[opts.key] = [];
  122. angular.forEach($scope.multiCheckbox.checked, function (checkbox, index) {
  123. if (checkbox) {
  124. $scope.model[opts.key].push(to.options[index][to.valueProp || 'value']);
  125. }
  126. });
  127. // Must make sure we mark as touched because only the last checkbox due to a bug in angular.
  128. $scope.fc.$setTouched();
  129. checkValidity(true);
  130. }
  131. if (opts.expressionProperties && opts.expressionProperties['templateOptions.required']) {
  132. $scope.$watch(function () {
  133. return $scope.to.required;
  134. }, function (newValue) {
  135. checkValidity(newValue);
  136. });
  137. }
  138. if ($scope.to.required) {
  139. var unwatchFormControl = $scope.$watch('fc', function (newValue) {
  140. if (!newValue) {
  141. return;
  142. }
  143. checkValidity(true);
  144. unwatchFormControl();
  145. });
  146. }
  147. }]
  148. });
  149. }
  150. addCheckboxType.$inject = ["formlyConfigProvider"];
  151. };
  152. module.exports = exports['default'];
  153. /***/ },
  154. /* 2 */
  155. /***/ function(module, exports, __webpack_require__) {
  156. module.exports = __WEBPACK_EXTERNAL_MODULE_2__;
  157. /***/ },
  158. /* 3 */
  159. /***/ function(module, exports, __webpack_require__) {
  160. module.exports = __WEBPACK_EXTERNAL_MODULE_3__;
  161. /***/ },
  162. /* 4 */
  163. /***/ function(module, exports, __webpack_require__) {
  164. // some versions of angular don't export the angular module properly,
  165. // so we get it from window in this case.
  166. 'use strict';
  167. var angular = __webpack_require__(8);
  168. if (!angular.version) {
  169. angular = window.angular;
  170. }
  171. module.exports = angular;
  172. /***/ },
  173. /* 5 */
  174. /***/ function(module, exports, __webpack_require__) {
  175. 'use strict';
  176. Object.defineProperty(exports, '__esModule', {
  177. value: true
  178. });
  179. exports['default'] = function (ngModule) {
  180. ngModule.config(addWrappers);
  181. function addWrappers(formlyConfigProvider) {
  182. formlyConfigProvider.setWrapper([{
  183. name: 'bootstrapLabel',
  184. template: __webpack_require__(17),
  185. apiCheck: function apiCheck(check) {
  186. return {
  187. templateOptions: {
  188. label: check.string,
  189. required: check.bool.optional
  190. }
  191. };
  192. }
  193. }, { name: 'bootstrapHasError', template: __webpack_require__(18) }]);
  194. }
  195. addWrappers.$inject = ["formlyConfigProvider"];
  196. };
  197. module.exports = exports['default'];
  198. /***/ },
  199. /* 6 */
  200. /***/ function(module, exports, __webpack_require__) {
  201. 'use strict';
  202. Object.defineProperty(exports, '__esModule', {
  203. value: true
  204. });
  205. exports['default'] = function (ngModule) {
  206. __webpack_require__(10)(ngModule);
  207. __webpack_require__(1)(ngModule);
  208. __webpack_require__(12)(ngModule);
  209. __webpack_require__(9)(ngModule);
  210. __webpack_require__(13)(ngModule);
  211. __webpack_require__(14)(ngModule);
  212. };
  213. module.exports = exports['default'];
  214. /***/ },
  215. /* 7 */
  216. /***/ function(module, exports, __webpack_require__) {
  217. 'use strict';
  218. Object.defineProperty(exports, '__esModule', {
  219. value: true
  220. });
  221. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  222. var _addons = __webpack_require__(15);
  223. var _addons2 = _interopRequireDefault(_addons);
  224. var _description = __webpack_require__(16);
  225. var _description2 = _interopRequireDefault(_description);
  226. exports['default'] = function (ngModule) {
  227. (0, _addons2['default'])(ngModule);
  228. (0, _description2['default'])(ngModule);
  229. };
  230. module.exports = exports['default'];
  231. /***/ },
  232. /* 8 */
  233. /***/ function(module, exports, __webpack_require__) {
  234. module.exports = __WEBPACK_EXTERNAL_MODULE_8__;
  235. /***/ },
  236. /* 9 */
  237. /***/ function(module, exports, __webpack_require__) {
  238. 'use strict';
  239. Object.defineProperty(exports, '__esModule', {
  240. value: true
  241. });
  242. exports['default'] = function (ngModule) {
  243. ngModule.config(addRadioType);
  244. function addRadioType(formlyConfigProvider) {
  245. formlyConfigProvider.setType({
  246. name: 'radio',
  247. template: __webpack_require__(19),
  248. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  249. defaultOptions: {
  250. noFormControl: false
  251. },
  252. apiCheck: function apiCheck(check) {
  253. return {
  254. templateOptions: {
  255. options: check.arrayOf(check.object),
  256. labelProp: check.string.optional,
  257. valueProp: check.string.optional
  258. }
  259. };
  260. }
  261. });
  262. }
  263. addRadioType.$inject = ["formlyConfigProvider"];
  264. };
  265. module.exports = exports['default'];
  266. /***/ },
  267. /* 10 */
  268. /***/ function(module, exports, __webpack_require__) {
  269. 'use strict';
  270. Object.defineProperty(exports, '__esModule', {
  271. value: true
  272. });
  273. exports['default'] = function (ngModule) {
  274. ngModule.config(addCheckboxType);
  275. function addCheckboxType(formlyConfigProvider) {
  276. formlyConfigProvider.setType({
  277. name: 'checkbox',
  278. template: __webpack_require__(20),
  279. wrapper: ['bootstrapHasError'],
  280. apiCheck: function apiCheck(check) {
  281. return {
  282. templateOptions: {
  283. label: check.string
  284. }
  285. };
  286. }
  287. });
  288. }
  289. addCheckboxType.$inject = ["formlyConfigProvider"];
  290. };
  291. module.exports = exports['default'];
  292. /***/ },
  293. /* 11 */
  294. /***/ function(module, exports, __webpack_require__) {
  295. 'use strict';
  296. Object.defineProperty(exports, '__esModule', {
  297. value: true
  298. });
  299. var ngModuleName = 'formlyBootstrap';
  300. var angular = __webpack_require__(4);
  301. var ngModule = angular.module(ngModuleName, [__webpack_require__(2)]);
  302. ngModule.constant('formlyBootstrapApiCheck', __webpack_require__(3)({
  303. output: {
  304. prefix: 'angular-formly-bootstrap'
  305. }
  306. }));
  307. ngModule.constant('formlyBootstrapVersion', ("6.0.0"));
  308. __webpack_require__(5)(ngModule);
  309. __webpack_require__(6)(ngModule);
  310. __webpack_require__(7)(ngModule);
  311. exports['default'] = ngModuleName;
  312. module.exports = exports['default'];
  313. /***/ },
  314. /* 12 */
  315. /***/ function(module, exports, __webpack_require__) {
  316. 'use strict';
  317. Object.defineProperty(exports, '__esModule', {
  318. value: true
  319. });
  320. exports['default'] = function (ngModule) {
  321. ngModule.config(addInputType);
  322. function addInputType(formlyConfigProvider) {
  323. formlyConfigProvider.setType({
  324. name: 'input',
  325. template: '<input class="form-control" ng-model="model[options.key]">',
  326. wrapper: ['bootstrapLabel', 'bootstrapHasError']
  327. });
  328. }
  329. addInputType.$inject = ["formlyConfigProvider"];
  330. };
  331. module.exports = exports['default'];
  332. /***/ },
  333. /* 13 */
  334. /***/ function(module, exports, __webpack_require__) {
  335. 'use strict';
  336. Object.defineProperty(exports, '__esModule', {
  337. value: true
  338. });
  339. function _defineProperty(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); }
  340. exports['default'] = function (ngModule) {
  341. ngModule.config(addSelectType);
  342. var template = '<select class="form-control" ng-model="model[options.key]"></select>';
  343. function addSelectType(formlyConfigProvider) {
  344. formlyConfigProvider.setType({
  345. name: 'select',
  346. template: template,
  347. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  348. defaultOptions: function defaultOptions(options) {
  349. /* jshint maxlen:195 */
  350. var ngOptions = options.templateOptions.ngOptions || 'option[to.valueProp || \'value\'] as option[to.labelProp || \'name\'] group by option[to.groupProp || \'group\'] for option in to.options';
  351. return {
  352. ngModelAttrs: _defineProperty({}, ngOptions, {
  353. value: 'ng-options'
  354. })
  355. };
  356. },
  357. apiCheck: function apiCheck(check) {
  358. return {
  359. templateOptions: {
  360. options: check.arrayOf(check.object),
  361. labelProp: check.string.optional,
  362. valueProp: check.string.optional,
  363. groupProp: check.string.optional
  364. }
  365. };
  366. }
  367. });
  368. }
  369. addSelectType.$inject = ["formlyConfigProvider"];
  370. };
  371. module.exports = exports['default'];
  372. /***/ },
  373. /* 14 */
  374. /***/ function(module, exports, __webpack_require__) {
  375. 'use strict';
  376. Object.defineProperty(exports, '__esModule', {
  377. value: true
  378. });
  379. exports['default'] = function (ngModule) {
  380. ngModule.config(addTextareaType);
  381. function addTextareaType(formlyConfigProvider) {
  382. formlyConfigProvider.setType({
  383. name: 'textarea',
  384. template: '<textarea class="form-control" ng-model="model[options.key]"></textarea>',
  385. wrapper: ['bootstrapLabel', 'bootstrapHasError'],
  386. defaultOptions: {
  387. ngModelAttrs: {
  388. rows: { attribute: 'rows' },
  389. cols: { attribute: 'cols' }
  390. }
  391. },
  392. apiCheck: function apiCheck(check) {
  393. return {
  394. templateOptions: {
  395. rows: check.number.optional,
  396. cols: check.number.optional
  397. }
  398. };
  399. }
  400. });
  401. }
  402. addTextareaType.$inject = ["formlyConfigProvider"];
  403. };
  404. module.exports = exports['default'];
  405. /***/ },
  406. /* 15 */
  407. /***/ function(module, exports, __webpack_require__) {
  408. 'use strict';
  409. Object.defineProperty(exports, '__esModule', {
  410. value: true
  411. });
  412. exports['default'] = function (ngModule) {
  413. ngModule.run(addAddonsManipulator);
  414. function addAddonsManipulator(formlyConfig, formlyBootstrapApiCheck) {
  415. var addonTemplate = __webpack_require__(22);
  416. var addonChecker = formlyBootstrapApiCheck.shape({
  417. 'class': formlyBootstrapApiCheck.string.optional,
  418. text: formlyBootstrapApiCheck.string.optional,
  419. onClick: formlyBootstrapApiCheck.func.optional
  420. }).strict.optional;
  421. var api = formlyBootstrapApiCheck.shape({
  422. templateOptions: formlyBootstrapApiCheck.shape({
  423. addonLeft: addonChecker,
  424. addonRight: addonChecker
  425. })
  426. });
  427. formlyConfig.templateManipulators.preWrapper.push(function (template, options) {
  428. if (!options.templateOptions.addonLeft && !options.templateOptions.addonRight) {
  429. return template;
  430. }
  431. formlyBootstrapApiCheck.warn([api], [options]);
  432. return addonTemplate.replace('<formly-transclude></formly-transclude>', template);
  433. });
  434. }
  435. addAddonsManipulator.$inject = ["formlyConfig", "formlyBootstrapApiCheck"];
  436. };
  437. module.exports = exports['default'];
  438. /***/ },
  439. /* 16 */
  440. /***/ function(module, exports, __webpack_require__) {
  441. 'use strict';
  442. Object.defineProperty(exports, '__esModule', {
  443. value: true
  444. });
  445. exports['default'] = function (ngModule) {
  446. ngModule.run(addDescriptionManipulator);
  447. function addDescriptionManipulator(formlyConfig) {
  448. formlyConfig.templateManipulators.preWrapper.push(function ariaDescribedBy(template, options, scope) {
  449. if (angular.isDefined(options.templateOptions.description)) {
  450. var el = document.createElement('div');
  451. el.appendChild(angular.element(template)[0]);
  452. el.appendChild(angular.element('<p id="' + scope.id + '_description"' + 'class="help-block"' + 'ng-if="to.description">' + '{{to.description}}' + '</p>')[0]);
  453. var modelEls = angular.element(el.querySelectorAll('[ng-model]'));
  454. if (modelEls) {
  455. modelEls.attr('aria-describedby', scope.id + '_description');
  456. }
  457. return el.innerHTML;
  458. } else {
  459. return template;
  460. }
  461. });
  462. }
  463. addDescriptionManipulator.$inject = ["formlyConfig"];
  464. };
  465. module.exports = exports['default'];
  466. /***/ },
  467. /* 17 */
  468. /***/ function(module, exports, __webpack_require__) {
  469. module.exports = "<div>\n <label for=\"{{id}}\" class=\"control-label\" ng-if=\"to.label\">\n {{to.label}}\n {{to.required ? '*' : ''}}\n </label>\n <formly-transclude></formly-transclude>\n</div>\n"
  470. /***/ },
  471. /* 18 */
  472. /***/ function(module, exports, __webpack_require__) {
  473. module.exports = "<div class=\"form-group\" ng-class=\"{'has-error': showError}\">\n <formly-transclude></formly-transclude>\n</div>\n"
  474. /***/ },
  475. /* 19 */
  476. /***/ function(module, exports, __webpack_require__) {
  477. module.exports = "<div class=\"radio-group\">\n <div ng-repeat=\"(key, option) in to.options\" class=\"radio\">\n <label>\n <input type=\"radio\"\n id=\"{{id + '_'+ $index}}\"\n tabindex=\"0\"\n ng-value=\"option[to.valueProp || 'value']\"\n ng-model=\"model[options.key]\">\n {{option[to.labelProp || 'name']}}\n </label>\n </div>\n</div>\n"
  478. /***/ },
  479. /* 20 */
  480. /***/ function(module, exports, __webpack_require__) {
  481. module.exports = "<div class=\"checkbox\">\n\t<label>\n\t\t<input type=\"checkbox\"\n class=\"formly-field-checkbox\"\n\t\t ng-model=\"model[options.key]\">\n\t\t{{to.label}}\n\t\t{{to.required ? '*' : ''}}\n\t</label>\n</div>\n"
  482. /***/ },
  483. /* 21 */
  484. /***/ function(module, exports, __webpack_require__) {
  485. module.exports = "<div class=\"radio-group\">\n <div ng-repeat=\"(key, option) in to.options\" class=\"checkbox\">\n <label>\n <input type=\"checkbox\"\n id=\"{{id + '_'+ $index}}\"\n ng-model=\"multiCheckbox.checked[$index]\"\n ng-change=\"multiCheckbox.change()\">\n {{option[to.labelProp || 'name']}}\n </label>\n </div>\n</div>\n"
  486. /***/ },
  487. /* 22 */
  488. /***/ function(module, exports, __webpack_require__) {
  489. module.exports = "<div ng-class=\"{'input-group': to.addonLeft || to.addonRight}\">\n <div class=\"input-group-addon\"\n ng-if=\"to.addonLeft\"\n ng-style=\"{cursor: to.addonLeft.onClick ? 'pointer' : 'inherit'}\"\n ng-click=\"to.addonLeft.onClick(options, this)\">\n <i class=\"{{to.addonLeft.class}}\" ng-if=\"to.addonLeft.class\"></i>\n <span ng-if=\"to.addonLeft.text\">{{to.addonLeft.text}}</span>\n </div>\n <formly-transclude></formly-transclude>\n <div class=\"input-group-addon\"\n ng-if=\"to.addonRight\"\n ng-style=\"{cursor: to.addonRight.onClick ? 'pointer' : 'inherit'}\"\n ng-click=\"to.addonRight.onClick(options, this)\">\n <i class=\"{{to.addonRight.class}}\" ng-if=\"to.addonRight.class\"></i>\n <span ng-if=\"to.addonRight.text\">{{to.addonRight.text}}</span>\n </div>\n</div>\n"
  490. /***/ }
  491. /******/ ])
  492. });
  493. ;
  494. //# sourceMappingURL=angular-formly-templates-bootstrap.js.map