@zeyos/zx 2.1.0 → 2.2.1

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 (311) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +15 -0
  3. package/dist/types/compat/base.d.ts +156 -0
  4. package/dist/types/compat/globals.d.ts +20 -0
  5. package/dist/types/compat/index.d.ts +128 -0
  6. package/dist/types/compat/map/basic.d.ts +175 -0
  7. package/dist/types/compat/map/data.d.ts +102 -0
  8. package/dist/types/compat/map/date-time.d.ts +80 -0
  9. package/dist/types/compat/map/factory.d.ts +9 -0
  10. package/dist/types/compat/map/form.d.ts +98 -0
  11. package/dist/types/compat/map/helpers.d.ts +12 -0
  12. package/dist/types/compat/map/http.d.ts +36 -0
  13. package/dist/types/compat/map/layout.d.ts +106 -0
  14. package/dist/types/compat/map/options.d.ts +80 -0
  15. package/dist/types/compat/map/select.d.ts +95 -0
  16. package/dist/types/compat/map/stubs.d.ts +32 -0
  17. package/dist/types/compat/map/utilities.d.ts +37 -0
  18. package/dist/types/compat-entry.d.ts +5 -0
  19. package/dist/types/components/badge/badge.d.ts +46 -0
  20. package/dist/types/components/breadcrumb/breadcrumb.d.ts +200 -0
  21. package/dist/types/components/button/button.d.ts +42 -0
  22. package/dist/types/components/check-button/check-button.d.ts +98 -0
  23. package/dist/types/components/checklist/checklist.d.ts +143 -0
  24. package/dist/types/components/checklist/field-adapter.d.ts +5 -0
  25. package/dist/types/components/context-menu/context-menu.d.ts +130 -0
  26. package/dist/types/components/copy/copy-button.d.ts +48 -0
  27. package/dist/types/components/copy/copy-input.d.ts +91 -0
  28. package/dist/types/components/data-filter/data-filter.d.ts +250 -0
  29. package/dist/types/components/data-filter/filter-core.d.ts +52 -0
  30. package/dist/types/components/date-picker/date-picker.d.ts +137 -0
  31. package/dist/types/components/date-picker/date-range-picker.d.ts +350 -0
  32. package/dist/types/components/date-picker/field-adapter.d.ts +6 -0
  33. package/dist/types/components/date-picker/month-picker.d.ts +75 -0
  34. package/dist/types/components/date-picker/range-field-adapter.d.ts +7 -0
  35. package/dist/types/components/date-picker/time-picker.d.ts +127 -0
  36. package/dist/types/components/datebox/date-range-box.d.ts +218 -0
  37. package/dist/types/components/datebox/datebox.d.ts +160 -0
  38. package/dist/types/components/datebox/field-adapter.d.ts +5 -0
  39. package/dist/types/components/dialog/dialog.d.ts +284 -0
  40. package/dist/types/components/dropdown/dropdown.d.ts +118 -0
  41. package/dist/types/components/empty-state/empty-state.d.ts +38 -0
  42. package/dist/types/components/field/field.d.ts +231 -0
  43. package/dist/types/components/field-upload/field-adapter.d.ts +5 -0
  44. package/dist/types/components/field-upload/field-upload.d.ts +213 -0
  45. package/dist/types/components/fieldset/fieldset.d.ts +125 -0
  46. package/dist/types/components/finder/finder.d.ts +252 -0
  47. package/dist/types/components/form/form.d.ts +194 -0
  48. package/dist/types/components/groupbox/groupbox.d.ts +89 -0
  49. package/dist/types/components/layout/layout.d.ts +132 -0
  50. package/dist/types/components/loading/inline-loading.d.ts +86 -0
  51. package/dist/types/components/loading/progress-bar.d.ts +168 -0
  52. package/dist/types/components/loading/spinner.d.ts +34 -0
  53. package/dist/types/components/master-panel/master-panel.d.ts +112 -0
  54. package/dist/types/components/menu-button/menu-button.d.ts +142 -0
  55. package/dist/types/components/message/message.d.ts +212 -0
  56. package/dist/types/components/modal/modal.d.ts +105 -0
  57. package/dist/types/components/multi-value-editor/field-adapter.d.ts +5 -0
  58. package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +66 -0
  59. package/dist/types/components/navigation-bar/navigation-bar.d.ts +229 -0
  60. package/dist/types/components/number-field/field-adapter.d.ts +5 -0
  61. package/dist/types/components/number-field/number-field.d.ts +292 -0
  62. package/dist/types/components/pagination/pagination.d.ts +267 -0
  63. package/dist/types/components/panel/panel.d.ts +194 -0
  64. package/dist/types/components/permission/permission.d.ts +93 -0
  65. package/dist/types/components/rating/field-adapter.d.ts +5 -0
  66. package/dist/types/components/rating/rating.d.ts +213 -0
  67. package/dist/types/components/search/search.d.ts +98 -0
  68. package/dist/types/components/select/field-adapter.d.ts +5 -0
  69. package/dist/types/components/select/filter.d.ts +11 -0
  70. package/dist/types/components/select/select.d.ts +235 -0
  71. package/dist/types/components/skeleton/skeleton.d.ts +97 -0
  72. package/dist/types/components/slider/field-adapter.d.ts +5 -0
  73. package/dist/types/components/slider/slider.d.ts +216 -0
  74. package/dist/types/components/split-view/split-view.d.ts +335 -0
  75. package/dist/types/components/stepper/stepper.d.ts +314 -0
  76. package/dist/types/components/stepper/steps.d.ts +131 -0
  77. package/dist/types/components/tabbox/tabbox.d.ts +230 -0
  78. package/dist/types/components/table/sort.d.ts +49 -0
  79. package/dist/types/components/table/table.d.ts +872 -0
  80. package/dist/types/components/tag-picker/field-adapter.d.ts +5 -0
  81. package/dist/types/components/tag-picker/tag-picker.d.ts +375 -0
  82. package/dist/types/components/timebox/field-adapter.d.ts +5 -0
  83. package/dist/types/components/timebox/timebox.d.ts +121 -0
  84. package/dist/types/components/toggle/field-adapter.d.ts +5 -0
  85. package/dist/types/components/toggle/toggle.d.ts +94 -0
  86. package/dist/types/components/toolbar/toolbar.d.ts +230 -0
  87. package/dist/types/components/tooltip/tooltip.d.ts +183 -0
  88. package/dist/types/components/tree/hierarchy.d.ts +113 -0
  89. package/dist/types/components/tree/tree.d.ts +383 -0
  90. package/dist/types/components/truncate/truncate.d.ts +61 -0
  91. package/dist/types/components/value-list/field-adapter.d.ts +5 -0
  92. package/dist/types/components/value-list/value-list.d.ts +143 -0
  93. package/dist/types/core/breakpoint.d.ts +68 -0
  94. package/dist/types/core/component.d.ts +115 -0
  95. package/dist/types/core/date.d.ts +50 -0
  96. package/dist/types/core/dom.d.ts +86 -0
  97. package/dist/types/core/export.d.ts +70 -0
  98. package/dist/types/core/fontawesome.d.ts +107 -0
  99. package/dist/types/core/format.d.ts +107 -0
  100. package/dist/types/core/http.d.ts +122 -0
  101. package/dist/types/core/i18n.d.ts +35 -0
  102. package/dist/types/core/icons.d.ts +137 -0
  103. package/dist/types/core/keyboard.d.ts +72 -0
  104. package/dist/types/core/position.d.ts +45 -0
  105. package/dist/types/core/storage.d.ts +46 -0
  106. package/dist/types/core/util.d.ts +117 -0
  107. package/dist/types/elements/define.d.ts +73 -0
  108. package/dist/types/elements/reflect.d.ts +27 -0
  109. package/dist/types/index.d.ts +79 -0
  110. package/dist/types/zeyos/connect.d.ts +65 -0
  111. package/dist/types/zeyos/form.d.ts +140 -0
  112. package/dist/types/zeyos/icons.d.ts +104 -0
  113. package/dist/types/zeyos/index.d.ts +12 -0
  114. package/dist/types/zeyos/modules.d.ts +110 -0
  115. package/dist/types/zeyos/query.d.ts +157 -0
  116. package/dist/types/zeyos/schema.d.ts +79 -0
  117. package/dist/types/zeyos/select.d.ts +167 -0
  118. package/dist/types/zeyos/table.d.ts +205 -0
  119. package/dist/zx-compat.esm.js +375 -39
  120. package/dist/zx-compat.esm.min.js +1 -1
  121. package/dist/zx-compat.global.js +372 -73
  122. package/dist/zx-compat.global.min.js +3 -3
  123. package/dist/zx-zeyos.esm.js +355 -49
  124. package/dist/zx-zeyos.esm.min.js +1 -1
  125. package/dist/zx.css +68 -6
  126. package/dist/zx.esm.js +359 -73
  127. package/dist/zx.esm.min.js +3 -3
  128. package/dist/zx.global.js +359 -73
  129. package/dist/zx.global.min.js +3 -3
  130. package/dist/zx.min.css +1 -1
  131. package/docs/api.json +48 -2
  132. package/docs/llms.md +31 -0
  133. package/package.json +37 -9
  134. package/src/compat/base.js +291 -0
  135. package/src/compat/globals.js +165 -0
  136. package/src/compat/index.js +84 -0
  137. package/src/compat/map/basic.js +464 -0
  138. package/src/compat/map/data.js +232 -0
  139. package/src/compat/map/date-time.js +177 -0
  140. package/src/compat/map/factory.js +45 -0
  141. package/src/compat/map/form.js +330 -0
  142. package/src/compat/map/helpers.js +46 -0
  143. package/src/compat/map/http.js +117 -0
  144. package/src/compat/map/layout.js +256 -0
  145. package/src/compat/map/options.js +267 -0
  146. package/src/compat/map/select.js +198 -0
  147. package/src/compat/map/stubs.js +26 -0
  148. package/src/compat/map/utilities.js +113 -0
  149. package/src/compat-entry.js +11 -0
  150. package/src/components/badge/badge.css +147 -0
  151. package/src/components/badge/badge.js +92 -0
  152. package/src/components/breadcrumb/breadcrumb.css +105 -0
  153. package/src/components/breadcrumb/breadcrumb.js +331 -0
  154. package/src/components/button/button.css +104 -0
  155. package/src/components/button/button.js +76 -0
  156. package/src/components/check-button/check-button.css +66 -0
  157. package/src/components/check-button/check-button.js +167 -0
  158. package/src/components/checklist/checklist.css +65 -0
  159. package/src/components/checklist/checklist.js +282 -0
  160. package/src/components/checklist/field-adapter.js +46 -0
  161. package/src/components/context-menu/context-menu.css +54 -0
  162. package/src/components/context-menu/context-menu.js +334 -0
  163. package/src/components/copy/copy-button.css +27 -0
  164. package/src/components/copy/copy-button.js +78 -0
  165. package/src/components/copy/copy-input.css +59 -0
  166. package/src/components/copy/copy-input.js +123 -0
  167. package/src/components/data-filter/data-filter.css +53 -0
  168. package/src/components/data-filter/data-filter.js +400 -0
  169. package/src/components/data-filter/filter-core.js +128 -0
  170. package/src/components/date-picker/date-picker.css +181 -0
  171. package/src/components/date-picker/date-picker.js +500 -0
  172. package/src/components/date-picker/date-range-picker.css +264 -0
  173. package/src/components/date-picker/date-range-picker.js +990 -0
  174. package/src/components/date-picker/field-adapter.js +36 -0
  175. package/src/components/date-picker/month-picker.js +223 -0
  176. package/src/components/date-picker/range-field-adapter.js +31 -0
  177. package/src/components/date-picker/time-picker.css +191 -0
  178. package/src/components/date-picker/time-picker.js +406 -0
  179. package/src/components/datebox/date-range-box.css +128 -0
  180. package/src/components/datebox/date-range-box.js +492 -0
  181. package/src/components/datebox/datebox.css +108 -0
  182. package/src/components/datebox/datebox.js +358 -0
  183. package/src/components/datebox/field-adapter.js +34 -0
  184. package/src/components/dialog/dialog.css +74 -0
  185. package/src/components/dialog/dialog.js +450 -0
  186. package/src/components/dropdown/dropdown.css +24 -0
  187. package/src/components/dropdown/dropdown.js +288 -0
  188. package/src/components/empty-state/empty-state.css +80 -0
  189. package/src/components/empty-state/empty-state.js +92 -0
  190. package/src/components/field/field.css +127 -0
  191. package/src/components/field/field.js +605 -0
  192. package/src/components/field-upload/field-adapter.js +21 -0
  193. package/src/components/field-upload/field-upload.css +108 -0
  194. package/src/components/field-upload/field-upload.js +475 -0
  195. package/src/components/fieldset/fieldset.css +37 -0
  196. package/src/components/fieldset/fieldset.js +307 -0
  197. package/src/components/finder/finder.css +98 -0
  198. package/src/components/finder/finder.js +509 -0
  199. package/src/components/form/form.css +32 -0
  200. package/src/components/form/form.js +302 -0
  201. package/src/components/groupbox/groupbox.css +51 -0
  202. package/src/components/groupbox/groupbox.js +199 -0
  203. package/src/components/layout/layout.css +117 -0
  204. package/src/components/layout/layout.js +136 -0
  205. package/src/components/loading/inline-loading.css +34 -0
  206. package/src/components/loading/inline-loading.js +140 -0
  207. package/src/components/loading/progress-bar.css +115 -0
  208. package/src/components/loading/progress-bar.js +259 -0
  209. package/src/components/loading/spinner.css +58 -0
  210. package/src/components/loading/spinner.js +57 -0
  211. package/src/components/master-panel/master-panel.css +51 -0
  212. package/src/components/master-panel/master-panel.js +203 -0
  213. package/src/components/menu-button/menu-button.css +49 -0
  214. package/src/components/menu-button/menu-button.js +294 -0
  215. package/src/components/message/message.css +122 -0
  216. package/src/components/message/message.js +499 -0
  217. package/src/components/modal/modal.css +47 -0
  218. package/src/components/modal/modal.js +203 -0
  219. package/src/components/multi-value-editor/field-adapter.js +44 -0
  220. package/src/components/multi-value-editor/multi-value-editor.css +56 -0
  221. package/src/components/multi-value-editor/multi-value-editor.js +170 -0
  222. package/src/components/navigation-bar/navigation-bar.css +130 -0
  223. package/src/components/navigation-bar/navigation-bar.js +450 -0
  224. package/src/components/number-field/field-adapter.js +40 -0
  225. package/src/components/number-field/number-field.css +77 -0
  226. package/src/components/number-field/number-field.js +545 -0
  227. package/src/components/pagination/pagination.css +95 -0
  228. package/src/components/pagination/pagination.js +481 -0
  229. package/src/components/panel/panel.css +123 -0
  230. package/src/components/panel/panel.js +336 -0
  231. package/src/components/permission/permission.css +47 -0
  232. package/src/components/permission/permission.js +198 -0
  233. package/src/components/rating/field-adapter.js +34 -0
  234. package/src/components/rating/rating.css +97 -0
  235. package/src/components/rating/rating.js +395 -0
  236. package/src/components/search/search.css +70 -0
  237. package/src/components/search/search.js +193 -0
  238. package/src/components/select/field-adapter.js +24 -0
  239. package/src/components/select/filter.js +39 -0
  240. package/src/components/select/select.css +180 -0
  241. package/src/components/select/select.js +663 -0
  242. package/src/components/skeleton/skeleton.css +76 -0
  243. package/src/components/skeleton/skeleton.js +139 -0
  244. package/src/components/slider/field-adapter.js +36 -0
  245. package/src/components/slider/slider.css +181 -0
  246. package/src/components/slider/slider.js +399 -0
  247. package/src/components/split-view/split-view.css +139 -0
  248. package/src/components/split-view/split-view.js +806 -0
  249. package/src/components/stepper/stepper.css +234 -0
  250. package/src/components/stepper/stepper.js +459 -0
  251. package/src/components/stepper/steps.js +131 -0
  252. package/src/components/tabbox/tabbox.css +281 -0
  253. package/src/components/tabbox/tabbox.js +484 -0
  254. package/src/components/table/sort.js +85 -0
  255. package/src/components/table/table.css +364 -0
  256. package/src/components/table/table.js +1711 -0
  257. package/src/components/tag-picker/field-adapter.js +35 -0
  258. package/src/components/tag-picker/tag-picker.css +169 -0
  259. package/src/components/tag-picker/tag-picker.js +837 -0
  260. package/src/components/timebox/field-adapter.js +24 -0
  261. package/src/components/timebox/timebox.css +51 -0
  262. package/src/components/timebox/timebox.js +276 -0
  263. package/src/components/toggle/field-adapter.js +24 -0
  264. package/src/components/toggle/toggle.css +66 -0
  265. package/src/components/toggle/toggle.js +150 -0
  266. package/src/components/toolbar/toolbar.css +81 -0
  267. package/src/components/toolbar/toolbar.js +511 -0
  268. package/src/components/tooltip/tooltip.css +36 -0
  269. package/src/components/tooltip/tooltip.js +420 -0
  270. package/src/components/tree/hierarchy.js +151 -0
  271. package/src/components/tree/tree.css +99 -0
  272. package/src/components/tree/tree.js +784 -0
  273. package/src/components/truncate/truncate.css +20 -0
  274. package/src/components/truncate/truncate.js +92 -0
  275. package/src/components/value-list/field-adapter.js +24 -0
  276. package/src/components/value-list/value-list.css +108 -0
  277. package/src/components/value-list/value-list.js +336 -0
  278. package/src/core/breakpoint.js +150 -0
  279. package/src/core/component.js +292 -0
  280. package/src/core/date.js +216 -0
  281. package/src/core/dom.js +260 -0
  282. package/src/core/export.js +204 -0
  283. package/src/core/fontawesome.js +177 -0
  284. package/src/core/format.js +283 -0
  285. package/src/core/http.js +246 -0
  286. package/src/core/i18n.js +83 -0
  287. package/src/core/icons.js +283 -0
  288. package/src/core/keyboard.js +240 -0
  289. package/src/core/position.js +177 -0
  290. package/src/core/storage.js +175 -0
  291. package/src/core/util.js +336 -0
  292. package/src/elements/define.js +715 -0
  293. package/src/elements/reflect.js +79 -0
  294. package/src/index.js +131 -0
  295. package/src/zeyos/connect.js +142 -0
  296. package/src/zeyos/form.js +254 -0
  297. package/src/zeyos/icons.js +92 -0
  298. package/src/zeyos/index.js +21 -0
  299. package/src/zeyos/modules.js +269 -0
  300. package/src/zeyos/query.js +199 -0
  301. package/src/zeyos/schema.js +474 -0
  302. package/src/zeyos/select.js +175 -0
  303. package/src/zeyos/table.js +272 -0
  304. package/styles/base.css +124 -0
  305. package/styles/icons.css +34 -0
  306. package/styles/tokens/dark.css +84 -0
  307. package/styles/tokens/density.css +9 -0
  308. package/styles/tokens/global.css +80 -0
  309. package/styles/tokens/modules.css +109 -0
  310. package/styles/tokens/semantic.css +49 -0
  311. package/styles/zx.css +61 -0
