@ada-cx/lovelace 1.9.2 → 1.12.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/AgentMessage/AgentMessage.css.d.ts +0 -1
- package/dist/components/AgentMessage/AgentMessage.css.js +2 -2
- package/dist/components/AgentMessage/AgentMessage.css.js.map +1 -1
- package/dist/components/AgentMessage/AgentMessage.d.ts +19 -12
- package/dist/components/AgentMessage/AgentMessage.js +9 -17
- package/dist/components/AgentMessage/AgentMessage.js.map +1 -1
- package/dist/components/AttachmentChip/AttachmentChip.css.d.ts +13 -0
- package/dist/components/AttachmentChip/AttachmentChip.css.js +16 -0
- package/dist/components/AttachmentChip/AttachmentChip.css.js.map +1 -0
- package/dist/components/AttachmentChip/AttachmentChip.d.ts +69 -0
- package/dist/components/AttachmentChip/AttachmentChip.js +51 -0
- package/dist/components/AttachmentChip/AttachmentChip.js.map +1 -0
- package/dist/components/AttachmentChip/index.d.ts +2 -0
- package/dist/components/Avatar/Avatar.css.d.ts +8 -8
- package/dist/components/Avatar/Avatar.css.js +1 -1
- package/dist/components/Button/Button.css.d.ts +14 -14
- package/dist/components/Checkbox/Checkbox.css.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.css.js.map +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.js +4 -4
- package/dist/components/Icon/icons/Document.d.ts +2 -0
- package/dist/components/Icon/icons/Document.js +14 -0
- package/dist/components/Icon/icons/Document.js.map +1 -0
- package/dist/components/Icon/icons/index.d.ts +1 -0
- package/dist/components/IconButton/IconButton.css.d.ts +14 -14
- package/dist/components/Input/Input.css.d.ts +5 -0
- package/dist/components/Input/Input.css.js.map +1 -1
- package/dist/components/Input/InputAttachments.d.ts +13 -2
- package/dist/components/Input/InputAttachments.js.map +1 -1
- package/dist/components/Input/InputField.d.ts +8 -1
- package/dist/components/Input/InputField.js +6 -5
- package/dist/components/Input/InputField.js.map +1 -1
- package/dist/components/Input/InputRoot.js +4 -4
- package/dist/components/Input/InputTextArea.js +7 -7
- package/dist/components/Link/Link.d.ts +7 -0
- package/dist/components/Link/Link.js.map +1 -1
- package/dist/components/MenuItem/MenuItem.css.js.map +1 -1
- package/dist/components/MenuItem/MenuItemRoot.js +9 -9
- package/dist/components/MessageError/MessageError.css.d.ts +5 -0
- package/dist/components/MessageError/MessageError.css.js +7 -0
- package/dist/components/MessageError/MessageError.css.js.map +1 -0
- package/dist/components/MessageError/MessageError.d.ts +38 -0
- package/dist/components/MessageError/MessageError.js +38 -0
- package/dist/components/MessageError/MessageError.js.map +1 -0
- package/dist/components/MessageError/index.d.ts +1 -0
- package/dist/components/MessageProse/MessageProse.css.d.ts +20 -0
- package/dist/components/MessageProse/MessageProse.css.js +7 -0
- package/dist/components/MessageProse/MessageProse.css.js.map +1 -0
- package/dist/components/MessageProse/MessageProse.d.ts +25 -0
- package/dist/components/MessageProse/MessageProse.js +17 -0
- package/dist/components/MessageProse/MessageProse.js.map +1 -0
- package/dist/components/MessageProse/index.d.ts +2 -0
- package/dist/components/MessageRow/MessageRow.context.d.ts +5 -0
- package/dist/components/MessageRow/MessageRow.context.js +7 -0
- package/dist/components/MessageRow/MessageRow.context.js.map +1 -0
- package/dist/components/MessageRow/MessageRow.css.d.ts +29 -0
- package/dist/components/MessageRow/MessageRow.css.js +39 -0
- package/dist/components/MessageRow/MessageRow.css.js.map +1 -0
- package/dist/components/MessageRow/MessageRow.d.ts +8 -0
- package/dist/components/MessageRow/MessageRow.js +8 -0
- package/dist/components/MessageRow/MessageRow.js.map +1 -0
- package/dist/components/MessageRow/MessageRowContent.d.ts +20 -0
- package/dist/components/MessageRow/MessageRowContent.js +21 -0
- package/dist/components/MessageRow/MessageRowContent.js.map +1 -0
- package/dist/components/MessageRow/MessageRowRoot.d.ts +23 -0
- package/dist/components/MessageRow/MessageRowRoot.js +19 -0
- package/dist/components/MessageRow/MessageRowRoot.js.map +1 -0
- package/dist/components/MessageRow/index.d.ts +2 -0
- package/dist/components/PictureMessage/PictureMessage.css.d.ts +2 -2
- package/dist/components/Radio/Radio.css.d.ts +1 -1
- package/dist/components/Radio/Radio.css.js.map +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/ToastNotification/ToastNotification.css.d.ts +6 -6
- package/dist/components/UserMessage/UserMessage.css.d.ts +0 -5
- package/dist/components/UserMessage/UserMessage.css.js +2 -2
- package/dist/components/UserMessage/UserMessage.css.js.map +1 -1
- package/dist/components/UserMessage/UserMessage.d.ts +10 -12
- package/dist/components/UserMessage/UserMessage.js +12 -38
- package/dist/components/UserMessage/UserMessage.js.map +1 -1
- package/dist/components/VideoMessage/VideoMessage.js +4 -4
- package/dist/index.d.ts +3 -0
- package/dist/index.js +86 -82
- package/dist/style.css +1 -1
- package/dist/styles/{row.d.ts → control-row.d.ts} +3 -3
- package/dist/tokens/generated/tokens.d.ts +1 -1
- package/dist/tokens/tokens.d.ts +2 -2
- package/dist/tokens.css +6 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* empty css */
|
|
2
2
|
//#region src/components/AgentMessage/AgentMessage.css.ts
|
|
3
|
-
var e = "_1xn6t060"
|
|
3
|
+
var e = "_1xn6t060";
|
|
4
4
|
//#endregion
|
|
5
|
-
export {
|
|
5
|
+
export { e as agentMessageBody };
|
|
6
6
|
|
|
7
7
|
//# sourceMappingURL=AgentMessage.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentMessage.css.js","names":[],"sources":["../../../src/components/AgentMessage/AgentMessage.css.ts"],"sourcesContent":["import { style } from \"@vanilla-extract/css\";\
|
|
1
|
+
{"version":3,"file":"AgentMessage.css.js","names":[],"sources":["../../../src/components/AgentMessage/AgentMessage.css.ts"],"sourcesContent":["import { style } from \"@vanilla-extract/css\";\n\nexport const agentMessageBody = style({\n\tminWidth: 0,\n\t// Match the Figma message frame: a 24px minimum row, single lines centered\n\t// against it so short text aligns with the avatar. Keep in sync with the\n\t// Avatar `sm` size (`Avatar.css.ts`); there is no shared `avatar-size-*`\n\t// token yet.\n\tdisplay: \"flex\",\n\tflexDirection: \"column\",\n\tjustifyContent: \"center\",\n\tminHeight: \"24px\",\n\t// `start` follows the text's resolved direction (see `dir=\"auto\"` on the\n\t// element), keeping mixed-direction content aligned to its own edge.\n\ttextAlign: \"start\",\n});\n"],"mappings":""}
|
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode, Ref } from "react";
|
|
2
2
|
export interface AgentMessageProps {
|
|
3
|
-
/** Monogram shown in the agent avatar bubble. */
|
|
4
|
-
initials?: string;
|
|
5
3
|
className?: string;
|
|
6
4
|
style?: CSSProperties;
|
|
7
5
|
ref?: Ref<HTMLDivElement>;
|
|
8
|
-
/** The agent's message
|
|
6
|
+
/** The agent's message content. Block content (lists, tables) is allowed. */
|
|
9
7
|
children?: ReactNode;
|
|
10
8
|
}
|
|
11
9
|
/**
|
|
12
|
-
* A single chat message from the agent:
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
10
|
+
* A single chat message from the agent: the message body, with the text
|
|
11
|
+
* direction detected from its own content.
|
|
12
|
+
*
|
|
13
|
+
* Row layout is the transcript's, not this component's — an avatar, a sender
|
|
14
|
+
* attribution, a reaction bar or a retry control are siblings the transcript
|
|
15
|
+
* places beside this body, so they align with the text rather than the avatar
|
|
16
|
+
* gutter and stay outside the body's direction detection. `UserMessage` draws
|
|
17
|
+
* the same boundary.
|
|
18
|
+
*
|
|
19
|
+
* Carries `data-slot="message-body"` from the shared body it composes, for a
|
|
20
|
+
* transcript that needs to find it. Prefer styling this component directly over
|
|
21
|
+
* a descendant selector against that attribute.
|
|
22
|
+
*
|
|
23
|
+
* Announcing new messages is likewise the transcript's responsibility — wrap
|
|
24
|
+
* the message list in a single persistent live region (e.g. `role="log"`)
|
|
25
|
+
* rather than giving each message its own, since a per-message live region
|
|
26
|
+
* mounted already-populated is not reliably announced.
|
|
20
27
|
*/
|
|
21
|
-
export declare function AgentMessage({
|
|
28
|
+
export declare function AgentMessage({ className, children, ...rest }: AgentMessageProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import { cx as e } from "../../utils/cx.js";
|
|
2
|
-
import {
|
|
3
|
-
import { agentMessageBody as n
|
|
4
|
-
import { jsx as
|
|
2
|
+
import { MessageProse as t } from "../MessageProse/MessageProse.js";
|
|
3
|
+
import { agentMessageBody as n } from "./AgentMessage.css.js";
|
|
4
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
5
5
|
//#region src/components/AgentMessage/AgentMessage.tsx
|
|
6
|
-
function
|
|
7
|
-
return /* @__PURE__ */
|
|
8
|
-
...
|
|
9
|
-
className: e(
|
|
10
|
-
children:
|
|
11
|
-
"aria-hidden": !0,
|
|
12
|
-
size: "sm",
|
|
13
|
-
children: o
|
|
14
|
-
}), /* @__PURE__ */ i("p", {
|
|
15
|
-
dir: "auto",
|
|
16
|
-
className: n,
|
|
17
|
-
children: c
|
|
18
|
-
})]
|
|
6
|
+
function i({ className: i, children: a, ...o }) {
|
|
7
|
+
return /* @__PURE__ */ r(t, {
|
|
8
|
+
...o,
|
|
9
|
+
className: e(n, i),
|
|
10
|
+
children: a
|
|
19
11
|
});
|
|
20
12
|
}
|
|
21
13
|
//#endregion
|
|
22
|
-
export {
|
|
14
|
+
export { i as AgentMessage };
|
|
23
15
|
|
|
24
16
|
//# sourceMappingURL=AgentMessage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentMessage.js","names":[],"sources":["../../../src/components/AgentMessage/AgentMessage.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode, Ref } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"AgentMessage.js","names":[],"sources":["../../../src/components/AgentMessage/AgentMessage.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode, Ref } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport { MessageProse } from \"../MessageProse/index.js\";\nimport { agentMessageBody } from \"./AgentMessage.css.js\";\n\nexport interface AgentMessageProps {\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n\t/** The agent's message content. Block content (lists, tables) is allowed. */\n\tchildren?: ReactNode;\n}\n\n/**\n * A single chat message from the agent: the message body, with the text\n * direction detected from its own content.\n *\n * Row layout is the transcript's, not this component's — an avatar, a sender\n * attribution, a reaction bar or a retry control are siblings the transcript\n * places beside this body, so they align with the text rather than the avatar\n * gutter and stay outside the body's direction detection. `UserMessage` draws\n * the same boundary.\n *\n * Carries `data-slot=\"message-body\"` from the shared body it composes, for a\n * transcript that needs to find it. Prefer styling this component directly over\n * a descendant selector against that attribute.\n *\n * Announcing new messages is likewise the transcript's responsibility — wrap\n * the message list in a single persistent live region (e.g. `role=\"log\"`)\n * rather than giving each message its own, since a per-message live region\n * mounted already-populated is not reliably announced.\n */\nexport function AgentMessage({\n\tclassName,\n\tchildren,\n\t...rest\n}: AgentMessageProps) {\n\treturn (\n\t\t<MessageProse {...rest} className={cx(agentMessageBody, className)}>\n\t\t\t{children}\n\t\t</MessageProse>\n\t);\n}\n"],"mappings":";;;;;AAgCA,SAAgB,EAAa,EAC5B,cACA,aACA,GAAG,KACkB;AACrB,QACC,kBAAC,GAAD;EAAc,GAAI;EAAM,WAAW,EAAG,GAAkB,EAAU;EAChE;EACa,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ComplexStyleRule } from "@vanilla-extract/css";
|
|
2
|
+
import type { RuntimeFn } from "@vanilla-extract/recipes";
|
|
3
|
+
export declare const attachmentChipRoot: RuntimeFn<{
|
|
4
|
+
interactive: Record<"true" | "false", ComplexStyleRule>;
|
|
5
|
+
}>;
|
|
6
|
+
/**
|
|
7
|
+
* Fixed box for the leading slot so a thumbnail, a spinner and an icon all
|
|
8
|
+
* occupy the same 24px square — otherwise the chip's contents shift as an
|
|
9
|
+
* upload settles and the stand-in gives way to the image.
|
|
10
|
+
*/
|
|
11
|
+
export declare const attachmentChipMedia: string;
|
|
12
|
+
export declare const attachmentChipThumbnail: string;
|
|
13
|
+
export declare const attachmentChipLabel: string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
import { createRuntimeFn as e } from "../../vendor/@vanilla-extract/recipes/dist/createRuntimeFn-62c9670f.esm.js";
|
|
3
|
+
//#region src/components/AttachmentChip/AttachmentChip.css.ts
|
|
4
|
+
var t = e({
|
|
5
|
+
defaultClassName: "_1chqu661 _1chqu660",
|
|
6
|
+
variantClassNames: { interactive: {
|
|
7
|
+
true: "_1chqu662",
|
|
8
|
+
false: "_1chqu663"
|
|
9
|
+
} },
|
|
10
|
+
defaultVariants: { interactive: !1 },
|
|
11
|
+
compoundVariants: []
|
|
12
|
+
}), n = "_1chqu664", r = "_1chqu665", i = "_1chqu666";
|
|
13
|
+
//#endregion
|
|
14
|
+
export { i as attachmentChipLabel, n as attachmentChipMedia, t as attachmentChipRoot, r as attachmentChipThumbnail };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=AttachmentChip.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttachmentChip.css.js","names":[],"sources":["../../../src/components/AttachmentChip/AttachmentChip.css.ts"],"sourcesContent":["import type { ComplexStyleRule } from \"@vanilla-extract/css\";\nimport { globalStyle, style } from \"@vanilla-extract/css\";\nimport type { RuntimeFn } from \"@vanilla-extract/recipes\";\nimport { recipe } from \"@vanilla-extract/recipes\";\nimport { t } from \"../../tokens/index.js\";\n\nconst attachmentChipBase = style({});\n\n/**\n * Figma pins each chip's frame height, the way it pins other control heights —\n * literals, with no size tier to route them through. The file chip is 40px: its\n * 24px thumbnail plus the 8px padding leaves nothing to trim. The summary chip\n * carries a 22px icon instead, and the composer draws it at 36px.\n */\nconst FILE_CHIP_HEIGHT = \"40px\";\nconst SUMMARY_CHIP_HEIGHT = \"36px\";\n\n/**\n * The cap the filename ellipsises against. Figma pins it on the file chip only;\n * the summary sizes to its own label, so a count is never clipped.\n */\nconst FILE_CHIP_MAX_WIDTH = \"148px\";\n\n/**\n * Annotated `string` deliberately: `t()` returns a template-literal type per\n * token, and four of them concatenated exceed what tsc will represent\n * (TS2590).\n */\nconst CHIP_SHADOW: string = `0 ${t(\"elevation-2-offset-y\")} ${t(\"elevation-2-blur\")} ${t(\"elevation-2-spread\")} ${t(\"elevation-2-color\")}`;\n\nexport const attachmentChipRoot: RuntimeFn<{\n\tinteractive: Record<\"true\" | \"false\", ComplexStyleRule>;\n}> = recipe({\n\tbase: [\n\t\tattachmentChipBase,\n\t\t{\n\t\t\tdisplay: \"flex\",\n\t\t\talignItems: \"center\",\n\t\t\tboxSizing: \"border-box\",\n\t\t\tgap: t(\"gap-8\"),\n\t\t\tminWidth: 0,\n\t\t\tpadding: t(\"padding-8\"),\n\t\t\toverflow: \"hidden\",\n\t\t\tborderRadius: t(\"border-radius-6\"),\n\t\t\tborder: 0,\n\t\t\tbackgroundColor: t(\"color-background-quaternary\"),\n\t\t\tcolor: t(\"color-content-default\"),\n\t\t\tfontFamily: t(\"font-family-body\"),\n\t\t\tfontSize: t(\"font-size-body\"),\n\t\t\tfontWeight: t(\"font-weight-regular\"),\n\t\t\tlineHeight: t(\"line-height-body\"),\n\t\t\ttextAlign: \"start\",\n\t\t\tappearance: \"none\",\n\t\t\tboxShadow: CHIP_SHADOW,\n\t\t},\n\t],\n\tvariants: {\n\t\t/**\n\t\t * Off, the chip is a plain container whose trailing button is the only\n\t\t * control — Figma's file chip, capped so a long filename ellipsises. On,\n\t\t * the chip itself is the control — Figma's summary chip, which has no\n\t\t * trailing button, sizes to its label, and so takes the shared state\n\t\t * layer.\n\t\t */\n\t\tinteractive: {\n\t\t\ttrue: {\n\t\t\t\theight: SUMMARY_CHIP_HEIGHT,\n\t\t\t\tposition: \"relative\",\n\t\t\t\tisolation: \"isolate\",\n\t\t\t\tcursor: \"pointer\",\n\t\t\t\toutline: \"none\",\n\t\t\t\t\"::after\": {\n\t\t\t\t\tcontent: '\"\"',\n\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\tinset: 0,\n\t\t\t\t\tborderRadius: \"inherit\",\n\t\t\t\t\tbackgroundColor: \"currentColor\",\n\t\t\t\t\topacity: 0,\n\t\t\t\t\tpointerEvents: \"none\",\n\t\t\t\t\tzIndex: -1,\n\t\t\t\t\ttransition: `opacity ${t(\"duration-fast\")} ${t(\"easing-standard\")}`,\n\t\t\t\t},\n\t\t\t\tselectors: {\n\t\t\t\t\t\"&[data-hovered]::after\": { opacity: t(\"opacity-state-hover\") },\n\t\t\t\t\t\"&[data-focus-visible]::after\": { opacity: t(\"opacity-state-focus\") },\n\t\t\t\t\t\"&[data-pressed]::after\": { opacity: t(\"opacity-state-pressed\") },\n\t\t\t\t\t\"&[data-focus-visible]\": {\n\t\t\t\t\t\toutline: `2px solid ${t(\"color-border-focus\")}`,\n\t\t\t\t\t\toutlineOffset: \"2px\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t\"@media\": {\n\t\t\t\t\t// A token-based ring is flattened away in High Contrast, so the\n\t\t\t\t\t// focus state needs a system colour to survive it.\n\t\t\t\t\t\"(forced-colors: active)\": {\n\t\t\t\t\t\tselectors: {\n\t\t\t\t\t\t\t\"&[data-focus-visible]\": {\n\t\t\t\t\t\t\t\toutline: \"2px solid Highlight\",\n\t\t\t\t\t\t\t\toutlineOffset: \"2px\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tfalse: {\n\t\t\t\theight: FILE_CHIP_HEIGHT,\n\t\t\t\tmaxWidth: FILE_CHIP_MAX_WIDTH,\n\t\t\t},\n\t\t},\n\t},\n\tdefaultVariants: { interactive: false },\n});\n\n/**\n * Fixed box for the leading slot so a thumbnail, a spinner and an icon all\n * occupy the same 24px square — otherwise the chip's contents shift as an\n * upload settles and the stand-in gives way to the image.\n */\nexport const attachmentChipMedia = style({\n\tdisplay: \"inline-flex\",\n\talignItems: \"center\",\n\tjustifyContent: \"center\",\n\tflexShrink: 0,\n\twidth: \"24px\",\n\theight: \"24px\",\n\tborderRadius: t(\"border-radius-6\"),\n\toverflow: \"hidden\",\n});\n\n/**\n * A thumbnail fills the box; an icon sits at 22px inside it, as Figma draws\n * it — and on the chip's own background, with no backing of its own.\n */\nglobalStyle(`${attachmentChipMedia} [data-slot=\"icon\"]`, {\n\tfontSize: t(\"icon-size-control\"),\n});\n\nexport const attachmentChipThumbnail = style({\n\twidth: \"100%\",\n\theight: \"100%\",\n\tobjectFit: \"cover\",\n});\n\nexport const attachmentChipLabel = style({\n\tminWidth: 0,\n\toverflow: \"hidden\",\n\ttextOverflow: \"ellipsis\",\n\twhiteSpace: \"nowrap\",\n\twordBreak: \"break-word\",\n});\n"],"mappings":""}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode, Ref } from "react";
|
|
2
|
+
export interface AttachmentChipProps {
|
|
3
|
+
/** Filename, or a summary such as "3 attachments". */
|
|
4
|
+
label: string;
|
|
5
|
+
/**
|
|
6
|
+
* Thumbnail source, rendered as given. Validate it first — and use
|
|
7
|
+
* `onImageError` to retire one that fails, since a broken image is worse
|
|
8
|
+
* than the stand-in.
|
|
9
|
+
*/
|
|
10
|
+
thumbnailUrl?: string | null;
|
|
11
|
+
/** Shown in the media box when there is no thumbnail: an icon, or a spinner. */
|
|
12
|
+
media?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* Marks the whole chip busy, for an upload that has not settled. Surfaces as
|
|
15
|
+
* `data-busy` on both roots and as `aria-busy` on the container root only —
|
|
16
|
+
* React Aria filters `aria-busy` out of `Button`'s DOM props, so a pressable
|
|
17
|
+
* chip cannot carry it and its caller should announce the state in a live
|
|
18
|
+
* region instead.
|
|
19
|
+
*/
|
|
20
|
+
isBusy?: boolean;
|
|
21
|
+
/** Fires when `thumbnailUrl` fails to load. */
|
|
22
|
+
onImageError?: () => void;
|
|
23
|
+
/**
|
|
24
|
+
* Makes the chip itself the control. Use it for a summary that opens
|
|
25
|
+
* something; leave it off when `action` is the only control, so the chip does
|
|
26
|
+
* not become a focus stop wrapping another button.
|
|
27
|
+
*/
|
|
28
|
+
onPress?: () => void;
|
|
29
|
+
/** Trailing control — typically a remove `IconButton`. Ignored with `onPress`. */
|
|
30
|
+
action?: ReactNode;
|
|
31
|
+
className?: string;
|
|
32
|
+
style?: CSSProperties;
|
|
33
|
+
/**
|
|
34
|
+
* The `div` root only. With `onPress` the root is a RAC `Button`, whose
|
|
35
|
+
* element type disagrees, and widening this to a union would stop an
|
|
36
|
+
* existing `RefObject<HTMLDivElement>` type-checking — so it is dropped
|
|
37
|
+
* there rather than forwarded. A pressable chip needs no ref today: RAC's
|
|
38
|
+
* modal restores focus to its trigger on dismiss.
|
|
39
|
+
*/
|
|
40
|
+
ref?: Ref<HTMLDivElement>;
|
|
41
|
+
id?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Deliberately the only passthrough besides `id` and the two ARIA props
|
|
44
|
+
* below: the two roots are a `div` and a RAC `Button`, whose event-handler
|
|
45
|
+
* types disagree, so a blanket `HTMLAttributes` spread cannot type-check
|
|
46
|
+
* against both.
|
|
47
|
+
*/
|
|
48
|
+
"data-testid"?: string;
|
|
49
|
+
/**
|
|
50
|
+
* What pressing the chip opens. `onPress` only makes it a button; without
|
|
51
|
+
* this a chip that opens the attachments sheet reads as "3 attachments,
|
|
52
|
+
* button" with no hint that a dialog follows. Ignored without `onPress`.
|
|
53
|
+
*/
|
|
54
|
+
"aria-haspopup"?: "dialog" | "menu" | "listbox" | "true";
|
|
55
|
+
/** Whether what `aria-haspopup` names is currently open. */
|
|
56
|
+
"aria-expanded"?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A staged or attached file inside the composer field: a thumbnail (or a
|
|
60
|
+
* stand-in), its name, and one control.
|
|
61
|
+
*
|
|
62
|
+
* Two shapes, and they are mutually exclusive by construction. With `action` the
|
|
63
|
+
* chip is a plain container and the trailing button is the only control — one
|
|
64
|
+
* file, removable. With `onPress` the chip itself is the control and the
|
|
65
|
+
* trailing slot is dropped, because a summary standing for several files has
|
|
66
|
+
* nowhere sensible to put a single remove. Passing both would nest a button
|
|
67
|
+
* inside a button, which is invalid and unreachable by keyboard.
|
|
68
|
+
*/
|
|
69
|
+
export declare function AttachmentChip({ label, thumbnailUrl, media, isBusy, onImageError, onPress, action, className, style, ref, id, "aria-haspopup": ariaHasPopup, "aria-expanded": ariaExpanded, "data-testid": testId, }: AttachmentChipProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { cx as e } from "../../utils/cx.js";
|
|
2
|
+
import { attachmentChipLabel as t, attachmentChipMedia as n, attachmentChipRoot as r, attachmentChipThumbnail as i } from "./AttachmentChip.css.js";
|
|
3
|
+
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
4
|
+
import { Button as c } from "react-aria-components";
|
|
5
|
+
//#region src/components/AttachmentChip/AttachmentChip.tsx
|
|
6
|
+
function l({ label: l, thumbnailUrl: u, media: d, isBusy: f, onImageError: p, onPress: m, action: h, className: g, style: _, ref: v, id: y, "aria-haspopup": b, "aria-expanded": x, "data-testid": S }) {
|
|
7
|
+
let C = /* @__PURE__ */ s(a, { children: [
|
|
8
|
+
/* @__PURE__ */ o("span", {
|
|
9
|
+
className: n,
|
|
10
|
+
"aria-hidden": "true",
|
|
11
|
+
children: u ? /* @__PURE__ */ o("img", {
|
|
12
|
+
className: i,
|
|
13
|
+
src: u,
|
|
14
|
+
alt: "",
|
|
15
|
+
onError: p
|
|
16
|
+
}) : d
|
|
17
|
+
}),
|
|
18
|
+
/* @__PURE__ */ o("span", {
|
|
19
|
+
className: t,
|
|
20
|
+
dir: "auto",
|
|
21
|
+
title: l,
|
|
22
|
+
children: l
|
|
23
|
+
}),
|
|
24
|
+
!m && h
|
|
25
|
+
] });
|
|
26
|
+
return m ? /* @__PURE__ */ o(c, {
|
|
27
|
+
id: y,
|
|
28
|
+
"data-testid": S,
|
|
29
|
+
"aria-label": l,
|
|
30
|
+
"aria-haspopup": b,
|
|
31
|
+
"aria-expanded": x,
|
|
32
|
+
"data-busy": f || void 0,
|
|
33
|
+
className: e(r({ interactive: !0 }), g),
|
|
34
|
+
style: _,
|
|
35
|
+
onPress: m,
|
|
36
|
+
children: C
|
|
37
|
+
}) : /* @__PURE__ */ o("div", {
|
|
38
|
+
id: y,
|
|
39
|
+
"data-testid": S,
|
|
40
|
+
ref: v,
|
|
41
|
+
"aria-busy": f || void 0,
|
|
42
|
+
"data-busy": f || void 0,
|
|
43
|
+
className: e(r({ interactive: !1 }), g),
|
|
44
|
+
style: _,
|
|
45
|
+
children: C
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { l as AttachmentChip };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=AttachmentChip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttachmentChip.js","names":[],"sources":["../../../src/components/AttachmentChip/AttachmentChip.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode, Ref } from \"react\";\nimport { Button as AriaButton } from \"react-aria-components\";\nimport { cx } from \"../../utils/cx.js\";\nimport {\n\tattachmentChipLabel,\n\tattachmentChipMedia,\n\tattachmentChipRoot,\n\tattachmentChipThumbnail,\n} from \"./AttachmentChip.css.js\";\n\nexport interface AttachmentChipProps {\n\t/** Filename, or a summary such as \"3 attachments\". */\n\tlabel: string;\n\t/**\n\t * Thumbnail source, rendered as given. Validate it first — and use\n\t * `onImageError` to retire one that fails, since a broken image is worse\n\t * than the stand-in.\n\t */\n\tthumbnailUrl?: string | null;\n\t/** Shown in the media box when there is no thumbnail: an icon, or a spinner. */\n\tmedia?: ReactNode;\n\t/**\n\t * Marks the whole chip busy, for an upload that has not settled. Surfaces as\n\t * `data-busy` on both roots and as `aria-busy` on the container root only —\n\t * React Aria filters `aria-busy` out of `Button`'s DOM props, so a pressable\n\t * chip cannot carry it and its caller should announce the state in a live\n\t * region instead.\n\t */\n\tisBusy?: boolean;\n\t/** Fires when `thumbnailUrl` fails to load. */\n\tonImageError?: () => void;\n\t/**\n\t * Makes the chip itself the control. Use it for a summary that opens\n\t * something; leave it off when `action` is the only control, so the chip does\n\t * not become a focus stop wrapping another button.\n\t */\n\tonPress?: () => void;\n\t/** Trailing control — typically a remove `IconButton`. Ignored with `onPress`. */\n\taction?: ReactNode;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\t/**\n\t * The `div` root only. With `onPress` the root is a RAC `Button`, whose\n\t * element type disagrees, and widening this to a union would stop an\n\t * existing `RefObject<HTMLDivElement>` type-checking — so it is dropped\n\t * there rather than forwarded. A pressable chip needs no ref today: RAC's\n\t * modal restores focus to its trigger on dismiss.\n\t */\n\tref?: Ref<HTMLDivElement>;\n\tid?: string;\n\t/**\n\t * Deliberately the only passthrough besides `id` and the two ARIA props\n\t * below: the two roots are a `div` and a RAC `Button`, whose event-handler\n\t * types disagree, so a blanket `HTMLAttributes` spread cannot type-check\n\t * against both.\n\t */\n\t\"data-testid\"?: string;\n\t/**\n\t * What pressing the chip opens. `onPress` only makes it a button; without\n\t * this a chip that opens the attachments sheet reads as \"3 attachments,\n\t * button\" with no hint that a dialog follows. Ignored without `onPress`.\n\t */\n\t\"aria-haspopup\"?: \"dialog\" | \"menu\" | \"listbox\" | \"true\";\n\t/** Whether what `aria-haspopup` names is currently open. */\n\t\"aria-expanded\"?: boolean;\n}\n\n/**\n * A staged or attached file inside the composer field: a thumbnail (or a\n * stand-in), its name, and one control.\n *\n * Two shapes, and they are mutually exclusive by construction. With `action` the\n * chip is a plain container and the trailing button is the only control — one\n * file, removable. With `onPress` the chip itself is the control and the\n * trailing slot is dropped, because a summary standing for several files has\n * nowhere sensible to put a single remove. Passing both would nest a button\n * inside a button, which is invalid and unreachable by keyboard.\n */\nexport function AttachmentChip({\n\tlabel,\n\tthumbnailUrl,\n\tmedia,\n\tisBusy,\n\tonImageError,\n\tonPress,\n\taction,\n\tclassName,\n\tstyle,\n\tref,\n\tid,\n\t\"aria-haspopup\": ariaHasPopup,\n\t\"aria-expanded\": ariaExpanded,\n\t\"data-testid\": testId,\n}: AttachmentChipProps) {\n\tconst content = (\n\t\t<>\n\t\t\t{/* Decorative: the label beside it is the accessible text, so alt text\n\t\t\t of the filename would read it twice. */}\n\t\t\t<span className={attachmentChipMedia} aria-hidden=\"true\">\n\t\t\t\t{thumbnailUrl ? (\n\t\t\t\t\t<img\n\t\t\t\t\t\tclassName={attachmentChipThumbnail}\n\t\t\t\t\t\tsrc={thumbnailUrl}\n\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\tonError={onImageError}\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\tmedia\n\t\t\t\t)}\n\t\t\t</span>\n\t\t\t<span className={attachmentChipLabel} dir=\"auto\" title={label}>\n\t\t\t\t{label}\n\t\t\t</span>\n\t\t\t{!onPress && action}\n\t\t</>\n\t);\n\n\tif (onPress) {\n\t\treturn (\n\t\t\t<AriaButton\n\t\t\t\tid={id}\n\t\t\t\tdata-testid={testId}\n\t\t\t\taria-label={label}\n\t\t\t\taria-haspopup={ariaHasPopup}\n\t\t\t\taria-expanded={ariaExpanded}\n\t\t\t\tdata-busy={isBusy || undefined}\n\t\t\t\tclassName={cx(attachmentChipRoot({ interactive: true }), className)}\n\t\t\t\tstyle={style}\n\t\t\t\tonPress={onPress}\n\t\t\t>\n\t\t\t\t{content}\n\t\t\t</AriaButton>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tid={id}\n\t\t\tdata-testid={testId}\n\t\t\tref={ref}\n\t\t\taria-busy={isBusy || undefined}\n\t\t\tdata-busy={isBusy || undefined}\n\t\t\tclassName={cx(attachmentChipRoot({ interactive: false }), className)}\n\t\t\tstyle={style}\n\t\t>\n\t\t\t{content}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;AA8EA,SAAgB,EAAe,EAC9B,UACA,iBACA,UACA,WACA,iBACA,YACA,WACA,cACA,UACA,QACA,OACA,iBAAiB,GACjB,iBAAiB,GACjB,eAAe,KACQ;CACvB,IAAM,IACL,kBAAA,GAAA,EAAA,UAAA;EAGC,kBAAC,QAAD;GAAM,WAAW;GAAqB,eAAY;aAChD,IACA,kBAAC,OAAD;IACC,WAAW;IACX,KAAK;IACL,KAAI;IACJ,SAAS;IACR,CAAA,GAEF;GAEK,CAAA;EACP,kBAAC,QAAD;GAAM,WAAW;GAAqB,KAAI;GAAO,OAAO;aACtD;GACK,CAAA;EACN,CAAC,KAAW;EACX,EAAA,CAAA;AAqBJ,QAlBI,IAEF,kBAAC,GAAD;EACK;EACJ,eAAa;EACb,cAAY;EACZ,iBAAe;EACf,iBAAe;EACf,aAAW,KAAU,KAAA;EACrB,WAAW,EAAG,EAAmB,EAAE,aAAa,IAAM,CAAC,EAAE,EAAU;EAC5D;EACE;YAER;EACW,CAAA,GAKd,kBAAC,OAAD;EACK;EACJ,eAAa;EACR;EACL,aAAW,KAAU,KAAA;EACrB,aAAW,KAAU,KAAA;EACrB,WAAW,EAAG,EAAmB,EAAE,aAAa,IAAO,CAAC,EAAE,EAAU;EAC7D;YAEN;EACI,CAAA"}
|