@ada-cx/lovelace 1.15.0 → 1.16.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.
@@ -1,16 +1,26 @@
1
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;
2
+ interface DropZoneBaseProps extends Omit<HTMLAttributes<HTMLDivElement>, "onDrop" | "children" | "aria-label"> {
7
3
  /**
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.
4
+ * Called when a drop carries items but no file, such as text, a link or a
5
+ * folder. The panel shows for any drag, because a drag does not reliably
6
+ * expose its contents until the drop.
7
+ */
8
+ onNoFilesDropped?: () => void;
9
+ /**
10
+ * Called when a dropped file cannot be read, or when `onFileDrop` or
11
+ * `onFilesDrop` throws. Without it such a failure is silent, since the drop
12
+ * surface has no error state.
10
13
  */
11
14
  onDropError?: (error: Error) => void;
12
15
  /** Ignore drags and drops, and never show the panel. Children stay mounted. */
13
16
  isDisabled?: boolean;
17
+ /**
18
+ * Ignore a drag that starts inside this document, such as selected text, a
19
+ * link or an image on the page. The zone shows no panel for it and delivers
20
+ * nothing. Use it when the zone covers content the user can drag, and only
21
+ * files from outside the page count as a drop.
22
+ */
23
+ ignorePageDrags?: boolean;
14
24
  /**
15
25
  * Panel heading, and the accessible name of the keyboard drop button. `aria-label`
16
26
  * is deliberately not accepted separately — the two would disagree, and the visible
@@ -22,11 +32,45 @@ export interface DropZoneProps extends Omit<HTMLAttributes<HTMLDivElement>, "onD
22
32
  className?: string;
23
33
  children: ReactNode;
24
34
  }
35
+ interface DropZonePerFileProps {
36
+ /**
37
+ * Called with the dropped file once it resolves. Exactly one file per drop,
38
+ * unless `allowMultiple` is set.
39
+ */
40
+ onFileDrop: (file: File) => void;
41
+ /**
42
+ * Called instead of `onFileDrop` when a drop carries more than one file and
43
+ * `allowMultiple` is not set.
44
+ */
45
+ onMultipleFilesRejected?: () => void;
46
+ /**
47
+ * Accept a drop that carries several files. `onFileDrop` then runs once per
48
+ * file, in drop order, after every file resolves.
49
+ */
50
+ allowMultiple?: boolean;
51
+ onFilesDrop?: never;
52
+ }
53
+ interface DropZoneBatchProps {
54
+ /**
55
+ * Called once per drop with every readable file, in drop order, whatever the
56
+ * count. Use it when the consumer decides what a count means.
57
+ */
58
+ onFilesDrop: (files: File[]) => void;
59
+ onFileDrop?: never;
60
+ onMultipleFilesRejected?: never;
61
+ allowMultiple?: never;
62
+ }
63
+ /**
64
+ * Exactly one delivery callback is required. Without one, a zone would accept a
65
+ * drop and deliver the files nowhere.
66
+ */
67
+ export type DropZoneProps = DropZoneBaseProps & (DropZonePerFileProps | DropZoneBatchProps);
25
68
  /**
26
- * A region that accepts a single dropped file, showing a panel over its children
27
- * while a drag is over it.
69
+ * A region that accepts a dropped file (or several, with `allowMultiple`),
70
+ * showing a panel over its children while a drag is over it.
28
71
  *
29
72
  * The panel fills the nearest positioned ancestor, so the caller decides how much
30
73
  * of the UI is droppable.
31
74
  */
32
- export declare function DropZone({ onFileDrop, onMultipleFilesRejected, onDropError, isDisabled, label, description, className, children, ...rest }: DropZoneProps): import("react/jsx-runtime").JSX.Element;
75
+ export declare function DropZone({ onFileDrop, onFilesDrop, onMultipleFilesRejected, onNoFilesDropped, onDropError, allowMultiple, isDisabled, ignorePageDrags, label, description, className, children, ...rest }: DropZoneProps): import("react/jsx-runtime").JSX.Element;
76
+ export {};
@@ -3,54 +3,84 @@ import { CloudUpload as t } from "../Icon/icons/CloudUpload.js";
3
3
  import { dropZoneRoot as n } from "./DropZone.css.js";
