@zeyos/zx 3.0.0 → 4.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 +51 -0
- package/DESIGN-SYSTEM.md +28 -68
- package/README.md +16 -37
- package/dist/types/components/app-sidebar/app-sidebar.d.ts +106 -32
- package/dist/types/components/card/card.d.ts +128 -0
- package/dist/types/components/chart/chart.d.ts +1 -0
- package/dist/types/components/launcher/launcher.d.ts +65 -6
- package/dist/types/components/select/select.d.ts +51 -0
- package/dist/types/components/table/table.d.ts +4 -3
- package/dist/types/core/dom.d.ts +8 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/{components/app-rail → internal}/app-rail.d.ts +34 -19
- package/dist/types/zeyos/icons.d.ts +5 -0
- package/dist/types/zeyos/index.d.ts +2 -1
- package/dist/types/zeyos/launcher.d.ts +147 -0
- package/dist/types/zeyos/select.d.ts +39 -0
- package/dist/zx-zeyos.esm.js +1324 -46
- package/dist/zx-zeyos.esm.min.js +1 -1
- package/dist/zx.css +400 -12
- package/dist/zx.esm.js +1059 -189
- package/dist/zx.esm.min.js +3 -3
- package/dist/zx.global.js +1059 -189
- package/dist/zx.global.min.js +3 -3
- package/dist/zx.min.css +1 -1
- package/docs/api.json +258 -145
- package/docs/llms.md +93 -112
- package/docs/llms.txt +16 -15
- package/package.json +8 -17
- package/src/components/app-sidebar/app-sidebar.css +12 -0
- package/src/components/app-sidebar/app-sidebar.js +310 -110
- package/src/components/card/card.css +149 -0
- package/src/components/card/card.js +285 -0
- package/src/components/chart/chart.js +8 -3
- package/src/components/grid/grid.js +10 -3
- package/src/components/launcher/launcher.css +113 -3
- package/src/components/launcher/launcher.js +234 -26
- package/src/components/select/field-adapter.js +9 -4
- package/src/components/select/select.css +144 -10
- package/src/components/select/select.js +259 -27
- package/src/components/table/table.js +8 -7
- package/src/core/dom.js +20 -0
- package/src/index.js +2 -1
- package/src/{components/app-rail → internal}/app-rail.js +80 -30
- package/src/zeyos/icons.js +8 -3
- package/src/zeyos/index.js +7 -1
- package/src/zeyos/launcher.js +338 -0
- package/src/zeyos/modules.js +1 -0
- package/src/zeyos/select.js +115 -1
- package/styles/tokens/global.css +1 -1
- package/styles/tokens/modules.css +1 -0
- package/styles/zx.css +1 -0
- package/MIGRATION.md +0 -749
- package/dist/types/compat/base.d.ts +0 -156
- package/dist/types/compat/globals.d.ts +0 -20
- package/dist/types/compat/index.d.ts +0 -128
- package/dist/types/compat/map/basic.d.ts +0 -175
- package/dist/types/compat/map/data.d.ts +0 -103
- package/dist/types/compat/map/date-time.d.ts +0 -80
- package/dist/types/compat/map/factory.d.ts +0 -9
- package/dist/types/compat/map/form.d.ts +0 -98
- package/dist/types/compat/map/helpers.d.ts +0 -12
- package/dist/types/compat/map/http.d.ts +0 -36
- package/dist/types/compat/map/layout.d.ts +0 -106
- package/dist/types/compat/map/options.d.ts +0 -80
- package/dist/types/compat/map/select.d.ts +0 -95
- package/dist/types/compat/map/stubs.d.ts +0 -32
- package/dist/types/compat/map/utilities.d.ts +0 -37
- package/dist/types/compat-entry.d.ts +0 -5
- package/dist/zx-compat.esm.js +0 -17848
- package/dist/zx-compat.esm.min.js +0 -1
- package/dist/zx-compat.global.js +0 -29008
- package/dist/zx-compat.global.min.js +0 -3
- package/src/compat/base.js +0 -291
- package/src/compat/globals.js +0 -167
- package/src/compat/index.js +0 -84
- package/src/compat/map/basic.js +0 -464
- package/src/compat/map/data.js +0 -254
- package/src/compat/map/date-time.js +0 -177
- package/src/compat/map/factory.js +0 -45
- package/src/compat/map/form.js +0 -330
- package/src/compat/map/helpers.js +0 -46
- package/src/compat/map/http.js +0 -117
- package/src/compat/map/layout.js +0 -256
- package/src/compat/map/options.js +0 -267
- package/src/compat/map/select.js +0 -198
- package/src/compat/map/stubs.js +0 -26
- package/src/compat/map/utilities.js +0 -113
- package/src/compat-entry.js +0 -11
package/src/zeyos/select.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Select } from '../index.js';
|
|
1
|
+
import { Select, h, icon } from '../index.js';
|
|
2
2
|
import { connect } from './connect.js';
|
|
3
|
+
import { moduleChip } from './icons.js';
|
|
3
4
|
import { buildListQuery } from './query.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -93,6 +94,105 @@ export function zeyosSelect(client, resource, opts = {}) {
|
|
|
93
94
|
return select;
|
|
94
95
|
}
|
|
95
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Builds the rich, resource-specific Entity-box preset over the generic injected Select binding.
|
|
99
|
+
* It adds module-colored icons, optional subtitles/groups, a fixed clear row, and an optional
|
|
100
|
+
* application-owned create command without changing the selected ID contract.
|
|
101
|
+
* @param {Record<string, any>} client Injected ZeyOS client instance.
|
|
102
|
+
* @param {string} resource Resource such as `projects` or `accounts`.
|
|
103
|
+
* @param {ZeyosSelectOptions & {
|
|
104
|
+
* subtitleKey?: string|((item: Record<string, unknown>) => unknown)|null,
|
|
105
|
+
* moduleKey?: string|((item: Record<string, unknown>) => unknown),
|
|
106
|
+
* none?: boolean|string,
|
|
107
|
+
* create?: boolean|{id?: string|number, label?: string, group?: string, icon?: string|Node, oninvoke?: Function},
|
|
108
|
+
* renderIcon?: ((item: Record<string, unknown>, context: Record<string, unknown>) => Node|null)|null
|
|
109
|
+
* }} [opts={}] Entity presentation, query, and Select options.
|
|
110
|
+
* @returns {Record<string, any>} Plain Select options.
|
|
111
|
+
*/
|
|
112
|
+
export function buildZeyosEntitySelectConfig(client, resource, opts = {}) {
|
|
113
|
+
const {
|
|
114
|
+
fields,
|
|
115
|
+
labelKey = inferLabelKey(client, resource),
|
|
116
|
+
valueKey = 'ID',
|
|
117
|
+
searchFields = inferSearchFields(client, resource),
|
|
118
|
+
subtitleKey = null,
|
|
119
|
+
moduleKey = () => resource,
|
|
120
|
+
groupKey = null,
|
|
121
|
+
none = true,
|
|
122
|
+
create = false,
|
|
123
|
+
renderIcon = defaultEntityIcon,
|
|
124
|
+
renderItem,
|
|
125
|
+
renderValueAdornment,
|
|
126
|
+
...rest
|
|
127
|
+
} = opts;
|
|
128
|
+
const projection = fields ?? defaultProjection(valueKey, labelKey, [
|
|
129
|
+
...searchFields,
|
|
130
|
+
...[subtitleKey, moduleKey, groupKey].filter((reader) => typeof reader === 'string')
|
|
131
|
+
]);
|
|
132
|
+
const base = buildZeyosSelectConfig(client, resource, {
|
|
133
|
+
...rest,
|
|
134
|
+
fields: projection,
|
|
135
|
+
labelKey,
|
|
136
|
+
valueKey,
|
|
137
|
+
searchFields,
|
|
138
|
+
groupKey,
|
|
139
|
+
clearable: none === false ? Boolean(rest.clearable) : true
|
|
140
|
+
});
|
|
141
|
+
const renderModuleIcon = (item, selected = false) => {
|
|
142
|
+
if (renderIcon === null) return null;
|
|
143
|
+
const module = readRecord(item, moduleKey) ?? resource;
|
|
144
|
+
return renderIcon(item, { resource, module: String(module), selected });
|
|
145
|
+
};
|
|
146
|
+
base.renderItem = renderItem ?? ((item) => {
|
|
147
|
+
const visual = renderModuleIcon(item);
|
|
148
|
+
return h('span', { class: 'zx-select__entity' },
|
|
149
|
+
visual ? h('span', {
|
|
150
|
+
class: 'zx-select__entity-icon',
|
|
151
|
+
ariaHidden: 'true'
|
|
152
|
+
}, visual) : null,
|
|
153
|
+
h('span', { class: 'zx-select__entity-copy' },
|
|
154
|
+
h('span', { class: 'zx-select__entity-label' }, String(readRecord(item, labelKey) ?? '')),
|
|
155
|
+
subtitleKey && readRecord(item, subtitleKey) != null
|
|
156
|
+
? h('span', { class: 'zx-select__entity-subtitle' }, String(readRecord(item, subtitleKey)))
|
|
157
|
+
: null));
|
|
158
|
+
});
|
|
159
|
+
base.renderValueAdornment = renderValueAdornment ?? ((item) => renderModuleIcon(item, true));
|
|
160
|
+
if (none !== false) {
|
|
161
|
+
base.noneLabel = typeof none === 'string' ? none : rest.noneLabel ?? 'No selection';
|
|
162
|
+
base.renderNone = rest.renderNone ?? ((label) => h('span', { class: 'zx-select__entity-none' },
|
|
163
|
+
h('span', { class: 'zx-select__entity-none-icon', ariaHidden: 'true' }),
|
|
164
|
+
h('span', {}, label)));
|
|
165
|
+
}
|
|
166
|
+
if (create) {
|
|
167
|
+
const descriptor = create === true ? {} : create;
|
|
168
|
+
const invoke = typeof descriptor.oninvoke === 'function' ? descriptor.oninvoke : null;
|
|
169
|
+
base.actions = [...(Array.isArray(base.actions) ? base.actions : []), {
|
|
170
|
+
id: descriptor.id ?? 'create',
|
|
171
|
+
label: descriptor.label ?? 'Create new…',
|
|
172
|
+
group: descriptor.group ?? 'New',
|
|
173
|
+
icon: descriptor.icon ?? 'plus',
|
|
174
|
+
invoke: (detail) => invoke?.({ ...detail, resource })
|
|
175
|
+
}];
|
|
176
|
+
}
|
|
177
|
+
return base;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Creates a ZeyOS Entity-box preset. Await `select.ready` when a non-null initial ID must be
|
|
182
|
+
* hydrated before presentation.
|
|
183
|
+
* @param {Record<string, any>} client Injected ZeyOS client instance.
|
|
184
|
+
* @param {string} resource Resource name.
|
|
185
|
+
* @param {Record<string, any>} [opts={}] Entity Select options.
|
|
186
|
+
* @returns {Select & {ready: Promise<Select>}}
|
|
187
|
+
*/
|
|
188
|
+
export function zeyosEntitySelect(client, resource, opts = {}) {
|
|
189
|
+
const config = buildZeyosEntitySelectConfig(client, resource, opts);
|
|
190
|
+
const requestedValue = opts.value ?? null;
|
|
191
|
+
const select = /** @type {Select & {ready: Promise<Select>}} */ (new Select(null, config));
|
|
192
|
+
select.ready = hydrateInitialValue(select, client, resource, requestedValue);
|
|
193
|
+
return select;
|
|
194
|
+
}
|
|
195
|
+
|
|
96
196
|
/**
|
|
97
197
|
* Normalizes list output without importing the client package. If the injected client exposes its
|
|
98
198
|
* own `normalizeListResult`, that implementation wins; otherwise arrays and `.data` are handled
|
|
@@ -139,6 +239,20 @@ function normalizeRecord(result) {
|
|
|
139
239
|
throw new TypeError('ZeyOS get operation did not return a record');
|
|
140
240
|
}
|
|
141
241
|
|
|
242
|
+
/** @param {Record<string, unknown>} item @param {unknown} reader @returns {unknown} */
|
|
243
|
+
function readRecord(item, reader) {
|
|
244
|
+
if (typeof reader === 'function') return reader(item);
|
|
245
|
+
if (item && typeof item === 'object' && typeof reader === 'string') return item[reader];
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/** Dependency-free module-color example; exact product glyphs remain host-injectable. @param {Record<string, unknown>} _item @param {{module?: unknown}} context @returns {Node} */
|
|
250
|
+
function defaultEntityIcon(_item, context) {
|
|
251
|
+
const chip = moduleChip(String(context.module ?? 'default'), { size: 20 });
|
|
252
|
+
chip.replaceChildren(icon('square', { size: 10 }));
|
|
253
|
+
return chip;
|
|
254
|
+
}
|
|
255
|
+
|
|
142
256
|
/** @param {unknown} valueKey @param {unknown} labelKey @param {string[]} searchFields @returns {string[]|undefined} */
|
|
143
257
|
function defaultProjection(valueKey, labelKey, searchFields) {
|
|
144
258
|
const keys = [valueKey, labelKey, ...searchFields].filter((key) => typeof key === 'string' && key);
|
package/styles/tokens/global.css
CHANGED
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
--zx-module-linecoupon: var(--zx-module-line);
|
|
90
90
|
--zx-module-logins: var(--zx-module-auth);
|
|
91
91
|
--zx-module-mailservers: var(--zx-module-channels);
|
|
92
|
+
--zx-module-main: var(--zx-module-zeyos);
|
|
92
93
|
--zx-module-notifications: var(--zx-module-messages);
|
|
93
94
|
--zx-module-participants-campaigns: var(--zx-module-participants);
|
|
94
95
|
--zx-module-participants-mailinglists: var(--zx-module-participants);
|
package/styles/zx.css
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
@import url("../src/components/toolbar/toolbar.css");
|
|
22
22
|
@import url("../src/components/toggle/toggle.css");
|
|
23
23
|
@import url("../src/components/groupbox/groupbox.css");
|
|
24
|
+
@import url("../src/components/card/card.css");
|
|
24
25
|
@import url("../src/components/panel/panel.css");
|
|
25
26
|
@import url("../src/components/master-panel/master-panel.css");
|
|
26
27
|
@import url("../src/components/tabbox/tabbox.css");
|