magic-pill 9.2.0 → 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.
Files changed (54) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/MIGRATING.md +2 -0
  3. package/README.md +45 -15
  4. package/dist/MagicPill/MagicPill.js +2 -2
  5. package/dist/MagicPill/MagicPill.mjs +4 -4
  6. package/dist/MagicPill/useChoreography.js +2 -1
  7. package/dist/MagicPill/useChoreography.mjs +3 -2
  8. package/dist/Pill/modal.js +2 -1
  9. package/dist/Pill/modal.mjs +3 -2
  10. package/dist/Pill/morph.js +3 -2
  11. package/dist/Pill/morph.mjs +4 -3
  12. package/dist/Pill/travel.js +2 -1
  13. package/dist/Pill/travel.mjs +3 -2
  14. package/dist/Pill/zone.js +3 -2
  15. package/dist/Pill/zone.mjs +4 -3
  16. package/dist/PillForm/PillSubmit.js +1 -1
  17. package/dist/PillForm/PillSubmit.mjs +3 -3
  18. package/dist/PillForm/popover.js +2 -1
  19. package/dist/PillForm/popover.mjs +3 -2
  20. package/dist/PillOptics/PillOptics.js +2 -1
  21. package/dist/PillOptics/PillOptics.mjs +3 -2
  22. package/dist/forms.css +2 -1
  23. package/dist/index.d.mts +28 -14
  24. package/dist/index.d.ts +28 -14
  25. package/dist/index.js +38 -12
  26. package/dist/index.mjs +38 -12
  27. package/dist/styles.css +6 -3
  28. package/dist/utils/react.js +8 -1
  29. package/dist/utils/react.mjs +8 -2
  30. package/package.json +2 -2
  31. package/dist/icons/ArrowIcon.d.mts +0 -4
  32. package/dist/icons/ArrowIcon.d.ts +0 -4
  33. package/dist/icons/BoxIcon.d.mts +0 -4
  34. package/dist/icons/BoxIcon.d.ts +0 -4
  35. package/dist/icons/CheckIcon.d.mts +0 -4
  36. package/dist/icons/CheckIcon.d.ts +0 -4
  37. package/dist/icons/CloseIcon.d.mts +0 -4
  38. package/dist/icons/CloseIcon.d.ts +0 -4
  39. package/dist/icons/CouponIcon.d.mts +0 -4
  40. package/dist/icons/CouponIcon.d.ts +0 -4
  41. package/dist/icons/DocumentIcon.d.mts +0 -4
  42. package/dist/icons/DocumentIcon.d.ts +0 -4
  43. package/dist/icons/HelpIcon.d.mts +0 -4
  44. package/dist/icons/HelpIcon.d.ts +0 -4
  45. package/dist/icons/InfoIcon.d.mts +0 -4
  46. package/dist/icons/InfoIcon.d.ts +0 -4
  47. package/dist/icons/MailIcon.d.mts +0 -4
  48. package/dist/icons/MailIcon.d.ts +0 -4
  49. package/dist/icons/PhoneIcon.d.mts +0 -4
  50. package/dist/icons/PhoneIcon.d.ts +0 -4
  51. package/dist/icons/PlusIcon.d.mts +0 -4
  52. package/dist/icons/PlusIcon.d.ts +0 -4
  53. package/dist/icons/UndoIcon.d.mts +0 -4
  54. package/dist/icons/UndoIcon.d.ts +0 -4
