slider.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  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 slider_1 = require("devextreme/ui/slider");
  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 label_1 = require("./nested/label");
  37. var format_1 = require("./nested/format");
  38. var tooltip_1 = require("./nested/tooltip");
  39. var CUSTOM_VALUE_ACCESSOR_PROVIDER = {
  40. provide: forms_1.NG_VALUE_ACCESSOR,
  41. useExisting: core_1.forwardRef(function () { return DxSliderComponent; }),
  42. multi: true
  43. };
  44. /**
  45. * The Slider is a widget that allows an end user to set a numeric value on a continuous range of possible values.
  46. */
  47. var DxSliderComponent = (function (_super) {
  48. __extends(DxSliderComponent, _super);
  49. function DxSliderComponent(elementRef, ngZone, templateHost, _watcherHelper, optionHost, transferState, platformId) {
  50. var _this = _super.call(this, elementRef, ngZone, templateHost, _watcherHelper, transferState, platformId) || this;
  51. _this.touched = function (_) { };
  52. _this._createEventEmitters([
  53. { subscribe: 'contentReady', emit: 'onContentReady' },
  54. { subscribe: 'disposing', emit: 'onDisposing' },
  55. { subscribe: 'initialized', emit: 'onInitialized' },
  56. { subscribe: 'optionChanged', emit: 'onOptionChanged' },
  57. { subscribe: 'valueChanged', emit: 'onValueChanged' },
  58. { emit: 'accessKeyChange' },
  59. { emit: 'activeStateEnabledChange' },
  60. { emit: 'disabledChange' },
  61. { emit: 'elementAttrChange' },
  62. { emit: 'focusStateEnabledChange' },
  63. { emit: 'heightChange' },
  64. { emit: 'hintChange' },
  65. { emit: 'hoverStateEnabledChange' },
  66. { emit: 'isValidChange' },
  67. { emit: 'keyStepChange' },
  68. { emit: 'labelChange' },
  69. { emit: 'maxChange' },
  70. { emit: 'minChange' },
  71. { emit: 'nameChange' },
  72. { emit: 'readOnlyChange' },
  73. { emit: 'rtlEnabledChange' },
  74. { emit: 'showRangeChange' },
  75. { emit: 'stepChange' },
  76. { emit: 'tabIndexChange' },
  77. { emit: 'tooltipChange' },
  78. { emit: 'validationErrorChange' },
  79. { emit: 'validationMessageModeChange' },
  80. { emit: 'valueChange' },
  81. { emit: 'visibleChange' },
  82. { emit: 'widthChange' },
  83. { emit: 'onBlur' }
  84. ]);
  85. optionHost.setHost(_this);
  86. return _this;
  87. }
  88. Object.defineProperty(DxSliderComponent.prototype, "accessKey", {
  89. get: /**
  90. * Specifies the shortcut key that sets focus on the widget.
  91. */
  92. function () {
  93. return this._getOption('accessKey');
  94. },
  95. set: function (value) {
  96. this._setOption('accessKey', value);
  97. },
  98. enumerable: true,
  99. configurable: true
  100. });
  101. Object.defineProperty(DxSliderComponent.prototype, "activeStateEnabled", {
  102. get: /**
  103. * Specifies whether or not the widget changes its state when interacting with a user.
  104. */
  105. function () {
  106. return this._getOption('activeStateEnabled');
  107. },
  108. set: function (value) {
  109. this._setOption('activeStateEnabled', value);
  110. },
  111. enumerable: true,
  112. configurable: true
  113. });
  114. Object.defineProperty(DxSliderComponent.prototype, "disabled", {
  115. get: /**
  116. * Specifies whether the widget responds to user interaction.
  117. */
  118. function () {
  119. return this._getOption('disabled');
  120. },
  121. set: function (value) {
  122. this._setOption('disabled', value);
  123. },
  124. enumerable: true,
  125. configurable: true
  126. });
  127. Object.defineProperty(DxSliderComponent.prototype, "elementAttr", {
  128. get: /**
  129. * Specifies the attributes to be attached to the widget's root element.
  130. */
  131. function () {
  132. return this._getOption('elementAttr');
  133. },
  134. set: function (value) {
  135. this._setOption('elementAttr', value);
  136. },
  137. enumerable: true,
  138. configurable: true
  139. });
  140. Object.defineProperty(DxSliderComponent.prototype, "focusStateEnabled", {
  141. get: /**
  142. * Specifies whether the widget can be focused using keyboard navigation.
  143. */
  144. function () {
  145. return this._getOption('focusStateEnabled');
  146. },
  147. set: function (value) {
  148. this._setOption('focusStateEnabled', value);
  149. },
  150. enumerable: true,
  151. configurable: true
  152. });
  153. Object.defineProperty(DxSliderComponent.prototype, "height", {
  154. get: /**
  155. * Specifies the widget's height.
  156. */
  157. function () {
  158. return this._getOption('height');
  159. },
  160. set: function (value) {
  161. this._setOption('height', value);
  162. },
  163. enumerable: true,
  164. configurable: true
  165. });
  166. Object.defineProperty(DxSliderComponent.prototype, "hint", {
  167. get: /**
  168. * Specifies text for a hint that appears when a user pauses on the widget.
  169. */
  170. function () {
  171. return this._getOption('hint');
  172. },
  173. set: function (value) {
  174. this._setOption('hint', value);
  175. },
  176. enumerable: true,
  177. configurable: true
  178. });
  179. Object.defineProperty(DxSliderComponent.prototype, "hoverStateEnabled", {
  180. get: /**
  181. * Specifies whether the widget changes its state when a user pauses on it.
  182. */
  183. function () {
  184. return this._getOption('hoverStateEnabled');
  185. },
  186. set: function (value) {
  187. this._setOption('hoverStateEnabled', value);
  188. },
  189. enumerable: true,
  190. configurable: true
  191. });
  192. Object.defineProperty(DxSliderComponent.prototype, "isValid", {
  193. get: /**
  194. * Specifies whether the editor's value is valid.
  195. */
  196. function () {
  197. return this._getOption('isValid');
  198. },
  199. set: function (value) {
  200. this._setOption('isValid', value);
  201. },
  202. enumerable: true,
  203. configurable: true
  204. });
  205. Object.defineProperty(DxSliderComponent.prototype, "keyStep", {
  206. get: /**
  207. * Specifies the step by which a handle moves when a user presses Page Up or Page Down.
  208. */
  209. function () {
  210. return this._getOption('keyStep');
  211. },
  212. set: function (value) {
  213. this._setOption('keyStep', value);
  214. },
  215. enumerable: true,
  216. configurable: true
  217. });
  218. Object.defineProperty(DxSliderComponent.prototype, "label", {
  219. get: /**
  220. * Configures the labels displayed at the min and max values.
  221. */
  222. function () {
  223. return this._getOption('label');
  224. },
  225. set: function (value) {
  226. this._setOption('label', value);
  227. },
  228. enumerable: true,
  229. configurable: true
  230. });
  231. Object.defineProperty(DxSliderComponent.prototype, "max", {
  232. get: /**
  233. * The maximum value the widget can accept.
  234. */
  235. function () {
  236. return this._getOption('max');
  237. },
  238. set: function (value) {
  239. this._setOption('max', value);
  240. },
  241. enumerable: true,
  242. configurable: true
  243. });
  244. Object.defineProperty(DxSliderComponent.prototype, "min", {
  245. get: /**
  246. * The minimum value the widget can accept.
  247. */
  248. function () {
  249. return this._getOption('min');
  250. },
  251. set: function (value) {
  252. this._setOption('min', value);
  253. },
  254. enumerable: true,
  255. configurable: true
  256. });
  257. Object.defineProperty(DxSliderComponent.prototype, "name", {
  258. get: /**
  259. * The value to be assigned to the `name` attribute of the underlying HTML element.
  260. */
  261. function () {
  262. return this._getOption('name');
  263. },
  264. set: function (value) {
  265. this._setOption('name', value);
  266. },
  267. enumerable: true,
  268. configurable: true
  269. });
  270. Object.defineProperty(DxSliderComponent.prototype, "readOnly", {
  271. get: /**
  272. * Specifies whether the editor is read-only.
  273. */
  274. function () {
  275. return this._getOption('readOnly');
  276. },
  277. set: function (value) {
  278. this._setOption('readOnly', value);
  279. },
  280. enumerable: true,
  281. configurable: true
  282. });
  283. Object.defineProperty(DxSliderComponent.prototype, "rtlEnabled", {
  284. get: /**
  285. * Switches the widget to a right-to-left representation.
  286. */
  287. function () {
  288. return this._getOption('rtlEnabled');
  289. },
  290. set: function (value) {
  291. this._setOption('rtlEnabled', value);
  292. },
  293. enumerable: true,
  294. configurable: true
  295. });
  296. Object.defineProperty(DxSliderComponent.prototype, "showRange", {
  297. get: /**
  298. * Specifies whether to highlight the selected range.
  299. */
  300. function () {
  301. return this._getOption('showRange');
  302. },
  303. set: function (value) {
  304. this._setOption('showRange', value);
  305. },
  306. enumerable: true,
  307. configurable: true
  308. });
  309. Object.defineProperty(DxSliderComponent.prototype, "step", {
  310. get: /**
  311. * Specifies the step by which the widget's value changes when a user drags a handler.
  312. */
  313. function () {
  314. return this._getOption('step');
  315. },
  316. set: function (value) {
  317. this._setOption('step', value);
  318. },
  319. enumerable: true,
  320. configurable: true
  321. });
  322. Object.defineProperty(DxSliderComponent.prototype, "tabIndex", {
  323. get: /**
  324. * Specifies the number of the element when the Tab key is used for navigating.
  325. */
  326. function () {
  327. return this._getOption('tabIndex');
  328. },
  329. set: function (value) {
  330. this._setOption('tabIndex', value);
  331. },
  332. enumerable: true,
  333. configurable: true
  334. });
  335. Object.defineProperty(DxSliderComponent.prototype, "tooltip", {
  336. get: /**
  337. * Configures a tooltip.
  338. */
  339. function () {
  340. return this._getOption('tooltip');
  341. },
  342. set: function (value) {
  343. this._setOption('tooltip', value);
  344. },
  345. enumerable: true,
  346. configurable: true
  347. });
  348. Object.defineProperty(DxSliderComponent.prototype, "validationError", {
  349. get: /**
  350. * Specifies information on the validation error when using a custom validation engine. Should be changed at runtime along with the isValid option.
  351. */
  352. function () {
  353. return this._getOption('validationError');
  354. },
  355. set: function (value) {
  356. this._setOption('validationError', value);
  357. },
  358. enumerable: true,
  359. configurable: true
  360. });
  361. Object.defineProperty(DxSliderComponent.prototype, "validationMessageMode", {
  362. get: /**
  363. * Specifies how the message about the validation rules that are not satisfied by this editor's value is displayed.
  364. */
  365. function () {
  366. return this._getOption('validationMessageMode');
  367. },
  368. set: function (value) {
  369. this._setOption('validationMessageMode', value);
  370. },
  371. enumerable: true,
  372. configurable: true
  373. });
  374. Object.defineProperty(DxSliderComponent.prototype, "value", {
  375. get: /**
  376. * The current slider value.
  377. */
  378. function () {
  379. return this._getOption('value');
  380. },
  381. set: function (value) {
  382. this._setOption('value', value);
  383. },
  384. enumerable: true,
  385. configurable: true
  386. });
  387. Object.defineProperty(DxSliderComponent.prototype, "visible", {
  388. get: /**
  389. * Specifies whether the widget is visible.
  390. */
  391. function () {
  392. return this._getOption('visible');
  393. },
  394. set: function (value) {
  395. this._setOption('visible', value);
  396. },
  397. enumerable: true,
  398. configurable: true
  399. });
  400. Object.defineProperty(DxSliderComponent.prototype, "width", {
  401. get: /**
  402. * Specifies the widget's width.
  403. */
  404. function () {
  405. return this._getOption('width');
  406. },
  407. set: function (value) {
  408. this._setOption('width', value);
  409. },
  410. enumerable: true,
  411. configurable: true
  412. });
  413. DxSliderComponent.prototype.change = function (_) { };
  414. DxSliderComponent.prototype._createInstance = function (element, options) {
  415. return new slider_1.default(element, options);
  416. };
  417. DxSliderComponent.prototype.writeValue = function (value) {
  418. this.eventHelper.lockedValueChangeEvent = true;
  419. this.value = value;
  420. this.eventHelper.lockedValueChangeEvent = false;
  421. };
  422. DxSliderComponent.prototype.setDisabledState = function (isDisabled) {
  423. this.disabled = isDisabled;
  424. };
  425. DxSliderComponent.prototype.registerOnChange = function (fn) { this.change = fn; };
  426. DxSliderComponent.prototype.registerOnTouched = function (fn) { this.touched = fn; };
  427. DxSliderComponent.prototype._createWidget = function (element) {
  428. var _this = this;
  429. _super.prototype._createWidget.call(this, element);
  430. this.instance.on('focusOut', function (e) {
  431. _this.eventHelper.fireNgEvent('onBlur', [e]);
  432. });
  433. };
  434. DxSliderComponent.prototype.ngOnDestroy = function () {
  435. this._destroyWidget();
  436. };
  437. DxSliderComponent.decorators = [
  438. { type: core_1.Component, args: [{
  439. selector: 'dx-slider',
  440. template: '',
  441. providers: [
  442. template_host_1.DxTemplateHost,
  443. watcher_helper_1.WatcherHelper,
  444. CUSTOM_VALUE_ACCESSOR_PROVIDER,
  445. nested_option_1.NestedOptionHost
  446. ]
  447. },] },
  448. ];
  449. /** @nocollapse */
  450. DxSliderComponent.ctorParameters = function () { return [
  451. { type: core_1.ElementRef, },
  452. { type: core_1.NgZone, },
  453. { type: template_host_1.DxTemplateHost, },
  454. { type: watcher_helper_1.WatcherHelper, },
  455. { type: nested_option_1.NestedOptionHost, },
  456. { type: platform_browser_2.TransferState, },
  457. { type: undefined, decorators: [{ type: core_1.Inject, args: [core_1.PLATFORM_ID,] },] },
  458. ]; };
  459. DxSliderComponent.propDecorators = {
  460. "accessKey": [{ type: core_1.Input },],
  461. "activeStateEnabled": [{ type: core_1.Input },],
  462. "disabled": [{ type: core_1.Input },],
  463. "elementAttr": [{ type: core_1.Input },],
  464. "focusStateEnabled": [{ type: core_1.Input },],
  465. "height": [{ type: core_1.Input },],
  466. "hint": [{ type: core_1.Input },],
  467. "hoverStateEnabled": [{ type: core_1.Input },],
  468. "isValid": [{ type: core_1.Input },],
  469. "keyStep": [{ type: core_1.Input },],
  470. "label": [{ type: core_1.Input },],
  471. "max": [{ type: core_1.Input },],
  472. "min": [{ type: core_1.Input },],
  473. "name": [{ type: core_1.Input },],
  474. "readOnly": [{ type: core_1.Input },],
  475. "rtlEnabled": [{ type: core_1.Input },],
  476. "showRange": [{ type: core_1.Input },],
  477. "step": [{ type: core_1.Input },],
  478. "tabIndex": [{ type: core_1.Input },],
  479. "tooltip": [{ type: core_1.Input },],
  480. "validationError": [{ type: core_1.Input },],
  481. "validationMessageMode": [{ type: core_1.Input },],
  482. "value": [{ type: core_1.Input },],
  483. "visible": [{ type: core_1.Input },],
  484. "width": [{ type: core_1.Input },],
  485. "onContentReady": [{ type: core_1.Output },],
  486. "onDisposing": [{ type: core_1.Output },],
  487. "onInitialized": [{ type: core_1.Output },],
  488. "onOptionChanged": [{ type: core_1.Output },],
  489. "onValueChanged": [{ type: core_1.Output },],
  490. "accessKeyChange": [{ type: core_1.Output },],
  491. "activeStateEnabledChange": [{ type: core_1.Output },],
  492. "disabledChange": [{ type: core_1.Output },],
  493. "elementAttrChange": [{ type: core_1.Output },],
  494. "focusStateEnabledChange": [{ type: core_1.Output },],
  495. "heightChange": [{ type: core_1.Output },],
  496. "hintChange": [{ type: core_1.Output },],
  497. "hoverStateEnabledChange": [{ type: core_1.Output },],
  498. "isValidChange": [{ type: core_1.Output },],
  499. "keyStepChange": [{ type: core_1.Output },],
  500. "labelChange": [{ type: core_1.Output },],
  501. "maxChange": [{ type: core_1.Output },],
  502. "minChange": [{ type: core_1.Output },],
  503. "nameChange": [{ type: core_1.Output },],
  504. "readOnlyChange": [{ type: core_1.Output },],
  505. "rtlEnabledChange": [{ type: core_1.Output },],
  506. "showRangeChange": [{ type: core_1.Output },],
  507. "stepChange": [{ type: core_1.Output },],
  508. "tabIndexChange": [{ type: core_1.Output },],
  509. "tooltipChange": [{ type: core_1.Output },],
  510. "validationErrorChange": [{ type: core_1.Output },],
  511. "validationMessageModeChange": [{ type: core_1.Output },],
  512. "valueChange": [{ type: core_1.Output },],
  513. "visibleChange": [{ type: core_1.Output },],
  514. "widthChange": [{ type: core_1.Output },],
  515. "onBlur": [{ type: core_1.Output },],
  516. "change": [{ type: core_1.HostListener, args: ['valueChange', ['$event'],] },],
  517. "touched": [{ type: core_1.HostListener, args: ['onBlur', ['$event'],] },],
  518. };
  519. return DxSliderComponent;
  520. }(component_1.DxComponent));
  521. exports.DxSliderComponent = DxSliderComponent;
  522. var DxSliderModule = (function () {
  523. function DxSliderModule() {
  524. }
  525. DxSliderModule.decorators = [
  526. { type: core_1.NgModule, args: [{
  527. imports: [
  528. label_1.DxoLabelModule,
  529. format_1.DxoFormatModule,
  530. tooltip_1.DxoTooltipModule,
  531. integration_1.DxIntegrationModule,
  532. template_1.DxTemplateModule,
  533. platform_browser_1.BrowserTransferStateModule
  534. ],
  535. declarations: [
  536. DxSliderComponent
  537. ],
  538. exports: [
  539. DxSliderComponent,
  540. label_1.DxoLabelModule,
  541. format_1.DxoFormatModule,
  542. tooltip_1.DxoTooltipModule,
  543. template_1.DxTemplateModule
  544. ]
  545. },] },
  546. ];
  547. return DxSliderModule;
  548. }());
  549. exports.DxSliderModule = DxSliderModule;
  550. //# sourceMappingURL=slider.js.map