magic-pill 9.0.0-next.2 → 9.0.0-next.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.
@@ -0,0 +1,399 @@
1
+ "use client";
2
+
3
+ import { Component, useLayoutEffect, useRef } from "react";
4
+ import { parseDuration, prefersReducedMotion } from "../utils/timing.mjs";
5
+
6
+ // src/Pill/morph.ts
7
+ const CLOSED = /* @__PURE__ */ new Set(["rest", "hidden"]);
8
+ /** Tags this module's animations, so a size change can stop the one before it. */
9
+ const MORPH = "mp-morph";
10
+ /** The length of the fading edge over the panel's clipped content. */
11
+ const EDGE = 48;
12
+ const EASING = "ease-in-out";
13
+ /** Rounded up: a hair narrower, and a message that just fits would wrap. */
14
+ const px = (value) => `${Math.max(0, Math.ceil(value * 100) / 100)}px`;
15
+ /**
16
+ * The pill at a size. Nothing in the stylesheet may cap it meanwhile (the
17
+ * circle clamps both axes, a panel scrolls past a maximum height).
18
+ */
19
+ const sized = (size) => ({
20
+ minWidth: "0px",
21
+ minHeight: "0px",
22
+ maxWidth: "none",
23
+ maxHeight: "none",
24
+ overflow: "hidden",
25
+ width: px(size.width),
26
+ height: px(size.height)
27
+ });
28
+ /**
29
+ * A part held at its final width while the pill resizes, so a message doesn't
30
+ * rewrap at every frame.
31
+ */
32
+ const held = (width) => ({
33
+ flexShrink: 0,
34
+ width: px(width)
35
+ });
36
+ /**
37
+ * Measures the pill's messages now (at their final width: before the pill's
38
+ * own animation starts), to hold them there during an animation.
39
+ */
40
+ function holdMessages(element) {
41
+ const messages = [...element.querySelectorAll(":scope > [data-mp=\"message\"]")].map((message) => [message, held(message.getBoundingClientRect().width)]);
42
+ return (options) => messages.map(([message, frame]) => message.animate([frame, frame], options));
43
+ }
44
+ const sameSize = (a, b) => Math.abs(a.width - b.width) < 1 && Math.abs(a.height - b.height) < 1;
45
+ /**
46
+ * The panel's content, cut by the pill's edges while it grows or shrinks: a
47
+ * mask that shows what's inside the pill, and fades it out along the bottom
48
+ * and the inline-end edges instead of cutting it (the corner stays hidden).
49
+ */
50
+ function revealMask(panel, size, edges) {
51
+ const visibleHeight = Math.max(0, size.height - panel.top);
52
+ const visibleWidth = Math.min(panel.width, size.width);
53
+ const fadeY = Math.min(edges, visibleHeight);
54
+ const fadeX = visibleWidth < panel.width ? Math.min(edges, visibleWidth) : 0;
55
+ const solidW = visibleWidth - fadeX;
56
+ const solidH = visibleHeight - fadeY;
57
+ const startX = panel.rtl ? panel.width - visibleWidth : 0;
58
+ const solidX = panel.rtl ? startX + fadeX : startX;
59
+ const sideX = panel.rtl ? startX : startX + solidW;
60
+ return {
61
+ width: px(panel.width),
62
+ maskImage: `linear-gradient(#000,#000),linear-gradient(to top,transparent,#000),linear-gradient(to ${panel.rtl ? "right" : "left"},transparent,#000)`,
63
+ maskRepeat: "no-repeat",
64
+ maskSize: `${px(solidW)} ${px(solidH)},${px(solidW)} ${px(fadeY)},${px(fadeX)} ${px(solidH)}`,
65
+ maskPosition: `${px(solidX)} 0px,${px(solidX)} ${px(solidH)},${px(sideX)} 0px`
66
+ };
67
+ }
68
+ /**
69
+ * How the pill goes from `from` (on screen) to `to` (its new natural size),
70
+ * or null when there's nothing to animate. Pure, so it can be tested.
71
+ */
72
+ function planMorph(from, to, previous, next, timings, panel) {
73
+ if (timings.change <= 0 || sameSize(from, to)) return null;
74
+ const delay = CLOSED.has(next) && !CLOSED.has(previous) ? timings.fade : 0;
75
+ const plan = {
76
+ pill: [sized(from), sized(to)],
77
+ options: {
78
+ duration: timings.change,
79
+ delay,
80
+ easing: EASING,
81
+ fill: "backwards"
82
+ }
83
+ };
84
+ const opening = next === "panel" && previous !== "panel";
85
+ const closing = previous === "panel" && next !== "panel";
86
+ if (panel && (opening || closing)) plan.panel = opening ? [revealMask(panel, from, EDGE), revealMask(panel, to, 0)] : [revealMask(panel, from, 0), revealMask(panel, to, EDGE)];
87
+ if (closing && !CLOSED.has(next)) {
88
+ const total = timings.change + timings.fade;
89
+ plan.content = {
90
+ keyframes: [
91
+ { opacity: 0 },
92
+ {
93
+ opacity: 0,
94
+ offset: timings.change / total
95
+ },
96
+ { opacity: 1 }
97
+ ],
98
+ options: {
99
+ duration: total,
100
+ easing: "ease-out"
101
+ }
102
+ };
103
+ }
104
+ return plan;
105
+ }
106
+ const readSize = (element) => ({
107
+ width: element.offsetWidth,
108
+ height: element.offsetHeight
109
+ });
110
+ /**
111
+ * Stops the size animations running on the pill (and in it), and drops the
112
+ * copy of the content a swap slides out (but `keep`). Returns whether anything ran.
113
+ */
114
+ function cancel(element, id, subtree) {
115
+ let cancelled = false;
116
+ for (const animation of element.getAnimations?.({ subtree }) ?? []) if (animation.id === id) {
117
+ animation.cancel();
118
+ cancelled = true;
119
+ }
120
+ return cancelled;
121
+ }
122
+ function stopMorphs(element, keep) {
123
+ let stopped = cancel(element, MORPH, true);
124
+ for (const outgoing of element.querySelectorAll(":scope > [data-mp=\"outgoing\"]")) if (outgoing !== keep) {
125
+ outgoing.remove();
126
+ stopped = true;
127
+ }
128
+ return stopped;
129
+ }
130
+ /**
131
+ * The size to the fraction of a pixel (offsetWidth rounds it): the copy of a
132
+ * message that just fits would wrap otherwise. An open pill isn't scaled.
133
+ */
134
+ const readExactSize = (element) => {
135
+ const { width, height } = element.getBoundingClientRect();
136
+ return {
137
+ width,
138
+ height
139
+ };
140
+ };
141
+ /**
142
+ * One content replacing another in an open pill, in one overlapping movement
143
+ * (the "rubik's cube"): the old content slides out through the top, the pill
144
+ * resizes, the new content comes in from the bottom (`down`: the other way
145
+ * round, for a pill at the top of the screen). A row's content lines up on
146
+ * the anchor side (`undefined`: a column, left alone). Pure, so it can be tested.
147
+ */
148
+ function planSwap(from, to, timings, anchor, down = false) {
149
+ const total = timings.fade + timings.change;
150
+ if (total <= 0) return null;
151
+ const out = down ? "" : "-";
152
+ const into = down ? "-" : "";
153
+ const justify = anchor && { justifyContent: anchor === "center" ? anchor : `flex-${anchor}` };
154
+ return {
155
+ pill: {
156
+ keyframes: [{
157
+ ...sized(from),
158
+ ...justify
159
+ }, {
160
+ ...sized(to),
161
+ ...justify
162
+ }],
163
+ options: {
164
+ id: MORPH,
165
+ duration: total * .6,
166
+ delay: total * .15,
167
+ easing: EASING,
168
+ fill: "backwards"
169
+ }
170
+ },
171
+ outgoing: {
172
+ keyframes: [{}, {
173
+ transform: `translateY(${out}${px(from.height)})`,
174
+ opacity: 0
175
+ }],
176
+ options: {
177
+ id: MORPH,
178
+ duration: total * .45,
179
+ easing: "ease-in",
180
+ fill: "forwards"
181
+ }
182
+ },
183
+ incoming: (width) => ({
184
+ keyframes: [{
185
+ ...held(width),
186
+ transform: `translateY(${into}${px(to.height)})`,
187
+ opacity: 0
188
+ }, {
189
+ ...held(width),
190
+ transform: "none",
191
+ opacity: 1
192
+ }],
193
+ options: {
194
+ id: MORPH,
195
+ duration: total * .65,
196
+ delay: total * .35,
197
+ easing: "ease-out",
198
+ fill: "backwards"
199
+ }
200
+ })
201
+ };
202
+ }
203
+ /**
204
+ * Before new content replaces the pill's: a still copy of what's on screen,
205
+ * laid over it, to slide out once the new content is in. Null when there's
206
+ * nothing to animate (unstyled, reduced motion, no Web Animations API).
207
+ */
208
+ function captureSwap(element) {
209
+ if (!element || element.hasAttribute("data-unstyled") || !element.animate || prefersReducedMotion()) return null;
210
+ const from = readExactSize(element);
211
+ const outgoing = document.createElement("div");
212
+ for (const child of element.children) if (child.getAttribute("data-mp") !== "outgoing") outgoing.append(child.cloneNode(true));
213
+ stopMorphs(element);
214
+ for (const node of outgoing.querySelectorAll("[id], [name]")) {
215
+ node.removeAttribute("id");
216
+ node.removeAttribute("name");
217
+ }
218
+ outgoing.setAttribute("data-mp", "outgoing");
219
+ outgoing.setAttribute("aria-hidden", "true");
220
+ outgoing.setAttribute("inert", "");
221
+ const style = getComputedStyle(element);
222
+ const row = style.flexDirection.startsWith("row");
223
+ const placement = element.dataset.placement ?? "";
224
+ const side = row ? placement.replace("inline", "-start") : style.alignItems;
225
+ const anchor = /start$/.test(side) ? "start" : /end$/.test(side) ? "end" : "center";
226
+ outgoing.style.cssText = `position:absolute;inset-block:0;margin-block:auto;${anchor === "center" ? "inset-inline:0;margin-inline:auto" : `inset-inline-${anchor}:0`};box-sizing:border-box;width:${held(from.width).width};height:${px(from.height)};display:flex;flex-direction:inherit;align-items:inherit;justify-content:inherit;gap:inherit;padding:inherit;pointer-events:none`;
227
+ element.append(outgoing);
228
+ return {
229
+ from,
230
+ outgoing,
231
+ anchor: row ? anchor : void 0,
232
+ down: placement.startsWith("top")
233
+ };
234
+ }
235
+ /** Once the new content is in: the swap prepared by `captureSwap`, played. */
236
+ function playSwap(element, { from, outgoing, anchor, down }) {
237
+ stopMorphs(element, outgoing);
238
+ const plan = planSwap(from, readExactSize(element), readMorphTimings(element), anchor, down);
239
+ const done = () => outgoing.remove();
240
+ if (!plan) return done();
241
+ const incoming = [...element.children].filter((child) => child !== outgoing);
242
+ const widths = incoming.map((child) => child.getBoundingClientRect().width);
243
+ element.animate(plan.pill.keyframes, plan.pill.options);
244
+ incoming.forEach((child, index) => {
245
+ const { keyframes, options } = plan.incoming(widths[index]);
246
+ child.animate(keyframes, options);
247
+ });
248
+ outgoing.animate(plan.outgoing.keyframes, plan.outgoing.options).finished.then(done, done);
249
+ }
250
+ function readMorphTimings(element) {
251
+ const style = getComputedStyle(element);
252
+ return {
253
+ fade: parseDuration(style.getPropertyValue("--_mp-fade"), 150),
254
+ change: parseDuration(style.getPropertyValue("--_mp-change"), 250)
255
+ };
256
+ }
257
+ function readPanel(pill) {
258
+ const element = pill.querySelector(":scope > [data-mp=\"panel\"]");
259
+ if (!element || getComputedStyle(element).display === "none") return void 0;
260
+ const pillRect = pill.getBoundingClientRect();
261
+ const rect = element.getBoundingClientRect();
262
+ return {
263
+ element,
264
+ box: {
265
+ top: rect.top - pillRect.top,
266
+ width: rect.width,
267
+ rtl: getComputedStyle(pill).direction === "rtl"
268
+ }
269
+ };
270
+ }
271
+ /**
272
+ * Animates the pill's size on each presence change. Off for `unstyled` pills,
273
+ * with reduced motion, and where the Web Animations API is missing.
274
+ */
275
+ function useSizeMorph(rootRef, presence, enabled, lastSize) {
276
+ const lastPresence = useRef(presence);
277
+ const running = useRef([]);
278
+ const openPanel = useRef(void 0);
279
+ useLayoutEffect(() => {
280
+ const element = rootRef.current;
281
+ if (!element || typeof ResizeObserver === "undefined") return;
282
+ const observer = new ResizeObserver((entries) => {
283
+ const size = readSize(element);
284
+ const box = entries?.[0]?.borderBoxSize?.[0];
285
+ const exact = box && {
286
+ width: box.inlineSize,
287
+ height: box.blockSize
288
+ };
289
+ lastSize.current = exact && sameSize(exact, size) ? exact : size;
290
+ if (lastPresence.current === "panel" && running.current.length === 0) openPanel.current = readPanel(element)?.box;
291
+ });
292
+ observer.observe(element);
293
+ return () => {
294
+ observer.disconnect();
295
+ running.current.forEach((animation) => animation.cancel());
296
+ };
297
+ }, [rootRef, lastSize]);
298
+ useLayoutEffect(() => {
299
+ const element = rootRef.current;
300
+ const previous = lastPresence.current;
301
+ lastPresence.current = presence;
302
+ if (!element || previous === presence) return;
303
+ if (!enabled || typeof element.animate !== "function" || prefersReducedMotion()) {
304
+ running.current.forEach((animation) => animation.cancel());
305
+ running.current = [];
306
+ return;
307
+ }
308
+ const current = readSize(element);
309
+ const from = stopMorphs(element) || running.current.length > 0 ? current : lastSize.current;
310
+ running.current.forEach((animation) => animation.cancel());
311
+ running.current = [];
312
+ const to = readSize(element);
313
+ lastSize.current = to;
314
+ if (!from) return;
315
+ const panel = readPanel(element);
316
+ if (presence === "panel") openPanel.current = panel?.box;
317
+ const panelBox = previous === "panel" ? openPanel.current : panel?.box;
318
+ const plan = planMorph(from, to, previous, presence, readMorphTimings(element), panelBox);
319
+ if (!plan) return;
320
+ const hold = holdMessages(element);
321
+ const options = {
322
+ ...plan.options,
323
+ id: MORPH
324
+ };
325
+ const animations = [element.animate(plan.pill, options)];
326
+ if (plan.panel && panel) {
327
+ animations.push(panel.element.animate(plan.panel, options));
328
+ const footer = panel.element.querySelector("[data-mp=\"panel-footer\"]");
329
+ if (footer) animations.push(footer.animate([{ position: "static" }, { position: "static" }], options));
330
+ }
331
+ if (!CLOSED.has(presence) && presence !== "panel") animations.push(...hold(options));
332
+ if (plan.content) {
333
+ const { keyframes, options } = plan.content;
334
+ for (const child of element.children) if (child !== panel?.element) animations.push(child.animate(keyframes, {
335
+ ...options,
336
+ id: MORPH
337
+ }));
338
+ }
339
+ running.current = animations;
340
+ animations[0].finished.then(() => {
341
+ if (running.current === animations) running.current = [];
342
+ }).catch(() => {});
343
+ }, [
344
+ rootRef,
345
+ presence,
346
+ enabled,
347
+ lastSize
348
+ ]);
349
+ }
350
+ /** Tags the placement animation, which runs alongside the size ones. */
351
+ const MOVE = "mp-move";
352
+ /**
353
+ * The pill moved to another placement (or orientation): it travels there
354
+ * from where it was (`from`), resizing on the way if its size changed.
355
+ */
356
+ function animateMove(element, from) {
357
+ if (!from.width || element.hasAttribute("data-unstyled") || !element.animate || prefersReducedMotion()) return;
358
+ cancel(element, MOVE);
359
+ const to = readExactSize(element);
360
+ const resized = !sameSize(from, to);
361
+ const hold = holdMessages(element);
362
+ const style = element.style.cssText;
363
+ if (resized) Object.assign(element.style, sized(from));
364
+ const start = element.getBoundingClientRect();
365
+ element.style.cssText = style;
366
+ const shift = `${from.left - start.left}px ${from.top - start.top}px`;
367
+ const { fade, change } = readMorphTimings(element);
368
+ const options = {
369
+ id: MOVE,
370
+ duration: fade + change,
371
+ easing: EASING
372
+ };
373
+ element.animate([{
374
+ translate: shift,
375
+ ...resized && sized(from)
376
+ }, {
377
+ translate: "0px 0px",
378
+ ...resized && sized(to)
379
+ }], options);
380
+ if (resized) hold(options);
381
+ }
382
+ /**
383
+ * Remembers where the pill is just before its placement changes (React calls
384
+ * this before it updates the page), then moves it from there.
385
+ */
386
+ var PlacementWatch = class extends Component {
387
+ getSnapshotBeforeUpdate(previous) {
388
+ return previous.placement !== this.props.placement ? this.props.target.current?.getBoundingClientRect() ?? null : null;
389
+ }
390
+ componentDidUpdate(_props, _state, from) {
391
+ const element = this.props.target.current;
392
+ if (from && element) animateMove(element, from);
393
+ }
394
+ render() {
395
+ return null;
396
+ }
397
+ };
398
+
399
+ export { PlacementWatch, animateMove, captureSwap, planMorph, planSwap, playSwap, useSizeMorph };
@@ -36,10 +36,15 @@ export interface PillProps extends Omit<ComponentPropsWithoutRef<"div">, "childr
36
36
  presence?: PillPresence;
