shadcn-zod-formkit 1.29.0 → 1.30.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/dist/index.cjs +143 -120
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +144 -121
- package/dist/index.mjs.map +1 -1
- package/dist/shadcn-zod-formkit-1.30.0.tgz +0 -0
- package/package.json +1 -1
- package/dist/shadcn-zod-formkit-1.29.0.tgz +0 -0
package/dist/index.cjs
CHANGED
|
@@ -2221,6 +2221,8 @@ var ColorInput = class extends BaseInput {
|
|
|
2221
2221
|
}
|
|
2222
2222
|
};
|
|
2223
2223
|
var PRESET_COLORS = [
|
|
2224
|
+
"#800000",
|
|
2225
|
+
// Maroon
|
|
2224
2226
|
"#ef4444",
|
|
2225
2227
|
// red
|
|
2226
2228
|
"#f97316",
|
|
@@ -2229,16 +2231,26 @@ var PRESET_COLORS = [
|
|
|
2229
2231
|
// yellow
|
|
2230
2232
|
"#22c55e",
|
|
2231
2233
|
// green
|
|
2234
|
+
"#00FF00",
|
|
2235
|
+
// lime
|
|
2236
|
+
"#00FFFF",
|
|
2237
|
+
// Aqua
|
|
2232
2238
|
"#06b6d4",
|
|
2233
2239
|
// cyan
|
|
2234
2240
|
"#3b82f6",
|
|
2235
2241
|
// blue
|
|
2236
2242
|
"#8b5cf6",
|
|
2237
2243
|
// purple
|
|
2244
|
+
"#800080",
|
|
2245
|
+
// purple
|
|
2246
|
+
"#FF00FF",
|
|
2247
|
+
// Fuchsia
|
|
2238
2248
|
"#ec4899",
|
|
2239
2249
|
// pink
|
|
2240
2250
|
"#64748b",
|
|
2241
2251
|
// slate
|
|
2252
|
+
"#808080",
|
|
2253
|
+
// Gray
|
|
2242
2254
|
"#000000"
|
|
2243
2255
|
// black
|
|
2244
2256
|
];
|
|
@@ -4564,6 +4576,111 @@ var FieldFileMultiUpload = ({ input, form, isSubmitting }) => {
|
|
|
4564
4576
|
);
|
|
4565
4577
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: formField });
|
|
4566
4578
|
};
|
|
4579
|
+
var TextInputGroup = class extends BaseInput {
|
|
4580
|
+
render() {
|
|
4581
|
+
const { input, form, isSubmitting } = this;
|
|
4582
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FieldTextGroup, { input, form, isSubmitting });
|
|
4583
|
+
}
|
|
4584
|
+
};
|
|
4585
|
+
var FieldTextGroup = ({ form, input, isSubmitting }) => {
|
|
4586
|
+
const [isValid2, setIsValid] = React3.useState(isValidField(input, form));
|
|
4587
|
+
const formField = /* @__PURE__ */ jsxRuntime.jsx(
|
|
4588
|
+
FormField,
|
|
4589
|
+
{
|
|
4590
|
+
control: form.control,
|
|
4591
|
+
name: input.name,
|
|
4592
|
+
render: ({ field }) => {
|
|
4593
|
+
setIsValid(isValidField(input, form));
|
|
4594
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: input.className, children: [
|
|
4595
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
|
|
4596
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { className: "shadow-lg", children: CustomInputGroup({
|
|
4597
|
+
input,
|
|
4598
|
+
isSubmitting,
|
|
4599
|
+
field,
|
|
4600
|
+
form,
|
|
4601
|
+
isValid: isValid2
|
|
4602
|
+
}) }),
|
|
4603
|
+
input.description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: input.description }),
|
|
4604
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, {})
|
|
4605
|
+
] });
|
|
4606
|
+
}
|
|
4607
|
+
},
|
|
4608
|
+
input.name
|
|
4609
|
+
);
|
|
4610
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: formField });
|
|
4611
|
+
};
|
|
4612
|
+
var CustomInputGroup = ({
|
|
4613
|
+
value,
|
|
4614
|
+
input,
|
|
4615
|
+
field,
|
|
4616
|
+
form,
|
|
4617
|
+
isSubmitting,
|
|
4618
|
+
onChange,
|
|
4619
|
+
isValid: isValid2
|
|
4620
|
+
}) => {
|
|
4621
|
+
const groupConfig = input.inputGroupConfig;
|
|
4622
|
+
const infoTooltip = input?.infoTooltip;
|
|
4623
|
+
const autoValidate = groupConfig?.autoValidIcons ?? input.zodType ? true : false;
|
|
4624
|
+
const iconValidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleCheck, { style: { color: "#00bf3e" } });
|
|
4625
|
+
const iconInvalidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleX, { style: { color: "#ff8080" } });
|
|
4626
|
+
const iconLoadingState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin", style: { color: "#1e90ff" } });
|
|
4627
|
+
const iconsRight = groupConfig?.iconsRight ?? [];
|
|
4628
|
+
const iconsLeft = groupConfig?.iconsLeft ?? [];
|
|
4629
|
+
const textLeft = groupConfig?.textLeft;
|
|
4630
|
+
const textRight = groupConfig?.textRight;
|
|
4631
|
+
const [showPassword, setShowPassword] = React3.useState(false);
|
|
4632
|
+
const isPasswordField = input.keyboardType === "password" /* PASSWORD */;
|
|
4633
|
+
const isNumberField = input.keyboardType === "number" /* NUMBER */;
|
|
4634
|
+
const showInputGroupAddons = iconsRight.length > 0 || textRight || autoValidate || infoTooltip || isPasswordField;
|
|
4635
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(InputGroup, { children: [
|
|
4636
|
+
(iconsLeft.length > 0 || textLeft) && /* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { children: [
|
|
4637
|
+
textLeft && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textLeft }),
|
|
4638
|
+
iconsLeft.map((IconComponent, index) => /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: 20 }, index))
|
|
4639
|
+
] }),
|
|
4640
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4641
|
+
InputGroupInput,
|
|
4642
|
+
{
|
|
4643
|
+
placeholder: input.placeHolder,
|
|
4644
|
+
disabled: input.disabled || isSubmitting,
|
|
4645
|
+
onBlur: field?.onBlur,
|
|
4646
|
+
name: field?.name,
|
|
4647
|
+
ref: field?.ref,
|
|
4648
|
+
type: isPasswordField && !showPassword ? "password" : isNumberField ? "number" : "text",
|
|
4649
|
+
value: field?.value ?? value ?? "",
|
|
4650
|
+
onChange: (e) => {
|
|
4651
|
+
if (onChange) {
|
|
4652
|
+
onChange(e);
|
|
4653
|
+
}
|
|
4654
|
+
let value2 = e.target.value;
|
|
4655
|
+
if (isNumberField) {
|
|
4656
|
+
value2 = e.target.value === "" ? "" : Number(e.target.value);
|
|
4657
|
+
}
|
|
4658
|
+
field?.onChange(value2);
|
|
4659
|
+
isValidField(input, form);
|
|
4660
|
+
handleOnChage(value2, input, field);
|
|
4661
|
+
}
|
|
4662
|
+
}
|
|
4663
|
+
),
|
|
4664
|
+
showInputGroupAddons && /* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { align: "inline-end", children: [
|
|
4665
|
+
infoTooltip && /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
|
|
4666
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { size: 20 }) }),
|
|
4667
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntime.jsx("p", { children: infoTooltip }) })
|
|
4668
|
+
] }),
|
|
4669
|
+
textRight && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textRight }),
|
|
4670
|
+
iconsRight.map((IconComponent, index) => /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { size: 20 }, index)),
|
|
4671
|
+
isPasswordField && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4672
|
+
"button",
|
|
4673
|
+
{
|
|
4674
|
+
type: "button",
|
|
4675
|
+
onClick: () => setShowPassword(!showPassword),
|
|
4676
|
+
className: "p-1",
|
|
4677
|
+
children: showPassword ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeOff, { size: 20 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { size: 20 })
|
|
4678
|
+
}
|
|
4679
|
+
),
|
|
4680
|
+
autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid2 ? iconValidState : iconInvalidState })
|
|
4681
|
+
] })
|
|
4682
|
+
] });
|
|
4683
|
+
};
|
|
4567
4684
|
var KeyValueListInput = class extends BaseInput {
|
|
4568
4685
|
render() {
|
|
4569
4686
|
const { input, form, isSubmitting } = this;
|
|
@@ -4620,27 +4737,31 @@ var FieldKeyValueList = ({ form, input, isSubmitting }) => {
|
|
|
4620
4737
|
children: [
|
|
4621
4738
|
/* @__PURE__ */ jsxRuntime.jsxs(ButtonGroup, { className: "w-full", children: [
|
|
4622
4739
|
/* @__PURE__ */ jsxRuntime.jsx(ButtonGroupText, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(LabelPrimitive.Label, { htmlFor: "key", children: "Key" }) }),
|
|
4623
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4624
|
-
|
|
4740
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4741
|
+
CustomInputGroup,
|
|
4625
4742
|
{
|
|
4626
|
-
|
|
4743
|
+
autoValidate: true,
|
|
4627
4744
|
value: pair.key,
|
|
4628
|
-
|
|
4745
|
+
input,
|
|
4746
|
+
isValid: pair.key.trim() != "",
|
|
4747
|
+
isSubmitting,
|
|
4629
4748
|
onChange: (e) => handleChange(index, "key", e.target.value),
|
|
4630
|
-
|
|
4749
|
+
form
|
|
4631
4750
|
}
|
|
4632
|
-
)
|
|
4751
|
+
)
|
|
4633
4752
|
] }),
|
|
4634
4753
|
/* @__PURE__ */ jsxRuntime.jsxs(ButtonGroup, { className: "w-full", children: [
|
|
4635
4754
|
/* @__PURE__ */ jsxRuntime.jsx(ButtonGroupText, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(LabelPrimitive.Label, { htmlFor: "value", children: "Value" }) }),
|
|
4636
4755
|
/* @__PURE__ */ jsxRuntime.jsx(InputGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4637
|
-
|
|
4756
|
+
CustomInputGroup,
|
|
4638
4757
|
{
|
|
4639
|
-
|
|
4758
|
+
autoValidate: true,
|
|
4640
4759
|
value: pair.value,
|
|
4641
|
-
|
|
4760
|
+
input,
|
|
4761
|
+
isValid: pair.value.trim() != "",
|
|
4762
|
+
isSubmitting,
|
|
4642
4763
|
onChange: (e) => handleChange(index, "value", e.target.value),
|
|
4643
|
-
|
|
4764
|
+
form
|
|
4644
4765
|
}
|
|
4645
4766
|
) })
|
|
4646
4767
|
] }),
|
|
@@ -4773,111 +4894,6 @@ var FieldMultiSelect = ({ form, input, isSubmitting }) => {
|
|
|
4773
4894
|
input.name
|
|
4774
4895
|
);
|
|
4775
4896
|
};
|
|
4776
|
-
var TextInputGroup = class extends BaseInput {
|
|
4777
|
-
render() {
|
|
4778
|
-
const { input, form, isSubmitting } = this;
|
|
4779
|
-
return /* @__PURE__ */ jsxRuntime.jsx(FieldTextGroup, { input, form, isSubmitting });
|
|
4780
|
-
}
|
|
4781
|
-
};
|
|
4782
|
-
var FieldTextGroup = ({ form, input, isSubmitting }) => {
|
|
4783
|
-
const [isValid2, setIsValid] = React3.useState(isValidField(input, form));
|
|
4784
|
-
const formField = /* @__PURE__ */ jsxRuntime.jsx(
|
|
4785
|
-
FormField,
|
|
4786
|
-
{
|
|
4787
|
-
control: form.control,
|
|
4788
|
-
name: input.name,
|
|
4789
|
-
render: ({ field }) => {
|
|
4790
|
-
setIsValid(isValidField(input, form));
|
|
4791
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: input.className, children: [
|
|
4792
|
-
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
|
|
4793
|
-
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { className: "shadow-lg", children: CustomInputGroup({
|
|
4794
|
-
input,
|
|
4795
|
-
isSubmitting,
|
|
4796
|
-
field,
|
|
4797
|
-
form,
|
|
4798
|
-
isValid: isValid2
|
|
4799
|
-
}) }),
|
|
4800
|
-
input.description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: input.description }),
|
|
4801
|
-
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, {})
|
|
4802
|
-
] });
|
|
4803
|
-
}
|
|
4804
|
-
},
|
|
4805
|
-
input.name
|
|
4806
|
-
);
|
|
4807
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: formField });
|
|
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
|
-
};
|
|
4881
4897
|
var NumberInput = class extends BaseInput {
|
|
4882
4898
|
render() {
|
|
4883
4899
|
const { input, form, isSubmitting } = this;
|
|
@@ -4990,6 +5006,10 @@ var FieldRepeater = ({ form, input, isSubmitting }) => {
|
|
|
4990
5006
|
});
|
|
4991
5007
|
const canAdd = !input.maxItems || fields.length < input.maxItems;
|
|
4992
5008
|
const canRemove = fields.length > (input.minItems ?? 0);
|
|
5009
|
+
const [isValid2, setIsValid] = React3.useState(isValidField(input, form));
|
|
5010
|
+
React3.useEffect(() => {
|
|
5011
|
+
setIsValid(isValidField(input, form));
|
|
5012
|
+
}, [input]);
|
|
4993
5013
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4994
5014
|
FormField,
|
|
4995
5015
|
{
|
|
@@ -5009,7 +5029,7 @@ var FieldRepeater = ({ form, input, isSubmitting }) => {
|
|
|
5009
5029
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5010
5030
|
"div",
|
|
5011
5031
|
{
|
|
5012
|
-
className: `grid gap-
|
|
5032
|
+
className: `grid gap-1 grid-cols-${cols}`,
|
|
5013
5033
|
children: group.map((subField) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5014
5034
|
FormField,
|
|
5015
5035
|
{
|
|
@@ -5018,11 +5038,14 @@ var FieldRepeater = ({ form, input, isSubmitting }) => {
|
|
|
5018
5038
|
render: ({ field, fieldState }) => /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: "flex-1", children: [
|
|
5019
5039
|
/* @__PURE__ */ jsxRuntime.jsx(FormLabel, { children: subField.label }),
|
|
5020
5040
|
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5021
|
-
|
|
5041
|
+
CustomInputGroup,
|
|
5022
5042
|
{
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5043
|
+
autoValidate: true,
|
|
5044
|
+
value: field.value,
|
|
5045
|
+
input: subField,
|
|
5046
|
+
isValid: isValid2,
|
|
5047
|
+
field,
|
|
5048
|
+
form
|
|
5026
5049
|
}
|
|
5027
5050
|
) }),
|
|
5028
5051
|
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, { children: fieldState.error?.message })
|