@fluentui/react-card 9.6.0 → 9.7.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 (61) hide show
  1. package/CHANGELOG.md +31 -2
  2. package/dist/index.d.ts +13 -2
  3. package/lib/components/Card/Card.types.js +1 -1
  4. package/lib/components/Card/Card.types.js.map +1 -1
  5. package/lib/components/Card/CardContext.js.map +1 -1
  6. package/lib/components/Card/useCard.js +66 -51
  7. package/lib/components/Card/useCard.js.map +1 -1
  8. package/lib/components/Card/useCardSelectable.js +13 -20
  9. package/lib/components/Card/useCardSelectable.js.map +1 -1
  10. package/lib/components/Card/useCardStyles.styles.js +3 -0
  11. package/lib/components/Card/useCardStyles.styles.js.map +1 -1
  12. package/lib/components/Card/useCardStyles.styles.raw.js +3 -0
  13. package/lib/components/Card/useCardStyles.styles.raw.js.map +1 -1
  14. package/lib/components/CardFooter/useCardFooter.js +0 -1
  15. package/lib/components/CardFooter/useCardFooter.js.map +1 -1
  16. package/lib/components/CardFooter/useCardFooterStyles.styles.js +2 -0
  17. package/lib/components/CardFooter/useCardFooterStyles.styles.js.map +1 -1
  18. package/lib/components/CardFooter/useCardFooterStyles.styles.raw.js +2 -0
  19. package/lib/components/CardFooter/useCardFooterStyles.styles.raw.js.map +1 -1
  20. package/lib/components/CardHeader/useCardHeader.js +3 -2
  21. package/lib/components/CardHeader/useCardHeader.js.map +1 -1
  22. package/lib/components/CardHeader/useCardHeaderStyles.styles.js +5 -0
  23. package/lib/components/CardHeader/useCardHeaderStyles.styles.js.map +1 -1
  24. package/lib/components/CardHeader/useCardHeaderStyles.styles.raw.js +5 -0
  25. package/lib/components/CardHeader/useCardHeaderStyles.styles.raw.js.map +1 -1
  26. package/lib/components/CardPreview/useCardPreview.js +3 -3
  27. package/lib/components/CardPreview/useCardPreview.js.map +1 -1
  28. package/lib/components/CardPreview/useCardPreviewStyles.styles.js +2 -0
  29. package/lib/components/CardPreview/useCardPreviewStyles.styles.js.map +1 -1
  30. package/lib/components/CardPreview/useCardPreviewStyles.styles.raw.js +2 -0
  31. package/lib/components/CardPreview/useCardPreviewStyles.styles.raw.js.map +1 -1
  32. package/lib-commonjs/components/Card/Card.types.js +0 -2
  33. package/lib-commonjs/components/Card/Card.types.js.map +1 -1
  34. package/lib-commonjs/components/Card/CardContext.js.map +1 -1
  35. package/lib-commonjs/components/Card/useCard.js +58 -49
  36. package/lib-commonjs/components/Card/useCard.js.map +1 -1
  37. package/lib-commonjs/components/Card/useCardSelectable.js +11 -18
  38. package/lib-commonjs/components/Card/useCardSelectable.js.map +1 -1
  39. package/lib-commonjs/components/Card/useCardStyles.styles.js +3 -0
  40. package/lib-commonjs/components/Card/useCardStyles.styles.js.map +1 -1
  41. package/lib-commonjs/components/Card/useCardStyles.styles.raw.js +3 -0
  42. package/lib-commonjs/components/Card/useCardStyles.styles.raw.js.map +1 -1
  43. package/lib-commonjs/components/CardFooter/useCardFooter.js +0 -2
  44. package/lib-commonjs/components/CardFooter/useCardFooter.js.map +1 -1
  45. package/lib-commonjs/components/CardFooter/useCardFooterStyles.styles.js +2 -0
  46. package/lib-commonjs/components/CardFooter/useCardFooterStyles.styles.js.map +1 -1
  47. package/lib-commonjs/components/CardFooter/useCardFooterStyles.styles.raw.js +2 -0
  48. package/lib-commonjs/components/CardFooter/useCardFooterStyles.styles.raw.js.map +1 -1
  49. package/lib-commonjs/components/CardHeader/useCardHeader.js +3 -2
  50. package/lib-commonjs/components/CardHeader/useCardHeader.js.map +1 -1
  51. package/lib-commonjs/components/CardHeader/useCardHeaderStyles.styles.js +5 -0
  52. package/lib-commonjs/components/CardHeader/useCardHeaderStyles.styles.js.map +1 -1
  53. package/lib-commonjs/components/CardHeader/useCardHeaderStyles.styles.raw.js +5 -0
  54. package/lib-commonjs/components/CardHeader/useCardHeaderStyles.styles.raw.js.map +1 -1
  55. package/lib-commonjs/components/CardPreview/useCardPreview.js +1 -2
  56. package/lib-commonjs/components/CardPreview/useCardPreview.js.map +1 -1
  57. package/lib-commonjs/components/CardPreview/useCardPreviewStyles.styles.js +2 -0
  58. package/lib-commonjs/components/CardPreview/useCardPreviewStyles.styles.js.map +1 -1
  59. package/lib-commonjs/components/CardPreview/useCardPreviewStyles.styles.raw.js +2 -0
  60. package/lib-commonjs/components/CardPreview/useCardPreviewStyles.styles.raw.js.map +1 -1
  61. package/package.json +5 -5
@@ -2,7 +2,6 @@
2
2
  import * as React from 'react';
3
3
  import { getIntrinsicElementProps, useMergedRefs, slot } from '@fluentui/react-utilities';
4
4
  import { useCardContext_unstable } from '../Card/CardContext';
