@fluentui/react-card 9.0.0-rc.2 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.json +34 -1
  2. package/CHANGELOG.md +14 -2
  3. package/README.md +2 -2
  4. package/lib-amd/Card.js +6 -0
  5. package/lib-amd/Card.js.map +1 -0
  6. package/lib-amd/CardFooter.js +6 -0
  7. package/lib-amd/CardFooter.js.map +1 -0
  8. package/lib-amd/CardHeader.js +6 -0
  9. package/lib-amd/CardHeader.js.map +1 -0
  10. package/lib-amd/CardPreview.js +6 -0
  11. package/lib-amd/CardPreview.js.map +1 -0
  12. package/lib-amd/components/Card/Card.js +16 -0
  13. package/lib-amd/components/Card/Card.js.map +1 -0
  14. package/lib-amd/components/Card/Card.types.js +5 -0
  15. package/lib-amd/components/Card/Card.types.js.map +1 -0
  16. package/lib-amd/components/Card/CardContext.js +31 -0
  17. package/lib-amd/components/Card/CardContext.js.map +1 -0
  18. package/lib-amd/components/Card/index.js +11 -0
  19. package/lib-amd/components/Card/index.js.map +1 -0
  20. package/lib-amd/components/Card/renderCard.js +18 -0
  21. package/lib-amd/components/Card/renderCard.js.map +1 -0
  22. package/lib-amd/components/Card/useCard.js +85 -0
  23. package/lib-amd/components/Card/useCard.js.map +1 -0
  24. package/lib-amd/components/Card/useCardContextValue.js +11 -0
  25. package/lib-amd/components/Card/useCardContextValue.js.map +1 -0
  26. package/lib-amd/components/Card/useCardSelectable.js +97 -0
  27. package/lib-amd/components/Card/useCardSelectable.js.map +1 -0
  28. package/lib-amd/components/Card/useCardStyles.js +253 -0
  29. package/lib-amd/components/Card/useCardStyles.js.map +1 -0
  30. package/lib-amd/components/CardFooter/CardFooter.js +15 -0
  31. package/lib-amd/components/CardFooter/CardFooter.js.map +1 -0
  32. package/lib-amd/components/CardFooter/CardFooter.types.js +5 -0
  33. package/lib-amd/components/CardFooter/CardFooter.types.js.map +1 -0
  34. package/lib-amd/components/CardFooter/index.js +10 -0
  35. package/lib-amd/components/CardFooter/index.js.map +1 -0
  36. package/lib-amd/components/CardFooter/renderCardFooter.js +16 -0
  37. package/lib-amd/components/CardFooter/renderCardFooter.js.map +1 -0
  38. package/lib-amd/components/CardFooter/useCardFooter.js +27 -0
  39. package/lib-amd/components/CardFooter/useCardFooter.js.map +1 -0
  40. package/lib-amd/components/CardFooter/useCardFooterStyles.js +31 -0
  41. package/lib-amd/components/CardFooter/useCardFooterStyles.js.map +1 -0
  42. package/lib-amd/components/CardHeader/CardHeader.js +15 -0
  43. package/lib-amd/components/CardHeader/CardHeader.js.map +1 -0
  44. package/lib-amd/components/CardHeader/CardHeader.types.js +5 -0
  45. package/lib-amd/components/CardHeader/CardHeader.types.js.map +1 -0
  46. package/lib-amd/components/CardHeader/index.js +10 -0
  47. package/lib-amd/components/CardHeader/index.js.map +1 -0
  48. package/lib-amd/components/CardHeader/renderCardHeader.js +18 -0
  49. package/lib-amd/components/CardHeader/renderCardHeader.js.map +1 -0
  50. package/lib-amd/components/CardHeader/useCardHeader.js +48 -0
  51. package/lib-amd/components/CardHeader/useCardHeader.js.map +1 -0
  52. package/lib-amd/components/CardHeader/useCardHeaderStyles.js +72 -0
  53. package/lib-amd/components/CardHeader/useCardHeaderStyles.js.map +1 -0
  54. package/lib-amd/components/CardPreview/CardPreview.js +15 -0
  55. package/lib-amd/components/CardPreview/CardPreview.js.map +1 -0
  56. package/lib-amd/components/CardPreview/CardPreview.types.js +5 -0
  57. package/lib-amd/components/CardPreview/CardPreview.types.js.map +1 -0
  58. package/lib-amd/components/CardPreview/index.js +10 -0
  59. package/lib-amd/components/CardPreview/index.js.map +1 -0
  60. package/lib-amd/components/CardPreview/renderCardPreview.js +16 -0
  61. package/lib-amd/components/CardPreview/renderCardPreview.js.map +1 -0
  62. package/lib-amd/components/CardPreview/useCardPreview.js +50 -0
  63. package/lib-amd/components/CardPreview/useCardPreview.js.map +1 -0
  64. package/lib-amd/components/CardPreview/useCardPreviewStyles.js +44 -0
  65. package/lib-amd/components/CardPreview/useCardPreviewStyles.js.map +1 -0
  66. package/lib-amd/index.js +30 -0
  67. package/lib-amd/index.js.map +1 -0
  68. package/package.json +5 -7
