@particle-academy/react-fancy 6.3.0 → 6.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +1 -0
  3. package/dist/CodeBlock.types-BFMFB4X2.d.cts +53 -0
  4. package/dist/CodeBlock.types-BFMFB4X2.d.ts +53 -0
  5. package/dist/autocomplete.cjs +5 -5
  6. package/dist/autocomplete.js +4 -4
  7. package/dist/card.cjs +8 -8
  8. package/dist/card.js +2 -2
  9. package/dist/chat-thread.cjs +5 -4
  10. package/dist/chat-thread.js +3 -2
  11. package/dist/{chunk-K7JOZQRK.cjs → chunk-2G6TIX5Q.cjs} +4 -4
  12. package/dist/{chunk-K7JOZQRK.cjs.map → chunk-2G6TIX5Q.cjs.map} +1 -1
  13. package/dist/{chunk-TH4JZAMK.js → chunk-5TP642UT.js} +4 -4
  14. package/dist/{chunk-TH4JZAMK.js.map → chunk-5TP642UT.js.map} +1 -1
  15. package/dist/chunk-6BB32POL.js +29 -0
  16. package/dist/chunk-6BB32POL.js.map +1 -0
  17. package/dist/{chunk-XIA2UAVO.js → chunk-6GVOW3UL.js} +4 -4
  18. package/dist/{chunk-XIA2UAVO.js.map → chunk-6GVOW3UL.js.map} +1 -1
  19. package/dist/{chunk-4JT2QANA.cjs → chunk-6H7ZN23X.cjs} +3 -3
  20. package/dist/{chunk-4JT2QANA.cjs.map → chunk-6H7ZN23X.cjs.map} +1 -1
  21. package/dist/chunk-7ZCNZUZK.cjs +183 -0
  22. package/dist/chunk-7ZCNZUZK.cjs.map +1 -0
  23. package/dist/{chunk-MP55W37V.cjs → chunk-BYO5RUDE.cjs} +4 -4
  24. package/dist/{chunk-MP55W37V.cjs.map → chunk-BYO5RUDE.cjs.map} +1 -1
  25. package/dist/{chunk-2XO6EYZ7.js → chunk-EENHSMV2.js} +3 -3
  26. package/dist/{chunk-2XO6EYZ7.js.map → chunk-EENHSMV2.js.map} +1 -1
  27. package/dist/{chunk-7JLKOVHX.cjs → chunk-HLI6RB5V.cjs} +4 -4
  28. package/dist/{chunk-7JLKOVHX.cjs.map → chunk-HLI6RB5V.cjs.map} +1 -1
  29. package/dist/chunk-HZUKPYR3.cjs +31 -0
  30. package/dist/chunk-HZUKPYR3.cjs.map +1 -0
  31. package/dist/chunk-J2BWXCES.js +177 -0
  32. package/dist/chunk-J2BWXCES.js.map +1 -0
  33. package/dist/{chunk-CKO2KCUN.cjs → chunk-MPCZUZ4O.cjs} +7 -175
  34. package/dist/chunk-MPCZUZ4O.cjs.map +1 -0
  35. package/dist/{chunk-FBWUXSKH.js → chunk-PVHZO4T3.js} +6 -24
  36. package/dist/chunk-PVHZO4T3.js.map +1 -0
  37. package/dist/{chunk-3AA2KGZG.js → chunk-QF2FODTG.js} +5 -173
  38. package/dist/chunk-QF2FODTG.js.map +1 -0
  39. package/dist/chunk-QH4YSG7C.cjs +205 -0
  40. package/dist/chunk-QH4YSG7C.cjs.map +1 -0
  41. package/dist/{chunk-SRICSNL4.cjs → chunk-RE4BYTVM.cjs} +12 -12
  42. package/dist/{chunk-SRICSNL4.cjs.map → chunk-RE4BYTVM.cjs.map} +1 -1
  43. package/dist/{chunk-A6NYZ3F5.js → chunk-RWU2MFUL.js} +4 -4
  44. package/dist/{chunk-A6NYZ3F5.js.map → chunk-RWU2MFUL.js.map} +1 -1
  45. package/dist/{chunk-G7227RTY.cjs → chunk-TQL3QW7F.cjs} +5 -23
  46. package/dist/chunk-TQL3QW7F.cjs.map +1 -0
  47. package/dist/{chunk-23KQF47X.js → chunk-UUEAFG6V.js} +3 -3
  48. package/dist/{chunk-23KQF47X.js.map → chunk-UUEAFG6V.js.map} +1 -1
  49. package/dist/chunk-YRI6OFLY.js +203 -0
  50. package/dist/chunk-YRI6OFLY.js.map +1 -0
  51. package/dist/{chunk-WF6AYHOS.js → chunk-YYNUTUJO.js} +4 -4
  52. package/dist/{chunk-WF6AYHOS.js.map → chunk-YYNUTUJO.js.map} +1 -1
  53. package/dist/{chunk-KSSTFLV2.cjs → chunk-Z44A7NPD.cjs} +6 -6
  54. package/dist/{chunk-KSSTFLV2.cjs.map → chunk-Z44A7NPD.cjs.map} +1 -1
  55. package/dist/code-block.cjs +19 -0
  56. package/dist/code-block.cjs.map +1 -0
  57. package/dist/code-block.d.cts +13 -0
  58. package/dist/code-block.d.ts +13 -0
  59. package/dist/code-block.js +10 -0
  60. package/dist/code-block.js.map +1 -0
  61. package/dist/code-view.cjs +3 -2
  62. package/dist/code-view.d.cts +9 -6
  63. package/dist/code-view.d.ts +9 -6
  64. package/dist/code-view.js +2 -1
  65. package/dist/composer.cjs +1 -1
  66. package/dist/composer.js +1 -1
  67. package/dist/content-renderer.cjs +5 -4
  68. package/dist/content-renderer.js +2 -1
  69. package/dist/dropdown.cjs +1 -1
  70. package/dist/dropdown.js +1 -1
  71. package/dist/editor.cjs +10 -8
  72. package/dist/editor.js +8 -6
  73. package/dist/index.cjs +114 -107
  74. package/dist/index.cjs.map +1 -1
  75. package/dist/index.d.cts +2 -0
  76. package/dist/index.d.ts +2 -0
  77. package/dist/index.js +28 -25
  78. package/dist/index.js.map +1 -1
  79. package/dist/input.cjs +3 -3
  80. package/dist/input.js +3 -3
  81. package/dist/inputs.cjs +10 -10
  82. package/dist/inputs.js +5 -5
  83. package/dist/json-editor.cjs +16 -16
  84. package/dist/json-editor.js +5 -5
  85. package/dist/magic-wand.cjs +2 -2
  86. package/dist/magic-wand.js +2 -2
  87. package/dist/mobile-menu.cjs +1 -1
  88. package/dist/mobile-menu.js +1 -1
  89. package/dist/paste-pills.cjs +1 -1
  90. package/dist/paste-pills.js +1 -1
  91. package/dist/popover.cjs +1 -1
  92. package/dist/popover.js +1 -1
  93. package/dist/prompt-input.cjs +1 -1
  94. package/dist/prompt-input.js +1 -1
  95. package/dist/reason-tag.cjs +1 -1
  96. package/dist/reason-tag.js +1 -1
  97. package/dist/select.cjs +5 -5
  98. package/dist/select.js +4 -4
  99. package/dist/sidebar.cjs +1 -1
  100. package/dist/sidebar.js +1 -1
  101. package/dist/tooltip.cjs +1 -1
  102. package/dist/tooltip.js +1 -1
  103. package/docs/CodeBlock.md +101 -0
  104. package/docs/CodeView.md +21 -5
  105. package/package.json +12 -2
  106. package/dist/chunk-3AA2KGZG.js.map +0 -1
  107. package/dist/chunk-CKO2KCUN.cjs.map +0 -1
  108. package/dist/chunk-FBWUXSKH.js.map +0 -1
  109. package/dist/chunk-G7227RTY.cjs.map +0 -1
