@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { h } from '../../core/dom.js';
|
|
2
2
|
import { copyToClipboard } from '../../core/export.js';
|
|
3
|
+
import { translate } from '../../core/i18n.js';
|
|
3
4
|
import { icon as createIcon } from '../../core/icons.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -7,8 +8,10 @@ import { icon as createIcon } from '../../core/icons.js';
|
|
|
7
8
|
* @property {string|(() => string)} [text=''] Text to copy, or a function returning it — a
|
|
8
9
|
* function is what a button beside a live value wants, so the copy is never stale.
|
|
9
10
|
* @property {string} [label=''] Visible label. Empty renders an icon-only ghost button.
|
|
10
|
-
* @property {string} [title
|
|
11
|
-
*
|
|
11
|
+
* @property {string|null} [title] Accessible name, and the native tooltip on the icon-only form; by
|
|
12
|
+
* default the `copy.copy` message ("Copy"). Null gives none.
|
|
13
|
+
* @property {string|null} [feedback] Confirmation announced and shown after a copy; by default the
|
|
14
|
+
* `copy.copied` message ("Copied"). Null says nothing.
|
|
12
15
|
* @property {number} [feedbackDuration=2000] Milliseconds the confirmation stays.
|
|
13
16
|
* @property {'md'|'sm'} [size='md'] Control size.
|
|
14
17
|
* @property {'default'|'primary'|'ghost'} [kind='ghost'] Visual intent.
|
|
@@ -20,8 +23,6 @@ import { icon as createIcon } from '../../core/icons.js';
|
|
|
20
23
|
const buttonDefaults = Object.freeze({
|
|
21
24
|
text: '',
|
|
22
25
|
label: '',
|
|
23
|
-
title: 'Copy',
|
|
24
|
-
feedback: 'Copied',
|
|
25
26
|
feedbackDuration: 2000,
|
|
26
27
|
size: 'md',
|
|
27
28
|
kind: 'ghost'
|
|
@@ -40,13 +41,14 @@ const buttonDefaults = Object.freeze({
|
|
|
40
41
|
*/
|
|
41
42
|
export function copyButton(opts = {}) {
|
|
42
43
|
const options = { ...buttonDefaults, ...opts };
|
|
44
|
+
const { title = translate('copy.copy'), feedback = translate('copy.copied') } = options;
|
|
43
45
|
const iconOnly = !options.label;
|
|
44
46
|
const element = /** @type {HTMLButtonElement} */ (h('button', {
|
|
45
47
|
class: ['zx-copy-button', iconOnly ? 'zx-icon-btn' : 'zx-btn'],
|
|
46
48
|
type: 'button',
|
|
47
49
|
dataset: { size: options.size === 'sm' ? 'sm' : 'md', kind: iconOnly ? null : options.kind },
|
|
48
|
-
title: iconOnly ? String(
|
|
49
|
-
ariaLabel: iconOnly ? String(
|
|
50
|
+
title: iconOnly ? String(title ?? '') : null,
|
|
51
|
+
ariaLabel: iconOnly ? String(title ?? '') : null
|
|
50
52
|
}));
|
|
51
53
|
|
|
52
54
|
const glyph = h('span', { class: 'zx-copy-button__icon', ariaHidden: 'true' },
|
|
@@ -66,7 +68,7 @@ export function copyButton(opts = {}) {
|
|
|
66
68
|
clearTimeout(timer);
|
|
67
69
|
element.dataset.copied = 'true';
|
|
68
70
|
glyph.replaceChildren(createIcon('check', { size: options.size === 'sm' ? 12 : 14 }));
|
|
69
|
-
status.textContent = String(
|
|
71
|
+
status.textContent = String(feedback ?? '');
|
|
70
72
|
timer = setTimeout(() => {
|
|
71
73
|
if (!element.isConnected) return;
|
|
72
74
|
delete element.dataset.copied;
|
|
@@ -8,8 +8,10 @@ import { copyButton } from './copy-button.js';
|
|
|
8
8
|
* @property {string} [value=''] Text shown and copied.
|
|
9
9
|
* @property {string} [label=''] Visible label above the box.
|
|
10
10
|
* @property {boolean} [hideLabel=false] Whether the label is kept for assistive technology only.
|
|
11
|
-
* @property {string} [feedback
|
|
12
|
-
*
|
|
11
|
+
* @property {string|null} [feedback] Confirmation shown after a copy, by default the `copy.copied`
|
|
12
|
+
* message ("Copied"). Null says nothing.
|
|
13
|
+
* @property {string|null} [buttonTitle] Accessible name of the copy button, by default the
|
|
14
|
+
* `copy.copy` message ("Copy"). Null gives none.
|
|
13
15
|
* @property {'md'|'sm'} [size='md'] Control size.
|
|
14
16
|
* @property {(event: CustomEvent<{value: string, copied: boolean}>) => void} [oncopy] Copy listener.
|
|
15
17
|
*/
|
|
@@ -33,8 +35,9 @@ export class CopyInput extends Component {
|
|
|
33
35
|
value: '',
|
|
34
36
|
label: '',
|
|
35
37
|
hideLabel: false,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
// Undefined rather than null, which gives no text at all.
|
|
39
|
+
feedback: undefined,
|
|
40
|
+
buttonTitle: undefined,
|
|
38
41
|
size: 'md'
|
|
39
42
|
};
|
|
40
43
|
|
|
@@ -56,10 +59,11 @@ export class CopyInput extends Component {
|
|
|
56
59
|
readOnly: true,
|
|
57
60
|
value: String(this.options.value ?? '')
|
|
58
61
|
}));
|
|
62
|
+
const { buttonTitle = this.msg('copy.copy'), feedback = this.msg('copy.copied') } = this.options;
|
|
59
63
|
const button = copyButton({
|
|
60
64
|
text: () => this.get(),
|
|
61
|
-
title:
|
|
62
|
-
feedback
|
|
65
|
+
title: buttonTitle,
|
|
66
|
+
feedback,
|
|
63
67
|
size: this.options.size === 'sm' ? 'sm' : 'md',
|
|
64
68
|
oncopy: (value, copied) => this.emit('copy', { value, copied })
|
|
65
69
|
});
|
|
@@ -227,6 +227,7 @@ export class DatePicker extends Component {
|
|
|
227
227
|
this.refs.heading.textContent = formatDate(first, '%B %Y');
|
|
228
228
|
this.refs.heading.setAttribute('aria-label',
|
|
229
229
|
this._message('datePicker.chooseMonthYear', 'Choose month and year, %1', formatDate(first, '%B %Y')));
|
|
230
|
+
const dayLabel = this._message('datePicker.dayLabel', '%e %B %Y');
|
|
230
231
|
const rows = [];
|
|
231
232
|
|
|
232
233
|
for (let week = 0; week < 6; week += 1) {
|
|
@@ -251,7 +252,7 @@ export class DatePicker extends Component {
|
|
|
251
252
|
ariaSelected: String(selected),
|
|
252
253
|
ariaDisabled: String(unavailable),
|
|
253
254
|
ariaCurrent: isSameDay(date, new Date()) ? 'date' : null,
|
|
254
|
-
ariaLabel:
|
|
255
|
+
ariaLabel: formatDate(date, dayLabel),
|
|
255
256
|
dataset: {
|
|
256
257
|
date: formatDate(date, '%Y-%m-%d'),
|
|
257
258
|
otherMonth: date.getMonth() === this._viewMonth ? null : 'true'
|
|
@@ -722,7 +722,7 @@ export class DateRangePicker extends Component {
|
|
|
722
722
|
|
|
723
723
|
/** @param {Date} date @param {string|null} state @returns {string} */
|
|
724
724
|
_dayLabel(date, state) {
|
|
725
|
-
const base = formatDate(date, '%A, %e %B %Y');
|
|
725
|
+
const base = formatDate(date, text('daterange.dayLabel', '%A, %e %B %Y'));
|
|
726
726
|
if (state === 'start') return `${base}, ${text('daterange.day.start', 'range start')}`;
|
|
727
727
|
if (state === 'end') return `${base}, ${text('daterange.day.end', 'range end')}`;
|
|
728
728
|
if (state === 'middle') return `${base}, ${text('daterange.day.middle', 'in selected range')}`;
|
|
@@ -746,7 +746,7 @@ export class DateRangePicker extends Component {
|
|
|
746
746
|
if (!this._start) return text('daterange.status.empty', 'No date range selected');
|
|
747
747
|
if (!this._end) {
|
|
748
748
|
return text('daterange.status.start', '%1 selected, choose an end date',
|
|
749
|
-
[formatDate(this._start, '%e %B %Y')]);
|
|
749
|
+
[formatDate(this._start, text('daterange.span.full', '%e %B %Y'))]);
|
|
750
750
|
}
|
|
751
751
|
const nights = rangeNights(this._start, this._end);
|
|
752
752
|
const spans = nights === 1
|
|
@@ -861,11 +861,12 @@ function text(key, fallback, args) {
|
|
|
861
861
|
* @returns {string}
|
|
862
862
|
*/
|
|
863
863
|
function spanLabel(start, end) {
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
if (start.
|
|
868
|
-
return `${formatDate(start, '%e')} – ${tail}`;
|
|
864
|
+
const full = text('daterange.span.full', '%e %B %Y');
|
|
865
|
+
if (isSameDay(start, end)) return formatDate(start, full);
|
|
866
|
+
const tail = formatDate(end, full);
|
|
867
|
+
if (start.getFullYear() !== end.getFullYear()) return `${formatDate(start, full)} – ${tail}`;
|
|
868
|
+
if (start.getMonth() !== end.getMonth()) return `${formatDate(start, text('daterange.span.month', '%e %B'))} – ${tail}`;
|
|
869
|
+
return `${formatDate(start, text('daterange.span.day', '%e'))} – ${tail}`;
|
|
869
870
|
}
|
|
870
871
|
|
|
871
872
|
/** @param {unknown} value @returns {DateRangePreset[]} */
|
|
@@ -6,6 +6,7 @@ import { ICON_SIZE, icon } from '../../core/icons.js';
|
|
|
6
6
|
import { position } from '../../core/position.js';
|
|
7
7
|
import { escapeRegExp, uid } from '../../core/util.js';
|
|
8
8
|
import { DateRangePicker, clampRange, normalizeRange } from '../date-picker/date-range-picker.js';
|
|
9
|
+
import { placeholderTokens } from './placeholder.js';
|
|
9
10
|
|
|
10
11
|
/** @typedef {import('../date-picker/date-range-picker.js').DateRange} DateRange */
|
|
11
12
|
/** @typedef {import('../date-picker/date-range-picker.js').DateRangePreset} DateRangePreset */
|
|
@@ -42,14 +43,6 @@ import { DateRangePicker, clampRange, normalizeRange } from '../date-picker/date
|
|
|
42
43
|
/** @typedef {{silent?: boolean}} DateRangeBoxSetOptions */
|
|
43
44
|
/** @typedef {'date'|'seconds'} DateRangeBoxUnit */
|
|
44
45
|
|
|
45
|
-
const PLACEHOLDER_TOKENS = {
|
|
46
|
-
'%d': 'DD',
|
|
47
|
-
'%e': 'D',
|
|
48
|
-
'%m': 'MM',
|
|
49
|
-
'%Y': 'YYYY',
|
|
50
|
-
'%y': 'YY'
|
|
51
|
-
};
|
|
52
|
-
|
|
53
46
|
/**
|
|
54
47
|
* Parses `"<start><separator><end>"` into a range. A lone date is read as a one-day range, and a
|
|
55
48
|
* trailing separator as a start-only range, so a half-typed value is not thrown away.
|
|
@@ -449,7 +442,8 @@ export class DateRangeBox extends Component {
|
|
|
449
442
|
|
|
450
443
|
/** @returns {string} */
|
|
451
444
|
_placeholder() {
|
|
452
|
-
const
|
|
445
|
+
const tokens = placeholderTokens((key) => this.msg(key));
|
|
446
|
+
const one = this._format.replace(/%[demYy]/g, (token) => tokens[token] ?? token);
|
|
453
447
|
return `${one}${this._separator}${one}`;
|
|
454
448
|
}
|
|
455
449
|
|
|
@@ -5,6 +5,7 @@ import { ICON_SIZE, icon } from '../../core/icons.js';
|
|
|
5
5
|
import { position } from '../../core/position.js';
|
|
6
6
|
import { uid } from '../../core/util.js';
|
|
7
7
|
import { DatePicker } from '../date-picker/date-picker.js';
|
|
8
|
+
import { placeholderTokens } from './placeholder.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @typedef {Object} DateboxOptions
|
|
@@ -80,7 +81,7 @@ export class Datebox extends Component {
|
|
|
80
81
|
class: 'zx-datebox__input',
|
|
81
82
|
type: 'text',
|
|
82
83
|
autocomplete: 'off',
|
|
83
|
-
placeholder: this.options.placeholder ?? placeholderFromFormat(this._format),
|
|
84
|
+
placeholder: this.options.placeholder ?? placeholderFromFormat(this._format, (key) => this.msg(key)),
|
|
84
85
|
'aria-haspopup': 'grid',
|
|
85
86
|
ariaControls: popoverId,
|
|
86
87
|
ariaExpanded: 'false'
|
|
@@ -89,13 +90,13 @@ export class Datebox extends Component {
|
|
|
89
90
|
ref: 'clear',
|
|
90
91
|
class: 'zx-icon-btn zx-datebox__clear',
|
|
91
92
|
type: 'button',
|
|
92
|
-
ariaLabel: '
|
|
93
|
+
ariaLabel: this.msg('datebox.clear')
|
|
93
94
|
}, icon('x', { size: ICON_SIZE.dismiss })),
|
|
94
95
|
h('button', {
|
|
95
96
|
ref: 'toggle',
|
|
96
97
|
class: 'zx-datebox__toggle',
|
|
97
98
|
type: 'button',
|
|
98
|
-
ariaLabel: '
|
|
99
|
+
ariaLabel: this.msg('datebox.choose'),
|
|
99
100
|
'aria-haspopup': 'grid',
|
|
100
101
|
ariaControls: popoverId,
|
|
101
102
|
ariaExpanded: 'false'
|
|
@@ -145,7 +146,7 @@ export class Datebox extends Component {
|
|
|
145
146
|
this.focus();
|
|
146
147
|
});
|
|
147
148
|
this.listen(document, 'keydown', (event) => {
|
|
148
|
-
if (!this._open || event.key !== 'Escape') return;
|
|
149
|
+
if (!this._open || event.defaultPrevented || event.key !== 'Escape') return;
|
|
149
150
|
event.preventDefault();
|
|
150
151
|
this._close(true);
|
|
151
152
|
});
|
|
@@ -272,18 +273,22 @@ export class Datebox extends Component {
|
|
|
272
273
|
_commitText() {
|
|
273
274
|
if (this._disabled) return;
|
|
274
275
|
const text = this.refs.input.value.trim();
|
|
275
|
-
|
|
276
|
-
|
|
276
|
+
const current = this._value ? formatDate(this._value, this._format) : '';
|
|
277
|
+
if (text === current) {
|
|
278
|
+
this._setValid();
|
|
279
|
+
this._syncDisplay();
|
|
277
280
|
return;
|
|
278
281
|
}
|
|
279
|
-
const parsed = parseDate(text, this._format);
|
|
280
|
-
if (!parsed) {
|
|
282
|
+
const parsed = text === '' ? null : parseDate(text, this._format);
|
|
283
|
+
if (text !== '' && !parsed) {
|
|
281
284
|
this.el.dataset.state = 'invalid';
|
|
282
285
|
this.refs.input.setAttribute('aria-invalid', 'true');
|
|
283
286
|
this.emit('invalid', { text });
|
|
284
287
|
return;
|
|
285
288
|
}
|
|
286
|
-
this.
|
|
289
|
+
const next = this._normalizeValue(parsed);
|
|
290
|
+
const unchanged = (next?.getTime() ?? null) === (this._value?.getTime() ?? null);
|
|
291
|
+
this.set(next, { silent: unchanged });
|
|
287
292
|
}
|
|
288
293
|
|
|
289
294
|
/** @param {Date|number|string|null|unknown} value @returns {Date|null} */
|
|
@@ -391,16 +396,8 @@ function effectiveFormat(format, time) {
|
|
|
391
396
|
return time && !/%[HM]/.test(value) ? `${value} %H:%M` : value;
|
|
392
397
|
}
|
|
393
398
|
|
|
394
|
-
/** @param {string} format @returns {string} */
|
|
395
|
-
function placeholderFromFormat(format) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
'%e': 'D',
|
|
399
|
-
'%m': 'MM',
|
|
400
|
-
'%Y': 'YYYY',
|
|
401
|
-
'%y': 'YY',
|
|
402
|
-
'%H': 'HH',
|
|
403
|
-
'%M': 'MM',
|
|
404
|
-
'%S': 'SS'
|
|
405
|
-
})[token] ?? token);
|
|
399
|
+
/** @param {string} format @param {(key: string) => string} message @returns {string} */
|
|
400
|
+
function placeholderFromFormat(format, message) {
|
|
401
|
+
const tokens = placeholderTokens(message);
|
|
402
|
+
return format.replace(/%[demYyHMS]/g, (token) => tokens[token] ?? token);
|
|
406
403
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What each numeric format token reads as in a date field's placeholder: `%Y` is `YYYY` in English
|
|
3
|
+
* and `JJJJ` in German. Datebox and DateRangeBox each replace the tokens their format allows.
|
|
4
|
+
* @param {(key: string) => string} message Resolves a message key for the field.
|
|
5
|
+
* @returns {Record<string, string>} Placeholder text by format token.
|
|
6
|
+
*/
|
|
7
|
+
export function placeholderTokens(message) {
|
|
8
|
+
return {
|
|
9
|
+
'%d': message('datebox.placeholder.day'),
|
|
10
|
+
'%e': message('datebox.placeholder.dayShort'),
|
|
11
|
+
'%m': message('datebox.placeholder.month'),
|
|
12
|
+
'%Y': message('datebox.placeholder.year'),
|
|
13
|
+
'%y': message('datebox.placeholder.yearShort'),
|
|
14
|
+
'%H': message('datebox.placeholder.hour'),
|
|
15
|
+
'%M': message('datebox.placeholder.minute'),
|
|
16
|
+
'%S': message('datebox.placeholder.second')
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -401,7 +401,7 @@ export class Dialog extends Modal {
|
|
|
401
401
|
{ label: okLabel ?? dialog._message('dialog.ok', 'OK'), kind: 'primary', action: () => finish(input.value) }
|
|
402
402
|
]);
|
|
403
403
|
dialog.listen(input, 'keydown', (event) => {
|
|
404
|
-
if (event.key !== 'Enter') return;
|
|
404
|
+
if (event.key !== 'Enter' || event.isComposing) return;
|
|
405
405
|
event.preventDefault();
|
|
406
406
|
finish(input.value);
|
|
407
407
|
});
|
|
@@ -59,7 +59,8 @@ const STORAGE_NAMESPACE = 'dock';
|
|
|
59
59
|
* front.
|
|
60
60
|
* @property {string|null} [storageKey=null] Key under which sizes, collapsed panes, and active
|
|
61
61
|
* tabs are remembered. Storage failures degrade to memory rather than throwing.
|
|
62
|
-
* @property {string} [label=
|
|
62
|
+
* @property {string|null} [label=null] Accessible name given to every divider; null reads the
|
|
63
|
+
* `dock.resize` message ("Resize panes").
|
|
63
64
|
* @property {(event: CustomEvent<{name: string}>) => void} [oncollapse] Collapse listener.
|
|
64
65
|
* @property {(event: CustomEvent<{name: string}>) => void} [onexpand] Expand listener.
|
|
65
66
|
* @property {(event: CustomEvent<{name: string, size: number}>) => void} [onresize] Resize listener.
|
|
@@ -99,7 +100,7 @@ export class Dock extends Component {
|
|
|
99
100
|
collapsible: true,
|
|
100
101
|
lazy: true,
|
|
101
102
|
storageKey: null,
|
|
102
|
-
label:
|
|
103
|
+
label: null
|
|
103
104
|
};
|
|
104
105
|
|
|
105
106
|
/**
|
|
@@ -113,6 +114,7 @@ export class Dock extends Component {
|
|
|
113
114
|
const key = this.options.storageKey;
|
|
114
115
|
if (key !== null && key !== undefined && key !== '') {
|
|
115
116
|
this._store = storage(STORAGE_NAMESPACE);
|
|
117
|
+
this._store.migrateLegacy([String(key)]);
|
|
116
118
|
const stored = this._store.get(String(key));
|
|
117
119
|
if (stored && typeof stored === 'object') this.setState(stored);
|
|
118
120
|
}
|
|
@@ -406,6 +408,7 @@ export class Dock extends Component {
|
|
|
406
408
|
record.collapsed = shouldCollapse;
|
|
407
409
|
this._syncPaneState(record);
|
|
408
410
|
}
|
|
411
|
+
this._materialize(record);
|
|
409
412
|
}
|
|
410
413
|
this._syncGrow();
|
|
411
414
|
this._syncDividers();
|
|
@@ -423,10 +426,10 @@ export class Dock extends Component {
|
|
|
423
426
|
this._dividerDrags = [];
|
|
424
427
|
for (const record of this._panes.values()) {
|
|
425
428
|
record.roving?.destroy();
|
|
426
|
-
record.breakpoint?.destroy();
|
|
427
429
|
// The dock never owned the sheet, so it hands it back rather than taking it down with it.
|
|
428
|
-
if (record.kind === 'sheet')
|
|
430
|
+
if (record.kind === 'sheet') this._releaseSheet(record);
|
|
429
431
|
}
|
|
432
|
+
this._panes.clear();
|
|
430
433
|
super.destroy();
|
|
431
434
|
if (!this._createdRoot && this._snapshot) restoreTarget(this.el, this._snapshot);
|
|
432
435
|
}
|
|
@@ -606,7 +609,7 @@ export class Dock extends Component {
|
|
|
606
609
|
// A separator's aria-orientation describes the separator, not the stack: panes stacked
|
|
607
610
|
// vertically are parted by horizontal lines.
|
|
608
611
|
ariaOrientation: this._orientation === 'vertical' ? 'horizontal' : 'vertical',
|
|
609
|
-
ariaLabel: String(this.options.label ?? '
|
|
612
|
+
ariaLabel: String(this.options.label ?? this.msg('dock.resize'))
|
|
610
613
|
});
|
|
611
614
|
this._dividerDrags.push(dragAxis(divider, {
|
|
612
615
|
orientation: this._orientation,
|
|
@@ -679,7 +682,10 @@ export class Dock extends Component {
|
|
|
679
682
|
collapsed: false,
|
|
680
683
|
collapsible: false,
|
|
681
684
|
breakpoint: null,
|
|
682
|
-
resync: null
|
|
685
|
+
resync: null,
|
|
686
|
+
originalSize: sheet.el.style.getPropertyValue('--zx-pane-size'),
|
|
687
|
+
originalSizePriority: sheet.el.style.getPropertyPriority('--zx-pane-size'),
|
|
688
|
+
originalGrow: sheet.el.getAttribute('data-grow')
|
|
683
689
|
};
|
|
684
690
|
const entries = [...this._panes.entries()];
|
|
685
691
|
const index = Number.isInteger(options.index)
|
|
@@ -723,19 +729,34 @@ export class Dock extends Component {
|
|
|
723
729
|
release(sheet) {
|
|
724
730
|
const record = [...this._panes.values()].find((candidate) => candidate.sheet === sheet);
|
|
725
731
|
if (!record) return this;
|
|
726
|
-
record.breakpoint?.destroy();
|
|
727
|
-
record.breakpoint = null;
|
|
728
732
|
this._panes.delete(record.name);
|
|
729
|
-
|
|
730
|
-
sheet.off('close', record.resync);
|
|
731
|
-
sheet.el.style.removeProperty('--zx-pane-size');
|
|
732
|
-
sheet._setDock(null);
|
|
733
|
+
this._releaseSheet(record);
|
|
733
734
|
this._layout();
|
|
734
735
|
this._syncGrow();
|
|
735
736
|
this._syncDividers();
|
|
736
737
|
return this;
|
|
737
738
|
}
|
|
738
739
|
|
|
740
|
+
/**
|
|
741
|
+
* Removes adoption-only subscriptions and styling before returning a surviving sheet.
|
|
742
|
+
* @param {Record<string, any>} record Adopted sheet record.
|
|
743
|
+
* @param {boolean} [rehost=true] Whether the sheet is still alive and can be floated.
|
|
744
|
+
* @returns {void}
|
|
745
|
+
*/
|
|
746
|
+
_releaseSheet(record, rehost = true) {
|
|
747
|
+
record.breakpoint?.destroy();
|
|
748
|
+
record.breakpoint = null;
|
|
749
|
+
const sheet = record.sheet;
|
|
750
|
+
sheet.off('open', record.resync);
|
|
751
|
+
sheet.off('close', record.resync);
|
|
752
|
+
if (record.originalSize) {
|
|
753
|
+
sheet.el.style.setProperty('--zx-pane-size', record.originalSize, record.originalSizePriority);
|
|
754
|
+
} else sheet.el.style.removeProperty('--zx-pane-size');
|
|
755
|
+
if (record.originalGrow === null) sheet.el.removeAttribute('data-grow');
|
|
756
|
+
else sheet.el.setAttribute('data-grow', record.originalGrow);
|
|
757
|
+
if (rehost) sheet._setDock(null);
|
|
758
|
+
}
|
|
759
|
+
|
|
739
760
|
/**
|
|
740
761
|
* Drops a sheet that destroyed itself while adopted, without re-hosting a dead element.
|
|
741
762
|
* @param {Object} sheet Sheet being destroyed.
|
|
@@ -744,7 +765,7 @@ export class Dock extends Component {
|
|
|
744
765
|
_forget(sheet) {
|
|
745
766
|
const record = [...this._panes.values()].find((candidate) => candidate.sheet === sheet);
|
|
746
767
|
if (!record) return;
|
|
747
|
-
|
|
768
|
+
this._releaseSheet(record, false);
|
|
748
769
|
this._panes.delete(record.name);
|
|
749
770
|
if (this._destroyed) return;
|
|
750
771
|
this._layout();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import { Component } from '../../core/component.js';
|
|
3
3
|
import { h, restoreTarget, safeHref, snapshotTarget } from '../../core/dom.js';
|
|
4
|
+
import { translate } from '../../core/i18n.js';
|
|
4
5
|
import { icon as createIcon } from '../../core/icons.js';
|
|
5
6
|
import { isElement } from '../../core/util.js';
|
|
6
7
|
|
|
@@ -54,7 +55,8 @@ import { isElement } from '../../core/util.js';
|
|
|
54
55
|
* @property {EntityRefActionEntry[]} [actions=[]] Secondary controls; element actions keep their own behavior.
|
|
55
56
|
* @property {'sm'|'md'|'lg'} [size='md'] Size of the icon and the identity text.
|
|
56
57
|
* @property {boolean} [wrap=false] Whether long identity text may wrap instead of truncating.
|
|
57
|
-
* @property {string} [actionsLabel=
|
|
58
|
+
* @property {string|null} [actionsLabel=null] Accessible name for secondary actions; null reads the
|
|
59
|
+
* `entityRef.actions` message ("Entity actions").
|
|
58
60
|
* @property {(event: CustomEvent<{id: unknown, entity: Readonly<EntityRefState>, href: string, event: MouseEvent}>) => void} [onactivate]
|
|
59
61
|
* Preventable primary-link listener.
|
|
60
62
|
* @property {(event: CustomEvent<{id: string, action: Readonly<EntityRefAction>, entity: Readonly<EntityRefState>, event: MouseEvent}>) => void} [onaction]
|
|
@@ -97,7 +99,7 @@ export class EntityRef extends Component {
|
|
|
97
99
|
actions: [],
|
|
98
100
|
size: 'md',
|
|
99
101
|
wrap: false,
|
|
100
|
-
actionsLabel:
|
|
102
|
+
actionsLabel: null
|
|
101
103
|
};
|
|
102
104
|
|
|
103
105
|
/**
|
|
@@ -116,7 +118,7 @@ export class EntityRef extends Component {
|
|
|
116
118
|
this.el = root;
|
|
117
119
|
this._snapshot = this._createdRoot ? null : snapshotTarget(root);
|
|
118
120
|
this._destroyed = false;
|
|
119
|
-
this._state =
|
|
121
|
+
this._state = entityRefState(this.options, this.msg('entityRef.actions'));
|
|
120
122
|
this._renderedActions = [];
|
|
121
123
|
|
|
122
124
|
root.replaceChildren(
|
|
@@ -144,7 +146,7 @@ export class EntityRef extends Component {
|
|
|
144
146
|
*/
|
|
145
147
|
set(values = {}) {
|
|
146
148
|
if (!values || typeof values !== 'object' || Array.isArray(values)) return this;
|
|
147
|
-
this._state =
|
|
149
|
+
this._state = entityRefState({ ...this._state, ...values }, this.msg('entityRef.actions'));
|
|
148
150
|
this._sync();
|
|
149
151
|
return this;
|
|
150
152
|
}
|
|
@@ -282,6 +284,15 @@ export class EntityRef extends Component {
|
|
|
282
284
|
* @returns {EntityRefState}
|
|
283
285
|
*/
|
|
284
286
|
export function normalizeEntityRef(values = {}) {
|
|
287
|
+
return entityRefState(values, translate('entityRef.actions'));
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* @param {Partial<EntityRefOptions>|null|undefined} values Candidate values.
|
|
292
|
+
* @param {string} actionsLabel Name of the secondary actions when the values give none.
|
|
293
|
+
* @returns {EntityRefState}
|
|
294
|
+
*/
|
|
295
|
+
function entityRefState(values, actionsLabel) {
|
|
285
296
|
const source = values && typeof values === 'object' && !Array.isArray(values) ? values : {};
|
|
286
297
|
const title = String(source.title ?? '');
|
|
287
298
|
const link = normalizeEntityRefLink(source.link);
|
|
@@ -296,7 +307,7 @@ export function normalizeEntityRef(values = {}) {
|
|
|
296
307
|
actions: normalizeEntityRefActions(source.actions),
|
|
297
308
|
size: normalizeSize(source.size),
|
|
298
309
|
wrap: Boolean(source.wrap),
|
|
299
|
-
actionsLabel: String(source.actionsLabel ||
|
|
310
|
+
actionsLabel: String(source.actionsLabel || actionsLabel)
|
|
300
311
|
};
|
|
301
312
|
}
|
|
302
313
|
|