@ada-cx/lovelace 1.6.0 → 1.8.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/Avatar/Avatar.css.d.ts +8 -8
- package/dist/components/Button/Button.css.d.ts +14 -14
- package/dist/components/Checkbox/Checkbox.css.d.ts +1 -1
- package/dist/components/Chip/Chip.css.d.ts +4 -4
- package/dist/components/Dialog/Dialog.css.d.ts +2 -2
- package/dist/components/DialogOverlay/DialogOverlay.css.js.map +1 -1
- package/dist/components/Divider/Divider.css.d.ts +2 -2
- package/dist/components/DropZone/DropZone.css.d.ts +5 -0
- package/dist/components/DropZone/DropZone.css.js +7 -0
- package/dist/components/DropZone/DropZone.css.js.map +1 -0
- package/dist/components/DropZone/DropZone.d.ts +32 -0
- package/dist/components/DropZone/DropZone.js +56 -0
- package/dist/components/DropZone/DropZone.js.map +1 -0
- package/dist/components/DropZone/index.d.ts +1 -0
- package/dist/components/FullscreenOverlay/FullscreenOverlay.css.js.map +1 -1
- package/dist/components/IconButton/IconButton.css.d.ts +14 -14
- package/dist/components/Input/Input.css.d.ts +1 -0
- package/dist/components/Input/Input.css.js +6 -6
- package/dist/components/Input/Input.css.js.map +1 -1
- package/dist/components/Input/Input.d.ts +3 -0
- package/dist/components/Input/Input.js +17 -15
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/Input/InputAttachments.d.ts +9 -0
- package/dist/components/Input/InputAttachments.js +15 -0
- package/dist/components/Input/InputAttachments.js.map +1 -0
- package/dist/components/Input/InputButton.js +4 -4
- package/dist/components/Input/InputField.js +4 -4
- package/dist/components/Input/InputHelperText.js +4 -4
- package/dist/components/Input/InputRoot.js +4 -4
- package/dist/components/Input/index.d.ts +1 -1
- package/dist/components/PictureMessage/PictureMessage.css.d.ts +2 -2
- package/dist/components/Radio/Radio.css.d.ts +1 -1
- package/dist/components/ScrollMarker/ScrollMarker.css.d.ts +6 -6
- package/dist/components/SheetOverlay/SheetOverlay.css.js.map +1 -1
- package/dist/components/Spinner/Spinner.css.d.ts +2 -2
- package/dist/components/Spinner/Spinner.css.js.map +1 -1
- package/dist/components/ToastNotification/ToastNotification.css.d.ts +6 -6
- package/dist/components/VideoMessage/VideoMessage.css.d.ts +8 -0
- package/dist/components/VideoMessage/VideoMessage.css.js +28 -0
- package/dist/components/VideoMessage/VideoMessage.css.js.map +1 -0
- package/dist/components/VideoMessage/VideoMessage.d.ts +32 -0
- package/dist/components/VideoMessage/VideoMessage.js +32 -0
- package/dist/components/VideoMessage/VideoMessage.js.map +1 -0
- package/dist/components/VideoMessage/index.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +31 -29
- package/dist/style.css +1 -1
- package/dist/tokens/generated/tokens.d.ts +3 -3
- package/dist/tokens/tokens.d.ts +2 -2
- package/dist/tokens.css +77 -9
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
export interface DropZoneProps extends Omit<HTMLAttributes<HTMLDivElement>, "onDrop" | "children" | "aria-label"> {
|
|
3
|
+
/** Called with the dropped file once it resolves. Exactly one file per drop. */
|
|
4
|
+
onFileDrop: (file: File) => void;
|
|
5
|
+
/** Called instead of `onFileDrop` when a drop carries more than one file. */
|
|
6
|
+
onMultipleFilesRejected?: () => void;
|
|
7
|
+
/**
|
|
8
|
+
* Called when a dropped file cannot be read, or when `onFileDrop` throws. Without
|
|
9
|
+
* it such a failure is silent, since the drop surface has no error state.
|
|
10
|
+
*/
|
|
11
|
+
onDropError?: (error: Error) => void;
|
|
12
|
+
/** Ignore drags and drops, and never show the panel. Children stay mounted. */
|
|
13
|
+
isDisabled?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Panel heading, and the accessible name of the keyboard drop button. `aria-label`
|
|
16
|
+
* is deliberately not accepted separately — the two would disagree, and the visible
|
|
17
|
+
* heading is the name a screen reader should read.
|
|
18
|
+
*/
|
|
19
|
+
label?: string;
|
|
20
|
+
/** Optional second line under the heading. */
|
|
21
|
+
description?: string;
|
|
22
|
+
className?: string;
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A region that accepts a single dropped file, showing a panel over its children
|
|
27
|
+
* while a drag is over it.
|
|
28
|
+
*
|
|
29
|
+
* The panel fills the nearest positioned ancestor, so the caller decides how much
|
|
30
|
+
* of the UI is droppable.
|
|
31
|
+
*/
|
|
32
|
+
export declare function DropZone({ onFileDrop, onMultipleFilesRejected, onDropError, isDisabled, label, description, className, children, ...rest }: DropZoneProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { cx as e } from "../../utils/cx.js";
|
|
2
|
+
import { CloudUpload as t } from "../Icon/icons/CloudUpload.js";
|
|
3
|
+
import { dropZoneRoot as n } from "./DropZone.css.js";
|
|
4
|
+
import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
5
|
+
import { useCallback as o, useRef as s } from "react";
|
|
6
|
+
import { DropZone as c } from "react-aria-components";
|
|
7
|
+
import { isFileDropItem as l } from "react-aria";
|
|
8
|
+
//#region src/components/DropZone/DropZone.tsx
|
|
9
|
+
function u({ onFileDrop: u, onMultipleFilesRejected: d, onDropError: f, isDisabled: p = !1, label: m = "Drop your file here", description: h, className: g, children: _, ...v }) {
|
|
10
|
+
let y = s(!1), b = o(async (e) => {
|
|
11
|
+
if (y.current) return;
|
|
12
|
+
let t = e.items.filter(l);
|
|
13
|
+
if (t.length !== 0) {
|
|
14
|
+
if (t.length > 1) {
|
|
15
|
+
d?.();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
y.current = !0;
|
|
19
|
+
try {
|
|
20
|
+
u(await t[0].getFile());
|
|
21
|
+
} catch (e) {
|
|
22
|
+
f?.(e instanceof Error ? e : Error(String(e)));
|
|
23
|
+
} finally {
|
|
24
|
+
y.current = !1;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}, [
|
|
28
|
+
f,
|
|
29
|
+
u,
|
|
30
|
+
d
|
|
31
|
+
]);
|
|
32
|
+
return /* @__PURE__ */ i(c, {
|
|
33
|
+
...v,
|
|
34
|
+
"aria-label": m,
|
|
35
|
+
isDisabled: p,
|
|
36
|
+
onDrop: b,
|
|
37
|
+
className: e(n, g),
|
|
38
|
+
children: ({ isDropTarget: e, isFocusVisible: n }) => /* @__PURE__ */ a(r, { children: [_, (e || n) && /* @__PURE__ */ a("div", {
|
|
39
|
+
className: "_1vy5zjp1",
|
|
40
|
+
children: [/* @__PURE__ */ i(t, {}), /* @__PURE__ */ a("div", {
|
|
41
|
+
className: "_1vy5zjp2",
|
|
42
|
+
children: [/* @__PURE__ */ i("p", {
|
|
43
|
+
className: "_1vy5zjp3",
|
|
44
|
+
children: m
|
|
45
|
+
}), h && /* @__PURE__ */ i("p", {
|
|
46
|
+
className: "_1vy5zjp4",
|
|
47
|
+
children: h
|
|
48
|
+
})]
|
|
49
|
+
})]
|
|
50
|
+
})] })
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { u as DropZone };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=DropZone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropZone.js","names":[],"sources":["../../../src/components/DropZone/DropZone.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode } from \"react\";\nimport { useCallback, useRef } from \"react\";\nimport type { DropEvent } from \"react-aria\";\nimport { isFileDropItem } from \"react-aria\";\nimport { DropZone as AriaDropZone } from \"react-aria-components\";\nimport { cx } from \"../../utils/cx.js\";\nimport { CloudUpload } from \"../Icon/icons/index.js\";\nimport {\n\tdropZoneDescription,\n\tdropZoneLabel,\n\tdropZonePanel,\n\tdropZoneRoot,\n\tdropZoneText,\n} from \"./DropZone.css.js\";\n\nexport interface DropZoneProps\n\textends Omit<\n\t\tHTMLAttributes<HTMLDivElement>,\n\t\t\"onDrop\" | \"children\" | \"aria-label\"\n\t> {\n\t/** Called with the dropped file once it resolves. Exactly one file per drop. */\n\tonFileDrop: (file: File) => void;\n\t/** Called instead of `onFileDrop` when a drop carries more than one file. */\n\tonMultipleFilesRejected?: () => void;\n\t/**\n\t * Called when a dropped file cannot be read, or when `onFileDrop` throws. Without\n\t * it such a failure is silent, since the drop surface has no error state.\n\t */\n\tonDropError?: (error: Error) => void;\n\t/** Ignore drags and drops, and never show the panel. Children stay mounted. */\n\tisDisabled?: boolean;\n\t/**\n\t * Panel heading, and the accessible name of the keyboard drop button. `aria-label`\n\t * is deliberately not accepted separately — the two would disagree, and the visible\n\t * heading is the name a screen reader should read.\n\t */\n\tlabel?: string;\n\t/** Optional second line under the heading. */\n\tdescription?: string;\n\tclassName?: string;\n\tchildren: ReactNode;\n}\n\n/**\n * A region that accepts a single dropped file, showing a panel over its children\n * while a drag is over it.\n *\n * The panel fills the nearest positioned ancestor, so the caller decides how much\n * of the UI is droppable.\n */\nexport function DropZone({\n\tonFileDrop,\n\tonMultipleFilesRejected,\n\tonDropError,\n\tisDisabled = false,\n\tlabel = \"Drop your file here\",\n\tdescription,\n\tclassName,\n\tchildren,\n\t...rest\n}: DropZoneProps) {\n\t// Resolving a dropped file is async, so a second drop can arrive before the\n\t// first reports. Claim the zone synchronously, while still on the drop event,\n\t// so only one drop per resolution reaches the consumer.\n\tconst resolvingRef = useRef(false);\n\n\tconst handleDrop = useCallback(\n\t\tasync (event: DropEvent) => {\n\t\t\tif (resolvingRef.current) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst files = event.items.filter(isFileDropItem);\n\t\t\tif (files.length === 0) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (files.length > 1) {\n\t\t\t\tonMultipleFilesRejected?.();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresolvingRef.current = true;\n\t\t\ttry {\n\t\t\t\tconst file = await files[0].getFile();\n\t\t\t\tonFileDrop(file);\n\t\t\t} catch (error) {\n\t\t\t\t// RAC calls onDrop without awaiting it, so anything thrown here — a file\n\t\t\t\t// the browser cannot read, or a consumer's own handler — escapes as an\n\t\t\t\t// unhandled rejection instead of reaching a caller. Report it and leave\n\t\t\t\t// the surface as it was; the consumer decides what a failed drop means.\n\t\t\t\tonDropError?.(\n\t\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t\t);\n\t\t\t} finally {\n\t\t\t\tresolvingRef.current = false;\n\t\t\t}\n\t\t},\n\t\t[onDropError, onFileDrop, onMultipleFilesRejected],\n\t);\n\n\treturn (\n\t\t<AriaDropZone\n\t\t\t{...rest}\n\t\t\taria-label={label}\n\t\t\tisDisabled={isDisabled}\n\t\t\tonDrop={handleDrop}\n\t\t\tclassName={cx(dropZoneRoot, className)}\n\t\t>\n\t\t\t{({ isDropTarget, isFocusVisible }) => (\n\t\t\t\t<>\n\t\t\t\t\t{children}\n\t\t\t\t\t{(isDropTarget || isFocusVisible) && (\n\t\t\t\t\t\t<div className={dropZonePanel}>\n\t\t\t\t\t\t\t<CloudUpload />\n\t\t\t\t\t\t\t<div className={dropZoneText}>\n\t\t\t\t\t\t\t\t<p className={dropZoneLabel}>{label}</p>\n\t\t\t\t\t\t\t\t{description && (\n\t\t\t\t\t\t\t\t\t<p className={dropZoneDescription}>{description}</p>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)}\n\t\t\t\t</>\n\t\t\t)}\n\t\t</AriaDropZone>\n\t);\n}\n"],"mappings":";;;;;;;;AAkDA,SAAgB,EAAS,EACxB,eACA,4BACA,gBACA,gBAAa,IACb,WAAQ,uBACR,gBACA,cACA,aACA,GAAG,KACc;CAIjB,IAAM,IAAe,EAAO,GAAM,EAE5B,IAAa,EAClB,OAAO,MAAqB;AAC3B,MAAI,EAAa,QAChB;EAED,IAAM,IAAQ,EAAM,MAAM,OAAO,EAAe;AAC5C,QAAM,WAAW,GAGrB;OAAI,EAAM,SAAS,GAAG;AACrB,SAA2B;AAC3B;;AAED,KAAa,UAAU;AACvB,OAAI;AAEH,MADa,MAAM,EAAM,GAAG,SAAS,CACrB;YACR,GAAO;AAKf,QACC,aAAiB,QAAQ,IAAY,MAAM,OAAO,EAAM,CAAC,CACzD;aACQ;AACT,MAAa,UAAU;;;IAGzB;EAAC;EAAa;EAAY;EAAwB,CAClD;AAED,QACC,kBAAC,GAAD;EACC,GAAI;EACJ,cAAY;EACA;EACZ,QAAQ;EACR,WAAW,EAAG,GAAc,EAAU;aAEpC,EAAE,iBAAc,wBACjB,kBAAA,GAAA,EAAA,UAAA,CACE,IACC,KAAgB,MACjB,kBAAC,OAAD;GAAK,WAAA;aAAL,CACC,kBAAC,GAAD,EAAe,CAAA,EACf,kBAAC,OAAD;IAAK,WAAA;cAAL,CACC,kBAAC,KAAD;KAAG,WAAA;eAA2B;KAAU,CAAA,EACvC,KACA,kBAAC,KAAD;KAAG,WAAA;eAAiC;KAAgB,CAAA,CAEhD;MACD;KAEL,EAAA,CAAA;EAEU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DropZone, type DropZoneProps } from "./DropZone.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FullscreenOverlay.css.js","names":[],"sources":["../../../src/components/FullscreenOverlay/FullscreenOverlay.css.ts"],"sourcesContent":["import { style } from \"@vanilla-extract/css\";\nimport { t } from \"../../tokens/index.js\";\nimport { overlayScrimBase } from \"../Overlay/overlay.css.js\";\n\n// Dark-scrim backdrop. It sits behind the full-window surface (so it's not\n// visible), but its RAC ModalOverlay still provides focus-trap + dismiss + the\n// fade under prefers-reduced-motion.\nexport const fullscreenScrim = style([\n\toverlayScrimBase,\n\t{ backgroundColor: t(\"color-
|
|
1
|
+
{"version":3,"file":"FullscreenOverlay.css.js","names":[],"sources":["../../../src/components/FullscreenOverlay/FullscreenOverlay.css.ts"],"sourcesContent":["import { style } from \"@vanilla-extract/css\";\nimport { t } from \"../../tokens/index.js\";\nimport { overlayScrimBase } from \"../Overlay/overlay.css.js\";\n\n// Dark-scrim backdrop. It sits behind the full-window surface (so it's not\n// visible), but its RAC ModalOverlay still provides focus-trap + dismiss + the\n// fade under prefers-reduced-motion.\nexport const fullscreenScrim = style([\n\toverlayScrimBase,\n\t{ backgroundColor: t(\"color-wash-neutral\") },\n]);\n\n// Fills the whole chat window: no size cap, no rounded corners. Same slide-up\n// entrance as the bottom sheet.\nexport const fullscreenModal = style({\n\tposition: \"relative\",\n\tdisplay: \"flex\",\n\tflexDirection: \"column\",\n\tminHeight: 0,\n\twidth: \"100%\",\n\theight: \"100%\",\n\tmaxHeight: \"100%\",\n\tbackgroundColor: t(\"color-background-default\"),\n\toverflow: \"hidden\",\n\tselectors: {\n\t\t\"&[data-entering]\": { transform: \"translateY(100%)\" },\n\t\t\"&[data-exiting]\": { transform: \"translateY(100%)\" },\n\t},\n\t\"@media\": {\n\t\t\"(prefers-reduced-motion: no-preference)\": {\n\t\t\ttransition: `transform ${t(\"duration-medium\")} ${t(\"easing-standard\")}`,\n\t\t},\n\t},\n});\n\nexport const fullscreenDialog = style({\n\tdisplay: \"flex\",\n\tflexDirection: \"column\",\n\tflex: \"1 1 auto\",\n\tminHeight: 0,\n\tmaxHeight: \"100%\",\n\toutline: \"none\",\n});\n"],"mappings":""}
|