@twintag/twintag-form 1.3.0 → 1.4.0-beta.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.
Files changed (65) hide show
  1. package/.turbo/turbo-build.log +6 -6
  2. package/CHANGELOG.md +12 -0
  3. package/README.md +121 -62
  4. package/dev/main.tsx +233 -210
  5. package/dist/common/button.d.ts +17 -30
  6. package/dist/common/calendar.d.ts +212 -4
  7. package/dist/common/form.d.ts +151 -9
  8. package/dist/common/icon.d.ts +2 -1
  9. package/dist/common/input.d.ts +276 -2
  10. package/dist/common/label.d.ts +39 -1
  11. package/dist/common/slider.d.ts +4 -0
  12. package/dist/common/textarea.d.ts +139 -2
  13. package/dist/components/config.d.ts +4 -2
  14. package/dist/components/containers/accordion.d.ts +3 -2
  15. package/dist/components/containers/category.d.ts +3 -2
  16. package/dist/components/fields/checkbox.d.ts +4 -2
  17. package/dist/components/fields/date-picker.d.ts +3 -1
  18. package/dist/components/fields/file.d.ts +4 -2
  19. package/dist/components/fields/input.d.ts +4 -2
  20. package/dist/components/fields/radiogroup.d.ts +4 -2
  21. package/dist/components/fields/submit.d.ts +3 -2
  22. package/dist/components/fields/textarea.d.ts +4 -2
  23. package/dist/components/fields/toggle.d.ts +4 -2
  24. package/dist/components/fields/tri-toggle.d.ts +5 -0
  25. package/dist/components/form.d.ts +2 -2
  26. package/dist/components/provider.d.ts +21 -0
  27. package/dist/components/renderer.d.ts +1 -0
  28. package/dist/index.d.ts +5 -3
  29. package/dist/twintag-form.react.js +12868 -12156
  30. package/dist/types/index.d.ts +25 -16
  31. package/dist/utils/data.d.ts +2 -1
  32. package/dist/utils/style.d.ts +2 -1
  33. package/index.html +5 -3
  34. package/lib/common/button.tsx +4 -5
  35. package/lib/common/calendar.tsx +25 -5
  36. package/lib/common/form.tsx +40 -19
  37. package/lib/common/input.tsx +20 -10
  38. package/lib/common/label.tsx +16 -3
  39. package/lib/common/slider.tsx +38 -0
  40. package/lib/common/textarea.tsx +17 -9
  41. package/lib/components/config.tsx +46 -17
  42. package/lib/components/containers/accordion.tsx +24 -7
  43. package/lib/components/containers/category.tsx +16 -7
  44. package/lib/components/fields/checkbox.tsx +12 -6
  45. package/lib/components/fields/date-picker.tsx +54 -18
  46. package/lib/components/fields/file.tsx +83 -76
  47. package/lib/components/fields/input.tsx +15 -6
  48. package/lib/components/fields/radiogroup.tsx +13 -7
  49. package/lib/components/fields/submit.tsx +5 -2
  50. package/lib/components/fields/textarea.tsx +14 -6
  51. package/lib/components/fields/toggle.tsx +12 -6
  52. package/lib/components/fields/tri-toggle.tsx +141 -0
  53. package/lib/components/form.tsx +5 -7
  54. package/lib/components/provider.tsx +159 -0
  55. package/lib/components/{Render/index.tsx → renderer.tsx} +19 -2
  56. package/lib/index.tsx +41 -36
  57. package/lib/types/index.ts +49 -39
  58. package/package.json +5 -7
  59. package/dist/components/Render/index.d.ts +0 -7
  60. package/dist/components/Render/useJson.d.ts +0 -2
  61. package/dist/components/index.d.ts +0 -7
  62. package/dist/provider.d.ts +0 -8
  63. package/lib/components/Render/useJson.ts +0 -76
  64. package/lib/components/index.tsx +0 -24
  65. package/lib/provider.tsx +0 -36
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import * as SliderPrimitive from '@radix-ui/react-slider';
3
+ declare const Slider: React.ForwardRefExoticComponent<Omit<SliderPrimitive.SliderProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
4
+ export { Slider };
@@ -1,4 +1,141 @@
1
+ import { VariantProps, TVReturnType } from 'tailwind-variants';
2
+ import { TVConfig } from 'tailwind-variants/dist/config.js';
3
+
1
4
  import * as React from 'react';
