@zeyos/zx 2.3.0 → 3.0.0

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 (105) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/DESIGN-SYSTEM.md +136 -0
  3. package/MIGRATION.md +155 -4
  4. package/README.md +24 -13
  5. package/dist/types/compat/map/data.d.ts +3 -2
  6. package/dist/types/components/account-menu/account-menu.d.ts +144 -0
  7. package/dist/types/components/app-rail/app-rail.d.ts +250 -0
  8. package/dist/types/components/app-sidebar/app-sidebar.d.ts +169 -0
  9. package/dist/types/components/avatar/avatar.d.ts +100 -0
  10. package/dist/types/components/chart/chart.d.ts +321 -0
  11. package/dist/types/components/date-picker/month-picker.d.ts +6 -0
  12. package/dist/types/components/dialog/dialog.d.ts +9 -0
  13. package/dist/types/components/dock/dock.d.ts +495 -0
  14. package/dist/types/components/dropdown/dropdown.d.ts +2 -2
  15. package/dist/types/components/field/field.d.ts +14 -0
  16. package/dist/types/components/field-upload/field-upload.d.ts +37 -4
  17. package/dist/types/components/form/form.d.ts +25 -3
  18. package/dist/types/components/grid/grid.d.ts +172 -0
  19. package/dist/types/components/launcher/launcher.d.ts +300 -0
  20. package/dist/types/components/layout/layout.d.ts +4 -4
  21. package/dist/types/components/menu-button/menu-button.d.ts +10 -2
  22. package/dist/types/components/modal/modal.d.ts +25 -0
  23. package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +7 -1
  24. package/dist/types/components/questionnaire/items.d.ts +327 -0
  25. package/dist/types/components/questionnaire/questionnaire.d.ts +449 -0
  26. package/dist/types/components/sheet/sheet-stack.d.ts +167 -0
  27. package/dist/types/components/sheet/sheet.d.ts +294 -0
  28. package/dist/types/components/split-view/split-view.d.ts +2 -21
  29. package/dist/types/components/table/table.d.ts +219 -12
  30. package/dist/types/components/tooltip/tooltip.d.ts +2 -2
  31. package/dist/types/components/value-list/value-list.d.ts +24 -3
  32. package/dist/types/core/dom.d.ts +114 -0
  33. package/dist/types/core/drag-axis.d.ts +111 -0
  34. package/dist/types/core/position.d.ts +4 -2
  35. package/dist/types/index.d.ts +12 -2
  36. package/dist/zx-compat.esm.js +641 -277
  37. package/dist/zx-compat.esm.min.js +1 -1
  38. package/dist/zx-compat.global.js +7609 -2236
  39. package/dist/zx-compat.global.min.js +3 -3
  40. package/dist/zx-zeyos.esm.js +546 -87
  41. package/dist/zx-zeyos.esm.min.js +1 -1
  42. package/dist/zx.css +1452 -101
  43. package/dist/zx.esm.js +7952 -2592
  44. package/dist/zx.esm.min.js +3 -3
  45. package/dist/zx.global.js +7952 -2592
  46. package/dist/zx.global.min.js +3 -3
  47. package/dist/zx.min.css +1 -1
  48. package/docs/api.json +2276 -337
  49. package/docs/llms.md +426 -30
  50. package/docs/llms.txt +21 -9
  51. package/package.json +4 -2
  52. package/src/compat/globals.js +3 -1
  53. package/src/compat/map/data.js +31 -9
  54. package/src/components/account-menu/account-menu.css +70 -0
  55. package/src/components/account-menu/account-menu.js +208 -0
  56. package/src/components/app-rail/app-rail.css +107 -0
  57. package/src/components/app-rail/app-rail.js +668 -0
  58. package/src/components/app-sidebar/app-sidebar.css +68 -0
  59. package/src/components/app-sidebar/app-sidebar.js +388 -0
  60. package/src/components/avatar/avatar.css +61 -0
  61. package/src/components/avatar/avatar.js +222 -0
  62. package/src/components/button/button.css +0 -1
  63. package/src/components/chart/chart.css +61 -0
  64. package/src/components/chart/chart.js +518 -0
  65. package/src/components/date-picker/month-picker.js +9 -0
  66. package/src/components/dialog/dialog.js +11 -4
  67. package/src/components/dock/dock.css +228 -0
  68. package/src/components/dock/dock.js +977 -0
  69. package/src/components/dropdown/dropdown.js +1 -1
  70. package/src/components/field/field.js +2 -0
  71. package/src/components/field-upload/field-upload.js +9 -4
  72. package/src/components/form/form.js +6 -3
  73. package/src/components/grid/grid.css +6 -0
  74. package/src/components/grid/grid.js +213 -0
  75. package/src/components/launcher/launcher.css +100 -0
  76. package/src/components/launcher/launcher.js +557 -0
  77. package/src/components/layout/layout.js +2 -2
  78. package/src/components/menu-button/menu-button.js +27 -2
  79. package/src/components/modal/modal.css +5 -1
  80. package/src/components/modal/modal.js +37 -2
  81. package/src/components/multi-value-editor/multi-value-editor.js +2 -1
  82. package/src/components/questionnaire/items.js +370 -0
  83. package/src/components/questionnaire/questionnaire.css +387 -0
  84. package/src/components/questionnaire/questionnaire.js +1033 -0
  85. package/src/components/select/select.css +0 -1
  86. package/src/components/sheet/sheet-stack.js +304 -0
  87. package/src/components/sheet/sheet.css +351 -0
  88. package/src/components/sheet/sheet.js +551 -0
  89. package/src/components/split-view/split-view.js +76 -161
  90. package/src/components/table/table.css +43 -0
  91. package/src/components/table/table.js +523 -45
  92. package/src/components/tooltip/tooltip.js +5 -2
  93. package/src/components/value-list/value-list.js +6 -3
  94. package/src/core/dom.js +302 -0
  95. package/src/core/drag-axis.js +203 -0
  96. package/src/core/position.js +68 -22
  97. package/src/index.js +19 -2
  98. package/styles/tokens/dark.css +2 -3
  99. package/styles/tokens/global.css +5 -5
  100. package/styles/tokens/semantic.css +5 -3
  101. package/styles/tokens/themes.css +1 -1
  102. package/styles/zx.css +10 -1
  103. package/dist/types/components/permission/permission.d.ts +0 -96
  104. package/src/components/permission/permission.css +0 -47
  105. package/src/components/permission/permission.js +0 -201
