@shellui/core 0.4.1 → 0.5.0-alpha.2

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.
Files changed (142) hide show
  1. package/README.md +2 -2
  2. package/package.json +15 -3
  3. package/schemas/curated-themes.json +4035 -0
  4. package/schemas/shellui.config.schema.json +961 -0
  5. package/schemas/shellui.theme.schema.json +187 -0
  6. package/src/app.tsx +4 -1
  7. package/src/components/ContentView.tsx +144 -9
  8. package/src/components/LoadingOverlay.tsx +1 -1
  9. package/src/components/ui/alert-dialog.tsx +1 -1
  10. package/src/components/ui/dialog.tsx +23 -5
  11. package/src/components/ui/drawer.tsx +282 -42
  12. package/src/components/ui/dropdown-menu.tsx +7 -2
  13. package/src/components/ui/input.tsx +21 -0
  14. package/src/components/ui/separator.tsx +23 -0
  15. package/src/components/ui/sheet.tsx +220 -0
  16. package/src/components/ui/sidebar.tsx +785 -221
  17. package/src/components/ui/skeleton.tsx +13 -0
  18. package/src/constants/urls.ts +1 -0
  19. package/src/features/admin/utils.ts +2 -45
  20. package/src/features/alertDialog/DialogContext.tsx +1 -1
  21. package/src/features/auth/components/LoginButton.tsx +25 -18
  22. package/src/features/auth/components/LoginPreferencesControls.tsx +124 -0
  23. package/src/features/auth/components/LoginView.tsx +131 -49
  24. package/src/features/config/types.ts +64 -82
  25. package/src/features/drawer/DrawerContext.tsx +55 -19
  26. package/src/features/layouts/AppLayout.tsx +3 -3
  27. package/src/features/layouts/OverlayShell.tsx +376 -77
  28. package/src/features/layouts/appbar/AppBarLayout.tsx +501 -88
  29. package/src/features/layouts/branding/AppBrandIcon.tsx +95 -0
  30. package/src/features/layouts/branding/resolveThemeAsset.spec.ts +33 -0
  31. package/src/features/layouts/branding/resolveThemeAsset.ts +33 -0
  32. package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +49 -0
  33. package/src/features/layouts/chrome/ContentDragOverlay.tsx +19 -0
  34. package/src/features/layouts/chrome/DesktopBackButton.tsx +71 -0
  35. package/src/features/layouts/chrome/DesktopChrome.tsx +28 -0
  36. package/src/features/layouts/chrome/DesktopForwardButton.tsx +59 -0
  37. package/src/features/layouts/chrome/DesktopHistoryButtons.tsx +16 -0
  38. package/src/features/layouts/chrome/constants.ts +11 -0
  39. package/src/features/layouts/chrome/goDesktopBack.spec.ts +218 -0
  40. package/src/features/layouts/chrome/goDesktopBack.ts +106 -0
  41. package/src/features/layouts/chrome/index.ts +26 -0
  42. package/src/features/layouts/chrome/runtime.ts +45 -0
  43. package/src/features/layouts/findMatchingNavigationItem.spec.ts +55 -0
  44. package/src/features/layouts/fullscreen/FullscreenLayout.tsx +17 -1
  45. package/src/features/layouts/isFrameForAppUrl.spec.ts +33 -0
  46. package/src/features/layouts/sidebar/NavigationContent.tsx +70 -34
  47. package/src/features/layouts/sidebar/SidebarIcons.tsx +41 -42
  48. package/src/features/layouts/sidebar/SidebarInner.tsx +142 -24
  49. package/src/features/layouts/sidebar/SidebarLayout.tsx +100 -37
  50. package/src/features/layouts/sidebar/sidebarUtils.ts +0 -7
  51. package/src/features/layouts/sidebar/types.ts +3 -3
  52. package/src/features/layouts/utils.ts +73 -5
  53. package/src/features/layouts/windows/WindowsLayout.tsx +173 -61
  54. package/src/features/modal/ModalContext.tsx +21 -8
  55. package/src/features/overlays/OverlayDrawerPendingBar.tsx +26 -0
  56. package/src/features/overlays/OverlayDynamicDemoView.tsx +108 -0
  57. package/src/features/overlays/OverlayPendingSpinner.tsx +18 -0
  58. package/src/features/overlays/ResponsiveModal.tsx +483 -0
  59. package/src/features/overlays/overlaySize.spec.ts +71 -0
  60. package/src/features/overlays/overlaySize.ts +228 -0
  61. package/src/features/overlays/useOverlayReportedSize.ts +130 -0
  62. package/src/features/settings/SettingsProvider.tsx +66 -46
  63. package/src/features/settings/SettingsView.tsx +42 -47
  64. package/src/features/settings/components/Appearance.tsx +305 -55
  65. package/src/features/settings/components/develop/DrawerTestButtons.tsx +18 -0
  66. package/src/features/settings/components/develop/ModalTestButtons.tsx +23 -0
  67. package/src/features/settings/utils/getResolvedAppearanceForSettings.ts +11 -5
  68. package/src/features/theme/applyTheme.ts +143 -0
  69. package/src/features/theme/color.ts +83 -0
  70. package/src/features/theme/curated/amber-minimal.json +86 -0
  71. package/src/features/theme/curated/amethyst-haze.json +86 -0
  72. package/src/features/theme/curated/astro-vista.json +86 -0
  73. package/src/features/theme/curated/bold-tech.json +86 -0
  74. package/src/features/theme/curated/bubblegum.json +86 -0
  75. package/src/features/theme/curated/caffeine.json +83 -0
  76. package/src/features/theme/curated/candyland.json +86 -0
  77. package/src/features/theme/curated/catppuccin.json +86 -0
  78. package/src/features/theme/curated/claude.json +86 -0
  79. package/src/features/theme/curated/claymorphism.json +86 -0
  80. package/src/features/theme/curated/clean-slate.json +86 -0
  81. package/src/features/theme/curated/cosmic-night.json +86 -0
  82. package/src/features/theme/curated/cyberpunk.json +86 -0
  83. package/src/features/theme/curated/darkmatter.json +86 -0
  84. package/src/features/theme/curated/doom-64.json +86 -0
  85. package/src/features/theme/curated/elegant-luxury.json +86 -0
  86. package/src/features/theme/curated/graphite.json +86 -0
  87. package/src/features/theme/curated/index.ts +260 -0
  88. package/src/features/theme/curated/kodama-grove.json +86 -0
  89. package/src/features/theme/curated/light-green.json +87 -0
  90. package/src/features/theme/curated/midnight-bloom.json +86 -0
  91. package/src/features/theme/curated/mocha-mousse.json +86 -0
  92. package/src/features/theme/curated/modern-minimal.json +86 -0
  93. package/src/features/theme/curated/mono.json +84 -0
  94. package/src/features/theme/curated/nature.json +86 -0
  95. package/src/features/theme/curated/neo-brutalism.json +86 -0
  96. package/src/features/theme/curated/northern-lights.json +86 -0
  97. package/src/features/theme/curated/notebook.json +87 -0
  98. package/src/features/theme/curated/ocean-breeze.json +86 -0
  99. package/src/features/theme/curated/pastel-dreams.json +86 -0
  100. package/src/features/theme/curated/perpetuity.json +86 -0
  101. package/src/features/theme/curated/quantum-rose.json +86 -0
  102. package/src/features/theme/curated/retro-arcade.json +86 -0
  103. package/src/features/theme/curated/sage-garden.json +86 -0
  104. package/src/features/theme/curated/shadcn.json +83 -0
  105. package/src/features/theme/curated/shellui.json +82 -0
  106. package/src/features/theme/curated/soft-pop.json +86 -0
  107. package/src/features/theme/curated/solar-dusk.json +86 -0
  108. package/src/features/theme/curated/starry-night.json +86 -0
  109. package/src/features/theme/curated/sunset-horizon.json +86 -0
  110. package/src/features/theme/curated/supabase.json +85 -0
  111. package/src/features/theme/curated/t3-chat.json +83 -0
  112. package/src/features/theme/curated/tangerine.json +86 -0
  113. package/src/features/theme/curated/twitter.json +86 -0
  114. package/src/features/theme/curated/vercel.json +86 -0
  115. package/src/features/theme/curated/vintage-paper.json +86 -0
  116. package/src/features/theme/curated/violet-bloom.json +87 -0
  117. package/src/features/theme/curated/zen-inspired.json +87 -0
  118. package/src/features/theme/index.ts +76 -0
  119. package/src/features/theme/normalize.ts +159 -0
  120. package/src/features/theme/registry.ts +50 -0
  121. package/src/features/theme/resolveConfig.ts +182 -0
  122. package/src/features/theme/safeApplyTheme.ts +147 -0
  123. package/src/features/theme/themes.spec.ts +276 -0
  124. package/src/features/theme/themes.ts +82 -558
  125. package/src/features/theme/tokenKeys.ts +60 -0
  126. package/src/features/theme/types.ts +170 -0
  127. package/src/features/theme/useTheme.tsx +48 -50
  128. package/src/hooks/use-mobile.tsx +19 -0
  129. package/src/i18n/translations/en/common.json +41 -0
  130. package/src/i18n/translations/en/settings.json +10 -2
  131. package/src/i18n/translations/fr/common.json +41 -0
  132. package/src/i18n/translations/fr/settings.json +10 -2
  133. package/src/index.css +372 -128
  134. package/src/index.ts +71 -0
  135. package/src/lib/z-index.ts +4 -1
  136. package/src/routes/components/IndexRoute.tsx +12 -2
  137. package/src/routes/components/NavigationItemRoute.tsx +1 -10
  138. package/src/routes/hooks/useNavigationItems.ts +29 -44
  139. package/src/routes/routes.tsx +63 -27
  140. package/tailwind.config.js +27 -27
  141. package/src/features/layouts/sidebar/BottomNavItem.tsx +0 -88
  142. package/src/features/layouts/sidebar/MobileBottomNav.tsx +0 -168
