magic-pill 8.1.0 → 9.0.0-next.1
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 +46 -0
- package/MIGRATING.md +224 -0
- package/README.md +312 -257
- package/dist/MagicPill/MagicPill.d.mts +27 -0
- package/dist/MagicPill/MagicPill.d.ts +27 -0
- package/dist/MagicPill/MagicPill.js +185 -0
- package/dist/MagicPill/MagicPill.mjs +185 -0
- package/dist/MagicPill/choreography.js +91 -0
- package/dist/MagicPill/choreography.mjs +85 -0
- package/dist/Pill/Pill.d.mts +7 -0
- package/dist/Pill/Pill.d.ts +7 -0
- package/dist/Pill/Pill.js +106 -0
- package/dist/Pill/Pill.mjs +106 -0
- package/dist/Pill/PillAction.d.mts +7 -0
- package/dist/Pill/PillAction.d.ts +7 -0
- package/dist/Pill/PillAction.js +67 -0
- package/dist/Pill/PillAction.mjs +67 -0
- package/dist/Pill/PillContext.d.mts +3 -0
- package/dist/Pill/PillContext.d.ts +3 -0
- package/dist/Pill/PillContext.js +26 -0
- package/dist/Pill/PillContext.mjs +24 -0
- package/dist/Pill/PillPanel.d.mts +9 -0
- package/dist/Pill/PillPanel.d.ts +9 -0
- package/dist/Pill/PillPanel.js +88 -0
- package/dist/Pill/PillPanel.mjs +87 -0
- package/dist/Pill/parts.d.mts +10 -0
- package/dist/Pill/parts.d.ts +10 -0
- package/dist/Pill/parts.js +46 -0
- package/dist/Pill/parts.mjs +43 -0
- package/dist/Pill/types.d.mts +88 -0
- package/dist/Pill/types.d.ts +88 -0
- package/dist/PillNavbar/PillNavbar.d.mts +31 -0
- package/dist/PillNavbar/PillNavbar.d.ts +31 -0
- package/dist/PillNavbar/PillNavbar.js +44 -0
- package/dist/PillNavbar/PillNavbar.mjs +44 -0
- package/dist/PillNavbar/matchPath.d.mts +2 -0
- package/dist/PillNavbar/matchPath.d.ts +2 -0
- package/dist/PillNavbar/matchPath.js +34 -0
- package/dist/PillNavbar/matchPath.mjs +34 -0
- package/dist/PillNotification/PillNotification.d.mts +51 -0
- package/dist/PillNotification/PillNotification.d.ts +51 -0
- package/dist/PillNotification/PillNotification.js +64 -0
- package/dist/PillNotification/PillNotification.mjs +63 -0
- package/dist/icons/ArrowIcon.d.mts +4 -0
- package/dist/icons/ArrowIcon.d.ts +4 -0
- package/dist/icons/ArrowIcon.js +21 -0
- package/dist/icons/ArrowIcon.mjs +21 -0
- package/dist/icons/BoxIcon.d.mts +4 -0
- package/dist/icons/BoxIcon.d.ts +4 -0
- package/dist/icons/BoxIcon.js +21 -0
- package/dist/icons/BoxIcon.mjs +21 -0
- package/dist/icons/CheckIcon.d.mts +4 -0
- package/dist/icons/CheckIcon.d.ts +4 -0
- package/dist/icons/CheckIcon.js +17 -0
- package/dist/icons/CheckIcon.mjs +17 -0
- package/dist/icons/CloseIcon.d.mts +4 -0
- package/dist/icons/CloseIcon.d.ts +4 -0
- package/dist/icons/CloseIcon.js +17 -0
- package/dist/icons/CloseIcon.mjs +17 -0
- package/dist/icons/CouponIcon.d.mts +4 -0
- package/dist/icons/CouponIcon.d.ts +4 -0
- package/dist/icons/CouponIcon.js +17 -0
- package/dist/icons/CouponIcon.mjs +17 -0
- package/dist/icons/DocumentIcon.d.mts +4 -0
- package/dist/icons/DocumentIcon.d.ts +4 -0
- package/dist/icons/DocumentIcon.js +17 -0
- package/dist/icons/DocumentIcon.mjs +17 -0
- package/dist/icons/HelpIcon.d.mts +4 -0
- package/dist/icons/HelpIcon.d.ts +4 -0
- package/dist/icons/HelpIcon.js +17 -0
- package/dist/icons/HelpIcon.mjs +17 -0
- package/dist/icons/InfoIcon.d.mts +4 -0
- package/dist/icons/InfoIcon.d.ts +4 -0
- package/dist/icons/InfoIcon.js +17 -0
- package/dist/icons/InfoIcon.mjs +17 -0
- package/dist/icons/MailIcon.d.mts +4 -0
- package/dist/icons/MailIcon.d.ts +4 -0
- package/dist/icons/MailIcon.js +17 -0
- package/dist/icons/MailIcon.mjs +17 -0
- package/dist/icons/PhoneIcon.d.mts +4 -0
- package/dist/icons/PhoneIcon.d.ts +4 -0
- package/dist/icons/PhoneIcon.js +21 -0
- package/dist/icons/PhoneIcon.mjs +21 -0
- package/dist/icons/PlusIcon.d.mts +4 -0
- package/dist/icons/PlusIcon.d.ts +4 -0
- package/dist/icons/PlusIcon.js +17 -0
- package/dist/icons/PlusIcon.mjs +17 -0
- package/dist/icons/UndoIcon.d.mts +4 -0
- package/dist/icons/UndoIcon.d.ts +4 -0
- package/dist/icons/UndoIcon.js +21 -0
- package/dist/icons/UndoIcon.mjs +21 -0
- package/dist/icons/types.d.mts +3 -0
- package/dist/icons/types.d.ts +3 -0
- package/dist/index.d.mts +25 -8
- package/dist/index.d.ts +25 -9
- package/dist/index.js +50 -1
- package/dist/index.mjs +24 -1
- package/dist/store/store.d.mts +63 -0
- package/dist/store/store.d.ts +63 -0
- package/dist/store/store.js +104 -0
- package/dist/store/store.mjs +102 -0
- package/dist/store/usePillQueue.d.mts +6 -0
- package/dist/store/usePillQueue.d.ts +6 -0
- package/dist/store/usePillQueue.js +17 -0
- package/dist/store/usePillQueue.mjs +17 -0
- package/dist/styles.css +456 -0
- package/dist/utils/react.js +23 -0
- package/dist/utils/react.mjs +21 -0
- package/dist/utils/url.js +22 -0
- package/dist/utils/url.mjs +22 -0
- package/package.json +7 -4
- package/dist/MagicPill.d.mts +0 -6
- package/dist/MagicPill.d.ts +0 -7
- package/dist/MagicPill.js +0 -2
- package/dist/MagicPill.js.map +0 -1
- package/dist/MagicPill.mjs +0 -2
- package/dist/MagicPill.mjs.map +0 -1
- package/dist/Navbar/Navbar.js +0 -2
- package/dist/Navbar/Navbar.js.map +0 -1
- package/dist/Navbar/Navbar.mjs +0 -2
- package/dist/Navbar/Navbar.mjs.map +0 -1
- package/dist/Notification/Notification.js +0 -2
- package/dist/Notification/Notification.js.map +0 -1
- package/dist/Notification/Notification.mjs +0 -2
- package/dist/Notification/Notification.mjs.map +0 -1
- package/dist/defaultPillData.d.mts +0 -2
- package/dist/defaultPillData.d.ts +0 -3
- package/dist/defaultPillData.js +0 -7
- package/dist/defaultPillData.js.map +0 -1
- package/dist/defaultPillData.mjs +0 -7
- package/dist/defaultPillData.mjs.map +0 -1
- package/dist/icons/arrow_label.js +0 -2
- package/dist/icons/arrow_label.js.map +0 -1
- package/dist/icons/arrow_label.mjs +0 -2
- package/dist/icons/arrow_label.mjs.map +0 -1
- package/dist/icons/box_label.js +0 -2
- package/dist/icons/box_label.js.map +0 -1
- package/dist/icons/box_label.mjs +0 -2
- package/dist/icons/box_label.mjs.map +0 -1
- package/dist/icons/checkmark.js +0 -2
- package/dist/icons/checkmark.js.map +0 -1
- package/dist/icons/checkmark.mjs +0 -2
- package/dist/icons/checkmark.mjs.map +0 -1
- package/dist/icons/checkmark_label.js +0 -2
- package/dist/icons/checkmark_label.js.map +0 -1
- package/dist/icons/checkmark_label.mjs +0 -2
- package/dist/icons/checkmark_label.mjs.map +0 -1
- package/dist/icons/coupon.js +0 -2
- package/dist/icons/coupon.js.map +0 -1
- package/dist/icons/coupon.mjs +0 -2
- package/dist/icons/coupon.mjs.map +0 -1
- package/dist/icons/cross_label.js +0 -2
- package/dist/icons/cross_label.js.map +0 -1
- package/dist/icons/cross_label.mjs +0 -2
- package/dist/icons/cross_label.mjs.map +0 -1
- package/dist/icons/info.js +0 -2
- package/dist/icons/info.js.map +0 -1
- package/dist/icons/info.mjs +0 -2
- package/dist/icons/info.mjs.map +0 -1
- package/dist/icons/info_label.js +0 -2
- package/dist/icons/info_label.js.map +0 -1
- package/dist/icons/info_label.mjs +0 -2
- package/dist/icons/info_label.mjs.map +0 -1
- package/dist/icons/mail_label.js +0 -2
- package/dist/icons/mail_label.js.map +0 -1
- package/dist/icons/mail_label.mjs +0 -2
- package/dist/icons/mail_label.mjs.map +0 -1
- package/dist/icons/plus_label.js +0 -2
- package/dist/icons/plus_label.js.map +0 -1
- package/dist/icons/plus_label.mjs +0 -2
- package/dist/icons/plus_label.mjs.map +0 -1
- package/dist/icons/questionmark.js +0 -2
- package/dist/icons/questionmark.js.map +0 -1
- package/dist/icons/questionmark.mjs +0 -2
- package/dist/icons/questionmark.mjs.map +0 -1
- package/dist/icons/quotation_label.js +0 -2
- package/dist/icons/quotation_label.js.map +0 -1
- package/dist/icons/quotation_label.mjs +0 -2
- package/dist/icons/quotation_label.mjs.map +0 -1
- package/dist/icons/tel_label.js +0 -2
- package/dist/icons/tel_label.js.map +0 -1
- package/dist/icons/tel_label.mjs +0 -2
- package/dist/icons/tel_label.mjs.map +0 -1
- package/dist/icons/undo_label.js +0 -2
- package/dist/icons/undo_label.js.map +0 -1
- package/dist/icons/undo_label.mjs +0 -2
- package/dist/icons/undo_label.mjs.map +0 -1
- package/dist/magicpill.css +0 -315
- package/dist/types/index.d.ts +0 -4
- package/dist/types/magicPill.d.mts +0 -50
- package/dist/types/magicPill.d.ts +0 -50
- package/dist/types/navbar.d.mts +0 -27
- package/dist/types/navbar.d.ts +0 -28
- package/dist/types/notification.d.mts +0 -140
- package/dist/types/notification.d.ts +0 -141
- package/dist/utils/handlers.d.mts +0 -20
- package/dist/utils/handlers.d.ts +0 -21
- package/dist/utils/handlers.js +0 -2
- package/dist/utils/handlers.js.map +0 -1
- package/dist/utils/handlers.mjs +0 -2
- package/dist/utils/handlers.mjs.map +0 -1
- package/dist/utils/icons.d.mts +0 -20
- package/dist/utils/icons.d.ts +0 -20
- package/dist/utils/icons.js +0 -2
- package/dist/utils/icons.js.map +0 -1
- package/dist/utils/icons.mjs +0 -2
- package/dist/utils/icons.mjs.map +0 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
let react = require("react");
|
|
2
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
3
|
+
|
|
4
|
+
// src/Pill/parts.tsx
|
|
5
|
+
/** The leading icon. Decorative (`aria-hidden`) unless you give it a `label`. */
|
|
6
|
+
const PillIcon = (0, react.forwardRef)(function PillIcon({ label, ...rest }, ref) {
|
|
7
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
8
|
+
...label ? {
|
|
9
|
+
role: "img",
|
|
10
|
+
"aria-label": label
|
|
11
|
+
} : { "aria-hidden": true },
|
|
12
|
+
...rest,
|
|
13
|
+
ref,
|
|
14
|
+
"data-mp": "icon"
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
/** The thin line between the icon and the message. */
|
|
18
|
+
const PillDivider = (0, react.forwardRef)(function PillDivider(props, ref) {
|
|
19
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
20
|
+
"aria-hidden": "true",
|
|
21
|
+
...props,
|
|
22
|
+
ref,
|
|
23
|
+
"data-mp": "divider"
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
/** The message, in the italic serif. Accepts any content. */
|
|
27
|
+
const PillMessage = (0, react.forwardRef)(function PillMessage(props, ref) {
|
|
28
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
29
|
+
...props,
|
|
30
|
+
ref,
|
|
31
|
+
"data-mp": "message"
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
/** A row (or a column, in a vertical pill) of actions. */
|
|
35
|
+
const PillActions = (0, react.forwardRef)(function PillActions(props, ref) {
|
|
36
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
37
|
+
...props,
|
|
38
|
+
ref,
|
|
39
|
+
"data-mp": "actions"
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
exports.PillActions = PillActions;
|
|
44
|
+
exports.PillDivider = PillDivider;
|
|
45
|
+
exports.PillIcon = PillIcon;
|
|
46
|
+
exports.PillMessage = PillMessage;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
// src/Pill/parts.tsx
|
|
5
|
+
/** The leading icon. Decorative (`aria-hidden`) unless you give it a `label`. */
|
|
6
|
+
const PillIcon = forwardRef(function PillIcon({ label, ...rest }, ref) {
|
|
7
|
+
return /* @__PURE__ */ jsx("span", {
|
|
8
|
+
...label ? {
|
|
9
|
+
role: "img",
|
|
10
|
+
"aria-label": label
|
|
11
|
+
} : { "aria-hidden": true },
|
|
12
|
+
...rest,
|
|
13
|
+
ref,
|
|
14
|
+
"data-mp": "icon"
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
/** The thin line between the icon and the message. */
|
|
18
|
+
const PillDivider = forwardRef(function PillDivider(props, ref) {
|
|
19
|
+
return /* @__PURE__ */ jsx("span", {
|
|
20
|
+
"aria-hidden": "true",
|
|
21
|
+
...props,
|
|
22
|
+
ref,
|
|
23
|
+
"data-mp": "divider"
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
/** The message, in the italic serif. Accepts any content. */
|
|
27
|
+
const PillMessage = forwardRef(function PillMessage(props, ref) {
|
|
28
|
+
return /* @__PURE__ */ jsx("div", {
|
|
29
|
+
...props,
|
|
30
|
+
ref,
|
|
31
|
+
"data-mp": "message"
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
/** A row (or a column, in a vertical pill) of actions. */
|
|
35
|
+
const PillActions = forwardRef(function PillActions(props, ref) {
|
|
36
|
+
return /* @__PURE__ */ jsx("div", {
|
|
37
|
+
...props,
|
|
38
|
+
ref,
|
|
39
|
+
"data-mp": "actions"
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export { PillActions, PillDivider, PillIcon, PillMessage };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { AnchorHTMLAttributes, ComponentPropsWithoutRef, ComponentType, ReactNode, Ref } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* How much room the pill takes. The pill animates between levels.
|
|
4
|
+
* - `hidden`: not shown, and out of the accessibility tree
|
|
5
|
+
* - `rest`: a circle showing only the leading icon
|
|
6
|
+
* - `compact`: the pill; actions show their icon only
|
|
7
|
+
* - `expanded`: the pill; every action shows icon + label
|
|
8
|
+
* - `panel`: the pill grows into a panel showing its <PillPanel>
|
|
9
|
+
*/
|
|
10
|
+
export type PillPresence = "hidden" | "rest" | "compact" | "expanded" | "panel";
|
|
11
|
+
/**
|
|
12
|
+
* Where the pill sits.
|
|
13
|
+
* - Edges are `position: fixed`; `start`/`end` follow the text direction.
|
|
14
|
+
* - `inline` stays in the normal page flow.
|
|
15
|
+
* - `overlay` is a modal: a native <dialog> opened with showModal().
|
|
16
|
+
*/
|
|
17
|
+
export type PillPlacement = "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "right" | "inline" | "overlay";
|
|
18
|
+
/** Defaults to `vertical` for `left`/`right`, `horizontal` everywhere else. */
|
|
19
|
+
export type PillOrientation = "horizontal" | "vertical";
|
|
20
|
+
/**
|
|
21
|
+
* Colour scheme. Any other string is written to `data-variant` so you can
|
|
22
|
+
* define your own: `[data-mp="pill"][data-variant="brand"] { --mp-surface: … }`.
|
|
23
|
+
*/
|
|
24
|
+
export type PillVariant = "neutral" | "success" | "danger" | (string & {});
|
|
25
|
+
/**
|
|
26
|
+
* A component that renders a link from an `href`, such as Next's `Link`.
|
|
27
|
+
* React Router's `Link` takes `to`: wrap it.
|
|
28
|
+
*/
|
|
29
|
+
export type LinkComponent = ComponentType<AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
30
|
+
href: string;
|
|
31
|
+
ref?: Ref<HTMLAnchorElement>;
|
|
32
|
+
}>;
|
|
33
|
+
export interface PillProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
|
|
34
|
+
children?: ReactNode;
|
|
35
|
+
/** Controlled presence. */
|
|
36
|
+
presence?: PillPresence;
|
|
37
|
+
/** Uncontrolled initial presence. Default `compact`. */
|
|
38
|
+
defaultPresence?: PillPresence;
|
|
39
|
+
/** Called when the pill asks to change level (panel trigger, close button, Escape). */
|
|
40
|
+
onPresenceChange?: (presence: PillPresence) => void;
|
|
41
|
+
/** Default `inline`. */
|
|
42
|
+
placement?: PillPlacement;
|
|
43
|
+
orientation?: PillOrientation;
|
|
44
|
+
/** Default `neutral`. */
|
|
45
|
+
variant?: PillVariant;
|
|
46
|
+
/** Keeps the behaviour and the data attributes, drops the visual styles. */
|
|
47
|
+
unstyled?: boolean;
|
|
48
|
+
}
|
|
49
|
+
interface PillActionBase {
|
|
50
|
+
/** Shown at every level. */
|
|
51
|
+
icon?: ReactNode;
|
|
52
|
+
/**
|
|
53
|
+
* Always required: it's the accessible name when only the icon shows.
|
|
54
|
+
* Visible on hover and focus, when `aria-current`/`expanded` is set, or at
|
|
55
|
+
* the `expanded` and `panel` levels.
|
|
56
|
+
*/
|
|
57
|
+
label: string;
|
|
58
|
+
/** Force the label to show. */
|
|
59
|
+
expanded?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/** An action that runs code: renders a <button>. */
|
|
62
|
+
export interface PillButtonActionProps extends PillActionBase, Omit<ComponentPropsWithoutRef<"button">, "children"> {
|
|
63
|
+
href?: undefined;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* An action that navigates: renders `linkComponent` (default <a>).
|
|
67
|
+
* Only relative, `http(s):`, `mailto:` and `tel:` URLs are rendered.
|
|
68
|
+
*/
|
|
69
|
+
export interface PillLinkActionProps extends PillActionBase, Omit<ComponentPropsWithoutRef<"a">, "children" | "href"> {
|
|
70
|
+
href: string;
|
|
71
|
+
linkComponent?: LinkComponent;
|
|
72
|
+
}
|
|
73
|
+
export type PillActionProps = PillButtonActionProps | PillLinkActionProps;
|
|
74
|
+
export interface PillPanelProps extends Omit<ComponentPropsWithoutRef<"div">, "title"> {
|
|
75
|
+
title?: ReactNode;
|
|
76
|
+
/** Default "Close". */
|
|
77
|
+
closeLabel?: string;
|
|
78
|
+
/** Default <CloseIcon />. */
|
|
79
|
+
closeIcon?: ReactNode;
|
|
80
|
+
}
|
|
81
|
+
export interface PillContextValue {
|
|
82
|
+
presence: PillPresence;
|
|
83
|
+
setPresence: (presence: PillPresence) => void;
|
|
84
|
+
placement: PillPlacement;
|
|
85
|
+
orientation: PillOrientation;
|
|
86
|
+
variant: PillVariant;
|
|
87
|
+
}
|
|
88
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { AnchorHTMLAttributes, ComponentPropsWithoutRef, ComponentType, ReactNode, Ref } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* How much room the pill takes. The pill animates between levels.
|
|
4
|
+
* - `hidden`: not shown, and out of the accessibility tree
|
|
5
|
+
* - `rest`: a circle showing only the leading icon
|
|
6
|
+
* - `compact`: the pill; actions show their icon only
|
|
7
|
+
* - `expanded`: the pill; every action shows icon + label
|
|
8
|
+
* - `panel`: the pill grows into a panel showing its <PillPanel>
|
|
9
|
+
*/
|
|
10
|
+
export type PillPresence = "hidden" | "rest" | "compact" | "expanded" | "panel";
|
|
11
|
+
/**
|
|
12
|
+
* Where the pill sits.
|
|
13
|
+
* - Edges are `position: fixed`; `start`/`end` follow the text direction.
|
|
14
|
+
* - `inline` stays in the normal page flow.
|
|
15
|
+
* - `overlay` is a modal: a native <dialog> opened with showModal().
|
|
16
|
+
*/
|
|
17
|
+
export type PillPlacement = "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "right" | "inline" | "overlay";
|
|
18
|
+
/** Defaults to `vertical` for `left`/`right`, `horizontal` everywhere else. */
|
|
19
|
+
export type PillOrientation = "horizontal" | "vertical";
|
|
20
|
+
/**
|
|
21
|
+
* Colour scheme. Any other string is written to `data-variant` so you can
|
|
22
|
+
* define your own: `[data-mp="pill"][data-variant="brand"] { --mp-surface: … }`.
|
|
23
|
+
*/
|
|
24
|
+
export type PillVariant = "neutral" | "success" | "danger" | (string & {});
|
|
25
|
+
/**
|
|
26
|
+
* A component that renders a link from an `href`, such as Next's `Link`.
|
|
27
|
+
* React Router's `Link` takes `to`: wrap it.
|
|
28
|
+
*/
|
|
29
|
+
export type LinkComponent = ComponentType<AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
30
|
+
href: string;
|
|
31
|
+
ref?: Ref<HTMLAnchorElement>;
|
|
32
|
+
}>;
|
|
33
|
+
export interface PillProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
|
|
34
|
+
children?: ReactNode;
|
|
35
|
+
/** Controlled presence. */
|
|
36
|
+
presence?: PillPresence;
|
|
37
|
+
/** Uncontrolled initial presence. Default `compact`. */
|
|
38
|
+
defaultPresence?: PillPresence;
|
|
39
|
+
/** Called when the pill asks to change level (panel trigger, close button, Escape). */
|
|
40
|
+
onPresenceChange?: (presence: PillPresence) => void;
|
|
41
|
+
/** Default `inline`. */
|
|
42
|
+
placement?: PillPlacement;
|
|
43
|
+
orientation?: PillOrientation;
|
|
44
|
+
/** Default `neutral`. */
|
|
45
|
+
variant?: PillVariant;
|
|
46
|
+
/** Keeps the behaviour and the data attributes, drops the visual styles. */
|
|
47
|
+
unstyled?: boolean;
|
|
48
|
+
}
|
|
49
|
+
interface PillActionBase {
|
|
50
|
+
/** Shown at every level. */
|
|
51
|
+
icon?: ReactNode;
|
|
52
|
+
/**
|
|
53
|
+
* Always required: it's the accessible name when only the icon shows.
|
|
54
|
+
* Visible on hover and focus, when `aria-current`/`expanded` is set, or at
|
|
55
|
+
* the `expanded` and `panel` levels.
|
|
56
|
+
*/
|
|
57
|
+
label: string;
|
|
58
|
+
/** Force the label to show. */
|
|
59
|
+
expanded?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/** An action that runs code: renders a <button>. */
|
|
62
|
+
export interface PillButtonActionProps extends PillActionBase, Omit<ComponentPropsWithoutRef<"button">, "children"> {
|
|
63
|
+
href?: undefined;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* An action that navigates: renders `linkComponent` (default <a>).
|
|
67
|
+
* Only relative, `http(s):`, `mailto:` and `tel:` URLs are rendered.
|
|
68
|
+
*/
|
|
69
|
+
export interface PillLinkActionProps extends PillActionBase, Omit<ComponentPropsWithoutRef<"a">, "children" | "href"> {
|
|
70
|
+
href: string;
|
|
71
|
+
linkComponent?: LinkComponent;
|
|
72
|
+
}
|
|
73
|
+
export type PillActionProps = PillButtonActionProps | PillLinkActionProps;
|
|
74
|
+
export interface PillPanelProps extends Omit<ComponentPropsWithoutRef<"div">, "title"> {
|
|
75
|
+
title?: ReactNode;
|
|
76
|
+
/** Default "Close". */
|
|
77
|
+
closeLabel?: string;
|
|
78
|
+
/** Default <CloseIcon />. */
|
|
79
|
+
closeIcon?: ReactNode;
|
|
80
|
+
}
|
|
81
|
+
export interface PillContextValue {
|
|
82
|
+
presence: PillPresence;
|
|
83
|
+
setPresence: (presence: PillPresence) => void;
|
|
84
|
+
placement: PillPlacement;
|
|
85
|
+
orientation: PillOrientation;
|
|
86
|
+
variant: PillVariant;
|
|
87
|
+
}
|
|
88
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { LinkComponent } from "../Pill/types.mjs";
|
|
3
|
+
import { NavMatch } from "./matchPath.mjs";
|
|
4
|
+
export interface NavItem {
|
|
5
|
+
href: string;
|
|
6
|
+
label: string;
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* How the item matches the current `pathname`. Default `prefix`, on whole
|
|
10
|
+
* path segments (`/blog` matches `/blog/post`, not `/blogroll`); `/` is
|
|
11
|
+
* always exact. The longest match wins, so only one item is active.
|
|
12
|
+
*/
|
|
13
|
+
match?: NavMatch;
|
|
14
|
+
}
|
|
15
|
+
export interface PillNavbarProps extends Omit<ComponentPropsWithoutRef<"nav">, "children"> {
|
|
16
|
+
items: readonly NavItem[];
|
|
17
|
+
/**
|
|
18
|
+
* The current path, e.g. Next's `usePathname()`. Without it, the navbar
|
|
19
|
+
* reads `window.location.pathname` after mounting and on `popstate`, which
|
|
20
|
+
* misses client-side navigations.
|
|
21
|
+
*/
|
|
22
|
+
pathname?: string;
|
|
23
|
+
linkComponent?: LinkComponent;
|
|
24
|
+
/** Default "Main". */
|
|
25
|
+
"aria-label"?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A <nav> of icon links. The active one shows its label and gets
|
|
29
|
+
* `aria-current="page"`. Render it inside a <Pill>, or as the base layer of a <MagicPill>.
|
|
30
|
+
*/
|
|
31
|
+
export declare const PillNavbar: import("react").ForwardRefExoticComponent<PillNavbarProps & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { LinkComponent } from "../Pill/types.js";
|
|
3
|
+
import { NavMatch } from "./matchPath.js";
|
|
4
|
+
export interface NavItem {
|
|
5
|
+
href: string;
|
|
6
|
+
label: string;
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* How the item matches the current `pathname`. Default `prefix`, on whole
|
|
10
|
+
* path segments (`/blog` matches `/blog/post`, not `/blogroll`); `/` is
|
|
11
|
+
* always exact. The longest match wins, so only one item is active.
|
|
12
|
+
*/
|
|
13
|
+
match?: NavMatch;
|
|
14
|
+
}
|
|
15
|
+
export interface PillNavbarProps extends Omit<ComponentPropsWithoutRef<"nav">, "children"> {
|
|
16
|
+
items: readonly NavItem[];
|
|
17
|
+
/**
|
|
18
|
+
* The current path, e.g. Next's `usePathname()`. Without it, the navbar
|
|
19
|
+
* reads `window.location.pathname` after mounting and on `popstate`, which
|
|
20
|
+
* misses client-side navigations.
|
|
21
|
+
*/
|
|
22
|
+
pathname?: string;
|
|
23
|
+
linkComponent?: LinkComponent;
|
|
24
|
+
/** Default "Main". */
|
|
25
|
+
"aria-label"?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A <nav> of icon links. The active one shows its label and gets
|
|
29
|
+
* `aria-current="page"`. Render it inside a <Pill>, or as the base layer of a <MagicPill>.
|
|
30
|
+
*/
|
|
31
|
+
export declare const PillNavbar: import("react").ForwardRefExoticComponent<PillNavbarProps & import("react").RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
let react = require("react");
|
|
4
|
+
const require_parts = require("../Pill/parts.js");
|
|
5
|
+
const require_PillAction = require("../Pill/PillAction.js");
|
|
6
|
+
const require_matchPath = require("./matchPath.js");
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
|
|
9
|
+
// src/PillNavbar/PillNavbar.tsx
|
|
10
|
+
/** Without a `pathname` prop: the browser's path, read after mounting (no hydration mismatch). */
|
|
11
|
+
function useLocationPathname(enabled) {
|
|
12
|
+
const [pathname, setPathname] = (0, react.useState)(void 0);
|
|
13
|
+
(0, react.useEffect)(() => {
|
|
14
|
+
if (!enabled) return;
|
|
15
|
+
const update = () => setPathname(window.location.pathname);
|
|
16
|
+
update();
|
|
17
|
+
window.addEventListener("popstate", update);
|
|
18
|
+
return () => window.removeEventListener("popstate", update);
|
|
19
|
+
}, [enabled]);
|
|
20
|
+
return pathname;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A <nav> of icon links. The active one shows its label and gets
|
|
24
|
+
* `aria-current="page"`. Render it inside a <Pill>, or as the base layer of a <MagicPill>.
|
|
25
|
+
*/
|
|
26
|
+
const PillNavbar = (0, react.forwardRef)(function PillNavbar({ items, pathname, linkComponent, "aria-label": ariaLabel = "Main", ...rest }, ref) {
|
|
27
|
+
const locationPathname = useLocationPathname(pathname === void 0);
|
|
28
|
+
const activeIndex = require_matchPath.findActiveIndex(pathname ?? locationPathname, items);
|
|
29
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("nav", {
|
|
30
|
+
"aria-label": ariaLabel,
|
|
31
|
+
...rest,
|
|
32
|
+
ref,
|
|
33
|
+
"data-mp": "navbar",
|
|
34
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_parts.PillActions, { children: items.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillAction, {
|
|
35
|
+
icon: item.icon,
|
|
36
|
+
label: item.label,
|
|
37
|
+
href: item.href,
|
|
38
|
+
linkComponent,
|
|
39
|
+
"aria-current": index === activeIndex ? "page" : void 0
|
|
40
|
+
}, item.href)) })
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
exports.PillNavbar = PillNavbar;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useEffect, useState } from "react";
|
|
4
|
+
import { PillActions } from "../Pill/parts.mjs";
|
|
5
|
+
import PillAction from "../Pill/PillAction.mjs";
|
|
6
|
+
import { findActiveIndex } from "./matchPath.mjs";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
|
|
9
|
+
// src/PillNavbar/PillNavbar.tsx
|
|
10
|
+
/** Without a `pathname` prop: the browser's path, read after mounting (no hydration mismatch). */
|
|
11
|
+
function useLocationPathname(enabled) {
|
|
12
|
+
const [pathname, setPathname] = useState(void 0);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (!enabled) return;
|
|
15
|
+
const update = () => setPathname(window.location.pathname);
|
|
16
|
+
update();
|
|
17
|
+
window.addEventListener("popstate", update);
|
|
18
|
+
return () => window.removeEventListener("popstate", update);
|
|
19
|
+
}, [enabled]);
|
|
20
|
+
return pathname;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A <nav> of icon links. The active one shows its label and gets
|
|
24
|
+
* `aria-current="page"`. Render it inside a <Pill>, or as the base layer of a <MagicPill>.
|
|
25
|
+
*/
|
|
26
|
+
const PillNavbar = forwardRef(function PillNavbar({ items, pathname, linkComponent, "aria-label": ariaLabel = "Main", ...rest }, ref) {
|
|
27
|
+
const locationPathname = useLocationPathname(pathname === void 0);
|
|
28
|
+
const activeIndex = findActiveIndex(pathname ?? locationPathname, items);
|
|
29
|
+
return /* @__PURE__ */ jsx("nav", {
|
|
30
|
+
"aria-label": ariaLabel,
|
|
31
|
+
...rest,
|
|
32
|
+
ref,
|
|
33
|
+
"data-mp": "navbar",
|
|
34
|
+
children: /* @__PURE__ */ jsx(PillActions, { children: items.map((item, index) => /* @__PURE__ */ jsx(PillAction, {
|
|
35
|
+
icon: item.icon,
|
|
36
|
+
label: item.label,
|
|
37
|
+
href: item.href,
|
|
38
|
+
linkComponent,
|
|
39
|
+
"aria-current": index === activeIndex ? "page" : void 0
|
|
40
|
+
}, item.href)) })
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export { PillNavbar };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/PillNavbar/matchPath.ts
|
|
2
|
+
/** "/blog/?q=1#top" → "/blog": no query, no hash, no trailing slash (except the root). */
|
|
3
|
+
function normalisePath(path) {
|
|
4
|
+
const withoutSuffix = path.split(/[?#]/, 1)[0];
|
|
5
|
+
return withoutSuffix.length > 1 ? withoutSuffix.replace(/\/+$/, "") || "/" : withoutSuffix;
|
|
6
|
+
}
|
|
7
|
+
function matches(pathname, item) {
|
|
8
|
+
if (typeof item.match === "function") return item.match(pathname);
|
|
9
|
+
if (!item.href.startsWith("/") || item.href.startsWith("//")) return false;
|
|
10
|
+
const path = normalisePath(pathname);
|
|
11
|
+
const href = normalisePath(item.href);
|
|
12
|
+
if (item.match === "exact" || href === "/") return path === href;
|
|
13
|
+
return path === href || path.startsWith(`${href}/`);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The index of the active item, or -1. Several items can match ("/blog" and
|
|
17
|
+
* "/blog/drafts" on "/blog/drafts/1"): the longest href wins, so exactly one
|
|
18
|
+
* item is active.
|
|
19
|
+
*/
|
|
20
|
+
function findActiveIndex(pathname, items) {
|
|
21
|
+
if (pathname === void 0) return -1;
|
|
22
|
+
let activeIndex = -1;
|
|
23
|
+
let activeLength = -1;
|
|
24
|
+
items.forEach((item, index) => {
|
|
25
|
+
const length = normalisePath(item.href).length;
|
|
26
|
+
if (length > activeLength && matches(pathname, item)) {
|
|
27
|
+
activeIndex = index;
|
|
28
|
+
activeLength = length;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return activeIndex;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.findActiveIndex = findActiveIndex;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/PillNavbar/matchPath.ts
|
|
2
|
+
/** "/blog/?q=1#top" → "/blog": no query, no hash, no trailing slash (except the root). */
|
|
3
|
+
function normalisePath(path) {
|
|
4
|
+
const withoutSuffix = path.split(/[?#]/, 1)[0];
|
|
5
|
+
return withoutSuffix.length > 1 ? withoutSuffix.replace(/\/+$/, "") || "/" : withoutSuffix;
|
|
6
|
+
}
|
|
7
|
+
function matches(pathname, item) {
|
|
8
|
+
if (typeof item.match === "function") return item.match(pathname);
|
|
9
|
+
if (!item.href.startsWith("/") || item.href.startsWith("//")) return false;
|
|
10
|
+
const path = normalisePath(pathname);
|
|
11
|
+
const href = normalisePath(item.href);
|
|
12
|
+
if (item.match === "exact" || href === "/") return path === href;
|
|
13
|
+
return path === href || path.startsWith(`${href}/`);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The index of the active item, or -1. Several items can match ("/blog" and
|
|
17
|
+
* "/blog/drafts" on "/blog/drafts/1"): the longest href wins, so exactly one
|
|
18
|
+
* item is active.
|
|
19
|
+
*/
|
|
20
|
+
function findActiveIndex(pathname, items) {
|
|
21
|
+
if (pathname === void 0) return -1;
|
|
22
|
+
let activeIndex = -1;
|
|
23
|
+
let activeLength = -1;
|
|
24
|
+
items.forEach((item, index) => {
|
|
25
|
+
const length = normalisePath(item.href).length;
|
|
26
|
+
if (length > activeLength && matches(pathname, item)) {
|
|
27
|
+
activeIndex = index;
|
|
28
|
+
activeLength = length;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return activeIndex;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { findActiveIndex };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { MouseEvent, ReactNode } from "react";
|
|
2
|
+
import { LinkComponent } from "../Pill/types.mjs";
|
|
3
|
+
/** Same rules as the matching <PillAction> props. */
|
|
4
|
+
export type NotificationAction = {
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
label: string;
|
|
7
|
+
/**
|
|
8
|
+
* Inside a <MagicPill>, clicking an action dismisses the notification.
|
|
9
|
+
* Call `event.preventDefault()` to keep it open.
|
|
10
|
+
*/
|
|
11
|
+
onClick: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
12
|
+
href?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
icon?: ReactNode;
|
|
15
|
+
label: string;
|
|
16
|
+
href: string;
|
|
17
|
+
onClick?: undefined;
|
|
18
|
+
};
|
|
19
|
+
export interface NotificationPanel {
|
|
20
|
+
title?: ReactNode;
|
|
21
|
+
content: ReactNode;
|
|
22
|
+
/** The action that opens the panel. Default `{ icon: <PlusIcon />, label: "Learn more" }`. */
|
|
23
|
+
trigger?: {
|
|
24
|
+
icon?: ReactNode;
|
|
25
|
+
label: string;
|
|
26
|
+
};
|
|
27
|
+
/** Default "Close". */
|
|
28
|
+
closeLabel?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface PillNotificationClassNames {
|
|
31
|
+
icon?: string;
|
|
32
|
+
divider?: string;
|
|
33
|
+
message?: string;
|
|
34
|
+
actions?: string;
|
|
35
|
+
action?: string;
|
|
36
|
+
panel?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface PillNotificationProps {
|
|
39
|
+
icon?: ReactNode;
|
|
40
|
+
/** Any content: strings, emphasis, live data. Never parsed as HTML (L3). */
|
|
41
|
+
message: ReactNode;
|
|
42
|
+
action?: NotificationAction;
|
|
43
|
+
panel?: NotificationPanel;
|
|
44
|
+
linkComponent?: LinkComponent;
|
|
45
|
+
classNames?: PillNotificationClassNames;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Icon · divider · message · action, with an optional expandable panel.
|
|
49
|
+
* Render it inside a <Pill>, or let <MagicPill> render it for pill().notify().
|
|
50
|
+
*/
|
|
51
|
+
export declare const PillNotification: (props: PillNotificationProps) => ReactNode;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { MouseEvent, ReactNode } from "react";
|
|
2
|
+
import { LinkComponent } from "../Pill/types.js";
|
|
3
|
+
/** Same rules as the matching <PillAction> props. */
|
|
4
|
+
export type NotificationAction = {
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
label: string;
|
|
7
|
+
/**
|
|
8
|
+
* Inside a <MagicPill>, clicking an action dismisses the notification.
|
|
9
|
+
* Call `event.preventDefault()` to keep it open.
|
|
10
|
+
*/
|
|
11
|
+
onClick: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
12
|
+
href?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
icon?: ReactNode;
|
|
15
|
+
label: string;
|
|
16
|
+
href: string;
|
|
17
|
+
onClick?: undefined;
|
|
18
|
+
};
|
|
19
|
+
export interface NotificationPanel {
|
|
20
|
+
title?: ReactNode;
|
|
21
|
+
content: ReactNode;
|
|
22
|
+
/** The action that opens the panel. Default `{ icon: <PlusIcon />, label: "Learn more" }`. */
|
|
23
|
+
trigger?: {
|
|
24
|
+
icon?: ReactNode;
|
|
25
|
+
label: string;
|
|
26
|
+
};
|
|
27
|
+
/** Default "Close". */
|
|
28
|
+
closeLabel?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface PillNotificationClassNames {
|
|
31
|
+
icon?: string;
|
|
32
|
+
divider?: string;
|
|
33
|
+
message?: string;
|
|
34
|
+
actions?: string;
|
|
35
|
+
action?: string;
|
|
36
|
+
panel?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface PillNotificationProps {
|
|
39
|
+
icon?: ReactNode;
|
|
40
|
+
/** Any content: strings, emphasis, live data. Never parsed as HTML (L3). */
|
|
41
|
+
message: ReactNode;
|
|
42
|
+
action?: NotificationAction;
|
|
43
|
+
panel?: NotificationPanel;
|
|
44
|
+
linkComponent?: LinkComponent;
|
|
45
|
+
classNames?: PillNotificationClassNames;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Icon · divider · message · action, with an optional expandable panel.
|
|
49
|
+
* Render it inside a <Pill>, or let <MagicPill> render it for pill().notify().
|
|
50
|
+
*/
|
|
51
|
+
export declare const PillNotification: (props: PillNotificationProps) => ReactNode;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const require_parts = require("../Pill/parts.js");
|
|
2
|
+
const require_PillAction = require("../Pill/PillAction.js");
|
|
3
|
+
const require_PillPanel = require("../Pill/PillPanel.js");
|
|
4
|
+
const require_PlusIcon = require("../icons/PlusIcon.js");
|
|
5
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
|
+
|
|
7
|
+
// src/PillNotification/PillNotification.tsx
|
|
8
|
+
/** The implementation, with the host-only `onAction` hook. */
|
|
9
|
+
function NotificationContent({ icon, message, action, panel, linkComponent, classNames = {}, onAction }) {
|
|
10
|
+
const hasIcon = icon !== void 0 && icon !== null;
|
|
11
|
+
const renderAction = (notificationAction) => {
|
|
12
|
+
const { icon: actionIcon, label } = notificationAction;
|
|
13
|
+
if (notificationAction.href !== void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillAction, {
|
|
14
|
+
icon: actionIcon,
|
|
15
|
+
label,
|
|
16
|
+
href: notificationAction.href,
|
|
17
|
+
linkComponent,
|
|
18
|
+
className: classNames.action,
|
|
19
|
+
onClick: onAction
|
|
20
|
+
});
|
|
21
|
+
const { onClick } = notificationAction;
|
|
22
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillAction, {
|
|
23
|
+
icon: actionIcon,
|
|
24
|
+
label,
|
|
25
|
+
className: classNames.action,
|
|
26
|
+
onClick: (event) => {
|
|
27
|
+
onClick(event);
|
|
28
|
+
onAction?.(event);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
33
|
+
hasIcon && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_parts.PillIcon, {
|
|
34
|
+
className: classNames.icon,
|
|
35
|
+
children: icon
|
|
36
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_parts.PillDivider, { className: classNames.divider })] }),
|
|
37
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_parts.PillMessage, {
|
|
38
|
+
className: classNames.message,
|
|
39
|
+
children: message
|
|
40
|
+
}),
|
|
41
|
+
(action || panel) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_parts.PillActions, {
|
|
42
|
+
className: classNames.actions,
|
|
43
|
+
children: [action && renderAction(action), panel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillPanel.PillPanelTrigger, {
|
|
44
|
+
icon: panel.trigger ? panel.trigger.icon : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PlusIcon, {}),
|
|
45
|
+
label: panel.trigger?.label ?? "Learn more",
|
|
46
|
+
className: classNames.action
|
|
47
|
+
})]
|
|
48
|
+
}),
|
|
49
|
+
panel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PillPanel.PillPanel, {
|
|
50
|
+
title: panel.title,
|
|
51
|
+
closeLabel: panel.closeLabel,
|
|
52
|
+
className: classNames.panel,
|
|
53
|
+
children: panel.content
|
|
54
|
+
})
|
|
55
|
+
] });
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Icon · divider · message · action, with an optional expandable panel.
|
|
59
|
+
* Render it inside a <Pill>, or let <MagicPill> render it for pill().notify().
|
|
60
|
+
*/
|
|
61
|
+
const PillNotification = NotificationContent;
|
|
62
|
+
|
|
63
|
+
exports.NotificationContent = NotificationContent;
|
|
64
|
+
exports.PillNotification = PillNotification;
|