@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,321 @@
1
+ import { Component } from '../../core/component.js';
2
+ export type ChartDataset = {
3
+ label?: string;
4
+ data?: unknown[];
5
+ [key: string]: unknown;
6
+ };
7
+ export type ChartData = {
8
+ labels?: unknown[];
9
+ datasets?: ChartDataset[];
10
+ [key: string]: unknown;
11
+ };
12
+ export type ChartSpec = {
13
+ /**
14
+ * Chart type.
15
+ */
16
+ type: string;
17
+ /**
18
+ * Chart data.
19
+ */
20
+ data: ChartData;
21
+ /**
22
+ * Engine-specific options.
23
+ */
24
+ options: Record<string, unknown>;
25
+ /**
26
+ * Point-selection callback.
27
+ */
28
+ onSelect: (detail: ChartSelectDetail) => void;
29
+ };
30
+ export type ChartHandle = {
31
+ /**
32
+ * Update the mounted chart.
33
+ */
34
+ update: (spec: ChartSpec) => void;
35
+ /**
36
+ * Resize the mounted chart.
37
+ */
38
+ resize: () => void;
39
+ /**
40
+ * Destroy the mounted chart.
41
+ */
42
+ destroy: () => void;
43
+ /**
44
+ * Engine instance.
45
+ */
46
+ instance?: unknown;
47
+ };
48
+ export type ChartAdapter = {
49
+ create: (canvas: HTMLCanvasElement, spec: ChartSpec) => ChartHandle;
50
+ };
51
+ export type ChartJsAdapterOptions = Object;
52
+ export type ChartSelectDetail = {
53
+ /**
54
+ * Dataset index.
55
+ */
56
+ datasetIndex: number;
57
+ /**
58
+ * Data index.
59
+ */
60
+ index: number;
61
+ /**
62
+ * Dataset definition.
63
+ */
64
+ dataset: ChartDataset | null;
65
+ /**
66
+ * Label at the selected index.
67
+ */
68
+ label: unknown;
69
+ /**
70
+ * Data value.
71
+ */
72
+ value: unknown;
73
+ /**
74
+ * Engine-native event when available.
75
+ */
76
+ nativeEvent: Event | null;
77
+ };
78
+ export type ChartOptions = {
79
+ /**
80
+ * Injected engine adapter.
81
+ */
82
+ adapter?: ChartAdapter | null;
83
+ /**
84
+ * Chart type passed to the adapter.
85
+ */
86
+ type?: string;
87
+ /**
88
+ * Chart data.
89
+ */
90
+ data?: ChartData;
91
+ /**
92
+ * Engine-specific options.
93
+ */
94
+ chartOptions?: Record<string, unknown>;
95
+ /**
96
+ * Accessible canvas and summary label; blank text falls back to `Chart`.
97
+ */
98
+ label?: string;
99
+ /**
100
+ * Accessible description.
101
+ */
102
+ description?: string;
103
+ /**
104
+ * Semantic data-table presentation.
105
+ */
106
+ summary?: 'hidden' | 'visible';
107
+ /**
108
+ * Initial loading state.
109
+ */
110
+ loading?: boolean;
111
+ /**
112
+ * Empty-state text.
113
+ */
114
+ emptyText?: string;
115
+ /**
116
+ * Loading-state text.
117
+ */
118
+ loadingText?: string;
119
+ /**
120
+ * Error fallback text.
121
+ */
122
+ errorText?: string;
123
+ /**
124
+ * Responsive container aspect ratio.
125
+ */
126
+ aspectRatio?: string;
127
+ /**
128
+ * Engine-ready listener.
129
+ */
130
+ onready?: (event: CustomEvent<{
131
+ instance: unknown;
132
+ }>) => void;
133
+ /**
134
+ * Update listener.
135
+ */
136
+ onupdate?: (event: CustomEvent<{
137
+ data: ChartData;
138
+ type: string;
139
+ }>) => void;
140
+ /**
141
+ * Point-selection listener.
142
+ */
143
+ onselect?: (event: CustomEvent<ChartSelectDetail>) => void;
144
+ /**
145
+ * Engine error listener.
146
+ */
147
+ onerror?: (event: CustomEvent<{
148
+ error: unknown;
149
+ }>) => void;
150
+ };
151
+ /** @typedef {{label?: string, data?: unknown[], [key: string]: unknown}} ChartDataset */
152
+ /** @typedef {{labels?: unknown[], datasets?: ChartDataset[], [key: string]: unknown}} ChartData */
153
+ /**
154
+ * @typedef {Object} ChartSpec
155
+ * @property {string} type Chart type.
156
+ * @property {ChartData} data Chart data.
157
+ * @property {Record<string, unknown>} options Engine-specific options.
158
+ * @property {(detail: ChartSelectDetail) => void} onSelect Point-selection callback.
159
+ */
160
+ /**
161
+ * @typedef {Object} ChartHandle
162
+ * @property {(spec: ChartSpec) => void} update Update the mounted chart.
163
+ * @property {() => void} resize Resize the mounted chart.
164
+ * @property {() => void} destroy Destroy the mounted chart.
165
+ * @property {unknown} [instance] Engine instance.
166
+ */
167
+ /** @typedef {{create: (canvas: HTMLCanvasElement, spec: ChartSpec) => ChartHandle}} ChartAdapter */
168
+ /**
169
+ * @typedef {Object} ChartJsAdapterOptions
170
+ * Generated API marker for the adapter class; its constructor accepts an injected engine and
171
+ * optional defaults directly rather than a component options object.
172
+ */
173
+ /**
174
+ * @typedef {Object} ChartSelectDetail
175
+ * @property {number} datasetIndex Dataset index.
176
+ * @property {number} index Data index.
177
+ * @property {ChartDataset|null} dataset Dataset definition.
178
+ * @property {unknown} label Label at the selected index.
179
+ * @property {unknown} value Data value.
180
+ * @property {Event|null} nativeEvent Engine-native event when available.
181
+ */
182
+ /**
183
+ * @typedef {Object} ChartOptions
184
+ * @property {ChartAdapter|null} [adapter=null] Injected engine adapter.
185
+ * @property {string} [type='bar'] Chart type passed to the adapter.
186
+ * @property {ChartData} [data={labels: [], datasets: []}] Chart data.
187
+ * @property {Record<string, unknown>} [chartOptions={}] Engine-specific options.
188
+ * @property {string} [label='Chart'] Accessible canvas and summary label; blank text falls back to `Chart`.
189
+ * @property {string} [description=''] Accessible description.
190
+ * @property {'hidden'|'visible'} [summary='hidden'] Semantic data-table presentation.
191
+ * @property {boolean} [loading=false] Initial loading state.
192
+ * @property {string} [emptyText='No chart data'] Empty-state text.
193
+ * @property {string} [loadingText='Loading chart…'] Loading-state text.
194
+ * @property {string} [errorText='Unable to render chart'] Error fallback text.
195
+ * @property {string} [aspectRatio='16 / 9'] Responsive container aspect ratio.
196
+ * @property {(event: CustomEvent<{instance: unknown}>) => void} [onready] Engine-ready listener.
197
+ * @property {(event: CustomEvent<{data: ChartData, type: string}>) => void} [onupdate] Update listener.
198
+ * @property {(event: CustomEvent<ChartSelectDetail>) => void} [onselect] Point-selection listener.
199
+ * @property {(event: CustomEvent<{error: unknown}>) => void} [onerror] Engine error listener.
200
+ */
201
+ /**
202
+ * Accessible, engine-neutral chart host with explicit adapter lifecycle.
203
+ * @fires Chart#ready
204
+ * @fires Chart#update
205
+ * @fires Chart#select
206
+ * @fires Chart#error
207
+ * @extends {Component<ChartOptions>}
208
+ */
209
+ export declare class Chart extends Component<ChartOptions> {
210
+ _createdRoot: boolean;
211
+ _original: {
212
+ attributes: string[][];
213
+ children: ChildNode[];
214
+ };
215
+ _adapter: ChartAdapter;
216
+ _type: string;
217
+ _data: ChartData;
218
+ _label: string;
219
+ _chartOptions: Record<string, unknown>;
220
+ _loading: boolean;
221
+ _error: unknown;
222
+ _handle: ChartHandle;
223
+ _destroyed: boolean;
224
+ _observer: ResizeObserver;
225
+ static cssName: string;
226
+ /** @type {Readonly<ChartOptions>} */
227
+ static defaults: Readonly<ChartOptions>;
228
+ /**
229
+ * Creates or enhances a chart host.
230
+ * @param {Element|string|null} target Chart target.
231
+ * @param {ChartOptions} [options={}] Chart options.
232
+ */
233
+ constructor(target?: Element | string | null, options?: ChartOptions);
234
+ /** @returns {HTMLElement} */
235
+ render(): HTMLElement;
236
+ /** Replaces chart data and updates or mounts the engine. @param {ChartData} data @returns {this} */
237
+ setData(data: ChartData): this;
238
+ /** Changes the chart type and updates/recreates the engine as needed. @param {string} type @returns {this} */
239
+ setType(type: string): this;
240
+ /** Replaces engine-specific options. @param {Record<string, unknown>} options @returns {this} */
241
+ update(options: Record<string, unknown>): this;
242
+ /** Replaces the engine adapter. @param {ChartAdapter|null} adapter @returns {this} */
243
+ setAdapter(adapter: ChartAdapter | null): this;
244
+ /** Toggles loading state. Loading charts do not keep an engine instance alive. @param {boolean} [loading=true] @returns {this} */
245
+ setLoading(loading?: boolean): this;
246
+ /** Shows an error and destroys the current engine. @param {unknown} error @returns {this} */
247
+ setError(error: unknown): this;
248
+ /** Clears the error and remounts when data and an adapter are available. @returns {this} */
249
+ clearError(): this;
250
+ /** Requests an engine resize. @returns {this} */
251
+ resize(): this;
252
+ /** Re-applies computed theme defaults through the adapter update path. @returns {this} */
253
+ refreshTheme(): this;
254
+ /** Returns the underlying engine instance when the adapter exposes it. @returns {unknown} */
255
+ getInstance(): unknown;
256
+ /** Destroys the engine/observer and restores or removes the host. @returns {void} */
257
+ destroy(): void;
258
+ /** @param {boolean} emitUpdate @returns {void} */
259
+ _mountOrUpdate(emitUpdate: boolean): void;
260
+ /** @returns {ChartSpec} */
261
+ _spec(): ChartSpec;
262
+ /** @returns {void} */
263
+ _destroyHandle(): void;
264
+ /** @returns {void} */
265
+ _syncState(): void;
266
+ /** @returns {void} */
267
+ _renderSummary(): void;
268
+ }
269
+ /**
270
+ * Adapter for an injected Chart.js 4 constructor or namespace.
271
+ */
272
+ export declare class ChartJsAdapter {
273
+ engine: Function;
274
+ defaults: Record<string, unknown>;
275
+ /**
276
+ * @param {Function|{Chart?: Function}} engine Injected Chart.js constructor or namespace.
277
+ * @param {Record<string, unknown>} [defaults={}] Adapter-wide Chart.js options.
278
+ */
279
+ constructor(engine: Function | {
280
+ Chart?: Function;
281
+ }, defaults?: Record<string, unknown>);
282
+ /**
283
+ * Creates one Chart.js lifecycle handle.
284
+ * @param {HTMLCanvasElement} canvas Canvas.
285
+ * @param {ChartSpec} spec Initial chart specification.
286
+ * @returns {ChartHandle}
287
+ */
288
+ create(canvas: HTMLCanvasElement, spec: ChartSpec): ChartHandle;
289
+ }
290
+ /**
291
+ * Clones arrays and plain objects while preserving callbacks and engine-specific object instances.
292
+ * @template T
293
+ * @param {T} value Value.
294
+ * @returns {T}
295
+ */
296
+ export declare function cloneChartValue<T>(value: T): T;
297
+ /** @param {ChartData} data @returns {boolean} */
298
+ export declare function isEmptyChartData(data: ChartData): boolean;
299
+ /**
300
+ * Builds the semantic table mirrored alongside the canvas.
301
+ * @param {ChartData} data Chart data.
302
+ * @param {string} label Caption.
303
+ * @returns {HTMLTableElement}
304
+ */
305
+ export declare function chartSummaryTable(data: ChartData, label?: string): HTMLTableElement;
306
+ /**
307
+ * Produces the exact text matrix rendered by the semantic chart summary.
308
+ * @param {ChartData} data Chart data.
309
+ * @returns {{headers: string[], rows: Array<{label: string, values: string[]}>}}
310
+ */
311
+ export declare function chartSummaryModel(data: ChartData): {
312
+ headers: string[];
313
+ rows: Array<{
314
+ label: string;
315
+ values: string[];
316
+ }>;
317
+ };
318
+ /** Fired after the adapter creates an engine instance. @event Chart#ready @type {CustomEvent<{instance: unknown}>} */
319
+ /** Fired after an existing chart updates. @event Chart#update @type {CustomEvent<{data: ChartData, type: string}>} */
320
+ /** Fired when the engine reports a selected point. @event Chart#select @type {CustomEvent<ChartSelectDetail>} */
321
+ /** Fired when adapter creation/update fails. @event Chart#error @type {CustomEvent<{error: unknown}>} */
@@ -40,6 +40,12 @@ export declare class MonthPicker extends DatePicker {
40
40
  static cssName: string;
41
41
  /** @type {MonthPickerOptions} */
42
42
  static defaults: MonthPickerOptions;
43
+ /**
44
+ * Creates a month picker with its narrower month-based option contract.
45
+ * @param {Element|string|null} target Existing element, selector, or null.
46
+ * @param {MonthPickerOptions} [options={}] Month-picker options.
47
+ */
48
+ constructor(target: Element | string | null, options?: MonthPickerOptions);
43
49
  /** @returns {HTMLElement} */
44
50
  render(): HTMLElement;
45
51
  /** @returns {Date|null} */
@@ -281,4 +281,13 @@ export declare class Dialog extends Modal {
281
281
  * @returns {Promise<string|null>}
282
282
  */
283
283
  static prompt({ title, message, value, placeholder }?: PromptOptions): Promise<string | null>;
284
+ /**
285
+ * Applies the dialog width. Subclasses that size themselves on a different axis override this.
286
+ *
287
+ * Called from the constructor before any subclass field initializers have run, so an override
288
+ * may only touch the DOM — reading an uninitialized private field here throws.
289
+ * @param {'sm'|'md'|'lg'|number} size Preset or pixel width.
290
+ * @returns {void}
291
+ */
292
+ _applySize(size: 'sm' | 'md' | 'lg' | number): void;
284
293
  }