@twintag/twintag-form 0.6.0 → 1.0.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 (80) hide show
  1. package/.eslintrc.cjs +5 -0
  2. package/.turbo/turbo-build.log +14 -9
  3. package/.turbo/turbo-lint.log +4 -0
  4. package/CHANGELOG.md +12 -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 +7930 -8119
  32. package/dist/twintag-form.webcomponent.js +2007 -1769
  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 +6 -6
  60. package/package.json +17 -9
  61. package/prettier.config.mjs +26 -0
  62. package/tailwind.config.ts +43 -0
  63. package/tsconfig.json +14 -3
  64. package/twind.config.ts +4 -21
  65. package/vite.config.ts +1 -1
  66. package/dist/components/Category/__styles.d.ts +0 -29
  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 -460
  71. package/dist/styles.d.ts +0 -487
  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,76 @@
1
+ import type {
2
+ ParsedJsonComponent,
3
+ RawJsonComponent,
4
+ TwintagFormContext,
5
+ } from '@twintag/twintag-form/types';
6
+
7
+ import { useMemo } from 'react';
8
+ import { LabelToString } from 'twintag-types/dom';
9
+ import { v4 as uuid } from 'uuid';
10
+
11
+ import { useTwintagForm } from '@twintag/twintag-form/provider';
12
+
13
+ type Components = TwintagFormContext['components'];
14
+
15
+ const format = (component: RawJsonComponent, components: Components) => {
16
+ const copy = { ...component };
17
+ let formattedConfig: ParsedJsonComponent;
18
+
19
+ if (copy.props) {
20
+ formattedConfig = { ...copy.props } as ParsedJsonComponent;
21
+ } else {
22
+ formattedConfig = { ...copy } as unknown as ParsedJsonComponent;
23
+ }
24
+
25
+ if (!copy.type) return Object.create(null) as ParsedJsonComponent;
26
+
27
+ const [type, subtype = undefined] = copy.type.split(':');
28
+ formattedConfig.id = `${type}-${uuid()}`;
29
+
30
+ const comp = components.get(type);
31
+
32
+ if (comp) {
33
+ formattedConfig.comp = comp;
34
+ }
35
+
36
+ formattedConfig.type = type;
37
+
38
+ if (subtype) {
39
+ formattedConfig.subtype = subtype;
40
+ }
41
+
42
+ if (copy.props) {
43
+ if (copy.props.subtype) {
44
+ formattedConfig.subtype = copy.props.subtype;
45
+ }
46
+
47
+ if (copy.props.label) {
48
+ const labelParsed = LabelToString.safeParse(copy.props.label);
49
+ formattedConfig.label = labelParsed.success
50
+ ? labelParsed.data
51
+ : undefined;
52
+ }
53
+ }
54
+
55
+ if (copy.children && Array.isArray(copy.children)) {
56
+ formattedConfig.items = copy.children.map((item) =>
57
+ format(item, components),
58
+ );
59
+ }
60
+
61
+ return formattedConfig;
62
+ };
63
+
64
+ export const useJson = (config: RawJsonComponent | RawJsonComponent[]) => {
65
+ const { components } = useTwintagForm();
66
+
67
+ const __config = useMemo(() => {
68
+ if (Array.isArray(config)) {
69
+ return config.map((item) => format(item, components));
70
+ }
71
+
72
+ return format(config, components);
73
+ }, [config, components]);
74
+
75
+ return __config;
76
+ };
@@ -0,0 +1,31 @@
1
+ import type { FC } from 'react';
2
+ import type { WithChildren } from 'twintag-types/dom';
3
+
4
+ import { tv } from 'tailwind-variants';
5
+
6
+ const categoryStyle = tv({
7
+ slots: {
8
+ container: 'w-full space-y-4',
9
+ heading: 'font-tf-font text-sm font-bold text-foreground',
10
+ items: 'grid gap-4',
11
+ },
12
+ });
13
+
14
+ type Props = {
15
+ label?: string;
16
+ } & WithChildren;
17
+
18
+ const Category: FC<Props> = ({ label, children }) => {
19
+ const { container, heading, items } = categoryStyle();
20
+
21
+ return (
22
+ <section className={container()}>
23
+ {label ? <h3 className={heading()}>{label}</h3> : <></>}
24
+
25
+ <div className={items()}>{children}</div>
26
+ </section>
27
+ );
28
+ };
29
+ Category.displayName = 'Category';
30
+
31
+ export { Category };
@@ -0,0 +1,75 @@
1
+ import type { FieldValues } from 'react-hook-form';
2
+ import type { WithChildren } from 'twintag-types/dom';
3
+
4
+ import { useEffect, useRef } from 'react';
5
+ import { useForm } from 'react-hook-form';
6
+
7
+ import { Form } from '@twintag/twintag-form/common/form';
8
+
9
+ type Props = {
10
+ resetOnSubmit?: boolean;
11
+ } & WithChildren;
12
+
13
+ export const TwintagForm = ({ resetOnSubmit, children }: Props) => {
14
+ const ref = useRef<HTMLFormElement>(null);
15
+
16
+ const form = useForm();
17
+
18
+ useEffect(() => {
19
+ if (form.formState.isSubmitSuccessful && resetOnSubmit) {
20
+ form.reset();
21
+ }
22
+ }, [form.formState]);
23
+
24
+ const onValid = (data: FieldValues) => {
25
+ const customSubmit = new CustomEvent('twintag-form-valid', {
26
+ detail: data,
27
+ bubbles: true,
28
+ cancelable: false,
29
+ composed: true,
30
+ });
31
+
32
+ ref.current?.dispatchEvent(customSubmit);
33
+ };
34
+
35
+ const onInvalid = (__errors: FieldValues) => {
36
+ const customSubmit = new CustomEvent('twintag-form-invalid', {
37
+ detail: __errors,
38
+ bubbles: true,
39
+ cancelable: false,
40
+ composed: true,
41
+ });
42
+
43
+ ref.current?.dispatchEvent(customSubmit);
44
+ };
45
+
46
+ const onValidate = () => {
47
+ void form.handleSubmit(onValid, onInvalid)();
48
+ };
49
+
50
+ useEffect(() => {
51
+ const form = ref.current;
52
+
53
+ if (form) {
54
+ form.addEventListener('twintag-form-validate', onValidate);
55
+ }
56
+
57
+ return () => {
58
+ if (form) {
59
+ form.removeEventListener('twintag-form-validate', onValidate);
60
+ }
61
+ };
62
+ }, []);
63
+
64
+ return (
65
+ <Form {...form}>
66
+ <form
67
+ ref={ref}
68
+ className='relative space-y-4 font-tf-font'
69
+ onSubmit={form.handleSubmit(onValid, onInvalid)}
70
+ >
71
+ {children}
72
+ </form>
73
+ </Form>
74
+ );
75
+ };
@@ -1,4 +1,27 @@
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 type { RawJsonComponent } from '@twintag/twintag-form/types';
2
+
3
+ import { Renderer } from '@twintag/twintag-form/components/Render';
4
+ import { useJson } from '@twintag/twintag-form/components/Render/useJson';
5
+
6
+ export { Input } from './Input';
7
+ export { Category } from './category';
8
+
9
+ type Props = {
10
+ config: RawJsonComponent | RawJsonComponent[];
11
+ };
12
+
13
+ export const TwintagJsonRenderer = ({ config }: Props) => {
14
+ const __config = useJson(config);
15
+
16
+ if (Array.isArray(__config)) {
17
+ return (
18
+ <>
19
+ {__config.map((item, idx) => (
20
+ <Renderer key={idx} config={item} />
21
+ ))}
22
+ </>
23
+ );
24
+ }
25
+
26
+ return <Renderer config={__config} />;
27
+ };
package/lib/index.tsx CHANGED
@@ -1,56 +1,32 @@
1
- import type { ComponentRef, Ref } from 'react';
2
- import type { RawJsonComponent } from '@twintag/twintag-json-renderer/types';
1
+ import type { ComponentProps, ElementType } from 'react';
2
+ import type { RawJsonComponent } from '@twintag/twintag-form/types';
3
3
 
