@ada-cx/lovelace 1.13.0 → 1.14.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 (60) hide show
  1. package/dist/components/Banner/Banner.css.d.ts +19 -1
  2. package/dist/components/Banner/Banner.css.js +12 -2
  3. package/dist/components/Banner/Banner.css.js.map +1 -1
  4. package/dist/components/Banner/Banner.d.ts +22 -40
  5. package/dist/components/Banner/Banner.js +22 -19
  6. package/dist/components/Banner/Banner.js.map +1 -1
  7. package/dist/components/Banner/BannerContainer.d.ts +35 -0
  8. package/dist/components/Banner/BannerContainer.js +38 -0
  9. package/dist/components/Banner/BannerContainer.js.map +1 -0
  10. package/dist/components/Banner/BannerContainerSlide.d.ts +15 -0
  11. package/dist/components/Banner/BannerContainerSlide.js +26 -0
  12. package/dist/components/Banner/BannerContainerSlide.js.map +1 -0
  13. package/dist/components/Banner/index.d.ts +2 -1
  14. package/dist/components/Icon/icons/CheckmarkCircle.d.ts +2 -0
  15. package/dist/components/Icon/icons/CheckmarkCircle.js +14 -0
  16. package/dist/components/Icon/icons/CheckmarkCircle.js.map +1 -0
  17. package/dist/components/Icon/icons/index.d.ts +1 -0
  18. package/dist/components/Toast/Toast.css.d.ts +36 -0
  19. package/dist/components/Toast/Toast.css.js +19 -0
  20. package/dist/components/Toast/Toast.css.js.map +1 -0
  21. package/dist/components/Toast/Toast.d.ts +52 -0
  22. package/dist/components/Toast/Toast.js +59 -0
  23. package/dist/components/Toast/Toast.js.map +1 -0
  24. package/dist/components/Toast/ToastContainer.d.ts +48 -0
  25. package/dist/components/Toast/ToastContainer.js +104 -0
  26. package/dist/components/Toast/ToastContainer.js.map +1 -0
  27. package/dist/components/{ToastRegion/ToastContent.d.ts → Toast/ToastItem.d.ts} +7 -2
  28. package/dist/components/Toast/index.d.ts +6 -0
  29. package/dist/components/{ToastRegion → Toast}/index.js +2 -1
  30. package/dist/hooks/index.d.ts +1 -1
  31. package/dist/index.d.ts +1 -2
  32. package/dist/index.js +69 -67
  33. package/dist/style.css +1 -1
  34. package/dist/utils/animation.d.ts +0 -16
  35. package/dist/utils/animation.js +24 -50
  36. package/dist/utils/animation.js.map +1 -1
  37. package/package.json +2 -2
  38. package/dist/components/Banner/BannerSurface.d.ts +0 -17
  39. package/dist/components/Banner/BannerSurface.js +0 -65
  40. package/dist/components/Banner/BannerSurface.js.map +0 -1
  41. package/dist/components/ToastNotification/ToastNotification.css.d.ts +0 -17
  42. package/dist/components/ToastNotification/ToastNotification.css.js +0 -17
  43. package/dist/components/ToastNotification/ToastNotification.css.js.map +0 -1
  44. package/dist/components/ToastNotification/ToastNotification.d.ts +0 -55
  45. package/dist/components/ToastNotification/ToastNotification.js +0 -42
  46. package/dist/components/ToastNotification/ToastNotification.js.map +0 -1
  47. package/dist/components/ToastNotification/index.d.ts +0 -2
  48. package/dist/components/ToastRegion/ToastRegion.css.d.ts +0 -2
  49. package/dist/components/ToastRegion/ToastRegion.css.js +0 -7
  50. package/dist/components/ToastRegion/ToastRegion.css.js.map +0 -1
  51. package/dist/components/ToastRegion/ToastRegion.d.ts +0 -45
  52. package/dist/components/ToastRegion/ToastRegion.js +0 -38
  53. package/dist/components/ToastRegion/ToastRegion.js.map +0 -1
  54. package/dist/components/ToastRegion/ToastRegionItem.d.ts +0 -13
  55. package/dist/components/ToastRegion/ToastRegionItem.js +0 -49
  56. package/dist/components/ToastRegion/ToastRegionItem.js.map +0 -1
  57. package/dist/components/ToastRegion/ToastRegionLandmark.d.ts +0 -15
  58. package/dist/components/ToastRegion/ToastRegionLandmark.js +0 -62
  59. package/dist/components/ToastRegion/ToastRegionLandmark.js.map +0 -1
  60. package/dist/components/ToastRegion/index.d.ts +0 -4
@@ -1 +1,19 @@
1
- export declare const bannerSurface: string;
1
+ export declare const bannerRoot: import("@vanilla-extract/recipes").RuntimeFn<{
2
+ status: {
3
+ success: {
4
+ backgroundColor: "var(--lovelace-color-background-success-light)";
5
+ color: "var(--lovelace-color-content-success)";
6
+ };
7
+ warning: {
8
+ backgroundColor: "var(--lovelace-color-background-warning-light)";
9
+ color: "var(--lovelace-color-content-warning)";
10
+ };
11
+ error: {
12
+ backgroundColor: "var(--lovelace-color-background-destructive-light)";
13
+ color: "var(--lovelace-color-content-destructive)";
14
+ };
15
+ };
16
+ }>;
17
+ export declare const bannerMessage: string;
18
+ export declare const bannerContainer: string;
19
+ export declare const bannerContainerSlide: string;
@@ -1,7 +1,17 @@
1
+ import { createRuntimeFn as e } from "../../vendor/@vanilla-extract/recipes/dist/createRuntimeFn-62c9670f.esm.js";
1
2
  /* empty css */
2
3
  //#region src/components/Banner/Banner.css.ts
3
- var e = "fpbgjm0";
4
+ var t = e({
5
+ defaultClassName: "fpbgjm1 fpbgjm0",
6
+ variantClassNames: { status: {
7
+ success: "fpbgjm2",
8
+ warning: "fpbgjm3",
9
+ error: "fpbgjm4"
10
+ } },
11
+ defaultVariants: { status: "success" },
12
+ compoundVariants: []
13
+ }), n = "fpbgjm5", r = "fpbgjm6", i = "fpbgjm7";
4
14
  //#endregion
5
- export { e as bannerSurface };
15
+ export { r as bannerContainer, i as bannerContainerSlide, n as bannerMessage, t as bannerRoot };
6
16
 
7
17
  //# sourceMappingURL=Banner.css.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Banner.css.js","names":[],"sources":["../../../src/components/Banner/Banner.css.ts"],"sourcesContent":["import { style } from \"@vanilla-extract/css\";\nimport { t } from \"../../tokens/index.js\";\n\n// Typed as a plain string: `t()` returns a union of every token name, and a\n// two-property template literal over two of them explodes past what tsc can\n// represent.\nconst surfaceTransition: string = `transform ${t(\"duration-medium\")} ${t(\n\t\"easing-standard\",\n)}, height ${t(\"duration-medium\")} ${t(\"easing-standard\")}, opacity ${t(\n\t\"duration-fast\",\n)} ${t(\"easing-standard\")}`;\n\n// Arrives and leaves by animating its own height, with the message held against\n// the bottom edge so it slides while the box grows or shrinks around it. The two\n// have to move together: a box that holds its full height for the whole travel\n// pushes whatever is below it a full height at once and then leaves it staring at\n// a gap until the message catches up.\nexport const bannerSurface = style({\n\tposition: \"relative\",\n\tdisplay: \"flex\",\n\talignItems: \"flex-end\",\n\toverflow: \"hidden\",\n\tselectors: {\n\t\t// Also translated on the way out, so the message clears the edge above it\n\t\t// rather than only being clipped away.\n\t\t\"&[data-exiting]\": { transform: \"translateY(-100%)\" },\n\t\t// One condition replacing another is a change of message on the same slot,\n\t\t// so the surface fades through the change instead of sliding. Sliding would\n\t\t// report a condition leaving and another arriving, which is not what the\n\t\t// chatter's situation did.\n\t\t\"&[data-swapping]\": { opacity: 0 },\n\t},\n\t\"@media\": {\n\t\t\"(prefers-reduced-motion: no-preference)\": {\n\t\t\ttransition: surfaceTransition,\n\t\t},\n\t},\n});\n"],"mappings":""}
