@salesforce/webapp-template-base-react-app-experimental 1.62.2 → 1.63.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.
Files changed (21) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +1 -1
  3. package/src/force-app/main/default/webapplications/base-react-app/package.json +11 -4
  4. package/src/force-app/main/default/webapplications/base-react-app/src/components/ui/alert.tsx +76 -0
  5. package/src/force-app/main/default/webapplications/base-react-app/src/components/ui/button.tsx +67 -0
  6. package/src/force-app/main/default/webapplications/base-react-app/src/components/ui/card.tsx +103 -0
  7. package/src/force-app/main/default/webapplications/base-react-app/src/components/ui/dialog.tsx +162 -0
  8. package/src/force-app/main/default/webapplications/base-react-app/src/components/ui/field.tsx +237 -0
  9. package/src/force-app/main/default/webapplications/base-react-app/src/components/ui/index.ts +84 -0
  10. package/src/force-app/main/default/webapplications/base-react-app/src/components/ui/input.tsx +19 -0
  11. package/src/force-app/main/default/webapplications/base-react-app/src/components/ui/label.tsx +22 -0
  12. package/src/force-app/main/default/webapplications/base-react-app/src/components/ui/pagination.tsx +132 -0
  13. package/src/force-app/main/default/webapplications/base-react-app/src/components/ui/select.tsx +193 -0
  14. package/src/force-app/main/default/webapplications/base-react-app/src/components/ui/separator.tsx +26 -0
  15. package/src/force-app/main/default/webapplications/base-react-app/src/components/ui/skeleton.tsx +14 -0
  16. package/src/force-app/main/default/webapplications/base-react-app/src/components/ui/spinner.tsx +16 -0
  17. package/src/force-app/main/default/webapplications/base-react-app/src/components/ui/table.tsx +114 -0
  18. package/src/force-app/main/default/webapplications/base-react-app/src/components/ui/tabs.tsx +88 -0
  19. package/src/force-app/main/default/webapplications/base-react-app/src/components.json +18 -0
  20. package/src/force-app/main/default/webapplications/base-react-app/src/lib/utils.ts +6 -0
  21. package/src/force-app/main/default/webapplications/base-react-app/src/styles/global.css +122 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.63.0](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.62.2...v1.63.0) (2026-03-03)
