@sesionario/blocks 1.16.0 → 1.17.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.cjs CHANGED
@@ -1746,7 +1746,7 @@ function PlatformNavbar({
1746
1746
  innerClassName
1747
1747
  ),
1748
1748
  children: [
1749
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex shrink-0 items-center gap-2", children: logo }),
1749
+ logo != null && logo !== false ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex shrink-0 items-center gap-2", children: logo }) : null,
1750
1750
  leading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex shrink-0 items-center gap-2", children: leading }) : null,
1751
1751
  /* @__PURE__ */ jsxRuntime.jsx(
1752
1752
  "div",
@@ -1831,11 +1831,9 @@ var defaultLabels3 = {
1831
1831
  personalProfile: "Personal profile",
1832
1832
  activity: "Activity",
1833
1833
  professionalProfile: "Professional profile",
1834
- mainApp: "Main app",
1835
- orgManagement: "Organization management",
1836
- backoffice: "Backoffice",
1837
- memberOrgs: "My organizations",
1838
- managementOrgs: "Management team",
1834
+ showMoreOrgs: "Show more",
1835
+ showLessOrgs: "Show less",
1836
+ manageOrg: "Manage organization",
1839
1837
  language: "Language",
1840
1838
  theme: "Theme",
1841
1839
  themeLight: "Light",
@@ -1846,6 +1844,30 @@ var defaultLabels3 = {
1846
1844
  signingOut: "Signing out\u2026",
1847
1845
  accountSettings: "Account settings"
1848
1846
  };
1847
+ var PLATFORM_ACCOUNT_ORG_COLLAPSE_AT = 4;
1848
+ function mergePlatformAccountOrgs(memberOrgs, manageableOrgs) {
1849
+ const manageableIds = new Set(manageableOrgs.map((org) => org.id));
1850
+ const byId = /* @__PURE__ */ new Map();
1851
+ for (const org of memberOrgs) {
1852
+ byId.set(org.id, {
1853
+ ...org,
1854
+ canManage: manageableIds.has(org.id)
1855
+ });
1856
+ }
1857
+ for (const org of manageableOrgs) {
1858
+ const existing = byId.get(org.id);
1859
+ if (existing) {
1860
+ byId.set(org.id, {
1861
+ ...existing,
1862
+ canManage: true,
1863
+ logo: existing.logo ?? org.logo
1864
+ });
1865
+ } else {
1866
+ byId.set(org.id, { ...org, canManage: true });
1867
+ }
1868
+ }
1869
+ return Array.from(byId.values());
1870
+ }
1849
1871
  function MenuAvatar({
1850
1872
  name,
1851
1873
  image,
@@ -1887,9 +1909,9 @@ function LanguageThemeSubs({
1887
1909
  const themeValue = theme ?? "system";
1888
1910
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1889
1911
  /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSub, { children: [
1890
- /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSubTrigger, { className: "gap-2", children: [
1891
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Languages, { className: "size-4" }),
1892
- labels.language
1912
+ /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSubTrigger, { className: "gap-2 [&>svg:last-child]:ml-0", children: [
1913
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: labels.language }),
1914
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Languages, { className: "size-4" })
1893
1915
  ] }),
1894
1916
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSubContent, { className: "min-w-40", children: /* @__PURE__ */ jsxRuntime.jsx(
1895
1917
  DropdownMenuRadioGroup,
@@ -1901,9 +1923,9 @@ function LanguageThemeSubs({
1901
1923
  ) })
1902
1924
  ] }),
1903
1925
  /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSub, { children: [
1904
- /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSubTrigger, { className: "gap-2", children: [
1905
- themeValue === "light" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Sun, { className: "size-4" }) : themeValue === "dark" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Moon, { className: "size-4" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Monitor, { className: "size-4" }),
1906
- labels.theme
1926
+ /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSubTrigger, { className: "gap-2 [&>svg:last-child]:ml-0", children: [
1927
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: labels.theme }),
1928
+ themeValue === "light" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Sun, { className: "size-4" }) : themeValue === "dark" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Moon, { className: "size-4" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Monitor, { className: "size-4" })
1907
1929
  ] }),
1908
1930
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSubContent, { className: "min-w-40", children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuRadioGroup, { value: themeValue, onValueChange: setTheme, children: [
1909
1931
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuRadioItem, { value: "system", children: labels.themeSystem }),
@@ -1913,11 +1935,86 @@ function LanguageThemeSubs({
1913
1935
  ] })
1914
1936
  ] });
1915
1937
  }
1938
+ function OrgMenuRows({
1939
+ orgs,
1940
+ appUrl,
1941
+ adminUrl,
1942
+ labels
1943
+ }) {
1944
+ const [expanded, setExpanded] = React7.useState(false);
1945
+ const collapsible = orgs.length > PLATFORM_ACCOUNT_ORG_COLLAPSE_AT;
1946
+ const visibleOrgs = collapsible && !expanded ? orgs.slice(0, PLATFORM_ACCOUNT_ORG_COLLAPSE_AT) : orgs;
1947
+ if (orgs.length === 0) return null;
1948
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1949
+ "div",
1950
+ {
1951
+ className: cn(
1952
+ expanded && orgs.length > PLATFORM_ACCOUNT_ORG_COLLAPSE_AT ? "max-h-64 overflow-y-auto scroll-fade-b" : void 0
1953
+ ),
1954
+ "data-testid": "platform-account-orgs",
1955
+ children: [
1956
+ visibleOrgs.map((org) => {
1957
+ const orgHomeHref = `${appUrl}/o/${org.slug}`;
1958
+ const manageHref = `${adminUrl}/api/auth/org/select?id=${encodeURIComponent(org.id)}`;
1959
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1960
+ "div",
1961
+ {
1962
+ className: "relative",
1963
+ "data-testid": `platform-account-org-${org.id}`,
1964
+ children: [
1965
+ /* @__PURE__ */ jsxRuntime.jsx(
1966
+ DropdownMenuItem,
1967
+ {
1968
+ asChild: true,
1969
+ className: cn("gap-2", org.canManage && "pr-9"),
1970
+ children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: orgHomeHref, children: [
1971
+ /* @__PURE__ */ jsxRuntime.jsx(
1972
+ MenuAvatar,
1973
+ {
1974
+ name: org.name,
1975
+ image: org.logo,
1976
+ sizeClass: "size-6"
1977
+ }
1978
+ ),
1979
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: org.name })
1980
+ ] })
1981
+ }
1982
+ ),
1983
+ org.canManage ? /* @__PURE__ */ jsxRuntime.jsx(
1984
+ DropdownMenuItem,
1985
+ {
1986
+ asChild: true,
1987
+ className: "absolute right-0.5 top-1/2 size-7 -translate-y-1/2 p-0",
1988
+ children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: manageHref, "aria-label": labels.manageOrg, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { className: "size-4" }) })
1989
+ }
1990
+ ) : null
1991
+ ]
1992
+ },
1993
+ org.id
1994
+ );
1995
+ }),
1996
+ collapsible ? /* @__PURE__ */ jsxRuntime.jsxs(
1997
+ DropdownMenuItem,
1998
+ {
1999
+ className: "gap-2",
2000
+ onSelect: (event) => {
2001
+ event.preventDefault();
2002
+ setExpanded((value) => !value);
2003
+ },
2004
+ children: [
2005
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: expanded ? labels.showLessOrgs : labels.showMoreOrgs }),
2006
+ expanded ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, { className: "size-4" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "size-4" })
2007
+ ]
2008
+ }
2009
+ ) : null
2010
+ ]
2011
+ }
2012
+ );
2013
+ }
1916
2014
  function PlatformAccountMenu({
1917
2015
  variant = "platform",
1918
2016
  isPending = false,
1919
2017
  user = null,
1920
- isAdmin = false,
1921
2018
  verificationStatus = "unverified",
1922
2019
  urls,
1923
2020
  memberOrgs = [],
@@ -1937,6 +2034,11 @@ function PlatformAccountMenu({
1937
2034
  }) {
1938
2035
  const labels = { ...defaultLabels3, ...labelsProp };
1939
2036
  const [signingOut, setSigningOut] = React7.useState(false);
2037
+ const mergedOrgs = React7.useMemo(
2038
+ () => mergePlatformAccountOrgs(memberOrgs, manageableOrgs),
2039
+ [memberOrgs, manageableOrgs]
2040
+ );
2041
+ const hasOrgs = mergedOrgs.length > 0;
1940
2042
  const loginHref = `${urls.authAppUrl}${urls.loginPath ?? "/login"}`;
1941
2043
  const accountHref = `${urls.authAppUrl}${urls.accountPath ?? "/account"}`;
1942
2044
  const activityHref = `${urls.authAppUrl}${urls.activityPath ?? "/account/activity"}`;
@@ -2016,48 +2118,36 @@ function PlatformAccountMenu({
2016
2118
  ] }),
2017
2119
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
2018
2120
  variant === "platform" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2121
+ hasOrgs ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2122
+ /* @__PURE__ */ jsxRuntime.jsx(
2123
+ OrgMenuRows,
2124
+ {
2125
+ orgs: mergedOrgs,
2126
+ appUrl: urls.appUrl,
2127
+ adminUrl: urls.adminUrl,
2128
+ labels
2129
+ }
2130
+ ),
2131
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {})
2132
+ ] }) : null,
2019
2133
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, className: "gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: accountHref, children: [
2020
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.User, { className: "size-4" }),
2021
- labels.personalProfile
2134
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: labels.personalProfile }),
2135
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.User, { className: "size-4" })
2022
2136
  ] }) }),
