@fluentui-copilot/react-reference 0.0.0-nightly-20250708-1433-52f2b6b1.1 → 0.0.0-nightly-20250709-0404-150e065c.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 +3 -3
- package/CHANGELOG.md +4 -4
- package/lib/Citation.js +1 -0
- package/lib/Reference.js +1 -0
- package/lib/ReferenceList.js +1 -0
- package/lib/ReferenceOverflowButton.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/Reference/Reference.js +5 -4
- package/lib/components/Reference/Reference.types.js +2 -1
- package/lib/components/Reference/index.js +1 -0
- package/lib/components/Reference/renderReference.js +17 -20
- package/lib/components/Reference/useReference.js +59 -53
- package/lib/components/ReferenceList/ReferenceList.js +6 -5
- package/lib/components/ReferenceList/ReferenceList.types.js +2 -1
- package/lib/components/ReferenceList/index.js +1 -0
- package/lib/components/ReferenceList/renderReferenceList.js +17 -17
- package/lib/components/ReferenceList/useReferenceList.js +80 -70
- package/lib/components/ReferenceList/useReferenceListContextValues.js +21 -13
- package/lib/components/ReferenceOverflowButton/ReferenceOverflowButton.js +5 -4
- package/lib/components/ReferenceOverflowButton/ReferenceOverflowButton.types.js +2 -1
- package/lib/components/ReferenceOverflowButton/index.js +1 -0
- package/lib/components/ReferenceOverflowButton/renderReferenceOverflowButton.js +14 -9
- package/lib/components/ReferenceOverflowButton/useReferenceOverflowButton.js +77 -77
- package/lib/contexts/index.js +1 -0
- package/lib/contexts/referenceListContext.js +12 -11
- package/lib/index.js +25 -12
- package/lib/utilities/generateReferenceCitationPreview.js +86 -75
- package/lib/utilities/index.js +1 -0
- package/lib/utilities/useReferenceCitationPreview.js +5 -5
- package/lib-commonjs/Citation.js +1 -0
- package/lib-commonjs/Reference.js +1 -0
- package/lib-commonjs/ReferenceList.js +1 -0
- package/lib-commonjs/ReferenceOverflowButton.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/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/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/useReferenceListContextValues.js +1 -1
- package/lib-commonjs/components/ReferenceList/useReferenceListContextValues.js.map +1 -1
- package/lib-commonjs/components/ReferenceOverflowButton/ReferenceOverflowButton.js +1 -1
- package/lib-commonjs/components/ReferenceOverflowButton/ReferenceOverflowButton.js.map +1 -1
- package/lib-commonjs/components/ReferenceOverflowButton/ReferenceOverflowButton.types.js +1 -0
- package/lib-commonjs/components/ReferenceOverflowButton/index.js +1 -0
- package/lib-commonjs/components/ReferenceOverflowButton/renderReferenceOverflowButton.js +1 -1
- package/lib-commonjs/components/ReferenceOverflowButton/renderReferenceOverflowButton.js.map +1 -1
- package/lib-commonjs/components/ReferenceOverflowButton/useReferenceOverflowButton.js +1 -1
- package/lib-commonjs/components/ReferenceOverflowButton/useReferenceOverflowButton.js.map +1 -1
- package/lib-commonjs/contexts/index.js +1 -0
- package/lib-commonjs/contexts/referenceListContext.js +1 -1
- package/lib-commonjs/contexts/referenceListContext.js.map +1 -1
- package/lib-commonjs/index.js +1 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utilities/generateReferenceCitationPreview.js +1 -1
- package/lib-commonjs/utilities/generateReferenceCitationPreview.js.map +1 -1
- package/lib-commonjs/utilities/index.js +1 -0
- package/lib-commonjs/utilities/useReferenceCitationPreview.js +1 -1
- package/lib-commonjs/utilities/useReferenceCitationPreview.js.map +1 -1
- package/package.json +6 -6
- package/lib/components/Citation/useCitationStyles.styles.raw.js +0 -69
- package/lib/components/Citation/useCitationStyles.styles.raw.js.map +0 -1
- package/lib/components/Reference/useReferenceStyles.styles.raw.js +0 -110
- package/lib/components/Reference/useReferenceStyles.styles.raw.js.map +0 -1
- package/lib/components/ReferenceList/useReferenceListStyles.styles.raw.js +0 -47
- package/lib/components/ReferenceList/useReferenceListStyles.styles.raw.js.map +0 -1
- package/lib/components/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.raw.js +0 -45
- package/lib/components/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.raw.js.map +0 -1
- package/lib-commonjs/components/Citation/useCitationStyles.styles.raw.js +0 -85
- package/lib-commonjs/components/Citation/useCitationStyles.styles.raw.js.map +0 -1
- package/lib-commonjs/components/Reference/useReferenceStyles.styles.raw.js +0 -132
- package/lib-commonjs/components/Reference/useReferenceStyles.styles.raw.js.map +0 -1
- package/lib-commonjs/components/ReferenceList/useReferenceListStyles.styles.raw.js +0 -63
- package/lib-commonjs/components/ReferenceList/useReferenceListStyles.styles.raw.js.map +0 -1
- package/lib-commonjs/components/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.raw.js +0 -61
- package/lib-commonjs/components/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.raw.js.map +0 -1
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx as _jsx } from "@fluentui/react-jsx-runtime/jsx-runtime";
|
|
2
2
|
import { OverflowItem, assertSlots } from '@fluentui/react-components';
|
|
3
3
|
/**
|
|
4
4
|
* Render the final JSX of ReferenceOverflowButton
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
*/
|
|
6
|
+
export const renderReferenceOverflowButton_unstable = state => {
|
|
7
|
+
assertSlots(state);
|
|
8
|
+
const {
|
|
9
|
+
id,
|
|
10
|
+
shouldRenderOverflowButton
|
|
11
|
+
} = state;
|
|
12
|
+
return shouldRenderOverflowButton ? /*#__PURE__*/_jsx(OverflowItem, {
|
|
13
|
+
id: id,
|
|
14
|
+
priority: 1,
|
|
15
|
+
children: /*#__PURE__*/_jsx(state.root, {})
|
|
16
|
+
}, id) : null;
|
|
13
17
|
};
|
|
18
|
+
//# sourceMappingURL=renderReferenceOverflowButton.js.map
|
|
@@ -12,82 +12,82 @@ import { useDesignVersion } from '@fluentui-copilot/react-provider';
|
|
|
12
12
|
*
|
|
13
13
|
* @param props - props from this instance of ReferenceOverflowButton
|
|
14
14
|
* @param ref - reference to root HTMLElement of ReferenceOverflowButton
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
15
|
+
*/
|
|
16
|
+
export const useReferenceOverflowButton_unstable = (props, ref) => {
|
|
17
|
+
'use no memo';
|
|
18
|
+
|
|
19
|
+
const {
|
|
20
|
+
children,
|
|
21
|
+
id,
|
|
22
|
+
text
|
|
23
|
+
} = props;
|
|
24
|
+
const designVersion = useDesignVersion(props.designVersion);
|
|
25
|
+
const rootRef = React.useRef(null);
|
|
26
|
+
const [setTimeout] = useTimeout();
|
|
27
|
+
const referenceOverflowButtonId = useId('reference-overflow-button-', id);
|
|
28
|
+
const areReferencesExpanded = useReferenceListContext_unstable(ctx => ctx.areReferencesExpanded);
|
|
29
|
+
const maxVisibleReferences = useReferenceListContext_unstable(ctx => ctx.maxVisibleReferences);
|
|
30
|
+
const referenceListRef = useReferenceListContext_unstable(ctx => ctx.referenceListRef);
|
|
31
|
+
const totalReferencesCount = useReferenceListContext_unstable(ctx => ctx.totalReferencesCount);
|
|
32
|
+
const triggeredViaKeyboard = useReferenceListContext_unstable(ctx => ctx.overflowButtonTriggeredViaKeyboard);
|
|
33
|
+
const {
|
|
34
|
+
isOverflowing,
|
|
35
|
+
overflowCount
|
|
36
|
+
} = useOverflowMenu();
|
|
37
|
+
const processedText = children !== null && children !== void 0 ? children : typeof text === 'function' ? text(overflowCount) : text;
|
|
38
|
+
const {
|
|
39
|
+
findFirstFocusable,
|
|
40
|
+
findNextFocusable
|
|
41
|
+
} = useFocusFinders();
|
|
42
|
+
const onKeyDown = React.useCallback(ev => {
|
|
43
|
+
if (ev.key === Enter || ev.key === Space) {
|
|
44
|
+
triggeredViaKeyboard.current = true;
|
|
45
|
+
}
|
|
46
|
+
}, [triggeredViaKeyboard]);
|
|
47
|
+
// We keep track of the previous overflow count to help determine the element to move focus to when expanding the references via keyboard.
|
|
48
|
+
const previousOverflow = React.useRef(0);
|
|
49
|
+
// When the references are expanded or collapsed via keyboard, we need to move focus to the appropriate element.
|
|
50
|
+
React.useEffect(() => {
|
|
51
|
+
// We only try to move focus if maxVisibleReferences is set and the overflow button was triggered via keyboard.
|
|
52
|
+
if (maxVisibleReferences !== undefined && triggeredViaKeyboard.current) {
|
|
53
|
+
let elementToFocus;
|
|
54
|
+
// If the references are collapsed, we move focus to the overflow button.
|
|
55
|
+
if (!areReferencesExpanded) {
|
|
56
|
+
elementToFocus = rootRef.current;
|
|
57
|
+
previousOverflow.current = overflowCount;
|
|
58
|
+
} else if (rootRef.current && referenceListRef.current) {
|
|
59
|
+
const positionToFocus = maxVisibleReferences < totalReferencesCount - previousOverflow.current ? maxVisibleReferences : totalReferencesCount - previousOverflow.current;
|
|
60
|
+
let currentElement = findFirstFocusable(referenceListRef.current);
|
|
61
|
+
for (let i = 0; i < positionToFocus && currentElement; i++) {
|
|
62
|
+
currentElement = findNextFocusable(currentElement);
|
|
33
63
|
}
|
|
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
|
-
areReferencesExpanded,
|
|
64
|
-
findFirstFocusable,
|
|
65
|
-
findNextFocusable,
|
|
66
|
-
isOverflowing,
|
|
67
|
-
maxVisibleReferences,
|
|
68
|
-
overflowCount,
|
|
69
|
-
referenceListRef,
|
|
70
|
-
setTimeout,
|
|
71
|
-
totalReferencesCount,
|
|
72
|
-
triggeredViaKeyboard
|
|
73
|
-
]);
|
|
74
|
-
const state = {
|
|
75
|
-
designVersion,
|
|
76
|
-
id: referenceOverflowButtonId,
|
|
77
|
-
shouldRenderOverflowButton: isOverflowing || areReferencesExpanded,
|
|
78
|
-
components: {
|
|
79
|
-
root: 'button'
|
|
80
|
-
},
|
|
81
|
-
root: slot.always(getIntrinsicElementProps('button', {
|
|
82
|
-
ref: useMergedRefs(rootRef, ref),
|
|
83
|
-
...props
|
|
84
|
-
}), {
|
|
85
|
-
defaultProps: {
|
|
86
|
-
children: processedText
|
|
87
|
-
},
|
|
88
|
-
elementType: 'button'
|
|
89
|
-
})
|
|
90
|
-
};
|
|
91
|
-
state.root.onKeyDown = mergeCallbacks(onKeyDown, props.onKeyDown);
|
|
92
|
-
return state;
|
|
64
|
+
elementToFocus = currentElement;
|
|
65
|
+
}
|
|
66
|
+
// We focus on the element and reset the triggeredViaKeyboard flag after a timeout to ensure that this is pushed at the end of the event queue.
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
elementToFocus === null || elementToFocus === void 0 ? void 0 : elementToFocus.focus();
|
|
69
|
+
triggeredViaKeyboard.current = false;
|
|
70
|
+
}, 0);
|
|
71
|
+
}
|
|
72
|
+
}, [areReferencesExpanded, findFirstFocusable, findNextFocusable, isOverflowing, maxVisibleReferences, overflowCount, referenceListRef, setTimeout, totalReferencesCount, triggeredViaKeyboard]);
|
|
73
|
+
const state = {
|
|
74
|
+
designVersion,
|
|
75
|
+
id: referenceOverflowButtonId,
|
|
76
|
+
shouldRenderOverflowButton: isOverflowing || areReferencesExpanded,
|
|
77
|
+
components: {
|
|
78
|
+
root: 'button'
|
|
79
|
+
},
|
|
80
|
+
root: slot.always(getIntrinsicElementProps('button', {
|
|
81
|
+
ref: useMergedRefs(rootRef, ref),
|
|
82
|
+
...props
|
|
83
|
+
}), {
|
|
84
|
+
defaultProps: {
|
|
85
|
+
children: processedText
|
|
86
|
+
},
|
|
87
|
+
elementType: 'button'
|
|
88
|
+
})
|
|
89
|
+
};
|
|
90
|
+
state.root.onKeyDown = mergeCallbacks(onKeyDown, props.onKeyDown);
|
|
91
|
+
return state;
|
|
93
92
|
};
|
|
93
|
+
//# sourceMappingURL=useReferenceOverflowButton.js.map
|
package/lib/contexts/index.js
CHANGED
|
@@ -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
|
@@ -2,20 +2,33 @@ import { Reference, referenceClassNames, referenceExtraClassNames, renderReferen
|
|
|
2
2
|
import { ReferenceList, referenceListClassNames, renderReferenceList_unstable, useReferenceListStyles_unstable, useReferenceList_unstable } from './ReferenceList';
|
|
3
3
|
import { generateReferenceCitationPreview, useReferenceCitationPreview } from './utilities';
|
|
4
4
|
export { Citation, citationClassNames, renderCitation_unstable, useCitation_unstable, useCitationStyles_unstable } from './Citation';
|
|
5
|
-
/** @deprecated use Reference */
|
|
6
|
-
|
|
7
|
-
/** @deprecated use
|
|
8
|
-
|
|
9
|
-
/** @deprecated use
|
|
10
|
-
|
|
5
|
+
/** @deprecated use Reference */
|
|
6
|
+
const ReferenceV2 = Reference;
|
|
7
|
+
/** @deprecated use referenceClassNames */
|
|
8
|
+
const referenceV2ClassNames = referenceClassNames;
|
|
9
|
+
/** @deprecated use referenceExtraClassNames */
|
|
10
|
+
const referenceV2ExtraClassNames = referenceExtraClassNames;
|
|
11
|
+
/** @deprecated use renderReference_unstable */
|
|
12
|
+
const renderReferenceV2_unstable = renderReference_unstable;
|
|
13
|
+
/** @deprecated use useReferenceStyles_unstable */
|
|
14
|
+
const useReferenceV2Styles_unstable = useReferenceStyles_unstable;
|
|
15
|
+
/** @deprecated use useReference_unstable */
|
|
16
|
+
const useReferenceV2_unstable = useReference_unstable;
|
|
11
17
|
export { Reference, ReferenceV2, referenceClassNames, referenceV2ClassNames, referenceExtraClassNames, referenceV2ExtraClassNames, renderReference_unstable, renderReferenceV2_unstable, useReferenceStyles_unstable, useReferenceV2Styles_unstable, useReference_unstable, useReferenceV2_unstable };
|
|
12
|
-
/** @deprecated use ReferenceList */
|
|
13
|
-
|
|
14
|
-
/** @deprecated use
|
|
15
|
-
|
|
16
|
-
/** @deprecated use
|
|
18
|
+
/** @deprecated use ReferenceList */
|
|
19
|
+
const ReferenceListV2 = ReferenceList;
|
|
20
|
+
/** @deprecated use referenceListClassNames */
|
|
21
|
+
const referenceListV2ClassNames = referenceListClassNames;
|
|
22
|
+
/** @deprecated use renderReferenceList_unstable */
|
|
23
|
+
const renderReferenceListV2_unstable = renderReferenceList_unstable;
|
|
24
|
+
/** @deprecated use useReferenceListStyles_unstable */
|
|
25
|
+
const useReferenceListV2Styles_unstable = useReferenceListStyles_unstable;
|
|
26
|
+
/** @deprecated use useReferenceList_unstable */
|
|
27
|
+
const useReferenceListV2_unstable = useReferenceList_unstable;
|
|
17
28
|
export { ReferenceList, ReferenceListV2, referenceListClassNames, referenceListV2ClassNames, renderReferenceList_unstable, renderReferenceListV2_unstable, useReferenceListStyles_unstable, useReferenceListV2Styles_unstable, useReferenceList_unstable, useReferenceListV2_unstable };
|
|
18
29
|
export { ReferenceOverflowButton, referenceOverflowButtonClassNames, renderReferenceOverflowButton_unstable, useReferenceOverflowButtonStyles_unstable, useReferenceOverflowButton_unstable } from './ReferenceOverflowButton';
|
|
19
30
|
export { ReferenceListContext, ReferenceListContextProvider, useReferenceListContext_unstable } from './contexts';
|
|
20
|
-
/** @deprecated use useReferenceCitationPreview */
|
|
31
|
+
/** @deprecated use useReferenceCitationPreview */
|
|
32
|
+
const useReferenceCitationPreviewV2 = useReferenceCitationPreview;
|
|
21
33
|
export { generateReferenceCitationPreview, useReferenceCitationPreview, useReferenceCitationPreviewV2 };
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -5,20 +5,18 @@ import { SensitivityLabel } from '@fluentui-copilot/react-sensitivity-label';
|
|
|
5
5
|
import { Citation } from '../Citation';
|
|
6
6
|
import { Reference } from '../Reference';
|
|
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
|
package/lib/utilities/index.js
CHANGED
|
@@ -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
|
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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Citation.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useCitation_unstable } from './useCitation';\nimport { renderCitation_unstable } from './renderCitation';\nimport { useCitationStyles_unstable } from './useCitationStyles.styles';\nimport type { CitationProps } from './Citation.types';\nimport type { ForwardRefComponent } from '@fluentui/react-components';\nimport { useCustomStyleHook } from '@fluentui-copilot/react-provider';\n\n// Citation component - TODO: add more docs\nexport const Citation: ForwardRefComponent<CitationProps> = React.forwardRef((props, ref) => {\n const state = useCitation_unstable(props, ref);\n\n useCitationStyles_unstable(state);\n useCustomStyleHook('useCitationStyles')(state);\n\n return renderCitation_unstable(state);\n});\n\nCitation.displayName = 'Citation';\n"],"names":["Citation","React","forwardRef","props","
|
|
1
|
+
{"version":3,"sources":["Citation.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useCitation_unstable } from './useCitation';\nimport { renderCitation_unstable } from './renderCitation';\nimport { useCitationStyles_unstable } from './useCitationStyles.styles';\nimport type { CitationProps } from './Citation.types';\nimport type { ForwardRefComponent } from '@fluentui/react-components';\nimport { useCustomStyleHook } from '@fluentui-copilot/react-provider';\n\n// Citation component - TODO: add more docs\nexport const Citation: ForwardRefComponent<CitationProps> = React.forwardRef((props, ref) => {\n const state = useCitation_unstable(props, ref);\n\n useCitationStyles_unstable(state);\n useCustomStyleHook('useCitationStyles')(state);\n\n return renderCitation_unstable(state);\n});\n\nCitation.displayName = 'Citation';\n"],"names":["Citation","React","forwardRef","props","state","useCitation_unstable","useCitationStyles_unstable","useCustomStyleHook","renderCitation_unstable","displayName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BASaA;;;eAAAA;;;;iEATU;6BACc;gCACG;yCACG;+BAGR;AAG5B,MAAMA,WAAAA,WAAAA,GAAAA,OAA+CC,UAAMC,CAAU,CAACC,OAACA;UAC5EC,QAAMA,IAAAA,iCAAQC,EAAAA,OAAqBF;2DAEnCG,EAAAA;yCACAC,EAAAA,qBAAmBH;WAEnBI,IAAAA,uCAAOA,EAAAA;AACT;AAEAR,SAASS,WAAW,GAAG"}
|
|
@@ -13,4 +13,4 @@ const _reactcomponents = require("@fluentui/react-components");
|
|
|
13
13
|
const renderCitation_unstable = (state)=>{
|
|
14
14
|
(0, _reactcomponents.assertSlots)(state);
|
|
15
15
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(state.root, {});
|
|
16
|
-
};
|
|
16
|
+
}; //# sourceMappingURL=renderCitation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["renderCitation.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-components';\nimport type { CitationState, CitationSlots } from './Citation.types';\n/**\n * Render the final JSX of Citation\n */\nexport const renderCitation_unstable = (state: CitationState) => {\n assertSlots<CitationSlots>(state);\n\n return <state.root />;\n};\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["renderCitation.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-components';\nimport type { CitationState, CitationSlots } from './Citation.types';\n/**\n * Render the final JSX of Citation\n */\nexport const renderCitation_unstable = (state: CitationState) => {\n assertSlots<CitationSlots>(state);\n\n return <state.root />;\n};\n"],"names":["assertSlots","state","_jsx","root"],"rangeMappings":";;;;;;;;;;;;;;","mappings":";;;;+BASEA;;;eAAAA;;;4BATwB;iCAGE;AAM1BA,MAAAA,0BAA2BC,CAAAA;oCAE3B,EAAAA;IACA,OAAA,WAAA,GAAAC,IAAAA,eAAA,EAAAD,MAAAE,IAAA,EAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useCitation.ts"],"sourcesContent":["import { getIntrinsicElementProps, slot } from '@fluentui/react-components';\nimport { usePreviewContext_unstable } from '@fluentui-copilot/react-preview';\nimport type { CitationProps, CitationState } from './Citation.types';\nimport { useDesignVersion } from '@fluentui-copilot/react-provider';\n/**\n * Create the state required to render Citation.\n *\n * The returned state can be modified with hooks such as useCitationStyles_unstable,\n * before being passed to renderCitation_unstable.\n *\n * @param props - props from this instance of Citation\n * @param ref - reference to root HTMLElement of Citation\n */\nexport const useCitation_unstable = (props: CitationProps, ref: React.Ref<HTMLAnchorElement>): CitationState => {\n const { referenceHref, block = false, ...otherProps } = props;\n const designVersion = useDesignVersion(props.designVersion);\n\n const isPopoverLocked = usePreviewContext_unstable(ctx => ctx.isPreviewLocked) && (props['aria-expanded'] as boolean);\n\n const state: CitationState = {\n block,\n designVersion,\n isPopoverLocked,\n components: {\n root: 'a',\n },\n root: slot.always(\n getIntrinsicElementProps('a', {\n ref,\n href: referenceHref,\n role: undefined,\n 'aria-expanded': undefined,\n ...otherProps,\n }),\n { elementType: 'a' },\n ),\n };\n\n return state;\n};\n"],"names":["
|
|
1
|
+
{"version":3,"sources":["useCitation.ts"],"sourcesContent":["import { getIntrinsicElementProps, slot } from '@fluentui/react-components';\nimport { usePreviewContext_unstable } from '@fluentui-copilot/react-preview';\nimport type { CitationProps, CitationState } from './Citation.types';\nimport { useDesignVersion } from '@fluentui-copilot/react-provider';\n/**\n * Create the state required to render Citation.\n *\n * The returned state can be modified with hooks such as useCitationStyles_unstable,\n * before being passed to renderCitation_unstable.\n *\n * @param props - props from this instance of Citation\n * @param ref - reference to root HTMLElement of Citation\n */\nexport const useCitation_unstable = (props: CitationProps, ref: React.Ref<HTMLAnchorElement>): CitationState => {\n const { referenceHref, block = false, ...otherProps } = props;\n const designVersion = useDesignVersion(props.designVersion);\n\n const isPopoverLocked = usePreviewContext_unstable(ctx => ctx.isPreviewLocked) && (props['aria-expanded'] as boolean);\n\n const state: CitationState = {\n block,\n designVersion,\n isPopoverLocked,\n components: {\n root: 'a',\n },\n root: slot.always(\n getIntrinsicElementProps('a', {\n ref,\n href: referenceHref,\n role: undefined,\n 'aria-expanded': undefined,\n ...otherProps,\n }),\n { elementType: 'a' },\n ),\n };\n\n return state;\n};\n"],"names":["referenceHref","props","ref","isPopoverLocked","block","state","components","usePreviewContext_unstable","ctx","isPreviewLocked","root","href","role","otherProps","elementType","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAcUA;;;eAAAA;;;iCAdqC;8BACJ;+BAEV;AAW/B,MAAQA,uBAAuB,CAAAC,OAAOC;UACtC,EAEAF,aAAMG,EAENC,QAAMC,KAAAA;UAGJF,gBAAAA,IAAAA,+BAAAA,EAAAA,MAAAA,aAAAA;UACAG,kBAAYC,IAAAA,wCAAA,EAAAC,CAAAA,MAAAA,IAAAC,eAAA,KAAAR,KAAA,CAAA,gBAAA;kBACVS;;;;oBAKEC;kBACAC;;mCAEA,CAAGC,MAAAA,CAAAA,IAAAA,yCAAU,EAAA,KAAA;;kBAEbC;kBAAiBC;YAEvB,iBAAAA;YAEA,GAAAF,UAAOR;QACP,IAAA"}
|
|
@@ -18,4 +18,4 @@ const Reference = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
|
|
|
18
18
|
(0, _useReferenceStylesstyles.useReferenceStyles_unstable)(state);
|
|
19
19
|
return (0, _renderReference.renderReference_unstable)(state);
|
|
20
20
|
});
|
|
21
|
-
Reference.displayName = 'Reference';
|
|
21
|
+
Reference.displayName = 'Reference'; //# sourceMappingURL=Reference.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Reference.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useReference_unstable } from './useReference';\nimport { renderReference_unstable } from './renderReference';\nimport { useReferenceStyles_unstable } from './useReferenceStyles.styles';\nimport type { ReferenceProps } from './Reference.types';\nimport type { ForwardRefComponent } from '@fluentui/react-components';\n\nexport const Reference: ForwardRefComponent<ReferenceProps> = React.forwardRef((props, ref) => {\n const state = useReference_unstable(props, ref);\n\n useReferenceStyles_unstable(state);\n return renderReference_unstable(state);\n});\n\nReference.displayName = 'Reference';\n"],"names":["Reference","React","forwardRef","props","
|
|
1
|
+
{"version":3,"sources":["Reference.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useReference_unstable } from './useReference';\nimport { renderReference_unstable } from './renderReference';\nimport { useReferenceStyles_unstable } from './useReferenceStyles.styles';\nimport type { ReferenceProps } from './Reference.types';\nimport type { ForwardRefComponent } from '@fluentui/react-components';\n\nexport const Reference: ForwardRefComponent<ReferenceProps> = React.forwardRef((props, ref) => {\n const state = useReference_unstable(props, ref);\n\n useReferenceStyles_unstable(state);\n return renderReference_unstable(state);\n});\n\nReference.displayName = 'Reference';\n"],"names":["Reference","React","forwardRef","props","state","useReference_unstable","useReferenceStyles_unstable","renderReference_unstable","displayName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAOaA;;;eAAAA;;;;iEAPU;8BACe;iCACG;0CACG;AAIrC,MAAMA,YAAAA,WAAAA,GAAAA,OAAiDC,UAAMC,CAAU,CAACC,OAACA;UAC9EC,QAAMA,IAAAA,mCAAQC,EAAAA,OAAsBF;6DAEpCG,EAAAA;WACAC,IAAAA,yCAAOA,EAAAA;AACT;AAEAP,UAAUQ,WAAW,GAAG"}
|