@fluentui-copilot/react-reference 0.13.9 → 0.13.10

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 (18) hide show
  1. package/CHANGELOG.json +16 -1
  2. package/CHANGELOG.md +10 -1
  3. package/dist/index.d.ts +1 -0
  4. package/lib/components/reference-v2/ReferenceList/useReferenceList.js +3 -1
  5. package/lib/components/reference-v2/ReferenceList/useReferenceList.js.map +1 -1
  6. package/lib/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.types.js.map +1 -1
  7. package/lib/components/reference-v2/ReferenceOverflowButton/renderReferenceOverflowButton.js +10 -2
  8. package/lib/components/reference-v2/ReferenceOverflowButton/renderReferenceOverflowButton.js.map +1 -1
  9. package/lib/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js +4 -1
  10. package/lib/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js.map +1 -1
  11. package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceList.js +3 -1
  12. package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceList.js.map +1 -1
  13. package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.types.js.map +1 -1
  14. package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/renderReferenceOverflowButton.js +6 -1
  15. package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/renderReferenceOverflowButton.js.map +1 -1
  16. package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js +3 -1
  17. package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js.map +1 -1
  18. package/package.json +2 -2
package/CHANGELOG.json CHANGED
@@ -2,7 +2,22 @@
2
2
  "name": "@fluentui-copilot/react-reference",
