@twintag/twintag-form 0.5.0 → 1.0.0-beta.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 (80) hide show
  1. package/.eslintrc.cjs +6 -1
  2. package/.turbo/turbo-build.log +15 -10
  3. package/.turbo/turbo-lint.log +4 -0
  4. package/CHANGELOG.md +17 -0
  5. package/README.md +87 -59
  6. package/dev/index.css +29 -0
  7. package/dev/main.tsx +163 -0
  8. package/dist/common/button.d.ts +137 -0
  9. package/dist/common/checkbox.d.ts +4 -0
  10. package/dist/common/form.d.ts +24 -0
  11. package/dist/common/input.d.ts +4 -0
  12. package/dist/common/label.d.ts +4 -0
  13. package/dist/common/radiogroup.d.ts +5 -0
  14. package/dist/common/switch.d.ts +4 -0
  15. package/dist/common/textarea.d.ts +4 -0
  16. package/dist/components/Input/checkbox.d.ts +2 -6
  17. package/dist/components/Input/file.d.ts +2 -6
  18. package/dist/components/Input/index.d.ts +2 -2
  19. package/dist/components/Input/radiogroup.d.ts +3 -0
  20. package/dist/components/Input/simple.d.ts +2 -6
  21. package/dist/components/Input/submit.d.ts +2 -6
  22. package/dist/components/Input/textarea.d.ts +2 -6
  23. package/dist/components/Input/toggle.d.ts +2 -6
  24. package/dist/components/Render/index.d.ts +7 -0
  25. package/dist/components/Render/useJson.d.ts +2 -0
  26. package/dist/components/{Label/index.d.ts → category.d.ts} +3 -4
  27. package/dist/components/form.d.ts +7 -0
  28. package/dist/components/index.d.ts +8 -4
  29. package/dist/index.d.ts +8 -9
  30. package/dist/provider.d.ts +8 -0
  31. package/dist/twintag-form.react.js +7961 -8082
  32. package/dist/twintag-form.webcomponent.js +2003 -1765
  33. package/dist/types/index.d.ts +33 -0
  34. package/index.html +13 -0
  35. package/lib/common/button.tsx +49 -0
  36. package/lib/common/checkbox.tsx +40 -0
  37. package/lib/common/form.tsx +192 -0
  38. package/lib/common/input.tsx +55 -0
  39. package/lib/common/label.tsx +26 -0
  40. package/lib/common/radiogroup.tsx +56 -0
  41. package/lib/common/switch.tsx +39 -0
  42. package/lib/common/textarea.tsx +53 -0
  43. package/lib/components/Input/checkbox.tsx +55 -42
  44. package/lib/components/Input/file.tsx +64 -72
  45. package/lib/components/Input/index.tsx +15 -15
  46. package/lib/components/Input/radiogroup.tsx +84 -0
  47. package/lib/components/Input/simple.tsx +50 -28
  48. package/lib/components/Input/submit.tsx +4 -13
  49. package/lib/components/Input/textarea.tsx +49 -27
  50. package/lib/components/Input/toggle.tsx +54 -45
  51. package/lib/components/Render/index.tsx +30 -0
  52. package/lib/components/Render/useJson.ts +76 -0
  53. package/lib/components/category.tsx +31 -0
  54. package/lib/components/form.tsx +75 -0
  55. package/lib/components/index.tsx +27 -4
  56. package/lib/index.tsx +24 -48
  57. package/lib/provider.tsx +36 -0
  58. package/lib/types/index.ts +37 -0
  59. package/lib/webcomponent.ts +4 -4
  60. package/package.json +21 -12
  61. package/prettier.config.mjs +26 -0
  62. package/tailwind.config.ts +43 -0
  63. package/tsconfig.json +25 -6
  64. package/twind.config.ts +4 -21
  65. package/vite.config.ts +2 -2
  66. package/dist/components/Category/__styles.d.ts +0 -19
  67. package/dist/components/Category/index.d.ts +0 -8
  68. package/dist/components/Form/index.d.ts +0 -12
  69. package/dist/components/Input/__props.d.ts +0 -10
  70. package/dist/components/Input/__styles.d.ts +0 -245
  71. package/dist/styles.d.ts +0 -262
  72. package/lib/__stories__/Form.stories.tsx +0 -141
  73. package/lib/components/Category/__styles.ts +0 -12
  74. package/lib/components/Category/index.tsx +0 -26
  75. package/lib/components/Form/index.tsx +0 -86
  76. package/lib/components/Input/__props.ts +0 -10
  77. package/lib/components/Input/__styles.ts +0 -132
  78. package/lib/components/Label/index.tsx +0 -24
  79. package/lib/styles.ts +0 -143
  80. package/tailwind.config.cjs +0 -8
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import * as LabelPrimitive from '@radix-ui/react-label';
3
+ declare const Label: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & React.RefAttributes<HTMLLabelElement>>;
4
+ export { Label };
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
3
+ declare const RadioGroup: React.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
4
+ declare const RadioGroupItem: React.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupItemProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
5
+ export { RadioGroup, RadioGroupItem };
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import * as SwitchPrimitives from '@radix-ui/react-switch';
3
+ declare const Switch: React.ForwardRefExoticComponent<Omit<SwitchPrimitives.SwitchProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
4
+ export { Switch };
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
3
+ declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
4
+ export { Textarea };
@@ -1,7 +1,3 @@
1
1
  import type { FC } from 'react';
