toast.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  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 toast_1 = require("devextreme/ui/toast");
  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 animation_1 = require("./nested/animation");
  36. var hide_1 = require("./nested/hide");
  37. var show_1 = require("./nested/show");
  38. var position_1 = require("./nested/position");
  39. var at_1 = require("./nested/at");
  40. var boundary_offset_1 = require("./nested/boundary-offset");
  41. var collision_1 = require("./nested/collision");
  42. var my_1 = require("./nested/my");
  43. var offset_1 = require("./nested/offset");
  44. /**
  45. * The Toast is a widget that provides pop-up notifications.
  46. */
  47. var DxToastComponent = (function (_super) {
  48. __extends(DxToastComponent, _super);
  49. function DxToastComponent(elementRef, ngZone, templateHost, _watcherHelper, optionHost, transferState, platformId) {
  50. var _this = _super.call(this, elementRef, ngZone, templateHost, _watcherHelper, transferState, platformId) || this;
  51. _this._createEventEmitters([
  52. { subscribe: 'contentReady', emit: 'onContentReady' },
  53. { subscribe: 'disposing', emit: 'onDisposing' },
  54. { subscribe: 'hidden', emit: 'onHidden' },
  55. { subscribe: 'hiding', emit: 'onHiding' },
  56. { subscribe: 'initialized', emit: 'onInitialized' },
  57. { subscribe: 'optionChanged', emit: 'onOptionChanged' },
  58. { subscribe: 'showing', emit: 'onShowing' },
  59. { subscribe: 'shown', emit: 'onShown' },
  60. { emit: 'accessKeyChange' },
  61. { emit: 'animationChange' },
  62. { emit: 'closeOnClickChange' },
  63. { emit: 'closeOnOutsideClickChange' },
  64. { emit: 'closeOnSwipeChange' },
  65. { emit: 'contentTemplateChange' },
  66. { emit: 'deferRenderingChange' },
  67. { emit: 'displayTimeChange' },
  68. { emit: 'elementAttrChange' },
  69. { emit: 'focusStateEnabledChange' },
  70. { emit: 'heightChange' },
  71. { emit: 'hintChange' },
  72. { emit: 'hoverStateEnabledChange' },
  73. { emit: 'maxHeightChange' },
  74. { emit: 'maxWidthChange' },
  75. { emit: 'messageChange' },
  76. { emit: 'minHeightChange' },
  77. { emit: 'minWidthChange' },
  78. { emit: 'positionChange' },
  79. { emit: 'rtlEnabledChange' },
  80. { emit: 'shadingChange' },
  81. { emit: 'shadingColorChange' },
  82. { emit: 'tabIndexChange' },
  83. { emit: 'typeChange' },
  84. { emit: 'visibleChange' },
  85. { emit: 'widthChange' }
  86. ]);
  87. optionHost.setHost(_this);
  88. return _this;
  89. }
  90. Object.defineProperty(DxToastComponent.prototype, "accessKey", {
  91. get: /**
  92. * Specifies the shortcut key that sets focus on the widget.
  93. */
  94. function () {
  95. return this._getOption('accessKey');
  96. },
  97. set: function (value) {
  98. this._setOption('accessKey', value);
  99. },
  100. enumerable: true,
  101. configurable: true
  102. });
  103. Object.defineProperty(DxToastComponent.prototype, "animation", {
  104. get: /**
  105. * Configures widget visibility animations. This object contains two fields: show and hide.
  106. */
  107. function () {
  108. return this._getOption('animation');
  109. },
  110. set: function (value) {
  111. this._setOption('animation', value);
  112. },
  113. enumerable: true,
  114. configurable: true
  115. });
  116. Object.defineProperty(DxToastComponent.prototype, "closeOnClick", {
  117. get: /**
  118. * A Boolean value specifying whether or not the toast is closed if a user clicks it.
  119. */
  120. function () {
  121. return this._getOption('closeOnClick');
  122. },
  123. set: function (value) {
  124. this._setOption('closeOnClick', value);
  125. },
  126. enumerable: true,
  127. configurable: true
  128. });
  129. Object.defineProperty(DxToastComponent.prototype, "closeOnOutsideClick", {
  130. get: /**
  131. * Specifies whether to close the widget if a user clicks outside it.
  132. */
  133. function () {
  134. return this._getOption('closeOnOutsideClick');
  135. },
  136. set: function (value) {
  137. this._setOption('closeOnOutsideClick', value);
  138. },
  139. enumerable: true,
  140. configurable: true
  141. });
  142. Object.defineProperty(DxToastComponent.prototype, "closeOnSwipe", {
  143. get: /**
  144. * A Boolean value specifying whether or not the toast is closed if a user swipes it out of the screen boundaries.
  145. */
  146. function () {
  147. return this._getOption('closeOnSwipe');
  148. },
  149. set: function (value) {
  150. this._setOption('closeOnSwipe', value);
  151. },
  152. enumerable: true,
  153. configurable: true
  154. });
  155. Object.defineProperty(DxToastComponent.prototype, "contentTemplate", {
  156. get: /**
  157. * Specifies a custom template for the widget content.
  158. */
  159. function () {
  160. return this._getOption('contentTemplate');
  161. },
  162. set: function (value) {
  163. this._setOption('contentTemplate', value);
  164. },
  165. enumerable: true,
  166. configurable: true
  167. });
  168. Object.defineProperty(DxToastComponent.prototype, "deferRendering", {
  169. get: /**
  170. * Specifies whether to render the widget's content when it is displayed. If false, the content is rendered immediately.
  171. */
  172. function () {
  173. return this._getOption('deferRendering');
  174. },
  175. set: function (value) {
  176. this._setOption('deferRendering', value);
  177. },
  178. enumerable: true,
  179. configurable: true
  180. });
  181. Object.defineProperty(DxToastComponent.prototype, "displayTime", {
  182. get: /**
  183. * The time span in milliseconds during which the Toast widget is visible.
  184. */
  185. function () {
  186. return this._getOption('displayTime');
  187. },
  188. set: function (value) {
  189. this._setOption('displayTime', value);
  190. },
  191. enumerable: true,
  192. configurable: true
  193. });
  194. Object.defineProperty(DxToastComponent.prototype, "elementAttr", {
  195. get: /**
  196. * Specifies the attributes to be attached to the widget's root element.
  197. */
  198. function () {
  199. return this._getOption('elementAttr');
  200. },
  201. set: function (value) {
  202. this._setOption('elementAttr', value);
  203. },
  204. enumerable: true,
  205. configurable: true
  206. });
  207. Object.defineProperty(DxToastComponent.prototype, "focusStateEnabled", {
  208. get: /**
  209. * Specifies whether the widget can be focused using keyboard navigation.
  210. */
  211. function () {
  212. return this._getOption('focusStateEnabled');
  213. },
  214. set: function (value) {
  215. this._setOption('focusStateEnabled', value);
  216. },
  217. enumerable: true,
  218. configurable: true
  219. });
  220. Object.defineProperty(DxToastComponent.prototype, "height", {
  221. get: /**
  222. * Specifies the widget's height in pixels.
  223. */
  224. function () {
  225. return this._getOption('height');
  226. },
  227. set: function (value) {
  228. this._setOption('height', value);
  229. },
  230. enumerable: true,
  231. configurable: true
  232. });
  233. Object.defineProperty(DxToastComponent.prototype, "hint", {
  234. get: /**
  235. * Specifies text for a hint that appears when a user pauses on the widget.
  236. */
  237. function () {
  238. return this._getOption('hint');
  239. },
  240. set: function (value) {
  241. this._setOption('hint', value);
  242. },
  243. enumerable: true,
  244. configurable: true
  245. });
  246. Object.defineProperty(DxToastComponent.prototype, "hoverStateEnabled", {
  247. get: /**
  248. * Specifies whether the widget changes its state when a user pauses on it.
  249. */
  250. function () {
  251. return this._getOption('hoverStateEnabled');
  252. },
  253. set: function (value) {
  254. this._setOption('hoverStateEnabled', value);
  255. },
  256. enumerable: true,
  257. configurable: true
  258. });
  259. Object.defineProperty(DxToastComponent.prototype, "maxHeight", {
  260. get: /**
  261. * Specifies the maximum height the widget can reach while resizing.
  262. */
  263. function () {
  264. return this._getOption('maxHeight');
  265. },
  266. set: function (value) {
  267. this._setOption('maxHeight', value);
  268. },
  269. enumerable: true,
  270. configurable: true
  271. });
  272. Object.defineProperty(DxToastComponent.prototype, "maxWidth", {
  273. get: /**
  274. * Specifies the maximum width the widget can reach while resizing.
  275. */
  276. function () {
  277. return this._getOption('maxWidth');
  278. },
  279. set: function (value) {
  280. this._setOption('maxWidth', value);
  281. },
  282. enumerable: true,
  283. configurable: true
  284. });
  285. Object.defineProperty(DxToastComponent.prototype, "message", {
  286. get: /**
  287. * The Toast message text.
  288. */
  289. function () {
  290. return this._getOption('message');
  291. },
  292. set: function (value) {
  293. this._setOption('message', value);
  294. },
  295. enumerable: true,
  296. configurable: true
  297. });
  298. Object.defineProperty(DxToastComponent.prototype, "minHeight", {
  299. get: /**
  300. * Specifies the minimum height the widget can reach while resizing.
  301. */
  302. function () {
  303. return this._getOption('minHeight');
  304. },
  305. set: function (value) {
  306. this._setOption('minHeight', value);
  307. },
  308. enumerable: true,
  309. configurable: true
  310. });
  311. Object.defineProperty(DxToastComponent.prototype, "minWidth", {
  312. get: /**
  313. * Specifies the minimum width the widget can reach while resizing.
  314. */
  315. function () {
  316. return this._getOption('minWidth');
  317. },
  318. set: function (value) {
  319. this._setOption('minWidth', value);
  320. },
  321. enumerable: true,
  322. configurable: true
  323. });
  324. Object.defineProperty(DxToastComponent.prototype, "position", {
  325. get: /**
  326. * Positions the widget.
  327. */
  328. function () {
  329. return this._getOption('position');
  330. },
  331. set: function (value) {
  332. this._setOption('position', value);
  333. },
  334. enumerable: true,
  335. configurable: true
  336. });
  337. Object.defineProperty(DxToastComponent.prototype, "rtlEnabled", {
  338. get: /**
  339. * Switches the widget to a right-to-left representation.
  340. */
  341. function () {
  342. return this._getOption('rtlEnabled');
  343. },
  344. set: function (value) {
  345. this._setOption('rtlEnabled', value);
  346. },
  347. enumerable: true,
  348. configurable: true
  349. });
  350. Object.defineProperty(DxToastComponent.prototype, "shading", {
  351. get: /**
  352. * Specifies whether to shade the background when the widget is active.
  353. */
  354. function () {
  355. return this._getOption('shading');
  356. },
  357. set: function (value) {
  358. this._setOption('shading', value);
  359. },
  360. enumerable: true,
  361. configurable: true
  362. });
  363. Object.defineProperty(DxToastComponent.prototype, "shadingColor", {
  364. get: /**
  365. * Specifies the shading color.
  366. */
  367. function () {
  368. return this._getOption('shadingColor');
  369. },
  370. set: function (value) {
  371. this._setOption('shadingColor', value);
  372. },
  373. enumerable: true,
  374. configurable: true
  375. });
  376. Object.defineProperty(DxToastComponent.prototype, "tabIndex", {
  377. get: /**
  378. * Specifies the number of the element when the Tab key is used for navigating.
  379. */
  380. function () {
  381. return this._getOption('tabIndex');
  382. },
  383. set: function (value) {
  384. this._setOption('tabIndex', value);
  385. },
  386. enumerable: true,
  387. configurable: true
  388. });
  389. Object.defineProperty(DxToastComponent.prototype, "type", {
  390. get: /**
  391. * Specifies the Toast widget type.
  392. */
  393. function () {
  394. return this._getOption('type');
  395. },
  396. set: function (value) {
  397. this._setOption('type', value);
  398. },
  399. enumerable: true,
  400. configurable: true
  401. });
  402. Object.defineProperty(DxToastComponent.prototype, "visible", {
  403. get: /**
  404. * A Boolean value specifying whether or not the widget is visible.
  405. */
  406. function () {
  407. return this._getOption('visible');
  408. },
  409. set: function (value) {
  410. this._setOption('visible', value);
  411. },
  412. enumerable: true,
  413. configurable: true
  414. });
  415. Object.defineProperty(DxToastComponent.prototype, "width", {
  416. get: /**
  417. * Specifies the widget's width in pixels.
  418. */
  419. function () {
  420. return this._getOption('width');
  421. },
  422. set: function (value) {
  423. this._setOption('width', value);
  424. },
  425. enumerable: true,
  426. configurable: true
  427. });
  428. DxToastComponent.prototype._createInstance = function (element, options) {
  429. return new toast_1.default(element, options);
  430. };
  431. DxToastComponent.prototype.ngOnDestroy = function () {
  432. this._destroyWidget();
  433. };
  434. DxToastComponent.decorators = [
  435. { type: core_1.Component, args: [{
  436. selector: 'dx-toast',
  437. template: '',
  438. providers: [
  439. template_host_1.DxTemplateHost,
  440. watcher_helper_1.WatcherHelper,
  441. nested_option_1.NestedOptionHost
  442. ]
  443. },] },
  444. ];
  445. /** @nocollapse */
  446. DxToastComponent.ctorParameters = function () { return [
  447. { type: core_1.ElementRef, },
  448. { type: core_1.NgZone, },
  449. { type: template_host_1.DxTemplateHost, },
  450. { type: watcher_helper_1.WatcherHelper, },
  451. { type: nested_option_1.NestedOptionHost, },
  452. { type: platform_browser_2.TransferState, },
  453. { type: undefined, decorators: [{ type: core_1.Inject, args: [core_1.PLATFORM_ID,] },] },
  454. ]; };
  455. DxToastComponent.propDecorators = {
  456. "accessKey": [{ type: core_1.Input },],
  457. "animation": [{ type: core_1.Input },],
  458. "closeOnClick": [{ type: core_1.Input },],
  459. "closeOnOutsideClick": [{ type: core_1.Input },],
  460. "closeOnSwipe": [{ type: core_1.Input },],
  461. "contentTemplate": [{ type: core_1.Input },],
  462. "deferRendering": [{ type: core_1.Input },],
  463. "displayTime": [{ type: core_1.Input },],
  464. "elementAttr": [{ type: core_1.Input },],
  465. "focusStateEnabled": [{ type: core_1.Input },],
  466. "height": [{ type: core_1.Input },],
  467. "hint": [{ type: core_1.Input },],
  468. "hoverStateEnabled": [{ type: core_1.Input },],
  469. "maxHeight": [{ type: core_1.Input },],
  470. "maxWidth": [{ type: core_1.Input },],
  471. "message": [{ type: core_1.Input },],
  472. "minHeight": [{ type: core_1.Input },],
  473. "minWidth": [{ type: core_1.Input },],
  474. "position": [{ type: core_1.Input },],
  475. "rtlEnabled": [{ type: core_1.Input },],
  476. "shading": [{ type: core_1.Input },],
  477. "shadingColor": [{ type: core_1.Input },],
  478. "tabIndex": [{ type: core_1.Input },],
  479. "type": [{ type: core_1.Input },],
  480. "visible": [{ type: core_1.Input },],
  481. "width": [{ type: core_1.Input },],
  482. "onContentReady": [{ type: core_1.Output },],
  483. "onDisposing": [{ type: core_1.Output },],
  484. "onHidden": [{ type: core_1.Output },],
  485. "onHiding": [{ type: core_1.Output },],
  486. "onInitialized": [{ type: core_1.Output },],
  487. "onOptionChanged": [{ type: core_1.Output },],
  488. "onShowing": [{ type: core_1.Output },],
  489. "onShown": [{ type: core_1.Output },],
  490. "accessKeyChange": [{ type: core_1.Output },],
  491. "animationChange": [{ type: core_1.Output },],
  492. "closeOnClickChange": [{ type: core_1.Output },],
  493. "closeOnOutsideClickChange": [{ type: core_1.Output },],
  494. "closeOnSwipeChange": [{ type: core_1.Output },],
  495. "contentTemplateChange": [{ type: core_1.Output },],
  496. "deferRenderingChange": [{ type: core_1.Output },],
  497. "displayTimeChange": [{ type: core_1.Output },],
  498. "elementAttrChange": [{ type: core_1.Output },],
  499. "focusStateEnabledChange": [{ type: core_1.Output },],
  500. "heightChange": [{ type: core_1.Output },],
  501. "hintChange": [{ type: core_1.Output },],
  502. "hoverStateEnabledChange": [{ type: core_1.Output },],
  503. "maxHeightChange": [{ type: core_1.Output },],
  504. "maxWidthChange": [{ type: core_1.Output },],
  505. "messageChange": [{ type: core_1.Output },],
  506. "minHeightChange": [{ type: core_1.Output },],
  507. "minWidthChange": [{ type: core_1.Output },],
  508. "positionChange": [{ type: core_1.Output },],
  509. "rtlEnabledChange": [{ type: core_1.Output },],
  510. "shadingChange": [{ type: core_1.Output },],
  511. "shadingColorChange": [{ type: core_1.Output },],
  512. "tabIndexChange": [{ type: core_1.Output },],
  513. "typeChange": [{ type: core_1.Output },],
  514. "visibleChange": [{ type: core_1.Output },],
  515. "widthChange": [{ type: core_1.Output },],
  516. };
  517. return DxToastComponent;
  518. }(component_1.DxComponent));
  519. exports.DxToastComponent = DxToastComponent;
  520. var DxToastModule = (function () {
  521. function DxToastModule() {
  522. }
  523. DxToastModule.decorators = [
  524. { type: core_1.NgModule, args: [{
  525. imports: [
  526. animation_1.DxoAnimationModule,
  527. hide_1.DxoHideModule,
  528. show_1.DxoShowModule,
  529. position_1.DxoPositionModule,
  530. at_1.DxoAtModule,
  531. boundary_offset_1.DxoBoundaryOffsetModule,
  532. collision_1.DxoCollisionModule,
  533. my_1.DxoMyModule,
  534. offset_1.DxoOffsetModule,
  535. integration_1.DxIntegrationModule,
  536. template_1.DxTemplateModule,
  537. platform_browser_1.BrowserTransferStateModule
  538. ],
  539. declarations: [
  540. DxToastComponent
  541. ],
  542. exports: [
  543. DxToastComponent,
  544. animation_1.DxoAnimationModule,
  545. hide_1.DxoHideModule,
  546. show_1.DxoShowModule,
  547. position_1.DxoPositionModule,
  548. at_1.DxoAtModule,
  549. boundary_offset_1.DxoBoundaryOffsetModule,
  550. collision_1.DxoCollisionModule,
  551. my_1.DxoMyModule,
  552. offset_1.DxoOffsetModule,
  553. template_1.DxTemplateModule
  554. ]
  555. },] },
  556. ];
  557. return DxToastModule;
  558. }());
  559. exports.DxToastModule = DxToastModule;
  560. //# sourceMappingURL=toast.js.map