@fluentui/react-card 9.0.0-beta.34 → 9.0.0-beta.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.json +73 -1
  2. package/CHANGELOG.md +27 -2
  3. package/dist/index.d.ts +43 -22
  4. package/lib/components/Card/Card.js +3 -1
  5. package/lib/components/Card/Card.js.map +1 -1
  6. package/lib/components/Card/Card.types.js.map +1 -1
  7. package/lib/components/Card/CardContext.js +37 -0
  8. package/lib/components/Card/CardContext.js.map +1 -0
  9. package/lib/components/Card/index.js +1 -0
  10. package/lib/components/Card/index.js.map +1 -1
  11. package/lib/components/Card/renderCard.js +7 -3
  12. package/lib/components/Card/renderCard.js.map +1 -1
  13. package/lib/components/Card/useCard.js +52 -31
  14. package/lib/components/Card/useCard.js.map +1 -1
  15. package/lib/components/Card/useCardContextValue.js +8 -0
  16. package/lib/components/Card/useCardContextValue.js.map +1 -0
  17. package/lib/components/Card/useCardSelectable.js +59 -36
  18. package/lib/components/Card/useCardSelectable.js.map +1 -1
  19. package/lib/components/Card/useCardStyles.js +73 -56
  20. package/lib/components/Card/useCardStyles.js.map +1 -1
  21. package/lib/components/CardHeader/CardHeader.types.js.map +1 -1
  22. package/lib/components/CardHeader/useCardHeader.js +27 -4
  23. package/lib/components/CardHeader/useCardHeader.js.map +1 -1
  24. package/lib/components/CardPreview/useCardPreview.js +36 -2
  25. package/lib/components/CardPreview/useCardPreview.js.map +1 -1
  26. package/lib/index.js +1 -0
  27. package/lib/index.js.map +1 -1
  28. package/lib-commonjs/components/Card/Card.js +4 -1
  29. package/lib-commonjs/components/Card/Card.js.map +1 -1
  30. package/lib-commonjs/components/Card/CardContext.js +47 -0
  31. package/lib-commonjs/components/Card/CardContext.js.map +1 -0
  32. package/lib-commonjs/components/Card/index.js +2 -0
  33. package/lib-commonjs/components/Card/index.js.map +1 -1
  34. package/lib-commonjs/components/Card/renderCard.js +8 -3
  35. package/lib-commonjs/components/Card/renderCard.js.map +1 -1
  36. package/lib-commonjs/components/Card/useCard.js +51 -29
  37. package/lib-commonjs/components/Card/useCard.js.map +1 -1
  38. package/lib-commonjs/components/Card/useCardContextValue.js +17 -0
  39. package/lib-commonjs/components/Card/useCardContextValue.js.map +1 -0
  40. package/lib-commonjs/components/Card/useCardSelectable.js +58 -35
  41. package/lib-commonjs/components/Card/useCardSelectable.js.map +1 -1
  42. package/lib-commonjs/components/Card/useCardStyles.js +73 -56
  43. package/lib-commonjs/components/Card/useCardStyles.js.map +1 -1
  44. package/lib-commonjs/components/CardHeader/useCardHeader.js +29 -3
  45. package/lib-commonjs/components/CardHeader/useCardHeader.js.map +1 -1
  46. package/lib-commonjs/components/CardPreview/useCardPreview.js +38 -1
  47. package/lib-commonjs/components/CardPreview/useCardPreview.js.map +1 -1
  48. package/lib-commonjs/index.js +16 -1
  49. package/lib-commonjs/index.js.map +1 -1
  50. package/package.json +5 -5
@@ -1,33 +1,50 @@
1
1
  import * as React from 'react';
2
2
  import { Enter, Space } from '@fluentui/keyboard-keys';
3
- import { resolveShorthand } from '@fluentui/react-utilities';
3
+ import { mergeCallbacks, resolveShorthand } from '@fluentui/react-utilities';
4
4
  import { useFocusFinders } from '@fluentui/react-tabster';
