@zeyos/zx 5.3.0 → 5.5.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 (114) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/README.md +49 -16
  3. package/dist/types/components/app-sidebar/app-sidebar.d.ts +33 -0
  4. package/dist/types/components/badge/badge.d.ts +5 -4
  5. package/dist/types/components/datebox/date-range-box.d.ts +15 -2
  6. package/dist/types/components/datebox/datebox.d.ts +37 -3
  7. package/dist/types/components/kbd/kbd.d.ts +41 -0
  8. package/dist/types/components/launcher/launcher.d.ts +4 -2
  9. package/dist/types/components/prose/prose.d.ts +69 -0
  10. package/dist/types/components/questionnaire/questionnaire.d.ts +0 -36
  11. package/dist/types/components/stat-tile/stat-tile.d.ts +20 -0
  12. package/dist/types/components/tag-picker/tag-picker.d.ts +11 -5
  13. package/dist/types/components/tree/tree.d.ts +44 -3
  14. package/dist/types/core/icons.d.ts +22 -1
  15. package/dist/types/index.d.ts +4 -2
  16. package/dist/types/internal/app-rail.d.ts +10 -3
  17. package/dist/types/internal/row-actions.d.ts +151 -0
  18. package/dist/zx-zeyos.esm.js +264 -82
  19. package/dist/zx-zeyos.esm.min.js +4 -4
  20. package/dist/zx.css +1288 -439
  21. package/dist/zx.esm.js +952 -392
  22. package/dist/zx.esm.min.js +6 -6
  23. package/dist/zx.global.js +952 -392
  24. package/dist/zx.global.min.js +6 -6
  25. package/dist/zx.min.css +1 -1
  26. package/docs/api.json +112 -4
  27. package/docs/llms.md +433 -38
  28. package/docs/llms.txt +21 -1
  29. package/package.json +1 -1
  30. package/src/components/account-menu/account-menu.js +2 -2
  31. package/src/components/app-rail/app-rail.css +11 -11
  32. package/src/components/app-sidebar/app-sidebar.css +90 -17
  33. package/src/components/app-sidebar/app-sidebar.js +120 -12
  34. package/src/components/badge/badge.css +33 -20
  35. package/src/components/badge/badge.js +5 -4
  36. package/src/components/breadcrumb/breadcrumb.css +28 -3
  37. package/src/components/breadcrumb/breadcrumb.js +2 -2
  38. package/src/components/button/button.css +24 -13
  39. package/src/components/button/button.js +20 -2
  40. package/src/components/calendar/calendar.css +14 -4
  41. package/src/components/card-view/card-view.js +2 -2
  42. package/src/components/chart/chart.js +20 -5
  43. package/src/components/check-button/check-button.css +11 -3
  44. package/src/components/check-button/check-button.js +3 -3
  45. package/src/components/context-menu/context-menu.css +7 -1
  46. package/src/components/date-picker/date-picker.css +6 -0
  47. package/src/components/date-picker/date-picker.js +5 -5
  48. package/src/components/date-picker/date-range-picker.css +6 -0
  49. package/src/components/date-picker/date-range-picker.js +3 -3
  50. package/src/components/date-picker/month-picker.js +3 -3
  51. package/src/components/date-picker/time-picker.css +6 -0
  52. package/src/components/datebox/date-range-box.js +30 -6
  53. package/src/components/datebox/datebox.js +44 -7
  54. package/src/components/dialog/dialog.css +0 -1
  55. package/src/components/dialog/dialog.js +2 -1
  56. package/src/components/dock/dock.js +2 -2
  57. package/src/components/dropdown/dropdown.css +2 -1
  58. package/src/components/entity-ref/entity-ref.css +8 -1
  59. package/src/components/file-item/file-item.css +1 -1
  60. package/src/components/finder/finder.js +2 -2
  61. package/src/components/groupbox/groupbox.js +2 -2
  62. package/src/components/kanban-view/kanban-view.css +8 -4
  63. package/src/components/kanban-view/kanban-view.js +3 -3
  64. package/src/components/kbd/kbd.css +64 -0
  65. package/src/components/kbd/kbd.js +121 -0
  66. package/src/components/launcher/launcher.css +30 -25
  67. package/src/components/launcher/launcher.js +15 -21
  68. package/src/components/list-toolbar/list-toolbar.css +7 -1
  69. package/src/components/menu-button/menu-button.css +9 -2
  70. package/src/components/message/message.css +6 -2
  71. package/src/components/message/message.js +2 -2
  72. package/src/components/module-bar/module-bar.css +11 -1
  73. package/src/components/multi-value-editor/multi-value-editor.js +4 -4
  74. package/src/components/navigation-bar/navigation-bar.css +3 -2
  75. package/src/components/pagination/pagination.js +2 -2
  76. package/src/components/panel/panel.js +2 -2
  77. package/src/components/prose/prose.css +53 -0
  78. package/src/components/prose/prose.js +152 -0
  79. package/src/components/questionnaire/questionnaire.css +7 -17
  80. package/src/components/questionnaire/questionnaire.js +16 -1
  81. package/src/components/rating/rating.css +3 -1
  82. package/src/components/search/search.js +2 -2
  83. package/src/components/select/glyphs.js +3 -3
  84. package/src/components/select/select.css +35 -7
  85. package/src/components/select/select.js +4 -4
  86. package/src/components/stat-tile/stat-tile.css +56 -2
  87. package/src/components/stat-tile/stat-tile.js +25 -2
  88. package/src/components/stepper/stepper.css +2 -1
  89. package/src/components/stepper/stepper.js +3 -3
  90. package/src/components/tabbox/tabbox.css +2 -2
  91. package/src/components/tabbox/tabbox.js +2 -2
  92. package/src/components/table/table.css +52 -16
  93. package/src/components/table/table.js +7 -5
  94. package/src/components/tag-picker/tag-picker.css +56 -43
  95. package/src/components/tag-picker/tag-picker.js +21 -16
  96. package/src/components/tree/tree.css +44 -0
  97. package/src/components/tree/tree.js +97 -9
  98. package/src/components/value-list/value-list.css +25 -4
  99. package/src/components/value-list/value-list.js +2 -1
  100. package/src/components/view/record-view.js +3 -3
  101. package/src/components/view-settings/view-settings.css +2 -1
  102. package/src/components/workspace-switcher/workspace-switcher.js +3 -3
  103. package/src/core/icons.js +34 -3
  104. package/src/elements/define.js +1 -0
  105. package/src/index.js +4 -2
  106. package/src/internal/app-rail.js +5 -1
  107. package/src/internal/row-actions.js +203 -0
  108. package/styles/base.css +26 -1
  109. package/styles/prose.css +306 -0
  110. package/styles/tokens/dark.css +108 -103
  111. package/styles/tokens/global.css +24 -9
  112. package/styles/tokens/semantic.css +520 -198
  113. package/styles/tokens/themes.css +9 -0
  114. package/styles/zx.css +3 -0
