@inui/design-system 0.0.0-stage → 1.22.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 +360 -2
- package/dist/components/ui/accordion.d.ts +44 -0
- package/dist/components/ui/accordion.d.ts.map +1 -0
- package/dist/components/ui/accordion.js +86 -0
- package/dist/components/ui/accordion.js.map +1 -0
- package/dist/components/ui/ai-avatar.d.ts +46 -0
- package/dist/components/ui/ai-avatar.d.ts.map +1 -0
- package/dist/components/ui/ai-avatar.js +43 -0
- package/dist/components/ui/ai-avatar.js.map +1 -0
- package/dist/components/ui/ai-label.d.ts +118 -0
- package/dist/components/ui/ai-label.d.ts.map +1 -0
- package/dist/components/ui/ai-label.js +184 -0
- package/dist/components/ui/ai-label.js.map +1 -0
- package/dist/components/ui/ai-sparkle.d.ts +91 -0
- package/dist/components/ui/ai-sparkle.d.ts.map +1 -0
- package/dist/components/ui/ai-sparkle.js +200 -0
- package/dist/components/ui/ai-sparkle.js.map +1 -0
- package/dist/components/ui/alert-dialog.d.ts +79 -0
- package/dist/components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/components/ui/alert-dialog.js +147 -0
- package/dist/components/ui/alert-dialog.js.map +1 -0
- package/dist/components/ui/alert.d.ts +71 -0
- package/dist/components/ui/alert.d.ts.map +1 -0
- package/dist/components/ui/alert.js +108 -0
- package/dist/components/ui/alert.js.map +1 -0
- package/dist/components/ui/aspect-ratio.d.ts +30 -0
- package/dist/components/ui/aspect-ratio.d.ts.map +1 -0
- package/dist/components/ui/aspect-ratio.js +40 -0
- package/dist/components/ui/aspect-ratio.js.map +1 -0
- package/dist/components/ui/attachment.d.ts +74 -0
- package/dist/components/ui/attachment.d.ts.map +1 -0
- package/dist/components/ui/attachment.js +142 -0
- package/dist/components/ui/attachment.js.map +1 -0
- package/dist/components/ui/avatar.d.ts +82 -0
- package/dist/components/ui/avatar.d.ts.map +1 -0
- package/dist/components/ui/avatar.js +123 -0
- package/dist/components/ui/avatar.js.map +1 -0
- package/dist/components/ui/badge.d.ts +130 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/badge.js +226 -0
- package/dist/components/ui/badge.js.map +1 -0
- package/dist/components/ui/breadcrumb.d.ts +43 -0
- package/dist/components/ui/breadcrumb.d.ts.map +1 -0
- package/dist/components/ui/breadcrumb.js +98 -0
- package/dist/components/ui/breadcrumb.js.map +1 -0
- package/dist/components/ui/browser-tabs.d.ts +218 -0
- package/dist/components/ui/browser-tabs.d.ts.map +1 -0
- package/dist/components/ui/browser-tabs.js +528 -0
- package/dist/components/ui/browser-tabs.js.map +1 -0
- package/dist/components/ui/bubble.d.ts +80 -0
- package/dist/components/ui/bubble.d.ts.map +1 -0
- package/dist/components/ui/bubble.js +235 -0
- package/dist/components/ui/bubble.js.map +1 -0
- package/dist/components/ui/button-group.d.ts +60 -0
- package/dist/components/ui/button-group.d.ts.map +1 -0
- package/dist/components/ui/button-group.js +89 -0
- package/dist/components/ui/button-group.js.map +1 -0
- package/dist/components/ui/button.d.ts +157 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +144 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/calendar.d.ts +57 -0
- package/dist/components/ui/calendar.d.ts.map +1 -0
- package/dist/components/ui/calendar.js +163 -0
- package/dist/components/ui/calendar.js.map +1 -0
- package/dist/components/ui/card.d.ts +96 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/card.js +131 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/carousel.d.ts +86 -0
- package/dist/components/ui/carousel.d.ts.map +1 -0
- package/dist/components/ui/carousel.js +207 -0
- package/dist/components/ui/carousel.js.map +1 -0
- package/dist/components/ui/checkbox.d.ts +54 -0
- package/dist/components/ui/checkbox.d.ts.map +1 -0
- package/dist/components/ui/checkbox.js +78 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/collapsible.d.ts +45 -0
- package/dist/components/ui/collapsible.d.ts.map +1 -0
- package/dist/components/ui/collapsible.js +65 -0
- package/dist/components/ui/collapsible.js.map +1 -0
- package/dist/components/ui/combobox.d.ts +111 -0
- package/dist/components/ui/combobox.d.ts.map +1 -0
- package/dist/components/ui/combobox.js +264 -0
- package/dist/components/ui/combobox.js.map +1 -0
- package/dist/components/ui/command.d.ts +71 -0
- package/dist/components/ui/command.d.ts.map +1 -0
- package/dist/components/ui/command.js +133 -0
- package/dist/components/ui/command.js.map +1 -0
- package/dist/components/ui/context-menu.d.ts +70 -0
- package/dist/components/ui/context-menu.d.ts.map +1 -0
- package/dist/components/ui/context-menu.js +163 -0
- package/dist/components/ui/context-menu.js.map +1 -0
- package/dist/components/ui/count-badge.d.ts +40 -0
- package/dist/components/ui/count-badge.d.ts.map +1 -0
- package/dist/components/ui/count-badge.js +43 -0
- package/dist/components/ui/count-badge.js.map +1 -0
- package/dist/components/ui/data-table.d.ts +1026 -0
- package/dist/components/ui/data-table.d.ts.map +1 -0
- package/dist/components/ui/data-table.js +3423 -0
- package/dist/components/ui/data-table.js.map +1 -0
- package/dist/components/ui/dialog.d.ts +73 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/dialog.js +145 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/direction.d.ts +35 -0
- package/dist/components/ui/direction.d.ts.map +1 -0
- package/dist/components/ui/direction.js +35 -0
- package/dist/components/ui/direction.js.map +1 -0
- package/dist/components/ui/drawer.d.ts +53 -0
- package/dist/components/ui/drawer.d.ts.map +1 -0
- package/dist/components/ui/drawer.js +115 -0
- package/dist/components/ui/drawer.js.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +75 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.js +173 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/dropzone.d.ts +141 -0
- package/dist/components/ui/dropzone.d.ts.map +1 -0
- package/dist/components/ui/dropzone.js +257 -0
- package/dist/components/ui/dropzone.js.map +1 -0
- package/dist/components/ui/empty.d.ts +94 -0
- package/dist/components/ui/empty.d.ts.map +1 -0
- package/dist/components/ui/empty.js +149 -0
- package/dist/components/ui/empty.js.map +1 -0
- package/dist/components/ui/field.d.ts +122 -0
- package/dist/components/ui/field.d.ts.map +1 -0
- package/dist/components/ui/field.js +254 -0
- package/dist/components/ui/field.js.map +1 -0
- package/dist/components/ui/hover-card.d.ts +51 -0
- package/dist/components/ui/hover-card.d.ts.map +1 -0
- package/dist/components/ui/hover-card.js +101 -0
- package/dist/components/ui/hover-card.js.map +1 -0
- package/dist/components/ui/input-group.d.ts +62 -0
- package/dist/components/ui/input-group.d.ts.map +1 -0
- package/dist/components/ui/input-group.js +115 -0
- package/dist/components/ui/input-group.js.map +1 -0
- package/dist/components/ui/input-otp.d.ts +52 -0
- package/dist/components/ui/input-otp.d.ts.map +1 -0
- package/dist/components/ui/input-otp.js +89 -0
- package/dist/components/ui/input-otp.js.map +1 -0
- package/dist/components/ui/input.d.ts +47 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +47 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/item.d.ts +74 -0
- package/dist/components/ui/item.d.ts.map +1 -0
- package/dist/components/ui/item.js +176 -0
- package/dist/components/ui/item.js.map +1 -0
- package/dist/components/ui/kbd.d.ts +41 -0
- package/dist/components/ui/kbd.d.ts.map +1 -0
- package/dist/components/ui/kbd.js +58 -0
- package/dist/components/ui/kbd.js.map +1 -0
- package/dist/components/ui/key-value-pair.d.ts +56 -0
- package/dist/components/ui/key-value-pair.d.ts.map +1 -0
- package/dist/components/ui/key-value-pair.js +110 -0
- package/dist/components/ui/key-value-pair.js.map +1 -0
- package/dist/components/ui/label.d.ts +83 -0
- package/dist/components/ui/label.d.ts.map +1 -0
- package/dist/components/ui/label.js +85 -0
- package/dist/components/ui/label.js.map +1 -0
- package/dist/components/ui/marker.d.ts +54 -0
- package/dist/components/ui/marker.d.ts.map +1 -0
- package/dist/components/ui/marker.js +79 -0
- package/dist/components/ui/marker.js.map +1 -0
- package/dist/components/ui/menubar.d.ts +72 -0
- package/dist/components/ui/menubar.d.ts.map +1 -0
- package/dist/components/ui/menubar.js +174 -0
- package/dist/components/ui/menubar.js.map +1 -0
- package/dist/components/ui/message-scroller.d.ts +53 -0
- package/dist/components/ui/message-scroller.d.ts.map +1 -0
- package/dist/components/ui/message-scroller.js +95 -0
- package/dist/components/ui/message-scroller.js.map +1 -0
- package/dist/components/ui/message.d.ts +63 -0
- package/dist/components/ui/message.d.ts.map +1 -0
- package/dist/components/ui/message.js +92 -0
- package/dist/components/ui/message.js.map +1 -0
- package/dist/components/ui/meta-list.d.ts +55 -0
- package/dist/components/ui/meta-list.d.ts.map +1 -0
- package/dist/components/ui/meta-list.js +75 -0
- package/dist/components/ui/meta-list.js.map +1 -0
- package/dist/components/ui/native-select.d.ts +51 -0
- package/dist/components/ui/native-select.d.ts.map +1 -0
- package/dist/components/ui/native-select.js +75 -0
- package/dist/components/ui/native-select.js.map +1 -0
- package/dist/components/ui/navigation-menu.d.ts +56 -0
- package/dist/components/ui/navigation-menu.d.ts.map +1 -0
- package/dist/components/ui/navigation-menu.js +116 -0
- package/dist/components/ui/navigation-menu.js.map +1 -0
- package/dist/components/ui/page-header.d.ts +223 -0
- package/dist/components/ui/page-header.d.ts.map +1 -0
- package/dist/components/ui/page-header.js +233 -0
- package/dist/components/ui/page-header.js.map +1 -0
- package/dist/components/ui/pagination.d.ts +68 -0
- package/dist/components/ui/pagination.d.ts.map +1 -0
- package/dist/components/ui/pagination.js +145 -0
- package/dist/components/ui/pagination.js.map +1 -0
- package/dist/components/ui/popover.d.ts +61 -0
- package/dist/components/ui/popover.d.ts.map +1 -0
- package/dist/components/ui/popover.js +144 -0
- package/dist/components/ui/popover.js.map +1 -0
- package/dist/components/ui/progress.d.ts +35 -0
- package/dist/components/ui/progress.d.ts.map +1 -0
- package/dist/components/ui/progress.js +46 -0
- package/dist/components/ui/progress.js.map +1 -0
- package/dist/components/ui/questionnaire.d.ts +92 -0
- package/dist/components/ui/questionnaire.d.ts.map +1 -0
- package/dist/components/ui/questionnaire.js +277 -0
- package/dist/components/ui/questionnaire.js.map +1 -0
- package/dist/components/ui/radio-group.d.ts +50 -0
- package/dist/components/ui/radio-group.d.ts.map +1 -0
- package/dist/components/ui/radio-group.js +65 -0
- package/dist/components/ui/radio-group.js.map +1 -0
- package/dist/components/ui/resizable.d.ts +44 -0
- package/dist/components/ui/resizable.d.ts.map +1 -0
- package/dist/components/ui/resizable.js +73 -0
- package/dist/components/ui/resizable.js.map +1 -0
- package/dist/components/ui/scroll-area.d.ts +55 -0
- package/dist/components/ui/scroll-area.d.ts.map +1 -0
- package/dist/components/ui/scroll-area.js +72 -0
- package/dist/components/ui/scroll-area.js.map +1 -0
- package/dist/components/ui/select.d.ts +274 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/select.js +609 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/separator.d.ts +31 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/separator.js +38 -0
- package/dist/components/ui/separator.js.map +1 -0
- package/dist/components/ui/sheet.d.ts +59 -0
- package/dist/components/ui/sheet.d.ts.map +1 -0
- package/dist/components/ui/sheet.js +128 -0
- package/dist/components/ui/sheet.js.map +1 -0
- package/dist/components/ui/sidebar.d.ts +166 -0
- package/dist/components/ui/sidebar.d.ts.map +1 -0
- package/dist/components/ui/sidebar.js +512 -0
- package/dist/components/ui/sidebar.js.map +1 -0
- package/dist/components/ui/skeleton.d.ts +35 -0
- package/dist/components/ui/skeleton.d.ts.map +1 -0
- package/dist/components/ui/skeleton.js +46 -0
- package/dist/components/ui/skeleton.js.map +1 -0
- package/dist/components/ui/slider.d.ts +39 -0
- package/dist/components/ui/slider.d.ts.map +1 -0
- package/dist/components/ui/slider.js +75 -0
- package/dist/components/ui/slider.js.map +1 -0
- package/dist/components/ui/sonner.d.ts +56 -0
- package/dist/components/ui/sonner.d.ts.map +1 -0
- package/dist/components/ui/sonner.js +96 -0
- package/dist/components/ui/sonner.js.map +1 -0
- package/dist/components/ui/spinner.d.ts +37 -0
- package/dist/components/ui/spinner.d.ts.map +1 -0
- package/dist/components/ui/spinner.js +51 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/stepper.d.ts +84 -0
- package/dist/components/ui/stepper.d.ts.map +1 -0
- package/dist/components/ui/stepper.js +145 -0
- package/dist/components/ui/stepper.js.map +1 -0
- package/dist/components/ui/switch.d.ts +36 -0
- package/dist/components/ui/switch.d.ts.map +1 -0
- package/dist/components/ui/switch.js +44 -0
- package/dist/components/ui/switch.js.map +1 -0
- package/dist/components/ui/table.d.ts +80 -0
- package/dist/components/ui/table.d.ts.map +1 -0
- package/dist/components/ui/table.js +130 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/components/ui/tabs.d.ts +87 -0
- package/dist/components/ui/tabs.d.ts.map +1 -0
- package/dist/components/ui/tabs.js +128 -0
- package/dist/components/ui/tabs.js.map +1 -0
- package/dist/components/ui/textarea.d.ts +35 -0
- package/dist/components/ui/textarea.d.ts.map +1 -0
- package/dist/components/ui/textarea.js +38 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/components/ui/time-picker.d.ts +58 -0
- package/dist/components/ui/time-picker.d.ts.map +1 -0
- package/dist/components/ui/time-picker.js +188 -0
- package/dist/components/ui/time-picker.js.map +1 -0
- package/dist/components/ui/toggle-group.d.ts +52 -0
- package/dist/components/ui/toggle-group.d.ts.map +1 -0
- package/dist/components/ui/toggle-group.js +94 -0
- package/dist/components/ui/toggle-group.js.map +1 -0
- package/dist/components/ui/toggle.d.ts +50 -0
- package/dist/components/ui/toggle.d.ts.map +1 -0
- package/dist/components/ui/toggle.js +70 -0
- package/dist/components/ui/toggle.js.map +1 -0
- package/dist/components/ui/tooltip.d.ts +51 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip.js +78 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/hooks/use-dark-mode.d.ts +2 -0
- package/dist/hooks/use-dark-mode.d.ts.map +1 -0
- package/dist/hooks/use-dark-mode.js +36 -0
- package/dist/hooks/use-dark-mode.js.map +1 -0
- package/dist/hooks/use-mobile.d.ts +2 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-mobile.js +20 -0
- package/dist/hooks/use-mobile.js.map +1 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +77 -0
- package/dist/lib/scope.d.ts +64 -0
- package/dist/lib/scope.d.ts.map +1 -0
- package/dist/lib/scope.js +74 -0
- package/dist/lib/scope.js.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +11 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/theme-tokens.css +537 -0
- package/dist/theme.css +417 -0
- package/package.json +103 -3
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { cn } from "../../lib/utils.js";
|
|
2
|
+
import { Separator as Separator$1 } from "./separator.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Slot } from "radix-ui";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { cva } from "class-variance-authority";
|
|
7
|
+
//#region src/components/ui/item.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Item — row for an entity in a list: media, text, and actions.
|
|
10
|
+
*
|
|
11
|
+
* cva-driven `div` (or `Slot` via `asChild`), no external primitive.
|
|
12
|
+
* `ItemMedia` has `default` | `icon` | `image` variants only — there is no
|
|
13
|
+
* separate `avatar` variant, so an `<Avatar>` goes in a plain (`default`)
|
|
14
|
+
* `ItemMedia`.
|
|
15
|
+
*/
|
|
16
|
+
var ItemGroupContext = React.createContext(false);
|
|
17
|
+
function ItemGroup({ className, ...props }) {
|
|
18
|
+
return /* @__PURE__ */ jsx(ItemGroupContext.Provider, {
|
|
19
|
+
value: true,
|
|
20
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
21
|
+
role: "list",
|
|
22
|
+
"data-slot": "item-group",
|
|
23
|
+
className: cn("group/item-group flex w-full flex-col gap-4 has-data-[size=sm]:gap-2.5 has-data-[size=xs]:gap-2", className),
|
|
24
|
+
...props
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function ItemSeparator({ className, ...props }) {
|
|
29
|
+
return /* @__PURE__ */ jsx(Separator$1, {
|
|
30
|
+
"data-slot": "item-separator",
|
|
31
|
+
orientation: "horizontal",
|
|
32
|
+
className: cn("my-2", className),
|
|
33
|
+
...props
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
var itemVariants = cva("group/item flex w-full flex-wrap items-center rounded-lg border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted", {
|
|
37
|
+
variants: {
|
|
38
|
+
variant: {
|
|
39
|
+
default: "border-transparent",
|
|
40
|
+
outline: "border-border",
|
|
41
|
+
muted: "border-transparent bg-muted/50"
|
|
42
|
+
},
|
|
43
|
+
size: {
|
|
44
|
+
default: "gap-2.5 px-3 py-2.5",
|
|
45
|
+
sm: "gap-2.5 px-3 py-2.5",
|
|
46
|
+
xs: "gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
defaultVariants: {
|
|
50
|
+
variant: "default",
|
|
51
|
+
size: "default"
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
function Item({ className, variant = "default", size = "default", asChild = false, ...props }) {
|
|
55
|
+
const isGrouped = React.useContext(ItemGroupContext);
|
|
56
|
+
const Comp = asChild ? Slot.Root : "div";
|
|
57
|
+
return /* @__PURE__ */ jsx(Comp, {
|
|
58
|
+
"data-slot": "item",
|
|
59
|
+
"data-variant": variant,
|
|
60
|
+
"data-size": size,
|
|
61
|
+
role: isGrouped ? "listitem" : void 0,
|
|
62
|
+
className: cn(itemVariants({
|
|
63
|
+
variant,
|
|
64
|
+
size,
|
|
65
|
+
className
|
|
66
|
+
})),
|
|
67
|
+
...props
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
var itemMediaVariants = cva("flex shrink-0 items-center justify-center gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start [&_svg]:pointer-events-none", {
|
|
71
|
+
variants: { variant: {
|
|
72
|
+
default: "bg-transparent",
|
|
73
|
+
icon: "[&_svg:not([class*='size-'])]:size-4",
|
|
74
|
+
image: "size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover"
|
|
75
|
+
} },
|
|
76
|
+
defaultVariants: { variant: "default" }
|
|
77
|
+
});
|
|
78
|
+
function ItemMedia({ className, variant = "default", ...props }) {
|
|
79
|
+
return /* @__PURE__ */ jsx("div", {
|
|
80
|
+
"data-slot": "item-media",
|
|
81
|
+
"data-variant": variant,
|
|
82
|
+
className: cn(itemMediaVariants({
|
|
83
|
+
variant,
|
|
84
|
+
className
|
|
85
|
+
})),
|
|
86
|
+
...props
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function ItemContent({ className, ...props }) {
|
|
90
|
+
return /* @__PURE__ */ jsx("div", {
|
|
91
|
+
"data-slot": "item-content",
|
|
92
|
+
className: cn("flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0 [&+[data-slot=item-content]]:flex-none", className),
|
|
93
|
+
...props
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function ItemTitle({ className, ...props }) {
|
|
97
|
+
return /* @__PURE__ */ jsx("div", {
|
|
98
|
+
"data-slot": "item-title",
|
|
99
|
+
className: cn("line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4", className),
|
|
100
|
+
...props
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function ItemDescription({ className, ...props }) {
|
|
104
|
+
return /* @__PURE__ */ jsx("p", {
|
|
105
|
+
"data-slot": "item-description",
|
|
106
|
+
className: cn("line-clamp-2 text-left text-sm leading-normal font-normal text-muted-foreground group-data-[size=xs]/item:text-xs [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary", className),
|
|
107
|
+
...props
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function ItemActions({ className, ...props }) {
|
|
111
|
+
return /* @__PURE__ */ jsx("div", {
|
|
112
|
+
"data-slot": "item-actions",
|
|
113
|
+
className: cn("flex items-center gap-2", className),
|
|
114
|
+
...props
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
function ItemHeader({ className, ...props }) {
|
|
118
|
+
return /* @__PURE__ */ jsx("div", {
|
|
119
|
+
"data-slot": "item-header",
|
|
120
|
+
className: cn("flex basis-full items-center justify-between gap-2", className),
|
|
121
|
+
...props
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function ItemFooter({ className, ...props }) {
|
|
125
|
+
return /* @__PURE__ */ jsx("div", {
|
|
126
|
+
"data-slot": "item-footer",
|
|
127
|
+
className: cn("flex basis-full items-center justify-between gap-2", className),
|
|
128
|
+
...props
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* WHEN TO USE
|
|
133
|
+
* - An entity list where each row has media, text, and actions — settings
|
|
134
|
+
* rows, search results, member lists, file/folder rows.
|
|
135
|
+
*
|
|
136
|
+
* NOT WHEN
|
|
137
|
+
* - Columnar data that needs alignment across rows — use Table.
|
|
138
|
+
* - A single grouped panel of content — use Card.
|
|
139
|
+
* - The row is a form control (checkbox, input, radio, select) — use Field.
|
|
140
|
+
*
|
|
141
|
+
* KEY RULES
|
|
142
|
+
* - Three sizes (default, sm, xs) and three variants (default, outline,
|
|
143
|
+
* muted) — `xs` is dense enough to use inside a dropdown-menu content
|
|
144
|
+
* area with zero padding.
|
|
145
|
+
* - `ItemMedia variant="icon"` auto-sizes any un-sized svg to `size-4`;
|
|
146
|
+
* `variant="image"` clips to a rounded square that shrinks with `size`.
|
|
147
|
+
* - `ItemGroup` sets `role="list"` and controls row gap by size — use it
|
|
148
|
+
* (not a plain `div`) whenever stacking more than one Item. Item only sets
|
|
149
|
+
* `role="listitem"` on itself when actually rendered inside an ItemGroup
|
|
150
|
+
* (detected via context) — a standalone Item outside any group stays role-less,
|
|
151
|
+
* since a bare `listitem` with no `list` ancestor is its own ARIA violation.
|
|
152
|
+
* - `ItemSeparator` is Separator pre-styled with `my-2` — use it between
|
|
153
|
+
* rows in a group instead of a raw `<Separator />`.
|
|
154
|
+
*
|
|
155
|
+
* USAGE
|
|
156
|
+
* <Item>
|
|
157
|
+
* <ItemMedia variant="icon"><FolderIcon /></ItemMedia>
|
|
158
|
+
* <ItemContent>
|
|
159
|
+
* <ItemTitle>Design tokens</ItemTitle>
|
|
160
|
+
* <ItemDescription>Colors, radius and typography.</ItemDescription>
|
|
161
|
+
* </ItemContent>
|
|
162
|
+
* <ItemActions>
|
|
163
|
+
* <Button variant="ghost" size="sm" iconOnly aria-label="Open"><ChevronRightIcon /></Button>
|
|
164
|
+
* </ItemActions>
|
|
165
|
+
* </Item>
|
|
166
|
+
*
|
|
167
|
+
* <ItemGroup className="rounded-xl border">
|
|
168
|
+
* <Item>...</Item>
|
|
169
|
+
* <ItemSeparator />
|
|
170
|
+
* <Item>...</Item>
|
|
171
|
+
* </ItemGroup>
|
|
172
|
+
*/
|
|
173
|
+
//#endregion
|
|
174
|
+
export { Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, ItemSeparator, ItemTitle };
|
|
175
|
+
|
|
176
|
+
//# sourceMappingURL=item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item.js","names":[],"sources":["../../../src/components/ui/item.tsx"],"sourcesContent":["/**\n * Item — row for an entity in a list: media, text, and actions.\n *\n * cva-driven `div` (or `Slot` via `asChild`), no external primitive.\n * `ItemMedia` has `default` | `icon` | `image` variants only — there is no\n * separate `avatar` variant, so an `<Avatar>` goes in a plain (`default`)\n * `ItemMedia`.\n */\n\nimport * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { Slot } from \"radix-ui\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Separator } from \"@/components/ui/separator\"\n\nconst ItemGroupContext = React.createContext(false)\n\nfunction ItemGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <ItemGroupContext.Provider value={true}>\n <div\n role=\"list\"\n data-slot=\"item-group\"\n className={cn(\n \"group/item-group flex w-full flex-col gap-4 has-data-[size=sm]:gap-2.5 has-data-[size=xs]:gap-2\",\n className\n )}\n {...props}\n />\n </ItemGroupContext.Provider>\n )\n}\n\nfunction ItemSeparator({\n className,\n ...props\n}: React.ComponentProps<typeof Separator>) {\n return (\n <Separator\n data-slot=\"item-separator\"\n orientation=\"horizontal\"\n className={cn(\"my-2\", className)}\n {...props}\n />\n )\n}\n\nconst itemVariants = cva(\n \"group/item flex w-full flex-wrap items-center rounded-lg border text-sm transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [a]:transition-colors [a]:hover:bg-muted\",\n {\n variants: {\n variant: {\n default: \"border-transparent\",\n outline: \"border-border\",\n muted: \"border-transparent bg-muted/50\",\n },\n size: {\n default: \"gap-2.5 px-3 py-2.5\",\n sm: \"gap-2.5 px-3 py-2.5\",\n xs: \"gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n }\n)\n\nfunction Item({\n className,\n variant = \"default\",\n size = \"default\",\n asChild = false,\n ...props\n}: React.ComponentProps<\"div\"> &\n VariantProps<typeof itemVariants> & { asChild?: boolean }) {\n const isGrouped = React.useContext(ItemGroupContext)\n const Comp = asChild ? Slot.Root : \"div\"\n return (\n <Comp\n data-slot=\"item\"\n data-variant={variant}\n data-size={size}\n role={isGrouped ? \"listitem\" : undefined}\n className={cn(itemVariants({ variant, size, className }))}\n {...props}\n />\n )\n}\n\nconst itemMediaVariants = cva(\n \"flex shrink-0 items-center justify-center gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start [&_svg]:pointer-events-none\",\n {\n variants: {\n variant: {\n default: \"bg-transparent\",\n icon: \"[&_svg:not([class*='size-'])]:size-4\",\n image:\n \"size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n }\n)\n\nfunction ItemMedia({\n className,\n variant = \"default\",\n ...props\n}: React.ComponentProps<\"div\"> & VariantProps<typeof itemMediaVariants>) {\n return (\n <div\n data-slot=\"item-media\"\n data-variant={variant}\n className={cn(itemMediaVariants({ variant, className }))}\n {...props}\n />\n )\n}\n\nfunction ItemContent({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"item-content\"\n className={cn(\n \"flex flex-1 flex-col gap-1 group-data-[size=xs]/item:gap-0 [&+[data-slot=item-content]]:flex-none\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction ItemTitle({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"item-title\"\n className={cn(\n \"line-clamp-1 flex w-fit items-center gap-2 text-sm leading-snug font-medium underline-offset-4\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction ItemDescription({ className, ...props }: React.ComponentProps<\"p\">) {\n return (\n <p\n data-slot=\"item-description\"\n className={cn(\n \"line-clamp-2 text-left text-sm leading-normal font-normal text-muted-foreground group-data-[size=xs]/item:text-xs [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction ItemActions({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"item-actions\"\n className={cn(\"flex items-center gap-2\", className)}\n {...props}\n />\n )\n}\n\nfunction ItemHeader({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"item-header\"\n className={cn(\n \"flex basis-full items-center justify-between gap-2\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction ItemFooter({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"item-footer\"\n className={cn(\n \"flex basis-full items-center justify-between gap-2\",\n className\n )}\n {...props}\n />\n )\n}\n\nexport {\n Item,\n ItemMedia,\n ItemContent,\n ItemActions,\n ItemGroup,\n ItemSeparator,\n ItemTitle,\n ItemDescription,\n ItemHeader,\n ItemFooter,\n}\n\n/**\n * WHEN TO USE\n * - An entity list where each row has media, text, and actions — settings\n * rows, search results, member lists, file/folder rows.\n *\n * NOT WHEN\n * - Columnar data that needs alignment across rows — use Table.\n * - A single grouped panel of content — use Card.\n * - The row is a form control (checkbox, input, radio, select) — use Field.\n *\n * KEY RULES\n * - Three sizes (default, sm, xs) and three variants (default, outline,\n * muted) — `xs` is dense enough to use inside a dropdown-menu content\n * area with zero padding.\n * - `ItemMedia variant=\"icon\"` auto-sizes any un-sized svg to `size-4`;\n * `variant=\"image\"` clips to a rounded square that shrinks with `size`.\n * - `ItemGroup` sets `role=\"list\"` and controls row gap by size — use it\n * (not a plain `div`) whenever stacking more than one Item. Item only sets\n * `role=\"listitem\"` on itself when actually rendered inside an ItemGroup\n * (detected via context) — a standalone Item outside any group stays role-less,\n * since a bare `listitem` with no `list` ancestor is its own ARIA violation.\n * - `ItemSeparator` is Separator pre-styled with `my-2` — use it between\n * rows in a group instead of a raw `<Separator />`.\n *\n * USAGE\n * <Item>\n * <ItemMedia variant=\"icon\"><FolderIcon /></ItemMedia>\n * <ItemContent>\n * <ItemTitle>Design tokens</ItemTitle>\n * <ItemDescription>Colors, radius and typography.</ItemDescription>\n * </ItemContent>\n * <ItemActions>\n * <Button variant=\"ghost\" size=\"sm\" iconOnly aria-label=\"Open\"><ChevronRightIcon /></Button>\n * </ItemActions>\n * </Item>\n *\n * <ItemGroup className=\"rounded-xl border\">\n * <Item>...</Item>\n * <ItemSeparator />\n * <Item>...</Item>\n * </ItemGroup>\n */\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,IAAM,mBAAmB,MAAM,cAAc,KAAK;AAElD,SAAS,UAAU,EAAE,WAAW,GAAG,SAAsC;CACvE,OACE,oBAAC,iBAAiB,UAAlB;EAA2B,OAAO;EAChC,UAAA,oBAAC,OAAD;GACE,MAAK;GACL,aAAU;GACV,WAAW,GACT,mGACA,SACF;GACA,GAAI;EACL,CAAA;CACwB,CAAA;AAE/B;AAEA,SAAS,cAAc,EACrB,WACA,GAAG,SACsC;CACzC,OACE,oBAAC,aAAD;EACE,aAAU;EACV,aAAY;EACZ,WAAW,GAAG,QAAQ,SAAS;EAC/B,GAAI;CACL,CAAA;AAEL;AAEA,IAAM,eAAe,IACnB,8OACA;CACE,UAAU;EACR,SAAS;GACP,SAAS;GACT,SAAS;GACT,OAAO;EACT;EACA,MAAM;GACJ,SAAS;GACT,IAAI;GACJ,IAAI;EACN;CACF;CACA,iBAAiB;EACf,SAAS;EACT,MAAM;CACR;AACF,CACF;AAEA,SAAS,KAAK,EACZ,WACA,UAAU,WACV,OAAO,WACP,UAAU,OACV,GAAG,SAEwD;CAC3D,MAAM,YAAY,MAAM,WAAW,gBAAgB;CACnD,MAAM,OAAO,UAAU,KAAK,OAAO;CACnC,OACE,oBAAC,MAAD;EACE,aAAU;EACV,gBAAc;EACd,aAAW;EACX,MAAM,YAAY,aAAa,KAAA;EAC/B,WAAW,GAAG,aAAa;GAAE;GAAS;GAAM;EAAU,CAAC,CAAC;EACxD,GAAI;CACL,CAAA;AAEL;AAEA,IAAM,oBAAoB,IACxB,kMACA;CACE,UAAU,EACR,SAAS;EACP,SAAS;EACT,MAAM;EACN,OACE;CACJ,EACF;CACA,iBAAiB,EACf,SAAS,UACX;AACF,CACF;AAEA,SAAS,UAAU,EACjB,WACA,UAAU,WACV,GAAG,SACoE;CACvE,OACE,oBAAC,OAAD;EACE,aAAU;EACV,gBAAc;EACd,WAAW,GAAG,kBAAkB;GAAE;GAAS;EAAU,CAAC,CAAC;EACvD,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,YAAY,EAAE,WAAW,GAAG,SAAsC;CACzE,OACE,oBAAC,OAAD;EACE,aAAU;EACV,WAAW,GACT,qGACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,UAAU,EAAE,WAAW,GAAG,SAAsC;CACvE,OACE,oBAAC,OAAD;EACE,aAAU;EACV,WAAW,GACT,kGACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,gBAAgB,EAAE,WAAW,GAAG,SAAoC;CAC3E,OACE,oBAAC,KAAD;EACE,aAAU;EACV,WAAW,GACT,uLACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,YAAY,EAAE,WAAW,GAAG,SAAsC;CACzE,OACE,oBAAC,OAAD;EACE,aAAU;EACV,WAAW,GAAG,2BAA2B,SAAS;EAClD,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,WAAW,EAAE,WAAW,GAAG,SAAsC;CACxE,OACE,oBAAC,OAAD;EACE,aAAU;EACV,WAAW,GACT,sDACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,WAAW,EAAE,WAAW,GAAG,SAAsC;CACxE,OACE,oBAAC,OAAD;EACE,aAAU;EACV,WAAW,GACT,sDACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kbd — inline keycap for a single key or keyboard shortcut.
|
|
3
|
+
*
|
|
4
|
+
* Plain `kbd` element; `KbdGroup` is also a `kbd`, used purely to space a
|
|
5
|
+
* chord. Includes tooltip-aware styling
|
|
6
|
+
* (`in-data-[slot=tooltip-content]:...`) so a Kbd inside a TooltipContent
|
|
7
|
+
* automatically switches to a background-tinted look instead of needing
|
|
8
|
+
* a manual className override.
|
|
9
|
+
*/
|
|
10
|
+
declare function Kbd({ className, ...props }: React.ComponentProps<"kbd">): import("react").JSX.Element;
|
|
11
|
+
declare function KbdGroup({ className, ...props }: React.ComponentProps<"div">): import("react").JSX.Element;
|
|
12
|
+
export { Kbd, KbdGroup };
|
|
13
|
+
/**
|
|
14
|
+
* WHEN TO USE
|
|
15
|
+
* - Documenting a keyboard shortcut inline, or showing the key hint on the
|
|
16
|
+
* trailing edge of a menu item / command-palette row.
|
|
17
|
+
*
|
|
18
|
+
* NOT WHEN
|
|
19
|
+
* - Code snippets or general inline monospace text — Kbd is sized and
|
|
20
|
+
* styled specifically as a keycap, not a `<code>` replacement.
|
|
21
|
+
*
|
|
22
|
+
* KEY RULES
|
|
23
|
+
* - `KbdGroup` spaces a chord (⌘K, Ctrl+Shift+P) so multiple keys read as
|
|
24
|
+
* one shortcut — use it whenever showing more than one key together.
|
|
25
|
+
* - Automatically adapts contrast when nested inside TooltipContent (via
|
|
26
|
+
* the `in-data-[slot=tooltip-content]` selector) — no manual color
|
|
27
|
+
* override needed for a Kbd shown inside a Tooltip.
|
|
28
|
+
*
|
|
29
|
+
* USAGE
|
|
30
|
+
* <KbdGroup>
|
|
31
|
+
* <Kbd>⌘</Kbd>
|
|
32
|
+
* <Kbd>K</Kbd>
|
|
33
|
+
* </KbdGroup>
|
|
34
|
+
*
|
|
35
|
+
* <KbdGroup>
|
|
36
|
+
* <Kbd>Ctrl</Kbd>
|
|
37
|
+
* <span className="text-muted-foreground">then</span>
|
|
38
|
+
* <Kbd>Esc</Kbd>
|
|
39
|
+
* </KbdGroup>
|
|
40
|
+
*/
|
|
41
|
+
//# sourceMappingURL=kbd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kbd.d.ts","sourceRoot":"","sources":["../../../src/components/ui/kbd.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,iBAAS,GAAG,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,+BAWhE;AAED,iBAAS,QAAQ,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,+BAQrE;AAED,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAA;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { cn } from "../../lib/utils.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/ui/kbd.tsx
|
|
4
|
+
/**
|
|
5
|
+
* Kbd — inline keycap for a single key or keyboard shortcut.
|
|
6
|
+
*
|
|
7
|
+
* Plain `kbd` element; `KbdGroup` is also a `kbd`, used purely to space a
|
|
8
|
+
* chord. Includes tooltip-aware styling
|
|
9
|
+
* (`in-data-[slot=tooltip-content]:...`) so a Kbd inside a TooltipContent
|
|
10
|
+
* automatically switches to a background-tinted look instead of needing
|
|
11
|
+
* a manual className override.
|
|
12
|
+
*/
|
|
13
|
+
function Kbd({ className, ...props }) {
|
|
14
|
+
return /* @__PURE__ */ jsx("kbd", {
|
|
15
|
+
"data-slot": "kbd",
|
|
16
|
+
className: cn("pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm bg-muted px-1 font-sans text-xs font-medium text-muted-foreground select-none in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background dark:in-data-[slot=tooltip-content]:bg-background/10 [&_svg:not([class*='size-'])]:size-3", className),
|
|
17
|
+
...props
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function KbdGroup({ className, ...props }) {
|
|
21
|
+
return /* @__PURE__ */ jsx("kbd", {
|
|
22
|
+
"data-slot": "kbd-group",
|
|
23
|
+
className: cn("inline-flex items-center gap-1", className),
|
|
24
|
+
...props
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* WHEN TO USE
|
|
29
|
+
* - Documenting a keyboard shortcut inline, or showing the key hint on the
|
|
30
|
+
* trailing edge of a menu item / command-palette row.
|
|
31
|
+
*
|
|
32
|
+
* NOT WHEN
|
|
33
|
+
* - Code snippets or general inline monospace text — Kbd is sized and
|
|
34
|
+
* styled specifically as a keycap, not a `<code>` replacement.
|
|
35
|
+
*
|
|
36
|
+
* KEY RULES
|
|
37
|
+
* - `KbdGroup` spaces a chord (⌘K, Ctrl+Shift+P) so multiple keys read as
|
|
38
|
+
* one shortcut — use it whenever showing more than one key together.
|
|
39
|
+
* - Automatically adapts contrast when nested inside TooltipContent (via
|
|
40
|
+
* the `in-data-[slot=tooltip-content]` selector) — no manual color
|
|
41
|
+
* override needed for a Kbd shown inside a Tooltip.
|
|
42
|
+
*
|
|
43
|
+
* USAGE
|
|
44
|
+
* <KbdGroup>
|
|
45
|
+
* <Kbd>⌘</Kbd>
|
|
46
|
+
* <Kbd>K</Kbd>
|
|
47
|
+
* </KbdGroup>
|
|
48
|
+
*
|
|
49
|
+
* <KbdGroup>
|
|
50
|
+
* <Kbd>Ctrl</Kbd>
|
|
51
|
+
* <span className="text-muted-foreground">then</span>
|
|
52
|
+
* <Kbd>Esc</Kbd>
|
|
53
|
+
* </KbdGroup>
|
|
54
|
+
*/
|
|
55
|
+
//#endregion
|
|
56
|
+
export { Kbd, KbdGroup };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=kbd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kbd.js","names":[],"sources":["../../../src/components/ui/kbd.tsx"],"sourcesContent":["/**\n * Kbd — inline keycap for a single key or keyboard shortcut.\n *\n * Plain `kbd` element; `KbdGroup` is also a `kbd`, used purely to space a\n * chord. Includes tooltip-aware styling\n * (`in-data-[slot=tooltip-content]:...`) so a Kbd inside a TooltipContent\n * automatically switches to a background-tinted look instead of needing\n * a manual className override.\n */\n\nimport { cn } from \"@/lib/utils\"\n\nfunction Kbd({ className, ...props }: React.ComponentProps<\"kbd\">) {\n return (\n <kbd\n data-slot=\"kbd\"\n className={cn(\n \"pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm bg-muted px-1 font-sans text-xs font-medium text-muted-foreground select-none in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background dark:in-data-[slot=tooltip-content]:bg-background/10 [&_svg:not([class*='size-'])]:size-3\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction KbdGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <kbd\n data-slot=\"kbd-group\"\n className={cn(\"inline-flex items-center gap-1\", className)}\n {...props}\n />\n )\n}\n\nexport { Kbd, KbdGroup }\n\n/**\n * WHEN TO USE\n * - Documenting a keyboard shortcut inline, or showing the key hint on the\n * trailing edge of a menu item / command-palette row.\n *\n * NOT WHEN\n * - Code snippets or general inline monospace text — Kbd is sized and\n * styled specifically as a keycap, not a `<code>` replacement.\n *\n * KEY RULES\n * - `KbdGroup` spaces a chord (⌘K, Ctrl+Shift+P) so multiple keys read as\n * one shortcut — use it whenever showing more than one key together.\n * - Automatically adapts contrast when nested inside TooltipContent (via\n * the `in-data-[slot=tooltip-content]` selector) — no manual color\n * override needed for a Kbd shown inside a Tooltip.\n *\n * USAGE\n * <KbdGroup>\n * <Kbd>⌘</Kbd>\n * <Kbd>K</Kbd>\n * </KbdGroup>\n *\n * <KbdGroup>\n * <Kbd>Ctrl</Kbd>\n * <span className=\"text-muted-foreground\">then</span>\n * <Kbd>Esc</Kbd>\n * </KbdGroup>\n */\n"],"mappings":";;;;;;;;;;;;AAYA,SAAS,IAAI,EAAE,WAAW,GAAG,SAAsC;CACjE,OACE,oBAAC,OAAD;EACE,aAAU;EACV,WAAW,GACT,yWACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,SAAS,EAAE,WAAW,GAAG,SAAsC;CACtE,OACE,oBAAC,OAAD;EACE,aAAU;EACV,WAAW,GAAG,kCAAkC,SAAS;EACzD,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KeyValuePair — a labelled property (key) paired with its value.
|
|
3
|
+
*
|
|
4
|
+
* `KeyValuePairKey` and
|
|
5
|
+
* `KeyValuePairValue` are plain slots inside `KeyValuePair`; `orientation`
|
|
6
|
+
* and `size` on the parent reposition/resize both via the
|
|
7
|
+
* `in-data-[orientation=...]`/`in-data-[size=...]` variants, the same
|
|
8
|
+
* ancestor-matching technique ButtonGroup already uses for its children.
|
|
9
|
+
*/
|
|
10
|
+
import * as React from "react";
|
|
11
|
+
import { type VariantProps } from "class-variance-authority";
|
|
12
|
+
declare const keyValuePairVariants: (props?: ({
|
|
13
|
+
orientation?: "horizontal" | "vertical" | null | undefined;
|
|
14
|
+
size?: "sm" | "default" | "xs" | null | undefined;
|
|
15
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
16
|
+
declare function KeyValuePair({ className, orientation, size, ...props }: React.ComponentProps<"div"> & VariantProps<typeof keyValuePairVariants>): React.JSX.Element;
|
|
17
|
+
declare function KeyValuePairKey({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
|
|
18
|
+
declare function KeyValuePairValue({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
19
|
+
declare function KeyValuePairGroup({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
20
|
+
export { KeyValuePair, KeyValuePairKey, KeyValuePairValue, KeyValuePairGroup, keyValuePairVariants, };
|
|
21
|
+
/**
|
|
22
|
+
* WHEN TO USE
|
|
23
|
+
* - Displaying structured properties — a record's fields, a summary panel,
|
|
24
|
+
* a details drawer — where each entry has a short label and a value.
|
|
25
|
+
*
|
|
26
|
+
* NOT WHEN
|
|
27
|
+
* - A form field the user edits — use Field.
|
|
28
|
+
* - Tabular data needing column alignment across many rows — use Table.
|
|
29
|
+
*
|
|
30
|
+
* KEY RULES
|
|
31
|
+
* - orientation: vertical | horizontal (default "vertical") — vertical stacks key above value
|
|
32
|
+
* (best for narrow containers or long keys); horizontal puts the key at ~40% width and the
|
|
33
|
+
* value at ~60%, for wider containers where rows should compare against each other.
|
|
34
|
+
* - size: default | sm | xs (default "default") — same vocabulary as Item/Table/Button. default
|
|
35
|
+
* and sm share text-sm, only tightening the gap between pairs; xs also drops to text-xs, for
|
|
36
|
+
* a details panel or table cell with no room to spare.
|
|
37
|
+
* - KeyValuePairValue is a plain slot — text, an icon + text, an Avatar, a Badge, a link, or a
|
|
38
|
+
* custom node all work unchanged, there's no value "type" prop to set.
|
|
39
|
+
* - Wrap multiple pairs in KeyValuePairGroup (not a plain div) for consistent row spacing.
|
|
40
|
+
* KeyValuePair only sets `role="listitem"` on itself when actually rendered inside a
|
|
41
|
+
* KeyValuePairGroup (detected via context) — standalone, it stays role-less, since a bare
|
|
42
|
+
* `listitem` with no `list` ancestor is its own ARIA violation.
|
|
43
|
+
*
|
|
44
|
+
* USAGE
|
|
45
|
+
* <KeyValuePairGroup>
|
|
46
|
+
* <KeyValuePair>
|
|
47
|
+
* <KeyValuePairKey>Status</KeyValuePairKey>
|
|
48
|
+
* <KeyValuePairValue><Badge>Active</Badge></KeyValuePairValue>
|
|
49
|
+
* </KeyValuePair>
|
|
50
|
+
* <KeyValuePair orientation="horizontal">
|
|
51
|
+
* <KeyValuePairKey>Owner</KeyValuePairKey>
|
|
52
|
+
* <KeyValuePairValue>James Wilson</KeyValuePairValue>
|
|
53
|
+
* </KeyValuePair>
|
|
54
|
+
* </KeyValuePairGroup>
|
|
55
|
+
*/
|
|
56
|
+
//# sourceMappingURL=key-value-pair.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-value-pair.d.ts","sourceRoot":"","sources":["../../../src/components/ui/key-value-pair.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAIjE,QAAA,MAAM,oBAAoB;;;8EAmBxB,CAAA;AAIF,iBAAS,YAAY,CAAC,EACpB,SAAS,EACT,WAAwB,EACxB,IAAgB,EAChB,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC,OAAO,oBAAoB,CAAC,qBAYzE;AAED,iBAAS,eAAe,CAAC,EACvB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,qBAW9B;AAED,iBAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAW7B;AAED,iBAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,qBAW7B;AAED,OAAO,EACL,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,GACrB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { cn } from "../../lib/utils.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
//#region src/components/ui/key-value-pair.tsx
|
|
6
|
+
/**
|
|
7
|
+
* KeyValuePair — a labelled property (key) paired with its value.
|
|
8
|
+
*
|
|
9
|
+
* `KeyValuePairKey` and
|
|
10
|
+
* `KeyValuePairValue` are plain slots inside `KeyValuePair`; `orientation`
|
|
11
|
+
* and `size` on the parent reposition/resize both via the
|
|
12
|
+
* `in-data-[orientation=...]`/`in-data-[size=...]` variants, the same
|
|
13
|
+
* ancestor-matching technique ButtonGroup already uses for its children.
|
|
14
|
+
*/
|
|
15
|
+
var keyValuePairVariants = cva("flex", {
|
|
16
|
+
variants: {
|
|
17
|
+
orientation: {
|
|
18
|
+
vertical: "flex-col gap-1 data-[size=xs]:gap-0.5",
|
|
19
|
+
horizontal: "flex-row items-baseline gap-4 data-[size=sm]:gap-3 data-[size=xs]:gap-2"
|
|
20
|
+
},
|
|
21
|
+
size: {
|
|
22
|
+
default: "",
|
|
23
|
+
sm: "",
|
|
24
|
+
xs: ""
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
defaultVariants: {
|
|
28
|
+
orientation: "vertical",
|
|
29
|
+
size: "default"
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
var KeyValuePairGroupContext = React.createContext(false);
|
|
33
|
+
function KeyValuePair({ className, orientation = "vertical", size = "default", ...props }) {
|
|
34
|
+
const isGrouped = React.useContext(KeyValuePairGroupContext);
|
|
35
|
+
return /* @__PURE__ */ jsx("div", {
|
|
36
|
+
"data-slot": "key-value-pair",
|
|
37
|
+
"data-orientation": orientation,
|
|
38
|
+
"data-size": size,
|
|
39
|
+
role: isGrouped ? "listitem" : void 0,
|
|
40
|
+
className: cn(keyValuePairVariants({
|
|
41
|
+
orientation,
|
|
42
|
+
size
|
|
43
|
+
}), className),
|
|
44
|
+
...props
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function KeyValuePairKey({ className, ...props }) {
|
|
48
|
+
return /* @__PURE__ */ jsx("span", {
|
|
49
|
+
"data-slot": "key-value-pair-key",
|
|
50
|
+
className: cn("min-w-0 text-sm text-muted-foreground in-data-[orientation=horizontal]:shrink-0 in-data-[orientation=horizontal]:basis-2/5 in-data-[size=xs]:text-xs", className),
|
|
51
|
+
...props
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function KeyValuePairValue({ className, ...props }) {
|
|
55
|
+
return /* @__PURE__ */ jsx("div", {
|
|
56
|
+
"data-slot": "key-value-pair-value",
|
|
57
|
+
className: cn("min-w-0 text-sm text-foreground in-data-[orientation=horizontal]:flex-1 in-data-[orientation=horizontal]:basis-3/5 in-data-[size=xs]:text-xs", className),
|
|
58
|
+
...props
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function KeyValuePairGroup({ className, ...props }) {
|
|
62
|
+
return /* @__PURE__ */ jsx(KeyValuePairGroupContext.Provider, {
|
|
63
|
+
value: true,
|
|
64
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
65
|
+
role: "list",
|
|
66
|
+
"data-slot": "key-value-pair-group",
|
|
67
|
+
className: cn("flex w-full flex-col gap-4", className),
|
|
68
|
+
...props
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* WHEN TO USE
|
|
74
|
+
* - Displaying structured properties — a record's fields, a summary panel,
|
|
75
|
+
* a details drawer — where each entry has a short label and a value.
|
|
76
|
+
*
|
|
77
|
+
* NOT WHEN
|
|
78
|
+
* - A form field the user edits — use Field.
|
|
79
|
+
* - Tabular data needing column alignment across many rows — use Table.
|
|
80
|
+
*
|
|
81
|
+
* KEY RULES
|
|
82
|
+
* - orientation: vertical | horizontal (default "vertical") — vertical stacks key above value
|
|
83
|
+
* (best for narrow containers or long keys); horizontal puts the key at ~40% width and the
|
|
84
|
+
* value at ~60%, for wider containers where rows should compare against each other.
|
|
85
|
+
* - size: default | sm | xs (default "default") — same vocabulary as Item/Table/Button. default
|
|
86
|
+
* and sm share text-sm, only tightening the gap between pairs; xs also drops to text-xs, for
|
|
87
|
+
* a details panel or table cell with no room to spare.
|
|
88
|
+
* - KeyValuePairValue is a plain slot — text, an icon + text, an Avatar, a Badge, a link, or a
|
|
89
|
+
* custom node all work unchanged, there's no value "type" prop to set.
|
|
90
|
+
* - Wrap multiple pairs in KeyValuePairGroup (not a plain div) for consistent row spacing.
|
|
91
|
+
* KeyValuePair only sets `role="listitem"` on itself when actually rendered inside a
|
|
92
|
+
* KeyValuePairGroup (detected via context) — standalone, it stays role-less, since a bare
|
|
93
|
+
* `listitem` with no `list` ancestor is its own ARIA violation.
|
|
94
|
+
*
|
|
95
|
+
* USAGE
|
|
96
|
+
* <KeyValuePairGroup>
|
|
97
|
+
* <KeyValuePair>
|
|
98
|
+
* <KeyValuePairKey>Status</KeyValuePairKey>
|
|
99
|
+
* <KeyValuePairValue><Badge>Active</Badge></KeyValuePairValue>
|
|
100
|
+
* </KeyValuePair>
|
|
101
|
+
* <KeyValuePair orientation="horizontal">
|
|
102
|
+
* <KeyValuePairKey>Owner</KeyValuePairKey>
|
|
103
|
+
* <KeyValuePairValue>James Wilson</KeyValuePairValue>
|
|
104
|
+
* </KeyValuePair>
|
|
105
|
+
* </KeyValuePairGroup>
|
|
106
|
+
*/
|
|
107
|
+
//#endregion
|
|
108
|
+
export { KeyValuePair, KeyValuePairGroup, KeyValuePairKey, KeyValuePairValue, keyValuePairVariants };
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=key-value-pair.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-value-pair.js","names":[],"sources":["../../../src/components/ui/key-value-pair.tsx"],"sourcesContent":["/**\n * KeyValuePair — a labelled property (key) paired with its value.\n *\n * `KeyValuePairKey` and\n * `KeyValuePairValue` are plain slots inside `KeyValuePair`; `orientation`\n * and `size` on the parent reposition/resize both via the\n * `in-data-[orientation=...]`/`in-data-[size=...]` variants, the same\n * ancestor-matching technique ButtonGroup already uses for its children.\n */\n\nimport * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\n\nconst keyValuePairVariants = cva(\"flex\", {\n variants: {\n orientation: {\n // Same default/sm/xs vocabulary as Item/Table: default and sm share\n // text-sm, only xs drops to text-xs — the gap step below tightens\n // one notch earlier than the text does.\n vertical: \"flex-col gap-1 data-[size=xs]:gap-0.5\",\n horizontal: \"flex-row items-baseline gap-4 data-[size=sm]:gap-3 data-[size=xs]:gap-2\",\n },\n size: {\n default: \"\",\n sm: \"\",\n xs: \"\",\n },\n },\n defaultVariants: {\n orientation: \"vertical\",\n size: \"default\",\n },\n})\n\nconst KeyValuePairGroupContext = React.createContext(false)\n\nfunction KeyValuePair({\n className,\n orientation = \"vertical\",\n size = \"default\",\n ...props\n}: React.ComponentProps<\"div\"> & VariantProps<typeof keyValuePairVariants>) {\n const isGrouped = React.useContext(KeyValuePairGroupContext)\n return (\n <div\n data-slot=\"key-value-pair\"\n data-orientation={orientation}\n data-size={size}\n role={isGrouped ? \"listitem\" : undefined}\n className={cn(keyValuePairVariants({ orientation, size }), className)}\n {...props}\n />\n )\n}\n\nfunction KeyValuePairKey({\n className,\n ...props\n}: React.ComponentProps<\"span\">) {\n return (\n <span\n data-slot=\"key-value-pair-key\"\n className={cn(\n \"min-w-0 text-sm text-muted-foreground in-data-[orientation=horizontal]:shrink-0 in-data-[orientation=horizontal]:basis-2/5 in-data-[size=xs]:text-xs\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction KeyValuePairValue({\n className,\n ...props\n}: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"key-value-pair-value\"\n className={cn(\n \"min-w-0 text-sm text-foreground in-data-[orientation=horizontal]:flex-1 in-data-[orientation=horizontal]:basis-3/5 in-data-[size=xs]:text-xs\",\n className\n )}\n {...props}\n />\n )\n}\n\nfunction KeyValuePairGroup({\n className,\n ...props\n}: React.ComponentProps<\"div\">) {\n return (\n <KeyValuePairGroupContext.Provider value={true}>\n <div\n role=\"list\"\n data-slot=\"key-value-pair-group\"\n className={cn(\"flex w-full flex-col gap-4\", className)}\n {...props}\n />\n </KeyValuePairGroupContext.Provider>\n )\n}\n\nexport {\n KeyValuePair,\n KeyValuePairKey,\n KeyValuePairValue,\n KeyValuePairGroup,\n keyValuePairVariants,\n}\n\n/**\n * WHEN TO USE\n * - Displaying structured properties — a record's fields, a summary panel,\n * a details drawer — where each entry has a short label and a value.\n *\n * NOT WHEN\n * - A form field the user edits — use Field.\n * - Tabular data needing column alignment across many rows — use Table.\n *\n * KEY RULES\n * - orientation: vertical | horizontal (default \"vertical\") — vertical stacks key above value\n * (best for narrow containers or long keys); horizontal puts the key at ~40% width and the\n * value at ~60%, for wider containers where rows should compare against each other.\n * - size: default | sm | xs (default \"default\") — same vocabulary as Item/Table/Button. default\n * and sm share text-sm, only tightening the gap between pairs; xs also drops to text-xs, for\n * a details panel or table cell with no room to spare.\n * - KeyValuePairValue is a plain slot — text, an icon + text, an Avatar, a Badge, a link, or a\n * custom node all work unchanged, there's no value \"type\" prop to set.\n * - Wrap multiple pairs in KeyValuePairGroup (not a plain div) for consistent row spacing.\n * KeyValuePair only sets `role=\"listitem\"` on itself when actually rendered inside a\n * KeyValuePairGroup (detected via context) — standalone, it stays role-less, since a bare\n * `listitem` with no `list` ancestor is its own ARIA violation.\n *\n * USAGE\n * <KeyValuePairGroup>\n * <KeyValuePair>\n * <KeyValuePairKey>Status</KeyValuePairKey>\n * <KeyValuePairValue><Badge>Active</Badge></KeyValuePairValue>\n * </KeyValuePair>\n * <KeyValuePair orientation=\"horizontal\">\n * <KeyValuePairKey>Owner</KeyValuePairKey>\n * <KeyValuePairValue>James Wilson</KeyValuePairValue>\n * </KeyValuePair>\n * </KeyValuePairGroup>\n */\n"],"mappings":";;;;;;;;;;;;;;AAeA,IAAM,uBAAuB,IAAI,QAAQ;CACvC,UAAU;EACR,aAAa;GAIX,UAAU;GACV,YAAY;EACd;EACA,MAAM;GACJ,SAAS;GACT,IAAI;GACJ,IAAI;EACN;CACF;CACA,iBAAiB;EACf,aAAa;EACb,MAAM;CACR;AACF,CAAC;AAED,IAAM,2BAA2B,MAAM,cAAc,KAAK;AAE1D,SAAS,aAAa,EACpB,WACA,cAAc,YACd,OAAO,WACP,GAAG,SACuE;CAC1E,MAAM,YAAY,MAAM,WAAW,wBAAwB;CAC3D,OACE,oBAAC,OAAD;EACE,aAAU;EACV,oBAAkB;EAClB,aAAW;EACX,MAAM,YAAY,aAAa,KAAA;EAC/B,WAAW,GAAG,qBAAqB;GAAE;GAAa;EAAK,CAAC,GAAG,SAAS;EACpE,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,gBAAgB,EACvB,WACA,GAAG,SAC4B;CAC/B,OACE,oBAAC,QAAD;EACE,aAAU;EACV,WAAW,GACT,wJACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,kBAAkB,EACzB,WACA,GAAG,SAC2B;CAC9B,OACE,oBAAC,OAAD;EACE,aAAU;EACV,WAAW,GACT,gJACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,kBAAkB,EACzB,WACA,GAAG,SAC2B;CAC9B,OACE,oBAAC,yBAAyB,UAA1B;EAAmC,OAAO;EACxC,UAAA,oBAAC,OAAD;GACE,MAAK;GACL,aAAU;GACV,WAAW,GAAG,8BAA8B,SAAS;GACrD,GAAI;EACL,CAAA;CACgC,CAAA;AAEvC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Label — accessible form control label.
|
|
3
|
+
*
|
|
4
|
+
* Dims via `group-data-[disabled=true]` when a parent group (not just its
|
|
5
|
+
* own peer control) is disabled, and via `has-disabled` when WRAPPING a
|
|
6
|
+
* disabled control —
|
|
7
|
+
* `peer-disabled` only ever matches a disabled control that's a following
|
|
8
|
+
* sibling, never one nested inside the label, which is the more common of
|
|
9
|
+
* the two documented usages below.
|
|
10
|
+
*
|
|
11
|
+
* Dims to `text-disabled-foreground`, not `opacity-50` — an opacity
|
|
12
|
+
* approach blends the label's dark text down to ~3.3:1 against a
|
|
13
|
+
* light background, failing WCAG 1.4.3's 4.5:1 text minimum (a disabled
|
|
14
|
+
* *control* is exempt from contrast rules, but this label is a separate
|
|
15
|
+
* element describing it, not the control itself, so it still needs to pass).
|
|
16
|
+
* Not `text-muted-foreground` either — that step alone doesn't read as
|
|
17
|
+
* clearly faded next to normal (near-black) label text; disabled-foreground
|
|
18
|
+
* is a dedicated, deliberately lighter token for exactly this case (see
|
|
19
|
+
* theme-tokens.css).
|
|
20
|
+
*/
|
|
21
|
+
import * as React from "react";
|
|
22
|
+
import { type VariantProps } from "class-variance-authority";
|
|
23
|
+
import { Label as LabelPrimitive } from "radix-ui";
|
|
24
|
+
declare const labelVariants: (props?: ({
|
|
25
|
+
size?: "sm" | "default" | null | undefined;
|
|
26
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
27
|
+
declare function Label({ className, size, required, optional, children, ...props }: React.ComponentProps<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants> & {
|
|
28
|
+
/** Marks the field as mandatory with a red dot after the text. Visual only — also put `required`/`aria-required` on the control. */
|
|
29
|
+
required?: boolean;
|
|
30
|
+
/** Shows a muted "(optional)" hint after the text, for forms where most fields are required and the exceptions need calling out. Mutually exclusive with `required`. */
|
|
31
|
+
optional?: boolean;
|
|
32
|
+
}): React.JSX.Element;
|
|
33
|
+
/** The required mark — a 6px destructive dot. Decorative: the control's own `required`/`aria-required` is what assistive tech reads. */
|
|
34
|
+
declare function RequiredDot({ className }: {
|
|
35
|
+
className?: string;
|
|
36
|
+
}): React.JSX.Element;
|
|
37
|
+
/** The optional mark — a muted "(optional)" after the label text. */
|
|
38
|
+
declare function OptionalHint({ className }: {
|
|
39
|
+
className?: string;
|
|
40
|
+
}): React.JSX.Element;
|
|
41
|
+
export { Label, RequiredDot, OptionalHint };
|
|
42
|
+
/**
|
|
43
|
+
* WHEN TO USE
|
|
44
|
+
* - Labelling any form control (Input, Checkbox, RadioGroupItem, Switch, ...)
|
|
45
|
+
* - Pair via `htmlFor`/`id`, or wrap the control so the whole row becomes a click target
|
|
46
|
+
* (dims automatically either way when the control is disabled)
|
|
47
|
+
*
|
|
48
|
+
* NOT WHEN
|
|
49
|
+
* - The field also needs description or error text — use Field instead, which renders its own label internally
|
|
50
|
+
*
|
|
51
|
+
* KEY RULES
|
|
52
|
+
* - `select-none` — label text is not selectable, matching native label behavior
|
|
53
|
+
* - Dims when: its own peer control is disabled (`peer-disabled:*`, sibling usage), it wraps a disabled
|
|
54
|
+
* control (`has-disabled:*`, wrapping usage), or a parent group is disabled (`group-data-[disabled=true]:*`)
|
|
55
|
+
* - `size`: "default" (text-sm) | "sm" (text-xs) — match it to the control it
|
|
56
|
+
* labels, e.g. "sm" next to a `size="sm"` Select in a dense form row.
|
|
57
|
+
* - Three states, all marked on the Label itself (never on the control or elsewhere): plain
|
|
58
|
+
* `<Label>` for an ordinary field; `<Label optional>` adds a muted "(optional)" hint, for forms
|
|
59
|
+
* where most fields are required and the exceptions need calling out; `<Label required>` adds a
|
|
60
|
+
* small red dot, for a mandatory field. Pick one convention per form — mark the required ones OR
|
|
61
|
+
* the optional ones, not both. Both marks are decorative: the control must still carry
|
|
62
|
+
* `required`/`aria-required`, which is what assistive tech announces.
|
|
63
|
+
*
|
|
64
|
+
* USAGE
|
|
65
|
+
* <Label htmlFor="email">Email</Label>
|
|
66
|
+
* <Input id="email" />
|
|
67
|
+
*
|
|
68
|
+
* <Label className="flex items-center gap-2">
|
|
69
|
+
* <Checkbox /> Accept terms
|
|
70
|
+
* </Label>
|
|
71
|
+
*
|
|
72
|
+
* <Label size="sm" htmlFor="team">Team</Label>
|
|
73
|
+
* <Select size="sm">...</Select>
|
|
74
|
+
*
|
|
75
|
+
* // Mandatory field: red dot on the label, `required` on the control
|
|
76
|
+
* <Label htmlFor="email" required>Email</Label>
|
|
77
|
+
* <Input id="email" required />
|
|
78
|
+
*
|
|
79
|
+
* // Optional field called out explicitly
|
|
80
|
+
* <Label htmlFor="nickname" optional>Nickname</Label>
|
|
81
|
+
* <Input id="nickname" />
|
|
82
|
+
*/
|
|
83
|
+
//# sourceMappingURL=label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../../../src/components/ui/label.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,KAAK,IAAI,cAAc,EAAE,MAAM,UAAU,CAAA;AAIlD,QAAA,MAAM,aAAa;;8EAalB,CAAA;AAOD,iBAAS,KAAK,CAAC,EACb,SAAS,EACT,IAAgB,EAChB,QAAgB,EAChB,QAAgB,EAChB,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,GACjD,YAAY,CAAC,OAAO,aAAa,CAAC,GAAG;IACnC,oIAAoI;IACpI,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,wKAAwK;IACxK,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,qBAcF;AAED,wIAAwI;AACxI,iBAAS,WAAW,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,qBAazD;AAED,qEAAqE;AACrE,iBAAS,YAAY,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,qBAS1D;AAED,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,CAAA;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG"}
|