4
- import { forwardRef } from 'react';
4
+ import { TwintagJsonRenderer } from '@twintag/twintag-form/components';
5
+ import { Category } from '@twintag/twintag-form/components/category';
6
+ import { TwintagForm } from '@twintag/twintag-form/components/form';
7
+ import { Input } from '@twintag/twintag-form/components/Input';
8
+ import { TwintagFormProvider } from '@twintag/twintag-form/provider';
5
9
 
6
- import Form from '@twintag/twintag-form//components/Form';
7
- import Input from '@twintag/twintag-form//components/Input';
8
- import Category from '@twintag/twintag-form//components/Category';
9
-
10
- import {
11
- TwintagJsonRenderer,
12
- TwintagJsonRegisterProvider,
13
- } from '@twintag/twintag-json-renderer';
14
-
15
- const blocks = new Map().set('input', Input);
16
- const containers = new Map().set('category', Category);
10
+ const components = new Map<string, ElementType>()
11
+ .set('input', Input)
12
+ .set('category', Category);
17
13
 
18
14
  type Props = {
19
15
  config: RawJsonComponent[];
20
- options?: {
21
- variant?: string;
16
+ options?: Partial<{
17
+ variant?: ComponentProps<typeof TwintagFormProvider>['variant'];
22
18
  resetOnSubmit?: boolean;
23
- };
19
+ }>;
24
20
  };
