formanitor 0.0.49 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as React15 from 'react';
2
2
  import React15__default, { createContext, useContext, useRef, useEffect, useState, useMemo, useCallback, useReducer } from 'react';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
- import { ChevronDown, ChevronUp, Check, Circle, X, Image, Upload, Trash2, Plus, Loader2, PenTool, Mic, Undo, Redo, ChevronRight, Calendar as Calendar$1, ChevronLeft, RefreshCw, Clock, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered } from 'lucide-react';
5
4
  import { clsx } from 'clsx';
6
5
  import { twMerge } from 'tailwind-merge';
6
+ import { ChevronDown, ChevronUp, Check, Circle, X, Image, Upload, Trash2, Plus, Loader2, PenTool, Mic, Undo, Redo, ChevronRight, Calendar as Calendar$1, ChevronLeft, RefreshCw, Clock, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered } from 'lucide-react';
7
7
  import * as LabelPrimitive from '@radix-ui/react-label';
8
8
  import { cva } from 'class-variance-authority';
9
9
  import { useEditor, EditorContent } from '@tiptap/react';
@@ -1513,16 +1513,28 @@ var FormStore = class {
1513
1513
  result[field.id] = null;
1514
1514
  return;
1515
1515
  }
1516
- if (field.type === "image_upload" || field.type === "media_upload" || field.type === "signature") {
1516
+ if (field.type === "image_upload" || field.type === "media_upload" || field.type === "signature" || field.type === "file_upload") {
1517
1517
  const raw = values[field.id];
1518
- if (raw !== void 0 && raw !== null && raw !== "") {
1519
- const key = typeof raw === "string" ? raw : raw.s3_key || raw.value || null;
1520
- if (key && typeof key === "string") {
1521
- result[field.id] = {
1522
- _type: "s3_key",
1523
- value: key
1524
- };
1518
+ if (raw === void 0 || raw === null || raw === "") {
1519
+ return;
1520
+ }
1521
+ const wrapKey = (key2) => {
1522
+ if (typeof key2 !== "string" || !key2) return null;
1523
+ return { _type: "s3_key", value: key2 };
1524
+ };
1525
+ if (Array.isArray(raw)) {
1526
+ const wrapped2 = raw.map(
1527
+ (item) => typeof item === "string" ? wrapKey(item) : wrapKey(item.s3_key ?? item.value)
1528
+ ).filter(Boolean);
1529
+ if (wrapped2.length > 0) {
1530
+ result[field.id] = wrapped2;
1525
1531
  }
1532
+ return;
1533
+ }
1534
+ const key = typeof raw === "string" ? raw : raw.s3_key ?? raw.value ?? null;
1535
+ const wrapped = wrapKey(key);
1536
+ if (wrapped) {
1537
+ result[field.id] = wrapped;
1526
1538
  }
1527
1539
  }
1528
1540
  });
@@ -1879,6 +1891,9 @@ function useField(fieldId) {
1879
1891
  setTouched
1880
1892
  };
1881
1893
  }
1894
+ function cn(...inputs) {
1895
+ return twMerge(clsx(inputs));
1896
+ }
1882
1897
  function RecordingWave() {
1883
1898
  const bars = [
1884
1899
  { dur: "0.6s", values: "3;10;3", yValues: "4.5;0;4.5", delay: "0s" },
@@ -1945,9 +1960,6 @@ function VoiceMicButton({ fieldId, onTranscriptReady }) {
1945
1960
  }
1946
1961
  );
1947
1962
  }
1948
- function cn(...inputs) {
1949
- return twMerge(clsx(inputs));
1950
- }
1951
1963
  var Input = React15.forwardRef(
1952
1964
  ({ className, type, ...props }, ref) => {
1953
1965
  return /* @__PURE__ */ jsx(
@@ -2018,6 +2030,41 @@ function getThemeConfig(fieldType, themeName) {
2018
2030
  if (!registry) return void 0;
2019
2031
  return registry[themeName];
2020
2032
  }
2033
+ function isLabelVisible(fieldDef) {
2034
+ return fieldDef.style?.labelVisible !== false;
2035
+ }
2036
+ function FieldRequiredIndicator({
2037
+ fieldDef
2038
+ }) {
2039
+ if (!fieldDef.required) return null;
2040
+ if (fieldDef.style?.showRequiredAsterisk === false) return null;
2041
+ return /* @__PURE__ */ jsx(
2042
+ "span",
2043
+ {
2044
+ className: cn(
2045
+ "text-red-500",
2046
+ fieldDef.style?.classNames?.requiredIndicator
2047
+ ),
2048
+ "aria-hidden": true,
2049
+ children: "*"
2050
+ }
2051
+ );
2052
+ }
2053
+ function fieldWrapperClass(fieldDef, ...defaults) {
2054
+ return cn(...defaults, fieldDef.style?.classNames?.wrapper);
2055
+ }
2056
+ function fieldLabelClass(fieldDef, ...defaults) {
2057
+ return cn(...defaults, fieldDef.style?.classNames?.label);
2058
+ }
2059
+ function fieldControlClass(fieldDef, ...defaults) {
2060
+ return cn(...defaults, fieldDef.style?.classNames?.control);
2061
+ }
2062
+ function fieldDescriptionClass(fieldDef, ...defaults) {
2063
+ return cn(...defaults, fieldDef.style?.classNames?.description);
2064
+ }
2065
+ function fieldErrorClass(fieldDef, ...defaults) {
2066
+ return cn(...defaults, fieldDef.style?.classNames?.error);
2067
+ }
2021
2068
  var TextWidget = ({ fieldId }) => {
2022
2069
  const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
2023
2070
  const { state } = useForm();
@@ -2035,34 +2082,50 @@ var TextWidget = ({ fieldId }) => {
2035
2082
  const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
2036
2083
  const labelClass = theme?.labelClassName;
2037
2084
  const inputClass = cn(theme?.inputClassName, showError && "border-red-500");
2085
+ const showLabel = isLabelVisible(fieldDef);
2038
2086
  const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
2039
2087
  fieldDef.label,
2040
2088
  " ",
2041
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
2089
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
2042
2090
  ] });
2043
- const labelEl = theme ? /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, children: labelContent });
2091
+ const labelEl = showLabel ? theme ? /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef, labelClass), children: labelContent }) : /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: labelContent }) : null;
2044
2092
  const placeholder = typeof fieldDef.placeholder === "string" && fieldDef.placeholder.trim() ? fieldDef.placeholder : void 0;
2045
- return /* @__PURE__ */ jsxs("div", { className: cn(wrapperClass, isTextarea && "flex h-full min-h-0 flex-col"), children: [
2046
- hasVoice ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
2047
- labelEl,
2048
- /* @__PURE__ */ jsx(VoiceMicButton, { fieldId, onTranscriptReady: setValue })
2049
- ] }) : labelEl,
2050
- /* @__PURE__ */ jsx(
2051
- Component,
2052
- {
2053
- id: fieldId,
2054
- value: value || "",
2055
- onChange: (e) => setValue(fieldDef.type === "number" ? Number(e.target.value) : e.target.value),
2056
- onBlur: setTouched,
2057
- disabled,
2058
- type: fieldDef.type === "number" ? "number" : "text",
2059
- className: cn(inputClass, isTextarea && height == null && "min-h-[80px] flex-1"),
2060
- placeholder,
2061
- ...isTextarea && { height }
2062
- }
2063
- ),
2064
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
2065
- ] });
2093
+ return /* @__PURE__ */ jsxs(
2094
+ "div",
2095
+ {
2096
+ className: fieldWrapperClass(
2097
+ fieldDef,
2098
+ wrapperClass,
2099
+ isTextarea && "flex h-full min-h-0 flex-col"
2100
+ ),
2101
+ children: [
2102
+ hasVoice ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
2103
+ labelEl,
2104
+ /* @__PURE__ */ jsx(VoiceMicButton, { fieldId, onTranscriptReady: setValue })
2105
+ ] }) : labelEl,
2106
+ /* @__PURE__ */ jsx(
2107
+ Component,
2108
+ {
2109
+ id: fieldId,
2110
+ value: value || "",
2111
+ onChange: (e) => setValue(fieldDef.type === "number" ? Number(e.target.value) : e.target.value),
2112
+ onBlur: setTouched,
2113
+ disabled,
2114
+ type: fieldDef.type === "number" ? "number" : "text",
2115
+ className: fieldControlClass(
2116
+ fieldDef,
2117
+ inputClass,
2118
+ isTextarea && height == null && "min-h-[80px] flex-1"
2119
+ ),
2120
+ placeholder,
2121
+ "aria-label": !showLabel ? fieldDef.label : void 0,
2122
+ ...isTextarea && { height }
2123
+ }
2124
+ ),
2125
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
2126
+ ]
2127
+ }
2128
+ );
2066
2129
  };
2067
2130
  var buttonVariants = cva(
2068
2131
  "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",
@@ -2326,24 +2389,28 @@ var RichTextWidget = ({ fieldId }) => {
2326
2389
  }
2327
2390
  }, [stringValue, editor]);
2328
2391
  if (!fieldDef) return null;
2392
+ const showLabel = isLabelVisible(fieldDef);
2329
2393
  const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
2330
2394
  fieldDef.label,
2331
2395
  " ",
2332
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
2396
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
2333
2397
  ] });
2334
- const labelEl = /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, children: labelContent });
2335
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
2398
+ const labelEl = /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: labelContent });
2399
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
2336
2400
  hasVoice ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
2337
- labelEl,
2401
+ showLabel ? labelEl : null,
2338
2402
  /* @__PURE__ */ jsx(VoiceMicButton, { fieldId, onTranscriptReady: setValue })
2339
- ] }) : labelEl,
2403
+ ] }) : showLabel ? labelEl : null,
2340
2404
  /* @__PURE__ */ jsxs(
2341
2405
  "div",
2342
2406
  {
2343
- className: cn(
2344
- "rounded-md border border-input bg-background text-sm ring-offset-background overflow-hidden",
2345
- showError && "border-red-500",
2346
- disabled && "opacity-60"
2407
+ className: fieldControlClass(
2408
+ fieldDef,
2409
+ cn(
2410
+ "rounded-md border border-input bg-background text-sm ring-offset-background overflow-hidden",
2411
+ showError && "border-red-500",
2412
+ disabled && "opacity-60"
2413
+ )
2347
2414
  ),
2348
2415
  children: [
2349
2416
  /* @__PURE__ */ jsx(RichTextToolbar, { editor, disabled }),
@@ -2369,7 +2436,7 @@ var RichTextWidget = ({ fieldId }) => {
2369
2436
  ]
2370
2437
  }
2371
2438
  ),
2372
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
2439
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
2373
2440
  ] });
2374
2441
  };
2375
2442
  var Select = SelectPrimitive.Root;
