@motor-hero/ui-kit 0.50.0 → 0.51.1

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.js CHANGED
@@ -681,7 +681,7 @@ function Rating({
681
681
 
682
682
  // src/components/combobox.tsx
683
683
  import * as PopoverPrimitive2 from "@radix-ui/react-popover";
684
- import { Command as CommandPrimitive } from "cmdk";
684
+ import { Command as CommandPrimitive, defaultFilter } from "cmdk";
685
685
  import { Check, ChevronsUpDown as ChevronsUpDown2, Loader2, Plus, Search } from "lucide-react";
686
686
  import * as React5 from "react";
687
687
  import { Drawer as DrawerPrimitive2 } from "vaul";
@@ -799,7 +799,14 @@ function Combobox({
799
799
  className
800
800
  ),
801
801
  children: [
802
- /* @__PURE__ */ jsx9("span", { className: cn("truncate", !selected && "text-muted-foreground"), children: selected ? selected.label : placeholder }),
802
+ /* @__PURE__ */ jsx9(
803
+ "span",
804
+ {
805
+ title: selected?.description,
806
+ className: cn("truncate", !selected && "text-muted-foreground"),
807
+ children: selected ? selected.label : placeholder
808
+ }
809
+ ),
803
810
  /* @__PURE__ */ jsx9(ChevronsUpDown2, { className: "h-4 w-4 shrink-0 opacity-50" })
804
811
  ]
805
812
  }
@@ -808,6 +815,7 @@ function Combobox({
808
815
  CommandPrimitive,
809
816
  {
810
817
  shouldFilter: !isServer,
818
+ filter: filterByKeywords,
811
819
  className: "flex h-full w-full flex-col overflow-hidden",
812
820
  children: [
813
821
  /* @__PURE__ */ jsxs7("div", { className: "flex items-center border-b px-3", children: [
@@ -832,6 +840,7 @@ function Combobox({
832
840
  CommandPrimitive.Item,
833
841
  {
834
842
  value: trimmedSearch,
843
+ keywords: [trimmedSearch],
835
844
  onSelect: () => handleSelect(trimmedSearch),
836
845
  className: "relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-2.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground sm:py-1.5",
837
846
  children: [
@@ -845,7 +854,8 @@ function Combobox({
845
854
  options.map((option) => /* @__PURE__ */ jsxs7(
846
855
  CommandPrimitive.Item,
847
856
  {
848
- value: isServer ? option.value : option.label,
857
+ value: option.value,
858
+ keywords: optionKeywords(option),
849
859
  disabled: option.disabled,
850
860
  onSelect: () => handleSelect(option.value),
851
861
  className: "relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-2.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 sm:py-1.5",
@@ -860,7 +870,7 @@ function Combobox({
860
870
  }
861
871
  ),
862
872
  option.icon,
863
- /* @__PURE__ */ jsx9("span", { className: "truncate", children: option.label })
873
+ /* @__PURE__ */ jsx9(OptionText, { option })
864
874
  ]
865
875
  },
866
876
  option.value
@@ -901,6 +911,23 @@ function Combobox({
901
911
  ] })
902
912
  ] });
903
913
  }
914
+ var filterByKeywords = (_value, search, keywords = []) => defaultFilter(keywords.join(" "), search);
915
+ var optionKeywords = (option) => option.description ? [option.label, option.description] : [option.label];
916
+ function OptionText({ option }) {
917
+ if (!option.description)
918
+ return /* @__PURE__ */ jsx9("span", { className: "truncate", children: option.label });
919
+ return /* @__PURE__ */ jsxs7("span", { className: "flex min-w-0 flex-col", children: [
920
+ /* @__PURE__ */ jsx9("span", { className: "truncate", children: option.label }),
921
+ /* @__PURE__ */ jsx9(
922
+ "span",
923
+ {
924
+ title: option.description,
925
+ className: "truncate text-xs text-muted-foreground",
926
+ children: option.description
927
+ }
928
+ )
929
+ ] });
930
+ }
904
931
 
905
932
  // src/components/confirm-dialog.tsx
906
933
  import * as AlertDialog from "@radix-ui/react-alert-dialog";
@@ -1818,6 +1845,10 @@ function MultiCombobox({
1818
1845
  for (const [key, option] of byValue) labelCache.current.set(key, option);
1819
1846
  });
1820
1847
  const selected = value.map((v) => byValue.get(v) ?? labelCache.current.get(v)).filter((option) => option !== void 0);
1848
+ const labelCounts = /* @__PURE__ */ new Map();
1849
+ for (const option of selected)
1850
+ labelCounts.set(option.label, (labelCounts.get(option.label) ?? 0) + 1);
1851
+ const chipLabel = (option) => option.description && (labelCounts.get(option.label) ?? 0) > 1 ? `${option.label} \xB7 ${option.description}` : option.label;
1821
1852
  const { listRef, sentinelRef } = useInfiniteScrollSentinel({
1822
1853
  enabled: isServer && !!hasMore,
1823
1854
  loading,
@@ -1856,9 +1887,10 @@ function MultiCombobox({
1856
1887
  selected.length === 0 ? /* @__PURE__ */ jsx21("span", { className: "text-muted-foreground", children: placeholder }) : selected.map((option) => /* @__PURE__ */ jsxs17(
1857
1888
  "span",
1858
1889
  {
1890
+ title: option.description,
1859
1891
  className: "inline-flex items-center gap-1 rounded bg-secondary px-1.5 py-0.5 text-xs text-secondary-foreground",
1860
1892
  children: [
1861
- option.label,
1893
+ chipLabel(option),
1862
1894
  /* @__PURE__ */ jsx21(
1863
1895
  "button",
1864
1896
  {
@@ -1886,6 +1918,7 @@ function MultiCombobox({
1886
1918
  CommandPrimitive2,
1887
1919
  {
1888
1920
  shouldFilter: !isServer,
1921
+ filter: filterByKeywords,
1889
1922
  className: "flex h-full w-full flex-col overflow-hidden",
1890
1923
  children: [
1891
1924
  /* @__PURE__ */ jsxs17("div", { className: "flex items-center border-b px-3", children: [
@@ -1909,7 +1942,8 @@ function MultiCombobox({
1909
1942
  options.map((option) => /* @__PURE__ */ jsxs17(
1910
1943
  CommandPrimitive2.Item,
1911
1944
  {
1912
- value: isServer ? option.value : option.label,
1945
+ value: option.value,
1946
+ keywords: optionKeywords(option),
1913
1947
  disabled: option.disabled,
1914
1948
  onSelect: () => toggleValue(option.value),
1915
1949
  className: "relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-2.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 sm:py-1.5",
@@ -1923,7 +1957,7 @@ function MultiCombobox({
1923
1957
  )
1924
1958
  }
1925
1959
  ),
1926
- /* @__PURE__ */ jsx21("span", { className: "truncate", children: option.label })
1960
+ /* @__PURE__ */ jsx21(OptionText, { option })
1927
1961
  ]
1928
1962
  },
1929
1963
  option.value