37
37
  /** Uncontrolled initial presence. Default `compact`. */
38
38
  defaultPresence?: PillPresence;
39
- /** Called when the pill asks to change level (panel trigger, close button, Escape). */
39
+ /** Called when the pill asks to change level (panel trigger, close button, Escape, backdrop click). */
40
40
  onPresenceChange?: (presence: PillPresence) => void;
41
41
  /** Default `inline`. */
42
42
  placement?: PillPlacement;
43
+ /**
44
+ * `overlay` only: a click outside the modal does what Escape does (closes
45
+ * the panel if it's open, the modal otherwise). Default `false`.
46
+ */
47
+ closeOnBackdropClick?: boolean;
43
48
  orientation?: PillOrientation;
44
49
  /** Default `neutral`. */
45
50
  variant?: PillVariant;
@@ -36,10 +36,15 @@ export interface PillProps extends Omit<ComponentPropsWithoutRef<"div">, "childr
36
36
  presence?: PillPresence;
37
37
  /** Uncontrolled initial presence. Default `compact`. */
38
38
  defaultPresence?: PillPresence;
39
- /** Called when the pill asks to change level (panel trigger, close button, Escape). */
39
+ /** Called when the pill asks to change level (panel trigger, close button, Escape, backdrop click). */
40
40
  onPresenceChange?: (presence: PillPresence) => void;
