@bizapps/ui 1.3.3 → 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
@@ -2126,9 +2126,10 @@ function PopoverContent({
2126
2126
  className,
2127
2127
  align = "center",
2128
2128
  sideOffset = 4,
2129
+ container,
2129
2130
  ...props
2130
2131
  }) {
2131
- return /* @__PURE__ */ jsxRuntime.jsx(radixUi.Popover.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
2132
+ return /* @__PURE__ */ jsxRuntime.jsx(radixUi.Popover.Portal, { container, children: /* @__PURE__ */ jsxRuntime.jsx(
2132
2133
  radixUi.Popover.Content,
2133
2134
  {
2134
2135
  "data-slot": "popover-content",
@@ -2633,6 +2634,17 @@ function AccordionContent({
2633
2634
  }
2634
2635
  );
2635
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
+ }
2636
2648
  function Combobox({
2637
2649
  options,
2638
2650
  value,
@@ -2641,10 +2653,17 @@ function Combobox({
2641
2653
  searchPlaceholder = "Search...",
2642
2654
  emptyMessage = "No results found.",
2643
2655
  disabled = false,
2644
- className
2656
+ className,
2657
+ container,
2658
+ matchMode = "fuzzy"
2645
2659
  }) {
2646
2660
  const [open, setOpen] = react.useState(false);
2661
+ const listRef = react.useRef(null);
2647
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
+ };
2648
2667
  return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange: setOpen, children: [
2649
2668
  /* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
2650
2669
  Button,
@@ -2664,18 +2683,19 @@ function Combobox({
2664
2683
  ]
2665
2684
  }
2666
2685
  ) }),
2667
- /* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { className: "w-64 rounded-lg p-0", align: "start", 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: [
2668
2687
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-border flex items-center gap-2 border-b px-3", children: [
2669
2688
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SearchIcon, { size: 14, className: "text-muted-foreground shrink-0" }),
2670
2689
  /* @__PURE__ */ jsxRuntime.jsx(
2671
2690
  cmdk.Command.Input,
2672
2691
  {
2673
2692
  placeholder: searchPlaceholder,
2693
+ onValueChange: handleSearchChange,
2674
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"
2675
2695
  }
2676
2696
  )
2677
2697
  ] }),
2678
- /* @__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: [
2679
2699
  /* @__PURE__ */ jsxRuntime.jsx(cmdk.Command.Empty, { className: "text-muted-foreground py-4 text-center text-sm", children: emptyMessage }),
2680
2700
  options.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(
2681
2701
  cmdk.Command.Item,