@@ -2535,12 +2602,13 @@ var SelectWidget = ({ fieldId }) => {
2535
2602
  if (!fieldDef) return null;
2536
2603
  const schemaPlaceholder = typeof fieldDef.placeholder === "string" && fieldDef.placeholder.trim() ? fieldDef.placeholder : void 0;
2537
2604
  const selectPlaceholder = loading ? "Loading..." : schemaPlaceholder ?? "Select...";
2538
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
2539
- /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, children: [
2605
+ const showLabel = isLabelVisible(fieldDef);
2606
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
2607
+ showLabel ? /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
2540
2608
  fieldDef.label,
2541
2609
  " ",
2542
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
2543
- ] }),
2610
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
2611
+ ] }) : null,
2544
2612
  /* @__PURE__ */ jsxs(
2545
2613
  Select,
2546
2614
  {
@@ -2552,12 +2620,22 @@ var SelectWidget = ({ fieldId }) => {
2552
2620
  setTouched();
2553
2621
  },
2554
2622
  children: [
2555
- /* @__PURE__ */ jsx(SelectTrigger, { id: fieldId, className: showError ? "border-red-500" : "", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: selectPlaceholder }) }),
2623
+ /* @__PURE__ */ jsx(
2624
+ SelectTrigger,
2625
+ {
2626
+ id: fieldId,
2627
+ className: fieldControlClass(
2628
+ fieldDef,
2629
+ showError ? "border-red-500" : ""
2630
+ ),
2631
+ children: /* @__PURE__ */ jsx(SelectValue, { placeholder: selectPlaceholder })
2632
+ }
2633
+ ),
2556
2634
  /* @__PURE__ */ jsx(SelectContent, { children: options.map((opt) => /* @__PURE__ */ jsx(SelectItem, { value: String(opt.value), children: opt.label }, String(opt.value))) })
2557
2635
  ]
2558
2636
  }
2559
2637
  ),
2560
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
2638
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
2561
2639
  ] });
2562
2640
  };
2563
2641
  var Checkbox = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
@@ -2604,34 +2682,44 @@ var MultiSelectWidget = ({ fieldId }) => {
2604
2682
  setTouched();
2605
2683
  };
2606
2684
  if (!fieldDef) return null;
2607
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
2608
- /* @__PURE__ */ jsxs(Label, { children: [
2685
+ const showLabel = isLabelVisible(fieldDef);
2686
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
2687
+ showLabel ? /* @__PURE__ */ jsxs(Label, { className: fieldLabelClass(fieldDef), children: [
2609
2688
  fieldDef.label,
2610
2689
  " ",
2611
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
2612
- ] }),
2613
- /* @__PURE__ */ jsxs("div", { className: `border rounded-md p-3 space-y-2 ${showError ? "border-red-500" : ""} ${disabled ? "opacity-50 pointer-events-none" : ""}`, children: [
2614
- loading && /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-500", children: "Loading options..." }),
2615
- !loading && options.map((opt) => /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
2616
- /* @__PURE__ */ jsx(
2617
- Checkbox,
2618
- {
2619
- id: `${fieldId}-${opt.value}`,
2620
- checked: currentValues.includes(opt.value),
2621
- onCheckedChange: () => toggleValue(opt.value)
2622
- }
2690
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
2691
+ ] }) : null,
2692
+ /* @__PURE__ */ jsxs(
2693
+ "div",
2694
+ {
2695
+ className: fieldControlClass(
2696
+ fieldDef,
2697
+ `border rounded-md p-3 space-y-2 ${showError ? "border-red-500" : ""} ${disabled ? "opacity-50 pointer-events-none" : ""}`
2623
2698
  ),
2624
- /* @__PURE__ */ jsx(
2625
- "label",
2626
- {
2627
- htmlFor: `${fieldId}-${opt.value}`,
2628
- className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
2629
- children: opt.label
2630
- }
2631
- )
2632
- ] }, String(opt.value)))
2633
- ] }),
2634
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
2699
+ children: [
2700
+ loading && /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-500", children: "Loading options..." }),
2701
+ !loading && options.map((opt) => /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
2702
+ /* @__PURE__ */ jsx(
2703
+ Checkbox,
2704
+ {
2705
+ id: `${fieldId}-${opt.value}`,
2706
+ checked: currentValues.includes(opt.value),
2707
+ onCheckedChange: () => toggleValue(opt.value)
2708
+ }
2709
+ ),
2710
+ /* @__PURE__ */ jsx(
2711
+ "label",
2712
+ {
2713
+ htmlFor: `${fieldId}-${opt.value}`,
2714
+ className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
2715
+ children: opt.label
2716
+ }
2717
+ )
2718
+ ] }, String(opt.value)))
2719
+ ]
2720
+ }
2721
+ ),
2722
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
2635
2723
  ] });
2636
2724
  };
2637
2725
  var Table = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsx(
@@ -2970,22 +3058,26 @@ var DateWidget = ({ fieldId }) => {
2970
3058
  const { state } = useForm();
2971
3059
  const showError = !!error && (touched || state.submitAttempted);
2972
3060
  if (!fieldDef) return null;
2973
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
2974
- /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, children: [
3061
+ const showLabel = isLabelVisible(fieldDef);
3062
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
3063
+ showLabel ? /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
2975
3064
  fieldDef.label,
2976
3065
  " ",
2977
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
2978
- ] }),
3066
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
3067
+ ] }) : null,
2979
3068
  /* @__PURE__ */ jsx("div", { onBlur: () => setTouched(), children: /* @__PURE__ */ jsx(
2980
3069
  DatePicker,
2981
3070
  {
2982
3071
  date: value ? new Date(value) : void 0,
2983
3072
  setDate: (date) => setValue(date ? date.toISOString() : void 0),
2984
3073
  placeholder: fieldDef.placeholder,
2985
- className: showError ? "border-red-500 w-full" : "w-full"
3074
+ className: fieldControlClass(
3075
+ fieldDef,
3076
+ showError ? "border-red-500 w-full" : "w-full"
3077
+ )
2986
3078
  }
2987
3079
  ) }),
2988
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
3080
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
2989
3081
  ] });
2990
3082
  };
2991
3083
  function parseTimeString(value) {
@@ -3102,6 +3194,7 @@ var DateTimeWidget = ({ fieldId }) => {
3102
3194
  const showError = !!error && (touched || state.submitAttempted);
3103
3195
  if (!fieldDef) return null;
3104
3196
  const currentDate = value ? new Date(value) : void 0;
3197
+ const showLabel = isLabelVisible(fieldDef);
3105
3198
  const handleChange = (date) => {
3106
3199
  if (!date) {
3107
3200
  setValue(void 0);
@@ -3109,12 +3202,12 @@ var DateTimeWidget = ({ fieldId }) => {
3109
3202
  }
3110
3203
  setValue(date.toISOString());
3111
3204
  };
3112
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
3113
- /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, children: [
3205
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
3206
+ showLabel ? /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
3114
3207
  fieldDef.label,
3115
3208
  " ",
3116
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
3117
- ] }),
3209
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
3210
+ ] }) : null,
3118
3211
  /* @__PURE__ */ jsx(
3119
3212
  "div",
3120
3213
  {
@@ -3126,12 +3219,15 @@ var DateTimeWidget = ({ fieldId }) => {
3126
3219
  dateTime: currentDate,
3127
3220
  setDateTime: handleChange,
3128
3221
  placeholder: fieldDef.placeholder,
3129
- className: showError ? "border-red-500 w-full" : "w-full"
3222
+ className: fieldControlClass(
3223
+ fieldDef,
3224
+ showError ? "border-red-500 w-full" : "w-full"
3225
+ )
3130
3226
  }
3131
3227
  )
3132
3228
  }
3133
3229
  ),
3134
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
3230
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
3135
3231
  ] });
3136
3232
  };
3137
3233
  function extractImageDisplayUrl(value) {
@@ -3162,13 +3258,15 @@ var ImageUploadWidget = ({ fieldId }) => {
3162
3258
  }
3163
3259
  };
3164
3260
  if (!fieldDef) return null;
3261
+ const showLabel = isLabelVisible(fieldDef);
3165
3262
  const uploadHandler = store.getUploadHandler();
3166
3263
  if (!uploadHandler) {
3167
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
3168
- /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, children: [
3264
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
3265
+ showLabel ? /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
3169
3266
  fieldDef.label,
3170
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
3171
- ] }),
3267
+ " ",
3268
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
3269
+ ] }) : null,
3172
3270
  /* @__PURE__ */ jsx("div", { className: "border-2 border-red-300 rounded-lg p-4 bg-red-50", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-red-600", children: "Upload handler not configured. Please provide an onUpload function in FormProvider config." }) })
3173
3271
  ] });
3174
3272
  }
