@ada-cx/lovelace 1.3.0 → 1.5.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/Banner/Banner.css.d.ts +1 -0
- package/dist/components/Banner/Banner.css.js +7 -0
- package/dist/components/Banner/Banner.css.js.map +1 -0
- package/dist/components/Banner/Banner.d.ts +51 -0
- package/dist/components/Banner/Banner.js +25 -0
- package/dist/components/Banner/Banner.js.map +1 -0
- package/dist/components/Banner/BannerSurface.d.ts +17 -0
- package/dist/components/Banner/BannerSurface.js +65 -0
- package/dist/components/Banner/BannerSurface.js.map +1 -0
- package/dist/components/Banner/index.d.ts +1 -0
- package/dist/components/BubbleOverlay/BubbleOverlay.js +21 -20
- package/dist/components/BubbleOverlay/BubbleOverlay.js.map +1 -1
- package/dist/components/Dialog/DialogIcon.js +5 -5
- package/dist/components/DialogOverlay/DialogOverlay.js +23 -22
- package/dist/components/DialogOverlay/DialogOverlay.js.map +1 -1
- package/dist/components/FullscreenOverlay/FullscreenOverlay.js +21 -20
- package/dist/components/FullscreenOverlay/FullscreenOverlay.js.map +1 -1
- package/dist/components/Input/InputRoot.js +4 -4
- package/dist/components/Input/InputTextArea.js +7 -7
- package/dist/components/MenuItem/MenuItemRoot.js +9 -9
- package/dist/components/Sheet/SheetBody.d.ts +3 -1
- package/dist/components/Sheet/SheetBody.js +5 -4
- package/dist/components/Sheet/SheetBody.js.map +1 -1
- package/dist/components/SheetOverlay/SheetOverlay.d.ts +3 -1
- package/dist/components/SheetOverlay/SheetOverlay.js +22 -20
- package/dist/components/SheetOverlay/SheetOverlay.js.map +1 -1
- package/dist/components/ToastNotification/ToastNotification.css.d.ts +1 -14
- package/dist/components/ToastNotification/ToastNotification.css.js +1 -9
- package/dist/components/ToastNotification/ToastNotification.css.js.map +1 -1
- package/dist/components/ToastNotification/ToastNotification.d.ts +30 -11
- package/dist/components/ToastNotification/ToastNotification.js +29 -18
- package/dist/components/ToastNotification/ToastNotification.js.map +1 -1
- package/dist/components/ToastNotification/index.d.ts +1 -1
- package/dist/components/ToastRegion/ToastContent.d.ts +9 -0
- package/dist/components/ToastRegion/ToastRegion.css.d.ts +2 -0
- package/dist/components/ToastRegion/ToastRegion.css.js +7 -0
- package/dist/components/ToastRegion/ToastRegion.css.js.map +1 -0
- package/dist/components/ToastRegion/ToastRegion.d.ts +45 -0
- package/dist/components/ToastRegion/ToastRegion.js +38 -0
- package/dist/components/ToastRegion/ToastRegion.js.map +1 -0
- package/dist/components/ToastRegion/ToastRegionItem.d.ts +13 -0
- package/dist/components/ToastRegion/ToastRegionItem.js +49 -0
- package/dist/components/ToastRegion/ToastRegionItem.js.map +1 -0
- package/dist/components/ToastRegion/ToastRegionLandmark.d.ts +15 -0
- package/dist/components/ToastRegion/ToastRegionLandmark.js +62 -0
- package/dist/components/ToastRegion/ToastRegionLandmark.js.map +1 -0
- package/dist/components/ToastRegion/index.d.ts +4 -0
- package/dist/components/ToastRegion/index.js +3 -0
- package/dist/components/Tooltip/Tooltip.js +8 -8
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/overlayRegistry.d.ts +22 -0
- package/dist/hooks/overlayRegistry.js +32 -0
- package/dist/hooks/overlayRegistry.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +76 -72
- package/dist/runtime/LovelaceProvider.js +12 -12
- package/dist/style.css +1 -1
- package/dist/utils/animation.d.ts +28 -0
- package/dist/utils/animation.js +68 -0
- package/dist/utils/animation.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* True until the element's entrance animation finishes. Style the "from" state
|
|
4
|
+
* off `[data-entering]`; removing the attribute is what starts the transition.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useEnterAnimation(ref: RefObject<HTMLElement | null>): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* True while the element plays its exit animation after `isPresent` goes false.
|
|
9
|
+
* Keep the element mounted until it returns false, and style the "to" state off
|
|
10
|
+
* `[data-exiting]`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useExitAnimation(ref: RefObject<HTMLElement | null>, isPresent: boolean): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The height to render the element at while it arrives or leaves, or null once it
|
|
15
|
+
* is settled and its own content should size it.
|
|
16
|
+
*
|
|
17
|
+
* A surface whose box already holds its full height reports the space before it
|
|
18
|
+
* arrives and keeps it after it leaves: whatever sits below jumps a full height at
|
|
19
|
+
* once, then waits out the travel against a gap. Animating the height moves that
|
|
20
|
+
* content in step with the surface instead.
|
|
21
|
+
*
|
|
22
|
+
* The height has to be measured, since a transition cannot run from `auto`. Each
|
|
23
|
+
* direction sets its start value in the commit that changed `isPresent`, then its
|
|
24
|
+
* end value on the next frame, so the browser has something to interpolate from.
|
|
25
|
+
* An arriving surface drops back to `null` once its transition ends, so a later
|
|
26
|
+
* change to its content can size it again.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useSlideHeight(ref: RefObject<HTMLElement | null>, isPresent: boolean): number | null;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { readPrefersReducedMotion as e } from "../hooks/usePrefersReducedMotion.js";
|
|
2
|
+
import { useCallback as t, useLayoutEffect as n, useRef as r, useState as i } from "react";
|
|
3
|
+
import { flushSync as a } from "react-dom";
|
|
4
|
+
//#region src/utils/animation.ts
|
|
5
|
+
function o(e, t, r) {
|
|
6
|
+
n(() => {
|
|
7
|
+
let n = e.current;
|
|
8
|
+
if (!t || !n) return;
|
|
9
|
+
if (!("getAnimations" in n)) {
|
|
10
|
+
r();
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
let i = n.getAnimations();
|
|
14
|
+
if (i.length === 0) {
|
|
15
|
+
r();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
let o = !1;
|
|
19
|
+
return Promise.allSettled(i.map((e) => e.finished)).then(() => {
|
|
20
|
+
o || a(r);
|
|
21
|
+
}), () => {
|
|
22
|
+
o = !0;
|
|
23
|
+
};
|
|
24
|
+
}, [
|
|
25
|
+
e,
|
|
26
|
+
t,
|
|
27
|
+
r
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
function s(e) {
|
|
31
|
+
let [n, r] = i(!0);
|
|
32
|
+
return o(e, n, t(() => r(!1), [])), n;
|
|
33
|
+
}
|
|
34
|
+
function c(e, n) {
|
|
35
|
+
let [r, a] = i(n ? "present" : "exited");
|
|
36
|
+
n && r !== "present" ? a("present") : !n && r === "present" && a("exiting");
|
|
37
|
+
let s = r === "exiting";
|
|
38
|
+
return o(e, s, t(() => a((e) => e === "exiting" ? "exited" : e), [])), s;
|
|
39
|
+
}
|
|
40
|
+
function l(t, a) {
|
|
41
|
+
let [o, s] = i(null), c = r(null);
|
|
42
|
+
return n(() => {
|
|
43
|
+
let n = t.current;
|
|
44
|
+
if (!n || c.current === a) return;
|
|
45
|
+
if (c.current = a, e()) {
|
|
46
|
+
s(null);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
let r = n.offsetHeight;
|
|
50
|
+
if (r === 0) {
|
|
51
|
+
s(null);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
s(a ? 0 : r);
|
|
55
|
+
let i = requestAnimationFrame(() => s(a ? r : 0));
|
|
56
|
+
if (!a) return () => cancelAnimationFrame(i);
|
|
57
|
+
let o = (e) => {
|
|
58
|
+
e.propertyName === "height" && s(null);
|
|
59
|
+
};
|
|
60
|
+
return n.addEventListener("transitionend", o), () => {
|
|
61
|
+
cancelAnimationFrame(i), n.removeEventListener("transitionend", o);
|
|
62
|
+
};
|
|
63
|
+
}, [t, a]), o;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { s as useEnterAnimation, c as useExitAnimation, l as useSlideHeight };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=animation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation.js","names":[],"sources":["../../src/utils/animation.ts"],"sourcesContent":["import type { RefObject } from \"react\";\nimport { useCallback, useLayoutEffect, useRef, useState } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport { readPrefersReducedMotion } from \"../hooks/usePrefersReducedMotion.js\";\n\n/**\n * Runs `onEnd` once every animation on the element has settled. Modelled on\n * react-aria's overlay animation handling, which is private API — RAC drives\n * `data-entering`/`data-exiting` for us on Dialog and Sheet, but its Toast does\n * not, so lovelace needs its own copy for the toast surfaces.\n *\n * Two cases resolve immediately and both are load-bearing: jsdom has no\n * `getAnimations`, and an element whose transition has not started yet reports\n * none. The latter is what removes `data-entering` and lets the transition run.\n */\nfunction useAnimationEnd(\n\tref: RefObject<HTMLElement | null>,\n\tisActive: boolean,\n\tonEnd: () => void,\n) {\n\tuseLayoutEffect(() => {\n\t\tconst element = ref.current;\n\t\tif (!isActive || !element) {\n\t\t\treturn;\n\t\t}\n\t\tif (!(\"getAnimations\" in element)) {\n\t\t\tonEnd();\n\t\t\treturn;\n\t\t}\n\t\tconst animations = element.getAnimations();\n\t\tif (animations.length === 0) {\n\t\t\tonEnd();\n\t\t\treturn;\n\t\t}\n\t\tlet cancelled = false;\n\t\tPromise.allSettled(animations.map((animation) => animation.finished)).then(\n\t\t\t() => {\n\t\t\t\tif (!cancelled) {\n\t\t\t\t\tflushSync(onEnd);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t};\n\t}, [ref, isActive, onEnd]);\n}\n\n/**\n * True until the element's entrance animation finishes. Style the \"from\" state\n * off `[data-entering]`; removing the attribute is what starts the transition.\n */\nexport function useEnterAnimation(ref: RefObject<HTMLElement | null>): boolean {\n\tconst [isEntering, setIsEntering] = useState(true);\n\tuseAnimationEnd(\n\t\tref,\n\t\tisEntering,\n\t\tuseCallback(() => setIsEntering(false), []),\n\t);\n\treturn isEntering;\n}\n\n/**\n * True while the element plays its exit animation after `isPresent` goes false.\n * Keep the element mounted until it returns false, and style the \"to\" state off\n * `[data-exiting]`.\n */\nexport function useExitAnimation(\n\tref: RefObject<HTMLElement | null>,\n\tisPresent: boolean,\n): boolean {\n\tconst [phase, setPhase] = useState<\"present\" | \"exiting\" | \"exited\">(\n\t\tisPresent ? \"present\" : \"exited\",\n\t);\n\n\t// Derive during render rather than in an effect so the exit styles land in the\n\t// same commit that dropped `isPresent` — a frame of the entered state would\n\t// otherwise paint first and the transition would start from the wrong place.\n\tif (isPresent && phase !== \"present\") {\n\t\tsetPhase(\"present\");\n\t} else if (!isPresent && phase === \"present\") {\n\t\tsetPhase(\"exiting\");\n\t}\n\n\tconst isExiting = phase === \"exiting\";\n\tuseAnimationEnd(\n\t\tref,\n\t\tisExiting,\n\t\tuseCallback(\n\t\t\t() => setPhase((current) => (current === \"exiting\" ? \"exited\" : current)),\n\t\t\t[],\n\t\t),\n\t);\n\treturn isExiting;\n}\n\n/**\n * The height to render the element at while it arrives or leaves, or null once it\n * is settled and its own content should size it.\n *\n * A surface whose box already holds its full height reports the space before it\n * arrives and keeps it after it leaves: whatever sits below jumps a full height at\n * once, then waits out the travel against a gap. Animating the height moves that\n * content in step with the surface instead.\n *\n * The height has to be measured, since a transition cannot run from `auto`. Each\n * direction sets its start value in the commit that changed `isPresent`, then its\n * end value on the next frame, so the browser has something to interpolate from.\n * An arriving surface drops back to `null` once its transition ends, so a later\n * change to its content can size it again.\n */\nexport function useSlideHeight(\n\tref: RefObject<HTMLElement | null>,\n\tisPresent: boolean,\n): number | null {\n\tconst [height, setHeight] = useState<number | null>(null);\n\tconst settledRef = useRef<boolean | null>(null);\n\n\tuseLayoutEffect(() => {\n\t\tconst element = ref.current;\n\t\tif (!element || settledRef.current === isPresent) {\n\t\t\treturn;\n\t\t}\n\t\tsettledRef.current = isPresent;\n\n\t\t// The surface only transitions its height under `no-preference`, so pinning\n\t\t// a measured height here would never hear the `transitionend` that hands\n\t\t// sizing back, and later, longer copy would be clipped for good.\n\t\tif (readPrefersReducedMotion()) {\n\t\t\tsetHeight(null);\n\t\t\treturn;\n\t\t}\n\n\t\t// A surface measured inside a hidden frame reports 0. Pinning that would clip\n\t\t// it shut for good: the height never changes, so no transition starts and no\n\t\t// `transitionend` arrives to hand sizing back.\n\t\tconst content = element.offsetHeight;\n\t\tif (content === 0) {\n\t\t\tsetHeight(null);\n\t\t\treturn;\n\t\t}\n\t\tsetHeight(isPresent ? 0 : content);\n\t\tconst frame = requestAnimationFrame(() =>\n\t\t\tsetHeight(isPresent ? content : 0),\n\t\t);\n\n\t\tif (!isPresent) {\n\t\t\treturn () => cancelAnimationFrame(frame);\n\t\t}\n\t\t// Hand sizing back to the content once it is in. A leaving surface keeps its\n\t\t// zero height instead — it is about to unmount.\n\t\tconst handleEnd = (event: TransitionEvent) => {\n\t\t\tif (event.propertyName === \"height\") {\n\t\t\t\tsetHeight(null);\n\t\t\t}\n\t\t};\n\t\telement.addEventListener(\"transitionend\", handleEnd);\n\t\treturn () => {\n\t\t\tcancelAnimationFrame(frame);\n\t\t\telement.removeEventListener(\"transitionend\", handleEnd);\n\t\t};\n\t}, [ref, isPresent]);\n\n\treturn height;\n}\n"],"mappings":";;;;AAeA,SAAS,EACR,GACA,GACA,GACC;AACD,SAAsB;EACrB,IAAM,IAAU,EAAI;AACpB,MAAI,CAAC,KAAY,CAAC,EACjB;AAED,MAAI,EAAE,mBAAmB,IAAU;AAClC,MAAO;AACP;;EAED,IAAM,IAAa,EAAQ,eAAe;AAC1C,MAAI,EAAW,WAAW,GAAG;AAC5B,MAAO;AACP;;EAED,IAAI,IAAY;AAQhB,SAPA,QAAQ,WAAW,EAAW,KAAK,MAAc,EAAU,SAAS,CAAC,CAAC,WAC/D;AACL,GAAK,KACJ,EAAU,EAAM;IAGlB,QACY;AACZ,OAAY;;IAEX;EAAC;EAAK;EAAU;EAAM,CAAC;;AAO3B,SAAgB,EAAkB,GAA6C;CAC9E,IAAM,CAAC,GAAY,KAAiB,EAAS,GAAK;AAMlD,QALA,EACC,GACA,GACA,QAAkB,EAAc,GAAM,EAAE,EAAE,CAAC,CAC3C,EACM;;AAQR,SAAgB,EACf,GACA,GACU;CACV,IAAM,CAAC,GAAO,KAAY,EACzB,IAAY,YAAY,SACxB;AAKD,CAAI,KAAa,MAAU,YAC1B,EAAS,UAAU,GACT,CAAC,KAAa,MAAU,aAClC,EAAS,UAAU;CAGpB,IAAM,IAAY,MAAU;AAS5B,QARA,EACC,GACA,GACA,QACO,GAAU,MAAa,MAAY,YAAY,WAAW,EAAS,EACzE,EAAE,CACF,CACD,EACM;;AAkBR,SAAgB,EACf,GACA,GACgB;CAChB,IAAM,CAAC,GAAQ,KAAa,EAAwB,KAAK,EACnD,IAAa,EAAuB,KAAK;AA+C/C,QA7CA,QAAsB;EACrB,IAAM,IAAU,EAAI;AACpB,MAAI,CAAC,KAAW,EAAW,YAAY,EACtC;AAOD,MALA,EAAW,UAAU,GAKjB,GAA0B,EAAE;AAC/B,KAAU,KAAK;AACf;;EAMD,IAAM,IAAU,EAAQ;AACxB,MAAI,MAAY,GAAG;AAClB,KAAU,KAAK;AACf;;AAED,IAAU,IAAY,IAAI,EAAQ;EAClC,IAAM,IAAQ,4BACb,EAAU,IAAY,IAAU,EAAE,CAClC;AAED,MAAI,CAAC,EACJ,cAAa,qBAAqB,EAAM;EAIzC,IAAM,KAAa,MAA2B;AAC7C,GAAI,EAAM,iBAAiB,YAC1B,EAAU,KAAK;;AAIjB,SADA,EAAQ,iBAAiB,iBAAiB,EAAU,QACvC;AAEZ,GADA,qBAAqB,EAAM,EAC3B,EAAQ,oBAAoB,iBAAiB,EAAU;;IAEtD,CAAC,GAAK,EAAU,CAAC,EAEb"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ada-cx/lovelace",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Ada's messaging design system primitives: React Aria Components behavior, vanilla-extract styling, Figma-generated design tokens.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"type": "module",
|
|
@@ -52,7 +52,8 @@
|
|
|
52
52
|
"@vanilla-extract/css": "^1.20.1",
|
|
53
53
|
"@vanilla-extract/recipes": "^0.5.7",
|
|
54
54
|
"react-aria": "^3.48.0",
|
|
55
|
-
"react-aria-components": "^1.15.1"
|
|
55
|
+
"react-aria-components": "^1.15.1",
|
|
56
|
+
"react-stately": "^3.46.0"
|
|
56
57
|
},
|
|
57
58
|
"peerDependencies": {
|
|
58
59
|
"react": "^19.0.0",
|