@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.
@@ -1,4 +1,4 @@
1
- import type { ElementType, FC } from 'react';
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
- type InputProps = {
54
- subtype?: string;
55
- label?: string;
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);
@@ -91,7 +91,7 @@ export const TwintagForm = forwardRef<HTMLFormElement, Props>(
91
91
  <Form {...form}>
92
92
  <form
93
93
  ref={ref}
94
- className='relative space-y-4 font-tf-font'
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
+ };
@@ -0,0 +1,8 @@
1
+ import type { FC } from 'react';
2
+ import type { Props } from '../types';
3
+
4
+ import { Label as LabelComp } from '../common/label';
5
+
6
+ export const Label: FC<Props> = ({ label }) => {
7
+ return <LabelComp>{label}</LabelComp>;
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twintag/twintag-form",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "author": "Twintag",
5
5
  "type": "module",
6
6
  "exports": {