@zeyos/zx 5.6.0 → 5.7.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 +154 -0
- package/README.md +73 -7
- package/bin/zx-css.js +328 -0
- package/dist/types/components/account-menu/account-menu.d.ts +4 -2
- package/dist/types/components/activity-list/activity-list.d.ts +14 -8
- package/dist/types/components/agent-thread/ag-ui.d.ts +340 -0
- package/dist/types/components/agent-thread/agent-thread.d.ts +142 -14
- package/dist/types/components/agent-thread/ui-message-stream.d.ts +401 -0
- package/dist/types/components/app-sidebar/app-sidebar.d.ts +14 -8
- package/dist/types/components/breadcrumb/breadcrumb.d.ts +3 -3
- package/dist/types/components/calendar/calendar-model.d.ts +9 -2
- package/dist/types/components/calendar/calendar.d.ts +12 -4
- package/dist/types/components/chart/chart.d.ts +25 -13
- package/dist/types/components/code-editor/code-editor.d.ts +7 -2
- package/dist/types/components/composer/composer.d.ts +206 -4
- package/dist/types/components/composer/queue.d.ts +76 -0
- package/dist/types/components/copy/copy-button.d.ts +6 -4
- package/dist/types/components/copy/copy-input.d.ts +10 -6
- package/dist/types/components/datebox/date-range-box.d.ts +33 -0
- package/dist/types/components/datebox/placeholder.d.ts +7 -0
- package/dist/types/components/dock/dock.d.ts +12 -3
- package/dist/types/components/entity-ref/entity-ref.d.ts +5 -3
- package/dist/types/components/field-upload/field-upload.d.ts +3 -2
- package/dist/types/components/file-item/file-item.d.ts +3 -2
- package/dist/types/components/file-list/file-list.d.ts +14 -8
- package/dist/types/components/filter/filter-model.d.ts +31 -1
- package/dist/types/components/filter/filter.d.ts +20 -2
- package/dist/types/components/finder/finder.d.ts +14 -6
- package/dist/types/components/flag/flag.d.ts +99 -0
- package/dist/types/components/grid/grid.d.ts +1 -1
- package/dist/types/components/kanban-view/kanban-view.d.ts +8 -66
- package/dist/types/components/launcher/launcher.d.ts +2 -0
- package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +3 -2
- package/dist/types/components/number-field/number-field.d.ts +17 -6
- package/dist/types/components/prompt-starters/prompt-starters.d.ts +107 -0
- package/dist/types/components/prose/prose.d.ts +9 -6
- package/dist/types/components/questionnaire/conditions.d.ts +270 -0
- package/dist/types/components/questionnaire/items.d.ts +52 -30
- package/dist/types/components/questionnaire/questionnaire.d.ts +44 -4
- package/dist/types/components/rating/rating.d.ts +5 -3
- package/dist/types/components/select/country.d.ts +106 -0
- package/dist/types/components/select/field-adapter.d.ts +2 -1
- package/dist/types/components/select/locale.d.ts +102 -0
- package/dist/types/components/select/select.d.ts +41 -2
- package/dist/types/components/slider/slider.d.ts +1 -0
- package/dist/types/components/sort-control/sort-control.d.ts +7 -3
- package/dist/types/components/source-list/source-list.d.ts +7 -5
- package/dist/types/components/split-view/split-view.d.ts +5 -3
- package/dist/types/components/surface/catalog.d.ts +260 -0
- package/dist/types/components/surface/elicit.d.ts +81 -0
- package/dist/types/components/surface/mcp.d.ts +165 -0
- package/dist/types/components/surface/schema.d.ts +314 -0
- package/dist/types/components/surface/stream.d.ts +118 -0
- package/dist/types/components/surface/surface.d.ts +718 -0
- package/dist/types/components/surface/text.d.ts +277 -0
- package/dist/types/components/surface/validate.d.ts +339 -0
- package/dist/types/components/table/table.d.ts +55 -3
- package/dist/types/components/table/window.d.ts +203 -0
- package/dist/types/components/toolbar/toolbar.d.ts +10 -6
- package/dist/types/components/tooltip/tooltip.d.ts +2 -2
- package/dist/types/components/tree/tree.d.ts +20 -13
- package/dist/types/core/component.d.ts +10 -0
- package/dist/types/core/date.d.ts +8 -1
- package/dist/types/core/dom.d.ts +1 -0
- package/dist/types/core/http.d.ts +10 -0
- package/dist/types/core/i18n.d.ts +38 -0
- package/dist/types/core/messages.d.ts +344 -1
- package/dist/types/core/storage.d.ts +7 -2
- package/dist/types/elements/define.d.ts +21 -46
- package/dist/types/elements/definitions.d.ts +147 -0
- package/dist/types/elements/kit.d.ts +7 -0
- package/dist/types/elements/reflect.d.ts +6 -3
- package/dist/types/index.d.ts +10 -1
- package/dist/types/internal/date-locale.d.ts +7 -0
- package/dist/types/internal/json-patch.d.ts +146 -0
- package/dist/types/locales/de.d.ts +13 -0
- package/dist/types/locales/en.d.ts +2 -0
- package/dist/types/locales/index.d.ts +823 -0
- package/dist/types/zeyos/view.d.ts +8 -1
- package/dist/zx-zeyos.esm.js +16802 -15180
- package/dist/zx-zeyos.esm.min.js +5 -5
- package/dist/zx.core.css +1276 -0
- package/dist/zx.core.min.css +1 -0
- package/dist/zx.css +498 -134
- package/dist/zx.esm.js +40778 -29654
- package/dist/zx.esm.min.js +36 -23
- package/dist/zx.global.js +40778 -29654
- package/dist/zx.global.min.js +36 -23
- package/dist/zx.layered.css +17302 -0
- package/dist/zx.layered.min.css +1 -0
- package/dist/zx.min.css +1 -1
- package/docs/agent-catalog.json +12501 -0
- package/docs/agent-surfaces.md +340 -0
- package/docs/api.json +851 -121
- package/docs/llms.md +1018 -71
- package/docs/llms.txt +30 -9
- package/package.json +29 -6
- package/src/components/account-menu/account-menu.js +6 -3
- package/src/components/activity-item/activity-item.js +2 -1
- package/src/components/activity-list/activity-list.js +16 -10
- package/src/components/agent-thread/ag-ui.js +1439 -0
- package/src/components/agent-thread/agent-thread.js +359 -54
- package/src/components/agent-thread/ui-message-stream.js +1281 -0
- package/src/components/app-sidebar/app-sidebar.js +18 -8
- package/src/components/approval-card/approval-card.js +3 -2
- package/src/components/block-view/block-view.js +7 -6
- package/src/components/breadcrumb/breadcrumb.js +8 -5
- package/src/components/calendar/calendar-model.js +8 -2
- package/src/components/calendar/calendar.js +53 -18
- package/src/components/chart/chart.js +54 -23
- package/src/components/code-editor/code-editor.js +45 -8
- package/src/components/code-editor/field-adapter.js +1 -1
- package/src/components/composer/composer.css +80 -1
- package/src/components/composer/composer.js +390 -16
- package/src/components/composer/queue.js +78 -0
- package/src/components/context-menu/context-menu.js +12 -1
- package/src/components/copy/copy-button.js +9 -7
- package/src/components/copy/copy-input.js +10 -6
- package/src/components/date-picker/date-picker.js +2 -1
- package/src/components/date-picker/date-range-picker.js +8 -7
- package/src/components/datebox/date-range-box.js +3 -9
- package/src/components/datebox/datebox.js +18 -21
- package/src/components/datebox/placeholder.js +18 -0
- package/src/components/dialog/dialog.js +1 -1
- package/src/components/dock/dock.js +34 -13
- package/src/components/entity-ref/entity-ref.js +16 -5
- package/src/components/field-upload/field-upload.js +81 -38
- package/src/components/file-item/file-item.js +70 -40
- package/src/components/file-list/file-list.js +15 -9
- package/src/components/filter/filter-model.js +46 -8
- package/src/components/filter/filter.css +3 -3
- package/src/components/filter/filter.js +29 -10
- package/src/components/filter-panel/filter-panel.js +13 -5
- package/src/components/finder/finder.js +50 -26
- package/src/components/flag/flag.css +40 -0
- package/src/components/flag/flag.js +177 -0
- package/src/components/form/form.js +1 -1
- package/src/components/grid/grid.js +22 -8
- package/src/components/kanban-view/kanban-view.js +51 -81
- package/src/components/launcher/launcher.js +17 -2
- package/src/components/list-toolbar/list-toolbar.js +2 -1
- package/src/components/master-panel/master-panel.js +1 -1
- package/src/components/menu-button/menu-button.js +4 -0
- package/src/components/message/message.js +3 -0
- package/src/components/multi-value-editor/multi-value-editor.js +10 -9
- package/src/components/navigation-bar/navigation-bar.js +3 -3
- package/src/components/number-field/number-field.js +29 -13
- package/src/components/prompt-starters/prompt-starters.css +91 -0
- package/src/components/prompt-starters/prompt-starters.js +206 -0
- package/src/components/prose/prose.js +14 -10
- package/src/components/questionnaire/conditions.js +666 -0
- package/src/components/questionnaire/items.js +150 -41
- package/src/components/questionnaire/questionnaire.js +126 -32
- package/src/components/rating/rating.js +5 -4
- package/src/components/run-status/run-status.js +2 -2
- package/src/components/select/country.js +136 -0
- package/src/components/select/field-adapter.js +7 -2
- package/src/components/select/locale.js +219 -0
- package/src/components/select/select.css +20 -22
- package/src/components/select/select.js +94 -12
- package/src/components/sheet/sheet-stack.js +10 -1
- package/src/components/slider/slider.js +7 -2
- package/src/components/sort-control/sort-control.js +15 -5
- package/src/components/source-list/source-list.js +7 -4
- package/src/components/split-view/split-view.js +5 -3
- package/src/components/surface/catalog.js +1334 -0
- package/src/components/surface/elicit.js +107 -0
- package/src/components/surface/mcp.js +243 -0
- package/src/components/surface/schema.js +644 -0
- package/src/components/surface/stream.js +245 -0
- package/src/components/surface/surface.css +308 -0
- package/src/components/surface/surface.js +2291 -0
- package/src/components/surface/text.js +513 -0
- package/src/components/surface/validate.js +2218 -0
- package/src/components/tabbox/tabbox.js +9 -0
- package/src/components/table/table.css +63 -3
- package/src/components/table/table.js +167 -28
- package/src/components/table/window.js +317 -0
- package/src/components/toolbar/toolbar.js +12 -7
- package/src/components/tooltip/tooltip.css +2 -3
- package/src/components/tooltip/tooltip.js +32 -5
- package/src/components/tree/tree.js +53 -23
- package/src/core/component.js +25 -1
- package/src/core/date.js +62 -16
- package/src/core/dom.js +22 -2
- package/src/core/format.js +15 -13
- package/src/core/http.js +29 -20
- package/src/core/i18n.js +83 -10
- package/src/core/keyboard.js +79 -8
- package/src/core/messages.js +376 -2
- package/src/core/overlay-host.js +1 -0
- package/src/core/storage.js +59 -6
- package/src/elements/define.js +178 -130
- package/src/elements/definitions.js +229 -0
- package/src/elements/kit.js +444 -0
- package/src/elements/reflect.js +8 -3
- package/src/index.js +10 -1
- package/src/internal/date-locale.js +11 -0
- package/src/internal/json-patch.js +405 -0
- package/src/locales/de.js +911 -0
- package/src/locales/en.js +2 -0
- package/src/locales/index.js +7 -0
- package/src/zeyos/calendar.js +2 -1
- package/src/zeyos/form.js +2 -1
- package/src/zeyos/launcher.js +7 -6
- package/src/zeyos/module-bar.js +2 -1
- package/src/zeyos/schema.js +37 -23
- package/src/zeyos/select.js +4 -3
- package/src/zeyos/table.js +2 -13
- package/src/zeyos/view.js +57 -17
- package/styles/core.css +11 -0
- package/styles/tokens/semantic.css +1 -0
- package/styles/zeyos.css +2 -0
- package/styles/zx.css +4 -8
- package/styles/zx.layered.css +1 -0
|
@@ -6,6 +6,9 @@ import { position } from '../../core/position.js';
|
|
|
6
6
|
import { uid } from '../../core/util.js';
|
|
7
7
|
import { itemColor } from './color.js';
|
|
8
8
|
import { matchItems } from './filter.js';
|
|
9
|
+
import { canonicalLocale, localeItems, localeSelectOptions } from './locale.js';
|
|
10
|
+
import { countryItems, countrySelectOptions } from './country.js';
|
|
11
|
+
import { normalizeRegion } from '../flag/flag.js';
|
|
9
12
|
import {
|
|
10
13
|
DEFAULT_STATUSES, STATUS_INDICATORS, STATUS_TONES, normalizePriorityLevel, priorityIcon, statusIcon
|
|
11
14
|
} from './glyphs.js';
|
|
@@ -50,7 +53,8 @@ import {
|
|
|
50
53
|
/**
|
|
51
54
|
* @typedef {Object} EntitySelectOptions
|
|
52
55
|
* @property {SelectItem[]} [recent=[]] Choices pinned above ordinary results.
|
|
53
|
-
* @property {string} [recentLabel
|
|
56
|
+
* @property {string|null} [recentLabel] Heading above recent choices, by default the `select.recent`
|
|
57
|
+
* message ("Recent"); null shows none.
|
|
54
58
|
* @property {boolean|SelectAction} [create=false] Optional create command at the bottom.
|
|
55
59
|
* @property {string|((item: SelectItem)=>unknown)} [iconKey='icon'] Item icon reader.
|
|
56
60
|
* @property {string|((item: SelectItem)=>unknown)} [colorKey='color'] Optional icon colour reader: a CSS
|
|
@@ -66,6 +70,9 @@ import {
|
|
|
66
70
|
/** @typedef {{item: SelectItem|null, clear: boolean, action: SelectAction|null, element: HTMLElement}} SelectOptionEntry */
|
|
67
71
|
/** @typedef {{silent?: boolean}} SelectSetOptions */
|
|
68
72
|
|
|
73
|
+
// Internal factory configuration; ordinary Select instances keep their IDs unchanged.
|
|
74
|
+
const NORMALIZE_VALUE = Symbol('normalizeSelectValue');
|
|
75
|
+
|
|
69
76
|
const PRIORITY_KEYS = [
|
|
70
77
|
'priority.lowest',
|
|
71
78
|
'priority.low',
|
|
@@ -120,6 +127,8 @@ export class Select extends Component {
|
|
|
120
127
|
// Instance state initialized here because render() runs inside the base
|
|
121
128
|
// constructor, before class-field initializers would run (and clobber it).
|
|
122
129
|
this._items = []; this._visibleItems = []; this._fixedItems = []; this._visibleFixed = []; this._actions = []; this._selected = null; this._optionEntries = []; this._activeIndex = -1; this._open = false; this._disabled = false; this._loading = false; this._requestSequence = 0; this._queryTimer = null; this._position = null; this._createdRoot = false; this._root = null; this._snapshot = null; this._pointerModality = false;
|
|
130
|
+
/** @private @type {(value: string) => string} */
|
|
131
|
+
this._normalizeValue = this.options[NORMALIZE_VALUE] ?? ((value) => value);
|
|
123
132
|
this._createdRoot = this.el === null;
|
|
124
133
|
const root = /** @type {HTMLElement} */ (this.el ?? h('div'));
|
|
125
134
|
this.el = root;
|
|
@@ -132,7 +141,7 @@ export class Select extends Component {
|
|
|
132
141
|
class: 'zx-select__input',
|
|
133
142
|
type: 'text',
|
|
134
143
|
role: 'combobox',
|
|
135
|
-
ariaLabel: String(this.options.label || this.options.placeholder || 'Select'),
|
|
144
|
+
ariaLabel: String(this.options.label || this.options.placeholder || this._message('select.label', 'Select')),
|
|
136
145
|
autocomplete: 'off',
|
|
137
146
|
spellcheck: false,
|
|
138
147
|
ariaExpanded: 'false',
|
|
@@ -274,7 +283,8 @@ export class Select extends Component {
|
|
|
274
283
|
*/
|
|
275
284
|
set(idOrItem, { silent = false } = {}) {
|
|
276
285
|
const previousValue = this.value;
|
|
277
|
-
const
|
|
286
|
+
const candidate = typeof idOrItem === 'string' ? this._normalizeValue(idOrItem) : idOrItem;
|
|
287
|
+
const item = candidate == null ? null : this._findItem(candidate);
|
|
278
288
|
this._selected = item;
|
|
279
289
|
this._syncInputValue();
|
|
280
290
|
this._renderOptions();
|
|
@@ -292,6 +302,8 @@ export class Select extends Component {
|
|
|
292
302
|
*/
|
|
293
303
|
setItems(items) {
|
|
294
304
|
const selectedValue = this.value;
|
|
305
|
+
this._cancelQuery();
|
|
306
|
+
this._setLoading(false);
|
|
295
307
|
this._items = Array.isArray(items) ? items.slice() : [];
|
|
296
308
|
this._visibleItems = this._items.slice();
|
|
297
309
|
this._selected = selectedValue == null ? null : this._findItem(selectedValue);
|
|
@@ -337,6 +349,11 @@ export class Select extends Component {
|
|
|
337
349
|
|
|
338
350
|
/** Opens the option panel. @returns {this} @fires Select#open */
|
|
339
351
|
open() {
|
|
352
|
+
return this._openPanel(true);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** @param {boolean} selectText Whether to select the existing label. @returns {this} */
|
|
356
|
+
_openPanel(selectText) {
|
|
340
357
|
if (this._disabled || this._open) return this;
|
|
341
358
|
this._open = true;
|
|
342
359
|
this.el.setAttribute('data-state', 'open');
|
|
@@ -351,7 +368,7 @@ export class Select extends Component {
|
|
|
351
368
|
// is a no-op while the panel is still hidden.
|
|
352
369
|
this._setActive(this._selectedEntryIndex());
|
|
353
370
|
if (this._activeIndex < 0 && this._optionEntries.length > 0) this._setActive(0);
|
|
354
|
-
if (this.options.filter && this._selected !== null) {
|
|
371
|
+
if (selectText && this.options.filter && this._selected !== null) {
|
|
355
372
|
/** @type {HTMLInputElement} */ (this.refs.input).select();
|
|
356
373
|
}
|
|
357
374
|
if (typeof this.options.filter === 'function') this._scheduleAsyncQuery('');
|
|
@@ -399,6 +416,60 @@ export class Select extends Component {
|
|
|
399
416
|
return this;
|
|
400
417
|
}
|
|
401
418
|
|
|
419
|
+
/**
|
|
420
|
+
* Creates a locale Select with native/localized names, pinned choices, and optional flags.
|
|
421
|
+
* Values are canonical BCP 47 tags; initial values and `set()` accept underscores and any case.
|
|
422
|
+
* @param {Element|string|null} target Component target.
|
|
423
|
+
* @param {import('./locale.js').LocaleSelectOptions & SelectOptions} [options={}] Locale options
|
|
424
|
+
* and Select overrides other than items, readers, and renderers.
|
|
425
|
+
* @returns {Select}
|
|
426
|
+
*/
|
|
427
|
+
static locale(target, options = {}) {
|
|
428
|
+
const select = new Select(target, {
|
|
429
|
+
...localeSelectOptions(options),
|
|
430
|
+
[NORMALIZE_VALUE]: (value) => canonicalLocale(value) ?? value
|
|
431
|
+
});
|
|
432
|
+
select.el.setAttribute('data-preset', 'locale');
|
|
433
|
+
return select;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Builds locale items without the DOM, for lists and summaries using the same names.
|
|
438
|
+
* @param {Array<string|import('./locale.js').LocaleItem>} locales Locale tags or specifications.
|
|
439
|
+
* @param {Pick<import('./locale.js').LocaleSelectOptions, 'displayLocale'|'display'|'flagRegions'|'sort'>} [options={}] Naming options.
|
|
440
|
+
* @returns {ReturnType<typeof localeItems>}
|
|
441
|
+
*/
|
|
442
|
+
static localeItems(locales, options = {}) {
|
|
443
|
+
return localeItems(locales, options);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Creates a country Select with localized names, pinned choices, and optional flags. Search
|
|
448
|
+
* includes the English name, ISO code, and descriptions; initial values and `set()` accept either case.
|
|
449
|
+
* @param {Element|string|null} target Component target.
|
|
450
|
+
* @param {import('./country.js').CountrySelectOptions & SelectOptions} [options={}] Country options
|
|
451
|
+
* and Select overrides other than items, readers, and renderers.
|
|
452
|
+
* @returns {Select}
|
|
453
|
+
*/
|
|
454
|
+
static country(target, options = {}) {
|
|
455
|
+
const select = new Select(target, {
|
|
456
|
+
...countrySelectOptions(options),
|
|
457
|
+
[NORMALIZE_VALUE]: (value) => normalizeRegion(value) ?? value
|
|
458
|
+
});
|
|
459
|
+
select.el.setAttribute('data-preset', 'country');
|
|
460
|
+
return select;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Builds country items without the DOM, defaulting to the ISO country catalogue.
|
|
465
|
+
* @param {Array<string|import('./country.js').CountryItem>} [countries] Country codes or specifications.
|
|
466
|
+
* @param {Pick<import('./country.js').CountrySelectOptions, 'displayLocale'|'showCode'|'sort'>} [options={}] Naming options.
|
|
467
|
+
* @returns {ReturnType<typeof countryItems>}
|
|
468
|
+
*/
|
|
469
|
+
static countryItems(countries, options = {}) {
|
|
470
|
+
return countryItems(countries, options);
|
|
471
|
+
}
|
|
472
|
+
|
|
402
473
|
/**
|
|
403
474
|
* Creates the five-level priority preset: values 0 (lowest) to 4 (highest), each drawn as grey
|
|
404
475
|
* signal bars filled to its level, except the highest, which is the one coloured level — a
|
|
@@ -480,8 +551,8 @@ export class Select extends Component {
|
|
|
480
551
|
*/
|
|
481
552
|
static entity(target, options = {}) {
|
|
482
553
|
const {
|
|
483
|
-
recent = [], recentLabel = '
|
|
484
|
-
subtitleKey = 'description', renderIcon = null,
|
|
554
|
+
recent = [], recentLabel = message('select.recent', options), create = false, iconKey = 'icon',
|
|
555
|
+
colorKey = 'color', subtitleKey = 'description', renderIcon = null,
|
|
485
556
|
fixedItems = [], actions = [], renderItem = null, renderValueAdornment = null,
|
|
486
557
|
...rest
|
|
487
558
|
} = options;
|
|
@@ -497,7 +568,7 @@ export class Select extends Component {
|
|
|
497
568
|
ariaHidden: 'true'
|
|
498
569
|
}, icon(value, { size: 14 }));
|
|
499
570
|
};
|
|
500
|
-
const createAction = create ? normalizeEntityCreateAction(create) : null;
|
|
571
|
+
const createAction = create ? normalizeEntityCreateAction(create, options) : null;
|
|
501
572
|
const select = new Select(target, {
|
|
502
573
|
...rest,
|
|
503
574
|
fixedItems: [...(Array.isArray(recent) ? recent : []), ...(Array.isArray(fixedItems) ? fixedItems : [])],
|
|
@@ -627,7 +698,7 @@ export class Select extends Component {
|
|
|
627
698
|
if (!this.options.filter) return;
|
|
628
699
|
const query = /** @type {HTMLInputElement} */ (this.refs.input).value;
|
|
629
700
|
this._syncValueAdornment();
|
|
630
|
-
if (!this._open) this.
|
|
701
|
+
if (!this._open) this._openPanel(false);
|
|
631
702
|
if (this.options.filter === 'local') {
|
|
632
703
|
this._visibleFixed = this._matchFixed(query);
|
|
633
704
|
this._visibleItems = matchItems(this._items, query, this._searchKeys());
|
|
@@ -985,12 +1056,23 @@ function readSelectItem(item, reader) {
|
|
|
985
1056
|
return null;
|
|
986
1057
|
}
|
|
987
1058
|
|
|
988
|
-
/**
|
|
989
|
-
|
|
1059
|
+
/**
|
|
1060
|
+
* Resolves a message for a preset, which hands text to the constructor before an instance exists.
|
|
1061
|
+
* `msg()` reads the `msg` option off whatever object borrows it, so the preset's own option counts.
|
|
1062
|
+
* @param {string} key Message key.
|
|
1063
|
+
* @param {SelectOptions} options Options the preset was given.
|
|
1064
|
+
* @returns {string}
|
|
1065
|
+
*/
|
|
1066
|
+
function message(key, options) {
|
|
1067
|
+
return Component.prototype.msg.call({ options }, key);
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
/** @param {boolean|SelectAction} value @param {SelectOptions} options @returns {SelectAction} */
|
|
1071
|
+
function normalizeEntityCreateAction(value, options) {
|
|
990
1072
|
const descriptor = value === true ? {} : value;
|
|
991
1073
|
return {
|
|
992
|
-
id: descriptor.id ?? 'create', label: descriptor.label ?? '
|
|
993
|
-
description: descriptor.description, group: descriptor.group ?? '
|
|
1074
|
+
id: descriptor.id ?? 'create', label: descriptor.label ?? message('select.create', options),
|
|
1075
|
+
description: descriptor.description, group: descriptor.group ?? message('select.createGroup', options),
|
|
994
1076
|
icon: descriptor.icon ?? 'plus', invoke: descriptor.invoke
|
|
995
1077
|
};
|
|
996
1078
|
}
|
|
@@ -79,7 +79,15 @@ export class SheetStack extends EventTarget {
|
|
|
79
79
|
this.#closers.set(sheet, onClose);
|
|
80
80
|
sheet.on('close', onClose);
|
|
81
81
|
}
|
|
82
|
+
// Clear the former covered state before presenting: an inert dialog cannot take focus.
|
|
83
|
+
this.#sync();
|
|
82
84
|
if (!sheet.isOpen()) sheet.open();
|
|
85
|
+
else {
|
|
86
|
+
// Native top-layer order follows presentation order. Rehosting uses Modal's generation
|
|
87
|
+
// guard so its queued close is not a stack pop or a new user-visible lifecycle.
|
|
88
|
+
sheet._rehost();
|
|
89
|
+
sheet._focusInitial();
|
|
90
|
+
}
|
|
83
91
|
this.#sync();
|
|
84
92
|
this.#emit('push', { sheet, depth: 0 });
|
|
85
93
|
return this;
|
|
@@ -97,8 +105,9 @@ export class SheetStack extends EventTarget {
|
|
|
97
105
|
pop() {
|
|
98
106
|
const sheet = this.top();
|
|
99
107
|
if (!sheet) return null;
|
|
100
|
-
this
|
|
108
|
+
// Dismiss this presentation before pop listeners can re-push and open a new one.
|
|
101
109
|
sheet.close();
|
|
110
|
+
this.#remove(sheet);
|
|
102
111
|
return sheet;
|
|
103
112
|
}
|
|
104
113
|
|
|
@@ -160,6 +160,7 @@ export class Slider extends Component {
|
|
|
160
160
|
const value = this._snap(next);
|
|
161
161
|
const changed = value !== this._value;
|
|
162
162
|
this._value = value;
|
|
163
|
+
this._committedValue = value;
|
|
163
164
|
this._paint();
|
|
164
165
|
if (changed && !silent) this.emit('change', { value });
|
|
165
166
|
return this;
|
|
@@ -246,7 +247,7 @@ export class Slider extends Component {
|
|
|
246
247
|
step: String(this._step),
|
|
247
248
|
disabled: Boolean(this.options.disabled),
|
|
248
249
|
readOnly: this._readonly,
|
|
249
|
-
ariaLabel: String(this.options.label ?? '
|
|
250
|
+
ariaLabel: String(this.options.label ?? this.msg('slider.value'))
|
|
250
251
|
}));
|
|
251
252
|
this.listen(number, 'input', () => {
|
|
252
253
|
if (this._readonly) return;
|
|
@@ -263,7 +264,10 @@ export class Slider extends Component {
|
|
|
263
264
|
number.value = String(this._value);
|
|
264
265
|
return;
|
|
265
266
|
}
|
|
266
|
-
this.
|
|
267
|
+
const value = this._snap(number.value === '' ? this._min : Number(number.value));
|
|
268
|
+
const changed = value !== this._committedValue;
|
|
269
|
+
this.set(value, { silent: true });
|
|
270
|
+
if (changed) this.emit('change', { value });
|
|
267
271
|
});
|
|
268
272
|
return number;
|
|
269
273
|
}
|
|
@@ -303,6 +307,7 @@ export class Slider extends Component {
|
|
|
303
307
|
this.refs.input.value = String(this._value);
|
|
304
308
|
return;
|
|
305
309
|
}
|
|
310
|
+
this._committedValue = this._value;
|
|
306
311
|
this.emit('change', { value: this._value });
|
|
307
312
|
}
|
|
308
313
|
|
|
@@ -10,7 +10,8 @@ import { Select } from '../select/select.js';
|
|
|
10
10
|
* @typedef {Object} SortControlOptions
|
|
11
11
|
* @property {SortField[]} [fields=[]] Available sort fields, in display order.
|
|
12
12
|
* @property {SortValue|null} [value=null] Initial sort; null chooses the first field ascending.
|
|
13
|
-
* @property {string} [label
|
|
13
|
+
* @property {string|null} [label] Accessible field label and direction-name prefix, by default the
|
|
14
|
+
* `sortControl.label` message ("Sort by"). Null gives neither.
|
|
14
15
|
* @property {{asc?:string,desc?:string}} [labels={}] Current/next direction labels, defaulting to Ascending/Descending.
|
|
15
16
|
* @property {boolean} [disabled=false] Whether interaction is disabled.
|
|
16
17
|
* @property {(event:CustomEvent<{value:SortValue}>)=>void} [onchange] Atomic field/direction change.
|
|
@@ -24,7 +25,7 @@ import { Select } from '../select/select.js';
|
|
|
24
25
|
export class SortControl extends Component {
|
|
25
26
|
static cssName = 'sort-control';
|
|
26
27
|
/** @type {SortControlOptions} */
|
|
27
|
-
static defaults = { fields: [], value: null, label:
|
|
28
|
+
static defaults = { fields: [], value: null, label: undefined, labels: {}, disabled: false };
|
|
28
29
|
|
|
29
30
|
/** @returns {HTMLElement} */
|
|
30
31
|
render() {
|
|
@@ -42,7 +43,7 @@ export class SortControl extends Component {
|
|
|
42
43
|
});
|
|
43
44
|
this._select = new Select(null, {
|
|
44
45
|
items: sortChoices(this.options.fields), valueKey: 'id', labelKey: 'label',
|
|
45
|
-
value: this._value?.id ?? null, label: this.
|
|
46
|
+
value: this._value?.id ?? null, label: this._label(),
|
|
46
47
|
filter: 'local', disabled: this._disabled,
|
|
47
48
|
onchange: ({ detail }) => {
|
|
48
49
|
if (!detail.item) return;
|
|
@@ -94,13 +95,22 @@ export class SortControl extends Component {
|
|
|
94
95
|
_syncDirection() {
|
|
95
96
|
const dir = this._value?.dir ?? 'asc';
|
|
96
97
|
const next = dir === 'asc' ? 'desc' : 'asc';
|
|
97
|
-
const labels = {
|
|
98
|
+
const labels = {
|
|
99
|
+
asc: this.msg('sortControl.ascending'), desc: this.msg('sortControl.descending'), ...this.options.labels
|
|
100
|
+
};
|
|
98
101
|
this._direction.replaceChildren(icon(dir === 'asc' ? 'arrow-up-wide-short' : 'arrow-down-wide-short'));
|
|
99
102
|
this._direction.dataset.direction = dir;
|
|
100
|
-
|
|
103
|
+
const label = this._label();
|
|
104
|
+
this._direction.setAttribute('aria-label', label === null ? labels[dir] : `${label}: ${labels[dir]}`);
|
|
101
105
|
this._direction.title = `${labels[dir]} → ${labels[next]}`;
|
|
102
106
|
}
|
|
103
107
|
|
|
108
|
+
/** @returns {string|null} The control's name: unset reads the catalogue, and null is no name. */
|
|
109
|
+
_label() {
|
|
110
|
+
const { label = this.msg('sortControl.label') } = this.options;
|
|
111
|
+
return label;
|
|
112
|
+
}
|
|
113
|
+
|
|
104
114
|
/** Focuses the searchable control. @returns {this} */
|
|
105
115
|
focus() { this._select.focus(); return this; }
|
|
106
116
|
/** Releases the owned Select and restores an enhanced target. @returns {void} */
|
|
@@ -17,8 +17,9 @@ import { Tooltip } from '../tooltip/tooltip.js';
|
|
|
17
17
|
* @typedef {Object} SourceListOptions
|
|
18
18
|
* @property {Source[]} [sources=[]] The sources, in the order an answer's `[n]` citations number
|
|
19
19
|
* them. Model text is data: every string reaches the page as text.
|
|
20
|
-
* @property {string} [label
|
|
21
|
-
*
|
|
20
|
+
* @property {string|null} [label] The visible label the list is named by, by default the
|
|
21
|
+
* `sourceList.label` message ("Sources"). Empty or null hides it and names the list with that
|
|
22
|
+
* message instead.
|
|
22
23
|
* @property {'chips'|'list'} [layout='chips'] `'chips'` wraps short chips beside the label;
|
|
23
24
|
* `'list'` gives each source a full-width row with its title and site.
|
|
24
25
|
* @property {boolean} [numbered=true] Whether each source shows its number.
|
|
@@ -63,7 +64,8 @@ export class SourceList extends Component {
|
|
|
63
64
|
/** @type {Readonly<SourceListOptions>} */
|
|
64
65
|
static defaults = {
|
|
65
66
|
sources: [],
|
|
66
|
-
|
|
67
|
+
// Undefined rather than null, which already hides the label.
|
|
68
|
+
label: undefined,
|
|
67
69
|
layout: 'chips',
|
|
68
70
|
numbered: true,
|
|
69
71
|
icons: {},
|
|
@@ -89,7 +91,8 @@ export class SourceList extends Component {
|
|
|
89
91
|
this._layout = this.options.layout === 'list' ? 'list' : 'chips';
|
|
90
92
|
root.dataset.layout = this._layout;
|
|
91
93
|
|
|
92
|
-
const label =
|
|
94
|
+
const { label: option = this.msg('sourceList.label') } = this.options;
|
|
95
|
+
const label = typeof option === 'string' ? option.trim() : '';
|
|
93
96
|
const labelId = uid('zx-source-list');
|
|
94
97
|
const heading = label ? h('span', { class: 'zx-source-list__label', id: labelId }, label) : null;
|
|
95
98
|
this._list = h('ol', {
|
|
@@ -29,7 +29,8 @@ const STORAGE_NAMESPACE = 'split-view';
|
|
|
29
29
|
* @property {string|null} [storageKey=null] Key under which the size is remembered between visits.
|
|
30
30
|
* Storage failures degrade to memory rather than throwing.
|
|
31
31
|
* @property {boolean} [disabled=false] Whether resizing is blocked.
|
|
32
|
-
* @property {string} [label=
|
|
32
|
+
* @property {string|null} [label=null] Accessible name of the divider; null reads the
|
|
33
|
+
* `splitView.resize` message ("Resize panes").
|
|
33
34
|
* @property {(event: CustomEvent<{size: number, ratio: number}>) => void} [onresize] Resize listener.
|
|
34
35
|
* @property {(event: CustomEvent<{size: number, ratio: number}>) => void} [onresizeend] Resize-end listener.
|
|
35
36
|
* @property {(event: CustomEvent<{pane: 'start'|'end'}>) => void} [oncollapse] Collapse listener.
|
|
@@ -70,7 +71,7 @@ export class SplitView extends Component {
|
|
|
70
71
|
snap: 0,
|
|
71
72
|
storageKey: null,
|
|
72
73
|
disabled: false,
|
|
73
|
-
label:
|
|
74
|
+
label: null
|
|
74
75
|
};
|
|
75
76
|
|
|
76
77
|
/** @type {ResizeObserver|null} */
|
|
@@ -91,6 +92,7 @@ export class SplitView extends Component {
|
|
|
91
92
|
const key = this.options.storageKey;
|
|
92
93
|
if (key !== null && key !== undefined && key !== '') {
|
|
93
94
|
this.#store = storage(STORAGE_NAMESPACE);
|
|
95
|
+
this.#store.migrateLegacy([String(key)]);
|
|
94
96
|
const stored = this.#store.get(String(key));
|
|
95
97
|
if (typeof stored === 'number' && Number.isFinite(stored) && stored >= 0) this.setSize(stored);
|
|
96
98
|
}
|
|
@@ -181,7 +183,7 @@ export class SplitView extends Component {
|
|
|
181
183
|
// A separator's aria-orientation describes the separator itself, not the split: panes lying
|
|
182
184
|
// side by side (orientation "horizontal") are parted by a vertical line.
|
|
183
185
|
ariaOrientation: this._orientation === 'vertical' ? 'horizontal' : 'vertical',
|
|
184
|
-
ariaLabel: String(options.label ?? '
|
|
186
|
+
ariaLabel: String(options.label ?? this.msg('splitView.resize')),
|
|
185
187
|
ariaControls: startId
|
|
186
188
|
});
|
|
187
189
|
const end = h('div', {
|