@the-portland-company/shell 0.36.2 → 0.37.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/CHANGELOG.md +18 -0
- package/dist/app-chrome.cjs +134 -24
- package/dist/app-chrome.cjs.map +1 -1
- package/dist/app-chrome.d.cts +8 -1
- package/dist/app-chrome.d.ts +8 -1
- package/dist/app-chrome.js +60 -23
- package/dist/app-chrome.js.map +1 -1
- package/dist/chunk-6UHJV2FH.js +63 -0
- package/dist/chunk-6UHJV2FH.js.map +1 -0
- package/dist/{chunk-LIGKGXFT.js → chunk-CGSS2PDG.js} +20 -6
- package/dist/chunk-CGSS2PDG.js.map +1 -0
- package/dist/native.cjs +18 -3
- package/dist/native.cjs.map +1 -1
- package/dist/native.d.cts +18 -1
- package/dist/native.d.ts +18 -1
- package/dist/native.js +1 -1
- package/dist/nav-preference.cjs +75 -0
- package/dist/nav-preference.cjs.map +1 -0
- package/dist/nav-preference.d.cts +18 -0
- package/dist/nav-preference.d.ts +18 -0
- package/dist/nav-preference.js +3 -0
- package/dist/nav-preference.js.map +1 -0
- package/package.json +6 -1
- package/dist/chunk-LIGKGXFT.js.map +0 -1
package/dist/native.d.cts
CHANGED
|
@@ -18,6 +18,20 @@ type NavIconLike = ComponentType<{
|
|
|
18
18
|
declare const CORE_APP_ORIGIN = "https://app.politogyvrm.com";
|
|
19
19
|
/** Text/Email fuel top-up page (SMS Signal + Email Broadcast). */
|
|
20
20
|
declare const CORE_BILLING_PATH = "/organization-settings/subscription-billing/text-email";
|
|
21
|
+
/**
|
|
22
|
+
* Resolve an organization logo URL for rendering in ANY app.
|
|
23
|
+
*
|
|
24
|
+
* `organizations.logo_url` is authored by VRM core and stored as a ROOT-RELATIVE
|
|
25
|
+
* core route — `/api/storage/public?bucket=organization-logos&path=<org>/logo.png`
|
|
26
|
+
* (the signed-storage proxy). VRM core renders it correctly because that path
|
|
27
|
+
* resolves against its own origin; every other app resolves it against its own
|
|
28
|
+
* origin (forms.politogyvrm.com/api/storage/public), gets a 404, and shows a
|
|
29
|
+
* broken image. The chrome API passes the stored value through verbatim, so the
|
|
30
|
+
* resolution belongs here — one definition for every app, core included.
|
|
31
|
+
*
|
|
32
|
+
* Absolute URLs (http/https/data/blob) pass through untouched.
|
|
33
|
+
*/
|
|
34
|
+
declare function resolveOrgLogoUrl(url: string | null | undefined): string | undefined;
|
|
21
35
|
declare function topBarIconButtonClass(tone?: 'default' | 'warning' | 'danger'): string;
|
|
22
36
|
/** The shared count badge — one definition, used by every slot. */
|
|
23
37
|
declare function TopBarCountBadge({ count }: {
|
|
@@ -67,6 +81,9 @@ type ChromeMe = {
|
|
|
67
81
|
userName: string | null;
|
|
68
82
|
avatarUrl: string | null;
|
|
69
83
|
themePreference: string | null;
|
|
84
|
+
/** Universal navigation-display choice ('menu'|'tabs'|'both'); null when
|
|
85
|
+
* unset or when the profile column is absent in this environment. */
|
|
86
|
+
navDisplay: string | null;
|
|
70
87
|
account?: string | null;
|
|
71
88
|
accountName?: string | null;
|
|
72
89
|
role?: string | null;
|
|
@@ -609,4 +626,4 @@ type NavAppShellProps = {
|
|
|
609
626
|
};
|
|
610
627
|
declare function NavAppShell({ sidebar, topBar, betaBanner, contentWrapper, children, }: NavAppShellProps): react_jsx_runtime.JSX.Element;
|
|
611
628
|
|
|
612
|
-
export { CAMPAIGN_FEATURE_AVAILABILITY, CORE_APP_ORIGIN, CORE_BILLING_PATH, type CampaignFeatureAvailability, type ChromeMe, type ChromeNotificationAlert, type ChromeNotificationImport, type ChromeNotificationQuarantine, type ChromeNotificationReply, type ChromeNotificationsPayload, type ChromeOrgSummary, type CommunicationsFuelStatus, FuelAction, type FuelChannelStatus, NavAppShell, type NavAppShellProps, NavBetaBanner, type NavBetaBannerProps, type NavBrand, type NavBreadcrumb, type NavChromeFetcher, NavChromeProvider, NavDisplayAction, type NavDisplayMode, type NavFooter, type NavFooterLink, type NavIcon, type NavItem, type NavLinkComponent, type NavLinkProps, type NavLinkedAccount, type NavMode, type NavModeOption, type NavOrg, type NavOrgOption, type NavRoleBadge, NavSidebar, type NavSidebarProps, type NavTab, NavTabStrip, type NavTabStripProps, NavThemeControl, NavTopBar, type NavTopBarAction, type NavTopBarProps, type NavUser, type NavUserMenu, NotificationsAction, type StandardNavIconKey, type StandardNavMode, type StandardNavOptions, SupportAction, type ThemePreference, TopBarCountBadge, TopBarPanelArrow, TopBarPopover, TopBarTooltip, TopBarWidgetSlot, envChipClasses, isNavItemActive, standardPolitogyNav, topBarIconButtonClass, useChromeMe, useChromeOrgs, useNavChromeFetcher, useThemePreference };
|
|
629
|
+
export { CAMPAIGN_FEATURE_AVAILABILITY, CORE_APP_ORIGIN, CORE_BILLING_PATH, type CampaignFeatureAvailability, type ChromeMe, type ChromeNotificationAlert, type ChromeNotificationImport, type ChromeNotificationQuarantine, type ChromeNotificationReply, type ChromeNotificationsPayload, type ChromeOrgSummary, type CommunicationsFuelStatus, FuelAction, type FuelChannelStatus, NavAppShell, type NavAppShellProps, NavBetaBanner, type NavBetaBannerProps, type NavBrand, type NavBreadcrumb, type NavChromeFetcher, NavChromeProvider, NavDisplayAction, type NavDisplayMode, type NavFooter, type NavFooterLink, type NavIcon, type NavItem, type NavLinkComponent, type NavLinkProps, type NavLinkedAccount, type NavMode, type NavModeOption, type NavOrg, type NavOrgOption, type NavRoleBadge, NavSidebar, type NavSidebarProps, type NavTab, NavTabStrip, type NavTabStripProps, NavThemeControl, NavTopBar, type NavTopBarAction, type NavTopBarProps, type NavUser, type NavUserMenu, NotificationsAction, type StandardNavIconKey, type StandardNavMode, type StandardNavOptions, SupportAction, type ThemePreference, TopBarCountBadge, TopBarPanelArrow, TopBarPopover, TopBarTooltip, TopBarWidgetSlot, envChipClasses, isNavItemActive, resolveOrgLogoUrl, standardPolitogyNav, topBarIconButtonClass, useChromeMe, useChromeOrgs, useNavChromeFetcher, useThemePreference };
|
package/dist/native.d.ts
CHANGED
|
@@ -18,6 +18,20 @@ type NavIconLike = ComponentType<{
|
|
|
18
18
|
declare const CORE_APP_ORIGIN = "https://app.politogyvrm.com";
|
|
19
19
|
/** Text/Email fuel top-up page (SMS Signal + Email Broadcast). */
|
|
20
20
|
declare const CORE_BILLING_PATH = "/organization-settings/subscription-billing/text-email";
|
|
21
|
+
/**
|
|
22
|
+
* Resolve an organization logo URL for rendering in ANY app.
|
|
23
|
+
*
|
|
24
|
+
* `organizations.logo_url` is authored by VRM core and stored as a ROOT-RELATIVE
|
|
25
|
+
* core route — `/api/storage/public?bucket=organization-logos&path=<org>/logo.png`
|
|
26
|
+
* (the signed-storage proxy). VRM core renders it correctly because that path
|
|
27
|
+
* resolves against its own origin; every other app resolves it against its own
|
|
28
|
+
* origin (forms.politogyvrm.com/api/storage/public), gets a 404, and shows a
|
|
29
|
+
* broken image. The chrome API passes the stored value through verbatim, so the
|
|
30
|
+
* resolution belongs here — one definition for every app, core included.
|
|
31
|
+
*
|
|
32
|
+
* Absolute URLs (http/https/data/blob) pass through untouched.
|
|
33
|
+
*/
|
|
34
|
+
declare function resolveOrgLogoUrl(url: string | null | undefined): string | undefined;
|
|
21
35
|
declare function topBarIconButtonClass(tone?: 'default' | 'warning' | 'danger'): string;
|
|
22
36
|
/** The shared count badge — one definition, used by every slot. */
|
|
23
37
|
declare function TopBarCountBadge({ count }: {
|
|
@@ -67,6 +81,9 @@ type ChromeMe = {
|
|
|
67
81
|
userName: string | null;
|
|
68
82
|
avatarUrl: string | null;
|
|
69
83
|
themePreference: string | null;
|
|
84
|
+
/** Universal navigation-display choice ('menu'|'tabs'|'both'); null when
|
|
85
|
+
* unset or when the profile column is absent in this environment. */
|
|
86
|
+
navDisplay: string | null;
|
|
70
87
|
account?: string | null;
|
|
71
88
|
accountName?: string | null;
|
|
72
89
|
role?: string | null;
|
|
@@ -609,4 +626,4 @@ type NavAppShellProps = {
|
|
|
609
626
|
};
|
|
610
627
|
declare function NavAppShell({ sidebar, topBar, betaBanner, contentWrapper, children, }: NavAppShellProps): react_jsx_runtime.JSX.Element;
|
|
611
628
|
|
|
612
|
-
export { CAMPAIGN_FEATURE_AVAILABILITY, CORE_APP_ORIGIN, CORE_BILLING_PATH, type CampaignFeatureAvailability, type ChromeMe, type ChromeNotificationAlert, type ChromeNotificationImport, type ChromeNotificationQuarantine, type ChromeNotificationReply, type ChromeNotificationsPayload, type ChromeOrgSummary, type CommunicationsFuelStatus, FuelAction, type FuelChannelStatus, NavAppShell, type NavAppShellProps, NavBetaBanner, type NavBetaBannerProps, type NavBrand, type NavBreadcrumb, type NavChromeFetcher, NavChromeProvider, NavDisplayAction, type NavDisplayMode, type NavFooter, type NavFooterLink, type NavIcon, type NavItem, type NavLinkComponent, type NavLinkProps, type NavLinkedAccount, type NavMode, type NavModeOption, type NavOrg, type NavOrgOption, type NavRoleBadge, NavSidebar, type NavSidebarProps, type NavTab, NavTabStrip, type NavTabStripProps, NavThemeControl, NavTopBar, type NavTopBarAction, type NavTopBarProps, type NavUser, type NavUserMenu, NotificationsAction, type StandardNavIconKey, type StandardNavMode, type StandardNavOptions, SupportAction, type ThemePreference, TopBarCountBadge, TopBarPanelArrow, TopBarPopover, TopBarTooltip, TopBarWidgetSlot, envChipClasses, isNavItemActive, standardPolitogyNav, topBarIconButtonClass, useChromeMe, useChromeOrgs, useNavChromeFetcher, useThemePreference };
|
|
629
|
+
export { CAMPAIGN_FEATURE_AVAILABILITY, CORE_APP_ORIGIN, CORE_BILLING_PATH, type CampaignFeatureAvailability, type ChromeMe, type ChromeNotificationAlert, type ChromeNotificationImport, type ChromeNotificationQuarantine, type ChromeNotificationReply, type ChromeNotificationsPayload, type ChromeOrgSummary, type CommunicationsFuelStatus, FuelAction, type FuelChannelStatus, NavAppShell, type NavAppShellProps, NavBetaBanner, type NavBetaBannerProps, type NavBrand, type NavBreadcrumb, type NavChromeFetcher, NavChromeProvider, NavDisplayAction, type NavDisplayMode, type NavFooter, type NavFooterLink, type NavIcon, type NavItem, type NavLinkComponent, type NavLinkProps, type NavLinkedAccount, type NavMode, type NavModeOption, type NavOrg, type NavOrgOption, type NavRoleBadge, NavSidebar, type NavSidebarProps, type NavTab, NavTabStrip, type NavTabStripProps, NavThemeControl, NavTopBar, type NavTopBarAction, type NavTopBarProps, type NavUser, type NavUserMenu, NotificationsAction, type StandardNavIconKey, type StandardNavMode, type StandardNavOptions, SupportAction, type ThemePreference, TopBarCountBadge, TopBarPanelArrow, TopBarPopover, TopBarTooltip, TopBarWidgetSlot, envChipClasses, isNavItemActive, resolveOrgLogoUrl, standardPolitogyNav, topBarIconButtonClass, useChromeMe, useChromeOrgs, useNavChromeFetcher, useThemePreference };
|
package/dist/native.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { CAMPAIGN_FEATURE_AVAILABILITY, CORE_APP_ORIGIN, CORE_BILLING_PATH, FuelAction, NavAppShell, NavBetaBanner, NavChromeProvider, NavDisplayAction, NavSidebar, NavTabStrip, NavThemeControl, NavTopBar, NotificationsAction, SupportAction, TopBarCountBadge, TopBarPanelArrow, TopBarPopover, TopBarTooltip, TopBarWidgetSlot, envChipClasses, isNavItemActive, standardPolitogyNav, topBarIconButtonClass, useChromeMe, useChromeOrgs, useNavChromeFetcher, useThemePreference } from './chunk-
|
|
2
|
+
export { CAMPAIGN_FEATURE_AVAILABILITY, CORE_APP_ORIGIN, CORE_BILLING_PATH, FuelAction, NavAppShell, NavBetaBanner, NavChromeProvider, NavDisplayAction, NavSidebar, NavTabStrip, NavThemeControl, NavTopBar, NotificationsAction, SupportAction, TopBarCountBadge, TopBarPanelArrow, TopBarPopover, TopBarTooltip, TopBarWidgetSlot, envChipClasses, isNavItemActive, resolveOrgLogoUrl, standardPolitogyNav, topBarIconButtonClass, useChromeMe, useChromeOrgs, useNavChromeFetcher, useThemePreference } from './chunk-CGSS2PDG.js';
|
|
3
3
|
import './chunk-LL7RCJQN.js';
|
|
4
4
|
//# sourceMappingURL=native.js.map
|
|
5
5
|
//# sourceMappingURL=native.js.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/nav-preference.ts
|
|
4
|
+
var NAV_DISPLAY_STORAGE_KEY = "politogy_nav_display";
|
|
5
|
+
var NAV_DISPLAY_COOKIE = "politogy_nav_display";
|
|
6
|
+
var LEGACY_NAV_DISPLAY_KEY = "vrm.navDisplay";
|
|
7
|
+
var NAV_DISPLAY_DEFAULT = "both";
|
|
8
|
+
var VALID = ["menu", "tabs", "both"];
|
|
9
|
+
function isNavDisplayPreference(v) {
|
|
10
|
+
return typeof v === "string" && VALID.includes(v);
|
|
11
|
+
}
|
|
12
|
+
function readNavDisplayCookie() {
|
|
13
|
+
if (typeof document === "undefined") return null;
|
|
14
|
+
try {
|
|
15
|
+
const m = document.cookie.match(
|
|
16
|
+
new RegExp(`(?:^|;\\s*)${NAV_DISPLAY_COOKIE}=([^;]+)`)
|
|
17
|
+
);
|
|
18
|
+
const v = m ? decodeURIComponent(m[1]) : null;
|
|
19
|
+
return isNavDisplayPreference(v) ? v : null;
|
|
20
|
+
} catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function writeNavDisplayCookie(pref) {
|
|
25
|
+
if (typeof document === "undefined" || typeof window === "undefined") return;
|
|
26
|
+
const host = window.location.hostname;
|
|
27
|
+
const domainAttr = /(^|\.)politogyvrm\.com$/i.test(host) ? "; Domain=.politogyvrm.com" : "";
|
|
28
|
+
const secure = window.location.protocol === "https:" ? "; Secure" : "";
|
|
29
|
+
document.cookie = `${NAV_DISPLAY_COOKIE}=${encodeURIComponent(
|
|
30
|
+
pref
|
|
31
|
+
)}; Path=/; Max-Age=31536000; SameSite=Lax${domainAttr}${secure}`;
|
|
32
|
+
}
|
|
33
|
+
function readNavDisplayLocal() {
|
|
34
|
+
if (typeof localStorage === "undefined") return null;
|
|
35
|
+
try {
|
|
36
|
+
const current = localStorage.getItem(NAV_DISPLAY_STORAGE_KEY);
|
|
37
|
+
if (isNavDisplayPreference(current)) return current;
|
|
38
|
+
const legacy = localStorage.getItem(LEGACY_NAV_DISPLAY_KEY);
|
|
39
|
+
return isNavDisplayPreference(legacy) ? legacy : null;
|
|
40
|
+
} catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function writeNavDisplayLocal(pref) {
|
|
45
|
+
if (typeof localStorage === "undefined") return;
|
|
46
|
+
try {
|
|
47
|
+
localStorage.setItem(NAV_DISPLAY_STORAGE_KEY, pref);
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function resolveNavDisplay() {
|
|
52
|
+
return readNavDisplayCookie() ?? readNavDisplayLocal() ?? NAV_DISPLAY_DEFAULT;
|
|
53
|
+
}
|
|
54
|
+
var NAV_DISPLAY_PREPAINT_SCRIPT = `(function(){try{
|
|
55
|
+
var KEY=${JSON.stringify(NAV_DISPLAY_STORAGE_KEY)};
|
|
56
|
+
var VALID=["menu","tabs","both"];
|
|
57
|
+
function fromCookie(){try{var m=document.cookie.match(/(?:^|;\\s*)${NAV_DISPLAY_COOKIE}=([^;]+)/);return m?decodeURIComponent(m[1]):null;}catch(e){return null;}}
|
|
58
|
+
var cookie=fromCookie();
|
|
59
|
+
if(cookie&&VALID.indexOf(cookie)!==-1){var ls=null;try{ls=localStorage.getItem(KEY);}catch(e){}
|
|
60
|
+
if(cookie!==ls){try{localStorage.setItem(KEY,cookie);}catch(e){}}}
|
|
61
|
+
}catch(e){}})();`;
|
|
62
|
+
|
|
63
|
+
exports.LEGACY_NAV_DISPLAY_KEY = LEGACY_NAV_DISPLAY_KEY;
|
|
64
|
+
exports.NAV_DISPLAY_COOKIE = NAV_DISPLAY_COOKIE;
|
|
65
|
+
exports.NAV_DISPLAY_DEFAULT = NAV_DISPLAY_DEFAULT;
|
|
66
|
+
exports.NAV_DISPLAY_PREPAINT_SCRIPT = NAV_DISPLAY_PREPAINT_SCRIPT;
|
|
67
|
+
exports.NAV_DISPLAY_STORAGE_KEY = NAV_DISPLAY_STORAGE_KEY;
|
|
68
|
+
exports.isNavDisplayPreference = isNavDisplayPreference;
|
|
69
|
+
exports.readNavDisplayCookie = readNavDisplayCookie;
|
|
70
|
+
exports.readNavDisplayLocal = readNavDisplayLocal;
|
|
71
|
+
exports.resolveNavDisplay = resolveNavDisplay;
|
|
72
|
+
exports.writeNavDisplayCookie = writeNavDisplayCookie;
|
|
73
|
+
exports.writeNavDisplayLocal = writeNavDisplayLocal;
|
|
74
|
+
//# sourceMappingURL=nav-preference.cjs.map
|
|
75
|
+
//# sourceMappingURL=nav-preference.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/nav-preference.ts"],"names":[],"mappings":";;;AAwBO,IAAM,uBAAA,GAA0B;AAChC,IAAM,kBAAA,GAAqB;AAG3B,IAAM,sBAAA,GAAyB;AAE/B,IAAM,mBAAA,GAA4C;AAEzD,IAAM,KAAA,GAAyC,CAAC,MAAA,EAAQ,MAAA,EAAQ,MAAM,CAAA;AAE/D,SAAS,uBAAuB,CAAA,EAAuC;AAC5E,EAAA,OAAO,OAAO,CAAA,KAAM,QAAA,IAAa,KAAA,CAA4B,SAAS,CAAC,CAAA;AACzE;AAGO,SAAS,oBAAA,GAAoD;AAClE,EAAA,IAAI,OAAO,QAAA,KAAa,WAAA,EAAa,OAAO,IAAA;AAC5C,EAAA,IAAI;AACF,IAAA,MAAM,CAAA,GAAI,SAAS,MAAA,CAAO,KAAA;AAAA,MACxB,IAAI,MAAA,CAAO,CAAA,WAAA,EAAc,kBAAkB,CAAA,QAAA,CAAU;AAAA,KACvD;AACA,IAAA,MAAM,IAAI,CAAA,GAAI,kBAAA,CAAmB,CAAA,CAAE,CAAC,CAAC,CAAA,GAAI,IAAA;AACzC,IAAA,OAAO,sBAAA,CAAuB,CAAC,CAAA,GAAI,CAAA,GAAI,IAAA;AAAA,EACzC,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAMO,SAAS,sBAAsB,IAAA,EAAkC;AACtE,EAAA,IAAI,OAAO,QAAA,KAAa,WAAA,IAAe,OAAO,WAAW,WAAA,EAAa;AACtE,EAAA,MAAM,IAAA,GAAO,OAAO,QAAA,CAAS,QAAA;AAC7B,EAAA,MAAM,UAAA,GAAa,0BAAA,CAA2B,IAAA,CAAK,IAAI,IAAI,2BAAA,GAA8B,EAAA;AACzF,EAAA,MAAM,MAAA,GAAS,MAAA,CAAO,QAAA,CAAS,QAAA,KAAa,WAAW,UAAA,GAAa,EAAA;AACpE,EAAA,QAAA,CAAS,MAAA,GAAS,CAAA,EAAG,kBAAkB,CAAA,CAAA,EAAI,kBAAA;AAAA,IACzC;AAAA,GACD,CAAA,wCAAA,EAA2C,UAAU,CAAA,EAAG,MAAM,CAAA,CAAA;AACjE;AAGO,SAAS,mBAAA,GAAmD;AACjE,EAAA,IAAI,OAAO,YAAA,KAAiB,WAAA,EAAa,OAAO,IAAA;AAChD,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,YAAA,CAAa,OAAA,CAAQ,uBAAuB,CAAA;AAC5D,IAAA,IAAI,sBAAA,CAAuB,OAAO,CAAA,EAAG,OAAO,OAAA;AAC5C,IAAA,MAAM,MAAA,GAAS,YAAA,CAAa,OAAA,CAAQ,sBAAsB,CAAA;AAC1D,IAAA,OAAO,sBAAA,CAAuB,MAAM,CAAA,GAAI,MAAA,GAAS,IAAA;AAAA,EACnD,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEO,SAAS,qBAAqB,IAAA,EAAkC;AACrE,EAAA,IAAI,OAAO,iBAAiB,WAAA,EAAa;AACzC,EAAA,IAAI;AACF,IAAA,YAAA,CAAa,OAAA,CAAQ,yBAAyB,IAAI,CAAA;AAAA,EACpD,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;AAGO,SAAS,iBAAA,GAA0C;AACxD,EAAA,OAAO,oBAAA,EAAqB,IAAK,mBAAA,EAAoB,IAAK,mBAAA;AAC5D;AAMO,IAAM,2BAAA,GAA8B,CAAA;AAAA,QAAA,EACjC,IAAA,CAAK,SAAA,CAAU,uBAAuB,CAAC,CAAA;AAAA;AAAA,kEAAA,EAEmB,kBAAkB,CAAA;AAAA;AAAA;AAAA;AAAA,gBAAA","file":"nav-preference.cjs","sourcesContent":["// Universal navigation-display preference — the same cross-app contract as the\n// theme (see ./theme-preference, which this deliberately mirrors).\n//\n// The user's choice of how navigation renders (Menu / Tabs / Both) follows the\n// authenticated user across every Politogy app + subdomain. Three layers:\n// 1. VRM Core `profiles.nav_display_preference` — source of truth, persisted\n// via the chrome API (`PATCH me/preferences { navDisplay }`) and read back\n// from `GET me` (`navDisplay`).\n// 2. `.politogyvrm.com` cookie `politogy_nav_display` — the cross-subdomain\n// vehicle (app session cookies are host-only, and so is localStorage).\n// 3. localStorage — same-app fast reads and cross-tab `storage` events.\n//\n// Before this existed the preference lived ONLY in localStorage under\n// `vrm.navDisplay`, which is per-ORIGIN: every app subdomain kept its own copy\n// and a freshly opened app booted the default, so the setting appeared not to\n// hold when moving between apps. The legacy key is still read as a fallback so\n// an existing local choice survives the upgrade.\n//\n// Server-safe (no 'use client'): layouts may import NAV_DISPLAY_PREPAINT_SCRIPT.\n\nexport type NavDisplayPreference = 'menu' | 'tabs' | 'both'\n\n// One key for BOTH the localStorage store and the cross-subdomain cookie, so a\n// choice in one app is the same key in the next.\nexport const NAV_DISPLAY_STORAGE_KEY = 'politogy_nav_display'\nexport const NAV_DISPLAY_COOKIE = 'politogy_nav_display'\n\n/** Pre-0.37 host-only key. Read for migration; never written. */\nexport const LEGACY_NAV_DISPLAY_KEY = 'vrm.navDisplay'\n\nexport const NAV_DISPLAY_DEFAULT: NavDisplayPreference = 'both'\n\nconst VALID: readonly NavDisplayPreference[] = ['menu', 'tabs', 'both']\n\nexport function isNavDisplayPreference(v: unknown): v is NavDisplayPreference {\n return typeof v === 'string' && (VALID as readonly string[]).includes(v)\n}\n\n/** Read the shared cookie (browser only; null on the server or when unset). */\nexport function readNavDisplayCookie(): NavDisplayPreference | null {\n if (typeof document === 'undefined') return null\n try {\n const m = document.cookie.match(\n new RegExp(`(?:^|;\\\\s*)${NAV_DISPLAY_COOKIE}=([^;]+)`),\n )\n const v = m ? decodeURIComponent(m[1]) : null\n return isNavDisplayPreference(v) ? v : null\n } catch {\n return null\n }\n}\n\n// Same host-aware scoping as the theme cookie: parent domain on\n// *.politogyvrm.com so every app subdomain reads it, host-only elsewhere\n// (localhost, *.pages.dev preview) because browsers silently drop a mismatched\n// Domain attribute. 1-year, SameSite=Lax, Secure on https.\nexport function writeNavDisplayCookie(pref: NavDisplayPreference): void {\n if (typeof document === 'undefined' || typeof window === 'undefined') return\n const host = window.location.hostname\n const domainAttr = /(^|\\.)politogyvrm\\.com$/i.test(host) ? '; Domain=.politogyvrm.com' : ''\n const secure = window.location.protocol === 'https:' ? '; Secure' : ''\n document.cookie = `${NAV_DISPLAY_COOKIE}=${encodeURIComponent(\n pref,\n )}; Path=/; Max-Age=31536000; SameSite=Lax${domainAttr}${secure}`\n}\n\n/** Read the local store, falling back to the legacy host-only key. */\nexport function readNavDisplayLocal(): NavDisplayPreference | null {\n if (typeof localStorage === 'undefined') return null\n try {\n const current = localStorage.getItem(NAV_DISPLAY_STORAGE_KEY)\n if (isNavDisplayPreference(current)) return current\n const legacy = localStorage.getItem(LEGACY_NAV_DISPLAY_KEY)\n return isNavDisplayPreference(legacy) ? legacy : null\n } catch {\n return null\n }\n}\n\nexport function writeNavDisplayLocal(pref: NavDisplayPreference): void {\n if (typeof localStorage === 'undefined') return\n try {\n localStorage.setItem(NAV_DISPLAY_STORAGE_KEY, pref)\n } catch {\n /* storage unavailable */\n }\n}\n\n/** Boot precedence: cookie → localStorage (incl. legacy) → default. */\nexport function resolveNavDisplay(): NavDisplayPreference {\n return readNavDisplayCookie() ?? readNavDisplayLocal() ?? NAV_DISPLAY_DEFAULT\n}\n\n// Inline pre-paint script — optional, and the mirror of THEME_PREPAINT_SCRIPT.\n// Nav display has no paint-blocking visual (the frame is client-rendered), but\n// seeding localStorage from the cookie before hydration keeps the first render\n// on the synced value instead of the default. Self-contained and silent.\nexport const NAV_DISPLAY_PREPAINT_SCRIPT = `(function(){try{\nvar KEY=${JSON.stringify(NAV_DISPLAY_STORAGE_KEY)};\nvar VALID=[\"menu\",\"tabs\",\"both\"];\nfunction fromCookie(){try{var m=document.cookie.match(/(?:^|;\\\\s*)${NAV_DISPLAY_COOKIE}=([^;]+)/);return m?decodeURIComponent(m[1]):null;}catch(e){return null;}}\nvar cookie=fromCookie();\nif(cookie&&VALID.indexOf(cookie)!==-1){var ls=null;try{ls=localStorage.getItem(KEY);}catch(e){}\nif(cookie!==ls){try{localStorage.setItem(KEY,cookie);}catch(e){}}}\n}catch(e){}})();`\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type NavDisplayPreference = 'menu' | 'tabs' | 'both';
|
|
2
|
+
declare const NAV_DISPLAY_STORAGE_KEY = "politogy_nav_display";
|
|
3
|
+
declare const NAV_DISPLAY_COOKIE = "politogy_nav_display";
|
|
4
|
+
/** Pre-0.37 host-only key. Read for migration; never written. */
|
|
5
|
+
declare const LEGACY_NAV_DISPLAY_KEY = "vrm.navDisplay";
|
|
6
|
+
declare const NAV_DISPLAY_DEFAULT: NavDisplayPreference;
|
|
7
|
+
declare function isNavDisplayPreference(v: unknown): v is NavDisplayPreference;
|
|
8
|
+
/** Read the shared cookie (browser only; null on the server or when unset). */
|
|
9
|
+
declare function readNavDisplayCookie(): NavDisplayPreference | null;
|
|
10
|
+
declare function writeNavDisplayCookie(pref: NavDisplayPreference): void;
|
|
11
|
+
/** Read the local store, falling back to the legacy host-only key. */
|
|
12
|
+
declare function readNavDisplayLocal(): NavDisplayPreference | null;
|
|
13
|
+
declare function writeNavDisplayLocal(pref: NavDisplayPreference): void;
|
|
14
|
+
/** Boot precedence: cookie → localStorage (incl. legacy) → default. */
|
|
15
|
+
declare function resolveNavDisplay(): NavDisplayPreference;
|
|
16
|
+
declare const NAV_DISPLAY_PREPAINT_SCRIPT: string;
|
|
17
|
+
|
|
18
|
+
export { LEGACY_NAV_DISPLAY_KEY, NAV_DISPLAY_COOKIE, NAV_DISPLAY_DEFAULT, NAV_DISPLAY_PREPAINT_SCRIPT, NAV_DISPLAY_STORAGE_KEY, type NavDisplayPreference, isNavDisplayPreference, readNavDisplayCookie, readNavDisplayLocal, resolveNavDisplay, writeNavDisplayCookie, writeNavDisplayLocal };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type NavDisplayPreference = 'menu' | 'tabs' | 'both';
|
|
2
|
+
declare const NAV_DISPLAY_STORAGE_KEY = "politogy_nav_display";
|
|
3
|
+
declare const NAV_DISPLAY_COOKIE = "politogy_nav_display";
|
|
4
|
+
/** Pre-0.37 host-only key. Read for migration; never written. */
|
|
5
|
+
declare const LEGACY_NAV_DISPLAY_KEY = "vrm.navDisplay";
|
|
6
|
+
declare const NAV_DISPLAY_DEFAULT: NavDisplayPreference;
|
|
7
|
+
declare function isNavDisplayPreference(v: unknown): v is NavDisplayPreference;
|
|
8
|
+
/** Read the shared cookie (browser only; null on the server or when unset). */
|
|
9
|
+
declare function readNavDisplayCookie(): NavDisplayPreference | null;
|
|
10
|
+
declare function writeNavDisplayCookie(pref: NavDisplayPreference): void;
|
|
11
|
+
/** Read the local store, falling back to the legacy host-only key. */
|
|
12
|
+
declare function readNavDisplayLocal(): NavDisplayPreference | null;
|
|
13
|
+
declare function writeNavDisplayLocal(pref: NavDisplayPreference): void;
|
|
14
|
+
/** Boot precedence: cookie → localStorage (incl. legacy) → default. */
|
|
15
|
+
declare function resolveNavDisplay(): NavDisplayPreference;
|
|
16
|
+
declare const NAV_DISPLAY_PREPAINT_SCRIPT: string;
|
|
17
|
+
|
|
18
|
+
export { LEGACY_NAV_DISPLAY_KEY, NAV_DISPLAY_COOKIE, NAV_DISPLAY_DEFAULT, NAV_DISPLAY_PREPAINT_SCRIPT, NAV_DISPLAY_STORAGE_KEY, type NavDisplayPreference, isNavDisplayPreference, readNavDisplayCookie, readNavDisplayLocal, resolveNavDisplay, writeNavDisplayCookie, writeNavDisplayLocal };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { LEGACY_NAV_DISPLAY_KEY, NAV_DISPLAY_COOKIE, NAV_DISPLAY_DEFAULT, NAV_DISPLAY_PREPAINT_SCRIPT, NAV_DISPLAY_STORAGE_KEY, isNavDisplayPreference, readNavDisplayCookie, readNavDisplayLocal, resolveNavDisplay, writeNavDisplayCookie, writeNavDisplayLocal } from './chunk-6UHJV2FH.js';
|
|
2
|
+
//# sourceMappingURL=nav-preference.js.map
|
|
3
|
+
//# sourceMappingURL=nav-preference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"nav-preference.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@the-portland-company/shell",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "Shared chrome (header, sidebar, footer, theme, auth) for politogy apps. Drop into any Vite SPA to inherit the politogy look and signed-in user.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
"import": "./dist/theme-preference.js",
|
|
37
37
|
"require": "./dist/theme-preference.cjs"
|
|
38
38
|
},
|
|
39
|
+
"./nav-preference": {
|
|
40
|
+
"types": "./dist/nav-preference.d.ts",
|
|
41
|
+
"import": "./dist/nav-preference.js",
|
|
42
|
+
"require": "./dist/nav-preference.cjs"
|
|
43
|
+
},
|
|
39
44
|
"./active-org": {
|
|
40
45
|
"types": "./dist/active-org.d.ts",
|
|
41
46
|
"import": "./dist/active-org.js",
|