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.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
type FieldType = 'text' | 'number' | 'textarea' | 'select' | 'multiselect' | 'radio' | 'repeatable' | 'checkbox' | 'image_upload' | 'signature' | 'date' | 'datetime' | 'editable_table' | 'static_text' | 'medications' | 'investigations' | 'procedures' | 'vitals' | 'referral' | 'followup' | string;
|
|
3
|
+
type FieldType = 'text' | 'number' | 'textarea' | 'select' | 'multiselect' | 'radio' | 'repeatable' | 'checkbox' | 'image_upload' | 'signature' | 'date' | 'datetime' | 'editable_table' | 'static_text' | 'medications' | 'investigations' | 'procedures' | 'vitals' | 'hidden_vitals' | 'referral' | 'followup' | string;
|
|
4
4
|
interface ValidationRule {
|
|
5
5
|
min?: number;
|
|
6
6
|
max?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
type FieldType = 'text' | 'number' | 'textarea' | 'select' | 'multiselect' | 'radio' | 'repeatable' | 'checkbox' | 'image_upload' | 'signature' | 'date' | 'datetime' | 'editable_table' | 'static_text' | 'medications' | 'investigations' | 'procedures' | 'vitals' | 'referral' | 'followup' | string;
|
|
3
|
+
type FieldType = 'text' | 'number' | 'textarea' | 'select' | 'multiselect' | 'radio' | 'repeatable' | 'checkbox' | 'image_upload' | 'signature' | 'date' | 'datetime' | 'editable_table' | 'static_text' | 'medications' | 'investigations' | 'procedures' | 'vitals' | 'hidden_vitals' | 'referral' | 'followup' | string;
|
|
4
4
|
interface ValidationRule {
|
|
5
5
|
min?: number;
|
|
6
6
|
max?: number;
|
package/dist/index.mjs
CHANGED
|
@@ -3763,6 +3763,38 @@ var VitalsWidget = ({ fieldId }) => {
|
|
|
3763
3763
|
}
|
|
3764
3764
|
);
|
|
3765
3765
|
};
|
|
3766
|
+
var HiddenVitalsWidget = ({ fieldId }) => {
|
|
3767
|
+
const { fieldDef, value, setValue, setTouched, error, disabled, touched } = useField(fieldId);
|
|
3768
|
+
const { state } = useForm();
|
|
3769
|
+
const showError = !!error && (touched || state.submitAttempted);
|
|
3770
|
+
if (!fieldDef) return null;
|
|
3771
|
+
const height = "height" in fieldDef ? fieldDef.height : void 0;
|
|
3772
|
+
const theme = getThemeConfig("textarea", fieldDef.theme);
|
|
3773
|
+
const wrapperClass = cn(theme?.wrapperClassName ?? "space-y-2", "sr-only");
|
|
3774
|
+
const labelClass = theme?.labelClassName;
|
|
3775
|
+
const inputClass = cn(theme?.inputClassName, showError && "border-red-500");
|
|
3776
|
+
const labelContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3777
|
+
fieldDef.label,
|
|
3778
|
+
" ",
|
|
3779
|
+
fieldDef.required && /* @__PURE__ */ jsx("span", { className: "text-red-500", children: "*" })
|
|
3780
|
+
] });
|
|
3781
|
+
return /* @__PURE__ */ jsxs("div", { className: wrapperClass, "aria-hidden": "true", children: [
|
|
3782
|
+
theme ? /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, className: labelClass, children: labelContent }) : /* @__PURE__ */ jsx(Label, { htmlFor: fieldId, children: labelContent }),
|
|
3783
|
+
/* @__PURE__ */ jsx(
|
|
3784
|
+
Textarea,
|
|
3785
|
+
{
|
|
3786
|
+
id: fieldId,
|
|
3787
|
+
value: value ?? "",
|
|
3788
|
+
onChange: (e) => setValue(e.target.value),
|
|
3789
|
+
onBlur: setTouched,
|
|
3790
|
+
disabled,
|
|
3791
|
+
className: inputClass,
|
|
3792
|
+
...height != null && { height }
|
|
3793
|
+
}
|
|
3794
|
+
),
|
|
3795
|
+
showError && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: error })
|
|
3796
|
+
] });
|
|
3797
|
+
};
|
|
3766
3798
|
function normalizeOptions(response) {
|
|
3767
3799
|
if (Array.isArray(response)) {
|
|
3768
3800
|
return response.map((o) => ({ label: String(o.label), value: String(o.value) }));
|
|
@@ -6379,6 +6411,8 @@ var FieldRenderer = ({ fieldId }) => {
|
|
|
6379
6411
|
return /* @__PURE__ */ jsx(DifferentialDiagnosisWidget, { fieldId });
|
|
6380
6412
|
case "vitals":
|
|
6381
6413
|
return /* @__PURE__ */ jsx(VitalsWidget, { fieldId });
|
|
6414
|
+
case "hidden_vitals":
|
|
6415
|
+
return /* @__PURE__ */ jsx(HiddenVitalsWidget, { fieldId });
|
|
6382
6416
|
case "referral":
|
|
6383
6417
|
return /* @__PURE__ */ jsx(ReferralWidget, { fieldId });
|
|
6384
6418
|
case "followup":
|
|
@@ -6910,6 +6944,39 @@ var ReadOnlyCheckbox = ({ fieldDef, value }) => {
|
|
|
6910
6944
|
/* @__PURE__ */ 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__ */ jsx("span", { className: "text-gray-400 italic", children: "Loading..." }) : displayText })
|
|
6911
6945
|
] });
|
|
6912
6946
|
};
|
|
6947
|
+
function normalizeValue2(value) {
|
|
6948
|
+
if (!value || !Array.isArray(value)) return [];
|
|
6949
|
+
return value.map((item) => {
|
|
6950
|
+
if (item && typeof item === "object" && "specialization" in item) {
|
|
6951
|
+
return {
|
|
6952
|
+
specialization: String(item.specialization),
|
|
6953
|
+
is_urgent: Boolean(item.is_urgent)
|
|
6954
|
+
};
|
|
6955
|
+
}
|
|
6956
|
+
return { specialization: String(item), is_urgent: false };
|
|
6957
|
+
});
|
|
6958
|
+
}
|
|
6959
|
+
var ReadOnlyReferral = ({ fieldDef, value }) => {
|
|
6960
|
+
if (!fieldDef) return null;
|
|
6961
|
+
const items = normalizeValue2(value);
|
|
6962
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
6963
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm font-medium text-gray-700", children: fieldDef.label }),
|
|
6964
|
+
items.length === 0 ? /* @__PURE__ */ jsx("div", { className: "text-gray-900 border border-gray-200 rounded-md p-3 bg-gray-50 min-h-[2.5rem]", children: /* @__PURE__ */ jsx("span", { className: "text-gray-400 italic", children: "No value" }) }) : /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1.5", children: items.map((item, i) => {
|
|
6965
|
+
const isUrgent = item.is_urgent;
|
|
6966
|
+
return /* @__PURE__ */ jsxs(
|
|
6967
|
+
"span",
|
|
6968
|
+
{
|
|
6969
|
+
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",
|
|
6970
|
+
children: [
|
|
6971
|
+
isUrgent && /* @__PURE__ */ jsx("span", { className: "flex-shrink-0 bg-red-600 text-white text-[10px] font-bold px-1 py-0.5 rounded", children: "U" }),
|
|
6972
|
+
item.specialization
|
|
6973
|
+
]
|
|
6974
|
+
},
|
|
6975
|
+
i
|
|
6976
|
+
);
|
|
6977
|
+
}) })
|
|
6978
|
+
] });
|
|
6979
|
+
};
|
|
6913
6980
|
var ReadOnlyFieldRenderer = ({ fieldDef, value }) => {
|
|
6914
6981
|
if (!fieldDef) return null;
|
|
6915
6982
|
switch (fieldDef.type) {
|
|
@@ -6938,6 +7005,8 @@ var ReadOnlyFieldRenderer = ({ fieldDef, value }) => {
|
|
|
6938
7005
|
return /* @__PURE__ */ jsx(ReadOnlySignature, { fieldDef, value });
|
|
6939
7006
|
case "editable_table":
|
|
6940
7007
|
return /* @__PURE__ */ jsx(ReadOnlyTable, { fieldDef, value });
|
|
7008
|
+
case "referral":
|
|
7009
|
+
return /* @__PURE__ */ jsx(ReadOnlyReferral, { fieldDef, value });
|
|
6941
7010
|
case "static_text": {
|
|
6942
7011
|
const def = fieldDef;
|
|
6943
7012
|
const size = def.size ?? "regular";
|