cortena-ui 1.3.0 → 1.4.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.
- package/README.md +74 -3
- package/dist/a2ui/catalogue-doc.d.ts +44 -0
- package/dist/a2ui/catalogue-doc.js +169 -0
- package/dist/a2ui/catalogue-doc.js.map +1 -0
- package/dist/a2ui/catalogue.d.ts +44 -0
- package/dist/a2ui/catalogue.js +942 -0
- package/dist/a2ui/catalogue.js.map +1 -0
- package/dist/a2ui/index.d.ts +7 -0
- package/dist/a2ui/message.d.ts +232 -0
- package/dist/a2ui/message.js +365 -0
- package/dist/a2ui/message.js.map +1 -0
- package/dist/a2ui/renderer.d.ts +46 -0
- package/dist/a2ui/renderer.js +252 -0
- package/dist/a2ui/renderer.js.map +1 -0
- package/dist/a2ui/views.d.ts +80 -0
- package/dist/a2ui/views.js +596 -0
- package/dist/a2ui/views.js.map +1 -0
- package/dist/a2ui.d.ts +8 -0
- package/dist/a2ui.js +7 -0
- package/dist/chart.d.ts +9 -0
- package/dist/chart.js +9 -0
- package/dist/components/accordion.d.ts +22 -0
- package/dist/components/accordion.js +63 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/alert.d.ts +15 -0
- package/dist/components/alert.js +64 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/avatar.d.ts +18 -0
- package/dist/components/avatar.js +40 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +47 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/breadcrumb.d.ts +71 -0
- package/dist/components/breadcrumb.js +123 -0
- package/dist/components/breadcrumb.js.map +1 -0
- package/dist/components/button-link.d.ts +28 -0
- package/dist/components/button-link.js +24 -0
- package/dist/components/button-link.js.map +1 -0
- package/dist/components/button.d.ts +24 -0
- package/dist/components/button.js +65 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/calendar.d.ts +28 -0
- package/dist/components/calendar.js +123 -0
- package/dist/components/calendar.js.map +1 -0
- package/dist/components/card.d.ts +32 -0
- package/dist/components/card.js +57 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/chart/chart.d.ts +71 -0
- package/dist/components/chart/chart.js +167 -0
- package/dist/components/chart/chart.js.map +1 -0
- package/dist/components/chart/container.d.ts +88 -0
- package/dist/components/chart/container.js +189 -0
- package/dist/components/chart/container.js.map +1 -0
- package/dist/components/chart/data.js +128 -0
- package/dist/components/chart/data.js.map +1 -0
- package/dist/components/chart/index.d.ts +9 -0
- package/dist/components/chart/index.js +10 -0
- package/dist/components/chart/nivo-charts.js +225 -0
- package/dist/components/chart/nivo-charts.js.map +1 -0
- package/dist/components/chart/nivo-lazy.js +50 -0
- package/dist/components/chart/nivo-lazy.js.map +1 -0
- package/dist/components/chart/nivo-theme.d.ts +156 -0
- package/dist/components/chart/nivo-theme.js +161 -0
- package/dist/components/chart/nivo-theme.js.map +1 -0
- package/dist/components/chart/recharts-charts.js +276 -0
- package/dist/components/chart/recharts-charts.js.map +1 -0
- package/dist/components/chart/recharts-lazy.js +58 -0
- package/dist/components/chart/recharts-lazy.js.map +1 -0
- package/dist/components/chart/recharts-parts.d.ts +10 -0
- package/dist/components/chart/recharts-parts.js +25 -0
- package/dist/components/chart/recharts-parts.js.map +1 -0
- package/dist/components/chart/tokens.d.ts +62 -0
- package/dist/components/chart/tokens.js +192 -0
- package/dist/components/chart/tokens.js.map +1 -0
- package/dist/components/chart/types.d.ts +114 -0
- package/dist/components/chart/types.js +27 -0
- package/dist/components/chart/types.js.map +1 -0
- package/dist/components/checkbox.d.ts +20 -0
- package/dist/components/checkbox.js +24 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/chip.d.ts +17 -0
- package/dist/components/chip.js +47 -0
- package/dist/components/chip.js.map +1 -0
- package/dist/components/combobox.d.ts +76 -0
- package/dist/components/combobox.js +201 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/command.d.ts +50 -0
- package/dist/components/command.js +117 -0
- package/dist/components/command.js.map +1 -0
- package/dist/components/data-table/data-table.d.ts +65 -0
- package/dist/components/data-table/data-table.js +588 -0
- package/dist/components/data-table/data-table.js.map +1 -0
- package/dist/components/data-table/export.d.ts +23 -0
- package/dist/components/data-table/export.js +95 -0
- package/dist/components/data-table/export.js.map +1 -0
- package/dist/components/data-table/features.d.ts +66 -0
- package/dist/components/data-table/features.js +103 -0
- package/dist/components/data-table/features.js.map +1 -0
- package/dist/components/data-table/index.d.ts +8 -0
- package/dist/components/data-table/parts.d.ts +79 -0
- package/dist/components/data-table/parts.js +400 -0
- package/dist/components/data-table/parts.js.map +1 -0
- package/dist/components/data-table/system-columns.js +84 -0
- package/dist/components/data-table/system-columns.js.map +1 -0
- package/dist/components/data-table/types.d.ts +172 -0
- package/dist/components/data-table/use-data-table.d.ts +19 -0
- package/dist/components/data-table/use-data-table.js +171 -0
- package/dist/components/data-table/use-data-table.js.map +1 -0
- package/dist/components/data-table/use-server-source.js +200 -0
- package/dist/components/data-table/use-server-source.js.map +1 -0
- package/dist/components/date-field.d.ts +54 -0
- package/dist/components/date-field.js +235 -0
- package/dist/components/date-field.js.map +1 -0
- package/dist/components/date-picker.d.ts +42 -0
- package/dist/components/date-picker.js +125 -0
- package/dist/components/date-picker.js.map +1 -0
- package/dist/components/dialog.d.ts +36 -0
- package/dist/components/dialog.js +97 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/dropdown-menu.d.ts +54 -0
- package/dist/components/dropdown-menu.js +191 -0
- package/dist/components/dropdown-menu.js.map +1 -0
- package/dist/components/dropzone.d.ts +48 -0
- package/dist/components/dropzone.js +185 -0
- package/dist/components/dropzone.js.map +1 -0
- package/dist/components/empty-state.d.ts +22 -0
- package/dist/components/empty-state.js +46 -0
- package/dist/components/empty-state.js.map +1 -0
- package/dist/components/error-banner.d.ts +17 -0
- package/dist/components/error-banner.js +52 -0
- package/dist/components/error-banner.js.map +1 -0
- package/dist/components/field.d.ts +64 -0
- package/dist/components/field.js +133 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/form.d.ts +37 -0
- package/dist/components/form.js +103 -0
- package/dist/components/form.js.map +1 -0
- package/dist/components/input.d.ts +17 -0
- package/dist/components/input.js +26 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/kbd.d.ts +11 -0
- package/dist/components/kbd.js +20 -0
- package/dist/components/kbd.js.map +1 -0
- package/dist/components/label.d.ts +14 -0
- package/dist/components/label.js +28 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/loading-skeleton.d.ts +22 -0
- package/dist/components/loading-skeleton.js +123 -0
- package/dist/components/loading-skeleton.js.map +1 -0
- package/dist/components/markdown.d.ts +44 -0
- package/dist/components/markdown.js +231 -0
- package/dist/components/markdown.js.map +1 -0
- package/dist/components/page-header.d.ts +26 -0
- package/dist/components/page-header.js +53 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/popover.d.ts +29 -0
- package/dist/components/popover.js +74 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/progress.d.ts +22 -0
- package/dist/components/progress.js +49 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/radio-group.d.ts +20 -0
- package/dist/components/radio-group.js +29 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/scroll-area.d.ts +25 -0
- package/dist/components/scroll-area.js +39 -0
- package/dist/components/scroll-area.js.map +1 -0
- package/dist/components/section-card.d.ts +29 -0
- package/dist/components/section-card.js +55 -0
- package/dist/components/section-card.js.map +1 -0
- package/dist/components/segmented.d.ts +27 -0
- package/dist/components/segmented.js +32 -0
- package/dist/components/segmented.js.map +1 -0
- package/dist/components/select.d.ts +62 -0
- package/dist/components/select.js +97 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/separator.d.ts +19 -0
- package/dist/components/separator.js +23 -0
- package/dist/components/separator.js.map +1 -0
- package/dist/components/sheet.d.ts +35 -0
- package/dist/components/sheet.js +131 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/skeleton.d.ts +12 -0
- package/dist/components/skeleton.js +22 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/sortable-list.d.ts +67 -0
- package/dist/components/sortable-list.js +206 -0
- package/dist/components/sortable-list.js.map +1 -0
- package/dist/components/spinner.d.ts +29 -0
- package/dist/components/spinner.js +34 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/status-dot.d.ts +26 -0
- package/dist/components/status-dot.js +47 -0
- package/dist/components/status-dot.js.map +1 -0
- package/dist/components/switch.d.ts +21 -0
- package/dist/components/switch.js +21 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/tabs.d.ts +24 -0
- package/dist/components/tabs.js +60 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/textarea.d.ts +19 -0
- package/dist/components/textarea.js +47 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/toast.d.ts +47 -0
- package/dist/components/toast.js +106 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/toolbar.d.ts +19 -0
- package/dist/components/toolbar.js +45 -0
- package/dist/components/toolbar.js.map +1 -0
- package/dist/components/tooltip.d.ts +28 -0
- package/dist/components/tooltip.js +59 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/core.d.ts +44 -0
- package/dist/core.js +44 -0
- package/dist/data-table.d.ts +9 -0
- package/dist/data-table.js +7 -0
- package/dist/form.d.ts +7 -0
- package/dist/form.js +7 -0
- package/dist/hooks/use-cortena-theme.d.ts +98 -0
- package/dist/hooks/use-cortena-theme.js +145 -0
- package/dist/hooks/use-cortena-theme.js.map +1 -0
- package/dist/index.d.ts +75 -2678
- package/dist/index.js +66 -8598
- package/dist/lib/cn.d.ts +10 -0
- package/dist/lib/cn.js +15 -0
- package/dist/lib/cn.js.map +1 -0
- package/dist/lib/render.d.ts +23 -0
- package/dist/lib/render.js +20 -0
- package/dist/lib/render.js.map +1 -0
- package/dist/lib/shakeable.js +39 -0
- package/dist/lib/shakeable.js.map +1 -0
- package/dist/markdown.d.ts +3 -0
- package/dist/markdown.js +3 -0
- package/dist/sortable-list.d.ts +3 -0
- package/dist/sortable-list.js +3 -0
- package/package.json +37 -14
- package/src/a2ui/catalogue.ts +140 -103
- package/src/a2ui/views.tsx +5 -2
- package/src/components/alert.tsx +1 -1
- package/src/components/badge.tsx +1 -1
- package/src/components/button.tsx +1 -1
- package/src/components/chart/chart.tsx +72 -25
- package/src/components/chart/container.tsx +24 -39
- package/src/components/chart/index.tsx +4 -2
- package/src/components/chart/nivo-charts.tsx +41 -13
- package/src/components/chart/nivo-lazy.tsx +52 -0
- package/src/components/chart/recharts-charts.tsx +98 -3
- package/src/components/chart/recharts-lazy.tsx +72 -0
- package/src/components/chart/recharts-parts.tsx +34 -0
- package/src/components/chart/tokens.ts +1 -1
- package/src/components/chart/types.ts +14 -0
- package/src/components/chip.tsx +1 -1
- package/src/components/combobox.tsx +2 -2
- package/src/components/data-table/export.ts +18 -2
- package/src/components/data-table/features.ts +77 -45
- package/src/components/data-table/parts.tsx +15 -0
- package/src/components/data-table/use-data-table.ts +7 -2
- package/src/components/data-table/use-server-source.ts +17 -4
- package/src/components/date-field.tsx +1 -1
- package/src/components/error-banner.tsx +1 -1
- package/src/components/field.tsx +2 -2
- package/src/components/form.tsx +2 -2
- package/src/components/input.tsx +1 -1
- package/src/components/label.tsx +1 -1
- package/src/components/markdown.tsx +5 -4
- package/src/components/sheet.tsx +2 -2
- package/src/components/sortable-list.tsx +2 -2
- package/src/components/textarea.tsx +1 -1
- package/src/components/toast.tsx +1 -1
- package/src/entries/a2ui.ts +11 -0
- package/src/entries/chart.ts +10 -0
- package/src/entries/core.ts +91 -0
- package/src/entries/data-table.ts +9 -0
- package/src/entries/form.ts +24 -0
- package/src/entries/markdown.ts +9 -0
- package/src/entries/sortable-list.ts +13 -0
- package/src/index.ts +32 -98
- package/src/lib/shakeable.ts +33 -0
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { inputClassName } from "./input.js";
|
|
5
|
+
import { Check, ChevronDown, X } from "lucide-react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Combobox } from "@base-ui/react/combobox";
|
|
8
|
+
import { createContext, useContext } from "react";
|
|
9
|
+
//#region src/components/combobox.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Combobox: a filterable text input with a listbox popup, on Base UI.
|
|
12
|
+
*
|
|
13
|
+
* Give the Root `items` (an array, or `[{ value, label }]`) and render the
|
|
14
|
+
* list with `<ComboboxList>{(item) => <ComboboxItem value={item} />}</ComboboxList>`;
|
|
15
|
+
* Base UI filters `items` against the input as the user types. Without
|
|
16
|
+
* `items` nothing is filtered and `ComboboxEmpty` never shows.
|
|
17
|
+
*
|
|
18
|
+
* - `ComboboxInput` is our `Input` with a trailing open/close trigger and,
|
|
19
|
+
* with `clearable`, an X button that clears the value.
|
|
20
|
+
* - `ComboboxContent` composes Portal + Positioner + Popup + List so
|
|
21
|
+
* consumers write one element; positioning props go to the Positioner.
|
|
22
|
+
* - Multiple selection: set `multiple` on the Root and wrap `ComboboxValue`
|
|
23
|
+
* (rendering a `ComboboxChip` per value) plus `ComboboxInput` in
|
|
24
|
+
* `ComboboxChips`. Inside `ComboboxChips` the input drops its own frame;
|
|
25
|
+
* the chips container carries the field look and anchors the popup.
|
|
26
|
+
* - `useComboboxFilter` is Base UI's `useFilter` for external filtering via
|
|
27
|
+
* `filteredItems`.
|
|
28
|
+
*
|
|
29
|
+
* `onValueChange` receives `(value, eventDetails)`; `onInputValueChange`
|
|
30
|
+
* reports the typed text.
|
|
31
|
+
*/
|
|
32
|
+
function Combobox$1(props) {
|
|
33
|
+
return /* @__PURE__ */ jsx(Combobox.Root, { ...props });
|
|
34
|
+
}
|
|
35
|
+
const InsideChipsContext = /* @__PURE__ */ createContext(false);
|
|
36
|
+
const controlButtonClassName = /* @__PURE__ */ cn("flex size-6 shrink-0 items-center justify-center rounded-[var(--ds-radius-sm)]", "text-[color:var(--ds-muted-foreground)] outline-none", "transition-[background-color,color] duration-[var(--ds-duration-fast)] ease-[var(--ds-ease-out)]", "hover:bg-[var(--ds-hover)] hover:text-[color:var(--ds-foreground)]", "focus-visible:ring-[3px] focus-visible:ring-[var(--ds-ring)]/40", "data-[disabled]:pointer-events-none data-[disabled]:opacity-50", "[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0");
|
|
37
|
+
function ComboboxTrigger({ className, children, ...props }) {
|
|
38
|
+
return /* @__PURE__ */ jsx(Combobox.Trigger, {
|
|
39
|
+
"data-slot": "combobox-trigger",
|
|
40
|
+
"aria-label": "Open",
|
|
41
|
+
className: cn(controlButtonClassName, className),
|
|
42
|
+
...props,
|
|
43
|
+
children: children ?? /* @__PURE__ */ jsx(Combobox.Icon, {
|
|
44
|
+
"data-slot": "combobox-icon",
|
|
45
|
+
className: "flex transition-transform duration-[var(--ds-duration-fast)] data-[popup-open]:rotate-180",
|
|
46
|
+
children: /* @__PURE__ */ jsx(ChevronDown, {})
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function ComboboxClear({ className, children, ...props }) {
|
|
51
|
+
return /* @__PURE__ */ jsx(Combobox.Clear, {
|
|
52
|
+
"data-slot": "combobox-clear",
|
|
53
|
+
"aria-label": "Clear",
|
|
54
|
+
className: cn(controlButtonClassName, className),
|
|
55
|
+
...props,
|
|
56
|
+
children: children ?? /* @__PURE__ */ jsx(X, {})
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function ComboboxInput({ className, clearable = false, wrapperClassName, ...props }) {
|
|
60
|
+
if (useContext(InsideChipsContext)) return /* @__PURE__ */ jsx(Combobox.Input, {
|
|
61
|
+
"data-slot": "combobox-input",
|
|
62
|
+
className: cn("h-7 min-w-16 flex-1 bg-transparent outline-none", "text-[length:var(--ds-text-caption-lg)] leading-[var(--ds-text-caption-lg--line-height)] text-[color:var(--ds-foreground)]", "placeholder:text-[color:var(--ds-text-tertiary)]", "disabled:cursor-not-allowed", className),
|
|
63
|
+
...props
|
|
64
|
+
});
|
|
65
|
+
return /* @__PURE__ */ jsxs(Combobox.InputGroup, {
|
|
66
|
+
"data-slot": "combobox-input-group",
|
|
67
|
+
className: cn("relative flex w-full items-center", wrapperClassName),
|
|
68
|
+
children: [/* @__PURE__ */ jsx(Combobox.Input, {
|
|
69
|
+
"data-slot": "combobox-input",
|
|
70
|
+
className: cn(inputClassName, clearable ? "pr-16" : "pr-9", className),
|
|
71
|
+
...props
|
|
72
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
73
|
+
className: "absolute inset-y-0 right-1.5 flex items-center gap-0.5",
|
|
74
|
+
children: [clearable ? /* @__PURE__ */ jsx(ComboboxClear, {}) : null, /* @__PURE__ */ jsx(ComboboxTrigger, {})]
|
|
75
|
+
})]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function ComboboxValue(props) {
|
|
79
|
+
return /* @__PURE__ */ jsx(Combobox.Value, { ...props });
|
|
80
|
+
}
|
|
81
|
+
function ComboboxChips({ className, chipsClassName, children, ...props }) {
|
|
82
|
+
return /* @__PURE__ */ jsx(InsideChipsContext.Provider, {
|
|
83
|
+
value: true,
|
|
84
|
+
children: /* @__PURE__ */ jsxs(Combobox.InputGroup, {
|
|
85
|
+
"data-slot": "combobox-input-group",
|
|
86
|
+
className: cn("relative flex w-full min-w-0 items-start gap-1 rounded-[var(--ds-radius-md)] border border-[var(--ds-border)] bg-[var(--ds-muted)] py-1 pl-1.5 pr-1.5", "transition-[border-color,box-shadow] duration-[var(--ds-duration-fast)] ease-[var(--ds-ease-out)]", "hover:border-[var(--ds-border-strong)]", "focus-within:border-[var(--ds-ring)] focus-within:ring-[3px] focus-within:ring-[var(--ds-ring)]/40", "data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50", "data-[invalid]:border-[var(--ds-destructive)] data-[invalid]:ring-[3px] data-[invalid]:ring-[var(--ds-destructive)]/20", className),
|
|
87
|
+
children: [/* @__PURE__ */ jsx(Combobox.Chips, {
|
|
88
|
+
"data-slot": "combobox-chips",
|
|
89
|
+
className: cn("flex min-h-7 min-w-0 flex-1 flex-wrap items-center gap-1 px-1", chipsClassName),
|
|
90
|
+
...props,
|
|
91
|
+
children
|
|
92
|
+
}), /* @__PURE__ */ jsx(ComboboxTrigger, { className: "mt-0.5" })]
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function ComboboxChip({ className, children, removable = true, ...props }) {
|
|
97
|
+
return /* @__PURE__ */ jsxs(Combobox.Chip, {
|
|
98
|
+
"data-slot": "combobox-chip",
|
|
99
|
+
className: cn("inline-flex h-6 max-w-full cursor-default items-center gap-1 whitespace-nowrap border pl-2.5 outline-none", removable ? "pr-1" : "pr-2.5", "rounded-[var(--ds-radius-full)] border-[var(--ds-border-subtle)] bg-[var(--ds-hover)]", "text-[length:var(--ds-text-caption)] font-medium text-[color:var(--ds-muted-foreground)]", "focus-visible:border-[var(--ds-ring)] focus-visible:bg-[var(--ds-primary-soft)] focus-visible:text-[color:var(--ds-primary)]", "data-[disabled]:opacity-50", className),
|
|
100
|
+
...props,
|
|
101
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
102
|
+
className: "truncate",
|
|
103
|
+
children
|
|
104
|
+
}), removable ? /* @__PURE__ */ jsx(Combobox.ChipRemove, {
|
|
105
|
+
"data-slot": "combobox-chip-remove",
|
|
106
|
+
"aria-label": "Remove",
|
|
107
|
+
className: cn("flex size-4 shrink-0 items-center justify-center rounded-[var(--ds-radius-full)] outline-none", "transition-[background-color,color] duration-[var(--ds-duration-fast)]", "hover:bg-[var(--ds-border)] hover:text-[color:var(--ds-foreground)]", "[&_svg]:size-3"),
|
|
108
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
109
|
+
}) : null]
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function ComboboxContent({ className, children, empty, listClassName, side = "bottom", align = "start", sideOffset = 4, alignOffset, anchor, collisionBoundary, collisionPadding, collisionAvoidance, sticky, positionMethod, keepMounted, container, ...props }) {
|
|
113
|
+
return /* @__PURE__ */ jsx(Combobox.Portal, {
|
|
114
|
+
keepMounted,
|
|
115
|
+
container,
|
|
116
|
+
children: /* @__PURE__ */ jsx(Combobox.Positioner, {
|
|
117
|
+
"data-slot": "combobox-positioner",
|
|
118
|
+
side,
|
|
119
|
+
align,
|
|
120
|
+
sideOffset,
|
|
121
|
+
alignOffset,
|
|
122
|
+
anchor,
|
|
123
|
+
collisionBoundary,
|
|
124
|
+
collisionPadding,
|
|
125
|
+
collisionAvoidance,
|
|
126
|
+
sticky,
|
|
127
|
+
positionMethod,
|
|
128
|
+
className: "isolate z-50 outline-none",
|
|
129
|
+
children: /* @__PURE__ */ jsxs(Combobox.Popup, {
|
|
130
|
+
"data-slot": "combobox-content",
|
|
131
|
+
className: cn("flex max-h-[min(var(--available-height,none),24rem)] w-[var(--anchor-width,auto)] min-w-[var(--anchor-width,auto)] flex-col overflow-hidden", "rounded-[var(--ds-radius-lg)] border border-[var(--ds-border)]", "bg-[var(--ds-popover)] text-[color:var(--ds-popover-foreground)] shadow-[var(--ds-shadow-lg)]", "outline-none", "open:animate-in open:fade-in-0 open:zoom-in-95", "closed:animate-out closed:fade-out-0 closed:zoom-out-95", "data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", "duration-[var(--ds-duration-fast)] ease-[var(--ds-ease-out)]", className),
|
|
132
|
+
...props,
|
|
133
|
+
children: [empty !== void 0 ? /* @__PURE__ */ jsx(ComboboxEmpty, { children: empty }) : null, /* @__PURE__ */ jsx(Combobox.List, {
|
|
134
|
+
"data-slot": "combobox-list",
|
|
135
|
+
className: cn("flex flex-col overflow-y-auto overflow-x-hidden p-1 outline-none", listClassName),
|
|
136
|
+
children
|
|
137
|
+
})]
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function ComboboxItem({ className, children, ...props }) {
|
|
143
|
+
return /* @__PURE__ */ jsxs(Combobox.Item, {
|
|
144
|
+
"data-slot": "combobox-item",
|
|
145
|
+
className: cn("relative flex w-full cursor-default select-none items-center gap-2 py-1.5 pr-8 pl-2", "rounded-[var(--ds-radius-sm)] text-[length:var(--ds-text-caption-lg)] text-[color:var(--ds-foreground)] outline-none", "data-[highlighted]:bg-[var(--ds-hover)] data-[highlighted]:text-[color:var(--ds-foreground)]", "data-[disabled]:pointer-events-none data-[disabled]:opacity-50", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", className),
|
|
146
|
+
...props,
|
|
147
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
148
|
+
"data-slot": "combobox-item-text",
|
|
149
|
+
className: "flex-1 truncate",
|
|
150
|
+
children
|
|
151
|
+
}), /* @__PURE__ */ jsx(Combobox.ItemIndicator, {
|
|
152
|
+
"data-slot": "combobox-item-indicator",
|
|
153
|
+
className: "absolute right-2 flex size-4 items-center justify-center text-[color:var(--ds-primary)]",
|
|
154
|
+
children: /* @__PURE__ */ jsx(Check, { className: "size-4" })
|
|
155
|
+
})]
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/** Renders per filtered item; use inside a `ComboboxGroup` given `items`, or for a flat list pass a function as `ComboboxContent` children instead. */
|
|
159
|
+
function ComboboxCollection(props) {
|
|
160
|
+
return /* @__PURE__ */ jsx(Combobox.Collection, { ...props });
|
|
161
|
+
}
|
|
162
|
+
function ComboboxEmpty({ className, ...props }) {
|
|
163
|
+
return /* @__PURE__ */ jsx(Combobox.Empty, {
|
|
164
|
+
"data-slot": "combobox-empty",
|
|
165
|
+
className: cn("px-2 py-1.5 text-[length:var(--ds-text-caption-lg)] text-[color:var(--ds-muted-foreground)] empty:m-0 empty:p-0", className),
|
|
166
|
+
...props
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
function ComboboxStatus({ className, ...props }) {
|
|
170
|
+
return /* @__PURE__ */ jsx(Combobox.Status, {
|
|
171
|
+
"data-slot": "combobox-status",
|
|
172
|
+
className: cn("px-2 py-1.5 text-[length:var(--ds-text-caption-lg)] text-[color:var(--ds-muted-foreground)] empty:m-0 empty:p-0", className),
|
|
173
|
+
...props
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function ComboboxGroup({ className, ...props }) {
|
|
177
|
+
return /* @__PURE__ */ jsx(Combobox.Group, {
|
|
178
|
+
"data-slot": "combobox-group",
|
|
179
|
+
className: cn("flex flex-col", className),
|
|
180
|
+
...props
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
function ComboboxGroupLabel({ className, ...props }) {
|
|
184
|
+
return /* @__PURE__ */ jsx(Combobox.GroupLabel, {
|
|
185
|
+
"data-slot": "combobox-group-label",
|
|
186
|
+
className: cn("px-2 py-1.5 text-[length:var(--ds-text-caption)] font-medium text-[color:var(--ds-muted-foreground)]", className),
|
|
187
|
+
...props
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function ComboboxSeparator({ className, ...props }) {
|
|
191
|
+
return /* @__PURE__ */ jsx(Combobox.Separator, {
|
|
192
|
+
"data-slot": "combobox-separator",
|
|
193
|
+
className: cn("-mx-1 my-1 h-px bg-[var(--ds-border)]", className),
|
|
194
|
+
...props
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
const useComboboxFilter = Combobox.useFilter;
|
|
198
|
+
//#endregion
|
|
199
|
+
export { Combobox$1 as Combobox, ComboboxChip, ComboboxChips, ComboboxClear, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxItem, ComboboxSeparator, ComboboxStatus, ComboboxTrigger, ComboboxValue, useComboboxFilter };
|
|
200
|
+
|
|
201
|
+
//# sourceMappingURL=combobox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox.js","names":["Combobox","ComboboxPrimitive"],"sources":["../../src/components/combobox.tsx"],"sourcesContent":["\"use client\";\n\nimport { Combobox as ComboboxPrimitive } from \"@base-ui/react/combobox\";\nimport { Check, ChevronDown, X } from \"lucide-react\";\nimport { createContext, useContext, type ReactNode } from \"react\";\nimport { cn } from \"@/lib/cn\";\nimport { inputClassName } from \"@/components/input\";\n\n/**\n * Combobox: a filterable text input with a listbox popup, on Base UI.\n *\n * Give the Root `items` (an array, or `[{ value, label }]`) and render the\n * list with `<ComboboxList>{(item) => <ComboboxItem value={item} />}</ComboboxList>`;\n * Base UI filters `items` against the input as the user types. Without\n * `items` nothing is filtered and `ComboboxEmpty` never shows.\n *\n * - `ComboboxInput` is our `Input` with a trailing open/close trigger and,\n * with `clearable`, an X button that clears the value.\n * - `ComboboxContent` composes Portal + Positioner + Popup + List so\n * consumers write one element; positioning props go to the Positioner.\n * - Multiple selection: set `multiple` on the Root and wrap `ComboboxValue`\n * (rendering a `ComboboxChip` per value) plus `ComboboxInput` in\n * `ComboboxChips`. Inside `ComboboxChips` the input drops its own frame;\n * the chips container carries the field look and anchors the popup.\n * - `useComboboxFilter` is Base UI's `useFilter` for external filtering via\n * `filteredItems`.\n *\n * `onValueChange` receives `(value, eventDetails)`; `onInputValueChange`\n * reports the typed text.\n */\nfunction Combobox<Value, Multiple extends boolean | undefined = false, Item = Value>(\n props: ComboboxPrimitive.Root.Props<Value, Multiple, Item>,\n) {\n return <ComboboxPrimitive.Root {...props} />;\n}\n\nconst InsideChipsContext = /* @__PURE__ */ createContext(false);\n\nconst controlButtonClassName = /* @__PURE__ */ cn(\n \"flex size-6 shrink-0 items-center justify-center rounded-[var(--ds-radius-sm)]\",\n \"text-[color:var(--ds-muted-foreground)] outline-none\",\n \"transition-[background-color,color] duration-[var(--ds-duration-fast)] ease-[var(--ds-ease-out)]\",\n \"hover:bg-[var(--ds-hover)] hover:text-[color:var(--ds-foreground)]\",\n \"focus-visible:ring-[3px] focus-visible:ring-[var(--ds-ring)]/40\",\n \"data-[disabled]:pointer-events-none data-[disabled]:opacity-50\",\n \"[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0\",\n);\n\nfunction ComboboxTrigger({ className, children, ...props }: ComboboxPrimitive.Trigger.Props) {\n return (\n <ComboboxPrimitive.Trigger\n data-slot=\"combobox-trigger\"\n aria-label=\"Open\"\n className={cn(controlButtonClassName, className)}\n {...props}\n >\n {children ?? (\n <ComboboxPrimitive.Icon\n data-slot=\"combobox-icon\"\n className=\"flex transition-transform duration-[var(--ds-duration-fast)] data-[popup-open]:rotate-180\"\n >\n <ChevronDown />\n </ComboboxPrimitive.Icon>\n )}\n </ComboboxPrimitive.Trigger>\n );\n}\n\nfunction ComboboxClear({ className, children, ...props }: ComboboxPrimitive.Clear.Props) {\n return (\n <ComboboxPrimitive.Clear\n data-slot=\"combobox-clear\"\n aria-label=\"Clear\"\n className={cn(controlButtonClassName, className)}\n {...props}\n >\n {children ?? <X />}\n </ComboboxPrimitive.Clear>\n );\n}\n\nexport interface ComboboxInputProps extends ComboboxPrimitive.Input.Props {\n /** Show an X button that clears the selection while there is one. */\n clearable?: boolean;\n /** Class for the wrapper that holds the input and its buttons. */\n wrapperClassName?: string;\n}\n\nfunction ComboboxInput({ className, clearable = false, wrapperClassName, ...props }: ComboboxInputProps) {\n const insideChips = useContext(InsideChipsContext);\n if (insideChips) {\n return (\n <ComboboxPrimitive.Input\n data-slot=\"combobox-input\"\n className={cn(\n \"h-7 min-w-16 flex-1 bg-transparent outline-none\",\n \"text-[length:var(--ds-text-caption-lg)] leading-[var(--ds-text-caption-lg--line-height)] text-[color:var(--ds-foreground)]\",\n \"placeholder:text-[color:var(--ds-text-tertiary)]\",\n \"disabled:cursor-not-allowed\",\n className,\n )}\n {...props}\n />\n );\n }\n return (\n <ComboboxPrimitive.InputGroup\n data-slot=\"combobox-input-group\"\n className={cn(\"relative flex w-full items-center\", wrapperClassName)}\n >\n <ComboboxPrimitive.Input\n data-slot=\"combobox-input\"\n className={cn(inputClassName, clearable ? \"pr-16\" : \"pr-9\", className)}\n {...props}\n />\n <div className=\"absolute inset-y-0 right-1.5 flex items-center gap-0.5\">\n {clearable ? <ComboboxClear /> : null}\n <ComboboxTrigger />\n </div>\n </ComboboxPrimitive.InputGroup>\n );\n}\n\nfunction ComboboxValue(props: ComboboxPrimitive.Value.Props) {\n return <ComboboxPrimitive.Value {...props} />;\n}\n\nexport interface ComboboxChipsProps extends ComboboxPrimitive.Chips.Props {\n /** Class for the inner chip row; `className` styles the field frame. */\n chipsClassName?: string;\n}\n\nfunction ComboboxChips({ className, chipsClassName, children, ...props }: ComboboxChipsProps) {\n return (\n <InsideChipsContext.Provider value>\n <ComboboxPrimitive.InputGroup\n data-slot=\"combobox-input-group\"\n className={cn(\n \"relative flex w-full min-w-0 items-start gap-1 rounded-[var(--ds-radius-md)] border border-[var(--ds-border)] bg-[var(--ds-muted)] py-1 pl-1.5 pr-1.5\",\n \"transition-[border-color,box-shadow] duration-[var(--ds-duration-fast)] ease-[var(--ds-ease-out)]\",\n \"hover:border-[var(--ds-border-strong)]\",\n \"focus-within:border-[var(--ds-ring)] focus-within:ring-[3px] focus-within:ring-[var(--ds-ring)]/40\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50\",\n \"data-[invalid]:border-[var(--ds-destructive)] data-[invalid]:ring-[3px] data-[invalid]:ring-[var(--ds-destructive)]/20\",\n className,\n )}\n >\n <ComboboxPrimitive.Chips\n data-slot=\"combobox-chips\"\n className={cn(\"flex min-h-7 min-w-0 flex-1 flex-wrap items-center gap-1 px-1\", chipsClassName)}\n {...props}\n >\n {children}\n </ComboboxPrimitive.Chips>\n <ComboboxTrigger className=\"mt-0.5\" />\n </ComboboxPrimitive.InputGroup>\n </InsideChipsContext.Provider>\n );\n}\n\nexport interface ComboboxChipProps extends ComboboxPrimitive.Chip.Props {\n /** Hide the remove button. */\n removable?: boolean;\n}\n\nfunction ComboboxChip({ className, children, removable = true, ...props }: ComboboxChipProps) {\n return (\n <ComboboxPrimitive.Chip\n data-slot=\"combobox-chip\"\n className={cn(\n \"inline-flex h-6 max-w-full cursor-default items-center gap-1 whitespace-nowrap border pl-2.5 outline-none\",\n removable ? \"pr-1\" : \"pr-2.5\",\n \"rounded-[var(--ds-radius-full)] border-[var(--ds-border-subtle)] bg-[var(--ds-hover)]\",\n \"text-[length:var(--ds-text-caption)] font-medium text-[color:var(--ds-muted-foreground)]\",\n \"focus-visible:border-[var(--ds-ring)] focus-visible:bg-[var(--ds-primary-soft)] focus-visible:text-[color:var(--ds-primary)]\",\n \"data-[disabled]:opacity-50\",\n className,\n )}\n {...props}\n >\n <span className=\"truncate\">{children}</span>\n {removable ? (\n <ComboboxPrimitive.ChipRemove\n data-slot=\"combobox-chip-remove\"\n aria-label=\"Remove\"\n className={cn(\n \"flex size-4 shrink-0 items-center justify-center rounded-[var(--ds-radius-full)] outline-none\",\n \"transition-[background-color,color] duration-[var(--ds-duration-fast)]\",\n \"hover:bg-[var(--ds-border)] hover:text-[color:var(--ds-foreground)]\",\n \"[&_svg]:size-3\",\n )}\n >\n <X />\n </ComboboxPrimitive.ChipRemove>\n ) : null}\n </ComboboxPrimitive.Chip>\n );\n}\n\ntype PositionerProps = Pick<\n ComboboxPrimitive.Positioner.Props,\n | \"side\"\n | \"align\"\n | \"sideOffset\"\n | \"alignOffset\"\n | \"anchor\"\n | \"collisionBoundary\"\n | \"collisionPadding\"\n | \"collisionAvoidance\"\n | \"sticky\"\n | \"positionMethod\"\n>;\n\nexport interface ComboboxContentProps\n extends Omit<ComboboxPrimitive.Popup.Props, \"children\">,\n PositionerProps {\n /** Items, or a render function called per filtered item (needs `items` on the Root). */\n children?: ComboboxPrimitive.List.Props[\"children\"];\n /**\n * Shown (via `ComboboxEmpty`, above the list) when nothing matches the query.\n * Needs `items` on the Root.\n */\n empty?: ReactNode;\n /** Class for the inner List element. */\n listClassName?: string;\n /** Keep the popup mounted in the DOM while hidden. */\n keepMounted?: boolean;\n /** Where to portal the popup; defaults to `<body>`. */\n container?: ComboboxPrimitive.Portal.Props[\"container\"];\n}\n\nfunction ComboboxContent({\n className,\n children,\n empty,\n listClassName,\n side = \"bottom\",\n align = \"start\",\n sideOffset = 4,\n alignOffset,\n anchor,\n collisionBoundary,\n collisionPadding,\n collisionAvoidance,\n sticky,\n positionMethod,\n keepMounted,\n container,\n ...props\n}: ComboboxContentProps) {\n return (\n <ComboboxPrimitive.Portal keepMounted={keepMounted} container={container}>\n <ComboboxPrimitive.Positioner\n data-slot=\"combobox-positioner\"\n side={side}\n align={align}\n sideOffset={sideOffset}\n alignOffset={alignOffset}\n anchor={anchor}\n collisionBoundary={collisionBoundary}\n collisionPadding={collisionPadding}\n collisionAvoidance={collisionAvoidance}\n sticky={sticky}\n positionMethod={positionMethod}\n className=\"isolate z-50 outline-none\"\n >\n <ComboboxPrimitive.Popup\n data-slot=\"combobox-content\"\n className={cn(\n \"flex max-h-[min(var(--available-height,none),24rem)] w-[var(--anchor-width,auto)] min-w-[var(--anchor-width,auto)] flex-col overflow-hidden\",\n \"rounded-[var(--ds-radius-lg)] border border-[var(--ds-border)]\",\n \"bg-[var(--ds-popover)] text-[color:var(--ds-popover-foreground)] shadow-[var(--ds-shadow-lg)]\",\n \"outline-none\",\n \"open:animate-in open:fade-in-0 open:zoom-in-95\",\n \"closed:animate-out closed:fade-out-0 closed:zoom-out-95\",\n \"data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2\",\n \"duration-[var(--ds-duration-fast)] ease-[var(--ds-ease-out)]\",\n className,\n )}\n {...props}\n >\n {empty !== undefined ? <ComboboxEmpty>{empty}</ComboboxEmpty> : null}\n <ComboboxPrimitive.List\n data-slot=\"combobox-list\"\n className={cn(\"flex flex-col overflow-y-auto overflow-x-hidden p-1 outline-none\", listClassName)}\n >\n {children}\n </ComboboxPrimitive.List>\n </ComboboxPrimitive.Popup>\n </ComboboxPrimitive.Positioner>\n </ComboboxPrimitive.Portal>\n );\n}\n\nfunction ComboboxItem({ className, children, ...props }: ComboboxPrimitive.Item.Props) {\n return (\n <ComboboxPrimitive.Item\n data-slot=\"combobox-item\"\n className={cn(\n \"relative flex w-full cursor-default select-none items-center gap-2 py-1.5 pr-8 pl-2\",\n \"rounded-[var(--ds-radius-sm)] text-[length:var(--ds-text-caption-lg)] text-[color:var(--ds-foreground)] outline-none\",\n \"data-[highlighted]:bg-[var(--ds-hover)] data-[highlighted]:text-[color:var(--ds-foreground)]\",\n \"data-[disabled]:pointer-events-none data-[disabled]:opacity-50\",\n \"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n {...props}\n >\n <span data-slot=\"combobox-item-text\" className=\"flex-1 truncate\">\n {children}\n </span>\n <ComboboxPrimitive.ItemIndicator\n data-slot=\"combobox-item-indicator\"\n className=\"absolute right-2 flex size-4 items-center justify-center text-[color:var(--ds-primary)]\"\n >\n <Check className=\"size-4\" />\n </ComboboxPrimitive.ItemIndicator>\n </ComboboxPrimitive.Item>\n );\n}\n\n/** Renders per filtered item; use inside a `ComboboxGroup` given `items`, or for a flat list pass a function as `ComboboxContent` children instead. */\nfunction ComboboxCollection(props: ComboboxPrimitive.Collection.Props) {\n return <ComboboxPrimitive.Collection {...props} />;\n}\n\nfunction ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {\n return (\n <ComboboxPrimitive.Empty\n data-slot=\"combobox-empty\"\n className={cn(\n \"px-2 py-1.5 text-[length:var(--ds-text-caption-lg)] text-[color:var(--ds-muted-foreground)] empty:m-0 empty:p-0\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction ComboboxStatus({ className, ...props }: ComboboxPrimitive.Status.Props) {\n return (\n <ComboboxPrimitive.Status\n data-slot=\"combobox-status\"\n className={cn(\n \"px-2 py-1.5 text-[length:var(--ds-text-caption-lg)] text-[color:var(--ds-muted-foreground)] empty:m-0 empty:p-0\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction ComboboxGroup({ className, ...props }: ComboboxPrimitive.Group.Props) {\n return (\n <ComboboxPrimitive.Group\n data-slot=\"combobox-group\"\n className={cn(\"flex flex-col\", className)}\n {...props}\n />\n );\n}\n\nfunction ComboboxGroupLabel({ className, ...props }: ComboboxPrimitive.GroupLabel.Props) {\n return (\n <ComboboxPrimitive.GroupLabel\n data-slot=\"combobox-group-label\"\n className={cn(\n \"px-2 py-1.5 text-[length:var(--ds-text-caption)] font-medium text-[color:var(--ds-muted-foreground)]\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction ComboboxSeparator({ className, ...props }: ComboboxPrimitive.Separator.Props) {\n return (\n <ComboboxPrimitive.Separator\n data-slot=\"combobox-separator\"\n className={cn(\"-mx-1 my-1 h-px bg-[var(--ds-border)]\", className)}\n {...props}\n />\n );\n}\n\nconst useComboboxFilter = ComboboxPrimitive.useFilter;\n\nexport {\n Combobox,\n ComboboxInput,\n ComboboxTrigger,\n ComboboxClear,\n ComboboxValue,\n ComboboxContent,\n ComboboxItem,\n ComboboxCollection,\n ComboboxEmpty,\n ComboboxStatus,\n ComboboxGroup,\n ComboboxGroupLabel,\n ComboboxSeparator,\n ComboboxChips,\n ComboboxChip,\n useComboboxFilter,\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Dialog, DialogContentProps } from "./dialog.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Command } from "cmdk";
|
|
5
|
+
//#region src/components/command.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Command palette on cmdk, styled like DropdownMenu.
|
|
8
|
+
*
|
|
9
|
+
* cmdk filters and ranks items itself from each item's text (or `value` /
|
|
10
|
+
* `keywords`); `CommandEmpty` renders when nothing matches. The selected
|
|
11
|
+
* (keyboard-highlighted) item carries `data-selected="true"`; `onSelect` on
|
|
12
|
+
* `CommandItem` fires on click and on Enter.
|
|
13
|
+
*
|
|
14
|
+
* `CommandDialog` puts a palette inside our Dialog with no header padding;
|
|
15
|
+
* it needs a `title` (visually hidden) so the dialog is labelled. Wire
|
|
16
|
+
* `open` / `onOpenChange` to a global shortcut (⌘K) for the usual pattern.
|
|
17
|
+
*/
|
|
18
|
+
declare function Command$1({ className, ...props }: React.ComponentProps<typeof Command>): React.JSX.Element;
|
|
19
|
+
export interface CommandDialogProps extends React.ComponentProps<typeof Dialog> {
|
|
20
|
+
/** Accessible name for the dialog; visually hidden. */
|
|
21
|
+
title?: string;
|
|
22
|
+
/** Accessible description for the dialog; visually hidden. */
|
|
23
|
+
description?: string;
|
|
24
|
+
/** Class for the dialog popup. */
|
|
25
|
+
className?: string;
|
|
26
|
+
/** Class for the inner Command root. */
|
|
27
|
+
commandClassName?: string;
|
|
28
|
+
/** Where to portal the dialog; defaults to `<body>`. */
|
|
29
|
+
container?: DialogContentProps["container"];
|
|
30
|
+
/** Keep the dialog mounted in the DOM while hidden. */
|
|
31
|
+
keepMounted?: boolean;
|
|
32
|
+
/** Props for the inner cmdk root (`filter`, `shouldFilter`, `loop`, `value`, ...). */
|
|
33
|
+
commandProps?: Omit<React.ComponentProps<typeof Command>, "children" | "className">;
|
|
34
|
+
children?: React.ReactNode;
|
|
35
|
+
}
|
|
36
|
+
declare function CommandDialog({ title, description, className, commandClassName, container, keepMounted, commandProps, children, ...props }: CommandDialogProps): React.JSX.Element;
|
|
37
|
+
declare function CommandInput({ className, ...props }: React.ComponentProps<typeof Command.Input>): React.JSX.Element;
|
|
38
|
+
declare function CommandList({ className, ...props }: React.ComponentProps<typeof Command.List>): React.JSX.Element;
|
|
39
|
+
declare function CommandEmpty({ className, ...props }: React.ComponentProps<typeof Command.Empty>): React.JSX.Element;
|
|
40
|
+
declare function CommandGroup({ className, ...props }: React.ComponentProps<typeof Command.Group>): React.JSX.Element;
|
|
41
|
+
declare function CommandSeparator({ className, ...props }: React.ComponentProps<typeof Command.Separator>): React.JSX.Element;
|
|
42
|
+
export interface CommandItemProps extends React.ComponentProps<typeof Command.Item> {
|
|
43
|
+
variant?: "default" | "destructive";
|
|
44
|
+
}
|
|
45
|
+
declare function CommandItem({ className, variant, ...props }: CommandItemProps): React.JSX.Element;
|
|
46
|
+
declare function CommandShortcut({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
|
|
47
|
+
declare function CommandLoading(props: React.ComponentProps<typeof Command.Loading>): React.JSX.Element;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { Command$1 as Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandLoading, CommandSeparator, CommandShortcut };
|
|
50
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { Dialog, DialogContent, DialogDescription, DialogTitle } from "./dialog.js";
|
|
5
|
+
import { Search } from "lucide-react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Command } from "cmdk";
|
|
8
|
+
//#region src/components/command.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Command palette on cmdk, styled like DropdownMenu.
|
|
11
|
+
*
|
|
12
|
+
* cmdk filters and ranks items itself from each item's text (or `value` /
|
|
13
|
+
* `keywords`); `CommandEmpty` renders when nothing matches. The selected
|
|
14
|
+
* (keyboard-highlighted) item carries `data-selected="true"`; `onSelect` on
|
|
15
|
+
* `CommandItem` fires on click and on Enter.
|
|
16
|
+
*
|
|
17
|
+
* `CommandDialog` puts a palette inside our Dialog with no header padding;
|
|
18
|
+
* it needs a `title` (visually hidden) so the dialog is labelled. Wire
|
|
19
|
+
* `open` / `onOpenChange` to a global shortcut (⌘K) for the usual pattern.
|
|
20
|
+
*/
|
|
21
|
+
function Command$1({ className, ...props }) {
|
|
22
|
+
return /* @__PURE__ */ jsx(Command, {
|
|
23
|
+
"data-slot": "command",
|
|
24
|
+
className: cn("flex h-full w-full flex-col overflow-hidden outline-none", "rounded-[var(--ds-radius-lg)] bg-[var(--ds-popover)] text-[color:var(--ds-popover-foreground)]", className),
|
|
25
|
+
...props
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function CommandDialog({ title = "Command palette", description = "Search for a command to run", className, commandClassName, container, keepMounted, commandProps, children, ...props }) {
|
|
29
|
+
return /* @__PURE__ */ jsx(Dialog, {
|
|
30
|
+
...props,
|
|
31
|
+
children: /* @__PURE__ */ jsxs(DialogContent, {
|
|
32
|
+
"data-slot": "command-dialog",
|
|
33
|
+
container,
|
|
34
|
+
keepMounted,
|
|
35
|
+
className: cn("max-w-xl overflow-hidden p-0", className),
|
|
36
|
+
children: [
|
|
37
|
+
/* @__PURE__ */ jsx(DialogTitle, {
|
|
38
|
+
className: "sr-only",
|
|
39
|
+
children: title
|
|
40
|
+
}),
|
|
41
|
+
/* @__PURE__ */ jsx(DialogDescription, {
|
|
42
|
+
className: "sr-only",
|
|
43
|
+
children: description
|
|
44
|
+
}),
|
|
45
|
+
/* @__PURE__ */ jsx(Command$1, {
|
|
46
|
+
className: cn("rounded-none", "[&_[data-slot=command-input-wrapper]]:h-12 [&_[data-slot=command-input-wrapper]_svg]:size-5", "[&_[data-slot=command-input]]:h-12 [&_[data-slot=command-input]]:text-[length:var(--ds-text-body-sm)]", "[&_[data-slot=command-list]]:max-h-80", "[&_[data-slot=command-item]]:py-2 [&_[data-slot=command-item]_svg]:size-5", commandClassName),
|
|
47
|
+
...commandProps,
|
|
48
|
+
children
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function CommandInput({ className, ...props }) {
|
|
55
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
56
|
+
"data-slot": "command-input-wrapper",
|
|
57
|
+
className: "flex h-10 items-center gap-2 border-b border-[var(--ds-border)] px-3",
|
|
58
|
+
children: [/* @__PURE__ */ jsx(Search, { className: "size-4 shrink-0 text-[color:var(--ds-muted-foreground)]" }), /* @__PURE__ */ jsx(Command.Input, {
|
|
59
|
+
"data-slot": "command-input",
|
|
60
|
+
className: cn("flex h-10 w-full min-w-0 bg-transparent py-2 outline-none", "text-[length:var(--ds-text-caption-lg)] text-[color:var(--ds-foreground)]", "placeholder:text-[color:var(--ds-text-tertiary)]", "disabled:cursor-not-allowed disabled:opacity-50", className),
|
|
61
|
+
...props
|
|
62
|
+
})]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function CommandList({ className, ...props }) {
|
|
66
|
+
return /* @__PURE__ */ jsx(Command.List, {
|
|
67
|
+
"data-slot": "command-list",
|
|
68
|
+
className: cn("max-h-72 scroll-py-1 overflow-y-auto overflow-x-hidden p-1 outline-none", className),
|
|
69
|
+
...props
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function CommandEmpty({ className, ...props }) {
|
|
73
|
+
return /* @__PURE__ */ jsx(Command.Empty, {
|
|
74
|
+
"data-slot": "command-empty",
|
|
75
|
+
className: cn("py-6 text-center text-[length:var(--ds-text-caption-lg)] text-[color:var(--ds-muted-foreground)]", className),
|
|
76
|
+
...props
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function CommandGroup({ className, ...props }) {
|
|
80
|
+
return /* @__PURE__ */ jsx(Command.Group, {
|
|
81
|
+
"data-slot": "command-group",
|
|
82
|
+
className: cn("overflow-hidden text-[color:var(--ds-foreground)]", "[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5", "[&_[cmdk-group-heading]]:text-[length:var(--ds-text-caption)] [&_[cmdk-group-heading]]:font-medium", "[&_[cmdk-group-heading]]:text-[color:var(--ds-muted-foreground)]", className),
|
|
83
|
+
...props
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function CommandSeparator({ className, ...props }) {
|
|
87
|
+
return /* @__PURE__ */ jsx(Command.Separator, {
|
|
88
|
+
"data-slot": "command-separator",
|
|
89
|
+
className: cn("-mx-1 my-1 h-px bg-[var(--ds-border-subtle)]", className),
|
|
90
|
+
...props
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function CommandItem({ className, variant = "default", ...props }) {
|
|
94
|
+
return /* @__PURE__ */ jsx(Command.Item, {
|
|
95
|
+
"data-slot": "command-item",
|
|
96
|
+
"data-variant": variant,
|
|
97
|
+
className: cn("relative flex cursor-default select-none items-center gap-2 px-2 py-1.5 outline-none", "rounded-[var(--ds-radius-sm)] text-[length:var(--ds-text-body-sm)] text-[color:var(--ds-foreground)]", "transition-colors duration-[var(--ds-duration-fast)]", "data-[selected=true]:bg-[var(--ds-hover)] data-[selected=true]:text-[color:var(--ds-foreground)]", "data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", variant === "destructive" && "text-[color:var(--ds-destructive)] data-[selected=true]:bg-[var(--ds-destructive-soft)] data-[selected=true]:text-[color:var(--ds-destructive)]", className),
|
|
98
|
+
...props
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function CommandShortcut({ className, ...props }) {
|
|
102
|
+
return /* @__PURE__ */ jsx("span", {
|
|
103
|
+
"data-slot": "command-shortcut",
|
|
104
|
+
className: cn("ml-auto text-[length:var(--ds-text-caption)] tracking-widest text-[color:var(--ds-muted-foreground)]", className),
|
|
105
|
+
...props
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function CommandLoading(props) {
|
|
109
|
+
return /* @__PURE__ */ jsx(Command.Loading, {
|
|
110
|
+
"data-slot": "command-loading",
|
|
111
|
+
...props
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
export { Command$1 as Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandLoading, CommandSeparator, CommandShortcut };
|
|
116
|
+
|
|
117
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","names":["Command","CommandPrimitive"],"sources":["../../src/components/command.tsx"],"sourcesContent":["\"use client\";\n\nimport { Command as CommandPrimitive } from \"cmdk\";\nimport { Search } from \"lucide-react\";\nimport type * as React from \"react\";\nimport { cn } from \"@/lib/cn\";\nimport {\n Dialog,\n DialogContent,\n type DialogContentProps,\n DialogDescription,\n DialogTitle,\n} from \"@/components/dialog\";\n\n/**\n * Command palette on cmdk, styled like DropdownMenu.\n *\n * cmdk filters and ranks items itself from each item's text (or `value` /\n * `keywords`); `CommandEmpty` renders when nothing matches. The selected\n * (keyboard-highlighted) item carries `data-selected=\"true\"`; `onSelect` on\n * `CommandItem` fires on click and on Enter.\n *\n * `CommandDialog` puts a palette inside our Dialog with no header padding;\n * it needs a `title` (visually hidden) so the dialog is labelled. Wire\n * `open` / `onOpenChange` to a global shortcut (⌘K) for the usual pattern.\n */\nfunction Command({ className, ...props }: React.ComponentProps<typeof CommandPrimitive>) {\n return (\n <CommandPrimitive\n data-slot=\"command\"\n className={cn(\n \"flex h-full w-full flex-col overflow-hidden outline-none\",\n \"rounded-[var(--ds-radius-lg)] bg-[var(--ds-popover)] text-[color:var(--ds-popover-foreground)]\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport interface CommandDialogProps extends React.ComponentProps<typeof Dialog> {\n /** Accessible name for the dialog; visually hidden. */\n title?: string;\n /** Accessible description for the dialog; visually hidden. */\n description?: string;\n /** Class for the dialog popup. */\n className?: string;\n /** Class for the inner Command root. */\n commandClassName?: string;\n /** Where to portal the dialog; defaults to `<body>`. */\n container?: DialogContentProps[\"container\"];\n /** Keep the dialog mounted in the DOM while hidden. */\n keepMounted?: boolean;\n /** Props for the inner cmdk root (`filter`, `shouldFilter`, `loop`, `value`, ...). */\n commandProps?: Omit<React.ComponentProps<typeof CommandPrimitive>, \"children\" | \"className\">;\n children?: React.ReactNode;\n}\n\nfunction CommandDialog({\n title = \"Command palette\",\n description = \"Search for a command to run\",\n className,\n commandClassName,\n container,\n keepMounted,\n commandProps,\n children,\n ...props\n}: CommandDialogProps) {\n return (\n <Dialog {...props}>\n <DialogContent\n data-slot=\"command-dialog\"\n container={container}\n keepMounted={keepMounted}\n className={cn(\"max-w-xl overflow-hidden p-0\", className)}\n >\n <DialogTitle className=\"sr-only\">{title}</DialogTitle>\n <DialogDescription className=\"sr-only\">{description}</DialogDescription>\n <Command\n className={cn(\n \"rounded-none\",\n \"[&_[data-slot=command-input-wrapper]]:h-12 [&_[data-slot=command-input-wrapper]_svg]:size-5\",\n \"[&_[data-slot=command-input]]:h-12 [&_[data-slot=command-input]]:text-[length:var(--ds-text-body-sm)]\",\n \"[&_[data-slot=command-list]]:max-h-80\",\n \"[&_[data-slot=command-item]]:py-2 [&_[data-slot=command-item]_svg]:size-5\",\n commandClassName,\n )}\n {...commandProps}\n >\n {children}\n </Command>\n </DialogContent>\n </Dialog>\n );\n}\n\nfunction CommandInput({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Input>) {\n return (\n <div\n data-slot=\"command-input-wrapper\"\n className=\"flex h-10 items-center gap-2 border-b border-[var(--ds-border)] px-3\"\n >\n <Search className=\"size-4 shrink-0 text-[color:var(--ds-muted-foreground)]\" />\n <CommandPrimitive.Input\n data-slot=\"command-input\"\n className={cn(\n \"flex h-10 w-full min-w-0 bg-transparent py-2 outline-none\",\n \"text-[length:var(--ds-text-caption-lg)] text-[color:var(--ds-foreground)]\",\n \"placeholder:text-[color:var(--ds-text-tertiary)]\",\n \"disabled:cursor-not-allowed disabled:opacity-50\",\n className,\n )}\n {...props}\n />\n </div>\n );\n}\n\nfunction CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>) {\n return (\n <CommandPrimitive.List\n data-slot=\"command-list\"\n className={cn(\n \"max-h-72 scroll-py-1 overflow-y-auto overflow-x-hidden p-1 outline-none\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction CommandEmpty({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>) {\n return (\n <CommandPrimitive.Empty\n data-slot=\"command-empty\"\n className={cn(\n \"py-6 text-center text-[length:var(--ds-text-caption-lg)] text-[color:var(--ds-muted-foreground)]\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction CommandGroup({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Group>) {\n return (\n <CommandPrimitive.Group\n data-slot=\"command-group\"\n className={cn(\n \"overflow-hidden text-[color:var(--ds-foreground)]\",\n \"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5\",\n \"[&_[cmdk-group-heading]]:text-[length:var(--ds-text-caption)] [&_[cmdk-group-heading]]:font-medium\",\n \"[&_[cmdk-group-heading]]:text-[color:var(--ds-muted-foreground)]\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction CommandSeparator({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Separator>) {\n return (\n <CommandPrimitive.Separator\n data-slot=\"command-separator\"\n className={cn(\"-mx-1 my-1 h-px bg-[var(--ds-border-subtle)]\", className)}\n {...props}\n />\n );\n}\n\nexport interface CommandItemProps extends React.ComponentProps<typeof CommandPrimitive.Item> {\n variant?: \"default\" | \"destructive\";\n}\n\nfunction CommandItem({ className, variant = \"default\", ...props }: CommandItemProps) {\n return (\n <CommandPrimitive.Item\n data-slot=\"command-item\"\n data-variant={variant}\n className={cn(\n \"relative flex cursor-default select-none items-center gap-2 px-2 py-1.5 outline-none\",\n \"rounded-[var(--ds-radius-sm)] text-[length:var(--ds-text-body-sm)] text-[color:var(--ds-foreground)]\",\n \"transition-colors duration-[var(--ds-duration-fast)]\",\n \"data-[selected=true]:bg-[var(--ds-hover)] data-[selected=true]:text-[color:var(--ds-foreground)]\",\n \"data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50\",\n \"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n variant === \"destructive\" &&\n \"text-[color:var(--ds-destructive)] data-[selected=true]:bg-[var(--ds-destructive-soft)] data-[selected=true]:text-[color:var(--ds-destructive)]\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction CommandShortcut({ className, ...props }: React.ComponentProps<\"span\">) {\n return (\n <span\n data-slot=\"command-shortcut\"\n className={cn(\n \"ml-auto text-[length:var(--ds-text-caption)] tracking-widest text-[color:var(--ds-muted-foreground)]\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction CommandLoading(props: React.ComponentProps<typeof CommandPrimitive.Loading>) {\n return <CommandPrimitive.Loading data-slot=\"command-loading\" {...props} />;\n}\n\nexport {\n Command,\n CommandDialog,\n CommandInput,\n CommandList,\n CommandEmpty,\n CommandGroup,\n CommandItem,\n CommandSeparator,\n CommandShortcut,\n CommandLoading,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0BA,SAASA,UAAQ,EAAE,WAAW,GAAG,SAAwD;CACvF,OACE,oBAACC,SAAD;EACE,aAAU;EACV,WAAW,GACT,4DACA,kGACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAoBA,SAAS,cAAc,EACrB,QAAQ,mBACR,cAAc,+BACd,WACA,kBACA,WACA,aACA,cACA,UACA,GAAG,SACkB;CACrB,OACE,oBAAC,QAAD;EAAQ,GAAI;EACV,UAAA,qBAAC,eAAD;GACE,aAAU;GACC;GACE;GACb,WAAW,GAAG,gCAAgC,SAAS;GAJzD,UAAA;IAME,oBAAC,aAAD;KAAa,WAAU;KAAW,UAAA;IAAmB,CAAA;IACrD,oBAAC,mBAAD;KAAmB,WAAU;KAAW,UAAA;IAA+B,CAAA;IACvE,oBAACD,WAAD;KACE,WAAW,GACT,gBACA,+FACA,yGACA,yCACA,6EACA,gBACF;KACA,GAAI;KAEH;IACM,CAAA;GACI;;CACT,CAAA;AAEZ;AAEA,SAAS,aAAa,EAAE,WAAW,GAAG,SAA8D;CAClG,OACE,qBAAC,OAAD;EACE,aAAU;EACV,WAAU;EAFZ,UAAA,CAIE,oBAAC,QAAD,EAAQ,WAAU,0DAA2D,CAAA,GAC7E,oBAACC,QAAiB,OAAlB;GACE,aAAU;GACV,WAAW,GACT,6DACA,6EACA,oDACA,mDACA,SACF;GACA,GAAI;EACL,CAAA,CACE;;AAET;AAEA,SAAS,YAAY,EAAE,WAAW,GAAG,SAA6D;CAChG,OACE,oBAACA,QAAiB,MAAlB;EACE,aAAU;EACV,WAAW,GACT,2EACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,aAAa,EAAE,WAAW,GAAG,SAA8D;CAClG,OACE,oBAACA,QAAiB,OAAlB;EACE,aAAU;EACV,WAAW,GACT,oGACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,aAAa,EAAE,WAAW,GAAG,SAA8D;CAClG,OACE,oBAACA,QAAiB,OAAlB;EACE,aAAU;EACV,WAAW,GACT,qDACA,iEACA,sGACA,oEACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,iBAAiB,EAAE,WAAW,GAAG,SAAkE;CAC1G,OACE,oBAACA,QAAiB,WAAlB;EACE,aAAU;EACV,WAAW,GAAG,gDAAgD,SAAS;EACvE,GAAI;CACL,CAAA;AAEL;AAMA,SAAS,YAAY,EAAE,WAAW,UAAU,WAAW,GAAG,SAA2B;CACnF,OACE,oBAACA,QAAiB,MAAlB;EACE,aAAU;EACV,gBAAc;EACd,WAAW,GACT,wFACA,wGACA,wDACA,oGACA,4EACA,qFACA,YAAY,iBACV,mJACF,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,gBAAgB,EAAE,WAAW,GAAG,SAAuC;CAC9E,OACE,oBAAC,QAAD;EACE,aAAU;EACV,WAAW,GACT,wGACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,eAAe,OAA8D;CACpF,OAAO,oBAACA,QAAiB,SAAlB;EAA0B,aAAU;EAAkB,GAAI;CAAQ,CAAA;AAC3E"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { DataTableInstance, DataTableRow, DataTableTable, UseDataTableOptions } from "./types.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { RowData } from "@tanstack/react-table";
|
|
5
|
+
//#region src/components/data-table/data-table.d.ts
|
|
6
|
+
export interface DataTableViewProps<Row extends RowData> {
|
|
7
|
+
className?: string;
|
|
8
|
+
/** Height of the scrolling body. Required for virtualisation to mean anything; defaults to 600px when virtualised. */
|
|
9
|
+
maxHeight?: number | string;
|
|
10
|
+
/** Force virtualisation on or off; undefined virtualises above 100 rows. */
|
|
11
|
+
virtualize?: boolean;
|
|
12
|
+
/** Estimated row height in px for the virtualizer. @default 40 */
|
|
13
|
+
rowHeight?: number;
|
|
14
|
+
/** @default true */
|
|
15
|
+
stickyHeader?: boolean;
|
|
16
|
+
/** @default "default" */
|
|
17
|
+
density?: "default" | "compact";
|
|
18
|
+
/** Detail panel under an expanded row; enables the expander column. */
|
|
19
|
+
renderSubComponent?: (row: DataTableRow<Row>) => React.ReactNode;
|
|
20
|
+
/** `false` hides the toolbar; a function replaces it. */
|
|
21
|
+
toolbar?: boolean | ((ctx: {
|
|
22
|
+
instance: DataTableInstance<Row>;
|
|
23
|
+
}) => React.ReactNode);
|
|
24
|
+
/** Rendered in the toolbar while rows are selected. */
|
|
25
|
+
bulkActions?: (ctx: {
|
|
26
|
+
rows: Row[];
|
|
27
|
+
table: DataTableTable<Row>;
|
|
28
|
+
}) => React.ReactNode;
|
|
29
|
+
/** Extra toolbar controls (right side). */
|
|
30
|
+
toolbarActions?: React.ReactNode;
|
|
31
|
+
searchPlaceholder?: string;
|
|
32
|
+
emptyState?: React.ReactNode;
|
|
33
|
+
/** @default "No results" */
|
|
34
|
+
emptyMessage?: string;
|
|
35
|
+
pageSizeOptions?: number[];
|
|
36
|
+
/** @default true */
|
|
37
|
+
enableExport?: boolean;
|
|
38
|
+
/** @default "export" */
|
|
39
|
+
exportFileName?: string;
|
|
40
|
+
/** Show the loading skeleton regardless of the source's own state. */
|
|
41
|
+
loading?: boolean;
|
|
42
|
+
/** Error to show above the table, in addition to the server source's. */
|
|
43
|
+
error?: string | Error | null;
|
|
44
|
+
onRowClick?: (row: Row, event: React.MouseEvent<HTMLTableRowElement>) => void;
|
|
45
|
+
/**
|
|
46
|
+
* The row a detail pane is currently showing, matched against the row id
|
|
47
|
+
* (`getRowId`, the row index when that is not set). It gets `data-active`
|
|
48
|
+
* and the `--ds-primary-soft` tint, independent of checkbox selection — a
|
|
49
|
+
* master/detail list highlights one row without selecting it, and a table
|
|
50
|
+
* with both can show a selected set and one open row at once.
|
|
51
|
+
*/
|
|
52
|
+
activeRowId?: string | null;
|
|
53
|
+
/** Extra classes per row, e.g. to dim rows the app considers stale. */
|
|
54
|
+
rowClassName?: (row: Row) => string | undefined;
|
|
55
|
+
}
|
|
56
|
+
export type DataTableProps<Row extends RowData> = DataTableViewProps<Row> & ({
|
|
57
|
+
instance: DataTableInstance<Row>;
|
|
58
|
+
} | UseDataTableOptions<Row>);
|
|
59
|
+
declare function DataTable<Row extends RowData>(props: DataTableProps<Row>): React.JSX.Element;
|
|
60
|
+
declare function DataTableView<Row extends RowData>({ instance, className, maxHeight, virtualize, rowHeight, stickyHeader, density, renderSubComponent, toolbar, bulkActions, toolbarActions, searchPlaceholder, emptyState, emptyMessage, pageSizeOptions, enableExport, exportFileName, loading, error, onRowClick, activeRowId, rowClassName }: DataTableViewProps<Row> & {
|
|
61
|
+
instance: DataTableInstance<Row>;
|
|
62
|
+
}): React.JSX.Element;
|
|
63
|
+
//#endregion
|
|
64
|
+
export { DataTable, DataTableView };
|
|
65
|
+
//# sourceMappingURL=data-table.d.ts.map
|