41
41
  /** Default `inline`. */
42
42
  placement?: PillPlacement;
43
+ /**
44
+ * `overlay` only: a click outside the modal does what Escape does (closes
45
+ * the panel if it's open, the modal otherwise). Default `false`.
46
+ */
47
+ closeOnBackdropClick?: boolean;
43
48
  orientation?: PillOrientation;
44
49
  /** Default `neutral`. */
45
50
  variant?: PillVariant;
@@ -1,11 +1,15 @@
1
1
  // src/PillNavbar/matchPath.ts
2
+ const SLASH = 47;
2
3
  /** "/blog/?q=1#top" → "/blog": no query, no hash, no trailing slash (except the root). */
3
4
  function normalisePath(path) {
4
5
  const withoutSuffix = path.split(/[?#]/, 1)[0];
5
- return withoutSuffix.length > 1 ? withoutSuffix.replace(/\/+$/, "") || "/" : withoutSuffix;
6
+ let end = withoutSuffix.length;
7
+ while (end > 1 && withoutSuffix.charCodeAt(end - 1) === SLASH) end--;
8
+ return withoutSuffix.slice(0, end);
6
9
  }
7
10
  function matches(pathname, item) {
8
- if (typeof item.match === "function") return item.match(pathname);
11
+ const customMatch = item.match;
12
+ if (typeof customMatch === "function") return customMatch(pathname);
9
13
  if (!item.href.startsWith("/") || item.href.startsWith("//")) return false;
10
14
  const path = normalisePath(pathname);
11
15
  const href = normalisePath(item.href);
@@ -1,11 +1,15 @@
1
1
  // src/PillNavbar/matchPath.ts
2
+ const SLASH = 47;
2
3
  /** "/blog/?q=1#top" → "/blog": no query, no hash, no trailing slash (except the root). */
3
4
  function normalisePath(path) {
4
5
  const withoutSuffix = path.split(/[?#]/, 1)[0];
5
- return withoutSuffix.length > 1 ? withoutSuffix.replace(/\/+$/, "") || "/" : withoutSuffix;
6
+ let end = withoutSuffix.length;
7
+ while (end > 1 && withoutSuffix.charCodeAt(end - 1) === SLASH) end--;
8
+ return withoutSuffix.slice(0, end);
6
9
  }
7
10
  function matches(pathname, item) {
8
- if (typeof item.match === "function") return item.match(pathname);
11
+ const customMatch = item.match;
12
+ if (typeof customMatch === "function") return customMatch(pathname);
9
13
  if (!item.href.startsWith("/") || item.href.startsWith("//")) return false;
10
14
  const path = normalisePath(pathname);
11
15
  const href = normalisePath(item.href);
@@ -4,6 +4,8 @@ import { LinkComponent } from "../Pill/types.mjs";
4
4
  export type NotificationAction = {
5
5
  icon?: ReactNode;
6
6
  label: string;
7
+ /** Always show the label, not only on hover and focus (phones don't hover). */
8
+ expanded?: boolean;
7
9
  /**
8
10
  * Inside a <MagicPill>, clicking an action dismisses the notification.
9
11
  * Call `event.preventDefault()` to keep it open.
@@ -13,6 +15,7 @@ export type NotificationAction = {
13
15
  } | {
14
16
  icon?: ReactNode;
15
17
  label: string;
18
+ expanded?: boolean;
16
19
  href: string;
17
20
  onClick?: undefined;
18
21
  };
@@ -23,6 +26,7 @@ export interface NotificationPanel {
23
26
  trigger?: {
24
27
  icon?: ReactNode;
25
28
  label: string;
29
+ expanded?: boolean;
26
30
  };
27
31
  /** Default "Close". */
28
32
  closeLabel?: string;
@@ -4,6 +4,8 @@ import { LinkComponent } from "../Pill/types.js";
4
4
  export type NotificationAction = {
5
5
  icon?: ReactNode;
6
6
  label: string;
7
+ /** Always show the label, not only on hover and focus (phones don't hover). */
8
+ expanded?: boolean;
7
9
  /**
8
10
  * Inside a <MagicPill>, clicking an action dismisses the notification.
9
11
  * Call `event.preventDefault()` to keep it open.
@@ -13,6 +15,7 @@ export type NotificationAction = {
13
15
  } | {
14
16
  icon?: ReactNode;
15
17
  label: string;
18
+ expanded?: boolean;
16
19
  href: string;
17
20
  onClick?: undefined;
18
21
  };
@@ -23,6 +26,7 @@ export interface NotificationPanel {
23
26
  trigger?: {
24
27
  icon?: ReactNode;
25
28
  label: string;
29
+ expanded?: boolean;
26
30
  };
27
31
  /** Default "Close". */
28
32
  closeLabel?: string;
@@ -9,10 +9,11 @@ let react_jsx_runtime = require("react/jsx-runtime");
9
9
  function NotificationContent({ icon, message, action, panel, linkComponent, classNames = {}, onAction }) {
10
10
  const hasIcon = icon !== void 0 && icon !== null;
11
11
  const renderAction = (notificationAction) => {
12
- const { icon: actionIcon, label } = notificationAction;
12
+ const { icon: actionIcon, label, expanded } = notificationAction;
13
13
  if (notificationAction.href !== void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillAction, {
14
14
  icon: actionIcon,
15
15
  label,
16
+ expanded,
16
17
  href: notificationAction.href,
17
18
  linkComponent,
18
19
  className: classNames.action,
@@ -22,6 +23,7 @@ function NotificationContent({ icon, message, action, panel, linkComponent, clas
22
23
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillAction, {
23
24
  icon: actionIcon,
24
25
  label,
26
+ expanded,
25
27
  className: classNames.action,
26
28
  onClick: (event) => {
27
29
  onClick(event);
@@ -43,6 +45,7 @@ function NotificationContent({ icon, message, action, panel, linkComponent, clas
43
45
  children: [action && renderAction(action), panel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillPanel.PillPanelTrigger, {
44
46
  icon: panel.trigger ? panel.trigger.icon : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PlusIcon, {}),
45
47
  label: panel.trigger?.label ?? "Learn more",
48
+ expanded: panel.trigger?.expanded,
46
49
  className: classNames.action
47
50
  })]
48
51
  }),
@@ -9,10 +9,11 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  function NotificationContent({ icon, message, action, panel, linkComponent, classNames = {}, onAction }) {
10
10
  const hasIcon = icon !== void 0 && icon !== null;
11
11
  const renderAction = (notificationAction) => {
12
- const { icon: actionIcon, label } = notificationAction;
12
+ const { icon: actionIcon, label, expanded } = notificationAction;
13
13
  if (notificationAction.href !== void 0) return /* @__PURE__ */ jsx(PillAction, {
14
14
  icon: actionIcon,
15
15
  label,
16
+ expanded,
16
17
  href: notificationAction.href,
17
18
  linkComponent,
18
19
  className: classNames.action,
@@ -22,6 +23,7 @@ function NotificationContent({ icon, message, action, panel, linkComponent, clas
22
23
  return /* @__PURE__ */ jsx(PillAction, {
23
24
  icon: actionIcon,
24
25
  label,
26
+ expanded,
25
27
  className: classNames.action,
26
28
  onClick: (event) => {
27
29
  onClick(event);
@@ -43,6 +45,7 @@ function NotificationContent({ icon, message, action, panel, linkComponent, clas
43
45
  children: [action && renderAction(action), panel && /* @__PURE__ */ jsx(PillPanelTrigger, {
44
46
  icon: panel.trigger ? panel.trigger.icon : /* @__PURE__ */ jsx(PlusIcon, {}),
45
47
  label: panel.trigger?.label ?? "Learn more",
48
+ expanded: panel.trigger?.expanded,
46
49
  className: classNames.action
47
50
  })]
48
51
  }),