formanitor 0.0.50 → 0.1.1

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
@@ -2,9 +2,9 @@
2
2
 
3
3
  var React15 = require('react');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
- var lucideReact = require('lucide-react');
6
5
  var clsx = require('clsx');
7
6
  var tailwindMerge = require('tailwind-merge');
7
+ var lucideReact = require('lucide-react');
8
8
  var LabelPrimitive = require('@radix-ui/react-label');
9
9
  var classVarianceAuthority = require('class-variance-authority');
10
10
  var react = require('@tiptap/react');
@@ -1926,6 +1926,9 @@ function useField(fieldId) {
1926
1926
  setTouched
1927
1927
  };
1928
1928
  }
1929
+ function cn(...inputs) {
1930
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
1931
+ }
1929
1932
  function RecordingWave() {
1930
1933
  const bars = [
1931
1934
  { dur: "0.6s", values: "3;10;3", yValues: "4.5;0;4.5", delay: "0s" },
@@ -1992,9 +1995,6 @@ function VoiceMicButton({ fieldId, onTranscriptReady }) {
1992
1995
  }
1993
1996
  );
1994
1997
  }
1995
- function cn(...inputs) {
1996
- return tailwindMerge.twMerge(clsx.clsx(inputs));
1997
- }
1998
1998
  var Input = React15__namespace.forwardRef(
1999
1999
  ({ className, type, ...props }, ref) => {
2000
2000
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -2065,6 +2065,41 @@ function getThemeConfig(fieldType, themeName) {
2065
2065
  if (!registry) return void 0;
2066
2066
  return registry[themeName];
2067
2067
  }
2068
+ function isLabelVisible(fieldDef) {
2069
+ return fieldDef.style?.labelVisible !== false;
2070
+ }
2071
+ function FieldRequiredIndicator({
2072
+ fieldDef
2073
+ }) {
2074
+ if (!fieldDef.required) return null;
2075
+ if (fieldDef.style?.showRequiredAsterisk === false) return null;
2076
+ return /* @__PURE__ */ jsxRuntime.jsx(
2077
+ "span",
2078
+ {
2079
+ className: cn(
2080
+ "text-red-500",
2081
+ fieldDef.style?.classNames?.requiredIndicator
2082
+ ),
2083
+ "aria-hidden": true,
2084
+ children: "*"
2085
+ }
2086
+ );
2087
+ }
2088
+ function fieldWrapperClass(fieldDef, ...defaults) {
2089
+ return cn(...defaults, fieldDef.style?.classNames?.wrapper);
2090
+ }
2091
+ function fieldLabelClass(fieldDef, ...defaults) {
2092
+ return cn(...defaults, fieldDef.style?.classNames?.label);
2093
+ }
2094
+ function fieldControlClass(fieldDef, ...defaults) {
2095
+ return cn(...defaults, fieldDef.style?.classNames?.control);
2096
+ }
2097
+ function fieldDescriptionClass(fieldDef, ...defaults) {
2098
+ return cn(...defaults, fieldDef.style?.classNames?.description);
2099
+ }
2100
+ function fieldErrorClass(fieldDef, ...defaults) {
2101
+ return cn(...defaults, fieldDef.style?.classNames?.error);
2102
+ }
2068
2103
  var TextWidget = ({ fieldId }) => {
2069
2104
  const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
2070
2105
  const { state } = useForm();
@@ -2082,34 +2117,50 @@ var TextWidget = ({ fieldId }) => {
2082
2117
  const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
2083
2118
  const labelClass = theme?.labelClassName;
2084
2119
  const inputClass = cn(theme?.inputClassName, showError && "border-red-500");
2120
+ const showLabel = isLabelVisible(fieldDef);
2085
2121
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2086
2122
  fieldDef.label,
2087
2123
  " ",
2088
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
2124
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
2089
2125
  ] });
2090
- const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, children: labelContent });
2126
+ const labelEl = showLabel ? theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef, labelClass), children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: labelContent }) : null;
2091
2127
  const placeholder = typeof fieldDef.placeholder === "string" && fieldDef.placeholder.trim() ? fieldDef.placeholder : void 0;
2092
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(wrapperClass, isTextarea && "flex h-full min-h-0 flex-col"), children: [
2093
- hasVoice ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
2094
- labelEl,
2095
- /* @__PURE__ */ jsxRuntime.jsx(VoiceMicButton, { fieldId, onTranscriptReady: setValue })
2096
- ] }) : labelEl,
2097
- /* @__PURE__ */ jsxRuntime.jsx(
2098
- Component,
2099
- {
2100
- id: fieldId,
2101
- value: value || "",
2102
- onChange: (e) => setValue(fieldDef.type === "number" ? Number(e.target.value) : e.target.value),
2103
- onBlur: setTouched,
2104
- disabled,
2105
- type: fieldDef.type === "number" ? "number" : "text",
2106
- className: cn(inputClass, isTextarea && height == null && "min-h-[80px] flex-1"),
2107
- placeholder,
2108
- ...isTextarea && { height }
2109
- }
2110
- ),
2111
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
2112
- ] });
2128
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2129
+ "div",
2130
+ {
2131
+ className: fieldWrapperClass(
2132
+ fieldDef,
2133
+ wrapperClass,
2134
+ isTextarea && "flex h-full min-h-0 flex-col"
2135
+ ),
2136
+ children: [
2137
+ hasVoice ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
2138
+ labelEl,
2139
+ /* @__PURE__ */ jsxRuntime.jsx(VoiceMicButton, { fieldId, onTranscriptReady: setValue })
2140
+ ] }) : labelEl,
2141
+ /* @__PURE__ */ jsxRuntime.jsx(
2142
+ Component,
2143
+ {
2144
+ id: fieldId,
2145
+ value: value || "",
2146
+ onChange: (e) => setValue(fieldDef.type === "number" ? Number(e.target.value) : e.target.value),
2147
+ onBlur: setTouched,
2148
+ disabled,
2149
+ type: fieldDef.type === "number" ? "number" : "text",
2150
+ className: fieldControlClass(
2151
+ fieldDef,
2152
+ inputClass,
2153
+ isTextarea && height == null && "min-h-[80px] flex-1"
2154
+ ),
2155
+ placeholder,
2156
+ "aria-label": !showLabel ? fieldDef.label : void 0,
2157
+ ...isTextarea && { height }
2158
+ }
2159
+ ),
2160
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
2161
+ ]
2162
+ }
2163
+ );
2113
2164
  };
2114
2165
  var buttonVariants = classVarianceAuthority.cva(
2115
2166
  "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
@@ -2373,24 +2424,28 @@ var RichTextWidget = ({ fieldId }) => {
2373
2424
  }
2374
2425
  }, [stringValue, editor]);
2375
2426
  if (!fieldDef) return null;
2427
+ const showLabel = isLabelVisible(fieldDef);
2376
2428
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2377
2429
  fieldDef.label,
2378
2430
  " ",
2379
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
2431
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
2380
2432
  ] });
2381
- const labelEl = /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, children: labelContent });
2382
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
2433
+ const labelEl = /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: labelContent });
2434
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
2383
2435
  hasVoice ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
2384
- labelEl,
2436
+ showLabel ? labelEl : null,
2385
2437
  /* @__PURE__ */ jsxRuntime.jsx(VoiceMicButton, { fieldId, onTranscriptReady: setValue })
2386
- ] }) : labelEl,
2438
+ ] }) : showLabel ? labelEl : null,
2387
2439
  /* @__PURE__ */ jsxRuntime.jsxs(
2388
2440
  "div",
2389
2441
  {
2390
- className: cn(
2391
- "rounded-md border border-input bg-background text-sm ring-offset-background overflow-hidden",
2392
- showError && "border-red-500",
2393
- disabled && "opacity-60"
2442
+ className: fieldControlClass(
2443
+ fieldDef,
2444
+ cn(
2445
+ "rounded-md border border-input bg-background text-sm ring-offset-background overflow-hidden",
2446
+ showError && "border-red-500",
2447
+ disabled && "opacity-60"
2448
+ )
2394
2449
  ),
2395
2450
  children: [
2396
2451
  /* @__PURE__ */ jsxRuntime.jsx(RichTextToolbar, { editor, disabled }),
@@ -2416,7 +2471,7 @@ var RichTextWidget = ({ fieldId }) => {
2416
2471
  ]
2417
2472
  }
2418
2473
  ),
2419
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
2474
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
2420
2475
  ] });
2421
2476
  };
2422
2477
  var Select = SelectPrimitive__namespace.Root;
@@ -2582,12 +2637,13 @@ var SelectWidget = ({ fieldId }) => {
2582
2637
  if (!fieldDef) return null;
2583
2638
  const schemaPlaceholder = typeof fieldDef.placeholder === "string" && fieldDef.placeholder.trim() ? fieldDef.placeholder : void 0;
2584
2639
  const selectPlaceholder = loading ? "Loading..." : schemaPlaceholder ?? "Select...";
2585
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
2586
- /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, children: [
2640
+ const showLabel = isLabelVisible(fieldDef);
2641
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
2642
+ showLabel ? /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
2587
2643
  fieldDef.label,
2588
2644
  " ",
2589
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
2590
- ] }),
2645
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
2646
+ ] }) : null,
2591
2647
  /* @__PURE__ */ jsxRuntime.jsxs(
2592
2648
  Select,
2593
2649
  {
@@ -2599,12 +2655,22 @@ var SelectWidget = ({ fieldId }) => {
2599
2655
  setTouched();
2600
2656
  },
2601
2657
  children: [
2602
- /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { id: fieldId, className: showError ? "border-red-500" : "", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: selectPlaceholder }) }),
2658
+ /* @__PURE__ */ jsxRuntime.jsx(
2659
+ SelectTrigger,
2660
+ {
2661
+ id: fieldId,
2662
+ className: fieldControlClass(
2663
+ fieldDef,
2664
+ showError ? "border-red-500" : ""
2665
+ ),
2666
+ children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: selectPlaceholder })
2667
+ }
2668
+ ),
2603
2669
  /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: options.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: String(opt.value), children: opt.label }, String(opt.value))) })