4
4
  import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
5
5
  import { DropZone as o } from "react-aria-components";
6
- import { useCallback as s, useRef as c } from "react";
7
- import { isFileDropItem as l } from "react-aria";
6
+ import { useCallback as s, useEffect as c, useRef as l, useState as u } from "react";
7
+ import { isFileDropItem as d } from "react-aria";
8
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 = c(!1), b = s(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());
9
+ var f = "application/x-lovelace-page-drag", p = (e) => e.kind === "text" && e.types.has(f);
10
+ function m({ onFileDrop: m, onFilesDrop: h, onMultipleFilesRejected: g, onNoFilesDropped: _, onDropError: v, allowMultiple: y = !1, isDisabled: b = !1, ignorePageDrags: x = !1, label: S = "Drop your file here", description: C, className: w, children: T, ...E }) {
11
+ let D = l(!1), [O, k] = u(!1);
12
+ c(() => {
13
+ if (!x) return;
14
+ let e = (e) => {
15
+ e.dataTransfer?.setData(f, "1");
16
+ }, t = (e) => {
17
+ k(!!e.dataTransfer?.types.includes(f));
18
+ };
19
+ return document.addEventListener("dragstart", e, !0), document.addEventListener("dragenter", t, !0), () => {
20
+ document.removeEventListener("dragstart", e, !0), document.removeEventListener("dragenter", t, !0), k(!1);
21
+ };
22
+ }, [x]);
23
+ let A = s(async (e) => {
24
+ if (D.current || x && e.items.some(p)) return;
25
+ let t = e.items.filter(d);
26
+ if (t.length === 0) {
27
+ e.items.length > 0 && _?.();
28
+ return;
29
+ }
30
+ if (t.length > 1 && !y && !h) {
31
+ g?.();
32
+ return;
33
+ }
34
+ D.current = !0;
35
+ let n = (e) => v?.(e instanceof Error ? e : Error(String(e)));
36
+ try {
37
+ let e = await Promise.allSettled(t.map((e) => e.getFile())), r = [];
38
+ for (let t of e) t.status === "rejected" ? n(t.reason) : r.push(t.value);
39
+ if (h) {
40
+ if (r.length > 0) try {
41
+ h(r);
42
+ } catch (e) {
43
+ n(e);
44
+ }
45
+ } else for (let e of r) try {
46
+ m?.(e);
21
47
  } catch (e) {
22
- f?.(e instanceof Error ? e : Error(String(e)));
23
- } finally {
24
- y.current = !1;
48
+ n(e);
25
49
  }
50
+ } finally {
51
+ D.current = !1;
26
52
  }
27
53
  }, [
28
- f,
29
- u,
30
- d
54
+ y,
55
+ x,
56
+ v,
57
+ m,
58
+ h,
59
+ g,
60
+ _
31
61
  ]);
32
62
  return /* @__PURE__ */ i(o, {
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", {
63
+ ...E,
64
+ "aria-label": S,
65
+ isDisabled: b,
66
+ onDrop: A,
67
+ className: e(n, w),
68
+ children: ({ isDropTarget: e, isFocusVisible: n }) => /* @__PURE__ */ a(r, { children: [T, (e && !O || n) && /* @__PURE__ */ a("div", {
39
69
  className: "_1vy5zjp1",
40
70
  children: [/* @__PURE__ */ i(t, {}), /* @__PURE__ */ a("div", {
41
71
  className: "_1vy5zjp2",
42
72
  children: [/* @__PURE__ */ i("p", {
43
73
  className: "_1vy5zjp3",
44
- children: m
45
- }), h && /* @__PURE__ */ i("p", {
74
+ children: S
75
+ }), C && /* @__PURE__ */ i("p", {
46
76
  className: "_1vy5zjp4",
47
- children: h
77
+ children: C
48
78
  })]
49
79
  })]
50
80
  })] })
51
81
  });
52
82
  }
53
83
  //#endregion
54
- export { u as DropZone };
84
+ export { m as DropZone };
55
85
 
