formanitor 0.0.28 → 0.0.29
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 +315 -215
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.mjs +155 -55
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React15 = require('react');
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var lucideReact = require('lucide-react');
|
|
5
6
|
var clsx = require('clsx');
|
|
6
7
|
var tailwindMerge = require('tailwind-merge');
|
|
7
8
|
var LabelPrimitive = require('@radix-ui/react-label');
|
|
@@ -10,7 +11,6 @@ var react = require('@tiptap/react');
|
|
|
10
11
|
var StarterKit = require('@tiptap/starter-kit');
|
|
11
12
|
var Placeholder = require('@tiptap/extension-placeholder');
|
|
12
13
|
var Underline = require('@tiptap/extension-underline');
|
|
13
|
-
var lucideReact = require('lucide-react');
|
|
14
14
|
var reactSlot = require('@radix-ui/react-slot');
|
|
15
15
|
var SeparatorPrimitive = require('@radix-ui/react-separator');
|
|
16
16
|
var SelectPrimitive = require('@radix-ui/react-select');
|
|
@@ -44,7 +44,7 @@ function _interopNamespace(e) {
|
|
|
44
44
|
return Object.freeze(n);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
var
|
|
47
|
+
var React15__namespace = /*#__PURE__*/_interopNamespace(React15);
|
|
48
48
|
var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
|
|
49
49
|
var StarterKit__default = /*#__PURE__*/_interopDefault(StarterKit);
|
|
50
50
|
var Placeholder__default = /*#__PURE__*/_interopDefault(Placeholder);
|
|
@@ -286,6 +286,9 @@ var FormStore = class {
|
|
|
286
286
|
getFieldDef(fieldId) {
|
|
287
287
|
return this.fieldMap[fieldId];
|
|
288
288
|
}
|
|
289
|
+
getVoice() {
|
|
290
|
+
return this.config.voice;
|
|
291
|
+
}
|
|
289
292
|
hasPersistence() {
|
|
290
293
|
return this.persistence !== NO_OP_PROVIDER;
|
|
291
294
|
}
|
|
@@ -638,6 +641,7 @@ var FormStore = class {
|
|
|
638
641
|
if (next.onUpload !== void 0) this.config.onUpload = next.onUpload;
|
|
639
642
|
if (next.onEvent !== void 0) this.config.onEvent = next.onEvent;
|
|
640
643
|
if (next.onDraftChange !== void 0) this.config.onDraftChange = next.onDraftChange;
|
|
644
|
+
if (next.voice !== void 0) this.config.voice = next.voice;
|
|
641
645
|
if (next.role !== void 0 && next.role !== this.config.role) {
|
|
642
646
|
this.config.role = next.role;
|
|
643
647
|
needsReeval = true;
|
|
@@ -699,20 +703,35 @@ var FormStore = class {
|
|
|
699
703
|
this.listeners.forEach((l) => l(this.state));
|
|
700
704
|
}
|
|
701
705
|
};
|
|
702
|
-
var
|
|
706
|
+
var VoiceContext = React15.createContext({
|
|
707
|
+
activeFieldId: null,
|
|
708
|
+
setActiveFieldId: () => {
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
function useVoiceContext() {
|
|
712
|
+
return React15.useContext(VoiceContext);
|
|
713
|
+
}
|
|
714
|
+
function VoiceContextProvider({ children }) {
|
|
715
|
+
const [activeFieldId, setActiveFieldIdState] = React15.useState(null);
|
|
716
|
+
const setActiveFieldId = React15.useCallback((id) => {
|
|
717
|
+
setActiveFieldIdState(id);
|
|
718
|
+
}, []);
|
|
719
|
+
return /* @__PURE__ */ jsxRuntime.jsx(VoiceContext.Provider, { value: { activeFieldId, setActiveFieldId }, children });
|
|
720
|
+
}
|
|
721
|
+
var FormContext = React15.createContext(null);
|
|
703
722
|
var emptyFrequentItems = {
|
|
704
723
|
medications: [],
|
|
705
724
|
investigations: [],
|
|
706
725
|
procedures: []
|
|
707
726
|
};
|
|
708
|
-
var FrequentItemsContext =
|
|
709
|
-
var FieldHandlersContext =
|
|
727
|
+
var FrequentItemsContext = React15.createContext(emptyFrequentItems);
|
|
728
|
+
var FieldHandlersContext = React15.createContext({});
|
|
710
729
|
function useFieldHandlers(fieldId) {
|
|
711
|
-
const map =
|
|
730
|
+
const map = React15.useContext(FieldHandlersContext);
|
|
712
731
|
return map[fieldId] ?? { onSearch: async () => [], recentlyUsed: [] };
|
|
713
732
|
}
|
|
714
733
|
function useFrequentItems() {
|
|
715
|
-
return
|
|
734
|
+
return React15.useContext(FrequentItemsContext);
|
|
716
735
|
}
|
|
717
736
|
var FormProvider = ({
|
|
718
737
|
schema,
|
|
@@ -721,23 +740,23 @@ var FormProvider = ({
|
|
|
721
740
|
frequentItems,
|
|
722
741
|
children
|
|
723
742
|
}) => {
|
|
724
|
-
const storeRef =
|
|
743
|
+
const storeRef = React15.useRef(null);
|
|
725
744
|
if (!storeRef.current) {
|
|
726
745
|
storeRef.current = new FormStore(schema, config);
|
|
727
746
|
}
|
|
728
|
-
|
|
747
|
+
React15.useEffect(() => {
|
|
729
748
|
if (storeRef.current && config) {
|
|
730
749
|
storeRef.current.updateConfig(config);
|
|
731
750
|
}
|
|
732
751
|
});
|
|
733
|
-
|
|
752
|
+
React15.useEffect(() => {
|
|
734
753
|
storeRef.current?.load();
|
|
735
754
|
}, []);
|
|
736
755
|
const frequentItemsValue = frequentItems ?? emptyFrequentItems;
|
|
737
|
-
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 }) }) });
|
|
756
|
+
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: /* @__PURE__ */ jsxRuntime.jsx(VoiceContextProvider, { children }) }) }) });
|
|
738
757
|
};
|
|
739
758
|
function useFormStore() {
|
|
740
|
-
const context =
|
|
759
|
+
const context = React15.useContext(FormContext);
|
|
741
760
|
if (!context) {
|
|
742
761
|
throw new Error("useFormStore must be used within a FormProvider");
|
|
743
762
|
}
|
|
@@ -745,8 +764,8 @@ function useFormStore() {
|
|
|
745
764
|
}
|
|
746
765
|
function useForm() {
|
|
747
766
|
const store = useFormStore();
|
|
748
|
-
const [state, setState] =
|
|
749
|
-
|
|
767
|
+
const [state, setState] = React15.useState(store.getState());
|
|
768
|
+
React15.useEffect(() => {
|
|
750
769
|
const unsubscribe = store.subscribe((newState) => {
|
|
751
770
|
setState({ ...newState });
|
|
752
771
|
});
|
|
@@ -768,8 +787,8 @@ function useForm() {
|
|
|
768
787
|
}
|
|
769
788
|
function useField(fieldId) {
|
|
770
789
|
const store = useFormStore();
|
|
771
|
-
const [fieldState, setFieldState] =
|
|
772
|
-
|
|
790
|
+
const [fieldState, setFieldState] = React15.useState(store.getFieldState(fieldId));
|
|
791
|
+
React15.useEffect(() => {
|
|
773
792
|
const unsubscribe = store.subscribe(() => {
|
|
774
793
|
const newState = store.getFieldState(fieldId);
|
|
775
794
|
setFieldState((prev) => {
|
|
@@ -791,10 +810,76 @@ function useField(fieldId) {
|
|
|
791
810
|
setTouched
|
|
792
811
|
};
|
|
793
812
|
}
|
|
813
|
+
function RecordingWave() {
|
|
814
|
+
const bars = [
|
|
815
|
+
{ dur: "0.6s", values: "3;10;3", yValues: "4.5;0;4.5", delay: "0s" },
|
|
816
|
+
{ dur: "0.6s", values: "8;3;8", yValues: "2;4.5;2", delay: "0.1s" },
|
|
817
|
+
{ dur: "0.6s", values: "5;11;5", yValues: "3.5;0.5;3.5", delay: "0.05s" },
|
|
818
|
+
{ dur: "0.6s", values: "10;4;10", yValues: "1;4;1", delay: "0.15s" }
|
|
819
|
+
];
|
|
820
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "12", viewBox: "0 0 18 12", "aria-hidden": true, children: bars.map((b, i) => /* @__PURE__ */ jsxRuntime.jsxs("rect", { x: i * 4 + 1, width: "2.5", rx: "1.25", fill: "currentColor", y: "0", height: "12", children: [
|
|
821
|
+
/* @__PURE__ */ jsxRuntime.jsx("animate", { attributeName: "height", values: b.values, dur: b.dur, begin: b.delay, repeatCount: "indefinite" }),
|
|
822
|
+
/* @__PURE__ */ jsxRuntime.jsx("animate", { attributeName: "y", values: b.yValues, dur: b.dur, begin: b.delay, repeatCount: "indefinite" })
|
|
823
|
+
] }, i)) });
|
|
824
|
+
}
|
|
825
|
+
function VoiceMicButton({ fieldId, onTranscriptReady }) {
|
|
826
|
+
const store = useFormStore();
|
|
827
|
+
const { activeFieldId, setActiveFieldId } = useVoiceContext();
|
|
828
|
+
const [status, setStatus] = React15.useState("idle");
|
|
829
|
+
const voice = store.getVoice();
|
|
830
|
+
const isActive = activeFieldId === fieldId;
|
|
831
|
+
const isRecording = status === "recording" && isActive;
|
|
832
|
+
const isTranscribing = status === "transcribing" && isActive;
|
|
833
|
+
const isBlocked = activeFieldId !== null && !isActive;
|
|
834
|
+
const handleClick = React15.useCallback(async () => {
|
|
835
|
+
if (!voice || isBlocked || isTranscribing) return;
|
|
836
|
+
if (isRecording) {
|
|
837
|
+
setStatus("transcribing");
|
|
838
|
+
try {
|
|
839
|
+
const transcript = await voice.stopRecording();
|
|
840
|
+
if (transcript) onTranscriptReady(transcript);
|
|
841
|
+
} catch {
|
|
842
|
+
} finally {
|
|
843
|
+
setStatus("idle");
|
|
844
|
+
setActiveFieldId(null);
|
|
845
|
+
}
|
|
846
|
+
} else {
|
|
847
|
+
setActiveFieldId(fieldId);
|
|
848
|
+
setStatus("recording");
|
|
849
|
+
try {
|
|
850
|
+
await voice.startRecording();
|
|
851
|
+
} catch {
|
|
852
|
+
setStatus("idle");
|
|
853
|
+
setActiveFieldId(null);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
}, [voice, isBlocked, isTranscribing, isRecording, fieldId, onTranscriptReady, setActiveFieldId]);
|
|
857
|
+
const title = isTranscribing ? "Processing\u2026" : isRecording ? "Stop recording" : "Dictate this field";
|
|
858
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
859
|
+
"button",
|
|
860
|
+
{
|
|
861
|
+
type: "button",
|
|
862
|
+
onClick: handleClick,
|
|
863
|
+
disabled: isBlocked || isTranscribing,
|
|
864
|
+
title,
|
|
865
|
+
className: [
|
|
866
|
+
"flex items-center gap-1 rounded px-1 py-0.5",
|
|
867
|
+
"text-[11px] font-medium transition-opacity",
|
|
868
|
+
isBlocked ? "pointer-events-none opacity-30" : "",
|
|
869
|
+
isTranscribing ? "cursor-wait opacity-50" : "",
|
|
870
|
+
!isBlocked && !isTranscribing ? "hover:opacity-70" : ""
|
|
871
|
+
].filter(Boolean).join(" "),
|
|
872
|
+
children: isTranscribing ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-3.5 w-3.5 animate-spin text-slate-400" }) : isRecording ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
873
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-rose-400", children: /* @__PURE__ */ jsxRuntime.jsx(RecordingWave, {}) }),
|
|
874
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-rose-400", children: "Stop" })
|
|
875
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Mic, { className: "h-4 w-4 text-slate-400" })
|
|
876
|
+
}
|
|
877
|
+
);
|
|
878
|
+
}
|
|
794
879
|
function cn(...inputs) {
|
|
795
880
|
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
796
881
|
}
|
|
797
|
-
var Input =
|
|
882
|
+
var Input = React15__namespace.forwardRef(
|
|
798
883
|
({ className, type, ...props }, ref) => {
|
|
799
884
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
800
885
|
"input",
|
|
@@ -814,7 +899,7 @@ Input.displayName = "Input";
|
|
|
814
899
|
var labelVariants = classVarianceAuthority.cva(
|
|
815
900
|
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
816
901
|
);
|
|
817
|
-
var Label =
|
|
902
|
+
var Label = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
818
903
|
LabelPrimitive__namespace.Root,
|
|
819
904
|
{
|
|
820
905
|
ref,
|
|
@@ -823,7 +908,7 @@ var Label = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @
|
|
|
823
908
|
}
|
|
824
909
|
));
|
|
825
910
|
Label.displayName = LabelPrimitive__namespace.Root.displayName;
|
|
826
|
-
var Textarea =
|
|
911
|
+
var Textarea = React15__namespace.forwardRef(
|
|
827
912
|
({ className, height, style, ...props }, ref) => {
|
|
828
913
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
829
914
|
"textarea",
|
|
@@ -867,6 +952,8 @@ function getThemeConfig(fieldType, themeName) {
|
|
|
867
952
|
var TextWidget = ({ fieldId }) => {
|
|
868
953
|
const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
|
|
869
954
|
const { state } = useForm();
|
|
955
|
+
const store = useFormStore();
|
|
956
|
+
const hasVoice = !!(fieldDef?.voice && store.getVoice());
|
|
870
957
|
const showError = !!error && (touched || state.submitAttempted);
|
|
871
958
|
if (!fieldDef) return null;
|
|
872
959
|
const Component = fieldDef.type === "textarea" ? Textarea : Input;
|
|
@@ -884,8 +971,12 @@ var TextWidget = ({ fieldId }) => {
|
|
|
884
971
|
" ",
|
|
885
972
|
fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
|
|
886
973
|
] });
|
|
974
|
+
const labelEl = theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, children: labelContent });
|
|
887
975
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperClass, children: [
|
|
888
|
-
|
|
976
|
+
hasVoice ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
977
|
+
labelEl,
|
|
978
|
+
/* @__PURE__ */ jsxRuntime.jsx(VoiceMicButton, { fieldId, onTranscriptReady: setValue })
|
|
979
|
+
] }) : labelEl,
|
|
889
980
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
890
981
|
Component,
|
|
891
982
|
{
|
|
@@ -927,7 +1018,7 @@ var buttonVariants = classVarianceAuthority.cva(
|
|
|
927
1018
|
}
|
|
928
1019
|
}
|
|
929
1020
|
);
|
|
930
|
-
var Button =
|
|
1021
|
+
var Button = React15__namespace.forwardRef(
|
|
931
1022
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
932
1023
|
const Comp = asChild ? reactSlot.Slot : "button";
|
|
933
1024
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -941,7 +1032,7 @@ var Button = React13__namespace.forwardRef(
|
|
|
941
1032
|
}
|
|
942
1033
|
);
|
|
943
1034
|
Button.displayName = "Button";
|
|
944
|
-
var Separator =
|
|
1035
|
+
var Separator = React15__namespace.forwardRef(
|
|
945
1036
|
({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
946
1037
|
SeparatorPrimitive__namespace.Root,
|
|
947
1038
|
{
|
|
@@ -966,8 +1057,8 @@ function RichTextToolbar({
|
|
|
966
1057
|
editor,
|
|
967
1058
|
disabled
|
|
968
1059
|
}) {
|
|
969
|
-
const [, rerender] =
|
|
970
|
-
|
|
1060
|
+
const [, rerender] = React15.useReducer((n) => n + 1, 0);
|
|
1061
|
+
React15.useEffect(() => {
|
|
971
1062
|
if (!editor) return;
|
|
972
1063
|
const handler = () => rerender();
|
|
973
1064
|
editor.on("selectionUpdate", handler);
|
|
@@ -1073,11 +1164,13 @@ function RichTextToolbar({
|
|
|
1073
1164
|
var RichTextWidget = ({ fieldId }) => {
|
|
1074
1165
|
const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
|
|
1075
1166
|
const { state } = useForm();
|
|
1167
|
+
const store = useFormStore();
|
|
1168
|
+
const hasVoice = !!(fieldDef?.voice && store.getVoice());
|
|
1076
1169
|
const showError = !!error && (touched || state.submitAttempted);
|
|
1077
1170
|
const def = fieldDef;
|
|
1078
1171
|
const placeholder = def?.placeholder ?? "Start typing\u2026";
|
|
1079
1172
|
const minHeight = def?.minHeight ?? 160;
|
|
1080
|
-
const extensions =
|
|
1173
|
+
const extensions = React15.useMemo(
|
|
1081
1174
|
() => [
|
|
1082
1175
|
StarterKit__default.default.configure({
|
|
1083
1176
|
// Disable headings entirely so the UI/content can't introduce H2/H3.
|
|
@@ -1127,16 +1220,16 @@ var RichTextWidget = ({ fieldId }) => {
|
|
|
1127
1220
|
},
|
|
1128
1221
|
[extensions, fieldId]
|
|
1129
1222
|
);
|
|
1130
|
-
|
|
1223
|
+
React15.useEffect(() => {
|
|
1131
1224
|
if (!editor || editor.isDestroyed) return;
|
|
1132
1225
|
editor.setEditable(!disabled);
|
|
1133
1226
|
}, [editor, disabled]);
|
|
1134
|
-
|
|
1227
|
+
React15.useEffect(() => {
|
|
1135
1228
|
if (!editor || editor.isDestroyed) return;
|
|
1136
1229
|
const el = editor.view.dom;
|
|
1137
1230
|
el.style.minHeight = `${minHeight}px`;
|
|
1138
1231
|
}, [editor, minHeight]);
|
|
1139
|
-
|
|
1232
|
+
React15.useEffect(() => {
|
|
1140
1233
|
if (!editor || editor.isDestroyed) return;
|
|
1141
1234
|
const fromForm = stringValue;
|
|
1142
1235
|
const fromEditor = editor.getHTML();
|
|
@@ -1154,8 +1247,12 @@ var RichTextWidget = ({ fieldId }) => {
|
|
|
1154
1247
|
" ",
|
|
1155
1248
|
fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
|
|
1156
1249
|
] });
|
|
1250
|
+
const labelEl = /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, children: labelContent });
|
|
1157
1251
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
1158
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1252
|
+
hasVoice ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
1253
|
+
labelEl,
|
|
1254
|
+
/* @__PURE__ */ jsxRuntime.jsx(VoiceMicButton, { fieldId, onTranscriptReady: setValue })
|
|
1255
|
+
] }) : labelEl,
|
|
1159
1256
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1160
1257
|
"div",
|
|
1161
1258
|
{
|
|
@@ -1193,7 +1290,7 @@ var RichTextWidget = ({ fieldId }) => {
|
|
|
1193
1290
|
};
|
|
1194
1291
|
var Select = SelectPrimitive__namespace.Root;
|
|
1195
1292
|
var SelectValue = SelectPrimitive__namespace.Value;
|
|
1196
|
-
var SelectTrigger =
|
|
1293
|
+
var SelectTrigger = React15__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1197
1294
|
SelectPrimitive__namespace.Trigger,
|
|
1198
1295
|
{
|
|
1199
1296
|
ref,
|
|
@@ -1209,7 +1306,7 @@ var SelectTrigger = React13__namespace.forwardRef(({ className, children, ...pro
|
|
|
1209
1306
|
}
|
|
1210
1307
|
));
|
|
1211
1308
|
SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
|
|
1212
|
-
var SelectScrollUpButton =
|
|
1309
|
+
var SelectScrollUpButton = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1213
1310
|
SelectPrimitive__namespace.ScrollUpButton,
|
|
1214
1311
|
{
|
|
1215
1312
|
ref,
|
|
@@ -1222,7 +1319,7 @@ var SelectScrollUpButton = React13__namespace.forwardRef(({ className, ...props
|
|
|
1222
1319
|
}
|
|
1223
1320
|
));
|
|
1224
1321
|
SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
|
|
1225
|
-
var SelectScrollDownButton =
|
|
1322
|
+
var SelectScrollDownButton = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1226
1323
|
SelectPrimitive__namespace.ScrollDownButton,
|
|
1227
1324
|
{
|
|
1228
1325
|
ref,
|
|
@@ -1235,7 +1332,7 @@ var SelectScrollDownButton = React13__namespace.forwardRef(({ className, ...prop
|
|
|
1235
1332
|
}
|
|
1236
1333
|
));
|
|
1237
1334
|
SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
|
|
1238
|
-
var SelectContent =
|
|
1335
|
+
var SelectContent = React15__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1239
1336
|
SelectPrimitive__namespace.Content,
|
|
1240
1337
|
{
|
|
1241
1338
|
ref,
|
|
@@ -1263,7 +1360,7 @@ var SelectContent = React13__namespace.forwardRef(({ className, children, positi
|
|
|
1263
1360
|
}
|
|
1264
1361
|
) }));
|
|
1265
1362
|
SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
|
|
1266
|
-
var SelectLabel =
|
|
1363
|
+
var SelectLabel = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1267
1364
|
SelectPrimitive__namespace.Label,
|
|
1268
1365
|
{
|
|
1269
1366
|
ref,
|
|
@@ -1272,7 +1369,7 @@ var SelectLabel = React13__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
1272
1369
|
}
|
|
1273
1370
|
));
|
|
1274
1371
|
SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
|
|
1275
|
-
var SelectItem =
|
|
1372
|
+
var SelectItem = React15__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1276
1373
|
SelectPrimitive__namespace.Item,
|
|
1277
1374
|
{
|
|
1278
1375
|
ref,
|
|
@@ -1288,7 +1385,7 @@ var SelectItem = React13__namespace.forwardRef(({ className, children, ...props
|
|
|
1288
1385
|
}
|
|
1289
1386
|
));
|
|
1290
1387
|
SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
|
|
1291
|
-
var SelectSeparator =
|
|
1388
|
+
var SelectSeparator = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1292
1389
|
SelectPrimitive__namespace.Separator,
|
|
1293
1390
|
{
|
|
1294
1391
|
ref,
|
|
@@ -1335,11 +1432,11 @@ async function fetchOptions(source, params) {
|
|
|
1335
1432
|
}
|
|
1336
1433
|
var SelectWidget = ({ fieldId }) => {
|
|
1337
1434
|
const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
|
|
1338
|
-
const [options, setOptions] =
|
|
1339
|
-
const [loading, setLoading] =
|
|
1435
|
+
const [options, setOptions] = React15.useState([]);
|
|
1436
|
+
const [loading, setLoading] = React15.useState(false);
|
|
1340
1437
|
const { state } = useForm();
|
|
1341
1438
|
const showError = !!error && (touched || state.submitAttempted);
|
|
1342
|
-
|
|
1439
|
+
React15.useEffect(() => {
|
|
1343
1440
|
if (!fieldDef) return;
|
|
1344
1441
|
const def = fieldDef;
|
|
1345
1442
|
if (def.options) {
|
|
@@ -1377,7 +1474,7 @@ var SelectWidget = ({ fieldId }) => {
|
|
|
1377
1474
|
showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
|
|
1378
1475
|
] });
|
|
1379
1476
|
};
|
|
1380
|
-
var Checkbox =
|
|
1477
|
+
var Checkbox = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1381
1478
|
CheckboxPrimitive__namespace.Root,
|
|
1382
1479
|
{
|
|
1383
1480
|
ref,
|
|
@@ -1398,12 +1495,12 @@ var Checkbox = React13__namespace.forwardRef(({ className, ...props }, ref) => /
|
|
|
1398
1495
|
Checkbox.displayName = CheckboxPrimitive__namespace.Root.displayName;
|
|
1399
1496
|
var MultiSelectWidget = ({ fieldId }) => {
|
|
1400
1497
|
const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
|
|
1401
|
-
const [options, setOptions] =
|
|
1402
|
-
const [loading, setLoading] =
|
|
1498
|
+
const [options, setOptions] = React15.useState([]);
|
|
1499
|
+
const [loading, setLoading] = React15.useState(false);
|
|
1403
1500
|
const { state } = useForm();
|
|
1404
1501
|
const showError = !!error && (touched || state.submitAttempted);
|
|
1405
1502
|
const currentValues = Array.isArray(value) ? value : [];
|
|
1406
|
-
|
|
1503
|
+
React15.useEffect(() => {
|
|
1407
1504
|
if (!fieldDef) return;
|
|
1408
1505
|
const def = fieldDef;
|
|
1409
1506
|
if (def.options) {
|
|
@@ -1451,7 +1548,7 @@ var MultiSelectWidget = ({ fieldId }) => {
|
|
|
1451
1548
|
showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
|
|
1452
1549
|
] });
|
|
1453
1550
|
};
|
|
1454
|
-
var Table =
|
|
1551
|
+
var Table = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1455
1552
|
"table",
|
|
1456
1553
|
{
|
|
1457
1554
|
ref,
|
|
@@ -1460,9 +1557,9 @@ var Table = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @
|
|
|
1460
1557
|
}
|
|
1461
1558
|
) }));
|
|
1462
1559
|
Table.displayName = "Table";
|
|
1463
|
-
var TableHeader =
|
|
1560
|
+
var TableHeader = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
|
|
1464
1561
|
TableHeader.displayName = "TableHeader";
|
|
1465
|
-
var TableBody =
|
|
1562
|
+
var TableBody = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1466
1563
|
"tbody",
|
|
1467
1564
|
{
|
|
1468
1565
|
ref,
|
|
@@ -1471,7 +1568,7 @@ var TableBody = React13__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
1471
1568
|
}
|
|
1472
1569
|
));
|
|
1473
1570
|
TableBody.displayName = "TableBody";
|
|
1474
|
-
var TableFooter =
|
|
1571
|
+
var TableFooter = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1475
1572
|
"tfoot",
|
|
1476
1573
|
{
|
|
1477
1574
|
ref,
|
|
@@ -1483,7 +1580,7 @@ var TableFooter = React13__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
1483
1580
|
}
|
|
1484
1581
|
));
|
|
1485
1582
|
TableFooter.displayName = "TableFooter";
|
|
1486
|
-
var TableRow =
|
|
1583
|
+
var TableRow = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1487
1584
|
"tr",
|
|
1488
1585
|
{
|
|
1489
1586
|
ref,
|
|
@@ -1495,7 +1592,7 @@ var TableRow = React13__namespace.forwardRef(({ className, ...props }, ref) => /
|
|
|
1495
1592
|
}
|
|
1496
1593
|
));
|
|
1497
1594
|
TableRow.displayName = "TableRow";
|
|
1498
|
-
var TableHead =
|
|
1595
|
+
var TableHead = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1499
1596
|
"th",
|
|
1500
1597
|
{
|
|
1501
1598
|
ref,
|
|
@@ -1507,7 +1604,7 @@ var TableHead = React13__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
1507
1604
|
}
|
|
1508
1605
|
));
|
|
1509
1606
|
TableHead.displayName = "TableHead";
|
|
1510
|
-
var TableCell =
|
|
1607
|
+
var TableCell = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1511
1608
|
"td",
|
|
1512
1609
|
{
|
|
1513
1610
|
ref,
|
|
@@ -1516,7 +1613,7 @@ var TableCell = React13__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
1516
1613
|
}
|
|
1517
1614
|
));
|
|
1518
1615
|
TableCell.displayName = "TableCell";
|
|
1519
|
-
var TableCaption =
|
|
1616
|
+
var TableCaption = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1520
1617
|
"caption",
|
|
1521
1618
|
{
|
|
1522
1619
|
ref,
|
|
@@ -1532,7 +1629,7 @@ var RepeatableWidget = ({
|
|
|
1532
1629
|
if (!fieldDef || fieldDef.type !== "repeatable") return null;
|
|
1533
1630
|
const def = fieldDef;
|
|
1534
1631
|
const rows = Array.isArray(value) ? value : [];
|
|
1535
|
-
const [hasInteracted, setHasInteracted] =
|
|
1632
|
+
const [hasInteracted, setHasInteracted] = React15__namespace.default.useState(false);
|
|
1536
1633
|
const showError = !!error && (touched || hasInteracted);
|
|
1537
1634
|
const addRow = () => {
|
|
1538
1635
|
setValue([...rows, {}]);
|
|
@@ -1701,7 +1798,7 @@ function Calendar({
|
|
|
1701
1798
|
Calendar.displayName = "Calendar";
|
|
1702
1799
|
var Popover = PopoverPrimitive__namespace.Root;
|
|
1703
1800
|
var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
|
|
1704
|
-
var PopoverContent =
|
|
1801
|
+
var PopoverContent = React15__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1705
1802
|
PopoverPrimitive__namespace.Content,
|
|
1706
1803
|
{
|
|
1707
1804
|
ref,
|
|
@@ -1780,14 +1877,14 @@ function DateTimePicker({
|
|
|
1780
1877
|
className,
|
|
1781
1878
|
placeholder = "Pick date & time"
|
|
1782
1879
|
}) {
|
|
1783
|
-
const [internalDate, setInternalDate] =
|
|
1784
|
-
const [timeString, setTimeString] =
|
|
1880
|
+
const [internalDate, setInternalDate] = React15__namespace.useState(dateTime);
|
|
1881
|
+
const [timeString, setTimeString] = React15__namespace.useState(() => {
|
|
1785
1882
|
if (!dateTime) return "";
|
|
1786
1883
|
const hours = dateTime.getHours().toString().padStart(2, "0");
|
|
1787
1884
|
const minutes = dateTime.getMinutes().toString().padStart(2, "0");
|
|
1788
1885
|
return `${hours}:${minutes}`;
|
|
1789
1886
|
});
|
|
1790
|
-
|
|
1887
|
+
React15__namespace.useEffect(() => {
|
|
1791
1888
|
setInternalDate(dateTime);
|
|
1792
1889
|
if (!dateTime) {
|
|
1793
1890
|
setTimeString("");
|
|
@@ -1916,9 +2013,9 @@ var ImageUploadWidget = ({ fieldId }) => {
|
|
|
1916
2013
|
const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
|
|
1917
2014
|
const store = useFormStore();
|
|
1918
2015
|
const { state } = useForm();
|
|
1919
|
-
const [isUploading, setIsUploading] =
|
|
1920
|
-
const [preview, setPreview] =
|
|
1921
|
-
const fileInputRef =
|
|
2016
|
+
const [isUploading, setIsUploading] = React15.useState(false);
|
|
2017
|
+
const [preview, setPreview] = React15.useState(null);
|
|
2018
|
+
const fileInputRef = React15.useRef(null);
|
|
1922
2019
|
const showError = !!error && (touched || state.submitAttempted);
|
|
1923
2020
|
if (!fieldDef) return null;
|
|
1924
2021
|
const uploadHandler = store.getUploadHandler();
|
|
@@ -1931,7 +2028,7 @@ var ImageUploadWidget = ({ fieldId }) => {
|
|
|
1931
2028
|
/* @__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." }) })
|
|
1932
2029
|
] });
|
|
1933
2030
|
}
|
|
1934
|
-
|
|
2031
|
+
React15__namespace.default.useEffect(() => {
|
|
1935
2032
|
if (value && typeof value === "string") {
|
|
1936
2033
|
setPreview(value);
|
|
1937
2034
|
} else {
|
|
@@ -2056,18 +2153,18 @@ var SignatureUploadWidget = ({ fieldId }) => {
|
|
|
2056
2153
|
const { fieldDef, setValue, setTouched, error, disabled, touched, value } = useField(fieldId);
|
|
2057
2154
|
const store = useFormStore();
|
|
2058
2155
|
const { state } = useForm();
|
|
2059
|
-
const canvasRef =
|
|
2060
|
-
const pathRef =
|
|
2061
|
-
const lastPointRef =
|
|
2062
|
-
const lastTimeRef =
|
|
2063
|
-
const lastWidthRef =
|
|
2064
|
-
const [isDrawing, setIsDrawing] =
|
|
2065
|
-
const [hasDrawing, setHasDrawing] =
|
|
2066
|
-
const [isUploading, setIsUploading] =
|
|
2067
|
-
const [isConfirmed, setIsConfirmed] =
|
|
2068
|
-
const [uploadError, setUploadError] =
|
|
2069
|
-
const confirmSignatureRef =
|
|
2070
|
-
|
|
2156
|
+
const canvasRef = React15.useRef(null);
|
|
2157
|
+
const pathRef = React15.useRef("");
|
|
2158
|
+
const lastPointRef = React15.useRef(null);
|
|
2159
|
+
const lastTimeRef = React15.useRef(null);
|
|
2160
|
+
const lastWidthRef = React15.useRef(2);
|
|
2161
|
+
const [isDrawing, setIsDrawing] = React15.useState(false);
|
|
2162
|
+
const [hasDrawing, setHasDrawing] = React15.useState(false);
|
|
2163
|
+
const [isUploading, setIsUploading] = React15.useState(false);
|
|
2164
|
+
const [isConfirmed, setIsConfirmed] = React15.useState(false);
|
|
2165
|
+
const [uploadError, setUploadError] = React15.useState(null);
|
|
2166
|
+
const confirmSignatureRef = React15.useRef(null);
|
|
2167
|
+
React15.useEffect(() => {
|
|
2071
2168
|
if (hasDrawing && !isConfirmed) {
|
|
2072
2169
|
store.registerPreSubmitHandler(fieldId, async () => {
|
|
2073
2170
|
if (confirmSignatureRef.current) {
|
|
@@ -2082,9 +2179,9 @@ var SignatureUploadWidget = ({ fieldId }) => {
|
|
|
2082
2179
|
};
|
|
2083
2180
|
}, [hasDrawing, isConfirmed, fieldId, store]);
|
|
2084
2181
|
const showError = !!error && (touched || state.submitAttempted);
|
|
2085
|
-
const displayUrl =
|
|
2182
|
+
const displayUrl = React15.useMemo(() => extractDisplayUrl(value), [value]);
|
|
2086
2183
|
const showPreview = displayUrl !== null;
|
|
2087
|
-
|
|
2184
|
+
React15.useEffect(() => {
|
|
2088
2185
|
if (showPreview) return;
|
|
2089
2186
|
const canvas = canvasRef.current;
|
|
2090
2187
|
if (!canvas) return;
|
|
@@ -2324,7 +2421,7 @@ var EditableTableWidget = ({
|
|
|
2324
2421
|
const addColumnLabel = def?.addColumnLabel ?? "Add Column";
|
|
2325
2422
|
const newColumnNameHint = def?.newColumnNameHint ?? "New Column Name";
|
|
2326
2423
|
const newColumnNameInputType = def?.newColumnNameInputType ?? "text";
|
|
2327
|
-
const tableData =
|
|
2424
|
+
const tableData = React15.useMemo(() => {
|
|
2328
2425
|
if (value && typeof value === "object" && "columns" in value && "rows" in value) {
|
|
2329
2426
|
return value;
|
|
2330
2427
|
}
|
|
@@ -2339,12 +2436,12 @@ var EditableTableWidget = ({
|
|
|
2339
2436
|
rows: []
|
|
2340
2437
|
};
|
|
2341
2438
|
}, [value, fieldDef]);
|
|
2342
|
-
const dataRef =
|
|
2343
|
-
|
|
2439
|
+
const dataRef = React15.useRef(tableData);
|
|
2440
|
+
React15.useEffect(() => {
|
|
2344
2441
|
dataRef.current = tableData;
|
|
2345
2442
|
}, [tableData]);
|
|
2346
|
-
const [newColumnName, setNewColumnName] =
|
|
2347
|
-
const [newColumnDate, setNewColumnDate] =
|
|
2443
|
+
const [newColumnName, setNewColumnName] = React15.useState("");
|
|
2444
|
+
const [newColumnDate, setNewColumnDate] = React15.useState(void 0);
|
|
2348
2445
|
const updateData = (newData) => {
|
|
2349
2446
|
setValue(newData);
|
|
2350
2447
|
};
|
|
@@ -2412,7 +2509,7 @@ var EditableTableWidget = ({
|
|
|
2412
2509
|
newRows[rowIndex] = { ...newRows[rowIndex], [colId]: val };
|
|
2413
2510
|
updateData({ ...currentData, rows: newRows });
|
|
2414
2511
|
};
|
|
2415
|
-
const columns =
|
|
2512
|
+
const columns = React15.useMemo(() => {
|
|
2416
2513
|
const currentCols = tableData.columns;
|
|
2417
2514
|
const dataCols = currentCols.map((col) => {
|
|
2418
2515
|
const showColumnDelete = !disabled && canDeleteColumn && col.allowDelete !== false;
|
|
@@ -2570,7 +2667,7 @@ var EditableTableWidget = ({
|
|
|
2570
2667
|
] })
|
|
2571
2668
|
] });
|
|
2572
2669
|
};
|
|
2573
|
-
var RadioGroup =
|
|
2670
|
+
var RadioGroup = React15__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
2574
2671
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2575
2672
|
RadioGroupPrimitive__namespace.Root,
|
|
2576
2673
|
{
|
|
@@ -2581,7 +2678,7 @@ var RadioGroup = React13__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
2581
2678
|
);
|
|
2582
2679
|
});
|
|
2583
2680
|
RadioGroup.displayName = RadioGroupPrimitive__namespace.Root.displayName;
|
|
2584
|
-
var RadioGroupItem =
|
|
2681
|
+
var RadioGroupItem = React15__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
2585
2682
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2586
2683
|
RadioGroupPrimitive__namespace.Item,
|
|
2587
2684
|
{
|
|
@@ -2598,11 +2695,11 @@ var RadioGroupItem = React13__namespace.forwardRef(({ className, ...props }, ref
|
|
|
2598
2695
|
RadioGroupItem.displayName = RadioGroupPrimitive__namespace.Item.displayName;
|
|
2599
2696
|
var RadioWidget = ({ fieldId }) => {
|
|
2600
2697
|
const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
|
|
2601
|
-
const [options, setOptions] =
|
|
2602
|
-
const [loading, setLoading] =
|
|
2698
|
+
const [options, setOptions] = React15.useState([]);
|
|
2699
|
+
const [loading, setLoading] = React15.useState(false);
|
|
2603
2700
|
const { state } = useForm();
|
|
2604
2701
|
const showError = !!error && (touched || state.submitAttempted);
|
|
2605
|
-
|
|
2702
|
+
React15.useEffect(() => {
|
|
2606
2703
|
if (!fieldDef) return;
|
|
2607
2704
|
const def = fieldDef;
|
|
2608
2705
|
if (def.options?.length) {
|
|
@@ -2661,12 +2758,12 @@ function isOptionSelected(selected, optValue) {
|
|
|
2661
2758
|
}
|
|
2662
2759
|
var CheckboxWidget = ({ fieldId }) => {
|
|
2663
2760
|
const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
|
|
2664
|
-
const [options, setOptions] =
|
|
2665
|
-
const [loading, setLoading] =
|
|
2761
|
+
const [options, setOptions] = React15.useState([]);
|
|
2762
|
+
const [loading, setLoading] = React15.useState(false);
|
|
2666
2763
|
const { state } = useForm();
|
|
2667
2764
|
const showError = !!error && (touched || state.submitAttempted);
|
|
2668
2765
|
const selectedValues = Array.isArray(value) ? value : [];
|
|
2669
|
-
|
|
2766
|
+
React15.useEffect(() => {
|
|
2670
2767
|
if (!fieldDef) return;
|
|
2671
2768
|
const def = fieldDef;
|
|
2672
2769
|
if (def.options?.length) {
|
|
@@ -2721,14 +2818,14 @@ var CheckboxWidget = ({ fieldId }) => {
|
|
|
2721
2818
|
showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
|
|
2722
2819
|
] });
|
|
2723
2820
|
};
|
|
2724
|
-
var AISuggestionsContext =
|
|
2821
|
+
var AISuggestionsContext = React15.createContext({});
|
|
2725
2822
|
function useAISuggestions() {
|
|
2726
|
-
return
|
|
2823
|
+
return React15.useContext(AISuggestionsContext);
|
|
2727
2824
|
}
|
|
2728
2825
|
var AISuggestionsProvider = AISuggestionsContext.Provider;
|
|
2729
2826
|
var Dialog = DialogPrimitive__namespace.Root;
|
|
2730
2827
|
var DialogPortal = DialogPrimitive__namespace.Portal;
|
|
2731
|
-
var DialogOverlay =
|
|
2828
|
+
var DialogOverlay = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2732
2829
|
DialogPrimitive__namespace.Overlay,
|
|
2733
2830
|
{
|
|
2734
2831
|
ref,
|
|
@@ -2740,7 +2837,7 @@ var DialogOverlay = React13__namespace.forwardRef(({ className, ...props }, ref)
|
|
|
2740
2837
|
}
|
|
2741
2838
|
));
|
|
2742
2839
|
DialogOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
|
|
2743
|
-
var DialogContent =
|
|
2840
|
+
var DialogContent = React15__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
|
|
2744
2841
|
/* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
|
|
2745
2842
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2746
2843
|
DialogPrimitive__namespace.Content,
|
|
@@ -2776,7 +2873,7 @@ var DialogHeader = ({
|
|
|
2776
2873
|
}
|
|
2777
2874
|
);
|
|
2778
2875
|
DialogHeader.displayName = "DialogHeader";
|
|
2779
|
-
var DialogTitle =
|
|
2876
|
+
var DialogTitle = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2780
2877
|
DialogPrimitive__namespace.Title,
|
|
2781
2878
|
{
|
|
2782
2879
|
ref,
|
|
@@ -2788,7 +2885,7 @@ var DialogTitle = React13__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
2788
2885
|
}
|
|
2789
2886
|
));
|
|
2790
2887
|
DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
|
|
2791
|
-
var DialogDescription =
|
|
2888
|
+
var DialogDescription = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2792
2889
|
DialogPrimitive__namespace.Description,
|
|
2793
2890
|
{
|
|
2794
2891
|
ref,
|
|
@@ -2955,7 +3052,7 @@ function MedicationCard({
|
|
|
2955
3052
|
onUpdate,
|
|
2956
3053
|
onRemove
|
|
2957
3054
|
}) {
|
|
2958
|
-
const [notesOpen, setNotesOpen] =
|
|
3055
|
+
const [notesOpen, setNotesOpen] = React15.useState(false);
|
|
2959
3056
|
function set(key, val) {
|
|
2960
3057
|
onUpdate({ ...med, [key]: val });
|
|
2961
3058
|
}
|
|
@@ -3116,19 +3213,19 @@ var AddMedicationField = ({
|
|
|
3116
3213
|
frequentItems = [],
|
|
3117
3214
|
suggestedMedications = []
|
|
3118
3215
|
}) => {
|
|
3119
|
-
const [open, setOpen] =
|
|
3120
|
-
const [query, setQuery] =
|
|
3121
|
-
const [results, setResults] =
|
|
3122
|
-
const [loading, setLoading] =
|
|
3123
|
-
const [addingResultId, setAddingResultId] =
|
|
3124
|
-
const debounceRef =
|
|
3125
|
-
const customIdRef =
|
|
3126
|
-
const valueRef =
|
|
3127
|
-
const searchInputRef =
|
|
3216
|
+
const [open, setOpen] = React15.useState(false);
|
|
3217
|
+
const [query, setQuery] = React15.useState("");
|
|
3218
|
+
const [results, setResults] = React15.useState([]);
|
|
3219
|
+
const [loading, setLoading] = React15.useState(false);
|
|
3220
|
+
const [addingResultId, setAddingResultId] = React15.useState(null);
|
|
3221
|
+
const debounceRef = React15.useRef(null);
|
|
3222
|
+
const customIdRef = React15.useRef(-1);
|
|
3223
|
+
const valueRef = React15.useRef([]);
|
|
3224
|
+
const searchInputRef = React15.useRef(null);
|
|
3128
3225
|
const safeValue = Array.isArray(value) ? value : [];
|
|
3129
3226
|
valueRef.current = safeValue;
|
|
3130
3227
|
const addedIds = new Set(safeValue.map((m) => String(m.id)));
|
|
3131
|
-
|
|
3228
|
+
React15.useEffect(() => {
|
|
3132
3229
|
if (!open) {
|
|
3133
3230
|
setQuery("");
|
|
3134
3231
|
setResults([]);
|
|
@@ -3356,19 +3453,19 @@ var AddInvestigationField = ({
|
|
|
3356
3453
|
recentlyUsed = [],
|
|
3357
3454
|
frequentItems = []
|
|
3358
3455
|
}) => {
|
|
3359
|
-
const [open, setOpen] =
|
|
3360
|
-
const [query, setQuery] =
|
|
3361
|
-
const [results, setResults] =
|
|
3362
|
-
const [loading, setLoading] =
|
|
3363
|
-
const [addingId, setAddingId] =
|
|
3364
|
-
const [addingFrequentId, setAddingFrequentId] =
|
|
3365
|
-
const debounceRef =
|
|
3366
|
-
const valueRef =
|
|
3367
|
-
const searchInputRef =
|
|
3456
|
+
const [open, setOpen] = React15.useState(false);
|
|
3457
|
+
const [query, setQuery] = React15.useState("");
|
|
3458
|
+
const [results, setResults] = React15.useState([]);
|
|
3459
|
+
const [loading, setLoading] = React15.useState(false);
|
|
3460
|
+
const [addingId, setAddingId] = React15.useState(null);
|
|
3461
|
+
const [addingFrequentId, setAddingFrequentId] = React15.useState(null);
|
|
3462
|
+
const debounceRef = React15.useRef(null);
|
|
3463
|
+
const valueRef = React15.useRef([]);
|
|
3464
|
+
const searchInputRef = React15.useRef(null);
|
|
3368
3465
|
const safeValue = Array.isArray(value) ? value : [];
|
|
3369
3466
|
valueRef.current = safeValue;
|
|
3370
3467
|
const addedIds = new Set(safeValue.map((inv) => inv.id));
|
|
3371
|
-
|
|
3468
|
+
React15.useEffect(() => {
|
|
3372
3469
|
if (!open) {
|
|
3373
3470
|
setQuery("");
|
|
3374
3471
|
setResults([]);
|
|
@@ -3594,21 +3691,21 @@ var AddProcedureField = ({
|
|
|
3594
3691
|
recentlyUsed = [],
|
|
3595
3692
|
frequentItems = []
|
|
3596
3693
|
}) => {
|
|
3597
|
-
const [open, setOpen] =
|
|
3598
|
-
const [query, setQuery] =
|
|
3599
|
-
const [results, setResults] =
|
|
3600
|
-
const [loading, setLoading] =
|
|
3601
|
-
const [addingId, setAddingId] =
|
|
3602
|
-
const [addingFrequentId, setAddingFrequentId] =
|
|
3603
|
-
const debounceRef =
|
|
3604
|
-
const valueRef =
|
|
3605
|
-
const searchInputRef =
|
|
3694
|
+
const [open, setOpen] = React15.useState(false);
|
|
3695
|
+
const [query, setQuery] = React15.useState("");
|
|
3696
|
+
const [results, setResults] = React15.useState([]);
|
|
3697
|
+
const [loading, setLoading] = React15.useState(false);
|
|
3698
|
+
const [addingId, setAddingId] = React15.useState(null);
|
|
3699
|
+
const [addingFrequentId, setAddingFrequentId] = React15.useState(null);
|
|
3700
|
+
const debounceRef = React15.useRef(null);
|
|
3701
|
+
const valueRef = React15.useRef([]);
|
|
3702
|
+
const searchInputRef = React15.useRef(null);
|
|
3606
3703
|
const safeValue = Array.isArray(value) ? value : [];
|
|
3607
3704
|
valueRef.current = safeValue;
|
|
3608
3705
|
const addedIds = new Set(
|
|
3609
3706
|
safeValue.filter((proc) => !proc.is_custom).map((proc) => proc.id)
|
|
3610
3707
|
);
|
|
3611
|
-
|
|
3708
|
+
React15.useEffect(() => {
|
|
3612
3709
|
if (!open) {
|
|
3613
3710
|
setQuery("");
|
|
3614
3711
|
setResults([]);
|
|
@@ -3851,7 +3948,7 @@ function getStatusBasedClass(status) {
|
|
|
3851
3948
|
}
|
|
3852
3949
|
}
|
|
3853
3950
|
function DiagnosisCard({ item, defaultOpen = false }) {
|
|
3854
|
-
const [open, setOpen] =
|
|
3951
|
+
const [open, setOpen] = React15.useState(defaultOpen);
|
|
3855
3952
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border border-gray-200 rounded-lg bg-[#F2F2F2] mb-2 last:mb-0 overflow-hidden", children: [
|
|
3856
3953
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3857
3954
|
"button",
|
|
@@ -3936,7 +4033,7 @@ var DifferentialDiagnosisWidget = ({ fieldId }) => {
|
|
|
3936
4033
|
const items = Array.isArray(value) ? value : [];
|
|
3937
4034
|
return /* @__PURE__ */ jsxRuntime.jsx(DifferentialDiagnosis, { differentialDiagnosis: items });
|
|
3938
4035
|
};
|
|
3939
|
-
var Spinner2 =
|
|
4036
|
+
var Spinner2 = React15__namespace.forwardRef(
|
|
3940
4037
|
({ className, size = "md", ...props }, ref) => {
|
|
3941
4038
|
const sizeClasses = {
|
|
3942
4039
|
sm: "h-4 w-4 border-2",
|
|
@@ -4081,10 +4178,10 @@ var Vitals = ({
|
|
|
4081
4178
|
var VitalsWidget = ({ fieldId }) => {
|
|
4082
4179
|
const { value, setValue, fieldDef } = useField(fieldId);
|
|
4083
4180
|
const handlers = useFieldHandlers(fieldId);
|
|
4084
|
-
const [loading, setLoading] =
|
|
4085
|
-
const [error, setError] =
|
|
4181
|
+
const [loading, setLoading] = React15.useState(false);
|
|
4182
|
+
const [error, setError] = React15.useState(null);
|
|
4086
4183
|
console.log("[VitalsWidget] fieldId:", fieldId, "| onFetch present:", !!handlers.onFetch, "| value:", value);
|
|
4087
|
-
const fetchVitals =
|
|
4184
|
+
const fetchVitals = React15.useCallback(async () => {
|
|
4088
4185
|
if (!handlers.onFetch) return;
|
|
4089
4186
|
setLoading(true);
|
|
4090
4187
|
setError(null);
|
|
@@ -4098,7 +4195,7 @@ var VitalsWidget = ({ fieldId }) => {
|
|
|
4098
4195
|
setLoading(false);
|
|
4099
4196
|
}
|
|
4100
4197
|
}, [handlers, setValue]);
|
|
4101
|
-
|
|
4198
|
+
React15.useEffect(() => {
|
|
4102
4199
|
fetchVitals();
|
|
4103
4200
|
}, []);
|
|
4104
4201
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -4167,15 +4264,15 @@ function normalizeValue(value) {
|
|
|
4167
4264
|
var ReferralWidget = ({ fieldId }) => {
|
|
4168
4265
|
const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
|
|
4169
4266
|
const handlers = useFieldHandlers(fieldId);
|
|
4170
|
-
const [options, setOptions] =
|
|
4171
|
-
const [loading, setLoading] =
|
|
4267
|
+
const [options, setOptions] = React15.useState([]);
|
|
4268
|
+
const [loading, setLoading] = React15.useState(false);
|
|
4172
4269
|
const { state } = useForm();
|
|
4173
4270
|
const showError = !!error && (touched || state.submitAttempted);
|
|
4174
4271
|
const selectedItems = normalizeValue(value);
|
|
4175
4272
|
const availableOptions = options.filter(
|
|
4176
4273
|
(opt) => !selectedItems.some((item) => item.specialization === opt.value)
|
|
4177
4274
|
);
|
|
4178
|
-
const loadOptions =
|
|
4275
|
+
const loadOptions = React15.useCallback(async () => {
|
|
4179
4276
|
if (handlers.onFetchOptions) {
|
|
4180
4277
|
setLoading(true);
|
|
4181
4278
|
try {
|
|
@@ -4196,11 +4293,11 @@ var ReferralWidget = ({ fieldId }) => {
|
|
|
4196
4293
|
setOptions([]);
|
|
4197
4294
|
}
|
|
4198
4295
|
}, [fieldDef, handlers]);
|
|
4199
|
-
|
|
4296
|
+
React15.useEffect(() => {
|
|
4200
4297
|
if (!fieldDef) return;
|
|
4201
4298
|
loadOptions();
|
|
4202
4299
|
}, [fieldDef, loadOptions]);
|
|
4203
|
-
const handleAdd =
|
|
4300
|
+
const handleAdd = React15.useCallback(
|
|
4204
4301
|
(specialization) => {
|
|
4205
4302
|
const next = [...selectedItems, { specialization, is_urgent: false }];
|
|
4206
4303
|
setValue(next);
|
|
@@ -4208,7 +4305,7 @@ var ReferralWidget = ({ fieldId }) => {
|
|
|
4208
4305
|
},
|
|
4209
4306
|
[selectedItems, setValue, setTouched]
|
|
4210
4307
|
);
|
|
4211
|
-
const handleRemove =
|
|
4308
|
+
const handleRemove = React15.useCallback(
|
|
4212
4309
|
(specialization) => {
|
|
4213
4310
|
const next = selectedItems.filter((item) => item.specialization !== specialization);
|
|
4214
4311
|
setValue(next);
|
|
@@ -4216,7 +4313,7 @@ var ReferralWidget = ({ fieldId }) => {
|
|
|
4216
4313
|
},
|
|
4217
4314
|
[selectedItems, setValue, setTouched]
|
|
4218
4315
|
);
|
|
4219
|
-
const handleToggleUrgent =
|
|
4316
|
+
const handleToggleUrgent = React15.useCallback(
|
|
4220
4317
|
(specialization) => {
|
|
4221
4318
|
const next = selectedItems.map(
|
|
4222
4319
|
(item) => item.specialization === specialization ? { ...item, is_urgent: !item.is_urgent } : item
|
|
@@ -4292,7 +4389,7 @@ var ReferralWidget = ({ fieldId }) => {
|
|
|
4292
4389
|
showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
|
|
4293
4390
|
] });
|
|
4294
4391
|
};
|
|
4295
|
-
var Card =
|
|
4392
|
+
var Card = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4296
4393
|
"div",
|
|
4297
4394
|
{
|
|
4298
4395
|
ref,
|
|
@@ -4304,7 +4401,7 @@ var Card = React13__namespace.forwardRef(({ className, ...props }, ref) => /* @_
|
|
|
4304
4401
|
}
|
|
4305
4402
|
));
|
|
4306
4403
|
Card.displayName = "Card";
|
|
4307
|
-
var CardHeader =
|
|
4404
|
+
var CardHeader = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4308
4405
|
"div",
|
|
4309
4406
|
{
|
|
4310
4407
|
ref,
|
|
@@ -4313,7 +4410,7 @@ var CardHeader = React13__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
4313
4410
|
}
|
|
4314
4411
|
));
|
|
4315
4412
|
CardHeader.displayName = "CardHeader";
|
|
4316
|
-
var CardTitle =
|
|
4413
|
+
var CardTitle = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4317
4414
|
"h3",
|
|
4318
4415
|
{
|
|
4319
4416
|
ref,
|
|
@@ -4325,7 +4422,7 @@ var CardTitle = React13__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
4325
4422
|
}
|
|
4326
4423
|
));
|
|
4327
4424
|
CardTitle.displayName = "CardTitle";
|
|
4328
|
-
var CardDescription =
|
|
4425
|
+
var CardDescription = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4329
4426
|
"p",
|
|
4330
4427
|
{
|
|
4331
4428
|
ref,
|
|
@@ -4334,9 +4431,9 @@ var CardDescription = React13__namespace.forwardRef(({ className, ...props }, re
|
|
|
4334
4431
|
}
|
|
4335
4432
|
));
|
|
4336
4433
|
CardDescription.displayName = "CardDescription";
|
|
4337
|
-
var CardContent =
|
|
4434
|
+
var CardContent = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
|
|
4338
4435
|
CardContent.displayName = "CardContent";
|
|
4339
|
-
var CardFooter =
|
|
4436
|
+
var CardFooter = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4340
4437
|
"div",
|
|
4341
4438
|
{
|
|
4342
4439
|
ref,
|
|
@@ -4422,11 +4519,11 @@ function parseLocalDate(dateString) {
|
|
|
4422
4519
|
var FollowupWidget = ({ fieldId }) => {
|
|
4423
4520
|
const { fieldDef, value, setValue, setTouched, error, disabled, visible } = useField(fieldId);
|
|
4424
4521
|
const followup = normalizeFollowup(value);
|
|
4425
|
-
const [calendarOpen, setCalendarOpen] =
|
|
4522
|
+
const [calendarOpen, setCalendarOpen] = React15.useState(false);
|
|
4426
4523
|
const currentFollowupType = followup ? followup.followupType : "no followup";
|
|
4427
4524
|
const hasFollowup = followup !== false;
|
|
4428
|
-
const [displayMode, setDisplayMode] =
|
|
4429
|
-
const [displayUnit, setDisplayUnit] =
|
|
4525
|
+
const [displayMode, setDisplayMode] = React15.useState("duration");
|
|
4526
|
+
const [displayUnit, setDisplayUnit] = React15.useState("days");
|
|
4430
4527
|
const daysNum = hasFollowup ? parseInt(followup.value, 10) || 7 : 7;
|
|
4431
4528
|
const currentDate = hasFollowup ? daysToDate(daysNum) : null;
|
|
4432
4529
|
const followupMode = displayMode;
|
|
@@ -4434,7 +4531,7 @@ var FollowupWidget = ({ fieldId }) => {
|
|
|
4434
4531
|
displayUnit === "weeks" ? Math.round(daysNum / 7) || 1 : Math.round(daysNum / 30) || 1
|
|
4435
4532
|
) : "7";
|
|
4436
4533
|
const currentUnit = displayUnit;
|
|
4437
|
-
const handleFollowupTypeChange =
|
|
4534
|
+
const handleFollowupTypeChange = React15.useCallback(
|
|
4438
4535
|
(newType) => {
|
|
4439
4536
|
setTouched();
|
|
4440
4537
|
if (newType === "no followup") {
|
|
@@ -4450,11 +4547,11 @@ var FollowupWidget = ({ fieldId }) => {
|
|
|
4450
4547
|
},
|
|
4451
4548
|
[followup, hasFollowup, setValue, setTouched]
|
|
4452
4549
|
);
|
|
4453
|
-
const handleModeChange =
|
|
4550
|
+
const handleModeChange = React15.useCallback((newMode) => {
|
|
4454
4551
|
setDisplayMode(newMode);
|
|
4455
4552
|
if (newMode === "date") setCalendarOpen(false);
|
|
4456
4553
|
}, []);
|
|
4457
|
-
const handleValueChange =
|
|
4554
|
+
const handleValueChange = React15.useCallback(
|
|
4458
4555
|
(newValue) => {
|
|
4459
4556
|
setTouched();
|
|
4460
4557
|
const num = parseInt(newValue, 10);
|
|
@@ -4469,10 +4566,10 @@ var FollowupWidget = ({ fieldId }) => {
|
|
|
4469
4566
|
},
|
|
4470
4567
|
[displayUnit, setValue, setTouched]
|
|
4471
4568
|
);
|
|
4472
|
-
const handleUnitChange =
|
|
4569
|
+
const handleUnitChange = React15.useCallback((newUnit) => {
|
|
4473
4570
|
setDisplayUnit(newUnit);
|
|
4474
4571
|
}, []);
|
|
4475
|
-
const handleDateSelect =
|
|
4572
|
+
const handleDateSelect = React15.useCallback(
|
|
4476
4573
|
(selected) => {
|
|
4477
4574
|
setTouched();
|
|
4478
4575
|
setCalendarOpen(false);
|
|
@@ -4605,13 +4702,13 @@ function useSmartKeywords(text, onSearch, debounceDelay = 1e3) {
|
|
|
4605
4702
|
hasOnSearch: typeof onSearch === "function",
|
|
4606
4703
|
debounceDelay
|
|
4607
4704
|
});
|
|
4608
|
-
const [extractedNouns, setExtractedNouns] =
|
|
4609
|
-
const [matchedConditions, setMatchedConditions] =
|
|
4610
|
-
const [isProcessing, setIsProcessing] =
|
|
4611
|
-
const [error, setError] =
|
|
4612
|
-
const timerRef =
|
|
4613
|
-
const abortRef =
|
|
4614
|
-
const processText =
|
|
4705
|
+
const [extractedNouns, setExtractedNouns] = React15.useState([]);
|
|
4706
|
+
const [matchedConditions, setMatchedConditions] = React15.useState([]);
|
|
4707
|
+
const [isProcessing, setIsProcessing] = React15.useState(false);
|
|
4708
|
+
const [error, setError] = React15.useState(null);
|
|
4709
|
+
const timerRef = React15.useRef(null);
|
|
4710
|
+
const abortRef = React15.useRef(0);
|
|
4711
|
+
const processText = React15.useCallback(
|
|
4615
4712
|
async (input, runId) => {
|
|
4616
4713
|
if (!input || input.trim().length === 0) {
|
|
4617
4714
|
console.log("[useSmartKeywords] skip empty input", {
|
|
@@ -4695,7 +4792,7 @@ function useSmartKeywords(text, onSearch, debounceDelay = 1e3) {
|
|
|
4695
4792
|
},
|
|
4696
4793
|
[onSearch]
|
|
4697
4794
|
);
|
|
4698
|
-
|
|
4795
|
+
React15.useEffect(() => {
|
|
4699
4796
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
4700
4797
|
const runId = ++abortRef.current;
|
|
4701
4798
|
console.log("[useSmartKeywords] schedule debounce", {
|
|
@@ -4732,7 +4829,7 @@ var SmartTextareaWidget = ({ fieldId }) => {
|
|
|
4732
4829
|
const structured = value;
|
|
4733
4830
|
const textValue = structured?.text ?? "";
|
|
4734
4831
|
const showError = !!error && (touched || state.submitAttempted);
|
|
4735
|
-
const onSearch =
|
|
4832
|
+
const onSearch = React15.useCallback(
|
|
4736
4833
|
(query) => handler.onSearch(query),
|
|
4737
4834
|
[handler]
|
|
4738
4835
|
);
|
|
@@ -4742,7 +4839,7 @@ var SmartTextareaWidget = ({ fieldId }) => {
|
|
|
4742
4839
|
def?.debounceDelay ?? 1e3
|
|
4743
4840
|
);
|
|
4744
4841
|
const currentKeywords = structured?.extractedKeywords ?? [];
|
|
4745
|
-
const nextKeywords =
|
|
4842
|
+
const nextKeywords = React15.useMemo(() => {
|
|
4746
4843
|
if (matchedConditions.length === 0 && currentKeywords.length === 0) return currentKeywords;
|
|
4747
4844
|
if (matchedConditions.length === currentKeywords.length && matchedConditions.every(
|
|
4748
4845
|
(m, i) => m.matchedCondition.id === currentKeywords[i]?.matchedCondition.id && m.extractedKeyword === currentKeywords[i]?.extractedKeyword
|
|
@@ -4751,19 +4848,19 @@ var SmartTextareaWidget = ({ fieldId }) => {
|
|
|
4751
4848
|
}
|
|
4752
4849
|
return matchedConditions;
|
|
4753
4850
|
}, [matchedConditions, currentKeywords]);
|
|
4754
|
-
const writeValue =
|
|
4851
|
+
const writeValue = React15.useCallback(
|
|
4755
4852
|
(text, keywords) => {
|
|
4756
4853
|
const next = { text, extractedKeywords: keywords };
|
|
4757
4854
|
setValue(next);
|
|
4758
4855
|
},
|
|
4759
4856
|
[setValue]
|
|
4760
4857
|
);
|
|
4761
|
-
|
|
4858
|
+
React15__namespace.default.useEffect(() => {
|
|
4762
4859
|
if (nextKeywords !== currentKeywords) {
|
|
4763
4860
|
writeValue(textValue, nextKeywords);
|
|
4764
4861
|
}
|
|
4765
4862
|
}, [nextKeywords]);
|
|
4766
|
-
const handleTextChange =
|
|
4863
|
+
const handleTextChange = React15.useCallback(
|
|
4767
4864
|
(e) => {
|
|
4768
4865
|
writeValue(e.target.value, currentKeywords);
|
|
4769
4866
|
},
|
|
@@ -4834,9 +4931,9 @@ var DiagnosisTextareaWidget = ({ fieldId }) => {
|
|
|
4834
4931
|
const { state } = useForm();
|
|
4835
4932
|
const handler = useFieldHandlers(fieldId);
|
|
4836
4933
|
const def = fieldDef;
|
|
4837
|
-
const [gradeGroups, setGradeGroups] =
|
|
4838
|
-
const [isLoadingGrades, setIsLoadingGrades] =
|
|
4839
|
-
const normalized =
|
|
4934
|
+
const [gradeGroups, setGradeGroups] = React15__namespace.default.useState([]);
|
|
4935
|
+
const [isLoadingGrades, setIsLoadingGrades] = React15__namespace.default.useState(false);
|
|
4936
|
+
const normalized = React15__namespace.default.useMemo(() => {
|
|
4840
4937
|
const raw = value;
|
|
4841
4938
|
if (typeof raw === "string") {
|
|
4842
4939
|
return { text: raw, selectedGradesByCondition: {} };
|
|
@@ -4868,7 +4965,7 @@ var DiagnosisTextareaWidget = ({ fieldId }) => {
|
|
|
4868
4965
|
}, [value]);
|
|
4869
4966
|
const textValue = normalized.text;
|
|
4870
4967
|
const showError = !!error && (touched || state.submitAttempted);
|
|
4871
|
-
|
|
4968
|
+
React15__namespace.default.useEffect(() => {
|
|
4872
4969
|
const query = textValue.trim();
|
|
4873
4970
|
const fetchGrades = handler.onFetchDiagnosisGrades;
|
|
4874
4971
|
const debounceMs = def?.debounceDelay ?? 1e3;
|
|
@@ -5173,10 +5270,10 @@ function stripGpalSuffix(label) {
|
|
|
5173
5270
|
return label.replace(/\s*\(G-P-A-L\)\s*$/i, "").trim();
|
|
5174
5271
|
}
|
|
5175
5272
|
function useDebouncedCommit(commit, delayMs) {
|
|
5176
|
-
const timeoutRef =
|
|
5177
|
-
const latestCommit =
|
|
5273
|
+
const timeoutRef = React15.useRef(null);
|
|
5274
|
+
const latestCommit = React15.useRef(commit);
|
|
5178
5275
|
latestCommit.current = commit;
|
|
5179
|
-
|
|
5276
|
+
React15.useEffect(() => {
|
|
5180
5277
|
return () => {
|
|
5181
5278
|
if (timeoutRef.current != null) window.clearTimeout(timeoutRef.current);
|
|
5182
5279
|
};
|
|
@@ -5188,18 +5285,18 @@ function useDebouncedCommit(commit, delayMs) {
|
|
|
5188
5285
|
}
|
|
5189
5286
|
var ObstetricHistoryWidget = ({ fieldId }) => {
|
|
5190
5287
|
const { fieldDef, value, setValue, disabled } = useField(fieldId);
|
|
5191
|
-
const [{ draft, isNewEntry }, setDraftState] =
|
|
5192
|
-
const [lmpError, setLmpError] =
|
|
5193
|
-
const [primaryEddError, setPrimaryEddError] =
|
|
5194
|
-
const [activeGpalKey, setActiveGpalKey] =
|
|
5288
|
+
const [{ draft, isNewEntry }, setDraftState] = React15.useState(() => normalizeToDraft(value));
|
|
5289
|
+
const [lmpError, setLmpError] = React15.useState(null);
|
|
5290
|
+
const [primaryEddError, setPrimaryEddError] = React15.useState(null);
|
|
5291
|
+
const [activeGpalKey, setActiveGpalKey] = React15.useState(null);
|
|
5195
5292
|
const refs = {
|
|
5196
|
-
G:
|
|
5197
|
-
P:
|
|
5198
|
-
A:
|
|
5199
|
-
L:
|
|
5293
|
+
G: React15.useRef(null),
|
|
5294
|
+
P: React15.useRef(null),
|
|
5295
|
+
A: React15.useRef(null),
|
|
5296
|
+
L: React15.useRef(null)
|
|
5200
5297
|
};
|
|
5201
|
-
const today =
|
|
5202
|
-
|
|
5298
|
+
const today = React15.useMemo(() => todayIso(), []);
|
|
5299
|
+
React15.useEffect(() => {
|
|
5203
5300
|
const next = normalizeToDraft(value);
|
|
5204
5301
|
const currStr = JSON.stringify(buildStored(draft, today));
|
|
5205
5302
|
const nextStr = JSON.stringify(buildStored(next.draft, today));
|
|
@@ -5210,7 +5307,7 @@ var ObstetricHistoryWidget = ({ fieldId }) => {
|
|
|
5210
5307
|
setValue(JSON.stringify(stored));
|
|
5211
5308
|
};
|
|
5212
5309
|
const commitDebounced = useDebouncedCommit(commitImmediate, 500);
|
|
5213
|
-
const storedComputed =
|
|
5310
|
+
const storedComputed = React15.useMemo(() => buildStored(draft, today), [draft, today]);
|
|
5214
5311
|
const rightPanelEnabled = draft.is_pregnant && (!!storedComputed.lmp || !!storedComputed.edd?.usg);
|
|
5215
5312
|
const headerLabel = fieldDef?.label ? stripGpalSuffix(fieldDef.label) : "Obstetric History";
|
|
5216
5313
|
const setDraft = (updater, persist) => {
|
|
@@ -5659,7 +5756,7 @@ var numberInputClass = "w-full border border-[#D0D0D0] rounded-md bg-white px-2
|
|
|
5659
5756
|
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";
|
|
5660
5757
|
var OphthalmologyWidget = ({ fieldId }) => {
|
|
5661
5758
|
const { fieldDef, value, setValue, disabled } = useField(fieldId);
|
|
5662
|
-
const safe =
|
|
5759
|
+
const safe = React15.useMemo(() => ensureValue(value), [value]);
|
|
5663
5760
|
const label = fieldDef?.label || "";
|
|
5664
5761
|
const update = (updater) => {
|
|
5665
5762
|
if (disabled) return;
|
|
@@ -6836,7 +6933,7 @@ var headerCellClass = "border border-slate-200 px-2 py-1 text-center font-semibo
|
|
|
6836
6933
|
var cellClass = "border border-slate-200 px-2 py-1 align-top";
|
|
6837
6934
|
var OphthalDiagnosisWidget = ({ fieldId }) => {
|
|
6838
6935
|
const { fieldDef, value, setValue, disabled } = useField(fieldId);
|
|
6839
|
-
const safe =
|
|
6936
|
+
const safe = React15.useMemo(() => ensureValue2(value), [value]);
|
|
6840
6937
|
const label = fieldDef?.label || "";
|
|
6841
6938
|
const updateEyeField = (eye, fieldLabel, next) => {
|
|
6842
6939
|
if (disabled) return;
|
|
@@ -6886,7 +6983,7 @@ var OphthalDiagnosisWidget = ({ fieldId }) => {
|
|
|
6886
6983
|
] })
|
|
6887
6984
|
] });
|
|
6888
6985
|
};
|
|
6889
|
-
var Slider =
|
|
6986
|
+
var Slider = React15__namespace.forwardRef(({ className, trackClassName, thumbClassName, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6890
6987
|
SliderPrimitive__namespace.Root,
|
|
6891
6988
|
{
|
|
6892
6989
|
ref,
|
|
@@ -6980,7 +7077,7 @@ var OrthopedicExamWidget = ({ fieldId }) => {
|
|
|
6980
7077
|
const { fieldDef, value, setValue, setTouched, error, touched, disabled } = useField(fieldId);
|
|
6981
7078
|
const { state } = useForm();
|
|
6982
7079
|
const showError = !!error && (touched || state.submitAttempted);
|
|
6983
|
-
const safeValue =
|
|
7080
|
+
const safeValue = React15.useMemo(() => {
|
|
6984
7081
|
if (!value || typeof value !== "object") return defaultValue();
|
|
6985
7082
|
const v = value;
|
|
6986
7083
|
const concerns = Array.isArray(v.concerns) ? v.concerns : [];
|
|
@@ -7002,10 +7099,10 @@ var OrthopedicExamWidget = ({ fieldId }) => {
|
|
|
7002
7099
|
}
|
|
7003
7100
|
};
|
|
7004
7101
|
}, [value]);
|
|
7005
|
-
const [panelOpen, setPanelOpen] =
|
|
7006
|
-
const draggingRef =
|
|
7007
|
-
const prevConcernsLengthRef =
|
|
7008
|
-
const reminderSections =
|
|
7102
|
+
const [panelOpen, setPanelOpen] = React15.useState(false);
|
|
7103
|
+
const draggingRef = React15.useRef(null);
|
|
7104
|
+
const prevConcernsLengthRef = React15.useRef(safeValue.concerns.length);
|
|
7105
|
+
const reminderSections = React15.useMemo(() => {
|
|
7009
7106
|
return safeValue.concerns.map((id) => ({
|
|
7010
7107
|
id,
|
|
7011
7108
|
label: CONCERNS.find((c) => c.id === id)?.label ?? id,
|
|
@@ -7013,7 +7110,7 @@ var OrthopedicExamWidget = ({ fieldId }) => {
|
|
|
7013
7110
|
})).filter((s) => s.points.length > 0);
|
|
7014
7111
|
}, [safeValue.concerns]);
|
|
7015
7112
|
const hasReminders = reminderSections.length > 0;
|
|
7016
|
-
|
|
7113
|
+
React15.useEffect(() => {
|
|
7017
7114
|
const prevLen = prevConcernsLengthRef.current;
|
|
7018
7115
|
const currLen = safeValue.concerns.length;
|
|
7019
7116
|
prevConcernsLengthRef.current = currLen;
|
|
@@ -7028,7 +7125,7 @@ var OrthopedicExamWidget = ({ fieldId }) => {
|
|
|
7028
7125
|
setPanelOpen(true);
|
|
7029
7126
|
}
|
|
7030
7127
|
}, [safeValue, setValue]);
|
|
7031
|
-
|
|
7128
|
+
React15.useEffect(() => {
|
|
7032
7129
|
const onMove = (e) => {
|
|
7033
7130
|
if (!draggingRef.current) return;
|
|
7034
7131
|
const { startX, startY, startTop, startRight } = draggingRef.current;
|
|
@@ -7274,6 +7371,9 @@ var FieldRenderer = ({ fieldId }) => {
|
|
|
7274
7371
|
if (!visible || !fieldDef) {
|
|
7275
7372
|
return null;
|
|
7276
7373
|
}
|
|
7374
|
+
return renderWidget(fieldId, fieldDef);
|
|
7375
|
+
};
|
|
7376
|
+
function renderWidget(fieldId, fieldDef) {
|
|
7277
7377
|
switch (fieldDef.type) {
|
|
7278
7378
|
case "text":
|
|
7279
7379
|
case "number":
|
|
@@ -7346,9 +7446,9 @@ var FieldRenderer = ({ fieldId }) => {
|
|
|
7346
7446
|
fieldDef.type
|
|
7347
7447
|
] });
|
|
7348
7448
|
}
|
|
7349
|
-
}
|
|
7449
|
+
}
|
|
7350
7450
|
var Section = ({ title, children }) => {
|
|
7351
|
-
const [expanded, setExpanded] =
|
|
7451
|
+
const [expanded, setExpanded] = React15.useState(true);
|
|
7352
7452
|
const handleToggle = () => setExpanded((prev) => !prev);
|
|
7353
7453
|
const contentClassName = cn(
|
|
7354
7454
|
"overflow-hidden transition-[height] duration-200 ease-in-out",
|
|
@@ -7401,7 +7501,7 @@ var DynamicForm = () => {
|
|
|
7401
7501
|
children: child.children.map((fieldId) => /* @__PURE__ */ jsxRuntime.jsx(FieldRenderer, { fieldId }, fieldId))
|
|
7402
7502
|
},
|
|
7403
7503
|
child.id
|
|
7404
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
7504
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(React15__namespace.default.Fragment, {}, child.id ?? index)
|
|
7405
7505
|
) }, node.id);
|
|
7406
7506
|
}
|
|
7407
7507
|
if (node.type === "column_layout") {
|
|
@@ -7489,13 +7589,13 @@ var SmartForm = ({
|
|
|
7489
7589
|
}) => {
|
|
7490
7590
|
const store = useFormStore();
|
|
7491
7591
|
const schema = store.getSchema();
|
|
7492
|
-
const prevAiResultRef =
|
|
7493
|
-
const aiSuggestions =
|
|
7592
|
+
const prevAiResultRef = React15.useRef(void 0);
|
|
7593
|
+
const aiSuggestions = React15.useMemo(() => {
|
|
7494
7594
|
if (aiAnalysisResult == null) return { medications: [] };
|
|
7495
7595
|
const medications = normalizeAIMedications(aiAnalysisResult.medications);
|
|
7496
7596
|
return { medications };
|
|
7497
7597
|
}, [aiAnalysisResult]);
|
|
7498
|
-
|
|
7598
|
+
React15.useEffect(() => {
|
|
7499
7599
|
if (aiAnalysisResult == null || Object.keys(aiAnalysisResult).length === 0) return;
|
|
7500
7600
|
const prev = prevAiResultRef.current;
|
|
7501
7601
|
if (prev != null && prev === aiAnalysisResult && shallowEqualKeys(prev, aiAnalysisResult)) return;
|
|
@@ -7568,9 +7668,9 @@ var ReadOnlyText = ({ fieldDef, value }) => {
|
|
|
7568
7668
|
] });
|
|
7569
7669
|
};
|
|
7570
7670
|
var ReadOnlySelect = ({ fieldDef, value }) => {
|
|
7571
|
-
const [options, setOptions] =
|
|
7572
|
-
const [loading, setLoading] =
|
|
7573
|
-
|
|
7671
|
+
const [options, setOptions] = React15.useState([]);
|
|
7672
|
+
const [loading, setLoading] = React15.useState(false);
|
|
7673
|
+
React15.useEffect(() => {
|
|
7574
7674
|
if (fieldDef.options) {
|
|
7575
7675
|
setOptions(fieldDef.options);
|
|
7576
7676
|
} else if (fieldDef.dataSource) {
|
|
@@ -7592,9 +7692,9 @@ var ReadOnlySelect = ({ fieldDef, value }) => {
|
|
|
7592
7692
|
] });
|
|
7593
7693
|
};
|
|
7594
7694
|
var ReadOnlyMultiSelect = ({ fieldDef, value }) => {
|
|
7595
|
-
const [options, setOptions] =
|
|
7596
|
-
const [loading, setLoading] =
|
|
7597
|
-
|
|
7695
|
+
const [options, setOptions] = React15.useState([]);
|
|
7696
|
+
const [loading, setLoading] = React15.useState(false);
|
|
7697
|
+
React15.useEffect(() => {
|
|
7598
7698
|
if (fieldDef.options) {
|
|
7599
7699
|
setOptions(fieldDef.options);
|
|
7600
7700
|
} else if (fieldDef.dataSource) {
|
|
@@ -7743,13 +7843,13 @@ var ReadOnlyTable = ({
|
|
|
7743
7843
|
fieldDef,
|
|
7744
7844
|
value
|
|
7745
7845
|
}) => {
|
|
7746
|
-
const tableData =
|
|
7846
|
+
const tableData = React15.useMemo(() => {
|
|
7747
7847
|
if (value && typeof value === "object" && "columns" in value && "rows" in value && Array.isArray(value.columns) && Array.isArray(value.rows)) {
|
|
7748
7848
|
return value;
|
|
7749
7849
|
}
|
|
7750
7850
|
return { columns: [], rows: [] };
|
|
7751
7851
|
}, [value]);
|
|
7752
|
-
const columns =
|
|
7852
|
+
const columns = React15.useMemo(() => {
|
|
7753
7853
|
return tableData.columns.map((col) => ({
|
|
7754
7854
|
accessorKey: col.id,
|
|
7755
7855
|
header: col.label,
|
|
@@ -7804,9 +7904,9 @@ var ReadOnlyDateTime = ({ fieldDef, value }) => {
|
|
|
7804
7904
|
] });
|
|
7805
7905
|
};
|
|
7806
7906
|
var ReadOnlyRadio = ({ fieldDef, value }) => {
|
|
7807
|
-
const [options, setOptions] =
|
|
7808
|
-
const [loading, setLoading] =
|
|
7809
|
-
|
|
7907
|
+
const [options, setOptions] = React15.useState([]);
|
|
7908
|
+
const [loading, setLoading] = React15.useState(false);
|
|
7909
|
+
React15.useEffect(() => {
|
|
7810
7910
|
if (fieldDef.options?.length) {
|
|
7811
7911
|
setOptions(fieldDef.options);
|
|
7812
7912
|
} else if (fieldDef.dataSource) {
|
|
@@ -7831,9 +7931,9 @@ function isOptionSelected2(selected, optValue) {
|
|
|
7831
7931
|
);
|
|
7832
7932
|
}
|
|
7833
7933
|
var ReadOnlyCheckbox = ({ fieldDef, value }) => {
|
|
7834
|
-
const [options, setOptions] =
|
|
7835
|
-
const [loading, setLoading] =
|
|
7836
|
-
|
|
7934
|
+
const [options, setOptions] = React15.useState([]);
|
|
7935
|
+
const [loading, setLoading] = React15.useState(false);
|
|
7936
|
+
React15.useEffect(() => {
|
|
7837
7937
|
if (fieldDef.options?.length) {
|
|
7838
7938
|
setOptions(fieldDef.options);
|
|
7839
7939
|
} else if (fieldDef.dataSource) {
|
|
@@ -7985,7 +8085,7 @@ var ReadOnlyForm = ({ schema, submission }) => {
|
|
|
7985
8085
|
child.id
|
|
7986
8086
|
);
|
|
7987
8087
|
}
|
|
7988
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8088
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React15__namespace.default.Fragment, {}, child.id ?? index);
|
|
7989
8089
|
};
|
|
7990
8090
|
const hasContent = node.children.some(
|
|
7991
8091
|
(child) => typeof child === "string" ? fieldMap.has(child) : child.type === "column_layout" && child.children?.some((id) => fieldMap.has(id))
|