2023
2137
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, className: "gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: activityHref, children: [
2024
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Activity, { className: "size-4" }),
2025
- labels.activity
2138
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: labels.activity }),
2139
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Activity, { className: "size-4" })
2026
2140
  ] }) }),
2027
2141
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, className: "gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: profileHref, children: [
2028
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.User, { className: "size-4" }),
2029
- labels.professionalProfile
2142
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: labels.professionalProfile }),
2143
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.User, { className: "size-4" })
2030
2144
  ] }) }),
2031
- memberOrgs.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSub, { children: [
2032
- /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSubTrigger, { className: "gap-2", children: [
2033
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Users, { className: "size-4" }),
2034
- labels.memberOrgs
2035
- ] }),
2036
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSubContent, { className: "min-w-48 max-h-64 overflow-y-auto scroll-fade-b", children: memberOrgs.map((org) => /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: `${urls.appUrl}/o/${org.slug}`, children: org.name }) }, org.id)) })
2037
- ] }) : null,
2038
- manageableOrgs.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSub, { children: [
2039
- /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuSubTrigger, { className: "gap-2", children: [
2040
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Building2, { className: "size-4" }),
2041
- labels.managementOrgs
2042
- ] }),
2043
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSubContent, { className: "min-w-48 max-h-64 overflow-y-auto scroll-fade-b", children: manageableOrgs.map((org) => /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
2044
- "a",
2045
- {
2046
- href: `${urls.adminUrl}/api/auth/org/select?id=${encodeURIComponent(org.id)}`,
2047
- children: org.name
2048
- }
2049
- ) }, org.id)) })
2050
- ] }) : null,
2051
2145
  extraItems,
