check-box.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = Object.setPrototypeOf ||
  4. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6. return function (d, b) {
  7. extendStatics(d, b);
  8. function __() { this.constructor = d; }
  9. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10. };
  11. })();
  12. /*!
  13. * devextreme-angular
  14. * Version: 19.1.16
  15. * Build date: Tue Oct 18 2022
  16. *
  17. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  18. *
  19. * This software may be modified and distributed under the terms
  20. * of the MIT license. See the LICENSE file in the root of the project for details.
  21. *
  22. * https://github.com/DevExpress/devextreme-angular
  23. */
  24. Object.defineProperty(exports, "__esModule", { value: true });
  25. var platform_browser_1 = require("@angular/platform-browser");
  26. var platform_browser_2 = require("@angular/platform-browser");
  27. var core_1 = require("@angular/core");
  28. var check_box_1 = require("devextreme/ui/check_box");
  29. var forms_1 = require("@angular/forms");
  30. var component_1 = require("../core/component");
  31. var template_host_1 = require("../core/template-host");
  32. var integration_1 = require("../core/integration");
  33. var template_1 = require("../core/template");
  34. var nested_option_1 = require("../core/nested-option");
  35. var watcher_helper_1 = require("../core/watcher-helper");
  36. var CUSTOM_VALUE_ACCESSOR_PROVIDER = {
  37. provide: forms_1.NG_VALUE_ACCESSOR,
  38. useExisting: core_1.forwardRef(function () { return DxCheckBoxComponent; }),
  39. multi: true
  40. };
  41. /**
  42. * The CheckBox is a small box, which when selected by the end user, shows that a particular feature has been enabled or a specific option has been chosen.
  43. */
  44. var DxCheckBoxComponent = (function (_super) {
  45. __extends(DxCheckBoxComponent, _super);
  46. function DxCheckBoxComponent(elementRef, ngZone, templateHost, _watcherHelper, optionHost, transferState, platformId) {
  47. var _this = _super.call(this, elementRef, ngZone, templateHost, _watcherHelper, transferState, platformId) || this;
  48. _this.touched = function (_) { };
  49. _this._createEventEmitters([
  50. { subscribe: 'contentReady', emit: 'onContentReady' },
  51. { subscribe: 'disposing', emit: 'onDisposing' },
  52. { subscribe: 'initialized', emit: 'onInitialized' },
  53. { subscribe: 'optionChanged', emit: 'onOptionChanged' },
  54. { subscribe: 'valueChanged', emit: 'onValueChanged' },
  55. { emit: 'accessKeyChange' },
  56. { emit: 'activeStateEnabledChange' },
  57. { emit: 'disabledChange' },
  58. { emit: 'elementAttrChange' },
  59. { emit: 'focusStateEnabledChange' },
  60. { emit: 'heightChange' },
  61. { emit: 'hintChange' },
  62. { emit: 'hoverStateEnabledChange' },
  63. { emit: 'isValidChange' },
  64. { emit: 'nameChange' },
  65. { emit: 'readOnlyChange' },
  66. { emit: 'rtlEnabledChange' },
  67. { emit: 'tabIndexChange' },
  68. { emit: 'textChange' },
  69. { emit: 'validationErrorChange' },
  70. { emit: 'validationMessageModeChange' },
  71. { emit: 'valueChange' },
  72. { emit: 'visibleChange' },
  73. { emit: 'widthChange' },
  74. { emit: 'onBlur' }
  75. ]);
  76. optionHost.setHost(_this);
  77. return _this;
  78. }
  79. Object.defineProperty(DxCheckBoxComponent.prototype, "accessKey", {
  80. get: /**
  81. * Specifies the shortcut key that sets focus on the widget.
  82. */
  83. function () {
  84. return this._getOption('accessKey');
  85. },
  86. set: function (value) {
  87. this._setOption('accessKey', value);
  88. },
  89. enumerable: true,
  90. configurable: true
  91. });
  92. Object.defineProperty(DxCheckBoxComponent.prototype, "activeStateEnabled", {
  93. get: /**
  94. * Specifies whether or not the widget changes its state when interacting with a user.
  95. */
  96. function () {
  97. return this._getOption('activeStateEnabled');
  98. },
  99. set: function (value) {
  100. this._setOption('activeStateEnabled', value);
  101. },
  102. enumerable: true,
  103. configurable: true
  104. });
  105. Object.defineProperty(DxCheckBoxComponent.prototype, "disabled", {
  106. get: /**
  107. * Specifies whether the widget responds to user interaction.
  108. */
  109. function () {
  110. return this._getOption('disabled');
  111. },
  112. set: function (value) {
  113. this._setOption('disabled', value);
  114. },
  115. enumerable: true,
  116. configurable: true
  117. });
  118. Object.defineProperty(DxCheckBoxComponent.prototype, "elementAttr", {
  119. get: /**
  120. * Specifies the attributes to be attached to the widget's root element.
  121. */
  122. function () {
  123. return this._getOption('elementAttr');
  124. },
  125. set: function (value) {
  126. this._setOption('elementAttr', value);
  127. },
  128. enumerable: true,
  129. configurable: true
  130. });
  131. Object.defineProperty(DxCheckBoxComponent.prototype, "focusStateEnabled", {
  132. get: /**
  133. * Specifies whether the widget can be focused using keyboard navigation.
  134. */
  135. function () {
  136. return this._getOption('focusStateEnabled');
  137. },
  138. set: function (value) {
  139. this._setOption('focusStateEnabled', value);
  140. },
  141. enumerable: true,
  142. configurable: true
  143. });
  144. Object.defineProperty(DxCheckBoxComponent.prototype, "height", {
  145. get: /**
  146. * Specifies the widget's height.
  147. */
  148. function () {
  149. return this._getOption('height');
  150. },
  151. set: function (value) {
  152. this._setOption('height', value);
  153. },
  154. enumerable: true,
  155. configurable: true
  156. });
  157. Object.defineProperty(DxCheckBoxComponent.prototype, "hint", {
  158. get: /**
  159. * Specifies text for a hint that appears when a user pauses on the widget.
  160. */
  161. function () {
  162. return this._getOption('hint');
  163. },
  164. set: function (value) {
  165. this._setOption('hint', value);
  166. },
  167. enumerable: true,
  168. configurable: true
  169. });
  170. Object.defineProperty(DxCheckBoxComponent.prototype, "hoverStateEnabled", {
  171. get: /**
  172. * Specifies whether the widget changes its state when a user pauses on it.
  173. */
  174. function () {
  175. return this._getOption('hoverStateEnabled');
  176. },
  177. set: function (value) {
  178. this._setOption('hoverStateEnabled', value);
  179. },
  180. enumerable: true,
  181. configurable: true
  182. });
  183. Object.defineProperty(DxCheckBoxComponent.prototype, "isValid", {
  184. get: /**
  185. * Specifies whether the editor's value is valid.
  186. */
  187. function () {
  188. return this._getOption('isValid');
  189. },
  190. set: function (value) {
  191. this._setOption('isValid', value);
  192. },
  193. enumerable: true,
  194. configurable: true
  195. });
  196. Object.defineProperty(DxCheckBoxComponent.prototype, "name", {
  197. get: /**
  198. * The value to be assigned to the `name` attribute of the underlying HTML element.
  199. */
  200. function () {
  201. return this._getOption('name');
  202. },
  203. set: function (value) {
  204. this._setOption('name', value);
  205. },
  206. enumerable: true,
  207. configurable: true
  208. });
  209. Object.defineProperty(DxCheckBoxComponent.prototype, "readOnly", {
  210. get: /**
  211. * Specifies whether the editor is read-only.
  212. */
  213. function () {
  214. return this._getOption('readOnly');
  215. },
  216. set: function (value) {
  217. this._setOption('readOnly', value);
  218. },
  219. enumerable: true,
  220. configurable: true
  221. });
  222. Object.defineProperty(DxCheckBoxComponent.prototype, "rtlEnabled", {
  223. get: /**
  224. * Switches the widget to a right-to-left representation.
  225. */
  226. function () {
  227. return this._getOption('rtlEnabled');
  228. },
  229. set: function (value) {
  230. this._setOption('rtlEnabled', value);
  231. },
  232. enumerable: true,
  233. configurable: true
  234. });
  235. Object.defineProperty(DxCheckBoxComponent.prototype, "tabIndex", {
  236. get: /**
  237. * Specifies the number of the element when the Tab key is used for navigating.
  238. */
  239. function () {
  240. return this._getOption('tabIndex');
  241. },
  242. set: function (value) {
  243. this._setOption('tabIndex', value);
  244. },
  245. enumerable: true,
  246. configurable: true
  247. });
  248. Object.defineProperty(DxCheckBoxComponent.prototype, "text", {
  249. get: /**
  250. * Specifies the text displayed by the check box.
  251. */
  252. function () {
  253. return this._getOption('text');
  254. },
  255. set: function (value) {
  256. this._setOption('text', value);
  257. },
  258. enumerable: true,
  259. configurable: true
  260. });
  261. Object.defineProperty(DxCheckBoxComponent.prototype, "validationError", {
  262. get: /**
  263. * Specifies information on the validation error when using a custom validation engine. Should be changed at runtime along with the isValid option.
  264. */
  265. function () {
  266. return this._getOption('validationError');
  267. },
  268. set: function (value) {
  269. this._setOption('validationError', value);
  270. },
  271. enumerable: true,
  272. configurable: true
  273. });
  274. Object.defineProperty(DxCheckBoxComponent.prototype, "validationMessageMode", {
  275. get: /**
  276. * Specifies how the message about the validation rules that are not satisfied by this editor's value is displayed.
  277. */
  278. function () {
  279. return this._getOption('validationMessageMode');
  280. },
  281. set: function (value) {
  282. this._setOption('validationMessageMode', value);
  283. },
  284. enumerable: true,
  285. configurable: true
  286. });
  287. Object.defineProperty(DxCheckBoxComponent.prototype, "value", {
  288. get: /**
  289. * Specifies the widget state.
  290. */
  291. function () {
  292. return this._getOption('value');
  293. },
  294. set: function (value) {
  295. this._setOption('value', value);
  296. },
  297. enumerable: true,
  298. configurable: true
  299. });
  300. Object.defineProperty(DxCheckBoxComponent.prototype, "visible", {
  301. get: /**
  302. * Specifies whether the widget is visible.
  303. */
  304. function () {
  305. return this._getOption('visible');
  306. },
  307. set: function (value) {
  308. this._setOption('visible', value);
  309. },
  310. enumerable: true,
  311. configurable: true
  312. });
  313. Object.defineProperty(DxCheckBoxComponent.prototype, "width", {
  314. get: /**
  315. * Specifies the widget's width.
  316. */
  317. function () {
  318. return this._getOption('width');
  319. },
  320. set: function (value) {
  321. this._setOption('width', value);
  322. },
  323. enumerable: true,
  324. configurable: true
  325. });
  326. DxCheckBoxComponent.prototype.change = function (_) { };
  327. DxCheckBoxComponent.prototype._createInstance = function (element, options) {
  328. return new check_box_1.default(element, options);
  329. };
  330. DxCheckBoxComponent.prototype.writeValue = function (value) {
  331. this.eventHelper.lockedValueChangeEvent = true;
  332. this.value = value;
  333. this.eventHelper.lockedValueChangeEvent = false;
  334. };
  335. DxCheckBoxComponent.prototype.setDisabledState = function (isDisabled) {
  336. this.disabled = isDisabled;
  337. };
  338. DxCheckBoxComponent.prototype.registerOnChange = function (fn) { this.change = fn; };
  339. DxCheckBoxComponent.prototype.registerOnTouched = function (fn) { this.touched = fn; };
  340. DxCheckBoxComponent.prototype._createWidget = function (element) {
  341. var _this = this;
  342. _super.prototype._createWidget.call(this, element);
  343. this.instance.on('focusOut', function (e) {
  344. _this.eventHelper.fireNgEvent('onBlur', [e]);
  345. });
  346. };
  347. DxCheckBoxComponent.prototype.ngOnDestroy = function () {
  348. this._destroyWidget();
  349. };
  350. DxCheckBoxComponent.decorators = [
  351. { type: core_1.Component, args: [{
  352. selector: 'dx-check-box',
  353. template: '',
  354. providers: [
  355. template_host_1.DxTemplateHost,
  356. watcher_helper_1.WatcherHelper,
  357. CUSTOM_VALUE_ACCESSOR_PROVIDER,
  358. nested_option_1.NestedOptionHost
  359. ]
  360. },] },
  361. ];
  362. /** @nocollapse */
  363. DxCheckBoxComponent.ctorParameters = function () { return [
  364. { type: core_1.ElementRef, },
  365. { type: core_1.NgZone, },
  366. { type: template_host_1.DxTemplateHost, },
  367. { type: watcher_helper_1.WatcherHelper, },
  368. { type: nested_option_1.NestedOptionHost, },
  369. { type: platform_browser_2.TransferState, },
  370. { type: undefined, decorators: [{ type: core_1.Inject, args: [core_1.PLATFORM_ID,] },] },
  371. ]; };
  372. DxCheckBoxComponent.propDecorators = {
  373. "accessKey": [{ type: core_1.Input },],
  374. "activeStateEnabled": [{ type: core_1.Input },],
  375. "disabled": [{ type: core_1.Input },],
  376. "elementAttr": [{ type: core_1.Input },],
  377. "focusStateEnabled": [{ type: core_1.Input },],
  378. "height": [{ type: core_1.Input },],
  379. "hint": [{ type: core_1.Input },],
  380. "hoverStateEnabled": [{ type: core_1.Input },],
  381. "isValid": [{ type: core_1.Input },],
  382. "name": [{ type: core_1.Input },],
  383. "readOnly": [{ type: core_1.Input },],
  384. "rtlEnabled": [{ type: core_1.Input },],
  385. "tabIndex": [{ type: core_1.Input },],
  386. "text": [{ type: core_1.Input },],
  387. "validationError": [{ type: core_1.Input },],
  388. "validationMessageMode": [{ type: core_1.Input },],
  389. "value": [{ type: core_1.Input },],
  390. "visible": [{ type: core_1.Input },],
  391. "width": [{ type: core_1.Input },],
  392. "onContentReady": [{ type: core_1.Output },],
  393. "onDisposing": [{ type: core_1.Output },],
  394. "onInitialized": [{ type: core_1.Output },],
  395. "onOptionChanged": [{ type: core_1.Output },],
  396. "onValueChanged": [{ type: core_1.Output },],
  397. "accessKeyChange": [{ type: core_1.Output },],
  398. "activeStateEnabledChange": [{ type: core_1.Output },],
  399. "disabledChange": [{ type: core_1.Output },],
  400. "elementAttrChange": [{ type: core_1.Output },],
  401. "focusStateEnabledChange": [{ type: core_1.Output },],
  402. "heightChange": [{ type: core_1.Output },],
  403. "hintChange": [{ type: core_1.Output },],
  404. "hoverStateEnabledChange": [{ type: core_1.Output },],
  405. "isValidChange": [{ type: core_1.Output },],
  406. "nameChange": [{ type: core_1.Output },],
  407. "readOnlyChange": [{ type: core_1.Output },],
  408. "rtlEnabledChange": [{ type: core_1.Output },],
  409. "tabIndexChange": [{ type: core_1.Output },],
  410. "textChange": [{ type: core_1.Output },],
  411. "validationErrorChange": [{ type: core_1.Output },],
  412. "validationMessageModeChange": [{ type: core_1.Output },],
  413. "valueChange": [{ type: core_1.Output },],
  414. "visibleChange": [{ type: core_1.Output },],
  415. "widthChange": [{ type: core_1.Output },],
  416. "onBlur": [{ type: core_1.Output },],
  417. "change": [{ type: core_1.HostListener, args: ['valueChange', ['$event'],] },],
  418. "touched": [{ type: core_1.HostListener, args: ['onBlur', ['$event'],] },],
  419. };
  420. return DxCheckBoxComponent;
  421. }(component_1.DxComponent));
  422. exports.DxCheckBoxComponent = DxCheckBoxComponent;
  423. var DxCheckBoxModule = (function () {
  424. function DxCheckBoxModule() {
  425. }
  426. DxCheckBoxModule.decorators = [
  427. { type: core_1.NgModule, args: [{
  428. imports: [
  429. integration_1.DxIntegrationModule,
  430. template_1.DxTemplateModule,
  431. platform_browser_1.BrowserTransferStateModule
  432. ],
  433. declarations: [
  434. DxCheckBoxComponent
  435. ],
  436. exports: [
  437. DxCheckBoxComponent,
  438. template_1.DxTemplateModule
  439. ]
  440. },] },
  441. ];
  442. return DxCheckBoxModule;
  443. }());
  444. exports.DxCheckBoxModule = DxCheckBoxModule;
  445. //# sourceMappingURL=check-box.js.map