shadcn-zod-formkit 3.6.0 → 3.7.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 +80 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +80 -27
- package/dist/index.mjs.map +1 -1
- package/dist/shadcn-zod-formkit-3.7.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
|
@@ -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: {
|
|
@@ -10155,7 +10154,6 @@ var useKeyboardStore = zustand.create((set, get) => ({
|
|
|
10155
10154
|
if (currentInputField && currentInputField.field) {
|
|
10156
10155
|
currentInputField.field.value += char;
|
|
10157
10156
|
set({ currentInputField });
|
|
10158
|
-
console.log("Updated currentInputField value:", state.currentInputField?.field?.value);
|
|
10159
10157
|
}
|
|
10160
10158
|
if (!state.activeInput) return state;
|
|
10161
10159
|
const current = state.inputs[state.activeInput] || "";
|
|
@@ -10167,8 +10165,14 @@ var useKeyboardStore = zustand.create((set, get) => ({
|
|
|
10167
10165
|
};
|
|
10168
10166
|
}),
|
|
10169
10167
|
backspace: () => set((state) => {
|
|
10168
|
+
let currentInputField = state.currentInputField;
|
|
10169
|
+
if (currentInputField && currentInputField.field) {
|
|
10170
|
+
currentInputField.field.value = currentInputField.field.value.slice(0, -1);
|
|
10171
|
+
set({ currentInputField });
|
|
10172
|
+
}
|
|
10170
10173
|
if (!state.activeInput) return state;
|
|
10171
10174
|
const current = state.inputs[state.activeInput] || "";
|
|
10175
|
+
console.log("RUN BACKSPACE - current value:", current);
|
|
10172
10176
|
return {
|
|
10173
10177
|
inputs: {
|
|
10174
10178
|
...state.inputs,
|
|
@@ -10201,8 +10205,54 @@ var KeyboardQwerty = ({ onKeyPress, onEnter, keyFontSize: keyFontSize3 = "text-2
|
|
|
10201
10205
|
const [shiftMode, setShiftMode] = React3.useState("off");
|
|
10202
10206
|
const [mode, setMode] = React3.useState("letters");
|
|
10203
10207
|
const lastShiftPress = React3.useRef(0);
|
|
10204
|
-
const { currentInputField, write } = useKeyboardStore();
|
|
10208
|
+
const { currentInputField, write, setIsOpen, backspace } = useKeyboardStore();
|
|
10205
10209
|
const isUpper = shiftMode !== "off";
|
|
10210
|
+
React3.useEffect(() => {
|
|
10211
|
+
const handleKeyDown = (e) => {
|
|
10212
|
+
if (!currentInputField) return;
|
|
10213
|
+
const key = e.key;
|
|
10214
|
+
if (key === "Enter") {
|
|
10215
|
+
e.preventDefault();
|
|
10216
|
+
onEnter?.();
|
|
10217
|
+
return;
|
|
10218
|
+
}
|
|
10219
|
+
console.log("\u{1F680} ~ handleKeyDown ~ key:", key);
|
|
10220
|
+
if (key === "Backspace") {
|
|
10221
|
+
backspace();
|
|
10222
|
+
e.preventDefault();
|
|
10223
|
+
onDelete?.();
|
|
10224
|
+
return;
|
|
10225
|
+
}
|
|
10226
|
+
if (key === " ") {
|
|
10227
|
+
e.preventDefault();
|
|
10228
|
+
handleKey(" ");
|
|
10229
|
+
return;
|
|
10230
|
+
}
|
|
10231
|
+
if (key === "Shift") {
|
|
10232
|
+
handleShift();
|
|
10233
|
+
return;
|
|
10234
|
+
}
|
|
10235
|
+
if (key === "CapsLock") {
|
|
10236
|
+
handleCaps();
|
|
10237
|
+
return;
|
|
10238
|
+
}
|
|
10239
|
+
if (key === "Tab") {
|
|
10240
|
+
e.preventDefault();
|
|
10241
|
+
return;
|
|
10242
|
+
}
|
|
10243
|
+
if (key === "Escape") {
|
|
10244
|
+
setIsOpen(false);
|
|
10245
|
+
return;
|
|
10246
|
+
}
|
|
10247
|
+
if (key.length === 1) {
|
|
10248
|
+
handleKey(key);
|
|
10249
|
+
}
|
|
10250
|
+
};
|
|
10251
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
10252
|
+
return () => {
|
|
10253
|
+
window.removeEventListener("keydown", handleKeyDown);
|
|
10254
|
+
};
|
|
10255
|
+
}, [currentInputField, shiftMode]);
|
|
10206
10256
|
const handleShift = () => {
|
|
10207
10257
|
const now = Date.now();
|
|
10208
10258
|
if (now - lastShiftPress.current < 300) {
|
|
@@ -10217,15 +10267,18 @@ var KeyboardQwerty = ({ onKeyPress, onEnter, keyFontSize: keyFontSize3 = "text-2
|
|
|
10217
10267
|
const output = isUpper ? key.toUpperCase() : key;
|
|
10218
10268
|
onKeyPress?.(output);
|
|
10219
10269
|
write(output);
|
|
10220
|
-
if (shiftMode === "once")
|
|
10221
|
-
setShiftMode("off");
|
|
10222
|
-
}
|
|
10270
|
+
if (shiftMode === "once") setShiftMode("off");
|
|
10223
10271
|
};
|
|
10224
10272
|
const handleCaps = () => {
|
|
10225
10273
|
setShiftMode((prev) => prev === "caps" ? "off" : "caps");
|
|
10226
10274
|
};
|
|
10227
10275
|
const shiftLabel = shiftMode === "caps" ? lucideReact.ArrowBigUpDash : lucideReact.ArrowBigUp;
|
|
10228
10276
|
const shiftActive = shiftMode !== "off";
|
|
10277
|
+
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: [
|
|
10278
|
+
" ",
|
|
10279
|
+
currentInputField.field?.value,
|
|
10280
|
+
" "
|
|
10281
|
+
] }) }) });
|
|
10229
10282
|
if (mode === "symbols") {
|
|
10230
10283
|
const keys = [
|
|
10231
10284
|
["!", "@", "#", "$", "%", "^", "&", "*", "(", ")"],
|
|
@@ -10237,32 +10290,31 @@ var KeyboardQwerty = ({ onKeyPress, onEnter, keyFontSize: keyFontSize3 = "text-2
|
|
|
10237
10290
|
onClick: () => handleKey(k)
|
|
10238
10291
|
}))
|
|
10239
10292
|
);
|
|
10240
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
10241
|
-
|
|
10242
|
-
|
|
10243
|
-
|
|
10244
|
-
|
|
10245
|
-
|
|
10246
|
-
|
|
10247
|
-
[
|
|
10248
|
-
|
|
10249
|
-
|
|
10250
|
-
|
|
10293
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full h-full flex flex-col", children: [
|
|
10294
|
+
textField,
|
|
10295
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10296
|
+
KeyboardBuilder,
|
|
10297
|
+
{
|
|
10298
|
+
className: "w-full h-full",
|
|
10299
|
+
keyFontSize: keyFontSize3,
|
|
10300
|
+
keys: [
|
|
10301
|
+
...keys,
|
|
10302
|
+
[
|
|
10303
|
+
{ label: "ABC", onClick: () => setMode("letters"), className: "flex-[2]" },
|
|
10304
|
+
{ label: " ", onClick: () => handleKey(" "), className: "flex-[4]" },
|
|
10305
|
+
{ label: "Enter", onClick: onEnter, className: "flex-[2] bg-green-200 " }
|
|
10306
|
+
]
|
|
10251
10307
|
]
|
|
10252
|
-
|
|
10253
|
-
|
|
10254
|
-
|
|
10308
|
+
}
|
|
10309
|
+
)
|
|
10310
|
+
] });
|
|
10255
10311
|
}
|
|
10256
10312
|
const fila1 = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"].map((l) => letter(l, isUpper, handleKey));
|
|
10257
10313
|
const fila2 = ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"].map((l) => letter(l, isUpper, handleKey));
|
|
10258
10314
|
const fila3 = ["a", "s", "d", "f", "g", "h", "j", "k", "l"].map((l) => letter(l, isUpper, handleKey));
|
|
10259
10315
|
const fila4 = ["z", "x", "c", "v", "b", "n", "m"].map((l) => letter(l, isUpper, handleKey));
|
|
10260
10316
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full h-full flex flex-col", children: [
|
|
10261
|
-
|
|
10262
|
-
" ",
|
|
10263
|
-
currentInputField.field?.value,
|
|
10264
|
-
" "
|
|
10265
|
-
] }) }),
|
|
10317
|
+
textField,
|
|
10266
10318
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
10267
10319
|
KeyboardBuilder,
|
|
10268
10320
|
{
|
|
@@ -10271,6 +10323,7 @@ var KeyboardQwerty = ({ onKeyPress, onEnter, keyFontSize: keyFontSize3 = "text-2
|
|
|
10271
10323
|
keys: [
|
|
10272
10324
|
[
|
|
10273
10325
|
{ label: "esc", onClick: () => {
|
|
10326
|
+
setIsOpen(false);
|
|
10274
10327
|
}, className: "bg-red-200" },
|
|
10275
10328
|
...fila1
|
|
10276
10329
|
],
|