2604
2670
  ]
2605
2671
  }
2606
2672
  ),
2607
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
2673
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
2608
2674
  ] });
2609
2675
  };
2610
2676
  var Checkbox = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
@@ -2651,34 +2717,44 @@ var MultiSelectWidget = ({ fieldId }) => {
2651
2717
  setTouched();
2652
2718
  };
2653
2719
  if (!fieldDef) return null;
2654
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
2655
- /* @__PURE__ */ jsxRuntime.jsxs(Label, { children: [
2720
+ const showLabel = isLabelVisible(fieldDef);
2721
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
2722
+ showLabel ? /* @__PURE__ */ jsxRuntime.jsxs(Label, { className: fieldLabelClass(fieldDef), children: [
2656
2723
  fieldDef.label,
2657
2724
  " ",
2658
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
2659
- ] }),
2660
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `border rounded-md p-3 space-y-2 ${showError ? "border-red-500" : ""} ${disabled ? "opacity-50 pointer-events-none" : ""}`, children: [
2661
- loading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-gray-500", children: "Loading options..." }),
2662
- !loading && options.map((opt) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-2", children: [
2663
- /* @__PURE__ */ jsxRuntime.jsx(
2664
- Checkbox,
2665
- {
2666
- id: `${fieldId}-${opt.value}`,
2667
- checked: currentValues.includes(opt.value),
2668
- onCheckedChange: () => toggleValue(opt.value)
2669
- }
2725
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
2726
+ ] }) : null,
2727
+ /* @__PURE__ */ jsxRuntime.jsxs(
2728
+ "div",
2729
+ {
2730
+ className: fieldControlClass(
2731
+ fieldDef,
2732
+ `border rounded-md p-3 space-y-2 ${showError ? "border-red-500" : ""} ${disabled ? "opacity-50 pointer-events-none" : ""}`
2670
2733
  ),
2671
- /* @__PURE__ */ jsxRuntime.jsx(
2672
- "label",
2673
- {
2674
- htmlFor: `${fieldId}-${opt.value}`,
2675
- className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
2676
- children: opt.label
2677
- }
2678
- )
2679
- ] }, String(opt.value)))
2680
- ] }),
2681
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
2734
+ children: [
2735
+ loading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-gray-500", children: "Loading options..." }),
2736
+ !loading && options.map((opt) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-2", children: [
2737
+ /* @__PURE__ */ jsxRuntime.jsx(
2738
+ Checkbox,
2739
+ {
2740
+ id: `${fieldId}-${opt.value}`,
2741
+ checked: currentValues.includes(opt.value),
2742
+ onCheckedChange: () => toggleValue(opt.value)
2743
+ }
2744
+ ),
2745
+ /* @__PURE__ */ jsxRuntime.jsx(
2746
+ "label",
2747
+ {
2748
+ htmlFor: `${fieldId}-${opt.value}`,
2749
+ className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
2750
+ children: opt.label
2751
+ }
2752
+ )
2753
+ ] }, String(opt.value)))
2754
+ ]
2755
+ }
2756
+ ),
2757
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
2682
2758
  ] });
2683
2759
  };
2684
2760
  var Table = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -3017,22 +3093,26 @@ var DateWidget = ({ fieldId }) => {
3017
3093
  const { state } = useForm();
3018
3094
  const showError = !!error && (touched || state.submitAttempted);
3019
3095
  if (!fieldDef) return null;
3020
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
3021
- /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, children: [
3096
+ const showLabel = isLabelVisible(fieldDef);
3097
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
3098
+ showLabel ? /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
3022
3099
  fieldDef.label,
3023
3100
  " ",
3024
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
3025
- ] }),
3101
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
3102
+ ] }) : null,
3026
3103
  /* @__PURE__ */ jsxRuntime.jsx("div", { onBlur: () => setTouched(), children: /* @__PURE__ */ jsxRuntime.jsx(
3027
3104
  DatePicker,
3028
3105
  {
3029
3106
  date: value ? new Date(value) : void 0,
3030
3107
  setDate: (date) => setValue(date ? date.toISOString() : void 0),
3031
3108
  placeholder: fieldDef.placeholder,
3032
- className: showError ? "border-red-500 w-full" : "w-full"
3109
+ className: fieldControlClass(
3110
+ fieldDef,
3111
+ showError ? "border-red-500 w-full" : "w-full"
3112
+ )
3033
3113
  }
3034
3114
  ) }),
3035
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
3115
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
3036
3116
  ] });
3037
3117
  };
3038
3118
  function parseTimeString(value) {
@@ -3149,6 +3229,7 @@ var DateTimeWidget = ({ fieldId }) => {
3149
3229
  const showError = !!error && (touched || state.submitAttempted);
3150
3230
  if (!fieldDef) return null;
3151
3231
  const currentDate = value ? new Date(value) : void 0;
3232
+ const showLabel = isLabelVisible(fieldDef);
3152
3233
  const handleChange = (date) => {
3153
3234
  if (!date) {
3154
3235
  setValue(void 0);
@@ -3156,12 +3237,12 @@ var DateTimeWidget = ({ fieldId }) => {
3156
3237
  }
3157
3238
  setValue(date.toISOString());
3158
3239
  };
3159
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
3160
- /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, children: [
3240
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
3241
+ showLabel ? /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
3161
3242
  fieldDef.label,
3162
3243
  " ",
3163
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
3164
- ] }),
3244
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
3245
+ ] }) : null,
3165
3246
  /* @__PURE__ */ jsxRuntime.jsx(
3166
3247
  "div",
3167
3248
  {
@@ -3173,12 +3254,15 @@ var DateTimeWidget = ({ fieldId }) => {
3173
3254
  dateTime: currentDate,
3174
3255
  setDateTime: handleChange,
3175
3256
  placeholder: fieldDef.placeholder,
3176
- className: showError ? "border-red-500 w-full" : "w-full"
3257
+ className: fieldControlClass(
3258
+ fieldDef,
3259
+ showError ? "border-red-500 w-full" : "w-full"
3260
+ )
3177
3261
  }
3178
3262
  )
3179
3263
  }
3180
3264
  ),
3181
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
3265
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
3182
3266
  ] });
3183
3267
  };
3184
3268
  function extractImageDisplayUrl(value) {
@@ -3209,13 +3293,15 @@ var ImageUploadWidget = ({ fieldId }) => {
3209
3293
  }
3210
3294
  };
3211
3295
  if (!fieldDef) return null;
3296
+ const showLabel = isLabelVisible(fieldDef);
3212
3297
  const uploadHandler = store.getUploadHandler();
3213
3298
  if (!uploadHandler) {
3214
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
3215
- /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, children: [
3299
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
3300
+ showLabel ? /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
3216
3301
  fieldDef.label,
3217
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
3218
- ] }),
3302
+ " ",
3303
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
3304
+ ] }) : null,
3219
3305
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-2 border-red-300 rounded-lg p-4 bg-red-50", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-red-600", children: "Upload handler not configured. Please provide an onUpload function in FormProvider config." }) })
3220
3306
  ] });
3221
3307
  }
