@namroodinc/liquid-editorial 0.1.6 → 0.1.8
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/AGENTS.md +4 -0
- package/README.md +42 -0
- package/UPGRADING.md +93 -11
- package/dist/chunks/Board-BLhB5_xx.cjs +2 -0
- package/dist/chunks/Board-BLhB5_xx.cjs.map +1 -0
- package/dist/chunks/Board-BTFSzn6c.js +239 -0
- package/dist/chunks/Board-BTFSzn6c.js.map +1 -0
- package/dist/chunks/EntryEditor-CcyYtH74.js +191 -0
- package/dist/chunks/EntryEditor-CcyYtH74.js.map +1 -0
- package/dist/chunks/EntryEditor-DIpc1iPF.cjs +2 -0
- package/dist/chunks/EntryEditor-DIpc1iPF.cjs.map +1 -0
- package/dist/chunks/{RichTextEditor-DC_0oN1s.cjs → RichTextEditor-BxtlbjXj.cjs} +2 -2
- package/dist/chunks/RichTextEditor-BxtlbjXj.cjs.map +1 -0
- package/dist/chunks/{RichTextEditor-CSpjsL1z.js → RichTextEditor-Dnx4i7bQ.js} +104 -93
- package/dist/chunks/RichTextEditor-Dnx4i7bQ.js.map +1 -0
- package/dist/chunks/mergeRefs-Bc3qS0Tt.cjs +2 -0
- package/dist/chunks/mergeRefs-Bc3qS0Tt.cjs.map +1 -0
- package/dist/chunks/mergeRefs-DGM402mE.js +10 -0
- package/dist/chunks/mergeRefs-DGM402mE.js.map +1 -0
- package/dist/components/AppShell/index.cjs +2 -0
- package/dist/components/AppShell/index.cjs.map +1 -0
- package/dist/components/AppShell/index.d.cts +15 -0
- package/dist/components/AppShell/index.d.cts.map +1 -0
- package/dist/components/AppShell/index.d.ts +15 -0
- package/dist/components/AppShell/index.d.ts.map +1 -0
- package/dist/components/AppShell/index.js +93 -0
- package/dist/components/AppShell/index.js.map +1 -0
- package/dist/components/AppShell/style.css +79 -0
- package/dist/components/AssetGrid/index.cjs +1 -1
- package/dist/components/AssetGrid/index.cjs.map +1 -1
- package/dist/components/AssetGrid/index.d.cts.map +1 -1
- package/dist/components/AssetGrid/index.d.ts.map +1 -1
- package/dist/components/AssetGrid/index.js +57 -59
- package/dist/components/AssetGrid/index.js.map +1 -1
- package/dist/components/AssetGrid/style.css +8 -16
- package/dist/components/Board/index.cjs +1 -2
- package/dist/components/Board/index.d.cts.map +1 -1
- package/dist/components/Board/index.d.ts.map +1 -1
- package/dist/components/Board/index.js +1 -227
- package/dist/components/Board/keyboard.d.cts +7 -0
- package/dist/components/Board/keyboard.d.cts.map +1 -0
- package/dist/components/Board/keyboard.d.ts +7 -0
- package/dist/components/Board/keyboard.d.ts.map +1 -0
- package/dist/components/Board/keyboard.test.d.cts +2 -0
- package/dist/components/Board/keyboard.test.d.cts.map +1 -0
- package/dist/components/Board/keyboard.test.d.ts +2 -0
- package/dist/components/Board/keyboard.test.d.ts.map +1 -0
- package/dist/components/Board/moves.d.cts +5 -0
- package/dist/components/Board/moves.d.cts.map +1 -0
- package/dist/components/Board/moves.d.ts +5 -0
- package/dist/components/Board/moves.d.ts.map +1 -0
- package/dist/components/Board/moves.test.d.cts +2 -0
- package/dist/components/Board/moves.test.d.cts.map +1 -0
- package/dist/components/Board/moves.test.d.ts +2 -0
- package/dist/components/Board/moves.test.d.ts.map +1 -0
- package/dist/components/Board/style.css +17 -28
- package/dist/components/Button/index.cjs +1 -1
- package/dist/components/Button/index.cjs.map +1 -1
- package/dist/components/Button/index.d.cts +3 -2
- package/dist/components/Button/index.d.cts.map +1 -1
- package/dist/components/Button/index.d.ts +3 -2
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Button/style.css +21 -15
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.cjs.map +1 -1
- package/dist/components/DatePicker/index.d.cts.map +1 -1
- package/dist/components/DatePicker/index.d.ts.map +1 -1
- package/dist/components/DatePicker/index.js +76 -72
- package/dist/components/DatePicker/index.js.map +1 -1
- package/dist/components/DatePicker/style.css +4 -61
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.cjs.map +1 -1
- package/dist/components/Drawer/index.d.cts +10 -1
- package/dist/components/Drawer/index.d.cts.map +1 -1
- package/dist/components/Drawer/index.d.ts +10 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +78 -49
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Drawer/style.css +106 -0
- package/dist/components/EntryEditor/index.cjs +1 -1
- package/dist/components/EntryEditor/index.d.cts.map +1 -1
- package/dist/components/EntryEditor/index.d.ts.map +1 -1
- package/dist/components/EntryEditor/index.js +1 -1
- package/dist/components/EntryEditor/model.d.cts.map +1 -1
- package/dist/components/EntryEditor/model.d.ts.map +1 -1
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.cjs.map +1 -1
- package/dist/components/EntryPicker/index.d.cts.map +1 -1
- package/dist/components/EntryPicker/index.d.ts.map +1 -1
- package/dist/components/EntryPicker/index.js +12 -11
- package/dist/components/EntryPicker/index.js.map +1 -1
- package/dist/components/EntryPicker/style.css +3 -30
- package/dist/components/Field/style.css +11 -3
- package/dist/components/Menu/index.cjs +1 -1
- package/dist/components/Menu/index.cjs.map +1 -1
- package/dist/components/Menu/index.d.cts.map +1 -1
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js +11 -16
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Menu/style.css +7 -41
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.cjs.map +1 -1
- package/dist/components/Modal/index.d.cts.map +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.js +12 -12
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/NumberField/index.cjs +1 -1
- package/dist/components/NumberField/index.cjs.map +1 -1
- package/dist/components/NumberField/index.js +13 -17
- package/dist/components/NumberField/index.js.map +1 -1
- package/dist/components/NumberField/style.css +1 -41
- package/dist/components/Pagination/index.cjs +1 -1
- package/dist/components/Pagination/index.cjs.map +1 -1
- package/dist/components/Pagination/index.js +1 -1
- package/dist/components/Pagination/index.js.map +1 -1
- package/dist/components/Pagination/style.css +0 -1
- package/dist/components/Popover/index.cjs +1 -1
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.js +4 -4
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.d.cts.map +1 -1
- package/dist/components/RichTextEditor/index.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.js +1 -1
- package/dist/components/SearchField/index.cjs +1 -1
- package/dist/components/SearchField/index.cjs.map +1 -1
- package/dist/components/SearchField/index.d.cts.map +1 -1
- package/dist/components/SearchField/index.d.ts.map +1 -1
- package/dist/components/SearchField/index.js +26 -27
- package/dist/components/SearchField/index.js.map +1 -1
- package/dist/components/SearchField/style.css +0 -21
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.cjs.map +1 -1
- package/dist/components/Select/index.d.cts.map +1 -1
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +101 -80
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Select/style.css +5 -38
- package/dist/components/SideNav/index.cjs +1 -1
- package/dist/components/SideNav/index.cjs.map +1 -1
- package/dist/components/SideNav/index.d.cts.map +1 -1
- package/dist/components/SideNav/index.d.ts.map +1 -1
- package/dist/components/SideNav/index.js +52 -49
- package/dist/components/SideNav/index.js.map +1 -1
- package/dist/components/SideNav/style.css +2 -27
- package/dist/components/SortableList/index.cjs +1 -1
- package/dist/components/SortableList/index.cjs.map +1 -1
- package/dist/components/SortableList/index.d.cts.map +1 -1
- package/dist/components/SortableList/index.d.ts.map +1 -1
- package/dist/components/SortableList/index.js +55 -53
- package/dist/components/SortableList/index.js.map +1 -1
- package/dist/components/SortableList/style.css +9 -15
- package/dist/components/Stepper/index.cjs +1 -1
- package/dist/components/Stepper/index.cjs.map +1 -1
- package/dist/components/Stepper/index.d.cts.map +1 -1
- package/dist/components/Stepper/index.d.ts.map +1 -1
- package/dist/components/Stepper/index.js +48 -39
- package/dist/components/Stepper/index.js.map +1 -1
- package/dist/components/Stepper/style.css +24 -18
- package/dist/components/SubNav/index.cjs +1 -1
- package/dist/components/SubNav/index.cjs.map +1 -1
- package/dist/components/SubNav/index.d.cts.map +1 -1
- package/dist/components/SubNav/index.d.ts.map +1 -1
- package/dist/components/SubNav/index.js +27 -28
- package/dist/components/SubNav/index.js.map +1 -1
- package/dist/components/SubNav/style.css +13 -0
- package/dist/components/Switch/index.cjs +1 -1
- package/dist/components/Switch/index.cjs.map +1 -1
- package/dist/components/Switch/index.d.cts.map +1 -1
- package/dist/components/Switch/index.d.ts.map +1 -1
- package/dist/components/Switch/index.js +23 -21
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Switch/style.css +2 -28
- package/dist/components/TagsInput/index.cjs +1 -1
- package/dist/components/TagsInput/index.cjs.map +1 -1
- package/dist/components/TagsInput/index.js +8 -10
- package/dist/components/TagsInput/index.js.map +1 -1
- package/dist/components/TagsInput/style.css +2 -24
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -38
- package/dist/internal/mergeRefs.d.cts +4 -0
- package/dist/internal/mergeRefs.d.cts.map +1 -0
- package/dist/internal/mergeRefs.d.ts +4 -0
- package/dist/internal/mergeRefs.d.ts.map +1 -0
- package/dist/styles.css +1 -0
- package/dist/test/dragEvent.d.cts +3 -0
- package/dist/test/dragEvent.d.cts.map +1 -0
- package/dist/test/dragEvent.d.ts +3 -0
- package/dist/test/dragEvent.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/chunks/EntryEditor-C32lKKnV.cjs +0 -2
- package/dist/chunks/EntryEditor-C32lKKnV.cjs.map +0 -1
- package/dist/chunks/EntryEditor-xVuiqtFo.js +0 -181
- package/dist/chunks/EntryEditor-xVuiqtFo.js.map +0 -1
- package/dist/chunks/RichTextEditor-CSpjsL1z.js.map +0 -1
- package/dist/chunks/RichTextEditor-DC_0oN1s.cjs.map +0 -1
- package/dist/components/Board/index.cjs.map +0 -1
- package/dist/components/Board/index.js.map +0 -1
|
@@ -219,139 +219,150 @@ var k = [
|
|
|
219
219
|
label: "Redo",
|
|
220
220
|
run: (e) => e.chain().focus().redo().run()
|
|
221
221
|
}]
|
|
222
|
-
]
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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, "aria-labelledby": j, "aria-describedby": M, "aria-invalid": N } = e, [P, F] = u(!1), [I, L] = u(null), R = o(() => L(null), []), [z] = u(() => e.defaultValue ?? (e.format === "json" ? C : "")), B = e.value === void 0 ? z : e.value, V = l(() => e.format === "json" ? D(B) : void 0, [e.format, B]), H = c(), U = a || !!V || N, W = i || !!V;
|
|
262
|
+
W && I && L(null);
|
|
263
|
+
let G = o((e, t) => {
|
|
264
|
+
if (W) return;
|
|
227
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);
|
|
228
|
-
|
|
266
|
+
L({
|
|
229
267
|
from: n?.from ?? e.selection.from,
|
|
230
268
|
to: n?.to ?? e.selection.to,
|
|
231
269
|
href: r?.attrs.href ?? "",
|
|
232
270
|
isEditing: !!r,
|
|
233
271
|
document: e.doc
|
|
234
272
|
});
|
|
235
|
-
}, [
|
|
273
|
+
}, [W]), K = l(() => ({
|
|
236
274
|
role: "textbox",
|
|
237
|
-
"aria-label":
|
|
275
|
+
"aria-label": d,
|
|
238
276
|
"aria-multiline": "true",
|
|
239
|
-
...
|
|
240
|
-
...
|
|
241
|
-
...
|
|
242
|
-
...
|
|
243
|
-
...
|
|
277
|
+
...S ? { id: S } : {},
|
|
278
|
+
...j ? { "aria-labelledby": j } : {},
|
|
279
|
+
...M ? { "aria-describedby": M } : {},
|
|
280
|
+
...U ? { "aria-invalid": String(U) } : {},
|
|
281
|
+
...T ? { "aria-required": "true" } : {}
|
|
244
282
|
}), [
|
|
245
|
-
|
|
246
|
-
|
|
283
|
+
d,
|
|
284
|
+
S,
|
|
285
|
+
j,
|
|
247
286
|
M,
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
attributes: q,
|
|
287
|
+
U,
|
|
288
|
+
T
|
|
289
|
+
]), q = l(() => ({
|
|
290
|
+
attributes: K,
|
|
253
291
|
handleDOMEvents: { click: (e, t) => {
|
|
254
292
|
let n = t.target instanceof Element ? t.target.closest("a") : null;
|
|
255
|
-
return !n || !e.dom.contains(n) ? !1 : (t.preventDefault(), e.editable &&
|
|
293
|
+
return !n || !e.dom.contains(n) ? !1 : (t.preventDefault(), e.editable && G(e.state, e.posAtDOM(n, 0)), !0);
|
|
256
294
|
} }
|
|
257
|
-
}), [
|
|
295
|
+
}), [K, G]), J = v({
|
|
258
296
|
immediatelyRender: !1,
|
|
259
|
-
editable: !
|
|
260
|
-
content:
|
|
261
|
-
extensions: [...w(), b.configure({ placeholder:
|
|
262
|
-
editorProps:
|
|
263
|
-
onFocus: () =>
|
|
264
|
-
onBlur: () =>
|
|
265
|
-
onUpdate: ({ editor:
|
|
266
|
-
|
|
297
|
+
editable: !W,
|
|
298
|
+
content: V ? C : typeof B == "string" ? B : E(B),
|
|
299
|
+
extensions: [...w(), b.configure({ placeholder: n })],
|
|
300
|
+
editorProps: q,
|
|
301
|
+
onFocus: () => F(!0),
|
|
302
|
+
onBlur: () => F(!1),
|
|
303
|
+
onUpdate: ({ editor: t }) => {
|
|
304
|
+
W || (e.format === "json" ? e.onChange?.(t.getJSON()) : e.onChange?.(t.getHTML()));
|
|
267
305
|
}
|
|
268
306
|
});
|
|
269
307
|
s(() => {
|
|
270
|
-
|
|
308
|
+
J && (J.setEditable(!W, !1), J.setOptions({ editorProps: q }));
|
|
271
309
|
}, [
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
310
|
+
J,
|
|
311
|
+
W,
|
|
312
|
+
q
|
|
275
313
|
]), s(() => {
|
|
276
|
-
if (!
|
|
277
|
-
let
|
|
278
|
-
|
|
314
|
+
if (!J || e.value === void 0 || V) return;
|
|
315
|
+
let t = typeof e.value == "string" ? h(e.value, J.schema) : J.schema.nodeFromJSON(E(e.value));
|
|
316
|
+
t.eq(J.state.doc) || J.commands.setContent(t, { emitUpdate: !1 });
|
|
279
317
|
}, [
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
318
|
+
J,
|
|
319
|
+
e.value,
|
|
320
|
+
V
|
|
283
321
|
]);
|
|
284
|
-
let
|
|
285
|
-
editor:
|
|
322
|
+
let Y = y({
|
|
323
|
+
editor: J,
|
|
286
324
|
selector: ({ editor: e }) => e ? {
|
|
287
325
|
active: Object.fromEntries(k.flat().map((t) => [t.id, t.active?.(e) ?? !1])),
|
|
288
326
|
linkActive: e.isActive("link")
|
|
289
327
|
} : null
|
|
290
328
|
});
|
|
291
329
|
return /* @__PURE__ */ p("div", {
|
|
292
|
-
ref:
|
|
293
|
-
className: ["ds-rte",
|
|
294
|
-
"data-focused":
|
|
295
|
-
"data-disabled":
|
|
296
|
-
"aria-invalid":
|
|
330
|
+
ref: t,
|
|
331
|
+
className: ["ds-rte", _].filter(Boolean).join(" "),
|
|
332
|
+
"data-focused": P || void 0,
|
|
333
|
+
"data-disabled": W || void 0,
|
|
334
|
+
"aria-invalid": U || void 0,
|
|
297
335
|
children: [
|
|
298
|
-
|
|
299
|
-
id:
|
|
336
|
+
V && /* @__PURE__ */ f("p", {
|
|
337
|
+
id: H,
|
|
300
338
|
role: "alert",
|
|
301
339
|
className: "ds-field__error",
|
|
302
|
-
children:
|
|
340
|
+
children: V
|
|
303
341
|
}),
|
|
304
342
|
/* @__PURE__ */ p("div", {
|
|
305
|
-
hidden: !!
|
|
306
|
-
children: [/* @__PURE__ */
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
children: n.map((t) => /* @__PURE__ */ f(e, {
|
|
314
|
-
size: "sm",
|
|
315
|
-
isIconOnly: !0,
|
|
316
|
-
iconStart: t.icon,
|
|
317
|
-
"aria-label": t.label,
|
|
318
|
-
title: t.label,
|
|
319
|
-
"aria-pressed": t.active ? X?.active[t.id] : void 0,
|
|
320
|
-
variant: X?.active[t.id] ? "active" : "neutral",
|
|
321
|
-
isDisabled: G || !Y,
|
|
322
|
-
onClick: () => Y && t.run(Y)
|
|
323
|
-
}, t.id))
|
|
324
|
-
}, r)),
|
|
325
|
-
/* @__PURE__ */ f(t, {
|
|
326
|
-
"aria-label": "Link",
|
|
327
|
-
children: /* @__PURE__ */ f(e, {
|
|
328
|
-
size: "sm",
|
|
329
|
-
isIconOnly: !0,
|
|
330
|
-
iconStart: "link",
|
|
331
|
-
"aria-label": X?.linkActive ? "Edit link" : "Add link",
|
|
332
|
-
title: X?.linkActive ? "Edit link" : "Add link",
|
|
333
|
-
variant: X?.linkActive ? "active" : "neutral",
|
|
334
|
-
isDisabled: G || !Y,
|
|
335
|
-
onClick: () => Y && K(Y.state, Y.isActive("link") ? Y.state.selection.from : void 0)
|
|
336
|
-
})
|
|
337
|
-
}),
|
|
338
|
-
T
|
|
339
|
-
]
|
|
343
|
+
hidden: !!V,
|
|
344
|
+
children: [/* @__PURE__ */ f(A, {
|
|
345
|
+
editor: J,
|
|
346
|
+
state: Y,
|
|
347
|
+
disabled: W,
|
|
348
|
+
label: d,
|
|
349
|
+
toolbarExtra: x,
|
|
350
|
+
openLink: G
|
|
340
351
|
}), /* @__PURE__ */ f("div", {
|
|
341
352
|
className: "ds-rte__content",
|
|
342
|
-
"data-size":
|
|
343
|
-
children: /* @__PURE__ */ f(m, { editor:
|
|
353
|
+
"data-size": r,
|
|
354
|
+
children: /* @__PURE__ */ f(m, { editor: J })
|
|
344
355
|
})]
|
|
345
356
|
}),
|
|
346
|
-
|
|
347
|
-
editor:
|
|
348
|
-
selection:
|
|
349
|
-
onClose:
|
|
357
|
+
J && I && !W && /* @__PURE__ */ f(O, {
|
|
358
|
+
editor: J,
|
|
359
|
+
selection: I,
|
|
360
|
+
onClose: R
|
|
350
361
|
})
|
|
351
362
|
]
|
|
352
363
|
});
|
|
353
364
|
});
|
|
354
365
|
//#endregion
|
|
355
|
-
export { D as n, C as r,
|
|
366
|
+
export { D as n, C as r, j as t };
|
|
356
367
|
|
|
357
|
-
//# sourceMappingURL=RichTextEditor-
|
|
368
|
+
//# sourceMappingURL=RichTextEditor-Dnx4i7bQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RichTextEditor-Dnx4i7bQ.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","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","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 [StarterKit.configure({ link: false }), Link.configure({ openOnClick: false, autolink: true })];\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\") throw new Error();\n const check = (node: JSONContent) => {\n const type = schema.nodes[node.type ?? \"\"];\n if (!type || Object.keys(node).some((key) => ![\"type\", \"attrs\", \"content\", \"marks\", \"text\"].includes(key)) ||\n (node.text !== undefined && node.type !== \"text\") ||\n (node.attrs && Object.keys(node.attrs).some((key) => !Object.hasOwn(type.spec.attrs ?? {}, key)))) {\n throw new Error();\n }\n for (const mark of node.marks ?? []) {\n const markType = schema.marks[mark.type];\n if (!markType || Object.keys(mark).some((key) => ![\"type\", \"attrs\"].includes(key)) ||\n Object.keys(mark.attrs ?? {}).some((key) => !Object.hasOwn(markType.spec.attrs ?? {}, key))) {\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 { forwardRef, useCallback, useEffect, useId, useMemo, useState, type AriaAttributes, type ReactNode } from \"react\";\nimport { createDocument, EditorContent, getMarkRange, useEditor, useEditorState, type Editor, type EditorOptions } 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 { documentError, emptyDocument, normalizeDocument, richTextExtensions, type RichTextDocument } from \"./document\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nexport type RichTextEditorSize = \"sm\" | \"md\" | \"lg\";\n\nexport type { RichTextDocument } from \"./document\";\n\ninterface RichTextEditorCommonProps {\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 /** Applied to the editable surface. */\n id?: string;\n isRequired?: boolean;\n \"aria-labelledby\"?: string;\n \"aria-describedby\"?: string;\n \"aria-invalid\"?: AriaAttributes[\"aria-invalid\"];\n}\n\nexport type RichTextEditorProps = RichTextEditorCommonProps & (\n | { format?: \"html\"; value?: string; defaultValue?: string; onChange?: (html: string) => void }\n | { format: \"json\"; value?: RichTextDocument; defaultValue?: RichTextDocument; onChange?: (document: RichTextDocument) => void }\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({ editor, selection, onClose }: {\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)) onClose();\n };\n editor.on(\"transaction\", onTransaction);\n return () => { editor.off(\"transaction\", onTransaction); };\n }, [editor, selection, onClose]);\n\n const canEdit = () => !editor.isDestroyed && editor.isEditable && editor.state.doc.eq(selection.document);\n const save = () => {\n if (!canEdit()) { onClose(); return; }\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.chain().focus().setTextSelection({ from: selection.from, to: selection.to });\n if (selection.from === selection.to && !selection.isEditing) {\n chain.setLink({ href: url }).insertContent({ type: \"text\", text: url, marks: [{ type: \"link\", attrs: { href: url } }] }).run();\n } else {\n chain.setLink({ href: url }).run();\n }\n onClose();\n };\n\n return (\n <Modal isOpen title={selection.isEditing ? \"Edit link\" : \"Add link\"} size=\"dialog\" onClose={onClose}\n footer={<>\n {selection.isEditing && <Button variant=\"danger\" onClick={() => {\n if (canEdit()) editor.chain().focus().setTextSelection({ from: selection.from, to: selection.to }).unsetLink().run();\n onClose();\n }}>Remove link</Button>}\n <Button onClick={onClose}>Cancel</Button>\n <Button variant=\"primary\" type=\"submit\" form={formId}>Save</Button>\n </>}>\n <form id={formId} noValidate onSubmit={(event) => { event.preventDefault(); event.stopPropagation(); save(); }}>\n <Field label=\"URL\" isRequired error={error}>\n {(field) => <TextField {...field} value={href} inputMode=\"url\" autoComplete=\"url\"\n placeholder=\"https://example.com\" onChange={(event) => { setHref(event.target.value); setError(undefined); }} />}\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({ editor, state, disabled, label, toolbarExtra, openLink }: {\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 className=\"ds-rte__toolbar\" role=\"toolbar\" aria-label={`${label} formatting`}>\n {GROUPS.map((group, i) => (\n <ButtonGroup key={i} aria-label={`Formatting ${i + 1}`}>\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={() => editor && openLink(editor.state, editor.isActive(\"link\") ? editor.state.selection.from : undefined)}\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(\n props,\n ref,\n ) {\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 \"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(() => props.defaultValue ?? (props.format === \"json\" ? emptyDocument : \"\"));\n const content = props.value !== undefined ? props.value : initialValue;\n const contentError = useMemo(() => props.format === \"json\" ? documentError(content) : undefined, [props.format, content]);\n const errorId = useId();\n const invalid = isInvalid || !!contentError || ariaInvalid;\n const disabled = isDisabled || !!contentError;\n if (disabled && linkSelection) setLinkSelection(null);\n const openLink = useCallback((state: Editor[\"state\"], position?: number) => {\n if (disabled) return;\n const range = position === undefined ? undefined : getMarkRange(state.doc.resolve(position), state.schema.marks.link);\n const link = range && 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 }, [disabled]);\n const attributes = useMemo(() => ({\n role: \"textbox\",\n \"aria-label\": 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 ? { \"aria-required\": \"true\" } : {}),\n }), [label, id, labelledBy, describedBy, invalid, isRequired]);\n const editorProps = useMemo<EditorOptions[\"editorProps\"]>(() => ({\n attributes,\n handleDOMEvents: { click: (view, event) => {\n const anchor = event.target instanceof Element ? event.target.closest(\"a\") : null;\n if (!anchor || !view.dom.contains(anchor)) return false;\n event.preventDefault();\n if (view.editable) openLink(view.state, view.posAtDOM(anchor, 0));\n return true;\n } },\n }), [attributes, openLink]);\n\n const editor = useEditor({\n immediatelyRender: false,\n editable: !disabled,\n content: contentError ? emptyDocument : typeof content === \"string\" ? content : normalizeDocument(content),\n extensions: [\n ...richTextExtensions(),\n Placeholder.configure({ placeholder }),\n ],\n editorProps,\n onFocus: () => setIsFocused(true),\n onBlur: () => setIsFocused(false),\n onUpdate: ({ editor: e }) => {\n if (disabled) return;\n if (props.format === \"json\") props.onChange?.(e.getJSON() as RichTextDocument);\n else props.onChange?.(e.getHTML());\n },\n });\n\n useEffect(() => {\n if (!editor) return;\n editor.setEditable(!disabled, false);\n editor.setOptions({ editorProps });\n }, [editor, disabled, editorProps]);\n\n useEffect(() => {\n if (!editor || props.value === undefined || contentError) return;\n const next = 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(\n GROUPS.flat().map((t) => [t.id, t.active?.(e) ?? false]),\n ),\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 && <p id={errorId} role=\"alert\" className=\"ds-field__error\">{contentError}</p>}\n <div hidden={!!contentError}>\n <EditorToolbar editor={editor} state={state} disabled={disabled} label={label}\n toolbarExtra={toolbarExtra} openLink={openLink} />\n <div className=\"ds-rte__content\" data-size={size}>\n <EditorContent editor={editor} />\n </div>\n </div>\n {editor && linkSelection && !disabled && <LinkDialog editor={editor} selection={linkSelection} onClose={closeLink} />}\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,CAACC,EAAW,UAAU,EAAE,MAAM,GAAM,CAAC,GAAGC,EAAK,UAAU;EAAE,aAAa;EAAO,UAAU;CAAK,CAAC,CAAC;AACvG;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,OAAO,MAAU,MAAM;EACvG,IAAMC,KAAS,MAAsB;GACnC,IAAMC,IAAOP,EAAO,MAAMQ,EAAK,QAAQ;GACvC,IAAI,CAACD,KAAQ,OAAO,KAAKC,CAAI,CAAC,CAAC,MAAM,MAAQ,CAAC;IAAC;IAAQ;IAAS;IAAW;IAAS;GAAM,CAAC,CAAC,SAASC,CAAG,CAAC,KACtGD,EAAK,SAAS,KAAA,KAAaA,EAAK,SAAS,UACzCA,EAAK,SAAS,OAAO,KAAKA,EAAK,KAAK,CAAC,CAAC,MAAM,MAAQ,CAAC,OAAO,OAAOD,EAAK,KAAK,SAAS,CAAC,GAAGE,CAAG,CAAC,GAC/F,M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AC,EAAE,IAAI,EAAE,SAAS,CAAC,KAAK,EAAK,CAAC,CACzD;GACA,YAAY,EAAE,SAAS,MAAM;EAC/B,IACA;CACR,CAAC;CAED,OACE,kBAAC,OAAD;EACO;EACL,WAAW,CAAC,UAAUgD,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EACzD,gBAAc/B,KAAa,KAAA;EAC3B,iBAAeT,KAAY,KAAA;EAC3B,gBAAcoB,KAAW,KAAA;EAL3B,UAAA;GAOGH,KAAgB,kBAAC,KAAD;IAAG,IAAIE;IAAS,MAAK;IAAQ,WAAU;IAAmB,UAAAF;GAAgB,CAAA;GAC3F,kBAAC,OAAD;IAAK,QAAQ,CAAC,CAACA;IAAf,UAAA,CACE,kBAACxB,GAAD;KAAuB;KAAe;KAAiB;KAAiB;KACxD;KAAwB;IAAW,CAAA,GACnD,kBAAC,OAAD;KAAK,WAAU;KAAkB,aAAWgD;KAC1C,UAAA,kBAACC,GAAD,EAAuB,UAAS,CAAA;IAC7B,CAAA,CACF;;GACJ9D,KAAU+B,KAAiB,CAACX,KAAY,kBAAC9B,GAAD;IAAoB;IAAQ,WAAWyC;IAAe,SAASE;GAAY,CAAA;EACjH;;AAET,CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeRefs-Bc3qS0Tt.cjs","names":["mergeRefs","refs","ref","node"],"sources":["../../src/internal/mergeRefs.ts"],"sourcesContent":["import type { Ref, RefCallback } from \"react\";\n\n/** Send the same node (and unmount notification) to internal and forwarded refs. */\nexport function mergeRefs<T>(...refs: (Ref<T> | undefined)[]): RefCallback<T> {\n return (node) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }\n };\n}\n"],"mappings":"AAGA,SAAgBA,EAAa,GAAGC,EAA8C,CAC5E,MAAQ,IAAS,CACf,IAAK,IAAMC,KAAOD,EACZ,OAAOC,GAAQ,WAAYA,EAAIC,CAAI,EAC9BD,IAAK,EAAI,QAAUC,EAEhC,CACF,C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeRefs-DGM402mE.js","names":["mergeRefs","refs","ref","node"],"sources":["../../src/internal/mergeRefs.ts"],"sourcesContent":["import type { Ref, RefCallback } from \"react\";\n\n/** Send the same node (and unmount notification) to internal and forwarded refs. */\nexport function mergeRefs<T>(...refs: (Ref<T> | undefined)[]): RefCallback<T> {\n return (node) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }\n };\n}\n"],"mappings":";AAGA,SAAgBA,EAAa,GAAGC,GAA8C;CAC5E,QAAQ,MAAS;EACf,KAAK,IAAMC,KAAOD,GAChB,AAAI,OAAOC,KAAQ,aAAYA,EAAIC,CAAI,IAC9BD,MAAK,EAAI,UAAUC;CAEhC;AACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Button/index.cjs"),t=require("../Drawer/index.cjs"),n=require("../SideNav/index.cjs"),r=require("../TopNav/index.cjs");let i=require("react"),a=require("react/jsx-runtime");var o=(0,i.forwardRef)(function({brand:o,navigation:s,actions:c,navigationLabel:l=`Main`,className:u,children:d,...f},p){let[m,h]=(0,i.useState)(null),[g,_]=(0,i.useState)(!1),v=(0,i.useRef)(null),y=(0,i.useRef)(null),b=(0,i.useRef)(!1),x=(0,i.useId)(),S=(0,i.useCallback)(e=>{h(e),typeof p==`function`?p(e):p&&(p.current=e)},[p]);(0,i.useEffect)(()=>{if(!m)return;let e=e=>{e<768||(m.querySelector(`[data-state='open'] [role='dialog']`)?.contains(document.activeElement)&&(b.current=!0),_(!1))};if(e(m.getBoundingClientRect().width),typeof ResizeObserver>`u`)return;let t=new ResizeObserver(([t])=>{t&&e(t.contentRect.width)});return t.observe(m),()=>{t.disconnect()}},[m]),(0,i.useEffect)(()=>{!g&&b.current&&(b.current=!1,(v.current?.querySelector(`[aria-current='page']`)??v.current?.querySelector(`a[href]`)??y.current)?.focus())},[g]);let C=c?.(`drawer`);return(0,a.jsxs)(`div`,{...f,ref:S,className:[`ds-appshell`,u].filter(Boolean).join(` `),children:[(0,a.jsxs)(`div`,{className:`ds-appshell__frame`,"aria-hidden":g||void 0,ref:e=>{e&&(e.inert=g)},children:[(0,a.jsx)(r.TopNav,{brand:o,actions:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`div`,{className:`ds-appshell__actions`,children:c?.(`topnav`)}),(0,a.jsx)(e.Button,{variant:`simple`,size:`lg`,isIconOnly:!0,iconStart:`menu`,className:`ds-appshell__toggle`,"aria-label":`Open navigation`,"aria-expanded":g,"aria-controls":x,onClick:()=>_(!0)})]})}),(0,a.jsxs)(`div`,{className:`ds-appshell__body`,children:[(0,a.jsx)(n.SideNav,{ref:v,className:`ds-appshell__desktop-nav`,label:l,children:s}),(0,a.jsx)(`main`,{ref:y,className:`ds-appshell__main`,tabIndex:-1,children:d})]})]}),(0,a.jsx)(t.Drawer,{id:x,isOpen:g,onClose:()=>_(!1),variant:`navigation`,portalContainer:m,title:o,"aria-label":`Navigation`,closeLabel:`Close navigation`,footer:C?(0,a.jsx)(n.SideNavFooter,{children:C}):void 0,children:(0,a.jsx)(n.SideNav,{className:`ds-appshell__mobile-nav`,label:l,onClick:e=>{let t=e.target instanceof Element?e.target.closest(`a[href]`):null,n=e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||t?.target===`_blank`;t&&!n&&_(!1)},children:s})})]})});exports.AppShell=o;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["forwardRef","useState","useRef","useId","useCallback","TopNav","_Fragment","Button","SideNav","Drawer","SideNavFooter","require_components_Button_index","require_components_Drawer_index","require_components_SideNav_index","require_components_TopNav_index","react","react_jsx_runtime","AppShell","rest","shell","setShell","isOpen","setOpen","desktopNavRef","mainRef","restoreDesktopFocus","drawerId","shellRef","node","ref","measure","width","observer","entry","drawerActions","actions","className","navigationLabel","navigation","brand","link","event","opensElsewhere"],"sources":["../../../src/components/AppShell/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { Drawer } from \"../Drawer\";\nimport { Button } from \"../Button\";\nimport { SideNav, SideNavFooter } from \"../SideNav\";\nimport { TopNav } from \"../TopNav\";\nimport \"./style.css\";\n\nexport interface AppShellProps extends HTMLAttributes<HTMLDivElement> {\n /** Product brand, shared by the top bar and mobile drawer header. */\n brand: ReactNode;\n /** SideNavSection/SideNavItem content. The application owns routing and selection. */\n navigation: ReactNode;\n /** One slot with a compact top-bar and expanded drawer presentation. */\n actions?: (location: \"topnav\" | \"drawer\") => ReactNode;\n navigationLabel?: string;\n /** Rendered inside the shell's scrolling main landmark. */\n children?: ReactNode;\n}\n\n/** Full-width product bar above a desktop rail, or a mobile navigation drawer. */\nexport const AppShell = forwardRef<HTMLDivElement, AppShellProps>(function AppShell(\n { brand, navigation, actions, navigationLabel = \"Main\", className, children, ...rest },\n ref,\n) {\n const [shell, setShell] = useState<HTMLDivElement | null>(null);\n const [isOpen, setOpen] = useState(false);\n const desktopNavRef = useRef<HTMLElement | null>(null);\n const mainRef = useRef<HTMLElement | null>(null);\n const restoreDesktopFocus = useRef(false);\n const drawerId = useId();\n const shellRef = useCallback((node: HTMLDivElement | null) => {\n setShell(node);\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }, [ref]);\n\n useEffect(() => {\n if (!shell) return;\n const measure = (width: number) => {\n if (width < 768) return;\n const focusInDrawer = shell.querySelector(\"[data-state='open'] [role='dialog']\")?.contains(document.activeElement);\n if (focusInDrawer) restoreDesktopFocus.current = true;\n setOpen(false);\n };\n measure(shell.getBoundingClientRect().width);\n if (typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(([entry]) => {\n if (entry) measure(entry.contentRect.width);\n });\n observer.observe(shell);\n return () => {\n observer.disconnect();\n };\n }, [shell]);\n\n useEffect(() => {\n if (isOpen || !restoreDesktopFocus.current) return;\n restoreDesktopFocus.current = false;\n const destination = desktopNavRef.current?.querySelector<HTMLElement>(\"[aria-current='page']\")\n ?? desktopNavRef.current?.querySelector<HTMLElement>(\"a[href]\");\n (destination ?? mainRef.current)?.focus();\n }, [isOpen]);\n\n const drawerActions = actions?.(\"drawer\");\n\n return (\n <div {...rest} ref={shellRef} className={[\"ds-appshell\", className].filter(Boolean).join(\" \")}>\n <div\n className=\"ds-appshell__frame\"\n aria-hidden={isOpen || undefined}\n ref={(node) => { if (node) node.inert = isOpen; }}\n >\n <TopNav\n brand={brand}\n actions={<>\n <div className=\"ds-appshell__actions\">{actions?.(\"topnav\")}</div>\n <Button\n variant=\"simple\"\n size=\"lg\"\n isIconOnly\n iconStart=\"menu\"\n className=\"ds-appshell__toggle\"\n aria-label=\"Open navigation\"\n aria-expanded={isOpen}\n aria-controls={drawerId}\n onClick={() => setOpen(true)}\n />\n </>}\n />\n <div className=\"ds-appshell__body\">\n <SideNav ref={desktopNavRef} className=\"ds-appshell__desktop-nav\" label={navigationLabel}>\n {navigation}\n </SideNav>\n <main ref={mainRef} className=\"ds-appshell__main\" tabIndex={-1}>{children}</main>\n </div>\n </div>\n <Drawer\n id={drawerId}\n isOpen={isOpen}\n onClose={() => setOpen(false)}\n variant=\"navigation\"\n portalContainer={shell}\n title={brand}\n aria-label=\"Navigation\"\n closeLabel=\"Close navigation\"\n footer={drawerActions ? <SideNavFooter>{drawerActions}</SideNavFooter> : undefined}\n >\n <SideNav\n className=\"ds-appshell__mobile-nav\"\n label={navigationLabel}\n onClick={(event) => {\n const link = event.target instanceof Element ? event.target.closest<HTMLAnchorElement>(\"a[href]\") : null;\n // Opening a link elsewhere (modifier keys, another button, a new tab) leaves this page in place.\n const opensElsewhere = event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey\n || event.altKey || link?.target === \"_blank\";\n if (link && !opensElsewhere) setOpen(false);\n }}\n >\n {navigation}\n </SideNav>\n </Drawer>\n </div>\n );\n});\n"],"mappings":"A,oQA6BA,IAAaiB,GAAA,EAAWjB,EAAAA,WAAAA,CAA0C,SAChE,CAAE,QAAO,aAAY,UAAS,kBAAkB,OAAQ,YAAW,WAAU,GAAGkB,GAChF,EACA,CACA,GAAM,CAACC,EAAOC,IAAA,EAAYnB,EAAAA,SAAAA,CAAgC,IAAI,EACxD,CAACoB,EAAQC,IAAA,EAAWrB,EAAAA,SAAAA,CAAS,EAAK,EAClCsB,GAAA,EAAgBrB,EAAAA,OAAAA,CAA2B,IAAI,EAC/CsB,GAAA,EAAUtB,EAAAA,OAAAA,CAA2B,IAAI,EACzCuB,GAAA,EAAsBvB,EAAAA,OAAAA,CAAO,EAAK,EAClCwB,GAAA,EAAWvB,EAAAA,MAAAA,CAAM,EACjBwB,GAAA,EAAWvB,EAAAA,YAAAA,CAAa,GAAgC,CAC5DgB,EAASQ,CAAI,EACT,OAAOC,GAAQ,WAAYA,EAAID,CAAI,EAC9BC,IAAK,EAAI,QAAUD,EAC9B,EAAG,CAACC,CAAG,CAAC,GAER,EAAAd,EAAA,UAAA,KAAgB,CACd,GAAI,CAACI,EAAO,OACZ,IAAMW,EAAW,GAAkB,CAC7BC,EAAQ,MACUZ,EAAM,cAAc,qCAAqC,CAAC,EAAE,SAAS,SAAS,aAAa,IAC9F,EAAoB,QAAU,IACjDG,EAAQ,EAAK,EACf,EAEA,GADAQ,EAAQX,EAAM,sBAAsB,CAAC,CAAC,KAAK,EACvC,OAAO,eAAmB,IAAa,OAC3C,IAAMa,EAAW,IAAI,gBAAgB,CAACC,KAAW,CAC3CA,GAAOH,EAAQG,EAAM,YAAY,KAAK,CAC5C,CAAC,EAED,OADAD,EAAS,QAAQb,CAAK,MACT,CACXa,EAAS,WAAW,CACtB,CACF,EAAG,CAACb,CAAK,CAAC,GAEV,EAAAJ,EAAA,UAAA,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,EAAA,IAAA,CAACP,EAAAA,OAAD,CACE,GAAIiB,EACI,SACR,YAAeJ,EAAQ,EAAK,EAC5B,QAAQ,aACR,gBAAiBH,EACjB,MAAOoB,EACP,aAAW,aACX,WAAW,mBACX,OAAQL,GAAgB,EAAAlB,EAAA,IAAA,CAACN,EAAAA,cAAD,CAAA,SAAgBwB,CAA6B,CAAA,EAAI,IAAA,GAEzE,UAAA,EAAAlB,EAAA,IAAA,CAACR,EAAAA,QAAD,CACE,UAAU,0BACV,MAAO6B,EACP,QAAU,GAAU,CAClB,IAAMG,EAAOC,EAAM,kBAAkB,QAAUA,EAAM,OAAO,QAA2B,SAAS,EAAI,KAE9FC,EAAiBD,EAAM,SAAW,GAAKA,EAAM,SAAWA,EAAM,SAAWA,EAAM,UAChFA,EAAM,QAAUD,GAAM,SAAW,SAClCA,GAAQ,CAACE,GAAgBpB,EAAQ,EAAK,CAC5C,EAEC,SAAAgB,CACM,CAAA,CACH,CAAA,CACL,C,EAET,CAAC,E"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
export interface AppShellProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** Product brand, shared by the top bar and mobile drawer header. */
|
|
4
|
+
brand: ReactNode;
|
|
5
|
+
/** SideNavSection/SideNavItem content. The application owns routing and selection. */
|
|
6
|
+
navigation: ReactNode;
|
|
7
|
+
/** One slot with a compact top-bar and expanded drawer presentation. */
|
|
8
|
+
actions?: (location: "topnav" | "drawer") => ReactNode;
|
|
9
|
+
navigationLabel?: string;
|
|
10
|
+
/** Rendered inside the shell's scrolling main landmark. */
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/** Full-width product bar above a desktop rail, or a mobile navigation drawer. */
|
|
14
|
+
export declare const AppShell: import("react").ForwardRefExoticComponent<AppShellProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
15
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/AppShell/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAKf,OAAO,aAAa,CAAC;AAErB,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,cAAc,CAAC;IACnE,qEAAqE;IACrE,KAAK,EAAE,SAAS,CAAC;IACjB,sFAAsF;IACtF,UAAU,EAAE,SAAS,CAAC;IACtB,wEAAwE;IACxE,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,KAAK,SAAS,CAAC;IACvD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,kFAAkF;AAClF,eAAO,MAAM,QAAQ,0GAuGnB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
export interface AppShellProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** Product brand, shared by the top bar and mobile drawer header. */
|
|
4
|
+
brand: ReactNode;
|
|
5
|
+
/** SideNavSection/SideNavItem content. The application owns routing and selection. */
|
|
6
|
+
navigation: ReactNode;
|
|
7
|
+
/** One slot with a compact top-bar and expanded drawer presentation. */
|
|
8
|
+
actions?: (location: "topnav" | "drawer") => ReactNode;
|
|
9
|
+
navigationLabel?: string;
|
|
10
|
+
/** Rendered inside the shell's scrolling main landmark. */
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/** Full-width product bar above a desktop rail, or a mobile navigation drawer. */
|
|
14
|
+
export declare const AppShell: import("react").ForwardRefExoticComponent<AppShellProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/AppShell/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAKf,OAAO,aAAa,CAAC;AAErB,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,cAAc,CAAC;IACnE,qEAAqE;IACrE,KAAK,EAAE,SAAS,CAAC;IACjB,sFAAsF;IACtF,UAAU,EAAE,SAAS,CAAC;IACtB,wEAAwE;IACxE,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,KAAK,SAAS,CAAC;IACvD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,kFAAkF;AAClF,eAAO,MAAM,QAAQ,0GAuGnB,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Button as e } from "../Button/index.js";
|
|
2
|
+
import { Drawer as t } from "../Drawer/index.js";
|
|
3
|
+
import { SideNav as n, SideNavFooter as r } from "../SideNav/index.js";
|
|
4
|
+
import { TopNav as i } from "../TopNav/index.js";
|
|
5
|
+
import { forwardRef as a, useCallback as o, useEffect as s, useId as c, useRef as l, useState as u } from "react";
|
|
6
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/AppShell/index.tsx
|
|
8
|
+
var m = a(function({ brand: a, navigation: m, actions: h, navigationLabel: g = "Main", className: _, children: v, ...y }, b) {
|
|
9
|
+
let [x, S] = u(null), [C, w] = u(!1), T = l(null), E = l(null), D = l(!1), O = c(), k = o((e) => {
|
|
10
|
+
S(e), typeof b == "function" ? b(e) : b && (b.current = e);
|
|
11
|
+
}, [b]);
|
|
12
|
+
s(() => {
|
|
13
|
+
if (!x) return;
|
|
14
|
+
let e = (e) => {
|
|
15
|
+
e < 768 || (x.querySelector("[data-state='open'] [role='dialog']")?.contains(document.activeElement) && (D.current = !0), w(!1));
|
|
16
|
+
};
|
|
17
|
+
if (e(x.getBoundingClientRect().width), typeof ResizeObserver > "u") return;
|
|
18
|
+
let t = new ResizeObserver(([t]) => {
|
|
19
|
+
t && e(t.contentRect.width);
|
|
20
|
+
});
|
|
21
|
+
return t.observe(x), () => {
|
|
22
|
+
t.disconnect();
|
|
23
|
+
};
|
|
24
|
+
}, [x]), s(() => {
|
|
25
|
+
!C && D.current && (D.current = !1, (T.current?.querySelector("[aria-current='page']") ?? T.current?.querySelector("a[href]") ?? E.current)?.focus());
|
|
26
|
+
}, [C]);
|
|
27
|
+
let A = h?.("drawer");
|
|
28
|
+
return /* @__PURE__ */ p("div", {
|
|
29
|
+
...y,
|
|
30
|
+
ref: k,
|
|
31
|
+
className: ["ds-appshell", _].filter(Boolean).join(" "),
|
|
32
|
+
children: [/* @__PURE__ */ p("div", {
|
|
33
|
+
className: "ds-appshell__frame",
|
|
34
|
+
"aria-hidden": C || void 0,
|
|
35
|
+
ref: (e) => {
|
|
36
|
+
e && (e.inert = C);
|
|
37
|
+
},
|
|
38
|
+
children: [/* @__PURE__ */ f(i, {
|
|
39
|
+
brand: a,
|
|
40
|
+
actions: /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("div", {
|
|
41
|
+
className: "ds-appshell__actions",
|
|
42
|
+
children: h?.("topnav")
|
|
43
|
+
}), /* @__PURE__ */ f(e, {
|
|
44
|
+
variant: "simple",
|
|
45
|
+
size: "lg",
|
|
46
|
+
isIconOnly: !0,
|
|
47
|
+
iconStart: "menu",
|
|
48
|
+
className: "ds-appshell__toggle",
|
|
49
|
+
"aria-label": "Open navigation",
|
|
50
|
+
"aria-expanded": C,
|
|
51
|
+
"aria-controls": O,
|
|
52
|
+
onClick: () => w(!0)
|
|
53
|
+
})] })
|
|
54
|
+
}), /* @__PURE__ */ p("div", {
|
|
55
|
+
className: "ds-appshell__body",
|
|
56
|
+
children: [/* @__PURE__ */ f(n, {
|
|
57
|
+
ref: T,
|
|
58
|
+
className: "ds-appshell__desktop-nav",
|
|
59
|
+
label: g,
|
|
60
|
+
children: m
|
|
61
|
+
}), /* @__PURE__ */ f("main", {
|
|
62
|
+
ref: E,
|
|
63
|
+
className: "ds-appshell__main",
|
|
64
|
+
tabIndex: -1,
|
|
65
|
+
children: v
|
|
66
|
+
})]
|
|
67
|
+
})]
|
|
68
|
+
}), /* @__PURE__ */ f(t, {
|
|
69
|
+
id: O,
|
|
70
|
+
isOpen: C,
|
|
71
|
+
onClose: () => w(!1),
|
|
72
|
+
variant: "navigation",
|
|
73
|
+
portalContainer: x,
|
|
74
|
+
title: a,
|
|
75
|
+
"aria-label": "Navigation",
|
|
76
|
+
closeLabel: "Close navigation",
|
|
77
|
+
footer: A ? /* @__PURE__ */ f(r, { children: A }) : void 0,
|
|
78
|
+
children: /* @__PURE__ */ f(n, {
|
|
79
|
+
className: "ds-appshell__mobile-nav",
|
|
80
|
+
label: g,
|
|
81
|
+
onClick: (e) => {
|
|
82
|
+
let t = e.target instanceof Element ? e.target.closest("a[href]") : null, n = e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || t?.target === "_blank";
|
|
83
|
+
t && !n && w(!1);
|
|
84
|
+
},
|
|
85
|
+
children: m
|
|
86
|
+
})
|
|
87
|
+
})]
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
//#endregion
|
|
91
|
+
export { m as AppShell };
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Fragment","Fragment$1","AppShell","forwardRef","rest","shell","setShell","useState","isOpen","setOpen","desktopNavRef","useRef","mainRef","restoreDesktopFocus","drawerId","useId","shellRef","useCallback","node","ref","useEffect","measure","width","observer","entry","drawerActions","actions","className","TopNav","Button","SideNav","navigationLabel","navigation","Drawer","brand","SideNavFooter","link","event","opensElsewhere"],"sources":["../../../src/components/AppShell/index.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { Drawer } from \"../Drawer\";\nimport { Button } from \"../Button\";\nimport { SideNav, SideNavFooter } from \"../SideNav\";\nimport { TopNav } from \"../TopNav\";\nimport \"./style.css\";\n\nexport interface AppShellProps extends HTMLAttributes<HTMLDivElement> {\n /** Product brand, shared by the top bar and mobile drawer header. */\n brand: ReactNode;\n /** SideNavSection/SideNavItem content. The application owns routing and selection. */\n navigation: ReactNode;\n /** One slot with a compact top-bar and expanded drawer presentation. */\n actions?: (location: \"topnav\" | \"drawer\") => ReactNode;\n navigationLabel?: string;\n /** Rendered inside the shell's scrolling main landmark. */\n children?: ReactNode;\n}\n\n/** Full-width product bar above a desktop rail, or a mobile navigation drawer. */\nexport const AppShell = forwardRef<HTMLDivElement, AppShellProps>(function AppShell(\n { brand, navigation, actions, navigationLabel = \"Main\", className, children, ...rest },\n ref,\n) {\n const [shell, setShell] = useState<HTMLDivElement | null>(null);\n const [isOpen, setOpen] = useState(false);\n const desktopNavRef = useRef<HTMLElement | null>(null);\n const mainRef = useRef<HTMLElement | null>(null);\n const restoreDesktopFocus = useRef(false);\n const drawerId = useId();\n const shellRef = useCallback((node: HTMLDivElement | null) => {\n setShell(node);\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n }, [ref]);\n\n useEffect(() => {\n if (!shell) return;\n const measure = (width: number) => {\n if (width < 768) return;\n const focusInDrawer = shell.querySelector(\"[data-state='open'] [role='dialog']\")?.contains(document.activeElement);\n if (focusInDrawer) restoreDesktopFocus.current = true;\n setOpen(false);\n };\n measure(shell.getBoundingClientRect().width);\n if (typeof ResizeObserver === \"undefined\") return;\n const observer = new ResizeObserver(([entry]) => {\n if (entry) measure(entry.contentRect.width);\n });\n observer.observe(shell);\n return () => {\n observer.disconnect();\n };\n }, [shell]);\n\n useEffect(() => {\n if (isOpen || !restoreDesktopFocus.current) return;\n restoreDesktopFocus.current = false;\n const destination = desktopNavRef.current?.querySelector<HTMLElement>(\"[aria-current='page']\")\n ?? desktopNavRef.current?.querySelector<HTMLElement>(\"a[href]\");\n (destination ?? mainRef.current)?.focus();\n }, [isOpen]);\n\n const drawerActions = actions?.(\"drawer\");\n\n return (\n <div {...rest} ref={shellRef} className={[\"ds-appshell\", className].filter(Boolean).join(\" \")}>\n <div\n className=\"ds-appshell__frame\"\n aria-hidden={isOpen || undefined}\n ref={(node) => { if (node) node.inert = isOpen; }}\n >\n <TopNav\n brand={brand}\n actions={<>\n <div className=\"ds-appshell__actions\">{actions?.(\"topnav\")}</div>\n <Button\n variant=\"simple\"\n size=\"lg\"\n isIconOnly\n iconStart=\"menu\"\n className=\"ds-appshell__toggle\"\n aria-label=\"Open navigation\"\n aria-expanded={isOpen}\n aria-controls={drawerId}\n onClick={() => setOpen(true)}\n />\n </>}\n />\n <div className=\"ds-appshell__body\">\n <SideNav ref={desktopNavRef} className=\"ds-appshell__desktop-nav\" label={navigationLabel}>\n {navigation}\n </SideNav>\n <main ref={mainRef} className=\"ds-appshell__main\" tabIndex={-1}>{children}</main>\n </div>\n </div>\n <Drawer\n id={drawerId}\n isOpen={isOpen}\n onClose={() => setOpen(false)}\n variant=\"navigation\"\n portalContainer={shell}\n title={brand}\n aria-label=\"Navigation\"\n closeLabel=\"Close navigation\"\n footer={drawerActions ? <SideNavFooter>{drawerActions}</SideNavFooter> : undefined}\n >\n <SideNav\n className=\"ds-appshell__mobile-nav\"\n label={navigationLabel}\n onClick={(event) => {\n const link = event.target instanceof Element ? event.target.closest<HTMLAnchorElement>(\"a[href]\") : null;\n // Opening a link elsewhere (modifier keys, another button, a new tab) leaves this page in place.\n const opensElsewhere = event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey\n || event.altKey || link?.target === \"_blank\";\n if (link && !opensElsewhere) setOpen(false);\n }}\n >\n {navigation}\n </SideNav>\n </Drawer>\n </div>\n );\n});\n"],"mapp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AC5C;IAEC,UAAAuB;GACM,CAAA;EACH,CAAA,CACL;;AAET,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
.ds-appshell {
|
|
3
|
+
position: relative;
|
|
4
|
+
container: ds-appshell / inline-size;
|
|
5
|
+
block-size: 100dvh;
|
|
6
|
+
inline-size: 100%;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
background: var(--color-canvas);
|
|
9
|
+
color: var(--color-text);
|
|
10
|
+
font-family: var(--font-sans);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.ds-appshell__frame {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
block-size: 100%;
|
|
17
|
+
min-block-size: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.ds-appshell .ds-topnav {
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
position: sticky;
|
|
23
|
+
inset-block-start: 0;
|
|
24
|
+
z-index: 10;
|
|
25
|
+
flex: none;
|
|
26
|
+
gap: var(--space-3);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.ds-appshell__body {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex: 1;
|
|
32
|
+
min-block-size: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.ds-appshell__desktop-nav {
|
|
36
|
+
box-sizing: border-box;
|
|
37
|
+
min-block-size: 0;
|
|
38
|
+
overflow-y: auto;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.ds-appshell__main {
|
|
42
|
+
flex: 1;
|
|
43
|
+
min-inline-size: 0;
|
|
44
|
+
overflow-y: auto;
|
|
45
|
+
padding: var(--space-8);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.ds-appshell__actions {
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
gap: var(--space-3);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.ds-appshell__toggle.ds-button {
|
|
55
|
+
display: none;
|
|
56
|
+
flex: none;
|
|
57
|
+
margin-inline-start: auto;
|
|
58
|
+
margin-inline-end: calc(-1 * var(--space-2));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.ds-appshell__mobile-nav {
|
|
62
|
+
inline-size: 100%;
|
|
63
|
+
min-block-size: 0;
|
|
64
|
+
border: 0;
|
|
65
|
+
overflow-y: auto;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.ds-appshell__mobile-nav .ds-sidenav__item {
|
|
69
|
+
min-block-size: calc(var(--space-10) + var(--space-1));
|
|
70
|
+
font-size: var(--field-font-size-md);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@container ds-appshell (width < 768px) {
|
|
74
|
+
.ds-appshell .ds-topnav { padding-inline: var(--space-4); }
|
|
75
|
+
.ds-appshell__desktop-nav, .ds-appshell__actions { display: none; }
|
|
76
|
+
.ds-appshell__toggle.ds-button { display: flex; }
|
|
77
|
+
.ds-appshell__main { padding: var(--space-6) var(--space-4); }
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-CWsA1W83.cjs"),t=require("../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-CWsA1W83.cjs"),t=require("../Button/index.cjs"),n=require("../Grid/index.cjs"),r=require("../Skeleton/index.cjs");let i=require("react"),a=require("react/jsx-runtime");function o(...e){return e.filter(Boolean).join(` `)}var s=(0,i.forwardRef)(function({isLoading:e=!1,loadingCount:t=8,className:r,children:i,...s},l){return(0,a.jsx)(n.Grid,{ref:l,columns:`auto`,gap:`md`,minColumnWidth:`var(--asset-tile-min-width)`,className:o(`ds-asset-grid`,r),"aria-busy":e||void 0,...s,children:e?Array.from({length:t},(e,t)=>(0,a.jsx)(c,{index:t},t)):i})});function c({index:e=0}){let t={animationDelay:`calc(var(--skeleton-stagger) * ${e})`};return(0,a.jsxs)(`div`,{className:`ds-asset-tile`,"data-loading":`true`,"aria-hidden":`true`,children:[(0,a.jsx)(r.Skeleton,{shape:`block`,className:`ds-asset-tile__thumb`,style:t}),(0,a.jsxs)(`div`,{className:`ds-asset-tile__text`,children:[(0,a.jsx)(r.Skeleton,{shape:`text`,width:`80%`,style:t}),(0,a.jsx)(r.Skeleton,{shape:`text`,width:`45%`,style:t})]})]})}var l=(0,i.forwardRef)(function({name:n,src:s,icon:c=`image`,meta:l,isSelected:u=!1,isPending:d=!1,onSelect:f,actions:p,className:m,...h},g){let[_,v]=(0,i.useState)(!1),[y,b]=(0,i.useState)(!1),x=!!s&&!_;return(0,a.jsxs)(`div`,{ref:g,className:o(`ds-asset-tile`,m),"data-selected":u||void 0,"data-pending":d||void 0,...h,children:[(0,a.jsxs)(`div`,{className:`ds-asset-tile__thumb`,children:[x?(0,a.jsxs)(a.Fragment,{children:[!y&&(0,a.jsx)(r.Skeleton,{shape:`block`,className:`ds-asset-tile__thumb-skeleton`}),(0,a.jsx)(`img`,{src:s,alt:``,loading:`lazy`,"data-loaded":y||void 0,onLoad:()=>b(!0),onError:()=>v(!0)})]}):(0,a.jsx)(`span`,{className:`ds-asset-tile__placeholder`,children:(0,a.jsx)(e.t,{name:_?`alert-triangle`:c,size:24})}),d&&(0,a.jsxs)(`span`,{className:`ds-asset-tile__pending`,role:`status`,children:[(0,a.jsx)(e.t,{name:`spinner`,size:20,className:`ds-asset-tile__spinner`}),(0,a.jsx)(`span`,{className:`ds-asset-tile__pending-label`,children:`Uploading`})]}),p&&(0,a.jsx)(`div`,{className:`ds-asset-tile__actions`,children:p}),f&&(0,a.jsx)(t.Button,{variant:`simple`,className:`ds-asset-tile__hit`,"aria-pressed":u,"aria-label":n,isDisabled:d,onClick:f})]}),(0,a.jsxs)(`div`,{className:`ds-asset-tile__text`,children:[(0,a.jsx)(`span`,{className:`ds-asset-tile__name`,children:n}),l&&(0,a.jsx)(`span`,{className:`ds-asset-tile__meta`,children:l})]})]})});function u({title:t,description:n,action:r}){return(0,a.jsxs)(`div`,{className:`ds-asset-empty`,children:[(0,a.jsx)(e.t,{name:`image`,size:24}),(0,a.jsx)(`span`,{className:`ds-asset-empty__title`,children:t}),n&&(0,a.jsx)(`span`,{className:`ds-asset-empty__description`,children:n}),r]})}exports.AssetGrid=s,exports.AssetGridEmpty=u,exports.AssetTile=l,exports.AssetTileSkeleton=c;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|