@@ -3236,49 +3334,59 @@ var ImageUploadWidget = ({ fieldId }) => {
3236
3334
  const handleUploadClick = () => {
3237
3335
  fileInputRef.current?.click();
3238
3336
  };
3239
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
3240
- /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, children: [
3337
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
3338
+ showLabel ? /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
3241
3339
  fieldDef.label,
3242
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
3243
- ] }),
3244
- /* @__PURE__ */ jsx("div", { className: "border-2 border-dashed border-gray-300 rounded-lg p-4", children: preview ? /* @__PURE__ */ jsxs("div", { className: "relative", children: [
3245
- /* @__PURE__ */ jsx(
3246
- "img",
3247
- {
3248
- src: preview,
3249
- alt: "Uploaded image",
3250
- className: "max-w-full max-h-48 mx-auto rounded-lg"
3251
- }
3252
- ),
3253
- /* @__PURE__ */ jsx(
3254
- Button,
3255
- {
3256
- type: "button",
3257
- variant: "destructive",
3258
- size: "sm",
3259
- className: "absolute top-2 right-2",
3260
- onClick: handleRemove,
3261
- disabled: disabled || isUploading,
3262
- children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
3263
- }
3264
- )
3265
- ] }) : /* @__PURE__ */ jsxs("div", { className: "text-center py-8", children: [
3266
- /* @__PURE__ */ jsx(Image, { className: "h-12 w-12 mx-auto text-gray-400 mb-4" }),
3267
- /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600 mb-4", children: "Click to upload an image or drag and drop" }),
3268
- /* @__PURE__ */ jsxs(
3269
- Button,
3270
- {
3271
- type: "button",
3272
- variant: "outline",
3273
- onClick: handleUploadClick,
3274
- disabled: disabled || isUploading,
3275
- children: [
3276
- /* @__PURE__ */ jsx(Upload, { className: "h-4 w-4 mr-2" }),
3277
- isUploading ? "Uploading..." : "Choose Image"
3278
- ]
3279
- }
3280
- )
3281
- ] }) }),
3340
+ " ",
3341
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
3342
+ ] }) : null,
3343
+ /* @__PURE__ */ jsx(
3344
+ "div",
3345
+ {
3346
+ className: fieldControlClass(
3347
+ fieldDef,
3348
+ "border-2 border-dashed border-gray-300 rounded-lg p-4"
3349
+ ),
3350
+ children: preview ? /* @__PURE__ */ jsxs("div", { className: "relative", children: [
3351
+ /* @__PURE__ */ jsx(
3352
+ "img",
3353
+ {
3354
+ src: preview,
3355
+ alt: "Uploaded image",
3356
+ className: "max-w-full max-h-48 mx-auto rounded-lg"
3357
+ }
3358
+ ),
3359
+ /* @__PURE__ */ jsx(
3360
+ Button,
3361
+ {
3362
+ type: "button",
3363
+ variant: "destructive",
3364
+ size: "sm",
3365
+ className: "absolute top-2 right-2",
3366
+ onClick: handleRemove,
3367
+ disabled: disabled || isUploading,
3368
+ children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
3369
+ }
3370
+ )
3371
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "text-center py-8", children: [
3372
+ /* @__PURE__ */ jsx(Image, { className: "h-12 w-12 mx-auto text-gray-400 mb-4" }),
3373
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600 mb-4", children: "Click to upload an image or drag and drop" }),
3374
+ /* @__PURE__ */ jsxs(
3375
+ Button,
3376
+ {
3377
+ type: "button",
3378
+ variant: "outline",
3379
+ onClick: handleUploadClick,
3380
+ disabled: disabled || isUploading,
3381
+ children: [
3382
+ /* @__PURE__ */ jsx(Upload, { className: "h-4 w-4 mr-2" }),
3383
+ isUploading ? "Uploading..." : "Choose Image"
3384
+ ]
3385
+ }
3386
+ )
3387
+ ] })
3388
+ }
3389
+ ),
3282
3390
  /* @__PURE__ */ jsx(
3283
3391
  "input",
3284
3392
  {
@@ -3290,8 +3398,8 @@ var ImageUploadWidget = ({ fieldId }) => {
3290
3398
  disabled: disabled || isUploading
3291
3399
  }
3292
3400
  ),
3293
- fieldDef.description && /* @__PURE__ */ jsx("p", { className: "text-xs text-gray-500", children: fieldDef.description }),
3294
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
3401
+ fieldDef.description && /* @__PURE__ */ jsx("p", { className: fieldDescriptionClass(fieldDef, "text-xs text-gray-500"), children: fieldDef.description }),
3402
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
3295
3403
  ] });
3296
3404
  };
3297
3405
  function urlLooksLikePdf(url) {
@@ -3333,13 +3441,15 @@ var MediaUploadWidget = ({ fieldId }) => {
3333
3441
  }
3334
3442
  };
3335
3443
  if (!fieldDef) return null;
3444
+ const showLabel = isLabelVisible(fieldDef);
3336
3445
  const uploadHandler = store.getUploadHandler();
3337
3446
  if (!uploadHandler) {
3338
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
3339
- /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, children: [
3447
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
3448
+ showLabel ? /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
3340
3449
  fieldDef.label,
3341
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
3342
- ] }),
3450
+ " ",
3451
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
3452
+ ] }) : null,
3343
3453
  /* @__PURE__ */ jsx("div", { className: "border-2 border-red-300 rounded-lg p-4 bg-red-50", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-red-600", children: "Upload handler not configured. Please provide an onUpload function in FormProvider config." }) })
3344
3454
  ] });
3345
3455
  }
@@ -3422,56 +3532,66 @@ var MediaUploadWidget = ({ fieldId }) => {
3422
3532
  const handleUploadClick = () => {
3423
3533
  fileInputRef.current?.click();
3424
3534
  };
3425
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
3426
- /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, children: [
3535
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
3536
+ showLabel ? /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
3427
3537
  fieldDef.label,
3428
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
3429
- ] }),
3430
- /* @__PURE__ */ jsx("div", { className: "border-2 border-dashed border-gray-300 rounded-lg p-4", children: preview ? /* @__PURE__ */ jsxs("div", { className: "relative", children: [
3431
- previewIsPdf ? /* @__PURE__ */ jsx(
3432
- "iframe",
3433
- {
3434
- src: preview,
3435
- title: "Uploaded PDF",
3436
- className: "w-full max-h-48 min-h-36 rounded-lg border border-gray-200 bg-white"
3437
- }
3438
- ) : /* @__PURE__ */ jsx(
3439
- "img",
3440
- {
3441
- src: preview,
3442
- alt: "Uploaded image",
3443
- className: "max-w-full max-h-48 mx-auto rounded-lg"
3444
- }
3445
- ),
3446
- /* @__PURE__ */ jsx(
3447
- Button,
3448
- {
3449
- type: "button",
3450
- variant: "destructive",
3451
- size: "sm",
3452
- className: "absolute top-2 right-2",
3453
- onClick: handleRemove,
3454
- disabled: disabled || isUploading,
3455
- children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
3456
- }
3457
- )
3458
- ] }) : /* @__PURE__ */ jsxs("div", { className: "text-center py-8", children: [
3459
- /* @__PURE__ */ jsx(Image, { className: "h-12 w-12 mx-auto text-gray-400 mb-4" }),
3460
- /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600 mb-4", children: "Click to upload an image or PDF, or drag and drop" }),
3461
- /* @__PURE__ */ jsxs(
3462
- Button,
3463
- {
3464
- type: "button",
3465
- variant: "outline",
3466
- onClick: handleUploadClick,
3467
- disabled: disabled || isUploading,
3468
- children: [
3469
- /* @__PURE__ */ jsx(Upload, { className: "h-4 w-4 mr-2" }),
3470
- isUploading ? "Uploading..." : "Choose Image"
3471
- ]
3472
- }
3473
- )
3474
- ] }) }),
3538
+ " ",
3539
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
3540
+ ] }) : null,
3541
+ /* @__PURE__ */ jsx(
3542
+ "div",
3543
+ {
3544
+ className: fieldControlClass(
3545
+ fieldDef,
3546
+ "border-2 border-dashed border-gray-300 rounded-lg p-4"
3547
+ ),
3548
+ children: preview ? /* @__PURE__ */ jsxs("div", { className: "relative", children: [
3549
+ previewIsPdf ? /* @__PURE__ */ jsx(
3550
+ "iframe",
3551
+ {
3552
+ src: preview,
3553
+ title: "Uploaded PDF",
3554
+ className: "w-full max-h-48 min-h-36 rounded-lg border border-gray-200 bg-white"
3555
+ }
3556
+ ) : /* @__PURE__ */ jsx(
3557
+ "img",
3558
+ {
3559
+ src: preview,
3560
+ alt: "Uploaded image",
3561
+ className: "max-w-full max-h-48 mx-auto rounded-lg"
3562
+ }
3563
+ ),
3564
+ /* @__PURE__ */ jsx(
3565
+ Button,
3566
+ {
3567
+ type: "button",
3568
+ variant: "destructive",
3569
+ size: "sm",
3570
+ className: "absolute top-2 right-2",
3571
+ onClick: handleRemove,
3572
+ disabled: disabled || isUploading,
3573
+ children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
3574
+ }
3575
+ )
3576
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "text-center py-8", children: [
3577
+ /* @__PURE__ */ jsx(Image, { className: "h-12 w-12 mx-auto text-gray-400 mb-4" }),
3578
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600 mb-4", children: "Click to upload an image or PDF, or drag and drop" }),
3579
+ /* @__PURE__ */ jsxs(
3580
+ Button,
3581
+ {
3582
+ type: "button",
3583
+ variant: "outline",
3584
+ onClick: handleUploadClick,
3585
+ disabled: disabled || isUploading,
3586
+ children: [
3587
+ /* @__PURE__ */ jsx(Upload, { className: "h-4 w-4 mr-2" }),
3588
+ isUploading ? "Uploading..." : "Choose Image"
3589
+ ]
3590
+ }
3591
+ )
3592
+ ] })
3593
+ }
3594
+ ),
3475
3595
  /* @__PURE__ */ jsx(
3476
3596
  "input",
3477
3597
  {
@@ -3483,8 +3603,8 @@ var MediaUploadWidget = ({ fieldId }) => {
3483
3603
  disabled: disabled || isUploading
3484
3604
  }
3485
3605
  ),
3486
- fieldDef.description && /* @__PURE__ */ jsx("p", { className: "text-xs text-gray-500", children: fieldDef.description }),
3487
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
3606
+ fieldDef.description && /* @__PURE__ */ jsx("p", { className: fieldDescriptionClass(fieldDef, "text-xs text-gray-500"), children: fieldDef.description }),
3607
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
3488
3608
  ] });
3489
3609
  };
3490
3610
  var distance = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
@@ -3673,23 +3793,34 @@ var SignatureUploadWidget = ({ fieldId }) => {
3673
3793
  };
3674
3794
  confirmSignatureRef.current = confirmSignature;
3675
3795
  const canClear = showPreview ? !disabled : hasDrawing || isConfirmed;
