formanitor 0.0.33 → 0.0.35
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 +96 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -2
- package/dist/index.d.ts +16 -2
- package/dist/index.mjs +96 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -653,6 +653,11 @@ var FormStore = class {
|
|
|
653
653
|
this.config.role = next.role;
|
|
654
654
|
needsReeval = true;
|
|
655
655
|
}
|
|
656
|
+
if (next.prefillData !== void 0 && next.prefillData !== this.prefillData) {
|
|
657
|
+
this.prefillData = next.prefillData;
|
|
658
|
+
this.state.values = applyPrefill(this.state.values, this.schema.fields, this.prefillData);
|
|
659
|
+
needsReeval = true;
|
|
660
|
+
}
|
|
656
661
|
if (needsReeval) {
|
|
657
662
|
this.evaluate();
|
|
658
663
|
this.notify();
|
|
@@ -732,6 +737,7 @@ var emptyFrequentItems = {
|
|
|
732
737
|
procedures: []
|
|
733
738
|
};
|
|
734
739
|
var FrequentItemsContext = React15.createContext(emptyFrequentItems);
|
|
740
|
+
var PackagesContext = React15.createContext([]);
|
|
735
741
|
var FieldHandlersContext = React15.createContext({});
|
|
736
742
|
function useFieldHandlers(fieldId) {
|
|
737
743
|
const map = React15.useContext(FieldHandlersContext);
|
|
@@ -740,11 +746,15 @@ function useFieldHandlers(fieldId) {
|
|
|
740
746
|
function useFrequentItems() {
|
|
741
747
|
return React15.useContext(FrequentItemsContext);
|
|
742
748
|
}
|
|
749
|
+
function usePackages() {
|
|
750
|
+
return React15.useContext(PackagesContext);
|
|
751
|
+
}
|
|
743
752
|
var FormProvider = ({
|
|
744
753
|
schema,
|
|
745
754
|
config,
|
|
746
755
|
fieldHandlers,
|
|
747
756
|
frequentItems,
|
|
757
|
+
packages,
|
|
748
758
|
children
|
|
749
759
|
}) => {
|
|
750
760
|
const storeRef = React15.useRef(null);
|
|
@@ -760,7 +770,7 @@ var FormProvider = ({
|
|
|
760
770
|
storeRef.current?.load();
|
|
761
771
|
}, []);
|
|
762
772
|
const frequentItemsValue = frequentItems ?? emptyFrequentItems;
|
|
763
|
-
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 }) }) }) });
|
|
773
|
+
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(PackagesContext.Provider, { value: packages ?? [], children: /* @__PURE__ */ jsxRuntime.jsx(VoiceContextProvider, { children }) }) }) }) });
|
|
764
774
|
};
|
|
765
775
|
function useFormStore() {
|
|
766
776
|
const context = React15.useContext(FormContext);
|
|
@@ -3113,18 +3123,20 @@ var AddEntityDialog = ({
|
|
|
3113
3123
|
open,
|
|
3114
3124
|
onClose,
|
|
3115
3125
|
title,
|
|
3126
|
+
chipSections,
|
|
3116
3127
|
recentlyUsedSlot,
|
|
3117
3128
|
chipSectionLabel = "Recently Used",
|
|
3118
3129
|
children,
|
|
3119
3130
|
actionSlot
|
|
3120
3131
|
}) => {
|
|
3121
|
-
|
|
3132
|
+
const sections = chipSections ?? (recentlyUsedSlot ? [{ label: chipSectionLabel, content: recentlyUsedSlot }] : []);
|
|
3133
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open, onOpenChange: (o) => !o && onClose(), children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "max-w-4xl w-full p-0 gap-0 flex flex-col max-h-[90vh] overflow-hidden", children: [
|
|
3122
3134
|
/* @__PURE__ */ jsxRuntime.jsx(DialogHeader, { className: "px-6 pt-6 pb-4 shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { className: "text-lg font-semibold", children: title }) }),
|
|
3123
3135
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-6 flex flex-col gap-4 overflow-y-auto flex-1 min-h-0 pb-4", children: [
|
|
3124
|
-
|
|
3125
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground mb-2", children:
|
|
3126
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2", children:
|
|
3127
|
-
] }),
|
|
3136
|
+
sections.map((section) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
3137
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground mb-2", children: section.label }),
|
|
3138
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2", children: section.content })
|
|
3139
|
+
] }, section.label)),
|
|
3128
3140
|
children
|
|
3129
3141
|
] }),
|
|
3130
3142
|
actionSlot != null && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-6 py-4 flex justify-end shrink-0 border-t border-border bg-background", children: actionSlot })
|
|
@@ -3666,7 +3678,8 @@ var AddInvestigationField = ({
|
|
|
3666
3678
|
onChange,
|
|
3667
3679
|
onSearch,
|
|
3668
3680
|
recentlyUsed = [],
|
|
3669
|
-
frequentItems = []
|
|
3681
|
+
frequentItems = [],
|
|
3682
|
+
packages = []
|
|
3670
3683
|
}) => {
|
|
3671
3684
|
const [open, setOpen] = React15.useState(false);
|
|
3672
3685
|
const [query, setQuery] = React15.useState("");
|
|
@@ -3677,6 +3690,8 @@ var AddInvestigationField = ({
|
|
|
3677
3690
|
const debounceRef = React15.useRef(null);
|
|
3678
3691
|
const valueRef = React15.useRef([]);
|
|
3679
3692
|
const searchInputRef = React15.useRef(null);
|
|
3693
|
+
const addedByPackage = React15.useRef(/* @__PURE__ */ new Map());
|
|
3694
|
+
const [selectedPackageIds, setSelectedPackageIds] = React15.useState(/* @__PURE__ */ new Set());
|
|
3680
3695
|
const safeValue = Array.isArray(value) ? value : [];
|
|
3681
3696
|
valueRef.current = safeValue;
|
|
3682
3697
|
const addedIds = new Set(safeValue.map((inv) => inv.id));
|
|
@@ -3751,6 +3766,27 @@ var AddInvestigationField = ({
|
|
|
3751
3766
|
setAddingFrequentId(null);
|
|
3752
3767
|
}
|
|
3753
3768
|
}
|
|
3769
|
+
function handlePackageToggle(pkg) {
|
|
3770
|
+
const alreadyAdded = addedByPackage.current.has(pkg.id);
|
|
3771
|
+
if (alreadyAdded) {
|
|
3772
|
+
const idsToRemove = new Set(addedByPackage.current.get(pkg.id) ?? []);
|
|
3773
|
+
onChange(valueRef.current.filter((inv) => !idsToRemove.has(inv.id)));
|
|
3774
|
+
addedByPackage.current.delete(pkg.id);
|
|
3775
|
+
setSelectedPackageIds((prev) => {
|
|
3776
|
+
const next = new Set(prev);
|
|
3777
|
+
next.delete(pkg.id);
|
|
3778
|
+
return next;
|
|
3779
|
+
});
|
|
3780
|
+
} else {
|
|
3781
|
+
const currentIds = new Set(valueRef.current.map((inv) => inv.id));
|
|
3782
|
+
const newTests = pkg.tests.filter((t) => !currentIds.has(t.id)).map((t) => mapToInvestigation(t));
|
|
3783
|
+
if (newTests.length > 0) {
|
|
3784
|
+
onChange([...valueRef.current, ...newTests]);
|
|
3785
|
+
}
|
|
3786
|
+
addedByPackage.current.set(pkg.id, newTests.map((t) => t.id));
|
|
3787
|
+
setSelectedPackageIds((prev) => new Set(prev).add(pkg.id));
|
|
3788
|
+
}
|
|
3789
|
+
}
|
|
3754
3790
|
const recentlyUsedChips = recentlyUsed.map((r) => {
|
|
3755
3791
|
const isAdded = addedIds.has(r.id);
|
|
3756
3792
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -3794,6 +3830,38 @@ var AddInvestigationField = ({
|
|
|
3794
3830
|
item.id
|
|
3795
3831
|
);
|
|
3796
3832
|
}) : [];
|
|
3833
|
+
const packageChips = packages.map((pkg) => {
|
|
3834
|
+
const isAdded = selectedPackageIds.has(pkg.id);
|
|
3835
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3836
|
+
"button",
|
|
3837
|
+
{
|
|
3838
|
+
type: "button",
|
|
3839
|
+
onClick: () => handlePackageToggle(pkg),
|
|
3840
|
+
className: cn(
|
|
3841
|
+
"rounded-full border text-xs px-4 py-1.5 transition-colors flex items-center gap-2",
|
|
3842
|
+
isAdded ? "border-green-300 bg-green-50 text-green-700" : "border-border bg-white hover:bg-gray-50"
|
|
3843
|
+
),
|
|
3844
|
+
children: [
|
|
3845
|
+
isAdded && /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u2713" }),
|
|
3846
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold", children: pkg.name }),
|
|
3847
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
|
|
3848
|
+
"rounded-full px-1.5 py-0.5 text-[10px] font-medium",
|
|
3849
|
+
isAdded ? "bg-green-100 text-green-600" : "bg-purple-100 text-purple-600"
|
|
3850
|
+
), children: pkg.tests.length })
|
|
3851
|
+
]
|
|
3852
|
+
},
|
|
3853
|
+
pkg.id
|
|
3854
|
+
);
|
|
3855
|
+
});
|
|
3856
|
+
const chipSections = [];
|
|
3857
|
+
if (frequentItemChips.length > 0) {
|
|
3858
|
+
chipSections.push({ label: "Frequently used", content: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: frequentItemChips }) });
|
|
3859
|
+
} else if (recentlyUsedChips.length > 0) {
|
|
3860
|
+
chipSections.push({ label: "Recently Used", content: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: recentlyUsedChips }) });
|
|
3861
|
+
}
|
|
3862
|
+
if (packageChips.length > 0) {
|
|
3863
|
+
chipSections.push({ label: "Packages", content: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: packageChips }) });
|
|
3864
|
+
}
|
|
3797
3865
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-md overflow-hidden flex flex-col bg-white border border-[#D0D0D0] space-y-3 p-3 h-fit", children: [
|
|
3798
3866
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-3", children: [
|
|
3799
3867
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold", children: label }),
|
|
@@ -3832,8 +3900,7 @@ var AddInvestigationField = ({
|
|
|
3832
3900
|
open,
|
|
3833
3901
|
onClose: () => setOpen(false),
|
|
3834
3902
|
title: "Add Investigation",
|
|
3835
|
-
|
|
3836
|
-
chipSectionLabel: frequentItemChips.length > 0 ? "Frequently used" : void 0,
|
|
3903
|
+
chipSections: chipSections.length > 0 ? chipSections : void 0,
|
|
3837
3904
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
3838
3905
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3839
3906
|
Input,
|
|
@@ -3874,6 +3941,7 @@ var AddInvestigationWidget = ({ fieldId }) => {
|
|
|
3874
3941
|
const { value, setValue } = useField(fieldId);
|
|
3875
3942
|
const handlers = useFieldHandlers(fieldId);
|
|
3876
3943
|
const { investigations: frequentInvestigations } = useFrequentItems();
|
|
3944
|
+
const packages = usePackages();
|
|
3877
3945
|
const safeValue = Array.isArray(value) ? value : [];
|
|
3878
3946
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3879
3947
|
AddInvestigationField,
|
|
@@ -3882,7 +3950,8 @@ var AddInvestigationWidget = ({ fieldId }) => {
|
|
|
3882
3950
|
onChange: setValue,
|
|
3883
3951
|
onSearch: handlers.onSearch,
|
|
3884
3952
|
recentlyUsed: handlers.recentlyUsed,
|
|
3885
|
-
frequentItems: frequentInvestigations
|
|
3953
|
+
frequentItems: frequentInvestigations,
|
|
3954
|
+
packages
|
|
3886
3955
|
}
|
|
3887
3956
|
);
|
|
3888
3957
|
};
|
|
@@ -8453,10 +8522,21 @@ var ReadOnlyReferral = ({ fieldDef, value }) => {
|
|
|
8453
8522
|
}) })
|
|
8454
8523
|
] });
|
|
8455
8524
|
};
|
|
8456
|
-
function
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
|
|
8525
|
+
function parseOrders(value) {
|
|
8526
|
+
if (value == null) return [];
|
|
8527
|
+
if (Array.isArray(value)) {
|
|
8528
|
+
return value.filter(
|
|
8529
|
+
(v) => v != null && typeof v === "object" && typeof v.id === "string"
|
|
8530
|
+
);
|
|
8531
|
+
}
|
|
8532
|
+
if (typeof value === "object") {
|
|
8533
|
+
const v = value;
|
|
8534
|
+
const orders = Array.isArray(v.orders) ? v.orders : [];
|
|
8535
|
+
return orders.filter(
|
|
8536
|
+
(o) => o != null && typeof o === "object" && typeof o.id === "string"
|
|
8537
|
+
);
|
|
8538
|
+
}
|
|
8539
|
+
return [];
|
|
8460
8540
|
}
|
|
8461
8541
|
function formatDuration2(start, end) {
|
|
8462
8542
|
if (!start && !end) return null;
|
|
@@ -8464,7 +8544,7 @@ function formatDuration2(start, end) {
|
|
|
8464
8544
|
return start ? `Start: ${start}` : `End: ${end}`;
|
|
8465
8545
|
}
|
|
8466
8546
|
var ReadOnlyDischargeMedicationOrders = ({ fieldDef, value }) => {
|
|
8467
|
-
const orders = React15.useMemo(() =>
|
|
8547
|
+
const orders = React15.useMemo(() => parseOrders(value), [value]);
|
|
8468
8548
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
8469
8549
|
/* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium text-gray-700", children: fieldDef.label }),
|
|
8470
8550
|
orders.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-gray-900 border border-gray-200 rounded-md p-3 bg-gray-50 min-h-[2.5rem]", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-400 italic", children: "No medicines added" }) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2", children: orders.map((o) => {
|
|
@@ -8764,6 +8844,7 @@ exports.useFieldHandlers = useFieldHandlers;
|
|
|
8764
8844
|
exports.useForm = useForm;
|
|
8765
8845
|
exports.useFormStore = useFormStore;
|
|
8766
8846
|
exports.useFrequentItems = useFrequentItems;
|
|
8847
|
+
exports.usePackages = usePackages;
|
|
8767
8848
|
exports.useSmartKeywords = useSmartKeywords;
|
|
8768
8849
|
exports.validateField = validateField;
|
|
8769
8850
|
exports.validateForm = validateForm;
|