magic-pill 9.4.0-next.2 → 9.4.0-next.4
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 +38 -2
- package/README.md +25 -17
- package/dist/MagicPill/MagicPill.d.mts +16 -2
- package/dist/MagicPill/MagicPill.d.ts +16 -2
- package/dist/MagicPill/MagicPill.js +12 -3
- package/dist/MagicPill/MagicPill.mjs +12 -3
- package/dist/Pill/Pill.js +1 -0
- package/dist/Pill/Pill.mjs +1 -0
- package/dist/Pill/goo.js +110 -35
- package/dist/Pill/goo.mjs +110 -36
- package/dist/Pill/modal.js +3 -1
- package/dist/Pill/modal.mjs +3 -1
- package/dist/Pill/morph.js +64 -10
- package/dist/Pill/morph.mjs +64 -11
- package/dist/Pill/zone.js +1 -2
- package/dist/Pill/zone.mjs +1 -2
- package/dist/PillForm/PillForm.js +6 -1
- package/dist/PillForm/PillForm.mjs +7 -2
- package/dist/PillForm/dates.js +14 -3
- package/dist/PillForm/dates.mjs +14 -3
- package/dist/PillForm/room.js +46 -0
- package/dist/PillForm/room.mjs +46 -0
- package/dist/PillNavbar/PillNavbar.js +3 -1
- package/dist/PillNavbar/PillNavbar.mjs +4 -2
- package/dist/PillNavbar/room.js +99 -24
- package/dist/PillNavbar/room.mjs +98 -25
- package/dist/PillNotification/PillNotification.js +2 -4
- package/dist/PillNotification/PillNotification.mjs +2 -4
- package/dist/PillNotification/RowsBody.js +77 -0
- package/dist/PillNotification/RowsBody.mjs +77 -0
- package/dist/forms.css +14 -0
- package/dist/satellites/Actions.js +181 -6
- package/dist/satellites/Actions.mjs +182 -7
- package/dist/satellites/Orbitals.js +218 -50
- package/dist/satellites/Orbitals.mjs +220 -52
- package/dist/satellites/Satellites.js +495 -107
- package/dist/satellites/Satellites.mjs +498 -111
- package/dist/satellites/handoff.js +36 -0
- package/dist/satellites/handoff.mjs +34 -0
- package/dist/satellites/layout.js +69 -3
- package/dist/satellites/layout.mjs +69 -4
- package/dist/satellites/measure.js +22 -0
- package/dist/satellites/measure.mjs +22 -1
- package/dist/satellites/orbits.js +49 -2
- package/dist/satellites/orbits.mjs +47 -3
- package/dist/satellites/types.d.mts +15 -1
- package/dist/satellites/types.d.ts +15 -1
- package/dist/satellites.d.mts +2 -2
- package/dist/satellites.d.ts +2 -2
- package/dist/styles.css +103 -15
- package/package.json +1 -1
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
let react = require("react");
|
|
4
|
+
const require_morph = require("../Pill/morph.js");
|
|
4
5
|
const require_PillAction = require("../Pill/PillAction.js");
|
|
5
6
|
const require_parts = require("../Pill/parts.js");
|
|
6
7
|
const require_store = require("../store/store.js");
|
|
8
|
+
const require_react = require("../utils/react.js");
|
|
9
|
+
const require_timing = require("../utils/timing.js");
|
|
10
|
+
const require_handoff = require("./handoff.js");
|
|
7
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
12
|
|
|
9
13
|
// src/satellites/Actions.tsx
|
|
@@ -139,12 +143,13 @@ function useActionsWheel(track) {
|
|
|
139
143
|
* a link or a button. `wheel`: cut short to that length, in px, turning to
|
|
140
144
|
* show the others.
|
|
141
145
|
*/
|
|
142
|
-
function ActionList({ items, host, wheel, inside }) {
|
|
146
|
+
function ActionList({ items, host, wheel, inside, leaving }) {
|
|
143
147
|
const track = (0, react.useRef)(null);
|
|
144
148
|
useActionsWheel(track);
|
|
145
149
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_parts.PillActions, {
|
|
146
150
|
ref: track,
|
|
147
151
|
"data-inside": inside ? "" : void 0,
|
|
152
|
+
"data-leaving": leaving ? "" : void 0,
|
|
148
153
|
"data-wheel": wheel !== void 0 ? "" : void 0,
|
|
149
154
|
style: wheel !== void 0 ? { "--_mp-wheel-length": `${wheel}px` } : void 0,
|
|
150
155
|
children: items.map((item) => item.href !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillAction, {
|
|
@@ -162,16 +167,186 @@ function ActionList({ items, host, wheel, inside }) {
|
|
|
162
167
|
}, item.id ?? item.label))
|
|
163
168
|
});
|
|
164
169
|
}
|
|
165
|
-
/**
|
|
170
|
+
/** The actions in the pill opening or folding away (playInside), or held closed until they open */
|
|
171
|
+
const INSIDE = "mp-inside-actions";
|
|
172
|
+
/** Their row and its divider with nothing of them left: no length, no gap on either side of the divider */
|
|
173
|
+
function closedFrames(pill) {
|
|
174
|
+
const vertical = pill.dataset.orientation === "vertical";
|
|
175
|
+
const size = vertical ? "height" : "width";
|
|
176
|
+
const [start, end] = vertical ? ["marginBlockStart", "marginBlockEnd"] : ["marginInlineStart", "marginInlineEnd"];
|
|
177
|
+
const style = getComputedStyle(pill);
|
|
178
|
+
const gap = Number.parseFloat(vertical ? style.rowGap : style.columnGap) || 0;
|
|
179
|
+
return {
|
|
180
|
+
size,
|
|
181
|
+
start,
|
|
182
|
+
end,
|
|
183
|
+
list: {
|
|
184
|
+
opacity: 0,
|
|
185
|
+
[size]: "0px"
|
|
186
|
+
},
|
|
187
|
+
divider: {
|
|
188
|
+
opacity: 0,
|
|
189
|
+
[size]: "0px",
|
|
190
|
+
[start]: `${-gap}px`,
|
|
191
|
+
[end]: `${-gap}px`
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* The actions in the pill opening out of nothing as they come (their row growing, then showing), or
|
|
197
|
+
* folding back into nothing before they go: the pill follows its content at each frame, and the
|
|
198
|
+
* satellites follow the pill. Their divider and its gaps go with them. Undefined: no motion.
|
|
199
|
+
*/
|
|
200
|
+
function playInside(list, divider, kind) {
|
|
201
|
+
const pill = list.closest("[data-mp=\"pill\"]");
|
|
202
|
+
if (!pill || typeof list.animate !== "function" || require_timing.prefersReducedMotion()) return void 0;
|
|
203
|
+
const { fade, change } = require_morph.readMorphTimings(pill);
|
|
204
|
+
if (fade + change <= 0) return void 0;
|
|
205
|
+
const closed = closedFrames(pill);
|
|
206
|
+
const { size, start, end } = closed;
|
|
207
|
+
const vertical = size === "height";
|
|
208
|
+
const length = vertical ? list.offsetHeight : list.offsetWidth;
|
|
209
|
+
const thickness = vertical ? divider.offsetHeight : divider.offsetWidth;
|
|
210
|
+
const grown = {
|
|
211
|
+
list: { [size]: `${length}px` },
|
|
212
|
+
divider: {
|
|
213
|
+
[size]: `${thickness}px`,
|
|
214
|
+
[start]: "0px",
|
|
215
|
+
[end]: "0px"
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
const frames = (part) => kind === "in" ? [
|
|
219
|
+
closed[part],
|
|
220
|
+
{
|
|
221
|
+
...grown[part],
|
|
222
|
+
opacity: 0,
|
|
223
|
+
offset: change / (fade + change)
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
...grown[part],
|
|
227
|
+
opacity: 1
|
|
228
|
+
}
|
|
229
|
+
] : [
|
|
230
|
+
{
|
|
231
|
+
...grown[part],
|
|
232
|
+
opacity: 1
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
...grown[part],
|
|
236
|
+
opacity: 0,
|
|
237
|
+
offset: fade / (fade + change)
|
|
238
|
+
},
|
|
239
|
+
closed[part]
|
|
240
|
+
];
|
|
241
|
+
const options = {
|
|
242
|
+
id: INSIDE,
|
|
243
|
+
duration: fade + change,
|
|
244
|
+
easing: "ease-in-out",
|
|
245
|
+
fill: kind === "out" ? "forwards" : "none"
|
|
246
|
+
};
|
|
247
|
+
list.style.overflow = "clip";
|
|
248
|
+
const animation = list.animate(frames("list"), options);
|
|
249
|
+
divider.animate(frames("divider"), options);
|
|
250
|
+
const done = () => list.style.removeProperty("overflow");
|
|
251
|
+
animation.finished.then(done, done);
|
|
252
|
+
return animation;
|
|
253
|
+
}
|
|
254
|
+
/** Stops their motion (an opening, a fold, the hold before they open) */
|
|
255
|
+
const stopInside = (...elements) => {
|
|
256
|
+
for (const element of elements) for (const animation of element?.getAnimations?.() ?? []) if (animation.id === INSIDE) animation.cancel();
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* In the pill itself (`actionsStyle="inside"`): the actions, then a divider (the other way round on
|
|
260
|
+
* the end side). They open out of nothing as they come, and fold away before they go. Switching to
|
|
261
|
+
* the pill, they wait for their own pill to go back into it; switching away, their own pill waits
|
|
262
|
+
* for them to have gone (handoff.ts).
|
|
263
|
+
*/
|
|
166
264
|
function InsideActions({ host }) {
|
|
167
265
|
const items = useHostActions(host);
|
|
168
|
-
|
|
266
|
+
const handoff = require_handoff.useHandoff(host.store);
|
|
267
|
+
const inside = host.actionsStyle === "inside";
|
|
268
|
+
const [style, setStyle] = (0, react.useState)(host.actionsStyle);
|
|
269
|
+
const [waiting, setWaiting] = (0, react.useState)(false);
|
|
270
|
+
const waits = style !== host.actionsStyle ? inside && style === "detached" && !!items : waiting;
|
|
271
|
+
if (style !== host.actionsStyle) {
|
|
272
|
+
setStyle(host.actionsStyle);
|
|
273
|
+
setWaiting(waits);
|
|
274
|
+
}
|
|
275
|
+
(0, react.useEffect)(() => {
|
|
276
|
+
if (waiting) setWaiting(false);
|
|
277
|
+
}, [waiting]);
|
|
278
|
+
const wanted = inside && handoff !== "in" && !waits ? items : null;
|
|
279
|
+
const [shown, setShown] = (0, react.useState)(wanted);
|
|
280
|
+
if (wanted && wanted !== shown) setShown(wanted);
|
|
281
|
+
const listed = wanted ?? shown;
|
|
282
|
+
const leaving = !wanted && !!shown;
|
|
283
|
+
const divider = (0, react.useRef)(null);
|
|
284
|
+
const store = host.store;
|
|
285
|
+
const handingOut = leaving && !inside && !!items;
|
|
286
|
+
const open = !!listed && !leaving;
|
|
287
|
+
const sideOf = () => {
|
|
288
|
+
const line = divider.current;
|
|
289
|
+
return {
|
|
290
|
+
line,
|
|
291
|
+
list: (host.actionsSide === "end" ? line?.nextElementSibling : line?.previousElementSibling) ?? null
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
require_react.useIsomorphicLayoutEffect(() => {
|
|
295
|
+
const { line, list } = sideOf();
|
|
296
|
+
const pill = list?.closest("[data-mp=\"pill\"]");
|
|
297
|
+
if (!open || !line || !list || !pill || typeof list.animate !== "function" || require_timing.prefersReducedMotion()) return;
|
|
298
|
+
const closed = closedFrames(pill);
|
|
299
|
+
const hold = {
|
|
300
|
+
id: INSIDE,
|
|
301
|
+
duration: 6e4,
|
|
302
|
+
fill: "forwards"
|
|
303
|
+
};
|
|
304
|
+
list.style.overflow = "clip";
|
|
305
|
+
list.animate([closed.list, closed.list], hold);
|
|
306
|
+
line.animate([closed.divider, closed.divider], hold);
|
|
307
|
+
const frame = requestAnimationFrame(() => {
|
|
308
|
+
stopInside(list, line);
|
|
309
|
+
playInside(list, line, "in");
|
|
310
|
+
});
|
|
311
|
+
return () => {
|
|
312
|
+
cancelAnimationFrame(frame);
|
|
313
|
+
stopInside(list, line);
|
|
314
|
+
list.style.removeProperty("overflow");
|
|
315
|
+
};
|
|
316
|
+
}, [open]);
|
|
317
|
+
require_react.useIsomorphicLayoutEffect(() => {
|
|
318
|
+
if (!leaving) return;
|
|
319
|
+
if (handingOut) require_handoff.setHandoff(store, "out");
|
|
320
|
+
const { line, list } = sideOf();
|
|
321
|
+
let cancelled = false;
|
|
322
|
+
const gone = () => {
|
|
323
|
+
if (cancelled) return;
|
|
324
|
+
setShown(null);
|
|
325
|
+
if (require_handoff.getHandoff(store) === "out") require_handoff.setHandoff(store, void 0);
|
|
326
|
+
};
|
|
327
|
+
stopInside(list, line);
|
|
328
|
+
const animation = list && line ? playInside(list, line, "out") : void 0;
|
|
329
|
+
if (animation) animation.finished.then(gone, () => {});
|
|
330
|
+
else gone();
|
|
331
|
+
return () => {
|
|
332
|
+
cancelled = true;
|
|
333
|
+
stopInside(list, line);
|
|
334
|
+
list?.style.removeProperty("overflow");
|
|
335
|
+
if (require_handoff.getHandoff(store) === "out") require_handoff.setHandoff(store, void 0);
|
|
336
|
+
};
|
|
337
|
+
}, [leaving]);
|
|
338
|
+
if (!listed) return null;
|
|
169
339
|
const list = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActionList, {
|
|
170
|
-
items,
|
|
340
|
+
items: listed,
|
|
171
341
|
host,
|
|
172
|
-
inside: true
|
|
342
|
+
inside: true,
|
|
343
|
+
leaving
|
|
344
|
+
});
|
|
345
|
+
const line = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_parts.PillDivider, {
|
|
346
|
+
ref: divider,
|
|
347
|
+
"data-leaving": leaving ? "" : void 0
|
|
173
348
|
});
|
|
174
|
-
return host.actionsSide === "end" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
349
|
+
return host.actionsSide === "end" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [line, list] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [list, line] });
|
|
175
350
|
}
|
|
176
351
|
|
|
177
352
|
exports.ActionList = ActionList;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { useEffect, useRef, useSyncExternalStore } from "react";
|
|
3
|
+
import { useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
4
|
+
import { readMorphTimings } from "../Pill/morph.mjs";
|
|
4
5
|
import PillAction from "../Pill/PillAction.mjs";
|
|
5
6
|
import { PillActions, PillDivider } from "../Pill/parts.mjs";
|
|
6
7
|
import { getStore } from "../store/store.mjs";
|
|
8
|
+
import { useIsomorphicLayoutEffect } from "../utils/react.mjs";
|
|
9
|
+
import { prefersReducedMotion } from "../utils/timing.mjs";
|
|
10
|
+
import { getHandoff, setHandoff, useHandoff } from "./handoff.mjs";
|
|
7
11
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
12
|
|
|
9
13
|
// src/satellites/Actions.tsx
|
|
@@ -139,12 +143,13 @@ function useActionsWheel(track) {
|
|
|
139
143
|
* a link or a button. `wheel`: cut short to that length, in px, turning to
|
|
140
144
|
* show the others.
|
|
141
145
|
*/
|
|
142
|
-
function ActionList({ items, host, wheel, inside }) {
|
|
146
|
+
function ActionList({ items, host, wheel, inside, leaving }) {
|
|
143
147
|
const track = useRef(null);
|
|
144
148
|
useActionsWheel(track);
|
|
145
149
|
return /* @__PURE__ */ jsx(PillActions, {
|
|
146
150
|
ref: track,
|
|
147
151
|
"data-inside": inside ? "" : void 0,
|
|
152
|
+
"data-leaving": leaving ? "" : void 0,
|
|
148
153
|
"data-wheel": wheel !== void 0 ? "" : void 0,
|
|
149
154
|
style: wheel !== void 0 ? { "--_mp-wheel-length": `${wheel}px` } : void 0,
|
|
150
155
|
children: items.map((item) => item.href !== void 0 ? /* @__PURE__ */ jsx(PillAction, {
|
|
@@ -162,16 +167,186 @@ function ActionList({ items, host, wheel, inside }) {
|
|
|
162
167
|
}, item.id ?? item.label))
|
|
163
168
|
});
|
|
164
169
|
}
|
|
165
|
-
/**
|
|
170
|
+
/** The actions in the pill opening or folding away (playInside), or held closed until they open */
|
|
171
|
+
const INSIDE = "mp-inside-actions";
|
|
172
|
+
/** Their row and its divider with nothing of them left: no length, no gap on either side of the divider */
|
|
173
|
+
function closedFrames(pill) {
|
|
174
|
+
const vertical = pill.dataset.orientation === "vertical";
|
|
175
|
+
const size = vertical ? "height" : "width";
|
|
176
|
+
const [start, end] = vertical ? ["marginBlockStart", "marginBlockEnd"] : ["marginInlineStart", "marginInlineEnd"];
|
|
177
|
+
const style = getComputedStyle(pill);
|
|
178
|
+
const gap = Number.parseFloat(vertical ? style.rowGap : style.columnGap) || 0;
|
|
179
|
+
return {
|
|
180
|
+
size,
|
|
181
|
+
start,
|
|
182
|
+
end,
|
|
183
|
+
list: {
|
|
184
|
+
opacity: 0,
|
|
185
|
+
[size]: "0px"
|
|
186
|
+
},
|
|
187
|
+
divider: {
|
|
188
|
+
opacity: 0,
|
|
189
|
+
[size]: "0px",
|
|
190
|
+
[start]: `${-gap}px`,
|
|
191
|
+
[end]: `${-gap}px`
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* The actions in the pill opening out of nothing as they come (their row growing, then showing), or
|
|
197
|
+
* folding back into nothing before they go: the pill follows its content at each frame, and the
|
|
198
|
+
* satellites follow the pill. Their divider and its gaps go with them. Undefined: no motion.
|
|
199
|
+
*/
|
|
200
|
+
function playInside(list, divider, kind) {
|
|
201
|
+
const pill = list.closest("[data-mp=\"pill\"]");
|
|
202
|
+
if (!pill || typeof list.animate !== "function" || prefersReducedMotion()) return void 0;
|
|
203
|
+
const { fade, change } = readMorphTimings(pill);
|
|
204
|
+
if (fade + change <= 0) return void 0;
|
|
205
|
+
const closed = closedFrames(pill);
|
|
206
|
+
const { size, start, end } = closed;
|
|
207
|
+
const vertical = size === "height";
|
|
208
|
+
const length = vertical ? list.offsetHeight : list.offsetWidth;
|
|
209
|
+
const thickness = vertical ? divider.offsetHeight : divider.offsetWidth;
|
|
210
|
+
const grown = {
|
|
211
|
+
list: { [size]: `${length}px` },
|
|
212
|
+
divider: {
|
|
213
|
+
[size]: `${thickness}px`,
|
|
214
|
+
[start]: "0px",
|
|
215
|
+
[end]: "0px"
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
const frames = (part) => kind === "in" ? [
|
|
219
|
+
closed[part],
|
|
220
|
+
{
|
|
221
|
+
...grown[part],
|
|
222
|
+
opacity: 0,
|
|
223
|
+
offset: change / (fade + change)
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
...grown[part],
|
|
227
|
+
opacity: 1
|
|
228
|
+
}
|
|
229
|
+
] : [
|
|
230
|
+
{
|
|
231
|
+
...grown[part],
|
|
232
|
+
opacity: 1
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
...grown[part],
|
|
236
|
+
opacity: 0,
|
|
237
|
+
offset: fade / (fade + change)
|
|
238
|
+
},
|
|
239
|
+
closed[part]
|
|
240
|
+
];
|
|
241
|
+
const options = {
|
|
242
|
+
id: INSIDE,
|
|
243
|
+
duration: fade + change,
|
|
244
|
+
easing: "ease-in-out",
|
|
245
|
+
fill: kind === "out" ? "forwards" : "none"
|
|
246
|
+
};
|
|
247
|
+
list.style.overflow = "clip";
|
|
248
|
+
const animation = list.animate(frames("list"), options);
|
|
249
|
+
divider.animate(frames("divider"), options);
|
|
250
|
+
const done = () => list.style.removeProperty("overflow");
|
|
251
|
+
animation.finished.then(done, done);
|
|
252
|
+
return animation;
|
|
253
|
+
}
|
|
254
|
+
/** Stops their motion (an opening, a fold, the hold before they open) */
|
|
255
|
+
const stopInside = (...elements) => {
|
|
256
|
+
for (const element of elements) for (const animation of element?.getAnimations?.() ?? []) if (animation.id === INSIDE) animation.cancel();
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* In the pill itself (`actionsStyle="inside"`): the actions, then a divider (the other way round on
|
|
260
|
+
* the end side). They open out of nothing as they come, and fold away before they go. Switching to
|
|
261
|
+
* the pill, they wait for their own pill to go back into it; switching away, their own pill waits
|
|
262
|
+
* for them to have gone (handoff.ts).
|
|
263
|
+
*/
|
|
166
264
|
function InsideActions({ host }) {
|
|
167
265
|
const items = useHostActions(host);
|
|
168
|
-
|
|
266
|
+
const handoff = useHandoff(host.store);
|
|
267
|
+
const inside = host.actionsStyle === "inside";
|
|
268
|
+
const [style, setStyle] = useState(host.actionsStyle);
|
|
269
|
+
const [waiting, setWaiting] = useState(false);
|
|
270
|
+
const waits = style !== host.actionsStyle ? inside && style === "detached" && !!items : waiting;
|
|
271
|
+
if (style !== host.actionsStyle) {
|
|
272
|
+
setStyle(host.actionsStyle);
|
|
273
|
+
setWaiting(waits);
|
|
274
|
+
}
|
|
275
|
+
useEffect(() => {
|
|
276
|
+
if (waiting) setWaiting(false);
|
|
277
|
+
}, [waiting]);
|
|
278
|
+
const wanted = inside && handoff !== "in" && !waits ? items : null;
|
|
279
|
+
const [shown, setShown] = useState(wanted);
|
|
280
|
+
if (wanted && wanted !== shown) setShown(wanted);
|
|
281
|
+
const listed = wanted ?? shown;
|
|
282
|
+
const leaving = !wanted && !!shown;
|
|
283
|
+
const divider = useRef(null);
|
|
284
|
+
const store = host.store;
|
|
285
|
+
const handingOut = leaving && !inside && !!items;
|
|
286
|
+
const open = !!listed && !leaving;
|
|
287
|
+
const sideOf = () => {
|
|
288
|
+
const line = divider.current;
|
|
289
|
+
return {
|
|
290
|
+
line,
|
|
291
|
+
list: (host.actionsSide === "end" ? line?.nextElementSibling : line?.previousElementSibling) ?? null
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
useIsomorphicLayoutEffect(() => {
|
|
295
|
+
const { line, list } = sideOf();
|
|
296
|
+
const pill = list?.closest("[data-mp=\"pill\"]");
|
|
297
|
+
if (!open || !line || !list || !pill || typeof list.animate !== "function" || prefersReducedMotion()) return;
|
|
298
|
+
const closed = closedFrames(pill);
|
|
299
|
+
const hold = {
|
|
300
|
+
id: INSIDE,
|
|
301
|
+
duration: 6e4,
|
|
302
|
+
fill: "forwards"
|
|
303
|
+
};
|
|
304
|
+
list.style.overflow = "clip";
|
|
305
|
+
list.animate([closed.list, closed.list], hold);
|
|
306
|
+
line.animate([closed.divider, closed.divider], hold);
|
|
307
|
+
const frame = requestAnimationFrame(() => {
|
|
308
|
+
stopInside(list, line);
|
|
309
|
+
playInside(list, line, "in");
|
|
310
|
+
});
|
|
311
|
+
return () => {
|
|
312
|
+
cancelAnimationFrame(frame);
|
|
313
|
+
stopInside(list, line);
|
|
314
|
+
list.style.removeProperty("overflow");
|
|
315
|
+
};
|
|
316
|
+
}, [open]);
|
|
317
|
+
useIsomorphicLayoutEffect(() => {
|
|
318
|
+
if (!leaving) return;
|
|
319
|
+
if (handingOut) setHandoff(store, "out");
|
|
320
|
+
const { line, list } = sideOf();
|
|
321
|
+
let cancelled = false;
|
|
322
|
+
const gone = () => {
|
|
323
|
+
if (cancelled) return;
|
|
324
|
+
setShown(null);
|
|
325
|
+
if (getHandoff(store) === "out") setHandoff(store, void 0);
|
|
326
|
+
};
|
|
327
|
+
stopInside(list, line);
|
|
328
|
+
const animation = list && line ? playInside(list, line, "out") : void 0;
|
|
329
|
+
if (animation) animation.finished.then(gone, () => {});
|
|
330
|
+
else gone();
|
|
331
|
+
return () => {
|
|
332
|
+
cancelled = true;
|
|
333
|
+
stopInside(list, line);
|
|
334
|
+
list?.style.removeProperty("overflow");
|
|
335
|
+
if (getHandoff(store) === "out") setHandoff(store, void 0);
|
|
336
|
+
};
|
|
337
|
+
}, [leaving]);
|
|
338
|
+
if (!listed) return null;
|
|
169
339
|
const list = /* @__PURE__ */ jsx(ActionList, {
|
|
170
|
-
items,
|
|
340
|
+
items: listed,
|
|
171
341
|
host,
|
|
172
|
-
inside: true
|
|
342
|
+
inside: true,
|
|
343
|
+
leaving
|
|
344
|
+
});
|
|
345
|
+
const line = /* @__PURE__ */ jsx(PillDivider, {
|
|
346
|
+
ref: divider,
|
|
347
|
+
"data-leaving": leaving ? "" : void 0
|
|
173
348
|
});
|
|
174
|
-
return host.actionsSide === "end" ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
349
|
+
return host.actionsSide === "end" ? /* @__PURE__ */ jsxs(Fragment$1, { children: [line, list] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [list, line] });
|
|
175
350
|
}
|
|
176
351
|
|
|
177
352
|
export { ActionList, InsideActions, useActionsWheel, useHostActions, usePillActions };
|