1
+ {"version":3,"file":"Banner.css.js","names":[],"sources":["../../../src/components/Banner/Banner.css.ts"],"sourcesContent":["import { globalStyle, style } from \"@vanilla-extract/css\";\nimport { recipe } from \"@vanilla-extract/recipes\";\nimport { t } from \"../../tokens/index.js\";\n\nconst bannerBase = style({\n\tdisplay: \"flex\",\n\tgap: t(\"gap-8\"),\n\talignItems: \"center\",\n\tjustifyContent: \"center\",\n\tboxSizing: \"border-box\",\n\twidth: \"100%\",\n\tpaddingInline: t(\"padding-12\"),\n\tpaddingBlock: t(\"padding-8\"),\n\tfontFamily: t(\"font-family-body\"),\n\tfontWeight: t(\"font-weight-medium\"),\n\tfontSize: t(\"font-size-body\"),\n\tlineHeight: t(\"line-height-body\"),\n\toverflowWrap: \"break-word\",\n});\n\nexport const bannerRoot = recipe({\n\tbase: bannerBase,\n\tvariants: {\n\t\tstatus: {\n\t\t\tsuccess: {\n\t\t\t\tbackgroundColor: t(\"color-background-success-light\"),\n\t\t\t\tcolor: t(\"color-content-success\"),\n\t\t\t},\n\t\t\twarning: {\n\t\t\t\tbackgroundColor: t(\"color-background-warning-light\"),\n\t\t\t\tcolor: t(\"color-content-warning\"),\n\t\t\t},\n\t\t\terror: {\n\t\t\t\tbackgroundColor: t(\"color-background-destructive-light\"),\n\t\t\t\tcolor: t(\"color-content-destructive\"),\n\t\t\t},\n\t\t},\n\t},\n\tdefaultVariants: {\n\t\tstatus: \"success\",\n\t},\n});\n\n// Shrinks to its text rather than filling the row, so a message that fits sits\n// in a cluster the row centres. One that does not fill takes the width that is\n// left and wraps against its own leading edge, which is the multi-line variant.\nexport const bannerMessage = style({\n\tminWidth: 0,\n});\n\nglobalStyle(`${bannerBase} > [data-slot='icon']`, {\n\tfontSize: t(\"icon-size-control\"),\n\tflexShrink: 0,\n});\n\n// Clips the banner's travel. The banner slides in and out of the container's\n// leading edge, so whatever the container is anchored to needs no offset that\n// has to track the chrome above it.\nexport const bannerContainer = style({\n\toverflow: \"hidden\",\n});\n\n// Typed as a plain string: `t()` returns a union of every token name, and a\n// two-property template literal over two of them explodes past what tsc can\n// represent.\nconst slideTransition: string = `transform ${t(\"duration-medium\")} ${t(\n\t\"easing-standard\",\n)}, opacity ${t(\"duration-fast\")} ${t(\"easing-standard\")}`;\n\nexport const bannerContainerSlide = style({\n\tselectors: {\n\t\t\"&[data-entering]\": { transform: \"translateY(-100%)\" },\n\t\t\"&[data-exiting]\": { transform: \"translateY(-100%)\" },\n\t\t// One condition replacing another is a change of message on the same slot,\n\t\t// so the banner fades through the change instead of sliding. Sliding would\n\t\t// report a condition leaving and another arriving, which is not what the\n\t\t// chatter's situation did.\n\t\t\"&[data-swapping]\": { opacity: 0 },\n\t},\n\t\"@media\": {\n\t\t\"(prefers-reduced-motion: no-preference)\": {\n\t\t\ttransition: slideTransition,\n\t\t},\n\t},\n});\n"],"mappings":""}
@@ -1,51 +1,33 @@
1
- import type { CSSProperties, Ref } from "react";
2
- import type { ToastStatus } from "../ToastNotification/ToastNotification.js";
1
+ import type { CSSProperties, ReactNode, Ref } from "react";
2
+ export type BannerStatus = "success" | "warning" | "error";
3
3
  export interface BannerProps {
4
4
  /**
5
- * The condition to report. Text, not nodes: the surface fades through a change
6
- * of message, and it can only tell one message from another by comparing them.
5
+ * The outcome being reported. It selects the background and content color
6
+ * pair, and the urgency `BannerContainer` announces it with. Bind it to the
7
+ * result of the action, not the UI.
7
8
  */
8
- message: string;
9
- /**
10
- * The outcome being reported. Also picks the urgency: `error` interrupts as an
11
- * assertive `alert`, anything else waits its turn as a polite `status`.
12
- */
13
- status?: ToastStatus;
14
- /** Whether the condition currently holds. */
15
- visible: boolean;
16
- /**
17
- * A counter that advances whenever the condition is reported again. Pass it for
18
- * a condition that can repeat with the same wording: without it the second
19
- * report changes nothing in the live region, so a reader never hears it.
20
- */
21
- revision?: number;
22
- /**
23
- * Runs when the reader presses dismiss, and renders the button. Clear the state
24
- * behind `visible` here, or the next change to that state raises the banner
25
- * again. Omit it for a condition the reader cannot act on.
26
- */
27
- onDismiss?: () => void;
28
- /** Accessible name for the dismiss button. Localize it. */
29
- dismissLabel?: string;
9
+ status?: BannerStatus;
30
10
  className?: string;
31
11
  style?: CSSProperties;
32
12
  ref?: Ref<HTMLDivElement>;
13
+ /**
14
+ * The message to display. A status icon is rendered automatically, so the
15
+ * status is conveyed without color perception; for screen-reader users the
16
+ * icon is decorative, so include the status in the copy when the message
17
+ * alone wouldn't make the outcome clear.
18
+ */
19
+ children?: ReactNode;
33
20
  }
34
21
  /**
35
- * Reports a condition for as long as it holds — an outage, a lost connection, a
36
- * failed send. It never queues and never times out, so nothing transient can push
37
- * it out of view and the message is still there when the reader reaches for it.
38
- *
39
- * Pass `onDismiss` only when the reader is meant to act on the condition; a banner
40
- * bound purely to state offers no control, because only that state takes it down.
41
- * Either way, read a durable field, never one a dismissal elsewhere can clear — a
42
- * banner wired to a dismissible field disappears while its condition still holds.
22
+ * The full-width status-tinted strip for a lasting condition. The message stays
23
+ * while the condition holds, rather than the floating card `Toast` paints for a
24
+ * passing event. The two differ on purpose: a strip reads as part of the page, a
25
+ * card as passing through.
43
26
  *
44
- * One at a time. On a narrow surface a second banner buries the content behind it,
45
- * so pick the condition to show rather than stacking them. For a finished event
46
- * rather than a condition, use `ToastRegion`.
27
+ * It carries no control, because only the condition behind it takes it down.
47
28
  *
48
- * Mount it unconditionally and drive it with `visible`. Give the container
49
- * `overflow: hidden` — the banner slides in from the container's leading edge.
29
+ * Purely presentational: it owns no live region, so rendering it standalone
30
+ * announces nothing. Put it in a `BannerContainer`, which owns the announcement
31
+ * and the motion.
50
32
  */
51
- export declare function Banner({ message, status, visible, revision, onDismiss, dismissLabel, className, style, ref, }: BannerProps): import("react/jsx-runtime").JSX.Element | null;
33
+ export declare function Banner({ status, className, children, ...rest }: BannerProps): import("react/jsx-runtime").JSX.Element;
@@ -1,25 +1,28 @@
1
- import { BannerSurface as e } from "./BannerSurface.js";
2
- import { jsx as t } from "react/jsx-runtime";
3
- import { useCallback as n, useState as r } from "react";
1
+ import { cx as e } from "../../utils/cx.js";
2
+ import { Checkmark as t } from "../Icon/icons/Checkmark.js";
3
+ import { ExclamationTriangle as n } from "../Icon/icons/ExclamationTriangle.js";
4
+ import { XmarkCircle as r } from "../Icon/icons/XmarkCircle.js";
5
+ import { bannerMessage as i, bannerRoot as a } from "./Banner.css.js";
6
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
4
7
  //#region src/components/Banner/Banner.tsx