3676
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
3677
- /* @__PURE__ */ jsxs(Label, { children: [
3796
+ const showLabel = isLabelVisible(fieldDef);
3797
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
3798
+ showLabel ? /* @__PURE__ */ jsxs(Label, { className: fieldLabelClass(fieldDef), children: [
3678
3799
  fieldDef.label,
3679
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
3680
- ] }),
3800
+ " ",
3801
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
3802
+ ] }) : null,
3681
3803
  showPreview ? (
3682
3804
  /* ── Preview mode: existing signature from backend ── */
3683
3805
  /* @__PURE__ */ jsxs("div", { className: "relative", children: [
3684
- /* @__PURE__ */ jsx("div", { className: "border border-gray-200 rounded bg-white flex items-center justify-start p-2", children: /* @__PURE__ */ jsx(
3685
- "img",
3806
+ /* @__PURE__ */ jsx(
3807
+ "div",
3686
3808
  {
3687
- src: displayUrl,
3688
- alt: "Signature",
3689
- className: "object-contain max-w-full",
3690
- style: { width: 400, height: 200 }
3809
+ className: fieldControlClass(
3810
+ fieldDef,
3811
+ "border border-gray-200 rounded bg-white flex items-center justify-start p-2"
3812
+ ),
3813
+ children: /* @__PURE__ */ jsx(
3814
+ "img",
3815
+ {
3816
+ src: displayUrl,
3817
+ alt: "Signature",
3818
+ className: "object-contain max-w-full",
3819
+ style: { width: 400, height: 200 }
3820
+ }
3821
+ )
3691
3822
  }
3692
- ) }),
3823
+ ),
3693
3824
  /* @__PURE__ */ jsx(
3694
3825
  Button,
3695
3826
  {
@@ -3712,7 +3843,10 @@ var SignatureUploadWidget = ({ fieldId }) => {
3712
3843
  "canvas",
3713
3844
  {
3714
3845
  ref: canvasRef,
3715
- className: `border rounded touch-none ${isConfirmed ? "border-green-300 cursor-default" : "border-gray-200 cursor-crosshair"}`,
3846
+ className: fieldControlClass(
3847
+ fieldDef,
3848
+ `border rounded touch-none ${isConfirmed ? "border-green-300 cursor-default" : "border-gray-200 cursor-crosshair"}`
3849
+ ),
3716
3850
  onMouseDown: startDrawing,
3717
3851
  onMouseMove: draw,
3718
3852
  onMouseUp: stopDrawing,
@@ -3757,7 +3891,285 @@ var SignatureUploadWidget = ({ fieldId }) => {
3757
3891
  ] })
3758
3892
  ] })
3759
3893
  ),
3760
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
3894
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
3895
+ ] });
3896
+ };
3897
+ function Upload3({
3898
+ value,
3899
+ accept,
3900
+ multiple,
3901
+ disabled,
3902
+ onChange,
3903
+ className,
3904
+ formatsLabel,
3905
+ placeholder = "Upload File",
3906
+ beforeUploadContent,
3907
+ id: idProp,
3908
+ listLayout = false
3909
+ }) {
3910
+ const inputRef = React15__default.useRef(null);
3911
+ const generatedId = React15__default.useId();
3912
+ const inputId = idProp ?? generatedId;
3913
+ const handleFileChange = (e) => {
3914
+ onChange(e.target.files ?? null);
3915
+ };
3916
+ React15__default.useEffect(() => {
3917
+ if (!value && inputRef.current) {
3918
+ inputRef.current.value = "";
3919
+ }
3920
+ }, [value]);
3921
+ const count = value?.length ?? 0;
3922
+ const formatsText = formatsLabel ?? accept;
3923
+ return /* @__PURE__ */ jsxs(
3924
+ "div",
3925
+ {
3926
+ className: cn(
3927
+ "border border-dashed bg-[#F7F7F7] border-gray-200 rounded-lg py-5 px-4 flex items-center justify-center text-[#989898]",
3928
+ disabled && "opacity-50 pointer-events-none",
3929
+ className
3930
+ ),
3931
+ children: [
3932
+ /* @__PURE__ */ jsx(
3933
+ "input",
3934
+ {
3935
+ type: "file",
3936
+ ref: inputRef,
3937
+ accept,
3938
+ id: inputId,
3939
+ className: "hidden",
3940
+ multiple,
3941
+ disabled,
3942
+ onChange: handleFileChange
3943
+ }
3944
+ ),
3945
+ /* @__PURE__ */ jsx(
3946
+ "label",
3947
+ {
3948
+ htmlFor: inputId,
3949
+ className: cn(
3950
+ "cursor-pointer w-full",
3951
+ disabled && "cursor-not-allowed"
3952
+ ),
3953
+ children: /* @__PURE__ */ jsx("div", { children: count > 0 && !listLayout ? /* @__PURE__ */ jsxs("div", { className: "text-center text-sm font-semibold text-gray-700", children: [
3954
+ count,
3955
+ " file",
3956
+ count === 1 ? "" : "s",
3957
+ " selected"
3958
+ ] }) : beforeUploadContent ? beforeUploadContent : /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center", children: [
3959
+ /* @__PURE__ */ jsxs("div", { className: "text-sm text-black font-normal leading-[120%] tracking-[-0.28px] text-center", children: [
3960
+ "Upload your surgery prescription",
3961
+ /* @__PURE__ */ jsx("br", {}),
3962
+ "and medical records"
3963
+ ] }),
3964
+ /* @__PURE__ */ jsx(
3965
+ Upload,
3966
+ {
3967
+ size: 20,
3968
+ className: "rotate-180 text-[#727272] mt-4"
3969
+ }
3970
+ ),
3971
+ /* @__PURE__ */ jsx("div", { className: "text-xs mt-1 text-text-shades-2", children: placeholder }),
3972
+ /* @__PURE__ */ jsxs("div", { className: "mt-2 text-10px leading-[140%] text-[#989898]", children: [
3973
+ "Supported formats - ",
3974
+ formatsText
3975
+ ] })
3976
+ ] }) })
3977
+ }
3978
+ )
3979
+ ]
3980
+ }
3981
+ );
3982
+ }
3983
+ function fileListFromArray(files) {
3984
+ const dt = new DataTransfer();
3985
+ files.forEach((f) => dt.items.add(f));
3986
+ return dt.files;
3987
+ }
3988
+ function matchesAccept(file, accept) {
3989
+ if (!accept || accept === "*/*") return true;
3990
+ const tokens = accept.split(",").map((t) => t.trim().toLowerCase());
3991
+ const name = file.name.toLowerCase();
3992
+ const type = file.type.toLowerCase();
3993
+ return tokens.some((token) => {
3994
+ if (token.startsWith(".")) return name.endsWith(token);
3995
+ if (token.endsWith("/*")) {
3996
+ const prefix = token.slice(0, -1);
3997
+ return type.startsWith(prefix);
3998
+ }
3999
+ return type === token;
4000
+ });
4001
+ }
4002
+ function basenameKey(key) {
4003
+ const parts = key.split("/");
4004
+ return parts[parts.length - 1] || key;
4005
+ }
4006
+ function fileRows(listLayout, localFiles, value) {
4007
+ if (!listLayout) return [];
4008
+ if (localFiles && localFiles.length > 0) {
4009
+ return Array.from(localFiles).map((f, i) => ({ label: f.name, index: i }));
4010
+ }
4011
+ if (Array.isArray(value) && value.length > 0) {
4012
+ return value.map((k, i) => ({
4013
+ label: basenameKey(String(k)),
4014
+ index: i
4015
+ }));
4016
+ }
4017
+ if (value !== null && value !== void 0 && value !== "") {
4018
+ return [{ label: basenameKey(String(value)), index: 0 }];
4019
+ }
4020
+ return [];
4021
+ }
4022
+ var FormFileUploadWidget = ({
4023
+ fieldId
4024
+ }) => {
4025
+ const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
4026
+ const store = useFormStore();
4027
+ const { state } = useForm();
4028
+ const [localFiles, setLocalFiles] = useState(null);
4029
+ const [isUploading, setIsUploading] = useState(false);
4030
+ const showError = !!error && (touched || state.submitAttempted);
4031
+ const listLayout = fieldDef?.type === "file_upload" && fieldDef.list === true;
4032
+ const rows = useMemo(
4033
+ () => fileRows(listLayout, localFiles, value),
4034
+ [listLayout, localFiles, value]
4035
+ );
4036
+ if (!fieldDef || fieldDef.type !== "file_upload") return null;
4037
+ const def = fieldDef;
4038
+ const accept = def.accept ?? "*/*";
4039
+ const maxSize = def.maxSize ?? 10 * 1024 * 1024;
4040
+ const allowMultiple = def.multiple === true;
4041
+ const uploadHandler = store.getUploadHandler();
4042
+ const showLabel = isLabelVisible(fieldDef);
4043
+ if (!uploadHandler) {
4044
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
4045
+ showLabel ? /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
4046
+ fieldDef.label,
4047
+ " ",
4048
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
4049
+ ] }) : null,
4050
+ /* @__PURE__ */ jsx("div", { className: "border-2 border-red-300 rounded-lg p-4 bg-red-50", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-red-600", children: "Upload handler not configured. Please provide an onUpload function in FormProvider config." }) })
4051
+ ] });
4052
+ }
4053
+ const hasStoredValue = value !== null && value !== void 0 && value !== "" && !(Array.isArray(value) && value.length === 0);
4054
+ const removeFileAt = (index) => {
4055
+ setTouched();
4056
+ if (disabled || isUploading) return;
4057
+ const hadLocal = localFiles != null && localFiles.length > 0;
4058
+ if (hadLocal) {
4059
+ const next = Array.from(localFiles).filter((_, i) => i !== index);
4060
+ if (next.length === 0) {
4061
+ setLocalFiles(null);
4062
+ setValue(null);
4063
+ return;
4064
+ }
4065
+ setLocalFiles(fileListFromArray(next));
4066
+ if (allowMultiple && Array.isArray(value)) {
4067
+ setValue(value.filter((_, i) => i !== index));
4068
+ } else {
4069
+ setValue(null);
4070
+ }
4071
+ return;
4072
+ }
4073
+ if (allowMultiple && Array.isArray(value)) {
4074
+ const next = value.filter((_, i) => i !== index);
4075
+ setValue(next.length ? next : null);
4076
+ return;
4077
+ }
4078
+ setValue(null);
4079
+ };
4080
+ const handleChange = async (files) => {
4081
+ setTouched();
4082
+ if (!files || files.length === 0) {
4083
+ setLocalFiles(null);
4084
+ setValue(null);
4085
+ return;
4086
+ }
4087
+ const selected = Array.from(files);
4088
+ for (const file of selected) {
4089
+ if (!matchesAccept(file, accept)) {
4090
+ alert(`File type not allowed: ${file.name}`);
4091
+ return;
4092
+ }
4093
+ if (file.size > maxSize) {
4094
+ alert(
4095
+ `File must be less than ${Math.round(maxSize / (1024 * 1024))}MB: ${file.name}`
4096
+ );
4097
+ return;
4098
+ }
4099
+ }
4100
+ const toUpload = allowMultiple ? selected : [selected[0]];
4101
+ setLocalFiles(fileListFromArray(toUpload));
4102
+ setIsUploading(true);
4103
+ store.incrementPendingUploads();
4104
+ try {
4105
+ if (allowMultiple) {
4106
+ const keys = [];
4107
+ for (const file of toUpload) {
4108
+ keys.push(await uploadHandler(file, file.name));
4109
+ }
4110
+ setValue(keys);
4111
+ } else {
4112
+ const key = await uploadHandler(toUpload[0], toUpload[0].name);
4113
+ setValue(key);
4114
+ }
4115
+ } catch (err) {
4116
+ console.error("[FormFileUpload] Upload failed:", err);
4117
+ const message = err instanceof Error ? err.message : "Upload failed. Please try again.";
4118
+ alert(message);
4119
+ setLocalFiles(null);
4120
+ setValue(null);
4121
+ } finally {
4122
+ setIsUploading(false);
4123
+ store.decrementPendingUploads();
4124
+ }
4125
+ };
4126
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
4127
+ showLabel ? /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
4128
+ fieldDef.label,
4129
+ " ",
4130
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
4131
+ ] }) : null,
4132
+ /* @__PURE__ */ jsx(
4133
+ Upload3,
4134
+ {
4135
+ accept,
4136
+ multiple: allowMultiple,
4137
+ value: localFiles,
4138
+ onChange: handleChange,
4139
+ disabled: disabled || isUploading,
4140
+ listLayout,
4141
+ placeholder: isUploading ? "Uploading..." : def.uploadPlaceholder ?? "Upload File",
4142
+ formatsLabel: def.uploadFormats,
4143
+ className: fieldControlClass(
4144
+ fieldDef,
4145
+ isUploading ? "opacity-70" : void 0
4146
+ )
4147
+ }
4148
+ ),
4149
+ listLayout && rows.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-2 mt-2 list-none p-0 m-0", children: rows.map((row) => /* @__PURE__ */ jsxs(
4150
+ "li",
4151
+ {
4152
+ 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]",
4153
+ children: [
4154
+ /* @__PURE__ */ jsx("span", { className: "truncate pr-2", children: row.label }),
4155
+ /* @__PURE__ */ jsx(
4156
+ "button",
4157
+ {
4158
+ type: "button",
4159
+ disabled: disabled || isUploading,
4160
+ onClick: () => removeFileAt(row.index),
4161
+ className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gray-400 text-white hover:bg-gray-500 disabled:opacity-50",
4162
+ "aria-label": `Remove ${row.label}`,
4163
+ children: /* @__PURE__ */ jsx(X, { size: 14, strokeWidth: 2.5 })
4164
+ }
4165
+ )
4166
+ ]
4167
+ },
4168
+ `${row.index}-${row.label}`
4169
+ )) }) : null,
4170
+ hasStoredValue && !listLayout ? /* @__PURE__ */ jsx("p", { className: "text-xs text-green-600", children: allowMultiple && Array.isArray(value) ? `${value.length} file(s) uploaded` : "File uploaded" }) : null,
4171
+ fieldDef.description && /* @__PURE__ */ jsx("p", { className: fieldDescriptionClass(fieldDef, "text-xs text-gray-500"), children: fieldDef.description }),
4172
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
3761
4173
  ] });
