@fluentui-copilot/react-reference 0.0.0-nightly-20240527-0406-162a35f3.1 → 0.0.0-nightly-20240531-0407-49d6b52e.1

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 (64) hide show
  1. package/CHANGELOG.json +9 -9
  2. package/CHANGELOG.md +7 -7
  3. package/dist/index.d.ts +9 -24
  4. package/lib/components/Citation/useCitationStyles.styles.js +2 -0
  5. package/lib/components/Citation/useCitationStyles.styles.js.map +1 -1
  6. package/lib/components/Reference/useReferenceStyles.styles.js +2 -0
  7. package/lib/components/Reference/useReferenceStyles.styles.js.map +1 -1
  8. package/lib/components/ReferenceGroupToggle/ReferenceGroupToggle.types.js.map +1 -1
  9. package/lib/components/ReferenceGroupToggle/useReferenceGroupToggle.js +3 -0
  10. package/lib/components/ReferenceGroupToggle/useReferenceGroupToggle.js.map +1 -1
  11. package/lib/components/ReferenceGroupToggle/useReferenceGroupToggleStyles.styles.js +24 -2
  12. package/lib/components/ReferenceGroupToggle/useReferenceGroupToggleStyles.styles.js.map +1 -1
  13. package/lib/components/ReferenceList/useReferenceListStyles.styles.js +2 -0
  14. package/lib/components/ReferenceList/useReferenceListStyles.styles.js.map +1 -1
  15. package/lib/components/reference-v2/Reference/Reference.types.js.map +1 -1
  16. package/lib/components/reference-v2/Reference/useReference.js +1 -9
  17. package/lib/components/reference-v2/Reference/useReference.js.map +1 -1
  18. package/lib/components/reference-v2/Reference/useReferenceStyles.styles.js +6 -26
  19. package/lib/components/reference-v2/Reference/useReferenceStyles.styles.js.map +1 -1
  20. package/lib/components/reference-v2/ReferenceList/ReferenceList.types.js.map +1 -1
  21. package/lib/components/reference-v2/ReferenceList/useReferenceList.js +9 -9
  22. package/lib/components/reference-v2/ReferenceList/useReferenceList.js.map +1 -1
  23. package/lib/components/reference-v2/ReferenceList/useReferenceListContextValues.js +8 -6
  24. package/lib/components/reference-v2/ReferenceList/useReferenceListContextValues.js.map +1 -1
  25. package/lib/components/reference-v2/ReferenceList/useReferenceListStyles.styles.js +2 -0
  26. package/lib/components/reference-v2/ReferenceList/useReferenceListStyles.styles.js.map +1 -1
  27. package/lib/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.types.js.map +1 -1
  28. package/lib/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js +23 -19
  29. package/lib/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js.map +1 -1
  30. package/lib/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.js +4 -20
  31. package/lib/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.js.map +1 -1
  32. package/lib/contexts/reference-v2/referenceListContext.js +5 -4
  33. package/lib/contexts/reference-v2/referenceListContext.js.map +1 -1
  34. package/lib-commonjs/components/Citation/useCitationStyles.styles.js +1 -0
  35. package/lib-commonjs/components/Citation/useCitationStyles.styles.js.map +1 -1
  36. package/lib-commonjs/components/Reference/useReferenceStyles.styles.js +1 -0
  37. package/lib-commonjs/components/Reference/useReferenceStyles.styles.js.map +1 -1
  38. package/lib-commonjs/components/ReferenceGroupToggle/ReferenceGroupToggle.types.js.map +1 -1
  39. package/lib-commonjs/components/ReferenceGroupToggle/useReferenceGroupToggle.js +3 -0
  40. package/lib-commonjs/components/ReferenceGroupToggle/useReferenceGroupToggle.js.map +1 -1
  41. package/lib-commonjs/components/ReferenceGroupToggle/useReferenceGroupToggleStyles.styles.js +27 -1
  42. package/lib-commonjs/components/ReferenceGroupToggle/useReferenceGroupToggleStyles.styles.js.map +1 -1
  43. package/lib-commonjs/components/ReferenceList/useReferenceListStyles.styles.js +1 -0
  44. package/lib-commonjs/components/ReferenceList/useReferenceListStyles.styles.js.map +1 -1
  45. package/lib-commonjs/components/reference-v2/Reference/Reference.types.js.map +1 -1
  46. package/lib-commonjs/components/reference-v2/Reference/useReference.js +1 -6
  47. package/lib-commonjs/components/reference-v2/Reference/useReference.js.map +1 -1
  48. package/lib-commonjs/components/reference-v2/Reference/useReferenceStyles.styles.js +3 -38
  49. package/lib-commonjs/components/reference-v2/Reference/useReferenceStyles.styles.js.map +1 -1
  50. package/lib-commonjs/components/reference-v2/ReferenceList/ReferenceList.types.js.map +1 -1
  51. package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceList.js +9 -7
  52. package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceList.js.map +1 -1
  53. package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceListContextValues.js +5 -4
  54. package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceListContextValues.js.map +1 -1
  55. package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceListStyles.styles.js +1 -0
  56. package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceListStyles.styles.js.map +1 -1
  57. package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.types.js.map +1 -1
  58. package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js +26 -17
  59. package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js.map +1 -1
  60. package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.js +2 -32
  61. package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.js.map +1 -1
  62. package/lib-commonjs/contexts/reference-v2/referenceListContext.js +5 -4
  63. package/lib-commonjs/contexts/reference-v2/referenceListContext.js.map +1 -1
  64. package/package.json +4 -4
