@zeyos/zx 2.3.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.
Files changed (150) hide show
  1. package/CHANGELOG.md +138 -0
  2. package/DESIGN-SYSTEM.md +96 -0
  3. package/README.md +29 -39
  4. package/dist/types/components/account-menu/account-menu.d.ts +144 -0
  5. package/dist/types/components/app-sidebar/app-sidebar.d.ts +243 -0
  6. package/dist/types/components/avatar/avatar.d.ts +100 -0
  7. package/dist/types/components/card/card.d.ts +128 -0
  8. package/dist/types/components/chart/chart.d.ts +322 -0
  9. package/dist/types/components/date-picker/month-picker.d.ts +6 -0
  10. package/dist/types/components/dialog/dialog.d.ts +9 -0
  11. package/dist/types/components/dock/dock.d.ts +495 -0
  12. package/dist/types/components/dropdown/dropdown.d.ts +2 -2
  13. package/dist/types/components/field/field.d.ts +14 -0
  14. package/dist/types/components/field-upload/field-upload.d.ts +37 -4
  15. package/dist/types/components/form/form.d.ts +25 -3
  16. package/dist/types/components/grid/grid.d.ts +172 -0
  17. package/dist/types/components/launcher/launcher.d.ts +359 -0
  18. package/dist/types/components/layout/layout.d.ts +4 -4
  19. package/dist/types/components/menu-button/menu-button.d.ts +10 -2
  20. package/dist/types/components/modal/modal.d.ts +25 -0
  21. package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +7 -1
  22. package/dist/types/components/questionnaire/items.d.ts +327 -0
  23. package/dist/types/components/questionnaire/questionnaire.d.ts +449 -0
  24. package/dist/types/components/select/select.d.ts +51 -0
  25. package/dist/types/components/sheet/sheet-stack.d.ts +167 -0
  26. package/dist/types/components/sheet/sheet.d.ts +294 -0
  27. package/dist/types/components/split-view/split-view.d.ts +2 -21
  28. package/dist/types/components/table/table.d.ts +223 -15
  29. package/dist/types/components/tooltip/tooltip.d.ts +2 -2
  30. package/dist/types/components/value-list/value-list.d.ts +24 -3
  31. package/dist/types/core/dom.d.ts +122 -0
  32. package/dist/types/core/drag-axis.d.ts +111 -0
  33. package/dist/types/core/position.d.ts +4 -2
  34. package/dist/types/index.d.ts +13 -2
  35. package/dist/types/internal/app-rail.d.ts +265 -0
  36. package/dist/types/zeyos/icons.d.ts +5 -0
  37. package/dist/types/zeyos/index.d.ts +2 -1
  38. package/dist/types/zeyos/launcher.d.ts +147 -0
  39. package/dist/types/zeyos/select.d.ts +39 -0
  40. package/dist/zx-zeyos.esm.js +1870 -133
  41. package/dist/zx-zeyos.esm.min.js +1 -1
  42. package/dist/zx.css +2006 -267
  43. package/dist/zx.esm.js +8987 -2757
  44. package/dist/zx.esm.min.js +3 -3
  45. package/dist/zx.global.js +8987 -2757
  46. package/dist/zx.global.min.js +3 -3
  47. package/dist/zx.min.css +1 -1
  48. package/docs/api.json +4396 -2344
  49. package/docs/llms.md +463 -86
  50. package/docs/llms.txt +32 -19
  51. package/package.json +10 -17
  52. package/src/components/account-menu/account-menu.css +70 -0
  53. package/src/components/account-menu/account-menu.js +208 -0
  54. package/src/components/app-rail/app-rail.css +107 -0
  55. package/src/components/app-sidebar/app-sidebar.css +80 -0
  56. package/src/components/app-sidebar/app-sidebar.js +588 -0
  57. package/src/components/avatar/avatar.css +61 -0
  58. package/src/components/avatar/avatar.js +222 -0
  59. package/src/components/button/button.css +0 -1
  60. package/src/components/card/card.css +149 -0
  61. package/src/components/card/card.js +285 -0
  62. package/src/components/chart/chart.css +61 -0
  63. package/src/components/chart/chart.js +523 -0
  64. package/src/components/date-picker/month-picker.js +9 -0
  65. package/src/components/dialog/dialog.js +11 -4
  66. package/src/components/dock/dock.css +228 -0
  67. package/src/components/dock/dock.js +977 -0
  68. package/src/components/dropdown/dropdown.js +1 -1
  69. package/src/components/field/field.js +2 -0
  70. package/src/components/field-upload/field-upload.js +9 -4
  71. package/src/components/form/form.js +6 -3
  72. package/src/components/grid/grid.css +6 -0
  73. package/src/components/grid/grid.js +220 -0
  74. package/src/components/launcher/launcher.css +210 -0
  75. package/src/components/launcher/launcher.js +765 -0
  76. package/src/components/layout/layout.js +2 -2
  77. package/src/components/menu-button/menu-button.js +27 -2
  78. package/src/components/modal/modal.css +5 -1
  79. package/src/components/modal/modal.js +37 -2
  80. package/src/components/multi-value-editor/multi-value-editor.js +2 -1
  81. package/src/components/questionnaire/items.js +370 -0
  82. package/src/components/questionnaire/questionnaire.css +387 -0
  83. package/src/components/questionnaire/questionnaire.js +1033 -0
  84. package/src/components/select/field-adapter.js +9 -4
  85. package/src/components/select/select.css +144 -11
  86. package/src/components/select/select.js +259 -27
  87. package/src/components/sheet/sheet-stack.js +304 -0
  88. package/src/components/sheet/sheet.css +351 -0
  89. package/src/components/sheet/sheet.js +551 -0
  90. package/src/components/split-view/split-view.js +76 -161
  91. package/src/components/table/table.css +43 -0
  92. package/src/components/table/table.js +531 -52
  93. package/src/components/tooltip/tooltip.js +5 -2
  94. package/src/components/value-list/value-list.js +6 -3
  95. package/src/core/dom.js +322 -0
  96. package/src/core/drag-axis.js +203 -0
  97. package/src/core/position.js +68 -22
  98. package/src/index.js +20 -2
  99. package/src/internal/app-rail.js +718 -0
  100. package/src/zeyos/icons.js +8 -3
  101. package/src/zeyos/index.js +7 -1
  102. package/src/zeyos/launcher.js +338 -0
  103. package/src/zeyos/modules.js +1 -0
  104. package/src/zeyos/select.js +115 -1
  105. package/styles/tokens/dark.css +2 -3
  106. package/styles/tokens/global.css +6 -6
  107. package/styles/tokens/modules.css +1 -0
  108. package/styles/tokens/semantic.css +5 -3
  109. package/styles/tokens/themes.css +1 -1
  110. package/styles/zx.css +11 -1
  111. package/MIGRATION.md +0 -598
  112. package/dist/types/compat/base.d.ts +0 -156
  113. package/dist/types/compat/globals.d.ts +0 -20
  114. package/dist/types/compat/index.d.ts +0 -128
  115. package/dist/types/compat/map/basic.d.ts +0 -175
  116. package/dist/types/compat/map/data.d.ts +0 -102
  117. package/dist/types/compat/map/date-time.d.ts +0 -80
  118. package/dist/types/compat/map/factory.d.ts +0 -9
  119. package/dist/types/compat/map/form.d.ts +0 -98
  120. package/dist/types/compat/map/helpers.d.ts +0 -12
  121. package/dist/types/compat/map/http.d.ts +0 -36
  122. package/dist/types/compat/map/layout.d.ts +0 -106
  123. package/dist/types/compat/map/options.d.ts +0 -80
  124. package/dist/types/compat/map/select.d.ts +0 -95
  125. package/dist/types/compat/map/stubs.d.ts +0 -32
  126. package/dist/types/compat/map/utilities.d.ts +0 -37
  127. package/dist/types/compat-entry.d.ts +0 -5
  128. package/dist/types/components/permission/permission.d.ts +0 -96
  129. package/dist/zx-compat.esm.js +0 -17484
  130. package/dist/zx-compat.esm.min.js +0 -1
  131. package/dist/zx-compat.global.js +0 -23635
  132. package/dist/zx-compat.global.min.js +0 -3
  133. package/src/compat/base.js +0 -291
  134. package/src/compat/globals.js +0 -165
  135. package/src/compat/index.js +0 -84
  136. package/src/compat/map/basic.js +0 -464
  137. package/src/compat/map/data.js +0 -232
  138. package/src/compat/map/date-time.js +0 -177
  139. package/src/compat/map/factory.js +0 -45
  140. package/src/compat/map/form.js +0 -330
  141. package/src/compat/map/helpers.js +0 -46
  142. package/src/compat/map/http.js +0 -117
  143. package/src/compat/map/layout.js +0 -256
  144. package/src/compat/map/options.js +0 -267
  145. package/src/compat/map/select.js +0 -198
  146. package/src/compat/map/stubs.js +0 -26
  147. package/src/compat/map/utilities.js +0 -113
  148. package/src/compat-entry.js +0 -11
  149. package/src/components/permission/permission.css +0 -47
  150. package/src/components/permission/permission.js +0 -201