56
86
  //# sourceMappingURL=DropZone.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"DropZone.js","names":[],"sources":["../../../src/components/DropZone/DropZone.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode } from \"react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { DropEvent, DropItem } 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\ninterface DropZoneBaseProps\n\textends Omit<\n\t\tHTMLAttributes<HTMLDivElement>,\n\t\t\"onDrop\" | \"children\" | \"aria-label\"\n\t> {\n\t/**\n\t * Called when a drop carries items but no file, such as text, a link or a\n\t * folder. The panel shows for any drag, because a drag does not reliably\n\t * expose its contents until the drop.\n\t */\n\tonNoFilesDropped?: () => void;\n\t/**\n\t * Called when a dropped file cannot be read, or when `onFileDrop` or\n\t * `onFilesDrop` throws. Without it such a failure is silent, since the drop\n\t * 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 * Ignore a drag that starts inside this document, such as selected text, a\n\t * link or an image on the page. The zone shows no panel for it and delivers\n\t * nothing. Use it when the zone covers content the user can drag, and only\n\t * files from outside the page count as a drop.\n\t */\n\tignorePageDrags?: 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\ninterface DropZonePerFileProps {\n\t/**\n\t * Called with the dropped file once it resolves. Exactly one file per drop,\n\t * unless `allowMultiple` is set.\n\t */\n\tonFileDrop: (file: File) => void;\n\t/**\n\t * Called instead of `onFileDrop` when a drop carries more than one file and\n\t * `allowMultiple` is not set.\n\t */\n\tonMultipleFilesRejected?: () => void;\n\t/**\n\t * Accept a drop that carries several files. `onFileDrop` then runs once per\n\t * file, in drop order, after every file resolves.\n\t */\n\tallowMultiple?: boolean;\n\tonFilesDrop?: never;\n}\n\ninterface DropZoneBatchProps {\n\t/**\n\t * Called once per drop with every readable file, in drop order, whatever the\n\t * count. Use it when the consumer decides what a count means.\n\t */\n\tonFilesDrop: (files: File[]) => void;\n\tonFileDrop?: never;\n\tonMultipleFilesRejected?: never;\n\tallowMultiple?: never;\n}\n\n/**\n * Marks a drag that starts inside this document, such as selected text or a\n * transcript image. The marker rides on the drag's own data, so no state can be\n * left over when a drag ends without a `dragend`.\n */\nconst PAGE_DRAG_TYPE = \"application/x-lovelace-page-drag\";\n\nconst isPageDragItem = (item: DropItem) =>\n\titem.kind === \"text\" && item.types.has(PAGE_DRAG_TYPE);\n\n/**\n * Exactly one delivery callback is required. Without one, a zone would accept a\n * drop and deliver the files nowhere.\n */\nexport type DropZoneProps = DropZoneBaseProps &\n\t(DropZonePerFileProps | DropZoneBatchProps);\n\n/**\n * A region that accepts a dropped file (or several, with `allowMultiple`),\n * showing a panel over its children 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\tonFilesDrop,\n\tonMultipleFilesRejected,\n\tonNoFilesDropped,\n\tonDropError,\n\tallowMultiple = false,\n\tisDisabled = false,\n\tignorePageDrags = 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\t// A page drag is tagged when it starts, and the tag rides on the drag data.\n\t// Every drag begins with a fresh dragenter, so the flag below cannot outlive\n\t// the drag that set it.\n\tconst [pageDragOver, setPageDragOver] = useState(false);\n\tuseEffect(() => {\n\t\tif (!ignorePageDrags) {\n\t\t\treturn;\n\t\t}\n\t\tconst markPageDrag = (event: DragEvent) => {\n\t\t\tevent.dataTransfer?.setData(PAGE_DRAG_TYPE, \"1\");\n\t\t};\n\t\tconst trackDrag = (event: DragEvent) => {\n\t\t\tsetPageDragOver(\n\t\t\t\tBoolean(event.dataTransfer?.types.includes(PAGE_DRAG_TYPE)),\n\t\t\t);\n\t\t};\n\t\tdocument.addEventListener(\"dragstart\", markPageDrag, true);\n\t\tdocument.addEventListener(\"dragenter\", trackDrag, true);\n\t\treturn () => {\n\t\t\tdocument.removeEventListener(\"dragstart\", markPageDrag, true);\n\t\t\tdocument.removeEventListener(\"dragenter\", trackDrag, true);\n\t\t\tsetPageDragOver(false);\n\t\t};\n\t}, [ignorePageDrags]);\n\n\tconst handleDrop = useCallback(\n\t\tasync (event: DropEvent) => {\n\t\t\tif (\n\t\t\t\tresolvingRef.current ||\n\t\t\t\t(ignorePageDrags && event.items.some(isPageDragItem))\n\t\t\t) {\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\tif (event.items.length > 0) {\n\t\t\t\t\tonNoFilesDropped?.();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (files.length > 1 && !allowMultiple && !onFilesDrop) {\n\t\t\t\tonMultipleFilesRejected?.();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresolvingRef.current = true;\n\t\t\t// RAC calls onDrop without awaiting it. Anything thrown here, such as a\n\t\t\t// file the browser cannot read or a consumer's own handler throwing,\n\t\t\t// escapes as an unhandled rejection instead of reaching a caller. Report\n\t\t\t// each failure on its own, so one bad file in a multi-file drop does not\n\t\t\t// lose the rest. The consumer decides what a failed file means.\n\t\t\tconst reportError = (error: unknown) =>\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\ttry {\n\t\t\t\tconst results = await Promise.allSettled(\n\t\t\t\t\tfiles.map((item) => item.getFile()),\n\t\t\t\t);\n\t\t\t\tconst readable: File[] = [];\n\t\t\t\tfor (const result of results) {\n\t\t\t\t\tif (result.status === \"rejected\") {\n\t\t\t\t\t\treportError(result.reason);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treadable.push(result.value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (onFilesDrop) {\n\t\t\t\t\tif (readable.length > 0) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tonFilesDrop(readable);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\treportError(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (const file of readable) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tonFileDrop?.(file);\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\treportError(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\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[\n\t\t\tallowMultiple,\n\t\t\tignorePageDrags,\n\t\t\tonDropError,\n\t\t\tonFileDrop,\n\t\t\tonFilesDrop,\n\t\t\tonMultipleFilesRejected,\n\t\t\tonNoFilesDropped,\n\t\t],\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 && !pageDragOver) || 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":";;;;;;;;AAwFA,IAAM,IAAiB,oCAEjB,KAAkB,MACvB,EAAK,SAAS,UAAU,EAAK,MAAM,IAAI,EAAe;AAgBvD,SAAgB,EAAS,EACxB,eACA,gBACA,4BACA,qBACA,gBACA,mBAAgB,IAChB,gBAAa,IACb,qBAAkB,IAClB,WAAQ,uBACR,gBACA,cACA,aACA,GAAG,KACc;CAIjB,IAAM,IAAe,EAAO,GAAM,EAK5B,CAAC,GAAc,KAAmB,EAAS,GAAM;AACvD,SAAgB;AACf,MAAI,CAAC,EACJ;EAED,IAAM,KAAgB,MAAqB;AAC1C,KAAM,cAAc,QAAQ,GAAgB,IAAI;KAE3C,KAAa,MAAqB;AACvC,KACC,EAAQ,EAAM,cAAc,MAAM,SAAS,EAAe,CAC1D;;AAIF,SAFA,SAAS,iBAAiB,aAAa,GAAc,GAAK,EAC1D,SAAS,iBAAiB,aAAa,GAAW,GAAK,QAC1C;AAGZ,GAFA,SAAS,oBAAoB,aAAa,GAAc,GAAK,EAC7D,SAAS,oBAAoB,aAAa,GAAW,GAAK,EAC1D,EAAgB,GAAM;;IAErB,CAAC,EAAgB,CAAC;CAErB,IAAM,IAAa,EAClB,OAAO,MAAqB;AAC3B,MACC,EAAa,WACZ,KAAmB,EAAM,MAAM,KAAK,EAAe,CAEpD;EAED,IAAM,IAAQ,EAAM,MAAM,OAAO,EAAe;AAChD,MAAI,EAAM,WAAW,GAAG;AACvB,GAAI,EAAM,MAAM,SAAS,KACxB,KAAoB;AAErB;;AAED,MAAI,EAAM,SAAS,KAAK,CAAC,KAAiB,CAAC,GAAa;AACvD,QAA2B;AAC3B;;AAED,IAAa,UAAU;EAMvB,IAAM,KAAe,MACpB,IACC,aAAiB,QAAQ,IAAY,MAAM,OAAO,EAAM,CAAC,CACzD;AACF,MAAI;GACH,IAAM,IAAU,MAAM,QAAQ,WAC7B,EAAM,KAAK,MAAS,EAAK,SAAS,CAAC,CACnC,EACK,IAAmB,EAAE;AAC3B,QAAK,IAAM,KAAU,EACpB,CAAI,EAAO,WAAW,aACrB,EAAY,EAAO,OAAO,GAE1B,EAAS,KAAK,EAAO,MAAM;AAG7B,OAAI;QACC,EAAS,SAAS,EACrB,KAAI;AACH,OAAY,EAAS;aACb,GAAO;AACf,OAAY,EAAM;;SAIpB,MAAK,IAAM,KAAQ,EAClB,KAAI;AACH,QAAa,EAAK;YACV,GAAO;AACf,MAAY,EAAM;;YAIZ;AACT,KAAa,UAAU;;IAGzB;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA,CACD;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,IACE,KAAgB,CAAC,KAAiB,MACpC,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"}
