@shellui/core 0.5.0-beta.2 → 0.5.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.
Files changed (70) hide show
  1. package/README.md +5 -5
  2. package/package.json +3 -2
  3. package/schemas/shellui.config.schema.json +10 -2
  4. package/src/app.tsx +8 -4
  5. package/src/components/ContentView.tsx +12 -5
  6. package/src/components/ui/alert-dialog.tsx +1 -1
  7. package/src/components/ui/dialog.tsx +5 -1
  8. package/src/components/ui/dropdown-menu.tsx +39 -4
  9. package/src/components/ui/sheet.tsx +1 -1
  10. package/src/components/ui/sidebar.tsx +60 -20
  11. package/src/components/ui/tabs.tsx +52 -0
  12. package/src/constants/urls.ts +1 -0
  13. package/src/features/auth/AuthProvider.tsx +17 -6
  14. package/src/features/chromeActions/ChromeActionIcons.tsx +261 -0
  15. package/src/features/chromeActions/ChromeActionsDemoView.tsx +149 -0
  16. package/src/features/chromeActions/ChromeActionsHost.tsx +1511 -0
  17. package/src/features/chromeActions/ChromeActionsProvider.tsx +141 -0
  18. package/src/features/chromeActions/chromeActionsStore.spec.ts +61 -0
  19. package/src/features/chromeActions/chromeActionsStore.ts +77 -0
  20. package/src/features/chromeActions/computeActionInsets.spec.ts +360 -0
  21. package/src/features/chromeActions/computeActionInsets.ts +326 -0
  22. package/src/features/chromeActions/index.ts +26 -0
  23. package/src/features/chromeActions/resolveUuidForRemoveIframe.spec.ts +49 -0
  24. package/src/features/config/types.ts +16 -2
  25. package/src/features/layouts/AppLayout.tsx +30 -3
  26. package/src/features/layouts/OverlayShell.tsx +63 -13
  27. package/src/features/layouts/app-bar-inset/AppBarInsetLayout.tsx +22 -0
  28. package/src/features/layouts/appbar/AppBarLayout.tsx +230 -86
  29. package/src/features/layouts/chrome/DesktopChrome.tsx +17 -3
  30. package/src/features/layouts/chrome/InsetMobileRadiusOverlay.tsx +18 -0
  31. package/src/features/layouts/chrome/index.ts +8 -0
  32. package/src/features/layouts/chrome/runtime.ts +73 -0
  33. package/src/features/layouts/chrome/useScrollHideChrome.ts +210 -0
  34. package/src/features/layouts/floating/FloatingBottomDock.tsx +410 -0
  35. package/src/features/layouts/floating/FloatingLayout.tsx +152 -0
  36. package/src/features/layouts/floating/FloatingSidebar.tsx +327 -0
  37. package/src/features/layouts/floating/FloatingStatusScrim.tsx +36 -0
  38. package/src/features/layouts/floating/computeFloatingInsets.spec.ts +83 -0
  39. package/src/features/layouts/floating/computeFloatingInsets.ts +155 -0
  40. package/src/features/layouts/floating/isShellOwnedPath.spec.ts +25 -0
  41. package/src/features/layouts/floating/isShellOwnedPath.ts +17 -0
  42. package/src/features/layouts/floating/layoutChromeStore.spec.ts +138 -0
  43. package/src/features/layouts/floating/layoutChromeStore.ts +209 -0
  44. package/src/features/layouts/floating/scrollChrome.spec.ts +49 -0
  45. package/src/features/layouts/floating/useFloatingChrome.ts +206 -0
  46. package/src/features/layouts/sidebar/SidebarLayout.tsx +119 -37
  47. package/src/features/layouts/sidebar/types.ts +4 -0
  48. package/src/features/layouts/sidebar-inset/SidebarInsetLayout.tsx +15 -0
  49. package/src/features/layouts/windows/WindowsLayout.tsx +240 -110
  50. package/src/features/overlays/ResponsiveModal.tsx +201 -21
  51. package/src/features/overlays/overlaySize.spec.ts +18 -0
  52. package/src/features/overlays/overlaySize.ts +89 -0
  53. package/src/features/settings/SettingsProvider.tsx +36 -9
  54. package/src/features/settings/SettingsView.tsx +6 -6
  55. package/src/features/settings/components/Develop.tsx +33 -13
  56. package/src/features/settings/components/develop/ChromeActionsTestButtons.tsx +63 -0
  57. package/src/features/settings/utils/buildSettingsForPropagation.ts +16 -0
  58. package/src/features/storage/StoragePickerContext.tsx +1 -0
  59. package/src/features/storage/uploads/uploadQueue.spec.ts +56 -1
  60. package/src/features/storage/uploads/uploadQueue.ts +42 -1
  61. package/src/features/theme/applyTheme.ts +23 -5
  62. package/src/hooks/use-mobile.tsx +21 -7
  63. package/src/hooks/use-viewport.ts +40 -0
  64. package/src/i18n/translations/en/settings.json +17 -2
  65. package/src/i18n/translations/fr/settings.json +17 -2
  66. package/src/index.css +473 -12
  67. package/src/index.html +6 -4
  68. package/src/index.ts +8 -0
  69. package/src/routes/components/RouteFallback.tsx +21 -2
  70. package/src/routes/routes.tsx +14 -0