@@ -55,6 +55,7 @@ export function moduleIcon(name, options = {}) {
55
55
  * @property {string|null} [label=null] Accessible label; null marks the chip decorative.
56
56
  * @property {boolean} [title=false] Adds the module's display name as a `title` tooltip.
57
57
  * @property {boolean} [standard=false] Use the stock Font Awesome fallback glyph.
58
+ * @property {string} [color] Override the module colour for a server-defined fork or weblet.
58
59
  * @property {string|string[]} [class] Extra class names.
59
60
  */
60
61
 
@@ -67,16 +68,20 @@ export function moduleIcon(name, options = {}) {
67
68
  * @returns {HTMLElement} A `<span class="zx-module-icon">` wrapping the glyph.
68
69
  */
69
70
  export function moduleChip(name, options = {}) {
70
- const { size = 24, iconSize = '1em', label = null, title = false, standard = false } = options;
71
+ const {
72
+ size = 24, iconSize = '1em', label = null, title = false, standard = false,
73
+ color = null
74
+ } = options;
71
75
  const key = normalizeModuleName(name);
72
76
  const info = moduleInfo(name);
77
+ const background = color || info.color;
73
78
 
74
79
  const chip = h('span', {
75
80
  class: ['zx-module-icon', options.class].flat().filter(Boolean),
76
81
  dataset: { module: key },
77
82
  style: {
78
- '--zx-module-color': info.color,
79
- '--zx-module-glyph': moduleGlyphColor(info.color),
83
+ '--zx-module-color': background,
84
+ '--zx-module-glyph': moduleGlyphColor(background),
80
85
  '--zx-module-icon-size': typeof size === 'number' ? `${size}px` : String(size)
81
86
  },
82
87
  title: title ? info.label : null
@@ -16,6 +16,12 @@ export {
16
16
  moduleGlyphColor, normalizeModuleName, registerModules
17
17
  } from './modules.js';
18
18
  export { ZEYOS_ICON_KIT, useZeyosIcons, moduleIcon, moduleChip } from './icons.js';
19
- export { zeyosSelect } from './select.js';
19
+ export {
20
+ ZEYOS_LAUNCHER_APPLICATIONS, buildZeyosLauncherConfig, zeyosLauncher,
21
+ normalizeZeyosLauncherApplications, normalizeZeyosLauncherRecords, zeyosActiveIdentifier
22
+ } from './launcher.js';
23
+ export {
24
+ zeyosSelect, buildZeyosSelectConfig, zeyosEntitySelect, buildZeyosEntitySelectConfig
25
+ } from './select.js';
20
26
  export { zeyosForm } from './form.js';
21
27
  export { zeyosTable } from './table.js';
@@ -0,0 +1,338 @@
1
+ import { Launcher } from '../components/launcher/launcher.js';
2
+ import { moduleChip } from './icons.js';
3
+ import { moduleInfo } from './modules.js';
4
+
5
+ /** Static application identifiers present in the current ZeyOS shell prototype. */
6
+ export const ZEYOS_LAUNCHER_APPLICATIONS = Object.freeze([
7
+ 'accounts', 'actionsteps', 'admin', 'auth', 'billing', 'calendar', 'campaigns', 'collection',
8
+ 'contacts', 'contracts', 'control', 'coupons', 'dev', 'documents', 'inventory', 'mailinglists',
9
+ 'main', 'messages', 'links', 'notes', 'objects', 'opportunities', 'payments', 'pricelists',
10
+ 'procurement', 'production', 'projects', 'tasks', 'tickets'
11
+ ]);
12
+
13
+ /**
14
+ * @typedef {Object} ZeyosLauncherState
15
+ * @property {Record<string, string>|Array<string|Record<string, any>>} [modules={}] Permitted module catalogue.
16
+ * @property {Array<Array<any>|Record<string, any>>} [menuApps=[]] Forks/weblets and authoritative menu entries.
17
+ * @property {string[]} [pinned=[]] Application identifiers in pinned order.
18
+ * @property {Array<Array<any>|Record<string, any>>} [recent=[]] Recent records.
19
+ * @property {string|null} [activeIdentifier=null] Current module, `fork#…`, or `weblet#…` identifier.
20
+ * @property {(module: string) => boolean} [canUseModule] Permission predicate.
21
+ * @property {(query: string, context: {signal: AbortSignal}) => Promise<unknown>|unknown} [search] Record search loader.
22
+ * @property {(context: {signal: AbortSignal}) => Promise<unknown>|unknown} [loadRecent] Recent-record loader.
23
+ * @property {(app: unknown) => Record<string, any>|null} [resolveApplication] Maps an app to href/invoke/value metadata.
24
+ * @property {(record: unknown) => Record<string, any>|null} [resolveRecord] Maps a record to href/invoke/value metadata.
25
+ * @property {Record<string, any>} [labels] Localized applications/recent/results/entity labels and hints.
26
+ * @property {(app: unknown, normalized: Record<string, any>) => Node|null} [renderApplicationIcon] Host icon renderer for modules, forks, and weblets.
27
+ * @property {(record: unknown, normalized: Record<string, any>) => Node|null} [renderRecordIcon] Host record icon renderer.
28
+ * @property {(app: unknown, normalized: Record<string, any>) => Node|null} [renderWebletIcon] Legacy weblet-only icon renderer.
29
+ */
30
+
31
+ /**
32
+ * @typedef {Object} ZeyosLauncherOptions
33
+ * @property {boolean} [standardIcons=false] Use stock icon fallbacks instead of the optional ZeyOS kit.
34
+ * @property {Array<Record<string, any>>} [items] Extra generic Launcher items.
35
+ * @property {Array<Record<string, any>>} [sources] Extra generic Launcher sources.
36
+ */
37
+
38
+ /**
39
+ * Builds a generic Launcher configuration from explicitly injected ZeyOS shell state. It never
40
+ * reads PG/C globals and never resolves a route itself.
41
+ * @param {ZeyosLauncherState} [state={}] Application-owned shell state.
42
+ * @param {ZeyosLauncherOptions & Record<string, any>} [options={}] Adapter and Launcher options.
43
+ * @returns {Record<string, any>} Plain Launcher options.
44
+ */
45
+ export function buildZeyosLauncherConfig(state = {}, options = {}) {
46
+ const {
47
+ standardIcons = false,
48
+ items: extraItems = [],
49
+ sources: extraSources = [],
50
+ ...launcherOptions
51
+ } = options;
52
+ const labels = launcherLabels(state.labels);
53
+ const iconOptions = {
54
+ standardIcons,
55
+ renderApplicationIcon: state.renderApplicationIcon,
56
+ renderWebletIcon: state.renderWebletIcon
57
+ };
58
+ const applications = normalizeZeyosLauncherApplications(state, iconOptions);
59
+ const recent = typeof state.loadRecent === 'function' ? []
60
+ : normalizeZeyosLauncherRecords(state.recent ?? [], {
61
+ query: '', labels, resolveRecord: state.resolveRecord,
62
+ renderRecordIcon: state.renderRecordIcon, standardIcons
63
+ });
64
+ const sources = [];
65
+ if (typeof state.loadRecent === 'function') {
66
+ sources.push({
67
+ id: 'zeyos-recent',
68
+ minQuery: 0,
69
+ when: 'empty',
70
+ order: 'source',
71
+ load: async (_query, context) => normalizeZeyosLauncherRecords(
72
+ await state.loadRecent(context),
73
+ {
74
+ query: '', labels, resolveRecord: state.resolveRecord,
75
+ renderRecordIcon: state.renderRecordIcon, standardIcons
76
+ }
77
+ )
78
+ });
79
+ }
80
+ if (typeof state.search === 'function') {
81
+ sources.push({
82
+ id: 'zeyos-records',
83
+ minQuery: 1,
84
+ when: 'query',
85
+ order: 'source',
86
+ load: async (query, context) => normalizeZeyosLauncherRecords(
87
+ await state.search(query, context),
88
+ {
89
+ query, labels, resolveRecord: state.resolveRecord,
90
+ renderRecordIcon: state.renderRecordIcon, standardIcons
91
+ }
92
+ )
93
+ });
94
+ }
95
+ sources.push(...extraSources);
96
+ return {
97
+ ...launcherOptions,
98
+ items: [...applications, ...recent, ...extraItems],
99
+ sources,
100
+ hints: options.hints ?? {
101
+ move: labels.move,
102
+ open: labels.open,
103
+ close: labels.close
104
+ }
105
+ };
106
+ }
107
+
108
+ /**
109
+ * Creates the ZeyOS-configured Launcher. State and route resolvers remain caller-owned inputs.
110
+ * @param {ZeyosLauncherState} [state={}] Injected shell state.
111
+ * @param {ZeyosLauncherOptions & Record<string, any>} [options={}] Adapter and Launcher options.
112
+ * @returns {Launcher}
113
+ */
114
+ export function zeyosLauncher(state = {}, options = {}) {
115
+ return new Launcher(null, buildZeyosLauncherConfig(state, options));
116
+ }
117
+
118
+ /**
119
+ * Normalizes module, fork, and weblet applications while preserving menu authority and pin order.
120
+ * @param {ZeyosLauncherState} [state={}] Injected shell state.
121
+ * @param {{standardIcons?: boolean, renderApplicationIcon?: Function, renderWebletIcon?: Function}} [options={}] Icon options.
122
+ * @returns {Array<Record<string, any>>}
123
+ */
124
+ export function normalizeZeyosLauncherApplications(state = {}, options = {}) {
125
+ const labels = launcherLabels(state.labels);
126
+ const pinned = Array.isArray(state.pinned) ? state.pinned.map(String) : [];
127
+ const seen = new Set();
128
+ const items = [];
129
+ const add = (raw, fallbackId = null, fallbackLabel = null) => {
130
+ const app = normalizeApplication(raw, fallbackId, fallbackLabel);
131
+ if (!app || seen.has(app.identifier)) return;
132
+ if (app.type === 'module' && typeof state.canUseModule === 'function'
133
+ && !state.canUseModule(app.module)) return;
134
+ seen.add(app.identifier);
135
+ const resolved = mergeDestination(app.raw, state.resolveApplication);
136
+ const pin = pinned.indexOf(app.identifier);
137
+ const icon = () => {
138
+ const custom = typeof options.renderApplicationIcon === 'function'
139
+ ? options.renderApplicationIcon(app.raw, app)
140
+ : app.type === 'weblet' && typeof options.renderWebletIcon === 'function'
141
+ ? options.renderWebletIcon(app.raw, app) : null;
142
+ return custom ?? moduleChip(app.module, {
143
+ size: 36,
144
+ standard: Boolean(options.standardIcons),
145
+ color: app.color
146
+ });
147
+ };
148
+ items.push({
149
+ id: app.identifier,
150
+ label: app.label,
151
+ keywords: [app.identifier, app.module],
152
+ group: labels.applications,
153
+ groupOrder: 0,
154
+ kind: 'application',
155
+ icon,
156
+ pinned: pin >= 0 ? pin : undefined,
157
+ current: app.identifier === state.activeIdentifier,
158
+ disabled: !resolved.href && typeof resolved.invoke !== 'function',
159
+ ...resolved,
160
+ _zeyos: app
161
+ });
162
+ };
163
+
164
+ for (const raw of Array.isArray(state.menuApps) ? state.menuApps : []) add(raw);
165
+ if (Array.isArray(state.modules)) {
166
+ for (const module of state.modules) {
167
+ if (typeof module === 'string') add([module, moduleInfo(module).label]);
168
+ else add(module, module?.id ?? module?.module, module?.label);
169
+ }
170
+ } else {
171
+ for (const [module, label] of Object.entries(state.modules ?? {})) add([module, label]);
172
+ }
173
+ return items;
174
+ }
175
+
176
+ /**
177
+ * Normalizes recent records or grouped search payloads without losing server/group order.
178
+ * @param {unknown} payload Recent/search payload.
179
+ * @param {{query?: string, labels?: Record<string, any>, resolveRecord?: Function, renderRecordIcon?: Function, standardIcons?: boolean}} [options={}] Mapping options.
180
+ * @returns {Array<Record<string, any>>}
181
+ */
182
+ export function normalizeZeyosLauncherRecords(payload, options = {}) {
183
+ const query = String(options.query ?? '');
184
+ const labels = launcherLabels(options.labels);
185
+ const records = flattenRecords(payload, query);
186
+ const groupOrders = new Map();
187
+ return records.flatMap(({ raw, group }, itemOrder) => {
188
+ const record = normalizeRecord(raw, group, query);
189
+ if (!record) return [];
190
+ const groupName = query === '' ? labels.recent
191
+ : record.group === '' ? labels.results
192
+ : labels.entities[record.group] ?? record.group;
193
+ if (!groupOrders.has(groupName)) groupOrders.set(groupName, groupOrders.size + 1);
194
+ const resolved = mergeDestination(record.raw, options.resolveRecord);
195
+ return [{
196
+ id: `record:${record.entity}:${record.fork ?? ''}:${record.ID}`,
197
+ label: record.name,
198
+ description: record.sec,
199
+ keywords: [record.entity, record.ID, record.fork ?? ''],
200
+ group: groupName,
201
+ groupOrder: groupOrders.get(groupName),
202
+ itemOrder,
203
+ kind: 'record',
204
+ when: query === '' ? 'empty' : 'query',
205
+ icon: () => {
206
+ const custom = typeof options.renderRecordIcon === 'function'
207
+ ? options.renderRecordIcon(record.raw, record) : null;
208
+ return custom ?? moduleChip(record.entity, {
209
+ size: 28,
210
+ standard: Boolean(options.standardIcons)
211
+ });
212
+ },
213
+ disabled: !resolved.href && typeof resolved.invoke !== 'function',
214
+ ...resolved,
215
+ _zeyos: record
216
+ }];
217
+ });
218
+ }
219
+
220
+ /** @param {{module?: string, fork?: unknown, weblet?: unknown}} state @returns {string} */
221
+ export function zeyosActiveIdentifier(state = {}) {
222
+ if (state.weblet != null && state.weblet !== '') return `weblet#${state.weblet}`;
223
+ if (state.fork != null && state.fork !== '') return `fork#${state.fork}`;
224
+ return String(state.module ?? '');
225
+ }
226
+
227
+ /** @param {unknown} raw @param {string|null} fallbackId @param {unknown} fallbackLabel @returns {Record<string, any>|null} */
228
+ function normalizeApplication(raw, fallbackId, fallbackLabel) {
229
+ if (Array.isArray(raw)) {
230
+ if (raw.length < 2) return null;
231
+ if (raw.length === 2) {
232
+ const module = String(raw[0]);
233
+ return { raw, identifier: module, label: String(raw[1]), module, type: 'module', color: null };
234
+ }
235
+ if (raw.length === 4) {
236
+ const module = String(raw[2] || 'default');
237
+ return {
238
+ raw, identifier: `fork#${raw[0]}`, label: String(raw[1]), module, type: 'fork',
239
+ color: normalizeServerColor(raw[3])
240
+ };
241
+ }
242
+ return {
243
+ raw, identifier: `weblet#${raw[0]}`, label: String(raw[1]), module: 'weblets',
244
+ type: 'weblet', color: normalizeServerColor(raw[8])
245
+ };
246
+ }
247
+ if (!raw || typeof raw !== 'object') return null;
248
+ const identifier = String(raw.identifier ?? raw.id ?? fallbackId ?? '');
249
+ if (!identifier) return null;
250
+ const type = identifier.startsWith('fork#') ? 'fork'
251
+ : identifier.startsWith('weblet#') ? 'weblet' : 'module';
252
+ return {
253
+ raw,
254
+ identifier,
255
+ label: String(raw.label ?? fallbackLabel ?? moduleInfo(identifier).label),
256
+ module: String(raw.module ?? (type === 'module' ? identifier : type === 'fork' ? 'default' : 'weblets')),
257
+ type,
258
+ color: normalizeServerColor(raw.color)
259
+ };
260
+ }
261
+
262
+ /** @param {unknown} payload @param {string} query @returns {Array<{raw: unknown, group: string}>} */
263
+ function flattenRecords(payload, query) {
264
+ if (Array.isArray(payload)) return payload.map((raw) => ({ raw, group: raw?.group ?? '' }));
265
+ if (!payload || typeof payload !== 'object') return [];
266
+ const result = [];
267
+ for (const [group, rows] of Object.entries(payload)) {
268
+ if (!Array.isArray(rows)) continue;
269
+ for (const row of rows) {
270
+ if (!Array.isArray(row)) {
271
+ result.push({ raw: row, group });
272
+ continue;
273
+ }
274
+ // Search payloads use [ID,fork,name,sec] under an entity key; top results carry entity last.
275
+ const raw = group === '' && row.length >= 5
276
+ ? { ID: row[0], fork: row[1], name: row[2], sec: row[3], entity: row[4], group }
277
+ : { ID: row[0], fork: row[1], name: row[2], sec: row[3], entity: group, group };
278
+ result.push({ raw, group });
279
+ }
280
+ }
281
+ return result;
282
+ }
283
+
284
+ /** @param {unknown} raw @param {string} group @param {string} query @returns {Record<string, any>|null} */
285
+ function normalizeRecord(raw, group, query) {
286
+ if (Array.isArray(raw)) {
287
+ if (query === '' && raw.length >= 4) {
288
+ return {
289
+ raw, entity: String(raw[0]), ID: raw[1], fork: raw[2] ?? null,
290
+ name: String(raw[3]), sec: String(raw[4] ?? ''), group: ''
291
+ };
292
+ }
293
+ return null;
294
+ }
295
+ if (!raw || typeof raw !== 'object' || raw.ID == null || raw.name == null) return null;
296
+ return {
297
+ raw,
298
+ entity: String(raw.entity ?? group ?? 'records'),
299
+ ID: raw.ID,
300
+ fork: raw.fork ?? null,
301
+ name: String(raw.name),
302
+ sec: String(raw.sec ?? ''),
303
+ group: String(raw.group ?? group ?? '')
304
+ };
305
+ }
306
+
307
+ /** @param {unknown} raw @param {unknown} resolver @returns {Record<string, any>} */
308
+ function mergeDestination(raw, resolver) {
309
+ const direct = raw && typeof raw === 'object' && !Array.isArray(raw) ? raw : {};
310
+ const resolved = typeof resolver === 'function' ? resolver(raw) : null;
311
+ const destination = resolved && typeof resolved === 'object' ? resolved : {};
312
+ return Object.fromEntries(['href', 'target', 'invoke', 'value'].flatMap((key) => {
313
+ const value = destination[key] ?? direct[key];
314
+ return value === undefined ? [] : [[key, value]];
315
+ }));
316
+ }
317
+
318
+ /** @param {unknown} value @returns {string|null} */
319
+ function normalizeServerColor(value) {
320
+ const source = String(value ?? '').trim();
321
+ if (!source) return null;
322
+ const color = source.startsWith('#') ? source : `#${source}`;
323
+ return /^#[\da-f]{3}(?:[\da-f]{3})?$/i.test(color) ? color : null;
324
+ }
325
+
326
+ /** @param {unknown} input @returns {Record<string, any>} */
327
+ function launcherLabels(input) {
328
+ const labels = input && typeof input === 'object' ? input : {};
329
+ return {
330
+ applications: String(labels.applications ?? 'Applications'),
331
+ recent: String(labels.recent ?? 'Recent'),
332
+ results: String(labels.results ?? 'Top results'),
333
+ entities: labels.entities && typeof labels.entities === 'object' ? labels.entities : {},
334
+ move: String(labels.move ?? 'Move'),
335
+ open: String(labels.open ?? 'Open'),
336
+ close: String(labels.close ?? 'Close')
337
+ };
338
+ }
@@ -109,6 +109,7 @@ export const zeyosModules = Object.freeze({
109
109
  * @type {Readonly<Record<string, string>>}
110
110
  */
111
111
  export const moduleAliases = Object.freeze({
112
+ main: 'zeyos',
112
113
  addresses: 'contacts',
113
114
  clocking: 'actionsteps',
114
115
  comments: 'notes',
@@ -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);
@@ -1,7 +1,6 @@
1
1
  /*
2
- * Tier-2 semantic tokens — dark theme, from the shadcn/ui preset `b2BVl11e4` (Zinc):
3
- * Zinc-950 page, Zinc-900 cards and popovers, Zinc-800 muted fills, translucent white borders
4
- * (10%) and inputs (15%), Zinc-400 muted text.
2
+ * Tier-2 semantic tokens — dark theme: a near-black page, raised neutral surfaces, muted fills,
3
+ * translucent white borders (10%) and inputs (15%), and restrained secondary text.
5
4
  *
6
5
  * The accent roles take the light end of the `--zx-accent-*` ramp (300/400/500) where the light
7
6
  * theme takes the dark end, so a preset that repoints the ramp lands correctly in both.
@@ -1,15 +1,15 @@
1
1
  /*
2
2
  * Tier-1 palette and primitives.
3
3
  *
4
- * Derived from the shadcn/ui preset `b2BVl11e4` (style Nova · base colour Zinc · theme Zinc ·
5
- * chart colour Emerald · Inter · radius small). The neutral ramp is Tailwind Zinc; the accent
6
- * ramp is the preset's Emerald chart ramp, anchored at 400 to the ZeyOS brand green #21cc75.
4
+ * The neutral ramp uses Zinc-like values; the accent ramp uses an emerald progression anchored at
5
+ * 400 to the ZeyOS brand green #21cc75. Inter and a compact radius scale support dense business
6
+ * interfaces without coupling the token contract to another UI toolkit.
7
7
  *
8
8
  * Only tier-2 semantic tokens (tokens/semantic.css, tokens/dark.css) may reference these.
9
9
  * Component CSS must never use them directly — tests/lint-tokens.js enforces that.
10
10
  */
11
11
  :root {
12
- /* Neutrals — Tailwind Zinc */
12
+ /* Neutrals */
13
13
  --zx-gray-0: #ffffff;
14
14
  --zx-gray-50: #fafafa;
15
15
  --zx-gray-100: #f4f4f5;
@@ -24,7 +24,7 @@
24
24
  --zx-gray-900: #18181b;
25
25
  --zx-gray-950: #09090b;
26
26
 
27
- /* Accent — the preset's Emerald chart ramp, with the ZeyOS brand green at 400 */
27
+ /* Accent — an emerald ramp with the ZeyOS brand green at 400 */
28
28
  --zx-green-300: #5ee9b5;
29
29
  --zx-green-400: #21cc75;
30
30
  --zx-green-500: #009966;
@@ -63,7 +63,7 @@
63
63
  --zx-space-7: 32px;
64
64
  --zx-space-8: 40px;
65
65
 
66
- /* Radius — the preset's `--radius: 0.45rem`, with shadcn's derived steps */
66
+ /* Radius — a 0.45rem base with compact derived steps */
67
67
  --zx-radius: 0.45rem;
68
68
  --zx-radius-sm: calc(var(--zx-radius) - 4px);
69
69
  --zx-radius-md: calc(var(--zx-radius) - 2px);
@@ -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);
@@ -1,9 +1,9 @@
1
1
  /*
2
2
  * Tier-2 semantic tokens — light theme (the default).
3
3
  *
4
- * The mapping follows the shadcn/ui preset `b2BVl11e4`: white surfaces, Zinc-100 hover/muted
5
- * fills, Zinc-200 borders and inputs, Zinc-500 muted text, Zinc-950 body text, and the Nova
6
- * control geometry (32px controls, `--radius` corners, a 3px translucent focus ring).
4
+ * The mapping uses white surfaces, restrained neutral hover/muted fills, quiet borders and inputs,
5
+ * strong body text, and compact control geometry (32px controls, `--radius` corners, a 3px
6
+ * translucent focus ring).
7
7
  *
8
8
  * The accent roles read `--zx-accent-*` rather than the green ramp directly, which is what lets
9
9
  * `tokens/themes.css` retheme them. Status colours keep their own ramps on purpose — see the note
@@ -48,6 +48,8 @@
48
48
  --zx-control-font-size: var(--zx-text-md);
49
49
  --zx-control-font-weight: 500;
50
50
  --zx-overlay-shadow: var(--zx-shadow-3);
51
+ /* Blur applied behind a backdrop that asked for it. Theme-independent, so light defines it once. */
52
+ --zx-overlay-blur: 8px;
51
53
  --zx-header-bg: var(--zx-gray-900);
52
54
  --zx-header-text: var(--zx-gray-50);
53
55
  }
@@ -17,7 +17,7 @@
17
17
  * against the dark page, which is what keeps `--zx-color-on-accent` correct in both polarities.
18
18
  */
19
19
 
20
- /* Zx — the ZeyOS brand green on the shadcn Emerald ramp. The default. */
20
+ /* Zx — the ZeyOS brand green on Xenon's emerald ramp. The default. */
21
21
  [data-zx-preset="zx"] {
22
22
  --zx-accent-300: #5ee9b5;
23
23
  --zx-accent-400: #21cc75;
package/styles/zx.css CHANGED
@@ -21,17 +21,25 @@
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");
27
28
  @import url("../src/components/navigation-bar/navigation-bar.css");
28
29
  @import url("../src/components/search/search.css");
30
+ @import url("../src/components/launcher/launcher.css");
31
+ @import url("../src/components/avatar/avatar.css");
32
+ @import url("../src/components/account-menu/account-menu.css");
33
+ @import url("../src/components/app-rail/app-rail.css");
34
+ @import url("../src/components/app-sidebar/app-sidebar.css");
29
35
  @import url("../src/components/message/message.css");
30
36
  @import url("../src/components/modal/modal.css");
31
37
  @import url("../src/components/dialog/dialog.css");
38
+ @import url("../src/components/sheet/sheet.css");
32
39
  @import url("../src/components/dropdown/dropdown.css");
33
40
  @import url("../src/components/tooltip/tooltip.css");
34
41
  @import url("../src/components/split-view/split-view.css");
42
+ @import url("../src/components/dock/dock.css");
35
43
  @import url("../src/components/menu-button/menu-button.css");
36
44
  @import url("../src/components/context-menu/context-menu.css");
37
45
  @import url("../src/components/select/select.css");
@@ -40,7 +48,6 @@
40
48
  @import url("../src/components/number-field/number-field.css");
41
49
  @import url("../src/components/slider/slider.css");
42
50
  @import url("../src/components/rating/rating.css");
43
- @import url("../src/components/permission/permission.css");
44
51
  @import url("../src/components/date-picker/date-picker.css");
45
52
  @import url("../src/components/date-picker/time-picker.css");
46
53
  @import url("../src/components/datebox/datebox.css");
@@ -48,6 +55,8 @@
48
55
  @import url("../src/components/datebox/date-range-box.css");
49
56
  @import url("../src/components/timebox/timebox.css");
50
57
  @import url("../src/components/table/table.css");
58
+ @import url("../src/components/grid/grid.css");
59
+ @import url("../src/components/chart/chart.css");
51
60
  @import url("../src/components/tree/tree.css");
52
61
  @import url("../src/components/finder/finder.css");
53
62
  @import url("../src/components/data-filter/data-filter.css");
@@ -60,3 +69,4 @@
60
69
  @import url("../src/components/value-list/value-list.css");
61
70
  @import url("../src/components/multi-value-editor/multi-value-editor.css");
62
71
  @import url("../src/components/field-upload/field-upload.css");
72
+ @import url("../src/components/questionnaire/questionnaire.css");