@fluentui-copilot/react-reference 0.0.0-nightly-20240625-0406-eccb618e.1 → 0.0.0-nightly-20240627-0406-0fec4afd.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 +11 -11
- package/CHANGELOG.md +8 -8
- package/dist/index.d.ts +46 -16
- package/lib/components/reference-v2/Reference/useReference.js +1 -1
- package/lib/components/reference-v2/Reference/useReference.js.map +1 -1
- package/lib/hooks/reference-v2/generateReferenceCitationPreview.js +107 -0
- package/lib/hooks/reference-v2/generateReferenceCitationPreview.js.map +1 -0
- package/lib/hooks/reference-v2/index.js +1 -0
- package/lib/hooks/reference-v2/index.js.map +1 -1
- package/lib/hooks/reference-v2/useReferenceCitationPreview.js +14 -121
- package/lib/hooks/reference-v2/useReferenceCitationPreview.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/components/reference-v2/Reference/useReference.js +1 -1
- package/lib-commonjs/components/reference-v2/Reference/useReference.js.map +1 -1
- package/lib-commonjs/hooks/reference-v2/generateReferenceCitationPreview.js +96 -0
- package/lib-commonjs/hooks/reference-v2/generateReferenceCitationPreview.js.map +1 -0
- package/lib-commonjs/hooks/reference-v2/index.js +1 -0
- package/lib-commonjs/hooks/reference-v2/index.js.map +1 -1
- package/lib-commonjs/hooks/reference-v2/useReferenceCitationPreview.js +3 -138
- package/lib-commonjs/hooks/reference-v2/useReferenceCitationPreview.js.map +1 -1
- package/lib-commonjs/index.js +3 -0
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"name": "@fluentui-copilot/react-reference",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
6
|
-
"tag": "@fluentui-copilot/react-reference_v0.0.0-nightly-
|
|
7
|
-
"version": "0.0.0-nightly-
|
|
5
|
+
"date": "Thu, 27 Jun 2024 04:13:14 GMT",
|
|
6
|
+
"tag": "@fluentui-copilot/react-reference_v0.0.0-nightly-20240627-0406-0fec4afd.1",
|
|
7
|
+
"version": "0.0.0-nightly-20240627-0406-0fec4afd.1",
|
|
8
8
|
"comments": {
|
|
9
9
|
"prerelease": [
|
|
10
10
|
{
|
|
@@ -16,26 +16,26 @@
|
|
|
16
16
|
{
|
|
17
17
|
"author": "beachball",
|
|
18
18
|
"package": "@fluentui-copilot/react-reference",
|
|
19
|
-
"comment": "Bump @fluentui-copilot/react-preview to v0.0.0-nightly-
|
|
20
|
-
"commit": "
|
|
19
|
+
"comment": "Bump @fluentui-copilot/react-preview to v0.0.0-nightly-20240627-0406-0fec4afd.1",
|
|
20
|
+
"commit": "04890dce56a60ec66f762517e7352caddcc76582"
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
"author": "beachball",
|
|
24
24
|
"package": "@fluentui-copilot/react-reference",
|
|
25
|
-
"comment": "Bump @fluentui-copilot/react-provider to v0.0.0-nightly-
|
|
26
|
-
"commit": "
|
|
25
|
+
"comment": "Bump @fluentui-copilot/react-provider to v0.0.0-nightly-20240627-0406-0fec4afd.1",
|
|
26
|
+
"commit": "04890dce56a60ec66f762517e7352caddcc76582"
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
"author": "beachball",
|
|
30
30
|
"package": "@fluentui-copilot/react-reference",
|
|
31
|
-
"comment": "Bump @fluentui-copilot/react-sensitivity-label to v0.0.0-nightly-
|
|
32
|
-
"commit": "
|
|
31
|
+
"comment": "Bump @fluentui-copilot/react-sensitivity-label to v0.0.0-nightly-20240627-0406-0fec4afd.1",
|
|
32
|
+
"commit": "04890dce56a60ec66f762517e7352caddcc76582"
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
"author": "beachball",
|
|
36
36
|
"package": "@fluentui-copilot/react-reference",
|
|
37
|
-
"comment": "Bump @fluentui-copilot/react-utilities to v0.0.0-nightly-
|
|
38
|
-
"commit": "
|
|
37
|
+
"comment": "Bump @fluentui-copilot/react-utilities to v0.0.0-nightly-20240627-0406-0fec4afd.1",
|
|
38
|
+
"commit": "04890dce56a60ec66f762517e7352caddcc76582"
|
|
39
39
|
}
|
|
40
40
|
]
|
|
41
41
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
# Change Log - @fluentui-copilot/react-reference
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 27 Jun 2024 04:13:14 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
-
## [0.0.0-nightly-
|
|
7
|
+
## [0.0.0-nightly-20240627-0406-0fec4afd.1](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-reference_v0.0.0-nightly-20240627-0406-0fec4afd.1)
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/react-reference_v0.12.0..@fluentui-copilot/react-reference_v0.0.0-nightly-
|
|
9
|
+
Thu, 27 Jun 2024 04:13:14 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/react-reference_v0.12.0..@fluentui-copilot/react-reference_v0.0.0-nightly-20240627-0406-0fec4afd.1)
|
|
11
11
|
|
|
12
12
|
### Changes
|
|
13
13
|
|
|
14
14
|
- Release nightly ([commit](https://github.com/microsoft/fluentai/commit/not available) by fluentui-internal@service.microsoft.com)
|
|
15
|
-
- Bump @fluentui-copilot/react-preview to v0.0.0-nightly-
|
|
16
|
-
- Bump @fluentui-copilot/react-provider to v0.0.0-nightly-
|
|
17
|
-
- Bump @fluentui-copilot/react-sensitivity-label to v0.0.0-nightly-
|
|
18
|
-
- Bump @fluentui-copilot/react-utilities to v0.0.0-nightly-
|
|
15
|
+
- Bump @fluentui-copilot/react-preview to v0.0.0-nightly-20240627-0406-0fec4afd.1 ([commit](https://github.com/microsoft/fluentai/commit/04890dce56a60ec66f762517e7352caddcc76582) by beachball)
|
|
16
|
+
- Bump @fluentui-copilot/react-provider to v0.0.0-nightly-20240627-0406-0fec4afd.1 ([commit](https://github.com/microsoft/fluentai/commit/04890dce56a60ec66f762517e7352caddcc76582) by beachball)
|
|
17
|
+
- Bump @fluentui-copilot/react-sensitivity-label to v0.0.0-nightly-20240627-0406-0fec4afd.1 ([commit](https://github.com/microsoft/fluentai/commit/04890dce56a60ec66f762517e7352caddcc76582) by beachball)
|
|
18
|
+
- Bump @fluentui-copilot/react-utilities to v0.0.0-nightly-20240627-0406-0fec4afd.1 ([commit](https://github.com/microsoft/fluentai/commit/04890dce56a60ec66f762517e7352caddcc76582) by beachball)
|
|
19
19
|
|
|
20
20
|
## [0.12.0](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-reference_v0.12.0)
|
|
21
21
|
|
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,20 @@ declare type CopilotMode = {
|
|
|
54
54
|
mode?: 'canvas' | 'sidecar';
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Function to generate a Citation - Reference pair with correctly wired props.
|
|
59
|
+
* Both the Citation and the Reference act as trigger components to Previews that are also correctly wired by the function.
|
|
60
|
+
* Props can either be passed in to the function or applied directly to the generated components in JSX.
|
|
61
|
+
*
|
|
62
|
+
* A `useReferenceCitationPreview` hook exists that calls this function and memoizes its return value based on the props.
|
|
63
|
+
* You should use the hook when the props used to generate the Citation - Reference pair can change dynamically.
|
|
64
|
+
* If they are static, or in case you wanted to generate multiple pairs within a cycle, you should call
|
|
65
|
+
* `generateReferenceCitationPreview` directly.
|
|
66
|
+
*
|
|
67
|
+
* @returns A Citation - Reference pair with correctly wired props.
|
|
68
|
+
*/
|
|
69
|
+
export declare const generateReferenceCitationPreview: ReferenceCitationPreviewGenerator;
|
|
70
|
+
|
|
57
71
|
/**
|
|
58
72
|
* A "packaged Citation". A packaged Citation is a `Citation` that is
|
|
59
73
|
* pre-packaged with props set by the `useReferenceCitation` hook.
|
|
@@ -171,6 +185,24 @@ export declare type ReferenceCitationData = {
|
|
|
171
185
|
sensitivityLabelProps?: SensitivityLabelProps;
|
|
172
186
|
};
|
|
173
187
|
|
|
188
|
+
export declare type ReferenceCitationPreviewGenerator = (props: ReferenceCitationPreviewGeneratorProps) => {
|
|
189
|
+
Citation: PackagedCitationV2;
|
|
190
|
+
Reference: PackagedReferenceV2;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export declare type ReferenceCitationPreviewGeneratorProps = {
|
|
194
|
+
citationPreviewProps?: PreviewProps;
|
|
195
|
+
citationPreviewSurfaceProps?: PreviewSurfaceProps;
|
|
196
|
+
citationProps?: CitationProps;
|
|
197
|
+
index: number;
|
|
198
|
+
previewContentProps?: PackagedPreviewContentV2Props;
|
|
199
|
+
previewHeaderProps?: PreviewHeaderProps;
|
|
200
|
+
referencePreviewProps?: PreviewProps;
|
|
201
|
+
referencePreviewSurfaceProps?: PreviewSurfaceProps;
|
|
202
|
+
referenceProps?: ReferenceV2Props;
|
|
203
|
+
sensitivityLabelProps?: SensitivityLabelProps;
|
|
204
|
+
};
|
|
205
|
+
|
|
174
206
|
/** deprecated Use ReferenceV2 component, hooks and types instead. */
|
|
175
207
|
export declare const referenceClassNames: SlotClassNames<ReferenceSlots>;
|
|
176
208
|
|
|
@@ -506,25 +538,23 @@ export declare type UseReferenceCitationPreview = (data: ReferenceCitationData)
|
|
|
506
538
|
*/
|
|
507
539
|
export declare const useReferenceCitationPreview: UseReferenceCitationPreview;
|
|
508
540
|
|
|
509
|
-
export declare type UseReferenceCitationPreviewV2 =
|
|
510
|
-
Citation: PackagedCitationV2;
|
|
511
|
-
Reference: PackagedReferenceV2;
|
|
512
|
-
};
|
|
541
|
+
export declare type UseReferenceCitationPreviewV2 = ReferenceCitationPreviewGenerator;
|
|
513
542
|
|
|
543
|
+
/**
|
|
544
|
+
* Hook to generate a Citation - Reference pair with correctly wired props.
|
|
545
|
+
* Both the Citation and the Reference act as trigger components to Previews that are also correctly wired by the hook.
|
|
546
|
+
* Props can either be passed in to the hook or applied directly to the generated components in JSX.
|
|
547
|
+
*
|
|
548
|
+
* This hook internally calls the `generateReferenceCitationPreview` function and memoizes its return value based on the props.
|
|
549
|
+
* You should only use this hook when the props used to generate the Citation - Reference pair can change dynamically.
|
|
550
|
+
* If they are static, or in case you wanted to generate multiple pairs within a cycle, you should call
|
|
551
|
+
* `generateReferenceCitationPreview` directly.
|
|
552
|
+
*
|
|
553
|
+
* @returns A Citation - Reference pair with correctly wired props.
|
|
554
|
+
*/
|
|
514
555
|
export declare const useReferenceCitationPreviewV2: UseReferenceCitationPreviewV2;
|
|
515
556
|
|
|
516
|
-
export declare type UseReferenceCitationPreviewV2Props =
|
|
517
|
-
citationPreviewProps?: PreviewProps;
|
|
518
|
-
citationPreviewSurfaceProps?: PreviewSurfaceProps;
|
|
519
|
-
citationProps?: CitationProps;
|
|
520
|
-
index: number;
|
|
521
|
-
previewContentProps?: PackagedPreviewContentV2Props;
|
|
522
|
-
previewHeaderProps?: PreviewHeaderProps;
|
|
523
|
-
referencePreviewProps?: PreviewProps;
|
|
524
|
-
referencePreviewSurfaceProps?: PreviewSurfaceProps;
|
|
525
|
-
referenceProps?: ReferenceV2Props;
|
|
526
|
-
sensitivityLabelProps?: SensitivityLabelProps;
|
|
527
|
-
};
|
|
557
|
+
export declare type UseReferenceCitationPreviewV2Props = ReferenceCitationPreviewGeneratorProps;
|
|
528
558
|
|
|
529
559
|
export declare type UseReferenceGroup = (props: UseReferenceGroupProps) => {
|
|
530
560
|
referenceGroupToggleProps: ReferenceGroupToggleProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useReference.ts"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, mergeClasses, slot, useId } from '@fluentui/react-components';\nimport { useReferenceListContext_unstable } from '../../../contexts/reference-v2/referenceListContext';\nimport { referenceExtraClassNames } from './useReferenceStyles.styles';\nimport type { ReferenceProps, ReferenceState } from './Reference.types';\n\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 = (\n props: ReferenceProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>,\n): ReferenceState => {\n const { as, children, id } = props;\n\n const shouldUseOverflow = useReferenceListContext_unstable(ctx => ctx.shouldUseOverflow);\n\n const referenceId = useId('reference-', id);\n\n const elementType = as || ((props as JSX.IntrinsicElements['a']).href ? 'a' : 'button');\n const propsWithAssignedAs = {\n type: elementType === 'button' ? 'button' : undefined,\n ...props,\n as: elementType,\n id: referenceId,\n } as ReferenceProps;\n\n const citation = slot.optional(props.citation, { elementType: 'span' });\n const graphic = slot.optional(props.graphic, { elementType: 'span' });\n const content = slot.optional(props.content, {\n elementType: 'span',\n renderByDefault: graphic !== undefined || !!children,\n });\n const divider = slot.optional(props.divider, {\n elementType: 'span',\n renderByDefault: citation !== undefined && content !== undefined,\n });\n\n const state: ReferenceState = {\n id: referenceId,\n shouldUseOverflow,\n\n components: {\n root:
|
|
1
|
+
{"version":3,"sources":["useReference.ts"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, mergeClasses, slot, useId } from '@fluentui/react-components';\nimport { useReferenceListContext_unstable } from '../../../contexts/reference-v2/referenceListContext';\nimport { referenceExtraClassNames } from './useReferenceStyles.styles';\nimport type { ReferenceProps, ReferenceState } from './Reference.types';\n\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 = (\n props: ReferenceProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>,\n): ReferenceState => {\n const { as, children, id } = props;\n\n const shouldUseOverflow = useReferenceListContext_unstable(ctx => ctx.shouldUseOverflow);\n\n const referenceId = useId('reference-', id);\n\n const elementType = as || ((props as JSX.IntrinsicElements['a']).href ? 'a' : 'button');\n const propsWithAssignedAs = {\n type: elementType === 'button' ? 'button' : undefined,\n ...props,\n as: elementType,\n id: referenceId,\n } as ReferenceProps;\n\n const citation = slot.optional(props.citation, { elementType: 'span' });\n const graphic = slot.optional(props.graphic, { elementType: 'span' });\n const content = slot.optional(props.content, {\n elementType: 'span',\n renderByDefault: graphic !== undefined || !!children,\n });\n const divider = slot.optional(props.divider, {\n elementType: 'span',\n renderByDefault: citation !== undefined && content !== undefined,\n });\n\n const state: ReferenceState = {\n id: referenceId,\n shouldUseOverflow,\n\n components: {\n root: elementType,\n citation: 'span',\n divider: 'span',\n graphic: 'span',\n content: 'span',\n },\n\n root: slot.always(\n getIntrinsicElementProps(elementType, {\n ref,\n ...propsWithAssignedAs,\n }),\n { elementType },\n ),\n citation,\n divider,\n content,\n graphic,\n };\n\n if (state.graphic && React.isValidElement<HTMLElement>(state.graphic.children)) {\n state.graphic.children = React.cloneElement(state.graphic.children, {\n className: mergeClasses(state.graphic.children.props.className, referenceExtraClassNames.graphicChild),\n });\n }\n\n return state;\n};\n"],"names":["React","getIntrinsicElementProps","mergeClasses","slot","useId","useReferenceListContext_unstable","referenceExtraClassNames","useReference_unstable","props","ref","as","children","id","shouldUseOverflow","ctx","referenceId","elementType","href","propsWithAssignedAs","type","undefined","citation","optional","graphic","content","renderByDefault","divider","state","components","root","always","isValidElement","cloneElement","className","graphicChild"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,wBAAwB,EAAEC,YAAY,EAAEC,IAAI,EAAEC,KAAK,QAAQ,6BAA6B;AACjG,SAASC,gCAAgC,QAAQ,sDAAsD;AACvG,SAASC,wBAAwB,QAA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X,MAAMgC,YAAY,CAACL,MAAMJ,OAAO,CAACZ,QAAQ,EAAE;YAClEsB,WAAW/B,aAAayB,MAAMJ,OAAO,CAACZ,QAAQ,CAACH,KAAK,CAACyB,SAAS,EAAE3B,yBAAyB4B,YAAY;QACvG;IACF;IAEA,OAAOP;AACT,EAAE"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { mergeCallbacks, usePopoverContext_unstable } from '@fluentui/react-components';
|
|
3
|
+
import { Preview, PreviewContent, PreviewHeader, PreviewMetadata, PreviewSurface, PreviewTrigger } from '@fluentui-copilot/react-preview';
|
|
4
|
+
import { SensitivityLabel } from '@fluentui-copilot/react-sensitivity-label';
|
|
5
|
+
import { Citation } from '../../Citation';
|
|
6
|
+
import { Reference } from '../../ReferenceV2';
|
|
7
|
+
// 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.
|
|
8
|
+
const CitationCloseButton = citationCloseButtonProps => {
|
|
9
|
+
const setPopoverOpen = usePopoverContext_unstable(context => context.setOpen);
|
|
10
|
+
const onPopoverCloseClick = React.useCallback(ev => {
|
|
11
|
+
setPopoverOpen(ev, false);
|
|
12
|
+
// Don't navigate
|
|
13
|
+
ev.preventDefault();
|
|
14
|
+
}, [setPopoverOpen]);
|
|
15
|
+
const onCitationCloseButtonClick = mergeCallbacks(onPopoverCloseClick, citationCloseButtonProps.onClick);
|
|
16
|
+
return /*#__PURE__*/React.createElement(Citation, {
|
|
17
|
+
...citationCloseButtonProps,
|
|
18
|
+
onClick: onCitationCloseButtonClick
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Function to generate a Citation - Reference pair with correctly wired props.
|
|
23
|
+
* Both the Citation and the Reference act as trigger components to Previews that are also correctly wired by the function.
|
|
24
|
+
* Props can either be passed in to the function or applied directly to the generated components in JSX.
|
|
25
|
+
*
|
|
26
|
+
* A `useReferenceCitationPreview` hook exists that calls this function and memoizes its return value based on the props.
|
|
27
|
+
* You should use the hook when the props used to generate the Citation - Reference pair can change dynamically.
|
|
28
|
+
* If they are static, or in case you wanted to generate multiple pairs within a cycle, you should call
|
|
29
|
+
* `generateReferenceCitationPreview` directly.
|
|
30
|
+
*
|
|
31
|
+
* @returns A Citation - Reference pair with correctly wired props.
|
|
32
|
+
*/
|
|
33
|
+
export const generateReferenceCitationPreview = props => {
|
|
34
|
+
const {
|
|
35
|
+
citationPreviewProps,
|
|
36
|
+
citationPreviewSurfaceProps,
|
|
37
|
+
citationProps,
|
|
38
|
+
index,
|
|
39
|
+
previewContentProps,
|
|
40
|
+
previewHeaderProps,
|
|
41
|
+
referencePreviewProps,
|
|
42
|
+
referencePreviewSurfaceProps,
|
|
43
|
+
referenceProps,
|
|
44
|
+
sensitivityLabelProps
|
|
45
|
+
} = props;
|
|
46
|
+
const CitationWithPreview = props => {
|
|
47
|
+
var _previewContentProps_content;
|
|
48
|
+
return /*#__PURE__*/React.createElement(Preview, {
|
|
49
|
+
closeOnScroll: true,
|
|
50
|
+
positioning: "below",
|
|
51
|
+
size: "small",
|
|
52
|
+
trapFocus: true,
|
|
53
|
+
withArrow: true,
|
|
54
|
+
...citationPreviewProps
|
|
55
|
+
}, /*#__PURE__*/React.createElement(PreviewTrigger, null, /*#__PURE__*/React.createElement(Citation, {
|
|
56
|
+
...citationProps,
|
|
57
|
+
...props
|
|
58
|
+
}, index)), /*#__PURE__*/React.createElement(PreviewSurface, citationPreviewSurfaceProps, /*#__PURE__*/React.createElement(PreviewContent, null, /*#__PURE__*/React.createElement(PreviewHeader, {
|
|
59
|
+
citation: /*#__PURE__*/React.createElement(CitationCloseButton, {
|
|
60
|
+
"aria-label": `Reference ${index}, close`,
|
|
61
|
+
referenceHref: "#",
|
|
62
|
+
tabIndex: -1
|
|
63
|
+
}, index),
|
|
64
|
+
media: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.graphic
|
|
65
|
+
}, referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.children), /*#__PURE__*/React.createElement(PreviewMetadata, {
|
|
66
|
+
icon: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.icon,
|
|
67
|
+
primaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.primaryText,
|
|
68
|
+
secondaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.secondaryText,
|
|
69
|
+
tertiaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.tertiaryText
|
|
70
|
+
}), sensitivityLabelProps && /*#__PURE__*/React.createElement(SensitivityLabel, sensitivityLabelProps), (_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)));
|
|
71
|
+
};
|
|
72
|
+
const ReferenceWithPreview = props => {
|
|
73
|
+
const mergedReferenceProps = {
|
|
74
|
+
citation: index,
|
|
75
|
+
...referenceProps,
|
|
76
|
+
...props
|
|
77
|
+
};
|
|
78
|
+
var _previewHeaderProps_children, _previewContentProps_content;
|
|
79
|
+
return /*#__PURE__*/React.createElement(Preview, {
|
|
80
|
+
closeOnScroll: true,
|
|
81
|
+
positioning: "below",
|
|
82
|
+
size: "small",
|
|
83
|
+
trapFocus: true,
|
|
84
|
+
withArrow: true,
|
|
85
|
+
...referencePreviewProps
|
|
86
|
+
}, /*#__PURE__*/React.createElement(PreviewTrigger, null, /*#__PURE__*/React.createElement(Reference, mergedReferenceProps)), /*#__PURE__*/React.createElement(PreviewSurface, referencePreviewSurfaceProps, /*#__PURE__*/React.createElement(PreviewContent, null, /*#__PURE__*/React.createElement(PreviewHeader, {
|
|
87
|
+
citation: /*#__PURE__*/React.createElement(CitationCloseButton, {
|
|
88
|
+
"aria-label": `Reference ${index}, close`,
|
|
89
|
+
referenceHref: "#",
|
|
90
|
+
tabIndex: -1
|
|
91
|
+
}, index),
|
|
92
|
+
media: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.graphic,
|
|
93
|
+
...previewHeaderProps
|
|
94
|
+
}, (_previewHeaderProps_children = previewHeaderProps === null || previewHeaderProps === void 0 ? void 0 : previewHeaderProps.children) !== null && _previewHeaderProps_children !== void 0 ? _previewHeaderProps_children : referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.children), /*#__PURE__*/React.createElement(PreviewMetadata, {
|
|
95
|
+
icon: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.icon,
|
|
96
|
+
primaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.primaryText,
|
|
97
|
+
secondaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.secondaryText,
|
|
98
|
+
tertiaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.tertiaryText
|
|
99
|
+
}), sensitivityLabelProps && /*#__PURE__*/React.createElement(SensitivityLabel, sensitivityLabelProps), (_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)));
|
|
100
|
+
};
|
|
101
|
+
const components = {
|
|
102
|
+
Citation: CitationWithPreview,
|
|
103
|
+
Reference: ReferenceWithPreview
|
|
104
|
+
};
|
|
105
|
+
return components;
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=generateReferenceCitationPreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["generateReferenceCitationPreview.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { mergeCallbacks, usePopoverContext_unstable } 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 {\n PreviewHeaderProps,\n PreviewMetadataProps,\n PreviewProps,\n PreviewSurfaceProps,\n} from '@fluentui-copilot/react-preview';\nimport type { SensitivityLabelProps } from '@fluentui-copilot/react-sensitivity-label';\n\nimport { Citation } from '../../Citation';\nimport { Reference } from '../../ReferenceV2';\nimport type { CitationProps } from '../../Citation';\nimport type { ReferenceProps } from '../../ReferenceV2';\n\nexport type PackagedCitation = React.FC<CitationProps>;\n\nexport type PackagedReference = React.FC<ReferenceProps>;\n\nexport type PackagedPreviewContentProps = Pick<\n PreviewMetadataProps,\n 'icon' | 'primaryText' | 'secondaryText' | 'tertiaryText'\n> & {\n content?: React.ReactNode;\n};\n\nexport type ReferenceCitationPreviewGeneratorProps = {\n citationPreviewProps?: PreviewProps;\n citationPreviewSurfaceProps?: PreviewSurfaceProps;\n citationProps?: CitationProps;\n index: number;\n previewContentProps?: PackagedPreviewContentProps;\n previewHeaderProps?: PreviewHeaderProps;\n referencePreviewProps?: PreviewProps;\n referencePreviewSurfaceProps?: PreviewSurfaceProps;\n referenceProps?: ReferenceProps;\n sensitivityLabelProps?: SensitivityLabelProps;\n};\n\nexport type ReferenceCitationPreviewGenerator = (props: ReferenceCitationPreviewGeneratorProps) => {\n Citation: PackagedCitation;\n Reference: PackagedReference;\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 * Function to generate a Citation - Reference pair with correctly wired props.\n * Both the Citation and the Reference act as trigger components to Previews that are also correctly wired by the function.\n * Props can either be passed in to the function or applied directly to the generated components in JSX.\n *\n * A `useReferenceCitationPreview` hook exists that calls this function and memoizes its return value based on the props.\n * You should use the hook when the props used to generate the Citation - Reference pair can change dynamically.\n * If they are static, or in case you wanted to generate multiple pairs within a cycle, you should call\n * `generateReferenceCitationPreview` directly.\n *\n * @returns A Citation - Reference pair with correctly wired props.\n */\nexport const generateReferenceCitationPreview: ReferenceCitationPreviewGenerator = props => {\n const {\n citationPreviewProps,\n citationPreviewSurfaceProps,\n citationProps,\n index,\n previewContentProps,\n previewHeaderProps,\n referencePreviewProps,\n referencePreviewSurfaceProps,\n referenceProps,\n sensitivityLabelProps,\n } = props;\n\n const CitationWithPreview: PackagedCitation = props => {\n return (\n <Preview closeOnScroll positioning=\"below\" size=\"small\" trapFocus withArrow {...citationPreviewProps}>\n <PreviewTrigger>\n <Citation {...citationProps} {...props}>\n {index}\n </Citation>\n </PreviewTrigger>\n <PreviewSurface {...citationPreviewSurfaceProps}>\n <PreviewContent>\n <PreviewHeader\n citation={\n <CitationCloseButton aria-label={`Reference ${index}, close`} referenceHref=\"#\" tabIndex={-1}>\n {index}\n </CitationCloseButton>\n }\n media={referenceProps?.graphic as PreviewHeaderProps['media']}\n >\n {referenceProps?.children}\n </PreviewHeader>\n <PreviewMetadata\n icon={previewContentProps?.icon}\n primaryText={previewContentProps?.primaryText}\n secondaryText={previewContentProps?.secondaryText}\n tertiaryText={previewContentProps?.tertiaryText}\n />\n {sensitivityLabelProps && <SensitivityLabel {...sensitivityLabelProps} />}\n {previewContentProps?.content ?? citationPreviewProps?.children}\n </PreviewContent>\n </PreviewSurface>\n </Preview>\n );\n };\n\n const ReferenceWithPreview: PackagedReference = props => {\n const mergedReferenceProps = {\n citation: index,\n ...referenceProps,\n ...props,\n } as ReferenceProps;\n\n return (\n <Preview closeOnScroll positioning=\"below\" size=\"small\" trapFocus withArrow {...referencePreviewProps}>\n <PreviewTrigger>\n <Reference {...mergedReferenceProps} />\n </PreviewTrigger>\n <PreviewSurface {...referencePreviewSurfaceProps}>\n <PreviewContent>\n <PreviewHeader\n citation={\n <CitationCloseButton aria-label={`Reference ${index}, close`} referenceHref=\"#\" tabIndex={-1}>\n {index}\n </CitationCloseButton>\n }\n media={referenceProps?.graphic as PreviewHeaderProps['media']}\n {...previewHeaderProps}\n >\n {previewHeaderProps?.children ?? referenceProps?.children}\n </PreviewHeader>\n <PreviewMetadata\n icon={previewContentProps?.icon}\n primaryText={previewContentProps?.primaryText}\n secondaryText={previewContentProps?.secondaryText}\n tertiaryText={previewContentProps?.tertiaryText}\n />\n {sensitivityLabelProps && <SensitivityLabel {...sensitivityLabelProps} />}\n {previewContentProps?.content ?? referencePreviewProps?.children}\n </PreviewContent>\n </PreviewSurface>\n </Preview>\n );\n };\n\n const components = {\n Citation: CitationWithPreview,\n Reference: ReferenceWithPreview,\n };\n\n return components;\n};\n"],"names":["React","mergeCallbacks","usePopoverContext_unstable","Preview","PreviewContent","PreviewHeader","PreviewMetadata","PreviewSurface","PreviewTrigger","SensitivityLabel","Citation","Reference","CitationCloseButton","citationCloseButtonProps","setPopoverOpen","context","setOpen","onPopoverCloseClick","useCallback","ev","preventDefault","onCitationCloseButtonClick","onClick","generateReferenceCitationPreview","props","citationPreviewProps","citationPreviewSurfaceProps","citationProps","index","previewContentProps","previewHeaderProps","referencePreviewProps","referencePreviewSurfaceProps","referenceProps","sensitivityLabelProps","CitationWithPreview","closeOnScroll","positioning","size","trapFocus","withArrow","citation","aria-label","referenceHref","tabIndex","media","graphic","children","icon","primaryText","secondaryText","tertiaryText","content","ReferenceWithPreview","mergedReferenceProps","components"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,cAAc,EAAEC,0BAA0B,QAAQ,6BAA6B;AAExF,SACEC,OAAO,EACPC,cAAc,EACd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,aAAa,EAAErB,gCAAAA,0CAAAA,oBAAqBqB,aAAa;YACjDC,YAAY,EAAEtB,gCAAAA,0CAAAA,oBAAqBsB,YAAY;YAEhDjB,uCAAyB,oBAACzB,kBAAqByB,wBAC/CL,CAAAA,+BAAAA,gCAAAA,0CAAAA,oBAAqBuB,OAAO,cAA5BvB,0CAAAA,+BAAgCE,kCAAAA,4CAAAA,sBAAuBgB,QAAQ;IAK1E;IAEA,MAAMQ,aAAa;QACjB7C,UAAUyB;QACVxB,WAAW0C;IACb;IAEA,OAAOE;AACT,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './useReferenceCitationPreview';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,gCAAgC"}
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './generateReferenceCitationPreview';\nexport * from './useReferenceCitationPreview';\n"],"names":[],"rangeMappings":";","mappings":"AAAA,cAAc,qCAAqC;AACnD,cAAc,gCAAgC"}
|
|
@@ -1,125 +1,18 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
|
|
2
1
|
import * as React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const onCitationCloseButtonClick = mergeCallbacks(onPopoverCloseClick, citationCloseButtonProps.onClick);
|
|
17
|
-
return /*#__PURE__*/_jsx(Citation, {
|
|
18
|
-
...citationCloseButtonProps,
|
|
19
|
-
onClick: onCitationCloseButtonClick
|
|
20
|
-
});
|
|
21
|
-
};
|
|
2
|
+
import { generateReferenceCitationPreview } from './generateReferenceCitationPreview';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to generate a Citation - Reference pair with correctly wired props.
|
|
5
|
+
* Both the Citation and the Reference act as trigger components to Previews that are also correctly wired by the hook.
|
|
6
|
+
* Props can either be passed in to the hook or applied directly to the generated components in JSX.
|
|
7
|
+
*
|
|
8
|
+
* This hook internally calls the `generateReferenceCitationPreview` function and memoizes its return value based on the props.
|
|
9
|
+
* You should only use this hook when the props used to generate the Citation - Reference pair can change dynamically.
|
|
10
|
+
* If they are static, or in case you wanted to generate multiple pairs within a cycle, you should call
|
|
11
|
+
* `generateReferenceCitationPreview` directly.
|
|
12
|
+
*
|
|
13
|
+
* @returns A Citation - Reference pair with correctly wired props.
|
|
14
|
+
*/
|
|
22
15
|
export const useReferenceCitationPreview = props => {
|
|
23
|
-
|
|
24
|
-
citationPreviewProps,
|
|
25
|
-
citationPreviewSurfaceProps,
|
|
26
|
-
citationProps,
|
|
27
|
-
index,
|
|
28
|
-
previewContentProps,
|
|
29
|
-
previewHeaderProps,
|
|
30
|
-
referencePreviewProps,
|
|
31
|
-
referencePreviewSurfaceProps,
|
|
32
|
-
referenceProps,
|
|
33
|
-
sensitivityLabelProps
|
|
34
|
-
} = props;
|
|
35
|
-
const components = React.useMemo(() => {
|
|
36
|
-
const CitationWithPreview = props => {
|
|
37
|
-
var _previewContentProps_content;
|
|
38
|
-
return /*#__PURE__*/_jsxs(Preview, {
|
|
39
|
-
closeOnScroll: true,
|
|
40
|
-
positioning: "below",
|
|
41
|
-
size: "small",
|
|
42
|
-
trapFocus: true,
|
|
43
|
-
withArrow: true,
|
|
44
|
-
...citationPreviewProps,
|
|
45
|
-
children: [/*#__PURE__*/_jsx(PreviewTrigger, {
|
|
46
|
-
children: /*#__PURE__*/_jsx(Citation, {
|
|
47
|
-
...citationProps,
|
|
48
|
-
...props,
|
|
49
|
-
children: index
|
|
50
|
-
})
|
|
51
|
-
}), /*#__PURE__*/_jsx(PreviewSurface, {
|
|
52
|
-
...citationPreviewSurfaceProps,
|
|
53
|
-
children: /*#__PURE__*/_jsxs(PreviewContent, {
|
|
54
|
-
children: [/*#__PURE__*/_jsx(PreviewHeader, {
|
|
55
|
-
citation: /*#__PURE__*/_jsx(CitationCloseButton, {
|
|
56
|
-
"aria-label": `Reference ${index}, close`,
|
|
57
|
-
referenceHref: "#",
|
|
58
|
-
tabIndex: -1,
|
|
59
|
-
children: index
|
|
60
|
-
}),
|
|
61
|
-
media: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.graphic,
|
|
62
|
-
children: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.children
|
|
63
|
-
}), /*#__PURE__*/_jsx(PreviewMetadata, {
|
|
64
|
-
icon: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.icon,
|
|
65
|
-
primaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.primaryText,
|
|
66
|
-
secondaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.secondaryText,
|
|
67
|
-
tertiaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.tertiaryText
|
|
68
|
-
}), sensitivityLabelProps && /*#__PURE__*/_jsx(SensitivityLabel, {
|
|
69
|
-
...sensitivityLabelProps
|
|
70
|
-
}), (_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]
|
|
71
|
-
})
|
|
72
|
-
})]
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
const ReferenceWithPreview = props => {
|
|
76
|
-
const mergedReferenceProps = {
|
|
77
|
-
citation: index,
|
|
78
|
-
...referenceProps,
|
|
79
|
-
...props
|
|
80
|
-
};
|
|
81
|
-
var _previewHeaderProps_children, _previewContentProps_content;
|
|
82
|
-
return /*#__PURE__*/_jsxs(Preview, {
|
|
83
|
-
closeOnScroll: true,
|
|
84
|
-
positioning: "below",
|
|
85
|
-
size: "small",
|
|
86
|
-
trapFocus: true,
|
|
87
|
-
withArrow: true,
|
|
88
|
-
...referencePreviewProps,
|
|
89
|
-
children: [/*#__PURE__*/_jsx(PreviewTrigger, {
|
|
90
|
-
children: /*#__PURE__*/_jsx(Reference, {
|
|
91
|
-
...mergedReferenceProps
|
|
92
|
-
})
|
|
93
|
-
}), /*#__PURE__*/_jsx(PreviewSurface, {
|
|
94
|
-
...referencePreviewSurfaceProps,
|
|
95
|
-
children: /*#__PURE__*/_jsxs(PreviewContent, {
|
|
96
|
-
children: [/*#__PURE__*/_jsx(PreviewHeader, {
|
|
97
|
-
citation: /*#__PURE__*/_jsx(CitationCloseButton, {
|
|
98
|
-
"aria-label": `Reference ${index}, close`,
|
|
99
|
-
referenceHref: "#",
|
|
100
|
-
tabIndex: -1,
|
|
101
|
-
children: index
|
|
102
|
-
}),
|
|
103
|
-
media: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.graphic,
|
|
104
|
-
...previewHeaderProps,
|
|
105
|
-
children: (_previewHeaderProps_children = previewHeaderProps === null || previewHeaderProps === void 0 ? void 0 : previewHeaderProps.children) !== null && _previewHeaderProps_children !== void 0 ? _previewHeaderProps_children : referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.children
|
|
106
|
-
}), /*#__PURE__*/_jsx(PreviewMetadata, {
|
|
107
|
-
icon: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.icon,
|
|
108
|
-
primaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.primaryText,
|
|
109
|
-
secondaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.secondaryText,
|
|
110
|
-
tertiaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.tertiaryText
|
|
111
|
-
}), sensitivityLabelProps && /*#__PURE__*/_jsx(SensitivityLabel, {
|
|
112
|
-
...sensitivityLabelProps
|
|
113
|
-
}), (_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]
|
|
114
|
-
})
|
|
115
|
-
})]
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
return {
|
|
119
|
-
Citation: CitationWithPreview,
|
|
120
|
-
Reference: ReferenceWithPreview
|
|
121
|
-
};
|
|
122
|
-
}, [citationPreviewProps, citationPreviewSurfaceProps, citationProps, index, previewHeaderProps, referencePreviewProps, referencePreviewSurfaceProps, referenceProps, previewContentProps, sensitivityLabelProps]);
|
|
123
|
-
return components;
|
|
16
|
+
return React.useMemo(() => generateReferenceCitationPreview(props), [props]);
|
|
124
17
|
};
|
|
125
18
|
//# 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';\n\nimport { mergeCallbacks, usePopoverContext_unstable } 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 {\n PreviewHeaderProps,\n PreviewMetadataProps,\n PreviewProps,\n PreviewSurfaceProps,\n} from '@fluentui-copilot/react-preview';\nimport type { SensitivityLabelProps } from '@fluentui-copilot/react-sensitivity-label';\n\nimport { Citation } from '../../Citation';\nimport { Reference } from '../../ReferenceV2';\nimport type { CitationProps } from '../../Citation';\nimport type { ReferenceProps } from '../../ReferenceV2';\n\nexport type PackagedCitation = React.FC<CitationProps>;\n\nexport type PackagedReference = React.FC<ReferenceProps>;\n\nexport type PackagedPreviewContentProps = Pick<\n PreviewMetadataProps,\n 'icon' | 'primaryText' | 'secondaryText' | 'tertiaryText'\n> & {\n content?: React.ReactNode;\n};\n\nexport type UseReferenceCitationPreviewProps = {\n citationPreviewProps?: PreviewProps;\n citationPreviewSurfaceProps?: PreviewSurfaceProps;\n citationProps?: CitationProps;\n index: number;\n previewContentProps?: PackagedPreviewContentProps;\n previewHeaderProps?: PreviewHeaderProps;\n referencePreviewProps?: PreviewProps;\n referencePreviewSurfaceProps?: PreviewSurfaceProps;\n referenceProps?: ReferenceProps;\n sensitivityLabelProps?: SensitivityLabelProps;\n};\n\nexport type UseReferenceCitationPreview = (props: UseReferenceCitationPreviewProps) => {\n Citation: PackagedCitation;\n Reference: PackagedReference;\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\nexport const useReferenceCitationPreview: UseReferenceCitationPreview = props => {\n const {\n citationPreviewProps,\n citationPreviewSurfaceProps,\n citationProps,\n index,\n previewContentProps,\n previewHeaderProps,\n referencePreviewProps,\n referencePreviewSurfaceProps,\n referenceProps,\n sensitivityLabelProps,\n } = props;\n\n const components = React.useMemo(() => {\n const CitationWithPreview: PackagedCitation = props => {\n return (\n <Preview closeOnScroll positioning=\"below\" size=\"small\" trapFocus withArrow {...citationPreviewProps}>\n <PreviewTrigger>\n <Citation {...citationProps} {...props}>\n {index}\n </Citation>\n </PreviewTrigger>\n <PreviewSurface {...citationPreviewSurfaceProps}>\n <PreviewContent>\n <PreviewHeader\n citation={\n <CitationCloseButton aria-label={`Reference ${index}, close`} referenceHref=\"#\" tabIndex={-1}>\n {index}\n </CitationCloseButton>\n }\n media={referenceProps?.graphic as PreviewHeaderProps['media']}\n >\n {referenceProps?.children}\n </PreviewHeader>\n <PreviewMetadata\n icon={previewContentProps?.icon}\n primaryText={previewContentProps?.primaryText}\n secondaryText={previewContentProps?.secondaryText}\n tertiaryText={previewContentProps?.tertiaryText}\n />\n {sensitivityLabelProps && <SensitivityLabel {...sensitivityLabelProps} />}\n {previewContentProps?.content ?? citationPreviewProps?.children}\n </PreviewContent>\n </PreviewSurface>\n </Preview>\n );\n };\n\n const ReferenceWithPreview: PackagedReference = props => {\n const mergedReferenceProps = {\n citation: index,\n ...referenceProps,\n ...props,\n } as ReferenceProps;\n\n return (\n <Preview closeOnScroll positioning=\"below\" size=\"small\" trapFocus withArrow {...referencePreviewProps}>\n <PreviewTrigger>\n <Reference {...mergedReferenceProps} />\n </PreviewTrigger>\n <PreviewSurface {...referencePreviewSurfaceProps}>\n <PreviewContent>\n <PreviewHeader\n citation={\n <CitationCloseButton aria-label={`Reference ${index}, close`} referenceHref=\"#\" tabIndex={-1}>\n {index}\n </CitationCloseButton>\n }\n media={referenceProps?.graphic as PreviewHeaderProps['media']}\n {...previewHeaderProps}\n >\n {previewHeaderProps?.children ?? referenceProps?.children}\n </PreviewHeader>\n <PreviewMetadata\n icon={previewContentProps?.icon}\n primaryText={previewContentProps?.primaryText}\n secondaryText={previewContentProps?.secondaryText}\n tertiaryText={previewContentProps?.tertiaryText}\n />\n {sensitivityLabelProps && <SensitivityLabel {...sensitivityLabelProps} />}\n {previewContentProps?.content ?? referencePreviewProps?.children}\n </PreviewContent>\n </PreviewSurface>\n </Preview>\n );\n };\n\n return {\n Citation: CitationWithPreview,\n Reference: ReferenceWithPreview,\n };\n }, [\n citationPreviewProps,\n citationPreviewSurfaceProps,\n citationProps,\n index,\n previewHeaderProps,\n referencePreviewProps,\n referencePreviewSurfaceProps,\n referenceProps,\n previewContentProps,\n sensitivityLabelProps,\n ]);\n\n return components;\n};\n"],"names":["React","mergeCallbacks","usePopoverContext_unstable","Preview","PreviewContent","PreviewHeader","PreviewMetadata","PreviewSurface","PreviewTrigger","SensitivityLabel","Citation","Reference","CitationCloseButton","citationCloseButtonProps","setPopoverOpen","context","setOpen","onPopoverCloseClick","useCallback","ev","preventDefault","onCitationCloseButtonClick","onClick","useReferenceCitationPreview","props","citationPreviewProps","citationPreviewSurfaceProps","citationProps","index","previewContentProps","previewHeaderProps","referencePreviewProps","referencePreviewSurfaceProps","referenceProps","sensitivityLabelProps","components","useMemo","CitationWithPreview","closeOnScroll","positioning","size","trapFocus","withArrow","citation","aria-label","referenceHref","tabIndex","media","graphic","children","icon","primaryText","secondaryText","tertiaryText","content","ReferenceWithPreview","mergedReferenceProps"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,YAAYA,WAAW,QAAQ;AAE/B,SAASC,cAAc,EAAEC,0BAA0B,QAAQ,6BAA6B;AAExF,SACEC,OAAO,EACPC,cAAc,EACdC,aAAa,EACbC,eAAe,EACfC,cAAc,EACdC,cAAc,QACT,kCAAkC;AACzC,SAASC,gBAAgB,QAAQ,4CAA4C;AAS7E,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,SAAS,QAAQ,oBAAoB;AAiC9C,6IAA6I;AAC7I,MAAMC,sBAAsB,CAACC;IAC3B,MAAMC,iBAAiBZ,2BAA2Ba,CAAAA,UAAWA,QAAQC,OAAO;IAE5E,MAAMC,sBAAsBjB,MAAMkB,WAAW,CAC3CC,CAAAA;QACEL,eAAeK,IAAI;QAEnB,iBAAiB;QACjBA,GAAGC,cAAc;IACnB,GACA;QAACN;KAAe;IAGlB,MAAMO,6BAA6BpB,eAAegB,qBAAqBJ,yBAAyBS,OAAO;IAEvG,qBAAO,KAACZ;QAAU,GA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B;QACAC;QACAC;QACAC;QACAE;QACAC;QACAC;QACAC;QACAJ;QACAK;KACD;IAED,OAAOC;AACT,EAAE"}
|
|
1
|
+
{"version":3,"sources":["useReferenceCitationPreview.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport * as React from 'react';\n\nimport {\n generateReferenceCitationPreview,\n type ReferenceCitationPreviewGenerator,\n type ReferenceCitationPreviewGeneratorProps,\n} from './generateReferenceCitationPreview';\n\nexport type UseReferenceCitationPreviewProps = ReferenceCitationPreviewGeneratorProps;\n\nexport type UseReferenceCitationPreview = ReferenceCitationPreviewGenerator;\n\n/**\n * Hook to generate a Citation - Reference pair with correctly wired props.\n * Both the Citation and the Reference act as trigger components to Previews that are also correctly wired by the hook.\n * Props can either be passed in to the hook or applied directly to the generated components in JSX.\n *\n * This hook internally calls the `generateReferenceCitationPreview` function and memoizes its return value based on the props.\n * You should only use this hook when the props used to generate the Citation - Reference pair can change dynamically.\n * If they are static, or in case you wanted to generate multiple pairs within a cycle, you should call\n * `generateReferenceCitationPreview` directly.\n *\n * @returns A Citation - Reference pair with correctly wired props.\n */\nexport const useReferenceCitationPreview: UseReferenceCitationPreview = props => {\n return React.useMemo(() => generateReferenceCitationPreview(props), [props]);\n};\n"],"names":["React","generateReferenceCitationPreview","useReferenceCitationPreview","props","useMemo"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD,GAEjD,YAAYA,WAAW,QAAQ;AAE/B,SACEC,gCAAgC,QAG3B,qCAAqC;AAM5C;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,8BAA2DC,CAAAA;IACtE,OAAOH,MAAMI,OAAO,CAAC,IAAMH,iCAAiCE,QAAQ;QAACA;KAAM;AAC7E,EAAE"}
|
package/lib/index.js
CHANGED
|
@@ -7,5 +7,5 @@ export { Reference as ReferenceV2, referenceClassNames as referenceV2ClassNames,
|
|
|
7
7
|
export { ReferenceList as ReferenceListV2, referenceListClassNames as referenceListV2ClassNames, renderReferenceList_unstable as renderReferenceListV2_unstable, useReferenceListStyles_unstable as useReferenceListV2Styles_unstable, useReferenceList_unstable as useReferenceListV2_unstable } from './ReferenceListV2';
|
|
8
8
|
export { ReferenceOverflowButton, referenceOverflowButtonClassNames, renderReferenceOverflowButton_unstable, useReferenceOverflowButtonStyles_unstable, useReferenceOverflowButton_unstable } from './ReferenceOverflowButton';
|
|
9
9
|
export { ReferenceListContext, ReferenceListContextProvider, useReferenceListContext_unstable } from './contexts/reference-v2';
|
|
10
|
-
export { useReferenceCitationPreview as useReferenceCitationPreviewV2 } from './hooks/reference-v2';
|
|
10
|
+
export { generateReferenceCitationPreview, useReferenceCitationPreview as useReferenceCitationPreviewV2 } from './hooks/reference-v2';
|
|
11
11
|
//# 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 { 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\n// reference-v2 exports\nexport type {\n ReferenceProps as ReferenceV2Props,\n ReferenceSlots as ReferenceV2Slots,\n ReferenceState as ReferenceV2State,\n} from './ReferenceV2';\nexport {\n Reference as ReferenceV2,\n referenceClassNames as referenceV2ClassNames,\n referenceExtraClassNames as referenceV2ExtraClassNames,\n renderReference_unstable as renderReferenceV2_unstable,\n useReferenceStyles_unstable as useReferenceV2Styles_unstable,\n useReference_unstable as useReferenceV2_unstable,\n} from './ReferenceV2';\n\nexport type {\n ReferenceListContextValues as ReferenceListV2ContextValues,\n ReferenceListProps as ReferenceListV2Props,\n ReferenceListSlots as ReferenceListV2Slots,\n ReferenceListState as ReferenceListV2State,\n} from './ReferenceListV2';\nexport {\n ReferenceList as ReferenceListV2,\n referenceListClassNames as referenceListV2ClassNames,\n renderReferenceList_unstable as renderReferenceListV2_unstable,\n useReferenceListStyles_unstable as useReferenceListV2Styles_unstable,\n useReferenceList_unstable as useReferenceListV2_unstable,\n} from './ReferenceListV2';\n\nexport type {\n ReferenceOverflowButtonProps,\n ReferenceOverflowButtonSlots,\n ReferenceOverflowButtonState,\n} from './ReferenceOverflowButton';\nexport {\n ReferenceOverflowButton,\n referenceOverflowButtonClassNames,\n renderReferenceOverflowButton_unstable,\n useReferenceOverflowButtonStyles_unstable,\n useReferenceOverflowButton_unstable,\n} from './ReferenceOverflowButton';\n\nexport type { ReferenceListContextValue } from './contexts/reference-v2';\nexport {\n ReferenceListContext,\n ReferenceListContextProvider,\n useReferenceListContext_unstable,\n} from './contexts/reference-v2';\n\nexport type {\n PackagedCitation as PackagedCitationV2,\n PackagedPreviewContentProps as PackagedPreviewContentV2Props,\n PackagedReference as PackagedReferenceV2,\n UseReferenceCitationPreview as UseReferenceCitationPreviewV2,\n UseReferenceCitationPreviewProps as UseReferenceCitationPreviewV2Props,\n} from './hooks/reference-v2';\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\n// reference-v2 exports\nexport type {\n ReferenceProps as ReferenceV2Props,\n ReferenceSlots as ReferenceV2Slots,\n ReferenceState as ReferenceV2State,\n} from './ReferenceV2';\nexport {\n Reference as ReferenceV2,\n referenceClassNames as referenceV2ClassNames,\n referenceExtraClassNames as referenceV2ExtraClassNames,\n renderReference_unstable as renderReferenceV2_unstable,\n useReferenceStyles_unstable as useReferenceV2Styles_unstable,\n useReference_unstable as useReferenceV2_unstable,\n} from './ReferenceV2';\n\nexport type {\n ReferenceListContextValues as ReferenceListV2ContextValues,\n ReferenceListProps as ReferenceListV2Props,\n ReferenceListSlots as ReferenceListV2Slots,\n ReferenceListState as ReferenceListV2State,\n} from './ReferenceListV2';\nexport {\n ReferenceList as ReferenceListV2,\n referenceListClassNames as referenceListV2ClassNames,\n renderReferenceList_unstable as renderReferenceListV2_unstable,\n useReferenceListStyles_unstable as useReferenceListV2Styles_unstable,\n useReferenceList_unstable as useReferenceListV2_unstable,\n} from './ReferenceListV2';\n\nexport type {\n ReferenceOverflowButtonProps,\n ReferenceOverflowButtonSlots,\n ReferenceOverflowButtonState,\n} from './ReferenceOverflowButton';\nexport {\n ReferenceOverflowButton,\n referenceOverflowButtonClassNames,\n renderReferenceOverflowButton_unstable,\n useReferenceOverflowButtonStyles_unstable,\n useReferenceOverflowButton_unstable,\n} from './ReferenceOverflowButton';\n\nexport type { ReferenceListContextValue } from './contexts/reference-v2';\nexport {\n ReferenceListContext,\n ReferenceListContextProvider,\n useReferenceListContext_unstable,\n} from './contexts/reference-v2';\n\nexport type {\n PackagedCitation as PackagedCitationV2,\n PackagedPreviewContentProps as PackagedPreviewContentV2Props,\n PackagedReference as PackagedReferenceV2,\n ReferenceCitationPreviewGenerator,\n ReferenceCitationPreviewGeneratorProps,\n UseReferenceCitationPreview as UseReferenceCitationPreviewV2,\n UseReferenceCitationPreviewProps as UseReferenceCitationPreviewV2Props,\n} from './hooks/reference-v2';\nexport {\n generateReferenceCitationPreview,\n useReferenceCitationPreview as useReferenceCitationPreviewV2,\n} from './hooks/reference-v2';\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","ReferenceV2","referenceV2ClassNames","referenceExtraClassNames","referenceV2ExtraClassNames","renderReferenceV2_unstable","useReferenceV2Styles_unstable","useReferenceV2_unstable","ReferenceListV2","referenceListV2ClassNames","renderReferenceListV2_unstable","useReferenceListV2Styles_unstable","useReferenceListV2_unstable","ReferenceOverflowButton","referenceOverflowButtonClassNames","renderReferenceOverflowButton_unstable","useReferenceOverflowButtonStyles_unstable","useReferenceOverflowButton_unstable","ReferenceListContext","ReferenceListContextProvider","useReferenceListContext_unstable","generateReferenceCitationPreview","useReferenceCitationPreviewV2"],"rangeMappings":";;;;;;;;;","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;AA8BhC,SACEhB,aAAaiB,WAAW,EACxBhB,uBAAuBiB,qBAAqB,EAC5CC,4BAA4BC,0BAA0B,EACtDlB,4BAA4BmB,0BAA0B,EACtDjB,+BAA+BkB,6BAA6B,EAC5DnB,yBAAyBoB,uBAAuB,QAC3C,gBAAgB;AAQvB,SACEhB,iBAAiBiB,eAAe,EAChChB,2BAA2BiB,yBAAyB,EACpDd,gCAAgCe,8BAA8B,EAC9DhB,mCAAmCiB,iCAAiC,EACpElB,6BAA6BmB,2BAA2B,QACnD,oBAAoB;AAO3B,SACEC,uBAAuB,EACvBC,iCAAiC,EACjCC,sCAAsC,EACtCC,yCAAyC,EACzCC,mCAAmC,QAC9B,4BAA4B;AAGnC,SACEC,oBAAoB,EACpBC,4BAA4B,EAC5BC,gCAAgC,QAC3B,0BAA0B;AAWjC,SACEC,gCAAgC,EAChChC,+BAA+BiC,6BAA6B,QACvD,uBAAuB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useReference.ts"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, mergeClasses, slot, useId } from '@fluentui/react-components';\nimport { useReferenceListContext_unstable } from '../../../contexts/reference-v2/referenceListContext';\nimport { referenceExtraClassNames } from './useReferenceStyles.styles';\nimport type { ReferenceProps, ReferenceState } from './Reference.types';\n\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 = (\n props: ReferenceProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>,\n): ReferenceState => {\n const { as, children, id } = props;\n\n const shouldUseOverflow = useReferenceListContext_unstable(ctx => ctx.shouldUseOverflow);\n\n const referenceId = useId('reference-', id);\n\n const elementType = as || ((props as JSX.IntrinsicElements['a']).href ? 'a' : 'button');\n const propsWithAssignedAs = {\n type: elementType === 'button' ? 'button' : undefined,\n ...props,\n as: elementType,\n id: referenceId,\n } as ReferenceProps;\n\n const citation = slot.optional(props.citation, { elementType: 'span' });\n const graphic = slot.optional(props.graphic, { elementType: 'span' });\n const content = slot.optional(props.content, {\n elementType: 'span',\n renderByDefault: graphic !== undefined || !!children,\n });\n const divider = slot.optional(props.divider, {\n elementType: 'span',\n renderByDefault: citation !== undefined && content !== undefined,\n });\n\n const state: ReferenceState = {\n id: referenceId,\n shouldUseOverflow,\n\n components: {\n root:
|
|
1
|
+
{"version":3,"sources":["useReference.ts"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, mergeClasses, slot, useId } from '@fluentui/react-components';\nimport { useReferenceListContext_unstable } from '../../../contexts/reference-v2/referenceListContext';\nimport { referenceExtraClassNames } from './useReferenceStyles.styles';\nimport type { ReferenceProps, ReferenceState } from './Reference.types';\n\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 = (\n props: ReferenceProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>,\n): ReferenceState => {\n const { as, children, id } = props;\n\n const shouldUseOverflow = useReferenceListContext_unstable(ctx => ctx.shouldUseOverflow);\n\n const referenceId = useId('reference-', id);\n\n const elementType = as || ((props as JSX.IntrinsicElements['a']).href ? 'a' : 'button');\n const propsWithAssignedAs = {\n type: elementType === 'button' ? 'button' : undefined,\n ...props,\n as: elementType,\n id: referenceId,\n } as ReferenceProps;\n\n const citation = slot.optional(props.citation, { elementType: 'span' });\n const graphic = slot.optional(props.graphic, { elementType: 'span' });\n const content = slot.optional(props.content, {\n elementType: 'span',\n renderByDefault: graphic !== undefined || !!children,\n });\n const divider = slot.optional(props.divider, {\n elementType: 'span',\n renderByDefault: citation !== undefined && content !== undefined,\n });\n\n const state: ReferenceState = {\n id: referenceId,\n shouldUseOverflow,\n\n components: {\n root: elementType,\n citation: 'span',\n divider: 'span',\n graphic: 'span',\n content: 'span',\n },\n\n root: slot.always(\n getIntrinsicElementProps(elementType, {\n ref,\n ...propsWithAssignedAs,\n }),\n { elementType },\n ),\n citation,\n divider,\n content,\n graphic,\n };\n\n if (state.graphic && React.isValidElement<HTMLElement>(state.graphic.children)) {\n state.graphic.children = React.cloneElement(state.graphic.children, {\n className: mergeClasses(state.graphic.children.props.className, referenceExtraClassNames.graphicChild),\n });\n }\n\n return state;\n};\n"],"names":["as","props","children","elementType","id","shouldUseOverflow","useReferenceListContext_unstable","ctx","referenceId","propsWithAssignedAs","type","citation","optional","slot","content","renderByDefault","graphic","undefined","ref","always","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A,CAAAd,QAAA,EAAA"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "generateReferenceCitationPreview", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return generateReferenceCitationPreview;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
+
const _reactcomponents = require("@fluentui/react-components");
|
|
14
|
+
const _reactpreview = require("@fluentui-copilot/react-preview");
|
|
15
|
+
const _reactsensitivitylabel = require("@fluentui-copilot/react-sensitivity-label");
|
|
16
|
+
const _Citation = require("../../Citation");
|
|
17
|
+
const _ReferenceV2 = require("../../ReferenceV2");
|
|
18
|
+
// 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.
|
|
19
|
+
const CitationCloseButton = (citationCloseButtonProps)=>{
|
|
20
|
+
const setPopoverOpen = (0, _reactcomponents.usePopoverContext_unstable)((context)=>context.setOpen);
|
|
21
|
+
const onPopoverCloseClick = _react.useCallback((ev)=>{
|
|
22
|
+
setPopoverOpen(ev, false);
|
|
23
|
+
// Don't navigate
|
|
24
|
+
ev.preventDefault();
|
|
25
|
+
}, [
|
|
26
|
+
setPopoverOpen
|
|
27
|
+
]);
|
|
28
|
+
const onCitationCloseButtonClick = (0, _reactcomponents.mergeCallbacks)(onPopoverCloseClick, citationCloseButtonProps.onClick);
|
|
29
|
+
return /*#__PURE__*/ _react.createElement(_Citation.Citation, {
|
|
30
|
+
...citationCloseButtonProps,
|
|
31
|
+
onClick: onCitationCloseButtonClick
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const generateReferenceCitationPreview = (props)=>{
|
|
35
|
+
const { citationPreviewProps, citationPreviewSurfaceProps, citationProps, index, previewContentProps, previewHeaderProps, referencePreviewProps, referencePreviewSurfaceProps, referenceProps, sensitivityLabelProps } = props;
|
|
36
|
+
const CitationWithPreview = (props)=>{
|
|
37
|
+
var _previewContentProps_content;
|
|
38
|
+
return /*#__PURE__*/ _react.createElement(_reactpreview.Preview, {
|
|
39
|
+
closeOnScroll: true,
|
|
40
|
+
positioning: "below",
|
|
41
|
+
size: "small",
|
|
42
|
+
trapFocus: true,
|
|
43
|
+
withArrow: true,
|
|
44
|
+
...citationPreviewProps
|
|
45
|
+
}, /*#__PURE__*/ _react.createElement(_reactpreview.PreviewTrigger, null, /*#__PURE__*/ _react.createElement(_Citation.Citation, {
|
|
46
|
+
...citationProps,
|
|
47
|
+
...props
|
|
48
|
+
}, index)), /*#__PURE__*/ _react.createElement(_reactpreview.PreviewSurface, citationPreviewSurfaceProps, /*#__PURE__*/ _react.createElement(_reactpreview.PreviewContent, null, /*#__PURE__*/ _react.createElement(_reactpreview.PreviewHeader, {
|
|
49
|
+
citation: /*#__PURE__*/ _react.createElement(CitationCloseButton, {
|
|
50
|
+
"aria-label": `Reference ${index}, close`,
|
|
51
|
+
referenceHref: "#",
|
|
52
|
+
tabIndex: -1
|
|
53
|
+
}, index),
|
|
54
|
+
media: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.graphic
|
|
55
|
+
}, referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.children), /*#__PURE__*/ _react.createElement(_reactpreview.PreviewMetadata, {
|
|
56
|
+
icon: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.icon,
|
|
57
|
+
primaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.primaryText,
|
|
58
|
+
secondaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.secondaryText,
|
|
59
|
+
tertiaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.tertiaryText
|
|
60
|
+
}), sensitivityLabelProps && /*#__PURE__*/ _react.createElement(_reactsensitivitylabel.SensitivityLabel, sensitivityLabelProps), (_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)));
|
|
61
|
+
};
|
|
62
|
+
const ReferenceWithPreview = (props)=>{
|
|
63
|
+
const mergedReferenceProps = {
|
|
64
|
+
citation: index,
|
|
65
|
+
...referenceProps,
|
|
66
|
+
...props
|
|
67
|
+
};
|
|
68
|
+
var _previewHeaderProps_children, _previewContentProps_content;
|
|
69
|
+
return /*#__PURE__*/ _react.createElement(_reactpreview.Preview, {
|
|
70
|
+
closeOnScroll: true,
|
|
71
|
+
positioning: "below",
|
|
72
|
+
size: "small",
|
|
73
|
+
trapFocus: true,
|
|
74
|
+
withArrow: true,
|
|
75
|
+
...referencePreviewProps
|
|
76
|
+
}, /*#__PURE__*/ _react.createElement(_reactpreview.PreviewTrigger, null, /*#__PURE__*/ _react.createElement(_ReferenceV2.Reference, mergedReferenceProps)), /*#__PURE__*/ _react.createElement(_reactpreview.PreviewSurface, referencePreviewSurfaceProps, /*#__PURE__*/ _react.createElement(_reactpreview.PreviewContent, null, /*#__PURE__*/ _react.createElement(_reactpreview.PreviewHeader, {
|
|
77
|
+
citation: /*#__PURE__*/ _react.createElement(CitationCloseButton, {
|
|
78
|
+
"aria-label": `Reference ${index}, close`,
|
|
79
|
+
referenceHref: "#",
|
|
80
|
+
tabIndex: -1
|
|
81
|
+
}, index),
|
|
82
|
+
media: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.graphic,
|
|
83
|
+
...previewHeaderProps
|
|
84
|
+
}, (_previewHeaderProps_children = previewHeaderProps === null || previewHeaderProps === void 0 ? void 0 : previewHeaderProps.children) !== null && _previewHeaderProps_children !== void 0 ? _previewHeaderProps_children : referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.children), /*#__PURE__*/ _react.createElement(_reactpreview.PreviewMetadata, {
|
|
85
|
+
icon: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.icon,
|
|
86
|
+
primaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.primaryText,
|
|
87
|
+
secondaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.secondaryText,
|
|
88
|
+
tertiaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.tertiaryText
|
|
89
|
+
}), sensitivityLabelProps && /*#__PURE__*/ _react.createElement(_reactsensitivitylabel.SensitivityLabel, sensitivityLabelProps), (_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)));
|
|
90
|
+
};
|
|
91
|
+
const components = {
|
|
92
|
+
Citation: CitationWithPreview,
|
|
93
|
+
Reference: ReferenceWithPreview
|
|
94
|
+
};
|
|
95
|
+
return components;
|
|
96
|
+
}; //# sourceMappingURL=generateReferenceCitationPreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["generateReferenceCitationPreview.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { mergeCallbacks, usePopoverContext_unstable } 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 {\n PreviewHeaderProps,\n PreviewMetadataProps,\n PreviewProps,\n PreviewSurfaceProps,\n} from '@fluentui-copilot/react-preview';\nimport type { SensitivityLabelProps } from '@fluentui-copilot/react-sensitivity-label';\n\nimport { Citation } from '../../Citation';\nimport { Reference } from '../../ReferenceV2';\nimport type { CitationProps } from '../../Citation';\nimport type { ReferenceProps } from '../../ReferenceV2';\n\nexport type PackagedCitation = React.FC<CitationProps>;\n\nexport type PackagedReference = React.FC<ReferenceProps>;\n\nexport type PackagedPreviewContentProps = Pick<\n PreviewMetadataProps,\n 'icon' | 'primaryText' | 'secondaryText' | 'tertiaryText'\n> & {\n content?: React.ReactNode;\n};\n\nexport type ReferenceCitationPreviewGeneratorProps = {\n citationPreviewProps?: PreviewProps;\n citationPreviewSurfaceProps?: PreviewSurfaceProps;\n citationProps?: CitationProps;\n index: number;\n previewContentProps?: PackagedPreviewContentProps;\n previewHeaderProps?: PreviewHeaderProps;\n referencePreviewProps?: PreviewProps;\n referencePreviewSurfaceProps?: PreviewSurfaceProps;\n referenceProps?: ReferenceProps;\n sensitivityLabelProps?: SensitivityLabelProps;\n};\n\nexport type ReferenceCitationPreviewGenerator = (props: ReferenceCitationPreviewGeneratorProps) => {\n Citation: PackagedCitation;\n Reference: PackagedReference;\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 * Function to generate a Citation - Reference pair with correctly wired props.\n * Both the Citation and the Reference act as trigger components to Previews that are also correctly wired by the function.\n * Props can either be passed in to the function or applied directly to the generated components in JSX.\n *\n * A `useReferenceCitationPreview` hook exists that calls this function and memoizes its return value based on the props.\n * You should use the hook when the props used to generate the Citation - Reference pair can change dynamically.\n * If they are static, or in case you wanted to generate multiple pairs within a cycle, you should call\n * `generateReferenceCitationPreview` directly.\n *\n * @returns A Citation - Reference pair with correctly wired props.\n */\nexport const generateReferenceCitationPreview: ReferenceCitationPreviewGenerator = props => {\n const {\n citationPreviewProps,\n citationPreviewSurfaceProps,\n citationProps,\n index,\n previewContentProps,\n previewHeaderProps,\n referencePreviewProps,\n referencePreviewSurfaceProps,\n referenceProps,\n sensitivityLabelProps,\n } = props;\n\n const CitationWithPreview: PackagedCitation = props => {\n return (\n <Preview closeOnScroll positioning=\"below\" size=\"small\" trapFocus withArrow {...citationPreviewProps}>\n <PreviewTrigger>\n <Citation {...citationProps} {...props}>\n {index}\n </Citation>\n </PreviewTrigger>\n <PreviewSurface {...citationPreviewSurfaceProps}>\n <PreviewContent>\n <PreviewHeader\n citation={\n <CitationCloseButton aria-label={`Reference ${index}, close`} referenceHref=\"#\" tabIndex={-1}>\n {index}\n </CitationCloseButton>\n }\n media={referenceProps?.graphic as PreviewHeaderProps['media']}\n >\n {referenceProps?.children}\n </PreviewHeader>\n <PreviewMetadata\n icon={previewContentProps?.icon}\n primaryText={previewContentProps?.primaryText}\n secondaryText={previewContentProps?.secondaryText}\n tertiaryText={previewContentProps?.tertiaryText}\n />\n {sensitivityLabelProps && <SensitivityLabel {...sensitivityLabelProps} />}\n {previewContentProps?.content ?? citationPreviewProps?.children}\n </PreviewContent>\n </PreviewSurface>\n </Preview>\n );\n };\n\n const ReferenceWithPreview: PackagedReference = props => {\n const mergedReferenceProps = {\n citation: index,\n ...referenceProps,\n ...props,\n } as ReferenceProps;\n\n return (\n <Preview closeOnScroll positioning=\"below\" size=\"small\" trapFocus withArrow {...referencePreviewProps}>\n <PreviewTrigger>\n <Reference {...mergedReferenceProps} />\n </PreviewTrigger>\n <PreviewSurface {...referencePreviewSurfaceProps}>\n <PreviewContent>\n <PreviewHeader\n citation={\n <CitationCloseButton aria-label={`Reference ${index}, close`} referenceHref=\"#\" tabIndex={-1}>\n {index}\n </CitationCloseButton>\n }\n media={referenceProps?.graphic as PreviewHeaderProps['media']}\n {...previewHeaderProps}\n >\n {previewHeaderProps?.children ?? referenceProps?.children}\n </PreviewHeader>\n <PreviewMetadata\n icon={previewContentProps?.icon}\n primaryText={previewContentProps?.primaryText}\n secondaryText={previewContentProps?.secondaryText}\n tertiaryText={previewContentProps?.tertiaryText}\n />\n {sensitivityLabelProps && <SensitivityLabel {...sensitivityLabelProps} />}\n {previewContentProps?.content ?? referencePreviewProps?.children}\n </PreviewContent>\n </PreviewSurface>\n </Preview>\n );\n };\n\n const components = {\n Citation: CitationWithPreview,\n Reference: ReferenceWithPreview,\n };\n\n return components;\n};\n"],"names":["CitationCloseButton","citationCloseButtonProps","setPopoverOpen","usePopoverContext_unstable","context","setOpen","onPopoverCloseClick","React","useCallback","ev","preventDefault","createElement","Citation","onCitationCloseButtonClick","onClick","citationPreviewProps","citationPreviewSurfaceProps","CitationWithPreview","previewContentProps","closeOnScroll","positioning","trapFocus","withArrow","props","index","Preview","citation","aria-label","tabIndex","referenceProps","children","primaryText","secondaryText","PreviewHeader","tertiaryText","sensitivityLabelProps","referenceHref","ReferenceWithPreview","PreviewMetadata","icon","previewHeaderProps","referencePreviewProps","_previewContentProps_content","media","PreviewSurface","referencePreviewSurfaceProps","PreviewContent","Reference","_previewHeaderProps_children","components"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;iEAAuB;iCAEoC;8BASpD;uCAC0B;0BASR;6BACC;AAiC1B,6IAA6I;AAC7I,MAAMA,sBAAsBC,CAAAA;UAC1BC,iBAAMA,IAAAA,2CAAiBC,EAAAA,CAAAA,UAA2BC,QAAWA,OAAQC;UAErEC,sBAAMA,OAAsBC,WAAMC,CAAAA,CAAAA;uBAE9BN,IAAeO;yBAEf;yBACGC;OACL;QAAAR;KACA;UAACA,6BAAAA,IAAAA,+BAAAA,EAAAA,qBAAAA,yBAAAA,OAAAA;WAAe,WAAA,GAAAK,OAAAI,aAAA,CAAAC,kBAAA,EAAA;QAGlB,GAAAX,wBA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AAAA;YACPlB,aAAAb,wBAAA,QAAAA,wBAAA,KAAA,IAAA,KAAA,IAAAA,oBAAAa,WAAA"}
|
|
@@ -3,5 +3,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
const _export_star = require("@swc/helpers/_/_export_star");
|
|
6
|
+
_export_star._(require("./generateReferenceCitationPreview"), exports);
|
|
6
7
|
_export_star._(require("./useReferenceCitationPreview"), exports);
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './useReferenceCitationPreview';\n"],"names":[],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './generateReferenceCitationPreview';\nexport * from './useReferenceCitationPreview';\n"],"names":[],"rangeMappings":";;;;;;","mappings":";;;;;uBAAc;uBACA"}
|
|
@@ -9,145 +9,10 @@ Object.defineProperty(exports, "useReferenceCitationPreview", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
|
-
const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
|
|
13
12
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
14
|
-
const
|
|
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
|
-
};
|
|
13
|
+
const _generateReferenceCitationPreview = require("./generateReferenceCitationPreview");
|
|
35
14
|
const useReferenceCitationPreview = (props)=>{
|
|
36
|
-
|
|
37
|
-
|
|
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.graphic,
|
|
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
|
-
const mergedReferenceProps = {
|
|
87
|
-
citation: index,
|
|
88
|
-
...referenceProps,
|
|
89
|
-
...props
|
|
90
|
-
};
|
|
91
|
-
var _previewHeaderProps_children, _previewContentProps_content;
|
|
92
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactpreview.Preview, {
|
|
93
|
-
closeOnScroll: true,
|
|
94
|
-
positioning: "below",
|
|
95
|
-
size: "small",
|
|
96
|
-
trapFocus: true,
|
|
97
|
-
withArrow: true,
|
|
98
|
-
...referencePreviewProps,
|
|
99
|
-
children: [
|
|
100
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactpreview.PreviewTrigger, {
|
|
101
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ReferenceV2.Reference, {
|
|
102
|
-
...mergedReferenceProps
|
|
103
|
-
})
|
|
104
|
-
}),
|
|
105
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactpreview.PreviewSurface, {
|
|
106
|
-
...referencePreviewSurfaceProps,
|
|
107
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reactpreview.PreviewContent, {
|
|
108
|
-
children: [
|
|
109
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactpreview.PreviewHeader, {
|
|
110
|
-
citation: /*#__PURE__*/ (0, _jsxruntime.jsx)(CitationCloseButton, {
|
|
111
|
-
"aria-label": `Reference ${index}, close`,
|
|
112
|
-
referenceHref: "#",
|
|
113
|
-
tabIndex: -1,
|
|
114
|
-
children: index
|
|
115
|
-
}),
|
|
116
|
-
media: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.graphic,
|
|
117
|
-
...previewHeaderProps,
|
|
118
|
-
children: (_previewHeaderProps_children = previewHeaderProps === null || previewHeaderProps === void 0 ? void 0 : previewHeaderProps.children) !== null && _previewHeaderProps_children !== void 0 ? _previewHeaderProps_children : referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.children
|
|
119
|
-
}),
|
|
120
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactpreview.PreviewMetadata, {
|
|
121
|
-
icon: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.icon,
|
|
122
|
-
primaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.primaryText,
|
|
123
|
-
secondaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.secondaryText,
|
|
124
|
-
tertiaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.tertiaryText
|
|
125
|
-
}),
|
|
126
|
-
sensitivityLabelProps && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactsensitivitylabel.SensitivityLabel, {
|
|
127
|
-
...sensitivityLabelProps
|
|
128
|
-
}),
|
|
129
|
-
(_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
|
|
130
|
-
]
|
|
131
|
-
})
|
|
132
|
-
})
|
|
133
|
-
]
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
return {
|
|
137
|
-
Citation: CitationWithPreview,
|
|
138
|
-
Reference: ReferenceWithPreview
|
|
139
|
-
};
|
|
140
|
-
}, [
|
|
141
|
-
citationPreviewProps,
|
|
142
|
-
citationPreviewSurfaceProps,
|
|
143
|
-
citationProps,
|
|
144
|
-
index,
|
|
145
|
-
previewHeaderProps,
|
|
146
|
-
referencePreviewProps,
|
|
147
|
-
referencePreviewSurfaceProps,
|
|
148
|
-
referenceProps,
|
|
149
|
-
previewContentProps,
|
|
150
|
-
sensitivityLabelProps
|
|
15
|
+
return _react.useMemo(()=>(0, _generateReferenceCitationPreview.generateReferenceCitationPreview)(props), [
|
|
16
|
+
props
|
|
151
17
|
]);
|
|
152
|
-
return components;
|
|
153
18
|
}; //# 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';\n\nimport {
|
|
1
|
+
{"version":3,"sources":["useReferenceCitationPreview.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport * as React from 'react';\n\nimport {\n generateReferenceCitationPreview,\n type ReferenceCitationPreviewGenerator,\n type ReferenceCitationPreviewGeneratorProps,\n} from './generateReferenceCitationPreview';\n\nexport type UseReferenceCitationPreviewProps = ReferenceCitationPreviewGeneratorProps;\n\nexport type UseReferenceCitationPreview = ReferenceCitationPreviewGenerator;\n\n/**\n * Hook to generate a Citation - Reference pair with correctly wired props.\n * Both the Citation and the Reference act as trigger components to Previews that are also correctly wired by the hook.\n * Props can either be passed in to the hook or applied directly to the generated components in JSX.\n *\n * This hook internally calls the `generateReferenceCitationPreview` function and memoizes its return value based on the props.\n * You should only use this hook when the props used to generate the Citation - Reference pair can change dynamically.\n * If they are static, or in case you wanted to generate multiple pairs within a cycle, you should call\n * `generateReferenceCitationPreview` directly.\n *\n * @returns A Citation - Reference pair with correctly wired props.\n */\nexport const useReferenceCitationPreview: UseReferenceCitationPreview = props => {\n return React.useMemo(() => generateReferenceCitationPreview(props), [props]);\n};\n"],"names":["React","generateReferenceCitationPreview","props"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":";;;;+BA4BSA;;;eAAAA;;;;iEA5BT;kDASO;AAmBL,MAAOA,8BAAoBC,CAAAA;WAA0CC,OAAAA,OAAAA,CAAAA,IAAAA,IAAAA,kEAAAA,EAAAA,QAAAA;QAAAA;KAAAA;GACvE,uDAAE"}
|
package/lib-commonjs/index.js
CHANGED
|
@@ -39,6 +39,9 @@ _export(exports, {
|
|
|
39
39
|
citationClassNames: function() {
|
|
40
40
|
return _Citation.citationClassNames;
|
|
41
41
|
},
|
|
42
|
+
generateReferenceCitationPreview: function() {
|
|
43
|
+
return _referencev21.generateReferenceCitationPreview;
|
|
44
|
+
},
|
|
42
45
|
referenceClassNames: function() {
|
|
43
46
|
return _Reference.referenceClassNames;
|
|
44
47
|
},
|
|
@@ -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 { 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\n// reference-v2 exports\nexport type {\n ReferenceProps as ReferenceV2Props,\n ReferenceSlots as ReferenceV2Slots,\n ReferenceState as ReferenceV2State,\n} from './ReferenceV2';\nexport {\n Reference as ReferenceV2,\n referenceClassNames as referenceV2ClassNames,\n referenceExtraClassNames as referenceV2ExtraClassNames,\n renderReference_unstable as renderReferenceV2_unstable,\n useReferenceStyles_unstable as useReferenceV2Styles_unstable,\n useReference_unstable as useReferenceV2_unstable,\n} from './ReferenceV2';\n\nexport type {\n ReferenceListContextValues as ReferenceListV2ContextValues,\n ReferenceListProps as ReferenceListV2Props,\n ReferenceListSlots as ReferenceListV2Slots,\n ReferenceListState as ReferenceListV2State,\n} from './ReferenceListV2';\nexport {\n ReferenceList as ReferenceListV2,\n referenceListClassNames as referenceListV2ClassNames,\n renderReferenceList_unstable as renderReferenceListV2_unstable,\n useReferenceListStyles_unstable as useReferenceListV2Styles_unstable,\n useReferenceList_unstable as useReferenceListV2_unstable,\n} from './ReferenceListV2';\n\nexport type {\n ReferenceOverflowButtonProps,\n ReferenceOverflowButtonSlots,\n ReferenceOverflowButtonState,\n} from './ReferenceOverflowButton';\nexport {\n ReferenceOverflowButton,\n referenceOverflowButtonClassNames,\n renderReferenceOverflowButton_unstable,\n useReferenceOverflowButtonStyles_unstable,\n useReferenceOverflowButton_unstable,\n} from './ReferenceOverflowButton';\n\nexport type { ReferenceListContextValue } from './contexts/reference-v2';\nexport {\n ReferenceListContext,\n ReferenceListContextProvider,\n useReferenceListContext_unstable,\n} from './contexts/reference-v2';\n\nexport type {\n PackagedCitation as PackagedCitationV2,\n PackagedPreviewContentProps as PackagedPreviewContentV2Props,\n PackagedReference as PackagedReferenceV2,\n UseReferenceCitationPreview as UseReferenceCitationPreviewV2,\n UseReferenceCitationPreviewProps as UseReferenceCitationPreviewV2Props,\n} from './hooks/reference-v2';\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\n// reference-v2 exports\nexport type {\n ReferenceProps as ReferenceV2Props,\n ReferenceSlots as ReferenceV2Slots,\n ReferenceState as ReferenceV2State,\n} from './ReferenceV2';\nexport {\n Reference as ReferenceV2,\n referenceClassNames as referenceV2ClassNames,\n referenceExtraClassNames as referenceV2ExtraClassNames,\n renderReference_unstable as renderReferenceV2_unstable,\n useReferenceStyles_unstable as useReferenceV2Styles_unstable,\n useReference_unstable as useReferenceV2_unstable,\n} from './ReferenceV2';\n\nexport type {\n ReferenceListContextValues as ReferenceListV2ContextValues,\n ReferenceListProps as ReferenceListV2Props,\n ReferenceListSlots as ReferenceListV2Slots,\n ReferenceListState as ReferenceListV2State,\n} from './ReferenceListV2';\nexport {\n ReferenceList as ReferenceListV2,\n referenceListClassNames as referenceListV2ClassNames,\n renderReferenceList_unstable as renderReferenceListV2_unstable,\n useReferenceListStyles_unstable as useReferenceListV2Styles_unstable,\n useReferenceList_unstable as useReferenceListV2_unstable,\n} from './ReferenceListV2';\n\nexport type {\n ReferenceOverflowButtonProps,\n ReferenceOverflowButtonSlots,\n ReferenceOverflowButtonState,\n} from './ReferenceOverflowButton';\nexport {\n ReferenceOverflowButton,\n referenceOverflowButtonClassNames,\n renderReferenceOverflowButton_unstable,\n useReferenceOverflowButtonStyles_unstable,\n useReferenceOverflowButton_unstable,\n} from './ReferenceOverflowButton';\n\nexport type { ReferenceListContextValue } from './contexts/reference-v2';\nexport {\n ReferenceListContext,\n ReferenceListContextProvider,\n useReferenceListContext_unstable,\n} from './contexts/reference-v2';\n\nexport type {\n PackagedCitation as PackagedCitationV2,\n PackagedPreviewContentProps as PackagedPreviewContentV2Props,\n PackagedReference as PackagedReferenceV2,\n ReferenceCitationPreviewGenerator,\n ReferenceCitationPreviewGeneratorProps,\n UseReferenceCitationPreview as UseReferenceCitationPreviewV2,\n UseReferenceCitationPreviewProps as UseReferenceCitationPreviewV2Props,\n} from './hooks/reference-v2';\nexport {\n generateReferenceCitationPreview,\n useReferenceCitationPreview as useReferenceCitationPreviewV2,\n} from './hooks/reference-v2';\n"],"names":["Citation","Reference","ReferenceGroupToggle","ReferenceList","ReferenceListContext","ReferenceListContextProvider","ReferenceListV2","ReferenceOverflowButton","ReferenceV2","citationClassNames","generateReferenceCitationPreview","referenceClassNames","referenceGroupToggleClassNames","referenceListClassNames","referenceListV2ClassNames","referenceOverflowButtonClassNames","referenceV2ClassNames","referenceV2ExtraClassNames","referenceExtraClassNames","renderCitation_unstable","renderReferenceGroupToggle_unstable","renderReferenceListV2_unstable","renderReferenceList_unstable","renderReferenceOverflowButton_unstable","renderReferenceV2_unstable","renderReference_unstable","useCitationStyles_unstable","useCitation_unstable","useReferenceCitationPreview","useReferenceCitationPreviewV2","useReferenceGroup","useReferenceGroupToggleStyles_unstable","useReferenceGroupToggle_unstable","useReferenceListContext_unstable","useReferenceListStyles_unstable","useReferenceListV2Styles_unstable","useReferenceListV2_unstable","useReferenceList_unstable","useReferenceOverflowButtonStyles_unstable","useReferenceOverflowButton_unstable","useReferenceStyles_unstable","useReferenceV2Styles_unstable","useReferenceV2_unstable","useReference_unstable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IACEA,QAAQ;eAARA,kBAAQ;;IAORC,SAAS;eAATA,oBAA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,kEAAyC;;IACzCC,mCAAmC;eAAnCA,4DAAmC;;IA/EnCC,2BAA2B;eAA3BA,sCAA2B;;IAmDIC,6BAA6B;eAA5DD,wCAAAA;;IACyBE,uBAAuB;eAAhDC,kCAAAA;;IArDAA,qBAAqB;eAArBA,gCAAqB;;;0BALhB;2BAOA;uBACwD;+BAOxD;sCAOA;6BAqCA;iCAcA;yCAaA;6BAOA;8BAcA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui-copilot/react-reference",
|
|
3
|
-
"version": "0.0.0-nightly-
|
|
3
|
+
"version": "0.0.0-nightly-20240627-0406-0fec4afd.1",
|
|
4
4
|
"description": "Fluent AI controls for citations and references",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@fluentui-copilot/react-preview": "0.0.0-nightly-
|
|
16
|
-
"@fluentui-copilot/react-provider": "0.0.0-nightly-
|
|
17
|
-
"@fluentui-copilot/react-sensitivity-label": "0.0.0-nightly-
|
|
18
|
-
"@fluentui-copilot/react-utilities": "0.0.0-nightly-
|
|
15
|
+
"@fluentui-copilot/react-preview": "0.0.0-nightly-20240627-0406-0fec4afd.1",
|
|
16
|
+
"@fluentui-copilot/react-provider": "0.0.0-nightly-20240627-0406-0fec4afd.1",
|
|
17
|
+
"@fluentui-copilot/react-sensitivity-label": "0.0.0-nightly-20240627-0406-0fec4afd.1",
|
|
18
|
+
"@fluentui-copilot/react-utilities": "0.0.0-nightly-20240627-0406-0fec4afd.1",
|
|
19
19
|
"@swc/helpers": "^0.5.1"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|