@algodomain/smart-forms 0.1.10 → 0.1.12

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
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkDRMVY7TX_cjs = require('./chunk-DRMVY7TX.cjs');
4
- var chunkWUYS7DMR_cjs = require('./chunk-WUYS7DMR.cjs');
3
+ var chunkTX7JD2XS_cjs = require('./chunk-TX7JD2XS.cjs');
4
+ var chunkAEN4A4ST_cjs = require('./chunk-AEN4A4ST.cjs');
5
5
  var React3 = require('react');
6
6
  var reactToastify = require('react-toastify');
7
7
  var jsxRuntime = require('react/jsx-runtime');
@@ -119,7 +119,7 @@ var BaseSmartForm = ({
119
119
  queryParamsToInclude,
120
120
  submitDisabled
121
121
  };
122
- return /* @__PURE__ */ jsxRuntime.jsx(chunkWUYS7DMR_cjs.SmartFormProvider, { config, initialData, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
122
+ return /* @__PURE__ */ jsxRuntime.jsx(chunkAEN4A4ST_cjs.SmartFormProvider, { config, initialData, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
123
123
  /* @__PURE__ */ jsxRuntime.jsx(ToastContainerWrapper, {}),
124
124
  /* @__PURE__ */ jsxRuntime.jsx(FormHeader, { title, subTitle, logo }),
125
125
  children,
@@ -127,15 +127,15 @@ var BaseSmartForm = ({
127
127
  ] }) });
128
128
  };
129
129
  var LoadingSpinner = ({ className = "h-4 w-4" }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: `animate-spin rounded-full border-b-2 border-current ${className}` });
130
- var SubmitButton = ({ onClick, disabled, isLoading, children, className }) => /* @__PURE__ */ jsxRuntime.jsx(chunkDRMVY7TX_cjs.Button, { onClick, disabled, className, children: isLoading ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
130
+ var SubmitButton = ({ onClick, disabled, isLoading, children, className }) => /* @__PURE__ */ jsxRuntime.jsx(chunkTX7JD2XS_cjs.Button, { onClick, disabled, className, children: isLoading ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
131
131
  /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner, {}),
132
132
  "Submitting..."
133
133
  ] }) : children });
134
- var DraftSaveButton = ({ onClick, disabled }) => /* @__PURE__ */ jsxRuntime.jsx(chunkDRMVY7TX_cjs.Button, { onClick, disabled, variant: "secondary", children: disabled ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
134
+ var DraftSaveButton = ({ onClick, disabled }) => /* @__PURE__ */ jsxRuntime.jsx(chunkTX7JD2XS_cjs.Button, { onClick, disabled, variant: "secondary", children: disabled ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
135
135
  /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner, {}),
136
136
  "Saving..."
137
137
  ] }) : "Save Draft" });
