@sesionario/blocks 1.16.0 → 1.17.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.cjs CHANGED
@@ -1836,6 +1836,9 @@ var defaultLabels3 = {
1836
1836
  backoffice: "Backoffice",
1837
1837
  memberOrgs: "My organizations",
1838
1838
  managementOrgs: "Management team",
1839
+ showMoreOrgs: "Show more",
1840
+ showLessOrgs: "Show less",
1841
+ manageOrg: "Manage organization",
1839
1842
  language: "Language",
1840
1843
  theme: "Theme",
1841
1844
  themeLight: "Light",
@@ -1846,6 +1849,30 @@ var defaultLabels3 = {
1846
1849
  signingOut: "Signing out\u2026",
1847
1850
  accountSettings: "Account settings"
1848
1851
  };
1852
+ var PLATFORM_ACCOUNT_ORG_COLLAPSE_AT = 4;
1853
+ function mergePlatformAccountOrgs(memberOrgs, manageableOrgs) {
1854
+ const manageableIds = new Set(manageableOrgs.map((org) => org.id));
1855
+ const byId = /* @__PURE__ */ new Map();
1856
+ for (const org of memberOrgs) {
1857
+ byId.set(org.id, {
1858
+ ...org,
1859
+ canManage: manageableIds.has(org.id)
1860
+ });
1861
+ }
1862
+ for (const org of manageableOrgs) {
1863
+ const existing = byId.get(org.id);
1864
+ if (existing) {
1865
+ byId.set(org.id, {
1866
+ ...existing,
1867
+ canManage: true,
1868
+ logo: existing.logo ?? org.logo
1869
+ });
1870
+ } else {
1871
+ byId.set(org.id, { ...org, canManage: true });
1872
+ }
1873
+ }
1874
+ return Array.from(byId.values());
1875
+ }
1849
1876
  function MenuAvatar({
1850
1877
  name,
1851
1878
  image,
@@ -1913,6 +1940,85 @@ function LanguageThemeSubs({
1913
1940
  ] })
1914
1941
  ] });
1915
1942
  }