@@ -0,0 +1,294 @@
1
+ import { Dialog } from '../dialog/dialog.js';
2
+ export type SheetSide = 'start' | 'end' | 'top' | 'bottom';
3
+ export type SheetModality = true | 'trap-focus' | false;
4
+ export type SheetBackdrop = 'dim' | 'blur' | 'none';
5
+ export type SheetOptions = {
6
+ /**
7
+ * Edge the sheet is anchored to. Logical, so `start` and `end`
8
+ * follow the writing direction.
9
+ */
10
+ side?: SheetSide;
11
+ /**
12
+ * `true` traps focus, locks page scroll, and blocks pointer
13
+ * interaction behind a backdrop; `'trap-focus'` traps focus only; `false` leaves the page fully
14
+ * interactive. Only `true` renders a backdrop — that is what makes the other two non-modal.
15
+ */
16
+ modal?: SheetModality;
17
+ /**
18
+ * Backdrop treatment, applied only when `modal` is
19
+ * `true`. `'blur'` reads `--zx-overlay-blur`.
20
+ */
21
+ backdrop?: SheetBackdrop;
22
+ /**
23
+ * Size along the sheet's own axis — width for
24
+ * `start`/`end`, height for `top`/`bottom`. A number is pixels, a string is any CSS length. Null
25
+ * keeps the per-side default.
26
+ */
27
+ size?: string | number | null;
28
+ /**
29
+ * Whether the header shows its close control. Independent of
30
+ * `closable`, so a sheet can offer Escape without an ✕, or the reverse.
31
+ */
32
+ closeButton?: boolean;
33
+ /**
34
+ * Whether the inner edge may be dragged to resize the sheet.
35
+ */
36
+ resizable?: boolean;
37
+ /**
38
+ * Smallest the sheet may be dragged to, in pixels.
39
+ */
40
+ min?: number;
41
+ /**
42
+ * Largest it may be dragged to; null means the viewport.
43
+ */
44
+ max?: number | null;
45
+ /**
46
+ * Whether to show a grab handle on the inner edge.
47
+ * `'auto'` shows one for `top` and `bottom` sheets, which is what makes them read as drawers.
48
+ */
49
+ handle?: boolean | 'auto';
50
+ /**
51
+ * Detents the sheet settles on. A number at or
52
+ * below 1 is a fraction of the viewport along the sheet's axis, anything larger is pixels, and a
53
+ * string is any CSS length `resolveSize` understands (`'320px'`, `'90%'`).
54
+ */
55
+ snap?: Array<number | string> | null;
56
+ /**
57
+ * Header title.
58
+ */
59
+ title?: string;
60
+ /**
61
+ * Body content.
62
+ */
63
+ content?: Node | string | number | {
64
+ toElement: () => Node | null;
65
+ } | null;
66
+ /**
67
+ * Footer buttons.
68
+ */
69
+ buttons?: import('../dialog/dialog.js').DialogButton[];
70
+ /**
71
+ * Whether Escape may close the sheet.
72
+ */
73
+ closable?: boolean;
74
+ /**
75
+ * Whether a click outside closes the sheet — the backdrop
76
+ * when modal, a document-level pointer press when not.
77
+ */
78
+ lightDismiss?: boolean;
79
+ /**
80
+ * Whether to destroy the sheet after it closes.
81
+ */
82
+ destroyOnClose?: boolean;
83
+ /**
84
+ * Open event listener.
85
+ */
86
+ onopen?: (event: CustomEvent<Record<string, never>>) => void;
87
+ /**
88
+ * Close event listener.
89
+ */
90
+ onclose?: (event: CustomEvent<{
91
+ result: unknown;
92
+ }>) => void;
93
+ /**
94
+ * Cancel event listener.
95
+ */
96
+ oncancel?: (event: CustomEvent<Record<string, never>>) => void;
97
+ /**
98
+ * Resize listener.
99
+ */
100
+ onresize?: (event: CustomEvent<{
101
+ size: number;
102
+ ratio: number;
103
+ }>) => void;
104
+ /**
105
+ * Dock-state listener.
106
+ */
107
+ ondockchange?: (event: CustomEvent<{
108
+ docked: boolean;
109
+ dock: import('../dock/dock.js').Dock | null;
110
+ }>) => void;
111
+ };
112
+ /**
113
+ * @typedef {Object} SheetOptions
114
+ * @property {SheetSide} [side='end'] Edge the sheet is anchored to. Logical, so `start` and `end`
115
+ * follow the writing direction.
116
+ * @property {SheetModality} [modal=true] `true` traps focus, locks page scroll, and blocks pointer
117
+ * interaction behind a backdrop; `'trap-focus'` traps focus only; `false` leaves the page fully
118
+ * interactive. Only `true` renders a backdrop — that is what makes the other two non-modal.
119
+ * @property {SheetBackdrop} [backdrop='dim'] Backdrop treatment, applied only when `modal` is
120
+ * `true`. `'blur'` reads `--zx-overlay-blur`.
121
+ * @property {string|number|null} [size=null] Size along the sheet's own axis — width for
122
+ * `start`/`end`, height for `top`/`bottom`. A number is pixels, a string is any CSS length. Null
123
+ * keeps the per-side default.
124
+ * @property {boolean} [closeButton=true] Whether the header shows its close control. Independent of
125
+ * `closable`, so a sheet can offer Escape without an ✕, or the reverse.
126
+ * @property {boolean} [resizable=false] Whether the inner edge may be dragged to resize the sheet.
127
+ * @property {number} [min=160] Smallest the sheet may be dragged to, in pixels.
128
+ * @property {number|null} [max=null] Largest it may be dragged to; null means the viewport.
129
+ * @property {boolean|'auto'} [handle='auto'] Whether to show a grab handle on the inner edge.
130
+ * `'auto'` shows one for `top` and `bottom` sheets, which is what makes them read as drawers.
131
+ * @property {Array<number|string>|null} [snap=null] Detents the sheet settles on. A number at or
132
+ * below 1 is a fraction of the viewport along the sheet's axis, anything larger is pixels, and a
133
+ * string is any CSS length `resolveSize` understands (`'320px'`, `'90%'`).
134
+ * @property {string} [title=''] Header title.
135
+ * @property {Node|string|number|{toElement: () => Node|null}|null} [content=null] Body content.
136
+ * @property {import('../dialog/dialog.js').DialogButton[]} [buttons=[]] Footer buttons.
137
+ * @property {boolean} [closable=true] Whether Escape may close the sheet.
138
+ * @property {boolean} [lightDismiss=true] Whether a click outside closes the sheet — the backdrop
139
+ * when modal, a document-level pointer press when not.
140
+ * @property {boolean} [destroyOnClose=false] Whether to destroy the sheet after it closes.
141
+ * @property {(event: CustomEvent<Record<string, never>>) => void} [onopen] Open event listener.
142
+ * @property {(event: CustomEvent<{result: unknown}>) => void} [onclose] Close event listener.
143
+ * @property {(event: CustomEvent<Record<string, never>>) => void} [oncancel] Cancel event listener.
144
+ * @property {(event: CustomEvent<{size: number, ratio: number}>) => void} [onresize] Resize listener.
145
+ * @property {(event: CustomEvent<{docked: boolean, dock: import('../dock/dock.js').Dock|null}>) => void} [ondockchange] Dock-state listener.
146
+ */
147
+ /**
148
+ * Edge-anchored surface: a Dialog that attaches to one side of the viewport instead of floating in
149
+ * the middle. One primitive covers both side sheets and mobile drawers; only the edge differs.
150
+ *
151
+ * Extends `Dialog` rather than reimplementing it, so the header, footer buttons, switchable views,
152
+ * and focus restoration all come from the same structured-dialog foundation.
153
+ *
154
+ * Modality is a three-way choice rather than a boolean because the three real behaviours do not
155
+ * collapse into two: a modal sheet delegates focus containment, page inertness, and Escape to the
156
+ * browser via `showModal()`; the other two open with `show()` and re-implement only what they still
157
+ * want. That is also why `backdrop` applies only to `modal: true` — `::backdrop` does not render
158
+ * for a non-modal dialog, and painting a fake one would make a sheet look blocking while it is not.
159
+ * @fires Sheet#open
160
+ * @fires Sheet#close
161
+ * @fires Sheet#cancel
162
+ * @fires Sheet#resize
163
+ * @fires Sheet#dockchange
164
+ */
165
+ export declare class Sheet extends Dialog {
166
+ #private;
167
+ _dock: any;
168
+ _handoff: boolean;
169
+ static cssName: string;
170
+ /** @type {Readonly<SheetOptions>} */
171
+ static defaults: Readonly<SheetOptions>;
172
+ /**
173
+ * Creates an edge-anchored sheet.
174
+ * @param {Element|string|null} [_target=null] Ignored; Sheet always owns its root.
175
+ * @param {SheetOptions} [options={}] Sheet options.
176
+ */
177
+ constructor(_target?: Element | string | null, options?: SheetOptions);
178
+ /**
179
+ * Moves to one of the configured detents.
180
+ * @param {number|string} target Detent index, or one of the `snap` values.
181
+ * @returns {this}
182
+ * @fires Sheet#resize
183
+ */
184
+ snapTo(target: number | string): this;
185
+ /**
186
+ * Returns the sheet's current size along its own axis, in pixels.
187
+ * @returns {number}
188
+ */
189
+ getSize(): number;
190
+ /**
191
+ * Resolves a translated string, falling back to English when no translator knows the key.
192
+ * @param {string} key Message key.
193
+ * @param {string} fallback English default.
194
+ * @returns {string}
195
+ */
196
+ _message(key: string, fallback: string): string;
197
+ /**
198
+ * Where the dialog lives: the owning dock while adopted, the document otherwise.
199
+ * @returns {Element}
200
+ */
201
+ mountTarget(): Element;
202
+ /**
203
+ * Reports whether a dock currently owns this sheet's positioning.
204
+ * @returns {boolean}
205
+ */
206
+ isDocked(): boolean;
207
+ /**
208
+ * Hands positioning to a dock, or takes it back. Called by `Dock.adopt()` and `Dock.release()`;
209
+ * applications go through those rather than here.
210
+ * @param {{el: Element}|null} dock Owning dock, or null to float again.
211
+ * @returns {void}
212
+ * @fires Sheet#dockchange
213
+ */
214
+ _setDock(dock: {
215
+ el: Element;
216
+ } | null): void;
217
+ /**
218
+ * Moves the dialog to its current mount and, when it was open, reopens it there.
219
+ *
220
+ * The close is unavoidable — a dialog cannot cross between the top layer and the flow while
221
+ * open — but it is invisible: `_isRealClose()` drops the stale event, and reopening bypasses
222
+ * `open()` so no lifecycle event is emitted for what is only a change of address.
223
+ * @returns {void}
224
+ */
225
+ _rehost(): void;
226
+ /**
227
+ * Drops the stale `close` a re-hosting handoff leaves behind.
228
+ * @returns {boolean}
229
+ */
230
+ _isRealClose(): boolean;
231
+ /**
232
+ * Opens the sheet, trapping focus first where the modality asks for it.
233
+ * @returns {this}
234
+ * @fires Modal#open
235
+ */
236
+ open(): this;
237
+ /**
238
+ * Closes the sheet with an optional result.
239
+ * @param {unknown} [result] Result included in the close event.
240
+ * @returns {this}
241
+ */
242
+ close(result?: unknown): this;
243
+ /**
244
+ * Moves the sheet to another edge. Takes effect immediately, open or closed.
245
+ * @param {SheetSide} side Edge to anchor to.
246
+ * @returns {this}
247
+ */
248
+ setSide(side: SheetSide): this;
249
+ /**
250
+ * Returns the edge the sheet is anchored to.
251
+ * @returns {SheetSide}
252
+ */
253
+ getSide(): SheetSide;
254
+ /**
255
+ * Resizes the sheet along its own axis.
256
+ * @param {string|number|null} size CSS length, pixel number, or null for the per-side default.
257
+ * @returns {this}
258
+ */
259
+ setSize(size: string | number | null): this;
260
+ /**
261
+ * Reports whether focus containment is active.
262
+ * @returns {boolean}
263
+ */
264
+ isModal(): boolean;
265
+ /**
266
+ * Sizes the sheet along whichever axis its side implies, by custom property rather than a fixed
267
+ * dimension so the per-side CSS default survives a null.
268
+ *
269
+ * Runs from `Dialog`'s constructor, before this class's field initializers — DOM only.
270
+ * @param {string|number|null} size CSS length, pixel number, or null.
271
+ * @returns {void}
272
+ */
273
+ _applySize(size: string | number | null): void;
274
+ /**
275
+ * Opens the sheet modally or not, as `modal` asks.
276
+ * @returns {void}
277
+ */
278
+ _show(): void;
279
+ /**
280
+ * Releases the focus trap and the owned dialog.
281
+ * @returns {void}
282
+ */
283
+ destroy(): void;
284
+ }
285
+ /**
286
+ * Sheet resize event.
287
+ * @event Sheet#resize
288
+ * @type {CustomEvent<{size: number, ratio: number}>}
289
+ */
290
+ /**
291
+ * Sheet dock-state event.
292
+ * @event Sheet#dockchange
293
+ * @type {CustomEvent<{docked: boolean, dock: import('../dock/dock.js').Dock|null}>}
294
+ */
@@ -1,4 +1,5 @@
1
1
  import { Component } from '../../core/component.js';
