@nocoo/basalt 2.0.3 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +134 -15
- package/ai/COMPATIBILITY.md +180 -0
- package/ai/INTEGRATION.md +1760 -0
- package/ai/RECIPES.md +161 -0
- package/ai/USAGE.md +99 -0
- package/ai/registry.json +38099 -0
- package/ai/sources.json +10 -0
- package/dist/assets/brand-mark.d.ts +1 -0
- package/dist/assets/brand-mark.js +7 -0
- package/dist/assets/brand-mark.js.map +1 -0
- package/dist/charts/area.d.ts +58 -5
- package/dist/charts/area.js +20 -12
- package/dist/charts/area.js.map +1 -1
- package/dist/charts/bar.d.ts +54 -5
- package/dist/charts/bar.js +16 -10
- package/dist/charts/bar.js.map +1 -1
- package/dist/charts/bullet.d.ts +18 -1
- package/dist/charts/bullet.js +6 -3
- package/dist/charts/bullet.js.map +1 -1
- package/dist/charts/charts.d.ts +58 -5
- package/dist/charts/charts.js +13 -2
- package/dist/charts/charts.js.map +1 -1
- package/dist/charts/config.d.ts +7 -0
- package/dist/charts/config.js +5 -1
- package/dist/charts/config.js.map +1 -1
- package/dist/charts/custom-chart.d.ts +58 -5
- package/dist/charts/custom-chart.js +13 -2
- package/dist/charts/custom-chart.js.map +1 -1
- package/dist/charts/donut.d.ts +18 -1
- package/dist/charts/donut.js +6 -3
- package/dist/charts/donut.js.map +1 -1
- package/dist/charts/frame.d.ts +40 -3
- package/dist/charts/frame.js +55 -28
- package/dist/charts/frame.js.map +1 -1
- package/dist/charts/funnel.d.ts +18 -1
- package/dist/charts/funnel.js +5 -1
- package/dist/charts/funnel.js.map +1 -1
- package/dist/charts/gauge.d.ts +18 -1
- package/dist/charts/gauge.js +38 -20
- package/dist/charts/gauge.js.map +1 -1
- package/dist/charts/grouped-bar.d.ts +54 -5
- package/dist/charts/grouped-bar.js +16 -10
- package/dist/charts/grouped-bar.js.map +1 -1
- package/dist/charts/heatmap-calendar.d.ts +61 -0
- package/dist/charts/heatmap-calendar.js +287 -96
- package/dist/charts/heatmap-calendar.js.map +1 -1
- package/dist/charts/heatmap-matrix.d.ts +99 -0
- package/dist/charts/heatmap-matrix.js +249 -0
- package/dist/charts/heatmap-matrix.js.map +1 -0
- package/dist/charts/line.d.ts +66 -5
- package/dist/charts/line.js +37 -30
- package/dist/charts/line.js.map +1 -1
- package/dist/charts/palette.d.ts +1 -0
- package/dist/charts/palette.js +7 -1
- package/dist/charts/palette.js.map +1 -1
- package/dist/charts/radar.d.ts +18 -1
- package/dist/charts/radar.js +26 -19
- package/dist/charts/radar.js.map +1 -1
- package/dist/charts/sankey.d.ts +18 -1
- package/dist/charts/sankey.js +4 -1
- package/dist/charts/sankey.js.map +1 -1
- package/dist/charts/series.d.ts +5 -7
- package/dist/charts/series.js.map +1 -1
- package/dist/charts/slot-bar.d.ts +38 -6
- package/dist/charts/slot-bar.js +5 -2
- package/dist/charts/slot-bar.js.map +1 -1
- package/dist/charts/sparkline.d.ts +35 -5
- package/dist/charts/sparkline.js +22 -18
- package/dist/charts/sparkline.js.map +1 -1
- package/dist/charts/stacked-bar.d.ts +58 -5
- package/dist/charts/stacked-bar.js +19 -12
- package/dist/charts/stacked-bar.js.map +1 -1
- package/dist/charts/stat-card.d.ts +51 -1
- package/dist/charts/stat-card.js +66 -39
- package/dist/charts/stat-card.js.map +1 -1
- package/dist/charts/timeline.d.ts +3 -0
- package/dist/charts/timeline.js +4 -3
- package/dist/charts/timeline.js.map +1 -1
- package/dist/charts/timeseries.d.ts +58 -5
- package/dist/charts/timeseries.js +13 -2
- package/dist/charts/timeseries.js.map +1 -1
- package/dist/charts/tooltip.d.ts +57 -0
- package/dist/charts/tooltip.js +119 -2
- package/dist/charts/tooltip.js.map +1 -1
- package/dist/components/accordion.d.ts +117 -2
- package/dist/components/accordion.js +20 -13
- package/dist/components/accordion.js.map +1 -1
- package/dist/components/alert-dialog.d.ts +131 -13
- package/dist/components/alert-dialog.js +12 -9
- package/dist/components/alert-dialog.js.map +1 -1
- package/dist/components/app-header.js +18 -17
- package/dist/components/app-header.js.map +1 -1
- package/dist/components/app-shell.js +15 -14
- package/dist/components/app-shell.js.map +1 -1
- package/dist/components/autocomplete.d.ts +4 -0
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/avatar.d.ts +76 -3
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/badge.d.ts +15 -1
- package/dist/components/badge.js +13 -12
- package/dist/components/badge.js.map +1 -1
- package/dist/components/banner.d.ts +88 -2
- package/dist/components/banner.js +41 -40
- package/dist/components/banner.js.map +1 -1
- package/dist/components/basalt-mark.js +14 -8
- package/dist/components/basalt-mark.js.map +1 -1
- package/dist/components/battery-meter.d.ts +10 -0
- package/dist/components/battery-meter.js +56 -0
- package/dist/components/battery-meter.js.map +1 -0
- package/dist/components/breadcrumbs.d.ts +27 -7
- package/dist/components/breadcrumbs.js +21 -20
- package/dist/components/breadcrumbs.js.map +1 -1
- package/dist/components/button.d.ts +48 -2
- package/dist/components/button.js +87 -36
- package/dist/components/button.js.map +1 -1
- package/dist/components/chat-bubble.d.ts +7 -0
- package/dist/components/chat-bubble.js +14 -13
- package/dist/components/chat-bubble.js.map +1 -1
- package/dist/components/chat-composer.d.ts +7 -3
- package/dist/components/chat-composer.js.map +1 -1
- package/dist/components/chat-header.d.ts +6 -1
- package/dist/components/chat-header.js +17 -16
- package/dist/components/chat-header.js.map +1 -1
- package/dist/components/chat-inbox.d.ts +7 -2
- package/dist/components/chat-inbox.js.map +1 -1
- package/dist/components/checkbox.js +84 -53
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/clipboard-text.d.ts +13 -2
- package/dist/components/clipboard-text.js +4 -4
- package/dist/components/clipboard-text.js.map +1 -1
- package/dist/components/collapsible.d.ts +58 -15
- package/dist/components/collapsible.js.map +1 -1
- package/dist/components/command-palette.d.ts +151 -61
- package/dist/components/command-palette.js.map +1 -1
- package/dist/components/confirm-dialog.d.ts +1 -1
- package/dist/components/confirm-dialog.js +6 -4
- package/dist/components/confirm-dialog.js.map +1 -1
- package/dist/components/context-menu.d.ts +210 -2
- package/dist/components/context-menu.js +7 -4
- package/dist/components/context-menu.js.map +1 -1
- package/dist/components/data-table.d.ts +40 -2
- package/dist/components/data-table.js +168 -120
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +53 -2
- package/dist/components/date-picker.js +387 -219
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/delete-resource.d.ts +7 -1
- package/dist/components/delete-resource.js +22 -18
- package/dist/components/delete-resource.js.map +1 -1
- package/dist/components/description-list.js +16 -15
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/dialog.d.ts +141 -12
- package/dist/components/dialog.js +42 -38
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/dock.d.ts +1 -1
- package/dist/components/dock.js +39 -58
- package/dist/components/dock.js.map +1 -1
- package/dist/components/dropdown-menu.d.ts +229 -15
- package/dist/components/dropdown-menu.js +9 -6
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/editable-nav-item.d.ts +33 -0
- package/dist/components/editable-nav-item.js +90 -0
- package/dist/components/editable-nav-item.js.map +1 -0
- package/dist/components/empty.d.ts +22 -2
- package/dist/components/empty.js +22 -13
- package/dist/components/empty.js.map +1 -1
- package/dist/components/field.js +31 -30
- package/dist/components/field.js.map +1 -1
- package/dist/components/file-dropzone.d.ts +37 -0
- package/dist/components/file-dropzone.js +103 -0
- package/dist/components/file-dropzone.js.map +1 -0
- package/dist/components/filter-bar.d.ts +34 -0
- package/dist/components/filter-bar.js +52 -0
- package/dist/components/filter-bar.js.map +1 -0
- package/dist/components/flow.js +19 -18
- package/dist/components/flow.js.map +1 -1
- package/dist/components/grid.d.ts +3 -1
- package/dist/components/grid.js.map +1 -1
- package/dist/components/hover-card.d.ts +111 -1
- package/dist/components/hover-card.js +9 -6
- package/dist/components/hover-card.js.map +1 -1
- package/dist/components/icon-picker.d.ts +34 -0
- package/dist/components/icon-picker.js +77 -0
- package/dist/components/icon-picker.js.map +1 -0
- package/dist/components/inline-editable.d.ts +46 -0
- package/dist/components/inline-editable.js +124 -0
- package/dist/components/inline-editable.js.map +1 -0
- package/dist/components/input-area.js +3 -3
- package/dist/components/input-group.js +7 -7
- package/dist/components/input.js +3 -3
- package/dist/components/label.js +18 -17
- package/dist/components/label.js.map +1 -1
- package/dist/components/layer-card.d.ts +10 -2
- package/dist/components/layer-card.js +71 -68
- package/dist/components/layer-card.js.map +1 -1
- package/dist/components/loader.d.ts +10 -2
- package/dist/components/loader.js.map +1 -1
- package/dist/components/menu-bar.d.ts +174 -6
- package/dist/components/menu-bar.js +33 -29
- package/dist/components/menu-bar.js.map +1 -1
- package/dist/components/meter.d.ts +27 -2
- package/dist/components/meter.js.map +1 -1
- package/dist/components/multi-select.d.ts +64 -0
- package/dist/components/multi-select.js +218 -0
- package/dist/components/multi-select.js.map +1 -0
- package/dist/components/navigation-menu.d.ts +88 -5
- package/dist/components/navigation-menu.js.map +1 -1
- package/dist/components/overlay.js +6 -5
- package/dist/components/overlay.js.map +1 -1
- package/dist/components/page-header.js +23 -21
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/pagination.js +7 -7
- package/dist/components/popover.d.ts +136 -16
- package/dist/components/popover.js +32 -28
- package/dist/components/popover.js.map +1 -1
- package/dist/components/radio.js +38 -37
- package/dist/components/radio.js.map +1 -1
- package/dist/components/resource-list.d.ts +26 -1
- package/dist/components/resource-list.js +28 -15
- package/dist/components/resource-list.js.map +1 -1
- package/dist/components/responsive-master-detail.d.ts +27 -0
- package/dist/components/responsive-master-detail.js +85 -0
- package/dist/components/responsive-master-detail.js.map +1 -0
- package/dist/components/section-rule.js +23 -22
- package/dist/components/section-rule.js.map +1 -1
- package/dist/components/select.d.ts +27 -3
- package/dist/components/select.js +11 -11
- package/dist/components/select.js.map +1 -1
- package/dist/components/sheet.d.ts +115 -11
- package/dist/components/sheet.js +37 -30
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/sidebar.d.ts +109 -17
- package/dist/components/sidebar.js +112 -111
- package/dist/components/sidebar.js.map +1 -1
- package/dist/components/skeleton-line.d.ts +22 -2
- package/dist/components/skeleton-line.js.map +1 -1
- package/dist/components/slider.d.ts +61 -1
- package/dist/components/slider.js +31 -15
- package/dist/components/slider.js.map +1 -1
- package/dist/components/stat-strip.js +16 -15
- package/dist/components/stat-strip.js.map +1 -1
- package/dist/components/switch.js +78 -47
- package/dist/components/switch.js.map +1 -1
- package/dist/components/table-of-contents.js +18 -17
- package/dist/components/table-of-contents.js.map +1 -1
- package/dist/components/table-pager.js +20 -19
- package/dist/components/table-pager.js.map +1 -1
- package/dist/components/table.d.ts +9 -3
- package/dist/components/table.js +19 -18
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.js +29 -22
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/tag-badge.d.ts +58 -0
- package/dist/components/tag-badge.js +72 -0
- package/dist/components/tag-badge.js.map +1 -0
- package/dist/components/tag-color-picker.d.ts +20 -0
- package/dist/components/tag-color-picker.js +42 -0
- package/dist/components/tag-color-picker.js.map +1 -0
- package/dist/components/text.js +17 -16
- package/dist/components/text.js.map +1 -1
- package/dist/components/toast.d.ts +173 -3
- package/dist/components/toast.js +1 -1
- package/dist/components/toast.js.map +1 -1
- package/dist/components/toggle-group.d.ts +88 -2
- package/dist/components/toggle-group.js +32 -31
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle.d.ts +35 -2
- package/dist/components/toggle.js +12 -11
- package/dist/components/toggle.js.map +1 -1
- package/dist/components/tooltip.d.ts +144 -6
- package/dist/components/tooltip.js +9 -6
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/typeahead-field.js +193 -132
- package/dist/components/typeahead-field.js.map +1 -1
- package/dist/components/upload-queue.d.ts +51 -0
- package/dist/components/upload-queue.js +116 -0
- package/dist/components/upload-queue.js.map +1 -0
- package/dist/providers/accent.d.ts +46 -2
- package/dist/providers/accent.js +358 -172
- package/dist/providers/accent.js.map +1 -1
- package/dist/providers/link.d.ts +14 -4
- package/dist/providers/link.js.map +1 -1
- package/dist/providers/theme.d.ts +38 -2
- package/dist/providers/theme.js +160 -27
- package/dist/providers/theme.js.map +1 -1
- package/dist/styles/base.css +83 -0
- package/dist/styles/standalone.css +699 -120
- package/dist/styles/tailwind.css +21 -7
- package/dist/styles/tokens.css +145 -91
- package/dist/utils/control-surface.d.ts +2 -1
- package/dist/utils/control-surface.js +4 -4
- package/dist/utils/control-surface.js.map +1 -1
- package/dist/utils/selection-indicator.js +2 -2
- package/dist/utils/selection-indicator.js.map +1 -1
- package/package.json +8 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-inbox.js","names":[],"sources":["../../src/components/chat-inbox.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { Button } from \"./button\";\n\nexport interface ChatInboxItem {\n\t/** Stable id for selection. */\n\tid: string;\n\t/** Thread title. */\n\ttitle: string;\n\t/** Last-message preview. */\n\tpreview?: string;\n\t/** Timestamp label. */\n\ttime?: string;\n\t/** Optional leading mark. */\n\tleading?: ReactNode;\n}\n\nexport interface ChatInboxProps
|
|
1
|
+
{"version":3,"file":"chat-inbox.js","names":[],"sources":["../../src/components/chat-inbox.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { Button } from \"./button\";\n\nexport interface ChatInboxItem {\n\t/** Stable id for selection. */\n\tid: string;\n\t/** Thread title. */\n\ttitle: string;\n\t/** Last-message preview. */\n\tpreview?: string;\n\t/** Timestamp label. */\n\ttime?: string;\n\t/** Optional leading mark. */\n\tleading?: ReactNode;\n}\n\nexport interface ChatInboxProps\n\textends Omit<HTMLAttributes<HTMLElement>, \"onSelect\" | \"className\"> {\n\t/**\n\t * Threads to list ({ id: string, title: string, preview?: string, time?: string, leading?: ReactNode }[]).\n\t */\n\titems: readonly ChatInboxItem[];\n\t/**\n\t * Selected thread id.\n\t */\n\tactiveId?: string;\n\t/**\n\t * Called when a thread is chosen.\n\t */\n\tonSelect: (id: string) => void;\n\t/**\n\t * Optional class name applied to the navigation element.\n\t * Component inherits native nav HTMLAttributes on the root element but does not forward ref.\n\t */\n\tclassName?: string;\n}\n\nexport function ChatInbox({ items, activeId, onSelect, className, ...props }: ChatInboxProps) {\n\treturn (\n\t\t<nav className={cn(\"flex min-h-0 flex-col gap-0.5 overflow-y-auto p-2\", className)} {...props}>\n\t\t\t{items.map((item) => {\n\t\t\t\tconst active = item.id === activeId;\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={item.id}\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tvariant=\"ghost\"\n\t\t\t\t\t\taria-current={active ? \"true\" : undefined}\n\t\t\t\t\t\tonClick={() => onSelect(item.id)}\n\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\"h-auto w-full justify-start gap-2 rounded-basalt-md px-2 py-2 text-left\",\n\t\t\t\t\t\t\tactive ? \"bg-basalt-accent\" : \"\",\n\t\t\t\t\t\t)}\n\t\t\t\t\t>\n\t\t\t\t\t\t{item.leading ? (\n\t\t\t\t\t\t\t<span className=\"flex h-8 w-8 shrink-0 items-center justify-center\">\n\t\t\t\t\t\t\t\t{item.leading}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t<span className=\"min-w-0 flex-1\">\n\t\t\t\t\t\t\t<span className=\"flex items-baseline justify-between gap-2\">\n\t\t\t\t\t\t\t\t<span className=\"truncate text-sm font-medium text-basalt-foreground\">\n\t\t\t\t\t\t\t\t\t{item.title}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t{item.time ? (\n\t\t\t\t\t\t\t\t\t<span className=\"shrink-0 text-[11px] text-basalt-muted-foreground\">\n\t\t\t\t\t\t\t\t\t\t{item.time}\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{item.preview ? (\n\t\t\t\t\t\t\t\t<span className=\"mt-0.5 block truncate text-xs text-basalt-muted-foreground\">\n\t\t\t\t\t\t\t\t\t{item.preview}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t})}\n\t\t</nav>\n\t);\n}\n"],"mappings":";;;;;AAsCA,SAAgB,EAAU,EAAE,UAAO,aAAU,aAAU,cAAW,GAAG,KAAyB;CAC7F,OACC,kBAAC,OAAD;EAAK,WAAW,EAAG,qDAAqD,CAAS;EAAG,GAAI;EACtF,UAAA,EAAM,KAAK,MAAS;GACpB,IAAM,IAAS,EAAK,OAAO;GAC3B,OACC,kBAAC,GAAD;IAEC,MAAK;IACL,SAAQ;IACR,gBAAc,IAAS,SAAS,KAAA;IAChC,eAAe,EAAS,EAAK,EAAE;IAC/B,WAAW,EACV,2EACA,IAAS,qBAAqB,EAC/B;IATD,UAAA,CAWE,EAAK,UACL,kBAAC,QAAD;KAAM,WAAU;KACd,UAAA,EAAK;IACD,CAAA,IACH,MACJ,kBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACC,kBAAC,QAAD;MAAM,WAAU;MAAhB,UAAA,CACC,kBAAC,QAAD;OAAM,WAAU;OACd,UAAA,EAAK;MACD,CAAA,GACL,EAAK,OACL,kBAAC,QAAD;OAAM,WAAU;OACd,UAAA,EAAK;MACD,CAAA,IACH,IACC;KACL,CAAA,GAAA,EAAK,UACL,kBAAC,QAAD;MAAM,WAAU;MACd,UAAA,EAAK;KACD,CAAA,IACH,IACC;IACC,CAAA,CAAA;GAhCF,GAAA,EAAK,EAgCH;EAEV,CAAC;CACG,CAAA;AAEP"}
|
|
@@ -1,64 +1,94 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn as e } from "../utils/cn.js";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
3
|
+
import { BASALT_UI_CLASS as t } from "../utils/control-surface.js";
|
|
4
|
+
import { FOCUS_RING as n } from "./overlay.js";
|
|
5
|
+
import * as r from "react";
|
|
6
|
+
import { Check as i, Minus as a } from "lucide-react";
|
|
7
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
8
|
+
import * as c from "@radix-ui/react-checkbox";
|
|
8
9
|
//#region src/components/checkbox.tsx
|
|
9
|
-
var
|
|
10
|
+
var l = {
|
|
10
11
|
sm: "h-3 w-3",
|
|
11
12
|
default: "h-4 w-4"
|
|
12
|
-
},
|
|
13
|
+
}, u = {
|
|
13
14
|
sm: "hidden h-3 w-3 group-data-[state=checked]:block",
|
|
14
15
|
default: "hidden h-4 w-4 group-data-[state=checked]:block"
|
|
15
|
-
},
|
|
16
|
+
}, d = {
|
|
16
17
|
sm: "hidden h-2.5 w-2.5 group-data-[state=indeterminate]:block",
|
|
17
18
|
default: "hidden h-3 w-3 group-data-[state=indeterminate]:block"
|
|
18
|
-
},
|
|
19
|
-
function
|
|
19
|
+
}, f = r.createContext(null);
|
|
20
|
+
function p(e, t, n) {
|
|
20
21
|
return n ? e.includes(t) ? e : [...e, t] : e.filter((e) => e !== t);
|
|
21
22
|
}
|
|
22
|
-
var
|
|
23
|
-
ref:
|
|
24
|
-
className: e("group peer shrink-0 rounded-[4px] border border-basalt-primary data-[state=checked]:bg-basalt-primary data-[state=checked]:text-basalt-primary-foreground data-[state=indeterminate]:bg-basalt-primary data-[state=indeterminate]:text-basalt-primary-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
|
25
|
-
...
|
|
26
|
-
children: /* @__PURE__ */
|
|
23
|
+
var m = r.forwardRef(({ className: r, size: f = "default", ...p }, m) => /* @__PURE__ */ o(c.Root, {
|
|
24
|
+
ref: m,
|
|
25
|
+
className: e(t, "group peer shrink-0 rounded-[4px] border border-basalt-primary data-[state=checked]:bg-basalt-primary data-[state=checked]:text-basalt-primary-foreground data-[state=indeterminate]:bg-basalt-primary data-[state=indeterminate]:text-basalt-primary-foreground disabled:cursor-not-allowed disabled:opacity-50", l[f], n, r),
|
|
26
|
+
...p,
|
|
27
|
+
children: /* @__PURE__ */ s(c.Indicator, {
|
|
27
28
|
className: "flex items-center justify-center text-current",
|
|
28
|
-
children: [/* @__PURE__ */
|
|
29
|
+
children: [/* @__PURE__ */ o(i, { className: u[f] }), /* @__PURE__ */ o(a, { className: d[f] })]
|
|
29
30
|
})
|
|
30
31
|
}));
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
let g =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
m.displayName = c.Root.displayName;
|
|
33
|
+
var h = r.forwardRef(({ className: t, value: n, defaultValue: i, onValueChange: a, error: c, disabled: l = !1, children: u, "aria-describedby": d, "aria-invalid": p, ...m }, h) => {
|
|
34
|
+
let g = r.useId(), _ = r.useRef(null), [v, y] = r.useState(i ?? []), b = n ?? v, x = !!c, S = `${g}-error`, C = [x ? S : null, d].filter(Boolean).join(" ") || void 0, w = r.useRef(null), T = r.useCallback((e) => {
|
|
35
|
+
let t = w.current;
|
|
36
|
+
t && t.eventPhase !== Event.NONE || (n === void 0 && y(e), a?.(e));
|
|
37
|
+
}, [a, n]), E = r.useCallback((e) => {
|
|
38
|
+
if (_.current = e, h) {
|
|
39
|
+
if (typeof h == "function") {
|
|
40
|
+
let t = h(e);
|
|
41
|
+
return typeof t == "function" ? () => {
|
|
42
|
+
_.current = null, t();
|
|
43
|
+
} : () => {
|
|
44
|
+
_.current = null, h(null);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return h.current = e, () => {
|
|
48
|
+
_.current = null, h.current = null;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}, [h]), D = m.form, O = r.useRef({
|
|
52
|
+
defaultValue: i,
|
|
53
|
+
value: n
|
|
54
|
+
});
|
|
55
|
+
return r.useEffect(() => {
|
|
56
|
+
O.current = {
|
|
57
|
+
defaultValue: i,
|
|
58
|
+
value: n
|
|
59
|
+
};
|
|
60
|
+
}), r.useEffect(() => {
|
|
39
61
|
let e = _.current?.form;
|
|
40
|
-
if (!e ||
|
|
41
|
-
let t = (e) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
62
|
+
if (!e || D && e.id !== D) return;
|
|
63
|
+
let t = !1, n = /* @__PURE__ */ new Set(), r = (e) => {
|
|
64
|
+
w.current = e;
|
|
65
|
+
let r = setTimeout(() => {
|
|
66
|
+
if (n.delete(r), t || e.defaultPrevented) return;
|
|
67
|
+
let i = O.current;
|
|
68
|
+
i.value === void 0 && y(i.defaultValue ?? []);
|
|
69
|
+
}, 0);
|
|
70
|
+
n.add(r);
|
|
71
|
+
};
|
|
72
|
+
return e.addEventListener("reset", r, !0), () => {
|
|
73
|
+
t = !0, w.current = null;
|
|
74
|
+
for (let e of n) clearTimeout(e);
|
|
75
|
+
n.clear(), e.removeEventListener("reset", r, !0);
|
|
45
76
|
};
|
|
46
|
-
|
|
47
|
-
}, [i, r]), /* @__PURE__ */ a(d.Provider, {
|
|
77
|
+
}, [D]), /* @__PURE__ */ o(f.Provider, {
|
|
48
78
|
value: {
|
|
49
79
|
value: b,
|
|
50
|
-
setValue:
|
|
80
|
+
setValue: T,
|
|
51
81
|
disabled: l,
|
|
52
82
|
invalid: x
|
|
53
83
|
},
|
|
54
|
-
children: /* @__PURE__ */
|
|
55
|
-
ref:
|
|
84
|
+
children: /* @__PURE__ */ s("fieldset", {
|
|
85
|
+
ref: E,
|
|
56
86
|
...m,
|
|
57
87
|
disabled: l,
|
|
58
88
|
"aria-invalid": x ? !0 : p,
|
|
59
89
|
"aria-describedby": C,
|
|
60
90
|
className: e("flex flex-col gap-2", t),
|
|
61
|
-
children: [u, x ? /* @__PURE__ */
|
|
91
|
+
children: [u, x ? /* @__PURE__ */ o("p", {
|
|
62
92
|
id: S,
|
|
63
93
|
className: "text-xs text-basalt-destructive",
|
|
64
94
|
role: "alert",
|
|
@@ -67,41 +97,42 @@ var m = n.forwardRef(({ className: t, value: r, defaultValue: i, onValueChange:
|
|
|
67
97
|
})
|
|
68
98
|
});
|
|
69
99
|
});
|
|
70
|
-
|
|
71
|
-
var
|
|
100
|
+
h.displayName = "Checkbox.Group";
|
|
101
|
+
var g = r.forwardRef(({ className: t, ...n }, r) => /* @__PURE__ */ o("legend", {
|
|
72
102
|
ref: r,
|
|
73
103
|
className: e("text-sm font-medium text-basalt-foreground", t),
|
|
74
104
|
...n
|
|
75
105
|
}));
|
|
76
|
-
|
|
77
|
-
var
|
|
78
|
-
let
|
|
106
|
+
g.displayName = "Checkbox.Legend";
|
|
107
|
+
var _ = r.forwardRef(({ className: e, value: t, children: n, disabled: i, size: a, id: c, ...l }, u) => {
|
|
108
|
+
let d = r.useContext(f), h = d != null, g = r.useId(), _ = c ?? g, v = h ? d.value.includes(t) : void 0, y = /* @__PURE__ */ o(m, {
|
|
79
109
|
ref: u,
|
|
80
110
|
...l,
|
|
81
111
|
id: _,
|
|
82
112
|
value: t,
|
|
83
|
-
size:
|
|
84
|
-
checked:
|
|
85
|
-
|
|
86
|
-
|
|
113
|
+
size: a,
|
|
114
|
+
checked: v,
|
|
115
|
+
defaultChecked: h ? v : void 0,
|
|
116
|
+
disabled: i || d?.disabled,
|
|
117
|
+
"aria-invalid": d?.invalid || void 0,
|
|
87
118
|
className: e,
|
|
88
119
|
onCheckedChange: (e) => {
|
|
89
|
-
h && typeof e == "boolean" &&
|
|
120
|
+
h && typeof e == "boolean" && d.setValue(p(d.value, t, e));
|
|
90
121
|
}
|
|
91
122
|
});
|
|
92
|
-
return
|
|
123
|
+
return n == null ? y : /* @__PURE__ */ s("label", {
|
|
93
124
|
htmlFor: _,
|
|
94
125
|
className: "flex items-center gap-2 text-sm text-basalt-foreground",
|
|
95
|
-
children: [
|
|
126
|
+
children: [y, n]
|
|
96
127
|
});
|
|
97
128
|
});
|
|
98
|
-
|
|
99
|
-
var
|
|
100
|
-
Group:
|
|
101
|
-
Legend:
|
|
102
|
-
Item:
|
|
129
|
+
_.displayName = "Checkbox.Item";
|
|
130
|
+
var v = Object.assign(m, {
|
|
131
|
+
Group: h,
|
|
132
|
+
Legend: g,
|
|
133
|
+
Item: _
|
|
103
134
|
});
|
|
104
135
|
//#endregion
|
|
105
|
-
export {
|
|
136
|
+
export { v as Checkbox };
|
|
106
137
|
|
|
107
138
|
//# sourceMappingURL=checkbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.js","names":[],"sources":["../../src/components/checkbox.tsx"],"sourcesContent":["import * as CheckboxPrimitive from \"@radix-ui/react-checkbox\";\nimport { Check, Minus } from \"lucide-react\";\nimport * as React from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { FOCUS_RING } from \"./overlay\";\n\nexport type CheckboxSize = \"sm\" | \"default\";\n\nconst CHECKBOX_SIZE_CLASS: Record<CheckboxSize, string> = {\n\tsm: \"h-3 w-3\",\n\tdefault: \"h-4 w-4\",\n};\n\nconst CHECK_ICON_CLASS: Record<CheckboxSize, string> = {\n\tsm: \"hidden h-3 w-3 group-data-[state=checked]:block\",\n\tdefault: \"hidden h-4 w-4 group-data-[state=checked]:block\",\n};\n\nconst MINUS_ICON_CLASS: Record<CheckboxSize, string> = {\n\tsm: \"hidden h-2.5 w-2.5 group-data-[state=indeterminate]:block\",\n\tdefault: \"hidden h-3 w-3 group-data-[state=indeterminate]:block\",\n};\n\ntype CheckboxGroupContextValue = {\n\tvalue: string[];\n\tsetValue: (next: string[]) => void;\n\tdisabled: boolean;\n\tinvalid: boolean;\n};\n\nconst CheckboxGroupContext = React.createContext<CheckboxGroupContextValue | null>(null);\n\nfunction nextCheckboxGroupValue(current: string[], itemValue: string, checked: boolean): string[] {\n\tif (checked) {\n\t\treturn current.includes(itemValue) ? current : [...current, itemValue];\n\t}\n\treturn current.filter((entry) => entry !== itemValue);\n}\n\nexport type CheckboxProps = Omit<\n\tReact.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>,\n\t\"checked\"\n> & {\n\t/**\n\t * The controlled checked state of the checkbox.\n\t */\n\tchecked?: boolean | \"indeterminate\";\n\t/**\n\t * The visual size of the checkbox.\n\t * @default default\n\t */\n\tsize?: CheckboxSize;\n};\n\nexport type CheckboxGroupProps = Omit<\n\tReact.ComponentPropsWithoutRef<\"fieldset\">,\n\t\"onChange\" | \"defaultValue\" | \"disabled\"\n> & {\n\t/**\n\t * The controlled selected values.\n\t */\n\tvalue?: string[];\n\t/**\n\t * The initially selected values.\n\t */\n\tdefaultValue?: string[];\n\t/**\n\t * Called when the selected values change.\n\t */\n\tonValueChange?: (value: string[]) => void;\n\t/**\n\t * Marks the group invalid and shows alert copy.\n\t */\n\terror?: React.ReactNode;\n\t/**\n\t * Disable every item in the group.\n\t * @default false\n\t */\n\tdisabled?: boolean;\n};\n\nexport type CheckboxLegendProps = React.ComponentPropsWithoutRef<\"legend\">;\n\nexport type CheckboxItemProps = Omit<\n\tCheckboxProps,\n\t\"checked\" | \"defaultChecked\" | \"onCheckedChange\" | \"value\"\n> & {\n\t/**\n\t * The value stored in the group when this item is checked.\n\t */\n\tvalue: string;\n};\n\nconst CheckboxRoot = React.forwardRef<\n\tReact.ElementRef<typeof CheckboxPrimitive.Root>,\n\tCheckboxProps\n>(({ className, size = \"default\", ...props }, ref) => (\n\t<CheckboxPrimitive.Root\n\t\tref={ref}\n\t\tclassName={cn(\n\t\t\t\"group peer shrink-0 rounded-[4px] border border-basalt-primary data-[state=checked]:bg-basalt-primary data-[state=checked]:text-basalt-primary-foreground data-[state=indeterminate]:bg-basalt-primary data-[state=indeterminate]:text-basalt-primary-foreground disabled:cursor-not-allowed disabled:opacity-50\",\n\t\t\tCHECKBOX_SIZE_CLASS[size],\n\t\t\tFOCUS_RING,\n\t\t\tclassName,\n\t\t)}\n\t\t{...props}\n\t>\n\t\t<CheckboxPrimitive.Indicator className=\"flex items-center justify-center text-current\">\n\t\t\t<Check className={CHECK_ICON_CLASS[size]} />\n\t\t\t<Minus className={MINUS_ICON_CLASS[size]} />\n\t\t</CheckboxPrimitive.Indicator>\n\t</CheckboxPrimitive.Root>\n));\nCheckboxRoot.displayName = CheckboxPrimitive.Root.displayName;\n\nconst CheckboxGroup = React.forwardRef<HTMLFieldSetElement, CheckboxGroupProps>(\n\t(\n\t\t{\n\t\t\tclassName,\n\t\t\tvalue,\n\t\t\tdefaultValue,\n\t\t\tonValueChange,\n\t\t\terror,\n\t\t\tdisabled = false,\n\t\t\tchildren,\n\t\t\t\"aria-describedby\": describedBy,\n\t\t\t\"aria-invalid\": ariaInvalid,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst generatedId = React.useId();\n\t\tconst nodeRef = React.useRef<HTMLFieldSetElement | null>(null);\n\t\tconst [uncontrolled, setUncontrolled] = React.useState(defaultValue ?? []);\n\t\tconst current = value ?? uncontrolled;\n\t\tconst invalid = Boolean(error);\n\t\tconst errorId = `${generatedId}-error`;\n\t\tconst mergedDescribedBy =\n\t\t\t[invalid ? errorId : null, describedBy].filter(Boolean).join(\" \") || undefined;\n\t\tconst setValue = React.useCallback(\n\t\t\t(next: string[]) => {\n\t\t\t\tif (value === undefined) {\n\t\t\t\t\tsetUncontrolled(next);\n\t\t\t\t}\n\t\t\t\tonValueChange?.(next);\n\t\t\t},\n\t\t\t[onValueChange, value],\n\t\t);\n\t\tconst setRefs = React.useCallback(\n\t\t\t(node: HTMLFieldSetElement | null) => {\n\t\t\t\tnodeRef.current = node;\n\t\t\t\tif (typeof ref === \"function\") {\n\t\t\t\t\tref(node);\n\t\t\t\t} else if (ref) {\n\t\t\t\t\tref.current = node;\n\t\t\t\t}\n\t\t\t},\n\t\t\t[ref],\n\t\t);\n\t\tReact.useEffect(() => {\n\t\t\tconst form = nodeRef.current?.form;\n\t\t\tif (!form || value !== undefined) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst onReset = (event: Event) => {\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tif (event.defaultPrevented) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tsetUncontrolled(defaultValue ?? []);\n\t\t\t\t});\n\t\t\t};\n\t\t\tform.addEventListener(\"reset\", onReset);\n\t\t\treturn () => form.removeEventListener(\"reset\", onReset);\n\t\t}, [defaultValue, value]);\n\t\treturn (\n\t\t\t<CheckboxGroupContext.Provider value={{ value: current, setValue, disabled, invalid }}>\n\t\t\t\t<fieldset\n\t\t\t\t\tref={setRefs}\n\t\t\t\t\t{...props}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\taria-invalid={invalid ? true : ariaInvalid}\n\t\t\t\t\taria-describedby={mergedDescribedBy}\n\t\t\t\t\tclassName={cn(\"flex flex-col gap-2\", className)}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t\t{invalid ? (\n\t\t\t\t\t\t<p id={errorId} className=\"text-xs text-basalt-destructive\" role=\"alert\">\n\t\t\t\t\t\t\t{error}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) : null}\n\t\t\t\t</fieldset>\n\t\t\t</CheckboxGroupContext.Provider>\n\t\t);\n\t},\n);\nCheckboxGroup.displayName = \"Checkbox.Group\";\n\nconst CheckboxLegend = React.forwardRef<HTMLLegendElement, CheckboxLegendProps>(\n\t({ className, ...props }, ref) => (\n\t\t<legend\n\t\t\tref={ref}\n\t\t\tclassName={cn(\"text-sm font-medium text-basalt-foreground\", className)}\n\t\t\t{...props}\n\t\t/>\n\t),\n);\nCheckboxLegend.displayName = \"Checkbox.Legend\";\n\nconst CheckboxItem = React.forwardRef<\n\tReact.ElementRef<typeof CheckboxPrimitive.Root>,\n\tCheckboxItemProps\n>(({ className, value, children, disabled, size, id, ...props }, ref) => {\n\tconst group = React.useContext(CheckboxGroupContext);\n\tconst grouped = group != null;\n\tconst generatedId = React.useId();\n\tconst controlId = id ?? generatedId;\n\tconst box = (\n\t\t<CheckboxRoot\n\t\t\tref={ref}\n\t\t\t{...props}\n\t\t\tid={controlId}\n\t\t\tvalue={value}\n\t\t\tsize={size}\n\t\t\tchecked={grouped ? group.value.includes(value) : undefined}\n\t\t\tdisabled={disabled || group?.disabled}\n\t\t\taria-invalid={group?.invalid || undefined}\n\t\t\tclassName={className}\n\t\t\tonCheckedChange={(next) => {\n\t\t\t\tif (grouped && typeof next === \"boolean\") {\n\t\t\t\t\tgroup.setValue(nextCheckboxGroupValue(group.value, value, next));\n\t\t\t\t}\n\t\t\t}}\n\t\t/>\n\t);\n\tif (children == null) {\n\t\treturn box;\n\t}\n\treturn (\n\t\t<label htmlFor={controlId} className=\"flex items-center gap-2 text-sm text-basalt-foreground\">\n\t\t\t{box}\n\t\t\t{children}\n\t\t</label>\n\t);\n});\nCheckboxItem.displayName = \"Checkbox.Item\";\n\nexport const Checkbox = Object.assign(CheckboxRoot, {\n\tGroup: CheckboxGroup,\n\tLegend: CheckboxLegend,\n\tItem: CheckboxItem,\n});\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"checkbox.js","names":[],"sources":["../../src/components/checkbox.tsx"],"sourcesContent":["import * as CheckboxPrimitive from \"@radix-ui/react-checkbox\";\nimport { Check, Minus } from \"lucide-react\";\nimport * as React from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { BASALT_UI_CLASS } from \"../utils/control-surface\";\nimport { FOCUS_RING } from \"./overlay\";\n\nexport type CheckboxSize = \"sm\" | \"default\";\n\nconst CHECKBOX_SIZE_CLASS: Record<CheckboxSize, string> = {\n\tsm: \"h-3 w-3\",\n\tdefault: \"h-4 w-4\",\n};\n\nconst CHECK_ICON_CLASS: Record<CheckboxSize, string> = {\n\tsm: \"hidden h-3 w-3 group-data-[state=checked]:block\",\n\tdefault: \"hidden h-4 w-4 group-data-[state=checked]:block\",\n};\n\nconst MINUS_ICON_CLASS: Record<CheckboxSize, string> = {\n\tsm: \"hidden h-2.5 w-2.5 group-data-[state=indeterminate]:block\",\n\tdefault: \"hidden h-3 w-3 group-data-[state=indeterminate]:block\",\n};\n\ntype CheckboxGroupContextValue = {\n\tvalue: string[];\n\tsetValue: (next: string[]) => void;\n\tdisabled: boolean;\n\tinvalid: boolean;\n};\n\nconst CheckboxGroupContext = React.createContext<CheckboxGroupContextValue | null>(null);\n\nfunction nextCheckboxGroupValue(current: string[], itemValue: string, checked: boolean): string[] {\n\tif (checked) {\n\t\treturn current.includes(itemValue) ? current : [...current, itemValue];\n\t}\n\treturn current.filter((entry) => entry !== itemValue);\n}\n\nexport type CheckboxProps = Omit<\n\tReact.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>,\n\t\"checked\"\n> & {\n\t/**\n\t * The controlled checked state of the checkbox.\n\t */\n\tchecked?: boolean | \"indeterminate\";\n\t/**\n\t * The visual size of the checkbox.\n\t * @default default\n\t */\n\tsize?: CheckboxSize;\n};\n\nexport type CheckboxGroupProps = Omit<\n\tReact.ComponentPropsWithoutRef<\"fieldset\">,\n\t\"onChange\" | \"defaultValue\" | \"disabled\"\n> & {\n\t/**\n\t * The controlled selected values.\n\t */\n\tvalue?: string[];\n\t/**\n\t * The initially selected values.\n\t */\n\tdefaultValue?: string[];\n\t/**\n\t * Called when the selected values change.\n\t */\n\tonValueChange?: (value: string[]) => void;\n\t/**\n\t * Marks the group invalid and shows alert copy.\n\t */\n\terror?: React.ReactNode;\n\t/**\n\t * Disable every item in the group.\n\t * @default false\n\t */\n\tdisabled?: boolean;\n};\n\nexport type CheckboxLegendProps = React.ComponentPropsWithoutRef<\"legend\">;\n\nexport type CheckboxItemProps = Omit<\n\tCheckboxProps,\n\t\"checked\" | \"defaultChecked\" | \"onCheckedChange\" | \"value\"\n> & {\n\t/**\n\t * The value stored in the group when this item is checked.\n\t */\n\tvalue: string;\n};\n\nconst CheckboxRoot = React.forwardRef<\n\tReact.ElementRef<typeof CheckboxPrimitive.Root>,\n\tCheckboxProps\n>(({ className, size = \"default\", ...props }, ref) => (\n\t<CheckboxPrimitive.Root\n\t\tref={ref}\n\t\tclassName={cn(\n\t\t\tBASALT_UI_CLASS,\n\t\t\t\"group peer shrink-0 rounded-[4px] border border-basalt-primary data-[state=checked]:bg-basalt-primary data-[state=checked]:text-basalt-primary-foreground data-[state=indeterminate]:bg-basalt-primary data-[state=indeterminate]:text-basalt-primary-foreground disabled:cursor-not-allowed disabled:opacity-50\",\n\t\t\tCHECKBOX_SIZE_CLASS[size],\n\t\t\tFOCUS_RING,\n\t\t\tclassName,\n\t\t)}\n\t\t{...props}\n\t>\n\t\t<CheckboxPrimitive.Indicator className=\"flex items-center justify-center text-current\">\n\t\t\t<Check className={CHECK_ICON_CLASS[size]} />\n\t\t\t<Minus className={MINUS_ICON_CLASS[size]} />\n\t\t</CheckboxPrimitive.Indicator>\n\t</CheckboxPrimitive.Root>\n));\nCheckboxRoot.displayName = CheckboxPrimitive.Root.displayName;\n\nconst CheckboxGroup = React.forwardRef<HTMLFieldSetElement, CheckboxGroupProps>(\n\t(\n\t\t{\n\t\t\tclassName,\n\t\t\tvalue,\n\t\t\tdefaultValue,\n\t\t\tonValueChange,\n\t\t\terror,\n\t\t\tdisabled = false,\n\t\t\tchildren,\n\t\t\t\"aria-describedby\": describedBy,\n\t\t\t\"aria-invalid\": ariaInvalid,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst generatedId = React.useId();\n\t\tconst nodeRef = React.useRef<HTMLFieldSetElement | null>(null);\n\t\tconst [uncontrolled, setUncontrolled] = React.useState(defaultValue ?? []);\n\t\tconst current = value ?? uncontrolled;\n\t\tconst invalid = Boolean(error);\n\t\tconst errorId = `${generatedId}-error`;\n\t\tconst mergedDescribedBy =\n\t\t\t[invalid ? errorId : null, describedBy].filter(Boolean).join(\" \") || undefined;\n\t\tconst resetEventRef = React.useRef<Event | null>(null);\n\t\tconst setValue = React.useCallback(\n\t\t\t(next: string[]) => {\n\t\t\t\tconst activeReset = resetEventRef.current;\n\t\t\t\tif (activeReset && activeReset.eventPhase !== Event.NONE) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (value === undefined) {\n\t\t\t\t\tsetUncontrolled(next);\n\t\t\t\t}\n\t\t\t\tonValueChange?.(next);\n\t\t\t},\n\t\t\t[onValueChange, value],\n\t\t);\n\t\tconst setRefs = React.useCallback(\n\t\t\t(node: HTMLFieldSetElement | null) => {\n\t\t\t\tnodeRef.current = node;\n\t\t\t\tif (!ref) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (typeof ref === \"function\") {\n\t\t\t\t\tconst cleanup = (ref as React.RefCallback<HTMLFieldSetElement>)(node);\n\t\t\t\t\tif (typeof cleanup === \"function\") {\n\t\t\t\t\t\treturn () => {\n\t\t\t\t\t\t\tnodeRef.current = null;\n\t\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tnodeRef.current = null;\n\t\t\t\t\t\tref(null);\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\t(ref as React.RefObject<HTMLFieldSetElement | null>).current = node;\n\t\t\t\treturn () => {\n\t\t\t\t\tnodeRef.current = null;\n\t\t\t\t\t(ref as React.RefObject<HTMLFieldSetElement | null>).current = null;\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ref],\n\t\t);\n\t\tconst formAttr = props.form;\n\t\tconst latestConfigRef = React.useRef({\n\t\t\tdefaultValue,\n\t\t\tvalue,\n\t\t});\n\t\tReact.useEffect(() => {\n\t\t\tlatestConfigRef.current = {\n\t\t\t\tdefaultValue,\n\t\t\t\tvalue,\n\t\t\t};\n\t\t});\n\n\t\tReact.useEffect(() => {\n\t\t\tconst form = nodeRef.current?.form;\n\t\t\tif (!form || (formAttr && form.id !== formAttr)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet disposed = false;\n\t\t\tconst timers = new Set<ReturnType<typeof setTimeout>>();\n\t\t\tconst onReset = (event: Event) => {\n\t\t\t\tresetEventRef.current = event;\n\t\t\t\tconst timer = setTimeout(() => {\n\t\t\t\t\ttimers.delete(timer);\n\t\t\t\t\tif (disposed || event.defaultPrevented) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst cfg = latestConfigRef.current;\n\t\t\t\t\tif (cfg.value === undefined) {\n\t\t\t\t\t\tsetUncontrolled(cfg.defaultValue ?? []);\n\t\t\t\t\t}\n\t\t\t\t}, 0);\n\t\t\t\ttimers.add(timer);\n\t\t\t};\n\t\t\tform.addEventListener(\"reset\", onReset, true);\n\t\t\treturn () => {\n\t\t\t\tdisposed = true;\n\t\t\t\tresetEventRef.current = null;\n\t\t\t\tfor (const timer of timers) {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t}\n\t\t\t\ttimers.clear();\n\t\t\t\tform.removeEventListener(\"reset\", onReset, true);\n\t\t\t};\n\t\t}, [formAttr]);\n\t\treturn (\n\t\t\t<CheckboxGroupContext.Provider value={{ value: current, setValue, disabled, invalid }}>\n\t\t\t\t<fieldset\n\t\t\t\t\tref={setRefs}\n\t\t\t\t\t{...props}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\taria-invalid={invalid ? true : ariaInvalid}\n\t\t\t\t\taria-describedby={mergedDescribedBy}\n\t\t\t\t\tclassName={cn(\"flex flex-col gap-2\", className)}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t\t{invalid ? (\n\t\t\t\t\t\t<p id={errorId} className=\"text-xs text-basalt-destructive\" role=\"alert\">\n\t\t\t\t\t\t\t{error}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) : null}\n\t\t\t\t</fieldset>\n\t\t\t</CheckboxGroupContext.Provider>\n\t\t);\n\t},\n);\nCheckboxGroup.displayName = \"Checkbox.Group\";\n\nconst CheckboxLegend = React.forwardRef<HTMLLegendElement, CheckboxLegendProps>(\n\t({ className, ...props }, ref) => (\n\t\t<legend\n\t\t\tref={ref}\n\t\t\tclassName={cn(\"text-sm font-medium text-basalt-foreground\", className)}\n\t\t\t{...props}\n\t\t/>\n\t),\n);\nCheckboxLegend.displayName = \"Checkbox.Legend\";\n\nconst CheckboxItem = React.forwardRef<\n\tReact.ElementRef<typeof CheckboxPrimitive.Root>,\n\tCheckboxItemProps\n>(({ className, value, children, disabled, size, id, ...props }, ref) => {\n\tconst group = React.useContext(CheckboxGroupContext);\n\tconst grouped = group != null;\n\tconst generatedId = React.useId();\n\tconst controlId = id ?? generatedId;\n\tconst isChecked = grouped ? group.value.includes(value) : undefined;\n\tconst box = (\n\t\t<CheckboxRoot\n\t\t\tref={ref}\n\t\t\t{...props}\n\t\t\tid={controlId}\n\t\t\tvalue={value}\n\t\t\tsize={size}\n\t\t\tchecked={isChecked}\n\t\t\tdefaultChecked={grouped ? isChecked : undefined}\n\t\t\tdisabled={disabled || group?.disabled}\n\t\t\taria-invalid={group?.invalid || undefined}\n\t\t\tclassName={className}\n\t\t\tonCheckedChange={(next) => {\n\t\t\t\tif (grouped && typeof next === \"boolean\") {\n\t\t\t\t\tgroup.setValue(nextCheckboxGroupValue(group.value, value, next));\n\t\t\t\t}\n\t\t\t}}\n\t\t/>\n\t);\n\tif (children == null) {\n\t\treturn box;\n\t}\n\treturn (\n\t\t<label htmlFor={controlId} className=\"flex items-center gap-2 text-sm text-basalt-foreground\">\n\t\t\t{box}\n\t\t\t{children}\n\t\t</label>\n\t);\n});\nCheckboxItem.displayName = \"Checkbox.Item\";\n\nexport const Checkbox = Object.assign(CheckboxRoot, {\n\tGroup: CheckboxGroup,\n\tLegend: CheckboxLegend,\n\tItem: CheckboxItem,\n});\n"],"mappings":"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"}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface ClipboardTextProps {
|
|
2
|
+
/**
|
|
3
|
+
* Text string displayed in the inline code block and default text copied to the clipboard.
|
|
4
|
+
*/
|
|
2
5
|
text: string;
|
|
6
|
+
/**
|
|
7
|
+
* Optional alternate text string written to clipboard instead of `text`.
|
|
8
|
+
* @default text
|
|
9
|
+
*/
|
|
3
10
|
copyText?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Additional CSS classes applied to the root container.
|
|
13
|
+
*/
|
|
4
14
|
className?: string;
|
|
5
|
-
}
|
|
15
|
+
}
|
|
16
|
+
export declare function ClipboardText({ text, copyText, className }: ClipboardTextProps): import("react").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn as e } from "../utils/cn.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { controlSurfaceClass as t } from "../utils/control-surface.js";
|
|
4
|
+
import { Button as n } from "./button.js";
|
|
5
5
|
import { useState as r } from "react";
|
|
6
6
|
import { Check as i, Copy as a } from "lucide-react";
|
|
7
7
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
@@ -10,11 +10,11 @@ function c({ text: c, copyText: l, className: u }) {
|
|
|
10
10
|
let [d, f] = r(!1);
|
|
11
11
|
return /* @__PURE__ */ s("div", {
|
|
12
12
|
"data-slot": "clipboard-text",
|
|
13
|
-
className:
|
|
13
|
+
className: t(e("inline-flex h-9 max-w-full items-stretch shadow-xs", u)),
|
|
14
14
|
children: [/* @__PURE__ */ o("code", {
|
|
15
15
|
className: "flex h-full min-w-0 items-center truncate rounded-l-basalt-md bg-transparent px-4 font-mono text-sm text-basalt-foreground",
|
|
16
16
|
children: c
|
|
17
|
-
}), /* @__PURE__ */ o(
|
|
17
|
+
}), /* @__PURE__ */ o(n, {
|
|
18
18
|
type: "button",
|
|
19
19
|
size: "icon",
|
|
20
20
|
variant: "ghost",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clipboard-text.js","names":[],"sources":["../../src/components/clipboard-text.tsx"],"sourcesContent":["import { Check, Copy } from \"lucide-react\";\nimport { useState } from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { controlSurfaceClass } from \"../utils/control-surface\";\nimport { Button } from \"./button\";\n\nexport
|
|
1
|
+
{"version":3,"file":"clipboard-text.js","names":[],"sources":["../../src/components/clipboard-text.tsx"],"sourcesContent":["import { Check, Copy } from \"lucide-react\";\nimport { useState } from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { controlSurfaceClass } from \"../utils/control-surface\";\nimport { Button } from \"./button\";\n\nexport interface ClipboardTextProps {\n\t/**\n\t * Text string displayed in the inline code block and default text copied to the clipboard.\n\t */\n\ttext: string;\n\t/**\n\t * Optional alternate text string written to clipboard instead of `text`.\n\t * @default text\n\t */\n\tcopyText?: string;\n\t/**\n\t * Additional CSS classes applied to the root container.\n\t */\n\tclassName?: string;\n}\n\nexport function ClipboardText({ text, copyText, className }: ClipboardTextProps) {\n\tconst [copied, setCopied] = useState(false);\n\treturn (\n\t\t<div\n\t\t\tdata-slot=\"clipboard-text\"\n\t\t\tclassName={controlSurfaceClass(\n\t\t\t\tcn(\"inline-flex h-9 max-w-full items-stretch shadow-xs\", className),\n\t\t\t)}\n\t\t>\n\t\t\t<code className=\"flex h-full min-w-0 items-center truncate rounded-l-basalt-md bg-transparent px-4 font-mono text-sm text-basalt-foreground\">\n\t\t\t\t{text}\n\t\t\t</code>\n\t\t\t<Button\n\t\t\t\ttype=\"button\"\n\t\t\t\tsize=\"icon\"\n\t\t\t\tvariant=\"ghost\"\n\t\t\t\taria-label=\"Copy\"\n\t\t\t\tclassName=\"h-full min-h-0 w-9 shrink-0 rounded-none rounded-r-basalt-md border-0 border-l border-basalt-border shadow-none\"\n\t\t\t\tonClick={async () => {\n\t\t\t\t\tawait navigator.clipboard.writeText(copyText ?? text);\n\t\t\t\t\tsetCopied(true);\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{copied ? <Check /> : <Copy />}\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAsBA,SAAgB,EAAc,EAAE,SAAM,aAAU,gBAAiC;CAChF,IAAM,CAAC,GAAQ,KAAa,EAAS,EAAK;CAC1C,OACC,kBAAC,OAAD;EACC,aAAU;EACV,WAAW,EACV,EAAG,sDAAsD,CAAS,CACnE;EAJD,UAAA,CAMC,kBAAC,QAAD;GAAM,WAAU;GACd,UAAA;EACI,CAAA,GACN,kBAAC,GAAD;GACC,MAAK;GACL,MAAK;GACL,SAAQ;GACR,cAAW;GACX,WAAU;GACV,SAAS,YAAY;IAEpB,AADA,MAAM,UAAU,UAAU,UAAU,KAAY,CAAI,GACpD,EAAU,EAAI;GACf;GAEC,UAAS,EAAT,IAAU,IAAY,GAAb,CAAQ,CAAW;EACtB,CAAA,CACJ;;AAEP"}
|
|
@@ -1,33 +1,76 @@
|
|
|
1
1
|
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
|
|
3
|
+
type RadixCollapsibleProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Root>;
|
|
4
|
+
type RadixCollapsibleTriggerProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.CollapsibleTrigger>;
|
|
5
|
+
type RadixCollapsibleContentProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.CollapsibleContent>;
|
|
6
|
+
export interface CollapsibleProps extends Omit<RadixCollapsibleProps, "open" | "defaultOpen" | "onOpenChange" | "disabled" | "asChild" | "children"> {
|
|
4
7
|
/**
|
|
5
|
-
*
|
|
8
|
+
* Collapsible structure elements, typically CollapsibleTrigger and CollapsibleContent.
|
|
6
9
|
*/
|
|
7
|
-
|
|
10
|
+
children?: React.ReactNode;
|
|
8
11
|
/**
|
|
9
|
-
* The
|
|
12
|
+
* The controlled open state of the collapsible.
|
|
13
|
+
*/
|
|
14
|
+
open?: RadixCollapsibleProps["open"];
|
|
15
|
+
/**
|
|
16
|
+
* The uncontrolled initial open state of the collapsible.
|
|
10
17
|
* @default false
|
|
11
18
|
*/
|
|
12
|
-
defaultOpen?:
|
|
19
|
+
defaultOpen?: RadixCollapsibleProps["defaultOpen"];
|
|
13
20
|
/**
|
|
14
21
|
* Called when the open state changes.
|
|
15
22
|
*/
|
|
16
|
-
onOpenChange?:
|
|
17
|
-
|
|
23
|
+
onOpenChange?: RadixCollapsibleProps["onOpenChange"];
|
|
24
|
+
/**
|
|
25
|
+
* When true, prevents the user from interacting with the collapsible.
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
disabled?: RadixCollapsibleProps["disabled"];
|
|
29
|
+
/**
|
|
30
|
+
* Change the default rendered div element to the child element, merging props and behavior.
|
|
31
|
+
* Note: Collapsible root is typed as React.FC and does not declare ref in its public Props;
|
|
32
|
+
* forwards rest props and inherits native div attributes.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
asChild?: RadixCollapsibleProps["asChild"];
|
|
36
|
+
}
|
|
18
37
|
export declare const Collapsible: React.FC<CollapsibleProps>;
|
|
19
|
-
export
|
|
20
|
-
export type CollapsibleContentProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.CollapsibleContent> & {
|
|
38
|
+
export interface CollapsibleTriggerProps extends Omit<RadixCollapsibleTriggerProps, "asChild" | "children"> {
|
|
21
39
|
/**
|
|
22
|
-
*
|
|
40
|
+
* Content of the trigger button. When asChild is false, automatically renders
|
|
41
|
+
* a text container span alongside an animated ChevronDown icon.
|
|
42
|
+
*/
|
|
43
|
+
children?: React.ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* Change the default rendered button element to the child element, merging props and behavior.
|
|
46
|
+
* When true, bypasses the default text span and ChevronDown icon wrapping.
|
|
47
|
+
* CollapsibleTrigger forwards ref to HTMLButtonElement and inherits native button attributes.
|
|
23
48
|
* @default false
|
|
24
49
|
*/
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
export declare const
|
|
50
|
+
asChild?: RadixCollapsibleTriggerProps["asChild"];
|
|
51
|
+
}
|
|
52
|
+
export declare const CollapsibleTrigger: React.ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
53
|
+
export interface CollapsibleContentProps extends Omit<RadixCollapsibleContentProps, "unstyled" | "forceMount" | "asChild"> {
|
|
28
54
|
/**
|
|
29
|
-
* Render children without the default inset border.
|
|
55
|
+
* Render children without the default inset border container.
|
|
56
|
+
* Note: When unstyled is false (default), children are wrapped in an inner inset border div.
|
|
57
|
+
* When combined with asChild, asChild slots onto that inner div unless unstyled={true} is set.
|
|
30
58
|
* @default false
|
|
31
59
|
*/
|
|
32
60
|
unstyled?: boolean;
|
|
33
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Used to force mounting when more control is needed. Useful when
|
|
63
|
+
* controlling animation with React animation libraries.
|
|
64
|
+
*/
|
|
65
|
+
forceMount?: RadixCollapsibleContentProps["forceMount"];
|
|
66
|
+
/**
|
|
67
|
+
* Change the default rendered div element to the child element, merging props and behavior.
|
|
68
|
+
* Note: When unstyled is false, asChild operates within the inner inset div wrapper;
|
|
69
|
+
* set unstyled={true} to slot directly onto the child element as the content/ref target.
|
|
70
|
+
* CollapsibleContent forwards ref to HTMLDivElement and inherits native div attributes.
|
|
71
|
+
* @default false
|
|
72
|
+
*/
|
|
73
|
+
asChild?: RadixCollapsibleContentProps["asChild"];
|
|
74
|
+
}
|
|
75
|
+
export declare const CollapsibleContent: React.ForwardRefExoticComponent<CollapsibleContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
76
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collapsible.js","names":[],"sources":["../../src/components/collapsible.tsx"],"sourcesContent":["import * as CollapsiblePrimitive from \"@radix-ui/react-collapsible\";\nimport { ChevronDown } from \"lucide-react\";\nimport * as React from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { FOCUS_INSET, OVERLAY_MOTION } from \"./overlay\";\n\
|
|
1
|
+
{"version":3,"file":"collapsible.js","names":[],"sources":["../../src/components/collapsible.tsx"],"sourcesContent":["import * as CollapsiblePrimitive from \"@radix-ui/react-collapsible\";\nimport { ChevronDown } from \"lucide-react\";\nimport * as React from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { FOCUS_INSET, OVERLAY_MOTION } from \"./overlay\";\n\ntype RadixCollapsibleProps = React.ComponentPropsWithoutRef<typeof CollapsiblePrimitive.Root>;\ntype RadixCollapsibleTriggerProps = React.ComponentPropsWithoutRef<\n\ttypeof CollapsiblePrimitive.CollapsibleTrigger\n>;\ntype RadixCollapsibleContentProps = React.ComponentPropsWithoutRef<\n\ttypeof CollapsiblePrimitive.CollapsibleContent\n>;\n\nexport interface CollapsibleProps\n\textends Omit<\n\t\tRadixCollapsibleProps,\n\t\t\"open\" | \"defaultOpen\" | \"onOpenChange\" | \"disabled\" | \"asChild\" | \"children\"\n\t> {\n\t/**\n\t * Collapsible structure elements, typically CollapsibleTrigger and CollapsibleContent.\n\t */\n\tchildren?: React.ReactNode;\n\t/**\n\t * The controlled open state of the collapsible.\n\t */\n\topen?: RadixCollapsibleProps[\"open\"];\n\t/**\n\t * The uncontrolled initial open state of the collapsible.\n\t * @default false\n\t */\n\tdefaultOpen?: RadixCollapsibleProps[\"defaultOpen\"];\n\t/**\n\t * Called when the open state changes.\n\t */\n\tonOpenChange?: RadixCollapsibleProps[\"onOpenChange\"];\n\t/**\n\t * When true, prevents the user from interacting with the collapsible.\n\t * @default false\n\t */\n\tdisabled?: RadixCollapsibleProps[\"disabled\"];\n\t/**\n\t * Change the default rendered div element to the child element, merging props and behavior.\n\t * Note: Collapsible root is typed as React.FC and does not declare ref in its public Props;\n\t * forwards rest props and inherits native div attributes.\n\t * @default false\n\t */\n\tasChild?: RadixCollapsibleProps[\"asChild\"];\n}\n\nexport const Collapsible: React.FC<CollapsibleProps> = CollapsiblePrimitive.Root;\n\nexport interface CollapsibleTriggerProps\n\textends Omit<RadixCollapsibleTriggerProps, \"asChild\" | \"children\"> {\n\t/**\n\t * Content of the trigger button. When asChild is false, automatically renders\n\t * a text container span alongside an animated ChevronDown icon.\n\t */\n\tchildren?: React.ReactNode;\n\t/**\n\t * Change the default rendered button element to the child element, merging props and behavior.\n\t * When true, bypasses the default text span and ChevronDown icon wrapping.\n\t * CollapsibleTrigger forwards ref to HTMLButtonElement and inherits native button attributes.\n\t * @default false\n\t */\n\tasChild?: RadixCollapsibleTriggerProps[\"asChild\"];\n}\n\nexport const CollapsibleTrigger = React.forwardRef<\n\tReact.ElementRef<typeof CollapsiblePrimitive.CollapsibleTrigger>,\n\tCollapsibleTriggerProps\n>(({ className, children, asChild = false, ...props }, ref) => {\n\tif (asChild) {\n\t\treturn (\n\t\t\t<CollapsiblePrimitive.CollapsibleTrigger ref={ref} asChild className={className} {...props}>\n\t\t\t\t{children}\n\t\t\t</CollapsiblePrimitive.CollapsibleTrigger>\n\t\t);\n\t}\n\treturn (\n\t\t<CollapsiblePrimitive.CollapsibleTrigger\n\t\t\tref={ref}\n\t\t\tclassName={cn(\n\t\t\t\t\"m-0 inline-flex cursor-pointer items-center gap-1 border-none bg-transparent p-0 text-sm font-medium text-basalt-foreground shadow-none select-none\",\n\t\t\t\tFOCUS_INSET,\n\t\t\t\t\"[&_svg]:size-3 [&_svg]:shrink-0 [&_svg]:origin-center [&_svg]:transition-transform [&_svg]:duration-100 [&_svg]:ease-out\",\n\t\t\t\t\"data-[state=open]:[&_svg]:rotate-180\",\n\t\t\t\tOVERLAY_MOTION,\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t>\n\t\t\t<span>{children}</span>\n\t\t\t<ChevronDown aria-hidden=\"true\" className={OVERLAY_MOTION} />\n\t\t</CollapsiblePrimitive.CollapsibleTrigger>\n\t);\n});\nCollapsibleTrigger.displayName = CollapsiblePrimitive.CollapsibleTrigger.displayName;\n\nexport interface CollapsibleContentProps\n\textends Omit<RadixCollapsibleContentProps, \"unstyled\" | \"forceMount\" | \"asChild\"> {\n\t/**\n\t * Render children without the default inset border container.\n\t * Note: When unstyled is false (default), children are wrapped in an inner inset border div.\n\t * When combined with asChild, asChild slots onto that inner div unless unstyled={true} is set.\n\t * @default false\n\t */\n\tunstyled?: boolean;\n\t/**\n\t * Used to force mounting when more control is needed. Useful when\n\t * controlling animation with React animation libraries.\n\t */\n\tforceMount?: RadixCollapsibleContentProps[\"forceMount\"];\n\t/**\n\t * Change the default rendered div element to the child element, merging props and behavior.\n\t * Note: When unstyled is false, asChild operates within the inner inset div wrapper;\n\t * set unstyled={true} to slot directly onto the child element as the content/ref target.\n\t * CollapsibleContent forwards ref to HTMLDivElement and inherits native div attributes.\n\t * @default false\n\t */\n\tasChild?: RadixCollapsibleContentProps[\"asChild\"];\n}\n\nexport const CollapsibleContent = React.forwardRef<\n\tReact.ElementRef<typeof CollapsiblePrimitive.CollapsibleContent>,\n\tCollapsibleContentProps\n>(({ className, children, unstyled = false, ...props }, ref) => (\n\t<CollapsiblePrimitive.CollapsibleContent\n\t\tref={ref}\n\t\tclassName={cn(\n\t\t\t\"overflow-hidden data-[state=closed]:animate-basalt-collapsible-up data-[state=open]:animate-basalt-collapsible-down\",\n\t\t\tOVERLAY_MOTION,\n\t\t\tclassName,\n\t\t)}\n\t\t{...props}\n\t>\n\t\t{unstyled ? (\n\t\t\tchildren\n\t\t) : (\n\t\t\t<div className=\"my-2 border-l-2 border-basalt-border py-1 pr-1 pl-4 text-sm text-basalt-foreground\">\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t)}\n\t</CollapsiblePrimitive.CollapsibleContent>\n));\nCollapsibleContent.displayName = CollapsiblePrimitive.CollapsibleContent.displayName;\n"],"mappings":";;;;;;;;AAkDA,IAAa,IAA0C,EAAqB,MAkB/D,IAAqB,EAAM,YAGrC,EAAE,cAAW,aAAU,aAAU,IAAO,GAAG,KAAS,MAClD,IAEF,kBAAC,EAAqB,oBAAtB;CAA8C;CAAK,SAAA;CAAmB;CAAW,GAAI;CACnF;AACuC,CAAA,IAI1C,kBAAC,EAAqB,oBAAtB;CACM;CACL,WAAW,EACV,uJACA,GACA,4HACA,wCACA,GACA,CACD;CACA,GAAI;CAVL,UAAA,CAYC,kBAAC,QAAD,EAAO,YAAe,CAAA,GACtB,kBAAC,GAAD;EAAa,eAAY;EAAO,WAAW;CAAiB,CAAA,CACpB;EAE1C;AACD,EAAmB,cAAc,EAAqB,mBAAmB;AA0BzE,IAAa,IAAqB,EAAM,YAGrC,EAAE,cAAW,aAAU,cAAW,IAAO,GAAG,KAAS,MACvD,kBAAC,EAAqB,oBAAtB;CACM;CACL,WAAW,EACV,uHACA,GACA,CACD;CACA,GAAI;CAEH,UAAA,IACA,IAEA,kBAAC,OAAD;EAAK,WAAU;EACb;CACG,CAAA;AAEkC,CAAA,CACzC;AACD,EAAmB,cAAc,EAAqB,mBAAmB"}
|