@twintag/twintag-form 1.6.1 → 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 +11 -11
- package/CHANGELOG.md +221 -209
- package/README.md +407 -370
- package/dev/index.css +32 -32
- package/dev/main.tsx +460 -459
- package/dist/components/fields/date-picker.d.ts +1 -1
- package/dist/components/fields/file.d.ts +1 -1
- package/dist/components/fields/input.d.ts +1 -1
- package/dist/components/fields/textarea.d.ts +1 -1
- package/dist/components/provider.d.ts +1 -6
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +152 -143
- package/dist/types/index.d.ts +16 -6
- package/dist/webcomponent.cjs +1 -1
- package/dist/webcomponent.d.ts +1 -1
- package/dist/webcomponent.js +3 -0
- package/lib/components/fields/date-picker.tsx +154 -154
- package/lib/components/fields/file.tsx +84 -83
- package/lib/components/fields/input.tsx +70 -70
- package/lib/components/fields/textarea.tsx +72 -68
- package/lib/components/provider.tsx +162 -163
- package/lib/index.tsx +45 -41
- package/lib/types/index.ts +102 -82
- package/lib/webcomponent.ts +2 -2
- package/package.json +1 -1
- package/vite.config.ts +2 -1
|
@@ -1,163 +1,162 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ParsedJsonComponent,
|
|
3
|
-
RawJsonComponent,
|
|
4
|
-
TwintagFormContext,
|
|
5
|
-
} from '@twintag/twintag-form/types';
|
|
6
|
-
import type { WithChildren } from 'twintag-types/dom';
|
|
7
|
-
|
|
8
|
-
import { createContext, useContext, useMemo } from 'react';
|
|
9
|
-
import { LabelToString } from 'twintag-types/dom';
|
|
10
|
-
import { v4 as uuid } from 'uuid';
|
|
11
|
-
|
|
12
|
-
export const twintagFormContext = createContext<TwintagFormContext>({
|
|
13
|
-
variant: 'default',
|
|
14
|
-
size: 'base',
|
|
15
|
-
inputs: new Map(),
|
|
16
|
-
components: new Map(),
|
|
17
|
-
config: [],
|
|
18
|
-
resetValues: {},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
type
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
'
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
};
|
|
1
|
+
import type {
|
|
2
|
+
ParsedJsonComponent,
|
|
3
|
+
RawJsonComponent,
|
|
4
|
+
TwintagFormContext,
|
|
5
|
+
} from '@twintag/twintag-form/types';
|
|
6
|
+
import type { WithChildren } from 'twintag-types/dom';
|
|
7
|
+
|
|
8
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
9
|
+
import { LabelToString } from 'twintag-types/dom';
|
|
10
|
+
import { v4 as uuid } from 'uuid';
|
|
11
|
+
|
|
12
|
+
export const twintagFormContext = createContext<TwintagFormContext>({
|
|
13
|
+
variant: 'default',
|
|
14
|
+
size: 'base',
|
|
15
|
+
inputs: new Map(),
|
|
16
|
+
components: new Map(),
|
|
17
|
+
config: [],
|
|
18
|
+
resetValues: {},
|
|
19
|
+
acceptFileType: undefined,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const useTwintagForm = () => {
|
|
23
|
+
const context = useContext(twintagFormContext);
|
|
24
|
+
|
|
25
|
+
if (!context) {
|
|
26
|
+
throw new Error('useTwintagForm must be used within a TwintagFormProvider');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return context;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type Components = TwintagFormContext['components'];
|
|
33
|
+
type Inputs = TwintagFormContext['inputs'];
|
|
34
|
+
|
|
35
|
+
const format = (component: RawJsonComponent, components: Components) => {
|
|
36
|
+
const copy = { ...component };
|
|
37
|
+
let formattedConfig: ParsedJsonComponent;
|
|
38
|
+
|
|
39
|
+
if (copy.props) {
|
|
40
|
+
formattedConfig = { ...copy.props } as ParsedJsonComponent;
|
|
41
|
+
} else {
|
|
42
|
+
formattedConfig = { ...copy } as unknown as ParsedJsonComponent;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!copy.type) return Object.create(null) as ParsedJsonComponent;
|
|
46
|
+
|
|
47
|
+
const [type, subtype = undefined] = copy.type.split(':');
|
|
48
|
+
formattedConfig.id = `${type}-${uuid()}`;
|
|
49
|
+
|
|
50
|
+
const comp = components.get(type);
|
|
51
|
+
|
|
52
|
+
if (comp) {
|
|
53
|
+
formattedConfig.comp = comp;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
formattedConfig.type = type;
|
|
57
|
+
|
|
58
|
+
if (subtype) {
|
|
59
|
+
formattedConfig.subtype = subtype;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (copy.props) {
|
|
63
|
+
if (copy.props.subtype) {
|
|
64
|
+
formattedConfig.subtype = copy.props.subtype;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (copy.props.label) {
|
|
68
|
+
const labelParsed = LabelToString.safeParse(copy.props.label);
|
|
69
|
+
formattedConfig.label = labelParsed.success
|
|
70
|
+
? labelParsed.data
|
|
71
|
+
: undefined;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (copy.children && Array.isArray(copy.children)) {
|
|
76
|
+
formattedConfig.items = copy.children.map((item) =>
|
|
77
|
+
format(item, components),
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return formattedConfig;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const getResetValues = (
|
|
85
|
+
config: ParsedJsonComponent | ParsedJsonComponent[],
|
|
86
|
+
inputs: Inputs,
|
|
87
|
+
) => {
|
|
88
|
+
const stack = Array.isArray(config) ? [...config] : [config];
|
|
89
|
+
|
|
90
|
+
const resetValues = new Map<string, unknown>();
|
|
91
|
+
|
|
92
|
+
while (stack.length > 0) {
|
|
93
|
+
const currentObj = stack.pop();
|
|
94
|
+
|
|
95
|
+
if (!currentObj) continue;
|
|
96
|
+
|
|
97
|
+
for (const [key, value] of Object.entries(currentObj)) {
|
|
98
|
+
if (Array.isArray(value)) {
|
|
99
|
+
for (const item of value) {
|
|
100
|
+
stack.push(item);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (typeof value === 'object' && value !== null) {
|
|
105
|
+
stack.push(value as unknown as ParsedJsonComponent);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (
|
|
109
|
+
key === 'subtype' &&
|
|
110
|
+
'bind' in currentObj &&
|
|
111
|
+
typeof currentObj.bind === 'string'
|
|
112
|
+
) {
|
|
113
|
+
resetValues.set(
|
|
114
|
+
currentObj.bind,
|
|
115
|
+
inputs.get(value as string)?.defaultValue,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return Object.fromEntries(resetValues);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export const TwintagFormProvider = ({
|
|
125
|
+
variant,
|
|
126
|
+
size,
|
|
127
|
+
inputs,
|
|
128
|
+
components,
|
|
129
|
+
config,
|
|
130
|
+
acceptFileType,
|
|
131
|
+
children,
|
|
132
|
+
}: Omit<TwintagFormContext, 'config' | 'resetValues'> & {
|
|
133
|
+
config: RawJsonComponent | RawJsonComponent[];
|
|
134
|
+
} & WithChildren) => {
|
|
135
|
+
const __config = useMemo(() => {
|
|
136
|
+
if (Array.isArray(config)) {
|
|
137
|
+
return config.map((item) => format(item, components));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return format(config, components);
|
|
141
|
+
}, [config, components]);
|
|
142
|
+
|
|
143
|
+
const resetValues = useMemo(() => {
|
|
144
|
+
return getResetValues(__config, inputs);
|
|
145
|
+
}, [__config, inputs]);
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<twintagFormContext.Provider
|
|
149
|
+
value={{
|
|
150
|
+
config: __config,
|
|
151
|
+
variant,
|
|
152
|
+
size,
|
|
153
|
+
inputs,
|
|
154
|
+
components,
|
|
155
|
+
resetValues,
|
|
156
|
+
acceptFileType,
|
|
157
|
+
}}
|
|
158
|
+
>
|
|
159
|
+
{children}
|
|
160
|
+
</twintagFormContext.Provider>
|
|
161
|
+
);
|
|
162
|
+
};
|
package/lib/index.tsx
CHANGED
|
@@ -1,41 +1,45 @@
|
|
|
1
|
-
import type { ComponentProps } from 'react';
|
|
2
|
-
import type { RawJsonComponent } from '@twintag/twintag-form/types';
|
|
3
|
-
|
|
4
|
-
import { forwardRef } from 'react';
|
|
5
|
-
|
|
6
|
-
import { components, Inputs } from '@twintag/twintag-form/components/config';
|
|
7
|
-
import { TwintagForm } from '@twintag/twintag-form/components/form';
|
|
8
|
-
import { TwintagFormProvider } from '@twintag/twintag-form/components/provider';
|
|
9
|
-
import { JsonRenderer } from '@twintag/twintag-form/components/renderer';
|
|
10
|
-
|
|
11
|
-
type Props = {
|
|
12
|
-
config: RawJsonComponent[];
|
|
13
|
-
options?: Partial<{
|
|
14
|
-
defaultValues
|
|
15
|
-
variant
|
|
16
|
-
size
|
|
17
|
-
resetOnSubmit?: boolean;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import type { RawJsonComponent } from '@twintag/twintag-form/types';
|
|
3
|
+
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
|
+
|
|
6
|
+
import { components, Inputs } from '@twintag/twintag-form/components/config';
|
|
7
|
+
import { TwintagForm } from '@twintag/twintag-form/components/form';
|
|
8
|
+
import { TwintagFormProvider } from '@twintag/twintag-form/components/provider';
|
|
9
|
+
import { JsonRenderer } from '@twintag/twintag-form/components/renderer';
|
|
10
|
+
|
|
11
|
+
type Props = {
|
|
12
|
+
config: RawJsonComponent[];
|
|
13
|
+
options?: Partial<{
|
|
14
|
+
defaultValues: ComponentProps<typeof TwintagForm>['defaultValues'];
|
|
15
|
+
variant: ComponentProps<typeof TwintagFormProvider>['variant'];
|
|
16
|
+
size: ComponentProps<typeof TwintagFormProvider>['size'];
|
|
17
|
+
resetOnSubmit?: boolean;
|
|
18
|
+
acceptFileType?: ComponentProps<
|
|
19
|
+
typeof TwintagFormProvider
|
|
20
|
+
>['acceptFileType'];
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const Form = forwardRef<HTMLFormElement, Props>(
|
|
25
|
+
({ config, options }, ref) => {
|
|
26
|
+
return (
|
|
27
|
+
<TwintagFormProvider
|
|
28
|
+
inputs={Inputs}
|
|
29
|
+
components={components}
|
|
30
|
+
variant={options?.variant}
|
|
31
|
+
size={options?.size}
|
|
32
|
+
config={config}
|
|
33
|
+
acceptFileType={options?.acceptFileType}
|
|
34
|
+
>
|
|
35
|
+
<TwintagForm
|
|
36
|
+
ref={ref}
|
|
37
|
+
defaultValues={options?.defaultValues}
|
|
38
|
+
resetOnSubmit={options?.resetOnSubmit}
|
|
39
|
+
>
|
|
40
|
+
<JsonRenderer />
|
|
41
|
+
</TwintagForm>
|
|
42
|
+
</TwintagFormProvider>
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
);
|
package/lib/types/index.ts
CHANGED
|
@@ -1,82 +1,102 @@
|
|
|
1
|
-
import type { ElementType } from 'react';
|
|
2
|
-
|
|
3
|
-
export type InputCompConfig = {
|
|
4
|
-
defaultValue?: unknown;
|
|
5
|
-
component: ElementType;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
type
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
?
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
export type
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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 || {}),
|