@@ -0,0 +1,261 @@
1
+ /**
2
+ * Built-in glyphs for chrome actions (`icon` name).
3
+ * Image / SVG URLs (http(s), data:, absolute or relative paths) render as <img>.
4
+ */
5
+
6
+ import type { ReactElement } from 'react';
7
+
8
+ type IconProps = {
9
+ className?: string;
10
+ 'data-shellui-chrome-action-animate'?: string;
11
+ };
12
+
13
+ function strokeIcon(
14
+ paths: ReactElement | ReactElement[],
15
+ { className, ...rest }: IconProps,
16
+ size = 20,
17
+ ): ReactElement {
18
+ return (
19
+ <svg
20
+ xmlns="http://www.w3.org/2000/svg"
21
+ width={size}
22
+ height={size}
23
+ viewBox="0 0 24 24"
24
+ fill="none"
25
+ stroke="currentColor"
26
+ strokeWidth="2"
27
+ strokeLinecap="round"
28
+ strokeLinejoin="round"
29
+ className={className}
30
+ aria-hidden
31
+ {...rest}
32
+ >
33
+ {paths}
34
+ </svg>
35
+ );
36
+ }
37
+
38
+ export function ChevronLeftIcon(props: IconProps) {
39
+ return strokeIcon(<path d="m15 18-6-6 6-6" />, props);
40
+ }
41
+
42
+ export function PlusIcon(props: IconProps) {
43
+ return strokeIcon(
44
+ <>
45
+ <path d="M5 12h14" />
46
+ <path d="M12 5v14" />
47
+ </>,
48
+ props,
49
+ 24,
50
+ );
51
+ }
52
+
53
+ export function MoreHorizontalIcon(props: IconProps) {
54
+ return strokeIcon(
55
+ <>
56
+ <circle
57
+ cx="12"
58
+ cy="12"
59
+ r="1"
60
+ />
61
+ <circle
62
+ cx="19"
63
+ cy="12"
64
+ r="1"
65
+ />
66
+ <circle
67
+ cx="5"
68
+ cy="12"
69
+ r="1"
70
+ />
71
+ </>,
72
+ props,
73
+ );
74
+ }
75
+
76
+ export function EditIcon(props: IconProps) {
77
+ return strokeIcon(
78
+ <>
79
+ <path d="M12 20h9" />
80
+ <path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z" />
81
+ </>,
82
+ props,
83
+ );
84
+ }
85
+
86
+ export function ShareIcon(props: IconProps) {
87
+ return strokeIcon(
88
+ <>
89
+ <circle
90
+ cx="18"
91
+ cy="5"
92
+ r="3"
93
+ />
94
+ <circle
95
+ cx="6"
96
+ cy="12"
97
+ r="3"
98
+ />
99
+ <circle
100
+ cx="18"
101
+ cy="19"
102
+ r="3"
103
+ />
104
+ <path d="m8.59 13.51 6.83 3.98" />
105
+ <path d="m15.41 6.51-6.82 3.98" />
106
+ </>,
107
+ props,
108
+ );
109
+ }
110
+
111
+ export function FilterIcon(props: IconProps) {
112
+ return strokeIcon(<polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" />, props);
113
+ }
114
+
115
+ export function ArchiveIcon(props: IconProps) {
116
+ return strokeIcon(
117
+ <>
118
+ <rect
119
+ width="20"
120
+ height="5"
121
+ x="2"
122
+ y="3"
123
+ rx="1"
124
+ />
125
+ <path d="M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8" />
126
+ <path d="M10 12h4" />
127
+ </>,
128
+ props,
129
+ );
130
+ }
131
+
132
+ export function SettingsIcon(props: IconProps) {
133
+ return strokeIcon(
134
+ <>
135
+ <path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" />
136
+ <circle
137
+ cx="12"
138
+ cy="12"
139
+ r="3"
140
+ />
141
+ </>,
142
+ props,
143
+ );
144
+ }
145
+
146
+ export function DeleteIcon(props: IconProps) {
147
+ return strokeIcon(
148
+ <>
149
+ <path d="M3 6h18" />
150
+ <path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" />
151
+ <path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" />
152
+ <line
153
+ x1="10"
154
+ x2="10"
155
+ y1="11"
156
+ y2="17"
157
+ />
158
+ <line
159
+ x1="14"
160
+ x2="14"
161
+ y1="11"
162
+ y2="17"
163
+ />
164
+ </>,
165
+ props,
166
+ );
167
+ }
168
+
169
+ export function StarIcon(props: IconProps) {
170
+ return strokeIcon(
171
+ <polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" />,
172
+ props,
173
+ );
174
+ }
175
+
176
+ export function RefreshIcon(props: IconProps) {
177
+ return strokeIcon(
178
+ <>
179
+ <path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" />
180
+ <path d="M21 3v5h-5" />
181
+ <path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16" />
182
+ <path d="M8 16H3v5" />
183
+ </>,
184
+ props,
185
+ );
186
+ }
187
+
188
+ const BUILTIN: Record<string, (props: IconProps) => ReactElement> = {
189
+ back: ChevronLeftIcon,
190
+ plus: PlusIcon,
191
+ more: MoreHorizontalIcon,
192
+ edit: EditIcon,
193
+ share: ShareIcon,
194
+ filter: FilterIcon,
195
+ archive: ArchiveIcon,
196
+ settings: SettingsIcon,
197
+ delete: DeleteIcon,
198
+ star: StarIcon,
199
+ refresh: RefreshIcon,
200
+ };
201
+
202
+ export function ChromeActionGlyph({
203
+ icon,
204
+ label,
205
+ className,
206
+ animate,
207
+ }: {
208
+ icon?: string;
209
+ label?: string;
210
+ className?: string;
211
+ /** When `icon-rotate`, continuously spins the glyph. */
212
+ animate?: string;
213
+ }) {
214
+ const spinning = animate === 'icon-rotate';
215
+ const glyphClass = [className ?? 'size-4 shrink-0', spinning ? 'animate-spin' : '']
216
+ .filter(Boolean)
217
+ .join(' ');
218
+ const animateAttr = spinning ? { 'data-shellui-chrome-action-animate': 'icon-rotate' } : {};
219
+
220
+ if (!icon) {
221
+ if (!label) return null;
222
+ return (
223
+ <span
224
+ className={`flex items-center justify-center text-xs font-semibold ${glyphClass}`}
225
+ {...animateAttr}
226
+ >
227
+ {label.charAt(0).toUpperCase()}
228
+ </span>
229
+ );
230
+ }
231
+
232
+ if (/^(https?:|data:|\/|\.)/.test(icon) || icon.includes('/')) {
233
+ return (
234
+ <img
235
+ src={icon}
236
+ alt=""
237
+ className={`${glyphClass} object-contain`}
238
+ {...animateAttr}
239
+ />
240
+ );
241
+ }
242
+
243
+ const Builtin = BUILTIN[icon];
244
+ if (Builtin) {
245
+ return (
246
+ <Builtin
247
+ className={glyphClass}
248
+ {...animateAttr}
249
+ />
250
+ );
251
+ }
252
+
253
+ return (
254
+ <span
255
+ className={`flex items-center justify-center text-xs font-semibold ${glyphClass}`}
256
+ {...animateAttr}
257
+ >
258
+ {(label ?? icon).charAt(0).toUpperCase()}
259
+ </span>
260
+ );
261
+ }
@@ -0,0 +1,149 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { shellui } from '@shellui/sdk';
3
+ import { Button } from '../../components/ui/button';
4
+
5
+ type DemoVariant = 'default' | 'updated';
6
+
7
+ function applyDemoActions(variant: DemoVariant): void {
8
+ const updated = variant === 'updated';
9
+ shellui.actions.set({
10
+ variant: updated ? 'secondary' : 'outline',
11
+ back: {
12
+ id: 'demo-back',
13
+ onClick: () => {
14
+ shellui.toast({ title: 'Back clicked (iframe)', type: 'info' });
15
+ },
16
+ },
17
+ title: updated ? 'Inbox · updated' : 'Inbox',
18
+ trailing: [
19
+ {
20
+ id: 'demo-edit',
21
+ label: updated ? 'Rename' : 'Edit',
22
+ icon: 'edit',
23
+ onClick: () => shellui.toast({ title: 'Edit clicked (iframe)', type: 'default' }),
24
+ },
25
+ {
26
+ id: 'demo-share',
27
+ label: 'Share',
28
+ icon: 'share',
29
+ onClick: () => shellui.toast({ title: 'Share clicked (iframe)', type: 'default' }),
30
+ },
31
+ {
32
+ id: 'demo-filter',
33
+ label: 'Filter',
34
+ icon: 'filter',
35
+ onClick: () => shellui.toast({ title: 'Filter clicked (iframe)', type: 'default' }),
36
+ },
37
+ {
38
+ id: 'demo-archive',
39
+ label: 'Archive',
40
+ icon: 'archive',
41
+ variant: updated ? 'destructive' : undefined,
42
+ onClick: () => shellui.toast({ title: 'Archive clicked (iframe)', type: 'default' }),
43
+ },
44
+ ],
45
+ primary: {
46
+ id: 'demo-compose',
47
+ icon: 'plus',
48
+ label: 'Compose',
49
+ onClick: () => shellui.toast({ title: 'Primary FAB clicked (iframe)', type: 'success' }),
50
+ },
51
+ });
52
+ }
53
+
54
+ /**
55
+ * Shell-owned page loaded inside a modal/drawer iframe from Settings → Develop.
56
+ * Exercises `shellui.actions.set/clear` through the real iframe postMessage path.
57
+ */
58
+ export function ChromeActionsDemoView() {
59
+ const [variant, setVariant] = useState<DemoVariant>('default');
60
+ const [ready, setReady] = useState(false);
61
+
62
+ useEffect(() => {
63
+ let cancelled = false;
64
+ void shellui.init().then(() => {
65
+ if (cancelled) return;
66
+ applyDemoActions('default');
67
+ setReady(true);
68
+ });
69
+ return () => {
70
+ cancelled = true;
71
+ shellui.actions.clear();
72
+ };
73
+ }, []);
74
+
75
+ return (
76
+ <div
77
+ data-chrome-actions-demo-root
78
+ className="box-border min-h-full bg-background text-foreground px-5"
79
+ >
80
+ <h1
81
+ className="text-base font-semibold mb-1 pt-4"
82
+ style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
83
+ >
84
+ Chrome actions (iframe)
85
+ </h1>
86
+ <p className="text-sm text-muted-foreground mb-4">
87
+ This page runs inside an iframe and drives floating chrome via{' '}
88
+ <code className="text-xs">shellui.actions.set()</code> /{' '}
89
+ <code className="text-xs">clear()</code>. Clicks round-trip with{' '}
90
+ <code className="text-xs">SHELLUI_ACTION</code>. Top/bottom padding comes from{' '}
91
+ <code className="text-xs">--shellui-inset-*</code> (animated when actions set or clear).
92
+ </p>
93
+
94
+ {!ready ? (
95
+ <p className="text-sm text-muted-foreground">Initializing SDK…</p>
96
+ ) : (
97
+ <div className="mb-4 flex flex-wrap gap-2">
98
+ <Button
99
+ type="button"
100
+ variant="outline"
101
+ size="sm"
102
+ onClick={() => {
103
+ setVariant('default');
104
+ applyDemoActions('default');
105
+ }}
106
+ >
107
+ Set actions
108
+ </Button>
109
+ <Button
110
+ type="button"
111
+ variant="outline"
112
+ size="sm"
113
+ onClick={() => {
114
+ setVariant('updated');
115
+ applyDemoActions('updated');
116
+ }}
117
+ >
118
+ Update actions
119
+ </Button>
120
+ <Button
121
+ type="button"
122
+ variant="outline"
123
+ size="sm"
124
+ onClick={() => shellui.actions.clear()}
125
+ >
126
+ Clear actions
127
+ </Button>
128
+ <Button
129
+ type="button"
130
+ variant="outline"
131
+ size="sm"
132
+ onClick={() => {
133
+ shellui.actions.clear();
134
+ shellui.closeDrawer();
135
+ shellui.closeModal();
136
+ }}
137
+ >
138
+ Close
139
+ </Button>
140
+ </div>
141
+ )}
142
+
143
+ <p className="text-xs text-muted-foreground">
144
+ Current variant: <strong className="text-foreground">{variant}</strong>. Narrow the viewport
145
+ (or open as a drawer on mobile) to see trailing actions collapse into ···.
146
+ </p>
147
+ </div>
148
+ );
149
+ }