2
- import type { VariantProps } from 'tailwind-variants';
3
- import { type CommonProps } from './__props';
4
- import { checkboxStyle } from './__styles';
5
- type Props = CommonProps<VariantProps<typeof checkboxStyle>['variant']>;
6
- declare const Checkbox: FC<Props>;
7
- export default Checkbox;
2
+ import type { Props } from '../../types';
3
+ export declare const Checkbox: FC<Props>;
@@ -1,7 +1,3 @@
1
1
  import type { FC } from 'react';
2
- import type { VariantProps } from 'tailwind-variants';
3
- import { type CommonProps } from './__props';
4
- import { fileStyle } from './__styles';
5
- type Props = CommonProps<VariantProps<typeof fileStyle>['variant']>;
6
- declare const File: FC<Props>;
7
- export default File;
2
+ import type { Props } from '../../types';
3
+ export declare const File: FC<Props>;
@@ -4,5 +4,5 @@ type Props = {
4
4
  label?: string;
5
5
  bind?: string;
6
6
  };
7
- declare const Input: FC<Props>;
8
- export default Input;
7
+ export declare const Input: FC<Props>;
8
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { FC } from 'react';
2
+ import type { Props } from '../../types';
3
+ export declare const RadioGroup: FC<Props>;
@@ -1,7 +1,3 @@
1
1
  import type { FC } from 'react';
2
- import type { VariantProps } from 'tailwind-variants';
3
- import { type CommonProps } from './__props';
4
- import { simpleStyle } from './__styles';
5
- type Props = CommonProps<VariantProps<typeof simpleStyle>['variant']>;
6
- declare const Simple: FC<Props>;
7
- export default Simple;
2
+ import type { Props } from '../../types';
3
+ export declare const Simple: FC<Props>;
@@ -1,7 +1,3 @@
1
1
  import type { FC } from 'react';
2
- import type { VariantProps } from 'tailwind-variants';
3
- import { type CommonProps } from './__props';
4
- import { submitStyle } from './__styles';
5
- type Props = CommonProps<VariantProps<typeof submitStyle>['variant']>;
6
- declare const Submit: FC<Props>;
7
- export default Submit;
2
+ import type { Props } from '../../types';
3
+ export declare const Submit: FC<Props>;
@@ -1,7 +1,3 @@
1
1
  import type { FC } from 'react';
2
- import type { VariantProps } from 'tailwind-variants';
3
- import { type CommonProps } from './__props';
4
- import { simpleStyle } from './__styles';
5
- type Props = CommonProps<VariantProps<typeof simpleStyle>['variant']>;
6
- declare const Textarea: FC<Props>;
7
- export default Textarea;
2
+ import type { Props } from '../../types';
3
+ export declare const Textarea: FC<Props>;
@@ -1,7 +1,3 @@
1
1
  import type { FC } from 'react';