5
- export const useCardSelectable = (props, cardRef) => {
5
+ /**
6
+ * @internal
7
+ *
8
+ * Create the state related to selectable cards.
9
+ *
10
+ * This internal hook controls all the logic for selectable cards and is
11
+ * intended to be used alongside with useCard_unstable.
12
+ *
13
+ * @param props - props from this instance of Card
14
+ * @param a11yProps - accessibility props shared between elements of the card
15
+ * @param ref - reference to the root element of Card
16
+ */
17
+
18
+ export const useCardSelectable = (props, {
19
+ referenceLabel,
20
+ referenceId
21
+ }, cardRef) => {
6
22
  const {
7
- select,
23
+ checkbox = {},
8
24
  selected,
9
25
  defaultSelected,
10
- onSelectionChange
26
+ onSelectionChange,
27
+ floatingAction,
28
+ onClick,
29
+ onKeyDown
11
30
  } = props;
12
31
  const {
13
32
  findAllFocusable
14
33
  } = useFocusFinders();
15
- const selectableRef = React.useRef(null);
16
- const isSelectable = [selected, defaultSelected, onSelectionChange, select].some(bool => typeof bool !== 'undefined');
17
- const hasSelectSlot = Boolean(select);
34
+ const checkboxRef = React.useRef(null);
35
+ const isSelectable = [selected, defaultSelected, onSelectionChange].some(prop => typeof prop !== 'undefined');
18
36
  const [isCardSelected, setIsCardSelected] = React.useState(false);
37
+ const [isSelectFocused, setIsSelectFocused] = React.useState(false);
19
38
  const shouldRestrictTriggerAction = React.useCallback(event => {
20
- var _a;
21
-
22
39
  if (!cardRef.current) {
23
40
  return false;
24
41
  }
25
42
 
26
43
  const focusableElements = findAllFocusable(cardRef.current);
27
44
  const target = event.target;
28
- const isTargetInFocusableGroup = focusableElements.some(element => element.contains(target));
29
- const isTargetInSelectableSlot = (_a = selectableRef === null || selectableRef === void 0 ? void 0 : selectableRef.current) === null || _a === void 0 ? void 0 : _a.contains(target);
30
- return isTargetInFocusableGroup && !isTargetInSelectableSlot;
45
+ const isElementInFocusableGroup = focusableElements.some(element => element.contains(target));
46
+ const isCheckboxSlot = (checkboxRef === null || checkboxRef === void 0 ? void 0 : checkboxRef.current) === target;
47
+ return isElementInFocusableGroup && !isCheckboxSlot;
31
48
  }, [cardRef, findAllFocusable]);
32
49
  const onChangeHandler = React.useCallback(event => {
33
50
  if (shouldRestrictTriggerAction(event)) {
@@ -49,42 +66,48 @@ export const useCardSelectable = (props, cardRef) => {
49
66
  onChangeHandler(event);
50
67
  }
51
68
  }, [onChangeHandler]);
52
- const selectableProps = React.useMemo(() => {
53
- if (!isSelectable) {
54
- return null;
69
+ const checkboxSlot = React.useMemo(() => {
70
+ if (!isSelectable || !!floatingAction) {
71
+ return;
55
72
  }
56
73
 
57
- const selectableEvents = {
58
- onClick: onChangeHandler,
59
- onKeyDown: onKeyDownHandler
60
- };
74
+ const selectableCheckboxProps = {};
61
75
 
62
- if (!hasSelectSlot) {
63
- return { ...selectableEvents,
64
- 'aria-checked': isCardSelected
65
- };
76
+ if (referenceId) {
77
+ selectableCheckboxProps['aria-labelledby'] = referenceId;
78
+ } else if (referenceLabel) {
79
+ selectableCheckboxProps['aria-label'] = referenceLabel;
66
80
  }
67
81
 
68
- return selectableEvents;
69
- }, [hasSelectSlot, isCardSelected, isSelectable, onChangeHandler, onKeyDownHandler]);
70
- const selectableSlot = React.useMemo(() => {
71
- if (!hasSelectSlot) {
72
- return undefined;
73
- }
74
-
75
- return resolveShorthand(select, {
82
+ return resolveShorthand(checkbox, {
76
83
  defaultProps: {
77
- ref: selectableRef
84
+ ref: checkboxRef,
85
+ type: 'checkbox',
86
+ checked: isCardSelected,
87
+ onChange: event => onChangeHandler(event),
88
+ onFocus: () => setIsSelectFocused(true),
89
+ onBlur: () => setIsSelectFocused(false),
90
+ ...selectableCheckboxProps
78
91
  }
79
92
  });
80
- }, [hasSelectSlot, select]);
93
+ }, [isSelectable, floatingAction, referenceId, referenceLabel, checkbox, isCardSelected, onChangeHandler]);
94
+ const selectableCardProps = React.useMemo(() => {
95
+ if (!isSelectable) {
96
+ return null;
97
+ }
98
+
99
+ return {
100
+ onClick: mergeCallbacks(onClick, onChangeHandler),
101
+ onKeyDown: mergeCallbacks(onKeyDown, onKeyDownHandler)
102
+ };
103
+ }, [isSelectable, onChangeHandler, onClick, onKeyDown, onKeyDownHandler]);
81
104
  React.useEffect(() => setIsCardSelected(Boolean(defaultSelected !== null && defaultSelected !== void 0 ? defaultSelected : selected)), [defaultSelected, selected, setIsCardSelected]);
82
105
  return {
83
106
  selected: isCardSelected,
84
107
  selectable: isSelectable,
85
- hasSelectSlot,
86
- selectableProps,
87
- selectableSlot
108
+ selectFocused: isSelectFocused,
109
+ selectableCardProps,
110
+ checkboxSlot
88
111
  };
89
112
  };
90
113
  //# sourceMappingURL=useCardSelectable.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-card/src/components/Card/useCardSelectable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,K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CAAC,aAAL,EAAoB;MAClB,OAAO,SAAP;IACD;;IAED,OAAO,gBAAgB,CAAC,MAAD,EAAS;MAC9B,YAAY,EAAE;QACZ,GAAG,EAAE;MADO;IADgB,CAAT,CAAvB;EAKD,CAVsB,EAUpB,CAAC,aAAD,EAAgB,MAAhB,CAVoB,CAAvB;EAYA,KAAK,CAAC,SAAN,CAAgB,MAAM,iBAAiB,CAAC,OAAO,CAAC,eAAe,KAAA,IAAf,IAAA,eAAe,KAAA,KAAA,CAAf,GAAA,eAAA,GAAmB,QAApB,CAAR,CAAvC,EAA+E,CAC7E,eAD6E,EAE7E,QAF6E,EAG7E,iBAH6E,CAA/E;EAMA,OAAO;IACL,QAAQ,EAAE,cADL;IAEL,UAAU,EAAE,YAFP;IAGL,aAHK;IAIL,eAJK;IAKL;EALK,CAAP;AAOD,CAnGM","sourcesContent":["import * as React from 'react';\nimport { Enter, Space } from '@fluentui/keyboard-keys';\nimport { resolveShorthand } from '@fluentui/react-utilities';\nimport { useFocusFinders } from '@fluentui/react-tabster';\n\nimport type { CarOnSelectionChangeEvent, CardProps, CardRefElement } from './Card.types';\n\nexport const useCardSelectable = (props: CardProps, cardRef: React.RefObject<CardRefElement>) => {\n const { select, selected, defaultSelected, onSelectionChange } = props;\n\n const { findAllFocusable } = useFocusFinders();\n const selectableRef = React.useRef<HTMLDivElement>(null);\n\n const isSelectable = [selected, defaultSelected, onSelectionChange, select].some(bool => typeof bool !== 'undefined');\n const hasSelectSlot = Boolean(select);\n\n const [isCardSelected, setIsCardSelected] = React.useState(false);\n\n const shouldRestrictTriggerAction = React.useCallback(\n (event: CarOnSelectionChangeEvent) => {\n if (!cardRef.current) {\n return false;\n }\n\n const focusableElements = findAllFocusable(cardRef.current);\n const target = event.target as HTMLElement;\n const isTargetInFocusableGroup = focusableElements.some(element => element.contains(target));\n const isTargetInSelectableSlot = selectableRef?.current?.contains(target);\n\n return isTargetInFocusableGroup && !isTargetInSelectableSlot;\n },\n [cardRef, findAllFocusable],\n );\n const onChangeHandler = React.useCallback(\n (event: CarOnSelectionChangeEvent) => {\n if (shouldRestrictTriggerAction(event)) {\n return;\n }\n\n const newCheckedValue = !isCardSelected;\n\n setIsCardSelected(newCheckedValue);\n\n if (onSelectionChange) {\n onSelectionChange(event, {\n selected: newCheckedValue,\n });\n }\n },\n [onSelectionChange, isCardSelected, shouldRestrictTriggerAction],\n );\n const onKeyDownHandler = React.useCallback(\n (event: React.KeyboardEvent<HTMLElement>) => {\n if ([Enter, Space].includes(event.key)) {\n event.preventDefault();\n onChangeHandler(event);\n }\n },\n [onChangeHandler],\n );\n\n const selectableProps = React.useMemo(() => {\n if (!isSelectable) {\n return null;\n }\n\n const selectableEvents = {\n onClick: onChangeHandler,\n onKeyDown: onKeyDownHandler,\n };\n\n if (!hasSelectSlot) {\n return {\n ...selectableEvents,\n 'aria-checked': isCardSelected,\n };\n }\n\n return selectableEvents;\n }, [hasSelectSlot, isCardSelected, isSelectable, onChangeHandler, onKeyDownHandler]);\n\n const selectableSlot = React.useMemo(() => {\n if (!hasSelectSlot) {\n return undefined;\n }\n\n return resolveShorthand(select, {\n defaultProps: {\n ref: selectableRef,\n },\n });\n }, [hasSelectSlot, select]);\n\n React.useEffect(() => setIsCardSelected(Boolean(defaultSelected ?? selected)), [\n defaultSelected,\n selected,\n setIsCardSelected,\n ]);\n\n return {\n selected: isCardSelected,\n selectable: isSelectable,\n hasSelectSlot,\n selectableProps,\n selectableSlot,\n };\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-card/src/components/Card/useCardSelectable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,KAAT,EAAgB,KAAhB,QAA6B,yBAA7B;AACA,SAAS,cAAT,EAAyB,gBAAzB,QAAiD,2BAAjD;AACA,SAAS,eAAT,QAAgC,yBAAhC;AAIA;;;;;;;;;;;AAWG;;AACH,OAAO,MAAM,iBAAiB,GAAG,CAC/B,KAD+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CAAvB;EAWD,CAxBoB,EAwBlB,CAAC,YAAD,EAAe,cAAf,EAA+B,WAA/B,EAA4C,cAA5C,EAA4D,QAA5D,EAAsE,cAAtE,EAAsF,eAAtF,CAxBkB,CAArB;EA0BA,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAN,CAAc,MAAK;IAC7C,IAAI,CAAC,YAAL,EAAmB;MACjB,OAAO,IAAP;IACD;;IAED,OAAO;MACL,OAAO,EAAE,cAAc,CAAC,OAAD,EAAU,eAAV,CADlB;MAEL,SAAS,EAAE,cAAc,CAAC,SAAD,EAAY,gBAAZ;IAFpB,CAAP;EAID,CAT2B,EASzB,CAAC,YAAD,EAAe,eAAf,EAAgC,OAAhC,EAAyC,SAAzC,EAAoD,gBAApD,CATyB,CAA5B;EAWA,KAAK,CAAC,SAAN,CAAgB,MAAM,iBAAiB,CAAC,OAAO,CAAC,eAAe,KAAA,IAAf,IAAA,eAAe,KAAA,KAAA,CAAf,GAAA,eAAA,GAAmB,QAApB,CAAR,CAAvC,EAA+E,CAC7E,eAD6E,EAE7E,QAF6E,EAG7E,iBAH6E,CAA/E;EAMA,OAAO;IACL,QAAQ,EAAE,cADL;IAEL,UAAU,EAAE,YAFP;IAGL,aAAa,EAAE,eAHV;IAIL,mBAJK;IAKL;EALK,CAAP;AAOD,CA7GM","sourcesContent":["import * as React from 'react';\nimport { Enter, Space } from '@fluentui/keyboard-keys';\nimport { mergeCallbacks, resolveShorthand } from '@fluentui/react-utilities';\nimport { useFocusFinders } from '@fluentui/react-tabster';\n\nimport type { CardContextValue, CardOnSelectionChangeEvent, CardProps, CardSlots } from './Card.types';\n\n/**\n * @internal\n *\n * Create the state related to selectable cards.\n *\n * This internal hook controls all the logic for selectable cards and is\n * intended to be used alongside with useCard_unstable.\n *\n * @param props - props from this instance of Card\n * @param a11yProps - accessibility props shared between elements of the card\n * @param ref - reference to the root element of Card\n */\nexport const useCardSelectable = (\n props: CardProps,\n { referenceLabel, referenceId }: Pick<CardContextValue['selectableA11yProps'], 'referenceId' | 'referenceLabel'>,\n cardRef: React.RefObject<HTMLDivElement>,\n) => {\n const { checkbox = {}, selected, defaultSelected, onSelectionChange, floatingAction, onClick, onKeyDown } = props;\n\n const { findAllFocusable } = useFocusFinders();\n\n const checkboxRef = React.useRef<HTMLInputElement>(null);\n\n const isSelectable = [selected, defaultSelected, onSelectionChange].some(prop => typeof prop !== 'undefined');\n\n const [isCardSelected, setIsCardSelected] = React.useState(false);\n const [isSelectFocused, setIsSelectFocused] = React.useState(false);\n\n const shouldRestrictTriggerAction = React.useCallback(\n (event: CardOnSelectionChangeEvent) => {\n if (!cardRef.current) {\n return false;\n }\n\n const focusableElements = findAllFocusable(cardRef.current);\n const target = event.target as HTMLElement;\n const isElementInFocusableGroup = focusableElements.some(element => element.contains(target));\n const isCheckboxSlot = checkboxRef?.current === target;\n\n return isElementInFocusableGroup && !isCheckboxSlot;\n },\n [cardRef, findAllFocusable],\n );\n\n const onChangeHandler = React.useCallback(\n (event: CardOnSelectionChangeEvent) => {\n if (shouldRestrictTriggerAction(event)) {\n return;\n }\n\n const newCheckedValue = !isCardSelected;\n\n setIsCardSelected(newCheckedValue);\n\n if (onSelectionChange) {\n onSelectionChange(event, { selected: newCheckedValue });\n }\n },\n [onSelectionChange, isCardSelected, shouldRestrictTriggerAction],\n );\n\n const onKeyDownHandler = React.useCallback(\n (event: React.KeyboardEvent<HTMLElement>) => {\n if ([Enter, Space].includes(event.key)) {\n event.preventDefault();\n onChangeHandler(event);\n }\n },\n [onChangeHandler],\n );\n\n const checkboxSlot = React.useMemo(() => {\n if (!isSelectable || !!floatingAction) {\n return;\n }\n\n const selectableCheckboxProps: CardSlots['checkbox'] = {};\n\n if (referenceId) {\n selectableCheckboxProps['aria-labelledby'] = referenceId;\n } else if (referenceLabel) {\n selectableCheckboxProps['aria-label'] = referenceLabel;\n }\n\n return resolveShorthand(checkbox, {\n defaultProps: {\n ref: checkboxRef,\n type: 'checkbox',\n checked: isCardSelected,\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => onChangeHandler(event),\n onFocus: () => setIsSelectFocused(true),\n onBlur: () => setIsSelectFocused(false),\n ...selectableCheckboxProps,\n },\n });\n }, [isSelectable, floatingAction, referenceId, referenceLabel, checkbox, isCardSelected, onChangeHandler]);\n\n const selectableCardProps = React.useMemo(() => {\n if (!isSelectable) {\n return null;\n }\n\n return {\n onClick: mergeCallbacks(onClick, onChangeHandler),\n onKeyDown: mergeCallbacks(onKeyDown, onKeyDownHandler),\n };\n }, [isSelectable, onChangeHandler, onClick, onKeyDown, onKeyDownHandler]);\n\n React.useEffect(() => setIsCardSelected(Boolean(defaultSelected ?? selected)), [\n defaultSelected,\n selected,\n setIsCardSelected,\n ]);\n\n return {\n selected: isCardSelected,\n selectable: isSelectable,\n selectFocused: isSelectFocused,\n selectableCardProps,\n checkboxSlot,\n };\n};\n"],"sourceRoot":"../src/"}
@@ -10,7 +10,8 @@ import { cardFooterClassNames } from '../CardFooter/useCardFooterStyles';
10
10
 
11
11
  export const cardClassNames = {
12
12
  root: 'fui-Card',
13
- select: 'fui-Card__select'
13
+ floatingAction: 'fui-Card__floatingAction',
14
+ checkbox: 'fui-Card__checkbox'
14
15
  };
15
16
  /**
16
17
  * CSS variable names used internally for uniform styling in Card.
@@ -20,6 +21,10 @@ export const cardCSSVars = {
20
21
  cardSizeVar: '--fui-Card--size',
21
22
  cardBorderRadiusVar: '--fui-Card--border-radius'
22
23
  };
24
+ const focusOutlineStyle = {
25
+ outlineRadius: `var(${cardCSSVars.cardBorderRadiusVar})`,
26
+ outlineWidth: tokens.strokeWidthThick
27
+ };
23
28
 
24
29
  const useStyles = /*#__PURE__*/__styles({
25
30
  "root": {
@@ -91,18 +96,53 @@ const useStyles = /*#__PURE__*/__styles({
91
96
  "Ghsupd": ["fdzzmfx", "fduh8kh"],
92
97
  "Bule8hv": ["fduh8kh", "fdzzmfx"]
93
98
  },
99
+ "selectableFocused": {
100
+ "Brovlpu": "ftqa4ok",
101
+ "B486eqv": "f2hkw1w",
102
+ "Bssx7fj": "f1b1k54r",
103
+ "uh7if5": ["f4ne723", "fqqcjud"],
104
+ "clntm0": "fh7aioi",
105
+ "Dlk2r6": ["fqqcjud", "f4ne723"],
106
+ "B2j2mmj": "ffht0p2",
107
+ "wigs8": "f1p0ul1q",
108
+ "pbfy6t": "f1c901ms",
109
+ "B0v4ure": "f1alokd7",
110
+ "ghq09": "f78i1la",
111
+ "B24cy0v": ["f1kvsw7t", "f1bw8brt"],
112
+ "Bwckmig": "f8k7e5g",
113
+ "Bvwlmkc": ["f1bw8brt", "f1kvsw7t"],
114
+ "Bbgo44z": "f125hn41",
115
+ "Bil7v7r": ["fgxkx34", "f1v56tyl"],
116
+ "skfxo0": "fdxas6f",
117
+ "jo1ztg": ["f1v56tyl", "fgxkx34"],
118
+ "Ba3ybja": ["fxwickw", "f1ia5cve"],
119
+ "az1dzo": ["f1ia5cve", "fxwickw"],
120
+ "vppk2z": ["f194aguw", "fqicc6c"],
121
+ "B6352mv": ["fqicc6c", "f194aguw"],
122
+ "nr063g": "fq4eyks",
123
+ "Blmvk6g": ["f1ya6x16", "ftuszwa"],
124
+ "Bsiemmq": "f1e2iu44",
125
+ "B98u21t": ["ftuszwa", "f1ya6x16"],
126
+ "B2pnrqr": "f4a0pcc",
127
+ "Bhhzhcn": "f11go4w5",
128
+ "Bec0n69": ["f4dzull", "fy687nj"],
129
+ "B29w5g4": ["fy687nj", "f4dzull"]
130
+ },
94
131
  "orientationHorizontal": {
95
132
  "Beiy3e4": "f1063pyq",
96
133
  "Bt984gj": "f122n59",
97
134
  "Bnoktp0": "fpfyeui",
98
135
  "Idhjb2": "fwi74qw",
99
- "Bsdbyht": ["f1yfsbdm", "f1vk4t4a"]
136
+ "ihgzqh": ["ffcmwrh", "f6ppoih"],
137
+ "Bgp6ld0": ["f1dc9p14", "fd933vt"]
100
138
  },
101
139
  "orientationVertical": {
102
140
  "Beiy3e4": "f1vx9l62",
103
141
  "Bt4kzjz": ["fobhde4", "fx5r7kn"],
104
142
  "B1ou843": ["fx5r7kn", "fobhde4"],
105
- "ydhu1d": "frl7skw"
143
+ "y1433z": "f19chtn8",
144
+ "B7egwnw": "fuvs6re",
145
+ "B49b4xf": "fy4glsf"
106
146
  },
107
147
  "sizeSmall": {
108
148
  "B7balbw": "f1pi9uxy",
@@ -116,23 +156,6 @@ const useStyles = /*#__PURE__*/__styles({
116
156
  "B7balbw": "f1qua4xo",
117
157
  "B1h88n7": "fimkt6v"
118
158
  },
119
- "interactiveLink": {
120
- "w71qe1": "f1iuv45f"
121
- },
122
- "interactiveButton": {
123
- "B4j52fo": "fre7gi1",
124
- "Bekrc4i": ["f1358rze", "f1rvrf73"],
125
- "Bn0qgzm": "fqdk4by",
126
- "ibv6hh": ["f1rvrf73", "f1358rze"],
127
- "a9b677": "fly5x3f",
128
- "Bt984gj": "ffnomw4",
129
- "Bowrso0": "fqrijq1",
130
- "Bg96gwp": "f1qumt79",
131
- "Bahqtrf": "f1mo0ibp",
132
- "Be2twd7": "fjoy568",
133
- "Bhrd7zp": "ff5ikls",
134
- "fsow6f": "fpgzoln"
135
- },
136
159
  "filled": {
137
160
  "De3pzq": "fxugw4r",
138
161
  "E5pizo": "f1whvlc6",
@@ -254,48 +277,26 @@ const useStyles = /*#__PURE__*/__styles({
254
277
  "select": {
255
278
  "qhf8xq": "f1euv43f",
256
279
  "Bhzewxz": "fqclxi7",
257
- "j35jbq": ["fiv86kb", "f36uhnt"]
280
+ "j35jbq": ["fiv86kb", "f36uhnt"],
281
+ "Bj3rh1h": "f19g0ac"
258
282
  },
259
- "selectHidden": {
260
- "a9b677": "f3tsq5r",
261
- "Bqenvij": "fniina8",
283
+ "hiddenCheckbox": {
284
+ "B68tc82": "f1p9o1ba",
285
+ "Bmxbyg5": "f1sil6mw",
286
+ "a9b677": "frkrog8",
287
+ "Bqenvij": "f1mpe4l3",
262
288
  "qhf8xq": "f1euv43f",
263
- "Bhzewxz": "f15twtuk",
264
- "j35jbq": ["f1e31b4d", "f1vgc2s3"]
289
+ "Bh84pgu": "fmf1zke",
290
+ "Bgl5zvf": "f1wch0ki",
291
+ "Huce71": "fz5stix"
265
292
  }
266
293
  }, {
267
- "d": [".f1p9o1ba{overflow-x:hidden;}", ".f1sil6mw{overflow-y:hidden;}", ".fifeqxg{border-bottom-right-radius:var(--fui-Card--border-radius);}", ".f899z7z{border-bottom-left-radius:var(--fui-Card--border-radius);}", ".f4h3tyx{border-top-right-radius:var(--fui-Card--border-radius);}", ".f18ur2pz{border-top-left-radius:var(--fui-Card--border-radius);}", ".f1lplnzb{padding-top:var(--fui-Card--size);}", ".f10m5gbb{padding-right:var(--fui-Card--size);}", ".f1k04kkk{padding-left:var(--fui-Card--size);}", ".fhftqfp{padding-bottom:var(--fui-Card--size);}", ".fxsr4vj{-webkit-column-gap:var(--fui-Card--size);column-gap:var(--fui-Card--size);}", ".fcvsdzp{row-gap:var(--fui-Card--size);}", ".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", ".f10pi13n{position:relative;}", ".f1ewtqcl{box-sizing:border-box;}", ".f19n0e5{color:var(--colorNeutralForeground1);}", ".f1mdlcz9::after{position:absolute;}", ".frwkxtg::after{top:0;}", ".f1n6gb5g::after{left:0;}", ".f15yvnhg::after{right:0;}", ".fo72kxq::after{bottom:0;}", ".f13zj6fq::after{content:\"\";}", ".f1nwj1ja::after{pointer-events:none;}", ".f8rth92::after{border-top-style:solid;}", ".flthirb::after{border-right-style:solid;}", ".ftkbnf5::after{border-left-style:solid;}", ".f1lh990p::after{border-bottom-style:solid;}", ".f6czdpx::after{border-top-width:var(--strokeWidthThin);}", ".f13hvwk3::after{border-right-width:var(--strokeWidthThin);}", ".f1en4csx::after{border-left-width:var(--strokeWidthThin);}", ".f1i1u9k0::after{border-bottom-width:var(--strokeWidthThin);}", ".f1qnomq5::after{border-bottom-right-radius:var(--fui-Card--border-radius);}", ".f2fl922::after{border-bottom-left-radius:var(--fui-Card--border-radius);}", ".f1anhtl::after{border-top-right-radius:var(--fui-Card--border-radius);}", ".f1n2zcl3::after{border-top-left-radius:var(--fui-Card--border-radius);}", ".f16v3d5c>.fui-CardHeader,.f16v3d5c>.fui-CardFooter{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;}", ".f1su8t2g>:not(.fui-CardPreview):not(.fui-CardHeader):not(.fui-CardFooter){-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;}", ".f8hki3x[data-fui-focus-visible]{border-top-color:transparent;}", ".f1d2448m[data-fui-focus-visible]{border-right-color:transparent;}", ".ffh67wi[data-fui-focus-visible]{border-left-color:transparent;}", ".f1bjia2o[data-fui-focus-visible]{border-bottom-color:transparent;}", ".f15bsgw9[data-fui-focus-visible]::after{content:\"\";}", ".f14e48fq[data-fui-focus-visible]::after{position:absolute;}", ".f18yb2kv[data-fui-focus-visible]::after{pointer-events:none;}", ".fd6o370[data-fui-focus-visible]::after{z-index:1;}", ".fh1cnn4[data-fui-focus-visible]::after{border-top-style:solid;}", ".fy7oxxb[data-fui-focus-visible]::after{border-right-style:solid;}", ".f184ne2d[data-fui-focus-visible]::after{border-left-style:solid;}", ".fpukqih[data-fui-focus-visible]::after{border-bottom-style:solid;}", ".f99gebs[data-fui-focus-visible]::after{border-top-width:var(--strokeWidthThick);}", ".f13b0oaq[data-fui-focus-visible]::after{border-right-width:var(--strokeWidthThick);}", ".f8t2bz6[data-fui-focus-visible]::after{border-left-width:var(--strokeWidthThick);}", ".f1jvq617[data-fui-focus-visible]::after{border-bottom-width:var(--strokeWidthThick);}", ".f11unbnk[data-fui-focus-visible]::after{border-bottom-right-radius:var(--fui-Card--border-radius);}", ".fbd201q[data-fui-focus-visible]::after{border-bottom-left-radius:var(--fui-Card--border-radius);}", ".f12nqxso[data-fui-focus-visible]::after{border-top-right-radius:var(--fui-Card--border-radius);}", ".f1uguk4w[data-fui-focus-visible]::after{border-top-left-radius:var(--fui-Card--border-radius);}", ".f1dvezut[data-fui-focus-visible]::after{border-top-color:var(--colorStrokeFocus2);}", ".fd0oaoj[data-fui-focus-visible]::after{border-right-color:var(--colorStrokeFocus2);}", ".f1cwg4i8[data-fui-focus-visible]::after{border-left-color:var(--colorStrokeFocus2);}", ".fjvm52t[data-fui-focus-visible]::after{border-bottom-color:var(--colorStrokeFocus2);}", ".f3l4wcz[data-fui-focus-visible]::after{top:-var(--strokeWidthThick);}", ".f6j2biq[data-fui-focus-visible]::after{bottom:-var(--strokeWidthThick);}", ".fdzzmfx[data-fui-focus-visible]::after{left:-var(--strokeWidthThick);}", ".fduh8kh[data-fui-focus-visible]::after{right:-var(--strokeWidthThick);}", ".f1063pyq{-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;}", ".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}", ".fpfyeui>.fui-CardPreview{margin-top:calc(var(--fui-Card--size) * -1);}", ".fwi74qw>.fui-CardPreview{margin-bottom:calc(var(--fui-Card--size) * -1);}", ".f1yfsbdm>:not([aria-hidden=\"true\"]):first-of-type.fui-CardPreview{margin-left:calc(var(--fui-Card--size) * -1);}", ".f1vk4t4a>:not([aria-hidden=\"true\"]):first-of-type.fui-CardPreview{margin-right:calc(var(--fui-Card--size) * -1);}", ".f1vx9l62{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}", ".fobhde4>.fui-CardPreview{margin-left:calc(var(--fui-Card--size) * -1);}", ".fx5r7kn>.fui-CardPreview{margin-right:calc(var(--fui-Card--size) * -1);}", ".frl7skw>:not([aria-hidden=\"true\"]):first-of-type.fui-CardPreview{margin-top:calc(var(--fui-Card--size) * -1);}", ".f1pi9uxy{--fui-Card--size:8px;}", ".f1h1zgly{--fui-Card--border-radius:var(--borderRadiusSmall);}", ".frsmuga{--fui-Card--size:12px;}", ".fuldkky{--fui-Card--border-radius:var(--borderRadiusMedium);}", ".f1qua4xo{--fui-Card--size:16px;}", ".fimkt6v{--fui-Card--border-radius:var(--borderRadiusLarge);}", ".f1iuv45f{text-decoration-line:none;}", ".fre7gi1{border-top-width:0;}", ".f1358rze{border-right-width:0;}", ".f1rvrf73{border-left-width:0;}", ".fqdk4by{border-bottom-width:0;}", ".fly5x3f{width:100%;}", ".ffnomw4{-webkit-align-items:normal;-webkit-box-align:normal;-ms-flex-align:normal;align-items:normal;}", ".fqrijq1{-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;appearance:none;}", ".f1qumt79{line-height:inherit;}", ".f1mo0ibp{font-family:inherit;}", ".fjoy568{font-size:inherit;}", ".ff5ikls{font-weight:inherit;}", ".fpgzoln{text-align:start;}", ".fxugw4r{background-color:var(--colorNeutralBackground1);}", ".f1whvlc6{box-shadow:var(--shadow4);}", ".f16gxe2i::after{border-top-color:var(--colorTransparentStroke);}", ".fpgykix::after{border-right-color:var(--colorTransparentStroke);}", ".fzybk4o::after{border-left-color:var(--colorTransparentStroke);}", ".f1osi826::after{border-bottom-color:var(--colorTransparentStroke);}", ".f1k6fduh{cursor:pointer;}", ".f1nfm20t{background-color:var(--colorNeutralBackground1Selected);}", ".f16eln5f::after{border-top-color:var(--colorNeutralStroke1Selected);}", ".fa2okxs::after{border-right-color:var(--colorNeutralStroke1Selected);}", ".fg4zq3l::after{border-left-color:var(--colorNeutralStroke1Selected);}", ".ff6932p::after{border-bottom-color:var(--colorNeutralStroke1Selected);}", ".f1dmdbja{background-color:var(--colorNeutralBackground2);}", ".fjxa0vh{background-color:var(--colorNeutralBackground2Selected);}", ".f1c21dwh{background-color:var(--colorTransparentBackground);}", ".f1couhl3{box-shadow:none;}", ".ft83z1f::after{border-top-color:var(--colorNeutralStroke1);}", ".f1g4150c::after{border-right-color:var(--colorNeutralStroke1);}", ".f192dr6e::after{border-left-color:var(--colorNeutralStroke1);}", ".f1qnawh6::after{border-bottom-color:var(--colorNeutralStroke1);}", ".f1q9pm1r{background-color:var(--colorTransparentBackgroundSelected);}", ".fhovq9v{background-color:var(--colorSubtleBackground);}", ".fq5gl1p{background-color:var(--colorSubtleBackgroundSelected);}", ".f1euv43f{position:absolute;}", ".fqclxi7{top:4px;}", ".fiv86kb{right:4px;}", ".f36uhnt{left:4px;}", ".f3tsq5r{width:0;}", ".fniina8{height:0;}", ".f15twtuk{top:0;}", ".f1e31b4d{right:0;}", ".f1vgc2s3{left:0;}"],
294
+ "d": [".f1p9o1ba{overflow-x:hidden;}", ".f1sil6mw{overflow-y:hidden;}", ".fifeqxg{border-bottom-right-radius:var(--fui-Card--border-radius);}", ".f899z7z{border-bottom-left-radius:var(--fui-Card--border-radius);}", ".f4h3tyx{border-top-right-radius:var(--fui-Card--border-radius);}", ".f18ur2pz{border-top-left-radius:var(--fui-Card--border-radius);}", ".f1lplnzb{padding-top:var(--fui-Card--size);}", ".f10m5gbb{padding-right:var(--fui-Card--size);}", ".f1k04kkk{padding-left:var(--fui-Card--size);}", ".fhftqfp{padding-bottom:var(--fui-Card--size);}", ".fxsr4vj{-webkit-column-gap:var(--fui-Card--size);column-gap:var(--fui-Card--size);}", ".fcvsdzp{row-gap:var(--fui-Card--size);}", ".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", ".f10pi13n{position:relative;}", ".f1ewtqcl{box-sizing:border-box;}", ".f19n0e5{color:var(--colorNeutralForeground1);}", ".f1mdlcz9::after{position:absolute;}", ".frwkxtg::after{top:0;}", ".f1n6gb5g::after{left:0;}", ".f15yvnhg::after{right:0;}", ".fo72kxq::after{bottom:0;}", ".f13zj6fq::after{content:\"\";}", ".f1nwj1ja::after{pointer-events:none;}", ".f8rth92::after{border-top-style:solid;}", ".flthirb::after{border-right-style:solid;}", ".ftkbnf5::after{border-left-style:solid;}", ".f1lh990p::after{border-bottom-style:solid;}", ".f6czdpx::after{border-top-width:var(--strokeWidthThin);}", ".f13hvwk3::after{border-right-width:var(--strokeWidthThin);}", ".f1en4csx::after{border-left-width:var(--strokeWidthThin);}", ".f1i1u9k0::after{border-bottom-width:var(--strokeWidthThin);}", ".f1qnomq5::after{border-bottom-right-radius:var(--fui-Card--border-radius);}", ".f2fl922::after{border-bottom-left-radius:var(--fui-Card--border-radius);}", ".f1anhtl::after{border-top-right-radius:var(--fui-Card--border-radius);}", ".f1n2zcl3::after{border-top-left-radius:var(--fui-Card--border-radius);}", ".f16v3d5c>.fui-CardHeader,.f16v3d5c>.fui-CardFooter{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;}", ".f1su8t2g>:not(.fui-CardPreview):not(.fui-CardHeader):not(.fui-CardFooter){-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;}", ".f8hki3x[data-fui-focus-visible]{border-top-color:transparent;}", ".f1d2448m[data-fui-focus-visible]{border-right-color:transparent;}", ".ffh67wi[data-fui-focus-visible]{border-left-color:transparent;}", ".f1bjia2o[data-fui-focus-visible]{border-bottom-color:transparent;}", ".f15bsgw9[data-fui-focus-visible]::after{content:\"\";}", ".f14e48fq[data-fui-focus-visible]::after{position:absolute;}", ".f18yb2kv[data-fui-focus-visible]::after{pointer-events:none;}", ".fd6o370[data-fui-focus-visible]::after{z-index:1;}", ".fh1cnn4[data-fui-focus-visible]::after{border-top-style:solid;}", ".fy7oxxb[data-fui-focus-visible]::after{border-right-style:solid;}", ".f184ne2d[data-fui-focus-visible]::after{border-left-style:solid;}", ".fpukqih[data-fui-focus-visible]::after{border-bottom-style:solid;}", ".f99gebs[data-fui-focus-visible]::after{border-top-width:var(--strokeWidthThick);}", ".f13b0oaq[data-fui-focus-visible]::after{border-right-width:var(--strokeWidthThick);}", ".f8t2bz6[data-fui-focus-visible]::after{border-left-width:var(--strokeWidthThick);}", ".f1jvq617[data-fui-focus-visible]::after{border-bottom-width:var(--strokeWidthThick);}", ".f11unbnk[data-fui-focus-visible]::after{border-bottom-right-radius:var(--fui-Card--border-radius);}", ".fbd201q[data-fui-focus-visible]::after{border-bottom-left-radius:var(--fui-Card--border-radius);}", ".f12nqxso[data-fui-focus-visible]::after{border-top-right-radius:var(--fui-Card--border-radius);}", ".f1uguk4w[data-fui-focus-visible]::after{border-top-left-radius:var(--fui-Card--border-radius);}", ".f1dvezut[data-fui-focus-visible]::after{border-top-color:var(--colorStrokeFocus2);}", ".fd0oaoj[data-fui-focus-visible]::after{border-right-color:var(--colorStrokeFocus2);}", ".f1cwg4i8[data-fui-focus-visible]::after{border-left-color:var(--colorStrokeFocus2);}", ".fjvm52t[data-fui-focus-visible]::after{border-bottom-color:var(--colorStrokeFocus2);}", ".f3l4wcz[data-fui-focus-visible]::after{top:-var(--strokeWidthThick);}", ".f6j2biq[data-fui-focus-visible]::after{bottom:-var(--strokeWidthThick);}", ".fdzzmfx[data-fui-focus-visible]::after{left:-var(--strokeWidthThick);}", ".fduh8kh[data-fui-focus-visible]::after{right:-var(--strokeWidthThick);}", ".f1b1k54r[data-fui-focus-within]:focus-within{border-top-color:transparent;}", ".f4ne723[data-fui-focus-within]:focus-within{border-right-color:transparent;}", ".fqqcjud[data-fui-focus-within]:focus-within{border-left-color:transparent;}", ".fh7aioi[data-fui-focus-within]:focus-within{border-bottom-color:transparent;}", ".ffht0p2[data-fui-focus-within]:focus-within::after{content:\"\";}", ".f1p0ul1q[data-fui-focus-within]:focus-within::after{position:absolute;}", ".f1c901ms[data-fui-focus-within]:focus-within::after{pointer-events:none;}", ".f1alokd7[data-fui-focus-within]:focus-within::after{z-index:1;}", ".f78i1la[data-fui-focus-within]:focus-within::after{border-top-style:solid;}", ".f1kvsw7t[data-fui-focus-within]:focus-within::after{border-right-style:solid;}", ".f1bw8brt[data-fui-focus-within]:focus-within::after{border-left-style:solid;}", ".f8k7e5g[data-fui-focus-within]:focus-within::after{border-bottom-style:solid;}", ".f125hn41[data-fui-focus-within]:focus-within::after{border-top-width:var(--strokeWidthThick);}", ".fgxkx34[data-fui-focus-within]:focus-within::after{border-right-width:var(--strokeWidthThick);}", ".f1v56tyl[data-fui-focus-within]:focus-within::after{border-left-width:var(--strokeWidthThick);}", ".fdxas6f[data-fui-focus-within]:focus-within::after{border-bottom-width:var(--strokeWidthThick);}", ".fxwickw[data-fui-focus-within]:focus-within::after{border-bottom-right-radius:var(--fui-Card--border-radius);}", ".f1ia5cve[data-fui-focus-within]:focus-within::after{border-bottom-left-radius:var(--fui-Card--border-radius);}", ".f194aguw[data-fui-focus-within]:focus-within::after{border-top-right-radius:var(--fui-Card--border-radius);}", ".fqicc6c[data-fui-focus-within]:focus-within::after{border-top-left-radius:var(--fui-Card--border-radius);}", ".fq4eyks[data-fui-focus-within]:focus-within::after{border-top-color:var(--colorStrokeFocus2);}", ".f1ya6x16[data-fui-focus-within]:focus-within::after{border-right-color:var(--colorStrokeFocus2);}", ".ftuszwa[data-fui-focus-within]:focus-within::after{border-left-color:var(--colorStrokeFocus2);}", ".f1e2iu44[data-fui-focus-within]:focus-within::after{border-bottom-color:var(--colorStrokeFocus2);}", ".f4a0pcc[data-fui-focus-within]:focus-within::after{top:-var(--strokeWidthThick);}", ".f11go4w5[data-fui-focus-within]:focus-within::after{bottom:-var(--strokeWidthThick);}", ".f4dzull[data-fui-focus-within]:focus-within::after{left:-var(--strokeWidthThick);}", ".fy687nj[data-fui-focus-within]:focus-within::after{right:-var(--strokeWidthThick);}", ".f1063pyq{-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;}", ".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}", ".fpfyeui>.fui-CardPreview{margin-top:calc(var(--fui-Card--size) * -1);}", ".fwi74qw>.fui-CardPreview{margin-bottom:calc(var(--fui-Card--size) * -1);}", ".ffcmwrh>:not([aria-hidden=\"true\"]).fui-CardPreview:first-of-type{margin-left:calc(var(--fui-Card--size) * -1);}", ".f6ppoih>:not([aria-hidden=\"true\"]).fui-CardPreview:first-of-type{margin-right:calc(var(--fui-Card--size) * -1);}", ".f1dc9p14>:not([aria-hidden=\"true\"]).fui-CardPreview:last-of-type{margin-right:calc(var(--fui-Card--size) * -1);}", ".fd933vt>:not([aria-hidden=\"true\"]).fui-CardPreview:last-of-type{margin-left:calc(var(--fui-Card--size) * -1);}", ".f1vx9l62{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}", ".fobhde4>.fui-CardPreview{margin-left:calc(var(--fui-Card--size) * -1);}", ".fx5r7kn>.fui-CardPreview{margin-right:calc(var(--fui-Card--size) * -1);}", ".f19chtn8>:not([aria-hidden=\"true\"]).fui-CardPreview:first-of-type{margin-top:calc(var(--fui-Card--size) * -1);}", ".fuvs6re>.fui-Card__floatingAction+.fui-CardPreview{margin-top:calc(var(--fui-Card--size) * -1);}", ".fy4glsf>:not([aria-hidden=\"true\"]).fui-CardPreview:last-of-type{margin-bottom:calc(var(--fui-Card--size) * -1);}", ".f1pi9uxy{--fui-Card--size:8px;}", ".f1h1zgly{--fui-Card--border-radius:var(--borderRadiusSmall);}", ".frsmuga{--fui-Card--size:12px;}", ".fuldkky{--fui-Card--border-radius:var(--borderRadiusMedium);}", ".f1qua4xo{--fui-Card--size:16px;}", ".fimkt6v{--fui-Card--border-radius:var(--borderRadiusLarge);}", ".fxugw4r{background-color:var(--colorNeutralBackground1);}", ".f1whvlc6{box-shadow:var(--shadow4);}", ".f16gxe2i::after{border-top-color:var(--colorTransparentStroke);}", ".fpgykix::after{border-right-color:var(--colorTransparentStroke);}", ".fzybk4o::after{border-left-color:var(--colorTransparentStroke);}", ".f1osi826::after{border-bottom-color:var(--colorTransparentStroke);}", ".f1k6fduh{cursor:pointer;}", ".f1nfm20t{background-color:var(--colorNeutralBackground1Selected);}", ".f16eln5f::after{border-top-color:var(--colorNeutralStroke1Selected);}", ".fa2okxs::after{border-right-color:var(--colorNeutralStroke1Selected);}", ".fg4zq3l::after{border-left-color:var(--colorNeutralStroke1Selected);}", ".ff6932p::after{border-bottom-color:var(--colorNeutralStroke1Selected);}", ".f1dmdbja{background-color:var(--colorNeutralBackground2);}", ".fjxa0vh{background-color:var(--colorNeutralBackground2Selected);}", ".f1c21dwh{background-color:var(--colorTransparentBackground);}", ".f1couhl3{box-shadow:none;}", ".ft83z1f::after{border-top-color:var(--colorNeutralStroke1);}", ".f1g4150c::after{border-right-color:var(--colorNeutralStroke1);}", ".f192dr6e::after{border-left-color:var(--colorNeutralStroke1);}", ".f1qnawh6::after{border-bottom-color:var(--colorNeutralStroke1);}", ".f1q9pm1r{background-color:var(--colorTransparentBackgroundSelected);}", ".fhovq9v{background-color:var(--colorSubtleBackground);}", ".fq5gl1p{background-color:var(--colorSubtleBackgroundSelected);}", ".f1euv43f{position:absolute;}", ".fqclxi7{top:4px;}", ".fiv86kb{right:4px;}", ".f36uhnt{left:4px;}", ".f19g0ac{z-index:1;}", ".frkrog8{width:1px;}", ".f1mpe4l3{height:1px;}", ".fmf1zke{clip:rect(0 0 0 0);}", ".f1wch0ki{-webkit-clip-path:inset(50%);clip-path:inset(50%);}", ".fz5stix{white-space:nowrap;}"],
268
295
  "f": [".ftqa4ok:focus{outline-style:none;}"],
269
296
  "i": [".f2hkw1w:focus-visible{outline-style:none;}"],
270
297
  "h": [".f1knas48:hover{background-color:var(--colorNeutralBackground1Hover);}", ".f1m145df:hover{box-shadow:var(--shadow8);}", ".f1kz6goq:hover{background-color:var(--colorNeutralBackground1Selected);}", ".f1uvynv3:hover{background-color:var(--colorNeutralBackground2Hover);}", ".fehi0vp:hover{background-color:var(--colorNeutralBackground2Selected);}", ".fjxutwb:hover{background-color:var(--colorTransparentBackgroundHover);}", ".f1llr77y:hover::after{border-top-color:var(--colorNeutralStroke1Hover);}", ".fzk0khw:hover::after{border-right-color:var(--colorNeutralStroke1Hover);}", ".fjj8tog:hover::after{border-left-color:var(--colorNeutralStroke1Hover);}", ".fb1u8ub:hover::after{border-bottom-color:var(--colorNeutralStroke1Hover);}", ".fg59vm4:hover{background-color:var(--colorTransparentBackgroundSelected);}", ".f1t94bn6:hover{background-color:var(--colorSubtleBackgroundHover);}", ".f1uqaxdt:hover{background-color:var(--colorSubtleBackgroundSelected);}"],
271
298
  "a": [".fb40n2d:active{background-color:var(--colorNeutralBackground1Pressed);}", ".f1yhgkbh:active{background-color:var(--colorNeutralBackground2Pressed);}", ".fophhak:active{background-color:var(--colorTransparentBackgroundPressed);}", ".f1uohb70:active::after{border-top-color:var(--colorNeutralStroke1Pressed);}", ".f1jm7v1n:active::after{border-right-color:var(--colorNeutralStroke1Pressed);}", ".f1bus3rq:active::after{border-left-color:var(--colorNeutralStroke1Pressed);}", ".f1fbu7rr:active::after{border-bottom-color:var(--colorNeutralStroke1Pressed);}", ".f1wfn5kd:active{background-color:var(--colorSubtleBackgroundPressed);}"]
272
299
  });
273
-
274
- const getInteractiveClassnames = (state, styles) => {
275
- const selectedMap = {
276
- filled: styles.filledInteractiveSelected,
277
- 'filled-alternative': styles.filledAlternativeInteractiveSelected,
278
- outline: styles.outlineInteractiveSelected,
279
- subtle: styles.subtleInteractiveSelected
280
- };
281
- const interactiveMap = {
282
- filled: styles.filledInteractive,
283
- 'filled-alternative': styles.filledAlternativeInteractive,
284
- outline: styles.outlineInteractive,
285
- subtle: styles.subtleInteractive
286
- };
287
- const baseClass = mergeClasses(interactiveMap[state.appearance], state.selected && selectedMap[state.appearance]);
288
-
289
- if (state.components.root === 'button') {
290
- return mergeClasses(baseClass, styles.interactiveButton);
291
- }
292
-
293
- if (state.components.root === 'a') {
294
- return mergeClasses(baseClass, styles.interactiveLink);
295
- }
296
-
297
- return baseClass;
298
- };
299
300
  /**
300
301
  * Apply styling to the Card slots based on the state.
301
302
  */
@@ -318,10 +319,26 @@ export const useCardStyles_unstable = state => {
318
319
  outline: styles.outline,
319
320
  subtle: styles.subtle
320
321
  };
321
- state.root.className = mergeClasses(cardClassNames.root, styles.root, orientationMap[state.orientation], sizeMap[state.size], appearanceMap[state.appearance], state.interactive && getInteractiveClassnames(state, styles), state.root.className);
322
+ const selectedMap = {
323
+ filled: styles.filledInteractiveSelected,
324
+ 'filled-alternative': styles.filledAlternativeInteractiveSelected,
325
+ outline: styles.outlineInteractiveSelected,
326
+ subtle: styles.subtleInteractiveSelected
327
+ };
328
+ const interactiveMap = {
329
+ filled: styles.filledInteractive,
330
+ 'filled-alternative': styles.filledAlternativeInteractive,
331
+ outline: styles.outlineInteractive,
332
+ subtle: styles.subtleInteractive
333
+ };
334
+ state.root.className = mergeClasses(cardClassNames.root, styles.root, orientationMap[state.orientation], sizeMap[state.size], appearanceMap[state.appearance], (state.interactive || state.selectable) && interactiveMap[state.appearance], state.selected && selectedMap[state.appearance], state.selectFocused && styles.selectableFocused, state.root.className);
335
+
336
+ if (state.floatingAction) {
337
+ state.floatingAction.className = mergeClasses(cardClassNames.floatingAction, styles.select, state.floatingAction.className);
338
+ }
322
339
 
323
- if (state.select) {
324
- state.select.className = mergeClasses(cardClassNames.select, state.hasSelectSlot ? styles.select : styles.selectHidden, state.select.className);
340
+ if (state.checkbox) {
341
+ state.checkbox.className = mergeClasses(cardClassNames.checkbox, styles.hiddenCheckbox, state.checkbox.className);
325
342
  }
326
343
 
327
344
  return state;
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-card/src/components/Card/useCardStyles.ts"],"names":[],"mappings":"AAAA,SAAS,UAAT,YAAiC,YAAjC,QAAqD,gBAArD;AACA,SAAS,MAAT,QAAuB,uBAAvB;AAEA,SAAS,uBAAT,QAAwC,yBAAxC;AACA,SAAS,qBAAT,QAAsC,qCAAtC;AACA,SAAS,oBAAT,QAAqC,mCAArC;AACA,SAAS,oBAAT,QAAqC,mCAArC;AAGA;;AAEG;;AACH,OAAO,MAAM,cAAc,GAA8B;EACvD,IAAI,EAAE,UADiD;EAEvD,MAAM,EAAE;AAF+C,CAAlD;AAKP;;AAEG;;AACH,OAAO,MAAM,WAAW,GAAG;EACzB,WAAW,EAAE,kBADY;EAEzB,mBAAmB,EAAE;AAFI,CAApB;;AAKP,MAAM,SAAS,gBAAG;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;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;IACd,KAAK,EAAE,MAAM,CAAC,SADA;IAEd,MAAM,EAAE,MAAM,CAAC,UAFD;IAGd,KAAK,EAAE,MAAM,CAAC;EAHA,CAAhB;EAMA,MAAM,aAAa,GAAG;IACpB,MAAM,EAAE,MAAM,CAAC,MADK;IAEpB,sBAAsB,MAAM,CAAC,iBAFT;IAGpB,OAAO,EAAE,MAAM,CAAC,OAHI;IAIpB,MAAM,EAAE,MAAM,CAAC;EAJK,CAAtB;EAOA,KAAK,CAAC,IAAN,CAAW,SAAX,GAAuB,YAAY,CACjC,cAAc,CAAC,IADkB,EAEjC,MAAM,CAAC,IAF0B,EAGjC,cAAc,CAAC,KAAK,CAAC,WAAP,CAHmB,EAIjC,OAAO,CAAC,KAAK,CAAC,IAAP,CAJ0B,EAKjC,aAAa,CAAC,KAAK,CAAC,UAAP,CALoB,EAMjC,KAAK,CAAC,WAAN,IAAqB,wBAAwB,CAAC,KAAD,EAAQ,MAAR,CANZ,EAOjC,KAAK,CAAC,IAAN,CAAW,SAPsB,CAAnC;;EAUA,IAAI,KAAK,CAAC,MAAV,EAAkB;IAChB,KAAK,CAAC,MAAN,CAAa,SAAb,GAAyB,YAAY,CACnC,cAAc,CAAC,MADoB,EAEnC,KAAK,CAAC,aAAN,GAAsB,MAAM,CAAC,MAA7B,GAAsC,MAAM,CAAC,YAFV,EAGnC,KAAK,CAAC,MAAN,CAAa,SAHsB,CAArC;EAKD;;EAED,OAAO,KAAP;AACD,CAxCM","sourcesContent":["import { shorthands, makeStyles, mergeClasses } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { createFocusOutlineStyle } from '@fluentui/react-tabster';\nimport { cardPreviewClassNames } from '../CardPreview/useCardPreviewStyles';\nimport { cardHeaderClassNames } from '../CardHeader/useCardHeaderStyles';\nimport { cardFooterClassNames } from '../CardFooter/useCardFooterStyles';\nimport type { CardSlots, CardState } from './Card.types';\n\n/**\n * Static CSS class names used internally for the component slots.\n */\nexport const cardClassNames: SlotClassNames<CardSlots> = {\n root: 'fui-Card',\n select: 'fui-Card__select',\n};\n\n/**\n * CSS variable names used internally for uniform styling in Card.\n */\nexport const cardCSSVars = {\n cardSizeVar: '--fui-Card--size',\n cardBorderRadiusVar: '--fui-Card--border-radius',\n};\n\nconst useStyles = makeStyles({\n root: {\n ...shorthands.overflow('hidden'),\n ...shorthands.borderRadius(`var(${cardCSSVars.cardBorderRadiusVar})`),\n ...shorthands.padding(`var(${cardCSSVars.cardSizeVar})`),\n ...shorthands.gap(`var(${cardCSSVars.cardSizeVar})`),\n\n display: 'flex',\n position: 'relative',\n boxSizing: 'border-box',\n color: tokens.colorNeutralForeground1,\n\n // Border setting using after pseudo element to allow CardPreview to render behind it.\n '::after': {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n content: '\"\"',\n pointerEvents: 'none',\n\n ...shorthands.borderStyle('solid'),\n ...shorthands.borderWidth(tokens.strokeWidthThin),\n ...shorthands.borderRadius(`var(${cardCSSVars.cardBorderRadiusVar})`),\n },\n\n // Prevents CardHeader and CardFooter from shrinking.\n [`> .${cardHeaderClassNames.root}, > .${cardFooterClassNames.root}`]: {\n flexShrink: 0,\n },\n // Allows non-card components to grow to fill the available space.\n [`> :not(.${cardPreviewClassNames.root}):not(.${cardHeaderClassNames.root}):not(.${cardFooterClassNames.root})`]: {\n flexGrow: 1,\n },\n\n ...createFocusOutlineStyle({\n style: {\n outlineRadius: `var(${cardCSSVars.cardBorderRadiusVar})`,\n outlineWidth: tokens.strokeWidthThick,\n },\n selector: 'focus',\n }),\n },\n\n orientationHorizontal: {\n flexDirection: 'row',\n alignItems: 'center',\n\n // Remove vertical padding to keep CardPreview content flush with Card's borders.\n [`> .${cardPreviewClassNames.root}`]: {\n marginTop: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`,\n marginBottom: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`,\n },\n // Due to Tabster's \"Groupper\" focus functionality, hidden elements are injected before and after Card's content.\n // As such, the code below targets a CardPreview, when it's the first element.\n // Since this is on horizontal cards, the left padding is removed to keep the content flush with the border.\n [`> :not([aria-hidden=\"true\"]):first-of-type.${cardPreviewClassNames.root}`]: {\n marginLeft: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`,\n },\n },\n orientationVertical: {\n flexDirection: 'column',\n\n // Remove lateral padding to keep CardPreview content flush with Card's borders.\n [`> .${cardPreviewClassNames.root}`]: {\n marginLeft: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`,\n marginRight: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`,\n },\n // Due to Tabster's \"Groupper\" focus functionality, hidden elements are injected before and after Card's content.\n // As such, the code below targets a CardPreview, when it's the first element.\n // Since this is on vertical cards, the top padding is removed to keep the content flush with the border.\n [`> :not([aria-hidden=\"true\"]):first-of-type.${cardPreviewClassNames.root}`]: {\n marginTop: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`,\n },\n },\n\n sizeSmall: {\n [cardCSSVars.cardSizeVar]: '8px',\n [cardCSSVars.cardBorderRadiusVar]: tokens.borderRadiusSmall,\n },\n sizeMedium: {\n [cardCSSVars.cardSizeVar]: '12px',\n [cardCSSVars.cardBorderRadiusVar]: tokens.borderRadiusMedium,\n },\n sizeLarge: {\n [cardCSSVars.cardSizeVar]: '16px',\n [cardCSSVars.cardBorderRadiusVar]: tokens.borderRadiusLarge,\n },\n\n interactiveLink: {\n textDecorationLine: 'none',\n },\n interactiveButton: {\n ...shorthands.border('0'),\n width: '100%',\n alignItems: 'normal',\n appearance: 'none',\n lineHeight: 'inherit',\n fontFamily: 'inherit',\n fontSize: 'inherit',\n fontWeight: 'inherit',\n textAlign: 'start',\n },\n\n filled: {\n backgroundColor: tokens.colorNeutralBackground1,\n boxShadow: tokens.shadow4,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorTransparentStroke),\n },\n },\n filledInteractive: {\n cursor: 'pointer',\n backgroundColor: tokens.colorNeutralBackground1,\n boxShadow: tokens.shadow4,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorTransparentStroke),\n },\n\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground1Hover,\n boxShadow: tokens.shadow8,\n },\n ':active': {\n backgroundColor: tokens.colorNeutralBackground1Pressed,\n },\n },\n filledInteractiveSelected: {\n backgroundColor: tokens.colorNeutralBackground1Selected,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Selected),\n },\n\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground1Selected,\n },\n },\n\n filledAlternative: {\n backgroundColor: tokens.colorNeutralBackground2,\n boxShadow: tokens.shadow4,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorTransparentStroke),\n },\n },\n filledAlternativeInteractive: {\n cursor: 'pointer',\n backgroundColor: tokens.colorNeutralBackground2,\n boxShadow: tokens.shadow4,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorTransparentStroke),\n },\n\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground2Hover,\n boxShadow: tokens.shadow8,\n },\n ':active': {\n backgroundColor: tokens.colorNeutralBackground2Pressed,\n },\n },\n filledAlternativeInteractiveSelected: {\n backgroundColor: tokens.colorNeutralBackground2Selected,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Selected),\n },\n\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground2Selected,\n },\n },\n\n outline: {\n backgroundColor: tokens.colorTransparentBackground,\n boxShadow: 'none',\n\n '::after': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1),\n },\n },\n outlineInteractive: {\n cursor: 'pointer',\n backgroundColor: tokens.colorTransparentBackground,\n boxShadow: 'none',\n\n '::after': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1),\n },\n\n ':hover': {\n backgroundColor: tokens.colorTransparentBackgroundHover,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Hover),\n },\n },\n ':active': {\n backgroundColor: tokens.colorTransparentBackgroundPressed,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Pressed),\n },\n },\n },\n outlineInteractiveSelected: {\n backgroundColor: tokens.colorTransparentBackgroundSelected,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Selected),\n },\n\n ':hover': {\n backgroundColor: tokens.colorTransparentBackgroundSelected,\n },\n },\n\n subtle: {\n backgroundColor: tokens.colorSubtleBackground,\n boxShadow: 'none',\n\n '::after': {\n ...shorthands.borderColor(tokens.colorTransparentStroke),\n },\n },\n subtleInteractive: {\n cursor: 'pointer',\n backgroundColor: tokens.colorSubtleBackground,\n boxShadow: 'none',\n\n '::after': {\n ...shorthands.borderColor(tokens.colorTransparentStroke),\n },\n\n ':hover': {\n backgroundColor: tokens.colorSubtleBackgroundHover,\n },\n ':active': {\n backgroundColor: tokens.colorSubtleBackgroundPressed,\n },\n },\n subtleInteractiveSelected: {\n backgroundColor: tokens.colorSubtleBackgroundSelected,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Selected),\n },\n\n ':hover': {\n backgroundColor: tokens.colorSubtleBackgroundSelected,\n },\n },\n\n select: {\n position: 'absolute',\n top: '4px',\n right: '4px',\n },\n\n selectHidden: {\n width: 0,\n height: 0,\n position: 'absolute',\n top: 0,\n right: 0,\n },\n});\n\nconst getInteractiveClassnames = (state: CardState, styles: ReturnType<typeof useStyles>) => {\n const selectedMap = {\n filled: styles.filledInteractiveSelected,\n 'filled-alternative': styles.filledAlternativeInteractiveSelected,\n outline: styles.outlineInteractiveSelected,\n subtle: styles.subtleInteractiveSelected,\n };\n const interactiveMap = {\n filled: styles.filledInteractive,\n 'filled-alternative': styles.filledAlternativeInteractive,\n outline: styles.outlineInteractive,\n subtle: styles.subtleInteractive,\n };\n const baseClass = mergeClasses(interactiveMap[state.appearance], state.selected && selectedMap[state.appearance]);\n\n if (state.components.root === 'button') {\n return mergeClasses(baseClass, styles.interactiveButton);\n }\n\n if (state.components.root === 'a') {\n return mergeClasses(baseClass, styles.interactiveLink);\n }\n\n return baseClass;\n};\n\n/**\n * Apply styling to the Card slots based on the state.\n */\nexport const useCardStyles_unstable = (state: CardState): CardState => {\n const styles = useStyles();\n\n const orientationMap = {\n horizontal: styles.orientationHorizontal,\n vertical: styles.orientationVertical,\n };\n\n const sizeMap = {\n small: styles.sizeSmall,\n medium: styles.sizeMedium,\n large: styles.sizeLarge,\n };\n\n const appearanceMap = {\n filled: styles.filled,\n 'filled-alternative': styles.filledAlternative,\n outline: styles.outline,\n subtle: styles.subtle,\n };\n\n state.root.className = mergeClasses(\n cardClassNames.root,\n styles.root,\n orientationMap[state.orientation],\n sizeMap[state.size],\n appearanceMap[state.appearance],\n state.interactive && getInteractiveClassnames(state, styles),\n state.root.className,\n );\n\n if (state.select) {\n state.select.className = mergeClasses(\n cardClassNames.select,\n state.hasSelectSlot ? styles.select : styles.selectHidden,\n state.select.className,\n );\n }\n\n return state;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-card/src/components/Card/useCardStyles.ts"],"names":[],"mappings":"AAAA,SAAS,UAAT,YAAiC,YAAjC,QAAqD,gBAArD;AACA,SAAS,MAAT,QAAuB,uBAAvB;AAEA,SAAS,uBAAT,QAAwC,yBAAxC;AAEA,SAAS,qBAAT,QAAsC,qCAAtC;AACA,SAAS,oBAAT,QAAqC,mCAArC;AACA,SAAS,oBAAT,QAAqC,mCAArC;AAGA;;AAEG;;AACH,OAAO,MAAM,cAAc,GAA8B;EACvD,IAAI,EAAE,UADiD;EAEvD,cAAc,EAAE,0BAFuC;EAGvD,QAAQ,EAAE;AAH6C,CAAlD;AAMP;;AAEG;;AACH,OAAO,MAAM,WAAW,GAAG;EACzB,WAAW,EAAE,kBADY;EAEzB,mBAAmB,EAAE;AAFI,CAApB;AAKP,MAAM,iBAAiB,GAAG;EACxB,aAAa,EAAE,OAAO,WAAW,CAAC,mBAAmB,GAD7B;EAExB,YAAY,EAAE,MAAM,CAAC;AAFG,CAA1B;;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AM,CAAC,kBAHK;IAIrB,MAAM,EAAE,MAAM,CAAC;EAJM,CAAvB;EAOA,KAAK,CAAC,IAAN,CAAW,SAAX,GAAuB,YAAY,CACjC,cAAc,CAAC,IADkB,EAEjC,MAAM,CAAC,IAF0B,EAGjC,cAAc,CAAC,KAAK,CAAC,WAAP,CAHmB,EAIjC,OAAO,CAAC,KAAK,CAAC,IAAP,CAJ0B,EAKjC,aAAa,CAAC,KAAK,CAAC,UAAP,CALoB,EAMjC,CAAC,KAAK,CAAC,WAAN,IAAqB,KAAK,CAAC,UAA5B,KAA2C,cAAc,CAAC,KAAK,CAAC,UAAP,CANxB,EAOjC,KAAK,CAAC,QAAN,IAAkB,WAAW,CAAC,KAAK,CAAC,UAAP,CAPI,EAQjC,KAAK,CAAC,aAAN,IAAuB,MAAM,CAAC,iBARG,EASjC,KAAK,CAAC,IAAN,CAAW,SATsB,CAAnC;;EAYA,IAAI,KAAK,CAAC,cAAV,EAA0B;IACxB,KAAK,CAAC,cAAN,CAAqB,SAArB,GAAiC,YAAY,CAC3C,cAAc,CAAC,cAD4B,EAE3C,MAAM,CAAC,MAFoC,EAG3C,KAAK,CAAC,cAAN,CAAqB,SAHsB,CAA7C;EAKD;;EAED,IAAI,KAAK,CAAC,QAAV,EAAoB;IAClB,KAAK,CAAC,QAAN,CAAe,SAAf,GAA2B,YAAY,CAAC,cAAc,CAAC,QAAhB,EAA0B,MAAM,CAAC,cAAjC,EAAiD,KAAK,CAAC,QAAN,CAAe,SAAhE,CAAvC;EACD;;EAED,OAAO,KAAP;AACD,CA3DM","sourcesContent":["import { shorthands, makeStyles, mergeClasses } from '@griffel/react';\nimport { tokens } from '@fluentui/react-theme';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { createFocusOutlineStyle } from '@fluentui/react-tabster';\n\nimport { cardPreviewClassNames } from '../CardPreview/useCardPreviewStyles';\nimport { cardHeaderClassNames } from '../CardHeader/useCardHeaderStyles';\nimport { cardFooterClassNames } from '../CardFooter/useCardFooterStyles';\nimport type { CardSlots, CardState } from './Card.types';\n\n/**\n * Static CSS class names used internally for the component slots.\n */\nexport const cardClassNames: SlotClassNames<CardSlots> = {\n root: 'fui-Card',\n floatingAction: 'fui-Card__floatingAction',\n checkbox: 'fui-Card__checkbox',\n};\n\n/**\n * CSS variable names used internally for uniform styling in Card.\n */\nexport const cardCSSVars = {\n cardSizeVar: '--fui-Card--size',\n cardBorderRadiusVar: '--fui-Card--border-radius',\n};\n\nconst focusOutlineStyle = {\n outlineRadius: `var(${cardCSSVars.cardBorderRadiusVar})`,\n outlineWidth: tokens.strokeWidthThick,\n};\n\nconst useStyles = makeStyles({\n root: {\n ...shorthands.overflow('hidden'),\n ...shorthands.borderRadius(`var(${cardCSSVars.cardBorderRadiusVar})`),\n ...shorthands.padding(`var(${cardCSSVars.cardSizeVar})`),\n ...shorthands.gap(`var(${cardCSSVars.cardSizeVar})`),\n\n display: 'flex',\n position: 'relative',\n boxSizing: 'border-box',\n color: tokens.colorNeutralForeground1,\n\n // Border setting using after pseudo element to allow CardPreview to render behind it.\n '::after': {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n content: '\"\"',\n pointerEvents: 'none',\n\n ...shorthands.borderStyle('solid'),\n ...shorthands.borderWidth(tokens.strokeWidthThin),\n ...shorthands.borderRadius(`var(${cardCSSVars.cardBorderRadiusVar})`),\n },\n\n // Prevents CardHeader and CardFooter from shrinking.\n [`> .${cardHeaderClassNames.root}, > .${cardFooterClassNames.root}`]: {\n flexShrink: 0,\n },\n // Allows non-card components to grow to fill the available space.\n [`> :not(.${cardPreviewClassNames.root}):not(.${cardHeaderClassNames.root}):not(.${cardFooterClassNames.root})`]: {\n flexGrow: 1,\n },\n\n ...createFocusOutlineStyle({\n style: focusOutlineStyle,\n selector: 'focus',\n }),\n },\n\n selectableFocused: createFocusOutlineStyle({\n style: focusOutlineStyle,\n selector: 'focus-within',\n }),\n\n orientationHorizontal: {\n flexDirection: 'row',\n alignItems: 'center',\n\n // Remove vertical padding to keep CardPreview content flush with Card's borders.\n [`> .${cardPreviewClassNames.root}`]: {\n marginTop: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`,\n marginBottom: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`,\n },\n // Due to Tabster's \"Groupper\" focus functionality, hidden elements are injected before and after Card's content.\n // As such, the code below targets a CardPreview, when it's the first element.\n // Since this is on horizontal cards, the left padding is removed to keep the content flush with the border.\n [`> :not([aria-hidden=\"true\"]).${cardPreviewClassNames.root}:first-of-type`]: {\n marginLeft: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`,\n },\n // Due to Tabster's \"Groupper\" focus functionality, hidden elements are injected before and after Card's content.\n // As such, the code below targets a CardPreview, when it's the last element.\n // Since this is on horizontal cards, the right padding is removed to keep the content flush with the border.\n [`> :not([aria-hidden=\"true\"]).${cardPreviewClassNames.root}:last-of-type`]: {\n marginRight: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`,\n },\n },\n orientationVertical: {\n flexDirection: 'column',\n\n // Remove lateral padding to keep CardPreview content flush with Card's borders.\n [`> .${cardPreviewClassNames.root}`]: {\n marginLeft: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`,\n marginRight: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`,\n },\n\n // Due to Tabster's \"Groupper\" focus functionality, hidden elements are injected before and after Card's content.\n // As such, the code below targets a CardPreview, when it's the first element.\n // Since this is on vertical cards, the top padding is removed to keep the content flush with the border.\n [`> :not([aria-hidden=\"true\"]).${cardPreviewClassNames.root}:first-of-type`]: {\n marginTop: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`,\n },\n [`> .${cardClassNames.floatingAction} + .${cardPreviewClassNames.root}`]: {\n marginTop: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`,\n },\n\n // Due to Tabster's \"Groupper\" focus functionality, hidden elements are injected before and after Card's content.\n // As such, the code below targets a CardPreview, when it's the first element.\n // Since this is on vertical cards, the bottom padding is removed to keep the content flush with the border.\n [`> :not([aria-hidden=\"true\"]).${cardPreviewClassNames.root}:last-of-type`]: {\n marginBottom: `calc(var(${cardCSSVars.cardSizeVar}) * -1)`,\n },\n },\n\n sizeSmall: {\n [cardCSSVars.cardSizeVar]: '8px',\n [cardCSSVars.cardBorderRadiusVar]: tokens.borderRadiusSmall,\n },\n sizeMedium: {\n [cardCSSVars.cardSizeVar]: '12px',\n [cardCSSVars.cardBorderRadiusVar]: tokens.borderRadiusMedium,\n },\n sizeLarge: {\n [cardCSSVars.cardSizeVar]: '16px',\n [cardCSSVars.cardBorderRadiusVar]: tokens.borderRadiusLarge,\n },\n\n filled: {\n backgroundColor: tokens.colorNeutralBackground1,\n boxShadow: tokens.shadow4,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorTransparentStroke),\n },\n },\n filledInteractive: {\n cursor: 'pointer',\n backgroundColor: tokens.colorNeutralBackground1,\n boxShadow: tokens.shadow4,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorTransparentStroke),\n },\n\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground1Hover,\n boxShadow: tokens.shadow8,\n },\n ':active': {\n backgroundColor: tokens.colorNeutralBackground1Pressed,\n },\n },\n filledInteractiveSelected: {\n backgroundColor: tokens.colorNeutralBackground1Selected,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Selected),\n },\n\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground1Selected,\n },\n },\n\n filledAlternative: {\n backgroundColor: tokens.colorNeutralBackground2,\n boxShadow: tokens.shadow4,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorTransparentStroke),\n },\n },\n filledAlternativeInteractive: {\n cursor: 'pointer',\n backgroundColor: tokens.colorNeutralBackground2,\n boxShadow: tokens.shadow4,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorTransparentStroke),\n },\n\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground2Hover,\n boxShadow: tokens.shadow8,\n },\n ':active': {\n backgroundColor: tokens.colorNeutralBackground2Pressed,\n },\n },\n filledAlternativeInteractiveSelected: {\n backgroundColor: tokens.colorNeutralBackground2Selected,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Selected),\n },\n\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground2Selected,\n },\n },\n\n outline: {\n backgroundColor: tokens.colorTransparentBackground,\n boxShadow: 'none',\n\n '::after': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1),\n },\n },\n outlineInteractive: {\n cursor: 'pointer',\n backgroundColor: tokens.colorTransparentBackground,\n boxShadow: 'none',\n\n '::after': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1),\n },\n\n ':hover': {\n backgroundColor: tokens.colorTransparentBackgroundHover,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Hover),\n },\n },\n ':active': {\n backgroundColor: tokens.colorTransparentBackgroundPressed,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Pressed),\n },\n },\n },\n outlineInteractiveSelected: {\n backgroundColor: tokens.colorTransparentBackgroundSelected,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Selected),\n },\n\n ':hover': {\n backgroundColor: tokens.colorTransparentBackgroundSelected,\n },\n },\n\n subtle: {\n backgroundColor: tokens.colorSubtleBackground,\n boxShadow: 'none',\n\n '::after': {\n ...shorthands.borderColor(tokens.colorTransparentStroke),\n },\n },\n subtleInteractive: {\n cursor: 'pointer',\n backgroundColor: tokens.colorSubtleBackground,\n boxShadow: 'none',\n\n '::after': {\n ...shorthands.borderColor(tokens.colorTransparentStroke),\n },\n\n ':hover': {\n backgroundColor: tokens.colorSubtleBackgroundHover,\n },\n ':active': {\n backgroundColor: tokens.colorSubtleBackgroundPressed,\n },\n },\n subtleInteractiveSelected: {\n backgroundColor: tokens.colorSubtleBackgroundSelected,\n\n '::after': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Selected),\n },\n\n ':hover': {\n backgroundColor: tokens.colorSubtleBackgroundSelected,\n },\n },\n\n select: {\n position: 'absolute',\n top: '4px',\n right: '4px',\n zIndex: 1,\n },\n\n hiddenCheckbox: {\n ...shorthands.overflow('hidden'),\n width: '1px',\n height: '1px',\n position: 'absolute',\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(50%)',\n whiteSpace: 'nowrap',\n },\n});\n\n/**\n * Apply styling to the Card slots based on the state.\n */\nexport const useCardStyles_unstable = (state: CardState): CardState => {\n const styles = useStyles();\n\n const orientationMap = {\n horizontal: styles.orientationHorizontal,\n vertical: styles.orientationVertical,\n };\n\n const sizeMap = {\n small: styles.sizeSmall,\n medium: styles.sizeMedium,\n large: styles.sizeLarge,\n };\n\n const appearanceMap = {\n filled: styles.filled,\n 'filled-alternative': styles.filledAlternative,\n outline: styles.outline,\n subtle: styles.subtle,\n };\n\n const selectedMap = {\n filled: styles.filledInteractiveSelected,\n 'filled-alternative': styles.filledAlternativeInteractiveSelected,\n outline: styles.outlineInteractiveSelected,\n subtle: styles.subtleInteractiveSelected,\n };\n const interactiveMap = {\n filled: styles.filledInteractive,\n 'filled-alternative': styles.filledAlternativeInteractive,\n outline: styles.outlineInteractive,\n subtle: styles.subtleInteractive,\n };\n\n state.root.className = mergeClasses(\n cardClassNames.root,\n styles.root,\n orientationMap[state.orientation],\n sizeMap[state.size],\n appearanceMap[state.appearance],\n (state.interactive || state.selectable) && interactiveMap[state.appearance],\n state.selected && selectedMap[state.appearance],\n state.selectFocused && styles.selectableFocused,\n state.root.className,\n );\n\n if (state.floatingAction) {\n state.floatingAction.className = mergeClasses(\n cardClassNames.floatingAction,\n styles.select,\n state.floatingAction.className,\n );\n }\n\n if (state.checkbox) {\n state.checkbox.className = mergeClasses(cardClassNames.checkbox, styles.hiddenCheckbox, state.checkbox.className);\n }\n\n return state;\n};\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"file":"CardHeader.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-card/src/components/CardHeader/CardHeader.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\n/**\n * Slots available in the CardHeader component.\n */\nexport type CardHeaderSlots = {\n /**\n * Root element of the component.\n */\n root: Slot<'div'>;\n\n /**\n * Element used to render an image or avatar related to the card.\n */\n image: Slot<'div', 'img'>;\n\n /**\n * Element used to render the main header title.\n */\n header: Slot<'span'>;\n\n /**\n * Element used to render short descriptions related to the title.\n */\n description: Slot<'span'>;\n\n /**\n * Container that renders on the far end of the footer, used for action buttons.\n */\n action?: Slot<'div'>;\n};\n\n/**\n * CardHeader component props.\n */\nexport type CardHeaderProps = ComponentProps<Partial<CardHeaderSlots>>;\n\n/**\n * State used in rendering CardHeader.\n */\nexport type CardHeaderState = ComponentState<CardHeaderSlots>;\n"]}
1
+ {"version":3,"file":"CardHeader.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-card/src/components/CardHeader/CardHeader.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\n/**\n * Slots available in the CardHeader component.\n */\nexport type CardHeaderSlots = {\n /**\n * Root element of the component.\n */\n root: Slot<'div'>;\n\n /**\n * Element used to render an image or avatar related to the card.\n */\n image: Slot<'div', 'img'>;\n\n /**\n * Element used to render the main header title.\n */\n header: Slot<'div'>;\n\n /**\n * Element used to render short descriptions related to the title.\n */\n description: Slot<'div'>;\n\n /**\n * Container that renders on the far end of the footer, used for action buttons.\n */\n action?: Slot<'div'>;\n};\n\n/**\n * CardHeader component props.\n */\nexport type CardHeaderProps = ComponentProps<Partial<CardHeaderSlots>>;\n\n/**\n * State used in rendering CardHeader.\n */\nexport type CardHeaderState = ComponentState<CardHeaderSlots>;\n"]}
@@ -1,4 +1,7 @@
1
- import { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';
1
+ import * as React from 'react';
2
+ import { getNativeElementProps, resolveShorthand, useId } from '@fluentui/react-utilities';
3
+ import { useCardContext_unstable } from '../Card/CardContext';
4
+ import { cardHeaderClassNames } from './useCardHeaderStyles';
2
5
  /**
3
6
  * Create the state required to render CardHeader.
4
7
  *
@@ -16,12 +19,28 @@ export const useCardHeader_unstable = (props, ref) => {
16
19
  description,
17
20
  action
18
21
  } = props;
22
+ const {
23
+ selectableA11yProps: {
24
+ referenceId,
25
+ setReferenceId
26
+ }
27
+ } = useCardContext_unstable();
28
+ const headerRef = React.useRef(null);
29
+ const generatedId = useId(cardHeaderClassNames.header, referenceId);
30
+ React.useEffect(() => {
31
+ if (header && headerRef.current) {
32
+ const {
33
+ id
34
+ } = headerRef.current;
35
+ setReferenceId(id ? id : generatedId);
36
+ }
37
+ }, [header, setReferenceId, generatedId]);
19
38
  return {
20
39
  components: {
21
40
  root: 'div',
22
41
  image: 'div',
23
- header: 'span',
24
- description: 'span',
42
+ header: 'div',
43
+ description: 'div',
25
44
  action: 'div'
26
45
  },
27
46
  root: getNativeElementProps('div', {
@@ -30,7 +49,11 @@ export const useCardHeader_unstable = (props, ref) => {
30
49
  }),
31
50
  image: resolveShorthand(image),
32
51
  header: resolveShorthand(header, {
33
- required: true
52
+ required: true,
53
+ defaultProps: {
54
+ ref: headerRef,
55
+ id: referenceId
56
+ }
34
57
  }),
35
58
  description: resolveShorthand(description),
36
59
  action: resolveShorthand(action)
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-card/src/components/CardHeader/useCardHeader.ts"],"names":[],"mappings":"AACA,SAAS,qBAAT,EAAgC,gBAAhC,QAAwD,2BAAxD;AAGA;;;;;;;;AAQG;;AACH,OAAO,MAAM,sBAAsB,GAAG,CAAC,KAAD,EAAyB,GAAzB,KAAyE;EAC7G,MAAM;IAAE,KAAF;IAAS,MAAT;IAAiB,WAAjB;IAA8B;EAA9B,IAAyC,KAA/C;EAEA,OAAO;IACL,UAAU,EAAE;MACV,IAAI,EAAE,KADI;MAEV,KAAK,EAAE,KAFG;MAGV,MAAM,EAAE,MAHE;MAIV,WAAW,EAAE,MAJH;MAKV,MAAM,EAAE;IALE,CADP;IASL,IAAI,EAAE,qBAAqB,CAAC,KAAD,EAAQ;MACjC,GADiC;MAEjC,GAAG;IAF8B,CAAR,CATtB;IAaL,KAAK,EAAE,gBAAgB,CAAC,KAAD,CAblB;IAcL,MAAM,EAAE,gBAAgB,CAAC,MAAD,EAAS;MAC/B,QAAQ,EAAE;IADqB,CAAT,CAdnB;IAiBL,WAAW,EAAE,gBAAgB,CAAC,WAAD,CAjBxB;IAkBL,MAAM,EAAE,gBAAgB,CAAC,MAAD;EAlBnB,CAAP;AAoBD,CAvBM","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';\nimport type { CardHeaderProps, CardHeaderState } from './CardHeader.types';\n\n/**\n * Create the state required to render CardHeader.\n *\n * The returned state can be modified with hooks such as useCardHeaderStyles_unstable,\n * before being passed to renderCardHeader_unstable.\n *\n * @param props - props from this instance of CardHeader\n * @param ref - reference to root HTMLElement of CardHeader\n */\nexport const useCardHeader_unstable = (props: CardHeaderProps, ref: React.Ref<HTMLElement>): CardHeaderState => {\n const { image, header, description, action } = props;\n\n return {\n components: {\n root: 'div',\n image: 'div',\n header: 'span',\n description: 'span',\n action: 'div',\n },\n\n root: getNativeElementProps('div', {\n ref,\n ...props,\n }),\n image: resolveShorthand(image),\n header: resolveShorthand(header, {\n required: true,\n }),\n description: resolveShorthand(description),\n action: resolveShorthand(action),\n };\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-card/src/components/CardHeader/useCardHeader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,qBAAT,EAAgC,gBAAhC,EAAkD,KAAlD,QAA+D,2BAA/D;AAEA,SAAS,uBAAT,QAAwC,qBAAxC;AACA,SAAS,oBAAT,QAAqC,uBAArC;AAEA;;;;;;;;AAQG;;AACH,OAAO,MAAM,sBAAsB,GAAG,CAAC,KAAD,EAAyB,GAAzB,KAAyE;EAC7G,MAAM;IAAE,KAAF;IAAS,MAAT;IAAiB,WAAjB;IAA8B;EAA9B,IAAyC,KAA/C;EAEA,MAAM;IACJ,mBAAmB,EAAE;MAAE,WAAF;MAAe;IAAf;EADjB,IAEF,uBAAuB,EAF3B;EAGA,MAAM,SAAS,GAAG,KAAK,CAAC,MAAN,CAA6B,IAA7B,CAAlB;EAEA,MAAM,WAAW,GAAG,KAAK,CAAC,oBAAoB,CAAC,MAAtB,EAA8B,WAA9B,CAAzB;EAEA,KAAK,CAAC,SAAN,CAAgB,MAAK;IACnB,IAAI,MAAM,IAAI,SAAS,CAAC,OAAxB,EAAiC;MAC/B,MAAM;QAAE;MAAF,IAAS,SAAS,CAAC,OAAzB;MAEA,cAAc,CAAC,EAAE,GAAG,EAAH,GAAQ,WAAX,CAAd;IACD;EACF,CAND,EAMG,CAAC,MAAD,EAAS,cAAT,EAAyB,WAAzB,CANH;EAQA,OAAO;IACL,UAAU,EAAE;MACV,IAAI,EAAE,KADI;MAEV,KAAK,EAAE,KAFG;MAGV,MAAM,EAAE,KAHE;MAIV,WAAW,EAAE,KAJH;MAKV,MAAM,EAAE;IALE,CADP;IASL,IAAI,EAAE,qBAAqB,CAAC,KAAD,EAAQ;MACjC,GADiC;MAEjC,GAAG;IAF8B,CAAR,CATtB;IAaL,KAAK,EAAE,gBAAgB,CAAC,KAAD,CAblB;IAcL,MAAM,EAAE,gBAAgB,CAAC,MAAD,EAAS;MAC/B,QAAQ,EAAE,IADqB;MAE/B,YAAY,EAAE;QACZ,GAAG,EAAE,SADO;QAEZ,EAAE,EAAE;MAFQ;IAFiB,CAAT,CAdnB;IAqBL,WAAW,EAAE,gBAAgB,CAAC,WAAD,CArBxB;IAsBL,MAAM,EAAE,gBAAgB,CAAC,MAAD;EAtBnB,CAAP;AAwBD,CA1CM","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport type { CardHeaderProps, CardHeaderState } from './CardHeader.types';\nimport { useCardContext_unstable } from '../Card/CardContext';\nimport { cardHeaderClassNames } from './useCardHeaderStyles';\n\n/**\n * Create the state required to render CardHeader.\n *\n * The returned state can be modified with hooks such as useCardHeaderStyles_unstable,\n * before being passed to renderCardHeader_unstable.\n *\n * @param props - props from this instance of CardHeader\n * @param ref - reference to root HTMLElement of CardHeader\n */\nexport const useCardHeader_unstable = (props: CardHeaderProps, ref: React.Ref<HTMLElement>): CardHeaderState => {\n const { image, header, description, action } = props;\n\n const {\n selectableA11yProps: { referenceId, setReferenceId },\n } = useCardContext_unstable();\n const headerRef = React.useRef<HTMLDivElement>(null);\n\n const generatedId = useId(cardHeaderClassNames.header, referenceId);\n\n React.useEffect(() => {\n if (header && headerRef.current) {\n const { id } = headerRef.current;\n\n setReferenceId(id ? id : generatedId);\n }\n }, [header, setReferenceId, generatedId]);\n\n return {\n components: {\n root: 'div',\n image: 'div',\n header: 'div',\n description: 'div',\n action: 'div',\n },\n\n root: getNativeElementProps('div', {\n ref,\n ...props,\n }),\n image: resolveShorthand(image),\n header: resolveShorthand(header, {\n required: true,\n defaultProps: {\n ref: headerRef,\n id: referenceId,\n },\n }),\n description: resolveShorthand(description),\n action: resolveShorthand(action),\n };\n};\n"],"sourceRoot":"../src/"}
@@ -1,4 +1,7 @@
1
- import { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';
1
+ import * as React from 'react';
2
+ import { getNativeElementProps, resolveShorthand, useMergedRefs } from '@fluentui/react-utilities';
3
+ import { useCardContext_unstable } from '../Card/CardContext';
4
+ import { cardPreviewClassNames } from './useCardPreviewStyles';
2
5
  /**
3
6
  * Create the state required to render CardPreview.
4
7
  *
@@ -13,13 +16,44 @@ export const useCardPreview_unstable = (props, ref) => {
13
16
  const {
14
17
  logo
15
18
  } = props;
19
+ const {
20
+ selectableA11yProps: {
21
+ referenceLabel,
22
+ referenceId,
23
+ setReferenceLabel,
24
+ setReferenceId
25
+ }
26
+ } = useCardContext_unstable();
27
+ const previewRef = useMergedRefs(ref, React.useRef(null));
28
+ React.useEffect(() => {
29
+ if (referenceLabel && referenceId) {
30
+ return;
31
+ }
32
+
33
+ if (previewRef.current && previewRef.current.parentNode) {
34
+ const img = previewRef.current.parentNode.querySelector(`.${cardPreviewClassNames.root} > img`);
35
+
36
+ if (img) {
37
+ const ariaLabel = img.getAttribute('aria-label');
38
+ const ariaDescribedby = img.getAttribute('aria-describedby');
39
+
40
+ if (ariaDescribedby) {
41
+ setReferenceId(ariaDescribedby);
42
+ } else if (img.alt) {
43
+ setReferenceLabel(img.alt);
44
+ } else if (ariaLabel) {
45
+ setReferenceLabel(ariaLabel);
46
+ }
47
+ }
48
+ }
49
+ }, [setReferenceLabel, referenceLabel, previewRef, referenceId, setReferenceId]);
16
50
  return {
17
51
  components: {
18
52
  root: 'div',
19
53
  logo: 'div'
20
54
  },
21
55
  root: getNativeElementProps('div', {
22
- ref,
56
+ ref: previewRef,
23
57
  ...props
24
58
  }),
25
59
  logo: resolveShorthand(logo)