@zeyos/zx 5.6.0 → 5.7.1
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 +188 -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/checklist/checklist.d.ts +29 -0
- 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/dialog/dialog.d.ts +2 -2
- 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/modal/modal.d.ts +34 -8
- package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +3 -2
- package/dist/types/components/number-field/number-field.d.ts +41 -7
- 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/sheet/sheet.d.ts +2 -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 +15 -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 +16852 -15131
- 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 +520 -143
- package/dist/zx.esm.js +40940 -29684
- package/dist/zx.esm.min.js +36 -23
- package/dist/zx.global.js +40940 -29684
- package/dist/zx.global.min.js +36 -23
- package/dist/zx.layered.css +17315 -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 +909 -137
- package/docs/llms.md +1046 -80
- 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/button/button.css +24 -11
- 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/checklist/checklist.css +9 -1
- package/src/components/checklist/checklist.js +59 -3
- package/src/components/checklist/field-adapter.js +2 -11
- 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 +4 -5
- 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/modal/modal.js +62 -8
- 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 +98 -29
- 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/sheet/sheet.js +12 -5
- 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 +67 -4
- package/src/core/format.js +15 -13
- package/src/core/http.js +29 -20
- package/src/core/i18n.js +83 -10
- package/src/core/icons.js +13 -2
- 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/position.js +3 -2
- 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 { Component } from '../../core/component.js';
|
|
2
2
|
import { h, restoreTarget, snapshotTarget } from '../../core/dom.js';
|
|
3
|
+
import { formattingLocale } from '../../core/i18n.js';
|
|
3
4
|
import { icon } from '../../core/icons.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -10,6 +11,11 @@ import { icon } from '../../core/icons.js';
|
|
|
10
11
|
* @property {number} [step=1] Increment applied by the buttons and arrow keys.
|
|
11
12
|
* @property {number} [largeStep=10] Multiple of `step` applied by PageUp/PageDown.
|
|
12
13
|
* @property {number|null} [precision=null] Decimal places; derived from `step` when null.
|
|
14
|
+
* @property {boolean} [snap=true] Whether a typed or assigned value is moved onto the `step` grid.
|
|
15
|
+
* With `false` the value is kept exactly as entered — `step` is then only the increment of the
|
|
16
|
+
* buttons and arrow keys, and decimals are rounded only to an explicit `precision`. `min` and
|
|
17
|
+
* `max` still apply. Use it for values that are not multiples of anything: an identifier, a
|
|
18
|
+
* seed, a measurement.
|
|
13
19
|
* @property {boolean} [wrap=false] Whether stepping past a bound wraps to the other one.
|
|
14
20
|
* @property {string} [placeholder=''] Empty-state text.
|
|
15
21
|
* @property {string|null} [label=null] Accessible name for the spinbutton.
|
|
@@ -19,7 +25,7 @@ import { icon } from '../../core/icons.js';
|
|
|
19
25
|
* @property {boolean} [required=false] Whether an empty value is invalid.
|
|
20
26
|
* @property {string|null} [name=null] Native form field name.
|
|
21
27
|
* @property {boolean} [group=false] Whether to render thousands separators while idle.
|
|
22
|
-
* @property {string|null} [locale=null] Locale for formatting; defaults to the
|
|
28
|
+
* @property {string|null} [locale=null] Locale for formatting; defaults to the active language.
|
|
23
29
|
* @property {Record<string, string>|Record<string, Record<string, string>>} [msg] Localized messages.
|
|
24
30
|
* @property {(event: CustomEvent<{value: number|null}>) => void} [onchange] Committed-value listener.
|
|
25
31
|
* @property {(event: CustomEvent<{value: number|null}>) => void} [oninput] Per-keystroke listener.
|
|
@@ -47,6 +53,7 @@ export class NumberField extends Component {
|
|
|
47
53
|
step: 1,
|
|
48
54
|
largeStep: 10,
|
|
49
55
|
precision: null,
|
|
56
|
+
snap: true,
|
|
50
57
|
wrap: false,
|
|
51
58
|
placeholder: '',
|
|
52
59
|
label: null,
|
|
@@ -74,9 +81,13 @@ export class NumberField extends Component {
|
|
|
74
81
|
|
|
75
82
|
const step = normalizeStep(this.options.step);
|
|
76
83
|
this._step = step;
|
|
77
|
-
this.
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
this._snap = this.options.snap !== false;
|
|
85
|
+
const explicit = this.options.precision !== null && this.options.precision !== undefined;
|
|
86
|
+
this._precision = explicit
|
|
87
|
+
? Math.max(0, Math.trunc(Number(this.options.precision) || 0))
|
|
88
|
+
: decimalsOf(step);
|
|
89
|
+
// Without snapping, only a precision the application asked for may round a value.
|
|
90
|
+
this._fixedPrecision = this._snap || explicit;
|
|
80
91
|
|
|
81
92
|
const down = this._stepButton('down', 'minus');
|
|
82
93
|
const up = this._stepButton('up', 'plus');
|
|
@@ -85,7 +96,7 @@ export class NumberField extends Component {
|
|
|
85
96
|
class: 'zx-number-field__input',
|
|
86
97
|
type: 'text',
|
|
87
98
|
role: 'spinbutton',
|
|
88
|
-
inputMode: this._precision > 0 ? 'decimal' : 'numeric',
|
|
99
|
+
inputMode: this._precision > 0 || !this._fixedPrecision ? 'decimal' : 'numeric',
|
|
89
100
|
autocomplete: 'off',
|
|
90
101
|
spellcheck: false,
|
|
91
102
|
placeholder: String(this.options.placeholder ?? ''),
|
|
@@ -152,7 +163,8 @@ export class NumberField extends Component {
|
|
|
152
163
|
}
|
|
153
164
|
|
|
154
165
|
/**
|
|
155
|
-
* Sets the value,
|
|
166
|
+
* Sets the value, clamping it into `[min, max]` and — unless `snap` is off — moving it onto the
|
|
167
|
+
* `step` grid.
|
|
156
168
|
* @param {number|string|null} next Next value; empty strings and null clear the field.
|
|
157
169
|
* @param {{silent?: boolean}} [options={}] Set `silent` to suppress `change`.
|
|
158
170
|
* @returns {this}
|
|
@@ -276,6 +288,16 @@ export class NumberField extends Component {
|
|
|
276
288
|
_coerce(raw) {
|
|
277
289
|
const parsed = parseNumber(raw, this.options.group ? this._separators() : null);
|
|
278
290
|
if (parsed === null) return null;
|
|
291
|
+
if (!this._snap) {
|
|
292
|
+
// Past the digits a double can round to, rounding would only turn a tiny value into zero.
|
|
293
|
+
if (this._decimalsFor(parsed) > ROUNDABLE_DECIMALS) return clampNumber(parsed, this._rangeMin, this._rangeMax);
|
|
294
|
+
return snapNumber(parsed, {
|
|
295
|
+
min: this._rangeMin,
|
|
296
|
+
max: this._rangeMax,
|
|
297
|
+
step: 0,
|
|
298
|
+
precision: this._decimalsFor(parsed)
|
|
299
|
+
});
|
|
300
|
+
}
|
|
279
301
|
return snapNumber(parsed, {
|
|
280
302
|
min: this._rangeMin,
|
|
281
303
|
max: this._rangeMax,
|
|
@@ -295,12 +317,13 @@ export class NumberField extends Component {
|
|
|
295
317
|
const max = this._rangeMax;
|
|
296
318
|
// Step from whatever is in the field right now: typing 25 then pressing ArrowUp must give 26,
|
|
297
319
|
// not commit-value + 1.
|
|
298
|
-
const typed = parseNumber(this.refs.input.value);
|
|
320
|
+
const typed = parseNumber(this.refs.input.value, this.options.group ? this._separators(this._inputLocale) : null);
|
|
299
321
|
const current = typed ?? this._value;
|
|
300
322
|
const base = current === null ? (min ?? 0) : current;
|
|
301
323
|
// An empty field steps to the lower bound first, so the first click lands on a real value.
|
|
302
324
|
const start = current === null && count > 0 && min !== null ? min - this._step * count : base;
|
|
303
|
-
|
|
325
|
+
const decimals = this._decimalsFor(start);
|
|
326
|
+
let next = decimals > ROUNDABLE_DECIMALS ? start + this._step * count : round(start + this._step * count, decimals);
|
|
304
327
|
|
|
305
328
|
if (this.options.wrap && min !== null && max !== null) {
|
|
306
329
|
if (next > max) next = min;
|
|
@@ -311,24 +334,33 @@ export class NumberField extends Component {
|
|
|
311
334
|
}
|
|
312
335
|
|
|
313
336
|
/**
|
|
314
|
-
* The grouping and decimal separators of the
|
|
315
|
-
* @
|
|
337
|
+
* The grouping and decimal separators of the effective formatting locale.
|
|
338
|
+
* @param {string|string[]} [locale] Locale of the text being parsed.
|
|
339
|
+
* @returns {{group: string, decimal: string, minus: string, digits: Record<string, string>}}
|
|
316
340
|
*/
|
|
317
|
-
_separators() {
|
|
318
|
-
|
|
319
|
-
|
|
341
|
+
_separators(locale = formattingLocale(this.options.locale)) {
|
|
342
|
+
const key = String(locale);
|
|
343
|
+
if (this._localeSeparators && this._separatorLocale === key) return this._localeSeparators;
|
|
344
|
+
this._separatorLocale = key;
|
|
345
|
+
const parts = new Intl.NumberFormat(locale, {
|
|
320
346
|
minimumFractionDigits: 1
|
|
321
347
|
}).formatToParts(1234.5);
|
|
348
|
+
const digitFormatter = new Intl.NumberFormat(locale, { useGrouping: false });
|
|
322
349
|
this._localeSeparators = {
|
|
323
350
|
group: parts.find((part) => part.type === 'group')?.value ?? ',',
|
|
324
|
-
decimal: parts.find((part) => part.type === 'decimal')?.value ?? '.'
|
|
351
|
+
decimal: parts.find((part) => part.type === 'decimal')?.value ?? '.',
|
|
352
|
+
minus: digitFormatter.formatToParts(-1).find((part) => part.type === 'minusSign')?.value ?? '-',
|
|
353
|
+
digits: Object.fromEntries(Array.from({ length: 10 }, (_, value) => [
|
|
354
|
+
digitFormatter.formatToParts(value).find((part) => part.type === 'integer')?.value ?? String(value),
|
|
355
|
+
String(value)
|
|
356
|
+
]))
|
|
325
357
|
};
|
|
326
358
|
return this._localeSeparators;
|
|
327
359
|
}
|
|
328
360
|
|
|
329
361
|
/** @returns {void} */
|
|
330
362
|
_onInput() {
|
|
331
|
-
const parsed = parseNumber(this.refs.input.value, this.options.group ? this._separators() : null);
|
|
363
|
+
const parsed = parseNumber(this.refs.input.value, this.options.group ? this._separators(this._inputLocale) : null);
|
|
332
364
|
this._syncAria(parsed);
|
|
333
365
|
this.emit('input', { value: parsed });
|
|
334
366
|
}
|
|
@@ -359,12 +391,13 @@ export class NumberField extends Component {
|
|
|
359
391
|
|
|
360
392
|
/** Parses whatever the user typed and normalizes the displayed text. @returns {void} */
|
|
361
393
|
_commit() {
|
|
362
|
-
this.set(this.refs.input.value);
|
|
394
|
+
this.set(parseNumber(this.refs.input.value, this.options.group ? this._separators(this._inputLocale) : null));
|
|
363
395
|
}
|
|
364
396
|
|
|
365
397
|
/** @returns {void} */
|
|
366
398
|
_syncInput() {
|
|
367
399
|
const input = /** @type {HTMLInputElement} */ (this.refs.input);
|
|
400
|
+
this._inputLocale = formattingLocale(this.options.locale);
|
|
368
401
|
const text = this._value === null ? '' : this._format(this._value, this._editing);
|
|
369
402
|
if (input.value !== text) input.value = text;
|
|
370
403
|
this._syncAria(this._value);
|
|
@@ -401,17 +434,29 @@ export class NumberField extends Component {
|
|
|
401
434
|
*/
|
|
402
435
|
_format(value, editing) {
|
|
403
436
|
// Ungrouped fields use a plain machine format, which `parseNumber` reads heuristically.
|
|
404
|
-
|
|
437
|
+
const decimals = this._decimalsFor(value);
|
|
438
|
+
if (!this.options.group) return value.toFixed(decimals);
|
|
405
439
|
// Grouped fields stay in the locale's notation even while editing — only the thousands
|
|
406
440
|
// separators drop away. Display and input therefore always use the same decimal character,
|
|
407
441
|
// so a value the field rendered is always a value it can read back.
|
|
408
|
-
return new Intl.NumberFormat(this.options.locale
|
|
409
|
-
minimumFractionDigits:
|
|
410
|
-
maximumFractionDigits:
|
|
442
|
+
return new Intl.NumberFormat(formattingLocale(this.options.locale), {
|
|
443
|
+
minimumFractionDigits: decimals,
|
|
444
|
+
maximumFractionDigits: decimals,
|
|
411
445
|
useGrouping: !editing
|
|
412
446
|
}).format(value);
|
|
413
447
|
}
|
|
414
448
|
|
|
449
|
+
/**
|
|
450
|
+
* Decimal places a value is held and shown at: the field's precision, widened to the value's
|
|
451
|
+
* own decimals when nothing fixed the precision (`snap: false` without `precision`).
|
|
452
|
+
* @param {number} value Value in question.
|
|
453
|
+
* @returns {number}
|
|
454
|
+
*/
|
|
455
|
+
_decimalsFor(value) {
|
|
456
|
+
if (this._fixedPrecision) return this._precision;
|
|
457
|
+
return Math.min(MAX_DECIMALS, Math.max(this._precision, decimalsOf(value)));
|
|
458
|
+
}
|
|
459
|
+
|
|
415
460
|
/**
|
|
416
461
|
* @param {string} key Message key.
|
|
417
462
|
* @param {string} fallback Text used when the host has no translation.
|
|
@@ -464,7 +509,7 @@ export class NumberField extends Component {
|
|
|
464
509
|
* which is the best available guess for free-form typing.
|
|
465
510
|
*
|
|
466
511
|
* @param {unknown} raw Value to parse.
|
|
467
|
-
* @param {{group: string, decimal: string}|null} [separators=null] Known locale separators.
|
|
512
|
+
* @param {{group: string, decimal: string, minus?: string, digits?: Record<string, string>}|null} [separators=null] Known locale separators, minus sign, and digit mappings.
|
|
468
513
|
* @returns {number|null} The number, or null when the input is empty or unparseable.
|
|
469
514
|
*/
|
|
470
515
|
export function parseNumber(raw, separators = null) {
|
|
@@ -475,9 +520,14 @@ export function parseNumber(raw, separators = null) {
|
|
|
475
520
|
|
|
476
521
|
let normalized;
|
|
477
522
|
if (separators) {
|
|
478
|
-
normalized = text
|
|
523
|
+
normalized = text;
|
|
524
|
+
for (const [digit, ascii] of Object.entries(separators.digits ?? {})) {
|
|
525
|
+
normalized = normalized.split(digit).join(ascii);
|
|
526
|
+
}
|
|
527
|
+
normalized = normalized
|
|
479
528
|
.split(separators.group).join('')
|
|
480
529
|
.replace(separators.decimal, '.')
|
|
530
|
+
.replace(separators.minus ?? '-', '-')
|
|
481
531
|
.replace(/[^\d.\-+eE]/g, '');
|
|
482
532
|
} else {
|
|
483
533
|
// Keep the last separator as the decimal point; everything before it is grouping.
|
|
@@ -525,13 +575,32 @@ function normalizeStep(step) {
|
|
|
525
575
|
return Number.isFinite(value) && value > 0 ? value : 1;
|
|
526
576
|
}
|
|
527
577
|
|
|
528
|
-
/**
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
578
|
+
/** Most decimals a value is displayed with (the limit of `toFixed`). */
|
|
579
|
+
const MAX_DECIMALS = 100;
|
|
580
|
+
/** Most decimals `round()` works to; an unsnapped value needing more is left unrounded. */
|
|
581
|
+
const ROUNDABLE_DECIMALS = 15;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* @param {number} value Value to bound.
|
|
585
|
+
* @param {number|null} min Lower bound.
|
|
586
|
+
* @param {number|null} max Upper bound.
|
|
587
|
+
* @returns {number}
|
|
588
|
+
*/
|
|
589
|
+
function clampNumber(value, min, max) {
|
|
590
|
+
if (min !== null && value < min) return min;
|
|
591
|
+
if (max !== null && value > max) return max;
|
|
592
|
+
return value;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Decimal places in a number's shortest exact notation, exponent form included (`2.5e-7` has 8).
|
|
597
|
+
* @param {number} value Number to measure.
|
|
598
|
+
* @returns {number}
|
|
599
|
+
*/
|
|
600
|
+
function decimalsOf(value) {
|
|
601
|
+
const [mantissa, exponent = '0'] = String(value).toLowerCase().split('e');
|
|
602
|
+
const fraction = mantissa.split('.')[1]?.length ?? 0;
|
|
603
|
+
return Math.max(0, fraction - Number(exponent));
|
|
535
604
|
}
|
|
536
605
|
|
|
537
606
|
/**
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* PromptStarters — the starting points of an empty conversation: a group of buttons on the surface
|
|
3
|
+
* tone, each a title with a muted line of two at most beneath it. The root is the container its
|
|
4
|
+
* own narrow form asks about, so it fills whatever it is placed in.
|
|
5
|
+
*/
|
|
6
|
+
.zx-prompt-starters {
|
|
7
|
+
container: zx-prompt-starters / inline-size;
|
|
8
|
+
display: grid;
|
|
9
|
+
gap: var(--zx-space-3);
|
|
10
|
+
inline-size: 100%;
|
|
11
|
+
min-inline-size: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.zx-prompt-starters[hidden] {
|
|
15
|
+
display: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.zx-prompt-starters__heading {
|
|
19
|
+
margin: 0;
|
|
20
|
+
color: var(--zx-color-text-muted);
|
|
21
|
+
font-size: var(--zx-text-sm);
|
|
22
|
+
font-weight: var(--zx-weight-medium);
|
|
23
|
+
text-align: start;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.zx-prompt-starters__list {
|
|
27
|
+
display: grid;
|
|
28
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
29
|
+
gap: var(--zx-space-3);
|
|
30
|
+
min-inline-size: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.zx-prompt-starters[data-columns="1"] > .zx-prompt-starters__list {
|
|
34
|
+
grid-template-columns: minmax(0, 1fr);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@container zx-prompt-starters (inline-size < 32rem) {
|
|
38
|
+
.zx-prompt-starters[data-columns="auto"] > .zx-prompt-starters__list {
|
|
39
|
+
grid-template-columns: minmax(0, 1fr);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.zx-prompt-starters .zx-prompt-starters__item {
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: flex-start;
|
|
46
|
+
gap: var(--zx-space-2);
|
|
47
|
+
min-inline-size: 0;
|
|
48
|
+
padding: var(--zx-space-3) var(--zx-space-4);
|
|
49
|
+
border: 1px solid var(--zx-color-border-subtle);
|
|
50
|
+
border-radius: var(--zx-radius-lg);
|
|
51
|
+
background: var(--zx-color-bg-surface);
|
|
52
|
+
color: var(--zx-color-text);
|
|
53
|
+
text-align: start;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.zx-prompt-starters .zx-prompt-starters__item:hover {
|
|
57
|
+
border-color: var(--zx-color-border);
|
|
58
|
+
background: var(--zx-color-bg-hover);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.zx-prompt-starters .zx-prompt-starters__item:focus-visible {
|
|
62
|
+
outline-color: transparent;
|
|
63
|
+
box-shadow: var(--zx-focus-ring);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.zx-prompt-starters__item > .zx-icon {
|
|
67
|
+
flex: none;
|
|
68
|
+
margin-block-start: 2px;
|
|
69
|
+
color: var(--zx-color-text-subtle);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.zx-prompt-starters__copy {
|
|
73
|
+
display: grid;
|
|
74
|
+
gap: var(--zx-space-1);
|
|
75
|
+
min-inline-size: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.zx-prompt-starters__title {
|
|
79
|
+
font-weight: var(--zx-weight-medium);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.zx-prompt-starters__text {
|
|
83
|
+
display: -webkit-box;
|
|
84
|
+
overflow: hidden;
|
|
85
|
+
-webkit-box-orient: vertical;
|
|
86
|
+
-webkit-line-clamp: 2;
|
|
87
|
+
line-clamp: 2;
|
|
88
|
+
color: var(--zx-color-text-muted);
|
|
89
|
+
font-size: var(--zx-text-sm);
|
|
90
|
+
font-weight: 400;
|
|
91
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { Component } from '../../core/component.js';
|
|
3
|
+
import { h, restoreTarget, snapshotTarget } from '../../core/dom.js';
|
|
4
|
+
import { ICON_SIZE, icon } from '../../core/icons.js';
|
|
5
|
+
import { uid } from '../../core/util.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* One conversation starter.
|
|
9
|
+
* @typedef {Object} PromptStarter
|
|
10
|
+
* @property {string|number} id Stable identifier.
|
|
11
|
+
* @property {string} title What the starter is called: its visible title and accessible name.
|
|
12
|
+
* @property {string} text The prompt it stands for, handed back in `pick`. Shown beneath the title
|
|
13
|
+
* when there is no `description`.
|
|
14
|
+
* @property {string} [description] What is shown beneath the title in place of `text`.
|
|
15
|
+
* @property {string} [icon] Icon name drawn before the title.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {Object} PromptStartersOptions
|
|
20
|
+
* @property {PromptStarter[]} [items=[]] The starters. An entry without `id`, `title` or `text` is
|
|
21
|
+
* left out, as is a repeated id; any other field on an item is handed back in `pick`.
|
|
22
|
+
* @property {string|null} [label=null] Accessible name of the group. Omitted resolves
|
|
23
|
+
* `promptStarters.label`, English `Suggestions`.
|
|
24
|
+
* @property {'auto'|1|2} [columns='auto'] Columns of starters. `'auto'` is two, and one in a
|
|
25
|
+
* container narrower than 32rem.
|
|
26
|
+
* @property {1|2|3|4|5|6|null} [headingLevel=null] Shows `label` above the starters as a heading of
|
|
27
|
+
* this level, which then names the group. Null keeps the label for assistive technology only.
|
|
28
|
+
* @property {Record<string, string>|Record<string, Record<string, string>>} [msg] Localized messages.
|
|
29
|
+
* @property {(event: CustomEvent<{item: PromptStarter}>) => void} [onpick] Listener for a starter
|
|
30
|
+
* being picked.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
const MESSAGES = Object.freeze({
|
|
34
|
+
'promptStarters.label': 'Suggestions'
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Starting points for an empty conversation: a labelled group of buttons, each with a title and a
|
|
39
|
+
* muted line beneath it. A pick is only reported. Whether it fills the composer or sends at once
|
|
40
|
+
* is the application's decision, and PromptStarters never sends anything itself.
|
|
41
|
+
*
|
|
42
|
+
* @fires PromptStarters#pick
|
|
43
|
+
* @extends {Component<PromptStartersOptions>}
|
|
44
|
+
*/
|
|
45
|
+
export class PromptStarters extends Component {
|
|
46
|
+
static cssName = 'prompt-starters';
|
|
47
|
+
|
|
48
|
+
/** @type {Readonly<PromptStartersOptions>} */
|
|
49
|
+
static defaults = {
|
|
50
|
+
items: [],
|
|
51
|
+
label: null,
|
|
52
|
+
columns: 'auto',
|
|
53
|
+
headingLevel: null,
|
|
54
|
+
msg: MESSAGES
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** @returns {HTMLElement} */
|
|
58
|
+
render() {
|
|
59
|
+
const created = !this.el;
|
|
60
|
+
const root = /** @type {HTMLElement} */ (this.el ?? h('div'));
|
|
61
|
+
this.el = root;
|
|
62
|
+
this._original = created ? null : snapshotTarget(root);
|
|
63
|
+
if (!created) root.replaceChildren();
|
|
64
|
+
this._destroyed = false;
|
|
65
|
+
/** @type {PromptStarter[]} */
|
|
66
|
+
this._items = [];
|
|
67
|
+
|
|
68
|
+
const options = this.options;
|
|
69
|
+
const label = String(options.label ?? this.msg('promptStarters.label'));
|
|
70
|
+
const level = headingLevel(options.headingLevel);
|
|
71
|
+
root.setAttribute('role', 'group');
|
|
72
|
+
root.dataset.columns = columnsOf(options.columns);
|
|
73
|
+
this._list = h('div', { class: 'zx-prompt-starters__list' });
|
|
74
|
+
if (level) {
|
|
75
|
+
const id = uid('zx-prompt-starters-heading');
|
|
76
|
+
root.setAttribute('aria-labelledby', id);
|
|
77
|
+
root.append(h(`h${level}`, { class: 'zx-prompt-starters__heading', id }, label));
|
|
78
|
+
} else {
|
|
79
|
+
root.setAttribute('aria-label', label);
|
|
80
|
+
}
|
|
81
|
+
root.append(this._list);
|
|
82
|
+
|
|
83
|
+
this.listen(root, 'click', (event) => this._onClick(/** @type {MouseEvent} */ (event)));
|
|
84
|
+
this._build(options.items);
|
|
85
|
+
return root;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Replaces the starters. The focus on a starter stays on the starter with the same `id`. Emits
|
|
90
|
+
* nothing.
|
|
91
|
+
* @param {PromptStarter[]} items
|
|
92
|
+
* @returns {this}
|
|
93
|
+
*/
|
|
94
|
+
setItems(items) {
|
|
95
|
+
if (!this._destroyed) this._build(items);
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Removes what was drawn and stops listening. @returns {void} */
|
|
100
|
+
destroy() {
|
|
101
|
+
if (this._destroyed) return;
|
|
102
|
+
this._destroyed = true;
|
|
103
|
+
super.destroy();
|
|
104
|
+
if (this._original) restoreTarget(this.el, this._original);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @private
|
|
109
|
+
* @param {unknown} items
|
|
110
|
+
* @returns {void}
|
|
111
|
+
*/
|
|
112
|
+
_build(items) {
|
|
113
|
+
const list = /** @type {HTMLElement} */ (this._list);
|
|
114
|
+
const active = list.ownerDocument.activeElement;
|
|
115
|
+
const focused = active && list.contains(active)
|
|
116
|
+
? /** @type {HTMLElement|null} */ (active.closest('[data-starter]'))?.dataset.starter ?? null
|
|
117
|
+
: null;
|
|
118
|
+
this._items = normalizeStarters(items);
|
|
119
|
+
list.replaceChildren(...this._items.map((item) => this._button(item)));
|
|
120
|
+
/** @type {HTMLElement} */ (this.el).hidden = this._items.length === 0;
|
|
121
|
+
if (focused === null) return;
|
|
122
|
+
const buttons = /** @type {HTMLElement[]} */ (Array.from(list.children));
|
|
123
|
+
buttons.find((button) => button.dataset.starter === focused)?.focus();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* A starter's button: named by its title, described by the line beneath it.
|
|
128
|
+
* @private
|
|
129
|
+
* @param {PromptStarter} item
|
|
130
|
+
* @returns {HTMLElement}
|
|
131
|
+
*/
|
|
132
|
+
_button(item) {
|
|
133
|
+
const id = uid('zx-prompt-starter');
|
|
134
|
+
return h('button', {
|
|
135
|
+
type: 'button',
|
|
136
|
+
class: 'zx-prompt-starters__item',
|
|
137
|
+
dataset: { starter: String(item.id) },
|
|
138
|
+
'aria-labelledby': `${id}-title`,
|
|
139
|
+
'aria-describedby': `${id}-text`
|
|
140
|
+
},
|
|
141
|
+
item.icon ? icon(item.icon, { size: ICON_SIZE.control }) : null,
|
|
142
|
+
h('span', { class: 'zx-prompt-starters__copy' },
|
|
143
|
+
h('span', { class: 'zx-prompt-starters__title', id: `${id}-title` }, item.title),
|
|
144
|
+
h('span', { class: 'zx-prompt-starters__text', id: `${id}-text` }, item.description || item.text)));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @private
|
|
149
|
+
* @param {MouseEvent} event
|
|
150
|
+
* @returns {void}
|
|
151
|
+
* @fires PromptStarters#pick
|
|
152
|
+
*/
|
|
153
|
+
_onClick(event) {
|
|
154
|
+
const button = /** @type {HTMLElement|null} */ (/** @type {Element|null} */ (event.target)?.closest?.('[data-starter]'));
|
|
155
|
+
if (!button) return;
|
|
156
|
+
const item = this._items.find((entry) => String(entry.id) === button.dataset.starter);
|
|
157
|
+
if (item) this.emit('pick', { item: { ...item } });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* The starters as they are drawn: an entry without an `id`, a `title` or a `text` that says
|
|
163
|
+
* something is left out, a repeated id keeps its first entry, and `title`, `text` and `description`
|
|
164
|
+
* become strings. `text` keeps its spaces and line breaks, for a prompt that ends where the person
|
|
165
|
+
* goes on writing. Any other field the application put on an item is kept.
|
|
166
|
+
* @param {unknown} items
|
|
167
|
+
* @returns {PromptStarter[]}
|
|
168
|
+
*/
|
|
169
|
+
function normalizeStarters(items) {
|
|
170
|
+
/** @type {PromptStarter[]} */
|
|
171
|
+
const list = [];
|
|
172
|
+
const seen = new Set();
|
|
173
|
+
for (const entry of Array.isArray(items) ? items : []) {
|
|
174
|
+
if (!entry || typeof entry !== 'object') continue;
|
|
175
|
+
const { description, ...item } = /** @type {Partial<PromptStarter>} */ (entry);
|
|
176
|
+
const key = item.id == null ? '' : String(item.id);
|
|
177
|
+
const title = String(item.title ?? '').trim();
|
|
178
|
+
const text = String(item.text ?? '');
|
|
179
|
+
if (!key || !title || !text.trim() || seen.has(key)) continue;
|
|
180
|
+
seen.add(key);
|
|
181
|
+
const note = String(description ?? '').trim();
|
|
182
|
+
list.push({ ...item, id: /** @type {string|number} */ (item.id), title, text, ...(note ? { description: note } : {}) });
|
|
183
|
+
}
|
|
184
|
+
return list;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* The columns an option names; anything but `1` or `2` is `'auto'`.
|
|
189
|
+
* @param {unknown} value
|
|
190
|
+
* @returns {string}
|
|
191
|
+
*/
|
|
192
|
+
function columnsOf(value) {
|
|
193
|
+
return value === 1 || value === 2 ? String(value) : 'auto';
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* The heading level an option names, or null for none.
|
|
198
|
+
* @param {unknown} value
|
|
199
|
+
* @returns {number|null}
|
|
200
|
+
*/
|
|
201
|
+
function headingLevel(value) {
|
|
202
|
+
const level = Number(value);
|
|
203
|
+
return value != null && Number.isInteger(level) && level >= 1 && level <= 6 ? level : null;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** Fired when a starter is picked. Nothing is sent: the application decides what a pick does. @event PromptStarters#pick @type {CustomEvent<{item: PromptStarter}>} */
|
|
@@ -1,14 +1,18 @@
|
|
|
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 } from '../../core/icons.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @typedef {Object} ProseAnchorsOptions
|
|
7
8
|
* @property {string} [selector='h2[id], h3[id], h4[id]'] The headings that get a link, inside a
|
|
8
9
|
* `.zx-prose` under the root. A heading without an `id` has nothing to link to and is skipped.
|
|
9
|
-
* @property {string} [label
|
|
10
|
-
*
|
|
11
|
-
* @property {string} [
|
|
10
|
+
* @property {string|null} [label] The link's accessible name; `%1` is the heading. By default the
|
|
11
|
+
* `prose.copyLinkTo` message ("Copy link to %1"). Null gives none.
|
|
12
|
+
* @property {string|null} [title] The link's tooltip, by default the `prose.copyLink` message
|
|
13
|
+
* ("Copy link"). Null gives none.
|
|
14
|
+
* @property {string|null} [feedback] What the live region says after a copy, by default the
|
|
15
|
+
* `prose.copied` message ("Link copied"). Null says nothing.
|
|
12
16
|
* @property {number} [feedbackDuration=2000] Milliseconds the tick and the message stay.
|
|
13
17
|
* @property {(id: string) => string} [href] The address copied for a heading id. Defaults to the
|
|
14
18
|
* current address with its hash replaced (`sectionHref(location.href, id)`).
|
|
@@ -23,12 +27,9 @@ import { icon } from '../../core/icons.js';
|
|
|
23
27
|
* @property {() => void} destroy Removes every link, the live region, and the listener.
|
|
24
28
|
*/
|
|
25
29
|
|
|
26
|
-
/** @type {Readonly<Required<Omit<ProseAnchorsOptions, 'href'|'oncopy'>>>} */
|
|
30
|
+
/** @type {Readonly<Required<Omit<ProseAnchorsOptions, 'href'|'oncopy'|'label'|'title'|'feedback'>>>} */
|
|
27
31
|
const defaults = Object.freeze({
|
|
28
32
|
selector: 'h2[id], h3[id], h4[id]',
|
|
29
|
-
label: 'Copy link to %1',
|
|
30
|
-
title: 'Copy link',
|
|
31
|
-
feedback: 'Link copied',
|
|
32
33
|
feedbackDuration: 2000
|
|
33
34
|
});
|
|
34
35
|
|
|
@@ -65,6 +66,9 @@ export function proseAnchors(root, options = {}) {
|
|
|
65
66
|
const target = typeof root === 'string' ? document.querySelector(root) : root;
|
|
66
67
|
if (!(target instanceof Element)) throw new TypeError('proseAnchors root could not be resolved');
|
|
67
68
|
const settings = { ...defaults, ...options };
|
|
69
|
+
const {
|
|
70
|
+
label = translate('prose.copyLinkTo'), title = translate('prose.copyLink'), feedback = translate('prose.copied')
|
|
71
|
+
} = settings;
|
|
68
72
|
const abort = new AbortController();
|
|
69
73
|
/** @type {Map<HTMLAnchorElement, HTMLElement>} Link → its heading. */
|
|
70
74
|
const anchors = new Map();
|
|
@@ -95,8 +99,8 @@ export function proseAnchors(root, options = {}) {
|
|
|
95
99
|
const anchor = /** @type {HTMLAnchorElement} */ (h('a', {
|
|
96
100
|
class: 'zx-prose__anchor',
|
|
97
101
|
href: `#${heading.id}`,
|
|
98
|
-
ariaLabel: String(
|
|
99
|
-
title: String(
|
|
102
|
+
ariaLabel: String(label ?? '').replace('%1', text),
|
|
103
|
+
title: String(title ?? ''),
|
|
100
104
|
'data-zx-reveal': ''
|
|
101
105
|
}, icon('link-2')));
|
|
102
106
|
if (!heading.hasAttribute('data-zx-reveal-host')) {
|
|
@@ -126,7 +130,7 @@ export function proseAnchors(root, options = {}) {
|
|
|
126
130
|
anchor.dataset.copied = 'true';
|
|
127
131
|
anchor.replaceChildren(icon('check'));
|
|
128
132
|
if (!status.isConnected) target.append(status);
|
|
129
|
-
status.textContent = String(
|
|
133
|
+
status.textContent = String(feedback ?? '');
|
|
130
134
|
timer = setTimeout(() => {
|
|
131
135
|
delete anchor.dataset.copied;
|
|
132
136
|
anchor.replaceChildren(icon('link-2'));
|