@zeyos/zx 2.2.1 → 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.
- package/CHANGELOG.md +197 -0
- package/DESIGN-SYSTEM.md +136 -0
- package/MIGRATION.md +155 -4
- package/README.md +51 -14
- package/dist/types/compat/map/data.d.ts +3 -2
- package/dist/types/components/account-menu/account-menu.d.ts +144 -0
- package/dist/types/components/app-rail/app-rail.d.ts +250 -0
- package/dist/types/components/app-sidebar/app-sidebar.d.ts +169 -0
- package/dist/types/components/avatar/avatar.d.ts +100 -0
- package/dist/types/components/chart/chart.d.ts +321 -0
- package/dist/types/components/date-picker/month-picker.d.ts +6 -0
- package/dist/types/components/dialog/dialog.d.ts +9 -0
- package/dist/types/components/dock/dock.d.ts +495 -0
- package/dist/types/components/dropdown/dropdown.d.ts +2 -2
- package/dist/types/components/field/field.d.ts +14 -0
- package/dist/types/components/field-upload/field-upload.d.ts +37 -4
- package/dist/types/components/form/form.d.ts +25 -3
- package/dist/types/components/grid/grid.d.ts +172 -0
- package/dist/types/components/launcher/launcher.d.ts +300 -0
- package/dist/types/components/layout/layout.d.ts +4 -4
- package/dist/types/components/menu-button/menu-button.d.ts +10 -2
- package/dist/types/components/modal/modal.d.ts +25 -0
- package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +74 -9
- package/dist/types/components/questionnaire/items.d.ts +327 -0
- package/dist/types/components/questionnaire/questionnaire.d.ts +449 -0
- package/dist/types/components/select/select.d.ts +36 -1
- package/dist/types/components/sheet/sheet-stack.d.ts +167 -0
- package/dist/types/components/sheet/sheet.d.ts +294 -0
- package/dist/types/components/split-view/split-view.d.ts +2 -21
- package/dist/types/components/tabbox/tabbox.d.ts +12 -3
- package/dist/types/components/table/table.d.ts +219 -12
- package/dist/types/components/tooltip/tooltip.d.ts +2 -2
- package/dist/types/components/value-list/value-list.d.ts +24 -3
- package/dist/types/core/dom.d.ts +114 -0
- package/dist/types/core/drag-axis.d.ts +111 -0
- package/dist/types/core/position.d.ts +4 -2
- package/dist/types/index.d.ts +12 -2
- package/dist/zx-compat.esm.js +943 -311
- package/dist/zx-compat.esm.min.js +1 -1
- package/dist/zx-compat.global.js +7893 -2252
- package/dist/zx-compat.global.min.js +3 -3
- package/dist/zx-zeyos.esm.js +826 -114
- package/dist/zx-zeyos.esm.min.js +1 -1
- package/dist/zx.css +1720 -243
- package/dist/zx.esm.js +8227 -2599
- package/dist/zx.esm.min.js +3 -3
- package/dist/zx.global.js +8227 -2599
- package/dist/zx.global.min.js +3 -3
- package/dist/zx.min.css +1 -1
- package/docs/api.json +2597 -255
- package/docs/llms.md +475 -37
- package/docs/llms.txt +21 -9
- package/package.json +4 -2
- package/src/compat/globals.js +3 -1
- package/src/compat/map/data.js +31 -9
- package/src/components/account-menu/account-menu.css +70 -0
- package/src/components/account-menu/account-menu.js +208 -0
- package/src/components/app-rail/app-rail.css +107 -0
- package/src/components/app-rail/app-rail.js +668 -0
- package/src/components/app-sidebar/app-sidebar.css +68 -0
- package/src/components/app-sidebar/app-sidebar.js +388 -0
- package/src/components/avatar/avatar.css +61 -0
- package/src/components/avatar/avatar.js +222 -0
- package/src/components/button/button.css +0 -1
- package/src/components/chart/chart.css +61 -0
- package/src/components/chart/chart.js +518 -0
- package/src/components/date-picker/date-range-picker.css +7 -0
- package/src/components/date-picker/month-picker.js +9 -0
- package/src/components/dialog/dialog.js +11 -4
- package/src/components/dock/dock.css +228 -0
- package/src/components/dock/dock.js +977 -0
- package/src/components/dropdown/dropdown.js +1 -1
- package/src/components/field/field.js +2 -0
- package/src/components/field-upload/field-upload.js +9 -4
- package/src/components/fieldset/fieldset.css +7 -0
- package/src/components/form/form.css +7 -0
- package/src/components/form/form.js +6 -3
- package/src/components/grid/grid.css +6 -0
- package/src/components/grid/grid.js +213 -0
- package/src/components/launcher/launcher.css +100 -0
- package/src/components/launcher/launcher.js +557 -0
- package/src/components/layout/layout.js +2 -2
- package/src/components/menu-button/menu-button.js +27 -2
- package/src/components/modal/modal.css +5 -1
- package/src/components/modal/modal.js +37 -2
- package/src/components/multi-value-editor/multi-value-editor.css +99 -15
- package/src/components/multi-value-editor/multi-value-editor.js +237 -19
- package/src/components/navigation-bar/navigation-bar.css +7 -0
- package/src/components/questionnaire/items.js +370 -0
- package/src/components/questionnaire/questionnaire.css +387 -0
- package/src/components/questionnaire/questionnaire.js +1033 -0
- package/src/components/search/search.css +10 -2
- package/src/components/select/select.css +6 -1
- package/src/components/select/select.js +99 -11
- package/src/components/sheet/sheet-stack.js +304 -0
- package/src/components/sheet/sheet.css +351 -0
- package/src/components/sheet/sheet.js +551 -0
- package/src/components/split-view/split-view.js +76 -161
- package/src/components/stepper/stepper.css +12 -2
- package/src/components/tabbox/tabbox.css +13 -3
- package/src/components/tabbox/tabbox.js +34 -10
- package/src/components/table/table.css +43 -0
- package/src/components/table/table.js +523 -45
- package/src/components/tooltip/tooltip.js +5 -2
- package/src/components/value-list/value-list.js +6 -3
- package/src/core/dom.js +302 -0
- package/src/core/drag-axis.js +203 -0
- package/src/core/position.js +68 -22
- package/src/index.js +19 -2
- package/styles/tokens/dark.css +15 -13
- package/styles/tokens/global.css +17 -5
- package/styles/tokens/semantic.css +14 -8
- package/styles/tokens/themes.css +72 -0
- package/styles/zx.css +11 -1
- package/dist/types/components/permission/permission.d.ts +0 -93
- package/src/components/permission/permission.css +0 -47
- package/src/components/permission/permission.js +0 -198
|
@@ -1,198 +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
|
-
* @fires Permission#change
|
|
22
|
-
* @extends {Component<PermissionOptions>}
|
|
23
|
-
*/
|
|
24
|
-
export class Permission extends Component {
|
|
25
|
-
static cssName = 'permission';
|
|
26
|
-
|
|
27
|
-
/** @type {PermissionOptions} */
|
|
28
|
-
static defaults = {
|
|
29
|
-
value: true,
|
|
30
|
-
groups: [],
|
|
31
|
-
groupsValueKey: 'ID',
|
|
32
|
-
groupsLabelKey: 'name'
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/** @returns {HTMLElement} */
|
|
37
|
-
render() {
|
|
38
|
-
// Instance state initialized here because render() runs inside the base
|
|
39
|
-
// constructor, before class-field initializers would run (and clobber it).
|
|
40
|
-
this._mode = 'public'; this._groupValue = null; this._groupSelect = null; this._createdRoot = false; this._originalChildren = []; this._root = null; this._originalState = null;
|
|
41
|
-
this._createdRoot = this.el === null;
|
|
42
|
-
const root = /** @type {HTMLElement} */ (this.el ?? h('div'));
|
|
43
|
-
this.el = root;
|
|
44
|
-
this._root = root;
|
|
45
|
-
if (!this._createdRoot) {
|
|
46
|
-
this._originalChildren = Array.from(root.childNodes);
|
|
47
|
-
this._originalState = root.getAttribute('data-state');
|
|
48
|
-
}
|
|
49
|
-
const name = uid('zx-permission');
|
|
50
|
-
const choices = h('div', {
|
|
51
|
-
class: 'zx-permission__choices',
|
|
52
|
-
role: 'radiogroup',
|
|
53
|
-
ariaLabel: this._message('permission.label', 'Permission')
|
|
54
|
-
});
|
|
55
|
-
const privateChoice = this._choice(name, 'private', this._message('permission.private', 'Private'));
|
|
56
|
-
const publicChoice = this._choice(name, 'public', this._message('permission.public', 'Public'));
|
|
57
|
-
const groupChoice = this._choice(name, 'group', this._message('permission.group', 'Group'));
|
|
58
|
-
const groupHost = h('div', { ref: 'groupHost', class: 'zx-permission__groups' });
|
|
59
|
-
choices.append(privateChoice.label, publicChoice.label, groupChoice.label, groupHost);
|
|
60
|
-
root.replaceChildren(choices);
|
|
61
|
-
this.refs.private = privateChoice.input;
|
|
62
|
-
this.refs.public = publicChoice.input;
|
|
63
|
-
this.refs.group = groupChoice.input;
|
|
64
|
-
|
|
65
|
-
this._groupSelect = new Select(groupHost, {
|
|
66
|
-
items: Array.isArray(this.options.groups) ? this.options.groups : [],
|
|
67
|
-
valueKey: this.options.groupsValueKey,
|
|
68
|
-
labelKey: this.options.groupsLabelKey,
|
|
69
|
-
placeholder: this._message('permission.group', 'Group')
|
|
70
|
-
});
|
|
71
|
-
this._groupSelect.refs.input.setAttribute(
|
|
72
|
-
'aria-label',
|
|
73
|
-
this._message('permission.group', 'Group')
|
|
74
|
-
);
|
|
75
|
-
for (const input of [privateChoice.input, publicChoice.input, groupChoice.input]) {
|
|
76
|
-
this.listen(input, 'change', () => {
|
|
77
|
-
if (!input.checked) return;
|
|
78
|
-
if (input.value === 'group') this._selectGroupMode();
|
|
79
|
-
else this.set(input.value);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
this.listen(groupHost, 'zx-change', (event) => {
|
|
83
|
-
event.stopPropagation();
|
|
84
|
-
if (this._mode !== 'group') return;
|
|
85
|
-
const previous = this.get();
|
|
86
|
-
this._groupValue = /** @type {CustomEvent} */ (event).detail.value;
|
|
87
|
-
const value = this.get();
|
|
88
|
-
if (!Object.is(previous, value)) this.emit('change', { value });
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
this.set(this.options.value, { silent: true });
|
|
92
|
-
return root;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** Returns the normalized permission value. @returns {'private'|'public'|unknown} */
|
|
96
|
-
get() {
|
|
97
|
-
if (this._mode === 'private') return 'private';
|
|
98
|
-
if (this._mode === 'public') return 'public';
|
|
99
|
-
return this._groupValue;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Sets a public, private, or group permission.
|
|
104
|
-
* @param {boolean|string|number|symbol|bigint|null} value Permission value.
|
|
105
|
-
* @param {{silent?: boolean}} [options={}] Update behavior.
|
|
106
|
-
* @returns {this}
|
|
107
|
-
* @fires Permission#change
|
|
108
|
-
*/
|
|
109
|
-
set(value, { silent = false } = {}) {
|
|
110
|
-
const previous = this.get();
|
|
111
|
-
if (value === true || value === 'public') {
|
|
112
|
-
this._mode = 'public';
|
|
113
|
-
} else if (value === false || value === 'private') {
|
|
114
|
-
this._mode = 'private';
|
|
115
|
-
} else {
|
|
116
|
-
this._mode = 'group';
|
|
117
|
-
this._groupValue = value;
|
|
118
|
-
this._groupSelect?.set(value, { silent: true });
|
|
119
|
-
}
|
|
120
|
-
this._sync();
|
|
121
|
-
const next = this.get();
|
|
122
|
-
if (!silent && !Object.is(previous, next)) this.emit('change', { value: next });
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** Destroys the embedded Select and restores an enhanced target. @returns {void} */
|
|
127
|
-
destroy() {
|
|
128
|
-
this._groupSelect?.destroy();
|
|
129
|
-
this._groupSelect = null;
|
|
130
|
-
if (!this._createdRoot && this.el) {
|
|
131
|
-
this.el.replaceChildren(...this._originalChildren);
|
|
132
|
-
if (this._originalState === null) this.el.removeAttribute('data-state');
|
|
133
|
-
else this.el.setAttribute('data-state', this._originalState);
|
|
134
|
-
}
|
|
135
|
-
super.destroy();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/** @returns {void} */
|
|
139
|
-
_selectGroupMode() {
|
|
140
|
-
const previous = this.get();
|
|
141
|
-
this._mode = 'group';
|
|
142
|
-
if (this._groupValue == null) {
|
|
143
|
-
const first = Array.isArray(this.options.groups) ? this.options.groups[0] : null;
|
|
144
|
-
this._groupValue = first == null ? null : read(first, this.options.groupsValueKey);
|
|
145
|
-
}
|
|
146
|
-
this._groupSelect?.set(this._groupValue, { silent: true });
|
|
147
|
-
this._sync();
|
|
148
|
-
const next = this.get();
|
|
149
|
-
if (!Object.is(previous, next)) this.emit('change', { value: next });
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/** @returns {void} */
|
|
153
|
-
_sync() {
|
|
154
|
-
/** @type {HTMLInputElement} */ (this.refs.private).checked = this._mode === 'private';
|
|
155
|
-
/** @type {HTMLInputElement} */ (this.refs.public).checked = this._mode === 'public';
|
|
156
|
-
/** @type {HTMLInputElement} */ (this.refs.group).checked = this._mode === 'group';
|
|
157
|
-
if (this._mode === 'group') this._groupSelect?.enable();
|
|
158
|
-
else this._groupSelect?.disable();
|
|
159
|
-
this._root?.setAttribute('data-state', this._mode);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* @param {string} name
|
|
164
|
-
* @param {'private'|'public'|'group'} value
|
|
165
|
-
* @param {string} text
|
|
166
|
-
* @returns {{label: HTMLLabelElement, input: HTMLInputElement}}
|
|
167
|
-
*/
|
|
168
|
-
_choice(name, value, text) {
|
|
169
|
-
const input = /** @type {HTMLInputElement} */ (h('input', {
|
|
170
|
-
type: 'radio',
|
|
171
|
-
name,
|
|
172
|
-
value
|
|
173
|
-
}));
|
|
174
|
-
const label = /** @type {HTMLLabelElement} */ (h('label', {
|
|
175
|
-
class: 'zx-permission__choice'
|
|
176
|
-
}, input, h('span', {}, text)));
|
|
177
|
-
return { label, input };
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/** @param {string} key @param {string} fallback @returns {string} */
|
|
181
|
-
_message(key, fallback) {
|
|
182
|
-
const message = this.msg(key);
|
|
183
|
-
return message === key ? fallback : message;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/** Permission-value change. @event Permission#change @type {CustomEvent<PermissionChangeDetail>} */
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* @param {PermissionGroup} item
|
|
191
|
-
* @param {string|((item: PermissionGroup) => unknown)} reader
|
|
192
|
-
* @returns {unknown}
|
|
193
|
-
*/
|
|
194
|
-
function read(item, reader) {
|
|
195
|
-
if (typeof reader === 'function') return reader(item);
|
|
196
|
-
if (item === null || typeof item !== 'object') return item;
|
|
197
|
-
return item[reader];
|
|
198
|
-
}
|