5
- function i({ message: i, status: a = "success", visible: o, revision: s, onDismiss: c, dismissLabel: l, className: u, style: d, ref: f }) {
6
- let [p, m] = r(!1), [h, g] = r(o);
7
- h !== o && (g(o), m(!o));
8
- let _ = n(() => m(!1), []);
9
- return !o && !p ? null : /* @__PURE__ */ t(e, {
10
- message: i,
11
- status: a,
12
- visible: o,
13
- revision: s,
14
- onExited: _,
15
- onDismiss: c,
16
- dismissLabel: l,
17
- className: u,
18
- style: d,
19
- ref: f
8
+ var c = {
9
+ success: t,
10
+ warning: n,
11
+ error: r
12
+ };
13
+ function l({ status: t = "success", className: n, children: r, ...l }) {
14
+ let u = c[t];
15
+ return /* @__PURE__ */ s("div", {
16
+ ...l,
17
+ "data-status": t,
18
+ className: e(a({ status: t }), n),
19
+ children: [/* @__PURE__ */ o(u, {}), /* @__PURE__ */ o("span", {
20
+ className: i,
21
+ children: r
22
+ })]
20
23
  });
21
24
  }
22
25
  //#endregion
23
- export { i as Banner };
26
+ export { l as Banner };
24
27
 
25
28
  //# sourceMappingURL=Banner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Banner.js","names":[],"sources":["../../../src/components/Banner/Banner.tsx"],"sourcesContent":["import type { CSSProperties, Ref } from \"react\";\nimport { useCallback, useState } from \"react\";\nimport type { ToastStatus } from \"../ToastNotification/ToastNotification.js\";\nimport { BannerSurface } from \"./BannerSurface.js\";\n\nexport interface BannerProps {\n\t/**\n\t * The condition to report. Text, not nodes: the surface fades through a change\n\t * of message, and it can only tell one message from another by comparing them.\n\t */\n\tmessage: string;\n\t/**\n\t * The outcome being reported. Also picks the urgency: `error` interrupts as an\n\t * assertive `alert`, anything else waits its turn as a polite `status`.\n\t */\n\tstatus?: ToastStatus;\n\t/** Whether the condition currently holds. */\n\tvisible: boolean;\n\t/**\n\t * A counter that advances whenever the condition is reported again. Pass it for\n\t * a condition that can repeat with the same wording: without it the second\n\t * report changes nothing in the live region, so a reader never hears it.\n\t */\n\trevision?: number;\n\t/**\n\t * Runs when the reader presses dismiss, and renders the button. Clear the state\n\t * behind `visible` here, or the next change to that state raises the banner\n\t * again. Omit it for a condition the reader cannot act on.\n\t */\n\tonDismiss?: () => void;\n\t/** Accessible name for the dismiss button. Localize it. */\n\tdismissLabel?: string;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n}\n\n/**\n * Reports a condition for as long as it holds — an outage, a lost connection, a\n * failed send. It never queues and never times out, so nothing transient can push\n * it out of view and the message is still there when the reader reaches for it.\n *\n * Pass `onDismiss` only when the reader is meant to act on the condition; a banner\n * bound purely to state offers no control, because only that state takes it down.\n * Either way, read a durable field, never one a dismissal elsewhere can clear — a\n * banner wired to a dismissible field disappears while its condition still holds.\n *\n * One at a time. On a narrow surface a second banner buries the content behind it,\n * so pick the condition to show rather than stacking them. For a finished event\n * rather than a condition, use `ToastRegion`.\n *\n * Mount it unconditionally and drive it with `visible`. Give the container\n * `overflow: hidden` — the banner slides in from the container's leading edge.\n */\nexport function Banner({\n\tmessage,\n\tstatus = \"success\",\n\tvisible,\n\trevision,\n\tonDismiss,\n\tdismissLabel,\n\tclassName,\n\tstyle,\n\tref,\n}: BannerProps) {\n\tconst [isExiting, setIsExiting] = useState(false);\n\tconst [wasVisible, setWasVisible] = useState(visible);\n\n\t// Derive during render rather than in a layout effect. An effect runs after\n\t// the commit that already returned null, so the surface would unmount and\n\t// come back with its exit animation missed. The previous value is state\n\t// rather than a ref because React can discard a render, which would keep a\n\t// ref write but drop the update beside it.\n\tif (wasVisible !== visible) {\n\t\tsetWasVisible(visible);\n\t\tsetIsExiting(!visible);\n\t}\n\n\tconst handleExited = useCallback(() => setIsExiting(false), []);\n\n\tif (!visible && !isExiting) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BannerSurface\n\t\t\tmessage={message}\n\t\t\tstatus={status}\n\t\t\tvisible={visible}\n\t\t\trevision={revision}\n\t\t\tonExited={handleExited}\n\t\t\tonDismiss={onDismiss}\n\t\t\tdismissLabel={dismissLabel}\n\t\t\tclassName={className}\n\t\t\tstyle={style}\n\t\t\tref={ref}\n\t\t/>\n\t);\n}\n"],"mappings":";;;;AAsDA,SAAgB,EAAO,EACtB,YACA,YAAS,WACT,YACA,aACA,cACA,iBACA,cACA,UACA,UACe;CACf,IAAM,CAAC,GAAW,KAAgB,EAAS,GAAM,EAC3C,CAAC,GAAY,KAAiB,EAAS,EAAQ;AAOrD,CAAI,MAAe,MAClB,EAAc,EAAQ,EACtB,EAAa,CAAC,EAAQ;CAGvB,IAAM,IAAe,QAAkB,EAAa,GAAM,EAAE,EAAE,CAAC;AAM/D,QAJI,CAAC,KAAW,CAAC,IACT,OAIP,kBAAC,GAAD;EACU;EACD;EACC;EACC;EACV,UAAU;EACC;EACG;EACH;EACJ;EACF;EACJ,CAAA"}
1
+ {"version":3,"file":"Banner.js","names":[],"sources":["../../../src/components/Banner/Banner.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode, Ref } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport {\n\tCheckmark,\n\tExclamationTriangle,\n\tXmarkCircle,\n} from \"../Icon/icons/index.js\";\nimport { bannerMessage, bannerRoot } from \"./Banner.css.js\";\n\nexport type BannerStatus = \"success\" | \"warning\" | \"error\";\n\nconst STATUS_ICON = {\n\tsuccess: Checkmark,\n\twarning: ExclamationTriangle,\n\terror: XmarkCircle,\n} as const;\n\nexport interface BannerProps {\n\t/**\n\t * The outcome being reported. It selects the background and content color\n\t * pair, and the urgency `BannerContainer` announces it with. Bind it to the\n\t * result of the action, not the UI.\n\t */\n\tstatus?: BannerStatus;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n\t/**\n\t * The message to display. A status icon is rendered automatically, so the\n\t * status is conveyed without color perception; for screen-reader users the\n\t * icon is decorative, so include the status in the copy when the message\n\t * alone wouldn't make the outcome clear.\n\t */\n\tchildren?: ReactNode;\n}\n\n/**\n * The full-width status-tinted strip for a lasting condition. The message stays\n * while the condition holds, rather than the floating card `Toast` paints for a\n * passing event. The two differ on purpose: a strip reads as part of the page, a\n * card as passing through.\n *\n * It carries no control, because only the condition behind it takes it down.\n *\n * Purely presentational: it owns no live region, so rendering it standalone\n * announces nothing. Put it in a `BannerContainer`, which owns the announcement\n * and the motion.\n */\nexport function Banner({\n\tstatus = \"success\",\n\tclassName,\n\tchildren,\n\t...rest\n}: BannerProps) {\n\tconst StatusIcon = STATUS_ICON[status];\n\treturn (\n\t\t<div\n\t\t\t{...rest}\n\t\t\tdata-status={status}\n\t\t\tclassName={cx(bannerRoot({ status }), className)}\n\t\t>\n\t\t\t<StatusIcon />\n\t\t\t<span className={bannerMessage}>{children}</span>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAWA,IAAM,IAAc;CACnB,SAAS;CACT,SAAS;CACT,OAAO;CACP;AAiCD,SAAgB,EAAO,EACtB,YAAS,WACT,cACA,aACA,GAAG,KACY;CACf,IAAM,IAAa,EAAY;AAC/B,QACC,kBAAC,OAAD;EACC,GAAI;EACJ,eAAa;EACb,WAAW,EAAG,EAAW,EAAE,WAAQ,CAAC,EAAE,EAAU;YAHjD,CAKC,kBAAC,GAAD,EAAc,CAAA,EACd,kBAAC,QAAD;GAAM,WAAW;GAAgB;GAAgB,CAAA,CAC5C"}
@@ -0,0 +1,35 @@
1
+ import type { CSSProperties, ReactElement, Ref } from "react";
2
+ import type { BannerProps } from "./Banner.js";
3
+ export interface BannerContainerProps {
4
+ /**
5
+ * The `Banner` for the condition that currently holds, or null when none
6
+ * does. Pick the one to show before handing it over: the container holds a
7
+ * single banner, and on a narrow surface a second one buries the content
8
+ * behind it.
9
+ */
10
+ children: ReactElement<BannerProps> | null;
11
+ /**
12
+ * Identifies the condition on screen. Change it whenever the reader should
13
+ * hear the banner again: the same condition happening a second time with the
14
+ * same wording, a different condition taking the slot, or a change of status.
15
+ * A change hides the region for a frame and reveals it, which is what makes
16
+ * wording the reader has already heard read out again. Leaving it alone still
17
+ * replaces the text, and the live region reports that change on its own.
18
+ */
19
+ occurrence?: string;
20
+ className?: string;
21
+ style?: CSSProperties;
22
+ ref?: Ref<HTMLDivElement>;
23
+ }
24
+ /**
25
+ * Announces and animates one `Banner`.
26
+ *
27
+ * It owns the live region, so the region is mounted and empty before any banner
28
+ * arrives. A live region that mounts with its text already in place is never
29
+ * announced. Urgency follows the banner's status: `error` interrupts as an
30
+ * assertive `alert`, anything else waits its turn as a polite `status`.
31
+ *
32
+ * Mount it for as long as the surface exists and drive it with `children`. It
33
+ * clips its own banner's travel, so the consumer needs no `overflow` rule.
34
+ */
35
+ export declare function BannerContainer({ children, occurrence, className, style, ref, }: BannerContainerProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,38 @@
1
+ import { cx as e } from "../../utils/cx.js";
2
+ import { bannerContainer as t } from "./Banner.css.js";
3
+ import { BannerContainerSlide as n } from "./BannerContainerSlide.js";
4
+ import { jsx as r } from "react/jsx-runtime";
5
+ import { useCallback as i, useEffect as a, useState as o } from "react";
6
+ //#region src/components/Banner/BannerContainer.tsx
7
+ function s({ children: s, occurrence: c, className: l, style: u, ref: d }) {
8
+ let f = s !== null, [p, m] = o(s), [h, g] = o(f), [_, v] = o(f ? "arrival" : "none"), [y, b] = o(c), x = h;
9
+ f && p !== s && m(s), f && !h && g(!0), y !== c && (b(c), f && x && v("swap")), a(() => {
10
+ if (_ === "none") return;
11
+ let e = 0, t = requestAnimationFrame(() => {
12
+ e = requestAnimationFrame(() => v("none"));
13
+ });
14
+ return () => {
15
+ cancelAnimationFrame(t), cancelAnimationFrame(e);
16
+ };
17
+ }, [_]);
18
+ let S = i(() => g(!1), []), C = h && p?.props.status === "error", w = h ? "status" : void 0;
19
+ return /* @__PURE__ */ r("div", {
20
+ ref: d,
21
+ className: e(t, l),
22
+ style: u,
23
+ role: C ? "alert" : w,
24
+ "aria-live": C ? "assertive" : "polite",
25
+ "aria-atomic": "true",
26
+ "aria-hidden": _ === "none" ? void 0 : "true",
27
+ children: h && /* @__PURE__ */ r(n, {
28
+ isPresent: f,
29
+ isSwapping: _ === "swap",
30
+ onExited: S,
31
+ children: p
32
+ })
33
+ });
34
+ }
35
+ //#endregion
36
+ export { s as BannerContainer };
37
+
38
+ //# sourceMappingURL=BannerContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BannerContainer.js","names":[],"sources":["../../../src/components/Banner/BannerContainer.tsx"],"sourcesContent":["import type { CSSProperties, ReactElement, Ref } from \"react\";\nimport { useCallback, useEffect, useState } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport { bannerContainer } from \"./Banner.css.js\";\nimport type { BannerProps } from \"./Banner.js\";\nimport { BannerContainerSlide } from \"./BannerContainerSlide.js\";\n\nexport interface BannerContainerProps {\n\t/**\n\t * The `Banner` for the condition that currently holds, or null when none\n\t * does. Pick the one to show before handing it over: the container holds a\n\t * single banner, and on a narrow surface a second one buries the content\n\t * behind it.\n\t */\n\tchildren: ReactElement<BannerProps> | null;\n\t/**\n\t * Identifies the condition on screen. Change it whenever the reader should\n\t * hear the banner again: the same condition happening a second time with the\n\t * same wording, a different condition taking the slot, or a change of status.\n\t * A change hides the region for a frame and reveals it, which is what makes\n\t * wording the reader has already heard read out again. Leaving it alone still\n\t * replaces the text, and the live region reports that change on its own.\n\t */\n\toccurrence?: string;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n}\n\n/** Why the live region is hidden for a frame, or `none` while it is not. */\ntype Reveal = \"none\" | \"arrival\" | \"swap\";\n\n/**\n * Announces and animates one `Banner`.\n *\n * It owns the live region, so the region is mounted and empty before any banner\n * arrives. A live region that mounts with its text already in place is never\n * announced. Urgency follows the banner's status: `error` interrupts as an\n * assertive `alert`, anything else waits its turn as a polite `status`.\n *\n * Mount it for as long as the surface exists and drive it with `children`. It\n * clips its own banner's travel, so the consumer needs no `overflow` rule.\n */\nexport function BannerContainer({\n\tchildren,\n\toccurrence,\n\tclassName,\n\tstyle,\n\tref,\n}: BannerContainerProps) {\n\tconst isPresent = children !== null;\n\n\t// Derive during render rather than in an effect. An effect runs after the\n\t// commit that already dropped the banner, so its exit animation would be\n\t// missed. The previous values are state rather than refs because React can\n\t// discard a render, which would keep a ref write but drop the update beside\n\t// it.\n\tconst [held, setHeld] = useState(children);\n\tconst [isShowing, setIsShowing] = useState(isPresent);\n\tconst [reveal, setReveal] = useState<Reveal>(isPresent ? \"arrival\" : \"none\");\n\tconst [lastOccurrence, setLastOccurrence] = useState(occurrence);\n\n\tconst wasShowing = isShowing;\n\tif (isPresent && held !== children) {\n\t\tsetHeld(children);\n\t}\n\tif (isPresent && !isShowing) {\n\t\tsetIsShowing(true);\n\t}\n\tif (lastOccurrence !== occurrence) {\n\t\tsetLastOccurrence(occurrence);\n\t\t// A banner arriving into an empty region is already a mutation the reader\n\t\t// hears, so only one replacing another has to be re-announced.\n\t\tif (isPresent && wasShowing) {\n\t\t\tsetReveal(\"swap\");\n\t\t}\n\t}\n\n\tuseEffect(() => {\n\t\tif (reveal === \"none\") {\n\t\t\treturn;\n\t\t}\n\t\t// Two frames: the first is the one the hidden state paints in, and clearing\n\t\t// the flag before that paint leaves the fade with nothing to run from.\n\t\tlet secondFrame = 0;\n\t\tconst frame = requestAnimationFrame(() => {\n\t\t\tsecondFrame = requestAnimationFrame(() => setReveal(\"none\"));\n\t\t});\n\t\treturn () => {\n\t\t\tcancelAnimationFrame(frame);\n\t\t\tcancelAnimationFrame(secondFrame);\n\t\t};\n\t}, [reveal]);\n\n\tconst handleExited = useCallback(() => setIsShowing(false), []);\n\n\t// Read off the banner on screen rather than the last one held. A region that\n\t// keeps a role with nothing in it reports a condition that has cleared, and it\n\t// answers to a consumer looking for whichever banner does hold.\n\tconst isError = isShowing && held?.props.status === \"error\";\n\tconst politeRole = isShowing ? \"status\" : undefined;\n\n\treturn (\n\t\t<div\n\t\t\tref={ref}\n\t\t\tclassName={cx(bannerContainer, className)}\n\t\t\tstyle={style}\n\t\t\trole={isError ? \"alert\" : politeRole}\n\t\t\taria-live={isError ? \"assertive\" : \"polite\"}\n\t\t\taria-atomic=\"true\"\n\t\t\taria-hidden={reveal === \"none\" ? undefined : \"true\"}\n\t\t>\n\t\t\t{isShowing && (\n\t\t\t\t<BannerContainerSlide\n\t\t\t\t\tisPresent={isPresent}\n\t\t\t\t\tisSwapping={reveal === \"swap\"}\n\t\t\t\t\tonExited={handleExited}\n\t\t\t\t>\n\t\t\t\t\t{held}\n\t\t\t\t</BannerContainerSlide>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;AA2CA,SAAgB,EAAgB,EAC/B,aACA,eACA,cACA,UACA,UACwB;CACxB,IAAM,IAAY,MAAa,MAOzB,CAAC,GAAM,KAAW,EAAS,EAAS,EACpC,CAAC,GAAW,KAAgB,EAAS,EAAU,EAC/C,CAAC,GAAQ,KAAa,EAAiB,IAAY,YAAY,OAAO,EACtE,CAAC,GAAgB,KAAqB,EAAS,EAAW,EAE1D,IAAa;AAgBnB,CAfI,KAAa,MAAS,KACzB,EAAQ,EAAS,EAEd,KAAa,CAAC,KACjB,EAAa,GAAK,EAEf,MAAmB,MACtB,EAAkB,EAAW,EAGzB,KAAa,KAChB,EAAU,OAAO,GAInB,QAAgB;AACf,MAAI,MAAW,OACd;EAID,IAAI,IAAc,GACZ,IAAQ,4BAA4B;AACzC,OAAc,4BAA4B,EAAU,OAAO,CAAC;IAC3D;AACF,eAAa;AAEZ,GADA,qBAAqB,EAAM,EAC3B,qBAAqB,EAAY;;IAEhC,CAAC,EAAO,CAAC;CAEZ,IAAM,IAAe,QAAkB,EAAa,GAAM,EAAE,EAAE,CAAC,EAKzD,IAAU,KAAa,GAAM,MAAM,WAAW,SAC9C,IAAa,IAAY,WAAW,KAAA;AAE1C,QACC,kBAAC,OAAD;EACM;EACL,WAAW,EAAG,GAAiB,EAAU;EAClC;EACP,MAAM,IAAU,UAAU;EAC1B,aAAW,IAAU,cAAc;EACnC,eAAY;EACZ,eAAa,MAAW,SAAS,KAAA,IAAY;YAE5C,KACA,kBAAC,GAAD;GACY;GACX,YAAY,MAAW;GACvB,UAAU;aAET;GACqB,CAAA;EAEnB,CAAA"}
@@ -0,0 +1,15 @@
1
+ import type { ReactNode } from "react";
2
+ export interface BannerContainerSlideProps {
3
+ /** False once the condition clears, which starts the exit animation. */
4
+ isPresent: boolean;
5
+ /** Whether the banner on screen is being replaced by another. */
6
+ isSwapping: boolean;
7
+ /** Runs when the exit animation finishes and the banner can be unmounted. */
8
+ onExited: () => void;
9
+ children: ReactNode;
10
+ }
11
+ /**
12
+ * Carries the banner's motion. Mounted for as long as a banner is on screen, so
13
+ * the enter animation runs on each arrival rather than once per container.
14
+ */
15
+ export declare function BannerContainerSlide({ isPresent, isSwapping, onExited, children, }: BannerContainerSlideProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import { bannerContainerSlide as e } from "./Banner.css.js";
2
+ import { useEnterAnimation as t, useExitAnimation as n } from "../../utils/animation.js";
3
+ import { jsx as r } from "react/jsx-runtime";
4
+ import { useEffect as i, useRef as a } from "react";
5
+ //#region src/components/Banner/BannerContainerSlide.tsx
6
+ function o({ isPresent: o, isSwapping: s, onExited: c, children: l }) {
7
+ let u = a(null), d = t(u), f = n(u, o);
8
+ return i(() => {
9
+ !o && !f && c();
10
+ }, [
11
+ o,
12
+ f,
13
+ c
14
+ ]), /* @__PURE__ */ r("div", {
15
+ ref: u,
16
+ className: e,
17
+ "data-entering": d || void 0,
18
+ "data-exiting": f || void 0,
19
+ "data-swapping": s || void 0,
20
+ children: l
21
+ });
22
+ }
23
+ //#endregion
24
+ export { o as BannerContainerSlide };
25
+
26
+ //# sourceMappingURL=BannerContainerSlide.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BannerContainerSlide.js","names":[],"sources":["../../../src/components/Banner/BannerContainerSlide.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { useEffect, useRef } from \"react\";\nimport { useEnterAnimation, useExitAnimation } from \"../../utils/animation.js\";\nimport { bannerContainerSlide } from \"./Banner.css.js\";\n\nexport interface BannerContainerSlideProps {\n\t/** False once the condition clears, which starts the exit animation. */\n\tisPresent: boolean;\n\t/** Whether the banner on screen is being replaced by another. */\n\tisSwapping: boolean;\n\t/** Runs when the exit animation finishes and the banner can be unmounted. */\n\tonExited: () => void;\n\tchildren: ReactNode;\n}\n\n/**\n * Carries the banner's motion. Mounted for as long as a banner is on screen, so\n * the enter animation runs on each arrival rather than once per container.\n */\nexport function BannerContainerSlide({\n\tisPresent,\n\tisSwapping,\n\tonExited,\n\tchildren,\n}: BannerContainerSlideProps) {\n\tconst ref = useRef<HTMLDivElement>(null);\n\tconst isEntering = useEnterAnimation(ref);\n\tconst isExiting = useExitAnimation(ref, isPresent);\n\n\tuseEffect(() => {\n\t\tif (!isPresent && !isExiting) {\n\t\t\tonExited();\n\t\t}\n\t}, [isPresent, isExiting, onExited]);\n\n\treturn (\n\t\t<div\n\t\t\tref={ref}\n\t\t\tclassName={bannerContainerSlide}\n\t\t\tdata-entering={isEntering || undefined}\n\t\t\tdata-exiting={isExiting || undefined}\n\t\t\tdata-swapping={isSwapping || undefined}\n\t\t>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;AAmBA,SAAgB,EAAqB,EACpC,cACA,eACA,aACA,eAC6B;CAC7B,IAAM,IAAM,EAAuB,KAAK,EAClC,IAAa,EAAkB,EAAI,EACnC,IAAY,EAAiB,GAAK,EAAU;AAQlD,QANA,QAAgB;AACf,EAAI,CAAC,KAAa,CAAC,KAClB,GAAU;IAET;EAAC;EAAW;EAAW;EAAS,CAAC,EAGnC,kBAAC,OAAD;EACM;EACL,WAAW;EACX,iBAAe,KAAc,KAAA;EAC7B,gBAAc,KAAa,KAAA;EAC3B,iBAAe,KAAc,KAAA;EAE5B;EACI,CAAA"}
@@ -1 +1,2 @@
1
- export { Banner, type BannerProps } from "./Banner.js";
1
+ export { Banner, type BannerProps, type BannerStatus } from "./Banner.js";
2
+ export { BannerContainer, type BannerContainerProps, } from "./BannerContainer.js";
@@ -0,0 +1,2 @@
1
+ import type { IconProps } from "../Icon.js";
2
+ export declare function CheckmarkCircle(props: Omit<IconProps, "children">): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { Icon as e } from "../Icon.js";
2
+ import { Glyph as t } from "./Glyph.js";
3
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
+ //#region src/components/Icon/icons/CheckmarkCircle.tsx
5
+ function i(i) {
6
+ return /* @__PURE__ */ n(e, {
7
+ ...i,
8
+ children: /* @__PURE__ */ r(t, { children: [/* @__PURE__ */ n("path", { d: "M12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2ZM12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4Z" }), /* @__PURE__ */ n("path", { d: "M15.70898 8.32129C16.08392 7.91605 16.71666 7.89096 17.12207 8.26562C17.5273 8.64056 17.5524 9.2733 17.17773 9.67871L10.6543 16.73047C10.46513 16.9347 10.19928 17.05068 9.9209 17.05078C9.64228 17.0508 9.3758 16.93492 9.18652 16.73047L6.46582 13.79004C6.09094 13.38466 6.11619 12.75198 6.52148 12.37695C6.92686 12.00215 7.55957 12.02637 7.93457 12.43164L9.91992 14.57812L15.70898 8.32129Z" })] })
9
+ });
10
+ }
11
+ //#endregion
12
+ export { i as CheckmarkCircle };
13
+
14
+ //# sourceMappingURL=CheckmarkCircle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckmarkCircle.js","names":[],"sources":["../../../../src/components/Icon/icons/CheckmarkCircle.tsx"],"sourcesContent":["import type { IconProps } from \"../Icon.js\";\nimport { Icon } from \"../Icon.js\";\nimport { Glyph } from \"./Glyph.js\";\n\nexport function CheckmarkCircle(props: Omit<IconProps, \"children\">) {\n\treturn (\n\t\t<Icon {...props}>\n\t\t\t<Glyph>\n\t\t\t\t<path d=\"M12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2ZM12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4Z\" />\n\t\t\t\t<path d=\"M15.70898 8.32129C16.08392 7.91605 16.71666 7.89096 17.12207 8.26562C17.5273 8.64056 17.5524 9.2733 17.17773 9.67871L10.6543 16.73047C10.46513 16.9347 10.19928 17.05068 9.9209 17.05078C9.64228 17.0508 9.3758 16.93492 9.18652 16.73047L6.46582 13.79004C6.09094 13.38466 6.11619 12.75198 6.52148 12.37695C6.92686 12.00215 7.55957 12.02637 7.93457 12.43164L9.91992 14.57812L15.70898 8.32129Z\" />\n\t\t\t</Glyph>\n\t\t</Icon>\n\t);\n}\n"],"mappings":";;;;AAIA,SAAgB,EAAgB,GAAoC;AACnE,QACC,kBAAC,GAAD;EAAM,GAAI;YACT,kBAAC,GAAD,EAAA,UAAA,CACC,kBAAC,QAAD,EAAM,GAAE,oOAAqO,CAAA,EAC7O,kBAAC,QAAD,EAAM,GAAE,uYAAwY,CAAA,CACzY,EAAA,CAAA;EACF,CAAA"}
@@ -7,6 +7,7 @@ export { ArrowRight } from "./ArrowRight.js";
7
7
  export { Bell } from "./Bell.js";
8
8
  export { BellSlash } from "./BellSlash.js";
9
9
  export { Checkmark } from "./Checkmark.js";
10
+ export { CheckmarkCircle } from "./CheckmarkCircle.js";
10
11
  export { ChevronLeft } from "./ChevronLeft.js";
11
12
  export { ChevronRight } from "./ChevronRight.js";
12
13
  export { CloudUpload } from "./CloudUpload.js";
@@ -0,0 +1,36 @@
1
+ export declare const toast: string;
2
+ export declare const toastIcon: import("@vanilla-extract/recipes").RuntimeFn<{
3
+ status: {
4
+ success: {
5
+ color: "var(--lovelace-color-content-success)";
6
+ fontSize: "var(--lovelace-icon-size-control)";
7
+ };
8
+ warning: {
9
+ color: "var(--lovelace-color-content-warning)";
10
+ fontSize: "var(--lovelace-icon-size-control)";
11
+ };
12
+ error: {
13
+ color: "var(--lovelace-color-content-destructive)";
14
+ fontSize: "var(--lovelace-icon-size-control)";
15
+ };
16
+ custom: {
17
+ color: "var(--lovelace-color-content-secondary)";
18
+ fontSize: "var(--lovelace-icon-size-lg)";
19
+ };
20
+ loading: {
21
+ width: "var(--lovelace-icon-size-lg)";
22
+ height: "var(--lovelace-icon-size-lg)";
23
+ };
24
+ };
25
+ }>;
26
+ export declare const toastMessage: string;
27
+ export declare const toastDismiss: string;
28
+ /**
29
+ * The always-mounted anchor the region portals into. It spans the width its
30
+ * consumer gives it while the cards only hug their content, so it passes the
31
+ * pointer through and each card takes it back.
32
+ */
33
+ export declare const toastAnchor: string;
34
+ export declare const toastRegion: string;
35
+ export declare const toastList: string;
36
+ export declare const toastCard: string;
@@ -0,0 +1,19 @@
1
+ import { createRuntimeFn as e } from "../../vendor/@vanilla-extract/recipes/dist/createRuntimeFn-62c9670f.esm.js";
2
+ /* empty css */
3
+ //#region src/components/Toast/Toast.css.ts
4
+ var t = "_16991601", n = e({
5
+ defaultClassName: "_16991602",
6
+ variantClassNames: { status: {
7
+ success: "_16991603",
8
+ warning: "_16991604",
9
+ error: "_16991605",
10
+ custom: "_16991606",
11
+ loading: "_16991607"
12
+ } },
13
+ defaultVariants: { status: "success" },
14
+ compoundVariants: []
15
+ }), r = "_16991608", i = "_16991609", a = "_1699160a", o = "_1699160b", s = "_1699160c", c = "_1699160d";
16
+ //#endregion
17
+ export { t as toast, a as toastAnchor, c as toastCard, i as toastDismiss, n as toastIcon, s as toastList, r as toastMessage, o as toastRegion };
18
+
19
+ //# sourceMappingURL=Toast.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toast.css.js","names":[],"sources":["../../../src/components/Toast/Toast.css.ts"],"sourcesContent":["import {\n\tcreateVar,\n\tfallbackVar,\n\tglobalStyle,\n\tstyle,\n} from \"@vanilla-extract/css\";\nimport { recipe } from \"@vanilla-extract/recipes\";\nimport { t } from \"../../tokens/index.js\";\n\n/**\n * The card's border colour, set on the element each theme is declared on.\n *\n * Dark resolves `border-default` and `background-tertiary` to the same\n * neutral-700, so the border paints nothing there. `border-medium` is what\n * separates the card from the canvas: the fill alone is 1.7:1 against\n * `background-default`, the border 3.4:1, which is the 3:1 that non-text\n * boundaries need.\n *\n * It rides the theme element rather than a `[data-theme=\"dark\"] &` descendant\n * selector, which matches any dark ancestor rather than the nearest one. A light\n * provider inside a dark page would take the dark border. The tokens themselves\n * are declared the same way, so the nearest provider wins by inheritance.\n */\nconst cardBorderColor = createVar();\n\nglobalStyle('[data-theme=\"light\"]', {\n\tvars: { [cardBorderColor]: t(\"color-border-default\") },\n});\n\nglobalStyle('[data-theme=\"dark\"]', {\n\tvars: { [cardBorderColor]: t(\"color-border-medium\") },\n});\n\n// Hugs its content rather than filling the row, which is what separates it from\n// the banner surface: a card that floats over the transcript, not a strip that\n// belongs to it. `toastList` below centres it.\nexport const toast = style({\n\tdisplay: \"flex\",\n\talignItems: \"center\",\n\tjustifyContent: \"flex-start\",\n\tboxSizing: \"border-box\",\n\t// Sized to its own content, the way Figma draws it — the five variants range\n\t// 157-222px wide. Without this the card is a block-level div and fills\n\t// whatever holds it, which is the banner surface's shape, not this one.\n\t// Capped so long copy wraps inside the chat window instead of overflowing it.\n\twidth: \"fit-content\",\n\tmaxWidth: \"100%\",\n\tgap: t(\"gap-8\"),\n\tpaddingInline: t(\"padding-12\"),\n\tpaddingBlock: t(\"padding-8\"),\n\tborderRadius: t(\"border-radius-10\"),\n\tborderWidth: t(\"border-width-default\"),\n\tborderStyle: \"solid\",\n\tborderColor: fallbackVar(cardBorderColor, t(\"color-border-default\")),\n\tbackgroundColor: t(\"color-background-tertiary\"),\n\tboxShadow: t(\"elevation-3\"),\n\t\"@media\": {\n\t\t// The shadow is what lifts the card off the transcript, and forced colors\n\t\t// drops it — so the border has to carry the boundary on its own.\n\t\t\"(forced-colors: active)\": { borderColor: \"CanvasText\" },\n\t},\n});\n\nexport const toastIcon = recipe({\n\tbase: {\n\t\tdisplay: \"flex\",\n\t\talignItems: \"center\",\n\t\tjustifyContent: \"center\",\n\t\tflexShrink: 0,\n\t\tlineHeight: 0,\n\t},\n\t// Only the glyph changes between statuses — the card paints identically for\n\t// all five, so there is no variant axis on the card itself.\n\tvariants: {\n\t\tstatus: {\n\t\t\tsuccess: {\n\t\t\t\tcolor: t(\"color-content-success\"),\n\t\t\t\tfontSize: t(\"icon-size-control\"),\n\t\t\t},\n\t\t\twarning: {\n\t\t\t\tcolor: t(\"color-content-warning\"),\n\t\t\t\tfontSize: t(\"icon-size-control\"),\n\t\t\t},\n\t\t\terror: {\n\t\t\t\tcolor: t(\"color-content-destructive\"),\n\t\t\t\tfontSize: t(\"icon-size-control\"),\n\t\t\t},\n\t\t\tcustom: {\n\t\t\t\tcolor: t(\"color-content-secondary\"),\n\t\t\t\tfontSize: t(\"icon-size-lg\"),\n\t\t\t},\n\t\t\t// Figma sizes this slot off line-height/title-small (24px). Spinner ships\n\t\t\t// 16px and 32px with per-size border widths, so the 16px one is centred\n\t\t\t// in a 24px box rather than scaled to a size it was not drawn for.\n\t\t\tloading: {\n\t\t\t\twidth: t(\"icon-size-lg\"),\n\t\t\t\theight: t(\"icon-size-lg\"),\n\t\t\t},\n\t\t},\n\t},\n\tdefaultVariants: { status: \"success\" },\n});\n\nexport const toastMessage = style({\n\tminWidth: 0,\n\tmarginInlineEnd: \"auto\",\n\t// The glyph carries the status, so the copy stays at the default content\n\t// colour rather than tinting with it — unlike the banner surface, where the\n\t// tinted background sets the whole card's tone.\n\tcolor: t(\"color-content-default\"),\n\tfontFamily: t(\"font-family-body\"),\n\tfontWeight: t(\"font-weight-medium\"),\n\tfontSize: t(\"font-size-body\"),\n\tlineHeight: t(\"line-height-body\"),\n\toverflowWrap: \"break-word\",\n});\n\n// IconButton's tertiary intent paints content-default; Figma wants the dismiss\n// glyph quieter. Its state layer is currentColor, so it follows automatically.\nexport const toastDismiss = style({\n\tflexShrink: 0,\n\tcolor: t(\"color-content-secondary\"),\n});\n\nglobalStyle(`${toast} > [data-slot='button'] [data-slot='icon']`, {\n\tfontSize: t(\"icon-size-sm\"),\n});\n\n// Matches the banner surface: the control is taken away only while the card is\n// leaving, which is not a state the reader should read as unavailable.\nglobalStyle(`${toast} > [data-slot='button'][data-disabled]`, {\n\t// Restated rather than inherited: this selector outranks `toastDismiss`, and\n\t// the card sets no colour of its own for `inherit` to land on.\n\tcolor: t(\"color-content-secondary\"),\n\tcursor: \"inherit\",\n});\n\n/**\n * The always-mounted anchor the region portals into. It spans the width its\n * consumer gives it while the cards only hug their content, so it passes the\n * pointer through and each card takes it back.\n */\nexport const toastAnchor = style({\n\tpointerEvents: \"none\",\n});\n\nexport const toastRegion = style({\n\toutline: \"none\",\n});\n\nexport const toastList = style({\n\tlistStyle: \"none\",\n\tmargin: 0,\n\tpadding: 0,\n\tdisplay: \"flex\",\n\t// The queue hands its toasts over newest first, and the newest belongs at the\n\t// bottom of the stack, nearest the composer. Reversing the column here rather\n\t// than reordering the list keeps the DOM order the queue's own, which is what\n\t// react-aria indexes against when it moves focus off a closing toast.\n\tflexDirection: \"column-reverse\",\n\talignItems: \"center\",\n\tgap: t(\"gap-16\"),\n});\n\n// Typed as a plain string for the reason the banner's slide is: `t()` returns a\n// union of every token name, and a multi-property template literal over it\n// explodes past what tsc can represent.\nconst cardTransition: string = `opacity ${t(\"duration-medium\")} ${t(\n\t\"easing-standard\",\n)}, transform ${t(\"duration-medium\")} ${t(\"easing-standard\")}`;\n\nexport const toastCard = style({\n\toutline: \"none\",\n\tpointerEvents: \"auto\",\n\t// Sized against elevation/3's 24px blur: the stack sits in a container the app\n\t// clips, so anything outside this inset is cut.\n\tpaddingInline: t(\"padding-16\"),\n\tselectors: {\n\t\t// Off-screen below the anchored edge: the state the card rises in from and\n\t\t// falls back out to. A transition, not a keyframe, and the same mechanism\n\t\t// as `bannerContainerSlide`. A transition interpolates from the current\n\t\t// computed value, so a card dismissed part-way through its entry reverses\n\t\t// from wherever it stands. A keyframe would restart the exit from its own\n\t\t// first frame and jump the card there first.\n\t\t\"&[data-entering]\": { opacity: 0, transform: \"translateY(100%)\" },\n\t\t// A leaving card must not take a click meant for the transcript under it.\n\t\t// The container sets `inert`, which drops pointer events, but WebKit added\n\t\t// `inert` in 15.5 and the floor in `messaging/vite.browser-targets.mjs` is\n\t\t// 15.4, so the card holds the pointer through its travel there without this.\n\t\t\"&[data-exiting]\": {\n\t\t\topacity: 0,\n\t\t\ttransform: \"translateY(100%)\",\n\t\t\tpointerEvents: \"none\",\n\t\t},\n\t},\n\t\"@media\": {\n\t\t// A reader who asked for no motion gets the end states with no travel to\n\t\t// them, so the card appears and clears with no transition.\n\t\t\"(prefers-reduced-motion: no-preference)\": {\n\t\t\ttransition: cardTransition,\n\t\t},\n\t},\n});\n\n// The ring follows the card, not the row. Restating the elevation is what keeps\n// it: `box-shadow` is one property, so the card's own elevation has to be\n// restated alongside the ring.\nconst FOCUS_RING = `inset 0 0 0 ${t(\"border-width-focus\")} ${t(\"color-border-focus\")}`;\n\nglobalStyle(`${toastCard}[data-focus-visible] ${toast}`, {\n\tboxShadow: `${FOCUS_RING}, ${t(\"elevation-3\")}`,\n});\n\nglobalStyle(`${toastCard}[data-focus-visible] ${toast}`, {\n\t\"@media\": {\n\t\t\"(forced-colors: active)\": {\n\t\t\toutline: \"2px solid Highlight\",\n\t\t\toutlineOffset: \"-2px\",\n\t\t},\n\t},\n});\n"],"mappings":""}
@@ -0,0 +1,52 @@
1
+ import type { CSSProperties, HTMLAttributes, ReactNode, Ref } from "react";
2
+ import type { PressEvent } from "react-aria";
3
+ export type ToastStatus = "success" | "warning" | "error" | "custom" | "loading";
4
+ export interface ToastProps {
5
+ /**
6
+ * The outcome being reported — selects the leading glyph and its colour. Bind
7
+ * it to the result of the action, not the UI. `custom` takes the glyph from
8
+ * `icon`; `loading` shows a spinner and refuses a dismiss control.
9
+ */
10
+ status?: ToastStatus;
11
+ /** The glyph for `status="custom"`. Ignored for every other status. */
12
+ icon?: ReactNode;
13
+ /**
14
+ * Renders a trailing dismiss button and runs this when the user presses it.
15
+ * Ignored while `status="loading"`, whose lifetime belongs to whatever raised
16
+ * it rather than to the reader.
17
+ */
18
+ onDismiss?: (event: PressEvent) => void;
19
+ /** Accessible name for the dismiss button. Localize it. */
20
+ dismissLabel?: string;
21
+ /**
22
+ * Takes the press away while the card is on screen only to finish leaving.
23
+ * WebKit added `inert` in 15.5, after the iOS 15.4 floor in
24
+ * `messaging/vite.browser-targets.mjs`. At that floor, the container's `inert`
25
+ * attribute leaves the button tabbable even though its press no longer acts
26
+ * on anything. Disabling keeps the card's layout still through the travel,
27
+ * which removing the button would not.
28
+ */
29
+ dismissDisabled?: boolean;
30
+ /**
31
+ * Attributes for the message element. A container that owns announcement
32
+ * passes its live-region props through here, so the dismiss button stays
33
+ * outside what gets announced.
34
+ */
35
+ messageProps?: HTMLAttributes<HTMLElement>;
36
+ className?: string;
37
+ style?: CSSProperties;
38
+ ref?: Ref<HTMLDivElement>;
39
+ /** The message to display. Keep it to a single line. */
40
+ children?: ReactNode;
41
+ }
42
+ /**
43
+ * The floating surface for a transient event — a card that sits above the
44
+ * transcript on a neutral background, rather than the tinted full-width strip
45
+ * `Banner` paints for a lasting condition. The two differ on purpose:
46
+ * a card reads as passing through, a strip as part of the page.
47
+ *
48
+ * Purely presentational, and carries no live region of its own, so it can sit
49
+ * inside a container that owns the announcement. Rendering it standalone
50
+ * announces nothing — reach for `ToastContainer`.
51
+ */
52
+ export declare function Toast({ status, icon, onDismiss, dismissLabel, dismissDisabled, messageProps, className, children, ...rest }: ToastProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,59 @@
1
+ import { cx as e } from "../../utils/cx.js";
2
+ import { CheckmarkCircle as t } from "../Icon/icons/CheckmarkCircle.js";
3
+ import { ExclamationTriangle as n } from "../Icon/icons/ExclamationTriangle.js";
4
+ import { Xmark as r } from "../Icon/icons/Xmark.js";
5
+ import { XmarkCircle as i } from "../Icon/icons/XmarkCircle.js";
6
+ import { IconButton as a } from "../IconButton/IconButton.js";
7
+ import { Spinner as o } from "../Spinner/Spinner.js";
8
+ import { toast as s, toastIcon as c, toastMessage as l } from "./Toast.css.js";
9
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
10
+ //#region src/components/Toast/Toast.tsx
11
+ var f = {
12
+ success: t,
13
+ warning: n,
14
+ error: i
15
+ };
16
+ function p({ status: e, icon: t }) {
17
+ if (e === "loading") return /* @__PURE__ */ u("span", {
18
+ "aria-hidden": "true",
19
+ children: /* @__PURE__ */ u(o, { size: "sm" })
20
+ });
21
+ if (e === "custom") return t;
22
+ let n = f[e];
23
+ return /* @__PURE__ */ u(n, {});
24
+ }
25
+ function m({ status: t = "success", icon: n, onDismiss: i, dismissLabel: o = "Dismiss notification", dismissDisabled: f = !1, messageProps: m, className: h, children: g, ..._ }) {
26
+ let v = !!i && t !== "loading", y = t !== "custom" || !!n;
27
+ return /* @__PURE__ */ d("div", {
28
+ ..._,
29
+ "data-status": t,
30
+ className: e(s, h),
31
+ children: [
32
+ y ? /* @__PURE__ */ u("span", {
33
+ className: c({ status: t }),
34
+ children: /* @__PURE__ */ u(p, {
35
+ status: t,
36
+ icon: n
37
+ })
38
+ }) : null,
39
+ /* @__PURE__ */ u("div", {
40
+ ...m,
41
+ className: e(m?.className, l),
42
+ children: g
43
+ }),
44
+ v && /* @__PURE__ */ u(a, {
45
+ label: o,
46
+ variant: "tertiary",
47
+ size: "xs",
48
+ isDisabled: f,
49
+ onPress: i,
50
+ className: "_16991609",
51
+ children: /* @__PURE__ */ u(r, {})
52
+ })
53
+ ]
54
+ });
55
+ }
56
+ //#endregion
57
+ export { m as Toast };
58
+
59
+ //# sourceMappingURL=Toast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toast.js","names":[],"sources":["../../../src/components/Toast/Toast.tsx"],"sourcesContent":["import type { CSSProperties, HTMLAttributes, ReactNode, Ref } from \"react\";\nimport type { PressEvent } from \"react-aria\";\nimport { cx } from \"../../utils/cx.js\";\nimport {\n\tCheckmarkCircle,\n\tExclamationTriangle,\n\tXmark,\n\tXmarkCircle,\n} from \"../Icon/icons/index.js\";\nimport { IconButton } from \"../IconButton/IconButton.js\";\nimport { Spinner } from \"../Spinner/Spinner.js\";\nimport { toast, toastDismiss, toastIcon, toastMessage } from \"./Toast.css.js\";\n\nexport type ToastStatus =\n\t| \"success\"\n\t| \"warning\"\n\t| \"error\"\n\t| \"custom\"\n\t| \"loading\";\n\nconst STATUS_ICON = {\n\tsuccess: CheckmarkCircle,\n\twarning: ExclamationTriangle,\n\terror: XmarkCircle,\n} as const;\n\nexport interface ToastProps {\n\t/**\n\t * The outcome being reported — selects the leading glyph and its colour. Bind\n\t * it to the result of the action, not the UI. `custom` takes the glyph from\n\t * `icon`; `loading` shows a spinner and refuses a dismiss control.\n\t */\n\tstatus?: ToastStatus;\n\t/** The glyph for `status=\"custom\"`. Ignored for every other status. */\n\ticon?: ReactNode;\n\t/**\n\t * Renders a trailing dismiss button and runs this when the user presses it.\n\t * Ignored while `status=\"loading\"`, whose lifetime belongs to whatever raised\n\t * it rather than to the reader.\n\t */\n\tonDismiss?: (event: PressEvent) => void;\n\t/** Accessible name for the dismiss button. Localize it. */\n\tdismissLabel?: string;\n\t/**\n\t * Takes the press away while the card is on screen only to finish leaving.\n\t * WebKit added `inert` in 15.5, after the iOS 15.4 floor in\n\t * `messaging/vite.browser-targets.mjs`. At that floor, the container's `inert`\n\t * attribute leaves the button tabbable even though its press no longer acts\n\t * on anything. Disabling keeps the card's layout still through the travel,\n\t * which removing the button would not.\n\t */\n\tdismissDisabled?: boolean;\n\t/**\n\t * Attributes for the message element. A container that owns announcement\n\t * passes its live-region props through here, so the dismiss button stays\n\t * outside what gets announced.\n\t */\n\tmessageProps?: HTMLAttributes<HTMLElement>;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n\t/** The message to display. Keep it to a single line. */\n\tchildren?: ReactNode;\n}\n\nfunction LeadingGlyph({\n\tstatus,\n\ticon,\n}: {\n\tstatus: ToastStatus;\n\ticon: ReactNode;\n}) {\n\tif (status === \"loading\") {\n\t\t// Spinner carries its own `role=\"status\" aria-label=\"Loading\"`, and the\n\t\t// container already puts a live region on the message. Two of them inside\n\t\t// one alertdialog announces \"Loading\" ahead of the message, so this one is\n\t\t// hidden — the copy is what the reader needs.\n\t\treturn (\n\t\t\t<span aria-hidden=\"true\">\n\t\t\t\t<Spinner size=\"sm\" />\n\t\t\t</span>\n\t\t);\n\t}\n\tif (status === \"custom\") {\n\t\treturn icon;\n\t}\n\tconst StatusIcon = STATUS_ICON[status];\n\treturn <StatusIcon />;\n}\n\n/**\n * The floating surface for a transient event — a card that sits above the\n * transcript on a neutral background, rather than the tinted full-width strip\n * `Banner` paints for a lasting condition. The two differ on purpose:\n * a card reads as passing through, a strip as part of the page.\n *\n * Purely presentational, and carries no live region of its own, so it can sit\n * inside a container that owns the announcement. Rendering it standalone\n * announces nothing — reach for `ToastContainer`.\n */\nexport function Toast({\n\tstatus = \"success\",\n\ticon,\n\tonDismiss,\n\tdismissLabel = \"Dismiss notification\",\n\tdismissDisabled = false,\n\tmessageProps,\n\tclassName,\n\tchildren,\n\t...rest\n}: ToastProps) {\n\t// Loading owns its own lifetime, so it never offers a dismiss control even\n\t// when the consumer passes one.\n\tconst canDismiss = !!onDismiss && status !== \"loading\";\n\t// Decided before the element exists: an element is truthy even when the\n\t// component returns null, so testing the rendered glyph would leave an empty\n\t// slot — and its `gap-8` — indenting the message of an iconless `custom`.\n\tconst hasGlyph = status !== \"custom\" || !!icon;\n\n\treturn (\n\t\t<div {...rest} data-status={status} className={cx(toast, className)}>\n\t\t\t{hasGlyph ? (\n\t\t\t\t<span className={toastIcon({ status })}>\n\t\t\t\t\t<LeadingGlyph status={status} icon={icon} />\n\t\t\t\t</span>\n\t\t\t) : null}\n\t\t\t{/* A div, not a span: a container that owns announcement puts a live\n\t\t\t region here, and React Aria renders that region as a div. */}\n\t\t\t<div\n\t\t\t\t{...messageProps}\n\t\t\t\tclassName={cx(messageProps?.className, toastMessage)}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t\t{canDismiss && (\n\t\t\t\t<IconButton\n\t\t\t\t\tlabel={dismissLabel}\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tsize=\"xs\"\n\t\t\t\t\tisDisabled={dismissDisabled}\n\t\t\t\t\tonPress={onDismiss}\n\t\t\t\t\tclassName={toastDismiss}\n\t\t\t\t>\n\t\t\t\t\t<Xmark />\n\t\t\t\t</IconButton>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;;AAoBA,IAAM,IAAc;CACnB,SAAS;CACT,SAAS;CACT,OAAO;CACP;AAyCD,SAAS,EAAa,EACrB,WACA,WAIE;AACF,KAAI,MAAW,UAKd,QACC,kBAAC,QAAD;EAAM,eAAY;YACjB,kBAAC,GAAD,EAAS,MAAK,MAAO,CAAA;EACf,CAAA;AAGT,KAAI,MAAW,SACd,QAAO;CAER,IAAM,IAAa,EAAY;AAC/B,QAAO,kBAAC,GAAD,EAAc,CAAA;;AAatB,SAAgB,EAAM,EACrB,YAAS,WACT,SACA,cACA,kBAAe,wBACf,qBAAkB,IAClB,iBACA,cACA,aACA,GAAG,KACW;CAGd,IAAM,IAAa,CAAC,CAAC,KAAa,MAAW,WAIvC,IAAW,MAAW,YAAY,CAAC,CAAC;AAE1C,QACC,kBAAC,OAAD;EAAK,GAAI;EAAM,eAAa;EAAQ,WAAW,EAAG,GAAO,EAAU;YAAnE;GACE,IACA,kBAAC,QAAD;IAAM,WAAW,EAAU,EAAE,WAAQ,CAAC;cACrC,kBAAC,GAAD;KAAsB;KAAc;KAAQ,CAAA;IACtC,CAAA,GACJ;GAGJ,kBAAC,OAAD;IACC,GAAI;IACJ,WAAW,EAAG,GAAc,WAAW,EAAa;IAEnD;IACI,CAAA;GACL,KACA,kBAAC,GAAD;IACC,OAAO;IACP,SAAQ;IACR,MAAK;IACL,YAAY;IACZ,SAAS;IACT,WAAA;cAEA,kBAAC,GAAD,EAAS,CAAA;IACG,CAAA;GAET"}