@foundrykit/primitives 2.0.6 → 2.0.8
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 +18 -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
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const SpinnerConfig: ComponentConfig = {
|
|
4
|
+
name: 'Spinner',
|
|
5
|
+
description:
|
|
6
|
+
'An animated loading indicator for pending or in-progress states.',
|
|
7
|
+
category: 'primitives',
|
|
8
|
+
tags: ['spinner', 'loading', 'feedback'],
|
|
9
|
+
preview: {
|
|
10
|
+
type: 'static',
|
|
11
|
+
html: '<div class="flex h-12 w-full items-center justify-center rounded-md border border-gray-300 bg-gray-100"><div class="h-5 w-5 rounded-full border-2 border-gray-400 border-t-transparent"></div></div>',
|
|
12
|
+
},
|
|
13
|
+
variants: [
|
|
14
|
+
{
|
|
15
|
+
name: 'Default',
|
|
16
|
+
description: 'Default spinner',
|
|
17
|
+
code: '<Spinner />',
|
|
18
|
+
preview: {
|
|
19
|
+
type: 'component',
|
|
20
|
+
component: 'Spinner',
|
|
21
|
+
props: {},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'Large',
|
|
26
|
+
description: 'Large spinner',
|
|
27
|
+
code: '<Spinner className="size-8" />',
|
|
28
|
+
preview: {
|
|
29
|
+
type: 'component',
|
|
30
|
+
component: 'Spinner',
|
|
31
|
+
props: {
|
|
32
|
+
className: 'size-8',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
dependencies: ['utils'],
|
|
38
|
+
packageDependencies: ['lucide-react'],
|
|
39
|
+
files: ['components/primitives/spinner/index.tsx'],
|
|
40
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { cn } from '@foundrykit/utils';
|
|
2
|
+
import { Loader2Icon } from 'lucide-react';
|
|
3
|
+
import type * as React from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Loading indicator built on the lucide `Loader2Icon` with a continuous
|
|
7
|
+
* spin animation. Adjust the size and color through `className` (e.g.
|
|
8
|
+
* `size-6 text-muted-foreground`).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <Spinner className="size-6 text-muted-foreground" />
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
function Spinner({
|
|
16
|
+
className,
|
|
17
|
+
...props
|
|
18
|
+
}: React.ComponentProps<typeof Loader2Icon>) {
|
|
19
|
+
return (
|
|
20
|
+
<Loader2Icon
|
|
21
|
+
role='status'
|
|
22
|
+
aria-label='Loading'
|
|
23
|
+
data-slot='spinner'
|
|
24
|
+
className={cn('size-4 animate-spin', className)}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { Spinner };
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
5
|
-
|
|
6
3
|
import { cn } from '@foundrykit/utils';
|
|
4
|
+
import * as SwitchPrimitive from '@radix-ui/react-switch';
|
|
5
|
+
import type * as React from 'react';
|
|
7
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Toggle switch built on Radix `Switch.Root` with a sliding thumb. Supports
|
|
9
|
+
* controlled/uncontrolled state and disabled styling via the underlying Radix
|
|
10
|
+
* props (`checked`/`onCheckedChange`).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <Switch checked={on} onCheckedChange={setOn} />
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
8
17
|
function Switch({
|
|
9
18
|
className,
|
|
10
19
|
...props
|
|
@@ -13,7 +22,7 @@ function Switch({
|
|
|
13
22
|
<SwitchPrimitive.Root
|
|
14
23
|
data-slot='switch'
|
|
15
24
|
className={cn(
|
|
16
|
-
'data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80
|
|
25
|
+
'data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 peer inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50',
|
|
17
26
|
className
|
|
18
27
|
)}
|
|
19
28
|
{...props}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const TableConfig: ComponentConfig = {
|
|
4
|
+
name: 'Table',
|
|
5
|
+
description:
|
|
6
|
+
'A responsive table component for displaying tabular data in rows and columns.',
|
|
7
|
+
category: 'primitives',
|
|
8
|
+
tags: ['table', 'data', 'grid'],
|
|
9
|
+
preview: {
|
|
10
|
+
type: 'static',
|
|
11
|
+
html: '<div class="w-full overflow-hidden rounded-md border border-gray-300"><div class="flex border-b border-gray-300 bg-gray-100 px-3 py-2"><div class="h-2 w-16 rounded bg-gray-400"></div></div><div class="flex px-3 py-2"><div class="h-2 w-24 rounded bg-gray-300"></div></div></div>',
|
|
12
|
+
},
|
|
13
|
+
variants: [
|
|
14
|
+
{
|
|
15
|
+
name: 'Default',
|
|
16
|
+
description: 'Default table',
|
|
17
|
+
code: '<Table><TableHeader><TableRow><TableHead>Name</TableHead></TableRow></TableHeader><TableBody><TableRow><TableCell>Acme</TableCell></TableRow></TableBody></Table>',
|
|
18
|
+
preview: {
|
|
19
|
+
type: 'component',
|
|
20
|
+
component: 'Table',
|
|
21
|
+
props: {},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'With Caption',
|
|
26
|
+
description: 'Table with a caption',
|
|
27
|
+
code: '<Table><TableCaption>A list of recent invoices.</TableCaption></Table>',
|
|
28
|
+
preview: {
|
|
29
|
+
type: 'component',
|
|
30
|
+
component: 'Table',
|
|
31
|
+
props: {},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
dependencies: ['utils'],
|
|
36
|
+
packageDependencies: [],
|
|
37
|
+
files: ['components/primitives/table/index.tsx'],
|
|
38
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { cn } from '@foundrykit/utils';
|
|
2
|
+
import type * as React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Responsive data table. Wraps a native `<table>` in a horizontally
|
|
6
|
+
* scrollable container and composes with {@link TableHeader},
|
|
7
|
+
* {@link TableBody}, {@link TableFooter}, {@link TableRow},
|
|
8
|
+
* {@link TableHead}, {@link TableCell} and {@link TableCaption}.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <Table>
|
|
13
|
+
* <TableHeader>
|
|
14
|
+
* <TableRow>
|
|
15
|
+
* <TableHead>Name</TableHead>
|
|
16
|
+
* </TableRow>
|
|
17
|
+
* </TableHeader>
|
|
18
|
+
* <TableBody>
|
|
19
|
+
* <TableRow>
|
|
20
|
+
* <TableCell>Acme</TableCell>
|
|
21
|
+
* </TableRow>
|
|
22
|
+
* </TableBody>
|
|
23
|
+
* </Table>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
function Table({ className, ...props }: React.ComponentProps<'table'>) {
|
|
27
|
+
return (
|
|
28
|
+
<div
|
|
29
|
+
data-slot='table-container'
|
|
30
|
+
className='relative w-full overflow-x-auto'
|
|
31
|
+
>
|
|
32
|
+
<table
|
|
33
|
+
data-slot='table'
|
|
34
|
+
className={cn('w-full caption-bottom text-sm', className)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function TableHeader({ className, ...props }: React.ComponentProps<'thead'>) {
|
|
42
|
+
return (
|
|
43
|
+
<thead
|
|
44
|
+
data-slot='table-header'
|
|
45
|
+
className={cn('[&_tr]:border-b', className)}
|
|
46
|
+
{...props}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function TableBody({ className, ...props }: React.ComponentProps<'tbody'>) {
|
|
52
|
+
return (
|
|
53
|
+
<tbody
|
|
54
|
+
data-slot='table-body'
|
|
55
|
+
className={cn('[&_tr:last-child]:border-0', className)}
|
|
56
|
+
{...props}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function TableFooter({ className, ...props }: React.ComponentProps<'tfoot'>) {
|
|
62
|
+
return (
|
|
63
|
+
<tfoot
|
|
64
|
+
data-slot='table-footer'
|
|
65
|
+
className={cn(
|
|
66
|
+
'bg-muted/50 border-t font-medium [&>tr]:last:border-b-0',
|
|
67
|
+
className
|
|
68
|
+
)}
|
|
69
|
+
{...props}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function TableRow({ className, ...props }: React.ComponentProps<'tr'>) {
|
|
75
|
+
return (
|
|
76
|
+
<tr
|
|
77
|
+
data-slot='table-row'
|
|
78
|
+
className={cn(
|
|
79
|
+
'hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors',
|
|
80
|
+
className
|
|
81
|
+
)}
|
|
82
|
+
{...props}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function TableHead({ className, ...props }: React.ComponentProps<'th'>) {
|
|
88
|
+
return (
|
|
89
|
+
<th
|
|
90
|
+
data-slot='table-head'
|
|
91
|
+
className={cn(
|
|
92
|
+
'text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]',
|
|
93
|
+
className
|
|
94
|
+
)}
|
|
95
|
+
{...props}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function TableCell({ className, ...props }: React.ComponentProps<'td'>) {
|
|
101
|
+
return (
|
|
102
|
+
<td
|
|
103
|
+
data-slot='table-cell'
|
|
104
|
+
className={cn(
|
|
105
|
+
'p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]',
|
|
106
|
+
className
|
|
107
|
+
)}
|
|
108
|
+
{...props}
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function TableCaption({
|
|
114
|
+
className,
|
|
115
|
+
...props
|
|
116
|
+
}: React.ComponentProps<'caption'>) {
|
|
117
|
+
return (
|
|
118
|
+
<caption
|
|
119
|
+
data-slot='table-caption'
|
|
120
|
+
className={cn('text-muted-foreground mt-4 text-sm', className)}
|
|
121
|
+
{...props}
|
|
122
|
+
/>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export {
|
|
127
|
+
Table,
|
|
128
|
+
TableBody,
|
|
129
|
+
TableCaption,
|
|
130
|
+
TableCell,
|
|
131
|
+
TableFooter,
|
|
132
|
+
TableHead,
|
|
133
|
+
TableHeader,
|
|
134
|
+
TableRow,
|
|
135
|
+
};
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
5
|
-
|
|
6
3
|
import { cn } from '@foundrykit/utils';
|
|
4
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
5
|
+
import type * as React from 'react';
|
|
7
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Tabbed interface root built on Radix `Tabs.Root`. Compose with
|
|
9
|
+
* {@link TabsList} containing {@link TabsTrigger}s and matching
|
|
10
|
+
* {@link TabsContent} panels; manage the active tab via Radix
|
|
11
|
+
* `value`/`defaultValue`/`onValueChange`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <Tabs defaultValue="a">
|
|
16
|
+
* <TabsList>
|
|
17
|
+
* <TabsTrigger value="a">A</TabsTrigger>
|
|
18
|
+
* <TabsTrigger value="b">B</TabsTrigger>
|
|
19
|
+
* </TabsList>
|
|
20
|
+
* <TabsContent value="a">Panel A</TabsContent>
|
|
21
|
+
* </Tabs>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
8
24
|
function Tabs({
|
|
9
25
|
className,
|
|
10
26
|
...props
|
|
@@ -42,7 +58,7 @@ function TabsTrigger({
|
|
|
42
58
|
<TabsPrimitive.Trigger
|
|
43
59
|
data-slot='tabs-trigger'
|
|
44
60
|
className={cn(
|
|
45
|
-
"data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5
|
|
61
|
+
"data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
46
62
|
className
|
|
47
63
|
)}
|
|
48
64
|
{...props}
|
|
@@ -63,4 +79,4 @@ function TabsContent({
|
|
|
63
79
|
);
|
|
64
80
|
}
|
|
65
81
|
|
|
66
|
-
export { Tabs, TabsList, TabsTrigger
|
|
82
|
+
export { Tabs, TabsContent, TabsList, TabsTrigger };
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
1
|
import { cn } from '@foundrykit/utils';
|
|
2
|
+
import type * as React from 'react';
|
|
4
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Styled multi-line text input wrapping the native `<textarea>`. Auto-sizes to
|
|
6
|
+
* content and includes focus-ring, disabled and `aria-invalid` styling.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <Textarea placeholder="Write a message" />
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
5
13
|
function Textarea({ className, ...props }: React.ComponentProps<'textarea'>) {
|
|
6
14
|
return (
|
|
7
15
|
<textarea
|
|
8
16
|
data-slot='textarea'
|
|
9
17
|
className={cn(
|
|
10
|
-
'border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 field-sizing-content
|
|
18
|
+
'border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',
|
|
11
19
|
className
|
|
12
20
|
)}
|
|
13
21
|
{...props}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { cn } from '@foundrykit/utils';
|
|
4
4
|
import * as TogglePrimitive from '@radix-ui/react-toggle';
|
|
5
5
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
6
|
-
|
|
7
|
-
import { cn } from '@foundrykit/utils';
|
|
6
|
+
import type * as React from 'react';
|
|
8
7
|
|
|
9
8
|
const toggleVariants = cva(
|
|
10
|
-
"
|
|
9
|
+
"hover:bg-muted hover:text-muted-foreground data-[state=on]:bg-accent data-[state=on]:text-accent-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
11
10
|
{
|
|
12
11
|
variants: {
|
|
13
12
|
variant: {
|
|
14
13
|
default: 'bg-transparent',
|
|
15
14
|
outline:
|
|
16
|
-
'border
|
|
15
|
+
'border-input hover:bg-accent hover:text-accent-foreground border bg-transparent shadow-xs',
|
|
17
16
|
},
|
|
18
17
|
size: {
|
|
19
|
-
default: 'h-9
|
|
20
|
-
sm: 'h-8 px-1.5
|
|
21
|
-
lg: 'h-10 px-2.5
|
|
18
|
+
default: 'h-9 min-w-9 px-2',
|
|
19
|
+
sm: 'h-8 min-w-8 px-1.5',
|
|
20
|
+
lg: 'h-10 min-w-10 px-2.5',
|
|
22
21
|
},
|
|
23
22
|
},
|
|
24
23
|
defaultVariants: {
|
|
@@ -28,6 +27,19 @@ const toggleVariants = cva(
|
|
|
28
27
|
}
|
|
29
28
|
);
|
|
30
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Two-state toggle button built on Radix `Toggle.Root`, styled via
|
|
32
|
+
* {@link toggleVariants} with a `variant` (default, outline) and `size`
|
|
33
|
+
* (default, sm, lg). Control the pressed state with Radix
|
|
34
|
+
* `pressed`/`onPressedChange`.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* <Toggle variant="outline" pressed={bold} onPressedChange={setBold}>
|
|
39
|
+
* <BoldIcon />
|
|
40
|
+
* </Toggle>
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
31
43
|
function Toggle({
|
|
32
44
|
className,
|
|
33
45
|
variant,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const ToggleGroupConfig: ComponentConfig = {
|
|
4
|
+
name: 'Toggle Group',
|
|
5
|
+
description:
|
|
6
|
+
'A set of two-state buttons that can be toggled on or off, individually or as a single selection.',
|
|
7
|
+
category: 'primitives',
|
|
8
|
+
tags: ['toggle-group', 'input', 'form'],
|
|
9
|
+
preview: {
|
|
10
|
+
type: 'static',
|
|
11
|
+
html: '<div class="flex h-12 w-full items-center px-3"><div class="flex w-fit items-center rounded-md border border-gray-300"><span class="h-9 rounded-l-md bg-gray-200 px-3 py-2 text-sm text-gray-600">B</span><span class="h-9 px-3 py-2 text-sm text-gray-600">I</span><span class="h-9 rounded-r-md px-3 py-2 text-sm text-gray-600">U</span></div></div>',
|
|
12
|
+
},
|
|
13
|
+
variants: [
|
|
14
|
+
{
|
|
15
|
+
name: 'Default',
|
|
16
|
+
description: 'Multiple-selection toggle group',
|
|
17
|
+
code: '<ToggleGroup type="multiple"><ToggleGroupItem value="bold">B</ToggleGroupItem></ToggleGroup>',
|
|
18
|
+
preview: {
|
|
19
|
+
type: 'component',
|
|
20
|
+
component: 'ToggleGroup',
|
|
21
|
+
props: {
|
|
22
|
+
type: 'multiple',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'Outline',
|
|
28
|
+
description: 'Outline single-selection toggle group',
|
|
29
|
+
code: '<ToggleGroup type="single" variant="outline"><ToggleGroupItem value="left">L</ToggleGroupItem></ToggleGroup>',
|
|
30
|
+
preview: {
|
|
31
|
+
type: 'component',
|
|
32
|
+
component: 'ToggleGroup',
|
|
33
|
+
props: {
|
|
34
|
+
type: 'single',
|
|
35
|
+
variant: 'outline',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
dependencies: ['utils'],
|
|
41
|
+
packageDependencies: [
|
|
42
|
+
'@radix-ui/react-toggle-group',
|
|
43
|
+
'class-variance-authority',
|
|
44
|
+
],
|
|
45
|
+
files: ['components/primitives/toggle-group/index.tsx'],
|
|
46
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@foundrykit/utils';
|
|
4
|
+
import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
|
|
5
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
|
|
8
|
+
const toggleGroupItemVariants = cva(
|
|
9
|
+
"hover:bg-muted hover:text-muted-foreground data-[state=on]:bg-accent data-[state=on]:text-accent-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
default: 'bg-transparent',
|
|
14
|
+
outline:
|
|
15
|
+
'border-input hover:bg-accent hover:text-accent-foreground border bg-transparent shadow-xs',
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
default: 'h-9 min-w-9 px-2',
|
|
19
|
+
sm: 'h-8 min-w-8 px-1.5',
|
|
20
|
+
lg: 'h-10 min-w-10 px-2.5',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
variant: 'default',
|
|
25
|
+
size: 'default',
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const ToggleGroupContext = React.createContext<
|
|
31
|
+
VariantProps<typeof toggleGroupItemVariants>
|
|
32
|
+
>({
|
|
33
|
+
size: 'default',
|
|
34
|
+
variant: 'default',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Set of two-state buttons built on Radix `ToggleGroup.Root`. Choose single- or
|
|
39
|
+
* multiple-selection with `type`, and share `variant`/`size` with every
|
|
40
|
+
* {@link ToggleGroupItem} via context.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* <ToggleGroup type="single" variant="outline">
|
|
45
|
+
* <ToggleGroupItem value="left"><AlignLeft /></ToggleGroupItem>
|
|
46
|
+
* <ToggleGroupItem value="center"><AlignCenter /></ToggleGroupItem>
|
|
47
|
+
* </ToggleGroup>
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
function ToggleGroup({
|
|
51
|
+
className,
|
|
52
|
+
variant,
|
|
53
|
+
size,
|
|
54
|
+
children,
|
|
55
|
+
...props
|
|
56
|
+
}: React.ComponentProps<typeof ToggleGroupPrimitive.Root> &
|
|
57
|
+
VariantProps<typeof toggleGroupItemVariants>) {
|
|
58
|
+
return (
|
|
59
|
+
<ToggleGroupPrimitive.Root
|
|
60
|
+
data-slot='toggle-group'
|
|
61
|
+
data-variant={variant}
|
|
62
|
+
data-size={size}
|
|
63
|
+
className={cn(
|
|
64
|
+
'group/toggle-group flex w-fit items-center rounded-md data-[variant=outline]:shadow-xs',
|
|
65
|
+
className
|
|
66
|
+
)}
|
|
67
|
+
{...props}
|
|
68
|
+
>
|
|
69
|
+
<ToggleGroupContext.Provider value={{ variant, size }}>
|
|
70
|
+
{children}
|
|
71
|
+
</ToggleGroupContext.Provider>
|
|
72
|
+
</ToggleGroupPrimitive.Root>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function ToggleGroupItem({
|
|
77
|
+
className,
|
|
78
|
+
children,
|
|
79
|
+
variant,
|
|
80
|
+
size,
|
|
81
|
+
...props
|
|
82
|
+
}: React.ComponentProps<typeof ToggleGroupPrimitive.Item> &
|
|
83
|
+
VariantProps<typeof toggleGroupItemVariants>) {
|
|
84
|
+
const context = React.useContext(ToggleGroupContext);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<ToggleGroupPrimitive.Item
|
|
88
|
+
data-slot='toggle-group-item'
|
|
89
|
+
data-variant={context.variant || variant}
|
|
90
|
+
data-size={context.size || size}
|
|
91
|
+
className={cn(
|
|
92
|
+
toggleGroupItemVariants({
|
|
93
|
+
variant: context.variant || variant,
|
|
94
|
+
size: context.size || size,
|
|
95
|
+
}),
|
|
96
|
+
'min-w-0 flex-1 shrink-0 rounded-none shadow-none first:rounded-l-md last:rounded-r-md focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:first:border-l',
|
|
97
|
+
className
|
|
98
|
+
)}
|
|
99
|
+
{...props}
|
|
100
|
+
>
|
|
101
|
+
{children}
|
|
102
|
+
</ToggleGroupPrimitive.Item>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
5
|
-
|
|
6
3
|
import { cn } from '@foundrykit/utils';
|
|
4
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
5
|
+
import type * as React from 'react';
|
|
7
6
|
|
|
7
|
+
/** Radix `Tooltip.Provider` wrapper (default `delayDuration` 0); wrap the app to share tooltip timing. */
|
|
8
8
|
function TooltipProvider({
|
|
9
9
|
delayDuration = 0,
|
|
10
10
|
...props
|
|
@@ -18,6 +18,20 @@ function TooltipProvider({
|
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Tooltip root built on Radix `Tooltip.Root`. Wraps itself in a
|
|
23
|
+
* {@link TooltipProvider} (default `delayDuration` 0), so it works standalone.
|
|
24
|
+
* Compose with {@link TooltipTrigger} and {@link TooltipContent} (portalled,
|
|
25
|
+
* animated, with an arrow).
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <Tooltip>
|
|
30
|
+
* <TooltipTrigger>Hover</TooltipTrigger>
|
|
31
|
+
* <TooltipContent>Details</TooltipContent>
|
|
32
|
+
* </Tooltip>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
21
35
|
function Tooltip({
|
|
22
36
|
...props
|
|
23
37
|
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
|
|
@@ -46,7 +60,7 @@ function TooltipContent({
|
|
|
46
60
|
data-slot='tooltip-content'
|
|
47
61
|
sideOffset={sideOffset}
|
|
48
62
|
className={cn(
|
|
49
|
-
'bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-tooltip-content-transform-origin)
|
|
63
|
+
'bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance',
|
|
50
64
|
className
|
|
51
65
|
)}
|
|
52
66
|
{...props}
|
|
@@ -58,4 +72,4 @@ function TooltipContent({
|
|
|
58
72
|
);
|
|
59
73
|
}
|
|
60
74
|
|
|
61
|
-
export { Tooltip,
|
|
75
|
+
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const TypographyConfig: ComponentConfig = {
|
|
4
|
+
name: 'Typography',
|
|
5
|
+
description:
|
|
6
|
+
'Presentational text styles for headings, body copy and inline content.',
|
|
7
|
+
category: 'primitives',
|
|
8
|
+
tags: ['typography', 'text', 'content'],
|
|
9
|
+
preview: {
|
|
10
|
+
type: 'static',
|
|
11
|
+
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">Typography</span></div>',
|
|
12
|
+
},
|
|
13
|
+
variants: [
|
|
14
|
+
{
|
|
15
|
+
name: 'Heading',
|
|
16
|
+
description: 'Level one heading',
|
|
17
|
+
code: '<TypographyH1>The quick brown fox</TypographyH1>',
|
|
18
|
+
preview: {
|
|
19
|
+
type: 'component',
|
|
20
|
+
component: 'TypographyH1',
|
|
21
|
+
props: {},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'Paragraph',
|
|
26
|
+
description: 'Body paragraph',
|
|
27
|
+
code: '<TypographyP>The quick brown fox jumps over the lazy dog.</TypographyP>',
|
|
28
|
+
preview: {
|
|
29
|
+
type: 'component',
|
|
30
|
+
component: 'TypographyP',
|
|
31
|
+
props: {},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
dependencies: ['utils'],
|
|
36
|
+
packageDependencies: [],
|
|
37
|
+
files: ['components/primitives/typography/index.tsx'],
|
|
38
|
+
};
|