@the-portland-company/shell 0.1.0 → 0.2.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.d.cts CHANGED
@@ -122,6 +122,16 @@ interface ShellProviderProps {
122
122
  appRegistry?: AppRegistryEntry[];
123
123
  /** Optional override for the base path if the app is mounted under a sub-path (e.g., '/contacts'). */
124
124
  basename?: string;
125
+ /** If provided, shell renders <OrgSelector /> in the header. */
126
+ organization?: ShellOrganizationValue;
127
+ /** If provided, UserMenu shows account switcher + add-account button. */
128
+ linkedAccounts?: ShellLinkedAccountsValue;
129
+ /** If provided, shell renders <SupportRequestButton /> in the header. */
130
+ support?: ShellSupportValue;
131
+ /** Optional element rendered in the header (typically <DevNotesMenu /> from @the-portland-company/devnotes). */
132
+ devNotesMenu?: ReactNode;
133
+ /** href used by the UserMenu "My Profile" link. Defaults to '/my-profile'. */
134
+ myProfileHref?: string;
125
135
  }
126
136
  /** Return value of useShellAuth(). */
127
137
  interface ShellAuthValue {
@@ -130,14 +140,101 @@ interface ShellAuthValue {
130
140
  session: Session | null;
131
141
  signOut: () => Promise<void>;
132
142
  }
143
+ /**
144
+ * Organization that the current user belongs to. Apps supply this via
145
+ * ShellProvider so the shell can render <OrgSelector /> in the header.
146
+ */
147
+ interface ShellOrganization {
148
+ id: string;
149
+ name: string;
150
+ logoUrl?: string | null;
151
+ /** Brand color as a hex string (e.g., '#0066cc'). Used for the org badge fallback. */
152
+ brandColor?: string | null;
153
+ }
154
+ interface ShellOrganizationValue {
155
+ currentOrg: ShellOrganization | null;
156
+ /** All orgs the user belongs to. */
157
+ organizations: ShellOrganization[];
158
+ /** Switch to the org with the given id. App owns the side effects. */
159
+ switchOrganization: (orgId: string) => Promise<void> | void;
160
+ /** Optional link rendered at the bottom of the org menu, e.g., '/organizations/new'. */
161
+ createOrgHref?: string;
162
+ }
163
+ /**
164
+ * An alternate user account the current user can switch into without signing
165
+ * out. App supplies the data + handlers; shell renders the UI inside UserMenu.
166
+ */
167
+ interface ShellLinkedAccount {
168
+ id: string;
169
+ email: string;
170
+ displayName?: string | null;
171
+ avatarUrl?: string | null;
172
+ }
173
+ interface ShellLinkedAccountsValue {
174
+ linkedAccounts: ShellLinkedAccount[];
175
+ switchToAccount: (accountId: string) => Promise<void> | void;
176
+ /** Called when the user clicks "Add account" in UserMenu. App opens its own modal. */
177
+ onAddAccount: () => void;
178
+ /** Called when the user wants to remove a linked account. App opens its own confirm. */
179
+ onRemoveAccount: (accountId: string) => void;
180
+ }
181
+ /** Context emitted to the host's submitSupportRequest handler. */
182
+ interface ShellSupportContext {
183
+ pathname: string;
184
+ search: string;
185
+ pageTitle?: string;
186
+ organizationName?: string;
187
+ }
188
+ interface ShellSupportValue {
189
+ /**
190
+ * Submit a support request. Host app handles persistence/email/etc.
191
+ * Shell renders the modal and calls this on submit.
192
+ */
193
+ submitSupportRequest: (input: {
194
+ email: string;
195
+ phone: string;
196
+ message: string;
197
+ context: ShellSupportContext;
198
+ }) => Promise<void>;
199
+ }
133
200
 
134
- declare function ShellProvider({ children, supabaseClient, currentApp, appRegistry, basename, }: ShellProviderProps): react_jsx_runtime.JSX.Element;
201
+ declare function ShellProvider({ children, supabaseClient, currentApp, appRegistry, basename, organization, linkedAccounts, support, devNotesMenu, myProfileHref, }: ShellProviderProps): react_jsx_runtime.JSX.Element;
135
202
 
136
203
  declare function useShellAuth(): ShellAuthValue;
137
204
 
138
205
  declare function useAppRegistry(): AppRegistryEntry[];
139
206
  declare function useCurrentApp(): string;
140
207
 
208
+ /**
209
+ * Returns the organization value supplied to ShellProvider, or null if the
210
+ * host app didn't pass an `organization` prop. Returning null lets chrome
211
+ * components (e.g., <OrgSelector />) render nothing instead of erroring.
212
+ */
213
+ declare function useShellOrganization(): ShellOrganizationValue | null;
214
+
215
+ /**
216
+ * Returns the linked-accounts value supplied to ShellProvider, or null if not
217
+ * provided. UserMenu uses this to decide whether to render the
218
+ * "switch account" section.
219
+ */
220
+ declare function useShellLinkedAccounts(): ShellLinkedAccountsValue | null;
221
+
222
+ /**
223
+ * Returns the support handler supplied to ShellProvider, or null if not
224
+ * provided. SupportRequestButton uses this to decide whether to render.
225
+ */
226
+ declare function useShellSupport(): ShellSupportValue | null;
227
+
228
+ interface ShellChromeValue {
229
+ devNotesMenu: ReactNode | null;
230
+ myProfileHref: string;
231
+ }
232
+ /**
233
+ * Returns chrome-level options supplied to ShellProvider (devNotesMenu slot,
234
+ * myProfileHref). Throws if used outside <ShellProvider>.
235
+ */
236
+ declare function useShellChrome(): ShellChromeValue;
237
+
141
238
  interface AppLayoutProps extends ShellSlots {
142
239
  children: ReactNode;
143
240
  buildInfo?: string;
@@ -161,6 +258,26 @@ interface FooterProps {
161
258
  }
162
259
  declare function Footer({ buildInfo }: FooterProps): react_jsx_runtime.JSX.Element;
163
260
 
261
+ /**
262
+ * Avatar dropdown rendered at the right side of the header. Reads auth,
263
+ * linked-accounts, and chrome context from ShellProvider.
264
+ */
265
+ declare function UserMenu(): react_jsx_runtime.JSX.Element | null;
266
+
267
+ /**
268
+ * Organization switcher rendered in the header. Reads from
269
+ * useShellOrganization(); renders nothing when no `organization` prop was
270
+ * supplied to ShellProvider.
271
+ */
272
+ declare function OrgSelector(): react_jsx_runtime.JSX.Element | null;
273
+
274
+ /**
275
+ * Support icon + modal rendered in the header. Reads auth, org, and support
276
+ * handler from ShellProvider. Renders nothing when the host app didn't supply
277
+ * a `support` prop.
278
+ */
279
+ declare function SupportRequestButton(): react_jsx_runtime.JSX.Element | null;
280
+
164
281
  interface RegisterShellPrecacheOptions {
165
282
  /** Path the host app serves the SW from. Default: '/sw-shell.js'. */
166
283
  scriptUrl?: string;
@@ -187,4 +304,4 @@ declare function registerShellPrecache(opts?: RegisterShellPrecacheOptions): Pro
187
304
  */
188
305
  declare function buildSpeculationRules(currentApp: string, registry: AppRegistryEntry[]): string | null;
189
306
 
190
- export { AppLayout, type AppRegistryEntry, BreadcrumbBar, Card, Footer, GlobalUiIdProvider, Header, HeaderTabBar, type HeaderTabBarItem, PageContainer, PageHeader, type ShellAuthStatus, type ShellAuthValue, ShellProvider, type ShellProviderProps, type ShellSlots, type ShellUser, Sidebar, buildSpeculationRules, politogyTheme, registerShellPrecache, useAppRegistry, useCurrentApp, useShellAuth };
307
+ export { AppLayout, type AppRegistryEntry, BreadcrumbBar, Card, Footer, GlobalUiIdProvider, Header, HeaderTabBar, type HeaderTabBarItem, OrgSelector, PageContainer, PageHeader, type ShellAuthStatus, type ShellAuthValue, type ShellLinkedAccount, type ShellLinkedAccountsValue, type ShellOrganization, type ShellOrganizationValue, ShellProvider, type ShellProviderProps, type ShellSlots, type ShellSupportContext, type ShellSupportValue, type ShellUser, Sidebar, SupportRequestButton, UserMenu, buildSpeculationRules, politogyTheme, registerShellPrecache, useAppRegistry, useCurrentApp, useShellAuth, useShellChrome, useShellLinkedAccounts, useShellOrganization, useShellSupport };
package/dist/index.d.ts CHANGED
@@ -122,6 +122,16 @@ interface ShellProviderProps {
122
122
  appRegistry?: AppRegistryEntry[];
123
123
  /** Optional override for the base path if the app is mounted under a sub-path (e.g., '/contacts'). */
124
124
  basename?: string;
125
+ /** If provided, shell renders <OrgSelector /> in the header. */
126
+ organization?: ShellOrganizationValue;
127
+ /** If provided, UserMenu shows account switcher + add-account button. */
128
+ linkedAccounts?: ShellLinkedAccountsValue;
129
+ /** If provided, shell renders <SupportRequestButton /> in the header. */
130
+ support?: ShellSupportValue;
131
+ /** Optional element rendered in the header (typically <DevNotesMenu /> from @the-portland-company/devnotes). */
132
+ devNotesMenu?: ReactNode;
133
+ /** href used by the UserMenu "My Profile" link. Defaults to '/my-profile'. */
134
+ myProfileHref?: string;
125
135
  }
126
136
  /** Return value of useShellAuth(). */
127
137
  interface ShellAuthValue {
@@ -130,14 +140,101 @@ interface ShellAuthValue {
130
140
  session: Session | null;
131
141
  signOut: () => Promise<void>;
132
142
  }
143
+ /**
144
+ * Organization that the current user belongs to. Apps supply this via
145
+ * ShellProvider so the shell can render <OrgSelector /> in the header.
146
+ */
147
+ interface ShellOrganization {
148
+ id: string;
149
+ name: string;
150
+ logoUrl?: string | null;
151
+ /** Brand color as a hex string (e.g., '#0066cc'). Used for the org badge fallback. */
152
+ brandColor?: string | null;
153
+ }
154
+ interface ShellOrganizationValue {
155
+ currentOrg: ShellOrganization | null;
156
+ /** All orgs the user belongs to. */
157
+ organizations: ShellOrganization[];
158
+ /** Switch to the org with the given id. App owns the side effects. */
159
+ switchOrganization: (orgId: string) => Promise<void> | void;
160
+ /** Optional link rendered at the bottom of the org menu, e.g., '/organizations/new'. */
161
+ createOrgHref?: string;
162
+ }
163
+ /**
164
+ * An alternate user account the current user can switch into without signing
165
+ * out. App supplies the data + handlers; shell renders the UI inside UserMenu.
166
+ */
167
+ interface ShellLinkedAccount {
168
+ id: string;
169
+ email: string;
170
+ displayName?: string | null;
171
+ avatarUrl?: string | null;
172
+ }
173
+ interface ShellLinkedAccountsValue {
174
+ linkedAccounts: ShellLinkedAccount[];
175
+ switchToAccount: (accountId: string) => Promise<void> | void;
176
+ /** Called when the user clicks "Add account" in UserMenu. App opens its own modal. */
177
+ onAddAccount: () => void;
178
+ /** Called when the user wants to remove a linked account. App opens its own confirm. */
179
+ onRemoveAccount: (accountId: string) => void;
180
+ }
181
+ /** Context emitted to the host's submitSupportRequest handler. */
182
+ interface ShellSupportContext {
183
+ pathname: string;
184
+ search: string;
185
+ pageTitle?: string;
186
+ organizationName?: string;
187
+ }
188
+ interface ShellSupportValue {
189
+ /**
190
+ * Submit a support request. Host app handles persistence/email/etc.
191
+ * Shell renders the modal and calls this on submit.
192
+ */
193
+ submitSupportRequest: (input: {
194
+ email: string;
195
+ phone: string;
196
+ message: string;
197
+ context: ShellSupportContext;
198
+ }) => Promise<void>;
199
+ }
133
200
 
134
- declare function ShellProvider({ children, supabaseClient, currentApp, appRegistry, basename, }: ShellProviderProps): react_jsx_runtime.JSX.Element;
201
+ declare function ShellProvider({ children, supabaseClient, currentApp, appRegistry, basename, organization, linkedAccounts, support, devNotesMenu, myProfileHref, }: ShellProviderProps): react_jsx_runtime.JSX.Element;
135
202
 
136
203
  declare function useShellAuth(): ShellAuthValue;
137
204
 
138
205
  declare function useAppRegistry(): AppRegistryEntry[];
139
206
  declare function useCurrentApp(): string;
140
207
 
208
+ /**
209
+ * Returns the organization value supplied to ShellProvider, or null if the
210
+ * host app didn't pass an `organization` prop. Returning null lets chrome
211
+ * components (e.g., <OrgSelector />) render nothing instead of erroring.
212
+ */
213
+ declare function useShellOrganization(): ShellOrganizationValue | null;
214
+
215
+ /**
216
+ * Returns the linked-accounts value supplied to ShellProvider, or null if not
217
+ * provided. UserMenu uses this to decide whether to render the
218
+ * "switch account" section.
219
+ */
220
+ declare function useShellLinkedAccounts(): ShellLinkedAccountsValue | null;
221
+
222
+ /**
223
+ * Returns the support handler supplied to ShellProvider, or null if not
224
+ * provided. SupportRequestButton uses this to decide whether to render.
225
+ */
226
+ declare function useShellSupport(): ShellSupportValue | null;
227
+
228
+ interface ShellChromeValue {
229
+ devNotesMenu: ReactNode | null;
230
+ myProfileHref: string;
231
+ }
232
+ /**
233
+ * Returns chrome-level options supplied to ShellProvider (devNotesMenu slot,
234
+ * myProfileHref). Throws if used outside <ShellProvider>.
235
+ */
236
+ declare function useShellChrome(): ShellChromeValue;
237
+
141
238
  interface AppLayoutProps extends ShellSlots {
142
239
  children: ReactNode;
143
240
  buildInfo?: string;
@@ -161,6 +258,26 @@ interface FooterProps {
161
258
  }
162
259
  declare function Footer({ buildInfo }: FooterProps): react_jsx_runtime.JSX.Element;
163
260
 
261
+ /**
262
+ * Avatar dropdown rendered at the right side of the header. Reads auth,
263
+ * linked-accounts, and chrome context from ShellProvider.
264
+ */
265
+ declare function UserMenu(): react_jsx_runtime.JSX.Element | null;
266
+
267
+ /**
268
+ * Organization switcher rendered in the header. Reads from
269
+ * useShellOrganization(); renders nothing when no `organization` prop was
270
+ * supplied to ShellProvider.
271
+ */
272
+ declare function OrgSelector(): react_jsx_runtime.JSX.Element | null;
273
+
274
+ /**
275
+ * Support icon + modal rendered in the header. Reads auth, org, and support
276
+ * handler from ShellProvider. Renders nothing when the host app didn't supply
277
+ * a `support` prop.
278
+ */
279
+ declare function SupportRequestButton(): react_jsx_runtime.JSX.Element | null;
280
+
164
281
  interface RegisterShellPrecacheOptions {
165
282
  /** Path the host app serves the SW from. Default: '/sw-shell.js'. */
166
283
  scriptUrl?: string;
@@ -187,4 +304,4 @@ declare function registerShellPrecache(opts?: RegisterShellPrecacheOptions): Pro
187
304
  */
188
305
  declare function buildSpeculationRules(currentApp: string, registry: AppRegistryEntry[]): string | null;
189
306
 
190
- export { AppLayout, type AppRegistryEntry, BreadcrumbBar, Card, Footer, GlobalUiIdProvider, Header, HeaderTabBar, type HeaderTabBarItem, PageContainer, PageHeader, type ShellAuthStatus, type ShellAuthValue, ShellProvider, type ShellProviderProps, type ShellSlots, type ShellUser, Sidebar, buildSpeculationRules, politogyTheme, registerShellPrecache, useAppRegistry, useCurrentApp, useShellAuth };
307
+ export { AppLayout, type AppRegistryEntry, BreadcrumbBar, Card, Footer, GlobalUiIdProvider, Header, HeaderTabBar, type HeaderTabBarItem, OrgSelector, PageContainer, PageHeader, type ShellAuthStatus, type ShellAuthValue, type ShellLinkedAccount, type ShellLinkedAccountsValue, type ShellOrganization, type ShellOrganizationValue, ShellProvider, type ShellProviderProps, type ShellSlots, type ShellSupportContext, type ShellSupportValue, type ShellUser, Sidebar, SupportRequestButton, UserMenu, buildSpeculationRules, politogyTheme, registerShellPrecache, useAppRegistry, useCurrentApp, useShellAuth, useShellChrome, useShellLinkedAccounts, useShellOrganization, useShellSupport };