3762
4174
  };
3763
4175
  var EditableTableWidget = ({
@@ -4068,12 +4480,22 @@ var RadioWidget = ({ fieldId }) => {
4068
4480
  setValue(opt ? opt.value : val);
4069
4481
  setTouched();
4070
4482
  };
4071
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
4072
- /* @__PURE__ */ jsxs(Label, { className: showError ? "text-red-600" : "", children: [
4073
- fieldDef.label,
4074
- " ",
4075
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
4076
- ] }),
4483
+ const showLabel = isLabelVisible(fieldDef);
4484
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
4485
+ showLabel ? /* @__PURE__ */ jsxs(
4486
+ Label,
4487
+ {
4488
+ className: fieldLabelClass(
4489
+ fieldDef,
4490
+ showError ? "text-red-600" : ""
4491
+ ),
4492
+ children: [
4493
+ fieldDef.label,
4494
+ " ",
4495
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
4496
+ ]
4497
+ }
4498
+ ) : null,
4077
4499
  /* @__PURE__ */ jsx(
4078
4500
  RadioGroup,
4079
4501
  {
@@ -4101,7 +4523,7 @@ var RadioWidget = ({ fieldId }) => {
4101
4523
  }
4102
4524
  ),
4103
4525
  loading && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Loading options..." }),
4104
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
4526
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
4105
4527
  ] });
4106
4528
  };
4107
4529
  function isOptionSelected(selected, optValue) {
@@ -4133,16 +4555,29 @@ var CheckboxWidget = ({ fieldId }) => {
4133
4555
  setTouched();
4134
4556
  };
4135
4557
  if (!fieldDef) return null;
4136
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
4137
- /* @__PURE__ */ jsxs(Label, { className: showError ? "text-red-600" : "", children: [
4138
- fieldDef.label,
4139
- " ",
4140
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
4141
- ] }),
4558
+ const showLabel = isLabelVisible(fieldDef);
4559
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
4560
+ showLabel ? /* @__PURE__ */ jsxs(
4561
+ Label,
4562
+ {
4563
+ className: fieldLabelClass(
4564
+ fieldDef,
4565
+ showError ? "text-red-600" : ""
4566
+ ),
4567
+ children: [
4568
+ fieldDef.label,
4569
+ " ",
4570
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
4571
+ ]
4572
+ }
4573
+ ) : null,
4142
4574
  /* @__PURE__ */ jsxs(
4143
4575
  "div",
4144
4576
  {
4145
- className: `border rounded-md p-3 space-y-2 ${showError ? "border-red-500" : ""} ${disabled || loading ? "opacity-50 pointer-events-none" : ""}`,
4577
+ className: fieldControlClass(
4578
+ fieldDef,
4579
+ `border rounded-md p-3 space-y-2 ${showError ? "border-red-500" : ""} ${disabled || loading ? "opacity-50 pointer-events-none" : ""}`
4580
+ ),
4146
4581
  children: [
4147
4582
  loading && /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: "Loading options..." }),
4148
4583
  !loading && options.map((opt) => /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
@@ -4167,8 +4602,8 @@ var CheckboxWidget = ({ fieldId }) => {
4167
4602
  ]
4168
4603
  }
4169
4604
  ),
4170
- fieldDef.description && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: fieldDef.description }),
4171
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
4605
+ fieldDef.description && /* @__PURE__ */ jsx("p", { className: fieldDescriptionClass(fieldDef, "text-xs text-muted-foreground"), children: fieldDef.description }),
4606
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
4172
4607
  ] });
4173
4608
  };
4174
4609
  var AISuggestionsContext = createContext({});
@@ -5662,24 +6097,31 @@ var HiddenVitalsWidget = ({ fieldId }) => {
5662
6097
  const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
5663
6098
  fieldDef.label,
5664
6099
  " ",
5665
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
5666
- ] });
5667
- return /* @__PURE__ */ jsxs("div", { className: wrapperClass, "aria-hidden": "true", children: [
5668
- theme ? /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, children: labelContent }),
5669
- /* @__PURE__ */ jsx(
5670
- Textarea,
5671
- {
5672
- id: fieldId,
5673
- value: value ?? "",
5674
- onChange: (e) => setValue(e.target.value),
5675
- onBlur: setTouched,
5676
- disabled,
5677
- className: inputClass,
5678
- ...height != null && { height }
5679
- }
5680
- ),
5681
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
6100
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
5682
6101
  ] });
6102
+ return /* @__PURE__ */ jsxs(
6103
+ "div",
6104
+ {
6105
+ className: fieldWrapperClass(fieldDef, wrapperClass),
6106
+ "aria-hidden": "true",
6107
+ children: [
6108
+ theme ? /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef, labelClass), children: labelContent }) : /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: labelContent }),
6109
+ /* @__PURE__ */ jsx(
6110
+ Textarea,
6111
+ {
6112
+ id: fieldId,
6113
+ value: value ?? "",
6114
+ onChange: (e) => setValue(e.target.value),
6115
+ onBlur: setTouched,
6116
+ disabled,
6117
+ className: fieldControlClass(fieldDef, inputClass),
6118
+ ...height != null && { height }
6119
+ }
6120
+ ),
6121
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
6122
+ ]
6123
+ }
6124
+ );
5683
6125
  };
5684
6126
  function normalizeOptions(response) {
5685
6127
  if (Array.isArray(response)) {
@@ -5764,10 +6206,10 @@ var ReferralWidget = ({ fieldId }) => {
5764
6206
  [selectedItems, setValue, setTouched]
5765
6207
  );
5766
6208
  if (!fieldDef) return null;
5767
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
5768
- /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, children: [
6209
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
6210
+ /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
5769
6211
  "Referral to ",
5770
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
6212
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
5771
6213
  ] }),
5772
6214
  loading && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Loading..." }),
5773
6215
  !loading && /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -5782,7 +6224,14 @@ var ReferralWidget = ({ fieldId }) => {
5782
6224
  }
5783
6225
  },
5784
6226
  children: [
5785
- /* @__PURE__ */ jsx(SelectTrigger, { id: fieldId, className: showError ? "border-red-500" : "", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select specializations..." }) }),
6227
+ /* @__PURE__ */ jsx(
6228
+ SelectTrigger,
6229
+ {
6230
+ id: fieldId,
6231
+ className: fieldControlClass(fieldDef, showError ? "border-red-500" : ""),
6232
+ children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select specializations..." })
6233
+ }
6234
+ ),
5786
6235
  /* @__PURE__ */ jsxs(SelectContent, { children: [
5787
6236
  availableOptions.map((opt) => /* @__PURE__ */ jsx(SelectItem, { value: opt.value, children: opt.label }, opt.value)),
5788
6237
  availableOptions.length === 0 && /* @__PURE__ */ jsx("div", { className: "py-2 px-2 text-sm text-muted-foreground", children: "All specializations selected" })
@@ -5826,7 +6275,7 @@ var ReferralWidget = ({ fieldId }) => {
5826
6275
  selectedItems.length === 0 && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-1", children: "No specializations selected" }),
5827
6276
  selectedItems.length > 0 && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-1.5", children: "Click a chip to mark as urgent" })
5828
6277
  ] }),
5829
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
6278
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
5830
6279
  ] });
5831
6280
  };
5832
6281
  var Card = React15.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
@@ -6325,29 +6774,41 @@ var SmartTextareaWidget = ({ fieldId }) => {
6325
6774
  const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
6326
6775
  const labelClass = theme?.labelClassName;
6327
6776
  const inputClass = cn(theme?.inputClassName, showError && "border-red-500");
6777
+ const showLabel = isLabelVisible(def);
6328
6778
  const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
6329
6779
  def.label,
6330
6780
  " ",
6331
- def.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" }),
6781
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef: def }),
6332
6782
  isProcessing && /* @__PURE__ */ jsx(Loader2, { className: "inline-block ml-1.5 h-3 w-3 animate-spin text-muted-foreground" })
6333
6783
  ] });
6334
- return /* @__PURE__ */ jsxs("div", { className: wrapperClass, children: [
6335
- theme ? /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, children: labelContent }),
6336
- /* @__PURE__ */ jsx(
6337
- Textarea,
6338
- {
6339
- id: fieldId,
6340
- value: textValue,
6341
- onChange: handleTextChange,
6342
- onBlur: setTouched,
6343
- disabled,
6344
- placeholder: def.placeholder,
6345
- className: inputClass,
6346
- ...height != null ? { height } : {}
6347
- }
6348
- ),
6349
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
6350
- ] });
6784
+ const labelEl = showLabel ? theme ? /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(def, labelClass), children: labelContent }) : /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(def), children: labelContent }) : null;
6785
+ return /* @__PURE__ */ jsxs(
6786
+ "div",
6787
+ {
6788
+ className: fieldWrapperClass(
6789
+ def,
6790
+ wrapperClass
6791
+ ),
6792
+ children: [
6793
+ labelEl,
6794
+ /* @__PURE__ */ jsx(
6795
+ Textarea,
6796
+ {
6797
+ id: fieldId,
6798
+ value: textValue,
6799
+ onChange: handleTextChange,
6800
+ onBlur: setTouched,
6801
+ disabled,
6802
+ placeholder: def.placeholder,
6803
+ className: fieldControlClass(def, inputClass),
6804
+ "aria-label": !showLabel ? def.label : void 0,
6805
+ ...height != null ? { height } : {}
6806
+ }
6807
+ ),
6808
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(def, "text-xs text-red-500"), children: error })
6809
+ ]
6810
+ }
6811
+ );
6351
6812
  };
