@misoto22/design 0.8.0 → 0.10.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 (167) hide show
  1. package/dist/agent/Accordion.md +1 -1
  2. package/dist/agent/Alert.md +1 -1
  3. package/dist/agent/AppShell.md +1 -1
  4. package/dist/agent/ArchitectureFigure.md +1 -1
  5. package/dist/agent/AreaChart.md +1 -1
  6. package/dist/agent/Article.md +1 -1
  7. package/dist/agent/AspectRatio.md +1 -1
  8. package/dist/agent/Avatar.md +1 -1
  9. package/dist/agent/Badge.md +1 -1
  10. package/dist/agent/BarChart.md +1 -1
  11. package/dist/agent/BarList.md +1 -1
  12. package/dist/agent/BigNumber.md +1 -1
  13. package/dist/agent/BoxPlot.md +1 -1
  14. package/dist/agent/Breadcrumb.md +1 -1
  15. package/dist/agent/BulletChart.md +1 -1
  16. package/dist/agent/Button.md +1 -1
  17. package/dist/agent/Calendar.md +1 -1
  18. package/dist/agent/Card.md +1 -1
  19. package/dist/agent/Checkbox.md +1 -1
  20. package/dist/agent/Code.md +1 -1
  21. package/dist/agent/CodeBlock.md +1 -1
  22. package/dist/agent/Collapsible.md +1 -1
  23. package/dist/agent/ColorPicker.md +75 -0
  24. package/dist/agent/Combobox.md +1 -1
  25. package/dist/agent/Command.md +1 -1
  26. package/dist/agent/ComposedChart.md +1 -1
  27. package/dist/agent/ContextMenu.md +1 -1
  28. package/dist/agent/DataflowFigure.md +1 -1
  29. package/dist/agent/DatePicker.md +1 -1
  30. package/dist/agent/DescriptionList.md +1 -1
  31. package/dist/agent/Diagram.md +1 -1
  32. package/dist/agent/DiagramCanvas.md +1 -1
  33. package/dist/agent/DiagramExportMenu.md +1 -1
  34. package/dist/agent/DiagramInspector.md +1 -1
  35. package/dist/agent/DiagramLegend.md +1 -1
  36. package/dist/agent/DiagramMinimap.md +1 -1
  37. package/dist/agent/DiagramToolbar.md +1 -1
  38. package/dist/agent/Dialog.md +1 -1
  39. package/dist/agent/DropdownMenu.md +1 -1
  40. package/dist/agent/EmptyState.md +1 -1
  41. package/dist/agent/ErrorState.md +1 -1
  42. package/dist/agent/Facet.md +1 -1
  43. package/dist/agent/Field.md +1 -1
  44. package/dist/agent/FigureBand.md +1 -1
  45. package/dist/agent/FloatingIconButton.md +1 -1
  46. package/dist/agent/FunnelChart.md +1 -1
  47. package/dist/agent/Heading.md +1 -1
  48. package/dist/agent/Heatmap.md +1 -1
  49. package/dist/agent/Histogram.md +1 -1
  50. package/dist/agent/Input.md +1 -1
  51. package/dist/agent/Kbd.md +2 -2
  52. package/dist/agent/LifecycleFigure.md +1 -1
  53. package/dist/agent/LineChart.md +1 -1
  54. package/dist/agent/LinkArrow.md +1 -1
  55. package/dist/agent/Markdown.md +1 -1
  56. package/dist/agent/NativeSelect.md +1 -1
  57. package/dist/agent/NavItem.md +1 -1
  58. package/dist/agent/NumberField.md +72 -0
  59. package/dist/agent/Pagination.md +1 -1
  60. package/dist/agent/PieChart.md +1 -1
  61. package/dist/agent/Popover.md +1 -1
  62. package/dist/agent/Progress.md +1 -1
  63. package/dist/agent/RadarChart.md +1 -1
  64. package/dist/agent/RadialChart.md +1 -1
  65. package/dist/agent/RadioGroup.md +1 -1
  66. package/dist/agent/SankeyChart.md +1 -1
  67. package/dist/agent/ScatterChart.md +1 -1
  68. package/dist/agent/ScrollArea.md +1 -1
  69. package/dist/agent/SearchableMenu.md +1 -1
  70. package/dist/agent/Select.md +1 -1
  71. package/dist/agent/Separator.md +1 -1
  72. package/dist/agent/SequenceFigure.md +1 -1
  73. package/dist/agent/Sheet.md +1 -1
  74. package/dist/agent/Sidebar.md +193 -0
  75. package/dist/agent/Skeleton.md +1 -1
  76. package/dist/agent/Slider.md +7 -3
  77. package/dist/agent/Sparkline.md +1 -1
  78. package/dist/agent/Spinner.md +1 -1
  79. package/dist/agent/StatusDot.md +1 -1
  80. package/dist/agent/StatusPill.md +1 -1
  81. package/dist/agent/Steps.md +1 -1
  82. package/dist/agent/Switch.md +1 -1
  83. package/dist/agent/Table.md +3 -1
  84. package/dist/agent/Tabs.md +1 -1
  85. package/dist/agent/Tag.md +1 -1
  86. package/dist/agent/Text.md +1 -1
  87. package/dist/agent/Textarea.md +1 -1
  88. package/dist/agent/Timestamp.md +1 -1
  89. package/dist/agent/Toast.md +1 -1
  90. package/dist/agent/ToggleGroup.md +1 -1
  91. package/dist/agent/Toolbar.md +1 -1
  92. package/dist/agent/Tooltip.md +1 -1
  93. package/dist/agent/TreemapChart.md +1 -1
  94. package/dist/agent/WaterfallChart.md +1 -1
  95. package/dist/agent/WorkflowFigure.md +1 -1
  96. package/dist/agent/catalog.json +362 -2
  97. package/dist/agent/index.md +9 -6
  98. package/dist/charts/BulletChart/BulletChart.js +16 -2
  99. package/dist/charts/BulletChart/BulletChart.js.map +1 -1
  100. package/dist/charts/RadarChart/RadarChart.js +4 -2
  101. package/dist/charts/RadarChart/RadarChart.js.map +1 -1
  102. package/dist/charts/lib/chart.js +16 -1
  103. package/dist/charts/lib/chart.js.map +1 -1
  104. package/dist/components/AppShell/AppShell.js +2 -2
  105. package/dist/components/AppShell/AppShell.js.map +1 -1
  106. package/dist/components/Button/Button.js +3 -3
  107. package/dist/components/Button/Button.js.map +1 -1
  108. package/dist/components/ColorPicker/ColorPicker.d.ts +67 -0
  109. package/dist/components/ColorPicker/ColorPicker.js +334 -0
  110. package/dist/components/ColorPicker/ColorPicker.js.map +1 -0
  111. package/dist/components/Command/Command.js +1 -1
  112. package/dist/components/Command/Command.js.map +1 -1
  113. package/dist/components/ContextMenu/ContextMenu.js +1 -1
  114. package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
  115. package/dist/components/Dialog/Dialog.js +1 -1
  116. package/dist/components/Dialog/Dialog.js.map +1 -1
  117. package/dist/components/DropdownMenu/DropdownMenu.js +1 -1
  118. package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -1
  119. package/dist/components/ErrorState/ErrorState.js +1 -1
  120. package/dist/components/ErrorState/ErrorState.js.map +1 -1
  121. package/dist/components/Kbd/Kbd.d.ts +7 -0
  122. package/dist/components/Kbd/Kbd.js +1 -1
  123. package/dist/components/Kbd/Kbd.js.map +1 -1
  124. package/dist/components/NavItem/NavItem.js +1 -1
  125. package/dist/components/NavItem/NavItem.js.map +1 -1
  126. package/dist/components/NumberField/NumberField.d.ts +69 -0
  127. package/dist/components/NumberField/NumberField.js +162 -0
  128. package/dist/components/NumberField/NumberField.js.map +1 -0
  129. package/dist/components/Popover/Popover.js +1 -1
  130. package/dist/components/Popover/Popover.js.map +1 -1
  131. package/dist/components/Select/Select.js +1 -1
  132. package/dist/components/Select/Select.js.map +1 -1
  133. package/dist/components/Sheet/Sheet.js +1 -1
  134. package/dist/components/Sheet/Sheet.js.map +1 -1
  135. package/dist/components/Sidebar/Sidebar.d.ts +357 -0
  136. package/dist/components/Sidebar/Sidebar.js +455 -0
  137. package/dist/components/Sidebar/Sidebar.js.map +1 -0
  138. package/dist/components/Slider/Slider.d.ts +22 -1
  139. package/dist/components/Slider/Slider.js +72 -8
  140. package/dist/components/Slider/Slider.js.map +1 -1
  141. package/dist/components/Table/Table.d.ts +14 -0
  142. package/dist/components/Table/Table.js.map +1 -1
  143. package/dist/components/Tabs/Tabs.js +7 -1
  144. package/dist/components/Tabs/Tabs.js.map +1 -1
  145. package/dist/diagrams/lib/route.d.ts +22 -1
  146. package/dist/diagrams/lib/route.js +24 -1
  147. package/dist/diagrams/lib/route.js.map +1 -1
  148. package/dist/diagrams/lib/wires.js +9 -5
  149. package/dist/diagrams/lib/wires.js.map +1 -1
  150. package/dist/index.d.ts +3 -0
  151. package/dist/index.js +3 -0
  152. package/dist/index.js.map +1 -1
  153. package/dist/lib/color.d.ts +80 -0
  154. package/dist/lib/color.js +189 -0
  155. package/dist/lib/color.js.map +1 -0
  156. package/dist/lib/numeric.d.ts +35 -0
  157. package/dist/lib/numeric.js +29 -0
  158. package/dist/lib/numeric.js.map +1 -0
  159. package/dist/semantic.css +4 -2
  160. package/dist/styles.css +1 -1
  161. package/dist/themes.css +99 -0
  162. package/dist/tokens.css +133 -4
  163. package/dist/tokens.d.ts +5 -0
  164. package/dist/tokens.js +31 -3
  165. package/dist/tokens.json +31 -3
  166. package/package.json +1 -1
  167. package/skills/misoto22-design/rules/forms.md +3 -1
