shadcn-zod-formkit 3.9.4 → 3.9.6

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 CHANGED
@@ -13009,6 +13009,10 @@ var KeyboardQwerty = ({ onKeyPress, onEnter, keyFontSize = "text-2xl", onDelete,
13009
13009
  const isUpper = shiftMode !== "off";
13010
13010
  React3.useEffect(() => {
13011
13011
  const handleKeyDown = (e) => {
13012
+ const active = document.activeElement;
13013
+ if (active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement || active instanceof HTMLElement && active.getAttribute("contenteditable") === "true") {
13014
+ return;
13015
+ }
13012
13016
  if (isInputRequired && !currentInputField) return;
13013
13017
  const key = e.key;
13014
13018
  if (key === "Enter") {
@@ -14222,13 +14226,15 @@ var TextInputGroup = class extends BaseInput {
14222
14226
  };
14223
14227
  var FieldTextGroup = ({ form, input, isSubmitting }) => {
14224
14228
  const [isValid, setIsValid] = React3.useState(isValidField(input, form));
14229
+ React3.useEffect(() => {
14230
+ setIsValid(isValidField(input, form));
14231
+ }, [form.formState]);
14225
14232
  const formField = /* @__PURE__ */ jsxRuntime.jsx(
14226
14233
  FormField,
14227
14234
  {
14228
14235
  control: form.control,
14229
14236
  name: input.name,
14230
14237
  render: ({ field }) => {
14231
- setIsValid(isValidField(input, form));
14232
14238
  return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: `${input.withLateralLabel ? "flex items-center gap-2 flex-row" : ""} ${input.className}`, children: [
14233
14239
  /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { className: `${input.withLateralLabel ? "text-right" : ""}`, children: /* @__PURE__ */ jsxRuntime.jsx("b", { children: input.label }) }),
14234
14240
  /* @__PURE__ */ jsxRuntime.jsx(FormControl, { className: `shadow-lg ${input.withLateralLabel ? " text-right" : ""}`, children: CustomInputGroup({
@@ -14319,6 +14325,8 @@ var CustomInputGroup = ({
14319
14325
  const inputGroupClass = input.isFakeInput ? fieldType : "";
14320
14326
  React3.useEffect(() => {
14321
14327
  if (!input.isFakeInput) return;
14328
+ field?.onChange(value);
14329
+ isValidField(input, form);
14322
14330
  handleOnChage(field?.value, input, field);
14323
14331
  }, [field?.value]);
14324
14332
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -14335,7 +14343,9 @@ var CustomInputGroup = ({
14335
14343
  placeholder: input.placeHolder,
14336
14344
  disabled: input.disabled || isSubmitting,
14337
14345
  onBlur: field?.onBlur,
14338
- onFocus: () => setCurrentInputField({ input, field }),
14346
+ onFocus: () => {
14347
+ if (withKeyboard) setCurrentInputField({ input, field });
14348
+ },
14339
14349
  name: field?.name,
14340
14350
  ref: field?.ref,
14341
14351
  type: fieldType,
@@ -14356,6 +14366,7 @@ var CustomInputGroup = ({
14356
14366
  value2 = applyTransform(processedValue, input.transform);
14357
14367
  }
14358
14368
  field?.onChange(value2);
14369
+ onChange?.({ target: { value: value2 } });
14359
14370
  isValidField(input, form);
14360
14371
  handleOnChage(value2, input, field);
14361
14372
  }
@@ -15260,29 +15271,25 @@ var FieldStringValueList = ({ form, input, isSubmitting }) => {
15260
15271
  const [isValid, setIsValid] = React3.useState(isValidField(input, form));
15261
15272
  React3.useEffect(() => {
15262
15273
  setIsValid(isValidField(input, form));
15263
- }, [input]);
15274
+ }, [form.formState]);
15264
15275
  React3.useEffect(() => {
15265
15276
  const current = form.getValues(fieldName);
15266
15277
  if (!Array.isArray(current)) {
15267
15278
  form.setValue(fieldName, []);
15268
15279
  }
15269
15280
  }, [form, fieldName]);
15270
- const handleAddItem = () => {
15281
+ const handleAddItem = React3.useCallback(() => {
15271
15282
  const current = form.getValues(fieldName) || [];
15272
- form.setValue(fieldName, [...current, ""]);
15273
- };
15274
- const handleRemoveItem = (index) => {
15283
+ form.setValue(fieldName, [...current, ""], { shouldDirty: true });
15284
+ }, [form, fieldName]);
15285
+ const handleRemoveItem = React3.useCallback((index) => {
15275
15286
  const current = form.getValues(fieldName) || [];
15276
- const updated = current.filter((_, i) => i !== index);
15277
- form.setValue(fieldName, updated);
15278
- };
15279
- const handleChange = (index, newValue) => {
15287
+ form.setValue(fieldName, current.filter((_, i) => i !== index), { shouldDirty: true });
15288
+ }, [form, fieldName]);
15289
+ const handleChange = React3.useCallback((index, newValue) => {
15280
15290
  const current = form.getValues(fieldName) || [];
15281
- const updated = current.map(
15282
- (item, i) => i === index ? newValue : item
15283
- );
15284
- form.setValue(fieldName, updated);
15285
- };
15291
+ form.setValue(fieldName, current.map((item, i) => i === index ? newValue : item), { shouldDirty: true });
15292
+ }, [form, fieldName]);
15286
15293
  return /* @__PURE__ */ jsxRuntime.jsx(
15287
15294
  FormField,
15288
15295
  {
@@ -15303,7 +15310,6 @@ var FieldStringValueList = ({ form, input, isSubmitting }) => {
15303
15310
  /* @__PURE__ */ jsxRuntime.jsx(
15304
15311
  CustomInputGroup,
15305
15312
  {
15306
- autoValidate: true,
15307
15313
  value,
15308
15314
  input,
15309
15315
  isValid,
@@ -15324,7 +15330,7 @@ var FieldStringValueList = ({ form, input, isSubmitting }) => {
15324
15330
  )
15325
15331
  ]
15326
15332
  },
15327
- index
15333
+ `${fieldName}_${index}`
15328
15334
  )),
15329
15335
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end mt-2", children: withAddBtn && /* @__PURE__ */ jsxRuntime.jsx(
15330
15336
  Button,
@@ -17433,7 +17439,7 @@ var DynamicForm = ({
17433
17439
  {
17434
17440
  type: btn.btnType,
17435
17441
  size: "lg",
17436
- className: submitBtnClass,
17442
+ className: submitBtnClass ?? btn.className,
17437
17443
  variant: btn.variant,
17438
17444
  onClick: btn.onClick,
17439
17445
  disabled: btn.disabled,