1943
+ function OrgMenuRows({
1944
+ orgs,
1945
+ appUrl,
1946
+ adminUrl,
1947
+ labels
1948
+ }) {
1949
+ const [expanded, setExpanded] = React7.useState(false);
1950
+ const collapsible = orgs.length > PLATFORM_ACCOUNT_ORG_COLLAPSE_AT;
1951
+ const visibleOrgs = collapsible && !expanded ? orgs.slice(0, PLATFORM_ACCOUNT_ORG_COLLAPSE_AT) : orgs;
1952
+ if (orgs.length === 0) return null;
1953
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1954
+ "div",
1955
+ {
1956
+ className: cn(
1957
+ expanded && orgs.length > PLATFORM_ACCOUNT_ORG_COLLAPSE_AT ? "max-h-64 overflow-y-auto scroll-fade-b" : void 0
1958
+ ),
1959
+ "data-testid": "platform-account-orgs",
1960
+ children: [
1961
+ visibleOrgs.map((org) => {
1962
+ const orgHomeHref = `${appUrl}/o/${org.slug}`;
1963
+ const manageHref = `${adminUrl}/api/auth/org/select?id=${encodeURIComponent(org.id)}`;
1964
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1965
+ "div",
1966
+ {
1967
+ className: "relative flex items-center",
1968
+ "data-testid": `platform-account-org-${org.id}`,
1969
+ children: [
1970
+ /* @__PURE__ */ jsxRuntime.jsx(
1971
+ DropdownMenuItem,
1972
+ {
1973
+ asChild: true,
1974
+ className: cn("min-w-0 flex-1 gap-2", org.canManage && "pr-9"),
1975
+ children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: orgHomeHref, children: [
1976
+ /* @__PURE__ */ jsxRuntime.jsx(
1977
+ MenuAvatar,
1978
+ {
1979
+ name: org.name,
1980
+ image: org.logo,
1981
+ sizeClass: "size-6"
1982
+ }
1983
+ ),
1984
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: org.name })
1985
+ ] })
1986
+ }
1987
+ ),
1988
+ org.canManage ? /* @__PURE__ */ jsxRuntime.jsx(
1989
+ DropdownMenuItem,
1990
+ {
1991
+ asChild: true,
1992
+ className: "absolute right-1 top-1/2 size-7 -translate-y-1/2 p-0",
1993
+ children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: manageHref, "aria-label": labels.manageOrg, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { className: "size-3.5" }) })
1994
+ }
1995
+ ) : null
1996
+ ]
1997
+ },
1998
+ org.id
1999
+ );
2000
+ }),
2001
+ collapsible ? /* @__PURE__ */ jsxRuntime.jsx(
2002
+ DropdownMenuItem,
2003
+ {
2004
+ className: "gap-2",
2005
+ onSelect: (event) => {
2006
+ event.preventDefault();
2007
+ setExpanded((value) => !value);
2008
+ },
2009
+ children: expanded ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2010
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, { className: "size-4" }),
2011
+ labels.showLessOrgs
2012
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2013
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "size-4" }),
2014
+ labels.showMoreOrgs
2015
+ ] })
2016
+ }
2017
+ ) : null
2018
+ ]
2019
+ }
2020
+ );
2021
+ }
1916
2022
  function PlatformAccountMenu({
1917
2023
  variant = "platform",
1918
2024
  isPending = false,
@@ -1937,6 +2043,10 @@ function PlatformAccountMenu({
1937
2043
  }) {
1938
2044
  const labels = { ...defaultLabels3, ...labelsProp };
1939
2045
  const [signingOut, setSigningOut] = React7.useState(false);
2046
+ const mergedOrgs = React7.useMemo(
2047
+ () => mergePlatformAccountOrgs(memberOrgs, manageableOrgs),
2048
+ [memberOrgs, manageableOrgs]
2049
+ );
1940
2050
  const loginHref = `${urls.authAppUrl}${urls.loginPath ?? "/login"}`;
1941
2051
  const accountHref = `${urls.authAppUrl}${urls.accountPath ?? "/account"}`;
1942
2052
  const activityHref = `${urls.authAppUrl}${urls.activityPath ?? "/account/activity"}`;
@@ -2028,26 +2138,15 @@ function PlatformAccountMenu({
2028
2138
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.User, { className: "size-4" }),
2029
2139
  labels.professionalProfile
2030
2140
  ] }) }),
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,
2141
+ /* @__PURE__ */ jsxRuntime.jsx(
2142
+ OrgMenuRows,
2143
+ {
2144
+ orgs: mergedOrgs,
2145
+ appUrl: urls.appUrl,
2146
+ adminUrl: urls.adminUrl,
2147
+ labels
2148
+ }
2149
+ ),
2051
2150
  extraItems,
2052
2151
  isAdmin && urls.backofficeUrl ? /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { asChild: true, className: "gap-2", children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: urls.backofficeUrl, children: [
2053
2152
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LayoutDashboard, { className: "size-4" }),
@@ -7686,6 +7785,7 @@ exports.MessageScrollerProvider = MessageScrollerProvider;
7686
7785
  exports.MessageScrollerViewport = MessageScrollerViewport;
7687
7786
  exports.MexicoMap = MexicoMap;
7688
7787
  exports.OrgSwitcher = OrgSwitcher;
7788
+ exports.PLATFORM_ACCOUNT_ORG_COLLAPSE_AT = PLATFORM_ACCOUNT_ORG_COLLAPSE_AT;
7689
7789
  exports.PhoneInput = PhoneInput;
7690
7790
  exports.PlatformAccountMenu = PlatformAccountMenu;
7691
7791
  exports.PlatformNavbar = PlatformNavbar;
@@ -7709,6 +7809,7 @@ exports.getAvatarColors = getAvatarColors;
7709
7809
  exports.getInitials = getInitials;
7710
7810
  exports.insertAtCaret = insertAtCaret;
7711
7811
  exports.markerVariants = markerVariants;
7812
+ exports.mergePlatformAccountOrgs = mergePlatformAccountOrgs;
7712
7813
  exports.normalizeEmojiQuery = normalizeEmojiQuery;
7713
7814
  exports.shouldRetryLiveEdge404 = shouldRetryLiveEdge404;
7714
7815
  exports.useDebouncedValue = useDebouncedValue;