@fluentui-copilot/react-reference 0.11.0 → 0.11.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.
- package/CHANGELOG.json +22 -1
- package/CHANGELOG.md +12 -2
- package/dist/index.d.ts +219 -0
- package/lib/Citation.js.map +1 -1
- package/lib/Reference.js.map +1 -1
- package/lib/ReferenceGroupToggle.js.map +1 -1
- package/lib/ReferenceList.js.map +1 -1
- package/lib/ReferenceListV2.js +2 -0
- package/lib/ReferenceListV2.js.map +1 -0
- package/lib/ReferenceOverflowButton.js +2 -0
- package/lib/ReferenceOverflowButton.js.map +1 -0
- package/lib/ReferenceV2.js +2 -0
- package/lib/ReferenceV2.js.map +1 -0
- package/lib/components/Citation/Citation.js.map +1 -1
- package/lib/components/Citation/Citation.types.js +3 -1
- package/lib/components/Citation/Citation.types.js.map +1 -1
- package/lib/components/Citation/index.js.map +1 -1
- package/lib/components/Citation/renderCitation.js.map +1 -1
- package/lib/components/Citation/useCitation.js.map +1 -1
- package/lib/components/Citation/useCitationStyles.js.map +1 -1
- package/lib/components/Reference/Reference.js.map +1 -1
- package/lib/components/Reference/Reference.types.js +3 -1
- package/lib/components/Reference/Reference.types.js.map +1 -1
- package/lib/components/Reference/index.js.map +1 -1
- package/lib/components/Reference/renderReference.js.map +1 -1
- package/lib/components/Reference/useReference.js +1 -1
- package/lib/components/Reference/useReference.js.map +1 -1
- package/lib/components/Reference/useReferenceStyles.js.map +1 -1
- package/lib/components/ReferenceGroupToggle/ReferenceGroupToggle.js.map +1 -1
- package/lib/components/ReferenceGroupToggle/ReferenceGroupToggle.types.js +3 -1
- package/lib/components/ReferenceGroupToggle/ReferenceGroupToggle.types.js.map +1 -1
- package/lib/components/ReferenceGroupToggle/index.js.map +1 -1
- package/lib/components/ReferenceGroupToggle/renderReferenceGroupToggle.js.map +1 -1
- package/lib/components/ReferenceGroupToggle/useReferenceGroupToggle.js.map +1 -1
- package/lib/components/ReferenceGroupToggle/useReferenceGroupToggleStyles.js.map +1 -1
- package/lib/components/ReferenceList/ReferenceList.js.map +1 -1
- package/lib/components/ReferenceList/ReferenceList.types.js +3 -1
- package/lib/components/ReferenceList/ReferenceList.types.js.map +1 -1
- package/lib/components/ReferenceList/index.js.map +1 -1
- package/lib/components/ReferenceList/renderReferenceList.js.map +1 -1
- package/lib/components/ReferenceList/useReferenceList.js.map +1 -1
- package/lib/components/ReferenceList/useReferenceListStyles.js.map +1 -1
- package/lib/components/reference-v2/Reference/Reference.js +11 -0
- package/lib/components/reference-v2/Reference/Reference.js.map +1 -0
- package/lib/components/reference-v2/Reference/Reference.types.js +2 -0
- package/lib/components/reference-v2/Reference/Reference.types.js.map +1 -0
- package/lib/components/reference-v2/Reference/index.js +6 -0
- package/lib/components/reference-v2/Reference/index.js.map +1 -0
- package/lib/components/reference-v2/Reference/renderReference.js +19 -0
- package/lib/components/reference-v2/Reference/renderReference.js.map +1 -0
- package/lib/components/reference-v2/Reference/useReference.js +72 -0
- package/lib/components/reference-v2/Reference/useReference.js.map +1 -0
- package/lib/components/reference-v2/Reference/useReferenceStyles.js +71 -0
- package/lib/components/reference-v2/Reference/useReferenceStyles.js.map +1 -0
- package/lib/components/reference-v2/ReferenceList/ReferenceList.js +13 -0
- package/lib/components/reference-v2/ReferenceList/ReferenceList.js.map +1 -0
- package/lib/components/reference-v2/ReferenceList/ReferenceList.types.js +2 -0
- package/lib/components/reference-v2/ReferenceList/ReferenceList.types.js.map +1 -0
- package/lib/components/reference-v2/ReferenceList/index.js +6 -0
- package/lib/components/reference-v2/ReferenceList/index.js.map +1 -0
- package/lib/components/reference-v2/ReferenceList/renderReferenceList.js +18 -0
- package/lib/components/reference-v2/ReferenceList/renderReferenceList.js.map +1 -0
- package/lib/components/reference-v2/ReferenceList/useReferenceList.js +94 -0
- package/lib/components/reference-v2/ReferenceList/useReferenceList.js.map +1 -0
- package/lib/components/reference-v2/ReferenceList/useReferenceListContextValues.js +21 -0
- package/lib/components/reference-v2/ReferenceList/useReferenceListContextValues.js.map +1 -0
- package/lib/components/reference-v2/ReferenceList/useReferenceListStyles.js +39 -0
- package/lib/components/reference-v2/ReferenceList/useReferenceListStyles.js.map +1 -0
- package/lib/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.js +12 -0
- package/lib/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.js.map +1 -0
- package/lib/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.types.js +4 -0
- package/lib/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.types.js.map +1 -0
- package/lib/components/reference-v2/ReferenceOverflowButton/index.js +6 -0
- package/lib/components/reference-v2/ReferenceOverflowButton/index.js.map +1 -0
- package/lib/components/reference-v2/ReferenceOverflowButton/renderReferenceOverflowButton.js +10 -0
- package/lib/components/reference-v2/ReferenceOverflowButton/renderReferenceOverflowButton.js.map +1 -0
- package/lib/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js +91 -0
- package/lib/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js.map +1 -0
- package/lib/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButtonStyles.js +35 -0
- package/lib/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButtonStyles.js.map +1 -0
- package/lib/components/reference-v2/index.js +4 -0
- package/lib/components/reference-v2/index.js.map +1 -0
- package/lib/{context → contexts}/ReferenceGroupContext.js.map +1 -1
- package/lib/contexts/reference-v2/index.js +2 -0
- package/lib/contexts/reference-v2/index.js.map +1 -0
- package/lib/contexts/reference-v2/referenceListContext.js +16 -0
- package/lib/contexts/reference-v2/referenceListContext.js.map +1 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/reference-v2/index.js +2 -0
- package/lib/hooks/reference-v2/index.js.map +1 -0
- package/lib/hooks/reference-v2/useReferenceCitationPreview.js +120 -0
- package/lib/hooks/reference-v2/useReferenceCitationPreview.js.map +1 -0
- package/lib/hooks/useReferenceCitationPreview.js.map +1 -1
- package/lib/hooks/useReferenceGroup.js.map +1 -1
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -1
- package/lib-commonjs/Citation.js.map +1 -1
- package/lib-commonjs/Reference.js.map +1 -1
- package/lib-commonjs/ReferenceGroupToggle.js.map +1 -1
- package/lib-commonjs/ReferenceList.js.map +1 -1
- package/lib-commonjs/ReferenceListV2.js +7 -0
- package/lib-commonjs/ReferenceListV2.js.map +1 -0
- package/lib-commonjs/ReferenceOverflowButton.js +7 -0
- package/lib-commonjs/ReferenceOverflowButton.js.map +1 -0
- package/lib-commonjs/ReferenceV2.js +7 -0
- package/lib-commonjs/ReferenceV2.js.map +1 -0
- package/lib-commonjs/components/Citation/Citation.js.map +1 -1
- package/lib-commonjs/components/Citation/Citation.types.js +3 -1
- package/lib-commonjs/components/Citation/Citation.types.js.map +1 -1
- package/lib-commonjs/components/Citation/index.js.map +1 -1
- package/lib-commonjs/components/Citation/renderCitation.js.map +1 -1
- package/lib-commonjs/components/Citation/useCitation.js.map +1 -1
- package/lib-commonjs/components/Citation/useCitationStyles.js.map +1 -1
- package/lib-commonjs/components/Reference/Reference.js.map +1 -1
- package/lib-commonjs/components/Reference/Reference.types.js +3 -1
- package/lib-commonjs/components/Reference/Reference.types.js.map +1 -1
- package/lib-commonjs/components/Reference/index.js.map +1 -1
- package/lib-commonjs/components/Reference/renderReference.js.map +1 -1
- package/lib-commonjs/components/Reference/useReference.js +1 -1
- package/lib-commonjs/components/Reference/useReference.js.map +1 -1
- package/lib-commonjs/components/Reference/useReferenceStyles.js.map +1 -1
- package/lib-commonjs/components/ReferenceGroupToggle/ReferenceGroupToggle.js.map +1 -1
- package/lib-commonjs/components/ReferenceGroupToggle/ReferenceGroupToggle.types.js +3 -1
- package/lib-commonjs/components/ReferenceGroupToggle/ReferenceGroupToggle.types.js.map +1 -1
- package/lib-commonjs/components/ReferenceGroupToggle/index.js.map +1 -1
- package/lib-commonjs/components/ReferenceGroupToggle/renderReferenceGroupToggle.js.map +1 -1
- package/lib-commonjs/components/ReferenceGroupToggle/useReferenceGroupToggle.js.map +1 -1
- package/lib-commonjs/components/ReferenceGroupToggle/useReferenceGroupToggleStyles.js.map +1 -1
- package/lib-commonjs/components/ReferenceList/ReferenceList.js.map +1 -1
- package/lib-commonjs/components/ReferenceList/ReferenceList.types.js +3 -1
- package/lib-commonjs/components/ReferenceList/ReferenceList.types.js.map +1 -1
- package/lib-commonjs/components/ReferenceList/index.js.map +1 -1
- package/lib-commonjs/components/ReferenceList/renderReferenceList.js.map +1 -1
- package/lib-commonjs/components/ReferenceList/useReferenceList.js.map +1 -1
- package/lib-commonjs/components/ReferenceList/useReferenceListStyles.js.map +1 -1
- package/lib-commonjs/components/reference-v2/Reference/Reference.js +21 -0
- package/lib-commonjs/components/reference-v2/Reference/Reference.js.map +1 -0
- package/lib-commonjs/components/reference-v2/Reference/Reference.types.js +5 -0
- package/lib-commonjs/components/reference-v2/Reference/Reference.types.js.map +1 -0
- package/lib-commonjs/components/reference-v2/Reference/index.js +28 -0
- package/lib-commonjs/components/reference-v2/Reference/index.js.map +1 -0
- package/lib-commonjs/components/reference-v2/Reference/renderReference.js +32 -0
- package/lib-commonjs/components/reference-v2/Reference/renderReference.js.map +1 -0
- package/lib-commonjs/components/reference-v2/Reference/useReference.js +67 -0
- package/lib-commonjs/components/reference-v2/Reference/useReference.js.map +1 -0
- package/lib-commonjs/components/reference-v2/Reference/useReferenceStyles.js +122 -0
- package/lib-commonjs/components/reference-v2/Reference/useReferenceStyles.js.map +1 -0
- package/lib-commonjs/components/reference-v2/ReferenceList/ReferenceList.js +23 -0
- package/lib-commonjs/components/reference-v2/ReferenceList/ReferenceList.js.map +1 -0
- package/lib-commonjs/components/reference-v2/ReferenceList/ReferenceList.types.js +5 -0
- package/lib-commonjs/components/reference-v2/ReferenceList/ReferenceList.types.js.map +1 -0
- package/lib-commonjs/components/reference-v2/ReferenceList/index.js +11 -0
- package/lib-commonjs/components/reference-v2/ReferenceList/index.js.map +1 -0
- package/lib-commonjs/components/reference-v2/ReferenceList/renderReferenceList.js +28 -0
- package/lib-commonjs/components/reference-v2/ReferenceList/renderReferenceList.js.map +1 -0
- package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceList.js +93 -0
- package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceList.js.map +1 -0
- package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceListContextValues.js +24 -0
- package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceListContextValues.js.map +1 -0
- package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceListStyles.js +55 -0
- package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceListStyles.js.map +1 -0
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.js +21 -0
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.js.map +1 -0
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.types.js +7 -0
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.types.js.map +1 -0
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/index.js +11 -0
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/index.js.map +1 -0
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/renderReferenceOverflowButton.js +16 -0
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/renderReferenceOverflowButton.js.map +1 -0
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js +84 -0
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js.map +1 -0
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButtonStyles.js +65 -0
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButtonStyles.js.map +1 -0
- package/lib-commonjs/components/reference-v2/index.js +9 -0
- package/lib-commonjs/components/reference-v2/index.js.map +1 -0
- package/lib-commonjs/contexts/ReferenceGroupContext.js.map +1 -0
- package/lib-commonjs/contexts/reference-v2/index.js +7 -0
- package/lib-commonjs/contexts/reference-v2/index.js.map +1 -0
- package/lib-commonjs/contexts/reference-v2/referenceListContext.js +36 -0
- package/lib-commonjs/contexts/reference-v2/referenceListContext.js.map +1 -0
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/reference-v2/index.js +7 -0
- package/lib-commonjs/hooks/reference-v2/index.js.map +1 -0
- package/lib-commonjs/hooks/reference-v2/useReferenceCitationPreview.js +148 -0
- package/lib-commonjs/hooks/reference-v2/useReferenceCitationPreview.js.map +1 -0
- package/lib-commonjs/hooks/useReferenceCitationPreview.js.map +1 -1
- package/lib-commonjs/hooks/useReferenceGroup.js.map +1 -1
- package/lib-commonjs/index.js +95 -30
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +11 -11
- package/lib-commonjs/context/ReferenceGroupContext.js.map +0 -1
- /package/lib/{context → contexts}/ReferenceGroupContext.js +0 -0
- /package/lib-commonjs/{context → contexts}/ReferenceGroupContext.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useReferenceList.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n getIntrinsicElementProps,\n mergeCallbacks,\n mergeClasses,\n slot,\n useArrowNavigationGroup,\n} from '@fluentui/react-components';\nimport type { ReferenceListProps, ReferenceListState } from './ReferenceList.types';\nimport { useRootStyles as useReferenceStyles } from '../Reference/useReferenceStyles';\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 { appearance = 'lighter', children, maxVisibleReferences, showLessButton, showMoreButton, ...rest } = props;\n\n const [areReferencesExpanded, setAreReferencesExpanded] = React.useState(false);\n\n const referenceInOverflowClassName = useReferenceStyles().overflow;\n const resolvedChildren = React.useMemo(() => {\n if (maxVisibleReferences !== undefined && !areReferencesExpanded) {\n const results = [];\n const childrenArray = React.Children.toArray(children);\n for (let index = 0; index < childrenArray.length; index++) {\n const child = childrenArray[index] as React.ReactElement;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if (index >= maxVisibleReferences && React.isValidElement<any>(child)) {\n results.push(\n React.cloneElement(child, {\n ...child.props,\n className: mergeClasses(child.props.className, referenceInOverflowClassName),\n }),\n );\n } else {\n results.push(child);\n }\n }\n return results;\n }\n\n return children;\n }, [areReferencesExpanded, children, maxVisibleReferences, referenceInOverflowClassName]);\n\n // We keep track of the previous overflow count to determine element to move focus to when expanding the references via keyboard.\n const previousOverflowCount = React.useRef(0);\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 = maxVisibleReferences !== undefined && !areReferencesExpanded;\n\n const state: ReferenceListState = {\n appearance,\n areReferencesExpanded,\n overflowButtonTriggeredViaKeyboard,\n previousOverflowCount,\n shouldUseOverflow,\n\n components: {\n root: 'div',\n showMoreButton: 'span',\n showLessButton: 'span',\n },\n root: slot.always(\n getIntrinsicElementProps('div', {\n ref,\n ...focusAttributes,\n ...rest,\n children: resolvedChildren,\n }),\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":["appearance","children","maxVisibleReferences","referenceInOverflowClassName","resolvedChildren","results","childrenArray","setAreReferencesExpanded","React","useState","isValidElement","cloneElement","props","areReferencesExpanded","className","Children","toArray","index","length","child","push","previousOverflowCount","useArrowNavigationGroup","circular","useRef","memorizeCurrent","axis","onShowMoreButtonClick","onShowLessButtonClick","useCallback","overflowButtonTriggeredViaKeyboard","showLessButton","always","ref","rest","getIntrinsicElementProps","focusAttributes","elementType","showMoreButton","optional","undefined","slot","state","onClick","mergeCallbacks"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAwBUA;;;eAAAA;;;;iEAxBa;iCAOhB;oCAE6C;AAelD,MAAQA,4BAAwBC,CAAAA,OAAUC;UAE1C,EAEAF,aAAMG,SAAAA,EACNF,QAAMG,sBACAF,gBACIG,gBACAC;kCAGJC,yBAAA,GAAAC,OAAAC,QAAA,CAAA;yCACaP,IAAAA,iCAAwBM,IAAME,QAAAA;6BACzCL,OACEG,OAAMG,CAAAA;qCACKC,aAAK,CAAAC,uBAAA;8BACdC;kCACFN,OAAAO,QAAA,CAAAC,OAAA,CAAAf;4BAEG,GAAAgB,QAAAX,cAAAY,MAAA,EAAAD,QAAA;8BACLZ,aAAac,CAAAA,MAAAA;8EACf;oBACFF,SAAAf,sCAAAM,OAAAE,cAAA,CAAAS,QAAA;4BACAC,IAAOf,eAAAA,OAAAA,YAAAA,CAAAA,OAAAA;wBACT,GAAAc,MAAAP,KAAA;wBAEAE,WAAOb,IAAAA,6BAAAA,EAAAA,MAAAA,KAAAA,CAAAA,SAAAA,EAAAA;oBACN;gBAACY,OAAAA;oBAAuBZ,QAAAA,IAAAA,CAAAA;gBAAUC;;YAAmD,OAAAG;QAExF;QACA,OAAMgB;OAEN;QAAAR;QAAAZ;QAAAC;QAAAC;KAAA;qIACwD;UAExDkB,wBAAwBC,OAAAA,MAAAA,CAAAA;gGAChB;UACNC,qCAAUf,OAAAgB,MAAA,CAAA;UACVC,kBAAiBH,IAAAA,wCAAA,EAAA;QACnBI,MAAA;QAEAH,UAAMI;yBACJpB;;UAGFoB,wBAAMC,OAAwBpB,WAAMqB,CAAAA;iCAClCtB;OACF,EAAG;UAEHqB,wBAA0B1B,OAAAA,WAAAA,CAAAA;QAE1BK,yBAAkC;;UAEhCM,oBAAAA,yBAAAA,aAAAA,CAAAA;UACAiB,QAAAA;;;;;;oBAOEC;kBACF;4BACWC;4BAEPC;;mCAEA,CAAGC,MAAI,CAAAC,IAAAA,yCAAA,EAAA,OAAA;;eAETC,eACA;mBAAEC;sBAAmBjC;YAEvBkC;yBAAoED;;wBACpEN,oBAAgBlB,qBAAAA,CAAAA,QAA6B0B,CAAAA,gBAASR;yBAAkBM;aAAoBG;QAC9FT,gBAAAlB,wBAAA4B,qBAAA,CAAAF,QAAA,CAAAR,gBAAA;YAEAM,aAAUC;aACRI;;QAGFA,MAAIA,cAAMX,EAAc;cACtBW,cAAMX,CAAAA,OAAeY,GAAAA,IAAAA,+BAAUC,EAAAA,uBAAehB,MAAuBc,cAAMX,CAAAA,OAAeY;;QAG5FD,MAAOA,cAAAA,EAAAA;QACPA,MAAAX,cAAA,CAAAY,OAAA,GAAAC,IAAAA,+BAAA,EAAAhB,uBAAAc,MAAAX,cAAA,CAAAY,OAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "useReferenceListContextValues_unstable", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return useReferenceListContextValues_unstable;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function useReferenceListContextValues_unstable(state) {
|
|
12
|
+
const { appearance, areReferencesExpanded, overflowButtonTriggeredViaKeyboard, previousOverflowCount, shouldUseOverflow } = state;
|
|
13
|
+
// This context is created with "@fluentui/react-context-selector", there is no sense to memoize it
|
|
14
|
+
const referenceList = {
|
|
15
|
+
appearance,
|
|
16
|
+
areReferencesExpanded,
|
|
17
|
+
overflowButtonTriggeredViaKeyboard,
|
|
18
|
+
previousOverflowCount,
|
|
19
|
+
shouldUseOverflow
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
referenceList
|
|
23
|
+
};
|
|
24
|
+
} //# sourceMappingURL=useReferenceListContextValues.js.map
|
package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceListContextValues.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useReferenceListContextValues.ts"],"sourcesContent":["import type { ReferenceListState, ReferenceListContextValues } from './ReferenceList.types';\n\nexport function useReferenceListContextValues_unstable(state: ReferenceListState): ReferenceListContextValues {\n const {\n appearance,\n areReferencesExpanded,\n overflowButtonTriggeredViaKeyboard,\n previousOverflowCount,\n shouldUseOverflow,\n } = state;\n\n // This context is created with \"@fluentui/react-context-selector\", there is no sense to memoize it\n const referenceList = {\n appearance,\n areReferencesExpanded,\n overflowButtonTriggeredViaKeyboard,\n previousOverflowCount,\n shouldUseOverflow,\n };\n\n return { referenceList };\n}\n"],"names":["useReferenceListContextValues_unstable","state","appearance","areReferencesExpanded","referenceList","overflowButtonTriggeredViaKeyboard","shouldUseOverflow","previousOverflowCount"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":";;;;+BAEgBA;;;eAAAA;;;AAAT,SAASA,uCAAuCC,KAAyB;UAC9E,EAQAC,UAAA,EACAC,qBAAMC,oCACJF,uBACAC,mBACAE;uGAEAC;UACFF,gBAAA;QAEAF;;QAAuBG;QACzBE"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
referenceListClassNames: function() {
|
|
13
|
+
return referenceListClassNames;
|
|
14
|
+
},
|
|
15
|
+
useReferenceListStyles_unstable: function() {
|
|
16
|
+
return useReferenceListStyles_unstable;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _reactcomponents = require("@fluentui/react-components");
|
|
20
|
+
const referenceListClassNames = {
|
|
21
|
+
root: 'fai-ReferenceList',
|
|
22
|
+
showMoreButton: 'fai-ReferenceList__showMoreButton',
|
|
23
|
+
showLessButton: 'fai-ReferenceList__showLessButton'
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Styles for the root slot
|
|
27
|
+
*/ const useRootBaseClassName = (0, _reactcomponents.__resetStyles)("rylvie1", null, [
|
|
28
|
+
".rylvie1{display:flex;flex-direction:row;gap:var(--spacingVerticalXS) var(--spacingHorizontalXS);}"
|
|
29
|
+
]);
|
|
30
|
+
const useRootStyles = (0, _reactcomponents.__styles)({
|
|
31
|
+
referencesExpanded: {
|
|
32
|
+
Eh141a: "fni485r"
|
|
33
|
+
}
|
|
34
|
+
}, {
|
|
35
|
+
d: [
|
|
36
|
+
".fni485r{flex-wrap:wrap;}"
|
|
37
|
+
]
|
|
38
|
+
});
|
|
39
|
+
const useOverflowButtonBaseClassName = (0, _reactcomponents.__resetStyles)("r6su6fj", null, [
|
|
40
|
+
".r6su6fj{flex-shrink:0;}"
|
|
41
|
+
]);
|
|
42
|
+
const useReferenceListStyles_unstable = (state)=>{
|
|
43
|
+
const { areReferencesExpanded, shouldUseOverflow } = state;
|
|
44
|
+
const rootBaseClassName = useRootBaseClassName();
|
|
45
|
+
const rootStyles = useRootStyles();
|
|
46
|
+
const overflowButtonBaseClassName = useOverflowButtonBaseClassName();
|
|
47
|
+
state.root.className = (0, _reactcomponents.mergeClasses)(referenceListClassNames.root, rootBaseClassName, (areReferencesExpanded || !shouldUseOverflow) && rootStyles.referencesExpanded, state.root.className);
|
|
48
|
+
if (state.showMoreButton) {
|
|
49
|
+
state.showMoreButton.className = (0, _reactcomponents.mergeClasses)(referenceListClassNames.showMoreButton, overflowButtonBaseClassName, state.showMoreButton.className);
|
|
50
|
+
}
|
|
51
|
+
if (state.showLessButton) {
|
|
52
|
+
state.showLessButton.className = (0, _reactcomponents.mergeClasses)(referenceListClassNames.showLessButton, overflowButtonBaseClassName, state.showLessButton.className);
|
|
53
|
+
}
|
|
54
|
+
return state;
|
|
55
|
+
}; //# sourceMappingURL=useReferenceListStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useReferenceListStyles.ts"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses, tokens } from '@fluentui/react-components';\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 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 useOverflowButtonBaseClassName = makeResetStyles({\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 const { areReferencesExpanded, shouldUseOverflow } = state;\n\n const rootBaseClassName = useRootBaseClassName();\n const rootStyles = useRootStyles();\n const overflowButtonBaseClassName = useOverflowButtonBaseClassName();\n\n state.root.className = mergeClasses(\n referenceListClassNames.root,\n rootBaseClassName,\n (areReferencesExpanded || !shouldUseOverflow) && rootStyles.referencesExpanded,\n state.root.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":["referenceListClassNames","useReferenceListStyles_unstable","root","showMoreButton","showLessButton","display","__resetStyles","flexDirection","__styles","spacingVerticalXS","Eh141a","useOverflowButtonBaseClassName","state","areReferencesExpanded","shouldUseOverflow","rootBaseClassName","useRootStyles","rootStyles","overflowButtonBaseClassName","mergeClasses","referencesExpanded","className"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAIaA,uBAAAA;eAAAA;;IAyBbC,+BAAA;eAAAA;;;iCA7B0D;AAInD,MAAMD,0BAA8D;UACzEE;oBACAC;oBACAC;AACF;AAEA;;CAEC,SAECC,uBAASC,IAAAA,8BAAA,EAAA,WAAA,MAAA;IAAA;CAAA;MACTC,gBAAeC,IAAAA,yBAAA,EAAA;wBACAC;QACjBC,QAAA;IAEA;;;;KAEc;;AAEd,MAAAC,iCAAAL,IAAAA,8BAAA,EAAA,WAAA,MAAA;IAAA;CAAA;AAMA,MAAAL,kCAAAW,CAAAA;YAGAC,qBAAaZ,EACXa,iBAAQD,KAERD;UACAG,oBAAmBC;UACnBC,aAAMC;UAENN,8BAAuBO;UAOnBP,IAAAA,CAAAA,SAAMT,GAAAA,IAAAA,6BAAgB,EAAAH,wBAAAE,IAAA,EAAAa,mBAAA,AAAAF,CAAAA,yBAAA,CAAAC,iBAAA,KAAAG,WAAAG,kBAAA,EAAAR,MAAAV,IAAA,CAAAmB,SAAA;cACxBT,cAAMT,EAAc;QAKtBS,MAAAT,cAAA,CAAAkB,SAAA,GAAAF,IAAAA,6BAAA,EAAAnB,wBAAAG,cAAA,EAAAe,6BAAAN,MAAAT,cAAA,CAAAkB,SAAA;;cAGET,cAAMR,EAAc;QAKtBQ,MAAAR,cAAA,CAAAiB,SAAA,GAAAF,IAAAA,6BAAA,EAAAnB,wBAAAI,cAAA,EAAAc,6BAAAN,MAAAR,cAAA,CAAAiB,SAAA;;IAGA,OAAAT"}
|
package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "ReferenceOverflowButton", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return ReferenceOverflowButton;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
+
const _useReferenceOverflowButton = require("./useReferenceOverflowButton");
|
|
14
|
+
const _renderReferenceOverflowButton = require("./renderReferenceOverflowButton");
|
|
15
|
+
const _useReferenceOverflowButtonStyles = require("./useReferenceOverflowButtonStyles");
|
|
16
|
+
const ReferenceOverflowButton = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
|
|
17
|
+
const state = (0, _useReferenceOverflowButton.useReferenceOverflowButton_unstable)(props, ref);
|
|
18
|
+
(0, _useReferenceOverflowButtonStyles.useReferenceOverflowButtonStyles_unstable)(state);
|
|
19
|
+
return (0, _renderReferenceOverflowButton.renderReferenceOverflowButton_unstable)(state);
|
|
20
|
+
});
|
|
21
|
+
ReferenceOverflowButton.displayName = 'ReferenceOverflowButton'; //# sourceMappingURL=ReferenceOverflowButton.js.map
|
package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["ReferenceOverflowButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useReferenceOverflowButton_unstable } from './useReferenceOverflowButton';\nimport { renderReferenceOverflowButton_unstable } from './renderReferenceOverflowButton';\nimport { useReferenceOverflowButtonStyles_unstable } from './useReferenceOverflowButtonStyles';\nimport type { ReferenceOverflowButtonProps } from './ReferenceOverflowButton.types';\nimport type { ForwardRefComponent } from '@fluentui/react-components';\n\n// ReferenceOverflowButton component - TODO: add more docs\nexport const ReferenceOverflowButton: ForwardRefComponent<ReferenceOverflowButtonProps> = React.forwardRef(\n (props, ref) => {\n const state = useReferenceOverflowButton_unstable(props, ref);\n\n useReferenceOverflowButtonStyles_unstable(state);\n return renderReferenceOverflowButton_unstable(state);\n },\n);\n\nReferenceOverflowButton.displayName = 'ReferenceOverflowButton';\n"],"names":["ReferenceOverflowButton","React","forwardRef","props","state","useReferenceOverflowButton_unstable","useReferenceOverflowButtonStyles_unstable","renderReferenceOverflowButton_unstable","displayName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAQaA;;;eAAAA;;;;iEARU;4CAC6B;+CACG;kDACG;AAKnD,MAAMA,0BAAAA,WAAAA,GAAAA,OAA6EC,UAAMC,CAAU,CACxGC,OAACA;UACCC,QAAMA,IAAAA,+DAAQC,EAAAA,OAAoCF;mFAElDG,EAAAA;WACAC,IAAAA,qEAAOA,EAAAA;AACT;AAGFP,wBAAwBQ,WAAW,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["ReferenceOverflowButton.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-components';\n\nexport type ReferenceOverflowButtonSlots = {\n root: Slot<'button'>;\n};\n\n/**\n * ReferenceOverflowButton Props\n */\nexport type ReferenceOverflowButtonProps = ComponentProps<ReferenceOverflowButtonSlots> & {\n /**\n * The appearance of the reference.\n * @default 'lighter'\n */\n appearance?: 'lighter' | 'darker';\n\n text?: string | ((overflowCount: number) => React.ReactNode);\n};\n\n/**\n * State used in rendering ReferenceOverflowButton\n */\nexport type ReferenceOverflowButtonState = ComponentState<ReferenceOverflowButtonSlots> &\n Required<Pick<ReferenceOverflowButtonProps, 'appearance'>> & {\n shouldRenderOverflowButton: boolean;\n };\n"],"names":[],"rangeMappings":";;","mappings":"AAmBA;;CAEC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
const _export_star = require("@swc/helpers/_/_export_star");
|
|
6
|
+
_export_star._(require("./ReferenceOverflowButton"), exports);
|
|
7
|
+
_export_star._(require("./ReferenceOverflowButton.types"), exports);
|
|
8
|
+
_export_star._(require("./renderReferenceOverflowButton"), exports);
|
|
9
|
+
_export_star._(require("./useReferenceOverflowButton"), exports);
|
|
10
|
+
_export_star._(require("./useReferenceOverflowButtonStyles"), exports);
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './ReferenceOverflowButton';\nexport * from './ReferenceOverflowButton.types';\nexport * from './renderReferenceOverflowButton';\nexport * from './useReferenceOverflowButton';\nexport * from './useReferenceOverflowButtonStyles';\n"],"names":[],"rangeMappings":";;;;;;;;;","mappings":";;;;;uBAAc;uBACA;uBACA;uBACA;uBACA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "renderReferenceOverflowButton_unstable", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return renderReferenceOverflowButton_unstable;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
|
|
12
|
+
const _reactcomponents = require("@fluentui/react-components");
|
|
13
|
+
const renderReferenceOverflowButton_unstable = (state)=>{
|
|
14
|
+
(0, _reactcomponents.assertSlots)(state);
|
|
15
|
+
return state.shouldRenderOverflowButton ? /*#__PURE__*/ (0, _jsxruntime.jsx)(state.root, {}) : null;
|
|
16
|
+
}; //# sourceMappingURL=renderReferenceOverflowButton.js.map
|
|
@@ -0,0 +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"}
|
package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "useReferenceOverflowButton_unstable", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return useReferenceOverflowButton_unstable;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
+
const _keyboardkeys = require("@fluentui/keyboard-keys");
|
|
14
|
+
const _reactcomponents = require("@fluentui/react-components");
|
|
15
|
+
const _reactutilities = require("@fluentui/react-utilities");
|
|
16
|
+
const _referenceListContext = require("../../../contexts/reference-v2/referenceListContext");
|
|
17
|
+
const useReferenceOverflowButton_unstable = (props, ref)=>{
|
|
18
|
+
const { children, text } = props;
|
|
19
|
+
const rootRef = _react.useRef(null);
|
|
20
|
+
const [setTimeout] = (0, _reactutilities.useTimeout)();
|
|
21
|
+
const { areReferencesExpanded, ctxAppearance, previousOverflowCount, triggeredViaKeyboard } = (0, _referenceListContext.useReferenceListContext_unstable)((ctx)=>({
|
|
22
|
+
ctxAppearance: ctx.appearance,
|
|
23
|
+
areReferencesExpanded: ctx.areReferencesExpanded,
|
|
24
|
+
previousOverflowCount: ctx.previousOverflowCount,
|
|
25
|
+
triggeredViaKeyboard: ctx.overflowButtonTriggeredViaKeyboard
|
|
26
|
+
}));
|
|
27
|
+
const appearance = props.appearance || ctxAppearance;
|
|
28
|
+
const { isOverflowing, overflowCount } = (0, _reactcomponents.useOverflowMenu)();
|
|
29
|
+
const processedText = children !== null && children !== void 0 ? children : typeof text === 'function' ? text(overflowCount) : text;
|
|
30
|
+
const { findPrevFocusable } = (0, _reactcomponents.useFocusFinders)();
|
|
31
|
+
const onKeyDown = _react.useCallback((ev)=>{
|
|
32
|
+
if (ev.key === _keyboardkeys.Enter || ev.key === _keyboardkeys.Space) {
|
|
33
|
+
triggeredViaKeyboard.current = true;
|
|
34
|
+
}
|
|
35
|
+
}, [
|
|
36
|
+
triggeredViaKeyboard
|
|
37
|
+
]);
|
|
38
|
+
// When the references are expanded or contracted via keyboard, we need to move focus to the appropriate element.
|
|
39
|
+
_react.useEffect(()=>{
|
|
40
|
+
if (triggeredViaKeyboard.current) {
|
|
41
|
+
let elementToFocus;
|
|
42
|
+
// If the references are contracted, we move focus to the overflow button.
|
|
43
|
+
if (!areReferencesExpanded) {
|
|
44
|
+
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
|
+
}
|
|
50
|
+
elementToFocus = currentElement;
|
|
51
|
+
}
|
|
52
|
+
// 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.
|
|
53
|
+
setTimeout(()=>{
|
|
54
|
+
elementToFocus === null || elementToFocus === void 0 ? void 0 : elementToFocus.focus();
|
|
55
|
+
triggeredViaKeyboard.current = false;
|
|
56
|
+
}, 0);
|
|
57
|
+
}
|
|
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
|
+
[
|
|
62
|
+
areReferencesExpanded,
|
|
63
|
+
isOverflowing,
|
|
64
|
+
triggeredViaKeyboard
|
|
65
|
+
]);
|
|
66
|
+
const state = {
|
|
67
|
+
appearance,
|
|
68
|
+
shouldRenderOverflowButton: isOverflowing || areReferencesExpanded,
|
|
69
|
+
components: {
|
|
70
|
+
root: 'button'
|
|
71
|
+
},
|
|
72
|
+
root: _reactcomponents.slot.always((0, _reactcomponents.getIntrinsicElementProps)('button', {
|
|
73
|
+
ref: (0, _reactcomponents.useMergedRefs)(rootRef, ref),
|
|
74
|
+
...props
|
|
75
|
+
}), {
|
|
76
|
+
defaultProps: {
|
|
77
|
+
children: processedText
|
|
78
|
+
},
|
|
79
|
+
elementType: 'button'
|
|
80
|
+
})
|
|
81
|
+
};
|
|
82
|
+
state.root.onKeyDown = (0, _reactcomponents.mergeCallbacks)(onKeyDown, props.onKeyDown);
|
|
83
|
+
return state;
|
|
84
|
+
}; //# sourceMappingURL=useReferenceOverflowButton.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
referenceOverflowButtonClassNames: function() {
|
|
13
|
+
return referenceOverflowButtonClassNames;
|
|
14
|
+
},
|
|
15
|
+
useReferenceOverflowButtonStyles_unstable: function() {
|
|
16
|
+
return useReferenceOverflowButtonStyles_unstable;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _reactcomponents = require("@fluentui/react-components");
|
|
20
|
+
const referenceOverflowButtonClassNames = {
|
|
21
|
+
root: 'fai-ReferenceOverflowButton'
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Styles for the root slot
|
|
25
|
+
*/ const useRootBaseClassName = (0, _reactcomponents.__resetStyles)("rbsq19a", null, [
|
|
26
|
+
".rbsq19a{background-color:var(--colorNeutralBackground3);border:var(--strokeWidthThin) solid var(--colorNeutralStroke2);border-radius:var(--borderRadiusMedium);color:var(--colorNeutralForeground2);display:inline-flex;padding:var(--spacingVerticalXXS) var(--spacingHorizontalS);font-family:var(--fontFamilyBase);font-size:var(--fontSizeBase200);font-weight:var(--fontWeightRegular);line-height:var(--lineHeightBase200);}",
|
|
27
|
+
".rbsq19a:hover{background-color:var(--colorNeutralBackground3Hover);border-color:var(--colorNeutralStroke1Hover);color:var(--colorNeutralForeground2Hover);}",
|
|
28
|
+
".rbsq19a:hover:active{background-color:var(--colorNeutralBackground3Pressed);border-color:var(--colorNeutralStroke1Pressed);color:var(--colorNeutralForeground2Pressed);}"
|
|
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
|
+
const useReferenceOverflowButtonStyles_unstable = (state)=>{
|
|
60
|
+
const { appearance } = state;
|
|
61
|
+
const rootBaseClassName = useRootBaseClassName();
|
|
62
|
+
const rootStyles = useRootStyles();
|
|
63
|
+
state.root.className = (0, _reactcomponents.mergeClasses)(referenceOverflowButtonClassNames.root, rootBaseClassName, appearance === 'darker' && rootStyles.darker, state.root.className);
|
|
64
|
+
return state;
|
|
65
|
+
}; //# sourceMappingURL=useReferenceOverflowButtonStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useReferenceOverflowButtonStyles.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;+DAEA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
const _export_star = require("@swc/helpers/_/_export_star");
|
|
6
|
+
_export_star._(require("./Reference"), exports);
|
|
7
|
+
_export_star._(require("./ReferenceList"), exports);
|
|
8
|
+
_export_star._(require("./ReferenceOverflowButton"), exports);
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './Reference';\nexport * from './ReferenceList';\nexport * from './ReferenceOverflowButton';\n"],"names":[],"rangeMappings":";;;;;;;","mappings":";;;;;uBAAc;uBACA;uBACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["ReferenceGroupContext.ts"],"sourcesContent":["import * as React from 'react';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = () => {};\n\nexport type ReferenceGroupContext = {\n open?: boolean;\n setOpen: () => void;\n};\n\nconst ReferenceGroupContext = React.createContext<ReferenceGroupContext | undefined>(undefined);\n\nexport const ReferenceGroupProvider = ReferenceGroupContext.Provider;\n\nexport const useReferenceGroupSetOpen = (): (() => void) => {\n const context = React.useContext(ReferenceGroupContext);\n return context?.setOpen ?? noop;\n};\n"],"names":["ReferenceGroupProvider","useReferenceGroupSetOpen","noop","ReferenceGroupContext","React","createContext","undefined","Provider","context","useContext","_context_setOpen","setOpen"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAYaA,sBAAAA;eAAAA;;IAEAC,wBAAAA;eAAAA;;;;iEAdU;AAEvB,gEAAgE;AAChE,MAAMC,OAAO,KAAO;AAOpB,MAAMC,sCAAwBC,OAAMC,aAAa,CAAoCC;AAE9E,MAAMN,yBAAyBG,sBAAsBI,QAAQ;AAE7D,MAAMN,2BAA2B;UACtCO,UAAMA,OAAUJ,UAAMK,CAAAA;;WACtB,AAAAC,CAAAA,mBAAOF,YAAAA,QAAAA,YAAAA,KAAAA,IAAAA,KAAAA,IAAAA,QAAAA,OAASG,MAAO,QAAAD,qBAAhBF,KAAAA,IAAAA,mBAAAA;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './referenceListContext';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
ReferenceListContext: function() {
|
|
13
|
+
return ReferenceListContext;
|
|
14
|
+
},
|
|
15
|
+
ReferenceListContextProvider: function() {
|
|
16
|
+
return ReferenceListContextProvider;
|
|
17
|
+
},
|
|
18
|
+
useReferenceListContext_unstable: function() {
|
|
19
|
+
return useReferenceListContext_unstable;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _reactcontextselector = require("@fluentui/react-context-selector");
|
|
23
|
+
const ReferenceListContext = (0, _reactcontextselector.createContext)(undefined);
|
|
24
|
+
const referenceListContextDefaultValue = {
|
|
25
|
+
appearance: 'lighter',
|
|
26
|
+
areReferencesExpanded: false,
|
|
27
|
+
overflowButtonTriggeredViaKeyboard: {
|
|
28
|
+
current: false
|
|
29
|
+
},
|
|
30
|
+
previousOverflowCount: {
|
|
31
|
+
current: 0
|
|
32
|
+
},
|
|
33
|
+
shouldUseOverflow: false
|
|
34
|
+
};
|
|
35
|
+
const ReferenceListContextProvider = ReferenceListContext.Provider;
|
|
36
|
+
const useReferenceListContext_unstable = (selector)=>(0, _reactcontextselector.useContextSelector)(ReferenceListContext, (ctx = referenceListContextDefaultValue)=>selector(ctx)); //# sourceMappingURL=referenceListContext.js.map
|
|
@@ -0,0 +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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './useReferenceCitationPreview';\nexport * from './useReferenceGroup';\n"],"names":[],"rangeMappings":";;;;;;","mappings":";;;;;uBAAc;uBACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './useReferenceCitationPreview';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "useReferenceCitationPreview", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return useReferenceCitationPreview;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
|
+
const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
|
|
13
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
14
|
+
const _reactcomponents = require("@fluentui/react-components");
|
|
15
|
+
const _reactpreview = require("@fluentui-copilot/react-preview");
|
|
16
|
+
const _reactsensitivitylabel = require("@fluentui-copilot/react-sensitivity-label");
|
|
17
|
+
const _Citation = require("../../Citation");
|
|
18
|
+
const _ReferenceV2 = require("../../ReferenceV2");
|
|
19
|
+
// Abstract the citation that serves as the close button of the Preview into its own component so that we have access to the popover context.
|
|
20
|
+
const CitationCloseButton = (citationCloseButtonProps)=>{
|
|
21
|
+
const setPopoverOpen = (0, _reactcomponents.usePopoverContext_unstable)((context)=>context.setOpen);
|
|
22
|
+
const onPopoverCloseClick = _react.useCallback((ev)=>{
|
|
23
|
+
setPopoverOpen(ev, false);
|
|
24
|
+
// Don't navigate
|
|
25
|
+
ev.preventDefault();
|
|
26
|
+
}, [
|
|
27
|
+
setPopoverOpen
|
|
28
|
+
]);
|
|
29
|
+
const onCitationCloseButtonClick = (0, _reactcomponents.mergeCallbacks)(onPopoverCloseClick, citationCloseButtonProps.onClick);
|
|
30
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_Citation.Citation, {
|
|
31
|
+
...citationCloseButtonProps,
|
|
32
|
+
onClick: onCitationCloseButtonClick
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
const useReferenceCitationPreview = (props)=>{
|
|
36
|
+
const { citationPreviewProps, citationPreviewSurfaceProps, citationProps, index, previewContentProps, referencePreviewProps, referencePreviewSurfaceProps, referenceProps, sensitivityLabelProps } = props;
|
|
37
|
+
const components = _react.useMemo(()=>{
|
|
38
|
+
const citationWithPreview = (props)=>{
|
|
39
|
+
var _previewContentProps_content;
|
|
40
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactpreview.Preview, {
|
|
41
|
+
closeOnScroll: true,
|
|
42
|
+
positioning: "below",
|
|
43
|
+
size: "small",
|
|
44
|
+
trapFocus: true,
|
|
45
|
+
withArrow: true,
|
|
46
|
+
...citationPreviewProps,
|
|
47
|
+
children: [
|
|
48
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactpreview.PreviewTrigger, {
|
|
49
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Citation.Citation, {
|
|
50
|
+
...citationProps,
|
|
51
|
+
...props,
|
|
52
|
+
children: index
|
|
53
|
+
})
|
|
54
|
+
}),
|
|
55
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactpreview.PreviewSurface, {
|
|
56
|
+
...citationPreviewSurfaceProps,
|
|
57
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactpreview.PreviewContent, {
|
|
58
|
+
children: [
|
|
59
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactpreview.PreviewHeader, {
|
|
60
|
+
citation: /*#__PURE__*/ (0, _jsxruntime.jsx)(CitationCloseButton, {
|
|
61
|
+
"aria-label": `Reference ${index}, close`,
|
|
62
|
+
referenceHref: "#",
|
|
63
|
+
tabIndex: -1,
|
|
64
|
+
children: index
|
|
65
|
+
}),
|
|
66
|
+
media: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.media,
|
|
67
|
+
children: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.children
|
|
68
|
+
}),
|
|
69
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactpreview.PreviewMetadata, {
|
|
70
|
+
icon: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.icon,
|
|
71
|
+
primaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.primaryText,
|
|
72
|
+
secondaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.secondaryText,
|
|
73
|
+
tertiaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.tertiaryText
|
|
74
|
+
}),
|
|
75
|
+
sensitivityLabelProps && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactsensitivitylabel.SensitivityLabel, {
|
|
76
|
+
...sensitivityLabelProps
|
|
77
|
+
}),
|
|
78
|
+
(_previewContentProps_content = previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.content) !== null && _previewContentProps_content !== void 0 ? _previewContentProps_content : citationPreviewProps === null || citationPreviewProps === void 0 ? void 0 : citationPreviewProps.children
|
|
79
|
+
]
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
const referenceWithPreview = (props)=>{
|
|
86
|
+
var _previewContentProps_content;
|
|
87
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactpreview.Preview, {
|
|
88
|
+
closeOnScroll: true,
|
|
89
|
+
positioning: "below",
|
|
90
|
+
size: "small",
|
|
91
|
+
trapFocus: true,
|
|
92
|
+
withArrow: true,
|
|
93
|
+
...referencePreviewProps,
|
|
94
|
+
children: [
|
|
95
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactpreview.PreviewTrigger, {
|
|
96
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ReferenceV2.Reference, {
|
|
97
|
+
citation: index,
|
|
98
|
+
...referenceProps,
|
|
99
|
+
...props
|
|
100
|
+
})
|
|
101
|
+
}),
|
|
102
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactpreview.PreviewSurface, {
|
|
103
|
+
...referencePreviewSurfaceProps,
|
|
104
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactpreview.PreviewContent, {
|
|
105
|
+
children: [
|
|
106
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactpreview.PreviewHeader, {
|
|
107
|
+
citation: /*#__PURE__*/ (0, _jsxruntime.jsx)(CitationCloseButton, {
|
|
108
|
+
"aria-label": `Reference ${index}, close`,
|
|
109
|
+
referenceHref: "#",
|
|
110
|
+
tabIndex: -1,
|
|
111
|
+
children: index
|
|
112
|
+
}),
|
|
113
|
+
media: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.media,
|
|
114
|
+
children: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.children
|
|
115
|
+
}),
|
|
116
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactpreview.PreviewMetadata, {
|
|
117
|
+
icon: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.icon,
|
|
118
|
+
primaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.primaryText,
|
|
119
|
+
secondaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.secondaryText,
|
|
120
|
+
tertiaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.tertiaryText
|
|
121
|
+
}),
|
|
122
|
+
sensitivityLabelProps && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactsensitivitylabel.SensitivityLabel, {
|
|
123
|
+
...sensitivityLabelProps
|
|
124
|
+
}),
|
|
125
|
+
(_previewContentProps_content = previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.content) !== null && _previewContentProps_content !== void 0 ? _previewContentProps_content : referencePreviewProps === null || referencePreviewProps === void 0 ? void 0 : referencePreviewProps.children
|
|
126
|
+
]
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
]
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
return {
|
|
133
|
+
Citation: citationWithPreview,
|
|
134
|
+
Reference: referenceWithPreview
|
|
135
|
+
};
|
|
136
|
+
}, [
|
|
137
|
+
citationPreviewProps,
|
|
138
|
+
citationPreviewSurfaceProps,
|
|
139
|
+
citationProps,
|
|
140
|
+
index,
|
|
141
|
+
referencePreviewProps,
|
|
142
|
+
referencePreviewSurfaceProps,
|
|
143
|
+
referenceProps,
|
|
144
|
+
previewContentProps,
|
|
145
|
+
sensitivityLabelProps
|
|
146
|
+
]);
|
|
147
|
+
return components;
|
|
148
|
+
}; //# sourceMappingURL=useReferenceCitationPreview.js.map
|