@algenium/blocks 1.9.1 → 1.10.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
@@ -3666,6 +3666,158 @@ function ThemeSwitcher({
3666
3666
  }
3667
3667
  );
3668
3668
  }
3669
+ var defaultLabels2 = {
3670
+ heading: "Organizations",
3671
+ create: "Create organization",
3672
+ empty: "No organization selected"
3673
+ };
3674
+ function TenantAvatar({
3675
+ name,
3676
+ logo,
3677
+ size = "md"
3678
+ }) {
3679
+ const sizeClass = size === "sm" ? "size-6 rounded-md" : "size-8 rounded-lg";
3680
+ const textClass = size === "sm" ? "text-xs" : "text-sm";
3681
+ return /* @__PURE__ */ jsxRuntime.jsx(
3682
+ "div",
3683
+ {
3684
+ className: cn(
3685
+ "flex shrink-0 items-center justify-center overflow-hidden bg-muted font-medium text-muted-foreground",
3686
+ sizeClass
3687
+ ),
3688
+ children: logo ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: logo, alt: "", className: "size-full object-cover" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: textClass, children: name.charAt(0).toUpperCase() })
3689
+ }
3690
+ );
3691
+ }
3692
+ function SwitcherSkeleton({ className }) {
3693
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3694
+ "div",
3695
+ {
3696
+ "data-testid": "org-switcher-skeleton",
3697
+ className: cn(
3698
+ "pointer-events-none flex h-12 min-h-12 w-full items-center gap-2 rounded-md px-2",
3699
+ className
3700
+ ),
3701
+ children: [
3702
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "size-8 shrink-0 animate-pulse rounded-lg bg-muted" }),
3703
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
3704
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-24 animate-pulse rounded bg-muted" }),
3705
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-3 w-16 animate-pulse rounded bg-muted" })
3706
+ ] }),
3707
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto size-4 shrink-0 animate-pulse rounded-sm bg-muted" })
3708
+ ]
3709
+ }
3710
+ );
3711
+ }
3712
+ var triggerClassName = "flex h-12 min-h-12 w-full items-center gap-2 rounded-md px-2 text-left text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:bg-accent data-[state=open]:text-accent-foreground";
3713
+ function OrgSwitcher({
3714
+ activeTenant,
3715
+ tenants,
3716
+ onSelectTenant,
3717
+ createUrl,
3718
+ isLoading = false,
3719
+ collapsed = false,
3720
+ isMobile = false,
3721
+ activeSubtitle,
3722
+ labels: userLabels,
3723
+ className,
3724
+ triggerClassName: triggerClassNameProp
3725
+ }) {
3726
+ const labels = { ...defaultLabels2, ...userLabels };
3727
+ if (isLoading) {
3728
+ return /* @__PURE__ */ jsxRuntime.jsx(SwitcherSkeleton, { className });
3729
+ }
3730
+ if (!activeTenant) {
3731
+ if (createUrl) {
3732
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3733
+ "a",
3734
+ {
3735
+ href: createUrl,
3736
+ "data-testid": "org-switcher-empty",
3737
+ className: cn(triggerClassName, className, triggerClassNameProp),
3738
+ children: [
3739
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-8 items-center justify-center rounded-lg bg-muted", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Building2, { className: "size-4 text-muted-foreground" }) }),
3740
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid min-w-0 flex-1 text-left leading-tight", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium", children: labels.empty }) })
3741
+ ]
3742
+ }
3743
+ );
3744
+ }
3745
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3746
+ "div",
3747
+ {
3748
+ "data-testid": "org-switcher-empty",
3749
+ className: cn(triggerClassName, "pointer-events-none", className),
3750
+ children: [
3751
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-8 items-center justify-center rounded-lg bg-muted", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Building2, { className: "size-4 text-muted-foreground" }) }),
3752
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid min-w-0 flex-1 text-left leading-tight", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium text-muted-foreground", children: labels.empty }) })
3753
+ ]
3754
+ }
3755
+ );
3756
+ }
3757
+ return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
3758
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
3759
+ Button,
3760
+ {
3761
+ type: "button",
3762
+ variant: "ghost",
3763
+ "data-testid": "org-switcher",
3764
+ className: cn(
3765
+ triggerClassName,
3766
+ "h-auto justify-start font-normal",
3767
+ className,
3768
+ triggerClassNameProp
3769
+ ),
3770
+ children: [
3771
+ /* @__PURE__ */ jsxRuntime.jsx(TenantAvatar, { name: activeTenant.name, logo: activeTenant.logo }),
3772
+ !collapsed ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3773
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid min-w-0 flex-1 text-left leading-tight", children: [
3774
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-semibold", children: activeTenant.name }),
3775
+ activeSubtitle ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs text-muted-foreground", children: activeSubtitle }) : null
3776
+ ] }),
3777
+ activeTenant.statusBadge,
3778
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsUpDown, { className: "ml-auto size-4 shrink-0 opacity-50" })
3779
+ ] }) : null
3780
+ ]
3781
+ }
3782
+ ) }),
3783
+ /* @__PURE__ */ jsxRuntime.jsxs(
3784
+ DropdownMenuContent,
3785
+ {
3786
+ className: "min-w-64 rounded-lg",
3787
+ align: "start",
3788
+ side: isMobile ? "bottom" : "right",
3789
+ sideOffset: 4,
3790
+ children: [
3791
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, { className: "text-xs text-muted-foreground", children: labels.heading }),
3792
+ tenants.map((tenant, index) => {
3793
+ const isActive = tenant.id === activeTenant.id;
3794
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3795
+ DropdownMenuItem,
3796
+ {
3797
+ onClick: () => onSelectTenant(tenant.id),
3798
+ className: "gap-2 p-2",
3799
+ children: [
3800
+ /* @__PURE__ */ jsxRuntime.jsx(TenantAvatar, { name: tenant.name, logo: tenant.logo, size: "sm" }),
3801
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 whitespace-normal break-words", children: tenant.name }),
3802
+ tenant.statusBadge,
3803
+ isActive ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "size-4 shrink-0 opacity-70" }) : /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuShortcut, { children: String.fromCharCode(65 + index) })
3804
+ ]
3805
+ },
3806
+ tenant.id
3807
+ );
3808
+ }),
3809
+ createUrl ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3810
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
3811
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuItem, { className: "gap-2 p-2", asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs("a", { href: createUrl, children: [
3812
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-6 items-center justify-center rounded-md border bg-background", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "size-4" }) }),
3813
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-medium text-muted-foreground", children: labels.create })
3814
+ ] }) })
3815
+ ] }) : null
3816
+ ]
3817
+ }
3818
+ )
3819
+ ] });
3820
+ }
3669
3821
  var defaultLanguages = [
3670
3822
  { key: "en", label: "EN", nativeName: "English" },
3671
3823
  { key: "es", label: "ES", nativeName: "Espa\xF1ol" }
@@ -3722,7 +3874,7 @@ function LanguageSwitcher({
3722
3874
  const onLanguageChange = propOnLanguageChange ?? context?.setLanguage;
3723
3875
  const sizes = sizeClasses2[size];
3724
3876
  const shapeClass = shapeClasses2[shape];
3725
- const defaultLabels4 = {
3877
+ const defaultLabels5 = {
3726
3878
  language: labels.language ?? "Language"
3727
3879
  };
3728
3880
  if (variant === "mini") {
@@ -3732,7 +3884,7 @@ function LanguageSwitcher({
3732
3884
  {
3733
3885
  variant: "ghost",
3734
3886
  size: "icon",
3735
- "aria-label": defaultLabels4.language,
3887
+ "aria-label": defaultLabels5.language,
3736
3888
  className: cn(sizes.buttonMini, shapeClass, className),
3737
3889
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Languages, { className: sizes.iconMini })
3738
3890
  }
@@ -3817,7 +3969,7 @@ function LanguageSwitcher({
3817
3969
  }
3818
3970
  );
3819
3971
  }
3820
- var defaultLabels2 = {
3972
+ var defaultLabels3 = {
3821
3973
  environment: "Data environment",
3822
3974
  live: "Live",
3823
3975
  staging: "Staging",
@@ -3890,7 +4042,7 @@ function EnvironmentMiniBadge({
3890
4042
  abbreviated = true
3891
4043
  }) {
3892
4044
  const ctx = useEnvironmentContext();
3893
- const labels = { ...defaultLabels2, ...userLabels };
4045
+ const labels = { ...defaultLabels3, ...userLabels };
3894
4046
  const environment = propEnvironment ?? ctx?.environment ?? "production";
3895
4047
  const text = abbreviated ? abbreviateEnvironment(environment) : getEnvironmentLabel(environment, labels);
3896
4048
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -3947,7 +4099,7 @@ function EnvironmentSwitcher({
3947
4099
  side = "bottom"
3948
4100
  }) {
3949
4101
  const ctx = useEnvironmentContext();
3950
- const labels = { ...defaultLabels2, ...userLabels };
4102
+ const labels = { ...defaultLabels3, ...userLabels };
3951
4103
  const environments = propEnvironments ?? ctx?.environments ?? [...BLOCKS_DATA_ENVIRONMENTS];
3952
4104
  const environment = propEnvironment ?? ctx?.environment ?? "production";
3953
4105
  const setEnvironment = propOnEnvironmentChange ?? ctx?.setEnvironment ?? (() => {
@@ -4102,7 +4254,7 @@ function EnvironmentSwitcher({
4102
4254
  }
4103
4255
  );
4104
4256
  }
4105
- var defaultLabels3 = {
4257
+ var defaultLabels4 = {
4106
4258
  stagingMessage: "You are viewing staging data \u2014 changes do not affect live customers.",
4107
4259
  developmentMessage: "You are viewing development data \u2014 for testing only.",
4108
4260
  dismiss: "Dismiss"
@@ -4114,7 +4266,7 @@ function EnvironmentBanner({
4114
4266
  enabled = true
4115
4267
  }) {
4116
4268
  const ctx = useEnvironmentContext();
4117
- const labels = { ...defaultLabels3, ...userLabels };
4269
+ const labels = { ...defaultLabels4, ...userLabels };
4118
4270
  const [dismissed, setDismissed] = React2.useState(false);
4119
4271
  const environment = propEnvironment ?? ctx?.environment ?? "production";
4120
4272
  const handleDismiss = React2.useCallback(() => {
@@ -8262,6 +8414,7 @@ exports.LoadingState = LoadingState;
8262
8414
  exports.MiniCalendar = MiniCalendar;
8263
8415
  exports.NotificationsContext = NotificationsContext;
8264
8416
  exports.NotificationsWidget = NotificationsWidget;
8417
+ exports.OrgSwitcher = OrgSwitcher;
8265
8418
  exports.Popover = Popover;
8266
8419
  exports.PopoverAnchor = PopoverAnchor;
8267
8420
  exports.PopoverContent = PopoverContent;