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.cjs CHANGED
@@ -1235,7 +1235,7 @@ var SelectContent = React13__namespace.forwardRef(({ className, children, positi
1235
1235
  {
1236
1236
  ref,
1237
1237
  className: cn(
1238
- "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",
1238
+ "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",
1239
1239
  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",
1240
1240
  className
1241
1241
  ),
@@ -3576,6 +3576,9 @@ function mapToProcedure(result) {
3576
3576
  fromAI: false
3577
3577
  };
3578
3578
  }
3579
+ function createCustomProcedure(trimmedName) {
3580
+ return { name: trimmedName.trim(), is_custom: true };
3581
+ }
3579
3582
  var AddProcedureField = ({
3580
3583
  label = "Procedures",
3581
3584
  value,
@@ -3594,7 +3597,9 @@ var AddProcedureField = ({
3594
3597
  const valueRef = React13.useRef([]);
3595
3598
  const searchInputRef = React13.useRef(null);
3596
3599
  valueRef.current = value;
3597
- const addedIds = new Set(value.map((proc) => proc.id));
3600
+ const addedIds = new Set(
3601
+ value.filter((proc) => !proc.is_custom).map((proc) => proc.id)
3602
+ );
3598
3603
  React13.useEffect(() => {
3599
3604
  if (!open) {
3600
3605
  setQuery("");
@@ -3636,12 +3641,23 @@ var AddProcedureField = ({
3636
3641
  setTimeout(() => searchInputRef.current?.focus(), 0);
3637
3642
  }, ADD_FEEDBACK_MS3);
3638
3643
  }
3639
- function removeProcedure(id) {
3640
- onChange(value.filter((proc) => proc.id !== id));
3644
+ function removeAt(index) {
3645
+ onChange(value.filter((_, i) => i !== index));
3646
+ }
3647
+ function removeBySearchId(id) {
3648
+ onChange(value.filter((proc) => proc.is_custom || proc.id !== id));
3649
+ }
3650
+ function handleAddCustom() {
3651
+ const trimmed = query.trim();
3652
+ if (!trimmed) return;
3653
+ if (valueRef.current.some((p) => p.is_custom && p.name === trimmed)) return;
3654
+ onChange([...valueRef.current, createCustomProcedure(trimmed)]);
3655
+ setQuery("");
3656
+ setResults([]);
3641
3657
  }
3642
3658
  function handleRecentlyUsedToggle(result) {
3643
3659
  if (addedIds.has(result.id)) {
3644
- removeProcedure(result.id);
3660
+ removeBySearchId(result.id);
3645
3661
  } else {
3646
3662
  addProcedure(result);
3647
3663
  }
@@ -3651,7 +3667,7 @@ var AddProcedureField = ({
3651
3667
  const addedById = addedIds.has(id);
3652
3668
  const addedByName = value.some((proc) => proc.name === item.name);
3653
3669
  if (addedById || addedByName) {
3654
- if (addedById) removeProcedure(id);
3670
+ if (addedById) removeBySearchId(id);
3655
3671
  else onChange(value.filter((proc) => proc.name !== item.name));
3656
3672
  return;
3657
3673
  }
@@ -3659,7 +3675,7 @@ var AddProcedureField = ({
3659
3675
  try {
3660
3676
  const searchResults = await onSearch(item.name);
3661
3677
  const first = searchResults?.[0];
3662
- if (first && !valueRef.current.some((proc) => proc.id === first.id)) {
3678
+ if (first && !valueRef.current.some((proc) => !proc.is_custom && proc.id === first.id)) {
3663
3679
  onChange([...valueRef.current, mapToProcedure(first)]);
3664
3680
  }
3665
3681
  } finally {
@@ -3688,7 +3704,7 @@ var AddProcedureField = ({
3688
3704
  const limitedFrequentItems = frequentItems.slice(0, 25);
3689
3705
  const frequentItemChips = limitedFrequentItems.length > 0 ? limitedFrequentItems.map((item) => {
3690
3706
  const id = String(item.id);
3691
- const isAdded = value.some((proc) => proc.id === id) || value.some((proc) => proc.name === item.name);
3707
+ const isAdded = value.some((proc) => !proc.is_custom && proc.id === id) || value.some((proc) => proc.name === item.name);
3692
3708
  const isAdding = addingFrequentId === id;
3693
3709
  return /* @__PURE__ */ jsxRuntime.jsxs(
3694
3710
  "button",
@@ -3722,7 +3738,7 @@ var AddProcedureField = ({
3722
3738
  }
3723
3739
  )
3724
3740
  ] }),
3725
- value.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "divide-y divide-border rounded-lg border border-border overflow-hidden", children: value.map((proc) => /* @__PURE__ */ jsxRuntime.jsxs(
3741
+ value.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "divide-y divide-border rounded-lg border border-border overflow-hidden", children: value.map((proc, index) => /* @__PURE__ */ jsxRuntime.jsxs(
3726
3742
  "div",
3727
3743
  {
3728
3744
  className: "flex items-center justify-between px-3 py-2 bg-white hover:bg-gray-50",
@@ -3732,14 +3748,14 @@ var AddProcedureField = ({
3732
3748
  "button",
3733
3749
  {
3734
3750
  type: "button",
3735
- onClick: () => removeProcedure(proc.id),
3751
+ onClick: () => removeAt(index),
3736
3752
  className: "text-muted-foreground hover:text-red-500 transition-colors cursor-pointer",
3737
3753
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4" })
3738
3754
  }
3739
3755
  )
3740
3756
  ]
3741
3757
  },
3742
- proc.id
3758
+ proc.is_custom ? `custom-${index}` : proc.id
3743
3759
  )) }),
3744
3760
  /* @__PURE__ */ jsxRuntime.jsx(
3745
3761
  AddEntityDialog,
@@ -3749,6 +3765,19 @@ var AddProcedureField = ({
3749
3765
  title: "Add Procedure",
3750
3766
  recentlyUsedSlot: frequentItemChips.length > 0 ? frequentItemChips : recentlyUsedChips.length > 0 ? recentlyUsedChips : void 0,
3751
3767
  chipSectionLabel: frequentItemChips.length > 0 ? "Frequently used" : void 0,
3768
+ actionSlot: /* @__PURE__ */ jsxRuntime.jsx(
3769
+ "button",
3770
+ {
3771
+ type: "button",
3772
+ disabled: !query.trim() || valueRef.current.some((p) => p.is_custom && p.name === query.trim()),
3773
+ onClick: handleAddCustom,
3774
+ className: cn(
3775
+ "rounded-md px-5 py-2 text-sm font-semibold bg-primary text-primary-foreground hover:bg-primary/90 transition-opacity cursor-pointer",
3776
+ (!query.trim() || valueRef.current.some((p) => p.is_custom && p.name === query.trim())) && "opacity-40 cursor-not-allowed"
3777
+ ),
3778
+ children: "Save Procedure"
3779
+ }
3780
+ ),
3752
3781
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
3753
3782
  /* @__PURE__ */ jsxRuntime.jsx(
3754
3783
  Input,
@@ -4216,7 +4245,7 @@ var ReferralWidget = ({ fieldId }) => {
4216
4245
  },
4217
4246
  `referral-${selectedItems.map((i) => i.specialization).join(",")}`
4218
4247
  ),
4219
- selectedItems.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1.5 mt-1.5", children: selectedItems.map((item) => {
4248
+ selectedItems.length > 0 && /* @__PURE__ */ jsxRuntime.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) => {
4220
4249
  const isUrgent = item.is_urgent;
4221
4250
  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";
4222
4251
  return /* @__PURE__ */ jsxRuntime.jsxs(