@fluentui-copilot/react-reference 0.0.0-nightly-20250925-0407-633f78c5.1 → 0.0.0-nightly-20251002-0405-17b34fb7.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 +18 -3
- package/CHANGELOG.md +13 -4
- package/dist/index.d.ts +8 -7
- package/lib/components/Reference/useReference.js.map +1 -1
- package/lib/components/ReferenceList/ReferenceList.types.js.map +1 -1
- package/lib/utilities/generateReferenceCitationPreview.js +2 -1
- package/lib/utilities/generateReferenceCitationPreview.js.map +1 -1
- package/lib-commonjs/components/Reference/useReference.js.map +1 -1
- package/lib-commonjs/components/ReferenceList/ReferenceList.types.js.map +1 -1
- package/lib-commonjs/utilities/generateReferenceCitationPreview.js +2 -1
- package/lib-commonjs/utilities/generateReferenceCitationPreview.js.map +1 -1
- package/package.json +11 -11
package/CHANGELOG.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"name": "@fluentui-copilot/react-reference",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "Thu,
|
|
6
|
-
"tag": "@fluentui-copilot/react-reference_v0.0.0-nightly-
|
|
7
|
-
"version": "0.0.0-nightly-
|
|
5
|
+
"date": "Thu, 02 Oct 2025 04:13:20 GMT",
|
|
6
|
+
"tag": "@fluentui-copilot/react-reference_v0.0.0-nightly-20251002-0405-17b34fb7.1",
|
|
7
|
+
"version": "0.0.0-nightly-20251002-0405-17b34fb7.1",
|
|
8
8
|
"comments": {
|
|
9
9
|
"prerelease": [
|
|
10
10
|
{
|
|
@@ -16,6 +16,21 @@
|
|
|
16
16
|
]
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Mon, 29 Sep 2025 20:26:51 GMT",
|
|
21
|
+
"tag": "@fluentui-copilot/react-reference_v0.16.5",
|
|
22
|
+
"version": "0.16.5",
|
|
23
|
+
"comments": {
|
|
24
|
+
"patch": [
|
|
25
|
+
{
|
|
26
|
+
"author": "tristan.watanabe@gmail.com",
|
|
27
|
+
"package": "@fluentui-copilot/react-reference",
|
|
28
|
+
"commit": "eb866bbd84d778637cb17f869920ae47a3eeec50",
|
|
29
|
+
"comment": "fix: type issues after React 18 upgrade."
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
19
34
|
{
|
|
20
35
|
"date": "Thu, 17 Jul 2025 17:49:25 GMT",
|
|
21
36
|
"tag": "@fluentui-copilot/react-reference_v0.16.3",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
# Change Log - @fluentui-copilot/react-reference
|
|
2
2
|
|
|
3
|
-
This log was last generated on Thu,
|
|
3
|
+
This log was last generated on Thu, 02 Oct 2025 04:13:20 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
-
## [0.0.0-nightly-
|
|
7
|
+
## [0.0.0-nightly-20251002-0405-17b34fb7.1](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-reference_v0.0.0-nightly-20251002-0405-17b34fb7.1)
|
|
8
8
|
|
|
9
|
-
Thu,
|
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/react-reference_v0.16.
|
|
9
|
+
Thu, 02 Oct 2025 04:13:20 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/react-reference_v0.16.5..@fluentui-copilot/react-reference_v0.0.0-nightly-20251002-0405-17b34fb7.1)
|
|
11
11
|
|
|
12
12
|
### Changes
|
|
13
13
|
|
|
14
14
|
- Release nightly ([commit](https://github.com/microsoft/fluentai/commit/not available) by fluentui-internal@service.microsoft.com)
|
|
15
15
|
|
|
16
|
+
## [0.16.5](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-reference_v0.16.5)
|
|
17
|
+
|
|
18
|
+
Mon, 29 Sep 2025 20:26:51 GMT
|
|
19
|
+
[Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/react-reference_v0.16.3..@fluentui-copilot/react-reference_v0.16.5)
|
|
20
|
+
|
|
21
|
+
### Patches
|
|
22
|
+
|
|
23
|
+
- fix: type issues after React 18 upgrade. ([PR #3341](https://github.com/microsoft/fluentai/pull/3341) by tristan.watanabe@gmail.com)
|
|
24
|
+
|
|
16
25
|
## [0.16.3](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-reference_v0.16.3)
|
|
17
26
|
|
|
18
27
|
Thu, 17 Jul 2025 17:49:25 GMT
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { DesignVersion } from '@fluentui-copilot/react-provider';
|
|
|
8
8
|
import { FC } from 'react';
|
|
9
9
|
import type { ForwardRefComponent } from '@fluentui/react-components';
|
|
10
10
|
import { ForwardRefComponent as ForwardRefComponent_2 } from '@fluentui/react-utilities';
|
|
11
|
+
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
11
12
|
import type { PreviewHeaderProps } from '@fluentui-copilot/react-preview';
|
|
12
13
|
import type { PreviewMetadataProps } from '@fluentui-copilot/react-preview';
|
|
13
14
|
import type { PreviewProps } from '@fluentui-copilot/react-preview';
|
|
@@ -160,7 +161,7 @@ export declare type ReferenceListSlots = {
|
|
|
160
161
|
export declare type ReferenceListState = ComponentState<ReferenceListSlots> & Pick<ReferenceListProps, 'maxVisibleReferences' | 'minVisibleReferences'> & {
|
|
161
162
|
areReferencesExpanded: boolean;
|
|
162
163
|
overflowButtonTriggeredViaKeyboard: React.MutableRefObject<boolean>;
|
|
163
|
-
referenceListRef: React.RefObject<HTMLDivElement>;
|
|
164
|
+
referenceListRef: React.RefObject<HTMLDivElement | null>;
|
|
164
165
|
shouldUseOverflow: boolean;
|
|
165
166
|
totalReferencesCount: number;
|
|
166
167
|
};
|
|
@@ -252,25 +253,25 @@ export declare type ReferenceV2State = ReferenceState;
|
|
|
252
253
|
/**
|
|
253
254
|
* Render the final JSX of Citation
|
|
254
255
|
*/
|
|
255
|
-
export declare const renderCitation_unstable: (state: CitationState) =>
|
|
256
|
+
export declare const renderCitation_unstable: (state: CitationState) => JSX_2.Element;
|
|
256
257
|
|
|
257
|
-
export declare const renderReference_unstable: (state: ReferenceState) =>
|
|
258
|
+
export declare const renderReference_unstable: (state: ReferenceState) => JSX_2.Element;
|
|
258
259
|
|
|
259
260
|
/**
|
|
260
261
|
* Render the final JSX of ReferenceList
|
|
261
262
|
*/
|
|
262
|
-
export declare const renderReferenceList_unstable: (state: ReferenceListState, contextValues: ReferenceListContextValues) =>
|
|
263
|
+
export declare const renderReferenceList_unstable: (state: ReferenceListState, contextValues: ReferenceListContextValues) => JSX_2.Element;
|
|
263
264
|
|
|
264
265
|
/** @deprecated use renderReferenceList_unstable */
|
|
265
|
-
export declare const renderReferenceListV2_unstable: (state: ReferenceListState, contextValues: ReferenceListContextValues) =>
|
|
266
|
+
export declare const renderReferenceListV2_unstable: (state: ReferenceListState, contextValues: ReferenceListContextValues) => JSX_2.Element;
|
|
266
267
|
|
|
267
268
|
/**
|
|
268
269
|
* Render the final JSX of ReferenceOverflowButton
|
|
269
270
|
*/
|
|
270
|
-
export declare const renderReferenceOverflowButton_unstable: (state: ReferenceOverflowButtonState) =>
|
|
271
|
+
export declare const renderReferenceOverflowButton_unstable: (state: ReferenceOverflowButtonState) => JSX_2.Element | null;
|
|
271
272
|
|
|
272
273
|
/** @deprecated use renderReference_unstable */
|
|
273
|
-
export declare const renderReferenceV2_unstable: (state: ReferenceState) =>
|
|
274
|
+
export declare const renderReferenceV2_unstable: (state: ReferenceState) => JSX_2.Element;
|
|
274
275
|
|
|
275
276
|
/**
|
|
276
277
|
* Create the state required to render Citation.
|
|
@@ -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/referenceListContext';\nimport { referenceExtraClassNames } from './useReferenceStyles.styles';\nimport type { ReferenceProps, ReferenceState, ReferenceSlots } from './Reference.types';\nimport { useDesignVersion } from '@fluentui-copilot/react-provider';\n
|
|
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/referenceListContext';\nimport { referenceExtraClassNames } from './useReferenceStyles.styles';\nimport type { ReferenceProps, ReferenceState, ReferenceSlots } from './Reference.types';\nimport { useDesignVersion } from '@fluentui-copilot/react-provider';\nimport type { JSXIntrinsicElement } from '@fluentui/react-components';\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 designVersion = useDesignVersion(props.designVersion);\n\n const shouldUseOverflow = useReferenceListContext_unstable(ctx => ctx.shouldUseOverflow);\n\n const referenceId = useId('reference-', id);\n\n const elementType = as || ((props as JSXIntrinsicElement<'a'>).href ? 'a' : 'button');\n const propsWithAssignedAs = {\n type: elementType === 'button' ? 'button' : undefined,\n ...props,\n as: elementType,\n id: referenceId,\n };\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 as ReferenceSlots['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 designVersion,\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(\n elementType,\n {\n ref,\n ...propsWithAssignedAs,\n },\n // `content` is a slot and it's type clashes with the HTMLElement `content` attribute\n ['content'],\n ) as ReferenceSlots['root'],\n { elementType },\n ),\n citation,\n divider,\n content,\n graphic,\n };\n\n if (state.graphic && React.isValidElement<HTMLElement>(state.graphic.children)) {\n state.graphic.children = React.cloneElement(state.graphic.children, {\n className: mergeClasses(state.graphic.children.props.className, referenceExtraClassNames.graphicChild),\n });\n }\n\n return state;\n};\n"],"names":["React","getIntrinsicElementProps","mergeClasses","slot","useId","useReferenceListContext_unstable","referenceExtraClassNames","useDesignVersion","useReference_unstable","props","ref","as","children","id","designVersion","shouldUseOverflow","ctx","referenceId","elementType","href","propsWithAssignedAs","type","undefined","citation","optional","graphic","content","renderByDefault","divider","state","components","root","always","isValidElement","cloneElement","className","graphicChild"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,wBAAwB,EAAEC,YAAY,EAAEC,IAAI,EAAEC,KAAK,QAAQ,6BAA6B;AACjG,SAASC,gCAAgC,QAAQ,sCAAsC;AACvF,SAASC,wBAAwB,QAAQ,8BAA8B;AAEvE,SAASC,gBAAgB,QAAQ,mCAAmC;AAEpE;;;;;;;;CAQC,GACD,OAAO,MAAMC,wBAAwB,CACnCC,OACAC;IAEA,MAAM,EAAEC,EAAE,EAAEC,QAAQ,EAAEC,EAAE,EAAE,GAAGJ;IAE7B,MAAMK,gBAAgBP,iBAAiBE,MAAMK,aAAa;IAE1D,MAAMC,oBAAoBV,iCAAiCW,CAAAA,MAAOA,IAAID,iBAAiB;IAEvF,MAAME,cAAcb,MAAM,cAAcS;IAExC,MAAMK,cAAcP,MAAO,CAAA,AAACF,MAAmCU,IAAI,GAAG,MAAM,QAAO;IACnF,MAAMC,sBAAsB;QAC1BC,MAAMH,gBAAgB,WAAW,WAAWI;QAC5C,GAAGb,KAAK;QACRE,IAAIO;QACJL,IAAII;IACN;IAEA,MAAMM,WAAWpB,KAAKqB,QAAQ,CAACf,MAAMc,QAAQ,EAAE;QAAEL,aAAa;IAAO;IACrE,MAAMO,UAAUtB,KAAKqB,QAAQ,CAACf,MAAMgB,OAAO,EAAE;QAAEP,aAAa;IAAO;IACnE,MAAMQ,UAAUvB,KAAKqB,QAAQ,CAACf,MAAMiB,OAAO,EAA+B;QACxER,aAAa;QACbS,iBAAiBF,YAAYH,aAAa,CAAC,CAACV;IAC9C;IACA,MAAMgB,UAAUzB,KAAKqB,QAAQ,CAACf,MAAMmB,OAAO,EAAE;QAC3CV,aAAa;QACbS,iBAAiBJ,aAAaD,aAAaI,YAAYJ;IACzD;IAEA,MAAMO,QAAwB;QAC5Bf;QACAD,IAAII;QACJF;QAEAe,YAAY;YACVC,MAAMb;YACNK,UAAU;YACVK,SAAS;YACTH,SAAS;YACTC,SAAS;QACX;QAEAK,MAAM5B,KAAK6B,MAAM,CACf/B,yBACEiB,aACA;YACER;YACA,GAAGU,mBAAmB;QACxB,GACA,qFAAqF;QACrF;YAAC;SAAU,GAEb;YAAEF;QAAY;QAEhBK;QACAK;QACAF;QACAD;IACF;IAEA,IAAII,MAAMJ,OAAO,IAAIzB,MAAMiC,cAAc,CAAcJ,MAAMJ,OAAO,CAACb,QAAQ,GAAG;QAC9EiB,MAAMJ,OAAO,CAACb,QAAQ,GAAGZ,MAAMkC,YAAY,CAACL,MAAMJ,OAAO,CAACb,QAAQ,EAAE;YAClEuB,WAAWjC,aAAa2B,MAAMJ,OAAO,CAACb,QAAQ,CAACH,KAAK,CAAC0B,SAAS,EAAE7B,yBAAyB8B,YAAY;QACvG;IACF;IAEA,OAAOP;AACT,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ReferenceList.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-components';\nimport type { ReferenceListContextValue } from '../../contexts/referenceListContext';\n\nexport type ReferenceListSlots = {\n /** The root of the component that contains the list of references. */\n root: NonNullable<Slot<'div'>>;\n\n /** The region that contains the references and is used for arrow navigation. */\n arrowableRegion: NonNullable<Slot<'div'>>;\n\n /** A space containing a button that expands the list of references. This slot is only rendered when the list of references is collapsed. */\n showMoreButton?: Slot<'span'>;\n\n /** A space containing a button that collapses the list of references. This slot is only rendered when the list of references is expanded. */\n showLessButton?: Slot<'span'>;\n};\n\nexport type ReferenceListProps = ComponentProps<Partial<ReferenceListSlots>> & {\n /**\n * The maximum number of references to display before the overflow button is shown even if there is\n * enough space available to show more.\n * If not set, the overflow functionality will be disabled.\n * If this value is less than `minVisibleReferences`, then `minVisibleReferences` will take precedence.\n * @default undefined\n */\n maxVisibleReferences?: number;\n\n /**\n * The minimum number of references to always show before overflowing.\n * If this value exceeds the number of references, the overflow functionality will be disabled.\n * If this value is greater than `maxVisibleReferences`, then this will take precedence.\n * @default undefined\n */\n minVisibleReferences?: number;\n};\n\nexport type ReferenceListState = ComponentState<ReferenceListSlots> &\n Pick<ReferenceListProps, 'maxVisibleReferences' | 'minVisibleReferences'> & {\n areReferencesExpanded: boolean;\n overflowButtonTriggeredViaKeyboard: React.MutableRefObject<boolean>;\n referenceListRef: React.RefObject<HTMLDivElement>;\n shouldUseOverflow: boolean;\n totalReferencesCount: number;\n };\n\nexport type ReferenceListContextValues = {\n referenceList: ReferenceListContextValue;\n};\n"],"names":[],"rangeMappings":"","mappings":"AA6CA,WAEE"}
|
|
1
|
+
{"version":3,"sources":["ReferenceList.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-components';\nimport type { ReferenceListContextValue } from '../../contexts/referenceListContext';\n\nexport type ReferenceListSlots = {\n /** The root of the component that contains the list of references. */\n root: NonNullable<Slot<'div'>>;\n\n /** The region that contains the references and is used for arrow navigation. */\n arrowableRegion: NonNullable<Slot<'div'>>;\n\n /** A space containing a button that expands the list of references. This slot is only rendered when the list of references is collapsed. */\n showMoreButton?: Slot<'span'>;\n\n /** A space containing a button that collapses the list of references. This slot is only rendered when the list of references is expanded. */\n showLessButton?: Slot<'span'>;\n};\n\nexport type ReferenceListProps = ComponentProps<Partial<ReferenceListSlots>> & {\n /**\n * The maximum number of references to display before the overflow button is shown even if there is\n * enough space available to show more.\n * If not set, the overflow functionality will be disabled.\n * If this value is less than `minVisibleReferences`, then `minVisibleReferences` will take precedence.\n * @default undefined\n */\n maxVisibleReferences?: number;\n\n /**\n * The minimum number of references to always show before overflowing.\n * If this value exceeds the number of references, the overflow functionality will be disabled.\n * If this value is greater than `maxVisibleReferences`, then this will take precedence.\n * @default undefined\n */\n minVisibleReferences?: number;\n};\n\nexport type ReferenceListState = ComponentState<ReferenceListSlots> &\n Pick<ReferenceListProps, 'maxVisibleReferences' | 'minVisibleReferences'> & {\n areReferencesExpanded: boolean;\n overflowButtonTriggeredViaKeyboard: React.MutableRefObject<boolean>;\n referenceListRef: React.RefObject<HTMLDivElement | null>;\n shouldUseOverflow: boolean;\n totalReferencesCount: number;\n };\n\nexport type ReferenceListContextValues = {\n referenceList: ReferenceListContextValue;\n};\n"],"names":[],"rangeMappings":"","mappings":"AA6CA,WAEE"}
|
|
@@ -51,7 +51,8 @@ const CitationCloseButton = (citationCloseButtonProps)=>{
|
|
|
51
51
|
referenceHref: "#",
|
|
52
52
|
tabIndex: -1
|
|
53
53
|
}, index),
|
|
54
|
-
media: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.graphic
|
|
54
|
+
media: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.graphic,
|
|
55
|
+
...previewHeaderProps
|
|
55
56
|
}, referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.children), /*#__PURE__*/ React.createElement(PreviewMetadata, {
|
|
56
57
|
icon: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.icon,
|
|
57
58
|
primaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.primaryText,
|
|
@@ -1 +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 '../Reference';\nimport type { CitationProps } from '../Citation';\nimport type { ReferenceProps } from '../Reference';\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?: Omit<PreviewProps, 'children'> & Partial<Pick<PreviewProps, 'children'>>;\n citationPreviewSurfaceProps?: PreviewSurfaceProps;\n citationProps?: CitationProps;\n index: number;\n previewContentProps?: PackagedPreviewContentProps;\n previewHeaderProps?: PreviewHeaderProps;\n referencePreviewProps?: Omit<PreviewProps, 'children'> & Partial<Pick<PreviewProps, 'children'>>;\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=\"above\" 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={`Close Reference ${index}`} 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=\"above\" 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={`Close Reference ${index}`} 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,cAAc;AACvC,SAASC,SAAS,QAAQ,eAAe;AAiCzC,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,aAA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AAEe,eAAc;gBAAIC,UAAU,CAAC;eACvFhB;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"}
|
|
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 '../Reference';\nimport type { CitationProps } from '../Citation';\nimport type { ReferenceProps } from '../Reference';\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?: Omit<PreviewProps, 'children'> & Partial<Pick<PreviewProps, 'children'>>;\n citationPreviewSurfaceProps?: PreviewSurfaceProps;\n citationProps?: CitationProps;\n index: number;\n previewContentProps?: PackagedPreviewContentProps;\n previewHeaderProps?: PreviewHeaderProps;\n referencePreviewProps?: Omit<PreviewProps, 'children'> & Partial<Pick<PreviewProps, 'children'>>;\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=\"above\" 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={`Close Reference ${index}`} referenceHref=\"#\" tabIndex={-1}>\n {index}\n </CitationCloseButton>\n }\n media={referenceProps?.graphic as PreviewHeaderProps['media']}\n {...previewHeaderProps}\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=\"above\" 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={`Close Reference ${index}`} 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,cAAc;AACvC,SAASC,SAAS,QA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wBAC/CL,CAAAA,+BAAAA,gCAAAA,0CAAAA,oBAAqBuB,OAAO,cAA5BvB,0CAAAA,+BAAgCE,kCAAAA,4CAAAA,sBAAuBgB,QAAQ;IAK1E;IAEA,MAAMQ,aAAa;QACjB7C,UAAUyB;QACVxB,WAAW0C;IACb;IAEA,OAAOE;AACT,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useReference.ts"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, mergeClasses, slot, useId } from '@fluentui/react-components';\nimport { useReferenceListContext_unstable } from '../../contexts/referenceListContext';\nimport { referenceExtraClassNames } from './useReferenceStyles.styles';\nimport type { ReferenceProps, ReferenceState, ReferenceSlots } from './Reference.types';\nimport { useDesignVersion } from '@fluentui-copilot/react-provider';\n
|
|
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/referenceListContext';\nimport { referenceExtraClassNames } from './useReferenceStyles.styles';\nimport type { ReferenceProps, ReferenceState, ReferenceSlots } from './Reference.types';\nimport { useDesignVersion } from '@fluentui-copilot/react-provider';\nimport type { JSXIntrinsicElement } from '@fluentui/react-components';\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 designVersion = useDesignVersion(props.designVersion);\n\n const shouldUseOverflow = useReferenceListContext_unstable(ctx => ctx.shouldUseOverflow);\n\n const referenceId = useId('reference-', id);\n\n const elementType = as || ((props as JSXIntrinsicElement<'a'>).href ? 'a' : 'button');\n const propsWithAssignedAs = {\n type: elementType === 'button' ? 'button' : undefined,\n ...props,\n as: elementType,\n id: referenceId,\n };\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 as ReferenceSlots['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 designVersion,\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(\n elementType,\n {\n ref,\n ...propsWithAssignedAs,\n },\n // `content` is a slot and it's type clashes with the HTMLElement `content` attribute\n ['content'],\n ) as ReferenceSlots['root'],\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":["useReference_unstable","props","ref","as","children","id","designVersion","useDesignVersion","shouldUseOverflow","useReferenceListContext_unstable","ctx","referenceId","useId","elementType","href","propsWithAssignedAs","type","undefined","citation","slot","optional","graphic","content","renderByDefault","divider","state","components","root","always","getIntrinsicElementProps","React","isValidElement","cloneElement","className","mergeClasses","referenceExtraClassNames","graphicChild"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAgBaA;;;eAAAA;;;;iEAhBU;iCAC6C;sCACnB;0CACR;+BAER;AAW1B,MAAMA,wBAAwB,CACnCC,OACAC;IAEA,MAAM,EAAEC,EAAE,EAAEC,QAAQ,EAAEC,EAAE,EAAE,GAAGJ;IAE7B,MAAMK,gBAAgBC,IAAAA,+BAAAA,EAAiBN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,OAAO,CAACjB,QAAQ,EAAE;YAClE6B,WAAWC,IAAAA,6BAAAA,EAAaT,MAAMJ,OAAO,CAACjB,QAAQ,CAACH,KAAK,CAACgC,SAAS,EAAEE,kDAAAA,CAAyBC,YAAY;QACvG;IACF;IAEA,OAAOX;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ReferenceList.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-components';\nimport type { ReferenceListContextValue } from '../../contexts/referenceListContext';\n\nexport type ReferenceListSlots = {\n /** The root of the component that contains the list of references. */\n root: NonNullable<Slot<'div'>>;\n\n /** The region that contains the references and is used for arrow navigation. */\n arrowableRegion: NonNullable<Slot<'div'>>;\n\n /** A space containing a button that expands the list of references. This slot is only rendered when the list of references is collapsed. */\n showMoreButton?: Slot<'span'>;\n\n /** A space containing a button that collapses the list of references. This slot is only rendered when the list of references is expanded. */\n showLessButton?: Slot<'span'>;\n};\n\nexport type ReferenceListProps = ComponentProps<Partial<ReferenceListSlots>> & {\n /**\n * The maximum number of references to display before the overflow button is shown even if there is\n * enough space available to show more.\n * If not set, the overflow functionality will be disabled.\n * If this value is less than `minVisibleReferences`, then `minVisibleReferences` will take precedence.\n * @default undefined\n */\n maxVisibleReferences?: number;\n\n /**\n * The minimum number of references to always show before overflowing.\n * If this value exceeds the number of references, the overflow functionality will be disabled.\n * If this value is greater than `maxVisibleReferences`, then this will take precedence.\n * @default undefined\n */\n minVisibleReferences?: number;\n};\n\nexport type ReferenceListState = ComponentState<ReferenceListSlots> &\n Pick<ReferenceListProps, 'maxVisibleReferences' | 'minVisibleReferences'> & {\n areReferencesExpanded: boolean;\n overflowButtonTriggeredViaKeyboard: React.MutableRefObject<boolean>;\n referenceListRef: React.RefObject<HTMLDivElement>;\n shouldUseOverflow: boolean;\n totalReferencesCount: number;\n };\n\nexport type ReferenceListContextValues = {\n referenceList: ReferenceListContextValue;\n};\n"],"names":[],"rangeMappings":"","mappings":""}
|
|
1
|
+
{"version":3,"sources":["ReferenceList.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-components';\nimport type { ReferenceListContextValue } from '../../contexts/referenceListContext';\n\nexport type ReferenceListSlots = {\n /** The root of the component that contains the list of references. */\n root: NonNullable<Slot<'div'>>;\n\n /** The region that contains the references and is used for arrow navigation. */\n arrowableRegion: NonNullable<Slot<'div'>>;\n\n /** A space containing a button that expands the list of references. This slot is only rendered when the list of references is collapsed. */\n showMoreButton?: Slot<'span'>;\n\n /** A space containing a button that collapses the list of references. This slot is only rendered when the list of references is expanded. */\n showLessButton?: Slot<'span'>;\n};\n\nexport type ReferenceListProps = ComponentProps<Partial<ReferenceListSlots>> & {\n /**\n * The maximum number of references to display before the overflow button is shown even if there is\n * enough space available to show more.\n * If not set, the overflow functionality will be disabled.\n * If this value is less than `minVisibleReferences`, then `minVisibleReferences` will take precedence.\n * @default undefined\n */\n maxVisibleReferences?: number;\n\n /**\n * The minimum number of references to always show before overflowing.\n * If this value exceeds the number of references, the overflow functionality will be disabled.\n * If this value is greater than `maxVisibleReferences`, then this will take precedence.\n * @default undefined\n */\n minVisibleReferences?: number;\n};\n\nexport type ReferenceListState = ComponentState<ReferenceListSlots> &\n Pick<ReferenceListProps, 'maxVisibleReferences' | 'minVisibleReferences'> & {\n areReferencesExpanded: boolean;\n overflowButtonTriggeredViaKeyboard: React.MutableRefObject<boolean>;\n referenceListRef: React.RefObject<HTMLDivElement | null>;\n shouldUseOverflow: boolean;\n totalReferencesCount: number;\n };\n\nexport type ReferenceListContextValues = {\n referenceList: ReferenceListContextValue;\n};\n"],"names":[],"rangeMappings":"","mappings":""}
|
|
@@ -51,7 +51,8 @@ const generateReferenceCitationPreview = (props)=>{
|
|
|
51
51
|
referenceHref: "#",
|
|
52
52
|
tabIndex: -1
|
|
53
53
|
}, index),
|
|
54
|
-
media: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.graphic
|
|
54
|
+
media: referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.graphic,
|
|
55
|
+
...previewHeaderProps
|
|
55
56
|
}, referenceProps === null || referenceProps === void 0 ? void 0 : referenceProps.children), /*#__PURE__*/ _react.createElement(_reactpreview.PreviewMetadata, {
|
|
56
57
|
icon: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.icon,
|
|
57
58
|
primaryText: previewContentProps === null || previewContentProps === void 0 ? void 0 : previewContentProps.primaryText,
|
|
@@ -1 +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 '../Reference';\nimport type { CitationProps } from '../Citation';\nimport type { ReferenceProps } from '../Reference';\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?: Omit<PreviewProps, 'children'> & Partial<Pick<PreviewProps, 'children'>>;\n citationPreviewSurfaceProps?: PreviewSurfaceProps;\n citationProps?: CitationProps;\n index: number;\n previewContentProps?: PackagedPreviewContentProps;\n previewHeaderProps?: PreviewHeaderProps;\n referencePreviewProps?: Omit<PreviewProps, 'children'> & Partial<Pick<PreviewProps, 'children'>>;\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=\"above\" 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={`Close Reference ${index}`} 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=\"above\" 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={`Close Reference ${index}`} 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":["generateReferenceCitationPreview","CitationCloseButton","citationCloseButtonProps","setPopoverOpen","usePopoverContext_unstable","context","setOpen","onPopoverCloseClick","React","useCallback","ev","preventDefault","onCitationCloseButtonClick","mergeCallbacks","onClick","createElement","Citation","props","citationPreviewProps","citationPreviewSurfaceProps","citationProps","index","previewContentProps","previewHeaderProps","referencePreviewProps","referencePreviewSurfaceProps","referenceProps","sensitivityLabelProps","CitationWithPreview","Preview","closeOnScroll","positioning","size","trapFocus","withArrow","PreviewTrigger","PreviewSurface","PreviewContent","PreviewHeader","citation","aria-label","referenceHref","tabIndex","media","graphic","children","PreviewMetadata","icon","primaryText","secondaryText","tertiaryText","SensitivityLabel","content","ReferenceWithPreview","mergedReferenceProps","Reference","components"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAsFaA;;;eAAAA;;;;iEAtFU;iCAEoC;8BASpD;uCAC0B;0BASR;2BACC;AAiC1B,6IAA6I;AAC7I,MAAMC,sBAAsB,CAACC;IAC3B,MAAMC,iBAAiBC,IAAAA,2CAAAA,EAA2BC,CAAAA,UAAWA,QAAQC,OAAO;IAE5E,MAAMC,sBAAsBC,OAAMC,WAAW,CAC3CC,CAAAA;QACEP,eAAeO,IAAI;QAEnB,iBAAiB;QACjBA,GAAGC,cAAc;IACnB,GACA;QAACR;KAAe;IAGlB,MAAMS,6BAA6BC,IAAAA,+BAAAA,EAAeN,qBAAqBL,yBAAyBY,OAAO;IAEvG,OAAA,WAAA,GAAON,OAAAO,aAAA,CAACC,kBAAAA,EAAAA;QAAU,GAAGd,wBAAwB;QAAEY,SAASF;;AAC1D;AAcO,MAAMZ,mCAAsEiB,CAAAA;IACjF,MAAM,EACJC,oBAAoB,EACpBC,2BAA2B,EAC3BC,aAAa,EACbC,KAAK,EACLC,mBAAmB,EACnBC,kBAAkB,EAClBC,qBAAqB,EACrBC,4BAA4B,EAC5BC,cAAc,EACdC,qBAA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oBsB,QAAQ,AAARA,MAAQ,QAA5BtB,iCAAAA,KAAAA,IAAAA,+BAAgCG,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,eAAgBmB,QAAQ,GAAA,WAAA,GAE3DrC,OAAAO,aAAA,CAAC+B,6BAAAA,EAAAA;YACCC,MAAMzB,wBAAAA,QAAAA,wBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,oBAAqByB,IAAI;YAC/BC,aAAa1B,wBAAAA,QAAAA,wBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,oBAAqB0B,WAAW;YAC7CC,eAAe3B,wBAAAA,QAAAA,wBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,oBAAqB2B,aAAa;YACjDC,cAAc5B,wBAAAA,QAAAA,wBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,oBAAqB4B,YAAY;YAEhDvB,yBAAAA,WAAAA,GAAyBnB,OAAAO,aAAA,CAACoC,uCAAAA,EAAqBxB,wBAC/CL,CAAAA,+BAAAA,wBAAAA,QAAAA,wBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,oBAAqB8B,OAAO,AAAPA,MAAO,QAA5B9B,iCAAAA,KAAAA,IAAAA,+BAAgCE,0BAAAA,QAAAA,0BAAAA,KAAAA,IAAAA,KAAAA,IAAAA,sBAAuBqB,QAAQ;IAK1E;IAEA,MAAMW,aAAa;QACjBxC,UAAUY;QACV2B,WAAWF;IACb;IAEA,OAAOG;AACT"}
|
|
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 '../Reference';\nimport type { CitationProps } from '../Citation';\nimport type { ReferenceProps } from '../Reference';\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?: Omit<PreviewProps, 'children'> & Partial<Pick<PreviewProps, 'children'>>;\n citationPreviewSurfaceProps?: PreviewSurfaceProps;\n citationProps?: CitationProps;\n index: number;\n previewContentProps?: PackagedPreviewContentProps;\n previewHeaderProps?: PreviewHeaderProps;\n referencePreviewProps?: Omit<PreviewProps, 'children'> & Partial<Pick<PreviewProps, 'children'>>;\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=\"above\" 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={`Close Reference ${index}`} referenceHref=\"#\" tabIndex={-1}>\n {index}\n </CitationCloseButton>\n }\n media={referenceProps?.graphic as PreviewHeaderProps['media']}\n {...previewHeaderProps}\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=\"above\" 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={`Close Reference ${index}`} 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":["generateReferenceCitationPreview","CitationCloseButton","citationCloseButtonProps","setPopoverOpen","usePopoverContext_unstable","context","setOpen","onPopoverCloseClick","React","useCallback","ev","preventDefault","onCitationCloseButtonClick","mergeCallbacks","onClick","createElement","Citation","props","citationPreviewProps","citationPreviewSurfaceProps","citationProps","index","previewContentProps","previewHeaderProps","referencePreviewProps","referencePreviewSurfaceProps","referenceProps","sensitivityLabelProps","CitationWithPreview","Preview","closeOnScroll","positioning","size","trapFocus","withArrow","PreviewTrigger","PreviewSurface","PreviewContent","PreviewHeader","citation","aria-label","referenceHref","tabIndex","media","graphic","children","PreviewMetadata","icon","primaryText","secondaryText","tertiaryText","SensitivityLabel","content","ReferenceWithPreview","mergedReferenceProps","Reference","components"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAsFaA;;;eAAAA;;;;iEAtFU;iCAEoC;8BASpD;uCAC0B;0BASR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CAACoC,uCAAAA,EAAqBxB,wBAC/CL,CAAAA,+BAAAA,wBAAAA,QAAAA,wBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,oBAAqB8B,OAAO,AAAPA,MAAO,QAA5B9B,iCAAAA,KAAAA,IAAAA,+BAAgCE,0BAAAA,QAAAA,0BAAAA,KAAAA,IAAAA,KAAAA,IAAAA,sBAAuBqB,QAAQ;IAK1E;IAEA,MAAMW,aAAa;QACjBxC,UAAUY;QACV2B,WAAWF;IACb;IAEA,OAAOG;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui-copilot/react-reference",
|
|
3
|
-
"version": "0.0.0-nightly-
|
|
3
|
+
"version": "0.0.0-nightly-20251002-0405-17b34fb7.1",
|
|
4
4
|
"description": "Fluent AI controls for citations and references",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -12,21 +12,21 @@
|
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@fluentui-copilot/react-preview": "0.0.0-nightly-
|
|
16
|
-
"@fluentui-copilot/react-provider": "0.0.0-nightly-
|
|
17
|
-
"@fluentui-copilot/react-sensitivity-label": "0.0.0-nightly-
|
|
18
|
-
"@fluentui-copilot/react-utilities": "0.0.0-nightly-
|
|
19
|
-
"@fluentui-copilot/tokens": "0.0.0-nightly-
|
|
15
|
+
"@fluentui-copilot/react-preview": "0.0.0-nightly-20251002-0405-17b34fb7.1",
|
|
16
|
+
"@fluentui-copilot/react-provider": "0.0.0-nightly-20251002-0405-17b34fb7.1",
|
|
17
|
+
"@fluentui-copilot/react-sensitivity-label": "0.0.0-nightly-20251002-0405-17b34fb7.1",
|
|
18
|
+
"@fluentui-copilot/react-utilities": "0.0.0-nightly-20251002-0405-17b34fb7.1",
|
|
19
|
+
"@fluentui-copilot/tokens": "0.0.0-nightly-20251002-0405-17b34fb7.1",
|
|
20
20
|
"@swc/helpers": "^0.5.1"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@fluentui/keyboard-keys": ">=9.0.8 <10.0.0",
|
|
24
|
-
"@fluentui/react-components": ">=9.
|
|
25
|
-
"@fluentui/react-context-selector": ">=9.2.
|
|
24
|
+
"@fluentui/react-components": ">=9.70.0 <10.0.0",
|
|
25
|
+
"@fluentui/react-context-selector": ">=9.2.7 <10.0.0",
|
|
26
26
|
"@fluentui/react-icons": ">=2.0.303 <3.0.0",
|
|
27
|
-
"@fluentui/react-jsx-runtime": ">=9.
|
|
28
|
-
"@fluentui/react-shared-contexts": ">=9.
|
|
29
|
-
"@fluentui/react-utilities": ">=9.
|
|
27
|
+
"@fluentui/react-jsx-runtime": ">=9.2.0 <10.0.0",
|
|
28
|
+
"@fluentui/react-shared-contexts": ">=9.25.1 <10.0.0",
|
|
29
|
+
"@fluentui/react-utilities": ">=9.24.1 <10.0.0",
|
|
30
30
|
"@types/react": ">=16.14.0 <19.0.0",
|
|
31
31
|
"@types/react-dom": ">=16.9.8 <19.0.0",
|
|
32
32
|
"react": ">=16.14.0 <19.0.0",
|