@@ -9,7 +9,12 @@ import {
9
9
  import { useLocation } from 'react-router';
10
10
  import { useTranslation } from 'react-i18next';
11
11
  import { shellui } from '@shellui/sdk';
12
- import type { NavigationItem, NavigationGroup } from '../../config/types';
12
+ import type {
13
+ NavigationItem,
14
+ NavigationGroup,
15
+ LocalizedString,
16
+ ThemeAsset,
17
+ } from '../../config/types';
13
18
  import {
14
19
  filterNavigationForAuthState,
15
20
  flattenNavigationItems,
@@ -25,27 +30,45 @@ import { cn } from '../../../lib/utils';
25
30
  import { Z_INDEX } from '../../../lib/z-index';
26
31
  import { LoginButton } from '../../auth/components/LoginButton';
27
32
  import { useAuth } from '../../auth/hooks/useAuth';
33
+ import { ExternalLinkIcon, NavIcon } from '../sidebar/SidebarIcons';
34
+ import { getExternalFaviconUrl, isAppIcon } from '../sidebar/sidebarUtils';
35
+ import { AppBrandIcon } from '../branding/AppBrandIcon';
28
36
 
29
37
  interface WindowsLayoutProps {
30
38
  title?: string;
31
- appIcon?: string;
32
- logo?: string;
39
+ appIcon?: ThemeAsset;
40
+ logo?: ThemeAsset;
33
41
  navigation: (NavigationItem | NavigationGroup)[];
34
42
  }
35
43
 
36
- const getExternalFaviconUrl = (url: string): string | null => {
37
- try {
38
- const parsed = new URL(url);
39
- const hostname = parsed.hostname;
40
- if (!hostname) return null;
41
- return `https://icons.duckduckgo.com/ip3/${hostname}.ico`;
42
- } catch {
43
- return null;
44
+ type StartSection =
45
+ | { type: 'group'; title: string | LocalizedString; items: NavigationItem[] }
46
+ | { type: 'items'; items: NavigationItem[] };
47
+
48
+ const isNavigationGroup = (item: NavigationItem | NavigationGroup): item is NavigationGroup =>
49
+ 'title' in item && 'items' in item;
50
+
51
+ /** Keep navigation groups as labeled categories; consecutive loose items share one untitled section. */
52
+ function buildStartSections(start: (NavigationItem | NavigationGroup)[]): StartSection[] {
53
+ const sections: StartSection[] = [];
54
+ for (const entry of start) {
55
+ if (isNavigationGroup(entry)) {
56
+ const items = entry.items.filter((i) => !i.hidden);
57
+ if (items.length > 0) {
58
+ sections.push({ type: 'group', title: entry.title, items });
59
+ }
60
+ continue;
61
+ }
62
+ if (entry.hidden) continue;
63
+ const last = sections[sections.length - 1];
64
+ if (last?.type === 'items') {
65
+ last.items.push(entry);
66
+ } else {
67
+ sections.push({ type: 'items', items: [entry] });
68
+ }
44
69
  }
45
- };
46
-
47
- /** True when the icon is a local app icon (/icons/); apply theme (dark invert) so it matches foreground. */
48
- const isAppIcon = (src: string) => src.startsWith('/icons/');
70
+ return sections;
71
+ }
49
72
 
50
73
  const genId = () => `win-${Date.now()}-${Math.random().toString(36).slice(2)}`;
51
74
 
@@ -505,12 +528,7 @@ function getBrowserTimezone(): string {
505
528
  return 'UTC';
506
529
  }
507
530
 
508
- export function WindowsLayout({
509
- title,
510
- appIcon: _appIcon,
511
- logo: _logo,
512
- navigation,
513
- }: WindowsLayoutProps) {
531
+ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: WindowsLayoutProps) {
514
532
  const location = useLocation();
515
533
  const { i18n } = useTranslation();
516
534
  const { isAuthenticated } = useAuth();
@@ -523,10 +541,10 @@ export function WindowsLayout({
523
541
  [navigation, isAuthenticated, settings.developerFeatures.enabled],
524
542
  );
525
543
  const timeZone = settings.region?.timezone ?? getBrowserTimezone();
526
- const { startNavItems, endNavItems, navigationItems } = useMemo(() => {
544
+ const { startSections, endNavItems, navigationItems } = useMemo(() => {
527
545
  const { start, end } = splitNavigationByPosition(authAwareNavigation);
528
546
  return {
529
- startNavItems: flattenNavigationItems(start),
547
+ startSections: buildStartSections(start),
530
548
  endNavItems: end,
531
549
  navigationItems: flattenNavigationItems(authAwareNavigation),
532
550
  };
@@ -539,6 +557,7 @@ export function WindowsLayout({
539
557
  const [now, setNow] = useState(() => new Date());
540
558
  const startPanelRef = useRef<HTMLDivElement>(null);
541
559
  const initialOpenFromUrlDoneRef = useRef(false);
560
+ const openPaths = useMemo(() => new Set(windows.map((w) => w.path)), [windows]);
542
561
 
543
562
  // Update date/time every second for taskbar clock
544
563
  useEffect(() => {
@@ -653,17 +672,38 @@ export function WindowsLayout({
653
672
  setStartMenuOpen(false);
654
673
  return;
655
674
  }
675
+ const existing = windows.find((w) => w.path === item.path);
676
+ if (existing) {
677
+ focusWindow(existing.id);
678
+ setStartMenuOpen(false);
679
+ return;
680
+ }
656
681
  openWindow(item);
657
682
  },
658
- [openWindow],
683
+ [openWindow, windows, focusWindow],
659
684
  );
660
685
 
661
686
  return (
662
687
  <>
663
688
  <div
664
- className="fixed inset-0 bg-muted/30"
689
+ className="fixed inset-0 overflow-hidden bg-background"
665
690
  style={{ paddingBottom: TASKBAR_HEIGHT }}
666
691
  >
692
+ {/* Organic primary wash behind windows — follows --primary with the active theme. */}
693
+ <div
694
+ aria-hidden
695
+ className="pointer-events-none absolute inset-0"
696
+ style={{
697
+ backgroundImage: [
698
+ 'radial-gradient(ellipse 95% 70% at 18% 108%, color-mix(in oklch, var(--primary) 32%, transparent), transparent 58%)',
699
+ 'radial-gradient(ellipse 70% 55% at 78% 118%, color-mix(in oklch, var(--primary) 22%, transparent), transparent 62%)',
700
+ 'radial-gradient(ellipse 55% 40% at 52% 92%, color-mix(in oklch, var(--primary) 14%, transparent), transparent 70%)',
701
+ 'radial-gradient(ellipse 40% 30% at 92% 78%, color-mix(in oklch, var(--primary) 10%, transparent), transparent 68%)',
702
+ 'radial-gradient(ellipse 35% 28% at 8% 72%, color-mix(in oklch, var(--primary) 8%, transparent), transparent 65%)',
703
+ ].join(', '),
704
+ }}
705
+ />
706
+
667
707
  {/* Desktop area: windows */}
668
708
  {windows.map((win, index) => {
669
709
  const navItem = navigationItems.find((n) => n.path === win.path);
@@ -714,54 +754,126 @@ export function WindowsLayout({
714
754
  aria-haspopup="true"
715
755
  aria-label="Start"
716
756
  >
717
- <StartIcon className="h-5 w-5" />
757
+ {appIcon ? (
758
+ <AppBrandIcon
759
+ appIcon={appIcon}
760
+ title={title}
761
+ linkToHome={false}
762
+ imgClassName="windows-app-icon size-5"
763
+ />
764
+ ) : (
765
+ <StartIcon className="h-5 w-5" />
766
+ )}
718
767
  <span className="font-semibold text-sm hidden sm:inline">{title || 'Start'}</span>
719
768
  </button>
720
769
  {/* Start menu panel */}
721
770
  {startMenuOpen && (
722
771
  <div
723
- className="absolute bottom-full left-0 mb-1 w-64 max-h-[70vh] overflow-y-auto rounded-lg border border-border bg-popover shadow-lg py-2 z-[10001]"
772
+ className="absolute bottom-full left-0 mb-2 flex w-[22rem] max-h-[min(72vh,34rem)] flex-col overflow-hidden rounded-xl border border-border/80 bg-popover/95 text-popover-foreground shadow-xl backdrop-blur-md"
724
773
  style={{ zIndex: Z_INDEX.MODAL_CONTENT }}
774
+ role="menu"
775
+ aria-label={title || 'Applications'}
725
776
  >
726
- <div className="px-2 pb-2 border-b border-border mb-2">
727
- <span className="text-sm font-semibold text-popover-foreground">
777
+ <div className="shrink-0 border-b border-border/60 px-4 py-3">
778
+ <p
779
+ className="text-sm font-semibold tracking-tight"
780
+ style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
781
+ >
728
782
  {title || 'Applications'}
729
- </span>
783
+ </p>
784
+ <p className="mt-0.5 text-xs text-muted-foreground">
785
+ Choose an app to open in a window
786
+ </p>
730
787
  </div>
731
- <div className="grid gap-0.5">
732
- {startNavItems
733
- .filter((item) => !item.hidden)
734
- .map((item) => {
735
- const label =
736
- typeof item.label === 'string'
737
- ? item.label
738
- : resolveNavLabel(item.label, currentLanguage);
739
- const icon =
740
- item.icon ??
741
- (item.openIn === 'external' ? getExternalFaviconUrl(item.url) : null);
788
+
789
+ <div className="min-h-0 flex-1 space-y-4 overflow-y-auto px-2 py-3">
790
+ {startSections.length === 0 ? (
791
+ <p className="px-2 py-6 text-center text-sm text-muted-foreground">
792
+ No applications available
793
+ </p>
794
+ ) : (
795
+ startSections.map((section, sectionIndex) => {
796
+ const categoryLabel =
797
+ section.type === 'group'
798
+ ? resolveNavLabel(section.title, currentLanguage)
799
+ : null;
742
800
  return (
743
- <button
744
- key={item.path}
745
- type="button"
746
- onClick={() => handleNavClick(item)}
747
- className="flex items-center gap-3 w-full px-3 py-2 text-left text-sm cursor-pointer text-popover-foreground hover:bg-accent hover:text-accent-foreground rounded-none transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
801
+ <section
802
+ key={
803
+ section.type === 'group'
804
+ ? `group-${categoryLabel}-${sectionIndex}`
805
+ : `items-${sectionIndex}`
806
+ }
807
+ className="space-y-1.5"
748
808
  >
749
- {icon ? (
750
- <img
751
- src={icon}
752
- alt=""
753
- className={cn(
754
- 'h-5 w-5 shrink-0 rounded-sm object-cover',
755
- isAppIcon(icon) && 'opacity-90 dark:opacity-100 dark:invert',
756
- )}
757
- />
758
- ) : (
759
- <span className="h-5 w-5 shrink-0 rounded-sm bg-muted" />
760
- )}
761
- <span className="truncate">{label}</span>
762
- </button>
809
+ {categoryLabel ? (
810
+ <h2
811
+ className="px-2.5 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground"
812
+ style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
813
+ >
814
+ {categoryLabel}
815
+ </h2>
816
+ ) : null}
817
+ <div className="space-y-0.5">
818
+ {section.items.map((item) => {
819
+ const label = resolveNavLabel(item.label, currentLanguage);
820
+ const isExternal = item.openIn === 'external';
821
+ const isOverlay = item.openIn === 'modal' || item.openIn === 'drawer';
822
+ const icon =
823
+ item.icon ?? (isExternal ? getExternalFaviconUrl(item.url) : null);
824
+ const isOpen = openPaths.has(item.path);
825
+ return (
826
+ <button
827
+ key={item.path}
828
+ type="button"
829
+ role="menuitem"
830
+ onClick={() => handleNavClick(item)}
831
+ className={cn(
832
+ 'group flex w-full items-center gap-3 rounded-lg px-2 py-2 text-left transition-colors',
833
+ 'cursor-pointer text-popover-foreground',
834
+ 'hover:bg-accent hover:text-accent-foreground',
835
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-popover',
836
+ isOpen && 'bg-accent/50',
837
+ )}
838
+ >
839
+ <span
840
+ className={cn(
841
+ 'flex size-9 shrink-0 items-center justify-center rounded-md',
842
+ 'bg-muted/70 text-foreground ring-1 ring-border/50',
843
+ 'group-hover:bg-background/80 group-hover:ring-border',
844
+ )}
845
+ >
846
+ <NavIcon
847
+ src={icon}
848
+ className="size-4"
849
+ />
850
+ </span>
851
+ <span className="min-w-0 flex-1">
852
+ <span className="block truncate text-sm font-medium leading-tight">
853
+ {label}
854
+ </span>
855
+ {isOpen && !isOverlay && !isExternal ? (
856
+ <span className="mt-0.5 block text-[11px] text-muted-foreground">
857
+ Open
858
+ </span>
859
+ ) : null}
860
+ </span>
861
+ {isExternal ? (
862
+ <ExternalLinkIcon className="size-3.5 shrink-0 opacity-50 group-hover:opacity-80" />
863
+ ) : isOpen && !isOverlay ? (
864
+ <span
865
+ className="size-1.5 shrink-0 rounded-full bg-primary"
866
+ aria-hidden
867
+ />
868
+ ) : null}
869
+ </button>
870
+ );
871
+ })}
872
+ </div>
873
+ </section>
763
874
  );
764
- })}
875
+ })
876
+ )}
765
877
  </div>
766
878
  </div>
767
879
  )}
@@ -1,4 +1,4 @@
1
- import { shellui, type ShellUIMessage } from '@shellui/sdk';
1
+ import { shellui, type OpenModalOptions, type ShellUIMessage } from '@shellui/sdk';
2
2
  import { createContext, useContext, useState, useEffect, useCallback, type ReactNode } from 'react';
3
3
  import { useConfig } from '../config/useConfig';
4
4
  import { validateAndNormalizeUrl } from './validateAndNormalizeUrl';
@@ -8,7 +8,8 @@ export { validateAndNormalizeUrl } from './validateAndNormalizeUrl';
8
8
  interface ModalContextValue {
9
9
  isOpen: boolean;
10
10
  modalUrl: string | null;
11
- openModal: (url?: string) => void;
11
+ options: OpenModalOptions | null;
12
+ openModal: (urlOrOptions?: string | OpenModalOptions) => void;
12
13
  closeModal: () => void;
13
14
  }
14
15
 
@@ -30,11 +31,17 @@ export const ModalProvider = ({ children }: ModalProviderProps) => {
30
31
  const { config } = useConfig();
31
32
  const [isOpen, setIsOpen] = useState(false);
32
33
  const [modalUrl, setModalUrl] = useState<string | null>(null);
34
+ const [options, setOptions] = useState<OpenModalOptions | null>(null);
33
35
 
34
36
  const openModal = useCallback(
35
- (url?: string) => {
36
- const validatedUrl = url ? validateAndNormalizeUrl(url, config) : null;
37
+ (urlOrOptions?: string | OpenModalOptions) => {
38
+ const opts: OpenModalOptions =
39
+ typeof urlOrOptions === 'string' || urlOrOptions === undefined
40
+ ? { url: urlOrOptions }
41
+ : urlOrOptions;
42
+ const validatedUrl = opts.url ? validateAndNormalizeUrl(opts.url, config) : null;
37
43
  setModalUrl(validatedUrl);
44
+ setOptions(opts);
38
45
  setIsOpen(true);
39
46
  },
40
47
  [config],
@@ -43,7 +50,10 @@ export const ModalProvider = ({ children }: ModalProviderProps) => {
43
50
  const closeModal = useCallback(() => {
44
51
  setIsOpen(false);
45
52
  // Clear URL after a short delay to allow animation to complete
46
- setTimeout(() => setModalUrl(null), 200);
53
+ setTimeout(() => {
54
+ setModalUrl(null);
55
+ setOptions(null);
56
+ }, 200);
47
57
  }, []);
48
58
 
49
59
  // Listen for postMessage events from nested iframes
@@ -51,8 +61,11 @@ export const ModalProvider = ({ children }: ModalProviderProps) => {
51
61
  const cleanupOpenModal = shellui.addMessageListener(
52
62
  'SHELLUI_OPEN_MODAL',
53
63
  (data: ShellUIMessage) => {
54
- const payload = data.payload as { url?: string };
55
- openModal(payload.url);
64
+ const payload = data.payload as OpenModalOptions & { url?: string | null };
65
+ openModal({
66
+ ...payload,
67
+ url: payload.url ?? undefined,
68
+ });
56
69
  },
57
70
  );
58
71
 
@@ -67,7 +80,7 @@ export const ModalProvider = ({ children }: ModalProviderProps) => {
67
80
  }, [openModal, closeModal]);
68
81
 
69
82
  return (
70
- <ModalContext.Provider value={{ isOpen, modalUrl, openModal, closeModal }}>
83
+ <ModalContext.Provider value={{ isOpen, modalUrl, options, openModal, closeModal }}>
71
84
  {children}
72
85
  </ModalContext.Provider>
73
86
  );
@@ -0,0 +1,26 @@
1
+ import { LOADING_OVERLAY_DURATION_MS } from '../../constants/loading';
2
+ import { DYNAMIC_DRAWER_PENDING_PX } from './overlaySize';
3
+
4
+ /**
5
+ * Full-bleed loading bar for dynamic drawers while waiting for the first size report.
6
+ * Matches drawer pending chrome height so the strip is the animation.
7
+ */
8
+ export function OverlayDrawerPendingBar() {
9
+ return (
10
+ <div
11
+ className="absolute inset-0 z-20 overflow-hidden bg-muted/30"
12
+ style={{ minHeight: DYNAMIC_DRAWER_PENDING_PX }}
13
+ aria-busy="true"
14
+ aria-live="polite"
15
+ >
16
+ <div
17
+ className="h-full w-0 bg-muted-foreground/40"
18
+ style={{
19
+ animation: `loading-bar-slide ${LOADING_OVERLAY_DURATION_MS}ms linear infinite`,
20
+ }}
21
+ aria-hidden
22
+ />
23
+ <span className="sr-only">Loading</span>
24
+ </div>
25
+ );
26
+ }
@@ -0,0 +1,108 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import { shellui } from '@shellui/sdk';
3
+ import { Button } from '../../components/ui/button';
4
+
5
+ /**
6
+ * Compact confirm UI for develop → dynamicSizing demos.
7
+ * Actions stay at the top so they remain reachable after expand.
8
+ * Reports content height to the parent overlay via the SDK.
9
+ *
10
+ * Avoid viewport units (vh/vw/%) in content height — inside a content-sized
11
+ * iframe they create a feedback loop (iframe grows → vh grows → report again).
12
+ */
13
+ export function OverlayDynamicDemoView() {
14
+ const [expanded, setExpanded] = useState(false);
15
+ const rootRef = useRef<HTMLDivElement>(null);
16
+
17
+ useEffect(() => {
18
+ let stop: (() => void) | undefined;
19
+ void shellui.init().then(() => {
20
+ // Observe the content root (grows with children) — not html/body (often height:100%)
21
+ stop = shellui.overlay.autoSize({
22
+ observe: true,
23
+ target: rootRef.current,
24
+ });
25
+ });
26
+ return () => {
27
+ stop?.();
28
+ shellui.overlay.autoSize({ observe: false });
29
+ };
30
+ }, []);
31
+
32
+ return (
33
+ <div
34
+ ref={rootRef}
35
+ data-overlay-demo-root
36
+ className="h-auto min-h-0 bg-background text-foreground p-5"
37
+ >
38
+ <h1
39
+ className="text-base font-semibold mb-1"
40
+ style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
41
+ >
42
+ Confirm action
43
+ </h1>
44
+ <p className="text-sm text-muted-foreground mb-3">
45
+ This demo uses <code className="text-xs">dynamicSizing</code> so the overlay hugs this
46
+ content. Expand to grow; actions stay above so you can always shrink again.
47
+ </p>
48
+
49
+ <div className="mb-4 flex flex-wrap gap-2">
50
+ <Button
51
+ type="button"
52
+ variant="outline"
53
+ size="sm"
54
+ onClick={() => setExpanded((v) => !v)}
55
+ >
56
+ {expanded ? 'Hide details' : 'Show more details'}
57
+ </Button>
58
+ <Button
59
+ type="button"
60
+ variant="outline"
61
+ size="sm"
62
+ onClick={() => {
63
+ shellui.closeDrawer();
64
+ shellui.closeModal();
65
+ }}
66
+ >
67
+ Cancel
68
+ </Button>
69
+ <Button
70
+ type="button"
71
+ size="sm"
72
+ onClick={() => {
73
+ shellui.toast({ title: 'Confirmed', type: 'success' });
74
+ shellui.closeDrawer();
75
+ shellui.closeModal();
76
+ }}
77
+ >
78
+ Confirm
79
+ </Button>
80
+ </div>
81
+
82
+ {expanded && (
83
+ <div className="rounded-md border border-border bg-muted/40 p-4 text-sm text-muted-foreground space-y-3">
84
+ <p className="font-medium text-foreground">Expanded details</p>
85
+ <p>
86
+ The iframe reports height over <code className="text-xs">SHELLUI_OVERLAY_SIZE</code>.
87
+ The parent animates to the new size and clamps to the viewport.
88
+ </p>
89
+ <div className="min-h-[22rem] space-y-3 rounded-md border border-dashed border-border/80 bg-background/60 p-4">
90
+ <p>
91
+ This block is intentionally tall (fixed rem height — not vh) so you can see the
92
+ overlay grow when details open, then shrink when you hide them.
93
+ </p>
94
+ <p>
95
+ Line 2 — keep scrolling in the panel if the viewport max is hit; the shell enables
96
+ inner scroll when height is clamped.
97
+ </p>
98
+ <p>Line 3 — dynamic sizing snaps without size animation (no debounce by default).</p>
99
+ <p>Line 4 — manual resize stays off while dynamicSizing is active.</p>
100
+ <p>Line 5 — use Hide details above to collapse and watch the height animate back.</p>
101
+ <p>Line 6 — Confirm / Cancel remain at the top so they never get clipped away.</p>
102
+ <p>Line 7 — end of sample content.</p>
103
+ </div>
104
+ </div>
105
+ )}
106
+ </div>
107
+ );
108
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Centered spinner shown while a dynamic overlay waits for the first size report.
3
+ */
4
+ export function OverlayPendingSpinner() {
5
+ return (
6
+ <div
7
+ className="absolute inset-0 z-20 flex items-center justify-center bg-background"
8
+ aria-busy="true"
9
+ aria-live="polite"
10
+ >
11
+ <div
12
+ className="size-6 shrink-0 animate-spin rounded-full border-2 border-muted-foreground/25 border-t-muted-foreground"
13
+ aria-hidden
14
+ />
15
+ <span className="sr-only">Loading</span>
16
+ </div>
17
+ );
18
+ }