@ada-cx/lovelace 1.18.3 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AttachmentChip/AttachmentChip.css.js.map +1 -1
- package/dist/components/Button/Button.css.js.map +1 -1
- package/dist/components/Card/Card.css.d.ts +8 -0
- package/dist/components/Card/Card.css.js +7 -0
- package/dist/components/Card/Card.css.js.map +1 -0
- package/dist/components/Card/Card.d.ts +14 -0
- package/dist/components/Card/Card.js +18 -0
- package/dist/components/Card/Card.js.map +1 -0
- package/dist/components/Card/CardActions.d.ts +7 -0
- package/dist/components/Card/CardActions.js +14 -0
- package/dist/components/Card/CardActions.js.map +1 -0
- package/dist/components/Card/CardBody.d.ts +7 -0
- package/dist/components/Card/CardBody.js +14 -0
- package/dist/components/Card/CardBody.js.map +1 -0
- package/dist/components/Card/CardDescription.d.ts +9 -0
- package/dist/components/Card/CardDescription.js +15 -0
- package/dist/components/Card/CardDescription.js.map +1 -0
- package/dist/components/Card/CardMedia.d.ts +17 -0
- package/dist/components/Card/CardMedia.js +23 -0
- package/dist/components/Card/CardMedia.js.map +1 -0
- package/dist/components/Card/CardRoot.d.ts +22 -0
- package/dist/components/Card/CardRoot.js +25 -0
- package/dist/components/Card/CardRoot.js.map +1 -0
- package/dist/components/Card/CardTitle.d.ts +9 -0
- package/dist/components/Card/CardTitle.js +15 -0
- package/dist/components/Card/CardTitle.js.map +1 -0
- package/dist/components/Card/index.d.ts +6 -0
- package/dist/components/Carousel/Carousel.css.d.ts +6 -0
- package/dist/components/Carousel/Carousel.css.js +7 -0
- package/dist/components/Carousel/Carousel.css.js.map +1 -0
- package/dist/components/Carousel/Carousel.d.ts +19 -0
- package/dist/components/Carousel/Carousel.js +141 -0
- package/dist/components/Carousel/Carousel.js.map +1 -0
- package/dist/components/Carousel/CarouselItem.d.ts +8 -0
- package/dist/components/Carousel/CarouselItem.js +14 -0
- package/dist/components/Carousel/CarouselItem.js.map +1 -0
- package/dist/components/Carousel/index.d.ts +2 -0
- package/dist/components/Checkbox/Checkbox.css.js.map +1 -1
- package/dist/components/Chip/Chip.css.js.map +1 -1
- package/dist/components/IconButton/IconButton.css.js.map +1 -1
- package/dist/components/Input/Input.css.js.map +1 -1
- package/dist/components/Link/Link.css.js.map +1 -1
- package/dist/components/MessageError/MessageError.css.js.map +1 -1
- package/dist/components/PillButton/PillButton.css.js.map +1 -1
- package/dist/components/Radio/Radio.css.js.map +1 -1
- package/dist/components/ScrollMarker/ScrollMarker.css.js.map +1 -1
- package/dist/components/Toast/Toast.css.js.map +1 -1
- package/dist/components/Toggle/Toggle.css.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +46 -43
- package/dist/style.css +1 -1
- package/dist/styles/focus-ring.d.ts +14 -0
- package/dist/tokens.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentChip.css.js","names":[],"sources":["../../../src/components/AttachmentChip/AttachmentChip.css.ts"],"sourcesContent":["import type { ComplexStyleRule } from \"@vanilla-extract/css\";\nimport { globalStyle, style } from \"@vanilla-extract/css\";\nimport type { RuntimeFn } from \"@vanilla-extract/recipes\";\nimport { recipe } from \"@vanilla-extract/recipes\";\nimport { typography } from \"../../styles/typography.js\";\nimport { t } from \"../../tokens/index.js\";\n\nconst attachmentChipBase = style({});\n\n/**\n * Figma pins each chip's frame height, the way it pins other control heights —\n * literals, with no size tier to route them through. The file chip is 40px: its\n * 24px thumbnail plus the 8px padding leaves nothing to trim. The summary chip\n * carries a 22px icon instead, and the composer draws it at 36px.\n */\nconst FILE_CHIP_HEIGHT = \"40px\";\nconst SUMMARY_CHIP_HEIGHT = \"36px\";\n\n/**\n * The cap the filename ellipsises against. Figma pins it on the file chip only;\n * the summary sizes to its own label, so a count is never clipped.\n */\nconst FILE_CHIP_MAX_WIDTH = \"148px\";\n\n/**\n * Annotated `string` deliberately: `t()` returns a template-literal type per\n * token, and four of them concatenated exceed what tsc will represent\n * (TS2590).\n */\nconst CHIP_SHADOW: string = `0 ${t(\"elevation-2-offset-y\")} ${t(\"elevation-2-blur\")} ${t(\"elevation-2-spread\")} ${t(\"elevation-2-color\")}`;\n\nexport const attachmentChipRoot: RuntimeFn<{\n\tinteractive: Record<\"true\" | \"false\", ComplexStyleRule>;\n}> = recipe({\n\tbase: [\n\t\tattachmentChipBase,\n\t\t{\n\t\t\tdisplay: \"flex\",\n\t\t\talignItems: \"center\",\n\t\t\tboxSizing: \"border-box\",\n\t\t\tgap: t(\"gap-8\"),\n\t\t\tminWidth: 0,\n\t\t\tpadding: t(\"padding-8\"),\n\t\t\toverflow: \"hidden\",\n\t\t\tborderRadius: t(\"border-radius-6\"),\n\t\t\tborder: 0,\n\t\t\tbackgroundColor: t(\"color-background-quaternary\"),\n\t\t\tcolor: t(\"color-content-default\"),\n\t\t\t...typography(\"body\", \"regular\"),\n\t\t\ttextAlign: \"start\",\n\t\t\tappearance: \"none\",\n\t\t\tboxShadow: CHIP_SHADOW,\n\t\t},\n\t],\n\tvariants: {\n\t\t/**\n\t\t * Off, the chip is a plain container whose trailing button is the only\n\t\t * control — Figma's file chip, capped so a long filename ellipsises. On,\n\t\t * the chip itself is the control — Figma's summary chip, which has no\n\t\t * trailing button, sizes to its label, and so takes the shared state\n\t\t * layer.\n\t\t */\n\t\tinteractive: {\n\t\t\ttrue: {\n\t\t\t\theight: SUMMARY_CHIP_HEIGHT,\n\t\t\t\tposition: \"relative\",\n\t\t\t\tisolation: \"isolate\",\n\t\t\t\tcursor: \"pointer\",\n\t\t\t\toutline: \"none\",\n\t\t\t\t\"::after\": {\n\t\t\t\t\tcontent: '\"\"',\n\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\tinset: 0,\n\t\t\t\t\tborderRadius: \"inherit\",\n\t\t\t\t\tbackgroundColor: \"currentColor\",\n\t\t\t\t\topacity: 0,\n\t\t\t\t\tpointerEvents: \"none\",\n\t\t\t\t\tzIndex: -1,\n\t\t\t\t\ttransition: `opacity ${t(\"duration-fast\")} ${t(\"easing-standard\")}`,\n\t\t\t\t},\n\t\t\t\tselectors: {\n\t\t\t\t\t\"&[data-hovered]::after\": { opacity: t(\"opacity-state-hover\") },\n\t\t\t\t\t\"&[data-focus-visible]::after\": { opacity: t(\"opacity-state-focus\") },\n\t\t\t\t\t\"&[data-pressed]::after\": { opacity: t(\"opacity-state-pressed\") },\n\t\t\t\t\t\"&[data-focus-visible]\":
|
|
1
|
+
{"version":3,"file":"AttachmentChip.css.js","names":[],"sources":["../../../src/components/AttachmentChip/AttachmentChip.css.ts"],"sourcesContent":["import type { ComplexStyleRule } from \"@vanilla-extract/css\";\nimport { globalStyle, style } from \"@vanilla-extract/css\";\nimport type { RuntimeFn } from \"@vanilla-extract/recipes\";\nimport { recipe } from \"@vanilla-extract/recipes\";\nimport { focusRing } from \"../../styles/focus-ring.js\";\nimport { typography } from \"../../styles/typography.js\";\nimport { t } from \"../../tokens/index.js\";\n\nconst attachmentChipBase = style({});\n\n/**\n * Figma pins each chip's frame height, the way it pins other control heights —\n * literals, with no size tier to route them through. The file chip is 40px: its\n * 24px thumbnail plus the 8px padding leaves nothing to trim. The summary chip\n * carries a 22px icon instead, and the composer draws it at 36px.\n */\nconst FILE_CHIP_HEIGHT = \"40px\";\nconst SUMMARY_CHIP_HEIGHT = \"36px\";\n\n/**\n * The cap the filename ellipsises against. Figma pins it on the file chip only;\n * the summary sizes to its own label, so a count is never clipped.\n */\nconst FILE_CHIP_MAX_WIDTH = \"148px\";\n\n/**\n * Annotated `string` deliberately: `t()` returns a template-literal type per\n * token, and four of them concatenated exceed what tsc will represent\n * (TS2590).\n */\nconst CHIP_SHADOW: string = `0 ${t(\"elevation-2-offset-y\")} ${t(\"elevation-2-blur\")} ${t(\"elevation-2-spread\")} ${t(\"elevation-2-color\")}`;\n\nexport const attachmentChipRoot: RuntimeFn<{\n\tinteractive: Record<\"true\" | \"false\", ComplexStyleRule>;\n}> = recipe({\n\tbase: [\n\t\tattachmentChipBase,\n\t\t{\n\t\t\tdisplay: \"flex\",\n\t\t\talignItems: \"center\",\n\t\t\tboxSizing: \"border-box\",\n\t\t\tgap: t(\"gap-8\"),\n\t\t\tminWidth: 0,\n\t\t\tpadding: t(\"padding-8\"),\n\t\t\toverflow: \"hidden\",\n\t\t\tborderRadius: t(\"border-radius-6\"),\n\t\t\tborder: 0,\n\t\t\tbackgroundColor: t(\"color-background-quaternary\"),\n\t\t\tcolor: t(\"color-content-default\"),\n\t\t\t...typography(\"body\", \"regular\"),\n\t\t\ttextAlign: \"start\",\n\t\t\tappearance: \"none\",\n\t\t\tboxShadow: CHIP_SHADOW,\n\t\t},\n\t],\n\tvariants: {\n\t\t/**\n\t\t * Off, the chip is a plain container whose trailing button is the only\n\t\t * control — Figma's file chip, capped so a long filename ellipsises. On,\n\t\t * the chip itself is the control — Figma's summary chip, which has no\n\t\t * trailing button, sizes to its label, and so takes the shared state\n\t\t * layer.\n\t\t */\n\t\tinteractive: {\n\t\t\ttrue: {\n\t\t\t\theight: SUMMARY_CHIP_HEIGHT,\n\t\t\t\tposition: \"relative\",\n\t\t\t\tisolation: \"isolate\",\n\t\t\t\tcursor: \"pointer\",\n\t\t\t\toutline: \"none\",\n\t\t\t\t\"::after\": {\n\t\t\t\t\tcontent: '\"\"',\n\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\tinset: 0,\n\t\t\t\t\tborderRadius: \"inherit\",\n\t\t\t\t\tbackgroundColor: \"currentColor\",\n\t\t\t\t\topacity: 0,\n\t\t\t\t\tpointerEvents: \"none\",\n\t\t\t\t\tzIndex: -1,\n\t\t\t\t\ttransition: `opacity ${t(\"duration-fast\")} ${t(\"easing-standard\")}`,\n\t\t\t\t},\n\t\t\t\tselectors: {\n\t\t\t\t\t\"&[data-hovered]::after\": { opacity: t(\"opacity-state-hover\") },\n\t\t\t\t\t\"&[data-focus-visible]::after\": { opacity: t(\"opacity-state-focus\") },\n\t\t\t\t\t\"&[data-pressed]::after\": { opacity: t(\"opacity-state-pressed\") },\n\t\t\t\t\t\"&[data-focus-visible]\": focusRing,\n\t\t\t\t},\n\t\t\t\t\"@media\": {\n\t\t\t\t\t// A token-based ring is flattened away in High Contrast, so the\n\t\t\t\t\t// focus state needs a system colour to survive it.\n\t\t\t\t\t\"(forced-colors: active)\": {\n\t\t\t\t\t\tselectors: {\n\t\t\t\t\t\t\t\"&[data-focus-visible]\": {\n\t\t\t\t\t\t\t\toutline: \"2px solid Highlight\",\n\t\t\t\t\t\t\t\toutlineOffset: \"2px\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tfalse: {\n\t\t\t\theight: FILE_CHIP_HEIGHT,\n\t\t\t\tmaxWidth: FILE_CHIP_MAX_WIDTH,\n\t\t\t},\n\t\t},\n\t},\n\tdefaultVariants: { interactive: false },\n});\n\n/**\n * Fixed box for the leading slot so a thumbnail, a spinner and an icon all\n * occupy the same 24px square — otherwise the chip's contents shift as an\n * upload settles and the stand-in gives way to the image.\n */\nexport const attachmentChipMedia = style({\n\tdisplay: \"inline-flex\",\n\talignItems: \"center\",\n\tjustifyContent: \"center\",\n\tflexShrink: 0,\n\twidth: \"24px\",\n\theight: \"24px\",\n\tborderRadius: t(\"border-radius-6\"),\n\toverflow: \"hidden\",\n});\n\n/**\n * A thumbnail fills the box; an icon sits at 22px inside it, as Figma draws\n * it — and on the chip's own background, with no backing of its own.\n */\nglobalStyle(`${attachmentChipMedia} [data-slot=\"icon\"]`, {\n\tfontSize: t(\"icon-size-control\"),\n});\n\nexport const attachmentChipThumbnail = style({\n\twidth: \"100%\",\n\theight: \"100%\",\n\tobjectFit: \"cover\",\n});\n\nexport const attachmentChipLabel = style({\n\tminWidth: 0,\n\toverflow: \"hidden\",\n\ttextOverflow: \"ellipsis\",\n\twhiteSpace: \"nowrap\",\n\twordBreak: \"break-word\",\n});\n"],"mappings":""}
|
|
@@ -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 { 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])\":
|
|
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":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const cardRoot: string;
|
|
2
|
+
export declare const cardPressable: string;
|
|
3
|
+
export declare const cardMedia: string;
|
|
4
|
+
export declare const cardMediaImage: string;
|
|
5
|
+
export declare const cardBody: string;
|
|
6
|
+
export declare const cardTitle: string;
|
|
7
|
+
export declare const cardDescription: string;
|
|
8
|
+
export declare const cardActions: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
//#region src/components/Card/Card.css.ts
|
|
3
|
+
var e = "_10mu92g0", t = "_10mu92g1", n = "_10mu92g2", r = "_10mu92g3", i = "_10mu92g4", a = "_10mu92g5", o = "_10mu92g6", s = "_10mu92g7";
|
|
4
|
+
//#endregion
|
|
5
|
+
export { s as cardActions, i as cardBody, o as cardDescription, n as cardMedia, r as cardMediaImage, t as cardPressable, e as cardRoot, a as cardTitle };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=Card.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.css.js","names":[],"sources":["../../../src/components/Card/Card.css.ts"],"sourcesContent":["import { globalStyle, style } from \"@vanilla-extract/css\";\nimport { focusRing } from \"../../styles/focus-ring.js\";\nimport { typography } from \"../../styles/typography.js\";\nimport { t } from \"../../tokens/index.js\";\n\nexport const cardRoot = style({\n\tposition: \"relative\",\n\tisolation: \"isolate\",\n\tdisplay: \"flex\",\n\tflexDirection: \"column\",\n\tboxSizing: \"border-box\",\n\twidth: \"100%\",\n\tmargin: 0,\n\tpadding: 0,\n\toverflow: \"hidden\",\n\tborder: `${t(\"border-width-default\")} solid ${t(\"color-border-default\")}`,\n\tborderRadius: t(\"border-radius-message\"),\n\tbackgroundColor: t(\"color-background-default\"),\n\tcolor: t(\"color-content-default\"),\n\ttextAlign: \"start\",\n});\n\n// The pressable card is a RAC Button, so the browser's button styles are reset\n// and the shared state layer sits over the whole surface.\nexport const cardPressable = style({\n\tappearance: \"none\",\n\tfont: \"inherit\",\n\tcursor: \"pointer\",\n\toutline: \"none\",\n\t\"::after\": {\n\t\tcontent: '\"\"',\n\t\tposition: \"absolute\",\n\t\tinset: 0,\n\t\tborderRadius: \"inherit\",\n\t\tbackgroundColor: \"currentColor\",\n\t\topacity: 0,\n\t\tpointerEvents: \"none\",\n\t\tzIndex: -1,\n\t\ttransition: `opacity ${t(\"duration-fast\")} ${t(\"easing-standard\")}`,\n\t},\n\tselectors: {\n\t\t\"&[data-hovered]:not([data-disabled])::after\": {\n\t\t\topacity: t(\"opacity-state-hover\"),\n\t\t},\n\t\t\"&[data-focus-visible]:not([data-disabled])::after\": {\n\t\t\topacity: t(\"opacity-state-focus\"),\n\t\t},\n\t\t\"&[data-pressed]:not([data-disabled])::after\": {\n\t\t\topacity: t(\"opacity-state-pressed\"),\n\t\t},\n\t\t\"&[data-focus-visible]:not([data-disabled])\": focusRing,\n\t\t\"&[data-disabled]\": { cursor: \"default\" },\n\t},\n\t\"@media\": {\n\t\t\"(forced-colors: active)\": {\n\t\t\tselectors: {\n\t\t\t\t\"&[data-focus-visible]:not([data-disabled])\": {\n\t\t\t\t\toutline: \"2px solid Highlight\",\n\t\t\t\t\toutlineOffset: \"2px\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n});\n\nexport const cardMedia = style({\n\tdisplay: \"flex\",\n\talignItems: \"center\",\n\tjustifyContent: \"center\",\n\tflexShrink: 0,\n\twidth: \"100%\",\n\taspectRatio: \"16 / 9\",\n\toverflow: \"hidden\",\n\tbackgroundColor: t(\"color-background-tertiary\"),\n\tcolor: t(\"color-content-disabled\"),\n});\n\nexport const cardMediaImage = style({\n\tdisplay: \"block\",\n\twidth: \"100%\",\n\theight: \"100%\",\n\tobjectFit: \"cover\",\n});\n\nglobalStyle(`${cardMedia} [data-slot='icon']`, {\n\tfontSize: t(\"icon-size-lg\"),\n});\n\nexport const cardBody = style({\n\tdisplay: \"flex\",\n\tflexDirection: \"column\",\n\tgap: t(\"gap-4\"),\n\tminWidth: 0,\n\tpadding: t(\"padding-12\"),\n});\n\nexport const cardTitle = style({\n\t...typography(\"body\", \"semi-bold\"),\n\toverflow: \"hidden\",\n\ttextOverflow: \"ellipsis\",\n\twhiteSpace: \"nowrap\",\n});\n\nexport const cardDescription = style({\n\t...typography(\"caption\"),\n\tdisplay: \"-webkit-box\",\n\toverflow: \"hidden\",\n\toverflowWrap: \"anywhere\",\n\tWebkitBoxOrient: \"vertical\",\n\tWebkitLineClamp: 3,\n});\n\n// The body's bottom padding and this top padding make the design's 20px gap\n// between the text and the button. The auto margin keeps the button at the\n// bottom when a row of cards stretches to its tallest card.\nexport const cardActions = style({\n\tdisplay: \"flex\",\n\tflexDirection: \"column\",\n\tgap: t(\"gap-8\"),\n\tmarginTop: \"auto\",\n\tpadding: `${t(\"padding-8\")} ${t(\"padding-12\")} ${t(\"padding-12\")}`,\n});\n\nglobalStyle(`${cardActions} > [data-slot='button']`, {\n\twidth: \"100%\",\n});\n"],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CardActions } from "./CardActions.js";
|
|
2
|
+
import { CardBody } from "./CardBody.js";
|
|
3
|
+
import { CardDescription } from "./CardDescription.js";
|
|
4
|
+
import { CardMedia } from "./CardMedia.js";
|
|
5
|
+
import { CardRoot } from "./CardRoot.js";
|
|
6
|
+
import { CardTitle } from "./CardTitle.js";
|
|
7
|
+
export type { CardProps } from "./CardRoot.js";
|
|
8
|
+
export declare const Card: typeof CardRoot & {
|
|
9
|
+
Media: typeof CardMedia;
|
|
10
|
+
Body: typeof CardBody;
|
|
11
|
+
Title: typeof CardTitle;
|
|
12
|
+
Description: typeof CardDescription;
|
|
13
|
+
Actions: typeof CardActions;
|
|
14
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CardActions as e } from "./CardActions.js";
|
|
2
|
+
import { CardBody as t } from "./CardBody.js";
|
|
3
|
+
import { CardDescription as n } from "./CardDescription.js";
|
|
4
|
+
import { CardMedia as r } from "./CardMedia.js";
|
|
5
|
+
import { CardRoot as i } from "./CardRoot.js";
|
|
6
|
+
import { CardTitle as a } from "./CardTitle.js";
|
|
7
|
+
//#region src/components/Card/Card.tsx
|
|
8
|
+
var o = Object.assign(i, {
|
|
9
|
+
Media: r,
|
|
10
|
+
Body: t,
|
|
11
|
+
Title: a,
|
|
12
|
+
Description: n,
|
|
13
|
+
Actions: e
|
|
14
|
+
});
|
|
15
|
+
//#endregion
|
|
16
|
+
export { o as Card };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=Card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.js","names":[],"sources":["../../../src/components/Card/Card.tsx"],"sourcesContent":["import { CardActions } from \"./CardActions.js\";\nimport { CardBody } from \"./CardBody.js\";\nimport { CardDescription } from \"./CardDescription.js\";\nimport { CardMedia } from \"./CardMedia.js\";\nimport { CardRoot } from \"./CardRoot.js\";\nimport { CardTitle } from \"./CardTitle.js\";\n\nexport type { CardProps } from \"./CardRoot.js\";\n\nexport const Card = Object.assign(CardRoot, {\n\tMedia: CardMedia,\n\tBody: CardBody,\n\tTitle: CardTitle,\n\tDescription: CardDescription,\n\tActions: CardActions,\n});\n"],"mappings":";;;;;;;AASA,IAAa,IAAO,OAAO,OAAO,GAAU;CAC3C,OAAO;CACP,MAAM;CACN,OAAO;CACP,aAAa;CACb,SAAS;CACT,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface CardActionsProps {
|
|
3
|
+
/** Buttons, each stretched to the card's width. */
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function CardActions({ children, className }: CardActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { cx as e } from "../../utils/cx.js";
|
|
2
|
+
import { cardActions as t } from "./Card.css.js";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/Card/CardActions.tsx
|
|
5
|
+
function r({ children: r, className: i }) {
|
|
6
|
+
return /* @__PURE__ */ n("div", {
|
|
7
|
+
className: e(t, i),
|
|
8
|
+
children: r
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { r as CardActions };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=CardActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CardActions.js","names":[],"sources":["../../../src/components/Card/CardActions.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport { cardActions } from \"./Card.css.js\";\n\nexport interface CardActionsProps {\n\t/** Buttons, each stretched to the card's width. */\n\tchildren?: ReactNode;\n\tclassName?: string;\n}\n\nexport function CardActions({ children, className }: CardActionsProps) {\n\treturn <div className={cx(cardActions, className)}>{children}</div>;\n}\n"],"mappings":";;;;AAUA,SAAgB,EAAY,EAAE,aAAU,gBAA+B;AACtE,QAAO,kBAAC,OAAD;EAAK,WAAW,EAAG,GAAa,EAAU;EAAG;EAAe,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface CardBodyProps {
|
|
3
|
+
/** The `Card.Title` and `Card.Description`. */
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function CardBody({ children, className }: CardBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { cx as e } from "../../utils/cx.js";
|
|
2
|
+
import { cardBody as t } from "./Card.css.js";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/Card/CardBody.tsx
|
|
5
|
+
function r({ children: r, className: i }) {
|
|
6
|
+
return /* @__PURE__ */ n("div", {
|
|
7
|
+
className: e(t, i),
|
|
8
|
+
children: r
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { r as CardBody };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=CardBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CardBody.js","names":[],"sources":["../../../src/components/Card/CardBody.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport { cardBody } from \"./Card.css.js\";\n\nexport interface CardBodyProps {\n\t/** The `Card.Title` and `Card.Description`. */\n\tchildren?: ReactNode;\n\tclassName?: string;\n}\n\nexport function CardBody({ children, className }: CardBodyProps) {\n\treturn <div className={cx(cardBody, className)}>{children}</div>;\n}\n"],"mappings":";;;;AAUA,SAAgB,EAAS,EAAE,aAAU,gBAA4B;AAChE,QAAO,kBAAC,OAAD;EAAK,WAAW,EAAG,GAAU,EAAU;EAAG;EAAe,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface CardDescriptionProps {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
/** Lets the card's button describe itself with the description. */
|
|
5
|
+
id?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Up to three lines. Longer text ends in an ellipsis. */
|
|
9
|
+
export declare function CardDescription({ children, id, className, }: CardDescriptionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { cx as e } from "../../utils/cx.js";
|
|
2
|
+
import { cardDescription as t } from "./Card.css.js";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/Card/CardDescription.tsx
|
|
5
|
+
function r({ children: r, id: i, className: a }) {
|
|
6
|
+
return /* @__PURE__ */ n("div", {
|
|
7
|
+
id: i,
|
|
8
|
+
className: e(t, a),
|
|
9
|
+
children: r
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { r as CardDescription };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=CardDescription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CardDescription.js","names":[],"sources":["../../../src/components/Card/CardDescription.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport { cardDescription } from \"./Card.css.js\";\n\nexport interface CardDescriptionProps {\n\tchildren?: ReactNode;\n\t/** Lets the card's button describe itself with the description. */\n\tid?: string;\n\tclassName?: string;\n}\n\n/** Up to three lines. Longer text ends in an ellipsis. */\nexport function CardDescription({\n\tchildren,\n\tid,\n\tclassName,\n}: CardDescriptionProps) {\n\treturn (\n\t\t<div id={id} className={cx(cardDescription, className)}>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;AAYA,SAAgB,EAAgB,EAC/B,aACA,OACA,gBACwB;AACxB,QACC,kBAAC,OAAD;EAAS;EAAI,WAAW,EAAG,GAAiB,EAAU;EACpD;EACI,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ImageLoadingStatus } from "../Image/index.js";
|
|
2
|
+
export interface CardMediaProps {
|
|
3
|
+
src: string | null | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Alt text. Pass `""` when the card's title already says what the image
|
|
6
|
+
* shows, so a screen reader does not read it twice.
|
|
7
|
+
*/
|
|
8
|
+
alt: string;
|
|
9
|
+
onLoadingStatusChange?: (status: ImageLoadingStatus) => void;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The card's image at 16:9, cropped to fill. A missing or failed image shows a
|
|
14
|
+
* muted media-slash box. The box is decorative, so the card's name stays its
|
|
15
|
+
* text.
|
|
16
|
+
*/
|
|
17
|
+
export declare function CardMedia({ src, alt, onLoadingStatusChange, className, }: CardMediaProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { cx as e } from "../../utils/cx.js";
|
|
2
|
+
import { MediaSlash as t } from "../Icon/icons/MediaSlash.js";
|
|
3
|
+
import { cardMedia as n, cardMediaImage as r } from "./Card.css.js";
|
|
4
|
+
import { Image as i } from "../Image/Image.js";
|
|
5
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/Card/CardMedia.tsx
|
|
7
|
+
function o({ src: o, alt: s, onLoadingStatusChange: c, className: l }) {
|
|
8
|
+
let u = /* @__PURE__ */ a(t, { "data-testid": "card-media-placeholder" });
|
|
9
|
+
return /* @__PURE__ */ a("div", {
|
|
10
|
+
className: e(n, l),
|
|
11
|
+
children: /* @__PURE__ */ a(i, {
|
|
12
|
+
className: r,
|
|
13
|
+
src: o,
|
|
14
|
+
alt: s,
|
|
15
|
+
fallback: u,
|
|
16
|
+
onLoadingStatusChange: c
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { o as CardMedia };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=CardMedia.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CardMedia.js","names":[],"sources":["../../../src/components/Card/CardMedia.tsx"],"sourcesContent":["import { 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 { cardMedia, cardMediaImage } from \"./Card.css.js\";\n\nexport interface CardMediaProps {\n\tsrc: string | null | undefined;\n\t/**\n\t * Alt text. Pass `\"\"` when the card's title already says what the image\n\t * shows, so a screen reader does not read it twice.\n\t */\n\talt: string;\n\tonLoadingStatusChange?: (status: ImageLoadingStatus) => void;\n\tclassName?: string;\n}\n\n/**\n * The card's image at 16:9, cropped to fill. A missing or failed image shows a\n * muted media-slash box. The box is decorative, so the card's name stays its\n * text.\n */\nexport function CardMedia({\n\tsrc,\n\talt,\n\tonLoadingStatusChange,\n\tclassName,\n}: CardMediaProps) {\n\tconst placeholder = <MediaSlash data-testid=\"card-media-placeholder\" />;\n\n\treturn (\n\t\t<div className={cx(cardMedia, className)}>\n\t\t\t<Image\n\t\t\t\tclassName={cardMediaImage}\n\t\t\t\tsrc={src}\n\t\t\t\talt={alt}\n\t\t\t\tfallback={placeholder}\n\t\t\t\tonLoadingStatusChange={onLoadingStatusChange}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;AAsBA,SAAgB,EAAU,EACzB,QACA,QACA,0BACA,gBACkB;CAClB,IAAM,IAAc,kBAAC,GAAD,EAAY,eAAY,0BAA2B,CAAA;AAEvE,QACC,kBAAC,OAAD;EAAK,WAAW,EAAG,GAAW,EAAU;YACvC,kBAAC,GAAD;GACC,WAAW;GACN;GACA;GACL,UAAU;GACa;GACtB,CAAA;EACG,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode, Ref } from "react";
|
|
2
|
+
export interface CardProps {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
/**
|
|
5
|
+
* Makes the whole card one button. Leave it out when the card holds its
|
|
6
|
+
* own buttons in `Card.Actions`: a button inside a button is invalid.
|
|
7
|
+
*/
|
|
8
|
+
onPress?: () => void;
|
|
9
|
+
/** Disables the pressable card. Has no effect without `onPress`. */
|
|
10
|
+
isDisabled?: boolean;
|
|
11
|
+
"aria-label"?: string;
|
|
12
|
+
"aria-labelledby"?: string;
|
|
13
|
+
"aria-describedby"?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
style?: CSSProperties;
|
|
16
|
+
ref?: Ref<HTMLElement>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A surface with an optional image, a title, a description and actions. With
|
|
20
|
+
* `onPress`, the whole card is the button and its text is the button's name.
|
|
21
|
+
*/
|
|
22
|
+
export declare function CardRoot({ children, onPress, isDisabled, className, ref, ...rest }: CardProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { cx as e } from "../../utils/cx.js";
|
|
2
|
+
import { cardPressable as t, cardRoot as n } from "./Card.css.js";
|
|
3
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
4
|
+
import { Button as i } from "react-aria-components";
|
|
5
|
+
//#region src/components/Card/CardRoot.tsx
|
|
6
|
+
function a({ children: a, onPress: o, isDisabled: s, className: c, ref: l, ...u }) {
|
|
7
|
+
return o ? /* @__PURE__ */ r(i, {
|
|
8
|
+
...u,
|
|
9
|
+
ref: l,
|
|
10
|
+
"data-pressable": "true",
|
|
11
|
+
isDisabled: s,
|
|
12
|
+
onPress: o,
|
|
13
|
+
className: e(n, t, c),
|
|
14
|
+
children: a
|
|
15
|
+
}) : /* @__PURE__ */ r("div", {
|
|
16
|
+
...u,
|
|
17
|
+
ref: l,
|
|
18
|
+
className: e(n, c),
|
|
19
|
+
children: a
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { a as CardRoot };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=CardRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CardRoot.js","names":[],"sources":["../../../src/components/Card/CardRoot.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode, Ref } from \"react\";\nimport { Button as AriaButton } from \"react-aria-components\";\nimport { cx } from \"../../utils/cx.js\";\nimport { cardPressable, cardRoot } from \"./Card.css.js\";\n\nexport interface CardProps {\n\tchildren?: ReactNode;\n\t/**\n\t * Makes the whole card one button. Leave it out when the card holds its\n\t * own buttons in `Card.Actions`: a button inside a button is invalid.\n\t */\n\tonPress?: () => void;\n\t/** Disables the pressable card. Has no effect without `onPress`. */\n\tisDisabled?: boolean;\n\t\"aria-label\"?: string;\n\t\"aria-labelledby\"?: string;\n\t\"aria-describedby\"?: string;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n\tref?: Ref<HTMLElement>;\n}\n\n/**\n * A surface with an optional image, a title, a description and actions. With\n * `onPress`, the whole card is the button and its text is the button's name.\n */\nexport function CardRoot({\n\tchildren,\n\tonPress,\n\tisDisabled,\n\tclassName,\n\tref,\n\t...rest\n}: CardProps) {\n\tif (onPress) {\n\t\treturn (\n\t\t\t<AriaButton\n\t\t\t\t{...rest}\n\t\t\t\tref={ref as Ref<HTMLButtonElement>}\n\t\t\t\tdata-pressable=\"true\"\n\t\t\t\tisDisabled={isDisabled}\n\t\t\t\tonPress={onPress}\n\t\t\t\tclassName={cx(cardRoot, cardPressable, className)}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</AriaButton>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div\n\t\t\t{...rest}\n\t\t\tref={ref as Ref<HTMLDivElement>}\n\t\t\tclassName={cx(cardRoot, className)}\n\t\t>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;AA0BA,SAAgB,EAAS,EACxB,aACA,YACA,eACA,cACA,QACA,GAAG,KACU;AAgBb,QAfI,IAEF,kBAAC,GAAD;EACC,GAAI;EACC;EACL,kBAAe;EACH;EACH;EACT,WAAW,EAAG,GAAU,GAAe,EAAU;EAEhD;EACW,CAAA,GAKd,kBAAC,OAAD;EACC,GAAI;EACC;EACL,WAAW,EAAG,GAAU,EAAU;EAEjC;EACI,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface CardTitleProps {
|
|
3
|
+
children?: ReactNode;
|
|
4
|
+
/** Lets a button or the pressable card name itself with the title. */
|
|
5
|
+
id?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
/** One line. A longer title ends in an ellipsis. */
|
|
9
|
+
export declare function CardTitle({ children, id, className }: CardTitleProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { cx as e } from "../../utils/cx.js";
|
|
2
|
+
import { cardTitle as t } from "./Card.css.js";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/Card/CardTitle.tsx
|
|
5
|
+
function r({ children: r, id: i, className: a }) {
|
|
6
|
+
return /* @__PURE__ */ n("span", {
|
|
7
|
+
id: i,
|
|
8
|
+
className: e(t, a),
|
|
9
|
+
children: r
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { r as CardTitle };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=CardTitle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CardTitle.js","names":[],"sources":["../../../src/components/Card/CardTitle.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport { cardTitle } from \"./Card.css.js\";\n\nexport interface CardTitleProps {\n\tchildren?: ReactNode;\n\t/** Lets a button or the pressable card name itself with the title. */\n\tid?: string;\n\tclassName?: string;\n}\n\n/** One line. A longer title ends in an ellipsis. */\nexport function CardTitle({ children, id, className }: CardTitleProps) {\n\treturn (\n\t\t<span id={id} className={cx(cardTitle, className)}>\n\t\t\t{children}\n\t\t</span>\n\t);\n}\n"],"mappings":";;;;AAYA,SAAgB,EAAU,EAAE,aAAU,OAAI,gBAA6B;AACtE,QACC,kBAAC,QAAD;EAAU;EAAI,WAAW,EAAG,GAAW,EAAU;EAC/C;EACK,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Card, type CardProps } from "./Card.js";
|
|
2
|
+
export type { CardActionsProps } from "./CardActions.js";
|
|
3
|
+
export type { CardBodyProps } from "./CardBody.js";
|
|
4
|
+
export type { CardDescriptionProps } from "./CardDescription.js";
|
|
5
|
+
export type { CardMediaProps } from "./CardMedia.js";
|
|
6
|
+
export type { CardTitleProps } from "./CardTitle.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const carouselRoot: string;
|
|
2
|
+
export declare const carouselTrack: string;
|
|
3
|
+
export declare const carouselItem: string;
|
|
4
|
+
export declare const carouselFooter: string;
|
|
5
|
+
export declare const carouselCounter: string;
|
|
6
|
+
export declare const carouselCounterNumber: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
//#region src/components/Carousel/Carousel.css.ts
|
|
3
|
+
var e = "_1vler2p0", t = "_1vler2p1", n = "_1vler2p2", r = "_1vler2p3", i = "_1vler2p4", a = "_1vler2p5";
|
|
4
|
+
//#endregion
|
|
5
|
+
export { i as carouselCounter, a as carouselCounterNumber, r as carouselFooter, n as carouselItem, e as carouselRoot, t as carouselTrack };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=Carousel.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Carousel.css.js","names":[],"sources":["../../../src/components/Carousel/Carousel.css.ts"],"sourcesContent":["import { style } from \"@vanilla-extract/css\";\nimport { typography } from \"../../styles/typography.js\";\nimport { t } from \"../../tokens/index.js\";\n\nexport const carouselRoot = style({\n\tdisplay: \"flex\",\n\tflexDirection: \"column\",\n\talignItems: \"stretch\",\n\tgap: t(\"gap-20\"),\n\tminWidth: 0,\n});\n\n// The block padding keeps a focused card's ring inside the scroll box, which\n// would otherwise clip it.\nexport const carouselTrack = style({\n\tdisplay: \"flex\",\n\tgap: t(\"gap-12\"),\n\tpaddingBlock: t(\"padding-4\"),\n\tpaddingInline: t(\"padding-12\"),\n\tscrollPaddingInline: t(\"padding-12\"),\n\toverflowX: \"auto\",\n\toverflowY: \"hidden\",\n\tscrollSnapType: \"x mandatory\",\n\tscrollbarWidth: \"none\",\n\tselectors: {\n\t\t\"&::-webkit-scrollbar\": { display: \"none\" },\n\t},\n});\n\n// The design's card is 280px. On a narrow column the item shrinks so the\n// cards beside it still peek in. A middle card centres, so both neighbours\n// show; the first and last cards meet the edges, so no end is left empty.\nexport const carouselItem = style({\n\tdisplay: \"flex\",\n\tflex: \"0 0 min(280px, 80%)\",\n\tminWidth: 0,\n\tscrollSnapAlign: \"center\",\n\tselectors: {\n\t\t\"&:first-child\": { scrollSnapAlign: \"start\" },\n\t\t\"&:last-child\": { scrollSnapAlign: \"end\" },\n\t},\n});\n\nexport const carouselFooter = style({\n\tdisplay: \"flex\",\n\talignItems: \"center\",\n\tjustifyContent: \"center\",\n});\n\nexport const carouselCounter = style({\n\t...typography(\"caption\"),\n\tdisplay: \"flex\",\n\talignItems: \"center\",\n\tgap: t(\"gap-4\"),\n\tpaddingInline: t(\"padding-16\"),\n\tcolor: t(\"color-content-default\"),\n\tfontVariantNumeric: \"tabular-nums\",\n});\n\nexport const carouselCounterNumber = style({\n\tminWidth: \"24px\",\n\ttextAlign: \"center\",\n});\n"],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
+
export interface CarouselProps {
|
|
3
|
+
/** The slides, each a `CarouselItem`. */
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
/** Accessible name of the group of slides. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** Accessible name of the previous-slide button. */
|
|
8
|
+
previousLabel: string;
|
|
9
|
+
/** Accessible name of the next-slide button. */
|
|
10
|
+
nextLabel: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: CSSProperties;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A row of slides that scrolls sideways and snaps to each slide. When the
|
|
16
|
+
* slides overflow, a footer shows the previous and next buttons and the
|
|
17
|
+
* position as "1 / 3". Keyboard focus on a partly hidden slide scrolls it in.
|
|
18
|
+
*/
|
|
19
|
+
export declare function Carousel({ children, label, previousLabel, nextLabel, className, style, }: CarouselProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { cx as e } from "../../utils/cx.js";
|
|
2
|
+
import { ChevronLeft as t } from "../Icon/icons/ChevronLeft.js";
|
|
3
|
+
import { ChevronRight as n } from "../Icon/icons/ChevronRight.js";
|
|
4
|
+
import { readPrefersReducedMotion as r } from "../../hooks/usePrefersReducedMotion.js";
|
|
5
|
+
import { IconButton as i } from "../IconButton/IconButton.js";
|
|
6
|
+
import { carouselRoot as a, carouselTrack as o } from "./Carousel.css.js";
|
|
7
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
8
|
+
import { Group as l, useLocale as u } from "react-aria-components";
|
|
9
|
+
import { Children as d, useEffect as f, useRef as p, useState as m } from "react";
|
|
10
|
+
//#region src/components/Carousel/Carousel.tsx
|
|
11
|
+
function h(e) {
|
|
12
|
+
return Array.from(e.children);
|
|
13
|
+
}
|
|
14
|
+
function g(e, t, n, r, i) {
|
|
15
|
+
let a = e.getBoundingClientRect(), o = t.getBoundingClientRect(), s = getComputedStyle(e), c = Number.parseFloat(s.scrollPaddingInlineStart) || 0, l = Number.parseFloat(s.scrollPaddingInlineEnd) || 0, u = () => o.left - a.left - (i ? l : c), d = () => o.right - a.right + (i ? c : l);
|
|
16
|
+
return n === 0 ? i ? d() : u() : n === r - 1 ? i ? u() : d() : (o.left + o.right) / 2 - (a.left + a.right) / 2;
|
|
17
|
+
}
|
|
18
|
+
function _(e, t) {
|
|
19
|
+
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
20
|
+
return r.left >= n.left - 1 && r.right <= n.right + 1;
|
|
21
|
+
}
|
|
22
|
+
function v(e, t) {
|
|
23
|
+
let n = h(e), r = e.scrollWidth - e.clientWidth;
|
|
24
|
+
if (n.length > 0 && r > 0 && Math.abs(e.scrollLeft) >= r - 1) return n.length - 1;
|
|
25
|
+
let i = 0, a = Infinity;
|
|
26
|
+
return n.forEach((r, o) => {
|
|
27
|
+
let s = Math.abs(g(e, r, o, n.length, t));
|
|
28
|
+
s < a && (i = o, a = s);
|
|
29
|
+
}), i;
|
|
30
|
+
}
|
|
31
|
+
function y(e) {
|
|
32
|
+
return typeof CSS > "u" || typeof CSS.supports != "function" || !CSS.supports("selector(:focus-visible)") ? !0 : e.matches(":focus-visible");
|
|
33
|
+
}
|
|
34
|
+
var b = 600;
|
|
35
|
+
function x({ children: x, label: S, previousLabel: C, nextLabel: w, className: T, style: E }) {
|
|
36
|
+
let D = p(null), [O, k] = m(0), A = p(null), j = p(null), [M, N] = m(!1), { direction: P } = u(), F = P === "rtl", I = d.toArray(x).length, L = () => {
|
|
37
|
+
j.current !== null && (clearTimeout(j.current), j.current = null);
|
|
38
|
+
}, R = () => {
|
|
39
|
+
L(), A.current = null;
|
|
40
|
+
}, z = () => {
|
|
41
|
+
let e = D.current;
|
|
42
|
+
A.current !== null && (R(), e && k(v(e, F)));
|
|
43
|
+
}, B = () => {
|
|
44
|
+
L(), j.current = setTimeout(z, b);
|
|
45
|
+
}, V = p(z);
|
|
46
|
+
V.current = z, f(() => {
|
|
47
|
+
let e = D.current;
|
|
48
|
+
if (!e) return;
|
|
49
|
+
let t = () => V.current();
|
|
50
|
+
return e.addEventListener("scrollend", t), () => {
|
|
51
|
+
e.removeEventListener("scrollend", t), j.current !== null && clearTimeout(j.current);
|
|
52
|
+
};
|
|
53
|
+
}, []), f(() => {
|
|
54
|
+
let e = D.current;
|
|
55
|
+
if (!e) return;
|
|
56
|
+
let t = () => N(e.scrollWidth > e.clientWidth);
|
|
57
|
+
if (t(), typeof ResizeObserver > "u") return;
|
|
58
|
+
let n = new ResizeObserver(t);
|
|
59
|
+
n.observe(e);
|
|
60
|
+
for (let t of h(e)) n.observe(t);
|
|
61
|
+
return () => n.disconnect();
|
|
62
|
+
}, [I]);
|
|
63
|
+
let H = O > 0, U = O < I - 1, W = (e) => {
|
|
64
|
+
let t = D.current, n = t ? h(t)[e] : void 0;
|
|
65
|
+
if (!t || !n) return;
|
|
66
|
+
let i = t.scrollLeft + g(t, n, e, h(t).length, F);
|
|
67
|
+
typeof t.scrollTo == "function" ? t.scrollTo({
|
|
68
|
+
left: i,
|
|
69
|
+
behavior: r() ? "instant" : "smooth"
|
|
70
|
+
}) : t.scrollLeft = i, A.current = e, k(e);
|
|
71
|
+
};
|
|
72
|
+
return /* @__PURE__ */ c("div", {
|
|
73
|
+
className: e(a, T),
|
|
74
|
+
style: E,
|
|
75
|
+
children: [/* @__PURE__ */ s(l, {
|
|
76
|
+
ref: D,
|
|
77
|
+
"aria-label": S,
|
|
78
|
+
className: o,
|
|
79
|
+
onPointerDown: R,
|
|
80
|
+
onTouchStart: R,
|
|
81
|
+
onWheel: R,
|
|
82
|
+
onFocus: (e) => {
|
|
83
|
+
let t = e.currentTarget, n = h(t).findIndex((t) => t.contains(e.target)), r = h(t)[n];
|
|
84
|
+
r && y(e.target) && !_(t, r) && W(n);
|
|
85
|
+
},
|
|
86
|
+
onScroll: (e) => {
|
|
87
|
+
let t = v(e.currentTarget, F);
|
|
88
|
+
if (A.current !== null) {
|
|
89
|
+
t === A.current ? R() : B();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
k(t);
|
|
93
|
+
},
|
|
94
|
+
children: x
|
|
95
|
+
}), I > 1 && M && /* @__PURE__ */ c("div", {
|
|
96
|
+
className: "_1vler2p3",
|
|
97
|
+
children: [
|
|
98
|
+
/* @__PURE__ */ s(i, {
|
|
99
|
+
label: C,
|
|
100
|
+
variant: "tertiary",
|
|
101
|
+
size: "xs",
|
|
102
|
+
"aria-disabled": !H || void 0,
|
|
103
|
+
onPress: () => {
|
|
104
|
+
H && W(O - 1);
|
|
105
|
+
},
|
|
106
|
+
children: s(F ? n : t, {})
|
|
107
|
+
}),
|
|
108
|
+
/* @__PURE__ */ c("div", {
|
|
109
|
+
"aria-hidden": "true",
|
|
110
|
+
"data-testid": "carousel-position",
|
|
111
|
+
className: "_1vler2p4",
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ s("span", {
|
|
114
|
+
className: "_1vler2p5",
|
|
115
|
+
children: O + 1
|
|
116
|
+
}),
|
|
117
|
+
/* @__PURE__ */ s("span", { children: "/" }),
|
|
118
|
+
/* @__PURE__ */ s("span", {
|
|
119
|
+
className: "_1vler2p5",
|
|
120
|
+
children: I
|
|
121
|
+
})
|
|
122
|
+
]
|
|
123
|
+
}),
|
|
124
|
+
/* @__PURE__ */ s(i, {
|
|
125
|
+
label: w,
|
|
126
|
+
variant: "tertiary",
|
|
127
|
+
size: "xs",
|
|
128
|
+
"aria-disabled": !U || void 0,
|
|
129
|
+
onPress: () => {
|
|
130
|
+
U && W(O + 1);
|
|
131
|
+
},
|
|
132
|
+
children: s(F ? t : n, {})
|
|
133
|
+
})
|
|
134
|
+
]
|
|
135
|
+
})]
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
//#endregion
|
|
139
|
+
export { x as Carousel };
|
|
140
|
+
|
|
141
|
+
//# sourceMappingURL=Carousel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Carousel.js","names":[],"sources":["../../../src/components/Carousel/Carousel.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\nimport { Children, useEffect, useRef, useState } from \"react\";\nimport { Group, useLocale } from \"react-aria-components\";\nimport { readPrefersReducedMotion } from \"../../hooks/usePrefersReducedMotion.js\";\nimport { cx } from \"../../utils/cx.js\";\nimport { ChevronLeft } from \"../Icon/icons/ChevronLeft.js\";\nimport { ChevronRight } from \"../Icon/icons/ChevronRight.js\";\nimport { IconButton } from \"../IconButton/index.js\";\nimport {\n\tcarouselCounter,\n\tcarouselCounterNumber,\n\tcarouselFooter,\n\tcarouselRoot,\n\tcarouselTrack,\n} from \"./Carousel.css.js\";\n\nexport interface CarouselProps {\n\t/** The slides, each a `CarouselItem`. */\n\tchildren?: ReactNode;\n\t/** Accessible name of the group of slides. */\n\tlabel: string;\n\t/** Accessible name of the previous-slide button. */\n\tpreviousLabel: string;\n\t/** Accessible name of the next-slide button. */\n\tnextLabel: string;\n\tclassName?: string;\n\tstyle?: CSSProperties;\n}\n\nfunction itemsOf(track: HTMLElement): HTMLElement[] {\n\treturn Array.from(track.children) as HTMLElement[];\n}\n\n/** How far the track must scroll for `item` to sit where it snaps: the first\n * item at the start edge, the last at the end edge and any other in the\n * middle. Physical pixels, so it adds to `scrollLeft` in either direction. */\nfunction offsetToSnap(\n\ttrack: HTMLElement,\n\titem: HTMLElement,\n\tindex: number,\n\tcount: number,\n\tisRtl: boolean,\n): number {\n\tconst trackRect = track.getBoundingClientRect();\n\tconst itemRect = item.getBoundingClientRect();\n\tconst style = getComputedStyle(track);\n\tconst paddingStart = Number.parseFloat(style.scrollPaddingInlineStart) || 0;\n\tconst paddingEnd = Number.parseFloat(style.scrollPaddingInlineEnd) || 0;\n\tconst left = () =>\n\t\titemRect.left - trackRect.left - (isRtl ? paddingEnd : paddingStart);\n\tconst right = () =>\n\t\titemRect.right - trackRect.right + (isRtl ? paddingStart : paddingEnd);\n\n\tif (index === 0) {\n\t\treturn isRtl ? right() : left();\n\t}\n\tif (index === count - 1) {\n\t\treturn isRtl ? left() : right();\n\t}\n\treturn (\n\t\t(itemRect.left + itemRect.right) / 2 -\n\t\t(trackRect.left + trackRect.right) / 2\n\t);\n}\n\nfunction isFullyVisible(track: HTMLElement, item: HTMLElement): boolean {\n\tconst trackRect = track.getBoundingClientRect();\n\tconst itemRect = item.getBoundingClientRect();\n\treturn (\n\t\titemRect.left >= trackRect.left - 1 && itemRect.right <= trackRect.right + 1\n\t);\n}\n\nfunction currentIndexOf(track: HTMLElement, isRtl: boolean): number {\n\tconst items = itemsOf(track);\n\t// A track short enough that the last item meets the end edge before it is\n\t// the closest snap point still has to count the end of its range as the last\n\t// item.\n\tconst maxScroll = track.scrollWidth - track.clientWidth;\n\tif (\n\t\titems.length > 0 &&\n\t\tmaxScroll > 0 &&\n\t\tMath.abs(track.scrollLeft) >= maxScroll - 1\n\t) {\n\t\treturn items.length - 1;\n\t}\n\tlet closest = 0;\n\tlet closestDistance = Number.POSITIVE_INFINITY;\n\titems.forEach((item, index) => {\n\t\tconst distance = Math.abs(\n\t\t\toffsetToSnap(track, item, index, items.length, isRtl),\n\t\t);\n\t\tif (distance < closestDistance) {\n\t\t\tclosest = index;\n\t\t\tclosestDistance = distance;\n\t\t}\n\t});\n\treturn closest;\n}\n\n// React Aria focuses a pressable card on pointerdown. A scroll at that moment\n// moves the card from under the finger and cancels the press, so only keyboard\n// focus scrolls. Where `:focus-visible` is not supported, as in jsdom, every\n// focus scrolls.\nfunction isKeyboardFocus(element: Element): boolean {\n\tif (\n\t\ttypeof CSS === \"undefined\" ||\n\t\ttypeof CSS.supports !== \"function\" ||\n\t\t!CSS.supports(\"selector(:focus-visible)\")\n\t) {\n\t\treturn true;\n\t}\n\treturn element.matches(\":focus-visible\");\n}\n\n// Safari before 18.2 has no `scrollend`, so a quiet period after the last\n// scroll event also counts as the end of a button scroll.\nconst SCROLL_SETTLE_MS = 600;\n\n/**\n * A row of slides that scrolls sideways and snaps to each slide. When the\n * slides overflow, a footer shows the previous and next buttons and the\n * position as \"1 / 3\". Keyboard focus on a partly hidden slide scrolls it in.\n */\nexport function Carousel({\n\tchildren,\n\tlabel,\n\tpreviousLabel,\n\tnextLabel,\n\tclassName,\n\tstyle,\n}: CarouselProps) {\n\tconst trackRef = useRef<HTMLDivElement>(null);\n\tconst [currentIndex, setCurrentIndex] = useState(0);\n\t// A button scroll animates past the slides in between. Until it lands, the\n\t// track position names one of those as current, and a second press would\n\t// start from it instead of from the slide the first press asked for.\n\tconst targetIndexRef = useRef<number | null>(null);\n\tconst settleTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\tconst [overflows, setOverflows] = useState(false);\n\tconst { direction } = useLocale();\n\tconst isRtl = direction === \"rtl\";\n\tconst count = Children.toArray(children).length;\n\n\tconst clearSettleTimer = () => {\n\t\tif (settleTimerRef.current !== null) {\n\t\t\tclearTimeout(settleTimerRef.current);\n\t\t\tsettleTimerRef.current = null;\n\t\t}\n\t};\n\tconst releaseTarget = () => {\n\t\tclearSettleTimer();\n\t\ttargetIndexRef.current = null;\n\t};\n\t// The track cannot always align the target slide, for example when the\n\t// slides after it fit beside it. The scroll then stops short of the target,\n\t// so the lock ends with the scroll and the counter takes the real position.\n\tconst settleTarget = () => {\n\t\tconst track = trackRef.current;\n\t\tif (targetIndexRef.current === null) {\n\t\t\treturn;\n\t\t}\n\t\treleaseTarget();\n\t\tif (track) {\n\t\t\tsetCurrentIndex(currentIndexOf(track, isRtl));\n\t\t}\n\t};\n\tconst scheduleSettle = () => {\n\t\tclearSettleTimer();\n\t\tsettleTimerRef.current = setTimeout(settleTarget, SCROLL_SETTLE_MS);\n\t};\n\tconst settleTargetRef = useRef(settleTarget);\n\tsettleTargetRef.current = settleTarget;\n\n\tuseEffect(() => {\n\t\tconst track = trackRef.current;\n\t\tif (!track) {\n\t\t\treturn;\n\t\t}\n\t\tconst onScrollEnd = () => settleTargetRef.current();\n\t\ttrack.addEventListener(\"scrollend\", onScrollEnd);\n\t\treturn () => {\n\t\t\ttrack.removeEventListener(\"scrollend\", onScrollEnd);\n\t\t\tif (settleTimerRef.current !== null) {\n\t\t\t\tclearTimeout(settleTimerRef.current);\n\t\t\t}\n\t\t};\n\t}, []);\n\n\t// biome-ignore lint/correctness/useExhaustiveDependencies: count isn't read here, but a new set of slides must be measured again.\n\tuseEffect(() => {\n\t\tconst track = trackRef.current;\n\t\tif (!track) {\n\t\t\treturn;\n\t\t}\n\t\tconst measure = () => setOverflows(track.scrollWidth > track.clientWidth);\n\t\tmeasure();\n\t\t// Absent in jsdom, so the measurement above has to stand on its own.\n\t\tif (typeof ResizeObserver === \"undefined\") {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new ResizeObserver(measure);\n\t\tobserver.observe(track);\n\t\tfor (const item of itemsOf(track)) {\n\t\t\tobserver.observe(item);\n\t\t}\n\t\treturn () => observer.disconnect();\n\t}, [count]);\n\n\tconst hasPrevious = currentIndex > 0;\n\tconst hasNext = currentIndex < count - 1;\n\n\tconst scrollToItem = (index: number) => {\n\t\tconst track = trackRef.current;\n\t\tconst item = track ? itemsOf(track)[index] : undefined;\n\t\tif (!track || !item) {\n\t\t\treturn;\n\t\t}\n\t\tconst left =\n\t\t\ttrack.scrollLeft +\n\t\t\toffsetToSnap(track, item, index, itemsOf(track).length, isRtl);\n\t\tif (typeof track.scrollTo === \"function\") {\n\t\t\ttrack.scrollTo({\n\t\t\t\tleft,\n\t\t\t\tbehavior: readPrefersReducedMotion() ? \"instant\" : \"smooth\",\n\t\t\t});\n\t\t} else {\n\t\t\ttrack.scrollLeft = left;\n\t\t}\n\t\ttargetIndexRef.current = index;\n\t\tsetCurrentIndex(index);\n\t};\n\n\treturn (\n\t\t<div className={cx(carouselRoot, className)} style={style}>\n\t\t\t<Group\n\t\t\t\tref={trackRef}\n\t\t\t\taria-label={label}\n\t\t\t\tclassName={carouselTrack}\n\t\t\t\tonPointerDown={releaseTarget}\n\t\t\t\tonTouchStart={releaseTarget}\n\t\t\t\tonWheel={releaseTarget}\n\t\t\t\tonFocus={(event) => {\n\t\t\t\t\tconst track = event.currentTarget;\n\t\t\t\t\tconst index = itemsOf(track).findIndex((item) =>\n\t\t\t\t\t\titem.contains(event.target),\n\t\t\t\t\t);\n\t\t\t\t\tconst item = itemsOf(track)[index];\n\t\t\t\t\tif (\n\t\t\t\t\t\titem &&\n\t\t\t\t\t\tisKeyboardFocus(event.target) &&\n\t\t\t\t\t\t!isFullyVisible(track, item)\n\t\t\t\t\t) {\n\t\t\t\t\t\tscrollToItem(index);\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t\tonScroll={(event) => {\n\t\t\t\t\tconst index = currentIndexOf(event.currentTarget, isRtl);\n\t\t\t\t\tif (targetIndexRef.current !== null) {\n\t\t\t\t\t\tif (index === targetIndexRef.current) {\n\t\t\t\t\t\t\treleaseTarget();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tscheduleSettle();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tsetCurrentIndex(index);\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</Group>\n\t\t\t{count > 1 && overflows && (\n\t\t\t\t<div className={carouselFooter}>\n\t\t\t\t\t<IconButton\n\t\t\t\t\t\tlabel={previousLabel}\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tsize=\"xs\"\n\t\t\t\t\t\t// aria-disabled keeps the button focusable at the end, so focus\n\t\t\t\t\t\t// does not jump away after the last press.\n\t\t\t\t\t\taria-disabled={!hasPrevious || undefined}\n\t\t\t\t\t\tonPress={() => {\n\t\t\t\t\t\t\tif (hasPrevious) {\n\t\t\t\t\t\t\t\tscrollToItem(currentIndex - 1);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{isRtl ? <ChevronRight /> : <ChevronLeft />}\n\t\t\t\t\t</IconButton>\n\t\t\t\t\t<div\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tdata-testid=\"carousel-position\"\n\t\t\t\t\t\tclassName={carouselCounter}\n\t\t\t\t\t>\n\t\t\t\t\t\t<span className={carouselCounterNumber}>{currentIndex + 1}</span>\n\t\t\t\t\t\t<span>/</span>\n\t\t\t\t\t\t<span className={carouselCounterNumber}>{count}</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<IconButton\n\t\t\t\t\t\tlabel={nextLabel}\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tsize=\"xs\"\n\t\t\t\t\t\taria-disabled={!hasNext || undefined}\n\t\t\t\t\t\tonPress={() => {\n\t\t\t\t\t\t\tif (hasNext) {\n\t\t\t\t\t\t\t\tscrollToItem(currentIndex + 1);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{isRtl ? <ChevronLeft /> : <ChevronRight />}\n\t\t\t\t\t</IconButton>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface CarouselItemProps {
|
|
3
|
+
/** One slide, usually a `Card`. */
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
/** One slide. Each item snaps to the start of the track. */
|
|
8
|
+
export declare function CarouselItem({ children, className }: CarouselItemProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { cx as e } from "../../utils/cx.js";
|
|
2
|
+
import { carouselItem as t } from "./Carousel.css.js";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/Carousel/CarouselItem.tsx
|
|
5
|
+
function r({ children: r, className: i }) {
|
|
6
|
+
return /* @__PURE__ */ n("div", {
|
|
7
|
+
className: e(t, i),
|
|
8
|
+
children: r
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { r as CarouselItem };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=CarouselItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CarouselItem.js","names":[],"sources":["../../../src/components/Carousel/CarouselItem.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { cx } from \"../../utils/cx.js\";\nimport { carouselItem } from \"./Carousel.css.js\";\n\nexport interface CarouselItemProps {\n\t/** One slide, usually a `Card`. */\n\tchildren?: ReactNode;\n\tclassName?: string;\n}\n\n/** One slide. Each item snaps to the start of the track. */\nexport function CarouselItem({ children, className }: CarouselItemProps) {\n\treturn <div className={cx(carouselItem, className)}>{children}</div>;\n}\n"],"mappings":";;;;AAWA,SAAgB,EAAa,EAAE,aAAU,gBAAgC;AACxE,QAAO,kBAAC,OAAD;EAAK,WAAW,EAAG,GAAc,EAAU;EAAG;EAAe,CAAA"}
|