@zeyos/zx 5.7.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 +34 -0
- package/dist/types/components/checklist/checklist.d.ts +29 -0
- package/dist/types/components/dialog/dialog.d.ts +2 -2
- package/dist/types/components/modal/modal.d.ts +34 -8
- package/dist/types/components/number-field/number-field.d.ts +24 -1
- package/dist/types/components/sheet/sheet.d.ts +2 -2
- package/dist/types/core/dom.d.ts +14 -0
- package/dist/zx-zeyos.esm.js +131 -32
- package/dist/zx-zeyos.esm.min.js +4 -4
- package/dist/zx.css +22 -9
- package/dist/zx.esm.js +175 -43
- package/dist/zx.esm.min.js +24 -24
- package/dist/zx.global.js +175 -43
- package/dist/zx.global.min.js +24 -24
- package/dist/zx.layered.css +22 -9
- package/dist/zx.layered.min.css +1 -1
- package/dist/zx.min.css +1 -1
- package/docs/api.json +47 -5
- package/docs/llms.md +28 -9
- package/package.json +1 -1
- package/src/components/button/button.css +24 -11
- 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/dialog/dialog.js +3 -4
- package/src/components/modal/modal.js +62 -8
- package/src/components/number-field/number-field.js +69 -16
- package/src/components/sheet/sheet.js +12 -5
- package/src/core/dom.js +45 -2
- package/src/core/icons.js +13 -2
- package/src/core/position.js +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,40 @@ and friends remain the complete record.
|
|
|
8
8
|
|
|
9
9
|
## Unreleased
|
|
10
10
|
|
|
11
|
+
## 5.7.1 — 2026-11-13
|
|
12
|
+
|
|
13
|
+
One preventable `cancel` for every way of dismissing an overlay, exact values in NumberField, a
|
|
14
|
+
lockable Checklist, and fixes for strict Content Security Policies and the pressed button state.
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- **`cancel` covers every dismissal.** Modal, Dialog and Sheet now raise the preventable `cancel`
|
|
19
|
+
for the header ✕, a backdrop click, a press outside a non-modal Sheet and a dismissing drag, not
|
|
20
|
+
only for Escape, and `event.detail.reason` names the gesture (`'escape'`, `'close-button'`,
|
|
21
|
+
`'button'`, `'backdrop'`, `'outside'`, `'drag'`). One listener is now enough for an "unsaved
|
|
22
|
+
changes" check. A programmatic `close()` still raises none.
|
|
23
|
+
- **`NumberField` `snap: false`** keeps a typed or assigned value exactly as entered instead of
|
|
24
|
+
moving it onto the `step` grid; `step` then only sets the button and arrow-key increment.
|
|
25
|
+
- **`Checklist`** `label` and `disabled` options, `setLabel()`, `enable()`, `disable()` and
|
|
26
|
+
`isDisabled()`.
|
|
27
|
+
- Bundled icons `download`, `box-archive`, `pencil` and `pen-to-square`, with `archive` and `edit`
|
|
28
|
+
as aliases. A glyph registered under an alias name with `registerIcons()` keeps precedence.
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
|
|
32
|
+
- A listener that treated `cancel` as "Escape was pressed" now also runs for the other dismissal
|
|
33
|
+
gestures; read `event.detail.reason` to tell them apart.
|
|
34
|
+
- A pressed button (`aria-pressed="true"`) has a stronger neutral fill and a frame that holds 3:1
|
|
35
|
+
against its neighbours in both themes. A pressed `ghost` button gains the frame too.
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- Escape on a modal overlay whose `cancel` was prevented no longer closes it on the third press.
|
|
40
|
+
- Anchored popups (Select, TagPicker, Dropdown, Tooltip, Datebox, Composer) no longer write an
|
|
41
|
+
empty `style=""` attribute on close, which a `style-src` policy without `'unsafe-inline'`
|
|
42
|
+
blocked and reported. Restoring an enhanced target's inline style no longer writes the attribute
|
|
43
|
+
either.
|
|
44
|
+
|
|
11
45
|
## 5.7.0 — 2026-11-09
|
|
12
46
|
|
|
13
47
|
Locale and country Select presets, complete English/German catalogues and plural messages,
|
|
@@ -29,6 +29,15 @@ export type ChecklistOptions = {
|
|
|
29
29
|
* Fallback initial checked state.
|
|
30
30
|
*/
|
|
31
31
|
defaultChecked?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Heading text, which is also the group's accessible name;
|
|
34
|
+
* null uses the `checklist.label` message.
|
|
35
|
+
*/
|
|
36
|
+
label?: string | null;
|
|
37
|
+
/**
|
|
38
|
+
* Whether the search field and every checkbox are disabled.
|
|
39
|
+
*/
|
|
40
|
+
disabled?: boolean;
|
|
32
41
|
/**
|
|
33
42
|
* Whether the heading is left out. The group keeps the
|
|
34
43
|
* heading text as its accessible name (`aria-label`); a Field labelling the checklist names it
|
|
@@ -68,6 +77,9 @@ export type ChecklistLoadedDetail = {
|
|
|
68
77
|
* @property {boolean} [search=true] Whether the search field is shown.
|
|
69
78
|
* @property {number} [height=280] Maximum list height in pixels.
|
|
70
79
|
* @property {boolean} [defaultChecked=false] Fallback initial checked state.
|
|
80
|
+
* @property {string|null} [label=null] Heading text, which is also the group's accessible name;
|
|
81
|
+
* null uses the `checklist.label` message.
|
|
82
|
+
* @property {boolean} [disabled=false] Whether the search field and every checkbox are disabled.
|
|
71
83
|
* @property {boolean} [hideLabel=false] Whether the heading is left out. The group keeps the
|
|
72
84
|
* heading text as its accessible name (`aria-label`); a Field labelling the checklist names it
|
|
73
85
|
* instead, which is why the `checklist` field type sets this.
|
|
@@ -95,6 +107,7 @@ export declare class Checklist extends Component<ChecklistOptions> {
|
|
|
95
107
|
_active: boolean;
|
|
96
108
|
_originalChildren: any[] | ChildNode[];
|
|
97
109
|
_originalAttributes: Map<any, any>;
|
|
110
|
+
_disabled: boolean;
|
|
98
111
|
static cssName: string;
|
|
99
112
|
/** @type {ChecklistOptions} */
|
|
100
113
|
static defaults: ChecklistOptions;
|
|
@@ -106,6 +119,18 @@ export declare class Checklist extends Component<ChecklistOptions> {
|
|
|
106
119
|
* @returns {this}
|
|
107
120
|
*/
|
|
108
121
|
setItems(items: ChecklistItem[]): this;
|
|
122
|
+
/**
|
|
123
|
+
* Replaces the heading text, which is also the group's accessible name.
|
|
124
|
+
* @param {string|null} label New label; null restores the `checklist.label` message.
|
|
125
|
+
* @returns {this}
|
|
126
|
+
*/
|
|
127
|
+
setLabel(label: string | null): this;
|
|
128
|
+
/** Enables the search field and the checkboxes. @returns {this} */
|
|
129
|
+
enable(): this;
|
|
130
|
+
/** Disables the search field and the checkboxes; values can still be set programmatically. @returns {this} */
|
|
131
|
+
disable(): this;
|
|
132
|
+
/** Whether the checklist is disabled. @returns {boolean} */
|
|
133
|
+
isDisabled(): boolean;
|
|
109
134
|
/** Returns checked IDs in item order. @returns {unknown[]} */
|
|
110
135
|
getValues(): unknown[];
|
|
111
136
|
/**
|
|
@@ -137,6 +162,10 @@ export declare class Checklist extends Component<ChecklistOptions> {
|
|
|
137
162
|
_replaceItems(items: ChecklistItem[]): void;
|
|
138
163
|
/** @returns {void} */
|
|
139
164
|
_renderItems(): void;
|
|
165
|
+
/** @returns {void} */
|
|
166
|
+
_syncDisabled(): void;
|
|
167
|
+
/** @param {string|null|undefined} label @returns {string} */
|
|
168
|
+
_labelText(label: string | null | undefined): string;
|
|
140
169
|
/** @param {Set<unknown>} next @returns {void} */
|
|
141
170
|
_replaceChecked(next: Set<unknown>): void;
|
|
142
171
|
/** @param {ChecklistItem} item @returns {unknown} */
|
|
@@ -66,7 +66,7 @@ export type DialogOptions = {
|
|
|
66
66
|
/**
|
|
67
67
|
* Cancel event listener.
|
|
68
68
|
*/
|
|
69
|
-
oncancel?: (event: CustomEvent<
|
|
69
|
+
oncancel?: (event: CustomEvent<import('../modal/modal.js').ModalCancelDetail>) => void;
|
|
70
70
|
};
|
|
71
71
|
export type DialogViewOptions = {
|
|
72
72
|
/**
|
|
@@ -192,7 +192,7 @@ export type PromptOptions = {
|
|
|
192
192
|
* @property {Element|string|null} [scope=null] Element whose nearest Zx theme scope owns the overlay; defaults to the opener. Resolved on every open, so a scope connected after construction still owns it.
|
|
193
193
|
* @property {(event: CustomEvent<Record<string, never>>) => void} [onopen] Open event listener.
|
|
194
194
|
* @property {(event: CustomEvent<{result: unknown}>) => void} [onclose] Close event listener.
|
|
195
|
-
* @property {(event: CustomEvent<
|
|
195
|
+
* @property {(event: CustomEvent<import('../modal/modal.js').ModalCancelDetail>) => void} [oncancel] Cancel event listener.
|
|
196
196
|
*/
|
|
197
197
|
/**
|
|
198
198
|
* @typedef {Object} DialogViewOptions
|
|
@@ -15,7 +15,8 @@ export type ModalOptions = {
|
|
|
15
15
|
*/
|
|
16
16
|
closable?: boolean;
|
|
17
17
|
/**
|
|
18
|
-
* Whether a backdrop click closes the modal.
|
|
18
|
+
* Whether a backdrop click closes the modal. Like every
|
|
19
|
+
* dismissal by the reader, it raises a preventable `cancel` first.
|
|
19
20
|
*/
|
|
20
21
|
lightDismiss?: boolean;
|
|
21
22
|
/**
|
|
@@ -39,20 +40,32 @@ export type ModalOptions = {
|
|
|
39
40
|
/**
|
|
40
41
|
* Cancel event listener.
|
|
41
42
|
*/
|
|
42
|
-
oncancel?: (event: CustomEvent<
|
|
43
|
+
oncancel?: (event: CustomEvent<ModalCancelDetail>) => void;
|
|
44
|
+
};
|
|
45
|
+
export type ModalDismissReason = 'escape' | 'close-button' | 'button' | 'backdrop' | 'outside' | 'drag';
|
|
46
|
+
export type ModalCancelDetail = {
|
|
47
|
+
reason: ModalDismissReason;
|
|
43
48
|
};
|
|
44
49
|
/**
|
|
45
50
|
* @typedef {Object} ModalOptions
|
|
46
51
|
* @property {Node|string|number|{toElement: () => Node|null}|null} [content=null] Modal content.
|
|
47
52
|
* @property {string|number} [width='auto'] CSS width, or a pixel width when numeric.
|
|
48
53
|
* @property {boolean} [closable=true] Whether Escape may close the modal.
|
|
49
|
-
* @property {boolean} [lightDismiss=false] Whether a backdrop click closes the modal.
|
|
54
|
+
* @property {boolean} [lightDismiss=false] Whether a backdrop click closes the modal. Like every
|
|
55
|
+
* dismissal by the reader, it raises a preventable `cancel` first.
|
|
50
56
|
* @property {boolean} [destroyOnClose=false] Whether to destroy the modal after it closes.
|
|
51
57
|
* @property {Element|string|null} [scope=null] Element whose nearest Zx theme scope owns the overlay; defaults to the opener. Resolved on every open, so a scope connected after construction still owns it.
|
|
52
58
|
* @property {(event: CustomEvent<Record<string, never>>) => void} [onopen] Open event listener.
|
|
53
59
|
* @property {(event: CustomEvent<{result: unknown}>) => void} [onclose] Close event listener.
|
|
54
|
-
* @property {(event: CustomEvent<
|
|
60
|
+
* @property {(event: CustomEvent<ModalCancelDetail>) => void} [oncancel] Cancel event listener.
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* What the reader did to ask for dismissal: pressed Escape, used a header close button, chose a
|
|
64
|
+
* footer button whose action is `'cancel'`, clicked the backdrop, pressed outside a non-modal
|
|
65
|
+
* overlay, or dragged it away.
|
|
66
|
+
* @typedef {'escape'|'close-button'|'button'|'backdrop'|'outside'|'drag'} ModalDismissReason
|
|
55
67
|
*/
|
|
68
|
+
/** @typedef {{reason: ModalDismissReason}} ModalCancelDetail */
|
|
56
69
|
/**
|
|
57
70
|
* Thin native-dialog overlay with lifecycle-safe content and dismissal behavior.
|
|
58
71
|
* The constructor always creates and appends a new dialog; its target argument is ignored.
|
|
@@ -114,12 +127,23 @@ export declare class Modal extends Component<ModalOptions> {
|
|
|
114
127
|
* Describes the current presentation for the overlay stack, or returns null to stay off it.
|
|
115
128
|
*
|
|
116
129
|
* The kind is read from the platform like `aria-modal` is: a `showModal()` dialog is `modal`,
|
|
117
|
-
* and
|
|
118
|
-
* presenting that way adds the Escape and outside-press
|
|
130
|
+
* and the stack leaves its Escape alone (this class answers it, see the constructor); anything
|
|
131
|
+
* else is `non-modal`, and a subclass presenting that way adds the Escape and outside-press
|
|
132
|
+
* handling it wants.
|
|
119
133
|
* @returns {import('../../core/overlay-stack.js').OverlayEntryOptions|null}
|
|
120
134
|
* @protected
|
|
121
135
|
*/
|
|
122
136
|
protected _overlayEntry(): import('../../core/overlay-stack.js').OverlayEntryOptions | null;
|
|
137
|
+
/**
|
|
138
|
+
* Asks to close on the reader's behalf: emits a preventable `cancel` naming what they did, and
|
|
139
|
+
* closes unless a listener prevented it. Every dismissal gesture goes through here; `close()`
|
|
140
|
+
* itself stays unconditional, for the application's own decisions.
|
|
141
|
+
* @param {ModalDismissReason} reason What the reader did.
|
|
142
|
+
* @returns {boolean} Whether the overlay is closing.
|
|
143
|
+
* @fires Modal#cancel
|
|
144
|
+
* @protected
|
|
145
|
+
*/
|
|
146
|
+
protected _requestDismiss(reason: ModalDismissReason): boolean;
|
|
123
147
|
/**
|
|
124
148
|
* Re-registers the current presentation on the overlay stack: called after every presentation,
|
|
125
149
|
* including a subclass's change of address that bypasses `open()`.
|
|
@@ -237,9 +261,11 @@ export declare class Modal extends Component<ModalOptions> {
|
|
|
237
261
|
* @type {CustomEvent<{result: unknown}>}
|
|
238
262
|
*/
|
|
239
263
|
/**
|
|
240
|
-
* Fired when
|
|
264
|
+
* Fired when the reader asks to dismiss the modal — Escape, a header close button, a `'cancel'`
|
|
265
|
+
* footer button, a backdrop click, a press outside a non-modal overlay, a drag — with the gesture
|
|
266
|
+
* in `detail.reason`. Preventing it keeps the modal open. A programmatic `close()` does not raise it.
|
|
241
267
|
* @event Modal#cancel
|
|
242
|
-
* @type {CustomEvent<
|
|
268
|
+
* @type {CustomEvent<ModalCancelDetail>}
|
|
243
269
|
*/
|
|
244
270
|
/**
|
|
245
271
|
* Picks the control initial focus belongs on inside an overlay panel: an `autofocus` control when
|
|
@@ -24,6 +24,14 @@ export type NumberFieldOptions = {
|
|
|
24
24
|
* Decimal places; derived from `step` when null.
|
|
25
25
|
*/
|
|
26
26
|
precision?: number | null;
|
|
27
|
+
/**
|
|
28
|
+
* Whether a typed or assigned value is moved onto the `step` grid.
|
|
29
|
+
* With `false` the value is kept exactly as entered — `step` is then only the increment of the
|
|
30
|
+
* buttons and arrow keys, and decimals are rounded only to an explicit `precision`. `min` and
|
|
31
|
+
* `max` still apply. Use it for values that are not multiples of anything: an identifier, a
|
|
32
|
+
* seed, a measurement.
|
|
33
|
+
*/
|
|
34
|
+
snap?: boolean;
|
|
27
35
|
/**
|
|
28
36
|
* Whether stepping past a bound wraps to the other one.
|
|
29
37
|
*/
|
|
@@ -89,6 +97,11 @@ export type NumberFieldOptions = {
|
|
|
89
97
|
* @property {number} [step=1] Increment applied by the buttons and arrow keys.
|
|
90
98
|
* @property {number} [largeStep=10] Multiple of `step` applied by PageUp/PageDown.
|
|
91
99
|
* @property {number|null} [precision=null] Decimal places; derived from `step` when null.
|
|
100
|
+
* @property {boolean} [snap=true] Whether a typed or assigned value is moved onto the `step` grid.
|
|
101
|
+
* With `false` the value is kept exactly as entered — `step` is then only the increment of the
|
|
102
|
+
* buttons and arrow keys, and decimals are rounded only to an explicit `precision`. `min` and
|
|
103
|
+
* `max` still apply. Use it for values that are not multiples of anything: an identifier, a
|
|
104
|
+
* seed, a measurement.
|
|
92
105
|
* @property {boolean} [wrap=false] Whether stepping past a bound wraps to the other one.
|
|
93
106
|
* @property {string} [placeholder=''] Empty-state text.
|
|
94
107
|
* @property {string|null} [label=null] Accessible name for the spinbutton.
|
|
@@ -122,7 +135,9 @@ export declare class NumberField extends Component<NumberFieldOptions> {
|
|
|
122
135
|
_createdRoot: boolean;
|
|
123
136
|
_snapshot: import("../../core/dom.js").TargetSnapshot;
|
|
124
137
|
_step: number;
|
|
138
|
+
_snap: boolean;
|
|
125
139
|
_precision: number;
|
|
140
|
+
_fixedPrecision: boolean;
|
|
126
141
|
_min: number;
|
|
127
142
|
_max: number;
|
|
128
143
|
_separatorLocale: string;
|
|
@@ -150,7 +165,8 @@ export declare class NumberField extends Component<NumberFieldOptions> {
|
|
|
150
165
|
*/
|
|
151
166
|
get(): number | null;
|
|
152
167
|
/**
|
|
153
|
-
* Sets the value,
|
|
168
|
+
* Sets the value, clamping it into `[min, max]` and — unless `snap` is off — moving it onto the
|
|
169
|
+
* `step` grid.
|
|
154
170
|
* @param {number|string|null} next Next value; empty strings and null clear the field.
|
|
155
171
|
* @param {{silent?: boolean}} [options={}] Set `silent` to suppress `change`.
|
|
156
172
|
* @returns {this}
|
|
@@ -250,6 +266,13 @@ export declare class NumberField extends Component<NumberFieldOptions> {
|
|
|
250
266
|
* @returns {string}
|
|
251
267
|
*/
|
|
252
268
|
_format(value: number, editing: boolean): string;
|
|
269
|
+
/**
|
|
270
|
+
* Decimal places a value is held and shown at: the field's precision, widened to the value's
|
|
271
|
+
* own decimals when nothing fixed the precision (`snap: false` without `precision`).
|
|
272
|
+
* @param {number} value Value in question.
|
|
273
|
+
* @returns {number}
|
|
274
|
+
*/
|
|
275
|
+
_decimalsFor(value: number): number;
|
|
253
276
|
/**
|
|
254
277
|
* @param {string} key Message key.
|
|
255
278
|
* @param {string} fallback Text used when the host has no translation.
|
|
@@ -97,7 +97,7 @@ export type SheetOptions = {
|
|
|
97
97
|
/**
|
|
98
98
|
* Cancel event listener.
|
|
99
99
|
*/
|
|
100
|
-
oncancel?: (event: CustomEvent<
|
|
100
|
+
oncancel?: (event: CustomEvent<import('../modal/modal.js').ModalCancelDetail>) => void;
|
|
101
101
|
/**
|
|
102
102
|
* Resize listener.
|
|
103
103
|
*/
|
|
@@ -145,7 +145,7 @@ export type SheetOptions = {
|
|
|
145
145
|
* @property {Element|string|null} [scope=null] Element whose nearest Zx theme scope owns a floating sheet; defaults to the opener.
|
|
146
146
|
* @property {(event: CustomEvent<Record<string, never>>) => void} [onopen] Open event listener.
|
|
147
147
|
* @property {(event: CustomEvent<{result: unknown}>) => void} [onclose] Close event listener.
|
|
148
|
-
* @property {(event: CustomEvent<
|
|
148
|
+
* @property {(event: CustomEvent<import('../modal/modal.js').ModalCancelDetail>) => void} [oncancel] Cancel event listener.
|
|
149
149
|
* @property {(event: CustomEvent<{size: number, ratio: number}>) => void} [onresize] Resize listener.
|
|
150
150
|
* @property {(event: CustomEvent<{docked: boolean, dock: import('../dock/dock.js').Dock|null}>) => void} [ondockchange] Dock-state listener.
|
|
151
151
|
*/
|
package/dist/types/core/dom.d.ts
CHANGED
|
@@ -146,6 +146,20 @@ export declare function snapshotTarget(element: Element): TargetSnapshot;
|
|
|
146
146
|
* @returns {void}
|
|
147
147
|
*/
|
|
148
148
|
export declare function restoreTarget(element: Element, snapshot: TargetSnapshot | null): void;
|
|
149
|
+
/**
|
|
150
|
+
* Puts an element's inline style back to a captured attribute value.
|
|
151
|
+
*
|
|
152
|
+
* Written through the CSSOM, never the attribute: under a `style-src` policy without
|
|
153
|
+
* `'unsafe-inline'`, setting the `style` attribute is an inline style the browser blocks and
|
|
154
|
+
* reports, while `style.cssText` is not governed by it. A style that was absent (or empty) is
|
|
155
|
+
* cleared and its attribute removed — after a read, because Chrome reflects CSSOM changes into the
|
|
156
|
+
* attribute lazily, and a removal it has not reflected yet comes back as an empty `style=""`,
|
|
157
|
+
* which the next capture would then try to restore.
|
|
158
|
+
* @param {Element & ElementCSSInlineStyle} element Element whose inline style to restore.
|
|
159
|
+
* @param {string|null} value Attribute value captured earlier, or null when it was absent.
|
|
160
|
+
* @returns {void}
|
|
161
|
+
*/
|
|
162
|
+
export declare function restoreInlineStyle(element: Element & ElementCSSInlineStyle, value: string | null): void;
|
|
149
163
|
/**
|
|
150
164
|
* Escapes text for safe insertion into an HTML string.
|
|
151
165
|
* @param {unknown} str Value to escape.
|
package/dist/zx-zeyos.esm.js
CHANGED
|
@@ -1776,10 +1776,32 @@ function snapshotTarget(element) {
|
|
|
1776
1776
|
}
|
|
1777
1777
|
function restoreTarget(element, snapshot3) {
|
|
1778
1778
|
if (!snapshot3) return;
|
|
1779
|
-
|
|
1780
|
-
|
|
1779
|
+
const styled = (
|
|
1780
|
+
/** @type {Element & ElementCSSInlineStyle} */
|
|
1781
|
+
element
|
|
1782
|
+
);
|
|
1783
|
+
const cssom = typeof styled.style?.cssText === "string";
|
|
1784
|
+
const saved = new Map(snapshot3.attributes);
|
|
1785
|
+
const intact = snapshot3.attributes.every(([name2]) => element.hasAttribute(name2));
|
|
1786
|
+
for (const attribute of Array.from(element.attributes)) {
|
|
1787
|
+
if (!intact || !saved.has(attribute.name)) {
|
|
1788
|
+
if (attribute.name === "style" && cssom) restoreInlineStyle(styled, null);
|
|
1789
|
+
else element.removeAttribute(attribute.name);
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
for (const [name2, value] of snapshot3.attributes) {
|
|
1793
|
+
if (name2 === "style" && cssom) restoreInlineStyle(styled, value);
|
|
1794
|
+
else if (element.getAttribute(name2) !== value) element.setAttribute(name2, value);
|
|
1795
|
+
}
|
|
1781
1796
|
element.replaceChildren(...snapshot3.children);
|
|
1782
1797
|
}
|
|
1798
|
+
function restoreInlineStyle(element, value) {
|
|
1799
|
+
const current = element.getAttribute("style");
|
|
1800
|
+
if (current === value || !value && current === null) return;
|
|
1801
|
+
element.style.cssText = value ?? "";
|
|
1802
|
+
element.getAttribute("style");
|
|
1803
|
+
if (!value) element.removeAttribute("style");
|
|
1804
|
+
}
|
|
1783
1805
|
function resolveElement(target) {
|
|
1784
1806
|
if (target == null) return null;
|
|
1785
1807
|
if (isElement(target)) return target;
|
|
@@ -2786,6 +2808,8 @@ var Checklist = class extends Component {
|
|
|
2786
2808
|
search: true,
|
|
2787
2809
|
height: 280,
|
|
2788
2810
|
defaultChecked: false,
|
|
2811
|
+
label: null,
|
|
2812
|
+
disabled: false,
|
|
2789
2813
|
hideLabel: false,
|
|
2790
2814
|
load: null
|
|
2791
2815
|
};
|
|
@@ -2807,12 +2831,14 @@ var Checklist = class extends Component {
|
|
|
2807
2831
|
);
|
|
2808
2832
|
this.el = root;
|
|
2809
2833
|
if (!this._createdRoot) this._originalChildren = Array.from(root.childNodes);
|
|
2810
|
-
|
|
2834
|
+
this._disabled = Boolean(this.options.disabled);
|
|
2835
|
+
for (const name2 of ["role", "aria-label", "aria-labelledby", "aria-disabled", "data-state"]) {
|
|
2811
2836
|
this._originalAttributes.set(name2, root.getAttribute(name2));
|
|
2812
2837
|
}
|
|
2813
|
-
const labelText = this.
|
|
2838
|
+
const labelText = this._labelText(this.options.label);
|
|
2814
2839
|
const labelId = uid("zx-checklist-label");
|
|
2815
2840
|
const title = this.options.hideLabel ? null : h("div", {
|
|
2841
|
+
ref: "label",
|
|
2816
2842
|
class: "zx-checklist__label",
|
|
2817
2843
|
id: labelId
|
|
2818
2844
|
}, labelText);
|
|
@@ -2823,7 +2849,8 @@ var Checklist = class extends Component {
|
|
|
2823
2849
|
autocomplete: "off",
|
|
2824
2850
|
placeholder: this._message("checklist.search", "Search"),
|
|
2825
2851
|
ariaLabel: this._message("checklist.search", "Search checklist"),
|
|
2826
|
-
hidden: !this.options.search
|
|
2852
|
+
hidden: !this.options.search,
|
|
2853
|
+
disabled: this._disabled
|
|
2827
2854
|
});
|
|
2828
2855
|
const list = h("div", {
|
|
2829
2856
|
ref: "list",
|
|
@@ -2852,6 +2879,7 @@ var Checklist = class extends Component {
|
|
|
2852
2879
|
this.emit("change", { values: this.getValues() });
|
|
2853
2880
|
});
|
|
2854
2881
|
this._replaceItems(this.options.items);
|
|
2882
|
+
this._syncDisabled();
|
|
2855
2883
|
if (typeof this.options.load === "function") {
|
|
2856
2884
|
queueMicrotask(() => {
|
|
2857
2885
|
if (this._active) void this.reload().catch(() => {
|
|
@@ -2869,6 +2897,33 @@ var Checklist = class extends Component {
|
|
|
2869
2897
|
this._replaceItems(items);
|
|
2870
2898
|
return this;
|
|
2871
2899
|
}
|
|
2900
|
+
/**
|
|
2901
|
+
* Replaces the heading text, which is also the group's accessible name.
|
|
2902
|
+
* @param {string|null} label New label; null restores the `checklist.label` message.
|
|
2903
|
+
* @returns {this}
|
|
2904
|
+
*/
|
|
2905
|
+
setLabel(label) {
|
|
2906
|
+
const text3 = this._labelText(label);
|
|
2907
|
+
if (this.refs.label) this.refs.label.textContent = text3;
|
|
2908
|
+
else this.el.setAttribute("aria-label", text3);
|
|
2909
|
+
return this;
|
|
2910
|
+
}
|
|
2911
|
+
/** Enables the search field and the checkboxes. @returns {this} */
|
|
2912
|
+
enable() {
|
|
2913
|
+
this._disabled = false;
|
|
2914
|
+
this._syncDisabled();
|
|
2915
|
+
return this;
|
|
2916
|
+
}
|
|
2917
|
+
/** Disables the search field and the checkboxes; values can still be set programmatically. @returns {this} */
|
|
2918
|
+
disable() {
|
|
2919
|
+
this._disabled = true;
|
|
2920
|
+
this._syncDisabled();
|
|
2921
|
+
return this;
|
|
2922
|
+
}
|
|
2923
|
+
/** Whether the checklist is disabled. @returns {boolean} */
|
|
2924
|
+
isDisabled() {
|
|
2925
|
+
return this._disabled;
|
|
2926
|
+
}
|
|
2872
2927
|
/** Returns checked IDs in item order. @returns {unknown[]} */
|
|
2873
2928
|
getValues() {
|
|
2874
2929
|
return this._items.map((item) => this._itemValue(item)).filter((value) => this._checked.has(value));
|
|
@@ -2967,6 +3022,7 @@ var Checklist = class extends Component {
|
|
|
2967
3022
|
type: "checkbox",
|
|
2968
3023
|
id: checkboxId,
|
|
2969
3024
|
checked: this._checked.has(this._itemValue(item)),
|
|
3025
|
+
disabled: this._disabled,
|
|
2970
3026
|
dataset: { index }
|
|
2971
3027
|
});
|
|
2972
3028
|
return h("label", {
|
|
@@ -2982,6 +3038,19 @@ var Checklist = class extends Component {
|
|
|
2982
3038
|
}
|
|
2983
3039
|
this.refs.list.replaceChildren(...rows);
|
|
2984
3040
|
}
|
|
3041
|
+
/** @returns {void} */
|
|
3042
|
+
_syncDisabled() {
|
|
3043
|
+
if (this._disabled) this.el.setAttribute("aria-disabled", "true");
|
|
3044
|
+
else this.el.removeAttribute("aria-disabled");
|
|
3045
|
+
this.refs.search.disabled = this._disabled;
|
|
3046
|
+
for (const input of this.refs.list.querySelectorAll('input[type="checkbox"]')) {
|
|
3047
|
+
input.disabled = this._disabled;
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
/** @param {string|null|undefined} label @returns {string} */
|
|
3051
|
+
_labelText(label) {
|
|
3052
|
+
return label == null || label === "" ? this._message("checklist.label", "Checklist") : String(label);
|
|
3053
|
+
}
|
|
2985
3054
|
/** @param {Set<unknown>} next @returns {void} */
|
|
2986
3055
|
_replaceChecked(next) {
|
|
2987
3056
|
if (setsEqual(this._checked, next)) return;
|
|
@@ -3024,19 +3093,11 @@ function setsEqual(left, right) {
|
|
|
3024
3093
|
function registerChecklistFieldAdapter() {
|
|
3025
3094
|
Field.register("checklist", (field, options) => {
|
|
3026
3095
|
const checklist = field.own(new Checklist(null, { hideLabel: true, ...options.props ?? {} }));
|
|
3027
|
-
let disabled = false;
|
|
3028
3096
|
let setting = false;
|
|
3029
|
-
const syncDisabled = () => {
|
|
3030
|
-
checklist.el.setAttribute("aria-disabled", String(disabled));
|
|
3031
|
-
for (const control of checklist.el.querySelectorAll("input, button, select, textarea")) {
|
|
3032
|
-
control.disabled = disabled;
|
|
3033
|
-
}
|
|
3034
|
-
};
|
|
3035
3097
|
field.listen(checklist.el, "change", (event) => event.stopImmediatePropagation());
|
|
3036
3098
|
checklist.on("change", (event) => {
|
|
3037
3099
|
if (!setting) field.emit("change", { value: event.detail.values });
|
|
3038
3100
|
});
|
|
3039
|
-
checklist.on("loaded", syncDisabled);
|
|
3040
3101
|
return {
|
|
3041
3102
|
el: checklist.el,
|
|
3042
3103
|
get: () => checklist.getValues(),
|
|
@@ -3047,15 +3108,14 @@ function registerChecklistFieldAdapter() {
|
|
|
3047
3108
|
} finally {
|
|
3048
3109
|
setting = false;
|
|
3049
3110
|
}
|
|
3050
|
-
syncDisabled();
|
|
3051
3111
|
},
|
|
3052
3112
|
focus: () => {
|
|
3053
3113
|
const search = checklist.el.querySelector(".zx-checklist__search:not([hidden]):not([disabled])");
|
|
3054
3114
|
(search ?? checklist.el.querySelector('input[type="checkbox"]:not([disabled])'))?.focus();
|
|
3055
3115
|
},
|
|
3056
3116
|
setDisabled: (value) => {
|
|
3057
|
-
|
|
3058
|
-
|
|
3117
|
+
if (value) checklist.disable();
|
|
3118
|
+
else checklist.enable();
|
|
3059
3119
|
}
|
|
3060
3120
|
};
|
|
3061
3121
|
});
|
|
@@ -3739,6 +3799,12 @@ var icons = Object.freeze({
|
|
|
3739
3799
|
success: outline("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM16 9l-5.5 5.5L8 12"),
|
|
3740
3800
|
// circle-check
|
|
3741
3801
|
upload: outline("M12 3v12M17 8l-5-5-5 5M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"),
|
|
3802
|
+
download: outline("M12 15V3M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5"),
|
|
3803
|
+
"box-archive": outline("M3 3h18a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-18a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1zM4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8M10 12h4"),
|
|
3804
|
+
// archive
|
|
3805
|
+
pencil: outline("M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497zM15 5l4 4"),
|
|
3806
|
+
"pen-to-square": outline("M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"),
|
|
3807
|
+
// square-pen
|
|
3742
3808
|
drag: outline("M8 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM8 5a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM8 19a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 5a1 1 0 1 0 2 0a1 1 0 1 0-2 0zM14 19a1 1 0 1 0 2 0a1 1 0 1 0-2 0z"),
|
|
3743
3809
|
// grip-vertical
|
|
3744
3810
|
star: outline("M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z"),
|
|
@@ -3766,6 +3832,8 @@ var icons = Object.freeze({
|
|
|
3766
3832
|
// </lucide-glyphs>
|
|
3767
3833
|
});
|
|
3768
3834
|
var aliases = Object.freeze({
|
|
3835
|
+
archive: "box-archive",
|
|
3836
|
+
edit: "pen-to-square",
|
|
3769
3837
|
settings: "gear",
|
|
3770
3838
|
clear: "x",
|
|
3771
3839
|
checked: "check",
|
|
@@ -3805,7 +3873,7 @@ async function loadFontAwesome(options) {
|
|
|
3805
3873
|
function icon(name2, options = {}) {
|
|
3806
3874
|
const spec = parseIconSpec(name2);
|
|
3807
3875
|
if (spec.classes) return faIcon(spec.classes, options);
|
|
3808
|
-
const resolved = aliases[spec.name] ?? spec.name;
|
|
3876
|
+
const resolved = Object.hasOwn(extraGlyphs, spec.name) ? spec.name : aliases[spec.name] ?? spec.name;
|
|
3809
3877
|
if (spec.provider === "builtin") return builtinIcon(resolved, options);
|
|
3810
3878
|
if (spec.provider === "fa") {
|
|
3811
3879
|
return faIcon(faIconClasses(resolved, {
|
|
@@ -5019,9 +5087,9 @@ function position(anchor, floating, options = {}) {
|
|
|
5019
5087
|
const rest = anchorNames(anchor).filter((name2) => name2 !== anchorName);
|
|
5020
5088
|
if (rest.length) anchor.style.setProperty("anchor-name", rest.join(", "));
|
|
5021
5089
|
else anchor.style.removeProperty("anchor-name");
|
|
5022
|
-
if (anchorStyle
|
|
5090
|
+
if (!anchorStyle && anchor.getAttribute("style") === "") anchor.removeAttribute("style");
|
|
5023
5091
|
}
|
|
5024
|
-
|
|
5092
|
+
restoreInlineStyle(floating, floatingStyle);
|
|
5025
5093
|
restoreAttribute(floating, "popover", popover);
|
|
5026
5094
|
}
|
|
5027
5095
|
};
|
|
@@ -7736,6 +7804,7 @@ var NumberField = class extends Component {
|
|
|
7736
7804
|
step: 1,
|
|
7737
7805
|
largeStep: 10,
|
|
7738
7806
|
precision: null,
|
|
7807
|
+
snap: true,
|
|
7739
7808
|
wrap: false,
|
|
7740
7809
|
placeholder: "",
|
|
7741
7810
|
label: null,
|
|
@@ -7762,7 +7831,10 @@ var NumberField = class extends Component {
|
|
|
7762
7831
|
this.el = root;
|
|
7763
7832
|
const step = normalizeStep2(this.options.step);
|
|
7764
7833
|
this._step = step;
|
|
7765
|
-
this.
|
|
7834
|
+
this._snap = this.options.snap !== false;
|
|
7835
|
+
const explicit = this.options.precision !== null && this.options.precision !== void 0;
|
|
7836
|
+
this._precision = explicit ? Math.max(0, Math.trunc(Number(this.options.precision) || 0)) : decimalsOf(step);
|
|
7837
|
+
this._fixedPrecision = this._snap || explicit;
|
|
7766
7838
|
const down = this._stepButton("down", "minus");
|
|
7767
7839
|
const up = this._stepButton("up", "plus");
|
|
7768
7840
|
const input = h("input", {
|
|
@@ -7770,7 +7842,7 @@ var NumberField = class extends Component {
|
|
|
7770
7842
|
class: "zx-number-field__input",
|
|
7771
7843
|
type: "text",
|
|
7772
7844
|
role: "spinbutton",
|
|
7773
|
-
inputMode: this._precision > 0 ? "decimal" : "numeric",
|
|
7845
|
+
inputMode: this._precision > 0 || !this._fixedPrecision ? "decimal" : "numeric",
|
|
7774
7846
|
autocomplete: "off",
|
|
7775
7847
|
spellcheck: false,
|
|
7776
7848
|
placeholder: String(this.options.placeholder ?? ""),
|
|
@@ -7831,7 +7903,8 @@ var NumberField = class extends Component {
|
|
|
7831
7903
|
return this._value;
|
|
7832
7904
|
}
|
|
7833
7905
|
/**
|
|
7834
|
-
* Sets the value,
|
|
7906
|
+
* Sets the value, clamping it into `[min, max]` and — unless `snap` is off — moving it onto the
|
|
7907
|
+
* `step` grid.
|
|
7835
7908
|
* @param {number|string|null} next Next value; empty strings and null clear the field.
|
|
7836
7909
|
* @param {{silent?: boolean}} [options={}] Set `silent` to suppress `change`.
|
|
7837
7910
|
* @returns {this}
|
|
@@ -7948,6 +8021,15 @@ var NumberField = class extends Component {
|
|
|
7948
8021
|
_coerce(raw2) {
|
|
7949
8022
|
const parsed = parseNumber(raw2, this.options.group ? this._separators() : null);
|
|
7950
8023
|
if (parsed === null) return null;
|
|
8024
|
+
if (!this._snap) {
|
|
8025
|
+
if (this._decimalsFor(parsed) > ROUNDABLE_DECIMALS) return clampNumber(parsed, this._rangeMin, this._rangeMax);
|
|
8026
|
+
return snapNumber(parsed, {
|
|
8027
|
+
min: this._rangeMin,
|
|
8028
|
+
max: this._rangeMax,
|
|
8029
|
+
step: 0,
|
|
8030
|
+
precision: this._decimalsFor(parsed)
|
|
8031
|
+
});
|
|
8032
|
+
}
|
|
7951
8033
|
return snapNumber(parsed, {
|
|
7952
8034
|
min: this._rangeMin,
|
|
7953
8035
|
max: this._rangeMax,
|
|
@@ -7968,7 +8050,8 @@ var NumberField = class extends Component {
|
|
|
7968
8050
|
const current = typed ?? this._value;
|
|
7969
8051
|
const base = current === null ? min ?? 0 : current;
|
|
7970
8052
|
const start = current === null && count > 0 && min !== null ? min - this._step * count : base;
|
|
7971
|
-
|
|
8053
|
+
const decimals = this._decimalsFor(start);
|
|
8054
|
+
let next = decimals > ROUNDABLE_DECIMALS ? start + this._step * count : round(start + this._step * count, decimals);
|
|
7972
8055
|
if (this.options.wrap && min !== null && max !== null) {
|
|
7973
8056
|
if (next > max) next = min;
|
|
7974
8057
|
else if (next < min) next = max;
|
|
@@ -8069,13 +8152,24 @@ var NumberField = class extends Component {
|
|
|
8069
8152
|
* @returns {string}
|
|
8070
8153
|
*/
|
|
8071
8154
|
_format(value, editing) {
|
|
8072
|
-
|
|
8155
|
+
const decimals = this._decimalsFor(value);
|
|
8156
|
+
if (!this.options.group) return value.toFixed(decimals);
|
|
8073
8157
|
return new Intl.NumberFormat(formattingLocale(this.options.locale), {
|
|
8074
|
-
minimumFractionDigits:
|
|
8075
|
-
maximumFractionDigits:
|
|
8158
|
+
minimumFractionDigits: decimals,
|
|
8159
|
+
maximumFractionDigits: decimals,
|
|
8076
8160
|
useGrouping: !editing
|
|
8077
8161
|
}).format(value);
|
|
8078
8162
|
}
|
|
8163
|
+
/**
|
|
8164
|
+
* Decimal places a value is held and shown at: the field's precision, widened to the value's
|
|
8165
|
+
* own decimals when nothing fixed the precision (`snap: false` without `precision`).
|
|
8166
|
+
* @param {number} value Value in question.
|
|
8167
|
+
* @returns {number}
|
|
8168
|
+
*/
|
|
8169
|
+
_decimalsFor(value) {
|
|
8170
|
+
if (this._fixedPrecision) return this._precision;
|
|
8171
|
+
return Math.min(MAX_DECIMALS, Math.max(this._precision, decimalsOf(value)));
|
|
8172
|
+
}
|
|
8079
8173
|
/**
|
|
8080
8174
|
* @param {string} key Message key.
|
|
8081
8175
|
* @param {string} fallback Text used when the host has no translation.
|
|
@@ -8149,12 +8243,17 @@ function normalizeStep2(step) {
|
|
|
8149
8243
|
const value = Number(step);
|
|
8150
8244
|
return Number.isFinite(value) && value > 0 ? value : 1;
|
|
8151
8245
|
}
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
if (
|
|
8156
|
-
|
|
8157
|
-
return
|
|
8246
|
+
var MAX_DECIMALS = 100;
|
|
8247
|
+
var ROUNDABLE_DECIMALS = 15;
|
|
8248
|
+
function clampNumber(value, min, max) {
|
|
8249
|
+
if (min !== null && value < min) return min;
|
|
8250
|
+
if (max !== null && value > max) return max;
|
|
8251
|
+
return value;
|
|
8252
|
+
}
|
|
8253
|
+
function decimalsOf(value) {
|
|
8254
|
+
const [mantissa, exponent = "0"] = String(value).toLowerCase().split("e");
|
|
8255
|
+
const fraction = mantissa.split(".")[1]?.length ?? 0;
|
|
8256
|
+
return Math.max(0, fraction - Number(exponent));
|
|
8158
8257
|
}
|
|
8159
8258
|
function round(value, precision) {
|
|
8160
8259
|
if (!Number.isFinite(value)) return value;
|