@@ -15,19 +15,20 @@ const _reactcomponents = require("@fluentui/react-components");
15
15
  const _reactutilities = require("@fluentui/react-utilities");
16
16
  const _referenceListContext = require("../../../contexts/reference-v2/referenceListContext");
17
17
  const useReferenceOverflowButton_unstable = (props, ref)=>{
18
+ 'use no memo';
18
19
  const { children, text } = props;
19
20
  const rootRef = _react.useRef(null);
20
21
  const [setTimeout] = (0, _reactutilities.useTimeout)();
21
- const { areReferencesExpanded, ctxAppearance, previousOverflowCount, triggeredViaKeyboard } = (0, _referenceListContext.useReferenceListContext_unstable)((ctx)=>({
22
- ctxAppearance: ctx.appearance,
22
+ const { areReferencesExpanded, maxVisibleReferences, referenceListRef, totalReferencesCount, triggeredViaKeyboard } = (0, _referenceListContext.useReferenceListContext_unstable)((ctx)=>({
23
23
  areReferencesExpanded: ctx.areReferencesExpanded,
24
- previousOverflowCount: ctx.previousOverflowCount,
24
+ maxVisibleReferences: ctx.maxVisibleReferences,
25
+ referenceListRef: ctx.referenceListRef,
26
+ totalReferencesCount: ctx.totalReferencesCount,
25
27
  triggeredViaKeyboard: ctx.overflowButtonTriggeredViaKeyboard
26
28
  }));
27
- const appearance = props.appearance || ctxAppearance;
28
29
  const { isOverflowing, overflowCount } = (0, _reactcomponents.useOverflowMenu)();
29
30
  const processedText = children !== null && children !== void 0 ? children : typeof text === 'function' ? text(overflowCount) : text;
30
- const { findPrevFocusable } = (0, _reactcomponents.useFocusFinders)();
31
+ const { findFirstFocusable, findNextFocusable } = (0, _reactcomponents.useFocusFinders)();
31
32
  const onKeyDown = _react.useCallback((ev)=>{
32
33
  if (ev.key === _keyboardkeys.Enter || ev.key === _keyboardkeys.Space) {
33
34
  triggeredViaKeyboard.current = true;
@@ -35,17 +36,22 @@ const useReferenceOverflowButton_unstable = (props, ref)=>{
35
36
  }, [
36
37
  triggeredViaKeyboard
37
38
  ]);
38
- // When the references are expanded or contracted via keyboard, we need to move focus to the appropriate element.
39
+ // We keep track of the previous overflow count to help determine the element to move focus to when expanding the references via keyboard.
40
+ const previousOverflow = _react.useRef(0);
41
+ // When the references are expanded or collapsed via keyboard, we need to move focus to the appropriate element.
39
42
  _react.useEffect(()=>{
40
- if (triggeredViaKeyboard.current) {
43
+ // We only try to move focus if maxVisibleReferences is set and the overflow button was triggered via keyboard.
44
+ if (maxVisibleReferences !== undefined && triggeredViaKeyboard.current) {
41
45
  let elementToFocus;
42
- // If the references are contracted, we move focus to the overflow button.
46
+ // If the references are collapsed, we move focus to the overflow button.
43
47
  if (!areReferencesExpanded) {
44
48
  elementToFocus = rootRef.current;
45
- } else if (rootRef.current && previousOverflowCount) {
46
- let currentElement = rootRef.current;
47
- for(let i = 0; i < previousOverflowCount.current && currentElement; i++){
48
- currentElement = findPrevFocusable(currentElement);
49
+ previousOverflow.current = overflowCount;
50
+ } else if (rootRef.current && referenceListRef.current) {
51
+ const positionToFocus = maxVisibleReferences < totalReferencesCount - previousOverflow.current ? maxVisibleReferences : totalReferencesCount - previousOverflow.current;
52
+ let currentElement = findFirstFocusable(referenceListRef.current);
53
+ for(let i = 0; i < positionToFocus && currentElement; i++){
54
+ currentElement = findNextFocusable(currentElement);
49
55
  }
50
56
  elementToFocus = currentElement;
51
57
  }
@@ -55,16 +61,19 @@ const useReferenceOverflowButton_unstable = (props, ref)=>{
55
61
  triggeredViaKeyboard.current = false;
56
62
  }, 0);
57
63
  }
58
- // We update the previousOverflowCount to the current one when references are contracted, so that we have the correct number once they are expanded.
59
- previousOverflowCount.current = areReferencesExpanded ? 0 : overflowCount;
60
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
61
- [
64
+ }, [
62
65
  areReferencesExpanded,
66
+ findFirstFocusable,
67
+ findNextFocusable,
63
68
  isOverflowing,
69
+ maxVisibleReferences,
70
+ overflowCount,
71
+ referenceListRef,
72
+ setTimeout,
73
+ totalReferencesCount,
64
74
  triggeredViaKeyboard
65
75
  ]);
66
76
  const state = {
67
- appearance,
68
77
  shouldRenderOverflowButton: isOverflowing || areReferencesExpanded,
69
78
  components: {
70
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 const { children, text } = props;\n\n const rootRef = React.useRef<HTMLButtonElement>(null);\n\n const [setTimeout] = useTimeout();\n\n const { areReferencesExpanded, ctxAppearance, previousOverflowCount, triggeredViaKeyboard } =\n useReferenceListContext_unstable(ctx => ({\n ctxAppearance: ctx.appearance,\n areReferencesExpanded: ctx.areReferencesExpanded,\n previousOverflowCount: ctx.previousOverflowCount,\n triggeredViaKeyboard: ctx.overflowButtonTriggeredViaKeyboard,\n }));\n const appearance = props.appearance || ctxAppearance;\n\n const { isOverflowing, overflowCount } = useOverflowMenu();\n\n const processedText = children ?? (typeof text === 'function' ? text(overflowCount) : text);\n\n const { findPrevFocusable } = 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 // When the references are expanded or contracted via keyboard, we need to move focus to the appropriate element.\n React.useEffect(\n () => {\n if (triggeredViaKeyboard.current) {\n let elementToFocus: HTMLElement | null | undefined;\n\n // If the references are contracted, we move focus to the overflow button.\n if (!areReferencesExpanded) {\n elementToFocus = rootRef.current;\n }\n // If the references are expanded, we move focus to the first reference that was hidden when they were contracted.\n // We do this by moving focus to the element that is overflowCount elements before the overflow button.\n else if (rootRef.current && previousOverflowCount) {\n let currentElement: HTMLElement | null | undefined = rootRef.current;\n for (let i = 0; i < previousOverflowCount.current && currentElement; i++) {\n currentElement = findPrevFocusable(currentElement);\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 // We update the previousOverflowCount to the current one when references are contracted, so that we have the correct number once they are expanded.\n previousOverflowCount.current = areReferencesExpanded ? 0 : overflowCount;\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [areReferencesExpanded, isOverflowing, triggeredViaKeyboard],\n );\n\n const state: ReferenceOverflowButtonState = {\n appearance,\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":["children","props","setTimeout","text","areReferencesExpanded","previousOverflowCount","ctxAppearance","appearance","triggeredViaKeyboard","processedText","useReferenceListContext_unstable","useFocusFinders","onKeyDown","React","useCallback","Enter","ctx","overflowButtonTriggeredViaKeyboard","isOverflowing","useEffect","elementToFocus","rootRef","current","ev","currentElement","i","overflowCount","findPrevFocusable","focus","shouldRenderOverflowButton","ref","state","elementType","root","slot","always","getIntrinsicElementProps","mergeCallbacks"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BA2BUA;;;eAAAA;;;;iEA3Ba;8BACM;iCAQtB;gCACoB;sCACsB;AAgB/C,MAAQA,sCAAmBC,CAAAA,OAAAA;UAE3B,EAEAD,QAAOE,EAEPC,IAAA;oBAGIC,OAAAA,MAAAA,CAAAA;sBACAC,GAAAA,IAAAA,0BAAAA;iCAEF,EACFC,aAAMC,EAENF,qBAAqB,EAErBG,oBAAMC,KAENC,IAAAA,sDAA8BC,EAAAA,CAAAA,MAAAA,CAAAA;YAC9BL,eAAMM,IAAYC,UAAMC;mCAELC,IAAAA,qBAA2B;mCACxCP,IAAAA,qBAA+B;kCACjCQ,IAAAC,kCAAA;;UAEDT,aAAAA,MAAAA,UAAAA,IAAAA;UAAqB,EAGxBU,aAAA,EACAL,aAAMM,yCAEEX;0BACEY,aAAAA,QAAAA,aAAAA,KAAAA,IAAAA,WAAAA,OAAAA,SAAAA,aAAAA,KAAAA,iBAAAA;6BAGChB,yCACHgB;sBAIGP,OAAIQ,WAAQC,CAAOC,CAAAA;uBACtBR,mBAAIS,IAAAA,GAAAA,GAAAA,KAAiDH,mBAAAA,EAAQC;iCACpDG,OAAOA,GAAIpB;;;;KAEpB;qHACiBmB;oBACnB,CAAA;iCAEAF,OAAA,EAAA;;sFAEEF;wCACAZ;iCACCa,QAAAC,OAAA;mBACL,IAAAD,QAAAC,OAAA,IAAAjB,uBAAA;gBAEA,IAAAmB,iBAAAH,QAAAC,OAAA;gBACAjB,IAAAA,IAAAA,IAAAA,GAAAA,IAAAA,sBAAgCD,OAAAA,IAAAA,gBAA4BsB,IAAAA;oBAE9DF,iBAAAG,kBAAAH;gBACA;gBAACpB,iBAAAA;;2JAAsCI;YAAqBN,WAAA;gBAG9DkB,mBAA4C,QAAAA,mBAAA,KAAA,IAAA,KAAA,IAAAA,eAAAQ,KAAA;gBAC1CrB,qBAAAA,OAAAA,GAAAA;eACAsB;;4JAGQ;8BACRP,OAAA,GAAAlB,wBAAA,IAAAsB;8DAIgCI;;;QACpBZ;QAAAV;KAAA;UACVuB,QACA;;oCAEctB,iBAAAA;oBACZ;kBACAuB;;QAGNC,MAAAC,qBAAA,CAAAC,MAAA,CAAAC,IAAAA,yCAAA,EAAA,UAAA;YAEAL,KAAME,IAAAA,8BAAc,EAAAZ,SAAGgB;YAEvB,GAAApC,KAAO8B;QACP,IAAA"}
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, maxVisibleReferences, referenceListRef, totalReferencesCount, triggeredViaKeyboard } =\n useReferenceListContext_unstable(ctx => ({\n areReferencesExpanded: ctx.areReferencesExpanded,\n maxVisibleReferences: ctx.maxVisibleReferences,\n referenceListRef: ctx.referenceListRef,\n totalReferencesCount: ctx.totalReferencesCount,\n triggeredViaKeyboard: ctx.overflowButtonTriggeredViaKeyboard,\n }));\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","referenceListRef","ctx","totalReferencesCount","maxVisibleReferences","isOverflowing","processedText","findFirstFocusable","triggeredViaKeyboard","React","Space","overflowButtonTriggeredViaKeyboard","useEffect","undefined","text","overflowCount","elementToFocus","previousOverflow","current","Enter","rootRef","positionToFocus","i","currentElement","useRef","findNextFocusable","focus","shouldRenderOverflowButton","setTimeout","state","getIntrinsicElementProps","defaultProps","elementType"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BA2BEA;;;eAAAA;;;;iEA3BqB;8BACM;iCAQtB;gCACoB;sCACsB;AAgB/C,MAAAA,sCAAA,CAAAC,OAAAC;;UAMA,EAEAC,QAAQC;oBAIJC,OAAAA,MAAkBC,CAAAA;sBAClBC,GAAAA,IAAAA,0BAAAA;iCAEF,EAEFC,oBAAQC,EAERJ,gBAAMK,EAENH,oBAAQI,EACRC,oBAAkBC,+DAEgB,EAAAP,CAAAA,MAAKQ,CAAAA;mCACjCF,IAAAA,qBAA+B;kCACjCN,IAAAE,oBAAA;YACFH,kBACAC,IAAAD,gBAAA;kCAACO,IAAAA,oBAAAA;kCAAqBN,IAAAS,kCAAA;;UAIxB,EAEAN,aAAA,EACAI,aAAMG,yCACJ;UACAN,gBAAIF,aAAyBS,QAAAA,aAAaL,KAAAA,IAAAA,WAA4B,OAAEM,SAAA,aAAAA,KAAAC,iBAAAD;8BAGtE,mBACKd,yCACHgB;sBACAC,OAAAA,WAAiBC,CAAAA,CAAAA;kBACnB,KAKKC,mBAAIC,IAAAA,GAAQF,GAAAA,KAAOR,mBAAIT,EAAAA;iCACpBoB,OAAAA,GAAAA;;;;KAMGC;8IAC4BC;6BACrCd,OAAAe,MAAA,CAAA;oHAEiBD;oBACnB,CAAA;uHAEA;qCACWV,aAAAL,qBAAAU,OAAA,EAAA;;qFAEsB;wCAC9B;gBACLF,iBAAAI,QAAAF,OAAA;gBACCD,iBAAAC,OAAA,GAAAH;mBACDf,IAAAA,QAAAA,OAAAA,IAAAA,iBAAAA,OAAAA,EAAAA;gBACAO,MAAAA,kBAAAA,uBAAAA,uBAAAA,iBAAAA,OAAAA,GAAAA,uBAAAA,uBAAAA,iBAAAA,OAAAA;gBACAkB,IAAAA,iBAAAA,mBAAAA,iBAAAA,OAAAA;gBACApB,IAAAA,IAAAA,IAAAA,GAAAA,IAAAA,mBAAAA,gBAAAA,IAAAA;oBACAD,iBAAAA,kBAAAA;gBACAW;gBACAd,iBAAAA;;2JAEAE;uBACAK;gBACDQ,mBAAA,QAAAA,mBAAA,KAAA,IAAA,KAAA,IAAAA,eAAAU,KAAA;gBAEDlB,qBAA4CU,OAAA,GAAA;eAC1CS;;;;QAGQpB;QAAAkB;QAAApB;QAAAD;QAAAW;QAAAd;QAAA2B;QAAAzB;QAAAK;KAAA;UACRqB,QAAA;oCAGEC,iBAAAA;oBACEhC;kBACA;;mCAGAiC,CAAAA,MAAAA,CAAAA,IAAAA,yCAAc,EAAA,UAAA;mDACZhC,EAAAA,SAAUO;oBACZ;;0BAEF;gBAEJP,UAAAO;YAEAuB;YAEAG,aAAOH;QACP"}
@@ -27,39 +27,9 @@ const referenceOverflowButtonClassNames = {
27
27
  ".rbsq19a:hover{background-color:var(--colorNeutralBackground3Hover);border-color:var(--colorNeutralStroke1Hover);color:var(--colorNeutralForeground2Hover);}",
28
28
  ".rbsq19a:hover:active{background-color:var(--colorNeutralBackground3Pressed);border-color:var(--colorNeutralStroke1Pressed);color:var(--colorNeutralForeground2Pressed);}"
29
29
  ]);
30
- const useRootStyles = (0, _reactcomponents.__styles)({
31
- darker: {
32
- De3pzq: "f3vzo32",
33
- g2u3we: "fj3muxo",
34
- h3c5rm: [
35
- "f1akhkt",
36
- "f1lxtadh"
37
- ],
38
- B9xav0g: "f1aperda",
39
- zhjwy3: [
40
- "f1lxtadh",
41
- "f1akhkt"
42
- ],
43
- Jwef8y: "f14vf7cg",
44
- iro3zm: "fho4vwd"
45
- }
46
- }, {
47
- d: [
48
- ".f3vzo32{background-color:var(--colorNeutralBackground5);}",
49
- ".fj3muxo{border-top-color:var(--colorNeutralStroke1);}",
50
- ".f1akhkt{border-right-color:var(--colorNeutralStroke1);}",
51
- ".f1lxtadh{border-left-color:var(--colorNeutralStroke1);}",
52
- ".f1aperda{border-bottom-color:var(--colorNeutralStroke1);}"
53
- ],
54
- h: [
55
- ".f14vf7cg:hover{background-color:var(--colorNeutralBackground5Hover);}",
56
- ".fho4vwd:hover:active{background-color:var(--colorNeutralBackground5Pressed);}"
57
- ]
58
- });
59
30
  const useReferenceOverflowButtonStyles_unstable = (state)=>{
60
- const { appearance } = state;
31
+ 'use no memo';
61
32
  const rootBaseClassName = useRootBaseClassName();
62
- const rootStyles = useRootStyles();
63
- state.root.className = (0, _reactcomponents.mergeClasses)(referenceOverflowButtonClassNames.root, rootBaseClassName, appearance === 'darker' && rootStyles.darker, state.root.className);
33
+ state.root.className = (0, _reactcomponents.mergeClasses)(referenceOverflowButtonClassNames.root, rootBaseClassName, state.root.className);
64
34
  return state;
65
35
  }; //# sourceMappingURL=useReferenceOverflowButtonStyles.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["useReferenceOverflowButtonStyles.styles.ts"],"sourcesContent":["import {\n makeResetStyles,\n makeStyles,\n mergeClasses,\n shorthands,\n tokens,\n typographyStyles,\n} from '@fluentui/react-components';\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 backgroundColor: tokens.colorNeutralBackground3,\n border: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke2}`,\n borderRadius: tokens.borderRadiusMedium,\n color: tokens.colorNeutralForeground2,\n display: 'inline-flex',\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 useRootStyles = makeStyles({\n darker: {\n backgroundColor: tokens.colorNeutralBackground5,\n ...shorthands.borderColor(tokens.colorNeutralStroke1),\n\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground5Hover,\n },\n\n ':hover:active': {\n backgroundColor: tokens.colorNeutralBackground5Pressed,\n },\n },\n});\n\n/**\n * Apply styling to the ReferenceOverflowButton slots based on the state\n */\nexport const useReferenceOverflowButtonStyles_unstable = (\n state: ReferenceOverflowButtonState,\n): ReferenceOverflowButtonState => {\n const { appearance } = state;\n\n const rootBaseClassName = useRootBaseClassName();\n const rootStyles = useRootStyles();\n\n state.root.className = mergeClasses(\n referenceOverflowButtonClassNames.root,\n rootBaseClassName,\n appearance === 'darker' && rootStyles.darker,\n state.root.className,\n );\n\n return state;\n};\n"],"names":["referenceOverflowButtonClassNames","useRootStyles","root","backgroundColor","colorNeutralBackground3","border","strokeWidthThin","borderRadius","color","tokens","display","padding","spacingVerticalXXS","B9xav0g","typographyStyles","zhjwy3","borderColor","state","darker","rootBaseClassName","useRootBaseClassName","className","mergeClasses","appearance","rootStyles"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAWaA,iCAAAA;eAAAA;;IA6BPC,yCAA2B;eAA3BA;;;iCAlCY;AAKX,MAAMD,oCAAkF;UAC7FE;AACF;AAEA;;CAEC,SAECC,uBAAwBC,IAAAA,8BAAAA,EAAAA,WAAuB,MAAA;IAAA;IAAA;IAAA;CAAA;MAC/CC,gBAAkBC,IAAAA,yBAAAA,EAAAA;YAClBC;QACAC,QAAOC;QACPC,QAAAA;QACAC,QAAAA;YAAS;YAAUC;SAAAA;QACnBC,SAAGC;QAEHC,QAAA;YAAA;YAAU;SAAA;gBACRZ;gBACAa;;;OAIF;QAAA;QAAiB;QAAA;QAAA;QAAA;KAAA;;;QACuC;KAAA;;AAMpDf,MAAAA,4CAA2BgB,CAAAA;UAC/BC,YACEf;UAGAgB,oBAAUC;uBACRjB;UACFD,IAAA,CAAAmB,SAAA,GAAAC,IAAAA,6BAAA,EAAAtB,kCAAAE,IAAA,EAAAiB,mBAAAI,eAAA,YAAAC,WAAAN,MAAA,EAAAD,MAAAf,IAAA,CAAAmB,SAAA;WAEAJ;sEAEA"}
1
+ {"version":3,"sources":["useReferenceOverflowButtonStyles.styles.ts"],"sourcesContent":["import { makeResetStyles, mergeClasses, tokens, typographyStyles } from '@fluentui/react-components';\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 backgroundColor: tokens.colorNeutralBackground3,\n border: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke2}`,\n borderRadius: tokens.borderRadiusMedium,\n color: tokens.colorNeutralForeground2,\n display: 'inline-flex',\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\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 rootBaseClassName = useRootBaseClassName();\n\n state.root.className = mergeClasses(referenceOverflowButtonClassNames.root, rootBaseClassName, state.root.className);\n\n return state;\n};\n"],"names":["referenceOverflowButtonClassNames","useReferenceOverflowButtonStyles_unstable","root","backgroundColor","colorNeutralBackground3","display","state","rootBaseClassName","useRootBaseClassName","tokens","colorNeutralBackground3Hover","className","borderColor"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAIaA,iCAAAA;eAAAA;;IAYFC,yCAAA;eAAAA;;;iCAhBqD;AAIzD,MAAMD,oCAAkF;UAC7FE;AACF;AAEA;;CAEC,SAECC,uBAAwBC,IAAAA,8BAAAA,EAAAA,WAAuB,MAAA;IAAA;IAAA;IAAA;CAAA;AAI/CC,MAASJ,4CAAAK,CAAAA;;UAITC,oBAAUC;UACRL,IAAAA,CAAAA,SAAAA,GAAiBM,IAAAA,6BAAOC,EAAAA,kCAA4BR,IAAA,EAAAK,mBAAAD,MAAAJ,IAAA,CAAAS,SAAA;WACpDC;sEAEF"}
@@ -22,15 +22,16 @@ _export(exports, {
22
22
  const _reactcontextselector = require("@fluentui/react-context-selector");
23
23
  const ReferenceListContext = (0, _reactcontextselector.createContext)(undefined);
24
24
  const referenceListContextDefaultValue = {
25
- appearance: 'lighter',
26
25
  areReferencesExpanded: false,
26
+ maxVisibleReferences: undefined,
27
27
  overflowButtonTriggeredViaKeyboard: {
28
28
  current: false
29
29
  },
30
- previousOverflowCount: {
31
- current: 0
30
+ referenceListRef: {
31
+ current: null
32
32
  },
33
- shouldUseOverflow: false
33
+ shouldUseOverflow: false,
34
+ totalReferencesCount: 0
34
35
  };
35
36
  const ReferenceListContextProvider = ReferenceListContext.Provider;
36
37
  const useReferenceListContext_unstable = (selector)=>(0, _reactcontextselector.useContextSelector)(ReferenceListContext, (ctx = referenceListContextDefaultValue)=>selector(ctx)); //# sourceMappingURL=referenceListContext.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["referenceListContext.ts"],"sourcesContent":["import { createContext, useContextSelector } from '@fluentui/react-context-selector';\nimport type { Context, ContextSelector } from '@fluentui/react-context-selector';\nimport type { ReferenceListState } from '../../ReferenceListV2';\n\n/**\n * Context shared between ReferenceList and its children components\n */\nexport type ReferenceListContextValue = Pick<\n ReferenceListState,\n | 'appearance'\n | 'areReferencesExpanded'\n | 'overflowButtonTriggeredViaKeyboard'\n | 'previousOverflowCount'\n | 'shouldUseOverflow'\n>;\n\nexport const ReferenceListContext: Context<ReferenceListContextValue> = createContext<\n ReferenceListContextValue | undefined\n>(undefined) as Context<ReferenceListContextValue>;\n\nconst referenceListContextDefaultValue: ReferenceListContextValue = {\n appearance: 'lighter',\n areReferencesExpanded: false,\n overflowButtonTriggeredViaKeyboard: { current: false },\n previousOverflowCount: { current: 0 },\n shouldUseOverflow: false,\n};\n\nexport const ReferenceListContextProvider = ReferenceListContext.Provider;\n\nexport const useReferenceListContext_unstable = <T>(selector: ContextSelector<ReferenceListContextValue, T>) =>\n useContextSelector(ReferenceListContext, (ctx = referenceListContextDefaultValue) => selector(ctx));\n"],"names":["ReferenceListContext","ReferenceListContextProvider","useReferenceListContext_unstable","createContext","undefined","referenceListContextDefaultValue","appearance","areReferencesExpanded","overflowButtonTriggeredViaKeyboard","current","previousOverflowCount","shouldUseOverflow","Provider","selector","useContextSelector","ctx"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAgBaA,oBAAAA;eAAAA;;IAYAC,4BAAAA;eAAAA;;IAEAC,gCAAAA;eAAAA;;;sCA9BqC;AAgB3C,MAAMF,uBAA2DG,IAAAA,mCAAAA,EAEtEC;AAEF,MAAMC,mCAA8D;gBAClEC;2BACAC;wCACAC;iBAAsCC;;2BACtCC;iBAAyBD;;uBACzBE;AACF;AAEO,MAAMV,+BAA+BD,qBAAqBY,QAAQ;AAElE,MAAMV,mCAAmCW,CAAAA,WAC9CC,IAAAA,wCAAAA,EAAmBd,sBAAsB,CAACe,MAAMV,gCAAgC,GAAKQ,SAASE"}
1
+ {"version":3,"sources":["referenceListContext.ts"],"sourcesContent":["import { createContext, useContextSelector } from '@fluentui/react-context-selector';\nimport type { Context, ContextSelector } from '@fluentui/react-context-selector';\nimport type { ReferenceListState } from '../../ReferenceListV2';\n\n/**\n * Context shared between ReferenceList and its children components\n */\nexport type ReferenceListContextValue = Pick<\n ReferenceListState,\n | 'areReferencesExpanded'\n | 'maxVisibleReferences'\n | 'overflowButtonTriggeredViaKeyboard'\n | 'referenceListRef'\n | 'shouldUseOverflow'\n | 'totalReferencesCount'\n>;\n\nexport const ReferenceListContext: Context<ReferenceListContextValue> = createContext<\n ReferenceListContextValue | undefined\n>(undefined) as Context<ReferenceListContextValue>;\n\nconst referenceListContextDefaultValue: ReferenceListContextValue = {\n areReferencesExpanded: false,\n maxVisibleReferences: undefined,\n overflowButtonTriggeredViaKeyboard: { current: false },\n referenceListRef: { current: null },\n shouldUseOverflow: false,\n totalReferencesCount: 0,\n};\n\nexport const ReferenceListContextProvider = ReferenceListContext.Provider;\n\nexport const useReferenceListContext_unstable = <T>(selector: ContextSelector<ReferenceListContextValue, T>) =>\n useContextSelector(ReferenceListContext, (ctx = referenceListContextDefaultValue) => selector(ctx));\n"],"names":["ReferenceListContext","ReferenceListContextProvider","useReferenceListContext_unstable","createContext","undefined","referenceListContextDefaultValue","areReferencesExpanded","maxVisibleReferences","overflowButtonTriggeredViaKeyboard","current","referenceListRef","shouldUseOverflow","totalReferencesCount","Provider","selector","useContextSelector","ctx"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAiBaA,oBAAAA;eAAAA;;IAaAC,4BAAAA;eAAAA;;IAEAC,gCAAAA;eAAAA;;;sCAhCqC;AAiB3C,MAAMF,uBAA2DG,IAAAA,mCAAAA,EAEtEC;AAEF,MAAMC,mCAA8D;2BAClEC;0BACAC;wCACAC;iBAAsCC;;sBACtCC;iBAAoBD;;uBACpBE;0BACAC;AACF;AAEO,MAAMX,+BAA+BD,qBAAqBa,QAAQ;AAElE,MAAMX,mCAAmCY,CAAAA,WAC9CC,IAAAA,wCAAAA,EAAmBf,sBAAsB,CAACgB,MAAMX,gCAAgC,GAAKS,SAASE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui-copilot/react-reference",
3
- "version": "0.0.0-nightly-20240527-0406-162a35f3.1",
3
+ "version": "0.0.0-nightly-20240531-0407-49d6b52e.1",
4
4
  "description": "Fluent AI controls for citations and references",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -12,9 +12,9 @@
12
12
  },
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@fluentui-copilot/react-preview": "0.0.0-nightly-20240527-0406-162a35f3.1",
16
- "@fluentui-copilot/react-provider": "0.0.0-nightly-20240527-0406-162a35f3.1",
17
- "@fluentui-copilot/react-sensitivity-label": "0.0.0-nightly-20240527-0406-162a35f3.1",
15
+ "@fluentui-copilot/react-preview": "0.0.0-nightly-20240531-0407-49d6b52e.1",
16
+ "@fluentui-copilot/react-provider": "0.0.0-nightly-20240531-0407-49d6b52e.1",
17
+ "@fluentui-copilot/react-sensitivity-label": "0.0.0-nightly-20240531-0407-49d6b52e.1",
18
18
  "@swc/helpers": "^0.5.1"
19
19
  },
20
20
  "peerDependencies": {