2052
- isAdmin && urls.backofficeUrl ? /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, className: "gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: urls.backofficeUrl, children: [
2053
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LayoutDashboard, { className: "size-4" }),
2054
- labels.backoffice
2055
- ] }) }) : null,
2056
2146
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {})
2057
2147
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2058
2148
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, className: "gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: accountHref, children: [
2059
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { className: "size-4" }),
2060
- labels.accountSettings
2149
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: labels.accountSettings }),
2150
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { className: "size-4" })
2061
2151
  ] }) }),
2062
2152
  extraItems,
2063
2153
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {})
@@ -2082,8 +2172,8 @@ function PlatformAccountMenu({
2082
2172
  void handleSignOut();
2083
2173
  },
2084
2174
  children: [
2085
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, { className: "size-4" }),
2086
- signingOut ? labels.signingOut : labels.signOut
2175
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: signingOut ? labels.signingOut : labels.signOut }),
2176
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, { className: "size-4" })
2087
2177
  ]
2088
2178
  }
2089
2179
  )
@@ -2099,8 +2189,8 @@ function PlatformAccountMenu({
2099
2189
  ),
2100
2190
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
2101
2191
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, className: "gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: loginHref, children: [
2102
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogIn, { className: "size-4" }),
2103
- labels.signIn
2192
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: labels.signIn }),
2193
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogIn, { className: "size-4" })
2104
2194
  ] }) })
