@fluentui-copilot/react-reference 0.16.1 → 0.16.3

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 (98) hide show
  1. package/CHANGELOG.json +36 -0
  2. package/CHANGELOG.md +20 -1
  3. package/lib/Citation.js +0 -1
  4. package/lib/Reference.js +0 -1
  5. package/lib/ReferenceList.js +0 -1
  6. package/lib/ReferenceOverflowButton.js +0 -1
  7. package/lib/components/Citation/Citation.js +5 -6
  8. package/lib/components/Citation/Citation.types.js +1 -2
  9. package/lib/components/Citation/index.js +0 -1
  10. package/lib/components/Citation/renderCitation.js +4 -6
  11. package/lib/components/Citation/useCitation.js +22 -28
  12. package/lib/components/Citation/useCitationStyles.styles.raw.js +69 -0
  13. package/lib/components/Citation/useCitationStyles.styles.raw.js.map +1 -0
  14. package/lib/components/Reference/Reference.js +4 -5
  15. package/lib/components/Reference/Reference.types.js +1 -2
  16. package/lib/components/Reference/index.js +0 -1
  17. package/lib/components/Reference/renderReference.js +20 -17
  18. package/lib/components/Reference/useReference.js +53 -59
  19. package/lib/components/Reference/useReferenceStyles.styles.raw.js +110 -0
  20. package/lib/components/Reference/useReferenceStyles.styles.raw.js.map +1 -0
  21. package/lib/components/ReferenceList/ReferenceList.js +5 -6
  22. package/lib/components/ReferenceList/ReferenceList.types.js +1 -2
  23. package/lib/components/ReferenceList/index.js +0 -1
  24. package/lib/components/ReferenceList/renderReferenceList.js +17 -17
  25. package/lib/components/ReferenceList/useReferenceList.js +70 -80
  26. package/lib/components/ReferenceList/useReferenceListContextValues.js +13 -21
  27. package/lib/components/ReferenceList/useReferenceListStyles.styles.raw.js +47 -0
  28. package/lib/components/ReferenceList/useReferenceListStyles.styles.raw.js.map +1 -0
  29. package/lib/components/ReferenceOverflowButton/ReferenceOverflowButton.js +4 -5
  30. package/lib/components/ReferenceOverflowButton/ReferenceOverflowButton.types.js +1 -2
  31. package/lib/components/ReferenceOverflowButton/index.js +0 -1
  32. package/lib/components/ReferenceOverflowButton/renderReferenceOverflowButton.js +9 -14
  33. package/lib/components/ReferenceOverflowButton/useReferenceOverflowButton.js +77 -77
  34. package/lib/components/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.raw.js +45 -0
  35. package/lib/components/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.raw.js.map +1 -0
  36. package/lib/contexts/index.js +0 -1
  37. package/lib/contexts/referenceListContext.js +11 -12
  38. package/lib/index.js +12 -25
  39. package/lib/utilities/generateReferenceCitationPreview.js +75 -86
  40. package/lib/utilities/index.js +0 -1
  41. package/lib/utilities/useReferenceCitationPreview.js +5 -5
  42. package/lib-commonjs/Citation.js +0 -1
  43. package/lib-commonjs/Reference.js +0 -1
  44. package/lib-commonjs/ReferenceList.js +0 -1
  45. package/lib-commonjs/ReferenceOverflowButton.js +0 -1
  46. package/lib-commonjs/components/Citation/Citation.js +1 -1
  47. package/lib-commonjs/components/Citation/Citation.js.map +1 -1
  48. package/lib-commonjs/components/Citation/Citation.types.js +0 -1
  49. package/lib-commonjs/components/Citation/index.js +0 -1
  50. package/lib-commonjs/components/Citation/renderCitation.js +1 -1
  51. package/lib-commonjs/components/Citation/renderCitation.js.map +1 -1
  52. package/lib-commonjs/components/Citation/useCitation.js +1 -1
  53. package/lib-commonjs/components/Citation/useCitation.js.map +1 -1
  54. package/lib-commonjs/components/Citation/useCitationStyles.styles.raw.js +85 -0
  55. package/lib-commonjs/components/Citation/useCitationStyles.styles.raw.js.map +1 -0
  56. package/lib-commonjs/components/Reference/Reference.js +1 -1
  57. package/lib-commonjs/components/Reference/Reference.js.map +1 -1
  58. package/lib-commonjs/components/Reference/Reference.types.js +0 -1
  59. package/lib-commonjs/components/Reference/index.js +0 -1
  60. package/lib-commonjs/components/Reference/renderReference.js +1 -1
  61. package/lib-commonjs/components/Reference/renderReference.js.map +1 -1
  62. package/lib-commonjs/components/Reference/useReference.js +1 -1
  63. package/lib-commonjs/components/Reference/useReference.js.map +1 -1
  64. package/lib-commonjs/components/Reference/useReferenceStyles.styles.raw.js +132 -0
  65. package/lib-commonjs/components/Reference/useReferenceStyles.styles.raw.js.map +1 -0
  66. package/lib-commonjs/components/ReferenceList/ReferenceList.js +1 -1
  67. package/lib-commonjs/components/ReferenceList/ReferenceList.js.map +1 -1
  68. package/lib-commonjs/components/ReferenceList/ReferenceList.types.js +0 -1
  69. package/lib-commonjs/components/ReferenceList/index.js +0 -1
  70. package/lib-commonjs/components/ReferenceList/renderReferenceList.js +1 -1
  71. package/lib-commonjs/components/ReferenceList/renderReferenceList.js.map +1 -1
  72. package/lib-commonjs/components/ReferenceList/useReferenceList.js +1 -1
  73. package/lib-commonjs/components/ReferenceList/useReferenceList.js.map +1 -1
  74. package/lib-commonjs/components/ReferenceList/useReferenceListContextValues.js +1 -1
  75. package/lib-commonjs/components/ReferenceList/useReferenceListContextValues.js.map +1 -1
  76. package/lib-commonjs/components/ReferenceList/useReferenceListStyles.styles.raw.js +63 -0
  77. package/lib-commonjs/components/ReferenceList/useReferenceListStyles.styles.raw.js.map +1 -0
  78. package/lib-commonjs/components/ReferenceOverflowButton/ReferenceOverflowButton.js +1 -1
  79. package/lib-commonjs/components/ReferenceOverflowButton/ReferenceOverflowButton.js.map +1 -1
  80. package/lib-commonjs/components/ReferenceOverflowButton/ReferenceOverflowButton.types.js +0 -1
  81. package/lib-commonjs/components/ReferenceOverflowButton/index.js +0 -1
  82. package/lib-commonjs/components/ReferenceOverflowButton/renderReferenceOverflowButton.js +1 -1
  83. package/lib-commonjs/components/ReferenceOverflowButton/renderReferenceOverflowButton.js.map +1 -1
  84. package/lib-commonjs/components/ReferenceOverflowButton/useReferenceOverflowButton.js +1 -1
  85. package/lib-commonjs/components/ReferenceOverflowButton/useReferenceOverflowButton.js.map +1 -1
  86. package/lib-commonjs/components/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.raw.js +61 -0
  87. package/lib-commonjs/components/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.raw.js.map +1 -0
  88. package/lib-commonjs/contexts/index.js +0 -1
  89. package/lib-commonjs/contexts/referenceListContext.js +1 -1
  90. package/lib-commonjs/contexts/referenceListContext.js.map +1 -1
  91. package/lib-commonjs/index.js +0 -1
  92. package/lib-commonjs/index.js.map +1 -1
  93. package/lib-commonjs/utilities/generateReferenceCitationPreview.js +1 -1
  94. package/lib-commonjs/utilities/generateReferenceCitationPreview.js.map +1 -1
  95. package/lib-commonjs/utilities/index.js +0 -1
  96. package/lib-commonjs/utilities/useReferenceCitationPreview.js +1 -1
  97. package/lib-commonjs/utilities/useReferenceCitationPreview.js.map +1 -1
  98. package/package.json +12 -12
