multi-view.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  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 multi_view_1 = require("devextreme/ui/multi_view");
  29. var component_1 = require("../core/component");
  30. var template_host_1 = require("../core/template-host");
  31. var integration_1 = require("../core/integration");
  32. var template_1 = require("../core/template");
  33. var nested_option_1 = require("../core/nested-option");
  34. var watcher_helper_1 = require("../core/watcher-helper");
  35. var iterable_differ_helper_1 = require("../core/iterable-differ-helper");
  36. var item_dxi_1 = require("./nested/item-dxi");
  37. var item_dxi_2 = require("./nested/item-dxi");
  38. /**
  39. * The MultiView is a widget that contains several views. An end user navigates through the views by swiping them in the horizontal direction.
  40. */
  41. var DxMultiViewComponent = (function (_super) {
  42. __extends(DxMultiViewComponent, _super);
  43. function DxMultiViewComponent(elementRef, ngZone, templateHost, _watcherHelper, _idh, optionHost, transferState, platformId) {
  44. var _this = _super.call(this, elementRef, ngZone, templateHost, _watcherHelper, transferState, platformId) || this;
  45. _this._watcherHelper = _watcherHelper;
  46. _this._idh = _idh;
  47. _this._createEventEmitters([
  48. { subscribe: 'contentReady', emit: 'onContentReady' },
  49. { subscribe: 'disposing', emit: 'onDisposing' },
  50. { subscribe: 'initialized', emit: 'onInitialized' },
  51. { subscribe: 'itemClick', emit: 'onItemClick' },
  52. { subscribe: 'itemContextMenu', emit: 'onItemContextMenu' },
  53. { subscribe: 'itemHold', emit: 'onItemHold' },
  54. { subscribe: 'itemRendered', emit: 'onItemRendered' },
  55. { subscribe: 'optionChanged', emit: 'onOptionChanged' },
  56. { subscribe: 'selectionChanged', emit: 'onSelectionChanged' },
  57. { emit: 'accessKeyChange' },
  58. { emit: 'activeStateEnabledChange' },
  59. { emit: 'animationEnabledChange' },
  60. { emit: 'dataSourceChange' },
  61. { emit: 'deferRenderingChange' },
  62. { emit: 'disabledChange' },
  63. { emit: 'elementAttrChange' },
  64. { emit: 'focusStateEnabledChange' },
  65. { emit: 'heightChange' },
  66. { emit: 'hintChange' },
  67. { emit: 'hoverStateEnabledChange' },
  68. { emit: 'itemHoldTimeoutChange' },
  69. { emit: 'itemsChange' },
  70. { emit: 'itemTemplateChange' },
  71. { emit: 'loopChange' },
  72. { emit: 'noDataTextChange' },
  73. { emit: 'rtlEnabledChange' },
  74. { emit: 'selectedIndexChange' },
  75. { emit: 'selectedItemChange' },
  76. { emit: 'swipeEnabledChange' },
  77. { emit: 'tabIndexChange' },
  78. { emit: 'visibleChange' },
  79. { emit: 'widthChange' }
  80. ]);
  81. _this._idh.setHost(_this);
  82. optionHost.setHost(_this);
  83. return _this;
  84. }
  85. Object.defineProperty(DxMultiViewComponent.prototype, "accessKey", {
  86. get: /**
  87. * Specifies the shortcut key that sets focus on the widget.
  88. */
  89. function () {
  90. return this._getOption('accessKey');
  91. },
  92. set: function (value) {
  93. this._setOption('accessKey', value);
  94. },
  95. enumerable: true,
  96. configurable: true
  97. });
  98. Object.defineProperty(DxMultiViewComponent.prototype, "activeStateEnabled", {
  99. get: /**
  100. * Specifies whether or not the widget changes its state when interacting with a user.
  101. */
  102. function () {
  103. return this._getOption('activeStateEnabled');
  104. },
  105. set: function (value) {
  106. this._setOption('activeStateEnabled', value);
  107. },
  108. enumerable: true,
  109. configurable: true
  110. });
  111. Object.defineProperty(DxMultiViewComponent.prototype, "animationEnabled", {
  112. get: /**
  113. * Specifies whether or not to animate the displayed item change.
  114. */
  115. function () {
  116. return this._getOption('animationEnabled');
  117. },
  118. set: function (value) {
  119. this._setOption('animationEnabled', value);
  120. },
  121. enumerable: true,
  122. configurable: true
  123. });
  124. Object.defineProperty(DxMultiViewComponent.prototype, "dataSource", {
  125. get: /**
  126. * Binds the widget to data.
  127. */
  128. function () {
  129. return this._getOption('dataSource');
  130. },
  131. set: function (value) {
  132. this._setOption('dataSource', value);
  133. },
  134. enumerable: true,
  135. configurable: true
  136. });
  137. Object.defineProperty(DxMultiViewComponent.prototype, "deferRendering", {
  138. get: /**
  139. * Specifies whether to render the view's content when it is displayed. If false, the content is rendered immediately.
  140. */
  141. function () {
  142. return this._getOption('deferRendering');
  143. },
  144. set: function (value) {
  145. this._setOption('deferRendering', value);
  146. },
  147. enumerable: true,
  148. configurable: true
  149. });
  150. Object.defineProperty(DxMultiViewComponent.prototype, "disabled", {
  151. get: /**
  152. * Specifies whether the widget responds to user interaction.
  153. */
  154. function () {
  155. return this._getOption('disabled');
  156. },
  157. set: function (value) {
  158. this._setOption('disabled', value);
  159. },
  160. enumerable: true,
  161. configurable: true
  162. });
  163. Object.defineProperty(DxMultiViewComponent.prototype, "elementAttr", {
  164. get: /**
  165. * Specifies the attributes to be attached to the widget's root element.
  166. */
  167. function () {
  168. return this._getOption('elementAttr');
  169. },
  170. set: function (value) {
  171. this._setOption('elementAttr', value);
  172. },
  173. enumerable: true,
  174. configurable: true
  175. });
  176. Object.defineProperty(DxMultiViewComponent.prototype, "focusStateEnabled", {
  177. get: /**
  178. * Specifies whether the widget can be focused using keyboard navigation.
  179. */
  180. function () {
  181. return this._getOption('focusStateEnabled');
  182. },
  183. set: function (value) {
  184. this._setOption('focusStateEnabled', value);
  185. },
  186. enumerable: true,
  187. configurable: true
  188. });
  189. Object.defineProperty(DxMultiViewComponent.prototype, "height", {
  190. get: /**
  191. * Specifies the widget's height.
  192. */
  193. function () {
  194. return this._getOption('height');
  195. },
  196. set: function (value) {
  197. this._setOption('height', value);
  198. },
  199. enumerable: true,
  200. configurable: true
  201. });
  202. Object.defineProperty(DxMultiViewComponent.prototype, "hint", {
  203. get: /**
  204. * Specifies text for a hint that appears when a user pauses on the widget.
  205. */
  206. function () {
  207. return this._getOption('hint');
  208. },
  209. set: function (value) {
  210. this._setOption('hint', value);
  211. },
  212. enumerable: true,
  213. configurable: true
  214. });
  215. Object.defineProperty(DxMultiViewComponent.prototype, "hoverStateEnabled", {
  216. get: /**
  217. * Specifies whether the widget changes its state when a user pauses on it.
  218. */
  219. function () {
  220. return this._getOption('hoverStateEnabled');
  221. },
  222. set: function (value) {
  223. this._setOption('hoverStateEnabled', value);
  224. },
  225. enumerable: true,
  226. configurable: true
  227. });
  228. Object.defineProperty(DxMultiViewComponent.prototype, "itemHoldTimeout", {
  229. get: /**
  230. * The time period in milliseconds before the onItemHold event is raised.
  231. */
  232. function () {
  233. return this._getOption('itemHoldTimeout');
  234. },
  235. set: function (value) {
  236. this._setOption('itemHoldTimeout', value);
  237. },
  238. enumerable: true,
  239. configurable: true
  240. });
  241. Object.defineProperty(DxMultiViewComponent.prototype, "items", {
  242. get: /**
  243. * An array of items displayed by the widget.
  244. */
  245. function () {
  246. return this._getOption('items');
  247. },
  248. set: function (value) {
  249. this._setOption('items', value);
  250. },
  251. enumerable: true,
  252. configurable: true
  253. });
  254. Object.defineProperty(DxMultiViewComponent.prototype, "itemTemplate", {
  255. get: /**
  256. * Specifies a custom template for items.
  257. */
  258. function () {
  259. return this._getOption('itemTemplate');
  260. },
  261. set: function (value) {
  262. this._setOption('itemTemplate', value);
  263. },
  264. enumerable: true,
  265. configurable: true
  266. });
  267. Object.defineProperty(DxMultiViewComponent.prototype, "loop", {
  268. get: /**
  269. * A Boolean value specifying whether or not to scroll back to the first item after the last item is swiped.
  270. */
  271. function () {
  272. return this._getOption('loop');
  273. },
  274. set: function (value) {
  275. this._setOption('loop', value);
  276. },
  277. enumerable: true,
  278. configurable: true
  279. });
  280. Object.defineProperty(DxMultiViewComponent.prototype, "noDataText", {
  281. get: /**
  282. * The text or HTML markup displayed by the widget if the item collection is empty.
  283. */
  284. function () {
  285. return this._getOption('noDataText');
  286. },
  287. set: function (value) {
  288. this._setOption('noDataText', value);
  289. },
  290. enumerable: true,
  291. configurable: true
  292. });
  293. Object.defineProperty(DxMultiViewComponent.prototype, "rtlEnabled", {
  294. get: /**
  295. * Switches the widget to a right-to-left representation.
  296. */
  297. function () {
  298. return this._getOption('rtlEnabled');
  299. },
  300. set: function (value) {
  301. this._setOption('rtlEnabled', value);
  302. },
  303. enumerable: true,
  304. configurable: true
  305. });
  306. Object.defineProperty(DxMultiViewComponent.prototype, "selectedIndex", {
  307. get: /**
  308. * The index of the currently displayed item.
  309. */
  310. function () {
  311. return this._getOption('selectedIndex');
  312. },
  313. set: function (value) {
  314. this._setOption('selectedIndex', value);
  315. },
  316. enumerable: true,
  317. configurable: true
  318. });
  319. Object.defineProperty(DxMultiViewComponent.prototype, "selectedItem", {
  320. get: /**
  321. * The selected item object.
  322. */
  323. function () {
  324. return this._getOption('selectedItem');
  325. },
  326. set: function (value) {
  327. this._setOption('selectedItem', value);
  328. },
  329. enumerable: true,
  330. configurable: true
  331. });
  332. Object.defineProperty(DxMultiViewComponent.prototype, "swipeEnabled", {
  333. get: /**
  334. * A Boolean value specifying whether or not to allow users to change the selected index by swiping.
  335. */
  336. function () {
  337. return this._getOption('swipeEnabled');
  338. },
  339. set: function (value) {
  340. this._setOption('swipeEnabled', value);
  341. },
  342. enumerable: true,
  343. configurable: true
  344. });
  345. Object.defineProperty(DxMultiViewComponent.prototype, "tabIndex", {
  346. get: /**
  347. * Specifies the number of the element when the Tab key is used for navigating.
  348. */
  349. function () {
  350. return this._getOption('tabIndex');
  351. },
  352. set: function (value) {
  353. this._setOption('tabIndex', value);
  354. },
  355. enumerable: true,
  356. configurable: true
  357. });
  358. Object.defineProperty(DxMultiViewComponent.prototype, "visible", {
  359. get: /**
  360. * Specifies whether the widget is visible.
  361. */
  362. function () {
  363. return this._getOption('visible');
  364. },
  365. set: function (value) {
  366. this._setOption('visible', value);
  367. },
  368. enumerable: true,
  369. configurable: true
  370. });
  371. Object.defineProperty(DxMultiViewComponent.prototype, "width", {
  372. get: /**
  373. * Specifies the widget's width.
  374. */
  375. function () {
  376. return this._getOption('width');
  377. },
  378. set: function (value) {
  379. this._setOption('width', value);
  380. },
  381. enumerable: true,
  382. configurable: true
  383. });
  384. Object.defineProperty(DxMultiViewComponent.prototype, "itemsChildren", {
  385. get: function () {
  386. return this._getOption('items');
  387. },
  388. set: function (value) {
  389. this.setChildren('items', value);
  390. },
  391. enumerable: true,
  392. configurable: true
  393. });
  394. DxMultiViewComponent.prototype._createInstance = function (element, options) {
  395. return new multi_view_1.default(element, options);
  396. };
  397. DxMultiViewComponent.prototype.ngOnDestroy = function () {
  398. this._destroyWidget();
  399. };
  400. DxMultiViewComponent.prototype.ngOnChanges = function (changes) {
  401. _super.prototype.ngOnChanges.call(this, changes);
  402. this.setupChanges('dataSource', changes);
  403. this.setupChanges('items', changes);
  404. };
  405. DxMultiViewComponent.prototype.setupChanges = function (prop, changes) {
  406. if (!(prop in this._optionsToUpdate)) {
  407. this._idh.setup(prop, changes);
  408. }
  409. };
  410. DxMultiViewComponent.prototype.ngDoCheck = function () {
  411. this._idh.doCheck('dataSource');
  412. this._idh.doCheck('items');
  413. this._watcherHelper.checkWatchers();
  414. _super.prototype.ngDoCheck.call(this);
  415. _super.prototype.clearChangedOptions.call(this);
  416. };
  417. DxMultiViewComponent.prototype._setOption = function (name, value) {
  418. var isSetup = this._idh.setupSingle(name, value);
  419. var isChanged = this._idh.getChanges(name, value) !== null;
  420. if (isSetup || isChanged) {
  421. _super.prototype._setOption.call(this, name, value);
  422. }
  423. };
  424. DxMultiViewComponent.decorators = [
  425. { type: core_1.Component, args: [{
  426. selector: 'dx-multi-view',
  427. template: '',
  428. providers: [
  429. template_host_1.DxTemplateHost,
  430. watcher_helper_1.WatcherHelper,
  431. nested_option_1.NestedOptionHost,
  432. iterable_differ_helper_1.IterableDifferHelper
  433. ]
  434. },] },
  435. ];
  436. /** @nocollapse */
  437. DxMultiViewComponent.ctorParameters = function () { return [
  438. { type: core_1.ElementRef, },
  439. { type: core_1.NgZone, },
  440. { type: template_host_1.DxTemplateHost, },
  441. { type: watcher_helper_1.WatcherHelper, },
  442. { type: iterable_differ_helper_1.IterableDifferHelper, },
  443. { type: nested_option_1.NestedOptionHost, },
  444. { type: platform_browser_2.TransferState, },
  445. { type: undefined, decorators: [{ type: core_1.Inject, args: [core_1.PLATFORM_ID,] },] },
  446. ]; };
  447. DxMultiViewComponent.propDecorators = {
  448. "accessKey": [{ type: core_1.Input },],
  449. "activeStateEnabled": [{ type: core_1.Input },],
  450. "animationEnabled": [{ type: core_1.Input },],
  451. "dataSource": [{ type: core_1.Input },],
  452. "deferRendering": [{ type: core_1.Input },],
  453. "disabled": [{ type: core_1.Input },],
  454. "elementAttr": [{ type: core_1.Input },],
  455. "focusStateEnabled": [{ type: core_1.Input },],
  456. "height": [{ type: core_1.Input },],
  457. "hint": [{ type: core_1.Input },],
  458. "hoverStateEnabled": [{ type: core_1.Input },],
  459. "itemHoldTimeout": [{ type: core_1.Input },],
  460. "items": [{ type: core_1.Input },],
  461. "itemTemplate": [{ type: core_1.Input },],
  462. "loop": [{ type: core_1.Input },],
  463. "noDataText": [{ type: core_1.Input },],
  464. "rtlEnabled": [{ type: core_1.Input },],
  465. "selectedIndex": [{ type: core_1.Input },],
  466. "selectedItem": [{ type: core_1.Input },],
  467. "swipeEnabled": [{ type: core_1.Input },],
  468. "tabIndex": [{ type: core_1.Input },],
  469. "visible": [{ type: core_1.Input },],
  470. "width": [{ type: core_1.Input },],
  471. "onContentReady": [{ type: core_1.Output },],
  472. "onDisposing": [{ type: core_1.Output },],
  473. "onInitialized": [{ type: core_1.Output },],
  474. "onItemClick": [{ type: core_1.Output },],
  475. "onItemContextMenu": [{ type: core_1.Output },],
  476. "onItemHold": [{ type: core_1.Output },],
  477. "onItemRendered": [{ type: core_1.Output },],
  478. "onOptionChanged": [{ type: core_1.Output },],
  479. "onSelectionChanged": [{ type: core_1.Output },],
  480. "accessKeyChange": [{ type: core_1.Output },],
  481. "activeStateEnabledChange": [{ type: core_1.Output },],
  482. "animationEnabledChange": [{ type: core_1.Output },],
  483. "dataSourceChange": [{ type: core_1.Output },],
  484. "deferRenderingChange": [{ type: core_1.Output },],
  485. "disabledChange": [{ type: core_1.Output },],
  486. "elementAttrChange": [{ type: core_1.Output },],
  487. "focusStateEnabledChange": [{ type: core_1.Output },],
  488. "heightChange": [{ type: core_1.Output },],
  489. "hintChange": [{ type: core_1.Output },],
  490. "hoverStateEnabledChange": [{ type: core_1.Output },],
  491. "itemHoldTimeoutChange": [{ type: core_1.Output },],
  492. "itemsChange": [{ type: core_1.Output },],
  493. "itemTemplateChange": [{ type: core_1.Output },],
  494. "loopChange": [{ type: core_1.Output },],
  495. "noDataTextChange": [{ type: core_1.Output },],
  496. "rtlEnabledChange": [{ type: core_1.Output },],
  497. "selectedIndexChange": [{ type: core_1.Output },],
  498. "selectedItemChange": [{ type: core_1.Output },],
  499. "swipeEnabledChange": [{ type: core_1.Output },],
  500. "tabIndexChange": [{ type: core_1.Output },],
  501. "visibleChange": [{ type: core_1.Output },],
  502. "widthChange": [{ type: core_1.Output },],
  503. "itemsChildren": [{ type: core_1.ContentChildren, args: [item_dxi_2.DxiItemComponent,] },],
  504. };
  505. return DxMultiViewComponent;
  506. }(component_1.DxComponent));
  507. exports.DxMultiViewComponent = DxMultiViewComponent;
  508. var DxMultiViewModule = (function () {
  509. function DxMultiViewModule() {
  510. }
  511. DxMultiViewModule.decorators = [
  512. { type: core_1.NgModule, args: [{
  513. imports: [
  514. item_dxi_1.DxiItemModule,
  515. integration_1.DxIntegrationModule,
  516. template_1.DxTemplateModule,
  517. platform_browser_1.BrowserTransferStateModule
  518. ],
  519. declarations: [
  520. DxMultiViewComponent
  521. ],
  522. exports: [
  523. DxMultiViewComponent,
  524. item_dxi_1.DxiItemModule,
  525. template_1.DxTemplateModule
  526. ]
  527. },] },
  528. ];
  529. return DxMultiViewModule;
  530. }());
  531. exports.DxMultiViewModule = DxMultiViewModule;
  532. //# sourceMappingURL=multi-view.js.map