@@ -0,0 +1,203 @@
1
+ import { Component } from '../../core/component.js';
2
+ import { h } from '../../core/dom.js';
3
+
4
+ /**
5
+ * @typedef {Object} ModalOptions
6
+ * @property {Node|string|number|{toElement: () => Node|null}|null} [content=null] Modal content.
7
+ * @property {string|number} [width='auto'] CSS width, or a pixel width when numeric.
8
+ * @property {boolean} [closable=true] Whether Escape may close the modal.
9
+ * @property {boolean} [lightDismiss=false] Whether a backdrop click closes the modal.
10
+ * @property {boolean} [destroyOnClose=false] Whether to destroy the modal after it closes.
11
+ * @property {(event: CustomEvent<Record<string, never>>) => void} [onopen] Open event listener.
12
+ * @property {(event: CustomEvent<{result: unknown}>) => void} [onclose] Close event listener.
13
+ * @property {(event: CustomEvent<Record<string, never>>) => void} [oncancel] Cancel event listener.
14
+ */
15
+
16
+ /**
17
+ * Thin native-dialog overlay with lifecycle-safe content and dismissal behavior.
18
+ * The constructor always creates and appends a new dialog; its target argument is ignored.
19
+ * @fires Modal#open
20
+ * @fires Modal#close
21
+ * @fires Modal#cancel
22
+ * @extends {Component<ModalOptions>}
23
+ */
24
+ export class Modal extends Component {
25
+ static cssName = 'modal';
26
+
27
+ /** @type {Readonly<ModalOptions>} */
28
+ static defaults = {
29
+ content: null,
30
+ width: 'auto',
31
+ closable: true,
32
+ lightDismiss: false,
33
+ destroyOnClose: false
34
+ };
35
+
36
+ #pendingResult;
37
+ #hasPendingResult = false;
38
+ #destroying = false;
39
+
40
+ /**
41
+ * Creates a modal appended to `document.body`.
42
+ * @param {Element|string|null} [_target=null] Ignored; Modal always owns its root dialog.
43
+ * @param {ModalOptions} [options={}] Modal options.
44
+ */
45
+ constructor(_target = null, options = {}) {
46
+ super(null, options);
47
+ this.#setWidth(this.options.width);
48
+ replaceContent(this.refs.content, this.options.content);
49
+
50
+ this.listen(this.el, 'cancel', (event) => {
51
+ const cancelEvent = this.emit('cancel');
52
+ if (!this.options.closable || cancelEvent.defaultPrevented) event.preventDefault();
53
+ });
54
+ this.listen(this.el, 'close', () => {
55
+ this.el.dataset.state = 'closed';
56
+ delete this.el.dataset.zxOverlayOrder;
57
+ const result = this.#hasPendingResult ? this.#pendingResult : (this.el.returnValue || undefined);
58
+ this.#pendingResult = undefined;
59
+ this.#hasPendingResult = false;
60
+ this.emit('close', { result });
61
+ if (this.options.destroyOnClose && !this.#destroying) this.destroy();
62
+ });
63
+ this.listen(this.el, 'click', (event) => {
64
+ if (!this.options.lightDismiss || event.target !== this.el || !isBackdropClick(this.el, event)) return;
65
+ this.close();
66
+ });
67
+ }
68
+
69
+ /**
70
+ * Creates the owned native dialog.
71
+ * @returns {HTMLDialogElement}
72
+ */
73
+ render() {
74
+ const dialog = /** @type {HTMLDialogElement} */ (h('dialog', {
75
+ class: 'zx-modal'
76
+ }, h('div', { class: 'zx-modal__content', ref: 'content' })));
77
+ dialog.dataset.state = 'closed';
78
+ document.body.append(dialog);
79
+ return dialog;
80
+ }
81
+
82
+ /**
83
+ * Opens the modal in the browser top layer.
84
+ * @returns {this}
85
+ * @fires Modal#open
86
+ */
87
+ open() {
88
+ if (this.isOpen()) return this;
89
+ this.el.dataset.zxOverlayOrder = String(nextOverlayOrder());
90
+ this.el.returnValue = '';
91
+ try {
92
+ this.el.showModal();
93
+ } catch (error) {
94
+ delete this.el.dataset.zxOverlayOrder;
95
+ throw error;
96
+ }
97
+ this.el.dataset.state = 'open';
98
+ this.emit('open');
99
+ return this;
100
+ }
101
+
102
+ /**
103
+ * Closes the modal with an optional result.
104
+ * @param {unknown} [result] Result included in the close event.
105
+ * @returns {this}
106
+ */
107
+ close(result) {
108
+ if (!this.isOpen()) return this;
109
+ this.#pendingResult = result;
110
+ this.#hasPendingResult = true;
111
+ this.el.close(typeof result === 'string' ? result : '');
112
+ return this;
113
+ }
114
+
115
+ /**
116
+ * Replaces the modal content without interpreting strings as HTML.
117
+ * @param {Node|string|number|{toElement: () => Node|null}|null} content Content to display.
118
+ * @returns {this}
119
+ */
120
+ setContent(content) {
121
+ replaceContent(this.refs.content, content);
122
+ return this;
123
+ }
124
+
125
+ /**
126
+ * Reports whether the native dialog is open.
127
+ * @returns {boolean}
128
+ */
129
+ isOpen() {
130
+ return this.el.open;
131
+ }
132
+
133
+ /**
134
+ * Closes and removes the owned dialog. Safe to call repeatedly.
135
+ * @returns {void}
136
+ */
137
+ destroy() {
138
+ if (this.#destroying) return;
139
+ this.#destroying = true;
140
+ if (this.isOpen()) this.el.close();
141
+ super.destroy();
142
+ }
143
+
144
+ /** @param {string|number} width @returns {void} */
145
+ #setWidth(width) {
146
+ if (typeof width === 'number' && Number.isFinite(width)) {
147
+ this.el.style.inlineSize = `${Math.max(0, width)}px`;
148
+ } else {
149
+ this.el.style.inlineSize = String(width ?? 'auto');
150
+ }
151
+ }
152
+ }
153
+
154
+ /**
155
+ * Fired after the modal enters the top layer.
156
+ * @event Modal#open
157
+ * @type {CustomEvent<Record<string, never>>}
158
+ */
159
+
160
+ /**
161
+ * Fired after the native dialog closes.
162
+ * @event Modal#close
163
+ * @type {CustomEvent<{result: unknown}>}
164
+ */
165
+
166
+ /**
167
+ * Fired when Escape requests cancellation. Preventing it keeps the modal open.
168
+ * @event Modal#cancel
169
+ * @type {CustomEvent<Record<string, never>>}
170
+ */
171
+
172
+ /**
173
+ * @param {Element} target
174
+ * @param {Node|string|number|{toElement: () => Node|null}|null|undefined} content
175
+ * @returns {void}
176
+ */
177
+ function replaceContent(target, content) {
178
+ target.replaceChildren();
179
+ if (content == null) return;
180
+ if (typeof content === 'string' || typeof content === 'number') {
181
+ target.append(document.createTextNode(String(content)));
182
+ } else if (typeof content.toElement === 'function') {
183
+ const element = content.toElement();
184
+ if (element) target.append(element);
185
+ } else if (typeof content.nodeType === 'number') {
186
+ target.append(content);
187
+ }
188
+ }
189
+
190
+ /** @param {HTMLDialogElement} dialog @param {MouseEvent} event @returns {boolean} */
191
+ function isBackdropClick(dialog, event) {
192
+ const rect = dialog.getBoundingClientRect();
193
+ return event.clientX < rect.left || event.clientX > rect.right ||
194
+ event.clientY < rect.top || event.clientY > rect.bottom;
195
+ }
196
+
197
+ /** @returns {number} */
198
+ function nextOverlayOrder() {
199
+ const orders = Array.from(document.querySelectorAll('[data-zx-overlay-order]'), (element) =>
200
+ Number(element.getAttribute('data-zx-overlay-order')) || 0
201
+ );
202
+ return Math.max(0, ...orders) + 1;
203
+ }
@@ -0,0 +1,44 @@
1
+ import { Field } from '../field/field.js';
2
+ import { MultiValueEditor } from './multi-value-editor.js';
3
+
4
+ /**
5
+ * Registers the MultiValueEditor-backed `multivalueeditor` field type.
6
+ * @returns {void}
7
+ */
8
+ export function registerMultiValueEditorFieldAdapter() {
9
+ Field.register('multivalueeditor', (field, options) => {
10
+ const editor = field.own(new MultiValueEditor(null, {
11
+ ...(options.props ?? {}),
12
+ values: Array.isArray(options.value) ? options.value : []
13
+ }));
14
+ const originalDisabled = new WeakMap();
15
+ let disabled = false;
16
+ const syncDisabled = () => {
17
+ editor.el.setAttribute('aria-disabled', String(disabled));
18
+ for (const control of editor.el.querySelectorAll('input, button, select, textarea')) {
19
+ if (disabled) {
20
+ if (!originalDisabled.has(control)) originalDisabled.set(control, Boolean(control.disabled));
21
+ control.disabled = true;
22
+ } else if (originalDisabled.has(control)) {
23
+ control.disabled = originalDisabled.get(control);
24
+ originalDisabled.delete(control);
25
+ }
26
+ }
27
+ };
28
+ field.listen(editor.el, 'change', (event) => event.stopImmediatePropagation());
29
+ editor.on('change', (event) => field.emit('change', { value: event.detail.values }));
30
+ return {
31
+ el: editor.el,
32
+ get: () => editor.getValues(),
33
+ set: (value) => {
34
+ editor.setValues(Array.isArray(value) ? value : [], { silent: true });
35
+ syncDisabled();
36
+ },
37
+ focus: () => editor.el.querySelector('.zx-multi-value-editor__value:not([disabled]), button:not([disabled])')?.focus(),
38
+ setDisabled: (value) => {
39
+ disabled = Boolean(value);
40
+ syncDisabled();
41
+ }
42
+ };
43
+ });
44
+ }
@@ -0,0 +1,56 @@
1
+ .zx-multi-value-editor {
2
+ display: grid;
3
+ gap: var(--zx-space-3);
4
+ min-inline-size: 0;
5
+ padding: var(--zx-space-3);
6
+ border: 1px solid var(--zx-color-border);
7
+ border-radius: var(--zx-radius-lg);
8
+ background: var(--zx-color-bg-surface);
9
+ container-type: inline-size;
10
+ }
11
+
12
+ .zx-multi-value-editor__rows {
13
+ display: grid;
14
+ gap: var(--zx-space-2);
15
+ }
16
+
17
+ .zx-multi-value-editor__row {
18
+ display: grid;
19
+ grid-template-columns: minmax(0, 1fr) auto;
20
+ gap: var(--zx-space-2);
21
+ align-items: center;
22
+ }
23
+
24
+ .zx-multi-value-editor__value {
25
+ inline-size: 100%;
26
+ }
27
+
28
+ .zx-multi-value-editor__controls {
29
+ display: inline-flex;
30
+ gap: var(--zx-space-1);
31
+ }
32
+
33
+ .zx-multi-value-editor__controls .zx-btn {
34
+ min-inline-size: var(--zx-control-height);
35
+ padding-inline: var(--zx-space-2);
36
+ }
37
+
38
+ .zx-multi-value-editor__controls .zx-btn:last-child {
39
+ color: var(--zx-color-danger);
40
+ }
41
+
42
+ .zx-multi-value-editor__add {
43
+ justify-self: start;
44
+ border-color: var(--zx-color-accent);
45
+ color: var(--zx-color-accent);
46
+ }
47
+
48
+ @container (max-width: 24rem) {
49
+ .zx-multi-value-editor__row {
50
+ grid-template-columns: minmax(0, 1fr);
51
+ }
52
+
53
+ .zx-multi-value-editor__controls {
54
+ justify-self: end;
55
+ }
56
+ }
@@ -0,0 +1,170 @@
1
+ import { Component } from '../../core/component.js';
2
+ import { h } from '../../core/dom.js';
3
+
4
+ /**
5
+ * @typedef {Object} MultiValueEditorOptions
6
+ * @property {unknown[]} [values=[]] Initial ordered values.
7
+ * @property {unknown[]|Record<string, string>|null} [options=null] Allowed values; null uses text inputs.
8
+ * @property {string} [addLabel='Add value'] Add-row button text.
9
+ */
10
+
11
+ /**
12
+ * Ordered value editor with explicit editable rows and controls.
13
+ * @fires MultiValueEditor#change
14
+ * @extends {Component<MultiValueEditorOptions>}
15
+ */
16
+ export class MultiValueEditor extends Component {
17
+ static cssName = 'multi-value-editor';
18
+
19
+ /** @type {MultiValueEditorOptions} */
20
+ static defaults = { values: [], options: null, addLabel: 'Add value' };
21
+
22
+ /** @returns {HTMLElement} */
23
+ render() {
24
+ const root = /** @type {HTMLElement} */ (this.el ?? h('div'));
25
+ this._values = Array.isArray(this.options.values) ? this.options.values.map(String) : [];
26
+ this._ownedNodes = [];
27
+ this._rows = h('div', { class: 'zx-multi-value-editor__rows' });
28
+ this._add = h('button', {
29
+ class: 'zx-btn zx-multi-value-editor__add',
30
+ type: 'button',
31
+ dataset: { action: 'add' }
32
+ }, String(this.options.addLabel ?? 'Add value'));
33
+ this._ownedNodes.push(this._rows, this._add);
34
+ root.append(this._rows, this._add);
35
+ this.listen(root, 'click', (event) => this._handleClick(event));
36
+ this.listen(this._rows, 'change', (event) => this._handleChange(event));
37
+ this._renderRows();
38
+ return root;
39
+ }
40
+
41
+ /**
42
+ * Returns a copy of the ordered values.
43
+ * @returns {string[]}
44
+ */
45
+ getValues() {
46
+ return this._values.slice();
47
+ }
48
+
49
+ /**
50
+ * Replaces all rows.
51
+ * @param {unknown[]} values New ordered values.
52
+ * @param {{silent?: boolean}} [options={}] Set `silent` to suppress `change`.
53
+ * @returns {this}
54
+ */
55
+ setValues(values, { silent = false } = {}) {
56
+ this._values = Array.isArray(values) ? values.map(String) : [];
57
+ this._renderRows();
58
+ if (!silent) this.emit('change', { values: this.getValues() });
59
+ return this;
60
+ }
61
+
62
+ /** @param {number} [focusIndex=-1] @returns {void} */
63
+ _renderRows(focusIndex = -1) {
64
+ const choices = normalizeOptions(this.options.options);
65
+ const useSelect = this.options.options !== null;
66
+ const rows = this._values.map((value, index) => {
67
+ const control = useSelect ? h('select', {
68
+ class: 'zx-multi-value-editor__value',
69
+ ariaLabel: `Value ${index + 1}`,
70
+ dataset: { index }
71
+ }, choices.map(([optionValue, label]) => h('option', {
72
+ value: optionValue,
73
+ selected: optionValue === value
74
+ }, label))) : h('input', {
75
+ class: 'zx-multi-value-editor__value',
76
+ type: 'text',
77
+ value,
78
+ ariaLabel: `Value ${index + 1}`,
79
+ dataset: { index }
80
+ });
81
+ return h('div', { class: 'zx-multi-value-editor__row', dataset: { row: index } },
82
+ control,
83
+ h('div', { class: 'zx-multi-value-editor__controls' },
84
+ h('button', {
85
+ class: 'zx-btn',
86
+ type: 'button',
87
+ disabled: index === 0,
88
+ ariaLabel: `Move value ${index + 1} up`,
89
+ dataset: { action: 'up', index }
90
+ }, '↑'),
91
+ h('button', {
92
+ class: 'zx-btn',
93
+ type: 'button',
94
+ disabled: index === this._values.length - 1,
95
+ ariaLabel: `Move value ${index + 1} down`,
96
+ dataset: { action: 'down', index }
97
+ }, '↓'),
98
+ h('button', {
99
+ class: 'zx-btn',
100
+ type: 'button',
101
+ ariaLabel: `Remove value ${index + 1}`,
102
+ dataset: { action: 'remove', index }
103
+ }, '×')
104
+ )
105
+ );
106
+ });
107
+ this._rows.replaceChildren(...rows);
108
+ if (focusIndex >= 0) rows[focusIndex]?.querySelector('.zx-multi-value-editor__value')?.focus();
109
+ }
110
+
111
+ /** @param {MouseEvent} event @returns {void} */
112
+ _handleClick(event) {
113
+ const button = event.target instanceof Element ? event.target.closest('[data-action]') : null;
114
+ if (!button || !this.el.contains(button)) return;
115
+ const action = button.dataset.action;
116
+ const index = Number(button.dataset.index);
117
+ if (action === 'add') {
118
+ const choices = normalizeOptions(this.options.options);
119
+ this._values.push(this.options.options === null ? '' : choices[0]?.[0] ?? '');
120
+ this._renderRows(this._values.length - 1);
121
+ this._emitChange();
122
+ } else if (action === 'remove' && Number.isInteger(index)) {
123
+ this._values.splice(index, 1);
124
+ this._renderRows(Math.min(index, this._values.length - 1));
125
+ this._emitChange();
126
+ } else if ((action === 'up' || action === 'down') && Number.isInteger(index)) {
127
+ const target = index + (action === 'up' ? -1 : 1);
128
+ if (target < 0 || target >= this._values.length) return;
129
+ [this._values[index], this._values[target]] = [this._values[target], this._values[index]];
130
+ this._renderRows(target);
131
+ this._emitChange();
132
+ }
133
+ }
134
+
135
+ /** @param {Event} event @returns {void} */
136
+ _handleChange(event) {
137
+ const control = event.target instanceof Element ? event.target.closest('[data-index]') : null;
138
+ if (!control) return;
139
+ const index = Number(control.dataset.index);
140
+ if (!Number.isInteger(index) || index < 0 || index >= this._values.length) return;
141
+ this._values[index] = control.value;
142
+ this._emitChange();
143
+ }
144
+
145
+ /** @returns {void} */
146
+ _emitChange() {
147
+ this.emit('change', { values: this.getValues() });
148
+ }
149
+
150
+ /** @returns {void} */
151
+ destroy() {
152
+ for (const node of this._ownedNodes ?? []) node.remove();
153
+ super.destroy();
154
+ }
155
+ }
156
+
157
+ /** @param {MultiValueEditorOptions['options']} options @returns {Array<[string, string]>} */
158
+ function normalizeOptions(options) {
159
+ if (Array.isArray(options)) return options.map((value) => [String(value), String(value)]);
160
+ if (options && typeof options === 'object') {
161
+ return Object.entries(options).map(([value, label]) => [value, String(label)]);
162
+ }
163
+ return [];
164
+ }
165
+
166
+ /**
167
+ * Ordered values changed event.
168
+ * @event MultiValueEditor#change
169
+ * @type {CustomEvent<{values: string[]}>
170
+ */
@@ -0,0 +1,130 @@
1
+ .zx-navigation-bar {
2
+ min-inline-size: 0;
3
+ container-type: inline-size;
4
+ }
5
+
6
+ .zx-navigation-bar__bar {
7
+ display: flex;
8
+ min-inline-size: 0;
9
+ align-items: center;
10
+ gap: var(--zx-space-3);
11
+ border: 1px solid var(--zx-color-border);
12
+ border-radius: var(--zx-radius-lg);
13
+ background: var(--zx-color-bg-raised);
14
+ padding: var(--zx-space-2) var(--zx-space-3);
15
+ box-shadow: var(--zx-overlay-shadow);
16
+ }
17
+
18
+ .zx-navigation-bar__brand {
19
+ flex: none;
20
+ padding-inline: var(--zx-space-2);
21
+ color: var(--zx-color-accent);
22
+ font-size: var(--zx-text-xl);
23
+ font-weight: 750;
24
+ }
25
+
26
+ .zx-navigation-bar__navigation {
27
+ min-inline-size: 0;
28
+ flex: 1;
29
+ }
30
+
31
+ .zx-navigation-bar__items {
32
+ display: flex;
33
+ min-inline-size: 0;
34
+ align-items: center;
35
+ gap: var(--zx-space-1);
36
+ }
37
+
38
+ .zx-navigation-bar__item {
39
+ display: inline-flex;
40
+ min-block-size: var(--zx-control-height);
41
+ align-items: center;
42
+ gap: var(--zx-space-2);
43
+ border: 0;
44
+ border-radius: var(--zx-control-radius);
45
+ background: var(--zx-color-bg-raised);
46
+ padding-inline: var(--zx-control-pad-x);
47
+ color: var(--zx-color-text-muted);
48
+ font: inherit;
49
+ text-decoration: none;
50
+ cursor: pointer;
51
+ }
52
+
53
+ .zx-navigation-bar__item:hover:not([aria-disabled="true"]) {
54
+ background: var(--zx-color-bg-hover);
55
+ color: var(--zx-color-text);
56
+ }
57
+
58
+ .zx-navigation-bar__item[aria-current="page"],
59
+ .zx-navigation-bar__item[aria-selected="true"] {
60
+ background: var(--zx-color-bg-selected);
61
+ color: var(--zx-color-accent);
62
+ font-weight: 650;
63
+ }
64
+
65
+ .zx-navigation-bar__item[aria-disabled="true"] {
66
+ color: var(--zx-color-text-muted);
67
+ cursor: not-allowed;
68
+ opacity: .6;
69
+ }
70
+
71
+ .zx-navigation-bar__item:focus-visible {
72
+ box-shadow: var(--zx-focus-ring);
73
+ }
74
+
75
+ .zx-navigation-bar__badge {
76
+ min-inline-size: var(--zx-space-4);
77
+ border-radius: var(--zx-radius-full);
78
+ background: var(--zx-color-accent);
79
+ padding-inline: var(--zx-space-1);
80
+ color: var(--zx-color-on-accent);
81
+ font-size: var(--zx-text-sm);
82
+ font-weight: 700;
83
+ line-height: var(--zx-space-4);
84
+ text-align: center;
85
+ }
86
+
87
+ .zx-navigation-bar__more {
88
+ display: none;
89
+ }
90
+
91
+ .zx-navigation-bar__more[data-empty="true"] {
92
+ display: none;
93
+ }
94
+
95
+ .zx-navigation-bar__actions {
96
+ display: flex;
97
+ flex: none;
98
+ align-items: center;
99
+ gap: var(--zx-space-2);
100
+ margin-inline-start: auto;
101
+ }
102
+
103
+ .zx-navigation-bar__actions:empty {
104
+ display: none;
105
+ }
106
+
107
+ .zx-navigation-bar__panels {
108
+ border: 1px solid var(--zx-color-border);
109
+ border-block-start: 0;
110
+ border-radius: 0 0 var(--zx-radius-lg) var(--zx-radius-lg);
111
+ background: var(--zx-color-bg-surface);
112
+ }
113
+
114
+ .zx-navigation-bar__panel {
115
+ padding: var(--zx-space-4);
116
+ }
117
+
118
+ .zx-navigation-bar__panel:focus-visible {
119
+ box-shadow: inset var(--zx-focus-ring);
120
+ }
121
+
122
+ @container (max-width: 44rem) {
123
+ .zx-navigation-bar__items {
124
+ display: none;
125
+ }
126
+
127
+ .zx-navigation-bar__more:not([data-empty="true"]) {
128
+ display: inline-flex;
129
+ }
130
+ }