@foundrykit/primitives 1.0.4 → 1.0.6
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/CHANGELOG.md +18 -0
- package/dist/index.cjs +220 -175
- package/dist/index.d.cts +12 -5
- package/dist/index.d.ts +12 -5
- package/dist/index.js +65 -22
- package/package.json +6 -5
- package/src/components/toggle/config.ts +67 -0
- package/src/components/toggle/index.tsx +47 -0
- package/src/index.ts +1 -0
- package/components.json +0 -20
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
export { Button, buttonVariants } from './components/button/index.cjs';
|
|
2
2
|
export { Input } from './components/input/index.cjs';
|
|
3
3
|
export { Badge, badgeVariants } from './components/badge/index.cjs';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import * as TogglePrimitive from '@radix-ui/react-toggle';
|
|
8
|
+
import { VariantProps } from 'class-variance-authority';
|
|
4
9
|
export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from './components/card/index.cjs';
|
|
5
10
|
export { Avatar, AvatarFallback, AvatarImage } from './components/avatar/index.cjs';
|
|
6
11
|
export { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from './components/breadcrumb/index.cjs';
|
|
@@ -15,12 +20,8 @@ export { Tabs, TabsContent, TabsList, TabsTrigger } from './components/tabs/inde
|
|
|
15
20
|
export { Textarea } from './components/textarea/index.cjs';
|
|
16
21
|
export { Skeleton } from './components/skeleton/index.cjs';
|
|
17
22
|
export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from './components/popover/index.cjs';
|
|
18
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
19
|
-
import * as React from 'react';
|
|
20
23
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
21
24
|
export { cn } from '@foundrykit/utils';
|
|
22
|
-
import 'class-variance-authority/types';
|
|
23
|
-
import 'class-variance-authority';
|
|
24
25
|
import '@radix-ui/react-avatar';
|
|
25
26
|
import '@radix-ui/react-checkbox';
|
|
26
27
|
import '@radix-ui/react-dropdown-menu';
|
|
@@ -32,6 +33,12 @@ import '@radix-ui/react-switch';
|
|
|
32
33
|
import '@radix-ui/react-tabs';
|
|
33
34
|
import '@radix-ui/react-popover';
|
|
34
35
|
|
|
36
|
+
declare const toggleVariants: (props?: ({
|
|
37
|
+
variant?: "default" | "outline" | null | undefined;
|
|
38
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
39
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
40
|
+
declare function Toggle({ className, variant, size, ...props }: React.ComponentProps<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>): react_jsx_runtime.JSX.Element;
|
|
41
|
+
|
|
35
42
|
declare function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
36
43
|
declare function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>): react_jsx_runtime.JSX.Element;
|
|
37
44
|
declare function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>): react_jsx_runtime.JSX.Element;
|
|
@@ -43,4 +50,4 @@ declare function DialogFooter({ className, ...props }: React.ComponentProps<'div
|
|
|
43
50
|
declare function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): react_jsx_runtime.JSX.Element;
|
|
44
51
|
declare function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>): react_jsx_runtime.JSX.Element;
|
|
45
52
|
|
|
46
|
-
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger };
|
|
53
|
+
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, Toggle, toggleVariants };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
export { Button, buttonVariants } from './components/button/index.js';
|
|
2
2
|
export { Input } from './components/input/index.js';
|
|
3
3
|
export { Badge, badgeVariants } from './components/badge/index.js';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import * as TogglePrimitive from '@radix-ui/react-toggle';
|
|
8
|
+
import { VariantProps } from 'class-variance-authority';
|
|
4
9
|
export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from './components/card/index.js';
|
|
5
10
|
export { Avatar, AvatarFallback, AvatarImage } from './components/avatar/index.js';
|
|
6
11
|
export { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from './components/breadcrumb/index.js';
|
|
@@ -15,12 +20,8 @@ export { Tabs, TabsContent, TabsList, TabsTrigger } from './components/tabs/inde
|
|
|
15
20
|
export { Textarea } from './components/textarea/index.js';
|
|
16
21
|
export { Skeleton } from './components/skeleton/index.js';
|
|
17
22
|
export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from './components/popover/index.js';
|
|
18
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
19
|
-
import * as React from 'react';
|
|
20
23
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
21
24
|
export { cn } from '@foundrykit/utils';
|
|
22
|
-
import 'class-variance-authority/types';
|
|
23
|
-
import 'class-variance-authority';
|
|
24
25
|
import '@radix-ui/react-avatar';
|
|
25
26
|
import '@radix-ui/react-checkbox';
|
|
26
27
|
import '@radix-ui/react-dropdown-menu';
|
|
@@ -32,6 +33,12 @@ import '@radix-ui/react-switch';
|
|
|
32
33
|
import '@radix-ui/react-tabs';
|
|
33
34
|
import '@radix-ui/react-popover';
|
|
34
35
|
|
|
36
|
+
declare const toggleVariants: (props?: ({
|
|
37
|
+
variant?: "default" | "outline" | null | undefined;
|
|
38
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
39
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
40
|
+
declare function Toggle({ className, variant, size, ...props }: React.ComponentProps<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>): react_jsx_runtime.JSX.Element;
|
|
41
|
+
|
|
35
42
|
declare function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>): react_jsx_runtime.JSX.Element;
|
|
36
43
|
declare function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>): react_jsx_runtime.JSX.Element;
|
|
37
44
|
declare function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>): react_jsx_runtime.JSX.Element;
|
|
@@ -43,4 +50,4 @@ declare function DialogFooter({ className, ...props }: React.ComponentProps<'div
|
|
|
43
50
|
declare function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): react_jsx_runtime.JSX.Element;
|
|
44
51
|
declare function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>): react_jsx_runtime.JSX.Element;
|
|
45
52
|
|
|
46
|
-
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger };
|
|
53
|
+
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, Toggle, toggleVariants };
|
package/dist/index.js
CHANGED
|
@@ -95,40 +95,81 @@ import {
|
|
|
95
95
|
DropdownMenuTrigger
|
|
96
96
|
} from "./chunk-PHMEWMFS.js";
|
|
97
97
|
|
|
98
|
+
// src/components/toggle/index.tsx
|
|
99
|
+
import * as TogglePrimitive from "@radix-ui/react-toggle";
|
|
100
|
+
import { cva } from "class-variance-authority";
|
|
101
|
+
import { cn } from "@foundrykit/utils";
|
|
102
|
+
import { jsx } from "react/jsx-runtime";
|
|
103
|
+
var toggleVariants = cva(
|
|
104
|
+
"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",
|
|
105
|
+
{
|
|
106
|
+
variants: {
|
|
107
|
+
variant: {
|
|
108
|
+
default: "bg-transparent",
|
|
109
|
+
outline: "border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"
|
|
110
|
+
},
|
|
111
|
+
size: {
|
|
112
|
+
default: "h-9 px-2 min-w-9",
|
|
113
|
+
sm: "h-8 px-1.5 min-w-8",
|
|
114
|
+
lg: "h-10 px-2.5 min-w-10"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
defaultVariants: {
|
|
118
|
+
variant: "default",
|
|
119
|
+
size: "default"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
function Toggle({
|
|
124
|
+
className,
|
|
125
|
+
variant,
|
|
126
|
+
size,
|
|
127
|
+
...props
|
|
128
|
+
}) {
|
|
129
|
+
return /* @__PURE__ */ jsx(
|
|
130
|
+
TogglePrimitive.Root,
|
|
131
|
+
{
|
|
132
|
+
"data-slot": "toggle",
|
|
133
|
+
className: cn(toggleVariants({ variant, size, className })),
|
|
134
|
+
...props
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
98
139
|
// src/components/dialog/index.tsx
|
|
99
140
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
100
141
|
import { XIcon } from "lucide-react";
|
|
101
|
-
import { cn } from "@foundrykit/utils";
|
|
102
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
142
|
+
import { cn as cn2 } from "@foundrykit/utils";
|
|
143
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
103
144
|
function Dialog({
|
|
104
145
|
...props
|
|
105
146
|
}) {
|
|
106
|
-
return /* @__PURE__ */
|
|
147
|
+
return /* @__PURE__ */ jsx2(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
|
|
107
148
|
}
|
|
108
149
|
function DialogTrigger({
|
|
109
150
|
...props
|
|
110
151
|
}) {
|
|
111
|
-
return /* @__PURE__ */
|
|
152
|
+
return /* @__PURE__ */ jsx2(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
|
|
112
153
|
}
|
|
113
154
|
function DialogPortal({
|
|
114
155
|
...props
|
|
115
156
|
}) {
|
|
116
|
-
return /* @__PURE__ */
|
|
157
|
+
return /* @__PURE__ */ jsx2(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
|
|
117
158
|
}
|
|
118
159
|
function DialogClose({
|
|
119
160
|
...props
|
|
120
161
|
}) {
|
|
121
|
-
return /* @__PURE__ */
|
|
162
|
+
return /* @__PURE__ */ jsx2(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
|
|
122
163
|
}
|
|
123
164
|
function DialogOverlay({
|
|
124
165
|
className,
|
|
125
166
|
...props
|
|
126
167
|
}) {
|
|
127
|
-
return /* @__PURE__ */
|
|
168
|
+
return /* @__PURE__ */ jsx2(
|
|
128
169
|
DialogPrimitive.Overlay,
|
|
129
170
|
{
|
|
130
171
|
"data-slot": "dialog-overlay",
|
|
131
|
-
className:
|
|
172
|
+
className: cn2(
|
|
132
173
|
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
133
174
|
className
|
|
134
175
|
),
|
|
@@ -143,12 +184,12 @@ function DialogContent({
|
|
|
143
184
|
...props
|
|
144
185
|
}) {
|
|
145
186
|
return /* @__PURE__ */ jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [
|
|
146
|
-
/* @__PURE__ */
|
|
187
|
+
/* @__PURE__ */ jsx2(DialogOverlay, {}),
|
|
147
188
|
/* @__PURE__ */ jsxs(
|
|
148
189
|
DialogPrimitive.Content,
|
|
149
190
|
{
|
|
150
191
|
"data-slot": "dialog-content",
|
|
151
|
-
className:
|
|
192
|
+
className: cn2(
|
|
152
193
|
"bg-background 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 fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
|
|
153
194
|
className
|
|
154
195
|
),
|
|
@@ -161,8 +202,8 @@ function DialogContent({
|
|
|
161
202
|
"data-slot": "dialog-close",
|
|
162
203
|
className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground rounded-xs focus:outline-hidden absolute right-4 top-4 opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
163
204
|
children: [
|
|
164
|
-
/* @__PURE__ */
|
|
165
|
-
/* @__PURE__ */
|
|
205
|
+
/* @__PURE__ */ jsx2(XIcon, {}),
|
|
206
|
+
/* @__PURE__ */ jsx2("span", { className: "sr-only", children: "Close" })
|
|
166
207
|
]
|
|
167
208
|
}
|
|
168
209
|
)
|
|
@@ -172,21 +213,21 @@ function DialogContent({
|
|
|
172
213
|
] });
|
|
173
214
|
}
|
|
174
215
|
function DialogHeader({ className, ...props }) {
|
|
175
|
-
return /* @__PURE__ */
|
|
216
|
+
return /* @__PURE__ */ jsx2(
|
|
176
217
|
"div",
|
|
177
218
|
{
|
|
178
219
|
"data-slot": "dialog-header",
|
|
179
|
-
className:
|
|
220
|
+
className: cn2("flex flex-col gap-2 text-center sm:text-left", className),
|
|
180
221
|
...props
|
|
181
222
|
}
|
|
182
223
|
);
|
|
183
224
|
}
|
|
184
225
|
function DialogFooter({ className, ...props }) {
|
|
185
|
-
return /* @__PURE__ */
|
|
226
|
+
return /* @__PURE__ */ jsx2(
|
|
186
227
|
"div",
|
|
187
228
|
{
|
|
188
229
|
"data-slot": "dialog-footer",
|
|
189
|
-
className:
|
|
230
|
+
className: cn2(
|
|
190
231
|
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
191
232
|
className
|
|
192
233
|
),
|
|
@@ -198,11 +239,11 @@ function DialogTitle({
|
|
|
198
239
|
className,
|
|
199
240
|
...props
|
|
200
241
|
}) {
|
|
201
|
-
return /* @__PURE__ */
|
|
242
|
+
return /* @__PURE__ */ jsx2(
|
|
202
243
|
DialogPrimitive.Title,
|
|
203
244
|
{
|
|
204
245
|
"data-slot": "dialog-title",
|
|
205
|
-
className:
|
|
246
|
+
className: cn2("text-lg font-semibold leading-none", className),
|
|
206
247
|
...props
|
|
207
248
|
}
|
|
208
249
|
);
|
|
@@ -211,18 +252,18 @@ function DialogDescription({
|
|
|
211
252
|
className,
|
|
212
253
|
...props
|
|
213
254
|
}) {
|
|
214
|
-
return /* @__PURE__ */
|
|
255
|
+
return /* @__PURE__ */ jsx2(
|
|
215
256
|
DialogPrimitive.Description,
|
|
216
257
|
{
|
|
217
258
|
"data-slot": "dialog-description",
|
|
218
|
-
className:
|
|
259
|
+
className: cn2("text-muted-foreground text-sm", className),
|
|
219
260
|
...props
|
|
220
261
|
}
|
|
221
262
|
);
|
|
222
263
|
}
|
|
223
264
|
|
|
224
265
|
// src/index.ts
|
|
225
|
-
import { cn as
|
|
266
|
+
import { cn as cn3 } from "@foundrykit/utils";
|
|
226
267
|
export {
|
|
227
268
|
Avatar,
|
|
228
269
|
AvatarFallback,
|
|
@@ -292,7 +333,9 @@ export {
|
|
|
292
333
|
TabsList,
|
|
293
334
|
TabsTrigger,
|
|
294
335
|
Textarea,
|
|
336
|
+
Toggle,
|
|
295
337
|
badgeVariants,
|
|
296
338
|
buttonVariants,
|
|
297
|
-
|
|
339
|
+
cn3 as cn,
|
|
340
|
+
toggleVariants
|
|
298
341
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foundrykit/primitives",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"@radix-ui/react-slot": "^1.2.3",
|
|
33
33
|
"@radix-ui/react-switch": "^1.2.6",
|
|
34
34
|
"@radix-ui/react-tabs": "^1.1.13",
|
|
35
|
+
"@radix-ui/react-toggle": "^1.1.10",
|
|
35
36
|
"class-variance-authority": "^0.7.1",
|
|
36
37
|
"clsx": "^2.1.1",
|
|
37
38
|
"lucide-react": "^0.475.0",
|
|
@@ -40,8 +41,8 @@
|
|
|
40
41
|
"react-dom": "^19.1.1",
|
|
41
42
|
"tailwind-merge": "^3.3.1",
|
|
42
43
|
"zod": "^3.25.76",
|
|
43
|
-
"@foundrykit/types": "1.0.
|
|
44
|
-
"@foundrykit/utils": "1.0.
|
|
44
|
+
"@foundrykit/types": "1.0.6",
|
|
45
|
+
"@foundrykit/utils": "1.0.4"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@types/node": "^20.19.9",
|
|
@@ -51,8 +52,8 @@
|
|
|
51
52
|
"fs-extra": "^11.2.0",
|
|
52
53
|
"tsup": "^8.0.0",
|
|
53
54
|
"typescript": "^5.9.2",
|
|
54
|
-
"@foundrykit/eslint-config": "1.0.
|
|
55
|
-
"@foundrykit/typescript-config": "1.0.
|
|
55
|
+
"@foundrykit/eslint-config": "1.0.4",
|
|
56
|
+
"@foundrykit/typescript-config": "1.0.4"
|
|
56
57
|
},
|
|
57
58
|
"peerDependencies": {
|
|
58
59
|
"react": "^19.1.1",
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ComponentConfig } from '@foundrykit/types';
|
|
2
|
+
|
|
3
|
+
export const ToggleConfig: ComponentConfig = {
|
|
4
|
+
name: 'Toggle',
|
|
5
|
+
description: 'Toggle component',
|
|
6
|
+
category: 'primitives',
|
|
7
|
+
tags: ['toggle', 'input', 'form'],
|
|
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"><div class="h-3 w-3 rounded-full border border-gray-400"></div><div class="h-2 w-12 rounded bg-gray-400"></div></div>',
|
|
11
|
+
},
|
|
12
|
+
variants: [
|
|
13
|
+
{
|
|
14
|
+
name: 'Default',
|
|
15
|
+
description: 'Default toggle',
|
|
16
|
+
code: '<Toggle />',
|
|
17
|
+
preview: {
|
|
18
|
+
type: 'component',
|
|
19
|
+
component: 'Toggle',
|
|
20
|
+
props: {},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'Checked',
|
|
25
|
+
description: 'Checked toggle',
|
|
26
|
+
code: '<Toggle checked />',
|
|
27
|
+
preview: {
|
|
28
|
+
type: 'component',
|
|
29
|
+
component: 'Toggle',
|
|
30
|
+
props: {
|
|
31
|
+
checked: true,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'Disabled',
|
|
37
|
+
description: 'Disabled toggle',
|
|
38
|
+
code: '<Toggle disabled />',
|
|
39
|
+
preview: {
|
|
40
|
+
type: 'component',
|
|
41
|
+
component: 'Toggle',
|
|
42
|
+
props: {
|
|
43
|
+
disabled: true,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'Custom Style',
|
|
49
|
+
description: 'Toggle with custom styling',
|
|
50
|
+
code: '<Toggle className="h-12 text-lg" />',
|
|
51
|
+
preview: {
|
|
52
|
+
type: 'component',
|
|
53
|
+
component: 'Toggle',
|
|
54
|
+
props: {
|
|
55
|
+
className: 'h-12 text-lg',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
dependencies: ['utils'],
|
|
61
|
+
packageDependencies: [
|
|
62
|
+
'lucide-react',
|
|
63
|
+
'@radix-ui/react-toggle',
|
|
64
|
+
'class-variance-authority',
|
|
65
|
+
],
|
|
66
|
+
files: ['components/toggle/index.tsx'],
|
|
67
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type * as React from 'react';
|
|
4
|
+
import * as TogglePrimitive from '@radix-ui/react-toggle';
|
|
5
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
6
|
+
|
|
7
|
+
import { cn } from '@foundrykit/utils';
|
|
8
|
+
|
|
9
|
+
const toggleVariants = cva(
|
|
10
|
+
"inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",
|
|
11
|
+
{
|
|
12
|
+
variants: {
|
|
13
|
+
variant: {
|
|
14
|
+
default: 'bg-transparent',
|
|
15
|
+
outline:
|
|
16
|
+
'border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground',
|
|
17
|
+
},
|
|
18
|
+
size: {
|
|
19
|
+
default: 'h-9 px-2 min-w-9',
|
|
20
|
+
sm: 'h-8 px-1.5 min-w-8',
|
|
21
|
+
lg: 'h-10 px-2.5 min-w-10',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
variant: 'default',
|
|
26
|
+
size: 'default',
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
function Toggle({
|
|
32
|
+
className,
|
|
33
|
+
variant,
|
|
34
|
+
size,
|
|
35
|
+
...props
|
|
36
|
+
}: React.ComponentProps<typeof TogglePrimitive.Root> &
|
|
37
|
+
VariantProps<typeof toggleVariants>) {
|
|
38
|
+
return (
|
|
39
|
+
<TogglePrimitive.Root
|
|
40
|
+
data-slot='toggle'
|
|
41
|
+
className={cn(toggleVariants({ variant, size, className }))}
|
|
42
|
+
{...props}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { Toggle, toggleVariants };
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export { Button, buttonVariants } from './components/button/index.js';
|
|
3
3
|
export { Input } from './components/input/index.js';
|
|
4
4
|
export { Badge, badgeVariants } from './components/badge/index.js';
|
|
5
|
+
export { Toggle, toggleVariants } from './components/toggle/index.js';
|
|
5
6
|
export {
|
|
6
7
|
Card,
|
|
7
8
|
CardHeader,
|
package/components.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://ui.shadcn.com/schema.json",
|
|
3
|
-
"style": "new-york",
|
|
4
|
-
"rsc": true,
|
|
5
|
-
"tsx": true,
|
|
6
|
-
"tailwind": {
|
|
7
|
-
"config": "",
|
|
8
|
-
"css": "@foundrykit/tokens/globals.css",
|
|
9
|
-
"baseColor": "neutral",
|
|
10
|
-
"cssVariables": true
|
|
11
|
-
},
|
|
12
|
-
"iconLibrary": "lucide",
|
|
13
|
-
"aliases": {
|
|
14
|
-
"components": "@workspace/ui/components",
|
|
15
|
-
"utils": "@workspace/ui/lib/utils",
|
|
16
|
-
"hooks": "@workspace/ui/hooks",
|
|
17
|
-
"lib": "@workspace/ui/lib",
|
|
18
|
-
"ui": "@workspace/ui/components"
|
|
19
|
-
}
|
|
20
|
-
}
|