shadcn-zod-formkit 3.6.0 → 3.8.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 +211 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +211 -36
- package/dist/index.mjs.map +1 -1
- package/dist/shadcn-zod-formkit-3.8.0.tgz +0 -0
- package/package.json +1 -1
- package/dist/shadcn-zod-formkit-3.6.0.tgz +0 -0
package/dist/index.cjs
CHANGED
|
@@ -9229,7 +9229,7 @@ var require_leaflet_src = __commonJS({
|
|
|
9229
9229
|
// Amount of pixels to pan when pressing an arrow key.
|
|
9230
9230
|
keyboardPanDelta: 80
|
|
9231
9231
|
});
|
|
9232
|
-
var
|
|
9232
|
+
var Keyboard4 = Handler.extend({
|
|
9233
9233
|
keyCodes: {
|
|
9234
9234
|
left: [37],
|
|
9235
9235
|
right: [39],
|
|
@@ -9347,7 +9347,7 @@ var require_leaflet_src = __commonJS({
|
|
|
9347
9347
|
stop(e);
|
|
9348
9348
|
}
|
|
9349
9349
|
});
|
|
9350
|
-
Map2.addInitHook("addHandler", "keyboard",
|
|
9350
|
+
Map2.addInitHook("addHandler", "keyboard", Keyboard4);
|
|
9351
9351
|
Map2.mergeOptions({
|
|
9352
9352
|
// @section Mouse wheel options
|
|
9353
9353
|
// @option scrollWheelZoom: Boolean|String = true
|
|
@@ -9565,7 +9565,7 @@ var require_leaflet_src = __commonJS({
|
|
|
9565
9565
|
Map2.BoxZoom = BoxZoom;
|
|
9566
9566
|
Map2.DoubleClickZoom = DoubleClickZoom;
|
|
9567
9567
|
Map2.Drag = Drag;
|
|
9568
|
-
Map2.Keyboard =
|
|
9568
|
+
Map2.Keyboard = Keyboard4;
|
|
9569
9569
|
Map2.ScrollWheelZoom = ScrollWheelZoom;
|
|
9570
9570
|
Map2.TapHold = TapHold;
|
|
9571
9571
|
Map2.TouchZoom = TouchZoom;
|
|
@@ -10132,11 +10132,10 @@ var useKeyboardStore = zustand.create((set, get) => ({
|
|
|
10132
10132
|
currentInputField: null,
|
|
10133
10133
|
setCurrentInputField(inputField) {
|
|
10134
10134
|
set({ currentInputField: inputField });
|
|
10135
|
-
console.log("Current Input Field set to:", inputField);
|
|
10136
10135
|
},
|
|
10137
10136
|
isOpen: false,
|
|
10138
|
-
setIsOpen() {
|
|
10139
|
-
set({ isOpen: !get().isOpen });
|
|
10137
|
+
setIsOpen(open) {
|
|
10138
|
+
set({ isOpen: open ?? !get().isOpen });
|
|
10140
10139
|
},
|
|
10141
10140
|
registerInput: (id, initialValue = "") => set((state) => ({
|
|
10142
10141
|
inputs: {
|
|
@@ -10150,12 +10149,29 @@ var useKeyboardStore = zustand.create((set, get) => ({
|
|
|
10150
10149
|
return { inputs: newInputs };
|
|
10151
10150
|
}),
|
|
10152
10151
|
focusInput: (id) => set({ activeInput: id }),
|
|
10152
|
+
// write: (char) =>
|
|
10153
|
+
// set((state) => {
|
|
10154
|
+
// const current = state.currentInputField;
|
|
10155
|
+
// if (!current?.field) return state;
|
|
10156
|
+
// const newValue = (current.field.value ?? "") + char;
|
|
10157
|
+
// current.field.onChange(newValue); // 🔥 RHF update
|
|
10158
|
+
// return {
|
|
10159
|
+
// currentInputField: {
|
|
10160
|
+
// ...current,
|
|
10161
|
+
// field: {
|
|
10162
|
+
// ...current.field,
|
|
10163
|
+
// value: newValue
|
|
10164
|
+
// }
|
|
10165
|
+
// }
|
|
10166
|
+
// };
|
|
10167
|
+
// }),
|
|
10153
10168
|
write: (char) => set((state) => {
|
|
10154
10169
|
let currentInputField = state.currentInputField;
|
|
10155
10170
|
if (currentInputField && currentInputField.field) {
|
|
10156
10171
|
currentInputField.field.value += char;
|
|
10172
|
+
const newValue = currentInputField.field.value;
|
|
10157
10173
|
set({ currentInputField });
|
|
10158
|
-
|
|
10174
|
+
currentInputField.field.onChange(newValue);
|
|
10159
10175
|
}
|
|
10160
10176
|
if (!state.activeInput) return state;
|
|
10161
10177
|
const current = state.inputs[state.activeInput] || "";
|
|
@@ -10167,8 +10183,16 @@ var useKeyboardStore = zustand.create((set, get) => ({
|
|
|
10167
10183
|
};
|
|
10168
10184
|
}),
|
|
10169
10185
|
backspace: () => set((state) => {
|
|
10186
|
+
let currentInputField = state.currentInputField;
|
|
10187
|
+
if (currentInputField && currentInputField.field) {
|
|
10188
|
+
const newValue = currentInputField.field.value.slice(0, -1);
|
|
10189
|
+
currentInputField.field.value = newValue;
|
|
10190
|
+
set({ currentInputField });
|
|
10191
|
+
currentInputField.field.onChange(newValue);
|
|
10192
|
+
}
|
|
10170
10193
|
if (!state.activeInput) return state;
|
|
10171
10194
|
const current = state.inputs[state.activeInput] || "";
|
|
10195
|
+
console.log("RUN BACKSPACE - current value:", current);
|
|
10172
10196
|
return {
|
|
10173
10197
|
inputs: {
|
|
10174
10198
|
...state.inputs,
|
|
@@ -10201,8 +10225,53 @@ var KeyboardQwerty = ({ onKeyPress, onEnter, keyFontSize: keyFontSize3 = "text-2
|
|
|
10201
10225
|
const [shiftMode, setShiftMode] = React3.useState("off");
|
|
10202
10226
|
const [mode, setMode] = React3.useState("letters");
|
|
10203
10227
|
const lastShiftPress = React3.useRef(0);
|
|
10204
|
-
const { currentInputField, write } = useKeyboardStore();
|
|
10228
|
+
const { currentInputField, write, setIsOpen, backspace } = useKeyboardStore();
|
|
10205
10229
|
const isUpper = shiftMode !== "off";
|
|
10230
|
+
React3.useEffect(() => {
|
|
10231
|
+
const handleKeyDown = (e) => {
|
|
10232
|
+
if (!currentInputField) return;
|
|
10233
|
+
const key = e.key;
|
|
10234
|
+
if (key === "Enter") {
|
|
10235
|
+
e.preventDefault();
|
|
10236
|
+
onEnter?.();
|
|
10237
|
+
return;
|
|
10238
|
+
}
|
|
10239
|
+
if (key === "Backspace") {
|
|
10240
|
+
backspace();
|
|
10241
|
+
e.preventDefault();
|
|
10242
|
+
onDelete?.();
|
|
10243
|
+
return;
|
|
10244
|
+
}
|
|
10245
|
+
if (key === " ") {
|
|
10246
|
+
e.preventDefault();
|
|
10247
|
+
handleKey(" ");
|
|
10248
|
+
return;
|
|
10249
|
+
}
|
|
10250
|
+
if (key === "Shift") {
|
|
10251
|
+
handleShift();
|
|
10252
|
+
return;
|
|
10253
|
+
}
|
|
10254
|
+
if (key === "CapsLock") {
|
|
10255
|
+
handleCaps();
|
|
10256
|
+
return;
|
|
10257
|
+
}
|
|
10258
|
+
if (key === "Tab") {
|
|
10259
|
+
e.preventDefault();
|
|
10260
|
+
return;
|
|
10261
|
+
}
|
|
10262
|
+
if (key === "Escape") {
|
|
10263
|
+
setIsOpen(false);
|
|
10264
|
+
return;
|
|
10265
|
+
}
|
|
10266
|
+
if (key.length === 1) {
|
|
10267
|
+
handleKey(key);
|
|
10268
|
+
}
|
|
10269
|
+
};
|
|
10270
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
10271
|
+
return () => {
|
|
10272
|
+
window.removeEventListener("keydown", handleKeyDown);
|
|
10273
|
+
};
|
|
10274
|
+
}, [currentInputField, shiftMode]);
|
|
10206
10275
|
const handleShift = () => {
|
|
10207
10276
|
const now = Date.now();
|
|
10208
10277
|
if (now - lastShiftPress.current < 300) {
|
|
@@ -10213,19 +10282,21 @@ var KeyboardQwerty = ({ onKeyPress, onEnter, keyFontSize: keyFontSize3 = "text-2
|
|
|
10213
10282
|
lastShiftPress.current = now;
|
|
10214
10283
|
};
|
|
10215
10284
|
const handleKey = (key) => {
|
|
10216
|
-
console.log("Key pressed:", key);
|
|
10217
10285
|
const output = isUpper ? key.toUpperCase() : key;
|
|
10218
10286
|
onKeyPress?.(output);
|
|
10219
10287
|
write(output);
|
|
10220
|
-
if (shiftMode === "once")
|
|
10221
|
-
setShiftMode("off");
|
|
10222
|
-
}
|
|
10288
|
+
if (shiftMode === "once") setShiftMode("off");
|
|
10223
10289
|
};
|
|
10224
10290
|
const handleCaps = () => {
|
|
10225
10291
|
setShiftMode((prev) => prev === "caps" ? "off" : "caps");
|
|
10226
10292
|
};
|
|
10227
10293
|
const shiftLabel = shiftMode === "caps" ? lucideReact.ArrowBigUpDash : lucideReact.ArrowBigUp;
|
|
10228
10294
|
const shiftActive = shiftMode !== "off";
|
|
10295
|
+
const textField = /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: currentInputField && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-3 h-full min-h-16 flex-1 flex flex-row text-2xl font-bold justify-center text-center items-center gap-2 rounded-xl border-2 transition-all outline-none border-amber-400 bg-amber-50 ", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
10296
|
+
" ",
|
|
10297
|
+
currentInputField.field?.value,
|
|
10298
|
+
" "
|
|
10299
|
+
] }) }) });
|
|
10229
10300
|
if (mode === "symbols") {
|
|
10230
10301
|
const keys = [
|
|
10231
10302
|
["!", "@", "#", "$", "%", "^", "&", "*", "(", ")"],
|
|
@@ -10237,32 +10308,31 @@ var KeyboardQwerty = ({ onKeyPress, onEnter, keyFontSize: keyFontSize3 = "text-2
|
|
|
10237
10308
|
onClick: () => handleKey(k)
|
|
10238
10309
|
}))
|
|
10239
10310
|
);
|
|
10240
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
10241
|
-
|
|
10242
|
-
|
|
10243
|
-
|
|
10244
|
-
|
|
10245
|
-
|
|
10246
|
-
|
|
10247
|
-
[
|
|
10248
|
-
|
|
10249
|
-
|
|
10250
|
-
|
|
10311
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full h-full flex flex-col", children: [
|
|
10312
|
+
textField,
|
|
10313
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10314
|
+
KeyboardBuilder,
|
|
10315
|
+
{
|
|
10316
|
+
className: "w-full h-full",
|
|
10317
|
+
keyFontSize: keyFontSize3,
|
|
10318
|
+
keys: [
|
|
10319
|
+
...keys,
|
|
10320
|
+
[
|
|
10321
|
+
{ label: "ABC", onClick: () => setMode("letters"), className: "flex-[2]" },
|
|
10322
|
+
{ label: " ", onClick: () => handleKey(" "), className: "flex-[4]" },
|
|
10323
|
+
{ label: "Enter", onClick: onEnter, className: "flex-[2] bg-green-200 " }
|
|
10324
|
+
]
|
|
10251
10325
|
]
|
|
10252
|
-
|
|
10253
|
-
|
|
10254
|
-
|
|
10326
|
+
}
|
|
10327
|
+
)
|
|
10328
|
+
] });
|
|
10255
10329
|
}
|
|
10256
10330
|
const fila1 = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"].map((l) => letter(l, isUpper, handleKey));
|
|
10257
10331
|
const fila2 = ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"].map((l) => letter(l, isUpper, handleKey));
|
|
10258
10332
|
const fila3 = ["a", "s", "d", "f", "g", "h", "j", "k", "l"].map((l) => letter(l, isUpper, handleKey));
|
|
10259
10333
|
const fila4 = ["z", "x", "c", "v", "b", "n", "m"].map((l) => letter(l, isUpper, handleKey));
|
|
10260
10334
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full h-full flex flex-col", children: [
|
|
10261
|
-
|
|
10262
|
-
" ",
|
|
10263
|
-
currentInputField.field?.value,
|
|
10264
|
-
" "
|
|
10265
|
-
] }) }),
|
|
10335
|
+
textField,
|
|
10266
10336
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10267
10337
|
KeyboardBuilder,
|
|
10268
10338
|
{
|
|
@@ -10271,6 +10341,7 @@ var KeyboardQwerty = ({ onKeyPress, onEnter, keyFontSize: keyFontSize3 = "text-2
|
|
|
10271
10341
|
keys: [
|
|
10272
10342
|
[
|
|
10273
10343
|
{ label: "esc", onClick: () => {
|
|
10344
|
+
setIsOpen(false);
|
|
10274
10345
|
}, className: "bg-red-200" },
|
|
10275
10346
|
...fila1
|
|
10276
10347
|
],
|
|
@@ -13563,6 +13634,104 @@ var FieldFileMultiUpload = ({ input, form, isSubmitting }) => {
|
|
|
13563
13634
|
);
|
|
13564
13635
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: formField });
|
|
13565
13636
|
};
|
|
13637
|
+
var FakeInput = ({ input, field, form, isValid, isSubmitting }) => {
|
|
13638
|
+
const ref = React3.useRef(null);
|
|
13639
|
+
const {
|
|
13640
|
+
setCurrentInputField,
|
|
13641
|
+
write,
|
|
13642
|
+
backspace,
|
|
13643
|
+
setIsOpen,
|
|
13644
|
+
currentInputField
|
|
13645
|
+
} = useKeyboardStore();
|
|
13646
|
+
const [isFocused, setIsFocused] = React3.useState(false);
|
|
13647
|
+
const [showPassword, setShowPassword] = React3.useState(false);
|
|
13648
|
+
const isPasswordField = input.keyboardType === "password" /* PASSWORD */ || input.inputType == "password" /* PASSWORD */;
|
|
13649
|
+
input.zodType ? true : false;
|
|
13650
|
+
const value = input?.value ?? field?.value ?? "";
|
|
13651
|
+
const handleFocus = () => {
|
|
13652
|
+
setIsFocused(true);
|
|
13653
|
+
setCurrentInputField({
|
|
13654
|
+
input,
|
|
13655
|
+
field
|
|
13656
|
+
});
|
|
13657
|
+
};
|
|
13658
|
+
const handleBlur = () => {
|
|
13659
|
+
setIsFocused(false);
|
|
13660
|
+
};
|
|
13661
|
+
React3.useEffect(() => {
|
|
13662
|
+
if (!isFocused) return;
|
|
13663
|
+
const handleKeyDown = (e) => {
|
|
13664
|
+
e.preventDefault();
|
|
13665
|
+
if (e.key === "Backspace") {
|
|
13666
|
+
backspace?.();
|
|
13667
|
+
return;
|
|
13668
|
+
}
|
|
13669
|
+
if (e.key === "Enter") {
|
|
13670
|
+
return;
|
|
13671
|
+
}
|
|
13672
|
+
if (e.key === "Escape") {
|
|
13673
|
+
setIsOpen(false);
|
|
13674
|
+
return;
|
|
13675
|
+
}
|
|
13676
|
+
if (e.key.length === 1) {
|
|
13677
|
+
write(e.key);
|
|
13678
|
+
}
|
|
13679
|
+
};
|
|
13680
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
13681
|
+
return () => {
|
|
13682
|
+
window.removeEventListener("keydown", handleKeyDown);
|
|
13683
|
+
};
|
|
13684
|
+
}, [isFocused]);
|
|
13685
|
+
React3.useEffect(() => {
|
|
13686
|
+
if (!field) return;
|
|
13687
|
+
field.onChange(field.value);
|
|
13688
|
+
}, [currentInputField]);
|
|
13689
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
13690
|
+
"div",
|
|
13691
|
+
{
|
|
13692
|
+
ref,
|
|
13693
|
+
tabIndex: 0,
|
|
13694
|
+
onFocus: handleFocus,
|
|
13695
|
+
onBlur: handleBlur,
|
|
13696
|
+
onClick: () => ref.current?.focus(),
|
|
13697
|
+
className: `
|
|
13698
|
+
p-3 min-h-16 w-full flex justify-items-center justify-between flex-row
|
|
13699
|
+
text-2xl font-bold rounded-xl border-2
|
|
13700
|
+
outline-none transition-all
|
|
13701
|
+
${isFocused ? "border-blue-500 bg-blue-50" : "border-amber-400 bg-amber-50"}
|
|
13702
|
+
`,
|
|
13703
|
+
children: [
|
|
13704
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 text-left self-center", children: input && (isPasswordField && !showPassword) ? "\u2022".repeat(value.toString().length) : value || "" }),
|
|
13705
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row gap-2 self-center", children: [
|
|
13706
|
+
isPasswordField && /* @__PURE__ */ jsxRuntime.jsx(
|
|
13707
|
+
Button,
|
|
13708
|
+
{
|
|
13709
|
+
variant: "ghost",
|
|
13710
|
+
type: "button",
|
|
13711
|
+
onClick: () => setShowPassword(!showPassword),
|
|
13712
|
+
children: showPassword ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeOff, { size: 20 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { size: 20 })
|
|
13713
|
+
}
|
|
13714
|
+
),
|
|
13715
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13716
|
+
Button,
|
|
13717
|
+
{
|
|
13718
|
+
variant: "ghost",
|
|
13719
|
+
type: "button",
|
|
13720
|
+
className: "text-2xl",
|
|
13721
|
+
onClick: (e) => {
|
|
13722
|
+
e.stopPropagation();
|
|
13723
|
+
handleFocus();
|
|
13724
|
+
setCurrentInputField({ input, field });
|
|
13725
|
+
setIsOpen(true);
|
|
13726
|
+
},
|
|
13727
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Keyboard, { size: 20 })
|
|
13728
|
+
}
|
|
13729
|
+
)
|
|
13730
|
+
] })
|
|
13731
|
+
]
|
|
13732
|
+
}
|
|
13733
|
+
);
|
|
13734
|
+
};
|
|
13566
13735
|
var TextInputGroup = class extends BaseInput {
|
|
13567
13736
|
render() {
|
|
13568
13737
|
const { input, form, isSubmitting } = this;
|
|
@@ -13611,9 +13780,6 @@ var CustomInputGroup = ({
|
|
|
13611
13780
|
const groupConfig = input.inputGroupConfig;
|
|
13612
13781
|
const infoTooltip = input?.infoTooltip;
|
|
13613
13782
|
const autoValidate = groupConfig?.autoValidIcons ?? input.zodType ? true : false;
|
|
13614
|
-
const iconValidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleCheck, { style: { color: "#00bf3e" } });
|
|
13615
|
-
const iconInvalidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleX, { style: { color: "#ff8080" } });
|
|
13616
|
-
const iconLoadingState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin", style: { color: "#1e90ff" } });
|
|
13617
13783
|
const iconsRight = groupConfig?.iconsRight ?? [];
|
|
13618
13784
|
const iconsLeft = groupConfig?.iconsLeft ?? [];
|
|
13619
13785
|
const textLeft = groupConfig?.textLeft;
|
|
@@ -13681,6 +13847,16 @@ var CustomInputGroup = ({
|
|
|
13681
13847
|
return value2;
|
|
13682
13848
|
}
|
|
13683
13849
|
};
|
|
13850
|
+
if (input.isFakeInput) {
|
|
13851
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13852
|
+
FakeInput,
|
|
13853
|
+
{
|
|
13854
|
+
input,
|
|
13855
|
+
field,
|
|
13856
|
+
form
|
|
13857
|
+
}
|
|
13858
|
+
);
|
|
13859
|
+
}
|
|
13684
13860
|
return /* @__PURE__ */ jsxRuntime.jsxs(InputGroup, { className: input.classNameGroupInput ?? "h-10", children: [
|
|
13685
13861
|
(iconsLeft.length > 0 || textLeft) && /* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { children: [
|
|
13686
13862
|
textLeft && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textLeft }),
|
|
@@ -13751,8 +13927,7 @@ var CustomInputGroup = ({
|
|
|
13751
13927
|
},
|
|
13752
13928
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Keyboard, {})
|
|
13753
13929
|
}
|
|
13754
|
-
)
|
|
13755
|
-
autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid ? iconValidState : iconInvalidState })
|
|
13930
|
+
)
|
|
13756
13931
|
] })
|
|
13757
13932
|
] });
|
|
13758
13933
|
};
|