@twintag/twintag-form 1.4.0 → 1.4.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 +6 -6
- package/CHANGELOG.md +6 -0
- package/dev/main.tsx +6 -0
- package/dist/components/config.d.ts +1 -1
- package/dist/components/input.d.ts +4 -0
- package/dist/components/label.d.ts +4 -0
- package/dist/twintag-form.react.js +378 -381
- package/lib/components/config.tsx +10 -22
- package/lib/components/form.tsx +1 -1
- package/lib/components/input.tsx +12 -0
- package/lib/components/label.tsx +8 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ElementType
|
|
1
|
+
import type { ElementType } from 'react';
|
|
2
2
|
import type { InputCompConfig } from '../types';
|
|
3
3
|
|
|
4
4
|
import { Accordion } from './containers/accordion';
|
|
@@ -12,6 +12,12 @@ import { Submit } from './fields/submit';
|
|
|
12
12
|
import { DEFAULT_TEXTAREA_VALUE, Textarea } from './fields/textarea';
|
|
13
13
|
import { DEFAULT_TOGGLE_VALUE, Toggle } from './fields/toggle';
|
|
14
14
|
import { DEFAULT_TRI_TOGGLE_VALUE, TriToggle } from './fields/tri-toggle';
|
|
15
|
+
import { Input } from './input';
|
|
16
|
+
import { Label } from './label';
|
|
17
|
+
|
|
18
|
+
export const Containers = new Map<string, ElementType>()
|
|
19
|
+
.set('category', Category)
|
|
20
|
+
.set('accordion', Accordion);
|
|
15
21
|
|
|
16
22
|
export const Inputs = new Map<string, InputCompConfig>()
|
|
17
23
|
.set('simple', {
|
|
@@ -50,24 +56,6 @@ export const Inputs = new Map<string, InputCompConfig>()
|
|
|
50
56
|
component: TriToggle,
|
|
51
57
|
});
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
label
|
|
56
|
-
bind?: string;
|
|
57
|
-
};
|
|
58
|
-
const Input: FC<InputProps> = ({ subtype = 'simple', ...rest }) => {
|
|
59
|
-
const Comp = Inputs.get(subtype)?.component;
|
|
60
|
-
|
|
61
|
-
if (!Comp) return <></>;
|
|
62
|
-
|
|
63
|
-
return <Comp {...rest} />;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export const Containers = new Map<string, ElementType>()
|
|
67
|
-
.set('category', Category)
|
|
68
|
-
.set('accordion', Accordion);
|
|
69
|
-
|
|
70
|
-
export const components = new Map<string, ElementType>(Containers).set(
|
|
71
|
-
'input',
|
|
72
|
-
Input,
|
|
73
|
-
);
|
|
59
|
+
export const components = new Map<string, ElementType>(Containers)
|
|
60
|
+
.set('input', Input)
|
|
61
|
+
.set('label', Label);
|
package/lib/components/form.tsx
CHANGED
|
@@ -91,7 +91,7 @@ export const TwintagForm = forwardRef<HTMLFormElement, Props>(
|
|
|
91
91
|
<Form {...form}>
|
|
92
92
|
<form
|
|
93
93
|
ref={ref}
|
|
94
|
-
className='relative
|
|
94
|
+
className='relative flex w-full flex-col gap-4 font-tf-font'
|
|
95
95
|
onSubmit={form.handleSubmit(onValid, onInvalid)}
|
|
96
96
|
>
|
|
97
97
|
{children}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { Props } from '../types';
|
|
3
|
+
|
|
4
|
+
import { Inputs } from './config';
|
|
5
|
+
|
|
6
|
+
export const Input: FC<Props<'input'>> = ({ subtype, ...rest }) => {
|
|
7
|
+
const Comp = Inputs.get(subtype!)?.component;
|
|
8
|
+
|
|
9
|
+
if (!Comp) return <></>;
|
|
10
|
+
|
|
11
|
+
return <Comp {...rest} />;
|
|
12
|
+
};
|