@shellui/core 0.5.0-beta.3 → 0.5.1
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/README.md +5 -5
- package/package.json +3 -2
- package/schemas/shellui.config.schema.json +98 -33
- package/src/app.tsx +10 -4
- package/src/components/ContentView.tsx +3 -5
- package/src/components/contentIframeSandbox.spec.ts +25 -0
- package/src/components/contentIframeSandbox.ts +43 -0
- package/src/components/ui/dialog.tsx +5 -1
- package/src/components/ui/dropdown-menu.tsx +39 -4
- package/src/components/ui/sheet.tsx +1 -1
- package/src/components/ui/sidebar.tsx +3 -2
- package/src/components/ui/tabs.tsx +52 -0
- package/src/constants/urls.ts +1 -0
- package/src/features/auth/AuthProvider.tsx +169 -35
- package/src/features/auth/backends/index.ts +2 -0
- package/src/features/auth/backends/shellui.ts +43 -35
- package/src/features/auth/backends/supabase.ts +1 -0
- package/src/features/auth/backends/types.ts +5 -0
- package/src/features/auth/components/LoginView.tsx +5 -1
- package/src/features/auth/components/OAuthCallbackView.tsx +115 -44
- package/src/features/auth/constants/oauth.ts +2 -0
- package/src/features/auth/hooks/useAuth.tsx +4 -0
- package/src/features/auth/utils/authSessionPersistence.spec.ts +93 -0
- package/src/features/auth/utils/authSessionPersistence.ts +138 -0
- package/src/features/auth/utils/authStorageKeys.ts +8 -0
- package/src/features/auth/utils/bffAuthClient.ts +107 -0
- package/src/features/auth/utils/buildOAuthSessionRedirectTo.spec.ts +22 -0
- package/src/features/auth/utils/buildOAuthSessionRedirectTo.ts +17 -0
- package/src/features/auth/utils/buildSessionFromTokenPayload.spec.ts +29 -0
- package/src/features/auth/utils/buildSessionFromTokenPayload.ts +24 -0
- package/src/features/auth/utils/index.ts +18 -3
- package/src/features/auth/utils/isBffAuthEnabled.ts +12 -0
- package/src/features/chromeActions/ChromeActionIcons.tsx +261 -0
- package/src/features/chromeActions/ChromeActionsDemoView.tsx +149 -0
- package/src/features/chromeActions/ChromeActionsHost.tsx +1511 -0
- package/src/features/chromeActions/ChromeActionsProvider.tsx +141 -0
- package/src/features/chromeActions/chromeActionsStore.spec.ts +61 -0
- package/src/features/chromeActions/chromeActionsStore.ts +77 -0
- package/src/features/chromeActions/computeActionInsets.spec.ts +360 -0
- package/src/features/chromeActions/computeActionInsets.ts +326 -0
- package/src/features/chromeActions/index.ts +26 -0
- package/src/features/chromeActions/resolveUuidForRemoveIframe.spec.ts +49 -0
- package/src/features/config/types.ts +49 -2
- package/src/features/layouts/AppLayout.tsx +4 -4
- package/src/features/layouts/OverlayShell.tsx +60 -12
- package/src/features/layouts/app-bar-inset/AppBarInsetLayout.tsx +1 -1
- package/src/features/layouts/appbar/AppBarLayout.tsx +194 -89
- package/src/features/layouts/chrome/DesktopChrome.tsx +17 -3
- package/src/features/layouts/chrome/InsetMobileRadiusOverlay.tsx +18 -0
- package/src/features/layouts/chrome/index.ts +8 -0
- package/src/features/layouts/chrome/runtime.ts +73 -0
- package/src/features/layouts/chrome/useScrollHideChrome.ts +210 -0
- package/src/features/layouts/floating/FloatingBottomDock.tsx +410 -0
- package/src/features/layouts/floating/FloatingLayout.tsx +31 -21
- package/src/features/layouts/floating/FloatingStatusScrim.tsx +36 -0
- package/src/features/layouts/floating/computeFloatingInsets.spec.ts +5 -5
- package/src/features/layouts/floating/computeFloatingInsets.ts +64 -12
- package/src/features/layouts/floating/isShellOwnedPath.spec.ts +2 -0
- package/src/features/layouts/floating/isShellOwnedPath.ts +1 -0
- package/src/features/layouts/floating/layoutChromeStore.spec.ts +138 -0
- package/src/features/layouts/floating/layoutChromeStore.ts +169 -6
- package/src/features/layouts/floating/useFloatingChrome.ts +20 -30
- package/src/features/layouts/sidebar/SidebarLayout.tsx +87 -31
- package/src/features/layouts/sidebar-inset/SidebarInsetLayout.tsx +1 -1
- package/src/features/layouts/windows/WindowsLayout.tsx +240 -110
- package/src/features/messaging/MessagingSecurityBootstrap.tsx +19 -0
- package/src/features/messaging/deriveAllowedMessageOrigins.spec.ts +86 -0
- package/src/features/messaging/deriveAllowedMessageOrigins.ts +74 -0
- package/src/features/modal/ModalContext.spec.ts +13 -2
- package/src/features/modal/validateAndNormalizeUrl.ts +9 -23
- package/src/features/overlays/ResponsiveModal.tsx +201 -21
- package/src/features/overlays/overlaySize.spec.ts +18 -0
- package/src/features/overlays/overlaySize.ts +89 -0
- package/src/features/security/trustedFrames.spec.ts +129 -0
- package/src/features/security/trustedFrames.ts +79 -0
- package/src/features/security/urlAllowlist.spec.ts +99 -0
- package/src/features/security/urlAllowlist.ts +122 -0
- package/src/features/settings/SettingsProvider.tsx +38 -54
- package/src/features/settings/components/Develop.tsx +2 -0
- package/src/features/settings/components/develop/ChromeActionsTestButtons.tsx +63 -0
- package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +23 -1
- package/src/features/settings/utils/buildSettingsForPropagation.ts +7 -0
- package/src/features/storage/StorageBridge.spec.ts +82 -0
- package/src/features/storage/StorageBridge.tsx +25 -3
- package/src/features/storage/StoragePickerContext.tsx +3 -4
- package/src/features/storage/uploads/uploadQueue.spec.ts +56 -1
- package/src/features/storage/uploads/uploadQueue.ts +44 -6
- package/src/features/theme/applyTheme.ts +23 -5
- package/src/hooks/use-mobile.tsx +21 -7
- package/src/i18n/translations/en/settings.json +9 -0
- package/src/i18n/translations/fr/settings.json +9 -0
- package/src/index.css +264 -124
- package/src/index.html +6 -4
- package/src/index.ts +8 -0
- package/src/routes/components/NavigationItemRoute.tsx +30 -15
- package/src/routes/components/RouteFallback.tsx +15 -0
- package/src/routes/routes.tsx +14 -0
- package/src/routes/utils/navigationRouteAccess.spec.ts +85 -0
- package/src/routes/utils/navigationRouteAccess.ts +43 -0
- package/src/features/auth/utils/clearStoredAuthSession.spec.ts +0 -23
- package/src/features/auth/utils/clearStoredAuthSession.ts +0 -10
- package/src/features/auth/utils/persistAuthSession.spec.ts +0 -35
- package/src/features/auth/utils/persistAuthSession.ts +0 -12
- package/src/features/auth/utils/readStoredAuthSession.spec.ts +0 -34
- package/src/features/auth/utils/readStoredAuthSession.ts +0 -14
- package/src/features/layouts/floating/FloatingFadeMask.tsx +0 -22
- package/src/features/layouts/floating/FloatingTabBar.tsx +0 -437
- package/src/features/layouts/floating/FloatingTabIndicator.tsx +0 -216
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AuthSession } from '../types';
|
|
2
|
+
import { buildSessionFromParams } from './buildSessionFromParams';
|
|
3
|
+
|
|
4
|
+
export const tokenPayloadToUrlParams = (
|
|
5
|
+
payload: Record<string, unknown> | null | undefined,
|
|
6
|
+
): URLSearchParams => {
|
|
7
|
+
const params = new URLSearchParams();
|
|
8
|
+
if (!payload) return params;
|
|
9
|
+
if (typeof payload.access_token === 'string') params.set('access_token', payload.access_token);
|
|
10
|
+
if (typeof payload.refresh_token === 'string') params.set('refresh_token', payload.refresh_token);
|
|
11
|
+
if (typeof payload.expires_at === 'number' || typeof payload.expires_at === 'string') {
|
|
12
|
+
params.set('expires_at', String(payload.expires_at));
|
|
13
|
+
}
|
|
14
|
+
if (typeof payload.expires_in === 'number' || typeof payload.expires_in === 'string') {
|
|
15
|
+
params.set('expires_in', String(payload.expires_in));
|
|
16
|
+
}
|
|
17
|
+
if (typeof payload.token_type === 'string') params.set('token_type', payload.token_type);
|
|
18
|
+
return params;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const buildSessionFromTokenPayload = (
|
|
22
|
+
payload: Record<string, unknown> | null | undefined,
|
|
23
|
+
nowSeconds: number,
|
|
24
|
+
): AuthSession | null => buildSessionFromParams(tokenPayloadToUrlParams(payload), nowSeconds);
|
|
@@ -4,7 +4,12 @@ export {
|
|
|
4
4
|
getShellUILoginDeviceId,
|
|
5
5
|
} from './clientLoginContext';
|
|
6
6
|
export { buildAuthUrlWithNext } from './buildAuthUrlWithNext';
|
|
7
|
+
export { buildOAuthSessionRedirectTo } from './buildOAuthSessionRedirectTo';
|
|
7
8
|
export { buildSessionFromParams } from './buildSessionFromParams';
|
|
9
|
+
export {
|
|
10
|
+
buildSessionFromTokenPayload,
|
|
11
|
+
tokenPayloadToUrlParams,
|
|
12
|
+
} from './buildSessionFromTokenPayload';
|
|
8
13
|
export { hashHasOAuthTokens } from './hashHasOAuthTokens';
|
|
9
14
|
export {
|
|
10
15
|
AuthRequestError,
|
|
@@ -19,7 +24,19 @@ export {
|
|
|
19
24
|
redirectCliCallbackError,
|
|
20
25
|
redirectToCliCallback,
|
|
21
26
|
} from './cliCallback';
|
|
22
|
-
export {
|
|
27
|
+
export {
|
|
28
|
+
clearStoredAuthSession,
|
|
29
|
+
persistAuthProfile,
|
|
30
|
+
persistAuthSession,
|
|
31
|
+
readStoredAuthSession,
|
|
32
|
+
} from './authSessionPersistence';
|
|
33
|
+
export type { PersistedAuthProfile } from './authSessionPersistence';
|
|
34
|
+
export {
|
|
35
|
+
establishBffAuthSession,
|
|
36
|
+
logoutBffAuthSession,
|
|
37
|
+
refreshBffAuthSession,
|
|
38
|
+
} from './bffAuthClient';
|
|
39
|
+
export { isBffAuthEnabledFromConfig, useIsBffAuthEnabled } from './isBffAuthEnabled';
|
|
23
40
|
export { decodeJwtPayload } from './decodeJwtPayload';
|
|
24
41
|
export { formatProviderLabel } from './formatProviderLabel';
|
|
25
42
|
export { getAccessTokenFromSdkSettings, getUserFromSdkSettings } from './getUserFromSdkSettings';
|
|
@@ -32,6 +49,4 @@ export { isTokenAutoRefreshDisabled } from './isTokenAutoRefreshDisabled';
|
|
|
32
49
|
export { normalizeAuthSettings } from './normalizeAuthSettings';
|
|
33
50
|
export { normalizeNextPath } from './normalizeNextPath';
|
|
34
51
|
export { normalizeRedirectPath } from './normalizeRedirectPath';
|
|
35
|
-
export { persistAuthSession } from './persistAuthSession';
|
|
36
|
-
export { readStoredAuthSession } from './readStoredAuthSession';
|
|
37
52
|
export { toAuthSessionFromSettingsUser } from './toAuthSessionFromSettingsUser';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useConfig } from '../../config/useConfig';
|
|
2
|
+
|
|
3
|
+
/** Whether same-origin BFF auth routes should handle refresh (HttpOnly cookie). */
|
|
4
|
+
export const isBffAuthEnabledFromConfig = (
|
|
5
|
+
security: { bffAuth?: { enabled?: boolean } } | undefined,
|
|
6
|
+
): boolean => security?.bffAuth?.enabled === true;
|
|
7
|
+
|
|
8
|
+
/** React hook — reads `security.bffAuth.enabled` from shell config. */
|
|
9
|
+
export const useIsBffAuthEnabled = (): boolean => {
|
|
10
|
+
const { config } = useConfig();
|
|
11
|
+
return isBffAuthEnabledFromConfig(config.security);
|
|
12
|
+
};
|
|
@@ -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
|
+
}
|