6352
6813
  function normalizeDiagnosisGrades(payload) {
6353
6814
  const result = [];
@@ -6467,10 +6928,11 @@ var DiagnosisTextareaWidget = ({ fieldId }) => {
6467
6928
  const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
6468
6929
  def.label,
6469
6930
  " ",
6470
- def.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
6931
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef: def })
6471
6932
  ] });
6472
- return /* @__PURE__ */ jsxs("div", { className: wrapperClass, children: [
6473
- theme ? /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, children: labelContent }),
6933
+ const showLabel = isLabelVisible(def);
6934
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(def, wrapperClass), children: [
6935
+ showLabel ? theme ? /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(def, labelClass), children: labelContent }) : /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(def), children: labelContent }) : null,
6474
6936
  /* @__PURE__ */ jsx(
6475
6937
  Textarea,
6476
6938
  {
@@ -6480,7 +6942,8 @@ var DiagnosisTextareaWidget = ({ fieldId }) => {
6480
6942
  onBlur: setTouched,
6481
6943
  disabled,
6482
6944
  placeholder: def.placeholder,
6483
- className: inputClass,
6945
+ className: fieldControlClass(def, inputClass),
6946
+ "aria-label": !showLabel ? def.label : void 0,
6484
6947
  ...def.height != null ? { height: def.height } : {}
6485
6948
  }
6486
6949
  ),
@@ -6514,7 +6977,7 @@ var DiagnosisTextareaWidget = ({ fieldId }) => {
6514
6977
  ] }, group.condition))
6515
6978
  }
6516
6979
  ),
6517
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
6980
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(def, "text-xs text-red-500"), children: error })
6518
6981
  ] });
6519
6982
  };
6520
6983
  var Switch = React15.forwardRef(
@@ -9834,7 +10297,7 @@ var OrthopedicExamWidget = ({ fieldId }) => {
9834
10297
  return /* @__PURE__ */ jsxs("div", { className: `space-y-4 relative ${disabled ? "opacity-60 pointer-events-none" : ""}`, children: [
9835
10298
  /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxs(Label, { className: "text-sm font-medium", children: [
9836
10299
  fieldDef.label,
9837
- fieldDef.required ? /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-1", children: "*" }) : null
10300
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
9838
10301
  ] }) }),
9839
10302
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
9840
10303
  /* @__PURE__ */ jsx("div", { className: "text-xs font-semibold text-muted-foreground", children: "Concern" }),
@@ -10025,26 +10488,30 @@ var MarMedicationOrdersWidget = ({ fieldId }) => {
10025
10488
  const theme = getThemeConfig("textarea", fieldDef.theme);
10026
10489
  const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
10027
10490
  const labelClass = theme?.labelClassName;
10491
+ const showLabel = isLabelVisible(fieldDef);
10028
10492
  const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
10029
10493
  fieldDef.label,
10030
10494
  " ",
10031
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
10495
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
10032
10496
  ] });
10033
- const labelEl = theme ? /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, children: labelContent });
10497
+ const labelEl = showLabel ? theme ? /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef, labelClass), children: labelContent }) : /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: labelContent }) : null;
10034
10498
  const text = typeof value === "string" ? value : value == null ? "" : String(value);
10035
10499
  const hasHandler = typeof handlers.onOpenMedicationOrders === "function";
10036
- return /* @__PURE__ */ jsxs("div", { className: wrapperClass, children: [
10500
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, wrapperClass), children: [
10037
10501
  labelEl,
10038
- fieldDef.description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: fieldDef.description }),
10502
+ fieldDef.description && /* @__PURE__ */ jsx("p", { className: fieldDescriptionClass(fieldDef, "text-sm text-muted-foreground"), children: fieldDef.description }),
10039
10503
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-3", children: [
10040
10504
  /* @__PURE__ */ jsx(
10041
10505
  "div",
10042
10506
  {
10043
10507
  id: fieldId,
10044
- className: cn(
10045
- "min-h-[80px] flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm whitespace-pre-wrap",
10046
- showError && "border-red-500",
10047
- !text && "text-muted-foreground"
10508
+ className: fieldControlClass(
10509
+ fieldDef,
10510
+ cn(
10511
+ "min-h-[80px] flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm whitespace-pre-wrap",
10512
+ showError && "border-red-500",
10513
+ !text && "text-muted-foreground"
10514
+ )
10048
10515
  ),
10049
10516
  style: height != null ? { minHeight: height } : void 0,
10050
10517
  "aria-readonly": "true",
@@ -10063,7 +10530,7 @@ var MarMedicationOrdersWidget = ({ fieldId }) => {
10063
10530
  }
10064
10531
  )
10065
10532
  ] }),
10066
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
10533
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
10067
10534
  ] });
10068
10535
  };
10069
10536
  function parseFieldValue(value) {
@@ -10143,22 +10610,25 @@ var DischargeMedicationOrdersWidget = ({ fieldId }) => {
10143
10610
  [orders, display_lines, setTouched, setValue]
10144
10611
  );
10145
10612
  if (!visible || !fieldDef) return null;
10146
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
10613
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
10147
10614
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
10148
- /* @__PURE__ */ jsxs(Label, { className: "text-sm font-medium", children: [
10615
+ /* @__PURE__ */ jsxs(Label, { className: fieldLabelClass(fieldDef, "text-sm font-medium"), children: [
10149
10616
  fieldDef.label,
10150
10617
  " ",
10151
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
10618
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
10152
10619
  ] }),
10153
10620
  /* @__PURE__ */ jsx(Button, { type: "button", onClick: onAdd, disabled: disabled || !handlers.onOpenDischargeMedicationOrders, children: "Add medicine" })
10154
10621
  ] }),
10155
- fieldDef.description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: fieldDef.description }),
10622
+ fieldDef.description && /* @__PURE__ */ jsx("p", { className: fieldDescriptionClass(fieldDef, "text-sm text-muted-foreground"), children: fieldDef.description }),
10156
10623
  orders.length === 0 ? /* @__PURE__ */ jsx(
10157
10624
  "div",
10158
10625
  {
10159
- className: cn(
10160
- "rounded-md border border-input bg-background px-3 py-3 text-sm text-muted-foreground",
10161
- showError && "border-red-500"
10626
+ className: fieldControlClass(
10627
+ fieldDef,
10628
+ cn(
10629
+ "rounded-md border border-input bg-background px-3 py-3 text-sm text-muted-foreground",
10630
+ showError && "border-red-500"
10631
+ )
10162
10632
  ),
10163
10633
  children: "No medicines added."
10164
10634
  }
@@ -10207,7 +10677,7 @@ var DischargeMedicationOrdersWidget = ({ fieldId }) => {
10207
10677
  ] })
10208
10678
  ] }, o.id);
10209
10679
  }) }),
10210
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
10680
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
10211
10681
  ] });
10212
10682
  };
10213
10683
  var DEFAULT_TOKEN_SEPARATOR2 = ", ";
@@ -10309,13 +10779,15 @@ var SuggestionTextareaWidget = ({ fieldId }) => {
10309
10779
  const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
10310
10780
  const labelClass = theme?.labelClassName;
10311
10781
  const inputClass = cn(theme?.inputClassName, showError && "border-red-500");
10782
+ const inputWithStyle = fieldControlClass(def, inputClass);
10312
10783
  const height = def.height != null ? typeof def.height === "string" ? Number(def.height) || void 0 : def.height : void 0;
10313
10784
  const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
10314
10785
  def.label,
10315
10786
  " ",
10316
- def.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
10787
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef: def })
10317
10788
  ] });
10318
- const labelEl = theme ? /* @__PURE__ */ jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { children: labelContent });
10789
+ const showLabel = isLabelVisible(def);
10790
+ const labelEl = showLabel ? theme ? /* @__PURE__ */ jsx(Label, { className: fieldLabelClass(def, labelClass), children: labelContent }) : /* @__PURE__ */ jsx(Label, { className: fieldLabelClass(def), children: labelContent }) : null;
10319
10791
  const onChipClick = (optValue) => {
10320
10792
  if (disabled) return;
10321
10793
  setValue(toggleSuggestionTokenInText(textValue, String(optValue), appendSeparator, chipAllowedSet));
@@ -10339,7 +10811,7 @@ var SuggestionTextareaWidget = ({ fieldId }) => {
10339
10811
  disabled && "pointer-events-none opacity-50"
10340
10812
  );
10341
10813
  const textareaShellClass = cn(
10342
- inputClass,
10814
+ inputWithStyle,
10343
10815
  hasShell && cn(
10344
10816
  "mt-0 rounded-t-none rounded-b-md border-0 shadow-none focus-visible:ring-offset-0",
10345
10817
  isHighlightLabel ? "border-t-0" : "min-h-[80px]"
@@ -10361,12 +10833,12 @@ var SuggestionTextareaWidget = ({ fieldId }) => {
10361
10833
  String(opt.value)
10362
10834
  );
10363
10835
  });
10364
- return /* @__PURE__ */ jsxs("div", { className: wrapperClass, children: [
10836
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(def, wrapperClass), children: [
10365
10837
  hasVoice ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
10366
10838
  labelEl,
10367
10839
  /* @__PURE__ */ jsx(VoiceMicButton, { fieldId, onTranscriptReady: setValue })
10368
10840
  ] }) : labelEl,
10369
- def.description && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: def.description }),
10841
+ def.description && /* @__PURE__ */ jsx("p", { className: fieldDescriptionClass(def, "text-xs text-muted-foreground"), children: def.description }),
10370
10842
  hasShell ? /* @__PURE__ */ jsxs("div", { className: suggestionShellClass, children: [
10371
10843
  hasSuggestions && /* @__PURE__ */ jsx("div", { className: chipsRowClass, role: "group", "aria-label": suggestionsAria, children: suggestionButtons }),
10372
10844
  hasEmbedded && /* @__PURE__ */ jsx("div", { className: embeddedRowClass, children: embeddedFieldIds.map((id) => /* @__PURE__ */ jsx(EmbeddedSchemaField, { fieldId: id }, id)) }),
@@ -10380,7 +10852,8 @@ var SuggestionTextareaWidget = ({ fieldId }) => {
10380
10852
  disabled,
10381
10853
  className: textareaShellClass,
10382
10854
  placeholder: def.placeholder,
10383
- style: height != null && Number.isFinite(height) ? { minHeight: height } : void 0
10855
+ style: height != null && Number.isFinite(height) ? { minHeight: height } : void 0,
10856
+ "aria-label": !showLabel ? def.label : void 0
10384
10857
  }
10385
10858
  )
10386
10859
  ] }) : /* @__PURE__ */ jsx(
@@ -10391,12 +10864,13 @@ var SuggestionTextareaWidget = ({ fieldId }) => {
10391
10864
  onChange: (e) => setValue(e.target.value),
10392
10865
  onBlur: setTouched,
10393
10866
  disabled,
10394
- className: inputClass,
10867
+ className: inputWithStyle,
10395
10868
  placeholder: def.placeholder,
10396
- style: height != null && Number.isFinite(height) ? { minHeight: height } : void 0
10869
+ style: height != null && Number.isFinite(height) ? { minHeight: height } : void 0,
10870
+ "aria-label": !showLabel ? def.label : void 0
10397
10871
  }
10398
10872
  ),
