shadcn-zod-formkit 1.27.4 → 1.29.0
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/README.md +2 -0
- package/dist/index.cjs +149 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +14 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.mjs +150 -81
- package/dist/index.mjs.map +1 -1
- package/dist/shadcn-zod-formkit-1.29.0.tgz +0 -0
- package/package.json +1 -1
- package/dist/shadcn-zod-formkit-1.27.4.tgz +0 -0
package/README.md
CHANGED
|
@@ -121,6 +121,8 @@ const mockFields: Array<FieldProps |FieldProps[]> = [
|
|
|
121
121
|
| **Input Multi Select** | `InputTypes.MULTI_SELECT` |
|
|
122
122
|
| **Select With Search** | `InputTypes.COMBOBOX` |
|
|
123
123
|
| **Input Drag Drop List** | `InputTypes.SORTABLE_LIST` |
|
|
124
|
+
| **Dynamic Tabs** | `InputTypes.REPEATER_TABS` |
|
|
125
|
+
| **Dynamic String List** | `InputTypes.STRING_LIST` |
|
|
124
126
|
|
|
125
127
|
|
|
126
128
|
|
package/dist/index.cjs
CHANGED
|
@@ -2220,6 +2220,28 @@ var ColorInput = class extends BaseInput {
|
|
|
2220
2220
|
return /* @__PURE__ */ jsxRuntime.jsx(FieldColor, { input, form, isSubmitting });
|
|
2221
2221
|
}
|
|
2222
2222
|
};
|
|
2223
|
+
var PRESET_COLORS = [
|
|
2224
|
+
"#ef4444",
|
|
2225
|
+
// red
|
|
2226
|
+
"#f97316",
|
|
2227
|
+
// orange
|
|
2228
|
+
"#eab308",
|
|
2229
|
+
// yellow
|
|
2230
|
+
"#22c55e",
|
|
2231
|
+
// green
|
|
2232
|
+
"#06b6d4",
|
|
2233
|
+
// cyan
|
|
2234
|
+
"#3b82f6",
|
|
2235
|
+
// blue
|
|
2236
|
+
"#8b5cf6",
|
|
2237
|
+
// purple
|
|
2238
|
+
"#ec4899",
|
|
2239
|
+
// pink
|
|
2240
|
+
"#64748b",
|
|
2241
|
+
// slate
|
|
2242
|
+
"#000000"
|
|
2243
|
+
// black
|
|
2244
|
+
];
|
|
2223
2245
|
var FieldColor = ({ form, input, isSubmitting }) => {
|
|
2224
2246
|
const [ColorCmp, _setColorCmp] = React3.useState(ColorComp);
|
|
2225
2247
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2250,13 +2272,17 @@ var FieldColor = ({ form, input, isSubmitting }) => {
|
|
|
2250
2272
|
var ColorComp = React3__namespace.default.forwardRef(
|
|
2251
2273
|
({ value = "#000000", onChange, onBlur, disabled, className, hideInput = ["hsv"] }, ref) => {
|
|
2252
2274
|
const [color, setColor] = reactColorPalette.useColor(value);
|
|
2253
|
-
const [open, setOpen] =
|
|
2275
|
+
const [open, setOpen] = React3.useState(false);
|
|
2254
2276
|
React3__namespace.default.useEffect(() => {
|
|
2255
2277
|
if (value !== color.hex) {
|
|
2256
2278
|
setColor({ ...color, hex: value });
|
|
2257
2279
|
}
|
|
2258
|
-
}, [
|
|
2280
|
+
}, [value]);
|
|
2259
2281
|
const handleColorChange = (newColor) => {
|
|
2282
|
+
setColor({ ...color, hex: newColor });
|
|
2283
|
+
onChange?.(newColor);
|
|
2284
|
+
};
|
|
2285
|
+
const handlePickerChange = (newColor) => {
|
|
2260
2286
|
setColor(newColor);
|
|
2261
2287
|
onChange?.(newColor.hex);
|
|
2262
2288
|
};
|
|
@@ -2266,21 +2292,38 @@ var ColorComp = React3__namespace.default.forwardRef(
|
|
|
2266
2292
|
onBlur?.();
|
|
2267
2293
|
}
|
|
2268
2294
|
};
|
|
2269
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2270
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2271
|
-
|
|
2295
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
2296
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2 p-2", children: PRESET_COLORS.map((presetColor) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2297
|
+
"button",
|
|
2272
2298
|
{
|
|
2273
|
-
|
|
2274
|
-
variant: "outline",
|
|
2299
|
+
type: "button",
|
|
2275
2300
|
disabled,
|
|
2276
|
-
className: cn(
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2301
|
+
className: cn(
|
|
2302
|
+
"size-6 rounded-md border-2 transition-all hover:scale-110 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
2303
|
+
color.hex === presetColor ? "border-foreground ring-2 ring-foreground/20" : "border-border hover:border-foreground/50"
|
|
2304
|
+
),
|
|
2305
|
+
style: { backgroundColor: presetColor },
|
|
2306
|
+
onClick: () => handleColorChange(presetColor),
|
|
2307
|
+
"aria-label": `Select color ${presetColor}`
|
|
2308
|
+
},
|
|
2309
|
+
presetColor
|
|
2310
|
+
)) }),
|
|
2311
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange: handleOpenChange, children: [
|
|
2312
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2313
|
+
Button,
|
|
2314
|
+
{
|
|
2315
|
+
ref,
|
|
2316
|
+
variant: "outline",
|
|
2317
|
+
disabled,
|
|
2318
|
+
className: cn("w-full justify-start text-left font-normal", !value && "text-muted-foreground", className),
|
|
2319
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
2320
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-4 border border-border rounded-sm", style: { backgroundColor: color.hex, width: 20, height: 20 } }),
|
|
2321
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: color.hex })
|
|
2322
|
+
] })
|
|
2323
|
+
}
|
|
2324
|
+
) }),
|
|
2325
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-auto p-3", align: "start", children: /* @__PURE__ */ jsxRuntime.jsx(reactColorPalette.ColorPicker, { color, onChange: handlePickerChange, hideInput }) })
|
|
2326
|
+
] })
|
|
2284
2327
|
] });
|
|
2285
2328
|
}
|
|
2286
2329
|
);
|
|
@@ -4737,21 +4780,7 @@ var TextInputGroup = class extends BaseInput {
|
|
|
4737
4780
|
}
|
|
4738
4781
|
};
|
|
4739
4782
|
var FieldTextGroup = ({ form, input, isSubmitting }) => {
|
|
4740
|
-
const groupConfig = input.inputGroupConfig;
|
|
4741
|
-
const infoTooltip = input?.infoTooltip;
|
|
4742
|
-
const autoValidate = groupConfig?.autoValidIcons ?? input.zodType ? true : false;
|
|
4743
|
-
const iconValidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleCheck, { style: { color: "#00bf3e" } });
|
|
4744
|
-
const iconInvalidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleX, { style: { color: "#ff8080" } });
|
|
4745
|
-
const iconLoadingState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin", style: { color: "#1e90ff" } });
|
|
4746
|
-
const iconsRight = groupConfig?.iconsRight ?? [];
|
|
4747
|
-
const iconsLeft = groupConfig?.iconsLeft ?? [];
|
|
4748
|
-
const textLeft = groupConfig?.textLeft;
|
|
4749
|
-
const textRight = groupConfig?.textRight;
|
|
4750
4783
|
const [isValid2, setIsValid] = React3.useState(isValidField(input, form));
|
|
4751
|
-
const [showPassword, setShowPassword] = React3.useState(false);
|
|
4752
|
-
const isPasswordField = input.keyboardType === "password" /* PASSWORD */;
|
|
4753
|
-
const isNumberField = input.keyboardType === "number" /* NUMBER */;
|
|
4754
|
-
const showInputGroupAddons = iconsRight.length > 0 || textRight || autoValidate || infoTooltip || isPasswordField;
|
|
4755
4784
|
const formField = /* @__PURE__ */ jsxRuntime.jsx(
|
|
4756
4785
|
FormField,
|
|
4757
4786
|
{
|
|
@@ -4761,51 +4790,13 @@ var FieldTextGroup = ({ form, input, isSubmitting }) => {
|
|
|
4761
4790
|
setIsValid(isValidField(input, form));
|
|
4762
4791
|
return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: input.className, children: [
|
|
4763
4792
|
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
|
|
4764
|
-
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { className: "shadow-lg", children:
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
{
|
|
4772
|
-
placeholder: input.placeHolder,
|
|
4773
|
-
disabled: input.disabled || isSubmitting,
|
|
4774
|
-
onBlur: field.onBlur,
|
|
4775
|
-
name: field.name,
|
|
4776
|
-
ref: field.ref,
|
|
4777
|
-
type: isPasswordField && !showPassword ? "password" : isNumberField ? "number" : "text",
|
|
4778
|
-
value: field.value ?? "",
|
|
4779
|
-
onChange: (e) => {
|
|
4780
|
-
let value = e.target.value;
|
|
4781
|
-
if (isNumberField) {
|
|
4782
|
-
value = e.target.value === "" ? "" : Number(e.target.value);
|
|
4783
|
-
}
|
|
4784
|
-
field.onChange(value);
|
|
4785
|
-
isValidField(input, form);
|
|
4786
|
-
handleOnChage(value, input, field);
|
|
4787
|
-
}
|
|
4788
|
-
}
|
|
4789
|
-
),
|
|
4790
|
-
showInputGroupAddons && /* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { align: "inline-end", children: [
|
|
4791
|
-
infoTooltip && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
4792
|
-
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { size: 20 }) }),
|
|
4793
|
-
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: infoTooltip }) })
|
|
4794
|
-
] }),
|
|
4795
|
-
textRight && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textRight }),
|
|
4796
|
-
iconsRight.map((IconComponent, index) => /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: 20 }, index)),
|
|
4797
|
-
isPasswordField && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4798
|
-
"button",
|
|
4799
|
-
{
|
|
4800
|
-
type: "button",
|
|
4801
|
-
onClick: () => setShowPassword(!showPassword),
|
|
4802
|
-
className: "p-1",
|
|
4803
|
-
children: showPassword ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeOff, { size: 20 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { size: 20 })
|
|
4804
|
-
}
|
|
4805
|
-
),
|
|
4806
|
-
autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid2 ? iconValidState : iconInvalidState })
|
|
4807
|
-
] })
|
|
4808
|
-
] }) }),
|
|
4793
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { className: "shadow-lg", children: CustomInputGroup({
|
|
4794
|
+
input,
|
|
4795
|
+
isSubmitting,
|
|
4796
|
+
field,
|
|
4797
|
+
form,
|
|
4798
|
+
isValid: isValid2
|
|
4799
|
+
}) }),
|
|
4809
4800
|
input.description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: input.description }),
|
|
4810
4801
|
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, {})
|
|
4811
4802
|
] });
|
|
@@ -4815,6 +4806,78 @@ var FieldTextGroup = ({ form, input, isSubmitting }) => {
|
|
|
4815
4806
|
);
|
|
4816
4807
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: formField });
|
|
4817
4808
|
};
|
|
4809
|
+
var CustomInputGroup = ({
|
|
4810
|
+
value,
|
|
4811
|
+
input,
|
|
4812
|
+
field,
|
|
4813
|
+
form,
|
|
4814
|
+
isSubmitting,
|
|
4815
|
+
onChange,
|
|
4816
|
+
isValid: isValid2
|
|
4817
|
+
}) => {
|
|
4818
|
+
const groupConfig = input.inputGroupConfig;
|
|
4819
|
+
const infoTooltip = input?.infoTooltip;
|
|
4820
|
+
const autoValidate = groupConfig?.autoValidIcons ?? input.zodType ? true : false;
|
|
4821
|
+
const iconValidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleCheck, { style: { color: "#00bf3e" } });
|
|
4822
|
+
const iconInvalidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleX, { style: { color: "#ff8080" } });
|
|
4823
|
+
const iconLoadingState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin", style: { color: "#1e90ff" } });
|
|
4824
|
+
const iconsRight = groupConfig?.iconsRight ?? [];
|
|
4825
|
+
const iconsLeft = groupConfig?.iconsLeft ?? [];
|
|
4826
|
+
const textLeft = groupConfig?.textLeft;
|
|
4827
|
+
const textRight = groupConfig?.textRight;
|
|
4828
|
+
const [showPassword, setShowPassword] = React3.useState(false);
|
|
4829
|
+
const isPasswordField = input.keyboardType === "password" /* PASSWORD */;
|
|
4830
|
+
const isNumberField = input.keyboardType === "number" /* NUMBER */;
|
|
4831
|
+
const showInputGroupAddons = iconsRight.length > 0 || textRight || autoValidate || infoTooltip || isPasswordField;
|
|
4832
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(InputGroup, { children: [
|
|
4833
|
+
(iconsLeft.length > 0 || textLeft) && /* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { children: [
|
|
4834
|
+
textLeft && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textLeft }),
|
|
4835
|
+
iconsLeft.map((IconComponent, index) => /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: 20 }, index))
|
|
4836
|
+
] }),
|
|
4837
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4838
|
+
InputGroupInput,
|
|
4839
|
+
{
|
|
4840
|
+
placeholder: input.placeHolder,
|
|
4841
|
+
disabled: input.disabled || isSubmitting,
|
|
4842
|
+
onBlur: field?.onBlur,
|
|
4843
|
+
name: field?.name,
|
|
4844
|
+
ref: field?.ref,
|
|
4845
|
+
type: isPasswordField && !showPassword ? "password" : isNumberField ? "number" : "text",
|
|
4846
|
+
value: field?.value ?? value ?? "",
|
|
4847
|
+
onChange: (e) => {
|
|
4848
|
+
if (onChange) {
|
|
4849
|
+
onChange(e);
|
|
4850
|
+
}
|
|
4851
|
+
let value2 = e.target.value;
|
|
4852
|
+
if (isNumberField) {
|
|
4853
|
+
value2 = e.target.value === "" ? "" : Number(e.target.value);
|
|
4854
|
+
}
|
|
4855
|
+
field?.onChange(value2);
|
|
4856
|
+
isValidField(input, form);
|
|
4857
|
+
handleOnChage(value2, input, field);
|
|
4858
|
+
}
|
|
4859
|
+
}
|
|
4860
|
+
),
|
|
4861
|
+
showInputGroupAddons && /* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { align: "inline-end", children: [
|
|
4862
|
+
infoTooltip && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
4863
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { size: 20 }) }),
|
|
4864
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: infoTooltip }) })
|
|
4865
|
+
] }),
|
|
4866
|
+
textRight && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textRight }),
|
|
4867
|
+
iconsRight.map((IconComponent, index) => /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: 20 }, index)),
|
|
4868
|
+
isPasswordField && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4869
|
+
"button",
|
|
4870
|
+
{
|
|
4871
|
+
type: "button",
|
|
4872
|
+
onClick: () => setShowPassword(!showPassword),
|
|
4873
|
+
className: "p-1",
|
|
4874
|
+
children: showPassword ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeOff, { size: 20 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { size: 20 })
|
|
4875
|
+
}
|
|
4876
|
+
),
|
|
4877
|
+
autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid2 ? iconValidState : iconInvalidState })
|
|
4878
|
+
] })
|
|
4879
|
+
] });
|
|
4880
|
+
};
|
|
4818
4881
|
var NumberInput = class extends BaseInput {
|
|
4819
4882
|
render() {
|
|
4820
4883
|
const { input, form, isSubmitting } = this;
|
|
@@ -5564,6 +5627,10 @@ var StringValueListInput = class extends BaseInput {
|
|
|
5564
5627
|
var FieldStringValueList = ({ form, input, isSubmitting }) => {
|
|
5565
5628
|
const fieldName = input.name;
|
|
5566
5629
|
const withAddBtn = input.withAddBtn ?? false;
|
|
5630
|
+
const [isValid2, setIsValid] = React3.useState(isValidField(input, form));
|
|
5631
|
+
React3.useEffect(() => {
|
|
5632
|
+
setIsValid(isValidField(input, form));
|
|
5633
|
+
}, [input]);
|
|
5567
5634
|
React3.useEffect(() => {
|
|
5568
5635
|
const current = form.getValues(fieldName);
|
|
5569
5636
|
if (!Array.isArray(current)) {
|
|
@@ -5591,7 +5658,7 @@ var FieldStringValueList = ({ form, input, isSubmitting }) => {
|
|
|
5591
5658
|
{
|
|
5592
5659
|
control: form.control,
|
|
5593
5660
|
name: fieldName,
|
|
5594
|
-
render: () => {
|
|
5661
|
+
render: (field) => {
|
|
5595
5662
|
const items = form.watch(fieldName) || [];
|
|
5596
5663
|
return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: input.className, children: [
|
|
5597
5664
|
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
|
|
@@ -5604,12 +5671,14 @@ var FieldStringValueList = ({ form, input, isSubmitting }) => {
|
|
|
5604
5671
|
className: "flex items-center gap-4 py-2",
|
|
5605
5672
|
children: [
|
|
5606
5673
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5607
|
-
|
|
5674
|
+
CustomInputGroup,
|
|
5608
5675
|
{
|
|
5609
|
-
|
|
5676
|
+
autoValidate: true,
|
|
5610
5677
|
value,
|
|
5611
|
-
|
|
5612
|
-
|
|
5678
|
+
input,
|
|
5679
|
+
isValid: isValid2,
|
|
5680
|
+
onChange: (e) => handleChange(index, e.target.value),
|
|
5681
|
+
form
|
|
5613
5682
|
}
|
|
5614
5683
|
),
|
|
5615
5684
|
input.isRemovebleOption && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6595,6 +6664,7 @@ exports.CommandSeparator = CommandSeparator;
|
|
|
6595
6664
|
exports.CommandShortcut = CommandShortcut;
|
|
6596
6665
|
exports.CurrencyInput = CurrencyInput;
|
|
6597
6666
|
exports.CustomAlert = CustomAlert;
|
|
6667
|
+
exports.CustomInputGroup = CustomInputGroup;
|
|
6598
6668
|
exports.DateInput = DateInput;
|
|
6599
6669
|
exports.DateTimeInput = DateTimeInput;
|
|
6600
6670
|
exports.Dialog = Dialog;
|