7
+
8
+ ### Features
9
+
10
+ - move shadcn UI into base-react-app ([#188](https://github.com/salesforce-experience-platform-emu/webapps/issues/188)) ([366443f](https://github.com/salesforce-experience-platform-emu/webapps/commit/366443f626c5232ca56c6a5dc6da874bfb955f22))
11
+
6
12
  ## [1.62.2](https://github.com/salesforce-experience-platform-emu/webapps/compare/v1.62.1...v1.62.2) (2026-03-02)
7
13
 
8
14
  **Note:** Version bump only for package @salesforce/webapp-template-base-react-app-experimental
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-template-base-react-app-experimental",
3
- "version": "1.62.2",
3
+ "version": "1.63.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -15,13 +15,20 @@
15
15
  "graphql:schema": "node scripts/get-graphql-schema.mjs"
16
16
  },
17
17
  "dependencies": {
18
- "@salesforce/sdk-data": "^1.62.2",
19
- "@salesforce/webapp-experimental": "^1.62.2",
18
+ "@salesforce/sdk-data": "^1.63.0",
19
+ "@salesforce/webapp-experimental": "^1.63.0",
20
20
  "@tailwindcss/vite": "^4.1.17",
21
21
  "react": "^19.2.0",
22
22
  "react-dom": "^19.2.0",
23
23
  "react-router": "^7.10.1",
24
- "tailwindcss": "^4.1.17"
24
+ "tailwindcss": "^4.1.17",
25
+ "class-variance-authority": "^0.7.1",
26
+ "clsx": "^2.1.1",
27
+ "lucide-react": "^0.562.0",
28
+ "radix-ui": "^1.4.3",
29
+ "shadcn": "^3.8.5",
30
+ "tailwind-merge": "^3.4.0",
31
+ "tw-animate-css": "^1.4.0"
25
32
  },
26
33
  "devDependencies": {
27
34
  "@eslint/js": "^9.39.1",
@@ -31,7 +38,7 @@
31
38
  "@graphql-eslint/eslint-plugin": "^4.1.0",
32
39
  "@graphql-tools/utils": "^11.0.0",
33
40
  "@playwright/test": "^1.49.0",
34
- "@salesforce/vite-plugin-webapp-experimental": "^1.62.2",
41
+ "@salesforce/vite-plugin-webapp-experimental": "^1.63.0",
35
42
  "@testing-library/jest-dom": "^6.6.3",
36
43
  "@testing-library/react": "^16.1.0",
37
44
  "@testing-library/user-event": "^14.5.2",
@@ -0,0 +1,76 @@
1
+ import * as React from 'react';
2
+ import { cva, type VariantProps } from 'class-variance-authority';
3
+
4
+ import { cn } from '../../lib/utils';
5
+
6
+ const alertVariants = cva(
7
+ "grid gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4 w-full relative group/alert",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: 'bg-card text-card-foreground',
12
+ destructive:
13
+ 'text-destructive bg-card *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current',
14
+ },
15
+ },
16
+ defaultVariants: {
17
+ variant: 'default',
18
+ },
19
+ }
20
+ );
21
+
22
+ function Alert({
23
+ className,
24
+ variant,
25
+ ...props
26
+ }: React.ComponentProps<'div'> & VariantProps<typeof alertVariants>) {
27
+ return (
28
+ <div
29
+ data-slot="alert"
30
+ role="alert"
31
+ className={cn(alertVariants({ variant }), className)}
32
+ {...props}
33
+ />
34
+ );
35
+ }
36
+
37
+ function AlertTitle({ className, ...props }: React.ComponentProps<'div'>) {
38
+ return (
39
+ <div
40
+ data-slot="alert-title"
41
+ className={cn(
42
+ 'font-medium group-has-[>svg]/alert:col-start-2 [&_a]:hover:text-foreground [&_a]:underline [&_a]:underline-offset-3',
43
+ className
44
+ )}
45
+ {...props}
46
+ />
47
+ );
48
+ }
49
+
50
+ function AlertDescription({
51
+ className,
52
+ ...props
53
+ }: React.ComponentProps<'div'>) {
54
+ return (
55
+ <div
56
+ data-slot="alert-description"
57
+ className={cn(
58
+ 'text-muted-foreground text-sm text-balance md:text-pretty [&_p:not(:last-child)]:mb-4 [&_a]:hover:text-foreground [&_a]:underline [&_a]:underline-offset-3',
59
+ className
60
+ )}
61
+ {...props}
62
+ />
63
+ );
64
+ }
65
+
66
+ function AlertAction({ className, ...props }: React.ComponentProps<'div'>) {
67
+ return (
68
+ <div
69
+ data-slot="alert-action"
70
+ className={cn('absolute top-2 right-2', className)}
71
+ {...props}
72
+ />
73
+ );
74
+ }
75
+
76
+ export { Alert, AlertTitle, AlertDescription, AlertAction };
@@ -0,0 +1,67 @@
1
+ import * as React from 'react';
2
+ import { cva, type VariantProps } from 'class-variance-authority';
3
+ import { Slot } from 'radix-ui';
4
+
5
+ import { cn } from '../../lib/utils';
6
+
7
+ const buttonVariants = cva(
8
+ "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:aria-invalid:border-destructive/50 rounded-lg border border-transparent bg-clip-padding text-sm font-medium focus-visible:ring-3 aria-invalid:ring-3 [&_svg:not([class*='size-'])]:size-4 inline-flex items-center justify-center whitespace-nowrap transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none shrink-0 [&_svg]:shrink-0 outline-none group/button select-none",
9
+ {
10
+ variants: {
11
+ variant: {
12
+ default: 'bg-primary text-primary-foreground [a]:hover:bg-primary/80',
13
+ outline:
14
+ 'border-border bg-background hover:bg-muted hover:text-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 aria-expanded:bg-muted aria-expanded:text-foreground',
15
+ secondary:
16
+ 'bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground',
17
+ ghost:
18
+ 'hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground',
19
+ destructive:
20
+ 'bg-destructive/10 hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive focus-visible:border-destructive/40 dark:hover:bg-destructive/30',
21
+ link: 'text-primary underline-offset-4 hover:underline',
22
+ },
23
+ size: {
24
+ default:
25
+ 'h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
26
+ xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
27
+ sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
28
+ lg: 'h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3',
29
+ icon: 'size-8',
30
+ 'icon-xs':
31
+ "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
32
+ 'icon-sm':
33
+ 'size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg',
34
+ 'icon-lg': 'size-9',
35
+ },
36
+ },
37
+ defaultVariants: {
38
+ variant: 'default',
39
+ size: 'default',
40
+ },
41
+ }
42
+ );
43
+
44
+ function Button({
45
+ className,
46
+ variant = 'default',
47
+ size = 'default',
48
+ asChild = false,
49
+ ...props
50
+ }: React.ComponentProps<'button'> &
51
+ VariantProps<typeof buttonVariants> & {
52
+ asChild?: boolean;
53
+ }) {
54
+ const Comp = asChild ? Slot.Root : 'button';
55
+
56
+ return (
57
+ <Comp
58
+ data-slot="button"
59
+ data-variant={variant}
60
+ data-size={size}
61
+ className={cn(buttonVariants({ variant, size, className }))}
62
+ {...(props as any)}
63
+ />
64
+ );
65
+ }
66
+
67
+ export { Button, buttonVariants };
@@ -0,0 +1,103 @@
1
+ import * as React from 'react';
2
+
3
+ import { cn } from '../../lib/utils';
4
+
5
+ function Card({
6
+ className,
7
+ size = 'default',
8
+ ...props
9
+ }: React.ComponentProps<'div'> & { size?: 'default' | 'sm' }) {
10
+ return (
11
+ <div
12
+ data-slot="card"
13
+ data-size={size}
14
+ className={cn(
15
+ 'ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-xl py-4 text-sm ring-1 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl group/card flex flex-col',
16
+ className
17
+ )}
18
+ {...props}
19
+ />
20
+ );
21
+ }
22
+
23
+ function CardHeader({ className, ...props }: React.ComponentProps<'div'>) {
24
+ return (
25
+ <div
26
+ data-slot="card-header"
27
+ className={cn(
28
+ 'gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]',
29
+ className
30
+ )}
31
+ {...props}
32
+ />
33
+ );
34
+ }
35
+
36
+ function CardTitle({ className, ...props }: React.ComponentProps<'div'>) {
37
+ return (
38
+ <div
39
+ data-slot="card-title"
40
+ className={cn(
41
+ 'text-base leading-snug font-medium group-data-[size=sm]/card:text-sm',
42
+ className
43
+ )}
44
+ {...props}
45
+ />
46
+ );
47
+ }
48
+
49
+ function CardDescription({ className, ...props }: React.ComponentProps<'div'>) {
50
+ return (
51
+ <div
52
+ data-slot="card-description"
53
+ className={cn('text-muted-foreground text-sm', className)}
54
+ {...props}
55
+ />
56
+ );
57
+ }
58
+
59
+ function CardAction({ className, ...props }: React.ComponentProps<'div'>) {
60
+ return (
61
+ <div
62
+ data-slot="card-action"
63
+ className={cn(
64
+ 'col-start-2 row-span-2 row-start-1 self-start justify-self-end',
65
+ className
66
+ )}
67
+ {...props}
68
+ />
69
+ );
70
+ }
71
+
72
+ function CardContent({ className, ...props }: React.ComponentProps<'div'>) {
73
+ return (
74
+ <div
75
+ data-slot="card-content"
76
+ className={cn('px-4 group-data-[size=sm]/card:px-3', className)}
77
+ {...props}
78
+ />
79
+ );
80
+ }
81
+
82
+ function CardFooter({ className, ...props }: React.ComponentProps<'div'>) {
83
+ return (
84
+ <div
85
+ data-slot="card-footer"
86
+ className={cn(
87
+ 'bg-muted/50 rounded-b-xl border-t p-4 group-data-[size=sm]/card:p-3 flex items-center',
88
+ className
89
+ )}
90
+ {...props}
91
+ />
92
+ );
93
+ }
94
+
95
+ export {
96
+ Card,
97
+ CardHeader,
98
+ CardFooter,
99
+ CardTitle,
100
+ CardAction,
101
+ CardDescription,
102
+ CardContent,
103
+ };
@@ -0,0 +1,162 @@
1
+ import * as React from 'react';
2
+ import { Dialog as DialogPrimitive } from 'radix-ui';
3
+
4
+ import { cn } from '../../lib/utils';
5
+ import { Button } from './button';
6
+ import { XIcon } from 'lucide-react';
7
+
8
+ function Dialog({
9
+ ...props
10
+ }: React.ComponentProps<typeof DialogPrimitive.Root>) {
11
+ return <DialogPrimitive.Root data-slot="dialog" {...props} />;
12
+ }
13
+
14
+ function DialogTrigger({
15
+ ...props
16
+ }: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
17
+ return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />;
18
+ }
19
+
20
+ function DialogPortal({
21
+ ...props
22
+ }: React.ComponentProps<typeof DialogPrimitive.Portal>) {
23
+ return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />;
24
+ }
25
+
26
+ function DialogClose({
27
+ ...props
28
+ }: React.ComponentProps<typeof DialogPrimitive.Close>) {
29
+ return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;
30
+ }
31
+
32
+ function DialogOverlay({
33
+ className,
34
+ ...props
35
+ }: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
36
+ return (
37
+ <DialogPrimitive.Overlay
38
+ data-slot="dialog-overlay"
39
+ className={cn(
40
+ 'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50',
41
+ className
42
+ )}
43
+ {...props}
44
+ />
45
+ );
46
+ }
47
+
48
+ function DialogContent({
49
+ className,
50
+ children,
51
+ showCloseButton = true,
52
+ ...props
53
+ }: React.ComponentProps<typeof DialogPrimitive.Content> & {
54
+ showCloseButton?: boolean;
55
+ }) {
56
+ return (
57
+ <DialogPortal>
58
+ <DialogOverlay />
59
+ <DialogPrimitive.Content
60
+ data-slot="dialog-content"
61
+ className={cn(
62
+ 'bg-background data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 ring-foreground/10 grid max-w-[calc(100%-2rem)] gap-4 rounded-xl p-4 text-sm ring-1 duration-100 sm:max-w-sm fixed top-1/2 left-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 outline-none',
63
+ className
64
+ )}
65
+ {...props}
66
+ >
67
+ {children}
68
+ {showCloseButton && (
69
+ <DialogPrimitive.Close data-slot="dialog-close" asChild>
70
+ <Button
71
+ variant="ghost"
72
+ className="absolute top-2 right-2"
73
+ size="icon-sm"
74
+ >
75
+ <XIcon />
76
+ <span className="sr-only">Close</span>
77
+ </Button>
78
+ </DialogPrimitive.Close>
79
+ )}
80
+ </DialogPrimitive.Content>
81
+ </DialogPortal>
82
+ );
83
+ }
84
+
85
+ function DialogHeader({ className, ...props }: React.ComponentProps<'div'>) {
86
+ return (
87
+ <div
88
+ data-slot="dialog-header"
89
+ className={cn('gap-2 flex flex-col', className)}
90
+ {...props}
91
+ />
92
+ );
93
+ }
94
+
95
+ function DialogFooter({
96
+ className,
97
+ showCloseButton = false,
98
+ children,
99
+ ...props
100
+ }: React.ComponentProps<'div'> & {
101
+ showCloseButton?: boolean;
102
+ }) {
103
+ return (
104
+ <div
105
+ data-slot="dialog-footer"
106
+ className={cn(
107
+ 'bg-muted/50 rounded-b-xl border-t p-4 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end',
108
+ className
109
+ )}
110
+ {...props}
111
+ >
112
+ {children}
113
+ {showCloseButton && (
114
+ <DialogPrimitive.Close asChild>
115
+ <Button variant="outline">Close</Button>
116
+ </DialogPrimitive.Close>
117
+ )}
118
+ </div>
119
+ );
120
+ }
121
+
122
+ function DialogTitle({
123
+ className,
124
+ ...props
125
+ }: React.ComponentProps<typeof DialogPrimitive.Title>) {
126
+ return (
127
+ <DialogPrimitive.Title
128
+ data-slot="dialog-title"
129
+ className={cn('text-base leading-none font-medium', className)}
130
+ {...props}
131
+ />
132
+ );
133
+ }
134
+
135
+ function DialogDescription({
136
+ className,
137
+ ...props
138
+ }: React.ComponentProps<typeof DialogPrimitive.Description>) {
139
+ return (
140
+ <DialogPrimitive.Description
141
+ data-slot="dialog-description"
142
+ className={cn(
143
+ 'text-muted-foreground *:[a]:hover:text-foreground text-sm *:[a]:underline *:[a]:underline-offset-3',
144
+ className
145
+ )}
146
+ {...props}
147
+ />
148
+ );
149
+ }
150
+
151
+ export {
152
+ Dialog,
153
+ DialogClose,
154
+ DialogContent,
155
+ DialogDescription,
156
+ DialogFooter,
157
+ DialogHeader,
158
+ DialogOverlay,
159
+ DialogPortal,
160
+ DialogTitle,
161
+ DialogTrigger,
162
+ };
@@ -0,0 +1,237 @@
1
+ import * as React from 'react';
2
+ import { useMemo } from 'react';
3
+ import { cva, type VariantProps } from 'class-variance-authority';
4
+
5
+ import { cn } from '../../lib/utils';
6
+ import { Label } from './label';
7
+ import { Separator } from './separator';
8
+
9
+ function FieldSet({ className, ...props }: React.ComponentProps<'fieldset'>) {
10
+ return (
11
+ <fieldset
12
+ data-slot="field-set"
13
+ className={cn(
14
+ 'gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3 flex flex-col',
15
+ className
16
+ )}
17
+ {...props}
18
+ />
19
+ );
20
+ }
21
+
22
+ function FieldLegend({
23
+ className,
24
+ variant = 'legend',
25
+ ...props
26
+ }: React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }) {
27
+ return (
28
+ <legend
29
+ data-slot="field-legend"
30
+ data-variant={variant}
31
+ className={cn(
32
+ 'mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base',
33
+ className
34
+ )}
35
+ {...props}
36
+ />
37
+ );
38
+ }
39
+
40
+ function FieldGroup({ className, ...props }: React.ComponentProps<'div'>) {
41
+ return (
42
+ <div
43
+ data-slot="field-group"
44
+ className={cn(
45
+ 'gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4 group/field-group @container/field-group flex w-full flex-col',
46
+ className
47
+ )}
48
+ {...props}
49
+ />
50
+ );
51
+ }
52
+
53
+ const fieldVariants = cva(
54
+ 'data-[invalid=true]:text-destructive gap-2 group/field flex w-full',
55
+ {
56
+ variants: {
57
+ orientation: {
58
+ vertical: 'flex-col *:w-full [&>.sr-only]:w-auto',
59
+ horizontal:
60
+ 'flex-row items-center *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
61
+ responsive:
62
+ 'flex-col *:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:*:data-[slot=field-label]:flex-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
63
+ },
64
+ },
65
+ defaultVariants: {
66
+ orientation: 'vertical',
67
+ },
68
+ }
69
+ );
70
+
71
+ function Field({
72
+ className,
73
+ orientation = 'vertical',
74
+ ...props
75
+ }: React.ComponentProps<'div'> & VariantProps<typeof fieldVariants>) {
76
+ return (
77
+ <div
78
+ role="group"
79
+ data-slot="field"
80
+ data-orientation={orientation}
81
+ className={cn(fieldVariants({ orientation }), className)}
82
+ {...props}
83
+ />
84
+ );
85
+ }
86
+
87
+ function FieldContent({ className, ...props }: React.ComponentProps<'div'>) {
88
+ return (
89
+ <div
90
+ data-slot="field-content"
91
+ className={cn(
92
+ 'gap-0.5 group/field-content flex flex-1 flex-col leading-snug',
93
+ className
94
+ )}
95
+ {...props}
96
+ />
97
+ );
98
+ }
99
+
100
+ function FieldLabel({
101
+ className,
102
+ ...props
103
+ }: React.ComponentProps<typeof Label>) {
104
+ return (
105
+ <Label
106
+ data-slot="field-label"
107
+ className={cn(
108
+ 'has-data-checked:bg-primary/5 has-data-checked:border-primary/30 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10 gap-2 group-data-[disabled=true]/field:opacity-50 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5 group/field-label peer/field-label flex w-fit leading-snug',
109
+ 'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col',
110
+ className
111
+ )}
112
+ {...props}
113
+ />
114
+ );
115
+ }
116
+
117
+ function FieldTitle({ className, ...props }: React.ComponentProps<'div'>) {
118
+ return (
119
+ <div
120
+ data-slot="field-label"
121
+ className={cn(
122
+ 'gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50 flex w-fit items-center leading-snug',
123
+ className
124
+ )}
125
+ {...props}
126
+ />
127
+ );
128
+ }
129
+
130
+ function FieldDescription({ className, ...props }: React.ComponentProps<'p'>) {
131
+ return (
132
+ <p
133
+ data-slot="field-description"
134
+ className={cn(
135
+ 'text-muted-foreground text-left text-sm [[data-variant=legend]+&]:-mt-1.5 leading-normal font-normal group-has-data-horizontal/field:text-balance',
136
+ 'last:mt-0 nth-last-2:-mt-1',
137
+ '[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4',
138
+ className
139
+ )}
140
+ {...props}
141
+ />
142
+ );
143
+ }
144
+
145
+ function FieldSeparator({
146
+ children,
147
+ className,
148
+ ...props
149
+ }: React.ComponentProps<'div'> & {
150
+ children?: React.ReactNode;
151
+ }) {
152
+ return (
153
+ <div
154
+ data-slot="field-separator"
155
+ data-content={!!children}
156
+ className={cn(
157
+ '-my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2 relative',
158
+ className
159
+ )}
160
+ {...props}
161
+ >
162
+ <Separator className="absolute inset-0 top-1/2" />
163
+ {children && (
164
+ <span
165
+ className="text-muted-foreground px-2 bg-background relative mx-auto block w-fit"
166
+ data-slot="field-separator-content"
167
+ >
168
+ {children}
169
+ </span>
170
+ )}
171
+ </div>
172
+ );
173
+ }
174
+
175
+ function FieldError({
176
+ className,
177
+ children,
178
+ errors,
179
+ ...props
180
+ }: React.ComponentProps<'div'> & {
181
+ errors?: Array<{ message?: string } | undefined>;
182
+ }) {
183
+ const content = useMemo(() => {
184
+ if (children) {
185
+ return children;
186
+ }
187
+
188
+ if (!errors?.length) {
189
+ return null;
190
+ }
191
+
192
+ const uniqueErrors = [
193
+ ...new Map(errors.map(error => [error?.message, error])).values(),
194
+ ];
195
+
196
+ if (uniqueErrors?.length == 1) {
197
+ return uniqueErrors[0]?.message;
198
+ }
199
+
200
+ return (
201
+ <ul className="ml-4 flex list-disc flex-col gap-1">
202
+ {uniqueErrors.map(
203
+ (error, index) =>
204
+ error?.message && <li key={index}>{error.message}</li>
205
+ )}
206
+ </ul>
207
+ );
208
+ }, [children, errors]);
209
+
210
+ if (!content) {
211
+ return null;
212
+ }
213
+
214
+ return (
215
+ <div
216
+ role="alert"
217
+ data-slot="field-error"
218
+ className={cn('text-destructive text-sm font-normal', className)}
219
+ {...props}
220
+ >
221
+ {content}
222
+ </div>
223
+ );
224
+ }
225
+
226
+ export {
227
+ Field,
228
+ FieldLabel,
229
+ FieldDescription,
230
+ FieldError,
231
+ FieldGroup,
232
+ FieldLegend,
233
+ FieldSeparator,
234
+ FieldSet,
235
+ FieldContent,
236
+ FieldTitle,
237
+ };