@ada-cx/lovelace 1.21.6 → 1.22.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/README.md +2 -2
- package/dist/components/AgentMessage/AgentMessage.css.js.map +1 -1
- package/dist/components/Button/Button.css.d.ts +3 -0
- package/dist/components/Button/Button.css.js +1 -0
- package/dist/components/Button/Button.css.js.map +1 -1
- package/dist/components/Chip/Chip.css.js +1 -0
- package/dist/components/Chip/Chip.css.js.map +1 -1
- package/dist/components/Chip/Chip.d.ts +2 -1
- package/dist/components/Chip/Chip.js.map +1 -1
- package/dist/components/IconButton/IconButton.css.d.ts +3 -0
- package/dist/components/IconButton/IconButton.css.js +1 -0
- package/dist/components/IconButton/IconButton.css.js.map +1 -1
- package/dist/components/Input/Input.css.d.ts +5 -1
- package/dist/components/Input/Input.css.js +1 -0
- package/dist/components/Input/Input.css.js.map +1 -1
- package/dist/components/MessageProse/MessageProse.css.d.ts +5 -6
- package/dist/components/MessageProse/MessageProse.css.js.map +1 -1
- package/dist/components/MessageRow/MessageRow.css.js.map +1 -1
- package/dist/components/PictureMessage/PictureMessage.d.ts +6 -1
- package/dist/components/PictureMessage/PictureMessage.js +10 -10
- package/dist/components/PictureMessage/PictureMessage.js.map +1 -1
- package/dist/components/ScrollMarker/ScrollMarker.css.d.ts +3 -0
- package/dist/components/ScrollMarker/ScrollMarker.css.js +1 -0
- package/dist/components/ScrollMarker/ScrollMarker.css.js.map +1 -1
- package/dist/components/SurveySelect/SurveySelect.d.ts +1 -1
- package/dist/components/SurveySelect/SurveySelect.js.map +1 -1
- package/dist/components/Toast/Toast.css.d.ts +6 -0
- package/dist/components/Toast/Toast.css.js +2 -2
- package/dist/components/Toast/Toast.css.js.map +1 -1
- package/dist/components/Toast/Toast.d.ts +2 -3
- package/dist/components/Toast/Toast.js.map +1 -1
- package/dist/components/Toast/ToastAnnouncer.d.ts +21 -0
- package/dist/components/Toast/ToastAnnouncer.js +104 -0
- package/dist/components/Toast/ToastAnnouncer.js.map +1 -0
- package/dist/components/Toast/ToastContainer.d.ts +11 -8
- package/dist/components/Toast/ToastContainer.js +46 -51
- package/dist/components/Toast/ToastContainer.js.map +1 -1
- package/dist/components/Toast/ToastItem.d.ts +7 -1
- package/dist/components/UserMessage/UserMessage.css.js.map +1 -1
- package/dist/components/VideoMessage/VideoMessage.d.ts +8 -1
- package/dist/components/VideoMessage/VideoMessage.js +9 -9
- package/dist/components/VideoMessage/VideoMessage.js.map +1 -1
- package/dist/runtime/LovelaceProvider.js +29 -26
- package/dist/runtime/LovelaceProvider.js.map +1 -1
- package/dist/runtime/branding.d.ts +71 -19
- package/dist/runtime/branding.js +97 -10
- package/dist/runtime/branding.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/styles/state-layer.css.d.ts +19 -0
- package/dist/styles/state-layer.css.js +23 -0
- package/dist/styles/state-layer.css.js.map +1 -0
- package/dist/tokens/generated/tokens.d.ts +7 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ import { t } from "@ada-cx/lovelace/tokens";
|
|
|
58
58
|
</LovelaceProvider>;
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
Overrides ride above the token layer as inline CSS variables, so they always win over the shipped defaults. Any unlayered `--lovelace-*` rule you write yourself wins the same way. If you need tokens without component styles, for example to build a custom theme, import `@ada-cx/lovelace/tokens.css` alone.
|
|
61
|
+
Overrides ride above the token layer as inline CSS variables, so they always win over the shipped defaults. Any unlayered `--lovelace-*` rule you write yourself wins the same way. Set an accent fill and the text on it through `override` as hex colors, not in a stylesheet. The provider reads that pair to pick the hover, focus, and pressed state layer that keeps the text at 4.5:1. If the pair is not complete, or a value is not a hex color, the provider keeps the default state layer and does not check its contrast. If you need tokens without component styles, for example to build a custom theme, import `@ada-cx/lovelace/tokens.css` alone.
|
|
62
62
|
|
|
63
63
|
## Brand overrides
|
|
64
64
|
|
|
@@ -85,7 +85,7 @@ function BrandedChat({ children }) {
|
|
|
85
85
|
}
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
The mapping paints the accent fill, picks a readable black or white for text on the accent,
|
|
88
|
+
The mapping paints the accent fill, picks a readable black or white for text on the accent, darkens or lightens the tint as accent text until it holds 4.5:1 on the rendered surface, and repairs a header text color that falls below the WCAG AA 4.5:1 contrast floor against its background. Corner style and text size presets re-point the radius and type-scale tokens. Every `BrandSettings` field is optional, and `createBrandOverrides({}, scheme)` returns `{}`. Legibility guards measure hex colors only, and they do not repair other values. A tint the guards cannot read is the exception. It still paints the accent fill as configured, but its accent text is the default accent `#4e53d1`, darkened or lightened until it holds 4.5:1.
|
|
89
89
|
|
|
90
90
|
The colorimetry behind the mapping is also exported: `contrastRatioBetween`, `isLegibleAgainst`, `isLegibleOnSurface`, `LOVELACE_SURFACES`, and `readableTextOnAccent`.
|
|
91
91
|
|
|
@@ -1 +1 @@
|
|
|
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
|
+
{"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\nexport const agentMessageBody = style({\n\t// Set here as well as on the row, because a consumer can render the body\n\t// outside a `MessageRow`, and the body would then take the page colour.\n\tcolor: t(\"color-content-default\"),\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":""}
|
|
@@ -3,6 +3,9 @@ export declare const buttonRoot: import("@vanilla-extract/recipes").RuntimeFn<{
|
|
|
3
3
|
primary: {
|
|
4
4
|
backgroundColor: "var(--lovelace-button-primary-background)";
|
|
5
5
|
color: "var(--lovelace-button-primary-content)";
|
|
6
|
+
"::after": {
|
|
7
|
+
readonly backgroundColor: `var(--${string})`;
|
|
8
|
+
};
|
|
6
9
|
selectors: {
|
|
7
10
|
"&[data-disabled]": {
|
|
8
11
|
backgroundColor: "var(--lovelace-color-background-disabled)";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.css.js","names":[],"sources":["../../../src/components/Button/Button.css.ts"],"sourcesContent":["import { globalStyle, style } from \"@vanilla-extract/css\";\nimport { recipe } from \"@vanilla-extract/recipes\";\nimport { focusRing } from \"../../styles/focus-ring.js\";\nimport { typography } from \"../../styles/typography.js\";\nimport { t } from \"../../tokens/index.js\";\n\nconst buttonBase = style({});\n\nexport const buttonRoot = recipe({\n\tbase: [\n\t\tbuttonBase,\n\t\t{\n\t\t\tposition: \"relative\",\n\t\t\tisolation: \"isolate\",\n\t\t\tdisplay: \"inline-flex\",\n\t\t\talignItems: \"center\",\n\t\t\tjustifyContent: \"center\",\n\t\t\tgap: t(\"gap-8\"),\n\t\t\tpaddingInline: t(\"padding-12\"),\n\t\t\tboxSizing: \"border-box\",\n\t\t\tborder: `${t(\"border-width-default\")} solid transparent`,\n\t\t\tborderRadius: t(\"border-radius-button\"),\n\t\t\t...typography(\"body\", \"medium\"),\n\t\t\twhiteSpace: \"nowrap\",\n\t\t\tcursor: \"pointer\",\n\t\t\tuserSelect: \"none\",\n\t\t\tappearance: \"none\",\n\t\t\ttextDecoration: \"none\",\n\t\t\toutline: \"none\",\n\t\t\ttransitionProperty: \"background-color, border-color\",\n\t\t\ttransitionDuration: t(\"duration-fast\"),\n\t\t\ttransitionTimingFunction: t(\"easing-standard\"),\n\t\t\t\"::after\": {\n\t\t\t\tcontent: '\"\"',\n\t\t\t\tposition: \"absolute\",\n\t\t\t\tinset: 0,\n\t\t\t\tborderRadius: \"inherit\",\n\t\t\t\tbackgroundColor: \"currentColor\",\n\t\t\t\topacity: 0,\n\t\t\t\tpointerEvents: \"none\",\n\t\t\t\tzIndex: -1,\n\t\t\t\ttransition: `opacity ${t(\"duration-fast\")} ${t(\"easing-standard\")}`,\n\t\t\t},\n\t\t\tselectors: {\n\t\t\t\t\"&[data-hovered]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-hover\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-focus-visible]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-focus\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-pressed]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-pressed\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": focusRing,\n\t\t\t\t\"&[data-disabled]\": {\n\t\t\t\t\tcursor: \"not-allowed\",\n\t\t\t\t\tcolor: t(\"color-content-disabled\"),\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"@media\": {\n\t\t\t\t\"(forced-colors: active)\": {\n\t\t\t\t\tselectors: {\n\t\t\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": {\n\t\t\t\t\t\t\toutline: \"2px solid Highlight\",\n\t\t\t\t\t\t\toutlineOffset: \"2px\",\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},\n\t],\n\tvariants: {\n\t\tintent: {\n\t\t\tprimary: {\n\t\t\t\tbackgroundColor: t(\"button-primary-background\"),\n\t\t\t\tcolor: t(\"button-primary-content\"),\n\t\t\t\tselectors: {\n\t\t\t\t\t\"&[data-disabled]\": {\n\t\t\t\t\t\tbackgroundColor: t(\"color-background-disabled\"),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"primary-destructive\": {\n\t\t\t\tbackgroundColor: t(\"color-background-destructive\"),\n\t\t\t\tcolor: t(\"color-content-on-destructive\"),\n\t\t\t\tselectors: {\n\t\t\t\t\t\"&[data-disabled]\": {\n\t\t\t\t\t\tbackgroundColor: t(\"color-background-disabled\"),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tsecondary: {\n\t\t\t\tbackgroundColor: t(\"color-background-default\"),\n\t\t\t\tcolor: t(\"color-content-default\"),\n\t\t\t\tborderColor: t(\"color-border-default\"),\n\t\t\t},\n\t\t\t\"secondary-destructive\": {\n\t\t\t\tbackgroundColor: t(\"color-background-default\"),\n\t\t\t\tcolor: t(\"color-content-destructive\"),\n\t\t\t\tborderColor: t(\"color-border-destructive\"),\n\t\t\t},\n\t\t\ttertiary: {\n\t\t\t\tbackgroundColor: \"transparent\",\n\t\t\t\tcolor: t(\"color-content-default\"),\n\t\t\t},\n\t\t\t\"tertiary-destructive\": {\n\t\t\t\tbackgroundColor: \"transparent\",\n\t\t\t\tcolor: t(\"color-content-destructive\"),\n\t\t\t},\n\t\t},\n\t\t// Hardcoded heights are correct.\n\t\tsize: {\n\t\t\tmd: { height: \"40px\" },\n\t\t\tsm: { height: \"32px\" },\n\t\t},\n\t},\n\tdefaultVariants: {\n\t\tintent: \"primary\",\n\t\tsize: \"md\",\n\t},\n});\n\nglobalStyle(`${buttonBase} [data-slot='icon']`, {\n\tflexShrink: 0,\n\tfontSize: t(\"icon-size-control\"),\n});\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Button.css.js","names":[],"sources":["../../../src/components/Button/Button.css.ts"],"sourcesContent":["import { globalStyle, style } from \"@vanilla-extract/css\";\nimport { recipe } from \"@vanilla-extract/recipes\";\nimport { focusRing } from \"../../styles/focus-ring.js\";\nimport { stateLayerOnAccent } from \"../../styles/state-layer.css.js\";\nimport { typography } from \"../../styles/typography.js\";\nimport { t } from \"../../tokens/index.js\";\n\nconst buttonBase = style({});\n\nexport const buttonRoot = recipe({\n\tbase: [\n\t\tbuttonBase,\n\t\t{\n\t\t\tposition: \"relative\",\n\t\t\tisolation: \"isolate\",\n\t\t\tdisplay: \"inline-flex\",\n\t\t\talignItems: \"center\",\n\t\t\tjustifyContent: \"center\",\n\t\t\tgap: t(\"gap-8\"),\n\t\t\tpaddingInline: t(\"padding-12\"),\n\t\t\tboxSizing: \"border-box\",\n\t\t\tborder: `${t(\"border-width-default\")} solid transparent`,\n\t\t\tborderRadius: t(\"border-radius-button\"),\n\t\t\t...typography(\"body\", \"medium\"),\n\t\t\twhiteSpace: \"nowrap\",\n\t\t\tcursor: \"pointer\",\n\t\t\tuserSelect: \"none\",\n\t\t\tappearance: \"none\",\n\t\t\ttextDecoration: \"none\",\n\t\t\toutline: \"none\",\n\t\t\ttransitionProperty: \"background-color, border-color\",\n\t\t\ttransitionDuration: t(\"duration-fast\"),\n\t\t\ttransitionTimingFunction: t(\"easing-standard\"),\n\t\t\t\"::after\": {\n\t\t\t\tcontent: '\"\"',\n\t\t\t\tposition: \"absolute\",\n\t\t\t\tinset: 0,\n\t\t\t\tborderRadius: \"inherit\",\n\t\t\t\tbackgroundColor: \"currentColor\",\n\t\t\t\topacity: 0,\n\t\t\t\tpointerEvents: \"none\",\n\t\t\t\tzIndex: -1,\n\t\t\t\ttransition: `opacity ${t(\"duration-fast\")} ${t(\"easing-standard\")}`,\n\t\t\t},\n\t\t\tselectors: {\n\t\t\t\t\"&[data-hovered]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-hover\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-focus-visible]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-focus\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-pressed]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-pressed\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": focusRing,\n\t\t\t\t\"&[data-disabled]\": {\n\t\t\t\t\tcursor: \"not-allowed\",\n\t\t\t\t\tcolor: t(\"color-content-disabled\"),\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"@media\": {\n\t\t\t\t\"(forced-colors: active)\": {\n\t\t\t\t\tselectors: {\n\t\t\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": {\n\t\t\t\t\t\t\toutline: \"2px solid Highlight\",\n\t\t\t\t\t\t\toutlineOffset: \"2px\",\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},\n\t],\n\tvariants: {\n\t\tintent: {\n\t\t\tprimary: {\n\t\t\t\tbackgroundColor: t(\"button-primary-background\"),\n\t\t\t\tcolor: t(\"button-primary-content\"),\n\t\t\t\t\"::after\": stateLayerOnAccent.buttonPrimary,\n\t\t\t\tselectors: {\n\t\t\t\t\t\"&[data-disabled]\": {\n\t\t\t\t\t\tbackgroundColor: t(\"color-background-disabled\"),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"primary-destructive\": {\n\t\t\t\tbackgroundColor: t(\"color-background-destructive\"),\n\t\t\t\tcolor: t(\"color-content-on-destructive\"),\n\t\t\t\tselectors: {\n\t\t\t\t\t\"&[data-disabled]\": {\n\t\t\t\t\t\tbackgroundColor: t(\"color-background-disabled\"),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tsecondary: {\n\t\t\t\tbackgroundColor: t(\"color-background-default\"),\n\t\t\t\tcolor: t(\"color-content-default\"),\n\t\t\t\tborderColor: t(\"color-border-default\"),\n\t\t\t},\n\t\t\t\"secondary-destructive\": {\n\t\t\t\tbackgroundColor: t(\"color-background-default\"),\n\t\t\t\tcolor: t(\"color-content-destructive\"),\n\t\t\t\tborderColor: t(\"color-border-destructive\"),\n\t\t\t},\n\t\t\ttertiary: {\n\t\t\t\tbackgroundColor: \"transparent\",\n\t\t\t\tcolor: t(\"color-content-default\"),\n\t\t\t},\n\t\t\t\"tertiary-destructive\": {\n\t\t\t\tbackgroundColor: \"transparent\",\n\t\t\t\tcolor: t(\"color-content-destructive\"),\n\t\t\t},\n\t\t},\n\t\t// Hardcoded heights are correct.\n\t\tsize: {\n\t\t\tmd: { height: \"40px\" },\n\t\t\tsm: { height: \"32px\" },\n\t\t},\n\t},\n\tdefaultVariants: {\n\t\tintent: \"primary\",\n\t\tsize: \"md\",\n\t},\n});\n\nglobalStyle(`${buttonBase} [data-slot='icon']`, {\n\tflexShrink: 0,\n\tfontSize: t(\"icon-size-control\"),\n});\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.css.js","names":[],"sources":["../../../src/components/Chip/Chip.css.ts"],"sourcesContent":["import { globalStyle, style } from \"@vanilla-extract/css\";\nimport { recipe } from \"@vanilla-extract/recipes\";\nimport { focusRing } from \"../../styles/focus-ring.js\";\nimport { typography } from \"../../styles/typography.js\";\nimport { t } from \"../../tokens/index.js\";\n\nconst chipBase = style({});\n\nexport const chipRoot = recipe({\n\tbase: [\n\t\tchipBase,\n\t\t{\n\t\t\tposition: \"relative\",\n\t\t\tisolation: \"isolate\",\n\t\t\tdisplay: \"inline-flex\",\n\t\t\talignItems: \"center\",\n\t\t\tjustifyContent: \"center\",\n\t\t\tboxSizing: \"border-box\",\n\t\t\tborder: `${t(\"border-width-default\")} solid transparent`,\n\t\t\t...typography(\"body\", \"medium\"),\n\t\t\twhiteSpace: \"nowrap\",\n\t\t\tcursor: \"pointer\",\n\t\t\tuserSelect: \"none\",\n\t\t\tappearance: \"none\",\n\t\t\toutline: \"none\",\n\t\t\ttransitionProperty: \"background-color, border-color\",\n\t\t\ttransitionDuration: t(\"duration-fast\"),\n\t\t\ttransitionTimingFunction: t(\"easing-standard\"),\n\t\t\t\"::after\": {\n\t\t\t\tcontent: '\"\"',\n\t\t\t\tposition: \"absolute\",\n\t\t\t\tinset: 0,\n\t\t\t\tborderRadius: \"inherit\",\n\t\t\t\tbackgroundColor: \"currentColor\",\n\t\t\t\topacity: 0,\n\t\t\t\tpointerEvents: \"none\",\n\t\t\t\tzIndex: -1,\n\t\t\t\ttransition: `opacity ${t(\"duration-fast\")} ${t(\"easing-standard\")}`,\n\t\t\t},\n\t\t\tselectors: {\n\t\t\t\t\"&:not([data-selected])\": {\n\t\t\t\t\tbackgroundColor: t(\"color-background-default\"),\n\t\t\t\t\tcolor: t(\"color-content-default\"),\n\t\t\t\t\tborderColor: t(\"color-border-default\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-selected]\": {\n\t\t\t\t\tbackgroundColor: t(\"chip-background-selected\"),\n\t\t\t\t\tcolor: t(\"color-content-on-accent\"),\n\t\t\t\t\tborderColor: \"transparent\",\n\t\t\t\t},\n\t\t\t\t\"&[data-hovered]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-hover\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-focus-visible]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-focus\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-pressed]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-pressed\"),\n\t\t\t\t},\n\t\t\t\t// Focus: inner 1px accent border + outer 2px focus ring (Figma double ring).\n\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": {\n\t\t\t\t\tborderColor: t(\"color-border-accent\"),\n\t\t\t\t\t...focusRing,\n\t\t\t\t},\n\t\t\t\t\"&[data-disabled]\": {\n\t\t\t\t\tcursor: \"not-allowed\",\n\t\t\t\t\tcolor: t(\"color-content-disabled\"),\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"@media\": {\n\t\t\t\t\"(forced-colors: active)\": {\n\t\t\t\t\tselectors: {\n\t\t\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": {\n\t\t\t\t\t\t\toutline: \"2px solid Highlight\",\n\t\t\t\t\t\t\toutlineOffset: \"2px\",\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},\n\t],\n\tvariants: {\n\t\tvariant: {\n\t\t\t// A flexible, min-80px pill; height comes from the size compound variants.\n\t\t\ttext: {\n\t\t\t\tminWidth: \"80px\",\n\t\t\t\tpaddingInline: t(\"padding-12\"),\n\t\t\t\tborderRadius: t(\"border-radius-pill\"),\n\t\t\t},\n\t\t\ticon: { borderRadius: t(\"border-radius-button\") },\n\t\t\tnumber: { borderRadius: t(\"border-radius-button\") },\n\t\t},\n\t\tsize: {\n\t\t\tmd: {},\n\t\t\tlg: {},\n\t\t},\n\t},\n\t// Dimensions per variant×size. Hardcoded px mirror Figma's fixed frame sizes;\n\t// text is a flexible pill (height only), icon/number are square. The large number\n\t// chip carries its own type size: at 48px the digit is the control's content, not\n\t// a label on it, so body type under-reads it.\n\tcompoundVariants: [\n\t\t{\n\t\t\tvariants: { variant: \"text\", size: \"md\" },\n\t\t\tstyle: { height: \"40px\" },\n\t\t},\n\t\t{\n\t\t\tvariants: { variant: \"text\", size: \"lg\" },\n\t\t\tstyle: { height: \"48px\" },\n\t\t},\n\t\t{\n\t\t\tvariants: { variant: \"icon\", size: \"md\" },\n\t\t\tstyle: { width: \"40px\", height: \"40px\" },\n\t\t},\n\t\t{\n\t\t\tvariants: { variant: \"icon\", size: \"lg\" },\n\t\t\tstyle: { width: \"48px\", height: \"48px\" },\n\t\t},\n\t\t{\n\t\t\tvariants: { variant: \"number\", size: \"md\" },\n\t\t\tstyle: { width: \"40px\", height: \"40px\" },\n\t\t},\n\t\t{\n\t\t\tvariants: { variant: \"number\", size: \"lg\" },\n\t\t\tstyle: {\n\t\t\t\twidth: \"48px\",\n\t\t\t\theight: \"48px\",\n\t\t\t\tfontSize: t(\"font-size-title-large\"),\n\t\t\t},\n\t\t},\n\t],\n\tdefaultVariants: {\n\t\tvariant: \"text\",\n\t\tsize: \"md\",\n\t},\n});\n\nglobalStyle(`${chipBase} [data-slot='icon']`, {\n\tfontSize: t(\"icon-size-control\"),\n\tflexShrink: 0,\n});\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Chip.css.js","names":[],"sources":["../../../src/components/Chip/Chip.css.ts"],"sourcesContent":["import { globalStyle, style } from \"@vanilla-extract/css\";\nimport { recipe } from \"@vanilla-extract/recipes\";\nimport { focusRing } from \"../../styles/focus-ring.js\";\nimport { stateLayerOnAccent } from \"../../styles/state-layer.css.js\";\nimport { typography } from \"../../styles/typography.js\";\nimport { t } from \"../../tokens/index.js\";\n\nconst chipBase = style({});\n\nexport const chipRoot = recipe({\n\tbase: [\n\t\tchipBase,\n\t\t{\n\t\t\tposition: \"relative\",\n\t\t\tisolation: \"isolate\",\n\t\t\tdisplay: \"inline-flex\",\n\t\t\talignItems: \"center\",\n\t\t\tjustifyContent: \"center\",\n\t\t\tboxSizing: \"border-box\",\n\t\t\tborder: `${t(\"border-width-default\")} solid transparent`,\n\t\t\t...typography(\"body\", \"medium\"),\n\t\t\twhiteSpace: \"nowrap\",\n\t\t\tcursor: \"pointer\",\n\t\t\tuserSelect: \"none\",\n\t\t\tappearance: \"none\",\n\t\t\toutline: \"none\",\n\t\t\ttransitionProperty: \"background-color, border-color, box-shadow\",\n\t\t\ttransitionDuration: t(\"duration-fast\"),\n\t\t\ttransitionTimingFunction: t(\"easing-standard\"),\n\t\t\t\"::after\": {\n\t\t\t\tcontent: '\"\"',\n\t\t\t\tposition: \"absolute\",\n\t\t\t\tinset: 0,\n\t\t\t\tborderRadius: \"inherit\",\n\t\t\t\tbackgroundColor: \"currentColor\",\n\t\t\t\topacity: 0,\n\t\t\t\tpointerEvents: \"none\",\n\t\t\t\tzIndex: -1,\n\t\t\t\ttransition: `opacity ${t(\"duration-fast\")} ${t(\"easing-standard\")}`,\n\t\t\t},\n\t\t\tselectors: {\n\t\t\t\t\"&:not([data-selected])\": {\n\t\t\t\t\tbackgroundColor: t(\"color-background-default\"),\n\t\t\t\t\tcolor: t(\"color-content-default\"),\n\t\t\t\t\tborderColor: t(\"color-border-default\"),\n\t\t\t\t},\n\t\t\t\t// The inset ring is the non-colour selected cue (WCAG 1.4.1). It draws inside\n\t\t\t\t// the border, so the chip keeps its size and its label does not move.\n\t\t\t\t\"&[data-selected]\": {\n\t\t\t\t\tbackgroundColor: t(\"chip-background-selected\"),\n\t\t\t\t\tcolor: t(\"color-content-on-accent\"),\n\t\t\t\t\tborderColor: \"transparent\",\n\t\t\t\t\tboxShadow: `inset 0 0 0 ${t(\"border-width-focus\")} currentColor`,\n\t\t\t\t},\n\t\t\t\t\"&[data-selected]::after\": stateLayerOnAccent.chipSelected,\n\t\t\t\t\"&[data-hovered]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-hover\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-focus-visible]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-focus\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-pressed]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-pressed\"),\n\t\t\t\t},\n\t\t\t\t// Focus: inner 1px accent border + outer 2px focus ring (Figma double ring).\n\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": {\n\t\t\t\t\tborderColor: t(\"color-border-accent\"),\n\t\t\t\t\t...focusRing,\n\t\t\t\t},\n\t\t\t\t\"&[data-disabled]\": {\n\t\t\t\t\tcursor: \"not-allowed\",\n\t\t\t\t\tcolor: t(\"color-content-disabled\"),\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"@media\": {\n\t\t\t\t\"(forced-colors: active)\": {\n\t\t\t\t\tselectors: {\n\t\t\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": {\n\t\t\t\t\t\t\toutline: \"2px solid Highlight\",\n\t\t\t\t\t\t\toutlineOffset: \"2px\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t// Without `none`, the browser forces the ring off and paints a Canvas\n\t\t\t\t\t\t// backplate behind the HighlightText label, which hides it.\n\t\t\t\t\t\t\"&[data-selected]\": {\n\t\t\t\t\t\t\tforcedColorAdjust: \"none\",\n\t\t\t\t\t\t\tbackgroundColor: \"Highlight\",\n\t\t\t\t\t\t\tcolor: \"HighlightText\",\n\t\t\t\t\t\t\tborderColor: \"Highlight\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"&[data-selected][data-disabled]\": {\n\t\t\t\t\t\t\tbackgroundColor: \"GrayText\",\n\t\t\t\t\t\t\tcolor: \"Canvas\",\n\t\t\t\t\t\t\tborderColor: \"GrayText\",\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},\n\t],\n\tvariants: {\n\t\tvariant: {\n\t\t\t// A flexible, min-80px pill; height comes from the size compound variants.\n\t\t\ttext: {\n\t\t\t\tminWidth: \"80px\",\n\t\t\t\tpaddingInline: t(\"padding-12\"),\n\t\t\t\tborderRadius: t(\"border-radius-pill\"),\n\t\t\t},\n\t\t\ticon: { borderRadius: t(\"border-radius-button\") },\n\t\t\tnumber: { borderRadius: t(\"border-radius-button\") },\n\t\t},\n\t\tsize: {\n\t\t\tmd: {},\n\t\t\tlg: {},\n\t\t},\n\t},\n\t// Dimensions per variant×size. Hardcoded px mirror Figma's fixed frame sizes;\n\t// text is a flexible pill (height only), icon/number are square. The large number\n\t// chip carries its own type size: at 48px the digit is the control's content, not\n\t// a label on it, so body type under-reads it.\n\tcompoundVariants: [\n\t\t{\n\t\t\tvariants: { variant: \"text\", size: \"md\" },\n\t\t\tstyle: { height: \"40px\" },\n\t\t},\n\t\t{\n\t\t\tvariants: { variant: \"text\", size: \"lg\" },\n\t\t\tstyle: { height: \"48px\" },\n\t\t},\n\t\t{\n\t\t\tvariants: { variant: \"icon\", size: \"md\" },\n\t\t\tstyle: { width: \"40px\", height: \"40px\" },\n\t\t},\n\t\t{\n\t\t\tvariants: { variant: \"icon\", size: \"lg\" },\n\t\t\tstyle: { width: \"48px\", height: \"48px\" },\n\t\t},\n\t\t{\n\t\t\tvariants: { variant: \"number\", size: \"md\" },\n\t\t\tstyle: { width: \"40px\", height: \"40px\" },\n\t\t},\n\t\t{\n\t\t\tvariants: { variant: \"number\", size: \"lg\" },\n\t\t\tstyle: {\n\t\t\t\twidth: \"48px\",\n\t\t\t\theight: \"48px\",\n\t\t\t\tfontSize: t(\"font-size-title-large\"),\n\t\t\t},\n\t\t},\n\t],\n\tdefaultVariants: {\n\t\tvariant: \"text\",\n\t\tsize: \"md\",\n\t},\n});\n\nglobalStyle(`${chipBase} [data-slot='icon']`, {\n\tfontSize: t(\"icon-size-control\"),\n\tflexShrink: 0,\n});\n"],"mappings":""}
|
|
@@ -15,7 +15,8 @@ export interface ChipProps extends Omit<AriaToggleButtonProps, "children" | "cla
|
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Tap-to-toggle selection chip for NPS and survey flows. Selection is a toggle
|
|
18
|
-
* (`isSelected`/`onChange` from React Aria); the selected state renders the accent fill
|
|
18
|
+
* (`isSelected`/`onChange` from React Aria); the selected state renders the accent fill
|
|
19
|
+
* and an inner ring, so it does not depend on colour alone.
|
|
19
20
|
*
|
|
20
21
|
* The `icon` variant has no visible text — supply an `aria-label` (or `aria-labelledby`)
|
|
21
22
|
* so the control has an accessible name.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.js","names":[],"sources":["../../../src/components/Chip/Chip.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode, Ref } from \"react\";\nimport type { ToggleButtonProps as AriaToggleButtonProps } from \"react-aria-components\";\nimport { ToggleButton as AriaToggleButton } from \"react-aria-components\";\nimport { cx } from \"../../utils/cx.js\";\nimport { chipRoot } from \"./Chip.css.js\";\n\nexport type ChipVariant = \"text\" | \"icon\" | \"number\";\nexport type ChipSize = \"md\" | \"lg\";\n\nexport interface ChipProps\n\textends Omit<AriaToggleButtonProps, \"children\" | \"className\" | \"style\"> {\n\t/** Content shape: `text` (pill label), `icon` (square glyph), or `number` (square value). */\n\tvariant?: ChipVariant;\n\t/** Control height: `md` (40px) or `lg` (48px). */\n\tsize?: ChipSize;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLButtonElement>;\n\t/** Chip content — a label, a numeric value, or a single `<Icon>`. */\n\tchildren: ReactNode;\n}\n\n/**\n * Tap-to-toggle selection chip for NPS and survey flows. Selection is a toggle\n * (`isSelected`/`onChange` from React Aria); the selected state renders the accent fill.\n *\n * The `icon` variant has no visible text — supply an `aria-label` (or `aria-labelledby`)\n * so the control has an accessible name.\n */\nexport function Chip({\n\tvariant = \"text\",\n\tsize = \"md\",\n\tclassName,\n\tchildren,\n\t...rest\n}: ChipProps) {\n\tif (\n\t\timport.meta.env.DEV &&\n\t\tvariant === \"icon\" &&\n\t\t!rest[\"aria-label\"] &&\n\t\t!rest[\"aria-labelledby\"]\n\t) {\n\t\tconsole.warn(\n\t\t\t'[Lovelace] Chip variant=\"icon\" has no accessible name — pass `aria-label` (or `aria-labelledby`). An icon-only chip has no visible text.',\n\t\t);\n\t}\n\treturn (\n\t\t<AriaToggleButton\n\t\t\t{...rest}\n\t\t\tdata-variant={variant}\n\t\t\tdata-size={size}\n\t\t\tclassName={cx(chipRoot({ variant, size }), className)}\n\t\t>\n\t\t\t{children}\n\t\t</AriaToggleButton>\n\t);\n}\n"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"Chip.js","names":[],"sources":["../../../src/components/Chip/Chip.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode, Ref } from \"react\";\nimport type { ToggleButtonProps as AriaToggleButtonProps } from \"react-aria-components\";\nimport { ToggleButton as AriaToggleButton } from \"react-aria-components\";\nimport { cx } from \"../../utils/cx.js\";\nimport { chipRoot } from \"./Chip.css.js\";\n\nexport type ChipVariant = \"text\" | \"icon\" | \"number\";\nexport type ChipSize = \"md\" | \"lg\";\n\nexport interface ChipProps\n\textends Omit<AriaToggleButtonProps, \"children\" | \"className\" | \"style\"> {\n\t/** Content shape: `text` (pill label), `icon` (square glyph), or `number` (square value). */\n\tvariant?: ChipVariant;\n\t/** Control height: `md` (40px) or `lg` (48px). */\n\tsize?: ChipSize;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLButtonElement>;\n\t/** Chip content — a label, a numeric value, or a single `<Icon>`. */\n\tchildren: ReactNode;\n}\n\n/**\n * Tap-to-toggle selection chip for NPS and survey flows. Selection is a toggle\n * (`isSelected`/`onChange` from React Aria); the selected state renders the accent fill\n * and an inner ring, so it does not depend on colour alone.\n *\n * The `icon` variant has no visible text — supply an `aria-label` (or `aria-labelledby`)\n * so the control has an accessible name.\n */\nexport function Chip({\n\tvariant = \"text\",\n\tsize = \"md\",\n\tclassName,\n\tchildren,\n\t...rest\n}: ChipProps) {\n\tif (\n\t\timport.meta.env.DEV &&\n\t\tvariant === \"icon\" &&\n\t\t!rest[\"aria-label\"] &&\n\t\t!rest[\"aria-labelledby\"]\n\t) {\n\t\tconsole.warn(\n\t\t\t'[Lovelace] Chip variant=\"icon\" has no accessible name — pass `aria-label` (or `aria-labelledby`). An icon-only chip has no visible text.',\n\t\t);\n\t}\n\treturn (\n\t\t<AriaToggleButton\n\t\t\t{...rest}\n\t\t\tdata-variant={variant}\n\t\t\tdata-size={size}\n\t\t\tclassName={cx(chipRoot({ variant, size }), className)}\n\t\t>\n\t\t\t{children}\n\t\t</AriaToggleButton>\n\t);\n}\n"],"mappings":";;;;;AA8BA,SAAgB,EAAK,EACpB,aAAU,QACV,UAAO,MACP,cACA,aACA,GAAG,KACU;CAWb,OACC,kBAAC,GAAD;EACC,GAAI;EACJ,gBAAc;EACd,aAAW;EACX,WAAW,EAAG,EAAS;GAAE;GAAS;EAAK,CAAC,GAAG,CAAS;EAEnD;CACgB,CAAA;AAEpB"}
|
|
@@ -3,6 +3,9 @@ export declare const iconButtonRoot: import("@vanilla-extract/recipes").RuntimeF
|
|
|
3
3
|
primary: {
|
|
4
4
|
backgroundColor: "var(--lovelace-button-primary-background)";
|
|
5
5
|
color: "var(--lovelace-button-primary-content)";
|
|
6
|
+
"::after": {
|
|
7
|
+
readonly backgroundColor: `var(--${string})`;
|
|
8
|
+
};
|
|
6
9
|
selectors: {
|
|
7
10
|
"&[data-disabled]": {
|
|
8
11
|
backgroundColor: "var(--lovelace-color-background-disabled)";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.css.js","names":[],"sources":["../../../src/components/IconButton/IconButton.css.ts"],"sourcesContent":["import { recipe } from \"@vanilla-extract/recipes\";\nimport { focusRing } from \"../../styles/focus-ring.js\";\nimport { t } from \"../../tokens/index.js\";\n\nexport const iconButtonRoot = recipe({\n\tbase: {\n\t\tposition: \"relative\",\n\t\tisolation: \"isolate\",\n\t\tdisplay: \"inline-flex\",\n\t\talignItems: \"center\",\n\t\tjustifyContent: \"center\",\n\t\tpadding: 0,\n\t\tboxSizing: \"border-box\",\n\t\tborder: `${t(\"border-width-default\")} solid transparent`,\n\t\tborderRadius: t(\"border-radius-button\"),\n\t\t// `fontSize` drives <Icon>'s 1em glyph, constant across sizes.\n\t\tfontSize: t(\"icon-size-control\"),\n\t\tcursor: \"pointer\",\n\t\tuserSelect: \"none\",\n\t\tappearance: \"none\",\n\t\toutline: \"none\",\n\t\ttransitionProperty: \"background-color, border-color\",\n\t\ttransitionDuration: t(\"duration-fast\"),\n\t\ttransitionTimingFunction: t(\"easing-standard\"),\n\t\tflexShrink: 0,\n\t\t\"::after\": {\n\t\t\tcontent: '\"\"',\n\t\t\tposition: \"absolute\",\n\t\t\tinset: 0,\n\t\t\tborderRadius: \"inherit\",\n\t\t\tbackgroundColor: \"currentColor\",\n\t\t\topacity: 0,\n\t\t\tpointerEvents: \"none\",\n\t\t\tzIndex: -1,\n\t\t\ttransition: `opacity ${t(\"duration-fast\")} ${t(\"easing-standard\")}`,\n\t\t},\n\t\tselectors: {\n\t\t\t\"&[data-hovered]:not([data-disabled])::after\": {\n\t\t\t\topacity: t(\"opacity-state-hover\"),\n\t\t\t},\n\t\t\t\"&[data-focus-visible]:not([data-disabled])::after\": {\n\t\t\t\topacity: t(\"opacity-state-focus\"),\n\t\t\t},\n\t\t\t\"&[data-pressed]:not([data-disabled])::after\": {\n\t\t\t\topacity: t(\"opacity-state-pressed\"),\n\t\t\t},\n\t\t\t\"&[data-focus-visible]:not([data-disabled])\": focusRing,\n\t\t\t\"&[data-disabled]\": {\n\t\t\t\tcursor: \"not-allowed\",\n\t\t\t\tcolor: t(\"color-content-disabled\"),\n\t\t\t},\n\t\t},\n\t\t\"@media\": {\n\t\t\t\"(forced-colors: active)\": {\n\t\t\t\tselectors: {\n\t\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": {\n\t\t\t\t\t\toutline: \"2px solid Highlight\",\n\t\t\t\t\t\toutlineOffset: \"2px\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\tvariants: {\n\t\tintent: {\n\t\t\tprimary: {\n\t\t\t\tbackgroundColor: t(\"button-primary-background\"),\n\t\t\t\tcolor: t(\"button-primary-content\"),\n\t\t\t\tselectors: {\n\t\t\t\t\t\"&[data-disabled]\": {\n\t\t\t\t\t\tbackgroundColor: t(\"color-background-disabled\"),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"primary-destructive\": {\n\t\t\t\tbackgroundColor: t(\"color-background-destructive\"),\n\t\t\t\tcolor: t(\"color-content-on-destructive\"),\n\t\t\t\tselectors: {\n\t\t\t\t\t\"&[data-disabled]\": {\n\t\t\t\t\t\tbackgroundColor: t(\"color-background-disabled\"),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tsecondary: {\n\t\t\t\tbackgroundColor: t(\"color-background-default\"),\n\t\t\t\tcolor: t(\"color-content-default\"),\n\t\t\t\tborderColor: t(\"color-border-default\"),\n\t\t\t},\n\t\t\t\"secondary-destructive\": {\n\t\t\t\tbackgroundColor: t(\"color-background-default\"),\n\t\t\t\tcolor: t(\"color-content-destructive\"),\n\t\t\t\tborderColor: t(\"color-border-destructive\"),\n\t\t\t},\n\t\t\ttertiary: {\n\t\t\t\tbackgroundColor: \"transparent\",\n\t\t\t\tcolor: t(\"color-content-default\"),\n\t\t\t},\n\t\t\t\"tertiary-destructive\": {\n\t\t\t\tbackgroundColor: \"transparent\",\n\t\t\t\tcolor: t(\"color-content-destructive\"),\n\t\t\t},\n\t\t},\n\t\t// Hardcoded square sizes mirror Figma's fixed frame dimensions.\n\t\tsize: {\n\t\t\tmd: { width: \"40px\", height: \"40px\" },\n\t\t\tsm: { width: \"32px\", height: \"32px\" },\n\t\t\txs: { width: \"24px\", height: \"24px\" },\n\t\t},\n\t},\n\tdefaultVariants: {\n\t\tintent: \"primary\",\n\t\tsize: \"md\",\n\t},\n});\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"IconButton.css.js","names":[],"sources":["../../../src/components/IconButton/IconButton.css.ts"],"sourcesContent":["import { recipe } from \"@vanilla-extract/recipes\";\nimport { focusRing } from \"../../styles/focus-ring.js\";\nimport { stateLayerOnAccent } from \"../../styles/state-layer.css.js\";\nimport { t } from \"../../tokens/index.js\";\n\nexport const iconButtonRoot = recipe({\n\tbase: {\n\t\tposition: \"relative\",\n\t\tisolation: \"isolate\",\n\t\tdisplay: \"inline-flex\",\n\t\talignItems: \"center\",\n\t\tjustifyContent: \"center\",\n\t\tpadding: 0,\n\t\tboxSizing: \"border-box\",\n\t\tborder: `${t(\"border-width-default\")} solid transparent`,\n\t\tborderRadius: t(\"border-radius-button\"),\n\t\t// `fontSize` drives <Icon>'s 1em glyph, constant across sizes.\n\t\tfontSize: t(\"icon-size-control\"),\n\t\tcursor: \"pointer\",\n\t\tuserSelect: \"none\",\n\t\tappearance: \"none\",\n\t\toutline: \"none\",\n\t\ttransitionProperty: \"background-color, border-color\",\n\t\ttransitionDuration: t(\"duration-fast\"),\n\t\ttransitionTimingFunction: t(\"easing-standard\"),\n\t\tflexShrink: 0,\n\t\t\"::after\": {\n\t\t\tcontent: '\"\"',\n\t\t\tposition: \"absolute\",\n\t\t\tinset: 0,\n\t\t\tborderRadius: \"inherit\",\n\t\t\tbackgroundColor: \"currentColor\",\n\t\t\topacity: 0,\n\t\t\tpointerEvents: \"none\",\n\t\t\tzIndex: -1,\n\t\t\ttransition: `opacity ${t(\"duration-fast\")} ${t(\"easing-standard\")}`,\n\t\t},\n\t\tselectors: {\n\t\t\t\"&[data-hovered]:not([data-disabled])::after\": {\n\t\t\t\topacity: t(\"opacity-state-hover\"),\n\t\t\t},\n\t\t\t\"&[data-focus-visible]:not([data-disabled])::after\": {\n\t\t\t\topacity: t(\"opacity-state-focus\"),\n\t\t\t},\n\t\t\t\"&[data-pressed]:not([data-disabled])::after\": {\n\t\t\t\topacity: t(\"opacity-state-pressed\"),\n\t\t\t},\n\t\t\t\"&[data-focus-visible]:not([data-disabled])\": focusRing,\n\t\t\t\"&[data-disabled]\": {\n\t\t\t\tcursor: \"not-allowed\",\n\t\t\t\tcolor: t(\"color-content-disabled\"),\n\t\t\t},\n\t\t},\n\t\t\"@media\": {\n\t\t\t\"(forced-colors: active)\": {\n\t\t\t\tselectors: {\n\t\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": {\n\t\t\t\t\t\toutline: \"2px solid Highlight\",\n\t\t\t\t\t\toutlineOffset: \"2px\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n\tvariants: {\n\t\tintent: {\n\t\t\tprimary: {\n\t\t\t\tbackgroundColor: t(\"button-primary-background\"),\n\t\t\t\tcolor: t(\"button-primary-content\"),\n\t\t\t\t\"::after\": stateLayerOnAccent.buttonPrimary,\n\t\t\t\tselectors: {\n\t\t\t\t\t\"&[data-disabled]\": {\n\t\t\t\t\t\tbackgroundColor: t(\"color-background-disabled\"),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"primary-destructive\": {\n\t\t\t\tbackgroundColor: t(\"color-background-destructive\"),\n\t\t\t\tcolor: t(\"color-content-on-destructive\"),\n\t\t\t\tselectors: {\n\t\t\t\t\t\"&[data-disabled]\": {\n\t\t\t\t\t\tbackgroundColor: t(\"color-background-disabled\"),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tsecondary: {\n\t\t\t\tbackgroundColor: t(\"color-background-default\"),\n\t\t\t\tcolor: t(\"color-content-default\"),\n\t\t\t\tborderColor: t(\"color-border-default\"),\n\t\t\t},\n\t\t\t\"secondary-destructive\": {\n\t\t\t\tbackgroundColor: t(\"color-background-default\"),\n\t\t\t\tcolor: t(\"color-content-destructive\"),\n\t\t\t\tborderColor: t(\"color-border-destructive\"),\n\t\t\t},\n\t\t\ttertiary: {\n\t\t\t\tbackgroundColor: \"transparent\",\n\t\t\t\tcolor: t(\"color-content-default\"),\n\t\t\t},\n\t\t\t\"tertiary-destructive\": {\n\t\t\t\tbackgroundColor: \"transparent\",\n\t\t\t\tcolor: t(\"color-content-destructive\"),\n\t\t\t},\n\t\t},\n\t\t// Hardcoded square sizes mirror Figma's fixed frame dimensions.\n\t\tsize: {\n\t\t\tmd: { width: \"40px\", height: \"40px\" },\n\t\t\tsm: { width: \"32px\", height: \"32px\" },\n\t\t\txs: { width: \"24px\", height: \"24px\" },\n\t\t},\n\t},\n\tdefaultVariants: {\n\t\tintent: \"primary\",\n\t\tsize: \"md\",\n\t},\n});\n"],"mappings":""}
|
|
@@ -14,7 +14,11 @@ export declare const inputControl: string;
|
|
|
14
14
|
export declare const inputTextArea: string;
|
|
15
15
|
export declare const inputButton: RuntimeFn<{
|
|
16
16
|
variant: {
|
|
17
|
-
primary: {
|
|
17
|
+
primary: {
|
|
18
|
+
"::after": {
|
|
19
|
+
readonly backgroundColor: `var(--${string})`;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
18
22
|
tertiary: (string | {
|
|
19
23
|
backgroundColor: "transparent";
|
|
20
24
|
color: "var(--lovelace-color-content-secondary)";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.css.js","names":[],"sources":["../../../src/components/Input/Input.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 { focusRing } from \"../../styles/focus-ring.js\";\nimport { typography } from \"../../styles/typography.js\";\nimport { t } from \"../../tokens/index.js\";\n\n// Shared by the text control and the label so their typography stays in lockstep.\nconst bodyText = {\n\t...typography(\"body\", \"regular\"),\n} as const;\n\n// Field and action-button icon glyphs share sizing.\nconst iconSlotSizing = {\n\tflexShrink: 0,\n\tfontSize: t(\"icon-size-control\"),\n} as const;\n\nexport const inputRoot = style({\n\tdisplay: \"flex\",\n\tflexDirection: \"column\",\n\twidth: \"100%\",\n\tfontFamily: t(\"font-family-body\"),\n});\n\n// Empty style used purely as a stable selector anchor for the globalStyle rules\n// below — a recipe class isn't a usable selector string, so descendant styles\n// hang off this base class instead.\nconst inputFieldBase = style({});\n\n// Composer-variant anchor: composed into the `composer` variant so the control's\n// content/placeholder colors (a descendant, not the field) can be re-themed to\n// the composer-* tokens via globalStyle.\nconst inputFieldComposer = style({});\n\n/**\n * Shares the line below the control with the field's own button rather than\n * taking a line of its own: Figma bottom-aligns the chips and the send action\n * on one line, which `Input.Field`'s `align-items: flex-end` then handles.\n */\nexport const inputAttachments = style({\n\tflex: \"1 1 auto\",\n\tminWidth: 0,\n\tdisplay: \"flex\",\n\tflexWrap: \"wrap\",\n\tgap: t(\"gap-8\"),\n});\n\n// Explicit annotation: the inferred recipe type exceeds tsc's declaration\n// serialization limit (TS7056) under `tsc -p tsconfig.build.json`.\nexport const inputField: RuntimeFn<{\n\tvariant: Record<\"default\" | \"composer\", ComplexStyleRule>;\n}> = recipe({\n\tbase: [\n\t\tinputFieldBase,\n\t\t{\n\t\t\tdisplay: \"flex\",\n\t\t\t// The control takes the whole first line whenever attachments are present\n\t\t\t// (see the `data-has-attachments` rule below), so the chips and the button\n\t\t\t// wrap onto the second. Keep wrapping unconditional because Chrome and\n\t\t\t// Firefox at the floor in `messaging/vite.browser-targets.mjs` lack\n\t\t\t// `:has()`. Without attachments nothing wraps: the control has\n\t\t\t// flex-basis 0, icons are 22px and the button takes a 22px line.\n\t\t\tflexWrap: \"wrap\",\n\t\t\talignItems: \"flex-end\",\n\t\t\tgap: t(\"gap-8\"),\n\t\t\twidth: \"100%\",\n\t\t\tminHeight: \"40px\",\n\t\t\tboxSizing: \"border-box\",\n\t\t\tpaddingInline: t(\"padding-12\"),\n\t\t\tpaddingBlock: t(\"padding-8\"),\n\t\t\tborder: `${t(\"border-width-default\")} solid ${t(\"color-border-control\")}`,\n\t\t\tbackgroundColor: t(\"color-background-default\"),\n\t\t\tborderRadius: t(\"border-radius-input\"),\n\t\t\tcursor: \"text\",\n\t\t\tselectors: {\n\t\t\t\t\"&[data-focus-within]\": {\n\t\t\t\t\tborderColor: t(\"color-border-accent\"),\n\t\t\t\t\t...focusRing,\n\t\t\t\t},\n\t\t\t\t\"&[data-disabled]\": {\n\t\t\t\t\tbackgroundColor: t(\"color-background-disabled\"),\n\t\t\t\t\tborderColor: t(\"color-border-default\"),\n\t\t\t\t\tcursor: \"not-allowed\",\n\t\t\t\t},\n\t\t\t\t// After focus-within and disabled so an invalid field keeps its destructive border.\n\t\t\t\t\"&[data-invalid]\": {\n\t\t\t\t\tborderColor: t(\"color-border-destructive\"),\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"@media\": {\n\t\t\t\t\"(prefers-reduced-motion: no-preference)\": {\n\t\t\t\t\ttransitionProperty: \"border-color\",\n\t\t\t\t\ttransitionDuration: t(\"duration-fast\"),\n\t\t\t\t\ttransitionTimingFunction: t(\"easing-standard\"),\n\t\t\t\t},\n\t\t\t\t// Token-color focus ring flattens in forced-colors; redraw with a system color.\n\t\t\t\t\"(forced-colors: active)\": {\n\t\t\t\t\tselectors: {\n\t\t\t\t\t\t\"&[data-focus-within]\": {\n\t\t\t\t\t\t\toutline: \"2px solid Highlight\",\n\t\t\t\t\t\t\toutlineOffset: \"2px\",\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},\n\t],\n\tvariants: {\n\t\tvariant: {\n\t\t\t// Default field styling lives in `base`; this key exists so the variant\n\t\t\t// axis accepts \"default\" as an explicit no-op.\n\t\t\tdefault: {},\n\t\t\tcomposer: [\n\t\t\t\tinputFieldComposer,\n\t\t\t\t{\n\t\t\t\t\tborderRadius: t(\"border-radius-composer\"),\n\t\t\t\t\tborder: `${t(\"border-width-default\")} solid ${t(\"composer-border-default\")}`,\n\t\t\t\t\tbackgroundColor: t(\"composer-background\"),\n\t\t\t\t\tselectors: {\n\t\t\t\t\t\t\"&[data-focus-within]\": {\n\t\t\t\t\t\t\tborderColor: t(\"composer-border-active\"),\n\t\t\t\t\t\t\toutline: `${t(\"border-width-focus\")} solid ${t(\"composer-border-focus\")}`,\n\t\t\t\t\t\t\toutlineOffset: t(\"border-width-focus\"),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t// Re-declared after focus-within for the same reason the base does:\n\t\t\t\t\t\t// variant styles are emitted after base at equal specificity, so\n\t\t\t\t\t\t// without this the composer's focus colour would win and an invalid\n\t\t\t\t\t\t// composer would lose its destructive border while focused.\n\t\t\t\t\t\t\"&[data-invalid]\": {\n\t\t\t\t\t\t\tborderColor: t(\"color-border-destructive\"),\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},\n\t},\n\tdefaultVariants: {\n\t\tvariant: \"default\",\n\t},\n});\n\nexport const inputControl = style({\n\tflex: 1,\n\tminWidth: 0,\n\tmargin: 0,\n\tpadding: 0,\n\tborder: \"none\",\n\tbackgroundColor: \"transparent\",\n\toutline: \"none\",\n\tappearance: \"none\",\n\t...bodyText,\n\tcolor: t(\"color-content-default\"),\n\tselectors: {\n\t\t\"&::placeholder\": {\n\t\t\tcolor: t(\"color-content-secondary\"),\n\t\t\topacity: 1,\n\t\t},\n\t\t\"&[data-disabled]\": {\n\t\t\tcolor: t(\"color-content-disabled\"),\n\t\t\tcursor: \"not-allowed\",\n\t\t},\n\t\t\"&[data-disabled]::placeholder\": {\n\t\t\tcolor: t(\"color-content-disabled\"),\n\t\t},\n\t},\n});\n\n// Same control base as the single-line inputControl (typography, colors,\n// placeholder/disabled states), plus the multi-line-specific box behavior.\nexport const inputTextArea = style([\n\tinputControl,\n\t{\n\t\tdisplay: \"block\",\n\t\twidth: \"100%\",\n\t\tboxSizing: \"border-box\",\n\t\t// Height is driven by the auto-grow logic in InputTextArea; the user never drags it.\n\t\tresize: \"none\",\n\t\toverflowY: \"auto\",\n\t\toverflowWrap: \"anywhere\",\n\t\twordBreak: \"break-word\",\n\t\tscrollbarWidth: \"thin\",\n\t\tscrollbarColor: `${t(\"color-border-default\")} transparent`,\n\t},\n]);\n\nconst inputButtonBase = style({});\nconst inputButtonTertiary = style({});\n\nexport const inputButton = recipe({\n\tbase: [\n\t\tinputButtonBase,\n\t\t{\n\t\t\tposition: \"relative\",\n\t\t\tisolation: \"isolate\",\n\t\t\tdisplay: \"inline-flex\",\n\t\t\talignItems: \"center\",\n\t\t\tjustifyContent: \"center\",\n\t\t\tflexShrink: 0,\n\t\t\t// Figma draws a 22px circle, but WCAG 2.5.8 needs a 24px target: the field\n\t\t\t// around it is a target too, since a press on its padding focuses the\n\t\t\t// control. The -1px margin keeps the 22px footprint of the icon, so the\n\t\t\t// field does not grow and every variant has the same centre.\n\t\t\twidth: \"24px\",\n\t\t\theight: \"24px\",\n\t\t\tmargin: \"-1px\",\n\t\t\tpadding: 0,\n\t\t\tborder: \"none\",\n\t\t\tborderRadius: t(\"border-radius-full\"),\n\t\t\tbackgroundColor: t(\"button-primary-background\"),\n\t\t\tcolor: t(\"button-primary-content\"),\n\t\t\tcursor: \"pointer\",\n\t\t\tappearance: \"none\",\n\t\t\toutline: \"none\",\n\t\t\toverflow: \"hidden\",\n\t\t\t\"::after\": {\n\t\t\t\tcontent: '\"\"',\n\t\t\t\tposition: \"absolute\",\n\t\t\t\tinset: 0,\n\t\t\t\tborderRadius: \"inherit\",\n\t\t\t\tbackgroundColor: \"currentColor\",\n\t\t\t\topacity: 0,\n\t\t\t\tpointerEvents: \"none\",\n\t\t\t\tzIndex: -1,\n\t\t\t},\n\t\t\tselectors: {\n\t\t\t\t\"&[data-hovered]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-hover\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-focus-visible]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-focus\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-pressed]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-pressed\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": focusRing,\n\t\t\t\t\"&[data-disabled]\": {\n\t\t\t\t\tcursor: \"not-allowed\",\n\t\t\t\t\tbackgroundColor: t(\"color-background-disabled\"),\n\t\t\t\t\tcolor: t(\"color-content-disabled\"),\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"@media\": {\n\t\t\t\t\"(prefers-reduced-motion: no-preference)\": {\n\t\t\t\t\tselectors: {\n\t\t\t\t\t\t\"&::after\": {\n\t\t\t\t\t\t\ttransition: `opacity ${t(\"duration-fast\")} ${t(\"easing-standard\")}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t// Token-color focus ring flattens in forced-colors; redraw with a system color.\n\t\t\t\t\"(forced-colors: active)\": {\n\t\t\t\t\tselectors: {\n\t\t\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": {\n\t\t\t\t\t\t\toutline: \"2px solid Highlight\",\n\t\t\t\t\t\t\toutlineOffset: \"2px\",\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},\n\t],\n\tvariants: {\n\t\tvariant: {\n\t\t\tprimary: {},\n\t\t\ttertiary: [\n\t\t\t\tinputButtonTertiary,\n\t\t\t\t{\n\t\t\t\t\tbackgroundColor: \"transparent\",\n\t\t\t\t\tcolor: t(\"color-content-secondary\"),\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t},\n\tdefaultVariants: {\n\t\tvariant: \"primary\",\n\t},\n});\n\nexport const inputLabel = style({\n\t...bodyText,\n\tmarginBottom: t(\"gap-8\"),\n\tcolor: t(\"color-content-default\"),\n});\n\nexport const inputHelperText = style({\n\tmarginTop: t(\"gap-4\"),\n\t...typography(\"caption\", \"regular\"),\n\tcolor: t(\"color-content-secondary\"),\n\tselectors: {\n\t\t\"&[data-invalid]\": {\n\t\t\tcolor: t(\"color-content-destructive\"),\n\t\t},\n\t},\n});\n\nglobalStyle(`${inputFieldBase} [data-slot='icon']`, iconSlotSizing);\nglobalStyle(`${inputButtonBase} [data-slot='icon']`, iconSlotSizing);\n\n// Direct child only: field-level icons follow content color. The send button's\n// icon is a deeper descendant, so it deliberately has no rule of its own — it\n// inherits the button's paired tokens (button-primary-content over\n// button-primary-background, or the disabled pair). Giving the icon its own\n// background re-pairs an accent foreground with a neutral backdrop, and those\n// two are unrelated tokens: a customer tint near the surface color then renders\n// the arrow at ~1:1.\nglobalStyle(`${inputFieldBase} > [data-slot='icon']`, {\n\tcolor: t(\"color-content-secondary\"),\n});\n\nglobalStyle(`${inputFieldBase}[data-disabled] > [data-slot='icon']`, {\n\tcolor: t(\"color-content-disabled\"),\n});\n\n// Composer variant re-themes the field's content colors to the composer-* tokens.\n// The control (input/textarea) and field-level icons are descendants of the field,\n// so these ride the composer anchor rather than the field recipe.\n/**\n * With attachments in the field the control owns the first line, so the chips\n * and the send button fall onto the second and bottom-align there.\n *\n * Driven by an attribute the caller sets rather than `:has()`, which the iOS 15\n * baseline does not have.\n */\nglobalStyle(`${inputFieldBase}[data-has-attachments] ${inputControl}`, {\n\tflexBasis: \"100%\",\n});\n\n// Figma stacks the text and the chips 20px apart while the send button keeps its\n// 8px from the chips, so the two axes take different gaps.\nglobalStyle(`${inputFieldBase}[data-has-attachments]`, {\n\trowGap: t(\"gap-20\"),\n});\n\nglobalStyle(`${inputFieldComposer} ${inputControl}`, {\n\tcolor: t(\"composer-content-default\"),\n});\n\nglobalStyle(`${inputFieldComposer} ${inputControl}::placeholder`, {\n\tcolor: t(\"composer-content-secondary\"),\n});\n\nglobalStyle(`${inputFieldComposer} > [data-slot='icon']`, {\n\tcolor: t(\"composer-content-secondary\"),\n});\n\nglobalStyle(`${inputFieldComposer} ${inputButtonTertiary}`, {\n\tcolor: t(\"composer-content-secondary\"),\n});\n\n// Equal specificity: later order overrides the base disabled fill and composer colour.\nglobalStyle(`${inputButtonTertiary}[data-disabled]`, {\n\tbackgroundColor: \"transparent\",\n\tcolor: t(\"color-content-disabled\"),\n});\n\n// The composer rules above are descendant selectors, so they tie with the field\n// recipe's [data-disabled] rules on specificity and win on order. Re-assert the\n// disabled colors after them or a disabled control renders as if it were editable.\nglobalStyle(`${inputFieldComposer} ${inputControl}[data-disabled]`, {\n\tcolor: t(\"color-content-disabled\"),\n});\n\nglobalStyle(\n\t`${inputFieldComposer} ${inputControl}[data-disabled]::placeholder`,\n\t{\n\t\tcolor: t(\"color-content-disabled\"),\n\t},\n);\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Input.css.js","names":[],"sources":["../../../src/components/Input/Input.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 { focusRing } from \"../../styles/focus-ring.js\";\nimport { stateLayerOnAccent } from \"../../styles/state-layer.css.js\";\nimport { typography } from \"../../styles/typography.js\";\nimport { t } from \"../../tokens/index.js\";\n\n// Shared by the text control and the label so their typography stays in lockstep.\nconst bodyText = {\n\t...typography(\"body\", \"regular\"),\n} as const;\n\n// Field and action-button icon glyphs share sizing.\nconst iconSlotSizing = {\n\tflexShrink: 0,\n\tfontSize: t(\"icon-size-control\"),\n} as const;\n\nexport const inputRoot = style({\n\tdisplay: \"flex\",\n\tflexDirection: \"column\",\n\twidth: \"100%\",\n\tfontFamily: t(\"font-family-body\"),\n});\n\n// Empty style used purely as a stable selector anchor for the globalStyle rules\n// below — a recipe class isn't a usable selector string, so descendant styles\n// hang off this base class instead.\nconst inputFieldBase = style({});\n\n// Composer-variant anchor: composed into the `composer` variant so the control's\n// content/placeholder colors (a descendant, not the field) can be re-themed to\n// the composer-* tokens via globalStyle.\nconst inputFieldComposer = style({});\n\n/**\n * Shares the line below the control with the field's own button rather than\n * taking a line of its own: Figma bottom-aligns the chips and the send action\n * on one line, which `Input.Field`'s `align-items: flex-end` then handles.\n */\nexport const inputAttachments = style({\n\tflex: \"1 1 auto\",\n\tminWidth: 0,\n\tdisplay: \"flex\",\n\tflexWrap: \"wrap\",\n\tgap: t(\"gap-8\"),\n});\n\n// Explicit annotation: the inferred recipe type exceeds tsc's declaration\n// serialization limit (TS7056) under `tsc -p tsconfig.build.json`.\nexport const inputField: RuntimeFn<{\n\tvariant: Record<\"default\" | \"composer\", ComplexStyleRule>;\n}> = recipe({\n\tbase: [\n\t\tinputFieldBase,\n\t\t{\n\t\t\tdisplay: \"flex\",\n\t\t\t// The control takes the whole first line whenever attachments are present\n\t\t\t// (see the `data-has-attachments` rule below), so the chips and the button\n\t\t\t// wrap onto the second. Keep wrapping unconditional because Chrome and\n\t\t\t// Firefox at the floor in `messaging/vite.browser-targets.mjs` lack\n\t\t\t// `:has()`. Without attachments nothing wraps: the control has\n\t\t\t// flex-basis 0, icons are 22px and the button takes a 22px line.\n\t\t\tflexWrap: \"wrap\",\n\t\t\talignItems: \"flex-end\",\n\t\t\tgap: t(\"gap-8\"),\n\t\t\twidth: \"100%\",\n\t\t\tminHeight: \"40px\",\n\t\t\tboxSizing: \"border-box\",\n\t\t\tpaddingInline: t(\"padding-12\"),\n\t\t\tpaddingBlock: t(\"padding-8\"),\n\t\t\tborder: `${t(\"border-width-default\")} solid ${t(\"color-border-control\")}`,\n\t\t\tbackgroundColor: t(\"color-background-default\"),\n\t\t\tborderRadius: t(\"border-radius-input\"),\n\t\t\tcursor: \"text\",\n\t\t\tselectors: {\n\t\t\t\t\"&[data-focus-within]\": {\n\t\t\t\t\tborderColor: t(\"color-border-accent\"),\n\t\t\t\t\t...focusRing,\n\t\t\t\t},\n\t\t\t\t\"&[data-disabled]\": {\n\t\t\t\t\tbackgroundColor: t(\"color-background-disabled\"),\n\t\t\t\t\tborderColor: t(\"color-border-default\"),\n\t\t\t\t\tcursor: \"not-allowed\",\n\t\t\t\t},\n\t\t\t\t// After focus-within and disabled so an invalid field keeps its destructive border.\n\t\t\t\t\"&[data-invalid]\": {\n\t\t\t\t\tborderColor: t(\"color-border-destructive\"),\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"@media\": {\n\t\t\t\t\"(prefers-reduced-motion: no-preference)\": {\n\t\t\t\t\ttransitionProperty: \"border-color\",\n\t\t\t\t\ttransitionDuration: t(\"duration-fast\"),\n\t\t\t\t\ttransitionTimingFunction: t(\"easing-standard\"),\n\t\t\t\t},\n\t\t\t\t// Token-color focus ring flattens in forced-colors; redraw with a system color.\n\t\t\t\t\"(forced-colors: active)\": {\n\t\t\t\t\tselectors: {\n\t\t\t\t\t\t\"&[data-focus-within]\": {\n\t\t\t\t\t\t\toutline: \"2px solid Highlight\",\n\t\t\t\t\t\t\toutlineOffset: \"2px\",\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},\n\t],\n\tvariants: {\n\t\tvariant: {\n\t\t\t// Default field styling lives in `base`; this key exists so the variant\n\t\t\t// axis accepts \"default\" as an explicit no-op.\n\t\t\tdefault: {},\n\t\t\tcomposer: [\n\t\t\t\tinputFieldComposer,\n\t\t\t\t{\n\t\t\t\t\tborderRadius: t(\"border-radius-composer\"),\n\t\t\t\t\tborder: `${t(\"border-width-default\")} solid ${t(\"composer-border-default\")}`,\n\t\t\t\t\tbackgroundColor: t(\"composer-background\"),\n\t\t\t\t\tselectors: {\n\t\t\t\t\t\t\"&[data-focus-within]\": {\n\t\t\t\t\t\t\tborderColor: t(\"composer-border-active\"),\n\t\t\t\t\t\t\toutline: `${t(\"border-width-focus\")} solid ${t(\"composer-border-focus\")}`,\n\t\t\t\t\t\t\toutlineOffset: t(\"border-width-focus\"),\n\t\t\t\t\t\t},\n\t\t\t\t\t\t// Re-declared after focus-within for the same reason the base does:\n\t\t\t\t\t\t// variant styles are emitted after base at equal specificity, so\n\t\t\t\t\t\t// without this the composer's focus colour would win and an invalid\n\t\t\t\t\t\t// composer would lose its destructive border while focused.\n\t\t\t\t\t\t\"&[data-invalid]\": {\n\t\t\t\t\t\t\tborderColor: t(\"color-border-destructive\"),\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},\n\t},\n\tdefaultVariants: {\n\t\tvariant: \"default\",\n\t},\n});\n\nexport const inputControl = style({\n\tflex: 1,\n\tminWidth: 0,\n\tmargin: 0,\n\tpadding: 0,\n\tborder: \"none\",\n\tbackgroundColor: \"transparent\",\n\toutline: \"none\",\n\tappearance: \"none\",\n\t...bodyText,\n\tcolor: t(\"color-content-default\"),\n\tselectors: {\n\t\t\"&::placeholder\": {\n\t\t\tcolor: t(\"color-content-secondary\"),\n\t\t\topacity: 1,\n\t\t},\n\t\t\"&[data-disabled]\": {\n\t\t\tcolor: t(\"color-content-disabled\"),\n\t\t\tcursor: \"not-allowed\",\n\t\t},\n\t\t\"&[data-disabled]::placeholder\": {\n\t\t\tcolor: t(\"color-content-disabled\"),\n\t\t},\n\t},\n});\n\n// Same control base as the single-line inputControl (typography, colors,\n// placeholder/disabled states), plus the multi-line-specific box behavior.\nexport const inputTextArea = style([\n\tinputControl,\n\t{\n\t\tdisplay: \"block\",\n\t\twidth: \"100%\",\n\t\tboxSizing: \"border-box\",\n\t\t// Height is driven by the auto-grow logic in InputTextArea; the user never drags it.\n\t\tresize: \"none\",\n\t\toverflowY: \"auto\",\n\t\toverflowWrap: \"anywhere\",\n\t\twordBreak: \"break-word\",\n\t\tscrollbarWidth: \"thin\",\n\t\tscrollbarColor: `${t(\"color-border-default\")} transparent`,\n\t},\n]);\n\nconst inputButtonBase = style({});\nconst inputButtonTertiary = style({});\n\nexport const inputButton = recipe({\n\tbase: [\n\t\tinputButtonBase,\n\t\t{\n\t\t\tposition: \"relative\",\n\t\t\tisolation: \"isolate\",\n\t\t\tdisplay: \"inline-flex\",\n\t\t\talignItems: \"center\",\n\t\t\tjustifyContent: \"center\",\n\t\t\tflexShrink: 0,\n\t\t\t// Figma draws a 22px circle, but WCAG 2.5.8 needs a 24px target: the field\n\t\t\t// around it is a target too, since a press on its padding focuses the\n\t\t\t// control. The -1px margin keeps the 22px footprint of the icon, so the\n\t\t\t// field does not grow and every variant has the same centre.\n\t\t\twidth: \"24px\",\n\t\t\theight: \"24px\",\n\t\t\tmargin: \"-1px\",\n\t\t\tpadding: 0,\n\t\t\tborder: \"none\",\n\t\t\tborderRadius: t(\"border-radius-full\"),\n\t\t\tbackgroundColor: t(\"button-primary-background\"),\n\t\t\tcolor: t(\"button-primary-content\"),\n\t\t\tcursor: \"pointer\",\n\t\t\tappearance: \"none\",\n\t\t\toutline: \"none\",\n\t\t\toverflow: \"hidden\",\n\t\t\t\"::after\": {\n\t\t\t\tcontent: '\"\"',\n\t\t\t\tposition: \"absolute\",\n\t\t\t\tinset: 0,\n\t\t\t\tborderRadius: \"inherit\",\n\t\t\t\tbackgroundColor: \"currentColor\",\n\t\t\t\topacity: 0,\n\t\t\t\tpointerEvents: \"none\",\n\t\t\t\tzIndex: -1,\n\t\t\t},\n\t\t\tselectors: {\n\t\t\t\t\"&[data-hovered]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-hover\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-focus-visible]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-focus\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-pressed]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-pressed\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": focusRing,\n\t\t\t\t\"&[data-disabled]\": {\n\t\t\t\t\tcursor: \"not-allowed\",\n\t\t\t\t\tbackgroundColor: t(\"color-background-disabled\"),\n\t\t\t\t\tcolor: t(\"color-content-disabled\"),\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"@media\": {\n\t\t\t\t\"(prefers-reduced-motion: no-preference)\": {\n\t\t\t\t\tselectors: {\n\t\t\t\t\t\t\"&::after\": {\n\t\t\t\t\t\t\ttransition: `opacity ${t(\"duration-fast\")} ${t(\"easing-standard\")}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t// Token-color focus ring flattens in forced-colors; redraw with a system color.\n\t\t\t\t\"(forced-colors: active)\": {\n\t\t\t\t\tselectors: {\n\t\t\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": {\n\t\t\t\t\t\t\toutline: \"2px solid Highlight\",\n\t\t\t\t\t\t\toutlineOffset: \"2px\",\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},\n\t],\n\tvariants: {\n\t\tvariant: {\n\t\t\tprimary: {\n\t\t\t\t\"::after\": stateLayerOnAccent.buttonPrimary,\n\t\t\t},\n\t\t\ttertiary: [\n\t\t\t\tinputButtonTertiary,\n\t\t\t\t{\n\t\t\t\t\tbackgroundColor: \"transparent\",\n\t\t\t\t\tcolor: t(\"color-content-secondary\"),\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t},\n\tdefaultVariants: {\n\t\tvariant: \"primary\",\n\t},\n});\n\nexport const inputLabel = style({\n\t...bodyText,\n\tmarginBottom: t(\"gap-8\"),\n\tcolor: t(\"color-content-default\"),\n});\n\nexport const inputHelperText = style({\n\tmarginTop: t(\"gap-4\"),\n\t...typography(\"caption\", \"regular\"),\n\tcolor: t(\"color-content-secondary\"),\n\tselectors: {\n\t\t\"&[data-invalid]\": {\n\t\t\tcolor: t(\"color-content-destructive\"),\n\t\t},\n\t},\n});\n\nglobalStyle(`${inputFieldBase} [data-slot='icon']`, iconSlotSizing);\nglobalStyle(`${inputButtonBase} [data-slot='icon']`, iconSlotSizing);\n\n// Direct child only: field-level icons follow content color. The send button's\n// icon is a deeper descendant, so it deliberately has no rule of its own — it\n// inherits the button's paired tokens (button-primary-content over\n// button-primary-background, or the disabled pair). Giving the icon its own\n// background re-pairs an accent foreground with a neutral backdrop, and those\n// two are unrelated tokens: a customer tint near the surface color then renders\n// the arrow at ~1:1.\nglobalStyle(`${inputFieldBase} > [data-slot='icon']`, {\n\tcolor: t(\"color-content-secondary\"),\n});\n\nglobalStyle(`${inputFieldBase}[data-disabled] > [data-slot='icon']`, {\n\tcolor: t(\"color-content-disabled\"),\n});\n\n// Composer variant re-themes the field's content colors to the composer-* tokens.\n// The control (input/textarea) and field-level icons are descendants of the field,\n// so these ride the composer anchor rather than the field recipe.\n/**\n * With attachments in the field the control owns the first line, so the chips\n * and the send button fall onto the second and bottom-align there.\n *\n * Driven by an attribute the caller sets rather than `:has()`, which the iOS 15\n * baseline does not have.\n */\nglobalStyle(`${inputFieldBase}[data-has-attachments] ${inputControl}`, {\n\tflexBasis: \"100%\",\n});\n\n// Figma stacks the text and the chips 20px apart while the send button keeps its\n// 8px from the chips, so the two axes take different gaps.\nglobalStyle(`${inputFieldBase}[data-has-attachments]`, {\n\trowGap: t(\"gap-20\"),\n});\n\nglobalStyle(`${inputFieldComposer} ${inputControl}`, {\n\tcolor: t(\"composer-content-default\"),\n});\n\nglobalStyle(`${inputFieldComposer} ${inputControl}::placeholder`, {\n\tcolor: t(\"composer-content-secondary\"),\n});\n\nglobalStyle(`${inputFieldComposer} > [data-slot='icon']`, {\n\tcolor: t(\"composer-content-secondary\"),\n});\n\nglobalStyle(`${inputFieldComposer} ${inputButtonTertiary}`, {\n\tcolor: t(\"composer-content-secondary\"),\n});\n\n// Equal specificity: later order overrides the base disabled fill and composer colour.\nglobalStyle(`${inputButtonTertiary}[data-disabled]`, {\n\tbackgroundColor: \"transparent\",\n\tcolor: t(\"color-content-disabled\"),\n});\n\n// The composer rules above are descendant selectors, so they tie with the field\n// recipe's [data-disabled] rules on specificity and win on order. Re-assert the\n// disabled colors after them or a disabled control renders as if it were editable.\nglobalStyle(`${inputFieldComposer} ${inputControl}[data-disabled]`, {\n\tcolor: t(\"color-content-disabled\"),\n});\n\nglobalStyle(\n\t`${inputFieldComposer} ${inputControl}[data-disabled]::placeholder`,\n\t{\n\t\tcolor: t(\"color-content-disabled\"),\n\t},\n);\n"],"mappings":""}
|
|
@@ -7,12 +7,11 @@
|
|
|
7
7
|
* against a real class. The host is a prose body with no role of its own, so unlike a row it
|
|
8
8
|
* can carry a cascade safely.
|
|
9
9
|
*
|
|
10
|
-
* Typography lives here rather than on each message component
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* re-points the colour for its accent fill, the same way it re-points the link.
|
|
10
|
+
* Typography lives here rather than on each message component. The size and
|
|
11
|
+
* line height read the semantic body tokens, as the Figma message components
|
|
12
|
+
* do. The body owns no colour: each host sets one. `AgentMessage` sets the
|
|
13
|
+
* default content colour, and `UserMessage` sets the content colour for its
|
|
14
|
+
* accent fill.
|
|
16
15
|
*
|
|
17
16
|
* `Text` (EXP-1054) is deliberately not the owner: it is UI typography, and a
|
|
18
17
|
* message body is a document tree a renderer emits, not a UI element.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageProse.css.js","names":[],"sources":["../../../src/components/MessageProse/MessageProse.css.ts"],"sourcesContent":["import { globalStyle, style } from \"@vanilla-extract/css\";\nimport { t } from \"../../tokens/index.js\";\n\n/**\n * Block-flow rules for a message body hosting rendered Markdown.\n *\n * One class rather than a spread `StyleRule` (the `controlRowFrame` shape):\n * these are descendant rules, and vanilla-extract's `selectors` key can only\n * target `&` itself, so `p + p` is only expressible through `globalStyle`\n * against a real class. The host is a prose body with no role of its own, so unlike a row it\n * can carry a cascade safely.\n *\n * Typography lives here rather than on each message component
|
|
1
|
+
{"version":3,"file":"MessageProse.css.js","names":[],"sources":["../../../src/components/MessageProse/MessageProse.css.ts"],"sourcesContent":["import { globalStyle, style } from \"@vanilla-extract/css\";\nimport { t } from \"../../tokens/index.js\";\n\n/**\n * Block-flow rules for a message body hosting rendered Markdown.\n *\n * One class rather than a spread `StyleRule` (the `controlRowFrame` shape):\n * these are descendant rules, and vanilla-extract's `selectors` key can only\n * target `&` itself, so `p + p` is only expressible through `globalStyle`\n * against a real class. The host is a prose body with no role of its own, so unlike a row it\n * can carry a cascade safely.\n *\n * Typography lives here rather than on each message component. The size and\n * line height read the semantic body tokens, as the Figma message components\n * do. The body owns no colour: each host sets one. `AgentMessage` sets the\n * default content colour, and `UserMessage` sets the content colour for its\n * accent fill.\n *\n * `Text` (EXP-1054) is deliberately not the owner: it is UI typography, and a\n * message body is a document tree a renderer emits, not a UI element.\n */\nexport const messageProse = style({\n\tcolor: \"inherit\",\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\t// Bot-authored and chatter-typed text can both carry an unbroken token\n\t// longer than the bubble.\n\toverflowWrap: \"anywhere\",\n\twordBreak: \"break-word\",\n});\n\n// Lovelace ships no global reset, so a consumer's rendered Markdown arrives with\n// UA margins. `packages/app` never sees them: `packages/ui/src/styles/global.ts`\n// zeroes every margin app-wide, and the rules below add the spacing back.\nglobalStyle(\n\t`${messageProse} :is(p, ul, ol, h1, h2, h3, h4, h5, h6, pre, blockquote, table, hr)`,\n\t{\n\t\tmargin: 0,\n\t},\n);\n\nglobalStyle(`${messageProse} :is(ul, ol)`, {\n\t// Legacy chat indents 15px; the nearest token wins over an untokenized value.\n\tpaddingInlineStart: t(\"padding-16\"),\n\tmargin: `${t(\"gap-4\")} 0`,\n});\n\n// Legacy chat has no paragraphs — it renders Markdown into a `pre-wrap` container\n// and spaces blank lines with a 1rem `double-line-break` span. 16px is that gap.\nglobalStyle(`${messageProse} p + p`, {\n\tmarginTop: t(\"gap-16\"),\n});\n\n// `:where()` keeps the mark rules at (0,0,1) so a component placed in the body\n// keeps its own styling: unguarded, `.messageProse a` at (0,1,1) would beat\n// `Link`'s `linkRoot` at (0,1,0).\nglobalStyle(`:where(${messageProse}) a`, {\n\t// Re-pointed per body rather than reading `color-content-link` directly —\n\t// `UserMessage` moves it for the accent fill.\n\tcolor: t(\"message-content-link\"),\n\t// The non-color cue a link needs to read as one (WCAG 1.4.1).\n\ttextDecoration: \"underline\",\n});\n\nglobalStyle(`:where(${messageProse}) strong`, {\n\tfontWeight: t(\"font-weight-semi-bold\"),\n});\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageRow.css.js","names":[],"sources":["../../../src/components/MessageRow/MessageRow.css.ts"],"sourcesContent":["import { recipe } from \"@vanilla-extract/recipes\";\nimport { t } from \"../../tokens/index.js\";\n\nexport const messageRowRoot = recipe({\n\tbase: {\n\t\tdisplay: \"flex\",\n\t\talignItems: \"flex-start\",\n\t\tgap: t(\"gap-12\"),\n\t},\n\tvariants: {\n\t\tsender: {\n\t\t\tagent: { justifyContent: \"flex-start\" },\n\t\t\tuser: { justifyContent: \"flex-end\" },\n\t\t},\n\t},\n\tdefaultVariants: { sender: \"agent\" },\n});\n\nexport const messageRowContent = recipe({\n\tbase: {\n\t\tdisplay: \"flex\",\n\t\tflexDirection: \"column\",\n\t\tminWidth: 0,\n\t\t// Message type and wrapping sit here rather than on the message body, so a\n\t\t// row whose content is a card, a widget or media reads at message size and\n\t\t// still breaks an unbroken token. Those rows render no message body, and\n\t\t// without this they fall through to the consumer's document default.\n\t\tfontFamily: t(\"font-family-body\"),\n\t\tfontSize: t(\"
|
|
1
|
+
{"version":3,"file":"MessageRow.css.js","names":[],"sources":["../../../src/components/MessageRow/MessageRow.css.ts"],"sourcesContent":["import { recipe } from \"@vanilla-extract/recipes\";\nimport { t } from \"../../tokens/index.js\";\n\nexport const messageRowRoot = recipe({\n\tbase: {\n\t\tdisplay: \"flex\",\n\t\talignItems: \"flex-start\",\n\t\tgap: t(\"gap-12\"),\n\t},\n\tvariants: {\n\t\tsender: {\n\t\t\tagent: { justifyContent: \"flex-start\" },\n\t\t\tuser: { justifyContent: \"flex-end\" },\n\t\t},\n\t},\n\tdefaultVariants: { sender: \"agent\" },\n});\n\nexport const messageRowContent = recipe({\n\tbase: {\n\t\tdisplay: \"flex\",\n\t\tflexDirection: \"column\",\n\t\tminWidth: 0,\n\t\t// Message type and wrapping sit here rather than on the message body, so a\n\t\t// row whose content is a card, a widget or media reads at message size and\n\t\t// still breaks an unbroken token. Those rows render no message body, and\n\t\t// without this they fall through to the consumer's document default.\n\t\tfontFamily: t(\"font-family-body\"),\n\t\tfontSize: t(\"font-size-body\"),\n\t\tlineHeight: t(\"line-height-body\"),\n\t\tcolor: t(\"color-content-default\"),\n\t\toverflowWrap: \"anywhere\",\n\t\twordBreak: \"break-word\",\n\t},\n\tvariants: {\n\t\tsender: {\n\t\t\t// The chatter's bubble shrink-wraps. A sibling can be wider, as a\n\t\t\t// delivery-failure row usually is, and nothing else would hold that\n\t\t\t// sibling against the trailing edge.\n\t\t\tuser: { alignItems: \"flex-end\" },\n\t\t\tagent: { alignItems: \"stretch\" },\n\t\t},\n\t\tfill: {\n\t\t\ttrue: { flex: \"1 1 0\", maxWidth: \"100%\" },\n\t\t\tfalse: { flex: \"0 1 auto\" },\n\t\t},\n\t},\n\tcompoundVariants: [\n\t\t// The cap is a share of the whole row, avatar gutter included. Capping the\n\t\t// content's own box instead would subtract the avatar and the gap again and\n\t\t// run the text about 36px narrower.\n\t\t//\n\t\t// Only the chatter takes the narrow arm. Legacy chat splits on `nonBubble`,\n\t\t// which in the generative engine is true for every bot and agent group, so\n\t\t// the sender split here is the same rule. Legacy's own 70% chatter cap reads\n\t\t// too tight against 90%, and its `max-width: 60%` arm under 374px is not\n\t\t// ported: it spends about 115px of a 288px row on empty gutter, and legacy\n\t\t// emits it at equal specificity so it drags the bot down too.\n\t\t{ variants: { sender: \"user\", fill: false }, style: { maxWidth: \"80%\" } },\n\t\t{ variants: { sender: \"agent\", fill: false }, style: { maxWidth: \"90%\" } },\n\t],\n\tdefaultVariants: { sender: \"agent\", fill: false },\n});\n"],"mappings":""}
|
|
@@ -18,6 +18,11 @@ export interface PictureMessageProps {
|
|
|
18
18
|
aspectRatio?: PictureAspectRatio;
|
|
19
19
|
/** Force the "image unavailable" placeholder (media-slash on a muted box). */
|
|
20
20
|
unavailable?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Name of the unavailable placeholder, in the language of the surrounding UI.
|
|
23
|
+
* Defaults to "Image unavailable". The alt text follows it after a colon.
|
|
24
|
+
*/
|
|
25
|
+
unavailableLabel?: string;
|
|
21
26
|
/**
|
|
22
27
|
* Reports the underlying image's load state so a consumer can reserve space
|
|
23
28
|
* while loading or react to a load failure. The frame already swaps to the
|
|
@@ -34,4 +39,4 @@ export interface PictureMessageProps {
|
|
|
34
39
|
* image is missing or unavailable — or when the image fails to load — it shows a
|
|
35
40
|
* muted media-slash placeholder.
|
|
36
41
|
*/
|
|
37
|
-
export declare function PictureMessage({ src, alt, aspectRatio, unavailable, onLoadingStatusChange, className, ...rest }: PictureMessageProps): import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
export declare function PictureMessage({ src, alt, aspectRatio, unavailable, unavailableLabel: unavailableName, onLoadingStatusChange, className, ...rest }: PictureMessageProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,24 +6,24 @@ import { jsx as a } from "react/jsx-runtime";
|
|
|
6
6
|
import { useState as o } from "react";
|
|
7
7
|
//#region src/components/PictureMessage/PictureMessage.tsx
|
|
8
8
|
var s = "Image unavailable";
|
|
9
|
-
function c({ src: c, alt: l, aspectRatio: u, unavailable: d = !1,
|
|
10
|
-
let [
|
|
9
|
+
function c({ src: c, alt: l, aspectRatio: u, unavailable: d = !1, unavailableLabel: f = s, onLoadingStatusChange: p, className: m, ...h }) {
|
|
10
|
+
let [g, _] = o("loading"), v = d || !c, y = v || g === "error", b = typeof l == "string" ? l.trim() : "", x = b ? `${f}: ${b}` : f;
|
|
11
11
|
return /* @__PURE__ */ a("div", {
|
|
12
|
-
...
|
|
12
|
+
...h,
|
|
13
13
|
"data-aspect-ratio": u,
|
|
14
|
-
"data-unavailable":
|
|
15
|
-
"data-status":
|
|
14
|
+
"data-unavailable": y || void 0,
|
|
15
|
+
"data-status": v ? void 0 : g,
|
|
16
16
|
className: e(i({
|
|
17
17
|
aspectRatio: u,
|
|
18
|
-
unavailable:
|
|
19
|
-
}),
|
|
20
|
-
children:
|
|
18
|
+
unavailable: y
|
|
19
|
+
}), m),
|
|
20
|
+
children: v ? /* @__PURE__ */ a(t, { label: x }) : /* @__PURE__ */ a(n, {
|
|
21
21
|
className: r,
|
|
22
22
|
src: c,
|
|
23
23
|
alt: l,
|
|
24
|
-
fallback: /* @__PURE__ */ a(t, { label:
|
|
24
|
+
fallback: /* @__PURE__ */ a(t, { label: x }),
|
|
25
25
|
onLoadingStatusChange: (e) => {
|
|
26
|
-
|
|
26
|
+
_(e), p?.(e);
|
|
27
27
|
}
|
|
28
28
|
})
|
|
29
29
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PictureMessage.js","names":[],"sources":["../../../src/components/PictureMessage/PictureMessage.tsx"],"sourcesContent":["import type { CSSProperties, Ref } from \"react\";\nimport { useState } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport { MediaSlash } from \"../Icon/icons/MediaSlash.js\";\nimport type { ImageLoadingStatus } from \"../Image/index.js\";\nimport { Image } from \"../Image/index.js\";\nimport { pictureImage, pictureRoot } from \"./PictureMessage.css.js\";\n\nexport type PictureAspectRatio = \"16:9\" | \"4:3\" | \"1:1\" | \"3:4\" | \"9:16\";\n\nexport interface PictureMessageProps {\n\t/**\n\t * Image URL. When absent — or when `unavailable` is set — the muted\n\t * \"image unavailable\" placeholder renders instead of the picture.\n\t */\n\tsrc?: string;\n\t/** Alt text describing the image. Never leave empty for content images. */\n\talt: string;\n\t/**\n\t * Frame proportions — bind to the source image's proportions so it isn't\n\t * cropped. The frame is context-sized (fills its container's width); the\n\t * consumer constrains it to the message column. When omitted, the frame\n\t * takes its height from the image's natural proportions.\n\t */\n\taspectRatio?: PictureAspectRatio;\n\t/** Force the \"image unavailable\" placeholder (media-slash on a muted box). */\n\tunavailable?: boolean;\n\t/**\n\t * Reports the underlying image's load state so a consumer can reserve space\n\t * while loading or react to a load failure. The frame already swaps to the\n\t * unavailable placeholder on error on its own.\n\t */\n\tonLoadingStatusChange?: (status: ImageLoadingStatus) => void;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n}\n\nconst UNAVAILABLE_LABEL = \"Image unavailable\";\n\n/**\n * A rounded image attachment rendered inside a chat message. Clips the picture to\n * the media-preview corner radius and holds it at a fixed aspect ratio; when the\n * image is missing or unavailable — or when the image fails to load — it shows a\n * muted media-slash placeholder.\n */\nexport function PictureMessage({\n\tsrc,\n\talt,\n\taspectRatio,\n\tunavailable = false,\n\tonLoadingStatusChange,\n\tclassName,\n\t...rest\n}: PictureMessageProps) {\n\tconst [status, setStatus] = useState<ImageLoadingStatus>(\"loading\");\n\tconst forced = unavailable || !src;\n\tconst showPlaceholder = forced || status === \"error\";\n\t// Lovelace can be consumed from older/untyped JavaScript even though the TS\n\t// contract requires a string, so the failure path must remain total.\n\tconst description = typeof alt === \"string\" ? alt.trim() : \"\";\n\tconst unavailableLabel = description\n\t\t? `${
|
|
1
|
+
{"version":3,"file":"PictureMessage.js","names":[],"sources":["../../../src/components/PictureMessage/PictureMessage.tsx"],"sourcesContent":["import type { CSSProperties, Ref } from \"react\";\nimport { useState } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport { MediaSlash } from \"../Icon/icons/MediaSlash.js\";\nimport type { ImageLoadingStatus } from \"../Image/index.js\";\nimport { Image } from \"../Image/index.js\";\nimport { pictureImage, pictureRoot } from \"./PictureMessage.css.js\";\n\nexport type PictureAspectRatio = \"16:9\" | \"4:3\" | \"1:1\" | \"3:4\" | \"9:16\";\n\nexport interface PictureMessageProps {\n\t/**\n\t * Image URL. When absent — or when `unavailable` is set — the muted\n\t * \"image unavailable\" placeholder renders instead of the picture.\n\t */\n\tsrc?: string;\n\t/** Alt text describing the image. Never leave empty for content images. */\n\talt: string;\n\t/**\n\t * Frame proportions — bind to the source image's proportions so it isn't\n\t * cropped. The frame is context-sized (fills its container's width); the\n\t * consumer constrains it to the message column. When omitted, the frame\n\t * takes its height from the image's natural proportions.\n\t */\n\taspectRatio?: PictureAspectRatio;\n\t/** Force the \"image unavailable\" placeholder (media-slash on a muted box). */\n\tunavailable?: boolean;\n\t/**\n\t * Name of the unavailable placeholder, in the language of the surrounding UI.\n\t * Defaults to \"Image unavailable\". The alt text follows it after a colon.\n\t */\n\tunavailableLabel?: string;\n\t/**\n\t * Reports the underlying image's load state so a consumer can reserve space\n\t * while loading or react to a load failure. The frame already swaps to the\n\t * unavailable placeholder on error on its own.\n\t */\n\tonLoadingStatusChange?: (status: ImageLoadingStatus) => void;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n}\n\nconst UNAVAILABLE_LABEL = \"Image unavailable\";\n\n/**\n * A rounded image attachment rendered inside a chat message. Clips the picture to\n * the media-preview corner radius and holds it at a fixed aspect ratio; when the\n * image is missing or unavailable — or when the image fails to load — it shows a\n * muted media-slash placeholder.\n */\nexport function PictureMessage({\n\tsrc,\n\talt,\n\taspectRatio,\n\tunavailable = false,\n\tunavailableLabel: unavailableName = UNAVAILABLE_LABEL,\n\tonLoadingStatusChange,\n\tclassName,\n\t...rest\n}: PictureMessageProps) {\n\tconst [status, setStatus] = useState<ImageLoadingStatus>(\"loading\");\n\tconst forced = unavailable || !src;\n\tconst showPlaceholder = forced || status === \"error\";\n\t// Lovelace can be consumed from older/untyped JavaScript even though the TS\n\t// contract requires a string, so the failure path must remain total.\n\tconst description = typeof alt === \"string\" ? alt.trim() : \"\";\n\tconst unavailableLabel = description\n\t\t? `${unavailableName}: ${description}`\n\t\t: unavailableName;\n\treturn (\n\t\t<div\n\t\t\t{...rest}\n\t\t\tdata-aspect-ratio={aspectRatio}\n\t\t\tdata-unavailable={showPlaceholder || undefined}\n\t\t\tdata-status={forced ? undefined : status}\n\t\t\tclassName={cx(\n\t\t\t\tpictureRoot({ aspectRatio, unavailable: showPlaceholder }),\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t>\n\t\t\t{forced ? (\n\t\t\t\t<MediaSlash label={unavailableLabel} />\n\t\t\t) : (\n\t\t\t\t<Image\n\t\t\t\t\tclassName={pictureImage}\n\t\t\t\t\tsrc={src}\n\t\t\t\t\talt={alt}\n\t\t\t\t\tfallback={<MediaSlash label={unavailableLabel} />}\n\t\t\t\t\tonLoadingStatusChange={(next) => {\n\t\t\t\t\t\tsetStatus(next);\n\t\t\t\t\t\tonLoadingStatusChange?.(next);\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AA2CA,IAAM,IAAoB;AAQ1B,SAAgB,EAAe,EAC9B,QACA,QACA,gBACA,iBAAc,IACd,kBAAkB,IAAkB,GACpC,0BACA,cACA,GAAG,KACoB;CACvB,IAAM,CAAC,GAAQ,KAAa,EAA6B,SAAS,GAC5D,IAAS,KAAe,CAAC,GACzB,IAAkB,KAAU,MAAW,SAGvC,IAAc,OAAO,KAAQ,WAAW,EAAI,KAAK,IAAI,IACrD,IAAmB,IACtB,GAAG,EAAgB,IAAI,MACvB;CACH,OACC,kBAAC,OAAD;EACC,GAAI;EACJ,qBAAmB;EACnB,oBAAkB,KAAmB,KAAA;EACrC,eAAa,IAAS,KAAA,IAAY;EAClC,WAAW,EACV,EAAY;GAAE;GAAa,aAAa;EAAgB,CAAC,GACzD,CACD;YAEC,IACA,kBAAC,GAAD,EAAY,OAAO,EAAmB,CAAA,IAEtC,kBAAC,GAAD;GACC,WAAW;GACN;GACA;GACL,UAAU,kBAAC,GAAD,EAAY,OAAO,EAAmB,CAAA;GAChD,wBAAwB,MAAS;IAEhC,AADA,EAAU,CAAI,GACd,IAAwB,CAAI;GAC7B;EACA,CAAA;CAEE,CAAA;AAEP"}
|
|
@@ -7,6 +7,9 @@ export declare const scrollMarkerRoot: import("@vanilla-extract/recipes").Runtim
|
|
|
7
7
|
brand: {
|
|
8
8
|
backgroundColor: "var(--lovelace-color-background-accent)";
|
|
9
9
|
color: "var(--lovelace-color-content-on-accent)";
|
|
10
|
+
"::after": {
|
|
11
|
+
readonly backgroundColor: `var(--${string})`;
|
|
12
|
+
};
|
|
10
13
|
};
|
|
11
14
|
};
|
|
12
15
|
type: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollMarker.css.js","names":[],"sources":["../../../src/components/ScrollMarker/ScrollMarker.css.ts"],"sourcesContent":["import { globalStyle, style } from \"@vanilla-extract/css\";\nimport { recipe } from \"@vanilla-extract/recipes\";\nimport { focusRing } from \"../../styles/focus-ring.js\";\nimport { typography } from \"../../styles/typography.js\";\nimport { t } from \"../../tokens/index.js\";\n\nconst DROP_SHADOW = t(\"elevation-2\");\n\nconst scrollMarkerBase = style({});\n\nexport const scrollMarkerRoot = recipe({\n\tbase: [\n\t\tscrollMarkerBase,\n\t\t{\n\t\t\tposition: \"relative\",\n\t\t\tisolation: \"isolate\",\n\t\t\tdisplay: \"inline-flex\",\n\t\t\talignItems: \"center\",\n\t\t\tjustifyContent: \"center\",\n\t\t\tboxSizing: \"border-box\",\n\t\t\tborder: \"none\",\n\t\t\tborderRadius: t(\"border-radius-full\"),\n\t\t\tboxShadow: DROP_SHADOW,\n\t\t\t...typography(\"body\", \"medium\"),\n\t\t\twhiteSpace: \"nowrap\",\n\t\t\tcursor: \"pointer\",\n\t\t\tuserSelect: \"none\",\n\t\t\tappearance: \"none\",\n\t\t\toutline: \"none\",\n\t\t\ttransitionProperty: \"background-color, box-shadow\",\n\t\t\ttransitionDuration: t(\"duration-fast\"),\n\t\t\ttransitionTimingFunction: t(\"easing-standard\"),\n\t\t\t\"::after\": {\n\t\t\t\tcontent: '\"\"',\n\t\t\t\tposition: \"absolute\",\n\t\t\t\tinset: 0,\n\t\t\t\tborderRadius: \"inherit\",\n\t\t\t\tbackgroundColor: \"currentColor\",\n\t\t\t\topacity: 0,\n\t\t\t\tpointerEvents: \"none\",\n\t\t\t\tzIndex: -1,\n\t\t\t\ttransition: `opacity ${t(\"duration-fast\")} ${t(\"easing-standard\")}`,\n\t\t\t},\n\t\t\tselectors: {\n\t\t\t\t\"&[data-hovered]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-hover\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-focus-visible]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-focus\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-pressed]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-pressed\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": focusRing,\n\t\t\t},\n\t\t\t\"@media\": {\n\t\t\t\t\"(forced-colors: active)\": {\n\t\t\t\t\tselectors: {\n\t\t\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": {\n\t\t\t\t\t\t\toutline: \"2px solid Highlight\",\n\t\t\t\t\t\t\toutlineOffset: \"2px\",\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},\n\t],\n\tvariants: {\n\t\tcolor: {\n\t\t\tdefault: {\n\t\t\t\tbackgroundColor: t(\"scrollmarker-background\"),\n\t\t\t\tcolor: t(\"scrollmarker-content\"),\n\t\t\t},\n\t\t\tbrand: {\n\t\t\t\tbackgroundColor: t(\"color-background-accent\"),\n\t\t\t\tcolor: t(\"color-content-on-accent\"),\n\t\t\t},\n\t\t},\n\t\t// Hardcoded frame dimensions mirror Figma's fixed sizes (icon-only 40px circle,\n\t\t// with-text 38px pill row), which the token set does not expose as spacing values.\n\t\ttype: {\n\t\t\ticonOnly: { width: \"40px\", height: \"40px\", padding: 0 },\n\t\t\twithText: {\n\t\t\t\theight: \"38px\",\n\t\t\t\tpaddingInline: t(\"padding-12\"),\n\t\t\t\tgap: t(\"gap-8\"),\n\t\t\t},\n\t\t},\n\t},\n\tdefaultVariants: {\n\t\tcolor: \"default\",\n\t\ttype: \"iconOnly\",\n\t},\n});\n\n// Descendant target must be a global rule; vanilla-extract disallows it inside `selectors`.\nglobalStyle(`${scrollMarkerBase} [data-slot='icon']`, {\n\tflexShrink: 0,\n\tfontSize: t(\"icon-size-control\"),\n});\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ScrollMarker.css.js","names":[],"sources":["../../../src/components/ScrollMarker/ScrollMarker.css.ts"],"sourcesContent":["import { globalStyle, style } from \"@vanilla-extract/css\";\nimport { recipe } from \"@vanilla-extract/recipes\";\nimport { focusRing } from \"../../styles/focus-ring.js\";\nimport { stateLayerOnAccent } from \"../../styles/state-layer.css.js\";\nimport { typography } from \"../../styles/typography.js\";\nimport { t } from \"../../tokens/index.js\";\n\nconst DROP_SHADOW = t(\"elevation-2\");\n\nconst scrollMarkerBase = style({});\n\nexport const scrollMarkerRoot = recipe({\n\tbase: [\n\t\tscrollMarkerBase,\n\t\t{\n\t\t\tposition: \"relative\",\n\t\t\tisolation: \"isolate\",\n\t\t\tdisplay: \"inline-flex\",\n\t\t\talignItems: \"center\",\n\t\t\tjustifyContent: \"center\",\n\t\t\tboxSizing: \"border-box\",\n\t\t\tborder: \"none\",\n\t\t\tborderRadius: t(\"border-radius-full\"),\n\t\t\tboxShadow: DROP_SHADOW,\n\t\t\t...typography(\"body\", \"medium\"),\n\t\t\twhiteSpace: \"nowrap\",\n\t\t\tcursor: \"pointer\",\n\t\t\tuserSelect: \"none\",\n\t\t\tappearance: \"none\",\n\t\t\toutline: \"none\",\n\t\t\ttransitionProperty: \"background-color, box-shadow\",\n\t\t\ttransitionDuration: t(\"duration-fast\"),\n\t\t\ttransitionTimingFunction: t(\"easing-standard\"),\n\t\t\t\"::after\": {\n\t\t\t\tcontent: '\"\"',\n\t\t\t\tposition: \"absolute\",\n\t\t\t\tinset: 0,\n\t\t\t\tborderRadius: \"inherit\",\n\t\t\t\tbackgroundColor: \"currentColor\",\n\t\t\t\topacity: 0,\n\t\t\t\tpointerEvents: \"none\",\n\t\t\t\tzIndex: -1,\n\t\t\t\ttransition: `opacity ${t(\"duration-fast\")} ${t(\"easing-standard\")}`,\n\t\t\t},\n\t\t\tselectors: {\n\t\t\t\t\"&[data-hovered]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-hover\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-focus-visible]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-focus\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-pressed]:not([data-disabled])::after\": {\n\t\t\t\t\topacity: t(\"opacity-state-pressed\"),\n\t\t\t\t},\n\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": focusRing,\n\t\t\t},\n\t\t\t\"@media\": {\n\t\t\t\t\"(forced-colors: active)\": {\n\t\t\t\t\tselectors: {\n\t\t\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": {\n\t\t\t\t\t\t\toutline: \"2px solid Highlight\",\n\t\t\t\t\t\t\toutlineOffset: \"2px\",\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},\n\t],\n\tvariants: {\n\t\tcolor: {\n\t\t\tdefault: {\n\t\t\t\tbackgroundColor: t(\"scrollmarker-background\"),\n\t\t\t\tcolor: t(\"scrollmarker-content\"),\n\t\t\t},\n\t\t\tbrand: {\n\t\t\t\tbackgroundColor: t(\"color-background-accent\"),\n\t\t\t\tcolor: t(\"color-content-on-accent\"),\n\t\t\t\t\"::after\": stateLayerOnAccent.accent,\n\t\t\t},\n\t\t},\n\t\t// Hardcoded frame dimensions mirror Figma's fixed sizes (icon-only 40px circle,\n\t\t// with-text 38px pill row), which the token set does not expose as spacing values.\n\t\ttype: {\n\t\t\ticonOnly: { width: \"40px\", height: \"40px\", padding: 0 },\n\t\t\twithText: {\n\t\t\t\theight: \"38px\",\n\t\t\t\tpaddingInline: t(\"padding-12\"),\n\t\t\t\tgap: t(\"gap-8\"),\n\t\t\t},\n\t\t},\n\t},\n\tdefaultVariants: {\n\t\tcolor: \"default\",\n\t\ttype: \"iconOnly\",\n\t},\n});\n\n// Descendant target must be a global rule; vanilla-extract disallows it inside `selectors`.\nglobalStyle(`${scrollMarkerBase} [data-slot='icon']`, {\n\tflexShrink: 0,\n\tfontSize: t(\"icon-size-control\"),\n});\n"],"mappings":""}
|
|
@@ -34,6 +34,6 @@ export type SurveySelectProps = SurveyLabelProps & {
|
|
|
34
34
|
/**
|
|
35
35
|
* Multi-select chip group for surveys — the labelled-pill counterpart to the single-select
|
|
36
36
|
* {@link SurveyRating}. Any number of options can be selected at once; selection state
|
|
37
|
-
* renders the accent fill on each {@link Chip}.
|
|
37
|
+
* renders the accent fill and inner ring on each {@link Chip}.
|
|
38
38
|
*/
|
|
39
39
|
export declare function SurveySelect({ options, selectionMode, disallowEmptySelection, isDisabled, selectedKeys, defaultSelectedKeys, onChange, className, style, ref, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, }: SurveySelectProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SurveySelect.js","names":[],"sources":["../../../src/components/SurveySelect/SurveySelect.tsx"],"sourcesContent":["import type { CSSProperties, Ref } from \"react\";\nimport type { Key } from \"react-aria-components\";\nimport { ToggleButtonGroup } from \"react-aria-components\";\nimport { cx } from \"../../utils/cx.js\";\nimport { Chip } from \"../Chip/index.js\";\nimport type { SurveyLabelProps } from \"../SurveyRating/SurveyLabelProps.js\";\nimport { surveySelectRoot } from \"./SurveySelect.css.js\";\n\nexport interface SurveySelectOption {\n\t/** Chip label text. */\n\tlabel: string;\n\t/** Stable identity used for selection. Defaults to the option's array index. */\n\tkey?: Key;\n}\n\nexport type SurveySelectProps = SurveyLabelProps & {\n\t/** Selectable options, rendered in order. */\n\toptions: SurveySelectOption[];\n\t/**\n\t * `multiple` (default) allows any number of selected chips; `single` allows at\n\t * most one (e.g. a Yes/No question) and renders as a radiogroup.\n\t */\n\tselectionMode?: \"single\" | \"multiple\";\n\t/**\n\t * When `true`, a selected option can't be toggled back off — restores radio\n\t * semantics for a required single-select (e.g. a Yes/No question).\n\t */\n\tdisallowEmptySelection?: boolean;\n\tisDisabled?: boolean;\n\t/** Selected option keys (controlled). */\n\tselectedKeys?: Key[];\n\t/** Initially-selected option keys (uncontrolled). */\n\tdefaultSelectedKeys?: Key[];\n\t/** Fires with the full set of selected keys and their options, in option order. */\n\tonChange?: (keys: Key[], options: SurveySelectOption[]) => void;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n};\n\nconst keyFor = (option: SurveySelectOption, index: number) =>\n\toption.key ?? index;\n\n/**\n * Multi-select chip group for surveys — the labelled-pill counterpart to the single-select\n * {@link SurveyRating}. Any number of options can be selected at once; selection state\n * renders the accent fill on each {@link Chip}.\n */\nexport function SurveySelect({\n\toptions,\n\tselectionMode = \"multiple\",\n\tdisallowEmptySelection,\n\tisDisabled,\n\tselectedKeys,\n\tdefaultSelectedKeys,\n\tonChange,\n\tclassName,\n\tstyle,\n\tref,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledBy,\n}: SurveySelectProps) {\n\tconst handleSelectionChange = (keys: Set<Key>) => {\n\t\tconst selected = options\n\t\t\t.map((option, index) => ({ option, key: keyFor(option, index) }))\n\t\t\t.filter(({ key }) => keys.has(key));\n\t\tonChange?.(\n\t\t\tselected.map((s) => s.key),\n\t\t\tselected.map((s) => s.option),\n\t\t);\n\t};\n\n\tconst isControlled = selectedKeys !== undefined;\n\n\treturn (\n\t\t<ToggleButtonGroup\n\t\t\tref={ref}\n\t\t\tselectionMode={selectionMode}\n\t\t\tdisallowEmptySelection={disallowEmptySelection}\n\t\t\tisDisabled={isDisabled}\n\t\t\taria-label={ariaLabelledBy ? undefined : ariaLabel}\n\t\t\taria-labelledby={ariaLabelledBy}\n\t\t\tclassName={cx(surveySelectRoot, className)}\n\t\t\tstyle={style}\n\t\t\tonSelectionChange={handleSelectionChange}\n\t\t\tselectedKeys={isControlled ? selectedKeys : undefined}\n\t\t\tdefaultSelectedKeys={\n\t\t\t\tisControlled ? undefined : (defaultSelectedKeys ?? [])\n\t\t\t}\n\t\t>\n\t\t\t{options.map((option, index) => (\n\t\t\t\t<Chip\n\t\t\t\t\tkey={keyFor(option, index)}\n\t\t\t\t\tid={keyFor(option, index)}\n\t\t\t\t\tvariant=\"text\"\n\t\t\t\t\tsize=\"md\"\n\t\t\t\t>\n\t\t\t\t\t{option.label}\n\t\t\t\t</Chip>\n\t\t\t))}\n\t\t</ToggleButtonGroup>\n\t);\n}\n"],"mappings":";;;;;;AAwCA,IAAM,KAAU,GAA4B,MAC3C,EAAO,OAAO;AAOf,SAAgB,EAAa,EAC5B,YACA,mBAAgB,YAChB,2BACA,eACA,iBACA,wBACA,aACA,cACA,UACA,QACA,cAAc,GACd,mBAAmB,KACE;CACrB,IAAM,KAAyB,MAAmB;EACjD,IAAM,IAAW,EACf,KAAK,GAAQ,OAAW;GAAE;GAAQ,KAAK,EAAO,GAAQ,CAAK;EAAE,EAAE,CAAC,CAChE,QAAQ,EAAE,aAAU,EAAK,IAAI,CAAG,CAAC;EACnC,IACC,EAAS,KAAK,MAAM,EAAE,GAAG,GACzB,EAAS,KAAK,MAAM,EAAE,MAAM,CAC7B;CACD,GAEM,IAAe,MAAiB,KAAA;CAEtC,OACC,kBAAC,GAAD;EACM;EACU;EACS;EACZ;EACZ,cAAY,IAAiB,KAAA,IAAY;EACzC,mBAAiB;EACjB,WAAW,EAAG,GAAkB,CAAS;EAClC;EACP,mBAAmB;EACnB,cAAc,IAAe,IAAe,KAAA;EAC5C,qBACC,IAAe,KAAA,IAAa,KAAuB,CAAC;YAGpD,EAAQ,KAAK,GAAQ,MACrB,kBAAC,GAAD;GAEC,IAAI,EAAO,GAAQ,CAAK;GACxB,SAAQ;GACR,MAAK;aAEJ,EAAO;EACH,GANA,EAAO,GAAQ,CAAK,CAMpB,CACN;CACiB,CAAA;AAErB"}
|
|
1
|
+
{"version":3,"file":"SurveySelect.js","names":[],"sources":["../../../src/components/SurveySelect/SurveySelect.tsx"],"sourcesContent":["import type { CSSProperties, Ref } from \"react\";\nimport type { Key } from \"react-aria-components\";\nimport { ToggleButtonGroup } from \"react-aria-components\";\nimport { cx } from \"../../utils/cx.js\";\nimport { Chip } from \"../Chip/index.js\";\nimport type { SurveyLabelProps } from \"../SurveyRating/SurveyLabelProps.js\";\nimport { surveySelectRoot } from \"./SurveySelect.css.js\";\n\nexport interface SurveySelectOption {\n\t/** Chip label text. */\n\tlabel: string;\n\t/** Stable identity used for selection. Defaults to the option's array index. */\n\tkey?: Key;\n}\n\nexport type SurveySelectProps = SurveyLabelProps & {\n\t/** Selectable options, rendered in order. */\n\toptions: SurveySelectOption[];\n\t/**\n\t * `multiple` (default) allows any number of selected chips; `single` allows at\n\t * most one (e.g. a Yes/No question) and renders as a radiogroup.\n\t */\n\tselectionMode?: \"single\" | \"multiple\";\n\t/**\n\t * When `true`, a selected option can't be toggled back off — restores radio\n\t * semantics for a required single-select (e.g. a Yes/No question).\n\t */\n\tdisallowEmptySelection?: boolean;\n\tisDisabled?: boolean;\n\t/** Selected option keys (controlled). */\n\tselectedKeys?: Key[];\n\t/** Initially-selected option keys (uncontrolled). */\n\tdefaultSelectedKeys?: Key[];\n\t/** Fires with the full set of selected keys and their options, in option order. */\n\tonChange?: (keys: Key[], options: SurveySelectOption[]) => void;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLDivElement>;\n};\n\nconst keyFor = (option: SurveySelectOption, index: number) =>\n\toption.key ?? index;\n\n/**\n * Multi-select chip group for surveys — the labelled-pill counterpart to the single-select\n * {@link SurveyRating}. Any number of options can be selected at once; selection state\n * renders the accent fill and inner ring on each {@link Chip}.\n */\nexport function SurveySelect({\n\toptions,\n\tselectionMode = \"multiple\",\n\tdisallowEmptySelection,\n\tisDisabled,\n\tselectedKeys,\n\tdefaultSelectedKeys,\n\tonChange,\n\tclassName,\n\tstyle,\n\tref,\n\t\"aria-label\": ariaLabel,\n\t\"aria-labelledby\": ariaLabelledBy,\n}: SurveySelectProps) {\n\tconst handleSelectionChange = (keys: Set<Key>) => {\n\t\tconst selected = options\n\t\t\t.map((option, index) => ({ option, key: keyFor(option, index) }))\n\t\t\t.filter(({ key }) => keys.has(key));\n\t\tonChange?.(\n\t\t\tselected.map((s) => s.key),\n\t\t\tselected.map((s) => s.option),\n\t\t);\n\t};\n\n\tconst isControlled = selectedKeys !== undefined;\n\n\treturn (\n\t\t<ToggleButtonGroup\n\t\t\tref={ref}\n\t\t\tselectionMode={selectionMode}\n\t\t\tdisallowEmptySelection={disallowEmptySelection}\n\t\t\tisDisabled={isDisabled}\n\t\t\taria-label={ariaLabelledBy ? undefined : ariaLabel}\n\t\t\taria-labelledby={ariaLabelledBy}\n\t\t\tclassName={cx(surveySelectRoot, className)}\n\t\t\tstyle={style}\n\t\t\tonSelectionChange={handleSelectionChange}\n\t\t\tselectedKeys={isControlled ? selectedKeys : undefined}\n\t\t\tdefaultSelectedKeys={\n\t\t\t\tisControlled ? undefined : (defaultSelectedKeys ?? [])\n\t\t\t}\n\t\t>\n\t\t\t{options.map((option, index) => (\n\t\t\t\t<Chip\n\t\t\t\t\tkey={keyFor(option, index)}\n\t\t\t\t\tid={keyFor(option, index)}\n\t\t\t\t\tvariant=\"text\"\n\t\t\t\t\tsize=\"md\"\n\t\t\t\t>\n\t\t\t\t\t{option.label}\n\t\t\t\t</Chip>\n\t\t\t))}\n\t\t</ToggleButtonGroup>\n\t);\n}\n"],"mappings":";;;;;;AAwCA,IAAM,KAAU,GAA4B,MAC3C,EAAO,OAAO;AAOf,SAAgB,EAAa,EAC5B,YACA,mBAAgB,YAChB,2BACA,eACA,iBACA,wBACA,aACA,cACA,UACA,QACA,cAAc,GACd,mBAAmB,KACE;CACrB,IAAM,KAAyB,MAAmB;EACjD,IAAM,IAAW,EACf,KAAK,GAAQ,OAAW;GAAE;GAAQ,KAAK,EAAO,GAAQ,CAAK;EAAE,EAAE,CAAC,CAChE,QAAQ,EAAE,aAAU,EAAK,IAAI,CAAG,CAAC;EACnC,IACC,EAAS,KAAK,MAAM,EAAE,GAAG,GACzB,EAAS,KAAK,MAAM,EAAE,MAAM,CAC7B;CACD,GAEM,IAAe,MAAiB,KAAA;CAEtC,OACC,kBAAC,GAAD;EACM;EACU;EACS;EACZ;EACZ,cAAY,IAAiB,KAAA,IAAY;EACzC,mBAAiB;EACjB,WAAW,EAAG,GAAkB,CAAS;EAClC;EACP,mBAAmB;EACnB,cAAc,IAAe,IAAe,KAAA;EAC5C,qBACC,IAAe,KAAA,IAAa,KAAuB,CAAC;YAGpD,EAAQ,KAAK,GAAQ,MACrB,kBAAC,GAAD;GAEC,IAAI,EAAO,GAAQ,CAAK;GACxB,SAAQ;GACR,MAAK;aAEJ,EAAO;EACH,GANA,EAAO,GAAQ,CAAK,CAMpB,CACN;CACiB,CAAA;AAErB"}
|
|
@@ -31,6 +31,12 @@ export declare const toastDismiss: string;
|
|
|
31
31
|
* pointer through and each card takes it back.
|
|
32
32
|
*/
|
|
33
33
|
export declare const toastAnchor: string;
|
|
34
|
+
/**
|
|
35
|
+
* Hides the announcer's live regions from view but keeps them a real box.
|
|
36
|
+
* WebKit before 16 drops an element with `display: contents` from the
|
|
37
|
+
* accessibility tree, and a region outside that tree is never spoken.
|
|
38
|
+
*/
|
|
39
|
+
export declare const toastAnnouncer: string;
|
|
34
40
|
export declare const toastRegion: string;
|
|
35
41
|
export declare const toastList: string;
|
|
36
42
|
export declare const toastCard: string;
|
|
@@ -12,8 +12,8 @@ var t = "_16991601", n = e({
|
|
|
12
12
|
} },
|
|
13
13
|
defaultVariants: { status: "success" },
|
|
14
14
|
compoundVariants: []
|
|
15
|
-
}), r = "_16991608", i = "_16991609", a = "_1699160a", o = "_1699160b", s = "_1699160c", c = "_1699160d";
|
|
15
|
+
}), r = "_16991608", i = "_16991609", a = "_1699160a", o = "_1699160b", s = "_1699160c", c = "_1699160d", l = "_1699160e";
|
|
16
16
|
//#endregion
|
|
17
|
-
export { t as toast, a as toastAnchor,
|
|
17
|
+
export { t as toast, a as toastAnchor, o as toastAnnouncer, l as toastCard, i as toastDismiss, n as toastIcon, c as toastList, r as toastMessage, s as toastRegion };
|
|
18
18
|
|
|
19
19
|
//# sourceMappingURL=Toast.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.css.js","names":[],"sources":["../../../src/components/Toast/Toast.css.ts"],"sourcesContent":["import {\n\tcreateVar,\n\tfallbackVar,\n\tglobalStyle,\n\tstyle,\n} from \"@vanilla-extract/css\";\nimport { recipe } from \"@vanilla-extract/recipes\";\nimport { t } from \"../../tokens/index.js\";\n\n/**\n * The card's border colour, set on the element each theme is declared on.\n *\n * Dark resolves `border-default` and `background-tertiary` to the same\n * neutral-700, so the border paints nothing there. `border-medium` is what\n * separates the card from the canvas: the fill alone is 1.7:1 against\n * `background-default`, the border 3.4:1, which is the 3:1 that non-text\n * boundaries need.\n *\n * It rides the theme element rather than a `[data-theme=\"dark\"] &` descendant\n * selector, which matches any dark ancestor rather than the nearest one. A light\n * provider inside a dark page would take the dark border. The tokens themselves\n * are declared the same way, so the nearest provider wins by inheritance.\n */\nconst cardBorderColor = createVar();\n\nglobalStyle('[data-theme=\"light\"]', {\n\tvars: { [cardBorderColor]: t(\"color-border-default\") },\n});\n\nglobalStyle('[data-theme=\"dark\"]', {\n\tvars: { [cardBorderColor]: t(\"color-border-medium\") },\n});\n\n// Hugs its content rather than filling the row, which is what separates it from\n// the banner surface: a card that floats over the transcript, not a strip that\n// belongs to it. `toastList` below centres it.\nexport const toast = style({\n\tdisplay: \"flex\",\n\talignItems: \"center\",\n\tjustifyContent: \"flex-start\",\n\tboxSizing: \"border-box\",\n\t// Sized to its own content, the way Figma draws it — the five variants range\n\t// 157-222px wide. Without this the card is a block-level div and fills\n\t// whatever holds it, which is the banner surface's shape, not this one.\n\t// Capped so long copy wraps inside the chat window instead of overflowing it.\n\twidth: \"fit-content\",\n\tmaxWidth: \"100%\",\n\tgap: t(\"gap-8\"),\n\tpaddingInline: t(\"padding-12\"),\n\tpaddingBlock: t(\"padding-8\"),\n\tborderRadius: t(\"border-radius-10\"),\n\tborderWidth: t(\"border-width-default\"),\n\tborderStyle: \"solid\",\n\tborderColor: fallbackVar(cardBorderColor, t(\"color-border-default\")),\n\tbackgroundColor: t(\"color-background-tertiary\"),\n\tboxShadow: t(\"elevation-3\"),\n\t\"@media\": {\n\t\t// The shadow is what lifts the card off the transcript, and forced colors\n\t\t// drops it — so the border has to carry the boundary on its own.\n\t\t\"(forced-colors: active)\": { borderColor: \"CanvasText\" },\n\t},\n});\n\nexport const toastIcon = recipe({\n\tbase: {\n\t\tdisplay: \"flex\",\n\t\talignItems: \"center\",\n\t\tjustifyContent: \"center\",\n\t\tflexShrink: 0,\n\t\tlineHeight: 0,\n\t},\n\t// Only the glyph changes between statuses — the card paints identically for\n\t// all five, so there is no variant axis on the card itself.\n\tvariants: {\n\t\tstatus: {\n\t\t\tsuccess: {\n\t\t\t\tcolor: t(\"color-content-success\"),\n\t\t\t\tfontSize: t(\"icon-size-control\"),\n\t\t\t},\n\t\t\twarning: {\n\t\t\t\tcolor: t(\"color-content-warning\"),\n\t\t\t\tfontSize: t(\"icon-size-control\"),\n\t\t\t},\n\t\t\terror: {\n\t\t\t\tcolor: t(\"color-content-destructive\"),\n\t\t\t\tfontSize: t(\"icon-size-control\"),\n\t\t\t},\n\t\t\tcustom: {\n\t\t\t\tcolor: t(\"color-content-secondary\"),\n\t\t\t\tfontSize: t(\"icon-size-lg\"),\n\t\t\t},\n\t\t\t// Figma sizes this slot off line-height/title-small (24px). Spinner ships\n\t\t\t// 16px and 32px with per-size border widths, so the 16px one is centred\n\t\t\t// in a 24px box rather than scaled to a size it was not drawn for.\n\t\t\tloading: {\n\t\t\t\twidth: t(\"icon-size-lg\"),\n\t\t\t\theight: t(\"icon-size-lg\"),\n\t\t\t},\n\t\t},\n\t},\n\tdefaultVariants: { status: \"success\" },\n});\n\nexport const toastMessage = style({\n\tminWidth: 0,\n\tmarginInlineEnd: \"auto\",\n\t// The glyph carries the status, so the copy stays at the default content\n\t// colour rather than tinting with it — unlike the banner surface, where the\n\t// tinted background sets the whole card's tone.\n\tcolor: t(\"color-content-default\"),\n\tfontFamily: t(\"font-family-body\"),\n\tfontWeight: t(\"font-weight-medium\"),\n\tfontSize: t(\"font-size-body\"),\n\tlineHeight: t(\"line-height-body\"),\n\toverflowWrap: \"break-word\",\n});\n\n// IconButton's tertiary intent paints content-default; Figma wants the dismiss\n// glyph quieter. Its state layer is currentColor, so it follows automatically.\nexport const toastDismiss = style({\n\tflexShrink: 0,\n\tcolor: t(\"color-content-secondary\"),\n});\n\nglobalStyle(`${toast} > [data-slot='button'] [data-slot='icon']`, {\n\tfontSize: t(\"icon-size-sm\"),\n});\n\n// Matches the banner surface: the control is taken away only while the card is\n// leaving, which is not a state the reader should read as unavailable.\nglobalStyle(`${toast} > [data-slot='button'][data-disabled]`, {\n\t// Restated rather than inherited: this selector outranks `toastDismiss`, and\n\t// the card sets no colour of its own for `inherit` to land on.\n\tcolor: t(\"color-content-secondary\"),\n\tcursor: \"inherit\",\n});\n\n/**\n * The always-mounted anchor the region portals into. It spans the width its\n * consumer gives it while the cards only hug their content, so it passes the\n * pointer through and each card takes it back.\n */\nexport const toastAnchor = style({\n\tpointerEvents: \"none\",\n});\n\nexport const toastRegion = style({\n\toutline: \"none\",\n});\n\nexport const toastList = style({\n\tlistStyle: \"none\",\n\tmargin: 0,\n\tpadding: 0,\n\tdisplay: \"flex\",\n\t// The queue hands its toasts over newest first, and the newest belongs at the\n\t// bottom of the stack, nearest the composer. Reversing the column here rather\n\t// than reordering the list keeps the DOM order the queue's own, which is what\n\t// react-aria indexes against when it moves focus off a closing toast.\n\tflexDirection: \"column-reverse\",\n\talignItems: \"center\",\n\tgap: t(\"gap-16\"),\n});\n\n// Typed as a plain string for the reason the banner's slide is: `t()` returns a\n// union of every token name, and a multi-property template literal over it\n// explodes past what tsc can represent.\nconst cardTransition: string = `opacity ${t(\"duration-medium\")} ${t(\n\t\"easing-standard\",\n)}, transform ${t(\"duration-medium\")} ${t(\"easing-standard\")}`;\n\nexport const toastCard = style({\n\toutline: \"none\",\n\tpointerEvents: \"auto\",\n\t// Sized against elevation/3's 24px blur: the stack sits in a container the app\n\t// clips, so anything outside this inset is cut.\n\tpaddingInline: t(\"padding-16\"),\n\tselectors: {\n\t\t// Off-screen below the anchored edge: the state the card rises in from and\n\t\t// falls back out to. A transition, not a keyframe, and the same mechanism\n\t\t// as `bannerContainerSlide`. A transition interpolates from the current\n\t\t// computed value, so a card dismissed part-way through its entry reverses\n\t\t// from wherever it stands. A keyframe would restart the exit from its own\n\t\t// first frame and jump the card there first.\n\t\t\"&[data-entering]\": { opacity: 0, transform: \"translateY(100%)\" },\n\t\t// A leaving card must not take a click meant for the transcript under it.\n\t\t// The container sets `inert`, which drops pointer events, but WebKit added\n\t\t// `inert` in 15.5 and the floor in `messaging/vite.browser-targets.mjs` is\n\t\t// 15.4, so the card holds the pointer through its travel there without this.\n\t\t\"&[data-exiting]\": {\n\t\t\topacity: 0,\n\t\t\ttransform: \"translateY(100%)\",\n\t\t\tpointerEvents: \"none\",\n\t\t},\n\t},\n\t\"@media\": {\n\t\t// A reader who asked for no motion gets the end states with no travel to\n\t\t// them, so the card appears and clears with no transition.\n\t\t\"(prefers-reduced-motion: no-preference)\": {\n\t\t\ttransition: cardTransition,\n\t\t},\n\t},\n});\n\n// Keep the ring inside: an outside ring would meet transcript content beneath the floating card.\nglobalStyle(`${toastCard}[data-focus-visible] ${toast}`, {\n\toutline: `${t(\"border-width-focus\")} solid ${t(\"color-border-focus\")}`,\n\toutlineOffset: `calc(-2 * ${t(\"border-width-focus\")})`,\n});\n\nglobalStyle(`${toastCard}[data-focus-visible] ${toast}`, {\n\t\"@media\": {\n\t\t\"(forced-colors: active)\": {\n\t\t\toutline: \"2px solid Highlight\",\n\t\t\toutlineOffset: \"-2px\",\n\t\t},\n\t},\n});\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Toast.css.js","names":[],"sources":["../../../src/components/Toast/Toast.css.ts"],"sourcesContent":["import {\n\tcreateVar,\n\tfallbackVar,\n\tglobalStyle,\n\tstyle,\n} from \"@vanilla-extract/css\";\nimport { recipe } from \"@vanilla-extract/recipes\";\nimport { t } from \"../../tokens/index.js\";\n\n/**\n * The card's border colour, set on the element each theme is declared on.\n *\n * Dark resolves `border-default` and `background-tertiary` to the same\n * neutral-700, so the border paints nothing there. `border-medium` is what\n * separates the card from the canvas: the fill alone is 1.7:1 against\n * `background-default`, the border 3.4:1, which is the 3:1 that non-text\n * boundaries need.\n *\n * It rides the theme element rather than a `[data-theme=\"dark\"] &` descendant\n * selector, which matches any dark ancestor rather than the nearest one. A light\n * provider inside a dark page would take the dark border. The tokens themselves\n * are declared the same way, so the nearest provider wins by inheritance.\n */\nconst cardBorderColor = createVar();\n\nglobalStyle('[data-theme=\"light\"]', {\n\tvars: { [cardBorderColor]: t(\"color-border-default\") },\n});\n\nglobalStyle('[data-theme=\"dark\"]', {\n\tvars: { [cardBorderColor]: t(\"color-border-medium\") },\n});\n\n// Hugs its content rather than filling the row, which is what separates it from\n// the banner surface: a card that floats over the transcript, not a strip that\n// belongs to it. `toastList` below centres it.\nexport const toast = style({\n\tdisplay: \"flex\",\n\talignItems: \"center\",\n\tjustifyContent: \"flex-start\",\n\tboxSizing: \"border-box\",\n\t// Sized to its own content, the way Figma draws it — the five variants range\n\t// 157-222px wide. Without this the card is a block-level div and fills\n\t// whatever holds it, which is the banner surface's shape, not this one.\n\t// Capped so long copy wraps inside the chat window instead of overflowing it.\n\twidth: \"fit-content\",\n\tmaxWidth: \"100%\",\n\tgap: t(\"gap-8\"),\n\tpaddingInline: t(\"padding-12\"),\n\tpaddingBlock: t(\"padding-8\"),\n\tborderRadius: t(\"border-radius-10\"),\n\tborderWidth: t(\"border-width-default\"),\n\tborderStyle: \"solid\",\n\tborderColor: fallbackVar(cardBorderColor, t(\"color-border-default\")),\n\tbackgroundColor: t(\"color-background-tertiary\"),\n\tboxShadow: t(\"elevation-3\"),\n\t\"@media\": {\n\t\t// The shadow is what lifts the card off the transcript, and forced colors\n\t\t// drops it — so the border has to carry the boundary on its own.\n\t\t\"(forced-colors: active)\": { borderColor: \"CanvasText\" },\n\t},\n});\n\nexport const toastIcon = recipe({\n\tbase: {\n\t\tdisplay: \"flex\",\n\t\talignItems: \"center\",\n\t\tjustifyContent: \"center\",\n\t\tflexShrink: 0,\n\t\tlineHeight: 0,\n\t},\n\t// Only the glyph changes between statuses — the card paints identically for\n\t// all five, so there is no variant axis on the card itself.\n\tvariants: {\n\t\tstatus: {\n\t\t\tsuccess: {\n\t\t\t\tcolor: t(\"color-content-success\"),\n\t\t\t\tfontSize: t(\"icon-size-control\"),\n\t\t\t},\n\t\t\twarning: {\n\t\t\t\tcolor: t(\"color-content-warning\"),\n\t\t\t\tfontSize: t(\"icon-size-control\"),\n\t\t\t},\n\t\t\terror: {\n\t\t\t\tcolor: t(\"color-content-destructive\"),\n\t\t\t\tfontSize: t(\"icon-size-control\"),\n\t\t\t},\n\t\t\tcustom: {\n\t\t\t\tcolor: t(\"color-content-secondary\"),\n\t\t\t\tfontSize: t(\"icon-size-lg\"),\n\t\t\t},\n\t\t\t// Figma sizes this slot off line-height/title-small (24px). Spinner ships\n\t\t\t// 16px and 32px with per-size border widths, so the 16px one is centred\n\t\t\t// in a 24px box rather than scaled to a size it was not drawn for.\n\t\t\tloading: {\n\t\t\t\twidth: t(\"icon-size-lg\"),\n\t\t\t\theight: t(\"icon-size-lg\"),\n\t\t\t},\n\t\t},\n\t},\n\tdefaultVariants: { status: \"success\" },\n});\n\nexport const toastMessage = style({\n\tminWidth: 0,\n\tmarginInlineEnd: \"auto\",\n\t// The glyph carries the status, so the copy stays at the default content\n\t// colour rather than tinting with it — unlike the banner surface, where the\n\t// tinted background sets the whole card's tone.\n\tcolor: t(\"color-content-default\"),\n\tfontFamily: t(\"font-family-body\"),\n\tfontWeight: t(\"font-weight-medium\"),\n\tfontSize: t(\"font-size-body\"),\n\tlineHeight: t(\"line-height-body\"),\n\toverflowWrap: \"break-word\",\n});\n\n// IconButton's tertiary intent paints content-default; Figma wants the dismiss\n// glyph quieter. Its state layer is currentColor, so it follows automatically.\nexport const toastDismiss = style({\n\tflexShrink: 0,\n\tcolor: t(\"color-content-secondary\"),\n});\n\nglobalStyle(`${toast} > [data-slot='button'] [data-slot='icon']`, {\n\tfontSize: t(\"icon-size-sm\"),\n});\n\n// Matches the banner surface: the control is taken away only while the card is\n// leaving, which is not a state the reader should read as unavailable.\nglobalStyle(`${toast} > [data-slot='button'][data-disabled]`, {\n\t// Restated rather than inherited: this selector outranks `toastDismiss`, and\n\t// the card sets no colour of its own for `inherit` to land on.\n\tcolor: t(\"color-content-secondary\"),\n\tcursor: \"inherit\",\n});\n\n/**\n * The always-mounted anchor the region portals into. It spans the width its\n * consumer gives it while the cards only hug their content, so it passes the\n * pointer through and each card takes it back.\n */\nexport const toastAnchor = style({\n\tpointerEvents: \"none\",\n});\n\n/**\n * Hides the announcer's live regions from view but keeps them a real box.\n * WebKit before 16 drops an element with `display: contents` from the\n * accessibility tree, and a region outside that tree is never spoken.\n */\nexport const toastAnnouncer = style({\n\tposition: \"absolute\",\n\twidth: 1,\n\theight: 1,\n\tpadding: 0,\n\tmargin: -1,\n\toverflow: \"hidden\",\n\tclip: \"rect(0, 0, 0, 0)\",\n\tclipPath: \"inset(50%)\",\n\twhiteSpace: \"nowrap\",\n\tborder: 0,\n\tuserSelect: \"none\",\n\tWebkitUserSelect: \"none\",\n});\n\nexport const toastRegion = style({\n\toutline: \"none\",\n});\n\nexport const toastList = style({\n\tlistStyle: \"none\",\n\tmargin: 0,\n\tpadding: 0,\n\tdisplay: \"flex\",\n\t// The queue hands its toasts over newest first, and the newest belongs at the\n\t// bottom of the stack, nearest the composer. Reversing the column here rather\n\t// than reordering the list keeps the DOM order the queue's own, which is what\n\t// react-aria indexes against when it moves focus off a closing toast.\n\tflexDirection: \"column-reverse\",\n\talignItems: \"center\",\n\tgap: t(\"gap-16\"),\n});\n\n// Typed as a plain string for the reason the banner's slide is: `t()` returns a\n// union of every token name, and a multi-property template literal over it\n// explodes past what tsc can represent.\nconst cardTransition: string = `opacity ${t(\"duration-medium\")} ${t(\n\t\"easing-standard\",\n)}, transform ${t(\"duration-medium\")} ${t(\"easing-standard\")}`;\n\nexport const toastCard = style({\n\toutline: \"none\",\n\tpointerEvents: \"auto\",\n\t// Sized against elevation/3's 24px blur: the stack sits in a container the app\n\t// clips, so anything outside this inset is cut.\n\tpaddingInline: t(\"padding-16\"),\n\tselectors: {\n\t\t// Off-screen below the anchored edge: the state the card rises in from and\n\t\t// falls back out to. A transition, not a keyframe, and the same mechanism\n\t\t// as `bannerContainerSlide`. A transition interpolates from the current\n\t\t// computed value, so a card dismissed part-way through its entry reverses\n\t\t// from wherever it stands. A keyframe would restart the exit from its own\n\t\t// first frame and jump the card there first.\n\t\t\"&[data-entering]\": { opacity: 0, transform: \"translateY(100%)\" },\n\t\t// A leaving card must not take a click meant for the transcript under it.\n\t\t// The container sets `inert`, which drops pointer events, but WebKit added\n\t\t// `inert` in 15.5 and the floor in `messaging/vite.browser-targets.mjs` is\n\t\t// 15.4, so the card holds the pointer through its travel there without this.\n\t\t\"&[data-exiting]\": {\n\t\t\topacity: 0,\n\t\t\ttransform: \"translateY(100%)\",\n\t\t\tpointerEvents: \"none\",\n\t\t},\n\t},\n\t\"@media\": {\n\t\t// A reader who asked for no motion gets the end states with no travel to\n\t\t// them, so the card appears and clears with no transition.\n\t\t\"(prefers-reduced-motion: no-preference)\": {\n\t\t\ttransition: cardTransition,\n\t\t},\n\t},\n});\n\n// Keep the ring inside: an outside ring would meet transcript content beneath the floating card.\nglobalStyle(`${toastCard}[data-focus-visible] ${toast}`, {\n\toutline: `${t(\"border-width-focus\")} solid ${t(\"color-border-focus\")}`,\n\toutlineOffset: `calc(-2 * ${t(\"border-width-focus\")})`,\n});\n\nglobalStyle(`${toastCard}[data-focus-visible] ${toast}`, {\n\t\"@media\": {\n\t\t\"(forced-colors: active)\": {\n\t\t\toutline: \"2px solid Highlight\",\n\t\t\toutlineOffset: \"-2px\",\n\t\t},\n\t},\n});\n"],"mappings":""}
|
|
@@ -28,9 +28,8 @@ export interface ToastProps {
|
|
|
28
28
|
*/
|
|
29
29
|
dismissDisabled?: boolean;
|
|
30
30
|
/**
|
|
31
|
-
* Attributes for the message element. A container that
|
|
32
|
-
*
|
|
33
|
-
* outside what gets announced.
|
|
31
|
+
* Attributes for the message element. A container passes the id that names
|
|
32
|
+
* the card through here.
|
|
34
33
|
*/
|
|
35
34
|
messageProps?: HTMLAttributes<HTMLElement>;
|
|
36
35
|
className?: string;
|