@@ -1,13 +1,35 @@
1
1
  export declare const textRoot: import("@vanilla-extract/recipes").RuntimeFn<{
2
2
  variant: {
3
- body: import("@vanilla-extract/css").StyleRule;
4
- caption: import("@vanilla-extract/css").StyleRule;
5
- "title-small": import("@vanilla-extract/css").StyleRule;
6
- "title-large": import("@vanilla-extract/css").StyleRule;
3
+ body: {
4
+ fontFamily: "var(--lovelace-font-family-body)";
5
+ fontSize: "var(--lovelace-font-size-caption)" | "var(--lovelace-font-size-body)" | "var(--lovelace-font-size-title-small)" | "var(--lovelace-font-size-title-large)";
6
+ lineHeight: "var(--lovelace-line-height-caption)" | "var(--lovelace-line-height-body)" | "var(--lovelace-line-height-title-small)" | "var(--lovelace-line-height-title-large)";
7
+ };
8
+ caption: {
9
+ fontFamily: "var(--lovelace-font-family-body)";
10
+ fontSize: "var(--lovelace-font-size-caption)" | "var(--lovelace-font-size-body)" | "var(--lovelace-font-size-title-small)" | "var(--lovelace-font-size-title-large)";
11
+ lineHeight: "var(--lovelace-line-height-caption)" | "var(--lovelace-line-height-body)" | "var(--lovelace-line-height-title-small)" | "var(--lovelace-line-height-title-large)";
12
+ };
13
+ "title-small": {
14
+ fontFamily: "var(--lovelace-font-family-body)";
15
+ fontSize: "var(--lovelace-font-size-caption)" | "var(--lovelace-font-size-body)" | "var(--lovelace-font-size-title-small)" | "var(--lovelace-font-size-title-large)";
16
+ lineHeight: "var(--lovelace-line-height-caption)" | "var(--lovelace-line-height-body)" | "var(--lovelace-line-height-title-small)" | "var(--lovelace-line-height-title-large)";
17
+ };
18
+ "title-large": {
19
+ fontFamily: "var(--lovelace-font-family-body)";
20
+ fontSize: "var(--lovelace-font-size-caption)" | "var(--lovelace-font-size-body)" | "var(--lovelace-font-size-title-small)" | "var(--lovelace-font-size-title-large)";
21
+ lineHeight: "var(--lovelace-line-height-caption)" | "var(--lovelace-line-height-body)" | "var(--lovelace-line-height-title-small)" | "var(--lovelace-line-height-title-large)";
22
+ };
7
23
  };
8
24
  weight: {
9
- regular: import("@vanilla-extract/css").StyleRule;
10
- medium: import("@vanilla-extract/css").StyleRule;
11
- "semi-bold": import("@vanilla-extract/css").StyleRule;
25
+ regular: {
26
+ fontWeight: "var(--lovelace-font-weight-regular)" | "var(--lovelace-font-weight-medium)" | "var(--lovelace-font-weight-semi-bold)";
27
+ };
28
+ medium: {
29
+ fontWeight: "var(--lovelace-font-weight-regular)" | "var(--lovelace-font-weight-medium)" | "var(--lovelace-font-weight-semi-bold)";
30
+ };
31
+ "semi-bold": {
32
+ fontWeight: "var(--lovelace-font-weight-regular)" | "var(--lovelace-font-weight-medium)" | "var(--lovelace-font-weight-semi-bold)";
33
+ };
12
34
  };
13
35
  }>;
