@motor-hero/ui-kit 0.50.0 → 0.51.0

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
@@ -846,6 +846,7 @@ function Combobox({
846
846
  CommandPrimitive.Item,
847
847
  {
848
848
  value: isServer ? option.value : option.label,
849
+ keywords: option.description ? [option.description] : void 0,
849
850
  disabled: option.disabled,
850
851
  onSelect: () => handleSelect(option.value),
851
852
  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 +861,7 @@ function Combobox({
860
861
  }
861
862
  ),
862
863
  option.icon,
863
- /* @__PURE__ */ jsx9("span", { className: "truncate", children: option.label })
864
+ /* @__PURE__ */ jsx9(OptionText, { option })
864
865
  ]
865
866
  },
866
867
  option.value
@@ -901,6 +902,21 @@ function Combobox({
901
902
  ] })
902
903
  ] });
903
904
  }
905
+ function OptionText({ option }) {
906
+ if (!option.description)
907
+ return /* @__PURE__ */ jsx9("span", { className: "truncate", children: option.label });
908
+ return /* @__PURE__ */ jsxs7("span", { className: "flex min-w-0 flex-col", children: [
909
+ /* @__PURE__ */ jsx9("span", { className: "truncate", children: option.label }),
910
+ /* @__PURE__ */ jsx9(
911
+ "span",
912
+ {
913
+ title: option.description,
914
+ className: "truncate text-xs text-muted-foreground",
915
+ children: option.description
916
+ }
917
+ )
918
+ ] });
919
+ }
904
920
 
905
921
  // src/components/confirm-dialog.tsx
906
922
  import * as AlertDialog from "@radix-ui/react-alert-dialog";
@@ -1818,6 +1834,10 @@ function MultiCombobox({
1818
1834
  for (const [key, option] of byValue) labelCache.current.set(key, option);
1819
1835
  });
1820
1836
  const selected = value.map((v) => byValue.get(v) ?? labelCache.current.get(v)).filter((option) => option !== void 0);
1837
+ const labelCounts = /* @__PURE__ */ new Map();
1838
+ for (const option of selected)
1839
+ labelCounts.set(option.label, (labelCounts.get(option.label) ?? 0) + 1);
1840
+ const chipLabel = (option) => option.description && (labelCounts.get(option.label) ?? 0) > 1 ? `${option.label} \xB7 ${option.description}` : option.label;
1821
1841
  const { listRef, sentinelRef } = useInfiniteScrollSentinel({
1822
1842
  enabled: isServer && !!hasMore,
1823
1843
  loading,
@@ -1856,9 +1876,10 @@ function MultiCombobox({
1856
1876
  selected.length === 0 ? /* @__PURE__ */ jsx21("span", { className: "text-muted-foreground", children: placeholder }) : selected.map((option) => /* @__PURE__ */ jsxs17(
1857
1877
  "span",
1858
1878
  {
1879
+ title: option.description,
1859
1880
  className: "inline-flex items-center gap-1 rounded bg-secondary px-1.5 py-0.5 text-xs text-secondary-foreground",
1860
1881
  children: [
1861
- option.label,
1882
+ chipLabel(option),
1862
1883
  /* @__PURE__ */ jsx21(
1863
1884
  "button",
1864
1885
  {
@@ -1910,6 +1931,7 @@ function MultiCombobox({
1910
1931
  CommandPrimitive2.Item,
1911
1932
  {
1912
1933
  value: isServer ? option.value : option.label,
1934
+ keywords: option.description ? [option.description] : void 0,
1913
1935
  disabled: option.disabled,
1914
1936
  onSelect: () => toggleValue(option.value),
1915
1937
  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 +1945,7 @@ function MultiCombobox({
1923
1945
  )
1924
1946
  }
1925
1947
  ),
1926
- /* @__PURE__ */ jsx21("span", { className: "truncate", children: option.label })
1948
+ /* @__PURE__ */ jsx21(OptionText, { option })
1927
1949
  ]
1928
1950
  },
1929
1951
  option.value