3
3
  "entries": [
4
4
  {
5
- "date": "Fri, 07 Feb 2025 02:01:25 GMT",
5
+ "date": "Fri, 28 Feb 2025 00:26:29 GMT",
6
+ "tag": "@fluentui-copilot/react-reference_v0.13.10",
7
+ "version": "0.13.10",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "tristan.watanabe@gmail.com",
12
+ "package": "@fluentui-copilot/react-reference",
13
+ "commit": "f62c9c504bcdb6e39ff00c1e95b0a93eb84b7e49",
14
+ "comment": "fix: overflow button now included in overflow calculation, preventing it from exceeding its parent container."
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Fri, 07 Feb 2025 02:02:09 GMT",
6
21
  "tag": "@fluentui-copilot/react-reference_v0.13.9",
7
22
  "version": "0.13.9",
8
23
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,9 +1,18 @@
1
1
  # Change Log - @fluentui-copilot/react-reference
2
2
 
3
- This log was last generated on Wed, 18 Dec 2024 08:55:42 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 28 Feb 2025 00:26:29 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [0.13.10](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-reference_v0.13.10)
8
+
9
+ Fri, 28 Feb 2025 00:26:29 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/react-reference_v0.13.9..@fluentui-copilot/react-reference_v0.13.10)
11
+
12
+ ### Patches
13
+
14
+ - fix: overflow button now included in overflow calculation, preventing it from exceeding its parent container. ([PR #2703](https://github.com/microsoft/fluentai/pull/2703) by tristan.watanabe@gmail.com)
15
+
7
16
  ## [0.13.8](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-reference_v0.13.8)
8
17
 
9
18
  Wed, 18 Dec 2024 08:55:42 GMT
package/dist/index.d.ts CHANGED
@@ -261,6 +261,7 @@ export declare type ReferenceOverflowButtonSlots = {
261
261
  * State used in rendering ReferenceOverflowButton
262
262
  */
263
263
  export declare type ReferenceOverflowButtonState = ComponentState<ReferenceOverflowButtonSlots> & {
264
+ id: string;
264
265
  shouldRenderOverflowButton: boolean;
265
266
  };
266
267
 
@@ -46,11 +46,13 @@ export const useReferenceList_unstable = (props, ref) => {
46
46
  setAreReferencesExpanded(false);
47
47
  }, []);
48
48
  const shouldUseOverflow = (minVisibleReferences === undefined || minVisibleReferences < totalReferencesCount) && maxVisibleReferences !== undefined && !areReferencesExpanded;
49
+ // Since the overflow button is an OverflowItem that's always visible, we need to account for it.
50
+ const minVisibleOverflowItems = minVisibleReferences ? minVisibleReferences + 1 : 1;
49
51
  const state = {
50
52
  areReferencesExpanded,
51
53
  overflowButtonTriggeredViaKeyboard,
52
54
  maxVisibleReferences,
53
- minVisibleReferences,
55
+ minVisibleReferences: minVisibleOverflowItems,
54
56
  referenceListRef,
55
57
  shouldUseOverflow,
56
58
  totalReferencesCount,
@@ -1 +1 @@
1
- {"version":3,"sources":["useReferenceList.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n getIntrinsicElementProps,\n mergeCallbacks,\n slot,\n useArrowNavigationGroup,\n useMergedRefs,\n} from '@fluentui/react-components';\nimport { useOverflowMaxVisibleItems } from '@fluentui-copilot/react-utilities';\nimport { useRootStyles } from '../Reference/useReferenceStyles.styles';\nimport type { ReferenceListProps, ReferenceListState } from './ReferenceList.types';\n\n/**\n * Create the state required to render ReferenceList.\n *\n * The returned state can be modified with hooks such as useReferenceListStyles_unstable,\n * before being passed to renderReferenceList_unstable.\n *\n * @param props - props from this instance of ReferenceList\n * @param ref - reference to root HTMLElement of ReferenceList\n */\nexport const useReferenceList_unstable = (\n props: ReferenceListProps,\n ref: React.Ref<HTMLDivElement>,\n): ReferenceListState => {\n const {\n arrowableRegion,\n children,\n maxVisibleReferences,\n minVisibleReferences,\n showLessButton,\n showMoreButton,\n ...rest\n } = props;\n\n const [areReferencesExpanded, setAreReferencesExpanded] = React.useState(false);\n const referenceListRef = React.useRef<HTMLDivElement>(null);\n\n const totalReferencesCount = React.Children.count(children);\n const styles = useRootStyles();\n const resolvedChildren = useOverflowMaxVisibleItems({\n additionalCondition: !areReferencesExpanded,\n children,\n maxVisibleItems: maxVisibleReferences,\n minVisibleItems: minVisibleReferences,\n overflowClassName: styles.overflow,\n });\n\n // We keep track of whether we are interacting with the overflow button via keyboard or not.\n const overflowButtonTriggeredViaKeyboard = React.useRef(false);\n\n const focusAttributes = useArrowNavigationGroup({\n axis: 'both',\n circular: true,\n memorizeCurrent: true,\n });\n\n const onShowMoreButtonClick = React.useCallback<React.MouseEventHandler<HTMLButtonElement>>(() => {\n setAreReferencesExpanded(true);\n }, []);\n\n const onShowLessButtonClick = React.useCallback<React.MouseEventHandler<HTMLButtonElement>>(() => {\n setAreReferencesExpanded(false);\n }, []);\n\n const shouldUseOverflow =\n (minVisibleReferences === undefined || minVisibleReferences < totalReferencesCount) &&\n maxVisibleReferences !== undefined &&\n !areReferencesExpanded;\n\n const state: ReferenceListState = {\n areReferencesExpanded,\n overflowButtonTriggeredViaKeyboard,\n maxVisibleReferences,\n minVisibleReferences,\n referenceListRef,\n shouldUseOverflow,\n totalReferencesCount,\n\n components: {\n root: 'div',\n arrowableRegion: 'div',\n showMoreButton: 'span',\n showLessButton: 'span',\n },\n root: slot.always(\n getIntrinsicElementProps('div', {\n ref: useMergedRefs(ref, referenceListRef),\n ...rest,\n }),\n { elementType: 'div' },\n ),\n arrowableRegion: slot.always(arrowableRegion, {\n defaultProps: { ...focusAttributes, children: resolvedChildren },\n elementType: 'div',\n }),\n showMoreButton: shouldUseOverflow ? slot.optional(showMoreButton, { elementType: 'span' }) : undefined,\n showLessButton: areReferencesExpanded ? slot.optional(showLessButton, { elementType: 'span' }) : undefined,\n };\n\n if (state.showMoreButton) {\n state.showMoreButton.onClick = mergeCallbacks(onShowMoreButtonClick, state.showMoreButton.onClick);\n }\n\n if (state.showLessButton) {\n state.showLessButton.onClick = mergeCallbacks(onShowLessButtonClick, state.showLessButton.onClick);\n }\n\n return state;\n};\n"],"names":["React","getIntrinsicElementProps","mergeCallbacks","slot","useArrowNavigationGroup","useMergedRefs","useOverflowMaxVisibleItems","useRootStyles","useReferenceList_unstable","props","ref","arrowableRegion","children","maxVisibleReferences","minVisibleReferences","showLessButton","showMoreButton","rest","areReferencesExpanded","setAreReferencesExpanded","useState","referenceListRef","useRef","totalReferencesCount","Children","count","styles","resolvedChildren","additionalCondition","maxVisibleItems","minVisibleItems","overflowClassName","overflow","overflowButtonTriggeredViaKeyboard","focusAttributes","axis","circular","memorizeCurrent","onShowMoreButtonClick","useCallback","onShowLessButtonClick","shouldUseOverflow","undefined","state","components","root","always","elementType","defaultProps","optional","onClick"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,wBAAwB,EACxBC,cAAc,EACdC,IAAI,EACJC,uBAAuB,EACvBC,aAAa,QACR,6BAA6B;AACpC,SAASC,0BAA0B,QAAQ,oCAAoC;AAC/E,SAASC,aAAa,QAAQ,yCAAyC;AAGvE;;;;;;;;CAQC,GACD,OAAO,MAAMC,4BAA4B,CACvCC,OACAC;IAEA,MAAM,EACJC,eAAe,EACfC,QAAQ,EACRC,oBAAoB,EACpBC,oBAAoB,EACpBC,cAAc,EACdC,cAAc,EACd,GAAGC,MACJ,GAAGR;IAEJ,MAAM,CAACS,uBAAuBC,yBAAyB,GAAGnB,MAAMoB,QAAQ,CAAC;IACzE,MAAMC,mBAAmBrB,MAAMsB,MAAM,CAAiB;IAEtD,MAAMC,uBAAuBvB,MAAMwB,QAAQ,CAACC,KAAK,CAACb;IAClD,MAAMc,SAASnB;IACf,MAAMoB,mBAAmBrB,2BAA2B;QAClDsB,qBAAqB,CAACV;QACtBN;QACAiB,iBAAiBhB;QACjBiB,iBAAiBhB;QACjBiB,mBAAmBL,OAAOM,QAAQ;IACpC;IAEA,4FAA4F;IAC5F,MAAMC,qCAAqCjC,MAAMsB,MAAM,CAAC;IAExD,MAAMY,kBAAkB9B,wBAAwB;QAC9C+B,MAAM;QACNC,UAAU;QAC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rinsicElementProps,\n mergeCallbacks,\n slot,\n useArrowNavigationGroup,\n useMergedRefs,\n} from '@fluentui/react-components';\nimport { useOverflowMaxVisibleItems } from '@fluentui-copilot/react-utilities';\nimport { useRootStyles } from '../Reference/useReferenceStyles.styles';\nimport type { ReferenceListProps, ReferenceListState } from './ReferenceList.types';\n\n/**\n * Create the state required to render ReferenceList.\n *\n * The returned state can be modified with hooks such as useReferenceListStyles_unstable,\n * before being passed to renderReferenceList_unstable.\n *\n * @param props - props from this instance of ReferenceList\n * @param ref - reference to root HTMLElement of ReferenceList\n */\nexport const useReferenceList_unstable = (\n props: ReferenceListProps,\n ref: React.Ref<HTMLDivElement>,\n): ReferenceListState => {\n const {\n arrowableRegion,\n children,\n maxVisibleReferences,\n minVisibleReferences,\n showLessButton,\n showMoreButton,\n ...rest\n } = props;\n\n const [areReferencesExpanded, setAreReferencesExpanded] = React.useState(false);\n const referenceListRef = React.useRef<HTMLDivElement>(null);\n\n const totalReferencesCount = React.Children.count(children);\n const styles = useRootStyles();\n const resolvedChildren = useOverflowMaxVisibleItems({\n additionalCondition: !areReferencesExpanded,\n children,\n maxVisibleItems: maxVisibleReferences,\n minVisibleItems: minVisibleReferences,\n overflowClassName: styles.overflow,\n });\n\n // We keep track of whether we are interacting with the overflow button via keyboard or not.\n const overflowButtonTriggeredViaKeyboard = React.useRef(false);\n\n const focusAttributes = useArrowNavigationGroup({\n axis: 'both',\n circular: true,\n memorizeCurrent: true,\n });\n\n const onShowMoreButtonClick = React.useCallback<React.MouseEventHandler<HTMLButtonElement>>(() => {\n setAreReferencesExpanded(true);\n }, []);\n\n const onShowLessButtonClick = React.useCallback<React.MouseEventHandler<HTMLButtonElement>>(() => {\n setAreReferencesExpanded(false);\n }, []);\n\n const shouldUseOverflow =\n (minVisibleReferences === undefined || minVisibleReferences < totalReferencesCount) &&\n maxVisibleReferences !== undefined &&\n !areReferencesExpanded;\n\n // Since the overflow button is an OverflowItem that's always visible, we need to account for it.\n const minVisibleOverflowItems = minVisibleReferences ? minVisibleReferences + 1 : 1;\n\n const state: ReferenceListState = {\n areReferencesExpanded,\n overflowButtonTriggeredViaKeyboard,\n maxVisibleReferences,\n minVisibleReferences: minVisibleOverflowItems,\n referenceListRef,\n shouldUseOverflow,\n totalReferencesCount,\n\n components: {\n root: 'div',\n arrowableRegion: 'div',\n showMoreButton: 'span',\n showLessButton: 'span',\n },\n root: slot.always(\n getIntrinsicElementProps('div', {\n ref: useMergedRefs(ref, referenceListRef),\n ...rest,\n }),\n { elementType: 'div' },\n ),\n arrowableRegion: slot.always(arrowableRegion, {\n defaultProps: { ...focusAttributes, children: resolvedChildren },\n elementType: 'div',\n }),\n showMoreButton: shouldUseOverflow ? slot.optional(showMoreButton, { elementType: 'span' }) : undefined,\n showLessButton: areReferencesExpanded ? slot.optional(showLessButton, { elementType: 'span' }) : undefined,\n };\n\n if (state.showMoreButton) {\n state.showMoreButton.onClick = mergeCallbacks(onShowMoreButtonClick, state.showMoreButton.onClick);\n }\n\n if (state.showLessButton) {\n state.showLessButton.onClick = mergeCallbacks(onShowLessButtonClick, state.showLessButton.onClick);\n }\n\n return state;\n};\n"],"names":["React","getIntrinsicElementProps","mergeCallbacks","slot","useArrowNavigationGroup","useMergedRefs","useOverflowMaxVisibleItems","useRootStyles","useReferenceList_unstable","props","ref","arrowableRegion","children","maxVisibleReferences","minVisibleReferences","showLessButton","showMoreButton","rest","areReferencesExpanded","setAreReferencesExpanded","useState","referenceListRef","useRef","totalReferencesCount","Children","count","styles","resolvedChildren","additionalCondition","maxVisibleItems","minVisibleItems","overflowClassName","overflow","overflowButtonTriggeredViaKeyboard","focusAttributes","axis","circular","memorizeCurrent","onShowMoreButtonClick","useCallback","onShowLessButtonClick","shouldUseOverflow","undefined","minVisibleOverflowItems","state","components","root","always","elementType","defaultProps","optional","onClick"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,sBAAsB6B;QACtBtB;QACAoB;QACAlB;QAEAsB,YAAY;YACVC,MAAM;YACNnC,iBAAiB;YACjBK,gBAAgB;YAChBD,gBAAgB;QAClB;QACA+B,MAAM3C,KAAK4C,MAAM,CACf9C,yBAAyB,OAAO;YAC9BS,KAAKL,cAAcK,KAAKW;YACxB,GAAGJ,IAAI;QACT,IACA;YAAE+B,aAAa;QAAM;QAEvBrC,iBAAiBR,KAAK4C,MAAM,CAACpC,iBAAiB;YAC5CsC,cAAc;gBAAE,GAAGf,eAAe;gBAAEtB,UAAUe;YAAiB;YAC/DqB,aAAa;QACf;QACAhC,gBAAgByB,oBAAoBtC,KAAK+C,QAAQ,CAAClC,gBAAgB;YAAEgC,aAAa;QAAO,KAAKN;QAC7F3B,gBAAgBG,wBAAwBf,KAAK+C,QAAQ,CAACnC,gBAAgB;YAAEiC,aAAa;QAAO,KAAKN;IACnG;IAEA,IAAIE,MAAM5B,cAAc,EAAE;QACxB4B,MAAM5B,cAAc,CAACmC,OAAO,GAAGjD,eAAeoC,uBAAuBM,MAAM5B,cAAc,CAACmC,OAAO;IACnG;IAEA,IAAIP,MAAM7B,cAAc,EAAE;QACxB6B,MAAM7B,cAAc,CAACoC,OAAO,GAAGjD,eAAesC,uBAAuBI,MAAM7B,cAAc,CAACoC,OAAO;IACnG;IAEA,OAAOP;AACT,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["ReferenceOverflowButton.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-components';\n\nexport type ReferenceOverflowButtonSlots = {\n /** The root of the component that renders the overflow button. */\n root: Slot<'button'>;\n};\n\n/**\n * ReferenceOverflowButton Props\n */\nexport type ReferenceOverflowButtonProps = ComponentProps<ReferenceOverflowButtonSlots> & {\n /**\n * The text that is displayed inside of the overflow button. This text is only displayed when `children` has not been passed to the component.\n * If a string is passed, that is what is rendered verbatim.\n * If a callback is passed, the callback is called with the number of items that are overflowing, and the result of the callback is rendered.\n */\n text?: string | ((overflowCount: number) => React.ReactNode);\n};\n\n/**\n * State used in rendering ReferenceOverflowButton\n */\nexport type ReferenceOverflowButtonState = ComponentState<ReferenceOverflowButtonSlots> & {\n shouldRenderOverflowButton: boolean;\n};\n"],"names":[],"rangeMappings":";;","mappings":"AAmBA;;CAEC,GACD,WAEE"}
1
+ {"version":3,"sources":["ReferenceOverflowButton.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-components';\n\nexport type ReferenceOverflowButtonSlots = {\n /** The root of the component that renders the overflow button. */\n root: Slot<'button'>;\n};\n\n/**\n * ReferenceOverflowButton Props\n */\nexport type ReferenceOverflowButtonProps = ComponentProps<ReferenceOverflowButtonSlots> & {\n /**\n * The text that is displayed inside of the overflow button. This text is only displayed when `children` has not been passed to the component.\n * If a string is passed, that is what is rendered verbatim.\n * If a callback is passed, the callback is called with the number of items that are overflowing, and the result of the callback is rendered.\n */\n text?: string | ((overflowCount: number) => React.ReactNode);\n};\n\n/**\n * State used in rendering ReferenceOverflowButton\n */\nexport type ReferenceOverflowButtonState = ComponentState<ReferenceOverflowButtonSlots> & {\n id: string;\n shouldRenderOverflowButton: boolean;\n};\n"],"names":[],"rangeMappings":";;","mappings":"AAmBA;;CAEC,GACD,WAGE"}
@@ -1,10 +1,18 @@
1
1
  import { jsx as _jsx } from "@fluentui/react-jsx-runtime/jsx-runtime";
2
- import { assertSlots } from '@fluentui/react-components';
2
+ import { OverflowItem, assertSlots } from '@fluentui/react-components';
3
3
  /**
4
4
  * Render the final JSX of ReferenceOverflowButton
5
5
  */
6
6
  export const renderReferenceOverflowButton_unstable = state => {
7
7
  assertSlots(state);
8
- return state.shouldRenderOverflowButton ? /*#__PURE__*/_jsx(state.root, {}) : null;
8
+ const {
9
+ id,
10
+ shouldRenderOverflowButton
11
+ } = state;
12
+ return shouldRenderOverflowButton ? /*#__PURE__*/_jsx(OverflowItem, {
13
+ id: id,
14
+ priority: 1,
15
+ children: /*#__PURE__*/_jsx(state.root, {})
16
+ }, id) : null;
9
17
  };
10
18
  //# sourceMappingURL=renderReferenceOverflowButton.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["renderReferenceOverflowButton.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-components';\nimport type { ReferenceOverflowButtonState, ReferenceOverflowButtonSlots } from './ReferenceOverflowButton.types';\n\n/**\n * Render the final JSX of ReferenceOverflowButton\n */\nexport const renderReferenceOverflowButton_unstable = (state: ReferenceOverflowButtonState) => {\n assertSlots<ReferenceOverflowButtonSlots>(state);\n\n return state.shouldRenderOverflowButton ? <state.root /> : null;\n};\n"],"names":["assertSlots","renderReferenceOverflowButton_unstable","state","shouldRenderOverflowButton","root"],"rangeMappings":";;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,6BAA6B;AAGzD;;CAEC,GACD,OAAO,MAAMC,yCAAyC,CAACC;IACrDF,YAA0CE;IAE1C,OAAOA,MAAMC,0BAA0B,iBAAG,KAACD,MAAME,IAAI,QAAM;AAC7D,EAAE"}
1
+ {"version":3,"sources":["renderReferenceOverflowButton.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { OverflowItem, assertSlots } from '@fluentui/react-components';\nimport type { ReferenceOverflowButtonState, ReferenceOverflowButtonSlots } from './ReferenceOverflowButton.types';\n\n/**\n * Render the final JSX of ReferenceOverflowButton\n */\nexport const renderReferenceOverflowButton_unstable = (state: ReferenceOverflowButtonState) => {\n assertSlots<ReferenceOverflowButtonSlots>(state);\n const { id, shouldRenderOverflowButton } = state;\n\n return shouldRenderOverflowButton ? (\n <OverflowItem key={id} id={id} priority={1}>\n <state.root />\n </OverflowItem>\n ) : null;\n};\n"],"names":["OverflowItem","assertSlots","renderReferenceOverflowButton_unstable","state","id","shouldRenderOverflowButton","priority","root"],"rangeMappings":";;;;;;;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,YAAY,EAAEC,WAAW,QAAQ,6BAA6B;AAGvE;;CAEC,GACD,OAAO,MAAMC,yCAAyC,CAACC;IACrDF,YAA0CE;IAC1C,MAAM,EAAEC,EAAE,EAAEC,0BAA0B,EAAE,GAAGF;IAE3C,OAAOE,2CACL,KAACL;QAAsBI,IAAIA;QAAIE,UAAU;kBACvC,cAAA,KAACH,MAAMI,IAAI;OADMH,MAGjB;AACN,EAAE"}
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { Enter, Space } from '@fluentui/keyboard-keys';
3
- import { getIntrinsicElementProps, mergeCallbacks, slot, useFocusFinders, useMergedRefs, useOverflowMenu } from '@fluentui/react-components';
3
+ import { getIntrinsicElementProps, mergeCallbacks, slot, useFocusFinders, useId, useMergedRefs, useOverflowMenu } from '@fluentui/react-components';
4
4
  import { useTimeout } from '@fluentui/react-utilities';
5
5
  import { useReferenceListContext_unstable } from '../../../contexts/reference-v2/referenceListContext';
6
6
  /**
@@ -17,10 +17,12 @@ export const useReferenceOverflowButton_unstable = (props, ref) => {
17
17
 
18
18
  const {
19
19
  children,
20
+ id,
20
21
  text
21
22
  } = props;
22
23
  const rootRef = React.useRef(null);
23
24
  const [setTimeout] = useTimeout();
25
+ const referenceOverflowButtonId = useId('reference-overflow-button-', id);
24
26
  const areReferencesExpanded = useReferenceListContext_unstable(ctx => ctx.areReferencesExpanded);
25
27
  const maxVisibleReferences = useReferenceListContext_unstable(ctx => ctx.maxVisibleReferences);
26
28
  const referenceListRef = useReferenceListContext_unstable(ctx => ctx.referenceListRef);
@@ -67,6 +69,7 @@ export const useReferenceOverflowButton_unstable = (props, ref) => {
67
69
  }
68
70
  }, [areReferencesExpanded, findFirstFocusable, findNextFocusable, isOverflowing, maxVisibleReferences, overflowCount, referenceListRef, setTimeout, totalReferencesCount, triggeredViaKeyboard]);
69
71
  const state = {
72
+ id: referenceOverflowButtonId,
70
73
  shouldRenderOverflowButton: isOverflowing || areReferencesExpanded,
71
74
  components: {
72
75
  root: 'button'
@@ -1 +1 @@
1
- {"version":3,"sources":["useReferenceOverflowButton.ts"],"sourcesContent":["import * as React from 'react';\nimport { Enter, Space } from '@fluentui/keyboard-keys';\nimport {\n getIntrinsicElementProps,\n mergeCallbacks,\n slot,\n useFocusFinders,\n useMergedRefs,\n useOverflowMenu,\n} from '@fluentui/react-components';\nimport { useTimeout } from '@fluentui/react-utilities';\nimport { useReferenceListContext_unstable } from '../../../contexts/reference-v2/referenceListContext';\nimport type { ReferenceOverflowButtonProps, ReferenceOverflowButtonState } from './ReferenceOverflowButton.types';\n\n/**\n * Create the state required to render ReferenceOverflowButton.\n *\n * The returned state can be modified with hooks such as useReferenceOverflowButtonStyles_unstable,\n * before being passed to renderReferenceOverflowButton_unstable.\n *\n * @param props - props from this instance of ReferenceOverflowButton\n * @param ref - reference to root HTMLElement of ReferenceOverflowButton\n */\nexport const useReferenceOverflowButton_unstable = (\n props: ReferenceOverflowButtonProps,\n ref: React.Ref<HTMLButtonElement>,\n): ReferenceOverflowButtonState => {\n 'use no memo';\n\n const { children, text } = props;\n\n const rootRef = React.useRef<HTMLButtonElement>(null);\n\n const [setTimeout] = useTimeout();\n\n const areReferencesExpanded = useReferenceListContext_unstable(ctx => ctx.areReferencesExpanded);\n const maxVisibleReferences = useReferenceListContext_unstable(ctx => ctx.maxVisibleReferences);\n const referenceListRef = useReferenceListContext_unstable(ctx => ctx.referenceListRef);\n const totalReferencesCount = useReferenceListContext_unstable(ctx => ctx.totalReferencesCount);\n const triggeredViaKeyboard = useReferenceListContext_unstable(ctx => ctx.overflowButtonTriggeredViaKeyboard);\n\n const { isOverflowing, overflowCount } = useOverflowMenu();\n\n const processedText = children ?? (typeof text === 'function' ? text(overflowCount) : text);\n\n const { findFirstFocusable, findNextFocusable } = useFocusFinders();\n const onKeyDown = React.useCallback<React.KeyboardEventHandler<HTMLButtonElement>>(\n ev => {\n if (ev.key === Enter || ev.key === Space) {\n triggeredViaKeyboard.current = true;\n }\n },\n [triggeredViaKeyboard],\n );\n\n // We keep track of the previous overflow count to help determine the element to move focus to when expanding the references via keyboard.\n const previousOverflow = React.useRef(0);\n\n // When the references are expanded or collapsed via keyboard, we need to move focus to the appropriate element.\n React.useEffect(() => {\n // We only try to move focus if maxVisibleReferences is set and the overflow button was triggered via keyboard.\n if (maxVisibleReferences !== undefined && triggeredViaKeyboard.current) {\n let elementToFocus: HTMLElement | null | undefined;\n\n // If the references are collapsed, we move focus to the overflow button.\n if (!areReferencesExpanded) {\n elementToFocus = rootRef.current;\n previousOverflow.current = overflowCount;\n }\n // If the references are expanded, we move focus to the first reference that was hidden when they were collapsed.\n // We do this by moving focus according to the following heuristics:\n // - If maxVisibleReferences is what determines what overflows, focus is moved to the element that is in the maxVisibleReferences position of the ReferenceList's children.\n // - If the space available is what is determines what overflows, focus is moved to the element that is in the (totalReferencesCount - overflowCount) position of the ReferenceList's children.\n else if (rootRef.current && referenceListRef.current) {\n const positionToFocus =\n maxVisibleReferences < totalReferencesCount - previousOverflow.current\n ? maxVisibleReferences\n : totalReferencesCount - previousOverflow.current;\n\n let currentElement: HTMLElement | null | undefined = findFirstFocusable(referenceListRef.current);\n for (let i = 0; i < positionToFocus && currentElement; i++) {\n currentElement = findNextFocusable(currentElement);\n }\n\n elementToFocus = currentElement;\n }\n\n // We focus on the element and reset the triggeredViaKeyboard flag after a timeout to ensure that this is pushed at the end of the event queue.\n setTimeout(() => {\n elementToFocus?.focus();\n triggeredViaKeyboard.current = false;\n }, 0);\n }\n }, [\n areReferencesExpanded,\n findFirstFocusable,\n findNextFocusable,\n isOverflowing,\n maxVisibleReferences,\n overflowCount,\n referenceListRef,\n setTimeout,\n totalReferencesCount,\n triggeredViaKeyboard,\n ]);\n\n const state: ReferenceOverflowButtonState = {\n shouldRenderOverflowButton: isOverflowing || areReferencesExpanded,\n\n components: {\n root: 'button',\n },\n\n root: slot.always(\n getIntrinsicElementProps('button', {\n ref: useMergedRefs(rootRef, ref),\n ...props,\n }),\n {\n defaultProps: {\n children: processedText,\n },\n elementType: 'button',\n },\n ),\n };\n\n state.root.onKeyDown = mergeCallbacks(onKeyDown, props.onKeyDown);\n\n return state;\n};\n"],"names":["React","Enter","Space","getIntrinsicElementProps","mergeCallbacks","slot","useFocusFinders","useMergedRefs","useOverflowMenu","useTimeout","useReferenceListContext_unstable","useReferenceOverflowButton_unstable","props","ref","children","text","rootRef","useRef","setTimeout","areReferencesExpanded","ctx","maxVisibleReferences","referenceListRef","totalReferencesCount","triggeredViaKeyboard","overflowButtonTriggeredViaKeyboard","isOverflowing","overflowCount","processedText","findFirstFocusable","findNextFocusable","onKeyDown","useCallback","ev","key","current","previousOverflow","useEffect","undefined","elementToFocus","positionToFocus","currentElement","i","focus","state","shouldRenderOverflowButton","components","root","always","defaultProps","elementType"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,KAAK,EAAEC,KAAK,QAAQ,0BAA0B;AACvD,SACEC,wBAAwB,EACxBC,cAAc,EACdC,IAAI,EACJC,eAAe,EACfC,aAAa,EACbC,eAAe,QACV,6BAA6B;AACpC,SAASC,UAAU,QAAQ,4BAA4B;AACvD,SAASC,gCAAgC,QAAQ,sDAAsD;AAGvG;;;;;;;;CAQC,GACD,OAAO,MAAMC,sCAAsC,CACjDC,OACAC;IAEA;IAEA,MAAM,EAAEC,QAAQ,EAAEC,IAAI,EAAE,GAAGH;IAE3B,MAAMI,UAAUhB,MAAMiB,MAAM,CAAoB;IAEhD,MAAM,CAACC,WAAW,GAAGT;IAErB,MAAMU,wBAAwBT,iCAAiCU,CAAAA,MAAOA,IAAID,qBAAqB;IAC/F,MAAME,uBAAuBX,iCAAiCU,CAAAA,MAAOA,IAAIC,oBAA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WAAW;gBACTqB,2BAAAA,qCAAAA,eAAgBI,KAAK;gBACrBnB,qBAAqBW,OAAO,GAAG;YACjC,GAAG;QACL;IACF,GAAG;QACDhB;QACAU;QACAC;QACAJ;QACAL;QACAM;QACAL;QACAJ;QACAK;QACAC;KACD;IAED,MAAMoB,QAAsC;QAC1CC,4BAA4BnB,iBAAiBP;QAE7C2B,YAAY;YACVC,MAAM;QACR;QAEAA,MAAM1C,KAAK2C,MAAM,CACf7C,yBAAyB,UAAU;YACjCU,KAAKN,cAAcS,SAASH;YAC5B,GAAGD,KAAK;QACV,IACA;YACEqC,cAAc;gBACZnC,UAAUc;YACZ;YACAsB,aAAa;QACf;IAEJ;IAEAN,MAAMG,IAAI,CAAChB,SAAS,GAAG3B,eAAe2B,WAAWnB,MAAMmB,SAAS;IAEhE,OAAOa;AACT,EAAE"}
1
+ {"version":3,"sources":["useReferenceOverflowButton.ts"],"sourcesContent":["import * as React from 'react';\nimport { Enter, Space } from '@fluentui/keyboard-keys';\nimport {\n getIntrinsicElementProps,\n mergeCallbacks,\n slot,\n useFocusFinders,\n useId,\n useMergedRefs,\n useOverflowMenu,\n} from '@fluentui/react-components';\nimport { useTimeout } from '@fluentui/react-utilities';\nimport { useReferenceListContext_unstable } from '../../../contexts/reference-v2/referenceListContext';\nimport type { ReferenceOverflowButtonProps, ReferenceOverflowButtonState } from './ReferenceOverflowButton.types';\n\n/**\n * Create the state required to render ReferenceOverflowButton.\n *\n * The returned state can be modified with hooks such as useReferenceOverflowButtonStyles_unstable,\n * before being passed to renderReferenceOverflowButton_unstable.\n *\n * @param props - props from this instance of ReferenceOverflowButton\n * @param ref - reference to root HTMLElement of ReferenceOverflowButton\n */\nexport const useReferenceOverflowButton_unstable = (\n props: ReferenceOverflowButtonProps,\n ref: React.Ref<HTMLButtonElement>,\n): ReferenceOverflowButtonState => {\n 'use no memo';\n\n const { children, id, text } = props;\n\n const rootRef = React.useRef<HTMLButtonElement>(null);\n\n const [setTimeout] = useTimeout();\n\n const referenceOverflowButtonId = useId('reference-overflow-button-', id);\n\n const areReferencesExpanded = useReferenceListContext_unstable(ctx => ctx.areReferencesExpanded);\n const maxVisibleReferences = useReferenceListContext_unstable(ctx => ctx.maxVisibleReferences);\n const referenceListRef = useReferenceListContext_unstable(ctx => ctx.referenceListRef);\n const totalReferencesCount = useReferenceListContext_unstable(ctx => ctx.totalReferencesCount);\n const triggeredViaKeyboard = useReferenceListContext_unstable(ctx => ctx.overflowButtonTriggeredViaKeyboard);\n\n const { isOverflowing, overflowCount } = useOverflowMenu();\n\n const processedText = children ?? (typeof text === 'function' ? text(overflowCount) : text);\n\n const { findFirstFocusable, findNextFocusable } = useFocusFinders();\n const onKeyDown = React.useCallback<React.KeyboardEventHandler<HTMLButtonElement>>(\n ev => {\n if (ev.key === Enter || ev.key === Space) {\n triggeredViaKeyboard.current = true;\n }\n },\n [triggeredViaKeyboard],\n );\n\n // We keep track of the previous overflow count to help determine the element to move focus to when expanding the references via keyboard.\n const previousOverflow = React.useRef(0);\n\n // When the references are expanded or collapsed via keyboard, we need to move focus to the appropriate element.\n React.useEffect(() => {\n // We only try to move focus if maxVisibleReferences is set and the overflow button was triggered via keyboard.\n if (maxVisibleReferences !== undefined && triggeredViaKeyboard.current) {\n let elementToFocus: HTMLElement | null | undefined;\n\n // If the references are collapsed, we move focus to the overflow button.\n if (!areReferencesExpanded) {\n elementToFocus = rootRef.current;\n previousOverflow.current = overflowCount;\n }\n // If the references are expanded, we move focus to the first reference that was hidden when they were collapsed.\n // We do this by moving focus according to the following heuristics:\n // - If maxVisibleReferences is what determines what overflows, focus is moved to the element that is in the maxVisibleReferences position of the ReferenceList's children.\n // - If the space available is what is determines what overflows, focus is moved to the element that is in the (totalReferencesCount - overflowCount) position of the ReferenceList's children.\n else if (rootRef.current && referenceListRef.current) {\n const positionToFocus =\n maxVisibleReferences < totalReferencesCount - previousOverflow.current\n ? maxVisibleReferences\n : totalReferencesCount - previousOverflow.current;\n\n let currentElement: HTMLElement | null | undefined = findFirstFocusable(referenceListRef.current);\n for (let i = 0; i < positionToFocus && currentElement; i++) {\n currentElement = findNextFocusable(currentElement);\n }\n\n elementToFocus = currentElement;\n }\n\n // We focus on the element and reset the triggeredViaKeyboard flag after a timeout to ensure that this is pushed at the end of the event queue.\n setTimeout(() => {\n elementToFocus?.focus();\n triggeredViaKeyboard.current = false;\n }, 0);\n }\n }, [\n areReferencesExpanded,\n findFirstFocusable,\n findNextFocusable,\n isOverflowing,\n maxVisibleReferences,\n overflowCount,\n referenceListRef,\n setTimeout,\n totalReferencesCount,\n triggeredViaKeyboard,\n ]);\n\n const state: ReferenceOverflowButtonState = {\n id: referenceOverflowButtonId,\n shouldRenderOverflowButton: isOverflowing || areReferencesExpanded,\n\n components: {\n root: 'button',\n },\n\n root: slot.always(\n getIntrinsicElementProps('button', {\n ref: useMergedRefs(rootRef, ref),\n ...props,\n }),\n {\n defaultProps: {\n children: processedText,\n },\n elementType: 'button',\n },\n ),\n };\n\n state.root.onKeyDown = mergeCallbacks(onKeyDown, props.onKeyDown);\n\n return state;\n};\n"],"names":["React","Enter","Space","getIntrinsicElementProps","mergeCallbacks","slot","useFocusFinders","useId","useMergedRefs","useOverflowMenu","useTimeout","useReferenceListContext_unstable","useReferenceOverflowButton_unstable","props","ref","children","id","text","rootRef","useRef","setTimeout","referenceOverflowButtonId","areReferencesExpanded","ctx","maxVisibleReferences","referenceListRef","totalReferencesCount","triggeredViaKeyboard","overflowButtonTriggeredViaKeyboard","isOverflowing","overflowCount","processedText","findFirstFocusable","findNextFocusable","onKeyDown","useCallback","ev","key","current","previousOverflow","useEffect","undefined","elementToFocus","positionToFocus","currentElement","i","focus","state","shouldRenderOverflowButton","components","root","always","defaultProps","elementType"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,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gH;IAChHnB,MAAMwC,SAAS,CAAC;QACd,+GAA+G;QAC/G,IAAIhB,yBAAyBiB,aAAad,qBAAqBW,OAAO,EAAE;YACtE,IAAII;YAEJ,yEAAyE;YACzE,IAAI,CAACpB,uBAAuB;gBAC1BoB,iBAAiBxB,QAAQoB,OAAO;gBAChCC,iBAAiBD,OAAO,GAAGR;YAC7B,OAKK,IAAIZ,QAAQoB,OAAO,IAAIb,iBAAiBa,OAAO,EAAE;gBACpD,MAAMK,kBACJnB,uBAAuBE,uBAAuBa,iBAAiBD,OAAO,GAClEd,uBACAE,uBAAuBa,iBAAiBD,OAAO;gBAErD,IAAIM,iBAAiDZ,mBAAmBP,iBAAiBa,OAAO;gBAChG,IAAK,IAAIO,IAAI,GAAGA,IAAIF,mBAAmBC,gBAAgBC,IAAK;oBAC1DD,iBAAiBX,kBAAkBW;gBACrC;gBAEAF,iBAAiBE;YACnB;YAEA,+IAA+I;YAC/IxB,WAAW;gBACTsB,2BAAAA,qCAAAA,eAAgBI,KAAK;gBACrBnB,qBAAqBW,OAAO,GAAG;YACjC,GAAG;QACL;IACF,GAAG;QACDhB;QACAU;QACAC;QACAJ;QACAL;QACAM;QACAL;QACAL;QACAM;QACAC;KACD;IAED,MAAMoB,QAAsC;QAC1C/B,IAAIK;QACJ2B,4BAA4BnB,iBAAiBP;QAE7C2B,YAAY;YACVC,MAAM;QACR;QAEAA,MAAM7C,KAAK8C,MAAM,CACfhD,yBAAyB,UAAU;YACjCW,KAAKN,cAAcU,SAASJ;YAC5B,GAAGD,KAAK;QACV,IACA;YACEuC,cAAc;gBACZrC,UAAUgB;YACZ;YACAsB,aAAa;QACf;IAEJ;IAEAN,MAAMG,IAAI,CAAChB,SAAS,GAAG9B,eAAe8B,WAAWrB,MAAMqB,SAAS;IAEhE,OAAOa;AACT,EAAE"}
@@ -40,11 +40,13 @@ const useReferenceList_unstable = (props, ref)=>{
40
40
  setAreReferencesExpanded(false);
41
41
  }, []);
42
42
  const shouldUseOverflow = (minVisibleReferences === undefined || minVisibleReferences < totalReferencesCount) && maxVisibleReferences !== undefined && !areReferencesExpanded;
43
+ // Since the overflow button is an OverflowItem that's always visible, we need to account for it.
44
+ const minVisibleOverflowItems = minVisibleReferences ? minVisibleReferences + 1 : 1;
43
45
  const state = {
44
46
  areReferencesExpanded,
45
47
  overflowButtonTriggeredViaKeyboard,
46
48
  maxVisibleReferences,
47
- minVisibleReferences,
49
+ minVisibleReferences: minVisibleOverflowItems,
48
50
  referenceListRef,
49
51
  shouldUseOverflow,
50
52
  totalReferencesCount,
@@ -1 +1 @@
1
- {"version":3,"sources":["useReferenceList.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n getIntrinsicElementProps,\n mergeCallbacks,\n slot,\n useArrowNavigationGroup,\n useMergedRefs,\n} from '@fluentui/react-components';\nimport { useOverflowMaxVisibleItems } from '@fluentui-copilot/react-utilities';\nimport { useRootStyles } from '../Reference/useReferenceStyles.styles';\nimport type { ReferenceListProps, ReferenceListState } from './ReferenceList.types';\n\n/**\n * Create the state required to render ReferenceList.\n *\n * The returned state can be modified with hooks such as useReferenceListStyles_unstable,\n * before being passed to renderReferenceList_unstable.\n *\n * @param props - props from this instance of ReferenceList\n * @param ref - reference to root HTMLElement of ReferenceList\n */\nexport const useReferenceList_unstable = (\n props: ReferenceListProps,\n ref: React.Ref<HTMLDivElement>,\n): ReferenceListState => {\n const {\n arrowableRegion,\n children,\n maxVisibleReferences,\n minVisibleReferences,\n showLessButton,\n showMoreButton,\n ...rest\n } = props;\n\n const [areReferencesExpanded, setAreReferencesExpanded] = React.useState(false);\n const referenceListRef = React.useRef<HTMLDivElement>(null);\n\n const totalReferencesCount = React.Children.count(children);\n const styles = useRootStyles();\n const resolvedChildren = useOverflowMaxVisibleItems({\n additionalCondition: !areReferencesExpanded,\n children,\n maxVisibleItems: maxVisibleReferences,\n minVisibleItems: minVisibleReferences,\n overflowClassName: styles.overflow,\n });\n\n // We keep track of whether we are interacting with the overflow button via keyboard or not.\n const overflowButtonTriggeredViaKeyboard = React.useRef(false);\n\n const focusAttributes = useArrowNavigationGroup({\n axis: 'both',\n circular: true,\n memorizeCurrent: true,\n });\n\n const onShowMoreButtonClick = React.useCallback<React.MouseEventHandler<HTMLButtonElement>>(() => {\n setAreReferencesExpanded(true);\n }, []);\n\n const onShowLessButtonClick = React.useCallback<React.MouseEventHandler<HTMLButtonElement>>(() => {\n setAreReferencesExpanded(false);\n }, []);\n\n const shouldUseOverflow =\n (minVisibleReferences === undefined || minVisibleReferences < totalReferencesCount) &&\n maxVisibleReferences !== undefined &&\n !areReferencesExpanded;\n\n const state: ReferenceListState = {\n areReferencesExpanded,\n overflowButtonTriggeredViaKeyboard,\n maxVisibleReferences,\n minVisibleReferences,\n referenceListRef,\n shouldUseOverflow,\n totalReferencesCount,\n\n components: {\n root: 'div',\n arrowableRegion: 'div',\n showMoreButton: 'span',\n showLessButton: 'span',\n },\n root: slot.always(\n getIntrinsicElementProps('div', {\n ref: useMergedRefs(ref, referenceListRef),\n ...rest,\n }),\n { elementType: 'div' },\n ),\n arrowableRegion: slot.always(arrowableRegion, {\n defaultProps: { ...focusAttributes, children: resolvedChildren },\n elementType: 'div',\n }),\n showMoreButton: shouldUseOverflow ? slot.optional(showMoreButton, { elementType: 'span' }) : undefined,\n showLessButton: areReferencesExpanded ? slot.optional(showLessButton, { elementType: 'span' }) : undefined,\n };\n\n if (state.showMoreButton) {\n state.showMoreButton.onClick = mergeCallbacks(onShowMoreButtonClick, state.showMoreButton.onClick);\n }\n\n if (state.showLessButton) {\n state.showLessButton.onClick = mergeCallbacks(onShowLessButtonClick, state.showLessButton.onClick);\n }\n\n return state;\n};\n"],"names":["arrowableRegion","maxVisibleReferences","referenceListRef","children","totalReferencesCount","useRootStyles","minVisibleReferences","resolvedChildren","additionalCondition","overflowClassName","styles","React","useState","useRef","Children","count","overflowButtonTriggeredViaKeyboard","focusAttributes","areReferencesExpanded","memorizeCurrent","minVisibleItems","onShowMoreButtonClick","useCallback","setAreReferencesExpanded","axis","circular","shouldUseOverflow","components","undefined","root","elementType","defaultProps","ref","showMoreButton","showLessButton","slot","optional","state"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BA0BIA;;;eAAAA;;;;iEA1BmB;iCAOhB;gCACoC;0CACb;AAgB5B,MACEA,4BAEAC,CAAAA,OAAAA;UAOF,EACAD,eAAME,EAENC,QAAMC,EACNH,oBAAeI,EACfC,oBAAMC,gBACJC,gBACAL;UAGAM,CAAAA,uBAAmBC,yBAAe,GAAAC,OAAAC,QAAA,CAAA;UACpCV,mBAAAS,OAAAE,MAAA,CAAA;UAEAT,uBAAAO,OAAAG,QAAA,CAAAC,KAAA,CAAAZ;UACAO,SAAMM,IAAAA,uCAAAA;UAENT,mBAAMU,IAAAA,0CAA0C,EAAA;6BACxC,CAAAC;;yBAENC;QACFC,iBAAAd;QAEAG,mBAAMY,OAAAA,QAAwBV;;gGAEzB;UAELK,qCAAoCM,OAAWT,MAA6C,CAAA;UAC1FU,kBAAAA,IAAAA,wCAAyB,EAAA;QAC3BC,MAAK;QAELC,UAAMC;QAKNP,iBAAkC;;UAEhCH,wBAAAA,OAAAA,WAAAA,CAAAA;iCACAf;;UAEAC,wBAAAA,OAAAA,WAAAA,CAAAA;iCACAwB;;UAGAC,oBAAY,AAAArB,CAAAA,yBAAAsB,aAAAtB,uBAAAF,oBAAA,KAAAH,yBAAA2B,aAAA,CAAAV;kBACVW;;;;;;;;oBAUA;kBAAEC;6BAAmB;4BAEvB9B;4BACE+B;;0CAAoC5B,CAAAA,IAAAA,yCAAUI,EAAAA,OAAAA;mDAAiB,EAAAyB,KAAA9B;mBAC/D4B;YACF;yBACAG;;yBAA6FL,qBAAAA,CAAAA,MAAAA,CAAAA,iBAAAA;0BAC7FM;kCAAqF;gBAAO/B,UAAKyB;YACnG;YAEAE,aAAUG;;QAEVA,gBAAAP,oBAAAS,qBAAA,CAAAC,QAAA,CAAAH,gBAAA;YAEAH,aAAUI;aACRG;QACFH,gBAAAhB,wBAAAiB,qBAAA,CAAAC,QAAA,CAAAF,gBAAA;YAEAJ,aAAOO;QACP,KAAAT"}
1
+ {"version":3,"sources":["useReferenceList.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n getIntrinsicElementProps,\n mergeCallbacks,\n slot,\n useArrowNavigationGroup,\n useMergedRefs,\n} from '@fluentui/react-components';\nimport { useOverflowMaxVisibleItems } from '@fluentui-copilot/react-utilities';\nimport { useRootStyles } from '../Reference/useReferenceStyles.styles';\nimport type { ReferenceListProps, ReferenceListState } from './ReferenceList.types';\n\n/**\n * Create the state required to render ReferenceList.\n *\n * The returned state can be modified with hooks such as useReferenceListStyles_unstable,\n * before being passed to renderReferenceList_unstable.\n *\n * @param props - props from this instance of ReferenceList\n * @param ref - reference to root HTMLElement of ReferenceList\n */\nexport const useReferenceList_unstable = (\n props: ReferenceListProps,\n ref: React.Ref<HTMLDivElement>,\n): ReferenceListState => {\n const {\n arrowableRegion,\n children,\n maxVisibleReferences,\n minVisibleReferences,\n showLessButton,\n showMoreButton,\n ...rest\n } = props;\n\n const [areReferencesExpanded, setAreReferencesExpanded] = React.useState(false);\n const referenceListRef = React.useRef<HTMLDivElement>(null);\n\n const totalReferencesCount = React.Children.count(children);\n const styles = useRootStyles();\n const resolvedChildren = useOverflowMaxVisibleItems({\n additionalCondition: !areReferencesExpanded,\n children,\n maxVisibleItems: maxVisibleReferences,\n minVisibleItems: minVisibleReferences,\n overflowClassName: styles.overflow,\n });\n\n // We keep track of whether we are interacting with the overflow button via keyboard or not.\n const overflowButtonTriggeredViaKeyboard = React.useRef(false);\n\n const focusAttributes = useArrowNavigationGroup({\n axis: 'both',\n circular: true,\n memorizeCurrent: true,\n });\n\n const onShowMoreButtonClick = React.useCallback<React.MouseEventHandler<HTMLButtonElement>>(() => {\n setAreReferencesExpanded(true);\n }, []);\n\n const onShowLessButtonClick = React.useCallback<React.MouseEventHandler<HTMLButtonElement>>(() => {\n setAreReferencesExpanded(false);\n }, []);\n\n const shouldUseOverflow =\n (minVisibleReferences === undefined || minVisibleReferences < totalReferencesCount) &&\n maxVisibleReferences !== undefined &&\n !areReferencesExpanded;\n\n // Since the overflow button is an OverflowItem that's always visible, we need to account for it.\n const minVisibleOverflowItems = minVisibleReferences ? minVisibleReferences + 1 : 1;\n\n const state: ReferenceListState = {\n areReferencesExpanded,\n overflowButtonTriggeredViaKeyboard,\n maxVisibleReferences,\n minVisibleReferences: minVisibleOverflowItems,\n referenceListRef,\n shouldUseOverflow,\n totalReferencesCount,\n\n components: {\n root: 'div',\n arrowableRegion: 'div',\n showMoreButton: 'span',\n showLessButton: 'span',\n },\n root: slot.always(\n getIntrinsicElementProps('div', {\n ref: useMergedRefs(ref, referenceListRef),\n ...rest,\n }),\n { elementType: 'div' },\n ),\n arrowableRegion: slot.always(arrowableRegion, {\n defaultProps: { ...focusAttributes, children: resolvedChildren },\n elementType: 'div',\n }),\n showMoreButton: shouldUseOverflow ? slot.optional(showMoreButton, { elementType: 'span' }) : undefined,\n showLessButton: areReferencesExpanded ? slot.optional(showLessButton, { elementType: 'span' }) : undefined,\n };\n\n if (state.showMoreButton) {\n state.showMoreButton.onClick = mergeCallbacks(onShowMoreButtonClick, state.showMoreButton.onClick);\n }\n\n if (state.showLessButton) {\n state.showLessButton.onClick = mergeCallbacks(onShowLessButtonClick, state.showLessButton.onClick);\n }\n\n return state;\n};\n"],"names":["arrowableRegion","maxVisibleReferences","referenceListRef","children","totalReferencesCount","useRootStyles","minVisibleReferences","resolvedChildren","additionalCondition","overflowClassName","styles","React","useState","useRef","Children","count","overflowButtonTriggeredViaKeyboard","focusAttributes","areReferencesExpanded","memorizeCurrent","minVisibleItems","onShowMoreButtonClick","useCallback","setAreReferencesExpanded","axis","circular","shouldUseOverflow","components","root","minVisibleOverflowItems","elementType","defaultProps","ref","showMoreButton","undefined","showLessButton","slot","optional","state"],"rangeMappings":";;;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EAH,aAAUK;aACRG;QACFH,gBAAAjB,wBAAAkB,qBAAA,CAAAC,QAAA,CAAAF,gBAAA;YAEAL,aAAOQ;QACP,KAAAJ"}
@@ -1 +1 @@
1
- {"version":3,"sources":["ReferenceOverflowButton.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-components';\n\nexport type ReferenceOverflowButtonSlots = {\n /** The root of the component that renders the overflow button. */\n root: Slot<'button'>;\n};\n\n/**\n * ReferenceOverflowButton Props\n */\nexport type ReferenceOverflowButtonProps = ComponentProps<ReferenceOverflowButtonSlots> & {\n /**\n * The text that is displayed inside of the overflow button. This text is only displayed when `children` has not been passed to the component.\n * If a string is passed, that is what is rendered verbatim.\n * If a callback is passed, the callback is called with the number of items that are overflowing, and the result of the callback is rendered.\n */\n text?: string | ((overflowCount: number) => React.ReactNode);\n};\n\n/**\n * State used in rendering ReferenceOverflowButton\n */\nexport type ReferenceOverflowButtonState = ComponentState<ReferenceOverflowButtonSlots> & {\n shouldRenderOverflowButton: boolean;\n};\n"],"names":[],"rangeMappings":";;","mappings":"AAmBA;;CAEC"}
1
+ {"version":3,"sources":["ReferenceOverflowButton.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-components';\n\nexport type ReferenceOverflowButtonSlots = {\n /** The root of the component that renders the overflow button. */\n root: Slot<'button'>;\n};\n\n/**\n * ReferenceOverflowButton Props\n */\nexport type ReferenceOverflowButtonProps = ComponentProps<ReferenceOverflowButtonSlots> & {\n /**\n * The text that is displayed inside of the overflow button. This text is only displayed when `children` has not been passed to the component.\n * If a string is passed, that is what is rendered verbatim.\n * If a callback is passed, the callback is called with the number of items that are overflowing, and the result of the callback is rendered.\n */\n text?: string | ((overflowCount: number) => React.ReactNode);\n};\n\n/**\n * State used in rendering ReferenceOverflowButton\n */\nexport type ReferenceOverflowButtonState = ComponentState<ReferenceOverflowButtonSlots> & {\n id: string;\n shouldRenderOverflowButton: boolean;\n};\n"],"names":[],"rangeMappings":";;","mappings":"AAmBA;;CAEC"}
@@ -12,5 +12,10 @@ const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
12
12
  const _reactcomponents = require("@fluentui/react-components");
13
13
  const renderReferenceOverflowButton_unstable = (state)=>{
14
14
  (0, _reactcomponents.assertSlots)(state);
15
- return state.shouldRenderOverflowButton ? /*#__PURE__*/ (0, _jsxruntime.jsx)(state.root, {}) : null;
15
+ const { id, shouldRenderOverflowButton } = state;
16
+ return shouldRenderOverflowButton ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactcomponents.OverflowItem, {
17
+ id: id,
18
+ priority: 1,
19
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.root, {})
20
+ }, id) : null;
16
21
  }; //# sourceMappingURL=renderReferenceOverflowButton.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["renderReferenceOverflowButton.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-components';\nimport type { ReferenceOverflowButtonState, ReferenceOverflowButtonSlots } from './ReferenceOverflowButton.types';\n\n/**\n * Render the final JSX of ReferenceOverflowButton\n */\nexport const renderReferenceOverflowButton_unstable = (state: ReferenceOverflowButtonState) => {\n assertSlots<ReferenceOverflowButtonSlots>(state);\n\n return state.shouldRenderOverflowButton ? <state.root /> : null;\n};\n"],"names":["assertSlots","state","shouldRenderOverflowButton","_jsx","root"],"rangeMappings":";;;;;;;;;;;;;;","mappings":";;;;+BAUEA;;;eAAAA;;;4BAVwB;iCAGE;AAO1BA,MAAAA,yCAA0CC,CAAAA;oCAEnCA,EAAAA;IACP,OAAAA,MAAAC,0BAAA,GAAA,WAAA,GAAAC,IAAAA,eAAA,EAAAF,MAAAG,IAAA,EAAA,CAAA,KAAA"}
1
+ {"version":3,"sources":["renderReferenceOverflowButton.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { OverflowItem, assertSlots } from '@fluentui/react-components';\nimport type { ReferenceOverflowButtonState, ReferenceOverflowButtonSlots } from './ReferenceOverflowButton.types';\n\n/**\n * Render the final JSX of ReferenceOverflowButton\n */\nexport const renderReferenceOverflowButton_unstable = (state: ReferenceOverflowButtonState) => {\n assertSlots<ReferenceOverflowButtonSlots>(state);\n const { id, shouldRenderOverflowButton } = state;\n\n return shouldRenderOverflowButton ? (\n <OverflowItem key={id} id={id} priority={1}>\n <state.root />\n </OverflowItem>\n ) : null;\n};\n"],"names":["assertSlots","state","id","_jsx","OverflowItem"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":";;;;+BAUEA;;;eAAAA;;;4BAVwB;iCAGgB;AAOxCA,MAAAA,yCAA0CC,CAAAA;oCAClCC,EAAED;UAEV,gCAC2C;WAAtBC,6BAGjB,WAAA,GAAAC,IAAAA,eAAA,EAAAC,6BAAA,EAAA;QACJF,IAAAA"}
@@ -16,9 +16,10 @@ const _reactutilities = require("@fluentui/react-utilities");
16
16
  const _referenceListContext = require("../../../contexts/reference-v2/referenceListContext");
17
17
  const useReferenceOverflowButton_unstable = (props, ref)=>{
18
18
  'use no memo';
19
- const { children, text } = props;
19
+ const { children, id, text } = props;
20
20
  const rootRef = _react.useRef(null);
21
21
  const [setTimeout] = (0, _reactutilities.useTimeout)();
22
+ const referenceOverflowButtonId = (0, _reactcomponents.useId)('reference-overflow-button-', id);
22
23
  const areReferencesExpanded = (0, _referenceListContext.useReferenceListContext_unstable)((ctx)=>ctx.areReferencesExpanded);
23
24
  const maxVisibleReferences = (0, _referenceListContext.useReferenceListContext_unstable)((ctx)=>ctx.maxVisibleReferences);
24
25
  const referenceListRef = (0, _referenceListContext.useReferenceListContext_unstable)((ctx)=>ctx.referenceListRef);
@@ -72,6 +73,7 @@ const useReferenceOverflowButton_unstable = (props, ref)=>{
72
73
  triggeredViaKeyboard
73
74
  ]);
74
75
  const state = {
76
+ id: referenceOverflowButtonId,
75
77
  shouldRenderOverflowButton: isOverflowing || areReferencesExpanded,
76
78
  components: {
77
79
  root: 'button'
@@ -1 +1 @@
1
- {"version":3,"sources":["useReferenceOverflowButton.ts"],"sourcesContent":["import * as React from 'react';\nimport { Enter, Space } from '@fluentui/keyboard-keys';\nimport {\n getIntrinsicElementProps,\n mergeCallbacks,\n slot,\n useFocusFinders,\n useMergedRefs,\n useOverflowMenu,\n} from '@fluentui/react-components';\nimport { useTimeout } from '@fluentui/react-utilities';\nimport { useReferenceListContext_unstable } from '../../../contexts/reference-v2/referenceListContext';\nimport type { ReferenceOverflowButtonProps, ReferenceOverflowButtonState } from './ReferenceOverflowButton.types';\n\n/**\n * Create the state required to render ReferenceOverflowButton.\n *\n * The returned state can be modified with hooks such as useReferenceOverflowButtonStyles_unstable,\n * before being passed to renderReferenceOverflowButton_unstable.\n *\n * @param props - props from this instance of ReferenceOverflowButton\n * @param ref - reference to root HTMLElement of ReferenceOverflowButton\n */\nexport const useReferenceOverflowButton_unstable = (\n props: ReferenceOverflowButtonProps,\n ref: React.Ref<HTMLButtonElement>,\n): ReferenceOverflowButtonState => {\n 'use no memo';\n\n const { children, text } = props;\n\n const rootRef = React.useRef<HTMLButtonElement>(null);\n\n const [setTimeout] = useTimeout();\n\n const areReferencesExpanded = useReferenceListContext_unstable(ctx => ctx.areReferencesExpanded);\n const maxVisibleReferences = useReferenceListContext_unstable(ctx => ctx.maxVisibleReferences);\n const referenceListRef = useReferenceListContext_unstable(ctx => ctx.referenceListRef);\n const totalReferencesCount = useReferenceListContext_unstable(ctx => ctx.totalReferencesCount);\n const triggeredViaKeyboard = useReferenceListContext_unstable(ctx => ctx.overflowButtonTriggeredViaKeyboard);\n\n const { isOverflowing, overflowCount } = useOverflowMenu();\n\n const processedText = children ?? (typeof text === 'function' ? text(overflowCount) : text);\n\n const { findFirstFocusable, findNextFocusable } = useFocusFinders();\n const onKeyDown = React.useCallback<React.KeyboardEventHandler<HTMLButtonElement>>(\n ev => {\n if (ev.key === Enter || ev.key === Space) {\n triggeredViaKeyboard.current = true;\n }\n },\n [triggeredViaKeyboard],\n );\n\n // We keep track of the previous overflow count to help determine the element to move focus to when expanding the references via keyboard.\n const previousOverflow = React.useRef(0);\n\n // When the references are expanded or collapsed via keyboard, we need to move focus to the appropriate element.\n React.useEffect(() => {\n // We only try to move focus if maxVisibleReferences is set and the overflow button was triggered via keyboard.\n if (maxVisibleReferences !== undefined && triggeredViaKeyboard.current) {\n let elementToFocus: HTMLElement | null | undefined;\n\n // If the references are collapsed, we move focus to the overflow button.\n if (!areReferencesExpanded) {\n elementToFocus = rootRef.current;\n previousOverflow.current = overflowCount;\n }\n // If the references are expanded, we move focus to the first reference that was hidden when they were collapsed.\n // We do this by moving focus according to the following heuristics:\n // - If maxVisibleReferences is what determines what overflows, focus is moved to the element that is in the maxVisibleReferences position of the ReferenceList's children.\n // - If the space available is what is determines what overflows, focus is moved to the element that is in the (totalReferencesCount - overflowCount) position of the ReferenceList's children.\n else if (rootRef.current && referenceListRef.current) {\n const positionToFocus =\n maxVisibleReferences < totalReferencesCount - previousOverflow.current\n ? maxVisibleReferences\n : totalReferencesCount - previousOverflow.current;\n\n let currentElement: HTMLElement | null | undefined = findFirstFocusable(referenceListRef.current);\n for (let i = 0; i < positionToFocus && currentElement; i++) {\n currentElement = findNextFocusable(currentElement);\n }\n\n elementToFocus = currentElement;\n }\n\n // We focus on the element and reset the triggeredViaKeyboard flag after a timeout to ensure that this is pushed at the end of the event queue.\n setTimeout(() => {\n elementToFocus?.focus();\n triggeredViaKeyboard.current = false;\n }, 0);\n }\n }, [\n areReferencesExpanded,\n findFirstFocusable,\n findNextFocusable,\n isOverflowing,\n maxVisibleReferences,\n overflowCount,\n referenceListRef,\n setTimeout,\n totalReferencesCount,\n triggeredViaKeyboard,\n ]);\n\n const state: ReferenceOverflowButtonState = {\n shouldRenderOverflowButton: isOverflowing || areReferencesExpanded,\n\n components: {\n root: 'button',\n },\n\n root: slot.always(\n getIntrinsicElementProps('button', {\n ref: useMergedRefs(rootRef, ref),\n ...props,\n }),\n {\n defaultProps: {\n children: processedText,\n },\n elementType: 'button',\n },\n ),\n };\n\n state.root.onKeyDown = mergeCallbacks(onKeyDown, props.onKeyDown);\n\n return state;\n};\n"],"names":["useReferenceOverflowButton_unstable","props","ref","children","areReferencesExpanded","text","rootRef","totalReferencesCount","setTimeout","triggeredViaKeyboard","useReferenceListContext_unstable","overflowCount","useOverflowMenu","maxVisibleReferences","referenceListRef","findFirstFocusable","useFocusFinders","useCallback","ev","Enter","ctx","overflowButtonTriggeredViaKeyboard","processedText","previousOverflow","findNextFocusable","React","onKeyDown","key","undefined","elementToFocus","current","i","positionToFocus","currentElement","focus","isOverflowing","components","state","shouldRenderOverflowButton","root","getIntrinsicElementProps","useMergedRefs","slot","mergeCallbacks"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BA2BEA;;;eAAAA;;;;iEA3BqB;8BACM;iCAQtB;gCACoB;sCACsB;AAgB/C,MAAAA,sCAAA,CAAAC,OAAAC;;UAMA,EAEAC,QAAMC,EACNC,IAAA,KACAJ;UACAK,UAAMC,OAAAA,MAAAA,CAAAA;UACN,CAAAC,WAAMC,GAAAA,IAAAA,0BAAuBC;UAE7BN,wBAAuBO,IAAAA,sDAAkBC,EAAAA,CAAAA,MAAAA,IAAAA,qBAAAA;UAEzCC,uBAAsBV,IAAAA,sDAAAA,EAAAA,CAAAA,MAAAA,IAAAA,oBAAoBE;UAE1CS,mBAAQC,IAAAA,sDAA0CC,EAAAA,CAAAA,MAAAA,IAAAA,gBAAAA;UAClDT,uBAAwBU,IAAAA,sDACtBC,EAAAA,CAAAA,MAAAA,IAAAA,oBAAAA;UACET,uBAAeU,IAAAA,sDAA2B,EAAAC,CAAAA,MAAAA,IAAAC,kCAAA;yBAE1C,EACFV,aACA,yCAACF;UAAqBa,gBAAAnB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AEJW;yDAIOA"}
1
+ {"version":3,"sources":["useReferenceOverflowButton.ts"],"sourcesContent":["import * as React from 'react';\nimport { Enter, Space } from '@fluentui/keyboard-keys';\nimport {\n getIntrinsicElementProps,\n mergeCallbacks,\n slot,\n useFocusFinders,\n useId,\n useMergedRefs,\n useOverflowMenu,\n} from '@fluentui/react-components';\nimport { useTimeout } from '@fluentui/react-utilities';\nimport { useReferenceListContext_unstable } from '../../../contexts/reference-v2/referenceListContext';\nimport type { ReferenceOverflowButtonProps, ReferenceOverflowButtonState } from './ReferenceOverflowButton.types';\n\n/**\n * Create the state required to render ReferenceOverflowButton.\n *\n * The returned state can be modified with hooks such as useReferenceOverflowButtonStyles_unstable,\n * before being passed to renderReferenceOverflowButton_unstable.\n *\n * @param props - props from this instance of ReferenceOverflowButton\n * @param ref - reference to root HTMLElement of ReferenceOverflowButton\n */\nexport const useReferenceOverflowButton_unstable = (\n props: ReferenceOverflowButtonProps,\n ref: React.Ref<HTMLButtonElement>,\n): ReferenceOverflowButtonState => {\n 'use no memo';\n\n const { children, id, text } = props;\n\n const rootRef = React.useRef<HTMLButtonElement>(null);\n\n const [setTimeout] = useTimeout();\n\n const referenceOverflowButtonId = useId('reference-overflow-button-', id);\n\n const areReferencesExpanded = useReferenceListContext_unstable(ctx => ctx.areReferencesExpanded);\n const maxVisibleReferences = useReferenceListContext_unstable(ctx => ctx.maxVisibleReferences);\n const referenceListRef = useReferenceListContext_unstable(ctx => ctx.referenceListRef);\n const totalReferencesCount = useReferenceListContext_unstable(ctx => ctx.totalReferencesCount);\n const triggeredViaKeyboard = useReferenceListContext_unstable(ctx => ctx.overflowButtonTriggeredViaKeyboard);\n\n const { isOverflowing, overflowCount } = useOverflowMenu();\n\n const processedText = children ?? (typeof text === 'function' ? text(overflowCount) : text);\n\n const { findFirstFocusable, findNextFocusable } = useFocusFinders();\n const onKeyDown = React.useCallback<React.KeyboardEventHandler<HTMLButtonElement>>(\n ev => {\n if (ev.key === Enter || ev.key === Space) {\n triggeredViaKeyboard.current = true;\n }\n },\n [triggeredViaKeyboard],\n );\n\n // We keep track of the previous overflow count to help determine the element to move focus to when expanding the references via keyboard.\n const previousOverflow = React.useRef(0);\n\n // When the references are expanded or collapsed via keyboard, we need to move focus to the appropriate element.\n React.useEffect(() => {\n // We only try to move focus if maxVisibleReferences is set and the overflow button was triggered via keyboard.\n if (maxVisibleReferences !== undefined && triggeredViaKeyboard.current) {\n let elementToFocus: HTMLElement | null | undefined;\n\n // If the references are collapsed, we move focus to the overflow button.\n if (!areReferencesExpanded) {\n elementToFocus = rootRef.current;\n previousOverflow.current = overflowCount;\n }\n // If the references are expanded, we move focus to the first reference that was hidden when they were collapsed.\n // We do this by moving focus according to the following heuristics:\n // - If maxVisibleReferences is what determines what overflows, focus is moved to the element that is in the maxVisibleReferences position of the ReferenceList's children.\n // - If the space available is what is determines what overflows, focus is moved to the element that is in the (totalReferencesCount - overflowCount) position of the ReferenceList's children.\n else if (rootRef.current && referenceListRef.current) {\n const positionToFocus =\n maxVisibleReferences < totalReferencesCount - previousOverflow.current\n ? maxVisibleReferences\n : totalReferencesCount - previousOverflow.current;\n\n let currentElement: HTMLElement | null | undefined = findFirstFocusable(referenceListRef.current);\n for (let i = 0; i < positionToFocus && currentElement; i++) {\n currentElement = findNextFocusable(currentElement);\n }\n\n elementToFocus = currentElement;\n }\n\n // We focus on the element and reset the triggeredViaKeyboard flag after a timeout to ensure that this is pushed at the end of the event queue.\n setTimeout(() => {\n elementToFocus?.focus();\n triggeredViaKeyboard.current = false;\n }, 0);\n }\n }, [\n areReferencesExpanded,\n findFirstFocusable,\n findNextFocusable,\n isOverflowing,\n maxVisibleReferences,\n overflowCount,\n referenceListRef,\n setTimeout,\n totalReferencesCount,\n triggeredViaKeyboard,\n ]);\n\n const state: ReferenceOverflowButtonState = {\n id: referenceOverflowButtonId,\n shouldRenderOverflowButton: isOverflowing || areReferencesExpanded,\n\n components: {\n root: 'button',\n },\n\n root: slot.always(\n getIntrinsicElementProps('button', {\n ref: useMergedRefs(rootRef, ref),\n ...props,\n }),\n {\n defaultProps: {\n children: processedText,\n },\n elementType: 'button',\n },\n ),\n };\n\n state.root.onKeyDown = mergeCallbacks(onKeyDown, props.onKeyDown);\n\n return state;\n};\n"],"names":["useReferenceOverflowButton_unstable","props","ref","children","referenceOverflowButtonId","id","text","rootRef","totalReferencesCount","setTimeout","triggeredViaKeyboard","useReferenceListContext_unstable","overflowCount","useOverflowMenu","areReferencesExpanded","maxVisibleReferences","useFocusFinders","referenceListRef","React","ev","Enter","ctx","overflowButtonTriggeredViaKeyboard","isOverflowing","processedText","findFirstFocusable","onKeyDown","undefined","elementToFocus","current","currentElement","findNextFocusable","previousOverflow","i","positionToFocus","state","shouldRenderOverflowButton","components","slot","always","getIntrinsicElementProps","root","defaultProps","mergeCallbacks"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BA4BEA;;;eAAAA;;;;iEA5BqB;8BACM;iCAStB;gCACoB;sCACsB;AAgB/C,MAAAA,sCAAA,CAAAC,OAAAC;;UAMA,EAEAC,QAAMC,EAENC,EAAA,EACAC,IAAA,KACAL;UACAM,UAAMC,OAAAA,MAAAA,CAAAA;UACN,CAAAC,WAAMC,GAAAA,IAAAA,0BAAuBC;UAE7BP,4BAAuBQ,IAAAA,sBAAa,EAAE,8BAAGC;UAEzCC,wBAAsBX,IAAAA,sDAAAA,EAAAA,CAAAA,MAAAA,IAAAA,qBAA6B;UAEnDY,uBAA0BJ,IAAAA,sDAAwBK,EAAAA,CAAAA,MAAAA,IAAAA,oBAAAA;UAClDC,mBAAkBC,IAAAA,sDAChBC,EAAAA,CAAAA,MAAAA,IAAAA,gBAAAA;UACEX,uBAAeY,IAAAA,sDAA2B,EAAAC,CAAAA,MAAAA,IAAAb,oBAAA;iCACxCE,IAAAA,sDAA+B,EAAAW,CAAAA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A,GAAAiB,IAAAA,+BAAA,EAAAjB,WAAAzB,MAAAyB,SAAA;WAEAS;GAGF,sDAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui-copilot/react-reference",
3
- "version": "0.13.9",
3
+ "version": "0.13.10",
4
4
  "description": "Fluent AI controls for citations and references",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -13,7 +13,7 @@
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
15
  "@fluentui-copilot/react-preview": "^0.5.8",
16
- "@fluentui-copilot/react-provider": "^0.9.3",
16
+ "@fluentui-copilot/react-provider": "^0.9.4",
17
17
  "@fluentui-copilot/react-sensitivity-label": "^0.5.8",
18
18
  "@fluentui-copilot/react-utilities": "^0.0.5",
19
19
  "@swc/helpers": "^0.5.1"