@ada-cx/lovelace 1.7.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/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/IconButton/IconButton.css.d.ts +14 -14
- 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/Spinner/Spinner.css.d.ts +2 -2
- package/dist/components/ThinkingShimmer/ThinkingShimmer.css.js.map +1 -1
- package/dist/components/ToastNotification/ToastNotification.css.d.ts +6 -6
- package/dist/components/TypingIndicator/TypingIndicator.css.js.map +1 -1
- 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 +1 -1
- package/dist/tokens/tokens.d.ts +2 -2
- package/dist/tokens.css +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
//#region src/components/DropZone/DropZone.css.ts
|
|
3
|
+
var e = "_1vy5zjp0", t = "_1vy5zjp1", n = "_1vy5zjp2", r = "_1vy5zjp3", i = "_1vy5zjp4";
|
|
4
|
+
//#endregion
|
|
5
|
+
export { i as dropZoneDescription, r as dropZoneLabel, t as dropZonePanel, e as dropZoneRoot, n as dropZoneText };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=DropZone.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropZone.css.js","names":[],"sources":["../../../src/components/DropZone/DropZone.css.ts"],"sourcesContent":["import { globalStyle, style } from \"@vanilla-extract/css\";\nimport { t } from \"../../tokens/index.js\";\n\nexport const dropZoneRoot = style({\n\tposition: \"relative\",\n\tdisplay: \"flex\",\n\tflexDirection: \"column\",\n\tflex: \"1 1 auto\",\n\tminHeight: 0,\n});\n\n// The panel covers the surface it is given rather than carrying the frame size\n// from Figma, so the same primitive works over a whole chat body or a smaller\n// region without the consumer overriding a fixed height.\nexport const dropZonePanel = style({\n\tposition: \"absolute\",\n\tinset: 0,\n\tdisplay: \"flex\",\n\tflexDirection: \"column\",\n\talignItems: \"center\",\n\tjustifyContent: \"center\",\n\tgap: t(\"gap-12\"),\n\tpadding: t(\"padding-16\"),\n\tborderRadius: t(\"border-radius-20\"),\n\tbackgroundColor: t(\"color-background-default\"),\n\t// The panel is a drag affordance, not a target: the drop is handled by the\n\t// zone underneath, and swallowing pointer events here would make the browser\n\t// fire dragleave the moment the panel appeared.\n\tpointerEvents: \"none\",\n});\n\n// 32px is the Figma frame size; the icon-size scale tops out at 24 (`icon-size-lg`).\nglobalStyle(`${dropZonePanel} [data-slot=\"icon\"]`, {\n\tfontSize: \"32px\",\n\tcolor: t(\"color-content-secondary\"),\n});\n\n// Figma ships two variants differing only in icon color. `active` is a drag actually\n// over the zone; `default` is the panel without one, which here is the keyboard path.\nglobalStyle(\n\t`${dropZoneRoot}[data-drop-target] ${dropZonePanel} [data-slot=\"icon\"]`,\n\t{\n\t\tcolor: t(\"color-content-highlight\"),\n\t},\n);\n\nexport const dropZoneText = style({\n\tdisplay: \"flex\",\n\tflexDirection: \"column\",\n\tgap: t(\"gap-8\"),\n\twidth: \"100%\",\n\ttextAlign: \"center\",\n\tfontFamily: t(\"font-family-body\"),\n\tfontWeight: t(\"font-weight-regular\"),\n\tfontSize: t(\"font-size-body\"),\n\tlineHeight: t(\"line-height-body\"),\n\twordBreak: \"break-word\",\n});\n\nexport const dropZoneLabel = style({\n\tmargin: 0,\n\tcolor: t(\"color-content-default\"),\n});\n\nexport const dropZoneDescription = style({\n\tmargin: 0,\n\tcolor: t(\"color-content-secondary\"),\n});\n"],"mappings":""}
|
|
@@ -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";
|