@twintag/twintag-form 0.4.1 → 0.5.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/.turbo/turbo-build.log +10 -54
- package/CHANGELOG.md +23 -0
- package/README.md +9 -5
- package/dist/components/Category/__styles.d.ts +19 -0
- package/dist/{lib/components → components}/Category/index.d.ts +2 -3
- package/dist/components/Form/index.d.ts +12 -0
- package/dist/{lib/types/index.d.ts → components/Input/__props.d.ts} +0 -6
- package/dist/components/Input/__styles.d.ts +245 -0
- package/dist/{lib/components → components}/Input/checkbox.d.ts +2 -3
- package/dist/{lib/components → components}/Input/file.d.ts +2 -3
- package/dist/{lib/components → components}/Input/index.d.ts +0 -1
- package/dist/{lib/components → components}/Input/simple.d.ts +2 -3
- package/dist/{lib/components → components}/Input/submit.d.ts +2 -3
- package/dist/{lib/components → components}/Input/textarea.d.ts +2 -3
- package/dist/{lib/components → components}/Input/toggle.d.ts +2 -3
- package/dist/{lib/components → components}/Label/index.d.ts +0 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/index.d.ts +14 -0
- package/dist/react.d.ts +1 -0
- package/dist/styles.d.ts +262 -0
- package/dist/twintag-form.react.js +8658 -0
- package/dist/twintag-form.webcomponent.js +4503 -0
- package/dist/webcomponent.d.ts +1 -0
- package/lib/__stories__/Form.stories.tsx +102 -10
- package/lib/components/Category/__styles.ts +12 -0
- package/lib/components/Category/index.tsx +5 -8
- package/lib/components/Form/index.tsx +33 -34
- package/lib/{types/index.ts → components/Input/__props.ts} +0 -6
- package/lib/components/Input/__styles.ts +132 -0
- package/lib/components/Input/checkbox.tsx +8 -11
- package/lib/components/Input/file.tsx +9 -12
- package/lib/components/Input/simple.tsx +8 -10
- package/lib/components/Input/submit.tsx +3 -9
- package/lib/components/Input/textarea.tsx +8 -10
- package/lib/components/Input/toggle.tsx +10 -11
- package/lib/components/Label/index.tsx +2 -1
- package/lib/components/index.tsx +4 -6
- package/lib/index.tsx +35 -157
- package/lib/styles.ts +2 -1
- package/lib/webcomponent.ts +1 -1
- package/package.json +11 -14
- package/tsconfig.json +3 -2
- package/vite.config.ts +47 -0
- package/dist/index.es.js +0 -27362
- package/dist/index.umd.js +0 -196
- package/dist/lib/__stories__/Form.stories.d.ts +0 -7
- package/dist/lib/__stories__/Form.stories.d.ts.map +0 -1
- package/dist/lib/components/Category/index.d.ts.map +0 -1
- package/dist/lib/components/Form/index.d.ts +0 -10
- package/dist/lib/components/Form/index.d.ts.map +0 -1
- package/dist/lib/components/Form/register.d.ts +0 -12
- package/dist/lib/components/Form/register.d.ts.map +0 -1
- package/dist/lib/components/Input/checkbox.d.ts.map +0 -1
- package/dist/lib/components/Input/file.d.ts.map +0 -1
- package/dist/lib/components/Input/index.d.ts.map +0 -1
- package/dist/lib/components/Input/simple.d.ts.map +0 -1
- package/dist/lib/components/Input/submit.d.ts.map +0 -1
- package/dist/lib/components/Input/textarea.d.ts.map +0 -1
- package/dist/lib/components/Input/toggle.d.ts.map +0 -1
- package/dist/lib/components/Label/index.d.ts.map +0 -1
- package/dist/lib/components/index.d.ts +0 -6
- package/dist/lib/components/index.d.ts.map +0 -1
- package/dist/lib/index.d.ts +0 -20
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/styles.d.ts +0 -131
- package/dist/lib/styles.d.ts.map +0 -1
- package/dist/lib/types/index.d.ts.map +0 -1
- package/dist/lib/webcomponent.d.ts +0 -2
- package/dist/lib/webcomponent.d.ts.map +0 -1
- package/dist/twind.config.d.ts +0 -5
- package/dist/twind.config.d.ts.map +0 -1
- package/dist/webcomponent.es.js +0 -31726
- package/dist/webcomponent.umd.js +0 -196
- package/lib/components/Form/register.tsx +0 -69
- package/scripts/build.js +0 -60
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { FC, ReactElement } from 'react';
|
|
2
|
-
import type { UseFormRegister, Control } from 'react-hook-form';
|
|
3
|
-
import type { WithChildren } from 'twintag-types/dom';
|
|
4
|
-
|
|
5
|
-
import { Children } from 'react';
|
|
6
|
-
|
|
7
|
-
import Input from '../Input';
|
|
8
|
-
|
|
9
|
-
type Props = {
|
|
10
|
-
useForm: { register: UseFormRegister<any>; control: Control };
|
|
11
|
-
} & WithChildren;
|
|
12
|
-
|
|
13
|
-
const RegisterInputs: FC<Props> = ({ children, useForm }) => {
|
|
14
|
-
return Children.map(children as any, (child) => {
|
|
15
|
-
if (!child) return null;
|
|
16
|
-
|
|
17
|
-
const Component = child.type;
|
|
18
|
-
|
|
19
|
-
if (child.props?.config?.items) {
|
|
20
|
-
return (
|
|
21
|
-
<Component
|
|
22
|
-
{...child.props}
|
|
23
|
-
config={{
|
|
24
|
-
...child.props.config,
|
|
25
|
-
items: child.props.config.items.map((item: any) => {
|
|
26
|
-
if (item.type === 'input') {
|
|
27
|
-
return {
|
|
28
|
-
...item,
|
|
29
|
-
useForm,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return item;
|
|
34
|
-
}),
|
|
35
|
-
}}
|
|
36
|
-
/>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (child.props?.children) {
|
|
41
|
-
return (
|
|
42
|
-
<Component {...child.props}>
|
|
43
|
-
<RegisterInputs useForm={useForm}>
|
|
44
|
-
{child.props.children}
|
|
45
|
-
</RegisterInputs>
|
|
46
|
-
</Component>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if ((child as ReactElement).props?.config?.type === 'input') {
|
|
51
|
-
return (
|
|
52
|
-
<Component
|
|
53
|
-
config={{
|
|
54
|
-
...child.props.config,
|
|
55
|
-
useForm,
|
|
56
|
-
}}
|
|
57
|
-
/>
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (child.type === Input) {
|
|
62
|
-
return <Component {...child.props} useForm={useForm} />;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return <Component {...child.props} />;
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export { RegisterInputs };
|
package/scripts/build.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { resolve, dirname } from "pathe";
|
|
2
|
-
import { fileURLToPath } from 'url';
|
|
3
|
-
import { build, defineConfig } from "vite";
|
|
4
|
-
import react from "@vitejs/plugin-react-swc";
|
|
5
|
-
import typescript from "@rollup/plugin-typescript";
|
|
6
|
-
|
|
7
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
|
|
9
|
-
const reactComponentLibrary = {
|
|
10
|
-
plugins: [],
|
|
11
|
-
entry: resolve(__dirname, "../lib/index.tsx"),
|
|
12
|
-
fileName: (format) => `index.${format}.js`,
|
|
13
|
-
name: "index",
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const webcomponentsLibrary = {
|
|
17
|
-
plugins: [],
|
|
18
|
-
entry: resolve(__dirname, "../lib/webcomponent.ts"),
|
|
19
|
-
fileName: (format) => `webcomponent.${format}.js`,
|
|
20
|
-
name: "webcomponent",
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const getSharedConfiguration = ({ plugins, ...library }) => {
|
|
24
|
-
return defineConfig({
|
|
25
|
-
resolve: {
|
|
26
|
-
alias: {
|
|
27
|
-
'@twintag-form': resolve(__dirname, '../lib'),
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
plugins: [react(), typescript(), ...plugins],
|
|
31
|
-
build: {
|
|
32
|
-
lib: {
|
|
33
|
-
formats: ["es", "umd"],
|
|
34
|
-
...library,
|
|
35
|
-
},
|
|
36
|
-
rollupOptions: {
|
|
37
|
-
external: ["react"],
|
|
38
|
-
output: {
|
|
39
|
-
globals: {
|
|
40
|
-
react: "react",
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const viteBuild = (configFactory) => {
|
|
49
|
-
return build(configFactory);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const buildLibraries = async () => {
|
|
53
|
-
await Promise.all(
|
|
54
|
-
[webcomponentsLibrary, reactComponentLibrary]
|
|
55
|
-
.map(getSharedConfiguration)
|
|
56
|
-
.map(viteBuild)
|
|
57
|
-
);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
buildLibraries()
|