shadcn-zod-formkit 3.7.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 +133 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +133 -11
- 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.7.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;
|
|
@@ -10149,11 +10149,29 @@ var useKeyboardStore = zustand.create((set, get) => ({
|
|
|
10149
10149
|
return { inputs: newInputs };
|
|
10150
10150
|
}),
|
|
10151
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
|
+
// }),
|
|
10152
10168
|
write: (char) => set((state) => {
|
|
10153
10169
|
let currentInputField = state.currentInputField;
|
|
10154
10170
|
if (currentInputField && currentInputField.field) {
|
|
10155
10171
|
currentInputField.field.value += char;
|
|
10172
|
+
const newValue = currentInputField.field.value;
|
|
10156
10173
|
set({ currentInputField });
|
|
10174
|
+
currentInputField.field.onChange(newValue);
|
|
10157
10175
|
}
|
|
10158
10176
|
if (!state.activeInput) return state;
|
|
10159
10177
|
const current = state.inputs[state.activeInput] || "";
|
|
@@ -10167,8 +10185,10 @@ var useKeyboardStore = zustand.create((set, get) => ({
|
|
|
10167
10185
|
backspace: () => set((state) => {
|
|
10168
10186
|
let currentInputField = state.currentInputField;
|
|
10169
10187
|
if (currentInputField && currentInputField.field) {
|
|
10170
|
-
|
|
10188
|
+
const newValue = currentInputField.field.value.slice(0, -1);
|
|
10189
|
+
currentInputField.field.value = newValue;
|
|
10171
10190
|
set({ currentInputField });
|
|
10191
|
+
currentInputField.field.onChange(newValue);
|
|
10172
10192
|
}
|
|
10173
10193
|
if (!state.activeInput) return state;
|
|
10174
10194
|
const current = state.inputs[state.activeInput] || "";
|
|
@@ -10216,7 +10236,6 @@ var KeyboardQwerty = ({ onKeyPress, onEnter, keyFontSize: keyFontSize3 = "text-2
|
|
|
10216
10236
|
onEnter?.();
|
|
10217
10237
|
return;
|
|
10218
10238
|
}
|
|
10219
|
-
console.log("\u{1F680} ~ handleKeyDown ~ key:", key);
|
|
10220
10239
|
if (key === "Backspace") {
|
|
10221
10240
|
backspace();
|
|
10222
10241
|
e.preventDefault();
|
|
@@ -10263,7 +10282,6 @@ var KeyboardQwerty = ({ onKeyPress, onEnter, keyFontSize: keyFontSize3 = "text-2
|
|
|
10263
10282
|
lastShiftPress.current = now;
|
|
10264
10283
|
};
|
|
10265
10284
|
const handleKey = (key) => {
|
|
10266
|
-
console.log("Key pressed:", key);
|
|
10267
10285
|
const output = isUpper ? key.toUpperCase() : key;
|
|
10268
10286
|
onKeyPress?.(output);
|
|
10269
10287
|
write(output);
|
|
@@ -13616,6 +13634,104 @@ var FieldFileMultiUpload = ({ input, form, isSubmitting }) => {
|
|
|
13616
13634
|
);
|
|
13617
13635
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: formField });
|
|
13618
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
|
+
};
|
|
13619
13735
|
var TextInputGroup = class extends BaseInput {
|
|
13620
13736
|
render() {
|
|
13621
13737
|
const { input, form, isSubmitting } = this;
|
|
@@ -13664,9 +13780,6 @@ var CustomInputGroup = ({
|
|
|
13664
13780
|
const groupConfig = input.inputGroupConfig;
|
|
13665
13781
|
const infoTooltip = input?.infoTooltip;
|
|
13666
13782
|
const autoValidate = groupConfig?.autoValidIcons ?? input.zodType ? true : false;
|
|
13667
|
-
const iconValidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleCheck, { style: { color: "#00bf3e" } });
|
|
13668
|
-
const iconInvalidState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleX, { style: { color: "#ff8080" } });
|
|
13669
|
-
const iconLoadingState = /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "animate-spin", style: { color: "#1e90ff" } });
|
|
13670
13783
|
const iconsRight = groupConfig?.iconsRight ?? [];
|
|
13671
13784
|
const iconsLeft = groupConfig?.iconsLeft ?? [];
|
|
13672
13785
|
const textLeft = groupConfig?.textLeft;
|
|
@@ -13734,6 +13847,16 @@ var CustomInputGroup = ({
|
|
|
13734
13847
|
return value2;
|
|
13735
13848
|
}
|
|
13736
13849
|
};
|
|
13850
|
+
if (input.isFakeInput) {
|
|
13851
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13852
|
+
FakeInput,
|
|
13853
|
+
{
|
|
13854
|
+
input,
|
|
13855
|
+
field,
|
|
13856
|
+
form
|
|
13857
|
+
}
|
|
13858
|
+
);
|
|
13859
|
+
}
|
|
13737
13860
|
return /* @__PURE__ */ jsxRuntime.jsxs(InputGroup, { className: input.classNameGroupInput ?? "h-10", children: [
|
|
13738
13861
|
(iconsLeft.length > 0 || textLeft) && /* @__PURE__ */ jsxRuntime.jsxs(InputGroupAddon, { children: [
|
|
13739
13862
|
textLeft && /* @__PURE__ */ jsxRuntime.jsx(InputGroupText, { children: textLeft }),
|
|
@@ -13804,8 +13927,7 @@ var CustomInputGroup = ({
|
|
|
13804
13927
|
},
|
|
13805
13928
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Keyboard, {})
|
|
13806
13929
|
}
|
|
13807
|
-
)
|
|
13808
|
-
autoValidate && /* @__PURE__ */ jsxRuntime.jsx("div", { children: isSubmitting ? iconLoadingState : isValid ? iconValidState : iconInvalidState })
|
|
13930
|
+
)
|
|
13809
13931
|
] })
|
|
13810
13932
|
] });
|
|
13811
13933
|
};
|