@@ -3283,49 +3369,59 @@ var ImageUploadWidget = ({ fieldId }) => {
3283
3369
  const handleUploadClick = () => {
3284
3370
  fileInputRef.current?.click();
3285
3371
  };
3286
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
3287
- /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, children: [
3372
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
3373
+ showLabel ? /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
3288
3374
  fieldDef.label,
3289
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
3290
- ] }),
3291
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-2 border-dashed border-gray-300 rounded-lg p-4", children: preview ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
3292
- /* @__PURE__ */ jsxRuntime.jsx(
3293
- "img",
3294
- {
3295
- src: preview,
3296
- alt: "Uploaded image",
3297
- className: "max-w-full max-h-48 mx-auto rounded-lg"
3298
- }
3299
- ),
3300
- /* @__PURE__ */ jsxRuntime.jsx(
3301
- Button,
3302
- {
3303
- type: "button",
3304
- variant: "destructive",
3305
- size: "sm",
3306
- className: "absolute top-2 right-2",
3307
- onClick: handleRemove,
3308
- disabled: disabled || isUploading,
3309
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4" })
3310
- }
3311
- )
3312
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-8", children: [
3313
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Image, { className: "h-12 w-12 mx-auto text-gray-400 mb-4" }),
3314
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-600 mb-4", children: "Click to upload an image or drag and drop" }),
3315
- /* @__PURE__ */ jsxRuntime.jsxs(
3316
- Button,
3317
- {
3318
- type: "button",
3319
- variant: "outline",
3320
- onClick: handleUploadClick,
3321
- disabled: disabled || isUploading,
3322
- children: [
3323
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Upload, { className: "h-4 w-4 mr-2" }),
3324
- isUploading ? "Uploading..." : "Choose Image"
3325
- ]
3326
- }
3327
- )
3328
- ] }) }),
3375
+ " ",
3376
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
3377
+ ] }) : null,
3378
+ /* @__PURE__ */ jsxRuntime.jsx(
3379
+ "div",
3380
+ {
3381
+ className: fieldControlClass(
3382
+ fieldDef,
3383
+ "border-2 border-dashed border-gray-300 rounded-lg p-4"
3384
+ ),
3385
+ children: preview ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
3386
+ /* @__PURE__ */ jsxRuntime.jsx(
3387
+ "img",
3388
+ {
3389
+ src: preview,
3390
+ alt: "Uploaded image",
3391
+ className: "max-w-full max-h-48 mx-auto rounded-lg"
3392
+ }
3393
+ ),
3394
+ /* @__PURE__ */ jsxRuntime.jsx(
3395
+ Button,
3396
+ {
3397
+ type: "button",
3398
+ variant: "destructive",
3399
+ size: "sm",
3400
+ className: "absolute top-2 right-2",
3401
+ onClick: handleRemove,
3402
+ disabled: disabled || isUploading,
3403
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4" })
3404
+ }
3405
+ )
3406
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-8", children: [
3407
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Image, { className: "h-12 w-12 mx-auto text-gray-400 mb-4" }),
3408
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-600 mb-4", children: "Click to upload an image or drag and drop" }),
3409
+ /* @__PURE__ */ jsxRuntime.jsxs(
3410
+ Button,
3411
+ {
3412
+ type: "button",
3413
+ variant: "outline",
3414
+ onClick: handleUploadClick,
3415
+ disabled: disabled || isUploading,
3416
+ children: [
3417
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Upload, { className: "h-4 w-4 mr-2" }),
3418
+ isUploading ? "Uploading..." : "Choose Image"
3419
+ ]
3420
+ }
3421
+ )
3422
+ ] })
3423
+ }
3424
+ ),
3329
3425
  /* @__PURE__ */ jsxRuntime.jsx(
3330
3426
  "input",
3331
3427
  {
@@ -3337,8 +3433,8 @@ var ImageUploadWidget = ({ fieldId }) => {
3337
3433
  disabled: disabled || isUploading
3338
3434
  }
3339
3435
  ),
3340
- fieldDef.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-gray-500", children: fieldDef.description }),
3341
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
3436
+ fieldDef.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldDescriptionClass(fieldDef, "text-xs text-gray-500"), children: fieldDef.description }),
3437
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
3342
3438
  ] });
3343
3439
  };
3344
3440
  function urlLooksLikePdf(url) {
@@ -3380,13 +3476,15 @@ var MediaUploadWidget = ({ fieldId }) => {
3380
3476
  }
3381
3477
  };
3382
3478
  if (!fieldDef) return null;
3479
+ const showLabel = isLabelVisible(fieldDef);
3383
3480
  const uploadHandler = store.getUploadHandler();
3384
3481
  if (!uploadHandler) {
3385
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
3386
- /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, children: [
3482
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
3483
+ showLabel ? /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
3387
3484
  fieldDef.label,
3388
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
3389
- ] }),
3485
+ " ",
3486
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
3487
+ ] }) : null,
3390
3488
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-2 border-red-300 rounded-lg p-4 bg-red-50", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-red-600", children: "Upload handler not configured. Please provide an onUpload function in FormProvider config." }) })
3391
3489
  ] });
3392
3490
  }
@@ -3469,56 +3567,66 @@ var MediaUploadWidget = ({ fieldId }) => {
3469
3567
  const handleUploadClick = () => {
3470
3568
  fileInputRef.current?.click();
3471
3569
  };
3472
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
3473
- /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, children: [
3570
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
3571
+ showLabel ? /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
3474
3572
  fieldDef.label,
3475
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
3476
- ] }),
3477
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-2 border-dashed border-gray-300 rounded-lg p-4", children: preview ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
3478
- previewIsPdf ? /* @__PURE__ */ jsxRuntime.jsx(
3479
- "iframe",
3480
- {
3481
- src: preview,
3482
- title: "Uploaded PDF",
3483
- className: "w-full max-h-48 min-h-36 rounded-lg border border-gray-200 bg-white"
3484
- }
3485
- ) : /* @__PURE__ */ jsxRuntime.jsx(
3486
- "img",
3487
- {
3488
- src: preview,
3489
- alt: "Uploaded image",
3490
- className: "max-w-full max-h-48 mx-auto rounded-lg"
3491
- }
3492
- ),
3493
- /* @__PURE__ */ jsxRuntime.jsx(
3494
- Button,
3495
- {
3496
- type: "button",
3497
- variant: "destructive",
3498
- size: "sm",
3499
- className: "absolute top-2 right-2",
3500
- onClick: handleRemove,
3501
- disabled: disabled || isUploading,
3502
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4" })
3503
- }
3504
- )
3505
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-8", children: [
3506
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Image, { className: "h-12 w-12 mx-auto text-gray-400 mb-4" }),
3507
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-600 mb-4", children: "Click to upload an image or PDF, or drag and drop" }),
3508
- /* @__PURE__ */ jsxRuntime.jsxs(
3509
- Button,
3510
- {
3511
- type: "button",
3512
- variant: "outline",
3513
- onClick: handleUploadClick,
3514
- disabled: disabled || isUploading,
3515
- children: [
3516
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Upload, { className: "h-4 w-4 mr-2" }),
3517
- isUploading ? "Uploading..." : "Choose Image"
3518
- ]
3519
- }
3520
- )
3521
- ] }) }),
3573
+ " ",
3574
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
3575
+ ] }) : null,
3576
+ /* @__PURE__ */ jsxRuntime.jsx(
3577
+ "div",
3578
+ {
3579
+ className: fieldControlClass(
3580
+ fieldDef,
3581
+ "border-2 border-dashed border-gray-300 rounded-lg p-4"
3582
+ ),
3583
+ children: preview ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
3584
+ previewIsPdf ? /* @__PURE__ */ jsxRuntime.jsx(
3585
+ "iframe",
3586
+ {
3587
+ src: preview,
3588
+ title: "Uploaded PDF",
3589
+ className: "w-full max-h-48 min-h-36 rounded-lg border border-gray-200 bg-white"
3590
+ }
3591
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
3592
+ "img",
3593
+ {
3594
+ src: preview,
3595
+ alt: "Uploaded image",
3596
+ className: "max-w-full max-h-48 mx-auto rounded-lg"
3597
+ }
3598
+ ),
3599
+ /* @__PURE__ */ jsxRuntime.jsx(
3600
+ Button,
3601
+ {
3602
+ type: "button",
3603
+ variant: "destructive",
3604
+ size: "sm",
3605
+ className: "absolute top-2 right-2",
3606
+ onClick: handleRemove,
3607
+ disabled: disabled || isUploading,
3608
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4" })
3609
+ }
3610
+ )
3611
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-8", children: [
3612
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Image, { className: "h-12 w-12 mx-auto text-gray-400 mb-4" }),
3613
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-600 mb-4", children: "Click to upload an image or PDF, or drag and drop" }),
3614
+ /* @__PURE__ */ jsxRuntime.jsxs(
3615
+ Button,
3616
+ {
3617
+ type: "button",
3618
+ variant: "outline",
3619
+ onClick: handleUploadClick,
3620
+ disabled: disabled || isUploading,
3621
+ children: [
3622
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Upload, { className: "h-4 w-4 mr-2" }),
3623
+ isUploading ? "Uploading..." : "Choose Image"
3624
+ ]
3625
+ }
3626
+ )
3627
+ ] })
3628
+ }
3629
+ ),
3522
3630
  /* @__PURE__ */ jsxRuntime.jsx(
3523
3631
  "input",
3524
3632
  {
@@ -3530,8 +3638,8 @@ var MediaUploadWidget = ({ fieldId }) => {
3530
3638
  disabled: disabled || isUploading
3531
3639
  }
3532
3640
  ),
3533
- fieldDef.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-gray-500", children: fieldDef.description }),
3534
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
3641
+ fieldDef.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldDescriptionClass(fieldDef, "text-xs text-gray-500"), children: fieldDef.description }),
3642
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
3535
3643
  ] });
3536
3644
  };
3537
3645
  var distance = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
@@ -3720,23 +3828,34 @@ var SignatureUploadWidget = ({ fieldId }) => {
3720
3828
  };
3721
3829
  confirmSignatureRef.current = confirmSignature;
3722
3830
  const canClear = showPreview ? !disabled : hasDrawing || isConfirmed;
