magic-pill 9.2.0 → 9.4.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/MIGRATING.md +2 -0
- package/README.md +158 -17
- package/dist/MagicPill/MagicPill.d.mts +43 -1
- package/dist/MagicPill/MagicPill.d.ts +43 -1
- package/dist/MagicPill/MagicPill.js +53 -6
- package/dist/MagicPill/MagicPill.mjs +56 -9
- package/dist/MagicPill/flag.js +1 -59
- package/dist/MagicPill/flag.mjs +1 -58
- package/dist/MagicPill/useChoreography.js +2 -1
- package/dist/MagicPill/useChoreography.mjs +3 -2
- package/dist/Pill/PillProgress.d.mts +12 -0
- package/dist/Pill/PillProgress.d.ts +12 -0
- package/dist/Pill/PillProgress.js +42 -0
- package/dist/Pill/PillProgress.mjs +42 -0
- package/dist/Pill/goo.js +353 -0
- package/dist/Pill/goo.mjs +347 -0
- package/dist/Pill/modal.js +2 -1
- package/dist/Pill/modal.mjs +3 -2
- package/dist/Pill/morph.js +7 -4
- package/dist/Pill/morph.mjs +8 -5
- package/dist/Pill/travel.js +2 -1
- package/dist/Pill/travel.mjs +3 -2
- package/dist/Pill/zone.js +3 -2
- package/dist/Pill/zone.mjs +4 -3
- package/dist/PillForm/PillSubmit.js +1 -1
- package/dist/PillForm/PillSubmit.mjs +3 -3
- package/dist/PillForm/popover.js +2 -1
- package/dist/PillForm/popover.mjs +3 -2
- package/dist/PillNavbar/PillNavbar.d.mts +8 -0
- package/dist/PillNavbar/PillNavbar.d.ts +8 -0
- package/dist/PillNavbar/PillNavbar.js +3 -2
- package/dist/PillNavbar/PillNavbar.mjs +3 -2
- package/dist/PillNavbar/room.d.mts +3 -0
- package/dist/PillNavbar/room.d.ts +2 -0
- package/dist/PillNavbar/room.js +89 -17
- package/dist/PillNavbar/room.mjs +89 -18
- package/dist/PillOptics/PillOptics.js +2 -1
- package/dist/PillOptics/PillOptics.mjs +3 -2
- package/dist/forms.css +2 -1
- package/dist/index.d.mts +30 -15
- package/dist/index.d.ts +30 -15
- package/dist/index.js +40 -12
- package/dist/index.mjs +40 -13
- package/dist/satellites/Actions.d.mts +12 -0
- package/dist/satellites/Actions.d.ts +11 -0
- package/dist/satellites/Actions.js +59 -0
- package/dist/satellites/Actions.mjs +56 -0
- package/dist/satellites/Orbitals.js +554 -0
- package/dist/satellites/Orbitals.mjs +554 -0
- package/dist/satellites/Satellites.js +400 -0
- package/dist/satellites/Satellites.mjs +400 -0
- package/dist/satellites/layout.js +156 -0
- package/dist/satellites/layout.mjs +156 -0
- package/dist/satellites/measure.js +25 -0
- package/dist/satellites/measure.mjs +24 -0
- package/dist/satellites/orbits.js +139 -0
- package/dist/satellites/orbits.mjs +136 -0
- package/dist/satellites/types.d.mts +54 -0
- package/dist/satellites/types.d.ts +54 -0
- package/dist/satellites.d.mts +5 -0
- package/dist/satellites.d.ts +5 -0
- package/dist/satellites.js +14 -0
- package/dist/satellites.mjs +12 -0
- package/dist/store/store.d.mts +103 -0
- package/dist/store/store.d.ts +103 -0
- package/dist/store/store.js +52 -1
- package/dist/store/store.mjs +52 -2
- package/dist/styles.css +174 -10
- package/dist/utils/react.js +8 -1
- package/dist/utils/react.mjs +8 -2
- package/package.json +12 -2
- package/dist/icons/ArrowIcon.d.mts +0 -4
- package/dist/icons/ArrowIcon.d.ts +0 -4
- package/dist/icons/BoxIcon.d.mts +0 -4
- package/dist/icons/BoxIcon.d.ts +0 -4
- package/dist/icons/CheckIcon.d.mts +0 -4
- package/dist/icons/CheckIcon.d.ts +0 -4
- package/dist/icons/CloseIcon.d.mts +0 -4
- package/dist/icons/CloseIcon.d.ts +0 -4
- package/dist/icons/CouponIcon.d.mts +0 -4
- package/dist/icons/CouponIcon.d.ts +0 -4
- package/dist/icons/DocumentIcon.d.mts +0 -4
- package/dist/icons/DocumentIcon.d.ts +0 -4
- package/dist/icons/HelpIcon.d.mts +0 -4
- package/dist/icons/HelpIcon.d.ts +0 -4
- package/dist/icons/InfoIcon.d.mts +0 -4
- package/dist/icons/InfoIcon.d.ts +0 -4
- package/dist/icons/MailIcon.d.mts +0 -4
- package/dist/icons/MailIcon.d.ts +0 -4
- package/dist/icons/PhoneIcon.d.mts +0 -4
- package/dist/icons/PhoneIcon.d.ts +0 -4
- package/dist/icons/PlusIcon.d.mts +0 -4
- package/dist/icons/PlusIcon.d.ts +0 -4
- package/dist/icons/UndoIcon.d.mts +0 -4
- package/dist/icons/UndoIcon.d.ts +0 -4
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
let react = require("react");
|
|
4
|
+
const require_Pill = require("../Pill/Pill.js");
|
|
5
|
+
const require_goo = require("../Pill/goo.js");
|
|
6
|
+
const require_PillProgress = require("../Pill/PillProgress.js");
|
|
7
|
+
const require_matchPath = require("../PillNavbar/matchPath.js");
|
|
8
|
+
const require_room = require("../PillNavbar/room.js");
|
|
9
|
+
const require_store = require("../store/store.js");
|
|
10
|
+
const require_react = require("../utils/react.js");
|
|
11
|
+
const require_timing = require("../utils/timing.js");
|
|
12
|
+
const require_visuallyHidden = require("../utils/visuallyHidden.js");
|
|
13
|
+
const require_layout = require("./layout.js");
|
|
14
|
+
const require_measure = require("./measure.js");
|
|
15
|
+
const require_Orbitals = require("./Orbitals.js");
|
|
16
|
+
const require_Actions = require("./Actions.js");
|
|
17
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
18
|
+
|
|
19
|
+
// src/satellites/Satellites.tsx
|
|
20
|
+
const ELECTRON_STYLE = {
|
|
21
|
+
position: "fixed",
|
|
22
|
+
zIndex: "var(--mp-z-index, 50)",
|
|
23
|
+
margin: 0
|
|
24
|
+
};
|
|
25
|
+
const SHIFT = "mp-satellite-shift";
|
|
26
|
+
/** The page's actions' entry among the satellites' presences */
|
|
27
|
+
const ACTIONS = "\0actions";
|
|
28
|
+
const SIDE_PLACEMENTS = /* @__PURE__ */ new Set(["left", "right"]);
|
|
29
|
+
/**
|
|
30
|
+
* The page's actions' box along the pill, whichever way their pill runs now
|
|
31
|
+
* and even while its size animates: laid out on a hidden copy, turned along.
|
|
32
|
+
*/
|
|
33
|
+
function alongBox(atom, vertical) {
|
|
34
|
+
const copy = atom.cloneNode(true);
|
|
35
|
+
copy.setAttribute("data-orientation", vertical ? "vertical" : "horizontal");
|
|
36
|
+
copy.removeAttribute("id");
|
|
37
|
+
copy.inert = true;
|
|
38
|
+
copy.style.visibility = "hidden";
|
|
39
|
+
copy.style.pointerEvents = "none";
|
|
40
|
+
copy.style.translate = "none";
|
|
41
|
+
copy.style.scale = "none";
|
|
42
|
+
atom.after(copy);
|
|
43
|
+
const box = {
|
|
44
|
+
width: copy.offsetWidth,
|
|
45
|
+
height: copy.offsetHeight
|
|
46
|
+
};
|
|
47
|
+
copy.remove();
|
|
48
|
+
return box;
|
|
49
|
+
}
|
|
50
|
+
/** Two boxes side by side, a gap apart: the second can come out of the first. */
|
|
51
|
+
const nextTo = (a, b, gap) => {
|
|
52
|
+
const sideBySide = Math.abs(a.top - b.top) < 2 && Math.abs(Math.abs(a.left - b.left) - (a.width + gap)) < 2;
|
|
53
|
+
const stacked = Math.abs(a.left - b.left) < 2 && Math.abs(Math.abs(a.top - b.top) - (a.height + gap)) < 2;
|
|
54
|
+
return sideBySide || stacked;
|
|
55
|
+
};
|
|
56
|
+
/** What an electron shows: the ring and its value or icon, the value alone, or the app's own. */
|
|
57
|
+
function ElectronContent({ electron }) {
|
|
58
|
+
const { input } = electron;
|
|
59
|
+
if (input.render) return input.render();
|
|
60
|
+
const inner = input.value !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
61
|
+
"data-mp": "electron-value",
|
|
62
|
+
children: input.value
|
|
63
|
+
}) : input.icon !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
64
|
+
"data-mp": "electron-icon",
|
|
65
|
+
"aria-hidden": "true",
|
|
66
|
+
children: input.icon
|
|
67
|
+
}) : null;
|
|
68
|
+
return input.progress !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillProgress.PillProgress, {
|
|
69
|
+
value: input.progress,
|
|
70
|
+
children: inner
|
|
71
|
+
}) : inner;
|
|
72
|
+
}
|
|
73
|
+
/** All of the circle is a link back to where it came from, or a button for its `onClick`. */
|
|
74
|
+
function ElectronBody({ electron, host }) {
|
|
75
|
+
const { input, origin } = electron;
|
|
76
|
+
const valueText = input.valueText ?? input.value;
|
|
77
|
+
const name = valueText ? `${input.label}, ${valueText}` : input.label;
|
|
78
|
+
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ElectronContent, { electron });
|
|
79
|
+
if (input.onClick) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
80
|
+
type: "button",
|
|
81
|
+
"data-mp": "electron",
|
|
82
|
+
"aria-label": name,
|
|
83
|
+
onClick: (event) => input.onClick?.(event),
|
|
84
|
+
children: content
|
|
85
|
+
});
|
|
86
|
+
if (origin !== void 0) {
|
|
87
|
+
const Link = host.linkComponent ?? "a";
|
|
88
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Link, {
|
|
89
|
+
href: origin,
|
|
90
|
+
"data-mp": "electron",
|
|
91
|
+
"aria-label": name,
|
|
92
|
+
draggable: false,
|
|
93
|
+
children: content
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
97
|
+
"data-mp": "electron",
|
|
98
|
+
role: "img",
|
|
99
|
+
"aria-label": name,
|
|
100
|
+
children: content
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function SatellitesLayer({ host }) {
|
|
104
|
+
const electrons = (0, react.useSyncExternalStore)(host.store.subscribe, host.store.getElectrons, () => require_store.NO_ELECTRONS);
|
|
105
|
+
const [, refresh] = (0, react.useReducer)((count) => count + 1, 0);
|
|
106
|
+
const shown = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
107
|
+
for (const electron of electrons) shown.current.set(electron.id, { electron });
|
|
108
|
+
for (const [id, entry] of shown.current) if (!entry.leaving && !electrons.some((electron) => electron.id === id)) shown.current.set(id, {
|
|
109
|
+
...entry,
|
|
110
|
+
leaving: true
|
|
111
|
+
});
|
|
112
|
+
const tucked = host.notifying && !host.keepElectronsOut;
|
|
113
|
+
const actions = require_Actions.useHostActions(host);
|
|
114
|
+
const lastActions = (0, react.useRef)(null);
|
|
115
|
+
if (actions) lastActions.current = actions;
|
|
116
|
+
const detached = host.actionsStyle === "detached";
|
|
117
|
+
const actionsPresence = detached && actions && !tucked ? "compact" : "hidden";
|
|
118
|
+
const shownActions = detached ? actions ?? lastActions.current : null;
|
|
119
|
+
const atom = (0, react.useRef)(null);
|
|
120
|
+
const [actionsAcross, setActionsAcross] = (0, react.useState)(false);
|
|
121
|
+
const actionsBox = (0, react.useRef)(null);
|
|
122
|
+
const across = (0, react.useRef)(actionsAcross);
|
|
123
|
+
across.current = actionsAcross;
|
|
124
|
+
const presenceOf = ({ electron, leaving }) => {
|
|
125
|
+
if (leaving || tucked) return "hidden";
|
|
126
|
+
return electron.input.hideOnOrigin !== false && electron.origin !== void 0 && require_matchPath.findActiveIndex(host.pathname, [{ href: electron.origin }]) === 0 ? "hidden" : "compact";
|
|
127
|
+
};
|
|
128
|
+
const entries = [...shown.current.values()].map((entry) => ({
|
|
129
|
+
...entry,
|
|
130
|
+
presence: presenceOf(entry)
|
|
131
|
+
}));
|
|
132
|
+
const elements = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
133
|
+
const presences = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
134
|
+
const applied = (0, react.useRef)({
|
|
135
|
+
shift: 0,
|
|
136
|
+
reserve: 0
|
|
137
|
+
});
|
|
138
|
+
const hostMin = (0, react.useRef)(void 0);
|
|
139
|
+
const rows = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
140
|
+
const arrange = (0, react.useRef)(() => {});
|
|
141
|
+
arrange.current = (animate) => {
|
|
142
|
+
const root = host.rootRef.current;
|
|
143
|
+
if (!root) return;
|
|
144
|
+
const vertical = SIDE_PLACEMENTS.has(host.placement);
|
|
145
|
+
const style = getComputedStyle(root);
|
|
146
|
+
const gap = require_measure.toPixels(style.getPropertyValue("--mp-electron-gap"), root, Number.parseFloat(style.columnGap) || 16);
|
|
147
|
+
const offset = require_measure.toPixels(style.getPropertyValue("--_mp-offset"), root, 24);
|
|
148
|
+
const out = entries.filter((entry) => entry.presence !== "hidden" && elements.current.get(entry.electron.id));
|
|
149
|
+
if (animate && !vertical) hostMin.current = require_room.foldedWidth(root);
|
|
150
|
+
const atomElement = atom.current;
|
|
151
|
+
const atomOut = actionsPresence !== "hidden" && atomElement;
|
|
152
|
+
if (atomOut && (animate || !actionsBox.current)) actionsBox.current = alongBox(atomElement, vertical);
|
|
153
|
+
const turn = host.actionsOrientation === "auto" ? "auto" : host.actionsOrientation === "vertical" === vertical ? "along" : "across";
|
|
154
|
+
const layout = require_layout.planSatellites({
|
|
155
|
+
viewport: {
|
|
156
|
+
width: document.documentElement.clientWidth || window.innerWidth,
|
|
157
|
+
height: window.innerHeight
|
|
158
|
+
},
|
|
159
|
+
host: {
|
|
160
|
+
left: root.offsetLeft,
|
|
161
|
+
top: root.offsetTop,
|
|
162
|
+
width: root.offsetWidth,
|
|
163
|
+
height: root.offsetHeight
|
|
164
|
+
},
|
|
165
|
+
hostMin: vertical ? void 0 : hostMin.current,
|
|
166
|
+
placement: host.placement,
|
|
167
|
+
vertical,
|
|
168
|
+
rtl: style.direction === "rtl",
|
|
169
|
+
electrons: out.map(({ electron }) => {
|
|
170
|
+
const element = elements.current.get(electron.id);
|
|
171
|
+
return {
|
|
172
|
+
id: electron.id,
|
|
173
|
+
width: element.offsetWidth || 72,
|
|
174
|
+
height: element.offsetHeight || 72
|
|
175
|
+
};
|
|
176
|
+
}),
|
|
177
|
+
actions: atomOut && actionsBox.current ? {
|
|
178
|
+
width: actionsBox.current.width,
|
|
179
|
+
height: actionsBox.current.height,
|
|
180
|
+
side: host.actionsSide,
|
|
181
|
+
turn
|
|
182
|
+
} : void 0,
|
|
183
|
+
side: host.electronSide,
|
|
184
|
+
line: host.electronLine,
|
|
185
|
+
arrange: host.arrange,
|
|
186
|
+
gap,
|
|
187
|
+
offset
|
|
188
|
+
});
|
|
189
|
+
const reduced = require_timing.prefersReducedMotion();
|
|
190
|
+
const moving = animate && !reduced && typeof root.animate === "function";
|
|
191
|
+
const timings = require_measure.durations(out[0] ? elements.current.get(out[0].electron.id) : root);
|
|
192
|
+
const previous = applied.current;
|
|
193
|
+
if (Math.abs(layout.shift - previous.shift) > .5) {
|
|
194
|
+
const along = (value) => vertical ? `0px ${value}px` : `${value}px 0px`;
|
|
195
|
+
if (layout.shift) root.style.setProperty("translate", along(layout.shift));
|
|
196
|
+
else root.style.removeProperty("translate");
|
|
197
|
+
if (moving) root.animate([{ translate: along(previous.shift - layout.shift) }, { translate: "0px 0px" }], {
|
|
198
|
+
id: SHIFT,
|
|
199
|
+
duration: timings.change,
|
|
200
|
+
easing: "ease-in-out",
|
|
201
|
+
composite: "add"
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
if (!vertical && layout.reserve !== previous.reserve) {
|
|
205
|
+
if (layout.reserve) root.style.setProperty("--_mp-shift-x", `${layout.reserve}px`);
|
|
206
|
+
else root.style.removeProperty("--_mp-shift-x");
|
|
207
|
+
}
|
|
208
|
+
applied.current = {
|
|
209
|
+
shift: layout.shift,
|
|
210
|
+
reserve: layout.reserve
|
|
211
|
+
};
|
|
212
|
+
if (animate && atomOut && layout.actionsAcross !== across.current) setActionsAcross(layout.actionsAcross);
|
|
213
|
+
const boxes = layout.boxes;
|
|
214
|
+
if (atomElement) {
|
|
215
|
+
const was = presences.current.get(ACTIONS);
|
|
216
|
+
const box = boxes.actions;
|
|
217
|
+
const settled = layout.actionsAcross === across.current;
|
|
218
|
+
if (box && atomOut && settled) {
|
|
219
|
+
atomElement.style.left = `${box.left}px`;
|
|
220
|
+
atomElement.style.top = `${box.top}px`;
|
|
221
|
+
if (animate && was !== "compact") require_goo.playSplit(root, atomElement, "split", {
|
|
222
|
+
delay: 0,
|
|
223
|
+
duration: require_measure.durations(atomElement).enter
|
|
224
|
+
});
|
|
225
|
+
} else if (animate && !atomOut && was === "compact") {
|
|
226
|
+
const { fade, change, exit } = require_measure.durations(atomElement);
|
|
227
|
+
require_goo.playSplit(root, atomElement, "join", {
|
|
228
|
+
delay: fade + change,
|
|
229
|
+
duration: exit
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
if (animate && (settled || !atomOut)) presences.current.set(ACTIONS, actionsPresence);
|
|
233
|
+
}
|
|
234
|
+
const crossOf = (box) => Math.round(vertical ? box.left : box.top);
|
|
235
|
+
out.forEach(({ electron }, index) => {
|
|
236
|
+
const element = elements.current.get(electron.id);
|
|
237
|
+
const box = boxes[electron.id];
|
|
238
|
+
const was = presences.current.get(electron.id);
|
|
239
|
+
const from = element.getBoundingClientRect();
|
|
240
|
+
element.style.left = `${box.left}px`;
|
|
241
|
+
element.style.top = `${box.top}px`;
|
|
242
|
+
const row = String(crossOf(box));
|
|
243
|
+
const changedRow = rows.current.has(electron.id) && rows.current.get(electron.id) !== row;
|
|
244
|
+
rows.current.set(electron.id, row);
|
|
245
|
+
if (!animate) {
|
|
246
|
+
if (changedRow && !reduced && typeof element.animate === "function") {
|
|
247
|
+
const to = element.getBoundingClientRect();
|
|
248
|
+
element.animate([{ translate: `${from.left - to.left}px ${from.top - to.top}px` }, { translate: "0px 0px" }], {
|
|
249
|
+
id: SHIFT,
|
|
250
|
+
duration: timings.change,
|
|
251
|
+
easing: "ease-in-out",
|
|
252
|
+
composite: "add"
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (was === void 0 || was === "hidden") {
|
|
258
|
+
const before = out[index - 1];
|
|
259
|
+
const neighbour = before ? elements.current.get(before.electron.id) : void 0;
|
|
260
|
+
const anchor = neighbour && before && nextTo(boxes[before.electron.id], box, gap) ? neighbour : root;
|
|
261
|
+
require_goo.playSplit(anchor, element, "split", {
|
|
262
|
+
delay: 0,
|
|
263
|
+
duration: require_measure.durations(element).enter
|
|
264
|
+
});
|
|
265
|
+
} else if (moving && (Math.abs(from.left - box.left) > .5 || Math.abs(from.top - box.top) > .5)) {
|
|
266
|
+
const to = element.getBoundingClientRect();
|
|
267
|
+
element.animate([{ translate: `${from.left - to.left}px ${from.top - to.top}px` }, { translate: "0px 0px" }], {
|
|
268
|
+
id: SHIFT,
|
|
269
|
+
duration: timings.change,
|
|
270
|
+
easing: "ease-in-out",
|
|
271
|
+
composite: "add"
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
if (animate) {
|
|
276
|
+
for (const entry of entries) {
|
|
277
|
+
const element = elements.current.get(entry.electron.id);
|
|
278
|
+
if (!element || entry.presence !== "hidden" || presences.current.get(entry.electron.id) !== "compact") continue;
|
|
279
|
+
if ((entry.leaving ? entry.electron.input.ending ?? host.electronEnding : "join") === "pop") continue;
|
|
280
|
+
const { fade, change, exit } = require_measure.durations(element);
|
|
281
|
+
require_goo.playSplit(root, element, "join", {
|
|
282
|
+
delay: fade + change,
|
|
283
|
+
duration: exit
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
for (const entry of entries) presences.current.set(entry.electron.id, entry.presence);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
require_react.useIsomorphicLayoutEffect(() => arrange.current(true));
|
|
290
|
+
(0, react.useEffect)(() => {
|
|
291
|
+
const root = host.rootRef.current;
|
|
292
|
+
if (!root) return;
|
|
293
|
+
const follow = () => arrange.current(false);
|
|
294
|
+
const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(follow);
|
|
295
|
+
observer?.observe(root);
|
|
296
|
+
if (atom.current) observer?.observe(atom.current);
|
|
297
|
+
window.addEventListener("resize", follow);
|
|
298
|
+
return () => {
|
|
299
|
+
observer?.disconnect();
|
|
300
|
+
window.removeEventListener("resize", follow);
|
|
301
|
+
root.style.removeProperty("translate");
|
|
302
|
+
if (!SIDE_PLACEMENTS.has(host.placement)) root.style.removeProperty("--_mp-shift-x");
|
|
303
|
+
applied.current = {
|
|
304
|
+
shift: 0,
|
|
305
|
+
reserve: 0
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
}, [
|
|
309
|
+
host.rootRef,
|
|
310
|
+
host.placement,
|
|
311
|
+
!!shownActions
|
|
312
|
+
]);
|
|
313
|
+
const leavingIds = entries.filter((entry) => entry.leaving).map((entry) => entry.electron.id);
|
|
314
|
+
(0, react.useEffect)(() => {
|
|
315
|
+
if (leavingIds.length === 0) return;
|
|
316
|
+
const timers = leavingIds.map((id) => {
|
|
317
|
+
const element = elements.current.get(id);
|
|
318
|
+
const { fade, change, exit } = element ? require_measure.durations(element) : {
|
|
319
|
+
fade: 150,
|
|
320
|
+
change: 250,
|
|
321
|
+
exit: 300
|
|
322
|
+
};
|
|
323
|
+
return setTimeout(() => {
|
|
324
|
+
shown.current.delete(id);
|
|
325
|
+
presences.current.delete(id);
|
|
326
|
+
rows.current.delete(id);
|
|
327
|
+
refresh();
|
|
328
|
+
}, fade + change + exit + 100);
|
|
329
|
+
});
|
|
330
|
+
return () => timers.forEach(clearTimeout);
|
|
331
|
+
}, [leavingIds.join(" ")]);
|
|
332
|
+
const [announcement, setAnnouncement] = (0, react.useState)("");
|
|
333
|
+
const announced = (0, react.useRef)(/* @__PURE__ */ new Map());
|
|
334
|
+
(0, react.useEffect)(() => {
|
|
335
|
+
for (const electron of electrons) {
|
|
336
|
+
const text = electron.input.announce;
|
|
337
|
+
if (text && announced.current.get(electron.id) !== text) setAnnouncement(text);
|
|
338
|
+
announced.current.set(electron.id, text);
|
|
339
|
+
}
|
|
340
|
+
}, [electrons]);
|
|
341
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
342
|
+
entries.map(({ electron, presence, leaving }) => {
|
|
343
|
+
const ending = electron.input.ending ?? host.electronEnding;
|
|
344
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Pill, {
|
|
345
|
+
ref: (element) => {
|
|
346
|
+
if (element) elements.current.set(electron.id, element);
|
|
347
|
+
else elements.current.delete(electron.id);
|
|
348
|
+
},
|
|
349
|
+
placement: "inline",
|
|
350
|
+
ladder: false,
|
|
351
|
+
moveThroughCircle: false,
|
|
352
|
+
theme: host.theme,
|
|
353
|
+
variant: electron.input.variant ?? host.variant,
|
|
354
|
+
presence,
|
|
355
|
+
"data-satellite": "electron",
|
|
356
|
+
"data-ending": leaving && ending === "pop" ? "pop" : void 0,
|
|
357
|
+
style: ELECTRON_STYLE,
|
|
358
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ElectronBody, {
|
|
359
|
+
electron,
|
|
360
|
+
host
|
|
361
|
+
})
|
|
362
|
+
}, electron.id);
|
|
363
|
+
}),
|
|
364
|
+
shownActions && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Pill, {
|
|
365
|
+
ref: atom,
|
|
366
|
+
placement: "inline",
|
|
367
|
+
ladder: false,
|
|
368
|
+
moveThroughCircle: false,
|
|
369
|
+
theme: host.theme,
|
|
370
|
+
variant: host.variant,
|
|
371
|
+
orientation: host.vertical !== actionsAcross ? "vertical" : "horizontal",
|
|
372
|
+
presence: actionsPresence,
|
|
373
|
+
scene: shownActions.map((item) => item.id ?? item.label).join("\n"),
|
|
374
|
+
role: "group",
|
|
375
|
+
"aria-label": host.actionsLabel,
|
|
376
|
+
"data-satellite": "actions",
|
|
377
|
+
style: ELECTRON_STYLE,
|
|
378
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Actions.ActionList, {
|
|
379
|
+
items: shownActions,
|
|
380
|
+
host
|
|
381
|
+
})
|
|
382
|
+
}),
|
|
383
|
+
entries.map(({ electron, presence }) => electron.input.orbitals?.length ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Orbitals.Orbitals, {
|
|
384
|
+
electron,
|
|
385
|
+
getElement: () => elements.current.get(electron.id),
|
|
386
|
+
host,
|
|
387
|
+
out: presence !== "hidden"
|
|
388
|
+
}, `orbitals ${electron.id}`) : null),
|
|
389
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
390
|
+
role: "status",
|
|
391
|
+
"aria-live": "polite",
|
|
392
|
+
"aria-atomic": "true",
|
|
393
|
+
"data-mp": "announcer",
|
|
394
|
+
style: require_visuallyHidden.VISUALLY_HIDDEN,
|
|
395
|
+
children: announcement
|
|
396
|
+
})
|
|
397
|
+
] });
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
exports.SatellitesLayer = SatellitesLayer;
|