2
+ export { resolveSize } from '../../core/drag-axis.js';
2
3
  export type SplitViewContent = string | Node | Component | null;
3
4
  export type SplitViewOptions = {
4
5
  /**
@@ -126,6 +127,7 @@ export type SplitViewOptions = {
126
127
  */
127
128
  export declare class SplitView extends Component<SplitViewOptions> {
128
129
  #private;
130
+ _startSize: number;
129
131
  _orientation: string;
130
132
  /** Current start size in pixels, or null while the CSS value in the property is in charge. */
131
133
  _size: number;
@@ -133,16 +135,6 @@ export declare class SplitView extends Component<SplitViewOptions> {
133
135
  _collapsed: 'start' | 'end' | null;
134
136
  _disabled: boolean;
135
137
  _destroyed: boolean;
136
- _dragging: boolean;
137
- /** Handle of the frame a pending drag update is scheduled in; `0` if none. */
138
- _frame: number;
139
- /** @type {number|null} */
140
- _pointerId: number | null;
141
- _startClient: number;
142
- _startSize: number;
143
- _pointerClient: number;
144
- /** Whether the pointer left its starting position, which separates a drag from a click. */
145
- _moved: boolean;
146
138
  /** Container size of the last observer pass; `-1` forces the next one to run. */
147
139
  _lastTotal: any;
148
140
  _createdRoot: boolean;
@@ -312,17 +304,6 @@ export type ClampSizeInput = {
312
304
  * @returns {number} A size in pixels, never negative.
313
305
  */
314
306
  export declare function clampSize({ size, min, max, total, divider }: ClampSizeInput): number;
315
- /**
316
- * Resolves a size option to pixels without touching the DOM.
317
- *
318
- * Numbers, bare numeric strings, and `px` lengths are pixels; a percentage resolves against
319
- * `total`. Every other CSS length — `rem`, `vh`, `calc()` — needs the browser, so it returns `NaN`
320
- * and the caller hands the value to CSS instead of guessing at it.
321
- * @param {number|string} value Size option.
322
- * @param {number} total Container size along the split axis, in pixels.
323
- * @returns {number} Pixels, or `NaN` when only the browser can resolve the value.
324
- */
325
- export declare function resolveSize(value: number | string, total: number): number;
326
307
  /**
327
308
  * Pulls a size onto the nearest target within a radius, leaving it alone when nothing is close.
328
309
  * The radius is inclusive, ties go to the target listed first, and a radius of zero or less turns