3723
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
3724
- /* @__PURE__ */ jsxRuntime.jsxs(Label, { children: [
3831
+ const showLabel = isLabelVisible(fieldDef);
3832
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
3833
+ showLabel ? /* @__PURE__ */ jsxRuntime.jsxs(Label, { className: fieldLabelClass(fieldDef), children: [
3725
3834
  fieldDef.label,
3726
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
3727
- ] }),
3835
+ " ",
3836
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
3837
+ ] }) : null,
3728
3838
  showPreview ? (
3729
3839
  /* ── Preview mode: existing signature from backend ── */
3730
3840
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
3731
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border border-gray-200 rounded bg-white flex items-center justify-start p-2", children: /* @__PURE__ */ jsxRuntime.jsx(
3732
- "img",
3841
+ /* @__PURE__ */ jsxRuntime.jsx(
3842
+ "div",
3733
3843
  {
3734
- src: displayUrl,
3735
- alt: "Signature",
3736
- className: "object-contain max-w-full",
3737
- style: { width: 400, height: 200 }
3844
+ className: fieldControlClass(
3845
+ fieldDef,
3846
+ "border border-gray-200 rounded bg-white flex items-center justify-start p-2"
3847
+ ),
3848
+ children: /* @__PURE__ */ jsxRuntime.jsx(
3849
+ "img",
3850
+ {
3851
+ src: displayUrl,
3852
+ alt: "Signature",
3853
+ className: "object-contain max-w-full",
3854
+ style: { width: 400, height: 200 }
3855
+ }
3856
+ )
3738
3857
  }
3739
- ) }),
3858
+ ),
3740
3859
  /* @__PURE__ */ jsxRuntime.jsx(
3741
3860
  Button,
3742
3861
  {
@@ -3759,7 +3878,10 @@ var SignatureUploadWidget = ({ fieldId }) => {
3759
3878
  "canvas",
3760
3879
  {
3761
3880
  ref: canvasRef,
3762
- className: `border rounded touch-none ${isConfirmed ? "border-green-300 cursor-default" : "border-gray-200 cursor-crosshair"}`,
3881
+ className: fieldControlClass(
3882
+ fieldDef,
3883
+ `border rounded touch-none ${isConfirmed ? "border-green-300 cursor-default" : "border-gray-200 cursor-crosshair"}`
3884
+ ),
3763
3885
  onMouseDown: startDrawing,
3764
3886
  onMouseMove: draw,
3765
3887
  onMouseUp: stopDrawing,
@@ -3804,7 +3926,7 @@ var SignatureUploadWidget = ({ fieldId }) => {
3804
3926
  ] })
3805
3927
  ] })
3806
3928
  ),
3807
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
3929
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
3808
3930
  ] });
3809
3931
  };
3810
3932
  function Upload3({
@@ -3817,7 +3939,8 @@ function Upload3({
3817
3939
  formatsLabel,
3818
3940
  placeholder = "Upload File",
3819
3941
  beforeUploadContent,
3820
- id: idProp
3942
+ id: idProp,
3943
+ listLayout = false
3821
3944
  }) {
3822
3945
  const inputRef = React15__namespace.default.useRef(null);
3823
3946
  const generatedId = React15__namespace.default.useId();
@@ -3858,19 +3981,33 @@ function Upload3({
3858
3981
  "label",
3859
3982
  {
3860
3983
  htmlFor: inputId,
3861
- className: cn("cursor-pointer w-full", disabled && "cursor-not-allowed"),
3862
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: count > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center text-sm font-semibold text-gray-700", children: [
3984
+ className: cn(
3985
+ "cursor-pointer w-full",
3986
+ disabled && "cursor-not-allowed"
3987
+ ),
3988
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: count > 0 && !listLayout ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center text-sm font-semibold text-gray-700", children: [
3863
3989
  count,
3864
3990
  " file",
3865
3991
  count === 1 ? "" : "s",
3866
3992
  " selected"
3867
3993
  ] }) : beforeUploadContent ? beforeUploadContent : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center", children: [
3868
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Upload, { size: 16, className: "rotate-180" }),
3869
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs font-semibold mt-0.5 text-gray-700", children: placeholder }),
3870
- formatsText ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 text-[10px]", children: [
3994
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm text-black font-normal leading-[120%] tracking-[-0.28px] text-center", children: [
3995
+ "Upload your surgery prescription",
3996
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
3997
+ "and medical records"
3998
+ ] }),
3999
+ /* @__PURE__ */ jsxRuntime.jsx(
4000
+ lucideReact.Upload,
4001
+ {
4002
+ size: 20,
4003
+ className: "rotate-180 text-[#727272] mt-4"
4004
+ }
4005
+ ),
4006
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs mt-1 text-text-shades-2", children: placeholder }),
4007
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 text-10px leading-[140%] text-[#989898]", children: [
3871
4008
  "Supported formats - ",
3872
4009
  formatsText
3873
- ] }) : null
4010
+ ] })
3874
4011
  ] }) })
3875
4012
  }
3876
4013
  )
@@ -3897,6 +4034,26 @@ function matchesAccept(file, accept) {
3897
4034
  return type === token;
3898
4035
  });
3899
4036
  }
4037
+ function basenameKey(key) {
4038
+ const parts = key.split("/");
4039
+ return parts[parts.length - 1] || key;
4040
+ }
4041
+ function fileRows(listLayout, localFiles, value) {
4042
+ if (!listLayout) return [];
4043
+ if (localFiles && localFiles.length > 0) {
4044
+ return Array.from(localFiles).map((f, i) => ({ label: f.name, index: i }));
4045
+ }
4046
+ if (Array.isArray(value) && value.length > 0) {
4047
+ return value.map((k, i) => ({
4048
+ label: basenameKey(String(k)),
4049
+ index: i
4050
+ }));
4051
+ }
4052
+ if (value !== null && value !== void 0 && value !== "") {
4053
+ return [{ label: basenameKey(String(value)), index: 0 }];
4054
+ }
4055
+ return [];
4056
+ }
3900
4057
  var FormFileUploadWidget = ({
3901
4058
  fieldId
3902
4059
  }) => {
@@ -3906,22 +4063,55 @@ var FormFileUploadWidget = ({
3906
4063
  const [localFiles, setLocalFiles] = React15.useState(null);
3907
4064
  const [isUploading, setIsUploading] = React15.useState(false);
3908
4065
  const showError = !!error && (touched || state.submitAttempted);
4066
+ const listLayout = fieldDef?.type === "file_upload" && fieldDef.list === true;
4067
+ const rows = React15.useMemo(
4068
+ () => fileRows(listLayout, localFiles, value),
4069
+ [listLayout, localFiles, value]
4070
+ );
3909
4071
  if (!fieldDef || fieldDef.type !== "file_upload") return null;
3910
4072
  const def = fieldDef;
3911
4073
  const accept = def.accept ?? "*/*";
3912
4074
  const maxSize = def.maxSize ?? 10 * 1024 * 1024;
3913
4075
  const allowMultiple = def.multiple === true;
3914
4076
  const uploadHandler = store.getUploadHandler();
4077
+ const showLabel = isLabelVisible(fieldDef);
3915
4078
  if (!uploadHandler) {
3916
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
3917
- /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, children: [
4079
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
4080
+ showLabel ? /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
3918
4081
  fieldDef.label,
3919
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
3920
- ] }),
4082
+ " ",
4083
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
4084
+ ] }) : null,
3921
4085
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-2 border-red-300 rounded-lg p-4 bg-red-50", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-red-600", children: "Upload handler not configured. Please provide an onUpload function in FormProvider config." }) })
3922
4086
  ] });
3923
4087
  }
3924
4088
  const hasStoredValue = value !== null && value !== void 0 && value !== "" && !(Array.isArray(value) && value.length === 0);
4089
+ const removeFileAt = (index) => {
4090
+ setTouched();
4091
+ if (disabled || isUploading) return;
4092
+ const hadLocal = localFiles != null && localFiles.length > 0;
4093
+ if (hadLocal) {
4094
+ const next = Array.from(localFiles).filter((_, i) => i !== index);
4095
+ if (next.length === 0) {
4096
+ setLocalFiles(null);
4097
+ setValue(null);
4098
+ return;
4099
+ }
4100
+ setLocalFiles(fileListFromArray(next));
4101
+ if (allowMultiple && Array.isArray(value)) {
4102
+ setValue(value.filter((_, i) => i !== index));
4103
+ } else {
4104
+ setValue(null);
4105
+ }
4106
+ return;
4107
+ }
4108
+ if (allowMultiple && Array.isArray(value)) {
4109
+ const next = value.filter((_, i) => i !== index);
4110
+ setValue(next.length ? next : null);
4111
+ return;
4112
+ }
4113
+ setValue(null);
4114
+ };
3925
4115
  const handleChange = async (files) => {
3926
4116
  setTouched();
3927
4117
  if (!files || files.length === 0) {
@@ -3968,11 +4158,12 @@ var FormFileUploadWidget = ({
3968
4158
  store.decrementPendingUploads();
3969
4159
  }
3970
4160
  };
3971
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
3972
- /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, children: [
4161
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
4162
+ showLabel ? /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
3973
4163
  fieldDef.label,
3974
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
3975
- ] }),
4164
+ " ",
4165
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
4166
+ ] }) : null,
3976
4167
  /* @__PURE__ */ jsxRuntime.jsx(
3977
4168
  Upload3,
3978
4169
  {
@@ -3981,14 +4172,39 @@ var FormFileUploadWidget = ({
3981
4172
  value: localFiles,
3982
4173
  onChange: handleChange,
3983
4174
  disabled: disabled || isUploading,
4175
+ listLayout,
3984
4176
  placeholder: isUploading ? "Uploading..." : def.uploadPlaceholder ?? "Upload File",
3985
4177
  formatsLabel: def.uploadFormats,
3986
- className: isUploading ? "opacity-70" : void 0
4178
+ className: fieldControlClass(
4179
+ fieldDef,
4180
+ isUploading ? "opacity-70" : void 0
4181
+ )
3987
4182
  }
3988
4183
  ),
3989
- hasStoredValue && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-green-600", children: allowMultiple && Array.isArray(value) ? `${value.length} file(s) uploaded` : "File uploaded" }),
3990
- fieldDef.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-gray-500", children: fieldDef.description }),
3991
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
4184
+ listLayout && rows.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "flex flex-col gap-2 mt-5 list-none p-0 m-0", children: rows.map((row) => /* @__PURE__ */ jsxRuntime.jsxs(
4185
+ "li",
4186
+ {
4187
+ className: "flex items-center justify-between rounded-md bg-white/50 px-3 py-2.5 text-sm text-[#191919] font-normal tracking-[-0.28px]",
4188
+ children: [
4189
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate pr-2", children: row.label }),
4190
+ /* @__PURE__ */ jsxRuntime.jsx(
4191
+ "button",
4192
+ {
4193
+ type: "button",
4194
+ disabled: disabled || isUploading,
4195
+ "aria-label": `Remove ${row.label}`,
4196
+ onClick: () => removeFileAt(row.index),
4197
+ className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-gray-400 text-white hover:bg-gray-500 disabled:opacity-50",
4198
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { size: 14, strokeWidth: 2.5 })
4199
+ }
4200
+ )
4201
+ ]
4202
+ },
4203
+ `${row.index}-${row.label}`
4204
+ )) }) : null,
4205
+ hasStoredValue && !listLayout ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-green-600", children: allowMultiple && Array.isArray(value) ? `${value.length} file(s) uploaded` : "File uploaded" }) : null,
4206
+ fieldDef.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldDescriptionClass(fieldDef, "text-xs text-gray-500"), children: fieldDef.description }),
4207
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
3992
4208
  ] });
