tabs.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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 tabs_1 = require("devextreme/ui/tabs");
  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 Tabs is a tab strip used to switch between pages or views. This widget is included in the TabPanel widget, but you can use the Tabs separately as well.
  40. */
  41. var DxTabsComponent = (function (_super) {
  42. __extends(DxTabsComponent, _super);
  43. function DxTabsComponent(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: 'dataSourceChange' },
  59. { emit: 'disabledChange' },
  60. { emit: 'elementAttrChange' },
  61. { emit: 'focusStateEnabledChange' },
  62. { emit: 'heightChange' },
  63. { emit: 'hintChange' },
  64. { emit: 'hoverStateEnabledChange' },
  65. { emit: 'itemHoldTimeoutChange' },
  66. { emit: 'itemsChange' },
  67. { emit: 'itemTemplateChange' },
  68. { emit: 'keyExprChange' },
  69. { emit: 'noDataTextChange' },
  70. { emit: 'repaintChangesOnlyChange' },
  71. { emit: 'rtlEnabledChange' },
  72. { emit: 'scrollByContentChange' },
  73. { emit: 'scrollingEnabledChange' },
  74. { emit: 'selectedIndexChange' },
  75. { emit: 'selectedItemChange' },
  76. { emit: 'selectedItemKeysChange' },
  77. { emit: 'selectedItemsChange' },
  78. { emit: 'selectionModeChange' },
  79. { emit: 'showNavButtonsChange' },
  80. { emit: 'tabIndexChange' },
  81. { emit: 'visibleChange' },
  82. { emit: 'widthChange' }
  83. ]);
  84. _this._idh.setHost(_this);
  85. optionHost.setHost(_this);
  86. return _this;
  87. }
  88. Object.defineProperty(DxTabsComponent.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(DxTabsComponent.prototype, "dataSource", {
  102. get: /**
  103. * Binds the widget to data.
  104. */
  105. function () {
  106. return this._getOption('dataSource');
  107. },
  108. set: function (value) {
  109. this._setOption('dataSource', value);
  110. },
  111. enumerable: true,
  112. configurable: true
  113. });
  114. Object.defineProperty(DxTabsComponent.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(DxTabsComponent.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(DxTabsComponent.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(DxTabsComponent.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(DxTabsComponent.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(DxTabsComponent.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(DxTabsComponent.prototype, "itemHoldTimeout", {
  193. get: /**
  194. * The time period in milliseconds before the onItemHold event is raised.
  195. */
  196. function () {
  197. return this._getOption('itemHoldTimeout');
  198. },
  199. set: function (value) {
  200. this._setOption('itemHoldTimeout', value);
  201. },
  202. enumerable: true,
  203. configurable: true
  204. });
  205. Object.defineProperty(DxTabsComponent.prototype, "items", {
  206. get: /**
  207. * An array of items displayed by the widget.
  208. */
  209. function () {
  210. return this._getOption('items');
  211. },
  212. set: function (value) {
  213. this._setOption('items', value);
  214. },
  215. enumerable: true,
  216. configurable: true
  217. });
  218. Object.defineProperty(DxTabsComponent.prototype, "itemTemplate", {
  219. get: /**
  220. * Specifies a custom template for items.
  221. */
  222. function () {
  223. return this._getOption('itemTemplate');
  224. },
  225. set: function (value) {
  226. this._setOption('itemTemplate', value);
  227. },
  228. enumerable: true,
  229. configurable: true
  230. });
  231. Object.defineProperty(DxTabsComponent.prototype, "keyExpr", {
  232. get: /**
  233. * Specifies which data field provides keys for widget items.
  234. */
  235. function () {
  236. return this._getOption('keyExpr');
  237. },
  238. set: function (value) {
  239. this._setOption('keyExpr', value);
  240. },
  241. enumerable: true,
  242. configurable: true
  243. });
  244. Object.defineProperty(DxTabsComponent.prototype, "noDataText", {
  245. get: /**
  246. * The text or HTML markup displayed by the widget if the item collection is empty.
  247. */
  248. function () {
  249. return this._getOption('noDataText');
  250. },
  251. set: function (value) {
  252. this._setOption('noDataText', value);
  253. },
  254. enumerable: true,
  255. configurable: true
  256. });
  257. Object.defineProperty(DxTabsComponent.prototype, "repaintChangesOnly", {
  258. get: /**
  259. * Specifies whether to repaint only those elements whose data changed.
  260. */
  261. function () {
  262. return this._getOption('repaintChangesOnly');
  263. },
  264. set: function (value) {
  265. this._setOption('repaintChangesOnly', value);
  266. },
  267. enumerable: true,
  268. configurable: true
  269. });
  270. Object.defineProperty(DxTabsComponent.prototype, "rtlEnabled", {
  271. get: /**
  272. * Switches the widget to a right-to-left representation.
  273. */
  274. function () {
  275. return this._getOption('rtlEnabled');
  276. },
  277. set: function (value) {
  278. this._setOption('rtlEnabled', value);
  279. },
  280. enumerable: true,
  281. configurable: true
  282. });
  283. Object.defineProperty(DxTabsComponent.prototype, "scrollByContent", {
  284. get: /**
  285. * Specifies whether or not an end-user can scroll tabs by swiping.
  286. */
  287. function () {
  288. return this._getOption('scrollByContent');
  289. },
  290. set: function (value) {
  291. this._setOption('scrollByContent', value);
  292. },
  293. enumerable: true,
  294. configurable: true
  295. });
  296. Object.defineProperty(DxTabsComponent.prototype, "scrollingEnabled", {
  297. get: /**
  298. * Specifies whether or not an end-user can scroll tabs.
  299. */
  300. function () {
  301. return this._getOption('scrollingEnabled');
  302. },
  303. set: function (value) {
  304. this._setOption('scrollingEnabled', value);
  305. },
  306. enumerable: true,
  307. configurable: true
  308. });
  309. Object.defineProperty(DxTabsComponent.prototype, "selectedIndex", {
  310. get: /**
  311. * The index of the currently selected widget item.
  312. */
  313. function () {
  314. return this._getOption('selectedIndex');
  315. },
  316. set: function (value) {
  317. this._setOption('selectedIndex', value);
  318. },
  319. enumerable: true,
  320. configurable: true
  321. });
  322. Object.defineProperty(DxTabsComponent.prototype, "selectedItem", {
  323. get: /**
  324. * The selected item object.
  325. */
  326. function () {
  327. return this._getOption('selectedItem');
  328. },
  329. set: function (value) {
  330. this._setOption('selectedItem', value);
  331. },
  332. enumerable: true,
  333. configurable: true
  334. });
  335. Object.defineProperty(DxTabsComponent.prototype, "selectedItemKeys", {
  336. get: /**
  337. * Specifies an array of currently selected item keys.
  338. */
  339. function () {
  340. return this._getOption('selectedItemKeys');
  341. },
  342. set: function (value) {
  343. this._setOption('selectedItemKeys', value);
  344. },
  345. enumerable: true,
  346. configurable: true
  347. });
  348. Object.defineProperty(DxTabsComponent.prototype, "selectedItems", {
  349. get: /**
  350. * An array of currently selected item objects.
  351. */
  352. function () {
  353. return this._getOption('selectedItems');
  354. },
  355. set: function (value) {
  356. this._setOption('selectedItems', value);
  357. },
  358. enumerable: true,
  359. configurable: true
  360. });
  361. Object.defineProperty(DxTabsComponent.prototype, "selectionMode", {
  362. get: /**
  363. * Specifies whether the widget enables an end-user to select only a single item or multiple items.
  364. */
  365. function () {
  366. return this._getOption('selectionMode');
  367. },
  368. set: function (value) {
  369. this._setOption('selectionMode', value);
  370. },
  371. enumerable: true,
  372. configurable: true
  373. });
  374. Object.defineProperty(DxTabsComponent.prototype, "showNavButtons", {
  375. get: /**
  376. * Specifies whether navigation buttons should be available when tabs exceed the widget's width.
  377. */
  378. function () {
  379. return this._getOption('showNavButtons');
  380. },
  381. set: function (value) {
  382. this._setOption('showNavButtons', value);
  383. },
  384. enumerable: true,
  385. configurable: true
  386. });
  387. Object.defineProperty(DxTabsComponent.prototype, "tabIndex", {
  388. get: /**
  389. * Specifies the number of the element when the Tab key is used for navigating.
  390. */
  391. function () {
  392. return this._getOption('tabIndex');
  393. },
  394. set: function (value) {
  395. this._setOption('tabIndex', value);
  396. },
  397. enumerable: true,
  398. configurable: true
  399. });
  400. Object.defineProperty(DxTabsComponent.prototype, "visible", {
  401. get: /**
  402. * Specifies whether the widget is visible.
  403. */
  404. function () {
  405. return this._getOption('visible');
  406. },
  407. set: function (value) {
  408. this._setOption('visible', value);
  409. },
  410. enumerable: true,
  411. configurable: true
  412. });
  413. Object.defineProperty(DxTabsComponent.prototype, "width", {
  414. get: /**
  415. * Specifies the widget's width.
  416. */
  417. function () {
  418. return this._getOption('width');
  419. },
  420. set: function (value) {
  421. this._setOption('width', value);
  422. },
  423. enumerable: true,
  424. configurable: true
  425. });
  426. Object.defineProperty(DxTabsComponent.prototype, "itemsChildren", {
  427. get: function () {
  428. return this._getOption('items');
  429. },
  430. set: function (value) {
  431. this.setChildren('items', value);
  432. },
  433. enumerable: true,
  434. configurable: true
  435. });
  436. DxTabsComponent.prototype._createInstance = function (element, options) {
  437. return new tabs_1.default(element, options);
  438. };
  439. DxTabsComponent.prototype.ngOnDestroy = function () {
  440. this._destroyWidget();
  441. };
  442. DxTabsComponent.prototype.ngOnChanges = function (changes) {
  443. _super.prototype.ngOnChanges.call(this, changes);
  444. this.setupChanges('dataSource', changes);
  445. this.setupChanges('items', changes);
  446. this.setupChanges('selectedItemKeys', changes);
  447. this.setupChanges('selectedItems', changes);
  448. };
  449. DxTabsComponent.prototype.setupChanges = function (prop, changes) {
  450. if (!(prop in this._optionsToUpdate)) {
  451. this._idh.setup(prop, changes);
  452. }
  453. };
  454. DxTabsComponent.prototype.ngDoCheck = function () {
  455. this._idh.doCheck('dataSource');
  456. this._idh.doCheck('items');
  457. this._idh.doCheck('selectedItemKeys');
  458. this._idh.doCheck('selectedItems');
  459. this._watcherHelper.checkWatchers();
  460. _super.prototype.ngDoCheck.call(this);
  461. _super.prototype.clearChangedOptions.call(this);
  462. };
  463. DxTabsComponent.prototype._setOption = function (name, value) {
  464. var isSetup = this._idh.setupSingle(name, value);
  465. var isChanged = this._idh.getChanges(name, value) !== null;
  466. if (isSetup || isChanged) {
  467. _super.prototype._setOption.call(this, name, value);
  468. }
  469. };
  470. DxTabsComponent.decorators = [
  471. { type: core_1.Component, args: [{
  472. selector: 'dx-tabs',
  473. template: '',
  474. providers: [
  475. template_host_1.DxTemplateHost,
  476. watcher_helper_1.WatcherHelper,
  477. nested_option_1.NestedOptionHost,
  478. iterable_differ_helper_1.IterableDifferHelper
  479. ]
  480. },] },
  481. ];
  482. /** @nocollapse */
  483. DxTabsComponent.ctorParameters = function () { return [
  484. { type: core_1.ElementRef, },
  485. { type: core_1.NgZone, },
  486. { type: template_host_1.DxTemplateHost, },
  487. { type: watcher_helper_1.WatcherHelper, },
  488. { type: iterable_differ_helper_1.IterableDifferHelper, },
  489. { type: nested_option_1.NestedOptionHost, },
  490. { type: platform_browser_2.TransferState, },
  491. { type: undefined, decorators: [{ type: core_1.Inject, args: [core_1.PLATFORM_ID,] },] },
  492. ]; };
  493. DxTabsComponent.propDecorators = {
  494. "accessKey": [{ type: core_1.Input },],
  495. "dataSource": [{ type: core_1.Input },],
  496. "disabled": [{ type: core_1.Input },],
  497. "elementAttr": [{ type: core_1.Input },],
  498. "focusStateEnabled": [{ type: core_1.Input },],
  499. "height": [{ type: core_1.Input },],
  500. "hint": [{ type: core_1.Input },],
  501. "hoverStateEnabled": [{ type: core_1.Input },],
  502. "itemHoldTimeout": [{ type: core_1.Input },],
  503. "items": [{ type: core_1.Input },],
  504. "itemTemplate": [{ type: core_1.Input },],
  505. "keyExpr": [{ type: core_1.Input },],
  506. "noDataText": [{ type: core_1.Input },],
  507. "repaintChangesOnly": [{ type: core_1.Input },],
  508. "rtlEnabled": [{ type: core_1.Input },],
  509. "scrollByContent": [{ type: core_1.Input },],
  510. "scrollingEnabled": [{ type: core_1.Input },],
  511. "selectedIndex": [{ type: core_1.Input },],
  512. "selectedItem": [{ type: core_1.Input },],
  513. "selectedItemKeys": [{ type: core_1.Input },],
  514. "selectedItems": [{ type: core_1.Input },],
  515. "selectionMode": [{ type: core_1.Input },],
  516. "showNavButtons": [{ type: core_1.Input },],
  517. "tabIndex": [{ type: core_1.Input },],
  518. "visible": [{ type: core_1.Input },],
  519. "width": [{ type: core_1.Input },],
  520. "onContentReady": [{ type: core_1.Output },],
  521. "onDisposing": [{ type: core_1.Output },],
  522. "onInitialized": [{ type: core_1.Output },],
  523. "onItemClick": [{ type: core_1.Output },],
  524. "onItemContextMenu": [{ type: core_1.Output },],
  525. "onItemHold": [{ type: core_1.Output },],
  526. "onItemRendered": [{ type: core_1.Output },],
  527. "onOptionChanged": [{ type: core_1.Output },],
  528. "onSelectionChanged": [{ type: core_1.Output },],
  529. "accessKeyChange": [{ type: core_1.Output },],
  530. "dataSourceChange": [{ type: core_1.Output },],
  531. "disabledChange": [{ type: core_1.Output },],
  532. "elementAttrChange": [{ type: core_1.Output },],
  533. "focusStateEnabledChange": [{ type: core_1.Output },],
  534. "heightChange": [{ type: core_1.Output },],
  535. "hintChange": [{ type: core_1.Output },],
  536. "hoverStateEnabledChange": [{ type: core_1.Output },],
  537. "itemHoldTimeoutChange": [{ type: core_1.Output },],
  538. "itemsChange": [{ type: core_1.Output },],
  539. "itemTemplateChange": [{ type: core_1.Output },],
  540. "keyExprChange": [{ type: core_1.Output },],
  541. "noDataTextChange": [{ type: core_1.Output },],
  542. "repaintChangesOnlyChange": [{ type: core_1.Output },],
  543. "rtlEnabledChange": [{ type: core_1.Output },],
  544. "scrollByContentChange": [{ type: core_1.Output },],
  545. "scrollingEnabledChange": [{ type: core_1.Output },],
  546. "selectedIndexChange": [{ type: core_1.Output },],
  547. "selectedItemChange": [{ type: core_1.Output },],
  548. "selectedItemKeysChange": [{ type: core_1.Output },],
  549. "selectedItemsChange": [{ type: core_1.Output },],
  550. "selectionModeChange": [{ type: core_1.Output },],
  551. "showNavButtonsChange": [{ type: core_1.Output },],
  552. "tabIndexChange": [{ type: core_1.Output },],
  553. "visibleChange": [{ type: core_1.Output },],
  554. "widthChange": [{ type: core_1.Output },],
  555. "itemsChildren": [{ type: core_1.ContentChildren, args: [item_dxi_2.DxiItemComponent,] },],
  556. };
  557. return DxTabsComponent;
  558. }(component_1.DxComponent));
  559. exports.DxTabsComponent = DxTabsComponent;
  560. var DxTabsModule = (function () {
  561. function DxTabsModule() {
  562. }
  563. DxTabsModule.decorators = [
  564. { type: core_1.NgModule, args: [{
  565. imports: [
  566. item_dxi_1.DxiItemModule,
  567. integration_1.DxIntegrationModule,
  568. template_1.DxTemplateModule,
  569. platform_browser_1.BrowserTransferStateModule
  570. ],
  571. declarations: [
  572. DxTabsComponent
  573. ],
  574. exports: [
  575. DxTabsComponent,
  576. item_dxi_1.DxiItemModule,
  577. template_1.DxTemplateModule
  578. ]
  579. },] },
  580. ];
  581. return DxTabsModule;
  582. }());
  583. exports.DxTabsModule = DxTabsModule;
  584. //# sourceMappingURL=tabs.js.map