@fluentui-copilot/react-reference 0.10.0 → 0.11.0
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 +16 -1
- package/CHANGELOG.md +11 -2
- package/dist/index.d.ts +3 -3
- package/lib/components/Citation/useCitation.js +4 -4
- package/lib/components/Citation/useCitation.js.map +1 -1
- package/lib/components/Reference/useReference.js +2 -2
- package/lib/components/Reference/useReference.js.map +1 -1
- package/lib/components/ReferenceList/useReferenceList.js +2 -2
- package/lib/components/ReferenceList/useReferenceList.js.map +1 -1
- package/lib-commonjs/components/Citation/useCitation.js +3 -3
- package/lib-commonjs/components/Citation/useCitation.js.map +1 -1
- package/lib-commonjs/components/Reference/useReference.js +1 -1
- package/lib-commonjs/components/Reference/useReference.js.map +1 -1
- package/lib-commonjs/components/ReferenceList/useReferenceList.js +1 -1
- package/lib-commonjs/components/ReferenceList/useReferenceList.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
2
2
|
"name": "@fluentui-copilot/react-reference",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "Wed,
|
|
5
|
+
"date": "Wed, 10 Apr 2024 23:06:59 GMT",
|
|
6
|
+
"tag": "@fluentui-copilot/react-reference_v0.11.0",
|
|
7
|
+
"version": "0.11.0",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"author": "Humberto.Morimoto@microsoft.com",
|
|
12
|
+
"package": "@fluentui-copilot/react-reference",
|
|
13
|
+
"commit": "2afa98912cd99ed6f604c582caee4d49d1ba895d",
|
|
14
|
+
"comment": "fix: Replace usage of deprecated getNativeElementProps with getIntrinsicElementProps."
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Wed, 03 Apr 2024 00:23:41 GMT",
|
|
6
21
|
"tag": "@fluentui-copilot/react-reference_v0.10.0",
|
|
7
22
|
"version": "0.10.0",
|
|
8
23
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
# Change Log - @fluentui-copilot/react-reference
|
|
2
2
|
|
|
3
|
-
This log was last generated on Wed,
|
|
3
|
+
This log was last generated on Wed, 10 Apr 2024 23:06:59 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [0.11.0](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-reference_v0.11.0)
|
|
8
|
+
|
|
9
|
+
Wed, 10 Apr 2024 23:06:59 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/react-reference_v0.10.0..@fluentui-copilot/react-reference_v0.11.0)
|
|
11
|
+
|
|
12
|
+
### Minor changes
|
|
13
|
+
|
|
14
|
+
- fix: Replace usage of deprecated getNativeElementProps with getIntrinsicElementProps. ([PR #1512](https://github.com/microsoft/fluentai/pull/1512) by Humberto.Morimoto@microsoft.com)
|
|
15
|
+
|
|
7
16
|
## [0.10.0](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/react-reference_v0.10.0)
|
|
8
17
|
|
|
9
|
-
Wed, 03 Apr 2024 00:23:
|
|
18
|
+
Wed, 03 Apr 2024 00:23:41 GMT
|
|
10
19
|
[Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/react-reference_v0.9.0..@fluentui-copilot/react-reference_v0.10.0)
|
|
11
20
|
|
|
12
21
|
### Minor changes
|
package/dist/index.d.ts
CHANGED
|
@@ -298,7 +298,7 @@ declare type SensitivityTooltipSlots = {
|
|
|
298
298
|
* @param props - props from this instance of Citation
|
|
299
299
|
* @param ref - reference to root HTMLElement of Citation
|
|
300
300
|
*/
|
|
301
|
-
export declare const useCitation_unstable: (props: CitationProps, ref: React.Ref<
|
|
301
|
+
export declare const useCitation_unstable: (props: CitationProps, ref: React.Ref<HTMLAnchorElement>) => CitationState;
|
|
302
302
|
|
|
303
303
|
/**
|
|
304
304
|
* Apply styling to the Citation slots based on the state
|
|
@@ -314,7 +314,7 @@ export declare const useCitationStyles_unstable: (state: CitationState) => Citat
|
|
|
314
314
|
* @param props - props from this instance of Reference
|
|
315
315
|
* @param ref - reference to root HTMLElement of Reference
|
|
316
316
|
*/
|
|
317
|
-
export declare const useReference_unstable: (props: ReferenceProps, ref: React_2.Ref<
|
|
317
|
+
export declare const useReference_unstable: (props: ReferenceProps, ref: React_2.Ref<HTMLDivElement>) => ReferenceState;
|
|
318
318
|
|
|
319
319
|
export declare type UseReferenceCitationPreview = (data: ReferenceCitationData) => {
|
|
320
320
|
Citation: PackagedCitation;
|
|
@@ -373,7 +373,7 @@ export declare const useReferenceGroupToggleStyles_unstable: (state: ReferenceGr
|
|
|
373
373
|
* @param props - props from this instance of ReferenceList
|
|
374
374
|
* @param ref - reference to root HTMLElement of ReferenceList
|
|
375
375
|
*/
|
|
376
|
-
export declare const useReferenceList_unstable: (props: ReferenceListProps, ref: React_2.Ref<
|
|
376
|
+
export declare const useReferenceList_unstable: (props: ReferenceListProps, ref: React_2.Ref<HTMLOListElement>) => ReferenceListState;
|
|
377
377
|
|
|
378
378
|
/**
|
|
379
379
|
* Apply styling to the ReferenceList slots based on the state
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getIntrinsicElementProps, slot } from '@fluentui/react-components';
|
|
2
2
|
import { usePreviewContext_unstable } from '@fluentui-copilot/react-preview';
|
|
3
3
|
/**
|
|
4
4
|
* Create the state required to render Citation.
|
|
@@ -22,11 +22,11 @@ export const useCitation_unstable = (props, ref) => {
|
|
|
22
22
|
components: {
|
|
23
23
|
root: 'a'
|
|
24
24
|
},
|
|
25
|
-
root: slot.always(
|
|
25
|
+
root: slot.always(getIntrinsicElementProps('a', {
|
|
26
26
|
ref,
|
|
27
27
|
href: referenceHref,
|
|
28
|
-
role:
|
|
29
|
-
'aria-expanded':
|
|
28
|
+
role: undefined,
|
|
29
|
+
'aria-expanded': undefined,
|
|
30
30
|
...otherProps
|
|
31
31
|
}), {
|
|
32
32
|
elementType: 'a'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useCitation.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["useCitation.ts"],"sourcesContent":["import { getIntrinsicElementProps, slot } from '@fluentui/react-components';\nimport { usePreviewContext_unstable } from '@fluentui-copilot/react-preview';\nimport type { CitationProps, CitationState } from './Citation.types';\n/**\n * Create the state required to render Citation.\n *\n * The returned state can be modified with hooks such as useCitationStyles_unstable,\n * before being passed to renderCitation_unstable.\n *\n * @param props - props from this instance of Citation\n * @param ref - reference to root HTMLElement of Citation\n */\nexport const useCitation_unstable = (props: CitationProps, ref: React.Ref<HTMLAnchorElement>): CitationState => {\n const { referenceHref, block = false, ...otherProps } = props;\n\n const isPopoverLocked = usePreviewContext_unstable(ctx => ctx.isPreviewLocked) && (props['aria-expanded'] as boolean);\n\n const state: CitationState = {\n block,\n isPopoverLocked,\n components: {\n root: 'a',\n },\n root: slot.always(\n getIntrinsicElementProps('a', {\n ref,\n href: referenceHref,\n role: undefined,\n 'aria-expanded': undefined,\n ...otherProps,\n }),\n { elementType: 'a' },\n ),\n };\n\n return state;\n};\n"],"names":["getIntrinsicElementProps","slot","usePreviewContext_unstable","useCitation_unstable","props","ref","referenceHref","block","otherProps","isPopoverLocked","ctx","isPreviewLocked","state","components","root","always","href","role","undefined","elementType"],"mappings":"AAAA,SAASA,wBAAwB,EAAEC,IAAI,QAAQ,6BAA6B;AAC5E,SAASC,0BAA0B,QAAQ,kCAAkC;AAE7E;;;;;;;;CAQC,GACD,OAAO,MAAMC,uBAAuB,CAACC,OAAsBC;IACzD,MAAM,EAAEC,aAAa,EAAEC,QAAQ,KAAK,EAAE,GAAGC,YAAY,GAAGJ;IAExD,MAAMK,kBAAkBP,2BAA2BQ,CAAAA,MAAOA,IAAIC,eAAe,KAAMP,KAAK,CAAC,gBAAgB;IAEzG,MAAMQ,QAAuB;QAC3BL;QACAE;QACAI,YAAY;YACVC,MAAM;QACR;QACAA,MAAMb,KAAKc,MAAM,CACff,yBAAyB,KAAK;YAC5BK;YACAW,MAAMV;YACNW,MAAMC;YACN,iBAAiBA;YACjB,GAAGV,UAAU;QACf,IACA;YAAEW,aAAa;QAAI;IAEvB;IAEA,OAAOP;AACT,EAAE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Button, Caption1,
|
|
2
|
+
import { Button, Caption1, getIntrinsicElementProps, mergeCallbacks, mergeClasses, slot, useId, usePopoverContext_unstable as usePopoverContext } from '@fluentui/react-components';
|
|
3
3
|
import { ChevronDown24Regular, ChevronUp24Regular, ChevronDown16Regular, ChevronUp16Regular } from '@fluentui/react-icons';
|
|
4
4
|
import { referenceExtraClassNames } from './useReferenceStyles';
|
|
5
5
|
import { Citation } from '../Citation';
|
|
@@ -96,7 +96,7 @@ export const useReference_unstable = (props, ref) => {
|
|
|
96
96
|
icon: 'span',
|
|
97
97
|
detailsButton: Button
|
|
98
98
|
},
|
|
99
|
-
root: slot.always(
|
|
99
|
+
root: slot.always(getIntrinsicElementProps('div', {
|
|
100
100
|
ref,
|
|
101
101
|
id: referenceId,
|
|
102
102
|
...groupSemantics,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useReference.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n Button,\n Caption1,\n getNativeElementProps,\n mergeCallbacks,\n mergeClasses,\n slot,\n useId,\n usePopoverContext_unstable as usePopoverContext,\n} from '@fluentui/react-components';\nimport {\n ChevronDown24Regular,\n ChevronUp24Regular,\n ChevronDown16Regular,\n ChevronUp16Regular,\n} from '@fluentui/react-icons';\nimport { referenceExtraClassNames } from './useReferenceStyles';\nimport { Citation } from '../Citation';\nimport type { ReferenceProps, ReferenceState } from './Reference.types';\nimport { useReferenceGroupSetOpen } from '../../context/ReferenceGroupContext';\nimport { useCopilotMode } from '@fluentui-copilot/react-provider';\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 = (props: ReferenceProps, ref: React.Ref<HTMLElement>): ReferenceState => {\n const { index, referenceId, citationHref, excerpt, layout = 'inline' } = props;\n\n const mode = useCopilotMode(props.mode);\n\n const labelId = useId();\n const mediaId = useId();\n const [isExpanded, setIsExpanded] = React.useState(layout === 'popover' ? true : false);\n\n const setPopoverOpen = usePopoverContext(context => context.setOpen);\n\n const onExpandClick: React.MouseEventHandler<HTMLButtonElement> = _e => {\n setIsExpanded(!isExpanded);\n };\n\n const label = slot.always(props.label, {\n defaultProps: { id: labelId },\n elementType: 'div',\n });\n const media = slot.optional(props.media, { defaultProps: { id: mediaId }, elementType: 'div' });\n if (media && React.isValidElement<HTMLElement>(media.children)) {\n media.children = React.cloneElement(media.children, {\n className: mergeClasses(media.children.props.className, referenceExtraClassNames.mediaChild),\n });\n }\n\n if (media?.id) {\n label['aria-describedby'] = label['aria-describedby']?.concat(media.id) ?? media.id;\n }\n\n const ariaLabelledByProp = props['aria-labelledby'];\n const groupSemantics = React.useMemo(() => {\n return layout === 'inline'\n ? {\n role: 'group',\n 'aria-labelledby': `${ariaLabelledByProp ?? ''} ${label.id}`,\n tabIndex: -1,\n }\n : {};\n }, [layout, ariaLabelledByProp, label.id]);\n\n // Within a popup, a citation should function as a close button\n const citationProps = React.useMemo(() => {\n const onPopoverCloseClick = (e: React.MouseEvent<HTMLAnchorElement>) => {\n setPopoverOpen(e, false);\n\n // don't navigate\n e.preventDefault();\n };\n\n return layout === 'popover'\n ? {\n referenceHref: '#',\n tabIndex: -1,\n 'aria-label': `Reference ${index}, close`,\n onClick: onPopoverCloseClick,\n }\n : {\n referenceHref: citationHref,\n };\n }, [layout, citationHref, index, setPopoverOpen]);\n\n const state: ReferenceState = {\n isExpanded,\n mode: layout === 'popover' ? 'sidecar' : mode,\n layout,\n index,\n components: {\n root: 'div',\n citation: 'div',\n media: 'div',\n actions: 'div',\n label: 'div',\n sensitivity: 'span',\n metadata: 'div',\n content: 'div',\n primaryText: 'span',\n secondaryText: 'span',\n tertiaryText: 'span',\n icon: 'span',\n detailsButton: Button,\n },\n root: slot.always(\n getNativeElementProps('div', {\n ref,\n id: referenceId,\n ...groupSemantics,\n ...props,\n }),\n { elementType: 'div' },\n ),\n citation: slot.optional(props.citation, {\n defaultProps: {\n children: (\n <Citation block {...citationProps}>\n {index}\n </Citation>\n ),\n },\n renderByDefault: true,\n elementType: 'div',\n }),\n media,\n actions: slot.optional(layout === 'inline' ? props.actions : null, {\n renderByDefault: true,\n elementType: 'div',\n }),\n label,\n sensitivity: slot.optional(props.sensitivity, { elementType: 'span' }),\n metadata: slot.always(props.metadata, { elementType: 'div' }),\n primaryText: slot.optional(props.primaryText, {\n defaultProps: {\n hidden: !isExpanded,\n },\n elementType: 'span',\n }),\n secondaryText: slot.optional(props.secondaryText, {\n defaultProps: {\n hidden: !isExpanded,\n },\n elementType: 'span',\n }),\n tertiaryText: slot.optional(props.tertiaryText, {\n defaultProps: {\n hidden: !isExpanded,\n },\n elementType: 'span',\n }),\n icon: slot.optional(props.icon, { elementType: 'span' }),\n content: slot.always(props.content, {\n defaultProps: {\n children: excerpt && <Caption1>{excerpt}</Caption1>,\n },\n elementType: 'div',\n }),\n detailsButton: slot.optional(layout === 'inline' ? props.detailsButton : null, {\n defaultProps: {\n appearance: 'transparent',\n 'aria-expanded': isExpanded,\n 'aria-label': 'show details',\n size: mode === 'sidecar' ? 'small' : 'medium',\n icon: {\n children: getIcon(isExpanded, mode),\n },\n },\n renderByDefault: true,\n elementType: Button,\n }),\n };\n\n if (state.detailsButton) {\n const onClick = state.detailsButton.onClick as React.MouseEventHandler<HTMLButtonElement>;\n state.detailsButton.onClick = mergeCallbacks(onClick, onExpandClick);\n }\n\n const referenceGroupSetOpen = useReferenceGroupSetOpen();\n const onTargettedByCitation = (e: React.FocusEvent<HTMLElement>) => {\n const relatedTargetHash: string | undefined = (e.relatedTarget as HTMLAnchorElement)?.hash;\n if (relatedTargetHash && relatedTargetHash.substring(1) === referenceId) {\n referenceGroupSetOpen();\n setIsExpanded(true);\n }\n };\n state.root.onFocus = mergeCallbacks(state.root.onFocus, onTargettedByCitation);\n\n return state;\n};\n\nconst getIcon = (isExpanded: boolean, mode: ReferenceProps['mode']): JSX.Element => {\n if (mode === 'sidecar') {\n return !isExpanded ? <ChevronDown16Regular /> : <ChevronUp16Regular />;\n }\n\n return !isExpanded ? <ChevronDown24Regular /> : <ChevronUp24Regular />;\n};\n"],"names":["React","Button","Caption1","getNativeElementProps","mergeCallbacks","mergeClasses","slot","useId","usePopoverContext_unstable","usePopoverContext","ChevronDown24Regular","ChevronUp24Regular","ChevronDown16Regular","ChevronUp16Regular","referenceExtraClassNames","Citation","useReferenceGroupSetOpen","useCopilotMode","useReference_unstable","props","ref","index","referenceId","citationHref","excerpt","layout","mode","labelId","mediaId","isExpanded","setIsExpanded","useState","setPopoverOpen","context","setOpen","onExpandClick","_e","label","always","defaultProps","id","elementType","media","optional","isValidElement","children","cloneElement","className","mediaChild","concat","ariaLabelledByProp","groupSemantics","useMemo","role","tabIndex","citationProps","onPopoverCloseClick","e","preventDefault","referenceHref","onClick","state","components","root","citation","actions","sensitivity","metadata","content","primaryText","secondaryText","tertiaryText","icon","detailsButton","block","renderByDefault","hidden","appearance","size","getIcon","referenceGroupSetOpen","onTargettedByCitation","relatedTargetHash","relatedTarget","hash","substring","onFocus"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,MAAM,EACNC,QAAQ,EACRC,qBAAqB,EACrBC,cAAc,EACdC,YAAY,EACZC,IAAI,EACJC,KAAK,EACLC,8BAA8BC,iBAAiB,QAC1C,6BAA6B;AACpC,SACEC,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C8C,MAAM;oBACJ3B,UAAUkC,QAAQlD,YAAYH;gBAChC;YACF;YACAiD,iBAAiB;YACjBlC,aAAaxC;QACf;IACF;IAEA,IAAI4D,MAAMY,aAAa,EAAE;QACvB,MAAMb,UAAUC,MAAMY,aAAa,CAACb,OAAO;QAC3CC,MAAMY,aAAa,CAACb,OAAO,GAAGxD,eAAewD,SAASzB;IACxD;IAEA,MAAM6C,wBAAwBhE;IAC9B,MAAMiE,wBAAwB,CAACxB;YACkBA;QAA/C,MAAMyB,qBAAyCzB,mBAAAA,EAAE0B,aAAa,cAAf1B,uCAAD,AAACA,iBAAuC2B,IAAI;QAC1F,IAAIF,qBAAqBA,kBAAkBG,SAAS,CAAC,OAAO/D,aAAa;YACvE0D;YACAlD,cAAc;QAChB;IACF;IACA+B,MAAME,IAAI,CAACuB,OAAO,GAAGlF,eAAeyD,MAAME,IAAI,CAACuB,OAAO,EAAEL;IAExD,OAAOpB;AACT,EAAE;AAEF,MAAMkB,UAAU,CAAClD,YAAqBH;IACpC,IAAIA,SAAS,WAAW;QACtB,OAAO,CAACG,2BAAa,oBAACjB,4CAA0B,oBAACC;IACnD;IAEA,OAAO,CAACgB,2BAAa,oBAACnB,4CAA0B,oBAACC;AACnD"}
|
|
1
|
+
{"version":3,"sources":["useReference.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n Button,\n Caption1,\n getIntrinsicElementProps,\n mergeCallbacks,\n mergeClasses,\n slot,\n useId,\n usePopoverContext_unstable as usePopoverContext,\n} from '@fluentui/react-components';\nimport {\n ChevronDown24Regular,\n ChevronUp24Regular,\n ChevronDown16Regular,\n ChevronUp16Regular,\n} from '@fluentui/react-icons';\nimport { referenceExtraClassNames } from './useReferenceStyles';\nimport { Citation } from '../Citation';\nimport type { ReferenceProps, ReferenceState } from './Reference.types';\nimport { useReferenceGroupSetOpen } from '../../context/ReferenceGroupContext';\nimport { useCopilotMode } from '@fluentui-copilot/react-provider';\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 = (props: ReferenceProps, ref: React.Ref<HTMLDivElement>): ReferenceState => {\n const { index, referenceId, citationHref, excerpt, layout = 'inline' } = props;\n\n const mode = useCopilotMode(props.mode);\n\n const labelId = useId();\n const mediaId = useId();\n const [isExpanded, setIsExpanded] = React.useState(layout === 'popover' ? true : false);\n\n const setPopoverOpen = usePopoverContext(context => context.setOpen);\n\n const onExpandClick: React.MouseEventHandler<HTMLButtonElement> = _e => {\n setIsExpanded(!isExpanded);\n };\n\n const label = slot.always(props.label, {\n defaultProps: { id: labelId },\n elementType: 'div',\n });\n const media = slot.optional(props.media, { defaultProps: { id: mediaId }, elementType: 'div' });\n if (media && React.isValidElement<HTMLElement>(media.children)) {\n media.children = React.cloneElement(media.children, {\n className: mergeClasses(media.children.props.className, referenceExtraClassNames.mediaChild),\n });\n }\n\n if (media?.id) {\n label['aria-describedby'] = label['aria-describedby']?.concat(media.id) ?? media.id;\n }\n\n const ariaLabelledByProp = props['aria-labelledby'];\n const groupSemantics = React.useMemo(() => {\n return layout === 'inline'\n ? {\n role: 'group',\n 'aria-labelledby': `${ariaLabelledByProp ?? ''} ${label.id}`,\n tabIndex: -1,\n }\n : {};\n }, [layout, ariaLabelledByProp, label.id]);\n\n // Within a popup, a citation should function as a close button\n const citationProps = React.useMemo(() => {\n const onPopoverCloseClick = (e: React.MouseEvent<HTMLAnchorElement>) => {\n setPopoverOpen(e, false);\n\n // don't navigate\n e.preventDefault();\n };\n\n return layout === 'popover'\n ? {\n referenceHref: '#',\n tabIndex: -1,\n 'aria-label': `Reference ${index}, close`,\n onClick: onPopoverCloseClick,\n }\n : {\n referenceHref: citationHref,\n };\n }, [layout, citationHref, index, setPopoverOpen]);\n\n const state: ReferenceState = {\n isExpanded,\n mode: layout === 'popover' ? 'sidecar' : mode,\n layout,\n index,\n components: {\n root: 'div',\n citation: 'div',\n media: 'div',\n actions: 'div',\n label: 'div',\n sensitivity: 'span',\n metadata: 'div',\n content: 'div',\n primaryText: 'span',\n secondaryText: 'span',\n tertiaryText: 'span',\n icon: 'span',\n detailsButton: Button,\n },\n root: slot.always(\n getIntrinsicElementProps('div', {\n ref,\n id: referenceId,\n ...groupSemantics,\n ...props,\n }),\n { elementType: 'div' },\n ),\n citation: slot.optional(props.citation, {\n defaultProps: {\n children: (\n <Citation block {...citationProps}>\n {index}\n </Citation>\n ),\n },\n renderByDefault: true,\n elementType: 'div',\n }),\n media,\n actions: slot.optional(layout === 'inline' ? props.actions : null, {\n renderByDefault: true,\n elementType: 'div',\n }),\n label,\n sensitivity: slot.optional(props.sensitivity, { elementType: 'span' }),\n metadata: slot.always(props.metadata, { elementType: 'div' }),\n primaryText: slot.optional(props.primaryText, {\n defaultProps: {\n hidden: !isExpanded,\n },\n elementType: 'span',\n }),\n secondaryText: slot.optional(props.secondaryText, {\n defaultProps: {\n hidden: !isExpanded,\n },\n elementType: 'span',\n }),\n tertiaryText: slot.optional(props.tertiaryText, {\n defaultProps: {\n hidden: !isExpanded,\n },\n elementType: 'span',\n }),\n icon: slot.optional(props.icon, { elementType: 'span' }),\n content: slot.always(props.content, {\n defaultProps: {\n children: excerpt && <Caption1>{excerpt}</Caption1>,\n },\n elementType: 'div',\n }),\n detailsButton: slot.optional(layout === 'inline' ? props.detailsButton : null, {\n defaultProps: {\n appearance: 'transparent',\n 'aria-expanded': isExpanded,\n 'aria-label': 'show details',\n size: mode === 'sidecar' ? 'small' : 'medium',\n icon: {\n children: getIcon(isExpanded, mode),\n },\n },\n renderByDefault: true,\n elementType: Button,\n }),\n };\n\n if (state.detailsButton) {\n const onClick = state.detailsButton.onClick as React.MouseEventHandler<HTMLButtonElement>;\n state.detailsButton.onClick = mergeCallbacks(onClick, onExpandClick);\n }\n\n const referenceGroupSetOpen = useReferenceGroupSetOpen();\n const onTargettedByCitation = (e: React.FocusEvent<HTMLElement>) => {\n const relatedTargetHash: string | undefined = (e.relatedTarget as HTMLAnchorElement)?.hash;\n if (relatedTargetHash && relatedTargetHash.substring(1) === referenceId) {\n referenceGroupSetOpen();\n setIsExpanded(true);\n }\n };\n state.root.onFocus = mergeCallbacks(state.root.onFocus, onTargettedByCitation);\n\n return state;\n};\n\nconst getIcon = (isExpanded: boolean, mode: ReferenceProps['mode']): JSX.Element => {\n if (mode === 'sidecar') {\n return !isExpanded ? <ChevronDown16Regular /> : <ChevronUp16Regular />;\n }\n\n return !isExpanded ? <ChevronDown24Regular /> : <ChevronUp24Regular />;\n};\n"],"names":["React","Button","Caption1","getIntrinsicElementProps","mergeCallbacks","mergeClasses","slot","useId","usePopoverContext_unstable","usePopoverContext","ChevronDown24Regular","ChevronUp24Regular","ChevronDown16Regular","ChevronUp16Regular","referenceExtraClassNames","Citation","useReferenceGroupSetOpen","useCopilotMode","useReference_unstable","props","ref","index","referenceId","citationHref","excerpt","layout","mode","labelId","mediaId","isExpanded","setIsExpanded","useState","setPopoverOpen","context","setOpen","onExpandClick","_e","label","always","defaultProps","id","elementType","media","optional","isValidElement","children","cloneElement","className","mediaChild","concat","ariaLabelledByProp","groupSemantics","useMemo","role","tabIndex","citationProps","onPopoverCloseClick","e","preventDefault","referenceHref","onClick","state","components","root","citation","actions","sensitivity","metadata","content","primaryText","secondaryText","tertiaryText","icon","detailsButton","block","renderByDefault","hidden","appearance","size","getIcon","referenceGroupSetOpen","onTargettedByCitation","relatedTargetHash","relatedTarget","hash","substring","onFocus"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,MAAM,EACNC,QAAQ,EACRC,wBAAwB,EACxBC,cAAc,EACdC,YAAY,EACZC,IAAI,EACJC,KAAK,EACLC,8BAA8BC,iBAAiB,QAC1C,6BAA6B;AACpC,SACEC,oBAAoB,EACpBC,kBAAkB,EAClBC,oBAAoB,EACpBC,kBAAkB,QACb,wBAAwB;AAC/B,SAASC,wBAAwB,QAAQ,uBAAu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,IAAI4D,MAAMY,aAAa,EAAE;QACvB,MAAMb,UAAUC,MAAMY,aAAa,CAACb,OAAO;QAC3CC,MAAMY,aAAa,CAACb,OAAO,GAAGxD,eAAewD,SAASzB;IACxD;IAEA,MAAM6C,wBAAwBhE;IAC9B,MAAMiE,wBAAwB,CAACxB;YACkBA;QAA/C,MAAMyB,qBAAyCzB,mBAAAA,EAAE0B,aAAa,cAAf1B,uCAAD,AAACA,iBAAuC2B,IAAI;QAC1F,IAAIF,qBAAqBA,kBAAkBG,SAAS,CAAC,OAAO/D,aAAa;YACvE0D;YACAlD,cAAc;QAChB;IACF;IACA+B,MAAME,IAAI,CAACuB,OAAO,GAAGlF,eAAeyD,MAAME,IAAI,CAACuB,OAAO,EAAEL;IAExD,OAAOpB;AACT,EAAE;AAEF,MAAMkB,UAAU,CAAClD,YAAqBH;IACpC,IAAIA,SAAS,WAAW;QACtB,OAAO,CAACG,2BAAa,oBAACjB,4CAA0B,oBAACC;IACnD;IAEA,OAAO,CAACgB,2BAAa,oBAACnB,4CAA0B,oBAACC;AACnD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { getIntrinsicElementProps, slot } from '@fluentui/react-components';
|
|
3
3
|
import { referenceListItemClassName } from './useReferenceListStyles';
|
|
4
4
|
// If you add JSX to this file, be sure to change the file type to .tsx
|
|
5
5
|
/**
|
|
@@ -16,7 +16,7 @@ export const useReferenceList_unstable = (props, ref) => {
|
|
|
16
16
|
components: {
|
|
17
17
|
root: 'ol'
|
|
18
18
|
},
|
|
19
|
-
root: slot.always(
|
|
19
|
+
root: slot.always(getIntrinsicElementProps('ol', {
|
|
20
20
|
ref,
|
|
21
21
|
...props,
|
|
22
22
|
children: React.Children.map(props.children, child => /*#__PURE__*/React.createElement("li", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useReferenceList.tsx"],"sourcesContent":["import * as React from 'react';\nimport {
|
|
1
|
+
{"version":3,"sources":["useReferenceList.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, slot } from '@fluentui/react-components';\nimport type { ReferenceListProps, ReferenceListState } from './ReferenceList.types';\nimport { referenceListItemClassName } from './useReferenceListStyles';\n\n// If you add JSX to this file, be sure to change the file type to .tsx\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<HTMLOListElement>,\n): ReferenceListState => {\n return {\n components: {\n root: 'ol',\n },\n root: slot.always(\n getIntrinsicElementProps('ol', {\n ref,\n ...props,\n children: React.Children.map(props.children, child => <li className={referenceListItemClassName}>{child}</li>),\n }),\n { elementType: 'ol' },\n ),\n };\n};\n"],"names":["React","getIntrinsicElementProps","slot","referenceListItemClassName","useReferenceList_unstable","props","ref","components","root","always","children","Children","map","child","li","className","elementType"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,wBAAwB,EAAEC,IAAI,QAAQ,6BAA6B;AAE5E,SAASC,0BAA0B,QAAQ,2BAA2B;AAEtE,uEAAuE;AAEvE;;;;;;;;CAQC,GACD,OAAO,MAAMC,4BAA4B,CACvCC,OACAC;IAEA,OAAO;QACLC,YAAY;YACVC,MAAM;QACR;QACAA,MAAMN,KAAKO,MAAM,CACfR,yBAAyB,MAAM;YAC7BK;YACA,GAAGD,KAAK;YACRK,UAAUV,MAAMW,QAAQ,CAACC,GAAG,CAACP,MAAMK,QAAQ,EAAEG,CAAAA,sBAAS,oBAACC;oBAAGC,WAAWZ;mBAA6BU;QACpG,IACA;YAAEG,aAAa;QAAK;IAExB;AACF,EAAE"}
|
|
@@ -19,11 +19,11 @@ const useCitation_unstable = (props, ref)=>{
|
|
|
19
19
|
components: {
|
|
20
20
|
root: 'a'
|
|
21
21
|
},
|
|
22
|
-
root: _reactcomponents.slot.always((0, _reactcomponents.
|
|
22
|
+
root: _reactcomponents.slot.always((0, _reactcomponents.getIntrinsicElementProps)('a', {
|
|
23
23
|
ref,
|
|
24
24
|
href: referenceHref,
|
|
25
|
-
role:
|
|
26
|
-
'aria-expanded':
|
|
25
|
+
role: undefined,
|
|
26
|
+
'aria-expanded': undefined,
|
|
27
27
|
...otherProps
|
|
28
28
|
}), {
|
|
29
29
|
elementType: 'a'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useCitation.js"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["useCitation.js"],"sourcesContent":["import { getIntrinsicElementProps, slot } from '@fluentui/react-components';\nimport { usePreviewContext_unstable } from '@fluentui-copilot/react-preview';\n/**\n * Create the state required to render Citation.\n *\n * The returned state can be modified with hooks such as useCitationStyles_unstable,\n * before being passed to renderCitation_unstable.\n *\n * @param props - props from this instance of Citation\n * @param ref - reference to root HTMLElement of Citation\n */\nexport const useCitation_unstable = (props, ref) => {\n const {\n referenceHref,\n block = false,\n ...otherProps\n } = props;\n const isPopoverLocked = usePreviewContext_unstable(ctx => ctx.isPreviewLocked) && props['aria-expanded'];\n const state = {\n block,\n isPopoverLocked,\n components: {\n root: 'a'\n },\n root: slot.always(getIntrinsicElementProps('a', {\n ref,\n href: referenceHref,\n role: undefined,\n 'aria-expanded': undefined,\n ...otherProps\n }), {\n elementType: 'a'\n })\n };\n return state;\n};\n//# sourceMappingURL=useCitation.js.map"],"names":["useCitation_unstable","props","ref","referenceHref","block","otherProps","isPopoverLocked","usePreviewContext_unstable","ctx","isPreviewLocked","state","components","root","slot","always","getIntrinsicElementProps","href","role","undefined","elementType"],"mappings":";;;;+BAWaA;;;eAAAA;;;iCAXkC;8BACJ;AAUpC,MAAMA,uBAAuB,CAACC,OAAOC;IAC1C,MAAM,EACJC,aAAa,EACbC,QAAQ,KAAK,EACb,GAAGC,YACJ,GAAGJ;IACJ,MAAMK,kBAAkBC,IAAAA,wCAA0B,EAACC,CAAAA,MAAOA,IAAIC,eAAe,KAAKR,KAAK,CAAC,gBAAgB;IACxG,MAAMS,QAAQ;QACZN;QACAE;QACAK,YAAY;YACVC,MAAM;QACR;QACAA,MAAMC,qBAAI,CAACC,MAAM,CAACC,IAAAA,yCAAwB,EAAC,KAAK;YAC9Cb;YACAc,MAAMb;YACNc,MAAMC;YACN,iBAAiBA;YACjB,GAAGb,UAAU;QACf,IAAI;YACFc,aAAa;QACf;IACF;IACA,OAAOT;AACT,GACA,uCAAuC"}
|
|
@@ -101,7 +101,7 @@ const useReference_unstable = (props, ref)=>{
|
|
|
101
101
|
icon: 'span',
|
|
102
102
|
detailsButton: _reactcomponents.Button
|
|
103
103
|
},
|
|
104
|
-
root: _reactcomponents.slot.always((0, _reactcomponents.
|
|
104
|
+
root: _reactcomponents.slot.always((0, _reactcomponents.getIntrinsicElementProps)('div', {
|
|
105
105
|
ref,
|
|
106
106
|
id: referenceId,
|
|
107
107
|
...groupSemantics,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useReference.js"],"sourcesContent":["import * as React from 'react';\nimport { Button, Caption1, getNativeElementProps, mergeCallbacks, mergeClasses, slot, useId, usePopoverContext_unstable as usePopoverContext } from '@fluentui/react-components';\nimport { ChevronDown24Regular, ChevronUp24Regular, ChevronDown16Regular, ChevronUp16Regular } from '@fluentui/react-icons';\nimport { referenceExtraClassNames } from './useReferenceStyles';\nimport { Citation } from '../Citation';\nimport { useReferenceGroupSetOpen } from '../../context/ReferenceGroupContext';\nimport { useCopilotMode } from '@fluentui-copilot/react-provider';\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 = (props, ref) => {\n const {\n index,\n referenceId,\n citationHref,\n excerpt,\n layout = 'inline'\n } = props;\n const mode = useCopilotMode(props.mode);\n const labelId = useId();\n const mediaId = useId();\n const [isExpanded, setIsExpanded] = React.useState(layout === 'popover' ? true : false);\n const setPopoverOpen = usePopoverContext(context => context.setOpen);\n const onExpandClick = _e => {\n setIsExpanded(!isExpanded);\n };\n const label = slot.always(props.label, {\n defaultProps: {\n id: labelId\n },\n elementType: 'div'\n });\n const media = slot.optional(props.media, {\n defaultProps: {\n id: mediaId\n },\n elementType: 'div'\n });\n if (media && /*#__PURE__*/React.isValidElement(media.children)) {\n media.children = /*#__PURE__*/React.cloneElement(media.children, {\n className: mergeClasses(media.children.props.className, referenceExtraClassNames.mediaChild)\n });\n }\n if (media === null || media === void 0 ? void 0 : media.id) {\n var _label_ariadescribedby;\n var _label_ariadescribedby_concat;\n label['aria-describedby'] = (_label_ariadescribedby_concat = (_label_ariadescribedby = label['aria-describedby']) === null || _label_ariadescribedby === void 0 ? void 0 : _label_ariadescribedby.concat(media.id)) !== null && _label_ariadescribedby_concat !== void 0 ? _label_ariadescribedby_concat : media.id;\n }\n const ariaLabelledByProp = props['aria-labelledby'];\n const groupSemantics = React.useMemo(() => {\n return layout === 'inline' ? {\n role: 'group',\n 'aria-labelledby': `${ariaLabelledByProp !== null && ariaLabelledByProp !== void 0 ? ariaLabelledByProp : ''} ${label.id}`,\n tabIndex: -1\n } : {};\n }, [layout, ariaLabelledByProp, label.id]);\n // Within a popup, a citation should function as a close button\n const citationProps = React.useMemo(() => {\n const onPopoverCloseClick = e => {\n setPopoverOpen(e, false);\n // don't navigate\n e.preventDefault();\n };\n return layout === 'popover' ? {\n referenceHref: '#',\n tabIndex: -1,\n 'aria-label': `Reference ${index}, close`,\n onClick: onPopoverCloseClick\n } : {\n referenceHref: citationHref\n };\n }, [layout, citationHref, index, setPopoverOpen]);\n const state = {\n isExpanded,\n mode: layout === 'popover' ? 'sidecar' : mode,\n layout,\n index,\n components: {\n root: 'div',\n citation: 'div',\n media: 'div',\n actions: 'div',\n label: 'div',\n sensitivity: 'span',\n metadata: 'div',\n content: 'div',\n primaryText: 'span',\n secondaryText: 'span',\n tertiaryText: 'span',\n icon: 'span',\n detailsButton: Button\n },\n root: slot.always(getNativeElementProps('div', {\n ref,\n id: referenceId,\n ...groupSemantics,\n ...props\n }), {\n elementType: 'div'\n }),\n citation: slot.optional(props.citation, {\n defaultProps: {\n children: /*#__PURE__*/React.createElement(Citation, {\n block: true,\n ...citationProps\n }, index)\n },\n renderByDefault: true,\n elementType: 'div'\n }),\n media,\n actions: slot.optional(layout === 'inline' ? props.actions : null, {\n renderByDefault: true,\n elementType: 'div'\n }),\n label,\n sensitivity: slot.optional(props.sensitivity, {\n elementType: 'span'\n }),\n metadata: slot.always(props.metadata, {\n elementType: 'div'\n }),\n primaryText: slot.optional(props.primaryText, {\n defaultProps: {\n hidden: !isExpanded\n },\n elementType: 'span'\n }),\n secondaryText: slot.optional(props.secondaryText, {\n defaultProps: {\n hidden: !isExpanded\n },\n elementType: 'span'\n }),\n tertiaryText: slot.optional(props.tertiaryText, {\n defaultProps: {\n hidden: !isExpanded\n },\n elementType: 'span'\n }),\n icon: slot.optional(props.icon, {\n elementType: 'span'\n }),\n content: slot.always(props.content, {\n defaultProps: {\n children: excerpt && /*#__PURE__*/React.createElement(Caption1, null, excerpt)\n },\n elementType: 'div'\n }),\n detailsButton: slot.optional(layout === 'inline' ? props.detailsButton : null, {\n defaultProps: {\n appearance: 'transparent',\n 'aria-expanded': isExpanded,\n 'aria-label': 'show details',\n size: mode === 'sidecar' ? 'small' : 'medium',\n icon: {\n children: getIcon(isExpanded, mode)\n }\n },\n renderByDefault: true,\n elementType: Button\n })\n };\n if (state.detailsButton) {\n const onClick = state.detailsButton.onClick;\n state.detailsButton.onClick = mergeCallbacks(onClick, onExpandClick);\n }\n const referenceGroupSetOpen = useReferenceGroupSetOpen();\n const onTargettedByCitation = e => {\n var _e_relatedTarget;\n const relatedTargetHash = (_e_relatedTarget = e.relatedTarget) === null || _e_relatedTarget === void 0 ? void 0 : _e_relatedTarget.hash;\n if (relatedTargetHash && relatedTargetHash.substring(1) === referenceId) {\n referenceGroupSetOpen();\n setIsExpanded(true);\n }\n };\n state.root.onFocus = mergeCallbacks(state.root.onFocus, onTargettedByCitation);\n return state;\n};\nconst getIcon = (isExpanded, mode) => {\n if (mode === 'sidecar') {\n return !isExpanded ? /*#__PURE__*/React.createElement(ChevronDown16Regular, null) : /*#__PURE__*/React.createElement(ChevronUp16Regular, null);\n }\n return !isExpanded ? /*#__PURE__*/React.createElement(ChevronDown24Regular, null) : /*#__PURE__*/React.createElement(ChevronUp24Regular, null);\n};\n//# sourceMappingURL=useReference.js.map"],"names":["useReference_unstable","props","ref","index","referenceId","citationHref","excerpt","layout","mode","useCopilotMode","labelId","useId","mediaId","isExpanded","setIsExpanded","React","useState","setPopoverOpen","usePopoverContext","context","setOpen","onExpandClick","_e","label","slot","always","defaultProps","id","elementType","media","optional","isValidElement","children","cloneElement","className","mergeClasses","referenceExtraClassNames","mediaChild","_label_ariadescribedby","_label_ariadescribedby_concat","concat","ariaLabelledByProp","groupSemantics","useMemo","role","tabIndex","citationProps","onPopoverCloseClick","e","preventDefault","referenceHref","onClick","state","components","root","citation","actions","sensitivity","metadata","content","primaryText","secondaryText","tertiaryText","icon","detailsButton","Button","getNativeElementProps","createElement","Citation","block","renderByDefault","hidden","Caption1","appearance","size","getIcon","mergeCallbacks","referenceGroupSetOpen","useReferenceGroupSetOpen","onTargettedByCitation","_e_relatedTarget","relatedTargetHash","relatedTarget","hash","substring","onFocus","ChevronDown16Regular","ChevronUp16Regular","ChevronDown24Regular","ChevronUp24Regular"],"mappings":";;;;+BAgBaA;;;eAAAA;;;;iEAhBU;iCAC6H;4BACjD;oCAC1D;0BAChB;uCACgB;+BACV;AAUxB,MAAMA,wBAAwB,CAACC,OAAOC;IAC3C,MAAM,EACJC,KAAK,EACLC,WAAW,EACXC,YAAY,EACZC,OAAO,EACPC,SAAS,QAAQ,EAClB,GAAGN;IACJ,MAAMO,OAAOC,IAAA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;gBAChC;YACF;YACA8D,iBAAiB;YACjB1C,aAAaqC,uBAAM;QACrB;IACF;IACA,IAAIb,MAAMY,aAAa,EAAE;QACvB,MAAMb,UAAUC,MAAMY,aAAa,CAACb,OAAO;QAC3CC,MAAMY,aAAa,CAACb,OAAO,GAAGyB,IAAAA,+BAAc,EAACzB,SAAS9B;IACxD;IACA,MAAMwD,wBAAwBC,IAAAA,+CAAwB;IACtD,MAAMC,wBAAwB/B,CAAAA;QAC5B,IAAIgC;QACJ,MAAMC,oBAAoB,AAACD,CAAAA,mBAAmBhC,EAAEkC,aAAa,AAAD,MAAO,QAAQF,qBAAqB,KAAK,IAAI,KAAK,IAAIA,iBAAiBG,IAAI;QACvI,IAAIF,qBAAqBA,kBAAkBG,SAAS,CAAC,OAAOhF,aAAa;YACvEyE;YACA/D,cAAc;QAChB;IACF;IACAsC,MAAME,IAAI,CAAC+B,OAAO,GAAGT,IAAAA,+BAAc,EAACxB,MAAME,IAAI,CAAC+B,OAAO,EAAEN;IACxD,OAAO3B;AACT;AACA,MAAMuB,UAAU,CAAC9D,YAAYL;IAC3B,IAAIA,SAAS,WAAW;QACtB,OAAO,CAACK,aAAa,WAAW,GAAEE,OAAMoD,aAAa,CAACmB,gCAAoB,EAAE,QAAQ,WAAW,GAAEvE,OAAMoD,aAAa,CAACoB,8BAAkB,EAAE;IAC3I;IACA,OAAO,CAAC1E,aAAa,WAAW,GAAEE,OAAMoD,aAAa,CAACqB,gCAAoB,EAAE,QAAQ,WAAW,GAAEzE,OAAMoD,aAAa,CAACsB,8BAAkB,EAAE;AAC3I,GACA,wCAAwC"}
|
|
1
|
+
{"version":3,"sources":["useReference.js"],"sourcesContent":["import * as React from 'react';\nimport { Button, Caption1, getIntrinsicElementProps, mergeCallbacks, mergeClasses, slot, useId, usePopoverContext_unstable as usePopoverContext } from '@fluentui/react-components';\nimport { ChevronDown24Regular, ChevronUp24Regular, ChevronDown16Regular, ChevronUp16Regular } from '@fluentui/react-icons';\nimport { referenceExtraClassNames } from './useReferenceStyles';\nimport { Citation } from '../Citation';\nimport { useReferenceGroupSetOpen } from '../../context/ReferenceGroupContext';\nimport { useCopilotMode } from '@fluentui-copilot/react-provider';\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 = (props, ref) => {\n const {\n index,\n referenceId,\n citationHref,\n excerpt,\n layout = 'inline'\n } = props;\n const mode = useCopilotMode(props.mode);\n const labelId = useId();\n const mediaId = useId();\n const [isExpanded, setIsExpanded] = React.useState(layout === 'popover' ? true : false);\n const setPopoverOpen = usePopoverContext(context => context.setOpen);\n const onExpandClick = _e => {\n setIsExpanded(!isExpanded);\n };\n const label = slot.always(props.label, {\n defaultProps: {\n id: labelId\n },\n elementType: 'div'\n });\n const media = slot.optional(props.media, {\n defaultProps: {\n id: mediaId\n },\n elementType: 'div'\n });\n if (media && /*#__PURE__*/React.isValidElement(media.children)) {\n media.children = /*#__PURE__*/React.cloneElement(media.children, {\n className: mergeClasses(media.children.props.className, referenceExtraClassNames.mediaChild)\n });\n }\n if (media === null || media === void 0 ? void 0 : media.id) {\n var _label_ariadescribedby;\n var _label_ariadescribedby_concat;\n label['aria-describedby'] = (_label_ariadescribedby_concat = (_label_ariadescribedby = label['aria-describedby']) === null || _label_ariadescribedby === void 0 ? void 0 : _label_ariadescribedby.concat(media.id)) !== null && _label_ariadescribedby_concat !== void 0 ? _label_ariadescribedby_concat : media.id;\n }\n const ariaLabelledByProp = props['aria-labelledby'];\n const groupSemantics = React.useMemo(() => {\n return layout === 'inline' ? {\n role: 'group',\n 'aria-labelledby': `${ariaLabelledByProp !== null && ariaLabelledByProp !== void 0 ? ariaLabelledByProp : ''} ${label.id}`,\n tabIndex: -1\n } : {};\n }, [layout, ariaLabelledByProp, label.id]);\n // Within a popup, a citation should function as a close button\n const citationProps = React.useMemo(() => {\n const onPopoverCloseClick = e => {\n setPopoverOpen(e, false);\n // don't navigate\n e.preventDefault();\n };\n return layout === 'popover' ? {\n referenceHref: '#',\n tabIndex: -1,\n 'aria-label': `Reference ${index}, close`,\n onClick: onPopoverCloseClick\n } : {\n referenceHref: citationHref\n };\n }, [layout, citationHref, index, setPopoverOpen]);\n const state = {\n isExpanded,\n mode: layout === 'popover' ? 'sidecar' : mode,\n layout,\n index,\n components: {\n root: 'div',\n citation: 'div',\n media: 'div',\n actions: 'div',\n label: 'div',\n sensitivity: 'span',\n metadata: 'div',\n content: 'div',\n primaryText: 'span',\n secondaryText: 'span',\n tertiaryText: 'span',\n icon: 'span',\n detailsButton: Button\n },\n root: slot.always(getIntrinsicElementProps('div', {\n ref,\n id: referenceId,\n ...groupSemantics,\n ...props\n }), {\n elementType: 'div'\n }),\n citation: slot.optional(props.citation, {\n defaultProps: {\n children: /*#__PURE__*/React.createElement(Citation, {\n block: true,\n ...citationProps\n }, index)\n },\n renderByDefault: true,\n elementType: 'div'\n }),\n media,\n actions: slot.optional(layout === 'inline' ? props.actions : null, {\n renderByDefault: true,\n elementType: 'div'\n }),\n label,\n sensitivity: slot.optional(props.sensitivity, {\n elementType: 'span'\n }),\n metadata: slot.always(props.metadata, {\n elementType: 'div'\n }),\n primaryText: slot.optional(props.primaryText, {\n defaultProps: {\n hidden: !isExpanded\n },\n elementType: 'span'\n }),\n secondaryText: slot.optional(props.secondaryText, {\n defaultProps: {\n hidden: !isExpanded\n },\n elementType: 'span'\n }),\n tertiaryText: slot.optional(props.tertiaryText, {\n defaultProps: {\n hidden: !isExpanded\n },\n elementType: 'span'\n }),\n icon: slot.optional(props.icon, {\n elementType: 'span'\n }),\n content: slot.always(props.content, {\n defaultProps: {\n children: excerpt && /*#__PURE__*/React.createElement(Caption1, null, excerpt)\n },\n elementType: 'div'\n }),\n detailsButton: slot.optional(layout === 'inline' ? props.detailsButton : null, {\n defaultProps: {\n appearance: 'transparent',\n 'aria-expanded': isExpanded,\n 'aria-label': 'show details',\n size: mode === 'sidecar' ? 'small' : 'medium',\n icon: {\n children: getIcon(isExpanded, mode)\n }\n },\n renderByDefault: true,\n elementType: Button\n })\n };\n if (state.detailsButton) {\n const onClick = state.detailsButton.onClick;\n state.detailsButton.onClick = mergeCallbacks(onClick, onExpandClick);\n }\n const referenceGroupSetOpen = useReferenceGroupSetOpen();\n const onTargettedByCitation = e => {\n var _e_relatedTarget;\n const relatedTargetHash = (_e_relatedTarget = e.relatedTarget) === null || _e_relatedTarget === void 0 ? void 0 : _e_relatedTarget.hash;\n if (relatedTargetHash && relatedTargetHash.substring(1) === referenceId) {\n referenceGroupSetOpen();\n setIsExpanded(true);\n }\n };\n state.root.onFocus = mergeCallbacks(state.root.onFocus, onTargettedByCitation);\n return state;\n};\nconst getIcon = (isExpanded, mode) => {\n if (mode === 'sidecar') {\n return !isExpanded ? /*#__PURE__*/React.createElement(ChevronDown16Regular, null) : /*#__PURE__*/React.createElement(ChevronUp16Regular, null);\n }\n return !isExpanded ? /*#__PURE__*/React.createElement(ChevronDown24Regular, null) : /*#__PURE__*/React.createElement(ChevronUp24Regular, null);\n};\n//# sourceMappingURL=useReference.js.map"],"names":["useReference_unstable","props","ref","index","referenceId","citationHref","excerpt","layout","mode","useCopilotMode","labelId","useId","mediaId","isExpanded","setIsExpanded","React","useState","setPopoverOpen","usePopoverContext","context","setOpen","onExpandClick","_e","label","slot","always","defaultProps","id","elementType","media","optional","isValidElement","children","cloneElement","className","mergeClasses","referenceExtraClassNames","mediaChild","_label_ariadescribedby","_label_ariadescribedby_concat","concat","ariaLabelledByProp","groupSemantics","useMemo","role","tabIndex","citationProps","onPopoverCloseClick","e","preventDefault","referenceHref","onClick","state","components","root","citation","actions","sensitivity","metadata","content","primaryText","secondaryText","tertiaryText","icon","detailsButton","Button","getIntrinsicElementProps","createElement","Citation","block","renderByDefault","hidden","Caption1","appearance","size","getIcon","mergeCallbacks","referenceGroupSetOpen","useReferenceGroupSetOpen","onTargettedByCitation","_e_relatedTarget","relatedTargetHash","relatedTarget","hash","substring","onFocus","ChevronDown16Regular","ChevronUp16Regular","ChevronDown24Regular","ChevronUp24Regular"],"mappings":";;;;+BAgBaA;;;eAAAA;;;;iEAhBU;iCACgI;4BACpD;oCAC1D;0BAChB;uCACgB;+BACV;AAUxB,MAAMA,wBAAwB,CAACC,OAAOC;IAC3C,MAAM,EACJC,KAAK,EACLC,WAAW,EACXC,YAAY,EACZC,OAAO,EACPC,SAAS,QAAQ,EAClB,GAAGN;IACJ,MAAMO,OAAOC,IAAAA,6BAAc,EAACR,MAAMO,IAAI;IACtC,MAAME,UAAUC,IAAAA,sBAAK;IACrB,MAAMC,UAAUD,IAAAA,sBAAK;IACrB,MAAM,CAACE,YAAYC,cAAc,GAAGC,OAAMC,QAAQ,CAACT,WAAW,YAAY,OAAO;IACjF,MAAMU,iBAAiBC,IAAAA,2CAAiB,EAACC,CAAAA,UAAWA,QAAQC,OAAO;IACnE,MAAMC,gBAAgBC,CAAAA;QACpBR,cAAc,CAACD;IACjB;IACA,MAAMU,QAAQC,qBAAI,CAACC,MAAM,CAACxB,MAAMsB,KAAK,EAAE;QACrCG,cAAc;YACZC,IAAIjB;QACN;QACAkB,aAAa;IACf;IACA,MAAMC,QAAQL,qBAAI,CAACM,QAAQ,CAAC7B,MAAM4B,KAAK,EAAE;QACvCH,cAAc;YACZC,IAAIf;QACN;QACAgB,aAAa;IACf;IACA,IAAIC,SAAS,WAAW,GAAEd,OAAMgB,cAAc,CAACF,MAAMG,QAAQ,GAAG;QAC9DH,MAAMG,QAAQ,GAAG,WAAW,GAAEjB,OAAMkB,YAAY,CAACJ,MAAMG,QAAQ,EAAE;YAC/DE,WAAWC,IAAAA,6BAAY,EAACN,MAAMG,QAAQ,CAAC/B,KAAK,CAACiC,SAAS,EAAEE,4CAAwB,CAACC,UAAU;QAC7F;IACF;IACA,IAAIR,UAAU,QAAQA,UAAU,KAAK,IAAI,KAAK,IAAIA,MAAMF,EAAE,EAAE;QAC1D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ACqB,gCAAoB,EAAE,QAAQ,WAAW,GAAEzE,OAAMoD,aAAa,CAACsB,8BAAkB,EAAE;AAC3I,GACA,wCAAwC"}
|
|
@@ -17,7 +17,7 @@ const useReferenceList_unstable = (props, ref)=>{
|
|
|
17
17
|
components: {
|
|
18
18
|
root: 'ol'
|
|
19
19
|
},
|
|
20
|
-
root: _reactcomponents.slot.always((0, _reactcomponents.
|
|
20
|
+
root: _reactcomponents.slot.always((0, _reactcomponents.getIntrinsicElementProps)('ol', {
|
|
21
21
|
ref,
|
|
22
22
|
...props,
|
|
23
23
|
children: _react.Children.map(props.children, (child)=>/*#__PURE__*/ _react.createElement("li", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useReferenceList.js"],"sourcesContent":["import * as React from 'react';\nimport {
|
|
1
|
+
{"version":3,"sources":["useReferenceList.js"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, slot } from '@fluentui/react-components';\nimport { referenceListItemClassName } from './useReferenceListStyles';\n// If you add JSX to this file, be sure to change the file type to .tsx\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 = (props, ref) => {\n return {\n components: {\n root: 'ol'\n },\n root: slot.always(getIntrinsicElementProps('ol', {\n ref,\n ...props,\n children: React.Children.map(props.children, child => /*#__PURE__*/React.createElement(\"li\", {\n className: referenceListItemClassName\n }, child))\n }), {\n elementType: 'ol'\n })\n };\n};\n//# sourceMappingURL=useReferenceList.js.map"],"names":["useReferenceList_unstable","props","ref","components","root","slot","always","getIntrinsicElementProps","children","React","Children","map","child","createElement","className","referenceListItemClassName","elementType"],"mappings":";;;;+BAaaA;;;eAAAA;;;;iEAbU;iCACwB;wCACJ;AAWpC,MAAMA,4BAA4B,CAACC,OAAOC;IAC/C,OAAO;QACLC,YAAY;YACVC,MAAM;QACR;QACAA,MAAMC,qBAAI,CAACC,MAAM,CAACC,IAAAA,yCAAwB,EAAC,MAAM;YAC/CL;YACA,GAAGD,KAAK;YACRO,UAAUC,OAAMC,QAAQ,CAACC,GAAG,CAACV,MAAMO,QAAQ,EAAEI,CAAAA,QAAS,WAAW,GAAEH,OAAMI,aAAa,CAAC,MAAM;oBAC3FC,WAAWC,kDAA0B;gBACvC,GAAGH;QACL,IAAI;YACFI,aAAa;QACf;IACF;AACF,GACA,4CAA4C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui-copilot/react-reference",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Fluent AI controls for citations and references",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@fluentui-copilot/react-preview": "^0.
|
|
15
|
+
"@fluentui-copilot/react-preview": "^0.4.0",
|
|
16
16
|
"@fluentui-copilot/react-provider": "^0.8.0",
|
|
17
|
-
"@fluentui-copilot/react-sensitivity-label": "^0.
|
|
17
|
+
"@fluentui-copilot/react-sensitivity-label": "^0.4.0",
|
|
18
18
|
"@swc/helpers": "^0.5.1"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|