3993
4209
  };
3994
4210
  var EditableTableWidget = ({
@@ -4299,12 +4515,22 @@ var RadioWidget = ({ fieldId }) => {
4299
4515
  setValue(opt ? opt.value : val);
4300
4516
  setTouched();
4301
4517
  };
4302
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
4303
- /* @__PURE__ */ jsxRuntime.jsxs(Label, { className: showError ? "text-red-600" : "", children: [
4304
- fieldDef.label,
4305
- " ",
4306
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
4307
- ] }),
4518
+ const showLabel = isLabelVisible(fieldDef);
4519
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
4520
+ showLabel ? /* @__PURE__ */ jsxRuntime.jsxs(
4521
+ Label,
4522
+ {
4523
+ className: fieldLabelClass(
4524
+ fieldDef,
4525
+ showError ? "text-red-600" : ""
4526
+ ),
4527
+ children: [
4528
+ fieldDef.label,
4529
+ " ",
4530
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
4531
+ ]
4532
+ }
4533
+ ) : null,
4308
4534
  /* @__PURE__ */ jsxRuntime.jsx(
4309
4535
  RadioGroup,
4310
4536
  {
@@ -4332,7 +4558,7 @@ var RadioWidget = ({ fieldId }) => {
4332
4558
  }
4333
4559
  ),
4334
4560
  loading && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "Loading options..." }),
4335
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
4561
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
4336
4562
  ] });
4337
4563
  };
4338
4564
  function isOptionSelected(selected, optValue) {
@@ -4364,16 +4590,29 @@ var CheckboxWidget = ({ fieldId }) => {
4364
4590
  setTouched();
4365
4591
  };
4366
4592
  if (!fieldDef) return null;
4367
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
4368
- /* @__PURE__ */ jsxRuntime.jsxs(Label, { className: showError ? "text-red-600" : "", children: [
4369
- fieldDef.label,
4370
- " ",
4371
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
4372
- ] }),
4593
+ const showLabel = isLabelVisible(fieldDef);
4594
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
4595
+ showLabel ? /* @__PURE__ */ jsxRuntime.jsxs(
4596
+ Label,
4597
+ {
4598
+ className: fieldLabelClass(
4599
+ fieldDef,
4600
+ showError ? "text-red-600" : ""
4601
+ ),
4602
+ children: [
4603
+ fieldDef.label,
4604
+ " ",
4605
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
4606
+ ]
4607
+ }
4608
+ ) : null,
4373
4609
  /* @__PURE__ */ jsxRuntime.jsxs(
4374
4610
  "div",
4375
4611
  {
4376
- className: `border rounded-md p-3 space-y-2 ${showError ? "border-red-500" : ""} ${disabled || loading ? "opacity-50 pointer-events-none" : ""}`,
4612
+ className: fieldControlClass(
4613
+ fieldDef,
4614
+ `border rounded-md p-3 space-y-2 ${showError ? "border-red-500" : ""} ${disabled || loading ? "opacity-50 pointer-events-none" : ""}`
4615
+ ),
4377
4616
  children: [
4378
4617
  loading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-muted-foreground", children: "Loading options..." }),
4379
4618
  !loading && options.map((opt) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-2", children: [
@@ -4398,8 +4637,8 @@ var CheckboxWidget = ({ fieldId }) => {
4398
4637
  ]
4399
4638
  }
4400
4639
  ),
4401
- fieldDef.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: fieldDef.description }),
4402
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
4640
+ fieldDef.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldDescriptionClass(fieldDef, "text-xs text-muted-foreground"), children: fieldDef.description }),
4641
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
4403
4642
  ] });
4404
4643
  };
4405
4644
  var AISuggestionsContext = React15.createContext({});
@@ -5893,24 +6132,31 @@ var HiddenVitalsWidget = ({ fieldId }) => {
5893
6132
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5894
6133
  fieldDef.label,
5895
6134
  " ",
5896
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
5897
- ] });
5898
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperClass, "aria-hidden": "true", children: [
5899
- theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, children: labelContent }),
5900
- /* @__PURE__ */ jsxRuntime.jsx(
5901
- Textarea,
5902
- {
5903
- id: fieldId,
5904
- value: value ?? "",
5905
- onChange: (e) => setValue(e.target.value),
5906
- onBlur: setTouched,
5907
- disabled,
5908
- className: inputClass,
5909
- ...height != null && { height }
5910
- }
5911
- ),
5912
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
6135
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
5913
6136
  ] });
6137
+ return /* @__PURE__ */ jsxRuntime.jsxs(
6138
+ "div",
6139
+ {
6140
+ className: fieldWrapperClass(fieldDef, wrapperClass),
6141
+ "aria-hidden": "true",
6142
+ children: [
6143
+ theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef, labelClass), children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: labelContent }),
6144
+ /* @__PURE__ */ jsxRuntime.jsx(
6145
+ Textarea,
6146
+ {
6147
+ id: fieldId,
6148
+ value: value ?? "",
6149
+ onChange: (e) => setValue(e.target.value),
6150
+ onBlur: setTouched,
6151
+ disabled,
6152
+ className: fieldControlClass(fieldDef, inputClass),
6153
+ ...height != null && { height }
6154
+ }
6155
+ ),
6156
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
6157
+ ]
6158
+ }
6159
+ );
5914
6160
  };
5915
6161
  function normalizeOptions(response) {
5916
6162
  if (Array.isArray(response)) {
@@ -5995,10 +6241,10 @@ var ReferralWidget = ({ fieldId }) => {
5995
6241
  [selectedItems, setValue, setTouched]
5996
6242
  );
5997
6243
  if (!fieldDef) return null;
5998
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
5999
- /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, children: [
6244
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
6245
+ /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
6000
6246
  "Referral to ",
6001
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
6247
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
6002
6248
  ] }),
6003
6249
  loading && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "Loading..." }),
6004
6250
  !loading && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -6013,7 +6259,14 @@ var ReferralWidget = ({ fieldId }) => {
6013
6259
  }
6014
6260
  },
6015
6261
  children: [
6016
- /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { id: fieldId, className: showError ? "border-red-500" : "", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select specializations..." }) }),
6262
+ /* @__PURE__ */ jsxRuntime.jsx(
6263
+ SelectTrigger,
6264
+ {
6265
+ id: fieldId,
6266
+ className: fieldControlClass(fieldDef, showError ? "border-red-500" : ""),
6267
+ children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select specializations..." })
6268
+ }
6269
+ ),
6017
6270
  /* @__PURE__ */ jsxRuntime.jsxs(SelectContent, { children: [
6018
6271
  availableOptions.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: opt.value, children: opt.label }, opt.value)),
6019
6272
  availableOptions.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-2 px-2 text-sm text-muted-foreground", children: "All specializations selected" })
@@ -6057,7 +6310,7 @@ var ReferralWidget = ({ fieldId }) => {
6057
6310
  selectedItems.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground mt-1", children: "No specializations selected" }),
6058
6311
  selectedItems.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground mt-1.5", children: "Click a chip to mark as urgent" })
6059
6312
  ] }),
6060
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
6313
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
6061
6314
  ] });
6062
6315
  };
6063
6316
  var Card = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
@@ -6556,29 +6809,41 @@ var SmartTextareaWidget = ({ fieldId }) => {
6556
6809
  const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
6557
6810
  const labelClass = theme?.labelClassName;
6558
6811
  const inputClass = cn(theme?.inputClassName, showError && "border-red-500");
6812
+ const showLabel = isLabelVisible(def);
6559
6813
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6560
6814
  def.label,
6561
6815
  " ",
6562
- def.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" }),
6816
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef: def }),
6563
6817
  isProcessing && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "inline-block ml-1.5 h-3 w-3 animate-spin text-muted-foreground" })
6564
6818
  ] });
6565
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperClass, children: [
6566
- theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, children: labelContent }),
6567
- /* @__PURE__ */ jsxRuntime.jsx(
6568
- Textarea,
6569
- {
6570
- id: fieldId,
6571
- value: textValue,
6572
- onChange: handleTextChange,
6573
- onBlur: setTouched,
6574
- disabled,
6575
- placeholder: def.placeholder,
6576
- className: inputClass,
6577
- ...height != null ? { height } : {}
6578
- }
6579
- ),
6580
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
6581
- ] });
6819
+ const labelEl = showLabel ? theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(def, labelClass), children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(def), children: labelContent }) : null;
6820
+ return /* @__PURE__ */ jsxRuntime.jsxs(
6821
+ "div",
6822
+ {
6823
+ className: fieldWrapperClass(
6824
+ def,
6825
+ wrapperClass
6826
+ ),
6827
+ children: [
6828
+ labelEl,
6829
+ /* @__PURE__ */ jsxRuntime.jsx(
6830
+ Textarea,
6831
+ {
6832
+ id: fieldId,
6833
+ value: textValue,
6834
+ onChange: handleTextChange,
6835
+ onBlur: setTouched,
6836
+ disabled,
6837
+ placeholder: def.placeholder,
6838
+ className: fieldControlClass(def, inputClass),
6839
+ "aria-label": !showLabel ? def.label : void 0,
6840
+ ...height != null ? { height } : {}
6841
+ }
6842
+ ),
6843
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(def, "text-xs text-red-500"), children: error })
6844
+ ]
6845
+ }
6846
+ );
6582
6847
  };
