@algodomain/smart-forms 0.1.10 → 0.1.11

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"
@@ -668,7 +668,7 @@ function Tabs({
668
668
  handleValueChange,
669
669
  registerTrigger
670
670
  },
671
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { "data-slot": "tabs", className: chunkWUYS7DMR_cjs.cn("flex flex-col gap-2", className), ...props, children: props.children })
671
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { "data-slot": "tabs", className: chunkAEN4A4ST_cjs.cn("flex flex-col gap-2", className), ...props, children: props.children })
672
672
  }
673
673
  ) });
674
674
  }
@@ -676,7 +676,7 @@ function Tabs({
676
676
  TabsPrimitive__namespace.Root,
677
677
  {
678
678
  "data-slot": "tabs",
679
- className: chunkWUYS7DMR_cjs.cn("flex flex-col gap-2", className),
679
+ className: chunkAEN4A4ST_cjs.cn("flex flex-col gap-2", className),
680
680
  ...props
681
681
  }
682
682
  ) });
@@ -698,7 +698,7 @@ function TabsList({
698
698
  MotionHighlight,
699
699
  {
700
700
  controlledItems: true,
701
- className: chunkWUYS7DMR_cjs.cn("bg-background rounded-sm shadow-sm", activeClassName),
701
+ className: chunkAEN4A4ST_cjs.cn("bg-background rounded-sm shadow-sm", activeClassName),
702
702
  value: activeValue,
703
703
  transition,
704
704
  children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -706,7 +706,7 @@ function TabsList({
706
706
  {
707
707
  role: "tablist",
708
708
  "data-slot": "tabs-list",
709
- className: chunkWUYS7DMR_cjs.cn(
709
+ className: chunkAEN4A4ST_cjs.cn(
710
710
  "bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",
711
711
  className
712
712
  ),
@@ -730,7 +730,7 @@ function TabsList({
730
730
  TabsPrimitive__namespace.List,
731
731
  {
732
732
  "data-slot": "tabs-list",
733
- className: chunkWUYS7DMR_cjs.cn(
733
+ className: chunkAEN4A4ST_cjs.cn(
734
734
  "bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",
735
735
  className
736
736
  ),
@@ -816,7 +816,7 @@ function UnderlineTabsList({
816
816
  TabsPrimitive__namespace.List,
817
817
  {
818
818
  "data-slot": "tabs-list",
819
- className: chunkWUYS7DMR_cjs.cn(
819
+ className: chunkAEN4A4ST_cjs.cn(
820
820
  "bg-background relative rounded-none border-b p-0",
821
821
  className
822
822
  ),
@@ -891,7 +891,7 @@ function TabsTrigger({
891
891
  onClick: () => !disabled && handleValueChange(props.value),
892
892
  "data-state": activeValue === props.value ? "active" : "inactive",
893
893
  disabled,
894
- className: chunkWUYS7DMR_cjs.cn(
894
+ className: chunkAEN4A4ST_cjs.cn(
895
895
  "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
896
  className
897
897
  ),
@@ -924,7 +924,7 @@ function TabsTrigger({
924
924
  {
925
925
  ref: localRef,
926
926
  "data-slot": "tabs-trigger",
927
- className: chunkWUYS7DMR_cjs.cn(
927
+ className: chunkAEN4A4ST_cjs.cn(
928
928
  "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
929
  className
930
930
  ),
@@ -936,7 +936,7 @@ function TabsTrigger({
936
936
  TabsPrimitive__namespace.Trigger,
937
937
  {
938
938
  "data-slot": "tabs-trigger",
939
- className: chunkWUYS7DMR_cjs.cn(
939
+ className: chunkAEN4A4ST_cjs.cn(
940
940
  "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
941
  className
942
942
  ),
@@ -983,7 +983,7 @@ function TabsContent({
983
983
  {
984
984
  role: "tabpanel",
985
985
  "data-slot": "tabs-content",
986
- className: chunkWUYS7DMR_cjs.cn("overflow-hidden", className),
986
+ className: chunkAEN4A4ST_cjs.cn("overflow-hidden", className),
987
987
  initial: { filter: "blur(0px)" },
988
988
  animate: { filter: isActive ? "blur(0px)" : "blur(2px)" },
989
989
  exit: { filter: "blur(0px)" },
@@ -1005,7 +1005,7 @@ function TabsContent({
1005
1005
  TabsPrimitive__namespace.Content,
1006
1006
  {
1007
1007
  "data-slot": "tabs-content",
1008
- className: chunkWUYS7DMR_cjs.cn("flex-1 outline-none", className),
1008
+ className: chunkAEN4A4ST_cjs.cn("flex-1 outline-none", className),
1009
1009
  ...props
1010
1010
  }
1011
1011
  );
@@ -1233,7 +1233,7 @@ var MultiTabFormContent = ({
1233
1233
  maxUnlockedTab,
1234
1234
  setMaxUnlockedTab
1235
1235
  }) => {
1236
- const { isLoading, isDraftSaving, submitForm, saveDraft, resetForm, validateFields, formData, validationRegistry, setErrors } = chunkWUYS7DMR_cjs.useSmartForm();
1236
+ const { isLoading, isDraftSaving, submitForm, saveDraft, resetForm, validateFields, formData, validationRegistry, setErrors, getValidationErrorMessage } = chunkAEN4A4ST_cjs.useSmartForm();
1237
1237
  const debounce = (func, wait) => {
1238
1238
  let timeout;
1239
1239
  return function executedFunction(...args) {
@@ -1312,7 +1312,8 @@ var MultiTabFormContent = ({
1312
1312
  validation.parse(formData[field]);
1313
1313
  } catch (error) {
1314
1314
  if (error instanceof zod.z.ZodError) {
1315
- allErrors[field] = error.issues[0]?.message || `Invalid ${field}`;
1315
+ const msg = error.issues[0]?.message ?? "";
1316
+ allErrors[field] = getValidationErrorMessage(field, msg);
1316
1317
  isValid = false;
1317
1318
  }
1318
1319
  }
@@ -1390,7 +1391,7 @@ var MultiTabFormContent = ({
1390
1391
  onNext();
1391
1392
  }
1392
1393
  }
1393
- }, [activeTab, getCombinedTabFields, validateFields, onNext, setCompletedTabs, setValidationErrorTabs, validationRegistry, formData, tabCallbacks, setProcessingTab, setProcessingError, setMaxUnlockedTab]);
1394
+ }, [activeTab, getCombinedTabFields, validateFields, onNext, setCompletedTabs, setValidationErrorTabs, validationRegistry, formData, tabCallbacks, setProcessingTab, setProcessingError, setMaxUnlockedTab, getValidationErrorMessage]);
1394
1395
  const handleSubmitWithValidation = React3.useCallback(async () => {
1395
1396
  const allErrors = {};
1396
1397
  let isValid = true;
@@ -1401,7 +1402,8 @@ var MultiTabFormContent = ({
1401
1402
  validation.parse(formData[field]);
1402
1403
  } catch (error) {
1403
1404
  if (error instanceof zod.z.ZodError) {
1404
- allErrors[field] = error.issues[0]?.message || `Invalid ${field}`;
1405
+ const msg = error.issues[0]?.message ?? "";
1406
+ allErrors[field] = getValidationErrorMessage(field, msg);
1405
1407
  isValid = false;
1406
1408
  }
1407
1409
  }
@@ -1437,7 +1439,7 @@ var MultiTabFormContent = ({
1437
1439
  }, 100);
1438
1440
  }
1439
1441
  }
1440
- }, [submitForm, getCombinedTabFields, onTabChange, tabs.length, validationRegistry, formData, setErrors, setValidationErrorTabs]);
1442
+ }, [submitForm, getCombinedTabFields, onTabChange, tabs.length, validationRegistry, formData, setErrors, setValidationErrorTabs, getValidationErrorMessage]);
1441
1443
  const activeTabValue = tabs[activeTab] || tabs[0] || "";
1442
1444
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1443
1445
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1482,14 +1484,7 @@ var MultiTabFormContent = ({
1482
1484
  const hasProcessingOverlay = tabCallbacks[index]?.processingOverlay;
1483
1485
  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
1486
  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
- )
1487
+ 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
1488
  ] }) }) }, index);
1494
1489
  }
1495
1490
  return null;
@@ -1543,7 +1538,7 @@ var MultiTabFormContent = ({
1543
1538
 
1544
1539
  // src/hooks/useFormWrapper.ts
1545
1540
  var useFormWrapper = () => {
1546
- return chunkWUYS7DMR_cjs.useSmartForm();
1541
+ return chunkAEN4A4ST_cjs.useSmartForm();
1547
1542
  };
1548
1543
  var useExternalFormRegistration = () => {
1549
1544
  const context = React3.useContext(ExternalFormContext);
@@ -1565,7 +1560,7 @@ var ExternalFieldProvider = ({
1565
1560
  children,
1566
1561
  registerField
1567
1562
  }) => {
1568
- return /* @__PURE__ */ jsxRuntime.jsx(chunkWUYS7DMR_cjs.FieldDetectionContext.Provider, { value: { registerField }, children });
1563
+ return /* @__PURE__ */ jsxRuntime.jsx(chunkAEN4A4ST_cjs.FieldDetectionContext.Provider, { value: { registerField }, children });
1569
1564
  };
1570
1565
 
1571
1566
  // src/useAutoDetectFields.tsx
@@ -1659,20 +1654,33 @@ var SmartTextArea = ({
1659
1654
  dirName,
1660
1655
  form
1661
1656
  }) => {
1662
- const { formData } = chunkWUYS7DMR_cjs.useSmartForm();
1663
- const { value, error, onChange, fieldRef, registerValidation } = chunkWUYS7DMR_cjs.useFormField(field);
1664
- const fieldDetection = chunkWUYS7DMR_cjs.useFieldDetection();
1657
+ const { formData } = chunkAEN4A4ST_cjs.useSmartForm();
1658
+ const { value, error, onChange, fieldRef, registerValidation } = chunkAEN4A4ST_cjs.useFormField(field);
1659
+ const fieldDetection = chunkAEN4A4ST_cjs.useFieldDetection();
1665
1660
  const hasRegistered = React3.useRef(false);
1666
1661
  const hasSetDefault = React3.useRef(false);
1667
1662
  const isDisabled = typeof disabled === "function" ? disabled(formData) : disabled || false;
1668
1663
  const isHidden = typeof hidden === "function" ? hidden(formData) : hidden || false;
1669
1664
  if (isHidden) return null;
1665
+ const displayName = label || field;
1666
+ const builtinValidation = React3.useMemo(() => {
1667
+ if (validation) return void 0;
1668
+ const preprocess = (v) => v === void 0 || v === null ? "" : v;
1669
+ if (minLength != null) {
1670
+ return zod.z.preprocess(preprocess, zod.z.string().min(minLength, `${displayName} must be at least ${minLength} characters`));
1671
+ }
1672
+ if (required) {
1673
+ return zod.z.preprocess(preprocess, zod.z.string().min(1, `${displayName} is required`));
1674
+ }
1675
+ return void 0;
1676
+ }, [validation, minLength, required, displayName]);
1677
+ const schemaToRegister = validation ?? builtinValidation;
1670
1678
  React3.useEffect(() => {
1671
- if (validation && !hasRegistered.current) {
1679
+ if (schemaToRegister && !hasRegistered.current) {
1672
1680
  hasRegistered.current = true;
1673
- registerValidation(field, validation);
1681
+ registerValidation(field, schemaToRegister, { label: displayName });
1674
1682
  }
1675
- }, [validation, field, registerValidation]);
1683
+ }, [schemaToRegister, field, registerValidation, displayName]);
1676
1684
  React3.useEffect(() => {
1677
1685
  if (fieldDetection?.registerField) {
1678
1686
  fieldDetection.registerField(field);
@@ -1709,21 +1717,21 @@ var SmartTextArea = ({
1709
1717
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex-1 min-w-0 ${className}`, children: [
1710
1718
  label && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-1", children: [
1711
1719
  /* @__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: [
1720
+ /* @__PURE__ */ jsxRuntime.jsxs(chunkAEN4A4ST_cjs.Label, { className: "text-sm font-medium text-foreground", children: [
1713
1721
  label,
1714
1722
  " ",
1715
1723
  required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-destructive", children: "*" })
1716
1724
  ] }),
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 }) })
1725
+ info && /* @__PURE__ */ jsxRuntime.jsx(chunkAEN4A4ST_cjs.TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(chunkAEN4A4ST_cjs.Tooltip, { children: [
1726
+ /* @__PURE__ */ jsxRuntime.jsx(chunkAEN4A4ST_cjs.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.InfoIcon, { className: "h-4 w-4 text-muted-foreground cursor-pointer" }) }),
1727
+ /* @__PURE__ */ jsxRuntime.jsx(chunkAEN4A4ST_cjs.TooltipContent, { children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "max-w-xs", children: info }) })
1720
1728
  ] }) })
1721
1729
  ] }),
1722
1730
  subLabel && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground mt-1", children: subLabel })
1723
1731
  ] }),
1724
1732
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
1725
1733
  /* @__PURE__ */ jsxRuntime.jsx(
1726
- chunkWUYS7DMR_cjs.Textarea,
1734
+ chunkAEN4A4ST_cjs.Textarea,
1727
1735
  {
1728
1736
  ref: fieldRef,
1729
1737
  value: value || "",
@@ -1760,47 +1768,47 @@ var SmartTextArea = ({
1760
1768
 
1761
1769
  Object.defineProperty(exports, "SmartCheckbox", {
1762
1770
  enumerable: true,
1763
- get: function () { return chunkDRMVY7TX_cjs.SmartCheckbox; }
1771
+ get: function () { return chunkTX7JD2XS_cjs.SmartCheckbox; }
1764
1772
  });
1765
1773
  Object.defineProperty(exports, "SmartCombobox", {
1766
1774
  enumerable: true,
1767
- get: function () { return chunkDRMVY7TX_cjs.SmartCombobox; }
1775
+ get: function () { return chunkTX7JD2XS_cjs.SmartCombobox; }
1768
1776
  });
1769
1777
  Object.defineProperty(exports, "SmartDatePicker", {
1770
1778
  enumerable: true,
1771
- get: function () { return chunkDRMVY7TX_cjs.SmartDatePicker; }
1779
+ get: function () { return chunkTX7JD2XS_cjs.SmartDatePicker; }
1772
1780
  });
1773
1781
  Object.defineProperty(exports, "SmartRadioGroup", {
1774
1782
  enumerable: true,
1775
- get: function () { return chunkDRMVY7TX_cjs.SmartRadioGroup; }
1783
+ get: function () { return chunkTX7JD2XS_cjs.SmartRadioGroup; }
1776
1784
  });
1777
1785
  Object.defineProperty(exports, "SmartSelect", {
1778
1786
  enumerable: true,
1779
- get: function () { return chunkDRMVY7TX_cjs.SmartSelect; }
1787
+ get: function () { return chunkTX7JD2XS_cjs.SmartSelect; }
1780
1788
  });
1781
1789
  Object.defineProperty(exports, "SmartTags", {
1782
1790
  enumerable: true,
1783
- get: function () { return chunkDRMVY7TX_cjs.SmartTags; }
1791
+ get: function () { return chunkTX7JD2XS_cjs.SmartTags; }
1784
1792
  });
1785
1793
  Object.defineProperty(exports, "SmartFormProvider", {
1786
1794
  enumerable: true,
1787
- get: function () { return chunkWUYS7DMR_cjs.SmartFormProvider; }
1795
+ get: function () { return chunkAEN4A4ST_cjs.SmartFormProvider; }
1788
1796
  });
1789
1797
  Object.defineProperty(exports, "SmartInput", {
1790
1798
  enumerable: true,
1791
- get: function () { return chunkWUYS7DMR_cjs.SmartInput; }
1799
+ get: function () { return chunkAEN4A4ST_cjs.SmartInput; }
1792
1800
  });
1793
1801
  Object.defineProperty(exports, "useFieldDetection", {
1794
1802
  enumerable: true,
1795
- get: function () { return chunkWUYS7DMR_cjs.useFieldDetection; }
1803
+ get: function () { return chunkAEN4A4ST_cjs.useFieldDetection; }
1796
1804
  });
1797
1805
  Object.defineProperty(exports, "useFormField", {
1798
1806
  enumerable: true,
1799
- get: function () { return chunkWUYS7DMR_cjs.useFormField; }
1807
+ get: function () { return chunkAEN4A4ST_cjs.useFormField; }
1800
1808
  });
1801
1809
  Object.defineProperty(exports, "useSmartForm", {
1802
1810
  enumerable: true,
1803
- get: function () { return chunkWUYS7DMR_cjs.useSmartForm; }
1811
+ get: function () { return chunkAEN4A4ST_cjs.useSmartForm; }
1804
1812
  });
1805
1813
  exports.BaseSmartForm = BaseSmartForm;
1806
1814
  exports.DraftSaveButton = DraftSaveButton;