@twintag/twintag-form 1.6.2-beta.0 → 1.6.2-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.
- package/.turbo/turbo-build.log +22 -0
- package/CHANGELOG.md +221 -215
- package/README.md +407 -407
- package/dev/main.tsx +460 -460
- package/dist/common/accordion.d.ts +7 -0
- package/dist/common/button.d.ts +71 -0
- package/dist/common/calendar.d.ts +139 -0
- package/dist/common/checkbox.d.ts +4 -0
- package/dist/common/form.d.ts +86 -0
- package/dist/common/icon.d.ts +8 -0
- package/dist/common/input.d.ts +133 -0
- package/dist/common/label.d.ts +21 -0
- package/dist/common/popover.d.ts +6 -0
- package/dist/common/radiogroup.d.ts +5 -0
- package/dist/common/slider.d.ts +4 -0
- package/dist/common/switch.d.ts +4 -0
- package/dist/common/textarea.d.ts +68 -0
- package/dist/components/config.d.ts +6 -0
- package/dist/components/containers/accordion.d.ts +7 -0
- package/dist/components/containers/category.d.ts +8 -0
- package/dist/components/fields/checkbox.d.ts +5 -0
- package/dist/components/fields/date-picker.d.ts +4 -0
- package/dist/components/fields/file.d.ts +5 -0
- package/dist/components/fields/input.d.ts +5 -0
- package/dist/components/fields/radiogroup.d.ts +7 -0
- package/dist/components/fields/submit.d.ts +4 -0
- package/dist/components/fields/textarea.d.ts +5 -0
- package/dist/components/fields/toggle.d.ts +5 -0
- package/dist/components/fields/tri-toggle.d.ts +5 -0
- package/dist/components/form.d.ts +9 -0
- package/dist/components/input.d.ts +4 -0
- package/dist/components/label.d.ts +4 -0
- package/dist/components/provider.d.ts +14 -0
- package/dist/components/renderer.d.ts +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +4465 -0
- package/dist/types/index.d.ts +68 -0
- package/dist/utils/data.d.ts +7 -0
- package/dist/utils/string.d.ts +3 -0
- package/dist/utils/style.d.ts +3 -0
- package/dist/webcomponent.cjs +1 -0
- package/dist/webcomponent.d.ts +1 -0
- package/dist/webcomponent.js +1165 -0
- package/lib/components/fields/date-picker.tsx +154 -154
- package/lib/components/fields/file.tsx +84 -84
- package/lib/components/fields/input.tsx +70 -70
- package/lib/components/fields/textarea.tsx +72 -72
- package/lib/components/provider.tsx +162 -162
- package/lib/index.tsx +45 -45
- package/lib/types/index.ts +102 -102
- package/lib/webcomponent.ts +2 -2
- package/package.json +1 -1
- package/vite.config.ts +2 -1
package/lib/types/index.ts
CHANGED
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
import type { ElementType } from 'react';
|
|
2
|
-
|
|
3
|
-
export type InputCompConfig = {
|
|
4
|
-
defaultValue?: unknown;
|
|
5
|
-
component: ElementType;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
type BaseInputOptions = Partial<{
|
|
9
|
-
description: string;
|
|
10
|
-
error: string;
|
|
11
|
-
optionalField: boolean;
|
|
12
|
-
}>;
|
|
13
|
-
|
|
14
|
-
type TextInputOptions = BaseInputOptions & {
|
|
15
|
-
placeholder?: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
type DatePickerInputOptions = BaseInputOptions & {
|
|
19
|
-
placeholder?: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
type FileInputOptions = BaseInputOptions & {
|
|
23
|
-
accept?: string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
type CompType = 'input' | 'item' | 'accordion' | 'category';
|
|
27
|
-
type StringLiteral<T> = T extends string
|
|
28
|
-
? string extends T
|
|
29
|
-
? never
|
|
30
|
-
: T
|
|
31
|
-
: never;
|
|
32
|
-
|
|
33
|
-
type RawProps<
|
|
34
|
-
TType extends string = string,
|
|
35
|
-
TSubtype extends string = string,
|
|
36
|
-
> = TType extends 'input' | 'item'
|
|
37
|
-
? {
|
|
38
|
-
type: TType;
|
|
39
|
-
bind: string;
|
|
40
|
-
label?: string;
|
|
41
|
-
subtype?: string;
|
|
42
|
-
options?: TSubtype extends 'text' | 'textarea'
|
|
43
|
-
? TextInputOptions
|
|
44
|
-
: TSubtype extends 'datepicker'
|
|
45
|
-
? DatePickerInputOptions
|
|
46
|
-
: TSubtype extends 'file'
|
|
47
|
-
? FileInputOptions
|
|
48
|
-
: BaseInputOptions;
|
|
49
|
-
}
|
|
50
|
-
: TType extends 'accordion'
|
|
51
|
-
? TSubtype extends 'item'
|
|
52
|
-
? {
|
|
53
|
-
type: TType;
|
|
54
|
-
subtype: TSubtype;
|
|
55
|
-
value?: string;
|
|
56
|
-
label: string;
|
|
57
|
-
icon: string;
|
|
58
|
-
}
|
|
59
|
-
: TSubtype extends 'multiple' | 'single'
|
|
60
|
-
? { type: TType; subtype: TSubtype; defaultValue?: string }
|
|
61
|
-
: never
|
|
62
|
-
: {
|
|
63
|
-
type: TType;
|
|
64
|
-
label?: string;
|
|
65
|
-
subtype?: string;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export type RawJsonComponent = CompType extends infer T
|
|
69
|
-
? T extends CompType
|
|
70
|
-
? {
|
|
71
|
-
type: StringLiteral<T>;
|
|
72
|
-
props?: Omit<RawProps<StringLiteral<T>>, 'type'>;
|
|
73
|
-
children?: RawJsonComponent[];
|
|
74
|
-
}
|
|
75
|
-
: never
|
|
76
|
-
: never;
|
|
77
|
-
|
|
78
|
-
export type ParsedJsonComponent<TType extends string = string> =
|
|
79
|
-
RawProps<TType> & {
|
|
80
|
-
id: string;
|
|
81
|
-
type: string;
|
|
82
|
-
subtype?: string;
|
|
83
|
-
comp?: ElementType;
|
|
84
|
-
items?: ParsedJsonComponent[];
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export type Props<
|
|
88
|
-
TType extends string = string,
|
|
89
|
-
TSubtype extends string = string,
|
|
90
|
-
> = Omit<RawProps<TType, TSubtype>, 'type'> & {
|
|
91
|
-
items?: (Props<'input'> & ParsedJsonComponent)[];
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export type TwintagFormContext = {
|
|
95
|
-
variant?: 'default' | 'outline';
|
|
96
|
-
size?: 'base' | 'sm';
|
|
97
|
-
inputs: Map<string, InputCompConfig>;
|
|
98
|
-
components: Map<string, ElementType>;
|
|
99
|
-
config: ParsedJsonComponent[] | ParsedJsonComponent;
|
|
100
|
-
resetValues: Record<string, unknown>;
|
|
101
|
-
acceptFileType?: string;
|
|
102
|
-
};
|
|
1
|
+
import type { ElementType } from 'react';
|
|
2
|
+
|
|
3
|
+
export type InputCompConfig = {
|
|
4
|
+
defaultValue?: unknown;
|
|
5
|
+
component: ElementType;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
type BaseInputOptions = Partial<{
|
|
9
|
+
description: string;
|
|
10
|
+
error: string;
|
|
11
|
+
optionalField: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
|
|
14
|
+
type TextInputOptions = BaseInputOptions & {
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type DatePickerInputOptions = BaseInputOptions & {
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type FileInputOptions = BaseInputOptions & {
|
|
23
|
+
accept?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type CompType = 'input' | 'item' | 'accordion' | 'category';
|
|
27
|
+
type StringLiteral<T> = T extends string
|
|
28
|
+
? string extends T
|
|
29
|
+
? never
|
|
30
|
+
: T
|
|
31
|
+
: never;
|
|
32
|
+
|
|
33
|
+
type RawProps<
|
|
34
|
+
TType extends string = string,
|
|
35
|
+
TSubtype extends string = string,
|
|
36
|
+
> = TType extends 'input' | 'item'
|
|
37
|
+
? {
|
|
38
|
+
type: TType;
|
|
39
|
+
bind: string;
|
|
40
|
+
label?: string;
|
|
41
|
+
subtype?: string;
|
|
42
|
+
options?: TSubtype extends 'text' | 'textarea'
|
|
43
|
+
? TextInputOptions
|
|
44
|
+
: TSubtype extends 'datepicker'
|
|
45
|
+
? DatePickerInputOptions
|
|
46
|
+
: TSubtype extends 'file'
|
|
47
|
+
? FileInputOptions
|
|
48
|
+
: BaseInputOptions;
|
|
49
|
+
}
|
|
50
|
+
: TType extends 'accordion'
|
|
51
|
+
? TSubtype extends 'item'
|
|
52
|
+
? {
|
|
53
|
+
type: TType;
|
|
54
|
+
subtype: TSubtype;
|
|
55
|
+
value?: string;
|
|
56
|
+
label: string;
|
|
57
|
+
icon: string;
|
|
58
|
+
}
|
|
59
|
+
: TSubtype extends 'multiple' | 'single'
|
|
60
|
+
? { type: TType; subtype: TSubtype; defaultValue?: string }
|
|
61
|
+
: never
|
|
62
|
+
: {
|
|
63
|
+
type: TType;
|
|
64
|
+
label?: string;
|
|
65
|
+
subtype?: string;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type RawJsonComponent = CompType extends infer T
|
|
69
|
+
? T extends CompType
|
|
70
|
+
? {
|
|
71
|
+
type: StringLiteral<T>;
|
|
72
|
+
props?: Omit<RawProps<StringLiteral<T>>, 'type'>;
|
|
73
|
+
children?: RawJsonComponent[];
|
|
74
|
+
}
|
|
75
|
+
: never
|
|
76
|
+
: never;
|
|
77
|
+
|
|
78
|
+
export type ParsedJsonComponent<TType extends string = string> =
|
|
79
|
+
RawProps<TType> & {
|
|
80
|
+
id: string;
|
|
81
|
+
type: string;
|
|
82
|
+
subtype?: string;
|
|
83
|
+
comp?: ElementType;
|
|
84
|
+
items?: ParsedJsonComponent[];
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export type Props<
|
|
88
|
+
TType extends string = string,
|
|
89
|
+
TSubtype extends string = string,
|
|
90
|
+
> = Omit<RawProps<TType, TSubtype>, 'type'> & {
|
|
91
|
+
items?: (Props<'input'> & ParsedJsonComponent)[];
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export type TwintagFormContext = {
|
|
95
|
+
variant?: 'default' | 'outline';
|
|
96
|
+
size?: 'base' | 'sm';
|
|
97
|
+
inputs: Map<string, InputCompConfig>;
|
|
98
|
+
components: Map<string, ElementType>;
|
|
99
|
+
config: ParsedJsonComponent[] | ParsedJsonComponent;
|
|
100
|
+
resetValues: Record<string, unknown>;
|
|
101
|
+
acceptFileType?: string;
|
|
102
|
+
};
|
package/lib/webcomponent.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import r2wc from '@r2wc/react-to-web-component';
|
|
2
2
|
import install from '@twind/with-web-components';
|
|
3
3
|
|
|
4
|
-
import { Form } from '
|
|
4
|
+
import { Form } from './index';
|
|
5
5
|
|
|
6
6
|
import config from '../twind.config';
|
|
7
7
|
|
|
8
8
|
const withTwind = install(config);
|
|
9
9
|
|
|
10
|
-
const TwintagFormElement = r2wc(Form, {
|
|
10
|
+
export const TwintagFormElement = r2wc(Form, {
|
|
11
11
|
props: {
|
|
12
12
|
config: 'json',
|
|
13
13
|
options: 'json',
|
package/package.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import react from '@vitejs/plugin-react-swc';
|
|
2
2
|
import { dirname, resolve } from 'pathe';
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
3
4
|
import { defineConfig } from 'vite';
|
|
4
5
|
import dts from 'vite-plugin-dts';
|
|
5
6
|
|
|
6
7
|
import { dependencies, devDependencies } from './package.json';
|
|
7
8
|
|
|
8
|
-
export const __dirname = dirname(
|
|
9
|
+
export const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
10
|
|
|
10
11
|
const externalPackages = [
|
|
11
12
|
...Object.keys(dependencies || {}),
|