package/CHANGELOG.json CHANGED
@@ -2,7 +2,40 @@
2
2
  "name": "@fluentui/react-card",
3
3
  "entries": [
4
4
  {
5
- "date": "Fri, 10 Mar 2023 07:11:11 GMT",
5
+ "date": "Mon, 13 Mar 2023 08:54:59 GMT",
6
+ "tag": "@fluentui/react-card_v9.0.0",
7
+ "version": "9.0.0",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "marcosvmmoura@gmail.com",
12
+ "package": "@fluentui/react-card",
13
+ "commit": "bd95bf8602d7cf036fbdd7c718343bf1bc43367d",
14
+ "comment": "feat: release 9.0.0"
15
+ },
16
+ {
17
+ "author": "beachball",
18
+ "package": "@fluentui/react-card",
19
+ "comment": "Bump @fluentui/react-tabster to v9.5.6",
20
+ "commit": "edf96a6b5d6f13843ada1400480e347b84384b8e"
21
+ },
22
+ {
23
+ "author": "beachball",
24
+ "package": "@fluentui/react-card",
25
+ "comment": "Bump @fluentui/react-utilities to v9.7.0",
26
+ "commit": "edf96a6b5d6f13843ada1400480e347b84384b8e"
27
+ },
28
+ {
29
+ "author": "beachball",
30
+ "package": "@fluentui/react-card",
31
+ "comment": "Bump @fluentui/react-button to v9.3.2",
32
+ "commit": "edf96a6b5d6f13843ada1400480e347b84384b8e"
33
+ }
34
+ ]
35
+ }
36
+ },
37
+ {
38
+ "date": "Fri, 10 Mar 2023 07:14:01 GMT",
6
39
  "tag": "@fluentui/react-card_v9.0.0-rc.2",
7
40
  "version": "9.0.0-rc.2",
8
41
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,24 @@
1
1
  # Change Log - @fluentui/react-card
2
2
 
3
- This log was last generated on Fri, 10 Mar 2023 07:11:11 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 13 Mar 2023 08:54:59 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.0.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-card_v9.0.0)
8
+
9
+ Mon, 13 Mar 2023 08:54:59 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-card_v9.0.0-rc.2..@fluentui/react-card_v9.0.0)
11
+
12
+ ### Patches
13
+
14
+ - feat: release 9.0.0 ([PR #27111](https://github.com/microsoft/fluentui/pull/27111) by marcosvmmoura@gmail.com)
15
+ - Bump @fluentui/react-tabster to v9.5.6 ([PR #27161](https://github.com/microsoft/fluentui/pull/27161) by beachball)
16
+ - Bump @fluentui/react-utilities to v9.7.0 ([PR #27161](https://github.com/microsoft/fluentui/pull/27161) by beachball)
17
+ - Bump @fluentui/react-button to v9.3.2 ([PR #27161](https://github.com/microsoft/fluentui/pull/27161) by beachball)
18
+
7
19
  ## [9.0.0-rc.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-card_v9.0.0-rc.2)
8
20
 
9
- Fri, 10 Mar 2023 07:11:11 GMT
21
+ Fri, 10 Mar 2023 07:14:01 GMT
10
22
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-card_v9.0.0-rc.1..@fluentui/react-card_v9.0.0-rc.2)
11
23
 
12
24
  ### Changes
package/README.md CHANGED
@@ -11,7 +11,7 @@ These are not production-ready components and **should never be used in a produc
11
11
  To import React Card components:
12
12
 
13
13
  ```js
14
- import { Card, CardPreview, CardHeader, CardFooter } from "@fluentui/react-components/unstable';
14
+ import { Card, CardPreview, CardHeader, CardFooter } from "@fluentui/react-components';
15
15
  ```
16
16
 
17
17
  Example Card usage:
@@ -21,7 +21,7 @@ Example Card usage:
21
21
  ```jsx
22
22
  import { Share16Regular, ArrowReply16Regular } from '@fluentui/react-icons';
23
23
  import { Button, Body1, Caption1 } from '@fluentui/react-components';
24
- import { Card, CardHeader, CardPreview, CardFooter } from '@fluentui/react-components/unstable';
24
+ import { Card, CardHeader, CardPreview, CardFooter } from '@fluentui/react-components';
25
25
 
26
26
  const App = () => (
27
27
  <>
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/Card/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=Card.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-card/src/Card.ts"],"names":[],"mappings":";;;IAAA,uCAAwC","sourcesContent":["export * from './components/Card/index';\n"]}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/CardFooter/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=CardFooter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardFooter.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-card/src/CardFooter.ts"],"names":[],"mappings":";;;IAAA,uCAA8C","sourcesContent":["export * from './components/CardFooter/index';\n"]}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/CardHeader/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=CardHeader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardHeader.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-card/src/CardHeader.ts"],"names":[],"mappings":";;;IAAA,uCAA8C","sourcesContent":["export * from './components/CardHeader/index';\n"]}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/CardPreview/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=CardPreview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardPreview.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-card/src/CardPreview.ts"],"names":[],"mappings":";;;IAAA,uCAA+C","sourcesContent":["export * from './components/CardPreview/index';\n"]}
@@ -0,0 +1,16 @@
1
+ define(["require", "exports", "react", "./useCard", "./renderCard", "./useCardStyles", "./useCardContextValue"], function (require, exports, React, useCard_1, renderCard_1, useCardStyles_1, useCardContextValue_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Card = void 0;
5
+ /**
6
+ * A card provides scaffolding for hosting actions and content for a single topic.
7
+ */
8
+ exports.Card = React.forwardRef(function (props, ref) {
9
+ var state = useCard_1.useCard_unstable(props, ref);
10
+ var cardContextValue = useCardContextValue_1.useCardContextValue(state);
11
+ useCardStyles_1.useCardStyles_unstable(state);
12
+ return renderCard_1.renderCard_unstable(state, cardContextValue);
13
+ });
14
+ exports.Card.displayName = 'Card';
15
+ });
16
+ //# sourceMappingURL=Card.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-card/src/components/Card/Card.tsx"],"names":[],"mappings":";;;;IAQA;;OAEG;IACU,QAAA,IAAI,GAAmC,KAAK,CAAC,UAAU,CAAiB,UAAC,KAAK,EAAE,GAAG;QAC9F,IAAM,KAAK,GAAG,0BAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC3C,IAAM,gBAAgB,GAAG,yCAAmB,CAAC,KAAK,CAAC,CAAC;QAEpD,sCAAsB,CAAC,KAAK,CAAC,CAAC;QAC9B,OAAO,gCAAmB,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,YAAI,CAAC,WAAW,GAAG,MAAM,CAAC","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"]}
@@ -0,0 +1,5 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ });
5
+ //# sourceMappingURL=Card.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card.types.js","sourceRoot":"","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 * Floating action that can be rendered on the top-right of a card. Often used together with\n * `selected`, `defaultSelected`, and `onSelectionChange` props\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.\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,31 @@
1
+ define(["require", "exports", "react"], function (require, exports, React) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useCardContext_unstable = exports.CardProvider = exports.cardContextDefaultValue = void 0;
5
+ var cardContext = React.createContext(undefined);
6
+ /**
7
+ * @internal
8
+ */
9
+ exports.cardContextDefaultValue = {
10
+ selectableA11yProps: {
11
+ referenceId: undefined,
12
+ setReferenceId: function () {
13
+ /* Noop */
14
+ },
15
+ referenceLabel: undefined,
16
+ setReferenceLabel: function () {
17
+ /* Noop */
18
+ },
19
+ },
20
+ };
21
+ /**
22
+ * @internal
23
+ */
24
+ exports.CardProvider = cardContext.Provider;
25
+ /**
26
+ * @internal
27
+ */
28
+ var useCardContext_unstable = function () { var _a; return (_a = React.useContext(cardContext)) !== null && _a !== void 0 ? _a : exports.cardContextDefaultValue; };
29
+ exports.useCardContext_unstable = useCardContext_unstable;
30
+ });
31
+ //# sourceMappingURL=CardContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardContext.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-card/src/components/Card/CardContext.ts"],"names":[],"mappings":";;;;IAGA,IAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAA+B,SAAS,CAAC,CAAC;IAEjF;;OAEG;IACU,QAAA,uBAAuB,GAAqB;QACvD,mBAAmB,EAAE;YACnB,WAAW,EAAE,SAAS;YACtB,cAAc;gBACZ,UAAU;YACZ,CAAC;YACD,cAAc,EAAE,SAAS;YACzB,iBAAiB;gBACf,UAAU;YACZ,CAAC;SACF;KACF,CAAC;IAEF;;OAEG;IACU,QAAA,YAAY,GAAG,WAAW,CAAC,QAAQ,CAAC;IAEjD;;OAEG;IACI,IAAM,uBAAuB,GAAG,sBAAM,OAAA,MAAA,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,mCAAI,+BAAuB,CAAA,EAAA,CAAC;IAAzF,QAAA,uBAAuB,2BAAkE","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"]}
@@ -0,0 +1,11 @@
1
+ define(["require", "exports", "tslib", "./Card", "./Card.types", "./CardContext", "./renderCard", "./useCard", "./useCardStyles"], function (require, exports, tslib_1, Card_1, Card_types_1, CardContext_1, renderCard_1, useCard_1, useCardStyles_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(Card_1, exports);
5
+ tslib_1.__exportStar(Card_types_1, exports);
6
+ tslib_1.__exportStar(CardContext_1, exports);
7
+ tslib_1.__exportStar(renderCard_1, exports);
8
+ tslib_1.__exportStar(useCard_1, exports);
9
+ tslib_1.__exportStar(useCardStyles_1, exports);
10
+ });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-card/src/components/Card/index.ts"],"names":[],"mappings":";;;IAAA,sCAAuB;IACvB,4CAA6B;IAC7B,6CAA8B;IAC9B,4CAA6B;IAC7B,yCAA0B;IAC1B,+CAAgC","sourcesContent":["export * from './Card';\nexport * from './Card.types';\nexport * from './CardContext';\nexport * from './renderCard';\nexport * from './useCard';\nexport * from './useCardStyles';\n"]}
@@ -0,0 +1,18 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "./CardContext"], function (require, exports, tslib_1, React, react_utilities_1, CardContext_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.renderCard_unstable = void 0;
5
+ /**
6
+ * Render the final JSX of Card.
7
+ */
8
+ var renderCard_unstable = function (state, cardContextValue) {
9
+ var _a = react_utilities_1.getSlots(state), slots = _a.slots, slotProps = _a.slotProps;
10
+ return (React.createElement(slots.root, tslib_1.__assign({}, slotProps.root),
11
+ React.createElement(CardContext_1.CardProvider, { value: cardContextValue },
12
+ slots.checkbox ? React.createElement(slots.checkbox, tslib_1.__assign({}, slotProps.checkbox)) : null,
13
+ slots.floatingAction ? React.createElement(slots.floatingAction, tslib_1.__assign({}, slotProps.floatingAction)) : null,
14
+ slotProps.root.children)));
15
+ };
16
+ exports.renderCard_unstable = renderCard_unstable;
17
+ });
18
+ //# sourceMappingURL=renderCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderCard.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-card/src/components/Card/renderCard.tsx"],"names":[],"mappings":";;;;IAKA;;OAEG;IACI,IAAM,mBAAmB,GAAG,UAAC,KAAgB,EAAE,gBAAkC;QAChF,IAAA,KAAuB,0BAAQ,CAAY,KAAK,CAAC,EAA/C,KAAK,WAAA,EAAE,SAAS,eAA+B,CAAC;QAExD,OAAO,CACL,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI;YAC5B,oBAAC,0BAAY,IAAC,KAAK,EAAE,gBAAgB;gBAClC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,oBAAC,KAAK,CAAC,QAAQ,uBAAK,SAAS,CAAC,QAAQ,EAAI,CAAC,CAAC,CAAC,IAAI;gBAClE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,oBAAC,KAAK,CAAC,cAAc,uBAAK,SAAS,CAAC,cAAc,EAAI,CAAC,CAAC,CAAC,IAAI;gBACpF,SAAS,CAAC,IAAI,CAAC,QAAQ,CACX,CACJ,CACd,CAAC;IACJ,CAAC,CAAC;IAZW,QAAA,mBAAmB,uBAY9B","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"]}
@@ -0,0 +1,85 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@fluentui/react-tabster", "./useCardSelectable", "./CardContext"], function (require, exports, tslib_1, React, react_utilities_1, react_tabster_1, useCardSelectable_1, CardContext_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useCard_unstable = void 0;
5
+ var focusMap = {
6
+ off: undefined,
7
+ 'no-tab': 'limited-trap-focus',
8
+ 'tab-exit': 'limited',
9
+ 'tab-only': 'unlimited',
10
+ };
11
+ /**
12
+ * Create the state for interactive cards.
13
+ *
14
+ * This internal hook defines if the card is interactive
15
+ * and control focus properties based on that.
16
+ *
17
+ * @param props - props from this instance of Card
18
+ */
19
+ var useCardInteractive = function (_a) {
20
+ var _b = _a.focusMode, focusMode = _b === void 0 ? 'off' : _b, props = tslib_1.__rest(_a, ["focusMode"]);
21
+ var interactive = [
22
+ 'onClick',
23
+ 'onDoubleClick',
24
+ 'onMouseUp',
25
+ 'onMouseDown',
26
+ 'onPointerUp',
27
+ 'onPointerDown',
28
+ 'onTouchStart',
29
+ 'onTouchEnd',
30
+ 'onDragStart',
31
+ 'onDragEnd',
32
+ ].some(function (prop) { return props[prop]; });
33
+ var groupperAttrs = react_tabster_1.useFocusableGroup({
34
+ tabBehavior: focusMap[interactive ? 'no-tab' : focusMode],
35
+ });
36
+ var interactiveFocusAttributes = tslib_1.__assign(tslib_1.__assign({}, groupperAttrs), { tabIndex: 0 });
37
+ return {
38
+ interactive: interactive,
39
+ focusAttributes: focusMode === 'off' ? null : interactiveFocusAttributes,
40
+ };
41
+ };
42
+ /**
43
+ * Create the state required to render Card.
44
+ *
45
+ * The returned state can be modified with hooks such as useCardStyles_unstable,
46
+ * before being passed to renderCard_unstable.
47
+ *
48
+ * @param props - props from this instance of Card
49
+ * @param ref - reference to the root element of Card
50
+ */
51
+ var useCard_unstable = function (props, ref) {
52
+ var _a = props.appearance, appearance = _a === void 0 ? 'filled' : _a, _b = props.orientation, orientation = _b === void 0 ? 'vertical' : _b, _c = props.size, size = _c === void 0 ? 'medium' : _c;
53
+ var _d = React.useState(CardContext_1.cardContextDefaultValue.selectableA11yProps.referenceId), referenceId = _d[0], setReferenceId = _d[1];
54
+ var _e = React.useState(CardContext_1.cardContextDefaultValue.selectableA11yProps.referenceId), referenceLabel = _e[0], setReferenceLabel = _e[1];
55
+ var cardBaseRef = react_tabster_1.useFocusWithin();
56
+ var _f = useCardSelectable_1.useCardSelectable(props, { referenceId: referenceId, referenceLabel: referenceLabel }, cardBaseRef), selectable = _f.selectable, selected = _f.selected, selectableCardProps = _f.selectableCardProps, selectFocused = _f.selectFocused, checkboxSlot = _f.checkboxSlot, floatingActionSlot = _f.floatingActionSlot;
57
+ var cardRef = react_utilities_1.useMergedRefs(cardBaseRef, ref);
58
+ var _g = useCardInteractive(props), interactive = _g.interactive, focusAttributes = _g.focusAttributes;
59
+ return {
60
+ appearance: appearance,
61
+ orientation: orientation,
62
+ size: size,
63
+ interactive: interactive,
64
+ selectable: selectable,
65
+ selectFocused: selectFocused,
66
+ selected: selected,
67
+ selectableA11yProps: {
68
+ setReferenceId: setReferenceId,
69
+ referenceId: referenceId,
70
+ referenceLabel: referenceLabel,
71
+ setReferenceLabel: setReferenceLabel,
72
+ },
73
+ components: {
74
+ root: 'div',
75
+ floatingAction: 'div',
76
+ checkbox: 'input',
77
+ },
78
+ root: react_utilities_1.getNativeElementProps('div', tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ ref: cardRef, role: 'group' }, focusAttributes), props), selectableCardProps)),
79
+ floatingAction: floatingActionSlot,
80
+ checkbox: checkboxSlot,
81
+ };
82
+ };
83
+ exports.useCard_unstable = useCard_unstable;
84
+ });
85
+ //# sourceMappingURL=useCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCard.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-card/src/components/Card/useCard.ts"],"names":[],"mappings":";;;;IAQA,IAAM,QAAQ,GAAG;QACf,GAAG,EAAE,SAAS;QACd,QAAQ,EAAE,oBAAoB;QAC9B,UAAU,EAAE,SAAS;QACrB,UAAU,EAAE,WAAW;KACf,CAAC;IAEX;;;;;;;OAOG;IACH,IAAM,kBAAkB,GAAG,UAAC,EAA0C;QAAxC,IAAA,iBAAiB,EAAjB,SAAS,mBAAG,KAAK,KAAA,EAAK,KAAK,sBAA7B,aAA+B,CAAF;QACvD,IAAM,WAAW,GACf;YACE,SAAS;YACT,eAAe;YACf,WAAW;YACX,aAAa;YACb,aAAa;YACb,eAAe;YACf,cAAc;YACd,YAAY;YACZ,aAAa;YACb,WAAW;SAEd,CAAC,IAAI,CAAC,UAAA,IAAI,IAAI,OAAA,KAAK,CAAC,IAAI,CAAC,EAAX,CAAW,CAAC,CAAC;QAE5B,IAAM,aAAa,GAAG,iCAAiB,CAAC;YACtC,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;SAC1D,CAAC,CAAC;QAEH,IAAM,0BAA0B,yCAC3B,aAAa,KAChB,QAAQ,EAAE,CAAC,GACZ,CAAC;QAEF,OAAO;YACL,WAAW,aAAA;YACX,eAAe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AAc,gBAAA;gBACd,WAAW,aAAA;gBACX,cAAc,gBAAA;gBACd,iBAAiB,mBAAA;aAClB;YAED,UAAU,EAAE;gBACV,IAAI,EAAE,KAAK;gBACX,cAAc,EAAE,KAAK;gBACrB,QAAQ,EAAE,OAAO;aAClB;YAED,IAAI,EAAE,uCAAqB,CAAC,KAAK,uDAC/B,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,OAAO,IACV,eAAe,GACf,KAAK,GACL,mBAAmB,EACtB;YAEF,cAAc,EAAE,kBAAkB;YAClC,QAAQ,EAAE,YAAY;SACvB,CAAC;IACJ,CAAC,CAAC;IA9CW,QAAA,gBAAgB,oBA8C3B","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, 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 [\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>)[]\n ).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' } = 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, floatingActionSlot } =\n useCardSelectable(props, { referenceId, referenceLabel }, cardBaseRef);\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: floatingActionSlot,\n checkbox: checkboxSlot,\n };\n};\n"]}
@@ -0,0 +1,11 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useCardContextValue = void 0;
5
+ function useCardContextValue(_a) {
6
+ var selectableA11yProps = _a.selectableA11yProps;
7
+ return { selectableA11yProps: selectableA11yProps };
8
+ }
9
+ exports.useCardContextValue = useCardContextValue;
10
+ });
11
+ //# sourceMappingURL=useCardContextValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCardContextValue.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-card/src/components/Card/useCardContextValue.ts"],"names":[],"mappings":";;;;IAEA,SAAgB,mBAAmB,CAAC,EAAkC;YAAhC,mBAAmB,yBAAA;QACvD,OAAO,EAAE,mBAAmB,qBAAA,EAAE,CAAC;IACjC,CAAC;IAFD,kDAEC","sourcesContent":["import type { CardContextValue, CardState } from './Card.types';\n\nexport function useCardContextValue({ selectableA11yProps }: CardState): CardContextValue {\n return { selectableA11yProps };\n}\n"]}
@@ -0,0 +1,97 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@fluentui/keyboard-keys", "@fluentui/react-tabster"], function (require, exports, tslib_1, React, react_utilities_1, keyboard_keys_1, react_tabster_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useCardSelectable = void 0;
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
+ var useCardSelectable = function (props, _a, cardRef) {
18
+ var referenceLabel = _a.referenceLabel, referenceId = _a.referenceId;
19
+ var _b = props.checkbox, checkbox = _b === void 0 ? {} : _b, selected = props.selected, defaultSelected = props.defaultSelected, onSelectionChange = props.onSelectionChange, floatingAction = props.floatingAction, onClick = props.onClick, onKeyDown = props.onKeyDown;
20
+ var findAllFocusable = react_tabster_1.useFocusFinders().findAllFocusable;
21
+ var checkboxRef = React.useRef(null);
22
+ var isSelectable = [selected, defaultSelected, onSelectionChange].some(function (prop) { return typeof prop !== 'undefined'; });
23
+ var _c = React.useState(false), isCardSelected = _c[0], setIsCardSelected = _c[1];
24
+ var _d = React.useState(false), isSelectFocused = _d[0], setIsSelectFocused = _d[1];
25
+ var shouldRestrictTriggerAction = React.useCallback(function (event) {
26
+ if (!cardRef.current) {
27
+ return false;
28
+ }
29
+ var focusableElements = findAllFocusable(cardRef.current);
30
+ var target = event.target;
31
+ var isElementInFocusableGroup = focusableElements.some(function (element) { return element.contains(target); });
32
+ var isCheckboxSlot = (checkboxRef === null || checkboxRef === void 0 ? void 0 : checkboxRef.current) === target;
33
+ return isElementInFocusableGroup && !isCheckboxSlot;
34
+ }, [cardRef, findAllFocusable]);
35
+ var onChangeHandler = React.useCallback(function (event) {
36
+ if (shouldRestrictTriggerAction(event)) {
37
+ return;
38
+ }
39
+ var newCheckedValue = !isCardSelected;
40
+ setIsCardSelected(newCheckedValue);
41
+ if (onSelectionChange) {
42
+ onSelectionChange(event, { selected: newCheckedValue });
43
+ }
44
+ }, [onSelectionChange, isCardSelected, shouldRestrictTriggerAction]);
45
+ var onKeyDownHandler = React.useCallback(function (event) {
46
+ if ([keyboard_keys_1.Enter].includes(event.key)) {
47
+ event.preventDefault();
48
+ onChangeHandler(event);
49
+ }
50
+ }, [onChangeHandler]);
51
+ var checkboxSlot = React.useMemo(function () {
52
+ if (!isSelectable || floatingAction) {
53
+ return;
54
+ }
55
+ var selectableCheckboxProps = {};
56
+ if (referenceId) {
57
+ selectableCheckboxProps['aria-labelledby'] = referenceId;
58
+ }
59
+ else if (referenceLabel) {
60
+ selectableCheckboxProps['aria-label'] = referenceLabel;
61
+ }
62
+ return react_utilities_1.resolveShorthand(checkbox, {
63
+ defaultProps: tslib_1.__assign({ ref: checkboxRef, type: 'checkbox', checked: isCardSelected, onChange: function (event) { return onChangeHandler(event); }, onFocus: function () { return setIsSelectFocused(true); }, onBlur: function () { return setIsSelectFocused(false); } }, selectableCheckboxProps),
64
+ });
65
+ }, [checkbox, floatingAction, isCardSelected, isSelectable, onChangeHandler, referenceId, referenceLabel]);
66
+ var floatingActionSlot = React.useMemo(function () {
67
+ if (!floatingAction) {
68
+ return;
69
+ }
70
+ return react_utilities_1.resolveShorthand(floatingAction, {
71
+ defaultProps: {
72
+ ref: checkboxRef,
73
+ },
74
+ });
75
+ }, [floatingAction]);
76
+ var selectableCardProps = React.useMemo(function () {
77
+ if (!isSelectable) {
78
+ return null;
79
+ }
80
+ return {
81
+ onClick: react_utilities_1.mergeCallbacks(onClick, onChangeHandler),
82
+ onKeyDown: react_utilities_1.mergeCallbacks(onKeyDown, onKeyDownHandler),
83
+ };
84
+ }, [isSelectable, onChangeHandler, onClick, onKeyDown, onKeyDownHandler]);
85
+ React.useEffect(function () { return setIsCardSelected(Boolean(defaultSelected !== null && defaultSelected !== void 0 ? defaultSelected : selected)); }, [defaultSelected, selected, setIsCardSelected]);
86
+ return {
87
+ selected: isCardSelected,
88
+ selectable: isSelectable,
89
+ selectFocused: isSelectFocused,
90
+ selectableCardProps: selectableCardProps,
91
+ checkboxSlot: checkboxSlot,
92
+ floatingActionSlot: floatingActionSlot,
93
+ };
94
+ };
95
+ exports.useCardSelectable = useCardSelectable;
96
+ });
97
+ //# sourceMappingURL=useCardSelectable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCardSelectable.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-card/src/components/Card/useCardSelectable.ts"],"names":[],"mappings":";;;;IAOA;;;;;;;;;;;OAWG;IACI,IAAM,iBAAiB,GAAG,UAC/B,KAAgB,EAChB,EAAgH,EAChH,OAAwC;YADtC,cAAc,oBAAA,EAAE,WAAW,iBAAA;QAGrB,IAAA,KAAoG,KAAK,SAA5F,EAAb,QAAQ,mBAAG,EAAE,KAAA,EAAE,QAAQ,GAA6E,KAAK,SAAlF,EAAE,eAAe,GAA4D,KAAK,gBAAjE,EAAE,iBAAiB,GAAyC,KAAK,kBAA9C,EAAE,cAAc,GAAyB,KAAK,eAA9B,EAAE,OAAO,GAAgB,KAAK,QAArB,EAAE,SAAS,GAAK,KAAK,UAAV,CAAW;QAE1G,IAAA,gBAAgB,GAAK,+BAAe,EAAE,iBAAtB,CAAuB;QAE/C,IAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAmB,IAAI,CAAC,CAAC;QAEzD,IAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,eAAe,EAAE,iBA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,cAAc,EAAE;gBACnB,OAAO;aACR;YAED,OAAO,kCAAgB,CAAC,cAAc,EAAE;gBACtC,YAAY,EAAE;oBACZ,GAAG,EAAE,WAAW;iBACjB;aACF,CAAC,CAAC;QACL,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;QAErB,IAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,CAAC;YACxC,IAAI,CAAC,YAAY,EAAE;gBACjB,OAAO,IAAI,CAAC;aACb;YAED,OAAO;gBACL,OAAO,EAAE,gCAAc,CAAC,OAAO,EAAE,eAAe,CAAC;gBACjD,SAAS,EAAE,gCAAc,CAAC,SAAS,EAAE,gBAAgB,CAAC;aACvD,CAAC;QACJ,CAAC,EAAE,CAAC,YAAY,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC;QAE1E,KAAK,CAAC,SAAS,CACb,cAAM,OAAA,iBAAiB,CAAC,OAAO,CAAC,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,QAAQ,CAAC,CAAC,EAAvD,CAAuD,EAC7D,CAAC,eAAe,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAC/C,CAAC;QAEF,OAAO;YACL,QAAQ,EAAE,cAAc;YACxB,UAAU,EAAE,YAAY;YACxB,aAAa,EAAE,eAAe;YAC9B,mBAAmB,qBAAA;YACnB,YAAY,cAAA;YACZ,kBAAkB,oBAAA;SACnB,CAAC;IACJ,CAAC,CAAC;IAzHW,QAAA,iBAAiB,qBAyH5B","sourcesContent":["import * as React from 'react';\nimport { mergeCallbacks, resolveShorthand } from '@fluentui/react-utilities';\nimport { Enter } from '@fluentui/keyboard-keys';\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].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 }, [checkbox, floatingAction, isCardSelected, isSelectable, onChangeHandler, referenceId, referenceLabel]);\n\n const floatingActionSlot = React.useMemo(() => {\n if (!floatingAction) {\n return;\n }\n\n return resolveShorthand(floatingAction, {\n defaultProps: {\n ref: checkboxRef,\n },\n });\n }, [floatingAction]);\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(\n () => setIsCardSelected(Boolean(defaultSelected ?? selected)),\n [defaultSelected, selected, setIsCardSelected],\n );\n\n return {\n selected: isCardSelected,\n selectable: isSelectable,\n selectFocused: isSelectFocused,\n selectableCardProps,\n checkboxSlot,\n floatingActionSlot,\n };\n};\n"]}