@thangnqdev/ui 0.2.0 → 0.2.2
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/LICENSE +21 -21
- package/README.md +144 -142
- package/bin/cli.js +125 -0
- package/dist/bento/index.cjs.map +1 -1
- package/dist/bento/index.js +2 -2
- package/dist/buttons/index.cjs.map +1 -1
- package/dist/buttons/index.js +3 -3
- package/dist/{chunk-77KTYOMQ.js → chunk-2OXZK6IP.js} +3 -3
- package/dist/chunk-2OXZK6IP.js.map +1 -0
- package/dist/{chunk-4CRFNALF.js → chunk-4GNFT2ZJ.js} +7 -7
- package/dist/chunk-4GNFT2ZJ.js.map +1 -0
- package/dist/{chunk-2YJBW4E2.js → chunk-4S6L5V7X.js} +2 -2
- package/dist/chunk-4S6L5V7X.js.map +1 -0
- package/dist/{chunk-I2FQBMVW.js → chunk-66VWUJEI.js} +3 -3
- package/dist/chunk-66VWUJEI.js.map +1 -0
- package/dist/{chunk-YOCGBORV.js → chunk-7NMB2Y64.js} +4 -4
- package/dist/chunk-7NMB2Y64.js.map +1 -0
- package/dist/{chunk-V52JOSDF.js → chunk-A7P3O5Z5.js} +3 -3
- package/dist/chunk-A7P3O5Z5.js.map +1 -0
- package/dist/{chunk-ME4XILG5.js → chunk-ATYGDTMK.js} +5 -5
- package/dist/chunk-ATYGDTMK.js.map +1 -0
- package/dist/{chunk-S6XJMYME.js → chunk-C4SUXMI3.js} +3 -3
- package/dist/chunk-C4SUXMI3.js.map +1 -0
- package/dist/{chunk-EXFR2BFJ.js → chunk-DUPPPGXY.js} +7 -7
- package/dist/chunk-DUPPPGXY.js.map +1 -0
- package/dist/{chunk-I5O2WCGF.js → chunk-EU2LPUYP.js} +3 -3
- package/dist/chunk-EU2LPUYP.js.map +1 -0
- package/dist/{chunk-D7FB3TCA.js → chunk-GXI2H5XA.js} +3 -3
- package/dist/chunk-GXI2H5XA.js.map +1 -0
- package/dist/{chunk-ADO3SVUA.js → chunk-IABPUCAQ.js} +2 -2
- package/dist/chunk-IABPUCAQ.js.map +1 -0
- package/dist/{chunk-PC5SZFZC.js → chunk-JOKEKOP3.js} +8 -8
- package/dist/chunk-JOKEKOP3.js.map +1 -0
- package/dist/{chunk-GXWB6BSY.js → chunk-KUQWUTZA.js} +4 -4
- package/dist/chunk-KUQWUTZA.js.map +1 -0
- package/dist/{chunk-ZEDXARXW.js → chunk-U3J4UPV3.js} +2 -2
- package/dist/chunk-U3J4UPV3.js.map +1 -0
- package/dist/{chunk-DSEL7ELZ.js → chunk-VE2PNSDQ.js} +4 -4
- package/dist/chunk-VE2PNSDQ.js.map +1 -0
- package/dist/{chunk-YJ64RI7J.js → chunk-WAFHC4DQ.js} +3 -3
- package/dist/chunk-WAFHC4DQ.js.map +1 -0
- package/dist/{chunk-W5WNWTQC.js → chunk-YJ67WYVW.js} +5 -5
- package/dist/chunk-YJ67WYVW.js.map +1 -0
- package/dist/{chunk-4MS6ZHFQ.js → chunk-Z427NPMU.js} +7 -7
- package/dist/chunk-Z427NPMU.js.map +1 -0
- package/dist/core/index.cjs +4 -4
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +2 -2
- package/dist/data-display/index.cjs.map +1 -1
- package/dist/data-display/index.js +5 -5
- package/dist/feedback/index.cjs.map +1 -1
- package/dist/feedback/index.js +2 -2
- package/dist/forms/index.cjs.map +1 -1
- package/dist/forms/index.js +8 -8
- package/dist/glass/index.cjs.map +1 -1
- package/dist/glass/index.js +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -19
- package/dist/layout/index.cjs.map +1 -1
- package/dist/layout/index.js +2 -2
- package/dist/navigation/index.cjs.map +1 -1
- package/dist/navigation/index.js +6 -6
- package/dist/overlays/index.cjs.map +1 -1
- package/dist/overlays/index.js +7 -7
- package/dist/reset.css +45 -45
- package/dist/tokens.css +11 -11
- package/dist/typography/index.cjs.map +1 -1
- package/dist/typography/index.js +4 -4
- package/llms.txt +3 -3
- package/package.json +166 -159
- package/scripts/postinstall.js +125 -0
- package/src/bento/BentoCard.tsx +140 -140
- package/src/bento/BentoGrid.tsx +50 -50
- package/src/bento/index.ts +2 -2
- package/src/bento/tokens.css +46 -46
- package/src/buttons/Button.tsx +104 -104
- package/src/buttons/ButtonGroup.tsx +43 -43
- package/src/buttons/IconButton.tsx +79 -79
- package/src/buttons/SplitButton.tsx +186 -186
- package/src/buttons/ToggleButton.tsx +157 -157
- package/src/buttons/index.ts +5 -5
- package/src/buttons/tokens.css +6 -6
- package/src/core/ThemeProvider.tsx +133 -133
- package/src/core/index.ts +2 -2
- package/src/core/tokens.css +134 -134
- package/src/data-display/Accordion.tsx +147 -147
- package/src/data-display/Avatar.tsx +134 -134
- package/src/data-display/Card.tsx +112 -112
- package/src/data-display/Chip.tsx +74 -74
- package/src/data-display/DataTablePro.tsx +534 -534
- package/src/data-display/StatCard.tsx +60 -60
- package/src/data-display/Table.tsx +74 -74
- package/src/data-display/Timeline.tsx +62 -62
- package/src/data-display/TreeView.tsx +279 -279
- package/src/data-display/tokens.css +4 -4
- package/src/feedback/Alert.tsx +80 -80
- package/src/feedback/EmptyState.tsx +45 -45
- package/src/feedback/Skeleton.tsx +66 -66
- package/src/feedback/Spinner.tsx +65 -65
- package/src/feedback/index.ts +5 -5
- package/src/feedback/tokens.css +4 -4
- package/src/forms/Checkbox.tsx +149 -149
- package/src/forms/CheckboxGroup.tsx +76 -76
- package/src/forms/Combobox.tsx +512 -512
- package/src/forms/DatePicker.tsx +784 -784
- package/src/forms/FileUpload.tsx +266 -266
- package/src/forms/FormField.tsx +115 -115
- package/src/forms/Input.tsx +151 -151
- package/src/forms/NumberInput.tsx +262 -262
- package/src/forms/PasswordInput.tsx +35 -35
- package/src/forms/PinInput.tsx +139 -139
- package/src/forms/Radio.tsx +142 -142
- package/src/forms/RangeSlider.tsx +237 -237
- package/src/forms/SearchInput.tsx +34 -34
- package/src/forms/Select.tsx +103 -103
- package/src/forms/Slider.tsx +85 -85
- package/src/forms/Textarea.tsx +114 -114
- package/src/forms/tokens.css +6 -6
- package/src/glass/GlassButton.tsx +59 -59
- package/src/glass/GlassCard.tsx +71 -71
- package/src/glass/index.ts +3 -3
- package/src/glass/tokens.css +81 -81
- package/src/index.ts +26 -26
- package/src/layout/AspectRatio.tsx +39 -39
- package/src/layout/Container.tsx +53 -53
- package/src/layout/Divider.tsx +61 -61
- package/src/layout/Flex.tsx +79 -79
- package/src/layout/Grid.tsx +124 -124
- package/src/layout/PageLayout.tsx +59 -59
- package/src/layout/Section.tsx +47 -47
- package/src/layout/Spacer.tsx +30 -30
- package/src/layout/Stack.tsx +88 -88
- package/src/layout/tokens.css +8 -8
- package/src/navigation/Breadcrumb.tsx +73 -73
- package/src/navigation/CommandPalette.tsx +142 -142
- package/src/navigation/DropdownMenu.tsx +244 -244
- package/src/navigation/Pagination.tsx +114 -114
- package/src/navigation/Stepper.tsx +93 -93
- package/src/navigation/Tabs.tsx +265 -265
- package/src/navigation/index.ts +6 -6
- package/src/navigation/tokens.css +4 -4
- package/src/overlays/AlertDialog.tsx +63 -63
- package/src/overlays/BottomSheet.tsx +143 -143
- package/src/overlays/ContextMenu.tsx +161 -161
- package/src/overlays/Drawer.tsx +160 -160
- package/src/overlays/FocusTrap.tsx +122 -122
- package/src/overlays/Modal.tsx +296 -296
- package/src/overlays/Popover.tsx +156 -156
- package/src/overlays/Portal.tsx +23 -23
- package/src/overlays/Toast.tsx +175 -175
- package/src/overlays/Tooltip.tsx +125 -125
- package/src/overlays/tokens.css +8 -8
- package/src/registry/components.ts +1368 -1368
- package/src/styles/components.css +39 -39
- package/src/styles/index.css +5 -5
- package/src/styles/reset.css +45 -45
- package/src/styles/tokens.css +11 -11
- package/src/typography/Blockquote.tsx +32 -32
- package/src/typography/Code.tsx +89 -89
- package/src/typography/Heading.tsx +56 -56
- package/src/typography/Kbd.tsx +25 -25
- package/src/typography/Label.tsx +47 -47
- package/src/typography/Link.tsx +56 -56
- package/src/typography/Text.tsx +62 -62
- package/src/typography/index.ts +7 -7
- package/src/typography/tokens.css +5 -5
- package/src/utils/cn.ts +6 -6
- package/src/utils/scroll-lock.ts +19 -19
- package/src/utils/useControllableState.ts +54 -54
- package/ui-contract.json +1 -1
- package/dist/chunk-2YJBW4E2.js.map +0 -1
- package/dist/chunk-4CRFNALF.js.map +0 -1
- package/dist/chunk-4MS6ZHFQ.js.map +0 -1
- package/dist/chunk-77KTYOMQ.js.map +0 -1
- package/dist/chunk-ADO3SVUA.js.map +0 -1
- package/dist/chunk-D7FB3TCA.js.map +0 -1
- package/dist/chunk-DSEL7ELZ.js.map +0 -1
- package/dist/chunk-EXFR2BFJ.js.map +0 -1
- package/dist/chunk-GXWB6BSY.js.map +0 -1
- package/dist/chunk-I2FQBMVW.js.map +0 -1
- package/dist/chunk-I5O2WCGF.js.map +0 -1
- package/dist/chunk-ME4XILG5.js.map +0 -1
- package/dist/chunk-PC5SZFZC.js.map +0 -1
- package/dist/chunk-S6XJMYME.js.map +0 -1
- package/dist/chunk-V52JOSDF.js.map +0 -1
- package/dist/chunk-W5WNWTQC.js.map +0 -1
- package/dist/chunk-YJ64RI7J.js.map +0 -1
- package/dist/chunk-YOCGBORV.js.map +0 -1
- package/dist/chunk-ZEDXARXW.js.map +0 -1
package/src/layout/Container.tsx
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
|
-
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
-
import { cn } from '../utils/cn';
|
|
4
|
-
|
|
5
|
-
export const containerVariants = cva('w-full mx-auto', {
|
|
6
|
-
variants: {
|
|
7
|
-
size: {
|
|
8
|
-
sm: 'max-w-screen-sm',
|
|
9
|
-
md: 'max-w-screen-md',
|
|
10
|
-
lg: 'max-w-screen-lg',
|
|
11
|
-
xl: 'max-w-screen-xl',
|
|
12
|
-
'2xl': 'max-w-screen-2xl',
|
|
13
|
-
fluid: 'max-w-full',
|
|
14
|
-
},
|
|
15
|
-
padding: {
|
|
16
|
-
none: 'px-0',
|
|
17
|
-
sm: 'px-4',
|
|
18
|
-
md: 'px-6',
|
|
19
|
-
lg: 'px-8 sm:px-12',
|
|
20
|
-
},
|
|
21
|
-
centered: {
|
|
22
|
-
true: 'flex flex-col items-center justify-center',
|
|
23
|
-
false: '',
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
defaultVariants: {
|
|
27
|
-
size: 'xl',
|
|
28
|
-
padding: 'md',
|
|
29
|
-
centered: false,
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
export interface ContainerProps
|
|
34
|
-
extends React.HTMLAttributes<HTMLDivElement>,
|
|
35
|
-
VariantProps<typeof containerVariants> {
|
|
36
|
-
as?: React.ElementType;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const Container = forwardRef<HTMLDivElement, ContainerProps>(
|
|
40
|
-
({ className, size, padding, centered, as: Component = 'div', children, ...props }, ref) => {
|
|
41
|
-
return (
|
|
42
|
-
<Component
|
|
43
|
-
ref={ref}
|
|
44
|
-
className={cn(containerVariants({ size, padding, centered }), className)}
|
|
45
|
-
{...props}
|
|
46
|
-
>
|
|
47
|
-
{children}
|
|
48
|
-
</Component>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
Container.displayName = 'Container';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { cn } from '../utils/cn';
|
|
4
|
+
|
|
5
|
+
export const containerVariants = cva('w-full mx-auto', {
|
|
6
|
+
variants: {
|
|
7
|
+
size: {
|
|
8
|
+
sm: 'max-w-screen-sm',
|
|
9
|
+
md: 'max-w-screen-md',
|
|
10
|
+
lg: 'max-w-screen-lg',
|
|
11
|
+
xl: 'max-w-screen-xl',
|
|
12
|
+
'2xl': 'max-w-screen-2xl',
|
|
13
|
+
fluid: 'max-w-full',
|
|
14
|
+
},
|
|
15
|
+
padding: {
|
|
16
|
+
none: 'px-0',
|
|
17
|
+
sm: 'px-4',
|
|
18
|
+
md: 'px-6',
|
|
19
|
+
lg: 'px-8 sm:px-12',
|
|
20
|
+
},
|
|
21
|
+
centered: {
|
|
22
|
+
true: 'flex flex-col items-center justify-center',
|
|
23
|
+
false: '',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
defaultVariants: {
|
|
27
|
+
size: 'xl',
|
|
28
|
+
padding: 'md',
|
|
29
|
+
centered: false,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export interface ContainerProps
|
|
34
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
35
|
+
VariantProps<typeof containerVariants> {
|
|
36
|
+
as?: React.ElementType;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const Container = forwardRef<HTMLDivElement, ContainerProps>(
|
|
40
|
+
({ className, size, padding, centered, as: Component = 'div', children, ...props }, ref) => {
|
|
41
|
+
return (
|
|
42
|
+
<Component
|
|
43
|
+
ref={ref}
|
|
44
|
+
className={cn(containerVariants({ size, padding, centered }), className)}
|
|
45
|
+
{...props}
|
|
46
|
+
>
|
|
47
|
+
{children}
|
|
48
|
+
</Component>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
Container.displayName = 'Container';
|
package/src/layout/Divider.tsx
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
|
-
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
-
import { cn } from '../utils/cn';
|
|
4
|
-
|
|
5
|
-
export const dividerVariants = cva('border-0 flex-shrink-0', {
|
|
6
|
-
variants: {
|
|
7
|
-
orientation: {
|
|
8
|
-
horizontal: 'w-full h-px border-t border-[var(--ui-border-subtle)] my-4',
|
|
9
|
-
vertical: 'h-full w-px border-l border-[var(--ui-border-subtle)] mx-4 inline-block align-middle self-stretch',
|
|
10
|
-
},
|
|
11
|
-
variant: {
|
|
12
|
-
solid: 'border-solid',
|
|
13
|
-
dashed: 'border-dashed',
|
|
14
|
-
dotted: 'border-dotted',
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
defaultVariants: {
|
|
18
|
-
orientation: 'horizontal',
|
|
19
|
-
variant: 'solid',
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export interface DividerProps
|
|
24
|
-
extends React.HTMLAttributes<HTMLDivElement>,
|
|
25
|
-
VariantProps<typeof dividerVariants> {
|
|
26
|
-
label?: React.ReactNode;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const Divider = forwardRef<HTMLDivElement, DividerProps>(
|
|
30
|
-
({ className, orientation = 'horizontal', variant, label, children, ...props }, ref) => {
|
|
31
|
-
const content = label || children;
|
|
32
|
-
|
|
33
|
-
if (orientation === 'horizontal' && content) {
|
|
34
|
-
return (
|
|
35
|
-
<div
|
|
36
|
-
ref={ref}
|
|
37
|
-
role="separator"
|
|
38
|
-
aria-orientation="horizontal"
|
|
39
|
-
className={cn('flex items-center w-full my-4 text-xs font-medium text-[var(--ui-text-muted)]', className)}
|
|
40
|
-
{...props}
|
|
41
|
-
>
|
|
42
|
-
<div className={cn('flex-grow border-t border-[var(--ui-border-subtle)]', dividerVariants({ variant }))} />
|
|
43
|
-
<span className="px-3 select-none">{content}</span>
|
|
44
|
-
<div className={cn('flex-grow border-t border-[var(--ui-border-subtle)]', dividerVariants({ variant }))} />
|
|
45
|
-
</div>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<div
|
|
51
|
-
ref={ref}
|
|
52
|
-
role="separator"
|
|
53
|
-
aria-orientation={orientation || 'horizontal'}
|
|
54
|
-
className={cn(dividerVariants({ orientation, variant }), className)}
|
|
55
|
-
{...props}
|
|
56
|
-
/>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
Divider.displayName = 'Divider';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { cn } from '../utils/cn';
|
|
4
|
+
|
|
5
|
+
export const dividerVariants = cva('border-0 flex-shrink-0', {
|
|
6
|
+
variants: {
|
|
7
|
+
orientation: {
|
|
8
|
+
horizontal: 'w-full h-px border-t border-[var(--ui-border-subtle)] my-4',
|
|
9
|
+
vertical: 'h-full w-px border-l border-[var(--ui-border-subtle)] mx-4 inline-block align-middle self-stretch',
|
|
10
|
+
},
|
|
11
|
+
variant: {
|
|
12
|
+
solid: 'border-solid',
|
|
13
|
+
dashed: 'border-dashed',
|
|
14
|
+
dotted: 'border-dotted',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
defaultVariants: {
|
|
18
|
+
orientation: 'horizontal',
|
|
19
|
+
variant: 'solid',
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export interface DividerProps
|
|
24
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
25
|
+
VariantProps<typeof dividerVariants> {
|
|
26
|
+
label?: React.ReactNode;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const Divider = forwardRef<HTMLDivElement, DividerProps>(
|
|
30
|
+
({ className, orientation = 'horizontal', variant, label, children, ...props }, ref) => {
|
|
31
|
+
const content = label || children;
|
|
32
|
+
|
|
33
|
+
if (orientation === 'horizontal' && content) {
|
|
34
|
+
return (
|
|
35
|
+
<div
|
|
36
|
+
ref={ref}
|
|
37
|
+
role="separator"
|
|
38
|
+
aria-orientation="horizontal"
|
|
39
|
+
className={cn('flex items-center w-full my-4 text-xs font-medium text-[var(--ui-text-muted)]', className)}
|
|
40
|
+
{...props}
|
|
41
|
+
>
|
|
42
|
+
<div className={cn('flex-grow border-t border-[var(--ui-border-subtle)]', dividerVariants({ variant }))} />
|
|
43
|
+
<span className="px-3 select-none">{content}</span>
|
|
44
|
+
<div className={cn('flex-grow border-t border-[var(--ui-border-subtle)]', dividerVariants({ variant }))} />
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div
|
|
51
|
+
ref={ref}
|
|
52
|
+
role="separator"
|
|
53
|
+
aria-orientation={orientation || 'horizontal'}
|
|
54
|
+
className={cn(dividerVariants({ orientation, variant }), className)}
|
|
55
|
+
{...props}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
Divider.displayName = 'Divider';
|
package/src/layout/Flex.tsx
CHANGED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
|
-
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
-
import { cn } from '../utils/cn';
|
|
4
|
-
|
|
5
|
-
export const flexVariants = cva('flex', {
|
|
6
|
-
variants: {
|
|
7
|
-
direction: {
|
|
8
|
-
row: 'flex-row',
|
|
9
|
-
'row-reverse': 'flex-row-reverse',
|
|
10
|
-
column: 'flex-col',
|
|
11
|
-
'column-reverse': 'flex-col-reverse',
|
|
12
|
-
},
|
|
13
|
-
align: {
|
|
14
|
-
start: 'items-start',
|
|
15
|
-
center: 'items-center',
|
|
16
|
-
end: 'items-end',
|
|
17
|
-
stretch: 'items-stretch',
|
|
18
|
-
baseline: 'items-baseline',
|
|
19
|
-
},
|
|
20
|
-
justify: {
|
|
21
|
-
start: 'justify-start',
|
|
22
|
-
center: 'justify-center',
|
|
23
|
-
end: 'justify-end',
|
|
24
|
-
between: 'justify-between',
|
|
25
|
-
around: 'justify-around',
|
|
26
|
-
evenly: 'justify-evenly',
|
|
27
|
-
},
|
|
28
|
-
wrap: {
|
|
29
|
-
nowrap: 'flex-nowrap',
|
|
30
|
-
wrap: 'flex-wrap',
|
|
31
|
-
'wrap-reverse': 'flex-wrap-reverse',
|
|
32
|
-
},
|
|
33
|
-
gap: {
|
|
34
|
-
0: 'gap-0',
|
|
35
|
-
1: 'gap-1',
|
|
36
|
-
2: 'gap-2',
|
|
37
|
-
3: 'gap-3',
|
|
38
|
-
4: 'gap-4',
|
|
39
|
-
5: 'gap-5',
|
|
40
|
-
6: 'gap-6',
|
|
41
|
-
8: 'gap-8',
|
|
42
|
-
10: 'gap-10',
|
|
43
|
-
12: 'gap-12',
|
|
44
|
-
},
|
|
45
|
-
inline: {
|
|
46
|
-
true: 'inline-flex',
|
|
47
|
-
false: 'flex',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
defaultVariants: {
|
|
51
|
-
direction: 'row',
|
|
52
|
-
align: 'stretch',
|
|
53
|
-
justify: 'start',
|
|
54
|
-
wrap: 'nowrap',
|
|
55
|
-
inline: false,
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
export interface FlexProps
|
|
60
|
-
extends React.HTMLAttributes<HTMLDivElement>,
|
|
61
|
-
VariantProps<typeof flexVariants> {
|
|
62
|
-
as?: React.ElementType;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export const Flex = forwardRef<HTMLDivElement, FlexProps>(
|
|
66
|
-
({ className, direction, align, justify, wrap, gap, inline, as: Component = 'div', children, ...props }, ref) => {
|
|
67
|
-
return (
|
|
68
|
-
<Component
|
|
69
|
-
ref={ref}
|
|
70
|
-
className={cn(flexVariants({ direction, align, justify, wrap, gap, inline }), className)}
|
|
71
|
-
{...props}
|
|
72
|
-
>
|
|
73
|
-
{children}
|
|
74
|
-
</Component>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
Flex.displayName = 'Flex';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { cn } from '../utils/cn';
|
|
4
|
+
|
|
5
|
+
export const flexVariants = cva('flex', {
|
|
6
|
+
variants: {
|
|
7
|
+
direction: {
|
|
8
|
+
row: 'flex-row',
|
|
9
|
+
'row-reverse': 'flex-row-reverse',
|
|
10
|
+
column: 'flex-col',
|
|
11
|
+
'column-reverse': 'flex-col-reverse',
|
|
12
|
+
},
|
|
13
|
+
align: {
|
|
14
|
+
start: 'items-start',
|
|
15
|
+
center: 'items-center',
|
|
16
|
+
end: 'items-end',
|
|
17
|
+
stretch: 'items-stretch',
|
|
18
|
+
baseline: 'items-baseline',
|
|
19
|
+
},
|
|
20
|
+
justify: {
|
|
21
|
+
start: 'justify-start',
|
|
22
|
+
center: 'justify-center',
|
|
23
|
+
end: 'justify-end',
|
|
24
|
+
between: 'justify-between',
|
|
25
|
+
around: 'justify-around',
|
|
26
|
+
evenly: 'justify-evenly',
|
|
27
|
+
},
|
|
28
|
+
wrap: {
|
|
29
|
+
nowrap: 'flex-nowrap',
|
|
30
|
+
wrap: 'flex-wrap',
|
|
31
|
+
'wrap-reverse': 'flex-wrap-reverse',
|
|
32
|
+
},
|
|
33
|
+
gap: {
|
|
34
|
+
0: 'gap-0',
|
|
35
|
+
1: 'gap-1',
|
|
36
|
+
2: 'gap-2',
|
|
37
|
+
3: 'gap-3',
|
|
38
|
+
4: 'gap-4',
|
|
39
|
+
5: 'gap-5',
|
|
40
|
+
6: 'gap-6',
|
|
41
|
+
8: 'gap-8',
|
|
42
|
+
10: 'gap-10',
|
|
43
|
+
12: 'gap-12',
|
|
44
|
+
},
|
|
45
|
+
inline: {
|
|
46
|
+
true: 'inline-flex',
|
|
47
|
+
false: 'flex',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
defaultVariants: {
|
|
51
|
+
direction: 'row',
|
|
52
|
+
align: 'stretch',
|
|
53
|
+
justify: 'start',
|
|
54
|
+
wrap: 'nowrap',
|
|
55
|
+
inline: false,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export interface FlexProps
|
|
60
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
61
|
+
VariantProps<typeof flexVariants> {
|
|
62
|
+
as?: React.ElementType;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const Flex = forwardRef<HTMLDivElement, FlexProps>(
|
|
66
|
+
({ className, direction, align, justify, wrap, gap, inline, as: Component = 'div', children, ...props }, ref) => {
|
|
67
|
+
return (
|
|
68
|
+
<Component
|
|
69
|
+
ref={ref}
|
|
70
|
+
className={cn(flexVariants({ direction, align, justify, wrap, gap, inline }), className)}
|
|
71
|
+
{...props}
|
|
72
|
+
>
|
|
73
|
+
{children}
|
|
74
|
+
</Component>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
Flex.displayName = 'Flex';
|
package/src/layout/Grid.tsx
CHANGED
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
|
-
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
-
import { cn } from '../utils/cn';
|
|
4
|
-
|
|
5
|
-
export const gridVariants = cva('grid', {
|
|
6
|
-
variants: {
|
|
7
|
-
cols: {
|
|
8
|
-
1: 'grid-cols-1',
|
|
9
|
-
2: 'grid-cols-1 sm:grid-cols-2',
|
|
10
|
-
3: 'grid-cols-1 sm:grid-cols-2 md:grid-cols-3',
|
|
11
|
-
4: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-4',
|
|
12
|
-
5: 'grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-5',
|
|
13
|
-
6: 'grid-cols-2 sm:grid-cols-3 lg:grid-cols-6',
|
|
14
|
-
12: 'grid-cols-12',
|
|
15
|
-
},
|
|
16
|
-
gap: {
|
|
17
|
-
0: 'gap-0',
|
|
18
|
-
1: 'gap-1',
|
|
19
|
-
2: 'gap-2',
|
|
20
|
-
3: 'gap-3',
|
|
21
|
-
4: 'gap-4',
|
|
22
|
-
5: 'gap-5',
|
|
23
|
-
6: 'gap-6',
|
|
24
|
-
8: 'gap-8',
|
|
25
|
-
10: 'gap-10',
|
|
26
|
-
12: 'gap-12',
|
|
27
|
-
},
|
|
28
|
-
flow: {
|
|
29
|
-
row: 'grid-flow-row',
|
|
30
|
-
col: 'grid-flow-col',
|
|
31
|
-
dense: 'grid-flow-dense',
|
|
32
|
-
'row-dense': 'grid-flow-row-dense',
|
|
33
|
-
'col-dense': 'grid-flow-col-dense',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
defaultVariants: {
|
|
37
|
-
cols: 1,
|
|
38
|
-
gap: 4,
|
|
39
|
-
flow: 'row',
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
export interface GridProps
|
|
44
|
-
extends React.HTMLAttributes<HTMLDivElement>,
|
|
45
|
-
VariantProps<typeof gridVariants> {
|
|
46
|
-
as?: React.ElementType;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const Grid = forwardRef<HTMLDivElement, GridProps>(
|
|
50
|
-
({ className, cols, gap, flow, as: Component = 'div', children, ...props }, ref) => {
|
|
51
|
-
return (
|
|
52
|
-
<Component
|
|
53
|
-
ref={ref}
|
|
54
|
-
className={cn(gridVariants({ cols, gap, flow }), className)}
|
|
55
|
-
{...props}
|
|
56
|
-
>
|
|
57
|
-
{children}
|
|
58
|
-
</Component>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
Grid.displayName = 'Grid';
|
|
63
|
-
|
|
64
|
-
export const gridItemVariants = cva('', {
|
|
65
|
-
variants: {
|
|
66
|
-
colSpan: {
|
|
67
|
-
1: 'col-span-1',
|
|
68
|
-
2: 'col-span-2',
|
|
69
|
-
3: 'col-span-3',
|
|
70
|
-
4: 'col-span-4',
|
|
71
|
-
5: 'col-span-5',
|
|
72
|
-
6: 'col-span-6',
|
|
73
|
-
7: 'col-span-7',
|
|
74
|
-
8: 'col-span-8',
|
|
75
|
-
9: 'col-span-9',
|
|
76
|
-
10: 'col-span-10',
|
|
77
|
-
11: 'col-span-11',
|
|
78
|
-
12: 'col-span-12',
|
|
79
|
-
full: 'col-span-full',
|
|
80
|
-
},
|
|
81
|
-
rowSpan: {
|
|
82
|
-
1: 'row-span-1',
|
|
83
|
-
2: 'row-span-2',
|
|
84
|
-
3: 'row-span-3',
|
|
85
|
-
4: 'row-span-4',
|
|
86
|
-
5: 'row-span-5',
|
|
87
|
-
6: 'row-span-6',
|
|
88
|
-
full: 'row-span-full',
|
|
89
|
-
},
|
|
90
|
-
colStart: {
|
|
91
|
-
1: 'col-start-1',
|
|
92
|
-
2: 'col-start-2',
|
|
93
|
-
3: 'col-start-3',
|
|
94
|
-
4: 'col-start-4',
|
|
95
|
-
5: 'col-start-5',
|
|
96
|
-
6: 'col-start-6',
|
|
97
|
-
auto: 'col-start-auto',
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
defaultVariants: {
|
|
101
|
-
colSpan: 1,
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
export interface GridItemProps
|
|
106
|
-
extends React.HTMLAttributes<HTMLDivElement>,
|
|
107
|
-
VariantProps<typeof gridItemVariants> {
|
|
108
|
-
as?: React.ElementType;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export const GridItem = forwardRef<HTMLDivElement, GridItemProps>(
|
|
112
|
-
({ className, colSpan, rowSpan, colStart, as: Component = 'div', children, ...props }, ref) => {
|
|
113
|
-
return (
|
|
114
|
-
<Component
|
|
115
|
-
ref={ref}
|
|
116
|
-
className={cn(gridItemVariants({ colSpan, rowSpan, colStart }), className)}
|
|
117
|
-
{...props}
|
|
118
|
-
>
|
|
119
|
-
{children}
|
|
120
|
-
</Component>
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
);
|
|
124
|
-
GridItem.displayName = 'GridItem';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { cn } from '../utils/cn';
|
|
4
|
+
|
|
5
|
+
export const gridVariants = cva('grid', {
|
|
6
|
+
variants: {
|
|
7
|
+
cols: {
|
|
8
|
+
1: 'grid-cols-1',
|
|
9
|
+
2: 'grid-cols-1 sm:grid-cols-2',
|
|
10
|
+
3: 'grid-cols-1 sm:grid-cols-2 md:grid-cols-3',
|
|
11
|
+
4: 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-4',
|
|
12
|
+
5: 'grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-5',
|
|
13
|
+
6: 'grid-cols-2 sm:grid-cols-3 lg:grid-cols-6',
|
|
14
|
+
12: 'grid-cols-12',
|
|
15
|
+
},
|
|
16
|
+
gap: {
|
|
17
|
+
0: 'gap-0',
|
|
18
|
+
1: 'gap-1',
|
|
19
|
+
2: 'gap-2',
|
|
20
|
+
3: 'gap-3',
|
|
21
|
+
4: 'gap-4',
|
|
22
|
+
5: 'gap-5',
|
|
23
|
+
6: 'gap-6',
|
|
24
|
+
8: 'gap-8',
|
|
25
|
+
10: 'gap-10',
|
|
26
|
+
12: 'gap-12',
|
|
27
|
+
},
|
|
28
|
+
flow: {
|
|
29
|
+
row: 'grid-flow-row',
|
|
30
|
+
col: 'grid-flow-col',
|
|
31
|
+
dense: 'grid-flow-dense',
|
|
32
|
+
'row-dense': 'grid-flow-row-dense',
|
|
33
|
+
'col-dense': 'grid-flow-col-dense',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: {
|
|
37
|
+
cols: 1,
|
|
38
|
+
gap: 4,
|
|
39
|
+
flow: 'row',
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export interface GridProps
|
|
44
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
45
|
+
VariantProps<typeof gridVariants> {
|
|
46
|
+
as?: React.ElementType;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const Grid = forwardRef<HTMLDivElement, GridProps>(
|
|
50
|
+
({ className, cols, gap, flow, as: Component = 'div', children, ...props }, ref) => {
|
|
51
|
+
return (
|
|
52
|
+
<Component
|
|
53
|
+
ref={ref}
|
|
54
|
+
className={cn(gridVariants({ cols, gap, flow }), className)}
|
|
55
|
+
{...props}
|
|
56
|
+
>
|
|
57
|
+
{children}
|
|
58
|
+
</Component>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
Grid.displayName = 'Grid';
|
|
63
|
+
|
|
64
|
+
export const gridItemVariants = cva('', {
|
|
65
|
+
variants: {
|
|
66
|
+
colSpan: {
|
|
67
|
+
1: 'col-span-1',
|
|
68
|
+
2: 'col-span-2',
|
|
69
|
+
3: 'col-span-3',
|
|
70
|
+
4: 'col-span-4',
|
|
71
|
+
5: 'col-span-5',
|
|
72
|
+
6: 'col-span-6',
|
|
73
|
+
7: 'col-span-7',
|
|
74
|
+
8: 'col-span-8',
|
|
75
|
+
9: 'col-span-9',
|
|
76
|
+
10: 'col-span-10',
|
|
77
|
+
11: 'col-span-11',
|
|
78
|
+
12: 'col-span-12',
|
|
79
|
+
full: 'col-span-full',
|
|
80
|
+
},
|
|
81
|
+
rowSpan: {
|
|
82
|
+
1: 'row-span-1',
|
|
83
|
+
2: 'row-span-2',
|
|
84
|
+
3: 'row-span-3',
|
|
85
|
+
4: 'row-span-4',
|
|
86
|
+
5: 'row-span-5',
|
|
87
|
+
6: 'row-span-6',
|
|
88
|
+
full: 'row-span-full',
|
|
89
|
+
},
|
|
90
|
+
colStart: {
|
|
91
|
+
1: 'col-start-1',
|
|
92
|
+
2: 'col-start-2',
|
|
93
|
+
3: 'col-start-3',
|
|
94
|
+
4: 'col-start-4',
|
|
95
|
+
5: 'col-start-5',
|
|
96
|
+
6: 'col-start-6',
|
|
97
|
+
auto: 'col-start-auto',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
defaultVariants: {
|
|
101
|
+
colSpan: 1,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
export interface GridItemProps
|
|
106
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
107
|
+
VariantProps<typeof gridItemVariants> {
|
|
108
|
+
as?: React.ElementType;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export const GridItem = forwardRef<HTMLDivElement, GridItemProps>(
|
|
112
|
+
({ className, colSpan, rowSpan, colStart, as: Component = 'div', children, ...props }, ref) => {
|
|
113
|
+
return (
|
|
114
|
+
<Component
|
|
115
|
+
ref={ref}
|
|
116
|
+
className={cn(gridItemVariants({ colSpan, rowSpan, colStart }), className)}
|
|
117
|
+
{...props}
|
|
118
|
+
>
|
|
119
|
+
{children}
|
|
120
|
+
</Component>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
GridItem.displayName = 'GridItem';
|