@oxy.so/bloom 19.8.1 → 19.8.3
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/docs/adoption-matrix.mdx +2 -2
- package/docs/menubar.mdx +1 -1
- package/docs/task-catalog.json +1 -1
- package/docs/task-catalog.mdx +1 -1
- package/lib/commonjs/app-shell/AppShellPanelLayout.js +7 -4
- package/lib/commonjs/app-shell/AppShellPanelLayout.js.map +1 -1
- package/lib/commonjs/menubar/Menubar.web.js +68 -8
- package/lib/commonjs/menubar/Menubar.web.js.map +1 -1
- package/lib/module/app-shell/AppShellPanelLayout.js +8 -5
- package/lib/module/app-shell/AppShellPanelLayout.js.map +1 -1
- package/lib/module/menubar/Menubar.web.js +69 -9
- package/lib/module/menubar/Menubar.web.js.map +1 -1
- package/lib/typescript/commonjs/app-shell/AppShellPanelLayout.d.ts.map +1 -1
- package/lib/typescript/commonjs/menubar/Menubar.web.d.ts.map +1 -1
- package/lib/typescript/module/app-shell/AppShellPanelLayout.d.ts.map +1 -1
- package/lib/typescript/module/menubar/Menubar.web.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/app-shell/AppShellPanelLayout.tsx +8 -9
- package/src/menubar/Menubar.web.tsx +63 -11
|
@@ -18,6 +18,7 @@ import { BloomScope } from '../appearance';
|
|
|
18
18
|
import React, {
|
|
19
19
|
type ComponentRef,
|
|
20
20
|
useCallback,
|
|
21
|
+
useEffect,
|
|
21
22
|
useLayoutEffect,
|
|
22
23
|
useMemo,
|
|
23
24
|
useRef,
|
|
@@ -61,6 +62,8 @@ export { MenubarMenu, MenubarTrigger } from './MenubarBase';
|
|
|
61
62
|
|
|
62
63
|
/** The panel's 1px edge, inside which the layers sit. */
|
|
63
64
|
const EDGE = 1;
|
|
65
|
+
/** The panel's own transitions while it changes from one menu into the next: its place and size. */
|
|
66
|
+
const MORPHED = ['left', 'top', 'width', 'height'];
|
|
64
67
|
|
|
65
68
|
const NO_ANCHOR = { current: null };
|
|
66
69
|
|
|
@@ -130,21 +133,70 @@ function MenubarViewport() {
|
|
|
130
133
|
});
|
|
131
134
|
|
|
132
135
|
// Once the panel has reached the open menu, the menus it changed from go; then it rests,
|
|
133
|
-
// sized by the open menu again.
|
|
136
|
+
// sized by the open menu again. "Reached" is the end of the panel's own transitions of its
|
|
137
|
+
// place and size, never a time: each of them that changed is pending until the browser runs it
|
|
138
|
+
// (`transitionrun`), then running until it ends or is cancelled. Nothing changed (the new menu
|
|
139
|
+
// at the old one's place and size) or Reduce Motion, nothing is pending, so it rests at once.
|
|
134
140
|
const leaving = useRef(layers);
|
|
135
141
|
leaving.current = layers;
|
|
136
142
|
const currentKey = current?.key;
|
|
143
|
+
const morph = useRef({
|
|
144
|
+
pending: new Set<string>(),
|
|
145
|
+
running: new Set<string>(),
|
|
146
|
+
last: new Map<string, string>(),
|
|
147
|
+
settle: () => {},
|
|
148
|
+
});
|
|
149
|
+
morph.current.settle = () => {
|
|
150
|
+
const { pending, running } = morph.current;
|
|
151
|
+
if (!target || target.key !== currentKey || pending.size > 0 || running.size > 0) return;
|
|
152
|
+
for (const layer of leaving.current) if (layer.exiting) retire(layer.key);
|
|
153
|
+
setTarget((now) => (now === target ? null : now));
|
|
154
|
+
};
|
|
137
155
|
useLayoutEffect(() => {
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
156
|
+
const element = hostElement(panel);
|
|
157
|
+
const { pending, running, last } = morph.current;
|
|
158
|
+
if (element) {
|
|
159
|
+
for (const property of MORPHED) {
|
|
160
|
+
const value = element.style.getPropertyValue(property);
|
|
161
|
+
const before = last.get(property);
|
|
162
|
+
last.set(property, value);
|
|
163
|
+
// A transition runs only from a value to another while morphing, never from `auto`.
|
|
164
|
+
if (morphing && !instant && before && value && before !== value) pending.add(property);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (!morphing || instant) {
|
|
168
|
+
pending.clear();
|
|
169
|
+
running.clear();
|
|
170
|
+
}
|
|
171
|
+
morph.current.settle();
|
|
172
|
+
});
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
const element = hostElement(panel);
|
|
175
|
+
if (!element) return undefined;
|
|
176
|
+
const ours = (event: Event) =>
|
|
177
|
+
event.target === element && MORPHED.includes((event as TransitionEvent).propertyName);
|
|
178
|
+
const run = (event: Event) => {
|
|
179
|
+
if (!ours(event)) return;
|
|
180
|
+
const property = (event as TransitionEvent).propertyName;
|
|
181
|
+
morph.current.pending.delete(property);
|
|
182
|
+
morph.current.running.add(property);
|
|
183
|
+
};
|
|
184
|
+
const end = (event: Event) => {
|
|
185
|
+
if (!ours(event)) return;
|
|
186
|
+
const property = (event as TransitionEvent).propertyName;
|
|
187
|
+
morph.current.pending.delete(property);
|
|
188
|
+
morph.current.running.delete(property);
|
|
189
|
+
morph.current.settle();
|
|
190
|
+
};
|
|
191
|
+
element.addEventListener('transitionrun', run);
|
|
192
|
+
element.addEventListener('transitionend', end);
|
|
193
|
+
element.addEventListener('transitioncancel', end);
|
|
194
|
+
return () => {
|
|
195
|
+
element.removeEventListener('transitionrun', run);
|
|
196
|
+
element.removeEventListener('transitionend', end);
|
|
197
|
+
element.removeEventListener('transitioncancel', end);
|
|
198
|
+
};
|
|
199
|
+
}, [panel]);
|
|
148
200
|
|
|
149
201
|
if (!entry || !showing) return null;
|
|
150
202
|
const { props } = entry;
|