2105
2195
  ] })
2106
2196
  }
@@ -7173,6 +7263,7 @@ function SupportMessengerProvider({
7173
7263
  className
7174
7264
  }) {
7175
7265
  const isMobile = useMediaQuery2("(max-width: 767px)");
7266
+ const dockRef = React7.useRef(null);
7176
7267
  const [listOpen, setListOpen] = React7.useState(false);
7177
7268
  const [threads, setThreads] = React7.useState([]);
7178
7269
  const [mobileThreadKey, setMobileThreadKey] = React7.useState(null);
@@ -7180,6 +7271,7 @@ function SupportMessengerProvider({
7180
7271
  () => items.reduce((sum, item) => sum + (item.unreadCount ?? 0), 0),
7181
7272
  [items]
7182
7273
  );
7274
+ const isDesktopOpen = !isMobile && (listOpen || threads.length > 0);
7183
7275
  React7.useEffect(() => {
7184
7276
  if (!forceMinimized) return;
7185
7277
  setListOpen(false);
@@ -7222,6 +7314,20 @@ function SupportMessengerProvider({
7222
7314
  setThreads([]);
7223
7315
  setMobileThreadKey(null);
7224
7316
  }, []);
7317
+ React7.useEffect(() => {
7318
+ if (!isDesktopOpen) return;
7319
+ function onPointerDown(event) {
7320
+ const target = event.target;
7321
+ if (!(target instanceof Node)) return;
7322
+ if (dockRef.current?.contains(target)) return;
7323
+ if (target instanceof Element && target.closest('[data-slot="popover-content"]')) {
7324
+ return;
7325
+ }
7326
+ closeAll();
7327
+ }
7328
+ document.addEventListener("pointerdown", onPointerDown);
7329
+ return () => document.removeEventListener("pointerdown", onPointerDown);
7330
+ }, [isDesktopOpen, closeAll]);
7225
7331
  const ctx = React7.useMemo(
7226
7332
  () => ({
7227
7333
  listOpen,
@@ -7265,6 +7371,7 @@ function SupportMessengerProvider({
7265
7371
  enabled ? /* @__PURE__ */ jsxRuntime.jsxs(
7266
7372
  "div",
7267
7373
  {
7374
+ ref: dockRef,
7268
7375
  className: cn(
7269
7376
  "pointer-events-none fixed right-4 bottom-4 z-50 flex flex-col items-end gap-3",
7270
7377
  className
@@ -7686,6 +7793,7 @@ exports.MessageScrollerProvider = MessageScrollerProvider;
7686
7793
  exports.MessageScrollerViewport = MessageScrollerViewport;
7687
7794
  exports.MexicoMap = MexicoMap;
7688
7795
  exports.OrgSwitcher = OrgSwitcher;
7796
+ exports.PLATFORM_ACCOUNT_ORG_COLLAPSE_AT = PLATFORM_ACCOUNT_ORG_COLLAPSE_AT;
7689
7797
  exports.PhoneInput = PhoneInput;
7690
7798
  exports.PlatformAccountMenu = PlatformAccountMenu;
7691
7799
  exports.PlatformNavbar = PlatformNavbar;
@@ -7709,6 +7817,7 @@ exports.getAvatarColors = getAvatarColors;
7709
7817
  exports.getInitials = getInitials;
7710
7818
  exports.insertAtCaret = insertAtCaret;
7711
7819
  exports.markerVariants = markerVariants;
7820
+ exports.mergePlatformAccountOrgs = mergePlatformAccountOrgs;
7712
7821
  exports.normalizeEmojiQuery = normalizeEmojiQuery;
7713
7822
  exports.shouldRetryLiveEdge404 = shouldRetryLiveEdge404;
7714
7823
  exports.useDebouncedValue = useDebouncedValue;