@twintag/twintag-form 1.4.0-beta.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 (59) hide show
  1. package/.turbo/turbo-build.log +6 -6
  2. package/CHANGELOG.md +6 -0
  3. package/README.md +121 -62
  4. package/dev/main.tsx +233 -209
  5. package/dist/common/button.d.ts +3 -2
  6. package/dist/common/calendar.d.ts +4 -4
  7. package/dist/common/form.d.ts +11 -11
  8. package/dist/common/icon.d.ts +2 -1
  9. package/dist/common/input.d.ts +3 -2
  10. package/dist/common/label.d.ts +3 -2
  11. package/dist/common/slider.d.ts +4 -0
  12. package/dist/common/textarea.d.ts +3 -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 +4 -3
  29. package/dist/twintag-form.react.js +12828 -12261
  30. package/dist/types/index.d.ts +25 -17
  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/slider.tsx +38 -0
  35. package/lib/components/config.tsx +46 -17
  36. package/lib/components/containers/accordion.tsx +1 -1
  37. package/lib/components/containers/category.tsx +1 -1
  38. package/lib/components/fields/checkbox.tsx +4 -2
  39. package/lib/components/fields/date-picker.tsx +4 -1
  40. package/lib/components/fields/file.tsx +83 -82
  41. package/lib/components/fields/input.tsx +4 -2
  42. package/lib/components/fields/radiogroup.tsx +4 -2
  43. package/lib/components/fields/submit.tsx +1 -1
  44. package/lib/components/fields/textarea.tsx +4 -2
  45. package/lib/components/fields/toggle.tsx +4 -2
  46. package/lib/components/fields/tri-toggle.tsx +141 -0
  47. package/lib/components/form.tsx +5 -7
  48. package/lib/components/provider.tsx +159 -0
  49. package/lib/components/{Render/index.tsx → renderer.tsx} +19 -2
  50. package/lib/index.tsx +41 -41
  51. package/lib/types/index.ts +49 -40
  52. package/package.json +7 -9
  53. package/dist/components/Render/index.d.ts +0 -7
  54. package/dist/components/Render/useJson.d.ts +0 -2
  55. package/dist/components/index.d.ts +0 -7
  56. package/dist/provider.d.ts +0 -8
  57. package/lib/components/Render/useJson.ts +0 -76
  58. package/lib/components/index.tsx +0 -24
  59. package/lib/provider.tsx +0 -39
@@ -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,7 +1,8 @@
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<{