@@ -1,4 +1,3 @@
1
- import type { StyleRule } from "@vanilla-extract/css";
2
1
  /**
3
2
  * The four semantic type tiers Figma defines, as variable names rather than
4
3
  * values. Lovelace 2.0 publishes no TEXT styles — typography lives entirely in
@@ -15,13 +14,19 @@ export type TextWeight = "regular" | "medium" | "semi-bold";
15
14
  * `font-family-code` / `font-family-mono` have none, so a family prop would be
16
15
  * surface Figma does not show.
17
16
  */
18
- export declare function typographyVariant(variant: TextVariant): StyleRule;
17
+ export declare function typographyVariant(variant: TextVariant): {
18
+ fontFamily: "var(--lovelace-font-family-body)";
19
+ fontSize: "var(--lovelace-font-size-caption)" | "var(--lovelace-font-size-body)" | "var(--lovelace-font-size-title-small)" | "var(--lovelace-font-size-title-large)";
20
+ lineHeight: "var(--lovelace-line-height-caption)" | "var(--lovelace-line-height-body)" | "var(--lovelace-line-height-title-small)" | "var(--lovelace-line-height-title-large)";
21
+ };
19
22
  /**
20
23
  * Weight alone. Split from the tier because the two axes are independent in
21
24
  * practice: `body` ships with `regular` on seven components and `medium` on
22
25
  * seven others, so a tier cannot carry a weight of its own.
23
26
  */
