@foundrykit/primitives 2.0.6 → 2.0.7
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/.turbo/turbo-build.log +233 -108
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +10 -0
- package/README.md +39 -136
- package/dist/chunk-25N35Z5M.js +42 -0
- package/dist/chunk-2JOT4DV4.js +66 -0
- package/dist/chunk-2PXD7LAX.js +172 -0
- package/dist/{chunk-VSXKLSEP.js → chunk-3BAO7TAS.js} +2 -2
- package/dist/chunk-3MEIDBWZ.js +225 -0
- package/dist/{chunk-A3U73FA7.js → chunk-3UKWAM5M.js} +2 -2
- package/dist/chunk-44I6VK3H.js +105 -0
- package/dist/chunk-46UI3AUE.js +62 -0
- package/dist/{chunk-AADRFFPH.js → chunk-5OSYIETI.js} +4 -4
- package/dist/chunk-67UXTT4O.js +116 -0
- package/dist/{chunk-J57CV3VT.js → chunk-6DRII3XC.js} +2 -2
- package/dist/chunk-727ACUWN.js +82 -0
- package/dist/chunk-76APYFRN.js +29 -0
- package/dist/chunk-AJAAMJYH.js +12 -0
- package/dist/chunk-BIFBYERK.js +69 -0
- package/dist/{chunk-PHMEWMFS.js → chunk-D4X2ZO5T.js} +7 -7
- package/dist/{chunk-UZIMC7AQ.js → chunk-DFGLEAZI.js} +2 -2
- package/dist/chunk-DKBMAFIR.js +65 -0
- package/dist/{chunk-U2EIVYWP.js → chunk-DXZ4GUQO.js} +2 -2
- package/dist/chunk-ED6T7ZZN.js +130 -0
- package/dist/{chunk-J4CRGO2P.js → chunk-EDKSYP4L.js} +2 -2
- package/dist/chunk-EEAK2RWF.js +23 -0
- package/dist/{chunk-FYCANIVJ.js → chunk-FF5D53KL.js} +2 -2
- package/dist/chunk-FIRYLO5W.js +253 -0
- package/dist/chunk-GPEL656S.js +84 -0
- package/dist/chunk-JKKCRFYB.js +36 -0
- package/dist/chunk-JTSIBZS4.js +194 -0
- package/dist/{chunk-QL4XJD7Y.js → chunk-MCXSVXO4.js} +2 -2
- package/dist/chunk-MMZJQ7RW.js +33 -0
- package/dist/{chunk-4GPFVBO2.js → chunk-MYIUX3DT.js} +3 -3
- package/dist/chunk-PAO3DSEF.js +48 -0
- package/dist/chunk-PLLG76QJ.js +32 -0
- package/dist/chunk-R3IEOV2B.js +155 -0
- package/dist/{chunk-KZMSLRLW.js → chunk-RDQF3IQE.js} +2 -2
- package/dist/{chunk-XQAJQKO7.js → chunk-SUEPE6OX.js} +3 -3
- package/dist/chunk-TA23RNS4.js +162 -0
- package/dist/chunk-TRXU4SOJ.js +224 -0
- package/dist/chunk-VA4MKQN7.js +40 -0
- package/dist/chunk-VPBVKBZ7.js +25 -0
- package/dist/{chunk-I44GXEPN.js → chunk-XVIHRZGJ.js} +1 -1
- package/dist/chunk-YT2ZIMZI.js +16 -0
- package/dist/components/accordion/index.cjs +104 -0
- package/dist/components/accordion/index.d.cts +25 -0
- package/dist/components/accordion/index.d.ts +25 -0
- package/dist/components/accordion/index.js +13 -0
- package/dist/components/alert/index.cjs +96 -0
- package/dist/components/alert/index.d.cts +28 -0
- package/dist/components/alert/index.d.ts +28 -0
- package/dist/components/alert/index.js +12 -0
- package/dist/components/alert-dialog/index.cjs +200 -0
- package/dist/components/alert-dialog/index.d.cts +42 -0
- package/dist/components/alert-dialog/index.d.ts +42 -0
- package/dist/components/alert-dialog/index.js +27 -0
- package/dist/components/aspect-ratio/index.cjs +47 -0
- package/dist/components/aspect-ratio/index.d.cts +19 -0
- package/dist/components/aspect-ratio/index.d.ts +19 -0
- package/dist/components/aspect-ratio/index.js +7 -0
- package/dist/components/avatar/index.cjs +1 -1
- package/dist/components/avatar/index.d.cts +16 -1
- package/dist/components/avatar/index.d.ts +16 -1
- package/dist/components/avatar/index.js +1 -1
- package/dist/components/badge/index.cjs +5 -5
- package/dist/components/badge/index.d.cts +13 -2
- package/dist/components/badge/index.d.ts +13 -2
- package/dist/components/badge/index.js +1 -1
- package/dist/components/breadcrumb/index.cjs +2 -2
- package/dist/components/breadcrumb/index.d.cts +19 -0
- package/dist/components/breadcrumb/index.d.ts +19 -0
- package/dist/components/breadcrumb/index.js +1 -1
- package/dist/components/button/index.cjs +18 -8
- package/dist/components/button/index.d.cts +15 -2
- package/dist/components/button/index.d.ts +15 -2
- package/dist/components/button/index.js +1 -1
- package/dist/components/button-group/index.cjs +142 -0
- package/dist/components/button-group/index.d.cts +33 -0
- package/dist/components/button-group/index.d.ts +33 -0
- package/dist/components/button-group/index.js +13 -0
- package/dist/components/card/index.cjs +2 -2
- package/dist/components/card/index.d.cts +16 -0
- package/dist/components/card/index.d.ts +16 -0
- package/dist/components/card/index.js +1 -1
- package/dist/components/checkbox/index.cjs +2 -2
- package/dist/components/checkbox/index.d.cts +11 -1
- package/dist/components/checkbox/index.d.ts +11 -1
- package/dist/components/checkbox/index.js +1 -1
- package/dist/components/collapsible/index.cjs +73 -0
- package/dist/components/collapsible/index.d.cts +22 -0
- package/dist/components/collapsible/index.d.ts +22 -0
- package/dist/components/collapsible/index.js +11 -0
- package/dist/components/context-menu/index.cjs +274 -0
- package/dist/components/context-menu/index.d.cts +48 -0
- package/dist/components/context-menu/index.d.ts +48 -0
- package/dist/components/context-menu/index.js +35 -0
- package/dist/components/direction/index.cjs +39 -0
- package/dist/components/direction/index.d.cts +20 -0
- package/dist/components/direction/index.d.ts +20 -0
- package/dist/components/direction/index.js +9 -0
- package/dist/components/drawer/index.cjs +164 -0
- package/dist/components/drawer/index.d.cts +35 -0
- package/dist/components/drawer/index.d.ts +35 -0
- package/dist/components/drawer/index.js +25 -0
- package/dist/components/dropdown/index.cjs +7 -7
- package/dist/components/dropdown/index.d.cts +25 -1
- package/dist/components/dropdown/index.d.ts +25 -1
- package/dist/components/dropdown/index.js +1 -1
- package/dist/components/empty/index.cjs +135 -0
- package/dist/components/empty/index.d.cts +38 -0
- package/dist/components/empty/index.d.ts +38 -0
- package/dist/components/empty/index.js +18 -0
- package/dist/components/field/index.cjs +269 -0
- package/dist/components/field/index.d.cts +42 -0
- package/dist/components/field/index.d.ts +42 -0
- package/dist/components/field/index.js +27 -0
- package/dist/components/hover-card/index.cjs +77 -0
- package/dist/components/hover-card/index.d.cts +22 -0
- package/dist/components/hover-card/index.d.ts +22 -0
- package/dist/components/hover-card/index.js +11 -0
- package/dist/components/input/index.cjs +2 -2
- package/dist/components/input/index.d.cts +11 -2
- package/dist/components/input/index.d.ts +11 -2
- package/dist/components/input/index.js +1 -1
- package/dist/components/item/index.cjs +262 -0
- package/dist/components/item/index.d.cts +47 -0
- package/dist/components/item/index.d.ts +47 -0
- package/dist/components/item/index.js +29 -0
- package/dist/components/kbd/index.cjs +57 -0
- package/dist/components/kbd/index.d.cts +19 -0
- package/dist/components/kbd/index.d.ts +19 -0
- package/dist/components/kbd/index.js +8 -0
- package/dist/components/label/index.cjs +2 -2
- package/dist/components/label/index.d.cts +10 -1
- package/dist/components/label/index.d.ts +10 -1
- package/dist/components/label/index.js +1 -1
- package/dist/components/menubar/index.cjs +303 -0
- package/dist/components/menubar/index.d.cts +49 -0
- package/dist/components/menubar/index.d.ts +49 -0
- package/dist/components/menubar/index.js +37 -0
- package/dist/components/native-select/index.cjs +53 -0
- package/dist/components/native-select/index.d.cts +19 -0
- package/dist/components/native-select/index.d.ts +19 -0
- package/dist/components/native-select/index.js +6 -0
- package/dist/components/navigation-menu/index.cjs +215 -0
- package/dist/components/navigation-menu/index.d.cts +37 -0
- package/dist/components/navigation-menu/index.d.ts +37 -0
- package/dist/components/navigation-menu/index.js +23 -0
- package/dist/components/popover/index.cjs +2 -2
- package/dist/components/popover/index.d.cts +14 -1
- package/dist/components/popover/index.d.ts +14 -1
- package/dist/components/popover/index.js +1 -1
- package/dist/components/progress/index.cjs +68 -0
- package/dist/components/progress/index.d.cts +16 -0
- package/dist/components/progress/index.d.ts +16 -0
- package/dist/components/progress/index.js +7 -0
- package/dist/components/radio-group/index.cjs +3 -3
- package/dist/components/radio-group/index.d.cts +15 -1
- package/dist/components/radio-group/index.d.ts +15 -1
- package/dist/components/radio-group/index.js +1 -1
- package/dist/components/resizable/index.cjs +75 -0
- package/dist/components/resizable/index.d.cts +25 -0
- package/dist/components/resizable/index.d.ts +25 -0
- package/dist/components/resizable/index.js +11 -0
- package/dist/components/scroll-area/index.cjs +3 -3
- package/dist/components/scroll-area/index.d.cts +14 -1
- package/dist/components/scroll-area/index.d.ts +14 -1
- package/dist/components/scroll-area/index.js +1 -1
- package/dist/components/select/index.cjs +4 -4
- package/dist/components/select/index.d.cts +19 -1
- package/dist/components/select/index.d.ts +19 -1
- package/dist/components/select/index.js +1 -1
- package/dist/components/separator/index.cjs +2 -2
- package/dist/components/separator/index.d.cts +12 -1
- package/dist/components/separator/index.d.ts +12 -1
- package/dist/components/separator/index.js +1 -1
- package/dist/components/skeleton/index.d.cts +9 -0
- package/dist/components/skeleton/index.d.ts +9 -0
- package/dist/components/slider/index.cjs +100 -0
- package/dist/components/slider/index.d.cts +18 -0
- package/dist/components/slider/index.d.ts +18 -0
- package/dist/components/slider/index.js +7 -0
- package/dist/components/sonner/index.cjs +51 -0
- package/dist/components/sonner/index.d.cts +18 -0
- package/dist/components/sonner/index.d.ts +18 -0
- package/dist/components/sonner/index.js +9 -0
- package/dist/components/spinner/index.cjs +47 -0
- package/dist/components/spinner/index.d.cts +17 -0
- package/dist/components/spinner/index.d.ts +17 -0
- package/dist/components/spinner/index.js +6 -0
- package/dist/components/switch/index.cjs +2 -2
- package/dist/components/switch/index.d.cts +11 -1
- package/dist/components/switch/index.d.ts +11 -1
- package/dist/components/switch/index.js +1 -1
- package/dist/components/table/index.cjs +147 -0
- package/dist/components/table/index.d.cts +35 -0
- package/dist/components/table/index.d.ts +35 -0
- package/dist/components/table/index.js +20 -0
- package/dist/components/tabs/index.cjs +2 -2
- package/dist/components/tabs/index.d.cts +18 -1
- package/dist/components/tabs/index.d.ts +18 -1
- package/dist/components/tabs/index.js +1 -1
- package/dist/components/textarea/index.cjs +1 -1
- package/dist/components/textarea/index.d.cts +9 -0
- package/dist/components/textarea/index.d.ts +9 -0
- package/dist/components/textarea/index.js +1 -1
- package/dist/components/toggle-group/index.cjs +120 -0
- package/dist/components/toggle-group/index.d.cts +27 -0
- package/dist/components/toggle-group/index.d.ts +27 -0
- package/dist/components/toggle-group/index.js +9 -0
- package/dist/components/typography/index.cjs +197 -0
- package/dist/components/typography/index.d.cts +28 -0
- package/dist/components/typography/index.d.ts +28 -0
- package/dist/components/typography/index.js +28 -0
- package/dist/index.cjs +3272 -781
- package/dist/index.d.cts +128 -24
- package/dist/index.d.ts +128 -24
- package/dist/index.js +485 -144
- package/package.json +25 -8
- package/postcss.config.mjs +1 -1
- package/registry.json +18 -5
- package/src/components/accordion/config.ts +28 -0
- package/src/components/accordion/index.tsx +80 -0
- package/src/components/alert/config.ts +40 -0
- package/src/components/alert/index.tsx +80 -0
- package/src/components/alert-dialog/config.ts +28 -0
- package/src/components/alert-dialog/index.tsx +188 -0
- package/src/components/aspect-ratio/config.ts +27 -0
- package/src/components/aspect-ratio/index.tsx +24 -0
- package/src/components/avatar/config.ts +1 -1
- package/src/components/avatar/index.tsx +18 -4
- package/src/components/badge/config.ts +1 -1
- package/src/components/badge/index.tsx +17 -7
- package/src/components/breadcrumb/config.ts +1 -1
- package/src/components/breadcrumb/index.tsx +24 -6
- package/src/components/button/config.ts +21 -1
- package/src/components/button/index.tsx +33 -9
- package/src/components/button-group/config.ts +39 -0
- package/src/components/button-group/index.tsx +99 -0
- package/src/components/card/config.ts +1 -1
- package/src/components/card/index.tsx +21 -6
- package/src/components/checkbox/config.ts +1 -1
- package/src/components/checkbox/index.tsx +13 -4
- package/src/components/collapsible/config.ts +27 -0
- package/src/components/collapsible/index.tsx +47 -0
- package/src/components/context-menu/config.ts +28 -0
- package/src/components/context-menu/index.tsx +271 -0
- package/src/components/dialog/config.ts +1 -1
- package/src/components/dialog/index.tsx +25 -6
- package/src/components/direction/config.ts +28 -0
- package/src/components/direction/index.tsx +27 -0
- package/src/components/drawer/config.ts +28 -0
- package/src/components/drawer/index.tsx +153 -0
- package/src/components/dropdown/config.ts +1 -1
- package/src/components/dropdown/index.tsx +37 -14
- package/src/components/empty/config.ts +38 -0
- package/src/components/empty/index.tsx +127 -0
- package/src/components/field/config.ts +40 -0
- package/src/components/field/index.tsx +252 -0
- package/src/components/hover-card/config.ts +27 -0
- package/src/components/hover-card/index.tsx +56 -0
- package/src/components/input/config.ts +1 -1
- package/src/components/input/index.tsx +13 -5
- package/src/components/input-group/index.tsx +33 -12
- package/src/components/item/config.ts +52 -0
- package/src/components/item/index.tsx +215 -0
- package/src/components/kbd/config.ts +38 -0
- package/src/components/kbd/index.tsx +40 -0
- package/src/components/label/config.ts +1 -1
- package/src/components/label/index.tsx +12 -4
- package/src/components/menubar/config.ts +28 -0
- package/src/components/menubar/index.tsx +295 -0
- package/src/components/native-select/config.ts +40 -0
- package/src/components/native-select/index.tsx +40 -0
- package/src/components/navigation-menu/config.ts +32 -0
- package/src/components/navigation-menu/index.tsx +188 -0
- package/src/components/popover/config.ts +1 -1
- package/src/components/popover/index.tsx +17 -5
- package/src/components/progress/config.ts +42 -0
- package/src/components/progress/index.tsx +39 -0
- package/src/components/radio-group/config.ts +1 -1
- package/src/components/radio-group/index.tsx +18 -5
- package/src/components/resizable/config.ts +28 -0
- package/src/components/resizable/index.tsx +67 -0
- package/src/components/scroll-area/index.tsx +17 -5
- package/src/components/select/config.ts +1 -1
- package/src/components/select/index.tsx +23 -6
- package/src/components/separator/config.ts +1 -1
- package/src/components/separator/index.tsx +14 -4
- package/src/components/sheet/index.tsx +21 -7
- package/src/components/skeleton/config.ts +1 -1
- package/src/components/skeleton/index.tsx +9 -0
- package/src/components/slider/config.ts +46 -0
- package/src/components/slider/index.tsx +73 -0
- package/src/components/sonner/config.ts +27 -0
- package/src/components/sonner/index.tsx +37 -0
- package/src/components/spinner/config.ts +40 -0
- package/src/components/spinner/index.tsx +30 -0
- package/src/components/switch/config.ts +1 -1
- package/src/components/switch/index.tsx +13 -4
- package/src/components/table/config.ts +38 -0
- package/src/components/table/index.tsx +135 -0
- package/src/components/tabs/config.ts +1 -1
- package/src/components/tabs/index.tsx +21 -5
- package/src/components/textarea/config.ts +1 -1
- package/src/components/textarea/index.tsx +11 -3
- package/src/components/toggle/index.tsx +20 -8
- package/src/components/toggle-group/config.ts +46 -0
- package/src/components/toggle-group/index.tsx +106 -0
- package/src/components/tooltip/index.tsx +19 -5
- package/src/components/typography/config.ts +38 -0
- package/src/components/typography/index.tsx +172 -0
- package/src/index.ts +239 -53
- package/tsup.config.ts +25 -0
- package/dist/chunk-FUWID6MC.js +0 -42
- package/dist/chunk-YTUI6MCB.js +0 -52
- package/eslint.config.js +0 -4
- package/dist/{chunk-VVNIYCKH.js → chunk-3TZXV53R.js} +1 -1
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { cn } from '@foundrykit/utils';
|
|
4
4
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
5
5
|
import { CheckIcon, ChevronRightIcon, CircleIcon } from 'lucide-react';
|
|
6
|
+
import type * as React from 'react';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Dropdown menu root built on Radix `DropdownMenu.Root`. Compose with
|
|
10
|
+
* {@link DropdownMenuTrigger}, {@link DropdownMenuContent} and items such as
|
|
11
|
+
* {@link DropdownMenuItem}, {@link DropdownMenuCheckboxItem},
|
|
12
|
+
* {@link DropdownMenuRadioItem}, {@link DropdownMenuLabel},
|
|
13
|
+
* {@link DropdownMenuSeparator}, {@link DropdownMenuShortcut} and submenus
|
|
14
|
+
* ({@link DropdownMenuSub}, {@link DropdownMenuSubTrigger},
|
|
15
|
+
* {@link DropdownMenuSubContent}).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* <DropdownMenu>
|
|
20
|
+
* <DropdownMenuTrigger>Open</DropdownMenuTrigger>
|
|
21
|
+
* <DropdownMenuContent>
|
|
22
|
+
* <DropdownMenuItem>Edit</DropdownMenuItem>
|
|
23
|
+
* <DropdownMenuItem variant="destructive">Delete</DropdownMenuItem>
|
|
24
|
+
* </DropdownMenuContent>
|
|
25
|
+
* </DropdownMenu>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
9
28
|
function DropdownMenu({
|
|
10
29
|
...props
|
|
11
30
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
|
@@ -42,7 +61,7 @@ function DropdownMenuContent({
|
|
|
42
61
|
data-slot='dropdown-menu-content'
|
|
43
62
|
sideOffset={sideOffset}
|
|
44
63
|
className={cn(
|
|
45
|
-
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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 max-h-(--radix-dropdown-menu-content-available-height) origin-(--radix-dropdown-menu-content-transform-origin)
|
|
64
|
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md',
|
|
46
65
|
className
|
|
47
66
|
)}
|
|
48
67
|
{...props}
|
|
@@ -59,6 +78,10 @@ function DropdownMenuGroup({
|
|
|
59
78
|
);
|
|
60
79
|
}
|
|
61
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Selectable menu item. Use `variant="destructive"` for dangerous actions and
|
|
83
|
+
* `inset` to align text with items that have leading icons.
|
|
84
|
+
*/
|
|
62
85
|
function DropdownMenuItem({
|
|
63
86
|
className,
|
|
64
87
|
inset,
|
|
@@ -74,7 +97,7 @@ function DropdownMenuItem({
|
|
|
74
97
|
data-inset={inset}
|
|
75
98
|
data-variant={variant}
|
|
76
99
|
className={cn(
|
|
77
|
-
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground
|
|
100
|
+
"focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
78
101
|
className
|
|
79
102
|
)}
|
|
80
103
|
{...props}
|
|
@@ -92,7 +115,7 @@ function DropdownMenuCheckboxItem({
|
|
|
92
115
|
<DropdownMenuPrimitive.CheckboxItem
|
|
93
116
|
data-slot='dropdown-menu-checkbox-item'
|
|
94
117
|
className={cn(
|
|
95
|
-
"focus:bg-accent focus:text-accent-foreground
|
|
118
|
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
96
119
|
className
|
|
97
120
|
)}
|
|
98
121
|
checked={checked}
|
|
@@ -128,7 +151,7 @@ function DropdownMenuRadioItem({
|
|
|
128
151
|
<DropdownMenuPrimitive.RadioItem
|
|
129
152
|
data-slot='dropdown-menu-radio-item'
|
|
130
153
|
className={cn(
|
|
131
|
-
"focus:bg-accent focus:text-accent-foreground
|
|
154
|
+
"focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
132
155
|
className
|
|
133
156
|
)}
|
|
134
157
|
{...props}
|
|
@@ -211,7 +234,7 @@ function DropdownMenuSubTrigger({
|
|
|
211
234
|
data-slot='dropdown-menu-sub-trigger'
|
|
212
235
|
data-inset={inset}
|
|
213
236
|
className={cn(
|
|
214
|
-
'focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground
|
|
237
|
+
'focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8',
|
|
215
238
|
className
|
|
216
239
|
)}
|
|
217
240
|
{...props}
|
|
@@ -230,7 +253,7 @@ function DropdownMenuSubContent({
|
|
|
230
253
|
<DropdownMenuPrimitive.SubContent
|
|
231
254
|
data-slot='dropdown-menu-sub-content'
|
|
232
255
|
className={cn(
|
|
233
|
-
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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 origin-(--radix-dropdown-menu-content-transform-origin)
|
|
256
|
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg',
|
|
234
257
|
className
|
|
235
258
|
)}
|
|
236
259
|
{...props}
|
|
@@ -240,18 +263,18 @@ function DropdownMenuSubContent({
|
|
|
240
263
|
|
|
241
264
|
export {
|
|
242
265
|
DropdownMenu,
|
|
243
|
-
|
|
244
|
-
DropdownMenuTrigger,
|
|
266
|
+
DropdownMenuCheckboxItem,
|
|
245
267
|
DropdownMenuContent,
|
|
246
268
|
DropdownMenuGroup,
|
|
247
|
-
DropdownMenuLabel,
|
|
248
269
|
DropdownMenuItem,
|
|
249
|
-
|
|
270
|
+
DropdownMenuLabel,
|
|
271
|
+
DropdownMenuPortal,
|
|
250
272
|
DropdownMenuRadioGroup,
|
|
251
273
|
DropdownMenuRadioItem,
|
|
252
274
|
DropdownMenuSeparator,
|
|
253
275
|
DropdownMenuShortcut,
|
|
254
276
|
DropdownMenuSub,
|
|
255
|
-
DropdownMenuSubTrigger,
|
|
256
277
|
DropdownMenuSubContent,
|
|
278
|
+
DropdownMenuSubTrigger,
|
|
279
|
+
DropdownMenuTrigger,
|
|
257
280
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const EmptyConfig: ComponentConfig = {
|
|
4
|
+
name: 'Empty',
|
|
5
|
+
description:
|
|
6
|
+
'An empty-state component for communicating that there is no content to display.',
|
|
7
|
+
category: 'primitives',
|
|
8
|
+
tags: ['empty', 'placeholder', 'feedback'],
|
|
9
|
+
preview: {
|
|
10
|
+
type: 'static',
|
|
11
|
+
html: '<div class="flex h-24 w-full flex-col items-center justify-center gap-2 rounded-md border border-dashed border-gray-300 bg-gray-100"><div class="h-8 w-8 rounded-lg bg-gray-300"></div><div class="h-2 w-24 rounded bg-gray-400"></div></div>',
|
|
12
|
+
},
|
|
13
|
+
variants: [
|
|
14
|
+
{
|
|
15
|
+
name: 'Default',
|
|
16
|
+
description: 'Default empty state',
|
|
17
|
+
code: '<Empty><EmptyHeader><EmptyTitle>No results</EmptyTitle><EmptyDescription>Try a different search.</EmptyDescription></EmptyHeader></Empty>',
|
|
18
|
+
preview: {
|
|
19
|
+
type: 'component',
|
|
20
|
+
component: 'Empty',
|
|
21
|
+
props: {},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'With Icon',
|
|
26
|
+
description: 'Empty state with an icon media',
|
|
27
|
+
code: '<Empty><EmptyHeader><EmptyMedia variant="icon"><InboxIcon /></EmptyMedia><EmptyTitle>No messages</EmptyTitle></EmptyHeader></Empty>',
|
|
28
|
+
preview: {
|
|
29
|
+
type: 'component',
|
|
30
|
+
component: 'Empty',
|
|
31
|
+
props: {},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
dependencies: ['utils'],
|
|
36
|
+
packageDependencies: ['class-variance-authority'],
|
|
37
|
+
files: ['components/primitives/empty/index.tsx'],
|
|
38
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { cn } from '@foundrykit/utils';
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import type * as React from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Empty-state container for communicating that there is no content to show.
|
|
7
|
+
* Compose with {@link EmptyHeader}, {@link EmptyMedia}, {@link EmptyTitle},
|
|
8
|
+
* {@link EmptyDescription} and {@link EmptyContent} to build a centered,
|
|
9
|
+
* illustrated message with optional actions.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <Empty>
|
|
14
|
+
* <EmptyHeader>
|
|
15
|
+
* <EmptyMedia variant="icon">
|
|
16
|
+
* <InboxIcon />
|
|
17
|
+
* </EmptyMedia>
|
|
18
|
+
* <EmptyTitle>No messages</EmptyTitle>
|
|
19
|
+
* <EmptyDescription>You're all caught up.</EmptyDescription>
|
|
20
|
+
* </EmptyHeader>
|
|
21
|
+
* <EmptyContent>
|
|
22
|
+
* <Button>Refresh</Button>
|
|
23
|
+
* </EmptyContent>
|
|
24
|
+
* </Empty>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
function Empty({ className, ...props }: React.ComponentProps<'div'>) {
|
|
28
|
+
return (
|
|
29
|
+
<div
|
|
30
|
+
data-slot='empty'
|
|
31
|
+
className={cn(
|
|
32
|
+
'flex min-w-0 flex-1 flex-col items-center justify-center gap-6 rounded-lg border-dashed p-6 text-center text-balance md:p-12',
|
|
33
|
+
className
|
|
34
|
+
)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function EmptyHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
data-slot='empty-header'
|
|
44
|
+
className={cn(
|
|
45
|
+
'flex max-w-sm flex-col items-center gap-2 text-center',
|
|
46
|
+
className
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const emptyMediaVariants = cva(
|
|
54
|
+
'mb-2 flex shrink-0 items-center justify-center [&_svg:not([class*=size-])]:size-6',
|
|
55
|
+
{
|
|
56
|
+
variants: {
|
|
57
|
+
variant: {
|
|
58
|
+
default: 'bg-transparent',
|
|
59
|
+
icon: 'bg-muted text-foreground flex size-10 shrink-0 items-center justify-center rounded-lg [&_svg:not([class*=size-])]:size-6',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
defaultVariants: {
|
|
63
|
+
variant: 'default',
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
function EmptyMedia({
|
|
69
|
+
className,
|
|
70
|
+
variant,
|
|
71
|
+
...props
|
|
72
|
+
}: React.ComponentProps<'div'> & VariantProps<typeof emptyMediaVariants>) {
|
|
73
|
+
return (
|
|
74
|
+
<div
|
|
75
|
+
data-slot='empty-media'
|
|
76
|
+
data-variant={variant}
|
|
77
|
+
className={cn(emptyMediaVariants({ variant }), className)}
|
|
78
|
+
{...props}
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function EmptyTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
|
84
|
+
return (
|
|
85
|
+
<div
|
|
86
|
+
data-slot='empty-title'
|
|
87
|
+
className={cn('text-lg font-medium tracking-tight', className)}
|
|
88
|
+
{...props}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function EmptyDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
|
94
|
+
return (
|
|
95
|
+
<p
|
|
96
|
+
data-slot='empty-description'
|
|
97
|
+
className={cn(
|
|
98
|
+
'text-muted-foreground [&>a:hover]:text-primary text-sm/relaxed [&>a]:underline [&>a]:underline-offset-4',
|
|
99
|
+
className
|
|
100
|
+
)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function EmptyContent({ className, ...props }: React.ComponentProps<'div'>) {
|
|
107
|
+
return (
|
|
108
|
+
<div
|
|
109
|
+
data-slot='empty-content'
|
|
110
|
+
className={cn(
|
|
111
|
+
'flex w-full max-w-sm min-w-0 flex-col items-center gap-4 text-sm text-balance',
|
|
112
|
+
className
|
|
113
|
+
)}
|
|
114
|
+
{...props}
|
|
115
|
+
/>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export {
|
|
120
|
+
Empty,
|
|
121
|
+
EmptyContent,
|
|
122
|
+
EmptyDescription,
|
|
123
|
+
EmptyHeader,
|
|
124
|
+
EmptyMedia,
|
|
125
|
+
EmptyTitle,
|
|
126
|
+
emptyMediaVariants,
|
|
127
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const FieldConfig: ComponentConfig = {
|
|
4
|
+
name: 'Field',
|
|
5
|
+
description:
|
|
6
|
+
'A composable set of primitives for building accessible form fields.',
|
|
7
|
+
category: 'primitives',
|
|
8
|
+
tags: ['field', 'form', 'label', 'input', 'validation'],
|
|
9
|
+
preview: {
|
|
10
|
+
type: 'static',
|
|
11
|
+
html: '<div class="flex w-full flex-col gap-1.5 rounded-md border border-gray-300 bg-gray-50 p-3"><div class="h-2 w-16 rounded bg-gray-400"></div><div class="h-8 w-full rounded-md border border-gray-300 bg-white"></div><div class="h-2 w-28 rounded bg-gray-300"></div></div>',
|
|
12
|
+
},
|
|
13
|
+
variants: [
|
|
14
|
+
{
|
|
15
|
+
name: 'Vertical',
|
|
16
|
+
description: 'Default vertical field',
|
|
17
|
+
code: '<Field><FieldLabel>Email</FieldLabel><input /></Field>',
|
|
18
|
+
preview: {
|
|
19
|
+
type: 'component',
|
|
20
|
+
component: 'Field',
|
|
21
|
+
props: {},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'Horizontal',
|
|
26
|
+
description: 'Horizontal field layout',
|
|
27
|
+
code: '<Field orientation="horizontal">...</Field>',
|
|
28
|
+
preview: {
|
|
29
|
+
type: 'component',
|
|
30
|
+
component: 'Field',
|
|
31
|
+
props: {
|
|
32
|
+
orientation: 'horizontal',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
dependencies: ['utils'],
|
|
38
|
+
packageDependencies: ['@radix-ui/react-label', 'class-variance-authority'],
|
|
39
|
+
files: ['components/primitives/field/index.tsx'],
|
|
40
|
+
};
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@foundrykit/utils';
|
|
4
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
5
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Field is a composable form-layout primitive. Group related controls with
|
|
10
|
+
* {@link FieldGroup}/{@link FieldSet}, then wrap each control in a {@link Field}
|
|
11
|
+
* alongside {@link FieldLabel}, {@link FieldDescription} and {@link FieldError}
|
|
12
|
+
* to get consistent spacing, orientation and validation styling.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <Field>
|
|
17
|
+
* <FieldLabel htmlFor="email">Email</FieldLabel>
|
|
18
|
+
* <input id="email" type="email" />
|
|
19
|
+
* <FieldDescription>We'll never share your email.</FieldDescription>
|
|
20
|
+
* </Field>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
const fieldVariants = cva(
|
|
24
|
+
'group/field data-[invalid=true]:text-destructive flex w-full gap-3',
|
|
25
|
+
{
|
|
26
|
+
variants: {
|
|
27
|
+
orientation: {
|
|
28
|
+
vertical: ['flex-col [&>*]:w-full [&>.sr-only]:w-auto'],
|
|
29
|
+
horizontal: [
|
|
30
|
+
'flex-row items-center',
|
|
31
|
+
'[&>[data-slot=field-label]]:flex-auto',
|
|
32
|
+
'has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox]]:mt-px has-[>[data-slot=field-content]]:[&>[role=radio]]:mt-px',
|
|
33
|
+
],
|
|
34
|
+
responsive: [
|
|
35
|
+
'flex-col @md/field-group:flex-row @md/field-group:items-center [&>*]:w-full @md/field-group:[&>*]:w-auto [&>.sr-only]:w-auto',
|
|
36
|
+
'@md/field-group:[&>[data-slot=field-label]]:flex-auto',
|
|
37
|
+
'@md/field-group:has-[>[data-slot=field-content]]:items-start',
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
defaultVariants: {
|
|
42
|
+
orientation: 'vertical',
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
function Field({
|
|
48
|
+
className,
|
|
49
|
+
orientation = 'vertical',
|
|
50
|
+
...props
|
|
51
|
+
}: React.ComponentProps<'div'> & VariantProps<typeof fieldVariants>) {
|
|
52
|
+
return (
|
|
53
|
+
<div
|
|
54
|
+
role='group'
|
|
55
|
+
data-slot='field'
|
|
56
|
+
data-orientation={orientation}
|
|
57
|
+
className={cn(fieldVariants({ orientation }), className)}
|
|
58
|
+
{...props}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function FieldSet({ className, ...props }: React.ComponentProps<'fieldset'>) {
|
|
64
|
+
return (
|
|
65
|
+
<fieldset
|
|
66
|
+
data-slot='field-set'
|
|
67
|
+
className={cn(
|
|
68
|
+
'flex flex-col gap-6',
|
|
69
|
+
'has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',
|
|
70
|
+
className
|
|
71
|
+
)}
|
|
72
|
+
{...props}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function FieldLegend({
|
|
78
|
+
className,
|
|
79
|
+
variant = 'legend',
|
|
80
|
+
...props
|
|
81
|
+
}: React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }) {
|
|
82
|
+
return (
|
|
83
|
+
<legend
|
|
84
|
+
data-slot='field-legend'
|
|
85
|
+
data-variant={variant}
|
|
86
|
+
className={cn(
|
|
87
|
+
'mb-3 font-medium',
|
|
88
|
+
'data-[variant=legend]:text-base',
|
|
89
|
+
'data-[variant=label]:text-sm',
|
|
90
|
+
className
|
|
91
|
+
)}
|
|
92
|
+
{...props}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function FieldGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
|
98
|
+
return (
|
|
99
|
+
<div
|
|
100
|
+
data-slot='field-group'
|
|
101
|
+
className={cn(
|
|
102
|
+
'group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4',
|
|
103
|
+
className
|
|
104
|
+
)}
|
|
105
|
+
{...props}
|
|
106
|
+
/>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function FieldContent({ className, ...props }: React.ComponentProps<'div'>) {
|
|
111
|
+
return (
|
|
112
|
+
<div
|
|
113
|
+
data-slot='field-content'
|
|
114
|
+
className={cn(
|
|
115
|
+
'group/field-content flex flex-1 flex-col gap-1.5 leading-snug',
|
|
116
|
+
className
|
|
117
|
+
)}
|
|
118
|
+
{...props}
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function FieldLabel({
|
|
124
|
+
className,
|
|
125
|
+
...props
|
|
126
|
+
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
|
|
127
|
+
return (
|
|
128
|
+
<LabelPrimitive.Root
|
|
129
|
+
data-slot='field-label'
|
|
130
|
+
className={cn(
|
|
131
|
+
'group/field-label peer/field-label flex w-fit gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50',
|
|
132
|
+
'has-[[data-slot=field]]:w-full has-[[data-slot=field]]:flex-col has-[[data-slot=field]]:rounded-md has-[[data-slot=field]]:border',
|
|
133
|
+
className
|
|
134
|
+
)}
|
|
135
|
+
{...props}
|
|
136
|
+
/>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function FieldTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
|
141
|
+
return (
|
|
142
|
+
<div
|
|
143
|
+
data-slot='field-title'
|
|
144
|
+
className={cn(
|
|
145
|
+
'flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50',
|
|
146
|
+
className
|
|
147
|
+
)}
|
|
148
|
+
{...props}
|
|
149
|
+
/>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function FieldDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
|
154
|
+
return (
|
|
155
|
+
<p
|
|
156
|
+
data-slot='field-description'
|
|
157
|
+
className={cn(
|
|
158
|
+
'text-muted-foreground text-sm leading-normal font-normal group-has-[[data-orientation=horizontal]]/field:text-balance',
|
|
159
|
+
'last:mt-0 [[data-variant=legend]+&]:-mt-1.5',
|
|
160
|
+
'[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4',
|
|
161
|
+
className
|
|
162
|
+
)}
|
|
163
|
+
{...props}
|
|
164
|
+
/>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function FieldSeparator({
|
|
169
|
+
children,
|
|
170
|
+
className,
|
|
171
|
+
...props
|
|
172
|
+
}: React.ComponentProps<'div'>) {
|
|
173
|
+
return (
|
|
174
|
+
<div
|
|
175
|
+
data-slot='field-separator'
|
|
176
|
+
data-content={!!children}
|
|
177
|
+
className={cn('relative -my-2 h-5 text-sm', className)}
|
|
178
|
+
{...props}
|
|
179
|
+
>
|
|
180
|
+
<div className='bg-border absolute inset-0 top-1/2 h-px' />
|
|
181
|
+
{children && (
|
|
182
|
+
<span
|
|
183
|
+
className='bg-background text-muted-foreground relative mx-auto block w-fit px-2'
|
|
184
|
+
data-slot='field-separator-content'
|
|
185
|
+
>
|
|
186
|
+
{children}
|
|
187
|
+
</span>
|
|
188
|
+
)}
|
|
189
|
+
</div>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function FieldError({
|
|
194
|
+
className,
|
|
195
|
+
children,
|
|
196
|
+
errors,
|
|
197
|
+
...props
|
|
198
|
+
}: React.ComponentProps<'div'> & {
|
|
199
|
+
errors?: Array<{ message?: string } | undefined>;
|
|
200
|
+
}) {
|
|
201
|
+
const content = React.useMemo(() => {
|
|
202
|
+
if (children) {
|
|
203
|
+
return children;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (!errors) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (errors.length === 1 && errors[0]?.message) {
|
|
211
|
+
return errors[0].message;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return (
|
|
215
|
+
<ul className='ml-4 flex list-disc flex-col gap-1'>
|
|
216
|
+
{errors.map(
|
|
217
|
+
(error, index) =>
|
|
218
|
+
error?.message && <li key={index}>{error.message}</li>
|
|
219
|
+
)}
|
|
220
|
+
</ul>
|
|
221
|
+
);
|
|
222
|
+
}, [children, errors]);
|
|
223
|
+
|
|
224
|
+
if (!content) {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
<div
|
|
230
|
+
role='alert'
|
|
231
|
+
data-slot='field-error'
|
|
232
|
+
className={cn('text-destructive text-sm font-normal', className)}
|
|
233
|
+
{...props}
|
|
234
|
+
>
|
|
235
|
+
{content}
|
|
236
|
+
</div>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export {
|
|
241
|
+
Field,
|
|
242
|
+
FieldContent,
|
|
243
|
+
FieldDescription,
|
|
244
|
+
FieldError,
|
|
245
|
+
FieldGroup,
|
|
246
|
+
FieldLabel,
|
|
247
|
+
FieldLegend,
|
|
248
|
+
FieldSeparator,
|
|
249
|
+
FieldSet,
|
|
250
|
+
FieldTitle,
|
|
251
|
+
fieldVariants,
|
|
252
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const HoverCardConfig: ComponentConfig = {
|
|
4
|
+
name: 'Hover Card',
|
|
5
|
+
description: 'For sighted users to preview content available behind a link.',
|
|
6
|
+
category: 'primitives',
|
|
7
|
+
tags: ['hover-card', 'overlay', 'popover', 'interactive'],
|
|
8
|
+
preview: {
|
|
9
|
+
type: 'static',
|
|
10
|
+
html: '<div class="flex h-12 w-full items-center rounded-md border border-gray-300 bg-gray-100 px-3"><span class="text-sm text-gray-600">Hover Card</span></div>',
|
|
11
|
+
},
|
|
12
|
+
variants: [
|
|
13
|
+
{
|
|
14
|
+
name: 'Default',
|
|
15
|
+
description: 'Default hover card',
|
|
16
|
+
code: '<HoverCard>...</HoverCard>',
|
|
17
|
+
preview: {
|
|
18
|
+
type: 'component',
|
|
19
|
+
component: 'HoverCard',
|
|
20
|
+
props: {},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
dependencies: ['utils'],
|
|
25
|
+
packageDependencies: ['@radix-ui/react-hover-card'],
|
|
26
|
+
files: ['components/primitives/hover-card/index.tsx'],
|
|
27
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@foundrykit/utils';
|
|
4
|
+
import * as HoverCardPrimitive from '@radix-ui/react-hover-card';
|
|
5
|
+
import type * as React from 'react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Hover card root built on Radix `HoverCard.Root` for sighted users to preview
|
|
9
|
+
* content available behind a link. Compose with {@link HoverCardTrigger} and
|
|
10
|
+
* {@link HoverCardContent}.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <HoverCard>
|
|
15
|
+
* <HoverCardTrigger>@nextjs</HoverCardTrigger>
|
|
16
|
+
* <HoverCardContent>The React Framework.</HoverCardContent>
|
|
17
|
+
* </HoverCard>
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
function HoverCard({
|
|
21
|
+
...props
|
|
22
|
+
}: React.ComponentProps<typeof HoverCardPrimitive.Root>) {
|
|
23
|
+
return <HoverCardPrimitive.Root data-slot='hover-card' {...props} />;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function HoverCardTrigger({
|
|
27
|
+
...props
|
|
28
|
+
}: React.ComponentProps<typeof HoverCardPrimitive.Trigger>) {
|
|
29
|
+
return (
|
|
30
|
+
<HoverCardPrimitive.Trigger data-slot='hover-card-trigger' {...props} />
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function HoverCardContent({
|
|
35
|
+
className,
|
|
36
|
+
align = 'center',
|
|
37
|
+
sideOffset = 4,
|
|
38
|
+
...props
|
|
39
|
+
}: React.ComponentProps<typeof HoverCardPrimitive.Content>) {
|
|
40
|
+
return (
|
|
41
|
+
<HoverCardPrimitive.Portal data-slot='hover-card-portal'>
|
|
42
|
+
<HoverCardPrimitive.Content
|
|
43
|
+
data-slot='hover-card-content'
|
|
44
|
+
align={align}
|
|
45
|
+
sideOffset={sideOffset}
|
|
46
|
+
className={cn(
|
|
47
|
+
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden',
|
|
48
|
+
className
|
|
49
|
+
)}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
</HoverCardPrimitive.Portal>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { HoverCard, HoverCardContent, HoverCardTrigger };
|