formanitor 0.0.34 → 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.mjs CHANGED
@@ -618,6 +618,11 @@ var FormStore = class {
618
618
  this.config.role = next.role;
619
619
  needsReeval = true;
620
620
  }
621
+ if (next.prefillData !== void 0 && next.prefillData !== this.prefillData) {
622
+ this.prefillData = next.prefillData;
623
+ this.state.values = applyPrefill(this.state.values, this.schema.fields, this.prefillData);
624
+ needsReeval = true;
625
+ }
621
626
  if (needsReeval) {
622
627
  this.evaluate();
623
628
  this.notify();
@@ -8482,10 +8487,21 @@ var ReadOnlyReferral = ({ fieldDef, value }) => {
8482
8487
  }) })
8483
8488
  ] });
8484
8489
  };
8485
- function isOrderArray(value) {
8486
- return Array.isArray(value) && value.every(
8487
- (v) => v != null && typeof v === "object" && typeof v.id === "string"
8488
- );
8490
+ function parseOrders(value) {
8491
+ if (value == null) return [];
8492
+ if (Array.isArray(value)) {
8493
+ return value.filter(
8494
+ (v) => v != null && typeof v === "object" && typeof v.id === "string"
8495
+ );
8496
+ }
8497
+ if (typeof value === "object") {
8498
+ const v = value;
8499
+ const orders = Array.isArray(v.orders) ? v.orders : [];
8500
+ return orders.filter(
8501
+ (o) => o != null && typeof o === "object" && typeof o.id === "string"
8502
+ );
8503
+ }
8504
+ return [];
8489
8505
  }
8490
8506
  function formatDuration2(start, end) {
8491
8507
  if (!start && !end) return null;
@@ -8493,7 +8509,7 @@ function formatDuration2(start, end) {
8493
8509
  return start ? `Start: ${start}` : `End: ${end}`;
8494
8510
  }
8495
8511
  var ReadOnlyDischargeMedicationOrders = ({ fieldDef, value }) => {
8496
- const orders = useMemo(() => isOrderArray(value) ? value : [], [value]);
8512
+ const orders = useMemo(() => parseOrders(value), [value]);
8497
8513
  return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
8498
8514
  /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium text-gray-700", children: fieldDef.label }),
8499
8515
  orders.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 medicines added" }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-2", children: orders.map((o) => {