@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.
Files changed (91) hide show
  1. package/dist/components/AgentMessage/AgentMessage.css.d.ts +0 -1
  2. package/dist/components/AgentMessage/AgentMessage.css.js +2 -2
  3. package/dist/components/AgentMessage/AgentMessage.css.js.map +1 -1
  4. package/dist/components/AgentMessage/AgentMessage.d.ts +19 -12
  5. package/dist/components/AgentMessage/AgentMessage.js +9 -17
  6. package/dist/components/AgentMessage/AgentMessage.js.map +1 -1
  7. package/dist/components/AttachmentChip/AttachmentChip.css.d.ts +13 -0
  8. package/dist/components/AttachmentChip/AttachmentChip.css.js +16 -0
  9. package/dist/components/AttachmentChip/AttachmentChip.css.js.map +1 -0
  10. package/dist/components/AttachmentChip/AttachmentChip.d.ts +69 -0
  11. package/dist/components/AttachmentChip/AttachmentChip.js +51 -0
  12. package/dist/components/AttachmentChip/AttachmentChip.js.map +1 -0
  13. package/dist/components/AttachmentChip/index.d.ts +2 -0
  14. package/dist/components/Avatar/Avatar.css.d.ts +8 -8
  15. package/dist/components/Avatar/Avatar.css.js +1 -1
  16. package/dist/components/Button/Button.css.d.ts +14 -14
  17. package/dist/components/Checkbox/Checkbox.css.d.ts +1 -1
  18. package/dist/components/Checkbox/Checkbox.css.js.map +1 -1
  19. package/dist/components/Chip/Chip.css.d.ts +4 -4
  20. package/dist/components/Dialog/Dialog.css.d.ts +2 -2
  21. package/dist/components/Divider/Divider.css.d.ts +2 -2
  22. package/dist/components/DropZone/DropZone.js +4 -4
  23. package/dist/components/Icon/icons/Document.d.ts +2 -0
  24. package/dist/components/Icon/icons/Document.js +14 -0
  25. package/dist/components/Icon/icons/Document.js.map +1 -0
  26. package/dist/components/Icon/icons/index.d.ts +1 -0
  27. package/dist/components/IconButton/IconButton.css.d.ts +14 -14
  28. package/dist/components/Input/Input.css.d.ts +5 -0
  29. package/dist/components/Input/Input.css.js.map +1 -1
  30. package/dist/components/Input/InputAttachments.d.ts +13 -2
  31. package/dist/components/Input/InputAttachments.js.map +1 -1
  32. package/dist/components/Input/InputField.d.ts +8 -1
  33. package/dist/components/Input/InputField.js +6 -5
  34. package/dist/components/Input/InputField.js.map +1 -1
  35. package/dist/components/Input/InputRoot.js +4 -4
  36. package/dist/components/Input/InputTextArea.js +7 -7
  37. package/dist/components/Link/Link.d.ts +7 -0
  38. package/dist/components/Link/Link.js.map +1 -1
  39. package/dist/components/MenuItem/MenuItem.css.js.map +1 -1
  40. package/dist/components/MenuItem/MenuItemRoot.js +9 -9
  41. package/dist/components/MessageError/MessageError.css.d.ts +5 -0
  42. package/dist/components/MessageError/MessageError.css.js +7 -0
  43. package/dist/components/MessageError/MessageError.css.js.map +1 -0
  44. package/dist/components/MessageError/MessageError.d.ts +38 -0
  45. package/dist/components/MessageError/MessageError.js +38 -0
  46. package/dist/components/MessageError/MessageError.js.map +1 -0
  47. package/dist/components/MessageError/index.d.ts +1 -0
  48. package/dist/components/MessageProse/MessageProse.css.d.ts +20 -0
  49. package/dist/components/MessageProse/MessageProse.css.js +7 -0
  50. package/dist/components/MessageProse/MessageProse.css.js.map +1 -0
  51. package/dist/components/MessageProse/MessageProse.d.ts +25 -0
  52. package/dist/components/MessageProse/MessageProse.js +17 -0
  53. package/dist/components/MessageProse/MessageProse.js.map +1 -0
  54. package/dist/components/MessageProse/index.d.ts +2 -0
  55. package/dist/components/MessageRow/MessageRow.context.d.ts +5 -0
  56. package/dist/components/MessageRow/MessageRow.context.js +7 -0
  57. package/dist/components/MessageRow/MessageRow.context.js.map +1 -0
  58. package/dist/components/MessageRow/MessageRow.css.d.ts +29 -0
  59. package/dist/components/MessageRow/MessageRow.css.js +39 -0
  60. package/dist/components/MessageRow/MessageRow.css.js.map +1 -0
  61. package/dist/components/MessageRow/MessageRow.d.ts +8 -0
  62. package/dist/components/MessageRow/MessageRow.js +8 -0
  63. package/dist/components/MessageRow/MessageRow.js.map +1 -0
  64. package/dist/components/MessageRow/MessageRowContent.d.ts +20 -0
  65. package/dist/components/MessageRow/MessageRowContent.js +21 -0
  66. package/dist/components/MessageRow/MessageRowContent.js.map +1 -0
  67. package/dist/components/MessageRow/MessageRowRoot.d.ts +23 -0
  68. package/dist/components/MessageRow/MessageRowRoot.js +19 -0
  69. package/dist/components/MessageRow/MessageRowRoot.js.map +1 -0
  70. package/dist/components/MessageRow/index.d.ts +2 -0
  71. package/dist/components/PictureMessage/PictureMessage.css.d.ts +2 -2
  72. package/dist/components/Radio/Radio.css.d.ts +1 -1
  73. package/dist/components/Radio/Radio.css.js.map +1 -1
  74. package/dist/components/ScrollMarker/ScrollMarker.css.d.ts +6 -6
  75. package/dist/components/Spinner/Spinner.css.d.ts +2 -2
  76. package/dist/components/ToastNotification/ToastNotification.css.d.ts +6 -6
  77. package/dist/components/UserMessage/UserMessage.css.d.ts +0 -5
  78. package/dist/components/UserMessage/UserMessage.css.js +2 -2
  79. package/dist/components/UserMessage/UserMessage.css.js.map +1 -1
  80. package/dist/components/UserMessage/UserMessage.d.ts +10 -12
  81. package/dist/components/UserMessage/UserMessage.js +12 -38
  82. package/dist/components/UserMessage/UserMessage.js.map +1 -1
  83. package/dist/components/VideoMessage/VideoMessage.js +4 -4
  84. package/dist/index.d.ts +3 -0
  85. package/dist/index.js +86 -82
  86. package/dist/style.css +1 -1
  87. package/dist/styles/{row.d.ts → control-row.d.ts} +3 -3
  88. package/dist/tokens/generated/tokens.d.ts +1 -1
  89. package/dist/tokens/tokens.d.ts +2 -2
  90. package/dist/tokens.css +6 -0
  91. package/package.json +1 -1