138
- var ResetButton = ({ onClick }) => /* @__PURE__ */ jsxRuntime.jsx(chunkDRMVY7TX_cjs.Button, { onClick, variant: "secondary", children: "Reset Form" });
138
+ var ResetButton = ({ onClick }) => /* @__PURE__ */ jsxRuntime.jsx(chunkTX7JD2XS_cjs.Button, { onClick, variant: "secondary", children: "Reset Form" });
139
139
  var NavigationButtons = ({
140
140
  onPrevious,
141
141
  onNext,
@@ -149,7 +149,7 @@ var NavigationButtons = ({
149
149
  isLastTab = false,
150
150
  disabled = false
151
151
  }) => {
152
- const { formData, config: formConfig } = chunkWUYS7DMR_cjs.useSmartForm();
152
+ const { formData, config: formConfig } = chunkAEN4A4ST_cjs.useSmartForm();
153
153
  const isSubmitDisabled = typeof formConfig.submitDisabled === "function" ? formConfig.submitDisabled(formData) : formConfig.submitDisabled || false;
154
154
  const hasResetButton = !!onReset;
155
155
  const hasDraftButton = config.allowSaveDraft && !!onSaveDraft;
@@ -159,7 +159,7 @@ var NavigationButtons = ({
159
159
  const isSingleButton = rightSectionButtons === 1 && !hasPreviousButton;
160
160
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between items-center mt-8 pt-6 border-t border-gray-200", children: [
161
161
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-4", children: onPrevious && /* @__PURE__ */ jsxRuntime.jsxs(
162
- chunkDRMVY7TX_cjs.Button,
162
+ chunkTX7JD2XS_cjs.Button,
163
163
  {
164
164
  onClick: onPrevious,
165
165
  disabled: isFirstTab || disabled,
@@ -171,7 +171,7 @@ var NavigationButtons = ({
171
171
  }
172
172
  ) }),
173
173
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: isSingleButton ? "w-full" : "flex gap-4", children: [
174
- onReset && /* @__PURE__ */ jsxRuntime.jsx(chunkDRMVY7TX_cjs.Button, { onClick: onReset, disabled, variant: "secondary", children: "Reset Form" }),
174
+ onReset && /* @__PURE__ */ jsxRuntime.jsx(chunkTX7JD2XS_cjs.Button, { onClick: onReset, disabled, variant: "secondary", children: "Reset Form" }),
175
175
  config.allowSaveDraft && onSaveDraft && /* @__PURE__ */ jsxRuntime.jsx(DraftSaveButton, { onClick: onSaveDraft, disabled: isDraftSaving || disabled }),
176
176
  isLastTab ? /* @__PURE__ */ jsxRuntime.jsxs(
177
177
  SubmitButton,
@@ -186,7 +186,7 @@ var NavigationButtons = ({
186
186
  ]
187
187
  }
188
188
  ) : onNext && /* @__PURE__ */ jsxRuntime.jsxs(
189
- chunkDRMVY7TX_cjs.Button,
189
+ chunkTX7JD2XS_cjs.Button,
190
190
  {
191
191
  onClick: onNext,
192
192
  disabled,
@@ -208,7 +208,7 @@ var SimpleFormButtons = ({
208
208
  isDraftSaving,
209
209
  config
210
210
  }) => {
211
- const { formData, config: formConfig } = chunkWUYS7DMR_cjs.useSmartForm();
211
+ const { formData, config: formConfig } = chunkAEN4A4ST_cjs.useSmartForm();
212
212
  const isSubmitDisabled = typeof formConfig.submitDisabled === "function" ? formConfig.submitDisabled(formData) : formConfig.submitDisabled || false;
213
213
  const hasResetButton = !!onReset;
214
214
  const hasDraftButton = config.allowSaveDraft && !!onSaveDraft;
@@ -234,7 +234,7 @@ var SimpleFormButtons = ({
234
234
  ] }) });
235
235
  };
236
236
  var SubmitButton2 = () => {
237
- const { isLoading, isDraftSaving, submitForm, saveDraft, resetForm, config } = chunkWUYS7DMR_cjs.useSmartForm();
237
+ const { isLoading, isDraftSaving, submitForm, saveDraft, resetForm, config } = chunkAEN4A4ST_cjs.useSmartForm();
238
238
  const shouldShowReset = config.showReset || config.enableLocalStorage;
239
239
  return /* @__PURE__ */ jsxRuntime.jsx(
240
240
  SimpleFormButtons,
@@ -354,7 +354,7 @@ function MotionHighlight({ ref, ...props }) {
354
354
  {
355
355
  ref: localRef,
356
356
  "data-slot": "motion-highlight-container",
357
- className: chunkWUYS7DMR_cjs.cn("relative", props?.containerClassName),
357
+ className: chunkAEN4A4ST_cjs.cn("relative", props?.containerClassName),
358
358
  children: [
359
359
  /* @__PURE__ */ jsxRuntime.jsx(react.AnimatePresence, { initial: false, children: boundsState && /* @__PURE__ */ jsxRuntime.jsx(
360
360
  react.motion.div,
@@ -382,7 +382,7 @@ function MotionHighlight({ ref, ...props }) {
382
382
  }
383
383
  },
384
384
  transition,
385
- className: chunkWUYS7DMR_cjs.cn("bg-muted absolute z-0", className, activeClassNameState)
385
+ className: chunkAEN4A4ST_cjs.cn("bg-muted absolute z-0", className, activeClassNameState)
386
386
  }
387
387
  ) }),
388
388
  children2
@@ -530,7 +530,7 @@ function MotionHighlightItem({
530
530
  {
531
531
  key: childValue,
532
532
  ref: localRef,
533
- className: chunkWUYS7DMR_cjs.cn("relative", element.props.className),
533
+ className: chunkAEN4A4ST_cjs.cn("relative", element.props.className),
534
534
  ...getNonOverridingDataAttributes(element, {
535
535
  ...dataAttributes,
536
536
  "data-slot": "motion-highlight-item-container"
@@ -544,7 +544,7 @@ function MotionHighlightItem({
544
544
  {
545
545
  layoutId: `transition-background-${contextId}`,
546
546
  "data-slot": "motion-highlight",
547
- className: chunkWUYS7DMR_cjs.cn("bg-muted absolute inset-0 z-0", contextClassName, activeClassName),
547
+ className: chunkAEN4A4ST_cjs.cn("bg-muted absolute inset-0 z-0", contextClassName, activeClassName),
548
548
  transition: itemTransition,
549
549
  initial: { opacity: 0 },
550
550
  animate: { opacity: 1 },
@@ -558,7 +558,7 @@ function MotionHighlightItem({
558
558
  ...dataAttributes
559
559
  }
560
560
  ) }),
561
- /* @__PURE__ */ jsxRuntime.jsx("div", { "data-slot": "motion-highlight-item", className: chunkWUYS7DMR_cjs.cn("relative z-[1]", className), ...dataAttributes, children })
561
+ /* @__PURE__ */ jsxRuntime.jsx("div", { "data-slot": "motion-highlight-item", className: chunkAEN4A4ST_cjs.cn("relative z-[1]", className), ...dataAttributes, children })
562
562
  ] })
563
563
  );
564
564
  }
@@ -576,7 +576,7 @@ function MotionHighlightItem({
576
576
  {
577
577
  ref: localRef,
578
578
  "data-slot": "motion-highlight-item-container",
579
- className: chunkWUYS7DMR_cjs.cn(mode === "children" && "relative", className),
579
+ className: chunkAEN4A4ST_cjs.cn(mode === "children" && "relative", className),
580
580
  ...dataAttributes,
581
581
  ...props,
582
582
  ...commonHandlers,
@@ -586,7 +586,7 @@ function MotionHighlightItem({
586
586
  {
587
587
  layoutId: `transition-background-${contextId}`,
588
588
  "data-slot": "motion-highlight",
589
- className: chunkWUYS7DMR_cjs.cn("bg-muted absolute inset-0 z-0", contextClassName, activeClassName),
589
+ className: chunkAEN4A4ST_cjs.cn("bg-muted absolute inset-0 z-0", contextClassName, activeClassName),
590
590
  transition: itemTransition,
591
591
  initial: { opacity: 0 },
592
592
  animate: { opacity: 1 },
@@ -601,7 +601,7 @@ function MotionHighlightItem({
601
601
  }
602
602
  ) }),
603
603
  React3__namespace.cloneElement(element, {
604
- className: chunkWUYS7DMR_cjs.cn("relative z-[1]", element.props.className),
604
+ className: chunkAEN4A4ST_cjs.cn("relative z-[1]", element.props.className),
605
605
  ...getNonOverridingDataAttributes(element, {
606
606
  ...dataAttributes,
607
607
  "data-slot": "motion-highlight-item"
@@ -660,6 +660,7 @@ function Tabs({
660
660
  if (!isControlled) setActiveValue(val);
661
661
  else props.onValueChange?.(val);
662
662
  };
663
+ const { onValueChange, ...divProps } = props;
663
664
  return /* @__PURE__ */ jsxRuntime.jsx(TabsConfigContext.Provider, { value: config, children: /* @__PURE__ */ jsxRuntime.jsx(
664
665
  TabsContext.Provider,
665
666
  {
@@ -668,7 +669,7 @@ function Tabs({
668
669
  handleValueChange,
669
670
  registerTrigger
670
671
  },
671
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { "data-slot": "tabs", className: chunkWUYS7DMR_cjs.cn("flex flex-col gap-2", className), ...props, children: props.children })
672
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { "data-slot": "tabs", className: chunkAEN4A4ST_cjs.cn("flex flex-col gap-2", className), ...divProps, children: props.children })
672
673
  }
673
674
  ) });
674
675
  }
@@ -676,7 +677,7 @@ function Tabs({
676
677
  TabsPrimitive__namespace.Root,
677
678
  {
678
679
  "data-slot": "tabs",
679
- className: chunkWUYS7DMR_cjs.cn("flex flex-col gap-2", className),
680
+ className: chunkAEN4A4ST_cjs.cn("flex flex-col gap-2", className),
680
681
  ...props
681
682
  }
682
683
  ) });
@@ -698,7 +699,7 @@ function TabsList({
698
699
  MotionHighlight,
699
700
  {
700
701
  controlledItems: true,
701
- className: chunkWUYS7DMR_cjs.cn("bg-background rounded-sm shadow-sm", activeClassName),
702
+ className: chunkAEN4A4ST_cjs.cn("bg-background rounded-sm shadow-sm", activeClassName),
702
703
  value: activeValue,
703
704
  transition,
704
705
  children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -706,7 +707,7 @@ function TabsList({
706
707
  {
707
708
  role: "tablist",
708
709
  "data-slot": "tabs-list",
709
- className: chunkWUYS7DMR_cjs.cn(
710
+ className: chunkAEN4A4ST_cjs.cn(
710
711
  "bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",
711
712
  className
712
713
  ),
@@ -730,7 +731,7 @@ function TabsList({
730
731
  TabsPrimitive__namespace.List,
731
732
  {
732
733
  "data-slot": "tabs-list",
733
- className: chunkWUYS7DMR_cjs.cn(
734
+ className: chunkAEN4A4ST_cjs.cn(
734
735
  "bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",
735
736
  className
736
737
  ),
@@ -816,7 +817,7 @@ function UnderlineTabsList({
816
817
  TabsPrimitive__namespace.List,
817
818
  {
818
819
  "data-slot": "tabs-list",
819
- className: chunkWUYS7DMR_cjs.cn(
820
+ className: chunkAEN4A4ST_cjs.cn(
820
821
  "bg-background relative rounded-none border-b p-0",
821
822
  className
822
823
  ),
@@ -891,7 +892,7 @@ function TabsTrigger({
891
892
  onClick: () => !disabled && handleValueChange(props.value),
892
893
  "data-state": activeValue === props.value ? "active" : "inactive",
893
894
  disabled,
894
- className: chunkWUYS7DMR_cjs.cn(
895
+ className: chunkAEN4A4ST_cjs.cn(
895
896
  "ring-offset-background focus-visible:ring-ring data-[state=active]:text-foreground z-10 inline-flex size-full cursor-pointer items-center justify-center rounded-sm px-2 py-1 text-sm font-medium whitespace-nowrap transition-transform focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50",
896
897
  className
897
898
  ),
@@ -924,7 +925,7 @@ function TabsTrigger({
924
925
  {
925
926
  ref: localRef,
926
927
  "data-slot": "tabs-trigger",
927
- className: chunkWUYS7DMR_cjs.cn(
928
+ className: chunkAEN4A4ST_cjs.cn(
928
929
  "bg-background dark:data-[state=active]:bg-background relative z-10 pl-10 pr-10 rounded-none border-0 data-[state=active]:shadow-none cursor-pointer",
929
930
  className
930
931
  ),
@@ -936,7 +937,7 @@ function TabsTrigger({
936
937
  TabsPrimitive__namespace.Trigger,
937
938
  {
938
939
  "data-slot": "tabs-trigger",
939
- className: chunkWUYS7DMR_cjs.cn(
940
+ className: chunkAEN4A4ST_cjs.cn(
940
941
  "data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
941
942
  className
942
943
  ),
@@ -983,7 +984,7 @@ function TabsContent({
983
984
  {
984
985
  role: "tabpanel",
985
986
  "data-slot": "tabs-content",
986
- className: chunkWUYS7DMR_cjs.cn("overflow-hidden", className),
987
+ className: chunkAEN4A4ST_cjs.cn("overflow-hidden", className),
987
988
  initial: { filter: "blur(0px)" },
988
989
  animate: { filter: isActive ? "blur(0px)" : "blur(2px)" },
989
990
  exit: { filter: "blur(0px)" },
@@ -1005,7 +1006,7 @@ function TabsContent({
1005
1006
  TabsPrimitive__namespace.Content,
1006
1007
  {
1007
1008
  "data-slot": "tabs-content",
1008
- className: chunkWUYS7DMR_cjs.cn("flex-1 outline-none", className),
1009
+ className: chunkAEN4A4ST_cjs.cn("flex-1 outline-none", className),
1009
1010
  ...props
1010
1011
  }
1011
1012
  );
@@ -1233,7 +1234,7 @@ var MultiTabFormContent = ({
1233
1234
  maxUnlockedTab,
1234
1235
  setMaxUnlockedTab
1235
1236
  }) => {
1236
- const { isLoading, isDraftSaving, submitForm, saveDraft, resetForm, validateFields, formData, validationRegistry, setErrors } = chunkWUYS7DMR_cjs.useSmartForm();
1237
+ const { isLoading, isDraftSaving, submitForm, saveDraft, resetForm, validateFields, formData, validationRegistry, setErrors, getValidationErrorMessage } = chunkAEN4A4ST_cjs.useSmartForm();
1237
1238
  const debounce = (func, wait) => {
1238
1239
  let timeout;
1239
1240
  return function executedFunction(...args) {
@@ -1312,7 +1313,8 @@ var MultiTabFormContent = ({
1312
1313
  validation.parse(formData[field]);
1313
1314
  } catch (error) {
1314
1315
  if (error instanceof zod.z.ZodError) {
1315
- allErrors[field] = error.issues[0]?.message || `Invalid ${field}`;
1316
+ const msg = error.issues[0]?.message ?? "";
1317
+ allErrors[field] = getValidationErrorMessage(field, msg);
1316
1318
  isValid = false;
1317
1319
  }
1318
1320
  }
@@ -1390,7 +1392,7 @@ var MultiTabFormContent = ({
1390
1392
  onNext();
1391
1393
  }
1392
1394
  }
1393
- }, [activeTab, getCombinedTabFields, validateFields, onNext, setCompletedTabs, setValidationErrorTabs, validationRegistry, formData, tabCallbacks, setProcessingTab, setProcessingError, setMaxUnlockedTab]);
1395
+ }, [activeTab, getCombinedTabFields, validateFields, onNext, setCompletedTabs, setValidationErrorTabs, validationRegistry, formData, tabCallbacks, setProcessingTab, setProcessingError, setMaxUnlockedTab, getValidationErrorMessage]);
1394
1396
  const handleSubmitWithValidation = React3.useCallback(async () => {
1395
1397
  const allErrors = {};
1396
1398
  let isValid = true;
@@ -1401,7 +1403,8 @@ var MultiTabFormContent = ({
1401
1403
  validation.parse(formData[field]);
1402
1404
  } catch (error) {
1403
1405
  if (error instanceof zod.z.ZodError) {
1404
- allErrors[field] = error.issues[0]?.message || `Invalid ${field}`;
1406
+ const msg = error.issues[0]?.message ?? "";
1407
+ allErrors[field] = getValidationErrorMessage(field, msg);
1405
1408
  isValid = false;
1406
1409
  }
1407
1410
  }
@@ -1437,7 +1440,7 @@ var MultiTabFormContent = ({
1437
1440
  }, 100);
1438
1441
  }
1439
1442
  }
1440
- }, [submitForm, getCombinedTabFields, onTabChange, tabs.length, validationRegistry, formData, setErrors, setValidationErrorTabs]);
1443
+ }, [submitForm, getCombinedTabFields, onTabChange, tabs.length, validationRegistry, formData, setErrors, setValidationErrorTabs, getValidationErrorMessage]);
1441
1444
  const activeTabValue = tabs[activeTab] || tabs[0] || "";
1442
1445
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1443
1446
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1482,14 +1485,7 @@ var MultiTabFormContent = ({
1482
1485
  const hasProcessingOverlay = tabCallbacks[index]?.processingOverlay;
1483
1486
  return /* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: tabProps.title, children: /* @__PURE__ */ jsxRuntime.jsx(TabIndexProvider, { tabIndex: index, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6 relative", children: [
1484
1487
  tabProps.children,
1485
- isCurrentlyProcessing && hasProcessingOverlay && /* @__PURE__ */ jsxRuntime.jsx(
1486
- "div",
1487
- {
1488
- className: "absolute inset-0 bg-white/80 backdrop-blur-sm z-50 flex items-center justify-center pointer-events-none",
1489
- style: { minHeight: "200px" },
1490
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pointer-events-auto", children: tabCallbacks[index].processingOverlay })
1491
- }
1492
- )
1488
+ isCurrentlyProcessing && hasProcessingOverlay && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed inset-0 bg-black/70 z-50 flex items-center justify-center pointer-events-none", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pointer-events-auto", children: tabCallbacks[index].processingOverlay }) })
1493
1489
  ] }) }) }, index);
1494
1490
  }
1495
1491
  return null;
@@ -1543,7 +1539,7 @@ var MultiTabFormContent = ({
1543
1539
 
1544
1540
  // src/hooks/useFormWrapper.ts
1545
1541
  var useFormWrapper = () => {
1546
- return chunkWUYS7DMR_cjs.useSmartForm();
1542
+ return chunkAEN4A4ST_cjs.useSmartForm();
1547
1543
  };
1548
1544
  var useExternalFormRegistration = () => {
1549
1545
  const context = React3.useContext(ExternalFormContext);
@@ -1565,7 +1561,7 @@ var ExternalFieldProvider = ({
1565
1561
  children,
1566
1562
  registerField
1567
1563
  }) => {
1568
- return /* @__PURE__ */ jsxRuntime.jsx(chunkWUYS7DMR_cjs.FieldDetectionContext.Provider, { value: { registerField }, children });
1564
+ return /* @__PURE__ */ jsxRuntime.jsx(chunkAEN4A4ST_cjs.FieldDetectionContext.Provider, { value: { registerField }, children });
1569
1565
  };
1570
1566
 
1571
1567
  // src/useAutoDetectFields.tsx
@@ -1656,23 +1652,36 @@ var SmartTextArea = ({
1656
1652
  maxLength,
1657
1653
  minLength,
1658
1654
  name,
1659
- dirName,
1655
+ dirname,
1660
1656
  form
1661
1657
  }) => {
1662
- const { formData } = chunkWUYS7DMR_cjs.useSmartForm();
1663
- const { value, error, onChange, fieldRef, registerValidation } = chunkWUYS7DMR_cjs.useFormField(field);
1664
- const fieldDetection = chunkWUYS7DMR_cjs.useFieldDetection();
1658
+ const { formData } = chunkAEN4A4ST_cjs.useSmartForm();
1659
+ const { value, error, onChange, fieldRef, registerValidation } = chunkAEN4A4ST_cjs.useFormField(field);
1660
+ const fieldDetection = chunkAEN4A4ST_cjs.useFieldDetection();
1665
1661
  const hasRegistered = React3.useRef(false);
1666
1662
  const hasSetDefault = React3.useRef(false);
1667
1663
  const isDisabled = typeof disabled === "function" ? disabled(formData) : disabled || false;
1668
1664
  const isHidden = typeof hidden === "function" ? hidden(formData) : hidden || false;
1669
1665
  if (isHidden) return null;
1666
+ const displayName = label || field;
1667
+ const builtinValidation = React3.useMemo(() => {
1668
+ if (validation) return void 0;
1669
+ const preprocess = (v) => v === void 0 || v === null ? "" : v;
1670
+ if (minLength != null) {
1671
+ return zod.z.preprocess(preprocess, zod.z.string().min(minLength, `${displayName} must be at least ${minLength} characters`));
1672
+ }
1673
+ if (required) {
1674
+ return zod.z.preprocess(preprocess, zod.z.string().min(1, `${displayName} is required`));
1675
+ }
1676
+ return void 0;
1677
+ }, [validation, minLength, required, displayName]);
1678
+ const schemaToRegister = validation ?? builtinValidation;
1670
1679
  React3.useEffect(() => {
1671
- if (validation && !hasRegistered.current) {
1680
+ if (schemaToRegister && !hasRegistered.current) {
1672
1681
  hasRegistered.current = true;
1673
- registerValidation(field, validation);
1682
+ registerValidation(field, schemaToRegister, { label: displayName });
1674
1683
  }
1675
- }, [validation, field, registerValidation]);
1684
+ }, [schemaToRegister, field, registerValidation, displayName]);
1676
1685
  React3.useEffect(() => {
1677
1686
  if (fieldDetection?.registerField) {
1678
1687
  fieldDetection.registerField(field);
@@ -1709,21 +1718,21 @@ var SmartTextArea = ({
1709
1718
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex-1 min-w-0 ${className}`, children: [
1710
1719
  label && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-1", children: [
1711
1720
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
1712
- /* @__PURE__ */ jsxRuntime.jsxs(chunkWUYS7DMR_cjs.Label, { className: "text-sm font-medium text-foreground", children: [
1721
+ /* @__PURE__ */ jsxRuntime.jsxs(chunkAEN4A4ST_cjs.Label, { className: "text-sm font-medium text-foreground", children: [
1713
1722
  label,
1714
1723
  " ",
1715
1724
  required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-destructive", children: "*" })
1716
1725
  ] }),
1717
- info && /* @__PURE__ */ jsxRuntime.jsx(chunkWUYS7DMR_cjs.TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(chunkWUYS7DMR_cjs.Tooltip, { children: [
1718
- /* @__PURE__ */ jsxRuntime.jsx(chunkWUYS7DMR_cjs.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.InfoIcon, { className: "h-4 w-4 text-muted-foreground cursor-pointer" }) }),
1719
- /* @__PURE__ */ jsxRuntime.jsx(chunkWUYS7DMR_cjs.TooltipContent, { children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "max-w-xs", children: info }) })
1726
+ info && /* @__PURE__ */ jsxRuntime.jsx(chunkAEN4A4ST_cjs.TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(chunkAEN4A4ST_cjs.Tooltip, { children: [
1727
+ /* @__PURE__ */ jsxRuntime.jsx(chunkAEN4A4ST_cjs.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.InfoIcon, { className: "h-4 w-4 text-muted-foreground cursor-pointer" }) }),
1728
+ /* @__PURE__ */ jsxRuntime.jsx(chunkAEN4A4ST_cjs.TooltipContent, { children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "max-w-xs", children: info }) })
1720
1729
  ] }) })
1721
1730
  ] }),
1722
1731
  subLabel && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground mt-1", children: subLabel })
1723
1732
  ] }),
1724
1733
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
1725
1734
  /* @__PURE__ */ jsxRuntime.jsx(
1726
- chunkWUYS7DMR_cjs.Textarea,
1735
+ chunkAEN4A4ST_cjs.Textarea,
1727
1736
  {
1728
1737
  ref: fieldRef,
1729
1738
  value: value || "",
@@ -1744,7 +1753,7 @@ var SmartTextArea = ({
1744
1753
  maxLength,
1745
1754
  minLength,
1746
1755
  name,
1747
- dirName,
1756
+ dirName: dirname,
1748
1757
  form
1749
1758
  }
1750
1759
  ),
@@ -1760,47 +1769,47 @@ var SmartTextArea = ({
1760
1769
 
1761
1770
  Object.defineProperty(exports, "SmartCheckbox", {
1762
1771
  enumerable: true,
1763
- get: function () { return chunkDRMVY7TX_cjs.SmartCheckbox; }
1772
+ get: function () { return chunkTX7JD2XS_cjs.SmartCheckbox; }
1764
1773
  });
1765
1774
  Object.defineProperty(exports, "SmartCombobox", {
1766
1775
  enumerable: true,
1767
- get: function () { return chunkDRMVY7TX_cjs.SmartCombobox; }
1776
+ get: function () { return chunkTX7JD2XS_cjs.SmartCombobox; }
1768
1777
  });
1769
1778
  Object.defineProperty(exports, "SmartDatePicker", {
1770
1779
  enumerable: true,
1771
- get: function () { return chunkDRMVY7TX_cjs.SmartDatePicker; }
1780
+ get: function () { return chunkTX7JD2XS_cjs.SmartDatePicker; }
1772
1781
  });
1773
1782
  Object.defineProperty(exports, "SmartRadioGroup", {
1774
1783
  enumerable: true,
1775
- get: function () { return chunkDRMVY7TX_cjs.SmartRadioGroup; }
1784
+ get: function () { return chunkTX7JD2XS_cjs.SmartRadioGroup; }
1776
1785
  });
1777
1786
  Object.defineProperty(exports, "SmartSelect", {
1778
1787
  enumerable: true,
1779
- get: function () { return chunkDRMVY7TX_cjs.SmartSelect; }
1788
+ get: function () { return chunkTX7JD2XS_cjs.SmartSelect; }
1780
1789
  });
1781
1790
  Object.defineProperty(exports, "SmartTags", {
1782
1791
  enumerable: true,
1783
- get: function () { return chunkDRMVY7TX_cjs.SmartTags; }
1792
+ get: function () { return chunkTX7JD2XS_cjs.SmartTags; }
1784
1793
  });
1785
1794
  Object.defineProperty(exports, "SmartFormProvider", {
1786
1795
  enumerable: true,
1787
- get: function () { return chunkWUYS7DMR_cjs.SmartFormProvider; }
1796
+ get: function () { return chunkAEN4A4ST_cjs.SmartFormProvider; }
1788
1797
  });
1789
1798
  Object.defineProperty(exports, "SmartInput", {
1790
1799
  enumerable: true,
1791
- get: function () { return chunkWUYS7DMR_cjs.SmartInput; }
1800
+ get: function () { return chunkAEN4A4ST_cjs.SmartInput; }
1792
1801
  });
1793
1802
  Object.defineProperty(exports, "useFieldDetection", {
1794
1803
  enumerable: true,
1795
- get: function () { return chunkWUYS7DMR_cjs.useFieldDetection; }
1804
+ get: function () { return chunkAEN4A4ST_cjs.useFieldDetection; }
1796
1805
  });
1797
1806
  Object.defineProperty(exports, "useFormField", {
1798
1807
  enumerable: true,
1799
- get: function () { return chunkWUYS7DMR_cjs.useFormField; }
1808
+ get: function () { return chunkAEN4A4ST_cjs.useFormField; }
1800
1809
  });
1801
1810
  Object.defineProperty(exports, "useSmartForm", {
1802
1811
  enumerable: true,
1803
- get: function () { return chunkWUYS7DMR_cjs.useSmartForm; }
1812
+ get: function () { return chunkAEN4A4ST_cjs.useSmartForm; }
1804
1813
  });
1805
1814
  exports.BaseSmartForm = BaseSmartForm;
1806
1815
  exports.DraftSaveButton = DraftSaveButton;