@namroodinc/liquid-editorial 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -5
- package/UPGRADING.md +152 -0
- package/dist/chunks/{Board-BaQ04nWg.cjs → Board-BPA6mVhf.cjs} +2 -2
- package/dist/chunks/{Board-BaQ04nWg.cjs.map → Board-BPA6mVhf.cjs.map} +1 -1
- package/dist/chunks/{Board-CUhF8pTX.js → Board-CcIF7jS0.js} +2 -2
- package/dist/chunks/{Board-CUhF8pTX.js.map → Board-CcIF7jS0.js.map} +1 -1
- package/dist/chunks/{ColourField-CJicr3OT.cjs → ColourField-BQ4a5tAV.cjs} +2 -2
- package/dist/chunks/{ColourField-CJicr3OT.cjs.map → ColourField-BQ4a5tAV.cjs.map} +1 -1
- package/dist/chunks/{ColourField-DjHRiFDU.js → ColourField-Doew1hLw.js} +3 -3
- package/dist/chunks/{ColourField-DjHRiFDU.js.map → ColourField-Doew1hLw.js.map} +1 -1
- package/dist/chunks/{DatePicker-aSlYLjtW.cjs → DatePicker-C0-609Zx.cjs} +2 -2
- package/dist/chunks/{DatePicker-aSlYLjtW.cjs.map → DatePicker-C0-609Zx.cjs.map} +1 -1
- package/dist/chunks/{DatePicker-D_6CQpUd.js → DatePicker-DmeWUsOS.js} +2 -2
- package/dist/chunks/{DatePicker-D_6CQpUd.js.map → DatePicker-DmeWUsOS.js.map} +1 -1
- package/dist/chunks/{FormEditor-M7tNidFo.js → FormEditor-DTnFO4oS.js} +172 -154
- package/dist/chunks/FormEditor-DTnFO4oS.js.map +1 -0
- package/dist/chunks/FormEditor-DfQLJnsO.cjs +2 -0
- package/dist/chunks/FormEditor-DfQLJnsO.cjs.map +1 -0
- package/dist/chunks/Icon-D1kx7-1c.js +81 -0
- package/dist/chunks/Icon-D1kx7-1c.js.map +1 -0
- package/dist/chunks/Icon-D38lQXNe.cjs +2 -0
- package/dist/chunks/Icon-D38lQXNe.cjs.map +1 -0
- package/dist/chunks/RichTextEditor-DEJ-u-ZR.js +483 -0
- package/dist/chunks/RichTextEditor-DEJ-u-ZR.js.map +1 -0
- package/dist/chunks/RichTextEditor-Ddk7qaqg.cjs +2 -0
- package/dist/chunks/RichTextEditor-Ddk7qaqg.cjs.map +1 -0
- package/dist/chunks/movableHost-CajG9_5Z.cjs +2 -0
- package/dist/chunks/movableHost-CajG9_5Z.cjs.map +1 -0
- package/dist/chunks/movableHost-NJj_FsAu.js +23 -0
- package/dist/chunks/movableHost-NJj_FsAu.js.map +1 -0
- package/dist/chunks/portalScope-AzzPM54i.js +105 -0
- package/dist/chunks/portalScope-AzzPM54i.js.map +1 -0
- package/dist/chunks/portalScope-BVA1-Ypu.cjs +2 -0
- package/dist/chunks/portalScope-BVA1-Ypu.cjs.map +1 -0
- package/dist/chunks/useModalDialog-BVaG--b3.js +87 -0
- package/dist/chunks/useModalDialog-BVaG--b3.js.map +1 -0
- package/dist/chunks/useModalDialog-Ctu270Dp.cjs +2 -0
- package/dist/chunks/useModalDialog-Ctu270Dp.cjs.map +1 -0
- package/dist/components/AssetCard/index.cjs +1 -1
- package/dist/components/AssetCard/index.js +1 -1
- package/dist/components/AssetGrid/index.cjs +1 -1
- package/dist/components/AssetGrid/index.js +1 -1
- package/dist/components/Board/index.cjs +1 -1
- package/dist/components/Board/index.js +1 -1
- package/dist/components/Button/index.cjs +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/ColourField/index.cjs +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.cjs.map +1 -1
- package/dist/components/Drawer/index.d.cts.map +1 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +59 -75
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Drawer/style.css +3 -0
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.cjs.map +1 -1
- package/dist/components/EditLayout/index.d.cts.map +1 -1
- package/dist/components/EditLayout/index.d.ts.map +1 -1
- package/dist/components/EditLayout/index.js +107 -121
- package/dist/components/EditLayout/index.js.map +1 -1
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.js +1 -1
- package/dist/components/FormEditor/README.md +75 -4
- package/dist/components/FormEditor/control.d.cts.map +1 -1
- package/dist/components/FormEditor/control.d.ts.map +1 -1
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.d.cts.map +1 -1
- package/dist/components/FormEditor/index.d.ts.map +1 -1
- package/dist/components/FormEditor/index.js +2 -1
- package/dist/components/FormEditor/model.d.cts +8 -0
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts +8 -0
- package/dist/components/FormEditor/model.d.ts.map +1 -1
- package/dist/components/FormEditor/style.css +7 -0
- package/dist/components/Icon/icons.d.cts +2 -0
- package/dist/components/Icon/icons.d.cts.map +1 -1
- package/dist/components/Icon/icons.d.ts +2 -0
- package/dist/components/Icon/icons.d.ts.map +1 -1
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.js +1 -1
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.cjs.map +1 -1
- package/dist/components/Modal/index.d.cts +9 -1
- package/dist/components/Modal/index.d.cts.map +1 -1
- package/dist/components/Modal/index.d.ts +9 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.js +37 -45
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/style.css +8 -1
- package/dist/components/Popover/index.cjs +1 -1
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.d.cts.map +1 -1
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +44 -37
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/Popover/style.css +3 -0
- package/dist/components/RichTextEditor/expanded-width.d.cts +4 -0
- package/dist/components/RichTextEditor/expanded-width.d.cts.map +1 -0
- package/dist/components/RichTextEditor/expanded-width.d.ts +4 -0
- package/dist/components/RichTextEditor/expanded-width.d.ts.map +1 -0
- package/dist/components/RichTextEditor/expansion.d.cts +28 -0
- package/dist/components/RichTextEditor/expansion.d.cts.map +1 -0
- package/dist/components/RichTextEditor/expansion.d.ts +28 -0
- package/dist/components/RichTextEditor/expansion.d.ts.map +1 -0
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.d.cts +4 -4
- package/dist/components/RichTextEditor/index.d.cts.map +1 -1
- package/dist/components/RichTextEditor/index.d.ts +4 -4
- package/dist/components/RichTextEditor/index.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.js +1 -1
- package/dist/components/RichTextEditor/style.css +85 -4
- package/dist/components/SearchField/index.cjs +1 -1
- package/dist/components/SearchField/index.js +1 -1
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/SideNav/index.cjs +1 -1
- package/dist/components/SideNav/index.js +1 -1
- package/dist/components/SortableList/index.cjs +1 -1
- package/dist/components/SortableList/index.js +1 -1
- package/dist/components/Stepper/index.cjs +1 -1
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/SubNav/index.cjs +1 -1
- package/dist/components/SubNav/index.js +1 -1
- package/dist/components/Table/index.cjs +1 -1
- package/dist/components/Table/index.js +1 -1
- package/dist/components/Toast/index.cjs +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/TopNav/index.cjs +1 -1
- package/dist/components/TopNav/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -30
- package/dist/internal/dialogFocus.d.cts +8 -0
- package/dist/internal/dialogFocus.d.cts.map +1 -1
- package/dist/internal/dialogFocus.d.ts +8 -0
- package/dist/internal/dialogFocus.d.ts.map +1 -1
- package/dist/internal/movableHost.d.cts +20 -0
- package/dist/internal/movableHost.d.cts.map +1 -0
- package/dist/internal/movableHost.d.ts +20 -0
- package/dist/internal/movableHost.d.ts.map +1 -0
- package/dist/internal/portalScope.d.cts +23 -0
- package/dist/internal/portalScope.d.cts.map +1 -0
- package/dist/internal/portalScope.d.ts +23 -0
- package/dist/internal/portalScope.d.ts.map +1 -0
- package/dist/internal/useModalDialog.d.cts +22 -0
- package/dist/internal/useModalDialog.d.cts.map +1 -0
- package/dist/internal/useModalDialog.d.ts +22 -0
- package/dist/internal/useModalDialog.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/chunks/FormEditor-M7tNidFo.js.map +0 -1
- package/dist/chunks/FormEditor-UzbPdiJo.cjs +0 -2
- package/dist/chunks/FormEditor-UzbPdiJo.cjs.map +0 -1
- package/dist/chunks/Icon-BBoWP_Y6.cjs +0 -2
- package/dist/chunks/Icon-BBoWP_Y6.cjs.map +0 -1
- package/dist/chunks/Icon-XNismJDm.js +0 -79
- package/dist/chunks/Icon-XNismJDm.js.map +0 -1
- package/dist/chunks/RichTextEditor-C7nMfDmE.cjs +0 -2
- package/dist/chunks/RichTextEditor-C7nMfDmE.cjs.map +0 -1
- package/dist/chunks/RichTextEditor-DjR10XJ-.js +0 -370
- package/dist/chunks/RichTextEditor-DjR10XJ-.js.map +0 -1
- package/dist/chunks/dialogFocus-B9iqKl3I.cjs +0 -2
- package/dist/chunks/dialogFocus-B9iqKl3I.cjs.map +0 -1
- package/dist/chunks/dialogFocus-BFoyeTpA.js +0 -48
- package/dist/chunks/dialogFocus-BFoyeTpA.js.map +0 -1
- package/dist/chunks/dialogStack-6yv3NXFD.js +0 -43
- package/dist/chunks/dialogStack-6yv3NXFD.js.map +0 -1
- package/dist/chunks/dialogStack-C9SLVu6Q.cjs +0 -2
- package/dist/chunks/dialogStack-C9SLVu6Q.cjs.map +0 -1
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
import { Button as e } from "../components/Button/index.js";
|
|
2
|
-
import { ButtonGroup as t } from "../components/ButtonGroup/index.js";
|
|
3
|
-
/* empty css */
|
|
4
|
-
import { Field as n } from "../components/Field/index.js";
|
|
5
|
-
import { Modal as r } from "../components/Modal/index.js";
|
|
6
|
-
import { TextField as i } from "../components/TextField/index.js";
|
|
7
|
-
import { forwardRef as a, useCallback as o, useEffect as s, useId as c, useMemo as l, useState as u } from "react";
|
|
8
|
-
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
9
|
-
import { EditorContent as m, createDocument as h, getMarkRange as g, getSchema as _, useEditor as v, useEditorState as y } from "@tiptap/react";
|
|
10
|
-
import { Placeholder as b } from "@tiptap/extension-placeholder";
|
|
11
|
-
import { StarterKit as x } from "@tiptap/starter-kit";
|
|
12
|
-
import { Link as S } from "@tiptap/extension-link";
|
|
13
|
-
//#region src/components/RichTextEditor/document.ts
|
|
14
|
-
var C = {
|
|
15
|
-
type: "doc",
|
|
16
|
-
content: [{ type: "paragraph" }]
|
|
17
|
-
};
|
|
18
|
-
function w() {
|
|
19
|
-
return [x.configure({ link: !1 }), S.configure({
|
|
20
|
-
openOnClick: !1,
|
|
21
|
-
autolink: !0
|
|
22
|
-
})];
|
|
23
|
-
}
|
|
24
|
-
var T = _(w());
|
|
25
|
-
function E(e) {
|
|
26
|
-
return e.content?.length ? e : {
|
|
27
|
-
...e,
|
|
28
|
-
content: C.content
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function D(e) {
|
|
32
|
-
try {
|
|
33
|
-
if (!e || typeof e != "object" || !("type" in e) || e.type !== "doc") throw Error();
|
|
34
|
-
let t = (e) => {
|
|
35
|
-
let n = T.nodes[e.type ?? ""];
|
|
36
|
-
if (!n || Object.keys(e).some((e) => ![
|
|
37
|
-
"type",
|
|
38
|
-
"attrs",
|
|
39
|
-
"content",
|
|
40
|
-
"marks",
|
|
41
|
-
"text"
|
|
42
|
-
].includes(e)) || e.text !== void 0 && e.type !== "text" || e.attrs && Object.keys(e.attrs).some((e) => !Object.hasOwn(n.spec.attrs ?? {}, e))) throw Error();
|
|
43
|
-
for (let t of e.marks ?? []) {
|
|
44
|
-
let e = T.marks[t.type];
|
|
45
|
-
if (!e || Object.keys(t).some((e) => !["type", "attrs"].includes(e)) || Object.keys(t.attrs ?? {}).some((t) => !Object.hasOwn(e.spec.attrs ?? {}, t))) throw Error();
|
|
46
|
-
}
|
|
47
|
-
e.content?.forEach(t);
|
|
48
|
-
}, n = e;
|
|
49
|
-
t(n), T.nodeFromJSON(E(n)).check();
|
|
50
|
-
} catch {
|
|
51
|
-
return "Unsupported or invalid rich-text document.";
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/components/RichTextEditor/index.tsx
|
|
56
|
-
function O({ editor: t, selection: a, onClose: o }) {
|
|
57
|
-
let [l, m] = u(a.href), [h, g] = u(), _ = c();
|
|
58
|
-
s(() => {
|
|
59
|
-
let e = () => {
|
|
60
|
-
t.state.doc.eq(a.document) || o();
|
|
61
|
-
};
|
|
62
|
-
return t.on("transaction", e), () => {
|
|
63
|
-
t.off("transaction", e);
|
|
64
|
-
};
|
|
65
|
-
}, [
|
|
66
|
-
t,
|
|
67
|
-
a,
|
|
68
|
-
o
|
|
69
|
-
]);
|
|
70
|
-
let v = () => !t.isDestroyed && t.isEditable && t.state.doc.eq(a.document), y = () => {
|
|
71
|
-
if (!v()) {
|
|
72
|
-
o();
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
let e = l.trim();
|
|
76
|
-
if (!e || !t.can().setLink({ href: e })) {
|
|
77
|
-
g(e ? "Enter a valid link URL." : "Enter a link URL.");
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
let n = t.chain().focus().setTextSelection({
|
|
81
|
-
from: a.from,
|
|
82
|
-
to: a.to
|
|
83
|
-
});
|
|
84
|
-
a.from === a.to && !a.isEditing ? n.setLink({ href: e }).insertContent({
|
|
85
|
-
type: "text",
|
|
86
|
-
text: e,
|
|
87
|
-
marks: [{
|
|
88
|
-
type: "link",
|
|
89
|
-
attrs: { href: e }
|
|
90
|
-
}]
|
|
91
|
-
}).run() : n.setLink({ href: e }).run(), o();
|
|
92
|
-
};
|
|
93
|
-
return /* @__PURE__ */ f(r, {
|
|
94
|
-
isOpen: !0,
|
|
95
|
-
title: a.isEditing ? "Edit link" : "Add link",
|
|
96
|
-
size: "dialog",
|
|
97
|
-
onClose: o,
|
|
98
|
-
footer: /* @__PURE__ */ p(d, { children: [
|
|
99
|
-
a.isEditing && /* @__PURE__ */ f(e, {
|
|
100
|
-
variant: "danger",
|
|
101
|
-
onClick: () => {
|
|
102
|
-
v() && t.chain().focus().setTextSelection({
|
|
103
|
-
from: a.from,
|
|
104
|
-
to: a.to
|
|
105
|
-
}).unsetLink().run(), o();
|
|
106
|
-
},
|
|
107
|
-
children: "Remove link"
|
|
108
|
-
}),
|
|
109
|
-
/* @__PURE__ */ f(e, {
|
|
110
|
-
onClick: o,
|
|
111
|
-
children: "Cancel"
|
|
112
|
-
}),
|
|
113
|
-
/* @__PURE__ */ f(e, {
|
|
114
|
-
variant: "primary",
|
|
115
|
-
type: "submit",
|
|
116
|
-
form: _,
|
|
117
|
-
children: "Save"
|
|
118
|
-
})
|
|
119
|
-
] }),
|
|
120
|
-
children: /* @__PURE__ */ f("form", {
|
|
121
|
-
id: _,
|
|
122
|
-
noValidate: !0,
|
|
123
|
-
onSubmit: (e) => {
|
|
124
|
-
e.preventDefault(), e.stopPropagation(), y();
|
|
125
|
-
},
|
|
126
|
-
children: /* @__PURE__ */ f(n, {
|
|
127
|
-
label: "URL",
|
|
128
|
-
isRequired: !0,
|
|
129
|
-
error: h,
|
|
130
|
-
children: (e) => /* @__PURE__ */ f(i, {
|
|
131
|
-
...e,
|
|
132
|
-
value: l,
|
|
133
|
-
inputMode: "url",
|
|
134
|
-
autoComplete: "url",
|
|
135
|
-
placeholder: "https://example.com",
|
|
136
|
-
onChange: (e) => {
|
|
137
|
-
m(e.target.value), g(void 0);
|
|
138
|
-
}
|
|
139
|
-
})
|
|
140
|
-
})
|
|
141
|
-
})
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
var k = [
|
|
145
|
-
[
|
|
146
|
-
{
|
|
147
|
-
id: "bold",
|
|
148
|
-
icon: "bold",
|
|
149
|
-
label: "Bold",
|
|
150
|
-
run: (e) => e.chain().focus().toggleBold().run(),
|
|
151
|
-
active: (e) => e.isActive("bold")
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
id: "italic",
|
|
155
|
-
icon: "italic",
|
|
156
|
-
label: "Italic",
|
|
157
|
-
run: (e) => e.chain().focus().toggleItalic().run(),
|
|
158
|
-
active: (e) => e.isActive("italic")
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
id: "strike",
|
|
162
|
-
icon: "strikethrough",
|
|
163
|
-
label: "Strikethrough",
|
|
164
|
-
run: (e) => e.chain().focus().toggleStrike().run(),
|
|
165
|
-
active: (e) => e.isActive("strike")
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
id: "code",
|
|
169
|
-
icon: "code",
|
|
170
|
-
label: "Inline code",
|
|
171
|
-
run: (e) => e.chain().focus().toggleCode().run(),
|
|
172
|
-
active: (e) => e.isActive("code")
|
|
173
|
-
}
|
|
174
|
-
],
|
|
175
|
-
[
|
|
176
|
-
{
|
|
177
|
-
id: "h2",
|
|
178
|
-
icon: "heading-2",
|
|
179
|
-
label: "Heading",
|
|
180
|
-
run: (e) => e.chain().focus().toggleHeading({ level: 2 }).run(),
|
|
181
|
-
active: (e) => e.isActive("heading", { level: 2 })
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
id: "h3",
|
|
185
|
-
icon: "heading-3",
|
|
186
|
-
label: "Subheading",
|
|
187
|
-
run: (e) => e.chain().focus().toggleHeading({ level: 3 }).run(),
|
|
188
|
-
active: (e) => e.isActive("heading", { level: 3 })
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
id: "quote",
|
|
192
|
-
icon: "quote",
|
|
193
|
-
label: "Quote",
|
|
194
|
-
run: (e) => e.chain().focus().toggleBlockquote().run(),
|
|
195
|
-
active: (e) => e.isActive("blockquote")
|
|
196
|
-
}
|
|
197
|
-
],
|
|
198
|
-
[{
|
|
199
|
-
id: "ul",
|
|
200
|
-
icon: "list",
|
|
201
|
-
label: "Bulleted list",
|
|
202
|
-
run: (e) => e.chain().focus().toggleBulletList().run(),
|
|
203
|
-
active: (e) => e.isActive("bulletList")
|
|
204
|
-
}, {
|
|
205
|
-
id: "ol",
|
|
206
|
-
icon: "list-ordered",
|
|
207
|
-
label: "Numbered list",
|
|
208
|
-
run: (e) => e.chain().focus().toggleOrderedList().run(),
|
|
209
|
-
active: (e) => e.isActive("orderedList")
|
|
210
|
-
}],
|
|
211
|
-
[{
|
|
212
|
-
id: "undo",
|
|
213
|
-
icon: "undo",
|
|
214
|
-
label: "Undo",
|
|
215
|
-
run: (e) => e.chain().focus().undo().run()
|
|
216
|
-
}, {
|
|
217
|
-
id: "redo",
|
|
218
|
-
icon: "redo",
|
|
219
|
-
label: "Redo",
|
|
220
|
-
run: (e) => e.chain().focus().redo().run()
|
|
221
|
-
}]
|
|
222
|
-
];
|
|
223
|
-
function A({ editor: n, state: r, disabled: i, label: a, toolbarExtra: o, openLink: s }) {
|
|
224
|
-
return /* @__PURE__ */ p("div", {
|
|
225
|
-
className: "ds-rte__toolbar",
|
|
226
|
-
role: "toolbar",
|
|
227
|
-
"aria-label": `${a} formatting`,
|
|
228
|
-
children: [
|
|
229
|
-
k.map((a, o) => /* @__PURE__ */ f(t, {
|
|
230
|
-
"aria-label": `Formatting ${o + 1}`,
|
|
231
|
-
children: a.map((t) => /* @__PURE__ */ f(e, {
|
|
232
|
-
size: "sm",
|
|
233
|
-
isIconOnly: !0,
|
|
234
|
-
iconStart: t.icon,
|
|
235
|
-
"aria-label": t.label,
|
|
236
|
-
title: t.label,
|
|
237
|
-
"aria-pressed": t.active ? r?.active[t.id] : void 0,
|
|
238
|
-
variant: r?.active[t.id] ? "active" : "neutral",
|
|
239
|
-
isDisabled: i || !n,
|
|
240
|
-
onClick: () => n && t.run(n)
|
|
241
|
-
}, t.id))
|
|
242
|
-
}, o)),
|
|
243
|
-
/* @__PURE__ */ f(t, {
|
|
244
|
-
"aria-label": "Link",
|
|
245
|
-
children: /* @__PURE__ */ f(e, {
|
|
246
|
-
size: "sm",
|
|
247
|
-
isIconOnly: !0,
|
|
248
|
-
iconStart: "link",
|
|
249
|
-
"aria-label": r?.linkActive ? "Edit link" : "Add link",
|
|
250
|
-
title: r?.linkActive ? "Edit link" : "Add link",
|
|
251
|
-
variant: r?.linkActive ? "active" : "neutral",
|
|
252
|
-
isDisabled: i || !n,
|
|
253
|
-
onClick: () => n && s(n.state, n.isActive("link") ? n.state.selection.from : void 0)
|
|
254
|
-
})
|
|
255
|
-
}),
|
|
256
|
-
o
|
|
257
|
-
]
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
var j = a(function(e, t) {
|
|
261
|
-
let { placeholder: n = "Write something…", size: r = "md", isDisabled: i = !1, isInvalid: a = !1, label: d = "Rich text editor", className: _, toolbarExtra: x, id: S, isRequired: T, required: j, "aria-label": M, "aria-labelledby": N, "aria-describedby": P, "aria-invalid": F } = e, [I, L] = u(!1), [R, z] = u(null), B = o(() => z(null), []), [V] = u(() => e.defaultValue ?? (e.format === "json" ? C : "")), H = e.value === void 0 ? V : e.value, U = l(() => e.format === "json" ? D(H) : void 0, [e.format, H]), W = c(), G = a || !!U || F, K = i || !!U;
|
|
262
|
-
K && R && z(null);
|
|
263
|
-
let q = o((e, t) => {
|
|
264
|
-
if (K) return;
|
|
265
|
-
let n = t === void 0 ? void 0 : g(e.doc.resolve(t), e.schema.marks.link), r = n && e.doc.nodeAt(n.from)?.marks.find((t) => t.type === e.schema.marks.link);
|
|
266
|
-
z({
|
|
267
|
-
from: n?.from ?? e.selection.from,
|
|
268
|
-
to: n?.to ?? e.selection.to,
|
|
269
|
-
href: r?.attrs.href ?? "",
|
|
270
|
-
isEditing: !!r,
|
|
271
|
-
document: e.doc
|
|
272
|
-
});
|
|
273
|
-
}, [K]), J = l(() => ({
|
|
274
|
-
role: "textbox",
|
|
275
|
-
...N ? {} : { "aria-label": M ?? d },
|
|
276
|
-
"aria-multiline": "true",
|
|
277
|
-
...S ? { id: S } : {},
|
|
278
|
-
...N ? { "aria-labelledby": N } : {},
|
|
279
|
-
...P ? { "aria-describedby": P } : {},
|
|
280
|
-
...G ? { "aria-invalid": String(G) } : {},
|
|
281
|
-
...T || j ? { "aria-required": "true" } : {}
|
|
282
|
-
}), [
|
|
283
|
-
d,
|
|
284
|
-
M,
|
|
285
|
-
S,
|
|
286
|
-
N,
|
|
287
|
-
P,
|
|
288
|
-
G,
|
|
289
|
-
T,
|
|
290
|
-
j
|
|
291
|
-
]), Y = l(() => ({
|
|
292
|
-
attributes: J,
|
|
293
|
-
handleDOMEvents: { click: (e, t) => {
|
|
294
|
-
let n = t.target instanceof Element ? t.target.closest("a") : null;
|
|
295
|
-
return !n || !e.dom.contains(n) ? !1 : (t.preventDefault(), e.editable && q(e.state, e.posAtDOM(n, 0)), !0);
|
|
296
|
-
} }
|
|
297
|
-
}), [J, q]), X = v({
|
|
298
|
-
immediatelyRender: !1,
|
|
299
|
-
editable: !K,
|
|
300
|
-
content: U ? C : typeof H == "string" ? H : E(H),
|
|
301
|
-
extensions: [...w(), b.configure({ placeholder: n })],
|
|
302
|
-
editorProps: Y,
|
|
303
|
-
onFocus: () => L(!0),
|
|
304
|
-
onBlur: () => L(!1),
|
|
305
|
-
onUpdate: ({ editor: t }) => {
|
|
306
|
-
K || (e.format === "json" ? e.onChange?.(t.getJSON()) : e.onChange?.(t.getHTML()));
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
s(() => {
|
|
310
|
-
X && (X.setEditable(!K, !1), X.setOptions({ editorProps: Y }));
|
|
311
|
-
}, [
|
|
312
|
-
X,
|
|
313
|
-
K,
|
|
314
|
-
Y
|
|
315
|
-
]), s(() => {
|
|
316
|
-
if (!X || e.value === void 0 || U) return;
|
|
317
|
-
let t = typeof e.value == "string" ? h(e.value, X.schema) : X.schema.nodeFromJSON(E(e.value));
|
|
318
|
-
t.eq(X.state.doc) || X.commands.setContent(t, { emitUpdate: !1 });
|
|
319
|
-
}, [
|
|
320
|
-
X,
|
|
321
|
-
e.value,
|
|
322
|
-
U
|
|
323
|
-
]);
|
|
324
|
-
let Z = y({
|
|
325
|
-
editor: X,
|
|
326
|
-
selector: ({ editor: e }) => e ? {
|
|
327
|
-
active: Object.fromEntries(k.flat().map((t) => [t.id, t.active?.(e) ?? !1])),
|
|
328
|
-
linkActive: e.isActive("link")
|
|
329
|
-
} : null
|
|
330
|
-
});
|
|
331
|
-
return /* @__PURE__ */ p("div", {
|
|
332
|
-
ref: t,
|
|
333
|
-
className: ["ds-rte", _].filter(Boolean).join(" "),
|
|
334
|
-
"data-focused": I || void 0,
|
|
335
|
-
"data-disabled": K || void 0,
|
|
336
|
-
"aria-invalid": G || void 0,
|
|
337
|
-
children: [
|
|
338
|
-
U && /* @__PURE__ */ f("p", {
|
|
339
|
-
id: W,
|
|
340
|
-
role: "alert",
|
|
341
|
-
className: "ds-field__error",
|
|
342
|
-
children: U
|
|
343
|
-
}),
|
|
344
|
-
/* @__PURE__ */ p("div", {
|
|
345
|
-
hidden: !!U,
|
|
346
|
-
children: [/* @__PURE__ */ f(A, {
|
|
347
|
-
editor: X,
|
|
348
|
-
state: Z,
|
|
349
|
-
disabled: K,
|
|
350
|
-
label: d,
|
|
351
|
-
toolbarExtra: x,
|
|
352
|
-
openLink: q
|
|
353
|
-
}), /* @__PURE__ */ f("div", {
|
|
354
|
-
className: "ds-rte__content",
|
|
355
|
-
"data-size": r,
|
|
356
|
-
children: /* @__PURE__ */ f(m, { editor: X })
|
|
357
|
-
})]
|
|
358
|
-
}),
|
|
359
|
-
X && R && !K && /* @__PURE__ */ f(O, {
|
|
360
|
-
editor: X,
|
|
361
|
-
selection: R,
|
|
362
|
-
onClose: B
|
|
363
|
-
})
|
|
364
|
-
]
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
//#endregion
|
|
368
|
-
export { D as n, C as r, j as t };
|
|
369
|
-
|
|
370
|
-
//# sourceMappingURL=RichTextEditor-DjR10XJ-.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextEditor-DjR10XJ-.js","names":["_Fragment","Fragment$1","emptyDocument","richTextExtensions","StarterKit","Link","schema","getSchema","normalizeDocument","document","documentError","value","check","type","node","key","mark","markType","LinkDialog","href","setHref","useState","selection","error","setError","formId","useId","onTransaction","editor","onClose","canEdit","save","url","chain","Modal","Button","event","Field","TextField","field","GROUPS","EditorToolbar","label","ButtonGroup","i","group","tool","state","disabled","openLink","toolbarExtra","RichTextEditor","forwardRef","ariaLabel","labelledBy","describedBy","ariaInvalid","props","isFocused","setIsFocused","linkSelection","setLinkSelection","closeLink","useCallback","initialValue","content","contentError","useMemo","errorId","invalid","isInvalid","isDisabled","range","position","getMarkRange","link","attributes","id","isRequired","required","editorProps","anchor","view","useEditor","Placeholder","e","useEffect","next","createDocument","useEditorState","className","size","EditorContent"],"sources":["../../src/components/RichTextEditor/document.ts","../../src/components/RichTextEditor/index.tsx"],"sourcesContent":["import { getSchema, type JSONContent } from \"@tiptap/react\";\nimport { StarterKit } from \"@tiptap/starter-kit\";\nimport { Link } from \"@tiptap/extension-link\";\n\nexport type RichTextDocument = JSONContent & { type: \"doc\" };\n\nexport const emptyDocument: RichTextDocument = { type: \"doc\", content: [{ type: \"paragraph\" }] };\n\nexport function richTextExtensions() {\n return [\n StarterKit.configure({ link: false }),\n Link.configure({ openOnClick: false, autolink: true }),\n ];\n}\n\nconst schema = getSchema(richTextExtensions());\n\n/** ProseMirror represents an empty writing surface with one empty paragraph. */\nexport function normalizeDocument(document: RichTextDocument): RichTextDocument {\n return !document.content?.length ? { ...document, content: emptyDocument.content } : document;\n}\n\nexport function documentError(value: unknown): string | undefined {\n try {\n if (!value || typeof value !== \"object\" || !(\"type\" in value) || value.type !== \"doc\") {\n throw new Error();\n }\n const check = (node: JSONContent) => {\n const type = schema.nodes[node.type ?? \"\"];\n if (\n !type ||\n Object.keys(node).some(\n (key) => ![\"type\", \"attrs\", \"content\", \"marks\", \"text\"].includes(key),\n ) ||\n (node.text !== undefined && node.type !== \"text\") ||\n (node.attrs &&\n Object.keys(node.attrs).some((key) => !Object.hasOwn(type.spec.attrs ?? {}, key)))\n ) {\n throw new Error();\n }\n for (const mark of node.marks ?? []) {\n const markType = schema.marks[mark.type];\n if (\n !markType ||\n Object.keys(mark).some((key) => ![\"type\", \"attrs\"].includes(key)) ||\n Object.keys(mark.attrs ?? {}).some(\n (key) => !Object.hasOwn(markType.spec.attrs ?? {}, key),\n )\n ) {\n throw new Error();\n }\n }\n node.content?.forEach(check);\n };\n const document = value as RichTextDocument;\n check(document);\n schema.nodeFromJSON(normalizeDocument(document)).check();\n } catch {\n return \"Unsupported or invalid rich-text document.\";\n }\n}\n","import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useMemo,\n useState,\n type ReactNode,\n} from \"react\";\nimport {\n createDocument,\n EditorContent,\n getMarkRange,\n useEditor,\n useEditorState,\n type Editor,\n type EditorOptions,\n} from \"@tiptap/react\";\nimport { Placeholder } from \"@tiptap/extension-placeholder\";\nimport { Button } from \"../Button\";\nimport { ButtonGroup } from \"../ButtonGroup\";\nimport { Field } from \"../Field\";\nimport { Modal } from \"../Modal\";\nimport { TextField } from \"../TextField\";\nimport type { IconName } from \"../Icon/icons\";\nimport {\n documentError,\n emptyDocument,\n normalizeDocument,\n richTextExtensions,\n type RichTextDocument,\n} from \"./document\";\nimport \"../Field/style.css\";\nimport type { FieldBinding } from \"../Field\";\nimport \"./style.css\";\n\nexport type RichTextEditorSize = \"sm\" | \"md\" | \"lg\";\n\nexport type { RichTextDocument } from \"./document\";\n\ninterface RichTextEditorCommonProps extends FieldBinding {\n placeholder?: string;\n size?: RichTextEditorSize;\n isDisabled?: boolean;\n isInvalid?: boolean;\n /** Accessible name for the editing surface. */\n label?: string;\n className?: string;\n /** Extra controls appended to the toolbar, e.g. a word count. */\n toolbarExtra?: ReactNode;\n isRequired?: boolean;\n}\n\nexport type RichTextEditorProps = RichTextEditorCommonProps &\n (\n | { format?: \"html\"; value?: string; defaultValue?: string; onChange?: (html: string) => void }\n | {\n format: \"json\";\n value?: RichTextDocument;\n defaultValue?: RichTextDocument;\n onChange?: (document: RichTextDocument) => void;\n }\n );\n\ninterface ToolItem {\n id: string;\n icon: IconName;\n label: string;\n run: (editor: Editor) => void;\n active?: (editor: Editor) => boolean;\n}\n\ninterface LinkSelection {\n from: number;\n to: number;\n href: string;\n isEditing: boolean;\n document: Editor[\"state\"][\"doc\"];\n}\n\nfunction LinkDialog({\n editor,\n selection,\n onClose,\n}: {\n editor: Editor;\n selection: LinkSelection;\n onClose: () => void;\n}) {\n const [href, setHref] = useState(selection.href);\n const [error, setError] = useState<string>();\n const formId = useId();\n\n useEffect(() => {\n const onTransaction = () => {\n if (!editor.state.doc.eq(selection.document)) {\n onClose();\n }\n };\n editor.on(\"transaction\", onTransaction);\n return () => {\n editor.off(\"transaction\", onTransaction);\n };\n }, [editor, selection, onClose]);\n\n const canEdit = () =>\n !editor.isDestroyed && editor.isEditable && editor.state.doc.eq(selection.document);\n const save = () => {\n if (!canEdit()) {\n onClose();\n return;\n }\n const url = href.trim();\n if (!url || !editor.can().setLink({ href: url })) {\n setError(url ? \"Enter a valid link URL.\" : \"Enter a link URL.\");\n return;\n }\n const chain = editor\n .chain()\n .focus()\n .setTextSelection({ from: selection.from, to: selection.to });\n if (selection.from === selection.to && !selection.isEditing) {\n chain\n .setLink({ href: url })\n .insertContent({ type: \"text\", text: url, marks: [{ type: \"link\", attrs: { href: url } }] })\n .run();\n } else {\n chain.setLink({ href: url }).run();\n }\n onClose();\n };\n\n return (\n <Modal\n isOpen\n title={selection.isEditing ? \"Edit link\" : \"Add link\"}\n size=\"dialog\"\n onClose={onClose}\n footer={\n <>\n {selection.isEditing && (\n <Button\n variant=\"danger\"\n onClick={() => {\n if (canEdit()) {\n editor\n .chain()\n .focus()\n .setTextSelection({ from: selection.from, to: selection.to })\n .unsetLink()\n .run();\n }\n onClose();\n }}\n >\n Remove link\n </Button>\n )}\n <Button onClick={onClose}>Cancel</Button>\n <Button\n variant=\"primary\"\n type=\"submit\"\n form={formId}\n >\n Save\n </Button>\n </>\n }\n >\n <form\n id={formId}\n noValidate\n onSubmit={(event) => {\n event.preventDefault();\n event.stopPropagation();\n save();\n }}\n >\n <Field\n label=\"URL\"\n isRequired\n error={error}\n >\n {(field) => (\n <TextField\n {...field}\n value={href}\n inputMode=\"url\"\n autoComplete=\"url\"\n placeholder=\"https://example.com\"\n onChange={(event) => {\n setHref(event.target.value);\n setError(undefined);\n }}\n />\n )}\n </Field>\n </form>\n </Modal>\n );\n}\n\nconst GROUPS: ToolItem[][] = [\n [\n {\n id: \"bold\",\n icon: \"bold\",\n label: \"Bold\",\n run: (e) => e.chain().focus().toggleBold().run(),\n active: (e) => e.isActive(\"bold\"),\n },\n {\n id: \"italic\",\n icon: \"italic\",\n label: \"Italic\",\n run: (e) => e.chain().focus().toggleItalic().run(),\n active: (e) => e.isActive(\"italic\"),\n },\n {\n id: \"strike\",\n icon: \"strikethrough\",\n label: \"Strikethrough\",\n run: (e) => e.chain().focus().toggleStrike().run(),\n active: (e) => e.isActive(\"strike\"),\n },\n {\n id: \"code\",\n icon: \"code\",\n label: \"Inline code\",\n run: (e) => e.chain().focus().toggleCode().run(),\n active: (e) => e.isActive(\"code\"),\n },\n ],\n [\n {\n id: \"h2\",\n icon: \"heading-2\",\n label: \"Heading\",\n run: (e) => e.chain().focus().toggleHeading({ level: 2 }).run(),\n active: (e) => e.isActive(\"heading\", { level: 2 }),\n },\n {\n id: \"h3\",\n icon: \"heading-3\",\n label: \"Subheading\",\n run: (e) => e.chain().focus().toggleHeading({ level: 3 }).run(),\n active: (e) => e.isActive(\"heading\", { level: 3 }),\n },\n {\n id: \"quote\",\n icon: \"quote\",\n label: \"Quote\",\n run: (e) => e.chain().focus().toggleBlockquote().run(),\n active: (e) => e.isActive(\"blockquote\"),\n },\n ],\n [\n {\n id: \"ul\",\n icon: \"list\",\n label: \"Bulleted list\",\n run: (e) => e.chain().focus().toggleBulletList().run(),\n active: (e) => e.isActive(\"bulletList\"),\n },\n {\n id: \"ol\",\n icon: \"list-ordered\",\n label: \"Numbered list\",\n run: (e) => e.chain().focus().toggleOrderedList().run(),\n active: (e) => e.isActive(\"orderedList\"),\n },\n ],\n [\n {\n id: \"undo\",\n icon: \"undo\",\n label: \"Undo\",\n run: (e) => e.chain().focus().undo().run(),\n },\n {\n id: \"redo\",\n icon: \"redo\",\n label: \"Redo\",\n run: (e) => e.chain().focus().redo().run(),\n },\n ],\n];\n\ninterface ToolbarState {\n active: Record<string, boolean>;\n linkActive: boolean;\n}\n\nfunction EditorToolbar({\n editor,\n state,\n disabled,\n label,\n toolbarExtra,\n openLink,\n}: {\n editor: Editor | null;\n state: ToolbarState | null;\n disabled: boolean;\n label: string;\n toolbarExtra: ReactNode;\n openLink: (state: Editor[\"state\"], position?: number) => void;\n}) {\n return (\n <div\n className=\"ds-rte__toolbar\"\n role=\"toolbar\"\n aria-label={`${label} formatting`}\n >\n {GROUPS.map((group, i) => (\n <ButtonGroup\n key={i}\n aria-label={`Formatting ${i + 1}`}\n >\n {group.map((tool) => (\n <Button\n key={tool.id}\n size=\"sm\"\n isIconOnly\n iconStart={tool.icon}\n aria-label={tool.label}\n title={tool.label}\n aria-pressed={tool.active ? state?.active[tool.id] : undefined}\n variant={state?.active[tool.id] ? \"active\" : \"neutral\"}\n isDisabled={disabled || !editor}\n onClick={() => editor && tool.run(editor)}\n />\n ))}\n </ButtonGroup>\n ))}\n <ButtonGroup aria-label=\"Link\">\n <Button\n size=\"sm\"\n isIconOnly\n iconStart=\"link\"\n aria-label={state?.linkActive ? \"Edit link\" : \"Add link\"}\n title={state?.linkActive ? \"Edit link\" : \"Add link\"}\n variant={state?.linkActive ? \"active\" : \"neutral\"}\n isDisabled={disabled || !editor}\n onClick={() =>\n editor &&\n openLink(\n editor.state,\n editor.isActive(\"link\") ? editor.state.selection.from : undefined,\n )\n }\n />\n </ButtonGroup>\n {toolbarExtra}\n </div>\n );\n}\n\n/**\n * The editorial writing surface. Rich text plus links — the same field skin,\n * radius and states as `TextField`, with the toolbar inside the frame.\n */\nexport const RichTextEditor = forwardRef<HTMLDivElement, RichTextEditorProps>(\n function RichTextEditor(props, ref) {\n const {\n placeholder = \"Write something…\",\n size = \"md\",\n isDisabled = false,\n isInvalid = false,\n label = \"Rich text editor\",\n className,\n toolbarExtra,\n id,\n isRequired,\n required,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": labelledBy,\n \"aria-describedby\": describedBy,\n \"aria-invalid\": ariaInvalid,\n } = props;\n const [isFocused, setIsFocused] = useState(false);\n const [linkSelection, setLinkSelection] = useState<LinkSelection | null>(null);\n const closeLink = useCallback(() => setLinkSelection(null), []);\n const [initialValue] = useState(\n () => props.defaultValue ?? (props.format === \"json\" ? emptyDocument : \"\"),\n );\n const content = props.value !== undefined ? props.value : initialValue;\n const contentError = useMemo(\n () => (props.format === \"json\" ? documentError(content) : undefined),\n [props.format, content],\n );\n const errorId = useId();\n const invalid = isInvalid || !!contentError || ariaInvalid;\n const disabled = isDisabled || !!contentError;\n if (disabled && linkSelection) {\n setLinkSelection(null);\n }\n const openLink = useCallback(\n (state: Editor[\"state\"], position?: number) => {\n if (disabled) {\n return;\n }\n const range =\n position === undefined\n ? undefined\n : getMarkRange(state.doc.resolve(position), state.schema.marks.link);\n const link =\n range &&\n state.doc.nodeAt(range.from)?.marks.find((mark) => mark.type === state.schema.marks.link);\n setLinkSelection({\n from: range?.from ?? state.selection.from,\n to: range?.to ?? state.selection.to,\n href: link?.attrs.href ?? \"\",\n isEditing: !!link,\n document: state.doc,\n });\n },\n [disabled],\n );\n const attributes = useMemo(\n () => ({\n role: \"textbox\",\n ...(!labelledBy ? { \"aria-label\": ariaLabel ?? label } : {}),\n \"aria-multiline\": \"true\",\n ...(id ? { id } : {}),\n ...(labelledBy ? { \"aria-labelledby\": labelledBy } : {}),\n ...(describedBy ? { \"aria-describedby\": describedBy } : {}),\n ...(invalid ? { \"aria-invalid\": String(invalid) } : {}),\n ...(isRequired || required ? { \"aria-required\": \"true\" } : {}),\n }),\n [label, ariaLabel, id, labelledBy, describedBy, invalid, isRequired, required],\n );\n const editorProps = useMemo<EditorOptions[\"editorProps\"]>(\n () => ({\n attributes,\n handleDOMEvents: {\n click: (view, event) => {\n const anchor = event.target instanceof Element ? event.target.closest(\"a\") : null;\n if (!anchor || !view.dom.contains(anchor)) {\n return false;\n }\n event.preventDefault();\n if (view.editable) {\n openLink(view.state, view.posAtDOM(anchor, 0));\n }\n return true;\n },\n },\n }),\n [attributes, openLink],\n );\n\n const editor = useEditor({\n immediatelyRender: false,\n editable: !disabled,\n content: contentError\n ? emptyDocument\n : typeof content === \"string\"\n ? content\n : normalizeDocument(content),\n extensions: [...richTextExtensions(), Placeholder.configure({ placeholder })],\n editorProps,\n onFocus: () => setIsFocused(true),\n onBlur: () => setIsFocused(false),\n onUpdate: ({ editor: e }) => {\n if (disabled) {\n return;\n }\n if (props.format === \"json\") {\n props.onChange?.(e.getJSON() as RichTextDocument);\n } else {\n props.onChange?.(e.getHTML());\n }\n },\n });\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n editor.setEditable(!disabled, false);\n editor.setOptions({ editorProps });\n }, [editor, disabled, editorProps]);\n\n useEffect(() => {\n if (!editor || props.value === undefined || contentError) {\n return;\n }\n const next =\n typeof props.value === \"string\"\n ? createDocument(props.value, editor.schema)\n : editor.schema.nodeFromJSON(normalizeDocument(props.value));\n // Parent echoes should preserve the current selection and undo history.\n if (!next.eq(editor.state.doc)) {\n editor.commands.setContent(next, { emitUpdate: false });\n }\n }, [editor, props.value, contentError]);\n\n const state = useEditorState({\n editor,\n selector: ({ editor: e }) =>\n e\n ? {\n active: Object.fromEntries(GROUPS.flat().map((t) => [t.id, t.active?.(e) ?? false])),\n linkActive: e.isActive(\"link\"),\n }\n : null,\n });\n\n return (\n <div\n ref={ref}\n className={[\"ds-rte\", className].filter(Boolean).join(\" \")}\n data-focused={isFocused || undefined}\n data-disabled={disabled || undefined}\n aria-invalid={invalid || undefined}\n >\n {contentError && (\n <p\n id={errorId}\n role=\"alert\"\n className=\"ds-field__error\"\n >\n {contentError}\n </p>\n )}\n <div hidden={!!contentError}>\n <EditorToolbar\n editor={editor}\n state={state}\n disabled={disabled}\n label={label}\n toolbarExtra={toolbarExtra}\n openLink={openLink}\n />\n <div\n className=\"ds-rte__content\"\n data-size={size}\n >\n <EditorContent editor={editor} />\n </div>\n </div>\n {editor && linkSelection && !disabled && (\n <LinkDialog\n editor={editor}\n selection={linkSelection}\n onClose={closeLink}\n />\n )}\n </div>\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;AAMA,IAAaE,IAAkC;CAAE,MAAM;CAAO,SAAS,CAAC,EAAE,MAAM,YAAY,CAAC;AAAE;AAE/F,SAAgBC,IAAqB;CACnC,OAAO,CACLC,EAAW,UAAU,EAAE,MAAM,GAAM,CAAC,GACpCC,EAAK,UAAU;EAAE,aAAa;EAAO,UAAU;CAAK,CAAC,CACvD;AACF;AAEA,IAAMC,IAASC,EAAUJ,EAAmB,CAAC;AAG7C,SAAgBK,EAAkB,GAA8C;CAC9E,OAAQC,EAAS,SAAS,SAA2DA,IAAlD;EAAE,GAAGA;EAAU,SAASP,EAAc;CAAQ;AACnF;AAEA,SAAgBQ,EAAc,GAAoC;CAChE,IAAI;EACF,IAAI,CAACC,KAAS,OAAOA,KAAU,YAAY,EAAE,UAAUA,MAAUA,EAAM,SAAS,OAC9E,MAAU,MAAM;EAElB,IAAMC,KAAS,MAAsB;GACnC,IAAM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EAAO,OAAO,aAAapB,EAAkBiD,EAAM,KAAK,CAAC;EAE/D,AAAK8B,EAAK,GAAG3D,EAAO,MAAM,GAAG,KAC3BA,EAAO,SAAS,WAAW2D,GAAM,EAAE,YAAY,GAAM,CAAC;CAE1D,GAAG;EAAC3D;EAAQ6B,EAAM;EAAOS;CAAY,CAAC;CAEtC,IAAMnB,IAAQ0C,EAAe;EAC3B;EACA,WAAW,EAAE,QAAQ,QACnB,IACI;GACE,QAAQ,OAAO,YAAYjD,EAAO,KAAK,CAAC,CAAC,KAAK,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,KAAK,EAAK,CAAC,CAAC;GACnF,YAAY,EAAE,SAAS,MAAM;EAC/B,IACA;CACR,CAAC;CAED,OACE,kBAAC,OAAD;EACO;EACL,WAAW,CAAC,UAAUkD,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EACzD,gBAAchC,KAAa,KAAA;EAC3B,iBAAeV,KAAY,KAAA;EAC3B,gBAAcqB,KAAW,KAAA;EAL3B,UAAA;GAOGH,KACC,kBAAC,KAAD;IACE,IAAIE;IACJ,MAAK;IACL,WAAU;IAET,UAAAF;GACA,CAAA;GAEL,kBAAC,OAAD;IAAK,QAAQ,CAAC,CAACA;IAAf,UAAA,CACE,kBAACzB,GAAD;KACU;KACD;KACG;KACH;KACO;KACJ;IACX,CAAA,GACD,kBAAC,OAAD;KACE,WAAU;KACV,aAAWkD;KAEX,UAAA,kBAACC,GAAD,EAAuB,UAAS,CAAA;IAC7B,CAAA,CACF;;GACJhE,KAAUgC,KAAiB,CAACZ,KAC3B,kBAAC9B,GAAD;IACU;IACR,WAAW0C;IACX,SAASE;GACV,CAAA;EAEA;;AAET,CACF"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function e(e){return(e.checkVisibility?.()??!e.closest(`[hidden]`))&&!e.closest(`[inert]`)}function t(e){return e instanceof HTMLInputElement&&e.type===`radio`}function n(e,n){return e===n||t(e)&&t(n)&&e.name!==``&&e.name===n.name&&e.form===n.form}function r(r){let i=Array.from(r.querySelectorAll(`:is(button, [href], input:not([type='hidden']), select, textarea, [tabindex], [contenteditable]:not([contenteditable='false'])):not(:disabled):not([tabindex='-1']):not([aria-hidden='true'])`)).filter(e);return i.filter(e=>!t(e)||e.checked||!i.some(r=>t(r)&&r.checked&&n(r,e)))}var i=new WeakMap;function a(e,t){return i.set(e,t),()=>{i.delete(e)}}function o(e){let t=e instanceof Element?e:e.parentElement;for(;t&&!i.has(t);)t=t.parentElement;return t}function s(e,t){let n=new Set,r=o(t);for(;r&&!n.has(r);){n.add(r);let t=i.get(r);if(e.contains(t))return!0;r=o(t)}return!1}function c(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}function l(e,t){if(e.key!==`Tab`||e.defaultPrevented||!t)return;let i=r(t),a=i[0],o=i.at(-1);if(!a||!o)return;let l=t.getRootNode().activeElement??document.activeElement,u=l!==null&&t.contains(l);!u&&l&&s(t,l)||(!u||(e.shiftKey?n(l,a)||c(l,a):n(l,o)||c(o,l)))&&(e.preventDefault(),(e.shiftKey?o:a).focus())}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|
|
2
|
-
//# sourceMappingURL=dialogFocus-B9iqKl3I.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dialogFocus-B9iqKl3I.cjs","names":["canTakeFocus","element","isRadio","sameStop","a","b","tabbableControls","controls","container","control","other","popupAnchors","registerPopup","popup","anchor","popupAround","node","inOwnedPopup","visited","panel","precedes","trapTabFocus","event","first","last","active","inside"],"sources":["../../src/internal/dialogFocus.ts"],"sourcesContent":["const focusableSelector =\n \":is(button, [href], input:not([type='hidden']), select, textarea, [tabindex], [contenteditable]:not([contenteditable='false'])):not(:disabled):not([tabindex='-1']):not([aria-hidden='true'])\";\n\n// Unrendered controls (display: none, [hidden], closed <details>) and inert\n// subtrees cannot take focus. Environments without checkVisibility fall back\n// to the hidden attribute.\nfunction canTakeFocus(element: HTMLElement) {\n return (\n (element.checkVisibility?.() ?? !element.closest(\"[hidden]\")) && !element.closest(\"[inert]\")\n );\n}\n\nfunction isRadio(element: Element | null): element is HTMLInputElement {\n return element instanceof HTMLInputElement && element.type === \"radio\";\n}\n\n/** Radios sharing a name and form are one Tab stop. */\nfunction sameStop(a: Element, b: Element) {\n return (\n a === b || (isRadio(a) && isRadio(b) && a.name !== \"\" && a.name === b.name && a.form === b.form)\n );\n}\n\n/**\n * The controls Tab visits inside `container`, in document order. A radio group\n * contributes only its checked radio, or every radio while none is checked.\n */\nexport function tabbableControls(container: HTMLElement) {\n const controls = Array.from(container.querySelectorAll<HTMLElement>(focusableSelector)).filter(\n canTakeFocus,\n );\n return controls.filter(\n (control) =>\n !isRadio(control) ||\n control.checked ||\n !controls.some((other) => isRadio(other) && other.checked && sameStop(other, control)),\n );\n}\n\nconst popupAnchors = new WeakMap<Element, Element>();\n\n/**\n * Popups portal outside the dialog that opened them. Registering one with its\n * anchor lets that dialog's Tab trap treat the popup as its own.\n */\nexport function registerPopup(popup: Element, anchor: Element) {\n popupAnchors.set(popup, anchor);\n return () => {\n popupAnchors.delete(popup);\n };\n}\n\nfunction popupAround(node: Node) {\n let element = node instanceof Element ? node : node.parentElement;\n while (element && !popupAnchors.has(element)) {\n element = element.parentElement;\n }\n return element;\n}\n\n/** Inside a popup anchored in the panel, directly or through other popups. */\nfunction inOwnedPopup(panel: HTMLElement, node: Node) {\n const visited = new Set<Element>();\n let popup = popupAround(node);\n while (popup && !visited.has(popup)) {\n visited.add(popup);\n const anchor = popupAnchors.get(popup)!;\n if (panel.contains(anchor)) {\n return true;\n }\n popup = popupAround(anchor);\n }\n return false;\n}\n\n/** `a` comes before `b` in document order, including as its ancestor. */\nfunction precedes(a: Node, b: Node) {\n return Boolean(b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING);\n}\n\n/**\n * Keeps Tab inside an aria-modal panel. Call only for the topmost dialog.\n * Focus that left the panel returns to its first control (last with Shift);\n * Tab inside a popup the panel owns is left to the popup and the browser.\n */\nexport function trapTabFocus(event: KeyboardEvent, panel: HTMLElement | null) {\n if (event.key !== \"Tab\" || event.defaultPrevented || !panel) {\n return;\n }\n const controls = tabbableControls(panel);\n const first = controls[0];\n const last = controls.at(-1);\n if (!first || !last) {\n return;\n }\n // document.activeElement stops at the host of a shadow root holding the panel.\n const active =\n (panel.getRootNode() as Document | ShadowRoot).activeElement ?? document.activeElement;\n const inside = active !== null && panel.contains(active);\n if (!inside && active && inOwnedPopup(panel, active)) {\n return;\n }\n // Focus on the panel itself, or on another untabbable element beyond the\n // first or last control, would otherwise leave the panel.\n const wraps =\n !inside ||\n (event.shiftKey\n ? sameStop(active, first) || precedes(active, first)\n : sameStop(active, last) || precedes(last, active));\n if (wraps) {\n event.preventDefault();\n (event.shiftKey ? last : first).focus();\n }\n}\n"],"mappings":"AAMA,SAASA,EAAa,EAAsB,CAC1C,OACGC,EAAQ,kBAAkB,GAAK,CAACA,EAAQ,QAAQ,UAAU,IAAM,CAACA,EAAQ,QAAQ,SAAS,CAE/F,CAEA,SAASC,EAAQ,EAAsD,CACrE,OAAOD,aAAmB,kBAAoBA,EAAQ,OAAS,OACjE,CAGA,SAASE,EAAS,EAAY,EAAY,CACxC,OACEC,IAAMC,GAAMH,EAAQE,CAAC,GAAKF,EAAQG,CAAC,GAAKD,EAAE,OAAS,IAAMA,EAAE,OAASC,EAAE,MAAQD,EAAE,OAASC,EAAE,IAE/F,CAMA,SAAgBC,EAAiB,EAAwB,CACvD,IAAMC,EAAW,MAAM,KAAKC,EAAU,iBAA8B,+LAAiB,CAAC,CAAC,CAAC,OACtFR,CACF,EACA,OAAOO,EAAS,OACb,GACC,CAACL,EAAQO,CAAO,GAChBA,EAAQ,SACR,CAACF,EAAS,KAAM,GAAUL,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QD,CAAI,GAAKJ,EAASI,EAAMC,CAAM,MAEnDH,EAAM,eAAe,GACpBA,EAAM,SAAWE,EAAOD,EAAA,CAAO,MAAM,EAE1C,C"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
function e(e) {
|
|
2
|
-
return (e.checkVisibility?.() ?? !e.closest("[hidden]")) && !e.closest("[inert]");
|
|
3
|
-
}
|
|
4
|
-
function t(e) {
|
|
5
|
-
return e instanceof HTMLInputElement && e.type === "radio";
|
|
6
|
-
}
|
|
7
|
-
function n(e, n) {
|
|
8
|
-
return e === n || t(e) && t(n) && e.name !== "" && e.name === n.name && e.form === n.form;
|
|
9
|
-
}
|
|
10
|
-
function r(r) {
|
|
11
|
-
let i = Array.from(r.querySelectorAll(":is(button, [href], input:not([type='hidden']), select, textarea, [tabindex], [contenteditable]:not([contenteditable='false'])):not(:disabled):not([tabindex='-1']):not([aria-hidden='true'])")).filter(e);
|
|
12
|
-
return i.filter((e) => !t(e) || e.checked || !i.some((r) => t(r) && r.checked && n(r, e)));
|
|
13
|
-
}
|
|
14
|
-
var i = /* @__PURE__ */ new WeakMap();
|
|
15
|
-
function a(e, t) {
|
|
16
|
-
return i.set(e, t), () => {
|
|
17
|
-
i.delete(e);
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function o(e) {
|
|
21
|
-
let t = e instanceof Element ? e : e.parentElement;
|
|
22
|
-
for (; t && !i.has(t);) t = t.parentElement;
|
|
23
|
-
return t;
|
|
24
|
-
}
|
|
25
|
-
function s(e, t) {
|
|
26
|
-
let n = /* @__PURE__ */ new Set(), r = o(t);
|
|
27
|
-
for (; r && !n.has(r);) {
|
|
28
|
-
n.add(r);
|
|
29
|
-
let t = i.get(r);
|
|
30
|
-
if (e.contains(t)) return !0;
|
|
31
|
-
r = o(t);
|
|
32
|
-
}
|
|
33
|
-
return !1;
|
|
34
|
-
}
|
|
35
|
-
function c(e, t) {
|
|
36
|
-
return !!(t.compareDocumentPosition(e) & Node.DOCUMENT_POSITION_PRECEDING);
|
|
37
|
-
}
|
|
38
|
-
function l(e, t) {
|
|
39
|
-
if (e.key !== "Tab" || e.defaultPrevented || !t) return;
|
|
40
|
-
let i = r(t), a = i[0], o = i.at(-1);
|
|
41
|
-
if (!a || !o) return;
|
|
42
|
-
let l = t.getRootNode().activeElement ?? document.activeElement, u = l !== null && t.contains(l);
|
|
43
|
-
!u && l && s(t, l) || (!u || (e.shiftKey ? n(l, a) || c(l, a) : n(l, o) || c(o, l))) && (e.preventDefault(), (e.shiftKey ? o : a).focus());
|
|
44
|
-
}
|
|
45
|
-
//#endregion
|
|
46
|
-
export { r as n, l as r, a as t };
|
|
47
|
-
|
|
48
|
-
//# sourceMappingURL=dialogFocus-BFoyeTpA.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dialogFocus-BFoyeTpA.js","names":["canTakeFocus","element","isRadio","sameStop","a","b","tabbableControls","controls","container","control","other","popupAnchors","registerPopup","popup","anchor","popupAround","node","inOwnedPopup","visited","panel","precedes","trapTabFocus","event","first","last","active","inside"],"sources":["../../src/internal/dialogFocus.ts"],"sourcesContent":["const focusableSelector =\n \":is(button, [href], input:not([type='hidden']), select, textarea, [tabindex], [contenteditable]:not([contenteditable='false'])):not(:disabled):not([tabindex='-1']):not([aria-hidden='true'])\";\n\n// Unrendered controls (display: none, [hidden], closed <details>) and inert\n// subtrees cannot take focus. Environments without checkVisibility fall back\n// to the hidden attribute.\nfunction canTakeFocus(element: HTMLElement) {\n return (\n (element.checkVisibility?.() ?? !element.closest(\"[hidden]\")) && !element.closest(\"[inert]\")\n );\n}\n\nfunction isRadio(element: Element | null): element is HTMLInputElement {\n return element instanceof HTMLInputElement && element.type === \"radio\";\n}\n\n/** Radios sharing a name and form are one Tab stop. */\nfunction sameStop(a: Element, b: Element) {\n return (\n a === b || (isRadio(a) && isRadio(b) && a.name !== \"\" && a.name === b.name && a.form === b.form)\n );\n}\n\n/**\n * The controls Tab visits inside `container`, in document order. A radio group\n * contributes only its checked radio, or every radio while none is checked.\n */\nexport function tabbableControls(container: HTMLElement) {\n const controls = Array.from(container.querySelectorAll<HTMLElement>(focusableSelector)).filter(\n canTakeFocus,\n );\n return controls.filter(\n (control) =>\n !isRadio(control) ||\n control.checked ||\n !controls.some((other) => isRadio(other) && other.checked && sameStop(other, control)),\n );\n}\n\nconst popupAnchors = new WeakMap<Element, Element>();\n\n/**\n * Popups portal outside the dialog that opened them. Registering one with its\n * anchor lets that dialog's Tab trap treat the popup as its own.\n */\nexport function registerPopup(popup: Element, anchor: Element) {\n popupAnchors.set(popup, anchor);\n return () => {\n popupAnchors.delete(popup);\n };\n}\n\nfunction popupAround(node: Node) {\n let element = node instanceof Element ? node : node.parentElement;\n while (element && !popupAnchors.has(element)) {\n element = element.parentElement;\n }\n return element;\n}\n\n/** Inside a popup anchored in the panel, directly or through other popups. */\nfunction inOwnedPopup(panel: HTMLElement, node: Node) {\n const visited = new Set<Element>();\n let popup = popupAround(node);\n while (popup && !visited.has(popup)) {\n visited.add(popup);\n const anchor = popupAnchors.get(popup)!;\n if (panel.contains(anchor)) {\n return true;\n }\n popup = popupAround(anchor);\n }\n return false;\n}\n\n/** `a` comes before `b` in document order, including as its ancestor. */\nfunction precedes(a: Node, b: Node) {\n return Boolean(b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING);\n}\n\n/**\n * Keeps Tab inside an aria-modal panel. Call only for the topmost dialog.\n * Focus that left the panel returns to its first control (last with Shift);\n * Tab inside a popup the panel owns is left to the popup and the browser.\n */\nexport function trapTabFocus(event: KeyboardEvent, panel: HTMLElement | null) {\n if (event.key !== \"Tab\" || event.defaultPrevented || !panel) {\n return;\n }\n const controls = tabbableControls(panel);\n const first = controls[0];\n const last = controls.at(-1);\n if (!first || !last) {\n return;\n }\n // document.activeElement stops at the host of a shadow root holding the panel.\n const active =\n (panel.getRootNode() as Document | ShadowRoot).activeElement ?? document.activeElement;\n const inside = active !== null && panel.contains(active);\n if (!inside && active && inOwnedPopup(panel, active)) {\n return;\n }\n // Focus on the panel itself, or on another untabbable element beyond the\n // first or last control, would otherwise leave the panel.\n const wraps =\n !inside ||\n (event.shiftKey\n ? sameStop(active, first) || precedes(active, first)\n : sameStop(active, last) || precedes(last, active));\n if (wraps) {\n event.preventDefault();\n (event.shiftKey ? last : first).focus();\n }\n}\n"],"mappings":"AAMA,SAASA,EAAa,GAAsB;CAC1C,QACGC,EAAQ,kBAAkB,KAAK,CAACA,EAAQ,QAAQ,UAAU,MAAM,CAACA,EAAQ,QAAQ,SAAS;AAE/F;AAEA,SAASC,EAAQ,GAAsD;CACrE,OAAOD,aAAmB,oBAAoBA,EAAQ,SAAS;AACjE;AAGA,SAASE,EAAS,GAAY,GAAY;CACxC,OACEC,MAAMC,KAAMH,EAAQE,CAAC,KAAKF,EAAQG,CAAC,KAAKD,EAAE,SAAS,MAAMA,EAAE,SAASC,EAAE,QAAQD,EAAE,SAASC,EAAE;AAE/F;AAMA,SAAgBC,EAAiB,GAAwB;CACvD,IAAMC,IAAW,MAAM,KAAKC,EAAU,iBAA8B,+LAAiB,CAAC,CAAC,CAAC,OACtFR,CACF;CACA,OAAOO,EAAS,QACb,MACC,CAACL,EAAQO,CAAO,KAChBA,EAAQ,WACR,CAACF,EAAS,MAAM,MAAUL,EAAQQ,CAAK,KAAKA,EAAM,WAAWP,EAASO,GAAOD,CAAO,CAAC,CACzF;AACF;AAEA,IAAME,oBAAe,IAAI,QAA0B;AAMnD,SAAgBC,EAAc,GAAgB,GAAiB;CAE7D,OADAD,EAAa,IAAIE,GAAOC,CAAM,SACjB;EACX,EAAa,OAAOD,CAAK;CAC3B;AACF;AAEA,SAASE,EAAY,GAAY;CAC/B,IAAId,IAAUe,aAAgB,UAAUA,IAAOA,EAAK;CACpD,OAAOf,KAAW,CAACU,EAAa,IAAIV,CAAO,IACzC,IAAUA,EAAQ;CAEpB,OAAOA;AACT;AAGA,SAASgB,EAAa,GAAoB,GAAY;CACpD,IAAMC,oBAAU,IAAI,IAAa,GAC7BL,IAAQE,EAAYC,CAAI;CAC5B,OAAOH,KAAS,CAACK,EAAQ,IAAIL,CAAK,IAAG;EACnC,EAAQ,IAAIA,CAAK;EACjB,IAAMC,IAASH,EAAa,IAAIE,CAAK;EACrC,IAAIM,EAAM,SAASL,CAAM,GACvB,OAAO;EAET,IAAQC,EAAYD,CAAM;CAC5B;CACA,OAAO;AACT;AAGA,SAASM,EAAS,GAAS,GAAS;CAClC,OAAO,GAAQf,EAAE,wBAAwBD,CAAC,IAAI,KAAK;AACrD;AAOA,SAAgBiB,EAAa,GAAsB,GAA2B;CAC5E,IAAIC,EAAM,QAAQ,SAASA,EAAM,oBAAoB,CAACH,GACpD;CAEF,IAAMZ,IAAWD,EAAiBa,CAAK,GACjCI,IAAQhB,EAAS,IACjBiB,IAAOjB,EAAS,GAAG,EAAE;CAC3B,IAAI,CAACgB,KAAS,CAACC,GACb;CAGF,IAAMC,IACHN,EAAM,YAAY,CAAC,CAA2B,iBAAiB,SAAS,eACrEO,IAASD,MAAW,QAAQN,EAAM,SAASM,CAAM;CACvD,AAAI,CAACC,KAAUD,KAAUR,EAAaE,GAAOM,CAAM,MAMjD,CAACC,MACAJ,EAAM,WACHnB,EAASsB,GAAQF,CAAK,KAAKH,EAASK,GAAQF,CAAK,IACjDpB,EAASsB,GAAQD,CAAI,KAAKJ,EAASI,GAAMC,CAAM,QAEnDH,EAAM,eAAe,IACpBA,EAAM,WAAWE,IAAOD,EAAA,CAAO,MAAM;AAE1C"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
//#region src/internal/lockBodyScroll.ts
|
|
2
|
-
var e = 0, t = {
|
|
3
|
-
overflow: "",
|
|
4
|
-
paddingRight: ""
|
|
5
|
-
};
|
|
6
|
-
function n() {
|
|
7
|
-
let { body: n, documentElement: r } = document;
|
|
8
|
-
if (e === 0) {
|
|
9
|
-
t = {
|
|
10
|
-
overflow: n.style.overflow,
|
|
11
|
-
paddingRight: n.style.paddingRight
|
|
12
|
-
};
|
|
13
|
-
let e = r.clientWidth;
|
|
14
|
-
n.style.overflow = "hidden";
|
|
15
|
-
let i = r.clientWidth - e;
|
|
16
|
-
if (i > 0) {
|
|
17
|
-
let e = parseFloat(getComputedStyle(n).paddingRight) || 0;
|
|
18
|
-
n.style.paddingRight = `${e + i}px`;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
e += 1;
|
|
22
|
-
let i = !1;
|
|
23
|
-
return () => {
|
|
24
|
-
i || (i = !0, --e, !(e > 0) && (n.style.overflow = t.overflow, n.style.paddingRight = t.paddingRight));
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/internal/dialogStack.ts
|
|
29
|
-
var r = [];
|
|
30
|
-
function i() {
|
|
31
|
-
let e = {};
|
|
32
|
-
return r.push(e), {
|
|
33
|
-
isTopmost: () => r.at(-1) === e,
|
|
34
|
-
close: () => {
|
|
35
|
-
let t = r.indexOf(e);
|
|
36
|
-
t !== -1 && r.splice(t, 1);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
//#endregion
|
|
41
|
-
export { n, i as t };
|
|
42
|
-
|
|
43
|
-
//# sourceMappingURL=dialogStack-6yv3NXFD.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dialogStack-6yv3NXFD.js","names":["locks","previous","lockBodyScroll","body","width","documentElement","scrollbar","padding","released","stack","openDialog","entry","index"],"sources":["../../src/internal/lockBodyScroll.ts","../../src/internal/dialogStack.ts"],"sourcesContent":["let locks = 0;\nlet previous = { overflow: \"\", paddingRight: \"\" };\n\n/**\n * Nested dialogs may unmount in either order; restore scrolling after the last.\n * Hiding a classic scrollbar widens the page, so the body is padded by the\n * width it gave back and layouts that measure themselves keep their mode.\n */\nexport function lockBodyScroll() {\n const { body, documentElement } = document;\n if (locks === 0) {\n previous = { overflow: body.style.overflow, paddingRight: body.style.paddingRight };\n const width = documentElement.clientWidth;\n body.style.overflow = \"hidden\";\n const scrollbar = documentElement.clientWidth - width;\n if (scrollbar > 0) {\n const padding = parseFloat(getComputedStyle(body).paddingRight) || 0;\n body.style.paddingRight = `${padding + scrollbar}px`;\n }\n }\n locks += 1;\n let released = false;\n return () => {\n if (released) {\n return;\n }\n released = true;\n locks -= 1;\n if (locks > 0) {\n return;\n }\n body.style.overflow = previous.overflow;\n body.style.paddingRight = previous.paddingRight;\n };\n}\n","const stack: object[] = [];\n\n/**\n * Register an open modal dialog. When dialogs nest (a picker over a drawer, a\n * drawer over a modal), only the most recently opened one handles keys.\n */\nexport function openDialog() {\n const entry = {};\n stack.push(entry);\n return {\n isTopmost: () => stack.at(-1) === entry,\n close: () => {\n const index = stack.indexOf(entry);\n if (index !== -1) {\n stack.splice(index, 1);\n }\n },\n };\n}\n"],"mappings":";AAAA,IAAIA,IAAQ,GACRC,IAAW;CAAE,UAAU;CAAI,cAAc;AAAG;AAOhD,SAAgBC,IAAiB;CAC/B,IAAM,EAAE,SAAM,uBAAoB;CAClC,IAAIF,MAAU,GAAG;EACf,IAAW;GAAE,UAAUG,EAAK,MAAM;GAAU,cAAcA,EAAK,MAAM;EAAa;EAClF,IAAMC,IAAQC,EAAgB;EAC9B,EAAK,MAAM,WAAW;EACtB,IAAMC,IAAYD,EAAgB,cAAcD;EAChD,IAAIE,IAAY,GAAG;GACjB,IAAMC,IAAU,WAAW,iBAAiBJ,CAAI,CAAC,CAAC,YAAY,KAAK;GACnE,EAAK,MAAM,eAAe,GAAGI,IAAUD,EAAU;EACnD;CACF;CACA,KAAS;CACT,IAAIE,IAAW;CACf,aAAa;EACX,AAAIA,MAGJ,IAAW,IACX,KACI,MAAQ,OAGZ,EAAK,MAAM,WAAWP,EAAS,UAC/B,EAAK,MAAM,eAAeA,EAAS;CACrC;AACF;;;AClCA,IAAMQ,IAAkB,CAAC;AAMzB,SAAgBC,IAAa;CAC3B,IAAMC,IAAQ,CAAC;CAEf,OADAF,EAAM,KAAKE,CAAK,GACT;EACL,iBAAiBF,EAAM,GAAG,EAAE,MAAME;EAClC,aAAa;GACX,IAAMC,IAAQH,EAAM,QAAQE,CAAK;GACjC,AAAIC,MAAU,MACZH,EAAM,OAAOG,GAAO,CAAC;EAEzB;CACF;AACF"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var e=0,t={overflow:``,paddingRight:``};function n(){let{body:n,documentElement:r}=document;if(e===0){t={overflow:n.style.overflow,paddingRight:n.style.paddingRight};let e=r.clientWidth;n.style.overflow=`hidden`;let i=r.clientWidth-e;if(i>0){let e=parseFloat(getComputedStyle(n).paddingRight)||0;n.style.paddingRight=`${e+i}px`}}e+=1;let i=!1;return()=>{i||(i=!0,--e,!(e>0)&&(n.style.overflow=t.overflow,n.style.paddingRight=t.paddingRight))}}var r=[];function i(){let e={};return r.push(e),{isTopmost:()=>r.at(-1)===e,close:()=>{let t=r.indexOf(e);t!==-1&&r.splice(t,1)}}}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
|
|
2
|
-
//# sourceMappingURL=dialogStack-C9SLVu6Q.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dialogStack-C9SLVu6Q.cjs","names":["locks","previous","lockBodyScroll","body","width","documentElement","scrollbar","padding","released","stack","openDialog","entry","index"],"sources":["../../src/internal/lockBodyScroll.ts","../../src/internal/dialogStack.ts"],"sourcesContent":["let locks = 0;\nlet previous = { overflow: \"\", paddingRight: \"\" };\n\n/**\n * Nested dialogs may unmount in either order; restore scrolling after the last.\n * Hiding a classic scrollbar widens the page, so the body is padded by the\n * width it gave back and layouts that measure themselves keep their mode.\n */\nexport function lockBodyScroll() {\n const { body, documentElement } = document;\n if (locks === 0) {\n previous = { overflow: body.style.overflow, paddingRight: body.style.paddingRight };\n const width = documentElement.clientWidth;\n body.style.overflow = \"hidden\";\n const scrollbar = documentElement.clientWidth - width;\n if (scrollbar > 0) {\n const padding = parseFloat(getComputedStyle(body).paddingRight) || 0;\n body.style.paddingRight = `${padding + scrollbar}px`;\n }\n }\n locks += 1;\n let released = false;\n return () => {\n if (released) {\n return;\n }\n released = true;\n locks -= 1;\n if (locks > 0) {\n return;\n }\n body.style.overflow = previous.overflow;\n body.style.paddingRight = previous.paddingRight;\n };\n}\n","const stack: object[] = [];\n\n/**\n * Register an open modal dialog. When dialogs nest (a picker over a drawer, a\n * drawer over a modal), only the most recently opened one handles keys.\n */\nexport function openDialog() {\n const entry = {};\n stack.push(entry);\n return {\n isTopmost: () => stack.at(-1) === entry,\n close: () => {\n const index = stack.indexOf(entry);\n if (index !== -1) {\n stack.splice(index, 1);\n }\n },\n };\n}\n"],"mappings":"AAAA,IAAIA,EAAQ,EACRC,EAAW,CAAE,SAAU,GAAI,aAAc,EAAG,EAOhD,SAAgBC,GAAiB,CAC/B,GAAM,CAAE,OAAM,mBAAoB,SAClC,GAAIF,IAAU,EAAG,CACf,EAAW,CAAE,SAAUG,EAAK,MAAM,SAAU,aAAcA,EAAK,MAAM,YAAa,EAClF,IAAMC,EAAQC,EAAgB,YAC9B,EAAK,MAAM,SAAW,SACtB,IAAMC,EAAYD,EAAgB,YAAcD,EAChD,GAAIE,EAAY,EAAG,CACjB,IAAMC,EAAU,WAAW,iBAAiBJ,CAAI,CAAC,CAAC,YAAY,GAAK,EACnE,EAAK,MAAM,aAAe,GAAGI,EAAUD,EAAU,GACnD,CACF,CACA,GAAS,EACT,IAAIE,EAAW,GACf,UAAa,CACPA,IAGJ,EAAW,GACX,IACI,IAAQ,KAGZ,EAAK,MAAM,SAAWP,EAAS,SAC/B,EAAK,MAAM,aAAeA,EAAS,cACrC,CACF,CClCA,IAAMQ,EAAkB,CAAC,EAMzB,SAAgBC,GAAa,CAC3B,IAAMC,EAAQ,CAAC,EAEf,OADAF,EAAM,KAAKE,CAAK,EACT,CACL,cAAiBF,EAAM,GAAG,EAAE,IAAME,EAClC,UAAa,CACX,IAAMC,EAAQH,EAAM,QAAQE,CAAK,EAC7BC,IAAU,IACZH,EAAM,OAAOG,EAAO,CAAC,CAEzB,CACF,CACF,C"}
|