@nocoo/basalt 2.0.0 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/alert-dialog.js +2 -1
- package/dist/components/alert-dialog.js.map +1 -1
- package/dist/components/button.js +2 -2
- package/dist/components/button.js.map +1 -1
- package/dist/components/chat-bubble.d.ts +17 -0
- package/dist/components/chat-bubble.js +25 -0
- package/dist/components/chat-bubble.js.map +1 -0
- package/dist/components/chat-composer.d.ts +41 -0
- package/dist/components/chat-composer.js +74 -0
- package/dist/components/chat-composer.js.map +1 -0
- package/dist/components/chat-header.d.ts +20 -0
- package/dist/components/chat-header.js +33 -0
- package/dist/components/chat-header.js.map +1 -0
- package/dist/components/chat-inbox.d.ts +28 -0
- package/dist/components/chat-inbox.js +44 -0
- package/dist/components/chat-inbox.js.map +1 -0
- package/dist/components/description-list.d.ts +21 -0
- package/dist/components/description-list.js +35 -0
- package/dist/components/description-list.js.map +1 -0
- package/dist/components/dialog.js +3 -2
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/dock.d.ts +39 -0
- package/dist/components/dock.js +116 -0
- package/dist/components/dock.js.map +1 -0
- package/dist/components/fab.d.ts +23 -0
- package/dist/components/fab.js +25 -0
- package/dist/components/fab.js.map +1 -0
- package/dist/components/layer-card.d.ts +23 -4
- package/dist/components/layer-card.js +83 -50
- package/dist/components/layer-card.js.map +1 -1
- package/dist/components/page-header.d.ts +4 -4
- package/dist/components/page-header.js +20 -23
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/section-rule.d.ts +10 -0
- package/dist/components/section-rule.js +44 -0
- package/dist/components/section-rule.js.map +1 -0
- package/dist/components/sheet.d.ts +4 -4
- package/dist/components/sheet.js +5 -4
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/sidebar.js +1 -0
- package/dist/components/sidebar.js.map +1 -1
- package/dist/components/table.js +6 -5
- package/dist/components/table.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +26 -25
- package/dist/providers/accent.d.ts +3 -2
- package/dist/providers/accent.js +166 -44
- package/dist/providers/accent.js.map +1 -1
- package/dist/styles/standalone.css +378 -92
- package/dist/styles/tailwind.css +1 -0
- package/dist/styles/tokens.css +70 -0
- package/dist/utils/control-surface.d.ts +1 -1
- package/dist/utils/control-surface.js +1 -1
- package/dist/utils/control-surface.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../utils/cn.js";
|
|
3
|
+
import { OVERLAY_LAYER as t, OVERLAY_MOTION as n } from "./overlay.js";
|
|
4
|
+
import { dialogOverlayClass as r } from "./dialog.js";
|
|
5
|
+
import { useEffect as i, useRef as a } from "react";
|
|
6
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/dock.tsx
|
|
8
|
+
var c = "button:not([disabled]), [href], input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])", l = "[data-radix-popper-content-wrapper], [data-radix-select-viewport]";
|
|
9
|
+
function u(e) {
|
|
10
|
+
return e ? [...e.querySelectorAll(c)].filter((e) => {
|
|
11
|
+
if (e.closest("[inert], [hidden]") || e.tabIndex < 0 || window.getComputedStyle(e).visibility === "hidden") return !1;
|
|
12
|
+
for (let t = e; t; t = t.parentElement) if (window.getComputedStyle(t).display === "none") return !1;
|
|
13
|
+
return !0;
|
|
14
|
+
}) : [];
|
|
15
|
+
}
|
|
16
|
+
function d({ className: t, children: n }) {
|
|
17
|
+
return /* @__PURE__ */ o("div", {
|
|
18
|
+
className: e("flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-3 py-3", t),
|
|
19
|
+
children: n
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function f({ open: c, mode: d = "push", width: f = "clamp(300px, 32.5vw, 546px)", onDismiss: p, dismissLabel: m = "Dismiss", className: h, children: g, "aria-label": _ }) {
|
|
23
|
+
let v = d === "overlay", y = a(null), b = a(null), x = (e) => {
|
|
24
|
+
y.current = e;
|
|
25
|
+
}, S = a(!v && c), C = a(null);
|
|
26
|
+
i(() => {
|
|
27
|
+
if (c) {
|
|
28
|
+
if (S.current) return;
|
|
29
|
+
C.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
30
|
+
let e = window.setTimeout(() => {
|
|
31
|
+
let e = y.current;
|
|
32
|
+
(u(e)[0] ?? e)?.focus(), S.current = !0;
|
|
33
|
+
}, 0);
|
|
34
|
+
return () => window.clearTimeout(e);
|
|
35
|
+
}
|
|
36
|
+
S.current &&= (C.current?.focus?.(), C.current = null, !1);
|
|
37
|
+
}, [c]), i(() => {
|
|
38
|
+
if (!v || !c) return;
|
|
39
|
+
let e = (e) => {
|
|
40
|
+
if (e.key === "Escape") {
|
|
41
|
+
if (e.defaultPrevented || !p) return;
|
|
42
|
+
e.preventDefault(), p();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (e.key !== "Tab") return;
|
|
46
|
+
let t = b.current;
|
|
47
|
+
if (!t) return;
|
|
48
|
+
let n = u(t);
|
|
49
|
+
if (n.length === 0) {
|
|
50
|
+
e.preventDefault(), y.current?.focus();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
let r = n[0], i = n[n.length - 1], a = document.activeElement;
|
|
54
|
+
if (a instanceof Element) {
|
|
55
|
+
let e = a.closest("[role='dialog'], [role='alertdialog']");
|
|
56
|
+
if (e && e !== y.current && !t.contains(e) || a.closest(l)) return;
|
|
57
|
+
}
|
|
58
|
+
if (!(a instanceof Node) || !t.contains(a) || !e.shiftKey && a === i) {
|
|
59
|
+
e.preventDefault(), r?.focus();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
e.shiftKey && a === r && (e.preventDefault(), i?.focus());
|
|
63
|
+
};
|
|
64
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
65
|
+
}, [
|
|
66
|
+
v,
|
|
67
|
+
c,
|
|
68
|
+
p
|
|
69
|
+
]);
|
|
70
|
+
let w = e("overflow-hidden bg-basalt-background transition-[width] duration-300 ease-in-out", v ? e("absolute top-0 right-0 h-full", t) : "sticky top-0 h-screen shrink-0", n, h), T = { width: c ? f : 0 }, E = /* @__PURE__ */ o("div", {
|
|
71
|
+
className: "flex h-full flex-col bg-basalt-card shadow-lg ring-1 ring-basalt-border/40",
|
|
72
|
+
style: { width: f },
|
|
73
|
+
children: g
|
|
74
|
+
});
|
|
75
|
+
return v ? /* @__PURE__ */ s("div", {
|
|
76
|
+
ref: b,
|
|
77
|
+
className: e("absolute inset-0", t, !c && "pointer-events-none"),
|
|
78
|
+
children: [p ? /* @__PURE__ */ o("button", {
|
|
79
|
+
type: "button",
|
|
80
|
+
tabIndex: c ? 0 : -1,
|
|
81
|
+
"aria-label": m,
|
|
82
|
+
"aria-hidden": !c,
|
|
83
|
+
"data-state": c ? "open" : "closed",
|
|
84
|
+
className: e(r("absolute"), !c && "opacity-0"),
|
|
85
|
+
onClick: c ? p : void 0
|
|
86
|
+
}) : /* @__PURE__ */ o("div", {
|
|
87
|
+
"aria-hidden": !0,
|
|
88
|
+
"data-state": c ? "open" : "closed",
|
|
89
|
+
className: e(r("absolute"), !c && "opacity-0")
|
|
90
|
+
}), /* @__PURE__ */ o("div", {
|
|
91
|
+
ref: x,
|
|
92
|
+
role: "dialog",
|
|
93
|
+
"aria-modal": c ? !0 : void 0,
|
|
94
|
+
"aria-label": _,
|
|
95
|
+
className: w,
|
|
96
|
+
style: T,
|
|
97
|
+
"aria-hidden": !c,
|
|
98
|
+
inert: !c || void 0,
|
|
99
|
+
tabIndex: c ? -1 : void 0,
|
|
100
|
+
children: E
|
|
101
|
+
})]
|
|
102
|
+
}) : /* @__PURE__ */ o("aside", {
|
|
103
|
+
ref: x,
|
|
104
|
+
className: w,
|
|
105
|
+
style: T,
|
|
106
|
+
"aria-label": _,
|
|
107
|
+
"aria-hidden": !c,
|
|
108
|
+
inert: !c || void 0,
|
|
109
|
+
tabIndex: c ? -1 : void 0,
|
|
110
|
+
children: E
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
114
|
+
export { f as Dock, d as DockBody };
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=dock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dock.js","names":[],"sources":["../../src/components/dock.tsx"],"sourcesContent":["import { type ReactNode, useEffect, useRef } from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { dialogOverlayClass } from \"./dialog\";\nimport { OVERLAY_LAYER, OVERLAY_MOTION } from \"./overlay\";\n\nconst FOCUSABLE =\n\t'button:not([disabled]), [href], input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\nconst PORTAL_FOCUS = \"[data-radix-popper-content-wrapper], [data-radix-select-viewport]\";\n\nfunction tabbables(root: HTMLElement | null) {\n\tif (!root) {\n\t\treturn [];\n\t}\n\treturn [...root.querySelectorAll<HTMLElement>(FOCUSABLE)].filter((node) => {\n\t\tif (node.closest(\"[inert], [hidden]\")) {\n\t\t\treturn false;\n\t\t}\n\t\tif (node.tabIndex < 0) {\n\t\t\treturn false;\n\t\t}\n\t\tif (window.getComputedStyle(node).visibility === \"hidden\") {\n\t\t\treturn false;\n\t\t}\n\t\tfor (let current: HTMLElement | null = node; current; current = current.parentElement) {\n\t\t\tif (window.getComputedStyle(current).display === \"none\") {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t});\n}\n\nexport type DockMode = \"overlay\" | \"push\";\n\nexport interface DockProps {\n\t/**\n\t * Whether the dock occupies its width.\n\t */\n\topen: boolean;\n\t/**\n\t * `push` shrinks the main column. `overlay` covers it with a Dialog scrim.\n\t * @default \"push\"\n\t */\n\tmode?: DockMode;\n\t/**\n\t * Width when open.\n\t * @default \"clamp(300px, 32.5vw, 546px)\"\n\t */\n\twidth?: string;\n\t/**\n\t * Overlay scrim click. Ignored in push mode.\n\t */\n\tonDismiss?: () => void;\n\t/**\n\t * Overlay scrim accessible name.\n\t * @default \"Dismiss\"\n\t */\n\tdismissLabel?: string;\n\t/**\n\t * Accessible name.\n\t */\n\t\"aria-label\": string;\n\tclassName?: string;\n\tchildren: ReactNode;\n}\n\nexport interface DockBodyProps {\n\tclassName?: string;\n\tchildren: ReactNode;\n}\n\nexport function DockBody({ className, children }: DockBodyProps) {\n\treturn (\n\t\t<div className={cn(\"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-3 py-3\", className)}>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n\nexport function Dock({\n\topen,\n\tmode = \"push\",\n\twidth = \"clamp(300px, 32.5vw, 546px)\",\n\tonDismiss,\n\tdismissLabel = \"Dismiss\",\n\tclassName,\n\tchildren,\n\t\"aria-label\": ariaLabel,\n}: DockProps) {\n\tconst overlay = mode === \"overlay\";\n\tconst panelRef = useRef<HTMLElement | null>(null);\n\tconst overlayRootRef = useRef<HTMLDivElement>(null);\n\tconst setPanel = (node: HTMLElement | null) => {\n\t\tpanelRef.current = node;\n\t};\n\tconst wasOpen = useRef(!overlay && open);\n\tconst previousFocus = useRef<HTMLElement | null>(null);\n\n\tuseEffect(() => {\n\t\tif (open) {\n\t\t\tif (wasOpen.current) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tpreviousFocus.current =\n\t\t\t\tdocument.activeElement instanceof HTMLElement ? document.activeElement : null;\n\t\t\tconst timer = window.setTimeout(() => {\n\t\t\t\tconst root = panelRef.current;\n\t\t\t\tconst nodes = tabbables(root);\n\t\t\t\t(nodes[0] ?? root)?.focus();\n\t\t\t\twasOpen.current = true;\n\t\t\t}, 0);\n\t\t\treturn () => window.clearTimeout(timer);\n\t\t}\n\t\tif (wasOpen.current) {\n\t\t\tpreviousFocus.current?.focus?.();\n\t\t\tpreviousFocus.current = null;\n\t\t\twasOpen.current = false;\n\t\t}\n\t}, [open]);\n\n\tuseEffect(() => {\n\t\tif (!overlay || !open) {\n\t\t\treturn;\n\t\t}\n\t\tconst onKeyDown = (event: KeyboardEvent) => {\n\t\t\tif (event.key === \"Escape\") {\n\t\t\t\tif (event.defaultPrevented || !onDismiss) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonDismiss();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.key !== \"Tab\") {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst root = overlayRootRef.current;\n\t\t\tif (!root) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst nodes = tabbables(root);\n\t\t\tif (nodes.length === 0) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tpanelRef.current?.focus();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst first = nodes[0];\n\t\t\tconst last = nodes[nodes.length - 1];\n\t\t\tconst active = document.activeElement;\n\t\t\tif (active instanceof Element) {\n\t\t\t\tconst nestedModal = active.closest(\"[role='dialog'], [role='alertdialog']\");\n\t\t\t\tif (nestedModal && nestedModal !== panelRef.current && !root.contains(nestedModal)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (active.closest(PORTAL_FOCUS)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!(active instanceof Node) ||\n\t\t\t\t!root.contains(active) ||\n\t\t\t\t(!event.shiftKey && active === last)\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tfirst?.focus();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.shiftKey && active === first) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tlast?.focus();\n\t\t\t}\n\t\t};\n\t\twindow.addEventListener(\"keydown\", onKeyDown);\n\t\treturn () => window.removeEventListener(\"keydown\", onKeyDown);\n\t}, [overlay, open, onDismiss]);\n\tconst panelClass = cn(\n\t\t\"overflow-hidden bg-basalt-background transition-[width] duration-300 ease-in-out\",\n\t\toverlay ? cn(\"absolute top-0 right-0 h-full\", OVERLAY_LAYER) : \"sticky top-0 h-screen shrink-0\",\n\t\tOVERLAY_MOTION,\n\t\tclassName,\n\t);\n\tconst panelStyle = { width: open ? width : 0 };\n\tconst inner = (\n\t\t<div\n\t\t\tclassName=\"flex h-full flex-col bg-basalt-card shadow-lg ring-1 ring-basalt-border/40\"\n\t\t\tstyle={{ width }}\n\t\t>\n\t\t\t{children}\n\t\t</div>\n\t);\n\n\tif (!overlay) {\n\t\treturn (\n\t\t\t<aside\n\t\t\t\tref={setPanel}\n\t\t\t\tclassName={panelClass}\n\t\t\t\tstyle={panelStyle}\n\t\t\t\taria-label={ariaLabel}\n\t\t\t\taria-hidden={!open}\n\t\t\t\tinert={!open || undefined}\n\t\t\t\ttabIndex={open ? -1 : undefined}\n\t\t\t>\n\t\t\t\t{inner}\n\t\t\t</aside>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tref={overlayRootRef}\n\t\t\tclassName={cn(\"absolute inset-0\", OVERLAY_LAYER, !open && \"pointer-events-none\")}\n\t\t>\n\t\t\t{onDismiss ? (\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\ttabIndex={open ? 0 : -1}\n\t\t\t\t\taria-label={dismissLabel}\n\t\t\t\t\taria-hidden={!open}\n\t\t\t\t\tdata-state={open ? \"open\" : \"closed\"}\n\t\t\t\t\tclassName={cn(dialogOverlayClass(\"absolute\"), !open && \"opacity-0\")}\n\t\t\t\t\tonClick={open ? onDismiss : undefined}\n\t\t\t\t/>\n\t\t\t) : (\n\t\t\t\t<div\n\t\t\t\t\taria-hidden\n\t\t\t\t\tdata-state={open ? \"open\" : \"closed\"}\n\t\t\t\t\tclassName={cn(dialogOverlayClass(\"absolute\"), !open && \"opacity-0\")}\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t<div\n\t\t\t\tref={setPanel}\n\t\t\t\trole=\"dialog\"\n\t\t\t\taria-modal={open ? true : undefined}\n\t\t\t\taria-label={ariaLabel}\n\t\t\t\tclassName={panelClass}\n\t\t\t\tstyle={panelStyle}\n\t\t\t\taria-hidden={!open}\n\t\t\t\tinert={!open || undefined}\n\t\t\t\ttabIndex={open ? -1 : undefined}\n\t\t\t>\n\t\t\t\t{inner}\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAKA,IAAM,IACL,qKACK,IAAe;AAErB,SAAS,EAAU,GAA0B;CAI5C,OAHK,IAGE,CAAC,GAAG,EAAK,iBAA8B,CAAS,CAAC,CAAC,CAAC,QAAQ,MAAS;EAO1E,IANI,EAAK,QAAQ,mBAAmB,KAGhC,EAAK,WAAW,KAGhB,OAAO,iBAAiB,CAAI,CAAC,CAAC,eAAe,UAChD,OAAO;EAER,KAAK,IAAI,IAA8B,GAAM,GAAS,IAAU,EAAQ,eACvE,IAAI,OAAO,iBAAiB,CAAO,CAAC,CAAC,YAAY,QAChD,OAAO;EAGT,OAAO;CACR,CAAC,IAlBO,CAAC;AAmBV;AAyCA,SAAgB,EAAS,EAAE,cAAW,eAA2B;CAChE,OACC,kBAAC,OAAD;EAAK,WAAW,EAAG,gEAAgE,CAAS;EAC1F;CACG,CAAA;AAEP;AAEA,SAAgB,EAAK,EACpB,SACA,UAAO,QACP,WAAQ,+BACR,cACA,kBAAe,WACf,cACA,aACA,cAAc,KACD;CACb,IAAM,IAAU,MAAS,WACnB,IAAW,EAA2B,IAAI,GAC1C,IAAiB,EAAuB,IAAI,GAC5C,KAAY,MAA6B;EAC9C,EAAS,UAAU;CACpB,GACM,IAAU,EAAO,CAAC,KAAW,CAAI,GACjC,IAAgB,EAA2B,IAAI;CAwBrD,AAtBA,QAAgB;EACf,IAAI,GAAM;GACT,IAAI,EAAQ,SACX;GAED,EAAc,UACb,SAAS,yBAAyB,cAAc,SAAS,gBAAgB;GAC1E,IAAM,IAAQ,OAAO,iBAAiB;IACrC,IAAM,I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AU,EAAG,iCAAiC,CAAa,IAAI,kCAC/D,GACA,CACD,GACM,IAAa,EAAE,OAAO,IAAO,IAAQ,EAAE,GACvC,IACL,kBAAC,OAAD;EACC,WAAU;EACV,OAAO,EAAE,SAAM;EAEd;CACG,CAAA;CAmBN,OAhBK,IAiBJ,kBAAC,OAAD;EACC,KAAK;EACL,WAAW,EAAG,oBAAoB,GAAe,CAAC,KAAQ,qBAAqB;EAFhF,UAAA,CAIE,IACA,kBAAC,UAAD;GACC,MAAK;GACL,UAAU,IAAO,IAAI;GACrB,cAAY;GACZ,eAAa,CAAC;GACd,cAAY,IAAO,SAAS;GAC5B,WAAW,EAAG,EAAmB,UAAU,GAAG,CAAC,KAAQ,WAAW;GAClE,SAAS,IAAO,IAAY,KAAA;EAC5B,CAAA,IAED,kBAAC,OAAD;GACC,eAAA;GACA,cAAY,IAAO,SAAS;GAC5B,WAAW,EAAG,EAAmB,UAAU,GAAG,CAAC,KAAQ,WAAW;EAClE,CAAA,GAEF,kBAAC,OAAD;GACC,KAAK;GACL,MAAK;GACL,cAAY,IAAO,KAAO,KAAA;GAC1B,cAAY;GACZ,WAAW;GACX,OAAO;GACP,eAAa,CAAC;GACd,OAAO,CAAC,KAAQ,KAAA;GAChB,UAAU,IAAO,KAAK,KAAA;GAErB,UAAA;EACG,CAAA,CACD;MAjDJ,kBAAC,SAAD;EACC,KAAK;EACL,WAAW;EACX,OAAO;EACP,cAAY;EACZ,eAAa,CAAC;EACd,OAAO,CAAC,KAAQ,KAAA;EAChB,UAAU,IAAO,KAAK,KAAA;EAErB,UAAA;CACK,CAAA;AAyCV"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type FabPlacement = "absolute" | "fixed";
|
|
3
|
+
export interface FabProps {
|
|
4
|
+
/**
|
|
5
|
+
* When true, the launcher hides so a dock can take the corner.
|
|
6
|
+
* @default false
|
|
7
|
+
*/
|
|
8
|
+
open?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Viewport pin versus containing frame.
|
|
11
|
+
* @default "fixed"
|
|
12
|
+
*/
|
|
13
|
+
placement?: FabPlacement;
|
|
14
|
+
/**
|
|
15
|
+
* Accessible name.
|
|
16
|
+
*/
|
|
17
|
+
"aria-label": string;
|
|
18
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
className?: string;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const Fab: React.ForwardRefExoticComponent<FabProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../utils/cn.js";
|
|
3
|
+
import { OVERLAY_LAYER as t, OVERLAY_MOTION as n } from "./overlay.js";
|
|
4
|
+
import { Button as r } from "./button.js";
|
|
5
|
+
import * as i from "react";
|
|
6
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/fab.tsx
|
|
8
|
+
var o = i.forwardRef(({ open: i = !1, placement: o = "fixed", className: s, children: c, onClick: l, "aria-label": u, disabled: d }, f) => /* @__PURE__ */ a(r, {
|
|
9
|
+
ref: f,
|
|
10
|
+
size: "icon",
|
|
11
|
+
"aria-label": u,
|
|
12
|
+
"aria-expanded": i,
|
|
13
|
+
"aria-hidden": i || void 0,
|
|
14
|
+
tabIndex: i ? -1 : 0,
|
|
15
|
+
inert: i || void 0,
|
|
16
|
+
disabled: d,
|
|
17
|
+
onClick: i ? void 0 : l,
|
|
18
|
+
className: e(o === "absolute" ? "absolute" : "fixed", "right-4 bottom-4 h-16 w-16 rounded-full shadow-lg", t, "transition-[transform,opacity] duration-300 ease-in-out", n, i ? "pointer-events-none scale-75 opacity-0" : "hover:scale-[1.03] active:scale-[0.98]", s),
|
|
19
|
+
children: c
|
|
20
|
+
}));
|
|
21
|
+
o.displayName = "Fab";
|
|
22
|
+
//#endregion
|
|
23
|
+
export { o as Fab };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=fab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fab.js","names":[],"sources":["../../src/components/fab.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { Button } from \"./button\";\nimport { OVERLAY_LAYER, OVERLAY_MOTION } from \"./overlay\";\n\nexport type FabPlacement = \"absolute\" | \"fixed\";\n\nexport interface FabProps {\n\t/**\n\t * When true, the launcher hides so a dock can take the corner.\n\t * @default false\n\t */\n\topen?: boolean;\n\t/**\n\t * Viewport pin versus containing frame.\n\t * @default \"fixed\"\n\t */\n\tplacement?: FabPlacement;\n\t/**\n\t * Accessible name.\n\t */\n\t\"aria-label\": string;\n\tonClick?: React.MouseEventHandler<HTMLButtonElement>;\n\tchildren?: React.ReactNode;\n\tclassName?: string;\n\tdisabled?: boolean;\n}\n\nexport const Fab = React.forwardRef<HTMLButtonElement, FabProps>(\n\t(\n\t\t{\n\t\t\topen = false,\n\t\t\tplacement = \"fixed\",\n\t\t\tclassName,\n\t\t\tchildren,\n\t\t\tonClick,\n\t\t\t\"aria-label\": ariaLabel,\n\t\t\tdisabled,\n\t\t},\n\t\tref,\n\t) => (\n\t\t<Button\n\t\t\tref={ref}\n\t\t\tsize=\"icon\"\n\t\t\taria-label={ariaLabel}\n\t\t\taria-expanded={open}\n\t\t\taria-hidden={open || undefined}\n\t\t\ttabIndex={open ? -1 : 0}\n\t\t\tinert={open || undefined}\n\t\t\tdisabled={disabled}\n\t\t\tonClick={open ? undefined : onClick}\n\t\t\tclassName={cn(\n\t\t\t\tplacement === \"absolute\" ? \"absolute\" : \"fixed\",\n\t\t\t\t\"right-4 bottom-4 h-16 w-16 rounded-full shadow-lg\",\n\t\t\t\tOVERLAY_LAYER,\n\t\t\t\t\"transition-[transform,opacity] duration-300 ease-in-out\",\n\t\t\t\tOVERLAY_MOTION,\n\t\t\t\topen ? \"pointer-events-none scale-75 opacity-0\" : \"hover:scale-[1.03] active:scale-[0.98]\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t>\n\t\t\t{children}\n\t\t</Button>\n\t),\n);\nFab.displayName = \"Fab\";\n"],"mappings":";;;;;;;AA4BA,IAAa,IAAM,EAAM,YAEvB,EACC,UAAO,IACP,eAAY,SACZ,cACA,aACA,YACA,cAAc,GACd,eAED,MAEA,kBAAC,GAAD;CACM;CACL,MAAK;CACL,cAAY;CACZ,iBAAe;CACf,eAAa,KAAQ,KAAA;CACrB,UAAU,IAAO,KAAK;CACtB,OAAO,KAAQ,KAAA;CACL;CACV,SAAS,IAAO,KAAA,IAAY;CAC5B,WAAW,EACV,MAAc,aAAa,aAAa,SACxC,qDACA,GACA,2DACA,GACA,IAAO,2CAA2C,0CAClD,CACD;CAEC;AACM,CAAA,CAEV;AACA,EAAI,cAAc"}
|
|
@@ -11,13 +11,25 @@ export type LayerCardProps = Omit<HTMLAttributes<HTMLDivElement>, "className"> &
|
|
|
11
11
|
* Additional classes for the card root.
|
|
12
12
|
*/
|
|
13
13
|
className?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Draw a hairline ring. Default grouping is luminance only.
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
outlined?: boolean;
|
|
14
19
|
/**
|
|
15
20
|
* Inner spacing for unstructured card content.
|
|
16
|
-
* @default "
|
|
21
|
+
* @default "md"
|
|
17
22
|
*/
|
|
18
23
|
padding?: LayerCardPadding;
|
|
19
24
|
};
|
|
20
25
|
export type LayerCardSectionProps = HTMLAttributes<HTMLDivElement>;
|
|
26
|
+
export type LayerCardWellProps = LayerCardSectionProps & {
|
|
27
|
+
/**
|
|
28
|
+
* Draw a hairline ring on a nested well.
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
outlined?: boolean;
|
|
32
|
+
};
|
|
21
33
|
export type LayerCardLoadingProps = Omit<HTMLAttributes<HTMLDivElement>, "aria-label"> & {
|
|
22
34
|
/**
|
|
23
35
|
* Accessible label announced for the loading state.
|
|
@@ -40,10 +52,11 @@ export type LayerCardEmptyProps = Omit<HTMLAttributes<HTMLDivElement>, "title">
|
|
|
40
52
|
*/
|
|
41
53
|
icon?: ReactNode;
|
|
42
54
|
};
|
|
43
|
-
declare function LayerCardSecondary({ className, ...props }: LayerCardSectionProps): import("react").JSX.Element;
|
|
44
|
-
declare function LayerCardPrimary({ className, ...props }: LayerCardSectionProps): import("react").JSX.Element;
|
|
45
55
|
declare function LayerCardHeader({ className, ...props }: LayerCardSectionProps): import("react").JSX.Element;
|
|
46
56
|
declare function LayerCardBody({ className, ...props }: LayerCardSectionProps): import("react").JSX.Element;
|
|
57
|
+
declare function LayerCardWell({ className, outlined, ...props }: LayerCardWellProps): import("react").JSX.Element;
|
|
58
|
+
declare function LayerCardPrimary(props: LayerCardWellProps): import("react").JSX.Element;
|
|
59
|
+
declare function LayerCardSecondary(props: LayerCardSectionProps): import("react").JSX.Element;
|
|
47
60
|
declare function LayerCardFooter({ className, ...props }: LayerCardSectionProps): import("react").JSX.Element;
|
|
48
61
|
declare function LayerCardLoading({ label, className, ...props }: LayerCardLoadingProps): import("react").JSX.Element;
|
|
49
62
|
declare function LayerCardEmpty({ title, description, icon, className, ...props }: LayerCardEmptyProps): import("react").JSX.Element;
|
|
@@ -52,9 +65,14 @@ export declare const LayerCard: import("react").ForwardRefExoticComponent<Omit<H
|
|
|
52
65
|
* Additional classes for the card root.
|
|
53
66
|
*/
|
|
54
67
|
className?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Draw a hairline ring. Default grouping is luminance only.
|
|
70
|
+
* @default false
|
|
71
|
+
*/
|
|
72
|
+
outlined?: boolean;
|
|
55
73
|
/**
|
|
56
74
|
* Inner spacing for unstructured card content.
|
|
57
|
-
* @default "
|
|
75
|
+
* @default "md"
|
|
58
76
|
*/
|
|
59
77
|
padding?: LayerCardPadding;
|
|
60
78
|
} & import("react").RefAttributes<HTMLDivElement>> & {
|
|
@@ -62,6 +80,7 @@ export declare const LayerCard: import("react").ForwardRefExoticComponent<Omit<H
|
|
|
62
80
|
Secondary: typeof LayerCardSecondary;
|
|
63
81
|
Header: typeof LayerCardHeader;
|
|
64
82
|
Body: typeof LayerCardBody;
|
|
83
|
+
Well: typeof LayerCardWell;
|
|
65
84
|
Footer: typeof LayerCardFooter;
|
|
66
85
|
Loading: typeof LayerCardLoading;
|
|
67
86
|
Empty: typeof LayerCardEmpty;
|
|
@@ -2,85 +2,108 @@
|
|
|
2
2
|
import { cn as e } from "../utils/cn.js";
|
|
3
3
|
import { Empty as t } from "./empty.js";
|
|
4
4
|
import { SkeletonLine as n } from "./skeleton-line.js";
|
|
5
|
-
import { Children as r, Fragment as i,
|
|
6
|
-
import { jsx as
|
|
5
|
+
import { Children as r, Fragment as i, cloneElement as a, forwardRef as o, isValidElement as s } from "react";
|
|
6
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
7
|
//#region src/components/layer-card.tsx
|
|
8
|
-
var
|
|
8
|
+
var u = "overflow-hidden rounded-basalt-lg text-basalt-foreground", d = {
|
|
9
9
|
none: "",
|
|
10
10
|
sm: "p-3",
|
|
11
11
|
md: "p-4",
|
|
12
12
|
lg: "p-6"
|
|
13
13
|
};
|
|
14
|
-
function
|
|
15
|
-
return
|
|
14
|
+
function f(e) {
|
|
15
|
+
return s(e);
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
children:
|
|
22
|
-
}));
|
|
23
|
-
h.displayName = "LayerCard";
|
|
24
|
-
function g({ className: t, ...n }) {
|
|
25
|
-
return /* @__PURE__ */ s("div", {
|
|
26
|
-
className: e(d, t),
|
|
27
|
-
...n
|
|
28
|
-
});
|
|
17
|
+
function p(e) {
|
|
18
|
+
return e.type;
|
|
19
|
+
}
|
|
20
|
+
function m(e, t) {
|
|
21
|
+
return r.toArray(e).some((e) => f(e) ? t(p(e)) ? !0 : p(e) === i && m(e.props.children, t) : !1);
|
|
29
22
|
}
|
|
30
|
-
|
|
23
|
+
function h(t, n) {
|
|
24
|
+
return n ? r.map(t, (t) => {
|
|
25
|
+
if (!f(t)) return t;
|
|
26
|
+
if (p(t) === i) return a(t, { children: h(t.props.children, n) });
|
|
27
|
+
if (p(t) === _ || p(t) === x) {
|
|
28
|
+
let n = t;
|
|
29
|
+
return a(n, { className: e(n.props.className, "border-b border-basalt-border") });
|
|
30
|
+
}
|
|
31
|
+
return t;
|
|
32
|
+
}) : t;
|
|
33
|
+
}
|
|
34
|
+
var g = o(({ className: t, children: n, outlined: r = !1, padding: i = "md", ...a }, o) => {
|
|
35
|
+
let s = m(n, (e) => T.has(e)), l = m(n, (e) => e === y || e === b), f = m(n, (e) => e === v) && !l;
|
|
36
|
+
return /* @__PURE__ */ c("div", {
|
|
37
|
+
ref: o,
|
|
38
|
+
"data-basalt-surface": "",
|
|
39
|
+
className: e(u, s ? "flex w-full flex-col" : d[i], r && "ring-1 ring-basalt-border/40", t),
|
|
40
|
+
...a,
|
|
41
|
+
children: h(n, f)
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
g.displayName = "LayerCard";
|
|
31
45
|
function _({ className: t, ...n }) {
|
|
32
|
-
return /* @__PURE__ */
|
|
33
|
-
className: e(
|
|
46
|
+
return /* @__PURE__ */ c("div", {
|
|
47
|
+
className: e("flex min-w-0 items-start justify-between gap-4 px-4 py-3 text-basalt-muted-foreground", t),
|
|
34
48
|
...n
|
|
35
49
|
});
|
|
36
50
|
}
|
|
37
|
-
_.displayName = "LayerCard.
|
|
51
|
+
_.displayName = "LayerCard.Header";
|
|
38
52
|
function v({ className: t, ...n }) {
|
|
39
|
-
return /* @__PURE__ */
|
|
40
|
-
className: e("
|
|
53
|
+
return /* @__PURE__ */ c("div", {
|
|
54
|
+
className: e("min-w-0 p-4", t),
|
|
41
55
|
...n
|
|
42
56
|
});
|
|
43
57
|
}
|
|
44
|
-
v.displayName = "LayerCard.
|
|
45
|
-
function y({ className: t,
|
|
46
|
-
return /* @__PURE__ */
|
|
47
|
-
|
|
48
|
-
|
|
58
|
+
v.displayName = "LayerCard.Body";
|
|
59
|
+
function y({ className: t, outlined: n = !1, ...r }) {
|
|
60
|
+
return /* @__PURE__ */ c("div", {
|
|
61
|
+
"data-basalt-surface": "",
|
|
62
|
+
className: e("min-w-0 p-4", n && "ring-1 ring-basalt-border/40", t),
|
|
63
|
+
...r
|
|
49
64
|
});
|
|
50
65
|
}
|
|
51
|
-
y.displayName = "LayerCard.
|
|
52
|
-
function b(
|
|
53
|
-
return /* @__PURE__ */
|
|
66
|
+
y.displayName = "LayerCard.Well";
|
|
67
|
+
function b(e) {
|
|
68
|
+
return /* @__PURE__ */ c(y, { ...e });
|
|
69
|
+
}
|
|
70
|
+
b.displayName = "LayerCard.Primary";
|
|
71
|
+
function x(e) {
|
|
72
|
+
return /* @__PURE__ */ c(_, { ...e });
|
|
73
|
+
}
|
|
74
|
+
x.displayName = "LayerCard.Secondary";
|
|
75
|
+
function S({ className: t, ...n }) {
|
|
76
|
+
return /* @__PURE__ */ c("div", {
|
|
54
77
|
className: e("flex flex-wrap items-center justify-end gap-2 border-t border-basalt-border px-4 py-3", t),
|
|
55
78
|
...n
|
|
56
79
|
});
|
|
57
80
|
}
|
|
58
|
-
|
|
59
|
-
function
|
|
60
|
-
return /* @__PURE__ */
|
|
81
|
+
S.displayName = "LayerCard.Footer";
|
|
82
|
+
function C({ label: t = "Loading", className: r, ...i }) {
|
|
83
|
+
return /* @__PURE__ */ l("div", {
|
|
61
84
|
role: "status",
|
|
62
85
|
"aria-label": t,
|
|
63
86
|
className: e("space-y-3 p-4", r),
|
|
64
87
|
...i,
|
|
65
88
|
children: [
|
|
66
|
-
/* @__PURE__ */
|
|
89
|
+
/* @__PURE__ */ c(n, {
|
|
67
90
|
minWidth: 100,
|
|
68
91
|
maxWidth: 100
|
|
69
92
|
}),
|
|
70
|
-
/* @__PURE__ */
|
|
93
|
+
/* @__PURE__ */ c(n, {
|
|
71
94
|
minWidth: 72,
|
|
72
95
|
maxWidth: 72
|
|
73
96
|
}),
|
|
74
|
-
/* @__PURE__ */
|
|
97
|
+
/* @__PURE__ */ c(n, {
|
|
75
98
|
minWidth: 88,
|
|
76
99
|
maxWidth: 88
|
|
77
100
|
})
|
|
78
101
|
]
|
|
79
102
|
});
|
|
80
103
|
}
|
|
81
|
-
|
|
82
|
-
function
|
|
83
|
-
return /* @__PURE__ */
|
|
104
|
+
C.displayName = "LayerCard.Loading";
|
|
105
|
+
function w({ title: n = "No content", description: r, icon: i, className: a, ...o }) {
|
|
106
|
+
return /* @__PURE__ */ c(t, {
|
|
84
107
|
title: n,
|
|
85
108
|
description: r,
|
|
86
109
|
icon: i,
|
|
@@ -88,17 +111,27 @@ function S({ title: n = "No content", description: r, icon: i, className: a, ...
|
|
|
88
111
|
...o
|
|
89
112
|
});
|
|
90
113
|
}
|
|
91
|
-
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
114
|
+
w.displayName = "LayerCard.Empty";
|
|
115
|
+
var T = /* @__PURE__ */ new Set([
|
|
116
|
+
_,
|
|
117
|
+
v,
|
|
118
|
+
y,
|
|
119
|
+
S,
|
|
120
|
+
C,
|
|
121
|
+
w,
|
|
122
|
+
b,
|
|
123
|
+
x
|
|
124
|
+
]), E = Object.assign(g, {
|
|
125
|
+
Primary: b,
|
|
126
|
+
Secondary: x,
|
|
127
|
+
Header: _,
|
|
128
|
+
Body: v,
|
|
129
|
+
Well: y,
|
|
130
|
+
Footer: S,
|
|
131
|
+
Loading: C,
|
|
132
|
+
Empty: w
|
|
100
133
|
});
|
|
101
134
|
//#endregion
|
|
102
|
-
export {
|
|
135
|
+
export { E as LayerCard };
|
|
103
136
|
|
|
104
137
|
//# sourceMappingURL=layer-card.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layer-card.js","names":[],"sources":["../../src/components/layer-card.tsx"],"sourcesContent":["import {\n\tChildren,\n\tFragment,\n\tforwardRef,\n\ttype HTMLAttributes,\n\tisValidElement,\n\ttype ReactElement,\n\ttype ReactNode,\n} from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { Empty } from \"./empty\";\nimport { SkeletonLine } from \"./skeleton-line\";\n\nconst
|
|
1
|
+
{"version":3,"file":"layer-card.js","names":[],"sources":["../../src/components/layer-card.tsx"],"sourcesContent":["import {\n\tChildren,\n\tcloneElement,\n\tFragment,\n\tforwardRef,\n\ttype HTMLAttributes,\n\tisValidElement,\n\ttype ReactElement,\n\ttype ReactNode,\n} from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { Empty } from \"./empty\";\nimport { SkeletonLine } from \"./skeleton-line\";\n\nconst ROOT_CLASSES = \"overflow-hidden rounded-basalt-lg text-basalt-foreground\";\nconst PADDING_CLASSES = {\n\tnone: \"\",\n\tsm: \"p-3\",\n\tmd: \"p-4\",\n\tlg: \"p-6\",\n} as const;\n\nexport type LayerCardPadding = keyof typeof PADDING_CLASSES;\n\nexport type LayerCardProps = Omit<HTMLAttributes<HTMLDivElement>, \"className\"> & {\n\t/**\n\t * Additional classes for the card root.\n\t */\n\tclassName?: string;\n\t/**\n\t * Draw a hairline ring. Default grouping is luminance only.\n\t * @default false\n\t */\n\toutlined?: boolean;\n\t/**\n\t * Inner spacing for unstructured card content.\n\t * @default \"md\"\n\t */\n\tpadding?: LayerCardPadding;\n};\nexport type LayerCardSectionProps = HTMLAttributes<HTMLDivElement>;\nexport type LayerCardWellProps = LayerCardSectionProps & {\n\t/**\n\t * Draw a hairline ring on a nested well.\n\t * @default false\n\t */\n\toutlined?: boolean;\n};\nexport type LayerCardLoadingProps = Omit<HTMLAttributes<HTMLDivElement>, \"aria-label\"> & {\n\t/**\n\t * Accessible label announced for the loading state.\n\t * @default \"Loading\"\n\t */\n\tlabel?: string;\n};\nexport type LayerCardEmptyProps = Omit<HTMLAttributes<HTMLDivElement>, \"title\"> & {\n\t/**\n\t * Empty-state heading.\n\t * @default \"No content\"\n\t */\n\ttitle?: string;\n\t/**\n\t * Supporting empty-state text.\n\t */\n\tdescription?: string;\n\t/**\n\t * Optional empty-state icon.\n\t */\n\ticon?: ReactNode;\n};\n\nfunction isElement(child: ReactNode): child is ReactElement<{ children?: ReactNode }> {\n\treturn isValidElement(child);\n}\n\nfunction childType(child: ReactElement): unknown {\n\treturn child.type;\n}\n\nfunction hasSlot(children: ReactNode, match: (type: unknown) => boolean): boolean {\n\treturn Children.toArray(children).some((child) => {\n\t\tif (!isElement(child)) {\n\t\t\treturn false;\n\t\t}\n\t\tif (match(childType(child))) {\n\t\t\treturn true;\n\t\t}\n\t\tif (childType(child) === Fragment) {\n\t\t\treturn hasSlot(child.props.children, match);\n\t\t}\n\t\treturn false;\n\t});\n}\n\nfunction decorateHeaders(children: ReactNode, divided: boolean): ReactNode {\n\tif (!divided) {\n\t\treturn children;\n\t}\n\treturn Children.map(children, (child) => {\n\t\tif (!isElement(child)) {\n\t\t\treturn child;\n\t\t}\n\t\tif (childType(child) === Fragment) {\n\t\t\treturn cloneElement(child, {\n\t\t\t\tchildren: decorateHeaders(child.props.children, divided),\n\t\t\t});\n\t\t}\n\t\tif (childType(child) === LayerCardHeader || childType(child) === LayerCardSecondary) {\n\t\t\tconst typed = child as ReactElement<{ className?: string }>;\n\t\t\treturn cloneElement(typed, {\n\t\t\t\tclassName: cn(typed.props.className, \"border-b border-basalt-border\"),\n\t\t\t});\n\t\t}\n\t\treturn child;\n\t});\n}\n\nconst LayerCardRoot = forwardRef<HTMLDivElement, LayerCardProps>(\n\t({ className, children, outlined = false, padding = \"md\", ...props }, ref) => {\n\t\tconst structured = hasSlot(children, (type) => STRUCTURED_TYPES.has(type));\n\t\tconst hasWell = hasSlot(\n\t\t\tchildren,\n\t\t\t(type) => type === LayerCardWell || type === LayerCardPrimary,\n\t\t);\n\t\tconst hasBody = hasSlot(children, (type) => type === LayerCardBody);\n\t\tconst headerDivided = hasBody && !hasWell;\n\t\treturn (\n\t\t\t<div\n\t\t\t\tref={ref}\n\t\t\t\tdata-basalt-surface=\"\"\n\t\t\t\tclassName={cn(\n\t\t\t\t\tROOT_CLASSES,\n\t\t\t\t\tstructured ? \"flex w-full flex-col\" : PADDING_CLASSES[padding],\n\t\t\t\t\toutlined && \"ring-1 ring-basalt-border/40\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t{decorateHeaders(children, headerDivided)}\n\t\t\t</div>\n\t\t);\n\t},\n);\nLayerCardRoot.displayName = \"LayerCard\";\n\nfunction LayerCardHeader({ className, ...props }: LayerCardSectionProps) {\n\treturn (\n\t\t<div\n\t\t\tclassName={cn(\n\t\t\t\t\"flex min-w-0 items-start justify-between gap-4 px-4 py-3 text-basalt-muted-foreground\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\nLayerCardHeader.displayName = \"LayerCard.Header\";\n\nfunction LayerCardBody({ className, ...props }: LayerCardSectionProps) {\n\treturn <div className={cn(\"min-w-0 p-4\", className)} {...props} />;\n}\nLayerCardBody.displayName = \"LayerCard.Body\";\n\nfunction LayerCardWell({ className, outlined = false, ...props }: LayerCardWellProps) {\n\treturn (\n\t\t<div\n\t\t\tdata-basalt-surface=\"\"\n\t\t\tclassName={cn(\"min-w-0 p-4\", outlined && \"ring-1 ring-basalt-border/40\", className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\nLayerCardWell.displayName = \"LayerCard.Well\";\n\nfunction LayerCardPrimary(props: LayerCardWellProps) {\n\treturn <LayerCardWell {...props} />;\n}\nLayerCardPrimary.displayName = \"LayerCard.Primary\";\n\nfunction LayerCardSecondary(props: LayerCardSectionProps) {\n\treturn <LayerCardHeader {...props} />;\n}\nLayerCardSecondary.displayName = \"LayerCard.Secondary\";\n\nfunction LayerCardFooter({ className, ...props }: LayerCardSectionProps) {\n\treturn (\n\t\t<div\n\t\t\tclassName={cn(\n\t\t\t\t\"flex flex-wrap items-center justify-end gap-2 border-t border-basalt-border px-4 py-3\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\nLayerCardFooter.displayName = \"LayerCard.Footer\";\n\nfunction LayerCardLoading({ label = \"Loading\", className, ...props }: LayerCardLoadingProps) {\n\treturn (\n\t\t<div role=\"status\" aria-label={label} className={cn(\"space-y-3 p-4\", className)} {...props}>\n\t\t\t<SkeletonLine minWidth={100} maxWidth={100} />\n\t\t\t<SkeletonLine minWidth={72} maxWidth={72} />\n\t\t\t<SkeletonLine minWidth={88} maxWidth={88} />\n\t\t</div>\n\t);\n}\nLayerCardLoading.displayName = \"LayerCard.Loading\";\n\nfunction LayerCardEmpty({\n\ttitle = \"No content\",\n\tdescription,\n\ticon,\n\tclassName,\n\t...props\n}: LayerCardEmptyProps) {\n\treturn (\n\t\t<Empty\n\t\t\ttitle={title}\n\t\t\tdescription={description}\n\t\t\ticon={icon}\n\t\t\tclassName={cn(\"p-8\", className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\nLayerCardEmpty.displayName = \"LayerCard.Empty\";\n\nconst STRUCTURED_TYPES = new Set<unknown>([\n\tLayerCardHeader,\n\tLayerCardBody,\n\tLayerCardWell,\n\tLayerCardFooter,\n\tLayerCardLoading,\n\tLayerCardEmpty,\n\tLayerCardPrimary,\n\tLayerCardSecondary,\n]);\n\nexport const LayerCard = Object.assign(LayerCardRoot, {\n\tPrimary: LayerCardPrimary,\n\tSecondary: LayerCardSecondary,\n\tHeader: LayerCardHeader,\n\tBody: LayerCardBody,\n\tWell: LayerCardWell,\n\tFooter: LayerCardFooter,\n\tLoading: LayerCardLoading,\n\tEmpty: LayerCardEmpty,\n});\n"],"mappings":";;;;;;;AAcA,IAAM,IAAe,4DACf,IAAkB;CACvB,MAAM;CACN,IAAI;CACJ,IAAI;CACJ,IAAI;AACL;AAmDA,SAAS,EAAU,GAAmE;CACrF,OAAO,EAAe,CAAK;AA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OAAO,CAAS;EAC9B,GAAI;CACJ,CAAA;AAEH;AACA,EAAe,cAAc;AAE7B,IAAM,oBAAmB,IAAI,IAAa;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC,GAEY,IAAY,OAAO,OAAO,GAAe;CACrD,SAAS;CACT,WAAW;CACX,QAAQ;CACR,MAAM;CACN,MAAM;CACN,QAAQ;CACR,SAAS;CACT,OAAO;AACR,CAAC"}
|
|
@@ -9,11 +9,11 @@ export interface PageHeaderProps {
|
|
|
9
9
|
title: React.ReactNode;
|
|
10
10
|
/** Supporting text below the title. */
|
|
11
11
|
description?: React.ReactNode;
|
|
12
|
-
/** A short label above the title. */
|
|
13
|
-
eyebrow?: React.ReactNode;
|
|
14
12
|
/** Trail of parent pages. */
|
|
15
13
|
breadcrumbs?: readonly PageHeaderBreadcrumb[];
|
|
16
|
-
/**
|
|
14
|
+
/** Right-side title-row actions. Put the create button last. */
|
|
17
15
|
actions?: React.ReactNode;
|
|
16
|
+
/** Own-row filters. Keep short filters in actions. */
|
|
17
|
+
filters?: React.ReactNode;
|
|
18
18
|
}
|
|
19
|
-
export declare function PageHeader({ actions, breadcrumbs, description,
|
|
19
|
+
export declare function PageHeader({ actions, breadcrumbs, description, filters, title }: PageHeaderProps): React.JSX.Element;
|
|
@@ -3,38 +3,35 @@ import { Breadcrumbs as e } from "./breadcrumbs.js";
|
|
|
3
3
|
import * as t from "react";
|
|
4
4
|
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
5
|
//#region src/components/page-header.tsx
|
|
6
|
-
function i({ actions: i, breadcrumbs: a, description: o,
|
|
6
|
+
function i({ actions: i, breadcrumbs: a, description: o, filters: s, title: c }) {
|
|
7
7
|
let l = t.useId();
|
|
8
8
|
return /* @__PURE__ */ r("header", {
|
|
9
9
|
"aria-labelledby": l,
|
|
10
|
-
className: "
|
|
11
|
-
children: [
|
|
12
|
-
items: [...a],
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
children: [
|
|
19
|
-
s ? /* @__PURE__ */ n("p", {
|
|
20
|
-
className: "text-xs font-medium text-basalt-muted-foreground",
|
|
21
|
-
children: s
|
|
22
|
-
}) : null,
|
|
23
|
-
/* @__PURE__ */ n("h1", {
|
|
10
|
+
className: "space-y-4",
|
|
11
|
+
children: [
|
|
12
|
+
a && a.length > 0 ? /* @__PURE__ */ n(e, { items: [...a] }) : null,
|
|
13
|
+
/* @__PURE__ */ r("div", {
|
|
14
|
+
className: "flex flex-col gap-4 md:flex-row md:items-start md:justify-between",
|
|
15
|
+
children: [/* @__PURE__ */ r("div", {
|
|
16
|
+
className: "min-w-0 flex-1 space-y-1",
|
|
17
|
+
children: [/* @__PURE__ */ n("h1", {
|
|
24
18
|
id: l,
|
|
25
19
|
className: "text-2xl font-semibold tracking-tight text-basalt-foreground",
|
|
26
20
|
children: c
|
|
27
|
-
}),
|
|
28
|
-
o ? /* @__PURE__ */ n("p", {
|
|
21
|
+
}), o ? /* @__PURE__ */ n("p", {
|
|
29
22
|
className: "text-sm text-basalt-muted-foreground",
|
|
30
23
|
children: o
|
|
31
|
-
}) : null
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
}) : null]
|
|
25
|
+
}), i ? /* @__PURE__ */ n("div", {
|
|
26
|
+
className: "flex flex-wrap items-center justify-end gap-2",
|
|
27
|
+
children: i
|
|
28
|
+
}) : null]
|
|
29
|
+
}),
|
|
30
|
+
s ? /* @__PURE__ */ n("div", {
|
|
34
31
|
className: "flex flex-wrap items-center gap-2",
|
|
35
|
-
children:
|
|
36
|
-
}) : null
|
|
37
|
-
|
|
32
|
+
children: s
|
|
33
|
+
}) : null
|
|
34
|
+
]
|
|
38
35
|
});
|
|
39
36
|
}
|
|
40
37
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-header.js","names":[],"sources":["../../src/components/page-header.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Breadcrumbs } from \"./breadcrumbs\";\n\nexport interface PageHeaderBreadcrumb {\n\thref?: string;\n\tlabel: React.ReactNode;\n\ticon?: React.ReactNode;\n}\n\nexport interface PageHeaderProps {\n\t/** The page title, rendered as the only heading. */\n\ttitle: React.ReactNode;\n\t/** Supporting text below the title. */\n\tdescription?: React.ReactNode;\n\t/**
|
|
1
|
+
{"version":3,"file":"page-header.js","names":[],"sources":["../../src/components/page-header.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Breadcrumbs } from \"./breadcrumbs\";\n\nexport interface PageHeaderBreadcrumb {\n\thref?: string;\n\tlabel: React.ReactNode;\n\ticon?: React.ReactNode;\n}\n\nexport interface PageHeaderProps {\n\t/** The page title, rendered as the only heading. */\n\ttitle: React.ReactNode;\n\t/** Supporting text below the title. */\n\tdescription?: React.ReactNode;\n\t/** Trail of parent pages. */\n\tbreadcrumbs?: readonly PageHeaderBreadcrumb[];\n\t/** Right-side title-row actions. Put the create button last. */\n\tactions?: React.ReactNode;\n\t/** Own-row filters. Keep short filters in actions. */\n\tfilters?: React.ReactNode;\n}\n\nexport function PageHeader({ actions, breadcrumbs, description, filters, title }: PageHeaderProps) {\n\tconst titleId = React.useId();\n\n\treturn (\n\t\t// biome-ignore lint/a11y/useAriaPropsSupportedByRole: the title heading names this header\n\t\t<header aria-labelledby={titleId} className=\"space-y-4\">\n\t\t\t{breadcrumbs && breadcrumbs.length > 0 ? <Breadcrumbs items={[...breadcrumbs]} /> : null}\n\t\t\t<div className=\"flex flex-col gap-4 md:flex-row md:items-start md:justify-between\">\n\t\t\t\t<div className=\"min-w-0 flex-1 space-y-1\">\n\t\t\t\t\t<h1 id={titleId} className=\"text-2xl font-semibold tracking-tight text-basalt-foreground\">\n\t\t\t\t\t\t{title}\n\t\t\t\t\t</h1>\n\t\t\t\t\t{description ? (\n\t\t\t\t\t\t<p className=\"text-sm text-basalt-muted-foreground\">{description}</p>\n\t\t\t\t\t) : null}\n\t\t\t\t</div>\n\t\t\t\t{actions ? (\n\t\t\t\t\t<div className=\"flex flex-wrap items-center justify-end gap-2\">{actions}</div>\n\t\t\t\t) : null}\n\t\t\t</div>\n\t\t\t{filters ? <div className=\"flex flex-wrap items-center gap-2\">{filters}</div> : null}\n\t\t</header>\n\t);\n}\n"],"mappings":";;;;;AAsBA,SAAgB,EAAW,EAAE,YAAS,gBAAa,gBAAa,YAAS,YAA0B;CAClG,IAAM,IAAU,EAAM,MAAM;CAE5B,OAEC,kBAAC,UAAD;EAAQ,mBAAiB;EAAS,WAAU;EAA5C,UAAA;GACE,KAAe,EAAY,SAAS,IAAI,kBAAC,GAAD,EAAa,OAAO,CAAC,GAAG,CAAW,EAAI,CAAA,IAAI;GACpF,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACC,kBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACC,kBAAC,MAAD;MAAI,IAAI;MAAS,WAAU;MACzB,UAAA;KACE,CAAA,GACH,IACA,kBAAC,KAAD;MAAG,WAAU;MAAwC,UAAA;KAAe,CAAA,IACjE,IACA;IACJ,CAAA,GAAA,IACA,kBAAC,OAAD;KAAK,WAAU;KAAiD,UAAA;IAAa,CAAA,IAC1E,IACA;;GACJ,IAAU,kBAAC,OAAD;IAAK,WAAU;IAAqC,UAAA;GAAa,CAAA,IAAI;EACzE;;AAEV"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
export type SectionRuleProps = Omit<HTMLAttributes<HTMLElement>, "title"> & {
|
|
3
|
+
/** Section title shown before the dashed rule. */
|
|
4
|
+
title: ReactNode;
|
|
5
|
+
/** Info tooltip beside the title. */
|
|
6
|
+
hint?: ReactNode;
|
|
7
|
+
/** Actions on the right of the dashed rule. */
|
|
8
|
+
actions?: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
export declare function SectionRule({ title, hint, actions, className, children, ...props }: SectionRuleProps): import("react").JSX.Element;
|