angular-formly-templates-bootstrap.js 19 KB

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