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
|
@@ -14,7 +14,7 @@ const MENU_STYLE = {
|
|
|
14
14
|
position: "fixed",
|
|
15
15
|
inset: 0,
|
|
16
16
|
pointerEvents: "none",
|
|
17
|
-
zIndex: "var(--mp-z-index, 50)"
|
|
17
|
+
zIndex: "calc(var(--mp-z-index, 50) - 2)"
|
|
18
18
|
};
|
|
19
19
|
const ORBITAL_STYLE = {
|
|
20
20
|
position: "fixed",
|
|
@@ -28,6 +28,34 @@ const LABEL_STYLE = {
|
|
|
28
28
|
left: 0,
|
|
29
29
|
top: 0
|
|
30
30
|
};
|
|
31
|
+
const TRACK_STYLE = {
|
|
32
|
+
position: "fixed",
|
|
33
|
+
left: 0,
|
|
34
|
+
top: 0,
|
|
35
|
+
borderRadius: "50%"
|
|
36
|
+
};
|
|
37
|
+
const MARKER_STYLE = {
|
|
38
|
+
position: "fixed",
|
|
39
|
+
left: 0,
|
|
40
|
+
top: 0,
|
|
41
|
+
margin: 0,
|
|
42
|
+
opacity: 0,
|
|
43
|
+
pointerEvents: "none"
|
|
44
|
+
};
|
|
45
|
+
const DOTS_STYLE = {
|
|
46
|
+
...MARKER_STYLE,
|
|
47
|
+
display: "flex",
|
|
48
|
+
gap: 4,
|
|
49
|
+
transition: "opacity 150ms ease-out"
|
|
50
|
+
};
|
|
51
|
+
const DOT_STYLE = {
|
|
52
|
+
display: "block",
|
|
53
|
+
inlineSize: 6,
|
|
54
|
+
blockSize: 6,
|
|
55
|
+
borderRadius: "50%",
|
|
56
|
+
background: "currentColor"
|
|
57
|
+
};
|
|
58
|
+
const ENDS = ["low", "high"];
|
|
31
59
|
/** Another electron opened its orbitals: these close */
|
|
32
60
|
const OPENED = "mp-orbitals-open";
|
|
33
61
|
/** The direction away from the screen's edge, by the host's placement */
|
|
@@ -82,6 +110,17 @@ function Orbitals({ electron, getElement, host, out }) {
|
|
|
82
110
|
const focusFirst = (0, react.useRef)(false);
|
|
83
111
|
const turn = (0, react.useRef)(0);
|
|
84
112
|
const snapping = (0, react.useRef)(0);
|
|
113
|
+
const markers = (0, react.useRef)({
|
|
114
|
+
low: null,
|
|
115
|
+
high: null
|
|
116
|
+
});
|
|
117
|
+
const track = (0, react.useRef)(null);
|
|
118
|
+
const [past, setPast] = (0, react.useState)({
|
|
119
|
+
low: 0,
|
|
120
|
+
high: 0
|
|
121
|
+
});
|
|
122
|
+
const lastPast = (0, react.useRef)(past);
|
|
123
|
+
const surface = (0, react.useRef)("");
|
|
85
124
|
const clearTimers = () => {
|
|
86
125
|
timers.current.forEach(clearTimeout);
|
|
87
126
|
timers.current = [];
|
|
@@ -92,7 +131,7 @@ function Orbitals({ electron, getElement, host, out }) {
|
|
|
92
131
|
if (!element || !root) return null;
|
|
93
132
|
const read = readSettings(element);
|
|
94
133
|
settings.current = read;
|
|
95
|
-
const obstacles = [root, ...document.querySelectorAll("[data-mp=\"pill\"]:is([data-satellite=\"electron\"], [data-satellite=\"actions\"])")].filter((other) => other !== element && other.dataset.presence !== "hidden").map((other) => other.getBoundingClientRect());
|
|
134
|
+
const obstacles = [...[root, ...document.querySelectorAll("[data-mp=\"pill\"]:is([data-satellite=\"electron\"], [data-satellite=\"actions\"])")].filter((other) => other !== element && other.dataset.presence !== "hidden").map((other) => other.getBoundingClientRect()), ...host.avoidPills ? require_measure.otherPills(root) : []];
|
|
96
135
|
orbit.current = require_orbits.planOrbit({
|
|
97
136
|
electron: element.getBoundingClientRect(),
|
|
98
137
|
count: items.length,
|
|
@@ -107,6 +146,14 @@ function Orbitals({ electron, getElement, host, out }) {
|
|
|
107
146
|
},
|
|
108
147
|
rtl: getComputedStyle(root).direction === "rtl"
|
|
109
148
|
});
|
|
149
|
+
if (host.orbitalsMore !== "peek") orbit.current = {
|
|
150
|
+
...orbit.current,
|
|
151
|
+
peek: {
|
|
152
|
+
low: false,
|
|
153
|
+
high: false
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
surface.current = getComputedStyle(element).backgroundColor;
|
|
110
157
|
return read;
|
|
111
158
|
};
|
|
112
159
|
const applyTurn = () => {
|
|
@@ -128,7 +175,49 @@ function Orbitals({ electron, getElement, host, out }) {
|
|
|
128
175
|
pill.style.pointerEvents = closing.current ? "none" : "auto";
|
|
129
176
|
}
|
|
130
177
|
});
|
|
178
|
+
placeMarkers(current);
|
|
131
179
|
placeLabel();
|
|
180
|
+
const disc = track.current;
|
|
181
|
+
if (disc && settings.current) {
|
|
182
|
+
const reach = current.radius + settings.current.size * .8;
|
|
183
|
+
disc.style.width = disc.style.height = `${reach * 2}px`;
|
|
184
|
+
disc.style.translate = `${current.x - reach}px ${current.y - reach}px`;
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
const placeMarkers = (current) => {
|
|
188
|
+
if (host.orbitalsMore === "peek") return;
|
|
189
|
+
const counts = require_orbits.hiddenPast(current, turn.current);
|
|
190
|
+
if (counts.low !== lastPast.current.low || counts.high !== lastPast.current.high) {
|
|
191
|
+
lastPast.current = counts;
|
|
192
|
+
setPast(counts);
|
|
193
|
+
}
|
|
194
|
+
const size = settings.current?.size ?? 44;
|
|
195
|
+
for (const end of ENDS) {
|
|
196
|
+
const marker = markers.current[end];
|
|
197
|
+
if (!marker) continue;
|
|
198
|
+
const on = current.wheel && counts[end] > 0 && !closing.current;
|
|
199
|
+
const length = marker.offsetWidth;
|
|
200
|
+
const height = marker.offsetHeight;
|
|
201
|
+
const outward = host.orbitalsMore === "count" ? size / 2 + Math.min(length, height) / 2 - 2 : size / 2 + 7;
|
|
202
|
+
const spot = require_orbits.pastEnd(current, end, size * .45, outward);
|
|
203
|
+
const reach = Math.max(length, height) / 2 + 6;
|
|
204
|
+
const x = Math.min(Math.max(spot.x, reach), (document.documentElement.clientWidth || window.innerWidth) - reach);
|
|
205
|
+
const y = Math.min(Math.max(spot.y, reach), window.innerHeight - reach);
|
|
206
|
+
marker.style.translate = `${x - length / 2}px ${y - height / 2}px`;
|
|
207
|
+
if (host.orbitalsMore === "dots") {
|
|
208
|
+
marker.style.rotate = `${spot.angle + 90}deg`;
|
|
209
|
+
marker.style.color = surface.current;
|
|
210
|
+
}
|
|
211
|
+
marker.style.opacity = on ? "1" : "0";
|
|
212
|
+
marker.style.pointerEvents = on && host.orbitalsMore === "count" ? "auto" : "none";
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
const turnPage = (end) => {
|
|
216
|
+
const current = orbit.current;
|
|
217
|
+
if (!current?.wheel) return;
|
|
218
|
+
const page = Math.max(1, current.visible - 1);
|
|
219
|
+
const towards = (end === "low" ? -1 : 1) * (current.rtl ? -1 : 1);
|
|
220
|
+
turnTo(Math.round(turn.current) + towards * page, true);
|
|
132
221
|
};
|
|
133
222
|
const placeLabel = () => {
|
|
134
223
|
const label = labelRef.current;
|
|
@@ -383,7 +472,11 @@ function Orbitals({ electron, getElement, host, out }) {
|
|
|
383
472
|
return;
|
|
384
473
|
}
|
|
385
474
|
link?.setAttribute("aria-expanded", "true");
|
|
386
|
-
const inside = (target) => target instanceof Node && ([
|
|
475
|
+
const inside = (target) => target instanceof Node && ([
|
|
476
|
+
...pills.current.values(),
|
|
477
|
+
...Object.values(markers.current),
|
|
478
|
+
track.current
|
|
479
|
+
].some((pill) => !!pill?.contains(target)) || !!link?.contains(target));
|
|
387
480
|
const onPointerDown = (event) => {
|
|
388
481
|
if (!inside(event.target)) api.current.close();
|
|
389
482
|
};
|
|
@@ -413,13 +506,15 @@ function Orbitals({ electron, getElement, host, out }) {
|
|
|
413
506
|
let drag = null;
|
|
414
507
|
const onDragStart = (event) => {
|
|
415
508
|
if (!orbit.current?.wheel || event.button !== 0 || !(event.target instanceof Node)) return;
|
|
416
|
-
|
|
509
|
+
const onTrack = !!track.current?.contains(event.target);
|
|
510
|
+
if (!onTrack && ![...pills.current.values()].some((pill) => pill.contains(event.target))) return;
|
|
417
511
|
drag = {
|
|
418
512
|
angle: angleOf(event),
|
|
419
513
|
turn: turn.current,
|
|
420
514
|
x: event.clientX,
|
|
421
515
|
y: event.clientY,
|
|
422
|
-
moved: false
|
|
516
|
+
moved: false,
|
|
517
|
+
onTrack
|
|
423
518
|
};
|
|
424
519
|
};
|
|
425
520
|
const onDragMove = (event) => {
|
|
@@ -431,8 +526,9 @@ function Orbitals({ electron, getElement, host, out }) {
|
|
|
431
526
|
};
|
|
432
527
|
const onDragEnd = () => {
|
|
433
528
|
if (!drag) return;
|
|
434
|
-
const { moved } = drag;
|
|
529
|
+
const { moved, onTrack } = drag;
|
|
435
530
|
drag = null;
|
|
531
|
+
if (!moved && onTrack) return api.current.close();
|
|
436
532
|
if (!moved) return;
|
|
437
533
|
api.current.snap();
|
|
438
534
|
const swallow = (event) => {
|
|
@@ -492,6 +588,28 @@ function Orbitals({ electron, getElement, host, out }) {
|
|
|
492
588
|
(0, react.useEffect)(() => {
|
|
493
589
|
if (!ring) turn.current = 0;
|
|
494
590
|
}, [ring]);
|
|
591
|
+
const follow = (0, react.useRef)(applyTurn);
|
|
592
|
+
follow.current = applyTurn;
|
|
593
|
+
(0, react.useEffect)(() => {
|
|
594
|
+
if (!ring) return;
|
|
595
|
+
let frame = 0;
|
|
596
|
+
const step = () => {
|
|
597
|
+
const element = getElement();
|
|
598
|
+
const current = orbit.current;
|
|
599
|
+
if (element && current) {
|
|
600
|
+
const rect = element.getBoundingClientRect();
|
|
601
|
+
const dx = rect.left + rect.width / 2 - current.x;
|
|
602
|
+
const dy = rect.top + rect.height / 2 - current.y;
|
|
603
|
+
if (Math.abs(dx) > .5 || Math.abs(dy) > .5) {
|
|
604
|
+
orbit.current = require_orbits.movedOrbit(current, dx, dy);
|
|
605
|
+
follow.current();
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
frame = requestAnimationFrame(step);
|
|
609
|
+
};
|
|
610
|
+
frame = requestAnimationFrame(step);
|
|
611
|
+
return () => cancelAnimationFrame(frame);
|
|
612
|
+
}, [ring]);
|
|
495
613
|
if (!ring || items.length === 0) return null;
|
|
496
614
|
const run = (item) => (event) => {
|
|
497
615
|
item.onClick?.(event);
|
|
@@ -525,60 +643,110 @@ function Orbitals({ electron, getElement, host, out }) {
|
|
|
525
643
|
"aria-label": electron.input.label,
|
|
526
644
|
"data-mp": "orbitals",
|
|
527
645
|
"data-orbitals": electron.id,
|
|
646
|
+
"data-wheel": orbit.current?.wheel ? "" : void 0,
|
|
528
647
|
style: MENU_STYLE,
|
|
529
|
-
children: [
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
"
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
648
|
+
children: [
|
|
649
|
+
orbit.current?.wheel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
650
|
+
ref: track,
|
|
651
|
+
"data-mp": "orbital-track",
|
|
652
|
+
"aria-hidden": "true",
|
|
653
|
+
style: TRACK_STYLE
|
|
654
|
+
}),
|
|
655
|
+
items.map((item, index) => {
|
|
656
|
+
const common = {
|
|
657
|
+
role: "menuitem",
|
|
658
|
+
tabIndex: -1,
|
|
659
|
+
"data-mp": "orbital",
|
|
660
|
+
"aria-label": item.label,
|
|
661
|
+
onClick: run(item),
|
|
662
|
+
onKeyDown: onKeyDown(index),
|
|
663
|
+
onFocus: () => setHot(index)
|
|
664
|
+
};
|
|
665
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Pill, {
|
|
666
|
+
ref: (element) => {
|
|
667
|
+
if (element) pills.current.set(index, element);
|
|
668
|
+
else pills.current.delete(index);
|
|
669
|
+
},
|
|
670
|
+
placement: "inline",
|
|
671
|
+
ladder: false,
|
|
672
|
+
moveThroughCircle: false,
|
|
673
|
+
theme: host.theme,
|
|
674
|
+
variant: electron.input.variant ?? host.variant,
|
|
675
|
+
presence: shown[index] ? "compact" : "hidden",
|
|
676
|
+
"data-satellite": "orbital",
|
|
677
|
+
"data-index": index,
|
|
678
|
+
"data-hot": hot === index ? "" : void 0,
|
|
679
|
+
style: host.tokens ? {
|
|
680
|
+
...host.tokens,
|
|
681
|
+
...ORBITAL_STYLE
|
|
682
|
+
} : ORBITAL_STYLE,
|
|
683
|
+
onPointerEnter: (event) => {
|
|
684
|
+
const moving = event.currentTarget.getAnimations?.().some((animation) => animation.id === "mp-split" && animation.playState === "running");
|
|
685
|
+
if (!closing.current && !moving) setHot(index);
|
|
686
|
+
},
|
|
687
|
+
onPointerLeave: () => setHot(-1),
|
|
688
|
+
children: item.href !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Link, {
|
|
689
|
+
href: item.href,
|
|
690
|
+
...common,
|
|
691
|
+
children: item.icon
|
|
692
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
693
|
+
type: "button",
|
|
694
|
+
...common,
|
|
695
|
+
children: item.icon
|
|
696
|
+
})
|
|
697
|
+
}, item.id ?? index);
|
|
698
|
+
}),
|
|
699
|
+
host.orbitalsMore === "dots" && ENDS.map((end) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
540
700
|
ref: (element) => {
|
|
541
|
-
|
|
542
|
-
|
|
701
|
+
markers.current[end] = element;
|
|
702
|
+
},
|
|
703
|
+
"aria-hidden": "true",
|
|
704
|
+
"data-mp": "orbital-dots",
|
|
705
|
+
"data-end": end,
|
|
706
|
+
style: DOTS_STYLE,
|
|
707
|
+
children: Array.from({ length: Math.min(3, past[end]) }, (_, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", { style: DOT_STYLE }, index))
|
|
708
|
+
}, end)),
|
|
709
|
+
host.orbitalsMore === "count" && ENDS.map((end) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Pill, {
|
|
710
|
+
ref: (element) => {
|
|
711
|
+
markers.current[end] = element;
|
|
543
712
|
},
|
|
544
713
|
placement: "inline",
|
|
545
714
|
ladder: false,
|
|
546
715
|
moveThroughCircle: false,
|
|
547
716
|
theme: host.theme,
|
|
548
717
|
variant: electron.input.variant ?? host.variant,
|
|
549
|
-
presence:
|
|
550
|
-
"data-satellite": "orbital",
|
|
551
|
-
"data-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
},
|
|
558
|
-
onPointerLeave: () => setHot(-1),
|
|
559
|
-
children: item.href !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Link, {
|
|
560
|
-
href: item.href,
|
|
561
|
-
...common,
|
|
562
|
-
children: item.icon
|
|
563
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
718
|
+
presence: "compact",
|
|
719
|
+
"data-satellite": "orbital-more",
|
|
720
|
+
"data-end": end,
|
|
721
|
+
style: host.tokens ? {
|
|
722
|
+
...host.tokens,
|
|
723
|
+
...MARKER_STYLE
|
|
724
|
+
} : MARKER_STYLE,
|
|
725
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
564
726
|
type: "button",
|
|
565
|
-
|
|
566
|
-
|
|
727
|
+
tabIndex: -1,
|
|
728
|
+
"aria-hidden": "true",
|
|
729
|
+
onClick: () => turnPage(end),
|
|
730
|
+
children: ["+", past[end]]
|
|
567
731
|
})
|
|
568
|
-
},
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
732
|
+
}, end)),
|
|
733
|
+
host.orbitalLabels && hot >= 0 && items[hot] && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Pill, {
|
|
734
|
+
ref: labelRef,
|
|
735
|
+
placement: "inline",
|
|
736
|
+
ladder: false,
|
|
737
|
+
moveThroughCircle: false,
|
|
738
|
+
theme: host.theme,
|
|
739
|
+
variant: electron.input.variant ?? host.variant,
|
|
740
|
+
presence: "compact",
|
|
741
|
+
"aria-hidden": "true",
|
|
742
|
+
"data-satellite": "orbital-label",
|
|
743
|
+
style: host.tokens ? {
|
|
744
|
+
...host.tokens,
|
|
745
|
+
...LABEL_STYLE
|
|
746
|
+
} : LABEL_STYLE,
|
|
747
|
+
children: items[hot].label
|
|
748
|
+
})
|
|
749
|
+
]
|
|
582
750
|
});
|
|
583
751
|
}
|
|
584
752
|
|