6583
6848
  function normalizeDiagnosisGrades(payload) {
6584
6849
  const result = [];
@@ -6698,10 +6963,11 @@ var DiagnosisTextareaWidget = ({ fieldId }) => {
6698
6963
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6699
6964
  def.label,
6700
6965
  " ",
6701
- def.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
6966
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef: def })
6702
6967
  ] });
6703
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperClass, children: [
6704
- theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, children: labelContent }),
6968
+ const showLabel = isLabelVisible(def);
6969
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(def, wrapperClass), children: [
6970
+ showLabel ? theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(def, labelClass), children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(def), children: labelContent }) : null,
6705
6971
  /* @__PURE__ */ jsxRuntime.jsx(
6706
6972
  Textarea,
6707
6973
  {
@@ -6711,7 +6977,8 @@ var DiagnosisTextareaWidget = ({ fieldId }) => {
6711
6977
  onBlur: setTouched,
6712
6978
  disabled,
6713
6979
  placeholder: def.placeholder,
6714
- className: inputClass,
6980
+ className: fieldControlClass(def, inputClass),
6981
+ "aria-label": !showLabel ? def.label : void 0,
6715
6982
  ...def.height != null ? { height: def.height } : {}
6716
6983
  }
6717
6984
  ),
@@ -6745,7 +7012,7 @@ var DiagnosisTextareaWidget = ({ fieldId }) => {
6745
7012
  ] }, group.condition))
6746
7013
  }
6747
7014
  ),
6748
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
7015
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(def, "text-xs text-red-500"), children: error })
6749
7016
  ] });
6750
7017
  };
6751
7018
  var Switch = React15__namespace.forwardRef(
@@ -10065,7 +10332,7 @@ var OrthopedicExamWidget = ({ fieldId }) => {
10065
10332
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `space-y-4 relative ${disabled ? "opacity-60 pointer-events-none" : ""}`, children: [
10066
10333
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxRuntime.jsxs(Label, { className: "text-sm font-medium", children: [
10067
10334
  fieldDef.label,
10068
- fieldDef.required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 ml-1", children: "*" }) : null
10335
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
10069
10336
  ] }) }),
10070
10337
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
10071
10338
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs font-semibold text-muted-foreground", children: "Concern" }),
@@ -10256,26 +10523,30 @@ var MarMedicationOrdersWidget = ({ fieldId }) => {
10256
10523
  const theme = getThemeConfig("textarea", fieldDef.theme);
10257
10524
  const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
10258
10525
  const labelClass = theme?.labelClassName;
10526
+ const showLabel = isLabelVisible(fieldDef);
10259
10527
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10260
10528
  fieldDef.label,
10261
10529
  " ",
10262
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
10530
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
10263
10531
  ] });
10264
- const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, children: labelContent });
10532
+ const labelEl = showLabel ? theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef, labelClass), children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: labelContent }) : null;
10265
10533
  const text = typeof value === "string" ? value : value == null ? "" : String(value);
10266
10534
  const hasHandler = typeof handlers.onOpenMedicationOrders === "function";
10267
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperClass, children: [
10535
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, wrapperClass), children: [
10268
10536
  labelEl,
10269
- fieldDef.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: fieldDef.description }),
10537
+ fieldDef.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldDescriptionClass(fieldDef, "text-sm text-muted-foreground"), children: fieldDef.description }),
10270
10538
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-3", children: [
10271
10539
  /* @__PURE__ */ jsxRuntime.jsx(
10272
10540
  "div",
10273
10541
  {
10274
10542
  id: fieldId,
10275
- className: cn(
10276
- "min-h-[80px] flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm whitespace-pre-wrap",
10277
- showError && "border-red-500",
10278
- !text && "text-muted-foreground"
10543
+ className: fieldControlClass(
10544
+ fieldDef,
10545
+ cn(
10546
+ "min-h-[80px] flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm whitespace-pre-wrap",
10547
+ showError && "border-red-500",
10548
+ !text && "text-muted-foreground"
10549
+ )
10279
10550
  ),
10280
10551
  style: height != null ? { minHeight: height } : void 0,
10281
10552
  "aria-readonly": "true",
@@ -10294,7 +10565,7 @@ var MarMedicationOrdersWidget = ({ fieldId }) => {
10294
10565
  }
10295
10566
  )
10296
10567
  ] }),
10297
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
10568
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
10298
10569
  ] });
10299
10570
  };
10300
10571
  function parseFieldValue(value) {
@@ -10374,22 +10645,25 @@ var DischargeMedicationOrdersWidget = ({ fieldId }) => {
10374
10645
  [orders, display_lines, setTouched, setValue]
10375
10646
  );
10376
10647
  if (!visible || !fieldDef) return null;
10377
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
10648
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
10378
10649
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
10379
- /* @__PURE__ */ jsxRuntime.jsxs(Label, { className: "text-sm font-medium", children: [
10650
+ /* @__PURE__ */ jsxRuntime.jsxs(Label, { className: fieldLabelClass(fieldDef, "text-sm font-medium"), children: [
10380
10651
  fieldDef.label,
10381
10652
  " ",
10382
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
10653
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
10383
10654
  ] }),
10384
10655
  /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "button", onClick: onAdd, disabled: disabled || !handlers.onOpenDischargeMedicationOrders, children: "Add medicine" })
10385
10656
  ] }),
10386
- fieldDef.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: fieldDef.description }),
10657
+ fieldDef.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldDescriptionClass(fieldDef, "text-sm text-muted-foreground"), children: fieldDef.description }),
10387
10658
  orders.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(
10388
10659
  "div",
10389
10660
  {
10390
- className: cn(
10391
- "rounded-md border border-input bg-background px-3 py-3 text-sm text-muted-foreground",
10392
- showError && "border-red-500"
10661
+ className: fieldControlClass(
10662
+ fieldDef,
10663
+ cn(
10664
+ "rounded-md border border-input bg-background px-3 py-3 text-sm text-muted-foreground",
10665
+ showError && "border-red-500"
10666
+ )
10393
10667
  ),
10394
10668
  children: "No medicines added."
10395
10669
  }
@@ -10438,7 +10712,7 @@ var DischargeMedicationOrdersWidget = ({ fieldId }) => {
10438
10712
  ] })
10439
10713
  ] }, o.id);
10440
10714
  }) }),
10441
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
10715
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
10442
10716
  ] });
10443
10717
  };
10444
10718
  var DEFAULT_TOKEN_SEPARATOR2 = ", ";
@@ -10540,13 +10814,15 @@ var SuggestionTextareaWidget = ({ fieldId }) => {
10540
10814
  const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
10541
10815
  const labelClass = theme?.labelClassName;
10542
10816
  const inputClass = cn(theme?.inputClassName, showError && "border-red-500");
10817
+ const inputWithStyle = fieldControlClass(def, inputClass);
10543
10818
  const height = def.height != null ? typeof def.height === "string" ? Number(def.height) || void 0 : def.height : void 0;
10544
10819
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10545
10820
  def.label,
10546
10821
  " ",
10547
- def.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
10822
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef: def })
10548
10823
  ] });
10549
- const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { children: labelContent });
10824
+ const showLabel = isLabelVisible(def);
10825
+ const labelEl = showLabel ? theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: fieldLabelClass(def, labelClass), children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: fieldLabelClass(def), children: labelContent }) : null;
10550
10826
  const onChipClick = (optValue) => {
10551
10827
  if (disabled) return;
10552
10828
  setValue(toggleSuggestionTokenInText(textValue, String(optValue), appendSeparator, chipAllowedSet));
@@ -10570,7 +10846,7 @@ var SuggestionTextareaWidget = ({ fieldId }) => {
10570
10846
  disabled && "pointer-events-none opacity-50"
10571
10847
  );
10572
10848
  const textareaShellClass = cn(
10573
- inputClass,
10849
+ inputWithStyle,
10574
10850
  hasShell && cn(
10575
10851
  "mt-0 rounded-t-none rounded-b-md border-0 shadow-none focus-visible:ring-offset-0",
10576
10852
  isHighlightLabel ? "border-t-0" : "min-h-[80px]"
@@ -10592,12 +10868,12 @@ var SuggestionTextareaWidget = ({ fieldId }) => {
10592
10868
  String(opt.value)
10593
10869
  );
10594
10870
  });
10595
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperClass, children: [
10871
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(def, wrapperClass), children: [
10596
10872
  hasVoice ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
10597
10873
  labelEl,
10598
10874
  /* @__PURE__ */ jsxRuntime.jsx(VoiceMicButton, { fieldId, onTranscriptReady: setValue })
10599
10875
  ] }) : labelEl,
