@fluentui/react-aria 9.7.3 → 9.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +27 -2
  2. package/dist/index.d.ts +29 -1
  3. package/lib/AriaLiveAnnouncer/AriaLiveAnnouncer.js +12 -0
  4. package/lib/AriaLiveAnnouncer/AriaLiveAnnouncer.js.map +1 -0
  5. package/lib/AriaLiveAnnouncer/AriaLiveAnnouncer.types.js +1 -0
  6. package/lib/AriaLiveAnnouncer/AriaLiveAnnouncer.types.js.map +1 -0
  7. package/lib/AriaLiveAnnouncer/index.js +4 -0
  8. package/lib/AriaLiveAnnouncer/index.js.map +1 -0
  9. package/lib/AriaLiveAnnouncer/renderAriaLiveAnnouncer.js +8 -0
  10. package/lib/AriaLiveAnnouncer/renderAriaLiveAnnouncer.js.map +1 -0
  11. package/lib/AriaLiveAnnouncer/useAriaLiveAnnouncer.js +124 -0
  12. package/lib/AriaLiveAnnouncer/useAriaLiveAnnouncer.js.map +1 -0
  13. package/lib/AriaLiveAnnouncer/useAriaLiveAnnouncerContextValues.js +11 -0
  14. package/lib/AriaLiveAnnouncer/useAriaLiveAnnouncerContextValues.js.map +1 -0
  15. package/lib/button/types.js.map +1 -1
  16. package/lib/index.js +1 -0
  17. package/lib/index.js.map +1 -1
  18. package/lib-commonjs/AriaLiveAnnouncer/AriaLiveAnnouncer.js +21 -0
  19. package/lib-commonjs/AriaLiveAnnouncer/AriaLiveAnnouncer.js.map +1 -0
  20. package/lib-commonjs/AriaLiveAnnouncer/AriaLiveAnnouncer.types.js +6 -0
  21. package/lib-commonjs/AriaLiveAnnouncer/AriaLiveAnnouncer.types.js.map +1 -0
  22. package/lib-commonjs/AriaLiveAnnouncer/index.js +28 -0
  23. package/lib-commonjs/AriaLiveAnnouncer/index.js.map +1 -0
  24. package/lib-commonjs/AriaLiveAnnouncer/renderAriaLiveAnnouncer.js +18 -0
  25. package/lib-commonjs/AriaLiveAnnouncer/renderAriaLiveAnnouncer.js.map +1 -0
  26. package/lib-commonjs/AriaLiveAnnouncer/useAriaLiveAnnouncer.js +135 -0
  27. package/lib-commonjs/AriaLiveAnnouncer/useAriaLiveAnnouncer.js.map +1 -0
  28. package/lib-commonjs/AriaLiveAnnouncer/useAriaLiveAnnouncerContextValues.js +22 -0
  29. package/lib-commonjs/AriaLiveAnnouncer/useAriaLiveAnnouncerContextValues.js.map +1 -0
  30. package/lib-commonjs/index.js +13 -0
  31. package/lib-commonjs/index.js.map +1 -1
  32. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,12 +1,37 @@
1
1
  # Change Log - @fluentui/react-aria
2
2
 
