@tearleads/windowing 0.2.40 → 0.2.41
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 +4 -3
- package/display/DisplayProperties.css +94 -0
- package/display/DisplayProperties.d.ts +6 -4
- package/display/DisplayProperties.js +23 -5
- package/display/DisplayProperties.js.map +1 -1
- package/docs/appearance.md +44 -4
- package/docs/screensavers.md +3 -1
- package/docs/windows.md +7 -1
- package/index.d.ts +4 -1
- package/index.js +8 -5
- package/index.js.map +1 -1
- package/menu/useLongPress.d.ts +15 -2
- package/menu/useLongPress.js +43 -14
- package/menu/useLongPress.js.map +1 -1
- package/package.json +1 -1
- package/routed/RoutedPaneNav.css +2 -1
- package/screensaver/ScreensaverProvider.d.ts +2 -2
- package/screensaver/ScreensaverProvider.js +4 -2
- package/screensaver/ScreensaverProvider.js.map +1 -1
- package/tray/SystemTray.css +20 -0
- package/tray/SystemTray.d.ts +23 -0
- package/tray/SystemTray.js +54 -0
- package/tray/SystemTray.js.map +1 -0
- package/tray/SystemTrayProvider.d.ts +26 -0
- package/tray/SystemTrayProvider.js +62 -0
- package/tray/SystemTrayProvider.js.map +1 -0
- package/tray/systemTrayDefinition.d.ts +19 -0
- package/tray/systemTrayDefinition.js +2 -0
- package/tray/systemTrayDefinition.js.map +1 -0
package/README.md
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
App-agnostic window management for React: window state (open, focus order,
|
|
4
4
|
minimize/maximize, a per-window route and Back stack), window chrome (title
|
|
5
5
|
bar, menu bar, toolbar, sidebar, status bar, resize handles), the menu and
|
|
6
|
-
sidebar primitives that chrome renders with, a taskbar's start menu
|
|
7
|
-
switch, and
|
|
8
|
-
(iPad / phone) shell.
|
|
6
|
+
sidebar primitives that chrome renders with, a taskbar's start menu, theme
|
|
7
|
+
switch, and system tray of apps the user can turn off, and a launcher that
|
|
8
|
+
runs a set of mini-apps in windows or in the routed (iPad / phone) shell.
|
|
9
9
|
|
|
10
10
|
The package knows nothing about the applications that run inside its windows.
|
|
11
11
|
It depends only on React, react-dom, and Phosphor icons, which draw the
|
|
@@ -68,6 +68,7 @@ desktop surface must be a positioned container.
|
|
|
68
68
|
- [Themes, wallpapers, and styles](./docs/appearance.md)
|
|
69
69
|
- [Themes](./docs/appearance.md#themes)
|
|
70
70
|
- [Wallpapers and Display Properties](./docs/appearance.md#wallpapers-and-display-properties)
|
|
71
|
+
- [System tray](./docs/appearance.md#system-tray)
|
|
71
72
|
- [Styles](./docs/appearance.md#styles)
|
|
72
73
|
- [Pluggable screensavers, lasers, and PIN unlock](./docs/screensavers.md)
|
|
73
74
|
- [Publishing](./docs/publishing.md)
|
|
@@ -112,3 +112,97 @@
|
|
|
112
112
|
text-overflow: ellipsis;
|
|
113
113
|
white-space: nowrap;
|
|
114
114
|
}
|
|
115
|
+
|
|
116
|
+
/* System Tray: one row per tray app, its name and an on/off switch. The rows
|
|
117
|
+
* stay narrow so a wide window does not set a switch far from its name. */
|
|
118
|
+
.display-properties-tray-apps {
|
|
119
|
+
display: flex;
|
|
120
|
+
flex-direction: column;
|
|
121
|
+
gap: var(--space-2xs);
|
|
122
|
+
max-width: 24rem;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.display-properties-tray-app {
|
|
126
|
+
display: flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
gap: var(--space-sm);
|
|
129
|
+
padding: var(--space-xs) var(--space-sm);
|
|
130
|
+
border-radius: var(--app-radius-control);
|
|
131
|
+
cursor: pointer;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.display-properties-tray-app:hover {
|
|
135
|
+
background: var(--app-hover-surface);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.display-properties-tray-app .display-properties-label {
|
|
139
|
+
flex: 1 1 auto;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.display-properties-tray-app-icon {
|
|
143
|
+
flex: 0 0 auto;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* A checkbox drawn as a sliding switch: a pill track and a round thumb that
|
|
147
|
+
* moves to the end and fills with the text color when on. */
|
|
148
|
+
.display-properties-switch {
|
|
149
|
+
--display-properties-switch-height: 1.25rem;
|
|
150
|
+
--display-properties-switch-thumb: calc(
|
|
151
|
+
var(--display-properties-switch-height) -
|
|
152
|
+
2 *
|
|
153
|
+
var(--border-width) -
|
|
154
|
+
4px
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
position: relative;
|
|
158
|
+
flex: 0 0 auto;
|
|
159
|
+
box-sizing: border-box;
|
|
160
|
+
width: calc(var(--display-properties-switch-height) * 1.8);
|
|
161
|
+
height: var(--display-properties-switch-height);
|
|
162
|
+
margin: 0;
|
|
163
|
+
border: var(--border-width) solid var(--color-dark);
|
|
164
|
+
border-radius: calc(var(--display-properties-switch-height) / 2);
|
|
165
|
+
background: transparent;
|
|
166
|
+
cursor: pointer;
|
|
167
|
+
appearance: none;
|
|
168
|
+
transition: background var(--transition);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.display-properties-switch::before {
|
|
172
|
+
position: absolute;
|
|
173
|
+
top: 2px;
|
|
174
|
+
left: 2px;
|
|
175
|
+
width: var(--display-properties-switch-thumb);
|
|
176
|
+
height: var(--display-properties-switch-thumb);
|
|
177
|
+
border-radius: 50%;
|
|
178
|
+
background: var(--color-dark);
|
|
179
|
+
content: "";
|
|
180
|
+
transition:
|
|
181
|
+
transform var(--transition),
|
|
182
|
+
background var(--transition);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.display-properties-switch:checked {
|
|
186
|
+
background: var(--color-dark);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.display-properties-switch:checked::before {
|
|
190
|
+
background: var(--color-light);
|
|
191
|
+
transform: translateX(calc(var(--display-properties-switch-height) * 0.8));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.display-properties-switch:focus-visible {
|
|
195
|
+
outline: 2px solid var(--color-dark);
|
|
196
|
+
outline-offset: 2px;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/* Let the platform draw its high-contrast checkbox. */
|
|
200
|
+
@media (forced-colors: active) {
|
|
201
|
+
.display-properties-switch {
|
|
202
|
+
appearance: auto;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.display-properties-switch::before {
|
|
206
|
+
content: none;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The display settings, for a host's Display Properties mini-app: the
|
|
3
|
-
* desktop's background, from the nearest {@link WallpaperProvider}
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* desktop's background, from the nearest {@link WallpaperProvider}; the color
|
|
4
|
+
* theme, from the nearest {@link ThemeProvider}; and a switch per tray app,
|
|
5
|
+
* from the nearest {@link SystemTrayProvider}. Each choice applies at once. A
|
|
6
|
+
* section whose provider is missing, or that offers one theme or no tray
|
|
7
|
+
* apps, is left out. It has no toolbar actions, so its window shows no
|
|
8
|
+
* toolbar row.
|
|
7
9
|
*/
|
|
8
10
|
export declare function DisplayProperties(): import("react").JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useId } from "react";
|
|
3
3
|
import { useOptionalTheme } from "../theme/ThemeProvider.js";
|
|
4
|
+
import { useOptionalSystemTray } from "../tray/SystemTrayProvider.js";
|
|
4
5
|
import { useOptionalWallpaper } from "../wallpaper/WallpaperProvider.js";
|
|
5
6
|
import { wallpaperStyle } from "../wallpaper/wallpapers.js";
|
|
6
7
|
import { useSuppressWindowToolbar } from "../window/CurrentWindowContext.js";
|
|
@@ -22,15 +23,32 @@ function ThemeSection() {
|
|
|
22
23
|
}
|
|
23
24
|
return (_jsxs("fieldset", { className: "display-properties-section", children: [_jsx("legend", { children: "Theme" }), _jsx("div", { className: "display-properties-themes", children: theme.themes.map((option) => (_jsxs("label", { className: "display-properties-theme", children: [_jsx("input", { checked: option.id === theme.activeTheme.id, className: "display-properties-input", name: name, onChange: () => theme.setTheme(option.id), type: "radio", value: option.id }), _jsx("span", { className: "display-properties-label", children: option.label })] }, option.id))) })] }));
|
|
24
25
|
}
|
|
26
|
+
function SystemTraySection() {
|
|
27
|
+
const tray = useOptionalSystemTray();
|
|
28
|
+
if (!tray || tray.definition.order.length === 0) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const { definition, isEnabled, setEnabled } = tray;
|
|
32
|
+
return (_jsxs("fieldset", { className: "display-properties-section", children: [_jsx("legend", { children: "System Tray" }), _jsx("div", { className: "display-properties-tray-apps", children: definition.order.map((id) => {
|
|
33
|
+
const app = definition.apps[id];
|
|
34
|
+
if (!app) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const { icon: Icon, title } = app;
|
|
38
|
+
return (_jsxs("label", { className: "display-properties-tray-app", children: [Icon && (_jsx(Icon, { "aria-hidden": "true", className: "display-properties-tray-app-icon", focusable: "false", size: 16 })), _jsx("span", { className: "display-properties-label", children: title }), _jsx("input", { "aria-checked": isEnabled(id), checked: isEnabled(id), className: "display-properties-switch", onChange: (event) => setEnabled(id, event.currentTarget.checked), role: "switch", type: "checkbox" })] }, id));
|
|
39
|
+
}) })] }));
|
|
40
|
+
}
|
|
25
41
|
/**
|
|
26
42
|
* The display settings, for a host's Display Properties mini-app: the
|
|
27
|
-
* desktop's background, from the nearest {@link WallpaperProvider}
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
43
|
+
* desktop's background, from the nearest {@link WallpaperProvider}; the color
|
|
44
|
+
* theme, from the nearest {@link ThemeProvider}; and a switch per tray app,
|
|
45
|
+
* from the nearest {@link SystemTrayProvider}. Each choice applies at once. A
|
|
46
|
+
* section whose provider is missing, or that offers one theme or no tray
|
|
47
|
+
* apps, is left out. It has no toolbar actions, so its window shows no
|
|
48
|
+
* toolbar row.
|
|
31
49
|
*/
|
|
32
50
|
export function DisplayProperties() {
|
|
33
51
|
useSuppressWindowToolbar(true);
|
|
34
|
-
return (_jsxs("div", { className: "display-properties", children: [_jsx(BackgroundSection, {}), _jsx(ThemeSection, {})] }));
|
|
52
|
+
return (_jsxs("div", { className: "display-properties", children: [_jsx(BackgroundSection, {}), _jsx(ThemeSection, {}), _jsx(SystemTraySection, {})] }));
|
|
35
53
|
}
|
|
36
54
|
//# sourceMappingURL=DisplayProperties.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisplayProperties.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/display/DisplayProperties.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,4BAA4B,CAAC;AACpC,OAAO,yBAAyB,CAAC;AAEjC,SAAS,iBAAiB;IACxB,MAAM,SAAS,GAAG,oBAAoB,EAAE,CAAC;IACzC,MAAM,IAAI,GAAG,KAAK,EAAE,CAAC;IACrB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CACL,oBAAU,SAAS,EAAC,4BAA4B,aAC9C,0CAA2B,EAC3B,cAAK,SAAS,EAAC,+BAA+B,YAC3C,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACpC,iBAAO,SAAS,EAAC,8BAA8B,aAC7C,gBACE,OAAO,EAAE,MAAM,CAAC,EAAE,KAAK,SAAS,CAAC,eAAe,CAAC,EAAE,EACnD,SAAS,EA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,MAAM,CAAC,KAAK,GAAQ,KATjB,MAAM,CAAC,EAAE,CAUlD,CACT,CAAC,GACE,IACG,CACZ,CAAC;AACJ,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"DisplayProperties.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/display/DisplayProperties.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,4BAA4B,CAAC;AACpC,OAAO,yBAAyB,CAAC;AAEjC,SAAS,iBAAiB;IACxB,MAAM,SAAS,GAAG,oBAAoB,EAAE,CAAC;IACzC,MAAM,IAAI,GAAG,KAAK,EAAE,CAAC;IACrB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CACL,oBAAU,SAAS,EAAC,4BAA4B,aAC9C,0CAA2B,EAC3B,cAAK,SAAS,EAAC,+BAA+B,YAC3C,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACpC,iBAAO,SAAS,EAAC,8BAA8B,aAC7C,gBACE,OAAO,EAAE,MAAM,CAAC,EAAE,KAAK,SAAS,CAAC,eAAe,CAAC,EAAE,EACnD,SAAS,EAAC,0BAA0B,EACpC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,EACjD,IAAI,EAAC,OAAO,EACZ,KAAK,EAAE,MAAM,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I,CAAC,CAAC;IAC/B,OAAO,CACL,eAAK,SAAS,EAAC,oBAAoB,aACjC,KAAC,iBAAiB,KAAG,EACrB,KAAC,YAAY,KAAG,EAChB,KAAC,iBAAiB,KAAG,IACjB,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useId } from \"react\";\nimport { useOptionalTheme } from \"../theme/ThemeProvider\";\nimport { useOptionalSystemTray } from \"../tray/SystemTrayProvider\";\nimport { useOptionalWallpaper } from \"../wallpaper/WallpaperProvider\";\nimport { wallpaperStyle } from \"../wallpaper/wallpapers\";\nimport { useSuppressWindowToolbar } from \"../window/CurrentWindowContext\";\nimport \"../wallpaper/Wallpaper.css\";\nimport \"./DisplayProperties.css\";\n\nfunction BackgroundSection() {\n const wallpaper = useOptionalWallpaper();\n const name = useId();\n if (!wallpaper) {\n return null;\n }\n return (\n <fieldset className=\"display-properties-section\">\n <legend>Background</legend>\n <div className=\"display-properties-wallpapers\">\n {wallpaper.wallpapers.map((option) => (\n <label className=\"display-properties-wallpaper\" key={option.id}>\n <input\n checked={option.id === wallpaper.activeWallpaper.id}\n className=\"display-properties-input\"\n name={name}\n onChange={() => wallpaper.setWallpaper(option.id)}\n type=\"radio\"\n value={option.id}\n />\n <span\n aria-hidden=\"true\"\n className=\"display-properties-swatch wallpaper-pattern\"\n data-pattern={option.tile ? \"\" : undefined}\n style={wallpaperStyle(option)}\n />\n <span className=\"display-properties-label\">{option.label}</span>\n </label>\n ))}\n </div>\n </fieldset>\n );\n}\n\nfunction ThemeSection() {\n const theme = useOptionalTheme();\n const name = useId();\n if (!theme || theme.themes.length < 2) {\n return null;\n }\n return (\n <fieldset className=\"display-properties-section\">\n <legend>Theme</legend>\n <div className=\"display-properties-themes\">\n {theme.themes.map((option) => (\n <label className=\"display-properties-theme\" key={option.id}>\n <input\n checked={option.id === theme.activeTheme.id}\n className=\"display-properties-input\"\n name={name}\n onChange={() => theme.setTheme(option.id)}\n type=\"radio\"\n value={option.id}\n />\n <span className=\"display-properties-label\">{option.label}</span>\n </label>\n ))}\n </div>\n </fieldset>\n );\n}\n\nfunction SystemTraySection() {\n const tray = useOptionalSystemTray();\n if (!tray || tray.definition.order.length === 0) {\n return null;\n }\n const { definition, isEnabled, setEnabled } = tray;\n return (\n <fieldset className=\"display-properties-section\">\n <legend>System Tray</legend>\n <div className=\"display-properties-tray-apps\">\n {definition.order.map((id) => {\n const app = definition.apps[id];\n if (!app) {\n return null;\n }\n const { icon: Icon, title } = app;\n return (\n <label className=\"display-properties-tray-app\" key={id}>\n {Icon && (\n <Icon\n aria-hidden=\"true\"\n className=\"display-properties-tray-app-icon\"\n focusable=\"false\"\n size={16}\n />\n )}\n <span className=\"display-properties-label\">{title}</span>\n <input\n aria-checked={isEnabled(id)}\n checked={isEnabled(id)}\n className=\"display-properties-switch\"\n onChange={(event) =>\n setEnabled(id, event.currentTarget.checked)\n }\n role=\"switch\"\n type=\"checkbox\"\n />\n </label>\n );\n })}\n </div>\n </fieldset>\n );\n}\n\n/**\n * The display settings, for a host's Display Properties mini-app: the\n * desktop's background, from the nearest {@link WallpaperProvider}; the color\n * theme, from the nearest {@link ThemeProvider}; and a switch per tray app,\n * from the nearest {@link SystemTrayProvider}. Each choice applies at once. A\n * section whose provider is missing, or that offers one theme or no tray\n * apps, is left out. It has no toolbar actions, so its window shows no\n * toolbar row.\n */\nexport function DisplayProperties() {\n useSuppressWindowToolbar(true);\n return (\n <div className=\"display-properties\">\n <BackgroundSection />\n <ThemeSection />\n <SystemTraySection />\n </div>\n );\n}\n"]}
|
package/docs/appearance.md
CHANGED
|
@@ -109,10 +109,50 @@ and set it. `DesktopWallpaper` paints its `wallpaper` prop instead when given
|
|
|
109
109
|
one, and nothing without a provider.
|
|
110
110
|
|
|
111
111
|
`DisplayProperties` is the content of a host's Display Properties mini-app: a
|
|
112
|
-
Background section listing the provider's wallpapers as previews,
|
|
113
|
-
section listing the theme provider's themes
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
Background section listing the provider's wallpapers as previews, a Theme
|
|
113
|
+
section listing the theme provider's themes, and a System Tray section with a
|
|
114
|
+
switch per tray app (see [System tray](#system-tray)). Each choice applies at
|
|
115
|
+
once; a section whose provider is missing, a theme list of one, or a tray
|
|
116
|
+
without apps is left out. Both Tearleads and a2f0.net open it from their
|
|
117
|
+
desktop's context menu.
|
|
118
|
+
|
|
119
|
+
## System tray
|
|
120
|
+
|
|
121
|
+
A host's tray apps are the small controls in its taskbar's corner, such as
|
|
122
|
+
`ThemeSwitch` or a sync status button. A `SystemTrayDefinition` lists them as
|
|
123
|
+
`{ title, icon?, component }` by id, with their order. `SystemTrayProvider`
|
|
124
|
+
takes the definition and a `storageKey` under which the apps the user turned
|
|
125
|
+
off persist, so every app starts on and one the host adds later appears.
|
|
126
|
+
Render `SystemTray` in the taskbar's corner:
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
const TRAY: SystemTrayDefinition<"layout" | "theme"> = {
|
|
130
|
+
apps: {
|
|
131
|
+
layout: { component: LayoutSwitch, icon: AppWindowIcon, title: "Layout" },
|
|
132
|
+
theme: { component: ThemeSwitch, icon: ThemeInvertIcon, title: "Theme" },
|
|
133
|
+
},
|
|
134
|
+
order: ["layout", "theme"],
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
<SystemTrayProvider definition={TRAY} storageKey="notes.tray.disabled">
|
|
138
|
+
<Desktop />
|
|
139
|
+
<footer className="taskbar">
|
|
140
|
+
<StartMenu items={START_ITEMS} />
|
|
141
|
+
<SystemTray menuItems={[openDisplayProperties]} />
|
|
142
|
+
</footer>
|
|
143
|
+
</SystemTrayProvider>;
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
`SystemTray` shows the apps left on, in order, and renders nothing without a
|
|
147
|
+
provider. An app may render nothing where it does not apply, and takes no
|
|
148
|
+
room then. Right-clicking an app, pressing the context-menu key on it, or
|
|
149
|
+
holding a finger on it opens its menu: "Disable" with the app's title, then
|
|
150
|
+
the `menuItems` the host passes as `{ id, label, icon?, onSelect }`, such as
|
|
151
|
+
one that opens Display Properties, where every app has a switch to turn it
|
|
152
|
+
back on. `useSystemTray` and `useOptionalSystemTray` read the definition and
|
|
153
|
+
each app's state and turn apps on and off. Define the definition once,
|
|
154
|
+
outside render, and mount one provider above every taskbar that shares the
|
|
155
|
+
choice.
|
|
116
156
|
|
|
117
157
|
## Styles
|
|
118
158
|
|
package/docs/screensavers.md
CHANGED
|
@@ -35,7 +35,9 @@ session or grace timer. Styles are included by the public import.
|
|
|
35
35
|
|
|
36
36
|
`useScreensaver()` returns stable `start()` and `stop()` callbacks and an
|
|
37
37
|
`isActive` boolean (artwork or a PIN gate is visible). It throws outside the
|
|
38
|
-
provider
|
|
38
|
+
provider; `useOptionalScreensaver()` returns `null` there instead, for a
|
|
39
|
+
control that hides where the host mounted no screensaver. Repeated starts
|
|
40
|
+
while active are ignored. Without a PIN, `stop()`
|
|
39
41
|
exits immediately and intentionally cancels input isolation, including a
|
|
40
42
|
pending release tail; reserve it for explicit host control or teardown, not an
|
|
41
43
|
effect watching `isActive`. With a PIN, `stop()` requests the PIN gate instead
|
package/docs/windows.md
CHANGED
|
@@ -76,7 +76,13 @@ disabled, announced as `aria-busy`, and shows a turning ring instead of its icon
|
|
|
76
76
|
A registration that also passes `onCancel` keeps the running Refresh reachable
|
|
77
77
|
but inert to a click: right-click, the context-menu key, or a touch long press
|
|
78
78
|
opens a menu offering Cancel Refresh. `useLongPress` is the touch half of that
|
|
79
|
-
gesture, exported for any element whose `onContextMenu` opens a menu.
|
|
79
|
+
gesture, exported for any element whose `onContextMenu` opens a menu. It
|
|
80
|
+
dispatches `contextmenu` on the element holding its handlers; pass
|
|
81
|
+
`{ emulateRightClick: true }` to deliver it as a mouse right-click arrives: a
|
|
82
|
+
secondary-button `mousedown`, then `contextmenu`, on the element the finger
|
|
83
|
+
pressed (or, if a re-render replaced it, the one now under the finger). Open
|
|
84
|
+
menus then close as on any press outside them, and a control inside the
|
|
85
|
+
wrapper sees the gesture first. The system tray uses it.
|
|
80
86
|
|
|
81
87
|
Windows with an `appId` reserve the toolbar and offer route-history Back.
|
|
82
88
|
With `historyBack={false}`, the row appears when actions register, then stays.
|
package/index.d.ts
CHANGED
|
@@ -32,12 +32,15 @@ export { RoutedPane, type RoutedPaneProps } from "./routed/RoutedPane.js";
|
|
|
32
32
|
export { RoutedPaneOverlayHostProvider, type RoutedPaneOverlayHostValue, useRoutedPaneOverlayHost, } from "./routed/RoutedPaneOverlayHost.js";
|
|
33
33
|
export type { SubscribeKeyboardVisibility } from "./routed/useMobileKeyboardVisible.js";
|
|
34
34
|
export { LaserScreensaver } from "./screensaver/LaserScreensaver.js";
|
|
35
|
-
export { type ScreensaverControls, ScreensaverProvider, type ScreensaverProviderProps, useScreensaver, } from "./screensaver/ScreensaverProvider.js";
|
|
35
|
+
export { type ScreensaverControls, ScreensaverProvider, type ScreensaverProviderProps, useOptionalScreensaver, useScreensaver, } from "./screensaver/ScreensaverProvider.js";
|
|
36
36
|
export type { ScreensaverPinVerifier } from "./screensaver/screensaverPinVerifier.js";
|
|
37
37
|
export { SidebarResizeHandle, useSidebarResize } from "./sidebar/SidebarResize.js";
|
|
38
38
|
export { ThemeProvider, useOptionalTheme, useTheme, } from "./theme/ThemeProvider.js";
|
|
39
39
|
export { ThemeSwitch } from "./theme/ThemeSwitch.js";
|
|
40
40
|
export type { DefaultTheme, ThemeDefinition, ThemeScheme, } from "./theme/themes.js";
|
|
41
|
+
export { SystemTray, type SystemTrayMenuItem } from "./tray/SystemTray.js";
|
|
42
|
+
export { SystemTrayProvider, useOptionalSystemTray, useSystemTray, } from "./tray/SystemTrayProvider.js";
|
|
43
|
+
export type { SystemTrayDefinition, TrayAppDefinition, } from "./tray/systemTrayDefinition.js";
|
|
41
44
|
export { DesktopWallpaper, type DesktopWallpaperProps, } from "./wallpaper/DesktopWallpaper.js";
|
|
42
45
|
export { BLOCKS_WALLPAPER, CHEVRON_WALLPAPER, HARLEQUIN_WALLPAPER, HONEYCOMB_WALLPAPER, PLAIN_WALLPAPER, TRIANGLES_WALLPAPER, } from "./wallpaper/tessellations.js";
|
|
43
46
|
export { useOptionalWallpaper, useWallpaper, WallpaperProvider, } from "./wallpaper/WallpaperProvider.js";
|
package/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import "./tokens.css";
|
|
2
2
|
// The public windowing API: window state, window chrome and its registration
|
|
3
3
|
// hooks, the menu and sidebar primitives the chrome renders with, a taskbar's
|
|
4
|
-
// start menu
|
|
5
|
-
// mini-apps that shows them in windows or in the routed (iPad /
|
|
6
|
-
// and desktop icons that open them, with a storage adapter for
|
|
7
|
-
// over a wallpaper chosen in Display Properties, plus a
|
|
4
|
+
// start menu, theme switch, and system tray, the icons the chrome draws, a
|
|
5
|
+
// launcher of mini-apps that shows them in windows or in the routed (iPad /
|
|
6
|
+
// phone) shell, and desktop icons that open them, with a storage adapter for
|
|
7
|
+
// their layout, over a wallpaper chosen in Display Properties, plus a
|
|
8
|
+
// host-supplied screensaver.
|
|
8
9
|
export { createRequiredContext, } from "./createRequiredContext.js";
|
|
9
10
|
export { DesktopIcons, } from "./desktop/DesktopIcons.js";
|
|
10
11
|
export { createMemoryDesktopStateStorage, createOpfsDesktopStateStorage, } from "./desktop/desktopStateStorage.js";
|
|
@@ -35,10 +36,12 @@ export { useLongPress } from "./menu/useLongPress.js";
|
|
|
35
36
|
export { RoutedPane } from "./routed/RoutedPane.js";
|
|
36
37
|
export { RoutedPaneOverlayHostProvider, useRoutedPaneOverlayHost, } from "./routed/RoutedPaneOverlayHost.js";
|
|
37
38
|
export { LaserScreensaver } from "./screensaver/LaserScreensaver.js";
|
|
38
|
-
export { ScreensaverProvider, useScreensaver, } from "./screensaver/ScreensaverProvider.js";
|
|
39
|
+
export { ScreensaverProvider, useOptionalScreensaver, useScreensaver, } from "./screensaver/ScreensaverProvider.js";
|
|
39
40
|
export { SidebarResizeHandle, useSidebarResize } from "./sidebar/SidebarResize.js";
|
|
40
41
|
export { ThemeProvider, useOptionalTheme, useTheme, } from "./theme/ThemeProvider.js";
|
|
41
42
|
export { ThemeSwitch } from "./theme/ThemeSwitch.js";
|
|
43
|
+
export { SystemTray } from "./tray/SystemTray.js";
|
|
44
|
+
export { SystemTrayProvider, useOptionalSystemTray, useSystemTray, } from "./tray/SystemTrayProvider.js";
|
|
42
45
|
export { DesktopWallpaper, } from "./wallpaper/DesktopWallpaper.js";
|
|
43
46
|
export { BLOCKS_WALLPAPER, CHEVRON_WALLPAPER, HARLEQUIN_WALLPAPER, HONEYCOMB_WALLPAPER, PLAIN_WALLPAPER, TRIANGLES_WALLPAPER, } from "./wallpaper/tessellations.js";
|
|
44
47
|
export { useOptionalWallpaper, useWallpaper, WallpaperProvider, } from "./wallpaper/WallpaperProvider.js";
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../home/runner/work/tearleads/tearleads/packages/windowing/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,6EAA6E;AAC7E,8EAA8E;AAC9E,yEAAyE;AACzE,8EAA8E;AAC9E,6EAA6E;AAC7E,mFAAmF;AACnF,OAAO,EACL,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,YAAY,GAEb,MAAM,wBAAwB,CAAC;AAKhC,OAAO,EACL,+BAA+B,EAC/B,6BAA6B,GAG9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAEL,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,0BAA0B,EAE1B,4BAA4B,EAC5B,0BAA0B,EAC1B,uBAAuB,EACvB,kCAAkC,GACnC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,eAAe,EAGf,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AkB,EAQlB,mBAAmB,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["import \"./tokens.css\";\n\n// The public windowing API: window state, window chrome and its registration\n// hooks, the menu and sidebar primitives the chrome renders with, a taskbar's\n// start menu and theme switch, the icons the chrome draws, a launcher of\n// mini-apps that shows them in windows or in the routed (iPad / phone) shell,\n// and desktop icons that open them, with a storage adapter for their layout,\n// over a wallpaper chosen in Display Properties, plus a host-supplied screensaver.\nexport {\n createRequiredContext,\n type RequiredContext,\n} from \"./createRequiredContext\";\nexport type { DesktopIconMenuItem } from \"./desktop/DesktopIconMenu\";\nexport {\n DesktopIcons,\n type DesktopIconsProps,\n} from \"./desktop/DesktopIcons\";\nexport type {\n DesktopIconPosition,\n DesktopState,\n} from \"./desktop/desktopState\";\nexport {\n createMemoryDesktopStateStorage,\n createOpfsDesktopStateStorage,\n type DesktopStateStorage,\n type OpfsDesktopStateStorageOptions,\n} from \"./desktop/desktopStateStorage\";\nexport { DisplayProperties } from \"./display/DisplayProperties\";\nexport {\n type WindowingIcons,\n WindowingIconsProvider,\n} from \"./icons/WindowingIcons\";\nexport type { WindowingIcon, WindowingIconProps } from \"./icons/windowingIcon\";\nexport {\n ROUTED_TABLET_BREAKPOINT_PX,\n ROUTED_TABLET_QUERY,\n WINDOWED_LAYOUT_MIN_WIDTH_PX,\n} from \"./launcher/breakpoints\";\nexport {\n type LauncherNavigationActions,\n LauncherNavigationProvider,\n type LauncherNavigationState,\n useLauncherNavigationActions,\n useLauncherNavigationState,\n useMiniAppRouteSegments,\n useOptionalLauncherNavigationState,\n} from \"./launcher/LauncherNavigationProvider\";\nexport {\n isLauncherAppId,\n type LauncherDefinition,\n type MiniAppDefinition,\n resolveLauncherHomeAppId,\n resolveLauncherOrder,\n} from \"./launcher/launcherDefinition\";\nexport {\n MiniAppRouteSegmentsProvider,\n useMiniAppWindowRouteSegments,\n} from \"./launcher/MiniAppRouteSegmentsContext\";\nexport { type MiniAppBoundary, MiniAppWindow } from \"./launcher/MiniAppWindow\";\nexport {\n NavigationModeOverrideProvider,\n useNavigationModeOverride,\n useOptionalNavigationModeOverride,\n} from \"./launcher/NavigationModeOverrideProvider\";\nexport { NavigationModeSwitch } from \"./launcher/NavigationModeSwitch\";\nexport {\n isWindowedLayoutEligible,\n type NavigationEnvironment,\n type NavigationMode,\n readNavigationEnvironment,\n resolveNavigationMode,\n} from \"./launcher/navigationMode\";\nexport {\n DEFAULT_MINI_APP_POSITION,\n type MiniAppWindowPlacement,\n type OpenMiniAppRequest,\n type PlaceMiniAppWindow,\n} from \"./launcher/openMiniAppWindow\";\nexport {\n buildMiniAppPath,\n type LauncherRoute,\n parseLauncherRoute,\n} from \"./launcher/routePaths\";\nexport {\n resolveActiveLauncherRoute,\n useActiveLauncherRoute,\n} from \"./launcher/useActiveLauncherRoute\";\nexport { useCompactRoutedMode } from \"./launcher/useCompactRoutedMode\";\nexport {\n type MiniAppRouteSetOptions,\n useMiniAppRouteState,\n} from \"./launcher/useMiniAppRouteState\";\nexport { useNavigationMode } from \"./launcher/useNavigationMode\";\nexport { useNavigationModeDocumentAttribute } from \"./launcher/useNavigationModeDocumentAttribute\";\nexport {\n useRoutedLayoutActive,\n useWindowedLayoutActive,\n} from \"./launcher/useRoutedLayoutActive\";\nexport {\n type RoutedLayoutTier,\n useRoutedLayoutTier,\n} from \"./launcher/useRoutedLayoutTier\";\nexport { Menu, type MenuPosition } from \"./menu/Menu\";\nexport { MenuItem, type MenuItemProps } from \"./menu/MenuItem\";\nexport {\n StartMenu,\n type StartMenuItem,\n type StartMenuProps,\n} from \"./menu/StartMenu\";\nexport {\n type ContextMenuState,\n useContextMenuPositionState,\n useContextMenuState,\n} from \"./menu/useContextMenuState\";\nexport { useLongPress } from \"./menu/useLongPress\";\nexport { RoutedPane, type RoutedPaneProps } from \"./routed/RoutedPane\";\nexport {\n RoutedPaneOverlayHostProvider,\n type RoutedPaneOverlayHostValue,\n useRoutedPaneOverlayHost,\n} from \"./routed/RoutedPaneOverlayHost\";\nexport type { SubscribeKeyboardVisibility } from \"./routed/useMobileKeyboardVisible\";\nexport { LaserScreensaver } from \"./screensaver/LaserScreensaver\";\nexport {\n type ScreensaverControls,\n ScreensaverProvider,\n type ScreensaverProviderProps,\n useScreensaver,\n} from \"./screensaver/ScreensaverProvider\";\nexport type { ScreensaverPinVerifier } from \"./screensaver/screensaverPinVerifier\";\nexport { SidebarResizeHandle, useSidebarResize } from \"./sidebar/SidebarResize\";\nexport {\n ThemeProvider,\n useOptionalTheme,\n useTheme,\n} from \"./theme/ThemeProvider\";\nexport { ThemeSwitch } from \"./theme/ThemeSwitch\";\nexport type {\n DefaultTheme,\n ThemeDefinition,\n ThemeScheme,\n} from \"./theme/themes\";\nexport {\n DesktopWallpaper,\n type DesktopWallpaperProps,\n} from \"./wallpaper/DesktopWallpaper\";\nexport {\n BLOCKS_WALLPAPER,\n CHEVRON_WALLPAPER,\n HARLEQUIN_WALLPAPER,\n HONEYCOMB_WALLPAPER,\n PLAIN_WALLPAPER,\n TRIANGLES_WALLPAPER,\n} from \"./wallpaper/tessellations\";\nexport {\n useOptionalWallpaper,\n useWallpaper,\n WallpaperProvider,\n} from \"./wallpaper/WallpaperProvider\";\nexport type {\n WallpaperDefinition,\n WallpaperTile,\n} from \"./wallpaper/wallpapers\";\nexport {\n CurrentWindowProvider,\n useCurrentWindow,\n useSuppressWindowToolbar,\n useWindowBackground,\n useWindowContentSize,\n} from \"./window/CurrentWindowContext\";\nexport { Window, type WindowContentBoundary } from \"./window/Window\";\nexport { WindowTitleBarActionButtons } from \"./window/WindowChromeActions\";\nexport { WindowCloseButton } from \"./window/WindowCloseButton\";\nexport {\n useWindowBackAction,\n useWindowBackActionValue,\n useWindowFileMenuItem,\n useWindowRefreshMenuItem,\n useWindowRefreshMenuItemValue,\n useWindowTitleBarAction,\n useWindowTitleBarActions,\n useWindowToolbarReservation,\n useWindowViewMenuItem,\n WindowMenuProvider,\n} from \"./window/WindowMenuContext\";\nexport {\n hasWindowSidebar,\n useRegisteredWindowSidebar,\n useWindowSidebar,\n WindowSidebarProvider,\n} from \"./window/WindowSidebarContext\";\nexport {\n findTopWindow,\n useWindowActions,\n useWindowStateData,\n type WindowCreateOptions,\n type WindowEntry,\n type WindowGeometry,\n type WindowPosition,\n type WindowSize,\n type WindowStateActions,\n type WindowStateData,\n WindowStateProvider,\n} from \"./window/WindowStateProvider\";\nexport { WindowToolBar } from \"./window/WindowToolBar\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../home/runner/work/tearleads/tearleads/packages/windowing/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,6EAA6E;AAC7E,8EAA8E;AAC9E,2EAA2E;AAC3E,4EAA4E;AAC5E,6EAA6E;AAC7E,sEAAsE;AACtE,6BAA6B;AAC7B,OAAO,EACL,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,YAAY,GAEb,MAAM,wBAAwB,CAAC;AAKhC,OAAO,EACL,+BAA+B,EAC/B,6BAA6B,GAG9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAEL,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,0BAA0B,EAE1B,4BAA4B,EAC5B,0BAA0B,EAC1B,uBAAuB,EACvB,kCAAkC,GACnC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACL,eAAe,EAGf,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAwB,aAAa,EAAE,MAAM,0BAA0B,CAAC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B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC","sourcesContent":["import \"./tokens.css\";\n\n// The public windowing API: window state, window chrome and its registration\n// hooks, the menu and sidebar primitives the chrome renders with, a taskbar's\n// start menu, theme switch, and system tray, the icons the chrome draws, a\n// launcher of mini-apps that shows them in windows or in the routed (iPad /\n// phone) shell, and desktop icons that open them, with a storage adapter for\n// their layout, over a wallpaper chosen in Display Properties, plus a\n// host-supplied screensaver.\nexport {\n createRequiredContext,\n type RequiredContext,\n} from \"./createRequiredContext\";\nexport type { DesktopIconMenuItem } from \"./desktop/DesktopIconMenu\";\nexport {\n DesktopIcons,\n type DesktopIconsProps,\n} from \"./desktop/DesktopIcons\";\nexport type {\n DesktopIconPosition,\n DesktopState,\n} from \"./desktop/desktopState\";\nexport {\n createMemoryDesktopStateStorage,\n createOpfsDesktopStateStorage,\n type DesktopStateStorage,\n type OpfsDesktopStateStorageOptions,\n} from \"./desktop/desktopStateStorage\";\nexport { DisplayProperties } from \"./display/DisplayProperties\";\nexport {\n type WindowingIcons,\n WindowingIconsProvider,\n} from \"./icons/WindowingIcons\";\nexport type { WindowingIcon, WindowingIconProps } from \"./icons/windowingIcon\";\nexport {\n ROUTED_TABLET_BREAKPOINT_PX,\n ROUTED_TABLET_QUERY,\n WINDOWED_LAYOUT_MIN_WIDTH_PX,\n} from \"./launcher/breakpoints\";\nexport {\n type LauncherNavigationActions,\n LauncherNavigationProvider,\n type LauncherNavigationState,\n useLauncherNavigationActions,\n useLauncherNavigationState,\n useMiniAppRouteSegments,\n useOptionalLauncherNavigationState,\n} from \"./launcher/LauncherNavigationProvider\";\nexport {\n isLauncherAppId,\n type LauncherDefinition,\n type MiniAppDefinition,\n resolveLauncherHomeAppId,\n resolveLauncherOrder,\n} from \"./launcher/launcherDefinition\";\nexport {\n MiniAppRouteSegmentsProvider,\n useMiniAppWindowRouteSegments,\n} from \"./launcher/MiniAppRouteSegmentsContext\";\nexport { type MiniAppBoundary, MiniAppWindow } from \"./launcher/MiniAppWindow\";\nexport {\n NavigationModeOverrideProvider,\n useNavigationModeOverride,\n useOptionalNavigationModeOverride,\n} from \"./launcher/NavigationModeOverrideProvider\";\nexport { NavigationModeSwitch } from \"./launcher/NavigationModeSwitch\";\nexport {\n isWindowedLayoutEligible,\n type NavigationEnvironment,\n type NavigationMode,\n readNavigationEnvironment,\n resolveNavigationMode,\n} from \"./launcher/navigationMode\";\nexport {\n DEFAULT_MINI_APP_POSITION,\n type MiniAppWindowPlacement,\n type OpenMiniAppRequest,\n type PlaceMiniAppWindow,\n} from \"./launcher/openMiniAppWindow\";\nexport {\n buildMiniAppPath,\n type LauncherRoute,\n parseLauncherRoute,\n} from \"./launcher/routePaths\";\nexport {\n resolveActiveLauncherRoute,\n useActiveLauncherRoute,\n} from \"./launcher/useActiveLauncherRoute\";\nexport { useCompactRoutedMode } from \"./launcher/useCompactRoutedMode\";\nexport {\n type MiniAppRouteSetOptions,\n useMiniAppRouteState,\n} from \"./launcher/useMiniAppRouteState\";\nexport { useNavigationMode } from \"./launcher/useNavigationMode\";\nexport { useNavigationModeDocumentAttribute } from \"./launcher/useNavigationModeDocumentAttribute\";\nexport {\n useRoutedLayoutActive,\n useWindowedLayoutActive,\n} from \"./launcher/useRoutedLayoutActive\";\nexport {\n type RoutedLayoutTier,\n useRoutedLayoutTier,\n} from \"./launcher/useRoutedLayoutTier\";\nexport { Menu, type MenuPosition } from \"./menu/Menu\";\nexport { MenuItem, type MenuItemProps } from \"./menu/MenuItem\";\nexport {\n StartMenu,\n type StartMenuItem,\n type StartMenuProps,\n} from \"./menu/StartMenu\";\nexport {\n type ContextMenuState,\n useContextMenuPositionState,\n useContextMenuState,\n} from \"./menu/useContextMenuState\";\nexport { useLongPress } from \"./menu/useLongPress\";\nexport { RoutedPane, type RoutedPaneProps } from \"./routed/RoutedPane\";\nexport {\n RoutedPaneOverlayHostProvider,\n type RoutedPaneOverlayHostValue,\n useRoutedPaneOverlayHost,\n} from \"./routed/RoutedPaneOverlayHost\";\nexport type { SubscribeKeyboardVisibility } from \"./routed/useMobileKeyboardVisible\";\nexport { LaserScreensaver } from \"./screensaver/LaserScreensaver\";\nexport {\n type ScreensaverControls,\n ScreensaverProvider,\n type ScreensaverProviderProps,\n useOptionalScreensaver,\n useScreensaver,\n} from \"./screensaver/ScreensaverProvider\";\nexport type { ScreensaverPinVerifier } from \"./screensaver/screensaverPinVerifier\";\nexport { SidebarResizeHandle, useSidebarResize } from \"./sidebar/SidebarResize\";\nexport {\n ThemeProvider,\n useOptionalTheme,\n useTheme,\n} from \"./theme/ThemeProvider\";\nexport { ThemeSwitch } from \"./theme/ThemeSwitch\";\nexport type {\n DefaultTheme,\n ThemeDefinition,\n ThemeScheme,\n} from \"./theme/themes\";\nexport { SystemTray, type SystemTrayMenuItem } from \"./tray/SystemTray\";\nexport {\n SystemTrayProvider,\n useOptionalSystemTray,\n useSystemTray,\n} from \"./tray/SystemTrayProvider\";\nexport type {\n SystemTrayDefinition,\n TrayAppDefinition,\n} from \"./tray/systemTrayDefinition\";\nexport {\n DesktopWallpaper,\n type DesktopWallpaperProps,\n} from \"./wallpaper/DesktopWallpaper\";\nexport {\n BLOCKS_WALLPAPER,\n CHEVRON_WALLPAPER,\n HARLEQUIN_WALLPAPER,\n HONEYCOMB_WALLPAPER,\n PLAIN_WALLPAPER,\n TRIANGLES_WALLPAPER,\n} from \"./wallpaper/tessellations\";\nexport {\n useOptionalWallpaper,\n useWallpaper,\n WallpaperProvider,\n} from \"./wallpaper/WallpaperProvider\";\nexport type {\n WallpaperDefinition,\n WallpaperTile,\n} from \"./wallpaper/wallpapers\";\nexport {\n CurrentWindowProvider,\n useCurrentWindow,\n useSuppressWindowToolbar,\n useWindowBackground,\n useWindowContentSize,\n} from \"./window/CurrentWindowContext\";\nexport { Window, type WindowContentBoundary } from \"./window/Window\";\nexport { WindowTitleBarActionButtons } from \"./window/WindowChromeActions\";\nexport { WindowCloseButton } from \"./window/WindowCloseButton\";\nexport {\n useWindowBackAction,\n useWindowBackActionValue,\n useWindowFileMenuItem,\n useWindowRefreshMenuItem,\n useWindowRefreshMenuItemValue,\n useWindowTitleBarAction,\n useWindowTitleBarActions,\n useWindowToolbarReservation,\n useWindowViewMenuItem,\n WindowMenuProvider,\n} from \"./window/WindowMenuContext\";\nexport {\n hasWindowSidebar,\n useRegisteredWindowSidebar,\n useWindowSidebar,\n WindowSidebarProvider,\n} from \"./window/WindowSidebarContext\";\nexport {\n findTopWindow,\n useWindowActions,\n useWindowStateData,\n type WindowCreateOptions,\n type WindowEntry,\n type WindowGeometry,\n type WindowPosition,\n type WindowSize,\n type WindowStateActions,\n type WindowStateData,\n WindowStateProvider,\n} from \"./window/WindowStateProvider\";\nexport { WindowToolBar } from \"./window/WindowToolBar\";\n"]}
|
package/menu/useLongPress.d.ts
CHANGED
|
@@ -5,10 +5,23 @@ interface LongPressHandlers {
|
|
|
5
5
|
onPointerMove: (event: ReactPointerEvent<HTMLElement>) => void;
|
|
6
6
|
onPointerUp: (event: ReactPointerEvent<HTMLElement>) => void;
|
|
7
7
|
}
|
|
8
|
+
interface LongPressOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Deliver the gesture as a mouse right-click arrives: a secondary-button
|
|
11
|
+
* `mousedown`, then `contextmenu`, on the element the finger pressed rather
|
|
12
|
+
* than the element holding these handlers. Open menus then close as they do
|
|
13
|
+
* on any press outside them, and a control inside a wrapper sees the event
|
|
14
|
+
* first, before it bubbles to the wrapper's menu. If the pressed element
|
|
15
|
+
* left the page during the hold (an icon redrawn for a new state), the
|
|
16
|
+
* element now under the finger receives both, or else the holder.
|
|
17
|
+
*/
|
|
18
|
+
emulateRightClick?: boolean | undefined;
|
|
19
|
+
}
|
|
8
20
|
/**
|
|
9
21
|
* Returns pointer handlers that, when a **touch** pointer is held still for
|
|
10
22
|
* {@link LONG_PRESS_DELAY_MS}, dispatch a native `contextmenu` event on the
|
|
11
|
-
*
|
|
23
|
+
* element holding them at the touch point (or, with `emulateRightClick`, a
|
|
24
|
+
* right-click's `mousedown` and `contextmenu` on the pressed element).
|
|
12
25
|
*
|
|
13
26
|
* Dispatching the real event (rather than calling a handler directly) means the
|
|
14
27
|
* element's existing `onContextMenu` — the same one a right-click triggers —
|
|
@@ -25,5 +38,5 @@ interface LongPressHandlers {
|
|
|
25
38
|
* Pass `enabled: false` (e.g. when no context-menu handler is wired) to make the
|
|
26
39
|
* returned handlers no-ops.
|
|
27
40
|
*/
|
|
28
|
-
export declare function useLongPress(enabled: boolean): LongPressHandlers;
|
|
41
|
+
export declare function useLongPress(enabled: boolean, options?: LongPressOptions): LongPressHandlers;
|
|
29
42
|
export {};
|
package/menu/useLongPress.js
CHANGED
|
@@ -4,10 +4,38 @@ const LONG_PRESS_DELAY_MS = 450;
|
|
|
4
4
|
const LONG_PRESS_MOVE_TOLERANCE_PX = 10;
|
|
5
5
|
/** Drop the click-suppressor if no synthesized click arrives within this window. */
|
|
6
6
|
const SYNTHESIZED_CLICK_WINDOW_MS = 700;
|
|
7
|
+
// The element to deliver to: the pressed element, else (when a re-render
|
|
8
|
+
// replaced it) the one now under the finger inside the holder, else the
|
|
9
|
+
// holder; null when even the holder has left the page.
|
|
10
|
+
function resolvePressedElement(pressed, holder, point) {
|
|
11
|
+
if (pressed?.isConnected) {
|
|
12
|
+
return pressed;
|
|
13
|
+
}
|
|
14
|
+
const underFinger = pressed
|
|
15
|
+
? holder.ownerDocument.elementFromPoint(point.x, point.y)
|
|
16
|
+
: null;
|
|
17
|
+
if (underFinger && holder.contains(underFinger)) {
|
|
18
|
+
return underFinger;
|
|
19
|
+
}
|
|
20
|
+
return holder.isConnected ? holder : null;
|
|
21
|
+
}
|
|
22
|
+
function deliverLongPress(element, point, emulateRightClick) {
|
|
23
|
+
const init = {
|
|
24
|
+
bubbles: true,
|
|
25
|
+
cancelable: true,
|
|
26
|
+
clientX: point.x,
|
|
27
|
+
clientY: point.y,
|
|
28
|
+
};
|
|
29
|
+
if (emulateRightClick) {
|
|
30
|
+
element.dispatchEvent(new MouseEvent("mousedown", { ...init, button: 2, buttons: 2 }));
|
|
31
|
+
}
|
|
32
|
+
element.dispatchEvent(new MouseEvent("contextmenu", init));
|
|
33
|
+
}
|
|
7
34
|
/**
|
|
8
35
|
* Returns pointer handlers that, when a **touch** pointer is held still for
|
|
9
36
|
* {@link LONG_PRESS_DELAY_MS}, dispatch a native `contextmenu` event on the
|
|
10
|
-
*
|
|
37
|
+
* element holding them at the touch point (or, with `emulateRightClick`, a
|
|
38
|
+
* right-click's `mousedown` and `contextmenu` on the pressed element).
|
|
11
39
|
*
|
|
12
40
|
* Dispatching the real event (rather than calling a handler directly) means the
|
|
13
41
|
* element's existing `onContextMenu` — the same one a right-click triggers —
|
|
@@ -24,7 +52,8 @@ const SYNTHESIZED_CLICK_WINDOW_MS = 700;
|
|
|
24
52
|
* Pass `enabled: false` (e.g. when no context-menu handler is wired) to make the
|
|
25
53
|
* returned handlers no-ops.
|
|
26
54
|
*/
|
|
27
|
-
export function useLongPress(enabled) {
|
|
55
|
+
export function useLongPress(enabled, options) {
|
|
56
|
+
const emulateRightClick = options?.emulateRightClick === true;
|
|
28
57
|
const timerRef = useRef(null);
|
|
29
58
|
const originRef = useRef(null);
|
|
30
59
|
const removeClickSuppressorRef = useRef(null);
|
|
@@ -70,21 +99,21 @@ export function useLongPress(enabled) {
|
|
|
70
99
|
return;
|
|
71
100
|
}
|
|
72
101
|
clearTimer();
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
const
|
|
102
|
+
const point = { x: event.clientX, y: event.clientY };
|
|
103
|
+
originRef.current = point;
|
|
104
|
+
const holder = event.currentTarget;
|
|
105
|
+
const pressed = emulateRightClick && event.target instanceof Element
|
|
106
|
+
? event.target
|
|
107
|
+
: null;
|
|
77
108
|
timerRef.current = setTimeout(() => {
|
|
78
109
|
timerRef.current = null;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
clientY,
|
|
85
|
-
}));
|
|
110
|
+
const element = resolvePressedElement(pressed, holder, point);
|
|
111
|
+
if (element) {
|
|
112
|
+
armClickSuppressor();
|
|
113
|
+
deliverLongPress(element, point, emulateRightClick);
|
|
114
|
+
}
|
|
86
115
|
}, LONG_PRESS_DELAY_MS);
|
|
87
|
-
}, [armClickSuppressor, clearTimer, enabled]);
|
|
116
|
+
}, [armClickSuppressor, clearTimer, emulateRightClick, enabled]);
|
|
88
117
|
const onPointerMove = useCallback((event) => {
|
|
89
118
|
const origin = originRef.current;
|
|
90
119
|
if (!origin) {
|
package/menu/useLongPress.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLongPress.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/menu/useLongPress.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,SAAS,EACT,MAAM,GACP,MAAM,OAAO,CAAC;AAEf,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,sFAAsF;AACtF,MAAM,4BAA4B,GAAG,EAAE,CAAC;AACxC,oFAAoF;AACpF,MAAM,2BAA2B,GAAG,GAAG,CAAC;AASxC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,YAAY,CAAC,OAAgB;IAC3C,MAAM,QAAQ,GAAG,MAAM,CAAuC,IAAI,CAAC,CAAC;IACpE,MAAM,SAAS,GAAG,MAAM,CAAkC,IAAI,CAAC,CAAC;IAChE,MAAM,wBAAwB,GAAG,MAAM,CAAsB,IAAI,CAAC,CAAC;IAEnE,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;QAClC,IAAI,QAAQ,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YAC9B,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC/B,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;QAC1B,CAAC;QACD,SAAS,CAAC,OAAO,GAAG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,CACb,CAAC;IAEF,OAAO;QACL,eAAe,EAAE,UAAU;QAC3B,aAAa;QACb,aAAa;QACb,WAAW,EAAE,UAAU;KACxB,CAAC;AACJ,CAAC","sourcesContent":["import {\n type PointerEvent as ReactPointerEvent,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\n\nconst LONG_PRESS_DELAY_MS = 450;\n/** Cancel the press if the finger drifts past this many px (a scroll, not a hold). */\nconst LONG_PRESS_MOVE_TOLERANCE_PX = 10;\n/** Drop the click-suppressor if no synthesized click arrives within this window. */\nconst SYNTHESIZED_CLICK_WINDOW_MS = 700;\n\ninterface LongPressHandlers {\n onPointerCancel: (event: ReactPointerEvent<HTMLElement>) => void;\n onPointerDown: (event: ReactPointerEvent<HTMLElement>) => void;\n onPointerMove: (event: ReactPointerEvent<HTMLElement>) => void;\n onPointerUp: (event: ReactPointerEvent<HTMLElement>) => void;\n}\n\n/**\n * Returns pointer handlers that, when a **touch** pointer is held still for\n * {@link LONG_PRESS_DELAY_MS}, dispatch a native `contextmenu` event on the\n * pressed element at the touch point.\n *\n * Dispatching the real event (rather than calling a handler directly) means the\n * element's existing `onContextMenu` — the same one a right-click triggers —\n * fires with a genuine event, so touch reuses the desktop context-menu path\n * verbatim. Mouse and pen pointers are ignored so right-click stays the desktop\n * affordance.\n *\n * After the long press fires we register a one-shot capturing `click` listener\n * on `window` to swallow the click the browser synthesizes on touch release —\n * `preventDefault()` on `pointerup` does NOT suppress that click per the Pointer\n * Events spec, so without this the element's `onClick` (navigate/select) would\n * also run.\n *\n * Pass `enabled: false` (e.g. when no context-menu handler is wired) to make the\n * returned handlers no-ops.\n */\nexport function useLongPress(enabled: boolean): LongPressHandlers {\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const originRef = useRef<{ x: number; y: number } | null>(null);\n const removeClickSuppressorRef = useRef<(() => void) | null>(null);\n\n const clearTimer = useCallback(() => {\n if (timerRef.current !== null) {\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n originRef.current = null;\n }, []);\n\n // Swallow exactly the next click (the one the browser synthesizes from the\n // touch release after a long press) and then detach. A timeout detaches the\n // suppressor if that click never arrives, so a later genuine tap still works.\n const armClickSuppressor = useCallback(() => {\n removeClickSuppressorRef.current?.();\n\n let fallbackTimer: ReturnType<typeof setTimeout> | null = null;\n const onClickCapture = (clickEvent: MouseEvent) => {\n clickEvent.preventDefault();\n clickEvent.stopPropagation();\n removeClickSuppressorRef.current?.();\n };\n\n const remove = () => {\n window.removeEventListener(\"click\", onClickCapture, true);\n if (fallbackTimer !== null) {\n clearTimeout(fallbackTimer);\n fallbackTimer = null;\n }\n removeClickSuppressorRef.current = null;\n };\n\n removeClickSuppressorRef.current = remove;\n window.addEventListener(\"click\", onClickCapture, true);\n fallbackTimer = setTimeout(remove, SYNTHESIZED_CLICK_WINDOW_MS);\n }, []);\n\n // Tear down on unmount, and also when `enabled` flips off mid-press so a\n // scheduled long-press timer / click suppressor never fires after the hook\n // is disabled.\n useEffect(\n () => () => {\n clearTimer();\n removeClickSuppressorRef.current?.();\n },\n [clearTimer, enabled],\n );\n\n const onPointerDown = useCallback(\n (event: ReactPointerEvent<HTMLElement>) => {\n if (!enabled || event.pointerType !== \"touch\") {\n return;\n }\n\n clearTimer();\n originRef.current = { x: event.clientX, y: event.clientY };\n const element = event.currentTarget;\n const clientX = event.clientX;\n const clientY = event.clientY;\n timerRef.current = setTimeout(() => {\n timerRef.current = null;\n armClickSuppressor();\n element.dispatchEvent(\n new MouseEvent(\"contextmenu\", {\n bubbles: true,\n cancelable: true,\n clientX,\n clientY,\n }),\n );\n }, LONG_PRESS_DELAY_MS);\n },\n [armClickSuppressor, clearTimer, enabled],\n );\n\n const onPointerMove = useCallback(\n (event: ReactPointerEvent<HTMLElement>) => {\n const origin = originRef.current;\n if (!origin) {\n return;\n }\n\n const movedTooFar =\n Math.abs(event.clientX - origin.x) > LONG_PRESS_MOVE_TOLERANCE_PX ||\n Math.abs(event.clientY - origin.y) > LONG_PRESS_MOVE_TOLERANCE_PX;\n if (movedTooFar) {\n clearTimer();\n }\n },\n [clearTimer],\n );\n\n return {\n onPointerCancel: clearTimer,\n onPointerDown,\n onPointerMove,\n onPointerUp: clearTimer,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useLongPress.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/menu/useLongPress.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,SAAS,EACT,MAAM,GACP,MAAM,OAAO,CAAC;AAEf,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,sFAAsF;AACtF,MAAM,4BAA4B,GAAG,EAAE,CAAC;AACxC,oFAAoF;AACpF,MAAM,2BAA2B,GAAG,GAAG,CAAC;AA2BxC,yEAAyE;AACzE,wEAAwE;AACxE,uDAAuD;AACvD,SAAS,qBAAqB,CAC5B,OAAuB,EACvB,MAAmB,EACnB,KAAY;IAEZ,IAAI,OAAO,EAAE,WAAW,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,MAAM,WAAW,GAAG,OAAO;QACzB,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;QACzD,CAAC,CAAC,IAAI,CAAC;IACT,IAAI,WAAW,IAAI,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAChD,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5C,CAAC;AAED,SAAS,gBAAgB,CACvB,OAAgB,EAChB,KAAY,EACZ,iBAA0B;IAE1B,MAAM,IAAI,GAAG;QACX,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,CAAC;QAChB,OAAO,EAAE,KAAK,CAAC,CAAC;KACjB,CA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C,CAAC,KAAK,CAAC,MAAM;YACd,CAAC,CAAC,IAAI,CAAC;QACX,QAAQ,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YACjC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;YACxB,MAAM,OAAO,GAAG,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;YAC9D,IAAI,OAAO,EAAE,CAAC;gBACZ,kBAAkB,EAAE,CAAC;gBACrB,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;YACtD,CAAC;QACH,CAAC,EAAE,mBAAmB,CAAC,CAAC;IAC1B,CAAC,EACD,CAAC,kBAAkB,EAAE,UAAU,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAC7D,CAAC;IAEF,MAAM,aAAa,GAAG,WAAW,CAC/B,CAAC,KAAqC,EAAE,EAAE;QACxC,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO;QACT,CAAC;QAED,MAAM,WAAW,GACf,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,4BAA4B;YACjE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,4BAA4B,CAAC;QACpE,IAAI,WAAW,EAAE,CAAC;YAChB,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC,EACD,CAAC,UAAU,CAAC,CACb,CAAC;IAEF,OAAO;QACL,eAAe,EAAE,UAAU;QAC3B,aAAa;QACb,aAAa;QACb,WAAW,EAAE,UAAU;KACxB,CAAC;AACJ,CAAC","sourcesContent":["import {\n type PointerEvent as ReactPointerEvent,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\n\nconst LONG_PRESS_DELAY_MS = 450;\n/** Cancel the press if the finger drifts past this many px (a scroll, not a hold). */\nconst LONG_PRESS_MOVE_TOLERANCE_PX = 10;\n/** Drop the click-suppressor if no synthesized click arrives within this window. */\nconst SYNTHESIZED_CLICK_WINDOW_MS = 700;\n\ninterface LongPressHandlers {\n onPointerCancel: (event: ReactPointerEvent<HTMLElement>) => void;\n onPointerDown: (event: ReactPointerEvent<HTMLElement>) => void;\n onPointerMove: (event: ReactPointerEvent<HTMLElement>) => void;\n onPointerUp: (event: ReactPointerEvent<HTMLElement>) => void;\n}\n\ninterface LongPressOptions {\n /**\n * Deliver the gesture as a mouse right-click arrives: a secondary-button\n * `mousedown`, then `contextmenu`, on the element the finger pressed rather\n * than the element holding these handlers. Open menus then close as they do\n * on any press outside them, and a control inside a wrapper sees the event\n * first, before it bubbles to the wrapper's menu. If the pressed element\n * left the page during the hold (an icon redrawn for a new state), the\n * element now under the finger receives both, or else the holder.\n */\n emulateRightClick?: boolean | undefined;\n}\n\ninterface Point {\n x: number;\n y: number;\n}\n\n// The element to deliver to: the pressed element, else (when a re-render\n// replaced it) the one now under the finger inside the holder, else the\n// holder; null when even the holder has left the page.\nfunction resolvePressedElement(\n pressed: Element | null,\n holder: HTMLElement,\n point: Point,\n): Element | null {\n if (pressed?.isConnected) {\n return pressed;\n }\n const underFinger = pressed\n ? holder.ownerDocument.elementFromPoint(point.x, point.y)\n : null;\n if (underFinger && holder.contains(underFinger)) {\n return underFinger;\n }\n return holder.isConnected ? holder : null;\n}\n\nfunction deliverLongPress(\n element: Element,\n point: Point,\n emulateRightClick: boolean,\n): void {\n const init = {\n bubbles: true,\n cancelable: true,\n clientX: point.x,\n clientY: point.y,\n };\n if (emulateRightClick) {\n element.dispatchEvent(\n new MouseEvent(\"mousedown\", { ...init, button: 2, buttons: 2 }),\n );\n }\n element.dispatchEvent(new MouseEvent(\"contextmenu\", init));\n}\n\n/**\n * Returns pointer handlers that, when a **touch** pointer is held still for\n * {@link LONG_PRESS_DELAY_MS}, dispatch a native `contextmenu` event on the\n * element holding them at the touch point (or, with `emulateRightClick`, a\n * right-click's `mousedown` and `contextmenu` on the pressed element).\n *\n * Dispatching the real event (rather than calling a handler directly) means the\n * element's existing `onContextMenu` — the same one a right-click triggers —\n * fires with a genuine event, so touch reuses the desktop context-menu path\n * verbatim. Mouse and pen pointers are ignored so right-click stays the desktop\n * affordance.\n *\n * After the long press fires we register a one-shot capturing `click` listener\n * on `window` to swallow the click the browser synthesizes on touch release —\n * `preventDefault()` on `pointerup` does NOT suppress that click per the Pointer\n * Events spec, so without this the element's `onClick` (navigate/select) would\n * also run.\n *\n * Pass `enabled: false` (e.g. when no context-menu handler is wired) to make the\n * returned handlers no-ops.\n */\nexport function useLongPress(\n enabled: boolean,\n options?: LongPressOptions,\n): LongPressHandlers {\n const emulateRightClick = options?.emulateRightClick === true;\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const originRef = useRef<{ x: number; y: number } | null>(null);\n const removeClickSuppressorRef = useRef<(() => void) | null>(null);\n\n const clearTimer = useCallback(() => {\n if (timerRef.current !== null) {\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }\n originRef.current = null;\n }, []);\n\n // Swallow exactly the next click (the one the browser synthesizes from the\n // touch release after a long press) and then detach. A timeout detaches the\n // suppressor if that click never arrives, so a later genuine tap still works.\n const armClickSuppressor = useCallback(() => {\n removeClickSuppressorRef.current?.();\n\n let fallbackTimer: ReturnType<typeof setTimeout> | null = null;\n const onClickCapture = (clickEvent: MouseEvent) => {\n clickEvent.preventDefault();\n clickEvent.stopPropagation();\n removeClickSuppressorRef.current?.();\n };\n\n const remove = () => {\n window.removeEventListener(\"click\", onClickCapture, true);\n if (fallbackTimer !== null) {\n clearTimeout(fallbackTimer);\n fallbackTimer = null;\n }\n removeClickSuppressorRef.current = null;\n };\n\n removeClickSuppressorRef.current = remove;\n window.addEventListener(\"click\", onClickCapture, true);\n fallbackTimer = setTimeout(remove, SYNTHESIZED_CLICK_WINDOW_MS);\n }, []);\n\n // Tear down on unmount, and also when `enabled` flips off mid-press so a\n // scheduled long-press timer / click suppressor never fires after the hook\n // is disabled.\n useEffect(\n () => () => {\n clearTimer();\n removeClickSuppressorRef.current?.();\n },\n [clearTimer, enabled],\n );\n\n const onPointerDown = useCallback(\n (event: ReactPointerEvent<HTMLElement>) => {\n if (!enabled || event.pointerType !== \"touch\") {\n return;\n }\n\n clearTimer();\n const point = { x: event.clientX, y: event.clientY };\n originRef.current = point;\n const holder = event.currentTarget;\n const pressed =\n emulateRightClick && event.target instanceof Element\n ? event.target\n : null;\n timerRef.current = setTimeout(() => {\n timerRef.current = null;\n const element = resolvePressedElement(pressed, holder, point);\n if (element) {\n armClickSuppressor();\n deliverLongPress(element, point, emulateRightClick);\n }\n }, LONG_PRESS_DELAY_MS);\n },\n [armClickSuppressor, clearTimer, emulateRightClick, enabled],\n );\n\n const onPointerMove = useCallback(\n (event: ReactPointerEvent<HTMLElement>) => {\n const origin = originRef.current;\n if (!origin) {\n return;\n }\n\n const movedTooFar =\n Math.abs(event.clientX - origin.x) > LONG_PRESS_MOVE_TOLERANCE_PX ||\n Math.abs(event.clientY - origin.y) > LONG_PRESS_MOVE_TOLERANCE_PX;\n if (movedTooFar) {\n clearTimer();\n }\n },\n [clearTimer],\n );\n\n return {\n onPointerCancel: clearTimer,\n onPointerDown,\n onPointerMove,\n onPointerUp: clearTimer,\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tearleads/windowing",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.41",
|
|
4
4
|
"description": "App-agnostic window management for React: window state, window chrome, and the menu and sidebar primitives it renders with.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
package/routed/RoutedPaneNav.css
CHANGED
|
@@ -130,7 +130,8 @@
|
|
|
130
130
|
inset-inline: 0;
|
|
131
131
|
inset-block-end: 0;
|
|
132
132
|
z-index: 2;
|
|
133
|
-
|
|
133
|
+
/* Tall enough for three rows of tablet tiles; shorter screens scroll. */
|
|
134
|
+
max-height: min(70vh, 42rem);
|
|
134
135
|
overflow-y: auto;
|
|
135
136
|
scrollbar-gutter: var(--scrollbar-gutter);
|
|
136
137
|
padding-bottom: max(var(--space-sm), var(--safe-area-bottom));
|
|
@@ -12,6 +12,6 @@ export interface ScreensaverProviderProps {
|
|
|
12
12
|
gracePeriodMs?: number;
|
|
13
13
|
verifyPin?: ScreensaverPinVerifier | undefined;
|
|
14
14
|
}
|
|
15
|
-
declare const useScreensaver: () => ScreensaverControls;
|
|
16
|
-
export { useScreensaver };
|
|
15
|
+
declare const useOptionalScreensaver: () => ScreensaverControls | null, useScreensaver: () => ScreensaverControls;
|
|
16
|
+
export { useOptionalScreensaver, useScreensaver };
|
|
17
17
|
export declare function ScreensaverProvider({ children, screensaver: Screensaver, gracePeriodMs, verifyPin, }: ScreensaverProviderProps): import("react").JSX.Element;
|
|
@@ -4,8 +4,10 @@ import { createRequiredContext } from "../createRequiredContext.js";
|
|
|
4
4
|
import { ScreensaverOverlay } from "./ScreensaverOverlay.js";
|
|
5
5
|
import { ScreensaverUnlock } from "./ScreensaverUnlock.js";
|
|
6
6
|
import { useScreensaverController } from "./useScreensaverController.js";
|
|
7
|
-
const { context: ScreensaverContext, useRequired: useScreensaver } = createRequiredContext("useScreensaver requires ScreensaverProvider");
|
|
8
|
-
|
|
7
|
+
const { context: ScreensaverContext, useOptional: useOptionalScreensaver, useRequired: useScreensaver, } = createRequiredContext("useScreensaver requires ScreensaverProvider");
|
|
8
|
+
// The optional twin lets a control that starts the screensaver hide itself
|
|
9
|
+
// where the host mounted no provider.
|
|
10
|
+
export { useOptionalScreensaver, useScreensaver };
|
|
9
11
|
export function ScreensaverProvider({ children, screensaver: Screensaver, gracePeriodMs = 2000, verifyPin, }) {
|
|
10
12
|
const { isActive, start, stop, state, submit, cancel, dismiss } = useScreensaverController(gracePeriodMs, verifyPin);
|
|
11
13
|
const unlocking = state.status === "unlock" || state.status === "verifying";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScreensaverProvider.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/screensaver/ScreensaverProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAsC,OAAO,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AActE,MAAM,
|
|
1
|
+
{"version":3,"file":"ScreensaverProvider.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/screensaver/ScreensaverProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAsC,OAAO,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AActE,MAAM,EACJ,OAAO,EAAE,kBAAkB,EAC3B,WAAW,EAAE,sBAAsB,EACnC,WAAW,EAAE,cAAc,GAC5B,GAAG,qBAAqB,CACvB,6CAA6C,CAC9C,CAAC;AAEF,2EAA2E;AAC3E,sCAAsC;AACtC,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,CAAC;AAElD,MAAM,UAAU,mBAAmB,CAAC,EAClC,QAAQ,EACR,WAAW,EAAE,WAAW,EACxB,aAAa,GAAG,IAAI,EACpB,SAAS,GACgB;IACzB,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAC7D,wBAAwB,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,WAAW,CAAC;IAC5E,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EACjC,CAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,CACxB,CAAC;IACF,OAAO,CACL,MAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,aACtC,QAAQ,EACR,QAAQ,IAAI,CACX,KAAC,kBAAkB,IAEjB,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,KAAK,CAAC,MAAM,KAAK,IAAI,EAC7B,WAAW,EAAE,SAAS,YAErB,SAAS,CAAC,CAAC,CAAC,CACX,KAAC,iBAAiB,IAChB,IAAI,EAAE,KAAK,CAAC,MAAM,KAAK,WAAW,EAClC,KAAK,EAAE,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EACrD,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GAChB,CACH,CAAC,CAAC,CAAC,CACF,KAAC,WAAW,KAAG,CAChB,IAdI,KAAK,CAAC,OAAO,CAeC,CACtB,IAC2B,CAC/B,CAAC;AACJ,CAAC","sourcesContent":["import { type ComponentType, type ReactNode, useMemo } from \"react\";\nimport { createRequiredContext } from \"../createRequiredContext\";\nimport { ScreensaverOverlay } from \"./ScreensaverOverlay\";\nimport { ScreensaverUnlock } from \"./ScreensaverUnlock\";\nimport type { ScreensaverPinVerifier } from \"./screensaverPinVerifier\";\nimport { useScreensaverController } from \"./useScreensaverController\";\n\nexport interface ScreensaverControls {\n start: () => void;\n stop: () => void;\n /** Artwork or PIN gate is visible; false can still consume a pending release. */\n isActive: boolean;\n}\nexport interface ScreensaverProviderProps {\n children: ReactNode;\n screensaver: ComponentType;\n gracePeriodMs?: number;\n verifyPin?: ScreensaverPinVerifier | undefined;\n}\nconst {\n context: ScreensaverContext,\n useOptional: useOptionalScreensaver,\n useRequired: useScreensaver,\n} = createRequiredContext<ScreensaverControls>(\n \"useScreensaver requires ScreensaverProvider\",\n);\n\n// The optional twin lets a control that starts the screensaver hide itself\n// where the host mounted no provider.\nexport { useOptionalScreensaver, useScreensaver };\n\nexport function ScreensaverProvider({\n children,\n screensaver: Screensaver,\n gracePeriodMs = 2000,\n verifyPin,\n}: ScreensaverProviderProps) {\n const { isActive, start, stop, state, submit, cancel, dismiss } =\n useScreensaverController(gracePeriodMs, verifyPin);\n const unlocking = state.status === \"unlock\" || state.status === \"verifying\";\n const value = useMemo(\n () => ({ start, stop, isActive }),\n [start, stop, isActive],\n );\n return (\n <ScreensaverContext.Provider value={value}>\n {children}\n {isActive && (\n <ScreensaverOverlay\n key={state.session}\n onStop={dismiss}\n locked={state.locked === true}\n interactive={unlocking}\n >\n {unlocking ? (\n <ScreensaverUnlock\n busy={state.status === \"verifying\"}\n error={state.status === \"unlock\" ? state.error : null}\n onSubmit={submit}\n onCancel={cancel}\n />\n ) : (\n <Screensaver />\n )}\n </ScreensaverOverlay>\n )}\n </ScreensaverContext.Provider>\n );\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* The system tray: its apps in a row, as the taskbar's other controls. */
|
|
2
|
+
.system-tray {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex: 0 0 auto;
|
|
5
|
+
align-items: center;
|
|
6
|
+
gap: var(--space-xs);
|
|
7
|
+
margin: 0;
|
|
8
|
+
padding: 0;
|
|
9
|
+
list-style: none;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.system-tray-app {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* A tray app that renders nothing where it does not apply takes no gap. */
|
|
18
|
+
.system-tray-app:empty {
|
|
19
|
+
display: none;
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { WindowingIcon } from "../icons/windowingIcon.js";
|
|
2
|
+
/** An item a host adds to every tray app's context menu, below Disable. */
|
|
3
|
+
export interface SystemTrayMenuItem {
|
|
4
|
+
icon?: WindowingIcon | undefined;
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
onSelect: () => void;
|
|
8
|
+
}
|
|
9
|
+
interface SystemTrayProps {
|
|
10
|
+
/**
|
|
11
|
+
* Items below "Disable <app>" in each tray app's context menu, such as one
|
|
12
|
+
* that opens the host's Display Properties to turn apps back on.
|
|
13
|
+
*/
|
|
14
|
+
menuItems?: ReadonlyArray<SystemTrayMenuItem> | undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The tray apps of the nearest {@link SystemTrayProvider} that the user left
|
|
18
|
+
* on, in order, for a taskbar's corner. Right-clicking one, pressing the
|
|
19
|
+
* context-menu key on it, or holding a finger on it opens its menu: Disable,
|
|
20
|
+
* then the host's `menuItems`. It renders nothing outside a provider.
|
|
21
|
+
*/
|
|
22
|
+
export declare function SystemTray({ menuItems }: SystemTrayProps): import("react").JSX.Element | null;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { createElement as _createElement } from "react";
|
|
3
|
+
import { Menu } from "../menu/Menu.js";
|
|
4
|
+
import { MenuItem } from "../menu/MenuItem.js";
|
|
5
|
+
import { useContextMenuState } from "../menu/useContextMenuState.js";
|
|
6
|
+
import { useLongPress } from "../menu/useLongPress.js";
|
|
7
|
+
import { useOptionalSystemTray } from "./SystemTrayProvider.js";
|
|
8
|
+
import "./SystemTray.css";
|
|
9
|
+
const NO_MENU_ITEMS = [];
|
|
10
|
+
// An app's portaled content, such as its own popover, bubbles to its tray
|
|
11
|
+
// slot through React though it sits elsewhere in the page. Only presses on
|
|
12
|
+
// what the slot actually contains open the tray's menu.
|
|
13
|
+
function isInSlot(event) {
|
|
14
|
+
return (event.target instanceof Node && event.currentTarget.contains(event.target));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The tray apps of the nearest {@link SystemTrayProvider} that the user left
|
|
18
|
+
* on, in order, for a taskbar's corner. Right-clicking one, pressing the
|
|
19
|
+
* context-menu key on it, or holding a finger on it opens its menu: Disable,
|
|
20
|
+
* then the host's `menuItems`. It renders nothing outside a provider.
|
|
21
|
+
*/
|
|
22
|
+
export function SystemTray({ menuItems = NO_MENU_ITEMS }) {
|
|
23
|
+
const tray = useOptionalSystemTray();
|
|
24
|
+
const { closeContextMenu, contextMenu, openContextMenu } = useContextMenuState();
|
|
25
|
+
// A long press arrives as a right-click would: other open menus close on
|
|
26
|
+
// its press, and the pressed control sees it first, so an app can close its
|
|
27
|
+
// own popover before the tray's menu opens.
|
|
28
|
+
const longPress = useLongPress(true, { emulateRightClick: true });
|
|
29
|
+
if (!tray) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const { definition, isEnabled, setEnabled } = tray;
|
|
33
|
+
const menuApp = contextMenu ? definition.apps[contextMenu.id] : undefined;
|
|
34
|
+
return (_jsxs(_Fragment, { children: [_jsx("ul", { "aria-label": "System tray", className: "system-tray", children: definition.order.filter(isEnabled).map((id) => {
|
|
35
|
+
const TrayApp = definition.apps[id]?.component;
|
|
36
|
+
return (TrayApp && (_createElement("li", { ...longPress, className: "system-tray-app", key: id, onContextMenu: (event) => {
|
|
37
|
+
if (isInSlot(event)) {
|
|
38
|
+
openContextMenu(event, id);
|
|
39
|
+
}
|
|
40
|
+
}, onPointerDown: (event) => {
|
|
41
|
+
if (isInSlot(event)) {
|
|
42
|
+
longPress.onPointerDown(event);
|
|
43
|
+
}
|
|
44
|
+
} },
|
|
45
|
+
_jsx(TrayApp, {}))));
|
|
46
|
+
}) }), contextMenu && menuApp && (_jsxs(Menu, { onClose: closeContextMenu, position: contextMenu.position, children: [_jsx(MenuItem, { icon: menuApp.icon, label: `Disable ${menuApp.title}`, onClick: () => {
|
|
47
|
+
closeContextMenu();
|
|
48
|
+
setEnabled(contextMenu.id, false);
|
|
49
|
+
} }), menuItems.map((item) => (_jsx(MenuItem, { icon: item.icon, label: item.label, onClick: () => {
|
|
50
|
+
closeContextMenu();
|
|
51
|
+
item.onSelect();
|
|
52
|
+
} }, item.id)))] }))] }));
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=SystemTray.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SystemTray.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/tray/SystemTray.tsx"],"names":[],"mappings":";;AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,kBAAkB,CAAC;AAkB1B,MAAM,aAAa,GAAsC,EAAE,CAAC;AAE5D,0EAA0E;AAC1E,2EAA2E;AAC3E,wDAAwD;AACxD,SAAS,QAAQ,CAAC,KAAkC;IAClD,OAAO,CACL,KAAK,CAAC,MAAM,YAAY,IAAI,IAAI,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAC3E,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,EAAE,SAAS,GAAG,aAAa,EAAmB;IACvE,MAAM,IAAI,GAAG,qBAAqB,EAAE,CAAC;IACrC,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,eA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C,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,WAAW,CAAC,QAAQ,aAC7D,KAAC,QAAQ,IACP,IAAI,EAAE,OAAO,CAAC,IAAI,EAClB,KAAK,EAAE,WAAW,OAAO,CAAC,KAAK,EAAE,EACjC,OAAO,EAAE,GAAG,EAAE;4BACZ,gBAAgB,EAAE,CAAC;4BACnB,UAAU,CAAC,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;wBACpC,CAAC,GACD,EACD,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACvB,KAAC,QAAQ,IACP,IAAI,EAAE,IAAI,CAAC,IAAI,EAEf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,GAAG,EAAE;4BACZ,gBAAgB,EAAE,CAAC;4BACnB,IAAI,CAAC,QAAQ,EAAE,CAAC;wBAClB,CAAC,IALI,IAAI,CAAC,EAAE,CAMZ,CACH,CAAC,IACG,CACR,IACA,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import type { SyntheticEvent } from \"react\";\nimport type { WindowingIcon } from \"../icons/windowingIcon\";\nimport { Menu } from \"../menu/Menu\";\nimport { MenuItem } from \"../menu/MenuItem\";\nimport { useContextMenuState } from \"../menu/useContextMenuState\";\nimport { useLongPress } from \"../menu/useLongPress\";\nimport { useOptionalSystemTray } from \"./SystemTrayProvider\";\nimport \"./SystemTray.css\";\n\n/** An item a host adds to every tray app's context menu, below Disable. */\nexport interface SystemTrayMenuItem {\n icon?: WindowingIcon | undefined;\n id: string;\n label: string;\n onSelect: () => void;\n}\n\ninterface SystemTrayProps {\n /**\n * Items below \"Disable <app>\" in each tray app's context menu, such as one\n * that opens the host's Display Properties to turn apps back on.\n */\n menuItems?: ReadonlyArray<SystemTrayMenuItem> | undefined;\n}\n\nconst NO_MENU_ITEMS: ReadonlyArray<SystemTrayMenuItem> = [];\n\n// An app's portaled content, such as its own popover, bubbles to its tray\n// slot through React though it sits elsewhere in the page. Only presses on\n// what the slot actually contains open the tray's menu.\nfunction isInSlot(event: SyntheticEvent<HTMLElement>): boolean {\n return (\n event.target instanceof Node && event.currentTarget.contains(event.target)\n );\n}\n\n/**\n * The tray apps of the nearest {@link SystemTrayProvider} that the user left\n * on, in order, for a taskbar's corner. Right-clicking one, pressing the\n * context-menu key on it, or holding a finger on it opens its menu: Disable,\n * then the host's `menuItems`. It renders nothing outside a provider.\n */\nexport function SystemTray({ menuItems = NO_MENU_ITEMS }: SystemTrayProps) {\n const tray = useOptionalSystemTray();\n const { closeContextMenu, contextMenu, openContextMenu } =\n useContextMenuState();\n // A long press arrives as a right-click would: other open menus close on\n // its press, and the pressed control sees it first, so an app can close its\n // own popover before the tray's menu opens.\n const longPress = useLongPress(true, { emulateRightClick: true });\n if (!tray) {\n return null;\n }\n\n const { definition, isEnabled, setEnabled } = tray;\n const menuApp = contextMenu ? definition.apps[contextMenu.id] : undefined;\n\n return (\n <>\n <ul aria-label=\"System tray\" className=\"system-tray\">\n {definition.order.filter(isEnabled).map((id) => {\n const TrayApp = definition.apps[id]?.component;\n return (\n TrayApp && (\n <li\n {...longPress}\n className=\"system-tray-app\"\n key={id}\n onContextMenu={(event) => {\n if (isInSlot(event)) {\n openContextMenu(event, id);\n }\n }}\n onPointerDown={(event) => {\n if (isInSlot(event)) {\n longPress.onPointerDown(event);\n }\n }}\n >\n <TrayApp />\n </li>\n )\n );\n })}\n </ul>\n {contextMenu && menuApp && (\n <Menu onClose={closeContextMenu} position={contextMenu.position}>\n <MenuItem\n icon={menuApp.icon}\n label={`Disable ${menuApp.title}`}\n onClick={() => {\n closeContextMenu();\n setEnabled(contextMenu.id, false);\n }}\n />\n {menuItems.map((item) => (\n <MenuItem\n icon={item.icon}\n key={item.id}\n label={item.label}\n onClick={() => {\n closeContextMenu();\n item.onSelect();\n }}\n />\n ))}\n </Menu>\n )}\n </>\n );\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type PropsWithChildren } from "react";
|
|
2
|
+
import type { SystemTrayDefinition } from "./systemTrayDefinition.js";
|
|
3
|
+
interface SystemTrayContextValue {
|
|
4
|
+
/** The host's tray apps, in tray order. */
|
|
5
|
+
definition: SystemTrayDefinition;
|
|
6
|
+
/** Whether the user has left the app on; every app starts on. */
|
|
7
|
+
isEnabled: (id: string) => boolean;
|
|
8
|
+
/** Turns one of the host's apps on or off, and persists the choice. */
|
|
9
|
+
setEnabled: (id: string, enabled: boolean) => void;
|
|
10
|
+
}
|
|
11
|
+
interface SystemTrayProviderProps<Id extends string> extends PropsWithChildren {
|
|
12
|
+
/** The host's tray apps. Define it once, outside render. */
|
|
13
|
+
definition: SystemTrayDefinition<Id>;
|
|
14
|
+
/** Where the apps the user turned off persist in localStorage. */
|
|
15
|
+
storageKey: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Owns the system tray: the host's tray apps and which of them the user turned
|
|
19
|
+
* off. {@link SystemTray} shows the ones left on, each with a context menu that
|
|
20
|
+
* turns it off, and Display Properties lists every one with a switch. Mount one
|
|
21
|
+
* above every taskbar that shares the choice.
|
|
22
|
+
*/
|
|
23
|
+
export declare function SystemTrayProvider<Id extends string>({ children, definition, storageKey, }: SystemTrayProviderProps<Id>): import("react").JSX.Element;
|
|
24
|
+
export declare const useSystemTray: () => SystemTrayContextValue;
|
|
25
|
+
export declare const useOptionalSystemTray: () => SystemTrayContextValue | null;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState, } from "react";
|
|
3
|
+
import { createRequiredContext } from "../createRequiredContext.js";
|
|
4
|
+
import { loadStoredPreference, saveStoredPreference, } from "../launcher/storedPreference.js";
|
|
5
|
+
const systemTrayContext = createRequiredContext("useSystemTray must be used within a SystemTrayProvider");
|
|
6
|
+
const NONE_DISABLED = new Set();
|
|
7
|
+
// The stored value is a JSON array of the ids the user turned off. Storing the
|
|
8
|
+
// off set rather than the on set lets a tray app the host adds later show up.
|
|
9
|
+
function parseDisabledAppIds(stored) {
|
|
10
|
+
if (stored === null) {
|
|
11
|
+
return NONE_DISABLED;
|
|
12
|
+
}
|
|
13
|
+
const parsed = JSON.parse(stored);
|
|
14
|
+
return Array.isArray(parsed)
|
|
15
|
+
? new Set(parsed.filter((id) => typeof id === "string"))
|
|
16
|
+
: NONE_DISABLED;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Owns the system tray: the host's tray apps and which of them the user turned
|
|
20
|
+
* off. {@link SystemTray} shows the ones left on, each with a context menu that
|
|
21
|
+
* turns it off, and Display Properties lists every one with a switch. Mount one
|
|
22
|
+
* above every taskbar that shares the choice.
|
|
23
|
+
*/
|
|
24
|
+
export function SystemTrayProvider({ children, definition, storageKey, }) {
|
|
25
|
+
const [disabledAppIds, setDisabledAppIds] = useState(() => loadStoredPreference(storageKey, parseDisabledAppIds));
|
|
26
|
+
// Persist only what the user changed, after the change commits, so several
|
|
27
|
+
// calls in one event (turning every app back on) all land.
|
|
28
|
+
const persistedAppIds = useRef(disabledAppIds);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (persistedAppIds.current === disabledAppIds) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
persistedAppIds.current = disabledAppIds;
|
|
34
|
+
saveStoredPreference(storageKey, JSON.stringify([...disabledAppIds]));
|
|
35
|
+
}, [disabledAppIds, storageKey]);
|
|
36
|
+
const isEnabled = useCallback((id) => !disabledAppIds.has(id), [disabledAppIds]);
|
|
37
|
+
const setEnabled = useCallback((id, enabled) => {
|
|
38
|
+
if (!Object.hasOwn(definition.apps, id)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
setDisabledAppIds((current) => {
|
|
42
|
+
if (current.has(id) !== enabled) {
|
|
43
|
+
return current;
|
|
44
|
+
}
|
|
45
|
+
const next = new Set(current);
|
|
46
|
+
if (enabled) {
|
|
47
|
+
next.delete(id);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
next.add(id);
|
|
51
|
+
}
|
|
52
|
+
return next;
|
|
53
|
+
});
|
|
54
|
+
}, [definition.apps]);
|
|
55
|
+
const value = useMemo(() => ({ definition, isEnabled, setEnabled }), [definition, isEnabled, setEnabled]);
|
|
56
|
+
return (_jsx(systemTrayContext.context.Provider, { value: value, children: children }));
|
|
57
|
+
}
|
|
58
|
+
export const useSystemTray = systemTrayContext.useRequired;
|
|
59
|
+
// Non-throwing accessor: without a provider the tray shows nothing, and Display
|
|
60
|
+
// Properties leaves out its System Tray section.
|
|
61
|
+
export const useOptionalSystemTray = systemTrayContext.useOptional;
|
|
62
|
+
//# sourceMappingURL=SystemTrayProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SystemTrayProvider.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/tray/SystemTrayProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AAYtC,MAAM,iBAAiB,GAAG,qBAAqB,CAC7C,wDAAwD,CACzD,CAAC;AAEF,MAAM,aAAa,GAAwB,IAAI,GAAG,EAAE,CAAC;AAErD,+EAA+E;AAC/E,8EAA8E;AAC9E,SAAS,mBAAmB,CAAC,MAAqB;IAChD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,aAAa,CAAC;IACvB,CAAC;IACD,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3C,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAC1B,CAAC,CAAC,IAAI,GAAG,C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AC;YACjB,CAAC;YACD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;YAC9B,IAAI,OAAO,EAAE,CAAC;gBACZ,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAClB,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACf,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC,EACD,CAAC,UAAU,CAAC,IAAI,CAAC,CAClB,CAAC;IAEF,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,EAC7C,CAAC,UAAU,EAAE,SAAS,EAAE,UAAU,CAAC,CACpC,CAAC;IAEF,OAAO,CACL,KAAC,iBAAiB,CAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAC7C,QAAQ,GAC0B,CACtC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC,WAAW,CAAC;AAE3D,gFAAgF;AAChF,iDAAiD;AACjD,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,WAAW,CAAC","sourcesContent":["import {\n type PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createRequiredContext } from \"../createRequiredContext\";\nimport {\n loadStoredPreference,\n saveStoredPreference,\n} from \"../launcher/storedPreference\";\nimport type { SystemTrayDefinition } from \"./systemTrayDefinition\";\n\ninterface SystemTrayContextValue {\n /** The host's tray apps, in tray order. */\n definition: SystemTrayDefinition;\n /** Whether the user has left the app on; every app starts on. */\n isEnabled: (id: string) => boolean;\n /** Turns one of the host's apps on or off, and persists the choice. */\n setEnabled: (id: string, enabled: boolean) => void;\n}\n\nconst systemTrayContext = createRequiredContext<SystemTrayContextValue>(\n \"useSystemTray must be used within a SystemTrayProvider\",\n);\n\nconst NONE_DISABLED: ReadonlySet<string> = new Set();\n\n// The stored value is a JSON array of the ids the user turned off. Storing the\n// off set rather than the on set lets a tray app the host adds later show up.\nfunction parseDisabledAppIds(stored: string | null): ReadonlySet<string> {\n if (stored === null) {\n return NONE_DISABLED;\n }\n const parsed: unknown = JSON.parse(stored);\n return Array.isArray(parsed)\n ? new Set(parsed.filter((id): id is string => typeof id === \"string\"))\n : NONE_DISABLED;\n}\n\ninterface SystemTrayProviderProps<Id extends string> extends PropsWithChildren {\n /** The host's tray apps. Define it once, outside render. */\n definition: SystemTrayDefinition<Id>;\n /** Where the apps the user turned off persist in localStorage. */\n storageKey: string;\n}\n\n/**\n * Owns the system tray: the host's tray apps and which of them the user turned\n * off. {@link SystemTray} shows the ones left on, each with a context menu that\n * turns it off, and Display Properties lists every one with a switch. Mount one\n * above every taskbar that shares the choice.\n */\nexport function SystemTrayProvider<Id extends string>({\n children,\n definition,\n storageKey,\n}: SystemTrayProviderProps<Id>) {\n const [disabledAppIds, setDisabledAppIds] = useState(() =>\n loadStoredPreference(storageKey, parseDisabledAppIds),\n );\n\n // Persist only what the user changed, after the change commits, so several\n // calls in one event (turning every app back on) all land.\n const persistedAppIds = useRef(disabledAppIds);\n useEffect(() => {\n if (persistedAppIds.current === disabledAppIds) {\n return;\n }\n persistedAppIds.current = disabledAppIds;\n saveStoredPreference(storageKey, JSON.stringify([...disabledAppIds]));\n }, [disabledAppIds, storageKey]);\n\n const isEnabled = useCallback(\n (id: string) => !disabledAppIds.has(id),\n [disabledAppIds],\n );\n\n const setEnabled = useCallback(\n (id: string, enabled: boolean) => {\n if (!Object.hasOwn(definition.apps, id)) {\n return;\n }\n setDisabledAppIds((current) => {\n if (current.has(id) !== enabled) {\n return current;\n }\n const next = new Set(current);\n if (enabled) {\n next.delete(id);\n } else {\n next.add(id);\n }\n return next;\n });\n },\n [definition.apps],\n );\n\n const value = useMemo<SystemTrayContextValue>(\n () => ({ definition, isEnabled, setEnabled }),\n [definition, isEnabled, setEnabled],\n );\n\n return (\n <systemTrayContext.context.Provider value={value}>\n {children}\n </systemTrayContext.context.Provider>\n );\n}\n\nexport const useSystemTray = systemTrayContext.useRequired;\n\n// Non-throwing accessor: without a provider the tray shows nothing, and Display\n// Properties leaves out its System Tray section.\nexport const useOptionalSystemTray = systemTrayContext.useOptional;\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import type { WindowingIcon } from "../icons/windowingIcon.js";
|
|
3
|
+
/**
|
|
4
|
+
* One tray app: a small control a host shows in its taskbar's tray, such as a
|
|
5
|
+
* theme switch or a status indicator, which the user can turn off.
|
|
6
|
+
*/
|
|
7
|
+
export interface TrayAppDefinition {
|
|
8
|
+
/** The control. It may render nothing where it does not apply. */
|
|
9
|
+
component: ComponentType;
|
|
10
|
+
/** Drawn beside the title in Display Properties and the app's menu. */
|
|
11
|
+
icon?: WindowingIcon | undefined;
|
|
12
|
+
/** Names the app in Display Properties and its context menu. */
|
|
13
|
+
title: string;
|
|
14
|
+
}
|
|
15
|
+
/** A host's tray apps and their order in the tray, start to end. */
|
|
16
|
+
export interface SystemTrayDefinition<Id extends string = string> {
|
|
17
|
+
apps: Readonly<Record<Id, TrayAppDefinition>>;
|
|
18
|
+
order: ReadonlyArray<Id>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"systemTrayDefinition.js","sourceRoot":"","sources":["../../../home/runner/work/tearleads/tearleads/packages/windowing/src/tray/systemTrayDefinition.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentType } from \"react\";\nimport type { WindowingIcon } from \"../icons/windowingIcon\";\n\n/**\n * One tray app: a small control a host shows in its taskbar's tray, such as a\n * theme switch or a status indicator, which the user can turn off.\n */\nexport interface TrayAppDefinition {\n /** The control. It may render nothing where it does not apply. */\n component: ComponentType;\n /** Drawn beside the title in Display Properties and the app's menu. */\n icon?: WindowingIcon | undefined;\n /** Names the app in Display Properties and its context menu. */\n title: string;\n}\n\n/** A host's tray apps and their order in the tray, start to end. */\nexport interface SystemTrayDefinition<Id extends string = string> {\n apps: Readonly<Record<Id, TrayAppDefinition>>;\n order: ReadonlyArray<Id>;\n}\n"]}
|