@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
@@ -1,201 +0,0 @@
1
- import { Component } from '../../core/component.js';
2
- import { h } from '../../core/dom.js';
3
- import { uid } from '../../core/util.js';
4
- import { Select } from '../select/select.js';
5
-
6
- /** @typedef {Record<string, any>|string|number|boolean|symbol|bigint|null|undefined} PermissionGroup */
7
- /**
8
- * @typedef {Object} PermissionOptions
9
- * @property {boolean|string|number|symbol|bigint|null} [value=true] Public, private, or group ID.
10
- * @property {PermissionGroup[]} [groups=[]] Available groups.
11
- * @property {string|((item: PermissionGroup) => unknown)} [groupsValueKey='ID'] Group ID property or reader.
12
- * @property {string|((item: PermissionGroup) => string)} [groupsLabelKey='name'] Group label property or reader.
13
- * @property {Record<string, string>|Record<string, Record<string, string>>} [msg] Localized messages.
14
- * @property {(event: CustomEvent<PermissionChangeDetail>) => void} [onchange] Change listener.
15
- */
16
- /** @typedef {{value: unknown}} PermissionChangeDetail */
17
-
18
- /**
19
- * Record-permission choice for private, public, and group access.
20
- *
21
- * @deprecated Use `Select.permission(target, {groups})`, which carries the same tri-state value in
22
- * one control and accepts a loader function for installations whose group list is too long to ship
23
- * with the form. This class stays for `gx.zeyos.Permission` and will be removed in 3.0.
24
- * @fires Permission#change
25
- * @extends {Component<PermissionOptions>}
26
- */
27
- export class Permission extends Component {
28
- static cssName = 'permission';
29
-
30
- /** @type {PermissionOptions} */
31
- static defaults = {
32
- value: true,
33
- groups: [],
34
- groupsValueKey: 'ID',
35
- groupsLabelKey: 'name'
36
- };
37
-
38
-
39
- /** @returns {HTMLElement} */
40
- render() {
41
- // Instance state initialized here because render() runs inside the base
42
- // constructor, before class-field initializers would run (and clobber it).
43
- this._mode = 'public'; this._groupValue = null; this._groupSelect = null; this._createdRoot = false; this._originalChildren = []; this._root = null; this._originalState = null;
44
- this._createdRoot = this.el === null;
45
- const root = /** @type {HTMLElement} */ (this.el ?? h('div'));
46
- this.el = root;
47
- this._root = root;
48
- if (!this._createdRoot) {
49
- this._originalChildren = Array.from(root.childNodes);
50
- this._originalState = root.getAttribute('data-state');
51
- }
52
- const name = uid('zx-permission');
53
- const choices = h('div', {
54
- class: 'zx-permission__choices',
55
- role: 'radiogroup',
56
- ariaLabel: this._message('permission.label', 'Permission')
57
- });
58
- const privateChoice = this._choice(name, 'private', this._message('permission.private', 'Private'));
59
- const publicChoice = this._choice(name, 'public', this._message('permission.public', 'Public'));
60
- const groupChoice = this._choice(name, 'group', this._message('permission.group', 'Group'));
61
- const groupHost = h('div', { ref: 'groupHost', class: 'zx-permission__groups' });
62
- choices.append(privateChoice.label, publicChoice.label, groupChoice.label, groupHost);
63
- root.replaceChildren(choices);
64
- this.refs.private = privateChoice.input;
65
- this.refs.public = publicChoice.input;
66
- this.refs.group = groupChoice.input;
67
-
68
- this._groupSelect = new Select(groupHost, {
69
- items: Array.isArray(this.options.groups) ? this.options.groups : [],
70
- valueKey: this.options.groupsValueKey,
71
- labelKey: this.options.groupsLabelKey,
72
- placeholder: this._message('permission.group', 'Group')
73
- });
74
- this._groupSelect.refs.input.setAttribute(
75
- 'aria-label',
76
- this._message('permission.group', 'Group')
77
- );
78
- for (const input of [privateChoice.input, publicChoice.input, groupChoice.input]) {
79
- this.listen(input, 'change', () => {
80
- if (!input.checked) return;
81
- if (input.value === 'group') this._selectGroupMode();
82
- else this.set(input.value);
83
- });
84
- }
85
- this.listen(groupHost, 'zx-change', (event) => {
86
- event.stopPropagation();
87
- if (this._mode !== 'group') return;
88
- const previous = this.get();
89
- this._groupValue = /** @type {CustomEvent} */ (event).detail.value;
90
- const value = this.get();
91
- if (!Object.is(previous, value)) this.emit('change', { value });
92
- });
93
-
94
- this.set(this.options.value, { silent: true });
95
- return root;
96
- }
97
-
98
- /** Returns the normalized permission value. @returns {'private'|'public'|unknown} */
99
- get() {
100
- if (this._mode === 'private') return 'private';
101
- if (this._mode === 'public') return 'public';
102
- return this._groupValue;
103
- }
104
-
105
- /**
106
- * Sets a public, private, or group permission.
107
- * @param {boolean|string|number|symbol|bigint|null} value Permission value.
108
- * @param {{silent?: boolean}} [options={}] Update behavior.
109
- * @returns {this}
110
- * @fires Permission#change
111
- */
112
- set(value, { silent = false } = {}) {
113
- const previous = this.get();
114
- if (value === true || value === 'public') {
115
- this._mode = 'public';
116
- } else if (value === false || value === 'private') {
117
- this._mode = 'private';
118
- } else {
119
- this._mode = 'group';
120
- this._groupValue = value;
121
- this._groupSelect?.set(value, { silent: true });
122
- }
123
- this._sync();
124
- const next = this.get();
125
- if (!silent && !Object.is(previous, next)) this.emit('change', { value: next });
126
- return this;
127
- }
128
-
129
- /** Destroys the embedded Select and restores an enhanced target. @returns {void} */
130
- destroy() {
131
- this._groupSelect?.destroy();
132
- this._groupSelect = null;
133
- if (!this._createdRoot && this.el) {
134
- this.el.replaceChildren(...this._originalChildren);
135
- if (this._originalState === null) this.el.removeAttribute('data-state');
136
- else this.el.setAttribute('data-state', this._originalState);
137
- }
138
- super.destroy();
139
- }
140
-
141
- /** @returns {void} */
142
- _selectGroupMode() {
143
- const previous = this.get();
144
- this._mode = 'group';
145
- if (this._groupValue == null) {
146
- const first = Array.isArray(this.options.groups) ? this.options.groups[0] : null;
147
- this._groupValue = first == null ? null : read(first, this.options.groupsValueKey);
148
- }
149
- this._groupSelect?.set(this._groupValue, { silent: true });
150
- this._sync();
151
- const next = this.get();
152
- if (!Object.is(previous, next)) this.emit('change', { value: next });
153
- }
154
-
155
- /** @returns {void} */
156
- _sync() {
157
- /** @type {HTMLInputElement} */ (this.refs.private).checked = this._mode === 'private';
158
- /** @type {HTMLInputElement} */ (this.refs.public).checked = this._mode === 'public';
159
- /** @type {HTMLInputElement} */ (this.refs.group).checked = this._mode === 'group';
160
- if (this._mode === 'group') this._groupSelect?.enable();
161
- else this._groupSelect?.disable();
162
- this._root?.setAttribute('data-state', this._mode);
163
- }
164
-
165
- /**
166
- * @param {string} name
167
- * @param {'private'|'public'|'group'} value
168
- * @param {string} text
169
- * @returns {{label: HTMLLabelElement, input: HTMLInputElement}}
170
- */
171
- _choice(name, value, text) {
172
- const input = /** @type {HTMLInputElement} */ (h('input', {
173
- type: 'radio',
174
- name,
175
- value
176
- }));
177
- const label = /** @type {HTMLLabelElement} */ (h('label', {
178
- class: 'zx-permission__choice'
179
- }, input, h('span', {}, text)));
180
- return { label, input };
181
- }
182
-
183
- /** @param {string} key @param {string} fallback @returns {string} */
184
- _message(key, fallback) {
185
- const message = this.msg(key);
186
- return message === key ? fallback : message;
187
- }
188
- }
189
-
190
- /** Permission-value change. @event Permission#change @type {CustomEvent<PermissionChangeDetail>} */
191
-
192
- /**
193
- * @param {PermissionGroup} item
194
- * @param {string|((item: PermissionGroup) => unknown)} reader
195
- * @returns {unknown}
196
- */
197
- function read(item, reader) {
198
- if (typeof reader === 'function') return reader(item);
199
- if (item === null || typeof item !== 'object') return item;
200
- return item[reader];
201
- }