2
- type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
3
- declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
5
+ declare const Textarea: React.ForwardRefExoticComponent<React.TextareaHTMLAttributes<HTMLTextAreaElement> & VariantProps< TVReturnType<{
6
+ variant: {
7
+ default: {
8
+ textarea: string;
9
+ };
10
+ beta: {
11
+ root: string;
12
+ textarea: string;
13
+ };
14
+ };
15
+ size: {
16
+ sm: {
17
+ textarea: string;
18
+ };
19
+ base: {
20
+ textarea: string;
21
+ };
22
+ };
23
+ }, {
24
+ root: string;
25
+ textarea: string[];
26
+ }, undefined, TVConfig<{
27
+ variant: {
28
+ default: {
29
+ textarea: string;
30
+ };
31
+ beta: {
32
+ root: string;
33
+ textarea: string;
34
+ };
35
+ };
36
+ size: {
37
+ sm: {
38
+ textarea: string;
39
+ };
40
+ base: {
41
+ textarea: string;
42
+ };
43
+ };
44
+ }, {
45
+ variant: {
46
+ default: {
47
+ textarea: string;
48
+ };
49
+ beta: {
50
+ root: string;
51
+ textarea: string;
52
+ };
53
+ };
54
+ size: {
55
+ sm: {
56
+ textarea: string;
57
+ };
58
+ base: {
59
+ textarea: string;
60
+ };
61
+ };
62
+ }>, {
63
+ variant: {
64
+ default: {
65
+ textarea: string;
66
+ };
67
+ beta: {
68
+ root: string;
69
+ textarea: string;
70
+ };
71
+ };
72
+ size: {
73
+ sm: {
74
+ textarea: string;
75
+ };
76
+ base: {
77
+ textarea: string;
78
+ };
79
+ };
80
+ }, {
81
+ root: string;
82
+ textarea: string[];
83
+ }, TVReturnType<{
84
+ variant: {
85
+ default: {
86
+ textarea: string;
87
+ };
88
+ beta: {
89
+ root: string;
90
+ textarea: string;
91
+ };
92
+ };
93
+ size: {
94
+ sm: {
95
+ textarea: string;
96
+ };
97
+ base: {
98
+ textarea: string;
99
+ };
100
+ };
101
+ }, {
102
+ root: string;
103
+ textarea: string[];
104
+ }, undefined, TVConfig<{
105
+ variant: {
106
+ default: {
107
+ textarea: string;
108
+ };
109
+ beta: {
110
+ root: string;
111
+ textarea: string;
112
+ };
113
+ };
114
+ size: {
115
+ sm: {
116
+ textarea: string;
117
+ };
118
+ base: {
119
+ textarea: string;
120
+ };
121
+ };
122
+ }, {
123
+ variant: {
124
+ default: {
125
+ textarea: string;
126
+ };
127
+ beta: {
128
+ root: string;
129
+ textarea: string;
130
+ };
131
+ };
132
+ size: {
133
+ sm: {
134
+ textarea: string;
135
+ };
136
+ base: {
137
+ textarea: string;
138
+ };
139
+ };
140
+ }>, unknown, unknown, undefined>>> & React.RefAttributes<HTMLTextAreaElement>>;
4
141
  export { Textarea };
@@ -1,4 +1,6 @@
1
- import type { ElementType } from 'react';
2
- export declare const Inputs: Map<string, ElementType>;
1
+ import { ElementType } from 'react';
2
+ import { ComponentConfig } from '../types';
3
+
4
+ export declare const Inputs: Map<string, ComponentConfig>;
3
5
  export declare const Containers: Map<string, ElementType>;
4
6
  export declare const components: Map<string, ElementType>;
