shadcn-zod-formkit 1.24.0 → 1.25.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 +100 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +100 -1
- package/dist/index.mjs.map +1 -1
- package/dist/shadcn-zod-formkit-1.25.0.tgz +0 -0
- package/package.json +1 -1
- package/dist/shadcn-zod-formkit-1.24.0.tgz +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -74,7 +74,8 @@ declare enum InputTypes {
|
|
|
74
74
|
MULTI_SELECT = "multi_select",
|
|
75
75
|
COMBOBOX = "COMBO_BOX",
|
|
76
76
|
SORTABLE_LIST = "sortable_list",
|
|
77
|
-
REPEATER_TABS = "repeater_tabs"
|
|
77
|
+
REPEATER_TABS = "repeater_tabs",
|
|
78
|
+
STRING_LIST = "string_list"
|
|
78
79
|
}
|
|
79
80
|
declare const inputFieldComp: InputTypes[];
|
|
80
81
|
|
|
@@ -83,6 +84,7 @@ type FieldConfig<T, RT = Record<string, any>> = FieldProps<T, RT> | FieldConfig<
|
|
|
83
84
|
interface FieldProps<T = Record<string, any>, RT = Record<string, any>> {
|
|
84
85
|
name: keyof T;
|
|
85
86
|
label: string;
|
|
87
|
+
isRemovebleOption?: boolean;
|
|
86
88
|
withDuplicatTag?: boolean;
|
|
87
89
|
onChange?: (...event: any[]) => void;
|
|
88
90
|
tabLabelField?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -74,7 +74,8 @@ declare enum InputTypes {
|
|
|
74
74
|
MULTI_SELECT = "multi_select",
|
|
75
75
|
COMBOBOX = "COMBO_BOX",
|
|
76
76
|
SORTABLE_LIST = "sortable_list",
|
|
77
|
-
REPEATER_TABS = "repeater_tabs"
|
|
77
|
+
REPEATER_TABS = "repeater_tabs",
|
|
78
|
+
STRING_LIST = "string_list"
|
|
78
79
|
}
|
|
79
80
|
declare const inputFieldComp: InputTypes[];
|
|
80
81
|
|
|
@@ -83,6 +84,7 @@ type FieldConfig<T, RT = Record<string, any>> = FieldProps<T, RT> | FieldConfig<
|
|
|
83
84
|
interface FieldProps<T = Record<string, any>, RT = Record<string, any>> {
|
|
84
85
|
name: keyof T;
|
|
85
86
|
label: string;
|
|
87
|
+
isRemovebleOption?: boolean;
|
|
86
88
|
withDuplicatTag?: boolean;
|
|
87
89
|
onChange?: (...event: any[]) => void;
|
|
88
90
|
tabLabelField?: string;
|
package/dist/index.mjs
CHANGED
|
@@ -256,9 +256,11 @@ var InputTypes = /* @__PURE__ */ ((InputTypes2) => {
|
|
|
256
256
|
InputTypes2["COMBOBOX"] = "COMBO_BOX";
|
|
257
257
|
InputTypes2["SORTABLE_LIST"] = "sortable_list";
|
|
258
258
|
InputTypes2["REPEATER_TABS"] = "repeater_tabs";
|
|
259
|
+
InputTypes2["STRING_LIST"] = "string_list";
|
|
259
260
|
return InputTypes2;
|
|
260
261
|
})(InputTypes || {});
|
|
261
262
|
var inputFieldComp = [
|
|
263
|
+
"string_list" /* STRING_LIST */,
|
|
262
264
|
"repeater_tabs" /* REPEATER_TABS */,
|
|
263
265
|
"sortable_list" /* SORTABLE_LIST */,
|
|
264
266
|
"COMBO_BOX" /* COMBOBOX */,
|
|
@@ -4182,7 +4184,7 @@ var FieldKeyValueList = ({ form, input, isSubmitting }) => {
|
|
|
4182
4184
|
return /* @__PURE__ */ jsxs(FormItem, { className: input.className, children: [
|
|
4183
4185
|
/* @__PURE__ */ jsx(FormLabel, { children: /* @__PURE__ */ jsx("b", { children: input.label }) }),
|
|
4184
4186
|
/* @__PURE__ */ jsx(FormMessage, {}),
|
|
4185
|
-
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3
|
|
4187
|
+
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 rounded-xl p-3 ", children: [
|
|
4186
4188
|
pairs.length === 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "No pairs have been added yet." }),
|
|
4187
4189
|
pairs.map((pair, index) => /* @__PURE__ */ jsxs(
|
|
4188
4190
|
"div",
|
|
@@ -5160,6 +5162,102 @@ function SortableWrapper({
|
|
|
5160
5162
|
}
|
|
5161
5163
|
);
|
|
5162
5164
|
}
|
|
5165
|
+
var StringValueListInput = class extends BaseInput {
|
|
5166
|
+
render() {
|
|
5167
|
+
const { input, form, isSubmitting } = this;
|
|
5168
|
+
return /* @__PURE__ */ jsx(
|
|
5169
|
+
FieldStringValueList,
|
|
5170
|
+
{
|
|
5171
|
+
input,
|
|
5172
|
+
form,
|
|
5173
|
+
isSubmitting
|
|
5174
|
+
}
|
|
5175
|
+
);
|
|
5176
|
+
}
|
|
5177
|
+
};
|
|
5178
|
+
var FieldStringValueList = ({ form, input, isSubmitting }) => {
|
|
5179
|
+
const fieldName = input.name;
|
|
5180
|
+
useEffect(() => {
|
|
5181
|
+
const current = form.getValues(fieldName);
|
|
5182
|
+
if (!Array.isArray(current)) {
|
|
5183
|
+
form.setValue(fieldName, []);
|
|
5184
|
+
}
|
|
5185
|
+
}, [form, fieldName]);
|
|
5186
|
+
const handleAddItem = () => {
|
|
5187
|
+
const current = form.getValues(fieldName) || [];
|
|
5188
|
+
form.setValue(fieldName, [...current, ""]);
|
|
5189
|
+
};
|
|
5190
|
+
const handleRemoveItem = (index) => {
|
|
5191
|
+
const current = form.getValues(fieldName) || [];
|
|
5192
|
+
const updated = current.filter((_, i) => i !== index);
|
|
5193
|
+
form.setValue(fieldName, updated);
|
|
5194
|
+
};
|
|
5195
|
+
const handleChange = (index, newValue) => {
|
|
5196
|
+
const current = form.getValues(fieldName) || [];
|
|
5197
|
+
const updated = current.map(
|
|
5198
|
+
(item, i) => i === index ? newValue : item
|
|
5199
|
+
);
|
|
5200
|
+
form.setValue(fieldName, updated);
|
|
5201
|
+
};
|
|
5202
|
+
return /* @__PURE__ */ jsx(
|
|
5203
|
+
FormField,
|
|
5204
|
+
{
|
|
5205
|
+
control: form.control,
|
|
5206
|
+
name: fieldName,
|
|
5207
|
+
render: () => {
|
|
5208
|
+
const items = form.watch(fieldName) || [];
|
|
5209
|
+
return /* @__PURE__ */ jsxs(FormItem, { className: input.className, children: [
|
|
5210
|
+
/* @__PURE__ */ jsx(FormLabel, { children: /* @__PURE__ */ jsx("b", { children: input.label }) }),
|
|
5211
|
+
/* @__PURE__ */ jsx(FormMessage, {}),
|
|
5212
|
+
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 rounded-xl ", children: [
|
|
5213
|
+
items.length === 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "No items have been added yet." }),
|
|
5214
|
+
items.map((value, index) => /* @__PURE__ */ jsxs(
|
|
5215
|
+
"div",
|
|
5216
|
+
{
|
|
5217
|
+
className: "flex gap-2 items-center",
|
|
5218
|
+
children: [
|
|
5219
|
+
/* @__PURE__ */ jsx(
|
|
5220
|
+
Input,
|
|
5221
|
+
{
|
|
5222
|
+
placeholder: `Item ${index + 1}`,
|
|
5223
|
+
value,
|
|
5224
|
+
disabled: isSubmitting,
|
|
5225
|
+
onChange: (e) => handleChange(index, e.target.value)
|
|
5226
|
+
}
|
|
5227
|
+
),
|
|
5228
|
+
input.isRemovebleOption && /* @__PURE__ */ jsx(
|
|
5229
|
+
Button,
|
|
5230
|
+
{
|
|
5231
|
+
type: "button",
|
|
5232
|
+
variant: "destructive",
|
|
5233
|
+
size: "icon",
|
|
5234
|
+
onClick: () => handleRemoveItem(index),
|
|
5235
|
+
disabled: isSubmitting,
|
|
5236
|
+
children: /* @__PURE__ */ jsx(Trash2, { size: 18 })
|
|
5237
|
+
}
|
|
5238
|
+
)
|
|
5239
|
+
]
|
|
5240
|
+
},
|
|
5241
|
+
index
|
|
5242
|
+
)),
|
|
5243
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end mt-2", children: /* @__PURE__ */ jsx(
|
|
5244
|
+
Button,
|
|
5245
|
+
{
|
|
5246
|
+
type: "button",
|
|
5247
|
+
variant: "outline",
|
|
5248
|
+
size: "sm",
|
|
5249
|
+
onClick: handleAddItem,
|
|
5250
|
+
disabled: isSubmitting,
|
|
5251
|
+
children: /* @__PURE__ */ jsx(Plus, { size: 18, className: "mr-1" })
|
|
5252
|
+
}
|
|
5253
|
+
) })
|
|
5254
|
+
] }) }),
|
|
5255
|
+
input.description && /* @__PURE__ */ jsx(FormDescription, { children: input.description })
|
|
5256
|
+
] });
|
|
5257
|
+
}
|
|
5258
|
+
}
|
|
5259
|
+
);
|
|
5260
|
+
};
|
|
5163
5261
|
var SwitchInput = class extends BaseInput {
|
|
5164
5262
|
render() {
|
|
5165
5263
|
const { input, form, isSubmitting } = this;
|
|
@@ -5471,6 +5569,7 @@ var inputMap = {
|
|
|
5471
5569
|
["COMBO_BOX" /* COMBOBOX */]: ComboboxInput,
|
|
5472
5570
|
["sortable_list" /* SORTABLE_LIST */]: SortableListInput,
|
|
5473
5571
|
["repeater_tabs" /* REPEATER_TABS */]: RepeaterTabsInput,
|
|
5572
|
+
["string_list" /* STRING_LIST */]: StringValueListInput,
|
|
5474
5573
|
//ToDos: ============================================================
|
|
5475
5574
|
["slider" /* SLIDER */]: SliderInput,
|
|
5476
5575
|
//ToDo: // PENDIENTE ... VISUALMENTE NO SE VE BIEN.!!!
|