@fluentui/react-infolabel 9.0.23 → 9.0.24

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.md CHANGED
@@ -1,12 +1,27 @@
1
1
  # Change Log - @fluentui/react-infolabel
2
2
 
3
- This log was last generated on Wed, 28 Feb 2024 02:28:41 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 07 Mar 2024 19:26:56 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.0.24](https://github.com/microsoft/fluentui/tree/@fluentui/react-infolabel_v9.0.24)
8
+
9
+ Thu, 07 Mar 2024 19:26:56 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-infolabel_v9.0.23..@fluentui/react-infolabel_v9.0.24)
11
+
12
+ ### Patches
13
+
14
+ - fix: InfoLabel popover dismisses if the InfoButton is clicked when it is already open ([PR #30731](https://github.com/microsoft/fluentui/pull/30731) by behowell@microsoft.com)
15
+ - Bump @fluentui/react-label to v9.1.64 ([PR #30687](https://github.com/microsoft/fluentui/pull/30687) by beachball)
16
+ - Bump @fluentui/react-popover to v9.9.0 ([PR #30687](https://github.com/microsoft/fluentui/pull/30687) by beachball)
17
+ - Bump @fluentui/react-tabster to v9.19.3 ([PR #30687](https://github.com/microsoft/fluentui/pull/30687) by beachball)
18
+ - Bump @fluentui/react-jsx-runtime to v9.0.32 ([PR #30687](https://github.com/microsoft/fluentui/pull/30687) by beachball)
19
+ - Bump @fluentui/react-theme to v9.1.17 ([PR #30687](https://github.com/microsoft/fluentui/pull/30687) by beachball)
20
+ - Bump @fluentui/react-utilities to v9.18.3 ([PR #30687](https://github.com/microsoft/fluentui/pull/30687) by beachball)
21
+
7
22
  ## [9.0.23](https://github.com/microsoft/fluentui/tree/@fluentui/react-infolabel_v9.0.23)
8
23
 
9
- Wed, 28 Feb 2024 02:28:41 GMT
24
+ Wed, 28 Feb 2024 02:34:19 GMT
10
25
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-infolabel_v9.0.22..@fluentui/react-infolabel_v9.0.23)
11
26
 
12
27
  ### Patches
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { DefaultInfoButtonIcon12, DefaultInfoButtonIcon16, DefaultInfoButtonIcon20 } from './DefaultInfoButtonIcons';
3
- import { getIntrinsicElementProps, mergeCallbacks, useControllableState, slot, useMergedRefs, isHTMLElement, elementContains } from '@fluentui/react-utilities';
3
+ import { getIntrinsicElementProps, mergeCallbacks, useControllableState, slot, useMergedRefs, elementContains, useEventCallback } from '@fluentui/react-utilities';
4
4
  import { Popover, PopoverSurface } from '@fluentui/react-popover';
5
5
  const infoButtonIconMap = {
6
6
  small: /*#__PURE__*/ React.createElement(DefaultInfoButtonIcon12, null),
@@ -22,6 +22,7 @@ const popoverSizeMap = {
22
22
  * @param ref - reference to root HTMLButtonElement of InfoButton
23
23
  */ export const useInfoButton_unstable = (props, ref)=>{
24
24
  const { size = 'medium', inline = true } = props;
25
+ const rootRef = useMergedRefs(ref);
25
26
  const state = {
26
27
  inline,
27
28
  size,
@@ -35,7 +36,7 @@ const popoverSizeMap = {
35
36
  type: 'button',
36
37
  'aria-label': 'information',
37
38
  ...props,
38
- ref
39
+ ref: rootRef
39
40
  }), {
40
41
  elementType: 'button'
41
42
  }),
@@ -63,19 +64,16 @@ const popoverSizeMap = {
63
64
  });
64
65
  state.popover.open = popoverOpen;
65
66
  state.popover.onOpenChange = mergeCallbacks(state.popover.onOpenChange, (e, data)=>setPopoverOpen(data.open));
66
- const focusOutRef = React.useCallback((el)=>{
67
- if (!el) {
68
- return;
67
+ const infoRef = useMergedRefs(state.info.ref);
68
+ state.info.ref = infoRef;
69
+ // Hide the popover when focus moves out of the button and popover
70
+ const onBlurButtonOrInfo = (e)=>{
71
+ const nextFocused = e.relatedTarget;
72
+ if (rootRef.current !== nextFocused && !elementContains(infoRef.current, nextFocused)) {
73
+ setPopoverOpen(false);
69
74
  }
70
- el.addEventListener('focusout', (e)=>{
71
- const nextFocused = e.relatedTarget;
72
- if (isHTMLElement(nextFocused) && !elementContains(el, nextFocused)) {
73
- setPopoverOpen(false);
74
- }
75
- });
76
- }, [
77
- setPopoverOpen
78
- ]);
79
- state.info.ref = useMergedRefs(state.info.ref, focusOutRef);
75
+ };
76
+ state.root.onBlur = useEventCallback(mergeCallbacks(state.root.onBlur, onBlurButtonOrInfo));
77
+ state.info.onBlurCapture = useEventCallback(mergeCallbacks(state.info.onBlurCapture, onBlurButtonOrInfo));
80
78
  return state;
81
79
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["useInfoButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { DefaultInfoButtonIcon12, DefaultInfoButtonIcon16, DefaultInfoButtonIcon20 } from './DefaultInfoButtonIcons';\nimport {\n getIntrinsicElementProps,\n mergeCallbacks,\n useControllableState,\n slot,\n useMergedRefs,\n isHTMLElement,\n elementContains,\n} from '@fluentui/react-utilities';\nimport { Popover, PopoverSurface } from '@fluentui/react-popover';\nimport type { InfoButtonProps, InfoButtonState } from './InfoButton.types';\nimport type { PopoverProps } from '@fluentui/react-popover';\n\nconst infoButtonIconMap = {\n small: <DefaultInfoButtonIcon12 />,\n medium: <DefaultInfoButtonIcon16 />,\n large: <DefaultInfoButtonIcon20 />,\n} as const;\n\nconst popoverSizeMap = {\n small: 'small',\n medium: 'small',\n large: 'medium',\n} as const;\n\n/**\n * Create the state required to render InfoButton.\n *\n * The returned state can be modified with hooks such as useInfoButtonStyles_unstable,\n * before being passed to renderInfoButton_unstable.\n *\n * @param props - props from this instance of InfoButton\n * @param ref - reference to root HTMLButtonElement of InfoButton\n */\nexport const useInfoButton_unstable = (props: InfoButtonProps, ref: React.Ref<HTMLButtonElement>): InfoButtonState => {\n const { size = 'medium', inline = true } = props;\n\n const state: InfoButtonState = {\n inline,\n size,\n\n components: {\n root: 'button',\n popover: Popover as React.FC<Partial<PopoverProps>>,\n info: PopoverSurface,\n },\n\n root: slot.always(\n getIntrinsicElementProps('button', {\n children: infoButtonIconMap[size],\n type: 'button',\n 'aria-label': 'information',\n ...props,\n ref,\n }),\n { elementType: 'button' },\n ),\n popover: slot.always(props.popover, {\n defaultProps: {\n inline,\n positioning: 'above-start',\n size: popoverSizeMap[size],\n withArrow: true,\n },\n elementType: Popover as React.FC<Partial<Omit<PopoverProps, 'openOnHover'>>>,\n }),\n info: slot.always(props.info, {\n defaultProps: {\n role: 'note',\n tabIndex: -1,\n },\n elementType: PopoverSurface,\n }),\n };\n\n const [popoverOpen, setPopoverOpen] = useControllableState({\n state: state.popover.open,\n defaultState: state.popover.defaultOpen,\n initialState: false,\n });\n\n state.popover.open = popoverOpen;\n state.popover.onOpenChange = mergeCallbacks(state.popover.onOpenChange, (e, data) => setPopoverOpen(data.open));\n\n const focusOutRef = React.useCallback(\n (el: HTMLDivElement) => {\n if (!el) {\n return;\n }\n\n el.addEventListener('focusout', e => {\n const nextFocused = e.relatedTarget;\n\n if (isHTMLElement(nextFocused) && !elementContains(el, nextFocused)) {\n setPopoverOpen(false);\n }\n });\n },\n [setPopoverOpen],\n );\n\n state.info.ref = useMergedRefs(state.info.ref, focusOutRef);\n\n return state;\n};\n"],"names":["React","DefaultInfoButtonIcon12","DefaultInfoButtonIcon16","DefaultInfoButtonIcon20","getIntrinsicElementProps","mergeCallbacks","useControllableState","slot","useMergedRefs","isHTMLElement","elementContains","Popover","PopoverSurface","infoButtonIconMap","small","medium","large","popoverSizeMap","useInfoButton_unstable","props","ref","size","inline","state","components","root","popover","info","always","children","type","elementType","defaultProps","positioning","withArrow","role","tabIndex","popoverOpen","setPopoverOpen","open","defaultState","defaultOpen","initialState","onOpenChange","e","data","focusOutRef","useCallback","el","addEventListener","nextFocused","relatedTarget"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,uBAAuB,EAAEC,uBAAuB,EAAEC,uBAAuB,QAAQ,2BAA2B;AACrH,SACEC,wBAAwB,EACxBC,cAAc,EACdC,oBAAoB,EACpBC,IAAI,EACJC,aAAa,EACbC,aAAa,EACbC,eAAe,QACV,4BAA4B;AACnC,SAASC,OAAO,EAAEC,cAAc,QAAQ,0BAA0B;AAIlE,MAAMC,oBAAoB;IACxBC,qBAAO,oBAACb;IACRc,sBAAQ,oBAACb;IACTc,qBAAO,oBAACb;AACV;AAEA,MAAMc,iBAAiB;IACrBH,OAAO;IACPC,QAAQ;IACRC,OAAO;AACT;AAEA;;;;;;;;CAQC,GACD,OAAO,MAAME,yBAAyB,CAACC,OAAwBC;IAC7D,MAAM,EAAEC,OAAO,QAAQ,EAAEC,SAAS,IAAI,EAAE,GAAGH;IAE3C,MAAMI,QAAyB;QAC7BD;QACAD;QAEAG,YAAY;YACVC,MAAM;YACNC,SAASf;YACTgB,MAAMf;QACR;QAEAa,MAAMlB,KAAKqB,MAAM,CACfxB,yBAAyB,UAAU;YACjCyB,UAAUhB,iBAAiB,CAACQ,KAAK;YACjCS,MAAM;YACN,cAAc;YACd,GAAGX,KAAK;YACRC;QACF,IACA;YAAEW,aAAa;QAAS;QAE1BL,SAASnB,KAAKqB,MAAM,CAACT,MAAMO,OAAO,EAAE;YAClCM,cAAc;gBACZV;gBACAW,aAAa;gBACbZ,MAAMJ,cAAc,CAACI,KAAK;gBAC1Ba,WAAW;YACb;YACAH,aAAapB;QACf;QACAgB,MAAMpB,KAAKqB,MAAM,CAACT,MAAMQ,IAAI,EAAE;YAC5BK,cAAc;gBACZG,MAAM;gBACNC,UAAU,CAAC;YACb;YACAL,aAAanB;QACf;IACF;IAEA,MAAM,CAACyB,aAAaC,eAAe,GAAGhC,qBAAqB;QACzDiB,OAAOA,MAAMG,OAAO,CAACa,IAAI;QACzBC,cAAcjB,MAAMG,OAAO,CAACe,WAAW;QACvCC,cAAc;IAChB;IAEAnB,MAAMG,OAAO,CAACa,IAAI,GAAGF;IACrBd,MAAMG,OAAO,CAACiB,YAAY,GAAGtC,eAAekB,MAAMG,OAAO,CAACiB,YAAY,EAAE,CAACC,GAAGC,OAASP,eAAeO,KAAKN,IAAI;IAE7G,MAAMO,cAAc9C,MAAM+C,WAAW,CACnC,CAACC;QACC,IAAI,CAACA,IAAI;YACP;QACF;QAEAA,GAAGC,gBAAgB,CAAC,YAAYL,CAAAA;YAC9B,MAAMM,cAAcN,EAAEO,aAAa;YAEnC,IAAI1C,cAAcyC,gBAAgB,CAACxC,gBAAgBsC,IAAIE,cAAc;gBACnEZ,eAAe;YACjB;QACF;IACF,GACA;QAACA;KAAe;IAGlBf,MAAMI,IAAI,CAACP,GAAG,GAAGZ,cAAce,MAAMI,IAAI,CAACP,GAAG,EAAE0B;IAE/C,OAAOvB;AACT,EAAE"}
1
+ {"version":3,"sources":["useInfoButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { DefaultInfoButtonIcon12, DefaultInfoButtonIcon16, DefaultInfoButtonIcon20 } from './DefaultInfoButtonIcons';\nimport {\n getIntrinsicElementProps,\n mergeCallbacks,\n useControllableState,\n slot,\n useMergedRefs,\n elementContains,\n useEventCallback,\n} from '@fluentui/react-utilities';\nimport { Popover, PopoverSurface } from '@fluentui/react-popover';\nimport type { InfoButtonProps, InfoButtonState } from './InfoButton.types';\nimport type { PopoverProps } from '@fluentui/react-popover';\n\nconst infoButtonIconMap = {\n small: <DefaultInfoButtonIcon12 />,\n medium: <DefaultInfoButtonIcon16 />,\n large: <DefaultInfoButtonIcon20 />,\n} as const;\n\nconst popoverSizeMap = {\n small: 'small',\n medium: 'small',\n large: 'medium',\n} as const;\n\n/**\n * Create the state required to render InfoButton.\n *\n * The returned state can be modified with hooks such as useInfoButtonStyles_unstable,\n * before being passed to renderInfoButton_unstable.\n *\n * @param props - props from this instance of InfoButton\n * @param ref - reference to root HTMLButtonElement of InfoButton\n */\nexport const useInfoButton_unstable = (props: InfoButtonProps, ref: React.Ref<HTMLButtonElement>): InfoButtonState => {\n const { size = 'medium', inline = true } = props;\n\n const rootRef = useMergedRefs(ref);\n\n const state: InfoButtonState = {\n inline,\n size,\n\n components: {\n root: 'button',\n popover: Popover as React.FC<Partial<PopoverProps>>,\n info: PopoverSurface,\n },\n\n root: slot.always(\n getIntrinsicElementProps('button', {\n children: infoButtonIconMap[size],\n type: 'button',\n 'aria-label': 'information',\n ...props,\n ref: rootRef,\n }),\n { elementType: 'button' },\n ),\n popover: slot.always(props.popover, {\n defaultProps: {\n inline,\n positioning: 'above-start',\n size: popoverSizeMap[size],\n withArrow: true,\n },\n elementType: Popover as React.FC<Partial<Omit<PopoverProps, 'openOnHover'>>>,\n }),\n info: slot.always(props.info, {\n defaultProps: {\n role: 'note',\n tabIndex: -1,\n },\n elementType: PopoverSurface,\n }),\n };\n\n const [popoverOpen, setPopoverOpen] = useControllableState({\n state: state.popover.open,\n defaultState: state.popover.defaultOpen,\n initialState: false,\n });\n\n state.popover.open = popoverOpen;\n state.popover.onOpenChange = mergeCallbacks(state.popover.onOpenChange, (e, data) => setPopoverOpen(data.open));\n\n const infoRef = useMergedRefs(state.info.ref);\n state.info.ref = infoRef;\n\n // Hide the popover when focus moves out of the button and popover\n const onBlurButtonOrInfo = (e: React.FocusEvent) => {\n const nextFocused = e.relatedTarget;\n if (rootRef.current !== nextFocused && !elementContains(infoRef.current, nextFocused)) {\n setPopoverOpen(false);\n }\n };\n\n state.root.onBlur = useEventCallback(mergeCallbacks(state.root.onBlur, onBlurButtonOrInfo));\n state.info.onBlurCapture = useEventCallback(mergeCallbacks(state.info.onBlurCapture, onBlurButtonOrInfo));\n\n return state;\n};\n"],"names":["React","DefaultInfoButtonIcon12","DefaultInfoButtonIcon16","DefaultInfoButtonIcon20","getIntrinsicElementProps","mergeCallbacks","useControllableState","slot","useMergedRefs","elementContains","useEventCallback","Popover","PopoverSurface","infoButtonIconMap","small","medium","large","popoverSizeMap","useInfoButton_unstable","props","ref","size","inline","rootRef","state","components","root","popover","info","always","children","type","elementType","defaultProps","positioning","withArrow","role","tabIndex","popoverOpen","setPopoverOpen","open","defaultState","defaultOpen","initialState","onOpenChange","e","data","infoRef","onBlurButtonOrInfo","nextFocused","relatedTarget","current","onBlur","onBlurCapture"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,uBAAuB,EAAEC,uBAAuB,EAAEC,uBAAuB,QAAQ,2BAA2B;AACrH,SACEC,wBAAwB,EACxBC,cAAc,EACdC,oBAAoB,EACpBC,IAAI,EACJC,aAAa,EACbC,eAAe,EACfC,gBAAgB,QACX,4BAA4B;AACnC,SAASC,OAAO,EAAEC,cAAc,QAAQ,0BAA0B;AAIlE,MAAMC,oBAAoB;IACxBC,qBAAO,oBAACb;IACRc,sBAAQ,oBAACb;IACTc,qBAAO,oBAACb;AACV;AAEA,MAAMc,iBAAiB;IACrBH,OAAO;IACPC,QAAQ;IACRC,OAAO;AACT;AAEA;;;;;;;;CAQC,GACD,OAAO,MAAME,yBAAyB,CAACC,OAAwBC;IAC7D,MAAM,EAAEC,OAAO,QAAQ,EAAEC,SAAS,IAAI,EAAE,GAAGH;IAE3C,MAAMI,UAAUf,cAAcY;IAE9B,MAAMI,QAAyB;QAC7BF;QACAD;QAEAI,YAAY;YACVC,MAAM;YACNC,SAAShB;YACTiB,MAAMhB;QACR;QAEAc,MAAMnB,KAAKsB,MAAM,CACfzB,yBAAyB,UAAU;YACjC0B,UAAUjB,iBAAiB,CAACQ,KAAK;YACjCU,MAAM;YACN,cAAc;YACd,GAAGZ,KAAK;YACRC,KAAKG;QACP,IACA;YAAES,aAAa;QAAS;QAE1BL,SAASpB,KAAKsB,MAAM,CAACV,MAAMQ,OAAO,EAAE;YAClCM,cAAc;gBACZX;gBACAY,aAAa;gBACbb,MAAMJ,cAAc,CAACI,KAAK;gBAC1Bc,WAAW;YACb;YACAH,aAAarB;QACf;QACAiB,MAAMrB,KAAKsB,MAAM,CAACV,MAAMS,IAAI,EAAE;YAC5BK,cAAc;gBACZG,MAAM;gBACNC,UAAU,CAAC;YACb;YACAL,aAAapB;QACf;IACF;IAEA,MAAM,CAAC0B,aAAaC,eAAe,GAAGjC,qBAAqB;QACzDkB,OAAOA,MAAMG,OAAO,CAACa,IAAI;QACzBC,cAAcjB,MAAMG,OAAO,CAACe,WAAW;QACvCC,cAAc;IAChB;IAEAnB,MAAMG,OAAO,CAACa,IAAI,GAAGF;IACrBd,MAAMG,OAAO,CAACiB,YAAY,GAAGvC,eAAemB,MAAMG,OAAO,CAACiB,YAAY,EAAE,CAACC,GAAGC,OAASP,eAAeO,KAAKN,IAAI;IAE7G,MAAMO,UAAUvC,cAAcgB,MAAMI,IAAI,CAACR,GAAG;IAC5CI,MAAMI,IAAI,CAACR,GAAG,GAAG2B;IAEjB,kEAAkE;IAClE,MAAMC,qBAAqB,CAACH;QAC1B,MAAMI,cAAcJ,EAAEK,aAAa;QACnC,IAAI3B,QAAQ4B,OAAO,KAAKF,eAAe,CAACxC,gBAAgBsC,QAAQI,OAAO,EAAEF,cAAc;YACrFV,eAAe;QACjB;IACF;IAEAf,MAAME,IAAI,CAAC0B,MAAM,GAAG1C,iBAAiBL,eAAemB,MAAME,IAAI,CAAC0B,MAAM,EAAEJ;IACvExB,MAAMI,IAAI,CAACyB,aAAa,GAAG3C,iBAAiBL,eAAemB,MAAMI,IAAI,CAACyB,aAAa,EAAEL;IAErF,OAAOxB;AACT,EAAE"}
@@ -25,6 +25,7 @@ const popoverSizeMap = {
25
25
  };
26
26
  const useInfoButton_unstable = (props, ref)=>{
27
27
  const { size = 'medium', inline = true } = props;
28
+ const rootRef = (0, _reactutilities.useMergedRefs)(ref);
28
29
  const state = {
29
30
  inline,
30
31
  size,
@@ -38,7 +39,7 @@ const useInfoButton_unstable = (props, ref)=>{
38
39
  type: 'button',
39
40
  'aria-label': 'information',
40
41
  ...props,
41
- ref
42
+ ref: rootRef
42
43
  }), {
43
44
  elementType: 'button'
44
45
  }),
@@ -66,19 +67,16 @@ const useInfoButton_unstable = (props, ref)=>{
66
67
  });
67
68
  state.popover.open = popoverOpen;
68
69
  state.popover.onOpenChange = (0, _reactutilities.mergeCallbacks)(state.popover.onOpenChange, (e, data)=>setPopoverOpen(data.open));
69
- const focusOutRef = _react.useCallback((el)=>{
70
- if (!el) {
71
- return;
70
+ const infoRef = (0, _reactutilities.useMergedRefs)(state.info.ref);
71
+ state.info.ref = infoRef;
72
+ // Hide the popover when focus moves out of the button and popover
73
+ const onBlurButtonOrInfo = (e)=>{
74
+ const nextFocused = e.relatedTarget;
75
+ if (rootRef.current !== nextFocused && !(0, _reactutilities.elementContains)(infoRef.current, nextFocused)) {
76
+ setPopoverOpen(false);
72
77
  }
73
- el.addEventListener('focusout', (e)=>{
74
- const nextFocused = e.relatedTarget;
75
- if ((0, _reactutilities.isHTMLElement)(nextFocused) && !(0, _reactutilities.elementContains)(el, nextFocused)) {
76
- setPopoverOpen(false);
77
- }
78
- });
79
- }, [
80
- setPopoverOpen
81
- ]);
82
- state.info.ref = (0, _reactutilities.useMergedRefs)(state.info.ref, focusOutRef);
78
+ };
79
+ state.root.onBlur = (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(state.root.onBlur, onBlurButtonOrInfo));
80
+ state.info.onBlurCapture = (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(state.info.onBlurCapture, onBlurButtonOrInfo));
83
81
  return state;
84
82
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["useInfoButton.js"],"sourcesContent":["import * as React from 'react';\nimport { DefaultInfoButtonIcon12, DefaultInfoButtonIcon16, DefaultInfoButtonIcon20 } from './DefaultInfoButtonIcons';\nimport { getIntrinsicElementProps, mergeCallbacks, useControllableState, slot, useMergedRefs, isHTMLElement, elementContains } from '@fluentui/react-utilities';\nimport { Popover, PopoverSurface } from '@fluentui/react-popover';\nconst infoButtonIconMap = {\n small: /*#__PURE__*/ React.createElement(DefaultInfoButtonIcon12, null),\n medium: /*#__PURE__*/ React.createElement(DefaultInfoButtonIcon16, null),\n large: /*#__PURE__*/ React.createElement(DefaultInfoButtonIcon20, null)\n};\nconst popoverSizeMap = {\n small: 'small',\n medium: 'small',\n large: 'medium'\n};\n/**\n * Create the state required to render InfoButton.\n *\n * The returned state can be modified with hooks such as useInfoButtonStyles_unstable,\n * before being passed to renderInfoButton_unstable.\n *\n * @param props - props from this instance of InfoButton\n * @param ref - reference to root HTMLButtonElement of InfoButton\n */ export const useInfoButton_unstable = (props, ref)=>{\n const { size = 'medium', inline = true } = props;\n const state = {\n inline,\n size,\n components: {\n root: 'button',\n popover: Popover,\n info: PopoverSurface\n },\n root: slot.always(getIntrinsicElementProps('button', {\n children: infoButtonIconMap[size],\n type: 'button',\n 'aria-label': 'information',\n ...props,\n ref\n }), {\n elementType: 'button'\n }),\n popover: slot.always(props.popover, {\n defaultProps: {\n inline,\n positioning: 'above-start',\n size: popoverSizeMap[size],\n withArrow: true\n },\n elementType: Popover\n }),\n info: slot.always(props.info, {\n defaultProps: {\n role: 'note',\n tabIndex: -1\n },\n elementType: PopoverSurface\n })\n };\n const [popoverOpen, setPopoverOpen] = useControllableState({\n state: state.popover.open,\n defaultState: state.popover.defaultOpen,\n initialState: false\n });\n state.popover.open = popoverOpen;\n state.popover.onOpenChange = mergeCallbacks(state.popover.onOpenChange, (e, data)=>setPopoverOpen(data.open));\n const focusOutRef = React.useCallback((el)=>{\n if (!el) {\n return;\n }\n el.addEventListener('focusout', (e)=>{\n const nextFocused = e.relatedTarget;\n if (isHTMLElement(nextFocused) && !elementContains(el, nextFocused)) {\n setPopoverOpen(false);\n }\n });\n }, [\n setPopoverOpen\n ]);\n state.info.ref = useMergedRefs(state.info.ref, focusOutRef);\n return state;\n};\n"],"names":["useInfoButton_unstable","infoButtonIconMap","small","React","createElement","DefaultInfoButtonIcon12","medium","DefaultInfoButtonIcon16","large","DefaultInfoButtonIcon20","popoverSizeMap","props","ref","size","inline","state","components","root","popover","Popover","info","PopoverSurface","slot","always","getIntrinsicElementProps","children","type","elementType","defaultProps","positioning","withArrow","role","tabIndex","popoverOpen","setPopoverOpen","useControllableState","open","defaultState","defaultOpen","initialState","onOpenChange","mergeCallbacks","e","data","focusOutRef","useCallback","el","addEventListener","nextFocused","relatedTarget","isHTMLElement","elementContains","useMergedRefs"],"mappings":";;;;+BAsBiBA;;;eAAAA;;;;iEAtBM;wCACmE;gCAC0C;8BAC5F;AACxC,MAAMC,oBAAoB;IACtBC,OAAO,WAAW,GAAGC,OAAMC,aAAa,CAACC,+CAAuB,EAAE;IAClEC,QAAQ,WAAW,GAAGH,OAAMC,aAAa,CAACG,+CAAuB,EAAE;IACnEC,OAAO,WAAW,GAAGL,OAAMC,aAAa,CAACK,+CAAuB,EAAE;AACtE;AACA,MAAMC,iBAAiB;IACnBR,OAAO;IACPI,QAAQ;IACRE,OAAO;AACX;AASW,MAAMR,yBAAyB,CAACW,OAAOC;IAC9C,MAAM,EAAEC,OAAO,QAAQ,EAAEC,SAAS,IAAI,EAAE,GAAGH;IAC3C,MAAMI,QAAQ;QACVD;QACAD;QACAG,YAAY;YACRC,MAAM;YACNC,SAASC,qBAAO;YAChBC,MAAMC,4BAAc;QACxB;QACAJ,MAAMK,oBAAI,CAACC,MAAM,CAACC,IAAAA,wCAAwB,EAAC,UAAU;YACjDC,UAAUxB,iBAAiB,CAACY,KAAK;YACjCa,MAAM;YACN,cAAc;YACd,GAAGf,KAAK;YACRC;QACJ,IAAI;YACAe,aAAa;QACjB;QACAT,SAASI,oBAAI,CAACC,MAAM,CAACZ,MAAMO,OAAO,EAAE;YAChCU,cAAc;gBACVd;gBACAe,aAAa;gBACbhB,MAAMH,cAAc,CAACG,KAAK;gBAC1BiB,WAAW;YACf;YACAH,aAAaR,qBAAO;QACxB;QACAC,MAAME,oBAAI,CAACC,MAAM,CAACZ,MAAMS,IAAI,EAAE;YAC1BQ,cAAc;gBACVG,MAAM;gBACNC,UAAU,CAAC;YACf;YACAL,aAAaN,4BAAc;QAC/B;IACJ;IACA,MAAM,CAACY,aAAaC,eAAe,GAAGC,IAAAA,oCAAoB,EAAC;QACvDpB,OAAOA,MAAMG,OAAO,CAACkB,IAAI;QACzBC,cAActB,MAAMG,OAAO,CAACoB,WAAW;QACvCC,cAAc;IAClB;IACAxB,MAAMG,OAAO,CAACkB,IAAI,GAAGH;IACrBlB,MAAMG,OAAO,CAACsB,YAAY,GAAGC,IAAAA,8BAAc,EAAC1B,MAAMG,OAAO,CAACsB,YAAY,EAAE,CAACE,GAAGC,OAAOT,eAAeS,KAAKP,IAAI;IAC3G,MAAMQ,cAAczC,OAAM0C,WAAW,CAAC,CAACC;QACnC,IAAI,CAACA,IAAI;YACL;QACJ;QACAA,GAAGC,gBAAgB,CAAC,YAAY,CAACL;YAC7B,MAAMM,cAAcN,EAAEO,aAAa;YACnC,IAAIC,IAAAA,6BAAa,EAACF,gBAAgB,CAACG,IAAAA,+BAAe,EAACL,IAAIE,cAAc;gBACjEd,eAAe;YACnB;QACJ;IACJ,GAAG;QACCA;KACH;IACDnB,MAAMK,IAAI,CAACR,GAAG,GAAGwC,IAAAA,6BAAa,EAACrC,MAAMK,IAAI,CAACR,GAAG,EAAEgC;IAC/C,OAAO7B;AACX"}
1
+ {"version":3,"sources":["useInfoButton.js"],"sourcesContent":["import * as React from 'react';\nimport { DefaultInfoButtonIcon12, DefaultInfoButtonIcon16, DefaultInfoButtonIcon20 } from './DefaultInfoButtonIcons';\nimport { getIntrinsicElementProps, mergeCallbacks, useControllableState, slot, useMergedRefs, elementContains, useEventCallback } from '@fluentui/react-utilities';\nimport { Popover, PopoverSurface } from '@fluentui/react-popover';\nconst infoButtonIconMap = {\n small: /*#__PURE__*/ React.createElement(DefaultInfoButtonIcon12, null),\n medium: /*#__PURE__*/ React.createElement(DefaultInfoButtonIcon16, null),\n large: /*#__PURE__*/ React.createElement(DefaultInfoButtonIcon20, null)\n};\nconst popoverSizeMap = {\n small: 'small',\n medium: 'small',\n large: 'medium'\n};\n/**\n * Create the state required to render InfoButton.\n *\n * The returned state can be modified with hooks such as useInfoButtonStyles_unstable,\n * before being passed to renderInfoButton_unstable.\n *\n * @param props - props from this instance of InfoButton\n * @param ref - reference to root HTMLButtonElement of InfoButton\n */ export const useInfoButton_unstable = (props, ref)=>{\n const { size = 'medium', inline = true } = props;\n const rootRef = useMergedRefs(ref);\n const state = {\n inline,\n size,\n components: {\n root: 'button',\n popover: Popover,\n info: PopoverSurface\n },\n root: slot.always(getIntrinsicElementProps('button', {\n children: infoButtonIconMap[size],\n type: 'button',\n 'aria-label': 'information',\n ...props,\n ref: rootRef\n }), {\n elementType: 'button'\n }),\n popover: slot.always(props.popover, {\n defaultProps: {\n inline,\n positioning: 'above-start',\n size: popoverSizeMap[size],\n withArrow: true\n },\n elementType: Popover\n }),\n info: slot.always(props.info, {\n defaultProps: {\n role: 'note',\n tabIndex: -1\n },\n elementType: PopoverSurface\n })\n };\n const [popoverOpen, setPopoverOpen] = useControllableState({\n state: state.popover.open,\n defaultState: state.popover.defaultOpen,\n initialState: false\n });\n state.popover.open = popoverOpen;\n state.popover.onOpenChange = mergeCallbacks(state.popover.onOpenChange, (e, data)=>setPopoverOpen(data.open));\n const infoRef = useMergedRefs(state.info.ref);\n state.info.ref = infoRef;\n // Hide the popover when focus moves out of the button and popover\n const onBlurButtonOrInfo = (e)=>{\n const nextFocused = e.relatedTarget;\n if (rootRef.current !== nextFocused && !elementContains(infoRef.current, nextFocused)) {\n setPopoverOpen(false);\n }\n };\n state.root.onBlur = useEventCallback(mergeCallbacks(state.root.onBlur, onBlurButtonOrInfo));\n state.info.onBlurCapture = useEventCallback(mergeCallbacks(state.info.onBlurCapture, onBlurButtonOrInfo));\n return state;\n};\n"],"names":["useInfoButton_unstable","infoButtonIconMap","small","React","createElement","DefaultInfoButtonIcon12","medium","DefaultInfoButtonIcon16","large","DefaultInfoButtonIcon20","popoverSizeMap","props","ref","size","inline","rootRef","useMergedRefs","state","components","root","popover","Popover","info","PopoverSurface","slot","always","getIntrinsicElementProps","children","type","elementType","defaultProps","positioning","withArrow","role","tabIndex","popoverOpen","setPopoverOpen","useControllableState","open","defaultState","defaultOpen","initialState","onOpenChange","mergeCallbacks","e","data","infoRef","onBlurButtonOrInfo","nextFocused","relatedTarget","current","elementContains","onBlur","useEventCallback","onBlurCapture"],"mappings":";;;;+BAsBiBA;;;eAAAA;;;;iEAtBM;wCACmE;gCAC6C;8BAC/F;AACxC,MAAMC,oBAAoB;IACtBC,OAAO,WAAW,GAAGC,OAAMC,aAAa,CAACC,+CAAuB,EAAE;IAClEC,QAAQ,WAAW,GAAGH,OAAMC,aAAa,CAACG,+CAAuB,EAAE;IACnEC,OAAO,WAAW,GAAGL,OAAMC,aAAa,CAACK,+CAAuB,EAAE;AACtE;AACA,MAAMC,iBAAiB;IACnBR,OAAO;IACPI,QAAQ;IACRE,OAAO;AACX;AASW,MAAMR,yBAAyB,CAACW,OAAOC;IAC9C,MAAM,EAAEC,OAAO,QAAQ,EAAEC,SAAS,IAAI,EAAE,GAAGH;IAC3C,MAAMI,UAAUC,IAAAA,6BAAa,EAACJ;IAC9B,MAAMK,QAAQ;QACVH;QACAD;QACAK,YAAY;YACRC,MAAM;YACNC,SAASC,qBAAO;YAChBC,MAAMC,4BAAc;QACxB;QACAJ,MAAMK,oBAAI,CAACC,MAAM,CAACC,IAAAA,wCAAwB,EAAC,UAAU;YACjDC,UAAU1B,iBAAiB,CAACY,KAAK;YACjCe,MAAM;YACN,cAAc;YACd,GAAGjB,KAAK;YACRC,KAAKG;QACT,IAAI;YACAc,aAAa;QACjB;QACAT,SAASI,oBAAI,CAACC,MAAM,CAACd,MAAMS,OAAO,EAAE;YAChCU,cAAc;gBACVhB;gBACAiB,aAAa;gBACblB,MAAMH,cAAc,CAACG,KAAK;gBAC1BmB,WAAW;YACf;YACAH,aAAaR,qBAAO;QACxB;QACAC,MAAME,oBAAI,CAACC,MAAM,CAACd,MAAMW,IAAI,EAAE;YAC1BQ,cAAc;gBACVG,MAAM;gBACNC,UAAU,CAAC;YACf;YACAL,aAAaN,4BAAc;QAC/B;IACJ;IACA,MAAM,CAACY,aAAaC,eAAe,GAAGC,IAAAA,oCAAoB,EAAC;QACvDpB,OAAOA,MAAMG,OAAO,CAACkB,IAAI;QACzBC,cAActB,MAAMG,OAAO,CAACoB,WAAW;QACvCC,cAAc;IAClB;IACAxB,MAAMG,OAAO,CAACkB,IAAI,GAAGH;IACrBlB,MAAMG,OAAO,CAACsB,YAAY,GAAGC,IAAAA,8BAAc,EAAC1B,MAAMG,OAAO,CAACsB,YAAY,EAAE,CAACE,GAAGC,OAAOT,eAAeS,KAAKP,IAAI;IAC3G,MAAMQ,UAAU9B,IAAAA,6BAAa,EAACC,MAAMK,IAAI,CAACV,GAAG;IAC5CK,MAAMK,IAAI,CAACV,GAAG,GAAGkC;IACjB,kEAAkE;IAClE,MAAMC,qBAAqB,CAACH;QACxB,MAAMI,cAAcJ,EAAEK,aAAa;QACnC,IAAIlC,QAAQmC,OAAO,KAAKF,eAAe,CAACG,IAAAA,+BAAe,EAACL,QAAQI,OAAO,EAAEF,cAAc;YACnFZ,eAAe;QACnB;IACJ;IACAnB,MAAME,IAAI,CAACiC,MAAM,GAAGC,IAAAA,gCAAgB,EAACV,IAAAA,8BAAc,EAAC1B,MAAME,IAAI,CAACiC,MAAM,EAAEL;IACvE9B,MAAMK,IAAI,CAACgC,aAAa,GAAGD,IAAAA,gCAAgB,EAACV,IAAAA,8BAAc,EAAC1B,MAAMK,IAAI,CAACgC,aAAa,EAAEP;IACrF,OAAO9B;AACX"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-infolabel",
3
- "version": "9.0.23",
3
+ "version": "9.0.24",
4
4
  "description": "InfoLabel component for Fluent UI v9",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -14,6 +14,8 @@
14
14
  "scripts": {
15
15
  "build": "just-scripts build",
16
16
  "clean": "just-scripts clean",
17
+ "e2e": "cypress run --component",
18
+ "e2e:local": "cypress open --component",
17
19
  "generate-api": "just-scripts generate-api",
18
20
  "lint": "just-scripts lint",
19
21
  "start": "yarn storybook",
@@ -31,12 +33,12 @@
31
33
  },
32
34
  "dependencies": {
33
35
  "@fluentui/react-icons": "^2.0.224",
34
- "@fluentui/react-label": "^9.1.63",
35
- "@fluentui/react-popover": "^9.8.40",
36
- "@fluentui/react-tabster": "^9.19.2",
37
- "@fluentui/react-jsx-runtime": "^9.0.31",
38
- "@fluentui/react-theme": "^9.1.16",
39
- "@fluentui/react-utilities": "^9.18.2",
36
+ "@fluentui/react-label": "^9.1.64",
37
+ "@fluentui/react-popover": "^9.9.0",
38
+ "@fluentui/react-tabster": "^9.19.3",
39
+ "@fluentui/react-jsx-runtime": "^9.0.32",
40
+ "@fluentui/react-theme": "^9.1.17",
41
+ "@fluentui/react-utilities": "^9.18.3",
40
42
  "@griffel/react": "^1.5.14",
41
43
  "@swc/helpers": "^0.5.1"
42
44
  },