@zod-to-form/react 0.2.1 → 0.2.2
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/dist/FieldRenderer.d.ts +10 -0
- package/dist/FieldRenderer.d.ts.map +1 -0
- package/dist/FieldRenderer.js +144 -0
- package/dist/FieldRenderer.js.map +1 -0
- package/dist/ZodForm.d.ts +17 -0
- package/dist/ZodForm.d.ts.map +1 -0
- package/dist/ZodForm.js +16 -0
- package/dist/ZodForm.js.map +1 -0
- package/dist/components/Checkbox.d.ts +3 -0
- package/dist/components/Checkbox.d.ts.map +1 -0
- package/dist/components/Checkbox.js +5 -0
- package/dist/components/Checkbox.js.map +1 -0
- package/dist/components/Combobox.d.ts +12 -0
- package/dist/components/Combobox.d.ts.map +1 -0
- package/dist/components/Combobox.js +12 -0
- package/dist/components/Combobox.js.map +1 -0
- package/dist/components/DatePicker.d.ts +3 -0
- package/dist/components/DatePicker.d.ts.map +1 -0
- package/dist/components/DatePicker.js +5 -0
- package/dist/components/DatePicker.js.map +1 -0
- package/dist/components/FileInput.d.ts +3 -0
- package/dist/components/FileInput.d.ts.map +1 -0
- package/dist/components/FileInput.js +5 -0
- package/dist/components/FileInput.js.map +1 -0
- package/dist/components/Input.d.ts +3 -0
- package/dist/components/Input.d.ts.map +1 -0
- package/dist/components/Input.js +5 -0
- package/dist/components/Input.js.map +1 -0
- package/dist/components/RadioGroup.d.ts +9 -0
- package/dist/components/RadioGroup.d.ts.map +1 -0
- package/dist/components/RadioGroup.js +6 -0
- package/dist/components/RadioGroup.js.map +1 -0
- package/dist/components/Select.d.ts +8 -0
- package/dist/components/Select.d.ts.map +1 -0
- package/dist/components/Select.js +5 -0
- package/dist/components/Select.js.map +1 -0
- package/dist/components/Switch.d.ts +3 -0
- package/dist/components/Switch.d.ts.map +1 -0
- package/dist/components/Switch.js +5 -0
- package/dist/components/Switch.js.map +1 -0
- package/dist/components/Textarea.d.ts +3 -0
- package/dist/components/Textarea.d.ts.map +1 -0
- package/dist/components/Textarea.js +5 -0
- package/dist/components/Textarea.js.map +1 -0
- package/dist/components/index.d.ts +31 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +38 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/shadcn/index.d.ts +1762 -0
- package/dist/shadcn/index.d.ts.map +1 -0
- package/dist/shadcn/index.js +122 -0
- package/dist/shadcn/index.js.map +1 -0
- package/dist/useZodForm.d.ts +13 -0
- package/dist/useZodForm.d.ts.map +1 -0
- package/dist/useZodForm.js +49 -0
- package/dist/useZodForm.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FormField } from '@zod-to-form/core';
|
|
2
|
+
import { defaultComponentMap } from './components/index.js';
|
|
3
|
+
type ComponentMap = typeof defaultComponentMap;
|
|
4
|
+
type FieldRendererProps = {
|
|
5
|
+
field: FormField;
|
|
6
|
+
components?: Partial<ComponentMap>;
|
|
7
|
+
};
|
|
8
|
+
export declare function FieldRenderer({ field, components }: FieldRendererProps): import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=FieldRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldRenderer.d.ts","sourceRoot":"","sources":["../src/FieldRenderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,KAAK,YAAY,GAAG,OAAO,mBAAmB,CAAC;AA4C/C,KAAK,kBAAkB,GAAG;IACxB,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;CACpC,CAAC;AA2GF,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,kBAAkB,kDAmEtE"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useFieldArray, useFormContext } from 'react-hook-form';
|
|
3
|
+
import { defaultComponentMap } from './components/index.js';
|
|
4
|
+
function getErrorAtPath(errors, path) {
|
|
5
|
+
const segments = path.split('.');
|
|
6
|
+
let current = errors;
|
|
7
|
+
for (const segment of segments) {
|
|
8
|
+
if (!current || typeof current !== 'object') {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
current = current[segment];
|
|
12
|
+
}
|
|
13
|
+
const message = current?.['message'];
|
|
14
|
+
if (typeof message === 'string') {
|
|
15
|
+
return message;
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
function getRegisterOptions(field) {
|
|
20
|
+
if (field.zodType === 'number' || field.zodType === 'bigint') {
|
|
21
|
+
return { valueAsNumber: true };
|
|
22
|
+
}
|
|
23
|
+
if (field.zodType === 'date') {
|
|
24
|
+
return { valueAsDate: true };
|
|
25
|
+
}
|
|
26
|
+
if (field.zodType === 'file') {
|
|
27
|
+
return {
|
|
28
|
+
setValueAs: (value) => {
|
|
29
|
+
if (value instanceof FileList) {
|
|
30
|
+
return value.length > 0 ? value.item(0) : undefined;
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
// ─── T088: Fieldset block for nested object fields ────────────────────
|
|
39
|
+
function FieldsetBlock({ field, components }) {
|
|
40
|
+
const componentMap = { ...defaultComponentMap, ...components };
|
|
41
|
+
const FormFieldComponent = componentMap.FormField;
|
|
42
|
+
const wrapperProps = {};
|
|
43
|
+
if (field.gridColumn) {
|
|
44
|
+
wrapperProps['style'] = { gridColumn: field.gridColumn };
|
|
45
|
+
}
|
|
46
|
+
return (_jsx(FormFieldComponent, { ...wrapperProps, children: _jsxs("fieldset", { children: [
|
|
47
|
+
_jsx("legend", { children: field.label }), field.children?.map((child) => (_jsx(FieldRenderer, { field: child, components: componentMap }, child.key)))] }) }));
|
|
48
|
+
}
|
|
49
|
+
// ─── T089: Array block with useFieldArray ─────────────────────────────
|
|
50
|
+
function getDefaultAppendValue(arrayItem) {
|
|
51
|
+
if (!arrayItem)
|
|
52
|
+
return '';
|
|
53
|
+
if (arrayItem.component === 'Fieldset')
|
|
54
|
+
return {};
|
|
55
|
+
if (arrayItem.zodType === 'number' || arrayItem.zodType === 'bigint')
|
|
56
|
+
return 0;
|
|
57
|
+
return '';
|
|
58
|
+
}
|
|
59
|
+
function ArrayBlock({ field, components }) {
|
|
60
|
+
const componentMap = { ...defaultComponentMap, ...components };
|
|
61
|
+
const { control } = useFormContext();
|
|
62
|
+
const { fields: items, append, remove } = useFieldArray({ control, name: field.key });
|
|
63
|
+
const minLength = field.constraints.minLength ?? 0;
|
|
64
|
+
const wrapperProps = {};
|
|
65
|
+
if (field.gridColumn) {
|
|
66
|
+
wrapperProps['style'] = { gridColumn: field.gridColumn };
|
|
67
|
+
}
|
|
68
|
+
return (_jsxs("fieldset", { ...wrapperProps, children: [
|
|
69
|
+
_jsx("legend", { children: field.label }), items.map((item, index) => {
|
|
70
|
+
if (!field.arrayItem)
|
|
71
|
+
return null;
|
|
72
|
+
const itemField = { ...field.arrayItem, key: `${field.key}.${index}` };
|
|
73
|
+
return (_jsxs("div", { children: [
|
|
74
|
+
_jsx(FieldRenderer, { field: itemField, components: componentMap }), _jsx("button", { type: "button", onClick: () => remove(index), disabled: items.length <= minLength, children: "Remove" })
|
|
75
|
+
] }, item.id));
|
|
76
|
+
}), _jsx("button", { type: "button", onClick: () => append(getDefaultAppendValue(field.arrayItem)), children: "Add" })
|
|
77
|
+
] }));
|
|
78
|
+
}
|
|
79
|
+
// ─── T090: Discriminated union block with watch ───────────────────────
|
|
80
|
+
function DiscriminatedUnionBlock({ field, components }) {
|
|
81
|
+
const componentMap = { ...defaultComponentMap, ...components };
|
|
82
|
+
const { register, watch } = useFormContext();
|
|
83
|
+
const discriminator = field.props['_discriminator'];
|
|
84
|
+
const discKey = `${field.key}.${discriminator}`;
|
|
85
|
+
const currentValue = watch(discKey);
|
|
86
|
+
const variants = field.props['_variants'];
|
|
87
|
+
const variantFields = currentValue ? (variants?.[currentValue] ?? []) : [];
|
|
88
|
+
const FormFieldComponent = componentMap.FormField;
|
|
89
|
+
const FormLabelComponent = componentMap.FormLabel;
|
|
90
|
+
const wrapperProps = {};
|
|
91
|
+
if (field.gridColumn) {
|
|
92
|
+
wrapperProps['style'] = { gridColumn: field.gridColumn };
|
|
93
|
+
}
|
|
94
|
+
return (_jsxs(FormFieldComponent, { ...wrapperProps, children: [
|
|
95
|
+
_jsx(FormLabelComponent, { htmlFor: discKey, children: field.label }), _jsxs("select", { id: discKey, ...register(discKey), children: [
|
|
96
|
+
_jsx("option", { value: "", children: "Select\u2026" }), field.options?.map((opt) => (_jsx("option", { value: String(opt.value), children: opt.label }, String(opt.value))))] }), variantFields.map((child) => (_jsx(FieldRenderer, { field: child, components: componentMap }, child.key)))] }));
|
|
97
|
+
}
|
|
98
|
+
export function FieldRenderer({ field, components }) {
|
|
99
|
+
// Always call hooks first (React hooks rule — no conditional hook calls)
|
|
100
|
+
const { register, formState } = useFormContext();
|
|
101
|
+
const componentMap = { ...defaultComponentMap, ...components };
|
|
102
|
+
// T088: dispatch nested object fields to FieldsetBlock
|
|
103
|
+
if (field.component === 'Fieldset') {
|
|
104
|
+
return _jsx(FieldsetBlock, { field: field, components: componentMap });
|
|
105
|
+
}
|
|
106
|
+
// T089: dispatch array fields to ArrayBlock
|
|
107
|
+
if (field.component === 'ArrayField') {
|
|
108
|
+
return _jsx(ArrayBlock, { field: field, components: componentMap });
|
|
109
|
+
}
|
|
110
|
+
// T090: dispatch discriminated union to DiscriminatedUnionBlock
|
|
111
|
+
if (field.component === 'Select' && field.props['_discriminator']) {
|
|
112
|
+
return _jsx(DiscriminatedUnionBlock, { field: field, components: componentMap });
|
|
113
|
+
}
|
|
114
|
+
const Component = (componentMap[field.component] ??
|
|
115
|
+
componentMap.Input);
|
|
116
|
+
const FormFieldComponent = componentMap.FormField;
|
|
117
|
+
const FormLabelComponent = componentMap.FormLabel;
|
|
118
|
+
const FormDescriptionComponent = componentMap.FormDescription;
|
|
119
|
+
const FormMessageComponent = componentMap.FormMessage;
|
|
120
|
+
const errorMessage = getErrorAtPath(formState.errors, field.key);
|
|
121
|
+
if (field.hidden) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const registration = register(field.key, getRegisterOptions(field));
|
|
125
|
+
const componentProps = {
|
|
126
|
+
id: field.key,
|
|
127
|
+
'aria-invalid': errorMessage ? 'true' : 'false',
|
|
128
|
+
required: field.required,
|
|
129
|
+
readOnly: field.readOnly,
|
|
130
|
+
...field.props,
|
|
131
|
+
...registration
|
|
132
|
+
};
|
|
133
|
+
if ('options' in field && field['options']) {
|
|
134
|
+
componentProps['options'] = field['options'];
|
|
135
|
+
}
|
|
136
|
+
const wrapperProps = {};
|
|
137
|
+
if (field.gridColumn) {
|
|
138
|
+
wrapperProps['style'] = { gridColumn: field.gridColumn };
|
|
139
|
+
}
|
|
140
|
+
const fieldContent = field.render ? field.render(field, componentProps) : (_jsx(Component, { ...componentProps }));
|
|
141
|
+
return (_jsxs(FormFieldComponent, { ...wrapperProps, children: [
|
|
142
|
+
_jsx(FormLabelComponent, { htmlFor: field.key, children: field.label }), fieldContent, field.description ? (_jsx(FormDescriptionComponent, { children: field.description })) : null, errorMessage ? _jsx(FormMessageComponent, { children: errorMessage }) : null] }));
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=FieldRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldRenderer.js","sourceRoot":"","sources":["../src/FieldRenderer.tsx"],"names":[],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AK,cAAc,GAAI,CAClC,CAAC;IAEF,OAAO,CACL,MAAC,kBAAkB,OAAK,YAAY;YAClC,KAAC,kBAAkB,IAAC,OAAO,EAAE,KAAK,CAAC,GAAG,YAAG,KAAK,CAAC,KAAK,GAAsB,EACzE,YAAY,EACZ,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CACnB,KAAC,wBAAwB,cAAE,KAAK,CAAC,WAAW,GAA4B,CACzE,CAAC,CAAC,CAAC,IAAI,EACP,YAAY,CAAC,CAAC,CAAC,KAAC,oBAAoB,cAAE,YAAY,GAAwB,CAAC,CAAC,CAAC,IAAI,IAC/D,CACtB,CAAC;AAAA,CACH"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ZodObject } from 'zod';
|
|
3
|
+
import type { FormProcessor, ZodFormRegistry } from '@zod-to-form/core';
|
|
4
|
+
import { defaultComponentMap } from './components/index.js';
|
|
5
|
+
type ZodFormProps<TSchema extends ZodObject> = {
|
|
6
|
+
schema: TSchema;
|
|
7
|
+
onSubmit: (data: TSchema['_zod']['output']) => unknown;
|
|
8
|
+
defaultValues?: Partial<TSchema['_zod']['output']>;
|
|
9
|
+
components?: Partial<typeof defaultComponentMap>;
|
|
10
|
+
formRegistry?: ZodFormRegistry;
|
|
11
|
+
processors?: Record<string, FormProcessor>;
|
|
12
|
+
className?: string;
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
};
|
|
15
|
+
export declare function ZodForm<TSchema extends ZodObject>(props: ZodFormProps<TSchema>): ReactNode;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=ZodForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZodForm.d.ts","sourceRoot":"","sources":["../src/ZodForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAExE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,KAAK,YAAY,CAAC,OAAO,SAAS,SAAS,IAAI;IAC7C,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC;IACvD,aAAa,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC,OAAO,mBAAmB,CAAC,CAAC;IACjD,YAAY,CAAC,EAAE,eAAe,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,wBAAgB,OAAO,CAAC,OAAO,SAAS,SAAS,EAAE,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,SAAS,CA6B1F"}
|
package/dist/ZodForm.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FormProvider } from 'react-hook-form';
|
|
3
|
+
import { FieldRenderer } from './FieldRenderer.js';
|
|
4
|
+
import { defaultComponentMap } from './components/index.js';
|
|
5
|
+
import { useZodForm } from './useZodForm.js';
|
|
6
|
+
export function ZodForm(props) {
|
|
7
|
+
const { schema, onSubmit, defaultValues, components, formRegistry, processors, className, children } = props;
|
|
8
|
+
const mergedComponents = { ...defaultComponentMap, ...components };
|
|
9
|
+
const { form, fields } = useZodForm(schema, {
|
|
10
|
+
defaultValues,
|
|
11
|
+
formRegistry,
|
|
12
|
+
processors
|
|
13
|
+
});
|
|
14
|
+
return (_jsx(FormProvider, { ...form, children: _jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: className, noValidate: true, children: [fields.map((field) => (_jsx(FieldRenderer, { field: field, components: mergedComponents }, field.key))), children] }) }));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=ZodForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZodForm.js","sourceRoot":"","sources":["../src/ZodForm.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAa7C,MAAM,UAAU,OAAO,CAA4B,KAA4B,EAAa;IAC1F,MAAM,EACJ,MAAM,EACN,QAAQ,EACR,aAAa,EACb,UAAU,EACV,YAAY,EACZ,UAAU,EACV,SAAS,EACT,QAAQ,EACT,GAAG,KAAK,CAAC;IACV,MAAM,gBAAgB,GAAG,EAAE,GAAG,mBAAmB,EAAE,GAAG,UAAU,EAAE,CAAC;IAEnE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,EAAE;QAC1C,aAAa;QACb,YAAY;QACZ,UAAU;KACX,CAAC,CAAC;IAEH,OAAO,CACL,KAAC,YAAY,OAAK,IAAI,YACpB,gBAAM,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,mBAC1E,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACrB,KAAC,aAAa,IAAiB,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,gBAAgB,IAArD,KAAK,CAAC,GAAG,CAAgD,CAC9E,CAAC,EACD,QAAQ,IACJ,GACM,CAChB,CAAC;AAAA,CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../src/components/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAEjD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,2CAEpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../src/components/Checkbox.tsx"],"names":[],"mappings":";AAEA,MAAM,UAAU,QAAQ,CAAC,KAA4C,EAAE;IACrE,OAAO,gBAAO,IAAI,EAAC,UAAU,KAAK,KAAK,GAAI,CAAC;AAAA,CAC7C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InputHTMLAttributes } from 'react';
|
|
2
|
+
import type { FormFieldOption } from '@zod-to-form/core';
|
|
3
|
+
type ComboboxProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'list'> & {
|
|
4
|
+
options?: FormFieldOption[];
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Unstyled native combobox using `<datalist>` + `<input list>`.
|
|
8
|
+
* Provides browser-native autocomplete from the options list.
|
|
9
|
+
*/
|
|
10
|
+
export declare function ComboboxFallback({ options, id, ...props }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=Combobox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Combobox.d.ts","sourceRoot":"","sources":["../../src/components/Combobox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,KAAK,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,GAAG;IACzE,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;CAC7B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,aAAa,2CAexE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Unstyled native combobox using `<datalist>` + `<input list>`.
|
|
4
|
+
* Provides browser-native autocomplete from the options list.
|
|
5
|
+
*/
|
|
6
|
+
export function ComboboxFallback({ options, id, ...props }) {
|
|
7
|
+
const listId = id ? `${id}-list` : undefined;
|
|
8
|
+
return (_jsxs(_Fragment, { children: [
|
|
9
|
+
_jsx("input", { ...props, id: id, list: listId, type: "text" }), _jsx("datalist", { id: listId, children: options?.map((option) => (_jsx("option", { value: `${option.value}`, children: option.label }, `${option.value}`))) })
|
|
10
|
+
] }));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=Combobox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Combobox.js","sourceRoot":"","sources":["../../src/components/Combobox.tsx"],"names":[],"mappings":";AAOA;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,KAAK,EAAiB,EAAE;IACzE,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IAE7C,OAAO,CACL;YACE,mBAAW,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,GAAG,EACtD,mBAAU,EAAE,EAAE,MAAM,YACjB,OAAO,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACxB,iBAAgC,KAAK,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,YACrD,MAAM,CAAC,KAAK,IADF,GAAG,MAAM,CAAC,KAAK,EAAE,CAErB,CACV,CAAC,GACO;YACV,CACJ,CAAC;AAAA,CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../src/components/DatePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAEjD,wBAAgB,UAAU,CAAC,KAAK,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,2CAEtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../src/components/DatePicker.tsx"],"names":[],"mappings":";AAEA,MAAM,UAAU,UAAU,CAAC,KAA4C,EAAE;IACvE,OAAO,gBAAO,IAAI,EAAC,MAAM,KAAK,KAAK,GAAI,CAAC;AAAA,CACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileInput.d.ts","sourceRoot":"","sources":["../../src/components/FileInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAEjD,wBAAgB,SAAS,CAAC,KAAK,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,2CAErE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileInput.js","sourceRoot":"","sources":["../../src/components/FileInput.tsx"],"names":[],"mappings":";AAEA,MAAM,UAAU,SAAS,CAAC,KAA4C,EAAE;IACtE,OAAO,gBAAO,IAAI,EAAC,MAAM,KAAK,KAAK,GAAI,CAAC;AAAA,CACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../src/components/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAEjD,wBAAgB,KAAK,CAAC,KAAK,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,2CAEjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../src/components/Input.tsx"],"names":[],"mappings":";AAEA,MAAM,UAAU,KAAK,CAAC,KAA4C,EAAE;IAClE,OAAO,mBAAW,KAAK,GAAI,CAAC;AAAA,CAC7B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { InputHTMLAttributes } from 'react';
|
|
2
|
+
import type { FormFieldOption } from '@zod-to-form/core';
|
|
3
|
+
type RadioGroupProps = InputHTMLAttributes<HTMLInputElement> & {
|
|
4
|
+
name: string;
|
|
5
|
+
options?: FormFieldOption[];
|
|
6
|
+
};
|
|
7
|
+
export declare function RadioGroup({ options, name, ...props }: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=RadioGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../../src/components/RadioGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,KAAK,eAAe,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,GAAG;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;CAC7B,CAAC;AAEF,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,2CAiBtE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function RadioGroup({ options, name, ...props }) {
|
|
3
|
+
return (_jsx("fieldset", { children: options?.map((option) => (_jsxs("label", { children: [
|
|
4
|
+
_jsx("input", { ...props, type: "radio", name: name, value: option.value, disabled: option.disabled }), option.label] }, `${option.value}`))) }));
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=RadioGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioGroup.js","sourceRoot":"","sources":["../../src/components/RadioGroup.tsx"],"names":[],"mappings":";AAQA,MAAM,UAAU,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,EAAmB,EAAE;IACvE,OAAO,CACL,6BACG,OAAO,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACxB;gBACE,mBACM,KAAK,EACT,IAAI,EAAC,OAAO,EACZ,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ,GACzB,EACD,MAAM,CAAC,KAAK,KARH,GAAG,MAAM,CAAC,KAAK,EAAE,CASrB,CACT,CAAC,GACO,CACZ,CAAC;AAAA,CACH"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SelectHTMLAttributes } from 'react';
|
|
2
|
+
import type { FormFieldOption } from '@zod-to-form/core';
|
|
3
|
+
type SelectProps = SelectHTMLAttributes<HTMLSelectElement> & {
|
|
4
|
+
options?: FormFieldOption[];
|
|
5
|
+
};
|
|
6
|
+
export declare function Select({ options, ...props }: SelectProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=Select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../src/components/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,KAAK,WAAW,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,GAAG;IAC3D,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;CAC7B,CAAC;AAEF,wBAAgB,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,WAAW,2CAUxD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export function Select({ options, ...props }) {
|
|
3
|
+
return (_jsx("select", { ...props, children: options?.map((option) => (_jsx("option", { value: option.value, disabled: option.disabled, children: option.label }, `${option.value}`))) }));
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=Select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.js","sourceRoot":"","sources":["../../src/components/Select.tsx"],"names":[],"mappings":";AAOA,MAAM,UAAU,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAe,EAAE;IACzD,OAAO,CACL,oBAAY,KAAK,YACd,OAAO,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACxB,iBAAgC,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,YAC3E,MAAM,CAAC,KAAK,IADF,GAAG,MAAM,CAAC,KAAK,EAAE,CAErB,CACV,CAAC,GACK,CACV,CAAC;AAAA,CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../../src/components/Switch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAEjD,wBAAgB,MAAM,CAAC,KAAK,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,2CAElE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../src/components/Switch.tsx"],"names":[],"mappings":";AAEA,MAAM,UAAU,MAAM,CAAC,KAA4C,EAAE;IACnE,OAAO,gBAAO,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,QAAQ,KAAK,KAAK,GAAI,CAAC;AAAA,CAC3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../../src/components/Textarea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAC;AAEpD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,sBAAsB,CAAC,mBAAmB,CAAC,2CAE1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Textarea.js","sourceRoot":"","sources":["../../src/components/Textarea.tsx"],"names":[],"mappings":";AAEA,MAAM,UAAU,QAAQ,CAAC,KAAkD,EAAE;IAC3E,OAAO,sBAAc,KAAK,GAAI,CAAC;AAAA,CAChC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { HTMLAttributes, LabelHTMLAttributes } from 'react';
|
|
2
|
+
import { Checkbox } from './Checkbox.js';
|
|
3
|
+
import { ComboboxFallback } from './Combobox.js';
|
|
4
|
+
import { DatePicker } from './DatePicker.js';
|
|
5
|
+
import { FileInput } from './FileInput.js';
|
|
6
|
+
import { Input } from './Input.js';
|
|
7
|
+
import { RadioGroup } from './RadioGroup.js';
|
|
8
|
+
import { Select } from './Select.js';
|
|
9
|
+
import { Switch } from './Switch.js';
|
|
10
|
+
import { Textarea } from './Textarea.js';
|
|
11
|
+
declare function FormField(props: HTMLAttributes<HTMLDivElement>): import("react").DetailedReactHTMLElement<HTMLAttributes<HTMLDivElement>, HTMLElement>;
|
|
12
|
+
declare function FormLabel(props: LabelHTMLAttributes<HTMLLabelElement>): import("react").DetailedReactHTMLElement<LabelHTMLAttributes<HTMLLabelElement>, HTMLElement>;
|
|
13
|
+
declare function FormDescription(props: HTMLAttributes<HTMLParagraphElement>): import("react").DetailedReactHTMLElement<HTMLAttributes<HTMLParagraphElement>, HTMLElement>;
|
|
14
|
+
declare function FormMessage(props: HTMLAttributes<HTMLParagraphElement>): import("react").DetailedReactHTMLElement<HTMLAttributes<HTMLParagraphElement>, HTMLElement>;
|
|
15
|
+
export declare const defaultComponentMap: {
|
|
16
|
+
Input: typeof Input;
|
|
17
|
+
Textarea: typeof Textarea;
|
|
18
|
+
Checkbox: typeof Checkbox;
|
|
19
|
+
Combobox: typeof ComboboxFallback;
|
|
20
|
+
Switch: typeof Switch;
|
|
21
|
+
Select: typeof Select;
|
|
22
|
+
DatePicker: typeof DatePicker;
|
|
23
|
+
FileInput: typeof FileInput;
|
|
24
|
+
RadioGroup: typeof RadioGroup;
|
|
25
|
+
FormField: typeof FormField;
|
|
26
|
+
FormLabel: typeof FormLabel;
|
|
27
|
+
FormDescription: typeof FormDescription;
|
|
28
|
+
FormMessage: typeof FormMessage;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,iBAAS,SAAS,CAAC,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,yFAEvD;AAED,iBAAS,SAAS,CAAC,KAAK,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,gGAE9D;AAED,iBAAS,eAAe,CAAC,KAAK,EAAE,cAAc,CAAC,oBAAoB,CAAC,+FAEnE;AAED,iBAAS,WAAW,CAAC,KAAK,EAAE,cAAc,CAAC,oBAAoB,CAAC,+FAE/D;AAED,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;CAc/B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createElement } from 'react';
|
|
2
|
+
import { Checkbox } from './Checkbox.js';
|
|
3
|
+
import { ComboboxFallback } from './Combobox.js';
|
|
4
|
+
import { DatePicker } from './DatePicker.js';
|
|
5
|
+
import { FileInput } from './FileInput.js';
|
|
6
|
+
import { Input } from './Input.js';
|
|
7
|
+
import { RadioGroup } from './RadioGroup.js';
|
|
8
|
+
import { Select } from './Select.js';
|
|
9
|
+
import { Switch } from './Switch.js';
|
|
10
|
+
import { Textarea } from './Textarea.js';
|
|
11
|
+
function FormField(props) {
|
|
12
|
+
return createElement('div', props);
|
|
13
|
+
}
|
|
14
|
+
function FormLabel(props) {
|
|
15
|
+
return createElement('label', props);
|
|
16
|
+
}
|
|
17
|
+
function FormDescription(props) {
|
|
18
|
+
return createElement('p', props);
|
|
19
|
+
}
|
|
20
|
+
function FormMessage(props) {
|
|
21
|
+
return createElement('p', props);
|
|
22
|
+
}
|
|
23
|
+
export const defaultComponentMap = {
|
|
24
|
+
Input,
|
|
25
|
+
Textarea,
|
|
26
|
+
Checkbox,
|
|
27
|
+
Combobox: ComboboxFallback,
|
|
28
|
+
Switch,
|
|
29
|
+
Select,
|
|
30
|
+
DatePicker,
|
|
31
|
+
FileInput,
|
|
32
|
+
RadioGroup,
|
|
33
|
+
FormField,
|
|
34
|
+
FormLabel,
|
|
35
|
+
FormDescription,
|
|
36
|
+
FormMessage
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,SAAS,SAAS,CAAC,KAAqC,EAAE;IACxD,OAAO,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAAA,CACpC;AAED,SAAS,SAAS,CAAC,KAA4C,EAAE;IAC/D,OAAO,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAAA,CACtC;AAED,SAAS,eAAe,CAAC,KAA2C,EAAE;IACpE,OAAO,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAAA,CAClC;AAED,SAAS,WAAW,CAAC,KAA2C,EAAE;IAChE,OAAO,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAAA,CAClC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,QAAQ,EAAE,gBAAgB;IAC1B,MAAM;IACN,MAAM;IACN,UAAU;IACV,SAAS;IACT,UAAU;IACV,SAAS;IACT,SAAS;IACT,eAAe;IACf,WAAW;CACZ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { FormField, FormFieldOption, FormFieldConstraints, FormMeta, WalkOptions } from '@zod-to-form/core';
|
|
2
|
+
export { ZodForm } from './ZodForm.js';
|
|
3
|
+
export { useZodForm } from './useZodForm.js';
|
|
4
|
+
export { defaultComponentMap } from './components/index.js';
|
|
5
|
+
export { shadcnComponentMap } from './shadcn/index.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,SAAS,EACT,eAAe,EACf,oBAAoB,EACpB,QAAQ,EACR,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @zod-to-form/react — Public API
|
|
2
|
+
// Runtime renderer — stubs until Phase 3 implementation
|
|
3
|
+
export { ZodForm } from './ZodForm.js';
|
|
4
|
+
export { useZodForm } from './useZodForm.js';
|
|
5
|
+
export { defaultComponentMap } from './components/index.js';
|
|
6
|
+
export { shadcnComponentMap } from './shadcn/index.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAWlC,wDAAwD;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
|