@getgreenline/blaze-ui 1.0.32 → 1.0.33

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.
@@ -36,6 +36,7 @@ declare const AppsConfig: readonly [{
36
36
  readonly subdomain: null;
37
37
  }];
38
38
  type AppName = (typeof AppsConfig)[number]["name"];
39
+ type AppSubdomain = NonNullable<(typeof AppsConfig)[number]["subdomain"]>;
39
40
  type HeaderAppSwitcherProps = {
40
41
  /**
41
42
  * Optional base host string (e.g. "https://blaze.me" or "staging.blaze.me").
@@ -44,7 +45,13 @@ type HeaderAppSwitcherProps = {
44
45
  commonHost?: string;
45
46
  /** Which app is currently active. Defaults to "Retail". */
46
47
  currentApp?: AppName;
48
+ /** Filter apps by subdomain. When omitted, all apps are shown. */
49
+ visibleApps?: AppSubdomain[];
50
+ /** Number of grid columns. When omitted, auto-calculated from app count: 1–3 → 1 col, 4 → 2 cols, >4 → 3 cols. */
51
+ columns?: 1 | 2 | 3 | 4;
52
+ /** When true, appends ?sso=true to all app URLs to trigger SSO login on the target app. */
53
+ ssoRedirect?: boolean;
47
54
  };
48
- declare function HeaderAppSwitcher({ commonHost, currentApp, }: HeaderAppSwitcherProps): import("react/jsx-runtime").JSX.Element;
49
- export { HeaderAppSwitcher, type HeaderAppSwitcherProps, type AppName };
55
+ declare function HeaderAppSwitcher({ commonHost, currentApp, visibleApps, columns, ssoRedirect, }: HeaderAppSwitcherProps): import("react/jsx-runtime").JSX.Element;
56
+ export { HeaderAppSwitcher, type HeaderAppSwitcherProps, type AppName, type AppSubdomain };
50
57
  //# sourceMappingURL=header-app-switcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"header-app-switcher.d.ts","sourceRoot":"","sources":["../../src/components/header-app-switcher.tsx"],"names":[],"mappings":"AAqBA,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BN,CAAA;AAEV,KAAK,OAAO,GAAG,CAAC,OA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KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,CAAA"}
@@ -105,10 +105,13 @@ const resolveHostInfo = (commonHost) => {
105
105
  host: "blaze.me",
106
106
  };
107
107
  };
108
- const buildAppUrl = (subdomain, base) => {
108
+ const buildAppUrl = (subdomain, base, ssoRedirect) => {
109
109
  if (!subdomain)
110
110
  return "#";
111
- return `${base.protocol}//${subdomain}.${base.host}`;
111
+ const url = new URL(`${base.protocol}//${subdomain}.${base.host}`);
112
+ if (ssoRedirect)
113
+ url.searchParams.set("sso", "true");
114
+ return url.toString();
112
115
  };
113
116
  function AppsGridIcon() {
114
117
  return (jsxs("svg", { "aria-hidden": true, viewBox: "0 0 24 24", fill: "currentColor", className: "tw:h-5 tw:w-5", children: [jsx("circle", { cx: "5", cy: "5", r: "1.5" }), jsx("circle", { cx: "12", cy: "5", r: "1.5" }), jsx("circle", { cx: "19", cy: "5", r: "1.5" }), jsx("circle", { cx: "5", cy: "12", r: "1.5" }), jsx("circle", { cx: "12", cy: "12", r: "1.5" }), jsx("circle", { cx: "19", cy: "12", r: "1.5" }), jsx("circle", { cx: "5", cy: "19", r: "1.5" }), jsx("circle", { cx: "12", cy: "19", r: "1.5" }), jsx("circle", { cx: "19", cy: "19", r: "1.5" })] }));
@@ -122,16 +125,29 @@ const getTileClassName = (isCurrent, isDisabled) => {
122
125
  }
123
126
  return "hover:tw:bg-accent tw:cursor-pointer";
124
127
  };
125
- function HeaderAppSwitcher({ commonHost, currentApp = "Retail", }) {
128
+ const gridColsClass = {
129
+ 1: "tw:grid-cols-1",
130
+ 2: "tw:grid-cols-2",
131
+ 3: "tw:grid-cols-3",
132
+ 4: "tw:grid-cols-4",
133
+ };
134
+ function getAutoColumns(appCount) {
135
+ return Math.min(Math.ceil(Math.sqrt(appCount)), 4);
136
+ }
137
+ function HeaderAppSwitcher({ commonHost, currentApp = "Retail", visibleApps, columns, ssoRedirect, }) {
126
138
  const apps = React.useMemo(() => {
127
139
  const base = resolveHostInfo(commonHost);
128
- return AppsConfig.map((app) => ({
140
+ const filtered = visibleApps
141
+ ? AppsConfig.filter((app) => app.subdomain && visibleApps.includes(app.subdomain))
142
+ : AppsConfig;
143
+ return filtered.map((app) => ({
129
144
  ...app,
130
145
  isCurrent: currentApp === app.name,
131
- href: buildAppUrl(app.subdomain, base),
146
+ href: buildAppUrl(app.subdomain, base, ssoRedirect),
132
147
  }));
133
- }, [commonHost, currentApp]);
134
- return (jsxs(Popover, { children: [jsx(PopoverTrigger, { asChild: true, children: jsxs(Button, { variant: "ghost", size: "icon", children: [jsx(AppsGridIcon, {}), jsx("span", { className: "tw:sr-only", children: "Switch apps" })] }) }), jsxs(PopoverContent, { align: "end", sideOffset: 8, className: "tw:w-72 tw:p-4", children: [jsx("p", { className: "tw:mb-3 tw:text-sm tw:font-medium tw:text-muted-foreground", children: "Blaze Apps" }), jsx("div", { className: "tw:grid tw:grid-cols-3 tw:gap-1", children: apps.map((app) => {
148
+ }, [commonHost, currentApp, visibleApps, ssoRedirect]);
149
+ const resolvedColumns = columns ?? getAutoColumns(apps.length);
150
+ return (jsxs(Popover, { children: [jsx(PopoverTrigger, { asChild: true, children: jsxs(Button, { variant: "ghost", size: "icon", children: [jsx(AppsGridIcon, {}), jsx("span", { className: "tw:sr-only", children: "Switch apps" })] }) }), jsxs(PopoverContent, { align: "end", sideOffset: 8, className: "tw:w-72 tw:p-4", children: [jsx("p", { className: "tw:mb-3 tw:text-sm tw:font-medium tw:text-muted-foreground", children: "Blaze Apps" }), jsx("div", { className: cn("tw:grid tw:gap-1", gridColsClass[resolvedColumns]), children: apps.map((app) => {
135
151
  const isDisabled = Boolean(app.disabled);
136
152
  const isCurrent = Boolean(app.isCurrent);
137
153
  const tileClassName = getTileClassName(isCurrent, isDisabled);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getgreenline/blaze-ui",
3
- "version": "1.0.32",
3
+ "version": "1.0.33",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@base-ui/react": "^1.1.0",