@twintag/twintag-form 1.4.0-beta.0 → 1.4.0-beta.2
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 +12 -0
- package/README.md +121 -62
- package/dev/main.tsx +453 -209
- package/dist/common/button.d.ts +3 -2
- package/dist/common/calendar.d.ts +4 -4
- package/dist/common/form.d.ts +11 -11
- package/dist/common/icon.d.ts +2 -1
- package/dist/common/input.d.ts +3 -2
- package/dist/common/label.d.ts +3 -2
- package/dist/common/slider.d.ts +4 -0
- package/dist/common/textarea.d.ts +3 -2
- package/dist/components/config.d.ts +4 -2
- package/dist/components/containers/accordion.d.ts +5 -6
- package/dist/components/containers/category.d.ts +3 -2
- package/dist/components/fields/checkbox.d.ts +5 -3
- package/dist/components/fields/date-picker.d.ts +4 -2
- package/dist/components/fields/file.d.ts +5 -3
- package/dist/components/fields/input.d.ts +5 -3
- package/dist/components/fields/radiogroup.d.ts +7 -3
- package/dist/components/fields/submit.d.ts +3 -2
- package/dist/components/fields/textarea.d.ts +5 -3
- package/dist/components/fields/toggle.d.ts +5 -3
- package/dist/components/fields/tri-toggle.d.ts +5 -0
- package/dist/components/form.d.ts +2 -2
- package/dist/components/provider.d.ts +21 -0
- package/dist/components/renderer.d.ts +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/twintag-form.react.js +12880 -12304
- package/dist/types/index.d.ts +43 -20
- package/dist/utils/data.d.ts +7 -2
- package/dist/utils/style.d.ts +2 -1
- package/index.html +6 -3
- package/lib/common/slider.tsx +38 -0
- package/lib/components/config.tsx +46 -17
- package/lib/components/containers/accordion.tsx +33 -18
- package/lib/components/containers/category.tsx +1 -1
- package/lib/components/fields/checkbox.tsx +5 -3
- package/lib/components/fields/date-picker.tsx +9 -2
- package/lib/components/fields/file.tsx +5 -4
- package/lib/components/fields/input.tsx +5 -3
- package/lib/components/fields/radiogroup.tsx +9 -3
- package/lib/components/fields/submit.tsx +1 -1
- package/lib/components/fields/textarea.tsx +5 -3
- package/lib/components/fields/toggle.tsx +5 -3
- package/lib/components/fields/tri-toggle.tsx +141 -0
- package/lib/components/form.tsx +5 -7
- package/lib/components/provider.tsx +163 -0
- package/lib/components/{Render/index.tsx → renderer.tsx} +19 -2
- package/lib/index.tsx +41 -41
- package/lib/types/index.ts +69 -29
- package/lib/utils/data.ts +5 -2
- package/package.json +6 -8
- package/dist/components/Render/index.d.ts +0 -7
- package/dist/components/Render/useJson.d.ts +0 -2
- package/dist/components/index.d.ts +0 -7
- package/dist/provider.d.ts +0 -8
- package/lib/components/Render/useJson.ts +0 -76
- package/lib/components/index.tsx +0 -24
- package/lib/provider.tsx +0 -39
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VariantProps, TVReturnType } from 'tailwind-variants';
|
|
2
|
+
import { DayPicker } from 'react-day-picker';
|
|
2
3
|
import { TVConfig } from 'tailwind-variants/dist/config.js';
|
|
3
|
-
|
|
4
|
+
|
|
4
5
|
import * as React from 'react';
|
|
5
|
-
import { DayPicker } from 'react-day-picker';
|
|
6
6
|
declare const calendarVariants: TVReturnType<{
|
|
7
7
|
variant: {
|
|
8
8
|
dropdown: {
|
|
@@ -210,7 +210,7 @@ declare const calendarVariants: TVReturnType<{
|
|
|
210
210
|
};
|
|
211
211
|
}>, unknown, unknown, undefined>>;
|
|
212
212
|
export type CalendarProps = React.ComponentProps<typeof DayPicker> & VariantProps<typeof calendarVariants>;
|
|
213
|
-
declare function Calendar({ size, className, classNames, showOutsideDays, ...props }: CalendarProps): JSX.Element;
|
|
213
|
+
declare function Calendar({ size, className, classNames, showOutsideDays, ...props }: CalendarProps): import("react/jsx-runtime").JSX.Element;
|
|
214
214
|
declare namespace Calendar {
|
|
215
215
|
var displayName: string;
|
|
216
216
|
}
|
package/dist/common/form.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ControllerProps, FieldPath, FieldValues, FormProviderProps, FieldError } from 'react-hook-form';
|
|
2
|
+
import { VariantProps, TVReturnType } from 'tailwind-variants';
|
|
3
3
|
import { TVConfig } from 'tailwind-variants/dist/config.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
4
|
+
import { LabelProps } from '@radix-ui/react-label';
|
|
5
|
+
import { SlotProps } from '@radix-ui/react-slot';
|
|
6
|
+
|
|
7
7
|
import * as React from 'react';
|
|
8
8
|
declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues extends FieldValues = TFieldValues>(props: FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
|
|
9
|
-
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => JSX.Element;
|
|
9
|
+
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
declare const useFormField: () => {
|
|
11
11
|
invalid: boolean;
|
|
12
12
|
isDirty: boolean;
|
|
@@ -18,7 +18,7 @@ declare const useFormField: () => {
|
|
|
18
18
|
formDescriptionId: string;
|
|
19
19
|
formMessageId: string;
|
|
20
20
|
};
|
|
21
|
-
declare const FormItem: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & VariantProps<TVReturnType<{
|
|
21
|
+
declare const FormItem: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & VariantProps< TVReturnType<{
|
|
22
22
|
variant: {
|
|
23
23
|
default: string;
|
|
24
24
|
beta: string;
|
|
@@ -54,7 +54,7 @@ declare const FormItem: React.ForwardRefExoticComponent<React.HTMLAttributes<HTM
|
|
|
54
54
|
beta: string;
|
|
55
55
|
};
|
|
56
56
|
}>, unknown, unknown, undefined>>> & React.RefAttributes<HTMLDivElement>>;
|
|
57
|
-
declare const FormLabel: React.ForwardRefExoticComponent<Omit<Omit<LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & VariantProps<TVReturnType<{
|
|
57
|
+
declare const FormLabel: React.ForwardRefExoticComponent<Omit<Omit< LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & VariantProps< TVReturnType<{
|
|
58
58
|
size: {
|
|
59
59
|
sm: string;
|
|
60
60
|
base: string;
|
|
@@ -90,8 +90,8 @@ declare const FormLabel: React.ForwardRefExoticComponent<Omit<Omit<LabelProps &
|
|
|
90
90
|
base: string;
|
|
91
91
|
};
|
|
92
92
|
}>, unknown, unknown, undefined>>> & React.RefAttributes<HTMLLabelElement>, "ref"> & React.RefAttributes<HTMLLabelElement>>;
|
|
93
|
-
declare const FormControl: React.ForwardRefExoticComponent<Omit<SlotProps & React.RefAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
94
|
-
declare const FormDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & VariantProps<TVReturnType<{
|
|
93
|
+
declare const FormControl: React.ForwardRefExoticComponent<Omit< SlotProps & React.RefAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
94
|
+
declare const FormDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & VariantProps< TVReturnType<{
|
|
95
95
|
size: {
|
|
96
96
|
sm: string;
|
|
97
97
|
base: string;
|
|
@@ -127,7 +127,7 @@ declare const FormDescription: React.ForwardRefExoticComponent<React.HTMLAttribu
|
|
|
127
127
|
base: string;
|
|
128
128
|
};
|
|
129
129
|
}>, unknown, unknown, undefined>>> & React.RefAttributes<HTMLParagraphElement>>;
|
|
130
|
-
declare const FormMessage: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & VariantProps<TVReturnType<{
|
|
130
|
+
declare const FormMessage: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & VariantProps< TVReturnType<{
|
|
131
131
|
size: {
|
|
132
132
|
sm: string;
|
|
133
133
|
base: string;
|
package/dist/common/icon.d.ts
CHANGED
package/dist/common/input.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { VariantProps, TVReturnType } from 'tailwind-variants';
|
|
1
2
|
import { TVConfig } from 'tailwind-variants/dist/config.js';
|
|
2
|
-
|
|
3
|
+
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
declare const inputVariants: TVReturnType<{
|
|
5
6
|
variant: {
|
|
@@ -138,7 +139,7 @@ declare const inputVariants: TVReturnType<{
|
|
|
138
139
|
};
|
|
139
140
|
}>, unknown, unknown, undefined>>;
|
|
140
141
|
export type InputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'> & VariantProps<typeof inputVariants>;
|
|
141
|
-
declare const Input: React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size"> & VariantProps<TVReturnType<{
|
|
142
|
+
declare const Input: React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size"> & VariantProps< TVReturnType<{
|
|
142
143
|
variant: {
|
|
143
144
|
default: {
|
|
144
145
|
input: string;
|
package/dist/common/label.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { VariantProps, TVReturnType } from 'tailwind-variants';
|
|
1
2
|
import { TVConfig } from 'tailwind-variants/dist/config.js';
|
|
2
|
-
|
|
3
|
+
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
5
|
-
declare const Label: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & VariantProps<TVReturnType<{
|
|
6
|
+
declare const Label: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & VariantProps< TVReturnType<{
|
|
6
7
|
size: {
|
|
7
8
|
sm: string;
|
|
8
9
|
base: string;
|
|
@@ -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,7 +1,8 @@
|
|
|
1
|
+
import { VariantProps, TVReturnType } from 'tailwind-variants';
|
|
1
2
|
import { TVConfig } from 'tailwind-variants/dist/config.js';
|
|
2
|
-
|
|
3
|
+
|
|
3
4
|
import * as React from 'react';
|
|
4
|
-
declare const Textarea: React.ForwardRefExoticComponent<React.TextareaHTMLAttributes<HTMLTextAreaElement> & VariantProps<TVReturnType<{
|
|
5
|
+
declare const Textarea: React.ForwardRefExoticComponent<React.TextareaHTMLAttributes<HTMLTextAreaElement> & VariantProps< TVReturnType<{
|
|
5
6
|
variant: {
|
|
6
7
|
default: {
|
|
7
8
|
textarea: string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { ElementType } from 'react';
|
|
2
|
+
import { InputCompConfig } from '../types';
|
|
3
|
+
|
|
4
|
+
export declare const Inputs: Map<string, InputCompConfig>;
|
|
3
5
|
export declare const Containers: Map<string, ElementType>;
|
|
4
6
|
export declare const components: Map<string, ElementType>;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} & WithChildren;
|
|
1
|
+
import { Props } from '../../types';
|
|
2
|
+
import { WithChildren } from 'twintag-types/dom';
|
|
3
|
+
import { FC } from 'react';
|
|
4
|
+
|
|
5
|
+
type AccordionProps = Props<'accordion', 'item' | 'multiple' | 'single'> & WithChildren;
|
|
7
6
|
declare const Accordion: FC<AccordionProps>;
|
|
8
7
|
export { Accordion };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Props } from '../../types';
|
|
3
|
+
|
|
4
|
+
export declare const DEFAULT_CHECKBOX_VALUE = false;
|
|
5
|
+
export declare const Checkbox: FC<Props<'input'>>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Props } from '../../types';
|
|
2
|
+
|
|
2
3
|
import * as React from 'react';
|
|
3
|
-
export declare const
|
|
4
|
+
export declare const DEFAULT_DATE_PICKER_VALUE: null;
|
|
5
|
+
export declare const DatePicker: React.FC<Props<'input'>>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Props } from '../../types';
|
|
3
|
+
|
|
4
|
+
export declare const DEFAULT_FILE_VALUE = "";
|
|
5
|
+
export declare const File: FC<Props<'input'>>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Props } from '../../types';
|
|
3
|
+
|
|
4
|
+
export declare const DEFAULT_INPUT_VALUE = "";
|
|
5
|
+
export declare const Input: FC<Props<'input'>>;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Props } from '../../types';
|
|
3
|
+
|
|
4
|
+
export declare const DEFAULT_RADIOGROUP_VALUE = "";
|
|
5
|
+
export declare const RadioGroup: FC<Props<'input'> & {
|
|
6
|
+
items: Props<'input'>[];
|
|
7
|
+
}>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Props } from '../../types';
|
|
3
|
+
|
|
4
|
+
export declare const DEFAULT_TEXTAREA_VALUE = "";
|
|
5
|
+
export declare const Textarea: FC<Props<'input'>>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Props } from '../../types';
|
|
3
|
+
|
|
4
|
+
export declare const DEFAULT_TOGGLE_VALUE = false;
|
|
5
|
+
export declare const Toggle: FC<Props<'input'>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { FieldValues } from 'react-hook-form';
|
|
1
2
|
import { ForwardRefExoticComponent, ReactNode, RefAttributes } from 'react';
|
|
2
|
-
|
|
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 { ParsedJsonComponent, RawJsonComponent, TwintagFormContext, InputCompConfig } 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: ParsedJsonComponent | ParsedJsonComponent[], inputs: Map<string, InputCompConfig>) => {
|
|
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, InputCompConfig>;
|
|
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,7 +1,8 @@
|
|
|
1
|
-
import { ForwardRefExoticComponent, RefAttributes
|
|
2
|
-
import
|
|
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<{
|