@@ -0,0 +1,183 @@
1
+ 'use strict';
2
+
3
+ var chunkNZHVDWOM_cjs = require('./chunk-NZHVDWOM.cjs');
4
+ var react = require('react');
5
+ var reactDom = require('react-dom');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ var FEEDBACK_MS = 2e3;
9
+ var WRITE_TIMEOUT_MS = 5e3;
10
+ var CopyContext = react.createContext(null);
11
+ async function defaultClipboardWriter(payload) {
12
+ const clip = typeof navigator !== "undefined" ? navigator.clipboard : void 0;
13
+ if (!clip) throw new Error("Clipboard API unavailable");
14
+ const Item = globalThis.ClipboardItem;
15
+ if (payload.html && Item && typeof clip.write === "function") {
16
+ try {
17
+ await clip.write([
18
+ new Item({
19
+ "text/html": new Blob([payload.html], { type: "text/html" }),
20
+ "text/plain": new Blob([payload.text], { type: "text/plain" })
21
+ })
22
+ ]);
23
+ return;
24
+ } catch {
25
+ }
26
+ }
27
+ if (typeof clip.writeText !== "function") throw new Error("Clipboard writeText unavailable");
28
+ await clip.writeText(payload.text);
29
+ }
30
+ async function runWriter(writer, payload) {
31
+ let timer;
32
+ try {
33
+ const result = await Promise.race([
34
+ Promise.resolve().then(() => writer(payload)),
35
+ new Promise((resolve) => {
36
+ timer = setTimeout(() => resolve(false), WRITE_TIMEOUT_MS);
37
+ })
38
+ ]);
39
+ return result !== false;
40
+ } catch {
41
+ return false;
42
+ } finally {
43
+ if (timer) clearTimeout(timer);
44
+ }
45
+ }
46
+ function codeText(pre, fromMarkdown) {
47
+ const text = (pre.querySelector("code") ?? pre).textContent ?? "";
48
+ return fromMarkdown && text.endsWith("\n") ? text.slice(0, -1) : text;
49
+ }
50
+ function tableTsv(table) {
51
+ const rows = [];
52
+ for (const tr of Array.from(table.querySelectorAll("tr"))) {
53
+ if (tr.closest("table") !== table) continue;
54
+ const cells = Array.from(tr.children).filter((c) => c.tagName === "TD" || c.tagName === "TH");
55
+ rows.push(cells.map((c) => cellText(c)).join(" "));
56
+ }
57
+ return rows.join("\n");
58
+ }
59
+ function cellText(cell) {
60
+ const clone = cell.cloneNode(true);
61
+ for (const br of Array.from(clone.querySelectorAll("br"))) br.replaceWith(" ");
62
+ return (clone.textContent ?? "").replace(/[\t\r\n]+/g, " ").replace(/ {2,}/g, " ").trim();
63
+ }
64
+ function HtmlChunk({
65
+ html,
66
+ fromMarkdown,
67
+ tail = false
68
+ }) {
69
+ const ref = react.useRef(null);
70
+ const ctx = react.useContext(CopyContext);
71
+ const [targets, setTargets] = react.useState([]);
72
+ const code = ctx?.code ?? false;
73
+ const table = ctx?.table ?? false;
74
+ const holdLastCode = tail && (ctx?.holdTailCode ?? false);
75
+ const inner = react.useMemo(() => ({ __html: html }), [html]);
76
+ react.useLayoutEffect(() => {
77
+ const root = ref.current;
78
+ if (!root || !code && !table) {
79
+ setTargets([]);
80
+ return;
81
+ }
82
+ const found = [];
83
+ const selector = [code && "pre", table && "table"].filter(Boolean).join(",");
84
+ const inProgress = holdLastCode ? Array.from(root.querySelectorAll("pre")).pop() : void 0;
85
+ for (const el of Array.from(root.querySelectorAll(selector))) {
86
+ if (el === inProgress) continue;
87
+ const kind = el.tagName === "PRE" ? "code" : "table";
88
+ const wrapper = document.createElement("div");
89
+ wrapper.setAttribute("data-react-fancy-content-copy-block", kind);
90
+ wrapper.className = kind === "code" ? "group relative" : "group relative flex flex-col";
91
+ wrapper.style.position = "relative";
92
+ const host = document.createElement("div");
93
+ host.setAttribute("data-react-fancy-content-copy-host", "");
94
+ host.className = kind === "code" ? "absolute right-2 top-2 z-10" : "flex justify-end";
95
+ el.replaceWith(wrapper);
96
+ if (kind === "table") wrapper.append(host, el);
97
+ else wrapper.append(el, host);
98
+ found.push({ kind, el, host });
99
+ }
100
+ setTargets(found);
101
+ return () => {
102
+ for (const t of found) {
103
+ const wrapper = t.host.parentElement;
104
+ if (wrapper?.parentNode) wrapper.replaceWith(t.el);
105
+ }
106
+ };
107
+ }, [html, code, table, holdLastCode]);
108
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
109
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref, dangerouslySetInnerHTML: inner }),
110
+ targets.map(
111
+ (t, i) => reactDom.createPortal(
112
+ /* @__PURE__ */ jsxRuntime.jsx(CopyButton, { kind: t.kind, target: t.el, fromMarkdown }),
113
+ t.host,
114
+ `${i}`
115
+ )
116
+ )
117
+ ] });
118
+ }
119
+ function CopyButton({
120
+ kind,
121
+ target,
122
+ fromMarkdown
123
+ }) {
124
+ const ctx = react.useContext(CopyContext);
125
+ const [state, setState] = react.useState("idle");
126
+ const timer = react.useRef(void 0);
127
+ const btn = react.useRef(null);
128
+ react.useEffect(() => () => clearTimeout(timer.current), []);
129
+ const onClick = react.useCallback(async () => {
130
+ if (!ctx || !btn.current) return;
131
+ const text = kind === "code" ? codeText(target, fromMarkdown) : tableTsv(target);
132
+ const ok = await ctx.copy({ kind, text, html: target.outerHTML }, btn.current);
133
+ setState(ok ? "copied" : "failed");
134
+ clearTimeout(timer.current);
135
+ timer.current = setTimeout(() => setState("idle"), FEEDBACK_MS);
136
+ }, [ctx, kind, target, fromMarkdown]);
137
+ const idleLabel = kind === "code" ? "Copy code" : "Copy table";
138
+ const label = state === "copied" ? "Copied" : state === "failed" ? "Copy failed" : idleLabel;
139
+ return /* @__PURE__ */ jsxRuntime.jsx(
140
+ chunkNZHVDWOM_cjs.Button,
141
+ {
142
+ ref: btn,
143
+ type: "button",
144
+ size: "xs",
145
+ variant: "ghost",
146
+ icon: state === "copied" ? "check" : state === "failed" ? "x" : "copy",
147
+ "aria-label": label,
148
+ title: label,
149
+ "data-react-fancy-content-copy": kind,
150
+ "data-copy-state": state,
151
+ onClick,
152
+ className: kind === "code" ? "text-zinc-300 hover:bg-zinc-800 hover:text-white opacity-70 group-hover:opacity-100 focus-visible:opacity-100" : "opacity-70 group-hover:opacity-100 focus-visible:opacity-100"
153
+ }
154
+ );
155
+ }
156
+ function useCopyPipeline({
157
+ writer,
158
+ onCopy,
159
+ rootRef,
160
+ announce
161
+ }) {
162
+ const latest = react.useRef({ writer, onCopy, announce });
163
+ latest.current = { writer, onCopy, announce };
164
+ return react.useCallback(
165
+ async (payload, button) => {
166
+ const { writer: w, onCopy: report, announce: say } = latest.current;
167
+ const ok = await runWriter(w ?? defaultClipboardWriter, payload);
168
+ say(ok ? "Copied" : "Copy failed");
169
+ const all = rootRef.current ? Array.from(rootRef.current.querySelectorAll("[data-react-fancy-content-copy]")) : [];
170
+ report?.({ ...payload, index: all.indexOf(button), ok });
171
+ return ok;
172
+ },
173
+ [rootRef]
174
+ );
175
+ }
176
+
177
+ exports.CopyContext = CopyContext;
178
+ exports.HtmlChunk = HtmlChunk;
179
+ exports.defaultClipboardWriter = defaultClipboardWriter;
180
+ exports.runWriter = runWriter;
181
+ exports.useCopyPipeline = useCopyPipeline;
182
+ //# sourceMappingURL=chunk-7ZCNZUZK.cjs.map
183
+ //# sourceMappingURL=chunk-7ZCNZUZK.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ContentRenderer/copy.tsx"],"names":["createContext","useRef","useContext","useState","useMemo","useLayoutEffect","jsxs","Fragment","jsx","createPortal","useEffect","useCallback","Button"],"mappings":";;;;;;;AAqBA,IAAM,WAAA,GAAc,GAAA;AAEpB,IAAM,gBAAA,GAAmB,GAAA;AAclB,IAAM,WAAA,GAAcA,oBAAuC,IAAI;AAOtE,eAAsB,uBAAuB,OAAA,EAAiD;AAC5F,EAAA,MAAM,IAAA,GAAO,O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EAAQ,MAAA,EAAQ,UAAU,CAAA;AAClD,EAAA,MAAA,CAAO,OAAA,GAAU,EAAE,MAAA,EAAQ,MAAA,EAAQ,QAAA,EAAS;AAE5C,EAAA,OAAOU,iBAAA;AAAA,IACL,OAAO,SAAkC,MAAA,KAAwB;AAC/D,MAAA,MAAM,EAAE,QAAQ,CAAA,EAAG,MAAA,EAAQ,QAAQ,QAAA,EAAU,GAAA,KAAQ,MAAA,CAAO,OAAA;AAC5D,MAAA,MAAM,EAAA,GAAK,MAAM,SAAA,CAAU,CAAA,IAAK,wBAAwB,OAAO,CAAA;AAC/D,MAAA,GAAA,CAAI,EAAA,GAAK,WAAW,aAAa,CAAA;AACjC,MAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,OAAA,GAChB,KAAA,CAAM,IAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,gBAAA,CAAiB,iCAAiC,CAAC,CAAA,GAC9E,EAAC;AACL,MAAA,MAAA,GAAS,EAAE,GAAG,OAAA,EAAS,KAAA,EAAO,IAAI,OAAA,CAAQ,MAAM,CAAA,EAAG,EAAA,EAAI,CAAA;AACvD,MAAA,OAAO,EAAA;AAAA,IACT,CAAA;AAAA,IACA,CAAC,OAAO;AAAA,GACV;AACF","file":"chunk-7ZCNZUZK.cjs","sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type RefObject,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Button } from \"../Button/Button\";\nimport type {\n ContentClipboardPayload,\n ContentClipboardWriter,\n ContentCopyEvent,\n ContentCopyKind,\n} from \"./ContentRenderer.types\";\n\n/** How long the check icon stays after a copy. */\nconst FEEDBACK_MS = 2000;\n/** A clipboard write that never settles is a silent failure; give up after this. */\nconst WRITE_TIMEOUT_MS = 5000;\n\nexport interface CopyContextValue {\n code: boolean;\n table: boolean;\n /** Write, announce, and report one copy. Resolves to whether it worked. */\n copy: (payload: ContentClipboardPayload, button: HTMLElement) => Promise<boolean>;\n /**\n * Progressive streaming closed an open code fence: the last code block of\n * the tail chunk is still arriving and gets no copy button until it closes.\n */\n holdTailCode?: boolean;\n}\n\nexport const CopyContext = createContext<CopyContextValue | null>(null);\n\n/**\n * Default clipboard writer: text/html + text/plain via `ClipboardItem` where\n * the browser has it, else (or if that write rejects) plain `writeText`.\n * Throws when nothing could be written, so the caller can say so.\n */\nexport async function defaultClipboardWriter(payload: ContentClipboardPayload): Promise<void> {\n const clip = typeof navigator !== \"undefined\" ? navigator.clipboard : undefined;\n if (!clip) throw new Error(\"Clipboard API unavailable\");\n\n const Item = (globalThis as { ClipboardItem?: typeof ClipboardItem }).ClipboardItem;\n if (payload.html && Item && typeof clip.write === \"function\") {\n try {\n await clip.write([\n new Item({\n \"text/html\": new Blob([payload.html], { type: \"text/html\" }),\n \"text/plain\": new Blob([payload.text], { type: \"text/plain\" }),\n }),\n ]);\n return;\n } catch {\n // Rich write refused (permissions, unsupported type): fall back to text.\n }\n }\n if (typeof clip.writeText !== \"function\") throw new Error(\"Clipboard writeText unavailable\");\n await clip.writeText(payload.text);\n}\n\n/** Run a writer, treating a throw, a rejection, `false`, or a hang as failure. */\nexport async function runWriter(\n writer: ContentClipboardWriter,\n payload: ContentClipboardPayload,\n): Promise<boolean> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n const result = await Promise.race([\n Promise.resolve().then(() => writer(payload)),\n new Promise<false>((resolve) => {\n timer = setTimeout(() => resolve(false), WRITE_TIMEOUT_MS);\n }),\n ]);\n return result !== false;\n } catch {\n return false;\n } finally {\n if (timer) clearTimeout(timer);\n }\n}\n\n/** Code exactly as written: the `<code>` text, minus the newline marked appends. */\nexport function codeText(pre: HTMLElement, fromMarkdown: boolean): string {\n const text = (pre.querySelector(\"code\") ?? pre).textContent ?? \"\";\n return fromMarkdown && text.endsWith(\"\\n\") ? text.slice(0, -1) : text;\n}\n\n/** A table as TSV: tab between cells, newline between rows, no trailing newline. */\nexport function tableTsv(table: HTMLTableElement): string {\n const rows: string[] = [];\n for (const tr of Array.from(table.querySelectorAll(\"tr\"))) {\n // Only this table's own cells, not those of a table nested in a cell.\n if (tr.closest(\"table\") !== table) continue;\n const cells = Array.from(tr.children).filter((c) => c.tagName === \"TD\" || c.tagName === \"TH\");\n rows.push(cells.map((c) => cellText(c)).join(\"\\t\"));\n }\n return rows.join(\"\\n\");\n}\n\nfunction cellText(cell: Element): string {\n const clone = cell.cloneNode(true) as Element;\n for (const br of Array.from(clone.querySelectorAll(\"br\"))) br.replaceWith(\" \");\n return (clone.textContent ?? \"\").replace(/[\\t\\r\\n]+/g, \" \").replace(/ {2,}/g, \" \").trim();\n}\n\ninterface Target {\n kind: ContentCopyKind;\n el: HTMLElement;\n host: HTMLElement;\n}\n\n/**\n * Sanitised HTML rendered with `dangerouslySetInnerHTML`, plus a react-fancy\n * copy `Button` portalled next to every `<pre>` and `<table>` in it.\n *\n * Each block is wrapped in a `data-react-fancy-content-copy-block` element and\n * the button lives beside the block, never inside it, so the button's own text\n * can never end up in what is copied.\n */\nexport function HtmlChunk({\n html,\n fromMarkdown,\n tail = false,\n}: {\n html: string;\n fromMarkdown: boolean;\n /** This chunk is the last thing rendered, so it holds any block still arriving. */\n tail?: boolean;\n}) {\n const ref = useRef<HTMLDivElement>(null);\n const ctx = useContext(CopyContext);\n const [targets, setTargets] = useState<Target[]>([]);\n const code = ctx?.code ?? false;\n const table = ctx?.table ?? false;\n const holdLastCode = tail && (ctx?.holdTailCode ?? false);\n // React 19 re-assigns innerHTML whenever this prop is a NEW object, even\n // with the same string, which would wipe the wrappers on every re-render\n // (including the one that mounts the buttons). One object per string.\n const inner = useMemo(() => ({ __html: html }), [html]);\n\n useLayoutEffect(() => {\n const root = ref.current;\n if (!root || (!code && !table)) {\n setTargets([]);\n return;\n }\n const found: Target[] = [];\n const selector = [code && \"pre\", table && \"table\"].filter(Boolean).join(\",\");\n const inProgress = holdLastCode ? Array.from(root.querySelectorAll(\"pre\")).pop() : undefined;\n for (const el of Array.from(root.querySelectorAll<HTMLElement>(selector))) {\n if (el === inProgress) continue;\n const kind: ContentCopyKind = el.tagName === \"PRE\" ? \"code\" : \"table\";\n const wrapper = document.createElement(\"div\");\n wrapper.setAttribute(\"data-react-fancy-content-copy-block\", kind);\n wrapper.className = kind === \"code\" ? \"group relative\" : \"group relative flex flex-col\";\n // Inline too: the code button is absolute, and a host whose Tailwind\n // never generated `relative` would let it escape the block (genie#1290).\n wrapper.style.position = \"relative\";\n const host = document.createElement(\"div\");\n host.setAttribute(\"data-react-fancy-content-copy-host\", \"\");\n host.className =\n kind === \"code\" ? \"absolute right-2 top-2 z-10\" : \"flex justify-end\";\n el.replaceWith(wrapper);\n if (kind === \"table\") wrapper.append(host, el);\n else wrapper.append(el, host);\n found.push({ kind, el, host });\n }\n setTargets(found);\n return () => {\n for (const t of found) {\n const wrapper = t.host.parentElement;\n if (wrapper?.parentNode) wrapper.replaceWith(t.el);\n }\n };\n }, [html, code, table, holdLastCode]);\n\n return (\n <>\n <div ref={ref} dangerouslySetInnerHTML={inner} />\n {targets.map((t, i) =>\n createPortal(\n <CopyButton kind={t.kind} target={t.el} fromMarkdown={fromMarkdown} />,\n t.host,\n `${i}`,\n ),\n )}\n </>\n );\n}\n\ntype CopyState = \"idle\" | \"copied\" | \"failed\";\n\nfunction CopyButton({\n kind,\n target,\n fromMarkdown,\n}: {\n kind: ContentCopyKind;\n target: HTMLElement;\n fromMarkdown: boolean;\n}) {\n const ctx = useContext(CopyContext);\n const [state, setState] = useState<CopyState>(\"idle\");\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const btn = useRef<HTMLButtonElement>(null);\n\n useEffect(() => () => clearTimeout(timer.current), []);\n\n const onClick = useCallback(async () => {\n if (!ctx || !btn.current) return;\n const text =\n kind === \"code\" ? codeText(target, fromMarkdown) : tableTsv(target as HTMLTableElement);\n const ok = await ctx.copy({ kind, text, html: target.outerHTML }, btn.current);\n setState(ok ? \"copied\" : \"failed\");\n clearTimeout(timer.current);\n timer.current = setTimeout(() => setState(\"idle\"), FEEDBACK_MS);\n }, [ctx, kind, target, fromMarkdown]);\n\n const idleLabel = kind === \"code\" ? \"Copy code\" : \"Copy table\";\n const label = state === \"copied\" ? \"Copied\" : state === \"failed\" ? \"Copy failed\" : idleLabel;\n\n return (\n <Button\n ref={btn}\n type=\"button\"\n size=\"xs\"\n variant=\"ghost\"\n icon={state === \"copied\" ? \"check\" : state === \"failed\" ? \"x\" : \"copy\"}\n aria-label={label}\n title={label}\n data-react-fancy-content-copy={kind}\n data-copy-state={state}\n onClick={onClick}\n className={\n kind === \"code\"\n ? \"text-zinc-300 hover:bg-zinc-800 hover:text-white opacity-70 group-hover:opacity-100 focus-visible:opacity-100\"\n : \"opacity-70 group-hover:opacity-100 focus-visible:opacity-100\"\n }\n />\n );\n}\n\n/** Build the copy pipeline a ContentRenderer root shares with its chunks. */\nexport function useCopyPipeline({\n writer,\n onCopy,\n rootRef,\n announce,\n}: {\n writer: ContentClipboardWriter | undefined;\n onCopy: ((event: ContentCopyEvent) => void) | undefined;\n rootRef: RefObject<HTMLElement | null>;\n announce: (message: string) => void;\n}) {\n // Read the latest props at click time without re-creating the context.\n const latest = useRef({ writer, onCopy, announce });\n latest.current = { writer, onCopy, announce };\n\n return useCallback(\n async (payload: ContentClipboardPayload, button: HTMLElement) => {\n const { writer: w, onCopy: report, announce: say } = latest.current;\n const ok = await runWriter(w ?? defaultClipboardWriter, payload);\n say(ok ? \"Copied\" : \"Copy failed\");\n const all = rootRef.current\n ? Array.from(rootRef.current.querySelectorAll(\"[data-react-fancy-content-copy]\"))\n : [];\n report?.({ ...payload, index: all.indexOf(button), ok });\n return ok;\n },\n [rootRef],\n );\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ var chunk6V44RRSB_cjs = require('./chunk-6V44RRSB.cjs');
3
4
  var chunkJ2DI6RMR_cjs = require('./chunk-J2DI6RMR.cjs');