2
- import type { VariantProps } from 'tailwind-variants';
3
- import { type CommonProps } from './__props';
4
- import { toggleStyle } from './__styles';
5
- type Props = CommonProps<VariantProps<typeof toggleStyle>['variant']>;
6
- declare const Toggle: FC<Props>;
7
- export default Toggle;
2
+ import type { Props } from '../../types';
3
+ export declare const Toggle: FC<Props>;
@@ -0,0 +1,7 @@
1
+ import type { FC } from 'react';
2
+ import type { ParsedJsonComponent } from '../../types';
3
+ type Props = {
4
+ config: ParsedJsonComponent;
5
+ };
6
+ export declare const Renderer: FC<Props>;
7
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { ParsedJsonComponent, RawJsonComponent } from '../../types';
2
+ export declare const useJson: (config: RawJsonComponent | RawJsonComponent[]) => ParsedJsonComponent | ParsedJsonComponent[];
@@ -1,8 +1,7 @@
1
1
  import type { FC } from 'react';
2
2
  import type { WithChildren } from 'twintag-types/dom';
3
3
  type Props = {
4
- required?: boolean;
5
- className?: string;
4
+ label?: string;
6
5
  } & WithChildren;
7
- declare const Label: FC<Props>;
8
- export default Label;
6
+ declare const Category: FC<Props>;
7
+ export { Category };
@@ -0,0 +1,7 @@
1
+ import { JSX } from 'react/jsx-runtime';
2
+ import type { WithChildren } from 'twintag-types/dom';
3
+ type Props = {
4
+ resetOnSubmit?: boolean;
5
+ } & WithChildren;
6
+ export declare const TwintagForm: ({ resetOnSubmit, children }: Props) => JSX.Element;
7
+ export {};
@@ -1,4 +1,8 @@
1
- export { default as Form } from './Form';
2
- export { default as Input } from './Input';
3
- export { default as Label } from './Label';
4
- export { default as Category } from './Category';
1
+ import { JSX } from 'react/jsx-runtime';
2
+ import type { RawJsonComponent } from '../types';
3
+ export { Input } from './Input';
4
+ export { Category } from './category';
5
+ type Props = {
6
+ config: RawJsonComponent | RawJsonComponent[];
7
+ };
8
+ export declare const TwintagJsonRenderer: ({ config }: Props) => JSX.Element;
package/dist/index.d.ts CHANGED
@@ -1,14 +1,13 @@
1
- import { ForwardRefExoticComponent, RefAttributes } from 'react';
2
- /// <reference types="react" />
3
- import type { RawJsonComponent } from '@twintag/twintag-json-renderer/types';
1
+ import { JSX } from 'react/jsx-runtime';
2
+ import type { ComponentProps } from 'react';
3
+ import type { RawJsonComponent } from './types';
4
+ import { TwintagFormProvider } from './provider';
4
5
  type Props = {
5
6
  config: RawJsonComponent[];
6
- options?: {
7
- variant?: string;
7
+ options?: Partial<{
8
+ variant?: ComponentProps<typeof TwintagFormProvider>['variant'];
8
9
  resetOnSubmit?: boolean;
9
- };
10
+ }>;
10
11
  };
11
- export declare const TwintagForm: ForwardRefExoticComponent<Props & RefAttributes<{
12
- validate: () => void;
13
- }>>;
12
+ export declare const Form: ({ config, options }: Props) => JSX.Element;
14
13
  export {};
@@ -0,0 +1,8 @@
1
+ import { JSX } from 'react/jsx-runtime';
2
+ import { Context } from 'react';
3
+ /// <reference types="react" />
4
+ import type { TwintagFormContext } from './types';
5
+ import type { WithChildren } from 'twintag-types/dom';
6
+ export declare const twintagFormContext: Context<TwintagFormContext>;
7
+ export declare const useTwintagForm: () => TwintagFormContext;
8
+ export declare const TwintagFormProvider: ({ children, variant, components, }: TwintagFormContext & WithChildren) => JSX.Element;