@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/dist/zx.global.js
CHANGED
|
@@ -725,10 +725,32 @@ var zx = (() => {
|
|
|
725
725
|
}
|
|
726
726
|
function restoreTarget(element, snapshot10) {
|
|
727
727
|
if (!snapshot10) return;
|
|
728
|
-
|
|
729
|
-
|
|
728
|
+
const styled = (
|
|
729
|
+
/** @type {Element & ElementCSSInlineStyle} */
|
|
730
|
+
element
|
|
731
|
+
);
|
|
732
|
+
const cssom = typeof styled.style?.cssText === "string";
|
|
733
|
+
const saved = new Map(snapshot10.attributes);
|
|
734
|
+
const intact = snapshot10.attributes.every(([name2]) => element.hasAttribute(name2));
|
|
735
|
+
for (const attribute of Array.from(element.attributes)) {
|
|
736
|
+
if (!intact || !saved.has(attribute.name)) {
|
|
737
|
+
if (attribute.name === "style" && cssom) restoreInlineStyle(styled, null);
|
|
738
|
+
else element.removeAttribute(attribute.name);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
for (const [name2, value] of snapshot10.attributes) {
|
|
742
|
+
if (name2 === "style" && cssom) restoreInlineStyle(styled, value);
|
|
743
|
+
else if (element.getAttribute(name2) !== value) element.setAttribute(name2, value);
|
|
744
|
+
}
|
|
730
745
|
element.replaceChildren(...snapshot10.children);
|
|
731
746
|
}
|
|
747
|
+
function restoreInlineStyle(element, value) {
|
|
748
|
+
const current = element.getAttribute("style");
|
|
749
|
+
if (current === value || !value && current === null) return;
|
|
750
|
+
element.style.cssText = value ?? "";
|
|
751
|
+
element.getAttribute("style");
|
|
752
|
+
if (!value) element.removeAttribute("style");
|
|
753
|
+
}
|
|
732
754
|
function htmlEscape(str) {
|
|
733
755
|
return String(str).replace(/[&<>"']/g, (character) => ({
|
|
734
756
|
"&": "&",
|
|
@@ -2807,6 +2829,8 @@ var zx = (() => {
|
|
|
2807
2829
|
search: true,
|
|
2808
2830
|
height: 280,
|
|
2809
2831
|
defaultChecked: false,
|
|
2832
|
+
label: null,
|
|
2833
|
+
disabled: false,
|
|
2810
2834
|
hideLabel: false,
|
|
2811
2835
|
load: null
|
|
2812
2836
|
};
|
|
@@ -2828,12 +2852,14 @@ var zx = (() => {
|
|
|
2828
2852
|
);
|
|
2829
2853
|
this.el = root;
|
|
2830
2854
|
if (!this._createdRoot) this._originalChildren = Array.from(root.childNodes);
|
|
2831
|
-
|
|
2855
|
+
this._disabled = Boolean(this.options.disabled);
|
|
2856
|
+
for (const name2 of ["role", "aria-label", "aria-labelledby", "aria-disabled", "data-state"]) {
|
|
2832
2857
|
this._originalAttributes.set(name2, root.getAttribute(name2));
|
|
2833
2858
|
}
|
|
2834
|
-
const labelText = this.
|
|
2859
|
+
const labelText = this._labelText(this.options.label);
|
|
2835
2860
|
const labelId = uid("zx-checklist-label");
|
|
2836
2861
|
const title = this.options.hideLabel ? null : h("div", {
|
|
2862
|
+
ref: "label",
|
|
2837
2863
|
class: "zx-checklist__label",
|
|
2838
2864
|
id: labelId
|
|
2839
2865
|
}, labelText);
|
|
@@ -2844,7 +2870,8 @@ var zx = (() => {
|
|
|
2844
2870
|
autocomplete: "off",
|
|
2845
2871
|
placeholder: this._message("checklist.search", "Search"),
|
|
2846
2872
|
ariaLabel: this._message("checklist.search", "Search checklist"),
|
|
2847
|
-
hidden: !this.options.search
|
|
2873
|
+
hidden: !this.options.search,
|
|
2874
|
+
disabled: this._disabled
|
|
2848
2875
|
});
|
|
2849
2876
|
const list = h("div", {
|
|
2850
2877
|
ref: "list",
|
|
@@ -2873,6 +2900,7 @@ var zx = (() => {
|
|
|
2873
2900
|
this.emit("change", { values: this.getValues() });
|
|
2874
2901
|
});
|
|
2875
2902
|
this._replaceItems(this.options.items);
|
|
2903
|
+
this._syncDisabled();
|
|
2876
2904
|
if (typeof this.options.load === "function") {
|
|
2877
2905
|
queueMicrotask(() => {
|
|
2878
2906
|
if (this._active) void this.reload().catch(() => {
|
|
@@ -2890,6 +2918,33 @@ var zx = (() => {
|
|
|
2890
2918
|
this._replaceItems(items);
|
|
2891
2919
|
return this;
|
|
2892
2920
|
}
|
|
2921
|
+
/**
|
|
2922
|
+
* Replaces the heading text, which is also the group's accessible name.
|
|
2923
|
+
* @param {string|null} label New label; null restores the `checklist.label` message.
|
|
2924
|
+
* @returns {this}
|
|
2925
|
+
*/
|
|
2926
|
+
setLabel(label) {
|
|
2927
|
+
const text6 = this._labelText(label);
|
|
2928
|
+
if (this.refs.label) this.refs.label.textContent = text6;
|
|
2929
|
+
else this.el.setAttribute("aria-label", text6);
|
|
2930
|
+
return this;
|
|
2931
|
+
}
|
|
2932
|
+
/** Enables the search field and the checkboxes. @returns {this} */
|
|
2933
|
+
enable() {
|
|
2934
|
+
this._disabled = false;
|
|
2935
|
+
this._syncDisabled();
|
|
2936
|
+
return this;
|
|
2937
|
+
}
|
|
2938
|
+
/** Disables the search field and the checkboxes; values can still be set programmatically. @returns {this} */
|
|
2939
|
+
disable() {
|
|
2940
|
+
this._disabled = true;
|
|
2941
|
+
this._syncDisabled();
|
|
2942
|
+
return this;
|
|
2943
|
+
}
|
|
2944
|
+
/** Whether the checklist is disabled. @returns {boolean} */
|
|
2945
|
+
isDisabled() {
|
|
2946
|
+
return this._disabled;
|
|
2947
|
+
}
|
|
2893
2948
|
/** Returns checked IDs in item order. @returns {unknown[]} */
|
|
2894
2949
|
getValues() {
|
|
2895
2950
|
return this._items.map((item) => this._itemValue(item)).filter((value) => this._checked.has(value));
|
|
@@ -2988,6 +3043,7 @@ var zx = (() => {
|
|
|
2988
3043
|
type: "checkbox",
|
|
2989
3044
|
id: checkboxId,
|
|
2990
3045
|
checked: this._checked.has(this._itemValue(item)),
|
|
3046
|
+
disabled: this._disabled,
|
|
2991
3047
|
dataset: { index }
|
|
2992
3048
|
});
|
|
2993
3049
|
return h("label", {
|
|
@@ -3003,6 +3059,19 @@ var zx = (() => {
|
|
|
3003
3059
|
}
|
|
3004
3060
|
this.refs.list.replaceChildren(...rows);
|
|
3005
3061
|
}
|
|
3062
|
+
/** @returns {void} */
|
|
3063
|
+
_syncDisabled() {
|
|
3064
|
+
if (this._disabled) this.el.setAttribute("aria-disabled", "true");
|
|
3065
|
+
else this.el.removeAttribute("aria-disabled");
|
|
3066
|
+
this.refs.search.disabled = this._disabled;
|
|
3067
|
+
for (const input of this.refs.list.querySelectorAll('input[type="checkbox"]')) {
|
|
3068
|
+
input.disabled = this._disabled;
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3071
|
+
/** @param {string|null|undefined} label @returns {string} */
|
|
3072
|
+
_labelText(label) {
|
|
3073
|
+
return label == null || label === "" ? this._message("checklist.label", "Checklist") : String(label);
|
|
3074
|
+
}
|
|
3006
3075
|
/** @param {Set<unknown>} next @returns {void} */
|
|
3007
3076
|
_replaceChecked(next) {
|
|
3008
3077
|
if (setsEqual(this._checked, next)) return;
|
|
@@ -3045,19 +3114,11 @@ var zx = (() => {
|
|
|
3045
3114
|
function registerChecklistFieldAdapter() {
|
|
3046
3115
|
Field.register("checklist", (field, options) => {
|
|
3047
3116
|
const checklist = field.own(new Checklist(null, { hideLabel: true, ...options.props ?? {} }));
|
|
3048
|
-
let disabled = false;
|
|
3049
3117
|
let setting = false;
|
|
3050
|
-
const syncDisabled = () => {
|
|
3051
|
-
checklist.el.setAttribute("aria-disabled", String(disabled));
|
|
3052
|
-
for (const control of checklist.el.querySelectorAll("input, button, select, textarea")) {
|
|
3053
|
-
control.disabled = disabled;
|
|
3054
|
-
}
|
|
3055
|
-
};
|
|
3056
3118
|
field.listen(checklist.el, "change", (event) => event.stopImmediatePropagation());
|
|
3057
3119
|
checklist.on("change", (event) => {
|
|
3058
3120
|
if (!setting) field.emit("change", { value: event.detail.values });
|
|
3059
3121
|
});
|
|
3060
|
-
checklist.on("loaded", syncDisabled);
|
|
3061
3122
|
return {
|
|
3062
3123
|
el: checklist.el,
|
|
3063
3124
|
get: () => checklist.getValues(),
|
|
@@ -3068,15 +3129,14 @@ var zx = (() => {
|
|
|
3068
3129
|
} finally {
|
|
3069
3130
|
setting = false;
|
|
3070
3131
|
}
|
|
3071
|
-
syncDisabled();
|
|
3072
3132
|
},
|
|
3073
3133
|
focus: () => {
|
|
3074
3134
|
const search = checklist.el.querySelector(".zx-checklist__search:not([hidden]):not([disabled])");
|
|
3075
3135
|
(search ?? checklist.el.querySelector('input[type="checkbox"]:not([disabled])'))?.focus();
|
|
3076
3136
|
},
|
|
3077
3137
|
setDisabled: (value) => {
|
|
3078
|
-
|
|
3079
|
-
|
|
3138
|
+
if (value) checklist.disable();
|
|
3139
|
+
else checklist.enable();
|
|
3080
3140
|
}
|
|
3081
3141
|
};
|
|
3082
3142
|
});
|
|
@@ -3760,6 +3820,12 @@ var zx = (() => {
|
|
|
3760
3820
|
success: outline("M2 12a10 10 0 1 0 20 0a10 10 0 1 0-20 0zM16 9l-5.5 5.5L8 12"),
|
|
3761
3821
|
// circle-check
|
|
3762
3822
|
upload: outline("M12 3v12M17 8l-5-5-5 5M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"),
|
|
3823
|
+
download: outline("M12 15V3M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5"),
|
|
3824
|
+
"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"),
|
|
3825
|
+
// archive
|
|
3826
|
+
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"),
|
|
3827
|
+
"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"),
|
|
3828
|
+
// square-pen
|
|
3763
3829
|
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"),
|
|
3764
3830
|
// grip-vertical
|
|
3765
3831
|
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"),
|
|
@@ -3787,6 +3853,8 @@ var zx = (() => {
|
|
|
3787
3853
|
// </lucide-glyphs>
|
|
3788
3854
|
});
|
|
3789
3855
|
var aliases = Object.freeze({
|
|
3856
|
+
archive: "box-archive",
|
|
3857
|
+
edit: "pen-to-square",
|
|
3790
3858
|
settings: "gear",
|
|
3791
3859
|
clear: "x",
|
|
3792
3860
|
checked: "check",
|
|
@@ -3842,7 +3910,7 @@ var zx = (() => {
|
|
|
3842
3910
|
function icon(name2, options = {}) {
|
|
3843
3911
|
const spec = parseIconSpec(name2);
|
|
3844
3912
|
if (spec.classes) return faIcon(spec.classes, options);
|
|
3845
|
-
const resolved = aliases[spec.name] ?? spec.name;
|
|
3913
|
+
const resolved = Object.hasOwn(extraGlyphs, spec.name) ? spec.name : aliases[spec.name] ?? spec.name;
|
|
3846
3914
|
if (spec.provider === "builtin") return builtinIcon(resolved, options);
|
|
3847
3915
|
if (spec.provider === "fa") {
|
|
3848
3916
|
return faIcon(faIconClasses(resolved, {
|
|
@@ -5056,9 +5124,9 @@ var zx = (() => {
|
|
|
5056
5124
|
const rest2 = anchorNames(anchor).filter((name2) => name2 !== anchorName);
|
|
5057
5125
|
if (rest2.length) anchor.style.setProperty("anchor-name", rest2.join(", "));
|
|
5058
5126
|
else anchor.style.removeProperty("anchor-name");
|
|
5059
|
-
if (anchorStyle
|
|
5127
|
+
if (!anchorStyle && anchor.getAttribute("style") === "") anchor.removeAttribute("style");
|
|
5060
5128
|
}
|
|
5061
|
-
|
|
5129
|
+
restoreInlineStyle(floating, floatingStyle);
|
|
5062
5130
|
restoreAttribute(floating, "popover", popover);
|
|
5063
5131
|
}
|
|
5064
5132
|
};
|
|
@@ -7778,6 +7846,7 @@ var zx = (() => {
|
|
|
7778
7846
|
step: 1,
|
|
7779
7847
|
largeStep: 10,
|
|
7780
7848
|
precision: null,
|
|
7849
|
+
snap: true,
|
|
7781
7850
|
wrap: false,
|
|
7782
7851
|
placeholder: "",
|
|
7783
7852
|
label: null,
|
|
@@ -7804,7 +7873,10 @@ var zx = (() => {
|
|
|
7804
7873
|
this.el = root;
|
|
7805
7874
|
const step2 = normalizeStep2(this.options.step);
|
|
7806
7875
|
this._step = step2;
|
|
7807
|
-
this.
|
|
7876
|
+
this._snap = this.options.snap !== false;
|
|
7877
|
+
const explicit = this.options.precision !== null && this.options.precision !== void 0;
|
|
7878
|
+
this._precision = explicit ? Math.max(0, Math.trunc(Number(this.options.precision) || 0)) : decimalsOf(step2);
|
|
7879
|
+
this._fixedPrecision = this._snap || explicit;
|
|
7808
7880
|
const down = this._stepButton("down", "minus");
|
|
7809
7881
|
const up = this._stepButton("up", "plus");
|
|
7810
7882
|
const input = h("input", {
|
|
@@ -7812,7 +7884,7 @@ var zx = (() => {
|
|
|
7812
7884
|
class: "zx-number-field__input",
|
|
7813
7885
|
type: "text",
|
|
7814
7886
|
role: "spinbutton",
|
|
7815
|
-
inputMode: this._precision > 0 ? "decimal" : "numeric",
|
|
7887
|
+
inputMode: this._precision > 0 || !this._fixedPrecision ? "decimal" : "numeric",
|
|
7816
7888
|
autocomplete: "off",
|
|
7817
7889
|
spellcheck: false,
|
|
7818
7890
|
placeholder: String(this.options.placeholder ?? ""),
|
|
@@ -7873,7 +7945,8 @@ var zx = (() => {
|
|
|
7873
7945
|
return this._value;
|
|
7874
7946
|
}
|
|
7875
7947
|
/**
|
|
7876
|
-
* Sets the value,
|
|
7948
|
+
* Sets the value, clamping it into `[min, max]` and — unless `snap` is off — moving it onto the
|
|
7949
|
+
* `step` grid.
|
|
7877
7950
|
* @param {number|string|null} next Next value; empty strings and null clear the field.
|
|
7878
7951
|
* @param {{silent?: boolean}} [options={}] Set `silent` to suppress `change`.
|
|
7879
7952
|
* @returns {this}
|
|
@@ -7990,6 +8063,15 @@ var zx = (() => {
|
|
|
7990
8063
|
_coerce(raw2) {
|
|
7991
8064
|
const parsed = parseNumber(raw2, this.options.group ? this._separators() : null);
|
|
7992
8065
|
if (parsed === null) return null;
|
|
8066
|
+
if (!this._snap) {
|
|
8067
|
+
if (this._decimalsFor(parsed) > ROUNDABLE_DECIMALS) return clampNumber(parsed, this._rangeMin, this._rangeMax);
|
|
8068
|
+
return snapNumber(parsed, {
|
|
8069
|
+
min: this._rangeMin,
|
|
8070
|
+
max: this._rangeMax,
|
|
8071
|
+
step: 0,
|
|
8072
|
+
precision: this._decimalsFor(parsed)
|
|
8073
|
+
});
|
|
8074
|
+
}
|
|
7993
8075
|
return snapNumber(parsed, {
|
|
7994
8076
|
min: this._rangeMin,
|
|
7995
8077
|
max: this._rangeMax,
|
|
@@ -8010,7 +8092,8 @@ var zx = (() => {
|
|
|
8010
8092
|
const current = typed ?? this._value;
|
|
8011
8093
|
const base = current === null ? min ?? 0 : current;
|
|
8012
8094
|
const start = current === null && count2 > 0 && min !== null ? min - this._step * count2 : base;
|
|
8013
|
-
|
|
8095
|
+
const decimals = this._decimalsFor(start);
|
|
8096
|
+
let next = decimals > ROUNDABLE_DECIMALS ? start + this._step * count2 : round(start + this._step * count2, decimals);
|
|
8014
8097
|
if (this.options.wrap && min !== null && max !== null) {
|
|
8015
8098
|
if (next > max) next = min;
|
|
8016
8099
|
else if (next < min) next = max;
|
|
@@ -8111,13 +8194,24 @@ var zx = (() => {
|
|
|
8111
8194
|
* @returns {string}
|
|
8112
8195
|
*/
|
|
8113
8196
|
_format(value, editing) {
|
|
8114
|
-
|
|
8197
|
+
const decimals = this._decimalsFor(value);
|
|
8198
|
+
if (!this.options.group) return value.toFixed(decimals);
|
|
8115
8199
|
return new Intl.NumberFormat(formattingLocale(this.options.locale), {
|
|
8116
|
-
minimumFractionDigits:
|
|
8117
|
-
maximumFractionDigits:
|
|
8200
|
+
minimumFractionDigits: decimals,
|
|
8201
|
+
maximumFractionDigits: decimals,
|
|
8118
8202
|
useGrouping: !editing
|
|
8119
8203
|
}).format(value);
|
|
8120
8204
|
}
|
|
8205
|
+
/**
|
|
8206
|
+
* Decimal places a value is held and shown at: the field's precision, widened to the value's
|
|
8207
|
+
* own decimals when nothing fixed the precision (`snap: false` without `precision`).
|
|
8208
|
+
* @param {number} value Value in question.
|
|
8209
|
+
* @returns {number}
|
|
8210
|
+
*/
|
|
8211
|
+
_decimalsFor(value) {
|
|
8212
|
+
if (this._fixedPrecision) return this._precision;
|
|
8213
|
+
return Math.min(MAX_DECIMALS, Math.max(this._precision, decimalsOf(value)));
|
|
8214
|
+
}
|
|
8121
8215
|
/**
|
|
8122
8216
|
* @param {string} key Message key.
|
|
8123
8217
|
* @param {string} fallback Text used when the host has no translation.
|
|
@@ -8191,12 +8285,17 @@ var zx = (() => {
|
|
|
8191
8285
|
const value = Number(step2);
|
|
8192
8286
|
return Number.isFinite(value) && value > 0 ? value : 1;
|
|
8193
8287
|
}
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
if (
|
|
8198
|
-
|
|
8199
|
-
return
|
|
8288
|
+
var MAX_DECIMALS = 100;
|
|
8289
|
+
var ROUNDABLE_DECIMALS = 15;
|
|
8290
|
+
function clampNumber(value, min, max) {
|
|
8291
|
+
if (min !== null && value < min) return min;
|
|
8292
|
+
if (max !== null && value > max) return max;
|
|
8293
|
+
return value;
|
|
8294
|
+
}
|
|
8295
|
+
function decimalsOf(value) {
|
|
8296
|
+
const [mantissa, exponent = "0"] = String(value).toLowerCase().split("e");
|
|
8297
|
+
const fraction = mantissa.split(".")[1]?.length ?? 0;
|
|
8298
|
+
return Math.max(0, fraction - Number(exponent));
|
|
8200
8299
|
}
|
|
8201
8300
|
function round(value, precision) {
|
|
8202
8301
|
if (!Number.isFinite(value)) return value;
|
|
@@ -13604,8 +13703,21 @@ var zx = (() => {
|
|
|
13604
13703
|
super(null, options);
|
|
13605
13704
|
this.#setWidth(this.options.width);
|
|
13606
13705
|
replaceContent(this.refs.content, this.options.content);
|
|
13706
|
+
if (typeof window !== "undefined") this.listen(window, "keydown", (event) => {
|
|
13707
|
+
const key = (
|
|
13708
|
+
/** @type {KeyboardEvent} */
|
|
13709
|
+
event
|
|
13710
|
+
);
|
|
13711
|
+
if (key.key !== "Escape" || key.defaultPrevented || key.isComposing) return;
|
|
13712
|
+
if (!this.isOpen() || !this.el.matches(":modal")) return;
|
|
13713
|
+
const modals = document.querySelectorAll("dialog:modal");
|
|
13714
|
+
if (modals[modals.length - 1] !== this.el) return;
|
|
13715
|
+
if (this.options.closable) this._requestDismiss("escape");
|
|
13716
|
+
else this.emit("cancel", { reason: "escape" });
|
|
13717
|
+
key.preventDefault();
|
|
13718
|
+
});
|
|
13607
13719
|
this.listen(this.el, "cancel", (event) => {
|
|
13608
|
-
const cancelEvent = this.emit("cancel");
|
|
13720
|
+
const cancelEvent = this.emit("cancel", { reason: "escape" });
|
|
13609
13721
|
if (!this.options.closable || cancelEvent.defaultPrevented) event.preventDefault();
|
|
13610
13722
|
});
|
|
13611
13723
|
this.listen(this.el, "close", () => {
|
|
@@ -13613,7 +13725,7 @@ var zx = (() => {
|
|
|
13613
13725
|
});
|
|
13614
13726
|
this.listen(this.el, "click", (event) => {
|
|
13615
13727
|
if (!this.options.lightDismiss || event.target !== this.el || !isBackdropClick(this.el, event)) return;
|
|
13616
|
-
this.
|
|
13728
|
+
this._requestDismiss("backdrop");
|
|
13617
13729
|
});
|
|
13618
13730
|
this.on("close", () => this.#restoreFocus());
|
|
13619
13731
|
}
|
|
@@ -13681,8 +13793,9 @@ var zx = (() => {
|
|
|
13681
13793
|
* Describes the current presentation for the overlay stack, or returns null to stay off it.
|
|
13682
13794
|
*
|
|
13683
13795
|
* The kind is read from the platform like `aria-modal` is: a `showModal()` dialog is `modal`,
|
|
13684
|
-
* and
|
|
13685
|
-
* presenting that way adds the Escape and outside-press
|
|
13796
|
+
* and the stack leaves its Escape alone (this class answers it, see the constructor); anything
|
|
13797
|
+
* else is `non-modal`, and a subclass presenting that way adds the Escape and outside-press
|
|
13798
|
+
* handling it wants.
|
|
13686
13799
|
* @returns {import('../../core/overlay-stack.js').OverlayEntryOptions|null}
|
|
13687
13800
|
* @protected
|
|
13688
13801
|
*/
|
|
@@ -13694,6 +13807,21 @@ var zx = (() => {
|
|
|
13694
13807
|
anchor: this.#opener
|
|
13695
13808
|
};
|
|
13696
13809
|
}
|
|
13810
|
+
/**
|
|
13811
|
+
* Asks to close on the reader's behalf: emits a preventable `cancel` naming what they did, and
|
|
13812
|
+
* closes unless a listener prevented it. Every dismissal gesture goes through here; `close()`
|
|
13813
|
+
* itself stays unconditional, for the application's own decisions.
|
|
13814
|
+
* @param {ModalDismissReason} reason What the reader did.
|
|
13815
|
+
* @returns {boolean} Whether the overlay is closing.
|
|
13816
|
+
* @fires Modal#cancel
|
|
13817
|
+
* @protected
|
|
13818
|
+
*/
|
|
13819
|
+
_requestDismiss(reason) {
|
|
13820
|
+
if (!this.isOpen()) return false;
|
|
13821
|
+
if (this.emit("cancel", { reason }).defaultPrevented) return false;
|
|
13822
|
+
this.close();
|
|
13823
|
+
return true;
|
|
13824
|
+
}
|
|
13697
13825
|
/**
|
|
13698
13826
|
* Re-registers the current presentation on the overlay stack: called after every presentation,
|
|
13699
13827
|
* including a subclass's change of address that bypasses `open()`.
|
|
@@ -14189,7 +14317,7 @@ var zx = (() => {
|
|
|
14189
14317
|
this.#baseButtons = normalizeDialogButtons(this.options.buttons);
|
|
14190
14318
|
this.#renderButtons(this.#baseButtons);
|
|
14191
14319
|
this.refs.close.hidden = !this.options.closable;
|
|
14192
|
-
this.listen(this.refs.close, "click", () => this.close
|
|
14320
|
+
this.listen(this.refs.close, "click", () => this._requestDismiss("close-button"));
|
|
14193
14321
|
this.listen(this.refs.footer, "click", (event) => {
|
|
14194
14322
|
const button2 = event.target.closest?.("[data-dialog-button]");
|
|
14195
14323
|
if (!button2 || !this.refs.footer.contains(button2)) return;
|
|
@@ -14565,8 +14693,7 @@ var zx = (() => {
|
|
|
14565
14693
|
if (action === "close") {
|
|
14566
14694
|
this.close();
|
|
14567
14695
|
} else if (action === "cancel") {
|
|
14568
|
-
|
|
14569
|
-
if (!event.defaultPrevented) this.close();
|
|
14696
|
+
this._requestDismiss("button");
|
|
14570
14697
|
} else if (typeof action === "function") {
|
|
14571
14698
|
action(this);
|
|
14572
14699
|
}
|
|
@@ -26526,7 +26653,8 @@ ${block.code}
|
|
|
26526
26653
|
}
|
|
26527
26654
|
if (this.options.closable && next < min / 2) {
|
|
26528
26655
|
this._applySize(this.#dragStart);
|
|
26529
|
-
this
|
|
26656
|
+
this.#syncHandleAria();
|
|
26657
|
+
this._requestDismiss("drag");
|
|
26530
26658
|
return;
|
|
26531
26659
|
}
|
|
26532
26660
|
const detents = this.#detents(total);
|
|
@@ -26673,15 +26801,19 @@ ${block.code}
|
|
|
26673
26801
|
...entry,
|
|
26674
26802
|
// An Escape pressed outside the sheet and everything it opened is not addressed to it.
|
|
26675
26803
|
onEscape: (event) => {
|
|
26676
|
-
if (!this.
|
|
26804
|
+
if (!this._overlayContains(
|
|
26677
26805
|
/** @type {Node|null} */
|
|
26678
26806
|
event.target
|
|
26679
26807
|
)) return false;
|
|
26680
|
-
if (!this.
|
|
26808
|
+
if (!this.options.closable) {
|
|
26809
|
+
this.emit("cancel", { reason: "escape" });
|
|
26810
|
+
return false;
|
|
26811
|
+
}
|
|
26812
|
+
this._requestDismiss("escape");
|
|
26681
26813
|
return void 0;
|
|
26682
26814
|
},
|
|
26683
26815
|
onOutsidePointer: this.options.lightDismiss ? () => {
|
|
26684
|
-
this.
|
|
26816
|
+
this._requestDismiss("outside");
|
|
26685
26817
|
} : void 0,
|
|
26686
26818
|
// Hosted inside a modal that has now closed, the sheet would stay open but never be seen.
|
|
26687
26819
|
onParentClose: () => {
|