10399
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
10873
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(def, "text-xs text-red-500"), children: error })
10400
10874
  ] });
10401
10875
  };
10402
10876
  var EMPTY_GRADES = { NO: 0, NC: 0, C: 0, PSC: 0 };
@@ -11163,23 +11637,27 @@ var SliderWidget = ({ fieldId }) => {
11163
11637
  const theme = getThemeConfig("textarea", def.theme);
11164
11638
  const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
11165
11639
  const labelClass = theme?.labelClassName;
11640
+ const showLabel = isLabelVisible(def);
11166
11641
  const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
11167
11642
  def.label,
11168
11643
  " ",
11169
- def.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" }),
11644
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef: def }),
11170
11645
  /* @__PURE__ */ jsxs("span", { className: "ml-2 text-muted-foreground font-normal tabular-nums", children: [
11171
11646
  num2,
11172
11647
  "/",
11173
11648
  max
11174
11649
  ] })
11175
11650
  ] });
11176
- const labelEl = theme ? /* @__PURE__ */ jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { children: labelContent });
11177
- return /* @__PURE__ */ jsxs("div", { className: wrapperClass, children: [
11651
+ const labelEl = showLabel ? theme ? /* @__PURE__ */ jsx(Label, { className: fieldLabelClass(def, labelClass), children: labelContent }) : /* @__PURE__ */ jsx(Label, { className: fieldLabelClass(def), children: labelContent }) : null;
11652
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(def, wrapperClass), children: [
11178
11653
  labelEl,
11179
11654
  /* @__PURE__ */ jsx(
11180
11655
  Slider,
11181
11656
  {
11182
- className: cn("py-1", showError && "opacity-90 ring-1 ring-red-500 rounded"),
11657
+ className: fieldControlClass(
11658
+ def,
11659
+ cn("py-1", showError && "opacity-90 ring-1 ring-red-500 rounded")
11660
+ ),
11183
11661
  disabled,
11184
11662
  min,
11185
11663
  max,
@@ -11189,10 +11667,11 @@ var SliderWidget = ({ fieldId }) => {
11189
11667
  const n = v[0] ?? min;
11190
11668
  setValue(n);
11191
11669
  setTouched();
11192
- }
11670
+ },
11671
+ "aria-label": !showLabel ? `${def.label} ${num2}/${max}` : void 0
11193
11672
  }
11194
11673
  ),
11195
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
11674
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(def, "text-xs text-red-500"), children: error })
11196
11675
  ] });
11197
11676
  };
11198
11677
  var CHIEF_CHIPS_FIELD = "chief_complaints_chips";
@@ -11305,7 +11784,7 @@ var GsSmartHistoryWidget = ({ fieldId }) => {
11305
11784
  const labelClass = theme?.labelClassName;
11306
11785
  const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
11307
11786
  fieldDef.label,
11308
- fieldDef.required ? /* @__PURE__ */ jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
11787
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
11309
11788
  ] });
11310
11789
  const labelEl = theme ? /* @__PURE__ */ jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium", children: labelContent });
11311
11790
  const bodyClass = cn(
@@ -11708,7 +12187,7 @@ var GsExaminationWidget = ({ fieldId }) => {
11708
12187
  const labelClass = theme?.labelClassName;
11709
12188
  const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
11710
12189
  fieldDef.label,
11711
- fieldDef.required ? /* @__PURE__ */ jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
12190
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
11712
12191
  ] });
11713
12192
  const labelEl = theme ? /* @__PURE__ */ jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium", children: labelContent });
11714
12193
  const bodyClass = cn(
@@ -12119,7 +12598,7 @@ var GsGradingWidget = ({ fieldId }) => {
12119
12598
  const labelClass = theme?.labelClassName;
12120
12599
  const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
12121
12600
  fieldDef.label,
12122
- fieldDef.required ? /* @__PURE__ */ jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
12601
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
12123
12602
  ] });
12124
12603
  const labelEl = theme ? /* @__PURE__ */ jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium", children: labelContent });
12125
12604
  const bodyClass = cn(
@@ -12178,6 +12657,7 @@ var PainScaleFlagsWidget = ({ fieldId }) => {
12178
12657
  const theme = getThemeConfig("textarea", def.theme);
12179
12658
  const wrapperClass = theme?.wrapperClassName ?? "space-y-2";
12180
12659
  const labelClass = theme?.labelClassName;
12660
+ const showLabel = isLabelVisible(def);
12181
12661
  const update = (next) => {
12182
12662
  setValue(normalizePainScaleFlags(next, { min, max }));
12183
12663
  setTouched();
@@ -12193,16 +12673,16 @@ var PainScaleFlagsWidget = ({ fieldId }) => {
12193
12673
  const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
12194
12674
  def.label,
12195
12675
  " ",
12196
- def.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
12676
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef: def })
12197
12677
  ] });
12198
- const labelEl = theme ? /* @__PURE__ */ jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { children: labelContent });
12678
+ const labelEl = showLabel ? theme ? /* @__PURE__ */ jsx(Label, { className: fieldLabelClass(def, labelClass), children: labelContent }) : /* @__PURE__ */ jsx(Label, { className: fieldLabelClass(def), children: labelContent }) : null;
12199
12679
  const bodyClass = cn(
12200
12680
  "-mt-1 flex min-w-0 flex-col border-t border-[#D0D0D0] bg-white px-3 py-3",
12201
12681
  disabled && "pointer-events-none opacity-60"
12202
12682
  );
12203
- return /* @__PURE__ */ jsxs("div", { className: cn(wrapperClass, "h-full min-h-0 flex flex-col"), children: [
12683
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(def, cn(wrapperClass, "h-full min-h-0 flex flex-col")), children: [
12204
12684
  labelEl,
12205
- def.description && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: def.description }),
12685
+ def.description && /* @__PURE__ */ jsx("p", { className: fieldDescriptionClass(def, "text-xs text-muted-foreground"), children: def.description }),
12206
12686
  /* @__PURE__ */ jsx("div", { className: cn(bodyClass, "min-h-0 flex-1"), children: /* @__PURE__ */ jsxs("div", { className: "min-w-0 space-y-3", children: [
12207
12687
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
12208
12688
  /* @__PURE__ */ jsxs(Label, { className: "text-sm font-medium text-slate-700", children: [
@@ -12288,7 +12768,7 @@ var PainScaleFlagsWidget = ({ fieldId }) => {
12288
12768
  ] }) : null
12289
12769
  ] }) : null
12290
12770
  ] }) }),
12291
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
12771
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(def, "text-xs text-red-500"), children: error })
12292
12772
  ] });
12293
12773
  };
12294
12774
  var CHIEF_CHIPS_FIELD3 = "chief_complaints_chips";
@@ -12443,7 +12923,7 @@ var UrologySmartHistoryWidget = ({ fieldId }) => {
12443
12923
  const labelClass = theme?.labelClassName;
12444
12924
  const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
12445
12925
  fieldDef.label,
12446
- fieldDef.required ? /* @__PURE__ */ jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
12926
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
12447
12927
  ] });
12448
12928
  const labelEl = theme ? /* @__PURE__ */ jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium", children: labelContent });
12449
12929
  const bodyClass = cn(
@@ -12806,7 +13286,7 @@ var UrologyExaminationWidget = ({ fieldId }) => {
12806
13286
  const labelClass = theme?.labelClassName;
12807
13287
  const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
12808
13288
  fieldDef.label,
12809
- fieldDef.required ? /* @__PURE__ */ jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
13289
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
12810
13290
  ] });
12811
13291
  const labelEl = theme ? /* @__PURE__ */ jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium", children: labelContent });
12812
13292
  const bodyClass = cn(
@@ -13032,7 +13512,7 @@ var UrologyPathwayWidget = ({ fieldId }) => {
13032
13512
  const subtitle = fieldDef.meta && typeof fieldDef.meta === "object" && fieldDef.meta !== null ? String(fieldDef.meta.subtitle ?? "") : "";
13033
13513
  const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
13034
13514
  fieldDef.label,
13035
- fieldDef.required ? /* @__PURE__ */ jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
13515
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
13036
13516
  ] });
13037
13517
  const labelEl = theme ? /* @__PURE__ */ jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium", children: labelContent });
13038
13518
  const bodyClass = cn(
@@ -13227,7 +13707,7 @@ var OBGExaminationWidget = ({ fieldId }) => {
13227
13707
  const labelClass = theme?.labelClassName;
13228
13708
  const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
13229
13709
  fieldDef.label,
13230
- fieldDef.required ? /* @__PURE__ */ jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
13710
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
13231
13711
  ] });
13232
13712
  const labelEl = theme ? /* @__PURE__ */ jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium", children: labelContent });
13233
13713
  const bodyClass = cn(
@@ -13360,7 +13840,7 @@ var OBGPathwayWidget = ({ fieldId }) => {
13360
13840
  const labelClass = theme?.labelClassName;
13361
13841
  const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
13362
13842
  fieldDef.label,
13363
- fieldDef.required ? /* @__PURE__ */ jsx("span", { className: "ml-1 text-red-500", children: "*" }) : null
13843
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
13364
13844
  ] });