25
21
 
26
- export const TwintagForm = forwardRef(
27
- ({ config, options }: Props, ref: Ref<ComponentRef<typeof Form>>) => {
28
- return (
29
- <TwintagJsonRegisterProvider
30
- register={{
31
- blocks,
32
- containers,
33
- custom: new Map(),
34
- }}
35
- >
36
- <Form ref={ref} options={options}>
37
- {config.map((item, idx) => (
38
- <TwintagJsonRenderer
39
- key={idx}
40
- config={{
41
- ...item,
42
- props: {
43
- ...item.props,
44
- options: {
45
- ...item.props.options,
46
- variant: options?.variant,
47
- },
48
- },
49
- }}
50
- />
51
- ))}
52
- </Form>
53
- </TwintagJsonRegisterProvider>
54
- );
55
- },
56
- );
22
+ export const Form = ({ config, options }: Props) => {
23
+ return (
24
+ <TwintagFormProvider variant={options?.variant} components={components}>
25
+ <TwintagForm resetOnSubmit={options?.resetOnSubmit}>
26
+ {config.map((item, idx) => (
27
+ <TwintagJsonRenderer key={idx} config={item} />
28
+ ))}
29
+ </TwintagForm>
30
+ </TwintagFormProvider>
31
+ );
32
+ };
@@ -0,0 +1,36 @@
1
+ import type { TwintagFormContext } from '@twintag/twintag-form/types';
2
+ import type { WithChildren } from 'twintag-types/dom';
3
+
4
+ import { createContext, useContext } from 'react';
5
+
6
+ export const twintagFormContext = createContext<TwintagFormContext>({
7
+ variant: 'default',
8
+ components: new Map(),
9
+ });
10
+
11
+ export const useTwintagForm = () => {
12
+ const context = useContext(twintagFormContext);
13
+
14
+ if (!context) {
15
+ throw new Error('useTwintagForm must be used within a TwintagFormProvider');
16
+ }
17
+
18
+ return context;
19
+ };
20
+
21
+ export const TwintagFormProvider = ({
22
+ children,
23
+ variant,
24
+ components,
25
+ }: TwintagFormContext & WithChildren) => {
26
+ return (
27
+ <twintagFormContext.Provider
28
+ value={{
29
+ variant,
30
+ components,
31
+ }}
32
+ >
33
+ {children}
34
+ </twintagFormContext.Provider>
35
+ );
36
+ };
@@ -0,0 +1,37 @@
1
+ import type { ElementType } from 'react';
2
+
3
+ export type TwintagFormContext = {
4
+ variant?: 'default' | 'beta';
5
+ components: Map<string, ElementType>;
6
+ };
7
+
8
+ type RawProps = Partial<{
9
+ bind: string;
10
+ subtype: string;
11
+ label: string;
12
+ options: Partial<{
13
+ description: string;
14
+ placeholder: string;
15
+ error: string;
16
+ optionalField: boolean;
17
+ }>;
18
+ }>;
19
+
20
+ export type RawJsonComponent = RawProps & {
21
+ type: string;
22
+ children?: RawJsonComponent[];
23
+ } & {
24
+ props?: RawProps;
25
+ };
26
+
27
+ export type Props = Omit<RawProps, 'subtype'> & {
28
+ bind: string;
29
+ items?: ParsedJsonComponent[];
30
+ };
31
+
32
+ export type ParsedJsonComponent = Props & {
33
+ id: string;
34
+ type: string;
35
+ subtype?: string;
36
+ comp?: ElementType;
37
+ };
@@ -1,17 +1,17 @@
1
- import install from '@twind/with-web-components';
2
1
  import r2wc from '@r2wc/react-to-web-component';
