@bizapps/ui 1.3.4 → 1.3.5

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/main.cjs CHANGED
@@ -2634,6 +2634,17 @@ function AccordionContent({
2634
2634
  }
2635
2635
  );
2636
2636
  }
2637
+ function createMatchFilter(mode) {
2638
+ return (value, search, keywords = []) => {
2639
+ const query = search.toLowerCase().trim();
2640
+ if (!query) return 1;
2641
+ const haystacks = [value, ...keywords].map((s) => s.toLowerCase());
2642
+ const matched = mode === "substring" ? haystacks.some((h) => h.includes(query)) : haystacks.some(
2643
+ (h) => h.startsWith(query) || h.split(/\s+/).some((word) => word.startsWith(query))
2644
+ );
2645
+ return matched ? 1 : 0;
2646
+ };
2647
+ }
2637
2648
  function Combobox({
2638
2649
  options,
2639
2650
  value,
@@ -2643,10 +2654,16 @@ function Combobox({
2643
2654
  emptyMessage = "No results found.",
2644
2655
  disabled = false,
2645
2656
  className,
2646
- container
2657
+ container,
2658
+ matchMode = "fuzzy"
2647
2659
  }) {
2648
2660
  const [open, setOpen] = react.useState(false);
2661
+ const listRef = react.useRef(null);
2649
2662
  const selected = options.find((opt) => opt.value === value);
2663
+ const filter = matchMode === "fuzzy" ? void 0 : createMatchFilter(matchMode);
2664
+ const handleSearchChange = () => {
2665
+ requestAnimationFrame(() => listRef.current?.scrollTo({ top: 0 }));
2666
+ };
2650
2667
  return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange: setOpen, children: [
2651
2668
  /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
2652
2669
  Button,
@@ -2666,18 +2683,19 @@ function Combobox({
2666
2683
  ]
2667
2684
  }
2668
2685
  ) }),
2669
- /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-64 rounded-lg p-0", align: "start", container, children: /* @__PURE__ */ jsxRuntime.jsxs(cmdk.Command, { className: "rounded-lg", children: [
2686
+ /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-64 rounded-lg p-0", align: "start", container, children: /* @__PURE__ */ jsxRuntime.jsxs(cmdk.Command, { className: "rounded-lg", filter, children: [
2670
2687
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-border flex items-center gap-2 border-b px-3", children: [
2671
2688
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SearchIcon, { size: 14, className: "text-muted-foreground shrink-0" }),
2672
2689
  /* @__PURE__ */ jsxRuntime.jsx(
2673
2690
  cmdk.Command.Input,
2674
2691
  {
2675
2692
  placeholder: searchPlaceholder,
2693
+ onValueChange: handleSearchChange,
2676
2694
  className: "placeholder:text-muted-foreground flex h-9 w-full bg-transparent py-2 text-sm outline-none disabled:cursor-not-allowed disabled:opacity-50"
2677
2695
  }
2678
2696
  )
2679
2697
  ] }),
2680
- /* @__PURE__ */ jsxRuntime.jsxs(cmdk.Command.List, { className: "max-h-56 overflow-y-auto p-1", children: [
2698
+ /* @__PURE__ */ jsxRuntime.jsxs(cmdk.Command.List, { ref: listRef, className: "max-h-56 overflow-y-auto p-1", children: [
2681
2699
  /* @__PURE__ */ jsxRuntime.jsx(cmdk.Command.Empty, { className: "text-muted-foreground py-4 text-center text-sm", children: emptyMessage }),
2682
2700
  options.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(
2683
2701
  cmdk.Command.Item,