shadcn-zod-formkit 1.22.3 → 1.22.4
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/index.cjs +42 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +42 -36
- package/dist/index.mjs.map +1 -1
- package/dist/shadcn-zod-formkit-1.22.4.tgz +0 -0
- package/package.json +1 -1
- package/dist/shadcn-zod-formkit-1.22.3.tgz +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -79,8 +79,8 @@ declare enum InputTypes {
|
|
|
79
79
|
declare const inputFieldComp: InputTypes[];
|
|
80
80
|
|
|
81
81
|
declare const flattenFields: <T extends Record<string, any>>(fields: FieldConfig<T>[]) => FieldProps<T>[];
|
|
82
|
-
type FieldConfig<T
|
|
83
|
-
interface FieldProps<T = Record<string, any>> {
|
|
82
|
+
type FieldConfig<T, RT = Record<string, any>> = FieldProps<T, RT> | FieldConfig<T, RT>[];
|
|
83
|
+
interface FieldProps<T = Record<string, any>, RT = Record<string, any>> {
|
|
84
84
|
name: keyof T;
|
|
85
85
|
label: string;
|
|
86
86
|
onChange?: (...event: any[]) => void;
|
|
@@ -89,7 +89,7 @@ interface FieldProps<T = Record<string, any>> {
|
|
|
89
89
|
children?: ReactNode | ((item: any, index: number) => ReactNode);
|
|
90
90
|
defaultValue?: any;
|
|
91
91
|
direction?: 'row' | 'col';
|
|
92
|
-
repeaterFields?:
|
|
92
|
+
repeaterFields?: FieldConfig<RT>;
|
|
93
93
|
minItems?: number;
|
|
94
94
|
maxItems?: number;
|
|
95
95
|
currencyFormat?: Intl.NumberFormatOptions;
|
package/dist/index.d.ts
CHANGED
|
@@ -79,8 +79,8 @@ declare enum InputTypes {
|
|
|
79
79
|
declare const inputFieldComp: InputTypes[];
|
|
80
80
|
|
|
81
81
|
declare const flattenFields: <T extends Record<string, any>>(fields: FieldConfig<T>[]) => FieldProps<T>[];
|
|
82
|
-
type FieldConfig<T
|
|
83
|
-
interface FieldProps<T = Record<string, any>> {
|
|
82
|
+
type FieldConfig<T, RT = Record<string, any>> = FieldProps<T, RT> | FieldConfig<T, RT>[];
|
|
83
|
+
interface FieldProps<T = Record<string, any>, RT = Record<string, any>> {
|
|
84
84
|
name: keyof T;
|
|
85
85
|
label: string;
|
|
86
86
|
onChange?: (...event: any[]) => void;
|
|
@@ -89,7 +89,7 @@ interface FieldProps<T = Record<string, any>> {
|
|
|
89
89
|
children?: ReactNode | ((item: any, index: number) => ReactNode);
|
|
90
90
|
defaultValue?: any;
|
|
91
91
|
direction?: 'row' | 'col';
|
|
92
|
-
repeaterFields?:
|
|
92
|
+
repeaterFields?: FieldConfig<RT>;
|
|
93
93
|
minItems?: number;
|
|
94
94
|
maxItems?: number;
|
|
95
95
|
currencyFormat?: Intl.NumberFormatOptions;
|
package/dist/index.mjs
CHANGED
|
@@ -5551,49 +5551,55 @@ var getFieldLabel = (fieldErrorKey, fields) => {
|
|
|
5551
5551
|
return foundField?.label ?? fieldErrorKey;
|
|
5552
5552
|
};
|
|
5553
5553
|
var isRenderableChild = (c) => c !== void 0 && c !== null && typeof c !== "function";
|
|
5554
|
-
var isFieldProps = (f) => !Array.isArray(f);
|
|
5555
5554
|
var FormFieldsGrid = ({
|
|
5556
5555
|
fields,
|
|
5557
5556
|
form,
|
|
5558
5557
|
isPending,
|
|
5559
5558
|
readOnly,
|
|
5560
5559
|
className = "",
|
|
5561
|
-
gap = "gap-
|
|
5560
|
+
gap = "gap-2"
|
|
5562
5561
|
}) => {
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5562
|
+
return /* @__PURE__ */ jsx("div", { className: `w-full grid grid-cols-1 ${gap} ${className}`, children: fields.map(
|
|
5563
|
+
(inputOrGroup, idx) => Array.isArray(inputOrGroup) ? /* @__PURE__ */ jsx(
|
|
5564
|
+
"div",
|
|
5565
|
+
{
|
|
5566
|
+
className: "w-full flex flex-row items-start gap-4 py-3",
|
|
5567
|
+
children: inputOrGroup.map((field, subIdx) => {
|
|
5568
|
+
const fieldCopy = {
|
|
5569
|
+
...field,
|
|
5570
|
+
disabled: readOnly ? true : field.disabled
|
|
5571
|
+
};
|
|
5572
|
+
const renderInlineChild = fieldCopy.childrenPosition !== "down" && isRenderableChild(fieldCopy.children);
|
|
5573
|
+
const renderInlineChildDown = fieldCopy.childrenPosition === "down" && isRenderableChild(fieldCopy.children);
|
|
5574
|
+
return /* @__PURE__ */ jsxs("div", { className: "w-full px-2", children: [
|
|
5575
|
+
renderInlineChild && /* @__PURE__ */ jsx(Fragment, { children: fieldCopy.children }),
|
|
5576
|
+
InputFactory.create(fieldCopy, form, isPending),
|
|
5577
|
+
renderInlineChildDown && /* @__PURE__ */ jsx(Fragment, { children: fieldCopy.children })
|
|
5578
|
+
] }, `field-${idx}-${subIdx}`);
|
|
5579
|
+
})
|
|
5580
|
+
},
|
|
5581
|
+
`field-group-${idx}`
|
|
5582
|
+
) : /* @__PURE__ */ jsx(
|
|
5583
|
+
"div",
|
|
5584
|
+
{
|
|
5585
|
+
className: "flex flex-col justify-between py-3 w-full px-2",
|
|
5586
|
+
children: (() => {
|
|
5587
|
+
const fieldCopy = {
|
|
5588
|
+
...inputOrGroup,
|
|
5589
|
+
disabled: readOnly ? true : inputOrGroup.disabled
|
|
5590
|
+
};
|
|
5591
|
+
const renderUp = fieldCopy.childrenPosition !== "down" && isRenderableChild(fieldCopy.children);
|
|
5592
|
+
const renderDown = fieldCopy.childrenPosition === "down" && isRenderableChild(fieldCopy.children);
|
|
5593
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5594
|
+
renderUp && /* @__PURE__ */ jsx(Fragment, { children: fieldCopy.children }),
|
|
5595
|
+
InputFactory.create(fieldCopy, form, isPending),
|
|
5596
|
+
renderDown && /* @__PURE__ */ jsx(Fragment, { children: fieldCopy.children })
|
|
5597
|
+
] });
|
|
5598
|
+
})()
|
|
5599
|
+
},
|
|
5600
|
+
`field-single-${idx}`
|
|
5601
|
+
)
|
|
5602
|
+
) });
|
|
5597
5603
|
};
|
|
5598
5604
|
var DynamicForm = ({
|
|
5599
5605
|
formTitle,
|