10600
- def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: def.description }),
10876
+ def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldDescriptionClass(def, "text-xs text-muted-foreground"), children: def.description }),
10601
10877
  hasShell ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: suggestionShellClass, children: [
10602
10878
  hasSuggestions && /* @__PURE__ */ jsxRuntime.jsx("div", { className: chipsRowClass, role: "group", "aria-label": suggestionsAria, children: suggestionButtons }),
10603
10879
  hasEmbedded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: embeddedRowClass, children: embeddedFieldIds.map((id) => /* @__PURE__ */ jsxRuntime.jsx(EmbeddedSchemaField, { fieldId: id }, id)) }),
@@ -10611,7 +10887,8 @@ var SuggestionTextareaWidget = ({ fieldId }) => {
10611
10887
  disabled,
10612
10888
  className: textareaShellClass,
10613
10889
  placeholder: def.placeholder,
10614
- style: height != null && Number.isFinite(height) ? { minHeight: height } : void 0
10890
+ style: height != null && Number.isFinite(height) ? { minHeight: height } : void 0,
10891
+ "aria-label": !showLabel ? def.label : void 0
10615
10892
  }
10616
10893
  )
10617
10894
  ] }) : /* @__PURE__ */ jsxRuntime.jsx(
@@ -10622,12 +10899,13 @@ var SuggestionTextareaWidget = ({ fieldId }) => {
10622
10899
  onChange: (e) => setValue(e.target.value),
10623
10900
  onBlur: setTouched,
10624
10901
  disabled,
10625
- className: inputClass,
10902
+ className: inputWithStyle,
10626
10903
  placeholder: def.placeholder,
10627
- style: height != null && Number.isFinite(height) ? { minHeight: height } : void 0
10904
+ style: height != null && Number.isFinite(height) ? { minHeight: height } : void 0,
10905
+ "aria-label": !showLabel ? def.label : void 0
10628
10906
  }
10629
10907
  ),
10630
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
10908
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(def, "text-xs text-red-500"), children: error })
10631
10909
  ] });
10632
10910
  };
10633
10911
  var EMPTY_GRADES = { NO: 0, NC: 0, C: 0, PSC: 0 };
@@ -11394,23 +11672,27 @@ var SliderWidget = ({ fieldId }) => {
11394
11672
  const theme = getThemeConfig("textarea", def.theme);
11395
11673
  const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
11396
11674
  const labelClass = theme?.labelClassName;
11675
+ const showLabel = isLabelVisible(def);
11397
11676
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
11398
11677
  def.label,
11399
11678
  " ",
11400
- def.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" }),
11679
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef: def }),
11401
11680
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-2 text-muted-foreground font-normal tabular-nums", children: [
11402
11681
  num2,
11403
11682
  "/",
11404
11683
  max
11405
11684
  ] })
11406
11685
  ] });
11407
- const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { children: labelContent });
11408
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperClass, children: [
11686
+ const labelEl = showLabel ? theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: fieldLabelClass(def, labelClass), children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: fieldLabelClass(def), children: labelContent }) : null;
11687
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(def, wrapperClass), children: [
11409
11688
  labelEl,
11410
11689
  /* @__PURE__ */ jsxRuntime.jsx(
11411
11690
  Slider,
11412
11691
  {
11413
- className: cn("py-1", showError && "opacity-90 ring-1 ring-red-500 rounded"),
11692
+ className: fieldControlClass(
11693
+ def,
11694
+ cn("py-1", showError && "opacity-90 ring-1 ring-red-500 rounded")
11695
+ ),
11414
11696
  disabled,
11415
11697
  min,
11416
11698
  max,
@@ -11420,10 +11702,11 @@ var SliderWidget = ({ fieldId }) => {
11420
11702
  const n = v[0] ?? min;
11421
11703
  setValue(n);
11422
11704
  setTouched();
11423
- }
11705
+ },
11706
+ "aria-label": !showLabel ? `${def.label} ${num2}/${max}` : void 0
11424
11707
  }
11425
11708
  ),
11426
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
11709
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(def, "text-xs text-red-500"), children: error })
11427
11710
  ] });
11428
11711
  };
11429
11712
  var CHIEF_CHIPS_FIELD = "chief_complaints_chips";
@@ -11536,7 +11819,7 @@ var GsSmartHistoryWidget = ({ fieldId }) => {
11536
11819
  const labelClass = theme?.labelClassName;
11537
11820
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
11538
11821
  fieldDef.label,
11539
- fieldDef.required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
11822
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
11540
11823
  ] });
11541
11824
  const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: labelContent });
11542
11825
  const bodyClass = cn(
@@ -11939,7 +12222,7 @@ var GsExaminationWidget = ({ fieldId }) => {
11939
12222
  const labelClass = theme?.labelClassName;
11940
12223
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
11941
12224
  fieldDef.label,
11942
- fieldDef.required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
12225
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
11943
12226
  ] });
11944
12227
  const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: labelContent });
11945
12228
  const bodyClass = cn(
@@ -12350,7 +12633,7 @@ var GsGradingWidget = ({ fieldId }) => {
12350
12633
  const labelClass = theme?.labelClassName;
12351
12634
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12352
12635
  fieldDef.label,
12353
- fieldDef.required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
12636
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
12354
12637
  ] });
12355
12638
  const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: labelContent });
12356
12639
  const bodyClass = cn(
@@ -12409,6 +12692,7 @@ var PainScaleFlagsWidget = ({ fieldId }) => {
12409
12692
  const theme = getThemeConfig("textarea", def.theme);
12410
12693
  const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
12411
12694
  const labelClass = theme?.labelClassName;
12695
+ const showLabel = isLabelVisible(def);
12412
12696
  const update = (next) => {
12413
12697
  setValue(normalizePainScaleFlags(next, { min, max }));
12414
12698
  setTouched();
@@ -12424,16 +12708,16 @@ var PainScaleFlagsWidget = ({ fieldId }) => {
12424
12708
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12425
12709
  def.label,
12426
12710
  " ",
12427
- def.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
12711
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef: def })
12428
12712
  ] });
12429
- const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { children: labelContent });
12713
+ const labelEl = showLabel ? theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: fieldLabelClass(def, labelClass), children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: fieldLabelClass(def), children: labelContent }) : null;
12430
12714
  const bodyClass = cn(
12431
12715
  "-mt-1 flex min-w-0 flex-col border-t border-[#D0D0D0] bg-white px-3 py-3",
12432
12716
  disabled && "pointer-events-none opacity-60"
12433
12717
  );
12434
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(wrapperClass, "h-full min-h-0 flex flex-col"), children: [
12718
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(def, cn(wrapperClass, "h-full min-h-0 flex flex-col")), children: [
12435
12719
  labelEl,
12436
- def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: def.description }),
12720
+ def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldDescriptionClass(def, "text-xs text-muted-foreground"), children: def.description }),
12437
12721
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(bodyClass, "min-h-0 flex-1"), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 space-y-3", children: [
12438
12722
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
12439
12723
  /* @__PURE__ */ jsxRuntime.jsxs(Label, { className: "text-sm font-medium text-slate-700", children: [
@@ -12519,7 +12803,7 @@ var PainScaleFlagsWidget = ({ fieldId }) => {
12519
12803
  ] }) : null
12520
12804
  ] }) : null
12521
12805
  ] }) }),
12522
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
12806
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(def, "text-xs text-red-500"), children: error })
12523
12807
  ] });
12524
12808
  };
12525
12809
  var CHIEF_CHIPS_FIELD3 = "chief_complaints_chips";
@@ -12674,7 +12958,7 @@ var UrologySmartHistoryWidget = ({ fieldId }) => {
12674
12958
  const labelClass = theme?.labelClassName;
12675
12959
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12676
12960
  fieldDef.label,
12677
- fieldDef.required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
12961
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
12678
12962
  ] });
12679
12963
  const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: labelContent });
12680
12964
  const bodyClass = cn(
@@ -13037,7 +13321,7 @@ var UrologyExaminationWidget = ({ fieldId }) => {
13037
13321
  const labelClass = theme?.labelClassName;
13038
13322
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
13039
13323
  fieldDef.label,
13040
- fieldDef.required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
13324
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
13041
13325
  ] });
13042
13326
  const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: labelContent });
13043
13327
  const bodyClass = cn(
@@ -13263,7 +13547,7 @@ var UrologyPathwayWidget = ({ fieldId }) => {
13263
13547
  const subtitle = fieldDef.meta && typeof fieldDef.meta === "object" && fieldDef.meta !== null ? String(fieldDef.meta.subtitle ?? "") : "";
13264
13548
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
13265
13549
  fieldDef.label,
13266
- fieldDef.required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
13550
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
13267
13551
  ] });
13268
13552
  const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: labelContent });
13269
13553
  const bodyClass = cn(
@@ -13458,7 +13742,7 @@ var OBGExaminationWidget = ({ fieldId }) => {
13458
13742
  const labelClass = theme?.labelClassName;
13459
13743
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
13460
13744
  fieldDef.label,
13461
- fieldDef.required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
13745
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
13462
13746
  ] });
13463
13747
  const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: labelContent });
13464
13748
  const bodyClass = cn(
@@ -13591,7 +13875,7 @@ var OBGPathwayWidget = ({ fieldId }) => {
13591
13875
  const labelClass = theme?.labelClassName;
13592
13876
  const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
13593
13877
  fieldDef.label,
13594
- fieldDef.required ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
13878
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
13595
13879
  ] });
13596
13880
  const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium", children: labelContent });
13597
13881
  const bodyClass = cn(
@@ -14079,6 +14363,7 @@ var PhoneInputWidget = ({ fieldId }) => {
14079
14363
  return () => clearTimeout(t);
14080
14364
  }, [resendCooldown]);
14081
14365
  if (!fieldDef) return null;
