@fluentui/react-teaching-popover 9.7.6 → 9.7.8
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.md +27 -2
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/lib/components/TeachingPopoverCarousel/Carousel/Carousel.js +43 -9
- package/lib/components/TeachingPopoverCarousel/Carousel/Carousel.js.map +1 -1
- package/lib/components/TeachingPopoverCarousel/Carousel/Carousel.types.js.map +1 -1
- package/lib-commonjs/components/TeachingPopoverCarousel/Carousel/Carousel.cjs +41 -7
- package/lib-commonjs/components/TeachingPopoverCarousel/Carousel/Carousel.cjs.map +1 -1
- package/lib-commonjs/components/TeachingPopoverCarousel/Carousel/Carousel.types.cjs.map +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-teaching-popover
|
|
2
2
|
|
|
3
|
-
<!-- This log was last generated on Mon,
|
|
3
|
+
<!-- This log was last generated on Mon, 19 Oct 2026 14:49:10 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.7.8](https://github.com/microsoft/fluentui/tree/@fluentui/react-teaching-popover_v9.7.8)
|
|
8
|
+
|
|
9
|
+
Mon, 19 Oct 2026 14:49:10 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-teaching-popover_v9.7.7..@fluentui/react-teaching-popover_v9.7.8)
|
|
11
|
+
|
|
12
|
+
### Patches
|
|
13
|
+
|
|
14
|
+
- fix: Announce carousel page changes after render. ([PR #36643](https://github.com/microsoft/fluentui/pull/36643) by paulmardling@microsoft.com)
|
|
15
|
+
- Bump @fluentui/react-aria to v9.17.16 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
|
|
16
|
+
- Bump @fluentui/react-button to v9.11.2 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
|
|
17
|
+
- Bump @fluentui/react-context-selector to v9.2.21 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
|
|
18
|
+
- Bump @fluentui/react-jsx-runtime to v9.4.7 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
|
|
19
|
+
- Bump @fluentui/react-popover to v9.14.10 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
|
|
20
|
+
- Bump @fluentui/react-tabster to v9.26.19 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
|
|
21
|
+
- Bump @fluentui/react-utilities to v9.27.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
|
|
22
|
+
|
|
23
|
+
## [9.7.7](https://github.com/microsoft/fluentui/tree/@fluentui/react-teaching-popover_v9.7.7)
|
|
24
|
+
|
|
25
|
+
Wed, 23 Sep 2026 09:04:33 GMT
|
|
26
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-teaching-popover_v9.7.6..@fluentui/react-teaching-popover_v9.7.7)
|
|
27
|
+
|
|
28
|
+
### Patches
|
|
29
|
+
|
|
30
|
+
- Bump @fluentui/react-popover to v9.14.9 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
|
|
31
|
+
|
|
7
32
|
## [9.7.6](https://github.com/microsoft/fluentui/tree/@fluentui/react-teaching-popover_v9.7.6)
|
|
8
33
|
|
|
9
|
-
|
|
34
|
+
Tue, 22 Sep 2026 11:25:39 GMT
|
|
10
35
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-teaching-popover_v9.7.5..@fluentui/react-teaching-popover_v9.7.6)
|
|
11
36
|
|
|
12
37
|
### Patches
|
package/dist/index.d.cts
CHANGED
|
@@ -600,8 +600,9 @@ export declare type TeachingPopoverTriggerState = PopoverTriggerState;
|
|
|
600
600
|
|
|
601
601
|
declare type UseCarouselOptions = {
|
|
602
602
|
/**
|
|
603
|
-
* Localizes the string used to announce carousel page changes to screen reader users
|
|
604
|
-
*
|
|
603
|
+
* Localizes the string used to announce carousel page changes to screen reader users.
|
|
604
|
+
* Runs after the destination page renders. When omitted, page changes are not announced.
|
|
605
|
+
* Return an empty string to suppress an announcement.
|
|
605
606
|
*/
|
|
606
607
|
announcement?: (newValue: string) => string;
|
|
607
608
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -600,8 +600,9 @@ export declare type TeachingPopoverTriggerState = PopoverTriggerState;
|
|
|
600
600
|
|
|
601
601
|
declare type UseCarouselOptions = {
|
|
602
602
|
/**
|
|
603
|
-
* Localizes the string used to announce carousel page changes to screen reader users
|
|
604
|
-
*
|
|
603
|
+
* Localizes the string used to announce carousel page changes to screen reader users.
|
|
604
|
+
* Runs after the destination page renders. When omitted, page changes are not announced.
|
|
605
|
+
* Return an empty string to suppress an announcement.
|
|
605
606
|
*/
|
|
606
607
|
announcement?: (newValue: string) => string;
|
|
607
608
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { isHTMLElement, useMergedRefs, useControllableState, useEventCallback } from "@fluentui/react-utilities";
|
|
3
|
+
import { isHTMLElement, useMergedRefs, useControllableState, useEventCallback, useIsomorphicLayoutEffect } from "@fluentui/react-utilities";
|
|
4
4
|
import { useAnnounce, useFluent_unstable as useFluent } from "@fluentui/react-shared-contexts";
|
|
5
|
-
import { CAROUSEL_ITEM } from "./constants.js";
|
|
5
|
+
import { CAROUSEL_ACTIVE_ITEM, CAROUSEL_ITEM } from "./constants.js";
|
|
6
6
|
import { useCarouselWalker_unstable } from "./useCarouselWalker.js";
|
|
7
7
|
import { createCarouselStore } from "./createCarouselStore.js";
|
|
8
8
|
// TODO: Migrate this into an external @fluentui/carousel component
|
|
@@ -20,6 +20,41 @@ export function useCarousel_unstable(options) {
|
|
|
20
20
|
});
|
|
21
21
|
const rootRef = React.useRef(null);
|
|
22
22
|
const { announce } = useAnnounce();
|
|
23
|
+
const previousValueRef = React.useRef(value);
|
|
24
|
+
const pendingAnnouncementRef = React.useRef(null);
|
|
25
|
+
const announcePage = useEventCallback(()=>{
|
|
26
|
+
const pendingValue = pendingAnnouncementRef.current;
|
|
27
|
+
const active = carouselWalker.active();
|
|
28
|
+
if (pendingValue === null || (active === null || active === void 0 ? void 0 : active.value) !== pendingValue) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
pendingAnnouncementRef.current = null;
|
|
32
|
+
const text = announcement === null || announcement === void 0 ? void 0 : announcement(pendingValue);
|
|
33
|
+
if (text) {
|
|
34
|
+
announce(text, {
|
|
35
|
+
polite: true
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
useIsomorphicLayoutEffect(()=>{
|
|
40
|
+
if (!announcement) {
|
|
41
|
+
pendingAnnouncementRef.current = null;
|
|
42
|
+
}
|
|
43
|
+
if (previousValueRef.current === value) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
previousValueRef.current = value;
|
|
47
|
+
pendingAnnouncementRef.current = null;
|
|
48
|
+
if (value === null || !announcement) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
pendingAnnouncementRef.current = value;
|
|
52
|
+
announcePage();
|
|
53
|
+
}, [
|
|
54
|
+
value,
|
|
55
|
+
announcement,
|
|
56
|
+
announcePage
|
|
57
|
+
]);
|
|
23
58
|
if (process.env.NODE_ENV !== 'production') {
|
|
24
59
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
25
60
|
React.useEffect(()=>{
|
|
@@ -50,7 +85,8 @@ export function useCarousel_unstable(options) {
|
|
|
50
85
|
const config = {
|
|
51
86
|
attributes: true,
|
|
52
87
|
attributeFilter: [
|
|
53
|
-
CAROUSEL_ITEM
|
|
88
|
+
CAROUSEL_ITEM,
|
|
89
|
+
CAROUSEL_ACTIVE_ITEM
|
|
54
90
|
],
|
|
55
91
|
childList: true,
|
|
56
92
|
subtree: true
|
|
@@ -77,6 +113,8 @@ export function useCarousel_unstable(options) {
|
|
|
77
113
|
}
|
|
78
114
|
}
|
|
79
115
|
}
|
|
116
|
+
// Selector-based context updates can commit cards after the carousel's layout effect.
|
|
117
|
+
announcePage();
|
|
80
118
|
};
|
|
81
119
|
// Create an observer instance linked to the callback function
|
|
82
120
|
const observer = new win.MutationObserver(callback);
|
|
@@ -85,8 +123,10 @@ export function useCarousel_unstable(options) {
|
|
|
85
123
|
// Later, you can stop observing
|
|
86
124
|
return ()=>{
|
|
87
125
|
observer.disconnect();
|
|
126
|
+
pendingAnnouncementRef.current = null;
|
|
88
127
|
};
|
|
89
128
|
}, [
|
|
129
|
+
announcePage,
|
|
90
130
|
carouselWalker,
|
|
91
131
|
store,
|
|
92
132
|
win
|
|
@@ -98,12 +138,6 @@ export function useCarousel_unstable(options) {
|
|
|
98
138
|
type: 'click',
|
|
99
139
|
value: newValue
|
|
100
140
|
});
|
|
101
|
-
const announceText = announcement === null || announcement === void 0 ? void 0 : announcement(newValue);
|
|
102
|
-
if (announceText) {
|
|
103
|
-
announce(announceText, {
|
|
104
|
-
polite: true
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
141
|
});
|
|
108
142
|
const selectPageByDirection = useEventCallback((event, direction)=>{
|
|
109
143
|
const active = carouselWalker.active();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TeachingPopoverCarousel/Carousel/Carousel.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { isHTMLElement, useMergedRefs, useControllableState, useEventCallback } from '@fluentui/react-utilities';\nimport { useAnnounce, useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\nimport { CAROUSEL_ITEM } from './constants';\nimport { useCarouselWalker_unstable } from './useCarouselWalker';\nimport { createCarouselStore } from './createCarouselStore';\nimport type { CarouselStore, UseCarouselOptions } from './Carousel.types';\nimport type { CarouselContextValue } from './CarouselContext';\n\n// TODO: Migrate this into an external @fluentui/carousel component\n// For now, we won't export this publicly, is only for internal TeachingPopover use until stabilized.\nexport function useCarousel_unstable(options: UseCarouselOptions): {\n carouselRef: React.RefObject<HTMLDivElement | null>;\n carousel: {\n store: CarouselStore;\n value: string | null;\n selectPageByDirection: (\n event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>,\n direction: 'next' | 'prev',\n ) => void;\n selectPageByValue: (event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>, newValue: string) => void;\n };\n} {\n const { announcement, onValueChange, onFinish } = options;\n\n const { targetDocument } = useFluent();\n const win = targetDocument?.defaultView;\n const { ref: carouselRef, walker: carouselWalker } = useCarouselWalker_unstable();\n const [store] = React.useState(() => createCarouselStore());\n\n const [value, setValue] = useControllableState({\n defaultState: options.defaultValue,\n state: options.value,\n initialState: null,\n });\n const rootRef = React.useRef<HTMLDivElement>(null);\n\n const { announce } = useAnnounce();\n\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (value === null) {\n // eslint-disable-next-line no-console\n console.error(\n 'useCarousel: Carousel needs to have a `defaultValue` or `value` prop set. If you want to control the value, use the `value` prop.',\n );\n }\n }, [value]);\n }\n\n React.useEffect(() => {\n const allItems = rootRef.current?.querySelectorAll(`[${CAROUSEL_ITEM}]`)!;\n\n for (let i = 0; i < allItems.length; i++) {\n store.addValue(allItems.item(i).getAttribute(CAROUSEL_ITEM)!);\n }\n\n return () => {\n store.clear();\n };\n }, [store]);\n\n React.useEffect(() => {\n if (!win) {\n return;\n }\n\n const config: MutationObserverInit = {\n attributes: true,\n attributeFilter: [CAROUSEL_ITEM],\n childList: true,\n subtree: true,\n };\n\n // Callback function to execute when mutations are observed\n const callback: MutationCallback = mutationList => {\n for (const mutation of mutationList) {\n for (const addedNode of Array.from(mutation.addedNodes)) {\n if (isHTMLElement(addedNode) && addedNode.hasAttribute(CAROUSEL_ITEM)) {\n const newValue = addedNode.getAttribute(CAROUSEL_ITEM)!;\n const newNode = carouselWalker.find(newValue);\n if (!newNode?.value) {\n return;\n }\n\n const previousNode = carouselWalker.prevPage(newNode?.value);\n store.insertValue(newValue, previousNode?.value ?? null);\n }\n }\n\n for (const removedNode of Array.from(mutation.removedNodes)) {\n if (isHTMLElement(removedNode) && removedNode?.hasAttribute(CAROUSEL_ITEM)) {\n const removedValue = removedNode.getAttribute(CAROUSEL_ITEM)!;\n\n store.removeValue(removedValue);\n }\n }\n }\n };\n\n // Create an observer instance linked to the callback function\n const observer = new win.MutationObserver(callback);\n\n // Start observing the target node for configured mutations\n observer.observe(rootRef.current!, config);\n\n // Later, you can stop observing\n return () => {\n observer.disconnect();\n };\n }, [carouselWalker, store, win]);\n\n const updateSlide = useEventCallback(\n (event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>, newValue: string) => {\n setValue(newValue);\n onValueChange?.(event, { event, type: 'click', value: newValue });\n\n const announceText = announcement?.(newValue);\n if (announceText) {\n announce(announceText, { polite: true });\n }\n },\n );\n\n const selectPageByDirection: CarouselContextValue['selectPageByDirection'] = useEventCallback((event, direction) => {\n const active = carouselWalker.active();\n\n if (!active?.value) {\n return;\n }\n\n const newPage =\n direction === 'prev' ? carouselWalker.prevPage(active.value) : carouselWalker.nextPage(active.value);\n\n if (newPage) {\n updateSlide(event, newPage?.value);\n } else {\n onFinish?.(event, { event, type: 'click', value: active?.value });\n }\n });\n\n return {\n carouselRef: useMergedRefs(rootRef, carouselRef),\n carousel: {\n store,\n value,\n selectPageByDirection,\n selectPageByValue: updateSlide,\n },\n };\n}\n"],"names":["React","isHTMLElement","useMergedRefs","useControllableState","useEventCallback","useAnnounce","useFluent_unstable","useFluent","CAROUSEL_ITEM","useCarouselWalker_unstable","createCarouselStore","useCarousel_unstable","options","announcement","onValueChange","onFinish","targetDocument","win","defaultView","ref","carouselRef","walker","carouselWalker","store","useState","value","setValue","defaultState","defaultValue","state","initialState","rootRef","useRef","announce","process","env","NODE_ENV","useEffect","console","error","allItems","current","querySelectorAll","i","length","addValue","item","getAttribute","clear","config","attributes","attributeFilter","childList","subtree","callback","mutationList","mutation","addedNode","Array","from","addedNodes","hasAttribute","newValue","newNode","find","previousNode","prevPage","insertValue","removedNode","removedNodes","removedValue","removeValue","observer","MutationObserver","observe","disconnect","updateSlide","event","type","announceText","polite","selectPageByDirection","direction","active","newPage","nextPage","carousel","selectPageByValue"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,aAAa,EAAEC,aAAa,EAAEC,oBAAoB,EAAEC,gBAAgB,QAAQ,4BAA4B;AACjH,SAASC,WAAW,EAAEC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAE/F,SAASC,aAAa,QAAQ,iBAAc;AAC5C,SAASC,0BAA0B,QAAQ,yBAAsB;AACjE,SAASC,mBAAmB,QAAQ,2BAAwB;AAI5D,mEAAmE;AACnE,qGAAqG;AACrG,OAAO,SAASC,qBAAqBC,OAA2B;IAY9D,MAAM,EAAEC,YAAY,EAAEC,aAAa,EAAEC,QAAQ,EAAE,GAAGH;IAElD,MAAM,EAAEI,cAAc,EAAE,GAAGT;IAC3B,MAAMU,MAAMD,2BAAAA,qCAAAA,eAAgBE,WAAW;IACvC,MAAM,EAAEC,KAAKC,WAAW,EAAEC,QAAQC,cAAc,EAAE,GAAGb;IACrD,MAAM,CAACc,MAAM,GAAGvB,MAAMwB,QAAQ,CAAC,IAAMd;IAErC,MAAM,CAACe,OAAOC,SAAS,GAAGvB,qBAAqB;QAC7CwB,cAAcf,QAAQgB,YAAY;QAClCC,OAAOjB,QAAQa,KAAK;QACpBK,cAAc;IAChB;IACA,MAAMC,UAAU/B,MAAMgC,MAAM,CAAiB;IAE7C,MAAM,EAAEC,QAAQ,EAAE,GAAG5B;IAErB,IAAI6B,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,sDAAsD;QACtDpC,MAAMqC,SAAS,CAAC;YACd,IAAIZ,UAAU,MAAM;gBAClB,sCAAsC;gBACtCa,QAAQC,KAAK,CACX;YAE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":3,"sources":["../src/components/TeachingPopoverCarousel/Carousel/Carousel.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport {\n isHTMLElement,\n useMergedRefs,\n useControllableState,\n useEventCallback,\n useIsomorphicLayoutEffect,\n} from '@fluentui/react-utilities';\nimport { useAnnounce, useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\nimport { CAROUSEL_ACTIVE_ITEM, CAROUSEL_ITEM } from './constants';\nimport { useCarouselWalker_unstable } from './useCarouselWalker';\nimport { createCarouselStore } from './createCarouselStore';\nimport type { CarouselStore, UseCarouselOptions } from './Carousel.types';\nimport type { CarouselContextValue } from './CarouselContext';\n\n// TODO: Migrate this into an external @fluentui/carousel component\n// For now, we won't export this publicly, is only for internal TeachingPopover use until stabilized.\nexport function useCarousel_unstable(options: UseCarouselOptions): {\n carouselRef: React.RefObject<HTMLDivElement | null>;\n carousel: {\n store: CarouselStore;\n value: string | null;\n selectPageByDirection: (\n event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>,\n direction: 'next' | 'prev',\n ) => void;\n selectPageByValue: (event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>, newValue: string) => void;\n };\n} {\n const { announcement, onValueChange, onFinish } = options;\n\n const { targetDocument } = useFluent();\n const win = targetDocument?.defaultView;\n const { ref: carouselRef, walker: carouselWalker } = useCarouselWalker_unstable();\n const [store] = React.useState(() => createCarouselStore());\n\n const [value, setValue] = useControllableState({\n defaultState: options.defaultValue,\n state: options.value,\n initialState: null,\n });\n const rootRef = React.useRef<HTMLDivElement>(null);\n\n const { announce } = useAnnounce();\n\n const previousValueRef = React.useRef(value);\n const pendingAnnouncementRef = React.useRef<string | null>(null);\n\n const announcePage = useEventCallback(() => {\n const pendingValue = pendingAnnouncementRef.current;\n const active = carouselWalker.active();\n if (pendingValue === null || active?.value !== pendingValue) {\n return;\n }\n\n pendingAnnouncementRef.current = null;\n const text = announcement?.(pendingValue);\n if (text) {\n announce(text, { polite: true });\n }\n });\n\n useIsomorphicLayoutEffect(() => {\n if (!announcement) {\n pendingAnnouncementRef.current = null;\n }\n\n if (previousValueRef.current === value) {\n return;\n }\n\n previousValueRef.current = value;\n pendingAnnouncementRef.current = null;\n if (value === null || !announcement) {\n return;\n }\n\n pendingAnnouncementRef.current = value;\n announcePage();\n }, [value, announcement, announcePage]);\n\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (value === null) {\n // eslint-disable-next-line no-console\n console.error(\n 'useCarousel: Carousel needs to have a `defaultValue` or `value` prop set. If you want to control the value, use the `value` prop.',\n );\n }\n }, [value]);\n }\n\n React.useEffect(() => {\n const allItems = rootRef.current?.querySelectorAll(`[${CAROUSEL_ITEM}]`)!;\n\n for (let i = 0; i < allItems.length; i++) {\n store.addValue(allItems.item(i).getAttribute(CAROUSEL_ITEM)!);\n }\n\n return () => {\n store.clear();\n };\n }, [store]);\n\n React.useEffect(() => {\n if (!win) {\n return;\n }\n\n const config: MutationObserverInit = {\n attributes: true,\n attributeFilter: [CAROUSEL_ITEM, CAROUSEL_ACTIVE_ITEM],\n childList: true,\n subtree: true,\n };\n\n // Callback function to execute when mutations are observed\n const callback: MutationCallback = mutationList => {\n for (const mutation of mutationList) {\n for (const addedNode of Array.from(mutation.addedNodes)) {\n if (isHTMLElement(addedNode) && addedNode.hasAttribute(CAROUSEL_ITEM)) {\n const newValue = addedNode.getAttribute(CAROUSEL_ITEM)!;\n const newNode = carouselWalker.find(newValue);\n if (!newNode?.value) {\n return;\n }\n\n const previousNode = carouselWalker.prevPage(newNode?.value);\n store.insertValue(newValue, previousNode?.value ?? null);\n }\n }\n\n for (const removedNode of Array.from(mutation.removedNodes)) {\n if (isHTMLElement(removedNode) && removedNode?.hasAttribute(CAROUSEL_ITEM)) {\n const removedValue = removedNode.getAttribute(CAROUSEL_ITEM)!;\n\n store.removeValue(removedValue);\n }\n }\n }\n\n // Selector-based context updates can commit cards after the carousel's layout effect.\n announcePage();\n };\n\n // Create an observer instance linked to the callback function\n const observer = new win.MutationObserver(callback);\n\n // Start observing the target node for configured mutations\n observer.observe(rootRef.current!, config);\n\n // Later, you can stop observing\n return () => {\n observer.disconnect();\n pendingAnnouncementRef.current = null;\n };\n }, [announcePage, carouselWalker, store, win]);\n\n const updateSlide = useEventCallback(\n (event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>, newValue: string) => {\n setValue(newValue);\n onValueChange?.(event, { event, type: 'click', value: newValue });\n },\n );\n\n const selectPageByDirection: CarouselContextValue['selectPageByDirection'] = useEventCallback((event, direction) => {\n const active = carouselWalker.active();\n\n if (!active?.value) {\n return;\n }\n\n const newPage =\n direction === 'prev' ? carouselWalker.prevPage(active.value) : carouselWalker.nextPage(active.value);\n\n if (newPage) {\n updateSlide(event, newPage?.value);\n } else {\n onFinish?.(event, { event, type: 'click', value: active?.value });\n }\n });\n\n return {\n carouselRef: useMergedRefs(rootRef, carouselRef),\n carousel: {\n store,\n value,\n selectPageByDirection,\n selectPageByValue: updateSlide,\n },\n };\n}\n"],"names":["React","isHTMLElement","useMergedRefs","useControllableState","useEventCallback","useIsomorphicLayoutEffect","useAnnounce","useFluent_unstable","useFluent","CAROUSEL_ACTIVE_ITEM","CAROUSEL_ITEM","useCarouselWalker_unstable","createCarouselStore","useCarousel_unstable","options","announcement","onValueChange","onFinish","targetDocument","win","defaultView","ref","carouselRef","walker","carouselWalker","store","useState","value","setValue","defaultState","defaultValue","state","initialState","rootRef","useRef","announce","previousValueRef","pendingAnnouncementRef","announcePage","pendingValue","current","active","text","polite","process","env","NODE_ENV","useEffect","console","error","allItems","querySelectorAll","i","length","addValue","item","getAttribute","clear","config","attributes","attributeFilter","childList","subtree","callback","mutationList","mutation","addedNode","Array","from","addedNodes","hasAttribute","newValue","newNode","find","previousNode","prevPage","insertValue","removedNode","removedNodes","removedValue","removeValue","observer","MutationObserver","observe","disconnect","updateSlide","event","type","selectPageByDirection","direction","newPage","nextPage","carousel","selectPageByVal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,MAAM;QAEpC,IAAI,EAACA,mBAAAA,6BAAAA,OAAQd,KAAK,GAAE;YAClB;QACF;QAEA,MAAM+D,UACJD,cAAc,SAASjE,eAAemD,QAAQ,CAAClC,OAAOd,KAAK,IAAIH,eAAemE,QAAQ,CAAClD,OAAOd,KAAK;QAErG,IAAI+D,SAAS;YACXL,YAAYC,OAAOI,oBAAAA,8BAAAA,QAAS/D,KAAK;QACnC,OAAO;YACLV,qBAAAA,+BAAAA,SAAWqE,OAAO;gBAAEA;gBAAOC,MAAM;gBAAS5D,KAAK,EAAEc,mBAAAA,6BAAAA,OAAQd,KAAK;YAAC;QACjE;IACF;IAEA,OAAO;QACLL,aAAapB,cAAc+B,SAASX;QACpCsE,UAAU;YACRnE;YACAE;YACA6D;YACAK,mBAAmBR;QACrB;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TeachingPopoverCarousel/Carousel/Carousel.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { EventData, EventHandler } from '@fluentui/react-utilities';\n\nexport type CarouselStore = {\n clear: () => void;\n addValue: (value: string) => void;\n insertValue: (value: string, prev: string | null) => void;\n removeValue: (value: string) => void;\n subscribe: (listener: () => void) => () => void;\n getSnapshot: () => string[];\n};\n\nexport type CarouselItem = {\n el: HTMLElement;\n value: string | null;\n};\n\nexport type UseCarouselOptions = {\n /**\n * Localizes the string used to announce carousel page changes to screen reader users
|
|
1
|
+
{"version":3,"sources":["../src/components/TeachingPopoverCarousel/Carousel/Carousel.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { EventData, EventHandler } from '@fluentui/react-utilities';\n\nexport type CarouselStore = {\n clear: () => void;\n addValue: (value: string) => void;\n insertValue: (value: string, prev: string | null) => void;\n removeValue: (value: string) => void;\n subscribe: (listener: () => void) => () => void;\n getSnapshot: () => string[];\n};\n\nexport type CarouselItem = {\n el: HTMLElement;\n value: string | null;\n};\n\nexport type UseCarouselOptions = {\n /**\n * Localizes the string used to announce carousel page changes to screen reader users.\n * Runs after the destination page renders. When omitted, page changes are not announced.\n * Return an empty string to suppress an announcement.\n */\n announcement?: (newValue: string) => string;\n\n /**\n * The initial page to display in uncontrolled mode.\n */\n defaultValue?: string;\n\n /**\n * The value of the currently active page.\n */\n value?: string;\n\n /**\n * Callback to notify a page change.\n */\n onValueChange?: EventHandler<CarouselValueChangeData>;\n\n /**\n * Callback to notify when the final button step of a carousel has been activated.\n */\n onFinish?: EventHandler<CarouselValueChangeData>;\n};\n\nexport type CarouselValueChangeData = EventData<'click', React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>> & {\n /**\n * The value to be set after event has occurred.\n */\n value?: string;\n};\n"],"names":[],"mappings":"AA8CA,WAKE"}
|
|
@@ -29,6 +29,41 @@ function useCarousel_unstable(options) {
|
|
|
29
29
|
});
|
|
30
30
|
const rootRef = _react.useRef(null);
|
|
31
31
|
const { announce } = (0, _reactsharedcontexts.useAnnounce)();
|
|
32
|
+
const previousValueRef = _react.useRef(value);
|
|
33
|
+
const pendingAnnouncementRef = _react.useRef(null);
|
|
34
|
+
const announcePage = (0, _reactutilities.useEventCallback)(()=>{
|
|
35
|
+
const pendingValue = pendingAnnouncementRef.current;
|
|
36
|
+
const active = carouselWalker.active();
|
|
37
|
+
if (pendingValue === null || (active === null || active === void 0 ? void 0 : active.value) !== pendingValue) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
pendingAnnouncementRef.current = null;
|
|
41
|
+
const text = announcement === null || announcement === void 0 ? void 0 : announcement(pendingValue);
|
|
42
|
+
if (text) {
|
|
43
|
+
announce(text, {
|
|
44
|
+
polite: true
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
(0, _reactutilities.useIsomorphicLayoutEffect)(()=>{
|
|
49
|
+
if (!announcement) {
|
|
50
|
+
pendingAnnouncementRef.current = null;
|
|
51
|
+
}
|
|
52
|
+
if (previousValueRef.current === value) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
previousValueRef.current = value;
|
|
56
|
+
pendingAnnouncementRef.current = null;
|
|
57
|
+
if (value === null || !announcement) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
pendingAnnouncementRef.current = value;
|
|
61
|
+
announcePage();
|
|
62
|
+
}, [
|
|
63
|
+
value,
|
|
64
|
+
announcement,
|
|
65
|
+
announcePage
|
|
66
|
+
]);
|
|
32
67
|
if (process.env.NODE_ENV !== 'production') {
|
|
33
68
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
34
69
|
_react.useEffect(()=>{
|
|
@@ -59,7 +94,8 @@ function useCarousel_unstable(options) {
|
|
|
59
94
|
const config = {
|
|
60
95
|
attributes: true,
|
|
61
96
|
attributeFilter: [
|
|
62
|
-
_constants.CAROUSEL_ITEM
|
|
97
|
+
_constants.CAROUSEL_ITEM,
|
|
98
|
+
_constants.CAROUSEL_ACTIVE_ITEM
|
|
63
99
|
],
|
|
64
100
|
childList: true,
|
|
65
101
|
subtree: true
|
|
@@ -86,6 +122,8 @@ function useCarousel_unstable(options) {
|
|
|
86
122
|
}
|
|
87
123
|
}
|
|
88
124
|
}
|
|
125
|
+
// Selector-based context updates can commit cards after the carousel's layout effect.
|
|
126
|
+
announcePage();
|
|
89
127
|
};
|
|
90
128
|
// Create an observer instance linked to the callback function
|
|
91
129
|
const observer = new win.MutationObserver(callback);
|
|
@@ -94,8 +132,10 @@ function useCarousel_unstable(options) {
|
|
|
94
132
|
// Later, you can stop observing
|
|
95
133
|
return ()=>{
|
|
96
134
|
observer.disconnect();
|
|
135
|
+
pendingAnnouncementRef.current = null;
|
|
97
136
|
};
|
|
98
137
|
}, [
|
|
138
|
+
announcePage,
|
|
99
139
|
carouselWalker,
|
|
100
140
|
store,
|
|
101
141
|
win
|
|
@@ -107,12 +147,6 @@ function useCarousel_unstable(options) {
|
|
|
107
147
|
type: 'click',
|
|
108
148
|
value: newValue
|
|
109
149
|
});
|
|
110
|
-
const announceText = announcement === null || announcement === void 0 ? void 0 : announcement(newValue);
|
|
111
|
-
if (announceText) {
|
|
112
|
-
announce(announceText, {
|
|
113
|
-
polite: true
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
150
|
});
|
|
117
151
|
const selectPageByDirection = (0, _reactutilities.useEventCallback)((event, direction)=>{
|
|
118
152
|
const active = carouselWalker.active();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TeachingPopoverCarousel/Carousel/Carousel.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { isHTMLElement, useMergedRefs, useControllableState, useEventCallback } from '@fluentui/react-utilities';\nimport { useAnnounce, useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\nimport { CAROUSEL_ITEM } from './constants';\nimport { useCarouselWalker_unstable } from './useCarouselWalker';\nimport { createCarouselStore } from './createCarouselStore';\nimport type { CarouselStore, UseCarouselOptions } from './Carousel.types';\nimport type { CarouselContextValue } from './CarouselContext';\n\n// TODO: Migrate this into an external @fluentui/carousel component\n// For now, we won't export this publicly, is only for internal TeachingPopover use until stabilized.\nexport function useCarousel_unstable(options: UseCarouselOptions): {\n carouselRef: React.RefObject<HTMLDivElement | null>;\n carousel: {\n store: CarouselStore;\n value: string | null;\n selectPageByDirection: (\n event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>,\n direction: 'next' | 'prev',\n ) => void;\n selectPageByValue: (event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>, newValue: string) => void;\n };\n} {\n const { announcement, onValueChange, onFinish } = options;\n\n const { targetDocument } = useFluent();\n const win = targetDocument?.defaultView;\n const { ref: carouselRef, walker: carouselWalker } = useCarouselWalker_unstable();\n const [store] = React.useState(() => createCarouselStore());\n\n const [value, setValue] = useControllableState({\n defaultState: options.defaultValue,\n state: options.value,\n initialState: null,\n });\n const rootRef = React.useRef<HTMLDivElement>(null);\n\n const { announce } = useAnnounce();\n\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (value === null) {\n // eslint-disable-next-line no-console\n console.error(\n 'useCarousel: Carousel needs to have a `defaultValue` or `value` prop set. If you want to control the value, use the `value` prop.',\n );\n }\n }, [value]);\n }\n\n React.useEffect(() => {\n const allItems = rootRef.current?.querySelectorAll(`[${CAROUSEL_ITEM}]`)!;\n\n for (let i = 0; i < allItems.length; i++) {\n store.addValue(allItems.item(i).getAttribute(CAROUSEL_ITEM)!);\n }\n\n return () => {\n store.clear();\n };\n }, [store]);\n\n React.useEffect(() => {\n if (!win) {\n return;\n }\n\n const config: MutationObserverInit = {\n attributes: true,\n attributeFilter: [CAROUSEL_ITEM],\n childList: true,\n subtree: true,\n };\n\n // Callback function to execute when mutations are observed\n const callback: MutationCallback = mutationList => {\n for (const mutation of mutationList) {\n for (const addedNode of Array.from(mutation.addedNodes)) {\n if (isHTMLElement(addedNode) && addedNode.hasAttribute(CAROUSEL_ITEM)) {\n const newValue = addedNode.getAttribute(CAROUSEL_ITEM)!;\n const newNode = carouselWalker.find(newValue);\n if (!newNode?.value) {\n return;\n }\n\n const previousNode = carouselWalker.prevPage(newNode?.value);\n store.insertValue(newValue, previousNode?.value ?? null);\n }\n }\n\n for (const removedNode of Array.from(mutation.removedNodes)) {\n if (isHTMLElement(removedNode) && removedNode?.hasAttribute(CAROUSEL_ITEM)) {\n const removedValue = removedNode.getAttribute(CAROUSEL_ITEM)!;\n\n store.removeValue(removedValue);\n }\n }\n }\n };\n\n // Create an observer instance linked to the callback function\n const observer = new win.MutationObserver(callback);\n\n // Start observing the target node for configured mutations\n observer.observe(rootRef.current!, config);\n\n // Later, you can stop observing\n return () => {\n observer.disconnect();\n };\n }, [carouselWalker, store, win]);\n\n const updateSlide = useEventCallback(\n (event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>, newValue: string) => {\n setValue(newValue);\n onValueChange?.(event, { event, type: 'click', value: newValue });\n\n const announceText = announcement?.(newValue);\n if (announceText) {\n announce(announceText, { polite: true });\n }\n },\n );\n\n const selectPageByDirection: CarouselContextValue['selectPageByDirection'] = useEventCallback((event, direction) => {\n const active = carouselWalker.active();\n\n if (!active?.value) {\n return;\n }\n\n const newPage =\n direction === 'prev' ? carouselWalker.prevPage(active.value) : carouselWalker.nextPage(active.value);\n\n if (newPage) {\n updateSlide(event, newPage?.value);\n } else {\n onFinish?.(event, { event, type: 'click', value: active?.value });\n }\n });\n\n return {\n carouselRef: useMergedRefs(rootRef, carouselRef),\n carousel: {\n store,\n value,\n selectPageByDirection,\n selectPageByValue: updateSlide,\n },\n };\n}\n"],"names":["React","isHTMLElement","useMergedRefs","useControllableState","useEventCallback","useAnnounce","useFluent_unstable","useFluent","CAROUSEL_ITEM","useCarouselWalker_unstable","createCarouselStore","useCarousel_unstable","options","announcement","onValueChange","onFinish","targetDocument","win","defaultView","ref","carouselRef","walker","carouselWalker","store","useState","value","setValue","defaultState","defaultValue","state","initialState","rootRef","useRef","announce","process","env","NODE_ENV","useEffect","console","error","allItems","current","querySelectorAll","i","length","addValue","item","getAttribute","clear","config","attributes","attributeFilter","childList","subtree","callback","mutationList","mutation","addedNode","Array","from","addedNodes","hasAttribute","newValue","newNode","find","previousNode","prevPage","insertValue","removedNode","removedNodes","removedValue","removeValue","observer","MutationObserver","observe","disconnect","updateSlide","event","type","announceText","polite","selectPageByDirection","direction","active","newPage","nextPage","carousel","selectPageByValue"],"mappings":"AAAA;;;;;+BAcgBW;;;;;;;iEAZO,QAAQ;gCACsD,4BAA4B;qCACpD,kCAAkC;2BAEjE,iBAAc;mCACD,yBAAsB;qCAC7B,2BAAwB;AAMrD,8BAA8BC,OAA2B;IAY9D,MAAM,EAAEC,YAAY,EAAEC,aAAa,EAAEC,QAAQ,EAAE,GAAGH;IAElD,MAAM,EAAEI,cAAc,EAAE,OAAGT,uCAAAA;IAC3B,MAAMU,MAAMD,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,eAAgBE,WAAW;IACvC,MA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ACyE,OAAgEf;QAC/DpC,SAASoC;QACThD,kBAAAA,QAAAA,kBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,cAAgB+D,OAAO;YAAEA;YAAOC,MAAM;YAASrD,OAAOqC;QAAS;QAE/D,MAAMiB,eAAelE,iBAAAA,QAAAA,iBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,aAAeiD;QACpC,IAAIiB,cAAc;YAChB9C,SAAS8C,cAAc;gBAAEC,QAAQ;YAAK;QACxC;IACF;IAGF,MAAMC,4BAAuE7E,gCAAAA,EAAiB,CAACyE,OAAOK;QACpG,MAAMC,SAAS7D,eAAe6D,MAAM;QAEpC,IAAI,EAACA,WAAAA,QAAAA,WAAAA,KAAAA,IAAAA,KAAAA,IAAAA,OAAQ1D,KAAAA,AAAK,GAAE;YAClB;QACF;QAEA,MAAM2D,UACJF,cAAc,SAAS5D,eAAe4C,QAAQ,CAACiB,OAAO1D,KAAK,IAAIH,eAAe+D,QAAQ,CAACF,OAAO1D,KAAK;QAErG,IAAI2D,SAAS;YACXR,YAAYC,OAAOO,YAAAA,QAAAA,YAAAA,KAAAA,IAAAA,KAAAA,IAAAA,QAAS3D,KAAK;QACnC,OAAO;YACLV,aAAAA,QAAAA,aAAAA,KAAAA,IAAAA,KAAAA,IAAAA,SAAW8D,OAAO;gBAAEA;gBAAOC,MAAM;gBAASrD,KAAK,EAAE0D,WAAAA,QAAAA,WAAAA,KAAAA,IAAAA,KAAAA,IAAAA,OAAQ1D,KAAK;YAAC;QACjE;IACF;IAEA,OAAO;QACLL,iBAAalB,6BAAAA,EAAc6B,SAASX;QACpCkE,UAAU;YACR/D;YACAE;YACAwD;YACAM,mBAAmBX;QACrB;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../src/components/TeachingPopoverCarousel/Carousel/Carousel.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport {\n isHTMLElement,\n useMergedRefs,\n useControllableState,\n useEventCallback,\n useIsomorphicLayoutEffect,\n} from '@fluentui/react-utilities';\nimport { useAnnounce, useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\nimport { CAROUSEL_ACTIVE_ITEM, CAROUSEL_ITEM } from './constants';\nimport { useCarouselWalker_unstable } from './useCarouselWalker';\nimport { createCarouselStore } from './createCarouselStore';\nimport type { CarouselStore, UseCarouselOptions } from './Carousel.types';\nimport type { CarouselContextValue } from './CarouselContext';\n\n// TODO: Migrate this into an external @fluentui/carousel component\n// For now, we won't export this publicly, is only for internal TeachingPopover use until stabilized.\nexport function useCarousel_unstable(options: UseCarouselOptions): {\n carouselRef: React.RefObject<HTMLDivElement | null>;\n carousel: {\n store: CarouselStore;\n value: string | null;\n selectPageByDirection: (\n event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>,\n direction: 'next' | 'prev',\n ) => void;\n selectPageByValue: (event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>, newValue: string) => void;\n };\n} {\n const { announcement, onValueChange, onFinish } = options;\n\n const { targetDocument } = useFluent();\n const win = targetDocument?.defaultView;\n const { ref: carouselRef, walker: carouselWalker } = useCarouselWalker_unstable();\n const [store] = React.useState(() => createCarouselStore());\n\n const [value, setValue] = useControllableState({\n defaultState: options.defaultValue,\n state: options.value,\n initialState: null,\n });\n const rootRef = React.useRef<HTMLDivElement>(null);\n\n const { announce } = useAnnounce();\n\n const previousValueRef = React.useRef(value);\n const pendingAnnouncementRef = React.useRef<string | null>(null);\n\n const announcePage = useEventCallback(() => {\n const pendingValue = pendingAnnouncementRef.current;\n const active = carouselWalker.active();\n if (pendingValue === null || active?.value !== pendingValue) {\n return;\n }\n\n pendingAnnouncementRef.current = null;\n const text = announcement?.(pendingValue);\n if (text) {\n announce(text, { polite: true });\n }\n });\n\n useIsomorphicLayoutEffect(() => {\n if (!announcement) {\n pendingAnnouncementRef.current = null;\n }\n\n if (previousValueRef.current === value) {\n return;\n }\n\n previousValueRef.current = value;\n pendingAnnouncementRef.current = null;\n if (value === null || !announcement) {\n return;\n }\n\n pendingAnnouncementRef.current = value;\n announcePage();\n }, [value, announcement, announcePage]);\n\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (value === null) {\n // eslint-disable-next-line no-console\n console.error(\n 'useCarousel: Carousel needs to have a `defaultValue` or `value` prop set. If you want to control the value, use the `value` prop.',\n );\n }\n }, [value]);\n }\n\n React.useEffect(() => {\n const allItems = rootRef.current?.querySelectorAll(`[${CAROUSEL_ITEM}]`)!;\n\n for (let i = 0; i < allItems.length; i++) {\n store.addValue(allItems.item(i).getAttribute(CAROUSEL_ITEM)!);\n }\n\n return () => {\n store.clear();\n };\n }, [store]);\n\n React.useEffect(() => {\n if (!win) {\n return;\n }\n\n const config: MutationObserverInit = {\n attributes: true,\n attributeFilter: [CAROUSEL_ITEM, CAROUSEL_ACTIVE_ITEM],\n childList: true,\n subtree: true,\n };\n\n // Callback function to execute when mutations are observed\n const callback: MutationCallback = mutationList => {\n for (const mutation of mutationList) {\n for (const addedNode of Array.from(mutation.addedNodes)) {\n if (isHTMLElement(addedNode) && addedNode.hasAttribute(CAROUSEL_ITEM)) {\n const newValue = addedNode.getAttribute(CAROUSEL_ITEM)!;\n const newNode = carouselWalker.find(newValue);\n if (!newNode?.value) {\n return;\n }\n\n const previousNode = carouselWalker.prevPage(newNode?.value);\n store.insertValue(newValue, previousNode?.value ?? null);\n }\n }\n\n for (const removedNode of Array.from(mutation.removedNodes)) {\n if (isHTMLElement(removedNode) && removedNode?.hasAttribute(CAROUSEL_ITEM)) {\n const removedValue = removedNode.getAttribute(CAROUSEL_ITEM)!;\n\n store.removeValue(removedValue);\n }\n }\n }\n\n // Selector-based context updates can commit cards after the carousel's layout effect.\n announcePage();\n };\n\n // Create an observer instance linked to the callback function\n const observer = new win.MutationObserver(callback);\n\n // Start observing the target node for configured mutations\n observer.observe(rootRef.current!, config);\n\n // Later, you can stop observing\n return () => {\n observer.disconnect();\n pendingAnnouncementRef.current = null;\n };\n }, [announcePage, carouselWalker, store, win]);\n\n const updateSlide = useEventCallback(\n (event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>, newValue: string) => {\n setValue(newValue);\n onValueChange?.(event, { event, type: 'click', value: newValue });\n },\n );\n\n const selectPageByDirection: CarouselContextValue['selectPageByDirection'] = useEventCallback((event, direction) => {\n const active = carouselWalker.active();\n\n if (!active?.value) {\n return;\n }\n\n const newPage =\n direction === 'prev' ? carouselWalker.prevPage(active.value) : carouselWalker.nextPage(active.value);\n\n if (newPage) {\n updateSlide(event, newPage?.value);\n } else {\n onFinish?.(event, { event, type: 'click', value: active?.value });\n }\n });\n\n return {\n carouselRef: useMergedRefs(rootRef, carouselRef),\n carousel: {\n store,\n value,\n selectPageByDirection,\n selectPageByValue: updateSlide,\n },\n };\n}\n"],"names":["React","isHTMLElement","useMergedRefs","useControllableState","useEventCallback","useIsomorphicLayoutEffect","useAnnounce","useFluent_unstable","useFluent","CAROUSEL_ACTIVE_ITEM","CAROUSEL_ITEM","useCarouselWalker_unstable","createCarouselStore","useCarousel_unstable","options","announcement","onValueChange","onFinish","targetDocument","win","defaultView","ref","carouselRef","walker","carouselWalker","store","useState","value","setValue","defaultState","defaultValue","state","initialState","rootRef","useRef","announce","previousValueRef","pendingAnnouncementRef","announcePage","pendingValue","current","active","text","polite","process","env","NODE_ENV","useEffect","console","error","allItems","querySelectorAll","i","length","addValue","item","getAttribute","clear","config","attributes","attributeFilter","childList","subtree","callback","mutationList","mutation","addedNode","Array","from","addedNodes","hasAttribute","newValue","newNode","find","previousNode","prevPage","insertValue","removedNode","removedNodes","removedValue","removeValue","observer","MutationObserver","observe","disconnect","updateSlide","event","type","selectPageByDirection","direction","newPage","nextPage","carousel","selectPageByValue"],"mappings":"AAAA;;;;;+BAoBgBa;;;;;;;iEAlBO,QAAQ;gCAOxB,4BAA4B;qCAC0B,kCAAkC;2BAE3C,iBAAc;mCACvB,yBAAsB;qCAC7B,2BAAwB;AAMrD,8BAA8BC,OAA2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A,IAAAA,cAAgBsE,OAAO;YAAEA;YAAOC,MAAM;YAAS5D,OAAO4C;QAAS;IACjE;IAGF,MAAMiB,wBAAuEpF,oCAAAA,EAAiB,CAACkF,OAAOG;QACpG,MAAMhD,SAASjB,eAAeiB,MAAM;QAEpC,IAAI,EAACA,WAAAA,QAAAA,WAAAA,KAAAA,IAAAA,KAAAA,IAAAA,OAAQd,KAAAA,AAAK,GAAE;YAClB;QACF;QAEA,MAAM+D,UACJD,cAAc,SAASjE,eAAemD,QAAQ,CAAClC,OAAOd,KAAK,IAAIH,eAAemE,QAAQ,CAAClD,OAAOd,KAAK;QAErG,IAAI+D,SAAS;YACXL,YAAYC,OAAOI,YAAAA,QAAAA,YAAAA,KAAAA,IAAAA,KAAAA,IAAAA,QAAS/D,KAAK;QACnC,OAAO;YACLV,aAAAA,QAAAA,aAAAA,KAAAA,IAAAA,KAAAA,IAAAA,SAAWqE,OAAO;gBAAEA;gBAAOC,MAAM;gBAAS5D,KAAK,EAAEc,WAAAA,QAAAA,WAAAA,KAAAA,IAAAA,KAAAA,IAAAA,OAAQd,KAAK;YAAC;QACjE;IACF;IAEA,OAAO;QACLL,iBAAapB,6BAAAA,EAAc+B,SAASX;QACpCsE,UAAU;YACRnE;YACAE;YACA6D;YACAK,mBAAmBR;QACrB;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TeachingPopoverCarousel/Carousel/Carousel.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { EventData, EventHandler } from '@fluentui/react-utilities';\n\nexport type CarouselStore = {\n clear: () => void;\n addValue: (value: string) => void;\n insertValue: (value: string, prev: string | null) => void;\n removeValue: (value: string) => void;\n subscribe: (listener: () => void) => () => void;\n getSnapshot: () => string[];\n};\n\nexport type CarouselItem = {\n el: HTMLElement;\n value: string | null;\n};\n\nexport type UseCarouselOptions = {\n /**\n * Localizes the string used to announce carousel page changes to screen reader users
|
|
1
|
+
{"version":3,"sources":["../src/components/TeachingPopoverCarousel/Carousel/Carousel.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { EventData, EventHandler } from '@fluentui/react-utilities';\n\nexport type CarouselStore = {\n clear: () => void;\n addValue: (value: string) => void;\n insertValue: (value: string, prev: string | null) => void;\n removeValue: (value: string) => void;\n subscribe: (listener: () => void) => () => void;\n getSnapshot: () => string[];\n};\n\nexport type CarouselItem = {\n el: HTMLElement;\n value: string | null;\n};\n\nexport type UseCarouselOptions = {\n /**\n * Localizes the string used to announce carousel page changes to screen reader users.\n * Runs after the destination page renders. When omitted, page changes are not announced.\n * Return an empty string to suppress an announcement.\n */\n announcement?: (newValue: string) => string;\n\n /**\n * The initial page to display in uncontrolled mode.\n */\n defaultValue?: string;\n\n /**\n * The value of the currently active page.\n */\n value?: string;\n\n /**\n * Callback to notify a page change.\n */\n onValueChange?: EventHandler<CarouselValueChangeData>;\n\n /**\n * Callback to notify when the final button step of a carousel has been activated.\n */\n onFinish?: EventHandler<CarouselValueChangeData>;\n};\n\nexport type CarouselValueChangeData = EventData<'click', React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>> & {\n /**\n * The value to be set after event has occurred.\n */\n value?: string;\n};\n"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-teaching-popover",
|
|
3
|
-
"version": "9.7.
|
|
3
|
+
"version": "9.7.8",
|
|
4
4
|
"description": "New fluentui react package",
|
|
5
5
|
"main": "lib-commonjs/index.cjs",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -19,16 +19,16 @@
|
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluentui/react-aria": "^9.17.
|
|
23
|
-
"@fluentui/react-button": "^9.11.
|
|
24
|
-
"@fluentui/react-context-selector": "^9.2.
|
|
22
|
+
"@fluentui/react-aria": "^9.17.16",
|
|
23
|
+
"@fluentui/react-button": "^9.11.2",
|
|
24
|
+
"@fluentui/react-context-selector": "^9.2.21",
|
|
25
25
|
"@fluentui/react-icons": "^2.0.245",
|
|
26
|
-
"@fluentui/react-jsx-runtime": "^9.4.
|
|
27
|
-
"@fluentui/react-popover": "^9.14.
|
|
26
|
+
"@fluentui/react-jsx-runtime": "^9.4.7",
|
|
27
|
+
"@fluentui/react-popover": "^9.14.10",
|
|
28
28
|
"@fluentui/react-shared-contexts": "^9.26.4",
|
|
29
|
-
"@fluentui/react-tabster": "^9.26.
|
|
29
|
+
"@fluentui/react-tabster": "^9.26.19",
|
|
30
30
|
"@fluentui/react-theme": "^9.2.2",
|
|
31
|
-
"@fluentui/react-utilities": "^9.
|
|
31
|
+
"@fluentui/react-utilities": "^9.27.0",
|
|
32
32
|
"@griffel/react": "^1.5.32",
|
|
33
33
|
"@swc/helpers": "^0.5.1",
|
|
34
34
|
"use-sync-external-store": "^1.4.0"
|