2
+ import install from '@twind/with-web-components';
3
3
 
4
- import config from '../twind.config';
4
+ import { Form } from '@twintag/twintag-form/index';
5
5
 
6
- import { TwintagForm } from '@twintag/twintag-form/index';
6
+ import config from '../twind.config';
7
7
 
8
8
  const withTwind = install(config);
9
9
 
10
- const TwintagFormElement = r2wc(TwintagForm, {
11
- props: Object.create({
10
+ const TwintagFormElement = r2wc(Form, {
11
+ props: {
12
12
  config: 'json',
13
13
  options: 'json',
14
- }),
14
+ },
15
15
  shadow: 'open',
16
16
  });
17
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twintag/twintag-form",
3
- "version": "0.6.0",
3
+ "version": "1.0.0-beta.1",
4
4
  "author": "Twintag",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,28 +17,33 @@
17
17
  "@heroicons/react": "^2.0.16",
18
18
  "@r2wc/react-to-web-component": "^2.0.3",
19
19
  "@radix-ui/react-checkbox": "^1.0.4",
20
+ "@radix-ui/react-icons": "^1.3.0",
21
+ "@radix-ui/react-label": "^2.0.2",
22
+ "@radix-ui/react-radio-group": "^1.1.3",
23
+ "@radix-ui/react-slot": "^1.0.2",
20
24
  "@radix-ui/react-switch": "^1.0.2",
21
25
  "@storybook/react": "7.0.2",
22
26
  "@twind/core": "^1.1.3",
23
27
  "@twind/preset-autoprefix": "^1.0.7",
24
28
  "@twind/preset-tailwind": "^1.1.4",
25
- "@twind/preset-tailwind-forms": "^1.1.2",
26
- "@twind/preset-typography": "^1.0.7",
27
29
  "@twind/with-web-components": "^1.1.3",
30
+ "lucide-react": "^0.269.0",
28
31
  "react": "^18.2.0",
29
32
  "react-dom": "^18.2.0",
30
- "react-hook-form": "^7.43.1",
31
- "@twintag/twintag-json-renderer": "0.2.0"
33
+ "react-hook-form": "^7.47.0",
34
+ "uuid": "^9.0.1"
32
35
  },
33
36
  "devDependencies": {
34
37
  "@rollup/plugin-typescript": "^11.1.1",
35
38
  "@storybook/addon-actions": "^7.0.20",
39
+ "@twind/with-react": "^1.1.3",
40
+ "@types/uuid": "^9.0.7",
36
41
  "@vitejs/plugin-react-swc": "^3.4.0",
37
- "eslint": "^8.38.0",
38
42
  "rollup": "^3.18.0",
39
- "vite-plugin-dts": "^3.0.3",
43
+ "tailwindcss": "^3.3.6",
40
44
  "vite": "^4.4.9",
41
- "tailwind-config": "0.2.0",
45
+ "vite-plugin-dts": "^3.0.3",
46
+ "eslint-config-custom": "1.0.0",
42
47
  "tsconfig": "0.0.0",
43
48
  "twintag-types": "0.2.0"
44
49
  },
@@ -46,7 +51,10 @@
46
51
  "access": "public"
47
52
  },
48
53
  "scripts": {
54
+ "dev": "vite",
49
55
  "build": "tsc && vite build",
50
- "lint": "eslint lib --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
56
+ "lint": "eslint . --ext .ts,.tsx",
57
+ "format": "prettier --write \"**/*.{ts,md,tsx,cjs,mjs,json}\" --ignore-path ../../.gitignore",
58
+ "format:check": "prettier --check \"**/*.{ts,tsx,cjs,mjs,json}\" --ignore-path ../../.gitignore"
51
59
  }