13365
13845
  const labelEl = theme ? /* @__PURE__ */ jsx(Label, { className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium", children: labelContent });
13366
13846
  const bodyClass = cn(
@@ -13848,6 +14328,7 @@ var PhoneInputWidget = ({ fieldId }) => {
13848
14328
  return () => clearTimeout(t);
13849
14329
  }, [resendCooldown]);
13850
14330
  if (!fieldDef) return null;
14331
+ const showLabel = isLabelVisible(fieldDef);
13851
14332
  const placeholder = typeof fieldDef.placeholder === "string" && fieldDef.placeholder.trim() ? fieldDef.placeholder : "Enter 10-digit mobile number";
13852
14333
  const handleChange = (e) => {
13853
14334
  const digits = e.target.value.replace(/\D/g, "").slice(0, 10);
@@ -13929,12 +14410,12 @@ var PhoneInputWidget = ({ fieldId }) => {
13929
14410
  isResendingRef.current = false;
13930
14411
  }
13931
14412
  };
13932
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
13933
- /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, children: [
14413
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
14414
+ showLabel ? /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
13934
14415
  fieldDef.label,
13935
14416
  " ",
13936
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
13937
- ] }),
14417
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
14418
+ ] }) : null,
13938
14419
  /* @__PURE__ */ jsxs("div", { className: "relative", children: [
13939
14420
  /* @__PURE__ */ jsx(
13940
14421
  Input,
@@ -13948,11 +14429,15 @@ var PhoneInputWidget = ({ fieldId }) => {
13948
14429
  disabled: disabled || status === "sending",
13949
14430
  placeholder,
13950
14431
  maxLength: 10,
13951
- className: cn(
13952
- showError && "border-red-500",
13953
- status === "sent" && "border-green-500 pr-9",
13954
- status === "sending" && "pr-9"
13955
- )
14432
+ className: fieldControlClass(
14433
+ fieldDef,
14434
+ cn(
14435
+ showError && "border-red-500",
14436
+ status === "sent" && "border-green-500 pr-9",
14437
+ status === "sending" && "pr-9"
14438
+ )
14439
+ ),
14440
+ "aria-label": !showLabel ? fieldDef.label : void 0
13956
14441
  }
13957
14442
  ),
13958
14443
  status === "sending" && /* @__PURE__ */ jsx("div", { className: "absolute inset-y-0 right-3 flex items-center pointer-events-none", children: /* @__PURE__ */ jsxs(
@@ -14005,7 +14490,7 @@ var PhoneInputWidget = ({ fieldId }) => {
14005
14490
  "OTP sent to +91",
14006
14491
  rawPhone
14007
14492
  ] }),
14008
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error }),
14493
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error }),
14009
14494
  status === "sent" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [
14010
14495
  /* @__PURE__ */ jsx("span", { children: "Didn't receive it?" }),
14011
14496
  /* @__PURE__ */ jsx(
@@ -14038,6 +14523,7 @@ var OtpInputWidget = ({ fieldId }) => {
14038
14523
  const isVerifyingRef = useRef(false);
14039
14524
  const showError = !!error && (touched || state.submitAttempted) && status !== "verifying" && status !== "verified";
14040
14525
  if (!fieldDef) return null;
14526
+ const showLabel = isLabelVisible(fieldDef);
14041
14527
  const placeholder = typeof fieldDef.placeholder === "string" && fieldDef.placeholder.trim() ? fieldDef.placeholder : "Enter 4-digit OTP";
14042
14528
  const handleChange = (e) => {
14043
14529
  const digits = e.target.value.replace(/\D/g, "").slice(0, 4);
@@ -14091,12 +14577,12 @@ var OtpInputWidget = ({ fieldId }) => {
14091
14577
  isVerifyingRef.current = false;
14092
14578
  }
14093
14579
  };
14094
- return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
14095
- /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, children: [
14580
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "space-y-2"), children: [
14581
+ showLabel ? /* @__PURE__ */ jsxs(Label, { htmlFor: fieldId, className: fieldLabelClass(fieldDef), children: [
14096
14582
  fieldDef.label,
14097
14583
  " ",
14098
- fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
14099
- ] }),
14584
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
14585
+ ] }) : null,
14100
14586
  /* @__PURE__ */ jsxs("div", { className: "relative", children: [
14101
14587
  /* @__PURE__ */ jsx(
14102
14588
  Input,
@@ -14110,12 +14596,16 @@ var OtpInputWidget = ({ fieldId }) => {
14110
14596
  disabled: disabled || status === "verifying" || status === "verified",
14111
14597
  placeholder,
14112
14598
  maxLength: 4,
14113
- className: cn(
14114
- "tracking-widest text-center text-lg",
14115
- showError && "border-red-500",
14116
- status === "verified" && "border-green-500 pr-9",
14117
- status === "verifying" && "pr-9"
14118
- )
14599
+ className: fieldControlClass(
14600
+ fieldDef,
14601
+ cn(
14602
+ "tracking-widest text-center text-lg",
14603
+ showError && "border-red-500",
14604
+ status === "verified" && "border-green-500 pr-9",
14605
+ status === "verifying" && "pr-9"
14606
+ )
14607
+ ),
14608
+ "aria-label": !showLabel ? fieldDef.label : void 0
14119
14609
  }
14120
14610
  ),
14121
14611
  status === "verifying" && /* @__PURE__ */ jsx("div", { className: "absolute inset-y-0 right-3 flex items-center pointer-events-none", children: /* @__PURE__ */ jsxs(
@@ -14165,7 +14655,7 @@ var OtpInputWidget = ({ fieldId }) => {
14165
14655
  ) })
14166
14656
  ] }),
14167
14657
  status === "verified" && /* @__PURE__ */ jsx("p", { className: "text-xs text-green-600", children: "Mobile number verified successfully" }),
14168
- showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
14658
+ showError && /* @__PURE__ */ jsx("p", { className: fieldErrorClass(fieldDef, "text-xs text-red-500"), children: error })
14169
14659
  ] });
14170
14660
  };
14171
14661
  var FieldRenderer = ({ fieldId }) => {
@@ -14207,6 +14697,8 @@ function renderWidget(fieldId, fieldDef) {
14207
14697
  return /* @__PURE__ */ jsx(ImageUploadWidget, { fieldId });
14208
14698
  case "media_upload":
14209
14699
  return /* @__PURE__ */ jsx(MediaUploadWidget, { fieldId });
14700
+ case "file_upload":
14701
+ return /* @__PURE__ */ jsx(FormFileUploadWidget, { fieldId });
14210
14702
  case "signature":
14211
14703
  return /* @__PURE__ */ jsx(SignatureUploadWidget, { fieldId });
14212
14704
  case "editable_table":
@@ -14267,7 +14759,8 @@ function renderWidget(fieldId, fieldDef) {
14267
14759
  const { value, setValue, setTouched, disabled } = useField(fieldId);
14268
14760
  const store = useFormStore();
14269
14761
  const excludes = fieldDef.excludes ?? [];
14270
- return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
14762
+ const showLabel = isLabelVisible(fieldDef);
14763
+ return /* @__PURE__ */ jsxs("div", { className: fieldWrapperClass(fieldDef, "flex items-center gap-3"), children: [
14271
14764
  /* @__PURE__ */ jsx(
14272
14765
  Switch,
14273
14766
  {
@@ -14280,7 +14773,20 @@ function renderWidget(fieldId, fieldDef) {
14280
14773
  }
14281
14774
  }
14282
14775
  ),
14283
- /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium leading-none cursor-pointer select-none", children: fieldDef.label })
14776
+ showLabel ? /* @__PURE__ */ jsxs(
14777
+ Label,
14778
+ {
14779
+ className: fieldLabelClass(
14780
+ fieldDef,
14781
+ "text-sm font-medium leading-none cursor-pointer select-none"
14782
+ ),
14783
+ children: [
14784
+ fieldDef.label,
14785
+ " ",
14786
+ /* @__PURE__ */ jsx(FieldRequiredIndicator, { fieldDef })
14787
+ ]
14788
+ }
14789
+ ) : null
14284
14790
  ] });
14285
14791
  }
14286
14792
  case "suggestion_textarea":
@@ -14299,10 +14805,19 @@ function renderWidget(fieldId, fieldDef) {
14299
14805
  const size = def.size ?? "regular";
14300
14806
  const labelClass = size === "large" ? "text-base" : "text-sm";
14301
14807
  const descClass = size === "large" ? "text-sm" : "text-xs";
14302
- return /* @__PURE__ */ jsxs("div", { className: `${labelClass} text-muted-foreground`, children: [
14303
- def.label,
14304
- def.description && /* @__PURE__ */ jsx("p", { className: `mt-1 ${descClass} opacity-90`, children: def.description })
14305
- ] });
14808
+ return /* @__PURE__ */ jsxs(
14809
+ "div",
14810
+ {
14811
+ className: fieldWrapperClass(
14812
+ def,
14813
+ cn(labelClass, "text-muted-foreground")
14814
+ ),
14815
+ children: [
14816
+ def.label,
14817
+ def.description && /* @__PURE__ */ jsx("p", { className: fieldDescriptionClass(def, cn("mt-1", descClass, "opacity-90")), children: def.description })
14818
+ ]
14819
+ }
14820
+ );
14306
14821
  }
14307
14822
  default:
14308
14823
  return /* @__PURE__ */ jsxs("div", { className: "text-red-500", children: [
@@ -15305,6 +15820,8 @@ var ReadOnlyFieldRenderer = ({
15305
15820
  return /* @__PURE__ */ jsx(ReadOnlyImageUpload, { fieldDef, value });
15306
15821
  case "media_upload":
15307
15822
  return /* @__PURE__ */ jsx(ReadOnlyMediaUpload, { fieldDef, value });
15823
+ case "file_upload":
15824
+ return /* @__PURE__ */ jsx(ReadOnlyMediaUpload, { fieldDef, value });
15308
15825
  case "signature":
15309
15826
  return /* @__PURE__ */ jsx(ReadOnlySignature, { fieldDef, value });
15310
15827
  case "editable_table":
@@ -15799,6 +16316,6 @@ function createUploadHandler(options) {
15799
16316
  };
15800
16317
  }
15801
16318
 
15802
- export { AddInvestigationField, AddMedicationField, DifferentialDiagnosis, DynamicForm, DynamicFormV2, EMAIL_REGEX, FieldRenderer, FormControls, FormProvider, FormStore, ImageUploadWidget, MAR_MEDICATION_ORDERS_META_KEY, MediaUploadWidget, MultiStepForm, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlyMediaUpload, ReadOnlySignature, ReadOnlyTable, RichTextWidget, SignatureUploadWidget, SmartForm, SmartTextareaWidget, createUploadHandler, evaluateRules, fieldMetaRequestsMarMedicationOrdersButton, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, usePackages, useSmartKeywords, validateField, validateForm };
16319
+ export { AddInvestigationField, AddMedicationField, DifferentialDiagnosis, DynamicForm, DynamicFormV2, EMAIL_REGEX, FieldRenderer, FieldRequiredIndicator, FormControls, FormFileUploadWidget, FormProvider, FormStore, ImageUploadWidget, MAR_MEDICATION_ORDERS_META_KEY, MediaUploadWidget, MultiStepForm, ReadOnlyForm, ReadOnlyImageUpload, ReadOnlyMediaUpload, ReadOnlySignature, ReadOnlyTable, RichTextWidget, SignatureUploadWidget, SmartForm, SmartTextareaWidget, Upload3 as Upload, createUploadHandler, evaluateRules, fieldControlClass, fieldDescriptionClass, fieldErrorClass, fieldLabelClass, fieldMetaRequestsMarMedicationOrdersButton, fieldWrapperClass, isLabelVisible, useField, useFieldHandlers, useForm, useFormStore, useFrequentItems, usePackages, useSmartKeywords, validateField, validateForm };
15803
16320
  //# sourceMappingURL=index.mjs.map
15804
16321
  //# sourceMappingURL=index.mjs.map