5
+ var chunkTI7D4QDM_cjs = require('./chunk-TI7D4QDM.cjs');
4
6
  var chunkKJ22KE56_cjs = require('./chunk-KJ22KE56.cjs');
5
7
  var chunkL3V3BYVS_cjs = require('./chunk-L3V3BYVS.cjs');
6
- var chunk6V44RRSB_cjs = require('./chunk-6V44RRSB.cjs');
7
- var chunkTI7D4QDM_cjs = require('./chunk-TI7D4QDM.cjs');
8
8
  var chunk57FQGQJK_cjs = require('./chunk-57FQGQJK.cjs');
9
9
  var chunkOUYC6EIL_cjs = require('./chunk-OUYC6EIL.cjs');
10
10
  var chunkSNHU2AI4_cjs = require('./chunk-SNHU2AI4.cjs');
@@ -199,5 +199,5 @@ function HighlightMatch({ text, query }) {
199
199
  Autocomplete.displayName = "Autocomplete";
200
200
 
201
201
  exports.Autocomplete = Autocomplete;
202
- //# sourceMappingURL=chunk-MP55W37V.cjs.map
203
- //# sourceMappingURL=chunk-MP55W37V.cjs.map
202
+ //# sourceMappingURL=chunk-BYO5RUDE.cjs.map
203
+ //# sourceMappingURL=chunk-BYO5RUDE.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Autocomplete/Autocomplete.tsx"],"names":["forwardRef","Autocomplete","useControllableState","useFieldMode","useInlineEdit","useState","useRef","useFloatingPosition","useCallback","useOutsideClick","useEscapeKey","useEffect","isImeComposing","jsx","cn","jsxs","Portal","Fragment"],"mappings":";;;;;;;;;;;;;;AAYO,IAAM,YAAA,GAAeA,gBAAA;AAAA,EAC1B,SAASC,aAAAA,CACP;AAAA,IACE,KAAA,EAAO,eAAA;AAAA,IACP,YAAA,GAAe,EAAA;AAAA,IACf,QAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAA,GAAU,KAAA;AAAA,IACV,YAAA,GAAe,mBAAA;AAAA,IACf,QAAA,GAAW,KAAA;AAAA,IACX,SAAA;AAAA,IACA;AAAA,KAEF,GAAA,EACA;AACA,IAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,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AAM,MAAM,IAAA,CAAK,WAAA,GAAc,OAAA,CAAQ,KAAA,CAAM,aAAa,CAAA;AAC1D,EAAA,IAAI,GAAA,KAAQ,EAAA,EAAI,uBAAOJ,cAAA,CAAAI,mBAAA,EAAA,EAAG,QAAA,EAAA,IAAA,EAAK,CAAA;AAE/B,EAAA,uBACEF,eAAA,CAAAE,mBAAA,EAAA,EACG,QAAA,EAAA;AAAA,IAAA,IAAA,CAAK,KAAA,CAAM,GAAG,GAAG,CAAA;AAAA,oBAClBJ,cAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,6CAAA,EACb,QAAA,EAAA,IAAA,CAAK,MAAM,GAAA,EAAK,GAAA,GAAM,KAAA,CAAM,MAAM,CAAA,EACrC,CAAA;AAAA,IACC,IAAA,CAAK,KAAA,CAAM,GAAA,GAAM,KAAA,CAAM,MAAM;AAAA,GAAA,EAChC,CAAA;AAEJ;AAEA,YAAA,CAAa,WAAA,GAAc,cAAA","file":"chunk-MP55W37V.cjs","sourcesContent":["import { forwardRef, useCallback, useEffect, useRef, useState } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { isImeComposing } from \"../../utils/ime\";\nimport { Portal } from \"../Portal\";\nimport { useControllableState } from \"../../hooks/use-controllable-state\";\nimport { useFloatingPosition } from \"../../hooks/use-floating-position\";\nimport { useOutsideClick } from \"../../hooks/use-outside-click\";\nimport { useEscapeKey } from \"../../hooks/use-escape-key\";\nimport { useFieldMode } from \"../inputs/mode/FieldMode.context\";\nimport { useInlineEdit } from \"../inputs/mode/useInlineEdit\";\nimport type { AutocompleteProps } from \"./Autocomplete.types\";\n\nexport const Autocomplete = forwardRef<HTMLInputElement, AutocompleteProps>(\n function Autocomplete(\n {\n value: controlledValue,\n defaultValue = \"\",\n onChange,\n onSearch,\n options,\n placeholder,\n loading = false,\n emptyMessage = \"No results found.\",\n disabled = false,\n className,\n mode,\n },\n ref,\n ) {\n const [value, setValue] = useControllableState(\n controlledValue,\n defaultValue,\n onChange,\n );\n const resolvedMode = useFieldMode(mode);\n const { showControl, interactive, enterEdit, exitEdit } = useInlineEdit(resolvedMode, disabled);\n const [query, setQuery] = useState(value);\n const [open, setOpen] = useState(false);\n const [activeIndex, setActiveIndex] = useState(-1);\n\n const anchorRef = useRef<HTMLInputElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n const position = useFloatingPosition(anchorRef, listRef, {\n placement: \"bottom-start\",\n offset: 4,\n enabled: open,\n });\n\n const close = useCallback(() => {\n setOpen(false);\n setActiveIndex(-1);\n }, []);\n\n useOutsideClick(wrapperRef, close, open);\n useEscapeKey(close, open);\n\n const filtered = options.filter((o) =>\n o.label.toLowerCase().includes(query.toLowerCase()),\n );\n\n const select = useCallback(\n (val: string) => {\n setValue(val);\n const opt = options.find((o) => o.value === val);\n setQuery(opt?.label ?? val);\n close();\n },\n [setValue, options, close],\n );\n\n useEffect(() => {\n onSearch?.(query);\n }, [query, onSearch]);\n\n const handleKeyDown = (e: React.KeyboardEvent) => {\n if (!open) {\n if (e.key === \"ArrowDown\") {\n setOpen(true);\n return;\n }\n return;\n }\n\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n setActiveIndex((i) => Math.min(i + 1, filtered.length - 1));\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n setActiveIndex((i) => Math.max(i - 1, 0));\n } else if (e.key === \"Enter\" && activeIndex >= 0 && !isImeComposing(e)) {\n e.preventDefault();\n const item = filtered[activeIndex];\n if (item && !item.disabled) select(item.value);\n }\n };\n\n if (!showControl) {\n const matched = options.find((o) => o.value === value);\n return (\n <div\n data-react-fancy-autocomplete=\"\"\n data-mode=\"view\"\n ref={wrapperRef}\n role={interactive ? \"button\" : undefined}\n tabIndex={interactive ? 0 : undefined}\n title={interactive ? \"Click to edit\" : undefined}\n onClick={interactive ? enterEdit : undefined}\n onKeyDown={\n interactive\n ? (e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n enterEdit();\n }\n }\n : undefined\n }\n className={cn(\n \"text-sm text-[color:var(--fancy-text,var(--color-zinc-900))] dark:text-[color:var(--fancy-text-dark,var(--color-zinc-100))]\",\n !value && \"text-[color:var(--fancy-text-faint,var(--color-zinc-400))] dark:text-[color:var(--fancy-text-faint-dark,var(--color-zinc-500))]\",\n interactive &&\n \"cursor-pointer rounded-md outline-none transition-colors hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] focus-visible:ring-2 focus-visible:ring-blue-500/40 dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))]\",\n className,\n )}\n >\n {matched?.label ?? value ?? \"—\"}\n </div>\n );\n }\n\n return (\n <div\n data-react-fancy-autocomplete=\"\"\n ref={wrapperRef}\n className={cn(\"relative\", className)}\n onBlur={(e) => {\n // Options live in a Portal; only exit when closed and focus left.\n if (interactive && !open && !e.currentTarget.contains(e.relatedTarget as Node)) {\n exitEdit();\n }\n }}\n >\n <input\n ref={(node) => {\n (anchorRef as React.MutableRefObject<HTMLInputElement | null>).current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLInputElement | null>).current = node;\n }}\n type=\"text\"\n value={query}\n onChange={(e) => {\n setQuery(e.target.value);\n setOpen(true);\n setActiveIndex(-1);\n }}\n onFocus={() => setOpen(true)}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n disabled={disabled}\n autoFocus={interactive}\n role=\"combobox\"\n aria-expanded={open}\n aria-autocomplete=\"list\"\n className=\"w-full rounded-lg border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-input,var(--color-white))] px-3 py-2 text-sm text-[color:var(--fancy-text,var(--color-zinc-900))] placeholder:text-[color:var(--fancy-text-faint,var(--color-zinc-400))] outline-none transition-[border-color,box-shadow] duration-150 focus:border-[color:var(--fancy-focus,var(--color-blue-500))] focus:ring-2 focus:ring-[color:var(--fancy-focus,var(--color-blue-500))]/40 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-input-dark,#1e1e24)] dark:text-[color:var(--fancy-text-dark,var(--color-zinc-100))] dark:placeholder:text-[color:var(--fancy-text-faint-dark,var(--color-zinc-500))] dark:focus:border-[color:var(--fancy-focus-dark,var(--color-blue-400))] dark:focus:ring-[color:var(--fancy-focus-dark,var(--color-blue-400))]/20\"\n />\n {open && (\n <Portal>\n <div\n ref={listRef}\n role=\"listbox\"\n className=\"fixed z-50 max-h-60 min-w-[8rem] overflow-y-auto rounded-xl border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] p-1 shadow-lg dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))] dark:shadow-zinc-950/50 fancy-scale-in\"\n style={{\n left: position.x,\n top: position.y,\n width: anchorRef.current?.offsetWidth,\n }}\n >\n {loading ? (\n <div className=\"px-3 py-2 text-sm text-zinc-400\">Loading...</div>\n ) : filtered.length === 0 ? (\n <div className=\"px-3 py-2 text-sm text-zinc-400\">\n {emptyMessage}\n </div>\n ) : (\n filtered.map((option, i) => (\n <button\n key={option.value}\n type=\"button\"\n role=\"option\"\n aria-selected={i === activeIndex}\n disabled={option.disabled}\n onClick={() => select(option.value)}\n className={cn(\n \"flex w-full items-center rounded-lg px-3 py-2 text-left text-sm text-zinc-700 transition-colors dark:text-zinc-200\",\n i === activeIndex\n ? \"bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] dark:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))]\"\n : \"hover:bg-[color:var(--fancy-surface-hover,var(--color-zinc-50))] dark:hover:bg-[color:var(--fancy-surface-hover-dark,color-mix(in_oklab,var(--color-zinc-800)_50%,transparent))]\",\n option.disabled && \"cursor-not-allowed opacity-50\",\n )}\n >\n <HighlightMatch text={option.label} query={query} />\n </button>\n ))\n )}\n </div>\n </Portal>\n )}\n </div>\n );\n },\n);\n\nfunction HighlightMatch({ text, query }: { text: string; query: string }) {\n if (!query) return <>{text}</>;\n\n const idx = text.toLowerCase().indexOf(query.toLowerCase());\n if (idx === -1) return <>{text}</>;\n\n return (\n <>\n {text.slice(0, idx)}\n <span className=\"font-semibold text-zinc-900 dark:text-white\">\n {text.slice(idx, idx + query.length)}\n </span>\n {text.slice(idx + query.length)}\n </>\n );\n}\n\nAutocomplete.displayName = \"Autocomplete\";\n"]}
1
+ {"version":3,"sources":["../src/components/Autocomplete/Autocomplete.tsx"],"names":["forwardRef","Autocomplete","useControllableState","useFieldMode","useInlineEdit","useState","useRef","useFloatingPosition","useCallback","useOutsideClick","useEscapeKey","useEffect","isImeComposing","jsx","cn","jsxs","Portal","Fragment"],"mappings":";;;;;;;;;;;;;;AAYO,IAAM,YAAA,GAAeA,gBAAA;AAAA,EAC1B,SAASC,aAAAA,CACP;AAAA,IACE,KAAA,EAAO,eAAA;AAAA,IACP,YAAA,GAAe,EAAA;AAAA,IACf,QAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAA;AAAA,IACA,WAAA;AAAA,IACA,OAAA,GAAU,KAAA;AAAA,IACV,YAAA,GAAe,mBAAA;AAAA,IACf,QAAA,GAAW,KAAA;AAAA,IACX,SAAA;AAAA,IACA;AAAA,KAEF,GAAA,EACA;AACA,IAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIC,sCAAA;AAAA,MACxB,eAAA;AAAA,MACA,YAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA,MAAM,YAAA,GAAeC,+BAAa,IAAI,CAAA;AACtC,IAAA,MAAM,EAAE,aAAa,WAAA,EAAa,SAAA,EAAW,UAAS,GAAIC,+BAAA,CAAc,cAAc,QAAQ,CAAA;AAC9F,IAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIC,eAAS,KAAK,CAAA;AACxC,IAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAIA,eAAS,KAAK,CAAA;AACtC,IAAA,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,IAAA,CAAK,MAAM,GAAA,EAAK,GAAA,GAAM,KAAA,CAAM,MAAM,CAAA,EACrC,CAAA;AAAA,IACC,IAAA,CAAK,KAAA,CAAM,GAAA,GAAM,KAAA,CAAM,MAAM;AAAA,GAAA,EAChC,CAAA;AAEJ;AAEA,YAAA,CAAa,WAAA,GAAc,cAAA","file":"chunk-BYO5RUDE.cjs","sourcesContent":["import { forwardRef, useCallback, useEffect, useRef, useState } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { isImeComposing } from \"../../utils/ime\";\nimport { Portal } from \"../Portal\";\nimport { useControllableState } from \"../../hooks/use-controllable-state\";\nimport { useFloatingPosition } from \"../../hooks/use-floating-position\";\nimport { useOutsideClick } from \"../../hooks/use-outside-click\";\nimport { useEscapeKey } from \"../../hooks/use-escape-key\";\nimport { useFieldMode } from \"../inputs/mode/FieldMode.context\";\nimport { useInlineEdit } from \"../inputs/mode/useInlineEdit\";\nimport type { AutocompleteProps } from \"./Autocomplete.types\";\n\nexport const Autocomplete = forwardRef<HTMLInputElement, AutocompleteProps>(\n function Autocomplete(\n {\n value: controlledValue,\n defaultValue = \"\",\n onChange,\n onSearch,\n options,\n placeholder,\n loading = false,\n emptyMessage = \"No results found.\",\n disabled = false,\n className,\n mode,\n },\n ref,\n ) {\n const [value, setValue] = useControllableState(\n controlledValue,\n defaultValue,\n onChange,\n );\n const resolvedMode = useFieldMode(mode);\n const { showControl, interactive, enterEdit, exitEdit } = useInlineEdit(resolvedMode, disabled);\n const [query, setQuery] = useState(value);\n const [open, setOpen] = useState(false);\n const [activeIndex, setActiveIndex] = useState(-1);\n\n const anchorRef = useRef<HTMLInputElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n const position = useFloatingPosition(anchorRef, listRef, {\n placement: \"bottom-start\",\n offset: 4,\n enabled: open,\n });\n\n const close = useCallback(() => {\n setOpen(false);\n setActiveIndex(-1);\n }, []);\n\n useOutsideClick(wrapperRef, close, open);\n useEscapeKey(close, open);\n\n const filtered = options.filter((o) =>\n o.label.toLowerCase().includes(query.toLowerCase()),\n );\n\n const select = useCallback(\n (val: string) => {\n setValue(val);\n const opt = options.find((o) => o.value === val);\n setQuery(opt?.label ?? val);\n close();\n },\n [setValue, options, close],\n );\n\n useEffect(() => {\n onSearch?.(query);\n }, [query, onSearch]);\n\n const handleKeyDown = (e: React.KeyboardEvent) => {\n if (!open) {\n if (e.key === \"ArrowDown\") {\n setOpen(true);\n return;\n }\n return;\n }\n\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n setActiveIndex((i) => Math.min(i + 1, filtered.length - 1));\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n setActiveIndex((i) => Math.max(i - 1, 0));\n } else if (e.key === \"Enter\" && activeIndex >= 0 && !isImeComposing(e)) {\n e.preventDefault();\n const item = filtered[activeIndex];\n if (item && !item.disabled) select(item.value);\n }\n };\n\n if (!showControl) {\n const matched = options.find((o) => o.value === value);\n return (\n <div\n data-react-fancy-autocomplete=\"\"\n data-mode=\"view\"\n ref={wrapperRef}\n role={interactive ? \"button\" : undefined}\n tabIndex={interactive ? 0 : undefined}\n title={interactive ? \"Click to edit\" : undefined}\n onClick={interactive ? enterEdit : undefined}\n onKeyDown={\n interactive\n ? (e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n enterEdit();\n }\n }\n : undefined\n }\n className={cn(\n \"text-sm text-[color:var(--fancy-text,var(--color-zinc-900))] dark:text-[color:var(--fancy-text-dark,var(--color-zinc-100))]\",\n !value && \"text-[color:var(--fancy-text-faint,var(--color-zinc-400))] dark:text-[color:var(--fancy-text-faint-dark,var(--color-zinc-500))]\",\n interactive &&\n \"cursor-pointer rounded-md outline-none transition-colors hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] focus-visible:ring-2 focus-visible:ring-blue-500/40 dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))]\",\n className,\n )}\n >\n {matched?.label ?? value ?? \"—\"}\n </div>\n );\n }\n\n return (\n <div\n data-react-fancy-autocomplete=\"\"\n ref={wrapperRef}\n className={cn(\"relative\", className)}\n onBlur={(e) => {\n // Options live in a Portal; only exit when closed and focus left.\n if (interactive && !open && !e.currentTarget.contains(e.relatedTarget as Node)) {\n exitEdit();\n }\n }}\n >\n <input\n ref={(node) => {\n (anchorRef as React.MutableRefObject<HTMLInputElement | null>).current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref) (ref as React.MutableRefObject<HTMLInputElement | null>).current = node;\n }}\n type=\"text\"\n value={query}\n onChange={(e) => {\n setQuery(e.target.value);\n setOpen(true);\n setActiveIndex(-1);\n }}\n onFocus={() => setOpen(true)}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n disabled={disabled}\n autoFocus={interactive}\n role=\"combobox\"\n aria-expanded={open}\n aria-autocomplete=\"list\"\n className=\"w-full rounded-lg border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-input,var(--color-white))] px-3 py-2 text-sm text-[color:var(--fancy-text,var(--color-zinc-900))] placeholder:text-[color:var(--fancy-text-faint,var(--color-zinc-400))] outline-none transition-[border-color,box-shadow] duration-150 focus:border-[color:var(--fancy-focus,var(--color-blue-500))] focus:ring-2 focus:ring-[color:var(--fancy-focus,var(--color-blue-500))]/40 dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-input-dark,#1e1e24)] dark:text-[color:var(--fancy-text-dark,var(--color-zinc-100))] dark:placeholder:text-[color:var(--fancy-text-faint-dark,var(--color-zinc-500))] dark:focus:border-[color:var(--fancy-focus-dark,var(--color-blue-400))] dark:focus:ring-[color:var(--fancy-focus-dark,var(--color-blue-400))]/20\"\n />\n {open && (\n <Portal>\n <div\n ref={listRef}\n role=\"listbox\"\n className=\"fixed z-50 max-h-60 min-w-[8rem] overflow-y-auto rounded-xl border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] p-1 shadow-lg dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))] dark:shadow-zinc-950/50 fancy-scale-in\"\n style={{\n left: position.x,\n top: position.y,\n width: anchorRef.current?.offsetWidth,\n }}\n >\n {loading ? (\n <div className=\"px-3 py-2 text-sm text-zinc-400\">Loading...</div>\n ) : filtered.length === 0 ? (\n <div className=\"px-3 py-2 text-sm text-zinc-400\">\n {emptyMessage}\n </div>\n ) : (\n filtered.map((option, i) => (\n <button\n key={option.value}\n type=\"button\"\n role=\"option\"\n aria-selected={i === activeIndex}\n disabled={option.disabled}\n onClick={() => select(option.value)}\n className={cn(\n \"flex w-full items-center rounded-lg px-3 py-2 text-left text-sm text-zinc-700 transition-colors dark:text-zinc-200\",\n i === activeIndex\n ? \"bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] dark:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))]\"\n : \"hover:bg-[color:var(--fancy-surface-hover,var(--color-zinc-50))] dark:hover:bg-[color:var(--fancy-surface-hover-dark,color-mix(in_oklab,var(--color-zinc-800)_50%,transparent))]\",\n option.disabled && \"cursor-not-allowed opacity-50\",\n )}\n >\n <HighlightMatch text={option.label} query={query} />\n </button>\n ))\n )}\n </div>\n </Portal>\n )}\n </div>\n );\n },\n);\n\nfunction HighlightMatch({ text, query }: { text: string; query: string }) {\n if (!query) return <>{text}</>;\n\n const idx = text.toLowerCase().indexOf(query.toLowerCase());\n if (idx === -1) return <>{text}</>;\n\n return (\n <>\n {text.slice(0, idx)}\n <span className=\"font-semibold text-zinc-900 dark:text-white\">\n {text.slice(idx, idx + query.length)}\n </span>\n {text.slice(idx + query.length)}\n </>\n );\n}\n\nAutocomplete.displayName = \"Autocomplete\";\n"]}
@@ -1,5 +1,5 @@
1
- import { Text } from './chunk-XM3V3RSU.js';
2
1
  import { Heading } from './chunk-QPM4CZ4G.js';
2
+ import { Text } from './chunk-XM3V3RSU.js';
3
3
  import { cn } from './chunk-MMW2JGKZ.js';
4
4
  import { createContext, forwardRef, useMemo, useContext } from 'react';
5
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -388,5 +388,5 @@ var Card = Object.assign(CardRoot, {
388
388
  });
389
389
 
390
390
  export { Card, CardBleed, CardBody, CardFooter, CardHeader, CardMedia };
391
- //# sourceMappingURL=chunk-2XO6EYZ7.js.map
392
- //# sourceMappingURL=chunk-2XO6EYZ7.js.map
391
+ //# sourceMappingURL=chunk-EENHSMV2.js.map
392
+ //# sourceMappingURL=chunk-EENHSMV2.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Card/Card.context.ts","../src/components/Card/Card.scales.ts","../src/components/Card/CardSection.tsx","../src/components/Card/CardHeader.tsx","../src/components/Card/CardBody.tsx","../src/components/Card/CardFooter.tsx","../src/components/Card/CardMedia.tsx","../src/components/Card/CardBleed.tsx","../src/components/Card/Card.tsx"],"names":["forwardRef","jsx","jsxs"],"mappings":";;;;;;AAaO,IAAM,WAAA,GAAc,cAAuC,IAAI,CAAA;AAE/D,SAAS,cAAA,GAA0C;AACxD,EAAA,OAAO,WAAW,WAAW,CAAA;AAC/B;AA0BO,IAAM,kBAAA,GAAqB,cAAkC,IAAI,CAAA;AAEjE,SAAS,qBAAA,GAA4C;AAC1D,EAAA,OAAO,WAAW,kBAAkB,CAAA;AACtC;;;ACvBO,IAAM,cAAA,GAA8C;AAAA,EACzD,IAAA,EAAM,EAAA;AAAA,EACN,EAAA,EAAI,yBAAA;AAAA,EACJ,EAAA,EAAI,uBAAA;AAAA,EACJ,EAAA,EAAI,uBAAA;AAAA,EACJ,EAAA,EAAI;AACN,CAAA;AAGO,IAAM,WAAA,GAA6C;AAAA,EACxD,EAAA,EAAI,IAAA;AAAA,EACJ,EAAA,EAAI,IAAA;AAAA,EACJ,EAAA,EAAI,IAAA;AAAA,EACJ,EAAA,EAAI;AACN,CAAA;AAEO,IAAM,aAAA,GAA0C;A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Z,EAAqB,KAAA,EAAO,SAC3B,QAAA,kBAAAA,GAAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,GAAA;AAAA,QACA,uBAAA,EAAsB,EAAA;AAAA,QACtB,SAAA,EAAW,EAAA;AAAA,UACT,oHAAA;AAAA,UACA,cAAc,IAAI,CAAA;AAAA,UAClB,eAAe,OAAO,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAStB,SAAA,IACE,0IAAA;AAAA;AAAA;AAAA;AAAA,UAIF,WAAA,IACE,oHAAA;AAAA,UACF,eAAe,eAAe,CAAA;AAAA,UAC9B;AAAA,SACF;AAAA,QACC,GAAG,KAAA;AAAA,QAEH;AAAA;AAAA,KACH,EACF,CAAA;AAAA,EAEJ;AACF,CAAA;AAEA,QAAA,CAAS,WAAA,GAAc,MAAA;AAEhB,IAAM,IAAA,GAAO,MAAA,CAAO,MAAA,CAAO,QAAA,EAAU;AAAA,EAC1C,KAAA,EAAO,SAAA;AAAA,EACP,MAAA,EAAQ,UAAA;AAAA,EACR,IAAA,EAAM,QAAA;AAAA,EACN,MAAA,EAAQ,UAAA;AAAA,EACR,KAAA,EAAO;AACT,CAAC","file":"chunk-2XO6EYZ7.js","sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { CardContextValue, CardPadding } from \"./Card.types\";\n\n/**\n * What a Card tells its parts.\n *\n * `null` is a SUPPORTED state, not an error — unlike `useAccordion`, which\n * throws. `Card.Header` and `Card.Footer` are usable on their own, as a section\n * heading above a card, and before this existed they rendered with a\n * `border-bottom` belonging to a card they were not inside. So the absence of a\n * card is information: it means \"style yourself standalone\", and it is why this\n * hook returns the value rather than asserting it.\n */\nexport const CardContext = createContext<CardContextValue | null>(null);\n\nexport function useCardContext(): CardContextValue | null {\n return useContext(CardContext);\n}\n\n/**\n * The padding step of the section a child sits inside, or `null` when there is\n * no padded section above it.\n *\n * `Card.Bleed` needs it because escaping the padding is two different\n * operations depending on depth, and a component cannot see its own depth:\n *\n * - Bleed inside a Header/Body/Footer is a GRANDchild of the card — the\n * padding is on that section, and reaching the card's edge means a negative\n * margin.\n * - Bleed as a direct child of the card IS the padded element — the padding\n * is on Bleed itself, and reaching the edge means zeroing it. A negative\n * margin here would pull the content outside the card entirely.\n *\n * Both look like \"cancel the padding\" and neither works for the other case,\n * which is exactly the kind of thing that ships looking fine in one demo.\n *\n * It carries the STEP rather than a boolean because the step is the only thing\n * the bleed actually needs, and it is NOT always derivable from the card's\n * `size`: `<Card size=\"md\" padding=\"lg\">` pads its children by `lg`, and a\n * standalone `Card.Header` has a card-less step of its own. A boolean sent the\n * bleed back to `size` for the distance, which was wrong in both of those\n * cases — by a whole padding step, silently.\n */\nexport const CardSectionContext = createContext<CardPadding | null>(null);\n\nexport function useCardSectionPadding(): CardPadding | null {\n return useContext(CardSectionContext);\n}\n","import type { CardPadding, CardSize } from \"./Card.types\";\n\n/**\n * One table per thing a `size` or a `padding` step scales.\n *\n * They live together, and apart from the components, because four of them have\n * to agree: the card's own radius, `Card.Media`'s top radius, the inset a\n * `dividerInset` rule stops at, and the negative margin a `Card.Bleed` uses to\n * escape. Those last three are all derived from the PADDING step — get one\n * wrong and the mismatch is a few pixels, which is the kind of defect that\n * survives review and then looks like a browser bug.\n *\n * Radius is keyed by `size`; everything that has to line up with the padding is\n * keyed by the padding step. Those are NOT the same key: `size` only picks the\n * DEFAULT padding, and an explicit `padding` prop overrides it. Keying the\n * inset and the bleed off `size` made `<Card size=\"md\" padding=\"lg\">` draw a\n * rule inset by 1rem over content inset by 1.5rem, and `padding=\"none\"` pull a\n * bleed clean outside the card.\n *\n * **`md` must stay byte-identical to what Card rendered before `size` existed**\n * (`rounded-lg`, `px-4`, `py-3`). `size` defaults to `md`, so that is what\n * makes this whole feature additive rather than a restyle of every consumer.\n */\n\nexport const paddingClasses: Record<CardPadding, string> = {\n none: \"\",\n xs: \"[&>*]:px-2 [&>*]:py-1.5\",\n sm: \"[&>*]:px-3 [&>*]:py-2\",\n md: \"[&>*]:px-4 [&>*]:py-3\",\n lg: \"[&>*]:px-6 [&>*]:py-4\",\n};\n\n/** The padding step a `size` implies when `padding` is not given. */\nexport const sizePadding: Record<CardSize, CardPadding> = {\n xs: \"xs\",\n sm: \"sm\",\n md: \"md\",\n lg: \"lg\",\n};\n\nexport const radiusClasses: Record<CardSize, string> = {\n xs: \"rounded\",\n sm: \"rounded-md\",\n md: \"rounded-lg\",\n lg: \"rounded-xl\",\n};\n\n/** `rounded-t-*` / `rounded-b-*` counterparts, for media and bleed. */\nexport const radiusTop: Record<CardSize, string> = {\n xs: \"rounded-t\",\n sm: \"rounded-t-md\",\n md: \"rounded-t-lg\",\n lg: \"rounded-t-xl\",\n};\n\nexport const radiusBottom: Record<CardSize, string> = {\n xs: \"rounded-b\",\n sm: \"rounded-b-md\",\n md: \"rounded-b-lg\",\n lg: \"rounded-b-xl\",\n};\n\n/** Padding a STANDALONE header/footer applies to itself, having no card. */\nexport const selfPadding: Record<CardPadding, string> = {\n none: \"\",\n xs: \"px-2 py-1.5\",\n sm: \"px-3 py-2\",\n md: \"px-4 py-3\",\n lg: \"px-6 py-4\",\n};\n\n/**\n * Where an inset divider stops — matches the horizontal padding step.\n *\n * Written out per variant rather than composed as `` `after:${insetX[step]}` ``.\n * **Tailwind generates CSS by scanning source for LITERAL class names**, so a\n * template string produces a class that exists in the DOM and in no stylesheet:\n * the divider silently does not render, and nothing in the build complains. The\n * duplication is the price of the scanner being a text search, and\n * `tests/card-tailwind.test.ts` compiles every one of these through Tailwind so\n * a typo cannot pass either.\n */\nexport const dividerInsetAfter: Record<CardPadding, string> = {\n none: \"after:inset-x-0\",\n xs: \"after:inset-x-2\",\n sm: \"after:inset-x-3\",\n md: \"after:inset-x-4\",\n lg: \"after:inset-x-6\",\n};\n\nexport const dividerInsetBefore: Record<CardPadding, string> = {\n none: \"before:inset-x-0\",\n xs: \"before:inset-x-2\",\n sm: \"before:inset-x-3\",\n md: \"before:inset-x-4\",\n lg: \"before:inset-x-6\",\n};\n\n/**\n * Negative margins a nested `Card.Bleed` uses to reach the card's edges.\n *\n * `none` is empty on purpose: with no padding to escape, a negative margin\n * would drag the content OUT of the card rather than to its edge.\n */\nexport const bleedX: Record<CardPadding, string> = {\n none: \"\",\n xs: \"-mx-2\",\n sm: \"-mx-3\",\n md: \"-mx-4\",\n lg: \"-mx-6\",\n};\n\nexport const bleedTop: Record<CardPadding, string> = {\n none: \"\",\n xs: \"-mt-1.5\",\n sm: \"-mt-2\",\n md: \"-mt-3\",\n lg: \"-mt-4\",\n};\n\nexport const bleedBottom: Record<CardPadding, string> = {\n none: \"\",\n xs: \"-mb-1.5\",\n sm: \"-mb-2\",\n md: \"-mb-3\",\n lg: \"-mb-4\",\n};\n","import { forwardRef } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Heading } from \"../Heading/Heading\";\nimport { Text } from \"../Text/Text\";\nimport { CardSectionContext, useCardContext } from \"./Card.context\";\nimport { dividerInsetAfter, dividerInsetBefore, selfPadding, sizePadding } from \"./Card.scales\";\nimport type { CardSectionProps } from \"./Card.types\";\n\n/**\n * The shared body of `Card.Header` and `Card.Footer`.\n *\n * They differ in exactly ONE way — which edge the rule sits on — so they are\n * one implementation with an `edge` argument rather than two files that have to\n * be kept in step. Composition, including where a lone `actions` block lands,\n * is identical in both. The previous pair had already drifted from\n * `ModalFooter`, which lays its actions out with `flex items-center\n * justify-end gap-3` while `Card.Footer` laid out nothing.\n */\nexport interface CardSectionInternalProps extends CardSectionProps {\n edge: \"top\" | \"bottom\";\n handle: string;\n}\n\nexport const CardSection = forwardRef<HTMLDivElement, CardSectionInternalProps>(\n (\n {\n edge,\n handle,\n heading,\n headingLevel = \"h3\",\n description,\n actions,\n size: sizeProp,\n className,\n children,\n ...props\n },\n ref,\n ) => {\n const card = useCardContext();\n\n // No card above us means this is a standalone section — a heading ABOVE a\n // card, which Flux supports and we rendered wrongly: it kept the rule that\n // belongs to a card it was not inside. Standalone also has to pad itself,\n // because the padding normally comes from the card's `[&>*]` rule.\n const standalone = card === null;\n const size = card?.size ?? sizeProp ?? \"md\";\n const sections = card?.sections ?? \"plain\";\n const dividerInset = card?.dividerInset ?? false;\n\n // The step the content is inset by, whoever applied it — the card's\n // `[&>*]` rule, or this element's own padding when standalone. An inset\n // rule has to stop exactly there, and a nested `Card.Bleed` has to travel\n // exactly that far back out, so both read this one value.\n const padding = card?.padding ?? sizePadding[size];\n\n const ruled = sections === \"divided\";\n const banded = sections === \"banded\";\n\n // Children WIN. Rendering both would give anyone who passed each by mistake\n // two titles, and silently ignoring children would be worse.\n const composed = children ?? null;\n const hasComposition = composed === null && (heading != null || description != null || actions != null);\n\n return (\n <div\n ref={ref}\n {...{ [handle]: \"\" }}\n className={cn(\n standalone && selfPadding[padding],\n banded && \"bg-zinc-50 dark:bg-zinc-800/50\",\n ruled &&\n !dividerInset &&\n (edge === \"bottom\"\n ? \"border-b border-[color:var(--fancy-border,var(--color-zinc-200))] dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]\"\n : \"border-t border-[color:var(--fancy-border,var(--color-zinc-200))] dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]\"),\n // An inset rule cannot be a border: a border draws on the element's\n // own edge, and the whole point is to stop short of it. So it is a\n // one-pixel pseudo-element, inset by the same step the padding uses —\n // which is why both come out of one table in Card.scales.\n ruled &&\n dividerInset &&\n cn(\n \"relative\",\n edge === \"bottom\"\n ? \"after:absolute after:bottom-0 after:h-px after:bg-[color:var(--fancy-border,var(--color-zinc-200))] dark:after:bg-[color:var(--fancy-border-dark,var(--color-zinc-700))]\"\n : \"before:absolute before:top-0 before:h-px before:bg-[color:var(--fancy-border,var(--color-zinc-200))] dark:before:bg-[color:var(--fancy-border-dark,var(--color-zinc-700))]\",\n edge === \"bottom\"\n ? dividerInsetAfter[padding]\n : dividerInsetBefore[padding],\n ),\n hasComposition && \"flex items-center gap-3\",\n hasComposition && (heading != null || description != null ? \"justify-between\" : \"justify-end\"),\n className,\n )}\n {...props}\n >\n {/* Padding is on THIS element either way -- from the card's `[&>*]`\n rule, or from `selfPadding` when standalone. A nested `Card.Bleed`\n escapes it with a negative margin in both cases, so the step goes\n down unconditionally; it used to be suppressed when standalone,\n which left a bleed inside a card-less header doing nothing. */}\n <CardSectionContext.Provider value={padding}>\n {composed ?? (\n <>\n {(heading != null || description != null) && (\n <div className=\"min-w-0\">\n {heading != null && (\n <Heading\n as={headingLevel}\n size=\"sm\"\n weight=\"semibold\"\n data-react-fancy-card-heading=\"\"\n >\n {heading}\n </Heading>\n )}\n {description != null && (\n <Text\n size=\"sm\"\n color=\"muted\"\n data-react-fancy-card-description=\"\"\n >\n {description}\n </Text>\n )}\n </div>\n )}\n {actions != null && (\n <div\n data-react-fancy-card-actions=\"\"\n className=\"flex shrink-0 items-center gap-2\"\n >\n {actions}\n </div>\n )}\n </>\n )}\n </CardSectionContext.Provider>\n </div>\n );\n },\n);\n\nCardSection.displayName = \"CardSection\";\n","import { forwardRef } from \"react\";\nimport { CardSection } from \"./CardSection\";\nimport type { CardHeaderProps } from \"./Card.types\";\n\n/**\n * A card's header. Also usable on its own, as a section heading above a card —\n * see `CardSection`, which decides that from the absence of a `CardContext`.\n */\nexport const CardHeader = forwardRef<HTMLDivElement, CardHeaderProps>(\n (props, ref) => (\n <CardSection\n ref={ref}\n edge=\"bottom\"\n handle=\"data-react-fancy-card-header\"\n {...props}\n />\n ),\n);\n\nCardHeader.displayName = \"CardHeader\";\n","import { forwardRef } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { CardSectionContext, useCardContext } from \"./Card.context\";\nimport type { CardBodyProps } from \"./Card.types\";\n\nexport const CardBody = forwardRef<HTMLDivElement, CardBodyProps>(\n ({ className, children, ...props }, ref) => {\n // The step the CARD pads this element by. `\"none\"` with no card above,\n // because then nothing pads it and there is nothing for a nested\n // `Card.Bleed` to escape.\n const padding = useCardContext()?.padding ?? \"none\";\n\n return (\n <div\n ref={ref}\n data-react-fancy-card-body=\"\"\n className={cn(className)}\n {...props}\n >\n {/*\n Body carries no classes of its own -- the card pads it through\n `[&>*]`, and giving it padding here would double that. The context is\n the only thing it adds: it tells a nested `Card.Bleed` that the\n padding to escape is on THIS element, and how much of it there is.\n */}\n <CardSectionContext.Provider value={padding}>{children}</CardSectionContext.Provider>\n </div>\n );\n },\n);\n\nCardBody.displayName = \"CardBody\";\n","import { forwardRef } from \"react\";\nimport { CardSection } from \"./CardSection\";\nimport type { CardFooterProps } from \"./Card.types\";\n\n/**\n * A card's footer. Its rule sits on the TOP edge, and a lone `actions` block\n * aligns to the end — matching `ModalFooter`, which has always done that while\n * this component laid out nothing.\n */\nexport const CardFooter = forwardRef<HTMLDivElement, CardFooterProps>(\n (props, ref) => (\n <CardSection\n ref={ref}\n edge=\"top\"\n handle=\"data-react-fancy-card-footer\"\n {...props}\n />\n ),\n);\n\nCardFooter.displayName = \"CardFooter\";\n","import { forwardRef } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useCardContext } from \"./Card.context\";\nimport { radiusTop } from \"./Card.scales\";\nimport type { CardMediaProps } from \"./Card.types\";\n\n/**\n * The fixed-ratio media region at the top of a card: a thumbnail, gradient or\n * solid swatch, with slots pinned to its corners.\n *\n * This is `Card.Media` rather than a separate `<MediaCard>` because the thing\n * being asked for was never a different card — it was a card with a picture in\n * it. Four surfaces had each rebuilt exactly this (a gallery index, a package\n * grid, a starter-kit grid and a showcase grid) and one of them was already\n * wrapping `Card` and hand-rolling only this region.\n *\n * ## The `background` is not decoration\n *\n * It shows through while the image loads and stays visible if the image never\n * arrives. The gallery relied on that: each style card is keyed to a swatch, so\n * a missing screenshot degrades to the right colour rather than to a hole.\n */\nexport const CardMedia = forwardRef<HTMLDivElement, CardMediaProps>(\n (\n {\n src,\n alt = \"\",\n ratio = \"16/9\",\n height,\n background,\n objectPosition = \"center\",\n loading = \"lazy\",\n topLeft,\n topRight,\n bottomLeft,\n bottomRight,\n className,\n style,\n children,\n ...props\n },\n ref,\n ) => {\n const cardSize = useCardContext()?.size ?? \"md\";\n\n return (\n <div\n ref={ref}\n data-react-fancy-card-media=\"\"\n className={cn(\n \"relative overflow-hidden\",\n // Follows the CARD's radius step rather than hardcoding `rounded-t-lg`.\n // It was fixed, so a `size=\"lg\"` card put a `rounded-xl` frame around\n // a `rounded-t-lg` image and left a visible sliver of card showing\n // through each top corner. Defaults to `md` with no card above, which\n // is the class it used to hardcode.\n radiusTop[cardSize],\n // Card's `padding` prop pads EVERY direct child\n // (`[&>*]:px-4 …`), which would inset the media and break the\n // flush-to-the-edge look every caller wants. `!` wins regardless of\n // stylesheet order, which plain `p-0` would not.\n \"!px-0 !py-0\",\n className,\n )}\n style={{\n ...(height === undefined ? { aspectRatio: ratio } : { height }),\n ...(background ? { background } : null),\n ...style,\n }}\n {...props}\n >\n {src ? (\n <img\n src={src}\n alt={alt}\n loading={loading}\n className=\"absolute inset-0 h-full w-full object-cover\"\n style={{ objectPosition }}\n />\n ) : null}\n\n {children}\n\n {topLeft ? <span className=\"absolute left-2 top-2 z-10\">{topLeft}</span> : null}\n {topRight ? <span className=\"absolute right-2 top-2 z-10\">{topRight}</span> : null}\n {bottomLeft ? <span className=\"absolute bottom-2 left-2 z-10\">{bottomLeft}</span> : null}\n {bottomRight ? <span className=\"absolute bottom-2 right-2 z-10\">{bottomRight}</span> : null}\n </div>\n );\n },\n);\n\nCardMedia.displayName = \"CardMedia\";\n","import { forwardRef } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useCardContext, useCardSectionPadding } from \"./Card.context\";\nimport { bleedBottom, bleedTop, bleedX, radiusBottom, radiusTop } from \"./Card.scales\";\nimport type { CardBleedProps } from \"./Card.types\";\n\n/**\n * Run content out to the card's edges — an image, a table, a chart strip.\n *\n * ## Why this is arithmetic and not a CSS-variable protocol\n *\n * Flux solves the same problem with a published set of custom properties\n * (`--flux-bleed-x`, `--flux-bleed-top`, …) that any child component may read.\n * It has to: its padding sits on the CARD, so a descendant has no way to know\n * how far it must reach. That is a public CSS API — a cross-package contract to\n * version forever.\n *\n * Ours does not need one, because padding sits on the card's direct CHILDREN.\n * The distance to the edge is therefore always one padding step, which the\n * padded section passes down in context. No variables, nothing for a consumer\n * to depend on, nothing to keep stable across releases.\n *\n * ## Two cases, and they are opposites\n *\n * - **Inside a `Card.Header` / `Card.Body` / `Card.Footer`** (the normal case):\n * the padding is on that section, so reaching the edge is a NEGATIVE MARGIN.\n * - **As a direct child of `Card`**: the padding is on this element, so\n * reaching the edge is ZEROING it. A negative margin here would pull the\n * content clean outside the card.\n *\n * A component cannot see its own depth, so the sections publish their padding\n * step in context and its absence means \"you are the padded element\". Both\n * cases read as \"cancel the padding\", which is exactly why picking either one\n * alone ships looking correct in whichever demo the author happened to write.\n *\n * The distance comes from that context and NOT from the card's `size`, because\n * the two disagree whenever `padding` is passed explicitly — and disagree by a\n * whole step, which looks like a rendering bug rather than a prop conflict.\n *\n * Corners are rounded only where the content actually meets the card's edge, so\n * a mid-body strip stays square while one at the top follows the card's radius.\n */\nexport const CardBleed = forwardRef<HTMLDivElement, CardBleedProps>(\n ({ edges = \"x\", className, children, ...props }, ref) => {\n const card = useCardContext();\n const section = useCardSectionPadding();\n // Radius follows the CARD (that is whose corners are being met); the\n // distance follows the PADDING.\n const size = card?.size ?? \"md\";\n\n const touchesTop = edges === \"top\" || edges === \"all\";\n const touchesBottom = edges === \"bottom\" || edges === \"all\";\n\n return (\n <div\n ref={ref}\n data-react-fancy-card-bleed=\"\"\n className={cn(\n // Clip children to whatever corners we round, or an image's square\n // edge sits over the card's curve.\n \"overflow-hidden\",\n section !== null\n ? cn(\n bleedX[section],\n touchesTop && bleedTop[section],\n touchesBottom && bleedBottom[section],\n )\n : // Direct child of the card: `!` because the padding it is undoing\n // comes from the card's own `[&>*]` rule, which is equally\n // specific. Same mechanism `Card.Media` uses.\n cn(\n \"!px-0\",\n touchesTop && \"!pt-0\",\n touchesBottom && \"!pb-0\",\n ),\n touchesTop && radiusTop[size],\n touchesBottom && radiusBottom[size],\n className,\n )}\n {...props}\n >\n {children}\n </div>\n );\n },\n);\n\nCardBleed.displayName = \"CardBleed\";\n","import { forwardRef, useMemo } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { CardHeader } from \"./CardHeader\";\nimport { CardBody } from \"./CardBody\";\nimport { CardFooter } from \"./CardFooter\";\nimport { CardMedia } from \"./CardMedia\";\nimport { CardBleed } from \"./CardBleed\";\nimport { CardContext } from \"./Card.context\";\nimport { paddingClasses, radiusClasses, sizePadding } from \"./Card.scales\";\nimport type { CardContextValue, CardProps } from \"./Card.types\";\n\nconst variantClasses: Record<NonNullable<CardProps[\"variant\"]>, string> = {\n outlined: \"border border-[color:var(--fancy-border,var(--color-zinc-200))] dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]\",\n elevated: \"shadow-md border border-zinc-100 dark:border-zinc-800\",\n flat: \"bg-zinc-50 dark:bg-zinc-800/50\",\n // Tint steps between \"no tint\" and `flat`. They work the same way `flat`\n // does: a later `bg-*` in the class string beats the base `bg-white`, because\n // `cn` is tailwind-merge and resolves conflicting utilities last-wins. Class\n // ORDER decides this, not CSS specificity — so these must stay after the base\n // background in the `cn(...)` call below.\n muted: \"bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] dark:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))]\",\n soft: \"bg-zinc-50/70 dark:bg-zinc-800/40\",\n};\n\n/**\n * Padding is applied to the card's DIRECT CHILDREN rather than the card\n * itself, so a full-bleed child (`Card.Media`) can opt out with `!px-0`\n * without having to undo a padding that is already baked into the frame.\n *\n * The selector is `&>*`, not `&>div`. It was `&>div` until 5.24.0, which meant\n * the tag a caller happened to choose silently decided whether that child was\n * padded: `<Card><div>a</div><p>b</p></Card>` inset the div and left the\n * paragraph hard against the border. Nothing in the caller's code hinted at\n * the rule, and the result read as a bug in the card.\n *\n * It is also why there is no `gap` to scale with `size`, which looks like an\n * omission and is not: each direct child carries its own `py-*`, so two\n * adjacent parts already have twice that between their content. Adding a row\n * gap on the card would double a space that is already there.\n */\n\nconst CardRoot = forwardRef<HTMLDivElement, CardProps>(\n (\n {\n variant = \"outlined\",\n size = \"md\",\n padding,\n sections = \"divided\",\n dividerInset = false,\n highlight = false,\n interactive = false,\n className,\n children,\n ...props\n },\n ref,\n ) => {\n // `padding` stays authoritative over the step `size` implies. That order is\n // what keeps `size` additive: a caller already passing `padding` sees no\n // change, and `padding=\"none\"` still means none.\n const resolvedPadding = padding ?? sizePadding[size];\n\n // The RESOLVED step goes into the context, not `size`. A part that has to\n // meet the content's edge — an inset divider, a `Card.Bleed` — needs the\n // distance the card actually applied, and `size` is only the default.\n const context = useMemo<CardContextValue>(\n () => ({ size, padding: resolvedPadding, sections, dividerInset }),\n [size, resolvedPadding, sections, dividerInset],\n );\n\n return (\n <CardContext.Provider value={context}>\n <div\n ref={ref}\n data-react-fancy-card=\"\"\n className={cn(\n \"bg-[color:var(--fancy-surface,var(--color-white))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n radiusClasses[size],\n variantClasses[variant],\n // A pseudo-element rather than an inset box-shadow: `shadow-*` and\n // `shadow-[inset...]` are the same tailwind-merge group, so an\n // inset shadow here would have SILENTLY DELETED `elevated`'s\n // `shadow-md`. Highlight and elevation have to be able to coexist.\n // `dark:` carries a REAL colour. It was `dark:before:bg-transparent`,\n // which made `highlight` a no-op in the mode that needs it most:\n // a dark surface has no border contrast of its own, and a 10% white\n // top edge is the whole reason Flux turns this on by default.\n highlight &&\n \"relative before:pointer-events-none before:absolute before:inset-x-0 before:top-0 before:h-px before:bg-white/70 dark:before:bg-white/10\",\n // `overflow-hidden` is part of `interactive` rather than always-on:\n // clipping unconditionally would cut off popovers and dropdowns that\n // legitimately overflow a static card.\n interactive &&\n \"overflow-hidden transition hover:-translate-y-0.5 hover:shadow-lg hover:border-zinc-300 dark:hover:border-zinc-600\",\n paddingClasses[resolvedPadding],\n className,\n )}\n {...props}\n >\n {children}\n </div>\n </CardContext.Provider>\n );\n },\n);\n\nCardRoot.displayName = \"Card\";\n\nexport const Card = Object.assign(CardRoot, {\n Media: CardMedia,\n Header: CardHeader,\n Body: CardBody,\n Footer: CardFooter,\n Bleed: CardBleed,\n});\n"]}
1
+ {"version":3,"sources":["../src/components/Card/Card.context.ts","../src/components/Card/Card.scales.ts","../src/components/Card/CardSection.tsx","../src/components/Card/CardHeader.tsx","../src/components/Card/CardBody.tsx","../src/components/Card/CardFooter.tsx","../src/components/Card/CardMedia.tsx","../src/components/Card/CardBleed.tsx","../src/components/Card/Card.tsx"],"names":["forwardRef","jsx","jsxs"],"mappings":";;;;;;AAaO,IAAM,WAAA,GAAc,cAAuC,IAAI,CAAA;AAE/D,SAAS,cAAA,GAA0C;AACxD,EAAA,OAAO,WAAW,WAAW,CAAA;AAC/B;AA0BO,IAAM,kBAAA,GAAqB,cAAkC,IAAI,CAAA;AAEjE,SAAS,qBAAA,GAA4C;AAC1D,EAAA,OAAO,WAAW,kBAAkB,CAAA;AACtC;;;ACvBO,IAAM,cAAA,GAA8C;AAAA,EACzD,IAAA,EAAM,EAAA;AAAA,EACN,EAAA,EAAI,yBAAA;AAAA,EACJ,EAAA,EAAI,uBAAA;AAAA,EACJ,EAAA,EAAI,uBAAA;AAAA,EACJ,EAAA,EAAI;AACN,CAAA;AAGO,IAAM,WAAA,GAA6C;AAAA,EACxD,EAAA,EAAI,IAAA;AAAA,EACJ,EAAA,EAAI,IAAA;AAAA,EACJ,EAAA,EAAI,IAAA;AAAA,EACJ,EAAA,EAAI;AACN,CAAA;AAEO,IAAM,aAAA,GAA0C;AAAA,EACrD,EAAA,EAAI,SAAA;AAAA,EACJ,EAAA,EAAI,YAAA;AAAA,EACJ,EAAA,EAAI,YAAA;AAAA,EACJ,EAAA,EAAI;AACN,CAAA;AAGO,IAAM,SAAA,GAAsC;AAAA,EACjD,EAAA,EAAI,WAAA;AAAA,EACJ,EAAA,EAAI,cAAA;AAAA,EACJ,EAAA,EAAI,cAAA;AAAA,EACJ,EAA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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAStB,SAAA,IACE,0IAAA;AAAA;AAAA;AAAA;AAAA,UAIF,WAAA,IACE,oHAAA;AAAA,UACF,eAAe,eAAe,CAAA;AAAA,UAC9B;AAAA,SACF;AAAA,QACC,GAAG,KAAA;AAAA,QAEH;AAAA;AAAA,KACH,EACF,CAAA;AAAA,EAEJ;AACF,CAAA;AAEA,QAAA,CAAS,WAAA,GAAc,MAAA;AAEhB,IAAM,IAAA,GAAO,MAAA,CAAO,MAAA,CAAO,QAAA,EAAU;AAAA,EAC1C,KAAA,EAAO,SAAA;AAAA,EACP,MAAA,EAAQ,UAAA;AAAA,EACR,IAAA,EAAM,QAAA;AAAA,EACN,MAAA,EAAQ,UAAA;AAAA,EACR,KAAA,EAAO;AACT,CAAC","file":"chunk-EENHSMV2.js","sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { CardContextValue, CardPadding } from \"./Card.types\";\n\n/**\n * What a Card tells its parts.\n *\n * `null` is a SUPPORTED state, not an error — unlike `useAccordion`, which\n * throws. `Card.Header` and `Card.Footer` are usable on their own, as a section\n * heading above a card, and before this existed they rendered with a\n * `border-bottom` belonging to a card they were not inside. So the absence of a\n * card is information: it means \"style yourself standalone\", and it is why this\n * hook returns the value rather than asserting it.\n */\nexport const CardContext = createContext<CardContextValue | null>(null);\n\nexport function useCardContext(): CardContextValue | null {\n return useContext(CardContext);\n}\n\n/**\n * The padding step of the section a child sits inside, or `null` when there is\n * no padded section above it.\n *\n * `Card.Bleed` needs it because escaping the padding is two different\n * operations depending on depth, and a component cannot see its own depth:\n *\n * - Bleed inside a Header/Body/Footer is a GRANDchild of the card — the\n * padding is on that section, and reaching the card's edge means a negative\n * margin.\n * - Bleed as a direct child of the card IS the padded element — the padding\n * is on Bleed itself, and reaching the edge means zeroing it. A negative\n * margin here would pull the content outside the card entirely.\n *\n * Both look like \"cancel the padding\" and neither works for the other case,\n * which is exactly the kind of thing that ships looking fine in one demo.\n *\n * It carries the STEP rather than a boolean because the step is the only thing\n * the bleed actually needs, and it is NOT always derivable from the card's\n * `size`: `<Card size=\"md\" padding=\"lg\">` pads its children by `lg`, and a\n * standalone `Card.Header` has a card-less step of its own. A boolean sent the\n * bleed back to `size` for the distance, which was wrong in both of those\n * cases — by a whole padding step, silently.\n */\nexport const CardSectionContext = createContext<CardPadding | null>(null);\n\nexport function useCardSectionPadding(): CardPadding | null {\n return useContext(CardSectionContext);\n}\n","import type { CardPadding, CardSize } from \"./Card.types\";\n\n/**\n * One table per thing a `size` or a `padding` step scales.\n *\n * They live together, and apart from the components, because four of them have\n * to agree: the card's own radius, `Card.Media`'s top radius, the inset a\n * `dividerInset` rule stops at, and the negative margin a `Card.Bleed` uses to\n * escape. Those last three are all derived from the PADDING step — get one\n * wrong and the mismatch is a few pixels, which is the kind of defect that\n * survives review and then looks like a browser bug.\n *\n * Radius is keyed by `size`; everything that has to line up with the padding is\n * keyed by the padding step. Those are NOT the same key: `size` only picks the\n * DEFAULT padding, and an explicit `padding` prop overrides it. Keying the\n * inset and the bleed off `size` made `<Card size=\"md\" padding=\"lg\">` draw a\n * rule inset by 1rem over content inset by 1.5rem, and `padding=\"none\"` pull a\n * bleed clean outside the card.\n *\n * **`md` must stay byte-identical to what Card rendered before `size` existed**\n * (`rounded-lg`, `px-4`, `py-3`). `size` defaults to `md`, so that is what\n * makes this whole feature additive rather than a restyle of every consumer.\n */\n\nexport const paddingClasses: Record<CardPadding, string> = {\n none: \"\",\n xs: \"[&>*]:px-2 [&>*]:py-1.5\",\n sm: \"[&>*]:px-3 [&>*]:py-2\",\n md: \"[&>*]:px-4 [&>*]:py-3\",\n lg: \"[&>*]:px-6 [&>*]:py-4\",\n};\n\n/** The padding step a `size` implies when `padding` is not given. */\nexport const sizePadding: Record<CardSize, CardPadding> = {\n xs: \"xs\",\n sm: \"sm\",\n md: \"md\",\n lg: \"lg\",\n};\n\nexport const radiusClasses: Record<CardSize, string> = {\n xs: \"rounded\",\n sm: \"rounded-md\",\n md: \"rounded-lg\",\n lg: \"rounded-xl\",\n};\n\n/** `rounded-t-*` / `rounded-b-*` counterparts, for media and bleed. */\nexport const radiusTop: Record<CardSize, string> = {\n xs: \"rounded-t\",\n sm: \"rounded-t-md\",\n md: \"rounded-t-lg\",\n lg: \"rounded-t-xl\",\n};\n\nexport const radiusBottom: Record<CardSize, string> = {\n xs: \"rounded-b\",\n sm: \"rounded-b-md\",\n md: \"rounded-b-lg\",\n lg: \"rounded-b-xl\",\n};\n\n/** Padding a STANDALONE header/footer applies to itself, having no card. */\nexport const selfPadding: Record<CardPadding, string> = {\n none: \"\",\n xs: \"px-2 py-1.5\",\n sm: \"px-3 py-2\",\n md: \"px-4 py-3\",\n lg: \"px-6 py-4\",\n};\n\n/**\n * Where an inset divider stops — matches the horizontal padding step.\n *\n * Written out per variant rather than composed as `` `after:${insetX[step]}` ``.\n * **Tailwind generates CSS by scanning source for LITERAL class names**, so a\n * template string produces a class that exists in the DOM and in no stylesheet:\n * the divider silently does not render, and nothing in the build complains. The\n * duplication is the price of the scanner being a text search, and\n * `tests/card-tailwind.test.ts` compiles every one of these through Tailwind so\n * a typo cannot pass either.\n */\nexport const dividerInsetAfter: Record<CardPadding, string> = {\n none: \"after:inset-x-0\",\n xs: \"after:inset-x-2\",\n sm: \"after:inset-x-3\",\n md: \"after:inset-x-4\",\n lg: \"after:inset-x-6\",\n};\n\nexport const dividerInsetBefore: Record<CardPadding, string> = {\n none: \"before:inset-x-0\",\n xs: \"before:inset-x-2\",\n sm: \"before:inset-x-3\",\n md: \"before:inset-x-4\",\n lg: \"before:inset-x-6\",\n};\n\n/**\n * Negative margins a nested `Card.Bleed` uses to reach the card's edges.\n *\n * `none` is empty on purpose: with no padding to escape, a negative margin\n * would drag the content OUT of the card rather than to its edge.\n */\nexport const bleedX: Record<CardPadding, string> = {\n none: \"\",\n xs: \"-mx-2\",\n sm: \"-mx-3\",\n md: \"-mx-4\",\n lg: \"-mx-6\",\n};\n\nexport const bleedTop: Record<CardPadding, string> = {\n none: \"\",\n xs: \"-mt-1.5\",\n sm: \"-mt-2\",\n md: \"-mt-3\",\n lg: \"-mt-4\",\n};\n\nexport const bleedBottom: Record<CardPadding, string> = {\n none: \"\",\n xs: \"-mb-1.5\",\n sm: \"-mb-2\",\n md: \"-mb-3\",\n lg: \"-mb-4\",\n};\n","import { forwardRef } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Heading } from \"../Heading/Heading\";\nimport { Text } from \"../Text/Text\";\nimport { CardSectionContext, useCardContext } from \"./Card.context\";\nimport { dividerInsetAfter, dividerInsetBefore, selfPadding, sizePadding } from \"./Card.scales\";\nimport type { CardSectionProps } from \"./Card.types\";\n\n/**\n * The shared body of `Card.Header` and `Card.Footer`.\n *\n * They differ in exactly ONE way — which edge the rule sits on — so they are\n * one implementation with an `edge` argument rather than two files that have to\n * be kept in step. Composition, including where a lone `actions` block lands,\n * is identical in both. The previous pair had already drifted from\n * `ModalFooter`, which lays its actions out with `flex items-center\n * justify-end gap-3` while `Card.Footer` laid out nothing.\n */\nexport interface CardSectionInternalProps extends CardSectionProps {\n edge: \"top\" | \"bottom\";\n handle: string;\n}\n\nexport const CardSection = forwardRef<HTMLDivElement, CardSectionInternalProps>(\n (\n {\n edge,\n handle,\n heading,\n headingLevel = \"h3\",\n description,\n actions,\n size: sizeProp,\n className,\n children,\n ...props\n },\n ref,\n ) => {\n const card = useCardContext();\n\n // No card above us means this is a standalone section — a heading ABOVE a\n // card, which Flux supports and we rendered wrongly: it kept the rule that\n // belongs to a card it was not inside. Standalone also has to pad itself,\n // because the padding normally comes from the card's `[&>*]` rule.\n const standalone = card === null;\n const size = card?.size ?? sizeProp ?? \"md\";\n const sections = card?.sections ?? \"plain\";\n const dividerInset = card?.dividerInset ?? false;\n\n // The step the content is inset by, whoever applied it — the card's\n // `[&>*]` rule, or this element's own padding when standalone. An inset\n // rule has to stop exactly there, and a nested `Card.Bleed` has to travel\n // exactly that far back out, so both read this one value.\n const padding = card?.padding ?? sizePadding[size];\n\n const ruled = sections === \"divided\";\n const banded = sections === \"banded\";\n\n // Children WIN. Rendering both would give anyone who passed each by mistake\n // two titles, and silently ignoring children would be worse.\n const composed = children ?? null;\n const hasComposition = composed === null && (heading != null || description != null || actions != null);\n\n return (\n <div\n ref={ref}\n {...{ [handle]: \"\" }}\n className={cn(\n standalone && selfPadding[padding],\n banded && \"bg-zinc-50 dark:bg-zinc-800/50\",\n ruled &&\n !dividerInset &&\n (edge === \"bottom\"\n ? \"border-b border-[color:var(--fancy-border,var(--color-zinc-200))] dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]\"\n : \"border-t border-[color:var(--fancy-border,var(--color-zinc-200))] dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]\"),\n // An inset rule cannot be a border: a border draws on the element's\n // own edge, and the whole point is to stop short of it. So it is a\n // one-pixel pseudo-element, inset by the same step the padding uses —\n // which is why both come out of one table in Card.scales.\n ruled &&\n dividerInset &&\n cn(\n \"relative\",\n edge === \"bottom\"\n ? \"after:absolute after:bottom-0 after:h-px after:bg-[color:var(--fancy-border,var(--color-zinc-200))] dark:after:bg-[color:var(--fancy-border-dark,var(--color-zinc-700))]\"\n : \"before:absolute before:top-0 before:h-px before:bg-[color:var(--fancy-border,var(--color-zinc-200))] dark:before:bg-[color:var(--fancy-border-dark,var(--color-zinc-700))]\",\n edge === \"bottom\"\n ? dividerInsetAfter[padding]\n : dividerInsetBefore[padding],\n ),\n hasComposition && \"flex items-center gap-3\",\n hasComposition && (heading != null || description != null ? \"justify-between\" : \"justify-end\"),\n className,\n )}\n {...props}\n >\n {/* Padding is on THIS element either way -- from the card's `[&>*]`\n rule, or from `selfPadding` when standalone. A nested `Card.Bleed`\n escapes it with a negative margin in both cases, so the step goes\n down unconditionally; it used to be suppressed when standalone,\n which left a bleed inside a card-less header doing nothing. */}\n <CardSectionContext.Provider value={padding}>\n {composed ?? (\n <>\n {(heading != null || description != null) && (\n <div className=\"min-w-0\">\n {heading != null && (\n <Heading\n as={headingLevel}\n size=\"sm\"\n weight=\"semibold\"\n data-react-fancy-card-heading=\"\"\n >\n {heading}\n </Heading>\n )}\n {description != null && (\n <Text\n size=\"sm\"\n color=\"muted\"\n data-react-fancy-card-description=\"\"\n >\n {description}\n </Text>\n )}\n </div>\n )}\n {actions != null && (\n <div\n data-react-fancy-card-actions=\"\"\n className=\"flex shrink-0 items-center gap-2\"\n >\n {actions}\n </div>\n )}\n </>\n )}\n </CardSectionContext.Provider>\n </div>\n );\n },\n);\n\nCardSection.displayName = \"CardSection\";\n","import { forwardRef } from \"react\";\nimport { CardSection } from \"./CardSection\";\nimport type { CardHeaderProps } from \"./Card.types\";\n\n/**\n * A card's header. Also usable on its own, as a section heading above a card —\n * see `CardSection`, which decides that from the absence of a `CardContext`.\n */\nexport const CardHeader = forwardRef<HTMLDivElement, CardHeaderProps>(\n (props, ref) => (\n <CardSection\n ref={ref}\n edge=\"bottom\"\n handle=\"data-react-fancy-card-header\"\n {...props}\n />\n ),\n);\n\nCardHeader.displayName = \"CardHeader\";\n","import { forwardRef } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { CardSectionContext, useCardContext } from \"./Card.context\";\nimport type { CardBodyProps } from \"./Card.types\";\n\nexport const CardBody = forwardRef<HTMLDivElement, CardBodyProps>(\n ({ className, children, ...props }, ref) => {\n // The step the CARD pads this element by. `\"none\"` with no card above,\n // because then nothing pads it and there is nothing for a nested\n // `Card.Bleed` to escape.\n const padding = useCardContext()?.padding ?? \"none\";\n\n return (\n <div\n ref={ref}\n data-react-fancy-card-body=\"\"\n className={cn(className)}\n {...props}\n >\n {/*\n Body carries no classes of its own -- the card pads it through\n `[&>*]`, and giving it padding here would double that. The context is\n the only thing it adds: it tells a nested `Card.Bleed` that the\n padding to escape is on THIS element, and how much of it there is.\n */}\n <CardSectionContext.Provider value={padding}>{children}</CardSectionContext.Provider>\n </div>\n );\n },\n);\n\nCardBody.displayName = \"CardBody\";\n","import { forwardRef } from \"react\";\nimport { CardSection } from \"./CardSection\";\nimport type { CardFooterProps } from \"./Card.types\";\n\n/**\n * A card's footer. Its rule sits on the TOP edge, and a lone `actions` block\n * aligns to the end — matching `ModalFooter`, which has always done that while\n * this component laid out nothing.\n */\nexport const CardFooter = forwardRef<HTMLDivElement, CardFooterProps>(\n (props, ref) => (\n <CardSection\n ref={ref}\n edge=\"top\"\n handle=\"data-react-fancy-card-footer\"\n {...props}\n />\n ),\n);\n\nCardFooter.displayName = \"CardFooter\";\n","import { forwardRef } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useCardContext } from \"./Card.context\";\nimport { radiusTop } from \"./Card.scales\";\nimport type { CardMediaProps } from \"./Card.types\";\n\n/**\n * The fixed-ratio media region at the top of a card: a thumbnail, gradient or\n * solid swatch, with slots pinned to its corners.\n *\n * This is `Card.Media` rather than a separate `<MediaCard>` because the thing\n * being asked for was never a different card — it was a card with a picture in\n * it. Four surfaces had each rebuilt exactly this (a gallery index, a package\n * grid, a starter-kit grid and a showcase grid) and one of them was already\n * wrapping `Card` and hand-rolling only this region.\n *\n * ## The `background` is not decoration\n *\n * It shows through while the image loads and stays visible if the image never\n * arrives. The gallery relied on that: each style card is keyed to a swatch, so\n * a missing screenshot degrades to the right colour rather than to a hole.\n */\nexport const CardMedia = forwardRef<HTMLDivElement, CardMediaProps>(\n (\n {\n src,\n alt = \"\",\n ratio = \"16/9\",\n height,\n background,\n objectPosition = \"center\",\n loading = \"lazy\",\n topLeft,\n topRight,\n bottomLeft,\n bottomRight,\n className,\n style,\n children,\n ...props\n },\n ref,\n ) => {\n const cardSize = useCardContext()?.size ?? \"md\";\n\n return (\n <div\n ref={ref}\n data-react-fancy-card-media=\"\"\n className={cn(\n \"relative overflow-hidden\",\n // Follows the CARD's radius step rather than hardcoding `rounded-t-lg`.\n // It was fixed, so a `size=\"lg\"` card put a `rounded-xl` frame around\n // a `rounded-t-lg` image and left a visible sliver of card showing\n // through each top corner. Defaults to `md` with no card above, which\n // is the class it used to hardcode.\n radiusTop[cardSize],\n // Card's `padding` prop pads EVERY direct child\n // (`[&>*]:px-4 …`), which would inset the media and break the\n // flush-to-the-edge look every caller wants. `!` wins regardless of\n // stylesheet order, which plain `p-0` would not.\n \"!px-0 !py-0\",\n className,\n )}\n style={{\n ...(height === undefined ? { aspectRatio: ratio } : { height }),\n ...(background ? { background } : null),\n ...style,\n }}\n {...props}\n >\n {src ? (\n <img\n src={src}\n alt={alt}\n loading={loading}\n className=\"absolute inset-0 h-full w-full object-cover\"\n style={{ objectPosition }}\n />\n ) : null}\n\n {children}\n\n {topLeft ? <span className=\"absolute left-2 top-2 z-10\">{topLeft}</span> : null}\n {topRight ? <span className=\"absolute right-2 top-2 z-10\">{topRight}</span> : null}\n {bottomLeft ? <span className=\"absolute bottom-2 left-2 z-10\">{bottomLeft}</span> : null}\n {bottomRight ? <span className=\"absolute bottom-2 right-2 z-10\">{bottomRight}</span> : null}\n </div>\n );\n },\n);\n\nCardMedia.displayName = \"CardMedia\";\n","import { forwardRef } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useCardContext, useCardSectionPadding } from \"./Card.context\";\nimport { bleedBottom, bleedTop, bleedX, radiusBottom, radiusTop } from \"./Card.scales\";\nimport type { CardBleedProps } from \"./Card.types\";\n\n/**\n * Run content out to the card's edges — an image, a table, a chart strip.\n *\n * ## Why this is arithmetic and not a CSS-variable protocol\n *\n * Flux solves the same problem with a published set of custom properties\n * (`--flux-bleed-x`, `--flux-bleed-top`, …) that any child component may read.\n * It has to: its padding sits on the CARD, so a descendant has no way to know\n * how far it must reach. That is a public CSS API — a cross-package contract to\n * version forever.\n *\n * Ours does not need one, because padding sits on the card's direct CHILDREN.\n * The distance to the edge is therefore always one padding step, which the\n * padded section passes down in context. No variables, nothing for a consumer\n * to depend on, nothing to keep stable across releases.\n *\n * ## Two cases, and they are opposites\n *\n * - **Inside a `Card.Header` / `Card.Body` / `Card.Footer`** (the normal case):\n * the padding is on that section, so reaching the edge is a NEGATIVE MARGIN.\n * - **As a direct child of `Card`**: the padding is on this element, so\n * reaching the edge is ZEROING it. A negative margin here would pull the\n * content clean outside the card.\n *\n * A component cannot see its own depth, so the sections publish their padding\n * step in context and its absence means \"you are the padded element\". Both\n * cases read as \"cancel the padding\", which is exactly why picking either one\n * alone ships looking correct in whichever demo the author happened to write.\n *\n * The distance comes from that context and NOT from the card's `size`, because\n * the two disagree whenever `padding` is passed explicitly — and disagree by a\n * whole step, which looks like a rendering bug rather than a prop conflict.\n *\n * Corners are rounded only where the content actually meets the card's edge, so\n * a mid-body strip stays square while one at the top follows the card's radius.\n */\nexport const CardBleed = forwardRef<HTMLDivElement, CardBleedProps>(\n ({ edges = \"x\", className, children, ...props }, ref) => {\n const card = useCardContext();\n const section = useCardSectionPadding();\n // Radius follows the CARD (that is whose corners are being met); the\n // distance follows the PADDING.\n const size = card?.size ?? \"md\";\n\n const touchesTop = edges === \"top\" || edges === \"all\";\n const touchesBottom = edges === \"bottom\" || edges === \"all\";\n\n return (\n <div\n ref={ref}\n data-react-fancy-card-bleed=\"\"\n className={cn(\n // Clip children to whatever corners we round, or an image's square\n // edge sits over the card's curve.\n \"overflow-hidden\",\n section !== null\n ? cn(\n bleedX[section],\n touchesTop && bleedTop[section],\n touchesBottom && bleedBottom[section],\n )\n : // Direct child of the card: `!` because the padding it is undoing\n // comes from the card's own `[&>*]` rule, which is equally\n // specific. Same mechanism `Card.Media` uses.\n cn(\n \"!px-0\",\n touchesTop && \"!pt-0\",\n touchesBottom && \"!pb-0\",\n ),\n touchesTop && radiusTop[size],\n touchesBottom && radiusBottom[size],\n className,\n )}\n {...props}\n >\n {children}\n </div>\n );\n },\n);\n\nCardBleed.displayName = \"CardBleed\";\n","import { forwardRef, useMemo } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { CardHeader } from \"./CardHeader\";\nimport { CardBody } from \"./CardBody\";\nimport { CardFooter } from \"./CardFooter\";\nimport { CardMedia } from \"./CardMedia\";\nimport { CardBleed } from \"./CardBleed\";\nimport { CardContext } from \"./Card.context\";\nimport { paddingClasses, radiusClasses, sizePadding } from \"./Card.scales\";\nimport type { CardContextValue, CardProps } from \"./Card.types\";\n\nconst variantClasses: Record<NonNullable<CardProps[\"variant\"]>, string> = {\n outlined: \"border border-[color:var(--fancy-border,var(--color-zinc-200))] dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))]\",\n elevated: \"shadow-md border border-zinc-100 dark:border-zinc-800\",\n flat: \"bg-zinc-50 dark:bg-zinc-800/50\",\n // Tint steps between \"no tint\" and `flat`. They work the same way `flat`\n // does: a later `bg-*` in the class string beats the base `bg-white`, because\n // `cn` is tailwind-merge and resolves conflicting utilities last-wins. Class\n // ORDER decides this, not CSS specificity — so these must stay after the base\n // background in the `cn(...)` call below.\n muted: \"bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] dark:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))]\",\n soft: \"bg-zinc-50/70 dark:bg-zinc-800/40\",\n};\n\n/**\n * Padding is applied to the card's DIRECT CHILDREN rather than the card\n * itself, so a full-bleed child (`Card.Media`) can opt out with `!px-0`\n * without having to undo a padding that is already baked into the frame.\n *\n * The selector is `&>*`, not `&>div`. It was `&>div` until 5.24.0, which meant\n * the tag a caller happened to choose silently decided whether that child was\n * padded: `<Card><div>a</div><p>b</p></Card>` inset the div and left the\n * paragraph hard against the border. Nothing in the caller's code hinted at\n * the rule, and the result read as a bug in the card.\n *\n * It is also why there is no `gap` to scale with `size`, which looks like an\n * omission and is not: each direct child carries its own `py-*`, so two\n * adjacent parts already have twice that between their content. Adding a row\n * gap on the card would double a space that is already there.\n */\n\nconst CardRoot = forwardRef<HTMLDivElement, CardProps>(\n (\n {\n variant = \"outlined\",\n size = \"md\",\n padding,\n sections = \"divided\",\n dividerInset = false,\n highlight = false,\n interactive = false,\n className,\n children,\n ...props\n },\n ref,\n ) => {\n // `padding` stays authoritative over the step `size` implies. That order is\n // what keeps `size` additive: a caller already passing `padding` sees no\n // change, and `padding=\"none\"` still means none.\n const resolvedPadding = padding ?? sizePadding[size];\n\n // The RESOLVED step goes into the context, not `size`. A part that has to\n // meet the content's edge — an inset divider, a `Card.Bleed` — needs the\n // distance the card actually applied, and `size` is only the default.\n const context = useMemo<CardContextValue>(\n () => ({ size, padding: resolvedPadding, sections, dividerInset }),\n [size, resolvedPadding, sections, dividerInset],\n );\n\n return (\n <CardContext.Provider value={context}>\n <div\n ref={ref}\n data-react-fancy-card=\"\"\n className={cn(\n \"bg-[color:var(--fancy-surface,var(--color-white))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n radiusClasses[size],\n variantClasses[variant],\n // A pseudo-element rather than an inset box-shadow: `shadow-*` and\n // `shadow-[inset...]` are the same tailwind-merge group, so an\n // inset shadow here would have SILENTLY DELETED `elevated`'s\n // `shadow-md`. Highlight and elevation have to be able to coexist.\n // `dark:` carries a REAL colour. It was `dark:before:bg-transparent`,\n // which made `highlight` a no-op in the mode that needs it most:\n // a dark surface has no border contrast of its own, and a 10% white\n // top edge is the whole reason Flux turns this on by default.\n highlight &&\n \"relative before:pointer-events-none before:absolute before:inset-x-0 before:top-0 before:h-px before:bg-white/70 dark:before:bg-white/10\",\n // `overflow-hidden` is part of `interactive` rather than always-on:\n // clipping unconditionally would cut off popovers and dropdowns that\n // legitimately overflow a static card.\n interactive &&\n \"overflow-hidden transition hover:-translate-y-0.5 hover:shadow-lg hover:border-zinc-300 dark:hover:border-zinc-600\",\n paddingClasses[resolvedPadding],\n className,\n )}\n {...props}\n >\n {children}\n </div>\n </CardContext.Provider>\n );\n },\n);\n\nCardRoot.displayName = \"Card\";\n\nexport const Card = Object.assign(CardRoot, {\n Media: CardMedia,\n Header: CardHeader,\n Body: CardBody,\n Footer: CardFooter,\n Bleed: CardBleed,\n});\n"]}
@@ -4,11 +4,11 @@ var chunkMRZXTL46_cjs = require('./chunk-MRZXTL46.cjs');
4
4
  var chunkP53432AK_cjs = require('./chunk-P53432AK.cjs');
