@plexusone/shell 0.2.3 → 0.3.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.mts CHANGED
@@ -1,6 +1,6 @@
1
+ import * as react from 'react';
1
2
  import { ReactNode } from 'react';
2
3
  import { CatalogApp, SessionMembership } from '@plexusone/auth';
3
- import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
 
5
5
  /**
6
6
  * Navigation item
@@ -419,7 +419,7 @@ interface ShellProviderProps extends Partial<AppShellConfig> {
419
419
  /**
420
420
  * ShellProvider - Provides shell state to components
421
421
  */
422
- declare function ShellProvider({ children, defaultCollapsed, onNavigate, onCollapseChange, }: ShellProviderProps): react_jsx_runtime.JSX.Element;
422
+ declare function ShellProvider({ children, defaultCollapsed, onNavigate, onCollapseChange, }: ShellProviderProps): react.JSX.Element;
423
423
  /**
424
424
  * Hook to access shell context
425
425
  *
@@ -509,7 +509,7 @@ declare function OrganizationSwitcher({ value, onChange, memberships, alwaysShow
509
509
 
510
510
  /** Props for {@link ProductSwitcher}. */
511
511
  interface ProductSwitcherProps {
512
- /** The application rendering the switcher. Always shown, first. */
512
+ /** The application rendering the switcher. Always shown, in its catalog place. */
513
513
  self: CatalogApp;
514
514
  /** The current organization's ID; roles are per organization. */
515
515
  organizationId?: string;
@@ -517,7 +517,8 @@ interface ProductSwitcherProps {
517
517
  apps?: CatalogApp[];
518
518
  /**
519
519
  * Client-side navigation, for applications composed in one build. Without
520
- * it, entries are plain links to each application's URL.
520
+ * it, entries are plain links to each application's URL, carrying the
521
+ * sidebar state and theme so the next application opens the same way.
521
522
  */
522
523
  onNavigate?: (url: string) => void;
523
524
  className?: string;
@@ -535,8 +536,11 @@ declare function ProductSwitcher({ self, organizationId, apps, onNavigate, class
535
536
 
536
537
  /**
537
538
  * The applications the product switcher shows: those in the catalog in
538
- * which the member holds a role for the current organization, in catalog
539
- * order, with the current application always present and first.
539
+ * which the member holds a role for the current organization, and the
540
+ * current application, all in catalog order. The order is the same in every
541
+ * application, so the switcher looks the same wherever it is; only which
542
+ * entry is current changes. An application the catalog does not list comes
543
+ * first.
540
544
  *
541
545
  * With an empty catalog (for example in local development) it is the
542
546
  * current application alone. Without a membership only the current
@@ -609,8 +613,9 @@ declare function resolveTheme(theme: Theme, prefersDark?: boolean): 'light' | 'd
609
613
  */
610
614
  declare function applyTheme(theme: Theme, root?: HTMLElement): void;
611
615
  /**
612
- * Applies the stored theme. Call it before the first render, so the page
613
- * does not flash the other theme.
616
+ * Applies the stored theme, after adopting preferences carried in the link.
617
+ * Call it before the first render, so the page does not flash the other
618
+ * theme and the sidebar opens as it was in the application linking here.
614
619
  */
615
620
  declare function applyStoredTheme(): void;
616
621
  /** The order the toggle cycles through. */
@@ -638,4 +643,25 @@ declare function useTheme(): [Theme, (theme: Theme) => void];
638
643
  */
639
644
  declare function Breadcrumbs({ items, onNavigate, separator, maxItems, }: BreadcrumbsProps): ReactNode;
640
645
 
641
- export { AppShell, type AppShellConfig, type AppShellProps, type BreadcrumbItem, Breadcrumbs, type BreadcrumbsProps, type NavItem, type NavSection, Navbar, type NavbarProps, OrgSwitcher, type OrgSwitcherProps, OrganizationSwitcher, type OrganizationSwitcherProps, ProductSwitcher, type ProductSwitcherProps, ProfileMenu, type ProfileMenuProps, type ShellContextValue, ShellProvider, Sidebar, type SidebarProps, THEME_CHANGE_EVENT, THEME_STORAGE_KEY, type Theme, ThemeToggle, type UserAction, UserMenu, type UserMenuProps, applyStoredTheme, applyTheme, initials, nextTheme, readStoredTheme, resolveTheme, switcherApps, useShell, useShellOptional, useTheme };
646
+ /** The key the sidebar's collapsed state is stored under. */
647
+ declare const COLLAPSED_KEY = "systemforge:sidebar-collapsed";
648
+ /** Preferences to carry; omitted ones are read from storage. */
649
+ interface CarriedPreferences {
650
+ sidebarCollapsed?: boolean;
651
+ theme?: Theme;
652
+ }
653
+ /**
654
+ * carryPreferences adds this application's sidebar state and theme to a
655
+ * link to another application of the suite, as a fragment. A URL that
656
+ * already has a fragment is left as it is.
657
+ */
658
+ declare function carryPreferences(url: string, prefs?: CarriedPreferences): string;
659
+ /**
660
+ * adoptCarriedPreferences stores preferences carried in this page's
661
+ * fragment and removes them from the address bar. applyStoredTheme calls it,
662
+ * before the first render.
663
+ */
664
+ declare function adoptCarriedPreferences(): void;
665
+
666
+ export { AppShell, Breadcrumbs, COLLAPSED_KEY, Navbar, OrgSwitcher, OrganizationSwitcher, ProductSwitcher, ProfileMenu, ShellProvider, Sidebar, THEME_CHANGE_EVENT, THEME_STORAGE_KEY, ThemeToggle, UserMenu, adoptCarriedPreferences, applyStoredTheme, applyTheme, carryPreferences, initials, nextTheme, readStoredTheme, resolveTheme, switcherApps, useShell, useShellOptional, useTheme };
667
+ export type { AppShellConfig, AppShellProps, BreadcrumbItem, BreadcrumbsProps, CarriedPreferences, NavItem, NavSection, NavbarProps, OrgSwitcherProps, OrganizationSwitcherProps, ProductSwitcherProps, ProfileMenuProps, ShellContextValue, SidebarProps, Theme, UserAction, UserMenuProps };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
+ import * as react from 'react';
1
2
  import { ReactNode } from 'react';
2
3
  import { CatalogApp, SessionMembership } from '@plexusone/auth';
3
- import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
 
5
5
  /**
6
6
  * Navigation item
@@ -419,7 +419,7 @@ interface ShellProviderProps extends Partial<AppShellConfig> {
419
419
  /**
420
420
  * ShellProvider - Provides shell state to components
421
421
  */
422
- declare function ShellProvider({ children, defaultCollapsed, onNavigate, onCollapseChange, }: ShellProviderProps): react_jsx_runtime.JSX.Element;
422
+ declare function ShellProvider({ children, defaultCollapsed, onNavigate, onCollapseChange, }: ShellProviderProps): react.JSX.Element;
423
423
  /**
424
424
  * Hook to access shell context
425
425
  *
@@ -509,7 +509,7 @@ declare function OrganizationSwitcher({ value, onChange, memberships, alwaysShow
509
509
 
510
510
  /** Props for {@link ProductSwitcher}. */
511
511
  interface ProductSwitcherProps {
512
- /** The application rendering the switcher. Always shown, first. */
512
+ /** The application rendering the switcher. Always shown, in its catalog place. */
513
513
  self: CatalogApp;
514
514
  /** The current organization's ID; roles are per organization. */
515
515
  organizationId?: string;
@@ -517,7 +517,8 @@ interface ProductSwitcherProps {
517
517
  apps?: CatalogApp[];
518
518
  /**
519
519
  * Client-side navigation, for applications composed in one build. Without
520
- * it, entries are plain links to each application's URL.
520
+ * it, entries are plain links to each application's URL, carrying the
521
+ * sidebar state and theme so the next application opens the same way.
521
522
  */
522
523
  onNavigate?: (url: string) => void;
523
524
  className?: string;
@@ -535,8 +536,11 @@ declare function ProductSwitcher({ self, organizationId, apps, onNavigate, class
535
536
 
536
537
  /**
537
538
  * The applications the product switcher shows: those in the catalog in
538
- * which the member holds a role for the current organization, in catalog
539
- * order, with the current application always present and first.
539
+ * which the member holds a role for the current organization, and the
540
+ * current application, all in catalog order. The order is the same in every
541
+ * application, so the switcher looks the same wherever it is; only which
542
+ * entry is current changes. An application the catalog does not list comes
543
+ * first.
540
544
  *
541
545
  * With an empty catalog (for example in local development) it is the
542
546
  * current application alone. Without a membership only the current
@@ -609,8 +613,9 @@ declare function resolveTheme(theme: Theme, prefersDark?: boolean): 'light' | 'd
609
613
  */
610
614
  declare function applyTheme(theme: Theme, root?: HTMLElement): void;
611
615
  /**
612
- * Applies the stored theme. Call it before the first render, so the page
613
- * does not flash the other theme.
616
+ * Applies the stored theme, after adopting preferences carried in the link.
617
+ * Call it before the first render, so the page does not flash the other
618
+ * theme and the sidebar opens as it was in the application linking here.
614
619
  */
615
620
  declare function applyStoredTheme(): void;
616
621
  /** The order the toggle cycles through. */
@@ -638,4 +643,25 @@ declare function useTheme(): [Theme, (theme: Theme) => void];
638
643
  */
639
644
  declare function Breadcrumbs({ items, onNavigate, separator, maxItems, }: BreadcrumbsProps): ReactNode;
640
645
 
641
- export { AppShell, type AppShellConfig, type AppShellProps, type BreadcrumbItem, Breadcrumbs, type BreadcrumbsProps, type NavItem, type NavSection, Navbar, type NavbarProps, OrgSwitcher, type OrgSwitcherProps, OrganizationSwitcher, type OrganizationSwitcherProps, ProductSwitcher, type ProductSwitcherProps, ProfileMenu, type ProfileMenuProps, type ShellContextValue, ShellProvider, Sidebar, type SidebarProps, THEME_CHANGE_EVENT, THEME_STORAGE_KEY, type Theme, ThemeToggle, type UserAction, UserMenu, type UserMenuProps, applyStoredTheme, applyTheme, initials, nextTheme, readStoredTheme, resolveTheme, switcherApps, useShell, useShellOptional, useTheme };
646
+ /** The key the sidebar's collapsed state is stored under. */
647
+ declare const COLLAPSED_KEY = "systemforge:sidebar-collapsed";
648
+ /** Preferences to carry; omitted ones are read from storage. */
649
+ interface CarriedPreferences {
650
+ sidebarCollapsed?: boolean;
651
+ theme?: Theme;
652
+ }
653
+ /**
654
+ * carryPreferences adds this application's sidebar state and theme to a
655
+ * link to another application of the suite, as a fragment. A URL that
656
+ * already has a fragment is left as it is.
657
+ */
658
+ declare function carryPreferences(url: string, prefs?: CarriedPreferences): string;
659
+ /**
660
+ * adoptCarriedPreferences stores preferences carried in this page's
661
+ * fragment and removes them from the address bar. applyStoredTheme calls it,
662
+ * before the first render.
663
+ */
664
+ declare function adoptCarriedPreferences(): void;
665
+
666
+ export { AppShell, Breadcrumbs, COLLAPSED_KEY, Navbar, OrgSwitcher, OrganizationSwitcher, ProductSwitcher, ProfileMenu, ShellProvider, Sidebar, THEME_CHANGE_EVENT, THEME_STORAGE_KEY, ThemeToggle, UserMenu, adoptCarriedPreferences, applyStoredTheme, applyTheme, carryPreferences, initials, nextTheme, readStoredTheme, resolveTheme, switcherApps, useShell, useShellOptional, useTheme };
667
+ export type { AppShellConfig, AppShellProps, BreadcrumbItem, BreadcrumbsProps, CarriedPreferences, NavItem, NavSection, NavbarProps, OrgSwitcherProps, OrganizationSwitcherProps, ProductSwitcherProps, ProfileMenuProps, ShellContextValue, SidebarProps, Theme, UserAction, UserMenuProps };