@fluentui-copilot/react-reference 0.12.0 → 0.12.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 +63 -1
- package/CHANGELOG.md +22 -2
- 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/components/reference-v2/Reference/useReferenceStyles.styles.js +5 -4
- package/lib/components/reference-v2/Reference/useReferenceStyles.styles.js.map +1 -1
- package/lib/components/reference-v2/ReferenceList/useReferenceList.js +11 -24
- package/lib/components/reference-v2/ReferenceList/useReferenceList.js.map +1 -1
- package/lib/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js +5 -13
- package/lib/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js.map +1 -1
- package/lib/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.js +1 -1
- package/lib/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.js.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/utilities/reference-v2/generateReferenceCitationPreview.js +107 -0
- package/lib/utilities/reference-v2/generateReferenceCitationPreview.js.map +1 -0
- package/lib/utilities/reference-v2/index.js +3 -0
- package/lib/utilities/reference-v2/index.js.map +1 -0
- package/lib/utilities/reference-v2/useReferenceCitationPreview.js +18 -0
- package/lib/utilities/reference-v2/useReferenceCitationPreview.js.map +1 -0
- 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.js +13 -11
- package/lib-commonjs/components/reference-v2/Reference/useReferenceStyles.styles.js.map +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceList.js +8 -27
- package/lib-commonjs/components/reference-v2/ReferenceList/useReferenceList.js.map +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js +5 -7
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js.map +1 -1
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.js +4 -4
- package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButtonStyles.styles.js.map +1 -1
- package/lib-commonjs/index.js +7 -4
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utilities/reference-v2/generateReferenceCitationPreview.js +96 -0
- package/lib-commonjs/utilities/reference-v2/generateReferenceCitationPreview.js.map +1 -0
- package/lib-commonjs/{hooks → utilities}/reference-v2/index.js +1 -0
- package/lib-commonjs/utilities/reference-v2/index.js.map +1 -0
- package/lib-commonjs/utilities/reference-v2/useReferenceCitationPreview.js +18 -0
- package/lib-commonjs/utilities/reference-v2/useReferenceCitationPreview.js.map +1 -0
- package/package.json +10 -9
- package/lib/hooks/reference-v2/index.js +0 -2
- package/lib/hooks/reference-v2/index.js.map +0 -1
- package/lib/hooks/reference-v2/useReferenceCitationPreview.js +0 -125
- package/lib/hooks/reference-v2/useReferenceCitationPreview.js.map +0 -1
- package/lib-commonjs/hooks/reference-v2/index.js.map +0 -1
- package/lib-commonjs/hooks/reference-v2/useReferenceCitationPreview.js +0 -153
- package/lib-commonjs/hooks/reference-v2/useReferenceCitationPreview.js.map +0 -1
- /package/lib/{hooks → utilities}/index.js +0 -0
- /package/lib/{hooks → utilities}/index.js.map +0 -0
- /package/lib/{hooks → utilities}/useReferenceCitationPreview.js +0 -0
- /package/lib/{hooks → utilities}/useReferenceCitationPreview.js.map +0 -0
- /package/lib/{hooks → utilities}/useReferenceGroup.js +0 -0
- /package/lib/{hooks → utilities}/useReferenceGroup.js.map +0 -0
- /package/lib-commonjs/{hooks → utilities}/index.js +0 -0
- /package/lib-commonjs/{hooks → utilities}/index.js.map +0 -0
- /package/lib-commonjs/{hooks → utilities}/useReferenceCitationPreview.js +0 -0
- /package/lib-commonjs/{hooks → utilities}/useReferenceCitationPreview.js.map +0 -0
- /package/lib-commonjs/{hooks → utilities}/useReferenceGroup.js +0 -0
- /package/lib-commonjs/{hooks → utilities}/useReferenceGroup.js.map +0 -0
|
@@ -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,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,oBAACZ;QAAU,GAAGG,wBAAwB;QAAES,SAASD;;AAC1D;AAEA;;;;;;;;;;;CAWC,GACD,OAAO,MAAME,mCAAsEC,CAAAA;IACjF,MAAM,EACJC,oBAAoB,EACpBC,2BAA2B,EAC3BC,aAAa,EACbC,KAAK,EACLC,mBAAmB,EACnBC,kBAAkB,EAClBC,qBAAqB,EACrBC,4BAA4B,EAC5BC,cAAc,EACdC,qBAAqB,EACtB,GAAGV;IAEJ,MAAMW,sBAAwCX,CAAAA;YA2BnCK;QA1BT,qBACE,oBAAC1B;YAAQiC,eAAAA;YAAcC,aAAY;YAAQC,MAAK;YAAQC,WAAAA;YAAUC,WAAAA;YAAW,GAAGf,oBAAoB;yBAClG,oBAACjB,oCACC,oBAACE;YAAU,GAAGiB,aAAa;YAAG,GAAGH,KAAK;WACnCI,uBAGL,oBAACrB,gBAAmBmB,2CAClB,oBAACtB,oCACC,oBAACC;YACCoC,wBACE,oBAAC7B;gBAAoB8B,cAAY,CAAC,UAAU,EAAEd,MAAM,OAAO,CAAC;gBAAEe,eAAc;gBAAIC,UAAU,CAAC;eACxFhB;YAGLiB,KAAK,EAAEZ,2BAAAA,qCAAAA,eAAgBa,OAAO;WAE7Bb,2BAAAA,qCAAAA,eAAgBc,QAAQ,iBAE3B,oBAACzC;YACC0C,IAAI,EAAEnB,gCAAAA,0CAAAA,oBAAqBmB,IAAI;YAC/BC,WAAW,EAAEpB,gCAAAA,0CAAAA,oBAAqBoB,WAAW;YAC7CC,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,+BAAgCJ,iCAAAA,2CAAAA,qBAAsBsB,QAAQ;IAKzE;IAEA,MAAMM,uBAA0C7B,CAAAA;QAC9C,MAAM8B,uBAAuB;YAC3Bb,UAAUb;YACV,GAAGK,cAAc;YACjB,GAAGT,KAAK;QACV;YAkBWM,8BASFD;QAzBT,qBACE,oBAAC1B;YAAQiC,eAAAA;YAAcC,aAAY;YAAQC,MAAK;YAAQC,WAAAA;YAAUC,WAAAA;YAAW,GAAGT,qBAAqB;yBACnG,oBAACvB,oCACC,oBAACG,WAAc2C,sCAEjB,oBAAC/C,gBAAmByB,4CAClB,oBAAC5B,oCACC,oBAACC;YACCoC,wBACE,oBAAC7B;gBAAoB8B,cAAY,CAAC,UAAU,EAAEd,MAAM,OAAO,CAAC;gBAAEe,eAAc;gBAAIC,UAAU,CAAC;eACxFhB;YAGLiB,KAAK,EAAEZ,2BAAAA,qCAAAA,eAAgBa,OAAO;YAC7B,GAAGhB,kBAAkB;WAErBA,CAAAA,+BAAAA,+BAAAA,yCAAAA,mBAAoBiB,QAAQ,cAA5BjB,0CAAAA,+BAAgCG,2BAAAA,qCAAAA,eAAgBc,QAAQ,iBAE3D,oBAACzC;YACC0C,IAAI,EAAEnB,gCAAAA,0CAAAA,oBAAqBmB,IAAI;YAC/BC,WAAW,EAAEpB,gCAAAA,0CAAAA,oBAAqBoB,WAAW;YAC7CC,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './generateReferenceCitationPreview';\nexport * from './useReferenceCitationPreview';\n"],"names":[],"rangeMappings":";","mappings":"AAAA,cAAc,qCAAqC;AACnD,cAAc,gCAAgC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
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
|
+
*/
|
|
15
|
+
export const useReferenceCitationPreview = props => {
|
|
16
|
+
return React.useMemo(() => generateReferenceCitationPreview(props), [props]);
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useReferenceCitationPreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -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","getIntrinsicElementProps","divider","state","React","cloneElement"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAmBUA;;;eAAAA;;;;iEAnBa;iCAC6C;sCACnB;0CACR;AAgBvC,MAAQA,wBAAqBC,CAAAA,OAAAA;UAE7B,EAEAD,EAAA,EAEAE,QAAMC,EACNC,EAAA;UAEEC,oBAAQC,IAAAA,sDAAA,EAAAC,CAAAA,MAAAA,IAAAF,iBAAA;UACRL,cAAIG,IAAAA,sBAAAA,EAAAA,cAAAA;UACJC,cAAII,MAAAA,CAAAA,MAAAA,IAAAA,GAAAA,MAAAA,QAAAA;UACNC,sBAAA;QAEAC,MAAMC,gBAAgBC,WAASX,WAAMU;gBAAYR;QAAoBH,IAAAG;QACrEC,IAAAI;;UAAmEG,WAAAE,qBAAA,CAAAD,QAAA,CAAAX,MAAAU,QAAA,EAAA;QACnER,aAAMW;;UAEJC,UAAAA,qBAAAA,CAAAA,QAAiBC,CAAAA,MAAYC,OAAAA,EAAAA;QAC/Bd,aAAA;;UAEEA,UAAAA,qBAAa,CAAAS,QAAA,CAAAX,MAAAa,OAAA,EAAA;qBACbC;QACFA,iBAAAC,YAAAC,aAAA,CAAA,CAAAf;;UAGEE,UAAII,qBAAAA,CAAAA,QAAAA,CAAAA,MAAAA,OAAAA,EAAAA;qBACJH;yBAEYM,aAAAM,aAAAH,YAAAG;;kBAEVN;;;oBAGAG;kBACFX;sBAEMU;qBAEFK;qBACGT;qBAEL;;cAAcI,qBAAA,CAAAM,MAAA,CAAAC,IAAAA,yCAAA,EAAAjB,aAAA;;eAGhBkB,mBAAAA;YACAP;;QAEF;QAEAH;;;;;QAMAW,MAAOA,OAAAA,kBAAAA,OAAAA,cAAAA,CAAAA,MAAAA,OAAAA,CAAAA,QAAAA,GAAAA;QACPA,MAAAN,OAAA,CAAAd,QAAA,iBAAAqB,OAAAC,YAAA,CAAAF,MAAAN,OAAA,CAAAd,QAAA,EAAA"}
|
|
@@ -34,19 +34,21 @@ const referenceExtraClassNames = {
|
|
|
34
34
|
graphicChild: 'fai-Reference__graphicChild'
|
|
35
35
|
};
|
|
36
36
|
const GRAPHIC_SIZE = '16px';
|
|
37
|
-
const useRootBaseClassName = (0, _reactcomponents.__resetStyles)("
|
|
38
|
-
".
|
|
39
|
-
".
|
|
40
|
-
".
|
|
41
|
-
".
|
|
42
|
-
".
|
|
37
|
+
const useRootBaseClassName = (0, _reactcomponents.__resetStyles)("r19i5hos", null, [
|
|
38
|
+
".r19i5hos{align-items:center;background-color:var(--colorNeutralBackground3);border:var(--strokeWidthThin) solid var(--colorNeutralStroke2);border-radius:var(--borderRadiusMedium);box-sizing:border-box;color:var(--colorNeutralForeground2);column-gap:var(--spacingHorizontalXXS);display:flex;flex-shrink:0;justify-content:center;max-width:100%;min-height:24px;padding:var(--spacingVerticalXXS) var(--spacingHorizontalS);text-decoration:none;}",
|
|
39
|
+
".r19i5hos:hover{background-color:var(--colorNeutralBackground3Hover);border-color:var(--colorNeutralStroke1Hover);color:var(--colorNeutralForeground2Hover);}",
|
|
40
|
+
".r19i5hos:hover .fai-Reference__divider{background-color:var(--colorNeutralStroke1Hover);}",
|
|
41
|
+
".r19i5hos:hover:active{background-color:var(--colorNeutralBackground3Pressed);border-color:var(--colorNeutralStroke1Pressed);color:var(--colorNeutralForeground2Pressed);}",
|
|
42
|
+
".r19i5hos:hover:active .fai-Reference__divider{background-color:var(--colorNeutralStroke1Pressed);}"
|
|
43
43
|
]);
|
|
44
44
|
const useRootStyles = (0, _reactcomponents.__styles)({
|
|
45
45
|
overflow: {
|
|
46
|
+
B2u0y6b: "f6dzj5z",
|
|
46
47
|
a9b677: "fly5x3f"
|
|
47
48
|
}
|
|
48
49
|
}, {
|
|
49
50
|
d: [
|
|
51
|
+
".f6dzj5z{max-width:100%;}",
|
|
50
52
|
".fly5x3f{width:100%;}"
|
|
51
53
|
]
|
|
52
54
|
});
|
|
@@ -56,12 +58,12 @@ const useCitationBaseClassName = (0, _reactcomponents.__resetStyles)("rzdip90",
|
|
|
56
58
|
const useDividerBaseClassName = (0, _reactcomponents.__resetStyles)("r1eyqaw5", null, [
|
|
57
59
|
".r1eyqaw5{background-color:var(--colorNeutralStroke2);height:16px;margin:var(--spacingVerticalNone) var(--spacingHorizontalXS);width:1px;}"
|
|
58
60
|
]);
|
|
59
|
-
const useGraphicBaseClassName = (0, _reactcomponents.__resetStyles)("
|
|
60
|
-
".
|
|
61
|
-
".
|
|
61
|
+
const useGraphicBaseClassName = (0, _reactcomponents.__resetStyles)("rpyrgl4", null, [
|
|
62
|
+
".rpyrgl4{display:inline-flex;font-size:16px;height:16px;line-height:16px;width:16px;}",
|
|
63
|
+
".rpyrgl4>.fai-Reference__graphicChild{height:16px;width:16px;}"
|
|
62
64
|
]);
|
|
63
|
-
const useContentBaseClassName = (0, _reactcomponents.__resetStyles)("
|
|
64
|
-
".
|
|
65
|
+
const useContentBaseClassName = (0, _reactcomponents.__resetStyles)("r1ycou3l", null, [
|
|
66
|
+
".r1ycou3l{align-items:center;column-gap:var(--spacingHorizontalSNudge);display:inline-flex;text-align:start;word-break:break-word;font-family:var(--fontFamilyBase);font-size:var(--fontSizeBase200);font-weight:var(--fontWeightRegular);line-height:var(--lineHeightBase200);}"
|
|
65
67
|
]);
|
|
66
68
|
const useReferenceStyles_unstable = (state)=>{
|
|
67
69
|
'use no memo';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useReferenceStyles.styles.ts"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses, tokens, typographyStyles } from '@fluentui/react-components';\nimport type { ReferenceSlots, ReferenceState } from './Reference.types';\nimport type { SlotClassNames } from '@fluentui/react-components';\n\nexport const referenceClassNames: SlotClassNames<ReferenceSlots> = {\n root: 'fai-Reference',\n citation: 'fai-Reference__citation',\n divider: 'fai-Reference__divider',\n graphic: 'fai-Reference__graphic',\n content: 'fai-Reference__content',\n};\n\nexport const referenceExtraClassNames = {\n graphicChild: 'fai-Reference__graphicChild',\n};\n\nconst GRAPHIC_SIZE = '16px';\n\nconst useRootBaseClassName = makeResetStyles({\n alignItems: 'center',\n backgroundColor: tokens.colorNeutralBackground3,\n border: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke2}`,\n borderRadius: tokens.borderRadiusMedium,\n boxSizing: 'border-box',\n color: tokens.colorNeutralForeground2,\n columnGap: tokens.spacingHorizontalXXS,\n display: 'flex',\n flexShrink: 0,\n justifyContent: 'center',\n maxWidth: '
|
|
1
|
+
{"version":3,"sources":["useReferenceStyles.styles.ts"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses, tokens, typographyStyles } from '@fluentui/react-components';\nimport type { ReferenceSlots, ReferenceState } from './Reference.types';\nimport type { SlotClassNames } from '@fluentui/react-components';\n\nexport const referenceClassNames: SlotClassNames<ReferenceSlots> = {\n root: 'fai-Reference',\n citation: 'fai-Reference__citation',\n divider: 'fai-Reference__divider',\n graphic: 'fai-Reference__graphic',\n content: 'fai-Reference__content',\n};\n\nexport const referenceExtraClassNames = {\n graphicChild: 'fai-Reference__graphicChild',\n};\n\nconst GRAPHIC_SIZE = '16px';\n\nconst useRootBaseClassName = makeResetStyles({\n alignItems: 'center',\n backgroundColor: tokens.colorNeutralBackground3,\n border: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke2}`,\n borderRadius: tokens.borderRadiusMedium,\n boxSizing: 'border-box',\n color: tokens.colorNeutralForeground2,\n columnGap: tokens.spacingHorizontalXXS,\n display: 'flex',\n flexShrink: 0,\n justifyContent: 'center',\n maxWidth: '100%',\n minHeight: '24px',\n padding: `${tokens.spacingVerticalXXS} ${tokens.spacingHorizontalS}`,\n textDecoration: 'none',\n\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground3Hover,\n borderColor: tokens.colorNeutralStroke1Hover,\n color: tokens.colorNeutralForeground2Hover,\n\n [`& .${referenceClassNames.divider}`]: {\n backgroundColor: tokens.colorNeutralStroke1Hover,\n },\n },\n\n ':hover:active': {\n backgroundColor: tokens.colorNeutralBackground3Pressed,\n borderColor: tokens.colorNeutralStroke1Pressed,\n color: tokens.colorNeutralForeground2Pressed,\n\n [`& .${referenceClassNames.divider}`]: {\n backgroundColor: tokens.colorNeutralStroke1Pressed,\n },\n },\n});\n\nexport const useRootStyles = makeStyles({\n overflow: {\n maxWidth: '100%',\n width: '100%',\n },\n});\n\nconst useCitationBaseClassName = makeResetStyles({\n ...typographyStyles.caption2Strong,\n});\n\nconst useDividerBaseClassName = makeResetStyles({\n backgroundColor: tokens.colorNeutralStroke2,\n height: '16px',\n margin: `${tokens.spacingVerticalNone} ${tokens.spacingHorizontalXS}`,\n width: '1px',\n});\n\nconst useGraphicBaseClassName = makeResetStyles({\n display: 'inline-flex',\n fontSize: GRAPHIC_SIZE,\n height: GRAPHIC_SIZE,\n lineHeight: GRAPHIC_SIZE,\n width: GRAPHIC_SIZE,\n\n [`> .${referenceExtraClassNames.graphicChild}`]: {\n height: GRAPHIC_SIZE,\n width: GRAPHIC_SIZE,\n },\n});\n\nconst useContentBaseClassName = makeResetStyles({\n alignItems: 'center',\n columnGap: tokens.spacingHorizontalSNudge,\n display: 'inline-flex',\n textAlign: 'start',\n wordBreak: 'break-word',\n ...typographyStyles.caption1,\n});\n\n/**\n * Apply styling to the Reference slots based on the state\n */\nexport const useReferenceStyles_unstable = (state: ReferenceState): ReferenceState => {\n 'use no memo';\n\n const rootBaseClassName = useRootBaseClassName();\n const citationBaseClassName = useCitationBaseClassName();\n const dividerBaseClassName = useDividerBaseClassName();\n const contentBaseClassName = useContentBaseClassName();\n const graphicBaseClassName = useGraphicBaseClassName();\n\n state.root.className = mergeClasses(referenceClassNames.root, rootBaseClassName, state.root.className);\n\n if (state.citation) {\n state.citation.className = mergeClasses(\n referenceClassNames.citation,\n citationBaseClassName,\n state.citation.className,\n );\n }\n\n if (state.divider) {\n state.divider.className = mergeClasses(referenceClassNames.divider, dividerBaseClassName, state.divider.className);\n }\n\n if (state.content) {\n state.content.className = mergeClasses(referenceClassNames.content, contentBaseClassName, state.content.className);\n }\n\n if (state.graphic) {\n state.graphic.className = mergeClasses(referenceClassNames.graphic, graphicBaseClassName, state.graphic.className);\n }\n\n return state;\n};\n"],"names":["referenceClassNames","referenceExtraClassNames","backgroundColor","colorNeutralBackground3Hover","alignItems","root","citation","divider","graphic","content","graphicChild","GRAPHIC_SIZE","useRootBaseClassName","makeResetStyles","__styles","border","borderRadius","columnGap","spacingHorizontalXXS","flexShrink","__resetStyles","justifyContent","maxWidth","minHeight","rootBaseClassName","tokens","dividerBaseClassName","useDividerBaseClassName","contentBaseClassName","useContentBaseClassName","graphicBaseClassName","useGraphicBaseClassName","colorNeutralBackground3Pressed","state","className","borderColor","color","colorNeutralForeground2Pressed","citationBaseClassName","mergeClasses","useRootStyles","makeStyles","width"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAIaA,mBAAAA;eAAAA;;IAQAC,wBAAAA;eAAAA;;IAuBTC,2BAAwBC;eAAxBD;;IAhBFE,aAAY;eAAZA;;;iCAnB0E;AAIrE,MAAMJ,sBAAsD;UACjEK;cACAC;aACAC;aACAC;aACAC;AACF;AAEO,MAAMR,2BAA2B;kBACtCS;AACF;AAEA,MAAMC,eAAe;AAErB,MAAMC,uBAAuBC,IAAAA,8BAAAA,EAAAA,YAAgB,MAAA;IAAA;IAAA;IAAA;IAAA;IAAA;CAAA;AAC3CT,MAAAA,gBAAYU,IAAAA,yBAAA,EAAA;cACZZ;QACAa,SAAS;QACTC,QAAAA;;;OAGAC;QAAAA;QAAkBC;KAAoB;;MAEtCC,2BAAYC,IAAAA,8BAAA,EAAA,WAAA,MAAA;IAAA;CAAA;MACZC,0BAAgBD,IAAAA,8BAAA,EAAA,YAAA,MAAA;IAAA;CAAA;MAChBE,0BAAUF,IAAAA,8BAAA,EAAA,WAAA,MAAA;IAAA;IAAA;CAAA;MACVG,0BAAWH,IAAAA,8BAAA,EAAA,YAAA,MAAA;IAAA;CAAA;MAKTlB,8BAAwBC,CAAAA;;UAIxBqB,oBAAOxB;kCACYyB;UACnBC,uBAAAC;UACFC,uBAAAC;UAEAC,uBAAiBC;UACf7B,IAAAA,CAAAA,SAAAA,GAAiBuB,IAAAA,6BAAOO,EAAAA,oBAAAA,IAA8B,EAAAR,mBAAAS,MAAA5B,IAAA,CAAA6B,SAAA;cACtDC,QAAAA,EAAaV;cACbW,QAAOX,CAAAA,SAAOY,GAAAA,IAAAA,6BAAAA,EAAAA,oBAA8B/B,QAAA,EAAAgC,uBAAAL,MAAA3B,QAAA,CAAA4B,SAAA;;cAG1ChC,OAAAA,EAAAA;cACFK,OAAA,CAAA2B,SAAA,GAAAK,IAAAA,6BAAA,EAAAvC,oBAAAO,OAAA,EAAAmB,sBAAAO,MAAA1B,OAAA,CAAA2B,SAAA;;IAEJ,IAAAD,MAAAxB,OAAA,EAAA;QAEAwB,MAAOxB,OAAM+B,CAAAA,SAAAA,GAAgBC,IAAAA,6BAAW,EAAAzC,oBAAAS,OAAA,EAAAmB,sBAAAK,MAAAxB,OAAA,CAAAyB,SAAA;;cAEpCZ,OAAU,EAAA;cACVoB,OAAO,CAAAR,SAAA,GAAAK,IAAAA,6BAAA,EAAAvC,oBAAAQ,OAAA,EAAAsB,sBAAAG,MAAAzB,OAAA,CAAA0B,SAAA;;IAEX,OAAGD;AAEH,wDACoC"}
|
|
@@ -11,39 +11,20 @@ Object.defineProperty(exports, "useReferenceList_unstable", {
|
|
|
11
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
12
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
13
|
const _reactcomponents = require("@fluentui/react-components");
|
|
14
|
+
const _reactutilities = require("@fluentui-copilot/react-utilities");
|
|
14
15
|
const _useReferenceStylesstyles = require("../Reference/useReferenceStyles.styles");
|
|
15
16
|
const useReferenceList_unstable = (props, ref)=>{
|
|
16
17
|
const { children, maxVisibleReferences, showLessButton, showMoreButton, ...rest } = props;
|
|
17
18
|
const [areReferencesExpanded, setAreReferencesExpanded] = _react.useState(false);
|
|
18
19
|
const referenceListRef = _react.useRef(null);
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
if (maxVisibleReferences !== undefined && !areReferencesExpanded) {
|
|
24
|
-
const results = [];
|
|
25
|
-
for(let index = 0; index < childrenArray.length; index++){
|
|
26
|
-
const child = childrenArray[index];
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
-
if (index >= maxVisibleReferences && /*#__PURE__*/ _react.isValidElement(child)) {
|
|
29
|
-
results.push(/*#__PURE__*/ _react.cloneElement(child, {
|
|
30
|
-
...child.props,
|
|
31
|
-
className: (0, _reactcomponents.mergeClasses)(child.props.className, referenceInOverflowClassName)
|
|
32
|
-
}));
|
|
33
|
-
} else {
|
|
34
|
-
results.push(child);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return results;
|
|
38
|
-
}
|
|
39
|
-
return children;
|
|
40
|
-
}, [
|
|
41
|
-
areReferencesExpanded,
|
|
20
|
+
const totalReferencesCount = _react.Children.count(children);
|
|
21
|
+
const styles = (0, _useReferenceStylesstyles.useRootStyles)();
|
|
22
|
+
const resolvedChildren = (0, _reactutilities.useOverflowMaxVisibleItems)({
|
|
23
|
+
additionalCondition: !areReferencesExpanded,
|
|
42
24
|
children,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
]);
|
|
25
|
+
maxVisibleItems: maxVisibleReferences,
|
|
26
|
+
overflowClassName: styles.overflow
|
|
27
|
+
});
|
|
47
28
|
// We keep track of whether we are interacting with the overflow button via keyboard or not.
|
|
48
29
|
const overflowButtonTriggeredViaKeyboard = _react.useRef(false);
|
|
49
30
|
const focusAttributes = (0, _reactcomponents.useArrowNavigationGroup)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useReferenceList.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n getIntrinsicElementProps,\n mergeCallbacks,\n
|
|
1
|
+
{"version":3,"sources":["useReferenceList.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n getIntrinsicElementProps,\n mergeCallbacks,\n slot,\n useArrowNavigationGroup,\n useMergedRefs,\n} from '@fluentui/react-components';\nimport { useOverflowMaxVisibleItems } from '@fluentui-copilot/react-utilities';\nimport { useRootStyles } from '../Reference/useReferenceStyles.styles';\nimport type { ReferenceListProps, ReferenceListState } from './ReferenceList.types';\n\n/**\n * Create the state required to render ReferenceList.\n *\n * The returned state can be modified with hooks such as useReferenceListStyles_unstable,\n * before being passed to renderReferenceList_unstable.\n *\n * @param props - props from this instance of ReferenceList\n * @param ref - reference to root HTMLElement of ReferenceList\n */\nexport const useReferenceList_unstable = (\n props: ReferenceListProps,\n ref: React.Ref<HTMLDivElement>,\n): ReferenceListState => {\n const { children, maxVisibleReferences, showLessButton, showMoreButton, ...rest } = props;\n\n const [areReferencesExpanded, setAreReferencesExpanded] = React.useState(false);\n const referenceListRef = React.useRef<HTMLDivElement>(null);\n\n const totalReferencesCount = React.Children.count(children);\n const styles = useRootStyles();\n const resolvedChildren = useOverflowMaxVisibleItems({\n additionalCondition: !areReferencesExpanded,\n children,\n maxVisibleItems: maxVisibleReferences,\n overflowClassName: styles.overflow,\n });\n\n // We keep track of whether we are interacting with the overflow button via keyboard or not.\n const overflowButtonTriggeredViaKeyboard = React.useRef(false);\n\n const focusAttributes = useArrowNavigationGroup({\n axis: 'both',\n circular: true,\n memorizeCurrent: true,\n });\n\n const onShowMoreButtonClick = React.useCallback<React.MouseEventHandler<HTMLButtonElement>>(() => {\n setAreReferencesExpanded(true);\n }, []);\n\n const onShowLessButtonClick = React.useCallback<React.MouseEventHandler<HTMLButtonElement>>(() => {\n setAreReferencesExpanded(false);\n }, []);\n\n const shouldUseOverflow = maxVisibleReferences !== undefined && !areReferencesExpanded;\n\n const state: ReferenceListState = {\n areReferencesExpanded,\n overflowButtonTriggeredViaKeyboard,\n maxVisibleReferences,\n referenceListRef,\n shouldUseOverflow,\n totalReferencesCount,\n\n components: {\n root: 'div',\n showMoreButton: 'span',\n showLessButton: 'span',\n },\n root: slot.always(\n getIntrinsicElementProps('div', {\n ref: useMergedRefs(ref, referenceListRef),\n ...focusAttributes,\n ...rest,\n children: resolvedChildren,\n }),\n { elementType: 'div' },\n ),\n showMoreButton: shouldUseOverflow ? slot.optional(showMoreButton, { elementType: 'span' }) : undefined,\n showLessButton: areReferencesExpanded ? slot.optional(showLessButton, { elementType: 'span' }) : undefined,\n };\n\n if (state.showMoreButton) {\n state.showMoreButton.onClick = mergeCallbacks(onShowMoreButtonClick, state.showMoreButton.onClick);\n }\n\n if (state.showLessButton) {\n state.showLessButton.onClick = mergeCallbacks(onShowLessButtonClick, state.showLessButton.onClick);\n }\n\n return state;\n};\n"],"names":["children","maxVisibleReferences","props","showLessButton","referenceListRef","totalReferencesCount","styles","showMoreButton","resolvedChildren","maxVisibleItems","overflowClassName","overflow","React","Children","count","useRootStyles","overflowButtonTriggeredViaKeyboard","useRef","additionalCondition","focusAttributes","memorizeCurrent","setAreReferencesExpanded","useArrowNavigationGroup","axis","onShowLessButtonClick","onShowMoreButtonClick","useCallback","areReferencesExpanded","components","slot","always","getIntrinsicElementProps","shouldUseOverflow","elementType","rest","undefined","optional","state"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAyBUA;;;eAAAA;;;;iEAzBa;iCAOhB;gCACoC;0CACb;AAgB5B,MAAQA,4BAAUC,CAAoBC,OAAEC;UAExC,EACAH,QAAMI,EAENH,oBAAMI,EACNF,cAAMG,EACNC,cAAMC;UAGJC,CAAAA,uBAAiBR,yBAAAA,GAAAA,OAAAA,QAAAA,CAAAA;UACjBS,mBAAmBJ,OAAAA,MAAOK,CAAAA;UAC5BN,uBAAAO,OAAAC,QAAA,CAAAC,KAAA,CAAAd;UAEAM,SAAAS,IAAAA,uCAAA;UACAP,mBAAMQ,IAAAA,0CAA2CC,EAAAA;QAEjDC,qBAAMC,CAAAA;;yBAEMlB;2BACVmB,OAAiBT,QAAA;;gGAGyE;UAC1FU,qCAAyBT,OAAAK,MAAA,CAAA;UACxBE,kBAAEG,IAAAA,wCAAA,EAAA;QAELC,MAAMC;kBACJH;QACFD,iBAAK;;UAILK,wBAAkCb,OAAAc,WAAA,CAAA;iCAChCC;;UAEA1B,wBAAAA,OAAAA,WAAAA,CAAAA;iCACAG;;UAEAC,oBAAAA,yBAAAA,aAAAA,CAAAA;UAEAuB,QAAAA;;;;;;;oBAQOT;kBACH;4BACUX;4BAEZ;;cAAqBqB,qBAAA,CAAAC,MAAA,CAAAC,IAAAA,yCAAA,EAAA,OAAA;iBAEvBxB,IAAAA,8BAAgByB,EAAAA,KAAAA;8BAAoDC;eAAoBC,IAAKC;sBAC7FhC;;yBAAiGgC;QACnG;QAEA5B,gBAAUA,oBAAgBsB,qBAAA,CAAAO,QAAA,CAAA7B,gBAAA;yBAClBA;QACR,KAAA4B;QAEAhC,gBAAUA,wBAAgB0B,qBAAA,CAAAO,QAAA,CAAAjC,gBAAA;yBAClBA;QACR,KAAAgC;;IAGA,IAAAE,MAAA9B,cAAA,EAAA"}
|
package/lib-commonjs/components/reference-v2/ReferenceOverflowButton/useReferenceOverflowButton.js
CHANGED
|
@@ -19,13 +19,11 @@ const useReferenceOverflowButton_unstable = (props, ref)=>{
|
|
|
19
19
|
const { children, text } = props;
|
|
20
20
|
const rootRef = _react.useRef(null);
|
|
21
21
|
const [setTimeout] = (0, _reactutilities.useTimeout)();
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
triggeredViaKeyboard: ctx.overflowButtonTriggeredViaKeyboard
|
|
28
|
-
}));
|
|
22
|
+
const areReferencesExpanded = (0, _referenceListContext.useReferenceListContext_unstable)((ctx)=>ctx.areReferencesExpanded);
|
|
23
|
+
const maxVisibleReferences = (0, _referenceListContext.useReferenceListContext_unstable)((ctx)=>ctx.maxVisibleReferences);
|
|
24
|
+
const referenceListRef = (0, _referenceListContext.useReferenceListContext_unstable)((ctx)=>ctx.referenceListRef);
|
|
25
|
+
const totalReferencesCount = (0, _referenceListContext.useReferenceListContext_unstable)((ctx)=>ctx.totalReferencesCount);
|
|
26
|
+
const triggeredViaKeyboard = (0, _referenceListContext.useReferenceListContext_unstable)((ctx)=>ctx.overflowButtonTriggeredViaKeyboard);
|
|
29
27
|
const { isOverflowing, overflowCount } = (0, _reactcomponents.useOverflowMenu)();
|
|
30
28
|
const processedText = children !== null && children !== void 0 ? children : typeof text === 'function' ? text(overflowCount) : text;
|
|
31
29
|
const { findFirstFocusable, findNextFocusable } = (0, _reactcomponents.useFocusFinders)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useReferenceOverflowButton.ts"],"sourcesContent":["import * as React from 'react';\nimport { Enter, Space } from '@fluentui/keyboard-keys';\nimport {\n getIntrinsicElementProps,\n mergeCallbacks,\n slot,\n useFocusFinders,\n useMergedRefs,\n useOverflowMenu,\n} from '@fluentui/react-components';\nimport { useTimeout } from '@fluentui/react-utilities';\nimport { useReferenceListContext_unstable } from '../../../contexts/reference-v2/referenceListContext';\nimport type { ReferenceOverflowButtonProps, ReferenceOverflowButtonState } from './ReferenceOverflowButton.types';\n\n/**\n * Create the state required to render ReferenceOverflowButton.\n *\n * The returned state can be modified with hooks such as useReferenceOverflowButtonStyles_unstable,\n * before being passed to renderReferenceOverflowButton_unstable.\n *\n * @param props - props from this instance of ReferenceOverflowButton\n * @param ref - reference to root HTMLElement of ReferenceOverflowButton\n */\nexport const useReferenceOverflowButton_unstable = (\n props: ReferenceOverflowButtonProps,\n ref: React.Ref<HTMLButtonElement>,\n): ReferenceOverflowButtonState => {\n 'use no memo';\n\n const { children, text } = props;\n\n const rootRef = React.useRef<HTMLButtonElement>(null);\n\n const [setTimeout] = useTimeout();\n\n const
|
|
1
|
+
{"version":3,"sources":["useReferenceOverflowButton.ts"],"sourcesContent":["import * as React from 'react';\nimport { Enter, Space } from '@fluentui/keyboard-keys';\nimport {\n getIntrinsicElementProps,\n mergeCallbacks,\n slot,\n useFocusFinders,\n useMergedRefs,\n useOverflowMenu,\n} from '@fluentui/react-components';\nimport { useTimeout } from '@fluentui/react-utilities';\nimport { useReferenceListContext_unstable } from '../../../contexts/reference-v2/referenceListContext';\nimport type { ReferenceOverflowButtonProps, ReferenceOverflowButtonState } from './ReferenceOverflowButton.types';\n\n/**\n * Create the state required to render ReferenceOverflowButton.\n *\n * The returned state can be modified with hooks such as useReferenceOverflowButtonStyles_unstable,\n * before being passed to renderReferenceOverflowButton_unstable.\n *\n * @param props - props from this instance of ReferenceOverflowButton\n * @param ref - reference to root HTMLElement of ReferenceOverflowButton\n */\nexport const useReferenceOverflowButton_unstable = (\n props: ReferenceOverflowButtonProps,\n ref: React.Ref<HTMLButtonElement>,\n): ReferenceOverflowButtonState => {\n 'use no memo';\n\n const { children, text } = props;\n\n const rootRef = React.useRef<HTMLButtonElement>(null);\n\n const [setTimeout] = useTimeout();\n\n\n const areReferencesExpanded = useReferenceListContext_unstable(ctx => ctx.areReferencesExpanded);\n const maxVisibleReferences = useReferenceListContext_unstable(ctx => ctx.maxVisibleReferences);\n const referenceListRef = useReferenceListContext_unstable(ctx => ctx.referenceListRef);\n const totalReferencesCount = useReferenceListContext_unstable(ctx => ctx.totalReferencesCount);\n const triggeredViaKeyboard = useReferenceListContext_unstable(ctx => ctx.overflowButtonTriggeredViaKeyboard);\n\n const { isOverflowing, overflowCount } = useOverflowMenu();\n\n const processedText = children ?? (typeof text === 'function' ? text(overflowCount) : text);\n\n const { findFirstFocusable, findNextFocusable } = useFocusFinders();\n const onKeyDown = React.useCallback<React.KeyboardEventHandler<HTMLButtonElement>>(\n ev => {\n if (ev.key === Enter || ev.key === Space) {\n triggeredViaKeyboard.current = true;\n }\n },\n [triggeredViaKeyboard],\n );\n\n // We keep track of the previous overflow count to help determine the element to move focus to when expanding the references via keyboard.\n const previousOverflow = React.useRef(0);\n\n // When the references are expanded or collapsed via keyboard, we need to move focus to the appropriate element.\n React.useEffect(() => {\n // We only try to move focus if maxVisibleReferences is set and the overflow button was triggered via keyboard.\n if (maxVisibleReferences !== undefined && triggeredViaKeyboard.current) {\n let elementToFocus: HTMLElement | null | undefined;\n\n // If the references are collapsed, we move focus to the overflow button.\n if (!areReferencesExpanded) {\n elementToFocus = rootRef.current;\n previousOverflow.current = overflowCount;\n }\n // If the references are expanded, we move focus to the first reference that was hidden when they were collapsed.\n // We do this by moving focus according to the following heuristics:\n // - If maxVisibleReferences is what determines what overflows, focus is moved to the element that is in the maxVisibleReferences position of the ReferenceList's children.\n // - If the space available is what is determines what overflows, focus is moved to the element that is in the (totalReferencesCount - overflowCount) position of the ReferenceList's children.\n else if (rootRef.current && referenceListRef.current) {\n const positionToFocus =\n maxVisibleReferences < totalReferencesCount - previousOverflow.current\n ? maxVisibleReferences\n : totalReferencesCount - previousOverflow.current;\n\n let currentElement: HTMLElement | null | undefined = findFirstFocusable(referenceListRef.current);\n for (let i = 0; i < positionToFocus && currentElement; i++) {\n currentElement = findNextFocusable(currentElement);\n }\n\n elementToFocus = currentElement;\n }\n\n // We focus on the element and reset the triggeredViaKeyboard flag after a timeout to ensure that this is pushed at the end of the event queue.\n setTimeout(() => {\n elementToFocus?.focus();\n triggeredViaKeyboard.current = false;\n }, 0);\n }\n }, [\n areReferencesExpanded,\n findFirstFocusable,\n findNextFocusable,\n isOverflowing,\n maxVisibleReferences,\n overflowCount,\n referenceListRef,\n setTimeout,\n totalReferencesCount,\n triggeredViaKeyboard,\n ]);\n\n const state: ReferenceOverflowButtonState = {\n shouldRenderOverflowButton: isOverflowing || areReferencesExpanded,\n\n components: {\n root: 'button',\n },\n\n root: slot.always(\n getIntrinsicElementProps('button', {\n ref: useMergedRefs(rootRef, ref),\n ...props,\n }),\n {\n defaultProps: {\n children: processedText,\n },\n elementType: 'button',\n },\n ),\n };\n\n state.root.onKeyDown = mergeCallbacks(onKeyDown, props.onKeyDown);\n\n return state;\n};\n"],"names":["useReferenceOverflowButton_unstable","props","ref","children","areReferencesExpanded","text","rootRef","totalReferencesCount","setTimeout","triggeredViaKeyboard","useReferenceListContext_unstable","overflowCount","useOverflowMenu","maxVisibleReferences","referenceListRef","findFirstFocusable","useFocusFinders","useCallback","ev","Enter","ctx","overflowButtonTriggeredViaKeyboard","processedText","previousOverflow","findNextFocusable","React","onKeyDown","key","undefined","elementToFocus","current","i","positionToFocus","currentElement","focus","isOverflowing","components","state","shouldRenderOverflowButton","root","getIntrinsicElementProps","useMergedRefs","slot","mergeCallbacks"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BA2BEA;;;eAAAA;;;;iEA3BqB;8BACM;iCAQtB;gCACoB;sCACsB;AAgB/C,MAAAA,sCAAA,CAAAC,OAAAC;;UAMA,EAGAC,QAAMC,EACNC,IAAA,KACAJ;UACAK,UAAMC,OAAAA,MAAAA,CAAAA;UACN,CAAAC,WAAMC,GAAAA,IAAAA,0BAAuBC;UAE7BN,wBAAuBO,IAAAA,sDAAkBC,EAAAA,CAAAA,MAAAA,IAAAA,qBAAAA;UAEzCC,uBAAsBV,IAAAA,sDAAAA,EAAAA,CAAAA,MAAAA,IAAAA,oBAAoBE;UAE1CS,mBAAQC,IAAAA,sDAA0CC,EAAAA,CAAAA,MAAAA,IAAAA,gBAAAA;UAClDT,uBAAwBU,IAAAA,sDACtBC,EAAAA,CAAAA,MAAAA,IAAAA,oBAAAA;UACET,uBAAeU,IAAAA,sDAA2B,EAAAC,CAAAA,MAAAA,IAAAC,kCAAA;yBAE1C,EACFV,aACA,yCAACF;UAAqBa,gBAAAnB,aAAA,QAAAA,aAAA,KAAA,IAAAA,WAAA,OAAAE,SAAA,aAAAA,KAAAM,iBAAAN;UAGxB,EACAU,kBAAMQ,EAENC,iBAAA,KACAC,IAAAA,gCAAgB;UACdC,YAAAD,OAAAR,WAAA,CAAAC,CAAAA;YACAA,GAAAS,GAAId,KAAAA,mBAAAA,IAAAA,GAAAA,GAAAA,KAAyBe,mBAAAA,EAAAA;iCACvBC,OAAAA,GAAAA;;;;KAGCzB;8IAC6B;6BAChCmB,OAAiBO,MAAAA,CAAO;oHAM4B;oBACpD,CAAA;uHAKgG;qCAChFC,aAAIC,qBAAmBC,OAAqB,EAAA;;qFAE5D;wCAEiBA;iCACnB3B,QAAAwB,OAAA;iCAEAA,OAAA,GAAAnB;mBACAH,IAAAA,QAAWsB,OAAA,IAAAhB,iBAAAgB,OAAA,EAAA;wCACTD,uBAAAA,uBAAAA,iBAAgBK,OAAK,GAAArB,uBAAAN,uBAAAgB,iBAAAO,OAAA;qCACrBrB,mBAA+BK,iBAAAgB,OAAA;oBACjC,IAAGC,IAAA,GAAAA,IAAAC,mBAAAC,gBAAAF,IAAA;oBACLE,iBAAAT,kBAAAS;gBACC;gBACD7B,iBAAAA;;2JAEAoB;uBACAW;gBACAtB,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,eAAAA,KAAAA;gBACAF,qBAAAA,OAAAA,GAAAA;eACAG;;;;QAEAP;QAAAA;QAAAA;QAAAA;QAAAA;QAAAA;QAAAA;QAAAA;QAAAA;KAAAA;UACAE,QAAAA;oCACD0B,iBAAA/B;QAEDgC,YAAMC;kBACJC;;mCAGEC,CAAAA,MAAM,CAAAC,IAAAA,yCAAA,EAAA,UAAA;iBACRC,IAAAA,8BAAA,EAAAnC,SAAAJ;eAEAqC,KAAMG;;0BAGM;gBACVvC,UACAmB;;yBAEInB;;;UAGJoC,IAAA,CAAAb,SAAA,GAAAiB,IAAAA,+BAAA,EAAAjB,WAAAzB,MAAAyB,SAAA;WAEJW;yDAIOA"}
|
|
@@ -22,10 +22,10 @@ const referenceOverflowButtonClassNames = {
|
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
24
|
* Styles for the root slot
|
|
25
|
-
*/ const useRootBaseClassName = (0, _reactcomponents.__resetStyles)("
|
|
26
|
-
".
|
|
27
|
-
".
|
|
28
|
-
".
|
|
25
|
+
*/ const useRootBaseClassName = (0, _reactcomponents.__resetStyles)("r1hm0apo", null, [
|
|
26
|
+
".r1hm0apo{align-items:center;background-color:var(--colorNeutralBackground3);border:var(--strokeWidthThin) solid var(--colorNeutralStroke2);border-radius:var(--borderRadiusMedium);color:var(--colorNeutralForeground2);cursor:pointer;display:inline-flex;justify-content:center;min-height:24px;padding:var(--spacingVerticalXXS) var(--spacingHorizontalS);font-family:var(--fontFamilyBase);font-size:var(--fontSizeBase200);font-weight:var(--fontWeightRegular);line-height:var(--lineHeightBase200);}",
|
|
27
|
+
".r1hm0apo:hover{background-color:var(--colorNeutralBackground3Hover);border-color:var(--colorNeutralStroke1Hover);color:var(--colorNeutralForeground2Hover);}",
|
|
28
|
+
".r1hm0apo:hover:active{background-color:var(--colorNeutralBackground3Pressed);border-color:var(--colorNeutralStroke1Pressed);color:var(--colorNeutralForeground2Pressed);}"
|
|
29
29
|
]);
|
|
30
30
|
const useReferenceOverflowButtonStyles_unstable = (state)=>{
|
|
31
31
|
'use no memo';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useReferenceOverflowButtonStyles.styles.ts"],"sourcesContent":["import { makeResetStyles, mergeClasses, tokens, typographyStyles } from '@fluentui/react-components';\nimport type { ReferenceOverflowButtonSlots, ReferenceOverflowButtonState } from './ReferenceOverflowButton.types';\nimport type { SlotClassNames } from '@fluentui/react-components';\n\nexport const referenceOverflowButtonClassNames: SlotClassNames<ReferenceOverflowButtonSlots> = {\n root: 'fai-ReferenceOverflowButton',\n};\n\n/**\n * Styles for the root slot\n */\nconst useRootBaseClassName = makeResetStyles({\n alignItems: 'center',\n backgroundColor: tokens.colorNeutralBackground3,\n border: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke2}`,\n borderRadius: tokens.borderRadiusMedium,\n color: tokens.colorNeutralForeground2,\n display: 'inline-flex',\n justifyContent: 'center',\n minHeight: '24px',\n padding: `${tokens.spacingVerticalXXS} ${tokens.spacingHorizontalS}`,\n ...typographyStyles.caption1,\n\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground3Hover,\n borderColor: tokens.colorNeutralStroke1Hover,\n color: tokens.colorNeutralForeground2Hover,\n },\n\n ':hover:active': {\n backgroundColor: tokens.colorNeutralBackground3Pressed,\n borderColor: tokens.colorNeutralStroke1Pressed,\n color: tokens.colorNeutralForeground2Pressed,\n },\n});\n\n/**\n * Apply styling to the ReferenceOverflowButton slots based on the state\n */\nexport const useReferenceOverflowButtonStyles_unstable = (\n state: ReferenceOverflowButtonState,\n): ReferenceOverflowButtonState => {\n 'use no memo';\n\n const rootBaseClassName = useRootBaseClassName();\n\n state.root.className = mergeClasses(referenceOverflowButtonClassNames.root, rootBaseClassName, state.root.className);\n\n return state;\n};\n"],"names":["referenceOverflowButtonClassNames","tokens","root","alignItems","__resetStyles","color","state","
|
|
1
|
+
{"version":3,"sources":["useReferenceOverflowButtonStyles.styles.ts"],"sourcesContent":["import { makeResetStyles, mergeClasses, tokens, typographyStyles } from '@fluentui/react-components';\nimport type { ReferenceOverflowButtonSlots, ReferenceOverflowButtonState } from './ReferenceOverflowButton.types';\nimport type { SlotClassNames } from '@fluentui/react-components';\n\nexport const referenceOverflowButtonClassNames: SlotClassNames<ReferenceOverflowButtonSlots> = {\n root: 'fai-ReferenceOverflowButton',\n};\n\n/**\n * Styles for the root slot\n */\nconst useRootBaseClassName = makeResetStyles({\n alignItems: 'center',\n backgroundColor: tokens.colorNeutralBackground3,\n border: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke2}`,\n borderRadius: tokens.borderRadiusMedium,\n color: tokens.colorNeutralForeground2,\n cursor: 'pointer',\n display: 'inline-flex',\n justifyContent: 'center',\n minHeight: '24px',\n padding: `${tokens.spacingVerticalXXS} ${tokens.spacingHorizontalS}`,\n ...typographyStyles.caption1,\n\n ':hover': {\n backgroundColor: tokens.colorNeutralBackground3Hover,\n borderColor: tokens.colorNeutralStroke1Hover,\n color: tokens.colorNeutralForeground2Hover,\n },\n\n ':hover:active': {\n backgroundColor: tokens.colorNeutralBackground3Pressed,\n borderColor: tokens.colorNeutralStroke1Pressed,\n color: tokens.colorNeutralForeground2Pressed,\n },\n});\n\n/**\n * Apply styling to the ReferenceOverflowButton slots based on the state\n */\nexport const useReferenceOverflowButtonStyles_unstable = (\n state: ReferenceOverflowButtonState,\n): ReferenceOverflowButtonState => {\n 'use no memo';\n\n const rootBaseClassName = useRootBaseClassName();\n\n state.root.className = mergeClasses(referenceOverflowButtonClassNames.root, rootBaseClassName, state.root.className);\n\n return state;\n};\n"],"names":["referenceOverflowButtonClassNames","tokens","root","alignItems","__resetStyles","color","state","justifyContent","useRootBaseClassName","minHeight","mergeClasses","rootBaseClassName","className","padding"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAIaA,iCAAAA;eAAAA;;IAYJC,yCAA8B;eAA9BA;;;iCAhBuD;AAIzD,MAAMD,oCAAkF;UAC7FE;AACF;AAEA;;CAEC,SAECC,uBAAYC,IAAAA,8BAAA,EAAA,YAAA,MAAA;IAAA;IAAA;IAAA;CAAA;AAIZC,MAAOJ,4CAA8BK,CAAAA;;UAGrCC,oBAAgBC;UAChBC,IAAAA,CAAAA,SAAW,GAAAC,IAAAA,6BAAA,EAAAV,kCAAAE,IAAA,EAAAS,mBAAAL,MAAAJ,IAAA,CAAAU,SAAA;WACXC;sEAGU"}
|
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
|
},
|
|
@@ -88,13 +91,13 @@ _export(exports, {
|
|
|
88
91
|
return _Citation.useCitation_unstable;
|
|
89
92
|
},
|
|
90
93
|
useReferenceCitationPreview: function() {
|
|
91
|
-
return
|
|
94
|
+
return _utilities.useReferenceCitationPreview;
|
|
92
95
|
},
|
|
93
96
|
useReferenceCitationPreviewV2: function() {
|
|
94
97
|
return _referencev21.useReferenceCitationPreview;
|
|
95
98
|
},
|
|
96
99
|
useReferenceGroup: function() {
|
|
97
|
-
return
|
|
100
|
+
return _utilities.useReferenceGroup;
|
|
98
101
|
},
|
|
99
102
|
useReferenceGroupToggleStyles_unstable: function() {
|
|
100
103
|
return _ReferenceGroupToggle.useReferenceGroupToggleStyles_unstable;
|
|
@@ -138,12 +141,12 @@ _export(exports, {
|
|
|
138
141
|
});
|
|
139
142
|
const _Citation = require("./Citation");
|
|
140
143
|
const _Reference = require("./Reference");
|
|
141
|
-
const
|
|
144
|
+
const _utilities = require("./utilities");
|
|
142
145
|
const _ReferenceList = require("./ReferenceList");
|
|
143
146
|
const _ReferenceGroupToggle = require("./ReferenceGroupToggle");
|
|
144
147
|
const _ReferenceV2 = require("./ReferenceV2");
|
|
145
148
|
const _ReferenceListV2 = require("./ReferenceListV2");
|
|
146
149
|
const _ReferenceOverflowButton = require("./ReferenceOverflowButton");
|
|
147
150
|
const _referencev2 = require("./contexts/reference-v2");
|
|
148
|
-
const _referencev21 = require("./
|
|
151
|
+
const _referencev21 = require("./utilities/reference-v2");
|
|
149
152
|
//# sourceMappingURL=index.js.map
|
|
@@ -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 './
|
|
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 './utilities';\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 './utilities';\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 './utilities/reference-v2';\nexport {\n generateReferenceCitationPreview,\n useReferenceCitationPreview as useReferenceCitationPreviewV2,\n} from './utilities/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,oBAAS;;IAeTC,oBAAoB;eAApBA,0CAAoB;;IAPpBC,aAAa;eAAbA,4BAAa;;IAgFbC,oBAAoB;eAApBA,iCAAoB;;IACpBC,4BAA4B;eAA5BA,yCAA4B;;IAvBXC,eAAe;eAAhCH,8BAAAA;;IAaAI,uBAAuB;eAAvBA,gDAAuB;;IA5BVC,WAAW;eAAxBP,sBAAAA;;IAzDAQ,kBAAkB;eAAlBA,4BAAkB;;IA6GlBC,gCAAgC;eAAhCA,8CAAgC;;IAtGhCC,mBAAmB;eAAnBA,8BAAmB;;IAenBC,8BAA8B;eAA9BA,oDAA8B;;IAP9BC,uBAAuB;eAAvBA,sCAAuB;;IA0DIC,yBAAyB;eAApDD,wCAAAA;;IAaAE,iCAAiC;eAAjCA,0DAAiC;;IA5BVC,qBAAqB;eAA5CL,gCAAAA;;IAC4BM,0BAA0B;eAAtDC,qCAAAA;;IA1DAC,uBAAuB;eAAvBA,iCAAuB;;IAsBvBC,mCAAmC;eAAnCA,yDAAmC;;IAmDHC,8BAA8B;eAA9DC,6CAAAA;;IAxDAA,4BAA4B;eAA5BA,2CAA4B;;IAqE5BC,sCAAsC;eAAtCA,+DAAsC;;IA3BVC,0BAA0B;eAAtDC,qCAAAA;;IApDAA,wBAAwB;eAAxBA,mCAAwB;;IALxBC,0BAA0B;eAA1BA,oCAA0B;;IAD1BC,oBAAoB;eAApBA,8BAAoB;;IAUbC,2BAA2B;eAA3BA,sCAA2B;;IAkGHC,6BAA6B;eAA5DD,yCAAAA;;IAlGoCE,iBAAiB;eAAjBA,4BAAiB;;IAYrDC,sCAAsC;eAAtCA,4DAAsC;;IACtCC,gCAAgC;eAAhCA,sDAAgC;;IAuEhCC,gCAAgC;eAAhCA,6CAAgC;;IA/EhCC,+BAA+B;eAA/BA,8CAA+B;;IA0DIC,iCAAiC;eAApED,gDAAAA;;IAC6BE,2BAA2B;eAAxDC,0CAAAA;;IA5DAA,yBAAyB;eAAzBA,wCAAyB;;IAwEzBC,yCAAyC;eAAzCA,kEAAyC;;IACzCC,mCAAmC;eAAnCA,4DAAmC;;IA/EnCC,2BAA2B;eAA3BA,sCAA2B;;IAmDIC,6BAA6B;eAA5DD,wCAAAA;;IACyBE,uBAAuB;eAAhDC,kCAAAA;;IArDAA,qBAAqB;eAArBA,gCAAqB;;;0BALhB;2BAOA;2BACwD;+BAOxD;sCAOA;6BAqCA;iCAcA;yCAaA;6BAOA;8BAcA"}
|