@@ -1,2 +1 @@
1
- export declare const agentMessageRoot: string;
2
1
  export declare const agentMessageBody: string;
@@ -1,7 +1,7 @@
1
1
  /* empty css */
2
2
  //#region src/components/AgentMessage/AgentMessage.css.ts
3
- var e = "_1xn6t060", t = "_1xn6t061";
3
+ var e = "_1xn6t060";
4
4
  //#endregion
5
- export { t as agentMessageBody, e as agentMessageRoot };
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\";\nimport { t } from \"../../tokens/index.js\";\n\n// `row` follows the ambient inline direction, so the avatar leads on the left\n// in LTR and trails on the right under `[dir=\"rtl\"]` — no per-direction variant.\nexport const agentMessageRoot = style({\n\tdisplay: \"flex\",\n\talignItems: \"flex-start\",\n\tgap: t(\"gap-12\"),\n});\n\nexport const agentMessageBody = style({\n\tmargin: 0,\n\tflex: \"1 0 0\",\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\tcolor: t(\"color-content-default\"),\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\toverflowWrap: \"anywhere\",\n\twordBreak: \"break-word\",\n});\n"],"mappings":""}
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 text. */
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: a decorative avatar bubble beside the
13
- * message text. The avatar conveys nothing beyond the text, so it is hidden
14
- * from assistive tech. Announcing new messages is the consuming transcript's
15
- * responsibility — wrap the message list in a single persistent live region
16
- * (e.g. `role="log"`) rather than giving each message its own, since a
17
- * per-message live region mounted already-populated is not reliably announced.
18
- * The row mirrors under an ambient `[dir="rtl"]` and the text direction is
19
- * detected from its own content.
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({ initials, className, children, ...rest }: AgentMessageProps): import("react/jsx-runtime").JSX.Element;
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 { Avatar as t } from "../Avatar/Avatar.js";
3
- import { agentMessageBody as n, agentMessageRoot as r } from "./AgentMessage.css.js";
4
- import { jsx as i, jsxs as a } from "react/jsx-runtime";
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 o({ initials: o = "C", className: s, children: c, ...l }) {
7
- return /* @__PURE__ */ a("div", {
8
- ...l,
9
- className: e(r, s),
10
- children: [/* @__PURE__ */ i(t, {
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 { o as AgentMessage };
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 { Avatar } from \"../Avatar/index.js\";\nimport { agentMessageBody, agentMessageRoot } from \"./AgentMessage.css.js\";\n\nexport interface AgentMessageProps {\n\t/** Monogram shown in the agent avatar bubble. */\n\tinitials?: string;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n\t/** The agent's message text. */\n\tchildren?: ReactNode;\n}\n\n/**\n * A single chat message from the agent: a decorative avatar bubble beside the\n * message text. The avatar conveys nothing beyond the text, so it is hidden\n * from assistive tech. Announcing new messages is the consuming transcript's\n * responsibility — wrap the message list in a single persistent live region\n * (e.g. `role=\"log\"`) rather than giving each message its own, since a\n * per-message live region mounted already-populated is not reliably announced.\n * The row mirrors under an ambient `[dir=\"rtl\"]` and the text direction is\n * detected from its own content.\n */\nexport function AgentMessage({\n\tinitials = \"C\",\n\tclassName,\n\tchildren,\n\t...rest\n}: AgentMessageProps) {\n\treturn (\n\t\t<div {...rest} className={cx(agentMessageRoot, className)}>\n\t\t\t<Avatar aria-hidden size=\"sm\">\n\t\t\t\t{initials}\n\t\t\t</Avatar>\n\t\t\t<p dir=\"auto\" className={agentMessageBody}>\n\t\t\t\t{children}\n\t\t\t</p>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;AAyBA,SAAgB,EAAa,EAC5B,cAAW,KACX,cACA,aACA,GAAG,KACkB;AACrB,QACC,kBAAC,OAAD;EAAK,GAAI;EAAM,WAAW,EAAG,GAAkB,EAAU;YAAzD,CACC,kBAAC,GAAD;GAAQ,eAAA;GAAY,MAAK;aACvB;GACO,CAAA,EACT,kBAAC,KAAD;GAAG,KAAI;GAAO,WAAW;GACvB;GACE,CAAA,CACC"}
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"}
@@ -0,0 +1,2 @@
1
+ export type { AttachmentChipProps } from "./AttachmentChip.js";
2
+ export { AttachmentChip } from "./AttachmentChip.js";