handsontable 16.1.1 → 16.2.0-next-216dbd0-20251112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/3rdparty/walkontable/src/overlays.js +1 -1
  2. package/3rdparty/walkontable/src/overlays.mjs +1 -1
  3. package/3rdparty/walkontable/src/selection/border/border.js +19 -3
  4. package/3rdparty/walkontable/src/selection/border/border.mjs +19 -3
  5. package/CHANGELOG.md +39 -0
  6. package/base.js +2 -2
  7. package/base.mjs +2 -2
  8. package/core/coordsMapper/index.js +11 -0
  9. package/core/coordsMapper/index.mjs +1 -0
  10. package/core/hooks/bucket.js +7 -1
  11. package/core/hooks/bucket.mjs +7 -1
  12. package/core/hooks/constants.js +54 -0
  13. package/core/hooks/constants.mjs +54 -0
  14. package/core/hooks/index.d.ts +6 -0
  15. package/core/index.js +10 -4
  16. package/core/index.mjs +2 -1
  17. package/core.d.ts +3 -2
  18. package/core.js +67 -26
  19. package/core.mjs +56 -15
  20. package/dataMap/metaManager/metaSchema.js +197 -20
  21. package/dataMap/metaManager/metaSchema.mjs +197 -20
  22. package/dist/handsontable.css +175 -3
  23. package/dist/handsontable.full.css +175 -3
  24. package/dist/handsontable.full.js +10864 -8426
  25. package/dist/handsontable.full.min.css +5 -4
  26. package/dist/handsontable.full.min.js +194 -193
  27. package/dist/handsontable.js +7126 -4827
  28. package/dist/handsontable.min.css +4 -4
  29. package/dist/handsontable.min.js +43 -42
  30. package/dist/languages/all.js +168 -21
  31. package/dist/languages/all.min.js +1 -1
  32. package/dist/languages/ar-AR.js +8 -1
  33. package/dist/languages/ar-AR.min.js +1 -1
  34. package/dist/languages/cs-CZ.js +8 -1
  35. package/dist/languages/cs-CZ.min.js +1 -1
  36. package/dist/languages/de-CH.js +8 -1
  37. package/dist/languages/de-CH.min.js +1 -1
  38. package/dist/languages/de-DE.js +8 -1
  39. package/dist/languages/de-DE.min.js +1 -1
  40. package/dist/languages/en-US.js +8 -1
  41. package/dist/languages/en-US.min.js +1 -1
  42. package/dist/languages/es-MX.js +8 -1
  43. package/dist/languages/es-MX.min.js +1 -1
  44. package/dist/languages/fa-IR.js +8 -1
  45. package/dist/languages/fa-IR.min.js +1 -1
  46. package/dist/languages/fr-FR.js +8 -1
  47. package/dist/languages/fr-FR.min.js +1 -1
  48. package/dist/languages/hr-HR.js +8 -1
  49. package/dist/languages/hr-HR.min.js +1 -1
  50. package/dist/languages/it-IT.js +8 -1
  51. package/dist/languages/it-IT.min.js +1 -1
  52. package/dist/languages/ja-JP.js +8 -1
  53. package/dist/languages/ja-JP.min.js +1 -1
  54. package/dist/languages/ko-KR.js +8 -1
  55. package/dist/languages/ko-KR.min.js +1 -1
  56. package/dist/languages/lv-LV.js +8 -1
  57. package/dist/languages/lv-LV.min.js +1 -1
  58. package/dist/languages/nb-NO.js +8 -1
  59. package/dist/languages/nb-NO.min.js +1 -1
  60. package/dist/languages/nl-NL.js +8 -1
  61. package/dist/languages/nl-NL.min.js +1 -1
  62. package/dist/languages/pl-PL.js +8 -1
  63. package/dist/languages/pl-PL.min.js +1 -1
  64. package/dist/languages/pt-BR.js +8 -1
  65. package/dist/languages/pt-BR.min.js +1 -1
  66. package/dist/languages/ru-RU.js +8 -1
  67. package/dist/languages/ru-RU.min.js +1 -1
  68. package/dist/languages/sr-SP.js +8 -1
  69. package/dist/languages/sr-SP.min.js +1 -1
  70. package/dist/languages/zh-CN.js +8 -1
  71. package/dist/languages/zh-CN.min.js +1 -1
  72. package/dist/languages/zh-TW.js +8 -1
  73. package/dist/languages/zh-TW.min.js +1 -1
  74. package/editors/autocompleteEditor/autocompleteEditor.js +21 -1
  75. package/editors/autocompleteEditor/autocompleteEditor.mjs +22 -2
  76. package/focusManager/constants.js +25 -0
  77. package/focusManager/constants.mjs +22 -0
  78. package/focusManager/eventListener.js +107 -0
  79. package/focusManager/eventListener.mjs +103 -0
  80. package/{focusManager.d.ts → focusManager/grid.d.ts} +1 -1
  81. package/{focusManager.js → focusManager/grid.js} +48 -17
  82. package/{focusManager.mjs → focusManager/grid.mjs} +47 -16
  83. package/focusManager/index.d.ts +2 -0
  84. package/focusManager/index.js +20 -0
  85. package/focusManager/index.mjs +20 -0
  86. package/focusManager/scope.js +133 -0
  87. package/focusManager/scope.mjs +129 -0
  88. package/focusManager/scopeManager.d.ts +19 -0
  89. package/focusManager/scopeManager.js +268 -0
  90. package/focusManager/scopeManager.mjs +263 -0
  91. package/focusManager/scopes/grid.js +120 -0
  92. package/focusManager/scopes/grid.mjs +116 -0
  93. package/focusManager/scopes/index.js +13 -0
  94. package/focusManager/scopes/index.mjs +9 -0
  95. package/{utils → focusManager/utils}/focusDetector.js +21 -31
  96. package/{utils → focusManager/utils}/focusDetector.mjs +21 -31
  97. package/focusManager/utils/utils.js +95 -0
  98. package/focusManager/utils/utils.mjs +89 -0
  99. package/helpers/dom/element.js +1 -1
  100. package/helpers/dom/element.mjs +2 -2
  101. package/helpers/dom/event.js +1 -1
  102. package/helpers/dom/event.mjs +1 -1
  103. package/helpers/mixed.js +2 -65
  104. package/helpers/mixed.mjs +2 -63
  105. package/i18n/constants.js +10 -1
  106. package/i18n/constants.mjs +10 -1
  107. package/i18n/languages/ar-AR.js +8 -1
  108. package/i18n/languages/ar-AR.mjs +8 -1
  109. package/i18n/languages/cs-CZ.js +8 -1
  110. package/i18n/languages/cs-CZ.mjs +8 -1
  111. package/i18n/languages/de-CH.js +8 -1
  112. package/i18n/languages/de-CH.mjs +8 -1
  113. package/i18n/languages/de-DE.js +8 -1
  114. package/i18n/languages/de-DE.mjs +8 -1
  115. package/i18n/languages/en-US.js +8 -1
  116. package/i18n/languages/en-US.mjs +8 -1
  117. package/i18n/languages/es-MX.js +8 -1
  118. package/i18n/languages/es-MX.mjs +8 -1
  119. package/i18n/languages/fa-IR.js +8 -1
  120. package/i18n/languages/fa-IR.mjs +8 -1
  121. package/i18n/languages/fr-FR.js +8 -1
  122. package/i18n/languages/fr-FR.mjs +8 -1
  123. package/i18n/languages/hr-HR.js +8 -1
  124. package/i18n/languages/hr-HR.mjs +8 -1
  125. package/i18n/languages/it-IT.js +8 -1
  126. package/i18n/languages/it-IT.mjs +8 -1
  127. package/i18n/languages/ja-JP.js +8 -1
  128. package/i18n/languages/ja-JP.mjs +8 -1
  129. package/i18n/languages/ko-KR.js +8 -1
  130. package/i18n/languages/ko-KR.mjs +8 -1
  131. package/i18n/languages/lv-LV.js +8 -1
  132. package/i18n/languages/lv-LV.mjs +8 -1
  133. package/i18n/languages/nb-NO.js +8 -1
  134. package/i18n/languages/nb-NO.mjs +8 -1
  135. package/i18n/languages/nl-NL.js +8 -1
  136. package/i18n/languages/nl-NL.mjs +8 -1
  137. package/i18n/languages/pl-PL.js +8 -1
  138. package/i18n/languages/pl-PL.mjs +8 -1
  139. package/i18n/languages/pt-BR.js +8 -1
  140. package/i18n/languages/pt-BR.mjs +8 -1
  141. package/i18n/languages/ru-RU.js +8 -1
  142. package/i18n/languages/ru-RU.mjs +8 -1
  143. package/i18n/languages/sr-SP.js +8 -1
  144. package/i18n/languages/sr-SP.mjs +8 -1
  145. package/i18n/languages/zh-CN.js +8 -1
  146. package/i18n/languages/zh-CN.mjs +8 -1
  147. package/i18n/languages/zh-TW.js +8 -1
  148. package/i18n/languages/zh-TW.mjs +8 -1
  149. package/index.d.ts +9 -0
  150. package/languages/all.js +168 -21
  151. package/languages/ar-AR.js +8 -1
  152. package/languages/ar-AR.mjs +8 -1
  153. package/languages/cs-CZ.js +8 -1
  154. package/languages/cs-CZ.mjs +8 -1
  155. package/languages/de-CH.js +8 -1
  156. package/languages/de-CH.mjs +8 -1
  157. package/languages/de-DE.js +8 -1
  158. package/languages/de-DE.mjs +8 -1
  159. package/languages/en-US.js +8 -1
  160. package/languages/en-US.mjs +8 -1
  161. package/languages/es-MX.js +8 -1
  162. package/languages/es-MX.mjs +8 -1
  163. package/languages/fa-IR.js +8 -1
  164. package/languages/fa-IR.mjs +8 -1
  165. package/languages/fr-FR.js +8 -1
  166. package/languages/fr-FR.mjs +8 -1
  167. package/languages/hr-HR.js +8 -1
  168. package/languages/hr-HR.mjs +8 -1
  169. package/languages/index.js +168 -21
  170. package/languages/it-IT.js +8 -1
  171. package/languages/it-IT.mjs +8 -1
  172. package/languages/ja-JP.js +8 -1
  173. package/languages/ja-JP.mjs +8 -1
  174. package/languages/ko-KR.js +8 -1
  175. package/languages/ko-KR.mjs +8 -1
  176. package/languages/lv-LV.js +8 -1
  177. package/languages/lv-LV.mjs +8 -1
  178. package/languages/nb-NO.js +8 -1
  179. package/languages/nb-NO.mjs +8 -1
  180. package/languages/nl-NL.js +8 -1
  181. package/languages/nl-NL.mjs +8 -1
  182. package/languages/pl-PL.js +8 -1
  183. package/languages/pl-PL.mjs +8 -1
  184. package/languages/pt-BR.js +8 -1
  185. package/languages/pt-BR.mjs +8 -1
  186. package/languages/ru-RU.js +8 -1
  187. package/languages/ru-RU.mjs +8 -1
  188. package/languages/sr-SP.js +8 -1
  189. package/languages/sr-SP.mjs +8 -1
  190. package/languages/zh-CN.js +8 -1
  191. package/languages/zh-CN.mjs +8 -1
  192. package/languages/zh-TW.js +8 -1
  193. package/languages/zh-TW.mjs +8 -1
  194. package/package.json +25 -7
  195. package/plugins/autoRowSize/autoRowSize.js +8 -1
  196. package/plugins/autoRowSize/autoRowSize.mjs +8 -1
  197. package/plugins/base/base.js +36 -10
  198. package/plugins/base/base.mjs +36 -10
  199. package/plugins/columnSummary/endpoints.js +13 -3
  200. package/plugins/columnSummary/endpoints.mjs +13 -3
  201. package/plugins/customBorders/customBorders.d.ts +1 -0
  202. package/plugins/customBorders/customBorders.js +32 -2
  203. package/plugins/customBorders/customBorders.mjs +32 -2
  204. package/plugins/dialog/constants.js +7 -0
  205. package/plugins/dialog/constants.mjs +4 -0
  206. package/plugins/dialog/dialog.d.ts +22 -2
  207. package/plugins/dialog/dialog.js +197 -81
  208. package/plugins/dialog/dialog.mjs +196 -81
  209. package/plugins/dialog/templates/base.js +60 -0
  210. package/plugins/dialog/templates/base.mjs +56 -0
  211. package/plugins/dialog/templates/confirm.js +106 -0
  212. package/plugins/dialog/templates/confirm.mjs +102 -0
  213. package/plugins/dialog/templates/index.js +6 -0
  214. package/plugins/dialog/templates/index.mjs +4 -0
  215. package/plugins/dialog/ui.js +125 -41
  216. package/plugins/dialog/ui.mjs +119 -35
  217. package/plugins/emptyDataState/emptyDataState.d.ts +24 -0
  218. package/plugins/emptyDataState/emptyDataState.js +526 -0
  219. package/plugins/emptyDataState/emptyDataState.mjs +521 -0
  220. package/plugins/emptyDataState/index.d.ts +1 -0
  221. package/plugins/emptyDataState/index.js +7 -0
  222. package/plugins/emptyDataState/index.mjs +1 -0
  223. package/plugins/emptyDataState/ui.js +282 -0
  224. package/plugins/emptyDataState/ui.mjs +278 -0
  225. package/plugins/filters/component/value.js +16 -1
  226. package/plugins/filters/component/value.mjs +16 -1
  227. package/plugins/filters/filters.d.ts +5 -1
  228. package/plugins/filters/filters.js +22 -1
  229. package/plugins/filters/filters.mjs +22 -1
  230. package/plugins/filters/ui/multipleSelect.js +90 -79
  231. package/plugins/filters/ui/multipleSelect.mjs +90 -79
  232. package/plugins/index.d.ts +3 -0
  233. package/plugins/index.js +3 -0
  234. package/plugins/index.mjs +3 -1
  235. package/plugins/mergeCells/utils.js +1 -5
  236. package/plugins/mergeCells/utils.mjs +1 -5
  237. package/plugins/pagination/pagination.js +37 -175
  238. package/plugins/pagination/pagination.mjs +37 -175
  239. package/plugins/pagination/strategies/autoPageSize.js +2 -2
  240. package/plugins/pagination/strategies/autoPageSize.mjs +2 -2
  241. package/plugins/pagination/ui.js +6 -10
  242. package/plugins/pagination/ui.mjs +7 -11
  243. package/plugins/stretchColumns/calculator.js +3 -1
  244. package/plugins/stretchColumns/calculator.mjs +3 -1
  245. package/plugins/undoRedo/undoRedo.js +16 -6
  246. package/plugins/undoRedo/undoRedo.mjs +16 -5
  247. package/renderers/checkboxRenderer/checkboxRenderer.js +12 -15
  248. package/renderers/checkboxRenderer/checkboxRenderer.mjs +12 -15
  249. package/selection/selection.js +1 -1
  250. package/selection/selection.mjs +1 -1
  251. package/settings.d.ts +3 -0
  252. package/shortcutContexts/commands/index.js +2 -1
  253. package/shortcutContexts/commands/index.mjs +2 -1
  254. package/shortcutContexts/commands/tabNavigation.js +51 -0
  255. package/shortcutContexts/commands/tabNavigation.mjs +48 -0
  256. package/shortcutContexts/constants.js +16 -1
  257. package/shortcutContexts/constants.mjs +16 -1
  258. package/shortcutContexts/editor.js +2 -2
  259. package/shortcutContexts/editor.mjs +3 -3
  260. package/shortcutContexts/grid.js +19 -3
  261. package/shortcutContexts/grid.mjs +20 -4
  262. package/shortcuts/manager.d.ts +1 -0
  263. package/shortcuts/manager.js +17 -2
  264. package/shortcuts/manager.mjs +17 -2
  265. package/styles/handsontable.css +192 -35
  266. package/styles/handsontable.min.css +3 -3
  267. package/styles/ht-icons-horizon.css +233 -0
  268. package/styles/ht-icons-horizon.min.css +30 -0
  269. package/styles/ht-icons-main.css +233 -0
  270. package/styles/ht-icons-main.min.css +30 -0
  271. package/styles/ht-theme-classic-no-icons.css +399 -0
  272. package/styles/ht-theme-classic-no-icons.min.css +30 -0
  273. package/styles/ht-theme-classic.css +308 -556
  274. package/styles/ht-theme-classic.min.css +3 -3
  275. package/styles/ht-theme-horizon-no-icons.css +405 -0
  276. package/styles/ht-theme-horizon-no-icons.min.css +30 -0
  277. package/styles/ht-theme-horizon.css +312 -556
  278. package/styles/ht-theme-horizon.min.css +3 -3
  279. package/styles/ht-theme-main-no-icons.css +396 -0
  280. package/styles/ht-theme-main-no-icons.min.css +30 -0
  281. package/styles/ht-theme-main.css +303 -556
  282. package/styles/ht-theme-main.min.css +3 -3
  283. package/tableView.js +23 -5
  284. package/tableView.mjs +23 -5
  285. package/utils/dataStructures/uniqueMap.js +10 -0
  286. package/utils/dataStructures/uniqueMap.mjs +10 -0
  287. package/utils/ghostTable.js +0 -3
  288. package/utils/ghostTable.mjs +0 -3
  289. package/utils/stylesHandler.js +19 -4
  290. package/utils/stylesHandler.mjs +19 -4
  291. package/core/focusCatcher/index.js +0 -131
  292. package/core/focusCatcher/index.mjs +0 -127
  293. package/core/focusCatcher/utils.js +0 -31
  294. package/core/focusCatcher/utils.mjs +0 -27
  295. package/plugins/pagination/focusController.js +0 -27
  296. package/plugins/pagination/focusController.mjs +0 -23
