formanitor 0.0.18 → 0.0.20
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 +69 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +69 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3793,6 +3793,38 @@ var VitalsWidget = ({ fieldId }) => {
|
|
|
3793
3793
|
}
|
|
3794
3794
|
);
|
|
3795
3795
|
};
|
|
3796
|
+
var HiddenVitalsWidget = ({ fieldId }) => {
|
|
3797
|
+
const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
|
|
3798
|
+
const { state } = useForm();
|
|
3799
|
+
const showError = !!error && (touched || state.submitAttempted);
|
|
3800
|
+
if (!fieldDef) return null;
|
|
3801
|
+
const height = "height" in fieldDef ? fieldDef.height : void 0;
|
|
3802
|
+
const theme = getThemeConfig("textarea", fieldDef.theme);
|
|
3803
|
+
const wrapperClass = cn(theme?.wrapperClassName ?? "space-y-2", "sr-only");
|
|
3804
|
+
const labelClass = theme?.labelClassName;
|
|
3805
|
+
const inputClass = cn(theme?.inputClassName, showError && "border-red-500");
|
|
3806
|
+
const labelContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3807
|
+
fieldDef.label,
|
|
3808
|
+
" ",
|
|
3809
|
+
fieldDef.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500", children: "*" })
|
|
3810
|
+
] });
|
|
3811
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperClass, "aria-hidden": "true", children: [
|
|
3812
|
+
theme ? /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, className: labelClass, children: labelContent }) : /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: fieldId, children: labelContent }),
|
|
3813
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3814
|
+
Textarea,
|
|
3815
|
+
{
|
|
3816
|
+
id: fieldId,
|
|
3817
|
+
value: value ?? "",
|
|
3818
|
+
onChange: (e) => setValue(e.target.value),
|
|
3819
|
+
onBlur: setTouched,
|
|
3820
|
+
disabled,
|
|
3821
|
+
className: inputClass,
|
|
3822
|
+
...height != null && { height }
|
|
3823
|
+
}
|
|
3824
|
+
),
|
|
3825
|
+
showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
|
|
3826
|
+
] });
|
|
3827
|
+
};
|
|
3796
3828
|
function normalizeOptions(response) {
|
|
3797
3829
|
if (Array.isArray(response)) {
|
|
3798
3830
|
return response.map((o) => ({ label: String(o.label), value: String(o.value) }));
|
|
@@ -6409,6 +6441,8 @@ var FieldRenderer = ({ fieldId }) => {
|
|
|
6409
6441
|
return /* @__PURE__ */ jsxRuntime.jsx(DifferentialDiagnosisWidget, { fieldId });
|
|
6410
6442
|
case "vitals":
|
|
6411
6443
|
return /* @__PURE__ */ jsxRuntime.jsx(VitalsWidget, { fieldId });
|
|
6444
|
+
case "hidden_vitals":
|
|
6445
|
+
return /* @__PURE__ */ jsxRuntime.jsx(HiddenVitalsWidget, { fieldId });
|
|
6412
6446
|
case "referral":
|
|
6413
6447
|
return /* @__PURE__ */ jsxRuntime.jsx(ReferralWidget, { fieldId });
|
|
6414
6448
|
case "followup":
|
|
@@ -6940,6 +6974,39 @@ var ReadOnlyCheckbox = ({ fieldDef, value }) => {
|
|
|
6940
6974
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-gray-900 border border-gray-200 rounded-md p-3 bg-gray-50 min-h-[2.5rem] flex items-center", children: loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-400 italic", children: "Loading..." }) : displayText })
|
|
6941
6975
|
] });
|
|
6942
6976
|
};
|
|
6977
|
+
function normalizeValue2(value) {
|
|
6978
|
+
if (!value || !Array.isArray(value)) return [];
|
|
6979
|
+
return value.map((item) => {
|
|
6980
|
+
if (item && typeof item === "object" && "specialization" in item) {
|
|
6981
|
+
return {
|
|
6982
|
+
specialization: String(item.specialization),
|
|
6983
|
+
is_urgent: Boolean(item.is_urgent)
|
|
6984
|
+
};
|
|
6985
|
+
}
|
|
6986
|
+
return { specialization: String(item), is_urgent: false };
|
|
6987
|
+
});
|
|
6988
|
+
}
|
|
6989
|
+
var ReadOnlyReferral = ({ fieldDef, value }) => {
|
|
6990
|
+
if (!fieldDef) return null;
|
|
6991
|
+
const items = normalizeValue2(value);
|
|
6992
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
6993
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium text-gray-700", children: fieldDef.label }),
|
|
6994
|
+
items.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 value" }) }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1.5", children: items.map((item, i) => {
|
|
6995
|
+
const isUrgent = item.is_urgent;
|
|
6996
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6997
|
+
"span",
|
|
6998
|
+
{
|
|
6999
|
+
className: isUrgent ? "inline-flex items-center gap-1 px-2 py-0.5 bg-red-100 text-red-800 border border-red-300 rounded-full text-xs font-medium" : "inline-flex items-center gap-1 px-2 py-0.5 bg-blue-100 text-blue-800 rounded-full text-xs font-medium",
|
|
7000
|
+
children: [
|
|
7001
|
+
isUrgent && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-shrink-0 bg-red-600 text-white text-[10px] font-bold px-1 py-0.5 rounded", children: "U" }),
|
|
7002
|
+
item.specialization
|
|
7003
|
+
]
|
|
7004
|
+
},
|
|
7005
|
+
i
|
|
7006
|
+
);
|
|
7007
|
+
}) })
|
|
7008
|
+
] });
|
|
7009
|
+
};
|
|
6943
7010
|
var ReadOnlyFieldRenderer = ({ fieldDef, value }) => {
|
|
6944
7011
|
if (!fieldDef) return null;
|
|
6945
7012
|
switch (fieldDef.type) {
|
|
@@ -6968,6 +7035,8 @@ var ReadOnlyFieldRenderer = ({ fieldDef, value }) => {
|
|
|
6968
7035
|
return /* @__PURE__ */ jsxRuntime.jsx(ReadOnlySignature, { fieldDef, value });
|
|
6969
7036
|
case "editable_table":
|
|
6970
7037
|
return /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyTable, { fieldDef, value });
|
|
7038
|
+
case "referral":
|
|
7039
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyReferral, { fieldDef, value });
|
|
6971
7040
|
case "static_text": {
|
|
6972
7041
|
const def = fieldDef;
|
|
6973
7042
|
const size = def.size ?? "regular";
|