package/src/core/icons.js CHANGED
@@ -15,9 +15,38 @@ import { faIconClasses, kitUrl, loadFontAwesomeKit, parseIconSpec } from './font
15
15
 
16
16
  const SVG_NS = 'http://www.w3.org/2000/svg';
17
17
 
18
+ /**
19
+ * Icon sizes in CSS pixels, named by the role an icon plays rather than by its measure, so a call
20
+ * site says what a glyph is for and every glyph in that role renders at one size:
21
+ *
22
+ * icon('chevron-down', { size: ICON_SIZE.chevron });
23
+ *
24
+ * Several roles share a value; they are named apart so one can change without a sweep. At 14px and
25
+ * below an outline glyph is drawn with a one-pixel line, so the roles that share 14 also share a
26
+ * stroke weight.
27
+ * @type {Readonly<{control: number, chevron: number, dismiss: number, check: number, sort: number,
28
+ * chip: number, marker: number}>}
29
+ */
30
+ export const ICON_SIZE = Object.freeze({
31
+ /** The default: an icon that is a control's content or leads its label. */
32
+ control: 16,
33
+ /** Dropdown, disclosure, and reorder chevrons; calendar and pager arrows; breadcrumb separators. */
34
+ chevron: 14,
35
+ /** The × that clears a field, closes a tab, dialog, or message, or removes a row. */
36
+ dismiss: 14,
37
+ /** The check of a selected option, a pressed toggle button, or a completed step. */
38
+ check: 14,
39
+ /** The sort-direction arrow beside a column heading. */
40
+ sort: 14,
41
+ /** Any glyph inside a chip or token, its remove × included. */
42
+ chip: 12,
43
+ /** A glyph drawn inside a small status marker. */
44
+ marker: 8
45
+ });
46
+
18
47
  /**
19
48
  * @typedef {Object} IconOptions
20
- * @property {number|string} [size=16] Rendered width and height.
49
+ * @property {number|string} [size=16] Rendered width and height; `ICON_SIZE` names one per role.
21
50
  * @property {string|null} [label=null] Accessible label; null marks the icon decorative.
22
51
  * @property {string|string[]} [class] Extra class names added to the element.
23
52
  * @property {string} [style] Font Awesome style for this icon only (`'solid'`, `'duotone'`, …).
@@ -126,6 +155,8 @@ export const icons = Object.freeze({
126
155
  // <lucide-glyphs>
127
156
  'arrow-up-wide-short': outline('M3 8l4-4 4 4M7 4v16M11 12h10M11 16h7M11 20h4'), // arrow-up-wide-narrow
128
157
  'arrow-down-wide-short': outline('M3 16l4 4 4-4M7 20V4M11 4h10M11 8h7M11 12h4'), // arrow-down-wide-narrow
158
+ 'arrow-up': outline('M5 12l7-7 7 7M12 19V5'),
159
+ 'arrow-down': outline('M12 5v14M19 12l-7 7-7-7'),
129
160
  'chevron-down': outline('M6 9l6 6 6-6'),
130
161
  'chevron-up': outline('M18 15l-6-6-6 6'),
131
162
  'chevron-left': outline('M15 18l-6-6 6-6'),
@@ -376,7 +407,7 @@ function builtinIcon(name, options) {
376
407
  * @returns {SVGSVGElement}
377
408
  */
