@ada-cx/lovelace 1.13.0 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AttachmentChip/AttachmentChip.css.js.map +1 -1
- package/dist/components/Banner/Banner.css.d.ts +19 -1
- package/dist/components/Banner/Banner.css.js +12 -2
- package/dist/components/Banner/Banner.css.js.map +1 -1
- package/dist/components/Banner/Banner.d.ts +22 -40
- package/dist/components/Banner/Banner.js +22 -19
- package/dist/components/Banner/Banner.js.map +1 -1
- package/dist/components/Banner/BannerContainer.d.ts +35 -0
- package/dist/components/Banner/BannerContainer.js +38 -0
- package/dist/components/Banner/BannerContainer.js.map +1 -0
- package/dist/components/Banner/BannerContainerSlide.d.ts +15 -0
- package/dist/components/Banner/BannerContainerSlide.js +26 -0
- package/dist/components/Banner/BannerContainerSlide.js.map +1 -0
- package/dist/components/Banner/index.d.ts +2 -1
- package/dist/components/Button/Button.css.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.css.js.map +1 -1
- package/dist/components/Chip/Chip.css.js.map +1 -1
- package/dist/components/Dialog/Dialog.css.js.map +1 -1
- package/dist/components/Divider/Divider.css.js.map +1 -1
- package/dist/components/DropZone/DropZone.css.js.map +1 -1
- package/dist/components/Header/Header.css.js.map +1 -1
- package/dist/components/Header/HeaderTitle.d.ts +13 -4
- package/dist/components/Header/HeaderTitle.js +9 -7
- package/dist/components/Header/HeaderTitle.js.map +1 -1
- package/dist/components/Icon/icons/CheckmarkCircle.d.ts +2 -0
- package/dist/components/Icon/icons/CheckmarkCircle.js +14 -0
- package/dist/components/Icon/icons/CheckmarkCircle.js.map +1 -0
- package/dist/components/Icon/icons/index.d.ts +1 -0
- package/dist/components/Input/Input.css.js.map +1 -1
- package/dist/components/Link/Link.css.js.map +1 -1
- package/dist/components/MessageError/MessageError.css.js.map +1 -1
- package/dist/components/PillButton/PillButton.css.js.map +1 -1
- package/dist/components/ProactiveMessage/ProactiveMessage.css.js.map +1 -1
- package/dist/components/Radio/Radio.css.js.map +1 -1
- package/dist/components/ScrollMarker/ScrollMarker.css.js.map +1 -1
- package/dist/components/Sheet/Sheet.css.js.map +1 -1
- package/dist/components/Survey/SurveyRating/SurveyRating.css.js.map +1 -1
- package/dist/components/Text/Text.css.d.ts +13 -0
- package/dist/components/Text/Text.css.js +28 -0
- package/dist/components/Text/Text.css.js.map +1 -0
- package/dist/components/Text/Text.d.ts +30 -0
- package/dist/components/Text/Text.js +17 -0
- package/dist/components/Text/Text.js.map +1 -0
- package/dist/components/Text/index.d.ts +3 -0
- package/dist/components/ThinkingShimmer/ThinkingShimmer.css.js.map +1 -1
- package/dist/components/Toast/Toast.css.d.ts +36 -0
- package/dist/components/Toast/Toast.css.js +19 -0
- package/dist/components/Toast/Toast.css.js.map +1 -0
- package/dist/components/Toast/Toast.d.ts +52 -0
- package/dist/components/Toast/Toast.js +59 -0
- package/dist/components/Toast/Toast.js.map +1 -0
- package/dist/components/Toast/ToastContainer.d.ts +48 -0
- package/dist/components/Toast/ToastContainer.js +104 -0
- package/dist/components/Toast/ToastContainer.js.map +1 -0
- package/dist/components/{ToastRegion/ToastContent.d.ts → Toast/ToastItem.d.ts} +7 -2
- package/dist/components/Toast/index.d.ts +6 -0
- package/dist/components/{ToastRegion → Toast}/index.js +2 -1
- package/dist/components/Tooltip/Tooltip.css.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +70 -67
- package/dist/style.css +1 -1
- package/dist/styles/typography.d.ts +32 -0
- package/dist/utils/animation.d.ts +0 -16
- package/dist/utils/animation.js +24 -50
- package/dist/utils/animation.js.map +1 -1
- package/package.json +2 -2
- package/dist/components/Banner/BannerSurface.d.ts +0 -17
- package/dist/components/Banner/BannerSurface.js +0 -65
- package/dist/components/Banner/BannerSurface.js.map +0 -1
- package/dist/components/ToastNotification/ToastNotification.css.d.ts +0 -17
- package/dist/components/ToastNotification/ToastNotification.css.js +0 -17
- package/dist/components/ToastNotification/ToastNotification.css.js.map +0 -1
- package/dist/components/ToastNotification/ToastNotification.d.ts +0 -55
- package/dist/components/ToastNotification/ToastNotification.js +0 -42
- package/dist/components/ToastNotification/ToastNotification.js.map +0 -1
- package/dist/components/ToastNotification/index.d.ts +0 -2
- package/dist/components/ToastRegion/ToastRegion.css.d.ts +0 -2
- package/dist/components/ToastRegion/ToastRegion.css.js +0 -7
- package/dist/components/ToastRegion/ToastRegion.css.js.map +0 -1
- package/dist/components/ToastRegion/ToastRegion.d.ts +0 -45
- package/dist/components/ToastRegion/ToastRegion.js +0 -38
- package/dist/components/ToastRegion/ToastRegion.js.map +0 -1
- package/dist/components/ToastRegion/ToastRegionItem.d.ts +0 -13
- package/dist/components/ToastRegion/ToastRegionItem.js +0 -49
- package/dist/components/ToastRegion/ToastRegionItem.js.map +0 -1
- package/dist/components/ToastRegion/ToastRegionLandmark.d.ts +0 -15
- package/dist/components/ToastRegion/ToastRegionLandmark.js +0 -62
- package/dist/components/ToastRegion/ToastRegionLandmark.js.map +0 -1
- package/dist/components/ToastRegion/index.d.ts +0 -4
|
@@ -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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CSSProperties, Ref } from "react";
|
|
2
|
+
import type { ToastQueue } from "react-stately";
|
|
3
|
+
import type { ToastItem } from "./ToastItem.js";
|
|
4
|
+
export interface ToastContainerProps {
|
|
5
|
+
/** The queue to display. Create one per surface with `new ToastQueue()`. */
|
|
6
|
+
queue: ToastQueue<ToastItem>;
|
|
7
|
+
/**
|
|
8
|
+
* Keys of the toasts that are leaving. Keep each one on the queue until
|
|
9
|
+
* `onExited` reports it, or it unmounts part-way through its travel.
|
|
10
|
+
*/
|
|
11
|
+
exiting: ReadonlySet<string>;
|
|
12
|
+
/** Runs when a leaving toast finishes its travel and can be closed. */
|
|
13
|
+
onExited: (key: string) => void;
|
|
14
|
+
/** Runs when the reader presses a toast's dismiss button. */
|
|
15
|
+
onDismiss: (key: string) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Overrides the region's accessible name. Leave it unset: the default is
|
|
18
|
+
* already localized and counts the toasts on show ("2 notifications."), which
|
|
19
|
+
* is what a screen-reader user hears on navigating here with F6.
|
|
20
|
+
*/
|
|
21
|
+
"aria-label"?: string;
|
|
22
|
+
className?: string;
|
|
23
|
+
style?: CSSProperties;
|
|
24
|
+
/** Attaches to the always-mounted anchor, not the region. */
|
|
25
|
+
ref?: Ref<HTMLDivElement>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Displays the toasts on a queue as a labelled landmark region.
|
|
29
|
+
*
|
|
30
|
+
* The container owns announcement, the card surface and the motion. It does not
|
|
31
|
+
* own the clock: the caller decides which toasts exist, when each one leaves, and
|
|
32
|
+
* what a dismiss press means. Mark a toast in `exiting` to start its travel, and
|
|
33
|
+
* take it off the queue when `onExited` reports it.
|
|
34
|
+
*
|
|
35
|
+
* No region renders while the queue is empty, so it does not sit in the
|
|
36
|
+
* accessibility tree between notifications. The anchor it renders into stays
|
|
37
|
+
* mounted regardless, carrying `data-react-aria-top-layer`: React Aria reads that
|
|
38
|
+
* attribute to decide what an open overlay hides, what a press outside an overlay
|
|
39
|
+
* counts as, and what a focus scope lets go. An anchor that came and went with the
|
|
40
|
+
* toasts would leave the consumer's chrome hidden, and a toast raised afterwards
|
|
41
|
+
* would mount inside that hidden subtree and never be announced.
|
|
42
|
+
*
|
|
43
|
+
* That exemption is why no region renders while a modal overlay is open. The
|
|
44
|
+
* region is anchored in the consumer's chrome, which the overlay paints over and
|
|
45
|
+
* seals off from the pointer, so a toast there would be announced and F6-reachable
|
|
46
|
+
* with a dismiss control nobody could press.
|
|
47
|
+
*/
|
|
48
|
+
export declare function ToastContainer({ queue, exiting, onExited, onDismiss, className, style, ref, "aria-label": ariaLabel, }: ToastContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { cx as e } from "../../utils/cx.js";
|
|
2
|
+
import { useEnterAnimation as t, useExitAnimation as n } from "../../utils/animation.js";
|
|
3
|
+
import { useHasOpenOverlay as r } from "../../hooks/overlayRegistry.js";
|
|
4
|
+
import { toastAnchor as i, toastCard as a } from "./Toast.css.js";
|
|
5
|
+
import { Toast as o } from "./Toast.js";
|
|
6
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
7
|
+
import { ButtonContext as c, TextContext as l, UNSTABLE_Toast as u, UNSTABLE_ToastList as d, UNSTABLE_ToastRegion as f, useSlottedContext as p } from "react-aria-components";
|
|
8
|
+
import { useCallback as m, useEffect as h, useLayoutEffect as g, useRef as _, useState as v } from "react";
|
|
9
|
+
import { UNSAFE_PortalProvider as y, useFocusVisible as b } from "react-aria";
|
|
10
|
+
//#region src/components/Toast/ToastContainer.tsx
|
|
11
|
+
function x({ status: e, icon: t, message: n, isExiting: r, onPress: i }) {
|
|
12
|
+
let a = p(c, "close"), u = p(l, "title"), [d, f] = v(!1);
|
|
13
|
+
return g(() => f(!0), []), /* @__PURE__ */ s(o, {
|
|
14
|
+
status: e,
|
|
15
|
+
icon: t,
|
|
16
|
+
onDismiss: i,
|
|
17
|
+
dismissDisabled: r,
|
|
18
|
+
dismissLabel: a?.["aria-label"],
|
|
19
|
+
messageProps: {
|
|
20
|
+
id: u && "id" in u ? u.id : void 0,
|
|
21
|
+
role: e === "error" ? "alert" : "status",
|
|
22
|
+
"aria-live": e === "error" ? "assertive" : "polite",
|
|
23
|
+
"aria-atomic": "true",
|
|
24
|
+
"aria-hidden": d ? void 0 : "true"
|
|
25
|
+
},
|
|
26
|
+
children: n
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function S(e) {
|
|
30
|
+
let t = e.closest("[role=\"region\"]"), n = [...t?.querySelectorAll("._1699160d") ?? []], r = n.indexOf(e);
|
|
31
|
+
if (r === -1) return t;
|
|
32
|
+
let i = (e) => !e.hasAttribute("data-exiting");
|
|
33
|
+
return n.slice(0, r).reverse().find(i) ?? n.slice(r + 1).find(i) ?? t;
|
|
34
|
+
}
|
|
35
|
+
function C({ toast: e, isExiting: r, onExited: i, onDismiss: o }) {
|
|
36
|
+
let c = _(null), l = t(c), d = n(c, !r), { isFocusVisible: f } = b();
|
|
37
|
+
h(() => {
|
|
38
|
+
r && !d && i(e.key);
|
|
39
|
+
}, [
|
|
40
|
+
r,
|
|
41
|
+
d,
|
|
42
|
+
i,
|
|
43
|
+
e.key
|
|
44
|
+
]), g(() => {
|
|
45
|
+
let e = c.current;
|
|
46
|
+
!r || !e || !f || e.contains(document.activeElement) && S(e)?.focus();
|
|
47
|
+
}, [r, f]), g(() => {
|
|
48
|
+
let e = c.current;
|
|
49
|
+
!r || !e || (e.setAttribute("inert", ""), e.setAttribute("aria-hidden", "true"), e.tabIndex = -1, e.removeAttribute("role"));
|
|
50
|
+
}, [r]);
|
|
51
|
+
let { status: p = "success", message: m, icon: v } = e.content;
|
|
52
|
+
return /* @__PURE__ */ s(u, {
|
|
53
|
+
toast: e,
|
|
54
|
+
ref: c,
|
|
55
|
+
className: a,
|
|
56
|
+
"data-entering": l || void 0,
|
|
57
|
+
"data-exiting": r || void 0,
|
|
58
|
+
children: /* @__PURE__ */ s(x, {
|
|
59
|
+
status: p,
|
|
60
|
+
icon: v,
|
|
61
|
+
message: m,
|
|
62
|
+
isExiting: r,
|
|
63
|
+
onPress: (t) => {
|
|
64
|
+
if (t.pointerType === "keyboard") {
|
|
65
|
+
let e = c.current;
|
|
66
|
+
e?.contains(document.activeElement) && S(e)?.focus();
|
|
67
|
+
}
|
|
68
|
+
o(e.key);
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function w({ queue: t, exiting: n, onExited: a, onDismiss: o, className: c, style: l, ref: u, "aria-label": p }) {
|
|
74
|
+
let [h, g] = v(null), _ = r(), b = m((e) => {
|
|
75
|
+
g(e), typeof u == "function" ? u(e) : u && (u.current = e);
|
|
76
|
+
}, [u]), x = m(() => h ?? document.body, [h]);
|
|
77
|
+
return /* @__PURE__ */ s("div", {
|
|
78
|
+
"data-react-aria-top-layer": "true",
|
|
79
|
+
ref: b,
|
|
80
|
+
className: e(i, c),
|
|
81
|
+
style: l,
|
|
82
|
+
children: h && !_ && /* @__PURE__ */ s(y, {
|
|
83
|
+
getContainer: x,
|
|
84
|
+
children: /* @__PURE__ */ s(f, {
|
|
85
|
+
queue: t,
|
|
86
|
+
"aria-label": p,
|
|
87
|
+
className: "_1699160b",
|
|
88
|
+
children: /* @__PURE__ */ s(d, {
|
|
89
|
+
className: "_1699160c",
|
|
90
|
+
children: ({ toast: e }) => /* @__PURE__ */ s(C, {
|
|
91
|
+
toast: e,
|
|
92
|
+
isExiting: n.has(e.key),
|
|
93
|
+
onExited: a,
|
|
94
|
+
onDismiss: o
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { w as ToastContainer };
|
|
103
|
+
|
|
104
|
+
//# sourceMappingURL=ToastContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastContainer.js","names":[],"sources":["../../../src/components/Toast/ToastContainer.tsx"],"sourcesContent":["import type { CSSProperties, Ref } from \"react\";\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseLayoutEffect,\n\tuseRef,\n\tuseState,\n} from \"react\";\nimport type { PressEvent } from \"react-aria\";\nimport { UNSAFE_PortalProvider, useFocusVisible } from \"react-aria\";\nimport {\n\tButtonContext,\n\tTextContext,\n\tUNSTABLE_Toast,\n\tUNSTABLE_ToastList,\n\tUNSTABLE_ToastRegion,\n\tuseSlottedContext,\n} from \"react-aria-components\";\nimport type { QueuedToast, ToastQueue } from \"react-stately\";\nimport { useHasOpenOverlay } from \"../../hooks/overlayRegistry.js\";\nimport { useEnterAnimation, useExitAnimation } from \"../../utils/animation.js\";\nimport { cx } from \"../../utils/cx.js\";\nimport { toastAnchor, toastCard, toastList, toastRegion } from \"./Toast.css.js\";\nimport { Toast } from \"./Toast.js\";\nimport type { ToastItem } from \"./ToastItem.js\";\n\nexport interface ToastContainerProps {\n\t/** The queue to display. Create one per surface with `new ToastQueue()`. */\n\tqueue: ToastQueue<ToastItem>;\n\t/**\n\t * Keys of the toasts that are leaving. Keep each one on the queue until\n\t * `onExited` reports it, or it unmounts part-way through its travel.\n\t */\n\texiting: ReadonlySet<string>;\n\t/** Runs when a leaving toast finishes its travel and can be closed. */\n\tonExited: (key: string) => void;\n\t/** Runs when the reader presses a toast's dismiss button. */\n\tonDismiss: (key: string) => void;\n\t/**\n\t * Overrides the region's accessible name. Leave it unset: the default is\n\t * already localized and counts the toasts on show (\"2 notifications.\"), which\n\t * is what a screen-reader user hears on navigating here with F6.\n\t */\n\t\"aria-label\"?: string;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\t/** Attaches to the always-mounted anchor, not the region. */\n\tref?: Ref<HTMLDivElement>;\n}\n\ninterface ToastCardProps {\n\ttoast: QueuedToast<ToastItem>;\n\tisExiting: boolean;\n\tonExited: (key: string) => void;\n\tonDismiss: (key: string) => void;\n}\n\n/**\n * The card's own dismiss control, named from the one React Aria would have\n * rendered.\n *\n * React Aria hands its close button down through `ButtonContext` under a `close`\n * slot, carrying both the localized name and a press handler that closes the\n * toast outright. `mergeProps` chains `on*` handlers rather than replacing them,\n * so a React Aria button given the container's handler would run both and take\n * the card off the queue before it could travel. Taking the name alone leaves the\n * lifetime with the caller.\n */\nfunction ToastDismiss({\n\tstatus,\n\ticon,\n\tmessage,\n\tisExiting,\n\tonPress,\n}: {\n\tstatus: NonNullable<ToastItem[\"status\"]>;\n\ticon: ToastItem[\"icon\"];\n\tmessage: ToastItem[\"message\"];\n\tisExiting: boolean;\n\tonPress: (event: PressEvent) => void;\n}) {\n\tconst closeButton = useSlottedContext(ButtonContext, \"close\");\n\t// React Aria names the card through `aria-labelledby`, pointing at the id it\n\t// hands down under the `title` slot. Nothing here renders its `Text`, so the\n\t// message has to carry that id or the card has no accessible name at all.\n\tconst title = useSlottedContext(TextContext, \"title\");\n\t// React Aria hides its own content element on the first render and reveals it\n\t// on the next, which is what makes NVDA announce a toast that mounts with its\n\t// text already in place. Those props reach that element through a context the\n\t// package does not export, so the reveal is repeated here.\n\tconst [isRevealed, setIsRevealed] = useState(false);\n\tuseLayoutEffect(() => setIsRevealed(true), []);\n\treturn (\n\t\t<Toast\n\t\t\tstatus={status}\n\t\t\ticon={icon}\n\t\t\tonDismiss={onPress}\n\t\t\t// The card carries `inert` by now, but WebKit added `inert` in 15.5,\n\t\t\t// after the iOS 15.4 floor in `messaging/vite.browser-targets.mjs`. At\n\t\t\t// that floor the button stays tabbable and offers a press that no longer\n\t\t\t// acts on anything, so it has to be disabled in its own right.\n\t\t\tdismissDisabled={isExiting}\n\t\t\tdismissLabel={closeButton?.[\"aria-label\"]}\n\t\t\t// The live region rides the message box itself. React Aria's own\n\t\t\t// `ToastContent` would need `display: contents` to stay out of the card's\n\t\t\t// row, and WebKit drops a box-less element from the accessibility tree\n\t\t\t// until 16, below the floor above, so the announcement would never reach\n\t\t\t// the reader there.\n\t\t\tmessageProps={{\n\t\t\t\tid: title && \"id\" in title ? title.id : undefined,\n\t\t\t\t// React Aria hardcodes `role=\"alert\"` for every toast, which interrupts\n\t\t\t\t// the reader whatever the outcome. The queue is one shared surface, so\n\t\t\t\t// urgency is chosen per card: a failure interrupts, anything else waits\n\t\t\t\t// its turn.\n\t\t\t\trole: status === \"error\" ? \"alert\" : \"status\",\n\t\t\t\t\"aria-live\": status === \"error\" ? \"assertive\" : \"polite\",\n\t\t\t\t\"aria-atomic\": \"true\",\n\t\t\t\t\"aria-hidden\": isRevealed ? undefined : \"true\",\n\t\t\t}}\n\t\t>\n\t\t\t{message}\n\t\t</Toast>\n\t);\n}\n\n/**\n * Where focus goes when the card under it leaves: the next card down the stack,\n * then the one above it, then the region itself. Landing on the region keeps\n * focus inside it, so React Aria still holds the element the reader came from and\n * restores it once the last card has gone.\n */\nfunction nextFocusTarget(element: HTMLElement): HTMLElement | null {\n\tconst region = element.closest<HTMLElement>('[role=\"region\"]');\n\t// React Aria wraps each card in a list item of its own, so the cards are read\n\t// off the region rather than from the element's own parent.\n\tconst cards = [\n\t\t...(region?.querySelectorAll<HTMLElement>(`.${toastCard}`) ?? []),\n\t];\n\tconst index = cards.indexOf(element);\n\tif (index === -1) {\n\t\treturn region;\n\t}\n\tconst settled = (card: HTMLElement) => !card.hasAttribute(\"data-exiting\");\n\t// `toastList` is `column-reverse`, so a higher DOM index sits visually above\n\t// and a lower one below. Take the card below first, nearest first, then walk\n\t// up, so focus lands on the card that rises into the freed row.\n\treturn (\n\t\tcards.slice(0, index).reverse().find(settled) ??\n\t\tcards.slice(index + 1).find(settled) ??\n\t\tregion\n\t);\n}\n\nfunction ToastCard({ toast, isExiting, onExited, onDismiss }: ToastCardProps) {\n\tconst ref = useRef<HTMLDivElement>(null);\n\t// The card rises in from `[data-entering]` and falls back out to\n\t// `[data-exiting]`, both off-screen, with a transition between. A transition\n\t// resumes from the current computed value, so a card dismissed mid-entry\n\t// reverses from wherever it stands. `useExitAnimation` and `useEnterAnimation`\n\t// watch the same transition, the way `BannerContainerSlide` does.\n\tconst isEntering = useEnterAnimation(ref);\n\tconst isLeaving = useExitAnimation(ref, !isExiting);\n\tconst { isFocusVisible } = useFocusVisible();\n\n\tuseEffect(() => {\n\t\tif (isExiting && !isLeaving) {\n\t\t\tonExited(toast.key);\n\t\t}\n\t}, [isExiting, isLeaving, onExited, toast.key]);\n\n\t// `inert` below drops the focus it holds to the document body. React Aria moves\n\t// focus for a toast that leaves the queue, and the card stays on the queue until\n\t// its travel is over, so the reader is handed on from here instead. It runs\n\t// before the effect below, which is what leaves it a card to read focus off.\n\t//\n\t// Only for a reader working the keyboard, though. A dismiss button focuses\n\t// itself under a mouse press in Chrome, so handing that on would park an\n\t// invisible focus on the card left standing, and a consumer that reads focus as\n\t// the reader asking for more time would hold its countdown there for as long as\n\t// the reader left the page alone.\n\tuseLayoutEffect(() => {\n\t\tconst element = ref.current;\n\t\tif (!isExiting || !element || !isFocusVisible) {\n\t\t\treturn;\n\t\t}\n\t\tif (element.contains(document.activeElement)) {\n\t\t\tnextFocusTarget(element)?.focus();\n\t\t}\n\t}, [isExiting, isFocusVisible]);\n\n\t// The caller has already let the card go, so it is on screen only to finish its\n\t// travel. `inert` takes it out of the accessibility tree, out of the tab order\n\t// and away from the pointer in one attribute. WebKit added `inert` in 15.5, and\n\t// the floor in `messaging/vite.browser-targets.mjs` is 15.4, so `role` and\n\t// `tabIndex` come off the element as well. React Aria pins both through props,\n\t// and a card never comes back from leaving, so nothing puts them back.\n\tuseLayoutEffect(() => {\n\t\tconst element = ref.current;\n\t\tif (!isExiting || !element) {\n\t\t\treturn;\n\t\t}\n\t\telement.setAttribute(\"inert\", \"\");\n\t\t// At the 15.4 floor `inert` does nothing, so the card would keep announcing\n\t\t// and stay in the reader's tree for the whole of its travel.\n\t\telement.setAttribute(\"aria-hidden\", \"true\");\n\t\telement.tabIndex = -1;\n\t\telement.removeAttribute(\"role\");\n\t}, [isExiting]);\n\n\tconst { status = \"success\", message, icon } = toast.content;\n\n\treturn (\n\t\t<UNSTABLE_Toast\n\t\t\ttoast={toast}\n\t\t\tref={ref}\n\t\t\tclassName={toastCard}\n\t\t\tdata-entering={isEntering || undefined}\n\t\t\tdata-exiting={isExiting || undefined}\n\t\t>\n\t\t\t<ToastDismiss\n\t\t\t\tstatus={status}\n\t\t\t\ticon={icon}\n\t\t\t\tmessage={message}\n\t\t\t\tisExiting={isExiting}\n\t\t\t\tonPress={(event) => {\n\t\t\t\t\t// The exit re-render disables this button, and a native disabled\n\t\t\t\t\t// button drops its focus to the document body in the same commit,\n\t\t\t\t\t// before the layout effect below can read focus off the card. Hand a\n\t\t\t\t\t// keyboard reader on here, while the button still holds focus.\n\t\t\t\t\tif (event.pointerType === \"keyboard\") {\n\t\t\t\t\t\tconst element = ref.current;\n\t\t\t\t\t\tif (element?.contains(document.activeElement)) {\n\t\t\t\t\t\t\tnextFocusTarget(element)?.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tonDismiss(toast.key);\n\t\t\t\t}}\n\t\t\t/>\n\t\t</UNSTABLE_Toast>\n\t);\n}\n\n/**\n * Displays the toasts on a queue as a labelled landmark region.\n *\n * The container owns announcement, the card surface and the motion. It does not\n * own the clock: the caller decides which toasts exist, when each one leaves, and\n * what a dismiss press means. Mark a toast in `exiting` to start its travel, and\n * take it off the queue when `onExited` reports it.\n *\n * No region renders while the queue is empty, so it does not sit in the\n * accessibility tree between notifications. The anchor it renders into stays\n * mounted regardless, carrying `data-react-aria-top-layer`: React Aria reads that\n * attribute to decide what an open overlay hides, what a press outside an overlay\n * counts as, and what a focus scope lets go. An anchor that came and went with the\n * toasts would leave the consumer's chrome hidden, and a toast raised afterwards\n * would mount inside that hidden subtree and never be announced.\n *\n * That exemption is why no region renders while a modal overlay is open. The\n * region is anchored in the consumer's chrome, which the overlay paints over and\n * seals off from the pointer, so a toast there would be announced and F6-reachable\n * with a dismiss control nobody could press.\n */\nexport function ToastContainer({\n\tqueue,\n\texiting,\n\tonExited,\n\tonDismiss,\n\tclassName,\n\tstyle,\n\tref,\n\t\"aria-label\": ariaLabel,\n}: ToastContainerProps) {\n\tconst [anchor, setAnchor] = useState<HTMLDivElement | null>(null);\n\tconst hasOpenOverlay = useHasOpenOverlay();\n\n\tconst attachAnchor = useCallback(\n\t\t(node: HTMLDivElement | null) => {\n\t\t\tsetAnchor(node);\n\t\t\tif (typeof ref === \"function\") {\n\t\t\t\tref(node);\n\t\t\t} else if (ref) {\n\t\t\t\tref.current = node;\n\t\t\t}\n\t\t},\n\t\t[ref],\n\t);\n\n\t// React Aria's region portals itself through whatever `UNSAFE_PortalProvider`\n\t// it finds, and a consumer that scopes one to its app root would take the\n\t// toasts out of this container entirely. Pointing a nested provider at the\n\t// anchor keeps them where the consumer placed them.\n\tconst getContainer = useCallback(() => anchor ?? document.body, [anchor]);\n\n\treturn (\n\t\t<div\n\t\t\tdata-react-aria-top-layer=\"true\"\n\t\t\tref={attachAnchor}\n\t\t\tclassName={cx(toastAnchor, className)}\n\t\t\tstyle={style}\n\t\t>\n\t\t\t{anchor && !hasOpenOverlay && (\n\t\t\t\t<UNSAFE_PortalProvider getContainer={getContainer}>\n\t\t\t\t\t<UNSTABLE_ToastRegion\n\t\t\t\t\t\tqueue={queue}\n\t\t\t\t\t\taria-label={ariaLabel}\n\t\t\t\t\t\tclassName={toastRegion}\n\t\t\t\t\t>\n\t\t\t\t\t\t<UNSTABLE_ToastList<ToastItem> className={toastList}>\n\t\t\t\t\t\t\t{({ toast }) => (\n\t\t\t\t\t\t\t\t<ToastCard\n\t\t\t\t\t\t\t\t\ttoast={toast}\n\t\t\t\t\t\t\t\t\tisExiting={exiting.has(toast.key)}\n\t\t\t\t\t\t\t\t\tonExited={onExited}\n\t\t\t\t\t\t\t\t\tonDismiss={onDismiss}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</UNSTABLE_ToastList>\n\t\t\t\t\t</UNSTABLE_ToastRegion>\n\t\t\t\t</UNSAFE_PortalProvider>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"mappings":"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"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import type { ToastStatus } from "../
|
|
2
|
+
import type { ToastStatus } from "../Toast/Toast.js";
|
|
3
3
|
/** What a caller puts on the queue via `queue.add(content, options)`. */
|
|
4
|
-
export interface
|
|
4
|
+
export interface ToastItem {
|
|
5
5
|
/** The message to announce and display. */
|
|
6
6
|
message: ReactNode;
|
|
7
7
|
/** The outcome being reported. Defaults to `success`. */
|
|
8
8
|
status?: ToastStatus;
|
|
9
|
+
/**
|
|
10
|
+
* The glyph for `status: "custom"`. Compose it with `<Icon>`; ignored for
|
|
11
|
+
* every other status.
|
|
12
|
+
*/
|
|
13
|
+
icon?: ReactNode;
|
|
9
14
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { ToastOptions } from "react-stately";
|
|
2
|
+
export { ToastQueue } from "react-stately";
|
|
3
|
+
export type { ToastProps, ToastStatus } from "./Toast.js";
|
|
4
|
+
export { Toast } from "./Toast.js";
|
|
5
|
+
export { ToastContainer, type ToastContainerProps } from "./ToastContainer.js";
|
|
6
|
+
export type { ToastItem } from "./ToastItem.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.css.js","names":[],"sources":["../../../src/components/Tooltip/Tooltip.css.ts"],"sourcesContent":["import { globalStyle, style } from \"@vanilla-extract/css\";\nimport { t } from \"../../tokens/index.js\";\n\n// A filter, not a box-shadow, so the shadow wraps the arrow silhouette rather than\n// just the rectangular bubble.\nconst TOOLTIP_SHADOW = t(\"elevation-2-filter\");\n\nexport const tooltip = style({\n\tboxSizing: \"border-box\",\n\tmaxWidth: \"184px\",\n\tpadding: t(\"spacing-8\"),\n\tborderRadius: t(\"border-radius-6\"),\n\tbackgroundColor: t(\"color-background-inverse\"),\n\tcolor: t(\"color-content-inverse\"),\n\
|
|
1
|
+
{"version":3,"file":"Tooltip.css.js","names":[],"sources":["../../../src/components/Tooltip/Tooltip.css.ts"],"sourcesContent":["import { globalStyle, style } from \"@vanilla-extract/css\";\nimport { typography } from \"../../styles/typography.js\";\nimport { t } from \"../../tokens/index.js\";\n\n// A filter, not a box-shadow, so the shadow wraps the arrow silhouette rather than\n// just the rectangular bubble.\nconst TOOLTIP_SHADOW = t(\"elevation-2-filter\");\n\nexport const tooltip = style({\n\tboxSizing: \"border-box\",\n\tmaxWidth: \"184px\",\n\tpadding: t(\"spacing-8\"),\n\tborderRadius: t(\"border-radius-6\"),\n\tbackgroundColor: t(\"color-background-inverse\"),\n\tcolor: t(\"color-content-inverse\"),\n\t...typography(\"caption\", \"regular\"),\n\ttextAlign: \"center\",\n\twordBreak: \"break-word\",\n\tfilter: TOOLTIP_SHADOW,\n\tselectors: {\n\t\t\"&[data-entering]\": { opacity: 0 },\n\t\t\"&[data-exiting]\": { opacity: 0 },\n\t},\n\t\"@media\": {\n\t\t\"(prefers-reduced-motion: no-preference)\": {\n\t\t\ttransition: `opacity ${t(\"duration-fast\")} ${t(\"easing-standard\")}`,\n\t\t},\n\t},\n});\n\nexport const arrow = style({\n\tdisplay: \"block\",\n});\n\n// The triangle's apex points down (correct for a tooltip above its trigger);\n// each placement rotates it to point back at the trigger.\nexport const arrowSvg = style({\n\tdisplay: \"block\",\n\tfill: t(\"color-background-inverse\"),\n});\n\nglobalStyle(`${tooltip}[data-placement^=\"top\"] ${arrowSvg}`, {\n\ttransform: \"rotate(0deg)\",\n});\nglobalStyle(`${tooltip}[data-placement^=\"bottom\"] ${arrowSvg}`, {\n\ttransform: \"rotate(180deg)\",\n});\nglobalStyle(`${tooltip}[data-placement^=\"left\"] ${arrowSvg}`, {\n\ttransform: \"rotate(-90deg)\",\n});\nglobalStyle(`${tooltip}[data-placement^=\"right\"] ${arrowSvg}`, {\n\ttransform: \"rotate(90deg)\",\n});\n"],"mappings":""}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { useRegisterOverlay } from "./overlayRegistry.js";
|
|
1
|
+
export { useHasOpenOverlay, useRegisterOverlay, } from "./overlayRegistry.js";
|
|
2
2
|
export { readPrefersReducedMotion, usePrefersReducedMotion, } from "./usePrefersReducedMotion.js";
|
|
3
3
|
export { useSubmitOnEnter } from "./useSubmitOnEnter.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -29,9 +29,9 @@ export * from "./components/Sheet/index.js";
|
|
|
29
29
|
export * from "./components/SheetOverlay/index.js";
|
|
30
30
|
export * from "./components/Spinner/index.js";
|
|
31
31
|
export * from "./components/Survey/index.js";
|
|
32
|
+
export * from "./components/Text/index.js";
|
|
32
33
|
export * from "./components/ThinkingShimmer/index.js";
|
|
33
|
-
export * from "./components/
|
|
34
|
-
export * from "./components/ToastRegion/index.js";
|
|
34
|
+
export * from "./components/Toast/index.js";
|
|
35
35
|
export * from "./components/Toggle/index.js";
|
|
36
36
|
export * from "./components/Tooltip/index.js";
|
|
37
37
|
export * from "./components/TypingIndicator/index.js";
|
package/dist/index.js
CHANGED
|
@@ -2,58 +2,58 @@ import { AgentMessage as e } from "./components/AgentMessage/AgentMessage.js";
|
|
|
2
2
|
import { AttachmentChip as t } from "./components/AttachmentChip/AttachmentChip.js";
|
|
3
3
|
import { AvatarPlaceholder as n } from "./components/Avatar/AvatarPlaceholder.js";
|
|
4
4
|
import { Avatar as r } from "./components/Avatar/Avatar.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { ChevronLeft as
|
|
17
|
-
import { ChevronRight as
|
|
18
|
-
import { CloudUpload as
|
|
19
|
-
import { Document as
|
|
20
|
-
import { Download as
|
|
21
|
-
import { Ellipses as
|
|
22
|
-
import { Email as
|
|
23
|
-
import { ExclamationSync as
|
|
24
|
-
import { ExclamationTriangle as
|
|
25
|
-
import { Eye as
|
|
26
|
-
import { EyeSlash as
|
|
27
|
-
import { Language as
|
|
28
|
-
import { MediaSlash as
|
|
29
|
-
import { MessagingFill as
|
|
30
|
-
import { Minimize as
|
|
31
|
-
import { Mute as
|
|
32
|
-
import { Paperclip as
|
|
33
|
-
import { PersonFill as
|
|
34
|
-
import { PlayFill as
|
|
35
|
-
import { SendFill as
|
|
36
|
-
import { StarBadgeFill as
|
|
37
|
-
import { ThumbsDown as
|
|
38
|
-
import { ThumbsUp as
|
|
39
|
-
import { Volume as
|
|
40
|
-
import { Xmark as
|
|
41
|
-
import { XmarkCircle as
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
5
|
+
import { Icon as i } from "./components/Icon/Icon.js";
|
|
6
|
+
import { AdaLogo as a } from "./components/Icon/icons/AdaLogo.js";
|
|
7
|
+
import { ArrowDown as o } from "./components/Icon/icons/ArrowDown.js";
|
|
8
|
+
import { ArrowLeft as s } from "./components/Icon/icons/ArrowLeft.js";
|
|
9
|
+
import { ArrowNortheast as c } from "./components/Icon/icons/ArrowNortheast.js";
|
|
10
|
+
import { ArrowNorthwest as l } from "./components/Icon/icons/ArrowNorthwest.js";
|
|
11
|
+
import { ArrowRight as u } from "./components/Icon/icons/ArrowRight.js";
|
|
12
|
+
import { Bell as d } from "./components/Icon/icons/Bell.js";
|
|
13
|
+
import { BellSlash as f } from "./components/Icon/icons/BellSlash.js";
|
|
14
|
+
import { Checkmark as p } from "./components/Icon/icons/Checkmark.js";
|
|
15
|
+
import { CheckmarkCircle as m } from "./components/Icon/icons/CheckmarkCircle.js";
|
|
16
|
+
import { ChevronLeft as h } from "./components/Icon/icons/ChevronLeft.js";
|
|
17
|
+
import { ChevronRight as g } from "./components/Icon/icons/ChevronRight.js";
|
|
18
|
+
import { CloudUpload as _ } from "./components/Icon/icons/CloudUpload.js";
|
|
19
|
+
import { Document as v } from "./components/Icon/icons/Document.js";
|
|
20
|
+
import { Download as y } from "./components/Icon/icons/Download.js";
|
|
21
|
+
import { Ellipses as b } from "./components/Icon/icons/Ellipses.js";
|
|
22
|
+
import { Email as x } from "./components/Icon/icons/Email.js";
|
|
23
|
+
import { ExclamationSync as S } from "./components/Icon/icons/ExclamationSync.js";
|
|
24
|
+
import { ExclamationTriangle as C } from "./components/Icon/icons/ExclamationTriangle.js";
|
|
25
|
+
import { Eye as w } from "./components/Icon/icons/Eye.js";
|
|
26
|
+
import { EyeSlash as T } from "./components/Icon/icons/EyeSlash.js";
|
|
27
|
+
import { Language as E } from "./components/Icon/icons/Language.js";
|
|
28
|
+
import { MediaSlash as D } from "./components/Icon/icons/MediaSlash.js";
|
|
29
|
+
import { MessagingFill as O } from "./components/Icon/icons/MessagingFill.js";
|
|
30
|
+
import { Minimize as k } from "./components/Icon/icons/Minimize.js";
|
|
31
|
+
import { Mute as A } from "./components/Icon/icons/Mute.js";
|
|
32
|
+
import { Paperclip as j } from "./components/Icon/icons/Paperclip.js";
|
|
33
|
+
import { PersonFill as M } from "./components/Icon/icons/PersonFill.js";
|
|
34
|
+
import { PlayFill as N } from "./components/Icon/icons/PlayFill.js";
|
|
35
|
+
import { SendFill as P } from "./components/Icon/icons/SendFill.js";
|
|
36
|
+
import { StarBadgeFill as F } from "./components/Icon/icons/StarBadgeFill.js";
|
|
37
|
+
import { ThumbsDown as I } from "./components/Icon/icons/ThumbsDown.js";
|
|
38
|
+
import { ThumbsUp as L } from "./components/Icon/icons/ThumbsUp.js";
|
|
39
|
+
import { Volume as R } from "./components/Icon/icons/Volume.js";
|
|
40
|
+
import { Xmark as z } from "./components/Icon/icons/Xmark.js";
|
|
41
|
+
import { XmarkCircle as B } from "./components/Icon/icons/XmarkCircle.js";
|
|
42
|
+
import { Banner as V } from "./components/Banner/Banner.js";
|
|
43
|
+
import { BannerContainer as H } from "./components/Banner/BannerContainer.js";
|
|
44
|
+
import { useHasOpenOverlay as U, useRegisterOverlay as W } from "./hooks/overlayRegistry.js";
|
|
45
|
+
import { BubbleOverlay as G } from "./components/BubbleOverlay/BubbleOverlay.js";
|
|
46
|
+
import { Button as K } from "./components/Button/Button.js";
|
|
47
|
+
import { Checkbox as q } from "./components/Checkbox/Checkbox.js";
|
|
48
|
+
import { CheckboxGroup as J } from "./components/Checkbox/CheckboxGroup.js";
|
|
49
|
+
import { Chip as Y } from "./components/Chip/Chip.js";
|
|
50
|
+
import { Dialog as X } from "./components/Dialog/Dialog.js";
|
|
51
|
+
import { DialogOverlay as Z } from "./components/DialogOverlay/DialogOverlay.js";
|
|
52
|
+
import { Divider as Q } from "./components/Divider/Divider.js";
|
|
53
|
+
import { DropZone as $ } from "./components/DropZone/DropZone.js";
|
|
54
|
+
import { FullscreenOverlay as ee } from "./components/FullscreenOverlay/FullscreenOverlay.js";
|
|
55
|
+
import { Header as te } from "./components/Header/Header.js";
|
|
56
|
+
import { IconButton as ne } from "./components/IconButton/IconButton.js";
|
|
57
57
|
import { Image as re } from "./components/Image/Image.js";
|
|
58
58
|
import { Input as ie } from "./components/Input/Input.js";
|
|
59
59
|
import { Link as ae } from "./components/Link/Link.js";
|
|
@@ -69,18 +69,21 @@ import { RadioGroup as me } from "./components/Radio/RadioGroup.js";
|
|
|
69
69
|
import { ScrollMarker as he } from "./components/ScrollMarker/ScrollMarker.js";
|
|
70
70
|
import { Sheet as ge } from "./components/Sheet/Sheet.js";
|
|
71
71
|
import { SheetOverlay as _e } from "./components/SheetOverlay/SheetOverlay.js";
|
|
72
|
-
import {
|
|
73
|
-
import {
|
|
74
|
-
import {
|
|
75
|
-
import {
|
|
76
|
-
import {
|
|
77
|
-
import {
|
|
78
|
-
import {
|
|
79
|
-
import {
|
|
80
|
-
import {
|
|
81
|
-
import {
|
|
82
|
-
import {
|
|
83
|
-
import {
|
|
84
|
-
import {
|
|
85
|
-
import {
|
|
86
|
-
|
|
72
|
+
import { readPrefersReducedMotion as ve, usePrefersReducedMotion as ye } from "./hooks/usePrefersReducedMotion.js";
|
|
73
|
+
import { useSubmitOnEnter as be } from "./hooks/useSubmitOnEnter.js";
|
|
74
|
+
import { Spinner as xe } from "./components/Spinner/Spinner.js";
|
|
75
|
+
import { SurveyRating as Se } from "./components/Survey/SurveyRating/SurveyRating.js";
|
|
76
|
+
import { SurveySelect as Ce } from "./components/Survey/SurveySelect/SurveySelect.js";
|
|
77
|
+
import { Text as we } from "./components/Text/Text.js";
|
|
78
|
+
import { ThinkingShimmer as Te } from "./components/ThinkingShimmer/ThinkingShimmer.js";
|
|
79
|
+
import { Toast as Ee } from "./components/Toast/Toast.js";
|
|
80
|
+
import { ToastContainer as De } from "./components/Toast/ToastContainer.js";
|
|
81
|
+
import { ToastQueue as Oe } from "./components/Toast/index.js";
|
|
82
|
+
import { Toggle as ke } from "./components/Toggle/Toggle.js";
|
|
83
|
+
import { Tooltip as Ae, TooltipTrigger as je } from "./components/Tooltip/Tooltip.js";
|
|
84
|
+
import { TypingIndicator as Me } from "./components/TypingIndicator/TypingIndicator.js";
|
|
85
|
+
import { UserMessage as Ne } from "./components/UserMessage/UserMessage.js";
|
|
86
|
+
import { VideoMessage as Pe } from "./components/VideoMessage/VideoMessage.js";
|
|
87
|
+
import { LOVELACE_SURFACES as Fe, contrastRatioBetween as Ie, createBrandOverrides as Le, isLegibleAgainst as Re, isLegibleOnSurface as ze, readableTextOnAccent as Be } from "./runtime/branding.js";
|
|
88
|
+
import { LovelaceProvider as Ve, useResolvedTheme as He } from "./runtime/LovelaceProvider.js";
|
|
89
|
+
export { a as AdaLogo, e as AgentMessage, o as ArrowDown, s as ArrowLeft, c as ArrowNortheast, l as ArrowNorthwest, u as ArrowRight, t as AttachmentChip, r as Avatar, n as AvatarPlaceholder, V as Banner, H as BannerContainer, d as Bell, f as BellSlash, G as BubbleOverlay, K as Button, q as Checkbox, J as CheckboxGroup, p as Checkmark, m as CheckmarkCircle, h as ChevronLeft, g as ChevronRight, Y as Chip, _ as CloudUpload, X as Dialog, Z as DialogOverlay, Q as Divider, v as Document, y as Download, $ as DropZone, b as Ellipses, x as Email, S as ExclamationSync, C as ExclamationTriangle, w as Eye, T as EyeSlash, ee as FullscreenOverlay, te as Header, i as Icon, ne as IconButton, re as Image, ie as Input, Fe as LOVELACE_SURFACES, E as Language, ae as Link, Ve as LovelaceProvider, D as MediaSlash, oe as Menu, se as MenuItem, ce as MessageError, le as MessageRow, O as MessagingFill, k as Minimize, A as Mute, j as Paperclip, M as PersonFill, ue as PictureMessage, de as PillButton, N as PlayFill, fe as ProactiveMessage, pe as Radio, me as RadioGroup, he as ScrollMarker, P as SendFill, ge as Sheet, _e as SheetOverlay, xe as Spinner, F as StarBadgeFill, Se as SurveyRating, Ce as SurveySelect, we as Text, Te as ThinkingShimmer, I as ThumbsDown, L as ThumbsUp, Ee as Toast, De as ToastContainer, Oe as ToastQueue, ke as Toggle, Ae as Tooltip, je as TooltipTrigger, Me as TypingIndicator, Ne as UserMessage, Pe as VideoMessage, R as Volume, z as Xmark, B as XmarkCircle, Ie as contrastRatioBetween, Le as createBrandOverrides, Re as isLegibleAgainst, ze as isLegibleOnSurface, ve as readPrefersReducedMotion, Be as readableTextOnAccent, U as useHasOpenOverlay, ye as usePrefersReducedMotion, W as useRegisterOverlay, He as useResolvedTheme, be as useSubmitOnEnter };
|