@regardio/react 0.7.23 → 0.8.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.
- package/dist/button/index.d.mts +2 -2
- package/dist/button/index.mjs +2 -2
- package/dist/button-BllZdqCA.mjs +109 -0
- package/dist/carousel/index.mjs +1 -1
- package/dist/checkbox/index.mjs +12 -17
- package/dist/combobox/index.d.mts +142 -0
- package/dist/combobox/index.mjs +238 -0
- package/dist/field/index.d.mts +2 -2
- package/dist/field/index.mjs +26 -26
- package/dist/fieldset/index.d.mts +2 -2
- package/dist/fieldset/index.mjs +18 -21
- package/dist/icon-button/index.d.mts +1 -1
- package/dist/icon-button/index.mjs +1 -1
- package/dist/index-BTB1biC_.d.mts +19 -0
- package/dist/index-DEHa010W.d.mts +35 -0
- package/dist/input/index.d.mts +1 -1
- package/dist/input/index.mjs +1 -1
- package/dist/input-BHRHF8xW.mjs +62 -0
- package/dist/password-input/index.d.mts +2 -2
- package/dist/password-input/index.mjs +5 -6
- package/dist/radio/index.mjs +12 -17
- package/dist/slider/index.mjs +6 -13
- package/dist/switch/index.mjs +7 -12
- package/dist/text/index.d.mts +6 -3
- package/dist/text/index.mjs +6 -3
- package/dist/toggle/index.mjs +44 -29
- package/package.json +39 -27
- package/src/button/button.test.tsx +12 -8
- package/src/button/button.tsx +50 -59
- package/src/button/index.ts +2 -2
- package/src/checkbox/checkbox.tsx +11 -14
- package/src/combobox/combobox.stories.tsx +137 -0
- package/src/combobox/combobox.tsx +435 -0
- package/src/combobox/index.ts +2 -0
- package/src/field/field.test.tsx +1 -1
- package/src/field/field.tsx +21 -13
- package/src/fieldset/fieldset.test.tsx +1 -1
- package/src/fieldset/fieldset.tsx +6 -6
- package/src/icon-button/icon-button.test.tsx +1 -1
- package/src/input/input.stories.tsx +0 -11
- package/src/input/input.test.tsx +5 -2
- package/src/input/input.tsx +34 -75
- package/src/password-input/password-input.tsx +4 -5
- package/src/radio/radio.tsx +11 -14
- package/src/slider/slider.tsx +6 -8
- package/src/storybook.css +27 -0
- package/src/switch/switch.tsx +6 -11
- package/src/text/text.tsx +6 -3
- package/src/toggle/toggle.test.tsx +1 -2
- package/src/toggle/toggle.tsx +44 -29
- package/dist/button-wigUM1BB.mjs +0 -127
- package/dist/index-B_G_f749.d.mts +0 -29
- package/dist/index-DH3W0i5O.d.mts +0 -35
- package/dist/input-C2SM4-AB.mjs +0 -71
package/src/button/button.tsx
CHANGED
|
@@ -2,80 +2,72 @@ import { Button as BaseUIButton } from '@base-ui/react/button';
|
|
|
2
2
|
import { tv } from '@regardio/tailwind/utils';
|
|
3
3
|
import type { ComponentProps } from 'react';
|
|
4
4
|
|
|
5
|
-
const buttonVariants = {
|
|
5
|
+
export const buttonVariants = {
|
|
6
6
|
destructive: [
|
|
7
|
-
'
|
|
8
|
-
'
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
7
|
+
'inline-flex',
|
|
8
|
+
'items-center',
|
|
9
|
+
'justify-center',
|
|
10
|
+
'transition-colors',
|
|
11
|
+
'bg-destructive',
|
|
12
|
+
'text-destructive-foreground',
|
|
13
|
+
'border-destructive',
|
|
14
|
+
'hover:bg-destructive-hover',
|
|
15
|
+
'hover:border-destructive-hover',
|
|
15
16
|
],
|
|
16
17
|
ghost: [
|
|
18
|
+
'inline-flex',
|
|
19
|
+
'items-center',
|
|
20
|
+
'justify-center',
|
|
21
|
+
'transition-colors',
|
|
17
22
|
'bg-transparent',
|
|
18
|
-
'text-
|
|
23
|
+
'text-foreground',
|
|
19
24
|
'border-transparent',
|
|
20
|
-
'hover:bg-
|
|
21
|
-
'hover:border-transparent',
|
|
22
|
-
'focus-visible:ring-2',
|
|
23
|
-
'focus-visible:ring-gray-500',
|
|
24
|
-
'focus-visible:ring-offset-2',
|
|
25
|
+
'hover:bg-muted',
|
|
25
26
|
],
|
|
26
27
|
outline: [
|
|
28
|
+
'inline-flex',
|
|
29
|
+
'items-center',
|
|
30
|
+
'justify-center',
|
|
31
|
+
'transition-colors',
|
|
27
32
|
'bg-transparent',
|
|
28
|
-
'text-
|
|
29
|
-
'border-
|
|
30
|
-
'hover:bg-
|
|
31
|
-
'hover:border-gray-400',
|
|
32
|
-
'focus-visible:ring-2',
|
|
33
|
-
'focus-visible:ring-gray-500',
|
|
34
|
-
'focus-visible:ring-offset-2',
|
|
33
|
+
'text-foreground',
|
|
34
|
+
'border-current',
|
|
35
|
+
'hover:bg-muted',
|
|
35
36
|
],
|
|
36
37
|
primary: [
|
|
37
|
-
'
|
|
38
|
-
'
|
|
39
|
-
'
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'
|
|
43
|
-
'
|
|
44
|
-
'
|
|
38
|
+
'inline-flex',
|
|
39
|
+
'items-center',
|
|
40
|
+
'justify-center',
|
|
41
|
+
'transition-colors',
|
|
42
|
+
'bg-primary',
|
|
43
|
+
'text-primary-foreground',
|
|
44
|
+
'border-primary',
|
|
45
|
+
'hover:bg-primary-hover',
|
|
46
|
+
'hover:border-primary-hover',
|
|
45
47
|
],
|
|
46
48
|
secondary: [
|
|
47
|
-
'bg-gray-100',
|
|
48
|
-
'text-gray-900',
|
|
49
|
-
'border-gray-300',
|
|
50
|
-
'hover:bg-gray-200',
|
|
51
|
-
'hover:border-gray-400',
|
|
52
|
-
'focus-visible:ring-2',
|
|
53
|
-
'focus-visible:ring-gray-500',
|
|
54
|
-
'focus-visible:ring-offset-2',
|
|
55
|
-
],
|
|
56
|
-
} as const;
|
|
57
|
-
|
|
58
|
-
const buttonSizes = {
|
|
59
|
-
'2xl': ['px-10', 'py-5', 'text-2xl', 'font-medium', 'rounded-lg'],
|
|
60
|
-
lg: ['px-6', 'py-3', 'text-lg', 'font-medium', 'rounded-lg'],
|
|
61
|
-
md: ['px-4', 'py-2', 'text-base', 'font-medium', 'rounded-md'],
|
|
62
|
-
sm: ['px-3', 'py-1.5', 'text-sm', 'font-medium', 'rounded-md'],
|
|
63
|
-
xl: ['px-8', 'py-4', 'text-xl', 'font-medium', 'rounded-lg'],
|
|
64
|
-
} as const;
|
|
65
|
-
|
|
66
|
-
const button = tv({
|
|
67
|
-
base: [
|
|
68
49
|
'inline-flex',
|
|
69
50
|
'items-center',
|
|
70
51
|
'justify-center',
|
|
71
|
-
'border',
|
|
72
52
|
'transition-colors',
|
|
73
|
-
'
|
|
74
|
-
'
|
|
75
|
-
'
|
|
76
|
-
'
|
|
77
|
-
'
|
|
53
|
+
'bg-secondary',
|
|
54
|
+
'text-secondary-foreground',
|
|
55
|
+
'border-secondary',
|
|
56
|
+
'hover:bg-secondary-hover',
|
|
57
|
+
'hover:border-secondary-hover',
|
|
78
58
|
],
|
|
59
|
+
} as const;
|
|
60
|
+
|
|
61
|
+
export const buttonSizes = {
|
|
62
|
+
'2xl': ['px-8', 'py-4', 'text-xl'],
|
|
63
|
+
lg: ['px-6', 'py-3', 'text-lg'],
|
|
64
|
+
md: ['px-4', 'py-2', 'text-base'],
|
|
65
|
+
sm: ['px-3', 'py-1.5', 'text-sm'],
|
|
66
|
+
xl: ['px-7', 'py-3.5', 'text-lg'],
|
|
67
|
+
} as const;
|
|
68
|
+
|
|
69
|
+
export const button: ReturnType<typeof tv> = tv({
|
|
70
|
+
base: [],
|
|
79
71
|
defaultVariants: {
|
|
80
72
|
size: 'md',
|
|
81
73
|
variant: 'primary',
|
|
@@ -92,15 +84,14 @@ export type ButtonSize = keyof typeof buttonSizes;
|
|
|
92
84
|
export interface ButtonProps extends Omit<ComponentProps<typeof BaseUIButton>, 'className'> {
|
|
93
85
|
className?: string;
|
|
94
86
|
size?: ButtonSize;
|
|
95
|
-
type?: 'button' | 'submit' | 'reset';
|
|
96
87
|
variant?: ButtonVariant;
|
|
97
88
|
}
|
|
98
89
|
|
|
99
90
|
export const Button = ({
|
|
100
91
|
children,
|
|
101
92
|
className,
|
|
102
|
-
variant,
|
|
103
93
|
size,
|
|
94
|
+
variant,
|
|
104
95
|
...props
|
|
105
96
|
}: ButtonProps): React.JSX.Element => {
|
|
106
97
|
return (
|
package/src/button/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { ButtonProps,
|
|
2
|
-
export { Button } from './button';
|
|
1
|
+
export type { ButtonProps, ButtonVariant } from './button';
|
|
2
|
+
export { Button, buttonVariants } from './button';
|
|
@@ -4,22 +4,19 @@ import type { ComponentProps } from 'react';
|
|
|
4
4
|
|
|
5
5
|
const checkboxRoot = tv({
|
|
6
6
|
base: [
|
|
7
|
-
'
|
|
8
|
-
'
|
|
7
|
+
'flex',
|
|
8
|
+
'items-center',
|
|
9
|
+
'justify-center',
|
|
9
10
|
'rounded',
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'focus:outline-none',
|
|
14
|
-
'focus:ring-2',
|
|
15
|
-
'focus:ring-blue-500',
|
|
16
|
-
'focus:ring-offset-2',
|
|
11
|
+
'focus-visible:outline-2',
|
|
12
|
+
'focus-visible:outline-offset-2',
|
|
13
|
+
'focus-visible:outline-ring',
|
|
17
14
|
'disabled:cursor-not-allowed',
|
|
18
|
-
'
|
|
19
|
-
'data-[
|
|
20
|
-
'data-[
|
|
15
|
+
'data-[checked]:bg-primary',
|
|
16
|
+
'data-[unchecked]:border',
|
|
17
|
+
'data-[unchecked]:border-current',
|
|
18
|
+
'data-[unchecked]:bg-background-muted',
|
|
21
19
|
'transition-colors',
|
|
22
|
-
'duration-200',
|
|
23
20
|
'cursor-pointer',
|
|
24
21
|
],
|
|
25
22
|
defaultVariants: {
|
|
@@ -35,7 +32,7 @@ const checkboxRoot = tv({
|
|
|
35
32
|
});
|
|
36
33
|
|
|
37
34
|
const checkboxIndicator = tv({
|
|
38
|
-
base: ['flex', '
|
|
35
|
+
base: ['flex', 'text-primary-foreground', 'data-[unchecked]:hidden'],
|
|
39
36
|
});
|
|
40
37
|
|
|
41
38
|
export type CheckboxSize = 'sm' | 'md' | 'lg';
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Combobox } from './combobox';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Combobox.Root> = {
|
|
5
|
+
component: Combobox.Root,
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: 'centered',
|
|
8
|
+
},
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
title: 'Components/Combobox',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof meta>;
|
|
15
|
+
|
|
16
|
+
const fruits = ['Apple', 'Banana', 'Cherry', 'Date', 'Elderberry', 'Fig', 'Grape'];
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
render: () => (
|
|
20
|
+
<div className="w-80">
|
|
21
|
+
<Combobox.Root items={fruits}>
|
|
22
|
+
<div className="block text-foreground mb-2">
|
|
23
|
+
Select a fruit
|
|
24
|
+
<Combobox.InputGroup className="mt-1">
|
|
25
|
+
<Combobox.Input placeholder="Search fruits..." />
|
|
26
|
+
<Combobox.Trigger>
|
|
27
|
+
<Combobox.Icon />
|
|
28
|
+
</Combobox.Trigger>
|
|
29
|
+
</Combobox.InputGroup>
|
|
30
|
+
</div>
|
|
31
|
+
<Combobox.Portal>
|
|
32
|
+
<Combobox.Positioner>
|
|
33
|
+
<Combobox.Popup>
|
|
34
|
+
<Combobox.List>
|
|
35
|
+
{fruits.map((fruit) => (
|
|
36
|
+
<Combobox.Item
|
|
37
|
+
key={fruit}
|
|
38
|
+
value={fruit}
|
|
39
|
+
>
|
|
40
|
+
<Combobox.ItemIndicator />
|
|
41
|
+
{fruit}
|
|
42
|
+
</Combobox.Item>
|
|
43
|
+
))}
|
|
44
|
+
</Combobox.List>
|
|
45
|
+
</Combobox.Popup>
|
|
46
|
+
</Combobox.Positioner>
|
|
47
|
+
</Combobox.Portal>
|
|
48
|
+
</Combobox.Root>
|
|
49
|
+
</div>
|
|
50
|
+
),
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const WithClear: Story = {
|
|
54
|
+
render: () => (
|
|
55
|
+
<div className="w-80">
|
|
56
|
+
<Combobox.Root items={fruits}>
|
|
57
|
+
<div className="block text-foreground mb-2">
|
|
58
|
+
Select a fruit
|
|
59
|
+
<Combobox.InputGroup className="mt-1">
|
|
60
|
+
<Combobox.Input
|
|
61
|
+
className="pr-20"
|
|
62
|
+
placeholder="Search fruits..."
|
|
63
|
+
/>
|
|
64
|
+
<Combobox.Clear />
|
|
65
|
+
<Combobox.Trigger>
|
|
66
|
+
<Combobox.Icon />
|
|
67
|
+
</Combobox.Trigger>
|
|
68
|
+
</Combobox.InputGroup>
|
|
69
|
+
</div>
|
|
70
|
+
<Combobox.Portal>
|
|
71
|
+
<Combobox.Positioner>
|
|
72
|
+
<Combobox.Popup>
|
|
73
|
+
<Combobox.List>
|
|
74
|
+
<Combobox.Empty>No results found</Combobox.Empty>
|
|
75
|
+
{fruits.map((fruit) => (
|
|
76
|
+
<Combobox.Item
|
|
77
|
+
key={fruit}
|
|
78
|
+
value={fruit}
|
|
79
|
+
>
|
|
80
|
+
<Combobox.ItemIndicator />
|
|
81
|
+
{fruit}
|
|
82
|
+
</Combobox.Item>
|
|
83
|
+
))}
|
|
84
|
+
</Combobox.List>
|
|
85
|
+
</Combobox.Popup>
|
|
86
|
+
</Combobox.Positioner>
|
|
87
|
+
</Combobox.Portal>
|
|
88
|
+
</Combobox.Root>
|
|
89
|
+
</div>
|
|
90
|
+
),
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const Multiple: Story = {
|
|
94
|
+
render: () => (
|
|
95
|
+
<div className="w-80">
|
|
96
|
+
<Combobox.Root
|
|
97
|
+
items={fruits}
|
|
98
|
+
multiple
|
|
99
|
+
>
|
|
100
|
+
<div className="block text-foreground mb-2">
|
|
101
|
+
Select fruits
|
|
102
|
+
<Combobox.InputGroup className="mt-1">
|
|
103
|
+
<Combobox.Chips>
|
|
104
|
+
<Combobox.Chip>
|
|
105
|
+
<Combobox.ChipRemove />
|
|
106
|
+
</Combobox.Chip>
|
|
107
|
+
<Combobox.Input
|
|
108
|
+
className="flex-1 min-w-[120px] bg-transparent focus-visible:outline-none"
|
|
109
|
+
placeholder="Search fruits..."
|
|
110
|
+
/>
|
|
111
|
+
</Combobox.Chips>
|
|
112
|
+
<Combobox.Trigger>
|
|
113
|
+
<Combobox.Icon />
|
|
114
|
+
</Combobox.Trigger>
|
|
115
|
+
</Combobox.InputGroup>
|
|
116
|
+
</div>
|
|
117
|
+
<Combobox.Portal>
|
|
118
|
+
<Combobox.Positioner>
|
|
119
|
+
<Combobox.Popup>
|
|
120
|
+
<Combobox.List>
|
|
121
|
+
{fruits.map((fruit) => (
|
|
122
|
+
<Combobox.Item
|
|
123
|
+
key={fruit}
|
|
124
|
+
value={fruit}
|
|
125
|
+
>
|
|
126
|
+
<Combobox.ItemIndicator />
|
|
127
|
+
{fruit}
|
|
128
|
+
</Combobox.Item>
|
|
129
|
+
))}
|
|
130
|
+
</Combobox.List>
|
|
131
|
+
</Combobox.Popup>
|
|
132
|
+
</Combobox.Positioner>
|
|
133
|
+
</Combobox.Portal>
|
|
134
|
+
</Combobox.Root>
|
|
135
|
+
</div>
|
|
136
|
+
),
|
|
137
|
+
};
|