@@ -1,5 +1,6 @@
1
- import type { WithChildren } from 'twintag-types/dom';
2
- import { type FC } from 'react';
1
+ import { WithChildren } from 'twintag-types/dom';
2
+ import { FC } from 'react';
3
+
3
4
  type AccordionProps = {
4
5
  subtype?: 'item' | 'multiple' | 'single';
5
6
  label?: string;
@@ -1,5 +1,6 @@
1
- import type { FC } from 'react';
2
- import type { WithChildren } from 'twintag-types/dom';
1
+ import { FC } from 'react';
2
+ import { WithChildren } from 'twintag-types/dom';
3
+
3
4
  type Props = {
4
5
  label?: string;
5
6
  } & WithChildren;
@@ -1,3 +1,5 @@
1
- import type { FC } from 'react';
2
- import type { Props } from '../../types';
1
+ import { FC } from 'react';
2
+ import { Props } from '../../types';
3
+
4
+ export declare const DEFAULT_CHECKBOX_VALUE = false;
3
5
  export declare const Checkbox: FC<Props>;
@@ -1,3 +1,5 @@
1
- import type { Props } from '../../types';
1
+ import { Props } from '../../types';
2
+
2
3
  import * as React from 'react';
4
+ export declare const DEFAULT_DATE_PICKER_VALUE: null;
3
5
  export declare const DatePicker: React.FC<Props>;
@@ -1,3 +1,5 @@
1
- import type { FC } from 'react';
2
- import type { Props } from '../../types';
1
+ import { FC } from 'react';
2
+ import { Props } from '../../types';
3
+
4
+ export declare const DEFAULT_FILE_VALUE = "";
3
5
  export declare const File: FC<Props>;
@@ -1,3 +1,5 @@
1
- import type { FC } from 'react';
2
- import type { Props } from '../../types';
1
+ import { FC } from 'react';
2
+ import { Props } from '../../types';
3
+
4
+ export declare const DEFAULT_INPUT_VALUE = "";
3
5
  export declare const Input: FC<Props>;
@@ -1,3 +1,5 @@
1
- import type { FC } from 'react';
2
- import type { Props } from '../../types';
1
+ import { FC } from 'react';
2
+ import { Props } from '../../types';
3
+
4
+ export declare const DEFAULT_RADIOGROUP_VALUE = "";
3
5
  export declare const RadioGroup: FC<Props>;
@@ -1,3 +1,4 @@
1
- import type { FC } from 'react';
2
- import type { Props } from '../../types';
1
+ import { FC } from 'react';
2
+ import { Props } from '../../types';
3
+
3
4
  export declare const Submit: FC<Props>;
@@ -1,3 +1,5 @@
1
- import type { FC } from 'react';
2
- import type { Props } from '../../types';
1
+ import { FC } from 'react';
2
+ import { Props } from '../../types';
3
+
4
+ export declare const DEFAULT_TEXTAREA_VALUE = "";
3
5
  export declare const Textarea: FC<Props>;
@@ -1,3 +1,5 @@
1
- import type { FC } from 'react';
2
- import type { Props } from '../../types';
1
+ import { FC } from 'react';
2
+ import { Props } from '../../types';
3
+
4
+ export declare const DEFAULT_TOGGLE_VALUE = false;
3
5
  export declare const Toggle: FC<Props>;
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ import { Props } from '../../types';
3
+
4
+ export declare const DEFAULT_TRI_TOGGLE_VALUE: null;
5
+ export declare const TriToggle: FC<Props>;
@@ -1,6 +1,6 @@
1
+ import { FieldValues } from 'react-hook-form';
1
2
  import { ForwardRefExoticComponent, ReactNode, RefAttributes } from 'react';
2
- /// <reference types="react" />
3
- import type { FieldValues } from 'react-hook-form';
3
+
4
4
  export declare const TwintagForm: ForwardRefExoticComponent<{
5
5
  defaultValues?: FieldValues | undefined;
6
6
  resetOnSubmit?: boolean | undefined;
@@ -0,0 +1,21 @@
1
+ import { RawJsonComponent, TwintagFormContext, ComponentConfig } from '../types';
2
+ import { WithChildren } from 'twintag-types/dom';
3
+ import { Context, ElementType, ReactNode } from 'react';
4
+
5
+ export declare const twintagFormContext: Context<TwintagFormContext>;
6
+ export declare const useTwintagForm: () => TwintagFormContext;
7
+ type Components = TwintagFormContext['components'];
8
+ type Inputs = TwintagFormContext['inputs'];
9
+ export declare const getResetValues: (config: RawJsonComponent | RawJsonComponent[], inputs: Map<string, ComponentConfig>) => {
10
+ [k: string]: unknown;
11
+ };
12
+ export declare const TwintagFormProvider: ({ variant, size, inputs, components, config, children, }: {
13
+ config: RawJsonComponent | RawJsonComponent[];
14
+ variant: TwintagFormContext['variant'];
15
+ size: TwintagFormContext['size'];
16
+ inputs: Map<string, ComponentConfig>;
17
+ components: Map<string, ElementType>;
18
+ } & {
19
+ children?: ReactNode;
20
+ }) => import("react/jsx-runtime").JSX.Element;
21
+ export {};
@@ -0,0 +1 @@
1
+ export declare const JsonRenderer: () => import("react/jsx-runtime").JSX.Element;
package/dist/index.d.ts CHANGED
@@ -1,12 +1,14 @@
1
- import { ForwardRefExoticComponent, RefAttributes, ComponentProps } from 'react';
2
- import type { RawJsonComponent } from './types';
1
+ import { ComponentProps, ForwardRefExoticComponent, RefAttributes } from 'react';
2
+ import { RawJsonComponent } from './types';
3
3
  import { TwintagForm } from './components/form';
4
- import { TwintagFormProvider } from './provider';
4
+ import { TwintagFormProvider } from './components/provider';
5
+
5
6
  type Props = {
6
7
  config: RawJsonComponent[];
7
8
  options?: Partial<{
8
9
  defaultValues?: ComponentProps<typeof TwintagForm>['defaultValues'];
9
10
  variant?: ComponentProps<typeof TwintagFormProvider>['variant'];
11
+ size?: ComponentProps<typeof TwintagFormProvider>['size'];
10
12
  resetOnSubmit?: boolean;
11
13
  }>;
12
14
  };