14366
+ const showLabel = isLabelVisible(fieldDef);
14082
14367
  const placeholder = typeof fieldDef.placeholder === "string" && fieldDef.placeholder.trim() ? fieldDef.placeholder : "Enter 10-digit mobile number";
14083
14368
  const handleChange = (e) => {
14084
14369
  const digits = e.target.value.replace(/\D/g, "").slice(0, 10);
@@ -14160,12 +14445,12 @@ var PhoneInputWidget = ({ fieldId }) => {
14160
14445
  isResendingRef.current = false;
14161
14446
  }
14162
14447
  };
14163
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
14164
- /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, children: [
14448
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
14449
+ showLabel ? /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
14165
14450
  fieldDef.label,
14166
14451
  " ",
14167
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
14168
- ] }),
14452
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
14453
+ ] }) : null,
14169
14454
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
14170
14455
  /* @__PURE__ */ jsxRuntime.jsx(
14171
14456
  Input,
@@ -14179,11 +14464,15 @@ var PhoneInputWidget = ({ fieldId }) => {
14179
14464
  disabled: disabled || status === "sending",
14180
14465
  placeholder,
14181
14466
  maxLength: 10,
14182
- className: cn(
14183
- showError && "border-red-500",
14184
- status === "sent" && "border-green-500 pr-9",
14185
- status === "sending" && "pr-9"
14186
- )
14467
+ className: fieldControlClass(
14468
+ fieldDef,
14469
+ cn(
14470
+ showError && "border-red-500",
14471
+ status === "sent" && "border-green-500 pr-9",
14472
+ status === "sending" && "pr-9"
14473
+ )
14474
+ ),
14475
+ "aria-label": !showLabel ? fieldDef.label : void 0
14187
14476
  }
14188
14477
  ),
14189
14478
  status === "sending" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-y-0 right-3 flex items-center pointer-events-none", children: /* @__PURE__ */ jsxRuntime.jsxs(
@@ -14236,7 +14525,7 @@ var PhoneInputWidget = ({ fieldId }) => {
14236
14525
  "OTP sent to +91",
14237
14526
  rawPhone
14238
14527
  ] }),
14239
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error }),
14528
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error }),
14240
14529
  status === "sent" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [
14241
14530
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Didn't receive it?" }),
14242
14531
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -14269,6 +14558,7 @@ var OtpInputWidget = ({ fieldId }) => {
14269
14558
  const isVerifyingRef = React15.useRef(false);
14270
14559
  const showError = !!error && (touched || state.submitAttempted) && status !== "verifying" && status !== "verified";
14271
14560
  if (!fieldDef) return null;
14561
+ const showLabel = isLabelVisible(fieldDef);
14272
14562
  const placeholder = typeof fieldDef.placeholder === "string" && fieldDef.placeholder.trim() ? fieldDef.placeholder : "Enter 4-digit OTP";
14273
14563
  const handleChange = (e) => {
14274
14564
  const digits = e.target.value.replace(/\D/g, "").slice(0, 4);
@@ -14322,12 +14612,12 @@ var OtpInputWidget = ({ fieldId }) => {
14322
14612
  isVerifyingRef.current = false;
14323
14613
  }
14324
14614
  };
14325
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
14326
- /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, children: [
14615
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
14616
+ showLabel ? /* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
14327
14617
  fieldDef.label,
14328
14618
  " ",
14329
- fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
14330
- ] }),
14619
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
14620
+ ] }) : null,
14331
14621
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
14332
14622
  /* @__PURE__ */ jsxRuntime.jsx(
14333
14623
  Input,
@@ -14341,12 +14631,16 @@ var OtpInputWidget = ({ fieldId }) => {
14341
14631
  disabled: disabled || status === "verifying" || status === "verified",
14342
14632
  placeholder,
14343
14633
  maxLength: 4,
14344
- className: cn(
14345
- "tracking-widest text-center text-lg",
14346
- showError && "border-red-500",
14347
- status === "verified" && "border-green-500 pr-9",
14348
- status === "verifying" && "pr-9"
14349
- )
14634
+ className: fieldControlClass(
14635
+ fieldDef,
14636
+ cn(
14637
+ "tracking-widest text-center text-lg",
14638
+ showError && "border-red-500",
14639
+ status === "verified" && "border-green-500 pr-9",
14640
+ status === "verifying" && "pr-9"
14641
+ )
14642
+ ),
14643
+ "aria-label": !showLabel ? fieldDef.label : void 0
14350
14644
  }
14351
14645
  ),
14352
14646
  status === "verifying" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-y-0 right-3 flex items-center pointer-events-none", children: /* @__PURE__ */ jsxRuntime.jsxs(
@@ -14396,7 +14690,7 @@ var OtpInputWidget = ({ fieldId }) => {
14396
14690
  ) })
14397
14691
  ] }),
14398
14692
  status === "verified" && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-green-600", children: "Mobile number verified successfully" }),
14399
- showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
14693
+ showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
14400
14694
  ] });
14401
14695
  };
14402
14696
  var FieldRenderer = ({ fieldId }) => {
@@ -14500,7 +14794,8 @@ function renderWidget(fieldId, fieldDef) {
14500
14794
  const { value, setValue, setTouched, disabled } = useField(fieldId);
14501
14795
  const store = useFormStore();
14502
14796
  const excludes = fieldDef.excludes ?? [];
14503
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
14797
+ const showLabel = isLabelVisible(fieldDef);
14798
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: fieldWrapperClass(fieldDef, "flex items-center gap-3"), children: [
14504
14799
  /* @__PURE__ */ jsxRuntime.jsx(
14505
14800
  Switch,
14506
14801
  {
@@ -14513,7 +14808,20 @@ function renderWidget(fieldId, fieldDef) {
14513
14808
  }
14514
14809
  }
14515
14810
  ),
14516
- /* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium leading-none cursor-pointer select-none", children: fieldDef.label })
14811
+ showLabel ? /* @__PURE__ */ jsxRuntime.jsxs(
14812
+ Label,
14813
+ {
14814
+ className: fieldLabelClass(
14815
+ fieldDef,
14816
+ "text-sm font-medium leading-none cursor-pointer select-none"
14817
+ ),
14818
+ children: [
14819
+ fieldDef.label,
14820
+ " ",
14821
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRequiredIndicator, { fieldDef })
14822
+ ]
14823
+ }
14824
+ ) : null
14517
14825
  ] });
14518
14826
  }
14519
14827
  case "suggestion_textarea":
@@ -14532,10 +14840,19 @@ function renderWidget(fieldId, fieldDef) {
14532
14840
  const size = def.size ?? "regular";
14533
14841
  const labelClass = size === "large" ? "text-base" : "text-sm";
14534
14842
  const descClass = size === "large" ? "text-sm" : "text-xs";
14535
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${labelClass} text-muted-foreground`, children: [
14536
- def.label,
14537
- def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: `mt-1 ${descClass} opacity-90`, children: def.description })
14538
- ] });
14843
+ return /* @__PURE__ */ jsxRuntime.jsxs(
14844
+ "div",
14845
+ {
14846
+ className: fieldWrapperClass(
14847
+ def,
14848
+ cn(labelClass, "text-muted-foreground")
14849
+ ),
14850
+ children: [
14851
+ def.label,
14852
+ def.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: fieldDescriptionClass(def, cn("mt-1", descClass, "opacity-90")), children: def.description })
14853
+ ]
14854
+ }
14855
+ );
14539
14856
  }
14540
14857
  default:
14541
14858
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-red-500", children: [
@@ -15916,7 +16233,7 @@ var FormControls = ({
15916
16233
  "div",
15917
16234
  {
15918
16235
  className: cn(
15919
- "flex gap-4 border-t bg-white p-4 items-center",
16236
+ "flex gap-4 border-t p-4 items-center",
15920
16237
  showWorkflowStatus ? "justify-between" : useWideActions ? "flex-col sm:flex-row sm:justify-stretch sm:gap-4" : "justify-end",
15921
16238
  className
15922
16239
  ),
@@ -16041,6 +16358,7 @@ exports.DynamicForm = DynamicForm;
16041
16358
  exports.DynamicFormV2 = DynamicFormV2;
16042
16359
  exports.EMAIL_REGEX = EMAIL_REGEX;
16043
16360
  exports.FieldRenderer = FieldRenderer;
16361
+ exports.FieldRequiredIndicator = FieldRequiredIndicator;
16044
16362
  exports.FormControls = FormControls;
16045
16363
  exports.FormFileUploadWidget = FormFileUploadWidget;
16046
16364
  exports.FormProvider = FormProvider;
@@ -16061,7 +16379,13 @@ exports.SmartTextareaWidget = SmartTextareaWidget;
16061
16379
  exports.Upload = Upload3;
16062
16380
  exports.createUploadHandler = createUploadHandler;
16063
16381
  exports.evaluateRules = evaluateRules;
16382
+ exports.fieldControlClass = fieldControlClass;
16383
+ exports.fieldDescriptionClass = fieldDescriptionClass;
16384
+ exports.fieldErrorClass = fieldErrorClass;
16385
+ exports.fieldLabelClass = fieldLabelClass;
16064
16386
  exports.fieldMetaRequestsMarMedicationOrdersButton = fieldMetaRequestsMarMedicationOrdersButton;
16387
+ exports.fieldWrapperClass = fieldWrapperClass;
16388
+ exports.isLabelVisible = isLabelVisible;
16065
16389
  exports.useField = useField;
16066
16390
  exports.useFieldHandlers = useFieldHandlers;
16067
16391
  exports.useForm = useForm;