378
409
  function iconSvg(viewBox, paint, options) {
379
- const { size = 16 } = options;
410
+ const { size = ICON_SIZE.control } = options;
380
411
  const svg = document.createElementNS(SVG_NS, 'svg');
381
412
  svg.setAttribute('class', classList('zx-icon', options.class));
382
413
  svg.setAttribute('viewBox', viewBox);
@@ -462,7 +493,7 @@ function warnMissingIcon(name) {
462
493
  * @returns {HTMLElement}
463
494
  */
464
495
  function faIcon(classes, options) {
465
- const { size = 16 } = options;
496
+ const { size = ICON_SIZE.control } = options;
466
497
  const element = document.createElement('i');
467
498
  element.className = classList('zx-icon', ...classes, options.class);
468
499
  element.style.fontSize = typeof size === 'number' ? `${size}px` : String(size);
@@ -88,6 +88,7 @@ const CHECKLIST_ATTRS = attributes({
88
88
 
89
89
  const DATEBOX_ATTRS = attributes({
90
90
  format: text({ default: '%d.%m.%Y', rebuild: true }),
91
+ 'display-format': text({ property: 'displayFormat', default: null, rebuild: true }),
91
92
  time: bool({ always: true, rebuild: true }),
92
93
  value: text({ option: null, default: null, normalize: normalizeDateValue, set: (component, value) => component.set(value, { silent: true }), get: (component, host) => dateValue(component.get(), Boolean(host.time)), serialize: serializeDateValue }),
93
94
  placeholder: text({ default: null, rebuild: true }),
package/src/index.js CHANGED
@@ -60,7 +60,7 @@ export {
60
60
  formatDate, parseDate, clampDate, isSameDay, addDays, addMonths, getWeekStart
61
61
  } from './core/date.js';
62
62
  export {
63
- icon, icons, iconNames, registerIcons,
63
+ icon, icons, iconNames, registerIcons, ICON_SIZE,
64
64
  configureIcons, getIconConfig, useFontAwesome, useBuiltinIcons, loadFontAwesome
65
65
  } from './core/icons.js';
66
66
  export {
@@ -78,6 +78,7 @@ export { toCsv, downloadBlob, copyToClipboard } from './core/export.js';
78
78
  export { defineElements } from './elements/define.js';
79
79
  export { button, buttonGroup, setButtonBusy } from './components/button/button.js';
80
80
  export { BADGE_TONES, badge, badgeGroup } from './components/badge/badge.js';
81
+ export { kbd, keyLabels } from './components/kbd/kbd.js';
81
82
  export { CheckButton } from './components/check-button/check-button.js';
82
83
  export { emptyState } from './components/empty-state/empty-state.js';
83
84
  export { spinner } from './components/loading/spinner.js';
@@ -88,6 +89,7 @@ export { stack, grid, aspect } from './components/layout/layout.js';
88
89
  export { truncate, isTruncated } from './components/truncate/truncate.js';
89
90
  export { copyButton } from './components/copy/copy-button.js';
90
91
  export { CopyInput } from './components/copy/copy-input.js';
92
+ export { proseAnchors, sectionHref } from './components/prose/prose.js';
91
93
  export { CodeEditor, indentSelection, editorPosition } from './components/code-editor/code-editor.js';
92
94
  export { Toolbar } from './components/toolbar/toolbar.js';
93
95
  export { Toggle } from './components/toggle/toggle.js';
@@ -146,7 +148,7 @@ export { Slider, stepPrecision } from './components/slider/slider.js';
146
148
  export { DatePicker } from './components/date-picker/date-picker.js';
147
149
  export { MonthPicker } from './components/date-picker/month-picker.js';
148
150
  export { TimePicker } from './components/date-picker/time-picker.js';
149
- export { Datebox, DateTimeBox } from './components/datebox/datebox.js';
151
+ export { Datebox, DateTimeBox, dateboxFormats } from './components/datebox/datebox.js';
150
152
  export {
151
153
  DateRangePicker, clampRange, defaultDateRangePresets, normalizeRange, rangeNights, rangeStateOf
152
154
  } from './components/date-picker/date-range-picker.js';
@@ -19,7 +19,11 @@ import { Tooltip } from '../components/tooltip/tooltip.js';
19
19
  * @property {AppNavItem[]} [children] Child destinations/actions.
20
20
  * @property {boolean} [section] Makes the item a section: a quiet heading over its `children`, which
21
21
  * render at the same level. A section is never focused, selected, or collapsed, and needs no `id`.
22
- * @property {Node|{toElement: () => Node|null}} [actions] A section's trailing controls, such as an add button.
22
+ * @property {Node|{toElement: () => Node|null}|Array<import('./row-actions.js').RowAction|Node>} [actions]
23
+ * On a section, trailing controls beside its heading, such as an add button, always shown. On a
24
+ * destination of AppSidebar's tree, the row's actions: `{icon, label, onSelect(item), disabled?,
25
+ * danger?}` descriptors or nodes, revealed with the row, in its context menu, and after its
26
+ * control in the Tab order while it holds focus. Minimized flyouts show destinations only.
23
27
  */
24
28
  /**
25
29
  * @typedef {Object} AppRailPresenterOptions
@@ -0,0 +1,203 @@
1
+ import { h } from '../core/dom.js';
2
+ import { icon } from '../core/icons.js';
3
+ import { ContextMenu } from '../components/context-menu/context-menu.js';
4
+ import { MenuButton } from '../components/menu-button/menu-button.js';
5
+
6
+ /**
7
+ * One action a row offers: a repeated, secondary command such as "Add sub-page" or "Rename".
8
+ * @typedef {Object} RowAction
9
+ * @property {string} label What the action does; the tooltip, and with the row's name its
10
+ * accessible name.
11
+ * @property {string} [icon] Icon name. Inline actions show only the icon.
12
+ * @property {(subject: any) => void} onSelect Runs the action for the row's node or item.
13
+ * @property {boolean} [disabled=false] Whether the action is unavailable on this row.
14
+ * @property {boolean} [danger=false] Whether the action destroys something; menus colour it.
15
+ */
16
+ /** @typedef {RowAction|Node} RowActionEntry */
17
+ /**
18
+ * The controls built for one row.
19
+ * @typedef {Object} RowActionStrip
20
+ * @property {HTMLElement} element The strip, marked `data-zx-reveal`.
21
+ * @property {RowAction[]} actions Every descriptor of the row, inline and folded, in order — what
22
+ * the row's context menu lists. Inline buttons and menu items carry indexes into it.
23
+ * @property {MenuButton|null} menu The overflow menu, when actions were folded.
24
+ * @property {() => void} destroy Destroys the overflow menu.
25
+ */
26
+ /** A row never carries more controls than this before the rest fold into a menu. */
27
+ export const ROW_ACTION_LIMIT = 2;
28
+
29
+ /**
30
+ * Whether an entry is a control of the application's own, placed in the row as given.
31
+ * @param {unknown} entry Candidate entry.
32
+ * @returns {entry is Node}
33
+ */
34
+ export function isRowActionNode(entry) {
35
+ return Boolean(entry) && typeof entry === 'object'
36
+ && typeof /** @type {{nodeType?: unknown}} */ (entry).nodeType === 'number';
37
+ }
38
+
39
+ /**
40
+ * Whether an entry is a usable action descriptor: a label and something to run.
41
+ * @param {unknown} entry Candidate entry.
42
+ * @returns {entry is RowAction}
43
+ */
44
+ export function isRowAction(entry) {
45
+ if (!entry || typeof entry !== 'object' || isRowActionNode(entry)) return false;
46
+ const action = /** @type {Record<string, unknown>} */ (entry);
47
+ return action.label != null && String(action.label) !== '' && typeof action.onSelect === 'function';
48
+ }
49
+
50
+ /**
51
+ * Decides which entries a row shows and which fold into its overflow menu. One or two entries all
52
+ * show; with more, the first shows and the descriptors after it fold, so a row carries at most two
53
+ * controls of its own. A node is the application's control and never folds.
54
+ * @param {unknown} entries What `rowActions` or `actions` returned.
55
+ * @returns {{inline: RowActionEntry[], overflow: RowAction[]}}
56
+ */
57
+ export function planRowActions(entries) {
58
+ const valid = /** @type {RowActionEntry[]} */ ((Array.isArray(entries) ? entries : [])
59
+ .filter((entry) => isRowActionNode(entry) || isRowAction(entry)));
60
+ if (valid.length <= ROW_ACTION_LIMIT) return { inline: valid, overflow: [] };
61
+ const [first, ...rest] = valid;
62
+ return {
63
+ inline: [first, ...rest.filter(isRowActionNode)],
64
+ overflow: /** @type {RowAction[]} */ (rest.filter((entry) => !isRowActionNode(entry)))
65
+ };
66
+ }
67
+
68
+ /**
69
+ * An action control's accessible name, which says which row it acts on: on a list of rows every
70
+ * "Rename" button is otherwise the same button. The action comes first, so a screen reader's
71
+ * list of buttons still sorts by what they do.
72
+ * @param {string} action Action label.
73
+ * @param {string} name The row's name.
74
+ * @returns {string}
75
+ */
76
+ export function rowActionLabel(action, name) {
77
+ const row = String(name ?? '').trim();
78
+ return row ? `${String(action).trim()}: ${row}` : String(action).trim();
79
+ }
80
+
81
+ /**
82
+ * Menu items for descriptors, valued by their index in `actions`.
83
+ * @param {RowAction[]} actions The row's descriptors.
84
+ * @param {RowAction[]} [only=actions] The descriptors to list.
85
+ * @returns {Array<{label: string, icon?: string, value: number, danger: boolean, disabled: boolean}>}
86
+ */
87
+ export function menuEntries(actions, only = actions) {
88
+ return only.map((action) => ({
89
+ label: String(action.label),
90
+ icon: action.icon ? String(action.icon) : undefined,
91
+ value: actions.indexOf(action),
92
+ danger: Boolean(action.danger),
93
+ disabled: Boolean(action.disabled)
94
+ }));
95
+ }
96
+
97
+ /**
98
+ * Builds a row's action strip: an icon button per inline descriptor, the given nodes, and the
99
+ * overflow menu. Every control starts outside the Tab order; the host component makes the strip
100
+ * of the row holding focus tabbable. Inline buttons carry `data-row-action`, an index into
101
+ * `actions`, so the host runs them from its own delegated click listener.
102
+ * @param {unknown} entries Row actions.
103
+ * @param {{block: string, name: string, moreLabel?: string, run: (action: RowAction) => void}} options
104
+ * `block` names the parts (`zx-<block>__actions`, `zx-<block>__action`); `name` is the row's
105
+ * name; `moreLabel` names the overflow menu ("More actions"); `run` is called with a descriptor
106
+ * chosen from the overflow menu.
107
+ * @returns {RowActionStrip|null} Null when nothing usable was given.
108
+ */
109
+ export function renderRowActions(entries, { block, name, moreLabel = 'More actions', run }) {
110
+ const plan = planRowActions(entries);
111
+ if (plan.inline.length === 0) return null;
112
+ const actions = /** @type {RowAction[]} */ ((Array.isArray(entries) ? entries : []).filter(isRowAction));
113
+ const element = /** @type {HTMLElement} */ (h('span', { class: `zx-${block}__actions`, 'data-zx-reveal': '' }));
114
+
115
+ for (const entry of plan.inline) {
116
+ if (isRowActionNode(entry)) {
117
+ element.append(entry);
118
+ continue;
119
+ }
120
+ element.append(h('button', {
121
+ type: 'button',
122
+ class: ['zx-icon-btn', `zx-${block}__action`],
123
+ ariaLabel: rowActionLabel(entry.label, name),
124
+ title: String(entry.label),
125
+ disabled: Boolean(entry.disabled),
126
+ dataset: { rowAction: String(actions.indexOf(entry)) }
127
+ }, icon(entry.icon ? String(entry.icon) : 'dots')));
128
+ }
129
+
130
+ let menu = null;
131
+ if (plan.overflow.length > 0) {
132
+ menu = new MenuButton(null, {
133
+ icon: 'dots',
134
+ label: '',
135
+ kind: 'ghost',
136
+ placement: 'bottom-end',
137
+ items: menuEntries(actions, plan.overflow)
138
+ });
139
+ const trigger = menu.getTrigger();
140
+ trigger.classList.add(`zx-${block}__action`, `zx-${block}__more`);
141
+ trigger.setAttribute('aria-label', rowActionLabel(moreLabel, name));
142
+ trigger.title = String(moreLabel);
143
+ menu.on('select', (event) => {
144
+ const action = actions[Number(/** @type {CustomEvent} */ (event).detail.value)];
145
+ if (action && !action.disabled) run(action);
146
+ });
147
+ // The menu's own bubbling events stop at the trigger: a listener for the row component's
148
+ // `zx-select` must never hear an action chosen from a row's menu.
149
+ for (const type of ['zx-select', 'zx-open', 'zx-close']) {
150
+ menu.listen(trigger, type, (event) => event.stopPropagation());
151
+ }
152
+ element.append(trigger);
153
+ }
154
+
155
+ setRowActionsTabbable(element, false);
156
+ return {
157
+ element,
158
+ actions,
159
+ menu,
160
+ destroy: () => menu?.destroy()
161
+ };
162
+ }
163
+
164
+ /**
165
+ * Puts every control in a strip in or out of the Tab order.
166
+ * @param {Element|null|undefined} element A strip.
167
+ * @param {boolean} tabbable Whether its controls are Tab stops.
168
+ * @returns {void}
169
+ */
170
+ export function setRowActionsTabbable(element, tabbable) {
171
+ if (!element) return;
172
+ const controls = element.querySelectorAll('button, a[href], input, select, textarea, [tabindex]');
173
+ for (const control of controls) /** @type {HTMLElement} */ (control).tabIndex = tabbable ? 0 : -1;
174
+ }
175
+
176
+ /**
177
+ * The context menu of a component's rows: every descriptor of the row it opens on. Choosing an
178
+ * item closes the menu, which returns focus to the row, and only then runs the action — so a
179
+ * dialog the action opens records the row as the place to return to.
180
+ * @param {Element} target The element holding the rows.
181
+ * @param {string} selector The rows.
182
+ * @param {(row: Element) => {actions: RowAction[], subject: unknown}|null} resolve The row's
183
+ * descriptors and what their `onSelect` receives.
184
+ * @returns {ContextMenu}
185
+ */
186
+ export function rowActionMenu(target, selector, resolve) {
187
+ const menu = new ContextMenu(target, {
188
+ selector,
189
+ items: (context) => {
190
+ const found = context ? resolve(context) : null;
191
+ return found ? menuEntries(found.actions) : [];
192
+ }
193
+ });
194
+ menu.on('select', (event) => {
195
+ const { value, context } = /** @type {CustomEvent} */ (event).detail;
196
+ event.preventDefault();
197
+ const found = context ? resolve(context) : null;
198
+ const action = found?.actions[Number(value)];
199
+ menu.close();
200
+ if (action && !action.disabled) action.onSelect(found.subject);
201
+ });
202
+ return menu;
203
+ }
package/styles/base.css CHANGED
@@ -82,8 +82,33 @@
82
82
  cursor: pointer;
83
83
  }
84
84
 
85
+ /* The hover fill is laid over the control fill rather than replacing it: in dark both are about 5%
86
+ white, and a swap would leave the pointer with nothing to show. */
85
87
  :where(.zx-scope button:not(.zx-icon-btn)):hover {
86
- background: var(--zx-color-bg-hover);
88
+ background: linear-gradient(var(--zx-color-bg-hover), var(--zx-color-bg-hover)), var(--zx-color-bg-control);
89
+ }
90
+
91
+ /* Revealed affordances. Inside a `[data-zx-reveal-host]` — a row, a section heading — an element
92
+ marked `[data-zx-reveal]` rests invisible and appears while the host is pointed at, holds focus,
93
+ is current or selected, or has a menu open. It keeps its space (opacity, never display), so
94
+ nothing shifts, and it stays in the tab order, so focusing it is enough to show it. Only
95
+ repeated, secondary per-row actions that are reachable another way belong here. Hosts do not
96
+ nest. Zero specificity, so a component can still decide for itself. */
97
+ :where(.zx-scope [data-zx-reveal-host]) :where([data-zx-reveal]) {
98
+ opacity: 0;
99
+ transition: opacity var(--zx-dur-fast) var(--zx-ease);
100
+ }
101
+
102
+ :where(.zx-scope [data-zx-reveal-host]):where(:hover, :focus-within, [aria-current]:not([aria-current="false"]),
103
+ [aria-selected="true"], :has([aria-expanded="true"])) :where([data-zx-reveal]) {
104
+ opacity: 1;
105
+ }
106
+
107
+ /* No pointer to hover with, or a request for more contrast: nothing hides. */
108
+ @media (hover: none), (prefers-contrast: more), (forced-colors: active) {
109
+ :where(.zx-scope [data-zx-reveal-host]) :where([data-zx-reveal]) {
110
+ opacity: 1;
111
+ }
87
112
  }
88
113
 
89
114
  /* Quiet fields. Inside `[data-zx-fields="quiet"]` — a property panel, an inspector, an inline
@@ -0,0 +1,306 @@
1
+ /*
2
+ * Prose — the reading register. `.zx-prose` sets authored content (a document, a record's notes, a
3
+ * message body, an assistant's answer) in the reading tokens rather than the interface ones:
4
+ * `--zx-font-prose`, `--zx-prose-size`, `--zx-prose-leading`, and `--zx-prose-measure`. A theme can
5
+ * therefore set its documents in a serif, or at another size, without touching a single control.
6
+ *
7
+ * Every rule is `.zx-prose` plus a `:where()` — one class of specificity — and this file loads
8
+ * before the component stylesheets, so a component placed in prose (a badge, an entity reference,
9
+ * a table) keeps its own styles, while an application's bare element reset (`p { margin: 0 }`)
10
+ * cannot undo the rhythm.
11
+ *
12
+ * <article class="zx-prose">…</article>
13
+ * <div class="zx-prose" data-size="sm">…</div> interface-sized, for comments and previews
14
+ * <article class="zx-prose" data-zx-measure="full">… no reading measure
15
+ */
16
+ .zx-prose {
17
+ max-inline-size: var(--zx-prose-measure);
18
+ color: var(--zx-color-text);
19
+ font-family: var(--zx-font-prose);
20
+ font-size: var(--zx-prose-size);
21
+ line-height: var(--zx-prose-leading);
22
+ overflow-wrap: break-word;
23
+ }
24
+
25
+ .zx-prose[data-size="sm"] {
26
+ font-size: var(--zx-text-md);
27
+ line-height: 1.6;
28
+ }
29
+
30
+ .zx-prose[data-zx-measure="full"] {
31
+ max-inline-size: none;
32
+ }
33
+
34
+ /* Rhythm: one gap between blocks, more above a heading, less below it. */
35
+ .zx-prose > :where(*) {
36
+ margin-block: 0;
37
+ }
38
+
39
+ .zx-prose > :where(* + *) {
40
+ margin-block-start: 1em;
41
+ }
42
+
43
+ .zx-prose :where(h1, h2, h3, h4) {
44
+ color: var(--zx-color-text);
45
+ font-weight: var(--zx-weight-title);
46
+ line-height: 1.3;
47
+ letter-spacing: var(--zx-tracking-tight);
48
+ text-wrap: balance;
49
+ scroll-margin-block-start: var(--zx-space-4);
50
+ }
51
+
52
+ /* Heading sizes follow the reading size, not the interface scale, so they move with it. */
53
+ .zx-prose :where(h1) {
54
+ font-size: 1.875em;
55
+ line-height: 1.2;
56
+ letter-spacing: var(--zx-tracking-title);
57
+ }
58
+
59
+ .zx-prose :where(h2) {
60
+ font-size: 1.375em;
61
+ letter-spacing: var(--zx-tracking-title);
62
+ }
63
+
64
+ .zx-prose :where(h3) {
65
+ font-size: 1.125em;
66
+ }
67
+
68
+ .zx-prose :where(h4) {
69
+ font-size: 1em;
70
+ }
71
+
72
+ .zx-prose > :where(h1, h2) {
73
+ margin-block-start: 2em;
74
+ }
75
+
76
+ .zx-prose > :where(h3, h4) {
77
+ margin-block-start: 1.5em;
78
+ }
79
+
80
+ .zx-prose > :where(h1, h2, h3, h4) + :where(*) {
81
+ margin-block-start: 0.5em;
82
+ }
83
+
84
+ .zx-prose > :where(:first-child) {
85
+ margin-block-start: 0;
86
+ }
87
+
88
+ .zx-prose :where(strong, b) {
89
+ font-weight: var(--zx-weight-semibold);
90
+ }
91
+
92
+ /* Links read as part of the sentence — the body colour over a quiet underline — and take the
93
+ accent on hover. The underline stays, so a link never relies on colour alone. */
94
+ .zx-prose :where(a[href]) {
95
+ color: inherit;
96
+ text-decoration: underline 1px color-mix(in srgb, currentColor 35%, transparent);
97
+ text-underline-offset: 0.2em;
98
+ transition: color var(--zx-dur-fast) var(--zx-ease), text-decoration-color var(--zx-dur-fast) var(--zx-ease);
99
+ }
100
+
101
+ .zx-prose :where(a[href]:hover) {
102
+ color: var(--zx-color-accent);
103
+ text-decoration-color: currentColor;
104
+ }
105
+
106
+ .zx-prose :where(ul, ol) {
107
+ padding-inline-start: 1.4em;
108
+ }
109
+
110
+ .zx-prose :where(li + li) {
111
+ margin-block-start: 0.25em;
112
+ }
113
+
114
+ .zx-prose :where(li > ul, li > ol) {
115
+ margin-block-start: 0.25em;
116
+ }
117
+
118
+ .zx-prose :where(li)::marker {
119
+ color: var(--zx-color-text-muted);
120
+ }
121
+
122
+ .zx-prose :where(hr) {
123
+ border: 0;
124
+ border-block-start: 1px solid var(--zx-color-border-subtle);
125
+ }
126
+
127
+ .zx-prose :where(blockquote) {
128
+ margin-inline: 0;
129
+ padding-inline-start: 1em;
130
+ border-inline-start: 3px solid var(--zx-color-border-strong);
131
+ color: var(--zx-color-text-muted);
132
+ }
133
+
134
+ .zx-prose :where(code, kbd, samp) {
135
+ font-family: var(--zx-font-mono);
136
+ font-size: 0.875em;
137
+ }
138
+
139
+ .zx-prose :where(:not(pre) > code) {
140
+ padding: 0.1em 0.35em;
141
+ border-radius: var(--zx-radius-sm);
142
+ background: var(--zx-color-bg-muted);
143
+ }
144
+
145
+ .zx-prose :where(pre) {
146
+ overflow-x: auto;
147
+ padding: var(--zx-space-3) var(--zx-space-4);
148
+ border-radius: var(--zx-radius-md);
149
+ background: var(--zx-color-bg-muted);
150
+ font-family: var(--zx-font-mono);
151
+ font-size: var(--zx-text-sm);
152
+ line-height: 1.65;
153
+ overflow-wrap: normal;
154
+ tab-size: 2;
155
+ }
156
+
157
+ .zx-prose :where(pre > code) {
158
+ font-size: inherit;
159
+ }
160
+
161
+ /* Content colour: a highlighter. A bare mark is the amber tone; `data-tone` picks any of the nine.
162
+ No padding, so marking a run of text never shifts the line it sits in. */
163
+ .zx-prose :where(mark) {
164
+ padding: 0;
165
+ border-radius: var(--zx-radius-sm);
166
+ background: var(--zx-color-tone-amber-bg);
167
+ color: var(--zx-color-tone-amber-fg);
168
+ }
169
+
170
+ .zx-prose :where(table) {
171
+ inline-size: 100%;
172
+ border-collapse: collapse;
173
+ font-size: var(--zx-text-md);
174
+ line-height: 1.5;
175
+ }
176
+
177
+ .zx-prose :where(th, td) {
178
+ padding: var(--zx-space-2) var(--zx-space-3);
179
+ border-block-end: 1px solid var(--zx-color-border-subtle);
180
+ text-align: start;
181
+ vertical-align: top;
182
+ }
183
+
184
+ .zx-prose :where(th:first-child, td:first-child) {
185
+ padding-inline-start: 0;
186
+ }
187
+
188
+ .zx-prose :where(th:last-child, td:last-child) {
189
+ padding-inline-end: 0;
190
+ }
191
+
192
+ .zx-prose :where(thead th) {
193
+ border-block-end-color: var(--zx-color-border);
194
+ color: var(--zx-color-text-muted);
195
+ font-size: var(--zx-text-sm);
196
+ font-weight: var(--zx-weight-medium);
197
+ }
198
+
199
+ .zx-prose :where(td[data-align="end"], th[data-align="end"]) {
200
+ text-align: end;
201
+ font-variant-numeric: tabular-nums;
202
+ }
203
+
204
+ .zx-prose :where(tbody tr:last-child > *) {
205
+ border-block-end: 0;
206
+ }
207
+
208
+ .zx-prose :where(figure) {
209
+ display: grid;
210
+ gap: var(--zx-space-2);
211
+ margin-inline: 0;
212
+ }
213
+
214
+ .zx-prose :where(img, video) {
215
+ display: block;
216
+ max-inline-size: 100%;
217
+ block-size: auto;
218
+ border-radius: var(--zx-radius-lg);
219
+ }
220
+
221
+ .zx-prose :where(figcaption) {
222
+ color: var(--zx-color-text-muted);
223
+ font-size: var(--zx-text-sm);
224
+ line-height: 1.5;
225
+ text-align: center;
226
+ }
227
+
228
+ /*
229
+ * Callout — a paragraph set apart: an icon column and a body on a tinted fill, no frame. Neutral by
230
+ * default, because most callouts are emphasis, not status; `data-kind` makes it a status
231
+ * (info, success, warning, danger) and `data-tone` a category. It reads at the interface size so a
232
+ * callout in a document and one in a panel are the same object.
233
+ */
234
+ .zx-callout {
235
+ --zx-callout-ink: var(--zx-color-text-muted);
236
+ --zx-callout-bg: var(--zx-color-bg-muted);
237
+ display: grid;
238
+ grid-template-columns: auto minmax(0, 1fr);
239
+ gap: var(--zx-space-3);
240
+ padding: var(--zx-space-3) var(--zx-space-4);
241
+ border-radius: var(--zx-radius-lg);
242
+ background: var(--zx-callout-bg);
243
+ color: var(--zx-color-text);
244
+ font-size: var(--zx-text-md);
245
+ line-height: 1.6;
246
+ }
247
+
248
+ .zx-callout:not(:has(> .zx-callout__icon)) {
249
+ grid-template-columns: minmax(0, 1fr);
250
+ }
251
+
252
+ .zx-callout__icon {
253
+ display: inline-grid;
254
+ block-size: 1.6em;
255
+ place-items: center;
256
+ color: var(--zx-callout-ink);
257
+ }
258
+
259
+ .zx-callout__body > :where(*) {
260
+ margin-block: 0;
261
+ }
262
+
263
+ .zx-callout__body > :where(* + *) {
264
+ margin-block-start: var(--zx-space-2);
265
+ }
266
+
267
+ .zx-callout__title {
268
+ font-weight: var(--zx-weight-semibold);
269
+ }
270
+
271
+ .zx-callout[data-kind="info"] { --zx-callout-ink: var(--zx-color-info); --zx-callout-bg: var(--zx-color-info-bg); }
272
+ .zx-callout[data-kind="success"] { --zx-callout-ink: var(--zx-color-success); --zx-callout-bg: var(--zx-color-success-bg); }
273
+ .zx-callout[data-kind="warning"] { --zx-callout-ink: var(--zx-color-warning); --zx-callout-bg: var(--zx-color-warning-bg); }
274
+ .zx-callout[data-kind="danger"] { --zx-callout-ink: var(--zx-color-danger); --zx-callout-bg: var(--zx-color-danger-bg); }
275
+
276
+ /* The nine categorical tones, for callouts, marks, and highlighted runs of text alike. */
277
+ :is(.zx-callout, .zx-prose :where(mark, span:not([class])))[data-tone="blue"] { --zx-prose-tone-ink: var(--zx-color-tone-blue-fg); --zx-prose-tone-fill: var(--zx-color-tone-blue-bg); }
278
+ :is(.zx-callout, .zx-prose :where(mark, span:not([class])))[data-tone="teal"] { --zx-prose-tone-ink: var(--zx-color-tone-teal-fg); --zx-prose-tone-fill: var(--zx-color-tone-teal-bg); }
279
+ :is(.zx-callout, .zx-prose :where(mark, span:not([class])))[data-tone="green"] { --zx-prose-tone-ink: var(--zx-color-tone-green-fg); --zx-prose-tone-fill: var(--zx-color-tone-green-bg); }
280
+ :is(.zx-callout, .zx-prose :where(mark, span:not([class])))[data-tone="amber"] { --zx-prose-tone-ink: var(--zx-color-tone-amber-fg); --zx-prose-tone-fill: var(--zx-color-tone-amber-bg); }
281
+ :is(.zx-callout, .zx-prose :where(mark, span:not([class])))[data-tone="orange"] { --zx-prose-tone-ink: var(--zx-color-tone-orange-fg); --zx-prose-tone-fill: var(--zx-color-tone-orange-bg); }
282
+ :is(.zx-callout, .zx-prose :where(mark, span:not([class])))[data-tone="red"] { --zx-prose-tone-ink: var(--zx-color-tone-red-fg); --zx-prose-tone-fill: var(--zx-color-tone-red-bg); }
283
+ :is(.zx-callout, .zx-prose :where(mark, span:not([class])))[data-tone="pink"] { --zx-prose-tone-ink: var(--zx-color-tone-pink-fg); --zx-prose-tone-fill: var(--zx-color-tone-pink-bg); }
284
+ :is(.zx-callout, .zx-prose :where(mark, span:not([class])))[data-tone="violet"] { --zx-prose-tone-ink: var(--zx-color-tone-violet-fg); --zx-prose-tone-fill: var(--zx-color-tone-violet-bg); }
285
+ :is(.zx-callout, .zx-prose :where(mark, span:not([class])))[data-tone="slate"] { --zx-prose-tone-ink: var(--zx-color-tone-slate-fg); --zx-prose-tone-fill: var(--zx-color-tone-slate-bg); }
286
+
287
+ .zx-callout[data-tone] {
288
+ --zx-callout-ink: var(--zx-prose-tone-ink);
289
+ --zx-callout-bg: var(--zx-prose-tone-fill);
290
+ }
291
+
292
+ .zx-prose :where(mark[data-tone]) {
293
+ background: var(--zx-prose-tone-fill);
294
+ color: var(--zx-prose-tone-ink);
295
+ }
296
+
297
+ /* A coloured run of text is ink only; with `data-fill` it is highlighted as well. Only bare spans:
298
+ a component span that carries a tone (a badge) keeps its own construction. */
299
+ .zx-prose :where(span[data-tone]:not([class])) {
300
+ color: var(--zx-prose-tone-ink);
301
+ }
302
+
303
+ .zx-prose :where(span[data-tone][data-fill]:not([class])) {
304
+ border-radius: var(--zx-radius-sm);
305
+ background: var(--zx-prose-tone-fill);
306
+ }