24
- export declare function typographyWeight(weight: TextWeight): StyleRule;
27
+ export declare function typographyWeight(weight: TextWeight): {
28
+ fontWeight: "var(--lovelace-font-weight-regular)" | "var(--lovelace-font-weight-medium)" | "var(--lovelace-font-weight-semi-bold)";
29
+ };
25
30
  /**
26
31
  * Both axes as one block, spread into a host's own class rather than shared as
27
32
  * one class — the `rowFrame` treatment. The hosts are a `<button>`, a
@@ -29,4 +34,9 @@ export declare function typographyWeight(weight: TextWeight): StyleRule;
29
34
  * every case the type sits on the component's own root: there is no text child
30
35
  * to hang a class on.
31
36
  */
32
- export declare function typography(variant: TextVariant, weight?: TextWeight): StyleRule;
37
+ export declare function typography(variant: TextVariant, weight?: TextWeight): {
38
+ fontWeight: "var(--lovelace-font-weight-regular)" | "var(--lovelace-font-weight-medium)" | "var(--lovelace-font-weight-semi-bold)";
39
+ fontFamily: "var(--lovelace-font-family-body)";
40
+ fontSize: "var(--lovelace-font-size-caption)" | "var(--lovelace-font-size-body)" | "var(--lovelace-font-size-title-small)" | "var(--lovelace-font-size-title-large)";
41
+ lineHeight: "var(--lovelace-line-height-caption)" | "var(--lovelace-line-height-body)" | "var(--lovelace-line-height-title-small)" | "var(--lovelace-line-height-title-large)";
42
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ada-cx/lovelace",
3
- "version": "1.15.0",
3
+ "version": "1.16.1",
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",
@@ -49,8 +49,6 @@
49
49
  "lint": "npx biome check"
50
50
  },
51
51
  "dependencies": {
52
- "@vanilla-extract/css": "^1.20.1",
53
- "@vanilla-extract/recipes": "^0.5.7",
54
52
  "react-aria": "^3.48.0",
55
53
  "react-aria-components": "^1.17.0",
56
54
  "react-stately": "^3.46.0"
@@ -61,6 +59,8 @@
61
59
  },
62
60
  "devDependencies": {
63
61
  "@figma/code-connect": "^1.3.0",
62
+ "@vanilla-extract/css": "^1.20.1",
63
+ "@vanilla-extract/recipes": "^0.5.7",
64
64
  "@vanilla-extract/vite-plugin": "^5.2.2"
65
65
  }
66
66
  }