spell-ui 0.8.16 → 0.8.17
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/dist/{UIInput-B3K0w4ow.js → UIInput-8s1aiaw1.js} +2 -2
- package/dist/UIInput-8s1aiaw1.js.map +1 -0
- package/dist/{UIRuntime-DxC1O7ON.js → UIRuntime-BaokNnwk.js} +8 -4
- package/dist/UIRuntime-BaokNnwk.js.map +1 -0
- package/dist/_spell-element/UIComponent.d.ts +7 -0
- package/dist/_spell-element/elements.types.d.ts +6 -0
- package/dist/_spell-element/vocabulary.types.d.ts +22 -0
- package/dist/_util/dom.d.ts +1 -1
- package/dist/components/ui-graph/UIGraph.d.ts +17 -0
- package/dist/components/ui-graph/UIGraph.en.d.ts +17 -0
- package/dist/components/ui-graph/UIGraph.es.d.ts +6 -0
- package/dist/components/ui-modal/ChoiceRows.d.ts +61 -0
- package/dist/components/ui-modal/ModalDialogs.d.ts +15 -1
- package/dist/components/ui-modal/UIModal.d.ts +6 -2
- package/dist/components/ui-modal/UIModal.en.d.ts +6 -2
- package/dist/components/ui-modal/UIModal.es.d.ts +1 -0
- package/dist/components/ui-tree/UITree.d.ts +5 -0
- package/dist/components/ui-tree/UITree.en.d.ts +5 -0
- package/dist/components/ui-tree/UITree.es.d.ts +3 -0
- package/dist/{components.es-eyezTRd7.js → components.es-jY2nBwuP.js} +11 -3
- package/dist/components.es-jY2nBwuP.js.map +1 -0
- package/dist/core.js +456 -431
- package/dist/core.js.map +1 -1
- package/dist/runtime/Modals.d.ts +7 -2
- package/dist/runtime/Styles.d.ts +7 -1
- package/dist/runtime/runtime.types.d.ts +26 -1
- package/dist/ui-calendar.js +1 -1
- package/dist/ui-graph.js +22 -0
- package/dist/ui-graph.js.map +1 -1
- package/dist/ui-input.js +1 -1
- package/dist/ui-modal.js +183 -97
- package/dist/ui-modal.js.map +1 -1
- package/dist/ui-root.js +1 -1
- package/dist/ui-search.js +1 -1
- package/dist/ui-tree.js +6 -1
- package/dist/ui-tree.js.map +1 -1
- package/dist/vocabulary/hooks.generated.d.ts +7 -0
- package/package.json +1 -1
- package/dist/UIInput-B3K0w4ow.js.map +0 -1
- package/dist/UIRuntime-DxC1O7ON.js.map +0 -1
- package/dist/components.es-eyezTRd7.js.map +0 -1
package/dist/ui-input.js
CHANGED
|
@@ -2,7 +2,7 @@ import "./rolldown-runtime-c6e9CmGy.js";
|
|
|
2
2
|
import { A as e, C as t, F as n, Gt as r, IconGlyph as i, Jt as a, Kt as o, NativeFallback as s, SlotContent as c, T as l, UI as ee, Ut as u, Wt as d, Yt as f, afterSolidUpdate as te, controlled as ne, derived as re, et as ie, onChange as p, proto as m, protoMerged as h, qt as g, state as ae, untracked as _, w as oe } from "./core.js";
|
|
3
3
|
import { DOMFormControl as se, FormComponent as ce } from "./forms.js";
|
|
4
4
|
import { t as le } from "./UILabel-pCjKxQlQ.js";
|
|
5
|
-
import { t as v } from "./UIInput-
|
|
5
|
+
import { t as v } from "./UIInput-8s1aiaw1.js";
|
|
6
6
|
import { Show as y } from "solid-js";
|
|
7
7
|
import { className as b, createComponent as x, effect as S, getOwner as C, insert as w, isServer as ue, readShallow as T, ref as de, setAttribute as E, spread as fe, template as D } from "@solidjs/web";
|
|
8
8
|
// src/components/ui-input/UIInput.en.ts
|
package/dist/ui-modal.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import "./rolldown-runtime-c6e9CmGy.js";
|
|
2
|
-
import {
|
|
2
|
+
import { At as e, CloseButton as t, D as n, Disclosure as r, F as i, Gt as a, Jt as o, Kt as s, Nt as c, O as ee, UI as l, UIComponent as u, Ut as d, V as f, Wt as p, Yt as m, a as te, after as ne, c as h, f as g, hasMarkdown as re, isBrowser as ie, on as _, onChange as ae, proto as v, protoMerged as y, qt as oe, soon as se, state as ce, u as b, untracked as x, whileConnected as le } from "./core.js";
|
|
3
3
|
import "./ui-parts.js";
|
|
4
4
|
import "./ui-button.js";
|
|
5
|
-
import { Show as
|
|
6
|
-
import { addEvent as
|
|
5
|
+
import { Show as ue } from "solid-js";
|
|
6
|
+
import { addEvent as S, className as C, createComponent as w, delegateEvents as de, effect as T, getOwner as fe, insert as E, isServer as pe, readShallow as D, ref as me, setAttribute as O, template as k } from "@solidjs/web";
|
|
7
7
|
// src/components/ui-modal/DialogComponent.tsx
|
|
8
|
-
var
|
|
9
|
-
constructor(...
|
|
10
|
-
super(...
|
|
8
|
+
var A = /* @__PURE__ */ k("<div>"), he = /* @__PURE__ */ k("<dialog><!><slot></slot><!>"), j, M, N, P, F, I, L, R, z, B, V, H, U = class _DialogComponent extends (B = u, z = [y], R = [x], L = [le], I = [_("command")], F = [x], P = [x], N = [ce], M = [_("slotchange", { target: "renderRoot" })], j = [ae("isReady", "ariaLabel", "heading", "slottedHeading")], B) {
|
|
9
|
+
constructor(...e) {
|
|
10
|
+
super(...e), m(V, 5, this), o(this, "dialog"), o(this, "overlayEntry", {
|
|
11
11
|
element: this.domElement,
|
|
12
12
|
kind: "modal",
|
|
13
|
-
onDismiss: /* @__PURE__ */
|
|
14
|
-
}),
|
|
13
|
+
onDismiss: /* @__PURE__ */ s((e) => void this.requestClose(e), "onDismiss")
|
|
14
|
+
}), o(this, "generation", 0), o(this, "disclosure", new r({
|
|
15
15
|
component: this,
|
|
16
16
|
member: "isVisible",
|
|
17
|
-
detail: /* @__PURE__ */
|
|
17
|
+
detail: /* @__PURE__ */ s((e, t) => e ? {
|
|
18
18
|
visible: e,
|
|
19
19
|
originalEvent: t
|
|
20
20
|
} : {
|
|
@@ -22,29 +22,29 @@ var O = /* @__PURE__ */ D("<div>"), ge = /* @__PURE__ */ D("<dialog><!><slot></s
|
|
|
22
22
|
reason: this.closeReason,
|
|
23
23
|
originalEvent: t
|
|
24
24
|
}, "detail"),
|
|
25
|
-
afterDetail: /* @__PURE__ */
|
|
26
|
-
})),
|
|
25
|
+
afterDetail: /* @__PURE__ */ s((e) => ({ visible: e }), "afterDetail")
|
|
26
|
+
})), o(this, "closeReason", "escape"), o(this, "isDismissing", !1), o(this, "pressStartedOnBackdrop", !1), o(this, "onPointerDown", /* @__PURE__ */ s((e) => {
|
|
27
27
|
let t = this.dialog;
|
|
28
28
|
if (!t || e.target !== t) return void (this.pressStartedOnBackdrop = !1);
|
|
29
29
|
let n = t.getBoundingClientRect(), { clientX: r, clientY: i } = e;
|
|
30
30
|
this.pressStartedOnBackdrop = r < n.left || r > n.right || i < n.top || i > n.bottom;
|
|
31
|
-
}, "onPointerDown")),
|
|
31
|
+
}, "onPointerDown")), o(this, "onCancel", /* @__PURE__ */ s((e) => {
|
|
32
32
|
e.preventDefault();
|
|
33
33
|
let t = this.pressStartedOnBackdrop ? "outside" : "escape";
|
|
34
34
|
if (this.pressStartedOnBackdrop = !1, this.isDismissing) return;
|
|
35
35
|
let n = this.closedBy;
|
|
36
36
|
n === "none" || t === "outside" && n !== "any" || this.requestClose(t, e);
|
|
37
|
-
}, "onCancel")),
|
|
37
|
+
}, "onCancel")), o(this, "onClose", m(V, 16, this, /* @__PURE__ */ s((e) => {
|
|
38
38
|
!this.dialog?.open && this.domElement.isConnected && (this.closeReason = "escape", this.disclosure.adopt(!1, e));
|
|
39
|
-
}, "onClose"))),
|
|
39
|
+
}, "onClose"))), m(V, 19, this), o(this, "closeButton", new t({
|
|
40
40
|
owner: this,
|
|
41
|
-
shows: /* @__PURE__ */
|
|
42
|
-
label: /* @__PURE__ */
|
|
43
|
-
part: this.dialogPart(
|
|
44
|
-
onClick: /* @__PURE__ */
|
|
45
|
-
})),
|
|
41
|
+
shows: /* @__PURE__ */ s(() => !!this.closable, "shows"),
|
|
42
|
+
label: /* @__PURE__ */ s(() => this.closeText, "label"),
|
|
43
|
+
part: this.dialogPart(b),
|
|
44
|
+
onClick: /* @__PURE__ */ s((e) => this.onCloseIcon(e), "onClick")
|
|
45
|
+
})), o(this, "onCloseIcon", /* @__PURE__ */ s((e) => {
|
|
46
46
|
e.stopPropagation(), this.requestClose("close", e);
|
|
47
|
-
}, "onCloseIcon")),
|
|
47
|
+
}, "onCloseIcon")), o(this, "onDialogClick", /* @__PURE__ */ s((e) => {
|
|
48
48
|
let t = _DialogComponent.actionFor(e, this.domElement);
|
|
49
49
|
if (!t) return;
|
|
50
50
|
let [n, r] = t, i = {
|
|
@@ -52,7 +52,7 @@ var O = /* @__PURE__ */ D("<div>"), ge = /* @__PURE__ */ D("<dialog><!><slot></s
|
|
|
52
52
|
originalEvent: e
|
|
53
53
|
};
|
|
54
54
|
this.fire(n === "approve" ? "ui-approving" : "ui-denying", i) && this.requestClose(n, e);
|
|
55
|
-
}, "onDialogClick")),
|
|
55
|
+
}, "onDialogClick")), oe(this, H, m(V, 8, this, this.findHeading())), m(V, 11, this), o(this, "headerId", ""), this.overlayEntry.kind = this.overlayKind;
|
|
56
56
|
}
|
|
57
57
|
get isModeless() {
|
|
58
58
|
return !1;
|
|
@@ -64,22 +64,22 @@ var O = /* @__PURE__ */ D("<div>"), ge = /* @__PURE__ */ D("<dialog><!><slot></s
|
|
|
64
64
|
return this.disclosure.open(e);
|
|
65
65
|
}
|
|
66
66
|
requestClose(e, t) {
|
|
67
|
-
return this.isVisible ? (this.isDismissing = !0,
|
|
67
|
+
return this.isVisible ? (this.isDismissing = !0, se(() => this.isDismissing = !1), this.closeReason = e, this.disclosure.close(t)) : !1;
|
|
68
68
|
}
|
|
69
69
|
async onVisibleChange(e, t) {
|
|
70
70
|
let n = this.dialog;
|
|
71
71
|
if (!n) return;
|
|
72
72
|
let r = te.keyframesBeside(t, this.elementSetup.animation);
|
|
73
73
|
if (e) {
|
|
74
|
-
this.show(), r && await
|
|
74
|
+
this.show(), r && await l.transitions.animate({
|
|
75
75
|
element: n,
|
|
76
76
|
name: r,
|
|
77
77
|
direction: "in"
|
|
78
78
|
}), await this.transitionsEnd() && this.isVisible && this.disclosure.sendAfter(!0);
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
|
-
let i =
|
|
82
|
-
r && i && await
|
|
81
|
+
let i = l.overlays.isOpen(this.overlayEntry);
|
|
82
|
+
r && i && await l.transitions.animate({
|
|
83
83
|
element: n,
|
|
84
84
|
name: r,
|
|
85
85
|
direction: "out"
|
|
@@ -91,12 +91,12 @@ var O = /* @__PURE__ */ D("<div>"), ge = /* @__PURE__ */ D("<dialog><!><slot></s
|
|
|
91
91
|
show() {
|
|
92
92
|
let e = this.dialog;
|
|
93
93
|
if (!e) return;
|
|
94
|
-
let t = this.isModeless, n = this.closedBy, r =
|
|
95
|
-
r ? e.setAttribute("closedby", n) : e.removeAttribute("closedby"), this.overlayEntry.closeOnEscape = n !== "none", this.overlayEntry.closeOnOutsideClick = !r && n === "any", this.overlayEntry.modal = !t,
|
|
94
|
+
let t = this.isModeless, n = this.closedBy, r = l.browser.supports.dialogClosedBy && !t;
|
|
95
|
+
r ? e.setAttribute("closedby", n) : e.removeAttribute("closedby"), this.overlayEntry.closeOnEscape = n !== "none", this.overlayEntry.closeOnOutsideClick = !r && n === "any", this.overlayEntry.modal = !t, l.transitions.reveal(e), e.open || (t ? e.show() : e.showModal(), l.focus.enter(e)), l.overlays.open(this.overlayEntry);
|
|
96
96
|
}
|
|
97
97
|
hide() {
|
|
98
98
|
let e = this.dialog;
|
|
99
|
-
e?.open && e.close(),
|
|
99
|
+
e?.open && e.close(), l.overlays.close(this.overlayEntry);
|
|
100
100
|
}
|
|
101
101
|
async transitionsEnd() {
|
|
102
102
|
let e = ++this.generation, t = this.dialog?.getAnimations() ?? [];
|
|
@@ -106,14 +106,14 @@ var O = /* @__PURE__ */ D("<div>"), ge = /* @__PURE__ */ D("<dialog><!><slot></s
|
|
|
106
106
|
return this.send(e, t);
|
|
107
107
|
}
|
|
108
108
|
onCommand(e) {
|
|
109
|
-
let t =
|
|
109
|
+
let t = c.action(e, this.isVisible);
|
|
110
110
|
t === "show" ? this.requestOpen(e) : t === "close" && this.requestClose("close", e);
|
|
111
111
|
}
|
|
112
112
|
get closedBy() {
|
|
113
|
-
return this.domElement.hasAttribute("closedby") ? this.closedby ?? "any" : this.domElement.hasAttribute(
|
|
113
|
+
return this.domElement.hasAttribute("closedby") ? this.closedby ?? "any" : this.domElement.hasAttribute(ge) && !this.closable ? "none" : "any";
|
|
114
114
|
}
|
|
115
115
|
get closeText() {
|
|
116
|
-
return this.translationForKey(
|
|
116
|
+
return this.translationForKey(b);
|
|
117
117
|
}
|
|
118
118
|
get ariaLabel() {
|
|
119
119
|
return this.attributes["aria-label"] ?? void 0;
|
|
@@ -122,7 +122,7 @@ var O = /* @__PURE__ */ D("<div>"), ge = /* @__PURE__ */ D("<dialog><!><slot></s
|
|
|
122
122
|
this.slottedHeading = this.findHeading();
|
|
123
123
|
}
|
|
124
124
|
findHeading() {
|
|
125
|
-
for (let e of this.domElement.children) if (
|
|
125
|
+
for (let e of this.domElement.children) if (u.registry.definitions.get(e.localName)?.vocabulary.noun === "header") return e;
|
|
126
126
|
}
|
|
127
127
|
onNameChanged(e, t, n, r) {
|
|
128
128
|
let i = this.dialog;
|
|
@@ -134,62 +134,62 @@ var O = /* @__PURE__ */ D("<div>"), ge = /* @__PURE__ */ D("<dialog><!><slot></s
|
|
|
134
134
|
if (this.ariaLabel) return;
|
|
135
135
|
if (this.heading) return this.headerId;
|
|
136
136
|
let e = this.slottedHeading;
|
|
137
|
-
return e ?
|
|
137
|
+
return e ? l.ids.ensure(e, `ui-${this.elementDefinition.vocabulary.noun}-heading`) : void 0;
|
|
138
138
|
}
|
|
139
139
|
render() {
|
|
140
|
-
this.headerId =
|
|
140
|
+
this.headerId = l.ids.next(`ui-${this.elementDefinition.vocabulary.noun}`);
|
|
141
141
|
let e = this;
|
|
142
|
-
var
|
|
143
|
-
return
|
|
142
|
+
var t = he(), r = t.firstChild, i = r.nextSibling, a = i.nextSibling;
|
|
143
|
+
return S(t, "click", e.onDialogClick, !0), S(t, "pointerdown", e.onPointerDown, !0), S(t, "close", e.onClose), S(t, "cancel", e.onCancel), me(() => (t) => e.dialog = t, t), E(t, w(ue, {
|
|
144
144
|
get when() {
|
|
145
145
|
return e.heading;
|
|
146
146
|
},
|
|
147
147
|
get children() {
|
|
148
|
-
var
|
|
149
|
-
return
|
|
148
|
+
var t = A();
|
|
149
|
+
return E(t, () => e.heading), T(() => ({
|
|
150
150
|
e: e.headerId,
|
|
151
|
-
t:
|
|
152
|
-
a: e.dialogPart(
|
|
153
|
-
}), ({ e, t, a: r }, i) => {
|
|
154
|
-
e !== i?.e &&
|
|
155
|
-
}),
|
|
151
|
+
t: D(n),
|
|
152
|
+
a: e.dialogPart(n)
|
|
153
|
+
}), ({ e, t: n, a: r }, i) => {
|
|
154
|
+
e !== i?.e && O(t, "id", e), C(t, n, i?.t), r !== i?.a && O(t, "part", r);
|
|
155
|
+
}), t;
|
|
156
156
|
}
|
|
157
|
-
}), r),
|
|
157
|
+
}), r), E(t, w(ue, {
|
|
158
158
|
get when() {
|
|
159
159
|
return e.content;
|
|
160
160
|
},
|
|
161
161
|
get children() {
|
|
162
|
-
var t =
|
|
163
|
-
return
|
|
164
|
-
e:
|
|
165
|
-
t: e.dialogPart(
|
|
162
|
+
var t = A();
|
|
163
|
+
return E(t, () => e.content), T(() => ({
|
|
164
|
+
e: D(g),
|
|
165
|
+
t: e.dialogPart(g)
|
|
166
166
|
}), ({ e, t: n }, r) => {
|
|
167
|
-
|
|
167
|
+
C(t, e, r?.e), n !== r?.t && O(t, "part", n);
|
|
168
168
|
}), t;
|
|
169
169
|
}
|
|
170
|
-
}), i), i._$owner =
|
|
171
|
-
e:
|
|
170
|
+
}), i), i._$owner = fe(), E(t, () => e.closeButton.draw(), a), T(() => ({
|
|
171
|
+
e: D(e.rootClass),
|
|
172
172
|
t: e.dialogPart(e.rootPart),
|
|
173
|
-
a:
|
|
174
|
-
}), ({ e, t, a: r }, i) => {
|
|
175
|
-
|
|
176
|
-
}),
|
|
173
|
+
a: pe ? e.serverLabelledBy() : void 0
|
|
174
|
+
}), ({ e, t: n, a: r }, i) => {
|
|
175
|
+
C(t, e, i?.e), n !== i?.t && O(t, "part", n), r !== i?.a && O(t, "aria-labelledby", r);
|
|
176
|
+
}), t;
|
|
177
177
|
}
|
|
178
178
|
dialogPart(e) {
|
|
179
179
|
return this.partForName(e);
|
|
180
180
|
}
|
|
181
181
|
static actionFor(e, t) {
|
|
182
|
-
for (let n of
|
|
183
|
-
let e =
|
|
182
|
+
for (let n of f.lightPath(e, t)) {
|
|
183
|
+
let e = f.of(n);
|
|
184
184
|
if (e) return [e, n];
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
};
|
|
188
|
-
|
|
189
|
-
var
|
|
190
|
-
|
|
188
|
+
V = a(B), H = /* @__PURE__ */ new WeakMap(), d(V, 1, "requestClose", R, U), d(V, 1, "watchPlacement", L, U), d(V, 1, "onCommand", I, U), d(V, 2, "closedBy", F, U), d(V, 4, "slottedHeading", N, U, H), d(V, 1, "onSlotChange", M, U), d(V, 1, "onNameChanged", j, U), d(V, 13, "elementSetup", z, U), d(V, 5, "onClose", P, U), p(V, U), s(U, "DialogComponent"), o(U, "elementSetup", m(V, 12, U, { visible: "hidden" })), m(V, 15, U);
|
|
189
|
+
var W = U, ge = "closable";
|
|
190
|
+
de(["pointerdown", "click"]);
|
|
191
191
|
// src/components/ui-modal/UIModal.en.ts
|
|
192
|
-
var
|
|
192
|
+
var G = {
|
|
193
193
|
tag: "ui-modal",
|
|
194
194
|
icon: "window restore outline",
|
|
195
195
|
topics: [
|
|
@@ -365,12 +365,17 @@ var U = {
|
|
|
365
365
|
{
|
|
366
366
|
key: "ok",
|
|
367
367
|
text: "OK",
|
|
368
|
-
description: "Approve button of `UI.modals.confirm()` / `alert()` / `prompt()
|
|
368
|
+
description: "Approve button of `UI.modals.confirm()` / `alert()` / `prompt()`, and `choose()` picking several."
|
|
369
369
|
},
|
|
370
370
|
{
|
|
371
371
|
key: "cancel",
|
|
372
372
|
text: "Cancel",
|
|
373
|
-
description: "Deny button of `UI.modals.confirm()` / `prompt()`."
|
|
373
|
+
description: "Deny button of `UI.modals.confirm()` / `prompt()` / `choose()`."
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
key: "search",
|
|
377
|
+
text: "Search",
|
|
378
|
+
description: "Search box above a long list of `UI.modals.choose()`."
|
|
374
379
|
}
|
|
375
380
|
],
|
|
376
381
|
ownsParts: [
|
|
@@ -379,12 +384,76 @@ var U = {
|
|
|
379
384
|
"description",
|
|
380
385
|
"actions"
|
|
381
386
|
]
|
|
382
|
-
},
|
|
383
|
-
|
|
384
|
-
styleSheets: { modal:
|
|
387
|
+
}, _e = "@layer ui.components.modal.types{:host{display:contents}.ui.modal{--_ui-modal-background:var(--ui-modal-background,var(--ui-surface));--_ui-modal-color:var(--ui-modal-color,var(--ui-text-color));--_ui-modal-radius:var(--ui-modal-radius,var(--ui-radius));--_ui-modal-shadow:var(--ui-modal-shadow,1px 3px 3px 0 oklch(0% 0 0/.2), 1px 3px 15px 2px oklch(0% 0 0/.2));--_ui-modal-dimmer-background:var(--ui-modal-dimmer-background,var(--ui-dimmer-background,oklch(0% 0 0/.85)));--_ui-modal-duration:var(--ui-modal-duration,var(--ui-duration-slow));--_ui-modal-close-size:var(--ui-modal-close-size,1.25em);--_ui-modal-close-hitbox:var(--ui-modal-close-hitbox,2.25em);--_ui-modal-close-opacity:var(--ui-modal-close-opacity,.8);--_ui-modal-inner-close-top:var(--ui-modal-inner-close-top,1.0625em);--_ui-modal-inner-close-right:var(--ui-modal-inner-close-right,1em);--_ui-modal-width:var(--ui-modal-width,var(--_modal-width));--_ui-modal-aligned-margin:var(--ui-modal-aligned-margin,var(--_modal-aligned-margin));--_modal-ratio:1;--_modal-width:95%;--_modal-aligned-margin:5vh;--_ui-modal-basic:0;--_ui-modal-header-size:var(--ui-modal-header-size,1.42857em);--_ui-modal-header-color:var(--ui-modal-header-color,var(--ui-text-dark));--_ui-modal-header-background:var(--ui-modal-header-background,var(--ui-surface));--_ui-modal-content-background:var(--ui-modal-content-background,var(--ui-surface));--_ui-modal-actions-background:var(--ui-modal-actions-background,var(--ui-surface-muted));--ui-inverted:0;z-index:var(--ui-z-modal);box-sizing:border-box;width:var(--_ui-modal-width);border-radius:var(--_ui-modal-radius);background:var(--_ui-modal-background);max-width:100%;box-shadow:var(--_ui-modal-shadow);color:var(--_ui-modal-color);font-family:var(--ui-font-family);font-size:var(--ui-font-size);line-height:var(--ui-line-height);text-align:start;transform-origin:50% 25%;-webkit-user-select:text;user-select:text;border:none;outline:none;flex:none;margin:0;padding:0;display:none;position:absolute}dialog.ui.modal{overscroll-behavior:contain;opacity:1;max-height:calc(100dvh - 2em);transition:opacity var(--_ui-modal-duration) var(--ui-ease), transform var(--_ui-modal-duration) var(--ui-ease), display var(--_ui-modal-duration) allow-discrete, overlay var(--_ui-modal-duration) allow-discrete;margin:auto;position:fixed;inset:0;overflow:auto;transform:none}dialog.ui.modal[open]{display:block}dialog.ui.modal:not([open]){opacity:0;transform:scale(.8)}@starting-style{dialog.ui.modal[open]{opacity:0;transform:scale(.8)}}dialog.ui.modal::backdrop{background:var(--_ui-modal-dimmer-background);backdrop-filter:var(--ui-modal-dimmer-filter,none);opacity:1;transition:opacity var(--_ui-modal-duration) var(--ui-ease), display var(--_ui-modal-duration) allow-discrete, overlay var(--_ui-modal-duration) allow-discrete}dialog.ui.modal:not([open])::backdrop{opacity:0}@starting-style{dialog.ui.modal[open]::backdrop{opacity:0}}@media (prefers-reduced-motion:reduce){dialog.ui.modal::backdrop{transition-duration:.01ms}}.ui.modal slot{--ui-color:initial;--ui-color-text:initial;--ui-color-header:initial;--ui-color-border:initial;--ui-color-background:initial;--ui-color-inverted:initial;--ui-color-on:initial;--ui-color-inverted-on:initial;--ui-scale:initial}.ui.modal>:first-child:not(.close),.ui.modal>.close:first-child+*{border-start-start-radius:var(--_ui-modal-radius);border-start-end-radius:var(--_ui-modal-radius)}.ui.modal>:last-child{border-end-end-radius:var(--_ui-modal-radius);border-end-start-radius:var(--_ui-modal-radius)}.ui.modal>.header~slot::slotted(:first-child){--_ui-modal-radius:0px}}@layer ui.components.modal.content{.ui.modal>.close{top:calc(-.25em - var(--_ui-modal-close-hitbox));right:calc(-.25em - var(--_ui-modal-close-hitbox));z-index:1;box-sizing:border-box;width:var(--_ui-modal-close-hitbox);height:var(--_ui-modal-close-hitbox);border-radius:var(--ui-radius);color:var(--ui-text-inverted-color);font-size:var(--_ui-modal-close-size);opacity:var(--_ui-modal-close-opacity);cursor:var(--ui-control-cursor);background:0 0;border:none;justify-content:center;align-items:center;margin:0;padding:0;display:inline-flex;position:absolute}.ui.modal>.close>svg{width:1em;height:1em}.ui.modal>.close:is(:hover,:focus-visible){opacity:1}.ui.modal>.close:focus-visible{outline:var(--ui-focus-width) solid var(--ui-focus-color);outline-offset:calc(var(--ui-focus-width) * -1)}dialog.ui.modal>.close,.ui.modal>.close.inside,.ui.fullscreen.modal>.close{top:var(--_ui-modal-inner-close-top);right:var(--_ui-modal-inner-close-right);color:var(--_ui-modal-color);font-size:1em}@media (width<768px),(768px<=width<992px){.ui.modal>.close{top:var(--_ui-modal-inner-close-top);right:var(--_ui-modal-inner-close-right);color:var(--_ui-modal-color);font-size:1em}}.ui.modal:has(>.close)>.header{padding-inline-end:calc(var(--_ui-modal-close-hitbox) * 1.2)}.ui.modal>.header{border-bottom:var(--ui-border-width) solid var(--ui-border-color);background:var(--_ui-modal-header-background);box-shadow:none;color:var(--_ui-modal-header-color);font-family:var(--ui-font-family-heading);margin:0;padding:.875em 1.05em;display:block}.ui.modal>.header:not(.ui){font-size:var(--_ui-modal-header-size);font-weight:var(--ui-font-weight-bold);line-height:var(--ui-line-height-heading)}.ui.modal>.content{box-sizing:border-box;width:100%;padding:var(--ui-modal-content-padding,1.5em);background:var(--_ui-modal-content-background);font-size:1em;line-height:1.4;display:block}.ui.modal>.image.content{flex-direction:row;display:flex}.ui.modal>.content>.image{flex:0 auto;align-self:start;max-width:100%;display:block}.ui.modal>.content>.description{flex:1 0 auto;align-self:start;min-width:0;display:block}.ui.modal>.content>:is(.icon,.image)+.description{width:auto;min-width:auto;flex:auto;padding-inline-start:var(--ui-modal-description-distance,2em)}.ui.modal>.scrolling.content{max-height:var(--ui-modal-scrolling-height,calc(80dvh - 10em));overscroll-behavior:none;overflow:auto}.ui.modal>.actions{padding:var(--ui-modal-actions-padding,1em);border-top:var(--ui-border-width) solid var(--ui-border-color);background:var(--_ui-modal-actions-background);text-align:right}.ui.modal .actions>.button:not(.fluid){margin-inline-start:var(--ui-modal-button-distance,.75em)}.ui.modal>.left.actions{text-align:left}.ui.modal>.left.actions>.button:not(.fluid){margin-inline:.5em}.ui.modal>:is(.centered,[class*=center\\ aligned]){text-align:center}.ui.modal>:is(.centered,[class*=center\\ aligned]).actions>.button:not(.fluid){margin-inline:.5em}@media (width<768px){.ui.modal>.header{padding:.525em .7em}.ui.modal>.content{padding:1em;display:block}.ui.modal .image.content{flex-direction:column}.ui.modal>.content>.image{text-align:center;max-width:100%;margin:0 auto;padding:0 0 1em;display:block}.ui.modal>.content>.description,.ui.modal>.content>:is(.icon,.image)+.description{width:100%;margin:0;padding:1em 0;display:block}.ui.modal>.actions{padding:1em 1em 0}.ui.modal .actions>:is(.buttons,.button){margin-bottom:1em}}}@layer ui.components.modal.variations{.ui.mini.modal{--_modal-ratio:.4;--_ui-modal-header-size:1.3em}.ui.tiny.modal{--_modal-ratio:.6;--_ui-modal-header-size:1.3em}.ui.small.modal{--_modal-ratio:.8;--_ui-modal-header-size:1.3em}.ui.large.modal{--_modal-ratio:1.2;--_ui-modal-header-size:1.6em}.ui.big.modal{--_modal-ratio:1.4;--_ui-modal-header-size:1.6em}.ui.huge.modal{--_modal-ratio:1.6;--_ui-modal-header-size:1.6em}.ui.massive.modal{--_modal-ratio:1.8;--_ui-modal-header-size:1.8em}@media (768px<=width<992px){.ui.modal{--_modal-width:calc(88% * min(var(--_modal-ratio), 1))}}@media (width>=992px){.ui.modal{--_modal-width:calc(850px * var(--_modal-ratio))}}@media (width>=1200px){.ui.modal{--_modal-width:calc(900px * var(--_modal-ratio))}}@media (width>=1920px){.ui.modal{--_modal-width:calc(950px * var(--_modal-ratio))}}.ui.fullscreen.modal{--_ui-modal-width:95%}dialog.ui.fullscreen.modal{margin-block:1em}.ui.overlay.fullscreen.modal{--_ui-modal-width:100%;border-radius:0}dialog.ui.overlay.fullscreen.modal{height:100dvh;max-height:100dvh;margin:0}dialog.ui[class*=top\\ aligned].modal{margin-block:var(--_ui-modal-aligned-margin) auto}dialog.ui[class*=bottom\\ aligned].modal{margin-block:auto var(--_ui-modal-aligned-margin)}@media (width<768px){.ui.modal{--_modal-aligned-margin:1em}}dialog.ui.scrolling.modal{max-height:calc(100dvh - 4em)}.ui.basic.modal{--_ui-modal-basic:1;--_ui-modal-background:transparent;--_ui-modal-color:var(--ui-text-inverted-color);--_ui-modal-header-color:var(--ui-text-inverted-color);--_ui-modal-header-background:transparent;--_ui-modal-content-background:transparent;--_ui-modal-actions-background:transparent;box-shadow:none;border-radius:0}.ui.basic.modal>.header{border-bottom:none}.ui.basic.modal>.actions{border-top:none}.ui.basic.modal>.close{color:var(--ui-text-inverted-color);top:1em;right:1.5em}.ui.transparent.modal{--_ui-modal-background:transparent;--_ui-modal-header-background:transparent;--_ui-modal-content-background:transparent;--_ui-modal-actions-background:transparent;box-shadow:none;border-radius:0;padding:0}.ui.inverted.modal{--ui-inverted:1;--ui-scheme:dark;color-scheme:dark}}@layer ui.components.modal.states{.ui.active.modal{display:block}}", K, q, J, Y, X, Z, Q, $ = class _UIModal extends (Z = W, X = [v], Y = [y], J = [v], q = [v], K = [v], Z) {};
|
|
388
|
+
Q = a(Z), d(Q, 13, "vocabulary", X, $), d(Q, 13, "elementSetup", Y, $), d(Q, 13, "rootPart", J, $), d(Q, 13, "overlayKind", q, $), d(Q, 13, "shownClass", K, $), p(Q, $), s($, "UIModal"), o($, "vocabulary", m(Q, 8, $, G)), m(Q, 11, $), o($, "elementSetup", m(Q, 12, $, {
|
|
389
|
+
styleSheets: { modal: _e },
|
|
385
390
|
animation: "scale"
|
|
386
|
-
})),
|
|
387
|
-
var
|
|
391
|
+
})), m(Q, 15, $), o($, "rootPart", m(Q, 16, $, "modal")), m(Q, 19, $), o($, "overlayKind", m(Q, 20, $, "modal")), m(Q, 23, $), o($, "shownClass", m(Q, 24, $, "active")), m(Q, 27, $);
|
|
392
|
+
var ve = $, ChoiceRows = class {
|
|
393
|
+
element;
|
|
394
|
+
several;
|
|
395
|
+
picked = /* @__PURE__ */ new Set();
|
|
396
|
+
onPicked = () => {};
|
|
397
|
+
onCountChanged = () => {};
|
|
398
|
+
document;
|
|
399
|
+
least;
|
|
400
|
+
most;
|
|
401
|
+
constructor({ document: e, options: t, tagFor: n }) {
|
|
402
|
+
let { rows: r, several: i = !1, least: a = 1, most: o = r.length, shown: s } = t;
|
|
403
|
+
this.document = e, this.several = i, this.least = a, this.most = o, this.element = e.createElement("div"), this.element.style.cssText = Ce, r.length > 20 ? this.drawList(r, n, s ?? ye) : this.drawButtons(r, n, s);
|
|
404
|
+
}
|
|
405
|
+
get fits() {
|
|
406
|
+
return this.picked.size >= this.least && this.picked.size <= this.most;
|
|
407
|
+
}
|
|
408
|
+
get positions() {
|
|
409
|
+
return [...this.picked].sort((e, t) => e - t);
|
|
410
|
+
}
|
|
411
|
+
drawButtons(e, t, n) {
|
|
412
|
+
let r = this.scroller(n, e.some((e) => e.color) ? xe : be);
|
|
413
|
+
e.forEach((e, n) => {
|
|
414
|
+
let i = this.document.createElement(t(h));
|
|
415
|
+
i.toggleAttribute(Ne, !0), i.setAttribute(Fe, Ie), i.append(...this.words(e, t)), this.several ? (i.toggleAttribute(Pe, !0), i.addEventListener(He, () => this.turn(n, !0)), i.addEventListener(Ue, () => this.turn(n, !1))) : i.addEventListener("click", () => this.pick(n)), r.append(i);
|
|
416
|
+
}), this.element.append(r);
|
|
417
|
+
}
|
|
418
|
+
drawList(e, t, n) {
|
|
419
|
+
let r = this.document.createElement("input");
|
|
420
|
+
r.type = "search", r.className = Oe, r.autofocus = !0, r.setAttribute("aria-label", l.i18n.t(ke)), r.placeholder = l.i18n.t(ke);
|
|
421
|
+
let i = this.scroller(n, Se), a = this.document.createElement(t(Ae));
|
|
422
|
+
a.toggleAttribute(Le, !0), a.toggleAttribute(Re, !0);
|
|
423
|
+
let o = e.map((e, n) => {
|
|
424
|
+
let r = this.document.createElement(t(je));
|
|
425
|
+
return r.setAttribute(ze, String(n)), r.append(...this.words(e, t)), a.append(r), {
|
|
426
|
+
item: r,
|
|
427
|
+
words: e.title.toLocaleLowerCase()
|
|
428
|
+
};
|
|
429
|
+
});
|
|
430
|
+
a.addEventListener(We, (e) => {
|
|
431
|
+
let { item: t } = e.detail, n = Number(t.getAttribute(ze));
|
|
432
|
+
if (!this.several) return this.pick(n);
|
|
433
|
+
let r = !this.picked.has(n);
|
|
434
|
+
t.toggleAttribute(Be, r), this.turn(n, r);
|
|
435
|
+
}), r.addEventListener("input", () => {
|
|
436
|
+
let e = r.value.trim().toLocaleLowerCase();
|
|
437
|
+
for (let { item: t, words: n } of o) t.hidden = !!e && !n.includes(e);
|
|
438
|
+
}), i.append(a), this.element.append(r, i);
|
|
439
|
+
}
|
|
440
|
+
scroller(e, t) {
|
|
441
|
+
let n = this.document.createElement("div");
|
|
442
|
+
return n.style.cssText = e ? `${Te};max-height:${e * t}em` : we, n;
|
|
443
|
+
}
|
|
444
|
+
words({ title: e, color: t }, n) {
|
|
445
|
+
let r = this.document.createTextNode(e);
|
|
446
|
+
if (!t) return [r];
|
|
447
|
+
let i = this.document.createElement(n(Me));
|
|
448
|
+
return i.setAttribute(Ve, De.has(t) ? `var(--ui-${t})` : t), i.setAttribute("aria-hidden", "true"), i.style.marginInlineEnd = Ee, [i, r];
|
|
449
|
+
}
|
|
450
|
+
pick(e) {
|
|
451
|
+
this.picked.clear(), this.picked.add(e), this.onPicked();
|
|
452
|
+
}
|
|
453
|
+
turn(e, t) {
|
|
454
|
+
t ? this.picked.add(e) : this.picked.delete(e), this.onCountChanged();
|
|
455
|
+
}
|
|
456
|
+
}, ye = 10, be = 2.75, xe = 3.125, Se = 2.2, Ce = "display: grid; gap: 0.5em; margin-top: 1em", we = "display: grid; gap: 0.25em", Te = `${we};overflow-y:auto;overscroll-behavior:contain;padding:4px;margin:-4px`, Ee = "0.5em", De = new Set(e), Oe = "ui-native", ke = "search", Ae = "list", je = "item", Me = "colour chip", Ne = "fluid", Pe = "toggle", Fe = "appearance", Ie = "basic", Le = "selection", Re = "divided", ze = "value", Be = "selected", Ve = "color", He = "ui-selected", Ue = "ui-deselected", We = "ui-chosen", Ge = class ModalDialogs {
|
|
388
457
|
document;
|
|
389
458
|
constructor({ document: e = globalThis.document } = {}) {
|
|
390
459
|
this.document = e;
|
|
@@ -401,45 +470,62 @@ var Q = Z, ye = class ModalDialogs {
|
|
|
401
470
|
input: e.value ?? ""
|
|
402
471
|
}, (e, t) => e ? t : void 0);
|
|
403
472
|
}
|
|
473
|
+
async choose(e) {
|
|
474
|
+
e.rows.length > 20 && await import("./ui-list.js"), e.rows.some((e) => e.color) && await import("./ui-theme-editor.js");
|
|
475
|
+
let t = new ChoiceRows({
|
|
476
|
+
document: this.document,
|
|
477
|
+
options: e,
|
|
478
|
+
tagFor: ModalDialogs.tagFor
|
|
479
|
+
});
|
|
480
|
+
return this.run(e, {
|
|
481
|
+
canDeny: !0,
|
|
482
|
+
rows: t
|
|
483
|
+
}, (e) => e || !t.several && t.picked.size ? t.positions : void 0);
|
|
484
|
+
}
|
|
404
485
|
run(e, t, n) {
|
|
405
|
-
return e.markdown &&
|
|
406
|
-
}
|
|
407
|
-
open(e, { canDeny: t, input: n },
|
|
408
|
-
let
|
|
409
|
-
|
|
410
|
-
let
|
|
411
|
-
|
|
412
|
-
let
|
|
413
|
-
t &&
|
|
414
|
-
let
|
|
415
|
-
|
|
416
|
-
e.key ===
|
|
486
|
+
return e.markdown && re(e.message) ? this.markdown(e).then((r) => this.open(e, t, n, r)) : this.open(e, t, n);
|
|
487
|
+
}
|
|
488
|
+
open(e, { canDeny: t, input: n, rows: r }, a, o) {
|
|
489
|
+
let s = this.document.createElement(G.tag);
|
|
490
|
+
s.setAttribute(Je, Ze), s.setAttribute("closedby", "closerequest"), e.closable !== !1 && s.setAttribute(Xe, ""), e.title ? s.setAttribute(ee, e.title) : s.setAttribute("aria-label", e.message);
|
|
491
|
+
let c = this.document.createElement(ModalDialogs.tagFor(g)), u = n === void 0 ? void 0 : this.input(n);
|
|
492
|
+
c.append(u ? this.label(e.message, u, o) : o ?? this.paragraph(e)), r && c.append(r.element);
|
|
493
|
+
let d = this.document.createElement(ModalDialogs.tagFor(ot));
|
|
494
|
+
t && d.append(this.button(e.cancelText ?? l.i18n.t(ut), ut));
|
|
495
|
+
let f = this.button(e.okText ?? l.i18n.t(dt), lt);
|
|
496
|
+
f.setAttribute(ct, e.okColor ?? st), (!r || r.several) && d.append(f), r && this.answerWith(r, s, f), s.append(c, d), u?.addEventListener("keydown", (e) => {
|
|
497
|
+
e.key === i.enter && f.click();
|
|
417
498
|
});
|
|
418
|
-
let
|
|
419
|
-
return this.document.body.append(
|
|
499
|
+
let p = o && ModalDialogs.drawn(o);
|
|
500
|
+
return this.document.body.append(s), p ? p.then(() => s.visible = !0) : s.visible = !0, new Promise((e) => {
|
|
420
501
|
let t = !1;
|
|
421
|
-
|
|
422
|
-
|
|
502
|
+
s.addEventListener(Ke, () => t = !0), s.addEventListener(qe, () => {
|
|
503
|
+
s.remove(), e(a(t, u?.value ?? ""));
|
|
423
504
|
}, { once: !0 });
|
|
424
505
|
});
|
|
425
506
|
}
|
|
507
|
+
answerWith(e, t, n) {
|
|
508
|
+
e.onPicked = () => t.visible = !1;
|
|
509
|
+
let updateApprove = () => n.toggleAttribute(Ye, !e.fits);
|
|
510
|
+
e.onCountChanged = updateApprove, updateApprove();
|
|
511
|
+
}
|
|
426
512
|
paragraph({ message: e, size: t }) {
|
|
427
513
|
let n = this.document.createElement("p");
|
|
428
|
-
if (n.style.whiteSpace =
|
|
514
|
+
if (n.style.whiteSpace = pt, t && t !== Qe) {
|
|
429
515
|
let r = this.document.createElement("span");
|
|
430
|
-
r.className =
|
|
516
|
+
r.className = $e + t, r.textContent = e, n.append(r);
|
|
431
517
|
} else n.textContent = e;
|
|
432
518
|
return n;
|
|
433
519
|
}
|
|
434
520
|
async markdown({ message: e, size: t }) {
|
|
435
521
|
await import("./ui-markdown.js");
|
|
436
|
-
let n = this.document.createElement(ModalDialogs.tagFor(
|
|
437
|
-
return n.toggleAttribute(
|
|
522
|
+
let n = this.document.createElement(ModalDialogs.tagFor(et));
|
|
523
|
+
return n.toggleAttribute(tt, !0), n.toggleAttribute(nt, !0), t && t !== Qe && n.setAttribute(Je, t), n.style.marginBlock = rt, n.textContent = e, n;
|
|
438
524
|
}
|
|
439
525
|
static drawn(e) {
|
|
440
526
|
return new Promise((t) => {
|
|
441
|
-
let n = ne(
|
|
442
|
-
e.addEventListener(
|
|
527
|
+
let n = ne(at, t);
|
|
528
|
+
e.addEventListener(it, () => {
|
|
443
529
|
n.cancel(), t();
|
|
444
530
|
}, { once: !0 });
|
|
445
531
|
});
|
|
@@ -450,20 +536,20 @@ var Q = Z, ye = class ModalDialogs {
|
|
|
450
536
|
}
|
|
451
537
|
label(e, t, n) {
|
|
452
538
|
let r = this.document.createElement("label");
|
|
453
|
-
r.className =
|
|
539
|
+
r.className = ft, r.style.cssText = mt;
|
|
454
540
|
let i = n;
|
|
455
|
-
return i || (i = this.document.createElement("span"), i.style.whiteSpace =
|
|
541
|
+
return i || (i = this.document.createElement("span"), i.style.whiteSpace = pt, i.textContent = e), r.append(i, t), r;
|
|
456
542
|
}
|
|
457
543
|
button(e, t) {
|
|
458
|
-
let n = this.document.createElement(ModalDialogs.tagFor(
|
|
544
|
+
let n = this.document.createElement(ModalDialogs.tagFor(h));
|
|
459
545
|
return n.className = t, n.textContent = e, n;
|
|
460
546
|
}
|
|
461
547
|
static tagFor(e) {
|
|
462
|
-
for (let t of
|
|
548
|
+
for (let t of l.vocabulary.vocabularies.values()) if (t.noun === e) return t.tag;
|
|
463
549
|
throw Error(`UI.modals: no component with the class noun "${e}" is registered; import its family (\`spell/ui/components/ui-parts\`, \`ui-button\`) before opening a dialog`);
|
|
464
550
|
}
|
|
465
|
-
},
|
|
466
|
-
|
|
467
|
-
export {
|
|
551
|
+
}, Ke = "ui-approving", qe = "ui-closed", Je = "size", Ye = "disabled", Xe = "closable", Ze = "tiny", Qe = "medium", $e = "ui-font-size-", et = "markdown", tt = "sanitized", nt = "breaks", rt = "1em", it = "ui-drawn", at = 1, ot = "actions", st = "primary", ct = "color", lt = "approve", ut = "cancel", dt = "ok", ft = "ui-native", pt = "pre-line", mt = "display: grid; gap: 0.5em";
|
|
552
|
+
ve.define(), ie() && l.load().then(() => l.modals.register(new Ge()));
|
|
553
|
+
export { W as DialogComponent, Ge as ModalDialogs, ve as UIModal };
|
|
468
554
|
|
|
469
555
|
//# sourceMappingURL=ui-modal.js.map
|