@fluentui-copilot/react-reference 0.15.5-hotfix.1 → 0.15.5-hotfix.2
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 +4 -4
- package/CHANGELOG.md +5 -5
- package/lib/Citation.js +1 -0
- package/lib/Reference.js +1 -0
- package/lib/ReferenceGroupToggle.js +1 -0
- package/lib/ReferenceList.js +1 -0
- package/lib/ReferenceListV2.js +1 -0
- package/lib/ReferenceOverflowButton.js +1 -0
- package/lib/ReferenceV2.js +1 -0
- package/lib/components/Citation/Citation.js +6 -5
- package/lib/components/Citation/Citation.types.js +2 -1
- package/lib/components/Citation/index.js +1 -0
- package/lib/components/Citation/renderCitation.js +6 -4
- package/lib/components/Citation/useCitation.js +28 -22
- package/lib/components/Citation/useCitationStyles.styles.raw.js +59 -54
- package/lib/components/Reference/Reference.js +7 -5
- package/lib/components/Reference/Reference.types.js +2 -1
- package/lib/components/Reference/index.js +1 -0
- package/lib/components/Reference/renderReference.js +12 -27
- package/lib/components/Reference/useReference.js +172 -173
- package/lib/components/Reference/useReferenceStyles.styles.raw.js +181 -172
- package/lib/components/ReferenceGroupToggle/ReferenceGroupToggle.js +6 -4
- package/lib/components/ReferenceGroupToggle/ReferenceGroupToggle.types.js +2 -1
- package/lib/components/ReferenceGroupToggle/index.js +1 -0
- package/lib/components/ReferenceGroupToggle/renderReferenceGroupToggle.js +8 -9
- package/lib/components/ReferenceGroupToggle/useReferenceGroupToggle.js +30 -26
- package/lib/components/ReferenceGroupToggle/useReferenceGroupToggleStyles.styles.raw.js +36 -31
- package/lib/components/ReferenceList/ReferenceList.js +7 -5
- package/lib/components/ReferenceList/ReferenceList.types.js +2 -1
- package/lib/components/ReferenceList/index.js +1 -0
- package/lib/components/ReferenceList/renderReferenceList.js +6 -4
- package/lib/components/ReferenceList/useReferenceList.js +17 -15
- package/lib/components/ReferenceList/useReferenceListStyles.styles.raw.js +22 -16
- package/lib/components/reference-v2/Reference/Reference.js +5 -4
- package/lib/components/reference-v2/Reference/Reference.types.js +2 -1
- package/lib/components/reference-v2/Reference/index.js +1 -0
- package/lib/components/reference-v2/Reference/renderReference.js +17 -20
- package/lib/components/reference-v2/Reference/useReference.js +59 -53
- package/lib/components/reference-v2/Reference/useReferenceStyles.styles.raw.js +89 -84
- package/lib/components/reference-v2/ReferenceList/ReferenceList.js +6 -5
- package/lib/components/reference-v2/ReferenceList/ReferenceList.types.js +2 -1
- package/lib/components/reference-v2/ReferenceList/index.js +1 -0
- package/lib/components/reference-v2/ReferenceList/renderReferenceList.js +17 -17
- package/lib/components/reference-v2/ReferenceList/useReferenceList.js +80 -70
- package/lib/components/reference-v2/ReferenceList/useReferenceListContextValues.js +21 -13
- package/lib/components/reference-v2/ReferenceList/useReferenceListStyles.styles.raw.js +38 -31
- package/lib/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.js +5 -4
- package/lib/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.types.js +2 -1
- package/lib/components/reference-v2/ReferenceOverflowButton/index.js +1 -0
- package/lib/components/reference-v2/ReferenceOverflowButton/renderReferenceOverflowButton.js +14 -9
- package/lib/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js +77 -77
- package/lib/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.raw.js +39 -33
- package/lib/components/reference-v2/index.js +1 -0
- package/lib/contexts/ReferenceGroupContext.js +6 -5
- package/lib/contexts/reference-v2/index.js +1 -0
- package/lib/contexts/reference-v2/referenceListContext.js +12 -11
- package/lib/index.js +1 -0
- package/lib/utilities/index.js +1 -0
- package/lib/utilities/reference-v2/generateReferenceCitationPreview.js +86 -75
- package/lib/utilities/reference-v2/index.js +1 -0
- package/lib/utilities/reference-v2/useReferenceCitationPreview.js +5 -5
- package/lib/utilities/useReferenceCitationPreview.js +114 -123
- package/lib/utilities/useReferenceGroup.js +24 -26
- package/lib/utilities/useReferenceGroup.styles.raw.js +4 -3
- package/lib-commonjs/Citation.js +1 -0
- package/lib-commonjs/Reference.js +1 -0
- package/lib-commonjs/ReferenceGroupToggle.js +1 -0
- package/lib-commonjs/ReferenceList.js +1 -0
- package/lib-commonjs/ReferenceListV2.js +1 -0
- package/lib-commonjs/ReferenceOverflowButton.js +1 -0
- package/lib-commonjs/ReferenceV2.js +1 -0
- package/lib-commonjs/components/Citation/Citation.js +1 -1
- package/lib-commonjs/components/Citation/Citation.js.map +1 -1
- package/lib-commonjs/components/Citation/Citation.types.js +1 -0
- package/lib-commonjs/components/Citation/index.js +1 -0
- package/lib-commonjs/components/Citation/renderCitation.js +1 -1
- package/lib-commonjs/components/Citation/renderCitation.js.map +1 -1
- package/lib-commonjs/components/Citation/useCitation.js +1 -1
- package/lib-commonjs/components/Citation/useCitation.js.map +1 -1
- package/lib-commonjs/components/Citation/useCitationStyles.styles.raw.js +1 -1
- package/lib-commonjs/components/Citation/useCitationStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/Reference/Reference.js +1 -1
- package/lib-commonjs/components/Reference/Reference.js.map +1 -1
- package/lib-commonjs/components/Reference/Reference.types.js +1 -0
- package/lib-commonjs/components/Reference/index.js +1 -0
- package/lib-commonjs/components/Reference/renderReference.js +1 -1
- package/lib-commonjs/components/Reference/renderReference.js.map +1 -1
- package/lib-commonjs/components/Reference/useReference.js +1 -1
- package/lib-commonjs/components/Reference/useReference.js.map +1 -1
- package/lib-commonjs/components/Reference/useReferenceStyles.styles.raw.js +1 -1
- package/lib-commonjs/components/Reference/useReferenceStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ReferenceGroupToggle/ReferenceGroupToggle.js +1 -1
- package/lib-commonjs/components/ReferenceGroupToggle/ReferenceGroupToggle.js.map +1 -1
- package/lib-commonjs/components/ReferenceGroupToggle/ReferenceGroupToggle.types.js +1 -0
- package/lib-commonjs/components/ReferenceGroupToggle/index.js +1 -0
- package/lib-commonjs/components/ReferenceGroupToggle/renderReferenceGroupToggle.js +1 -1
- package/lib-commonjs/components/ReferenceGroupToggle/renderReferenceGroupToggle.js.map +1 -1
- package/lib-commonjs/components/ReferenceGroupToggle/useReferenceGroupToggle.js +1 -1
- package/lib-commonjs/components/ReferenceGroupToggle/useReferenceGroupToggle.js.map +1 -1
- package/lib-commonjs/components/ReferenceGroupToggle/useReferenceGroupToggleStyles.styles.raw.js +1 -1
- package/lib-commonjs/components/ReferenceGroupToggle/useReferenceGroupToggleStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ReferenceList/ReferenceList.js +1 -1
- package/lib-commonjs/components/ReferenceList/ReferenceList.js.map +1 -1
- package/lib-commonjs/components/ReferenceList/ReferenceList.types.js +1 -0
- package/lib-commonjs/components/ReferenceList/index.js +1 -0
- package/lib-commonjs/components/ReferenceList/renderReferenceList.js +1 -1
- package/lib-commonjs/components/ReferenceList/renderReferenceList.js.map +1 -1
- package/lib-commonjs/components/ReferenceList/useReferenceList.js +1 -1
- package/lib-commonjs/components/ReferenceList/useReferenceList.js.map +1 -1
- package/lib-commonjs/components/ReferenceList/useReferenceListStyles.styles.raw.js +1 -1
- package/lib-commonjs/components/ReferenceList/useReferenceListStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/reference-v2/Reference/Reference.js +1 -1
- package/lib-commonjs/components/reference-v2/Reference/Reference.js.map +1 -1
- package/lib-commonjs/components/reference-v2/Reference/Reference.types.js +1 -0
- package/lib-commonjs/components/reference-v2/Reference/index.js +1 -0
- package/lib-commonjs/components/reference-v2/Reference/renderReference.js +1 -1
- package/lib-commonjs/components/reference-v2/Reference/renderReference.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/components/reference-v2/Reference/useReferenceStyles.styles.raw.js +1 -1
- package/lib-commonjs/components/reference-v2/Reference/useReferenceStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceList/ReferenceList.js +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceList/ReferenceList.js.map +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceList/ReferenceList.types.js +1 -0
- package/lib-commonjs/components/reference-v2/ReferenceList/index.js +1 -0
- package/lib-commonjs/components/reference-v2/ReferenceList/renderReferenceList.js +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceList/renderReferenceList.js.map +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceList.js +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceList.js.map +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceListContextValues.js +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceListContextValues.js.map +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceListStyles.styles.raw.js +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceListStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.js +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.js.map +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/ReferenceOverflowButton.types.js +1 -0
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/index.js +1 -0
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/renderReferenceOverflowButton.js +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/renderReferenceOverflowButton.js.map +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js.map +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.raw.js +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/reference-v2/index.js +1 -0
- package/lib-commonjs/contexts/ReferenceGroupContext.js +1 -1
- package/lib-commonjs/contexts/ReferenceGroupContext.js.map +1 -1
- package/lib-commonjs/contexts/reference-v2/index.js +1 -0
- package/lib-commonjs/contexts/reference-v2/referenceListContext.js +1 -1
- package/lib-commonjs/contexts/reference-v2/referenceListContext.js.map +1 -1
- package/lib-commonjs/index.js +1 -0
- package/lib-commonjs/utilities/index.js +1 -0
- package/lib-commonjs/utilities/reference-v2/generateReferenceCitationPreview.js +1 -1
- package/lib-commonjs/utilities/reference-v2/generateReferenceCitationPreview.js.map +1 -1
- package/lib-commonjs/utilities/reference-v2/index.js +1 -0
- package/lib-commonjs/utilities/reference-v2/useReferenceCitationPreview.js +1 -1
- package/lib-commonjs/utilities/reference-v2/useReferenceCitationPreview.js.map +1 -1
- package/lib-commonjs/utilities/useReferenceCitationPreview.js +1 -1
- package/lib-commonjs/utilities/useReferenceCitationPreview.js.map +1 -1
- package/lib-commonjs/utilities/useReferenceGroup.js +1 -1
- package/lib-commonjs/utilities/useReferenceGroup.js.map +1 -1
- package/lib-commonjs/utilities/useReferenceGroup.styles.raw.js +1 -1
- package/lib-commonjs/utilities/useReferenceGroup.styles.raw.js.map +1 -1
- package/package.json +6 -6
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { createContext, useContextSelector } from '@fluentui/react-context-selector';
|
|
2
2
|
export const ReferenceListContext = createContext(undefined);
|
|
3
3
|
const referenceListContextDefaultValue = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
areReferencesExpanded: false,
|
|
5
|
+
maxVisibleReferences: undefined,
|
|
6
|
+
overflowButtonTriggeredViaKeyboard: {
|
|
7
|
+
current: false
|
|
8
|
+
},
|
|
9
|
+
referenceListRef: {
|
|
10
|
+
current: null
|
|
11
|
+
},
|
|
12
|
+
shouldUseOverflow: false,
|
|
13
|
+
totalReferencesCount: 0
|
|
14
14
|
};
|
|
15
15
|
export const ReferenceListContextProvider = ReferenceListContext.Provider;
|
|
16
|
-
export const useReferenceListContext_unstable =
|
|
16
|
+
export const useReferenceListContext_unstable = selector => useContextSelector(ReferenceListContext, (ctx = referenceListContextDefaultValue) => selector(ctx));
|
|
17
|
+
//# sourceMappingURL=referenceListContext.js.map
|
package/lib/index.js
CHANGED
|
@@ -8,3 +8,4 @@ export { ReferenceList as ReferenceListV2, referenceListClassNames as referenceL
|
|
|
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
10
|
export { generateReferenceCitationPreview, useReferenceCitationPreview as useReferenceCitationPreviewV2 } from './utilities/reference-v2';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
package/lib/utilities/index.js
CHANGED
|
@@ -5,20 +5,18 @@ import { SensitivityLabel } from '@fluentui-copilot/react-sensitivity-label';
|
|
|
5
5
|
import { Citation } from '../../Citation';
|
|
6
6
|
import { Reference } from '../../ReferenceV2';
|
|
7
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 =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
onClick: onCitationCloseButtonClick
|
|
21
|
-
});
|
|
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
|
+
});
|
|
22
20
|
};
|
|
23
21
|
/**
|
|
24
22
|
* Function to generate a Citation - Reference pair with correctly wired props.
|
|
@@ -31,66 +29,79 @@ const CitationCloseButton = (citationCloseButtonProps)=>{
|
|
|
31
29
|
* `generateReferenceCitationPreview` directly.
|
|
32
30
|
*
|
|
33
31
|
* @returns A Citation - Reference pair with correctly wired props.
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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: "above",
|
|
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": `Close Reference ${index}`,
|
|
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
|
|
61
77
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
};
|
|
91
|
-
const components = {
|
|
92
|
-
Citation: CitationWithPreview,
|
|
93
|
-
Reference: ReferenceWithPreview
|
|
94
|
-
};
|
|
95
|
-
return components;
|
|
78
|
+
var _previewHeaderProps_children, _previewContentProps_content;
|
|
79
|
+
return /*#__PURE__*/React.createElement(Preview, {
|
|
80
|
+
closeOnScroll: true,
|
|
81
|
+
positioning: "above",
|
|
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": `Close Reference ${index}`,
|
|
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;
|
|
96
106
|
};
|
|
107
|
+
//# sourceMappingURL=generateReferenceCitationPreview.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
2
|
import { generateReferenceCitationPreview } from './generateReferenceCitationPreview';
|
|
3
3
|
/**
|
|
4
4
|
* Hook to generate a Citation - Reference pair with correctly wired props.
|
|
@@ -11,8 +11,8 @@ import { generateReferenceCitationPreview } from './generateReferenceCitationPre
|
|
|
11
11
|
* `generateReferenceCitationPreview` directly.
|
|
12
12
|
*
|
|
13
13
|
* @returns A Citation - Reference pair with correctly wired props.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
]);
|
|
14
|
+
*/
|
|
15
|
+
export const useReferenceCitationPreview = props => {
|
|
16
|
+
return React.useMemo(() => generateReferenceCitationPreview(props), [props]);
|
|
18
17
|
};
|
|
18
|
+
//# sourceMappingURL=useReferenceCitationPreview.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { Caption1, assertSlots, mergeCallbacks, slot, useId, usePopoverContext_unstable } from '@fluentui/react-components';
|
|
4
4
|
import { Preview, PreviewContent, PreviewHeader, PreviewMetadata, PreviewSurface, PreviewTrigger } from '@fluentui-copilot/react-preview';
|
|
@@ -6,20 +6,18 @@ import { SensitivityLabel } from '@fluentui-copilot/react-sensitivity-label';
|
|
|
6
6
|
import { Citation } from '../Citation';
|
|
7
7
|
import { Reference } from '../Reference';
|
|
8
8
|
// Abstract the citation that serves as the close button of the Preview into its own component so that we have access to the popover context.
|
|
9
|
-
const CitationCloseButton =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
onClick: onCitationCloseButtonClick
|
|
22
|
-
});
|
|
9
|
+
const CitationCloseButton = citationCloseButtonProps => {
|
|
10
|
+
const setPopoverOpen = usePopoverContext_unstable(context => context.setOpen);
|
|
11
|
+
const onPopoverCloseClick = React.useCallback(ev => {
|
|
12
|
+
setPopoverOpen(ev, false);
|
|
13
|
+
// Don't navigate
|
|
14
|
+
ev.preventDefault();
|
|
15
|
+
}, [setPopoverOpen]);
|
|
16
|
+
const onCitationCloseButtonClick = mergeCallbacks(onPopoverCloseClick, citationCloseButtonProps.onClick);
|
|
17
|
+
return /*#__PURE__*/_jsx(Citation, {
|
|
18
|
+
...citationCloseButtonProps,
|
|
19
|
+
onClick: onCitationCloseButtonClick
|
|
20
|
+
});
|
|
23
21
|
};
|
|
24
22
|
/**
|
|
25
23
|
* Hook to package a `Citation` and `Reference` together in an
|
|
@@ -27,112 +25,105 @@ const CitationCloseButton = (citationCloseButtonProps)=>{
|
|
|
27
25
|
*
|
|
28
26
|
* When using citations and references, prefer using them via this
|
|
29
27
|
* hook to ensure props are wired up correctly.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
referenceProps,
|
|
131
|
-
citationProps,
|
|
132
|
-
previewHeaderProps,
|
|
133
|
-
previewProps,
|
|
134
|
-
previewSurfaceProps,
|
|
135
|
-
sensitivityLabelProps
|
|
136
|
-
]);
|
|
137
|
-
return components;
|
|
28
|
+
*/
|
|
29
|
+
export const useReferenceCitationPreview = ({
|
|
30
|
+
index,
|
|
31
|
+
referenceId: propsRefId,
|
|
32
|
+
citationId: propsCiteId,
|
|
33
|
+
citationProps,
|
|
34
|
+
referenceProps,
|
|
35
|
+
previewHeaderProps,
|
|
36
|
+
previewProps,
|
|
37
|
+
previewSurfaceProps,
|
|
38
|
+
sensitivityLabelProps
|
|
39
|
+
}) => {
|
|
40
|
+
const refId = useId();
|
|
41
|
+
const citeId = useId();
|
|
42
|
+
const referenceId = propsRefId !== null && propsRefId !== void 0 ? propsRefId : refId;
|
|
43
|
+
const citationId = propsCiteId !== null && propsCiteId !== void 0 ? propsCiteId : citeId;
|
|
44
|
+
const components = React.useMemo(() => {
|
|
45
|
+
const citationHref = `#${citationId}`;
|
|
46
|
+
const PackagedReference = props => {
|
|
47
|
+
var _props_index, _ref;
|
|
48
|
+
const referenceIndex = (_ref = (_props_index = props.index) !== null && _props_index !== void 0 ? _props_index : referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.index) !== null && _ref !== void 0 ? _ref : index;
|
|
49
|
+
return /*#__PURE__*/_jsx(Reference, {
|
|
50
|
+
...referenceProps,
|
|
51
|
+
index: referenceIndex,
|
|
52
|
+
referenceId: referenceId,
|
|
53
|
+
citationHref: citationHref,
|
|
54
|
+
...props
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
const CitationWithPreview = props => {
|
|
58
|
+
// We assert content as a slot to use it with its resolved props object and the correct defaults below.
|
|
59
|
+
const content = slot.always(referenceProps ? referenceProps.content : undefined, {
|
|
60
|
+
defaultProps: {
|
|
61
|
+
children: (referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.excerpt) && /*#__PURE__*/_jsx(Caption1, {
|
|
62
|
+
children: referenceProps.excerpt
|
|
63
|
+
})
|
|
64
|
+
},
|
|
65
|
+
elementType: 'div'
|
|
66
|
+
});
|
|
67
|
+
const citationWithPreviewState = {
|
|
68
|
+
components: {
|
|
69
|
+
content: 'div'
|
|
70
|
+
},
|
|
71
|
+
content
|
|
72
|
+
};
|
|
73
|
+
assertSlots(citationWithPreviewState);
|
|
74
|
+
// We resolve the slots' objects for sensitivity and title here so that we can use the information from their children below.
|
|
75
|
+
const sensitivity = slot.optional(referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.sensitivity, {
|
|
76
|
+
elementType: 'span'
|
|
77
|
+
});
|
|
78
|
+
const title = slot.optional(referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.label, {
|
|
79
|
+
elementType: 'div'
|
|
80
|
+
});
|
|
81
|
+
var _previewHeaderProps_children, _sensitivityLabelProps_description, _previewSurfaceProps_children;
|
|
82
|
+
return /*#__PURE__*/_jsxs(Preview, {
|
|
83
|
+
closeOnScroll: true,
|
|
84
|
+
positioning: "above",
|
|
85
|
+
size: "small",
|
|
86
|
+
trapFocus: true,
|
|
87
|
+
withArrow: true,
|
|
88
|
+
...previewProps,
|
|
89
|
+
children: [/*#__PURE__*/_jsx(PreviewTrigger, {
|
|
90
|
+
children: /*#__PURE__*/_jsx(Citation, {
|
|
91
|
+
...citationProps,
|
|
92
|
+
id: citationId,
|
|
93
|
+
...props,
|
|
94
|
+
children: index
|
|
95
|
+
})
|
|
96
|
+
}), /*#__PURE__*/_jsx(PreviewSurface, {
|
|
97
|
+
...previewSurfaceProps,
|
|
98
|
+
children: /*#__PURE__*/_jsxs(PreviewContent, {
|
|
99
|
+
children: [/*#__PURE__*/_jsx(PreviewHeader, {
|
|
100
|
+
citation: /*#__PURE__*/_jsx(CitationCloseButton, {
|
|
101
|
+
"aria-label": `Close Reference ${index}`,
|
|
102
|
+
referenceHref: "#",
|
|
103
|
+
tabIndex: -1,
|
|
104
|
+
children: index
|
|
105
|
+
}),
|
|
106
|
+
media: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.media,
|
|
107
|
+
...previewHeaderProps,
|
|
108
|
+
children: (_previewHeaderProps_children = previewHeaderProps === null || previewHeaderProps === void 0 ? void 0 : previewHeaderProps.children) !== null && _previewHeaderProps_children !== void 0 ? _previewHeaderProps_children : title === null || title === void 0 ? void 0 : title.children
|
|
109
|
+
}), /*#__PURE__*/_jsx(PreviewMetadata, {
|
|
110
|
+
icon: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.icon,
|
|
111
|
+
primaryText: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.primaryText,
|
|
112
|
+
secondaryText: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.secondaryText,
|
|
113
|
+
tertiaryText: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.tertiaryText
|
|
114
|
+
}), sensitivity && /*#__PURE__*/_jsx(SensitivityLabel, {
|
|
115
|
+
description: (_sensitivityLabelProps_description = sensitivityLabelProps === null || sensitivityLabelProps === void 0 ? void 0 : sensitivityLabelProps.description) !== null && _sensitivityLabelProps_description !== void 0 ? _sensitivityLabelProps_description : '',
|
|
116
|
+
children: sensitivity.children
|
|
117
|
+
}), /*#__PURE__*/_jsx(citationWithPreviewState.content, {}), (_previewSurfaceProps_children = previewSurfaceProps === null || previewSurfaceProps === void 0 ? void 0 : previewSurfaceProps.children) !== null && _previewSurfaceProps_children !== void 0 ? _previewSurfaceProps_children : previewProps === null || previewProps === void 0 ? void 0 : previewProps.children]
|
|
118
|
+
})
|
|
119
|
+
})]
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
Citation: CitationWithPreview,
|
|
124
|
+
Reference: PackagedReference
|
|
125
|
+
};
|
|
126
|
+
}, [index, referenceId, citationId, referenceProps, citationProps, previewHeaderProps, previewProps, previewSurfaceProps, sensitivityLabelProps]);
|
|
127
|
+
return components;
|
|
138
128
|
};
|
|
129
|
+
//# sourceMappingURL=useReferenceCitationPreview.js.map
|
|
@@ -7,30 +7,28 @@ import { useStyles } from './useReferenceGroup.styles';
|
|
|
7
7
|
*
|
|
8
8
|
* When rendering a group of references, prefer to use this hook
|
|
9
9
|
* hook to ensure state is maintained correctly
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
referenceListId,
|
|
34
|
-
styles.hidden
|
|
35
|
-
]);
|
|
10
|
+
*/
|
|
11
|
+
export const useReferenceGroup = props => {
|
|
12
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
13
|
+
const styles = useStyles();
|
|
14
|
+
const referenceListId = useId('reference-list', props.referenceListId);
|
|
15
|
+
return React.useMemo(() => {
|
|
16
|
+
const handleClick = () => {
|
|
17
|
+
setIsOpen(isOpen => !isOpen);
|
|
18
|
+
};
|
|
19
|
+
const referenceGroupToggleProps = {
|
|
20
|
+
'aria-controls': referenceListId,
|
|
21
|
+
isOpen,
|
|
22
|
+
onClick: handleClick
|
|
23
|
+
};
|
|
24
|
+
const referenceListProps = {
|
|
25
|
+
className: isOpen ? undefined : styles.hidden,
|
|
26
|
+
id: referenceListId
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
referenceGroupToggleProps,
|
|
30
|
+
referenceListProps
|
|
31
|
+
};
|
|
32
|
+
}, [isOpen, referenceListId, styles.hidden]);
|
|
36
33
|
};
|
|
34
|
+
//# sourceMappingURL=useReferenceGroup.js.map
|
package/lib-commonjs/Citation.js
CHANGED
|
@@ -20,4 +20,4 @@ const Citation = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
|
|
|
20
20
|
(0, _reactprovider.useCustomStyleHook)('useCitationStyles')(state);
|
|
21
21
|
return (0, _renderCitation.renderCitation_unstable)(state);
|
|
22
22
|
});
|
|
23
|
-
Citation.displayName = 'Citation';
|
|
23
|
+
Citation.displayName = 'Citation'; //# sourceMappingURL=Citation.js.map
|