@zeyos/zx 5.5.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 +210 -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 +711 -0
- 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/approval-card/approval-card.d.ts +596 -0
- package/dist/types/components/avatar/avatar.d.ts +91 -4
- package/dist/types/components/block-view/block-view.d.ts +205 -0
- 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 +938 -0
- 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/run-status/run-status.d.ts +393 -0
- package/dist/types/components/run-trace/run-trace.d.ts +624 -0
- 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 +179 -0
- 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 +479 -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 +18 -1
- package/dist/types/internal/agent-model.d.ts +587 -0
- package/dist/types/internal/date-locale.d.ts +7 -0
- package/dist/types/internal/highlight.d.ts +24 -0
- package/dist/types/internal/json-patch.d.ts +146 -0
- package/dist/types/internal/presence-loop.d.ts +148 -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 +20505 -18748
- 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 +2424 -134
- package/dist/zx.esm.js +46167 -28468
- package/dist/zx.esm.min.js +40 -8
- package/dist/zx.global.js +46167 -28468
- package/dist/zx.global.min.js +40 -8
- 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 +2057 -166
- package/docs/llms.md +1458 -58
- package/docs/llms.txt +38 -8
- 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.css +417 -0
- package/src/components/agent-thread/agent-thread.js +1670 -0
- 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.css +289 -0
- package/src/components/approval-card/approval-card.js +1378 -0
- package/src/components/avatar/avatar.css +56 -1
- package/src/components/avatar/avatar.js +148 -26
- package/src/components/block-view/block-view.css +300 -0
- package/src/components/block-view/block-view.js +524 -0
- 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 +482 -0
- package/src/components/composer/composer.js +1815 -0
- 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.css +208 -0
- package/src/components/run-status/run-status.js +782 -0
- package/src/components/run-trace/run-trace.css +443 -0
- package/src/components/run-trace/run-trace.js +1209 -0
- 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.css +208 -0
- package/src/components/source-list/source-list.js +358 -0
- 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 +519 -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 +18 -1
- package/src/internal/agent-model.js +488 -0
- package/src/internal/date-locale.js +11 -0
- package/src/internal/highlight.js +104 -0
- package/src/internal/json-patch.js +405 -0
- package/src/internal/presence-loop.js +343 -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 +11 -8
- package/styles/zx.layered.css +1 -0
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
cloneCalendarEvent, layoutCalendarSpans, layoutTimedCalendarEvents, normalizeCalendarEvents,
|
|
9
9
|
shiftCalendarEvent, startOfCalendarDay
|
|
10
10
|
} from './calendar-model.js';
|
|
11
|
+
import { dateLocale } from '../../internal/date-locale.js';
|
|
11
12
|
|
|
12
13
|
/** @typedef {import('./calendar-model.js').CalendarEvent} CalendarEvent */
|
|
13
14
|
/** @typedef {import('./calendar-model.js').CalendarView} CalendarView */
|
|
@@ -19,7 +20,8 @@ import {
|
|
|
19
20
|
* @property {Date|string|number|null} [date=null] Initial local anchor date; null uses today.
|
|
20
21
|
* @property {CalendarView} [view='month'] Initial view.
|
|
21
22
|
* @property {CalendarView[]} [views=['agenda','day','week','month','year']] Allowed views.
|
|
22
|
-
* @property {string|string[]} [locale] Intl locale override.
|
|
23
|
+
* @property {string|string[]} [locale] Intl locale override. Unset, dates follow `setLanguage()`, and
|
|
24
|
+
* the browser's language under an English one.
|
|
23
25
|
* @property {number} [weekStart=1] First weekday, 0 (Sunday) through 6 (Saturday).
|
|
24
26
|
* @property {boolean} [weekNumbers=true] Show ISO week numbers in month view.
|
|
25
27
|
* @property {boolean} [workweek=false] Show Monday–Friday in the week time grid.
|
|
@@ -268,7 +270,9 @@ export class Calendar extends Component {
|
|
|
268
270
|
};
|
|
269
271
|
// `source` is assembled from canonical keys, so the configured readers must not be reapplied
|
|
270
272
|
// here — but `dateUnit` must, or a numeric change is read in the wrong unit.
|
|
271
|
-
const [next] = normalizeCalendarEvents([source], {
|
|
273
|
+
const [next] = normalizeCalendarEvents([source], {
|
|
274
|
+
dateUnit: this.options.dateUnit, untitledTitle: this.msg('calendar.untitled')
|
|
275
|
+
});
|
|
272
276
|
next.data = source.data;
|
|
273
277
|
this._events = this._events.map((event, eventIndex) => eventIndex === index ? next : event);
|
|
274
278
|
this._mutationVersions.delete(String(id));
|
|
@@ -386,6 +390,7 @@ export class Calendar extends Component {
|
|
|
386
390
|
eventLocation: this.options.eventLocation,
|
|
387
391
|
eventEditable: this.options.eventEditable,
|
|
388
392
|
eventDurationEditable: this.options.eventDurationEditable,
|
|
393
|
+
untitledTitle: this.msg('calendar.untitled'),
|
|
389
394
|
dateUnit: this.options.dateUnit
|
|
390
395
|
};
|
|
391
396
|
}
|
|
@@ -497,11 +502,11 @@ export class Calendar extends Component {
|
|
|
497
502
|
let firstTabStop = true;
|
|
498
503
|
for (let row = 0; row < slotCount; row += 1) {
|
|
499
504
|
const minutes = min + row * slot;
|
|
500
|
-
axis.append(h('span', { class: 'zx-calendar__time-label' }, minutes % 60 === 0 ? formatTimeMinutes(minutes, this.
|
|
505
|
+
axis.append(h('span', { class: 'zx-calendar__time-label' }, minutes % 60 === 0 ? formatTimeMinutes(minutes, this._locale()) : ''));
|
|
501
506
|
for (let column = 0; column < days.length; column += 1) {
|
|
502
507
|
const date = dateWithMinutes(days[column], minutes);
|
|
503
508
|
const key = String(date.getTime());
|
|
504
|
-
const tabbable = this._focusedSlot
|
|
509
|
+
const tabbable = firstTabStop && (!this._focusedSlot || this._focusedSlot === key);
|
|
505
510
|
if (tabbable) firstTabStop = false;
|
|
506
511
|
slots.append(h('button', {
|
|
507
512
|
type: 'button',
|
|
@@ -521,6 +526,9 @@ export class Calendar extends Component {
|
|
|
521
526
|
}));
|
|
522
527
|
}
|
|
523
528
|
}
|
|
529
|
+
// A remembered date can leave the visible period. Keep a reachable stop even when navigation
|
|
530
|
+
// happened while focus was outside the grid; focus restoration may choose a relative slot.
|
|
531
|
+
if (firstTabStop && slots.firstElementChild) slots.firstElementChild.tabIndex = 0;
|
|
524
532
|
const eventsLayer = h('div', { class: 'zx-calendar__timed-events', ariaHidden: 'false' });
|
|
525
533
|
days.forEach((day, dayIndex) => {
|
|
526
534
|
const layouts = layoutTimedCalendarEvents(this._events, day, {
|
|
@@ -756,7 +764,7 @@ export class Calendar extends Component {
|
|
|
756
764
|
insetBlockStart: `${((minutes - min) / (max - min)) * 100}%`,
|
|
757
765
|
'--zx-calendar-now-day': String(dayIndex)
|
|
758
766
|
} : null
|
|
759
|
-
}, h('span', { class: 'zx-calendar__now-time' }, formatTimeMinutes(minutes, this.
|
|
767
|
+
}, h('span', { class: 'zx-calendar__now-time' }, formatTimeMinutes(minutes, this._locale())));
|
|
760
768
|
}
|
|
761
769
|
|
|
762
770
|
/** @param {Event} event @returns {void} */
|
|
@@ -891,6 +899,9 @@ export class Calendar extends Component {
|
|
|
891
899
|
const edit = this._keyboardEdit;
|
|
892
900
|
if (edit.action === 'move') edit.event = shiftCalendarEvent(edit.event, { days, minutes });
|
|
893
901
|
else {
|
|
902
|
+
const end = addCalendarDays(edit.event.end, days);
|
|
903
|
+
end.setMinutes(end.getMinutes() + minutes);
|
|
904
|
+
if (end <= edit.event.start) return;
|
|
894
905
|
const proposed = shiftCalendarEvent(edit.event, { days: 0, minutes: 0, endDays: days, endMinutes: minutes });
|
|
895
906
|
if (proposed.end > proposed.start) edit.event = proposed;
|
|
896
907
|
}
|
|
@@ -1325,7 +1336,7 @@ export class Calendar extends Component {
|
|
|
1325
1336
|
if (this._view === 'month') return this._format(this._date, { month: 'long', year: 'numeric' });
|
|
1326
1337
|
if (this._view === 'year') return this._format(this._date, { year: 'numeric' });
|
|
1327
1338
|
const last = addCalendarDays(range.end, -1);
|
|
1328
|
-
const formatter = new Intl.DateTimeFormat(this.
|
|
1339
|
+
const formatter = new Intl.DateTimeFormat(this._locale(), {
|
|
1329
1340
|
day: 'numeric', month: 'long', year: 'numeric'
|
|
1330
1341
|
});
|
|
1331
1342
|
if (typeof formatter.formatRange === 'function') return formatter.formatRange(range.start, last);
|
|
@@ -1342,29 +1353,36 @@ export class Calendar extends Component {
|
|
|
1342
1353
|
_eventTime(event, day) {
|
|
1343
1354
|
if (event.allDay) return this.msg('calendar.allDay');
|
|
1344
1355
|
if (calendarEventSpansDays(event)) {
|
|
1345
|
-
if (sameCalendarDay(event.start, day)) return `${formatDateTime(event.start, this.
|
|
1346
|
-
if (sameCalendarDay(event.end, day)) return `→ ${formatDateTime(event.end, this.
|
|
1356
|
+
if (sameCalendarDay(event.start, day)) return `${formatDateTime(event.start, this._locale())} →`;
|
|
1357
|
+
if (sameCalendarDay(event.end, day)) return `→ ${formatDateTime(event.end, this._locale())}`;
|
|
1347
1358
|
return this.msg('calendar.allDay');
|
|
1348
1359
|
}
|
|
1349
|
-
const start = formatTimeDate(event.start, this.
|
|
1360
|
+
const start = formatTimeDate(event.start, this._locale());
|
|
1350
1361
|
if (event.end <= event.start) return start;
|
|
1351
|
-
return `${start}–${formatTimeDate(event.end, this.
|
|
1362
|
+
return `${start}–${formatTimeDate(event.end, this._locale())}`;
|
|
1352
1363
|
}
|
|
1353
1364
|
|
|
1354
1365
|
/** @param {CalendarEvent} event @returns {string} */
|
|
1355
1366
|
_eventLabel(event) {
|
|
1356
1367
|
const location = event.location ? `, ${event.location}` : '';
|
|
1357
|
-
|
|
1368
|
+
const label = this.msg('calendar.eventLabel', event.title,
|
|
1369
|
+
formatDateTime(event.start, this._locale()), formatDateTime(event.end, this._locale()));
|
|
1370
|
+
return `${label}${location}`;
|
|
1358
1371
|
}
|
|
1359
1372
|
|
|
1360
1373
|
/** @param {Date} date @returns {string} */
|
|
1361
1374
|
_dateTimeLabel(date) {
|
|
1362
|
-
return formatDateTime(date, this.
|
|
1375
|
+
return formatDateTime(date, this._locale());
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
/** @returns {string|string[]|undefined} The locale this calendar writes its dates in. */
|
|
1379
|
+
_locale() {
|
|
1380
|
+
return dateLocale(this.options.locale);
|
|
1363
1381
|
}
|
|
1364
1382
|
|
|
1365
1383
|
/** @param {Date} date @param {Intl.DateTimeFormatOptions} options @returns {string} */
|
|
1366
1384
|
_format(date, options) {
|
|
1367
|
-
return new Intl.DateTimeFormat(this.
|
|
1385
|
+
return new Intl.DateTimeFormat(this._locale(), options).format(date);
|
|
1368
1386
|
}
|
|
1369
1387
|
|
|
1370
1388
|
/** @returns {Date} */
|
|
@@ -1389,7 +1407,7 @@ export class Calendar extends Component {
|
|
|
1389
1407
|
if (target.dataset.slot) this._focusedSlot = target.dataset.slot;
|
|
1390
1408
|
}
|
|
1391
1409
|
|
|
1392
|
-
/** @returns {{eventId?: string, eventAction?: string, date?: string, slot?: string}|null} */
|
|
1410
|
+
/** @returns {{eventId?: string, eventAction?: string, date?: string, slot?: string, row?: string, column?: string}|null} */
|
|
1393
1411
|
_focusIdentity() {
|
|
1394
1412
|
const active = document.activeElement;
|
|
1395
1413
|
if (!(active instanceof HTMLElement) || !this.el.contains(active)) return null;
|
|
@@ -1397,16 +1415,33 @@ export class Calendar extends Component {
|
|
|
1397
1415
|
eventId: active.dataset.eventId,
|
|
1398
1416
|
eventAction: active.dataset.eventAction,
|
|
1399
1417
|
date: active.dataset.date,
|
|
1400
|
-
slot: active.dataset.slot
|
|
1418
|
+
slot: active.dataset.slot,
|
|
1419
|
+
row: active.dataset.rowIndex,
|
|
1420
|
+
column: active.dataset.dayIndex
|
|
1401
1421
|
};
|
|
1402
1422
|
}
|
|
1403
1423
|
|
|
1404
|
-
/** @param {{eventId?: string, eventAction?: string, date?: string, slot?: string}} identity @returns {void} */
|
|
1424
|
+
/** @param {{eventId?: string, eventAction?: string, date?: string, slot?: string, row?: string, column?: string}} identity @returns {void} */
|
|
1405
1425
|
_restoreFocus(identity) {
|
|
1406
1426
|
let target = null;
|
|
1407
1427
|
if (identity.eventId) target = this.el.querySelector(
|
|
1408
1428
|
`[data-event-id="${cssEscape(identity.eventId)}"][data-event-action="${identity.eventAction ?? 'activate'}"]`);
|
|
1409
|
-
if (!target && identity.slot)
|
|
1429
|
+
if (!target && identity.slot) {
|
|
1430
|
+
const slots = [...this.el.querySelectorAll('[data-slot]:not(:disabled)')];
|
|
1431
|
+
target = slots.find((slot) => slot.dataset.slot === identity.slot) ?? null;
|
|
1432
|
+
if (!target) {
|
|
1433
|
+
// Rows and columns describe local time and relative day, unlike the old absolute timestamp.
|
|
1434
|
+
const row = Number(identity.row) || 0;
|
|
1435
|
+
const column = Number(identity.column) || 0;
|
|
1436
|
+
target = slots.sort((left, right) =>
|
|
1437
|
+
Math.abs(Number(left.dataset.rowIndex) - row) - Math.abs(Number(right.dataset.rowIndex) - row)
|
|
1438
|
+
|| Math.abs(Number(left.dataset.dayIndex) - column) - Math.abs(Number(right.dataset.dayIndex) - column))[0] ?? null;
|
|
1439
|
+
}
|
|
1440
|
+
if (target) {
|
|
1441
|
+
for (const slot of slots) slot.tabIndex = slot === target ? 0 : -1;
|
|
1442
|
+
this._focusedSlot = target.dataset.slot;
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1410
1445
|
if (!target && identity.date) target = this.el.querySelector(`[data-date-cell][data-date="${cssEscape(identity.date)}"]`);
|
|
1411
1446
|
target?.focus?.();
|
|
1412
1447
|
}
|
|
@@ -1440,7 +1475,7 @@ export class Calendar extends Component {
|
|
|
1440
1475
|
if (!visible) return;
|
|
1441
1476
|
line.style.insetBlockStart = `${((minutes - min) / (max - min)) * 100}%`;
|
|
1442
1477
|
line.style.setProperty('--zx-calendar-now-day', String(dayIndex));
|
|
1443
|
-
line.querySelector('.zx-calendar__now-time').textContent = formatTimeMinutes(minutes, this.
|
|
1478
|
+
line.querySelector('.zx-calendar__now-time').textContent = formatTimeMinutes(minutes, this._locale());
|
|
1444
1479
|
}
|
|
1445
1480
|
|
|
1446
1481
|
/** @param {string} message @returns {void} */
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Component } from '../../core/component.js';
|
|
2
2
|
import { h } from '../../core/dom.js';
|
|
3
|
+
import { translate } from '../../core/i18n.js';
|
|
3
4
|
import { prefersReducedMotion, watchMotion } from '../../core/motion.js';
|
|
4
5
|
import { uid } from '../../core/util.js';
|
|
5
6
|
|
|
6
7
|
/** @typedef {{label?: string, data?: unknown[], [key: string]: unknown}} ChartDataset */
|
|
7
8
|
/** @typedef {{labels?: unknown[], datasets?: ChartDataset[], [key: string]: unknown}} ChartData */
|
|
9
|
+
/** @typedef {(key: string, ...args: unknown[]) => string} ChartText Resolves a message. */
|
|
8
10
|
/**
|
|
9
11
|
* @typedef {Object} ChartSpec
|
|
10
12
|
* @property {string} type Chart type.
|
|
@@ -43,13 +45,17 @@ import { uid } from '../../core/util.js';
|
|
|
43
45
|
* @property {string} [type='bar'] Chart type passed to the adapter.
|
|
44
46
|
* @property {ChartData} [data={labels: [], datasets: []}] Chart data.
|
|
45
47
|
* @property {Record<string, unknown>} [chartOptions={}] Engine-specific options.
|
|
46
|
-
* @property {string} [label=
|
|
48
|
+
* @property {string|null} [label=null] Accessible canvas and summary label; null or blank text reads
|
|
49
|
+
* the `chart.label` message ("Chart").
|
|
47
50
|
* @property {string} [description=''] Accessible description.
|
|
48
51
|
* @property {'hidden'|'visible'} [summary='hidden'] Semantic data-table presentation.
|
|
49
52
|
* @property {boolean} [loading=false] Initial loading state.
|
|
50
|
-
* @property {string} [emptyText
|
|
51
|
-
*
|
|
52
|
-
* @property {string} [
|
|
53
|
+
* @property {string|null} [emptyText] Empty-state text, by default the `chart.empty` message
|
|
54
|
+
* ("No chart data"). Null shows none.
|
|
55
|
+
* @property {string|null} [loadingText] Loading-state text, by default the `chart.loading` message
|
|
56
|
+
* ("Loading chart…"). Null shows none.
|
|
57
|
+
* @property {string|null} [errorText] Error fallback text, by default the `chart.error` message
|
|
58
|
+
* ("Unable to render chart"). Null shows none.
|
|
53
59
|
* @property {string} [aspectRatio='16 / 9'] Responsive container aspect ratio.
|
|
54
60
|
* @property {(event: CustomEvent<{instance: unknown}>) => void} [onready] Engine-ready listener.
|
|
55
61
|
* @property {(event: CustomEvent<{data: ChartData, type: string}>) => void} [onupdate] Update listener.
|
|
@@ -74,13 +80,14 @@ export class Chart extends Component {
|
|
|
74
80
|
type: 'bar',
|
|
75
81
|
data: { labels: [], datasets: [] },
|
|
76
82
|
chartOptions: {},
|
|
77
|
-
label:
|
|
83
|
+
label: null,
|
|
78
84
|
description: '',
|
|
79
85
|
summary: 'hidden',
|
|
80
86
|
loading: false,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
// Undefined rather than null, which shows nothing.
|
|
88
|
+
emptyText: undefined,
|
|
89
|
+
loadingText: undefined,
|
|
90
|
+
errorText: undefined,
|
|
84
91
|
aspectRatio: '16 / 9'
|
|
85
92
|
};
|
|
86
93
|
|
|
@@ -106,7 +113,7 @@ export class Chart extends Component {
|
|
|
106
113
|
this._adapter = this.options.adapter;
|
|
107
114
|
this._type = String(this.options.type || 'bar');
|
|
108
115
|
this._data = normalizeChartData(this.options.data);
|
|
109
|
-
this._label =
|
|
116
|
+
this._label = String(this.options.label ?? '').trim() || this.msg('chart.label');
|
|
110
117
|
this._chartOptions = cloneChartValue(this.options.chartOptions);
|
|
111
118
|
this._loading = Boolean(this.options.loading);
|
|
112
119
|
this._error = null;
|
|
@@ -199,7 +206,7 @@ export class Chart extends Component {
|
|
|
199
206
|
|
|
200
207
|
/** Shows an error and destroys the current engine. @param {unknown} error @returns {this} */
|
|
201
208
|
setError(error) {
|
|
202
|
-
this._error = error ?? new Error(
|
|
209
|
+
this._error = error ?? new Error(this._errorText());
|
|
203
210
|
this._hasError = true;
|
|
204
211
|
this._loading = false;
|
|
205
212
|
this._destroyHandle();
|
|
@@ -304,25 +311,27 @@ export class Chart extends Component {
|
|
|
304
311
|
const state = this._loading ? 'loading' : this._hasError ? 'error' : empty ? 'empty' : 'ready';
|
|
305
312
|
this.el.dataset.state = state;
|
|
306
313
|
this.refs.viewport.hidden = state !== 'ready';
|
|
314
|
+
const { loadingText = this.msg('chart.loading'), emptyText = this.msg('chart.empty') } = this.options;
|
|
307
315
|
let text = '';
|
|
308
|
-
if (state === 'loading') text = String(
|
|
309
|
-
else if (state === 'error') text = errorMessage(this._error, this.
|
|
310
|
-
else if (state === 'empty') text = String(
|
|
316
|
+
if (state === 'loading') text = String(loadingText ?? '');
|
|
317
|
+
else if (state === 'error') text = errorMessage(this._error, this._errorText());
|
|
318
|
+
else if (state === 'empty') text = String(emptyText ?? '');
|
|
311
319
|
this.refs.status.textContent = text;
|
|
312
320
|
this.refs.status.hidden = !text;
|
|
313
321
|
}
|
|
314
322
|
|
|
323
|
+
/** @returns {string} What an error without a message of its own says. */
|
|
324
|
+
_errorText() {
|
|
325
|
+
const { errorText = this.msg('chart.error') } = this.options;
|
|
326
|
+
return String(errorText ?? '');
|
|
327
|
+
}
|
|
328
|
+
|
|
315
329
|
/** @returns {void} */
|
|
316
330
|
_renderSummary() {
|
|
317
|
-
this.refs.summary.replaceChildren(
|
|
331
|
+
this.refs.summary.replaceChildren(summaryTable(this._data, this._label, (key, ...args) => this.msg(key, ...args)));
|
|
318
332
|
}
|
|
319
333
|
}
|
|
320
334
|
|
|
321
|
-
/** @param {unknown} value @returns {string} */
|
|
322
|
-
function normalizeChartLabel(value) {
|
|
323
|
-
return String(value ?? '').trim() || 'Chart';
|
|
324
|
-
}
|
|
325
|
-
|
|
326
335
|
/**
|
|
327
336
|
* Adapter for an injected Chart.js 4 constructor or namespace.
|
|
328
337
|
*/
|
|
@@ -463,17 +472,30 @@ export function isEmptyChartData(data) {
|
|
|
463
472
|
return !Array.isArray(data?.datasets) || !data.datasets.some((dataset) => Array.isArray(dataset?.data) && dataset.data.length > 0);
|
|
464
473
|
}
|
|
465
474
|
|
|
475
|
+
/** The catalogue, for the summary helpers when no Chart called them. @type {ChartText} */
|
|
476
|
+
const catalogueText = (key, ...args) => translate(key, args);
|
|
477
|
+
|
|
466
478
|
/**
|
|
467
479
|
* Builds the semantic table mirrored alongside the canvas.
|
|
480
|
+
* @param {ChartData} data Chart data.
|
|
481
|
+
* @param {string} [label] Caption, by default the `chart.summary` message ("Chart data").
|
|
482
|
+
* @returns {HTMLTableElement}
|
|
483
|
+
*/
|
|
484
|
+
export function chartSummaryTable(data, label = translate('chart.summary')) {
|
|
485
|
+
return summaryTable(data, label, catalogueText);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
468
489
|
* @param {ChartData} data Chart data.
|
|
469
490
|
* @param {string} label Caption.
|
|
491
|
+
* @param {ChartText} text Resolves the table's own words; a Chart passes its `msg()`.
|
|
470
492
|
* @returns {HTMLTableElement}
|
|
471
493
|
*/
|
|
472
|
-
|
|
473
|
-
const summary =
|
|
494
|
+
function summaryTable(data, label, text) {
|
|
495
|
+
const summary = summaryModel(data, text);
|
|
474
496
|
const table = /** @type {HTMLTableElement} */ (h('table', { class: 'zx-chart__table' },
|
|
475
497
|
h('caption', {}, label),
|
|
476
|
-
h('thead', {}, h('tr', {}, h('th', { scope: 'col' }, '
|
|
498
|
+
h('thead', {}, h('tr', {}, h('th', { scope: 'col' }, text('chart.summaryLabel')),
|
|
477
499
|
summary.headers.map((header) => h('th', { scope: 'col' }, header)))),
|
|
478
500
|
h('tbody', {}, summary.rows.map((row) => h('tr', {},
|
|
479
501
|
h('th', { scope: 'row' }, row.label),
|
|
@@ -487,12 +509,21 @@ export function chartSummaryTable(data, label = 'Chart data') {
|
|
|
487
509
|
* @returns {{headers: string[], rows: Array<{label: string, values: string[]}>}}
|
|
488
510
|
*/
|
|
489
511
|
export function chartSummaryModel(data) {
|
|
512
|
+
return summaryModel(data, catalogueText);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* @param {ChartData} data Chart data.
|
|
517
|
+
* @param {ChartText} text Resolves the name of an unnamed series.
|
|
518
|
+
* @returns {{headers: string[], rows: Array<{label: string, values: string[]}>}}
|
|
519
|
+
*/
|
|
520
|
+
function summaryModel(data, text) {
|
|
490
521
|
const datasets = Array.isArray(data?.datasets) ? data.datasets : [];
|
|
491
522
|
const labels = Array.isArray(data?.labels) ? data.labels : [];
|
|
492
523
|
const length = Math.max(labels.length,
|
|
493
524
|
...datasets.map((dataset) => Array.isArray(dataset.data) ? dataset.data.length : 0), 0);
|
|
494
525
|
return {
|
|
495
|
-
headers: datasets.map((dataset, index) => String(dataset.label ??
|
|
526
|
+
headers: datasets.map((dataset, index) => String(dataset.label ?? text('chart.series', index + 1))),
|
|
496
527
|
rows: Array.from({ length }, (_, index) => ({
|
|
497
528
|
label: String(labels[index] ?? index + 1),
|
|
498
529
|
values: datasets.map((dataset) => summaryValue(dataset.data?.[index]))
|
|
@@ -6,7 +6,8 @@ import { h } from '../../core/dom.js';
|
|
|
6
6
|
* @property {unknown} [value=''] Initial text.
|
|
7
7
|
* @property {string} [name=''] Form field name.
|
|
8
8
|
* @property {string} [language='text'] Language identifier shown to the user and exposed as data.
|
|
9
|
-
* @property {string} [label=
|
|
9
|
+
* @property {string|null} [label=null] Accessible editor label; null reads the `codeEditor.label`
|
|
10
|
+
* message ("Code editor").
|
|
10
11
|
* @property {string} [placeholder=''] Placeholder text.
|
|
11
12
|
* @property {number} [rows=12] Visible textarea rows.
|
|
12
13
|
* @property {string} [indent='\t'] Text inserted by Tab and removed by Shift+Tab.
|
|
@@ -42,7 +43,7 @@ export class CodeEditor extends Component {
|
|
|
42
43
|
value: '',
|
|
43
44
|
name: '',
|
|
44
45
|
language: 'text',
|
|
45
|
-
label:
|
|
46
|
+
label: null,
|
|
46
47
|
placeholder: '',
|
|
47
48
|
rows: 12,
|
|
48
49
|
indent: '\t',
|
|
@@ -73,7 +74,7 @@ export class CodeEditor extends Component {
|
|
|
73
74
|
this._input = /** @type {HTMLTextAreaElement} */ (h('textarea', {
|
|
74
75
|
class: 'zx-code-editor__input',
|
|
75
76
|
name: this.options.name ? String(this.options.name) : undefined,
|
|
76
|
-
ariaLabel: String(this.options.label ?? '
|
|
77
|
+
ariaLabel: String(this.options.label ?? this.msg('codeEditor.label')),
|
|
77
78
|
placeholder: String(this.options.placeholder ?? ''),
|
|
78
79
|
rows: normalizeRows(this.options.rows),
|
|
79
80
|
wrap: normalizeWrap(this.options.wrap),
|
|
@@ -84,6 +85,8 @@ export class CodeEditor extends Component {
|
|
|
84
85
|
autocapitalize: 'off'
|
|
85
86
|
}));
|
|
86
87
|
this._input.value = String(this.options.value ?? '');
|
|
88
|
+
this._committedValue = this._input.value;
|
|
89
|
+
this._indentEditing = false;
|
|
87
90
|
root.dataset.language = this._language;
|
|
88
91
|
root.dataset.readonly = String(Boolean(this.options.readOnly));
|
|
89
92
|
root.dataset.disabled = String(Boolean(this.options.disabled));
|
|
@@ -92,12 +95,16 @@ export class CodeEditor extends Component {
|
|
|
92
95
|
this._tabReleased = false;
|
|
93
96
|
|
|
94
97
|
this.listen(this._input, 'keydown', (event) => this._handleKeydown(event));
|
|
95
|
-
this.listen(this._input, 'blur', () => {
|
|
98
|
+
this.listen(this._input, 'blur', () => {
|
|
99
|
+
this._tabReleased = false;
|
|
100
|
+
this._commitValue();
|
|
101
|
+
});
|
|
96
102
|
this.listen(this._input, 'input', () => {
|
|
103
|
+
if (this._indentEditing) return;
|
|
97
104
|
this._updatePosition();
|
|
98
105
|
this.emit('input', { value: this.getValue() });
|
|
99
106
|
});
|
|
100
|
-
this.listen(this._input, 'change', () => this.
|
|
107
|
+
this.listen(this._input, 'change', () => this._commitValue());
|
|
101
108
|
for (const type of ['click', 'keyup', 'select', 'focus']) {
|
|
102
109
|
this.listen(this._input, type, () => this._updatePosition());
|
|
103
110
|
}
|
|
@@ -118,6 +125,7 @@ export class CodeEditor extends Component {
|
|
|
118
125
|
const next = String(value ?? '');
|
|
119
126
|
if (this._input.value === next) return this;
|
|
120
127
|
this._input.value = next;
|
|
128
|
+
this._committedValue = next;
|
|
121
129
|
this._updatePosition();
|
|
122
130
|
if (!silent) this.emit('change', { value: next });
|
|
123
131
|
return this;
|
|
@@ -170,20 +178,49 @@ export class CodeEditor extends Component {
|
|
|
170
178
|
event.shiftKey
|
|
171
179
|
);
|
|
172
180
|
if (result.value === this._input.value) return;
|
|
173
|
-
|
|
181
|
+
// Native editing commands retain the textarea's undo history; assigning value or using
|
|
182
|
+
// setRangeText does not. Replace only the changed range so surrounding edits stay intact.
|
|
183
|
+
const previous = this._input.value;
|
|
184
|
+
let from = 0;
|
|
185
|
+
while (from < previous.length && previous[from] === result.value[from]) from += 1;
|
|
186
|
+
let tail = 0;
|
|
187
|
+
while (tail < previous.length - from && tail < result.value.length - from
|
|
188
|
+
&& previous[previous.length - tail - 1] === result.value[result.value.length - tail - 1]) tail += 1;
|
|
189
|
+
this._input.setSelectionRange(from, previous.length - tail);
|
|
190
|
+
this._indentEditing = true;
|
|
191
|
+
try {
|
|
192
|
+
const document = this._input.ownerDocument;
|
|
193
|
+
const replacement = result.value.slice(from, result.value.length - tail);
|
|
194
|
+
document?.execCommand?.(replacement ? 'insertText' : 'delete', false, replacement);
|
|
195
|
+
} catch {
|
|
196
|
+
// An unavailable editing command falls through to the same plain-text fallback.
|
|
197
|
+
} finally {
|
|
198
|
+
this._indentEditing = false;
|
|
199
|
+
}
|
|
200
|
+
// Browsers without the editing command still indent and commit, but cannot add that change
|
|
201
|
+
// to native history. Keep this fallback separate from the supported native editing path.
|
|
202
|
+
if (this._input.value !== result.value) this._input.value = result.value;
|
|
174
203
|
this._input.setSelectionRange(result.start, result.end);
|
|
175
204
|
this._updatePosition();
|
|
176
205
|
this.emit('input', { value: this.getValue() });
|
|
177
206
|
}
|
|
178
207
|
|
|
208
|
+
/** Commits once, whether the browser emits change before blur or the fallback edited text. @returns {void} */
|
|
209
|
+
_commitValue() {
|
|
210
|
+
const value = this.getValue();
|
|
211
|
+
if (value === this._committedValue) return;
|
|
212
|
+
this._committedValue = value;
|
|
213
|
+
this.emit('change', { value });
|
|
214
|
+
}
|
|
215
|
+
|
|
179
216
|
/** @returns {void} */
|
|
180
217
|
_updatePosition() {
|
|
181
218
|
if (!this.options.status) return;
|
|
182
219
|
const position = editorPosition(this._input.value, this._input.selectionStart ?? 0,
|
|
183
220
|
this._input.selectionEnd ?? 0);
|
|
184
221
|
this._position.textContent = position.lines > 1
|
|
185
|
-
?
|
|
186
|
-
:
|
|
222
|
+
? this.msgPlural('codeEditor.selection', position.lines, position.line, position.column, position.lines)
|
|
223
|
+
: this.msg('codeEditor.position', position.line, position.column);
|
|
187
224
|
}
|
|
188
225
|
|
|
189
226
|
/** @returns {void} */
|
|
@@ -8,7 +8,7 @@ import { Field } from '../field/field.js';
|
|
|
8
8
|
export function registerCodeEditorFieldAdapter() {
|
|
9
9
|
Field.register('code', (field, options) => {
|
|
10
10
|
const editor = field.own(new CodeEditor(null, {
|
|
11
|
-
label: options.label ? String(options.label) :
|
|
11
|
+
label: options.label ? String(options.label) : null,
|
|
12
12
|
placeholder: options.placeholder,
|
|
13
13
|
readOnly: Boolean(options.props?.readOnly),
|
|
14
14
|
disabled: Boolean(options.disabled),
|