@fluentui/react-card 9.0.40 → 9.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.json CHANGED
@@ -2,7 +2,103 @@
2
2
  "name": "@fluentui/react-card",
3
3
  "entries": [
4
4
  {
5
- "date": "Wed, 20 Sep 2023 17:40:42 GMT",
5
+ "date": "Tue, 26 Sep 2023 17:44:08 GMT",
6
+ "tag": "@fluentui/react-card_v9.0.42",
7
+ "version": "9.0.42",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "yuanboxue@microsoft.com",
12
+ "package": "@fluentui/react-card",
13
+ "commit": "05a23f6f5f331841c9ac9fb63764440c543f791d",
14
+ "comment": "chore: trigger manual version bump after broken release"
15
+ },
16
+ {
17
+ "author": "beachball",
18
+ "package": "@fluentui/react-card",
19
+ "comment": "Bump @fluentui/keyboard-keys to v9.0.6",
20
+ "commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
21
+ },
22
+ {
23
+ "author": "beachball",
24
+ "package": "@fluentui/react-card",
25
+ "comment": "Bump @fluentui/react-tabster to v9.13.1",
26
+ "commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
27
+ },
28
+ {
29
+ "author": "beachball",
30
+ "package": "@fluentui/react-card",
31
+ "comment": "Bump @fluentui/react-theme to v9.1.14",
32
+ "commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
33
+ },
34
+ {
35
+ "author": "beachball",
36
+ "package": "@fluentui/react-card",
37
+ "comment": "Bump @fluentui/react-utilities to v9.13.5",
38
+ "commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
39
+ },
40
+ {
41
+ "author": "beachball",
42
+ "package": "@fluentui/react-card",
43
+ "comment": "Bump @fluentui/react-jsx-runtime to v9.0.12",
44
+ "commit": "05a23f6f5f331841c9ac9fb63764440c543f791d"
45
+ }
46
+ ]
47
+ }
48
+ },
49
+ {
50
+ "date": "Tue, 26 Sep 2023 15:32:03 GMT",
51
+ "tag": "@fluentui/react-card_v9.0.41",
52
+ "version": "9.0.41",
53
+ "comments": {
54
+ "patch": [
55
+ {
56
+ "author": "marcosvmmoura@gmail.com",
57
+ "package": "@fluentui/react-card",
58
+ "commit": "c1ae0fb42575ae2deb11b32110538adbd0f652ad",
59
+ "comment": "fix: sync controllable state for selectable cards"
60
+ },
61
+ {
62
+ "author": "martinhochel@microsoft.com",
63
+ "package": "@fluentui/react-card",
64
+ "commit": "e61473fa10195f6ebf2308205c1e72e91b711831",
65
+ "comment": "fix: bump swc core to mitigate transpilation memory leaks"
66
+ },
67
+ {
68
+ "author": "beachball",
69
+ "package": "@fluentui/react-card",
70
+ "comment": "Bump @fluentui/keyboard-keys to v9.0.5",
71
+ "commit": "e16520437e10cd824ac254dd797e32762b5de72d"
72
+ },
73
+ {
74
+ "author": "beachball",
75
+ "package": "@fluentui/react-card",
76
+ "comment": "Bump @fluentui/react-tabster to v9.13.0",
77
+ "commit": "e16520437e10cd824ac254dd797e32762b5de72d"
78
+ },
79
+ {
80
+ "author": "beachball",
81
+ "package": "@fluentui/react-card",
82
+ "comment": "Bump @fluentui/react-theme to v9.1.13",
83
+ "commit": "e16520437e10cd824ac254dd797e32762b5de72d"
84
+ },
85
+ {
86
+ "author": "beachball",
87
+ "package": "@fluentui/react-card",
88
+ "comment": "Bump @fluentui/react-utilities to v9.13.4",
89
+ "commit": "e16520437e10cd824ac254dd797e32762b5de72d"
90
+ },
91
+ {
92
+ "author": "beachball",
93
+ "package": "@fluentui/react-card",
94
+ "comment": "Bump @fluentui/react-jsx-runtime to v9.0.11",
95
+ "commit": "e16520437e10cd824ac254dd797e32762b5de72d"
96
+ }
97
+ ]
98
+ }
99
+ },
100
+ {
101
+ "date": "Wed, 20 Sep 2023 17:47:35 GMT",
6
102
  "tag": "@fluentui/react-card_v9.0.40",
7
103
  "version": "9.0.40",
8
104
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,41 @@
1
1
  # Change Log - @fluentui/react-card
2
2
 
3
- This log was last generated on Wed, 20 Sep 2023 17:40:42 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 26 Sep 2023 17:44:08 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.0.42](https://github.com/microsoft/fluentui/tree/@fluentui/react-card_v9.0.42)
8
+
9
+ Tue, 26 Sep 2023 17:44:08 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-card_v9.0.41..@fluentui/react-card_v9.0.42)
11
+
12
+ ### Patches
13
+
14
+ - chore: trigger manual version bump after broken release ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by yuanboxue@microsoft.com)
15
+ - Bump @fluentui/keyboard-keys to v9.0.6 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
16
+ - Bump @fluentui/react-tabster to v9.13.1 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
17
+ - Bump @fluentui/react-theme to v9.1.14 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
18
+ - Bump @fluentui/react-utilities to v9.13.5 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
19
+ - Bump @fluentui/react-jsx-runtime to v9.0.12 ([PR #29303](https://github.com/microsoft/fluentui/pull/29303) by beachball)
20
+
21
+ ## [9.0.41](https://github.com/microsoft/fluentui/tree/@fluentui/react-card_v9.0.41)
22
+
23
+ Tue, 26 Sep 2023 15:32:03 GMT
24
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-card_v9.0.40..@fluentui/react-card_v9.0.41)
25
+
26
+ ### Patches
27
+
28
+ - fix: sync controllable state for selectable cards ([PR #29276](https://github.com/microsoft/fluentui/pull/29276) by marcosvmmoura@gmail.com)
29
+ - fix: bump swc core to mitigate transpilation memory leaks ([PR #29253](https://github.com/microsoft/fluentui/pull/29253) by martinhochel@microsoft.com)
30
+ - Bump @fluentui/keyboard-keys to v9.0.5 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
31
+ - Bump @fluentui/react-tabster to v9.13.0 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
32
+ - Bump @fluentui/react-theme to v9.1.13 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
33
+ - Bump @fluentui/react-utilities to v9.13.4 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
34
+ - Bump @fluentui/react-jsx-runtime to v9.0.11 ([PR #29300](https://github.com/microsoft/fluentui/pull/29300) by beachball)
35
+
7
36
  ## [9.0.40](https://github.com/microsoft/fluentui/tree/@fluentui/react-card_v9.0.40)
8
37
 
9
- Wed, 20 Sep 2023 17:40:42 GMT
38
+ Wed, 20 Sep 2023 17:47:35 GMT
10
39
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-card_v9.0.39..@fluentui/react-card_v9.0.40)
11
40
 
12
41
  ### Patches
@@ -15,7 +15,9 @@ const cardContext = React.createContext(undefined);
15
15
  /**
16
16
  * @internal
17
17
  */ export const CardProvider = cardContext.Provider;
18
- var _React_useContext;
19
18
  /**
20
19
  * @internal
21
- */ export const useCardContext_unstable = ()=>(_React_useContext = React.useContext(cardContext)) !== null && _React_useContext !== void 0 ? _React_useContext : cardContextDefaultValue;
20
+ */ export const useCardContext_unstable = ()=>{
21
+ var _React_useContext;
22
+ return (_React_useContext = React.useContext(cardContext)) !== null && _React_useContext !== void 0 ? _React_useContext : cardContextDefaultValue;
23
+ };
@@ -1 +1 @@
1
- {"version":3,"sources":["CardContext.ts"],"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"],"names":["React","cardContext","createContext","undefined","cardContextDefaultValue","selectableA11yProps","referenceId","setReferenceId","referenceLabel","setReferenceLabel","CardProvider","Provider","useCardContext_unstable","useContext"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAG/B,MAAMC,cAAcD,MAAME,aAAa,CAA+BC;AAEtE;;CAEC,GACD,OAAO,MAAMC,0BAA4C;IACvDC,qBAAqB;QACnBC,aAAaH;QACbI;QACE,QAAQ,GACV;QACAC,gBAAgBL;QAChBM;QACE,QAAQ,GACV;IACF;AACF,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMC,eAAeT,YAAYU,QAAQ,CAAC;IAKJX;AAH7C;;CAEC,GACD,OAAO,MAAMY,0BAA0B,IAAMZ,CAAAA,oBAAAA,MAAMa,UAAU,CAACZ,0BAAjBD,+BAAAA,oBAAiCI,wBAAwB"}
1
+ {"version":3,"sources":["CardContext.ts"],"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"],"names":["React","cardContext","createContext","undefined","cardContextDefaultValue","selectableA11yProps","referenceId","setReferenceId","referenceLabel","setReferenceLabel","CardProvider","Provider","useCardContext_unstable","useContext"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAG/B,MAAMC,cAAcD,MAAME,aAAa,CAA+BC;AAEtE;;CAEC,GACD,OAAO,MAAMC,0BAA4C;IACvDC,qBAAqB;QACnBC,aAAaH;QACbI;QACE,QAAQ,GACV;QACAC,gBAAgBL;QAChBM;QACE,QAAQ,GACV;IACF;AACF,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMC,eAAeT,YAAYU,QAAQ,CAAC;AAEjD;;CAEC,GACD,OAAO,MAAMC,0BAA0B;QAAMZ;WAAAA,CAAAA,oBAAAA,MAAMa,UAAU,CAACZ,0BAAjBD,+BAAAA,oBAAiCI;AAAsB,EAAE"}
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { mergeCallbacks, slot } from '@fluentui/react-utilities';
2
+ import { mergeCallbacks, slot, useControllableState } from '@fluentui/react-utilities';
3
3
  import { Enter } from '@fluentui/keyboard-keys';
4
4
  import { useFocusFinders } from '@fluentui/react-tabster';
5
5
  /**
@@ -14,25 +14,28 @@ import { useFocusFinders } from '@fluentui/react-tabster';
14
14
  * @param a11yProps - accessibility props shared between elements of the card
15
15
  * @param ref - reference to the root element of Card
16
16
  */ export const useCardSelectable = (props, { referenceLabel, referenceId }, cardRef)=>{
17
- const { checkbox = {}, selected, defaultSelected, onSelectionChange, floatingAction, onClick, onKeyDown } = props;
17
+ const { checkbox = {}, onSelectionChange, floatingAction, onClick, onKeyDown } = props;
18
18
  const { findAllFocusable } = useFocusFinders();
19
19
  const checkboxRef = React.useRef(null);
20
- const isSelectable = [
21
- selected,
22
- defaultSelected,
20
+ const [selected, setSelected] = useControllableState({
21
+ state: props.selected,
22
+ defaultState: props.defaultSelected,
23
+ initialState: false
24
+ });
25
+ const selectable = [
26
+ props.selected,
27
+ props.defaultSelected,
23
28
  onSelectionChange
24
29
  ].some((prop)=>typeof prop !== 'undefined');
25
- const [isCardSelected, setIsCardSelected] = React.useState(false);
26
- const [isSelectFocused, setIsSelectFocused] = React.useState(false);
30
+ const [selectFocused, setSelectFocused] = React.useState(false);
27
31
  const shouldRestrictTriggerAction = React.useCallback((event)=>{
28
- var _checkboxRef;
29
32
  if (!cardRef.current) {
30
33
  return false;
31
34
  }
32
35
  const focusableElements = findAllFocusable(cardRef.current);
33
36
  const target = event.target;
34
37
  const isElementInFocusableGroup = focusableElements.some((element)=>element.contains(target));
35
- const isCheckboxSlot = ((_checkboxRef = checkboxRef) === null || _checkboxRef === void 0 ? void 0 : _checkboxRef.current) === target;
38
+ const isCheckboxSlot = (checkboxRef === null || checkboxRef === void 0 ? void 0 : checkboxRef.current) === target;
36
39
  return isElementInFocusableGroup && !isCheckboxSlot;
37
40
  }, [
38
41
  cardRef,
@@ -42,8 +45,8 @@ import { useFocusFinders } from '@fluentui/react-tabster';
42
45
  if (shouldRestrictTriggerAction(event)) {
43
46
  return;
44
47
  }
45
- const newCheckedValue = !isCardSelected;
46
- setIsCardSelected(newCheckedValue);
48
+ const newCheckedValue = !selected;
49
+ setSelected(newCheckedValue);
47
50
  if (onSelectionChange) {
48
51
  onSelectionChange(event, {
49
52
  selected: newCheckedValue
@@ -51,7 +54,8 @@ import { useFocusFinders } from '@fluentui/react-tabster';
51
54
  }
52
55
  }, [
53
56
  onSelectionChange,
54
- isCardSelected,
57
+ selected,
58
+ setSelected,
55
59
  shouldRestrictTriggerAction
56
60
  ]);
57
61
  const onKeyDownHandler = React.useCallback((event)=>{
@@ -65,7 +69,7 @@ import { useFocusFinders } from '@fluentui/react-tabster';
65
69
  onChangeHandler
66
70
  ]);
67
71
  const checkboxSlot = React.useMemo(()=>{
68
- if (!isSelectable || floatingAction) {
72
+ if (!selectable || floatingAction) {
69
73
  return;
70
74
  }
71
75
  const selectableCheckboxProps = {};
@@ -78,10 +82,10 @@ import { useFocusFinders } from '@fluentui/react-tabster';
78
82
  defaultProps: {
79
83
  ref: checkboxRef,
80
84
  type: 'checkbox',
81
- checked: isCardSelected,
85
+ checked: selected,
82
86
  onChange: (event)=>onChangeHandler(event),
83
- onFocus: ()=>setIsSelectFocused(true),
84
- onBlur: ()=>setIsSelectFocused(false),
87
+ onFocus: ()=>setSelectFocused(true),
88
+ onBlur: ()=>setSelectFocused(false),
85
89
  ...selectableCheckboxProps
86
90
  },
87
91
  elementType: 'input'
@@ -89,8 +93,8 @@ import { useFocusFinders } from '@fluentui/react-tabster';
89
93
  }, [
90
94
  checkbox,
91
95
  floatingAction,
92
- isCardSelected,
93
- isSelectable,
96
+ selected,
97
+ selectable,
94
98
  onChangeHandler,
95
99
  referenceId,
96
100
  referenceLabel
@@ -109,7 +113,7 @@ import { useFocusFinders } from '@fluentui/react-tabster';
109
113
  floatingAction
110
114
  ]);
111
115
  const selectableCardProps = React.useMemo(()=>{
112
- if (!isSelectable) {
116
+ if (!selectable) {
113
117
  return null;
114
118
  }
115
119
  return {
@@ -117,21 +121,16 @@ import { useFocusFinders } from '@fluentui/react-tabster';
117
121
  onKeyDown: mergeCallbacks(onKeyDown, onKeyDownHandler)
118
122
  };
119
123
  }, [
120
- isSelectable,
124
+ selectable,
121
125
  onChangeHandler,
122
126
  onClick,
123
127
  onKeyDown,
124
128
  onKeyDownHandler
125
129
  ]);
126
- React.useEffect(()=>setIsCardSelected(Boolean(defaultSelected !== null && defaultSelected !== void 0 ? defaultSelected : selected)), [
127
- defaultSelected,
128
- selected,
129
- setIsCardSelected
130
- ]);
131
130
  return {
132
- selected: isCardSelected,
133
- selectable: isSelectable,
134
- selectFocused: isSelectFocused,
131
+ selected,
132
+ selectable,
133
+ selectFocused,
135
134
  selectableCardProps,
136
135
  checkboxSlot,
137
136
  floatingActionSlot
@@ -1 +1 @@
1
- {"version":3,"sources":["useCardSelectable.ts"],"sourcesContent":["import * as React from 'react';\nimport { mergeCallbacks, slot } 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 slot.optional(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 elementType: 'input',\n });\n }, [checkbox, floatingAction, isCardSelected, isSelectable, onChangeHandler, referenceId, referenceLabel]);\n\n const floatingActionSlot = React.useMemo(() => {\n if (!floatingAction) {\n return;\n }\n\n return slot.optional(floatingAction, {\n defaultProps: {\n ref: checkboxRef,\n },\n elementType: 'div',\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"],"names":["React","mergeCallbacks","slot","Enter","useFocusFinders","useCardSelectable","props","referenceLabel","referenceId","cardRef","checkbox","selected","defaultSelected","onSelectionChange","floatingAction","onClick","onKeyDown","findAllFocusable","checkboxRef","useRef","isSelectable","some","prop","isCardSelected","setIsCardSelected","useState","isSelectFocused","setIsSelectFocused","shouldRestrictTriggerAction","useCallback","event","current","focusableElements","target","isElementInFocusableGroup","element","contains","isCheckboxSlot","onChangeHandler","newCheckedValue","onKeyDownHandler","includes","key","preventDefault","checkboxSlot","useMemo","selectableCheckboxProps","optional","defaultProps","ref","type","checked","onChange","onFocus","onBlur","elementType","floatingActionSlot","selectableCardProps","useEffect","Boolean","selectable","selectFocused"],"mappings":"AAAA,YAAYA,WAAW,QAAQ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AAWf,eAAee,WAAWwB;QACvC;IACF,GAAG;QAACpB;QAAckB;QAAiBvB;QAASC;QAAWwB;KAAiB;IAExExC,MAAM0D,SAAS,CACb,IAAMlC,kBAAkBmC,QAAQ/C,4BAAAA,6BAAAA,kBAAmBD,YACnD;QAACC;QAAiBD;QAAUa;KAAkB;IAGhD,OAAO;QACLb,UAAUY;QACVqC,YAAYxC;QACZyC,eAAenC;QACf+B;QACAb;QACAY;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["useCardSelectable.ts"],"sourcesContent":["import * as React from 'react';\nimport { mergeCallbacks, slot, useControllableState } 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 = {}, onSelectionChange, floatingAction, onClick, onKeyDown } = props;\n\n const { findAllFocusable } = useFocusFinders();\n const checkboxRef = React.useRef<HTMLInputElement>(null);\n\n const [selected, setSelected] = useControllableState({\n state: props.selected,\n defaultState: props.defaultSelected,\n initialState: false,\n });\n const selectable = [props.selected, props.defaultSelected, onSelectionChange].some(\n prop => typeof prop !== 'undefined',\n );\n\n const [selectFocused, setSelectFocused] = 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 = !selected;\n\n setSelected(newCheckedValue);\n\n if (onSelectionChange) {\n onSelectionChange(event, { selected: newCheckedValue });\n }\n },\n [onSelectionChange, selected, setSelected, 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 (!selectable || 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 slot.optional(checkbox, {\n defaultProps: {\n ref: checkboxRef,\n type: 'checkbox',\n checked: selected,\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => onChangeHandler(event),\n onFocus: () => setSelectFocused(true),\n onBlur: () => setSelectFocused(false),\n ...selectableCheckboxProps,\n },\n elementType: 'input',\n });\n }, [checkbox, floatingAction, selected, selectable, onChangeHandler, referenceId, referenceLabel]);\n\n const floatingActionSlot = React.useMemo(() => {\n if (!floatingAction) {\n return;\n }\n\n return slot.optional(floatingAction, {\n defaultProps: {\n ref: checkboxRef,\n },\n elementType: 'div',\n });\n }, [floatingAction]);\n\n const selectableCardProps = React.useMemo(() => {\n if (!selectable) {\n return null;\n }\n\n return {\n onClick: mergeCallbacks(onClick, onChangeHandler),\n onKeyDown: mergeCallbacks(onKeyDown, onKeyDownHandler),\n };\n }, [selectable, onChangeHandler, onClick, onKeyDown, onKeyDownHandler]);\n\n return {\n selected,\n selectable,\n selectFocused,\n selectableCardProps,\n checkboxSlot,\n floatingActionSlot,\n };\n};\n"],"names":["React","mergeCallbacks","slot","useControllableState","Enter","useFocusFinders","useCardSelectable","props","referenceLabel","referenceId","cardRef","checkbox","onSelectionChange","floatingAction","onClick","onKeyDown","findAllFocusable","checkboxRef","useRef","selected","setSelected","state","defaultState","defaultSelected","initialState","selectable","some","prop","selectFocused","setSelectFocused","useState","shouldRestrictTriggerAction","useCallback","event","current","focusableElements","target","isElementInFocusableGroup","element","contains","isCheckboxSlot","onChangeHandler","newCheckedValue","onKeyDownHandler","includes","key","preventDefault","checkboxSlot","useMemo","selectableCheckboxProps","optional","defaultProps","ref","type","checked","onChange","onFocus","onBlur","elementType","floatingActionSlot","selectableCardProps"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,cAAc,EAAEC,IAAI,EAAEC,oBAAoB,QAAQ,4BAA4B;AACvF,SAASC,KAAK,QAAQ,0BAA0B;AAChD,SAASC,eAAe,QAAQ,0BAA0B;AAI1D;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,oBAAoB,CAC/BC,OACA,EAAEC,cAAc,EAAEC,WAAW,EAAmF,EAChHC;IAEA,MAAM,EAAEC,WAAW,CAAC,CAAC,EAAEC,iBAAiB,EAAEC,cAAc,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGR;IAEjF,MAAM,EAAES,gBAAgB,EAAE,GAAGX;IAC7B,MAAMY,cAAcjB,MAAMkB,MAAM,CAAmB;IAEnD,MAAM,CAACC,UAAUC,YAAY,GAAGjB,qBAAqB;QACnDkB,OAAOd,MAAMY,QAAQ;QACrBG,cAAcf,MAAMgB,eAAe;QACnCC,cAAc;IAChB;IACA,MAAMC,aAAa;QAAClB,MAAMY,QAAQ;QAAEZ,MAAMgB,eAAe;QAAEX;KAAkB,CAACc,IAAI,CAChFC,CAAAA,OAAQ,OAAOA,SAAS;IAG1B,MAAM,CAACC,eAAeC,iBAAiB,GAAG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,UAAU,CAACtB,QAA+CQ,gBAAgBR;gBAC1EuB,SAAS,IAAM3B,iBAAiB;gBAChC4B,QAAQ,IAAM5B,iBAAiB;gBAC/B,GAAGoB,uBAAuB;YAC5B;YACAS,aAAa;QACf;IACF,GAAG;QAAC/C;QAAUE;QAAgBM;QAAUM;QAAYgB;QAAiBhC;QAAaD;KAAe;IAEjG,MAAMmD,qBAAqB3D,MAAMgD,OAAO,CAAC;QACvC,IAAI,CAACnC,gBAAgB;YACnB;QACF;QAEA,OAAOX,KAAKgD,QAAQ,CAACrC,gBAAgB;YACnCsC,cAAc;gBACZC,KAAKnC;YACP;YACAyC,aAAa;QACf;IACF,GAAG;QAAC7C;KAAe;IAEnB,MAAM+C,sBAAsB5D,MAAMgD,OAAO,CAAC;QACxC,IAAI,CAACvB,YAAY;YACf,OAAO;QACT;QAEA,OAAO;YACLX,SAASb,eAAea,SAAS2B;YACjC1B,WAAWd,eAAec,WAAW4B;QACvC;IACF,GAAG;QAAClB;QAAYgB;QAAiB3B;QAASC;QAAW4B;KAAiB;IAEtE,OAAO;QACLxB;QACAM;QACAG;QACAgC;QACAb;QACAY;IACF;AACF,EAAE"}
@@ -21,11 +21,10 @@ import { cardHeaderClassNames } from './useCardHeaderStyles.styles';
21
21
  *
22
22
  * @returns the id to use for the CardHeader root element
23
23
  */ function getReferenceId(headerId, childWithId, generatedId) {
24
- var _childWithId;
25
24
  if (headerId) {
26
25
  return headerId;
27
26
  }
28
- if ((_childWithId = childWithId) === null || _childWithId === void 0 ? void 0 : _childWithId.props.id) {
27
+ if (childWithId === null || childWithId === void 0 ? void 0 : childWithId.props.id) {
29
28
  return childWithId.props.id;
30
29
  }
31
30
  return generatedId;
@@ -53,9 +52,9 @@ import { cardHeaderClassNames } from './useCardHeaderStyles.styles';
53
52
  elementType: 'div'
54
53
  });
55
54
  React.useEffect(()=>{
56
- var _headerRef_current, _headerSlot;
55
+ var _headerRef_current;
57
56
  const headerId = !hasChildId.current ? (_headerRef_current = headerRef.current) === null || _headerRef_current === void 0 ? void 0 : _headerRef_current.id : undefined;
58
- const childWithId = getChildWithId((_headerSlot = headerSlot) === null || _headerSlot === void 0 ? void 0 : _headerSlot.children);
57
+ const childWithId = getChildWithId(headerSlot === null || headerSlot === void 0 ? void 0 : headerSlot.children);
59
58
  hasChildId.current = Boolean(childWithId);
60
59
  setReferenceId(getReferenceId(headerId, childWithId, generatedId));
61
60
  }, [
@@ -1 +1 @@
1
- {"version":3,"sources":["useCardHeader.ts"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useId, slot } from '@fluentui/react-utilities';\nimport type { CardHeaderProps, CardHeaderState } from './CardHeader.types';\nimport { useCardContext_unstable } from '../Card/CardContext';\nimport { cardHeaderClassNames } from './useCardHeaderStyles.styles';\n\n/**\n * Finds the first child of CardHeader with an id prop.\n *\n * @param header - the header prop of CardHeader\n */\nfunction getChildWithId(header: React.ReactNode) {\n function isReactElementWithIdProp(element: React.ReactNode): element is React.ReactElement {\n return React.isValidElement(element) && Boolean(element.props.id);\n }\n\n return React.Children.toArray(header).find(isReactElementWithIdProp);\n}\n\n/**\n * Returns the id to use for the CardHeader root element.\n *\n * @param headerId - the id prop of the CardHeader component\n * @param childWithId - the first child of the CardHeader component with an id prop\n * @param generatedId - a generated id\n *\n * @returns the id to use for the CardHeader root element\n */\nfunction getReferenceId(\n headerId: string | undefined,\n childWithId: React.ReactElement | undefined,\n generatedId: string,\n): string {\n if (headerId) {\n return headerId;\n }\n\n if (childWithId?.props.id) {\n return childWithId.props.id;\n }\n\n return generatedId;\n}\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 hasChildId = React.useRef(false);\n const generatedId = useId(cardHeaderClassNames.header, referenceId);\n\n const headerSlot = slot.optional(header, {\n renderByDefault: true,\n defaultProps: {\n ref: headerRef,\n id: !hasChildId.current ? referenceId : undefined,\n },\n elementType: 'div',\n });\n React.useEffect(() => {\n const headerId = !hasChildId.current ? headerRef.current?.id : undefined;\n const childWithId = getChildWithId(headerSlot?.children);\n hasChildId.current = Boolean(childWithId);\n setReferenceId(getReferenceId(headerId, childWithId, generatedId));\n }, [generatedId, header, headerSlot, setReferenceId]);\n return {\n components: { root: 'div', image: 'div', header: 'div', description: 'div', action: 'div' },\n\n root: slot.always(\n getNativeElementProps('div', {\n ref,\n ...props,\n }),\n { elementType: 'div' },\n ),\n image: slot.optional(image, { elementType: 'div' }),\n header: headerSlot,\n description: slot.optional(description, { elementType: 'div' }),\n action: slot.optional(action, { elementType: 'div' }),\n };\n};\n"],"names":["React","getNativeElementProps","useId","slot","useCardContext_unstable","cardHeaderClassNames","getChildWithId","header","isReactElementWithIdProp","element","isValidElement","Boolean","props","id","Children","toArray","find","getReferenceId","headerId","childWithId","generatedId","useCardHeader_unstable","ref","image","description","action","selectableA11yProps","referenceId","setReferenceId","headerRef","useRef","hasChildId","headerSlot","optional","renderByDefault","defaultProps","current","undefined","elementType","useEffect","children","components","root","always"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,qBAAqB,EAAEC,KAAK,EAAEC,IAAI,QAAQ,4BAA4B;AAE/E,SAASC,uBAAuB,QAAQ,sBAAsB;AAC9D,SAASC,oBAAoB,QAAQ,+BAA+B;AAEpE;;;;CAIC,GACD,SAASC,eAAeC,MAAuB;IAC7C,SAASC,yBAAyBC,OAAwB;QACxD,OAAOT,MAAMU,cAAc,CAACD,YAAYE,QAAQF,QAAQG,KAAK,CAACC,EAAE;IAClE;IAEA,OAAOb,MAAMc,QAAQ,CAACC,OAAO,CAAC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Aa;YAAOC,QAAQ;QAAM;QAE1FiB,MAAMvC,KAAKwC,MAAM,CACf1C,sBAAsB,OAAO;YAC3BqB;YACA,GAAGV,KAAK;QACV,IACA;YAAE0B,aAAa;QAAM;QAEvBf,OAAOpB,KAAK8B,QAAQ,CAACV,OAAO;YAAEe,aAAa;QAAM;QACjD/B,QAAQyB;QACRR,aAAarB,KAAK8B,QAAQ,CAACT,aAAa;YAAEc,aAAa;QAAM;QAC7Db,QAAQtB,KAAK8B,QAAQ,CAACR,QAAQ;YAAEa,aAAa;QAAM;IACrD;AACF,EAAE"}
1
+ {"version":3,"sources":["useCardHeader.ts"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useId, slot } from '@fluentui/react-utilities';\nimport type { CardHeaderProps, CardHeaderState } from './CardHeader.types';\nimport { useCardContext_unstable } from '../Card/CardContext';\nimport { cardHeaderClassNames } from './useCardHeaderStyles.styles';\n\n/**\n * Finds the first child of CardHeader with an id prop.\n *\n * @param header - the header prop of CardHeader\n */\nfunction getChildWithId(header: React.ReactNode) {\n function isReactElementWithIdProp(element: React.ReactNode): element is React.ReactElement {\n return React.isValidElement(element) && Boolean(element.props.id);\n }\n\n return React.Children.toArray(header).find(isReactElementWithIdProp);\n}\n\n/**\n * Returns the id to use for the CardHeader root element.\n *\n * @param headerId - the id prop of the CardHeader component\n * @param childWithId - the first child of the CardHeader component with an id prop\n * @param generatedId - a generated id\n *\n * @returns the id to use for the CardHeader root element\n */\nfunction getReferenceId(\n headerId: string | undefined,\n childWithId: React.ReactElement | undefined,\n generatedId: string,\n): string {\n if (headerId) {\n return headerId;\n }\n\n if (childWithId?.props.id) {\n return childWithId.props.id;\n }\n\n return generatedId;\n}\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 hasChildId = React.useRef(false);\n const generatedId = useId(cardHeaderClassNames.header, referenceId);\n\n const headerSlot = slot.optional(header, {\n renderByDefault: true,\n defaultProps: {\n ref: headerRef,\n id: !hasChildId.current ? referenceId : undefined,\n },\n elementType: 'div',\n });\n React.useEffect(() => {\n const headerId = !hasChildId.current ? headerRef.current?.id : undefined;\n const childWithId = getChildWithId(headerSlot?.children);\n hasChildId.current = Boolean(childWithId);\n setReferenceId(getReferenceId(headerId, childWithId, generatedId));\n }, [generatedId, header, headerSlot, setReferenceId]);\n return {\n components: { root: 'div', image: 'div', header: 'div', description: 'div', action: 'div' },\n\n root: slot.always(\n getNativeElementProps('div', {\n ref,\n ...props,\n }),\n { elementType: 'div' },\n ),\n image: slot.optional(image, { elementType: 'div' }),\n header: headerSlot,\n description: slot.optional(description, { elementType: 'div' }),\n action: slot.optional(action, { elementType: 'div' }),\n };\n};\n"],"names":["React","getNativeElementProps","useId","slot","useCardContext_unstable","cardHeaderClassNames","getChildWithId","header","isReactElementWithIdProp","element","isValidElement","Boolean","props","id","Children","toArray","find","getReferenceId","headerId","childWithId","generatedId","useCardHeader_unstable","ref","image","description","action","selectableA11yProps","referenceId","setReferenceId","headerRef","useRef","hasChildId","headerSlot","optional","renderByDefault","defaultProps","current","undefined","elementType","useEffect","children","components","root","always"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,qBAAqB,EAAEC,KAAK,EAAEC,IAAI,QAAQ,4BAA4B;AAE/E,SAASC,uBAAuB,QAAQ,sBAAsB;AAC9D,SAASC,oBAAoB,QAAQ,+BAA+B;AAEpE;;;;CAIC,GACD,SAASC,eAAeC,MAAuB;IAC7C,SAASC,yBAAyBC,OAAwB;QACxD,OAAOT,MAAMU,cAAc,CAACD,YAA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AY;YAAEC,MAAM;YAAOnB,OAAO;YAAOhB,QAAQ;YAAOiB,aAAa;YAAOC,QAAQ;QAAM;QAE1FiB,MAAMvC,KAAKwC,MAAM,CACf1C,sBAAsB,OAAO;YAC3BqB;YACA,GAAGV,KAAK;QACV,IACA;YAAE0B,aAAa;QAAM;QAEvBf,OAAOpB,KAAK8B,QAAQ,CAACV,OAAO;YAAEe,aAAa;QAAM;QACjD/B,QAAQyB;QACRR,aAAarB,KAAK8B,QAAQ,CAACT,aAAa;YAAEc,aAAa;QAAM;QAC7Db,QAAQtB,KAAK8B,QAAQ,CAACR,QAAQ;YAAEa,aAAa;QAAM;IACrD;AACF,EAAE"}
@@ -33,5 +33,7 @@ const cardContextDefaultValue = {
33
33
  }
34
34
  };
35
35
  const CardProvider = cardContext.Provider;
36
- var _React_useContext;
37
- const useCardContext_unstable = ()=>(_React_useContext = _react.useContext(cardContext)) !== null && _React_useContext !== void 0 ? _React_useContext : cardContextDefaultValue;
36
+ const useCardContext_unstable = ()=>{
37
+ var _React_useContext;
38
+ return (_React_useContext = _react.useContext(cardContext)) !== null && _React_useContext !== void 0 ? _React_useContext : cardContextDefaultValue;
39
+ };
@@ -1 +1 @@
1
- {"version":3,"sources":["CardContext.js"],"sourcesContent":["import * as React from 'react';\nconst cardContext = React.createContext(undefined);\n/**\n * @internal\n */ export const cardContextDefaultValue = {\n selectableA11yProps: {\n referenceId: undefined,\n setReferenceId () {\n /* Noop */ },\n referenceLabel: undefined,\n setReferenceLabel () {\n /* Noop */ }\n }\n};\n/**\n * @internal\n */ export const CardProvider = cardContext.Provider;\nvar _React_useContext;\n/**\n * @internal\n */ export const useCardContext_unstable = ()=>(_React_useContext = React.useContext(cardContext)) !== null && _React_useContext !== void 0 ? _React_useContext : cardContextDefaultValue;\n"],"names":["cardContextDefaultValue","CardProvider","useCardContext_unstable","cardContext","React","createContext","undefined","selectableA11yProps","referenceId","setReferenceId","referenceLabel","setReferenceLabel","Provider","_React_useContext","useContext"],"mappings":";;;;;;;;;;;IAIiBA,uBAAuB;eAAvBA;;IAYAC,YAAY;eAAZA;;IAIAC,uBAAuB;eAAvBA;;;;iEApBM;AACvB,MAAMC,4BAAcC,OAAMC,aAAa,CAACC;AAG7B,MAAMN,0BAA0B;IACvCO,qBAAqB;QACjBC,aAAaF;QACbG;QACA,QAAQ,GAAG;QACXC,gBAAgBJ;QAChBK;QACA,QAAQ,GAAG;IACf;AACJ;AAGW,MAAMV,eAAeE,YAAYS,QAAQ;AACpD,IAAIC;AAGO,MAAMX,0BAA0B,IAAI,AAACW,CAAAA,oBAAoBT,OAAMU,UAAU,CAACX,YAAW,MAAO,QAAQU,sBAAsB,KAAK,IAAIA,oBAAoBb"}
1
+ {"version":3,"sources":["CardContext.js"],"sourcesContent":["import * as React from 'react';\nconst cardContext = React.createContext(undefined);\n/**\n * @internal\n */ export const cardContextDefaultValue = {\n selectableA11yProps: {\n referenceId: undefined,\n setReferenceId () {\n /* Noop */ },\n referenceLabel: undefined,\n setReferenceLabel () {\n /* Noop */ }\n }\n};\n/**\n * @internal\n */ export const CardProvider = cardContext.Provider;\n/**\n * @internal\n */ export const useCardContext_unstable = ()=>{\n var _React_useContext;\n return (_React_useContext = React.useContext(cardContext)) !== null && _React_useContext !== void 0 ? _React_useContext : cardContextDefaultValue;\n};\n"],"names":["cardContextDefaultValue","CardProvider","useCardContext_unstable","cardContext","React","createContext","undefined","selectableA11yProps","referenceId","setReferenceId","referenceLabel","setReferenceLabel","Provider","_React_useContext","useContext"],"mappings":";;;;;;;;;;;IAIiBA,uBAAuB;eAAvBA;;IAYAC,YAAY;eAAZA;;IAGAC,uBAAuB;eAAvBA;;;;iEAnBM;AACvB,MAAMC,4BAAcC,OAAMC,aAAa,CAACC;AAG7B,MAAMN,0BAA0B;IACvCO,qBAAqB;QACjBC,aAAaF;QACbG;QACA,QAAQ,GAAG;QACXC,gBAAgBJ;QAChBK;QACA,QAAQ,GAAG;IACf;AACJ;AAGW,MAAMV,eAAeE,YAAYS,QAAQ;AAGzC,MAAMV,0BAA0B;IACvC,IAAIW;IACJ,OAAO,AAACA,CAAAA,oBAAoBT,OAAMU,UAAU,CAACX,YAAW,MAAO,QAAQU,sBAAsB,KAAK,IAAIA,oBAAoBb;AAC9H"}
@@ -14,25 +14,28 @@ const _reactutilities = require("@fluentui/react-utilities");
14
14
  const _keyboardkeys = require("@fluentui/keyboard-keys");
15
15
  const _reacttabster = require("@fluentui/react-tabster");
16
16
  const useCardSelectable = (props, { referenceLabel, referenceId }, cardRef)=>{
17
- const { checkbox = {}, selected, defaultSelected, onSelectionChange, floatingAction, onClick, onKeyDown } = props;
17
+ const { checkbox = {}, onSelectionChange, floatingAction, onClick, onKeyDown } = props;
18
18
  const { findAllFocusable } = (0, _reacttabster.useFocusFinders)();
19
19
  const checkboxRef = _react.useRef(null);
20
- const isSelectable = [
21
- selected,
22
- defaultSelected,
20
+ const [selected, setSelected] = (0, _reactutilities.useControllableState)({
21
+ state: props.selected,
22
+ defaultState: props.defaultSelected,
23
+ initialState: false
24
+ });
25
+ const selectable = [
26
+ props.selected,
27
+ props.defaultSelected,
23
28
  onSelectionChange
24
29
  ].some((prop)=>typeof prop !== 'undefined');
25
- const [isCardSelected, setIsCardSelected] = _react.useState(false);
26
- const [isSelectFocused, setIsSelectFocused] = _react.useState(false);
30
+ const [selectFocused, setSelectFocused] = _react.useState(false);
27
31
  const shouldRestrictTriggerAction = _react.useCallback((event)=>{
28
- var _checkboxRef;
29
32
  if (!cardRef.current) {
30
33
  return false;
31
34
  }
32
35
  const focusableElements = findAllFocusable(cardRef.current);
33
36
  const target = event.target;
34
37
  const isElementInFocusableGroup = focusableElements.some((element)=>element.contains(target));
35
- const isCheckboxSlot = ((_checkboxRef = checkboxRef) === null || _checkboxRef === void 0 ? void 0 : _checkboxRef.current) === target;
38
+ const isCheckboxSlot = (checkboxRef === null || checkboxRef === void 0 ? void 0 : checkboxRef.current) === target;
36
39
  return isElementInFocusableGroup && !isCheckboxSlot;
37
40
  }, [
38
41
  cardRef,
@@ -42,8 +45,8 @@ const useCardSelectable = (props, { referenceLabel, referenceId }, cardRef)=>{
42
45
  if (shouldRestrictTriggerAction(event)) {
43
46
  return;
44
47
  }
45
- const newCheckedValue = !isCardSelected;
46
- setIsCardSelected(newCheckedValue);
48
+ const newCheckedValue = !selected;
49
+ setSelected(newCheckedValue);
47
50
  if (onSelectionChange) {
48
51
  onSelectionChange(event, {
49
52
  selected: newCheckedValue
@@ -51,7 +54,8 @@ const useCardSelectable = (props, { referenceLabel, referenceId }, cardRef)=>{
51
54
  }
52
55
  }, [
53
56
  onSelectionChange,
54
- isCardSelected,
57
+ selected,
58
+ setSelected,
55
59
  shouldRestrictTriggerAction
56
60
  ]);
57
61
  const onKeyDownHandler = _react.useCallback((event)=>{
@@ -65,7 +69,7 @@ const useCardSelectable = (props, { referenceLabel, referenceId }, cardRef)=>{
65
69
  onChangeHandler
66
70
  ]);
67
71
  const checkboxSlot = _react.useMemo(()=>{
68
- if (!isSelectable || floatingAction) {
72
+ if (!selectable || floatingAction) {
69
73
  return;
70
74
  }
71
75
  const selectableCheckboxProps = {};
@@ -78,10 +82,10 @@ const useCardSelectable = (props, { referenceLabel, referenceId }, cardRef)=>{
78
82
  defaultProps: {
79
83
  ref: checkboxRef,
80
84
  type: 'checkbox',
81
- checked: isCardSelected,
85
+ checked: selected,
82
86
  onChange: (event)=>onChangeHandler(event),
83
- onFocus: ()=>setIsSelectFocused(true),
84
- onBlur: ()=>setIsSelectFocused(false),
87
+ onFocus: ()=>setSelectFocused(true),
88
+ onBlur: ()=>setSelectFocused(false),
85
89
  ...selectableCheckboxProps
86
90
  },
87
91
  elementType: 'input'
@@ -89,8 +93,8 @@ const useCardSelectable = (props, { referenceLabel, referenceId }, cardRef)=>{
89
93
  }, [
90
94
  checkbox,
91
95
  floatingAction,
92
- isCardSelected,
93
- isSelectable,
96
+ selected,
97
+ selectable,
94
98
  onChangeHandler,
95
99
  referenceId,
96
100
  referenceLabel
@@ -109,7 +113,7 @@ const useCardSelectable = (props, { referenceLabel, referenceId }, cardRef)=>{
109
113
  floatingAction
110
114
  ]);
111
115
  const selectableCardProps = _react.useMemo(()=>{
112
- if (!isSelectable) {
116
+ if (!selectable) {
113
117
  return null;
114
118
  }
115
119
  return {
@@ -117,21 +121,16 @@ const useCardSelectable = (props, { referenceLabel, referenceId }, cardRef)=>{
117
121
  onKeyDown: (0, _reactutilities.mergeCallbacks)(onKeyDown, onKeyDownHandler)
118
122
  };
119
123
  }, [
120
- isSelectable,
124
+ selectable,
121
125
  onChangeHandler,
122
126
  onClick,
123
127
  onKeyDown,
124
128
  onKeyDownHandler
125
129
  ]);
126
- _react.useEffect(()=>setIsCardSelected(Boolean(defaultSelected !== null && defaultSelected !== void 0 ? defaultSelected : selected)), [
127
- defaultSelected,
128
- selected,
129
- setIsCardSelected
130
- ]);
131
130
  return {
132
- selected: isCardSelected,
133
- selectable: isSelectable,
134
- selectFocused: isSelectFocused,
131
+ selected,
132
+ selectable,
133
+ selectFocused,
135
134
  selectableCardProps,
136
135
  checkboxSlot,
137
136
  floatingActionSlot
@@ -1 +1 @@
1
- {"version":3,"sources":["useCardSelectable.js"],"sourcesContent":["import * as React from 'react';\nimport { mergeCallbacks, slot } from '@fluentui/react-utilities';\nimport { Enter } from '@fluentui/keyboard-keys';\nimport { useFocusFinders } from '@fluentui/react-tabster';\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 */ export const useCardSelectable = (props, { referenceLabel, referenceId }, cardRef)=>{\n const { checkbox = {}, selected, defaultSelected, onSelectionChange, floatingAction, onClick, onKeyDown } = props;\n const { findAllFocusable } = useFocusFinders();\n const checkboxRef = React.useRef(null);\n const isSelectable = [\n selected,\n defaultSelected,\n onSelectionChange\n ].some((prop)=>typeof prop !== 'undefined');\n const [isCardSelected, setIsCardSelected] = React.useState(false);\n const [isSelectFocused, setIsSelectFocused] = React.useState(false);\n const shouldRestrictTriggerAction = React.useCallback((event)=>{\n var _checkboxRef;\n if (!cardRef.current) {\n return false;\n }\n const focusableElements = findAllFocusable(cardRef.current);\n const target = event.target;\n const isElementInFocusableGroup = focusableElements.some((element)=>element.contains(target));\n const isCheckboxSlot = ((_checkboxRef = checkboxRef) === null || _checkboxRef === void 0 ? void 0 : _checkboxRef.current) === target;\n return isElementInFocusableGroup && !isCheckboxSlot;\n }, [\n cardRef,\n findAllFocusable\n ]);\n const onChangeHandler = React.useCallback((event)=>{\n if (shouldRestrictTriggerAction(event)) {\n return;\n }\n const newCheckedValue = !isCardSelected;\n setIsCardSelected(newCheckedValue);\n if (onSelectionChange) {\n onSelectionChange(event, {\n selected: newCheckedValue\n });\n }\n }, [\n onSelectionChange,\n isCardSelected,\n shouldRestrictTriggerAction\n ]);\n const onKeyDownHandler = React.useCallback((event)=>{\n if ([\n Enter\n ].includes(event.key)) {\n event.preventDefault();\n onChangeHandler(event);\n }\n }, [\n onChangeHandler\n ]);\n const checkboxSlot = React.useMemo(()=>{\n if (!isSelectable || floatingAction) {\n return;\n }\n const selectableCheckboxProps = {};\n if (referenceId) {\n selectableCheckboxProps['aria-labelledby'] = referenceId;\n } else if (referenceLabel) {\n selectableCheckboxProps['aria-label'] = referenceLabel;\n }\n return slot.optional(checkbox, {\n defaultProps: {\n ref: checkboxRef,\n type: 'checkbox',\n checked: isCardSelected,\n onChange: (event)=>onChangeHandler(event),\n onFocus: ()=>setIsSelectFocused(true),\n onBlur: ()=>setIsSelectFocused(false),\n ...selectableCheckboxProps\n },\n elementType: 'input'\n });\n }, [\n checkbox,\n floatingAction,\n isCardSelected,\n isSelectable,\n onChangeHandler,\n referenceId,\n referenceLabel\n ]);\n const floatingActionSlot = React.useMemo(()=>{\n if (!floatingAction) {\n return;\n }\n return slot.optional(floatingAction, {\n defaultProps: {\n ref: checkboxRef\n },\n elementType: 'div'\n });\n }, [\n floatingAction\n ]);\n const selectableCardProps = React.useMemo(()=>{\n if (!isSelectable) {\n return null;\n }\n return {\n onClick: mergeCallbacks(onClick, onChangeHandler),\n onKeyDown: mergeCallbacks(onKeyDown, onKeyDownHandler)\n };\n }, [\n isSelectable,\n onChangeHandler,\n onClick,\n onKeyDown,\n onKeyDownHandler\n ]);\n React.useEffect(()=>setIsCardSelected(Boolean(defaultSelected !== null && defaultSelected !== void 0 ? defaultSelected : selected)), [\n defaultSelected,\n selected,\n setIsCardSelected\n ]);\n return {\n selected: isCardSelected,\n selectable: isSelectable,\n selectFocused: isSelectFocused,\n selectableCardProps,\n checkboxSlot,\n floatingActionSlot\n };\n};\n"],"names":["useCardSelectable","props","referenceLabel","referenceId","cardRef","checkbox","selected","defaultSelected","onSelectionChange","floatingAction","onClick","onKeyDown","findAllFocusable","useFocusFinders","checkboxRef","React","useRef","isSelectable","some","prop","isCardSelected","setIsCardSelected","useState","isSelectFocused","setIsSelectFocused","shouldRestrictTriggerAction","useCallback","event","_checkboxRef","current","focusableElements","target","isElementInFocusableGroup","element","contains","isCheckboxSlot","onChangeHandler","newCheckedValue","onKeyDownHandler","Enter","includes","key","preventDefault","checkboxSlot","useMemo","selectableCheckboxProps","slot","optional","defaultProps","ref","type","checked","onChange","onFocus","onBlur","elementType","floatingActionSlot","selectableCardProps","mergeCallbacks","useEffect","Boolean","selectable","selectFocused"],"mappings":";;;;+BAeiBA;;;eAAAA;;;;iEAfM;gCACc;8BACf;8BACU;AAYrB,MAAMA,oBAAoB,CAACC,OAAO,EAAEC,cAAc,EAAEC,WAAW,EAAE,EAAEC;IAC1E,MAAM,EAAEC,WAAW,CAAC,CAAC,EAAEC,QAAQ,EAAEC,eAAe,EAAEC,iBAAiB,EAAEC,cAAc,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGV;IAC5G,MAAM,EAAEW,gBAAgB,EAAE,GAAGC,IAAAA,6BAAe;IAC5C,MAAMC,cAAcC,OAAMC,MAAM,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,0BAA0B,CAAC;QACjC,IAAI1C,aAAa;YACb0C,uBAAuB,CAAC,kBAAkB,GAAG1C;QACjD,OAAO,IAAID,gBAAgB;YACvB2C,uBAAuB,CAAC,aAAa,GAAG3C;QAC5C;QACA,OAAO4C,oBAAI,CAACC,QAAQ,CAAC1C,UAAU;YAC3B2C,cAAc;gBACVC,KAAKnC;gBACLoC,MAAM;gBACNC,SAAS/B;gBACTgC,UAAU,CAACzB,QAAQS,gBAAgBT;gBACnC0B,SAAS,IAAI7B,mBAAmB;gBAChC8B,QAAQ,IAAI9B,mBAAmB;gBAC/B,GAAGqB,uBAAuB;YAC9B;YACAU,aAAa;QACjB;IACJ,GAAG;QACClD;QACAI;QACAW;QACAH;QACAmB;QACAjC;QACAD;KACH;IACD,MAAMsD,qBAAqBzC,OAAM6B,OAAO,CAAC;QACrC,IAAI,CAACnC,gBAAgB;YACjB;QACJ;QACA,OAAOqC,oBAAI,CAACC,QAAQ,CAACtC,gBAAgB;YACjCuC,cAAc;gBACVC,KAAKnC;YACT;YACAyC,aAAa;QACjB;IACJ,GAAG;QACC9C;KACH;IACD,MAAMgD,sBAAsB1C,OAAM6B,OAAO,CAAC;QACtC,IAAI,CAAC3B,cAAc;YACf,OAAO;QACX;QACA,OAAO;YACHP,SAASgD,IAAAA,8BAAc,EAAChD,SAAS0B;YACjCzB,WAAW+C,IAAAA,8BAAc,EAAC/C,WAAW2B;QACzC;IACJ,GAAG;QACCrB;QACAmB;QACA1B;QACAC;QACA2B;KACH;IACDvB,OAAM4C,SAAS,CAAC,IAAItC,kBAAkBuC,QAAQrD,oBAAoB,QAAQA,oBAAoB,KAAK,IAAIA,kBAAkBD,YAAY;QACjIC;QACAD;QACAe;KACH;IACD,OAAO;QACHf,UAAUc;QACVyC,YAAY5C;QACZ6C,eAAevC;QACfkC;QACAd;QACAa;IACJ;AACJ"}
1
+ {"version":3,"sources":["useCardSelectable.js"],"sourcesContent":["import * as React from 'react';\nimport { mergeCallbacks, slot, useControllableState } from '@fluentui/react-utilities';\nimport { Enter } from '@fluentui/keyboard-keys';\nimport { useFocusFinders } from '@fluentui/react-tabster';\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 */ export const useCardSelectable = (props, { referenceLabel, referenceId }, cardRef)=>{\n const { checkbox = {}, onSelectionChange, floatingAction, onClick, onKeyDown } = props;\n const { findAllFocusable } = useFocusFinders();\n const checkboxRef = React.useRef(null);\n const [selected, setSelected] = useControllableState({\n state: props.selected,\n defaultState: props.defaultSelected,\n initialState: false\n });\n const selectable = [\n props.selected,\n props.defaultSelected,\n onSelectionChange\n ].some((prop)=>typeof prop !== 'undefined');\n const [selectFocused, setSelectFocused] = React.useState(false);\n const shouldRestrictTriggerAction = React.useCallback((event)=>{\n if (!cardRef.current) {\n return false;\n }\n const focusableElements = findAllFocusable(cardRef.current);\n const target = event.target;\n const isElementInFocusableGroup = focusableElements.some((element)=>element.contains(target));\n const isCheckboxSlot = (checkboxRef === null || checkboxRef === void 0 ? void 0 : checkboxRef.current) === target;\n return isElementInFocusableGroup && !isCheckboxSlot;\n }, [\n cardRef,\n findAllFocusable\n ]);\n const onChangeHandler = React.useCallback((event)=>{\n if (shouldRestrictTriggerAction(event)) {\n return;\n }\n const newCheckedValue = !selected;\n setSelected(newCheckedValue);\n if (onSelectionChange) {\n onSelectionChange(event, {\n selected: newCheckedValue\n });\n }\n }, [\n onSelectionChange,\n selected,\n setSelected,\n shouldRestrictTriggerAction\n ]);\n const onKeyDownHandler = React.useCallback((event)=>{\n if ([\n Enter\n ].includes(event.key)) {\n event.preventDefault();\n onChangeHandler(event);\n }\n }, [\n onChangeHandler\n ]);\n const checkboxSlot = React.useMemo(()=>{\n if (!selectable || floatingAction) {\n return;\n }\n const selectableCheckboxProps = {};\n if (referenceId) {\n selectableCheckboxProps['aria-labelledby'] = referenceId;\n } else if (referenceLabel) {\n selectableCheckboxProps['aria-label'] = referenceLabel;\n }\n return slot.optional(checkbox, {\n defaultProps: {\n ref: checkboxRef,\n type: 'checkbox',\n checked: selected,\n onChange: (event)=>onChangeHandler(event),\n onFocus: ()=>setSelectFocused(true),\n onBlur: ()=>setSelectFocused(false),\n ...selectableCheckboxProps\n },\n elementType: 'input'\n });\n }, [\n checkbox,\n floatingAction,\n selected,\n selectable,\n onChangeHandler,\n referenceId,\n referenceLabel\n ]);\n const floatingActionSlot = React.useMemo(()=>{\n if (!floatingAction) {\n return;\n }\n return slot.optional(floatingAction, {\n defaultProps: {\n ref: checkboxRef\n },\n elementType: 'div'\n });\n }, [\n floatingAction\n ]);\n const selectableCardProps = React.useMemo(()=>{\n if (!selectable) {\n return null;\n }\n return {\n onClick: mergeCallbacks(onClick, onChangeHandler),\n onKeyDown: mergeCallbacks(onKeyDown, onKeyDownHandler)\n };\n }, [\n selectable,\n onChangeHandler,\n onClick,\n onKeyDown,\n onKeyDownHandler\n ]);\n return {\n selected,\n selectable,\n selectFocused,\n selectableCardProps,\n checkboxSlot,\n floatingActionSlot\n };\n};\n"],"names":["useCardSelectable","props","referenceLabel","referenceId","cardRef","checkbox","onSelectionChange","floatingAction","onClick","onKeyDown","findAllFocusable","useFocusFinders","checkboxRef","React","useRef","selected","setSelected","useControllableState","state","defaultState","defaultSelected","initialState","selectable","some","prop","selectFocused","setSelectFocused","useState","shouldRestrictTriggerAction","useCallback","event","current","focusableElements","target","isElementInFocusableGroup","element","contains","isCheckboxSlot","onChangeHandler","newCheckedValue","onKeyDownHandler","Enter","includes","key","preventDefault","checkboxSlot","useMemo","selectableCheckboxProps","slot","optional","defaultProps","ref","type","checked","onChange","onFocus","onBlur","elementType","floatingActionSlot","selectableCardProps","mergeCallbacks"],"mappings":";;;;+BAeiBA;;;eAAAA;;;;iEAfM;gCACoC;8BACrC;8BACU;AAYrB,MAAMA,oBAAoB,CAACC,OAAO,EAAE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H;IACD,OAAO;QACHzB;QACAO;QACAG;QACAkC;QACAd;QACAa;IACJ;AACJ"}
@@ -32,11 +32,10 @@ const _useCardHeaderStylesstyles = require("./useCardHeaderStyles.styles");
32
32
  *
33
33
  * @returns the id to use for the CardHeader root element
34
34
  */ function getReferenceId(headerId, childWithId, generatedId) {
35
- var _childWithId;
36
35
  if (headerId) {
37
36
  return headerId;
38
37
  }
39
- if ((_childWithId = childWithId) === null || _childWithId === void 0 ? void 0 : _childWithId.props.id) {
38
+ if (childWithId === null || childWithId === void 0 ? void 0 : childWithId.props.id) {
40
39
  return childWithId.props.id;
41
40
  }
42
41
  return generatedId;
@@ -56,9 +55,9 @@ const useCardHeader_unstable = (props, ref)=>{
56
55
  elementType: 'div'
57
56
  });
58
57
  _react.useEffect(()=>{
59
- var _headerRef_current, _headerSlot;
58
+ var _headerRef_current;
60
59
  const headerId = !hasChildId.current ? (_headerRef_current = headerRef.current) === null || _headerRef_current === void 0 ? void 0 : _headerRef_current.id : undefined;
61
- const childWithId = getChildWithId((_headerSlot = headerSlot) === null || _headerSlot === void 0 ? void 0 : _headerSlot.children);
60
+ const childWithId = getChildWithId(headerSlot === null || headerSlot === void 0 ? void 0 : headerSlot.children);
62
61
  hasChildId.current = Boolean(childWithId);
63
62
  setReferenceId(getReferenceId(headerId, childWithId, generatedId));
64
63
  }, [
@@ -1 +1 @@
1
- {"version":3,"sources":["useCardHeader.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useId, slot } from '@fluentui/react-utilities';\nimport { useCardContext_unstable } from '../Card/CardContext';\nimport { cardHeaderClassNames } from './useCardHeaderStyles.styles';\n/**\n * Finds the first child of CardHeader with an id prop.\n *\n * @param header - the header prop of CardHeader\n */ function getChildWithId(header) {\n function isReactElementWithIdProp(element) {\n return React.isValidElement(element) && Boolean(element.props.id);\n }\n return React.Children.toArray(header).find(isReactElementWithIdProp);\n}\n/**\n * Returns the id to use for the CardHeader root element.\n *\n * @param headerId - the id prop of the CardHeader component\n * @param childWithId - the first child of the CardHeader component with an id prop\n * @param generatedId - a generated id\n *\n * @returns the id to use for the CardHeader root element\n */ function getReferenceId(headerId, childWithId, generatedId) {\n var _childWithId;\n if (headerId) {\n return headerId;\n }\n if ((_childWithId = childWithId) === null || _childWithId === void 0 ? void 0 : _childWithId.props.id) {\n return childWithId.props.id;\n }\n return generatedId;\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 */ export const useCardHeader_unstable = (props, ref)=>{\n const { image, header, description, action } = props;\n const { selectableA11yProps: { referenceId, setReferenceId } } = useCardContext_unstable();\n const headerRef = React.useRef(null);\n const hasChildId = React.useRef(false);\n const generatedId = useId(cardHeaderClassNames.header, referenceId);\n const headerSlot = slot.optional(header, {\n renderByDefault: true,\n defaultProps: {\n ref: headerRef,\n id: !hasChildId.current ? referenceId : undefined\n },\n elementType: 'div'\n });\n React.useEffect(()=>{\n var _headerRef_current, _headerSlot;\n const headerId = !hasChildId.current ? (_headerRef_current = headerRef.current) === null || _headerRef_current === void 0 ? void 0 : _headerRef_current.id : undefined;\n const childWithId = getChildWithId((_headerSlot = headerSlot) === null || _headerSlot === void 0 ? void 0 : _headerSlot.children);\n hasChildId.current = Boolean(childWithId);\n setReferenceId(getReferenceId(headerId, childWithId, generatedId));\n }, [\n generatedId,\n header,\n headerSlot,\n setReferenceId\n ]);\n return {\n components: {\n root: 'div',\n image: 'div',\n header: 'div',\n description: 'div',\n action: 'div'\n },\n root: slot.always(getNativeElementProps('div', {\n ref,\n ...props\n }), {\n elementType: 'div'\n }),\n image: slot.optional(image, {\n elementType: 'div'\n }),\n header: headerSlot,\n description: slot.optional(description, {\n elementType: 'div'\n }),\n action: slot.optional(action, {\n elementType: 'div'\n })\n };\n};\n"],"names":["useCardHeader_unstable","getChildWithId","header","isReactElementWithIdProp","element","React","isValidElement","Boolean","props","id","Children","toArray","find","getReferenceId","headerId","childWithId","generatedId","_childWithId","ref","image","description","action","selectableA11yProps","referenceId","setReferenceId","useCardContext_unstable","headerRef","useRef","hasChildId","useId","cardHeaderClassNames","headerSlot","slot","optional","renderByDefault","defaultProps","current","undefined","elementType","useEffect","_headerRef_current","_headerSlot","children","components","root","always","getNativeElementProps"],"mappings":";;;;+BAwCiBA;;;eAAAA;;;;iEAxCM;gCAC4B;6BACX;2CACH;AACrC;;;;CAIC,GAAG,SAASC,eAAeC,MAAM;IAC9B,SAASC,yBAAyBC,OAAO;QACrC,qBAAOC,OAAMC,cAAc,CAACF,YAAYG,QAAQH,QAAQI,KAAK,CAACC,EAAE;IACpE;IACA,OAAOJ,OAAMK,QAAQ,CAACC,OAAO,CAACT,QAAQU,IAAI,CAACT;AAC/C;AACA;;;;;;;;CAQC,GAAG,SAASU,eAAeC,QAAQ,EAAEC,WAAW,EAAEC,WAAW;IAC1D,IAAIC;IACJ,IAAIH,UAAU;QACV,OAAOA;IACX;IACA,IAAI,AAACG,CAAAA,eAAeF,WAAU,MAAO,QAAQE,iBAAiB,KAAK,IAAI,KAAK,IAAIA,aAAaT,KAAK,CAACC,EAAE,EAAE;QACnG,OAAOM,YAAYP,KAAK,CAACC,EAAE;IAC/B;IACA,OAAOO;AACX;AASW,MAAMhB,yBAAyB,CAACQ,OAAOU;IAC9C,MAAM,EAAEC,KAAK,EAAEjB,MAAM,EAAEkB,WAAW,EAAEC,MAAM,EAAE,GAAGb;IAC/C,MAAM,EAAEc,qBAAqB,EAAEC,WAAW,EAAEC,cAAc,EAAE,EAAE,GAAGC,IAAAA,oCAAuB;IACxF,MAAMC,YAAYrB,OAAMsB,MAAM,CAAC;IAC/B,MAAMC,aAAavB,OAAMsB,MAAM,CAAC;IAChC,MAAMX,cAAca,IAAAA,qBAAK,EAACC,+CAAoB,CAAC5B,MAAM,EAAEqB;IACvD,MAAMQ,aAAaC,oBAAI,CAACC,QAAQ,CAAC/B,QAAQ;QACrCgC,iBAAiB;QACjBC,cAAc;YACVjB,KAAKQ;YACLjB,IAAI,CAACmB,WAAWQ,OAAO,GAAGb,cAAcc;QAC5C;QACAC,aAAa;IACjB;IACAjC,OAAMkC,SAAS,CAAC;QACZ,IAAIC,oBAAoBC;QACxB,MAAM3B,WAAW,CAACc,WAAWQ,OAAO,GAAG,AAACI,CAAAA,qBAAqBd,UAAUU,OAAO,AAAD,MAAO,QAAQI,uBAAuB,KAAK,IAAI,KAAK,IAAIA,mBAAmB/B,EAAE,GAAG4B;QAC7J,MAAMtB,cAAcd,eAAe,AAACwC,CAAAA,cAAcV,UAAS,MAAO,QAAQU,gBAAgB,KAAK,IAAI,KAAK,IAAIA,YAAYC,QAAQ;QAChId,WAAWQ,OAAO,GAAG7B,QAAQQ;QAC7BS,eAAeX,eAAeC,UAAUC,aAAaC;IACzD,GAAG;QACCA;QACAd;QACA6B;QACAP;KACH;IACD,OAAO;QACHmB,YAAY;YACRC,MAAM;YACNzB,OAAO;YACPjB,QAAQ;YACRkB,aAAa;YACbC,QAAQ;QACZ;QACAuB,MAAMZ,oBAAI,CAACa,MAAM,CAACC,IAAAA,qCAAqB,EAAC,OAAO;YAC3C5B;YACA,GAAGV,KAAK;QACZ,IAAI;YACA8B,aAAa;QACjB;QACAnB,OAAOa,oBAAI,CAACC,QAAQ,CAACd,OAAO;YACxBmB,aAAa;QACjB;QACApC,QAAQ6B;QACRX,aAAaY,oBAAI,CAACC,QAAQ,CAACb,aAAa;YACpCkB,aAAa;QACjB;QACAjB,QAAQW,oBAAI,CAACC,QAAQ,CAACZ,QAAQ;YAC1BiB,aAAa;QACjB;IACJ;AACJ"}
1
+ {"version":3,"sources":["useCardHeader.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useId, slot } from '@fluentui/react-utilities';\nimport { useCardContext_unstable } from '../Card/CardContext';\nimport { cardHeaderClassNames } from './useCardHeaderStyles.styles';\n/**\n * Finds the first child of CardHeader with an id prop.\n *\n * @param header - the header prop of CardHeader\n */ function getChildWithId(header) {\n function isReactElementWithIdProp(element) {\n return React.isValidElement(element) && Boolean(element.props.id);\n }\n return React.Children.toArray(header).find(isReactElementWithIdProp);\n}\n/**\n * Returns the id to use for the CardHeader root element.\n *\n * @param headerId - the id prop of the CardHeader component\n * @param childWithId - the first child of the CardHeader component with an id prop\n * @param generatedId - a generated id\n *\n * @returns the id to use for the CardHeader root element\n */ function getReferenceId(headerId, childWithId, generatedId) {\n if (headerId) {\n return headerId;\n }\n if (childWithId === null || childWithId === void 0 ? void 0 : childWithId.props.id) {\n return childWithId.props.id;\n }\n return generatedId;\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 */ export const useCardHeader_unstable = (props, ref)=>{\n const { image, header, description, action } = props;\n const { selectableA11yProps: { referenceId, setReferenceId } } = useCardContext_unstable();\n const headerRef = React.useRef(null);\n const hasChildId = React.useRef(false);\n const generatedId = useId(cardHeaderClassNames.header, referenceId);\n const headerSlot = slot.optional(header, {\n renderByDefault: true,\n defaultProps: {\n ref: headerRef,\n id: !hasChildId.current ? referenceId : undefined\n },\n elementType: 'div'\n });\n React.useEffect(()=>{\n var _headerRef_current;\n const headerId = !hasChildId.current ? (_headerRef_current = headerRef.current) === null || _headerRef_current === void 0 ? void 0 : _headerRef_current.id : undefined;\n const childWithId = getChildWithId(headerSlot === null || headerSlot === void 0 ? void 0 : headerSlot.children);\n hasChildId.current = Boolean(childWithId);\n setReferenceId(getReferenceId(headerId, childWithId, generatedId));\n }, [\n generatedId,\n header,\n headerSlot,\n setReferenceId\n ]);\n return {\n components: {\n root: 'div',\n image: 'div',\n header: 'div',\n description: 'div',\n action: 'div'\n },\n root: slot.always(getNativeElementProps('div', {\n ref,\n ...props\n }), {\n elementType: 'div'\n }),\n image: slot.optional(image, {\n elementType: 'div'\n }),\n header: headerSlot,\n description: slot.optional(description, {\n elementType: 'div'\n }),\n action: slot.optional(action, {\n elementType: 'div'\n })\n };\n};\n"],"names":["useCardHeader_unstable","getChildWithId","header","isReactElementWithIdProp","element","React","isValidElement","Boolean","props","id","Children","toArray","find","getReferenceId","headerId","childWithId","generatedId","ref","image","description","action","selectableA11yProps","referenceId","setReferenceId","useCardContext_unstable","headerRef","useRef","hasChildId","useId","cardHeaderClassNames","headerSlot","slot","optional","renderByDefault","defaultProps","current","undefined","elementType","useEffect","_headerRef_current","children","components","root","always","getNativeElementProps"],"mappings":";;;;+BAuCiBA;;;eAAAA;;;;iEAvCM;gCAC4B;6BACX;2CACH;AACrC;;;;CAIC,GAAG,SAASC,eAAeC,MAAM;IAC9B,SAASC,yBAAyBC,OAAO;QACrC,qBAAOC,OAAMC,cAAc,CAACF,YAAYG,QAAQH,QAAQI,KAAK,CAACC,EAAE;IACpE;IACA,OAAOJ,OAAMK,QAAQ,CAACC,OAAO,CAACT,QAAQU,IAAI,CAACT;AAC/C;AACA;;;;;;;;CAQC,GAAG,SAASU,eAAeC,QAAQ,EAAEC,WAAW,EAAEC,WAAW;IAC1D,IAAIF,UAAU;QACV,OAAOA;IACX;IACA,IAAIC,gBAAgB,QAAQA,gBAAgB,KAAK,IAAI,KAAK,IAAIA,YAAYP,KAAK,CAACC,EAAE,EAAE;QAChF,OAAOM,YAAYP,KAAK,CAACC,EAAE;IAC/B;IACA,OAAOO;AACX;AASW,MAAMhB,yBAAyB,CAACQ,OAAOS;IAC9C,MAAM,EAAEC,KAAK,EAAEhB,MAAM,EAAEiB,WAAW,EAAEC,MAAM,EAAE,GAAGZ;IAC/C,MAAM,EAAEa,qBAAqB,EAAEC,WAAW,EAAEC,cAAc,EAAE,EAAE,GAAGC,IAAAA,oCAAuB;IACxF,MAAMC,YAAYpB,OAAMqB,MAAM,CAAC;IAC/B,MAAMC,aAAatB,OAAMqB,MAAM,CAAC;IAChC,MAAMV,cAAcY,IAAAA,qBAAK,EAACC,+CAAoB,CAAC3B,MAAM,EAAEoB;IACvD,MAAMQ,aAAaC,oBAAI,CAACC,QAAQ,CAAC9B,QAAQ;QACrC+B,iBAAiB;QACjBC,cAAc;YACVjB,KAAKQ;YACLhB,IAAI,CAACkB,WAAWQ,OAAO,GAAGb,cAAcc;QAC5C;QACAC,aAAa;IACjB;IACAhC,OAAMiC,SAAS,CAAC;QACZ,IAAIC;QACJ,MAAMzB,WAAW,CAACa,WAAWQ,OAAO,GAAG,AAACI,CAAAA,qBAAqBd,UAAUU,OAAO,AAAD,MAAO,QAAQI,uBAAuB,KAAK,IAAI,KAAK,IAAIA,mBAAmB9B,EAAE,GAAG2B;QAC7J,MAAMrB,cAAcd,eAAe6B,eAAe,QAAQA,eAAe,KAAK,IAAI,KAAK,IAAIA,WAAWU,QAAQ;QAC9Gb,WAAWQ,OAAO,GAAG5B,QAAQQ;QAC7BQ,eAAeV,eAAeC,UAAUC,aAAaC;IACzD,GAAG;QACCA;QACAd;QACA4B;QACAP;KACH;IACD,OAAO;QACHkB,YAAY;YACRC,MAAM;YACNxB,OAAO;YACPhB,QAAQ;YACRiB,aAAa;YACbC,QAAQ;QACZ;QACAsB,MAAMX,oBAAI,CAACY,MAAM,CAACC,IAAAA,qCAAqB,EAAC,OAAO;YAC3C3B;YACA,GAAGT,KAAK;QACZ,IAAI;YACA6B,aAAa;QACjB;QACAnB,OAAOa,oBAAI,CAACC,QAAQ,CAACd,OAAO;YACxBmB,aAAa;QACjB;QACAnC,QAAQ4B;QACRX,aAAaY,oBAAI,CAACC,QAAQ,CAACb,aAAa;YACpCkB,aAAa;QACjB;QACAjB,QAAQW,oBAAI,CAACC,QAAQ,CAACZ,QAAQ;YAC1BiB,aAAa;QACjB;IACJ;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-card",
3
- "version": "9.0.40",
3
+ "version": "9.0.42",
4
4
  "private": false,
5
5
  "description": "Card container components for Fluent UI React.",
6
6
  "main": "lib-commonjs/index.js",
@@ -38,11 +38,11 @@
38
38
  "@fluentui/scripts-tasks": "*"
39
39
  },
40
40
  "dependencies": {
41
- "@fluentui/keyboard-keys": "^9.0.4",
42
- "@fluentui/react-tabster": "^9.12.11",
43
- "@fluentui/react-theme": "^9.1.12",
44
- "@fluentui/react-utilities": "^9.13.3",
45
- "@fluentui/react-jsx-runtime": "^9.0.10",
41
+ "@fluentui/keyboard-keys": "^9.0.6",
42
+ "@fluentui/react-tabster": "^9.13.1",
43
+ "@fluentui/react-theme": "^9.1.14",
44
+ "@fluentui/react-utilities": "^9.13.5",
45
+ "@fluentui/react-jsx-runtime": "^9.0.12",
46
46
  "@griffel/react": "^1.5.14",
47
47
  "@swc/helpers": "^0.5.1"
48
48
  },