package/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [9.3.0] - 2026-11-27
6
+ A token for the content's fade, the built-in icons deprecated, and two fixes. Nothing to change in your code: the icons still work as before, and leaving them can wait until the next major version.
7
+
8
+ ### Added
9
+ - `--mp-duration-fade` (`150ms`): how long the content takes to fade out before the pill shrinks, and in once it has grown, like the other duration tokens
10
+
11
+ ### Deprecated
12
+ - The twelve built-in icons (`ArrowIcon`, `BoxIcon`, `CheckIcon`, `CloseIcon`, `CouponIcon`, `DocumentIcon`, `HelpIcon`, `InfoIcon`, `MailIcon`, `PhoneIcon`, `PlusIcon`, `UndoIcon`) and `IconProps`: bring your own icons, any React content fits an icon slot (README, "Icons"). They still work, unchanged, and go in the next major version. The defaults the library draws itself stay
13
+
14
+ ### Fixed
15
+ - React 18 no longer warns about `useLayoutEffect` when the pills render on the server (L31)
16
+ - An `<img>` in an icon slot (a notification's, an action's, a field's) is sized like an `<svg>`, 1em square, instead of its file's own size
17
+
5
18
  ## [9.2.0] - 2026-11-26
6
19
  Placement changes through the circle, and new layouts for notifications: in rows on any host, and as cards or flags in a sidebar. One default changes: a pill whose placement changes now closes to a circle, travels, and opens at its new place; `moveThroughCircle={false}` keeps the old travel at full size. Nothing else to change in your code.
7
20
 
package/MIGRATING.md CHANGED
@@ -139,6 +139,8 @@ The active item also changes: an item is active on its own path and below, on wh
139
139
  ## 4. Icons
140
140
  Icons are components now, and any React content works as an icon.
141
141
 
142
+ > **The built-in icons below are deprecated since 9.3** (they still work, and go in the next major version): you can also pass your own icons right away, any SVG, image or icon component ([README, "Icons"](./README.md#icons)). The table is the quickest way off 8.x.
143
+
142
144
  | 8.x name | 9 component |
143
145
  |---|---|
144
146
  | `info` | `InfoIcon` |
package/README.md CHANGED
@@ -3,10 +3,7 @@ Let it empower you.
3
3
 
4
4
  > **9.0.0 is the first stable release of Magic Pill**; earlier versions are deprecated. Upgrading from 8.x? Read the [migration guide](./MIGRATING.md). 8.x is documented in the [8.1.0 README](https://github.com/CedricTheveneau/Magic-Pill/tree/v8.1.0#readme).
5
5
 
6
- **[Try it on the live demo](https://cedrictheveneau.github.io/Magic-Pill/)**: the playground, the templates and the building blocks.
7
-
8
- #### Thank you !!
9
- Thank you for your patience and to all people who already have shown interest in Magic Pill, it's my very first npm package and I couldn't ask for a better reception of my package after only a few days after its initial release.
6
+ **[Try it on the live demo](https://cedrictheveneau.github.io/Magic-Pill/)**: the playground, the templates, the building blocks, and [the docs](https://cedrictheveneau.github.io/Magic-Pill/docs/) with live examples.
10
7
 
11
8
  ## Badges
12
9
  ![npm version](https://img.shields.io/npm/v/magic-pill?color=blue)
@@ -18,7 +15,7 @@ Thank you for your patience and to all people who already have shown interest in
18
15
  ## Introduction
19
16
  Magic Pill is **a design primitive, not just a notification library.** At its core is *the pill*: a dark, fully rounded, elevated container with a strong design language, and you can put anything inside it.
20
17
 
21
- On top of it come ready-made **templates** (a notification, a navbar) and a **controller** you can call from anywhere: `pill().notify(...)`. Use one pill as a discreet assistant at the bottom of the page, or several pills together (a sidebar, a navbar, a modal) to build a whole interface.
18
+ On top of it come ready-made **templates** (a notification, a navbar, a form panel) and a **controller** you can call from anywhere: `pill().notify(...)`. Use one pill as a discreet assistant at the bottom of the page, or several pills together (a sidebar, a navbar, a modal) to build a whole interface.
22
19
 
23
20
  ## Features
24
21
  - [X] Two lines to get started: mount `<MagicPill />`, then call `pill().notify(...)` from anywhere, even outside React
@@ -26,11 +23,13 @@ On top of it come ready-made **templates** (a notification, a navbar) and a **co
26
23
  - [X] Several named pills on one page, at any edge or corner, inline, or as a modal; pills that share a spot line up instead of overlapping
27
24
  - [X] Anything inside: messages, icons and panels are React content; build your own templates from the same parts
28
25
  - [X] Shape-changing animations (circle ↔ pill ↔ panel) at the pill's real size, notifications that slide into each other, a pill that travels when its placement changes, all respecting reduced motion
26
+ - [X] Notifications laid out the way the pill is: in one row, in rows, and in a sidebar as cards or as a flag out of its edge
29
27
  - [X] Forms: fields on native controls, in a panel or in the pill, validated by the browser, and a calendar (optional)
28
+ - [X] Themes (optional): glass and Liquid Glass, with refraction, a pointer light and adaptive tinting, or a theme of your own from the tokens
30
29
  - [X] Accessible: screen reader announcements, keyboard focus pauses the countdown, focus handling for panels and modals
31
30
  - [X] Works in any React 18+ app, including React Server Components (Next.js App Router), with any router
32
31
  - [X] Styles you can override without `!important`, design tokens, no fonts loaded behind your back
33
- - [X] Tiny: the quick start adds about **13.3 kB gzipped** to your app (10.2 kB of JavaScript + 3.1 kB of CSS, minified by your bundler), checked in CI. Unused parts are tree-shaken.
32
+ - [X] Tiny: the quick start adds about **16.5 kB gzipped** to your app (13.1 kB of JavaScript + 3.4 kB of CSS, minified by your bundler), checked in CI. Unused parts are tree-shaken.
34
33
  - [X] Written in TypeScript, zero runtime dependencies
35
34
 
36
35
  ## Installation
@@ -74,6 +73,8 @@ pill().notify({ icon: <CheckIcon />, message: "Saved!", variant: "success" });
74
73
 
75
74
  That's it. The pill pops in at the bottom of the page, stays for 5 seconds, then goes away.
76
75
 
76
+ > **Icons:** the examples use the built-in icons (`CheckIcon`…), which are **deprecated**: they still work, and go in the next major version. Any icon works instead, from your own SVGs to Lucide or Font Awesome: see [Icons](#icons).
77
+
77
78
  ### Fonts
78
79
  Magic Pill loads no fonts: it uses your page's fonts. For the signature look, an italic serif for messages (**Overlock**) and a bold sans for action labels (**Lexend**), point the two font tokens at them.
79
80
 
@@ -483,9 +484,35 @@ With the keyboard: the arrows, Home and End (the week), Page Up and Page Down (t
483
484
  > **Your app's resets:** CSS like `input { border: 1px solid }` that isn't in a layer also reaches the pill's fields. Their look is on what surrounds the controls, so they only need to stay bare: scope such rules, or put them in a layer. A global `:focus-visible` outline is the exception, already handled: the focus ring is drawn around the field, for the keyboard only (not after a click or a tap), and the bare control never draws one of its own.
484
485
 
485
486
  ## Icons
486
- Twelve built-in icons, drawn in `currentColor` and decorative by default (`aria-hidden`). Any other icon or SVG works too: icons are just React content.
487
+ Bring your own: every `icon` (a notification's, an action's, a navbar item's, a field's, `idleIcon`, a panel's `trigger`) and `<PillIcon>` take any React content. The slot sizes and colours it for you:
488
+
489
+ - an `<svg>` or an `<img>` is drawn 1em square, whatever its own `width` and `height` (1.25rem in an action, larger as the leading icon);
490
+ - a font icon (Font Awesome's `<i>`, an emoji) takes the slot's font size;
491
+ - it's in the pill's text colour: draw your SVGs in `currentColor` to follow it (most icon libraries do);
492
+ - it's decorative (`aria-hidden`): the action's label or the message says what it means. Give `<PillIcon>` a `label` when the icon carries meaning of its own.
493
+
494
+ ```tsx
495
+ import { ShoppingCart } from "lucide-react"; // or Heroicons, Phosphor, Material…
496
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
497
+ import { faTruck } from "@fortawesome/free-solid-svg-icons";
498
+
499
+ pill().notify({ icon: <ShoppingCart />, message: "Added to your cart" });
500
+ pill().notify({ icon: <FontAwesomeIcon icon={faTruck} />, message: "Shipped today" });
501
+ pill().notify({ icon: <i className="fa-solid fa-truck" />, message: "Shipped today" }); // Font Awesome's web font
502
+ pill().notify({ icon: <img src="/icons/cart.svg" alt="" />, message: "Added to your cart" });
503
+ pill().notify({
504
+ icon: (
505
+ <svg viewBox="0 0 24 24" fill="currentColor">
506
+ <path d="M12 2 2 22h20L12 2Z" />
507
+ </svg>
508
+ ),
509
+ message: "Your own SVG",
510
+ });
511
+ ```
512
+
513
+ An `<img>` keeps its file's colours: `currentColor` only reaches inline SVGs and font icons.
487
514
 
488
- `ArrowIcon` · `BoxIcon` · `CheckIcon` · `CloseIcon` · `CouponIcon` · `DocumentIcon` · `HelpIcon` · `InfoIcon` · `MailIcon` · `PhoneIcon` · `PlusIcon` · `UndoIcon`
515
+ **The twelve built-in icons are deprecated** (`ArrowIcon` · `BoxIcon` · `CheckIcon` · `CloseIcon` · `CouponIcon` · `DocumentIcon` · `HelpIcon` · `InfoIcon` · `MailIcon` · `PhoneIcon` · `PlusIcon` · `UndoIcon`, and `IconProps`). They still work, unchanged, and editors strike them through; they go in the next major version. The library keeps the three it uses as defaults (the panel's trigger, its close button, the submit's tick), so nothing changes when you don't pass your own. To keep one of them, copy its SVG from `src/icons/` (MIT).
489
516
 
490
517
  ## Styling
491
518
  - **Easy to override:** every rule sits in a `magic-pill` cascade layer. Any CSS of yours that isn't in a layer wins, whatever its specificity, with no `!important`.
@@ -526,6 +553,7 @@ Twelve built-in icons, drawn in `currentColor` and decorative by default (`aria-
526
553
  | `--mp-offset` / `--mp-z-index` | `1.5rem` from the viewport edges (plus safe areas) / `50` |
527
554
  | `--mp-backdrop` / `--mp-backdrop-blur` | the overlay's backdrop: `rgb(20 20 20 / 0.4)` / no blur |
528
555
  | `--mp-duration-enter` / `--mp-duration-change` / `--mp-duration-exit` | `500ms` / `250ms` / `300ms` |
556
+ | `--mp-duration-fade` | `150ms`: the content fades out before the pill shrinks, and in once it has grown |
529
557
  | `--mp-scale-origin` | `center`: where the pill pops in from and scales out to (e.g. `bottom` to come out of the edge) |
530
558
  | `--mp-align` | How a vertical pill lines up its items: `start`, `center` or `end` (following the text direction). By default, along the screen edge for a `left` or `right` pill, centred otherwise |
531
559
 
@@ -615,7 +643,7 @@ import { MagicPill, PillOptics } from "magic-pill";
615
643
  - **Safe links:** links only render relative, `http(s):`, `mailto:` and `tel:` URLs. Anything else, such as `javascript:`, renders without a link (with a warning in development). React 18 doesn't block those URLs by itself.
616
644
 
617
645
  ## TypeScript
618
- Everything is typed. The main types are `NotifyOptions`, `NotifyInput`, `PillController`, `MagicPillProps`, `PillProps`, `PillPresence`, `PillPlacement`, `PillVariant`, `PillTheme`, `NavItem` and `LinkComponent`.
646
+ Everything is typed, and every component's props are exported as `<Component>Props` (`MagicPillProps`, `PillProps`, `PillFormPanelProps`, `PillInputProps`…). The other main types are `NotifyOptions`, `NotifyInput`, `PillController`, `PillPresence`, `PillPlacement`, `PillVariant`, `PillTheme`, `NotificationLayout`, `NavItem`, `LinkComponent` and `SendHandler`.
619
647
 
620
648
  ## Build your own
621
649
  Maybe what I brought to the table wasn't enough but you like the idea behind it, that's why Magic Pill is under [MIT License](https://www.tldrlegal.com/license/mit-license), which means you can pretty much do whatever you want and build upon my own version of Magic Pill to bring it to new heights or just make it your own.
@@ -660,10 +688,12 @@ You can also send me emails anytime at [theveneaucedricpro@gmail.com](mailto:the
660
688
  Magic Pill is distributed under the [MIT License](https://www.tldrlegal.com/license/mit-license).
661
689
 
662
690
  ## What's next?
663
- | Coming next | Done in 9.0 |
691
+ | Coming next | Done in 9.x |
664
692
  |-----------|-----------|
665
- | A documentation site with live examples | Custom icons (any React content) |
666
- | Themes (glass, custom) | Animated morphing between contents, panels and placements |
667
- | Forms, toolbox and carousel indicator templates | Transitions between the navbar and notifications |
668
- | More built-in icons | Function triggers on actions (`onClick`) |
669
- | | Responsive styles, full documentation, tests |
693
+ | The Electron: a small circle that splits off the pill to keep an activity (a timer, a call, an upload) within reach | A documentation site with live examples |
694
+ | Toolbox and carousel indicator templates | Themes: glass, Liquid Glass, your own |
695
+ | More layouts for vertical pills | Forms and a calendar |
696
+ | Performance presets for the glass | Notification layouts: rows, cards, flags |
697
+ | Usage from a CDN | Pills that share a spot line up instead of overlapping |
698
+ | | Animated morphing between contents, panels and placements, through the circle |
699
+ | | Any icon (any React content), actions with `onClick` or `href`, full documentation, tests |
@@ -159,7 +159,7 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
159
159
  }
160
160
  });
161
161
  const flagY = flagDisplayed.presence === "panel" ? void 0 : flagSpot.y;
162
- (0, react.useLayoutEffect)(() => {
162
+ require_react.useIsomorphicLayoutEffect(() => {
163
163
  const from = flagFrom.current;
164
164
  flagFrom.current = null;
165
165
  const flag = flagRef.current;
@@ -175,7 +175,7 @@ const MagicPill = (0, react.forwardRef)(function MagicPill({ name = "main", chil
175
175
  });
176
176
  }, [flagSpot, flagY]);
177
177
  const flagPresence = (0, react.useRef)(flagDisplayed.presence);
178
- (0, react.useLayoutEffect)(() => {
178
+ require_react.useIsomorphicLayoutEffect(() => {
179
179
  const previous = flagPresence.current;
180
180
  flagPresence.current = flagDisplayed.presence;
181
181
  const sidebar = rootRef.current;
@@ -1,13 +1,13 @@
1
1
  "use client";
2
2
 
3
- import { Fragment, forwardRef, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
3
+ import { Fragment, forwardRef, useEffect, useMemo, useRef, useState } from "react";
4
4
  import Pill from "../Pill/Pill.mjs";
5
5
  import { PillIcon } from "../Pill/parts.mjs";
6
6
  import { NotificationContent } from "../PillNotification/PillNotification.mjs";
7
7
  import { getStore } from "../store/store.mjs";
8
8
  import { getInputModality, trackInputModality } from "../utils/inputModality.mjs";
9
9
  import { usePillQueue } from "../store/usePillQueue.mjs";
10
- import { mergeRefs } from "../utils/react.mjs";
10
+ import { mergeRefs, useIsomorphicLayoutEffect } from "../utils/react.mjs";
11
11
  import { prefersReducedMotion } from "../utils/timing.mjs";
12
12
  import { VISUALLY_HIDDEN } from "../utils/visuallyHidden.mjs";
13
13
  import { BASE, IDLE, NONE, isOpen, readTimings } from "./choreography.mjs";
@@ -159,7 +159,7 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
159
159
  }
160
160
  });
161
161
  const flagY = flagDisplayed.presence === "panel" ? void 0 : flagSpot.y;
162
- useLayoutEffect(() => {
162
+ useIsomorphicLayoutEffect(() => {
163
163
  const from = flagFrom.current;
164
164
  flagFrom.current = null;
165
165
  const flag = flagRef.current;
@@ -175,7 +175,7 @@ const MagicPill = forwardRef(function MagicPill({ name = "main", children, scene
175
175
  });
176
176
  }, [flagSpot, flagY]);
177
177
  const flagPresence = useRef(flagDisplayed.presence);
178
- useLayoutEffect(() => {
178
+ useIsomorphicLayoutEffect(() => {
179
179
  const previous = flagPresence.current;
180
180
  flagPresence.current = flagDisplayed.presence;
181
181
  const sidebar = rootRef.current;
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  let react = require("react");
4
+ const require_react = require("../utils/react.js");
4
5
  const require_choreography = require("./choreography.js");
5
6
  const require_morph = require("../Pill/morph.js");
6
7
 
@@ -19,7 +20,7 @@ function useChoreography(rootRef, target, options) {
19
20
  optionsRef.current = options;
20
21
  const followUps = (0, react.useRef)([]);
21
22
  const capture = (0, react.useRef)(null);
22
- (0, react.useLayoutEffect)(() => {
23
+ require_react.useIsomorphicLayoutEffect(() => {
23
24
  const swapped = capture.current;
24
25
  capture.current = null;
25
26
  if (swapped && rootRef.current) require_morph.playSwap(rootRef.current, swapped);
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
- import { useEffect, useLayoutEffect, useRef, useState } from "react";
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { useIsomorphicLayoutEffect } from "../utils/react.mjs";
4
5
  import { batchSteps, isSwap, planSteps, readTimings } from "./choreography.mjs";
5
6
  import { captureSwap, playSwap } from "../Pill/morph.mjs";
6
7
 
@@ -19,7 +20,7 @@ function useChoreography(rootRef, target, options) {
19
20
  optionsRef.current = options;
20
21
  const followUps = useRef([]);
21
22
  const capture = useRef(null);
22
- useLayoutEffect(() => {
23
+ useIsomorphicLayoutEffect(() => {
23
24
  const swapped = capture.current;
24
25
  capture.current = null;
25
26
  if (swapped && rootRef.current) playSwap(rootRef.current, swapped);
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  let react = require("react");
4
+ const require_react = require("../utils/react.js");
4
5
 
5
6
  // src/Pill/modal.ts
6
7
  /**
@@ -31,7 +32,7 @@ function useModal(rootRef, isOverlay, presence, lastSize) {
31
32
  }
32
33
  if (presence === "rest" || !dialog.contains(document.activeElement)) dialog.focus();
33
34
  };
34
- (0, react.useLayoutEffect)(() => {
35
+ require_react.useIsomorphicLayoutEffect(() => {
35
36
  show();
36
37
  const dialog = rootRef.current;
37
38
  if (!isOverlay || isVisible || !dialog?.open) return;
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
- import { useEffect, useLayoutEffect } from "react";
3
+ import { useEffect } from "react";
4
+ import { useIsomorphicLayoutEffect } from "../utils/react.mjs";
4
5
 
5
6
  // src/Pill/modal.ts
6
7
  /**
@@ -31,7 +32,7 @@ function useModal(rootRef, isOverlay, presence, lastSize) {
31
32
  }
32
33
  if (presence === "rest" || !dialog.contains(document.activeElement)) dialog.focus();
33
34
  };
34
- useLayoutEffect(() => {
35
+ useIsomorphicLayoutEffect(() => {
35
36
  show();
36
37
  const dialog = rootRef.current;
37
38
  if (!isOverlay || isVisible || !dialog?.open) return;
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  let react = require("react");
4
+ const require_react = require("../utils/react.js");
4
5
  const require_timing = require("../utils/timing.js");
5
6
 
6
7
  // src/Pill/morph.ts
@@ -403,7 +404,7 @@ function useSizeMorph(rootRef, presence, enabled, lastSize) {
403
404
  const lastPresence = (0, react.useRef)(presence);
404
405
  const running = (0, react.useRef)([]);
405
406
  const openPanel = (0, react.useRef)(void 0);
406
- (0, react.useLayoutEffect)(() => {
407
+ require_react.useIsomorphicLayoutEffect(() => {
407
408
  const element = rootRef.current;
408
409
  if (!element || typeof ResizeObserver === "undefined") return;
409
410
  const observer = new ResizeObserver((entries) => {
@@ -422,7 +423,7 @@ function useSizeMorph(rootRef, presence, enabled, lastSize) {
422
423
  running.current.forEach((animation) => animation.cancel());
423
424
  };
424
425
  }, [rootRef, lastSize]);
425
- (0, react.useLayoutEffect)(() => {
426
+ require_react.useIsomorphicLayoutEffect(() => {
426
427
  const element = rootRef.current;
427
428
  const previous = lastPresence.current;
428
429
  lastPresence.current = presence;
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
- import { Component, useLayoutEffect, useRef } from "react";
3
+ import { Component, useRef } from "react";
4
+ import { useIsomorphicLayoutEffect } from "../utils/react.mjs";
4
5
  import { parseDuration, prefersReducedMotion } from "../utils/timing.mjs";
5
6
 
6
7
  // src/Pill/morph.ts
@@ -403,7 +404,7 @@ function useSizeMorph(rootRef, presence, enabled, lastSize) {
403
404
  const lastPresence = useRef(presence);
404
405
  const running = useRef([]);
405
406
  const openPanel = useRef(void 0);
406
- useLayoutEffect(() => {
407
+ useIsomorphicLayoutEffect(() => {
407
408
  const element = rootRef.current;
408
409
  if (!element || typeof ResizeObserver === "undefined") return;
409
410
  const observer = new ResizeObserver((entries) => {
@@ -422,7 +423,7 @@ function useSizeMorph(rootRef, presence, enabled, lastSize) {
422
423
  running.current.forEach((animation) => animation.cancel());
423
424
  };
424
425
  }, [rootRef, lastSize]);
425
- useLayoutEffect(() => {
426
+ useIsomorphicLayoutEffect(() => {
426
427
  const element = rootRef.current;
427
428
  const previous = lastPresence.current;
428
429
  lastPresence.current = presence;
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  let react = require("react");
4
+ const require_react = require("../utils/react.js");
4
5
  const require_morph = require("./morph.js");
5
6
  const require_timing = require("../utils/timing.js");
6
7
 
@@ -35,7 +36,7 @@ function useTravel(rootRef, { placement, orientation, presence, enabled }) {
35
36
  if (enabled && travelsThroughCircle(shown, target) && !CLOSED.has(presence) && !require_timing.prefersReducedMotion()) setPhase("closing");
36
37
  else setShown(target);
37
38
  }
38
- (0, react.useLayoutEffect)(() => {
39
+ require_react.useIsomorphicLayoutEffect(() => {
39
40
  if (phase !== "closing") return;
40
41
  const root = rootRef.current;
41
42
  const active = document.activeElement;
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
- import { useEffect, useLayoutEffect, useRef, useState } from "react";
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { useIsomorphicLayoutEffect } from "../utils/react.mjs";
4
5
  import { readMorphTimings } from "./morph.mjs";
5
6
  import { prefersReducedMotion } from "../utils/timing.mjs";
6
7
 
@@ -35,7 +36,7 @@ function useTravel(rootRef, { placement, orientation, presence, enabled }) {
35
36
  if (enabled && travelsThroughCircle(shown, target) && !CLOSED.has(presence) && !prefersReducedMotion()) setPhase("closing");
36
37
  else setShown(target);
37
38
  }
38
- useLayoutEffect(() => {
39
+ useIsomorphicLayoutEffect(() => {
39
40
  if (phase !== "closing") return;
40
41
  const root = rootRef.current;
41
42
  const active = document.activeElement;
package/dist/Pill/zone.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  let react = require("react");
4
+ const require_react = require("../utils/react.js");
4
5
  const require_morph = require("./morph.js");
5
6
  const require_timing = require("../utils/timing.js");
6
7
 
@@ -97,7 +98,7 @@ function useZone(rootRef, zone, presence) {
97
98
  size: 0,
98
99
  frozen: presence === "panel"
99
100
  });
100
- (0, react.useLayoutEffect)(() => {
101
+ require_react.useIsomorphicLayoutEffect(() => {
101
102
  const rung = rungRef.current;
102
103
  const element = rootRef.current;
103
104
  if (!zone || !element) return;
@@ -124,7 +125,7 @@ function useZone(rootRef, zone, presence) {
124
125
  arrange(zone, () => travel(element));
125
126
  };
126
127
  }, [rootRef, zone]);
127
- (0, react.useLayoutEffect)(() => {
128
+ require_react.useIsomorphicLayoutEffect(() => {
128
129
  const rung = rungRef.current;
129
130
  const previous = rung.presence;
130
131
  const { element } = rung;
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
- import { useLayoutEffect, useRef } from "react";
3
+ import { useRef } from "react";
4
+ import { useIsomorphicLayoutEffect } from "../utils/react.mjs";
4
5
  import { EASING, MORPH, cancel, readMorphTimings } from "./morph.mjs";
5
6
  import { parseDuration, prefersReducedMotion } from "../utils/timing.mjs";
6
7
 
@@ -97,7 +98,7 @@ function useZone(rootRef, zone, presence) {
97
98
  size: 0,
98
99
  frozen: presence === "panel"
99
100
  });
100
- useLayoutEffect(() => {
101
+ useIsomorphicLayoutEffect(() => {
101
102
  const rung = rungRef.current;
102
103
  const element = rootRef.current;
103
104
  if (!zone || !element) return;
@@ -124,7 +125,7 @@ function useZone(rootRef, zone, presence) {
124
125
  arrange(zone, () => travel(element));
125
126
  };
126
127
  }, [rootRef, zone]);
127
- useLayoutEffect(() => {
128
+ useIsomorphicLayoutEffect(() => {
128
129
  const rung = rungRef.current;
129
130
  const previous = rung.presence;
130
131
  const { element } = rung;
@@ -33,7 +33,7 @@ function useBusyLabel(busyLabel, interval, isBusy) {
33
33
  /** One label replacing another: the action widens or narrows with it. */
34
34
  function useLabelMorph(buttonRef, label) {
35
35
  const previous = (0, react.useRef)(null);
36
- (0, react.useLayoutEffect)(() => {
36
+ require_react.useIsomorphicLayoutEffect(() => {
37
37
  const text = buttonRef.current?.querySelector("[data-mp=\"label\"] > span");
38
38
  if (!text) return;
39
39
  text.getAnimations?.().forEach((animation) => animation.cancel());
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
 
3
- import { forwardRef, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
3
+ import { forwardRef, useContext, useEffect, useMemo, useRef, useState } from "react";
4
4
  import { FormContext } from "./FormContext.mjs";
5
5
  import PillAction from "../Pill/PillAction.mjs";
6
6
  import CheckIcon from "../icons/CheckIcon.mjs";
7
- import { mergeRefs } from "../utils/react.mjs";
7
+ import { mergeRefs, useIsomorphicLayoutEffect } from "../utils/react.mjs";
8
8
  import { prefersReducedMotion } from "../utils/timing.mjs";
9
9
  import { VISUALLY_HIDDEN } from "../utils/visuallyHidden.mjs";
10
10
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -33,7 +33,7 @@ function useBusyLabel(busyLabel, interval, isBusy) {
33
33
  /** One label replacing another: the action widens or narrows with it. */
34
34
  function useLabelMorph(buttonRef, label) {
35
35
  const previous = useRef(null);
36
- useLayoutEffect(() => {
36
+ useIsomorphicLayoutEffect(() => {
37
37
  const text = buttonRef.current?.querySelector("[data-mp=\"label\"] > span");
38
38
  if (!text) return;
39
39
  text.getAnimations?.().forEach((animation) => animation.cancel());
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  let react = require("react");
4
+ const require_react = require("../utils/react.js");
4
5
 
5
6
  // src/PillForm/popover.ts
6
7
  /** From the field, and from the screen's edges */
@@ -27,7 +28,7 @@ function placePopover(field, popover, viewport, isRtl) {
27
28
  * elsewhere closes it. Without popovers, it's shown in the page, under the field.
28
29
  */
29
30
  function usePopover(popoverRef, fieldRef, isOpen, onClose) {
30
- (0, react.useLayoutEffect)(() => {
31
+ require_react.useIsomorphicLayoutEffect(() => {
31
32
  const popover = popoverRef.current;
32
33
  const field = fieldRef.current;
33
34
  if (!isOpen || !popover || !field || !supportsPopover()) return;
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
- import { useEffect, useLayoutEffect } from "react";
3
+ import { useEffect } from "react";
4
+ import { useIsomorphicLayoutEffect } from "../utils/react.mjs";
4
5
 
5
6
  // src/PillForm/popover.ts
6
7
  /** From the field, and from the screen's edges */
@@ -27,7 +28,7 @@ function placePopover(field, popover, viewport, isRtl) {
27
28
  * elsewhere closes it. Without popovers, it's shown in the page, under the field.
28
29
  */
29
30
  function usePopover(popoverRef, fieldRef, isOpen, onClose) {
30
- useLayoutEffect(() => {
31
+ useIsomorphicLayoutEffect(() => {
31
32
  const popover = popoverRef.current;
32
33
  const field = fieldRef.current;
33
34
  if (!isOpen || !popover || !field || !supportsPopover()) return;
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  let react = require("react");
4
+ const require_react = require("../utils/react.js");
4
5
  const require_themed = require("../Pill/themed.js");
5
6
  const require_adaptive = require("./adaptive.js");
6
7
  const require_lens = require("./lens.js");
@@ -119,7 +120,7 @@ function PillOptics() {
119
120
  else element.style.removeProperty(property);
120
121
  });
121
122
  };
122
- (0, react.useLayoutEffect)(apply, [lenses]);
123
+ require_react.useIsomorphicLayoutEffect(apply, [lenses]);
123
124
  (0, react.useEffect)(() => {
124
125
  let stopped = false;
125
126
  let pending = false;
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
- import { Fragment, useEffect, useLayoutEffect, useRef, useState } from "react";
3
+ import { Fragment, useEffect, useRef, useState } from "react";
4
+ import { useIsomorphicLayoutEffect } from "../utils/react.mjs";
4
5
  import { onThemedPills, themedPills } from "../Pill/themed.mjs";
5
6
  import { adapt } from "./adaptive.mjs";
6
7
  import { canRefract, lensId, lensMap, makeLens } from "./lens.mjs";
@@ -119,7 +120,7 @@ function PillOptics() {
119
120
  else element.style.removeProperty(property);
120
121
  });
121
122
  };
122
- useLayoutEffect(apply, [lenses]);
123
+ useIsomorphicLayoutEffect(apply, [lenses]);
123
124
  useEffect(() => {
124
125
  let stopped = false;
125
126
  let pending = false;
package/dist/forms.css CHANGED
@@ -518,9 +518,10 @@
518
518
  font-size: 1.15rem;
519
519
  pointer-events: none;
520
520
 
521
- & > svg {
521
+ & > :is(svg, img) {
522
522
  inline-size: 1em;
523
523
  block-size: 1em;
524
+ object-fit: contain;
524
525
  }
525
526
  }
526
527
 
package/dist/index.d.mts CHANGED
@@ -30,17 +30,31 @@ import { PillColor, PillColorProps } from "./PillForm/PillColor.mjs";
30
30
  import MagicPill, { MagicPillProps } from "./MagicPill/MagicPill.mjs";
31
31
  import { DismissReason, NotifyInput, NotifyOptions, NotifyRenderOptions, PillController, PillQueueState, QueuedNotification, pill } from "./store/store.mjs";
32
32
  import { usePillQueue } from "./store/usePillQueue.mjs";
33
- import ArrowIcon from "./icons/ArrowIcon.mjs";
34
- import BoxIcon from "./icons/BoxIcon.mjs";
35
- import CheckIcon from "./icons/CheckIcon.mjs";
36
- import CloseIcon from "./icons/CloseIcon.mjs";
37
- import CouponIcon from "./icons/CouponIcon.mjs";
38
- import DocumentIcon from "./icons/DocumentIcon.mjs";
39
- import HelpIcon from "./icons/HelpIcon.mjs";
40
- import InfoIcon from "./icons/InfoIcon.mjs";
41
- import MailIcon from "./icons/MailIcon.mjs";
42
- import PhoneIcon from "./icons/PhoneIcon.mjs";
43
- import PlusIcon from "./icons/PlusIcon.mjs";
44
- import UndoIcon from "./icons/UndoIcon.mjs";
45
- import { IconProps } from "./icons/types.mjs";
46
- export { ArrowIcon, BoxIcon, type CalendarLabels, CheckIcon, CloseIcon, CouponIcon, type DateType, type DismissReason, DocumentIcon, type FieldControlProps, type FieldProps, HelpIcon, type IconProps, InfoIcon, type LinkComponent, MagicPill, type MagicPillProps, MailIcon, type NavActionItem, type NavItem, type NavLinkItem, type NavPanelItem, type NotificationAction, type NotificationLayout, type NotificationPanel, type NotifyInput, type NotifyOptions, type NotifyRenderOptions, PhoneIcon, Pill, PillAction, type PillActionProps, PillActions, type PillButtonActionProps, PillCheckbox, type PillCheckboxProps, type PillChoice, PillChoices, type PillChoicesProps, PillCode, type PillCodeProps, PillColor, type PillColorProps, type PillContextValue, type PillController, PillDate, type PillDateProps, PillDivider, PillField, type PillFieldProps, PillFields, type PillFieldsProps, PillFile, type PillFileProps, PillForm, PillFormPanel, type PillFormPanelProps, type PillFormProps, PillIcon, PillInput, type PillInputProps, type PillInputType, type PillLinkActionProps, PillMessage, type PillMultipleChoiceProps, PillNavbar, type PillNavbarProps, PillNotification, type PillNotificationClassNames, type PillNotificationProps, PillOptics, type PillOption, type PillOptionGroup, type PillOrientation, PillPanel, type PillPanelProps, PillPanelTrigger, type PillPanelTriggerProps, type PillPlacement, type PillPresence, type PillProps, type PillQueueState, PillSelect, type PillSelectProps, type PillSingleChoiceProps, PillSlider, type PillSliderProps, PillStepper, type PillStepperProps, PillSubmit, type PillSubmitProps, PillSwitch, type PillSwitchProps, PillTextarea, type PillTextareaProps, type PillTheme, type PillVariant, PlusIcon, type QueuedNotification, type SceneChange, type SendHandler, UndoIcon, pill, usePill, usePillQueue };
33
+ import { IconProps as IconProps$1 } from "./icons/types.mjs";
34
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
35
+ export declare const ArrowIcon: (props: IconProps$1) => import("react").JSX.Element;
36
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
37
+ export declare const BoxIcon: (props: IconProps$1) => import("react").JSX.Element;
38
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
39
+ export declare const CheckIcon: (props: IconProps$1) => import("react").JSX.Element;
40
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
41
+ export declare const CloseIcon: (props: IconProps$1) => import("react").JSX.Element;
42
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
43
+ export declare const CouponIcon: (props: IconProps$1) => import("react").JSX.Element;
44
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
45
+ export declare const DocumentIcon: (props: IconProps$1) => import("react").JSX.Element;
46
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
47
+ export declare const HelpIcon: (props: IconProps$1) => import("react").JSX.Element;
48
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
49
+ export declare const InfoIcon: (props: IconProps$1) => import("react").JSX.Element;
50
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
51
+ export declare const MailIcon: (props: IconProps$1) => import("react").JSX.Element;
52
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
53
+ export declare const PhoneIcon: (props: IconProps$1) => import("react").JSX.Element;
54
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
55
+ export declare const PlusIcon: (props: IconProps$1) => import("react").JSX.Element;
56
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
57
+ export declare const UndoIcon: (props: IconProps$1) => import("react").JSX.Element;
58
+ /** @deprecated The props of the built-in icons, which are deprecated: any `<svg>` attribute, `ComponentPropsWithoutRef<"svg">`. */
59
+ export type IconProps = IconProps$1;
60
+ export { type CalendarLabels, type DateType, type DismissReason, type FieldControlProps, type FieldProps, type LinkComponent, MagicPill, type MagicPillProps, type NavActionItem, type NavItem, type NavLinkItem, type NavPanelItem, type NotificationAction, type NotificationLayout, type NotificationPanel, type NotifyInput, type NotifyOptions, type NotifyRenderOptions, Pill, PillAction, type PillActionProps, PillActions, type PillButtonActionProps, PillCheckbox, type PillCheckboxProps, type PillChoice, PillChoices, type PillChoicesProps, PillCode, type PillCodeProps, PillColor, type PillColorProps, type PillContextValue, type PillController, PillDate, type PillDateProps, PillDivider, PillField, type PillFieldProps, PillFields, type PillFieldsProps, PillFile, type PillFileProps, PillForm, PillFormPanel, type PillFormPanelProps, type PillFormProps, PillIcon, PillInput, type PillInputProps, type PillInputType, type PillLinkActionProps, PillMessage, type PillMultipleChoiceProps, PillNavbar, type PillNavbarProps, PillNotification, type PillNotificationClassNames, type PillNotificationProps, PillOptics, type PillOption, type PillOptionGroup, type PillOrientation, PillPanel, type PillPanelProps, PillPanelTrigger, type PillPanelTriggerProps, type PillPlacement, type PillPresence, type PillProps, type PillQueueState, PillSelect, type PillSelectProps, type PillSingleChoiceProps, PillSlider, type PillSliderProps, PillStepper, type PillStepperProps, PillSubmit, type PillSubmitProps, PillSwitch, type PillSwitchProps, PillTextarea, type PillTextareaProps, type PillTheme, type PillVariant, type QueuedNotification, type SceneChange, type SendHandler, pill, usePill, usePillQueue };
package/dist/index.d.ts CHANGED
@@ -30,17 +30,31 @@ import { PillColor, PillColorProps } from "./PillForm/PillColor.js";
30
30
  import MagicPill, { MagicPillProps } from "./MagicPill/MagicPill.js";
31
31
  import { DismissReason, NotifyInput, NotifyOptions, NotifyRenderOptions, PillController, PillQueueState, QueuedNotification, pill } from "./store/store.js";
32
32
  import { usePillQueue } from "./store/usePillQueue.js";
33
- import ArrowIcon from "./icons/ArrowIcon.js";
34
- import BoxIcon from "./icons/BoxIcon.js";
35
- import CheckIcon from "./icons/CheckIcon.js";
36
- import CloseIcon from "./icons/CloseIcon.js";
37
- import CouponIcon from "./icons/CouponIcon.js";
38
- import DocumentIcon from "./icons/DocumentIcon.js";
39
- import HelpIcon from "./icons/HelpIcon.js";
40
- import InfoIcon from "./icons/InfoIcon.js";
41
- import MailIcon from "./icons/MailIcon.js";
42
- import PhoneIcon from "./icons/PhoneIcon.js";
43
- import PlusIcon from "./icons/PlusIcon.js";
44
- import UndoIcon from "./icons/UndoIcon.js";
45
- import { IconProps } from "./icons/types.js";
46
- export { ArrowIcon, BoxIcon, type CalendarLabels, CheckIcon, CloseIcon, CouponIcon, type DateType, type DismissReason, DocumentIcon, type FieldControlProps, type FieldProps, HelpIcon, type IconProps, InfoIcon, type LinkComponent, MagicPill, type MagicPillProps, MailIcon, type NavActionItem, type NavItem, type NavLinkItem, type NavPanelItem, type NotificationAction, type NotificationLayout, type NotificationPanel, type NotifyInput, type NotifyOptions, type NotifyRenderOptions, PhoneIcon, Pill, PillAction, type PillActionProps, PillActions, type PillButtonActionProps, PillCheckbox, type PillCheckboxProps, type PillChoice, PillChoices, type PillChoicesProps, PillCode, type PillCodeProps, PillColor, type PillColorProps, type PillContextValue, type PillController, PillDate, type PillDateProps, PillDivider, PillField, type PillFieldProps, PillFields, type PillFieldsProps, PillFile, type PillFileProps, PillForm, PillFormPanel, type PillFormPanelProps, type PillFormProps, PillIcon, PillInput, type PillInputProps, type PillInputType, type PillLinkActionProps, PillMessage, type PillMultipleChoiceProps, PillNavbar, type PillNavbarProps, PillNotification, type PillNotificationClassNames, type PillNotificationProps, PillOptics, type PillOption, type PillOptionGroup, type PillOrientation, PillPanel, type PillPanelProps, PillPanelTrigger, type PillPanelTriggerProps, type PillPlacement, type PillPresence, type PillProps, type PillQueueState, PillSelect, type PillSelectProps, type PillSingleChoiceProps, PillSlider, type PillSliderProps, PillStepper, type PillStepperProps, PillSubmit, type PillSubmitProps, PillSwitch, type PillSwitchProps, PillTextarea, type PillTextareaProps, type PillTheme, type PillVariant, PlusIcon, type QueuedNotification, type SceneChange, type SendHandler, UndoIcon, pill, usePill, usePillQueue };
33
+ import { IconProps as IconProps$1 } from "./icons/types.js";
34
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
35
+ export declare const ArrowIcon: (props: IconProps$1) => import("react").JSX.Element;
36
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
37
+ export declare const BoxIcon: (props: IconProps$1) => import("react").JSX.Element;
38
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
39
+ export declare const CheckIcon: (props: IconProps$1) => import("react").JSX.Element;
40
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
41
+ export declare const CloseIcon: (props: IconProps$1) => import("react").JSX.Element;
42
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
43
+ export declare const CouponIcon: (props: IconProps$1) => import("react").JSX.Element;
44
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
45
+ export declare const DocumentIcon: (props: IconProps$1) => import("react").JSX.Element;
46
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
47
+ export declare const HelpIcon: (props: IconProps$1) => import("react").JSX.Element;
48
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
49
+ export declare const InfoIcon: (props: IconProps$1) => import("react").JSX.Element;
50
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
51
+ export declare const MailIcon: (props: IconProps$1) => import("react").JSX.Element;
52
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
53
+ export declare const PhoneIcon: (props: IconProps$1) => import("react").JSX.Element;
54
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
55
+ export declare const PlusIcon: (props: IconProps$1) => import("react").JSX.Element;
56
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
57
+ export declare const UndoIcon: (props: IconProps$1) => import("react").JSX.Element;
58
+ /** @deprecated The props of the built-in icons, which are deprecated: any `<svg>` attribute, `ComponentPropsWithoutRef<"svg">`. */
59
+ export type IconProps = IconProps$1;
60
+ export { type CalendarLabels, type DateType, type DismissReason, type FieldControlProps, type FieldProps, type LinkComponent, MagicPill, type MagicPillProps, type NavActionItem, type NavItem, type NavLinkItem, type NavPanelItem, type NotificationAction, type NotificationLayout, type NotificationPanel, type NotifyInput, type NotifyOptions, type NotifyRenderOptions, Pill, PillAction, type PillActionProps, PillActions, type PillButtonActionProps, PillCheckbox, type PillCheckboxProps, type PillChoice, PillChoices, type PillChoicesProps, PillCode, type PillCodeProps, PillColor, type PillColorProps, type PillContextValue, type PillController, PillDate, type PillDateProps, PillDivider, PillField, type PillFieldProps, PillFields, type PillFieldsProps, PillFile, type PillFileProps, PillForm, PillFormPanel, type PillFormPanelProps, type PillFormProps, PillIcon, PillInput, type PillInputProps, type PillInputType, type PillLinkActionProps, PillMessage, type PillMultipleChoiceProps, PillNavbar, type PillNavbarProps, PillNotification, type PillNotificationClassNames, type PillNotificationProps, PillOptics, type PillOption, type PillOptionGroup, type PillOrientation, PillPanel, type PillPanelProps, PillPanelTrigger, type PillPanelTriggerProps, type PillPlacement, type PillPresence, type PillProps, type PillQueueState, PillSelect, type PillSelectProps, type PillSingleChoiceProps, PillSlider, type PillSliderProps, PillStepper, type PillStepperProps, PillSubmit, type PillSubmitProps, PillSwitch, type PillSwitchProps, PillTextarea, type PillTextareaProps, type PillTheme, type PillVariant, type QueuedNotification, type SceneChange, type SendHandler, pill, usePill, usePillQueue };
package/dist/index.js CHANGED
@@ -40,17 +40,43 @@ const require_PhoneIcon = require("./icons/PhoneIcon.js");
40
40
  const require_PlusIcon = require("./icons/PlusIcon.js");
41
41
  const require_UndoIcon = require("./icons/UndoIcon.js");
42
42
 
43
- exports.ArrowIcon = require_ArrowIcon;
44
- exports.BoxIcon = require_BoxIcon;
45
- exports.CheckIcon = require_CheckIcon;
46
- exports.CloseIcon = require_CloseIcon;
47
- exports.CouponIcon = require_CouponIcon;
48
- exports.DocumentIcon = require_DocumentIcon;
49
- exports.HelpIcon = require_HelpIcon;
50
- exports.InfoIcon = require_InfoIcon;
43
+ // src/index.ts
44
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
45
+ const ArrowIcon = require_ArrowIcon;
46
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
47
+ const BoxIcon = require_BoxIcon;
48
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
49
+ const CheckIcon = require_CheckIcon;
50
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
51
+ const CloseIcon = require_CloseIcon;
52
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
53
+ const CouponIcon = require_CouponIcon;
54
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
55
+ const DocumentIcon = require_DocumentIcon;
56
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
57
+ const HelpIcon = require_HelpIcon;
58
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
59
+ const InfoIcon = require_InfoIcon;
60
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
61
+ const MailIcon = require_MailIcon;
62
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
63
+ const PhoneIcon = require_PhoneIcon;
64
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
65
+ const PlusIcon = require_PlusIcon;
66
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
67
+ const UndoIcon = require_UndoIcon;
68
+
69
+ exports.ArrowIcon = ArrowIcon;
70
+ exports.BoxIcon = BoxIcon;
71
+ exports.CheckIcon = CheckIcon;
72
+ exports.CloseIcon = CloseIcon;
73
+ exports.CouponIcon = CouponIcon;
74
+ exports.DocumentIcon = DocumentIcon;
75
+ exports.HelpIcon = HelpIcon;
76
+ exports.InfoIcon = InfoIcon;
51
77
  exports.MagicPill = require_MagicPill;
52
- exports.MailIcon = require_MailIcon;
53
- exports.PhoneIcon = require_PhoneIcon;
78
+ exports.MailIcon = MailIcon;
79
+ exports.PhoneIcon = PhoneIcon;
54
80
  exports.Pill = require_Pill;
55
81
  exports.PillAction = require_PillAction;
56
82
  exports.PillActions = require_parts.PillActions;
@@ -79,8 +105,8 @@ exports.PillStepper = require_PillStepper.PillStepper;
79
105
  exports.PillSubmit = require_PillSubmit.PillSubmit;
80
106
  exports.PillSwitch = require_PillSwitch.PillSwitch;
81
107
  exports.PillTextarea = require_PillTextarea.PillTextarea;
82
- exports.PlusIcon = require_PlusIcon;
83
- exports.UndoIcon = require_UndoIcon;
108
+ exports.PlusIcon = PlusIcon;
109
+ exports.UndoIcon = UndoIcon;
84
110
  exports.pill = require_store.pill;
85
111
  exports.usePill = require_PillContext.usePill;
86
112
  exports.usePillQueue = require_usePillQueue.usePillQueue;
package/dist/index.mjs CHANGED
@@ -26,17 +26,43 @@ import { PillColor } from "./PillForm/PillColor.mjs";
26
26
  import MagicPill from "./MagicPill/MagicPill.mjs";
27
27
  import { pill } from "./store/store.mjs";
28
28
  import { usePillQueue } from "./store/usePillQueue.mjs";
29
- import ArrowIcon from "./icons/ArrowIcon.mjs";
30
- import BoxIcon from "./icons/BoxIcon.mjs";
31
- import CheckIcon from "./icons/CheckIcon.mjs";
32
- import CloseIcon from "./icons/CloseIcon.mjs";
33
- import CouponIcon from "./icons/CouponIcon.mjs";
34
- import DocumentIcon from "./icons/DocumentIcon.mjs";
35
- import HelpIcon from "./icons/HelpIcon.mjs";
36
- import InfoIcon from "./icons/InfoIcon.mjs";
37
- import MailIcon from "./icons/MailIcon.mjs";
38
- import PhoneIcon from "./icons/PhoneIcon.mjs";
39
- import PlusIcon from "./icons/PlusIcon.mjs";
40
- import UndoIcon from "./icons/UndoIcon.mjs";
29
+ import ArrowIcon$1 from "./icons/ArrowIcon.mjs";
30
+ import BoxIcon$1 from "./icons/BoxIcon.mjs";
31
+ import CheckIcon$1 from "./icons/CheckIcon.mjs";
32
+ import CloseIcon$1 from "./icons/CloseIcon.mjs";
33
+ import CouponIcon$1 from "./icons/CouponIcon.mjs";
34
+ import DocumentIcon$1 from "./icons/DocumentIcon.mjs";
35
+ import HelpIcon$1 from "./icons/HelpIcon.mjs";
36
+ import InfoIcon$1 from "./icons/InfoIcon.mjs";
37
+ import MailIcon$1 from "./icons/MailIcon.mjs";
38
+ import PhoneIcon$1 from "./icons/PhoneIcon.mjs";
39
+ import PlusIcon$1 from "./icons/PlusIcon.mjs";
40
+ import UndoIcon$1 from "./icons/UndoIcon.mjs";
41
+
42
+ // src/index.ts
43
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
44
+ const ArrowIcon = ArrowIcon$1;
45
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
46
+ const BoxIcon = BoxIcon$1;
47
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
48
+ const CheckIcon = CheckIcon$1;
49
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
50
+ const CloseIcon = CloseIcon$1;
51
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
52
+ const CouponIcon = CouponIcon$1;
53
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
54
+ const DocumentIcon = DocumentIcon$1;
55
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
56
+ const HelpIcon = HelpIcon$1;
57
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
58
+ const InfoIcon = InfoIcon$1;
59
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
60
+ const MailIcon = MailIcon$1;
61
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
62
+ const PhoneIcon = PhoneIcon$1;
63
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
64
+ const PlusIcon = PlusIcon$1;
65
+ /** @deprecated Bring your own icons: any svg, image or icon component works (README, "Icons"). The built-in ones go in the next major version. */
66
+ const UndoIcon = UndoIcon$1;
41
67
 
42
68
  export { ArrowIcon, BoxIcon, CheckIcon, CloseIcon, CouponIcon, DocumentIcon, HelpIcon, InfoIcon, MagicPill, MailIcon, PhoneIcon, Pill, PillAction, PillActions, PillCheckbox, PillChoices, PillCode, PillColor, PillDate, PillDivider, PillField, PillFields, PillFile, PillForm, PillFormPanel, PillIcon, PillInput, PillMessage, PillNavbar, PillNotification, PillOptics, PillPanel, PillPanelTrigger, PillSelect, PillSlider, PillStepper, PillSubmit, PillSwitch, PillTextarea, PlusIcon, UndoIcon, pill, usePill, usePillQueue };
package/dist/styles.css CHANGED
@@ -76,7 +76,7 @@
76
76
  --_mp-exit: var(--mp-duration-exit, 300ms);
77
77
  --_mp-change: var(--mp-duration-change, 250ms);
78
78
  /* The content fades out before the pill shrinks, and in once it has grown */
79
- --_mp-fade: 150ms;
79
+ --_mp-fade: var(--mp-duration-fade, 150ms);
80
80
  /* A panel stays above the other pills until it has closed back */
81
81
  --_mp-lower: calc(var(--_mp-fade) + var(--_mp-change));
82
82
  /* The entry overshoot from the mockups' "pop" */
@@ -509,10 +509,13 @@
509
509
  font-size: 1.25rem;
510
510
  }
511
511
 
512
- & [data-mp="icon"] > svg,
513
- & [data-mp="action-icon"] > svg {
512
+ /* Any icon fits the slot: an svg or an image is 1em square, a font
513
+ icon (Font Awesome's <i>, an emoji) takes the font size */
514
+ & [data-mp="icon"] > :is(svg, img),
515
+ & [data-mp="action-icon"] > :is(svg, img) {
514
516
  inline-size: 1em;
515
517
  block-size: 1em;
518
+ object-fit: contain;
516
519
  }
517
520
 
518
521
  /* Labels: folded away (but still the accessible name) until expanded.
@@ -10,6 +10,12 @@ const INERT_VALUE = Number.parseInt(react.version, 10) >= 19 ? true : "";
10
10
  function inertProps(inert) {
11
11
  return inert ? { inert: INERT_VALUE } : {};
12
12
  }
13
+ /**
14
+ * `useLayoutEffect` in the browser, `useEffect` on the server (L31). Layout
15
+ * effects never run on the server anyway, but React 18 warns about each one
16
+ * it meets while rendering there. Every hook of the library uses this one.
17
+ */
18
+ const useIsomorphicLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
13
19
  /** Combine refs (React 18 compatible: no ref cleanup functions). */
14
20
  function mergeRefs(...refs) {
15
21
  return (node) => {
@@ -20,4 +26,5 @@ function mergeRefs(...refs) {
20
26
 
21
27
  exports.devWarn = devWarn;
22
28
  exports.inertProps = inertProps;
23
- exports.mergeRefs = mergeRefs;
29
+ exports.mergeRefs = mergeRefs;
30
+ exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
@@ -1,4 +1,4 @@
1
- import { version } from "react";
1
+ import { useEffect, useLayoutEffect, version } from "react";
2
2
 
3
3
  // src/utils/react.ts
4
4
  /** Warn in development builds only. */
@@ -10,6 +10,12 @@ const INERT_VALUE = Number.parseInt(version, 10) >= 19 ? true : "";
10
10
  function inertProps(inert) {
11
11
  return inert ? { inert: INERT_VALUE } : {};
12
12
  }
13
+ /**
14
+ * `useLayoutEffect` in the browser, `useEffect` on the server (L31). Layout
15
+ * effects never run on the server anyway, but React 18 warns about each one
16
+ * it meets while rendering there. Every hook of the library uses this one.
17
+ */
18
+ const useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
13
19
  /** Combine refs (React 18 compatible: no ref cleanup functions). */
14
20
  function mergeRefs(...refs) {
15
21
  return (node) => {
@@ -18,4 +24,4 @@ function mergeRefs(...refs) {
18
24
  };
19
25
  }
20
26
 
21
- export { devWarn, inertProps, mergeRefs };
27
+ export { devWarn, inertProps, mergeRefs, useIsomorphicLayoutEffect };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magic-pill",
3
- "version": "9.2.0",
3
+ "version": "9.3.0",
4
4
  "type": "commonjs",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -27,7 +27,7 @@
27
27
  "sideEffects": [
28
28
  "*.css"
29
29
  ],
30
- "description": "A new way to guide your audience and bring them contextual information through your app",
30
+ "description": "A design primitive for React: one pill that becomes notifications, a navbar, panels, forms and modals, and morphs between them",
31
31
  "repository": {
32
32
  "type": "git",
33
33
  "url": "git+https://github.com/CedricTheveneau/Magic-Pill.git"
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.mjs";
2
- /** v9 icon (from `arrow_label`): drawn in `currentColor`, decorative by default. */
3
- declare const ArrowIcon: (props: IconProps) => import("react").JSX.Element;
4
- export { ArrowIcon as default };
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.js";
2
- /** v9 icon (from `arrow_label`): drawn in `currentColor`, decorative by default. */
3
- declare const ArrowIcon: (props: IconProps) => import("react").JSX.Element;
4
- export = ArrowIcon;
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.mjs";
2
- /** v9 icon (from `box_label`): drawn in `currentColor`, decorative by default. */
3
- declare const BoxIcon: (props: IconProps) => import("react").JSX.Element;
4
- export { BoxIcon as default };
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.js";
2
- /** v9 icon (from `box_label`): drawn in `currentColor`, decorative by default. */
3
- declare const BoxIcon: (props: IconProps) => import("react").JSX.Element;
4
- export = BoxIcon;
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.mjs";
2
- /** v9 icon (from `checkmark`): drawn in `currentColor`, decorative by default. */
3
- declare const CheckIcon: (props: IconProps) => import("react").JSX.Element;
4
- export { CheckIcon as default };
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.js";
2
- /** v9 icon (from `checkmark`): drawn in `currentColor`, decorative by default. */
3
- declare const CheckIcon: (props: IconProps) => import("react").JSX.Element;
4
- export = CheckIcon;
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.mjs";
2
- /** v9 icon (from `cross_label`): drawn in `currentColor`, decorative by default. */
3
- declare const CloseIcon: (props: IconProps) => import("react").JSX.Element;
4
- export { CloseIcon as default };
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.js";
2
- /** v9 icon (from `cross_label`): drawn in `currentColor`, decorative by default. */
3
- declare const CloseIcon: (props: IconProps) => import("react").JSX.Element;
4
- export = CloseIcon;
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.mjs";
2
- /** v9 icon (from `coupon`): drawn in `currentColor`, decorative by default. */
3
- declare const CouponIcon: (props: IconProps) => import("react").JSX.Element;
4
- export { CouponIcon as default };
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.js";
2
- /** v9 icon (from `coupon`): drawn in `currentColor`, decorative by default. */
3
- declare const CouponIcon: (props: IconProps) => import("react").JSX.Element;
4
- export = CouponIcon;
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.mjs";
2
- /** v9 icon (from `quotation_label`): drawn in `currentColor`, decorative by default. */
3
- declare const DocumentIcon: (props: IconProps) => import("react").JSX.Element;
4
- export { DocumentIcon as default };
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.js";
2
- /** v9 icon (from `quotation_label`): drawn in `currentColor`, decorative by default. */
3
- declare const DocumentIcon: (props: IconProps) => import("react").JSX.Element;
4
- export = DocumentIcon;
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.mjs";
2
- /** v9 icon (from `questionmark`): drawn in `currentColor`, decorative by default. */
3
- declare const HelpIcon: (props: IconProps) => import("react").JSX.Element;
4
- export { HelpIcon as default };
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.js";
2
- /** v9 icon (from `questionmark`): drawn in `currentColor`, decorative by default. */
3
- declare const HelpIcon: (props: IconProps) => import("react").JSX.Element;
4
- export = HelpIcon;
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.mjs";
2
- /** v9 icon (from `info`): drawn in `currentColor`, decorative by default. */
3
- declare const InfoIcon: (props: IconProps) => import("react").JSX.Element;
4
- export { InfoIcon as default };
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.js";
2
- /** v9 icon (from `info`): drawn in `currentColor`, decorative by default. */
3
- declare const InfoIcon: (props: IconProps) => import("react").JSX.Element;
4
- export = InfoIcon;
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.mjs";
2
- /** v9 icon (from `mail_label`): drawn in `currentColor`, decorative by default. */
3
- declare const MailIcon: (props: IconProps) => import("react").JSX.Element;
4
- export { MailIcon as default };
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.js";
2
- /** v9 icon (from `mail_label`): drawn in `currentColor`, decorative by default. */
3
- declare const MailIcon: (props: IconProps) => import("react").JSX.Element;
4
- export = MailIcon;
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.mjs";
2
- /** v9 icon (from `tel_label`): drawn in `currentColor`, decorative by default. */
3
- declare const PhoneIcon: (props: IconProps) => import("react").JSX.Element;
4
- export { PhoneIcon as default };
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.js";
2
- /** v9 icon (from `tel_label`): drawn in `currentColor`, decorative by default. */
3
- declare const PhoneIcon: (props: IconProps) => import("react").JSX.Element;
4
- export = PhoneIcon;
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.mjs";
2
- /** v9 icon (from `plus_label`): drawn in `currentColor`, decorative by default. */
3
- declare const PlusIcon: (props: IconProps) => import("react").JSX.Element;
4
- export { PlusIcon as default };
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.js";
2
- /** v9 icon (from `plus_label`): drawn in `currentColor`, decorative by default. */
3
- declare const PlusIcon: (props: IconProps) => import("react").JSX.Element;
4
- export = PlusIcon;
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.mjs";
2
- /** v9 icon (from `undo_label`): drawn in `currentColor`, decorative by default. */
3
- declare const UndoIcon: (props: IconProps) => import("react").JSX.Element;
4
- export { UndoIcon as default };
@@ -1,4 +0,0 @@
1
- import { IconProps } from "./types.js";
2
- /** v9 icon (from `undo_label`): drawn in `currentColor`, decorative by default. */
3
- declare const UndoIcon: (props: IconProps) => import("react").JSX.Element;
4
- export = UndoIcon;