formanitor 0.0.22 → 0.0.24
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 +531 -250
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -4
- package/dist/index.d.ts +46 -4
- package/dist/index.mjs +373 -97
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -1
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React13 = require('react');
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var clsx = require('clsx');
|
|
6
6
|
var tailwindMerge = require('tailwind-merge');
|
|
7
7
|
var LabelPrimitive = require('@radix-ui/react-label');
|
|
8
8
|
var classVarianceAuthority = require('class-variance-authority');
|
|
9
|
-
var
|
|
9
|
+
var react = require('@tiptap/react');
|
|
10
|
+
var StarterKit = require('@tiptap/starter-kit');
|
|
11
|
+
var Placeholder = require('@tiptap/extension-placeholder');
|
|
12
|
+
var Underline = require('@tiptap/extension-underline');
|
|
10
13
|
var lucideReact = require('lucide-react');
|
|
11
|
-
var CheckboxPrimitive = require('@radix-ui/react-checkbox');
|
|
12
14
|
var reactSlot = require('@radix-ui/react-slot');
|
|
15
|
+
var SeparatorPrimitive = require('@radix-ui/react-separator');
|
|
16
|
+
var SelectPrimitive = require('@radix-ui/react-select');
|
|
17
|
+
var CheckboxPrimitive = require('@radix-ui/react-checkbox');
|
|
13
18
|
var dateFns = require('date-fns');
|
|
14
19
|
var reactDayPicker = require('react-day-picker');
|
|
15
20
|
var PopoverPrimitive = require('@radix-ui/react-popover');
|
|
@@ -39,8 +44,12 @@ function _interopNamespace(e) {
|
|
|
39
44
|
return Object.freeze(n);
|
|
40
45
|
}
|
|
41
46
|
|
|
42
|
-
var
|
|
47
|
+
var React13__namespace = /*#__PURE__*/_interopNamespace(React13);
|
|
43
48
|
var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
|
|
49
|
+
var StarterKit__default = /*#__PURE__*/_interopDefault(StarterKit);
|
|
50
|
+
var Placeholder__default = /*#__PURE__*/_interopDefault(Placeholder);
|
|
51
|
+
var Underline__default = /*#__PURE__*/_interopDefault(Underline);
|
|
52
|
+
var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrimitive);
|
|
44
53
|
var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
|
|
45
54
|
var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
|
|
46
55
|
var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
|
|
@@ -685,20 +694,20 @@ var FormStore = class {
|
|
|
685
694
|
this.listeners.forEach((l) => l(this.state));
|
|
686
695
|
}
|
|
687
696
|
};
|
|
688
|
-
var FormContext =
|
|
697
|
+
var FormContext = React13.createContext(null);
|
|
689
698
|
var emptyFrequentItems = {
|
|
690
699
|
medications: [],
|
|
691
700
|
investigations: [],
|
|
692
701
|
procedures: []
|
|
693
702
|
};
|
|
694
|
-
var FrequentItemsContext =
|
|
695
|
-
var FieldHandlersContext =
|
|
703
|
+
var FrequentItemsContext = React13.createContext(emptyFrequentItems);
|
|
704
|
+
var FieldHandlersContext = React13.createContext({});
|
|
696
705
|
function useFieldHandlers(fieldId) {
|
|
697
|
-
const map =
|
|
706
|
+
const map = React13.useContext(FieldHandlersContext);
|
|
698
707
|
return map[fieldId] ?? { onSearch: async () => [], recentlyUsed: [] };
|
|
699
708
|
}
|
|
700
709
|
function useFrequentItems() {
|
|
701
|
-
return
|
|
710
|
+
return React13.useContext(FrequentItemsContext);
|
|
702
711
|
}
|
|
703
712
|
var FormProvider = ({
|
|
704
713
|
schema,
|
|
@@ -707,23 +716,23 @@ var FormProvider = ({
|
|
|
707
716
|
frequentItems,
|
|
708
717
|
children
|
|
709
718
|
}) => {
|
|
710
|
-
const storeRef =
|
|
719
|
+
const storeRef = React13.useRef(null);
|
|
711
720
|
if (!storeRef.current) {
|
|
712
721
|
storeRef.current = new FormStore(schema, config);
|
|
713
722
|
}
|
|
714
|
-
|
|
723
|
+
React13.useEffect(() => {
|
|
715
724
|
if (storeRef.current && config) {
|
|
716
725
|
storeRef.current.updateConfig(config);
|
|
717
726
|
}
|
|
718
727
|
});
|
|
719
|
-
|
|
728
|
+
React13.useEffect(() => {
|
|
720
729
|
storeRef.current?.load();
|
|
721
730
|
}, []);
|
|
722
731
|
const frequentItemsValue = frequentItems ?? emptyFrequentItems;
|
|
723
732
|
return /* @__PURE__ */ jsxRuntime.jsx(FormContext.Provider, { value: storeRef.current, children: /* @__PURE__ */ jsxRuntime.jsx(FieldHandlersContext.Provider, { value: fieldHandlers ?? {}, children: /* @__PURE__ */ jsxRuntime.jsx(FrequentItemsContext.Provider, { value: frequentItemsValue, children }) }) });
|
|
724
733
|
};
|
|
725
734
|
function useFormStore() {
|
|
726
|
-
const context =
|
|
735
|
+
const context = React13.useContext(FormContext);
|
|
727
736
|
if (!context) {
|
|
728
737
|
throw new Error("useFormStore must be used within a FormProvider");
|
|
729
738
|
}
|
|
@@ -731,8 +740,8 @@ function useFormStore() {
|
|
|
731
740
|
}
|
|
732
741
|
function useForm() {
|
|
733
742
|
const store = useFormStore();
|
|
734
|
-
const [state, setState] =
|
|
735
|
-
|
|
743
|
+
const [state, setState] = React13.useState(store.getState());
|
|
744
|
+
React13.useEffect(() => {
|
|
736
745
|
const unsubscribe = store.subscribe((newState) => {
|
|
737
746
|
setState({ ...newState });
|
|
738
747
|
});
|
|
@@ -754,8 +763,8 @@ function useForm() {
|
|
|
754
763
|
}
|
|
755
764
|
function useField(fieldId) {
|
|
756
765
|
const store = useFormStore();
|
|
757
|
-
const [fieldState, setFieldState] =
|
|
758
|
-
|
|
766
|
+
const [fieldState, setFieldState] = React13.useState(store.getFieldState(fieldId));
|
|
767
|
+
React13.useEffect(() => {
|
|
759
768
|
const unsubscribe = store.subscribe(() => {
|
|
760
769
|
const newState = store.getFieldState(fieldId);
|
|
761
770
|
setFieldState((prev) => {
|
|
@@ -780,7 +789,7 @@ function useField(fieldId) {
|
|
|
780
789
|
function cn(...inputs) {
|
|
781
790
|
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
782
791
|
}
|
|
783
|
-
var Input =
|
|
792
|
+
var Input = React13__namespace.forwardRef(
|
|
784
793
|
({ className, type, ...props }, ref) => {
|
|
785
794
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
786
795
|
"input",
|
|
@@ -800,7 +809,7 @@ Input.displayName = "Input";
|
|
|
800
809
|
var labelVariants = classVarianceAuthority.cva(
|
|
801
810
|
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
802
811
|
);
|
|
803
|
-
var Label =
|
|
812
|
+
var Label = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
804
813
|
LabelPrimitive__namespace.Root,
|
|
805
814
|
{
|
|
806
815
|
ref,
|
|
@@ -809,7 +818,7 @@ var Label = React11__namespace.forwardRef(({ className, ...props }, ref) => /* @
|
|
|
809
818
|
}
|
|
810
819
|
));
|
|
811
820
|
Label.displayName = LabelPrimitive__namespace.Root.displayName;
|
|
812
|
-
var Textarea =
|
|
821
|
+
var Textarea = React13__namespace.forwardRef(
|
|
813
822
|
({ className, height, style, ...props }, ref) => {
|
|
814
823
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
815
824
|
"textarea",
|
|
@@ -855,8 +864,8 @@ var TextWidget = ({ fieldId }) => {
|
|
|
855
864
|
const { state } = useForm();
|
|
856
865
|
const showError = !!error && (touched || state.submitAttempted);
|
|
857
866
|
if (!fieldDef) return null;
|
|
858
|
-
const Component = fieldDef.type === "textarea"
|
|
859
|
-
const isTextarea = fieldDef.type === "textarea"
|
|
867
|
+
const Component = fieldDef.type === "textarea" ? Textarea : Input;
|
|
868
|
+
const isTextarea = fieldDef.type === "textarea";
|
|
860
869
|
const height = isTextarea && "height" in fieldDef ? fieldDef.height : void 0;
|
|
861
870
|
const theme = getThemeConfig(
|
|
862
871
|
isTextarea ? "textarea" : "text",
|
|
@@ -888,9 +897,298 @@ var TextWidget = ({ fieldId }) => {
|
|
|
888
897
|
showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
|
|
889
898
|
] });
|
|
890
899
|
};
|
|
900
|
+
var buttonVariants = classVarianceAuthority.cva(
|
|
901
|
+
"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",
|
|
902
|
+
{
|
|
903
|
+
variants: {
|
|
904
|
+
variant: {
|
|
905
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
906
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
907
|
+
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
908
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
909
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
910
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
911
|
+
},
|
|
912
|
+
size: {
|
|
913
|
+
default: "h-10 px-4 py-2",
|
|
914
|
+
sm: "h-9 rounded-md px-3",
|
|
915
|
+
lg: "h-11 rounded-md px-8",
|
|
916
|
+
icon: "h-10 w-10"
|
|
917
|
+
}
|
|
918
|
+
},
|
|
919
|
+
defaultVariants: {
|
|
920
|
+
variant: "default",
|
|
921
|
+
size: "default"
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
);
|
|
925
|
+
var Button = React13__namespace.forwardRef(
|
|
926
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
927
|
+
const Comp = asChild ? reactSlot.Slot : "button";
|
|
928
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
929
|
+
Comp,
|
|
930
|
+
{
|
|
931
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
932
|
+
ref,
|
|
933
|
+
...props
|
|
934
|
+
}
|
|
935
|
+
);
|
|
936
|
+
}
|
|
937
|
+
);
|
|
938
|
+
Button.displayName = "Button";
|
|
939
|
+
var Separator = React13__namespace.forwardRef(
|
|
940
|
+
({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
941
|
+
SeparatorPrimitive__namespace.Root,
|
|
942
|
+
{
|
|
943
|
+
ref,
|
|
944
|
+
decorative,
|
|
945
|
+
orientation,
|
|
946
|
+
className: cn(
|
|
947
|
+
"shrink-0 bg-border",
|
|
948
|
+
orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
|
|
949
|
+
className
|
|
950
|
+
),
|
|
951
|
+
...props
|
|
952
|
+
}
|
|
953
|
+
)
|
|
954
|
+
);
|
|
955
|
+
Separator.displayName = SeparatorPrimitive__namespace.Root.displayName;
|
|
956
|
+
function isEmptyHtml(html) {
|
|
957
|
+
const t = html.trim();
|
|
958
|
+
return t === "" || t === "<p></p>" || t === "<p><br></p>" || t === '<p><br class="ProseMirror-trailingBreak"></p>';
|
|
959
|
+
}
|
|
960
|
+
function RichTextToolbar({
|
|
961
|
+
editor,
|
|
962
|
+
disabled
|
|
963
|
+
}) {
|
|
964
|
+
const [, rerender] = React13.useReducer((n) => n + 1, 0);
|
|
965
|
+
React13.useEffect(() => {
|
|
966
|
+
if (!editor) return;
|
|
967
|
+
const handler = () => rerender();
|
|
968
|
+
editor.on("selectionUpdate", handler);
|
|
969
|
+
editor.on("transaction", handler);
|
|
970
|
+
return () => {
|
|
971
|
+
editor.off("selectionUpdate", handler);
|
|
972
|
+
editor.off("transaction", handler);
|
|
973
|
+
};
|
|
974
|
+
}, [editor]);
|
|
975
|
+
if (!editor) {
|
|
976
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1 border-b border-input bg-muted/30 px-2 py-1.5 min-h-[42px]" });
|
|
977
|
+
}
|
|
978
|
+
const fmtBtn = (active, onClick, icon, title) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
979
|
+
Button,
|
|
980
|
+
{
|
|
981
|
+
type: "button",
|
|
982
|
+
variant: active ? "secondary" : "outline",
|
|
983
|
+
size: "icon",
|
|
984
|
+
className: "h-8 w-8 shrink-0",
|
|
985
|
+
disabled,
|
|
986
|
+
title,
|
|
987
|
+
onClick: () => {
|
|
988
|
+
if (!disabled) onClick();
|
|
989
|
+
},
|
|
990
|
+
children: icon
|
|
991
|
+
}
|
|
992
|
+
);
|
|
993
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
994
|
+
"div",
|
|
995
|
+
{
|
|
996
|
+
className: "flex flex-wrap items-center gap-1 border-b border-input bg-muted/30 px-2 py-1.5",
|
|
997
|
+
role: "toolbar",
|
|
998
|
+
"aria-label": "Rich text formatting",
|
|
999
|
+
children: [
|
|
1000
|
+
fmtBtn(
|
|
1001
|
+
editor.isActive("bold"),
|
|
1002
|
+
() => editor.chain().focus().toggleBold().run(),
|
|
1003
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Bold, { className: "h-4 w-4" }),
|
|
1004
|
+
"Bold"
|
|
1005
|
+
),
|
|
1006
|
+
fmtBtn(
|
|
1007
|
+
editor.isActive("italic"),
|
|
1008
|
+
() => editor.chain().focus().toggleItalic().run(),
|
|
1009
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Italic, { className: "h-4 w-4" }),
|
|
1010
|
+
"Italic"
|
|
1011
|
+
),
|
|
1012
|
+
fmtBtn(
|
|
1013
|
+
editor.isActive("underline"),
|
|
1014
|
+
() => editor.chain().focus().toggleUnderline().run(),
|
|
1015
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Underline, { className: "h-4 w-4" }),
|
|
1016
|
+
"Underline"
|
|
1017
|
+
),
|
|
1018
|
+
fmtBtn(
|
|
1019
|
+
editor.isActive("strike"),
|
|
1020
|
+
() => editor.chain().focus().toggleStrike().run(),
|
|
1021
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Strikethrough, { className: "h-4 w-4" }),
|
|
1022
|
+
"Strikethrough"
|
|
1023
|
+
),
|
|
1024
|
+
/* @__PURE__ */ jsxRuntime.jsx(Separator, { orientation: "vertical", className: "mx-0.5 h-6" }),
|
|
1025
|
+
fmtBtn(
|
|
1026
|
+
editor.isActive("bulletList"),
|
|
1027
|
+
() => editor.chain().focus().toggleBulletList().run(),
|
|
1028
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.List, { className: "h-4 w-4" }),
|
|
1029
|
+
"Bullet list"
|
|
1030
|
+
),
|
|
1031
|
+
fmtBtn(
|
|
1032
|
+
editor.isActive("orderedList"),
|
|
1033
|
+
() => editor.chain().focus().toggleOrderedList().run(),
|
|
1034
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ListOrdered, { className: "h-4 w-4" }),
|
|
1035
|
+
"Numbered list"
|
|
1036
|
+
),
|
|
1037
|
+
/* @__PURE__ */ jsxRuntime.jsx(Separator, { orientation: "vertical", className: "mx-0.5 h-6" }),
|
|
1038
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1039
|
+
Button,
|
|
1040
|
+
{
|
|
1041
|
+
type: "button",
|
|
1042
|
+
variant: "outline",
|
|
1043
|
+
size: "icon",
|
|
1044
|
+
className: "h-8 w-8 shrink-0",
|
|
1045
|
+
disabled: disabled || !editor.can().undo(),
|
|
1046
|
+
title: "Undo",
|
|
1047
|
+
onClick: () => editor.chain().focus().undo().run(),
|
|
1048
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Undo, { className: "h-4 w-4" })
|
|
1049
|
+
}
|
|
1050
|
+
),
|
|
1051
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1052
|
+
Button,
|
|
1053
|
+
{
|
|
1054
|
+
type: "button",
|
|
1055
|
+
variant: "outline",
|
|
1056
|
+
size: "icon",
|
|
1057
|
+
className: "h-8 w-8 shrink-0",
|
|
1058
|
+
disabled: disabled || !editor.can().redo(),
|
|
1059
|
+
title: "Redo",
|
|
1060
|
+
onClick: () => editor.chain().focus().redo().run(),
|
|
1061
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Redo, { className: "h-4 w-4" })
|
|
1062
|
+
}
|
|
1063
|
+
)
|
|
1064
|
+
]
|
|
1065
|
+
}
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
1068
|
+
var RichTextWidget = ({ fieldId }) => {
|
|
1069
|
+
const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
|
|
1070
|
+
const { state } = useForm();
|
|
1071
|
+
const showError = !!error && (touched || state.submitAttempted);
|
|
1072
|
+
const def = fieldDef;
|
|
1073
|
+
const placeholder = def?.placeholder ?? "Start typing\u2026";
|
|
1074
|
+
const minHeight = def?.minHeight ?? 160;
|
|
1075
|
+
const extensions = React13.useMemo(
|
|
1076
|
+
() => [
|
|
1077
|
+
StarterKit__default.default.configure({
|
|
1078
|
+
// Disable headings entirely so the UI/content can't introduce H2/H3.
|
|
1079
|
+
heading: false,
|
|
1080
|
+
bulletList: {
|
|
1081
|
+
HTMLAttributes: {
|
|
1082
|
+
class: "list-disc pl-6 my-2"
|
|
1083
|
+
}
|
|
1084
|
+
},
|
|
1085
|
+
orderedList: {
|
|
1086
|
+
HTMLAttributes: {
|
|
1087
|
+
class: "list-decimal pl-6 my-2"
|
|
1088
|
+
}
|
|
1089
|
+
},
|
|
1090
|
+
listItem: {
|
|
1091
|
+
HTMLAttributes: {
|
|
1092
|
+
class: "my-1"
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
}),
|
|
1096
|
+
Underline__default.default,
|
|
1097
|
+
Placeholder__default.default.configure({
|
|
1098
|
+
placeholder
|
|
1099
|
+
})
|
|
1100
|
+
],
|
|
1101
|
+
[placeholder]
|
|
1102
|
+
);
|
|
1103
|
+
const stringValue = typeof value === "string" ? value : "";
|
|
1104
|
+
const editor = react.useEditor(
|
|
1105
|
+
{
|
|
1106
|
+
extensions,
|
|
1107
|
+
content: stringValue || "",
|
|
1108
|
+
editable: !disabled,
|
|
1109
|
+
immediatelyRender: false,
|
|
1110
|
+
onUpdate: ({ editor: ed }) => {
|
|
1111
|
+
const html = ed.getHTML();
|
|
1112
|
+
setValue(isEmptyHtml(html) ? "" : html);
|
|
1113
|
+
},
|
|
1114
|
+
onBlur: () => setTouched(),
|
|
1115
|
+
editorProps: {
|
|
1116
|
+
attributes: {
|
|
1117
|
+
id: fieldId,
|
|
1118
|
+
class: "focus:outline-none",
|
|
1119
|
+
style: `min-height: ${minHeight}px`
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
},
|
|
1123
|
+
[extensions, fieldId]
|
|
1124
|
+
);
|
|
1125
|
+
React13.useEffect(() => {
|
|
1126
|
+
if (!editor || editor.isDestroyed) return;
|
|
1127
|
+
editor.setEditable(!disabled);
|
|
1128
|
+
}, [editor, disabled]);
|
|
1129
|
+
React13.useEffect(() => {
|
|
1130
|
+
if (!editor || editor.isDestroyed) return;
|
|
1131
|
+
const el = editor.view.dom;
|
|
1132
|
+
el.style.minHeight = `${minHeight}px`;
|
|
1133
|
+
}, [editor, minHeight]);
|
|
1134
|
+
React13.useEffect(() => {
|
|
1135
|
+
if (!editor || editor.isDestroyed) return;
|
|
1136
|
+
const fromForm = stringValue;
|
|
1137
|
+
const fromEditor = editor.getHTML();
|
|
1138
|
+
if (isEmptyHtml(fromForm) && isEmptyHtml(fromEditor)) return;
|
|
1139
|
+
if (fromForm && fromForm !== fromEditor) {
|
|
1140
|
+
editor.commands.setContent(fromForm, { emitUpdate: false });
|
|
1141
|
+
}
|
|
1142
|
+
if (!fromForm && !isEmptyHtml(fromEditor)) {
|
|
1143
|
+
editor.commands.setContent("", { emitUpdate: false });
|
|
1144
|
+
}
|
|
1145
|
+
}, [stringValue, editor]);
|
|
1146
|
+
if (!fieldDef) return null;
|
|
1147
|
+
const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1148
|
+
fieldDef.label,
|
|
1149
|
+
" ",
|
|
1150
|
+
fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
|
|
1151
|
+
] });
|
|
1152
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
1153
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, children: labelContent }),
|
|
1154
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1155
|
+
"div",
|
|
1156
|
+
{
|
|
1157
|
+
className: cn(
|
|
1158
|
+
"rounded-md border border-input bg-background text-sm ring-offset-background overflow-hidden",
|
|
1159
|
+
showError && "border-red-500",
|
|
1160
|
+
disabled && "opacity-60"
|
|
1161
|
+
),
|
|
1162
|
+
children: [
|
|
1163
|
+
/* @__PURE__ */ jsxRuntime.jsx(RichTextToolbar, { editor, disabled }),
|
|
1164
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1165
|
+
"div",
|
|
1166
|
+
{
|
|
1167
|
+
className: cn(
|
|
1168
|
+
"px-3 py-2",
|
|
1169
|
+
"[&_.ProseMirror]:outline-none",
|
|
1170
|
+
"[&_.ProseMirror_ul]:list-disc [&_.ProseMirror_ul]:pl-6 [&_.ProseMirror_ul]:my-2",
|
|
1171
|
+
"[&_.ProseMirror_ol]:list-decimal [&_.ProseMirror_ol]:pl-6 [&_.ProseMirror_ol]:my-2",
|
|
1172
|
+
"[&_.ProseMirror_li]:list-item",
|
|
1173
|
+
"[&_.ProseMirror_blockquote]:border-l-4 [&_.ProseMirror_blockquote]:border-muted-foreground/40 [&_.ProseMirror_blockquote]:pl-3 [&_.ProseMirror_blockquote]:italic [&_.ProseMirror_blockquote]:my-2",
|
|
1174
|
+
"[&_.ProseMirror_p.is-editor-empty:first-child::before]:text-muted-foreground",
|
|
1175
|
+
"[&_.ProseMirror_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)]",
|
|
1176
|
+
"[&_.ProseMirror_p.is-editor-empty:first-child::before]:float-left",
|
|
1177
|
+
"[&_.ProseMirror_p.is-editor-empty:first-child::before]:pointer-events-none",
|
|
1178
|
+
"[&_.ProseMirror_p.is-editor-empty:first-child::before]:h-0"
|
|
1179
|
+
),
|
|
1180
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(react.EditorContent, { editor })
|
|
1181
|
+
}
|
|
1182
|
+
)
|
|
1183
|
+
]
|
|
1184
|
+
}
|
|
1185
|
+
),
|
|
1186
|
+
showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
|
|
1187
|
+
] });
|
|
1188
|
+
};
|
|
891
1189
|
var Select = SelectPrimitive__namespace.Root;
|
|
892
1190
|
var SelectValue = SelectPrimitive__namespace.Value;
|
|
893
|
-
var SelectTrigger =
|
|
1191
|
+
var SelectTrigger = React13__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
894
1192
|
SelectPrimitive__namespace.Trigger,
|
|
895
1193
|
{
|
|
896
1194
|
ref,
|
|
@@ -906,7 +1204,7 @@ var SelectTrigger = React11__namespace.forwardRef(({ className, children, ...pro
|
|
|
906
1204
|
}
|
|
907
1205
|
));
|
|
908
1206
|
SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
|
|
909
|
-
var SelectScrollUpButton =
|
|
1207
|
+
var SelectScrollUpButton = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
910
1208
|
SelectPrimitive__namespace.ScrollUpButton,
|
|
911
1209
|
{
|
|
912
1210
|
ref,
|
|
@@ -919,7 +1217,7 @@ var SelectScrollUpButton = React11__namespace.forwardRef(({ className, ...props
|
|
|
919
1217
|
}
|
|
920
1218
|
));
|
|
921
1219
|
SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
|
|
922
|
-
var SelectScrollDownButton =
|
|
1220
|
+
var SelectScrollDownButton = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
923
1221
|
SelectPrimitive__namespace.ScrollDownButton,
|
|
924
1222
|
{
|
|
925
1223
|
ref,
|
|
@@ -932,7 +1230,7 @@ var SelectScrollDownButton = React11__namespace.forwardRef(({ className, ...prop
|
|
|
932
1230
|
}
|
|
933
1231
|
));
|
|
934
1232
|
SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
|
|
935
|
-
var SelectContent =
|
|
1233
|
+
var SelectContent = React13__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
936
1234
|
SelectPrimitive__namespace.Content,
|
|
937
1235
|
{
|
|
938
1236
|
ref,
|
|
@@ -960,7 +1258,7 @@ var SelectContent = React11__namespace.forwardRef(({ className, children, positi
|
|
|
960
1258
|
}
|
|
961
1259
|
) }));
|
|
962
1260
|
SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
|
|
963
|
-
var SelectLabel =
|
|
1261
|
+
var SelectLabel = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
964
1262
|
SelectPrimitive__namespace.Label,
|
|
965
1263
|
{
|
|
966
1264
|
ref,
|
|
@@ -969,7 +1267,7 @@ var SelectLabel = React11__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
969
1267
|
}
|
|
970
1268
|
));
|
|
971
1269
|
SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
|
|
972
|
-
var SelectItem =
|
|
1270
|
+
var SelectItem = React13__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
973
1271
|
SelectPrimitive__namespace.Item,
|
|
974
1272
|
{
|
|
975
1273
|
ref,
|
|
@@ -985,7 +1283,7 @@ var SelectItem = React11__namespace.forwardRef(({ className, children, ...props
|
|
|
985
1283
|
}
|
|
986
1284
|
));
|
|
987
1285
|
SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
|
|
988
|
-
var SelectSeparator =
|
|
1286
|
+
var SelectSeparator = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
989
1287
|
SelectPrimitive__namespace.Separator,
|
|
990
1288
|
{
|
|
991
1289
|
ref,
|
|
@@ -1032,11 +1330,11 @@ async function fetchOptions(source, params) {
|
|
|
1032
1330
|
}
|
|
1033
1331
|
var SelectWidget = ({ fieldId }) => {
|
|
1034
1332
|
const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
|
|
1035
|
-
const [options, setOptions] =
|
|
1036
|
-
const [loading, setLoading] =
|
|
1333
|
+
const [options, setOptions] = React13.useState([]);
|
|
1334
|
+
const [loading, setLoading] = React13.useState(false);
|
|
1037
1335
|
const { state } = useForm();
|
|
1038
1336
|
const showError = !!error && (touched || state.submitAttempted);
|
|
1039
|
-
|
|
1337
|
+
React13.useEffect(() => {
|
|
1040
1338
|
if (!fieldDef) return;
|
|
1041
1339
|
const def = fieldDef;
|
|
1042
1340
|
if (def.options) {
|
|
@@ -1074,7 +1372,7 @@ var SelectWidget = ({ fieldId }) => {
|
|
|
1074
1372
|
showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
|
|
1075
1373
|
] });
|
|
1076
1374
|
};
|
|
1077
|
-
var Checkbox =
|
|
1375
|
+
var Checkbox = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1078
1376
|
CheckboxPrimitive__namespace.Root,
|
|
1079
1377
|
{
|
|
1080
1378
|
ref,
|
|
@@ -1095,12 +1393,12 @@ var Checkbox = React11__namespace.forwardRef(({ className, ...props }, ref) => /
|
|
|
1095
1393
|
Checkbox.displayName = CheckboxPrimitive__namespace.Root.displayName;
|
|
1096
1394
|
var MultiSelectWidget = ({ fieldId }) => {
|
|
1097
1395
|
const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
|
|
1098
|
-
const [options, setOptions] =
|
|
1099
|
-
const [loading, setLoading] =
|
|
1396
|
+
const [options, setOptions] = React13.useState([]);
|
|
1397
|
+
const [loading, setLoading] = React13.useState(false);
|
|
1100
1398
|
const { state } = useForm();
|
|
1101
1399
|
const showError = !!error && (touched || state.submitAttempted);
|
|
1102
1400
|
const currentValues = Array.isArray(value) ? value : [];
|
|
1103
|
-
|
|
1401
|
+
React13.useEffect(() => {
|
|
1104
1402
|
if (!fieldDef) return;
|
|
1105
1403
|
const def = fieldDef;
|
|
1106
1404
|
if (def.options) {
|
|
@@ -1148,46 +1446,7 @@ var MultiSelectWidget = ({ fieldId }) => {
|
|
|
1148
1446
|
showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
|
|
1149
1447
|
] });
|
|
1150
1448
|
};
|
|
1151
|
-
var
|
|
1152
|
-
"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",
|
|
1153
|
-
{
|
|
1154
|
-
variants: {
|
|
1155
|
-
variant: {
|
|
1156
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
1157
|
-
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
1158
|
-
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
1159
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
1160
|
-
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
1161
|
-
link: "text-primary underline-offset-4 hover:underline"
|
|
1162
|
-
},
|
|
1163
|
-
size: {
|
|
1164
|
-
default: "h-10 px-4 py-2",
|
|
1165
|
-
sm: "h-9 rounded-md px-3",
|
|
1166
|
-
lg: "h-11 rounded-md px-8",
|
|
1167
|
-
icon: "h-10 w-10"
|
|
1168
|
-
}
|
|
1169
|
-
},
|
|
1170
|
-
defaultVariants: {
|
|
1171
|
-
variant: "default",
|
|
1172
|
-
size: "default"
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
);
|
|
1176
|
-
var Button = React11__namespace.forwardRef(
|
|
1177
|
-
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
1178
|
-
const Comp = asChild ? reactSlot.Slot : "button";
|
|
1179
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1180
|
-
Comp,
|
|
1181
|
-
{
|
|
1182
|
-
className: cn(buttonVariants({ variant, size, className })),
|
|
1183
|
-
ref,
|
|
1184
|
-
...props
|
|
1185
|
-
}
|
|
1186
|
-
);
|
|
1187
|
-
}
|
|
1188
|
-
);
|
|
1189
|
-
Button.displayName = "Button";
|
|
1190
|
-
var Table = React11__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1449
|
+
var Table = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1191
1450
|
"table",
|
|
1192
1451
|
{
|
|
1193
1452
|
ref,
|
|
@@ -1196,9 +1455,9 @@ var Table = React11__namespace.forwardRef(({ className, ...props }, ref) => /* @
|
|
|
1196
1455
|
}
|
|
1197
1456
|
) }));
|
|
1198
1457
|
Table.displayName = "Table";
|
|
1199
|
-
var TableHeader =
|
|
1458
|
+
var TableHeader = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
|
|
1200
1459
|
TableHeader.displayName = "TableHeader";
|
|
1201
|
-
var TableBody =
|
|
1460
|
+
var TableBody = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1202
1461
|
"tbody",
|
|
1203
1462
|
{
|
|
1204
1463
|
ref,
|
|
@@ -1207,7 +1466,7 @@ var TableBody = React11__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
1207
1466
|
}
|
|
1208
1467
|
));
|
|
1209
1468
|
TableBody.displayName = "TableBody";
|
|
1210
|
-
var TableFooter =
|
|
1469
|
+
var TableFooter = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1211
1470
|
"tfoot",
|
|
1212
1471
|
{
|
|
1213
1472
|
ref,
|
|
@@ -1219,7 +1478,7 @@ var TableFooter = React11__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
1219
1478
|
}
|
|
1220
1479
|
));
|
|
1221
1480
|
TableFooter.displayName = "TableFooter";
|
|
1222
|
-
var TableRow =
|
|
1481
|
+
var TableRow = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1223
1482
|
"tr",
|
|
1224
1483
|
{
|
|
1225
1484
|
ref,
|
|
@@ -1231,7 +1490,7 @@ var TableRow = React11__namespace.forwardRef(({ className, ...props }, ref) => /
|
|
|
1231
1490
|
}
|
|
1232
1491
|
));
|
|
1233
1492
|
TableRow.displayName = "TableRow";
|
|
1234
|
-
var TableHead =
|
|
1493
|
+
var TableHead = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1235
1494
|
"th",
|
|
1236
1495
|
{
|
|
1237
1496
|
ref,
|
|
@@ -1243,7 +1502,7 @@ var TableHead = React11__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
1243
1502
|
}
|
|
1244
1503
|
));
|
|
1245
1504
|
TableHead.displayName = "TableHead";
|
|
1246
|
-
var TableCell =
|
|
1505
|
+
var TableCell = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1247
1506
|
"td",
|
|
1248
1507
|
{
|
|
1249
1508
|
ref,
|
|
@@ -1252,7 +1511,7 @@ var TableCell = React11__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
1252
1511
|
}
|
|
1253
1512
|
));
|
|
1254
1513
|
TableCell.displayName = "TableCell";
|
|
1255
|
-
var TableCaption =
|
|
1514
|
+
var TableCaption = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1256
1515
|
"caption",
|
|
1257
1516
|
{
|
|
1258
1517
|
ref,
|
|
@@ -1268,7 +1527,7 @@ var RepeatableWidget = ({
|
|
|
1268
1527
|
if (!fieldDef || fieldDef.type !== "repeatable") return null;
|
|
1269
1528
|
const def = fieldDef;
|
|
1270
1529
|
const rows = Array.isArray(value) ? value : [];
|
|
1271
|
-
const [hasInteracted, setHasInteracted] =
|
|
1530
|
+
const [hasInteracted, setHasInteracted] = React13__namespace.default.useState(false);
|
|
1272
1531
|
const showError = !!error && (touched || hasInteracted);
|
|
1273
1532
|
const addRow = () => {
|
|
1274
1533
|
setValue([...rows, {}]);
|
|
@@ -1437,7 +1696,7 @@ function Calendar({
|
|
|
1437
1696
|
Calendar.displayName = "Calendar";
|
|
1438
1697
|
var Popover = PopoverPrimitive__namespace.Root;
|
|
1439
1698
|
var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
|
|
1440
|
-
var PopoverContent =
|
|
1699
|
+
var PopoverContent = React13__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1441
1700
|
PopoverPrimitive__namespace.Content,
|
|
1442
1701
|
{
|
|
1443
1702
|
ref,
|
|
@@ -1516,14 +1775,14 @@ function DateTimePicker({
|
|
|
1516
1775
|
className,
|
|
1517
1776
|
placeholder = "Pick date & time"
|
|
1518
1777
|
}) {
|
|
1519
|
-
const [internalDate, setInternalDate] =
|
|
1520
|
-
const [timeString, setTimeString] =
|
|
1778
|
+
const [internalDate, setInternalDate] = React13__namespace.useState(dateTime);
|
|
1779
|
+
const [timeString, setTimeString] = React13__namespace.useState(() => {
|
|
1521
1780
|
if (!dateTime) return "";
|
|
1522
1781
|
const hours = dateTime.getHours().toString().padStart(2, "0");
|
|
1523
1782
|
const minutes = dateTime.getMinutes().toString().padStart(2, "0");
|
|
1524
1783
|
return `${hours}:${minutes}`;
|
|
1525
1784
|
});
|
|
1526
|
-
|
|
1785
|
+
React13__namespace.useEffect(() => {
|
|
1527
1786
|
setInternalDate(dateTime);
|
|
1528
1787
|
if (!dateTime) {
|
|
1529
1788
|
setTimeString("");
|
|
@@ -1652,9 +1911,9 @@ var ImageUploadWidget = ({ fieldId }) => {
|
|
|
1652
1911
|
const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
|
|
1653
1912
|
const store = useFormStore();
|
|
1654
1913
|
const { state } = useForm();
|
|
1655
|
-
const [isUploading, setIsUploading] =
|
|
1656
|
-
const [preview, setPreview] =
|
|
1657
|
-
const fileInputRef =
|
|
1914
|
+
const [isUploading, setIsUploading] = React13.useState(false);
|
|
1915
|
+
const [preview, setPreview] = React13.useState(null);
|
|
1916
|
+
const fileInputRef = React13.useRef(null);
|
|
1658
1917
|
const showError = !!error && (touched || state.submitAttempted);
|
|
1659
1918
|
if (!fieldDef) return null;
|
|
1660
1919
|
const uploadHandler = store.getUploadHandler();
|
|
@@ -1667,7 +1926,7 @@ var ImageUploadWidget = ({ fieldId }) => {
|
|
|
1667
1926
|
/* @__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." }) })
|
|
1668
1927
|
] });
|
|
1669
1928
|
}
|
|
1670
|
-
|
|
1929
|
+
React13__namespace.default.useEffect(() => {
|
|
1671
1930
|
if (value && typeof value === "string") {
|
|
1672
1931
|
setPreview(value);
|
|
1673
1932
|
} else {
|
|
@@ -1792,18 +2051,18 @@ var SignatureUploadWidget = ({ fieldId }) => {
|
|
|
1792
2051
|
const { fieldDef, setValue, setTouched, error, disabled, touched, value } = useField(fieldId);
|
|
1793
2052
|
const store = useFormStore();
|
|
1794
2053
|
const { state } = useForm();
|
|
1795
|
-
const canvasRef =
|
|
1796
|
-
const pathRef =
|
|
1797
|
-
const lastPointRef =
|
|
1798
|
-
const lastTimeRef =
|
|
1799
|
-
const lastWidthRef =
|
|
1800
|
-
const [isDrawing, setIsDrawing] =
|
|
1801
|
-
const [hasDrawing, setHasDrawing] =
|
|
1802
|
-
const [isUploading, setIsUploading] =
|
|
1803
|
-
const [isConfirmed, setIsConfirmed] =
|
|
1804
|
-
const [uploadError, setUploadError] =
|
|
1805
|
-
const confirmSignatureRef =
|
|
1806
|
-
|
|
2054
|
+
const canvasRef = React13.useRef(null);
|
|
2055
|
+
const pathRef = React13.useRef("");
|
|
2056
|
+
const lastPointRef = React13.useRef(null);
|
|
2057
|
+
const lastTimeRef = React13.useRef(null);
|
|
2058
|
+
const lastWidthRef = React13.useRef(2);
|
|
2059
|
+
const [isDrawing, setIsDrawing] = React13.useState(false);
|
|
2060
|
+
const [hasDrawing, setHasDrawing] = React13.useState(false);
|
|
2061
|
+
const [isUploading, setIsUploading] = React13.useState(false);
|
|
2062
|
+
const [isConfirmed, setIsConfirmed] = React13.useState(false);
|
|
2063
|
+
const [uploadError, setUploadError] = React13.useState(null);
|
|
2064
|
+
const confirmSignatureRef = React13.useRef(null);
|
|
2065
|
+
React13.useEffect(() => {
|
|
1807
2066
|
if (hasDrawing && !isConfirmed) {
|
|
1808
2067
|
store.registerPreSubmitHandler(fieldId, async () => {
|
|
1809
2068
|
if (confirmSignatureRef.current) {
|
|
@@ -1818,9 +2077,9 @@ var SignatureUploadWidget = ({ fieldId }) => {
|
|
|
1818
2077
|
};
|
|
1819
2078
|
}, [hasDrawing, isConfirmed, fieldId, store]);
|
|
1820
2079
|
const showError = !!error && (touched || state.submitAttempted);
|
|
1821
|
-
const displayUrl =
|
|
2080
|
+
const displayUrl = React13.useMemo(() => extractDisplayUrl(value), [value]);
|
|
1822
2081
|
const showPreview = displayUrl !== null;
|
|
1823
|
-
|
|
2082
|
+
React13.useEffect(() => {
|
|
1824
2083
|
if (showPreview) return;
|
|
1825
2084
|
const canvas = canvasRef.current;
|
|
1826
2085
|
if (!canvas) return;
|
|
@@ -2060,7 +2319,7 @@ var EditableTableWidget = ({
|
|
|
2060
2319
|
const addColumnLabel = def?.addColumnLabel ?? "Add Column";
|
|
2061
2320
|
const newColumnNameHint = def?.newColumnNameHint ?? "New Column Name";
|
|
2062
2321
|
const newColumnNameInputType = def?.newColumnNameInputType ?? "text";
|
|
2063
|
-
const tableData =
|
|
2322
|
+
const tableData = React13.useMemo(() => {
|
|
2064
2323
|
if (value && typeof value === "object" && "columns" in value && "rows" in value) {
|
|
2065
2324
|
return value;
|
|
2066
2325
|
}
|
|
@@ -2075,12 +2334,12 @@ var EditableTableWidget = ({
|
|
|
2075
2334
|
rows: []
|
|
2076
2335
|
};
|
|
2077
2336
|
}, [value, fieldDef]);
|
|
2078
|
-
const dataRef =
|
|
2079
|
-
|
|
2337
|
+
const dataRef = React13.useRef(tableData);
|
|
2338
|
+
React13.useEffect(() => {
|
|
2080
2339
|
dataRef.current = tableData;
|
|
2081
2340
|
}, [tableData]);
|
|
2082
|
-
const [newColumnName, setNewColumnName] =
|
|
2083
|
-
const [newColumnDate, setNewColumnDate] =
|
|
2341
|
+
const [newColumnName, setNewColumnName] = React13.useState("");
|
|
2342
|
+
const [newColumnDate, setNewColumnDate] = React13.useState(void 0);
|
|
2084
2343
|
const updateData = (newData) => {
|
|
2085
2344
|
setValue(newData);
|
|
2086
2345
|
};
|
|
@@ -2148,7 +2407,7 @@ var EditableTableWidget = ({
|
|
|
2148
2407
|
newRows[rowIndex] = { ...newRows[rowIndex], [colId]: val };
|
|
2149
2408
|
updateData({ ...currentData, rows: newRows });
|
|
2150
2409
|
};
|
|
2151
|
-
const columns =
|
|
2410
|
+
const columns = React13.useMemo(() => {
|
|
2152
2411
|
const currentCols = tableData.columns;
|
|
2153
2412
|
const dataCols = currentCols.map((col) => {
|
|
2154
2413
|
const showColumnDelete = !disabled && canDeleteColumn && col.allowDelete !== false;
|
|
@@ -2306,7 +2565,7 @@ var EditableTableWidget = ({
|
|
|
2306
2565
|
] })
|
|
2307
2566
|
] });
|
|
2308
2567
|
};
|
|
2309
|
-
var RadioGroup =
|
|
2568
|
+
var RadioGroup = React13__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
2310
2569
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2311
2570
|
RadioGroupPrimitive__namespace.Root,
|
|
2312
2571
|
{
|
|
@@ -2317,7 +2576,7 @@ var RadioGroup = React11__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
2317
2576
|
);
|
|
2318
2577
|
});
|
|
2319
2578
|
RadioGroup.displayName = RadioGroupPrimitive__namespace.Root.displayName;
|
|
2320
|
-
var RadioGroupItem =
|
|
2579
|
+
var RadioGroupItem = React13__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
2321
2580
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2322
2581
|
RadioGroupPrimitive__namespace.Item,
|
|
2323
2582
|
{
|
|
@@ -2334,11 +2593,11 @@ var RadioGroupItem = React11__namespace.forwardRef(({ className, ...props }, ref
|
|
|
2334
2593
|
RadioGroupItem.displayName = RadioGroupPrimitive__namespace.Item.displayName;
|
|
2335
2594
|
var RadioWidget = ({ fieldId }) => {
|
|
2336
2595
|
const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
|
|
2337
|
-
const [options, setOptions] =
|
|
2338
|
-
const [loading, setLoading] =
|
|
2596
|
+
const [options, setOptions] = React13.useState([]);
|
|
2597
|
+
const [loading, setLoading] = React13.useState(false);
|
|
2339
2598
|
const { state } = useForm();
|
|
2340
2599
|
const showError = !!error && (touched || state.submitAttempted);
|
|
2341
|
-
|
|
2600
|
+
React13.useEffect(() => {
|
|
2342
2601
|
if (!fieldDef) return;
|
|
2343
2602
|
const def = fieldDef;
|
|
2344
2603
|
if (def.options?.length) {
|
|
@@ -2397,12 +2656,12 @@ function isOptionSelected(selected, optValue) {
|
|
|
2397
2656
|
}
|
|
2398
2657
|
var CheckboxWidget = ({ fieldId }) => {
|
|
2399
2658
|
const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
|
|
2400
|
-
const [options, setOptions] =
|
|
2401
|
-
const [loading, setLoading] =
|
|
2659
|
+
const [options, setOptions] = React13.useState([]);
|
|
2660
|
+
const [loading, setLoading] = React13.useState(false);
|
|
2402
2661
|
const { state } = useForm();
|
|
2403
2662
|
const showError = !!error && (touched || state.submitAttempted);
|
|
2404
2663
|
const selectedValues = Array.isArray(value) ? value : [];
|
|
2405
|
-
|
|
2664
|
+
React13.useEffect(() => {
|
|
2406
2665
|
if (!fieldDef) return;
|
|
2407
2666
|
const def = fieldDef;
|
|
2408
2667
|
if (def.options?.length) {
|
|
@@ -2457,14 +2716,14 @@ var CheckboxWidget = ({ fieldId }) => {
|
|
|
2457
2716
|
showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
|
|
2458
2717
|
] });
|
|
2459
2718
|
};
|
|
2460
|
-
var AISuggestionsContext =
|
|
2719
|
+
var AISuggestionsContext = React13.createContext({});
|
|
2461
2720
|
function useAISuggestions() {
|
|
2462
|
-
return
|
|
2721
|
+
return React13.useContext(AISuggestionsContext);
|
|
2463
2722
|
}
|
|
2464
2723
|
var AISuggestionsProvider = AISuggestionsContext.Provider;
|
|
2465
2724
|
var Dialog = DialogPrimitive__namespace.Root;
|
|
2466
2725
|
var DialogPortal = DialogPrimitive__namespace.Portal;
|
|
2467
|
-
var DialogOverlay =
|
|
2726
|
+
var DialogOverlay = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2468
2727
|
DialogPrimitive__namespace.Overlay,
|
|
2469
2728
|
{
|
|
2470
2729
|
ref,
|
|
@@ -2476,7 +2735,7 @@ var DialogOverlay = React11__namespace.forwardRef(({ className, ...props }, ref)
|
|
|
2476
2735
|
}
|
|
2477
2736
|
));
|
|
2478
2737
|
DialogOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
|
|
2479
|
-
var DialogContent =
|
|
2738
|
+
var DialogContent = React13__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
|
|
2480
2739
|
/* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
|
|
2481
2740
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2482
2741
|
DialogPrimitive__namespace.Content,
|
|
@@ -2512,7 +2771,7 @@ var DialogHeader = ({
|
|
|
2512
2771
|
}
|
|
2513
2772
|
);
|
|
2514
2773
|
DialogHeader.displayName = "DialogHeader";
|
|
2515
|
-
var DialogTitle =
|
|
2774
|
+
var DialogTitle = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2516
2775
|
DialogPrimitive__namespace.Title,
|
|
2517
2776
|
{
|
|
2518
2777
|
ref,
|
|
@@ -2524,7 +2783,7 @@ var DialogTitle = React11__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
2524
2783
|
}
|
|
2525
2784
|
));
|
|
2526
2785
|
DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
|
|
2527
|
-
var DialogDescription =
|
|
2786
|
+
var DialogDescription = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2528
2787
|
DialogPrimitive__namespace.Description,
|
|
2529
2788
|
{
|
|
2530
2789
|
ref,
|
|
@@ -2554,6 +2813,22 @@ var AddEntityDialog = ({
|
|
|
2554
2813
|
actionSlot != null && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-6 py-4 flex justify-end shrink-0 border-t border-border bg-background", children: actionSlot })
|
|
2555
2814
|
] }) });
|
|
2556
2815
|
};
|
|
2816
|
+
var BEFORE_AFTER_OPTIONS = [
|
|
2817
|
+
{ label: "Blank", value: "" },
|
|
2818
|
+
{ label: "AFTER FOOD", value: "AFTER FOOD" },
|
|
2819
|
+
{ label: "BEFORE FOOD", value: "BEFORE FOOD" },
|
|
2820
|
+
{ label: "WITH FOOD", value: "WITH FOOD" },
|
|
2821
|
+
{ label: "SINGLE DOSE", value: "SINGLE DOSE" },
|
|
2822
|
+
{ label: "BED TIME", value: "BED TIME" },
|
|
2823
|
+
{ label: "EMPTY STOMACH", value: "EMPTY STOMACH" },
|
|
2824
|
+
{ label: "LOCAL APPLICATION", value: "LOCAL APPLICATION" },
|
|
2825
|
+
{ label: "STAT", value: "STAT" },
|
|
2826
|
+
{ label: "INHALATION", value: "INHALATION" }
|
|
2827
|
+
];
|
|
2828
|
+
var BEFORE_AFTER_NORMALIZATION_MAP = {
|
|
2829
|
+
AF: "AFTER FOOD",
|
|
2830
|
+
BF: "BEFORE FOOD"
|
|
2831
|
+
};
|
|
2557
2832
|
function mapToMedication(result) {
|
|
2558
2833
|
return {
|
|
2559
2834
|
id: result.id,
|
|
@@ -2617,7 +2892,7 @@ function mapFrequentItemToMedication(item) {
|
|
|
2617
2892
|
const parsed = parseDuration(item.duration);
|
|
2618
2893
|
const duration_value = item.duration_value ?? parsed.value;
|
|
2619
2894
|
const duration_unit = item.duration_unit ?? parsed.unit;
|
|
2620
|
-
const before_after = item.before_after
|
|
2895
|
+
const before_after = normalizeBeforeAfter(item.before_after);
|
|
2621
2896
|
const routeNote = item.route ? `Route: ${item.route}` : "";
|
|
2622
2897
|
const baseNotes = item.notes?.trim() || "";
|
|
2623
2898
|
const combinedNotes = [baseNotes, routeNote.trim()].filter((part) => part.length > 0).join(" \u2014 ");
|
|
@@ -2636,6 +2911,13 @@ function mapFrequentItemToMedication(item) {
|
|
|
2636
2911
|
notes: combinedNotes
|
|
2637
2912
|
};
|
|
2638
2913
|
}
|
|
2914
|
+
function normalizeBeforeAfter(value) {
|
|
2915
|
+
if (value == null) return "AFTER FOOD";
|
|
2916
|
+
const mapped = BEFORE_AFTER_NORMALIZATION_MAP[value];
|
|
2917
|
+
if (mapped) return mapped;
|
|
2918
|
+
const validValues = BEFORE_AFTER_OPTIONS.map((option) => option.value);
|
|
2919
|
+
return validValues.includes(value) ? value : "AFTER FOOD";
|
|
2920
|
+
}
|
|
2639
2921
|
function Spinner({
|
|
2640
2922
|
value,
|
|
2641
2923
|
onChange
|
|
@@ -2668,7 +2950,7 @@ function MedicationCard({
|
|
|
2668
2950
|
onUpdate,
|
|
2669
2951
|
onRemove
|
|
2670
2952
|
}) {
|
|
2671
|
-
const [notesOpen, setNotesOpen] =
|
|
2953
|
+
const [notesOpen, setNotesOpen] = React13.useState(false);
|
|
2672
2954
|
function set(key, val) {
|
|
2673
2955
|
onUpdate({ ...med, [key]: val });
|
|
2674
2956
|
}
|
|
@@ -2743,16 +3025,13 @@ function MedicationCard({
|
|
|
2743
3025
|
)
|
|
2744
3026
|
] }),
|
|
2745
3027
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-2 items-center flex-1 min-w-0 justify-end", children: ["morning", "afternoon", "night"].map((slot) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col items-center gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, { value: med[slot], onChange: (v) => set(slot, v) }) }, slot)) }),
|
|
2746
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3028
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2747
3029
|
"select",
|
|
2748
3030
|
{
|
|
2749
3031
|
className: "text-xs border border-border rounded px-2 py-1 bg-white shrink-0",
|
|
2750
|
-
value: med.before_after
|
|
2751
|
-
onChange: (e) => set("before_after", e.target.value
|
|
2752
|
-
children:
|
|
2753
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "AF", children: "AF" }),
|
|
2754
|
-
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "BF", children: "BF" })
|
|
2755
|
-
]
|
|
3032
|
+
value: normalizeBeforeAfter(med.before_after),
|
|
3033
|
+
onChange: (e) => set("before_after", e.target.value),
|
|
3034
|
+
children: BEFORE_AFTER_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: option.value, children: option.label }, option.label))
|
|
2756
3035
|
}
|
|
2757
3036
|
)
|
|
2758
3037
|
] }),
|
|
@@ -2832,19 +3111,19 @@ var AddMedicationField = ({
|
|
|
2832
3111
|
frequentItems = [],
|
|
2833
3112
|
suggestedMedications = []
|
|
2834
3113
|
}) => {
|
|
2835
|
-
const [open, setOpen] =
|
|
2836
|
-
const [query, setQuery] =
|
|
2837
|
-
const [results, setResults] =
|
|
2838
|
-
const [loading, setLoading] =
|
|
2839
|
-
const [addingResultId, setAddingResultId] =
|
|
2840
|
-
const debounceRef =
|
|
2841
|
-
const customIdRef =
|
|
2842
|
-
const valueRef =
|
|
2843
|
-
const searchInputRef =
|
|
3114
|
+
const [open, setOpen] = React13.useState(false);
|
|
3115
|
+
const [query, setQuery] = React13.useState("");
|
|
3116
|
+
const [results, setResults] = React13.useState([]);
|
|
3117
|
+
const [loading, setLoading] = React13.useState(false);
|
|
3118
|
+
const [addingResultId, setAddingResultId] = React13.useState(null);
|
|
3119
|
+
const debounceRef = React13.useRef(null);
|
|
3120
|
+
const customIdRef = React13.useRef(-1);
|
|
3121
|
+
const valueRef = React13.useRef([]);
|
|
3122
|
+
const searchInputRef = React13.useRef(null);
|
|
2844
3123
|
const safeValue = Array.isArray(value) ? value : [];
|
|
2845
3124
|
valueRef.current = safeValue;
|
|
2846
3125
|
const addedIds = new Set(safeValue.map((m) => String(m.id)));
|
|
2847
|
-
|
|
3126
|
+
React13.useEffect(() => {
|
|
2848
3127
|
if (!open) {
|
|
2849
3128
|
setQuery("");
|
|
2850
3129
|
setResults([]);
|
|
@@ -3072,18 +3351,18 @@ var AddInvestigationField = ({
|
|
|
3072
3351
|
recentlyUsed = [],
|
|
3073
3352
|
frequentItems = []
|
|
3074
3353
|
}) => {
|
|
3075
|
-
const [open, setOpen] =
|
|
3076
|
-
const [query, setQuery] =
|
|
3077
|
-
const [results, setResults] =
|
|
3078
|
-
const [loading, setLoading] =
|
|
3079
|
-
const [addingId, setAddingId] =
|
|
3080
|
-
const [addingFrequentId, setAddingFrequentId] =
|
|
3081
|
-
const debounceRef =
|
|
3082
|
-
const valueRef =
|
|
3083
|
-
const searchInputRef =
|
|
3354
|
+
const [open, setOpen] = React13.useState(false);
|
|
3355
|
+
const [query, setQuery] = React13.useState("");
|
|
3356
|
+
const [results, setResults] = React13.useState([]);
|
|
3357
|
+
const [loading, setLoading] = React13.useState(false);
|
|
3358
|
+
const [addingId, setAddingId] = React13.useState(null);
|
|
3359
|
+
const [addingFrequentId, setAddingFrequentId] = React13.useState(null);
|
|
3360
|
+
const debounceRef = React13.useRef(null);
|
|
3361
|
+
const valueRef = React13.useRef([]);
|
|
3362
|
+
const searchInputRef = React13.useRef(null);
|
|
3084
3363
|
valueRef.current = value;
|
|
3085
3364
|
const addedIds = new Set(value.map((inv) => inv.id));
|
|
3086
|
-
|
|
3365
|
+
React13.useEffect(() => {
|
|
3087
3366
|
if (!open) {
|
|
3088
3367
|
setQuery("");
|
|
3089
3368
|
setResults([]);
|
|
@@ -3305,18 +3584,18 @@ var AddProcedureField = ({
|
|
|
3305
3584
|
recentlyUsed = [],
|
|
3306
3585
|
frequentItems = []
|
|
3307
3586
|
}) => {
|
|
3308
|
-
const [open, setOpen] =
|
|
3309
|
-
const [query, setQuery] =
|
|
3310
|
-
const [results, setResults] =
|
|
3311
|
-
const [loading, setLoading] =
|
|
3312
|
-
const [addingId, setAddingId] =
|
|
3313
|
-
const [addingFrequentId, setAddingFrequentId] =
|
|
3314
|
-
const debounceRef =
|
|
3315
|
-
const valueRef =
|
|
3316
|
-
const searchInputRef =
|
|
3587
|
+
const [open, setOpen] = React13.useState(false);
|
|
3588
|
+
const [query, setQuery] = React13.useState("");
|
|
3589
|
+
const [results, setResults] = React13.useState([]);
|
|
3590
|
+
const [loading, setLoading] = React13.useState(false);
|
|
3591
|
+
const [addingId, setAddingId] = React13.useState(null);
|
|
3592
|
+
const [addingFrequentId, setAddingFrequentId] = React13.useState(null);
|
|
3593
|
+
const debounceRef = React13.useRef(null);
|
|
3594
|
+
const valueRef = React13.useRef([]);
|
|
3595
|
+
const searchInputRef = React13.useRef(null);
|
|
3317
3596
|
valueRef.current = value;
|
|
3318
3597
|
const addedIds = new Set(value.map((proc) => proc.id));
|
|
3319
|
-
|
|
3598
|
+
React13.useEffect(() => {
|
|
3320
3599
|
if (!open) {
|
|
3321
3600
|
setQuery("");
|
|
3322
3601
|
setResults([]);
|
|
@@ -3534,7 +3813,7 @@ function getStatusBasedClass(status) {
|
|
|
3534
3813
|
}
|
|
3535
3814
|
}
|
|
3536
3815
|
function DiagnosisCard({ item, defaultOpen = false }) {
|
|
3537
|
-
const [open, setOpen] =
|
|
3816
|
+
const [open, setOpen] = React13.useState(defaultOpen);
|
|
3538
3817
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border border-gray-200 rounded-lg bg-[#F2F2F2] mb-2 last:mb-0 overflow-hidden", children: [
|
|
3539
3818
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3540
3819
|
"button",
|
|
@@ -3619,7 +3898,7 @@ var DifferentialDiagnosisWidget = ({ fieldId }) => {
|
|
|
3619
3898
|
const items = Array.isArray(value) ? value : [];
|
|
3620
3899
|
return /* @__PURE__ */ jsxRuntime.jsx(DifferentialDiagnosis, { differentialDiagnosis: items });
|
|
3621
3900
|
};
|
|
3622
|
-
var Spinner2 =
|
|
3901
|
+
var Spinner2 = React13__namespace.forwardRef(
|
|
3623
3902
|
({ className, size = "md", ...props }, ref) => {
|
|
3624
3903
|
const sizeClasses = {
|
|
3625
3904
|
sm: "h-4 w-4 border-2",
|
|
@@ -3764,10 +4043,10 @@ var Vitals = ({
|
|
|
3764
4043
|
var VitalsWidget = ({ fieldId }) => {
|
|
3765
4044
|
const { value, setValue, fieldDef } = useField(fieldId);
|
|
3766
4045
|
const handlers = useFieldHandlers(fieldId);
|
|
3767
|
-
const [loading, setLoading] =
|
|
3768
|
-
const [error, setError] =
|
|
4046
|
+
const [loading, setLoading] = React13.useState(false);
|
|
4047
|
+
const [error, setError] = React13.useState(null);
|
|
3769
4048
|
console.log("[VitalsWidget] fieldId:", fieldId, "| onFetch present:", !!handlers.onFetch, "| value:", value);
|
|
3770
|
-
const fetchVitals =
|
|
4049
|
+
const fetchVitals = React13.useCallback(async () => {
|
|
3771
4050
|
if (!handlers.onFetch) return;
|
|
3772
4051
|
setLoading(true);
|
|
3773
4052
|
setError(null);
|
|
@@ -3781,7 +4060,7 @@ var VitalsWidget = ({ fieldId }) => {
|
|
|
3781
4060
|
setLoading(false);
|
|
3782
4061
|
}
|
|
3783
4062
|
}, [handlers, setValue]);
|
|
3784
|
-
|
|
4063
|
+
React13.useEffect(() => {
|
|
3785
4064
|
fetchVitals();
|
|
3786
4065
|
}, []);
|
|
3787
4066
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3850,15 +4129,15 @@ function normalizeValue(value) {
|
|
|
3850
4129
|
var ReferralWidget = ({ fieldId }) => {
|
|
3851
4130
|
const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
|
|
3852
4131
|
const handlers = useFieldHandlers(fieldId);
|
|
3853
|
-
const [options, setOptions] =
|
|
3854
|
-
const [loading, setLoading] =
|
|
4132
|
+
const [options, setOptions] = React13.useState([]);
|
|
4133
|
+
const [loading, setLoading] = React13.useState(false);
|
|
3855
4134
|
const { state } = useForm();
|
|
3856
4135
|
const showError = !!error && (touched || state.submitAttempted);
|
|
3857
4136
|
const selectedItems = normalizeValue(value);
|
|
3858
4137
|
const availableOptions = options.filter(
|
|
3859
4138
|
(opt) => !selectedItems.some((item) => item.specialization === opt.value)
|
|
3860
4139
|
);
|
|
3861
|
-
const loadOptions =
|
|
4140
|
+
const loadOptions = React13.useCallback(async () => {
|
|
3862
4141
|
if (handlers.onFetchOptions) {
|
|
3863
4142
|
setLoading(true);
|
|
3864
4143
|
try {
|
|
@@ -3879,11 +4158,11 @@ var ReferralWidget = ({ fieldId }) => {
|
|
|
3879
4158
|
setOptions([]);
|
|
3880
4159
|
}
|
|
3881
4160
|
}, [fieldDef, handlers]);
|
|
3882
|
-
|
|
4161
|
+
React13.useEffect(() => {
|
|
3883
4162
|
if (!fieldDef) return;
|
|
3884
4163
|
loadOptions();
|
|
3885
4164
|
}, [fieldDef, loadOptions]);
|
|
3886
|
-
const handleAdd =
|
|
4165
|
+
const handleAdd = React13.useCallback(
|
|
3887
4166
|
(specialization) => {
|
|
3888
4167
|
const next = [...selectedItems, { specialization, is_urgent: false }];
|
|
3889
4168
|
setValue(next);
|
|
@@ -3891,7 +4170,7 @@ var ReferralWidget = ({ fieldId }) => {
|
|
|
3891
4170
|
},
|
|
3892
4171
|
[selectedItems, setValue, setTouched]
|
|
3893
4172
|
);
|
|
3894
|
-
const handleRemove =
|
|
4173
|
+
const handleRemove = React13.useCallback(
|
|
3895
4174
|
(specialization) => {
|
|
3896
4175
|
const next = selectedItems.filter((item) => item.specialization !== specialization);
|
|
3897
4176
|
setValue(next);
|
|
@@ -3899,7 +4178,7 @@ var ReferralWidget = ({ fieldId }) => {
|
|
|
3899
4178
|
},
|
|
3900
4179
|
[selectedItems, setValue, setTouched]
|
|
3901
4180
|
);
|
|
3902
|
-
const handleToggleUrgent =
|
|
4181
|
+
const handleToggleUrgent = React13.useCallback(
|
|
3903
4182
|
(specialization) => {
|
|
3904
4183
|
const next = selectedItems.map(
|
|
3905
4184
|
(item) => item.specialization === specialization ? { ...item, is_urgent: !item.is_urgent } : item
|
|
@@ -3975,7 +4254,7 @@ var ReferralWidget = ({ fieldId }) => {
|
|
|
3975
4254
|
showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
|
|
3976
4255
|
] });
|
|
3977
4256
|
};
|
|
3978
|
-
var Card =
|
|
4257
|
+
var Card = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3979
4258
|
"div",
|
|
3980
4259
|
{
|
|
3981
4260
|
ref,
|
|
@@ -3987,7 +4266,7 @@ var Card = React11__namespace.forwardRef(({ className, ...props }, ref) => /* @_
|
|
|
3987
4266
|
}
|
|
3988
4267
|
));
|
|
3989
4268
|
Card.displayName = "Card";
|
|
3990
|
-
var CardHeader =
|
|
4269
|
+
var CardHeader = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3991
4270
|
"div",
|
|
3992
4271
|
{
|
|
3993
4272
|
ref,
|
|
@@ -3996,7 +4275,7 @@ var CardHeader = React11__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
3996
4275
|
}
|
|
3997
4276
|
));
|
|
3998
4277
|
CardHeader.displayName = "CardHeader";
|
|
3999
|
-
var CardTitle =
|
|
4278
|
+
var CardTitle = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4000
4279
|
"h3",
|
|
4001
4280
|
{
|
|
4002
4281
|
ref,
|
|
@@ -4008,7 +4287,7 @@ var CardTitle = React11__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
4008
4287
|
}
|
|
4009
4288
|
));
|
|
4010
4289
|
CardTitle.displayName = "CardTitle";
|
|
4011
|
-
var CardDescription =
|
|
4290
|
+
var CardDescription = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4012
4291
|
"p",
|
|
4013
4292
|
{
|
|
4014
4293
|
ref,
|
|
@@ -4017,9 +4296,9 @@ var CardDescription = React11__namespace.forwardRef(({ className, ...props }, re
|
|
|
4017
4296
|
}
|
|
4018
4297
|
));
|
|
4019
4298
|
CardDescription.displayName = "CardDescription";
|
|
4020
|
-
var CardContent =
|
|
4299
|
+
var CardContent = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
|
|
4021
4300
|
CardContent.displayName = "CardContent";
|
|
4022
|
-
var CardFooter =
|
|
4301
|
+
var CardFooter = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4023
4302
|
"div",
|
|
4024
4303
|
{
|
|
4025
4304
|
ref,
|
|
@@ -4105,11 +4384,11 @@ function parseLocalDate(dateString) {
|
|
|
4105
4384
|
var FollowupWidget = ({ fieldId }) => {
|
|
4106
4385
|
const { fieldDef, value, setValue, setTouched, error, disabled, visible } = useField(fieldId);
|
|
4107
4386
|
const followup = normalizeFollowup(value);
|
|
4108
|
-
const [calendarOpen, setCalendarOpen] =
|
|
4387
|
+
const [calendarOpen, setCalendarOpen] = React13.useState(false);
|
|
4109
4388
|
const currentFollowupType = followup ? followup.followupType : "no followup";
|
|
4110
4389
|
const hasFollowup = followup !== false;
|
|
4111
|
-
const [displayMode, setDisplayMode] =
|
|
4112
|
-
const [displayUnit, setDisplayUnit] =
|
|
4390
|
+
const [displayMode, setDisplayMode] = React13.useState("duration");
|
|
4391
|
+
const [displayUnit, setDisplayUnit] = React13.useState("days");
|
|
4113
4392
|
const daysNum = hasFollowup ? parseInt(followup.value, 10) || 7 : 7;
|
|
4114
4393
|
const currentDate = hasFollowup ? daysToDate(daysNum) : null;
|
|
4115
4394
|
const followupMode = displayMode;
|
|
@@ -4117,7 +4396,7 @@ var FollowupWidget = ({ fieldId }) => {
|
|
|
4117
4396
|
displayUnit === "weeks" ? Math.round(daysNum / 7) || 1 : Math.round(daysNum / 30) || 1
|
|
4118
4397
|
) : "7";
|
|
4119
4398
|
const currentUnit = displayUnit;
|
|
4120
|
-
const handleFollowupTypeChange =
|
|
4399
|
+
const handleFollowupTypeChange = React13.useCallback(
|
|
4121
4400
|
(newType) => {
|
|
4122
4401
|
setTouched();
|
|
4123
4402
|
if (newType === "no followup") {
|
|
@@ -4133,11 +4412,11 @@ var FollowupWidget = ({ fieldId }) => {
|
|
|
4133
4412
|
},
|
|
4134
4413
|
[followup, hasFollowup, setValue, setTouched]
|
|
4135
4414
|
);
|
|
4136
|
-
const handleModeChange =
|
|
4415
|
+
const handleModeChange = React13.useCallback((newMode) => {
|
|
4137
4416
|
setDisplayMode(newMode);
|
|
4138
4417
|
if (newMode === "date") setCalendarOpen(false);
|
|
4139
4418
|
}, []);
|
|
4140
|
-
const handleValueChange =
|
|
4419
|
+
const handleValueChange = React13.useCallback(
|
|
4141
4420
|
(newValue) => {
|
|
4142
4421
|
setTouched();
|
|
4143
4422
|
const num = parseInt(newValue, 10);
|
|
@@ -4152,10 +4431,10 @@ var FollowupWidget = ({ fieldId }) => {
|
|
|
4152
4431
|
},
|
|
4153
4432
|
[displayUnit, setValue, setTouched]
|
|
4154
4433
|
);
|
|
4155
|
-
const handleUnitChange =
|
|
4434
|
+
const handleUnitChange = React13.useCallback((newUnit) => {
|
|
4156
4435
|
setDisplayUnit(newUnit);
|
|
4157
4436
|
}, []);
|
|
4158
|
-
const handleDateSelect =
|
|
4437
|
+
const handleDateSelect = React13.useCallback(
|
|
4159
4438
|
(selected) => {
|
|
4160
4439
|
setTouched();
|
|
4161
4440
|
setCalendarOpen(false);
|
|
@@ -4288,13 +4567,13 @@ function useSmartKeywords(text, onSearch, debounceDelay = 1e3) {
|
|
|
4288
4567
|
hasOnSearch: typeof onSearch === "function",
|
|
4289
4568
|
debounceDelay
|
|
4290
4569
|
});
|
|
4291
|
-
const [extractedNouns, setExtractedNouns] =
|
|
4292
|
-
const [matchedConditions, setMatchedConditions] =
|
|
4293
|
-
const [isProcessing, setIsProcessing] =
|
|
4294
|
-
const [error, setError] =
|
|
4295
|
-
const timerRef =
|
|
4296
|
-
const abortRef =
|
|
4297
|
-
const processText =
|
|
4570
|
+
const [extractedNouns, setExtractedNouns] = React13.useState([]);
|
|
4571
|
+
const [matchedConditions, setMatchedConditions] = React13.useState([]);
|
|
4572
|
+
const [isProcessing, setIsProcessing] = React13.useState(false);
|
|
4573
|
+
const [error, setError] = React13.useState(null);
|
|
4574
|
+
const timerRef = React13.useRef(null);
|
|
4575
|
+
const abortRef = React13.useRef(0);
|
|
4576
|
+
const processText = React13.useCallback(
|
|
4298
4577
|
async (input, runId) => {
|
|
4299
4578
|
if (!input || input.trim().length === 0) {
|
|
4300
4579
|
console.log("[useSmartKeywords] skip empty input", {
|
|
@@ -4378,7 +4657,7 @@ function useSmartKeywords(text, onSearch, debounceDelay = 1e3) {
|
|
|
4378
4657
|
},
|
|
4379
4658
|
[onSearch]
|
|
4380
4659
|
);
|
|
4381
|
-
|
|
4660
|
+
React13.useEffect(() => {
|
|
4382
4661
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
4383
4662
|
const runId = ++abortRef.current;
|
|
4384
4663
|
console.log("[useSmartKeywords] schedule debounce", {
|
|
@@ -4415,7 +4694,7 @@ var SmartTextareaWidget = ({ fieldId }) => {
|
|
|
4415
4694
|
const structured = value;
|
|
4416
4695
|
const textValue = structured?.text ?? "";
|
|
4417
4696
|
const showError = !!error && (touched || state.submitAttempted);
|
|
4418
|
-
const onSearch =
|
|
4697
|
+
const onSearch = React13.useCallback(
|
|
4419
4698
|
(query) => handler.onSearch(query),
|
|
4420
4699
|
[handler]
|
|
4421
4700
|
);
|
|
@@ -4425,7 +4704,7 @@ var SmartTextareaWidget = ({ fieldId }) => {
|
|
|
4425
4704
|
def?.debounceDelay ?? 1e3
|
|
4426
4705
|
);
|
|
4427
4706
|
const currentKeywords = structured?.extractedKeywords ?? [];
|
|
4428
|
-
const nextKeywords =
|
|
4707
|
+
const nextKeywords = React13.useMemo(() => {
|
|
4429
4708
|
if (matchedConditions.length === 0 && currentKeywords.length === 0) return currentKeywords;
|
|
4430
4709
|
if (matchedConditions.length === currentKeywords.length && matchedConditions.every(
|
|
4431
4710
|
(m, i) => m.matchedCondition.id === currentKeywords[i]?.matchedCondition.id && m.extractedKeyword === currentKeywords[i]?.extractedKeyword
|
|
@@ -4434,19 +4713,19 @@ var SmartTextareaWidget = ({ fieldId }) => {
|
|
|
4434
4713
|
}
|
|
4435
4714
|
return matchedConditions;
|
|
4436
4715
|
}, [matchedConditions, currentKeywords]);
|
|
4437
|
-
const writeValue =
|
|
4716
|
+
const writeValue = React13.useCallback(
|
|
4438
4717
|
(text, keywords) => {
|
|
4439
4718
|
const next = { text, extractedKeywords: keywords };
|
|
4440
4719
|
setValue(next);
|
|
4441
4720
|
},
|
|
4442
4721
|
[setValue]
|
|
4443
4722
|
);
|
|
4444
|
-
|
|
4723
|
+
React13__namespace.default.useEffect(() => {
|
|
4445
4724
|
if (nextKeywords !== currentKeywords) {
|
|
4446
4725
|
writeValue(textValue, nextKeywords);
|
|
4447
4726
|
}
|
|
4448
4727
|
}, [nextKeywords]);
|
|
4449
|
-
const handleTextChange =
|
|
4728
|
+
const handleTextChange = React13.useCallback(
|
|
4450
4729
|
(e) => {
|
|
4451
4730
|
writeValue(e.target.value, currentKeywords);
|
|
4452
4731
|
},
|
|
@@ -4688,10 +4967,10 @@ function stripGpalSuffix(label) {
|
|
|
4688
4967
|
return label.replace(/\s*\(G-P-A-L\)\s*$/i, "").trim();
|
|
4689
4968
|
}
|
|
4690
4969
|
function useDebouncedCommit(commit, delayMs) {
|
|
4691
|
-
const timeoutRef =
|
|
4692
|
-
const latestCommit =
|
|
4970
|
+
const timeoutRef = React13.useRef(null);
|
|
4971
|
+
const latestCommit = React13.useRef(commit);
|
|
4693
4972
|
latestCommit.current = commit;
|
|
4694
|
-
|
|
4973
|
+
React13.useEffect(() => {
|
|
4695
4974
|
return () => {
|
|
4696
4975
|
if (timeoutRef.current != null) window.clearTimeout(timeoutRef.current);
|
|
4697
4976
|
};
|
|
@@ -4703,18 +4982,18 @@ function useDebouncedCommit(commit, delayMs) {
|
|
|
4703
4982
|
}
|
|
4704
4983
|
var ObstetricHistoryWidget = ({ fieldId }) => {
|
|
4705
4984
|
const { fieldDef, value, setValue, disabled } = useField(fieldId);
|
|
4706
|
-
const [{ draft, isNewEntry }, setDraftState] =
|
|
4707
|
-
const [lmpError, setLmpError] =
|
|
4708
|
-
const [primaryEddError, setPrimaryEddError] =
|
|
4709
|
-
const [activeGpalKey, setActiveGpalKey] =
|
|
4985
|
+
const [{ draft, isNewEntry }, setDraftState] = React13.useState(() => normalizeToDraft(value));
|
|
4986
|
+
const [lmpError, setLmpError] = React13.useState(null);
|
|
4987
|
+
const [primaryEddError, setPrimaryEddError] = React13.useState(null);
|
|
4988
|
+
const [activeGpalKey, setActiveGpalKey] = React13.useState(null);
|
|
4710
4989
|
const refs = {
|
|
4711
|
-
G:
|
|
4712
|
-
P:
|
|
4713
|
-
A:
|
|
4714
|
-
L:
|
|
4990
|
+
G: React13.useRef(null),
|
|
4991
|
+
P: React13.useRef(null),
|
|
4992
|
+
A: React13.useRef(null),
|
|
4993
|
+
L: React13.useRef(null)
|
|
4715
4994
|
};
|
|
4716
|
-
const today =
|
|
4717
|
-
|
|
4995
|
+
const today = React13.useMemo(() => todayIso(), []);
|
|
4996
|
+
React13.useEffect(() => {
|
|
4718
4997
|
const next = normalizeToDraft(value);
|
|
4719
4998
|
const currStr = JSON.stringify(buildStored(draft, today));
|
|
4720
4999
|
const nextStr = JSON.stringify(buildStored(next.draft, today));
|
|
@@ -4725,7 +5004,7 @@ var ObstetricHistoryWidget = ({ fieldId }) => {
|
|
|
4725
5004
|
setValue(JSON.stringify(stored));
|
|
4726
5005
|
};
|
|
4727
5006
|
const commitDebounced = useDebouncedCommit(commitImmediate, 500);
|
|
4728
|
-
const storedComputed =
|
|
5007
|
+
const storedComputed = React13.useMemo(() => buildStored(draft, today), [draft, today]);
|
|
4729
5008
|
const rightPanelEnabled = draft.is_pregnant && (!!storedComputed.lmp || !!storedComputed.edd?.usg);
|
|
4730
5009
|
const headerLabel = fieldDef?.label ? stripGpalSuffix(fieldDef.label) : "Obstetric History";
|
|
4731
5010
|
const setDraft = (updater, persist) => {
|
|
@@ -5174,7 +5453,7 @@ var numberInputClass = "w-full border border-[#D0D0D0] rounded-md bg-white px-2
|
|
|
5174
5453
|
var textInputClass = "w-full border border-[#D0D0D0] rounded-md bg-white px-2 py-1 text-xs focus-visible:outline-none focus-visible:ring-0";
|
|
5175
5454
|
var OphthalmologyWidget = ({ fieldId }) => {
|
|
5176
5455
|
const { fieldDef, value, setValue, disabled } = useField(fieldId);
|
|
5177
|
-
const safe =
|
|
5456
|
+
const safe = React13.useMemo(() => ensureValue(value), [value]);
|
|
5178
5457
|
const label = fieldDef?.label || "";
|
|
5179
5458
|
const update = (updater) => {
|
|
5180
5459
|
if (disabled) return;
|
|
@@ -6351,7 +6630,7 @@ var headerCellClass = "border border-slate-200 px-2 py-1 text-center font-semibo
|
|
|
6351
6630
|
var cellClass = "border border-slate-200 px-2 py-1 align-top";
|
|
6352
6631
|
var OphthalDiagnosisWidget = ({ fieldId }) => {
|
|
6353
6632
|
const { fieldDef, value, setValue, disabled } = useField(fieldId);
|
|
6354
|
-
const safe =
|
|
6633
|
+
const safe = React13.useMemo(() => ensureValue2(value), [value]);
|
|
6355
6634
|
const label = fieldDef?.label || "";
|
|
6356
6635
|
const updateEyeField = (eye, fieldLabel, next) => {
|
|
6357
6636
|
if (disabled) return;
|
|
@@ -6401,7 +6680,7 @@ var OphthalDiagnosisWidget = ({ fieldId }) => {
|
|
|
6401
6680
|
] })
|
|
6402
6681
|
] });
|
|
6403
6682
|
};
|
|
6404
|
-
var Slider =
|
|
6683
|
+
var Slider = React13__namespace.forwardRef(({ className, trackClassName, thumbClassName, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6405
6684
|
SliderPrimitive__namespace.Root,
|
|
6406
6685
|
{
|
|
6407
6686
|
ref,
|
|
@@ -6495,7 +6774,7 @@ var OrthopedicExamWidget = ({ fieldId }) => {
|
|
|
6495
6774
|
const { fieldDef, value, setValue, setTouched, error, touched, disabled } = useField(fieldId);
|
|
6496
6775
|
const { state } = useForm();
|
|
6497
6776
|
const showError = !!error && (touched || state.submitAttempted);
|
|
6498
|
-
const safeValue =
|
|
6777
|
+
const safeValue = React13.useMemo(() => {
|
|
6499
6778
|
if (!value || typeof value !== "object") return defaultValue();
|
|
6500
6779
|
const v = value;
|
|
6501
6780
|
const concerns = Array.isArray(v.concerns) ? v.concerns : [];
|
|
@@ -6517,10 +6796,10 @@ var OrthopedicExamWidget = ({ fieldId }) => {
|
|
|
6517
6796
|
}
|
|
6518
6797
|
};
|
|
6519
6798
|
}, [value]);
|
|
6520
|
-
const [panelOpen, setPanelOpen] =
|
|
6521
|
-
const draggingRef =
|
|
6522
|
-
const prevConcernsLengthRef =
|
|
6523
|
-
const reminderSections =
|
|
6799
|
+
const [panelOpen, setPanelOpen] = React13.useState(false);
|
|
6800
|
+
const draggingRef = React13.useRef(null);
|
|
6801
|
+
const prevConcernsLengthRef = React13.useRef(safeValue.concerns.length);
|
|
6802
|
+
const reminderSections = React13.useMemo(() => {
|
|
6524
6803
|
return safeValue.concerns.map((id) => ({
|
|
6525
6804
|
id,
|
|
6526
6805
|
label: CONCERNS.find((c) => c.id === id)?.label ?? id,
|
|
@@ -6528,7 +6807,7 @@ var OrthopedicExamWidget = ({ fieldId }) => {
|
|
|
6528
6807
|
})).filter((s) => s.points.length > 0);
|
|
6529
6808
|
}, [safeValue.concerns]);
|
|
6530
6809
|
const hasReminders = reminderSections.length > 0;
|
|
6531
|
-
|
|
6810
|
+
React13.useEffect(() => {
|
|
6532
6811
|
const prevLen = prevConcernsLengthRef.current;
|
|
6533
6812
|
const currLen = safeValue.concerns.length;
|
|
6534
6813
|
prevConcernsLengthRef.current = currLen;
|
|
@@ -6543,7 +6822,7 @@ var OrthopedicExamWidget = ({ fieldId }) => {
|
|
|
6543
6822
|
setPanelOpen(true);
|
|
6544
6823
|
}
|
|
6545
6824
|
}, [safeValue, setValue]);
|
|
6546
|
-
|
|
6825
|
+
React13.useEffect(() => {
|
|
6547
6826
|
const onMove = (e) => {
|
|
6548
6827
|
if (!draggingRef.current) return;
|
|
6549
6828
|
const { startX, startY, startTop, startRight } = draggingRef.current;
|
|
@@ -6794,8 +7073,9 @@ var FieldRenderer = ({ fieldId }) => {
|
|
|
6794
7073
|
case "number":
|
|
6795
7074
|
return /* @__PURE__ */ jsxRuntime.jsx(TextWidget, { fieldId });
|
|
6796
7075
|
case "textarea":
|
|
6797
|
-
case "richtext":
|
|
6798
7076
|
return /* @__PURE__ */ jsxRuntime.jsx(TextWidget, { fieldId });
|
|
7077
|
+
case "richtext":
|
|
7078
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RichTextWidget, { fieldId });
|
|
6799
7079
|
case "date":
|
|
6800
7080
|
return /* @__PURE__ */ jsxRuntime.jsx(DateWidget, { fieldId });
|
|
6801
7081
|
case "datetime":
|
|
@@ -6860,7 +7140,7 @@ var FieldRenderer = ({ fieldId }) => {
|
|
|
6860
7140
|
}
|
|
6861
7141
|
};
|
|
6862
7142
|
var Section = ({ title, children }) => {
|
|
6863
|
-
const [expanded, setExpanded] =
|
|
7143
|
+
const [expanded, setExpanded] = React13.useState(true);
|
|
6864
7144
|
const handleToggle = () => setExpanded((prev) => !prev);
|
|
6865
7145
|
const contentClassName = cn(
|
|
6866
7146
|
"overflow-hidden transition-[height] duration-200 ease-in-out",
|
|
@@ -6913,7 +7193,7 @@ var DynamicForm = () => {
|
|
|
6913
7193
|
children: child.children.map((fieldId) => /* @__PURE__ */ jsxRuntime.jsx(FieldRenderer, { fieldId }, fieldId))
|
|
6914
7194
|
},
|
|
6915
7195
|
child.id
|
|
6916
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
7196
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(React13__namespace.default.Fragment, {}, child.id ?? index)
|
|
6917
7197
|
) }, node.id);
|
|
6918
7198
|
}
|
|
6919
7199
|
if (node.type === "column_layout") {
|
|
@@ -7001,13 +7281,13 @@ var SmartForm = ({
|
|
|
7001
7281
|
}) => {
|
|
7002
7282
|
const store = useFormStore();
|
|
7003
7283
|
const schema = store.getSchema();
|
|
7004
|
-
const prevAiResultRef =
|
|
7005
|
-
const aiSuggestions =
|
|
7284
|
+
const prevAiResultRef = React13.useRef(void 0);
|
|
7285
|
+
const aiSuggestions = React13.useMemo(() => {
|
|
7006
7286
|
if (aiAnalysisResult == null) return { medications: [] };
|
|
7007
7287
|
const medications = normalizeAIMedications(aiAnalysisResult.medications);
|
|
7008
7288
|
return { medications };
|
|
7009
7289
|
}, [aiAnalysisResult]);
|
|
7010
|
-
|
|
7290
|
+
React13.useEffect(() => {
|
|
7011
7291
|
if (aiAnalysisResult == null || Object.keys(aiAnalysisResult).length === 0) return;
|
|
7012
7292
|
const prev = prevAiResultRef.current;
|
|
7013
7293
|
if (prev != null && prev === aiAnalysisResult && shallowEqualKeys(prev, aiAnalysisResult)) return;
|
|
@@ -7080,9 +7360,9 @@ var ReadOnlyText = ({ fieldDef, value }) => {
|
|
|
7080
7360
|
] });
|
|
7081
7361
|
};
|
|
7082
7362
|
var ReadOnlySelect = ({ fieldDef, value }) => {
|
|
7083
|
-
const [options, setOptions] =
|
|
7084
|
-
const [loading, setLoading] =
|
|
7085
|
-
|
|
7363
|
+
const [options, setOptions] = React13.useState([]);
|
|
7364
|
+
const [loading, setLoading] = React13.useState(false);
|
|
7365
|
+
React13.useEffect(() => {
|
|
7086
7366
|
if (fieldDef.options) {
|
|
7087
7367
|
setOptions(fieldDef.options);
|
|
7088
7368
|
} else if (fieldDef.dataSource) {
|
|
@@ -7104,9 +7384,9 @@ var ReadOnlySelect = ({ fieldDef, value }) => {
|
|
|
7104
7384
|
] });
|
|
7105
7385
|
};
|
|
7106
7386
|
var ReadOnlyMultiSelect = ({ fieldDef, value }) => {
|
|
7107
|
-
const [options, setOptions] =
|
|
7108
|
-
const [loading, setLoading] =
|
|
7109
|
-
|
|
7387
|
+
const [options, setOptions] = React13.useState([]);
|
|
7388
|
+
const [loading, setLoading] = React13.useState(false);
|
|
7389
|
+
React13.useEffect(() => {
|
|
7110
7390
|
if (fieldDef.options) {
|
|
7111
7391
|
setOptions(fieldDef.options);
|
|
7112
7392
|
} else if (fieldDef.dataSource) {
|
|
@@ -7255,13 +7535,13 @@ var ReadOnlyTable = ({
|
|
|
7255
7535
|
fieldDef,
|
|
7256
7536
|
value
|
|
7257
7537
|
}) => {
|
|
7258
|
-
const tableData =
|
|
7538
|
+
const tableData = React13.useMemo(() => {
|
|
7259
7539
|
if (value && typeof value === "object" && "columns" in value && "rows" in value && Array.isArray(value.columns) && Array.isArray(value.rows)) {
|
|
7260
7540
|
return value;
|
|
7261
7541
|
}
|
|
7262
7542
|
return { columns: [], rows: [] };
|
|
7263
7543
|
}, [value]);
|
|
7264
|
-
const columns =
|
|
7544
|
+
const columns = React13.useMemo(() => {
|
|
7265
7545
|
return tableData.columns.map((col) => ({
|
|
7266
7546
|
accessorKey: col.id,
|
|
7267
7547
|
header: col.label,
|
|
@@ -7316,9 +7596,9 @@ var ReadOnlyDateTime = ({ fieldDef, value }) => {
|
|
|
7316
7596
|
] });
|
|
7317
7597
|
};
|
|
7318
7598
|
var ReadOnlyRadio = ({ fieldDef, value }) => {
|
|
7319
|
-
const [options, setOptions] =
|
|
7320
|
-
const [loading, setLoading] =
|
|
7321
|
-
|
|
7599
|
+
const [options, setOptions] = React13.useState([]);
|
|
7600
|
+
const [loading, setLoading] = React13.useState(false);
|
|
7601
|
+
React13.useEffect(() => {
|
|
7322
7602
|
if (fieldDef.options?.length) {
|
|
7323
7603
|
setOptions(fieldDef.options);
|
|
7324
7604
|
} else if (fieldDef.dataSource) {
|
|
@@ -7343,9 +7623,9 @@ function isOptionSelected2(selected, optValue) {
|
|
|
7343
7623
|
);
|
|
7344
7624
|
}
|
|
7345
7625
|
var ReadOnlyCheckbox = ({ fieldDef, value }) => {
|
|
7346
|
-
const [options, setOptions] =
|
|
7347
|
-
const [loading, setLoading] =
|
|
7348
|
-
|
|
7626
|
+
const [options, setOptions] = React13.useState([]);
|
|
7627
|
+
const [loading, setLoading] = React13.useState(false);
|
|
7628
|
+
React13.useEffect(() => {
|
|
7349
7629
|
if (fieldDef.options?.length) {
|
|
7350
7630
|
setOptions(fieldDef.options);
|
|
7351
7631
|
} else if (fieldDef.dataSource) {
|
|
@@ -7497,7 +7777,7 @@ var ReadOnlyForm = ({ schema, submission }) => {
|
|
|
7497
7777
|
child.id
|
|
7498
7778
|
);
|
|
7499
7779
|
}
|
|
7500
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7780
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React13__namespace.default.Fragment, {}, child.id ?? index);
|
|
7501
7781
|
};
|
|
7502
7782
|
const hasContent = node.children.some(
|
|
7503
7783
|
(child) => typeof child === "string" ? fieldMap.has(child) : child.type === "column_layout" && child.children?.some((id) => fieldMap.has(id))
|
|
@@ -7639,6 +7919,7 @@ exports.ReadOnlyForm = ReadOnlyForm;
|
|
|
7639
7919
|
exports.ReadOnlyImageUpload = ReadOnlyImageUpload;
|
|
7640
7920
|
exports.ReadOnlySignature = ReadOnlySignature;
|
|
7641
7921
|
exports.ReadOnlyTable = ReadOnlyTable;
|
|
7922
|
+
exports.RichTextWidget = RichTextWidget;
|
|
7642
7923
|
exports.SignatureUploadWidget = SignatureUploadWidget;
|
|
7643
7924
|
exports.SmartForm = SmartForm;
|
|
7644
7925
|
exports.SmartTextareaWidget = SmartTextareaWidget;
|