formanitor 0.0.24 → 0.0.26

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
@@ -1200,7 +1200,7 @@ var SelectContent = React13.forwardRef(({ className, children, position = "poppe
1200
1200
  {
1201
1201
  ref,
1202
1202
  className: cn(
1203
- "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
1203
+ "relative z-50 max-h-52 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
1204
1204
  position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
1205
1205
  className
1206
1206
  ),
@@ -3541,6 +3541,9 @@ function mapToProcedure(result) {
3541
3541
  fromAI: false
3542
3542
  };
3543
3543
  }
3544
+ function createCustomProcedure(trimmedName) {
3545
+ return { name: trimmedName.trim(), is_custom: true };
3546
+ }
3544
3547
  var AddProcedureField = ({
3545
3548
  label = "Procedures",
3546
3549
  value,
@@ -3559,7 +3562,9 @@ var AddProcedureField = ({
3559
3562
  const valueRef = useRef([]);
3560
3563
  const searchInputRef = useRef(null);
3561
3564
  valueRef.current = value;
3562
- const addedIds = new Set(value.map((proc) => proc.id));
3565
+ const addedIds = new Set(
3566
+ value.filter((proc) => !proc.is_custom).map((proc) => proc.id)
3567
+ );
3563
3568
  useEffect(() => {
3564
3569
  if (!open) {
3565
3570
  setQuery("");
@@ -3601,12 +3606,23 @@ var AddProcedureField = ({
3601
3606
  setTimeout(() => searchInputRef.current?.focus(), 0);
3602
3607
  }, ADD_FEEDBACK_MS3);
3603
3608
  }
3604
- function removeProcedure(id) {
3605
- onChange(value.filter((proc) => proc.id !== id));
3609
+ function removeAt(index) {
3610
+ onChange(value.filter((_, i) => i !== index));
3611
+ }
3612
+ function removeBySearchId(id) {
3613
+ onChange(value.filter((proc) => proc.is_custom || proc.id !== id));
3614
+ }
3615
+ function handleAddCustom() {
3616
+ const trimmed = query.trim();
3617
+ if (!trimmed) return;
3618
+ if (valueRef.current.some((p) => p.is_custom && p.name === trimmed)) return;
3619
+ onChange([...valueRef.current, createCustomProcedure(trimmed)]);
3620
+ setQuery("");
3621
+ setResults([]);
3606
3622
  }
3607
3623
  function handleRecentlyUsedToggle(result) {
3608
3624
  if (addedIds.has(result.id)) {
3609
- removeProcedure(result.id);
3625
+ removeBySearchId(result.id);
3610
3626
  } else {
3611
3627
  addProcedure(result);
3612
3628
  }
@@ -3616,7 +3632,7 @@ var AddProcedureField = ({
3616
3632
  const addedById = addedIds.has(id);
3617
3633
  const addedByName = value.some((proc) => proc.name === item.name);
3618
3634
  if (addedById || addedByName) {
3619
- if (addedById) removeProcedure(id);
3635
+ if (addedById) removeBySearchId(id);
3620
3636
  else onChange(value.filter((proc) => proc.name !== item.name));
3621
3637
  return;
3622
3638
  }
@@ -3624,7 +3640,7 @@ var AddProcedureField = ({
3624
3640
  try {
3625
3641
  const searchResults = await onSearch(item.name);
3626
3642
  const first = searchResults?.[0];
3627
- if (first && !valueRef.current.some((proc) => proc.id === first.id)) {
3643
+ if (first && !valueRef.current.some((proc) => !proc.is_custom && proc.id === first.id)) {
3628
3644
  onChange([...valueRef.current, mapToProcedure(first)]);
3629
3645
  }
3630
3646
  } finally {
@@ -3653,7 +3669,7 @@ var AddProcedureField = ({
3653
3669
  const limitedFrequentItems = frequentItems.slice(0, 25);
3654
3670
  const frequentItemChips = limitedFrequentItems.length > 0 ? limitedFrequentItems.map((item) => {
3655
3671
  const id = String(item.id);
3656
- const isAdded = value.some((proc) => proc.id === id) || value.some((proc) => proc.name === item.name);
3672
+ const isAdded = value.some((proc) => !proc.is_custom && proc.id === id) || value.some((proc) => proc.name === item.name);
3657
3673
  const isAdding = addingFrequentId === id;
3658
3674
  return /* @__PURE__ */ jsxs(
3659
3675
  "button",
@@ -3687,7 +3703,7 @@ var AddProcedureField = ({
3687
3703
  }
3688
3704
  )
3689
3705
  ] }),
3690
- value.length > 0 && /* @__PURE__ */ jsx("div", { className: "divide-y divide-border rounded-lg border border-border overflow-hidden", children: value.map((proc) => /* @__PURE__ */ jsxs(
3706
+ value.length > 0 && /* @__PURE__ */ jsx("div", { className: "divide-y divide-border rounded-lg border border-border overflow-hidden", children: value.map((proc, index) => /* @__PURE__ */ jsxs(
3691
3707
  "div",
3692
3708
  {
3693
3709
  className: "flex items-center justify-between px-3 py-2 bg-white hover:bg-gray-50",
@@ -3697,14 +3713,14 @@ var AddProcedureField = ({
3697
3713
  "button",
3698
3714
  {
3699
3715
  type: "button",
3700
- onClick: () => removeProcedure(proc.id),
3716
+ onClick: () => removeAt(index),
3701
3717
  className: "text-muted-foreground hover:text-red-500 transition-colors cursor-pointer",
3702
3718
  children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
3703
3719
  }
3704
3720
  )
3705
3721
  ]
3706
3722
  },
3707
- proc.id
3723
+ proc.is_custom ? `custom-${index}` : proc.id
3708
3724
  )) }),
3709
3725
  /* @__PURE__ */ jsx(
3710
3726
  AddEntityDialog,
@@ -3714,6 +3730,19 @@ var AddProcedureField = ({
3714
3730
  title: "Add Procedure",
3715
3731
  recentlyUsedSlot: frequentItemChips.length > 0 ? frequentItemChips : recentlyUsedChips.length > 0 ? recentlyUsedChips : void 0,
3716
3732
  chipSectionLabel: frequentItemChips.length > 0 ? "Frequently used" : void 0,
3733
+ actionSlot: /* @__PURE__ */ jsx(
3734
+ "button",
3735
+ {
3736
+ type: "button",
3737
+ disabled: !query.trim() || valueRef.current.some((p) => p.is_custom && p.name === query.trim()),
3738
+ onClick: handleAddCustom,
3739
+ className: cn(
3740
+ "rounded-md px-5 py-2 text-sm font-semibold bg-primary text-primary-foreground hover:bg-primary/90 transition-opacity cursor-pointer",
3741
+ (!query.trim() || valueRef.current.some((p) => p.is_custom && p.name === query.trim())) && "opacity-40 cursor-not-allowed"
3742
+ ),
3743
+ children: "Save Procedure"
3744
+ }
3745
+ ),
3717
3746
  children: /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
3718
3747
  /* @__PURE__ */ jsx(
3719
3748
  Input,
@@ -4181,7 +4210,7 @@ var ReferralWidget = ({ fieldId }) => {
4181
4210
  },
4182
4211
  `referral-${selectedItems.map((i) => i.specialization).join(",")}`
4183
4212
  ),
4184
- selectedItems.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1.5 mt-1.5", children: selectedItems.map((item) => {
4213
+ selectedItems.length > 0 && /* @__PURE__ */ jsx("div", { className: "mt-1.5 flex h-12 flex-wrap content-start gap-1.5 overflow-y-auto pr-1", children: selectedItems.map((item) => {
4185
4214
  const isUrgent = item.is_urgent;
4186
4215
  const chipClass = isUrgent ? "inline-flex items-center gap-0.5 px-2 py-0.5 bg-red-100 text-red-800 border border-red-300 rounded-full text-xs max-w-full cursor-pointer hover:bg-red-200 transition-colors" : "inline-flex items-center gap-0.5 px-2 py-0.5 bg-blue-100 text-blue-800 rounded-full text-xs max-w-full cursor-pointer hover:bg-blue-200 transition-colors";
4187
4216
  return /* @__PURE__ */ jsxs(