@motor-hero/ui-kit 0.44.1 → 0.45.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
@@ -671,30 +671,35 @@ function useInfiniteScrollSentinel({
671
671
  loading,
672
672
  onLoadMore
673
673
  }) {
674
- const listRef = React4.useRef(null);
675
- const sentinelRef = React4.useRef(null);
674
+ const [listNode, setListNode] = React4.useState(null);
675
+ const [sentinelNode, setSentinelNode] = React4.useState(
676
+ null
677
+ );
676
678
  const loadingRef = React4.useRef(loading);
677
679
  const onLoadMoreRef = React4.useRef(onLoadMore);
680
+ const listRef = React4.useCallback((node) => {
681
+ setListNode(node);
682
+ }, []);
683
+ const sentinelRef = React4.useCallback((node) => {
684
+ setSentinelNode(node);
685
+ }, []);
678
686
  React4.useEffect(() => {
679
687
  loadingRef.current = loading;
680
688
  onLoadMoreRef.current = onLoadMore;
681
689
  });
682
690
  React4.useEffect(() => {
683
- if (!enabled) return;
684
- const root = listRef.current;
685
- const sentinel = sentinelRef.current;
686
- if (!root || !sentinel) return;
691
+ if (!enabled || !listNode || !sentinelNode) return;
687
692
  const observer = new IntersectionObserver(
688
693
  (entries) => {
689
694
  if (entries[0]?.isIntersecting && !loadingRef.current) {
690
695
  onLoadMoreRef.current?.();
691
696
  }
692
697
  },
693
- { root, rootMargin: "0px 0px 100px 0px" }
698
+ { root: listNode, rootMargin: "0px 0px 100px 0px" }
694
699
  );
695
- observer.observe(sentinel);
700
+ observer.observe(sentinelNode);
696
701
  return () => observer.disconnect();
697
- }, [enabled]);
702
+ }, [enabled, listNode, sentinelNode]);
698
703
  return { listRef, sentinelRef };
699
704
  }
700
705
 