5
5
  var chunkQF7CD4JH_cjs = require('./chunk-QF7CD4JH.cjs');
6
6
  var chunkO3F6DYWR_cjs = require('./chunk-O3F6DYWR.cjs');
7
+ var chunk6V44RRSB_cjs = require('./chunk-6V44RRSB.cjs');
7
8
  var chunkJ2DI6RMR_cjs = require('./chunk-J2DI6RMR.cjs');
9
+ var chunkTI7D4QDM_cjs = require('./chunk-TI7D4QDM.cjs');
8
10
  var chunkKJ22KE56_cjs = require('./chunk-KJ22KE56.cjs');
9
11
  var chunkL3V3BYVS_cjs = require('./chunk-L3V3BYVS.cjs');
10
- var chunk6V44RRSB_cjs = require('./chunk-6V44RRSB.cjs');
11
- var chunkTI7D4QDM_cjs = require('./chunk-TI7D4QDM.cjs');
12
12
  var chunk57FQGQJK_cjs = require('./chunk-57FQGQJK.cjs');
13
13
  var chunkOUYC6EIL_cjs = require('./chunk-OUYC6EIL.cjs');
14
14
  var chunkZU5Q77OT_cjs = require('./chunk-ZU5Q77OT.cjs');
@@ -528,5 +528,5 @@ var Select = react.forwardRef(
528
528
  Select.displayName = "Select";
529
529
 
530
530
  exports.Select = Select;
531
- //# sourceMappingURL=chunk-7JLKOVHX.cjs.map
532
- //# sourceMappingURL=chunk-7JLKOVHX.cjs.map
531
+ //# sourceMappingURL=chunk-HLI6RB5V.cjs.map
532
+ //# sourceMappingURL=chunk-HLI6RB5V.cjs.map