@motor-hero/ui-kit 0.49.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
@@ -1984,6 +2006,7 @@ function PageHeader({ title, description, action, className }) {
1984
2006
  }
1985
2007
 
1986
2008
  // src/components/pagination.tsx
2009
+ import { useId as useId2, useState as useState11 } from "react";
1987
2010
  import { jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
1988
2011
  var navButtonClass2 = "inline-flex h-8 max-sm:h-10 items-center justify-center rounded-md border border-input bg-background px-3 text-xs font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground cursor-pointer disabled:pointer-events-none disabled:opacity-50";
1989
2012
  function Pagination({
@@ -1992,6 +2015,7 @@ function Pagination({
1992
2015
  hasNextPage,
1993
2016
  hasPreviousPage,
1994
2017
  totalPages,
2018
+ showPageJump = false,
1995
2019
  showPageSizeSelector = false,
1996
2020
  pageSize,
1997
2021
  onPageSizeChange,
@@ -2027,7 +2051,7 @@ function Pagination({
2027
2051
  children: "Anterior"
2028
2052
  }
2029
2053
  ),
2030
- /* @__PURE__ */ jsxs19("span", { className: "text-sm text-muted-foreground", children: [
2054
+ showPageJump && totalPages !== void 0 ? /* @__PURE__ */ jsx23(PageJumpInput, { page, totalPages, onPageChange }) : /* @__PURE__ */ jsxs19("span", { className: "text-sm text-muted-foreground", children: [
2031
2055
  "P\xE1gina ",
2032
2056
  page,
2033
2057
  totalPages ? ` de ${totalPages}` : ""
@@ -2047,6 +2071,50 @@ function Pagination({
2047
2071
  }
2048
2072
  );
2049
2073
  }
2074
+ function PageJumpInput({ page, totalPages, onPageChange }) {
2075
+ const inputId = useId2();
2076
+ const [draft, setDraft] = useState11(null);
2077
+ const [prevPage, setPrevPage] = useState11(page);
2078
+ if (page !== prevPage) {
2079
+ setPrevPage(page);
2080
+ setDraft(null);
2081
+ }
2082
+ const commit = () => {
2083
+ if (draft === null) return;
2084
+ setDraft(null);
2085
+ if (draft === "") return;
2086
+ const target = Math.max(1, Math.min(Number(draft), totalPages));
2087
+ if (target !== page) onPageChange(target);
2088
+ };
2089
+ return /* @__PURE__ */ jsxs19("span", { className: "flex items-center gap-1.5 whitespace-nowrap text-sm text-muted-foreground", children: [
2090
+ /* @__PURE__ */ jsx23("label", { htmlFor: inputId, className: "max-sm:sr-only", children: "P\xE1gina" }),
2091
+ /* @__PURE__ */ jsx23(
2092
+ "input",
2093
+ {
2094
+ id: inputId,
2095
+ type: "text",
2096
+ inputMode: "numeric",
2097
+ enterKeyHint: "go",
2098
+ autoComplete: "off",
2099
+ "aria-label": "Ir para a p\xE1gina",
2100
+ value: draft ?? String(page),
2101
+ onChange: (e) => setDraft(e.target.value.replace(/\D/g, "")),
2102
+ onFocus: (e) => e.target.select(),
2103
+ onBlur: commit,
2104
+ onKeyDown: (e) => {
2105
+ if (e.key === "Enter") commit();
2106
+ else if (e.key === "Escape") setDraft(null);
2107
+ },
2108
+ style: { width: `${String(totalPages).length + 3}ch` },
2109
+ className: "h-8 max-sm:h-10 rounded-md border border-input bg-background px-1.5 text-center text-xs font-medium tabular-nums text-foreground shadow-sm transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
2110
+ }
2111
+ ),
2112
+ /* @__PURE__ */ jsxs19("span", { children: [
2113
+ "de ",
2114
+ totalPages
2115
+ ] })
2116
+ ] });
2117
+ }
2050
2118
 
2051
2119
  // src/components/password-input.tsx
2052
2120
  import { Eye, EyeOff } from "lucide-react";
@@ -2169,7 +2237,7 @@ function ResponsiveDataView({
2169
2237
  // src/components/row-actions-menu.tsx
2170
2238
  import * as DropdownMenu3 from "@radix-ui/react-dropdown-menu";
2171
2239
  import { ChevronRight as ChevronRight3, MoreVertical } from "lucide-react";
2172
- import { useState as useState12 } from "react";
2240
+ import { useState as useState13 } from "react";
2173
2241
  import { Drawer as DrawerPrimitive6 } from "vaul";
2174
2242
  import { Fragment as Fragment6, jsx as jsx27, jsxs as jsxs23 } from "react/jsx-runtime";
2175
2243
  var triggerClass = "inline-flex h-8 w-8 max-sm:h-10 max-sm:w-10 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50";
@@ -2183,7 +2251,7 @@ function RowActionsMenu({
2183
2251
  renderLink = defaultRenderLink
2184
2252
  }) {
2185
2253
  const isDesktop = useIsDesktop();
2186
- const [open, setOpen] = useState12(false);
2254
+ const [open, setOpen] = useState13(false);
2187
2255
  if (actions.length === 0) return null;
2188
2256
  const trigger = /* @__PURE__ */ jsx27(
2189
2257
  "button",
@@ -2527,14 +2595,14 @@ function Toaster(props) {
2527
2595
  import { RefreshCw } from "lucide-react";
2528
2596
 
2529
2597
  // src/hooks/use-version-check.ts
2530
- import { useCallback as useCallback3, useEffect as useEffect7, useState as useState13 } from "react";
2598
+ import { useCallback as useCallback3, useEffect as useEffect7, useState as useState14 } from "react";
2531
2599
  function useVersionCheck({
2532
2600
  currentBuild,
2533
2601
  url = "/version.json",
2534
2602
  intervalMs = 6e4
2535
2603
  }) {
2536
- const [latestBuild, setLatestBuild] = useState13(null);
2537
- const [staleChecks, setStaleChecks] = useState13(0);
2604
+ const [latestBuild, setLatestBuild] = useState14(null);
2605
+ const [staleChecks, setStaleChecks] = useState14(0);
2538
2606
  useEffect7(() => {
2539
2607
  if (!currentBuild) return;
2540
2608
  let cancelled = false;
@@ -2612,7 +2680,7 @@ function UpdateBanner({
2612
2680
  }
2613
2681
 
2614
2682
  // src/hooks/use-company-subdomain.ts
2615
- import { useState as useState14 } from "react";
2683
+ import { useState as useState15 } from "react";
2616
2684
  var ALWAYS_RESERVED = ["www", "localhost"];
2617
2685
  function getSubdomain(hostname, reservedSubdomains = []) {
2618
2686
  const labels = hostname.split(".");
@@ -2645,7 +2713,7 @@ function useCompanySubdomain(opts = {}) {
2645
2713
  overrideStorageKey = "company-subdomain",
2646
2714
  reservedSubdomains = []
2647
2715
  } = opts;
2648
- const [subdomain] = useState14(() => {
2716
+ const [subdomain] = useState15(() => {
2649
2717
  if (enableOverride) {
2650
2718
  const override = resolveOverride(overrideStorageKey);
2651
2719
  if (override) return override;
@@ -2657,9 +2725,9 @@ function useCompanySubdomain(opts = {}) {
2657
2725
  }
2658
2726
 
2659
2727
  // src/hooks/use-disclosure.ts
2660
- import { useCallback as useCallback4, useState as useState15 } from "react";
2728
+ import { useCallback as useCallback4, useState as useState16 } from "react";
2661
2729
  function useDisclosure(initial = false) {
2662
- const [open, setOpen] = useState15(initial);
2730
+ const [open, setOpen] = useState16(initial);
2663
2731
  const onOpen = useCallback4(() => setOpen(true), []);
2664
2732
  const onClose = useCallback4(() => setOpen(false), []);
2665
2733
  const onToggle = useCallback4(() => setOpen((v) => !v), []);