52
60
  }
@@ -0,0 +1,26 @@
1
+ import baseConfig from '../../prettier.config.mjs';
2
+
3
+ /**
4
+ * @type {import('prettier').Config & import('prettier-plugin-tailwindcss').PluginOptions &
5
+ * import("@ianvs/prettier-plugin-sort-imports").PluginConfig}
6
+ */
7
+ const config = {
8
+ ...baseConfig,
9
+ importOrder: [
10
+ '<TYPES>^react$',
11
+ '<TYPES>',
12
+ '<TYPES>^@/.*$',
13
+ '<TYPES>^[./]',
14
+ '',
15
+ '^zod$',
16
+ '^react$',
17
+ '<THIRD_PARTY_MODULES>',
18
+ '',
19
+ '^@twintag/twintag-form/.*$',
20
+ '^@/.*$',
21
+ '',
22
+ '^[./]',
23
+ ],
24
+ };
25
+
26
+ export default config;
@@ -0,0 +1,43 @@
1
+ import type { Config } from 'tailwindcss';
2
+
3
+ import { fontFamily } from 'tailwindcss/defaultTheme';
4
+
5
+ const config = {
6
+ content: ['./dev/main.tsx', './lib/**/*.{ts,tsx}', './index.html'],
7
+ theme: {
8
+ extend: {
9
+ colors: {
10
+ background: 'hsl(var(--tf-background) / <alpha-value>)',
11
+ foreground: 'hsl(var(--tf-foreground) / <alpha-value>)',
12
+ primary: {
13
+ DEFAULT: 'hsl(var(--tf-primary) / <alpha-value>)',
14
+ foreground: 'hsl(var(--tf-primary-foreground) / <alpha-value>)',
15
+ },
16
+ accent: {
17
+ DEFAULT: 'hsl(var(--tf-accent) / <alpha-value>)',
18
+ foreground: 'hsl(var(--tf-accent-foreground) / <alpha-value>)',
19
+ },
20
+ destructive: {
21
+ DEFAULT: 'hsl(var(--tf-destructive) / <alpha-value>)',
22
+ foreground: 'hsl(var(--tf-destructive-foreground) / <alpha-value>)',
23
+ },
24
+ muted: {
25
+ DEFAULT: 'hsl(var(--tf-muted) / <alpha-value>)',
26
+ foreground: 'hsl(var(--tf-muted-foreground) / <alpha-value>)',
27
+ },
28
+ input: 'hsl(var(--tf-input) / <alpha-value>)',
29
+ ring: 'hsl(var(--tf-ring) / <alpha-value>)',
30
+ },
31
+ borderRadius: {
32
+ lg: `var(--tf-radius)`,
33
+ md: `calc(var(--tf-radius) - 2px)`,
34
+ sm: 'calc(var(--tf-radius) - 4px)',
35
+ },
36
+ fontFamily: {
37
+ 'tf-font': ['var(--tf-font)', ...fontFamily.sans],
38
+ },
39
+ },
40
+ },
41
+ } satisfies Config;
42
+
43
+ export default config;
package/tsconfig.json CHANGED
@@ -1,7 +1,16 @@
1
1
  {
2
2
  "extends": "tsconfig/vite.json",
3
- "include": ["lib", "types.d.ts", "scripts"],
4
- "exclude": ["dist"],
3
+ "include": [
4
+ ".eslintrc.cjs",
5
+ "prettier.config.mjs",
6
+ "lib",
7
+ "dev",
8
+ "scripts",
9
+ "types.d.ts",
10
+ "tailwind.config.ts",
11
+ "vite.config.ts"
12
+ ],
13
+ "exclude": ["dist", "build", "node_modules"],
5
14
  "compilerOptions": {
6
15
  "baseUrl": ".",
7
16
  "paths": {
@@ -17,6 +26,8 @@
17
26
  "strict": true,
18
27
  "noUnusedLocals": true,
19
28
  "noUnusedParameters": true,
20
- "noFallthroughCasesInSwitch": true
29
+ "noFallthroughCasesInSwitch": true,
30
+
31
+ "allowJs": true
21
32
  }
22
33
  }
package/twind.config.ts CHANGED
@@ -1,29 +1,12 @@
1
1
  import { defineConfig } from '@twind/core';
2
2
  import presetAutoprefix from '@twind/preset-autoprefix';
3
3
  import presetTailwind from '@twind/preset-tailwind';
4
- import presetTypography from '@twind/preset-typography';
5
- import presetTailwindForms from '@twind/preset-tailwind-forms';
4
+
5
+ import tailwindConfig from './tailwind.config';
6
6
 
7
7
  export default defineConfig({
8
8
  theme: {
9
- extend: {
10
- colors: {
11
- primary: 'var(--tt-clr-primary,black)',
12
- accent: 'var(--tt-clr-accent,blue)',
13
- label: 'var(--tt-clr-label,black)',
14
- input: 'var(--tt-clr-input,black)',
15
- placeholder: 'var(--tt-clr-placeholder,#94a3b8)',
16
- 'category-label': 'var(--tt-clr-category-label,black)',
17
- },
18
- fontFamily: {
19
- 'ff-text': ['var(--tt-ff-text)', 'Helvetica', 'Arial', 'sans-serif'],
20
- },
21
- },
9
+ extend: tailwindConfig.theme.extend,
22
10
  },
23
- presets: [
24
- presetAutoprefix(),
25
- presetTailwind(),
26
- presetTypography(),
27
- presetTailwindForms(),
28
- ],
11
+ presets: [presetAutoprefix(), presetTailwind()],
29
12
  });
package/vite.config.ts CHANGED
@@ -1,6 +1,6 @@
1
+ import react from '@vitejs/plugin-react-swc';
1
2
  import { resolve } from 'pathe';
2
3
  import { defineConfig } from 'vite';
3
- import react from '@vitejs/plugin-react-swc';
4
4
  import dts from 'vite-plugin-dts';
5
5
 
6
6
  // https://vitejs.dev/config/
@@ -1,29 +0,0 @@
1
- import { TVConfig } from 'tailwind-variants/dist/config.js';
2
- import { TVReturnType } from 'tailwind-variants';
3
- export declare const categoryStyle: TVReturnType<{
4
- variant: {};
5
- }, {
6
- container: string;
7
- span: string;
8
- items: string;
9
- }, undefined, TVConfig<{
10
- variant: {};
11
- }, {
12
- variant: {};
13
- }>, {
14
- variant: {};
15
- }, {
16
- container: string;
17
- span: string;
18
- items: string;
19
- }, TVReturnType<{
20
- variant: {};
21
- }, {
22
- container: string;
23
- span: string;
24
- items: string;
25
- }, undefined, TVConfig<{
26
- variant: {};
27
- }, {
28
- variant: {};
29
- }>, unknown, unknown, undefined>>;
@@ -1,8 +0,0 @@
1
- import type { FC } from 'react';
2
- import type { VariantProps } from 'tailwind-variants';
3
- import type { WithChildren } from 'twintag-types/dom';
4
- import type { CommonProps } from '../Input/__props';
5
- import { categoryStyle } from './__styles';
6
- type Props = CommonProps<VariantProps<typeof categoryStyle>['variant']> & WithChildren;
7
- declare const Category: FC<Props>;
8
- export default Category;
@@ -1,12 +0,0 @@
1
- import { ForwardRefExoticComponent, ReactNode, RefAttributes } from 'react';
2
- /// <reference types="react" />
3
- declare const Form: ForwardRefExoticComponent<{
4
- options?: {
5
- resetOnSubmit?: boolean | undefined;
6
- } | undefined;
7
- } & {
8
- children?: ReactNode;
9
- } & RefAttributes<{
10
- validate?: (() => void) | undefined;
11
- }>>;
12
- export default Form;
@@ -1,10 +0,0 @@
1
- export type CommonProps<TVariant> = {
2
- label: string;
3
- bind: string;
4
- checked?: boolean;
5
- options?: {
6
- variant?: TVariant;
7
- placeholder?: string;
8
- optionalField?: boolean;
9
- };
10
- };