@@ -725,7 +730,14 @@ function Combobox({
725
730
  const [search, setSearch] = React5.useState("");
726
731
  const isDesktop = useIsDesktop();
727
732
  const isServer = onSearchChange !== void 0;
728
- const selected = selectedOption?.value === value ? selectedOption : options.find((option) => option.value === value) ?? (creatable && value ? { value, label: value } : void 0);
733
+ const labelCache = React5.useRef(/* @__PURE__ */ new Map());
734
+ const fromPage = selectedOption?.value === value ? selectedOption : options.find((option) => option.value === value);
735
+ React5.useEffect(() => {
736
+ for (const option of options) labelCache.current.set(option.value, option);
737
+ if (selectedOption)
738
+ labelCache.current.set(selectedOption.value, selectedOption);
739
+ });
740
+ const selected = fromPage ?? (value ? labelCache.current.get(value) : void 0) ?? (creatable && value ? { value, label: value } : void 0);
729
741
  const handleOpenChange = (next) => {
730
742
  setOpen(next);
731
743
  if (!next) setSearch("");
@@ -1534,7 +1546,7 @@ function HighlightPill({
1534
1546
  }
1535
1547
 
1536
1548
  // src/components/mobile-card-list.tsx
1537
- import { useRef as useRef3 } from "react";
1549
+ import { useRef as useRef4 } from "react";
1538
1550
  import { jsx as jsx18, jsxs as jsxs15 } from "react/jsx-runtime";
1539
1551
  var SCROLL_THRESHOLD = 8;
1540
1552
  function MobileCardList({
@@ -1545,8 +1557,8 @@ function MobileCardList({
1545
1557
  loadingCount = 5,
1546
1558
  className
1547
1559
  }) {
1548
- const start = useRef3(null);
1549
- const scrolled = useRef3(false);
1560
+ const start = useRef4(null);
1561
+ const scrolled = useRef4(false);
1550
1562
  const onTouchStart = (e) => {
1551
1563
  const t = e.touches[0];
1552
1564
  start.current = { x: t.clientX, y: t.clientY };
@@ -1602,7 +1614,7 @@ import * as DropdownMenu2 from "@radix-ui/react-dropdown-menu";
1602
1614
  import { Moon, Sun, Monitor } from "lucide-react";
1603
1615
 
1604
1616
  // src/components/theme-provider.tsx
1605
- import { createContext, useContext, useEffect as useEffect4, useState as useState8 } from "react";
1617
+ import { createContext, useContext, useEffect as useEffect5, useState as useState9 } from "react";
1606
1618
 
1607
1619
  // src/lib/company-theme.ts
1608
1620
  var VAR_MAP = {
@@ -1643,10 +1655,10 @@ function ThemeProvider({
1643
1655
  companyTheme,
1644
1656
  ...props
1645
1657
  }) {
1646
- const [theme, setTheme] = useState8(
1658
+ const [theme, setTheme] = useState9(
1647
1659
  () => localStorage.getItem(storageKey) || defaultTheme
1648
1660
  );
1649
- useEffect4(() => {
1661
+ useEffect5(() => {
1650
1662
  const root = window.document.documentElement;
1651
1663
  const applyResolved = (resolved) => {
1652
1664
  root.classList.remove("light", "dark");
@@ -1769,12 +1781,14 @@ function MultiCombobox({
1769
1781
  const [open, setOpen] = React8.useState(false);
1770
1782
  const isDesktop = useIsDesktop();
1771
1783
  const isServer = onSearchChange !== void 0;
1772
- const seen = /* @__PURE__ */ new Set();
1773
- const selected = [...selectedOptions ?? [], ...options].filter((option) => {
1774
- if (!value.includes(option.value) || seen.has(option.value)) return false;
1775
- seen.add(option.value);
1776
- return true;
1784
+ const labelCache = React8.useRef(/* @__PURE__ */ new Map());
1785
+ const byValue = /* @__PURE__ */ new Map();
1786
+ for (const option of options) byValue.set(option.value, option);
1787
+ for (const option of selectedOptions ?? []) byValue.set(option.value, option);
1788
+ React8.useEffect(() => {
1789
+ for (const [key, option] of byValue) labelCache.current.set(key, option);
1777
1790
  });
1791
+ const selected = value.map((v) => byValue.get(v) ?? labelCache.current.get(v)).filter((option) => option !== void 0);
1778
1792
  const { listRef, sentinelRef } = useInfiniteScrollSentinel({
1779
1793
  enabled: isServer && !!hasMore,
1780
1794
  loading,
@@ -2118,7 +2132,7 @@ function ResponsiveDataView({
2118
2132
  // src/components/row-actions-menu.tsx
2119
2133
  import * as DropdownMenu3 from "@radix-ui/react-dropdown-menu";
2120
2134
  import { ChevronRight as ChevronRight3, MoreVertical } from "lucide-react";
2121
- import { useState as useState11 } from "react";
2135
+ import { useState as useState12 } from "react";
2122
2136
  import { Drawer as DrawerPrimitive6 } from "vaul";
2123
2137
  import { Fragment as Fragment6, jsx as jsx27, jsxs as jsxs23 } from "react/jsx-runtime";
2124
2138
  var triggerClass = "inline-flex h-8 w-8 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";
@@ -2132,7 +2146,7 @@ function RowActionsMenu({
2132
2146
  renderLink = defaultRenderLink
2133
2147
  }) {
2134
2148
  const isDesktop = useIsDesktop();
2135
- const [open, setOpen] = useState11(false);
2149
+ const [open, setOpen] = useState12(false);
2136
2150
  if (actions.length === 0) return null;
2137
2151
  const trigger = /* @__PURE__ */ jsx27(
2138
2152
  "button",
@@ -2473,7 +2487,7 @@ function Toaster(props) {
2473
2487
  }
2474
2488
 
2475
2489
  // src/hooks/use-company-subdomain.ts
2476
- import { useState as useState12 } from "react";
2490
+ import { useState as useState13 } from "react";
2477
2491
  var ALWAYS_RESERVED = ["www", "localhost"];
2478
2492
  function getSubdomain(hostname, reservedSubdomains = []) {
2479
2493
  const labels = hostname.split(".");
@@ -2506,7 +2520,7 @@ function useCompanySubdomain(opts = {}) {
2506
2520
  overrideStorageKey = "company-subdomain",
2507
2521
  reservedSubdomains = []
2508
2522
  } = opts;
2509
- const [subdomain] = useState12(() => {
2523
+ const [subdomain] = useState13(() => {
2510
2524
  if (enableOverride) {
2511
2525
  const override = resolveOverride(overrideStorageKey);
2512
2526
  if (override) return override;
@@ -2518,20 +2532,20 @@ function useCompanySubdomain(opts = {}) {
2518
2532
  }
2519
2533
 
2520
2534
  // src/hooks/use-disclosure.ts
2521
- import { useCallback as useCallback2, useState as useState13 } from "react";
2535
+ import { useCallback as useCallback3, useState as useState14 } from "react";
2522
2536
  function useDisclosure(initial = false) {
2523
- const [open, setOpen] = useState13(initial);
2524
- const onOpen = useCallback2(() => setOpen(true), []);
2525
- const onClose = useCallback2(() => setOpen(false), []);
2526
- const onToggle = useCallback2(() => setOpen((v) => !v), []);
2537
+ const [open, setOpen] = useState14(initial);
2538
+ const onOpen = useCallback3(() => setOpen(true), []);
2539
+ const onClose = useCallback3(() => setOpen(false), []);
2540
+ const onToggle = useCallback3(() => setOpen((v) => !v), []);
2527
2541
  return { open, onOpen, onClose, onToggle, setOpen };
2528
2542
  }
2529
2543
 
2530
2544
  // src/hooks/use-toast.ts
2531
2545
  import { toast } from "sonner";
2532
- import { useCallback as useCallback3 } from "react";
2546
+ import { useCallback as useCallback4 } from "react";
2533
2547
  function useCustomToast() {
2534
- const showToast = useCallback3(
2548
+ const showToast = useCallback4(
2535
2549
  (title, description, status = "success") => {
2536
2550
  switch (status) {
2537
2551
  case "success":