magic-pill 9.1.1 → 9.3.0
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 +32 -0
- package/MIGRATING.md +2 -0
- package/README.md +55 -17
- package/dist/MagicPill/MagicPill.d.mts +9 -1
- package/dist/MagicPill/MagicPill.d.ts +9 -1
- package/dist/MagicPill/MagicPill.js +208 -107
- package/dist/MagicPill/MagicPill.mjs +211 -110
- package/dist/MagicPill/flag.js +93 -0
- package/dist/MagicPill/flag.mjs +91 -0
- package/dist/MagicPill/useChoreography.js +66 -0
- package/dist/MagicPill/useChoreography.mjs +66 -0
- package/dist/Pill/Pill.js +20 -9
- package/dist/Pill/Pill.mjs +21 -10
- package/dist/Pill/modal.js +2 -1
- package/dist/Pill/modal.mjs +3 -2
- package/dist/Pill/morph.js +178 -26
- package/dist/Pill/morph.mjs +178 -28
- package/dist/Pill/travel.js +77 -0
- package/dist/Pill/travel.mjs +76 -0
- package/dist/Pill/types.d.mts +8 -0
- package/dist/Pill/types.d.ts +8 -0
- package/dist/Pill/zone.js +3 -2
- package/dist/Pill/zone.mjs +4 -3
- package/dist/PillForm/PillField.js +16 -1
- package/dist/PillForm/PillField.mjs +17 -2
- 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.js +2 -1
- package/dist/PillNavbar/PillNavbar.mjs +2 -1
- package/dist/PillNotification/PillNotification.d.mts +16 -1
- package/dist/PillNotification/PillNotification.d.ts +16 -1
- package/dist/PillNotification/PillNotification.js +41 -30
- package/dist/PillNotification/PillNotification.mjs +41 -30
- package/dist/PillOptics/PillOptics.js +2 -1
- package/dist/PillOptics/PillOptics.mjs +3 -2
- package/dist/forms.css +40 -27
- package/dist/index.d.mts +29 -15
- package/dist/index.d.ts +29 -15
- package/dist/index.js +38 -12
- package/dist/index.mjs +38 -12
- package/dist/store/store.d.mts +9 -1
- package/dist/store/store.d.ts +9 -1
- package/dist/styles.css +91 -3
- package/dist/utils/react.js +8 -1
- package/dist/utils/react.mjs +8 -2
- package/package.json +2 -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
|
@@ -2,15 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
let react = require("react");
|
|
4
4
|
const require_Pill = require("../Pill/Pill.js");
|
|
5
|
-
const require_morph = require("../Pill/morph.js");
|
|
6
5
|
const require_parts = require("../Pill/parts.js");
|
|
7
6
|
const require_PillNotification = require("../PillNotification/PillNotification.js");
|
|
8
7
|
const require_store = require("../store/store.js");
|
|
9
8
|
const require_inputModality = require("../utils/inputModality.js");
|
|
10
9
|
const require_usePillQueue = require("../store/usePillQueue.js");
|
|
11
10
|
const require_react = require("../utils/react.js");
|
|
11
|
+
const require_timing = require("../utils/timing.js");
|
|
12
12
|
const require_visuallyHidden = require("../utils/visuallyHidden.js");
|
|
13
13
|
const require_choreography = require("./choreography.js");
|
|
14
|
+
const require_flag = require("./flag.js");
|
|
15
|
+
const require_useChoreography = require("./useChoreography.js");
|
|
14
16
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
15
17
|
|
|
16
18
|
// src/MagicPill/MagicPill.tsx
|
|
@@ -33,14 +35,59 @@ function useDocumentHidden() {
|
|
|
33
35
|
return hidden;
|
|
34
36
|
}
|
|
35
37
|
/**
|
|
38
|
+
* Pauses a notification while it's pointed at or has the keyboard focus
|
|
39
|
+
* (Y3, L22). The handlers go on the pill that shows it.
|
|
40
|
+
*/
|
|
41
|
+
function usePause(rootRef, presence) {
|
|
42
|
+
const [hovered, setHovered] = (0, react.useState)(false);
|
|
43
|
+
const [focused, setFocused] = (0, react.useState)(false);
|
|
44
|
+
(0, react.useEffect)(() => {
|
|
45
|
+
if (presence === "hidden") {
|
|
46
|
+
setHovered(false);
|
|
47
|
+
setFocused(false);
|
|
48
|
+
}
|
|
49
|
+
}, [presence]);
|
|
50
|
+
(0, react.useEffect)(() => {
|
|
51
|
+
const root = rootRef.current;
|
|
52
|
+
if (!focused || !root) return;
|
|
53
|
+
const update = () => {
|
|
54
|
+
if (!root.contains(document.activeElement)) setFocused(false);
|
|
55
|
+
};
|
|
56
|
+
update();
|
|
57
|
+
const observer = new MutationObserver(update);
|
|
58
|
+
observer.observe(root, {
|
|
59
|
+
childList: true,
|
|
60
|
+
subtree: true
|
|
61
|
+
});
|
|
62
|
+
return () => observer.disconnect();
|
|
63
|
+
}, [rootRef, focused]);
|
|
64
|
+
return {
|
|
65
|
+
active: hovered || focused,
|
|
66
|
+
handlers: {
|
|
67
|
+
onPointerEnter: (event) => {
|
|
68
|
+
if (event.pointerType !== "touch") setHovered(true);
|
|
69
|
+
},
|
|
70
|
+
onPointerLeave: () => setHovered(false),
|
|
71
|
+
onFocus: () => {
|
|
72
|
+
if (require_inputModality.getInputModality() === "keyboard") setFocused(true);
|
|
73
|
+
},
|
|
74
|
+
onBlur: (event) => {
|
|
75
|
+
if (!event.currentTarget.contains(event.relatedTarget)) setFocused(false);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const notificationIn = ({ scene, presence }) => scene.kind === "notification" && require_choreography.isOpen(presence) ? scene.item : null;
|
|
81
|
+
/**
|
|
36
82
|
* The batteries-included pill: a <Pill> with a base layer, a queue of
|
|
37
83
|
* notifications fed by pill(name), and a live region that announces them.
|
|
38
84
|
*/
|
|
39
|
-
const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", children, scene, duration = DEFAULT_DURATION, idle = "hidden", idleIcon, swap = "queue", linkComponent, classNames, placement = "bottom", variant, onPointerEnter, onPointerLeave, onFocus, onBlur, ...rest }, forwardedRef) {
|
|
85
|
+
const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", children, scene, duration = DEFAULT_DURATION, idle = "hidden", idleIcon, swap = "queue", notificationLayout = "pill", linkComponent, classNames, placement = "bottom", orientation, moveThroughCircle, variant, onPointerEnter, onPointerLeave, onFocus, onBlur, ...rest }, forwardedRef) {
|
|
40
86
|
const store = require_store.getStore(name);
|
|
41
87
|
const { current } = require_usePillQueue.usePillQueue(name);
|
|
42
88
|
const rootRef = (0, react.useRef)(null);
|
|
43
89
|
const ref = (0, react.useMemo)(() => require_react.mergeRefs(rootRef, forwardedRef), [forwardedRef]);
|
|
90
|
+
const flagRef = (0, react.useRef)(null);
|
|
44
91
|
(0, react.useEffect)(() => store.registerHost(), [store]);
|
|
45
92
|
(0, react.useEffect)(require_inputModality.trackInputModality, []);
|
|
46
93
|
const hasBase = hasContent(children);
|
|
@@ -57,82 +104,103 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
|
|
|
57
104
|
});
|
|
58
105
|
const [isFillingIn, setIsFillingIn] = (0, react.useState)(false);
|
|
59
106
|
const isWaiting = isFillingIn && hasBase;
|
|
60
|
-
const
|
|
107
|
+
const onSide = placement === "left" || placement === "right";
|
|
108
|
+
const isVertical = orientation === "vertical" || orientation === void 0 && onSide;
|
|
109
|
+
const layoutOf = (item) => {
|
|
110
|
+
const layout = item.input.layout ?? notificationLayout;
|
|
111
|
+
if (layout === "card" && !isVertical) return "pill";
|
|
112
|
+
if (layout === "flag" && !(isVertical && onSide && hasBase)) return "pill";
|
|
113
|
+
return layout;
|
|
114
|
+
};
|
|
115
|
+
const sceneLayout = (shown) => shown.kind === "notification" ? layoutOf(shown.item) : void 0;
|
|
116
|
+
const isFlag = current !== null && current !== void 0 && layoutOf(current) === "flag";
|
|
117
|
+
const target = (0, react.useMemo)(() => current && !isWaiting && !isFlag ? {
|
|
61
118
|
kind: "notification",
|
|
62
119
|
item: current
|
|
63
120
|
} : hasBase ? base : idle === "rest" ? require_choreography.IDLE : require_choreography.NONE, [
|
|
64
121
|
current,
|
|
65
122
|
isWaiting,
|
|
123
|
+
isFlag,
|
|
66
124
|
hasBase,
|
|
67
125
|
base,
|
|
68
126
|
idle
|
|
69
127
|
]);
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
(0, react.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
128
|
+
const flagTarget = (0, react.useMemo)(() => current && !isWaiting && isFlag ? {
|
|
129
|
+
kind: "notification",
|
|
130
|
+
item: current
|
|
131
|
+
} : require_choreography.NONE, [
|
|
132
|
+
current,
|
|
133
|
+
isWaiting,
|
|
134
|
+
isFlag
|
|
135
|
+
]);
|
|
136
|
+
const orientationOf = (shown) => isVertical && shown.kind === "notification" && sceneLayout(shown) !== "card" ? "horizontal" : orientation;
|
|
137
|
+
const sidebarWidth = (0, react.useRef)(void 0);
|
|
138
|
+
const [isSliding, setIsSliding] = (0, react.useState)(false);
|
|
139
|
+
const { displayed, setDisplayed, displayedRef } = require_useChoreography.useChoreography(rootRef, target, {
|
|
140
|
+
swapMode: (from, to) => {
|
|
141
|
+
if (!isVertical || swap !== "always") return swap;
|
|
142
|
+
const layout = sceneLayout(to.kind === "notification" ? to : from);
|
|
143
|
+
return layout === "rows" || layout === "card" ? "always" : "queue";
|
|
144
|
+
},
|
|
145
|
+
turns: (from, to) => (orientationOf(from) ?? "") !== (orientationOf(to) ?? ""),
|
|
146
|
+
beforeApply: (from) => {
|
|
147
|
+
if (from.scene.kind === "base" && require_choreography.isOpen(from.presence) && rootRef.current) sidebarWidth.current = rootRef.current.getBoundingClientRect().width;
|
|
148
|
+
},
|
|
149
|
+
onSlide: setIsSliding
|
|
150
|
+
});
|
|
151
|
+
const [flagSpot, setFlagSpot] = (0, react.useState)({ shift: 0 });
|
|
152
|
+
const flagFrom = (0, react.useRef)(null);
|
|
153
|
+
const { displayed: flagDisplayed, setDisplayed: setFlagDisplayed, displayedRef: flagDisplayedRef } = require_useChoreography.useChoreography(flagRef, flagTarget, {
|
|
154
|
+
swapMode: () => swap === "never" ? "never" : "queue",
|
|
155
|
+
beforeApply: (from, next) => {
|
|
156
|
+
if (next.scene.kind !== "notification" || next.scene === from.scene || !rootRef.current) return;
|
|
157
|
+
if (flagRef.current && require_choreography.isOpen(from.presence)) flagFrom.current = flagRef.current.getBoundingClientRect();
|
|
158
|
+
setFlagSpot(require_flag.measureFlagSpot(rootRef.current, next.scene.item.input.at));
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
const flagY = flagDisplayed.presence === "panel" ? void 0 : flagSpot.y;
|
|
162
|
+
require_react.useIsomorphicLayoutEffect(() => {
|
|
163
|
+
const from = flagFrom.current;
|
|
164
|
+
flagFrom.current = null;
|
|
165
|
+
const flag = flagRef.current;
|
|
166
|
+
if (!from || !flag || typeof flag.animate !== "function" || require_timing.prefersReducedMotion()) return;
|
|
167
|
+
const to = flag.getBoundingClientRect();
|
|
168
|
+
const shift = from.top + from.height / 2 - (to.top + to.height / 2);
|
|
169
|
+
if (Math.abs(shift) < 1) return;
|
|
170
|
+
const { fade, change } = require_choreography.readTimings(flag);
|
|
171
|
+
flag.animate([{ translate: `0px ${shift}px` }, { translate: "0px 0px" }], {
|
|
172
|
+
duration: fade + change,
|
|
173
|
+
easing: "ease-in-out",
|
|
174
|
+
composite: "add"
|
|
175
|
+
});
|
|
176
|
+
}, [flagSpot, flagY]);
|
|
177
|
+
const flagPresence = (0, react.useRef)(flagDisplayed.presence);
|
|
178
|
+
require_react.useIsomorphicLayoutEffect(() => {
|
|
179
|
+
const previous = flagPresence.current;
|
|
180
|
+
flagPresence.current = flagDisplayed.presence;
|
|
181
|
+
const sidebar = rootRef.current;
|
|
182
|
+
const flag = flagRef.current;
|
|
183
|
+
if (!sidebar || !flag || previous === flagDisplayed.presence) return;
|
|
184
|
+
const { enter, fade, change, exit } = require_choreography.readTimings(flag);
|
|
185
|
+
if (previous === "hidden" && flagDisplayed.presence === "rest") require_flag.playBridge(sidebar, flag, flagSpot.y, "split", {
|
|
186
|
+
delay: 0,
|
|
187
|
+
duration: enter
|
|
188
|
+
});
|
|
189
|
+
else if (flagDisplayed.presence === "hidden") require_flag.playBridge(sidebar, flag, flagSpot.y, "join", {
|
|
190
|
+
delay: fade + change,
|
|
191
|
+
duration: exit
|
|
192
|
+
});
|
|
193
|
+
}, [flagDisplayed.presence]);
|
|
85
194
|
(0, react.useEffect)(() => {
|
|
86
195
|
const hasForm = () => !!rootRef.current?.querySelector("[data-mp=\"panel\"][data-open] form");
|
|
87
196
|
setIsFillingIn(displayed.scene.kind === "base" && displayed.presence === "panel" && hasForm());
|
|
88
197
|
}, [displayed]);
|
|
89
|
-
(
|
|
90
|
-
|
|
91
|
-
if (!next) return;
|
|
92
|
-
rootRef.current?.offsetWidth;
|
|
93
|
-
setDisplayed(next);
|
|
94
|
-
}, [displayed]);
|
|
95
|
-
(0, react.useEffect)(() => {
|
|
96
|
-
const current = displayedRef.current;
|
|
97
|
-
const timers = require_choreography.batchSteps(current, require_choreography.planSteps(current, target, require_choreography.readTimings(rootRef.current), swapMode.current)).map(({ at, states }) => {
|
|
98
|
-
const apply = () => {
|
|
99
|
-
if (require_choreography.isSwap(displayedRef.current, states[0], swapMode.current)) capture.current = require_morph.captureSwap(rootRef.current);
|
|
100
|
-
followUps.current = states.slice(1);
|
|
101
|
-
setDisplayed(states[0]);
|
|
102
|
-
};
|
|
103
|
-
if (at > 0) return setTimeout(apply, at);
|
|
104
|
-
apply();
|
|
105
|
-
});
|
|
106
|
-
return () => {
|
|
107
|
-
timers.forEach(clearTimeout);
|
|
108
|
-
followUps.current = [];
|
|
109
|
-
};
|
|
110
|
-
}, [target]);
|
|
111
|
-
const [hovered, setHovered] = (0, react.useState)(false);
|
|
112
|
-
const [focused, setFocused] = (0, react.useState)(false);
|
|
198
|
+
const mainPause = usePause(rootRef, displayed.presence);
|
|
199
|
+
const flagPause = usePause(flagRef, flagDisplayed.presence);
|
|
113
200
|
const documentHidden = useDocumentHidden();
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
setFocused(false);
|
|
118
|
-
}
|
|
119
|
-
}, [displayed.presence]);
|
|
120
|
-
(0, react.useEffect)(() => {
|
|
121
|
-
const root = rootRef.current;
|
|
122
|
-
if (!focused || !root) return;
|
|
123
|
-
const update = () => {
|
|
124
|
-
if (!root.contains(document.activeElement)) setFocused(false);
|
|
125
|
-
};
|
|
126
|
-
update();
|
|
127
|
-
const observer = new MutationObserver(update);
|
|
128
|
-
observer.observe(root, {
|
|
129
|
-
childList: true,
|
|
130
|
-
subtree: true
|
|
131
|
-
});
|
|
132
|
-
return () => observer.disconnect();
|
|
133
|
-
}, [focused]);
|
|
134
|
-
const shown = displayed.scene.kind === "notification" && require_choreography.isOpen(displayed.presence) ? displayed.scene.item : null;
|
|
135
|
-
const paused = hovered || focused || documentHidden || displayed.presence === "panel";
|
|
201
|
+
const inFlag = notificationIn(flagDisplayed);
|
|
202
|
+
const shown = notificationIn(displayed) ?? inFlag;
|
|
203
|
+
const paused = documentHidden || (shown !== null && shown === inFlag ? flagPause.active || flagDisplayed.presence === "panel" : mainPause.active || displayed.presence === "panel");
|
|
136
204
|
(0, react.useEffect)(() => {
|
|
137
205
|
if (!shown || paused) return;
|
|
138
206
|
const ms = shown.input.duration ?? duration;
|
|
@@ -150,29 +218,29 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
|
|
|
150
218
|
if (!shown) return;
|
|
151
219
|
const { announce } = shown.input;
|
|
152
220
|
if (announce === false) return;
|
|
153
|
-
const text = typeof announce === "string" ? announce : readMessage(rootRef.current);
|
|
221
|
+
const text = typeof announce === "string" ? announce : readMessage(shown === inFlag ? flagRef.current : rootRef.current);
|
|
154
222
|
if (text) setAnnouncement((previous) => previous?.key === shown ? previous : {
|
|
155
223
|
key: shown,
|
|
156
224
|
text
|
|
157
225
|
});
|
|
158
|
-
}, [shown]);
|
|
159
|
-
const
|
|
160
|
-
const { scene, presence } =
|
|
226
|
+
}, [shown, inFlag]);
|
|
227
|
+
const presenceHandler = (stateRef, setState) => (next) => {
|
|
228
|
+
const { scene: shownScene, presence } = stateRef.current;
|
|
161
229
|
if (next === "hidden") {
|
|
162
|
-
if (
|
|
230
|
+
if (shownScene.kind === "notification") store.dismiss(shownScene.item.id, "dismissed");
|
|
163
231
|
return;
|
|
164
232
|
}
|
|
165
|
-
if (require_choreography.isOpen(next) && require_choreography.isOpen(presence))
|
|
166
|
-
scene,
|
|
233
|
+
if (require_choreography.isOpen(next) && require_choreography.isOpen(presence)) setState({
|
|
234
|
+
scene: shownScene,
|
|
167
235
|
presence: next
|
|
168
236
|
});
|
|
169
237
|
};
|
|
170
|
-
const renderScene = (
|
|
171
|
-
switch (
|
|
172
|
-
case "base": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: lastScenes.current.get(
|
|
238
|
+
const renderScene = (shownScene) => {
|
|
239
|
+
switch (shownScene.kind) {
|
|
240
|
+
case "base": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: lastScenes.current.get(shownScene.key)?.children ?? lastBase.current }, shownScene.key);
|
|
173
241
|
case "idle": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_parts.PillIcon, { children: idleIcon });
|
|
174
242
|
case "notification": {
|
|
175
|
-
const { id, input } =
|
|
243
|
+
const { id, input } = shownScene.item;
|
|
176
244
|
if (input.render) return input.render({
|
|
177
245
|
id,
|
|
178
246
|
dismiss: () => store.dismiss(id, "dismissed")
|
|
@@ -182,6 +250,7 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
|
|
|
182
250
|
message: input.message,
|
|
183
251
|
action: input.action,
|
|
184
252
|
panel: input.panel,
|
|
253
|
+
layout: layoutOf(shownScene.item),
|
|
185
254
|
linkComponent,
|
|
186
255
|
classNames,
|
|
187
256
|
onAction: (event) => {
|
|
@@ -195,38 +264,70 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
|
|
|
195
264
|
const displayedKey = displayed.scene.kind === "base" ? displayed.scene.key : scene;
|
|
196
265
|
for (const key of lastScenes.current.keys()) if (key !== scene && key !== displayedKey) lastScenes.current.delete(key);
|
|
197
266
|
const sceneVariant = displayed.scene.kind === "notification" ? displayed.scene.item.input.variant ?? variant : (lastScenes.current.get(displayedKey) ?? { variant }).variant;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
267
|
+
const mainLayout = sceneLayout(displayed.scene);
|
|
268
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
269
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Pill, {
|
|
270
|
+
...rest,
|
|
271
|
+
ref,
|
|
272
|
+
placement,
|
|
273
|
+
orientation: orientationOf(displayed.scene),
|
|
274
|
+
moveThroughCircle: moveThroughCircle !== false && !isSliding,
|
|
275
|
+
"data-layout": mainLayout,
|
|
276
|
+
style: mainLayout === "card" && sidebarWidth.current ? {
|
|
277
|
+
...rest.style,
|
|
278
|
+
"--_mp-sidebar-width": `${sidebarWidth.current}px`
|
|
279
|
+
} : rest.style,
|
|
280
|
+
variant: sceneVariant,
|
|
281
|
+
presence: displayed.presence,
|
|
282
|
+
onPresenceChange: presenceHandler(displayedRef, setDisplayed),
|
|
283
|
+
onPointerEnter: (event) => {
|
|
284
|
+
onPointerEnter?.(event);
|
|
285
|
+
mainPause.handlers.onPointerEnter(event);
|
|
286
|
+
},
|
|
287
|
+
onPointerLeave: (event) => {
|
|
288
|
+
onPointerLeave?.(event);
|
|
289
|
+
mainPause.handlers.onPointerLeave();
|
|
290
|
+
},
|
|
291
|
+
onFocus: (event) => {
|
|
292
|
+
onFocus?.(event);
|
|
293
|
+
mainPause.handlers.onFocus();
|
|
294
|
+
},
|
|
295
|
+
onBlur: (event) => {
|
|
296
|
+
onBlur?.(event);
|
|
297
|
+
mainPause.handlers.onBlur(event);
|
|
298
|
+
},
|
|
299
|
+
children: renderScene(displayed.scene)
|
|
300
|
+
}),
|
|
301
|
+
(isVertical && onSide && hasBase || flagDisplayed.presence !== "hidden") && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Pill, {
|
|
302
|
+
ref: flagRef,
|
|
303
|
+
placement,
|
|
304
|
+
orientation: "horizontal",
|
|
305
|
+
ladder: false,
|
|
306
|
+
moveThroughCircle: false,
|
|
307
|
+
theme: rest.theme,
|
|
308
|
+
variant: flagDisplayed.scene.kind === "notification" ? flagDisplayed.scene.item.input.variant ?? variant : variant,
|
|
309
|
+
presence: flagDisplayed.presence,
|
|
310
|
+
onPresenceChange: (next) => {
|
|
311
|
+
if (flagRef.current && require_choreography.isOpen(next)) flagFrom.current = flagRef.current.getBoundingClientRect();
|
|
312
|
+
presenceHandler(flagDisplayedRef, setFlagDisplayed)(next);
|
|
313
|
+
},
|
|
314
|
+
"data-layout": "flag",
|
|
315
|
+
style: require_flag.flagStyle({
|
|
316
|
+
shift: flagSpot.shift,
|
|
317
|
+
y: flagY
|
|
318
|
+
}),
|
|
319
|
+
...flagPause.handlers,
|
|
320
|
+
children: renderScene(flagDisplayed.scene)
|
|
321
|
+
}),
|
|
322
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
323
|
+
role: "status",
|
|
324
|
+
"aria-live": "polite",
|
|
325
|
+
"aria-atomic": "true",
|
|
326
|
+
"data-mp": "announcer",
|
|
327
|
+
style: require_visuallyHidden.VISUALLY_HIDDEN,
|
|
328
|
+
children: announcement && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: announcement.text }, announcement.key.id + announcement.text)
|
|
329
|
+
})
|
|
330
|
+
] });
|
|
230
331
|
});
|
|
231
332
|
|
|
232
333
|
module.exports = MagicPill;
|