3
- This log was last generated on Thu, 18 Jan 2024 14:19:09 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 30 Jan 2024 23:12:35 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.8.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.8.1)
8
+
9
+ Tue, 30 Jan 2024 23:12:35 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.8.0..@fluentui/react-aria_v9.8.1)
11
+
12
+ ### Patches
13
+
14
+ - Bump @fluentui/react-tabster to v9.18.0 ([PR #30429](https://github.com/microsoft/fluentui/pull/30429) by beachball)
15
+ - Bump @fluentui/react-utilities to v9.18.0 ([PR #30429](https://github.com/microsoft/fluentui/pull/30429) by beachball)
16
+
17
+ ## [9.8.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.8.0)
18
+
19
+ Tue, 23 Jan 2024 15:10:57 GMT
20
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.7.3..@fluentui/react-aria_v9.8.0)
21
+
22
+ ### Minor changes
23
+
24
+ - feat: add AriaLiveAnnouncer component ([PR #30345](https://github.com/microsoft/fluentui/pull/30345) by olfedias@microsoft.com)
25
+ - Bump @fluentui/react-tabster to v9.17.4 ([PR #30359](https://github.com/microsoft/fluentui/pull/30359) by beachball)
26
+ - Bump @fluentui/react-utilities to v9.17.0 ([PR #30359](https://github.com/microsoft/fluentui/pull/30359) by beachball)
27
+
28
+ ### Patches
29
+
30
+ - chore: import UnionToIntersection from react-utilities instead of redeclaring it locally ([PR #30317](https://github.com/microsoft/fluentui/pull/30317) by bernardo.sunderhus@gmail.com)
31
+
7
32
  ## [9.7.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-aria_v9.7.3)
8
33
 
9
- Thu, 18 Jan 2024 14:19:09 GMT
34
+ Thu, 18 Jan 2024 14:25:03 GMT
10
35
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-aria_v9.7.2..@fluentui/react-aria_v9.7.3)
11
36
 
12
37
  ### Patches
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
+ import type { AnnounceContextValue } from '@fluentui/react-shared-contexts';
1
2
  import type { ExtractSlotProps } from '@fluentui/react-utilities';
2
3
  import * as React_2 from 'react';
3
4
  import type { ResolveShorthandFunction } from '@fluentui/react-utilities';
4
5
  import type { Slot } from '@fluentui/react-utilities';
6
+ import type { UnionToIntersection } from '@fluentui/react-utilities';
5
7
 
6
8
  /**
7
9
  * Applied to the active descendant when the user is navigating with keyboard
@@ -69,6 +71,28 @@ export declare type ARIAButtonSlotProps<AlternateAs extends 'a' | 'div' = 'a' |
69
71
 
70
72
  export declare type ARIAButtonType = 'button' | 'a' | 'div';
71
73
 
74
+ declare type AriaLiveAnnounceFn = AnnounceContextValue['announce'];
75
+
76
+ /**
77
+ * A sample implementation of a component that manages aria live announcements.
78
+ */
79
+ export declare const AriaLiveAnnouncer: React_2.FC<AriaLiveAnnouncerProps>;
80
+
81
+ declare type AriaLiveAnnouncerContextValues = {
82
+ announce: {
83
+ announce: AriaLiveAnnounceFn;
84
+ };
85
+ };
86
+
87
+ export declare type AriaLiveAnnouncerProps = {
88
+ children?: React_2.ReactNode;
89
+ };
90
+
91
+ export declare type AriaLiveAnnouncerState = {
92
+ announce: AriaLiveAnnounceFn;
93
+ children?: React_2.ReactNode;
94
+ };
95
+
72
96
  declare interface IteratorOptions {
73
97
  /**
74
98
  * When passive, the active descendant is changed
@@ -77,7 +101,7 @@ declare interface IteratorOptions {
77
101
  passive?: boolean;
78
102
  }
79
103
 
80
- declare type UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;
104
+ export declare const renderAriaLiveAnnouncer_unstable: (state: AriaLiveAnnouncerState, contextValues: AriaLiveAnnouncerContextValues) => JSX.Element;
81
105
 
82
106
  export declare function useActiveDescendant<TActiveParentElement extends HTMLElement, TListboxElement extends HTMLElement>(options: ActiveDescendantOptions): UseActiveDescendantReturn<TActiveParentElement, TListboxElement>;
83
107
 
@@ -138,4 +162,8 @@ export declare function useARIAButtonProps<Type extends ARIAButtonType, Props ex
138
162
  */
139
163
  export declare const useARIAButtonShorthand: ResolveShorthandFunction<ARIAButtonSlotProps>;
140
164
 
165
+ export declare const useAriaLiveAnnouncer_unstable: (props: AriaLiveAnnouncerProps) => AriaLiveAnnouncerState;
166
+
167
+ export declare function useAriaLiveAnnouncerContextValues_unstable(state: AriaLiveAnnouncerState): AriaLiveAnnouncerContextValues;
168
+
141
169
  export { }
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { renderAriaLiveAnnouncer_unstable } from './renderAriaLiveAnnouncer';
3
+ import { useAriaLiveAnnouncer_unstable } from './useAriaLiveAnnouncer';
4
+ import { useAriaLiveAnnouncerContextValues_unstable } from './useAriaLiveAnnouncerContextValues';
5
+ /**
6
+ * A sample implementation of a component that manages aria live announcements.
7
+ */ export const AriaLiveAnnouncer = (props)=>{
8
+ const state = useAriaLiveAnnouncer_unstable(props);
9
+ const contextValues = useAriaLiveAnnouncerContextValues_unstable(state);
10
+ return renderAriaLiveAnnouncer_unstable(state, contextValues);
11
+ };
12
+ AriaLiveAnnouncer.displayName = 'AriaLiveAnnouncer';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["AriaLiveAnnouncer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport type { AriaLiveAnnouncerProps } from './AriaLiveAnnouncer.types';\nimport { renderAriaLiveAnnouncer_unstable } from './renderAriaLiveAnnouncer';\nimport { useAriaLiveAnnouncer_unstable } from './useAriaLiveAnnouncer';\nimport { useAriaLiveAnnouncerContextValues_unstable } from './useAriaLiveAnnouncerContextValues';\n\n/**\n * A sample implementation of a component that manages aria live announcements.\n */\nexport const AriaLiveAnnouncer: React.FC<AriaLiveAnnouncerProps> = props => {\n const state = useAriaLiveAnnouncer_unstable(props);\n const contextValues = useAriaLiveAnnouncerContextValues_unstable(state);\n\n return renderAriaLiveAnnouncer_unstable(state, contextValues);\n};\n\nAriaLiveAnnouncer.displayName = 'AriaLiveAnnouncer';\n"],"names":["React","renderAriaLiveAnnouncer_unstable","useAriaLiveAnnouncer_unstable","useAriaLiveAnnouncerContextValues_unstable","AriaLiveAnnouncer","props","state","contextValues","displayName"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAG/B,SAASC,gCAAgC,QAAQ,4BAA4B;AAC7E,SAASC,6BAA6B,QAAQ,yBAAyB;AACvE,SAASC,0CAA0C,QAAQ,sCAAsC;AAEjG;;CAEC,GACD,OAAO,MAAMC,oBAAsDC,CAAAA;IACjE,MAAMC,QAAQJ,8BAA8BG;IAC5C,MAAME,gBAAgBJ,2CAA2CG;IAEjE,OAAOL,iCAAiCK,OAAOC;AACjD,EAAE;AAEFH,kBAAkBI,WAAW,GAAG"}
@@ -0,0 +1 @@
1
+ import * as React from 'react';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["AriaLiveAnnouncer.types.ts"],"sourcesContent":["import type { AnnounceContextValue } from '@fluentui/react-shared-contexts';\nimport * as React from 'react';\n\nexport type AriaLiveAnnounceFn = AnnounceContextValue['announce'];\n\nexport type AriaLiveMessage = {\n message: string;\n\n createdAt: number;\n\n priority: number;\n batchId?: string;\n};\n\nexport type AriaLiveAnnouncerProps = {\n children?: React.ReactNode;\n};\n\nexport type AriaLiveAnnouncerState = {\n announce: AriaLiveAnnounceFn;\n children?: React.ReactNode;\n};\n\nexport type AriaLiveAnnouncerContextValues = {\n announce: { announce: AriaLiveAnnounceFn };\n};\n"],"names":["React"],"mappings":"AACA,YAAYA,WAAW,QAAQ"}
@@ -0,0 +1,4 @@
1
+ export { AriaLiveAnnouncer } from './AriaLiveAnnouncer';
2
+ export { renderAriaLiveAnnouncer_unstable } from './renderAriaLiveAnnouncer';
3
+ export { useAriaLiveAnnouncer_unstable } from './useAriaLiveAnnouncer';
4
+ export { useAriaLiveAnnouncerContextValues_unstable } from './useAriaLiveAnnouncerContextValues';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export { AriaLiveAnnouncer } from './AriaLiveAnnouncer';\nexport type { AriaLiveAnnouncerProps, AriaLiveAnnouncerState } from './AriaLiveAnnouncer.types';\nexport { renderAriaLiveAnnouncer_unstable } from './renderAriaLiveAnnouncer';\nexport { useAriaLiveAnnouncer_unstable } from './useAriaLiveAnnouncer';\nexport { useAriaLiveAnnouncerContextValues_unstable } from './useAriaLiveAnnouncerContextValues';\n"],"names":["AriaLiveAnnouncer","renderAriaLiveAnnouncer_unstable","useAriaLiveAnnouncer_unstable","useAriaLiveAnnouncerContextValues_unstable"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,sBAAsB;AAExD,SAASC,gCAAgC,QAAQ,4BAA4B;AAC7E,SAASC,6BAA6B,QAAQ,yBAAyB;AACvE,SAASC,0CAA0C,QAAQ,sCAAsC"}
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "@fluentui/react-jsx-runtime/jsx-runtime";
2
+ import { AnnounceProvider } from '@fluentui/react-shared-contexts';
3
+ export const renderAriaLiveAnnouncer_unstable = (state, contextValues)=>{
4
+ return /*#__PURE__*/ _jsx(AnnounceProvider, {
5
+ value: contextValues.announce,
6
+ children: state.children
7
+ });
8
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["renderAriaLiveAnnouncer.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { AnnounceProvider } from '@fluentui/react-shared-contexts';\n\nimport type { AriaLiveAnnouncerContextValues, AriaLiveAnnouncerState } from './AriaLiveAnnouncer.types';\n\nexport const renderAriaLiveAnnouncer_unstable = (\n state: AriaLiveAnnouncerState,\n contextValues: AriaLiveAnnouncerContextValues,\n) => {\n return <AnnounceProvider value={contextValues.announce}>{state.children}</AnnounceProvider>;\n};\n"],"names":["AnnounceProvider","renderAriaLiveAnnouncer_unstable","state","contextValues","value","announce","children"],"mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,gBAAgB,QAAQ,kCAAkC;AAInE,OAAO,MAAMC,mCAAmC,CAC9CC,OACAC;IAEA,qBAAO,KAACH;QAAiBI,OAAOD,cAAcE,QAAQ;kBAAGH,MAAMI,QAAQ;;AACzE,EAAE"}
@@ -0,0 +1,124 @@
1
+ import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
2
+ import { createPriorityQueue, useTimeout } from '@fluentui/react-utilities';
3
+ import * as React from 'react';
4
+ /** The duration the message needs to be in present in DOM for screen readers to register a change and announce */ const MESSAGE_DURATION = 500;
5
+ const VISUALLY_HIDDEN_STYLES = {
6
+ clip: 'rect(0px, 0px, 0px, 0px)',
7
+ height: '1px',
8
+ margin: '-1px',
9
+ width: '1px',
10
+ position: 'absolute',
11
+ overflow: 'hidden',
12
+ textWrap: 'nowrap'
13
+ };
14
+ export const useAriaLiveAnnouncer_unstable = (props)=>{
15
+ const { targetDocument } = useFluent();
16
+ const timeoutRef = React.useRef(undefined);
17
+ const [setAnnounceTimeout, clearAnnounceTimeout] = useTimeout();
18
+ const elementRef = React.useRef(null);
19
+ const order = React.useRef(0);
20
+ // investigate alert implementation later
21
+ // const [alertList, setAlertList] = React.useState<string[]>([]);
22
+ const batchMessages = React.useRef([]);
23
+ const [messageQueue] = React.useState(()=>createPriorityQueue((a, b)=>{
24
+ if (a.priority !== b.priority) {
25
+ return b.priority - a.priority;
26
+ }
27
+ return a.createdAt - b.createdAt;
28
+ }));
29
+ const queueMessage = React.useCallback(()=>{
30
+ if (timeoutRef.current || !elementRef.current) {
31
+ return;
32
+ }
33
+ const runCycle = ()=>{
34
+ if (!elementRef.current) {
35
+ return;
36
+ }
37
+ if (targetDocument && messageQueue.peek()) {
38
+ // need a wrapping element for Narrator/Edge, which currently does not pick up text-only live region changes
39
+ // consistently
40
+ // if this is fixed, we can set textContent to the string directly
41
+ const wrappingEl = targetDocument.createElement('span');
42
+ wrappingEl.innerText = messageQueue.all().filter((msg)=>msg.message.trim().length > 0).reduce((prevText, currMsg)=>prevText + currMsg.message + '. ', '');
43
+ elementRef.current.innerText = '';
44
+ elementRef.current.appendChild(wrappingEl);
45
+ messageQueue.clear();
46
+ batchMessages.current = [];
47
+ // begin new cycle to clear (or update) messages
48
+ timeoutRef.current = setAnnounceTimeout(()=>{
49
+ runCycle();
50
+ }, MESSAGE_DURATION);
51
+ } else {
52
+ elementRef.current.textContent = '';
53
+ clearAnnounceTimeout();
54
+ timeoutRef.current = undefined;
55
+ }
56
+ };
57
+ runCycle();
58
+ }, [
59
+ clearAnnounceTimeout,
60
+ messageQueue,
61
+ setAnnounceTimeout,
62
+ targetDocument
63
+ ]);
64
+ const announce = React.useMemo(()=>(message, options = {})=>{
65
+ const { alert = false, priority = 0, batchId } = options;
66
+ // check if message is an alert
67
+ if (alert) {
68
+ // TODO: alert implementation
69
+ // setAlertList([...alertList, message]);
70
+ }
71
+ const liveMessage = {
72
+ message,
73
+ createdAt: order.current++,
74
+ priority,
75
+ batchId
76
+ };
77
+ // check if batchId exists
78
+ if (batchId) {
79
+ // update associated msg if it does
80
+ const batchMessage = batchMessages.current.find((msg)=>msg.batchId === batchId);
81
+ if (batchMessage) {
82
+ // replace existing message in queue
83
+ messageQueue.remove(batchMessage.message);
84
+ // update list of existing batchIds w/ most recent message
85
+ batchMessage.message = liveMessage;
86
+ } else {
87
+ // update list of existing batchIds, add new if doesn't already exist
88
+ batchMessages.current = [
89
+ ...batchMessages.current,
90
+ {
91
+ batchId,
92
+ message: liveMessage
93
+ }
94
+ ];
95
+ }
96
+ }
97
+ // add new message
98
+ messageQueue.enqueue(liveMessage);
99
+ queueMessage();
100
+ }, [
101
+ messageQueue,
102
+ queueMessage
103
+ ]);
104
+ React.useEffect(()=>{
105
+ if (!targetDocument) {
106
+ return;
107
+ }
108
+ const element = targetDocument.createElement('div');
109
+ element.setAttribute('aria-live', 'assertive');
110
+ Object.assign(element.style, VISUALLY_HIDDEN_STYLES);
111
+ targetDocument.body.append(element);
112
+ elementRef.current = element;
113
+ return ()=>{
114
+ element.remove();
115
+ elementRef.current = null;
116
+ };
117
+ }, [
118
+ targetDocument
119
+ ]);
120
+ return {
121
+ announce,
122
+ children: props.children
123
+ };
124
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useAriaLiveAnnouncer.ts"],"sourcesContent":["import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { createPriorityQueue, useTimeout } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nimport type {\n AriaLiveAnnounceFn,\n AriaLiveAnnouncerState,\n AriaLiveAnnouncerProps,\n AriaLiveMessage,\n} from './AriaLiveAnnouncer.types';\n\n/** The duration the message needs to be in present in DOM for screen readers to register a change and announce */\nconst MESSAGE_DURATION = 500;\n\nconst VISUALLY_HIDDEN_STYLES = {\n clip: 'rect(0px, 0px, 0px, 0px)',\n height: '1px',\n margin: '-1px',\n width: '1px',\n position: 'absolute',\n overflow: 'hidden',\n textWrap: 'nowrap',\n};\n\nexport const useAriaLiveAnnouncer_unstable = (props: AriaLiveAnnouncerProps): AriaLiveAnnouncerState => {\n const { targetDocument } = useFluent();\n\n const timeoutRef = React.useRef<number | undefined>(undefined);\n const [setAnnounceTimeout, clearAnnounceTimeout] = useTimeout();\n\n const elementRef = React.useRef<HTMLDivElement | null>(null);\n\n const order = React.useRef(0);\n\n // investigate alert implementation later\n // const [alertList, setAlertList] = React.useState<string[]>([]);\n\n const batchMessages = React.useRef<{ batchId: string; message: AriaLiveMessage }[]>([]);\n\n const [messageQueue] = React.useState(() =>\n createPriorityQueue<AriaLiveMessage>((a, b) => {\n if (a.priority !== b.priority) {\n return b.priority - a.priority;\n }\n\n return a.createdAt - b.createdAt;\n }),\n );\n\n const queueMessage = React.useCallback(() => {\n if (timeoutRef.current || !elementRef.current) {\n return;\n }\n\n const runCycle = () => {\n if (!elementRef.current) {\n return;\n }\n\n if (targetDocument && messageQueue.peek()) {\n // need a wrapping element for Narrator/Edge, which currently does not pick up text-only live region changes\n // consistently\n // if this is fixed, we can set textContent to the string directly\n\n const wrappingEl = targetDocument.createElement('span');\n\n wrappingEl.innerText = messageQueue\n .all()\n .filter(msg => msg.message.trim().length > 0)\n .reduce((prevText, currMsg) => prevText + currMsg.message + '. ', '');\n\n elementRef.current.innerText = '';\n elementRef.current.appendChild(wrappingEl);\n\n messageQueue.clear();\n batchMessages.current = [];\n\n // begin new cycle to clear (or update) messages\n timeoutRef.current = setAnnounceTimeout(() => {\n runCycle();\n }, MESSAGE_DURATION);\n } else {\n elementRef.current.textContent = '';\n clearAnnounceTimeout();\n\n timeoutRef.current = undefined;\n }\n };\n\n runCycle();\n }, [clearAnnounceTimeout, messageQueue, setAnnounceTimeout, targetDocument]);\n\n const announce: AriaLiveAnnounceFn = React.useMemo(\n () =>\n (message, options = {}) => {\n const { alert = false, priority = 0, batchId } = options;\n\n // check if message is an alert\n if (alert) {\n // TODO: alert implementation\n // setAlertList([...alertList, message]);\n }\n\n const liveMessage: AriaLiveMessage = {\n message,\n createdAt: order.current++,\n priority,\n batchId,\n };\n\n // check if batchId exists\n if (batchId) {\n // update associated msg if it does\n const batchMessage = batchMessages.current.find(msg => msg.batchId === batchId);\n\n if (batchMessage) {\n // replace existing message in queue\n messageQueue.remove(batchMessage.message);\n\n // update list of existing batchIds w/ most recent message\n batchMessage.message = liveMessage;\n } else {\n // update list of existing batchIds, add new if doesn't already exist\n batchMessages.current = [...batchMessages.current, { batchId, message: liveMessage }];\n }\n }\n\n // add new message\n messageQueue.enqueue(liveMessage);\n queueMessage();\n },\n [messageQueue, queueMessage],\n );\n\n React.useEffect(() => {\n if (!targetDocument) {\n return;\n }\n\n const element = targetDocument.createElement('div');\n element.setAttribute('aria-live', 'assertive');\n\n Object.assign(element.style, VISUALLY_HIDDEN_STYLES);\n targetDocument.body.append(element);\n\n elementRef.current = element;\n\n return () => {\n element.remove();\n elementRef.current = null;\n };\n }, [targetDocument]);\n\n return {\n announce,\n children: props.children,\n };\n};\n"],"names":["useFluent_unstable","useFluent","createPriorityQueue","useTimeout","React","MESSAGE_DURATION","VISUALLY_HIDDEN_STYLES","clip","height","margin","width","position","overflow","textWrap","useAriaLiveAnnouncer_unstable","props","targetDocument","timeoutRef","useRef","undefined","setAnnounceTimeout","clearAnnounceTimeout","elementRef","order","batchMessages","messageQueue","useState","a","b","priority","createdAt","queueMessage","useCallback","current","runCycle","peek","wrappingEl","createElement","innerText","all","filter","msg","message","trim","length","reduce","prevText","currMsg","appendChild","clear","textContent","announce","useMemo","options","alert","batchId","liveMessage","batchMessage","find","remove","enqueue","useEffect","element","setAttribute","Object","assign","style","body","append","children"],"mappings":"AAAA,SAASA,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,mBAAmB,EAAEC,UAAU,QAAQ,4BAA4B;AAC5E,YAAYC,WAAW,QAAQ;AAS/B,gHAAgH,GAChH,MAAMC,mBAAmB;AAEzB,MAAMC,yBAAyB;IAC7BC,MAAM;IACNC,QAAQ;IACRC,QAAQ;IACRC,OAAO;IACPC,UAAU;IACVC,UAAU;IACVC,UAAU;AACZ;AAEA,OAAO,MAAMC,gCAAgC,CAACC;IAC5C,MAAM,EAAEC,cAAc,EAAE,GAAGf;IAE3B,MAAMgB,aAAab,MAAMc,M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AAO,GAAG;QACvB;IACF,GAAG;QAACjB;KAAe;IAEnB,OAAO;QACLmC;QACAkB,UAAUtD,MAAMsD,QAAQ;IAC1B;AACF,EAAE"}
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ export function useAriaLiveAnnouncerContextValues_unstable(state) {
3
+ const { announce } = state;
4
+ return React.useMemo(()=>({
5
+ announce: {
6
+ announce
7
+ }
8
+ }), [
9
+ announce
10
+ ]);
11
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useAriaLiveAnnouncerContextValues.ts"],"sourcesContent":["import * as React from 'react';\nimport type { AriaLiveAnnouncerContextValues, AriaLiveAnnouncerState } from './AriaLiveAnnouncer.types';\n\nexport function useAriaLiveAnnouncerContextValues_unstable(\n state: AriaLiveAnnouncerState,\n): AriaLiveAnnouncerContextValues {\n const { announce } = state;\n\n return React.useMemo(() => ({ announce: { announce } }), [announce]);\n}\n"],"names":["React","useAriaLiveAnnouncerContextValues_unstable","state","announce","useMemo"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAG/B,OAAO,SAASC,2CACdC,KAA6B;IAE7B,MAAM,EAAEC,QAAQ,EAAE,GAAGD;IAErB,OAAOF,MAAMI,OAAO,CAAC,IAAO,CAAA;YAAED,UAAU;gBAAEA;YAAS;QAAE,CAAA,GAAI;QAACA;KAAS;AACrE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["types.ts"],"sourcesContent":["import type { ExtractSlotProps, Slot } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\ntype UnionToIntersection<U> = (U extends unknown ? (x: U) => U : never) extends (x: infer I) => U ? I : never;\n\nexport type ARIAButtonType = 'button' | 'a' | 'div';\n\nexport type ARIAButtonElement<AlternateAs extends 'a' | 'div' = 'a' | 'div'> =\n | HTMLButtonElement\n | (AlternateAs extends 'a' ? HTMLAnchorElement : never)\n | (AlternateAs extends 'div' ? HTMLDivElement : never);\n\n/**\n * @internal\n */\nexport type ARIAButtonElementIntersection<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = UnionToIntersection<\n ARIAButtonElement<AlternateAs>\n>;\n\n/**\n * Props expected by `useARIAButtonProps` hooks\n */\nexport type ARIAButtonProps<Type extends ARIAButtonType = ARIAButtonType> = React.PropsWithRef<\n JSX.IntrinsicElements[Type]\n> & {\n disabled?: boolean;\n /**\n * When set, allows the button to be focusable even when it has been disabled.\n * This is used in scenarios where it is important to keep a consistent tab order\n * for screen reader and keyboard users. The primary example of this\n * pattern is when the disabled button is in a menu or a commandbar and is seldom used for standalone buttons.\n *\n * @default false\n */\n disabledFocusable?: boolean;\n};\n\nexport type ARIAButtonSlotProps<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = ExtractSlotProps<\n Slot<'button', AlternateAs>\n> &\n Pick<ARIAButtonProps<ARIAButtonType>, 'disabled' | 'disabledFocusable'>;\n\n/**\n * Props that will be modified internally by `useARIAButtonProps` by each case.\n * This typing is to ensure a well specified return value for `useARIAbButtonProps`\n */\nexport type ARIAButtonAlteredProps<Type extends ARIAButtonType> =\n | (Type extends 'button'\n ? Pick<\n JSX.IntrinsicElements['button'],\n 'onClick' | 'onKeyDown' | 'onKeyUp' | 'disabled' | 'aria-disabled' | 'tabIndex'\n >\n : never)\n | (Type extends 'a'\n ? Pick<\n JSX.IntrinsicElements['a'],\n 'onClick' | 'onKeyDown' | 'onKeyUp' | 'aria-disabled' | 'tabIndex' | 'role' | 'href'\n >\n : never)\n | (Type extends 'div'\n ? Pick<JSX.IntrinsicElements['div'], 'onClick' | 'onKeyDown' | 'onKeyUp' | 'aria-disabled' | 'tabIndex' | 'role'>\n : never);\n\n/**\n * Merge of props provided by the user and props provided internally.\n */\nexport type ARIAButtonResultProps<Type extends ARIAButtonType, Props> = Props &\n UnionToIntersection<ARIAButtonAlteredProps<Type>>;\n"],"names":["React"],"mappings":"AACA,YAAYA,WAAW,QAAQ"}
1
+ {"version":3,"sources":["types.ts"],"sourcesContent":["import type { ExtractSlotProps, Slot, UnionToIntersection } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nexport type ARIAButtonType = 'button' | 'a' | 'div';\n\nexport type ARIAButtonElement<AlternateAs extends 'a' | 'div' = 'a' | 'div'> =\n | HTMLButtonElement\n | (AlternateAs extends 'a' ? HTMLAnchorElement : never)\n | (AlternateAs extends 'div' ? HTMLDivElement : never);\n\n/**\n * @internal\n */\nexport type ARIAButtonElementIntersection<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = UnionToIntersection<\n ARIAButtonElement<AlternateAs>\n>;\n\n/**\n * Props expected by `useARIAButtonProps` hooks\n */\nexport type ARIAButtonProps<Type extends ARIAButtonType = ARIAButtonType> = React.PropsWithRef<\n JSX.IntrinsicElements[Type]\n> & {\n disabled?: boolean;\n /**\n * When set, allows the button to be focusable even when it has been disabled.\n * This is used in scenarios where it is important to keep a consistent tab order\n * for screen reader and keyboard users. The primary example of this\n * pattern is when the disabled button is in a menu or a commandbar and is seldom used for standalone buttons.\n *\n * @default false\n */\n disabledFocusable?: boolean;\n};\n\nexport type ARIAButtonSlotProps<AlternateAs extends 'a' | 'div' = 'a' | 'div'> = ExtractSlotProps<\n Slot<'button', AlternateAs>\n> &\n Pick<ARIAButtonProps<ARIAButtonType>, 'disabled' | 'disabledFocusable'>;\n\n/**\n * Props that will be modified internally by `useARIAButtonProps` by each case.\n * This typing is to ensure a well specified return value for `useARIAbButtonProps`\n */\nexport type ARIAButtonAlteredProps<Type extends ARIAButtonType> =\n | (Type extends 'button'\n ? Pick<\n JSX.IntrinsicElements['button'],\n 'onClick' | 'onKeyDown' | 'onKeyUp' | 'disabled' | 'aria-disabled' | 'tabIndex'\n >\n : never)\n | (Type extends 'a'\n ? Pick<\n JSX.IntrinsicElements['a'],\n 'onClick' | 'onKeyDown' | 'onKeyUp' | 'aria-disabled' | 'tabIndex' | 'role' | 'href'\n >\n : never)\n | (Type extends 'div'\n ? Pick<JSX.IntrinsicElements['div'], 'onClick' | 'onKeyDown' | 'onKeyUp' | 'aria-disabled' | 'tabIndex' | 'role'>\n : never);\n\n/**\n * Merge of props provided by the user and props provided internally.\n */\nexport type ARIAButtonResultProps<Type extends ARIAButtonType, Props> = Props &\n UnionToIntersection<ARIAButtonAlteredProps<Type>>;\n"],"names":["React"],"mappings":"AACA,YAAYA,WAAW,QAAQ"}
package/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { // eslint-disable-next-line deprecation/deprecation
2
2
  useARIAButtonShorthand, useARIAButtonProps } from './button/index';
3
3
  export { useActiveDescendant, ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE } from './activedescendant';
4
+ export { AriaLiveAnnouncer, renderAriaLiveAnnouncer_unstable, useAriaLiveAnnouncer_unstable, useAriaLiveAnnouncerContextValues_unstable } from './AriaLiveAnnouncer/index';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export {\n // eslint-disable-next-line deprecation/deprecation\n useARIAButtonShorthand,\n useARIAButtonProps,\n} from './button/index';\nexport { useActiveDescendant, ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE } from './activedescendant';\nexport type { ActiveDescendantImperativeRef, ActiveDescendantOptions } from './activedescendant';\nexport type {\n ARIAButtonSlotProps,\n ARIAButtonProps,\n ARIAButtonResultProps,\n ARIAButtonType,\n ARIAButtonElement,\n ARIAButtonElementIntersection,\n ARIAButtonAlteredProps,\n} from './button/index';\n"],"names":["useARIAButtonShorthand","useARIAButtonProps","useActiveDescendant","ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE"],"mappings":"AAAA,SACE,mDAAmD;AACnDA,sBAAsB,EACtBC,kBAAkB,QACb,iBAAiB;AACxB,SAASC,mBAAmB,EAAEC,uCAAuC,QAAQ,qBAAqB"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export {\n // eslint-disable-next-line deprecation/deprecation\n useARIAButtonShorthand,\n useARIAButtonProps,\n} from './button/index';\nexport { useActiveDescendant, ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE } from './activedescendant';\nexport type { ActiveDescendantImperativeRef, ActiveDescendantOptions } from './activedescendant';\nexport type {\n ARIAButtonSlotProps,\n ARIAButtonProps,\n ARIAButtonResultProps,\n ARIAButtonType,\n ARIAButtonElement,\n ARIAButtonElementIntersection,\n ARIAButtonAlteredProps,\n} from './button/index';\n\nexport {\n AriaLiveAnnouncer,\n renderAriaLiveAnnouncer_unstable,\n useAriaLiveAnnouncer_unstable,\n useAriaLiveAnnouncerContextValues_unstable,\n} from './AriaLiveAnnouncer/index';\nexport type { AriaLiveAnnouncerProps, AriaLiveAnnouncerState } from './AriaLiveAnnouncer/index';\n"],"names":["useARIAButtonShorthand","useARIAButtonProps","useActiveDescendant","ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE","AriaLiveAnnouncer","renderAriaLiveAnnouncer_unstable","useAriaLiveAnnouncer_unstable","useAriaLiveAnnouncerContextValues_unstable"],"mappings":"AAAA,SACE,mDAAmD;AACnDA,sBAAsB,EACtBC,kBAAkB,QACb,iBAAiB;AACxB,SAASC,mBAAmB,EAAEC,uCAAuC,QAAQ,qBAAqB;AAYlG,SACEC,iBAAiB,EACjBC,gCAAgC,EAChCC,6BAA6B,EAC7BC,0CAA0C,QACrC,4BAA4B"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "AriaLiveAnnouncer", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return AriaLiveAnnouncer;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _renderAriaLiveAnnouncer = require("./renderAriaLiveAnnouncer");
14
+ const _useAriaLiveAnnouncer = require("./useAriaLiveAnnouncer");
15
+ const _useAriaLiveAnnouncerContextValues = require("./useAriaLiveAnnouncerContextValues");
16
+ const AriaLiveAnnouncer = (props)=>{
17
+ const state = (0, _useAriaLiveAnnouncer.useAriaLiveAnnouncer_unstable)(props);
18
+ const contextValues = (0, _useAriaLiveAnnouncerContextValues.useAriaLiveAnnouncerContextValues_unstable)(state);
19
+ return (0, _renderAriaLiveAnnouncer.renderAriaLiveAnnouncer_unstable)(state, contextValues);
20
+ };
21
+ AriaLiveAnnouncer.displayName = 'AriaLiveAnnouncer';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["AriaLiveAnnouncer.js"],"sourcesContent":["import * as React from 'react';\nimport { renderAriaLiveAnnouncer_unstable } from './renderAriaLiveAnnouncer';\nimport { useAriaLiveAnnouncer_unstable } from './useAriaLiveAnnouncer';\nimport { useAriaLiveAnnouncerContextValues_unstable } from './useAriaLiveAnnouncerContextValues';\n/**\n * A sample implementation of a component that manages aria live announcements.\n */ export const AriaLiveAnnouncer = (props)=>{\n const state = useAriaLiveAnnouncer_unstable(props);\n const contextValues = useAriaLiveAnnouncerContextValues_unstable(state);\n return renderAriaLiveAnnouncer_unstable(state, contextValues);\n};\nAriaLiveAnnouncer.displayName = 'AriaLiveAnnouncer';\n"],"names":["AriaLiveAnnouncer","props","state","useAriaLiveAnnouncer_unstable","contextValues","useAriaLiveAnnouncerContextValues_unstable","renderAriaLiveAnnouncer_unstable","displayName"],"mappings":";;;;+BAMiBA;;;eAAAA;;;;iEANM;yCAC0B;sCACH;mDACa;AAGhD,MAAMA,oBAAoB,CAACC;IAClC,MAAMC,QAAQC,IAAAA,mDAA6B,EAACF;IAC5C,MAAMG,gBAAgBC,IAAAA,6EAA0C,EAACH;IACjE,OAAOI,IAAAA,yDAAgC,EAACJ,OAAOE;AACnD;AACAJ,kBAAkBO,WAAW,GAAG"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
6
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["AriaLiveAnnouncer.types.js"],"sourcesContent":["import * as React from 'react';\n"],"names":[],"mappings":";;;;;iEAAuB"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ AriaLiveAnnouncer: function() {
13
+ return _AriaLiveAnnouncer.AriaLiveAnnouncer;
14
+ },
15
+ renderAriaLiveAnnouncer_unstable: function() {
16
+ return _renderAriaLiveAnnouncer.renderAriaLiveAnnouncer_unstable;
17
+ },
18
+ useAriaLiveAnnouncer_unstable: function() {
19
+ return _useAriaLiveAnnouncer.useAriaLiveAnnouncer_unstable;
20
+ },
21
+ useAriaLiveAnnouncerContextValues_unstable: function() {
22
+ return _useAriaLiveAnnouncerContextValues.useAriaLiveAnnouncerContextValues_unstable;
23
+ }
24
+ });
25
+ const _AriaLiveAnnouncer = require("./AriaLiveAnnouncer");
26
+ const _renderAriaLiveAnnouncer = require("./renderAriaLiveAnnouncer");
27
+ const _useAriaLiveAnnouncer = require("./useAriaLiveAnnouncer");
28
+ const _useAriaLiveAnnouncerContextValues = require("./useAriaLiveAnnouncerContextValues");
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["export { AriaLiveAnnouncer } from './AriaLiveAnnouncer';\nexport { renderAriaLiveAnnouncer_unstable } from './renderAriaLiveAnnouncer';\nexport { useAriaLiveAnnouncer_unstable } from './useAriaLiveAnnouncer';\nexport { useAriaLiveAnnouncerContextValues_unstable } from './useAriaLiveAnnouncerContextValues';\n"],"names":["AriaLiveAnnouncer","renderAriaLiveAnnouncer_unstable","useAriaLiveAnnouncer_unstable","useAriaLiveAnnouncerContextValues_unstable"],"mappings":";;;;;;;;;;;IAASA,iBAAiB;eAAjBA,oCAAiB;;IACjBC,gCAAgC;eAAhCA,yDAAgC;;IAChCC,6BAA6B;eAA7BA,mDAA6B;;IAC7BC,0CAA0C;eAA1CA,6EAA0C;;;mCAHjB;yCACe;sCACH;mDACa"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "renderAriaLiveAnnouncer_unstable", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return renderAriaLiveAnnouncer_unstable;
9
+ }
10
+ });
11
+ const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
12
+ const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
13
+ const renderAriaLiveAnnouncer_unstable = (state, contextValues)=>{
14
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactsharedcontexts.AnnounceProvider, {
15
+ value: contextValues.announce,
16
+ children: state.children
17
+ });
18
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["renderAriaLiveAnnouncer.js"],"sourcesContent":[" import { jsx as _jsx } from \"@fluentui/react-jsx-runtime/jsx-runtime\";\nimport { AnnounceProvider } from '@fluentui/react-shared-contexts';\nexport const renderAriaLiveAnnouncer_unstable = (state, contextValues)=>{\n return /*#__PURE__*/ _jsx(AnnounceProvider, {\n value: contextValues.announce,\n children: state.children\n });\n};\n"],"names":["renderAriaLiveAnnouncer_unstable","state","contextValues","_jsx","AnnounceProvider","value","announce","children"],"mappings":";;;;+BAEaA;;;eAAAA;;;4BAFiB;qCACG;AAC1B,MAAMA,mCAAmC,CAACC,OAAOC;IACpD,OAAO,WAAW,GAAGC,IAAAA,eAAI,EAACC,qCAAgB,EAAE;QACxCC,OAAOH,cAAcI,QAAQ;QAC7BC,UAAUN,MAAMM,QAAQ;IAC5B;AACJ"}
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useAriaLiveAnnouncer_unstable", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useAriaLiveAnnouncer_unstable;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
13
+ const _reactutilities = require("@fluentui/react-utilities");
14
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
15
+ /** The duration the message needs to be in present in DOM for screen readers to register a change and announce */ const MESSAGE_DURATION = 500;
16
+ const VISUALLY_HIDDEN_STYLES = {
17
+ clip: 'rect(0px, 0px, 0px, 0px)',
18
+ height: '1px',
19
+ margin: '-1px',
20
+ width: '1px',
21
+ position: 'absolute',
22
+ overflow: 'hidden',
23
+ textWrap: 'nowrap'
24
+ };
25
+ const useAriaLiveAnnouncer_unstable = (props)=>{
26
+ const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
27
+ const timeoutRef = _react.useRef(undefined);
28
+ const [setAnnounceTimeout, clearAnnounceTimeout] = (0, _reactutilities.useTimeout)();
29
+ const elementRef = _react.useRef(null);
30
+ const order = _react.useRef(0);
31
+ // investigate alert implementation later
32
+ // const [alertList, setAlertList] = React.useState<string[]>([]);
33
+ const batchMessages = _react.useRef([]);
34
+ const [messageQueue] = _react.useState(()=>(0, _reactutilities.createPriorityQueue)((a, b)=>{
35
+ if (a.priority !== b.priority) {
36
+ return b.priority - a.priority;
37
+ }
38
+ return a.createdAt - b.createdAt;
39
+ }));
40
+ const queueMessage = _react.useCallback(()=>{
41
+ if (timeoutRef.current || !elementRef.current) {
42
+ return;
43
+ }
44
+ const runCycle = ()=>{
45
+ if (!elementRef.current) {
46
+ return;
47
+ }
48
+ if (targetDocument && messageQueue.peek()) {
49
+ // need a wrapping element for Narrator/Edge, which currently does not pick up text-only live region changes
50
+ // consistently
51
+ // if this is fixed, we can set textContent to the string directly
52
+ const wrappingEl = targetDocument.createElement('span');
53
+ wrappingEl.innerText = messageQueue.all().filter((msg)=>msg.message.trim().length > 0).reduce((prevText, currMsg)=>prevText + currMsg.message + '. ', '');
54
+ elementRef.current.innerText = '';
55
+ elementRef.current.appendChild(wrappingEl);
56
+ messageQueue.clear();
57
+ batchMessages.current = [];
58
+ // begin new cycle to clear (or update) messages
59
+ timeoutRef.current = setAnnounceTimeout(()=>{
60
+ runCycle();
61
+ }, MESSAGE_DURATION);
62
+ } else {
63
+ elementRef.current.textContent = '';
64
+ clearAnnounceTimeout();
65
+ timeoutRef.current = undefined;
66
+ }
67
+ };
68
+ runCycle();
69
+ }, [
70
+ clearAnnounceTimeout,
71
+ messageQueue,
72
+ setAnnounceTimeout,
73
+ targetDocument
74
+ ]);
75
+ const announce = _react.useMemo(()=>(message, options = {})=>{
76
+ const { alert = false, priority = 0, batchId } = options;
77
+ // check if message is an alert
78
+ if (alert) {
79
+ // TODO: alert implementation
80
+ // setAlertList([...alertList, message]);
81
+ }
82
+ const liveMessage = {
83
+ message,
84
+ createdAt: order.current++,
85
+ priority,
86
+ batchId
87
+ };
88
+ // check if batchId exists
89
+ if (batchId) {
90
+ // update associated msg if it does
91
+ const batchMessage = batchMessages.current.find((msg)=>msg.batchId === batchId);
92
+ if (batchMessage) {
93
+ // replace existing message in queue
94
+ messageQueue.remove(batchMessage.message);
95
+ // update list of existing batchIds w/ most recent message
96
+ batchMessage.message = liveMessage;
97
+ } else {
98
+ // update list of existing batchIds, add new if doesn't already exist
99
+ batchMessages.current = [
100
+ ...batchMessages.current,
101
+ {
102
+ batchId,
103
+ message: liveMessage
104
+ }
105
+ ];
106
+ }
107
+ }
108
+ // add new message
109
+ messageQueue.enqueue(liveMessage);
110
+ queueMessage();
111
+ }, [
112
+ messageQueue,
113
+ queueMessage
114
+ ]);
115
+ _react.useEffect(()=>{
116
+ if (!targetDocument) {
117
+ return;
118
+ }
119
+ const element = targetDocument.createElement('div');
120
+ element.setAttribute('aria-live', 'assertive');
121
+ Object.assign(element.style, VISUALLY_HIDDEN_STYLES);
122
+ targetDocument.body.append(element);
123
+ elementRef.current = element;
124
+ return ()=>{
125
+ element.remove();
126
+ elementRef.current = null;
127
+ };
128
+ }, [
129
+ targetDocument
130
+ ]);
131
+ return {
132
+ announce,
133
+ children: props.children
134
+ };
135
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useAriaLiveAnnouncer.js"],"sourcesContent":["import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { createPriorityQueue, useTimeout } from '@fluentui/react-utilities';\nimport * as React from 'react';\n/** The duration the message needs to be in present in DOM for screen readers to register a change and announce */ const MESSAGE_DURATION = 500;\nconst VISUALLY_HIDDEN_STYLES = {\n clip: 'rect(0px, 0px, 0px, 0px)',\n height: '1px',\n margin: '-1px',\n width: '1px',\n position: 'absolute',\n overflow: 'hidden',\n textWrap: 'nowrap'\n};\nexport const useAriaLiveAnnouncer_unstable = (props)=>{\n const { targetDocument } = useFluent();\n const timeoutRef = React.useRef(undefined);\n const [setAnnounceTimeout, clearAnnounceTimeout] = useTimeout();\n const elementRef = React.useRef(null);\n const order = React.useRef(0);\n // investigate alert implementation later\n // const [alertList, setAlertList] = React.useState<string[]>([]);\n const batchMessages = React.useRef([]);\n const [messageQueue] = React.useState(()=>createPriorityQueue((a, b)=>{\n if (a.priority !== b.priority) {\n return b.priority - a.priority;\n }\n return a.createdAt - b.createdAt;\n }));\n const queueMessage = React.useCallback(()=>{\n if (timeoutRef.current || !elementRef.current) {\n return;\n }\n const runCycle = ()=>{\n if (!elementRef.current) {\n return;\n }\n if (targetDocument && messageQueue.peek()) {\n // need a wrapping element for Narrator/Edge, which currently does not pick up text-only live region changes\n // consistently\n // if this is fixed, we can set textContent to the string directly\n const wrappingEl = targetDocument.createElement('span');\n wrappingEl.innerText = messageQueue.all().filter((msg)=>msg.message.trim().length > 0).reduce((prevText, currMsg)=>prevText + currMsg.message + '. ', '');\n elementRef.current.innerText = '';\n elementRef.current.appendChild(wrappingEl);\n messageQueue.clear();\n batchMessages.current = [];\n // begin new cycle to clear (or update) messages\n timeoutRef.current = setAnnounceTimeout(()=>{\n runCycle();\n }, MESSAGE_DURATION);\n } else {\n elementRef.current.textContent = '';\n clearAnnounceTimeout();\n timeoutRef.current = undefined;\n }\n };\n runCycle();\n }, [\n clearAnnounceTimeout,\n messageQueue,\n setAnnounceTimeout,\n targetDocument\n ]);\n const announce = React.useMemo(()=>(message, options = {})=>{\n const { alert = false, priority = 0, batchId } = options;\n // check if message is an alert\n if (alert) {\n // TODO: alert implementation\n // setAlertList([...alertList, message]);\n }\n const liveMessage = {\n message,\n createdAt: order.current++,\n priority,\n batchId\n };\n // check if batchId exists\n if (batchId) {\n // update associated msg if it does\n const batchMessage = batchMessages.current.find((msg)=>msg.batchId === batchId);\n if (batchMessage) {\n // replace existing message in queue\n messageQueue.remove(batchMessage.message);\n // update list of existing batchIds w/ most recent message\n batchMessage.message = liveMessage;\n } else {\n // update list of existing batchIds, add new if doesn't already exist\n batchMessages.current = [\n ...batchMessages.current,\n {\n batchId,\n message: liveMessage\n }\n ];\n }\n }\n // add new message\n messageQueue.enqueue(liveMessage);\n queueMessage();\n }, [\n messageQueue,\n queueMessage\n ]);\n React.useEffect(()=>{\n if (!targetDocument) {\n return;\n }\n const element = targetDocument.createElement('div');\n element.setAttribute('aria-live', 'assertive');\n Object.assign(element.style, VISUALLY_HIDDEN_STYLES);\n targetDocument.body.append(element);\n elementRef.current = element;\n return ()=>{\n element.remove();\n elementRef.current = null;\n };\n }, [\n targetDocument\n ]);\n return {\n announce,\n children: props.children\n };\n};\n"],"names":["useAriaLiveAnnouncer_unstable","MESSAGE_DURATION","VISUALLY_HIDDEN_STYLES","clip","height","margin","width","position","overflow","textWrap","props","targetDocument","useFluent","timeoutRef","React","useRef","undefined","setAnnounceTimeout","clearAnnounceTimeout","useTimeout","elementRef","order","batchMessages","messageQueue","useState","createPriorityQueue","a","b","priority","createdAt","queueMessage","useCallback","current","runCycle","peek","wrappingEl","createElement","innerText","all","filter","msg","message","trim","length","reduce","prevText","currMsg","appendChild","clear","textContent","announce","useMemo","options","alert","batchId","liveMessage","batchMessage","find","remove","enqueue","useEffect","element","setAttribute","Object","assign","style","body","append","children"],"mappings":";;;;+BAaaA;;;eAAAA;;;;qCAbmC;gCACA;iEACzB;AACvB,gHAAgH,GAAG,MAAMC,mBAAmB;AAC5I,MAAMC,yBAAyB;IAC3BC,MAAM;IACNC,QAAQ;IACRC,QAAQ;IACRC,OAAO;IACPC,UAAU;IACVC,UAAU;IACVC,UAAU;AACd;AACO,MAAMT,gCAAgC,CAACU;IAC1C,MAAM,EAAEC,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,MAAMC,aAAaC,OAAMC,MAAM,CAACC;IAChC,MAAM,CAACC,oBAAoBC,qBAAqB,GAAGC,IAAAA,0BAAU;IAC7D,MAAMC,aAAaN,OAAMC,MAAM,CAAC;IAChC,MAAMM,QAAQP,OAAMC,MAAM,CAAC;IAC3B,yCAAyC;IACzC,kEAAkE;IAClE,MAAMO,gBAAgBR,OAAMC,MAAM,CAAC,EAAE;IACrC,MAAM,CAACQ,aAAa,GAAGT,OAAMU,QAAQ,CAAC,IAAIC,IAAAA,mCAAmB,EAAC,CAACC,GAAGC;YAC1D,IAAID,EAAEE,QAAQ,KAAKD,EAAEC,QAAQ,EAAE;gBAC3B,OAAOD,EAAEC,QAAQ,GAAGF,EAAEE,QAAQ;YAClC;YACA,OAAOF,EAAEG,SAAS,GAAGF,EAAEE,SAAS;QACpC;IACJ,MAAMC,eAAehB,OAAMiB,WAAW,CAAC;QACnC,IAAIlB,WAAWmB,OAAO,IAAI,CAACZ,WAAWY,OAAO,EAAE;YAC3C;QACJ;QACA,MAAMC,WAAW;YACb,IAAI,CAACb,WAAWY,OAAO,EAAE;gBACrB;YACJ;YACA,IAAIrB,kBAAkBY,aAAaW,IAAI,IAAI;gBACvC,4GAA4G;gBAC5G,eAAe;gBACf,kEAAkE;gBAClE,MAAMC,aAAaxB,eAAeyB,aAAa,CAAC;gBAChDD,WAAWE,SAAS,GAAGd,aAAae,GAA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AAkB;YAClBhC,aAAaoC,OAAO,CAACJ;YACrBzB;QACJ,GAAG;QACHP;QACAO;KACH;IACDhB,OAAM8C,SAAS,CAAC;QACZ,IAAI,CAACjD,gBAAgB;YACjB;QACJ;QACA,MAAMkD,UAAUlD,eAAeyB,aAAa,CAAC;QAC7CyB,QAAQC,YAAY,CAAC,aAAa;QAClCC,OAAOC,MAAM,CAACH,QAAQI,KAAK,EAAE/D;QAC7BS,eAAeuD,IAAI,CAACC,MAAM,CAACN;QAC3BzC,WAAWY,OAAO,GAAG6B;QACrB,OAAO;YACHA,QAAQH,MAAM;YACdtC,WAAWY,OAAO,GAAG;QACzB;IACJ,GAAG;QACCrB;KACH;IACD,OAAO;QACHuC;QACAkB,UAAU1D,MAAM0D,QAAQ;IAC5B;AACJ"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useAriaLiveAnnouncerContextValues_unstable", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return useAriaLiveAnnouncerContextValues_unstable;
9
+ }
10
+ });
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ function useAriaLiveAnnouncerContextValues_unstable(state) {
14
+ const { announce } = state;
15
+ return _react.useMemo(()=>({
16
+ announce: {
17
+ announce
18
+ }
19
+ }), [
20
+ announce
21
+ ]);
22
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useAriaLiveAnnouncerContextValues.js"],"sourcesContent":["import * as React from 'react';\nexport function useAriaLiveAnnouncerContextValues_unstable(state) {\n const { announce } = state;\n return React.useMemo(()=>({\n announce: {\n announce\n }\n }), [\n announce\n ]);\n}\n"],"names":["useAriaLiveAnnouncerContextValues_unstable","state","announce","React","useMemo"],"mappings":";;;;+BACgBA;;;eAAAA;;;;iEADO;AAChB,SAASA,2CAA2CC,KAAK;IAC5D,MAAM,EAAEC,QAAQ,EAAE,GAAGD;IACrB,OAAOE,OAAMC,OAAO,CAAC,IAAK,CAAA;YAClBF,UAAU;gBACNA;YACJ;QACJ,CAAA,GAAI;QACJA;KACH;AACL"}
@@ -20,7 +20,20 @@ _export(exports, {
20
20
  },
21
21
  ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE: function() {
22
22
  return _activedescendant.ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE;
23
+ },
24
+ AriaLiveAnnouncer: function() {
25
+ return _index1.AriaLiveAnnouncer;
26
+ },
27
+ renderAriaLiveAnnouncer_unstable: function() {
28
+ return _index1.renderAriaLiveAnnouncer_unstable;
29
+ },
30
+ useAriaLiveAnnouncer_unstable: function() {
31
+ return _index1.useAriaLiveAnnouncer_unstable;
32
+ },
33
+ useAriaLiveAnnouncerContextValues_unstable: function() {
34
+ return _index1.useAriaLiveAnnouncerContextValues_unstable;
23
35
  }
24
36
  });
25
37
  const _index = require("./button/index");
26
38
  const _activedescendant = require("./activedescendant");
39
+ const _index1 = require("./AriaLiveAnnouncer/index");
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js"],"sourcesContent":["export { // eslint-disable-next-line deprecation/deprecation\nuseARIAButtonShorthand, useARIAButtonProps } from './button/index';\nexport { useActiveDescendant, ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE } from './activedescendant';\n"],"names":["useARIAButtonShorthand","useARIAButtonProps","useActiveDescendant","ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE"],"mappings":";;;;;;;;;;;IACAA,sBAAsB;eAAtBA,6BAAsB;;IAAEC,kBAAkB;eAAlBA,yBAAkB;;IACjCC,mBAAmB;eAAnBA,qCAAmB;;IAAEC,uCAAuC;eAAvCA,yDAAuC;;;uBADnB;kCAC2B"}
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["export { // eslint-disable-next-line deprecation/deprecation\nuseARIAButtonShorthand, useARIAButtonProps } from './button/index';\nexport { useActiveDescendant, ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE } from './activedescendant';\nexport { AriaLiveAnnouncer, renderAriaLiveAnnouncer_unstable, useAriaLiveAnnouncer_unstable, useAriaLiveAnnouncerContextValues_unstable } from './AriaLiveAnnouncer/index';\n"],"names":["useARIAButtonShorthand","useARIAButtonProps","useActiveDescendant","ACTIVEDESCENDANT_FOCUSVISIBLE_ATTRIBUTE","AriaLiveAnnouncer","renderAriaLiveAnnouncer_unstable","useAriaLiveAnnouncer_unstable","useAriaLiveAnnouncerContextValues_unstable"],"mappings":";;;;;;;;;;;IACAA,sBAAsB;eAAtBA,6BAAsB;;IAAEC,kBAAkB;eAAlBA,yBAAkB;;IACjCC,mBAAmB;eAAnBA,qCAAmB;;IAAEC,uCAAuC;eAAvCA,yDAAuC;;IAC5DC,iBAAiB;eAAjBA,yBAAiB;;IAAEC,gCAAgC;eAAhCA,wCAAgC;;IAAEC,6BAA6B;eAA7BA,qCAA6B;;IAAEC,0CAA0C;eAA1CA,kDAA0C;;;uBAFrF;kCAC2B;wBACkE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-aria",
3
- "version": "9.7.3",
3
+ "version": "9.8.1",
4
4
  "description": "React helper to ensure ARIA",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -35,8 +35,8 @@
35
35
  "dependencies": {
36
36
  "@fluentui/keyboard-keys": "^9.0.7",
37
37
  "@fluentui/react-shared-contexts": "^9.14.0",
38
- "@fluentui/react-tabster": "^9.17.3",
39
- "@fluentui/react-utilities": "^9.16.1",
38
+ "@fluentui/react-tabster": "^9.18.0",
39
+ "@fluentui/react-utilities": "^9.18.0",
40
40
  "@swc/helpers": "^0.5.1"
41
41
  },
42
42
  "peerDependencies": {