@@ -0,0 +1,334 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useId, useRef, useState } from "react";
4
+ import { cn } from "../../lib/cn.js";
5
+ import {
6
+ clamp,
7
+ colorFormat,
8
+ colorToRgb,
9
+ fitGamut,
10
+ formatColor,
11
+ maxChroma,
12
+ parseColor
13
+ } from "../../lib/color.js";
14
+ import { CONTROL_BASE, CONTROL_BORDER, isInvalid } from "../../lib/control.js";
15
+ import { warnBlankName } from "../../lib/warn.js";
16
+ import { useFieldControl } from "../Field/field-control.js";
17
+ import { Input } from "../Input/Input.js";
18
+ import { Popover, PopoverContent, PopoverTrigger } from "../Popover/Popover.js";
19
+ import { ToggleGroup, ToggleGroupItem } from "../ToggleGroup/ToggleGroup.js";
20
+ const PLANE_W = 256;
21
+ const PLANE_H = 160;
22
+ const HUE_STOPS = 73;
23
+ const BLACK = { l: 0, c: 0, h: 0, a: 1 };
24
+ const FORMAT_LABELS = {
25
+ hex: "Hex",
26
+ oklch: "OKLCH",
27
+ // Not "Display P3": the three segments share the strip evenly, and the long
28
+ // name wraps to two lines inside its third and makes the whole row twice as
29
+ // tall as the two beside it.
30
+ p3: "P3"
31
+ };
32
+ const checkerboard = (square) => `repeating-conic-gradient(var(--stone) 0% 25%, var(--paper) 0% 50%) 0 0 / ${square} ${square}`;
33
+ function ColorPicker({
34
+ label,
35
+ value: controlled,
36
+ defaultValue = "#000000",
37
+ onValueChange,
38
+ disabled,
39
+ invalid,
40
+ className,
41
+ id,
42
+ "aria-describedby": describedBy,
43
+ "aria-invalid": ariaInvalid,
44
+ "aria-required": ariaRequired
45
+ }) {
46
+ warnBlankName("ColorPicker", "label", label, "the trigger is announced with no name");
47
+ const bad = isInvalid(invalid, ariaInvalid);
48
+ const field = useFieldControl();
49
+ const generated = useId();
50
+ const triggerId = id ?? generated;
51
+ const valueId = `${triggerId}-value`;
52
+ const nameId = field?.labelId ?? `${triggerId}-name`;
53
+ const [uncontrolled, setUncontrolled] = useState(defaultValue);
54
+ const value = controlled ?? uncontrolled;
55
+ const [color, setColor] = useState(() => parseColor(defaultValue) ?? BLACK);
56
+ const [format, setFormat] = useState(() => colorFormat(defaultValue));
57
+ const emitted = useRef(null);
58
+ const saturationRef = useRef(0);
59
+ useEffect(() => {
60
+ if (value === emitted.current) return;
61
+ const parsed = parseColor(value);
62
+ if (!parsed) return;
63
+ setColor((prev) => ({ ...parsed, h: parsed.c < 1e-7 ? prev.h : parsed.h }));
64
+ setFormat(colorFormat(value));
65
+ }, [value]);
66
+ const space = format === "hex" ? "srgb" : "p3";
67
+ const ceiling = maxChroma(color.l, color.h, space);
68
+ const saturation = ceiling > 0 ? clamp(color.c / ceiling) : saturationRef.current;
69
+ useEffect(() => {
70
+ if (ceiling > 0) saturationRef.current = saturation;
71
+ }, [ceiling, saturation]);
72
+ const commit = (next, nextFormat = format) => {
73
+ const fitted = nextFormat === "oklch" ? next : fitGamut(next, nextFormat === "p3" ? "p3" : "srgb");
74
+ setColor(fitted);
75
+ setFormat(nextFormat);
76
+ const text = formatColor(fitted, nextFormat);
77
+ emitted.current = text;
78
+ if (controlled === void 0) setUncontrolled(text);
79
+ onValueChange?.(text);
80
+ };
81
+ const setPlane = (nextSaturation, lightness) => {
82
+ saturationRef.current = nextSaturation;
83
+ commit({ ...color, l: lightness, c: nextSaturation * maxChroma(lightness, color.h, space) });
84
+ };
85
+ const planeRef = useRef(null);
86
+ const canvasRef = useRef(null);
87
+ const painted = useRef("");
88
+ const trackPointer = (event) => {
89
+ const rect = planeRef.current?.getBoundingClientRect();
90
+ if (!rect || rect.width === 0 || rect.height === 0) return;
91
+ setPlane(
92
+ clamp((event.clientX - rect.left) / rect.width),
93
+ clamp(1 - (event.clientY - rect.top) / rect.height)
94
+ );
95
+ };
96
+ const paint = (canvas) => {
97
+ if (!canvas) return;
98
+ const key = `${color.h.toFixed(3)}:${space}`;
99
+ if (painted.current === key) return;
100
+ const context = canvas.getContext("2d");
101
+ if (!context || typeof context.createImageData !== "function") return;
102
+ painted.current = key;
103
+ const pixels = context.createImageData(PLANE_W, PLANE_H);
104
+ for (let y = 0; y < PLANE_H; y++) {
105
+ const l = 1 - y / (PLANE_H - 1);
106
+ const rowMax = maxChroma(l, color.h, space);
107
+ for (let x = 0; x < PLANE_W; x++) {
108
+ const rgb = colorToRgb({ l, c: x / (PLANE_W - 1) * rowMax, h: color.h, a: 1 }, "srgb");
109
+ const at = (y * PLANE_W + x) * 4;
110
+ for (let channel = 0; channel < 3; channel++) {
111
+ pixels.data[at + channel] = Math.round(clamp(rgb[channel] ?? 0) * 255);
112
+ }
113
+ pixels.data[at + 3] = 255;
114
+ }
115
+ }
116
+ context.putImageData(pixels, 0, 0);
117
+ };
118
+ useEffect(() => {
119
+ paint(canvasRef.current);
120
+ });
121
+ const opaque = formatColor({ ...color, a: 1 }, "oklch");
122
+ const hueTrack = Array.from({ length: HUE_STOPS }, (_, i) => {
123
+ const h = i * (360 / (HUE_STOPS - 1));
124
+ return formatColor({ l: color.l, c: saturation * maxChroma(color.l, h, space), h, a: 1 }, "oklch");
125
+ }).join(", ");
126
+ const typed = parseColor(value);
127
+ return /* @__PURE__ */ jsxs(Popover, { children: [
128
+ /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
129
+ "button",
130
+ {
131
+ type: "button",
132
+ id: triggerId,
133
+ disabled,
134
+ "aria-labelledby": `${nameId} ${valueId}`,
135
+ "aria-describedby": describedBy,
136
+ "aria-required": ariaRequired,
137
+ "aria-invalid": bad || void 0,
138
+ className: cn(
139
+ CONTROL_BASE,
140
+ bad ? CONTROL_BORDER.invalid : CONTROL_BORDER.resting,
141
+ "flex cursor-pointer items-center gap-2.5 text-start",
142
+ className
143
+ ),
144
+ children: [
145
+ field?.labelId == null && /* @__PURE__ */ jsx("span", { id: nameId, className: "sr-only", children: label }),
146
+ /* @__PURE__ */ jsx(
147
+ "span",
148
+ {
149
+ "aria-hidden": "true",
150
+ className: "size-4 shrink-0 rounded-(--radius-xs) border border-(--rule-2)",
151
+ style: { background: `linear-gradient(${value}, ${value}), ${checkerboard("4px")}` }
152
+ }
153
+ ),
154
+ /* @__PURE__ */ jsx("span", { id: valueId, className: "mono-meta truncate", children: value })
155
+ ]
156
+ }
157
+ ) }),
158
+ /* @__PURE__ */ jsxs(PopoverContent, { label: `${label} picker`, className: "flex w-72 flex-col gap-3", children: [
159
+ /* @__PURE__ */ jsx(
160
+ ToggleGroup,
161
+ {
162
+ type: "single",
163
+ value: format,
164
+ onValueChange: (next) => next && commit(color, next),
165
+ "aria-label": "Colour notation",
166
+ className: "w-full",
167
+ children: Object.keys(FORMAT_LABELS).map((option) => /* @__PURE__ */ jsx(ToggleGroupItem, { value: option, className: "flex-1", children: FORMAT_LABELS[option] }, option))
168
+ }
169
+ ),
170
+ /* @__PURE__ */ jsxs(
171
+ "div",
172
+ {
173
+ ref: planeRef,
174
+ role: "group",
175
+ "aria-label": `${label} field`,
176
+ onPointerDown: (event) => {
177
+ if (event.button !== 0) return;
178
+ event.preventDefault();
179
+ event.currentTarget.setPointerCapture(event.pointerId);
180
+ trackPointer(event);
181
+ },
182
+ onPointerMove: (event) => {
183
+ if (event.currentTarget.hasPointerCapture(event.pointerId)) trackPointer(event);
184
+ },
185
+ onPointerUp: (event) => {
186
+ if (event.currentTarget.hasPointerCapture(event.pointerId)) {
187
+ event.currentTarget.releasePointerCapture(event.pointerId);
188
+ }
189
+ },
190
+ className: "relative h-40 w-full cursor-crosshair touch-none select-none rounded-(--radius) focus-within:[outline:var(--focus-w)_solid_var(--focus)] focus-within:[outline-offset:var(--focus-off)]",
191
+ children: [
192
+ /* @__PURE__ */ jsx(
193
+ "canvas",
194
+ {
195
+ ref: (node) => {
196
+ canvasRef.current = node;
197
+ if (!node) painted.current = "";
198
+ paint(node);
199
+ },
200
+ width: PLANE_W,
201
+ height: PLANE_H,
202
+ "aria-hidden": "true",
203
+ className: "block size-full rounded-(--radius)"
204
+ }
205
+ ),
206
+ /* @__PURE__ */ jsx(
207
+ "span",
208
+ {
209
+ "aria-hidden": "true",
210
+ className: "pointer-events-none absolute inset-0 rounded-(--radius) shadow-[inset_0_0_0_1px_var(--rule)]"
211
+ }
212
+ ),
213
+ /* @__PURE__ */ jsx(
214
+ "span",
215
+ {
216
+ "aria-hidden": "true",
217
+ className: "pointer-events-none absolute -m-1.5 size-3 rounded-(--radius-pill) border-2 border-(--paper) shadow-[0_0_0_1px_var(--rule-hard)]",
218
+ style: { left: `${saturation * 100}%`, top: `${(1 - color.l) * 100}%`, background: opaque }
219
+ }
220
+ ),
221
+ /* @__PURE__ */ jsx(
222
+ "input",
223
+ {
224
+ type: "range",
225
+ min: 0,
226
+ max: 100,
227
+ step: 1,
228
+ value: Math.round(saturation * 100),
229
+ "aria-label": "Chroma",
230
+ "aria-valuetext": `${Math.round(saturation * 100)} percent chroma`,
231
+ onChange: (event) => setPlane(Number(event.target.value) / 100, color.l),
232
+ className: "sr-only"
233
+ }
234
+ ),
235
+ /* @__PURE__ */ jsx(
236
+ "input",
237
+ {
238
+ type: "range",
239
+ min: 0,
240
+ max: 100,
241
+ step: 1,
242
+ value: Math.round(color.l * 100),
243
+ "aria-label": "Lightness",
244
+ "aria-valuetext": `${Math.round(color.l * 100)} percent lightness`,
245
+ onChange: (event) => setPlane(saturation, Number(event.target.value) / 100),
246
+ className: "sr-only"
247
+ }
248
+ )
249
+ ]
250
+ }
251
+ ),
252
+ /* @__PURE__ */ jsx(
253
+ ColorTrack,
254
+ {
255
+ name: "Hue",
256
+ max: 360,
257
+ step: 1,
258
+ value: color.h,
259
+ announce: `${Math.round(color.h)} degrees`,
260
+ thumb: opaque,
261
+ track: `linear-gradient(to right in oklab, ${hueTrack})`,
262
+ onChange: (h) => commit({ ...color, h, c: saturation * maxChroma(color.l, h, space) })
263
+ }
264
+ ),
265
+ /* @__PURE__ */ jsx(
266
+ ColorTrack,
267
+ {
268
+ name: "Opacity",
269
+ max: 100,
270
+ step: 1,
271
+ value: color.a * 100,
272
+ announce: `${Math.round(color.a * 100)} percent`,
273
+ thumb: formatColor(color, "oklch"),
274
+ track: `linear-gradient(to right, transparent, ${opaque}), ${checkerboard("8px")}`,
275
+ onChange: (percent) => commit({ ...color, a: percent / 100 })
276
+ }
277
+ ),
278
+ /* @__PURE__ */ jsx(
279
+ Input,
280
+ {
281
+ value,
282
+ spellCheck: false,
283
+ autoComplete: "off",
284
+ "aria-label": `${label} as CSS`,
285
+ invalid: typed === null,
286
+ onChange: (event) => {
287
+ const next = event.target.value;
288
+ emitted.current = next;
289
+ if (controlled === void 0) setUncontrolled(next);
290
+ const parsed = parseColor(next);
291
+ if (parsed) {
292
+ setColor(parsed);
293
+ setFormat(colorFormat(next));
294
+ }
295
+ onValueChange?.(next);
296
+ },
297
+ className: "mono-meta"
298
+ }
299
+ )
300
+ ] })
301
+ ] });
302
+ }
303
+ function ColorTrack({ name, max, step, value, announce, track, thumb, onChange }) {
304
+ return /* @__PURE__ */ jsxs("label", { className: "flex items-center gap-3 text-sm text-(--ink-2)", children: [
305
+ /* @__PURE__ */ jsx("span", { className: "w-14 shrink-0", children: name }),
306
+ /* @__PURE__ */ jsx(
307
+ "input",
308
+ {
309
+ type: "range",
310
+ min: 0,
311
+ max,
312
+ step,
313
+ value,
314
+ "aria-valuetext": announce,
315
+ onChange: (event) => onChange(Number(event.target.value)),
316
+ style: { background: track },
317
+ className: cn(
318
+ "h-4 w-full cursor-pointer appearance-none rounded-(--radius-xs) shadow-[inset_0_0_0_1px_var(--rule)]",
319
+ "[&::-webkit-slider-thumb]:h-6 [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-(--radius-xs) [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-(--paper) [&::-webkit-slider-thumb]:bg-(--thumb) [&::-webkit-slider-thumb]:bg-clip-padding [&::-webkit-slider-thumb]:shadow-[0_0_0_1px_var(--rule-hard)]",
320
+ "[&::-moz-range-thumb]:h-6 [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:rounded-(--radius-xs) [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-(--paper) [&::-moz-range-thumb]:bg-(--thumb) [&::-moz-range-thumb]:bg-clip-padding [&::-moz-range-thumb]:shadow-[0_0_0_1px_var(--rule-hard)]"
321
+ ),
322
+ ref: (node) => {
323
+ node?.style.setProperty("--thumb", thumb);
324
+ }
325
+ }
326
+ )
327
+ ] });
328
+ }
329
+ var ColorPicker_default = ColorPicker;
330
+ export {
331
+ ColorPicker,
332
+ ColorPicker_default as default
333
+ };
334
+ //# sourceMappingURL=ColorPicker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/ColorPicker/ColorPicker.tsx"],"sourcesContent":["'use client'\n\nimport { useEffect, useId, useRef, useState, type PointerEvent } from 'react'\nimport { cn } from '../../lib/cn'\nimport {\n clamp,\n colorFormat,\n colorToRgb,\n fitGamut,\n formatColor,\n maxChroma,\n parseColor,\n type Color,\n type ColorFormat,\n type ColorSpace,\n} from '../../lib/color'\nimport { CONTROL_BASE, CONTROL_BORDER, isInvalid } from '../../lib/control'\nimport { warnBlankName } from '../../lib/warn'\nimport { useFieldControl } from '../Field/field-control'\nimport { Input } from '../Input/Input'\nimport { Popover, PopoverContent, PopoverTrigger } from '../Popover/Popover'\nimport { ToggleGroup, ToggleGroupItem } from '../ToggleGroup/ToggleGroup'\n\n/** The plane's pixel grid. Wider than it is tall, like the panel holding it. */\nconst PLANE_W = 256\nconst PLANE_H = 160\n\n/** Hue stops in the strip behind the hue slider. Every 5°, plus the wrap. */\nconst HUE_STOPS = 73\n\nconst BLACK: Color = { l: 0, c: 0, h: 0, a: 1 }\n\nconst FORMAT_LABELS: Record<ColorFormat, string> = {\n hex: 'Hex',\n oklch: 'OKLCH',\n // Not \"Display P3\": the three segments share the strip evenly, and the long\n // name wraps to two lines inside its third and makes the whole row twice as\n // tall as the two beside it.\n p3: 'P3',\n}\n\n/**\n * A checkerboard, so alpha reads as alpha rather than as a lighter colour.\n *\n * Sized per surface: 8px checks read as a texture behind a full-width track and\n * as two grey squares inside a 16px swatch.\n */\nconst checkerboard = (square: string) =>\n `repeating-conic-gradient(var(--stone) 0% 25%, var(--paper) 0% 50%) 0 0 / ${square} ${square}`\n\nexport interface ColorPickerProps {\n /**\n * Names the control. Required — the trigger shows a colour, and a colour is\n * not a name.\n *\n * Announced together with the value, the way `Select`'s is: a reader hears\n * \"Brand colour, #a78bfa\". Inside a `Field` with a label, that label is used\n * and this one is not repeated.\n */\n label: string\n /** The colour, as any absolute CSS colour string. */\n value?: string\n defaultValue?: string\n /**\n * Fires with a CSS colour string in whichever notation the panel is set to —\n * so the notation a caller passes in is the notation they get back until\n * somebody changes it in the panel.\n */\n onValueChange?: (value: string) => void\n disabled?: boolean\n /** Paints the resting border with `--danger` and reflects `aria-invalid`. */\n invalid?: boolean\n className?: string\n /** The TRIGGER's id — the element a label points at. A `Field` sets it. */\n id?: string\n /** Ids of the copy describing the control. A `Field` sets it from hint, error and description. */\n 'aria-describedby'?: string\n /** The spelling a form library sets; read together with `invalid`. */\n 'aria-invalid'?: boolean | 'true' | 'false'\n /** Announced on the trigger. A `Field` sets it from `required`. */\n 'aria-required'?: boolean\n}\n\n/**\n * A colour, chosen or typed.\n *\n * The panel works in OKLCH, and that is the reason to reach for this rather\n * than `<input type=\"color\">`. In HSV — which is what the native picker and\n * most libraries use — dragging along a row of constant \"lightness\" walks\n * through colours the eye reads as getting darker, so a reader tuning a palette\n * is fighting the instrument. OKLCH's lightness is the one a person sees, so\n * two colours at the same height on the plane genuinely match, and the hue\n * strip stays at the lightness already chosen instead of showing a rainbow that\n * belongs to some other colour.\n *\n * The plane is normalised to the gamut ROW BY ROW: its right edge is the most\n * chroma that exists at that lightness and hue, so the whole surface is\n * reachable rather than a lens of colour inside a field of clipped duplicates.\n *\n * **What it accepts.** Hex, `rgb()`, `hsl()`, `oklch()` and\n * `color(display-p3 …)`, in both syntaxes. Named colours are not accepted:\n * resolving them needs a table of every CSS name or a live DOM, and a box that\n * takes \"rebeccapurple\" but not \"papayawhip\" is worse than one that takes\n * neither.\n *\n * **Keyboard.** The plane is a group of two real sliders — chroma across,\n * lightness up — so the arrows move it and a screen reader announces where it\n * is. That is the part a 2D canvas usually leaves out, and leaving it out makes\n * the control unusable rather than merely awkward.\n *\n * @example\n * <Field label=\"Brand colour\"><ColorPicker label=\"Brand colour\" defaultValue=\"#a78bfa\" /></Field>\n */\nexport function ColorPicker({\n label,\n value: controlled,\n defaultValue = '#000000',\n onValueChange,\n disabled,\n invalid,\n className,\n id,\n 'aria-describedby': describedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n}: ColorPickerProps) {\n warnBlankName('ColorPicker', 'label', label, 'the trigger is announced with no name')\n const bad = isInvalid(invalid, ariaInvalid)\n\n const field = useFieldControl()\n const generated = useId()\n const triggerId = id ?? generated\n const valueId = `${triggerId}-value`\n const nameId = field?.labelId ?? `${triggerId}-name`\n\n const [uncontrolled, setUncontrolled] = useState(defaultValue)\n const value = controlled ?? uncontrolled\n\n const [color, setColor] = useState<Color>(() => parseColor(defaultValue) ?? BLACK)\n const [format, setFormat] = useState<ColorFormat>(() => colorFormat(defaultValue))\n // What this component last wrote out, so its own emission does not read back\n // as an outside change and re-derive the hue it just preserved.\n const emitted = useRef<string | null>(null)\n\n // The plane's horizontal position, kept across the two rows where it cannot\n // be derived: at pure black and pure white every chroma is zero, so `c / max`\n // is 0/0 and the handle would jump to the left edge on the way past.\n const saturationRef = useRef(0)\n\n useEffect(() => {\n if (value === emitted.current) return\n const parsed = parseColor(value)\n if (!parsed) return\n // A grey has no hue — only the angle of its rounding error. Keeping the\n // last real one is what stops the strip spinning when a reader drags the\n // handle through the neutral column.\n setColor((prev) => ({ ...parsed, h: parsed.c < 1e-7 ? prev.h : parsed.h }))\n setFormat(colorFormat(value))\n }, [value])\n\n // Hex is bounded to sRGB; both of the others can address the wider gamut, so\n // the plane shows what the notation can actually hold.\n const space: ColorSpace = format === 'hex' ? 'srgb' : 'p3'\n const ceiling = maxChroma(color.l, color.h, space)\n const saturation = ceiling > 0 ? clamp(color.c / ceiling) : saturationRef.current\n\n useEffect(() => {\n if (ceiling > 0) saturationRef.current = saturation\n }, [ceiling, saturation])\n\n const commit = (next: Color, nextFormat: ColorFormat = format) => {\n const fitted = nextFormat === 'oklch' ? next : fitGamut(next, nextFormat === 'p3' ? 'p3' : 'srgb')\n setColor(fitted)\n setFormat(nextFormat)\n const text = formatColor(fitted, nextFormat)\n emitted.current = text\n if (controlled === undefined) setUncontrolled(text)\n onValueChange?.(text)\n }\n\n /** Moves the plane handle, in the 0–1 coordinates the plane is drawn in. */\n const setPlane = (nextSaturation: number, lightness: number) => {\n saturationRef.current = nextSaturation\n commit({ ...color, l: lightness, c: nextSaturation * maxChroma(lightness, color.h, space) })\n }\n\n const planeRef = useRef<HTMLDivElement>(null)\n const canvasRef = useRef<HTMLCanvasElement>(null)\n const painted = useRef<string>('')\n\n const trackPointer = (event: PointerEvent<HTMLDivElement>) => {\n const rect = planeRef.current?.getBoundingClientRect()\n if (!rect || rect.width === 0 || rect.height === 0) return\n setPlane(\n clamp((event.clientX - rect.left) / rect.width),\n clamp(1 - (event.clientY - rect.top) / rect.height),\n )\n }\n\n /**\n * Fills the plane, at most once per hue.\n *\n * Called from the canvas's own ref callback rather than only from an effect,\n * because the canvas does not exist until the panel is open AND Radix's\n * popper has measured it — which is a commit later than the one that opened\n * it. An effect keyed to the open state runs on the commit BEFORE the node\n * arrives, finds a ref holding null, and never runs again: a plane that\n * stayed blank until the reader happened to move the hue.\n */\n const paint = (canvas: HTMLCanvasElement | null) => {\n if (!canvas) return\n const key = `${color.h.toFixed(3)}:${space}`\n if (painted.current === key) return\n const context = canvas.getContext('2d')\n // A headless environment can hand back a 2D context with most of the\n // drawing surface missing. Nothing here is load-bearing — the plane is the\n // pointer's aim, and the two sliders under it work either way — so a\n // partial context means no plane rather than a thrown render.\n if (!context || typeof context.createImageData !== 'function') return\n painted.current = key\n\n const pixels = context.createImageData(PLANE_W, PLANE_H)\n for (let y = 0; y < PLANE_H; y++) {\n const l = 1 - y / (PLANE_H - 1)\n // Each row is normalised to its OWN reachable chroma. Painted against one\n // global maximum instead, the top and bottom thirds of the plane are\n // bands of clipped duplicates a reader can never pick apart.\n const rowMax = maxChroma(l, color.h, space)\n for (let x = 0; x < PLANE_W; x++) {\n const rgb = colorToRgb({ l, c: (x / (PLANE_W - 1)) * rowMax, h: color.h, a: 1 }, 'srgb')\n const at = (y * PLANE_W + x) * 4\n for (let channel = 0; channel < 3; channel++) {\n pixels.data[at + channel] = Math.round(clamp(rgb[channel] ?? 0) * 255)\n }\n pixels.data[at + 3] = 255\n }\n }\n context.putImageData(pixels, 0, 0)\n }\n\n /** Repaints a canvas that is already on screen when the hue moves under it. */\n useEffect(() => {\n paint(canvasRef.current)\n })\n\n const opaque = formatColor({ ...color, a: 1 }, 'oklch')\n const hueTrack = Array.from({ length: HUE_STOPS }, (_, i) => {\n const h = i * (360 / (HUE_STOPS - 1))\n return formatColor({ l: color.l, c: saturation * maxChroma(color.l, h, space), h, a: 1 }, 'oklch')\n }).join(', ')\n\n const typed = parseColor(value)\n\n return (\n <Popover>\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n id={triggerId}\n disabled={disabled}\n // Named by the label AND by its own value, in that order — the same\n // arrangement Select uses, and for the same reason: `aria-label`\n // outranks the content, so naming it \"Brand colour\" would tell a\n // reader the noun and never the answer.\n aria-labelledby={`${nameId} ${valueId}`}\n aria-describedby={describedBy}\n aria-required={ariaRequired}\n aria-invalid={bad || undefined}\n className={cn(\n CONTROL_BASE,\n bad ? CONTROL_BORDER.invalid : CONTROL_BORDER.resting,\n 'flex cursor-pointer items-center gap-2.5 text-start',\n className,\n )}\n >\n {/* Standing outside a Field there is no label to point at, so the\n trigger carries its own — the name half of the two the\n `aria-labelledby` above names, with the value as the other. */}\n {field?.labelId == null && (\n <span id={nameId} className=\"sr-only\">\n {label}\n </span>\n )}\n <span\n aria-hidden=\"true\"\n className=\"size-4 shrink-0 rounded-(--radius-xs) border border-(--rule-2)\"\n // The colour as a flat GRADIENT, not as a colour. In the\n // `background` shorthand a plain colour is only legal in the last\n // layer, so `background: #a78bfa, <checks>` is invalid and the\n // whole declaration is dropped — which drew an empty swatch.\n style={{ background: `linear-gradient(${value}, ${value}), ${checkerboard('4px')}` }}\n />\n <span id={valueId} className=\"mono-meta truncate\">\n {value}\n </span>\n </button>\n </PopoverTrigger>\n\n <PopoverContent label={`${label} picker`} className=\"flex w-72 flex-col gap-3\">\n <ToggleGroup\n type=\"single\"\n value={format}\n // `type=\"single\"` commits an empty string when the pressed segment is\n // the selected one, which here would leave the panel with no notation\n // to write in at all.\n onValueChange={(next) => next && commit(color, next as ColorFormat)}\n aria-label=\"Colour notation\"\n className=\"w-full\"\n >\n {(Object.keys(FORMAT_LABELS) as ColorFormat[]).map((option) => (\n <ToggleGroupItem key={option} value={option} className=\"flex-1\">\n {FORMAT_LABELS[option]}\n </ToggleGroupItem>\n ))}\n </ToggleGroup>\n\n {/* A group of two real sliders rather than a canvas with key handlers:\n the arrows, Home and End are then the platform's, and a reader is\n told which axis they are on and where they are along it. The canvas\n underneath is what a pointer aims at. */}\n <div\n ref={planeRef}\n role=\"group\"\n aria-label={`${label} field`}\n onPointerDown={(event) => {\n if (event.button !== 0) return\n event.preventDefault()\n event.currentTarget.setPointerCapture(event.pointerId)\n trackPointer(event)\n }}\n onPointerMove={(event) => {\n if (event.currentTarget.hasPointerCapture(event.pointerId)) trackPointer(event)\n }}\n onPointerUp={(event) => {\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId)\n }\n }}\n // The focus ring has to be drawn HERE: the two sliders that take the\n // focus are `sr-only`, so the one the browser draws on them is\n // clipped away with the rest of the box.\n className=\"relative h-40 w-full cursor-crosshair touch-none select-none rounded-(--radius) focus-within:[outline:var(--focus-w)_solid_var(--focus)] focus-within:[outline-offset:var(--focus-off)]\"\n >\n <canvas\n ref={(node) => {\n canvasRef.current = node\n // Closing destroys the canvas and its bitmap with it, so the next\n // open has to repaint even at the same hue.\n if (!node) painted.current = ''\n paint(node)\n }}\n width={PLANE_W}\n height={PLANE_H}\n aria-hidden=\"true\"\n className=\"block size-full rounded-(--radius)\"\n />\n {/* A hairline over the plane, so the light corner still has an edge. */}\n <span\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-0 rounded-(--radius) shadow-[inset_0_0_0_1px_var(--rule)]\"\n />\n <span\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute -m-1.5 size-3 rounded-(--radius-pill) border-2 border-(--paper) shadow-[0_0_0_1px_var(--rule-hard)]\"\n style={{ left: `${saturation * 100}%`, top: `${(1 - color.l) * 100}%`, background: opaque }}\n />\n <input\n type=\"range\"\n min={0}\n max={100}\n step={1}\n value={Math.round(saturation * 100)}\n aria-label=\"Chroma\"\n aria-valuetext={`${Math.round(saturation * 100)} percent chroma`}\n onChange={(event) => setPlane(Number(event.target.value) / 100, color.l)}\n className=\"sr-only\"\n />\n <input\n type=\"range\"\n min={0}\n max={100}\n step={1}\n value={Math.round(color.l * 100)}\n aria-label=\"Lightness\"\n aria-valuetext={`${Math.round(color.l * 100)} percent lightness`}\n onChange={(event) => setPlane(saturation, Number(event.target.value) / 100)}\n className=\"sr-only\"\n />\n </div>\n\n <ColorTrack\n name=\"Hue\"\n max={360}\n step={1}\n value={color.h}\n announce={`${Math.round(color.h)} degrees`}\n thumb={opaque}\n track={`linear-gradient(to right in oklab, ${hueTrack})`}\n onChange={(h) => commit({ ...color, h, c: saturation * maxChroma(color.l, h, space) })}\n />\n <ColorTrack\n name=\"Opacity\"\n max={100}\n step={1}\n value={color.a * 100}\n announce={`${Math.round(color.a * 100)} percent`}\n thumb={formatColor(color, 'oklch')}\n track={`linear-gradient(to right, transparent, ${opaque}), ${checkerboard('8px')}`}\n onChange={(percent) => commit({ ...color, a: percent / 100 })}\n />\n\n <Input\n value={value}\n spellCheck={false}\n autoComplete=\"off\"\n aria-label={`${label} as CSS`}\n invalid={typed === null}\n onChange={(event) => {\n const next = event.target.value\n emitted.current = next\n if (controlled === undefined) setUncontrolled(next)\n const parsed = parseColor(next)\n if (parsed) {\n setColor(parsed)\n setFormat(colorFormat(next))\n }\n onValueChange?.(next)\n }}\n className=\"mono-meta\"\n />\n </PopoverContent>\n </Popover>\n )\n}\n\ninterface ColorTrackProps {\n name: string\n max: number\n step: number\n value: number\n /** What the number MEANS, since a bare \"212\" on a hue slider is not a reading. */\n announce: string\n /** CSS for the strip behind the thumb. */\n track: string\n /** The colour the thumb is filled with. */\n thumb: string\n onChange: (value: number) => void\n}\n\n/**\n * One channel of the picker, as a native range input.\n *\n * Native rather than this system's `Slider`, and deliberately: the whole point\n * of these two is the strip BEHIND the thumb — a hue ramp taken at the current\n * lightness, an opacity ramp over a checkerboard — and Radix's track is not a\n * surface a caller can paint. A native range gives the same keyboard contract\n * for nothing, which is what made the trade worth taking.\n */\nfunction ColorTrack({ name, max, step, value, announce, track, thumb, onChange }: ColorTrackProps) {\n return (\n <label className=\"flex items-center gap-3 text-sm text-(--ink-2)\">\n <span className=\"w-14 shrink-0\">{name}</span>\n <input\n type=\"range\"\n min={0}\n max={max}\n step={step}\n value={value}\n aria-valuetext={announce}\n onChange={(event) => onChange(Number(event.target.value))}\n style={{ background: track }}\n className={cn(\n 'h-4 w-full cursor-pointer appearance-none rounded-(--radius-xs) shadow-[inset_0_0_0_1px_var(--rule)]',\n '[&::-webkit-slider-thumb]:h-6 [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-(--radius-xs) [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-(--paper) [&::-webkit-slider-thumb]:bg-(--thumb) [&::-webkit-slider-thumb]:bg-clip-padding [&::-webkit-slider-thumb]:shadow-[0_0_0_1px_var(--rule-hard)]',\n '[&::-moz-range-thumb]:h-6 [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:rounded-(--radius-xs) [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-(--paper) [&::-moz-range-thumb]:bg-(--thumb) [&::-moz-range-thumb]:bg-clip-padding [&::-moz-range-thumb]:shadow-[0_0_0_1px_var(--rule-hard)]',\n )}\n // Read by both thumb rules above; a pseudo-element cannot take a style\n // attribute of its own, so the colour has to arrive as a variable.\n ref={(node) => {\n node?.style.setProperty('--thumb', thumb)\n }}\n />\n </label>\n )\n}\n\nexport default ColorPicker\n"],"mappings":";AAgQQ,SAuBI,KAvBJ;AA9PR,SAAS,WAAW,OAAO,QAAQ,gBAAmC;AACtE,SAAS,UAAU;AACnB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,cAAc,gBAAgB,iBAAiB;AACxD,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC,SAAS,aAAa;AACtB,SAAS,SAAS,gBAAgB,sBAAsB;AACxD,SAAS,aAAa,uBAAuB;AAG7C,MAAM,UAAU;AAChB,MAAM,UAAU;AAGhB,MAAM,YAAY;AAElB,MAAM,QAAe,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE;AAE9C,MAAM,gBAA6C;AAAA,EACjD,KAAK;AAAA,EACL,OAAO;AAAA;AAAA;AAAA;AAAA,EAIP,IAAI;AACN;AAQA,MAAM,eAAe,CAAC,WACpB,4EAA4E,MAAM,IAAI,MAAM;AAiEvF,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA,OAAO;AAAA,EACP,eAAe;A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AK;AAAA,IACtC;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,KAAK;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA,kBAAgB;AAAA,QAChB,UAAU,CAAC,UAAU,SAAS,OAAO,MAAM,OAAO,KAAK,CAAC;AAAA,QACxD,OAAO,EAAE,YAAY,MAAM;AAAA,QAC3B,WAAW;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,QAGA,KAAK,CAAC,SAAS;AACb,gBAAM,MAAM,YAAY,WAAW,KAAK;AAAA,QAC1C;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;AAEA,IAAO,sBAAQ;","names":[]}
@@ -25,7 +25,7 @@ function Command({
25
25
  CommandPrimitive,
26
26
  {
27
27
  className: cn(
28
- "flex w-full flex-col overflow-hidden rounded-(--radius-lg) border border-(--panel-border) bg-(--panel-bg) panel-blur",
28
+ "flex w-full flex-col overflow-hidden rounded-(--radius-lg) border border-(--panel-border) bg-(--panel-bg) shadow-(--panel-lift) panel-blur",
29
29
  className
30
30
  ),
31
31
  ...props
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Command/Command.tsx"],"sourcesContent":["'use client'\n\nimport { Command as CommandPrimitive } from 'cmdk'\nimport { Search, type LucideIcon } from 'lucide-react'\nimport { isValidElement, type ComponentProps, type ReactNode } from 'react'\nimport { cn } from '../../lib/cn'\n\n/**\n * True for a component type — `icon={Settings}` — rather than a rendered element.\n *\n * Everything a `ReactNode` can be is an element, a primitive, an array, another\n * iterable or a promise; a Lucide icon is none of those, it is a `forwardRef`\n * object. So both spellings are tellable apart at runtime, which is what lets\n * one prop take either — and it has to, because this prop meant the opposite\n * thing one import away and the wrong spelling failed at render, not at the\n * type.\n */\nfunction isIconComponent(icon: LucideIcon | ReactNode): icon is LucideIcon {\n if (isValidElement(icon)) return false\n if (typeof icon === 'function') return true\n if (typeof icon !== 'object' || icon === null) return false\n return !Array.isArray(icon) && !(Symbol.iterator in icon) && !('then' in icon)\n}\n\n/** The leading glyph, sized by this component when it was handed a component. */\nfunction iconNode(icon: LucideIcon | ReactNode): ReactNode {\n if (!isIconComponent(icon)) return icon\n const Icon = icon\n return <Icon size={16} strokeWidth={1.5} aria-hidden />\n}\nimport { Dialog, DialogContent } from '../Dialog/Dialog'\nimport { Kbd } from '../Kbd/Kbd'\n\n/**\n * A filterable list of actions — the ⌘K surface.\n *\n * Built on cmdk rather than on a `Select` or a menu, because the interaction is\n * neither: the list is filtered as you type, the highlighted row moves with the\n * arrow keys while focus STAYS in the input, and Enter runs the highlighted\n * row. That is the ARIA combobox pattern, and it is the part nobody should\n * hand-roll — `aria-activedescendant` moving without focus moving is precisely\n * where a home-made palette stops working with a screen reader.\n *\n * @example\n * <Command label=\"Command palette\">\n * <CommandInput placeholder=\"Type a command…\" />\n * <CommandList>\n * <CommandEmpty>Nothing matches.</CommandEmpty>\n * <CommandGroup heading=\"Navigate\">\n * <CommandItem onSelect={go}>Components</CommandItem>\n * </CommandGroup>\n * </CommandList>\n * </Command>\n */\nexport function Command({\n className,\n ...props\n}: ComponentProps<typeof CommandPrimitive>) {\n return (\n <CommandPrimitive\n className={cn(\n 'flex w-full flex-col overflow-hidden rounded-(--radius-lg) border border-(--panel-border) bg-(--panel-bg) panel-blur',\n className,\n )}\n {...props}\n />\n )\n}\n\n/** The filter field. Carries the search icon and the combobox semantics. */\nexport function CommandInput({\n className,\n ...props\n}: ComponentProps<typeof CommandPrimitive.Input>) {\n return (\n <div className=\"flex items-center gap-3 border-b border-(--rule) px-4\">\n <Search size={18} strokeWidth={1.5} aria-hidden className=\"shrink-0 text-(--ink-3-aa)\" />\n <CommandPrimitive.Input\n className={cn(\n 'h-13 w-full bg-transparent text-[15px] text-(--ink) outline-none placeholder:text-(--ink-3-aa)',\n className,\n )}\n {...props}\n />\n </div>\n )\n}\n\nexport function CommandList({\n className,\n ...props\n}: ComponentProps<typeof CommandPrimitive.List>) {\n return (\n <CommandPrimitive.List\n className={cn('max-h-72 overflow-y-auto overflow-x-hidden p-2 scroll-slim', className)}\n {...props}\n />\n )\n}\n\n/** Shown when the filter matches nothing. Say what would match, not \"no results\". */\nexport function CommandEmpty(props: ComponentProps<typeof CommandPrimitive.Empty>) {\n return (\n <CommandPrimitive.Empty\n className=\"px-3 py-10 text-center text-sm text-(--ink-3-aa)\"\n {...props}\n />\n )\n}\n\n/**\n * The key-hint strip along the bottom.\n *\n * A palette is a keyboard surface whose keys are invisible: nothing on screen\n * says the arrows move the row or that Enter runs it, and a reader who reaches\n * for the mouse has been failed by the design rather than by themselves.\n *\n * @example\n * <CommandFooter>\n * <CommandHint keys={['↑', '↓']}>navigate</CommandHint>\n * <CommandHint keys={['↵']}>open</CommandHint>\n * </CommandFooter>\n */\nexport function CommandFooter({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n className={cn(\n 'flex items-center gap-4 border-t border-(--rule) bg-(--paper-2) px-3.5 py-2',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport interface CommandHintProps extends Omit<ComponentProps<'span'>, 'children'> {\n /** The keys this hint describes, printed as `Kbd` chips. */\n keys: string[]\n /** What they do — a verb, lowercase, no sentence. */\n children: ReactNode\n}\n\n/** One key-and-verb pair inside a `CommandFooter`. */\nexport function CommandHint({ keys, children, className, ...props }: CommandHintProps) {\n return (\n <span className={cn('flex items-center gap-1.5 mono-meta text-(--ink-3-aa)', className)} {...props}>\n {keys.map((key) => (\n <Kbd key={key}>{key}</Kbd>\n ))}\n {children}\n </span>\n )\n}\n\nexport function CommandGroup({\n className,\n ...props\n}: ComponentProps<typeof CommandPrimitive.Group>) {\n return (\n <CommandPrimitive.Group\n className={cn(\n 'overflow-hidden [&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:eyebrow [&_[cmdk-group-heading]]:text-(--ink-3-aa)',\n className,\n )}\n {...props}\n />\n )\n}\n\n/**\n * A divider between groups.\n *\n * Marked presentational, because ARIA permits a `listbox` to contain only\n * `option` and `group` — and the library renders this as `role=\"separator\"`,\n * which puts a critical `aria-required-children` violation inside every palette\n * that uses one. The grouping is already announced by the groups themselves, so\n * removing the divider from the accessibility tree loses nothing.\n */\nexport function CommandSeparator({\n className,\n ...props\n}: ComponentProps<typeof CommandPrimitive.Separator>) {\n return (\n <CommandPrimitive.Separator\n role=\"presentation\"\n aria-hidden=\"true\"\n className={cn('my-1 h-px bg-(--rule)', className)}\n {...props}\n />\n )\n}\n\nexport interface CommandItemProps extends ComponentProps<typeof CommandPrimitive.Item> {\n /** A shortcut printed at the end of the row. */\n shortcut?: string\n /**\n * A leading glyph. Either spelling — `icon={<Settings size={16} />}` passes\n * the element, `icon={Settings}` passes the component and this sizes it.\n *\n * It is what makes a long list scannable — the eye sorts by shape before it\n * reads, and forty identical rows of text defeat that.\n */\n icon?: LucideIcon | ReactNode\n /**\n * A quiet note at the end of the row — what kind of thing this is, or its\n * current state. Not a description: a palette that prints a sentence per row\n * stops being scannable at about six of them.\n */\n meta?: ReactNode\n}\n\nexport function CommandItem({ shortcut, icon, meta, className, children, ...props }: CommandItemProps) {\n return (\n <CommandPrimitive.Item\n className={cn(\n 'flex cursor-pointer items-center gap-3 rounded-(--radius-row) px-3 py-2.5 text-[15px] text-(--ink-2) outline-none transition-colors duration-(--duration-fast)',\n // The highlighted row is a chosen state, and law 7 says a chosen state\n // reads --accent. The leading rule gives it an edge the eye catches\n // while scrolling, which a fill alone does not.\n 'relative data-[selected=true]:bg-(--accent-muted) data-[selected=true]:text-(--ink)',\n 'before:absolute before:inset-y-1 before:start-0 before:w-0.5 before:rounded-(--radius-pill) before:bg-transparent data-[selected=true]:before:bg-(--accent)',\n 'data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-(--disabled-opacity)',\n className,\n )}\n {...props}\n >\n {icon && (\n <span className=\"grid size-4 shrink-0 place-items-center text-(--ink-3-aa) [&_svg]:size-4\">\n {iconNode(icon)}\n </span>\n )}\n {children}\n {meta && <span className=\"ms-auto ps-3 mono-meta text-(--ink-3-aa)\">{meta}</span>}\n {shortcut && <Kbd className={cn(meta ? '' : 'ms-auto')}>{shortcut}</Kbd>}\n </CommandPrimitive.Item>\n )\n}\n\nexport interface CommandDialogProps {\n open: boolean\n onOpenChange: (open: boolean) => void\n /** Names the palette for assistive tech. */\n label: string\n children: ReactNode\n}\n\n/**\n * The palette in a modal, which is how it is nearly always used.\n *\n * The dialog's own padding is removed: a palette is edge-to-edge, and its input\n * is the first thing focus lands on.\n */\nexport function CommandDialog({ open, onOpenChange, label, children }: CommandDialogProps) {\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent\n title={label}\n hideTitle\n showClose={false}\n // Above centre, not at it. A palette is read as a layer over the page\n // rather than as a message about it, and centring it puts the list\n // under the reader's own hands on a laptop.\n // `scrollbar-gutter: auto` undoes the `stable` that `Dialog`'s own\n // `scroll-slim` sets. The dialog never scrolls — the list inside it\n // does — but the reserved gutter was still there, so the list stopped\n // thirteen pixels short of the panel and drew its own hairline inside\n // an empty channel. Two bars, one of them permanently blank.\n className=\"top-[10vh] w-[min(94vw,44rem)] translate-y-0 overflow-hidden p-0 [scrollbar-gutter:auto]\"\n >\n {/* The modal has the whole screen, so its list may be taller than the\n default an inline menu should keep.\n\n `scroll-hairline` rather than `scroll-slim`: eleven pixels of grey\n down the side of a palette is the widest thing in it. */}\n <Command\n label={label}\n className=\"rounded-none border-0 [&_[cmdk-list]]:max-h-[26rem] [&_[cmdk-list]]:scroll-hairline\"\n >\n {children}\n </Command>\n </DialogContent>\n </Dialog>\n )\n}\n\nexport default Command\n"],"mappings":";AA4BS,cA+CL,YA/CK;AA1BT,SAAS,WAAW,wBAAwB;AAC5C,SAAS,cAA+B;AACxC,SAAS,sBAA2D;AACpE,SAAS,UAAU;AAYnB,SAAS,gBAAgB,MAAkD;AACzE,MAAI,eAAe,IAAI,EAAG,QAAO;AACjC,MAAI,OAAO,SAAS,WAAY,QAAO;AACvC,MAAI,OAAO,SAAS,Y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E,oBAAC,UAAO,MAAY,cAClB;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,MACP,WAAS;AAAA,MACT,WAAW;AAAA,MASX,WAAU;AAAA,MAOV;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,WAAU;AAAA,UAET;AAAA;AAAA,MACH;AAAA;AAAA,EACF,GACF;AAEJ;AAEA,IAAO,kBAAQ;","names":[]}
1
+ {"version":3,"sources":["../../../src/components/Command/Command.tsx"],"sourcesContent":["'use client'\n\nimport { Command as CommandPrimitive } from 'cmdk'\nimport { Search, type LucideIcon } from 'lucide-react'\nimport { isValidElement, type ComponentProps, type ReactNode } from 'react'\nimport { cn } from '../../lib/cn'\n\n/**\n * True for a component type — `icon={Settings}` — rather than a rendered element.\n *\n * Everything a `ReactNode` can be is an element, a primitive, an array, another\n * iterable or a promise; a Lucide icon is none of those, it is a `forwardRef`\n * object. So both spellings are tellable apart at runtime, which is what lets\n * one prop take either — and it has to, because this prop meant the opposite\n * thing one import away and the wrong spelling failed at render, not at the\n * type.\n */\nfunction isIconComponent(icon: LucideIcon | ReactNode): icon is LucideIcon {\n if (isValidElement(icon)) return false\n if (typeof icon === 'function') return true\n if (typeof icon !== 'object' || icon === null) return false\n return !Array.isArray(icon) && !(Symbol.iterator in icon) && !('then' in icon)\n}\n\n/** The leading glyph, sized by this component when it was handed a component. */\nfunction iconNode(icon: LucideIcon | ReactNode): ReactNode {\n if (!isIconComponent(icon)) return icon\n const Icon = icon\n return <Icon size={16} strokeWidth={1.5} aria-hidden />\n}\nimport { Dialog, DialogContent } from '../Dialog/Dialog'\nimport { Kbd } from '../Kbd/Kbd'\n\n/**\n * A filterable list of actions — the ⌘K surface.\n *\n * Built on cmdk rather than on a `Select` or a menu, because the interaction is\n * neither: the list is filtered as you type, the highlighted row moves with the\n * arrow keys while focus STAYS in the input, and Enter runs the highlighted\n * row. That is the ARIA combobox pattern, and it is the part nobody should\n * hand-roll — `aria-activedescendant` moving without focus moving is precisely\n * where a home-made palette stops working with a screen reader.\n *\n * @example\n * <Command label=\"Command palette\">\n * <CommandInput placeholder=\"Type a command…\" />\n * <CommandList>\n * <CommandEmpty>Nothing matches.</CommandEmpty>\n * <CommandGroup heading=\"Navigate\">\n * <CommandItem onSelect={go}>Components</CommandItem>\n * </CommandGroup>\n * </CommandList>\n * </Command>\n */\nexport function Command({\n className,\n ...props\n}: ComponentProps<typeof CommandPrimitive>) {\n return (\n <CommandPrimitive\n className={cn(\n 'flex w-full flex-col overflow-hidden rounded-(--radius-lg) border border-(--panel-border) bg-(--panel-bg) shadow-(--panel-lift) panel-blur',\n className,\n )}\n {...props}\n />\n )\n}\n\n/** The filter field. Carries the search icon and the combobox semantics. */\nexport function CommandInput({\n className,\n ...props\n}: ComponentProps<typeof CommandPrimitive.Input>) {\n return (\n <div className=\"flex items-center gap-3 border-b border-(--rule) px-4\">\n <Search size={18} strokeWidth={1.5} aria-hidden className=\"shrink-0 text-(--ink-3-aa)\" />\n <CommandPrimitive.Input\n className={cn(\n 'h-13 w-full bg-transparent text-[15px] text-(--ink) outline-none placeholder:text-(--ink-3-aa)',\n className,\n )}\n {...props}\n />\n </div>\n )\n}\n\nexport function CommandList({\n className,\n ...props\n}: ComponentProps<typeof CommandPrimitive.List>) {\n return (\n <CommandPrimitive.List\n className={cn('max-h-72 overflow-y-auto overflow-x-hidden p-2 scroll-slim', className)}\n {...props}\n />\n )\n}\n\n/** Shown when the filter matches nothing. Say what would match, not \"no results\". */\nexport function CommandEmpty(props: ComponentProps<typeof CommandPrimitive.Empty>) {\n return (\n <CommandPrimitive.Empty\n className=\"px-3 py-10 text-center text-sm text-(--ink-3-aa)\"\n {...props}\n />\n )\n}\n\n/**\n * The key-hint strip along the bottom.\n *\n * A palette is a keyboard surface whose keys are invisible: nothing on screen\n * says the arrows move the row or that Enter runs it, and a reader who reaches\n * for the mouse has been failed by the design rather than by themselves.\n *\n * @example\n * <CommandFooter>\n * <CommandHint keys={['↑', '↓']}>navigate</CommandHint>\n * <CommandHint keys={['↵']}>open</CommandHint>\n * </CommandFooter>\n */\nexport function CommandFooter({ className, ...props }: ComponentProps<'div'>) {\n return (\n <div\n className={cn(\n 'flex items-center gap-4 border-t border-(--rule) bg-(--paper-2) px-3.5 py-2',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport interface CommandHintProps extends Omit<ComponentProps<'span'>, 'children'> {\n /** The keys this hint describes, printed as `Kbd` chips. */\n keys: string[]\n /** What they do — a verb, lowercase, no sentence. */\n children: ReactNode\n}\n\n/** One key-and-verb pair inside a `CommandFooter`. */\nexport function CommandHint({ keys, children, className, ...props }: CommandHintProps) {\n return (\n <span className={cn('flex items-center gap-1.5 mono-meta text-(--ink-3-aa)', className)} {...props}>\n {keys.map((key) => (\n <Kbd key={key}>{key}</Kbd>\n ))}\n {children}\n </span>\n )\n}\n\nexport function CommandGroup({\n className,\n ...props\n}: ComponentProps<typeof CommandPrimitive.Group>) {\n return (\n <CommandPrimitive.Group\n className={cn(\n 'overflow-hidden [&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:eyebrow [&_[cmdk-group-heading]]:text-(--ink-3-aa)',\n className,\n )}\n {...props}\n />\n )\n}\n\n/**\n * A divider between groups.\n *\n * Marked presentational, because ARIA permits a `listbox` to contain only\n * `option` and `group` — and the library renders this as `role=\"separator\"`,\n * which puts a critical `aria-required-children` violation inside every palette\n * that uses one. The grouping is already announced by the groups themselves, so\n * removing the divider from the accessibility tree loses nothing.\n */\nexport function CommandSeparator({\n className,\n ...props\n}: ComponentProps<typeof CommandPrimitive.Separator>) {\n return (\n <CommandPrimitive.Separator\n role=\"presentation\"\n aria-hidden=\"true\"\n className={cn('my-1 h-px bg-(--rule)', className)}\n {...props}\n />\n )\n}\n\nexport interface CommandItemProps extends ComponentProps<typeof CommandPrimitive.Item> {\n /** A shortcut printed at the end of the row. */\n shortcut?: string\n /**\n * A leading glyph. Either spelling — `icon={<Settings size={16} />}` passes\n * the element, `icon={Settings}` passes the component and this sizes it.\n *\n * It is what makes a long list scannable — the eye sorts by shape before it\n * reads, and forty identical rows of text defeat that.\n */\n icon?: LucideIcon | ReactNode\n /**\n * A quiet note at the end of the row — what kind of thing this is, or its\n * current state. Not a description: a palette that prints a sentence per row\n * stops being scannable at about six of them.\n */\n meta?: ReactNode\n}\n\nexport function CommandItem({ shortcut, icon, meta, className, children, ...props }: CommandItemProps) {\n return (\n <CommandPrimitive.Item\n className={cn(\n 'flex cursor-pointer items-center gap-3 rounded-(--radius-row) px-3 py-2.5 text-[15px] text-(--ink-2) outline-none transition-colors duration-(--duration-fast)',\n // The highlighted row is a chosen state, and law 7 says a chosen state\n // reads --accent. The leading rule gives it an edge the eye catches\n // while scrolling, which a fill alone does not.\n 'relative data-[selected=true]:bg-(--accent-muted) data-[selected=true]:text-(--ink)',\n 'before:absolute before:inset-y-1 before:start-0 before:w-0.5 before:rounded-(--radius-pill) before:bg-transparent data-[selected=true]:before:bg-(--accent)',\n 'data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-(--disabled-opacity)',\n className,\n )}\n {...props}\n >\n {icon && (\n <span className=\"grid size-4 shrink-0 place-items-center text-(--ink-3-aa) [&_svg]:size-4\">\n {iconNode(icon)}\n </span>\n )}\n {children}\n {meta && <span className=\"ms-auto ps-3 mono-meta text-(--ink-3-aa)\">{meta}</span>}\n {shortcut && <Kbd className={cn(meta ? '' : 'ms-auto')}>{shortcut}</Kbd>}\n </CommandPrimitive.Item>\n )\n}\n\nexport interface CommandDialogProps {\n open: boolean\n onOpenChange: (open: boolean) => void\n /** Names the palette for assistive tech. */\n label: string\n children: ReactNode\n}\n\n/**\n * The palette in a modal, which is how it is nearly always used.\n *\n * The dialog's own padding is removed: a palette is edge-to-edge, and its input\n * is the first thing focus lands on.\n */\nexport function CommandDialog({ open, onOpenChange, label, children }: CommandDialogProps) {\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent\n title={label}\n hideTitle\n showClose={false}\n // Above centre, not at it. A palette is read as a layer over the page\n // rather than as a message about it, and centring it puts the list\n // under the reader's own hands on a laptop.\n // `scrollbar-gutter: auto` undoes the `stable` that `Dialog`'s own\n // `scroll-slim` sets. The dialog never scrolls — the list inside it\n // does — but the reserved gutter was still there, so the list stopped\n // thirteen pixels short of the panel and drew its own hairline inside\n // an empty channel. Two bars, one of them permanently blank.\n className=\"top-[10vh] w-[min(94vw,44rem)] translate-y-0 overflow-hidden p-0 [scrollbar-gutter:auto]\"\n >\n {/* The modal has the whole screen, so its list may be taller than the\n default an inline menu should keep.\n\n `scroll-hairline` rather than `scroll-slim`: eleven pixels of grey\n down the side of a palette is the widest thing in it. */}\n <Command\n label={label}\n className=\"rounded-none border-0 [&_[cmdk-list]]:max-h-[26rem] [&_[cmdk-list]]:scroll-hairline\"\n >\n {children}\n </Command>\n </DialogContent>\n </Dialog>\n )\n}\n\nexport default Command\n"],"mappings":";AA4BS,cA+CL,YA/CK;AA1BT,SAAS,WAAW,wBAAwB;AAC5C,SAAS,cAA+B;AACxC,SAAS,sBAA2D;AACpE,SAAS,UAAU;AAYnB,SAAS,gBAAgB,MAAkD;AACzE,MAAI,eAAe,IAAI,EAAG,QAAO;AACjC,MAAI,OAAO,SAAS,WAAY,QAAO;AACvC,MAAI,OAAO,SAAS,YAAY,SAAS,KAAM,QAAO;AACtD,SAAO,CAAC,MAAM,QAAQ,IAAI,KAAK,EAAE,OAAO,YAAY,SAAS,EAAE,UAAU;AAC3E;AAGA,SAAS,SAAS,MAAyC;AACzD,MAAI,CAAC,gBAAgB,IAAI,EAAG,QAAO;AACnC,QAAM,OAAO;AACb,SAAO,oBAAC,QAAK,MAAM,IAAI,aAAa,KAAK,eAAW,MAAC;AACvD;AACA,SAAS,QAAQ,qBAAqB;AACtC,SAAS,WAAW;AAuBb,SAAS,QAAQ;AAAA,EACtB;AAAA,EACA,GAAG;AACL,GAA4C;AAC1C,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,Q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MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;AAWO,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA,GAAG;AACL,GAAsD;AACpD,SACE;AAAA,IAAC,iBAAiB;AAAA,IAAjB;AAAA,MACC,MAAK;AAAA,MACL,eAAY;AAAA,MACZ,WAAW,GAAG,yBAAyB,SAAS;AAAA,MAC/C,GAAG;AAAA;AAAA,EACN;AAEJ;AAqBO,SAAS,YAAY,EAAE,UAAU,MAAM,MAAM,WAAW,UAAU,GAAG,MAAM,GAAqB;AACrG,SACE;AAAA,IAAC,iBAAiB;AAAA,IAAjB;AAAA,MACC,WAAW;AAAA,QACT;AAAA;AAAA;AAAA;AAAA,QAIA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MAEH;AAAA,gBACC,oBAAC,UAAK,WAAU,4EACb,mBAAS,IAAI,GAChB;AAAA,QAED;AAAA,QACA,QAAQ,oBAAC,UAAK,WAAU,4CAA4C,gBAAK;AAAA,QACzE,YAAY,oBAAC,OAAI,WAAW,GAAG,OAAO,KAAK,SAAS,GAAI,oBAAS;AAAA;AAAA;AAAA,EACpE;AAEJ;AAgBO,SAAS,cAAc,EAAE,MAAM,cAAc,OAAO,SAAS,GAAuB;AACzF,SACE,oBAAC,UAAO,MAAY,cAClB;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,MACP,WAAS;AAAA,MACT,WAAW;AAAA,MASX,WAAU;AAAA,MAOV;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,WAAU;AAAA,UAET;AAAA;AAAA,MACH;AAAA;AAAA,EACF,GACF;AAEJ;AAEA,IAAO,kBAAQ;","names":[]}
@@ -32,7 +32,7 @@ function ContextMenuContent({
32
32
  collisionPadding: 8,
33
33
  "data-m22-animated": true,
34
34
  className: cn(
35
- "z-(--z-dropdown) min-w-44 rounded-(--radius-lg) border border-(--panel-border) bg-(--panel-bg) p-1.5 panel-blur",
35
+ "z-(--z-dropdown) min-w-44 rounded-(--radius-lg) border border-(--panel-border) bg-(--panel-bg) p-1.5 shadow-(--panel-lift) panel-blur",
36
36
  "data-[state=open]:animate-[m22-pop-in_var(--duration-fast)_var(--ease-out-expo)] data-[state=closed]:animate-[m22-pop-out_var(--duration-fast)_var(--ease)] origin-(--radix-popper-transform-origin)",
37
37
  className
38
38
  ),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/ContextMenu/ContextMenu.tsx"],"sourcesContent":["'use client'\n\nimport * as ContextMenuPrimitive from '@radix-ui/react-context-menu'\nimport type { LucideIcon } from 'lucide-react'\nimport { isValidElement, useId, type ComponentProps, type ReactNode } from 'react'\nimport { cn } from '../../lib/cn'\nimport { useOverlayContainer } from '../../lib/overlay-container'\n\n/**\n * True for a component type — `icon={Copy}` — rather than a rendered element.\n *\n * Everything a `ReactNode` can be is an element, a primitive, an array, another\n * iterable or a promise; a Lucide icon is none of those, it is a `forwardRef`\n * object. So both spellings are tellable apart at runtime, which is what lets\n * one prop take either — and it has to, because this prop meant the opposite\n * thing one import away and the wrong spelling failed at render, not at the\n * type.\n */\nfunction isIconComponent(icon: LucideIcon | ReactNode): icon is LucideIcon {\n if (isValidElement(icon)) return false\n if (typeof icon === 'function') return true\n if (typeof icon !== 'object' || icon === null) return false\n return !Array.isArray(icon) && !(Symbol.iterator in icon) && !('then' in icon)\n}\n\n/** The leading glyph, sized by this component when it was handed a component. */\nfunction iconNode(icon: LucideIcon | ReactNode): ReactNode {\n if (icon === undefined || icon === null || icon === false) return null\n if (!isIconComponent(icon)) {\n return (\n <span aria-hidden className=\"grid size-4 shrink-0 place-items-center [&_svg]:size-4\">\n {icon}\n </span>\n )\n }\n const Icon = icon\n return <Icon size={16} strokeWidth={1.5} className=\"shrink-0\" aria-hidden />\n}\n\n/** Radix ContextMenu root and trigger, as typed passthroughs. */\nexport const ContextMenu = ContextMenuPrimitive.Root\nexport const ContextMenuTrigger = ContextMenuPrimitive.Trigger\n\n/**\n * The menu a right-click opens.\n *\n * Never the only way to reach an action. A context menu is opened by a\n * secondary pointer button or a keyboard's own menu key, and a meaningful share\n * of readers have neither — a touch user, someone on a trackpad they have not\n * configured, anyone driving the page by keyboard alone. Whatever is in here\n * belongs somewhere reachable too: a row's overflow button, a toolbar.\n *\n * @example\n * <ContextMenu>\n * <ContextMenuTrigger asChild><Card>Right-click me</Card></ContextMenuTrigger>\n * <ContextMenuContent>\n * <ContextMenuItem icon={Copy}>Copy</ContextMenuItem>\n * </ContextMenuContent>\n * </ContextMenu>\n */\nexport function ContextMenuContent({\n className,\n ...rest\n}: ComponentProps<typeof ContextMenuPrimitive.Content>) {\n const container = useOverlayContainer()\n\n return (\n <ContextMenuPrimitive.Portal container={container ?? undefined}>\n <ContextMenuPrimitive.Content\n collisionBoundary={container ?? undefined}\n collisionPadding={8}\n data-m22-animated\n className={cn(\n 'z-(--z-dropdown) min-w-44 rounded-(--radius-lg) border border-(--panel-border) bg-(--panel-bg) p-1.5 panel-blur',\n 'data-[state=open]:animate-[m22-pop-in_var(--duration-fast)_var(--ease-out-expo)] data-[state=closed]:animate-[m22-pop-out_var(--duration-fast)_var(--ease)] origin-(--radix-popper-transform-origin)',\n className,\n )}\n {...rest}\n />\n </ContextMenuPrimitive.Portal>\n )\n}\n\nexport interface ContextMenuItemProps\n extends ComponentProps<typeof ContextMenuPrimitive.Item> {\n /**\n * Optional leading icon. Either spelling — `icon={Copy}` passes the component\n * and this sizes it, `icon={<Copy size={16} />}` passes the element and this\n * places it.\n */\n icon?: LucideIcon | ReactNode\n /** Paints the row as destructive. Use for delete, revoke, disconnect. */\n destructive?: boolean\n}\n\n/** A row. Highlight follows `data-highlighted`, which covers hover and keyboard. */\nexport function ContextMenuItem({\n icon,\n destructive = false,\n className,\n children,\n ...rest\n}: ContextMenuItemProps) {\n return (\n <ContextMenuPrimitive.Item\n className={cn(\n 'flex cursor-pointer items-center gap-2.5 rounded-(--radius-row) px-2.5 py-2 text-sm outline-none transition-colors duration-(--duration-fast) data-[highlighted]:bg-(--stone) data-[disabled]:pointer-events-none data-[disabled]:opacity-(--disabled-opacity)',\n destructive ? 'text-(--danger)' : 'text-(--ink-2) data-[highlighted]:text-(--ink)',\n className,\n )}\n {...rest}\n >\n {iconNode(icon)}\n {children}\n </ContextMenuPrimitive.Item>\n )\n}\n\n/** Hairline divider between groups. */\nexport function ContextMenuSeparator({\n className,\n ...rest\n}: ComponentProps<typeof ContextMenuPrimitive.Separator>) {\n return (\n <ContextMenuPrimitive.Separator className={cn('my-1 h-px bg-(--rule)', className)} {...rest} />\n )\n}\n\n/**\n * Mono eyebrow heading, on its own.\n *\n * Visual only: Radix renders it as a bare `<div>` with no role. Reach for\n * `ContextMenuGroup` when the eyebrow is a HEADING over rows; this is right for\n * a line that heads nothing.\n */\nexport function ContextMenuLabel({\n className,\n ...rest\n}: ComponentProps<typeof ContextMenuPrimitive.Label>) {\n return (\n <ContextMenuPrimitive.Label\n className={cn('px-2.5 py-1.5 eyebrow text-(--ink-3-aa)', className)}\n {...rest}\n />\n )\n}\n\nexport interface ContextMenuGroupProps\n extends ComponentProps<typeof ContextMenuPrimitive.Group> {\n /** The eyebrow over the rows, and the group's accessible name. */\n label?: ReactNode\n}\n\n/**\n * A named section of a menu.\n *\n * The eyebrow alone was a picture of a heading: Radix's `MenuLabel` carries no\n * role and no `aria-labelledby` wiring, so a sighted reader saw sections and a\n * screen-reader user got one undifferentiated list. This renders the group,\n * renders the label inside it, and points the one at the other.\n */\nexport function ContextMenuGroup({ label, children, ...rest }: ContextMenuGroupProps) {\n const id = useId()\n\n return (\n <ContextMenuPrimitive.Group\n aria-labelledby={label === undefined ? undefined : id}\n {...rest}\n >\n {label !== undefined && <ContextMenuLabel id={id}>{label}</ContextMenuLabel>}\n {children}\n </ContextMenuPrimitive.Group>\n )\n}\n\nexport default ContextMenu\n"],"mappings":";AA8BM,cA0EF,YA1EE;AA5BN,YAAY,0BAA0B;AAEtC,SAAS,gBAAgB,aAAkD;AAC3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I;AAAA,QACb;AAAA;AAAA;AAAA,EACH;AAEJ;AAGO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA,GAAG;AACL,GAA0D;AACxD,SACE,oBAAC,qBAAqB,WAArB,EAA+B,WAAW,GAAG,yBAAyB,SAAS,GAAI,GAAG,MAAM;AAEjG;AASO,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA,GAAG;AACL,GAAsD;AACpD,SACE;AAAA,IAAC,qBAAqB;AAAA,IAArB;AAAA,MACC,WAAW,GAAG,2CAA2C,SAAS;AAAA,MACjE,GAAG;AAAA;AAAA,EACN;AAEJ;AAgBO,SAAS,iBAAiB,EAAE,OAAO,UAAU,GAAG,KAAK,GAA0B;AACpF,QAAM,KAAK,MAAM;AAEjB,SACE;AAAA,IAAC,qBAAqB;AAAA,IAArB;AAAA,MACC,mBAAiB,UAAU,SAAY,SAAY;AAAA,MAClD,GAAG;AAAA,MAEH;AAAA,kBAAU,UAAa,oBAAC,oBAAiB,IAAS,iBAAM;AAAA,QACxD;AAAA;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,sBAAQ;","names":[]}
1
+ {"version":3,"sources":["../../../src/components/ContextMenu/ContextMenu.tsx"],"sourcesContent":["'use client'\n\nimport * as ContextMenuPrimitive from '@radix-ui/react-context-menu'\nimport type { LucideIcon } from 'lucide-react'\nimport { isValidElement, useId, type ComponentProps, type ReactNode } from 'react'\nimport { cn } from '../../lib/cn'\nimport { useOverlayContainer } from '../../lib/overlay-container'\n\n/**\n * True for a component type — `icon={Copy}` — rather than a rendered element.\n *\n * Everything a `ReactNode` can be is an element, a primitive, an array, another\n * iterable or a promise; a Lucide icon is none of those, it is a `forwardRef`\n * object. So both spellings are tellable apart at runtime, which is what lets\n * one prop take either — and it has to, because this prop meant the opposite\n * thing one import away and the wrong spelling failed at render, not at the\n * type.\n */\nfunction isIconComponent(icon: LucideIcon | ReactNode): icon is LucideIcon {\n if (isValidElement(icon)) return false\n if (typeof icon === 'function') return true\n if (typeof icon !== 'object' || icon === null) return false\n return !Array.isArray(icon) && !(Symbol.iterator in icon) && !('then' in icon)\n}\n\n/** The leading glyph, sized by this component when it was handed a component. */\nfunction iconNode(icon: LucideIcon | ReactNode): ReactNode {\n if (icon === undefined || icon === null || icon === false) return null\n if (!isIconComponent(icon)) {\n return (\n <span aria-hidden className=\"grid size-4 shrink-0 place-items-center [&_svg]:size-4\">\n {icon}\n </span>\n )\n }\n const Icon = icon\n return <Icon size={16} strokeWidth={1.5} className=\"shrink-0\" aria-hidden />\n}\n\n/** Radix ContextMenu root and trigger, as typed passthroughs. */\nexport const ContextMenu = ContextMenuPrimitive.Root\nexport const ContextMenuTrigger = ContextMenuPrimitive.Trigger\n\n/**\n * The menu a right-click opens.\n *\n * Never the only way to reach an action. A context menu is opened by a\n * secondary pointer button or a keyboard's own menu key, and a meaningful share\n * of readers have neither — a touch user, someone on a trackpad they have not\n * configured, anyone driving the page by keyboard alone. Whatever is in here\n * belongs somewhere reachable too: a row's overflow button, a toolbar.\n *\n * @example\n * <ContextMenu>\n * <ContextMenuTrigger asChild><Card>Right-click me</Card></ContextMenuTrigger>\n * <ContextMenuContent>\n * <ContextMenuItem icon={Copy}>Copy</ContextMenuItem>\n * </ContextMenuContent>\n * </ContextMenu>\n */\nexport function ContextMenuContent({\n className,\n ...rest\n}: ComponentProps<typeof ContextMenuPrimitive.Content>) {\n const container = useOverlayContainer()\n\n return (\n <ContextMenuPrimitive.Portal container={container ?? undefined}>\n <ContextMenuPrimitive.Content\n collisionBoundary={container ?? undefined}\n collisionPadding={8}\n data-m22-animated\n className={cn(\n 'z-(--z-dropdown) min-w-44 rounded-(--radius-lg) border border-(--panel-border) bg-(--panel-bg) p-1.5 shadow-(--panel-lift) panel-blur',\n 'data-[state=open]:animate-[m22-pop-in_var(--duration-fast)_var(--ease-out-expo)] data-[state=closed]:animate-[m22-pop-out_var(--duration-fast)_var(--ease)] origin-(--radix-popper-transform-origin)',\n className,\n )}\n {...rest}\n />\n </ContextMenuPrimitive.Portal>\n )\n}\n\nexport interface ContextMenuItemProps\n extends ComponentProps<typeof ContextMenuPrimitive.Item> {\n /**\n * Optional leading icon. Either spelling — `icon={Copy}` passes the component\n * and this sizes it, `icon={<Copy size={16} />}` passes the element and this\n * places it.\n */\n icon?: LucideIcon | ReactNode\n /** Paints the row as destructive. Use for delete, revoke, disconnect. */\n destructive?: boolean\n}\n\n/** A row. Highlight follows `data-highlighted`, which covers hover and keyboard. */\nexport function ContextMenuItem({\n icon,\n destructive = false,\n className,\n children,\n ...rest\n}: ContextMenuItemProps) {\n return (\n <ContextMenuPrimitive.Item\n className={cn(\n 'flex cursor-pointer items-center gap-2.5 rounded-(--radius-row) px-2.5 py-2 text-sm outline-none transition-colors duration-(--duration-fast) data-[highlighted]:bg-(--stone) data-[disabled]:pointer-events-none data-[disabled]:opacity-(--disabled-opacity)',\n destructive ? 'text-(--danger)' : 'text-(--ink-2) data-[highlighted]:text-(--ink)',\n className,\n )}\n {...rest}\n >\n {iconNode(icon)}\n {children}\n </ContextMenuPrimitive.Item>\n )\n}\n\n/** Hairline divider between groups. */\nexport function ContextMenuSeparator({\n className,\n ...rest\n}: ComponentProps<typeof ContextMenuPrimitive.Separator>) {\n return (\n <ContextMenuPrimitive.Separator className={cn('my-1 h-px bg-(--rule)', className)} {...rest} />\n )\n}\n\n/**\n * Mono eyebrow heading, on its own.\n *\n * Visual only: Radix renders it as a bare `<div>` with no role. Reach for\n * `ContextMenuGroup` when the eyebrow is a HEADING over rows; this is right for\n * a line that heads nothing.\n */\nexport function ContextMenuLabel({\n className,\n ...rest\n}: ComponentProps<typeof ContextMenuPrimitive.Label>) {\n return (\n <ContextMenuPrimitive.Label\n className={cn('px-2.5 py-1.5 eyebrow text-(--ink-3-aa)', className)}\n {...rest}\n />\n )\n}\n\nexport interface ContextMenuGroupProps\n extends ComponentProps<typeof ContextMenuPrimitive.Group> {\n /** The eyebrow over the rows, and the group's accessible name. */\n label?: ReactNode\n}\n\n/**\n * A named section of a menu.\n *\n * The eyebrow alone was a picture of a heading: Radix's `MenuLabel` carries no\n * role and no `aria-labelledby` wiring, so a sighted reader saw sections and a\n * screen-reader user got one undifferentiated list. This renders the group,\n * renders the label inside it, and points the one at the other.\n */\nexport function ContextMenuGroup({ label, children, ...rest }: ContextMenuGroupProps) {\n const id = useId()\n\n return (\n <ContextMenuPrimitive.Group\n aria-labelledby={label === undefined ? undefined : id}\n {...rest}\n >\n {label !== undefined && <ContextMenuLabel id={id}>{label}</ContextMenuLabel>}\n {children}\n </ContextMenuPrimitive.Group>\n )\n}\n\nexport default ContextMenu\n"],"mappings":";AA8BM,cA0EF,YA1EE;AA5BN,YAAY,0BAA0B;AAEtC,SAAS,gBAAgB,aAAkD;AAC3E,SAAS,UAAU;AACnB,SAAS,2BAA2B;AAYpC,SAAS,gBAAgB,MAAkD;AACzE,MAAI,eAAe,IAAI,EAAG,QAAO;AACjC,MAAI,OAAO,SAAS,WAAY,QAAO;AACvC,MAAI,OAAO,SAAS,YAAY,SAAS,KAAM,QAAO;AACtD,SAAO,CAAC,MAAM,QAAQ,IAAI,KAAK,EAAE,OAAO,YAAY,SAAS,EAAE,UAAU;AAC3E;AAGA,SAAS,SAAS,MAAyC;AACzD,MAAI,SAAS,UAAa,SAAS,QAAQ,SAAS,MAAO,QAAO;AAClE,MAAI,CAAC,gBAAgB,IAAI,GAAG;AAC1B,WACE,oBAAC,UAAK,eAAW,MAAC,WAAU,0DACzB,gBACH;AAAA,EAEJ;AACA,QAAM,OAAO;AACb,SAAO,oBAAC,QAAK,MAAM,IAAI,aAAa,KAAK,WAAU,YAAW,eAAW,MAAC;AAC5E;AAGO,MAAM,cAAc,qBAAqB;AACzC,MAAM,qBAAqB,qBAAqB;AAmBhD,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA,GAAG;AACL,GAAwD;AACtD,QAAM,YAAY,oBAAoB;AAEtC,SACE,oBAAC,qBAAqB,QAArB,EAA4B,WAAW,aAAa,QACnD;AAAA,IAAC,qBAAqB;AAAA,IAArB;AAAA,MACC,mBAAmB,aAAa;AAAA,MAChC,kBAAkB;AAAA,MAClB,qBAAiB;AAAA,MACjB,WAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,EACN,GACF;AAEJ;AAeO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAyB;AACvB,SACE;AAAA,IAAC,qBAAqB;AAAA,IAArB;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,cAAc,oBAAoB;AAAA,QAClC;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MAEH;AAAA,iBAAS,IAAI;AAAA,QACb;AAAA;AAAA;AAAA,EACH;AAEJ;AAGO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA,GAAG;AACL,GAA0D;AACxD,SACE,oBAAC,qBAAqB,WAArB,EAA+B,WAAW,GAAG,yBAAyB,SAAS,GAAI,GAAG,MAAM;AAEjG;AASO,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA,GAAG;AACL,GAAsD;AACpD,SACE;AAAA,IAAC,qBAAqB;AAAA,IAArB;AAAA,MACC,WAAW,GAAG,2CAA2C,SAAS;AAAA,MACjE,GAAG;AAAA;AAAA,EACN;AAEJ;AAgBO,SAAS,iBAAiB,EAAE,OAAO,UAAU,GAAG,KAAK,GAA0B;AACpF,QAAM,KAAK,MAAM;AAEjB,SACE;AAAA,IAAC,qBAAqB;AAAA,IAArB;AAAA,MACC,mBAAiB,UAAU,SAAY,SAAY;AAAA,MAClD,GAAG;AAAA,MAEH;AAAA,kBAAU,UAAa,oBAAC,oBAAiB,IAAS,iBAAM;AAAA,QACxD;AAAA;AAAA;AAAA,EACH;AAEJ;AAEA,IAAO,sBAAQ;","names":[]}
@@ -54,7 +54,7 @@ function DialogContent({
54
54
  {
55
55
  "data-m22-animated": true,
56
56
  className: cn(
57
- "fixed left-1/2 top-1/2 z-(--z-modal) max-h-[85vh] w-[min(92vw,32rem)] -translate-x-1/2 -translate-y-1/2 overflow-auto rounded-(--radius-lg) border border-(--panel-border) bg-(--panel-bg) p-6 panel-blur scroll-slim",
57
+ "fixed left-1/2 top-1/2 z-(--z-modal) max-h-[85vh] w-[min(92vw,32rem)] -translate-x-1/2 -translate-y-1/2 overflow-auto rounded-(--radius-lg) border border-(--panel-border) bg-(--panel-bg) p-6 shadow-(--panel-lift) panel-blur scroll-slim",
58
58
  "data-[state=open]:animate-[m22-panel-in_var(--duration-base)_var(--ease)]",
59
59
  // Against the container's box rather than the viewport's, and capped
60
60
  // by it: 92vw inside a 400px frame is not a cap at all.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["'use client'\n\nimport * as DialogPrimitive from '@radix-ui/react-dialog'\nimport { X } from 'lucide-react'\nimport type { ComponentProps, ReactNode } from 'react'\nimport { cn } from '../../lib/cn'\nimport { useOverlayContainer } from '../../lib/overlay-container'\nimport { DEV, warn } from '../../lib/warn'\n\n/** Radix Dialog root + trigger + close, re-exported as typed passthroughs. */\nexport const Dialog = DialogPrimitive.Root\nexport const DialogTrigger = DialogPrimitive.Trigger\nexport const DialogClose = DialogPrimitive.Close\n\n/** Title + description stack; renders nothing when both are omitted. */\nfunction DialogHeader({\n title,\n description,\n hidden,\n}: {\n title?: ReactNode\n description?: ReactNode\n hidden: boolean\n}) {\n if (title === undefined && description === undefined) return null\n return (\n <div className={cn('mb-4 flex flex-col gap-1 pe-8', hidden && 'sr-only')}>\n {title !== undefined && (\n <DialogPrimitive.Title className=\"m-0 font-heading text-[length:var(--fs-item)] font-normal text-(--ink)\">\n {title}\n </DialogPrimitive.Title>\n )}\n {description !== undefined && (\n <DialogPrimitive.Description className=\"m-0 text-sm leading-relaxed text-(--ink-3-aa)\">\n {description}\n </DialogPrimitive.Description>\n )}\n </div>\n )\n}\n\nexport interface DialogContentProps\n extends Omit<ComponentProps<typeof DialogPrimitive.Content>, 'title' | 'className'> {\n /**\n * Heading text.\n *\n * Pass one even when `hideTitle` is set. Radix requires a title, so omitting\n * it renders a hidden fallback reading the literal word \"Dialog\" — which\n * satisfies an automated accessibility check and announces every unnamed\n * modal in the application as the same thing. Development says so out loud.\n */\n title?: ReactNode\n /** Sub-heading under the title. */\n description?: ReactNode\n className?: string\n /** Show the top-right close control (default true). */\n showClose?: boolean\n /**\n * Keeps the title for assistive tech and hides it visually.\n *\n * For a surface whose purpose is obvious to anyone who can see it — a command\n * palette, a media lightbox — where a printed heading would be furniture. The\n * title itself is never optional: Radix requires one, and a modal with no\n * accessible name drops a screen reader into an unnamed region.\n */\n hideTitle?: boolean\n}\n\n/**\n * A modal surface: portal → scrim → centred panel.\n *\n * Radix owns the focus trap, the escape key, the scroll lock and the\n * `aria-modal` wiring — all of which a hand-rolled dialog gets subtly wrong,\n * usually by leaving focus behind in the page underneath.\n *\n * Radix requires a `Dialog.Title` whether or not one is shown, so a dialog\n * without a visible heading still renders a hidden one rather than shipping an\n * unnamed modal — and warns in development, because the fallback it renders is\n * the literal word \"Dialog\" and a placeholder that passes an accessibility\n * check is how the problem survives a review.\n *\n * Portals into the element an enclosing `OverlayContainer` names, and switches\n * from viewport positioning to container positioning when there is one. A\n * `fixed` panel covers the page whatever it is portalled into, so honouring\n * the container without that swap would have moved the markup and left the\n * picture unchanged.\n *\n * @example\n * <Dialog>\n * <DialogTrigger asChild><Button>Delete</Button></DialogTrigger>\n * <DialogContent title=\"Delete file\" description=\"This cannot be undone.\">\n * <DialogClose asChild><Button variant=\"secondary\">Cancel</Button></DialogClose>\n * </DialogContent>\n * </Dialog>\n */\nexport function DialogContent({\n title,\n description,\n children,\n className,\n showClose = true,\n hideTitle = false,\n ...rest\n}: DialogContentProps) {\n const container = useOverlayContainer()\n\n if (DEV && title === undefined) {\n warn({\n code: 'DIALOG_TITLE_MISSING',\n problem:\n 'DialogContent has no title, so its accessible name is the fallback string \"Dialog\". Every unnamed modal in the app announces identically, and the check that would have caught it passes.',\n field: 'title',\n fix: 'Give it a title that says what the dialog asks. Add hideTitle when the heading would be furniture on screen.',\n component: 'Dialog',\n })\n }\n\n return (\n <DialogPrimitive.Portal container={container ?? undefined}>\n <DialogPrimitive.Overlay\n data-m22-animated\n className={cn(\n 'inset-0 z-(--z-overlay) bg-(--scrim) data-[state=open]:animate-[m22-fade-in_var(--duration-fast)_var(--ease)]',\n container ? 'absolute' : 'fixed',\n )}\n />\n <DialogPrimitive.Content\n data-m22-animated\n className={cn(\n 'fixed left-1/2 top-1/2 z-(--z-modal) max-h-[85vh] w-[min(92vw,32rem)] -translate-x-1/2 -translate-y-1/2 overflow-auto rounded-(--radius-lg) border border-(--panel-border) bg-(--panel-bg) p-6 panel-blur scroll-slim',\n 'data-[state=open]:animate-[m22-panel-in_var(--duration-base)_var(--ease)]',\n // Against the container's box rather than the viewport's, and capped\n // by it: 92vw inside a 400px frame is not a cap at all.\n container && 'absolute max-h-[calc(100%-2rem)] max-w-[calc(100%-2rem)]',\n className,\n )}\n {...rest}\n >\n <DialogHeader title={title} description={description} hidden={hideTitle} />\n\n {title === undefined && (\n <DialogPrimitive.Title className=\"sr-only\">Dialog</DialogPrimitive.Title>\n )}\n\n {showClose && (\n <DialogPrimitive.Close\n aria-label=\"Close\"\n className=\"absolute end-3 top-3 grid size-9 place-items-center rounded-(--radius-pill) text-(--ink-3-aa) transition-colors duration-(--duration-fast) hover:bg-(--stone) hover:text-(--ink)\"\n >\n <X size={16} strokeWidth={1.5} aria-hidden />\n </DialogPrimitive.Close>\n )}\n\n {children}\n </DialogPrimitive.Content>\n </DialogPrimitive.Portal>\n )\n}\n\nexport default Dialog\n"],"mappings":";AA0BI,SAEI,KAFJ;AAxBJ,YAAY,qBAAqB;AACjC,SAAS,SAAS;AAElB,SAAS,UAAU;AACnB,SAAS,2BAA2B;AACpC,SAAS,KAAK,YAAY;AAGnB,MAAM,SAAS,gBAAgB;AAC/B,MAAM,gBAAgB,gB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;AAAA,cACC,cAAW;AAAA,cACX,WAAU;AAAA,cAEV,8BAAC,KAAE,MAAM,IAAI,aAAa,KAAK,eAAW,MAAC;AAAA;AAAA,UAC7C;AAAA,UAGD;AAAA;AAAA;AAAA,IACH;AAAA,KACF;AAEJ;AAEA,IAAO,iBAAQ;","names":[]}
1
+ {"version":3,"sources":["../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["'use client'\n\nimport * as DialogPrimitive from '@radix-ui/react-dialog'\nimport { X } from 'lucide-react'\nimport type { ComponentProps, ReactNode } from 'react'\nimport { cn } from '../../lib/cn'\nimport { useOverlayContainer } from '../../lib/overlay-container'\nimport { DEV, warn } from '../../lib/warn'\n\n/** Radix Dialog root + trigger + close, re-exported as typed passthroughs. */\nexport const Dialog = DialogPrimitive.Root\nexport const DialogTrigger = DialogPrimitive.Trigger\nexport const DialogClose = DialogPrimitive.Close\n\n/** Title + description stack; renders nothing when both are omitted. */\nfunction DialogHeader({\n title,\n description,\n hidden,\n}: {\n title?: ReactNode\n description?: ReactNode\n hidden: boolean\n}) {\n if (title === undefined && description === undefined) return null\n return (\n <div className={cn('mb-4 flex flex-col gap-1 pe-8', hidden && 'sr-only')}>\n {title !== undefined && (\n <DialogPrimitive.Title className=\"m-0 font-heading text-[length:var(--fs-item)] font-normal text-(--ink)\">\n {title}\n </DialogPrimitive.Title>\n )}\n {description !== undefined && (\n <DialogPrimitive.Description className=\"m-0 text-sm leading-relaxed text-(--ink-3-aa)\">\n {description}\n </DialogPrimitive.Description>\n )}\n </div>\n )\n}\n\nexport interface DialogContentProps\n extends Omit<ComponentProps<typeof DialogPrimitive.Content>, 'title' | 'className'> {\n /**\n * Heading text.\n *\n * Pass one even when `hideTitle` is set. Radix requires a title, so omitting\n * it renders a hidden fallback reading the literal word \"Dialog\" — which\n * satisfies an automated accessibility check and announces every unnamed\n * modal in the application as the same thing. Development says so out loud.\n */\n title?: ReactNode\n /** Sub-heading under the title. */\n description?: ReactNode\n className?: string\n /** Show the top-right close control (default true). */\n showClose?: boolean\n /**\n * Keeps the title for assistive tech and hides it visually.\n *\n * For a surface whose purpose is obvious to anyone who can see it — a command\n * palette, a media lightbox — where a printed heading would be furniture. The\n * title itself is never optional: Radix requires one, and a modal with no\n * accessible name drops a screen reader into an unnamed region.\n */\n hideTitle?: boolean\n}\n\n/**\n * A modal surface: portal → scrim → centred panel.\n *\n * Radix owns the focus trap, the escape key, the scroll lock and the\n * `aria-modal` wiring — all of which a hand-rolled dialog gets subtly wrong,\n * usually by leaving focus behind in the page underneath.\n *\n * Radix requires a `Dialog.Title` whether or not one is shown, so a dialog\n * without a visible heading still renders a hidden one rather than shipping an\n * unnamed modal — and warns in development, because the fallback it renders is\n * the literal word \"Dialog\" and a placeholder that passes an accessibility\n * check is how the problem survives a review.\n *\n * Portals into the element an enclosing `OverlayContainer` names, and switches\n * from viewport positioning to container positioning when there is one. A\n * `fixed` panel covers the page whatever it is portalled into, so honouring\n * the container without that swap would have moved the markup and left the\n * picture unchanged.\n *\n * @example\n * <Dialog>\n * <DialogTrigger asChild><Button>Delete</Button></DialogTrigger>\n * <DialogContent title=\"Delete file\" description=\"This cannot be undone.\">\n * <DialogClose asChild><Button variant=\"secondary\">Cancel</Button></DialogClose>\n * </DialogContent>\n * </Dialog>\n */\nexport function DialogContent({\n title,\n description,\n children,\n className,\n showClose = true,\n hideTitle = false,\n ...rest\n}: DialogContentProps) {\n const container = useOverlayContainer()\n\n if (DEV && title === undefined) {\n warn({\n code: 'DIALOG_TITLE_MISSING',\n problem:\n 'DialogContent has no title, so its accessible name is the fallback string \"Dialog\". Every unnamed modal in the app announces identically, and the check that would have caught it passes.',\n field: 'title',\n fix: 'Give it a title that says what the dialog asks. Add hideTitle when the heading would be furniture on screen.',\n component: 'Dialog',\n })\n }\n\n return (\n <DialogPrimitive.Portal container={container ?? undefined}>\n <DialogPrimitive.Overlay\n data-m22-animated\n className={cn(\n 'inset-0 z-(--z-overlay) bg-(--scrim) data-[state=open]:animate-[m22-fade-in_var(--duration-fast)_var(--ease)]',\n container ? 'absolute' : 'fixed',\n )}\n />\n <DialogPrimitive.Content\n data-m22-animated\n className={cn(\n 'fixed left-1/2 top-1/2 z-(--z-modal) max-h-[85vh] w-[min(92vw,32rem)] -translate-x-1/2 -translate-y-1/2 overflow-auto rounded-(--radius-lg) border border-(--panel-border) bg-(--panel-bg) p-6 shadow-(--panel-lift) panel-blur scroll-slim',\n 'data-[state=open]:animate-[m22-panel-in_var(--duration-base)_var(--ease)]',\n // Against the container's box rather than the viewport's, and capped\n // by it: 92vw inside a 400px frame is not a cap at all.\n container && 'absolute max-h-[calc(100%-2rem)] max-w-[calc(100%-2rem)]',\n className,\n )}\n {...rest}\n >\n <DialogHeader title={title} description={description} hidden={hideTitle} />\n\n {title === undefined && (\n <DialogPrimitive.Title className=\"sr-only\">Dialog</DialogPrimitive.Title>\n )}\n\n {showClose && (\n <DialogPrimitive.Close\n aria-label=\"Close\"\n className=\"absolute end-3 top-3 grid size-9 place-items-center rounded-(--radius-pill) text-(--ink-3-aa) transition-colors duration-(--duration-fast) hover:bg-(--stone) hover:text-(--ink)\"\n >\n <X size={16} strokeWidth={1.5} aria-hidden />\n </DialogPrimitive.Close>\n )}\n\n {children}\n </DialogPrimitive.Content>\n </DialogPrimitive.Portal>\n )\n}\n\nexport default Dialog\n"],"mappings":";AA0BI,SAEI,KAFJ;AAxBJ,YAAY,qBAAqB;AACjC,SAAS,SAAS;AAElB,SAAS,UAAU;AACnB,SAAS,2BAA2B;AACpC,SAAS,KAAK,YAAY;AAGnB,MAAM,SAAS,gBAAgB;AAC/B,MAAM,gBAAgB,gBAAgB;AACtC,MAAM,cAAc,gBAAgB;AAG3C,SAAS,aAAa;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,MAAI,UAAU,UAAa,gBAAgB,OAAW,QAAO;AAC7D,SACE,qBAAC,SAAI,WAAW,GAAG,iCAAiC,UAAU,SAAS,GACpE;AAAA,cAAU,UACT,oBAAC,gBA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35
35
  sideOffset,
36
36
  "data-m22-animated": true,
37
37
  className: cn(
38
- "z-(--z-dropdown) min-w-44 rounded-(--radius-lg) border border-(--panel-border) bg-(--panel-bg) p-1.5 panel-blur",
38
+ "z-(--z-dropdown) min-w-44 rounded-(--radius-lg) border border-(--panel-border) bg-(--panel-bg) p-1.5 shadow-(--panel-lift) panel-blur",
39
39
  "data-[state=open]:animate-[m22-pop-in_var(--duration-fast)_var(--ease-out-expo)] data-[state=closed]:animate-[m22-pop-out_var(--duration-fast)_var(--ease)] origin-(--radix-popper-transform-origin)",
40
40
  className
41
41
  ),