@twintag/twintag-form 0.4.2 → 0.6.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.
Files changed (77) hide show
  1. package/.eslintrc.cjs +1 -1
  2. package/.turbo/turbo-build.log +11 -55
  3. package/CHANGELOG.md +28 -0
  4. package/README.md +9 -9
  5. package/dist/components/Category/__styles.d.ts +29 -0
  6. package/dist/{lib/components → components}/Category/index.d.ts +2 -3
  7. package/dist/components/Form/index.d.ts +12 -0
  8. package/dist/{lib/types/index.d.ts → components/Input/__props.d.ts} +0 -6
  9. package/dist/components/Input/__styles.d.ts +460 -0
  10. package/dist/{lib/components → components}/Input/checkbox.d.ts +2 -3
  11. package/dist/{lib/components → components}/Input/file.d.ts +2 -3
  12. package/dist/{lib/components → components}/Input/index.d.ts +0 -1
  13. package/dist/{lib/components → components}/Input/simple.d.ts +2 -3
  14. package/dist/{lib/components → components}/Input/submit.d.ts +2 -3
  15. package/dist/{lib/components → components}/Input/textarea.d.ts +2 -3
  16. package/dist/{lib/components → components}/Input/toggle.d.ts +2 -3
  17. package/dist/{lib/components → components}/Label/index.d.ts +0 -1
  18. package/dist/components/index.d.ts +4 -0
  19. package/dist/index.d.ts +14 -0
  20. package/dist/react.d.ts +1 -0
  21. package/dist/styles.d.ts +487 -0
  22. package/dist/twintag-form.react.js +8726 -0
  23. package/dist/twintag-form.webcomponent.js +4503 -0
  24. package/dist/webcomponent.d.ts +1 -0
  25. package/lib/__stories__/Form.stories.tsx +104 -12
  26. package/lib/components/Category/__styles.ts +12 -0
  27. package/lib/components/Category/index.tsx +5 -8
  28. package/lib/components/Form/index.tsx +33 -34
  29. package/lib/{types/index.ts → components/Input/__props.ts} +0 -6
  30. package/lib/components/Input/__styles.ts +132 -0
  31. package/lib/components/Input/checkbox.tsx +9 -12
  32. package/lib/components/Input/file.tsx +10 -13
  33. package/lib/components/Input/simple.tsx +9 -11
  34. package/lib/components/Input/submit.tsx +3 -9
  35. package/lib/components/Input/textarea.tsx +9 -11
  36. package/lib/components/Input/toggle.tsx +11 -12
  37. package/lib/components/Label/index.tsx +3 -2
  38. package/lib/components/index.tsx +4 -6
  39. package/lib/index.tsx +39 -161
  40. package/lib/styles.ts +19 -18
  41. package/lib/webcomponent.ts +3 -3
  42. package/package.json +14 -17
  43. package/tsconfig.json +12 -3
  44. package/twind.config.ts +7 -7
  45. package/vite.config.ts +47 -0
  46. package/dist/index.es.js +0 -27362
  47. package/dist/index.umd.js +0 -196
  48. package/dist/lib/__stories__/Form.stories.d.ts +0 -7
  49. package/dist/lib/__stories__/Form.stories.d.ts.map +0 -1
  50. package/dist/lib/components/Category/index.d.ts.map +0 -1
  51. package/dist/lib/components/Form/index.d.ts +0 -10
  52. package/dist/lib/components/Form/index.d.ts.map +0 -1
  53. package/dist/lib/components/Form/register.d.ts +0 -12
  54. package/dist/lib/components/Form/register.d.ts.map +0 -1
  55. package/dist/lib/components/Input/checkbox.d.ts.map +0 -1
  56. package/dist/lib/components/Input/file.d.ts.map +0 -1
  57. package/dist/lib/components/Input/index.d.ts.map +0 -1
  58. package/dist/lib/components/Input/simple.d.ts.map +0 -1
  59. package/dist/lib/components/Input/submit.d.ts.map +0 -1
  60. package/dist/lib/components/Input/textarea.d.ts.map +0 -1
  61. package/dist/lib/components/Input/toggle.d.ts.map +0 -1
  62. package/dist/lib/components/Label/index.d.ts.map +0 -1
  63. package/dist/lib/components/index.d.ts +0 -6
  64. package/dist/lib/components/index.d.ts.map +0 -1
  65. package/dist/lib/index.d.ts +0 -20
  66. package/dist/lib/index.d.ts.map +0 -1
  67. package/dist/lib/styles.d.ts +0 -131
  68. package/dist/lib/styles.d.ts.map +0 -1
  69. package/dist/lib/types/index.d.ts.map +0 -1
  70. package/dist/lib/webcomponent.d.ts +0 -2
  71. package/dist/lib/webcomponent.d.ts.map +0 -1
  72. package/dist/twind.config.d.ts +0 -5
  73. package/dist/twind.config.d.ts.map +0 -1
  74. package/dist/webcomponent.es.js +0 -31726
  75. package/dist/webcomponent.umd.js +0 -196
  76. package/lib/components/Form/register.tsx +0 -69
  77. 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()