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

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 +46 -1
  2. package/CHANGELOG.md +16 -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
package/CHANGELOG.json CHANGED
@@ -2,7 +2,52 @@
2
2
  "name": "@fluentui/react-card",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 05 Dec 2022 18:25:37 GMT",
5
+ "date": "Tue, 20 Dec 2022 14:55:46 GMT",
6
+ "tag": "@fluentui/react-card_v9.0.0-beta.35",
7
+ "version": "9.0.0-beta.35",
8
+ "comments": {
9
+ "prerelease": [
10
+ {
11
+ "author": "marcosvmmoura@gmail.com",
12
+ "package": "@fluentui/react-card",
13
+ "commit": "5a613ed831254b8d8fbb8fd4648bfc034050a7eb",
14
+ "comment": "fix: remove unnecessary selectable ref and add support for aria-describedby on card preview"
15
+ },
16
+ {
17
+ "author": "marcosvmmoura@gmail.com",
18
+ "package": "@fluentui/react-card",
19
+ "commit": "5743aed3aa6b7048694111230c534008a59348ff",
20
+ "comment": "fix selectable card accessibility"
21
+ },
22
+ {
23
+ "author": "beachball",
24
+ "package": "@fluentui/react-card",
25
+ "comment": "Bump @fluentui/react-tabster to v9.3.3",
26
+ "commit": "e7530bc179fd0e303448083c76a4af41a0e15322"
27
+ },
28
+ {
29
+ "author": "beachball",
30
+ "package": "@fluentui/react-card",
31
+ "comment": "Bump @fluentui/react-theme to v9.1.4",
32
+ "commit": "e7530bc179fd0e303448083c76a4af41a0e15322"
33
+ },
34
+ {
35
+ "author": "beachball",
36
+ "package": "@fluentui/react-card",
37
+ "comment": "Bump @fluentui/react-utilities to v9.3.0",
38
+ "commit": "e7530bc179fd0e303448083c76a4af41a0e15322"
39
+ },
40
+ {
41
+ "author": "beachball",
42
+ "package": "@fluentui/react-card",
43
+ "comment": "Bump @fluentui/react-button to v9.1.11",
44
+ "commit": "e7530bc179fd0e303448083c76a4af41a0e15322"
45
+ }
46
+ ]
47
+ }
48
+ },
49
+ {
50
+ "date": "Mon, 05 Dec 2022 18:29:39 GMT",
6
51
  "tag": "@fluentui/react-card_v9.0.0-beta.34",
7
52
  "version": "9.0.0-beta.34",
8
53
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,26 @@
1
1
  # Change Log - @fluentui/react-card
2
2
 
3
- This log was last generated on Mon, 05 Dec 2022 18:25:37 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 20 Dec 2022 14:55:46 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.0.0-beta.35](https://github.com/microsoft/fluentui/tree/@fluentui/react-card_v9.0.0-beta.35)
8
+
9
+ Tue, 20 Dec 2022 14:55:46 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-card_v9.0.0-beta.34..@fluentui/react-card_v9.0.0-beta.35)
11
+
12
+ ### Changes
13
+
14
+ - fix: remove unnecessary selectable ref and add support for aria-describedby on card preview ([PR #25934](https://github.com/microsoft/fluentui/pull/25934) by marcosvmmoura@gmail.com)
15
+ - fix selectable card accessibility ([PR #25827](https://github.com/microsoft/fluentui/pull/25827) by marcosvmmoura@gmail.com)
16
+ - Bump @fluentui/react-tabster to v9.3.3 ([PR #26047](https://github.com/microsoft/fluentui/pull/26047) by beachball)
17
+ - Bump @fluentui/react-theme to v9.1.4 ([PR #26047](https://github.com/microsoft/fluentui/pull/26047) by beachball)
18
+ - Bump @fluentui/react-utilities to v9.3.0 ([PR #26047](https://github.com/microsoft/fluentui/pull/26047) by beachball)
19
+ - Bump @fluentui/react-button to v9.1.11 ([PR #26047](https://github.com/microsoft/fluentui/pull/26047) by beachball)
20
+
7
21
  ## [9.0.0-beta.34](https://github.com/microsoft/fluentui/tree/@fluentui/react-card_v9.0.0-beta.34)
8
22
 
9
- Mon, 05 Dec 2022 18:25:37 GMT
23
+ Mon, 05 Dec 2022 18:29:39 GMT
10
24
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-card_v9.0.0-beta.33..@fluentui/react-card_v9.0.0-beta.34)
11
25
 
12
26
  ### Changes
package/dist/index.d.ts CHANGED
@@ -15,6 +15,18 @@ export declare const Card: ForwardRefComponent<CardProps>;
15
15
  */
16
16
  export declare const cardClassNames: SlotClassNames<CardSlots>;
17
17
 
18
+ /**
19
+ * Data shared between card components
20
+ */
21
+ export declare interface CardContextValue {
22
+ selectableA11yProps: {
23
+ referenceId?: string;
24
+ setReferenceId: (referenceId: string) => void;
25
+ referenceLabel?: string;
26
+ setReferenceLabel: (referenceLabel: string) => void;
27
+ };
28
+ }
29
+
18
30
  /**
19
31
  * CSS variable names used internally for uniform styling in Card.
20
32
  */
@@ -94,11 +106,11 @@ export declare type CardHeaderSlots = {
94
106
  /**
95
107
  * Element used to render the main header title.
96
108
  */
97
- header: Slot<'span'>;
109
+ header: Slot<'div'>;
98
110
  /**
99
111
  * Element used to render short descriptions related to the title.
100
112
  */
101
- description: Slot<'span'>;
113
+ description: Slot<'div'>;
102
114
  /**
103
115
  * Container that renders on the far end of the footer, used for action buttons.
104
116
  */
@@ -117,6 +129,13 @@ declare type CardOnSelectData = {
117
129
  selected: boolean;
118
130
  };
119
131
 
132
+ /**
133
+ * Card selected event type
134
+ *
135
+ * This event is fired when a selectable card changes its selection state.
136
+ */
137
+ export declare type CardOnSelectionChangeEvent = React_2.MouseEvent | React_2.KeyboardEvent | React_2.ChangeEvent;
138
+
120
139
  /**
121
140
  * Component to render image previews of documents or articles in a Card component.
122
141
  */
@@ -213,7 +232,7 @@ export declare type CardProps = ComponentProps<CardSlots> & {
213
232
  */
214
233
  selected?: boolean;
215
234
  /**
216
- * Defines whether the card is initially in a selected state or not when rendered.
235
+ * Defines whether the card is initially in a selected state when rendered.
217
236
  *
218
237
  * @default false
219
238
  */
@@ -221,13 +240,13 @@ export declare type CardProps = ComponentProps<CardSlots> & {
221
240
  /**
222
241
  * Callback to be called when the selected state value changes.
223
242
  */
224
- onSelectionChange?: (event: CarOnSelectionChangeEvent, data: CardOnSelectData) => void;
243
+ onSelectionChange?: (event: CardOnSelectionChangeEvent, data: CardOnSelectData) => void;
225
244
  };
226
245
 
227
246
  /**
228
- * Card refs to the root element slot.
247
+ * @internal
229
248
  */
230
- declare type CardRefElement = HTMLDivElement | HTMLButtonElement | HTMLAnchorElement;
249
+ export declare const CardProvider: React_2.Provider<CardContextValue | undefined>;
231
250
 
232
251
  /**
233
252
  * Slots available in the Card component.
@@ -236,17 +255,21 @@ export declare type CardSlots = {
236
255
  /**
237
256
  * Root element of the component.
238
257
  */
239
- root: Slot<'div', 'a' | 'button'>;
258
+ root: Slot<'div'>;
240
259
  /**
241
260
  * Select element represents a checkbox.
242
261
  */
243
- select?: Slot<'div', 'input'>;
262
+ floatingAction?: Slot<'div'>;
263
+ /**
264
+ * The internal checkbox element that renders when the card is selectable.
265
+ */
266
+ checkbox?: Slot<'input'>;
244
267
  };
245
268
 
246
269
  /**
247
270
  * State used in rendering Card.
248
271
  */
249
- export declare type CardState = ComponentState<CardSlots> & Required<Pick<CardProps, 'appearance' | 'orientation' | 'size'> & {
272
+ export declare type CardState = ComponentState<CardSlots> & CardContextValue & Required<Pick<CardProps, 'appearance' | 'orientation' | 'size'> & {
250
273
  /**
251
274
  * Represents a card that contains interactive events (MouseEvents) or is a button/a tag.
252
275
  *
@@ -260,30 +283,23 @@ export declare type CardState = ComponentState<CardSlots> & Required<Pick<CardPr
260
283
  */
261
284
  selectable: boolean;
262
285
  /**
263
- * Represents a selectable card that contains a slot for the select element.
286
+ * Defines whether the card is currently selected.
264
287
  *
265
288
  * @default false
266
289
  */
267
- hasSelectSlot: boolean;
290
+ selected: boolean;
268
291
  /**
269
- * Defines whether the card is currently selected.
292
+ * Defines whether the card internal checkbox is currently focused.
270
293
  *
271
294
  * @default false
272
295
  */
273
- selected: boolean;
296
+ selectFocused: boolean;
274
297
  }>;
275
298
 
276
- /**
277
- * Card selected event type
278
- *
279
- * This event is fired when a selectable card changes its selection state.
280
- */
281
- export declare type CarOnSelectionChangeEvent = React_2.MouseEvent | React_2.KeyboardEvent | React_2.ChangeEvent;
282
-
283
299
  /**
284
300
  * Render the final JSX of Card.
285
301
  */
286
- export declare const renderCard_unstable: (state: CardState) => JSX.Element;
302
+ export declare const renderCard_unstable: (state: CardState, cardContextValue: CardContextValue) => JSX.Element;
287
303
 
288
304
  /**
289
305
  * Render the final JSX of CardFooter.
@@ -309,7 +325,12 @@ export declare const renderCardPreview_unstable: (state: CardPreviewState) => JS
309
325
  * @param props - props from this instance of Card
310
326
  * @param ref - reference to the root element of Card
311
327
  */
312
- export declare const useCard_unstable: (props: CardProps, ref: React_2.Ref<CardRefElement>) => CardState;
328
+ export declare const useCard_unstable: (props: CardProps, ref: React_2.Ref<HTMLDivElement>) => CardState;
329
+
330
+ /**
331
+ * @internal
332
+ */
333
+ export declare const useCardContext_unstable: () => CardContextValue;
313
334
 
314
335
  /**
315
336
  * Create the state required to render CardFooter.
@@ -2,14 +2,16 @@ import * as React from 'react';
2
2
  import { useCard_unstable } from './useCard';
3
3
  import { renderCard_unstable } from './renderCard';
4
4
  import { useCardStyles_unstable } from './useCardStyles';
5
+ import { useCardContextValue } from './useCardContextValue';
5
6
  /**
6
7
  * A card provides scaffolding for hosting actions and content for a single topic.
7
8
  */
8
9
 
9
10
  export const Card = /*#__PURE__*/React.forwardRef((props, ref) => {
10
11
  const state = useCard_unstable(props, ref);
12
+ const cardContextValue = useCardContextValue(state);
11
13
  useCardStyles_unstable(state);
12
- return renderCard_unstable(state);
14
+ return renderCard_unstable(state, cardContextValue);
13
15
  });
14
16
  Card.displayName = 'Card';
15
17
  //# sourceMappingURL=Card.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-card/src/components/Card/Card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,gBAAT,QAAiC,WAAjC;AACA,SAAS,mBAAT,QAAoC,cAApC;AACA,SAAS,sBAAT,QAAuC,iBAAvC;AAIA;;AAEG;;AACH,OAAO,MAAM,IAAI,gBAAmC,KAAK,CAAC,UAAN,CAAiC,CAAC,KAAD,EAAQ,GAAR,KAAe;EAClG,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAD,EAAQ,GAAR,CAA9B;EAEA,sBAAsB,CAAC,KAAD,CAAtB;EACA,OAAO,mBAAmB,CAAC,KAAD,CAA1B;AACD,CALmD,CAA7C;AAOP,IAAI,CAAC,WAAL,GAAmB,MAAnB","sourcesContent":["import * as React from 'react';\nimport { useCard_unstable } from './useCard';\nimport { renderCard_unstable } from './renderCard';\nimport { useCardStyles_unstable } from './useCardStyles';\nimport type { CardProps, CardRefElement } from './Card.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * A card provides scaffolding for hosting actions and content for a single topic.\n */\nexport const Card: ForwardRefComponent<CardProps> = React.forwardRef<CardRefElement>((props, ref) => {\n const state = useCard_unstable(props, ref);\n\n useCardStyles_unstable(state);\n return renderCard_unstable(state);\n});\n\nCard.displayName = 'Card';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-card/src/components/Card/Card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,gBAAT,QAAiC,WAAjC;AACA,SAAS,mBAAT,QAAoC,cAApC;AACA,SAAS,sBAAT,QAAuC,iBAAvC;AAGA,SAAS,mBAAT,QAAoC,uBAApC;AAEA;;AAEG;;AACH,OAAO,MAAM,IAAI,gBAAmC,KAAK,CAAC,UAAN,CAAiC,CAAC,KAAD,EAAQ,GAAR,KAAe;EAClG,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAD,EAAQ,GAAR,CAA9B;EACA,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,KAAD,CAA5C;EAEA,sBAAsB,CAAC,KAAD,CAAtB;EACA,OAAO,mBAAmB,CAAC,KAAD,EAAQ,gBAAR,CAA1B;AACD,CANmD,CAA7C;AAQP,IAAI,CAAC,WAAL,GAAmB,MAAnB","sourcesContent":["import * as React from 'react';\nimport { useCard_unstable } from './useCard';\nimport { renderCard_unstable } from './renderCard';\nimport { useCardStyles_unstable } from './useCardStyles';\nimport type { CardProps } from './Card.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCardContextValue } from './useCardContextValue';\n\n/**\n * A card provides scaffolding for hosting actions and content for a single topic.\n */\nexport const Card: ForwardRefComponent<CardProps> = React.forwardRef<HTMLDivElement>((props, ref) => {\n const state = useCard_unstable(props, ref);\n const cardContextValue = useCardContextValue(state);\n\n useCardStyles_unstable(state);\n return renderCard_unstable(state, cardContextValue);\n});\n\nCard.displayName = 'Card';\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"file":"Card.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-card/src/components/Card/Card.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\n/**\n * Card refs to the root element slot.\n */\nexport type CardRefElement = HTMLDivElement | HTMLButtonElement | HTMLAnchorElement;\n\n/**\n * Card selected event type\n *\n * This event is fired when a selectable card changes its selection state.\n */\nexport type CarOnSelectionChangeEvent = React.MouseEvent | React.KeyboardEvent | React.ChangeEvent;\n\n/**\n * Data sent from the selection events on a selectable card.\n */\nexport type CardOnSelectData = {\n selected: boolean;\n};\n\n/**\n * Slots available in the Card component.\n */\nexport type CardSlots = {\n /**\n * Root element of the component.\n */\n root: Slot<'div', 'a' | 'button'>;\n\n /**\n * Select element represents a checkbox.\n */\n select?: Slot<'div', 'input'>;\n};\n\n/**\n * Card component props.\n */\nexport type CardProps = ComponentProps<CardSlots> & {\n /**\n * Sets the appearance of the card.\n *\n * `filled`\n * The card will have a shadow, border and background color.\n *\n * `filled-alternative`\n * This appearance is similar to `filled`, but the background color will be a little darker.\n *\n * `outline`\n * This appearance is similar to `filled`, but the background color will be transparent and no shadow applied.\n *\n * `subtle`\n * This appearance is similar to `filled-alternative`, but no border is applied.\n *\n * @default 'filled'\n */\n appearance?: 'filled' | 'filled-alternative' | 'outline' | 'subtle';\n\n /**\n * Sets the focus behavior for the card. If `true`, the card will use the `noTab` focus behavior.\n *\n * `off`\n * The card will not focusable.\n *\n * `no-tab`\n * This behaviour traps the focus inside of the Card when pressing the Enter key and will only release focus when\n * pressing the Escape key.\n *\n * `tab-exit`\n * This behaviour traps the focus inside of the Card when pressing the Enter key but will release focus when pressing\n * the Tab key on the last inner element.\n *\n * `tab-only`\n * This behaviour will cycle through all elements inside of the Card when pressing the Tab key and then release focus\n * after the last inner element.\n *\n * @default 'off'\n */\n focusMode?: 'off' | 'no-tab' | 'tab-exit' | 'tab-only';\n\n /**\n * Defines the orientation of the card.\n *\n * @default 'vertical'\n */\n orientation?: 'horizontal' | 'vertical';\n\n /**\n * Controls the card's border radius and padding between inner elements.\n *\n * @default 'medium'\n */\n size?: 'small' | 'medium' | 'large';\n\n /**\n * Defines the controlled selected state of the card.\n *\n * @default false\n */\n selected?: boolean;\n\n /**\n * Defines whether the card is initially in a selected state or not when rendered.\n *\n * @default false\n */\n defaultSelected?: boolean;\n\n /**\n * Callback to be called when the selected state value changes.\n */\n onSelectionChange?: (event: CarOnSelectionChangeEvent, data: CardOnSelectData) => void;\n};\n\n/**\n * State used in rendering Card.\n */\nexport type CardState = ComponentState<CardSlots> &\n Required<\n Pick<CardProps, 'appearance' | 'orientation' | 'size'> & {\n /**\n * Represents a card that contains interactive events (MouseEvents) or is a button/a tag.\n *\n * @default false\n */\n interactive: boolean;\n\n /**\n * Represents a selectable card.\n *\n * @default false\n */\n selectable: boolean;\n\n /**\n * Represents a selectable card that contains a slot for the select element.\n *\n * @default false\n */\n hasSelectSlot: boolean;\n\n /**\n * Defines whether the card is currently selected.\n *\n * @default false\n */\n selected: boolean;\n }\n >;\n"]}
1
+ {"version":3,"file":"Card.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-card/src/components/Card/Card.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\n/**\n * Card selected event type\n *\n * This event is fired when a selectable card changes its selection state.\n */\nexport type CardOnSelectionChangeEvent = React.MouseEvent | React.KeyboardEvent | React.ChangeEvent;\n\n/**\n * Data sent from the selection events on a selectable card.\n */\nexport type CardOnSelectData = {\n selected: boolean;\n};\n\n/**\n * Data shared between card components\n */\nexport interface CardContextValue {\n selectableA11yProps: {\n referenceId?: string;\n setReferenceId: (referenceId: string) => void;\n referenceLabel?: string;\n setReferenceLabel: (referenceLabel: string) => void;\n };\n}\n\n/**\n * Slots available in the Card component.\n */\nexport type CardSlots = {\n /**\n * Root element of the component.\n */\n root: Slot<'div'>;\n\n /**\n * Select element represents a checkbox.\n */\n floatingAction?: Slot<'div'>;\n\n /**\n * The internal checkbox element that renders when the card is selectable.\n */\n checkbox?: Slot<'input'>;\n};\n\n/**\n * Card component props.\n */\nexport type CardProps = ComponentProps<CardSlots> & {\n /**\n * Sets the appearance of the card.\n *\n * `filled`\n * The card will have a shadow, border and background color.\n *\n * `filled-alternative`\n * This appearance is similar to `filled`, but the background color will be a little darker.\n *\n * `outline`\n * This appearance is similar to `filled`, but the background color will be transparent and no shadow applied.\n *\n * `subtle`\n * This appearance is similar to `filled-alternative`, but no border is applied.\n *\n * @default 'filled'\n */\n appearance?: 'filled' | 'filled-alternative' | 'outline' | 'subtle';\n\n /**\n * Sets the focus behavior for the card. If `true`, the card will use the `noTab` focus behavior.\n *\n * `off`\n * The card will not focusable.\n *\n * `no-tab`\n * This behaviour traps the focus inside of the Card when pressing the Enter key and will only release focus when\n * pressing the Escape key.\n *\n * `tab-exit`\n * This behaviour traps the focus inside of the Card when pressing the Enter key but will release focus when pressing\n * the Tab key on the last inner element.\n *\n * `tab-only`\n * This behaviour will cycle through all elements inside of the Card when pressing the Tab key and then release focus\n * after the last inner element.\n *\n * @default 'off'\n */\n focusMode?: 'off' | 'no-tab' | 'tab-exit' | 'tab-only';\n\n /**\n * Defines the orientation of the card.\n *\n * @default 'vertical'\n */\n orientation?: 'horizontal' | 'vertical';\n\n /**\n * Controls the card's border radius and padding between inner elements.\n *\n * @default 'medium'\n */\n size?: 'small' | 'medium' | 'large';\n\n /**\n * Defines the controlled selected state of the card.\n *\n * @default false\n */\n selected?: boolean;\n\n /**\n * Defines whether the card is initially in a selected state when rendered.\n *\n * @default false\n */\n defaultSelected?: boolean;\n\n /**\n * Callback to be called when the selected state value changes.\n */\n onSelectionChange?: (event: CardOnSelectionChangeEvent, data: CardOnSelectData) => void;\n};\n\n/**\n * State used in rendering Card.\n */\nexport type CardState = ComponentState<CardSlots> &\n CardContextValue &\n Required<\n Pick<CardProps, 'appearance' | 'orientation' | 'size'> & {\n /**\n * Represents a card that contains interactive events (MouseEvents) or is a button/a tag.\n *\n * @default false\n */\n interactive: boolean;\n\n /**\n * Represents a selectable card.\n *\n * @default false\n */\n selectable: boolean;\n\n /**\n * Defines whether the card is currently selected.\n *\n * @default false\n */\n selected: boolean;\n\n /**\n * Defines whether the card internal checkbox is currently focused.\n *\n * @default false\n */\n selectFocused: boolean;\n }\n >;\n"]}
@@ -0,0 +1,37 @@
1
+ import * as React from 'react';
2
+ const cardContext = /*#__PURE__*/React.createContext(undefined);
3
+ /**
4
+ * @internal
5
+ */
6
+
7
+ export const cardContextDefaultValue = {
8
+ selectableA11yProps: {
9
+ referenceId: undefined,
10
+
11
+ setReferenceId() {
12
+ /* Noop */
13
+ },
14
+
15
+ referenceLabel: undefined,
16
+
17
+ setReferenceLabel() {
18
+ /* Noop */
19
+ }
20
+
21
+ }
22
+ };
23
+ /**
24
+ * @internal
25
+ */
26
+
27
+ export const CardProvider = cardContext.Provider;
28
+ /**
29
+ * @internal
30
+ */
31
+
32
+ export const useCardContext_unstable = () => {
33
+ var _a;
34
+
35
+ return (_a = React.useContext(cardContext)) !== null && _a !== void 0 ? _a : cardContextDefaultValue;
36
+ };
37
+ //# sourceMappingURL=CardContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["packages/react-components/react-card/src/components/Card/CardContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAGA,MAAM,WAAW,gBAAG,KAAK,CAAC,aAAN,CAAkD,SAAlD,CAApB;AAEA;;AAEG;;AACH,OAAO,MAAM,uBAAuB,GAAqB;EACvD,mBAAmB,EAAE;IACnB,WAAW,EAAE,SADM;;IAEnB,cAAc,GAAA;MACZ;IACD,CAJkB;;IAKnB,cAAc,EAAE,SALG;;IAMnB,iBAAiB,GAAA;MACf;IACD;;EARkB;AADkC,CAAlD;AAaP;;AAEG;;AACH,OAAO,MAAM,YAAY,GAAG,WAAW,CAAC,QAAjC;AAEP;;AAEG;;AACH,OAAO,MAAM,uBAAuB,GAAG,MAAK;EAAA,IAAA,EAAA;;EAAC,OAAA,CAAA,EAAA,GAAA,KAAK,CAAC,UAAN,CAAiB,WAAjB,CAAA,MAA6B,IAA7B,IAA6B,EAAA,KAAA,KAAA,CAA7B,GAA6B,EAA7B,GAAiC,uBAAjC;AAAwD,CAA9F","sourcesContent":["import * as React from 'react';\nimport { CardContextValue } from './Card.types';\n\nconst cardContext = React.createContext<CardContextValue | undefined>(undefined);\n\n/**\n * @internal\n */\nexport const cardContextDefaultValue: CardContextValue = {\n selectableA11yProps: {\n referenceId: undefined,\n setReferenceId() {\n /* Noop */\n },\n referenceLabel: undefined,\n setReferenceLabel() {\n /* Noop */\n },\n },\n};\n\n/**\n * @internal\n */\nexport const CardProvider = cardContext.Provider;\n\n/**\n * @internal\n */\nexport const useCardContext_unstable = () => React.useContext(cardContext) ?? cardContextDefaultValue;\n"],"sourceRoot":"../src/"}
@@ -1,5 +1,6 @@
1
1
  export * from './Card';
2
2
  export * from './Card.types';
3
+ export * from './CardContext';
3
4
  export * from './renderCard';
4
5
  export * from './useCard';
5
6
  export * from './useCardStyles';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-card/src/components/Card/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './Card';\nexport * from './Card.types';\nexport * from './renderCard';\nexport * from './useCard';\nexport * from './useCardStyles';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-card/src/components/Card/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './Card';\nexport * from './Card.types';\nexport * from './CardContext';\nexport * from './renderCard';\nexport * from './useCard';\nexport * from './useCardStyles';\n"]}
@@ -1,16 +1,20 @@
1
1
  import * as React from 'react';
2
2
  import { getSlots } from '@fluentui/react-utilities';
3
+ import { CardProvider } from './CardContext';
3
4
  /**
4
5
  * Render the final JSX of Card.
5
6
  */
6
7
 
7
- export const renderCard_unstable = state => {
8
+ export const renderCard_unstable = (state, cardContextValue) => {
8
9
  const {
9
10
  slots,
10
11
  slotProps
11
12
  } = getSlots(state);
12
13
  return /*#__PURE__*/React.createElement(slots.root, { ...slotProps.root
13
- }, slotProps.root.children, state.hasSelectSlot && slots.select ? /*#__PURE__*/React.createElement(slots.select, { ...slotProps.select
14
- }) : null);
14
+ }, /*#__PURE__*/React.createElement(CardProvider, {
15
+ value: cardContextValue
16
+ }, slots.checkbox ? /*#__PURE__*/React.createElement(slots.checkbox, { ...slotProps.checkbox
17
+ }) : null, slots.floatingAction ? /*#__PURE__*/React.createElement(slots.floatingAction, { ...slotProps.floatingAction
18
+ }) : null, slotProps.root.children));
15
19
  };
16
20
  //# sourceMappingURL=renderCard.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-card/src/components/Card/renderCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;AAEG;;AACH,OAAO,MAAM,mBAAmB,GAAI,KAAD,IAAqB;EACtD,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,QAAQ,CAAY,KAAZ,CAArC;EAEA,oBACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,EACG,SAAS,CAAC,IAAV,CAAe,QADlB,EAEG,KAAK,CAAC,aAAN,IAAuB,KAAK,CAAC,MAA7B,gBAAsC,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,MAAP,EAAa,EAAA,GAAK,SAAS,CAAC;EAAf,CAAb,CAAtC,GAA+E,IAFlF,CADF;AAMD,CATM","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { CardSlots, CardState } from './Card.types';\n\n/**\n * Render the final JSX of Card.\n */\nexport const renderCard_unstable = (state: CardState) => {\n const { slots, slotProps } = getSlots<CardSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n {slotProps.root.children}\n {state.hasSelectSlot && slots.select ? <slots.select {...slotProps.select} /> : null}\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-card/src/components/Card/renderCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAEA,SAAS,YAAT,QAA6B,eAA7B;AAEA;;AAEG;;AACH,OAAO,MAAM,mBAAmB,GAAG,CAAC,KAAD,EAAmB,gBAAnB,KAAyD;EAC1F,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,QAAQ,CAAY,KAAZ,CAArC;EAEA,oBACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,eACE,KAAA,CAAA,aAAA,CAAC,YAAD,EAAa;IAAC,KAAK,EAAE;EAAR,CAAb,EACG,KAAK,CAAC,QAAN,gBAAiB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,QAAP,EAAe,EAAA,GAAK,SAAS,CAAC;EAAf,CAAf,CAAjB,GAA8D,IADjE,EAEG,KAAK,CAAC,cAAN,gBAAuB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,cAAP,EAAqB,EAAA,GAAK,SAAS,CAAC;EAAf,CAArB,CAAvB,GAAgF,IAFnF,EAGG,SAAS,CAAC,IAAV,CAAe,QAHlB,CADF,CADF;AASD,CAZM","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { CardContextValue, CardSlots, CardState } from './Card.types';\nimport { CardProvider } from './CardContext';\n\n/**\n * Render the final JSX of Card.\n */\nexport const renderCard_unstable = (state: CardState, cardContextValue: CardContextValue) => {\n const { slots, slotProps } = getSlots<CardSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n <CardProvider value={cardContextValue}>\n {slots.checkbox ? <slots.checkbox {...slotProps.checkbox} /> : null}\n {slots.floatingAction ? <slots.floatingAction {...slotProps.floatingAction} /> : null}\n {slotProps.root.children}\n </CardProvider>\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
@@ -1,31 +1,38 @@
1
1
  import * as React from 'react';
2
- import { getNativeElementProps } from '@fluentui/react-utilities';
3
- import { useFocusableGroup } from '@fluentui/react-tabster';
2
+ import { getNativeElementProps, resolveShorthand, useMergedRefs } from '@fluentui/react-utilities';
3
+ import { useFocusableGroup, useFocusWithin } from '@fluentui/react-tabster';
4
4
  import { useCardSelectable } from './useCardSelectable';
5
+ import { cardContextDefaultValue } from './CardContext';
5
6
  const focusMap = {
6
7
  off: undefined,
7
8
  'no-tab': 'limited-trap-focus',
8
9
  'tab-exit': 'limited',
9
10
  'tab-only': 'unlimited'
10
11
  };
12
+ /**
13
+ * Create the state for interactive cards.
14
+ *
15
+ * This internal hook defines if the card is interactive
16
+ * and control focus properties based on that.
17
+ *
18
+ * @param props - props from this instance of Card
19
+ */
11
20
 
12
- const useCardFocusAttributes = ({
13
- focusMode = 'off'
14
- }, {
15
- interactive
21
+ const useCardInteractive = ({
22
+ focusMode = 'off',
23
+ ...props
16
24
  }) => {
17
- const internalFocusMode = interactive ? 'no-tab' : focusMode;
25
+ const interactive = ['onClick', 'onDoubleClick', 'onMouseUp', 'onMouseDown', 'onPointerUp', 'onPointerDown', 'onTouchStart', 'onTouchEnd', 'onDragStart', 'onDragEnd'].some(prop => props[prop]);
18
26
  const groupperAttrs = useFocusableGroup({
19
- tabBehavior: focusMap[internalFocusMode]
27
+ tabBehavior: focusMap[interactive ? 'no-tab' : focusMode]
20
28
  });
21
-
22
- if (internalFocusMode === 'off') {
23
- return null;
24
- }
25
-
26
- return { ...groupperAttrs,
29
+ const interactiveFocusAttributes = { ...groupperAttrs,
27
30
  tabIndex: 0
28
31
  };
32
+ return {
33
+ interactive,
34
+ focusAttributes: focusMode === 'off' ? null : interactiveFocusAttributes
35
+ };
29
36
  };
30
37
  /**
31
38
  * Create the state required to render Card.
@@ -43,40 +50,54 @@ export const useCard_unstable = (props, ref) => {
43
50
  appearance = 'filled',
44
51
  orientation = 'vertical',
45
52
  size = 'medium',
46
- as = 'div'
53
+ floatingAction
47
54
  } = props;
48
- const cardRef = React.useRef(null);
55
+ const [referenceId, setReferenceId] = React.useState(cardContextDefaultValue.selectableA11yProps.referenceId);
56
+ const [referenceLabel, setReferenceLabel] = React.useState(cardContextDefaultValue.selectableA11yProps.referenceId);
57
+ const cardBaseRef = useFocusWithin();
49
58
  const {
50
59
  selectable,
51
- hasSelectSlot,
52
60
  selected,
53
- selectableSlot,
54
- selectableProps
55
- } = useCardSelectable(props, cardRef);
56
- const interactive = Boolean(selectable || ['a', 'button'].includes(as) || props.onClick || props.onDoubleClick || props.onMouseUp || props.onMouseDown || props.onPointerUp || props.onPointerDown || props.onTouchStart || props.onTouchEnd);
57
- const focusAttributes = useCardFocusAttributes(props, {
58
- interactive
59
- });
61
+ selectableCardProps,
62
+ selectFocused,
63
+ checkboxSlot
64
+ } = useCardSelectable(props, {
65
+ referenceId,
66
+ referenceLabel
67
+ }, cardBaseRef);
68
+ const cardRef = useMergedRefs(cardBaseRef, ref);
69
+ const {
70
+ interactive,
71
+ focusAttributes
72
+ } = useCardInteractive(props);
60
73
  return {
61
74
  appearance,
62
75
  orientation,
63
76
  size,
64
77
  interactive,
65
78
  selectable,
66
- hasSelectSlot,
79
+ selectFocused,
67
80
  selected,
81
+ selectableA11yProps: {
82
+ setReferenceId,
83
+ referenceId,
84
+ referenceLabel,
85
+ setReferenceLabel
86
+ },
68
87
  components: {
69
- root: as,
70
- select: 'div'
88
+ root: 'div',
89
+ floatingAction: 'div',
90
+ checkbox: 'input'
71
91
  },
72
- root: getNativeElementProps(as, {
73
- ref: ref || cardRef,
92
+ root: getNativeElementProps('div', {
93
+ ref: cardRef,
74
94
  role: 'group',
75
95
  ...focusAttributes,
76
96
  ...props,
77
- ...selectableProps
97
+ ...selectableCardProps
78
98
  }),
79
- select: selectableSlot
99
+ floatingAction: resolveShorthand(floatingAction),
100
+ checkbox: checkboxSlot
80
101
  };
81
102
  };
82
103
  //# sourceMappingURL=useCard.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-card/src/components/Card/useCard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,qBAAT,QAAsC,2BAAtC;AACA,SAAS,iBAAT,QAAkC,yBAAlC;AAGA,SAAS,iBAAT,QAAkC,qBAAlC;AAEA,MAAM,QAAQ,GAAG;EACf,GAAG,EAAE,SADU;EAEf,UAAU,oBAFK;EAGf,YAAY,SAHG;EAIf,YAAY;AAJG,CAAjB;;AAWA,MAAM,sBAAsB,GAAG,CAAC;EAAE,SAAS,GAAG;AAAd,CAAD,EAAmC;EAAE;AAAF,CAAnC,KAAqF;EAClH,MAAM,iBAAiB,GAAG,WAAW,GAAG,QAAH,GAAc,SAAnD;EAEA,MAAM,aAAa,GAAG,iBAAiB,CAAC;IACtC,WAAW,EAAE,QAAQ,CAAC,iBAAD;EADiB,CAAD,CAAvC;;EAIA,IAAI,iBAAiB,KAAK,KAA1B,EAAiC;IAC/B,OAAO,IAAP;EACD;;EAED,OAAO,EACL,GAAG,aADE;IAEL,QAAQ,EAAE;EAFL,CAAP;AAID,CAfD;AAiBA;;;;;;;;AAQG;;;AACH,OAAO,MAAM,gBAAgB,GAAG,CAAC,KAAD,EAAmB,GAAnB,KAAgE;EAC9F,MAAM;IAAE,UAAU,GAAG,QAAf;IAAyB,WAAW,GAAG,UAAvC;IAAmD,IAAI,GAAG,QAA1D;IAAoE,EAAE,GAAG;EAAzE,IAAmF,KAAzF;EACA,MAAM,OAAO,GAAG,KAAK,CAAC,MAAN,CAA6B,IAA7B,CAAhB;EAEA,MAAM;IAAE,UAAF;IAAc,aAAd;IAA6B,QAA7B;IAAuC,cAAvC;IAAuD;EAAvD,IAA2E,iBAAiB,CAAC,KAAD,EAAQ,OAAR,CAAlG;EAEA,MAAM,WAAW,GAAG,OAAO,CACzB,UAAU,IACR,CAAC,GAAD,EAAM,QAAN,EAAgB,QAAhB,CAAyB,EAAzB,CADF,IAEE,KAAK,CAAC,OAFR,IAGE,KAAK,CAAC,aAHR,IAIE,KAAK,CAAC,SAJR,IAKE,KAAK,CAAC,WALR,IAME,KAAK,CAAC,WANR,IAOE,KAAK,CAAC,aAPR,IAQE,KAAK,CAAC,YARR,IASE,KAAK,CAAC,UAViB,CAA3B;EAaA,MAAM,eAAe,GAAG,sBAAsB,CAAC,KAAD,EAAQ;IAAE;EAAF,CAAR,CAA9C;EAEA,OAAO;IACL,UADK;IAEL,WAFK;IAGL,IAHK;IAIL,WAJK;IAKL,UALK;IAML,aANK;IAOL,QAPK;IASL,UAAU,EAAE;MACV,IAAI,EAAE,EADI;MAEV,MAAM,EAAE;IAFE,CATP;IAcL,IAAI,EAAE,qBAAqB,CAAC,EAAD,EAAK;MAC9B,GAAG,EAAE,GAAG,IAAI,OADkB;MAE9B,IAAI,EAAE,OAFwB;MAG9B,GAAG,eAH2B;MAI9B,GAAG,KAJ2B;MAK9B,GAAG;IAL2B,CAAL,CAdtB;IAsBL,MAAM,EAAE;EAtBH,CAAP;AAwBD,CA7CM","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps } from '@fluentui/react-utilities';\nimport { useFocusableGroup } from '@fluentui/react-tabster';\n\nimport type { CardProps, CardRefElement, CardState } from './Card.types';\nimport { useCardSelectable } from './useCardSelectable';\n\nconst focusMap = {\n off: undefined,\n 'no-tab': 'limited-trap-focus',\n 'tab-exit': 'limited',\n 'tab-only': 'unlimited',\n} as const;\n\ntype UseCardFocusAttributesOptions = {\n interactive: boolean;\n};\n\nconst useCardFocusAttributes = ({ focusMode = 'off' }: CardProps, { interactive }: UseCardFocusAttributesOptions) => {\n const internalFocusMode = interactive ? 'no-tab' : focusMode;\n\n const groupperAttrs = useFocusableGroup({\n tabBehavior: focusMap[internalFocusMode],\n });\n\n if (internalFocusMode === 'off') {\n return null;\n }\n\n return {\n ...groupperAttrs,\n tabIndex: 0,\n };\n};\n\n/**\n * Create the state required to render Card.\n *\n * The returned state can be modified with hooks such as useCardStyles_unstable,\n * before being passed to renderCard_unstable.\n *\n * @param props - props from this instance of Card\n * @param ref - reference to the root element of Card\n */\nexport const useCard_unstable = (props: CardProps, ref: React.Ref<CardRefElement>): CardState => {\n const { appearance = 'filled', orientation = 'vertical', size = 'medium', as = 'div' } = props;\n const cardRef = React.useRef<CardRefElement>(null);\n\n const { selectable, hasSelectSlot, selected, selectableSlot, selectableProps } = useCardSelectable(props, cardRef);\n\n const interactive = Boolean(\n selectable ||\n ['a', 'button'].includes(as) ||\n props.onClick ||\n props.onDoubleClick ||\n props.onMouseUp ||\n props.onMouseDown ||\n props.onPointerUp ||\n props.onPointerDown ||\n props.onTouchStart ||\n props.onTouchEnd,\n );\n\n const focusAttributes = useCardFocusAttributes(props, { interactive });\n\n return {\n appearance,\n orientation,\n size,\n interactive,\n selectable,\n hasSelectSlot,\n selected,\n\n components: {\n root: as,\n select: 'div',\n },\n\n root: getNativeElementProps(as, {\n ref: ref || cardRef,\n role: 'group',\n ...focusAttributes,\n ...props,\n ...selectableProps,\n }),\n\n select: selectableSlot,\n };\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-card/src/components/Card/useCard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,qBAAT,EAAgC,gBAAhC,EAAkD,aAAlD,QAAuE,2BAAvE;AACA,SAAS,iBAAT,EAA4B,cAA5B,QAAkD,yBAAlD;AAGA,SAAS,iBAAT,QAAkC,qBAAlC;AACA,SAAS,uBAAT,QAAwC,eAAxC;AAEA,MAAM,QAAQ,GAAG;EACf,GAAG,EAAE,SADU;EAEf,UAAU,oBAFK;EAGf,YAAY,SAHG;EAIf,YAAY;AAJG,CAAjB;AAOA;;;;;;;AAOG;;AACH,MAAM,kBAAkB,GAAG,CAAC;EAAE,SAAS,GAAG,KAAd;EAAqB,GAAG;AAAxB,CAAD,KAA+C;EACxE,MAAM,WAAW,GAAI,CACnB,SADmB,EAEnB,eAFmB,EAGnB,WAHmB,EAInB,aAJmB,EAKnB,aALmB,EAMnB,eANmB,EAOnB,cAPmB,EAQnB,YARmB,EASnB,aATmB,EAUnB,WAVmB,EAW6B,IAX7B,CAWkC,IAAI,IAAI,KAAK,CAAC,IAAD,CAX/C,CAArB;EAaA,MAAM,aAAa,GAAG,iBAAiB,CAAC;IACtC,WAAW,EAAE,QAAQ,CAAC,WAAW,GAAG,QAAH,GAAc,SAA1B;EADiB,CAAD,CAAvC;EAIA,MAAM,0BAA0B,GAAG,EACjC,GAAG,aAD8B;IAEjC,QAAQ,EAAE;EAFuB,CAAnC;EAKA,OAAO;IACL,WADK;IAEL,eAAe,EAAE,SAAS,KAAK,KAAd,GAAsB,IAAtB,GAA6B;EAFzC,CAAP;AAID,CA3BD;AA6BA;;;;;;;;AAQG;;;AACH,OAAO,MAAM,gBAAgB,GAAG,CAAC,KAAD,EAAmB,GAAnB,KAAgE;EAC9F,MAAM;IAAE,UAAU,GAAG,QAAf;IAAyB,WAAW,GAAG,UAAvC;IAAmD,IAAI,GAAG,QAA1D;IAAoE;EAApE,IAAuF,KAA7F;EAEA,MAAM,CAAC,WAAD,EAAc,cAAd,IAAgC,KAAK,CAAC,QAAN,CAAe,uBAAuB,CAAC,mBAAxB,CAA4C,WAA3D,CAAtC;EACA,MAAM,CAAC,cAAD,EAAiB,iBAAjB,IAAsC,KAAK,CAAC,QAAN,CAAe,uBAAuB,CAAC,mBAAxB,CAA4C,WAA3D,CAA5C;EAEA,MAAM,WAAW,GAAG,cAAc,EAAlC;EACA,MAAM;IAAE,UAAF;IAAc,QAAd;IAAwB,mBAAxB;IAA6C,aAA7C;IAA4D;EAA5D,IAA6E,iBAAiB,CAClG,KADkG,EAElG;IAAE,WAAF;IAAe;EAAf,CAFkG,EAGlG,WAHkG,CAApG;EAMA,MAAM,OAAO,GAAG,aAAa,CAAC,WAAD,EAAc,GAAd,CAA7B;EAEA,MAAM;IAAE,WAAF;IAAe;EAAf,IAAmC,kBAAkB,CAAC,KAAD,CAA3D;EAEA,OAAO;IACL,UADK;IAEL,WAFK;IAGL,IAHK;IAIL,WAJK;IAKL,UALK;IAML,aANK;IAOL,QAPK;IAQL,mBAAmB,EAAE;MACnB,cADmB;MAEnB,WAFmB;MAGnB,cAHmB;MAInB;IAJmB,CARhB;IAeL,UAAU,EAAE;MACV,IAAI,EAAE,KADI;MAEV,cAAc,EAAE,KAFN;MAGV,QAAQ,EAAE;IAHA,CAfP;IAqBL,IAAI,EAAE,qBAAqB,CAAC,KAAD,EAAQ;MACjC,GAAG,EAAE,OAD4B;MAEjC,IAAI,EAAE,OAF2B;MAGjC,GAAG,eAH8B;MAIjC,GAAG,KAJ8B;MAKjC,GAAG;IAL8B,CAAR,CArBtB;IA6BL,cAAc,EAAE,gBAAgB,CAAC,cAAD,CA7B3B;IA8BL,QAAQ,EAAE;EA9BL,CAAP;AAgCD,CAjDM","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, resolveShorthand, useMergedRefs } from '@fluentui/react-utilities';\nimport { useFocusableGroup, useFocusWithin } from '@fluentui/react-tabster';\n\nimport type { CardProps, CardState } from './Card.types';\nimport { useCardSelectable } from './useCardSelectable';\nimport { cardContextDefaultValue } from './CardContext';\n\nconst focusMap = {\n off: undefined,\n 'no-tab': 'limited-trap-focus',\n 'tab-exit': 'limited',\n 'tab-only': 'unlimited',\n} as const;\n\n/**\n * Create the state for interactive cards.\n *\n * This internal hook defines if the card is interactive\n * and control focus properties based on that.\n *\n * @param props - props from this instance of Card\n */\nconst useCardInteractive = ({ focusMode = 'off', ...props }: CardProps) => {\n const interactive = ([\n 'onClick',\n 'onDoubleClick',\n 'onMouseUp',\n 'onMouseDown',\n 'onPointerUp',\n 'onPointerDown',\n 'onTouchStart',\n 'onTouchEnd',\n 'onDragStart',\n 'onDragEnd',\n ] as (keyof React.HTMLAttributes<HTMLElement>)[]).some(prop => props[prop]);\n\n const groupperAttrs = useFocusableGroup({\n tabBehavior: focusMap[interactive ? 'no-tab' : focusMode],\n });\n\n const interactiveFocusAttributes = {\n ...groupperAttrs,\n tabIndex: 0,\n };\n\n return {\n interactive,\n focusAttributes: focusMode === 'off' ? null : interactiveFocusAttributes,\n };\n};\n\n/**\n * Create the state required to render Card.\n *\n * The returned state can be modified with hooks such as useCardStyles_unstable,\n * before being passed to renderCard_unstable.\n *\n * @param props - props from this instance of Card\n * @param ref - reference to the root element of Card\n */\nexport const useCard_unstable = (props: CardProps, ref: React.Ref<HTMLDivElement>): CardState => {\n const { appearance = 'filled', orientation = 'vertical', size = 'medium', floatingAction } = props;\n\n const [referenceId, setReferenceId] = React.useState(cardContextDefaultValue.selectableA11yProps.referenceId);\n const [referenceLabel, setReferenceLabel] = React.useState(cardContextDefaultValue.selectableA11yProps.referenceId);\n\n const cardBaseRef = useFocusWithin<HTMLDivElement>();\n const { selectable, selected, selectableCardProps, selectFocused, checkboxSlot } = useCardSelectable(\n props,\n { referenceId, referenceLabel },\n cardBaseRef,\n );\n\n const cardRef = useMergedRefs(cardBaseRef, ref);\n\n const { interactive, focusAttributes } = useCardInteractive(props);\n\n return {\n appearance,\n orientation,\n size,\n interactive,\n selectable,\n selectFocused,\n selected,\n selectableA11yProps: {\n setReferenceId,\n referenceId,\n referenceLabel,\n setReferenceLabel,\n },\n\n components: {\n root: 'div',\n floatingAction: 'div',\n checkbox: 'input',\n },\n\n root: getNativeElementProps('div', {\n ref: cardRef,\n role: 'group',\n ...focusAttributes,\n ...props,\n ...selectableCardProps,\n }),\n\n floatingAction: resolveShorthand(floatingAction),\n checkbox: checkboxSlot,\n };\n};\n"],"sourceRoot":"../src/"}
@@ -0,0 +1,8 @@
1
+ export function useCardContextValue({
2
+ selectableA11yProps
3
+ }) {
4
+ return {
5
+ selectableA11yProps
6
+ };
7
+ }
8
+ //# sourceMappingURL=useCardContextValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["packages/react-components/react-card/src/components/Card/useCardContextValue.ts"],"names":[],"mappings":"AAEA,OAAM,SAAU,mBAAV,CAA8B;EAAE;AAAF,CAA9B,EAAgE;EACpE,OAAO;IAAE;EAAF,CAAP;AACD","sourcesContent":["import type { CardContextValue, CardState } from './Card.types';\n\nexport function useCardContextValue({ selectableA11yProps }: CardState): CardContextValue {\n return { selectableA11yProps };\n}\n"],"sourceRoot":"../src/"}