5
- import { cardPreviewClassNames } from './useCardPreviewStyles.styles';
6
5
  /**
7
6
  * Create the state required to render CardPreview.
8
7
  *
@@ -33,7 +32,7 @@ import { cardPreviewClassNames } from './useCardPreviewStyles.styles';
33
32
  return;
34
33
  }
35
34
  if (previewRef.current && previewRef.current.parentNode) {
36
- const img = previewRef.current.parentNode.querySelector(`.${cardPreviewClassNames.root} > img`);
35
+ const img = previewRef.current.parentNode.querySelector(`.fui-CardPreview > img`);
37
36
  if (img) {
38
37
  const ariaLabel = img.getAttribute('aria-label');
39
38
  const ariaDescribedby = img.getAttribute('aria-describedby');
@@ -58,7 +57,8 @@ import { cardPreviewClassNames } from './useCardPreviewStyles.styles';
58
57
  root: 'div',
59
58
  logo: 'div'
60
59
  },
61
- root: slot.always(getIntrinsicElementProps('div', {
60
+ root: slot.always(// eslint-disable-next-line react-hooks/refs
61
+ getIntrinsicElementProps('div', {
62
62
  ref: previewRef,
63
63
  ...props
64
64
  }), {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/CardPreview/useCardPreview.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { getIntrinsicElementProps, useMergedRefs, slot } from '@fluentui/react-utilities';\nimport type {\n CardPreviewBaseProps,\n CardPreviewBaseState,\n CardPreviewProps,\n CardPreviewState,\n} from './CardPreview.types';\nimport { useCardContext_unstable } from '../Card/CardContext';\nimport { cardPreviewClassNames } from './useCardPreviewStyles.styles';\n\n/**\n * Create the state required to render CardPreview.\n *\n * The returned state can be modified with hooks such as useCardPreviewStyles_unstable,\n * before being passed to renderCardPreview_unstable.\n *\n * @param props - props from this instance of CardPreview\n * @param ref - reference to root HTMLElement of CardPreview\n */\nexport const useCardPreview_unstable = (props: CardPreviewProps, ref: React.Ref<HTMLElement>): CardPreviewState => {\n return useCardPreviewBase_unstable(props, ref);\n};\n\n/**\n * Base hook for CardPreview component, which manages state related to slots structure\n * and the card's selectable accessibility label.\n * Note: CardPreview has no design props, so this is equivalent to useCardPreview_unstable.\n *\n * @param props - props from this instance of CardPreview\n * @param ref - reference to root HTMLElement of CardPreview\n */\nexport const useCardPreviewBase_unstable = (\n props: CardPreviewBaseProps,\n ref: React.Ref<HTMLElement>,\n): CardPreviewBaseState => {\n const { logo } = props;\n\n const {\n selectableA11yProps: { referenceLabel, referenceId, setReferenceLabel, setReferenceId },\n } = useCardContext_unstable();\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n const previewRef = useMergedRefs(ref as React.Ref<HTMLDivElement>, React.useRef<HTMLDivElement>(null));\n\n React.useEffect(() => {\n if (referenceLabel && referenceId) {\n return;\n }\n\n if (previewRef.current && previewRef.current.parentNode) {\n const img = previewRef.current.parentNode.querySelector<HTMLImageElement>(`.${cardPreviewClassNames.root} > img`);\n\n if (img) {\n const ariaLabel = img.getAttribute('aria-label');\n const ariaDescribedby = img.getAttribute('aria-describedby');\n\n if (ariaDescribedby) {\n setReferenceId(ariaDescribedby);\n } else if (img.alt) {\n setReferenceLabel(img.alt);\n } else if (ariaLabel) {\n setReferenceLabel(ariaLabel);\n }\n }\n }\n }, [setReferenceLabel, referenceLabel, previewRef, referenceId, setReferenceId]);\n\n return {\n components: {\n root: 'div',\n logo: 'div',\n },\n\n root: slot.always(\n getIntrinsicElementProps('div', {\n ref: previewRef,\n ...props,\n }),\n { elementType: 'div' },\n ),\n logo: slot.optional(logo, { elementType: 'div' }),\n };\n};\n"],"names":["React","getIntrinsicElementProps","useMergedRefs","slot","useCardContext_unstable","cardPreviewClassNames","useCardPreview_unstable","props","ref","useCardPreviewBase_unstable","logo","selectableA11yProps","referenceLabel","referenceId","setReferenceLabel","setReferenceId","previewRef","useRef","useEffect","current","parentNode","img","querySelector","root","ariaLabel","getAttribute","ariaDescribedby","alt","components","always","elementType","optional"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,wBAAwB,EAAEC,aAAa,EAAEC,IAAI,QAAQ,4BAA4B;AAO1F,SAASC,uBAAuB,QAAQ,sBAAsB;AAC9D,SAASC,qBAAqB,QAAQ,gCAAgC;AAEtE;;;;;;;;CAQC,GACD,OAAO,MAAMC,0BAA0B,CAACC,OAAyBC;IAC/D,OAAOC,4BAA4BF,OAAOC;AAC5C,EAAE;AAEF;;;;;;;CAOC,GACD,OAAO,MAAMC,8BAA8B,CACzCF,OACAC;IAEA,MAAM,EAAEE,IAAI,EAAE,GAAGH;IAEjB,MAAM,EACJI,qBAAqB,EAAEC,cAAc,EAAEC,WAAW,EAAEC,iBAAiB,EAAEC,cAAc,EAAE,EACxF,GAAGX;IACJ,SAAS;IACT,4EAA4E;IAC5E,4FAA4F;IAC5F,MAAMY,aAAad,cAAcM,KAAkCR,MAAMiB,MAAM,CAAiB;IAEhGjB,MAAMkB,SAAS,CAAC;QACd,IAAIN,kBAAkBC,aAAa;YACjC;QACF;QAEA,IAAIG,WAAWG,OAAO,IAAIH,WAAWG,OAAO,CAACC,UAAU,EAAE;YACvD,MAAMC,MAAML,WAAWG,OAAO,CAACC,UAAU,CAACE,aAAa,CAAmB,CAAC,CAAC,EAAEjB,sBAAsBkB,IAAI,CAAC,MAAM,CAAC;YAEhH,IAAIF,KAAK;gBACP,MAAMG,YAAYH,IAAII,YAAY,CAAC;gBACnC,MAAMC,kBAAkBL,IAAII,YAAY,CAAC;gBAEzC,IAAIC,iBAAiB;oBACnBX,eAAeW;gBACjB,OAAO,IAAIL,IAAIM,GAAG,EAAE;oBAClBb,kBAAkBO,IAAIM,GAAG;gBAC3B,OAAO,IAAIH,WAAW;oBACpBV,kBAAkBU;gBACpB;YACF;QACF;IACF,GAAG;QAACV;QAAmBF;QAAgBI;QAAYH;QAAaE;KAAe;IAE/E,OAAO;QACLa,YAAY;YACVL,MAAM;YACNb,MAAM;QACR;QAEAa,MAAMpB,KAAK0B,MAAM,CACf5B,yBAAyB,OAAO;YAC9BO,KAAKQ;YACL,GAAGT,KAAK;QACV,IACA;YAAEuB,aAAa;QAAM;QAEvBpB,MAAMP,KAAK4B,QAAQ,CAACrB,MAAM;YAAEoB,aAAa;QAAM;IACjD;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/components/CardPreview/useCardPreview.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { getIntrinsicElementProps, useMergedRefs, slot } from '@fluentui/react-utilities';\nimport type {\n CardPreviewBaseProps,\n CardPreviewBaseState,\n CardPreviewProps,\n CardPreviewState,\n} from './CardPreview.types';\nimport { useCardContext_unstable } from '../Card/CardContext';\n\n/**\n * Create the state required to render CardPreview.\n *\n * The returned state can be modified with hooks such as useCardPreviewStyles_unstable,\n * before being passed to renderCardPreview_unstable.\n *\n * @param props - props from this instance of CardPreview\n * @param ref - reference to root HTMLElement of CardPreview\n */\nexport const useCardPreview_unstable = (props: CardPreviewProps, ref: React.Ref<HTMLElement>): CardPreviewState => {\n return useCardPreviewBase_unstable(props, ref);\n};\n\n/**\n * Base hook for CardPreview component, which manages state related to slots structure\n * and the card's selectable accessibility label.\n * Note: CardPreview has no design props, so this is equivalent to useCardPreview_unstable.\n *\n * @param props - props from this instance of CardPreview\n * @param ref - reference to root HTMLElement of CardPreview\n */\nexport const useCardPreviewBase_unstable = (\n props: CardPreviewBaseProps,\n ref: React.Ref<HTMLElement>,\n): CardPreviewBaseState => {\n const { logo } = props;\n\n const {\n selectableA11yProps: { referenceLabel, referenceId, setReferenceLabel, setReferenceId },\n } = useCardContext_unstable();\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n const previewRef = useMergedRefs(ref as React.Ref<HTMLDivElement>, React.useRef<HTMLDivElement>(null));\n\n React.useEffect(() => {\n if (referenceLabel && referenceId) {\n return;\n }\n\n if (previewRef.current && previewRef.current.parentNode) {\n const img = previewRef.current.parentNode.querySelector<HTMLImageElement>(`.fui-CardPreview > img`);\n\n if (img) {\n const ariaLabel = img.getAttribute('aria-label');\n const ariaDescribedby = img.getAttribute('aria-describedby');\n\n if (ariaDescribedby) {\n setReferenceId(ariaDescribedby);\n } else if (img.alt) {\n setReferenceLabel(img.alt);\n } else if (ariaLabel) {\n setReferenceLabel(ariaLabel);\n }\n }\n }\n }, [setReferenceLabel, referenceLabel, previewRef, referenceId, setReferenceId]);\n\n return {\n components: {\n root: 'div',\n logo: 'div',\n },\n\n root: slot.always(\n // eslint-disable-next-line react-hooks/refs\n getIntrinsicElementProps('div', {\n ref: previewRef,\n ...props,\n }),\n { elementType: 'div' },\n ),\n logo: slot.optional(logo, { elementType: 'div' }),\n };\n};\n"],"names":["React","getIntrinsicElementProps","useMergedRefs","slot","useCardContext_unstable","useCardPreview_unstable","props","ref","useCardPreviewBase_unstable","logo","selectableA11yProps","referenceLabel","referenceId","setReferenceLabel","setReferenceId","previewRef","useRef","useEffect","current","parentNode","img","querySelector","ariaLabel","getAttribute","ariaDescribedby","alt","components","root","always","elementType","optional"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,wBAAwB,EAAEC,aAAa,EAAEC,IAAI,QAAQ,4BAA4B;AAO1F,SAASC,uBAAuB,QAAQ,sBAAsB;AAE9D;;;;;;;;CAQC,GACD,OAAO,MAAMC,0BAA0B,CAACC,OAAyBC;IAC/D,OAAOC,4BAA4BF,OAAOC;AAC5C,EAAE;AAEF;;;;;;;CAOC,GACD,OAAO,MAAMC,8BAA8B,CACzCF,OACAC;IAEA,MAAM,EAAEE,IAAI,EAAE,GAAGH;IAEjB,MAAM,EACJI,qBAAqB,EAAEC,cAAc,EAAEC,WAAW,EAAEC,iBAAiB,EAAEC,cAAc,EAAE,EACxF,GAAGV;IACJ,SAAS;IACT,4EAA4E;IAC5E,4FAA4F;IAC5F,MAAMW,aAAab,cAAcK,KAAkCP,MAAMgB,MAAM,CAAiB;IAEhGhB,MAAMiB,SAAS,CAAC;QACd,IAAIN,kBAAkBC,aAAa;YACjC;QACF;QAEA,IAAIG,WAAWG,OAAO,IAAIH,WAAWG,OAAO,CAACC,UAAU,EAAE;YACvD,MAAMC,MAAML,WAAWG,OAAO,CAACC,UAAU,CAACE,aAAa,CAAmB,CAAC,sBAAsB,CAAC;YAElG,IAAID,KAAK;gBACP,MAAME,YAAYF,IAAIG,YAAY,CAAC;gBACnC,MAAMC,kBAAkBJ,IAAIG,YAAY,CAAC;gBAEzC,IAAIC,iBAAiB;oBACnBV,eAAeU;gBACjB,OAAO,IAAIJ,IAAIK,GAAG,EAAE;oBAClBZ,kBAAkBO,IAAIK,GAAG;gBAC3B,OAAO,IAAIH,WAAW;oBACpBT,kBAAkBS;gBACpB;YACF;QACF;IACF,GAAG;QAACT;QAAmBF;QAAgBI;QAAYH;QAAaE;KAAe;IAE/E,OAAO;QACLY,YAAY;YACVC,MAAM;YACNlB,MAAM;QACR;QAEAkB,MAAMxB,KAAKyB,MAAM,CACf,4CAA4C;QAC5C3B,yBAAyB,OAAO;YAC9BM,KAAKQ;YACL,GAAGT,KAAK;QACV,IACA;YAAEuB,aAAa;QAAM;QAEvBpB,MAAMN,KAAK2B,QAAQ,CAACrB,MAAM;YAAEoB,aAAa;QAAM;IACjD;AACF,EAAE"}
@@ -32,8 +32,10 @@ export const useCardPreviewStyles_unstable = state => {
32
32
  'use no memo';
33
33
 
34
34
  const styles = useStyles();
35
+ // eslint-disable-next-line react-hooks/immutability
35
36
  state.root.className = mergeClasses(cardPreviewClassNames.root, styles.root, state.root.className);
36
37
  if (state.logo) {
38
+ // eslint-disable-next-line react-hooks/immutability
37
39
  state.logo.className = mergeClasses(cardPreviewClassNames.logo, styles.logo, state.logo.className);
38
40
  }
39
41
  return state;
@@ -1 +1 @@
1
- {"version":3,"names":["__styles","mergeClasses","cardPreviewClassNames","root","logo","useStyles","qhf8xq","Byfpedg","Btj6oj6","B1m4t4s","B5kzvoi","oyh7mz","a9b677","Bqenvij","d","useCardPreviewStyles_unstable","state","styles","className"],"sources":["useCardPreviewStyles.styles.js"],"sourcesContent":["'use client';\nimport { makeStyles, mergeClasses } from '@griffel/react';\n/**\n * Static CSS class names used internally for the component slots.\n */ export const cardPreviewClassNames = {\n root: 'fui-CardPreview',\n logo: 'fui-CardPreview__logo'\n};\nconst useStyles = makeStyles({\n root: {\n position: 'relative',\n [`> :not(.${cardPreviewClassNames.logo})`]: {\n display: 'block',\n height: '100%',\n width: '100%'\n }\n },\n logo: {\n position: 'absolute',\n bottom: '12px',\n left: '12px',\n width: '32px',\n height: '32px'\n }\n});\n/**\n * Apply styling to the CardPreview slots based on the state.\n */ export const useCardPreviewStyles_unstable = (state)=>{\n 'use no memo';\n const styles = useStyles();\n state.root.className = mergeClasses(cardPreviewClassNames.root, styles.root, state.root.className);\n if (state.logo) {\n state.logo.className = mergeClasses(cardPreviewClassNames.logo, styles.logo, state.logo.className);\n }\n return state;\n};\n"],"mappings":"AAAA,YAAY;;AACZ,SAAAA,QAAA,EAAqBC,YAAY,QAAQ,gBAAgB;AACzD;AACA;AACA;AAAI,OAAO,MAAMC,qBAAqB,GAAG;EACrCC,IAAI,EAAE,iBAAiB;EACvBC,IAAI,EAAE;AACV,CAAC;AACD,MAAMC,SAAS,gBAAGL,QAAA;EAAAG,IAAA;IAAAG,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;EAAA;EAAAL,IAAA;IAAAE,MAAA;IAAAI,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;AAAA;EAAAC,CAAA;AAAA,CAgBjB,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMC,6BAA6B,GAAIC,KAAK,IAAG;EACtD,aAAa;;EACb,MAAMC,MAAM,GAAGZ,SAAS,CAAC,CAAC;EAC1BW,KAAK,CAACb,IAAI,CAACe,SAAS,GAAGjB,YAAY,CAACC,qBAAqB,CAACC,IAAI,EAAEc,MAAM,CAACd,IAAI,EAAEa,KAAK,CAACb,IAAI,CAACe,SAAS,CAAC;EAClG,IAAIF,KAAK,CAACZ,IAAI,EAAE;IACZY,KAAK,CAACZ,IAAI,CAACc,SAAS,GAAGjB,YAAY,CAACC,qBAAqB,CAACE,IAAI,EAAEa,MAAM,CAACb,IAAI,EAAEY,KAAK,CAACZ,IAAI,CAACc,SAAS,CAAC;EACtG;EACA,OAAOF,KAAK;AAChB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["__styles","mergeClasses","cardPreviewClassNames","root","logo","useStyles","qhf8xq","Byfpedg","Btj6oj6","B1m4t4s","B5kzvoi","oyh7mz","a9b677","Bqenvij","d","useCardPreviewStyles_unstable","state","styles","className"],"sources":["useCardPreviewStyles.styles.js"],"sourcesContent":["'use client';\nimport { makeStyles, mergeClasses } from '@griffel/react';\n/**\n * Static CSS class names used internally for the component slots.\n */ export const cardPreviewClassNames = {\n root: 'fui-CardPreview',\n logo: 'fui-CardPreview__logo'\n};\nconst useStyles = makeStyles({\n root: {\n position: 'relative',\n [`> :not(.${cardPreviewClassNames.logo})`]: {\n display: 'block',\n height: '100%',\n width: '100%'\n }\n },\n logo: {\n position: 'absolute',\n bottom: '12px',\n left: '12px',\n width: '32px',\n height: '32px'\n }\n});\n/**\n * Apply styling to the CardPreview slots based on the state.\n */ export const useCardPreviewStyles_unstable = (state)=>{\n 'use no memo';\n const styles = useStyles();\n // eslint-disable-next-line react-hooks/immutability\n state.root.className = mergeClasses(cardPreviewClassNames.root, styles.root, state.root.className);\n if (state.logo) {\n // eslint-disable-next-line react-hooks/immutability\n state.logo.className = mergeClasses(cardPreviewClassNames.logo, styles.logo, state.logo.className);\n }\n return state;\n};\n"],"mappings":"AAAA,YAAY;;AACZ,SAAAA,QAAA,EAAqBC,YAAY,QAAQ,gBAAgB;AACzD;AACA;AACA;AAAI,OAAO,MAAMC,qBAAqB,GAAG;EACrCC,IAAI,EAAE,iBAAiB;EACvBC,IAAI,EAAE;AACV,CAAC;AACD,MAAMC,SAAS,gBAAGL,QAAA;EAAAG,IAAA;IAAAG,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;EAAA;EAAAL,IAAA;IAAAE,MAAA;IAAAI,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;AAAA;EAAAC,CAAA;AAAA,CAgBjB,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMC,6BAA6B,GAAIC,KAAK,IAAG;EACtD,aAAa;;EACb,MAAMC,MAAM,GAAGZ,SAAS,CAAC,CAAC;EAC1B;EACAW,KAAK,CAACb,IAAI,CAACe,SAAS,GAAGjB,YAAY,CAACC,qBAAqB,CAACC,IAAI,EAAEc,MAAM,CAACd,IAAI,EAAEa,KAAK,CAACb,IAAI,CAACe,SAAS,CAAC;EAClG,IAAIF,KAAK,CAACZ,IAAI,EAAE;IACZ;IACAY,KAAK,CAACZ,IAAI,CAACc,SAAS,GAAGjB,YAAY,CAACC,qBAAqB,CAACE,IAAI,EAAEa,MAAM,CAACb,IAAI,EAAEY,KAAK,CAACZ,IAAI,CAACc,SAAS,CAAC;EACtG;EACA,OAAOF,KAAK;AAChB,CAAC","ignoreList":[]}
@@ -28,8 +28,10 @@ const useStyles = makeStyles({
28
28
  */ export const useCardPreviewStyles_unstable = (state)=>{
29
29
  'use no memo';
30
30
  const styles = useStyles();
31
+ // eslint-disable-next-line react-hooks/immutability
31
32
  state.root.className = mergeClasses(cardPreviewClassNames.root, styles.root, state.root.className);
32
33
  if (state.logo) {
34
+ // eslint-disable-next-line react-hooks/immutability
33
35
  state.logo.className = mergeClasses(cardPreviewClassNames.logo, styles.logo, state.logo.className);
34
36
  }
35
37
  return state;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/CardPreview/useCardPreviewStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport type { CardPreviewSlots, CardPreviewState } from './CardPreview.types';\n\n/**\n * Static CSS class names used internally for the component slots.\n */\nexport const cardPreviewClassNames: SlotClassNames<CardPreviewSlots> = {\n root: 'fui-CardPreview',\n logo: 'fui-CardPreview__logo',\n};\n\nconst useStyles = makeStyles({\n root: {\n position: 'relative',\n\n [`> :not(.${cardPreviewClassNames.logo})`]: {\n display: 'block',\n height: '100%',\n width: '100%',\n },\n },\n\n logo: {\n position: 'absolute',\n bottom: '12px',\n left: '12px',\n width: '32px',\n height: '32px',\n },\n});\n\n/**\n * Apply styling to the CardPreview slots based on the state.\n */\nexport const useCardPreviewStyles_unstable = (state: CardPreviewState): CardPreviewState => {\n 'use no memo';\n\n const styles = useStyles();\n state.root.className = mergeClasses(cardPreviewClassNames.root, styles.root, state.root.className);\n\n if (state.logo) {\n state.logo.className = mergeClasses(cardPreviewClassNames.logo, styles.logo, state.logo.className);\n }\n\n return state;\n};\n"],"names":["makeStyles","mergeClasses","cardPreviewClassNames","root","logo","useStyles","position","display","height","width","bottom","left","useCardPreviewStyles_unstable","state","styles","className"],"mappings":"AAAA;AAGA,SAASA,UAAU,EAAEC,YAAY,QAAQ,iBAAiB;AAG1D;;CAEC,GACD,OAAO,MAAMC,wBAA0D;IACrEC,MAAM;IACNC,MAAM;AACR,EAAE;AAEF,MAAMC,YAAYL,WAAW;IAC3BG,MAAM;QACJG,UAAU;QAEV,CAAC,CAAC,QAAQ,EAAEJ,sBAAsBE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;YAC1CG,SAAS;YACTC,QAAQ;YACRC,OAAO;QACT;IACF;IAEAL,MAAM;QACJE,UAAU;QACVI,QAAQ;QACRC,MAAM;QACNF,OAAO;QACPD,QAAQ;IACV;AACF;AAEA;;CAEC,GACD,OAAO,MAAMI,gCAAgC,CAACC;IAC5C;IAEA,MAAMC,SAAST;IACfQ,MAAMV,IAAI,CAACY,SAAS,GAAGd,aAAaC,sBAAsBC,IAAI,EAAEW,OAAOX,IAAI,EAAEU,MAAMV,IAAI,CAACY,SAAS;IAEjG,IAAIF,MAAMT,IAAI,EAAE;QACdS,MAAMT,IAAI,CAACW,SAAS,GAAGd,aAAaC,sBAAsBE,IAAI,EAAEU,OAAOV,IAAI,EAAES,MAAMT,IAAI,CAACW,SAAS;IACnG;IAEA,OAAOF;AACT,EAAE"}
1
+ {"version":3,"sources":["../src/components/CardPreview/useCardPreviewStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport type { CardPreviewSlots, CardPreviewState } from './CardPreview.types';\n\n/**\n * Static CSS class names used internally for the component slots.\n */\nexport const cardPreviewClassNames: SlotClassNames<CardPreviewSlots> = {\n root: 'fui-CardPreview',\n logo: 'fui-CardPreview__logo',\n};\n\nconst useStyles = makeStyles({\n root: {\n position: 'relative',\n\n [`> :not(.${cardPreviewClassNames.logo})`]: {\n display: 'block',\n height: '100%',\n width: '100%',\n },\n },\n\n logo: {\n position: 'absolute',\n bottom: '12px',\n left: '12px',\n width: '32px',\n height: '32px',\n },\n});\n\n/**\n * Apply styling to the CardPreview slots based on the state.\n */\nexport const useCardPreviewStyles_unstable = (state: CardPreviewState): CardPreviewState => {\n 'use no memo';\n\n const styles = useStyles();\n // eslint-disable-next-line react-hooks/immutability\n state.root.className = mergeClasses(cardPreviewClassNames.root, styles.root, state.root.className);\n\n if (state.logo) {\n // eslint-disable-next-line react-hooks/immutability\n state.logo.className = mergeClasses(cardPreviewClassNames.logo, styles.logo, state.logo.className);\n }\n\n return state;\n};\n"],"names":["makeStyles","mergeClasses","cardPreviewClassNames","root","logo","useStyles","position","display","height","width","bottom","left","useCardPreviewStyles_unstable","state","styles","className"],"mappings":"AAAA;AAGA,SAASA,UAAU,EAAEC,YAAY,QAAQ,iBAAiB;AAG1D;;CAEC,GACD,OAAO,MAAMC,wBAA0D;IACrEC,MAAM;IACNC,MAAM;AACR,EAAE;AAEF,MAAMC,YAAYL,WAAW;IAC3BG,MAAM;QACJG,UAAU;QAEV,CAAC,CAAC,QAAQ,EAAEJ,sBAAsBE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;YAC1CG,SAAS;YACTC,QAAQ;YACRC,OAAO;QACT;IACF;IAEAL,MAAM;QACJE,UAAU;QACVI,QAAQ;QACRC,MAAM;QACNF,OAAO;QACPD,QAAQ;IACV;AACF;AAEA;;CAEC,GACD,OAAO,MAAMI,gCAAgC,CAACC;IAC5C;IAEA,MAAMC,SAAST;IACf,oDAAoD;IACpDQ,MAAMV,IAAI,CAACY,SAAS,GAAGd,aAAaC,sBAAsBC,IAAI,EAAEW,OAAOX,IAAI,EAAEU,MAAMV,IAAI,CAACY,SAAS;IAEjG,IAAIF,MAAMT,IAAI,EAAE;QACd,oDAAoD;QACpDS,MAAMT,IAAI,CAACW,SAAS,GAAGd,aAAaC,sBAAsBE,IAAI,EAAEU,OAAOV,IAAI,EAAES,MAAMT,IAAI,CAACW,SAAS;IACnG;IAEA,OAAOF;AACT,EAAE"}
@@ -2,5 +2,3 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
6
- const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Card/Card.types.ts"],"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 // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onSelectionChange?: (event: CardOnSelectionChangeEvent, data: CardOnSelectData) => void;\n\n /**\n * Makes the card and card selection disabled (not propagated to children).\n *\n * @default false\n */\n disabled?: boolean;\n};\n\nexport type CardBaseProps = Omit<CardProps, 'appearance' | 'orientation' | 'size'>;\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 * Defines whether the card is disabled.\n *\n * @default false\n */\n disabled: boolean;\n }\n >;\n\nexport type CardBaseState = Omit<CardState, 'appearance' | 'orientation' | 'size'>;\n"],"names":["React"],"mappings":";;;;;iEAAuB,QAAQ"}
1
+ {"version":3,"sources":["../src/components/Card/Card.types.ts"],"sourcesContent":["import type * 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 // eslint-disable-next-line @nx/workspace-consistent-callback-type -- can't change type of existing callback\n onSelectionChange?: (event: CardOnSelectionChangeEvent, data: CardOnSelectData) => void;\n\n /**\n * Makes the card and card selection disabled (not propagated to children).\n *\n * @default false\n */\n disabled?: boolean;\n};\n\nexport type CardBaseProps = Omit<CardProps, 'appearance' | 'orientation' | 'size'> & {\n /**\n * Predicate function to determine whether the card's selection action should be restricted.\n */\n shouldRestrictTriggerAction?: (event: CardOnSelectionChangeEvent) => boolean;\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 * Defines whether the card is disabled.\n *\n * @default false\n */\n disabled: boolean;\n }\n >;\n\nexport type CardBaseState = Omit<CardState, 'appearance' | 'orientation' | 'size'>;\n"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Card/CardContext.ts"],"sourcesContent":["'use client';\n\nimport * 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 = (): CardContextValue => React.useContext(cardContext) ?? cardContextDefaultValue;\n"],"names":["React","cardContext","createContext","undefined","cardContextDefaultValue","selectableA11yProps","referenceId","setReferenceId","referenceLabel","setReferenceLabel","CardProvider","Provider","useCardContext_unstable","useContext"],"mappings":"AAAA;;;;;;;;;;;;gBA0BaU;;;2BAhBAN;;;2BAqBAQ;;;;;iEA7BU,QAAQ;AAG/B,MAAMX,4BAAcD,OAAME,aAAa,CAA+BC;AAK/D,MAAMC,0BAA4C;IACvDC,qBAAqB;QACnBC,aAAaH;QACbI;QACE,QAAQ,GACV;QACAC,gBAAgBL;QAChBM;QACE,QAAQ,GACV;IACF;AACF,EAAE;AAKK,MAAMC,eAAeT,YAAYU,QAAQ,CAAC;AAK1C,MAAMC,0BAA0B;QAAwBZ;WAAAA,CAAAA,oBAAAA,OAAMa,UAAU,CAACZ,YAAAA,MAAAA,QAAjBD,sBAAAA,KAAAA,IAAAA,oBAAiCI;EAAwB"}
1
+ {"version":3,"sources":["../src/components/Card/CardContext.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { 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 = (): CardContextValue => React.useContext(cardContext) ?? cardContextDefaultValue;\n"],"names":["React","cardContext","createContext","undefined","cardContextDefaultValue","selectableA11yProps","referenceId","setReferenceId","referenceLabel","setReferenceLabel","CardProvider","Provider","useCardContext_unstable","useContext"],"mappings":"AAAA;;;;;;;;;;;;gBA0BaU;;;2BAhBAN;;;2BAqBAQ;;;;;iEA7BU,QAAQ;AAG/B,MAAMX,4BAAcD,OAAME,aAAa,CAA+BC;AAK/D,MAAMC,0BAA4C;IACvDC,qBAAqB;QACnBC,aAAaH;QACbI;QACE,QAAQ,GACV;QACAC,gBAAgBL;QAChBM;QACE,QAAQ,GACV;IACF;AACF,EAAE;AAKK,MAAMC,eAAeT,YAAYU,QAAQ,CAAC;AAK1C,MAAMC,0BAA0B;QAAwBZ;WAAAA,CAAAA,oBAAAA,OAAMa,UAAU,CAACZ,YAAAA,MAAAA,QAAjBD,sBAAAA,KAAAA,IAAAA,oBAAiCI;EAAwB"}
@@ -29,54 +29,66 @@ const focusMap = {
29
29
  'tab-exit': 'limited',
30
30
  'tab-only': 'unlimited'
31
31
  };
32
+ const interactiveEventProps = [
33
+ 'onClick',
34
+ 'onDoubleClick',
35
+ 'onMouseUp',
36
+ 'onMouseDown',
37
+ 'onPointerUp',
38
+ 'onPointerDown',
39
+ 'onTouchStart',
40
+ 'onTouchEnd',
41
+ 'onDragStart',
42
+ 'onDragEnd'
43
+ ];
32
44
  /**
33
- * Create the state for interactive cards.
34
- *
35
- * This internal hook defines if the card is interactive
36
- * and control focus properties based on that.
37
- *
38
- * @param props - props from this instance of Card
39
- */ const useCardInteractive = ({ focusMode: initialFocusMode, disabled = false, ...props })=>{
40
- const interactive = [
41
- 'onClick',
42
- 'onDoubleClick',
43
- 'onMouseUp',
44
- 'onMouseDown',
45
- 'onPointerUp',
46
- 'onPointerDown',
47
- 'onTouchStart',
48
- 'onTouchEnd',
49
- 'onDragStart',
50
- 'onDragEnd'
51
- ].some((prop)=>props[prop]);
52
- // default focusMode to tab-only when interactive, and off when not
53
- const focusMode = initialFocusMode !== null && initialFocusMode !== void 0 ? initialFocusMode : interactive ? 'no-tab' : 'off';
54
- const groupperAttrs = (0, _reacttabster.useFocusableGroup)({
55
- tabBehavior: focusMap[focusMode]
56
- });
57
- if (disabled) {
58
- return {
59
- interactive: false,
60
- focusAttributes: null
61
- };
45
+ * Compute whether a Card is interactive based on the presence of pointer/mouse
46
+ * event props and the disabled flag. This intentionally does not depend on
47
+ * focus management utilities so it can be used from headless contexts.
48
+ */ const computeInteractive = (props)=>{
49
+ if (props.disabled) {
50
+ return false;
62
51
  }
63
- if (focusMode === 'off') {
64
- return {
65
- interactive,
66
- focusAttributes: null
67
- };
68
- }
69
- return {
70
- interactive,
71
- focusAttributes: {
72
- ...groupperAttrs,
73
- tabIndex: 0
74
- }
75
- };
52
+ return interactiveEventProps.some((prop)=>props[prop] !== undefined);
76
53
  };
77
54
  const useCard_unstable = (props, ref)=>{
78
55
  const { appearance = 'filled', orientation = 'vertical', size = 'medium', ...cardProps } = props;
79
- const state = useCardBase_unstable(cardProps, ref);
56
+ const { disabled = false, focusMode: focusModeProp } = props;
57
+ // Focus-within ref drives the styled focus outline; merged with the user ref
58
+ // before being passed down so the base hook does not depend on react-tabster.
59
+ const focusWithinRef = (0, _reacttabster.useFocusWithin)();
60
+ const cardRef = (0, _reactutilities.useMergedRefs)(focusWithinRef, ref);
61
+ // Focus-aware predicate that prevents toggling the selection when the user
62
+ // interacts with an inner focusable element.
63
+ const { findAllFocusable } = (0, _reacttabster.useFocusFinders)();
64
+ const shouldRestrictTriggerAction = _react.useCallback((event)=>{
65
+ if (!focusWithinRef.current) {
66
+ return false;
67
+ }
68
+ const focusableElements = findAllFocusable(focusWithinRef.current);
69
+ const target = event.target;
70
+ return focusableElements.some((element)=>element.contains(target));
71
+ }, [
72
+ findAllFocusable,
73
+ focusWithinRef
74
+ ]);
75
+ const interactive = computeInteractive(props);
76
+ const focusMode = focusModeProp !== null && focusModeProp !== void 0 ? focusModeProp : interactive ? 'no-tab' : 'off';
77
+ const groupperAttrs = (0, _reacttabster.useFocusableGroup)({
78
+ tabBehavior: focusMap[focusMode]
79
+ });
80
+ const state = useCardBase_unstable({
81
+ shouldRestrictTriggerAction,
82
+ ...cardProps
83
+ }, cardRef);
84
+ // Apply focusable-group attributes only when the card is not selectable, not
85
+ // disabled and the focus mode is enabled.
86
+ const shouldApplyFocusAttributes = !disabled && !state.selectable && focusMode !== 'off';
87
+ if (shouldApplyFocusAttributes) {
88
+ Object.assign(state.root, groupperAttrs, {
89
+ tabIndex: 0
90
+ });
91
+ }
80
92
  return {
81
93
  ...state,
82
94
  appearance,
@@ -88,15 +100,12 @@ const useCardBase_unstable = (props, ref)=>{
88
100
  const { disabled = false, ...restProps } = props;
89
101
  const [referenceId, setReferenceId] = _react.useState(_CardContext.cardContextDefaultValue.selectableA11yProps.referenceId);
90
102
  const [referenceLabel, setReferenceLabel] = _react.useState(_CardContext.cardContextDefaultValue.selectableA11yProps.referenceId);
91
- const cardBaseRef = (0, _reacttabster.useFocusWithin)();
92
103
  const { selectable, selected, selectableCardProps, selectFocused, checkboxSlot, floatingActionSlot } = (0, _useCardSelectable.useCardSelectable)(props, {
93
104
  referenceId,
94
105
  referenceLabel
95
- }, cardBaseRef);
96
- const cardRef = (0, _reactutilities.useMergedRefs)(cardBaseRef, ref);
97
- const { interactive, focusAttributes } = useCardInteractive(props);
106
+ });
107
+ const interactive = computeInteractive(props);
98
108
  let cardRootProps = {
99
- ...!selectable ? focusAttributes : null,
100
109
  ...restProps,
101
110
  ...selectableCardProps
102
111
  };
@@ -125,7 +134,7 @@ const useCardBase_unstable = (props, ref)=>{
125
134
  checkbox: 'input'
126
135
  },
127
136
  root: _reactutilities.slot.always((0, _reactutilities.getIntrinsicElementProps)('div', {
128
- ref: cardRef,
137
+ ref,
129
138
  role: 'group',
130
139
  ...cardRootProps
131
140
  }), {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Card/useCard.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { getIntrinsicElementProps, useMergedRefs, slot } from '@fluentui/react-utilities';\nimport { useFocusableGroup, useFocusWithin } from '@fluentui/react-tabster';\n\nimport type { CardBaseProps, CardBaseState, 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: initialFocusMode, disabled = false, ...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 // default focusMode to tab-only when interactive, and off when not\n const focusMode = initialFocusMode ?? (interactive ? 'no-tab' : 'off');\n\n const groupperAttrs = useFocusableGroup({\n tabBehavior: focusMap[focusMode],\n });\n\n if (disabled) {\n return {\n interactive: false,\n focusAttributes: null,\n };\n }\n\n if (focusMode === 'off') {\n return {\n interactive,\n focusAttributes: null,\n };\n }\n\n return {\n interactive,\n focusAttributes: {\n ...groupperAttrs,\n tabIndex: 0,\n },\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', ...cardProps } = props;\n const state = useCardBase_unstable(cardProps, ref);\n\n return {\n ...state,\n appearance,\n orientation,\n size,\n };\n};\n\n/**\n * Base hook for Card component, which manages state related to interactivity, selection,\n * focus management, ARIA attributes, and slot structure without design props.\n *\n * @param props - props from this instance of Card\n * @param ref - reference to the root element of Card\n */\nexport const useCardBase_unstable = (props: CardBaseProps, ref: React.Ref<HTMLDivElement>): CardBaseState => {\n const { disabled = false, ...restProps } = 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 let cardRootProps = {\n ...(!selectable ? focusAttributes : null),\n ...restProps,\n ...selectableCardProps,\n };\n\n if (disabled) {\n cardRootProps = {\n ...restProps,\n 'aria-disabled': true,\n onClick: undefined,\n };\n }\n\n return {\n interactive,\n selectable,\n selectFocused,\n selected,\n disabled,\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: slot.always(\n getIntrinsicElementProps('div', {\n ref: cardRef,\n role: 'group',\n ...cardRootProps,\n }),\n { elementType: 'div' },\n ),\n\n floatingAction: floatingActionSlot,\n checkbox: checkboxSlot,\n };\n};\n"],"names":["React","getIntrinsicElementProps","useMergedRefs","slot","useFocusableGroup","useFocusWithin","useCardSelectable","cardContextDefaultValue","focusMap","off","undefined","useCardInteractive","focusMode","initialFocusMode","disabled","props","interactive","some","prop","groupperAttrs","tabBehavior","focusAttributes","tabIndex","useCard_unstable","ref","appearance","orientation","size","cardProps","state","useCardBase_unstable","restProps","referenceId","setReferenceId","useState","selectableA11yProps","referenceLabel","setReferenceLabel","cardBaseRef","selectable","selected","selectableCardProps","selectFocused","checkboxSlot","floatingActionSlot","cardRef","cardRootProps","onClick","components","root","floatingAction","checkbox","always","role","elementType"],"mappings":"AAAA;;;;;;;;;;;;wBAmGa8B;;;oBAnBAP;eAAAA;;;;iEA9EU,QAAQ;gCAC+B,4BAA4B;8BACxC,0BAA0B;mCAG1C,sBAAsB;6BAChB,gBAAgB;AAExD,MAAMf,WAAW;IACfC,KAAKC;IACL,UAAU;IACV,YAAY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EkC,UAAU,EAAEC,QAAQ,EAAEC,mBAAmB,EAAEC,aAAa,EAAEC,YAAY,EAAEC,kBAAkB,EAAE,OAClGtC,oCAAAA,EAAkBS,OAAO;QAAEiB;QAAaI;IAAe,GAAGE;IAE5D,MAAMO,cAAU3C,6BAAAA,EAAcoC,aAAad;IAE3C,MAAM,EAAER,WAAW,EAAEK,eAAe,EAAE,GAAGV,mBAAmBI;IAE5D,IAAI+B,gBAAgB;QAClB,GAAI,CAACP,aAAalB,kBAAkB,IAAI;QACxC,GAAGU,SAAS;QACZ,GAAGU,mBAAmB;IACxB;IAEA,IAAI3B,UAAU;QACZgC,gBAAgB;YACd,GAAGf,SAAS;YACZ,iBAAiB;YACjBgB,SAASrC;QACX;IACF;IAEA,OAAO;QACLM;QACAuB;QACAG;QACAF;QACA1B;QACAqB,qBAAqB;YACnBF;YACAD;YACAI;YACAC;QACF;QAEAW,YAAY;YACVC,MAAM;YACNC,gBAAgB;YAChBC,UAAU;QACZ;QAEAF,MAAM9C,oBAAAA,CAAKiD,MAAM,KACfnD,wCAAAA,EAAyB,OAAO;YAC9BuB,KAAKqB;YACLQ,MAAM;YACN,GAAGP,aAAa;QAClB,IACA;YAAEQ,aAAa;QAAM;QAGvBJ,gBAAgBN;QAChBO,UAAUR;IACZ;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/components/Card/useCard.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { getIntrinsicElementProps, useMergedRefs, slot } from '@fluentui/react-utilities';\nimport { useFocusableGroup, useFocusFinders, useFocusWithin } from '@fluentui/react-tabster';\n\nimport type { CardBaseProps, CardBaseState, CardOnSelectionChangeEvent, 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\nconst interactiveEventProps = [\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\n/**\n * Compute whether a Card is interactive based on the presence of pointer/mouse\n * event props and the disabled flag. This intentionally does not depend on\n * focus management utilities so it can be used from headless contexts.\n */\nconst computeInteractive = (props: CardProps): boolean => {\n if (props.disabled) {\n return false;\n }\n\n return interactiveEventProps.some(prop => props[prop] !== undefined);\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', ...cardProps } = props;\n const { disabled = false, focusMode: focusModeProp } = props;\n\n // Focus-within ref drives the styled focus outline; merged with the user ref\n // before being passed down so the base hook does not depend on react-tabster.\n const focusWithinRef = useFocusWithin<HTMLDivElement>();\n const cardRef = useMergedRefs(focusWithinRef, ref);\n\n // Focus-aware predicate that prevents toggling the selection when the user\n // interacts with an inner focusable element.\n const { findAllFocusable } = useFocusFinders();\n const shouldRestrictTriggerAction = React.useCallback(\n (event: CardOnSelectionChangeEvent) => {\n if (!focusWithinRef.current) {\n return false;\n }\n\n const focusableElements = findAllFocusable(focusWithinRef.current);\n const target = event.target as HTMLElement;\n\n return focusableElements.some(element => element.contains(target));\n },\n [findAllFocusable, focusWithinRef],\n );\n\n const interactive = computeInteractive(props);\n const focusMode = focusModeProp ?? (interactive ? 'no-tab' : 'off');\n const groupperAttrs = useFocusableGroup({\n tabBehavior: focusMap[focusMode],\n });\n\n const state = useCardBase_unstable(\n {\n shouldRestrictTriggerAction,\n ...cardProps,\n },\n cardRef,\n );\n\n // Apply focusable-group attributes only when the card is not selectable, not\n // disabled and the focus mode is enabled.\n const shouldApplyFocusAttributes = !disabled && !state.selectable && focusMode !== 'off';\n if (shouldApplyFocusAttributes) {\n Object.assign(state.root, groupperAttrs, { tabIndex: 0 });\n }\n\n return {\n ...state,\n appearance,\n orientation,\n size,\n };\n};\n\n/**\n * Base hook for Card component, which manages state related to interactivity, selection,\n * ARIA attributes, and slot structure without design props or focus management.\n *\n * This hook is intentionally free of `@fluentui/react-tabster` so that it can be\n * consumed by headless component packages. Focus management (focusable group\n * attributes, focus-within, focus-restriction predicate) is layered on top in\n * `useCard_unstable`.\n *\n * @param props - props from this instance of Card\n * @param ref - reference to the root element of Card\n * @param options - optional behavior overrides such as a focus-aware restriction predicate\n */\nexport const useCardBase_unstable = (props: CardBaseProps, ref: React.Ref<HTMLDivElement>): CardBaseState => {\n const { disabled = false, ...restProps } = props;\n\n const [referenceId, setReferenceId] = React.useState(cardContextDefaultValue.selectableA11yProps.referenceId);\n const [referenceLabel, setReferenceLabel] = React.useState(cardContextDefaultValue.selectableA11yProps.referenceId);\n\n const { selectable, selected, selectableCardProps, selectFocused, checkboxSlot, floatingActionSlot } =\n useCardSelectable(props, { referenceId, referenceLabel });\n\n const interactive = computeInteractive(props);\n\n let cardRootProps = {\n ...restProps,\n ...selectableCardProps,\n };\n\n if (disabled) {\n cardRootProps = {\n ...restProps,\n 'aria-disabled': true,\n onClick: undefined,\n };\n }\n\n return {\n interactive,\n selectable,\n selectFocused,\n selected,\n disabled,\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: slot.always(\n getIntrinsicElementProps('div', {\n ref,\n role: 'group',\n ...cardRootProps,\n }),\n { elementType: 'div' },\n ),\n\n floatingAction: floatingActionSlot,\n checkbox: checkboxSlot,\n };\n};\n"],"names":["React","getIntrinsicElementProps","useMergedRefs","slot","useFocusableGroup","useFocusFinders","useFocusWithin","useCardSelectable","cardContextDefaultValue","focusMap","off","undefined","interactiveEventProps","computeInteractive","props","disabled","some","prop","useCard_unstable","ref","appearance","orientation","size","cardProps","focusMode","focusModeProp","focusWithinRef","cardRef","findAllFocusable","shouldRestrictTriggerAction","useCallback","event","current","focusableElements","target","element","contains","interactive","groupperAttrs","tabBehavior","state","useCardBase_unstable","shouldApplyFocusAttributes","selectable","Object","assign","root","tabIndex","restProps","referenceId","setReferenceId","useState","selectableA11yProps","referenceLabel","setReferenceLabel","selected","selectableCardProps","selectFocused","checkboxSlot","floatingActionSlot","cardRootProps","onClick","components","floatingAction","checkbox","always","role","elementType"],"mappings":"AAAA;;;;;;;;;;;;IAwHayC,oBAAAA;;;oBApEAvB;eAAAA;;;;iEAlDU,QAAQ;gCAC+B,4BAA4B;8BACvB,0BAA0B;mCAG3D,sBAAsB;6BAChB,gBAAgB;AAExD,MAAMT,WAAW;IACfC,KAAKC;IACL,UAAU;IACV,YAAY;IACZ,YAAY;AACd;AAEA,MAAMC,wBAAwB;IAC5B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED;;;;CAIC,GACD,MAAMC,qBAAqB,CAACC;IAC1B,IAAIA,MAAMC,QAAQ,EAAE;QAClB,OAAO;IACT;IAEA,OAAOH,sBAAsBI,IAAI,CAACC,CAAAA,OAAQH,KAAK,CAACG,KAAK,KAAKN;AAC5D;AAWO,yBAAyB,CAACG,OAAkBK;IACjD,MAAM,EAAEC,aAAa,QAAQ,EAAEC,cAAc,UAAU,EAAEC,OAAO,QAAQ,EAAE,GAAGC,WAAW,GAAGT;IAC3F,MAAM,EAAEC,WAAW,KAAK,EAAES,WAAWC,aAAa,EAAE,GAAGX;IAEvD,6EAA6E;IAC7E,8EAA8E;IAC9E,MAAMY,qBAAiBpB,4BAAAA;IACvB,MAAMqB,cAAUzB,6BAAAA,EAAcwB,gBAAgBP;IAE9C,2EAA2E;IAC3E,6CAA6C;IAC7C,MAAM,EAAES,gBAAgB,EAAE,OAAGvB,6BAAAA;IAC7B,M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EAAkBO,OAAO;QAAEmC;QAAaI;IAAe;IAEzD,MAAMhB,cAAcxB,mBAAmBC;IAEvC,IAAI8C,gBAAgB;QAClB,GAAGZ,SAAS;QACZ,GAAGQ,mBAAmB;IACxB;IAEA,IAAIzC,UAAU;QACZ6C,gBAAgB;YACd,GAAGZ,SAAS;YACZ,iBAAiB;YACjBa,SAASlD;QACX;IACF;IAEA,OAAO;QACL0B;QACAM;QACAc;QACAF;QACAxC;QACAqC,qBAAqB;YACnBF;YACAD;YACAI;YACAC;QACF;QAEAQ,YAAY;YACVhB,MAAM;YACNiB,gBAAgB;YAChBC,UAAU;QACZ;QAEAlB,MAAM3C,oBAAAA,CAAK8D,MAAM,KACfhE,wCAAAA,EAAyB,OAAO;YAC9BkB;YACA+C,MAAM;YACN,GAAGN,aAAa;QAClB,IACA;YAAEO,aAAa;QAAM;QAGvBJ,gBAAgBJ;QAChBK,UAAUN;IACZ;AACF,EAAE"}
@@ -13,10 +13,8 @@ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildc
13
13
  const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
14
14
  const _reactutilities = require("@fluentui/react-utilities");
15
15
  const _keyboardkeys = require("@fluentui/keyboard-keys");
16
- const _reacttabster = require("@fluentui/react-tabster");
17
- const useCardSelectable = (props, { referenceLabel, referenceId }, cardRef)=>{
18
- const { checkbox = {}, onSelectionChange, floatingAction, onClick, onKeyDown, disabled } = props;
19
- const { findAllFocusable } = (0, _reacttabster.useFocusFinders)();
16
+ const useCardSelectable = (props, { referenceLabel, referenceId })=>{
17
+ const { checkbox = {}, onSelectionChange, floatingAction, onClick, onKeyDown, disabled, shouldRestrictTriggerAction } = props;
20
18
  const checkboxRef = _react.useRef(null);
21
19
  const [selected, setSelected] = (0, _reactutilities.useControllableState)({
22
20
  state: props.selected,
@@ -29,21 +27,12 @@ const useCardSelectable = (props, { referenceLabel, referenceId }, cardRef)=>{
29
27
  onSelectionChange
30
28
  ].some((prop)=>typeof prop !== 'undefined');
31
29
  const [selectFocused, setSelectFocused] = _react.useState(false);
32
- const shouldRestrictTriggerAction = _react.useCallback((event)=>{
33
- if (!cardRef.current) {
34
- return false;
35
- }
36
- const focusableElements = findAllFocusable(cardRef.current);
37
- const target = event.target;
38
- const isElementInFocusableGroup = focusableElements.some((element)=>element.contains(target));
39
- const isCheckboxSlot = (checkboxRef === null || checkboxRef === void 0 ? void 0 : checkboxRef.current) === target;
40
- return isElementInFocusableGroup && !isCheckboxSlot;
41
- }, [
42
- cardRef,
43
- findAllFocusable
44
- ]);
45
30
  const onChangeHandler = _react.useCallback((event)=>{
46
- if (disabled || shouldRestrictTriggerAction(event)) {
31
+ if (disabled) {
32
+ return;
33
+ }
34
+ const isCheckboxOrFloatingActionTarget = checkboxRef.current === event.target;
35
+ if (!isCheckboxOrFloatingActionTarget && (shouldRestrictTriggerAction === null || shouldRestrictTriggerAction === void 0 ? void 0 : shouldRestrictTriggerAction(event))) {
47
36
  return;
48
37
  }
49
38
  const newCheckedValue = !selected;
@@ -80,6 +69,7 @@ const useCardSelectable = (props, { referenceLabel, referenceId }, cardRef)=>{
80
69
  } else if (referenceLabel) {
81
70
  selectableCheckboxProps['aria-label'] = referenceLabel;
82
71
  }
72
+ // eslint-disable-next-line react-hooks/refs
83
73
  return _reactutilities.slot.optional(checkbox, {
84
74
  defaultProps: {
85
75
  ref: checkboxRef,
@@ -107,6 +97,7 @@ const useCardSelectable = (props, { referenceLabel, referenceId }, cardRef)=>{
107
97
  if (!floatingAction) {
108
98
  return;
109
99
  }
100
+ // eslint-disable-next-line react-hooks/refs
110
101
  return _reactutilities.slot.optional(floatingAction, {
111
102
  defaultProps: {
112
103
  ref: checkboxRef
@@ -121,7 +112,9 @@ const useCardSelectable = (props, { referenceLabel, referenceId }, cardRef)=>{
121
112
  return null;
122
113
  }
123
114
  return {
115
+ // eslint-disable-next-line react-hooks/refs
124
116
  onClick: (0, _reactutilities.mergeCallbacks)(onClick, onChangeHandler),
117
+ // eslint-disable-next-line react-hooks/refs
125
118
  onKeyDown: (0, _reactutilities.mergeCallbacks)(onKeyDown, onKeyDownHandler)
126
119
  };
127
120
  }, [
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/Card/useCardSelectable.ts"],"sourcesContent":["'use client';\n\nimport * 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, CardState } from './Card.types';\n\ntype SelectableA11yProps = Pick<CardContextValue['selectableA11yProps'], 'referenceId' | 'referenceLabel'>;\n\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 * @internal\n * @param props - props from this instance of Card\n * @param a11yProps - accessibility props shared between elements of the card\n * @param cardRef - reference to the root element of Card\n */\nexport const useCardSelectable = (\n props: CardProps,\n { referenceLabel, referenceId }: SelectableA11yProps,\n cardRef: React.RefObject<HTMLDivElement | null>,\n): {\n selected: boolean;\n selectable: boolean;\n selectFocused: boolean;\n selectableCardProps: {\n onClick: React.MouseEventHandler<HTMLDivElement>;\n onKeyDown: React.KeyboardEventHandler<HTMLDivElement>;\n } | null;\n checkboxSlot: CardState['checkbox'];\n floatingActionSlot: CardState['floatingAction'];\n} => {\n const { checkbox = {}, onSelectionChange, floatingAction, onClick, onKeyDown, disabled } = 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 (disabled || 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 [disabled, 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 disabled,\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, disabled, 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","disabled","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;;;;;+BAsBaM;;;;;;;iEApBU,QAAQ;gCAC4B,4BAA4B;8BACjE,0BAA0B;8BAChB,0BAA0B;AAiBnD,0BAA0B,CAC/BC,OACA,EAAEC,cAAc,EAAEC,WAAW,EAAuB,EACpDC;IAYA,MAAM,EAAEC,WAAW,CAAC,CAAC,EAAEC,iBAAiB,EAAEC,cAAc,EAAEC,OAAO,EAAEC,SAAS,EAAEC,QAAQ,EAAE,GAAGT;IAE3F,MAAM,EAAEU,gBAAgB,EAAE,OAAGZ,6BAAAA;IAC7B,MAAMa,cAAclB,OAAMmB,MAAM,CAAmB;IAEnD,MAAM,CAACC,UAAUC,YAAY,OAAGlB,oCAAAA,EAAqB;QACnDmB,OAAOf,MAAMa,QAAQ;QACrBG,cAAchB,MAAMiB,eAAe;QACnCC,cAAc;IAChB;IACA,MAAMC,aAAa;QAACnB,MAAMa,QAAQ;QAAEb,MAAMiB,eAAe;QAAEZ;KAAkB,CAACe,IAAI,CAChFC,CAAAA,OAAQ,OAAOA,SAAS;IAG1B,MAAM,CAACC,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AA,CAAKiD,QAAQ,CAACxC,UAAU;YAC7ByC,cAAc;gBACZC,KAAKnC;gBACLoC,MAAM;gBACNC,SAASnC;gBACTJ;gBACAwC,UAAU,CAACtB,QAA+CQ,gBAAgBR;gBAC1EuB,SAAS,IAAM3B,iBAAiB;gBAChC4B,QAAQ,IAAM5B,iBAAiB;gBAC/B,GAAGoB,uBAAuB;YAC5B;YACAS,aAAa;QACf;IACF,GAAG;QAAChD;QAAUK;QAAUH;QAAgBO;QAAUM;QAAYgB;QAAiBjC;QAAaD;KAAe;IAE3G,MAAMoD,qBAAqB5D,OAAMiD,OAAO,CAAC;QACvC,IAAI,CAACpC,gBAAgB;YACnB;QACF;QAEA,OAAOX,oBAAAA,CAAKiD,QAAQ,CAACtC,gBAAgB;YACnCuC,cAAc;gBACZC,KAAKnC;YACP;YACAyC,aAAa;QACf;IACF,GAAG;QAAC9C;KAAe;IAEnB,MAAMgD,sBAAsB7D,OAAMiD,OAAO,CAAC;QACxC,IAAI,CAACvB,YAAY;YACf,OAAO;QACT;QAEA,OAAO;YACLZ,aAASb,8BAAAA,EAAea,SAAS4B;YACjC3B,eAAWd,8BAAAA,EAAec,WAAW6B;QACvC;IACF,GAAG;QAAClB;QAAYgB;QAAiB5B;QAASC;QAAW6B;KAAiB;IAEtE,OAAO;QACLxB;QACAM;QACAG;QACAgC;QACAb;QACAY;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/components/Card/useCardSelectable.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { mergeCallbacks, slot, useControllableState } from '@fluentui/react-utilities';\nimport { Enter } from '@fluentui/keyboard-keys';\n\nimport type { CardBaseProps, CardContextValue, CardOnSelectionChangeEvent, CardSlots, CardState } from './Card.types';\n\ntype SelectableA11yProps = Pick<CardContextValue['selectableA11yProps'], 'referenceId' | 'referenceLabel'>;\n\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 useCardBase_unstable / useCard_unstable.\n *\n * @internal\n * @param props - props from this instance of Card\n * @param a11yProps - accessibility props shared between elements of the card\n * @param options - optional behavior overrides such as a focus-aware restriction predicate\n */\nexport const useCardSelectable = (\n props: CardBaseProps,\n { referenceLabel, referenceId }: SelectableA11yProps,\n): {\n selected: boolean;\n selectable: boolean;\n selectFocused: boolean;\n selectableCardProps: {\n onClick: React.MouseEventHandler<HTMLDivElement>;\n onKeyDown: React.KeyboardEventHandler<HTMLDivElement>;\n } | null;\n checkboxSlot: CardState['checkbox'];\n floatingActionSlot: CardState['floatingAction'];\n} => {\n const {\n checkbox = {},\n onSelectionChange,\n floatingAction,\n onClick,\n onKeyDown,\n disabled,\n shouldRestrictTriggerAction,\n } = props;\n\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 onChangeHandler = React.useCallback(\n (event: CardOnSelectionChangeEvent) => {\n if (disabled) {\n return;\n }\n\n const isCheckboxOrFloatingActionTarget = checkboxRef.current === (event.target as HTMLElement);\n\n if (!isCheckboxOrFloatingActionTarget && 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 [disabled, 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 // eslint-disable-next-line react-hooks/refs\n return slot.optional(checkbox, {\n defaultProps: {\n ref: checkboxRef,\n type: 'checkbox',\n checked: selected,\n disabled,\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, disabled, floatingAction, selected, selectable, onChangeHandler, referenceId, referenceLabel]);\n\n const floatingActionSlot = React.useMemo(() => {\n if (!floatingAction) {\n return;\n }\n\n // eslint-disable-next-line react-hooks/refs\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 // eslint-disable-next-line react-hooks/refs\n onClick: mergeCallbacks(onClick, onChangeHandler),\n // eslint-disable-next-line react-hooks/refs\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","useCardSelectable","props","referenceLabel","referenceId","checkbox","onSelectionChange","floatingAction","onClick","onKeyDown","disabled","shouldRestrictTriggerAction","checkboxRef","useRef","selected","setSelected","state","defaultState","defaultSelected","initialState","selectable","some","prop","selectFocused","setSelectFocused","useState","onChangeHandler","useCallback","event","isCheckboxOrFloatingActionTarget","current","target","newCheckedValue","onKeyDownHandler","includes","key","preventDefault","checkboxSlot","useMemo","selectableCheckboxProps","optional","defaultProps","ref","type","checked","onChange","onFocus","onBlur","elementType","floatingActionSlot","selectableCardProps"],"mappings":"AAAA;;;;;+BAqBaK;;;;;;;iEAnBU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(state)=>{
932
932
  styles.focused,
933
933
  styles.selectableFocused
934
934
  ]);
935
+ // eslint-disable-next-line react-hooks/immutability
935
936
  state.root.className = (0, _react1.mergeClasses)(cardClassNames.root, resetStyles, orientationMap[state.orientation], sizeMap[state.size], appearanceMap[state.appearance], isSelectableOrInteractive && styles.interactive, isSelectableOrInteractive && interactiveMap[state.appearance], state.selected && selectedMap[state.appearance], focusedClassName, isSelectableOrInteractive && styles.highContrastInteractive, state.selected && styles.highContrastSelected, state.disabled && styles.disabled, state.disabled && state.appearance === 'outline' && styles.outlineDisabled, state.root.className);
936
937
  if (state.floatingAction) {
938
+ // eslint-disable-next-line react-hooks/immutability
937
939
  state.floatingAction.className = (0, _react1.mergeClasses)(cardClassNames.floatingAction, styles.select, state.floatingAction.className);
938
940
  }
939
941
  if (state.checkbox) {
942
+ // eslint-disable-next-line react-hooks/immutability
940
943
  state.checkbox.className = (0, _react1.mergeClasses)(cardClassNames.checkbox, styles.hiddenCheckbox, state.checkbox.className);
941
944
  }
942
945
  return state;