formanitor 0.0.34 → 0.0.36
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 +82 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.mjs +82 -5
- 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();
|
|
@@ -5343,6 +5348,40 @@ var DiagnosisTextareaWidget = ({ fieldId }) => {
|
|
|
5343
5348
|
showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
|
|
5344
5349
|
] });
|
|
5345
5350
|
};
|
|
5351
|
+
var Switch = React15__namespace.forwardRef(
|
|
5352
|
+
({ className, checked, onCheckedChange, disabled, ...props }, ref) => {
|
|
5353
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5354
|
+
"button",
|
|
5355
|
+
{
|
|
5356
|
+
type: "button",
|
|
5357
|
+
role: "switch",
|
|
5358
|
+
"aria-checked": checked,
|
|
5359
|
+
"data-state": checked ? "checked" : "unchecked",
|
|
5360
|
+
disabled,
|
|
5361
|
+
ref,
|
|
5362
|
+
onClick: () => {
|
|
5363
|
+
if (!disabled && onCheckedChange) {
|
|
5364
|
+
onCheckedChange(!checked);
|
|
5365
|
+
}
|
|
5366
|
+
},
|
|
5367
|
+
className: cn(
|
|
5368
|
+
"peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
|
5369
|
+
className
|
|
5370
|
+
),
|
|
5371
|
+
...props,
|
|
5372
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5373
|
+
"span",
|
|
5374
|
+
{
|
|
5375
|
+
"data-state": checked ? "checked" : "unchecked",
|
|
5376
|
+
className: "pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform",
|
|
5377
|
+
style: { transform: checked ? "translateX(1rem)" : "translateX(0)" }
|
|
5378
|
+
}
|
|
5379
|
+
)
|
|
5380
|
+
}
|
|
5381
|
+
);
|
|
5382
|
+
}
|
|
5383
|
+
);
|
|
5384
|
+
Switch.displayName = "Switch";
|
|
5346
5385
|
var DEFAULT_DRAFT = {
|
|
5347
5386
|
gpal: { G: 0, P: 0, A: 0, L: 0 },
|
|
5348
5387
|
lmp: "",
|
|
@@ -7916,6 +7955,26 @@ function renderWidget(fieldId, fieldDef) {
|
|
|
7916
7955
|
return /* @__PURE__ */ jsxRuntime.jsx(OphthalDiagnosisWidget, { fieldId });
|
|
7917
7956
|
case "orthopedic_exam":
|
|
7918
7957
|
return /* @__PURE__ */ jsxRuntime.jsx(OrthopedicExamWidget, { fieldId });
|
|
7958
|
+
case "toggle": {
|
|
7959
|
+
const { value, setValue, setTouched, disabled } = useField(fieldId);
|
|
7960
|
+
const store = useFormStore();
|
|
7961
|
+
const excludes = fieldDef.excludes ?? [];
|
|
7962
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
7963
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7964
|
+
Switch,
|
|
7965
|
+
{
|
|
7966
|
+
checked: value === true,
|
|
7967
|
+
disabled,
|
|
7968
|
+
onCheckedChange: (checked) => {
|
|
7969
|
+
setValue(checked);
|
|
7970
|
+
setTouched();
|
|
7971
|
+
if (checked) excludes.forEach((id) => store.setValue(id, false));
|
|
7972
|
+
}
|
|
7973
|
+
}
|
|
7974
|
+
),
|
|
7975
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium leading-none cursor-pointer select-none", children: fieldDef.label })
|
|
7976
|
+
] });
|
|
7977
|
+
}
|
|
7919
7978
|
case "static_text": {
|
|
7920
7979
|
const def = fieldDef;
|
|
7921
7980
|
const size = def.size ?? "regular";
|
|
@@ -8517,10 +8576,21 @@ var ReadOnlyReferral = ({ fieldDef, value }) => {
|
|
|
8517
8576
|
}) })
|
|
8518
8577
|
] });
|
|
8519
8578
|
};
|
|
8520
|
-
function
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
|
|
8579
|
+
function parseOrders(value) {
|
|
8580
|
+
if (value == null) return [];
|
|
8581
|
+
if (Array.isArray(value)) {
|
|
8582
|
+
return value.filter(
|
|
8583
|
+
(v) => v != null && typeof v === "object" && typeof v.id === "string"
|
|
8584
|
+
);
|
|
8585
|
+
}
|
|
8586
|
+
if (typeof value === "object") {
|
|
8587
|
+
const v = value;
|
|
8588
|
+
const orders = Array.isArray(v.orders) ? v.orders : [];
|
|
8589
|
+
return orders.filter(
|
|
8590
|
+
(o) => o != null && typeof o === "object" && typeof o.id === "string"
|
|
8591
|
+
);
|
|
8592
|
+
}
|
|
8593
|
+
return [];
|
|
8524
8594
|
}
|
|
8525
8595
|
function formatDuration2(start, end) {
|
|
8526
8596
|
if (!start && !end) return null;
|
|
@@ -8528,7 +8598,7 @@ function formatDuration2(start, end) {
|
|
|
8528
8598
|
return start ? `Start: ${start}` : `End: ${end}`;
|
|
8529
8599
|
}
|
|
8530
8600
|
var ReadOnlyDischargeMedicationOrders = ({ fieldDef, value }) => {
|
|
8531
|
-
const orders = React15.useMemo(() =>
|
|
8601
|
+
const orders = React15.useMemo(() => parseOrders(value), [value]);
|
|
8532
8602
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
8533
8603
|
/* @__PURE__ */ jsxRuntime.jsx(Label, { className: "text-sm font-medium text-gray-700", children: fieldDef.label }),
|
|
8534
8604
|
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) => {
|
|
@@ -8598,6 +8668,13 @@ var ReadOnlyFieldRenderer = ({ fieldDef, value }) => {
|
|
|
8598
8668
|
return /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyReferral, { fieldDef, value });
|
|
8599
8669
|
case "discharge_medication_orders":
|
|
8600
8670
|
return /* @__PURE__ */ jsxRuntime.jsx(ReadOnlyDischargeMedicationOrders, { fieldDef, value });
|
|
8671
|
+
case "toggle": {
|
|
8672
|
+
const isOn = value === true;
|
|
8673
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
8674
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: fieldDef.label }),
|
|
8675
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: `inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${isOn ? "bg-green-100 text-green-800" : "bg-gray-100 text-gray-600"}`, children: isOn ? "Yes" : "No" })
|
|
8676
|
+
] });
|
|
8677
|
+
}
|
|
8601
8678
|
case "static_text": {
|
|
8602
8679
|
const def = fieldDef;
|
|
8603
8680
|
const size = def.size ?? "regular";
|