@twintag/twintag-form 1.5.0 → 1.6.1
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 +9 -10
- package/CHANGELOG.md +12 -0
- package/dist/common/button.d.ts +5 -86
- package/dist/common/calendar.d.ts +3 -81
- package/dist/common/form.d.ts +11 -91
- package/dist/common/input.d.ts +4 -149
- package/dist/common/label.d.ts +2 -23
- package/dist/common/textarea.d.ts +2 -75
- package/dist/components/containers/accordion.d.ts +1 -1
- package/dist/components/fields/date-picker.d.ts +1 -2
- package/dist/components/form.d.ts +2 -2
- package/dist/components/provider.d.ts +4 -4
- package/dist/index.cjs +1 -0
- package/dist/index.js +4456 -0
- package/dist/webcomponent.cjs +1 -1
- package/dist/webcomponent.js +140 -3736
- package/lib/common/button.tsx +6 -6
- package/lib/common/calendar.tsx +11 -10
- package/lib/common/checkbox.tsx +3 -3
- package/lib/common/form.tsx +3 -3
- package/lib/common/icon.tsx +1 -1
- package/lib/common/input.tsx +4 -4
- package/lib/common/label.tsx +1 -1
- package/lib/common/popover.tsx +1 -1
- package/lib/common/radiogroup.tsx +2 -2
- package/lib/common/slider.tsx +3 -3
- package/lib/common/switch.tsx +3 -3
- package/lib/common/textarea.tsx +3 -3
- package/lib/components/containers/accordion.tsx +1 -1
- package/lib/components/containers/category.tsx +1 -1
- package/lib/components/fields/checkbox.tsx +1 -1
- package/lib/components/fields/date-picker.tsx +6 -6
- package/lib/components/fields/file.tsx +1 -1
- package/lib/components/fields/input.tsx +1 -1
- package/lib/components/fields/radiogroup.tsx +2 -2
- package/lib/components/fields/textarea.tsx +1 -1
- package/lib/components/fields/toggle.tsx +1 -1
- package/lib/components/fields/tri-toggle.tsx +4 -4
- package/lib/utils/data.ts +5 -3
- package/lib/utils/string.ts +3 -3
- package/lib/webcomponent.ts +0 -1
- package/package.json +8 -9
- package/tailwind.config.ts +21 -26
- package/tsconfig.json +0 -1
- package/vite.config.ts +13 -2
- package/.eslintrc.cjs +0 -9
- package/dist/react.cjs +0 -89
- package/dist/react.d.ts +0 -1
- package/dist/react.js +0 -22662
package/lib/common/button.tsx
CHANGED
|
@@ -6,20 +6,20 @@ import { tv } from 'tailwind-variants';
|
|
|
6
6
|
|
|
7
7
|
const buttonVariants = tv({
|
|
8
8
|
base: [
|
|
9
|
-
'inline-flex items-center justify-center whitespace-nowrap rounded-md font-medium transition-colors',
|
|
10
|
-
'ring-offset-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
9
|
+
'inline-flex items-center justify-center whitespace-nowrap rounded-tf-md font-medium transition-colors',
|
|
10
|
+
'ring-offset-background focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-tf-ring focus-visible:ring-offset-2',
|
|
11
11
|
'disabled:pointer-events-none disabled:opacity-50',
|
|
12
12
|
],
|
|
13
13
|
variants: {
|
|
14
14
|
variant: {
|
|
15
15
|
default:
|
|
16
|
-
'bg-primary-foreground text-primary shadow hover:bg-primary-foreground/90',
|
|
16
|
+
'bg-tf-primary-foreground text-tf-primary shadow hover:bg-tf-primary-foreground/90',
|
|
17
17
|
outline:
|
|
18
|
-
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
|
|
19
|
-
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
|
18
|
+
'border border-tf-input bg-tf-background hover:bg-tf-accent hover:text-tf-accent-foreground',
|
|
19
|
+
ghost: 'hover:bg-tf-accent hover:text-tf-accent-foreground',
|
|
20
20
|
},
|
|
21
21
|
size: {
|
|
22
|
-
sm: 'h-9 rounded-md px-3 text-sm',
|
|
22
|
+
sm: 'h-9 rounded-tf-md px-3 text-sm',
|
|
23
23
|
base: 'h-10 px-3 py-2 text-base',
|
|
24
24
|
},
|
|
25
25
|
},
|
package/lib/common/calendar.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
1
2
|
import type { VariantProps } from 'tailwind-variants';
|
|
2
3
|
|
|
3
|
-
import * as React from 'react';
|
|
4
4
|
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
5
5
|
import { DayPicker } from 'react-day-picker';
|
|
6
6
|
import { tv } from 'tailwind-variants';
|
|
@@ -24,22 +24,23 @@ const calendarVariants = tv({
|
|
|
24
24
|
nav_button_next: 'absolute right-1',
|
|
25
25
|
table: 'w-full border-collapse space-y-1',
|
|
26
26
|
head_row: 'flex',
|
|
27
|
-
head_cell:
|
|
27
|
+
head_cell:
|
|
28
|
+
'w-9 rounded-tf-md text-[0.8rem] font-normal text-tf-muted-foreground',
|
|
28
29
|
row: 'mt-2 flex w-full',
|
|
29
|
-
cell: 'relative h-9 w-9 p-0 text-center focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-transparent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-muted/50 [&:has([aria-selected].day-range-end)]:rounded-r-md',
|
|
30
|
+
cell: 'relative h-9 w-9 p-0 text-center focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-transparent first:[&:has([aria-selected])]:rounded-l-tf-md last:[&:has([aria-selected])]:rounded-r-tf-md [&:has([aria-selected].day-outside)]:bg-tf-muted/50 [&:has([aria-selected].day-range-end)]:rounded-r-tf-md',
|
|
30
31
|
day: buttonVariants({
|
|
31
32
|
variant: 'ghost',
|
|
32
33
|
className: 'h-9 w-9 p-0 font-normal aria-selected:opacity-100',
|
|
33
34
|
}),
|
|
34
35
|
day_range_end: 'day-range-end',
|
|
35
36
|
day_selected:
|
|
36
|
-
'bg-accent text-accent-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground',
|
|
37
|
-
day_today: 'bg-muted text-muted-foreground',
|
|
37
|
+
'bg-tf-accent text-tf-accent-foreground hover:bg-tf-accent hover:text-tf-accent-foreground focus:bg-tf-accent focus:text-tf-accent-foreground',
|
|
38
|
+
day_today: 'bg-tf-muted text-tf-muted-foreground',
|
|
38
39
|
day_outside:
|
|
39
|
-
'day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/30 aria-selected:text-accent-foreground',
|
|
40
|
-
day_disabled: 'text-muted-foreground opacity-50',
|
|
40
|
+
'day-outside text-tf-muted-foreground opacity-50 aria-selected:bg-tf-accent/30 aria-selected:text-tf-accent-foreground',
|
|
41
|
+
day_disabled: 'text-tf-muted-foreground opacity-50',
|
|
41
42
|
day_range_middle:
|
|
42
|
-
'aria-selected:bg-accent aria-selected:text-accent-foreground',
|
|
43
|
+
'aria-selected:bg-tf-accent aria-selected:text-tf-accent-foreground',
|
|
43
44
|
day_hidden: 'invisible',
|
|
44
45
|
},
|
|
45
46
|
variants: {
|
|
@@ -49,8 +50,8 @@ const calendarVariants = tv({
|
|
|
49
50
|
caption_dropdowns: [
|
|
50
51
|
'flex w-4/6 justify-center gap-1',
|
|
51
52
|
'[&>*>span]:hidden [&>*]:flex-1 [&>.rdp-vhidden]:hidden ',
|
|
52
|
-
'[&>*>select]:h-7 [&>*>select]:min-w-[3.6rem] [&>*>select]:rounded-md [&>*>select]:border [&>*>select]:border-input [&>*>select]:bg-background [&>*>select]:px-1',
|
|
53
|
-
'[&>*>select]:ring-offset-background [&>*>select]:focus-visible:outline-none [&>*>select]:focus-visible:ring-1 [&>*>select]:focus-visible:ring-ring',
|
|
53
|
+
'[&>*>select]:h-7 [&>*>select]:min-w-[3.6rem] [&>*>select]:rounded-tf-md [&>*>select]:border [&>*>select]:border-tf-input [&>*>select]:bg-tf-background [&>*>select]:px-1',
|
|
54
|
+
'[&>*>select]:ring-offset-tf-background [&>*>select]:focus-visible:outline-none [&>*>select]:focus-visible:ring-1 [&>*>select]:focus-visible:ring-tf-ring',
|
|
54
55
|
],
|
|
55
56
|
},
|
|
56
57
|
},
|
package/lib/common/checkbox.tsx
CHANGED
|
@@ -6,10 +6,10 @@ import { tv } from 'tailwind-variants';
|
|
|
6
6
|
const checkboxVariants = tv({
|
|
7
7
|
slots: {
|
|
8
8
|
root: [
|
|
9
|
-
'peer h-4 w-4 shrink-0 rounded-sm border border-accent shadow',
|
|
10
|
-
'focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1',
|
|
9
|
+
'peer h-4 w-4 shrink-0 rounded-tf-sm border border-tf-accent shadow',
|
|
10
|
+
'focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-tf-ring focus-visible:ring-offset-1',
|
|
11
11
|
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
12
|
-
'data-[state=checked]:bg-accent data-[state=checked]:text-accent-foreground',
|
|
12
|
+
'data-[state=checked]:bg-tf-accent data-[state=checked]:text-tf-accent-foreground',
|
|
13
13
|
],
|
|
14
14
|
indicator: 'flex items-center justify-center text-current',
|
|
15
15
|
icon: 'h-4 w-4',
|
package/lib/common/form.tsx
CHANGED
|
@@ -99,7 +99,7 @@ const formLabelVariants = tv({
|
|
|
99
99
|
base: '',
|
|
100
100
|
variants: {
|
|
101
101
|
error: {
|
|
102
|
-
true: 'text-destructive',
|
|
102
|
+
true: 'text-tf-destructive',
|
|
103
103
|
},
|
|
104
104
|
},
|
|
105
105
|
});
|
|
@@ -148,7 +148,7 @@ const FormControl = React.forwardRef<
|
|
|
148
148
|
FormControl.displayName = 'FormControl';
|
|
149
149
|
|
|
150
150
|
const formDescriptionVariants = tv({
|
|
151
|
-
base: 'text-muted-foreground',
|
|
151
|
+
base: 'text-tf-muted-foreground',
|
|
152
152
|
variants: {
|
|
153
153
|
size: {
|
|
154
154
|
sm: 'text-[0.8rem] leading-none',
|
|
@@ -178,7 +178,7 @@ const FormDescription = React.forwardRef<
|
|
|
178
178
|
FormDescription.displayName = 'FormDescription';
|
|
179
179
|
|
|
180
180
|
const formMessageVariants = tv({
|
|
181
|
-
base: 'font-medium text-destructive',
|
|
181
|
+
base: 'font-medium text-tf-destructive',
|
|
182
182
|
variants: {
|
|
183
183
|
size: {
|
|
184
184
|
sm: 'text-[0.8rem]',
|
package/lib/common/icon.tsx
CHANGED
package/lib/common/input.tsx
CHANGED
|
@@ -7,8 +7,8 @@ const inputVariants = tv({
|
|
|
7
7
|
slots: {
|
|
8
8
|
root: 'relative',
|
|
9
9
|
input: [
|
|
10
|
-
'flex h-10 w-full border-input bg-background py-2 text-primary-foreground placeholder:text-muted-foreground focus-visible:outline-none',
|
|
11
|
-
'file:border-0 file:bg-transparent file:px-0 file:font-medium file:text-primary-foreground',
|
|
10
|
+
'flex h-10 w-full border-tf-input bg-tf-background py-2 text-tf-primary-foreground placeholder:text-tf-muted-foreground focus-visible:outline-none',
|
|
11
|
+
'file:border-0 file:bg-transparent file:px-0 file:font-medium file:text-tf-primary-foreground',
|
|
12
12
|
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
13
13
|
],
|
|
14
14
|
},
|
|
@@ -16,10 +16,10 @@ const inputVariants = tv({
|
|
|
16
16
|
variant: {
|
|
17
17
|
default: {
|
|
18
18
|
input:
|
|
19
|
-
'rounded-md border px-3 ring-offset-background focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
19
|
+
'rounded-tf-md border px-3 ring-offset-tf-background focus-visible:ring-2 focus-visible:ring-tf-ring focus-visible:ring-offset-2',
|
|
20
20
|
},
|
|
21
21
|
outline: {
|
|
22
|
-
root: 'after:absolute after:left-0 after:top-[calc(100%_+_1px)] after:w-full after:rounded-full after:content-[""] focus-within:after:h-0.5 focus-within:after:bg-ring',
|
|
22
|
+
root: 'after:absolute after:left-0 after:top-[calc(100%_+_1px)] after:w-full after:rounded-full after:content-[""] focus-within:after:h-0.5 focus-within:after:bg-tf-ring',
|
|
23
23
|
input: 'border-b px-1',
|
|
24
24
|
},
|
|
25
25
|
},
|
package/lib/common/label.tsx
CHANGED
package/lib/common/popover.tsx
CHANGED
|
@@ -7,7 +7,7 @@ const Popover = PopoverPrimitive.Root;
|
|
|
7
7
|
const PopoverTrigger = PopoverPrimitive.Trigger;
|
|
8
8
|
|
|
9
9
|
const popoverContentVariants = tv({
|
|
10
|
-
base: 'z-50 w-72 rounded-md border bg-background p-4 text-foreground shadow-md outline-none',
|
|
10
|
+
base: 'z-50 w-72 rounded-tf-md border bg-tf-background p-4 text-tf-foreground shadow-md outline-none',
|
|
11
11
|
});
|
|
12
12
|
const PopoverContent = React.forwardRef<
|
|
13
13
|
React.ElementRef<typeof PopoverPrimitive.Content>,
|
|
@@ -23,8 +23,8 @@ RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
|
|
|
23
23
|
const radioGroupItemVariants = tv({
|
|
24
24
|
slots: {
|
|
25
25
|
item: [
|
|
26
|
-
'aspect-square h-4 w-4 items-center rounded-full border border-accent text-accent ring-offset-background',
|
|
27
|
-
'focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
26
|
+
'aspect-square h-4 w-4 items-center rounded-full border border-tf-accent text-tf-accent ring-offset-tf-background',
|
|
27
|
+
'focus:outline-none focus-visible:ring-2 focus-visible:ring-tf-ring focus-visible:ring-offset-2',
|
|
28
28
|
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
29
29
|
],
|
|
30
30
|
indicator: 'relative block h-full w-full',
|
package/lib/common/slider.tsx
CHANGED
|
@@ -5,10 +5,10 @@ import { tv } from 'tailwind-variants';
|
|
|
5
5
|
const sliderVariants = tv({
|
|
6
6
|
slots: {
|
|
7
7
|
root: 'relative flex w-full touch-none select-none items-center',
|
|
8
|
-
track: 'relative h-2 w-full grow overflow-hidden rounded-full bg-muted',
|
|
9
|
-
range: 'absolute h-full bg-accent',
|
|
8
|
+
track: 'relative h-2 w-full grow overflow-hidden rounded-full bg-tf-muted',
|
|
9
|
+
range: 'absolute h-full bg-tf-accent',
|
|
10
10
|
thumb:
|
|
11
|
-
'block h-5 w-5 rounded-full border-2 border-accent bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
|
|
11
|
+
'block h-5 w-5 rounded-full border-2 border-tf-accent bg-tf-background ring-offset-tf-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-tf-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
|
|
12
12
|
},
|
|
13
13
|
});
|
|
14
14
|
|
package/lib/common/switch.tsx
CHANGED
|
@@ -6,12 +6,12 @@ const switchVariants = tv({
|
|
|
6
6
|
slots: {
|
|
7
7
|
root: [
|
|
8
8
|
'peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors',
|
|
9
|
-
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
|
|
9
|
+
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-tf-ring focus-visible:ring-offset-2 focus-visible:ring-offset-tf-background',
|
|
10
10
|
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
11
|
-
'data-[state=checked]:bg-accent data-[state=unchecked]:bg-muted',
|
|
11
|
+
'data-[state=checked]:bg-tf-accent data-[state=unchecked]:bg-tf-muted',
|
|
12
12
|
],
|
|
13
13
|
thumb: [
|
|
14
|
-
'pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform',
|
|
14
|
+
'pointer-events-none block h-4 w-4 rounded-full bg-tf-background shadow-lg ring-0 transition-transform',
|
|
15
15
|
'data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0',
|
|
16
16
|
],
|
|
17
17
|
},
|
package/lib/common/textarea.tsx
CHANGED
|
@@ -7,7 +7,7 @@ const textareaVariants = tv({
|
|
|
7
7
|
slots: {
|
|
8
8
|
root: 'relative',
|
|
9
9
|
textarea: [
|
|
10
|
-
'flex min-h-[60px] w-full border-input bg-background py-2 text-primary-foreground shadow-sm placeholder:text-muted-foreground focus-visible:outline-none',
|
|
10
|
+
'flex min-h-[60px] w-full border-tf-input bg-tf-background py-2 text-tf-primary-foreground shadow-sm placeholder:text-tf-muted-foreground focus-visible:outline-none',
|
|
11
11
|
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
12
12
|
],
|
|
13
13
|
},
|
|
@@ -15,10 +15,10 @@ const textareaVariants = tv({
|
|
|
15
15
|
variant: {
|
|
16
16
|
default: {
|
|
17
17
|
textarea:
|
|
18
|
-
'rounded-md border px-3 ring-offset-background focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
18
|
+
'rounded-tf-md border px-3 ring-offset-tf-background focus-visible:ring-2 focus-visible:ring-tf-ring focus-visible:ring-offset-2',
|
|
19
19
|
},
|
|
20
20
|
outline: {
|
|
21
|
-
root: 'after:absolute after:left-0 after:top-[calc(100%_+_1px)] after:w-full after:rounded-full after:content-[""] focus-within:after:h-0.5 focus-within:after:bg-ring',
|
|
21
|
+
root: 'after:absolute after:left-0 after:top-[calc(100%_+_1px)] after:w-full after:rounded-full after:content-[""] focus-within:after:h-0.5 focus-within:after:bg-tf-ring',
|
|
22
22
|
textarea: 'border-b px-1',
|
|
23
23
|
},
|
|
24
24
|
},
|
|
@@ -8,7 +8,7 @@ import { useTwintagForm } from '@twintag/twintag-form/components/provider';
|
|
|
8
8
|
const categoryStyle = tv({
|
|
9
9
|
slots: {
|
|
10
10
|
container: 'relative w-full space-y-3',
|
|
11
|
-
heading: 'font-tf-font text-category',
|
|
11
|
+
heading: 'font-tf-font text-tf-category',
|
|
12
12
|
content: 'grid gap-3',
|
|
13
13
|
},
|
|
14
14
|
variants: {
|
|
@@ -48,7 +48,7 @@ export const Checkbox: FC<Props<'input'>> = ({ label, bind, options }) => {
|
|
|
48
48
|
{label}
|
|
49
49
|
{!isOptional ? (
|
|
50
50
|
<span className='ml-0.5 inline-block'>
|
|
51
|
-
<AsteriskIcon className='h-3 w-3 text-destructive' />
|
|
51
|
+
<AsteriskIcon className='h-3 w-3 text-tf-destructive' />
|
|
52
52
|
</span>
|
|
53
53
|
) : (
|
|
54
54
|
<></>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
1
2
|
import type { Props } from '@twintag/twintag-form/types';
|
|
2
3
|
|
|
3
|
-
import * as React from 'react';
|
|
4
4
|
import { format } from 'date-fns';
|
|
5
5
|
import { AsteriskIcon, Calendar as CalendarIcon } from 'lucide-react';
|
|
6
6
|
import { useFormContext } from 'react-hook-form';
|
|
@@ -26,7 +26,7 @@ import { useTwintagForm } from '@twintag/twintag-form/components/provider';
|
|
|
26
26
|
const datePickerTriggerVariants = tv({
|
|
27
27
|
slots: {
|
|
28
28
|
button: 'w-full justify-start text-left font-normal',
|
|
29
|
-
icon: 'ml-auto text-muted-foreground opacity-70',
|
|
29
|
+
icon: 'ml-auto text-tf-muted-foreground opacity-70',
|
|
30
30
|
},
|
|
31
31
|
variants: {
|
|
32
32
|
variant: {
|
|
@@ -35,12 +35,12 @@ const datePickerTriggerVariants = tv({
|
|
|
35
35
|
},
|
|
36
36
|
outline: {
|
|
37
37
|
button:
|
|
38
|
-
'rounded-none border-x-transparent border-t-transparent px-1 transition-none hover:bg-white hover:text-muted-foreground',
|
|
38
|
+
'rounded-none border-x-transparent border-t-transparent px-1 transition-none hover:bg-white hover:text-tf-muted-foreground',
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
41
|
withValue: {
|
|
42
42
|
true: {
|
|
43
|
-
button: 'text-muted-foreground',
|
|
43
|
+
button: 'text-tf-muted-foreground',
|
|
44
44
|
},
|
|
45
45
|
false: {
|
|
46
46
|
button: '',
|
|
@@ -95,7 +95,7 @@ export const DatePicker: React.FC<Props<'input'>> = ({
|
|
|
95
95
|
{label}
|
|
96
96
|
{!isOptional ? (
|
|
97
97
|
<span className='ml-0.5 inline-block'>
|
|
98
|
-
<AsteriskIcon className='h-3 w-3 text-destructive' />
|
|
98
|
+
<AsteriskIcon className='h-3 w-3 text-tf-destructive' />
|
|
99
99
|
</span>
|
|
100
100
|
) : (
|
|
101
101
|
<></>
|
|
@@ -137,7 +137,7 @@ export const DatePicker: React.FC<Props<'input'>> = ({
|
|
|
137
137
|
mode='single'
|
|
138
138
|
size={size}
|
|
139
139
|
selected={
|
|
140
|
-
!isNaN(new Date(field.value as Date).getTime())
|
|
140
|
+
!Number.isNaN(new Date(field.value as Date).getTime())
|
|
141
141
|
? new Date(field.value as Date)
|
|
142
142
|
: undefined
|
|
143
143
|
}
|
|
@@ -38,7 +38,7 @@ export const File: FC<Props<'input'>> = ({ label, bind, options }) => {
|
|
|
38
38
|
{label}
|
|
39
39
|
{!isOptional ? (
|
|
40
40
|
<span className='ml-0.5 inline-block'>
|
|
41
|
-
<AsteriskIcon className='h-3 w-3 text-destructive' />
|
|
41
|
+
<AsteriskIcon className='h-3 w-3 text-tf-destructive' />
|
|
42
42
|
</span>
|
|
43
43
|
) : (
|
|
44
44
|
<></>
|
|
@@ -39,7 +39,7 @@ export const Input: FC<Props<'input'>> = ({ label, bind, options }) => {
|
|
|
39
39
|
{label}
|
|
40
40
|
{!isOptional ? (
|
|
41
41
|
<span className='ml-0.5 inline-block'>
|
|
42
|
-
<AsteriskIcon className='h-3 w-3 text-destructive' />
|
|
42
|
+
<AsteriskIcon className='h-3 w-3 text-tf-destructive' />
|
|
43
43
|
</span>
|
|
44
44
|
) : (
|
|
45
45
|
<></>
|
|
@@ -45,7 +45,7 @@ export const RadioGroup: FC<
|
|
|
45
45
|
{label}
|
|
46
46
|
{!isOptional ? (
|
|
47
47
|
<span className='ml-0.5 inline-block'>
|
|
48
|
-
<AsteriskIcon className='h-3 w-3 text-destructive' />
|
|
48
|
+
<AsteriskIcon className='h-3 w-3 text-tf-destructive' />
|
|
49
49
|
</span>
|
|
50
50
|
) : (
|
|
51
51
|
<></>
|
|
@@ -82,7 +82,7 @@ export const RadioGroup: FC<
|
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
return
|
|
85
|
+
return null;
|
|
86
86
|
})}
|
|
87
87
|
</CommonRadioGroup>
|
|
88
88
|
</FormControl>
|
|
@@ -38,7 +38,7 @@ export const Textarea: FC<Props<'input'>> = ({ label, bind, options }) => {
|
|
|
38
38
|
{label}
|
|
39
39
|
{!isOptional ? (
|
|
40
40
|
<span className='ml-0.5 inline-block'>
|
|
41
|
-
<AsteriskIcon className='h-3 w-3 text-destructive' />
|
|
41
|
+
<AsteriskIcon className='h-3 w-3 text-tf-destructive' />
|
|
42
42
|
</span>
|
|
43
43
|
) : (
|
|
44
44
|
<></>
|
|
@@ -39,7 +39,7 @@ export const Toggle: FC<Props<'input'>> = ({ label, bind, options }) => {
|
|
|
39
39
|
{label}
|
|
40
40
|
{!isOptional ? (
|
|
41
41
|
<span className='ml-0.5 inline-block'>
|
|
42
|
-
<AsteriskIcon className='h-3 w-3 text-destructive' />
|
|
42
|
+
<AsteriskIcon className='h-3 w-3 text-tf-destructive' />
|
|
43
43
|
</span>
|
|
44
44
|
) : (
|
|
45
45
|
<></>
|
|
@@ -20,10 +20,10 @@ import { useTwintagForm } from '@twintag/twintag-form/components/provider';
|
|
|
20
20
|
const sliderVariants = tv({
|
|
21
21
|
slots: {
|
|
22
22
|
root: 'relative flex w-11 touch-none select-none items-center',
|
|
23
|
-
track: 'relative h-5 w-full grow overflow-hidden rounded-full bg-muted',
|
|
24
|
-
range: 'absolute h-full bg-accent',
|
|
23
|
+
track: 'relative h-5 w-full grow overflow-hidden rounded-full bg-tf-muted',
|
|
24
|
+
range: 'absolute h-full bg-tf-accent',
|
|
25
25
|
thumb:
|
|
26
|
-
'relative block h-4 w-4 rounded-full border-2 border-transparent bg-background shadow-lg focus-visible:outline-none focus-visible:ring-0 disabled:pointer-events-none disabled:opacity-50',
|
|
26
|
+
'relative block h-4 w-4 rounded-full border-2 border-transparent bg-tf-background shadow-lg focus-visible:outline-none focus-visible:ring-0 disabled:pointer-events-none disabled:opacity-50',
|
|
27
27
|
},
|
|
28
28
|
variants: {
|
|
29
29
|
state: {
|
|
@@ -33,7 +33,7 @@ const sliderVariants = tv({
|
|
|
33
33
|
},
|
|
34
34
|
// null
|
|
35
35
|
1: {
|
|
36
|
-
thumb: 'h-5 w-5 border-accent',
|
|
36
|
+
thumb: 'h-5 w-5 border-tf-accent',
|
|
37
37
|
},
|
|
38
38
|
// true
|
|
39
39
|
2: {
|
package/lib/utils/data.ts
CHANGED
|
@@ -6,16 +6,18 @@ type Items = (Props<'input'> & {
|
|
|
6
6
|
export const getBindSetFromItems = (items: Items): Set<string> => {
|
|
7
7
|
const binds = new Set<string>();
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
for (const item of items) {
|
|
10
10
|
if (item.bind) {
|
|
11
11
|
binds.add(item.bind);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
if (item.items) {
|
|
15
15
|
const subBinds = getBindSetFromItems(item.items as unknown as Items);
|
|
16
|
-
|
|
16
|
+
for (const bind of subBinds) {
|
|
17
|
+
binds.add(bind);
|
|
18
|
+
}
|
|
17
19
|
}
|
|
18
|
-
}
|
|
20
|
+
}
|
|
19
21
|
|
|
20
22
|
return binds;
|
|
21
23
|
};
|
package/lib/utils/string.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export const camelize = (str: string) => {
|
|
2
2
|
return str
|
|
3
|
-
.replace(/(?:^\w|[A-Z]|\b\w)/g,
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
.replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) =>
|
|
4
|
+
index === 0 ? word.toLowerCase() : word.toUpperCase(),
|
|
5
|
+
)
|
|
6
6
|
.replace(/\s+/g, '');
|
|
7
7
|
};
|
|
8
8
|
|
package/lib/webcomponent.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twintag/twintag-form",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"author": "Twintag",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"require": "./dist/index.cjs"
|
|
10
11
|
},
|
|
11
12
|
"./webcomponent": {
|
|
12
|
-
"
|
|
13
|
-
"
|
|
13
|
+
"types": "./dist/webcomponent.d.ts",
|
|
14
|
+
"import": "./dist/webcomponent.js",
|
|
15
|
+
"require": "./dist/webcomponent.cjs"
|
|
14
16
|
}
|
|
15
17
|
},
|
|
16
18
|
"dependencies": {
|
|
@@ -43,12 +45,10 @@
|
|
|
43
45
|
"@twind/with-react": "^1.1.3",
|
|
44
46
|
"@types/uuid": "^9.0.7",
|
|
45
47
|
"@vitejs/plugin-react-swc": "^3.6.0",
|
|
46
|
-
"tailwindcss": "^3.3.6",
|
|
47
48
|
"vite": "^5.2.11",
|
|
48
49
|
"vite-plugin-dts": "^3.9.1",
|
|
49
50
|
"tsconfig": "0.0.0",
|
|
50
|
-
"twintag-types": "0.
|
|
51
|
-
"eslint-config-custom": "1.0.0"
|
|
51
|
+
"twintag-types": "0.4.0"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
|
@@ -56,7 +56,6 @@
|
|
|
56
56
|
"scripts": {
|
|
57
57
|
"dev": "vite",
|
|
58
58
|
"build": "tsc && vite build",
|
|
59
|
-
"lint": "eslint . --ext .ts,.tsx",
|
|
60
59
|
"format": "prettier --write \"**/*.{ts,md,tsx,cjs,mjs,json,html}\" --ignore-path ../../.gitignore",
|
|
61
60
|
"format:check": "prettier --check \"**/*.{ts,md,tsx,cjs,mjs,json,html}\" --ignore-path ../../.gitignore"
|
|
62
61
|
}
|
package/tailwind.config.ts
CHANGED
|
@@ -7,36 +7,31 @@ const config = {
|
|
|
7
7
|
theme: {
|
|
8
8
|
extend: {
|
|
9
9
|
colors: {
|
|
10
|
-
category: 'hsl(var(--tf-category) / <alpha-value>)',
|
|
11
|
-
label: 'hsl(var(--tf-label) / <alpha-value>)',
|
|
10
|
+
'tf-category': 'hsl(var(--tf-category) / <alpha-value>)',
|
|
11
|
+
'tf-label': 'hsl(var(--tf-label) / <alpha-value>)',
|
|
12
12
|
|
|
13
|
-
background: 'hsl(var(--tf-background) / <alpha-value>)',
|
|
14
|
-
foreground: 'hsl(var(--tf-foreground) / <alpha-value>)',
|
|
13
|
+
'tf-background': 'hsl(var(--tf-background) / <alpha-value>)',
|
|
14
|
+
'tf-foreground': 'hsl(var(--tf-foreground) / <alpha-value>)',
|
|
15
15
|
|
|
16
|
-
primary:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
accent:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
foreground: 'hsl(var(--tf-muted-foreground) / <alpha-value>)',
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
input: 'hsl(var(--tf-input) / <alpha-value>)',
|
|
34
|
-
ring: 'hsl(var(--tf-ring) / <alpha-value>)',
|
|
16
|
+
'tf-primary': 'hsl(var(--tf-primary) / <alpha-value>)',
|
|
17
|
+
'tf-primary-foreground':
|
|
18
|
+
'hsl(var(--tf-primary-foreground) / <alpha-value>)',
|
|
19
|
+
'tf-accent': 'hsl(var(--tf-accent) / <alpha-value>)',
|
|
20
|
+
'tf-accent-foreground':
|
|
21
|
+
'hsl(var(--tf-accent-foreground) / <alpha-value>)',
|
|
22
|
+
'tf-destructive': 'hsl(var(--tf-destructive) / <alpha-value>)',
|
|
23
|
+
'tf-destructive-foreground':
|
|
24
|
+
'hsl(var(--tf-destructive-foreground) / <alpha-value>)',
|
|
25
|
+
'tf-muted': 'hsl(var(--tf-muted) / <alpha-value>)',
|
|
26
|
+
'tf-muted-foreground':
|
|
27
|
+
'hsl(var(--tf-muted-foreground) / <alpha-value>)',
|
|
28
|
+
'tf-input': 'hsl(var(--tf-input) / <alpha-value>)',
|
|
29
|
+
'tf-ring': 'hsl(var(--tf-ring) / <alpha-value>)',
|
|
35
30
|
},
|
|
36
31
|
borderRadius: {
|
|
37
|
-
lg:
|
|
38
|
-
md:
|
|
39
|
-
sm: 'calc(var(--tf-radius) - 4px)',
|
|
32
|
+
'tf-lg': 'var(--tf-radius)',
|
|
33
|
+
'tf-md': 'calc(var(--tf-radius) - 2px)',
|
|
34
|
+
'tf-sm': 'calc(var(--tf-radius) - 4px)',
|
|
40
35
|
},
|
|
41
36
|
fontFamily: {
|
|
42
37
|
'tf-font': ['var(--tf-font)', ...fontFamily.sans],
|
package/tsconfig.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -3,8 +3,19 @@ import { dirname, resolve } from 'pathe';
|
|
|
3
3
|
import { defineConfig } from 'vite';
|
|
4
4
|
import dts from 'vite-plugin-dts';
|
|
5
5
|
|
|
6
|
+
import { dependencies, devDependencies } from './package.json';
|
|
7
|
+
|
|
6
8
|
export const __dirname = dirname(new URL(import.meta.url).pathname);
|
|
7
9
|
|
|
10
|
+
const externalPackages = [
|
|
11
|
+
...Object.keys(dependencies || {}),
|
|
12
|
+
...Object.keys(devDependencies || {}),
|
|
13
|
+
].filter((packageName) => packageName !== 'twintag-types');
|
|
14
|
+
|
|
15
|
+
const regexesOfPackages = externalPackages.map(
|
|
16
|
+
(packageName) => new RegExp(`^${packageName}(/.*)?`),
|
|
17
|
+
);
|
|
18
|
+
|
|
8
19
|
// https://vitejs.dev/config/
|
|
9
20
|
export default defineConfig({
|
|
10
21
|
resolve: {
|
|
@@ -16,14 +27,14 @@ export default defineConfig({
|
|
|
16
27
|
lib: {
|
|
17
28
|
// Could also be a dictionary or array of multiple entry points
|
|
18
29
|
entry: {
|
|
19
|
-
|
|
30
|
+
index: resolve(__dirname, './lib/index.tsx'),
|
|
20
31
|
webcomponent: resolve(__dirname, './lib/webcomponent.ts'),
|
|
21
32
|
},
|
|
22
33
|
},
|
|
23
34
|
rollupOptions: {
|
|
24
35
|
// make sure to externalize deps that shouldn't be bundled
|
|
25
36
|
// into your library
|
|
26
|
-
external:
|
|
37
|
+
external: regexesOfPackages,
|
|
27
38
|
preserveEntrySignatures: 'strict',
|
|
28
39
|
output: {
|
|
29
40
|
preserveModules: false,
|