@zeyos/zx 5.7.1 → 5.8.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 +296 -0
- package/README.md +47 -9
- package/dist/types/components/activity-item/activity-item.d.ts +14 -3
- package/dist/types/components/agent-avatar/agent-avatar.d.ts +165 -0
- package/dist/types/components/agent-avatar/agent-face.d.ts +93 -0
- package/dist/types/components/agent-thread/ag-ui.d.ts +21 -9
- package/dist/types/components/agent-thread/agent-thread.d.ts +26 -0
- package/dist/types/components/agent-thread/ui-message-stream.d.ts +3 -1
- package/dist/types/components/approval-card/approval-card.d.ts +31 -2
- package/dist/types/components/aurora/aurora.d.ts +31 -5
- package/dist/types/components/calendar/calendar.d.ts +39 -26
- package/dist/types/components/chart/chart.d.ts +250 -20
- package/dist/types/components/chart/color.d.ts +66 -0
- package/dist/types/components/chart/svg-adapter.d.ts +103 -0
- package/dist/types/components/chart/svg-geometry.d.ts +203 -0
- package/dist/types/components/check-button/check-button.d.ts +1 -4
- package/dist/types/components/checklist/checklist.d.ts +19 -5
- package/dist/types/components/code-editor/code-editor.d.ts +55 -1
- package/dist/types/components/composer/composer.d.ts +41 -6
- package/dist/types/components/context-menu/context-menu.d.ts +36 -8
- package/dist/types/components/copy/copy-button.d.ts +6 -0
- package/dist/types/components/copy/copy-input.d.ts +1 -0
- package/dist/types/components/date-picker/date-picker.d.ts +14 -0
- package/dist/types/components/date-picker/time-picker.d.ts +26 -17
- package/dist/types/components/datebox/datebox.d.ts +8 -4
- package/dist/types/components/dialog/dialog.d.ts +13 -2
- package/dist/types/components/empty-state/empty-state.d.ts +10 -1
- package/dist/types/components/field/field.d.ts +4 -2
- package/dist/types/components/form/form.d.ts +2 -1
- package/dist/types/components/kanban-view/kanban-card.d.ts +7 -0
- package/dist/types/components/kanban-view/kanban-view.d.ts +15 -3
- package/dist/types/components/launcher/launcher.d.ts +26 -0
- package/dist/types/components/master-panel/master-panel.d.ts +9 -4
- package/dist/types/components/menu-button/menu-button.d.ts +29 -5
- package/dist/types/components/message/message.d.ts +308 -5
- package/dist/types/components/modal/modal.d.ts +11 -0
- package/dist/types/components/modal/native-dialog.d.ts +40 -0
- package/dist/types/components/module-bar/module-bar.d.ts +9 -2
- package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +5 -4
- package/dist/types/components/number-field/number-field.d.ts +7 -0
- package/dist/types/components/pagination/pagination.d.ts +341 -19
- package/dist/types/components/run-status/run-status.d.ts +26 -0
- package/dist/types/components/run-trace/run-trace.d.ts +10 -6
- package/dist/types/components/search/search.d.ts +16 -4
- package/dist/types/components/select/select.d.ts +19 -1
- package/dist/types/components/sheet/sheet.d.ts +18 -4
- package/dist/types/components/slider/slider.d.ts +2 -1
- package/dist/types/components/stat-tile/stat-tile.d.ts +20 -3
- package/dist/types/components/stepper/stepper.d.ts +17 -4
- package/dist/types/components/surface/catalog.d.ts +61 -17
- package/dist/types/components/surface/surface.d.ts +6 -4
- package/dist/types/components/table/table.d.ts +207 -5
- package/dist/types/components/table/window.d.ts +25 -1
- package/dist/types/components/toggle/toggle.d.ts +38 -6
- package/dist/types/components/tooltip/tooltip.d.ts +5 -4
- package/dist/types/components/tree/tree.d.ts +43 -6
- package/dist/types/components/truncate/truncate.d.ts +4 -2
- package/dist/types/components/value-list/value-list.d.ts +9 -2
- package/dist/types/core/date.d.ts +2 -1
- package/dist/types/core/drag-axis.d.ts +10 -5
- package/dist/types/core/export.d.ts +2 -2
- package/dist/types/core/format.d.ts +3 -1
- package/dist/types/core/icons.d.ts +36 -3
- package/dist/types/core/keyboard.d.ts +7 -3
- package/dist/types/core/messages.d.ts +3 -0
- package/dist/types/core/storage.d.ts +4 -3
- package/dist/types/core/util.d.ts +3 -1
- package/dist/types/elements/define.d.ts +5 -2
- package/dist/types/index.d.ts +6 -4
- package/dist/types/internal/agent-model.d.ts +99 -0
- package/dist/types/internal/app-rail.d.ts +37 -2
- package/dist/types/internal/collections.d.ts +18 -0
- package/dist/types/internal/menu-items.d.ts +27 -0
- package/dist/types/internal/overlay-content.d.ts +23 -0
- package/dist/types/internal/presence-loop.d.ts +5 -2
- package/dist/types/locales/index.d.ts +3 -0
- package/dist/types/zeyos/calendar.d.ts +43 -7
- package/dist/types/zeyos/connect.d.ts +4 -0
- package/dist/types/zeyos/form.d.ts +13 -5
- package/dist/types/zeyos/select.d.ts +5 -2
- package/dist/types/zeyos/table.d.ts +16 -8
- package/dist/types/zeyos/view.d.ts +2 -1
- package/dist/zx-zeyos.esm.js +2998 -451
- package/dist/zx-zeyos.esm.min.js +4 -4
- package/dist/zx.core.css +4 -0
- package/dist/zx.core.min.css +1 -1
- package/dist/zx.css +948 -48
- package/dist/zx.esm.js +7432 -3408
- package/dist/zx.esm.min.js +26 -26
- package/dist/zx.global.js +7432 -3408
- package/dist/zx.global.min.js +26 -26
- package/dist/zx.layered.css +950 -48
- package/dist/zx.layered.min.css +1 -1
- package/dist/zx.min.css +1 -1
- package/docs/agent-catalog.json +159 -1
- package/docs/agent-surfaces.md +21 -21
- package/docs/api.json +3122 -528
- package/docs/components/account-menu.md +24 -0
- package/docs/components/activity-item.md +23 -0
- package/docs/components/activity-list.md +28 -0
- package/docs/components/agent-avatar.md +59 -0
- package/docs/components/agent-thread.md +275 -0
- package/docs/components/app-icon.md +36 -0
- package/docs/components/app-sidebar.md +92 -0
- package/docs/components/approval-card.md +71 -0
- package/docs/components/aurora.md +34 -0
- package/docs/components/avatar.md +37 -0
- package/docs/components/badge.md +36 -0
- package/docs/components/block-view.md +34 -0
- package/docs/components/breadcrumb.md +20 -0
- package/docs/components/button.md +23 -0
- package/docs/components/calendar.md +68 -0
- package/docs/components/card-view.md +73 -0
- package/docs/components/card.md +25 -0
- package/docs/components/chart.md +109 -0
- package/docs/components/check-button.md +16 -0
- package/docs/components/checklist.md +19 -0
- package/docs/components/code-editor.md +38 -0
- package/docs/components/composer.md +107 -0
- package/docs/components/context-menu.md +32 -0
- package/docs/components/copy.md +37 -0
- package/docs/components/data-filter.md +16 -0
- package/docs/components/date-picker.md +31 -0
- package/docs/components/date-range.md +21 -0
- package/docs/components/datebox.md +31 -0
- package/docs/components/dialog.md +25 -0
- package/docs/components/dock.md +57 -0
- package/docs/components/dropdown.md +39 -0
- package/docs/components/elements.md +63 -0
- package/docs/components/empty-state.md +17 -0
- package/docs/components/entity-ref.md +26 -0
- package/docs/components/field-upload.md +18 -0
- package/docs/components/file-item.md +27 -0
- package/docs/components/file-list.md +23 -0
- package/docs/components/filter-panel.md +45 -0
- package/docs/components/filter.md +47 -0
- package/docs/components/finder.md +25 -0
- package/docs/components/form-widgets.md +42 -0
- package/docs/components/form.md +80 -0
- package/docs/components/grid.md +26 -0
- package/docs/components/groupbox.md +11 -0
- package/docs/components/helpers.md +359 -0
- package/docs/components/icons.md +87 -0
- package/docs/components/index.md +99 -0
- package/docs/components/kanban-view.md +42 -0
- package/docs/components/kbd.md +23 -0
- package/docs/components/kernel.md +41 -0
- package/docs/components/launcher.md +66 -0
- package/docs/components/layout.md +33 -0
- package/docs/components/list-toolbar.md +38 -0
- package/docs/components/loading.md +48 -0
- package/docs/components/menu-button.md +47 -0
- package/docs/components/message.md +76 -0
- package/docs/components/modal.md +27 -0
- package/docs/components/module-bar.md +71 -0
- package/docs/components/multi-value-editor.md +16 -0
- package/docs/components/navigation-bar.md +22 -0
- package/docs/components/number-field.md +34 -0
- package/docs/components/pagination.md +73 -0
- package/docs/components/panel.md +28 -0
- package/docs/components/prompt-starters.md +40 -0
- package/docs/components/prose.md +38 -0
- package/docs/components/questionnaire.md +115 -0
- package/docs/components/rating.md +19 -0
- package/docs/components/run-status.md +50 -0
- package/docs/components/run-trace.md +72 -0
- package/docs/components/search.md +11 -0
- package/docs/components/select.md +129 -0
- package/docs/components/sheet-stack.md +39 -0
- package/docs/components/sheet.md +77 -0
- package/docs/components/skeleton.md +27 -0
- package/docs/components/slider.md +29 -0
- package/docs/components/sort-control.md +21 -0
- package/docs/components/source-list.md +30 -0
- package/docs/components/split-view.md +12 -0
- package/docs/components/stat-tile.md +49 -0
- package/docs/components/stepper.md +27 -0
- package/docs/components/surface.md +152 -0
- package/docs/components/tabbox.md +33 -0
- package/docs/components/table-view.md +43 -0
- package/docs/components/table.md +232 -0
- package/docs/components/tag-picker.md +39 -0
- package/docs/components/timebox.md +16 -0
- package/docs/components/toggle.md +21 -0
- package/docs/components/tokens.md +82 -0
- package/docs/components/toolbar.md +26 -0
- package/docs/components/tooltip.md +16 -0
- package/docs/components/tree.md +48 -0
- package/docs/components/truncate.md +21 -0
- package/docs/components/value-list.md +14 -0
- package/docs/components/view-settings.md +56 -0
- package/docs/components/workspace-switcher.md +42 -0
- package/docs/components/zeyos.md +196 -0
- package/docs/llms-small.txt +299 -0
- package/docs/llms.md +697 -100
- package/docs/llms.txt +46 -19
- package/package.json +9 -4
- package/src/components/activity-item/activity-item.js +21 -2
- package/src/components/agent-avatar/agent-avatar.css +195 -0
- package/src/components/agent-avatar/agent-avatar.js +333 -0
- package/src/components/agent-avatar/agent-face.js +292 -0
- package/src/components/agent-thread/ag-ui.js +44 -11
- package/src/components/agent-thread/agent-thread.js +103 -11
- package/src/components/agent-thread/ui-message-stream.js +3 -1
- package/src/components/app-rail/app-rail.css +5 -0
- package/src/components/app-sidebar/app-sidebar.css +3 -0
- package/src/components/app-sidebar/app-sidebar.js +4 -3
- package/src/components/approval-card/approval-card.css +6 -0
- package/src/components/approval-card/approval-card.js +55 -7
- package/src/components/aurora/aurora.css +149 -14
- package/src/components/aurora/aurora.js +49 -6
- package/src/components/calendar/calendar.css +6 -2
- package/src/components/calendar/calendar.js +127 -47
- package/src/components/card-view/card-view.js +5 -6
- package/src/components/chart/chart.css +159 -1
- package/src/components/chart/chart.js +450 -62
- package/src/components/chart/color.js +297 -0
- package/src/components/chart/svg-adapter.js +576 -0
- package/src/components/chart/svg-geometry.js +323 -0
- package/src/components/check-button/check-button.js +3 -18
- package/src/components/checklist/checklist.js +46 -17
- package/src/components/checklist/field-adapter.js +4 -1
- package/src/components/code-editor/code-editor.css +33 -0
- package/src/components/code-editor/code-editor.js +97 -8
- package/src/components/code-editor/field-adapter.js +3 -0
- package/src/components/composer/composer.css +3 -0
- package/src/components/composer/composer.js +100 -22
- package/src/components/context-menu/context-menu.js +41 -5
- package/src/components/copy/copy-button.js +9 -1
- package/src/components/copy/copy-input.js +5 -0
- package/src/components/data-filter/filter-core.js +0 -1
- package/src/components/date-picker/date-picker.css +8 -0
- package/src/components/date-picker/date-picker.js +47 -8
- package/src/components/date-picker/date-range-picker.js +1 -1
- package/src/components/date-picker/month-picker.js +19 -3
- package/src/components/date-picker/time-picker.js +54 -19
- package/src/components/datebox/date-range-box.js +7 -3
- package/src/components/datebox/datebox.js +32 -6
- package/src/components/dialog/dialog.css +6 -0
- package/src/components/dialog/dialog.js +22 -30
- package/src/components/dropdown/dropdown.js +1 -18
- package/src/components/empty-state/empty-state.js +21 -2
- package/src/components/field/field.js +19 -3
- package/src/components/fieldset/fieldset.js +3 -1
- package/src/components/filter/filter.js +9 -0
- package/src/components/form/form.js +19 -2
- package/src/components/kanban-view/kanban-card.js +15 -2
- package/src/components/kanban-view/kanban-view.css +21 -0
- package/src/components/kanban-view/kanban-view.js +29 -16
- package/src/components/launcher/launcher.css +14 -0
- package/src/components/launcher/launcher.js +54 -9
- package/src/components/master-panel/master-panel.js +24 -22
- package/src/components/menu-button/menu-button.js +26 -4
- package/src/components/message/message.css +228 -29
- package/src/components/message/message.js +664 -30
- package/src/components/modal/modal.js +70 -25
- package/src/components/modal/native-dialog.js +91 -0
- package/src/components/module-bar/module-bar.css +3 -0
- package/src/components/module-bar/module-bar.js +17 -4
- package/src/components/multi-value-editor/multi-value-editor.css +7 -2
- package/src/components/multi-value-editor/multi-value-editor.js +3 -2
- package/src/components/navigation-bar/navigation-bar.js +13 -1
- package/src/components/number-field/field-adapter.js +3 -0
- package/src/components/number-field/number-field.js +2 -1
- package/src/components/pagination/pagination.css +26 -2
- package/src/components/pagination/pagination.js +551 -65
- package/src/components/prose/prose.js +7 -1
- package/src/components/rating/field-adapter.js +3 -0
- package/src/components/run-status/run-status.js +43 -3
- package/src/components/run-trace/run-trace.js +15 -7
- package/src/components/search/search.js +3 -18
- package/src/components/select/field-adapter.js +8 -1
- package/src/components/select/select.js +68 -13
- package/src/components/sheet/sheet.js +27 -8
- package/src/components/slider/field-adapter.js +3 -0
- package/src/components/slider/slider.js +4 -6
- package/src/components/stat-tile/stat-tile.js +24 -9
- package/src/components/stepper/stepper.css +15 -0
- package/src/components/stepper/stepper.js +34 -2
- package/src/components/surface/catalog.js +185 -28
- package/src/components/surface/surface.js +10 -5
- package/src/components/tabbox/tabbox.js +13 -1
- package/src/components/table/table.css +160 -2
- package/src/components/table/table.js +479 -52
- package/src/components/table/window.js +46 -4
- package/src/components/table-view/table-view.js +1 -10
- package/src/components/tag-picker/field-adapter.js +3 -0
- package/src/components/tag-picker/tag-picker.js +2 -0
- package/src/components/timebox/field-adapter.js +3 -0
- package/src/components/toggle/toggle.js +51 -27
- package/src/components/tooltip/tooltip.js +21 -14
- package/src/components/tree/tree.js +87 -14
- package/src/components/truncate/truncate.js +21 -5
- package/src/components/value-list/value-list.js +37 -9
- package/src/components/view-settings/view-settings.js +1 -5
- package/src/core/component.js +34 -2
- package/src/core/date.js +5 -4
- package/src/core/drag-axis.js +24 -7
- package/src/core/export.js +4 -4
- package/src/core/fontawesome.js +34 -3
- package/src/core/format.js +3 -1
- package/src/core/http.js +23 -11
- package/src/core/icons.js +51 -10
- package/src/core/keyboard.js +83 -9
- package/src/core/messages.js +3 -0
- package/src/core/position.js +2 -2
- package/src/core/storage.js +80 -31
- package/src/core/util.js +16 -5
- package/src/elements/define.js +82 -47
- package/src/elements/kit.js +46 -35
- package/src/index.js +8 -4
- package/src/internal/agent-model.js +152 -0
- package/src/internal/app-rail.js +53 -2
- package/src/internal/collections.js +25 -0
- package/src/internal/menu-items.js +59 -0
- package/src/internal/overlay-content.js +35 -0
- package/src/internal/presence-loop.js +61 -14
- package/src/locales/de.js +3 -0
- package/src/zeyos/calendar.js +81 -19
- package/src/zeyos/connect.js +5 -1
- package/src/zeyos/form.js +29 -10
- package/src/zeyos/select.js +36 -12
- package/src/zeyos/table.js +43 -11
- package/src/zeyos/view.js +2 -1
- package/styles/tokens/semantic.css +7 -1
- package/styles/zx.css +1 -0
|
@@ -2,6 +2,7 @@ import { Component } from '../../core/component.js';
|
|
|
2
2
|
import { h } from '../../core/dom.js';
|
|
3
3
|
import { ICON_SIZE, icon } from '../../core/icons.js';
|
|
4
4
|
import { printf } from '../../core/i18n.js';
|
|
5
|
+
import { rovingTabindex } from '../../core/keyboard.js';
|
|
5
6
|
import { uid } from '../../core/util.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -18,8 +19,9 @@ import { uid } from '../../core/util.js';
|
|
|
18
19
|
*/
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
|
-
* Tag/chip editor. It uses the APG listbox/option focus model:
|
|
22
|
-
* move focus,
|
|
22
|
+
* Tag/chip editor. It uses the APG listbox/option focus model: the list is one tab stop (a roving
|
|
23
|
+
* tabindex), each chip is an option, arrow keys move focus, Home/End go to the first and last
|
|
24
|
+
* chip, Ctrl+Left/Right reorders, and Delete/Backspace removes the focused option.
|
|
23
25
|
* @fires ValueList#change
|
|
24
26
|
* @fires ValueList#add
|
|
25
27
|
* @fires ValueList#remove
|
|
@@ -43,6 +45,7 @@ export class ValueList extends Component {
|
|
|
43
45
|
const root = /** @type {HTMLElement} */ (this.el ?? h('div'));
|
|
44
46
|
this._ownedNodes = [];
|
|
45
47
|
this._disabled = false;
|
|
48
|
+
this._roving = null;
|
|
46
49
|
this._dragIndex = -1;
|
|
47
50
|
this._initialState = root.getAttribute('data-state');
|
|
48
51
|
this._initialDisabled = root.getAttribute('data-disabled');
|
|
@@ -87,6 +90,7 @@ export class ValueList extends Component {
|
|
|
87
90
|
if (event.target === root && !this._disabled) this.focus();
|
|
88
91
|
});
|
|
89
92
|
this._renderChips();
|
|
93
|
+
this._syncRoving();
|
|
90
94
|
return root;
|
|
91
95
|
}
|
|
92
96
|
|
|
@@ -176,6 +180,7 @@ export class ValueList extends Component {
|
|
|
176
180
|
this._input.disabled = false;
|
|
177
181
|
this.el.dataset.disabled = 'false';
|
|
178
182
|
this._renderChips();
|
|
183
|
+
this._syncRoving();
|
|
179
184
|
return this;
|
|
180
185
|
}
|
|
181
186
|
|
|
@@ -187,16 +192,33 @@ export class ValueList extends Component {
|
|
|
187
192
|
this._disabled = true;
|
|
188
193
|
this._input.disabled = true;
|
|
189
194
|
this.el.dataset.disabled = 'true';
|
|
195
|
+
this._syncRoving();
|
|
190
196
|
this._renderChips();
|
|
191
197
|
return this;
|
|
192
198
|
}
|
|
193
199
|
|
|
200
|
+
/**
|
|
201
|
+
* Keeps the chips one tab stop while the list is editable; a disabled list keeps none.
|
|
202
|
+
* @returns {void}
|
|
203
|
+
*/
|
|
204
|
+
_syncRoving() {
|
|
205
|
+
if (this._disabled) {
|
|
206
|
+
this._roving?.destroy();
|
|
207
|
+
this._roving = null;
|
|
208
|
+
} else {
|
|
209
|
+
this._roving ??= rovingTabindex(this._list, '.zx-value-list__chip', { orientation: 'horizontal', wrap: false });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
194
213
|
/** @returns {void} */
|
|
195
214
|
_renderChips(focusIndex = -1) {
|
|
215
|
+
// The chip that held the tab stop keeps it across a redraw, unless focus moves to another.
|
|
216
|
+
const previous = [...this._list.children].findIndex((chip) => /** @type {HTMLElement} */ (chip).tabIndex === 0);
|
|
217
|
+
const tabStop = Math.min(focusIndex >= 0 ? focusIndex : Math.max(0, previous), this._values.length - 1);
|
|
196
218
|
const chips = this._values.map((value, index) => h('li', {
|
|
197
219
|
class: 'zx-value-list__chip',
|
|
198
220
|
role: 'option',
|
|
199
|
-
tabIndex: this._disabled ?
|
|
221
|
+
tabIndex: !this._disabled && index === tabStop ? 0 : -1,
|
|
200
222
|
draggable: Boolean(this.options.sortable) && !this._disabled,
|
|
201
223
|
ariaSelected: 'false',
|
|
202
224
|
ariaDisabled: String(this._disabled),
|
|
@@ -237,12 +259,16 @@ export class ValueList extends Component {
|
|
|
237
259
|
}
|
|
238
260
|
const horizontal = event.key === 'ArrowLeft' ? -1 : event.key === 'ArrowRight' ? 1 : 0;
|
|
239
261
|
const vertical = event.key === 'ArrowUp' ? -1 : event.key === 'ArrowDown' ? 1 : 0;
|
|
240
|
-
const
|
|
241
|
-
if (
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
else
|
|
262
|
+
const next = Math.max(0, Math.min(this._values.length - 1, index + (horizontal || vertical)));
|
|
263
|
+
if (event.ctrlKey && horizontal && this.options.sortable) {
|
|
264
|
+
event.preventDefault();
|
|
265
|
+
// Redrawn under the key: the roving group finds the event's chip gone and leaves it alone.
|
|
266
|
+
this._move(index, next, true);
|
|
267
|
+
} else if (vertical) {
|
|
268
|
+
// Left, Right, Home, and End are the roving group's; Up and Down step the same way.
|
|
269
|
+
event.preventDefault();
|
|
270
|
+
this._list.querySelector(`[data-index="${next}"]`)?.focus();
|
|
271
|
+
}
|
|
246
272
|
}
|
|
247
273
|
|
|
248
274
|
/** @param {MouseEvent} event @returns {void} */
|
|
@@ -321,6 +347,8 @@ export class ValueList extends Component {
|
|
|
321
347
|
|
|
322
348
|
/** @returns {void} */
|
|
323
349
|
destroy() {
|
|
350
|
+
this._roving?.destroy();
|
|
351
|
+
this._roving = null;
|
|
324
352
|
for (const node of this._ownedNodes ?? []) node.remove();
|
|
325
353
|
if (this._initialState === null) this.el.removeAttribute('data-state');
|
|
326
354
|
else this.el.setAttribute('data-state', this._initialState);
|
|
@@ -3,6 +3,7 @@ import { h, highlightMatch, restoreTarget, snapshotTarget } from '../../core/dom
|
|
|
3
3
|
import { printf } from '../../core/i18n.js';
|
|
4
4
|
import { icon } from '../../core/icons.js';
|
|
5
5
|
import { uid } from '../../core/util.js';
|
|
6
|
+
import { sameSet } from '../../internal/collections.js';
|
|
6
7
|
import { Search } from '../search/search.js';
|
|
7
8
|
import { Select } from '../select/select.js';
|
|
8
9
|
import { Toggle } from '../toggle/toggle.js';
|
|
@@ -1817,11 +1818,6 @@ function sameList(left, right) {
|
|
|
1817
1818
|
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
1818
1819
|
}
|
|
1819
1820
|
|
|
1820
|
-
/** @param {Set<string>} left @param {Set<string>} right @returns {boolean} */
|
|
1821
|
-
function sameSet(left, right) {
|
|
1822
|
-
return left.size === right.size && [...left].every((value) => right.has(value));
|
|
1823
|
-
}
|
|
1824
|
-
|
|
1825
1821
|
/** @param {ViewSettingsBoard|null} left @param {ViewSettingsBoard|null} right @returns {boolean} */
|
|
1826
1822
|
function sameBoard(left, right) {
|
|
1827
1823
|
if (!left || !right) return left === right;
|
package/src/core/component.js
CHANGED
|
@@ -320,15 +320,47 @@ function mergeOptions(constructor, options) {
|
|
|
320
320
|
messages = deepMerge(messages, defaults.msg);
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
-
|
|
323
|
+
/*
|
|
324
|
+
* An option passed as `undefined` is an option not passed: a wrapper that forwards
|
|
325
|
+
* `{ value: props.value }` means "whatever the default is" when the prop is unset, the way a
|
|
326
|
+
* destructuring default reads it. `null` is a value and still overrides.
|
|
327
|
+
*/
|
|
328
|
+
if (options && typeof options === 'object') {
|
|
329
|
+
// Object.assign's own key set — enumerable own properties, symbol keys included (Select's
|
|
330
|
+
// presets pass one) — so only the `undefined` values differ from a plain assignment.
|
|
331
|
+
/** @type {Record<PropertyKey, any>} */
|
|
332
|
+
const passed = Object.assign({}, options);
|
|
333
|
+
/** @type {Record<PropertyKey, any>} */
|
|
334
|
+
const merged = result;
|
|
335
|
+
for (const key of Reflect.ownKeys(passed)) {
|
|
336
|
+
if (passed[key] !== undefined) merged[key] = passed[key];
|
|
337
|
+
}
|
|
338
|
+
}
|
|
324
339
|
if (options?.msg && typeof options.msg === 'object') {
|
|
325
340
|
hasMessages = true;
|
|
326
|
-
messages = deepMerge(messages, options.msg);
|
|
341
|
+
messages = deepMerge(messages, withoutUndefined(options.msg));
|
|
327
342
|
}
|
|
328
343
|
if (hasMessages) result.msg = messages;
|
|
329
344
|
return result;
|
|
330
345
|
}
|
|
331
346
|
|
|
347
|
+
/**
|
|
348
|
+
* Copies a `msg` table without the entries that are `undefined`, at any depth, so that merging it
|
|
349
|
+
* over the declared defaults leaves those defaults in place. The table passed in is not changed.
|
|
350
|
+
* @param {Record<string, any>} table Message table, flat or keyed by language.
|
|
351
|
+
* @returns {Record<string, any>}
|
|
352
|
+
*/
|
|
353
|
+
function withoutUndefined(table) {
|
|
354
|
+
if (!isMessageTable(table)) return table;
|
|
355
|
+
/** @type {Record<string, any>} */
|
|
356
|
+
const result = {};
|
|
357
|
+
for (const [key, value] of Object.entries(table)) {
|
|
358
|
+
if (value === undefined) continue;
|
|
359
|
+
result[key] = isMessageTable(value) ? withoutUndefined(value) : value;
|
|
360
|
+
}
|
|
361
|
+
return result;
|
|
362
|
+
}
|
|
363
|
+
|
|
332
364
|
/**
|
|
333
365
|
* The `defaults` objects a class and its ancestors declare, base class first.
|
|
334
366
|
* @param {typeof Component} constructor
|
package/src/core/date.js
CHANGED
|
@@ -54,7 +54,8 @@ export function formatDate(date, fmt, options) {
|
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* Parses numeric date tokens from a string, returning null for mismatches or invalid dates.
|
|
57
|
-
* Unspecified fields default to 1970-01-01 00:00:00 local time.
|
|
57
|
+
* Unspecified fields default to 1970-01-01 00:00:00 local time. A time that the local clock skips
|
|
58
|
+
* at a daylight-saving change is accepted and moved forward, as `Date` does.
|
|
58
59
|
* @param {string} str Date text.
|
|
59
60
|
* @param {string} fmt Matching numeric format.
|
|
60
61
|
* @returns {Date|null}
|
|
@@ -94,6 +95,9 @@ export function parseDate(str, fmt) {
|
|
|
94
95
|
const hour = values['%H'] ?? 0;
|
|
95
96
|
const minute = values['%M'] ?? 0;
|
|
96
97
|
const second = values['%S'] ?? 0;
|
|
98
|
+
// The time is checked by range rather than read back: a wall-clock time inside a daylight-saving
|
|
99
|
+
// gap (02:30 on the night clocks jump to 03:00) is valid input, which Date moves forward.
|
|
100
|
+
if (hour > 23 || minute > 59 || second > 59) return null;
|
|
97
101
|
const parsed = new Date(0);
|
|
98
102
|
parsed.setHours(0, 0, 0, 0);
|
|
99
103
|
parsed.setFullYear(year, month, day);
|
|
@@ -105,9 +109,6 @@ export function parseDate(str, fmt) {
|
|
|
105
109
|
if (values['%m'] !== undefined && parsed.getMonth() !== month) return null;
|
|
106
110
|
if (values['%d'] !== undefined && parsed.getDate() !== day) return null;
|
|
107
111
|
if (values['%e'] !== undefined && parsed.getDate() !== day) return null;
|
|
108
|
-
if (values['%H'] !== undefined && parsed.getHours() !== hour) return null;
|
|
109
|
-
if (values['%M'] !== undefined && parsed.getMinutes() !== minute) return null;
|
|
110
|
-
if (values['%S'] !== undefined && parsed.getSeconds() !== second) return null;
|
|
111
112
|
return parsed;
|
|
112
113
|
}
|
|
113
114
|
|
package/src/core/drag-axis.js
CHANGED
|
@@ -13,11 +13,13 @@ export const STEP_LARGE = 64;
|
|
|
13
13
|
* drag begins. Return `false` to refuse it — the usual reason being that there is nothing to
|
|
14
14
|
* resize on either side of the handle.
|
|
15
15
|
* @property {(delta: number) => void} onMove Called at most once per frame with the signed pixel
|
|
16
|
-
* distance travelled along the axis since pointer-down.
|
|
16
|
+
* distance travelled along the axis since pointer-down. A horizontal distance is logical: positive
|
|
17
|
+
* towards the inline end, which is leftwards when the handle's computed `direction` is `rtl`.
|
|
17
18
|
* @property {(delta: number, moved: boolean) => void} [onEnd] Called once the pointer is released.
|
|
18
19
|
* `moved` is false for a press that never travelled, which is a click rather than a drag.
|
|
19
20
|
* @property {(direction: -1|1, large: boolean) => void} [onStep] Called for an arrow key along the
|
|
20
|
-
* axis. `large` is true while Shift is held.
|
|
21
|
+
* axis. `large` is true while Shift is held. `1` is ArrowDown, or towards the inline end:
|
|
22
|
+
* ArrowRight, and ArrowLeft under `rtl`, so the handle moves the way the arrow points.
|
|
21
23
|
* @property {(edge: 'min'|'max') => void} [onJump] Called for Home and End.
|
|
22
24
|
* @property {() => void} [onActivate] Called for Enter and Space, which components use for the
|
|
23
25
|
* collapse affordance a splitter is expected to offer.
|
|
@@ -41,7 +43,8 @@ export const STEP_LARGE = 64;
|
|
|
41
43
|
* sheet grows in the opposite direction depending on which edge it is attached to. What they do
|
|
42
44
|
* share is the fiddly part — pointer capture that survives the pointer leaving the handle, one
|
|
43
45
|
* write per frame however fast the pointer reports, telling a click apart from a zero-distance
|
|
44
|
-
* drag, and the WAI-ARIA keyboard map.
|
|
46
|
+
* drag, and the WAI-ARIA keyboard map. Its distances are logical, like the layouts it serves:
|
|
47
|
+
* under `dir="rtl"` a horizontal handle mirrors both the pointer and the arrow keys.
|
|
45
48
|
*
|
|
46
49
|
* @param {Element} handle Element the pointer grabs; also the keyboard target.
|
|
47
50
|
* @param {DragAxisOptions} options Axis and callbacks.
|
|
@@ -60,6 +63,8 @@ export function dragAxis(handle, options) {
|
|
|
60
63
|
let pointerId = null;
|
|
61
64
|
let startClient = 0;
|
|
62
65
|
let client = 0;
|
|
66
|
+
/** `-1` while a horizontal drag runs right to left, which turns physical distance into logical. */
|
|
67
|
+
let sign = 1;
|
|
63
68
|
let moved = false;
|
|
64
69
|
/** Handle of the frame a pending update is scheduled in; `0` if none. */
|
|
65
70
|
let frame = 0;
|
|
@@ -70,6 +75,16 @@ export function dragAxis(handle, options) {
|
|
|
70
75
|
/** @returns {boolean} */
|
|
71
76
|
const blocked = () => Boolean(options.disabled?.());
|
|
72
77
|
|
|
78
|
+
/** @returns {boolean} Whether a horizontal handle lays out right to left. */
|
|
79
|
+
const rightToLeft = () => {
|
|
80
|
+
if (vertical) return false;
|
|
81
|
+
try {
|
|
82
|
+
return globalThis.getComputedStyle?.(handle)?.direction === 'rtl';
|
|
83
|
+
} catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
73
88
|
/** @returns {void} */
|
|
74
89
|
const releasePointer = () => {
|
|
75
90
|
const id = pointerId;
|
|
@@ -108,6 +123,7 @@ export function dragAxis(handle, options) {
|
|
|
108
123
|
*/
|
|
109
124
|
dragging = true;
|
|
110
125
|
pointerId = pointer.pointerId;
|
|
126
|
+
sign = rightToLeft() ? -1 : 1;
|
|
111
127
|
startClient = axis(pointer);
|
|
112
128
|
client = startClient;
|
|
113
129
|
moved = false;
|
|
@@ -127,7 +143,7 @@ export function dragAxis(handle, options) {
|
|
|
127
143
|
if (frame !== 0) return;
|
|
128
144
|
frame = requestAnimationFrame(() => {
|
|
129
145
|
frame = 0;
|
|
130
|
-
if (dragging) options.onMove(client - startClient);
|
|
146
|
+
if (dragging) options.onMove(sign * (client - startClient));
|
|
131
147
|
});
|
|
132
148
|
}, { signal });
|
|
133
149
|
|
|
@@ -138,7 +154,7 @@ export function dragAxis(handle, options) {
|
|
|
138
154
|
cancelFrame();
|
|
139
155
|
client = axis(pointer);
|
|
140
156
|
const travelled = moved;
|
|
141
|
-
const delta = client - startClient;
|
|
157
|
+
const delta = sign * (client - startClient);
|
|
142
158
|
finish();
|
|
143
159
|
options.onEnd?.(delta, travelled);
|
|
144
160
|
};
|
|
@@ -159,8 +175,9 @@ export function dragAxis(handle, options) {
|
|
|
159
175
|
options.onJump(key.key === 'Home' ? 'min' : 'max');
|
|
160
176
|
return;
|
|
161
177
|
}
|
|
162
|
-
const
|
|
163
|
-
const
|
|
178
|
+
const reversed = rightToLeft();
|
|
179
|
+
const decrease = vertical ? 'ArrowUp' : reversed ? 'ArrowRight' : 'ArrowLeft';
|
|
180
|
+
const increase = vertical ? 'ArrowDown' : reversed ? 'ArrowLeft' : 'ArrowRight';
|
|
164
181
|
if (key.key !== decrease && key.key !== increase) return;
|
|
165
182
|
if (!options.onStep) return;
|
|
166
183
|
key.preventDefault();
|
package/src/core/export.js
CHANGED
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
* @property {string} [type='text/plain;charset=utf-8'] MIME type of the generated blob.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
const FORMULA_STARTERS = ['=', '+', '-', '@'];
|
|
21
|
+
/** Leading characters that can make a spreadsheet treat a text cell as a formula (OWASP list). */
|
|
22
|
+
const FORMULA_STARTERS = ['=', '+', '-', '@', '\t', '\r'];
|
|
23
23
|
/** Object URLs are revoked late so the browser has started the download before they disappear. */
|
|
24
24
|
const REVOKE_DELAY = 1000;
|
|
25
25
|
|
|
@@ -28,8 +28,8 @@ const REVOKE_DELAY = 1000;
|
|
|
28
28
|
*
|
|
29
29
|
* Fields containing the delimiter, a double quote, CR, or LF are quoted with inner quotes doubled.
|
|
30
30
|
* Dates become ISO strings, null and undefined become empty fields, and text that starts with
|
|
31
|
-
* `=`, `+`, `-`, or
|
|
32
|
-
* formula. Numbers are never prefixed, so negative amounts survive intact.
|
|
31
|
+
* `=`, `+`, `-`, `@`, a tab, or a carriage return is prefixed with a tab so spreadsheets treat it
|
|
32
|
+
* as text rather than a formula. Numbers are never prefixed, so negative amounts survive intact.
|
|
33
33
|
*
|
|
34
34
|
* @param {Iterable<any>|null|undefined} rows Row objects.
|
|
35
35
|
* @param {Array<string|CsvColumn>} columns Column ids, or descriptors with a label and accessor.
|
package/src/core/fontawesome.js
CHANGED
|
@@ -158,9 +158,16 @@ export function loadFontAwesomeKit(kit) {
|
|
|
158
158
|
const promise = /** @type {Promise<void>} */ (new Promise((resolve, reject) => {
|
|
159
159
|
const absolute = new URL(url, document.baseURI).href;
|
|
160
160
|
const existing = [...document.scripts].find((script) => script.src === absolute);
|
|
161
|
-
if (existing
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
if (existing) {
|
|
162
|
+
// A script element cannot be asked whether it has run, and one that already has never fires
|
|
163
|
+
// `load` again. What it leaves behind can: a hosted kit's config, the API a self-hosted
|
|
164
|
+
// build defines, or the finished fetch in resource timing. Without any of them it is still on
|
|
165
|
+
// its way, and its own `load` or `error` settles this. A finished document is no proof — a
|
|
166
|
+
// script inserted after it finished may still be loading.
|
|
167
|
+
if (scriptHasLoaded(absolute)) {
|
|
168
|
+
resolve();
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
164
171
|
}
|
|
165
172
|
|
|
166
173
|
const script = existing ?? document.createElement('script');
|
|
@@ -179,3 +186,27 @@ export function loadFontAwesomeKit(kit) {
|
|
|
179
186
|
kitLoads.set(url, promise);
|
|
180
187
|
return promise;
|
|
181
188
|
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Whether a script already on the page has visibly finished: Font Awesome's kit config or API is
|
|
192
|
+
* defined, or the browser recorded a successful load of that URL by a script element — not a
|
|
193
|
+
* `fetch()` or a preload, which say nothing about the script having run, and not a failed attempt,
|
|
194
|
+
* which a retry would otherwise be mistaken for.
|
|
195
|
+
* @param {string} url Absolute script URL.
|
|
196
|
+
* @returns {boolean}
|
|
197
|
+
*/
|
|
198
|
+
function scriptHasLoaded(url) {
|
|
199
|
+
if (globalThis.FontAwesomeKitConfig || globalThis.FontAwesome) return true;
|
|
200
|
+
try {
|
|
201
|
+
return globalThis.performance?.getEntriesByName?.(url, 'resource').some((entry) => {
|
|
202
|
+
const timing = /** @type {PerformanceResourceTiming & {responseStatus?: number}} */ (entry);
|
|
203
|
+
if (timing.initiatorType !== 'script' || !(timing.responseEnd > 0)) return false;
|
|
204
|
+
// The status where the browser reports one; otherwise a body that arrived.
|
|
205
|
+
return typeof timing.responseStatus === 'number' && timing.responseStatus > 0
|
|
206
|
+
? timing.responseStatus >= 200 && timing.responseStatus < 300
|
|
207
|
+
: timing.decodedBodySize > 0;
|
|
208
|
+
}) ?? false;
|
|
209
|
+
} catch {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
}
|
package/src/core/format.js
CHANGED
|
@@ -31,7 +31,9 @@ import { formattingLocale } from './i18n.js';
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* @typedef {Object} RelativeTimeFormatOptions
|
|
34
|
-
* @property {Date|number|string} [now=new Date()] Reference point the date is measured against
|
|
34
|
+
* @property {Date|number|string} [now=new Date()] Reference point the date is measured against: a
|
|
35
|
+
* Date, a Unix timestamp in seconds (not milliseconds — wrap `Date.now()` in a Date), or a date
|
|
36
|
+
* string, read the same way as the date itself.
|
|
35
37
|
* @property {string} [locale=getLanguage()] BCP 47 language tag.
|
|
36
38
|
* @property {'auto'|'always'} [numeric='auto'] `auto` produces "yesterday", `always` "1 day ago".
|
|
37
39
|
*/
|
package/src/core/http.js
CHANGED
|
@@ -79,24 +79,25 @@ export class Http {
|
|
|
79
79
|
const text = await response.text();
|
|
80
80
|
controller.signal.throwIfAborted();
|
|
81
81
|
let json = null;
|
|
82
|
+
let parseError = null;
|
|
82
83
|
if (text !== '') {
|
|
83
84
|
try {
|
|
84
85
|
json = JSON.parse(text);
|
|
85
86
|
} catch (cause) {
|
|
86
|
-
|
|
87
|
-
new Error('Invalid JSON response', { cause })
|
|
88
|
-
);
|
|
89
|
-
error.response = response;
|
|
90
|
-
throw error;
|
|
87
|
+
parseError = cause;
|
|
91
88
|
}
|
|
92
89
|
}
|
|
93
90
|
|
|
94
91
|
if (!response.ok) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
// A failed response is reported as the HTTP error it is: a gateway's HTML error page is
|
|
93
|
+
// not an invalid JSON response. Only a JSON body can carry a more specific legacy error.
|
|
94
|
+
if (parseError === null) {
|
|
95
|
+
try {
|
|
96
|
+
parseResult(json);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
/** @type {Error & {response?: Response}} */ (error).response = response;
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
100
101
|
}
|
|
101
102
|
const error = /** @type {Error & {response?: Response}} */ (
|
|
102
103
|
new Error(`HTTP ${response.status} ${response.statusText}`.trim())
|
|
@@ -104,6 +105,13 @@ export class Http {
|
|
|
104
105
|
error.response = response;
|
|
105
106
|
throw error;
|
|
106
107
|
}
|
|
108
|
+
if (parseError !== null) {
|
|
109
|
+
const error = /** @type {Error & {response?: Response}} */ (
|
|
110
|
+
new Error('Invalid JSON response', { cause: parseError })
|
|
111
|
+
);
|
|
112
|
+
error.response = response;
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
107
115
|
return parseResult(json);
|
|
108
116
|
} catch (caught) {
|
|
109
117
|
const error = caught instanceof Error ? caught : new Error(String(caught));
|
|
@@ -209,7 +217,11 @@ function appendQuery(url, query) {
|
|
|
209
217
|
encoded = parameters.toString();
|
|
210
218
|
}
|
|
211
219
|
if (!encoded) return url;
|
|
212
|
-
|
|
220
|
+
// Parameters belong to the query, which ends where a fragment begins.
|
|
221
|
+
const hash = url.indexOf('#');
|
|
222
|
+
const target = hash < 0 ? url : url.slice(0, hash);
|
|
223
|
+
const fragment = hash < 0 ? '' : url.slice(hash);
|
|
224
|
+
return target + (target.includes('?') ? '&' : '?') + encoded + fragment;
|
|
213
225
|
}
|
|
214
226
|
|
|
215
227
|
/** @param {URLSearchParams} parameters @param {string} key @param {unknown} value @returns {void} */
|
package/src/core/icons.js
CHANGED
|
@@ -148,7 +148,7 @@ const outline = (path) => [VIEW_BOX, path, 'stroke'];
|
|
|
148
148
|
* The bundled glyph set: outline icons from Lucide (ISC; see the notice above), embedded as path
|
|
149
149
|
* data so the library carries no webfont, stylesheet, or package dependency. Every entry is
|
|
150
150
|
* `[viewBox, path, 'stroke']` in a 24-unit view box. Extend the set with `registerIcons()`; read
|
|
151
|
-
* every available name with `iconNames()`.
|
|
151
|
+
* every available name with `iconNames()`, and the other names a glyph answers to in `iconAliases`.
|
|
152
152
|
* @type {Readonly<Record<string, IconGlyph>>}
|
|
153
153
|
*/
|
|
154
154
|
export const icons = Object.freeze({
|
|
@@ -209,11 +209,27 @@ export const icons = Object.freeze({
|
|
|
209
209
|
});
|
|
210
210
|
|
|
211
211
|
/**
|
|
212
|
-
* Other names for bundled glyphs
|
|
213
|
-
* (`archive`, `edit`) that are still the ones most code reaches for.
|
|
214
|
-
*
|
|
212
|
+
* Other names for bundled glyphs, as `alias → bundled name`: legacy gx Factory names, and the
|
|
213
|
+
* older Font Awesome names (`archive`, `edit`) that are still the ones most code reaches for.
|
|
214
|
+
*
|
|
215
|
+
* | Alias | Renders |
|
|
216
|
+
* | --- | --- |
|
|
217
|
+
* | `archive` | `box-archive` |
|
|
218
|
+
* | `edit` | `pen-to-square` |
|
|
219
|
+
* | `settings` | `gear` |
|
|
220
|
+
* | `clear` | `x` |
|
|
221
|
+
* | `checked` | `check` |
|
|
222
|
+
* | `question` | `info` |
|
|
223
|
+
* | `range` | `filter` |
|
|
224
|
+
* | `fields` | `list` |
|
|
225
|
+
* | `grid` | `table-cells-large` |
|
|
226
|
+
*
|
|
227
|
+
* `icon()` accepts an alias wherever it accepts the bundled name, under either renderer, and
|
|
228
|
+
* `iconNames()` lists them. A glyph an application registered under the alias itself takes
|
|
229
|
+
* precedence (see `icon()`); the table is frozen, so that registration is how an alias is changed.
|
|
230
|
+
* @type {Readonly<Record<string, string>>}
|
|
215
231
|
*/
|
|
216
|
-
const
|
|
232
|
+
export const iconAliases = Object.freeze({
|
|
217
233
|
archive: 'box-archive',
|
|
218
234
|
edit: 'pen-to-square',
|
|
219
235
|
settings: 'gear',
|
|
@@ -331,18 +347,43 @@ export function registerIcons(glyphs) {
|
|
|
331
347
|
}
|
|
332
348
|
|
|
333
349
|
/**
|
|
334
|
-
* Lists every inline SVG glyph
|
|
350
|
+
* Lists every name `icon()` renders as an inline SVG glyph: the bundled set, the glyphs added with
|
|
351
|
+
* `registerIcons()`, and the aliases in `iconAliases`. The two agree — a name listed here renders
|
|
352
|
+
* a glyph, and a bare name that is not listed renders the placeholder (or throws with
|
|
353
|
+
* `{ strict: true }`). Font Awesome is not part of the answer: it resolves names in the browser,
|
|
354
|
+
* so under that renderer any name may draw.
|
|
355
|
+
*
|
|
356
|
+
* An alias is listed beside the glyph it draws, so the list holds more names than glyphs. For one
|
|
357
|
+
* entry per glyph — an icon gallery — leave the aliases out:
|
|
358
|
+
*
|
|
359
|
+
* iconNames().filter((name) => !Object.hasOwn(iconAliases, name));
|
|
335
360
|
* @returns {string[]} Sorted icon names.
|
|
336
361
|
*/
|
|
337
362
|
export function iconNames() {
|
|
338
|
-
return [...new Set([
|
|
363
|
+
return [...new Set([
|
|
364
|
+
...Object.keys(icons), ...Object.keys(extraGlyphs), ...Object.keys(iconAliases)
|
|
365
|
+
])].sort();
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Resolves a bare icon name to the glyph name it is drawn from: a registered glyph keeps its own
|
|
370
|
+
* name, an alias resolves to its bundled glyph, and anything else is returned unchanged. Own
|
|
371
|
+
* properties only, so a name such as `constructor` is an unknown icon and nothing else.
|
|
372
|
+
* @param {string} name Bare icon name.
|
|
373
|
+
* @returns {string}
|
|
374
|
+
*/
|
|
375
|
+
function resolveIconName(name) {
|
|
376
|
+
if (Object.hasOwn(extraGlyphs, name)) return name;
|
|
377
|
+
return Object.hasOwn(iconAliases, name) ? iconAliases[name] : name;
|
|
339
378
|
}
|
|
340
379
|
|
|
341
380
|
/**
|
|
342
381
|
* Creates an icon element.
|
|
343
382
|
*
|
|
344
383
|
* Bare names (`'check'`) render through the active provider: the bundled inline SVG set by
|
|
345
|
-
* default, or Font Awesome after `useFontAwesome()` / `loadFontAwesome()`. A name
|
|
384
|
+
* default, or Font Awesome after `useFontAwesome()` / `loadFontAwesome()`. A bare name may be an
|
|
385
|
+
* alias from `iconAliases` (`'edit'` draws `pen-to-square`, `'settings'` draws `gear`); a glyph
|
|
386
|
+
* registered under the alias name wins over the alias. A name can also select
|
|
346
387
|
* its renderer itself — `'fa:user'`, `'duotone:user'`, `'kit:zeyos-notes'`, `'builtin:check'`, or
|
|
347
388
|
* a literal Font Awesome class list such as `'fa-solid fa-user'`.
|
|
348
389
|
*
|
|
@@ -363,7 +404,7 @@ export function icon(name, options = {}) {
|
|
|
363
404
|
if (spec.classes) return faIcon(spec.classes, options);
|
|
364
405
|
|
|
365
406
|
// An application that registered a glyph under an alias name keeps its own glyph.
|
|
366
|
-
const resolved =
|
|
407
|
+
const resolved = resolveIconName(spec.name);
|
|
367
408
|
if (spec.provider === 'builtin') return builtinIcon(resolved, options);
|
|
368
409
|
if (spec.provider === 'fa') {
|
|
369
410
|
return faIcon(faIconClasses(resolved, {
|
|
@@ -392,7 +433,7 @@ export function icon(name, options = {}) {
|
|
|
392
433
|
* @throws {RangeError} With `options.strict`, when no glyph carries that name.
|
|
393
434
|
*/
|
|
394
435
|
function builtinIcon(name, options) {
|
|
395
|
-
const entry = extraGlyphs[name] ?? icons[name];
|
|
436
|
+
const entry = extraGlyphs[name] ?? (Object.hasOwn(icons, name) ? icons[name] : undefined);
|
|
396
437
|
if (!entry) {
|
|
397
438
|
if (options.strict) throw new RangeError(`Unknown icon: ${name}`);
|
|
398
439
|
warnMissingIcon(name);
|