@fluentui-copilot/react-reference 0.0.0-nightly-20240326-0406-81404260.1 → 0.0.0-nightly-20240329-0406-56cbae9a.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 +9 -9
- package/CHANGELOG.md +7 -7
- package/dist/index.d.ts +40 -191
- package/lib/components/Citation/Citation.types.js.map +1 -1
- package/lib/components/Citation/renderCitation.js +3 -22
- package/lib/components/Citation/renderCitation.js.map +1 -1
- package/lib/components/Citation/useCitation.js +3 -157
- package/lib/components/Citation/useCitation.js.map +1 -1
- package/lib/components/Citation/useCitationStyles.js +1 -6
- package/lib/components/Citation/useCitationStyles.js.map +1 -1
- package/lib/components/Reference/Reference.types.js.map +1 -1
- package/lib/components/Reference/renderReference.js +1 -1
- package/lib/components/Reference/renderReference.js.map +1 -1
- package/lib/components/Reference/useReference.js +0 -5
- package/lib/components/Reference/useReference.js.map +1 -1
- package/lib/components/Reference/useReferenceStyles.js +1 -38
- package/lib/components/Reference/useReferenceStyles.js.map +1 -1
- package/lib/hooks/index.js +1 -2
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useReferenceCitationPreview.js +11 -12
- package/lib/hooks/useReferenceCitationPreview.js.map +1 -1
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib-commonjs/components/Citation/renderCitation.js +1 -23
- package/lib-commonjs/components/Citation/renderCitation.js.map +1 -1
- package/lib-commonjs/components/Citation/useCitation.js +3 -155
- package/lib-commonjs/components/Citation/useCitation.js.map +1 -1
- package/lib-commonjs/components/Citation/useCitationStyles.js +1 -6
- package/lib-commonjs/components/Citation/useCitationStyles.js.map +1 -1
- package/lib-commonjs/components/Reference/renderReference.js +0 -1
- package/lib-commonjs/components/Reference/renderReference.js.map +1 -1
- package/lib-commonjs/components/Reference/useReference.js +0 -5
- package/lib-commonjs/components/Reference/useReference.js.map +1 -1
- package/lib-commonjs/components/Reference/useReferenceStyles.js +4 -98
- package/lib-commonjs/components/Reference/useReferenceStyles.js.map +1 -1
- package/lib-commonjs/hooks/index.js +1 -8
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useReferenceCitationPreview.js +10 -10
- package/lib-commonjs/hooks/useReferenceCitationPreview.js.map +1 -1
- package/lib-commonjs/index.js +0 -19
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +4 -4
- package/lib/ReferenceGroup.js +0 -2
- package/lib/ReferenceGroup.js.map +0 -1
- package/lib/components/ReferenceGroup/ReferenceGroup.js +0 -19
- package/lib/components/ReferenceGroup/ReferenceGroup.js.map +0 -1
- package/lib/components/ReferenceGroup/ReferenceGroup.types.js +0 -2
- package/lib/components/ReferenceGroup/ReferenceGroup.types.js.map +0 -1
- package/lib/components/ReferenceGroup/index.js +0 -6
- package/lib/components/ReferenceGroup/index.js.map +0 -1
- package/lib/components/ReferenceGroup/renderReferenceGroup.js +0 -21
- package/lib/components/ReferenceGroup/renderReferenceGroup.js.map +0 -1
- package/lib/components/ReferenceGroup/useReferenceGroup.js +0 -104
- package/lib/components/ReferenceGroup/useReferenceGroup.js.map +0 -1
- package/lib/components/ReferenceGroup/useReferenceGroupContextValues.js +0 -10
- package/lib/components/ReferenceGroup/useReferenceGroupContextValues.js.map +0 -1
- package/lib/components/ReferenceGroup/useReferenceGroupStyles.js +0 -50
- package/lib/components/ReferenceGroup/useReferenceGroupStyles.js.map +0 -1
- package/lib/hooks/useReferenceCitation.js +0 -77
- package/lib/hooks/useReferenceCitation.js.map +0 -1
- package/lib-commonjs/ReferenceGroup.js +0 -7
- package/lib-commonjs/ReferenceGroup.js.map +0 -1
- package/lib-commonjs/components/ReferenceGroup/ReferenceGroup.js +0 -25
- package/lib-commonjs/components/ReferenceGroup/ReferenceGroup.js.map +0 -1
- package/lib-commonjs/components/ReferenceGroup/ReferenceGroup.types.js +0 -5
- package/lib-commonjs/components/ReferenceGroup/ReferenceGroup.types.js.map +0 -1
- package/lib-commonjs/components/ReferenceGroup/index.js +0 -11
- package/lib-commonjs/components/ReferenceGroup/index.js.map +0 -1
- package/lib-commonjs/components/ReferenceGroup/renderReferenceGroup.js +0 -33
- package/lib-commonjs/components/ReferenceGroup/renderReferenceGroup.js.map +0 -1
- package/lib-commonjs/components/ReferenceGroup/useReferenceGroup.js +0 -103
- package/lib-commonjs/components/ReferenceGroup/useReferenceGroup.js.map +0 -1
- package/lib-commonjs/components/ReferenceGroup/useReferenceGroupContextValues.js +0 -23
- package/lib-commonjs/components/ReferenceGroup/useReferenceGroupContextValues.js.map +0 -1
- package/lib-commonjs/components/ReferenceGroup/useReferenceGroupStyles.js +0 -75
- package/lib-commonjs/components/ReferenceGroup/useReferenceGroupStyles.js.map +0 -1
- package/lib-commonjs/hooks/useReferenceCitation.js +0 -78
- package/lib-commonjs/hooks/useReferenceCitation.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
// eslint-disable-next-line @nx/enforce-module-boundaries
|
|
3
|
+
import { Caption1, assertSlots, mergeCallbacks, slot, useId, usePopoverContext_unstable } from '@fluentui/react-components';
|
|
5
4
|
import { Preview, PreviewContent, PreviewHeader, PreviewMetadata, PreviewSurface, PreviewTrigger } from '@fluentui-copilot/react-preview';
|
|
5
|
+
import { SensitivityLabel } from '@fluentui-copilot/react-sensitivity-label';
|
|
6
6
|
import { Citation } from '../Citation';
|
|
7
7
|
import { Reference } from '../Reference';
|
|
8
8
|
// 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.
|
|
@@ -33,7 +33,8 @@ export const useReferenceCitationPreview = ({
|
|
|
33
33
|
citationProps,
|
|
34
34
|
referenceProps,
|
|
35
35
|
previewProps,
|
|
36
|
-
previewSurfaceProps
|
|
36
|
+
previewSurfaceProps,
|
|
37
|
+
sensitivityLabelProps
|
|
37
38
|
}) => {
|
|
38
39
|
const refId = useId();
|
|
39
40
|
const citeId = useId();
|
|
@@ -69,13 +70,14 @@ export const useReferenceCitationPreview = ({
|
|
|
69
70
|
content
|
|
70
71
|
};
|
|
71
72
|
assertSlots(citationWithPreviewState);
|
|
72
|
-
// We resolve the slots' objects for
|
|
73
|
-
const
|
|
73
|
+
// We resolve the slots' objects for sensitivity and title here so that we can use the information from their children below.
|
|
74
|
+
const sensitivity = slot.optional(referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.sensitivity, {
|
|
74
75
|
elementType: 'span'
|
|
75
76
|
});
|
|
76
77
|
const title = slot.optional(referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.label, {
|
|
77
78
|
elementType: 'div'
|
|
78
79
|
});
|
|
80
|
+
var _sensitivityLabelProps_description;
|
|
79
81
|
return /*#__PURE__*/_jsxs(Preview, {
|
|
80
82
|
closeOnScroll: true,
|
|
81
83
|
positioning: "below",
|
|
@@ -87,7 +89,6 @@ export const useReferenceCitationPreview = ({
|
|
|
87
89
|
children: /*#__PURE__*/_jsx(Citation, {
|
|
88
90
|
...citationProps,
|
|
89
91
|
id: citationId,
|
|
90
|
-
referenceId: referenceId,
|
|
91
92
|
...props,
|
|
92
93
|
children: index
|
|
93
94
|
})
|
|
@@ -108,11 +109,9 @@ export const useReferenceCitationPreview = ({
|
|
|
108
109
|
primaryText: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.primaryText,
|
|
109
110
|
secondaryText: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.secondaryText,
|
|
110
111
|
tertiaryText: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.tertiaryText
|
|
111
|
-
}),
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
size: "small",
|
|
115
|
-
children: sensitivityLabel.children
|
|
112
|
+
}), sensitivity && /*#__PURE__*/_jsx(SensitivityLabel, {
|
|
113
|
+
description: (_sensitivityLabelProps_description = sensitivityLabelProps === null || sensitivityLabelProps === void 0 ? void 0 : sensitivityLabelProps.description) !== null && _sensitivityLabelProps_description !== void 0 ? _sensitivityLabelProps_description : '',
|
|
114
|
+
children: sensitivity.children
|
|
116
115
|
}), /*#__PURE__*/_jsx(citationWithPreviewState.content, {}), previewProps === null || previewProps === void 0 ? void 0 : previewProps.children]
|
|
117
116
|
})
|
|
118
117
|
})]
|
|
@@ -122,7 +121,7 @@ export const useReferenceCitationPreview = ({
|
|
|
122
121
|
Citation: CitationWithPreview,
|
|
123
122
|
Reference: PackagedReference
|
|
124
123
|
};
|
|
125
|
-
}, [index, referenceId, citationId, referenceProps, citationProps, previewProps, previewSurfaceProps]);
|
|
124
|
+
}, [index, referenceId, citationId, referenceProps, citationProps, previewProps, previewSurfaceProps, sensitivityLabelProps]);
|
|
126
125
|
return components;
|
|
127
126
|
};
|
|
128
127
|
//# sourceMappingURL=useReferenceCitationPreview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useReferenceCitationPreview.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport * as React from 'react';\nimport {\n Badge,\n Caption1,\n assertSlots,\n mergeCallbacks,\n slot,\n useId,\n usePopoverContext_unstable,\n} from '@fluentui/react-components';\nimport type { Slot } from '@fluentui/react-components';\n\n// eslint-disable-next-line @nx/enforce-module-boundaries\nimport {\n Preview,\n PreviewContent,\n PreviewHeader,\n PreviewMetadata,\n PreviewSurface,\n PreviewTrigger,\n} from '@fluentui-copilot/react-preview';\n// eslint-disable-next-line @nx/enforce-module-boundaries\nimport type { PreviewProps, PreviewSurfaceProps } from '@fluentui-copilot/react-preview';\n\nimport { Citation } from '../Citation';\nimport { Reference } from '../Reference';\nimport type { CitationProps } from '../Citation';\nimport type { ReferenceProps } from '../Reference';\n\ntype PartialCitationProps = 'referenceHref' | 'referenceId';\n\n/**\n * Props for a \"packaged Citation\". A packaged Citation is a `Citation` that is\n * pre-packaged with props set by the `useReferenceCitation` hook.\n */\nexport type PackagedCitationProps = Omit<CitationProps, PartialCitationProps | 'popover' | 'popoverSurface'> &\n Partial<Pick<CitationProps, PartialCitationProps>>;\n\n/**\n * A \"packaged Citation\". A packaged Citation is a `Citation` that is\n * pre-packaged with props set by the `useReferenceCitation` hook.\n */\nexport type PackagedCitation = React.FC<PackagedCitationProps>;\n\ntype PartialReferenceProps = 'citationHref' | 'index' | 'referenceId';\n\n/**\n * Props for a \"packaged Reference\". A packaged Reference is a `Reference` that is\n * pre-packaged with props set by the `useReferenceCitation` hook.\n */\nexport type PackagedReferenceProps = Omit<ReferenceProps, PartialReferenceProps> &\n Partial<Pick<ReferenceProps, PartialReferenceProps>>;\n\n/**\n * A \"packaged Reference\". A packaged Reference is a `Reference` that is\n * pre-packaged with props set by the `useReferenceCitation` hook.\n */\nexport type PackagedReference = React.FC<PackagedReferenceProps>;\n\n/**\n * Data used to package a `Citation` and `Reference` together with\n * the `useReferenceCitation` hook.\n */\nexport type ReferenceCitationData = {\n index: number;\n referenceId?: string;\n citationId?: string;\n citationProps?: PackagedCitationProps;\n referenceProps?: PackagedReferenceProps;\n previewProps?: PreviewProps;\n previewSurfaceProps?: PreviewSurfaceProps;\n};\n\nexport type UseReferenceCitationPreview = (data: ReferenceCitationData) => {\n Citation: PackagedCitation;\n Reference: PackagedReference;\n};\n\ntype PreviewExtraSlots = {\n content: Slot<'div'>;\n};\n\n// 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.\nconst CitationCloseButton = (citationCloseButtonProps: CitationProps) => {\n const setPopoverOpen = usePopoverContext_unstable(context => context.setOpen);\n\n const onPopoverCloseClick = React.useCallback<NonNullable<CitationProps['onClick']>>(\n ev => {\n setPopoverOpen(ev, false);\n\n // Don't navigate\n ev.preventDefault();\n },\n [setPopoverOpen],\n );\n\n const onCitationCloseButtonClick = mergeCallbacks(onPopoverCloseClick, citationCloseButtonProps.onClick);\n\n return <Citation {...citationCloseButtonProps} onClick={onCitationCloseButtonClick} />;\n};\n\n/**\n * Hook to package a `Citation` and `Reference` together in an\n * accessibly by default manner.\n *\n * When using citations and references, prefer using them via this\n * hook to ensure props are wired up correctly.\n */\nexport const useReferenceCitationPreview: UseReferenceCitationPreview = ({\n index,\n referenceId: propsRefId,\n citationId: propsCiteId,\n citationProps,\n referenceProps,\n previewProps,\n previewSurfaceProps,\n}) => {\n const refId = useId();\n const citeId = useId();\n\n const referenceId = propsRefId ?? refId;\n const citationId = propsCiteId ?? citeId;\n\n const components = React.useMemo(() => {\n const citationHref = `#${citationId}`;\n\n const PackagedReference: PackagedReference = props => {\n const referenceIndex = props.index ?? referenceProps?.index ?? index;\n\n return (\n <Reference\n {...referenceProps}\n index={referenceIndex}\n referenceId={referenceId}\n citationHref={citationHref}\n {...props}\n />\n );\n };\n\n const CitationWithPreview: PackagedCitation = props => {\n // We assert content as a slot to use it with its resolved props object and the correct defaults below.\n const content = slot.always(referenceProps ? referenceProps.content : undefined, {\n defaultProps: {\n children: referenceProps?.excerpt && <Caption1>{referenceProps.excerpt}</Caption1>,\n },\n elementType: 'div',\n });\n const citationWithPreviewState = {\n components: {\n content: 'div',\n },\n content,\n };\n assertSlots<PreviewExtraSlots>(citationWithPreviewState);\n\n // We resolve the slots' objects for sensitivityLabel and title here so that we can use the information from their children below.\n const sensitivityLabel = slot.optional(referenceProps?.sensitivityLabel, { elementType: 'span' });\n const title = slot.optional(referenceProps?.label, { elementType: 'div' });\n\n return (\n <Preview closeOnScroll positioning=\"below\" size=\"small\" trapFocus withArrow {...previewProps}>\n <PreviewTrigger>\n <Citation {...citationProps} id={citationId} referenceId={referenceId} {...props}>\n {index}\n </Citation>\n </PreviewTrigger>\n <PreviewSurface {...previewSurfaceProps}>\n <PreviewContent>\n <PreviewHeader\n citation={\n <CitationCloseButton aria-label={`Reference ${index}, close`} referenceHref=\"#\" tabIndex={-1}>\n {index}\n </CitationCloseButton>\n }\n media={referenceProps?.media}\n >\n {title?.children}\n </PreviewHeader>\n <PreviewMetadata\n icon={referenceProps?.icon}\n primaryText={referenceProps?.primaryText}\n secondaryText={referenceProps?.secondaryText}\n tertiaryText={referenceProps?.tertiaryText}\n />\n {sensitivityLabel && (\n <Badge color=\"informative\" shape=\"rounded\" size=\"small\">\n {sensitivityLabel.children}\n </Badge>\n )}\n <citationWithPreviewState.content />\n {previewProps?.children}\n </PreviewContent>\n </PreviewSurface>\n </Preview>\n );\n };\n\n return {\n Citation: CitationWithPreview,\n Reference: PackagedReference,\n };\n }, [index, referenceId, citationId, referenceProps, citationProps, previewProps, previewSurfaceProps]);\n\n return components;\n};\n"],"names":["React","Badge","Caption1","assertSlots","mergeCallbacks","slot","useId","usePopoverContext_unstable","Preview","PreviewContent","PreviewHeader","PreviewMetadata","PreviewSurface","PreviewTrigger","Citation","Reference","CitationCloseButton","citationCloseButtonProps","setPopoverOpen","context","setOpen","onPopoverCloseClick","useCallback","ev","preventDefault","onCitationCloseButtonClick","onClick","useReferenceCitationPreview","index","referenceId","propsRefId","citationId","propsCiteId","citationProps","referenceProps","previewProps","previewSurfaceProps","refId","citeId","components","useMemo","citationHref","PackagedReference","props","referenceIndex","CitationWithPreview","content","always","undefined","defaultProps","children","excerpt","elementType","citationWithPreviewState","sensitivityLabel","optional","title","label","closeOnScroll","positioning","size","trapFocus","withArrow","id","citation","aria-label","referenceHref","tabIndex","media","icon","primaryText","secondaryText","tertiaryText","color","shape"],"mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,YAAYA,WAAW,QAAQ;AAC/B,SACEC,KAAK,EACLC,QAAQ,EACRC,WAAW,EACXC,cAAc,EACdC,IAAI,EACJC,KAAK,EACLC,0BAA0B,QACrB,6BAA6B;AAGpC,yDAAyD;AACzD,SACEC,OAAO,EACPC,cAAc,EACdC,aAAa,EACbC,eAAe,EACfC,cAAc,EACdC,cAAc,QACT,kCAAkC;AAIzC,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,SAAS,QAAQ,eAAe;AAyDzC,6IAA6I;AAC7I,MAAMC,sB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B,KAACG,yBAAyBP,OAAO;gCAChCX,yBAAAA,mCAAAA,aAAce,QAAQ;;;;;;QAKjC;QAEA,OAAO;YACLpC,UAAU+B;YACV9B,WAAW2B;QACb;IACF,GAAG;QAACd;QAAOC;QAAaE;QAAYG;QAAgBD;QAAeE;QAAcC;KAAoB;IAErG,OAAOG;AACT,EAAE"}
|
|
1
|
+
{"version":3,"sources":["useReferenceCitationPreview.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport * as React from 'react';\nimport {\n Caption1,\n assertSlots,\n mergeCallbacks,\n slot,\n useId,\n usePopoverContext_unstable,\n} from '@fluentui/react-components';\nimport type { Slot } from '@fluentui/react-components';\n\nimport {\n Preview,\n PreviewContent,\n PreviewHeader,\n PreviewMetadata,\n PreviewSurface,\n PreviewTrigger,\n} from '@fluentui-copilot/react-preview';\nimport { SensitivityLabel } from '@fluentui-copilot/react-sensitivity-label';\nimport type { PreviewProps, PreviewSurfaceProps } from '@fluentui-copilot/react-preview';\nimport type { SensitivityLabelProps } from '@fluentui-copilot/react-sensitivity-label';\n\nimport { Citation } from '../Citation';\nimport { Reference } from '../Reference';\nimport type { CitationProps } from '../Citation';\nimport type { ReferenceProps } from '../Reference';\n\n/**\n * Props for a \"packaged Citation\". A packaged Citation is a `Citation` that is\n * pre-packaged with props set by the `useReferenceCitation` hook.\n */\nexport type PackagedCitationProps = Omit<CitationProps, 'referenceHref'> &\n Partial<Pick<CitationProps, 'referenceHref'>>;\n\n/**\n * A \"packaged Citation\". A packaged Citation is a `Citation` that is\n * pre-packaged with props set by the `useReferenceCitation` hook.\n */\nexport type PackagedCitation = React.FC<PackagedCitationProps>;\n\ntype PartialReferenceProps = 'citationHref' | 'index' | 'referenceId';\n\n/**\n * Props for a \"packaged Reference\". A packaged Reference is a `Reference` that is\n * pre-packaged with props set by the `useReferenceCitation` hook.\n */\nexport type PackagedReferenceProps = Omit<ReferenceProps, PartialReferenceProps> &\n Partial<Pick<ReferenceProps, PartialReferenceProps>>;\n\n/**\n * A \"packaged Reference\". A packaged Reference is a `Reference` that is\n * pre-packaged with props set by the `useReferenceCitation` hook.\n */\nexport type PackagedReference = React.FC<PackagedReferenceProps>;\n\n/**\n * Data used to package a `Citation` and `Reference` together with\n * the `useReferenceCitation` hook.\n */\nexport type ReferenceCitationData = {\n index: number;\n referenceId?: string;\n citationId?: string;\n citationProps?: PackagedCitationProps;\n referenceProps?: PackagedReferenceProps;\n previewProps?: PreviewProps;\n previewSurfaceProps?: PreviewSurfaceProps;\n sensitivityLabelProps?: SensitivityLabelProps;\n};\n\nexport type UseReferenceCitationPreview = (data: ReferenceCitationData) => {\n Citation: PackagedCitation;\n Reference: PackagedReference;\n};\n\ntype PreviewExtraSlots = {\n content: Slot<'div'>;\n};\n\n// 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.\nconst CitationCloseButton = (citationCloseButtonProps: CitationProps) => {\n const setPopoverOpen = usePopoverContext_unstable(context => context.setOpen);\n\n const onPopoverCloseClick = React.useCallback<NonNullable<CitationProps['onClick']>>(\n ev => {\n setPopoverOpen(ev, false);\n\n // Don't navigate\n ev.preventDefault();\n },\n [setPopoverOpen],\n );\n\n const onCitationCloseButtonClick = mergeCallbacks(onPopoverCloseClick, citationCloseButtonProps.onClick);\n\n return <Citation {...citationCloseButtonProps} onClick={onCitationCloseButtonClick} />;\n};\n\n/**\n * Hook to package a `Citation` and `Reference` together in an\n * accessibly by default manner.\n *\n * When using citations and references, prefer using them via this\n * hook to ensure props are wired up correctly.\n */\nexport const useReferenceCitationPreview: UseReferenceCitationPreview = ({\n index,\n referenceId: propsRefId,\n citationId: propsCiteId,\n citationProps,\n referenceProps,\n previewProps,\n previewSurfaceProps,\n sensitivityLabelProps,\n}) => {\n const refId = useId();\n const citeId = useId();\n\n const referenceId = propsRefId ?? refId;\n const citationId = propsCiteId ?? citeId;\n\n const components = React.useMemo(() => {\n const citationHref = `#${citationId}`;\n\n const PackagedReference: PackagedReference = props => {\n const referenceIndex = props.index ?? referenceProps?.index ?? index;\n\n return (\n <Reference\n {...referenceProps}\n index={referenceIndex}\n referenceId={referenceId}\n citationHref={citationHref}\n {...props}\n />\n );\n };\n\n const CitationWithPreview: PackagedCitation = props => {\n // We assert content as a slot to use it with its resolved props object and the correct defaults below.\n const content = slot.always(referenceProps ? referenceProps.content : undefined, {\n defaultProps: {\n children: referenceProps?.excerpt && <Caption1>{referenceProps.excerpt}</Caption1>,\n },\n elementType: 'div',\n });\n const citationWithPreviewState = {\n components: {\n content: 'div',\n },\n content,\n };\n assertSlots<PreviewExtraSlots>(citationWithPreviewState);\n\n // We resolve the slots' objects for sensitivity and title here so that we can use the information from their children below.\n const sensitivity = slot.optional(referenceProps?.sensitivity, { elementType: 'span' });\n const title = slot.optional(referenceProps?.label, { elementType: 'div' });\n\n return (\n <Preview closeOnScroll positioning=\"below\" size=\"small\" trapFocus withArrow {...previewProps}>\n <PreviewTrigger>\n <Citation {...citationProps} id={citationId} {...props}>\n {index}\n </Citation>\n </PreviewTrigger>\n <PreviewSurface {...previewSurfaceProps}>\n <PreviewContent>\n <PreviewHeader\n citation={\n <CitationCloseButton aria-label={`Reference ${index}, close`} referenceHref=\"#\" tabIndex={-1}>\n {index}\n </CitationCloseButton>\n }\n media={referenceProps?.media}\n >\n {title?.children}\n </PreviewHeader>\n <PreviewMetadata\n icon={referenceProps?.icon}\n primaryText={referenceProps?.primaryText}\n secondaryText={referenceProps?.secondaryText}\n tertiaryText={referenceProps?.tertiaryText}\n />\n {sensitivity && (\n <SensitivityLabel description={sensitivityLabelProps?.description ?? ''}>\n {sensitivity.children}\n </SensitivityLabel>\n )}\n <citationWithPreviewState.content />\n {previewProps?.children}\n </PreviewContent>\n </PreviewSurface>\n </Preview>\n );\n };\n\n return {\n Citation: CitationWithPreview,\n Reference: PackagedReference,\n };\n }, [\n index,\n referenceId,\n citationId,\n referenceProps,\n citationProps,\n previewProps,\n previewSurfaceProps,\n sensitivityLabelProps,\n ]);\n\n return components;\n};\n"],"names":["React","Caption1","assertSlots","mergeCallbacks","slot","useId","usePopoverContext_unstable","Preview","PreviewContent","PreviewHeader","PreviewMetadata","PreviewSurface","PreviewTrigger","SensitivityLabel","Citation","Reference","CitationCloseButton","citationCloseButtonProps","setPopoverOpen","context","setOpen","onPopoverCloseClick","useCallback","ev","preventDefault","onCitationCloseButtonClick","onClick","useReferenceCitationPreview","index","referenceId","propsRefId","citationId","propsCiteId","citationProps","referenceProps","previewProps","previewSurfaceProps","sensitivityLabelProps","refId","citeId","components","useMemo","citationHref","PackagedReference","props","referenceIndex","CitationWithPreview","content","always","undefined","defaultProps","children","excerpt","elementType","citationWithPreviewState","sensitivity","optional","title","label","closeOnScroll","positioning","size","trapFocus","withArrow","id","citation","aria-label","referenceHref","tabIndex","media","icon","primaryText","secondaryText","tertiaryText","description"],"mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,YAAYA,WAAW,QAAQ;AAC/B,SACEC,QAAQ,EACRC,WAAW,EACXC,cAAc,EACdC,IAAI,EACJC,KAAK,EACLC,0BAA0B,QACrB,6BAA6B;AAGpC,SACEC,OAAO,EACPC,cAAc,EACdC,aAAa,EACbC,eAAe,EACfC,cAAc,EACdC,cAAc,QACT,kCAAkC;AACzC,SAASC,gBAAgB,QAAQ,4CAA4C;AAI7E,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,SAAS,QAAQ,eAAe;AAwDzC,6IAA6I;AAC7I,MAAMC,sBAAsB,CAACC;IAC3B,MAAMC,iBAAiBZ,2BAA2Ba,CAAAA,UAAWA,QAAQC,OAAO;IAE5E,MAAMC,sBAAsBrB,MAAMsB,WAAW,CAC3CC,CAAAA;QACEL,eAAeK,IAAI;QAEnB,iBAAiB;QACjBA,GAAGC,cAAc;IACnB,GACA;QAACN;KAAe;IAGlB,MAAMO,6BAA6BtB,eAAekB,qBAAqBJ,yBAAyBS,OAAO;IAEvG,qBAAO,KAACZ;QAAU,GAAGG,wBAA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,7 +1,6 @@
|
|
|
1
1
|
export { Citation, citationClassNames, renderCitation_unstable, useCitation_unstable, useCitationStyles_unstable } from './Citation';
|
|
2
2
|
export { Reference, referenceClassNames, renderReference_unstable, useReference_unstable, useReferenceStyles_unstable } from './Reference';
|
|
3
|
-
export {
|
|
3
|
+
export { useReferenceCitationPreview, useReferenceGroup } from './hooks';
|
|
4
4
|
export { ReferenceList, referenceListClassNames, useReferenceList_unstable, useReferenceListStyles_unstable, renderReferenceList_unstable } from './ReferenceList';
|
|
5
|
-
export { ReferenceGroup, referenceGroupClassNames, renderReferenceGroup_unstable, useReferenceGroup_unstable, useReferenceGroupStyles_unstable } from './ReferenceGroup';
|
|
6
5
|
export { ReferenceGroupToggle, referenceGroupToggleClassNames, renderReferenceGroupToggle_unstable, useReferenceGroupToggleStyles_unstable, useReferenceGroupToggle_unstable } from './ReferenceGroupToggle';
|
|
7
6
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export {\n Citation,\n citationClassNames,\n renderCitation_unstable,\n useCitation_unstable,\n useCitationStyles_unstable,\n} from './Citation';\nexport {\n Reference,\n referenceClassNames,\n renderReference_unstable,\n useReference_unstable,\n useReferenceStyles_unstable,\n} from './Reference';\nexport {
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export {\n Citation,\n citationClassNames,\n renderCitation_unstable,\n useCitation_unstable,\n useCitationStyles_unstable,\n} from './Citation';\nexport {\n Reference,\n referenceClassNames,\n renderReference_unstable,\n useReference_unstable,\n useReferenceStyles_unstable,\n} from './Reference';\nexport { useReferenceCitationPreview, useReferenceGroup } from './hooks';\nexport {\n ReferenceList,\n referenceListClassNames,\n useReferenceList_unstable,\n useReferenceListStyles_unstable,\n renderReferenceList_unstable,\n} from './ReferenceList';\nexport {\n ReferenceGroupToggle,\n referenceGroupToggleClassNames,\n renderReferenceGroupToggle_unstable,\n useReferenceGroupToggleStyles_unstable,\n useReferenceGroupToggle_unstable,\n} from './ReferenceGroupToggle';\n\n// Types\n\nexport type { CitationSlots, CitationProps, CitationState } from './Citation';\nexport type { ReferenceSlots, ReferenceProps, ReferenceState } from './Reference';\nexport type { ReferenceListSlots, ReferenceListProps, ReferenceListState } from './ReferenceList';\nexport type {\n ReferenceGroupToggleSlots,\n ReferenceGroupToggleProps,\n ReferenceGroupToggleState,\n} from './ReferenceGroupToggle';\n\nexport type {\n PackagedCitationProps,\n PackagedCitation,\n PackagedReferenceProps,\n PackagedReference,\n ReferenceCitationData,\n UseReferenceCitationPreview,\n UseReferenceGroup,\n UseReferenceGroupProps,\n} from './hooks';\n"],"names":["Citation","citationClassNames","renderCitation_unstable","useCitation_unstable","useCitationStyles_unstable","Reference","referenceClassNames","renderReference_unstable","useReference_unstable","useReferenceStyles_unstable","useReferenceCitationPreview","useReferenceGroup","ReferenceList","referenceListClassNames","useReferenceList_unstable","useReferenceListStyles_unstable","renderReferenceList_unstable","ReferenceGroupToggle","referenceGroupToggleClassNames","renderReferenceGroupToggle_unstable","useReferenceGroupToggleStyles_unstable","useReferenceGroupToggle_unstable"],"mappings":"AAAA,SACEA,QAAQ,EACRC,kBAAkB,EAClBC,uBAAuB,EACvBC,oBAAoB,EACpBC,0BAA0B,QACrB,aAAa;AACpB,SACEC,SAAS,EACTC,mBAAmB,EACnBC,wBAAwB,EACxBC,qBAAqB,EACrBC,2BAA2B,QACtB,cAAc;AACrB,SAASC,2BAA2B,EAAEC,iBAAiB,QAAQ,UAAU;AACzE,SACEC,aAAa,EACbC,uBAAuB,EACvBC,yBAAyB,EACzBC,+BAA+B,EAC/BC,4BAA4B,QACvB,kBAAkB;AACzB,SACEC,oBAAoB,EACpBC,8BAA8B,EAC9BC,mCAAmC,EACnCC,sCAAsC,EACtCC,gCAAgC,QAC3B,yBAAyB"}
|
|
@@ -10,29 +10,7 @@ Object.defineProperty(exports, "renderCitation_unstable", {
|
|
|
10
10
|
});
|
|
11
11
|
const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
|
|
12
12
|
const _reactcomponents = require("@fluentui/react-components");
|
|
13
|
-
const popoverPositioning = {
|
|
14
|
-
overflowBoundaryPadding: 4,
|
|
15
|
-
position: 'below'
|
|
16
|
-
};
|
|
17
13
|
const renderCitation_unstable = (state)=>{
|
|
18
14
|
(0, _reactcomponents.assertSlots)(state);
|
|
19
|
-
return
|
|
20
|
-
closeOnScroll: true,
|
|
21
|
-
onOpenChange: state.onPopoverOpenChange,
|
|
22
|
-
open: state.isPopoverOpen,
|
|
23
|
-
positioning: popoverPositioning,
|
|
24
|
-
size: "small",
|
|
25
|
-
trapFocus: true,
|
|
26
|
-
unstable_disableAutoFocus: state.disableAutoFocus,
|
|
27
|
-
withArrow: true,
|
|
28
|
-
children: [
|
|
29
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactcomponents.PopoverTrigger, {
|
|
30
|
-
disableButtonEnhancement: true,
|
|
31
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.root, {})
|
|
32
|
-
}),
|
|
33
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(state.popoverSurface, {
|
|
34
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.popover, {})
|
|
35
|
-
})
|
|
36
|
-
]
|
|
37
|
-
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(state.root, {});
|
|
15
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(state.root, {});
|
|
38
16
|
}; //# sourceMappingURL=renderCitation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["renderCitation.js"],"sourcesContent":["import { jsx as _jsx
|
|
1
|
+
{"version":3,"sources":["renderCitation.js"],"sourcesContent":["import { jsx as _jsx } from \"@fluentui/react-jsx-runtime/jsx-runtime\";\nimport { assertSlots } from '@fluentui/react-components';\n/**\n * Render the final JSX of Citation\n */\nexport const renderCitation_unstable = state => {\n assertSlots(state);\n return /*#__PURE__*/_jsx(state.root, {});\n};\n//# sourceMappingURL=renderCitation.js.map"],"names":["renderCitation_unstable","state","assertSlots","_jsx","root"],"mappings":";;;;+BAKaA;;;eAAAA;;;4BALe;iCACA;AAIrB,MAAMA,0BAA0BC,CAAAA;IACrCC,IAAAA,4BAAW,EAACD;IACZ,OAAO,WAAW,GAAEE,IAAAA,eAAI,EAACF,MAAMG,IAAI,EAAE,CAAC;AACxC,GACA,0CAA0C"}
|
|
@@ -8,146 +8,16 @@ Object.defineProperty(exports, "useCitation_unstable", {
|
|
|
8
8
|
return useCitation_unstable;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
|
-
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
11
|
const _reactcomponents = require("@fluentui/react-components");
|
|
14
|
-
const _keyboardkeys = require("@fluentui/keyboard-keys");
|
|
15
|
-
const _reactutilities = require("@fluentui/react-utilities");
|
|
16
12
|
const _reactpreview = require("@fluentui-copilot/react-preview");
|
|
17
|
-
const POPOVER_MOUSE_HIDE_DELAY = 500;
|
|
18
|
-
const POPOVER_KEYBOARD_HIDE_DELAY = 0;
|
|
19
|
-
const getDelay = (type)=>{
|
|
20
|
-
if (type === 'focus' || type === 'blur') {
|
|
21
|
-
return POPOVER_KEYBOARD_HIDE_DELAY;
|
|
22
|
-
}
|
|
23
|
-
return POPOVER_MOUSE_HIDE_DELAY;
|
|
24
|
-
};
|
|
25
13
|
const useCitation_unstable = (props, ref)=>{
|
|
26
|
-
const {
|
|
27
|
-
const
|
|
28
|
-
const [setTimeout, clearTimeout] = (0, _reactutilities.useTimeout)();
|
|
29
|
-
const popoverId = (0, _reactcomponents.useId)('citation-popover-');
|
|
30
|
-
const [disableAutoFocus, setDisableAutoFocus] = _react.useState(true);
|
|
31
|
-
const { current: citationInternalState } = _react.useRef({
|
|
32
|
-
openByClick: false,
|
|
33
|
-
openByHoverOverCitation: false,
|
|
34
|
-
openByHoverOverPopover: false,
|
|
35
|
-
openByKeyboard: false
|
|
36
|
-
});
|
|
37
|
-
const isOpen = ()=>{
|
|
38
|
-
return citationInternalState.openByClick || citationInternalState.openByHoverOverCitation || citationInternalState.openByHoverOverPopover || citationInternalState.openByKeyboard;
|
|
39
|
-
};
|
|
40
|
-
const [isPopoverOpen, setIsPopoverOpen] = _react.useState(false);
|
|
41
|
-
const preventDefaultClose = _react.useRef(false);
|
|
42
|
-
const handleCitationTargetEnter = (e)=>{
|
|
43
|
-
citationInternalState.openByHoverOverCitation = true;
|
|
44
|
-
// We want to disable auto focus only if the popover is being opened by hovering over the citation
|
|
45
|
-
if (!citationInternalState.openByClick && !citationInternalState.openByKeyboard) {
|
|
46
|
-
setDisableAutoFocus(true);
|
|
47
|
-
}
|
|
48
|
-
setIsPopoverOpen(isOpen());
|
|
49
|
-
};
|
|
50
|
-
const handleCitationTargetLeave = (e)=>{
|
|
51
|
-
citationInternalState.openByHoverOverCitation = false;
|
|
52
|
-
setTimeout(()=>{
|
|
53
|
-
setIsPopoverOpen(isOpen());
|
|
54
|
-
}, getDelay(e.type));
|
|
55
|
-
};
|
|
56
|
-
const handleCitationClick = (e)=>{
|
|
57
|
-
// Setting preventDefaultClose so that onPopoverOpenChange does not apply its logic when click is on the citation as we want to control that behavior.
|
|
58
|
-
preventDefaultClose.current = true;
|
|
59
|
-
// We set disableAutoFocus to false so that interactive elements within popover can be focused when it opens via click.
|
|
60
|
-
setDisableAutoFocus(false);
|
|
61
|
-
// If openByKeyboard is true, then the popover was already opened via keyboard and we always want to close it.
|
|
62
|
-
citationInternalState.openByClick = citationInternalState.openByKeyboard ? false : !citationInternalState.openByClick;
|
|
63
|
-
citationInternalState.openByHoverOverCitation = false;
|
|
64
|
-
citationInternalState.openByHoverOverPopover = false;
|
|
65
|
-
citationInternalState.openByKeyboard = false;
|
|
66
|
-
setIsPopoverOpen(isOpen());
|
|
67
|
-
};
|
|
68
|
-
const handleCitationKeyDown = (e)=>{
|
|
69
|
-
if (e.key === _keyboardkeys.Enter) {
|
|
70
|
-
clearTimeout();
|
|
71
|
-
// Setting default prevented so the enter key does not trigger a click event or onPopoverOpenChange.
|
|
72
|
-
e.preventDefault();
|
|
73
|
-
// We set disableAutoFocus to false so that interactive elements within popover can be focused when it opens via keyboard.
|
|
74
|
-
setDisableAutoFocus(false);
|
|
75
|
-
// If openByClick is true, then the popover was already opened via click and we always want to close it.
|
|
76
|
-
citationInternalState.openByKeyboard = citationInternalState.openByClick ? false : !citationInternalState.openByKeyboard;
|
|
77
|
-
citationInternalState.openByClick = false;
|
|
78
|
-
citationInternalState.openByHoverOverCitation = false;
|
|
79
|
-
citationInternalState.openByHoverOverPopover = false;
|
|
80
|
-
setIsPopoverOpen(isOpen());
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
const handlePopoverTargetEnter = (e)=>{
|
|
84
|
-
citationInternalState.openByHoverOverPopover = true;
|
|
85
|
-
setIsPopoverOpen(isOpen());
|
|
86
|
-
};
|
|
87
|
-
const handlePopoverTargetLeave = (e)=>{
|
|
88
|
-
citationInternalState.openByHoverOverPopover = false;
|
|
89
|
-
setTimeout(()=>{
|
|
90
|
-
setIsPopoverOpen(isOpen());
|
|
91
|
-
}, getDelay(e.type));
|
|
92
|
-
};
|
|
93
|
-
const onPopoverOpenChange = (e, data)=>{
|
|
94
|
-
if (!data.open) {
|
|
95
|
-
// We set all open state to false if preventDefaultClose was not set to true
|
|
96
|
-
if (!preventDefaultClose.current) {
|
|
97
|
-
clearTimeout();
|
|
98
|
-
citationInternalState.openByClick = false;
|
|
99
|
-
citationInternalState.openByHoverOverCitation = false;
|
|
100
|
-
citationInternalState.openByHoverOverPopover = false;
|
|
101
|
-
citationInternalState.openByKeyboard = false;
|
|
102
|
-
// use isOpen if managing owned popover, otherwise use data.open
|
|
103
|
-
const open = popover ? isOpen() : data.open;
|
|
104
|
-
setIsPopoverOpen(open);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
preventDefaultClose.current = false;
|
|
108
|
-
};
|
|
109
|
-
// hitting escape should close the popover if it was opened by hover
|
|
110
|
-
// this is necessary to attach to the document because focus is likely not within the citation or popover
|
|
111
|
-
(0, _reactcomponents.useIsomorphicLayoutEffect)(()=>{
|
|
112
|
-
if (isPopoverOpen) {
|
|
113
|
-
const onDocumentKeyDown = (e)=>{
|
|
114
|
-
const openedByHover = !citationInternalState.openByClick && !citationInternalState.openByKeyboard;
|
|
115
|
-
if (openedByHover && e.key === _keyboardkeys.Escape) {
|
|
116
|
-
clearTimeout();
|
|
117
|
-
// We set state back to its default if the Escape key has been pressed
|
|
118
|
-
setDisableAutoFocus(true);
|
|
119
|
-
citationInternalState.openByClick = false;
|
|
120
|
-
citationInternalState.openByHoverOverCitation = false;
|
|
121
|
-
citationInternalState.openByHoverOverPopover = false;
|
|
122
|
-
citationInternalState.openByKeyboard = false;
|
|
123
|
-
setIsPopoverOpen(isOpen());
|
|
124
|
-
e.stopPropagation();
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('keydown', onDocumentKeyDown, {
|
|
128
|
-
capture: true
|
|
129
|
-
});
|
|
130
|
-
return ()=>{
|
|
131
|
-
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('keydown', onDocumentKeyDown, {
|
|
132
|
-
capture: true
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
}, [
|
|
137
|
-
targetDocument,
|
|
138
|
-
isPopoverOpen
|
|
139
|
-
]);
|
|
140
|
-
const isPopoverLocked = (0, _reactpreview.usePreviewContext_unstable)((ctx)=>ctx.isPreviewLocked) && props['aria-expanded'] || citationInternalState.openByClick || citationInternalState.openByKeyboard;
|
|
14
|
+
const { referenceHref, block = false, ...otherProps } = props;
|
|
15
|
+
const isPopoverLocked = (0, _reactpreview.usePreviewContext_unstable)((ctx)=>ctx.isPreviewLocked) && props['aria-expanded'];
|
|
141
16
|
const state = {
|
|
142
17
|
block,
|
|
143
|
-
disableAutoFocus,
|
|
144
|
-
isPopoverOpen,
|
|
145
18
|
isPopoverLocked,
|
|
146
|
-
onPopoverOpenChange,
|
|
147
19
|
components: {
|
|
148
|
-
root: 'a'
|
|
149
|
-
popover: 'div',
|
|
150
|
-
popoverSurface: _reactcomponents.PopoverSurface
|
|
20
|
+
root: 'a'
|
|
151
21
|
},
|
|
152
22
|
root: _reactcomponents.slot.always((0, _reactcomponents.getNativeElementProps)('a', {
|
|
153
23
|
ref,
|
|
@@ -157,29 +27,7 @@ const useCitation_unstable = (props, ref)=>{
|
|
|
157
27
|
...otherProps
|
|
158
28
|
}), {
|
|
159
29
|
elementType: 'a'
|
|
160
|
-
}),
|
|
161
|
-
popover: _reactcomponents.slot.optional(popover, {
|
|
162
|
-
elementType: 'div'
|
|
163
|
-
}),
|
|
164
|
-
popoverSurface: _reactcomponents.slot.optional(popoverSurface, {
|
|
165
|
-
defaultProps: {
|
|
166
|
-
id: popoverId,
|
|
167
|
-
'aria-labelledby': popoverId
|
|
168
|
-
},
|
|
169
|
-
elementType: _reactcomponents.PopoverSurface,
|
|
170
|
-
renderByDefault: true
|
|
171
30
|
})
|
|
172
31
|
};
|
|
173
|
-
// attach popover handling events only if a popover is present
|
|
174
|
-
if (state.popover) {
|
|
175
|
-
state.root.onMouseEnter = (0, _reactcomponents.mergeCallbacks)(state.root.onMouseEnter, handleCitationTargetEnter);
|
|
176
|
-
state.root.onMouseLeave = (0, _reactcomponents.mergeCallbacks)(state.root.onMouseLeave, handleCitationTargetLeave);
|
|
177
|
-
state.root.onBlur = (0, _reactcomponents.mergeCallbacks)(state.root.onBlur, handleCitationTargetLeave);
|
|
178
|
-
state.root.onClick = (0, _reactcomponents.mergeCallbacks)(state.root.onClick, handleCitationClick);
|
|
179
|
-
state.root.onKeyDown = (0, _reactcomponents.mergeCallbacks)(state.root.onKeyDown, handleCitationKeyDown);
|
|
180
|
-
state.popover.onMouseEnter = (0, _reactcomponents.mergeCallbacks)(state.popover.onMouseEnter, handlePopoverTargetEnter);
|
|
181
|
-
state.popover.onMouseLeave = (0, _reactcomponents.mergeCallbacks)(state.popover.onMouseLeave, handlePopoverTargetLeave);
|
|
182
|
-
state.popover.onFocus = (0, _reactcomponents.mergeCallbacks)(state.popover.onFocus, handlePopoverTargetEnter);
|
|
183
|
-
}
|
|
184
32
|
return state;
|
|
185
33
|
}; //# sourceMappingURL=useCitation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useCitation.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, PopoverSurface, mergeCallbacks, slot, useFluent, useId, useIsomorphicLayoutEffect } from '@fluentui/react-components';\nimport { Enter, Escape } from '@fluentui/keyboard-keys';\nimport { useTimeout } from '@fluentui/react-utilities';\nimport { usePreviewContext_unstable } from '@fluentui-copilot/react-preview';\nconst POPOVER_MOUSE_HIDE_DELAY = 500;\nconst POPOVER_KEYBOARD_HIDE_DELAY = 0;\nconst getDelay = type => {\n if (type === 'focus' || type === 'blur') {\n return POPOVER_KEYBOARD_HIDE_DELAY;\n }\n return POPOVER_MOUSE_HIDE_DELAY;\n};\n/**\n * Create the state required to render Citation.\n *\n * The returned state can be modified with hooks such as useCitationStyles_unstable,\n * before being passed to renderCitation_unstable.\n *\n * @param props - props from this instance of Citation\n * @param ref - reference to root HTMLElement of Citation\n */\nexport const useCitation_unstable = (props, ref) => {\n const {\n popover,\n popoverSurface,\n referenceHref,\n block = false,\n ...otherProps\n } = props;\n const {\n targetDocument\n } = useFluent();\n const [setTimeout, clearTimeout] = useTimeout();\n const popoverId = useId('citation-popover-');\n const [disableAutoFocus, setDisableAutoFocus] = React.useState(true);\n const {\n current: citationInternalState\n } = React.useRef({\n openByClick: false,\n openByHoverOverCitation: false,\n openByHoverOverPopover: false,\n openByKeyboard: false\n });\n const isOpen = () => {\n return citationInternalState.openByClick || citationInternalState.openByHoverOverCitation || citationInternalState.openByHoverOverPopover || citationInternalState.openByKeyboard;\n };\n const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);\n const preventDefaultClose = React.useRef(false);\n const handleCitationTargetEnter = e => {\n citationInternalState.openByHoverOverCitation = true;\n // We want to disable auto focus only if the popover is being opened by hovering over the citation\n if (!citationInternalState.openByClick && !citationInternalState.openByKeyboard) {\n setDisableAutoFocus(true);\n }\n setIsPopoverOpen(isOpen());\n };\n const handleCitationTargetLeave = e => {\n citationInternalState.openByHoverOverCitation = false;\n setTimeout(() => {\n setIsPopoverOpen(isOpen());\n }, getDelay(e.type));\n };\n const handleCitationClick = e => {\n // Setting preventDefaultClose so that onPopoverOpenChange does not apply its logic when click is on the citation as we want to control that behavior.\n preventDefaultClose.current = true;\n // We set disableAutoFocus to false so that interactive elements within popover can be focused when it opens via click.\n setDisableAutoFocus(false);\n // If openByKeyboard is true, then the popover was already opened via keyboard and we always want to close it.\n citationInternalState.openByClick = citationInternalState.openByKeyboard ? false : !citationInternalState.openByClick;\n citationInternalState.openByHoverOverCitation = false;\n citationInternalState.openByHoverOverPopover = false;\n citationInternalState.openByKeyboard = false;\n setIsPopoverOpen(isOpen());\n };\n const handleCitationKeyDown = e => {\n if (e.key === Enter) {\n clearTimeout();\n // Setting default prevented so the enter key does not trigger a click event or onPopoverOpenChange.\n e.preventDefault();\n // We set disableAutoFocus to false so that interactive elements within popover can be focused when it opens via keyboard.\n setDisableAutoFocus(false);\n // If openByClick is true, then the popover was already opened via click and we always want to close it.\n citationInternalState.openByKeyboard = citationInternalState.openByClick ? false : !citationInternalState.openByKeyboard;\n citationInternalState.openByClick = false;\n citationInternalState.openByHoverOverCitation = false;\n citationInternalState.openByHoverOverPopover = false;\n setIsPopoverOpen(isOpen());\n }\n };\n const handlePopoverTargetEnter = e => {\n citationInternalState.openByHoverOverPopover = true;\n setIsPopoverOpen(isOpen());\n };\n const handlePopoverTargetLeave = e => {\n citationInternalState.openByHoverOverPopover = false;\n setTimeout(() => {\n setIsPopoverOpen(isOpen());\n }, getDelay(e.type));\n };\n const onPopoverOpenChange = (e, data) => {\n if (!data.open) {\n // We set all open state to false if preventDefaultClose was not set to true\n if (!preventDefaultClose.current) {\n clearTimeout();\n citationInternalState.openByClick = false;\n citationInternalState.openByHoverOverCitation = false;\n citationInternalState.openByHoverOverPopover = false;\n citationInternalState.openByKeyboard = false;\n // use isOpen if managing owned popover, otherwise use data.open\n const open = popover ? isOpen() : data.open;\n setIsPopoverOpen(open);\n }\n }\n preventDefaultClose.current = false;\n };\n // hitting escape should close the popover if it was opened by hover\n // this is necessary to attach to the document because focus is likely not within the citation or popover\n useIsomorphicLayoutEffect(() => {\n if (isPopoverOpen) {\n const onDocumentKeyDown = e => {\n const openedByHover = !citationInternalState.openByClick && !citationInternalState.openByKeyboard;\n if (openedByHover && e.key === Escape) {\n clearTimeout();\n // We set state back to its default if the Escape key has been pressed\n setDisableAutoFocus(true);\n citationInternalState.openByClick = false;\n citationInternalState.openByHoverOverCitation = false;\n citationInternalState.openByHoverOverPopover = false;\n citationInternalState.openByKeyboard = false;\n setIsPopoverOpen(isOpen());\n e.stopPropagation();\n }\n };\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('keydown', onDocumentKeyDown, {\n capture: true\n });\n return () => {\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('keydown', onDocumentKeyDown, {\n capture: true\n });\n };\n }\n }, [targetDocument, isPopoverOpen]);\n const isPopoverLocked = usePreviewContext_unstable(ctx => ctx.isPreviewLocked) && props['aria-expanded'] || citationInternalState.openByClick || citationInternalState.openByKeyboard;\n const state = {\n block,\n disableAutoFocus,\n isPopoverOpen,\n isPopoverLocked,\n onPopoverOpenChange,\n components: {\n root: 'a',\n popover: 'div',\n popoverSurface: PopoverSurface\n },\n root: slot.always(getNativeElementProps('a', {\n ref,\n href: referenceHref,\n role: null,\n 'aria-expanded': null,\n ...otherProps\n }), {\n elementType: 'a'\n }),\n popover: slot.optional(popover, {\n elementType: 'div'\n }),\n popoverSurface: slot.optional(popoverSurface, {\n defaultProps: {\n id: popoverId,\n 'aria-labelledby': popoverId\n },\n elementType: PopoverSurface,\n renderByDefault: true\n })\n };\n // attach popover handling events only if a popover is present\n if (state.popover) {\n state.root.onMouseEnter = mergeCallbacks(state.root.onMouseEnter, handleCitationTargetEnter);\n state.root.onMouseLeave = mergeCallbacks(state.root.onMouseLeave, handleCitationTargetLeave);\n state.root.onBlur = mergeCallbacks(state.root.onBlur, handleCitationTargetLeave);\n state.root.onClick = mergeCallbacks(state.root.onClick, handleCitationClick);\n state.root.onKeyDown = mergeCallbacks(state.root.onKeyDown, handleCitationKeyDown);\n state.popover.onMouseEnter = mergeCallbacks(state.popover.onMouseEnter, handlePopoverTargetEnter);\n state.popover.onMouseLeave = mergeCallbacks(state.popover.onMouseLeave, handlePopoverTargetLeave);\n state.popover.onFocus = mergeCallbacks(state.popover.onFocus, handlePopoverTargetEnter);\n }\n return state;\n};\n//# sourceMappingURL=useCitation.js.map"],"names":["useCitation_unstable","POPOVER_MOUSE_HIDE_DELAY","POPOVER_KEYBOARD_HIDE_DELAY","getDelay","type","props","ref","popover","popoverSurface","referenceHref","block","otherProps","targetDocument","useFluent","setTimeout","clearTimeout","useTimeout","popoverId","useId","disableAutoFocus","setDisableAutoFocus","React","useState","current","citationInternalState","useRef","openByClick","openByHoverOverCitation","openByHoverOverPopover","openByKeyboard","isOpen","isPopoverOpen","setIsPopoverOpen","preventDefaultClose","handleCitationTargetEnter","e","handleCitationTargetLeave","handleCitationClick","handleCitationKeyDown","key","Enter","preventDefault","handlePopoverTargetEnter","handlePopoverTargetLeave","onPopoverOpenChange","data","open","useIsomorphicLayoutEffect","onDocumentKeyDown","openedByHover","Escape","stopPropagation","addEventListener","capture","removeEventListener","isPopoverLocked","usePreviewContext_unstable","ctx","isPreviewLocked","state","components","root","PopoverSurface","slot","always","getNativeElementProps","href","role","elementType","optional","defaultProps","id","renderByDefault","onMouseEnter","mergeC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N0D,MAAM;YACN,iBAAiB;YACjB,GAAGxD,UAAU;QACf,IAAI;YACFyD,aAAa;QACf;QACA7D,SAASwD,qBAAI,CAACM,QAAQ,CAAC9D,SAAS;YAC9B6D,aAAa;QACf;QACA5D,gBAAgBuD,qBAAI,CAACM,QAAQ,CAAC7D,gBAAgB;YAC5C8D,cAAc;gBACZC,IAAItD;gBACJ,mBAAmBA;YACrB;YACAmD,aAAaN,+BAAc;YAC3BU,iBAAiB;QACnB;IACF;IACA,8DAA8D;IAC9D,IAAIb,MAAMpD,OAAO,EAAE;QACjBoD,MAAME,IAAI,CAACY,YAAY,GAAGC,IAAAA,+BAAc,EAACf,MAAME,IAAI,CAACY,YAAY,EAAEvC;QAClEyB,MAAME,IAAI,CAACc,YAAY,GAAGD,IAAAA,+BAAc,EAACf,MAAME,IAAI,CAACc,YAAY,EAAEvC;QAClEuB,MAAME,IAAI,CAACe,MAAM,GAAGF,IAAAA,+BAAc,EAACf,MAAME,IAAI,CAACe,MAAM,EAAExC;QACtDuB,MAAME,IAAI,CAACgB,OAAO,GAAGH,IAAAA,+BAAc,EAACf,MAAME,IAAI,CAACgB,OAAO,EAAExC;QACxDsB,MAAME,IAAI,CAACiB,SAAS,GAAGJ,IAAAA,+BAAc,EAACf,MAAME,IAAI,CAACiB,SAAS,EAAExC;QAC5DqB,MAAMpD,OAAO,CAACkE,YAAY,GAAGC,IAAAA,+BAAc,EAACf,MAAMpD,OAAO,CAACkE,YAAY,EAAE/B;QACxEiB,MAAMpD,OAAO,CAACoE,YAAY,GAAGD,IAAAA,+BAAc,EAACf,MAAMpD,OAAO,CAACoE,YAAY,EAAEhC;QACxEgB,MAAMpD,OAAO,CAACwE,OAAO,GAAGL,IAAAA,+BAAc,EAACf,MAAMpD,OAAO,CAACwE,OAAO,EAAErC;IAChE;IACA,OAAOiB;AACT,GACA,uCAAuC"}
|
|
1
|
+
{"version":3,"sources":["useCitation.js"],"sourcesContent":["import { getNativeElementProps, slot } from '@fluentui/react-components';\nimport { usePreviewContext_unstable } from '@fluentui-copilot/react-preview';\n/**\n * Create the state required to render Citation.\n *\n * The returned state can be modified with hooks such as useCitationStyles_unstable,\n * before being passed to renderCitation_unstable.\n *\n * @param props - props from this instance of Citation\n * @param ref - reference to root HTMLElement of Citation\n */\nexport const useCitation_unstable = (props, ref) => {\n const {\n referenceHref,\n block = false,\n ...otherProps\n } = props;\n const isPopoverLocked = usePreviewContext_unstable(ctx => ctx.isPreviewLocked) && props['aria-expanded'];\n const state = {\n block,\n isPopoverLocked,\n components: {\n root: 'a'\n },\n root: slot.always(getNativeElementProps('a', {\n ref,\n href: referenceHref,\n role: null,\n 'aria-expanded': null,\n ...otherProps\n }), {\n elementType: 'a'\n })\n };\n return state;\n};\n//# sourceMappingURL=useCitation.js.map"],"names":["useCitation_unstable","props","ref","referenceHref","block","otherProps","isPopoverLocked","usePreviewContext_unstable","ctx","isPreviewLocked","state","components","root","slot","always","getNativeElementProps","href","role","elementType"],"mappings":";;;;+BAWaA;;;eAAAA;;;iCAX+B;8BACD;AAUpC,MAAMA,uBAAuB,CAACC,OAAOC;IAC1C,MAAM,EACJC,aAAa,EACbC,QAAQ,KAAK,EACb,GAAGC,YACJ,GAAGJ;IACJ,MAAMK,kBAAkBC,IAAAA,wCAA0B,EAACC,CAAAA,MAAOA,IAAIC,eAAe,KAAKR,KAAK,CAAC,gBAAgB;IACxG,MAAMS,QAAQ;QACZN;QACAE;QACAK,YAAY;YACVC,MAAM;QACR;QACAA,MAAMC,qBAAI,CAACC,MAAM,CAACC,IAAAA,sCAAqB,EAAC,KAAK;YAC3Cb;YACAc,MAAMb;YACNc,MAAM;YACN,iBAAiB;YACjB,GAAGZ,UAAU;QACf,IAAI;YACFa,aAAa;QACf;IACF;IACA,OAAOR;AACT,GACA,uCAAuC"}
|
|
@@ -18,9 +18,7 @@ _export(exports, {
|
|
|
18
18
|
});
|
|
19
19
|
const _reactcomponents = require("@fluentui/react-components");
|
|
20
20
|
const citationClassNames = {
|
|
21
|
-
root: 'fai-Citation'
|
|
22
|
-
popover: 'fai-Citation__popover',
|
|
23
|
-
popoverSurface: 'fai-Citation__popoverSurface'
|
|
21
|
+
root: 'fai-Citation'
|
|
24
22
|
};
|
|
25
23
|
const useCitationBaseClassName = (0, _reactcomponents.__resetStyles)("rad2akz", "r1hx2d32", [
|
|
26
24
|
".rad2akz{display:inline-flex;justify-content:center;box-sizing:border-box;align-items:center;font-family:var(--fontFamilyBase);font-size:var(--fontSizeBase100);font-weight:var(--fontWeightSemibold);line-height:var(--lineHeightBase100);color:var(--colorNeutralForeground2);border:var(--strokeWidthThin) solid var(--colorNeutralStroke2);min-width:14px;height:14px;vertical-align:calc((var(--lineHeightBase100) - var(--fontSizeBase100)) / 2);border-radius:var(--borderRadiusMedium);text-decoration:none;margin-left:var(--spacingHorizontalXXS);margin-right:var(--spacingHorizontalXXS);}",
|
|
@@ -93,8 +91,5 @@ const useCitationStyles_unstable = (state)=>{
|
|
|
93
91
|
const rootBaseClassName = useCitationBaseClassName();
|
|
94
92
|
const rootStyles = useCitationRootStyles();
|
|
95
93
|
state.root.className = (0, _reactcomponents.mergeClasses)(citationClassNames.root, state.isPopoverLocked && rootStyles.isPopoverLocked, state.block && rootStyles.isBlock, rootBaseClassName, state.root.className);
|
|
96
|
-
if (state.popover) {
|
|
97
|
-
state.popover.className = (0, _reactcomponents.mergeClasses)(citationClassNames.popover, state.popover.className);
|
|
98
|
-
}
|
|
99
94
|
return state;
|
|
100
95
|
}; //# sourceMappingURL=useCitationStyles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useCitationStyles.js"],"sourcesContent":["import { __resetStyles, __styles, mergeClasses, shorthands, tokens, typographyStyles } from '@fluentui/react-components';\nexport const citationClassNames = {\n root: 'fai-Citation'
|
|
1
|
+
{"version":3,"sources":["useCitationStyles.js"],"sourcesContent":["import { __resetStyles, __styles, mergeClasses, shorthands, tokens, typographyStyles } from '@fluentui/react-components';\nexport const citationClassNames = {\n root: 'fai-Citation'\n};\nconst useCitationBaseClassName = __resetStyles(\"rad2akz\", \"r1hx2d32\", [\".rad2akz{display:inline-flex;justify-content:center;box-sizing:border-box;align-items:center;font-family:var(--fontFamilyBase);font-size:var(--fontSizeBase100);font-weight:var(--fontWeightSemibold);line-height:var(--lineHeightBase100);color:var(--colorNeutralForeground2);border:var(--strokeWidthThin) solid var(--colorNeutralStroke2);min-width:14px;height:14px;vertical-align:calc((var(--lineHeightBase100) - var(--fontSizeBase100)) / 2);border-radius:var(--borderRadiusMedium);text-decoration:none;margin-left:var(--spacingHorizontalXXS);margin-right:var(--spacingHorizontalXXS);}\", \".rad2akz:hover{cursor:pointer;color:var(--colorBrandForeground2Hover);border-color:var(--colorBrandStroke2Hover);background-color:var(--colorBrandBackground2Hover);}\", \".rad2akz:hover:active{cursor:pointer;color:var(--colorBrandForeground2Pressed);border-color:var(--colorBrandStroke2Pressed);background-color:var(--colorBrandBackground2Pressed);}\", \".r1hx2d32{display:inline-flex;justify-content:center;box-sizing:border-box;align-items:center;font-family:var(--fontFamilyBase);font-size:var(--fontSizeBase100);font-weight:var(--fontWeightSemibold);line-height:var(--lineHeightBase100);color:var(--colorNeutralForeground2);border:var(--strokeWidthThin) solid var(--colorNeutralStroke2);min-width:14px;height:14px;vertical-align:calc((var(--lineHeightBase100) - var(--fontSizeBase100)) / 2);border-radius:var(--borderRadiusMedium);text-decoration:none;margin-right:var(--spacingHorizontalXXS);margin-left:var(--spacingHorizontalXXS);}\", \".r1hx2d32:hover{cursor:pointer;color:var(--colorBrandForeground2Hover);border-color:var(--colorBrandStroke2Hover);background-color:var(--colorBrandBackground2Hover);}\", \".r1hx2d32:hover:active{cursor:pointer;color:var(--colorBrandForeground2Pressed);border-color:var(--colorBrandStroke2Pressed);background-color:var(--colorBrandBackground2Pressed);}\"]);\nconst useCitationRootStyles = __styles({\n isBlock: {\n mc9l5x: \"f22iagw\",\n Frg6f3: [\"f1tyq0we\", \"f11qmguv\"],\n t21cq0: [\"f11qmguv\", \"f1tyq0we\"]\n },\n isPopoverLocked: {\n sj55zd: \"fkjhhq2\",\n g2u3we: \"f1nbqb3e\",\n h3c5rm: [\"fah3j9v\", \"f56crja\"],\n B9xav0g: \"fef4ti1\",\n zhjwy3: [\"f56crja\", \"fah3j9v\"],\n De3pzq: \"f16xkysk\",\n Bi91k9c: \"fbszb7v\",\n Bgoe8wy: \"ftxwbyd\",\n Bwzppfd: [\"f1p7dilp\", \"f15x2k42\"],\n oetu4i: \"fegdlwn\",\n gg5e9n: [\"f15x2k42\", \"f1p7dilp\"],\n Jwef8y: \"f121v1wq\"\n }\n}, {\n d: [\".f22iagw{display:flex;}\", \".f1tyq0we{margin-left:0;}\", \".f11qmguv{margin-right:0;}\", \".fkjhhq2{color:var(--colorBrandForeground2Pressed);}\", \".f1nbqb3e{border-top-color:var(--colorBrandStroke2Pressed);}\", \".fah3j9v{border-right-color:var(--colorBrandStroke2Pressed);}\", \".f56crja{border-left-color:var(--colorBrandStroke2Pressed);}\", \".fef4ti1{border-bottom-color:var(--colorBrandStroke2Pressed);}\", \".f16xkysk{background-color:var(--colorBrandBackground2);}\"],\n h: [\".fbszb7v:hover{color:var(--colorBrandForeground2Pressed);}\", \".ftxwbyd:hover{border-top-color:var(--colorBrandStroke2Pressed);}\", \".f1p7dilp:hover{border-right-color:var(--colorBrandStroke2Pressed);}\", \".f15x2k42:hover{border-left-color:var(--colorBrandStroke2Pressed);}\", \".fegdlwn:hover{border-bottom-color:var(--colorBrandStroke2Pressed);}\", \".f121v1wq:hover{background-color:var(--colorBrandBackground2);}\"]\n});\n/**\n * Apply styling to the Citation slots based on the state\n */\nexport const useCitationStyles_unstable = state => {\n const rootBaseClassName = useCitationBaseClassName();\n const rootStyles = useCitationRootStyles();\n state.root.className = mergeClasses(citationClassNames.root, state.isPopoverLocked && rootStyles.isPopoverLocked, state.block && rootStyles.isBlock, rootBaseClassName, state.root.className);\n return state;\n};\n//# sourceMappingURL=useCitationStyles.js.map"],"names":["citationClassNames","useCitationStyles_unstable","root","useCitationBaseClassName","__resetStyles","useCitationRootStyles","__styles","isBlock","mc9l5x","Frg6f3","t21cq0","isPopoverLocked","sj55zd","g2u3we","h3c5rm","B9xav0g","zhjwy3","De3pzq","Bi91k9c","Bgoe8wy","Bwzppfd","oetu4i","gg5e9n","Jwef8y","d","h","state","rootBaseClassName","rootStyles","className","mergeClasses","block"],"mappings":";;;;;;;;;;;IACaA,kBAAkB;eAAlBA;;IA+BAC,0BAA0B;eAA1BA;;;iCAhC+E;AACrF,MAAMD,qBAAqB;IAChCE,MAAM;AACR;AACA,MAAMC,2BAA2BC,IAAAA,8BAAa,EAAC,WAAW,YAAY;IAAC;IAA0kB;IAAyK;IAAsL;IAA2kB;IAA0K;CAAsL;AAC35D,MAAMC,wBAAwBC,IAAAA,yBAAQ,EAAC;IACrCC,SAAS;QACPC,QAAQ;QACRC,QAAQ;YAAC;YAAY;SAAW;QAChCC,QAAQ;YAAC;YAAY;SAAW;IAClC;IACAC,iBAAiB;QACfC,QAAQ;QACRC,QAAQ;QACRC,QAAQ;YAAC;YAAW;SAAU;QAC9BC,SAAS;QACTC,QAAQ;YAAC;YAAW;SAAU;QAC9BC,QAAQ;QACRC,SAAS;QACTC,SAAS;QACTC,SAAS;YAAC;YAAY;SAAW;QACjCC,QAAQ;QACRC,QAAQ;YAAC;YAAY;SAAW;QAChCC,QAAQ;IACV;AACF,GAAG;IACDC,GAAG;QAAC;QAA2B;QAA6B;QAA8B;QAAwD;QAAgE;QAAiE;QAAgE;QAAkE;KAA4D;IACjdC,GAAG;QAAC;QAA8D;QAAqE;QAAwE;QAAuE;QAAwE;KAAkE;AACla;AAIO,MAAMxB,6BAA6ByB,CAAAA;IACxC,MAAMC,oBAAoBxB;IAC1B,MAAMyB,aAAavB;IACnBqB,MAAMxB,IAAI,CAAC2B,SAAS,GAAGC,IAAAA,6BAAY,EAAC9B,mBAAmBE,IAAI,EAAEwB,MAAMf,eAAe,IAAIiB,WAAWjB,eAAe,EAAEe,MAAMK,KAAK,IAAIH,WAAWrB,OAAO,EAAEoB,mBAAmBD,MAAMxB,IAAI,CAAC2B,SAAS;IAC5L,OAAOH;AACT,GACA,6CAA6C"}
|
|
@@ -23,7 +23,6 @@ const renderReference_unstable = (state)=>{
|
|
|
23
23
|
state.detailsButton && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.detailsButton, {})
|
|
24
24
|
]
|
|
25
25
|
}),
|
|
26
|
-
state.sensitivityLabel && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.sensitivityLabel, {}),
|
|
27
26
|
state.sensitivity && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.sensitivity, {}),
|
|
28
27
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(state.metadata, {
|
|
29
28
|
children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["renderReference.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"@fluentui/react-jsx-runtime/jsx-runtime\";\nimport { assertSlots } from '@fluentui/react-components';\n/**\n * Render the final JSX of Reference\n */\nexport const renderReference_unstable = state => {\n assertSlots(state);\n return /*#__PURE__*/_jsxs(state.root, {\n children: [state.citation && /*#__PURE__*/_jsx(state.citation, {}), state.media && /*#__PURE__*/_jsx(state.media, {}), /*#__PURE__*/_jsx(state.label, {}), state.actions && /*#__PURE__*/_jsxs(state.actions, {\n children: [state.actions.children, state.detailsButton && /*#__PURE__*/_jsx(state.detailsButton, {})]\n }), state.
|
|
1
|
+
{"version":3,"sources":["renderReference.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"@fluentui/react-jsx-runtime/jsx-runtime\";\nimport { assertSlots } from '@fluentui/react-components';\n/**\n * Render the final JSX of Reference\n */\nexport const renderReference_unstable = state => {\n assertSlots(state);\n return /*#__PURE__*/_jsxs(state.root, {\n children: [state.citation && /*#__PURE__*/_jsx(state.citation, {}), state.media && /*#__PURE__*/_jsx(state.media, {}), /*#__PURE__*/_jsx(state.label, {}), state.actions && /*#__PURE__*/_jsxs(state.actions, {\n children: [state.actions.children, state.detailsButton && /*#__PURE__*/_jsx(state.detailsButton, {})]\n }), state.sensitivity && /*#__PURE__*/_jsx(state.sensitivity, {}), /*#__PURE__*/_jsxs(state.metadata, {\n children: [state.primaryText && /*#__PURE__*/_jsx(state.primaryText, {}), state.secondaryText && /*#__PURE__*/_jsx(state.secondaryText, {}), state.tertiaryText && /*#__PURE__*/_jsx(state.tertiaryText, {}), state.icon && /*#__PURE__*/_jsx(state.icon, {}), state.metadata.children]\n }), /*#__PURE__*/_jsx(state.content, {})]\n });\n};\n//# sourceMappingURL=renderReference.js.map"],"names":["renderReference_unstable","state","assertSlots","_jsxs","root","children","citation","_jsx","media","label","actions","detailsButton","sensitivity","metadata","primaryText","secondaryText","tertiaryText","icon","content"],"mappings":";;;;+BAKaA;;;eAAAA;;;4BAL8B;iCACf;AAIrB,MAAMA,2BAA2BC,CAAAA;IACtCC,IAAAA,4BAAW,EAACD;IACZ,OAAO,WAAW,GAAEE,IAAAA,gBAAK,EAACF,MAAMG,IAAI,EAAE;QACpCC,UAAU;YAACJ,MAAMK,QAAQ,IAAI,WAAW,GAAEC,IAAAA,eAAI,EAACN,MAAMK,QAAQ,EAAE,CAAC;YAAIL,MAAMO,KAAK,IAAI,WAAW,GAAED,IAAAA,eAAI,EAACN,MAAMO,KAAK,EAAE,CAAC;YAAI,WAAW,GAAED,IAAAA,eAAI,EAACN,MAAMQ,KAAK,EAAE,CAAC;YAAIR,MAAMS,OAAO,IAAI,WAAW,GAAEP,IAAAA,gBAAK,EAACF,MAAMS,OAAO,EAAE;gBAC5ML,UAAU;oBAACJ,MAAMS,OAAO,CAACL,QAAQ;oBAAEJ,MAAMU,aAAa,IAAI,WAAW,GAAEJ,IAAAA,eAAI,EAACN,MAAMU,aAAa,EAAE,CAAC;iBAAG;YACvG;YAAIV,MAAMW,WAAW,IAAI,WAAW,GAAEL,IAAAA,eAAI,EAACN,MAAMW,WAAW,EAAE,CAAC;YAAI,WAAW,GAAET,IAAAA,gBAAK,EAACF,MAAMY,QAAQ,EAAE;gBACpGR,UAAU;oBAACJ,MAAMa,WAAW,IAAI,WAAW,GAAEP,IAAAA,eAAI,EAACN,MAAMa,WAAW,EAAE,CAAC;oBAAIb,MAAMc,aAAa,IAAI,WAAW,GAAER,IAAAA,eAAI,EAACN,MAAMc,aAAa,EAAE,CAAC;oBAAId,MAAMe,YAAY,IAAI,WAAW,GAAET,IAAAA,eAAI,EAACN,MAAMe,YAAY,EAAE,CAAC;oBAAIf,MAAMgB,IAAI,IAAI,WAAW,GAAEV,IAAAA,eAAI,EAACN,MAAMgB,IAAI,EAAE,CAAC;oBAAIhB,MAAMY,QAAQ,CAACR,QAAQ;iBAAC;YACzR;YAAI,WAAW,GAAEE,IAAAA,eAAI,EAACN,MAAMiB,OAAO,EAAE,CAAC;SAAG;IAC3C;AACF,GACA,2CAA2C"}
|
|
@@ -93,7 +93,6 @@ const useReference_unstable = (props, ref)=>{
|
|
|
93
93
|
actions: 'div',
|
|
94
94
|
label: 'div',
|
|
95
95
|
sensitivity: 'span',
|
|
96
|
-
sensitivityLabel: 'span',
|
|
97
96
|
metadata: 'div',
|
|
98
97
|
content: 'div',
|
|
99
98
|
primaryText: 'span',
|
|
@@ -114,7 +113,6 @@ const useReference_unstable = (props, ref)=>{
|
|
|
114
113
|
defaultProps: {
|
|
115
114
|
children: /*#__PURE__*/ _react.createElement(_Citation.Citation, {
|
|
116
115
|
block: true,
|
|
117
|
-
referenceId: referenceId,
|
|
118
116
|
...citationProps
|
|
119
117
|
}, index)
|
|
120
118
|
},
|
|
@@ -130,9 +128,6 @@ const useReference_unstable = (props, ref)=>{
|
|
|
130
128
|
sensitivity: _reactcomponents.slot.optional(props.sensitivity, {
|
|
131
129
|
elementType: 'span'
|
|
132
130
|
}),
|
|
133
|
-
sensitivityLabel: _reactcomponents.slot.optional(props.sensitivityLabel, {
|
|
134
|
-
elementType: 'span'
|
|
135
|
-
}),
|
|
136
131
|
metadata: _reactcomponents.slot.always(props.metadata, {
|
|
137
132
|
elementType: 'div'
|
|
138
133
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useReference.js"],"sourcesContent":["import * as React from 'react';\nimport { Button, Caption1, getNativeElementProps, mergeCallbacks, mergeClasses, slot, useId, usePopoverContext_unstable as usePopoverContext } from '@fluentui/react-components';\nimport { ChevronDown24Regular, ChevronUp24Regular, ChevronDown16Regular, ChevronUp16Regular } from '@fluentui/react-icons';\nimport { referenceExtraClassNames } from './useReferenceStyles';\nimport { Citation } from '../Citation';\nimport { useReferenceGroupSetOpen } from '../../context/ReferenceGroupContext';\nimport { useCopilotMode } from '@fluentui-copilot/react-provider';\n/**\n * Create the state required to render Reference.\n *\n * The returned state can be modified with hooks such as useReferenceStyles_unstable,\n * before being passed to renderReference_unstable.\n *\n * @param props - props from this instance of Reference\n * @param ref - reference to root HTMLElement of Reference\n */\nexport const useReference_unstable = (props, ref) => {\n const {\n index,\n referenceId,\n citationHref,\n excerpt,\n layout = 'inline'\n } = props;\n const mode = useCopilotMode(props.mode);\n const labelId = useId();\n const mediaId = useId();\n const [isExpanded, setIsExpanded] = React.useState(layout === 'popover' ? true : false);\n const setPopoverOpen = usePopoverContext(context => context.setOpen);\n const onExpandClick = _e => {\n setIsExpanded(!isExpanded);\n };\n const label = slot.always(props.label, {\n defaultProps: {\n id: labelId\n },\n elementType: 'div'\n });\n const media = slot.optional(props.media, {\n defaultProps: {\n id: mediaId\n },\n elementType: 'div'\n });\n if (media && /*#__PURE__*/React.isValidElement(media.children)) {\n media.children = /*#__PURE__*/React.cloneElement(media.children, {\n className: mergeClasses(media.children.props.className, referenceExtraClassNames.mediaChild)\n });\n }\n if (media === null || media === void 0 ? void 0 : media.id) {\n var _label_ariadescribedby;\n var _label_ariadescribedby_concat;\n label['aria-describedby'] = (_label_ariadescribedby_concat = (_label_ariadescribedby = label['aria-describedby']) === null || _label_ariadescribedby === void 0 ? void 0 : _label_ariadescribedby.concat(media.id)) !== null && _label_ariadescribedby_concat !== void 0 ? _label_ariadescribedby_concat : media.id;\n }\n const ariaLabelledByProp = props['aria-labelledby'];\n const groupSemantics = React.useMemo(() => {\n return layout === 'inline' ? {\n role: 'group',\n 'aria-labelledby': `${ariaLabelledByProp !== null && ariaLabelledByProp !== void 0 ? ariaLabelledByProp : ''} ${label.id}`,\n tabIndex: -1\n } : {};\n }, [layout, ariaLabelledByProp, label.id]);\n // Within a popup, a citation should function as a close button\n const citationProps = React.useMemo(() => {\n const onPopoverCloseClick = e => {\n setPopoverOpen(e, false);\n // don't navigate\n e.preventDefault();\n };\n return layout === 'popover' ? {\n referenceHref: '#',\n tabIndex: -1,\n 'aria-label': `Reference ${index}, close`,\n onClick: onPopoverCloseClick\n } : {\n referenceHref: citationHref\n };\n }, [layout, citationHref, index, setPopoverOpen]);\n const state = {\n isExpanded,\n mode: layout === 'popover' ? 'sidecar' : mode,\n layout,\n index,\n components: {\n root: 'div',\n citation: 'div',\n media: 'div',\n actions: 'div',\n label: 'div',\n sensitivity: 'span',\n sensitivityLabel: 'span',\n metadata: 'div',\n content: 'div',\n primaryText: 'span',\n secondaryText: 'span',\n tertiaryText: 'span',\n icon: 'span',\n detailsButton: Button\n },\n root: slot.always(getNativeElementProps('div', {\n ref,\n id: referenceId,\n ...groupSemantics,\n ...props\n }), {\n elementType: 'div'\n }),\n citation: slot.optional(props.citation, {\n defaultProps: {\n children: /*#__PURE__*/React.createElement(Citation, {\n block: true,\n referenceId: referenceId,\n ...citationProps\n }, index)\n },\n renderByDefault: true,\n elementType: 'div'\n }),\n media,\n actions: slot.optional(layout === 'inline' ? props.actions : null, {\n renderByDefault: true,\n elementType: 'div'\n }),\n label,\n sensitivity: slot.optional(props.sensitivity, {\n elementType: 'span'\n }),\n sensitivityLabel: slot.optional(props.sensitivityLabel, {\n elementType: 'span'\n }),\n metadata: slot.always(props.metadata, {\n elementType: 'div'\n }),\n primaryText: slot.optional(props.primaryText, {\n defaultProps: {\n hidden: !isExpanded\n },\n elementType: 'span'\n }),\n secondaryText: slot.optional(props.secondaryText, {\n defaultProps: {\n hidden: !isExpanded\n },\n elementType: 'span'\n }),\n tertiaryText: slot.optional(props.tertiaryText, {\n defaultProps: {\n hidden: !isExpanded\n },\n elementType: 'span'\n }),\n icon: slot.optional(props.icon, {\n elementType: 'span'\n }),\n content: slot.always(props.content, {\n defaultProps: {\n children: excerpt && /*#__PURE__*/React.createElement(Caption1, null, excerpt)\n },\n elementType: 'div'\n }),\n detailsButton: slot.optional(layout === 'inline' ? props.detailsButton : null, {\n defaultProps: {\n appearance: 'transparent',\n 'aria-expanded': isExpanded,\n 'aria-label': 'show details',\n size: mode === 'sidecar' ? 'small' : 'medium',\n icon: {\n children: getIcon(isExpanded, mode)\n }\n },\n renderByDefault: true,\n elementType: Button\n })\n };\n if (state.detailsButton) {\n const onClick = state.detailsButton.onClick;\n state.detailsButton.onClick = mergeCallbacks(onClick, onExpandClick);\n }\n const referenceGroupSetOpen = useReferenceGroupSetOpen();\n const onTargettedByCitation = e => {\n var _e_relatedTarget;\n const relatedTargetHash = (_e_relatedTarget = e.relatedTarget) === null || _e_relatedTarget === void 0 ? void 0 : _e_relatedTarget.hash;\n if (relatedTargetHash && relatedTargetHash.substring(1) === referenceId) {\n referenceGroupSetOpen();\n setIsExpanded(true);\n }\n };\n state.root.onFocus = mergeCallbacks(state.root.onFocus, onTargettedByCitation);\n return state;\n};\nconst getIcon = (isExpanded, mode) => {\n if (mode === 'sidecar') {\n return !isExpanded ? /*#__PURE__*/React.createElement(ChevronDown16Regular, null) : /*#__PURE__*/React.createElement(ChevronUp16Regular, null);\n }\n return !isExpanded ? /*#__PURE__*/React.createElement(ChevronDown24Regular, null) : /*#__PURE__*/React.createElement(ChevronUp24Regular, null);\n};\n//# sourceMappingURL=useReference.js.map"],"names":["useReference_unstable","props","ref","index","referenceId","citationHref","excerpt","layout","mode","useCopilotMode","labelId","useId","mediaId","isExpanded","setIsExpanded","React","useState","setPopoverOpen","usePopoverContext","context","setOpen","onExpandClick","_e","label","slot","always","defaultProps","id","elementType","media","optional","isValidElement","children","cloneElement","className","mergeClasses","referenceExtraClassNames","mediaChild","_label_ariadescribedby","_label_ariadescribedby_concat","concat","ariaLabelledByProp","groupSemantics","useMemo","role","tabIndex","citationProps","onPopoverCloseClick","e","preventDefault","referenceHref","onClick","state","components","root","citation","actions","sensitivity","sensitivityLabel","metadata","content","primaryText","secondaryText","tertiaryText","icon","detailsButton","Button","getNativeElementProps","createElement","Citation","block","renderByDefault","hidden","Caption1","appearance","size","getIcon","mergeCallbacks","referenceGroupSetOpen","useReferenceGroupSetOpen","onTargettedByCitation","_e_relatedTarget","relatedTargetHash","relatedTarget","hash","substring","onFocus","ChevronDown16Regular","ChevronUp16Regular","ChevronDown24Regular","ChevronUp24Regular"],"mappings":";;;;+BAgBaA;;;eAAAA;;;;iEAhBU;iCAC6H;4BACjD;oCAC1D;0BAChB;uCACgB;+BACV;AAUxB,MAAMA,wBAAwB,CAACC,OAAOC;IAC3C,MAAM,EACJC,KAAK,EACLC,WAAW,EACXC,YAAY,EACZC,OAAO,EACPC,SAAS,QAAQ,EAClB,GAAGN;IACJ,MAAMO,OAAOC,IAAAA,6BAAc,EAACR,MAAMO,IAAI;IACtC,MAAME,UAAUC,IAAAA,sBAAK;IACrB,MAAMC,UAAUD,IAAAA,sBAAK;IACrB,MAAM,CAACE,YAAYC,cAAc,GAAGC,OAAMC,QAAQ,CAACT,WAAW,YAAY,OAAO;IACjF,MAAMU,iBAAiBC,IAAAA,2CAAiB,EAACC,CAAAA,UAAWA,QAAQC,OAAO;IACnE,MAAMC,gBAAgBC,CAAAA;QACpBR,cAAc,CAACD;IACjB;IACA,MAAMU,QAAQC,qBAAI,CAACC,MAAM,CAACxB,MAAMsB,KAAK,EAAE;QACrCG,cAAc;YACZC,IAAIjB;QACN;QACAkB,aAAa;IACf;IACA,MAAMC,QAAQL,qBAAI,CAACM,QAAQ,CAAC7B,MAAM4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AEmC,aAAa,AAAD,MAAO,QAAQF,qBAAqB,KAAK,IAAI,KAAK,IAAIA,iBAAiBG,IAAI;QACvI,IAAIF,qBAAqBA,kBAAkBG,SAAS,CAAC,OAAOjF,aAAa;YACvE0E;YACAhE,cAAc;QAChB;IACF;IACAsC,MAAME,IAAI,CAACgC,OAAO,GAAGT,IAAAA,+BAAc,EAACzB,MAAME,IAAI,CAACgC,OAAO,EAAEN;IACxD,OAAO5B;AACT;AACA,MAAMwB,UAAU,CAAC/D,YAAYL;IAC3B,IAAIA,SAAS,WAAW;QACtB,OAAO,CAACK,aAAa,WAAW,GAAEE,OAAMqD,aAAa,CAACmB,gCAAoB,EAAE,QAAQ,WAAW,GAAExE,OAAMqD,aAAa,CAACoB,8BAAkB,EAAE;IAC3I;IACA,OAAO,CAAC3E,aAAa,WAAW,GAAEE,OAAMqD,aAAa,CAACqB,gCAAoB,EAAE,QAAQ,WAAW,GAAE1E,OAAMqD,aAAa,CAACsB,8BAAkB,EAAE;AAC3I,GACA,wCAAwC"}
|
|
1
|
+
{"version":3,"sources":["useReference.js"],"sourcesContent":["import * as React from 'react';\nimport { Button, Caption1, getNativeElementProps, mergeCallbacks, mergeClasses, slot, useId, usePopoverContext_unstable as usePopoverContext } from '@fluentui/react-components';\nimport { ChevronDown24Regular, ChevronUp24Regular, ChevronDown16Regular, ChevronUp16Regular } from '@fluentui/react-icons';\nimport { referenceExtraClassNames } from './useReferenceStyles';\nimport { Citation } from '../Citation';\nimport { useReferenceGroupSetOpen } from '../../context/ReferenceGroupContext';\nimport { useCopilotMode } from '@fluentui-copilot/react-provider';\n/**\n * Create the state required to render Reference.\n *\n * The returned state can be modified with hooks such as useReferenceStyles_unstable,\n * before being passed to renderReference_unstable.\n *\n * @param props - props from this instance of Reference\n * @param ref - reference to root HTMLElement of Reference\n */\nexport const useReference_unstable = (props, ref) => {\n const {\n index,\n referenceId,\n citationHref,\n excerpt,\n layout = 'inline'\n } = props;\n const mode = useCopilotMode(props.mode);\n const labelId = useId();\n const mediaId = useId();\n const [isExpanded, setIsExpanded] = React.useState(layout === 'popover' ? true : false);\n const setPopoverOpen = usePopoverContext(context => context.setOpen);\n const onExpandClick = _e => {\n setIsExpanded(!isExpanded);\n };\n const label = slot.always(props.label, {\n defaultProps: {\n id: labelId\n },\n elementType: 'div'\n });\n const media = slot.optional(props.media, {\n defaultProps: {\n id: mediaId\n },\n elementType: 'div'\n });\n if (media && /*#__PURE__*/React.isValidElement(media.children)) {\n media.children = /*#__PURE__*/React.cloneElement(media.children, {\n className: mergeClasses(media.children.props.className, referenceExtraClassNames.mediaChild)\n });\n }\n if (media === null || media === void 0 ? void 0 : media.id) {\n var _label_ariadescribedby;\n var _label_ariadescribedby_concat;\n label['aria-describedby'] = (_label_ariadescribedby_concat = (_label_ariadescribedby = label['aria-describedby']) === null || _label_ariadescribedby === void 0 ? void 0 : _label_ariadescribedby.concat(media.id)) !== null && _label_ariadescribedby_concat !== void 0 ? _label_ariadescribedby_concat : media.id;\n }\n const ariaLabelledByProp = props['aria-labelledby'];\n const groupSemantics = React.useMemo(() => {\n return layout === 'inline' ? {\n role: 'group',\n 'aria-labelledby': `${ariaLabelledByProp !== null && ariaLabelledByProp !== void 0 ? ariaLabelledByProp : ''} ${label.id}`,\n tabIndex: -1\n } : {};\n }, [layout, ariaLabelledByProp, label.id]);\n // Within a popup, a citation should function as a close button\n const citationProps = React.useMemo(() => {\n const onPopoverCloseClick = e => {\n setPopoverOpen(e, false);\n // don't navigate\n e.preventDefault();\n };\n return layout === 'popover' ? {\n referenceHref: '#',\n tabIndex: -1,\n 'aria-label': `Reference ${index}, close`,\n onClick: onPopoverCloseClick\n } : {\n referenceHref: citationHref\n };\n }, [layout, citationHref, index, setPopoverOpen]);\n const state = {\n isExpanded,\n mode: layout === 'popover' ? 'sidecar' : mode,\n layout,\n index,\n components: {\n root: 'div',\n citation: 'div',\n media: 'div',\n actions: 'div',\n label: 'div',\n sensitivity: 'span',\n metadata: 'div',\n content: 'div',\n primaryText: 'span',\n secondaryText: 'span',\n tertiaryText: 'span',\n icon: 'span',\n detailsButton: Button\n },\n root: slot.always(getNativeElementProps('div', {\n ref,\n id: referenceId,\n ...groupSemantics,\n ...props\n }), {\n elementType: 'div'\n }),\n citation: slot.optional(props.citation, {\n defaultProps: {\n children: /*#__PURE__*/React.createElement(Citation, {\n block: true,\n ...citationProps\n }, index)\n },\n renderByDefault: true,\n elementType: 'div'\n }),\n media,\n actions: slot.optional(layout === 'inline' ? props.actions : null, {\n renderByDefault: true,\n elementType: 'div'\n }),\n label,\n sensitivity: slot.optional(props.sensitivity, {\n elementType: 'span'\n }),\n metadata: slot.always(props.metadata, {\n elementType: 'div'\n }),\n primaryText: slot.optional(props.primaryText, {\n defaultProps: {\n hidden: !isExpanded\n },\n elementType: 'span'\n }),\n secondaryText: slot.optional(props.secondaryText, {\n defaultProps: {\n hidden: !isExpanded\n },\n elementType: 'span'\n }),\n tertiaryText: slot.optional(props.tertiaryText, {\n defaultProps: {\n hidden: !isExpanded\n },\n elementType: 'span'\n }),\n icon: slot.optional(props.icon, {\n elementType: 'span'\n }),\n content: slot.always(props.content, {\n defaultProps: {\n children: excerpt && /*#__PURE__*/React.createElement(Caption1, null, excerpt)\n },\n elementType: 'div'\n }),\n detailsButton: slot.optional(layout === 'inline' ? props.detailsButton : null, {\n defaultProps: {\n appearance: 'transparent',\n 'aria-expanded': isExpanded,\n 'aria-label': 'show details',\n size: mode === 'sidecar' ? 'small' : 'medium',\n icon: {\n children: getIcon(isExpanded, mode)\n }\n },\n renderByDefault: true,\n elementType: Button\n })\n };\n if (state.detailsButton) {\n const onClick = state.detailsButton.onClick;\n state.detailsButton.onClick = mergeCallbacks(onClick, onExpandClick);\n }\n const referenceGroupSetOpen = useReferenceGroupSetOpen();\n const onTargettedByCitation = e => {\n var _e_relatedTarget;\n const relatedTargetHash = (_e_relatedTarget = e.relatedTarget) === null || _e_relatedTarget === void 0 ? void 0 : _e_relatedTarget.hash;\n if (relatedTargetHash && relatedTargetHash.substring(1) === referenceId) {\n referenceGroupSetOpen();\n setIsExpanded(true);\n }\n };\n state.root.onFocus = mergeCallbacks(state.root.onFocus, onTargettedByCitation);\n return state;\n};\nconst getIcon = (isExpanded, mode) => {\n if (mode === 'sidecar') {\n return !isExpanded ? /*#__PURE__*/React.createElement(ChevronDown16Regular, null) : /*#__PURE__*/React.createElement(ChevronUp16Regular, null);\n }\n return !isExpanded ? /*#__PURE__*/React.createElement(ChevronDown24Regular, null) : /*#__PURE__*/React.createElement(ChevronUp24Regular, null);\n};\n//# sourceMappingURL=useReference.js.map"],"names":["useReference_unstable","props","ref","index","referenceId","citationHref","excerpt","layout","mode","useCopilotMode","labelId","useId","mediaId","isExpanded","setIsExpanded","React","useState","setPopoverOpen","usePopoverContext","context","setOpen","onExpandClick","_e","label","slot","always","defaultProps","id","elementType","media","optional","isValidElement","children","cloneElement","className","mergeClasses","referenceExtraClassNames","mediaChild","_label_ariadescribedby","_label_ariadescribedby_concat","concat","ariaLabelledByProp","groupSemantics","useMemo","role","tabIndex","citationProps","onPopoverCloseClick","e","preventDefault","referenceHref","onClick","state","components","root","citation","actions","sensitivity","metadata","content","primaryText","secondaryText","tertiaryText","icon","detailsButton","Button","getNativeElementProps","createElement","Citation","block","renderByDefault","hidden","Caption1","appearance","size","getIcon","mergeCallbacks","referenceGroupSetOpen","useReferenceGroupSetOpen","onTargettedByCitation","_e_relatedTarget","relatedTargetHash","relatedTarget","hash","substring","onFocus","ChevronDown16Regular","ChevronUp16Regular","ChevronDown24Regular","ChevronUp24Regular"],"mappings":";;;;+BAgBaA;;;eAAAA;;;;iEAhBU;iCAC6H;4BACjD;oCAC1D;0BAChB;uCACgB;+BACV;AAUxB,MAAMA,wBAAwB,CAACC,OAAOC;IAC3C,MAAM,EACJC,KAAK,EACLC,WAAW,EACXC,YAAY,EACZC,OAAO,EACPC,SAAS,QAAQ,EAClB,GAAGN;IACJ,MAAMO,OAAOC,IAAAA,6BAAc,EAACR,MAAMO,IAAI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