@@ -0,0 +1,102 @@
1
+ import "core-js/modules/es.error.cause.js";
2
+ import "core-js/modules/es.array.push.js";
3
+ import "core-js/modules/esnext.iterator.constructor.js";
4
+ import "core-js/modules/esnext.iterator.map.js";
5
+ import { DIALOG_CLASS_NAME } from "../constants.mjs";
6
+ import { stripTags } from "../../../helpers/string.mjs";
7
+ import { html } from "../../../helpers/templateLiteralTag.mjs";
8
+ /**
9
+ * The `confirmTemplate` function returns a HTML string with the confirm template.
10
+ *
11
+ * @param {object} vars The variables to use for the template.
12
+ * @param {string} vars.id The ID of the confirm.
13
+ * @param {string} vars.title The title of the confirm.
14
+ * @param {string} vars.description The description of the confirm.
15
+ * @param {object[]} vars.buttons The buttons to display in the confirm.
16
+ * - `text`: The text of the button.
17
+ * - `type`: The type of the button ('primary' | 'secondary').
18
+ * - `callback`: The callback to trigger when the button is clicked.
19
+ * @returns {string} HTML string with the confirm template.
20
+ */
21
+ export function confirmTemplate(_ref) {
22
+ let {
23
+ id = '',
24
+ title = '',
25
+ description = '',
26
+ buttons = []
27
+ } = _ref;
28
+ /**
29
+ * Returns the HTML string for the template.
30
+ *
31
+ * @returns {string}
32
+ */
33
+ function template() {
34
+ return `
35
+ <div tabindex="-1" data-ref="contentElement" class="${DIALOG_CLASS_NAME}__content-wrapper-inner">
36
+ <div class="${DIALOG_CLASS_NAME}__content">
37
+ <h2
38
+ id="${id}-dialog-confirm-title"
39
+ class="${DIALOG_CLASS_NAME}__title">${stripTags(title)}</h2>
40
+ <p
41
+ id="${id}-dialog-confirm-description"
42
+ class="${DIALOG_CLASS_NAME}__description">${stripTags(description)}</p>
43
+ </div>
44
+ ${buttons.length > 0 ? `
45
+ <div data-ref="buttonsContainer" class="${DIALOG_CLASS_NAME}__buttons">
46
+ ${buttons.map(button => `
47
+ <button class="ht-button ht-button--${button.type}">${stripTags(button.text)}</button>
48
+ `).join('')}
49
+ </div>
50
+ ` : ''}
51
+ </div>
52
+ `;
53
+ }
54
+ let fragment = null;
55
+ const refs = {};
56
+
57
+ /**
58
+ * Compiles the template.
59
+ *
60
+ * @returns {object} The compiled template.
61
+ */
62
+ function compile() {
63
+ const elements = html`${template()}`;
64
+ Object.assign(refs, elements.refs);
65
+ fragment = elements.fragment;
66
+ return elements;
67
+ }
68
+
69
+ /**
70
+ * Gets the focusable elements of the template.
71
+ *
72
+ * @returns {HTMLElement[]} The focusable elements.
73
+ */
74
+ function focusableElements() {
75
+ if (fragment === null) {
76
+ throw new Error('Compile the template first.');
77
+ }
78
+ const {
79
+ contentElement,
80
+ buttonsContainer
81
+ } = refs;
82
+ const elements = [];
83
+ if (buttonsContainer) {
84
+ elements.push(...Array.from(buttonsContainer.children));
85
+ } else {
86
+ elements.push(contentElement);
87
+ }
88
+ return elements;
89
+ }
90
+ return {
91
+ TEMPLATE_NAME: 'confirm',
92
+ dialogA11YOptions() {
93
+ return {
94
+ role: 'alertdialog',
95
+ ariaLabelledby: `${id}-dialog-confirm-title`,
96
+ ariaDescribedby: description ? `${id}-dialog-confirm-description` : undefined
97
+ };
98
+ },
99
+ compile,
100
+ focusableElements
101
+ };
102
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ var _base = require("./base");
5
+ var _confirm = require("./confirm");
6
+ const TEMPLATES = exports.TEMPLATES = new Map([['base', _base.baseTemplate], ['confirm', _confirm.confirmTemplate]]);
@@ -0,0 +1,4 @@
1
+ import { baseTemplate } from "./base.mjs";
2
+ import { confirmTemplate } from "./confirm.mjs";
3
+ const TEMPLATES = new Map([['base', baseTemplate], ['confirm', confirmTemplate]]);
4
+ export { TEMPLATES };
@@ -2,23 +2,27 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  require("core-js/modules/es.error.cause.js");
5
+ require("core-js/modules/esnext.iterator.constructor.js");
6
+ require("core-js/modules/esnext.iterator.filter.js");
7
+ require("core-js/modules/esnext.iterator.for-each.js");
8
+ require("core-js/modules/esnext.iterator.map.js");
5
9
  var _templateLiteralTag = require("../../helpers/templateLiteralTag");
6
10
  var _object = require("../../helpers/object");
7
11
  var _localHooks = _interopRequireDefault(require("../../mixins/localHooks"));
8
12
  var _element = require("../../helpers/dom/element");
9
13
  var _a11y = require("../../helpers/a11y");
14
+ var _templates = require("./templates");
15
+ var _constants = require("./constants");
10
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
+ function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
11
18
  function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
12
19
  function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
13
20
  function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
14
21
  function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
15
22
  function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
16
- const DIALOG_CLASS_NAME = 'ht-dialog';
17
- const TEMPLATE = `
18
- <div data-ref="dialogElement" class="${DIALOG_CLASS_NAME}">
19
- <div data-ref="contentWrapperElement" class="${DIALOG_CLASS_NAME}__content-wrapper">
20
- <div data-ref="contentElement" class="${DIALOG_CLASS_NAME}__content"></div>
21
- </div>
23
+ const CONTAINER_TEMPLATE = `
24
+ <div data-ref="dialogElement" class="${_constants.DIALOG_CLASS_NAME}">
25
+ <div data-ref="dialogWrapperElement" class="${_constants.DIALOG_CLASS_NAME}__content-wrapper">
22
26
  </div>
23
27
  `;
24
28
 
@@ -32,12 +36,20 @@ const TEMPLATE = `
32
36
  var _rootElement = /*#__PURE__*/new WeakMap();
33
37
  var _refs = /*#__PURE__*/new WeakMap();
34
38
  var _isRtl = /*#__PURE__*/new WeakMap();
39
+ var _animationStarted = /*#__PURE__*/new WeakMap();
40
+ var _template = /*#__PURE__*/new WeakMap();
41
+ var _templateButtonCallbacks = /*#__PURE__*/new WeakMap();
42
+ var _DialogUI_brand = /*#__PURE__*/new WeakSet();
35
43
  class DialogUI {
36
44
  constructor(_ref) {
37
45
  let {
38
46
  rootElement,
39
47
  isRtl
40
48
  } = _ref;
49
+ /**
50
+ * Handles the transition end event.
51
+ */
52
+ _classPrivateMethodInitSpec(this, _DialogUI_brand);
41
53
  /**
42
54
  * The root element where the dialog UI will be installed.
43
55
  *
@@ -56,11 +68,55 @@ class DialogUI {
56
68
  * @type {boolean}
57
69
  */
58
70
  _classPrivateFieldInitSpec(this, _isRtl, false);
71
+ /**
72
+ * Indicates if the animation has started.
73
+ *
74
+ * @type {boolean}
75
+ */
76
+ _classPrivateFieldInitSpec(this, _animationStarted, false);
77
+ /**
78
+ * The template to use for the dialog.
79
+ *
80
+ * @type {function(): string}
81
+ */
82
+ _classPrivateFieldInitSpec(this, _template, _templates.TEMPLATES.get('base'));
83
+ /**
84
+ * The callbacks of the template buttons to trigger when the button is clicked.
85
+ *
86
+ * @type {Array<function(MouseEvent)>}
87
+ */
88
+ _classPrivateFieldInitSpec(this, _templateButtonCallbacks, []);
59
89
  _classPrivateFieldSet(_rootElement, this, rootElement);
60
90
  _classPrivateFieldSet(_isRtl, this, isRtl);
61
91
  this.install();
62
92
  }
63
93
 
94
+ /**
95
+ * Uses the specified template for the dialog.
96
+ *
97
+ * @param {string} templateName The name of the template to use.
98
+ * @param {object} templateVars The variables to use for the template.
99
+ */
100
+ useTemplate(templateName) {
101
+ var _templateVars$buttons;
102
+ let templateVars = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
103
+ if (!_templates.TEMPLATES.has(templateName) || templateName === 'base') {
104
+ const validTemplates = Array.from(_templates.TEMPLATES.keys()).filter(template => template !== 'base').join(', ');
105
+ throw new Error((0, _templateLiteralTag.toSingleLine)`Invalid template: ${templateName}.\x20
106
+ Valid templates are: ${validTemplates}.`);
107
+ }
108
+ _classPrivateFieldSet(_template, this, _templates.TEMPLATES.get(templateName)(templateVars));
109
+ _classPrivateFieldSet(_templateButtonCallbacks, this, ((_templateVars$buttons = templateVars.buttons) !== null && _templateVars$buttons !== void 0 ? _templateVars$buttons : []).map(button => button.callback));
110
+ }
111
+
112
+ /**
113
+ * Uses the default template for the dialog for the `content` option.
114
+ */
115
+ useDefaultTemplate() {
116
+ _classPrivateFieldSet(_template, this, _templates.TEMPLATES.get('base')());
117
+ _classPrivateFieldSet(_templateButtonCallbacks, this, []);
118
+ }
119
+
64
120
  /**
65
121
  * Creates the dialog UI elements and sets up the structure.
66
122
  */
@@ -69,15 +125,16 @@ class DialogUI {
69
125
  if ((_classPrivateFieldGet2 = _classPrivateFieldGet(_refs, this)) !== null && _classPrivateFieldGet2 !== void 0 && _classPrivateFieldGet2.dialogElement) {
70
126
  return;
71
127
  }
72
- const elements = (0, _templateLiteralTag.html)`${TEMPLATE}`;
128
+ const elements = (0, _templateLiteralTag.html)`${CONTAINER_TEMPLATE}`;
73
129
  _classPrivateFieldSet(_refs, this, elements.refs);
74
130
  const {
75
131
  dialogElement
76
132
  } = _classPrivateFieldGet(_refs, this);
77
- dialogElement.addEventListener('click', () => this.runLocalHooks('clickDialogElement'));
78
133
 
79
134
  // Set ARIA attributes
80
- (0, _element.setAttribute)(dialogElement, [(0, _a11y.A11Y_MODAL)(), (0, _a11y.A11Y_TABINDEX)(-1), ['dir', _classPrivateFieldGet(_isRtl, this) ? 'rtl' : 'ltr']]);
135
+ (0, _element.setAttribute)(dialogElement, [(0, _a11y.A11Y_MODAL)(), ['dir', _classPrivateFieldGet(_isRtl, this) ? 'rtl' : 'ltr']]);
136
+ dialogElement.addEventListener('transitionstart', () => _assertClassBrand(_DialogUI_brand, this, _onTransitionStart).call(this));
137
+ dialogElement.addEventListener('transitionend', () => _assertClassBrand(_DialogUI_brand, this, _onTransitionEnd).call(this));
81
138
 
82
139
  // Append to Handsontable after table grid element
83
140
  _classPrivateFieldGet(_rootElement, this).after(elements.fragment);
@@ -88,18 +145,17 @@ class DialogUI {
88
145
  *
89
146
  * @returns {HTMLElement} The dialog element.
90
147
  */
91
- getDialogElement() {
148
+ getContainer() {
92
149
  return _classPrivateFieldGet(_refs, this).dialogElement;
93
150
  }
94
151
 
95
152
  /**
96
- * Checks if the given element is inside the dialog.
153
+ * Gets the focusable elements.
97
154
  *
98
- * @param {HTMLElement} element - The element to check.
99
- * @returns {boolean} Returns `true` if the element is inside the dialog, `false` otherwise.
155
+ * @returns {HTMLElement[]} The focusable elements.
100
156
  */
101
- isInsideDialog(element) {
102
- return _classPrivateFieldGet(_refs, this).dialogElement.contains(element);
157
+ getFocusableElements() {
158
+ return _classPrivateFieldGet(_template, this).focusableElements();
103
159
  }
104
160
 
105
161
  /**
@@ -126,19 +182,31 @@ class DialogUI {
126
182
  animation,
127
183
  a11y
128
184
  } = _ref2;
185
+ const elements = _classPrivateFieldGet(_template, this).compile();
129
186
  const {
130
187
  dialogElement,
131
- contentElement
188
+ dialogWrapperElement
189
+ } = _classPrivateFieldGet(_refs, this);
190
+ dialogWrapperElement.innerHTML = '';
191
+ dialogWrapperElement.appendChild(elements.fragment);
192
+ Object.assign(_classPrivateFieldGet(_refs, this), elements.refs);
193
+ const {
194
+ contentElement,
195
+ buttonsContainer
132
196
  } = _classPrivateFieldGet(_refs, this);
197
+ if (_classPrivateFieldGet(_template, this).TEMPLATE_NAME !== 'base') {
198
+ Object.assign(a11y, _classPrivateFieldGet(_template, this).dialogA11YOptions());
199
+ }
133
200
 
134
201
  // Dialog class name
135
202
  const customClass = customClassName ? ` ${customClassName}` : '';
136
- const backgroundClass = background ? ` ${DIALOG_CLASS_NAME}--background-${background}` : '';
137
- const animationClass = animation ? ` ${DIALOG_CLASS_NAME}--animation` : '';
138
- const showClass = isVisible ? ` ${DIALOG_CLASS_NAME}--show` : '';
203
+ const backgroundClass = background ? ` ${_constants.DIALOG_CLASS_NAME}--background-${background}` : '';
204
+ const animationClass = animation ? ` ${_constants.DIALOG_CLASS_NAME}--animation` : '';
205
+ const showClass = isVisible ? ` ${_constants.DIALOG_CLASS_NAME}--show` : '';
139
206
 
140
207
  // Update dialog class name
141
- dialogElement.className = `${DIALOG_CLASS_NAME}${customClass}${backgroundClass}${animationClass}${showClass}`;
208
+ dialogElement.className = [_constants.DIALOG_CLASS_NAME, `${_constants.DIALOG_CLASS_NAME}--${_classPrivateFieldGet(_template, this).TEMPLATE_NAME}`, 'handsontable', customClass, backgroundClass, animationClass, showClass].join(' ');
209
+ (0, _element.setAttribute)(dialogElement, [_classPrivateFieldGet(_template, this).TEMPLATE_NAME === 'base' ? (0, _a11y.A11Y_TABINDEX)(-1) : undefined]);
142
210
 
143
211
  // Dialog aria attributes
144
212
  (0, _element.setAttribute)(dialogElement, [a11y.role === 'alertdialog' ? (0, _a11y.A11Y_ALERTDIALOG)() : (0, _a11y.A11Y_DIALOG)()]);
@@ -159,19 +227,27 @@ class DialogUI {
159
227
  }
160
228
 
161
229
  // Dialog content class name
162
- const contentBackgroundClass = contentBackground ? ` ${DIALOG_CLASS_NAME}__content--background` : '';
230
+ const contentBackgroundClass = contentBackground ? ` ${_constants.DIALOG_CLASS_NAME}__content--background` : '';
163
231
 
164
232
  // Update content class name
165
- contentElement.className = `${DIALOG_CLASS_NAME}__content${contentBackgroundClass}`;
166
-
167
- // Clear existing dialog content
168
- contentElement.innerHTML = '';
233
+ (0, _element.addClass)(contentElement, `${_constants.DIALOG_CLASS_NAME}__content${contentBackgroundClass}`);
234
+ if (_classPrivateFieldGet(_template, this).TEMPLATE_NAME === 'base') {
235
+ // Clear existing dialog content
236
+ contentElement.innerHTML = '';
169
237
 
170
- // Render new dialog content
171
- if (typeof content === 'string') {
172
- (0, _element.fastInnerHTML)(contentElement, content);
173
- } else if (content instanceof HTMLElement || content instanceof DocumentFragment) {
174
- contentElement.appendChild(content);
238
+ // Render new dialog content
239
+ if (typeof content === 'string') {
240
+ (0, _element.fastInnerHTML)(contentElement, content);
241
+ } else if (content instanceof HTMLElement || content instanceof DocumentFragment) {
242
+ contentElement.appendChild(content);
243
+ }
244
+ } else if (buttonsContainer) {
245
+ Array.from(buttonsContainer.children).forEach((button, index) => {
246
+ const callback = _classPrivateFieldGet(_templateButtonCallbacks, this)[index];
247
+ if (callback) {
248
+ button.addEventListener('click', callback);
249
+ }
250
+ });
175
251
  }
176
252
  return this;
177
253
  }
@@ -193,7 +269,8 @@ class DialogUI {
193
269
  // eslint-disable-next-line no-unused-expressions
194
270
  dialogElement.offsetHeight;
195
271
  }
196
- (0, _element.addClass)(dialogElement, `${DIALOG_CLASS_NAME}--show`);
272
+ (0, _element.addClass)(dialogElement, `${_constants.DIALOG_CLASS_NAME}--show`);
273
+ _classPrivateFieldSet(_animationStarted, this, false);
197
274
  return this;
198
275
  }
199
276
 
@@ -207,18 +284,11 @@ class DialogUI {
207
284
  const {
208
285
  dialogElement
209
286
  } = _classPrivateFieldGet(_refs, this);
210
- (0, _element.removeClass)(dialogElement, `${DIALOG_CLASS_NAME}--show`);
211
- if (animation) {
212
- dialogElement.addEventListener('transitionend', () => {
213
- if (!(0, _element.hasClass)(dialogElement, `${DIALOG_CLASS_NAME}--show`)) {
214
- dialogElement.style.display = 'none';
215
- }
216
- }, {
217
- once: true
218
- });
219
- } else {
287
+ (0, _element.removeClass)(dialogElement, `${_constants.DIALOG_CLASS_NAME}--show`);
288
+ if (animation && !_classPrivateFieldGet(_animationStarted, this) || !animation) {
220
289
  dialogElement.style.display = 'none';
221
290
  }
291
+ _classPrivateFieldSet(_animationStarted, this, false);
222
292
  return this;
223
293
  }
224
294
 
@@ -261,4 +331,18 @@ class DialogUI {
261
331
  }
262
332
  }
263
333
  exports.DialogUI = DialogUI;
334
+ function _onTransitionEnd() {
335
+ const {
336
+ dialogElement
337
+ } = _classPrivateFieldGet(_refs, this);
338
+ if (!(0, _element.hasClass)(dialogElement, `${_constants.DIALOG_CLASS_NAME}--show`)) {
339
+ dialogElement.style.display = 'none';
340
+ }
341
+ }
342
+ /**
343
+ * Handles the transition start event. This is used to track if the animation has started.
344
+ */
345
+ function _onTransitionStart() {
346
+ _classPrivateFieldSet(_animationStarted, this, true);
347
+ }
264
348
  (0, _object.mixin)(DialogUI, _localHooks.default);
@@ -1,20 +1,24 @@
1
1
  import "core-js/modules/es.error.cause.js";
2
+ import "core-js/modules/esnext.iterator.constructor.js";
3
+ import "core-js/modules/esnext.iterator.filter.js";
4
+ import "core-js/modules/esnext.iterator.for-each.js";
5
+ import "core-js/modules/esnext.iterator.map.js";
6
+ function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
2
7
  function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
3
8
  function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
4
9
  function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
5
10
  function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
6
11
  function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
7
- import { html } from "../../helpers/templateLiteralTag.mjs";
12
+ import { html, toSingleLine } from "../../helpers/templateLiteralTag.mjs";
8
13
  import { mixin } from "../../helpers/object.mjs";
9
14
  import localHooks from "../../mixins/localHooks.mjs";
10
15
  import { addClass, removeClass, hasClass, fastInnerHTML, setAttribute, removeAttribute } from "../../helpers/dom/element.mjs";
11
16
  import { A11Y_DIALOG, A11Y_MODAL, A11Y_TABINDEX, A11Y_LABEL, A11Y_LABELED_BY, A11Y_DESCRIBED_BY, A11Y_ALERTDIALOG } from "../../helpers/a11y.mjs";
12
- const DIALOG_CLASS_NAME = 'ht-dialog';
13
- const TEMPLATE = `
17
+ import { TEMPLATES } from "./templates/index.mjs";
18
+ import { DIALOG_CLASS_NAME } from "./constants.mjs";
19
+ const CONTAINER_TEMPLATE = `
14
20
  <div data-ref="dialogElement" class="${DIALOG_CLASS_NAME}">
15
- <div data-ref="contentWrapperElement" class="${DIALOG_CLASS_NAME}__content-wrapper">
16
- <div data-ref="contentElement" class="${DIALOG_CLASS_NAME}__content"></div>
17
- </div>
21
+ <div data-ref="dialogWrapperElement" class="${DIALOG_CLASS_NAME}__content-wrapper">
18
22
  </div>
19
23
  `;
20
24
 
@@ -28,12 +32,20 @@ const TEMPLATE = `
28
32
  var _rootElement = /*#__PURE__*/new WeakMap();
29
33
  var _refs = /*#__PURE__*/new WeakMap();
30
34
  var _isRtl = /*#__PURE__*/new WeakMap();
35
+ var _animationStarted = /*#__PURE__*/new WeakMap();
36
+ var _template = /*#__PURE__*/new WeakMap();
37
+ var _templateButtonCallbacks = /*#__PURE__*/new WeakMap();
38
+ var _DialogUI_brand = /*#__PURE__*/new WeakSet();
31
39
  export class DialogUI {
32
40
  constructor(_ref) {
33
41
  let {
34
42
  rootElement,
35
43
  isRtl
36
44
  } = _ref;
45
+ /**
46
+ * Handles the transition end event.
47
+ */
48
+ _classPrivateMethodInitSpec(this, _DialogUI_brand);
37
49
  /**
38
50
  * The root element where the dialog UI will be installed.
39
51
  *
@@ -52,11 +64,55 @@ export class DialogUI {
52
64
  * @type {boolean}
53
65
  */
54
66
  _classPrivateFieldInitSpec(this, _isRtl, false);
67
+ /**
68
+ * Indicates if the animation has started.
69
+ *
70
+ * @type {boolean}
71
+ */
72
+ _classPrivateFieldInitSpec(this, _animationStarted, false);
73
+ /**
74
+ * The template to use for the dialog.
75
+ *
76
+ * @type {function(): string}
77
+ */
78
+ _classPrivateFieldInitSpec(this, _template, TEMPLATES.get('base'));
79
+ /**
80
+ * The callbacks of the template buttons to trigger when the button is clicked.
81
+ *
82
+ * @type {Array<function(MouseEvent)>}
83
+ */
84
+ _classPrivateFieldInitSpec(this, _templateButtonCallbacks, []);
55
85
  _classPrivateFieldSet(_rootElement, this, rootElement);
56
86
  _classPrivateFieldSet(_isRtl, this, isRtl);
57
87
  this.install();
58
88
  }
59
89
 
90
+ /**
91
+ * Uses the specified template for the dialog.
92
+ *
93
+ * @param {string} templateName The name of the template to use.
94
+ * @param {object} templateVars The variables to use for the template.
95
+ */
96
+ useTemplate(templateName) {
97
+ var _templateVars$buttons;
98
+ let templateVars = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
99
+ if (!TEMPLATES.has(templateName) || templateName === 'base') {
100
+ const validTemplates = Array.from(TEMPLATES.keys()).filter(template => template !== 'base').join(', ');
101
+ throw new Error(toSingleLine`Invalid template: ${templateName}.\x20
102
+ Valid templates are: ${validTemplates}.`);
103
+ }
104
+ _classPrivateFieldSet(_template, this, TEMPLATES.get(templateName)(templateVars));
105
+ _classPrivateFieldSet(_templateButtonCallbacks, this, ((_templateVars$buttons = templateVars.buttons) !== null && _templateVars$buttons !== void 0 ? _templateVars$buttons : []).map(button => button.callback));
106
+ }
107
+
108
+ /**
109
+ * Uses the default template for the dialog for the `content` option.
110
+ */
111
+ useDefaultTemplate() {
112
+ _classPrivateFieldSet(_template, this, TEMPLATES.get('base')());
113
+ _classPrivateFieldSet(_templateButtonCallbacks, this, []);
114
+ }
115
+
60
116
  /**
61
117
  * Creates the dialog UI elements and sets up the structure.
62
118
  */
@@ -65,15 +121,16 @@ export class DialogUI {
65
121
  if ((_classPrivateFieldGet2 = _classPrivateFieldGet(_refs, this)) !== null && _classPrivateFieldGet2 !== void 0 && _classPrivateFieldGet2.dialogElement) {
66
122
  return;
67
123
  }
68
- const elements = html`${TEMPLATE}`;
124
+ const elements = html`${CONTAINER_TEMPLATE}`;
69
125
  _classPrivateFieldSet(_refs, this, elements.refs);
70
126
  const {
71
127
  dialogElement
72
128
  } = _classPrivateFieldGet(_refs, this);
73
- dialogElement.addEventListener('click', () => this.runLocalHooks('clickDialogElement'));
74
129
 
75
130
  // Set ARIA attributes
76
- setAttribute(dialogElement, [A11Y_MODAL(), A11Y_TABINDEX(-1), ['dir', _classPrivateFieldGet(_isRtl, this) ? 'rtl' : 'ltr']]);
131
+ setAttribute(dialogElement, [A11Y_MODAL(), ['dir', _classPrivateFieldGet(_isRtl, this) ? 'rtl' : 'ltr']]);
132
+ dialogElement.addEventListener('transitionstart', () => _assertClassBrand(_DialogUI_brand, this, _onTransitionStart).call(this));
133
+ dialogElement.addEventListener('transitionend', () => _assertClassBrand(_DialogUI_brand, this, _onTransitionEnd).call(this));
77
134
 
78
135
  // Append to Handsontable after table grid element
79
136
  _classPrivateFieldGet(_rootElement, this).after(elements.fragment);
@@ -84,18 +141,17 @@ export class DialogUI {
84
141
  *
85
142
  * @returns {HTMLElement} The dialog element.
86
143
  */
87
- getDialogElement() {
144
+ getContainer() {
88
145
  return _classPrivateFieldGet(_refs, this).dialogElement;
89
146
  }
90
147
 
91
148
  /**
92
- * Checks if the given element is inside the dialog.
149
+ * Gets the focusable elements.
93
150
  *
94
- * @param {HTMLElement} element - The element to check.
95
- * @returns {boolean} Returns `true` if the element is inside the dialog, `false` otherwise.
151
+ * @returns {HTMLElement[]} The focusable elements.
96
152
  */
97
- isInsideDialog(element) {
98
- return _classPrivateFieldGet(_refs, this).dialogElement.contains(element);
153
+ getFocusableElements() {
154
+ return _classPrivateFieldGet(_template, this).focusableElements();
99
155
  }
100
156
 
101
157
  /**
@@ -122,10 +178,21 @@ export class DialogUI {
122
178
  animation,
123
179
  a11y
124
180
  } = _ref2;
181
+ const elements = _classPrivateFieldGet(_template, this).compile();
125
182
  const {
126
183
  dialogElement,
127
- contentElement
184
+ dialogWrapperElement
185
+ } = _classPrivateFieldGet(_refs, this);
186
+ dialogWrapperElement.innerHTML = '';
187
+ dialogWrapperElement.appendChild(elements.fragment);
188
+ Object.assign(_classPrivateFieldGet(_refs, this), elements.refs);
189
+ const {
190
+ contentElement,
191
+ buttonsContainer
128
192
  } = _classPrivateFieldGet(_refs, this);
193
+ if (_classPrivateFieldGet(_template, this).TEMPLATE_NAME !== 'base') {
194
+ Object.assign(a11y, _classPrivateFieldGet(_template, this).dialogA11YOptions());
195
+ }
129
196
 
130
197
  // Dialog class name
131
198
  const customClass = customClassName ? ` ${customClassName}` : '';
@@ -134,7 +201,8 @@ export class DialogUI {
134
201
  const showClass = isVisible ? ` ${DIALOG_CLASS_NAME}--show` : '';
135
202
 
136
203
  // Update dialog class name
137
- dialogElement.className = `${DIALOG_CLASS_NAME}${customClass}${backgroundClass}${animationClass}${showClass}`;
204
+ dialogElement.className = [DIALOG_CLASS_NAME, `${DIALOG_CLASS_NAME}--${_classPrivateFieldGet(_template, this).TEMPLATE_NAME}`, 'handsontable', customClass, backgroundClass, animationClass, showClass].join(' ');
205
+ setAttribute(dialogElement, [_classPrivateFieldGet(_template, this).TEMPLATE_NAME === 'base' ? A11Y_TABINDEX(-1) : undefined]);
138
206
 
139
207
  // Dialog aria attributes
140
208
  setAttribute(dialogElement, [a11y.role === 'alertdialog' ? A11Y_ALERTDIALOG() : A11Y_DIALOG()]);
@@ -158,16 +226,24 @@ export class DialogUI {
158
226
  const contentBackgroundClass = contentBackground ? ` ${DIALOG_CLASS_NAME}__content--background` : '';
159
227
 
160
228
  // Update content class name
161
- contentElement.className = `${DIALOG_CLASS_NAME}__content${contentBackgroundClass}`;
162
-
163
- // Clear existing dialog content
164
- contentElement.innerHTML = '';
229
+ addClass(contentElement, `${DIALOG_CLASS_NAME}__content${contentBackgroundClass}`);
230
+ if (_classPrivateFieldGet(_template, this).TEMPLATE_NAME === 'base') {
231
+ // Clear existing dialog content
232
+ contentElement.innerHTML = '';
165
233
 
166
- // Render new dialog content
167
- if (typeof content === 'string') {
168
- fastInnerHTML(contentElement, content);
169
- } else if (content instanceof HTMLElement || content instanceof DocumentFragment) {
170
- contentElement.appendChild(content);
234
+ // Render new dialog content
235
+ if (typeof content === 'string') {
236
+ fastInnerHTML(contentElement, content);
237
+ } else if (content instanceof HTMLElement || content instanceof DocumentFragment) {
238
+ contentElement.appendChild(content);
239
+ }
240
+ } else if (buttonsContainer) {
241
+ Array.from(buttonsContainer.children).forEach((button, index) => {
242
+ const callback = _classPrivateFieldGet(_templateButtonCallbacks, this)[index];
243
+ if (callback) {
244
+ button.addEventListener('click', callback);
245
+ }
246
+ });
171
247
  }
172
248
  return this;
173
249
  }
@@ -190,6 +266,7 @@ export class DialogUI {
190
266
  dialogElement.offsetHeight;
191
267
  }
192
268
  addClass(dialogElement, `${DIALOG_CLASS_NAME}--show`);
269
+ _classPrivateFieldSet(_animationStarted, this, false);
193
270
  return this;
194
271
  }
195
272
 
@@ -204,17 +281,10 @@ export class DialogUI {
204
281
  dialogElement
205
282
  } = _classPrivateFieldGet(_refs, this);
206
283
  removeClass(dialogElement, `${DIALOG_CLASS_NAME}--show`);
207
- if (animation) {
208
- dialogElement.addEventListener('transitionend', () => {
209
- if (!hasClass(dialogElement, `${DIALOG_CLASS_NAME}--show`)) {
210
- dialogElement.style.display = 'none';
211
- }
212
- }, {
213
- once: true
214
- });
215
- } else {
284
+ if (animation && !_classPrivateFieldGet(_animationStarted, this) || !animation) {
216
285
  dialogElement.style.display = 'none';
217
286
  }
287
+ _classPrivateFieldSet(_animationStarted, this, false);
218
288
  return this;
219
289
  }
220
290
 
@@ -256,4 +326,18 @@ export class DialogUI {
256
326
  _classPrivateFieldSet(_refs, this, null);
257
327
  }
258
328
  }
329
+ function _onTransitionEnd() {
330
+ const {
331
+ dialogElement
332
+ } = _classPrivateFieldGet(_refs, this);
333
+ if (!hasClass(dialogElement, `${DIALOG_CLASS_NAME}--show`)) {
334
+ dialogElement.style.display = 'none';
335
+ }
336
+ }
337
+ /**
338
+ * Handles the transition start event. This is used to track if the animation has started.
339
+ */
340
+ function _onTransitionStart() {
341
+ _classPrivateFieldSet(_animationStarted, this, true);
342
+ }
259
343
  mixin(DialogUI, localHooks);