@@ -1,22 +1,22 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
2
2
  import { Overflow, assertSlots } from '@fluentui/react-components';
3
3
  import { ReferenceListContextProvider } from '../../contexts/referenceListContext';
4
4
  /**
5
5
  * Render the final JSX of ReferenceList
6
- */
7
- export const renderReferenceList_unstable = (state, contextValues) => {
8
- assertSlots(state);
9
- const {
10
- minVisibleReferences
11
- } = state;
12
- return /*#__PURE__*/_jsx(ReferenceListContextProvider, {
13
- value: contextValues.referenceList,
14
- children: /*#__PURE__*/_jsx(Overflow, {
15
- minimumVisible: minVisibleReferences,
16
- children: /*#__PURE__*/_jsxs(state.root, {
17
- children: [/*#__PURE__*/_jsx(state.arrowableRegion, {}), state.showMoreButton && /*#__PURE__*/_jsx(state.showMoreButton, {}), state.showLessButton && /*#__PURE__*/_jsx(state.showLessButton, {})]
18
- })
19
- })
20
- });
6
+ */ export const renderReferenceList_unstable = (state, contextValues)=>{
7
+ assertSlots(state);
8
+ const { minVisibleReferences } = state;
9
+ return /*#__PURE__*/ _jsx(ReferenceListContextProvider, {
10
+ value: contextValues.referenceList,
11
+ children: /*#__PURE__*/ _jsx(Overflow, {
12
+ minimumVisible: minVisibleReferences,
13
+ children: /*#__PURE__*/ _jsxs(state.root, {
14
+ children: [
15
+ /*#__PURE__*/ _jsx(state.arrowableRegion, {}),
16
+ state.showMoreButton && /*#__PURE__*/ _jsx(state.showMoreButton, {}),
17
+ state.showLessButton && /*#__PURE__*/ _jsx(state.showLessButton, {})
18
+ ]
19
+ })
20
+ })
21
+ });
21
22
  };
22
- //# sourceMappingURL=renderReferenceList.js.map
@@ -10,84 +10,74 @@ import { useRootStyles } from '../Reference/useReferenceStyles.styles';
10
10
  *
11
11
  * @param props - props from this instance of ReferenceList
12
12
  * @param ref - reference to root HTMLElement of ReferenceList
13
- */
14
- export const useReferenceList_unstable = (props, ref) => {
15
- const {
16
- arrowableRegion,
17
- children,
18
- maxVisibleReferences,
19
- minVisibleReferences,
20
- showLessButton,
21
- showMoreButton,
22
- ...rest
23
- } = props;
24
- const [areReferencesExpanded, setAreReferencesExpanded] = React.useState(false);
25
- const referenceListRef = React.useRef(null);
26
- const totalReferencesCount = React.Children.count(children);
27
- const styles = useRootStyles();
28
- const resolvedChildren = useOverflowMaxVisibleItems({
29
- additionalCondition: !areReferencesExpanded,
30
- children,
31
- maxVisibleItems: maxVisibleReferences,
32
- minVisibleItems: minVisibleReferences,
33
- overflowClassName: styles.overflow
34
- });
35
- // We keep track of whether we are interacting with the overflow button via keyboard or not.
36
- const overflowButtonTriggeredViaKeyboard = React.useRef(false);
37
- const focusAttributes = useArrowNavigationGroup({
38
- axis: 'both',
39
- circular: true,
40
- memorizeCurrent: true
41
- });
42
- const onShowMoreButtonClick = React.useCallback(() => {
43
- setAreReferencesExpanded(true);
44
- }, []);
45
- const onShowLessButtonClick = React.useCallback(() => {
46
- setAreReferencesExpanded(false);
47
- }, []);
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;
51
- const state = {
52
- areReferencesExpanded,
53
- overflowButtonTriggeredViaKeyboard,
54
- maxVisibleReferences,
55
- minVisibleReferences: minVisibleOverflowItems,
56
- referenceListRef,
57
- shouldUseOverflow,
58
- totalReferencesCount,
59
- components: {
60
- root: 'div',
61
- arrowableRegion: 'div',
62
- showMoreButton: 'span',
63
- showLessButton: 'span'
64
- },
65
- root: slot.always(getIntrinsicElementProps('div', {
66
- ref: useMergedRefs(ref, referenceListRef),
67
- ...rest
68
- }), {
69
- elementType: 'div'
70
- }),
71
- arrowableRegion: slot.always(arrowableRegion, {
72
- defaultProps: {
73
- ...focusAttributes,
74
- children: resolvedChildren
75
- },
76
- elementType: 'div'
77
- }),
78
- showMoreButton: shouldUseOverflow ? slot.optional(showMoreButton, {
79
- elementType: 'span'
80
- }) : undefined,
81
- showLessButton: areReferencesExpanded ? slot.optional(showLessButton, {
82
- elementType: 'span'
83
- }) : undefined
84
- };
85
- if (state.showMoreButton) {
86
- state.showMoreButton.onClick = mergeCallbacks(onShowMoreButtonClick, state.showMoreButton.onClick);
87
- }
88
- if (state.showLessButton) {
89
- state.showLessButton.onClick = mergeCallbacks(onShowLessButtonClick, state.showLessButton.onClick);
90
- }
91
- return state;
13
+ */ export const useReferenceList_unstable = (props, ref)=>{
14
+ const { arrowableRegion, children, maxVisibleReferences, minVisibleReferences, showLessButton, showMoreButton, ...rest } = props;
15
+ const [areReferencesExpanded, setAreReferencesExpanded] = React.useState(false);
16
+ const referenceListRef = React.useRef(null);
17
+ const totalReferencesCount = React.Children.count(children);
18
+ const styles = useRootStyles();
19
+ const resolvedChildren = useOverflowMaxVisibleItems({
20
+ additionalCondition: !areReferencesExpanded,
21
+ children,
22
+ maxVisibleItems: maxVisibleReferences,
23
+ minVisibleItems: minVisibleReferences,
24
+ overflowClassName: styles.overflow
25
+ });
26
+ // We keep track of whether we are interacting with the overflow button via keyboard or not.
27
+ const overflowButtonTriggeredViaKeyboard = React.useRef(false);
28
+ const focusAttributes = useArrowNavigationGroup({
29
+ axis: 'both',
30
+ circular: true,
31
+ memorizeCurrent: true
32
+ });
33
+ const onShowMoreButtonClick = React.useCallback(()=>{
34
+ setAreReferencesExpanded(true);
35
+ }, []);
36
+ const onShowLessButtonClick = React.useCallback(()=>{
37
+ setAreReferencesExpanded(false);
38
+ }, []);
39
+ const shouldUseOverflow = (minVisibleReferences === undefined || minVisibleReferences < totalReferencesCount) && maxVisibleReferences !== undefined && !areReferencesExpanded;
40
+ // Since the overflow button is an OverflowItem that's always visible, we need to account for it.
41
+ const minVisibleOverflowItems = minVisibleReferences ? minVisibleReferences + 1 : 1;
42
+ const state = {
43
+ areReferencesExpanded,
44
+ overflowButtonTriggeredViaKeyboard,
45
+ maxVisibleReferences,
46
+ minVisibleReferences: minVisibleOverflowItems,
47
+ referenceListRef,
48
+ shouldUseOverflow,
49
+ totalReferencesCount,
50
+ components: {
51
+ root: 'div',
52
+ arrowableRegion: 'div',
53
+ showMoreButton: 'span',
54
+ showLessButton: 'span'
55
+ },
56
+ root: slot.always(getIntrinsicElementProps('div', {
57
+ ref: useMergedRefs(ref, referenceListRef),
58
+ ...rest
59
+ }), {
60
+ elementType: 'div'
61
+ }),
62
+ arrowableRegion: slot.always(arrowableRegion, {
63
+ defaultProps: {
64
+ ...focusAttributes,
65
+ children: resolvedChildren
66
+ },
67
+ elementType: 'div'
68
+ }),
69
+ showMoreButton: shouldUseOverflow ? slot.optional(showMoreButton, {
70
+ elementType: 'span'
71
+ }) : undefined,
72
+ showLessButton: areReferencesExpanded ? slot.optional(showLessButton, {
73
+ elementType: 'span'
74
+ }) : undefined
75
+ };
76
+ if (state.showMoreButton) {
77
+ state.showMoreButton.onClick = mergeCallbacks(onShowMoreButtonClick, state.showMoreButton.onClick);
78
+ }
79
+ if (state.showLessButton) {
80
+ state.showLessButton.onClick = mergeCallbacks(onShowLessButtonClick, state.showLessButton.onClick);
81
+ }
82
+ return state;
92
83
  };
93
- //# sourceMappingURL=useReferenceList.js.map
@@ -1,23 +1,15 @@
1
1
  export function useReferenceListContextValues_unstable(state) {
2
- const {
3
- areReferencesExpanded,
4
- maxVisibleReferences,
5
- overflowButtonTriggeredViaKeyboard,
6
- referenceListRef,
7
- shouldUseOverflow,
8
- totalReferencesCount
9
- } = state;
10
- // This context is created with "@fluentui/react-context-selector", there is no sense to memoize it
11
- const referenceList = {
12
- areReferencesExpanded,
13
- maxVisibleReferences,
14
- overflowButtonTriggeredViaKeyboard,
15
- referenceListRef,
16
- shouldUseOverflow,
17
- totalReferencesCount
18
- };
19
- return {
20
- referenceList
21
- };
2
+ const { areReferencesExpanded, maxVisibleReferences, overflowButtonTriggeredViaKeyboard, referenceListRef, shouldUseOverflow, totalReferencesCount } = state;
3
+ // This context is created with "@fluentui/react-context-selector", there is no sense to memoize it
4
+ const referenceList = {
5
+ areReferencesExpanded,
6
+ maxVisibleReferences,
7
+ overflowButtonTriggeredViaKeyboard,
8
+ referenceListRef,
9
+ shouldUseOverflow,
10
+ totalReferencesCount
11
+ };
12
+ return {
13
+ referenceList
14
+ };
22
15
  }
23
- //# sourceMappingURL=useReferenceListContextValues.js.map
@@ -0,0 +1,47 @@
1
+ import { makeResetStyles, makeStyles, mergeClasses } from '@fluentui/react-components';
2
+ import { tokens } from '@fluentui-copilot/tokens';
3
+ export const referenceListClassNames = {
4
+ root: 'fai-ReferenceList',
5
+ arrowableRegion: 'fai-ReferenceList__arrowableRegion',
6
+ showMoreButton: 'fai-ReferenceList__showMoreButton',
7
+ showLessButton: 'fai-ReferenceList__showLessButton'
8
+ };
9
+ /**
10
+ * Styles for the root slot
11
+ */ const useRootBaseClassName = makeResetStyles({
12
+ display: 'flex',
13
+ flexDirection: 'row',
14
+ gap: `${tokens.spacingVerticalXS} ${tokens.spacingHorizontalXS}`
15
+ });
16
+ const useRootStyles = makeStyles({
17
+ referencesExpanded: {
18
+ flexWrap: 'wrap'
19
+ }
20
+ });
21
+ const useArrowableRegionBaseClassName = makeResetStyles({
22
+ display: 'contents',
23
+ maxWidth: '100%'
24
+ });
25
+ const useOverflowButtonBaseClassName = makeResetStyles({
26
+ display: 'inline-flex',
27
+ flexShrink: 0
28
+ });
29
+ /**
30
+ * Apply styling to the ReferenceList slots based on the state
31
+ */ export const useReferenceListStyles_unstable = (state)=>{
32
+ 'use no memo';
33
+ const { areReferencesExpanded, shouldUseOverflow } = state;
34
+ const rootBaseClassName = useRootBaseClassName();
35
+ const arrowableRegionBaseClassName = useArrowableRegionBaseClassName();
36
+ const overflowButtonBaseClassName = useOverflowButtonBaseClassName();
37
+ const rootStyles = useRootStyles();
38
+ state.root.className = mergeClasses(referenceListClassNames.root, rootBaseClassName, (areReferencesExpanded || !shouldUseOverflow) && rootStyles.referencesExpanded, state.root.className);
39
+ state.arrowableRegion.className = mergeClasses(referenceListClassNames.arrowableRegion, arrowableRegionBaseClassName, state.arrowableRegion.className);
40
+ if (state.showMoreButton) {
41
+ state.showMoreButton.className = mergeClasses(referenceListClassNames.showMoreButton, overflowButtonBaseClassName, state.showMoreButton.className);
42
+ }
43
+ if (state.showLessButton) {
44
+ state.showLessButton.className = mergeClasses(referenceListClassNames.showLessButton, overflowButtonBaseClassName, state.showLessButton.className);
45
+ }
46
+ return state;
47
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useReferenceListStyles.styles.ts"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses } from '@fluentui/react-components';\nimport { tokens } from '@fluentui-copilot/tokens';\nimport type { ReferenceListSlots, ReferenceListState } from './ReferenceList.types';\nimport type { SlotClassNames } from '@fluentui/react-components';\n\nexport const referenceListClassNames: SlotClassNames<ReferenceListSlots> = {\n root: 'fai-ReferenceList',\n arrowableRegion: 'fai-ReferenceList__arrowableRegion',\n showMoreButton: 'fai-ReferenceList__showMoreButton',\n showLessButton: 'fai-ReferenceList__showLessButton',\n};\n\n/**\n * Styles for the root slot\n */\nconst useRootBaseClassName = makeResetStyles({\n display: 'flex',\n flexDirection: 'row',\n gap: `${tokens.spacingVerticalXS} ${tokens.spacingHorizontalXS}`,\n});\n\nconst useRootStyles = makeStyles({\n referencesExpanded: {\n flexWrap: 'wrap',\n },\n});\n\nconst useArrowableRegionBaseClassName = makeResetStyles({\n display: 'contents',\n maxWidth: '100%',\n});\n\nconst useOverflowButtonBaseClassName = makeResetStyles({\n display: 'inline-flex',\n flexShrink: 0,\n});\n\n/**\n * Apply styling to the ReferenceList slots based on the state\n */\nexport const useReferenceListStyles_unstable = (state: ReferenceListState): ReferenceListState => {\n 'use no memo';\n\n const { areReferencesExpanded, shouldUseOverflow } = state;\n\n const rootBaseClassName = useRootBaseClassName();\n const arrowableRegionBaseClassName = useArrowableRegionBaseClassName();\n const overflowButtonBaseClassName = useOverflowButtonBaseClassName();\n const rootStyles = useRootStyles();\n\n state.root.className = mergeClasses(\n referenceListClassNames.root,\n rootBaseClassName,\n (areReferencesExpanded || !shouldUseOverflow) && rootStyles.referencesExpanded,\n state.root.className,\n );\n\n state.arrowableRegion.className = mergeClasses(\n referenceListClassNames.arrowableRegion,\n arrowableRegionBaseClassName,\n state.arrowableRegion.className,\n );\n\n if (state.showMoreButton) {\n state.showMoreButton.className = mergeClasses(\n referenceListClassNames.showMoreButton,\n overflowButtonBaseClassName,\n state.showMoreButton.className,\n );\n }\n\n if (state.showLessButton) {\n state.showLessButton.className = mergeClasses(\n referenceListClassNames.showLessButton,\n overflowButtonBaseClassName,\n state.showLessButton.className,\n );\n }\n\n return state;\n};\n"],"names":["makeResetStyles","makeStyles","mergeClasses","tokens","referenceListClassNames","root","arrowableRegion","showMoreButton","showLessButton","useRootBaseClassName","display","flexDirection","gap","spacingVerticalXS","spacingHorizontalXS","useRootStyles","referencesExpanded","flexWrap","useArrowableRegionBaseClassName","maxWidth","useOverflowButtonBaseClassName","flexShrink","useReferenceListStyles_unstable","state","areReferencesExpanded","shouldUseOverflow","rootBaseClassName","arrowableRegionBaseClassName","overflowButtonBaseClassName","rootStyles","className"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;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AEA,IAAIP,MAAMf,cAAc,EAAE;QACxBe,MAAMf,cAAc,CAACsB,SAAS,GAAG5B,aAC/BE,wBAAwBI,cAAc,EACtCoB,6BACAL,MAAMf,cAAc,CAACsB,SAAS;IAElC;IAEA,OAAOP;AACT,EAAE"}
@@ -3,10 +3,9 @@ import { useReferenceOverflowButton_unstable } from './useReferenceOverflowButto
3
3
  import { renderReferenceOverflowButton_unstable } from './renderReferenceOverflowButton';
4
4
  import { useReferenceOverflowButtonStyles_unstable } from './useReferenceOverflowButtonStyles.styles';
5
5
  // ReferenceOverflowButton component - TODO: add more docs
6
- export const ReferenceOverflowButton = /*#__PURE__*/React.forwardRef((props, ref) => {
7
- const state = useReferenceOverflowButton_unstable(props, ref);
8
- useReferenceOverflowButtonStyles_unstable(state);
9
- return renderReferenceOverflowButton_unstable(state);
6
+ export const ReferenceOverflowButton = /*#__PURE__*/ React.forwardRef((props, ref)=>{
7
+ const state = useReferenceOverflowButton_unstable(props, ref);
8
+ useReferenceOverflowButtonStyles_unstable(state);
9
+ return renderReferenceOverflowButton_unstable(state);
10
10
  });
11
11
  ReferenceOverflowButton.displayName = 'ReferenceOverflowButton';
12
- //# sourceMappingURL=ReferenceOverflowButton.js.map
@@ -1,4 +1,3 @@
1
1
  /**
2
2
  * State used in rendering ReferenceOverflowButton
3
- */export {};
4
- //# sourceMappingURL=ReferenceOverflowButton.types.js.map
3
+ */ export { };
@@ -2,4 +2,3 @@ export { ReferenceOverflowButton } from './ReferenceOverflowButton';
2
2
  export { renderReferenceOverflowButton_unstable } from './renderReferenceOverflowButton';
3
3
  export { useReferenceOverflowButton_unstable } from './useReferenceOverflowButton';
4
4
  export { referenceOverflowButtonClassNames, useReferenceOverflowButtonStyles_unstable } from './useReferenceOverflowButtonStyles.styles';
5
- //# sourceMappingURL=index.js.map
@@ -1,18 +1,13 @@
1
- import { jsx as _jsx } from "@fluentui/react-jsx-runtime/jsx-runtime";
1
+ import { jsx as _jsx } from "@fluentui/react-jsx-runtime/jsx-runtime";
2
2
  import { OverflowItem, assertSlots } from '@fluentui/react-components';
3
3
  /**
4
4
  * Render the final JSX of ReferenceOverflowButton
5
- */
6
- export const renderReferenceOverflowButton_unstable = state => {
7
- assertSlots(state);
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;
5
+ */ export const renderReferenceOverflowButton_unstable = (state)=>{
6
+ assertSlots(state);
7
+ const { id, shouldRenderOverflowButton } = state;
8
+ return shouldRenderOverflowButton ? /*#__PURE__*/ _jsx(OverflowItem, {
9
+ id: id,
10
+ priority: 1,
11
+ children: /*#__PURE__*/ _jsx(state.root, {})
12
+ }, id) : null;
17
13
  };
18
- //# sourceMappingURL=renderReferenceOverflowButton.js.map
@@ -12,82 +12,82 @@ import { useDesignVersion } from '@fluentui-copilot/react-provider';
12
12
  *
13
13
  * @param props - props from this instance of ReferenceOverflowButton
14
14
  * @param ref - reference to root HTMLElement of ReferenceOverflowButton
15
- */
16
- export const useReferenceOverflowButton_unstable = (props, ref) => {
17
- 'use no memo';
18
-
19
- const {
20
- children,
21
- id,
22
- text
23
- } = props;
24
- const designVersion = useDesignVersion(props.designVersion);
25
- const rootRef = React.useRef(null);
26
- const [setTimeout] = useTimeout();
27
- const referenceOverflowButtonId = useId('reference-overflow-button-', id);
28
- const areReferencesExpanded = useReferenceListContext_unstable(ctx => ctx.areReferencesExpanded);
29
- const maxVisibleReferences = useReferenceListContext_unstable(ctx => ctx.maxVisibleReferences);
30
- const referenceListRef = useReferenceListContext_unstable(ctx => ctx.referenceListRef);
31
- const totalReferencesCount = useReferenceListContext_unstable(ctx => ctx.totalReferencesCount);
32
- const triggeredViaKeyboard = useReferenceListContext_unstable(ctx => ctx.overflowButtonTriggeredViaKeyboard);
33
- const {
34
- isOverflowing,
35
- overflowCount
36
- } = useOverflowMenu();
37
- const processedText = children !== null && children !== void 0 ? children : typeof text === 'function' ? text(overflowCount) : text;
38
- const {
39
- findFirstFocusable,
40
- findNextFocusable
41
- } = useFocusFinders();
42
- const onKeyDown = React.useCallback(ev => {
43
- if (ev.key === Enter || ev.key === Space) {
44
- triggeredViaKeyboard.current = true;
45
- }
46
- }, [triggeredViaKeyboard]);
47
- // We keep track of the previous overflow count to help determine the element to move focus to when expanding the references via keyboard.
48
- const previousOverflow = React.useRef(0);
49
- // When the references are expanded or collapsed via keyboard, we need to move focus to the appropriate element.
50
- React.useEffect(() => {
51
- // We only try to move focus if maxVisibleReferences is set and the overflow button was triggered via keyboard.
52
- if (maxVisibleReferences !== undefined && triggeredViaKeyboard.current) {
53
- let elementToFocus;
54
- // If the references are collapsed, we move focus to the overflow button.
55
- if (!areReferencesExpanded) {
56
- elementToFocus = rootRef.current;
57
- previousOverflow.current = overflowCount;
58
- } else if (rootRef.current && referenceListRef.current) {
59
- const positionToFocus = maxVisibleReferences < totalReferencesCount - previousOverflow.current ? maxVisibleReferences : totalReferencesCount - previousOverflow.current;
60
- let currentElement = findFirstFocusable(referenceListRef.current);
61
- for (let i = 0; i < positionToFocus && currentElement; i++) {
62
- currentElement = findNextFocusable(currentElement);
15
+ */ export const useReferenceOverflowButton_unstable = (props, ref)=>{
16
+ 'use no memo';
17
+ const { children, id, text } = props;
18
+ const designVersion = useDesignVersion(props.designVersion);
19
+ const rootRef = React.useRef(null);
20
+ const [setTimeout] = useTimeout();
21
+ const referenceOverflowButtonId = useId('reference-overflow-button-', id);
22
+ const areReferencesExpanded = useReferenceListContext_unstable((ctx)=>ctx.areReferencesExpanded);
23
+ const maxVisibleReferences = useReferenceListContext_unstable((ctx)=>ctx.maxVisibleReferences);
24
+ const referenceListRef = useReferenceListContext_unstable((ctx)=>ctx.referenceListRef);
25
+ const totalReferencesCount = useReferenceListContext_unstable((ctx)=>ctx.totalReferencesCount);
26
+ const triggeredViaKeyboard = useReferenceListContext_unstable((ctx)=>ctx.overflowButtonTriggeredViaKeyboard);
27
+ const { isOverflowing, overflowCount } = useOverflowMenu();
28
+ const processedText = children !== null && children !== void 0 ? children : typeof text === 'function' ? text(overflowCount) : text;
29
+ const { findFirstFocusable, findNextFocusable } = useFocusFinders();
30
+ const onKeyDown = React.useCallback((ev)=>{
31
+ if (ev.key === Enter || ev.key === Space) {
32
+ triggeredViaKeyboard.current = true;
63
33
  }
64
- elementToFocus = currentElement;
65
- }
66
- // 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.
67
- setTimeout(() => {
68
- elementToFocus === null || elementToFocus === void 0 ? void 0 : elementToFocus.focus();
69
- triggeredViaKeyboard.current = false;
70
- }, 0);
71
- }
72
- }, [areReferencesExpanded, findFirstFocusable, findNextFocusable, isOverflowing, maxVisibleReferences, overflowCount, referenceListRef, setTimeout, totalReferencesCount, triggeredViaKeyboard]);
73
- const state = {
74
- designVersion,
75
- id: referenceOverflowButtonId,
76
- shouldRenderOverflowButton: isOverflowing || areReferencesExpanded,
77
- components: {
78
- root: 'button'
79
- },
80
- root: slot.always(getIntrinsicElementProps('button', {
81
- ref: useMergedRefs(rootRef, ref),
82
- ...props
83
- }), {
84
- defaultProps: {
85
- children: processedText
86
- },
87
- elementType: 'button'
88
- })
89
- };
90
- state.root.onKeyDown = mergeCallbacks(onKeyDown, props.onKeyDown);
91
- return state;
34
+ }, [
35
+ triggeredViaKeyboard
36
+ ]);
37
+ // We keep track of the previous overflow count to help determine the element to move focus to when expanding the references via keyboard.
38
+ const previousOverflow = React.useRef(0);
39
+ // When the references are expanded or collapsed via keyboard, we need to move focus to the appropriate element.
40
+ React.useEffect(()=>{
41
+ // We only try to move focus if maxVisibleReferences is set and the overflow button was triggered via keyboard.
42
+ if (maxVisibleReferences !== undefined && triggeredViaKeyboard.current) {
43
+ let elementToFocus;
44
+ // If the references are collapsed, we move focus to the overflow button.
45
+ if (!areReferencesExpanded) {
46
+ elementToFocus = rootRef.current;
47
+ previousOverflow.current = overflowCount;
48
+ } else if (rootRef.current && referenceListRef.current) {
49
+ const positionToFocus = maxVisibleReferences < totalReferencesCount - previousOverflow.current ? maxVisibleReferences : totalReferencesCount - previousOverflow.current;
50
+ let currentElement = findFirstFocusable(referenceListRef.current);
51
+ for(let i = 0; i < positionToFocus && currentElement; i++){
52
+ currentElement = findNextFocusable(currentElement);
53
+ }
54
+ elementToFocus = currentElement;
55
+ }
56
+ // 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.
57
+ setTimeout(()=>{
58
+ elementToFocus === null || elementToFocus === void 0 ? void 0 : elementToFocus.focus();
59
+ triggeredViaKeyboard.current = false;
60
+ }, 0);
61
+ }
62
+ }, [
63
+ areReferencesExpanded,
64
+ findFirstFocusable,
65
+ findNextFocusable,
66
+ isOverflowing,
67
+ maxVisibleReferences,
68
+ overflowCount,
69
+ referenceListRef,
70
+ setTimeout,
71
+ totalReferencesCount,
72
+ triggeredViaKeyboard
73
+ ]);
74
+ const state = {
75
+ designVersion,
76
+ id: referenceOverflowButtonId,
77
+ shouldRenderOverflowButton: isOverflowing || areReferencesExpanded,
78
+ components: {
79
+ root: 'button'
80
+ },
81
+ root: slot.always(getIntrinsicElementProps('button', {
82
+ ref: useMergedRefs(rootRef, ref),
83
+ ...props
84
+ }), {
85
+ defaultProps: {
86
+ children: processedText
87
+ },
88
+ elementType: 'button'
89
+ })
90
+ };
91
+ state.root.onKeyDown = mergeCallbacks(onKeyDown, props.onKeyDown);
92
+ return state;
92
93
  };
93
- //# sourceMappingURL=useReferenceOverflowButton.js.map
@@ -0,0 +1,45 @@
1
+ import { makeResetStyles, makeStyles, mergeClasses } from '@fluentui/react-components';
2
+ import { tokens, typographyStyles } from '@fluentui-copilot/tokens';
3
+ export const referenceOverflowButtonClassNames = {
4
+ root: 'fai-ReferenceOverflowButton'
5
+ };
6
+ /**
7
+ * Styles for the root slot
8
+ */ const useRootBaseClassName = makeResetStyles({
9
+ alignItems: 'center',
10
+ backgroundColor: tokens.colorNeutralBackground3,
11
+ border: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke2}`,
12
+ borderRadius: tokens.borderRadiusMedium,
13
+ color: tokens.colorNeutralForeground2,
14
+ cursor: 'pointer',
15
+ display: 'inline-flex',
16
+ justifyContent: 'center',
17
+ minHeight: '24px',
18
+ padding: `${tokens.spacingVerticalXXS} ${tokens.spacingHorizontalS}`,
19
+ ...typographyStyles.caption1,
20
+ ':hover': {
21
+ backgroundColor: tokens.colorNeutralBackground3Hover,
22
+ borderColor: tokens.colorNeutralStroke1Hover,
23
+ color: tokens.colorNeutralForeground2Hover
24
+ },
25
+ ':hover:active': {
26
+ backgroundColor: tokens.colorNeutralBackground3Pressed,
27
+ borderColor: tokens.colorNeutralStroke1Pressed,
28
+ color: tokens.colorNeutralForeground2Pressed
29
+ }
30
+ });
31
+ const useNextStyles = makeStyles({
32
+ root: {
33
+ borderRadius: tokens.borderRadiusXLarge
34
+ }
35
+ });
36
+ /**
37
+ * Apply styling to the ReferenceOverflowButton slots based on the state
38
+ */ export const useReferenceOverflowButtonStyles_unstable = (state)=>{
39
+ 'use no memo';
40
+ const { designVersion } = state;
41
+ const rootBaseClassName = useRootBaseClassName();
42
+ const nextStyles = useNextStyles();
43
+ state.root.className = mergeClasses(referenceOverflowButtonClassNames.root, rootBaseClassName, designVersion === 'next' && nextStyles.root, state.root.className);
44
+ return state;
45
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useReferenceOverflowButtonStyles.styles.ts"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses } from '@fluentui/react-components';\nimport { tokens, typographyStyles } from '@fluentui-copilot/tokens';\nimport type { ReferenceOverflowButtonSlots, ReferenceOverflowButtonState } from './ReferenceOverflowButton.types';\nimport type { SlotClassNames } from '@fluentui/react-components';\n\nexport const referenceOverflowButtonClassNames: SlotClassNames<ReferenceOverflowButtonSlots> = {\n root: 'fai-ReferenceOverflowButton',\n};\n\n/**\n * Styles for the root slot\n */\nconst useRootBaseClassName = makeResetStyles({\n alignItems: 'center',\n backgroundColor: tokens.colorNeutralBackground3,\n border: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke2}`,\n borderRadius: tokens.borderRadiusMedium,\n color: tokens.colorNeutralForeground2,\n cursor: 'pointer',\n display: 'inline-flex',\n justifyContent: 'center',\n minHeight: '24px',\n padding: `${tokens.spacingVerticalXXS} ${tokens.spacingHorizontalS}`,\n ...typographyStyles.caption1,\n\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground3Hover,\n borderColor: tokens.colorNeutralStroke1Hover,\n color: tokens.colorNeutralForeground2Hover,\n },\n\n ':hover:active': {\n backgroundColor: tokens.colorNeutralBackground3Pressed,\n borderColor: tokens.colorNeutralStroke1Pressed,\n color: tokens.colorNeutralForeground2Pressed,\n },\n});\n\nconst useNextStyles = makeStyles({ root: { borderRadius: tokens.borderRadiusXLarge } });\n\n/**\n * Apply styling to the ReferenceOverflowButton slots based on the state\n */\nexport const useReferenceOverflowButtonStyles_unstable = (\n state: ReferenceOverflowButtonState,\n): ReferenceOverflowButtonState => {\n 'use no memo';\n\n const { designVersion } = state;\n\n const rootBaseClassName = useRootBaseClassName();\n const nextStyles = useNextStyles();\n\n state.root.className = mergeClasses(\n referenceOverflowButtonClassNames.root,\n rootBaseClassName,\n designVersion === 'next' && nextStyles.root,\n state.root.className,\n );\n\n return state;\n};\n"],"names":["makeResetStyles","makeStyles","mergeClasses","tokens","typographyStyles","referenceOverflowButtonClassNames","root","useRootBaseClassName","alignItems","backgroundColor","colorNeutralBackground3","border","strokeWidthThin","colorNeutralStroke2","borderRadius","borderRadiusMedium","color","colorNeutralForeground2","cursor","display","justifyContent","minHeight","padding","spacingVerticalXXS","spacingHorizontalS","caption1","colorNeutralBackground3Hover","borderColor","colorNeutralStroke1Hover","colorNeutralForeground2Hover","colorNeutralBackground3Pressed","colorNeutralStroke1Pressed","colorNeutralForeground2Pressed","useNextStyles","borderRadiusXLarge","useRe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CC,IAAI,EACtCgC,mBACAD,kBAAkB,UAAUE,WAAWjC,IAAI,EAC3C8B,MAAM9B,IAAI,CAACkC,SAAS;IAGtB,OAAOJ;AACT,EAAE"}
@@ -1,2 +1 @@
1
1
  export { ReferenceListContext, ReferenceListContextProvider, useReferenceListContext_unstable } from './referenceListContext';
2
- //# sourceMappingURL=index.js.map
@@ -1,17 +1,16 @@
1
1
  import { createContext, useContextSelector } from '@fluentui/react-context-selector';
2
2
  export const ReferenceListContext = createContext(undefined);
3
3
  const referenceListContextDefaultValue = {
4
- areReferencesExpanded: false,
5
- maxVisibleReferences: undefined,
6
- overflowButtonTriggeredViaKeyboard: {
7
- current: false
8
- },
9
- referenceListRef: {
10
- current: null
11
- },
12
- shouldUseOverflow: false,
13
- totalReferencesCount: 0
4
+ areReferencesExpanded: false,
5
+ maxVisibleReferences: undefined,
6
+ overflowButtonTriggeredViaKeyboard: {
7
+ current: false
8
+ },
9
+ referenceListRef: {
10
+ current: null
11
+ },
12
+ shouldUseOverflow: false,
13
+ totalReferencesCount: 0
14
14
  };
15
15
  export const ReferenceListContextProvider = ReferenceListContext.Provider;
16
- export const useReferenceListContext_unstable = selector => useContextSelector(ReferenceListContext, (ctx = referenceListContextDefaultValue) => selector(ctx));
17
- //# sourceMappingURL=referenceListContext.js.map
16
+ export const useReferenceListContext_unstable = (selector)=>useContextSelector(ReferenceListContext, (ctx = referenceListContextDefaultValue)=>selector(ctx));