@fluentui/react-tabster 9.17.4 → 9.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -2
- package/dist/index.d.ts +29 -17
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useKeyborg.js +19 -0
- package/lib/hooks/useKeyborg.js.map +1 -0
- package/lib/hooks/useOnKeyboardNavigationChange.js +2 -11
- package/lib/hooks/useOnKeyboardNavigationChange.js.map +1 -1
- package/lib/hooks/useSetKeyboardNavigation.js +11 -0
- package/lib/hooks/useSetKeyboardNavigation.js.map +1 -0
- package/lib/hooks/useTabster.js +5 -2
- package/lib/hooks/useTabster.js.map +1 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/hooks/index.js +1 -0
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useKeyborg.js +26 -0
- package/lib-commonjs/hooks/useKeyborg.js.map +1 -0
- package/lib-commonjs/hooks/useOnKeyboardNavigationChange.js +2 -11
- package/lib-commonjs/hooks/useOnKeyboardNavigationChange.js.map +1 -1
- package/lib-commonjs/hooks/useSetKeyboardNavigation.js +21 -0
- package/lib-commonjs/hooks/useSetKeyboardNavigation.js.map +1 -0
- package/lib-commonjs/hooks/useTabster.js +5 -2
- package/lib-commonjs/hooks/useTabster.js.map +1 -1
- package/lib-commonjs/index.js +13 -0
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,35 @@
|
|
1
1
|
# Change Log - @fluentui/react-tabster
|
2
2
|
|
3
|
-
This log was last generated on Tue,
|
3
|
+
This log was last generated on Tue, 06 Feb 2024 17:52:09 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.19.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-tabster_v9.19.0)
|
8
|
+
|
9
|
+
Tue, 06 Feb 2024 17:52:09 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tabster_v9.18.0..@fluentui/react-tabster_v9.19.0)
|
11
|
+
|
12
|
+
### Minor changes
|
13
|
+
|
14
|
+
- feat: useSetKeyboardNavigation hook ([PR #30316](https://github.com/microsoft/fluentui/pull/30316) by lingfangao@hotmail.com)
|
15
|
+
|
16
|
+
## [9.18.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-tabster_v9.18.0)
|
17
|
+
|
18
|
+
Tue, 30 Jan 2024 23:16:53 GMT
|
19
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tabster_v9.17.4..@fluentui/react-tabster_v9.18.0)
|
20
|
+
|
21
|
+
### Minor changes
|
22
|
+
|
23
|
+
- Optional ShadowDOM support. ([PR #30429](https://github.com/microsoft/fluentui/pull/30429) by marata@microsoft.com)
|
24
|
+
- Bump @fluentui/react-utilities to v9.18.0 ([PR #29983](https://github.com/microsoft/fluentui/pull/29983) by beachball)
|
25
|
+
|
26
|
+
### Patches
|
27
|
+
|
28
|
+
- Tabster 5.3.0 and Keyborg 2.4.1. ([PR #30387](https://github.com/microsoft/fluentui/pull/30387) by marata@microsoft.com)
|
29
|
+
|
7
30
|
## [9.17.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-tabster_v9.17.4)
|
8
31
|
|
9
|
-
Tue, 23 Jan 2024 15:
|
32
|
+
Tue, 23 Jan 2024 15:11:00 GMT
|
10
33
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tabster_v9.17.3..@fluentui/react-tabster_v9.17.4)
|
11
34
|
|
12
35
|
### Patches
|
package/dist/index.d.ts
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
import { dispatchGroupperMoveFocusEvent } from 'tabster';
|
2
|
+
import { dispatchMoverMoveFocusEvent } from 'tabster';
|
1
3
|
import type { GriffelStyle } from '@griffel/react';
|
2
4
|
import { KEYBORG_FOCUSIN } from 'keyborg';
|
3
5
|
import { KeyborgFocusInEvent } from 'keyborg';
|
4
6
|
import { makeResetStyles } from '@griffel/react';
|
5
7
|
import * as React_2 from 'react';
|
6
8
|
import type { RefObject } from 'react';
|
7
|
-
import { Types } from 'tabster';
|
9
|
+
import { Types as TabsterTypes } from 'tabster';
|
8
10
|
|
9
11
|
/**
|
10
12
|
* @internal
|
@@ -82,6 +84,10 @@ export declare interface CreateFocusOutlineStyleOptions extends Omit<CreateCusto
|
|
82
84
|
enableOutline?: boolean;
|
83
85
|
}
|
84
86
|
|
87
|
+
export { dispatchGroupperMoveFocusEvent }
|
88
|
+
|
89
|
+
export { dispatchMoverMoveFocusEvent }
|
90
|
+
|
85
91
|
export declare type FocusOutlineOffset = Record<'top' | 'bottom' | 'left' | 'right', string>;
|
86
92
|
|
87
93
|
export declare type FocusOutlineStyleOptions = {
|
@@ -101,13 +107,15 @@ export { KEYBORG_FOCUSIN }
|
|
101
107
|
|
102
108
|
export { KeyborgFocusInEvent }
|
103
109
|
|
104
|
-
export declare type TabsterDOMAttribute =
|
110
|
+
export declare type TabsterDOMAttribute = TabsterTypes.TabsterDOMAttribute;
|
111
|
+
|
112
|
+
export { TabsterTypes }
|
105
113
|
|
106
114
|
/**
|
107
115
|
* A hook that returns the necessary tabster attributes to support arrow key navigation
|
108
116
|
* @param options - Options to configure keyboard navigation
|
109
117
|
*/
|
110
|
-
export declare const useArrowNavigationGroup: (options?: UseArrowNavigationGroupOptions) =>
|
118
|
+
export declare const useArrowNavigationGroup: (options?: UseArrowNavigationGroupOptions) => TabsterTypes.TabsterDOMAttribute;
|
111
119
|
|
112
120
|
export declare interface UseArrowNavigationGroupOptions {
|
113
121
|
/**
|
@@ -132,7 +140,7 @@ export declare interface UseArrowNavigationGroupOptions {
|
|
132
140
|
/**
|
133
141
|
* Tabster should ignore default handling of keydown events
|
134
142
|
*/
|
135
|
-
ignoreDefaultKeydown?:
|
143
|
+
ignoreDefaultKeydown?: TabsterTypes.FocusableProps['ignoreKeydown'];
|
136
144
|
/**
|
137
145
|
* The default focusable item in the group will be an element with Focusable.isDefault property.
|
138
146
|
* Note that there is no way in \@fluentui/react-tabster to set default focusable element,
|
@@ -145,7 +153,7 @@ export declare interface UseArrowNavigationGroupOptions {
|
|
145
153
|
* A hook that returns the necessary tabster attributes to support groupping.
|
146
154
|
* @param options - Options to configure keyboard navigation
|
147
155
|
*/
|
148
|
-
export declare const useFocusableGroup: (options?: UseFocusableGroupOptions) =>
|
156
|
+
export declare const useFocusableGroup: (options?: UseFocusableGroupOptions) => TabsterTypes.TabsterDOMAttribute;
|
149
157
|
|
150
158
|
export declare interface UseFocusableGroupOptions {
|
151
159
|
/**
|
@@ -155,7 +163,7 @@ export declare interface UseFocusableGroupOptions {
|
|
155
163
|
/**
|
156
164
|
* Tabster can ignore default handling of keydown events
|
157
165
|
*/
|
158
|
-
ignoreDefaultKeydown?:
|
166
|
+
ignoreDefaultKeydown?: TabsterTypes.FocusableProps['ignoreKeydown'];
|
159
167
|
}
|
160
168
|
|
161
169
|
/**
|
@@ -165,8 +173,8 @@ export declare const useFocusFinders: () => {
|
|
165
173
|
findAllFocusable: (container: HTMLElement, acceptCondition?: ((el: HTMLElement) => boolean) | undefined) => HTMLElement[];
|
166
174
|
findFirstFocusable: (container: HTMLElement) => HTMLElement | null | undefined;
|
167
175
|
findLastFocusable: (container: HTMLElement) => HTMLElement | null | undefined;
|
168
|
-
findNextFocusable: (currentElement: HTMLElement, options?: Pick<Partial<
|
169
|
-
findPrevFocusable: (currentElement: HTMLElement, options?: Pick<Partial<
|
176
|
+
findNextFocusable: (currentElement: HTMLElement, options?: Pick<Partial<TabsterTypes.FindNextProps>, 'container'>) => HTMLElement | null | undefined;
|
177
|
+
findPrevFocusable: (currentElement: HTMLElement, options?: Pick<Partial<TabsterTypes.FindNextProps>, 'container'>) => HTMLElement | null | undefined;
|
170
178
|
};
|
171
179
|
|
172
180
|
/**
|
@@ -174,7 +182,7 @@ export declare const useFocusFinders: () => {
|
|
174
182
|
* @param name - The observed element to focus
|
175
183
|
* @returns Function that will focus the
|
176
184
|
*/
|
177
|
-
export declare function useFocusObserved(name: string, options?: UseFocusObservedOptions): () =>
|
185
|
+
export declare function useFocusObserved(name: string, options?: UseFocusObservedOptions): () => TabsterTypes.ObservedElementAsyncRequest<boolean>;
|
178
186
|
|
179
187
|
declare interface UseFocusObservedOptions {
|
180
188
|
/**
|
@@ -211,7 +219,7 @@ export declare function useKeyboardNavAttribute<E extends HTMLElement>(): RefObj
|
|
211
219
|
* @param attributes - collection of tabster attributes from other react-tabster hooks
|
212
220
|
* @returns single merged tabster attribute
|
213
221
|
*/
|
214
|
-
export declare const useMergedTabsterAttributes_unstable: (...attributes:
|
222
|
+
export declare const useMergedTabsterAttributes_unstable: (...attributes: TabsterTypes.TabsterDOMAttribute[]) => TabsterTypes.TabsterDOMAttribute;
|
215
223
|
|
216
224
|
/**
|
217
225
|
* Applies modal dialog behaviour through DOM attributes
|
@@ -221,8 +229,8 @@ export declare const useMergedTabsterAttributes_unstable: (...attributes: Types.
|
|
221
229
|
* @returns DOM attributes to apply to the modal element and its trigger
|
222
230
|
*/
|
223
231
|
export declare const useModalAttributes: (options?: UseModalAttributesOptions) => {
|
224
|
-
modalAttributes:
|
225
|
-
triggerAttributes:
|
232
|
+
modalAttributes: TabsterTypes.TabsterDOMAttribute;
|
233
|
+
triggerAttributes: TabsterTypes.TabsterDOMAttribute;
|
226
234
|
};
|
227
235
|
|
228
236
|
export declare interface UseModalAttributesOptions {
|
@@ -250,7 +258,7 @@ export declare interface UseModalAttributesOptions {
|
|
250
258
|
id?: string;
|
251
259
|
}
|
252
260
|
|
253
|
-
export declare function useObservedElement(name: string | string[]):
|
261
|
+
export declare function useObservedElement(name: string | string[]): TabsterTypes.TabsterDOMAttribute;
|
254
262
|
|
255
263
|
/**
|
256
264
|
* Instantiates [keyborg](https://github.com/microsoft/keyborg) and subscribes to changes
|
@@ -264,24 +272,28 @@ export declare function useOnKeyboardNavigationChange(callback: (isNavigatingWit
|
|
264
272
|
* Focus will be restored to the most recent target element when it is lost from a source
|
265
273
|
* @returns Attribute to apply to the element that might lose focus
|
266
274
|
*/
|
267
|
-
export declare function useRestoreFocusSource():
|
275
|
+
export declare function useRestoreFocusSource(): TabsterTypes.TabsterDOMAttribute;
|
268
276
|
|
269
277
|
/**
|
270
278
|
* Focus will be restored to the most recent target element when it is lost from a source
|
271
279
|
* @returns Attribute to apply to the target element where focus is restored
|
272
280
|
*/
|
273
|
-
export declare function useRestoreFocusTarget():
|
281
|
+
export declare function useRestoreFocusTarget(): TabsterTypes.TabsterDOMAttribute;
|
282
|
+
|
283
|
+
/**
|
284
|
+
*/
|
285
|
+
export declare function useSetKeyboardNavigation(): (isNavigatingWithKeyboard: boolean) => void;
|
274
286
|
|
275
287
|
/**
|
276
288
|
* @internal
|
277
289
|
* Hook that returns tabster attributes while ensuring tabster exists
|
278
290
|
*/
|
279
|
-
export declare const useTabsterAttributes: (props:
|
291
|
+
export declare const useTabsterAttributes: (props: TabsterTypes.TabsterAttributeProps) => TabsterTypes.TabsterDOMAttribute;
|
280
292
|
|
281
293
|
/**
|
282
294
|
* Designates an area where tabster does not control focus
|
283
295
|
* @returns Attribute to apply to the target element that should be uncontrolled by tabster
|
284
296
|
*/
|
285
|
-
export declare function useUncontrolledFocus():
|
297
|
+
export declare function useUncontrolledFocus(): TabsterTypes.TabsterDOMAttribute;
|
286
298
|
|
287
299
|
export { }
|
package/lib/hooks/index.js
CHANGED
package/lib/hooks/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './useArrowNavigationGroup';\nexport * from './useFocusableGroup';\nexport * from './useFocusFinders';\nexport * from './useFocusVisible';\nexport * from './useFocusWithin';\nexport * from './useKeyboardNavAttribute';\nexport * from './useOnKeyboardNavigationChange';\nexport * from './useModalAttributes';\nexport * from './useTabsterAttributes';\nexport * from './useObservedElement';\nexport * from './useMergeTabsterAttributes';\nexport * from './useFocusObserved';\nexport * from './useRestoreFocus';\nexport * from './useUncontrolledFocus';\n"],"names":[],"mappings":"AAAA,cAAc,4BAA4B;AAC1C,cAAc,sBAAsB;AACpC,cAAc,oBAAoB;AAClC,cAAc,oBAAoB;AAClC,cAAc,mBAAmB;AACjC,cAAc,4BAA4B;AAC1C,cAAc,kCAAkC;AAChD,cAAc,uBAAuB;AACrC,cAAc,yBAAyB;AACvC,cAAc,uBAAuB;AACrC,cAAc,8BAA8B;AAC5C,cAAc,qBAAqB;AACnC,cAAc,oBAAoB;AAClC,cAAc,yBAAyB"}
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './useArrowNavigationGroup';\nexport * from './useFocusableGroup';\nexport * from './useFocusFinders';\nexport * from './useFocusVisible';\nexport * from './useFocusWithin';\nexport * from './useKeyboardNavAttribute';\nexport * from './useOnKeyboardNavigationChange';\nexport * from './useModalAttributes';\nexport * from './useTabsterAttributes';\nexport * from './useObservedElement';\nexport * from './useMergeTabsterAttributes';\nexport * from './useFocusObserved';\nexport * from './useRestoreFocus';\nexport * from './useUncontrolledFocus';\nexport * from './useSetKeyboardNavigation';\n"],"names":[],"mappings":"AAAA,cAAc,4BAA4B;AAC1C,cAAc,sBAAsB;AACpC,cAAc,oBAAoB;AAClC,cAAc,oBAAoB;AAClC,cAAc,mBAAmB;AACjC,cAAc,4BAA4B;AAC1C,cAAc,kCAAkC;AAChD,cAAc,uBAAuB;AACrC,cAAc,yBAAyB;AACvC,cAAc,uBAAuB;AACrC,cAAc,8BAA8B;AAC5C,cAAc,qBAAqB;AACnC,cAAc,oBAAoB;AAClC,cAAc,yBAAyB;AACvC,cAAc,6BAA6B"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { createKeyborg, disposeKeyborg } from 'keyborg';
|
3
|
+
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
4
|
+
/**
|
5
|
+
* @internal
|
6
|
+
* Instantiates [keyborg](https://github.com/microsoft/keyborg)
|
7
|
+
* @returns - keyborg instance
|
8
|
+
*/ export function useKeyborg() {
|
9
|
+
const { targetDocument } = useFluent();
|
10
|
+
const keyborg = React.useMemo(()=>targetDocument && createKeyborg(targetDocument.defaultView), [
|
11
|
+
targetDocument
|
12
|
+
]);
|
13
|
+
React.useEffect(()=>{
|
14
|
+
return ()=>keyborg && disposeKeyborg(keyborg);
|
15
|
+
}, [
|
16
|
+
keyborg
|
17
|
+
]);
|
18
|
+
return keyborg;
|
19
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useKeyborg.ts"],"sourcesContent":["import * as React from 'react';\nimport { createKeyborg, disposeKeyborg } from 'keyborg';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\n/**\n * @internal\n * Instantiates [keyborg](https://github.com/microsoft/keyborg)\n * @returns - keyborg instance\n */\nexport function useKeyborg() {\n const { targetDocument } = useFluent();\n const keyborg = React.useMemo(() => targetDocument && createKeyborg(targetDocument.defaultView!), [targetDocument]);\n\n React.useEffect(() => {\n return () => keyborg && disposeKeyborg(keyborg);\n }, [keyborg]);\n\n return keyborg;\n}\n"],"names":["React","createKeyborg","disposeKeyborg","useFluent_unstable","useFluent","useKeyborg","targetDocument","keyborg","useMemo","defaultView","useEffect"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,aAAa,EAAEC,cAAc,QAAQ,UAAU;AACxD,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAElF;;;;CAIC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,cAAc,EAAE,GAAGF;IAC3B,MAAMG,UAAUP,MAAMQ,OAAO,CAAC,IAAMF,kBAAkBL,cAAcK,eAAeG,WAAW,GAAI;QAACH;KAAe;IAElHN,MAAMU,SAAS,CAAC;QACd,OAAO,IAAMH,WAAWL,eAAeK;IACzC,GAAG;QAACA;KAAQ;IAEZ,OAAOA;AACT"}
|
@@ -1,17 +1,13 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import { createKeyborg, disposeKeyborg } from 'keyborg';
|
3
|
-
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
4
2
|
import { useEventCallback } from '@fluentui/react-utilities';
|
3
|
+
import { useKeyborg } from './useKeyborg';
|
5
4
|
/**
|
6
5
|
* Instantiates [keyborg](https://github.com/microsoft/keyborg) and subscribes to changes
|
7
6
|
* in the keyboard navigation mode.
|
8
7
|
*
|
9
8
|
* @param callback - called every time the keyboard navigation state changes
|
10
9
|
*/ export function useOnKeyboardNavigationChange(callback) {
|
11
|
-
const
|
12
|
-
const keyborg = React.useMemo(()=>targetDocument && createKeyborg(targetDocument.defaultView), [
|
13
|
-
targetDocument
|
14
|
-
]);
|
10
|
+
const keyborg = useKeyborg();
|
15
11
|
const eventCallback = useEventCallback(callback);
|
16
12
|
React.useEffect(()=>{
|
17
13
|
if (keyborg) {
|
@@ -25,9 +21,4 @@ import { useEventCallback } from '@fluentui/react-utilities';
|
|
25
21
|
keyborg,
|
26
22
|
eventCallback
|
27
23
|
]);
|
28
|
-
React.useEffect(()=>{
|
29
|
-
return ()=>keyborg && disposeKeyborg(keyborg);
|
30
|
-
}, [
|
31
|
-
keyborg
|
32
|
-
]);
|
33
24
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useOnKeyboardNavigationChange.ts"],"sourcesContent":["import * as React from 'react';\nimport {
|
1
|
+
{"version":3,"sources":["useOnKeyboardNavigationChange.ts"],"sourcesContent":["import * as React from 'react';\nimport type { KeyborgCallback } from 'keyborg';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport { useKeyborg } from './useKeyborg';\n\n/**\n * Instantiates [keyborg](https://github.com/microsoft/keyborg) and subscribes to changes\n * in the keyboard navigation mode.\n *\n * @param callback - called every time the keyboard navigation state changes\n */\nexport function useOnKeyboardNavigationChange(callback: (isNavigatingWithKeyboard: boolean) => void) {\n const keyborg = useKeyborg();\n const eventCallback = useEventCallback(callback);\n React.useEffect(() => {\n if (keyborg) {\n const cb: KeyborgCallback = next => {\n eventCallback(next);\n };\n keyborg.subscribe(cb);\n return () => keyborg.unsubscribe(cb);\n }\n }, [keyborg, eventCallback]);\n}\n"],"names":["React","useEventCallback","useKeyborg","useOnKeyboardNavigationChange","callback","keyborg","eventCallback","useEffect","cb","next","subscribe","unsubscribe"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,UAAU,QAAQ,eAAe;AAE1C;;;;;CAKC,GACD,OAAO,SAASC,8BAA8BC,QAAqD;IACjG,MAAMC,UAAUH;IAChB,MAAMI,gBAAgBL,iBAAiBG;IACvCJ,MAAMO,SAAS,CAAC;QACd,IAAIF,SAAS;YACX,MAAMG,KAAsBC,CAAAA;gBAC1BH,cAAcG;YAChB;YACAJ,QAAQK,SAAS,CAACF;YAClB,OAAO,IAAMH,QAAQM,WAAW,CAACH;QACnC;IACF,GAAG;QAACH;QAASC;KAAc;AAC7B"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { useKeyborg } from './useKeyborg';
|
3
|
+
/**
|
4
|
+
*/ export function useSetKeyboardNavigation() {
|
5
|
+
const keyborg = useKeyborg();
|
6
|
+
return React.useCallback((isNavigatingWithKeyboard)=>{
|
7
|
+
keyborg === null || keyborg === void 0 ? void 0 : keyborg.setVal(isNavigatingWithKeyboard);
|
8
|
+
}, [
|
9
|
+
keyborg
|
10
|
+
]);
|
11
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useSetKeyboardNavigation.ts"],"sourcesContent":["import * as React from 'react';\nimport { useKeyborg } from './useKeyborg';\n\n/**\n */\nexport function useSetKeyboardNavigation() {\n const keyborg = useKeyborg();\n\n return React.useCallback(\n (isNavigatingWithKeyboard: boolean) => {\n keyborg?.setVal(isNavigatingWithKeyboard);\n },\n [keyborg],\n );\n}\n"],"names":["React","useKeyborg","useSetKeyboardNavigation","keyborg","useCallback","isNavigatingWithKeyboard","setVal"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,UAAU,QAAQ,eAAe;AAE1C;CACC,GACD,OAAO,SAASC;IACd,MAAMC,UAAUF;IAEhB,OAAOD,MAAMI,WAAW,CACtB,CAACC;QACCF,oBAAAA,8BAAAA,QAASG,MAAM,CAACD;IAClB,GACA;QAACF;KAAQ;AAEb"}
|
package/lib/hooks/useTabster.js
CHANGED
@@ -11,6 +11,7 @@ import { useIsomorphicLayoutEffect, getParent } from '@fluentui/react-utilities'
|
|
11
11
|
*/ export const useTabster = ()=>{
|
12
12
|
const { targetDocument } = useFluent();
|
13
13
|
const defaultView = (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) || undefined;
|
14
|
+
const shadowDOMAPI = defaultView === null || defaultView === void 0 ? void 0 : defaultView.__tabsterShadowDOMAPI;
|
14
15
|
const tabster = React.useMemo(()=>{
|
15
16
|
if (!defaultView) {
|
16
17
|
return null;
|
@@ -22,10 +23,12 @@ import { useIsomorphicLayoutEffect, getParent } from '@fluentui/react-utilities'
|
|
22
23
|
checkUncontrolledTrappingFocus: (element)=>{
|
23
24
|
var _element_firstElementChild;
|
24
25
|
return !!((_element_firstElementChild = element.firstElementChild) === null || _element_firstElementChild === void 0 ? void 0 : _element_firstElementChild.hasAttribute('data-is-focus-trap-zone-bumper'));
|
25
|
-
}
|
26
|
+
},
|
27
|
+
DOMAPI: shadowDOMAPI
|
26
28
|
});
|
27
29
|
}, [
|
28
|
-
defaultView
|
30
|
+
defaultView,
|
31
|
+
shadowDOMAPI
|
29
32
|
]);
|
30
33
|
useIsomorphicLayoutEffect(()=>{
|
31
34
|
return ()=>{
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useTabster.ts"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { createTabster, disposeTabster, Types as TabsterTypes } from 'tabster';\nimport { useIsomorphicLayoutEffect, getParent } from '@fluentui/react-utilities';\n\n/**\n * Tries to get a tabster instance on the current window or creates a new one\n * Since Tabster is single instance only, feel free to call this hook to ensure Tabster exists if necessary\n *\n * @internal\n * @returns Tabster core instance\n */\nexport const useTabster = (): TabsterTypes.TabsterCore | null => {\n const { targetDocument } = useFluent();\n\n const defaultView = targetDocument?.defaultView || undefined;\n const tabster = React.useMemo(() => {\n if (!defaultView) {\n return null;\n }\n\n return createTabster(defaultView, {\n autoRoot: {},\n controlTab: false,\n getParent,\n checkUncontrolledTrappingFocus: element =>\n !!element.firstElementChild?.hasAttribute('data-is-focus-trap-zone-bumper'),\n });\n }, [defaultView]);\n\n useIsomorphicLayoutEffect(() => {\n return () => {\n if (tabster) {\n disposeTabster(tabster);\n }\n };\n }, [tabster]);\n\n return tabster;\n};\n"],"names":["React","useFluent_unstable","useFluent","createTabster","disposeTabster","useIsomorphicLayoutEffect","getParent","useTabster","targetDocument","defaultView","undefined","tabster","useMemo","autoRoot","controlTab","checkUncontrolledTrappingFocus","element","firstElementChild","hasAttribute"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,aAAa,EAAEC,cAAc,QAA+B,UAAU;AAC/E,SAASC,yBAAyB,EAAEC,SAAS,QAAQ,4BAA4B;
|
1
|
+
{"version":3,"sources":["useTabster.ts"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { createTabster, disposeTabster, Types as TabsterTypes } from 'tabster';\nimport { useIsomorphicLayoutEffect, getParent } from '@fluentui/react-utilities';\n\ninterface WindowWithTabsterShadowDOMAPI extends Window {\n __tabsterShadowDOMAPI?: TabsterTypes.DOMAPI;\n}\n\n/**\n * Tries to get a tabster instance on the current window or creates a new one\n * Since Tabster is single instance only, feel free to call this hook to ensure Tabster exists if necessary\n *\n * @internal\n * @returns Tabster core instance\n */\nexport const useTabster = (): TabsterTypes.TabsterCore | null => {\n const { targetDocument } = useFluent();\n\n const defaultView = targetDocument?.defaultView || undefined;\n\n const shadowDOMAPI = (defaultView as WindowWithTabsterShadowDOMAPI | undefined)?.__tabsterShadowDOMAPI;\n\n const tabster = React.useMemo(() => {\n if (!defaultView) {\n return null;\n }\n\n return createTabster(defaultView, {\n autoRoot: {},\n controlTab: false,\n getParent,\n checkUncontrolledTrappingFocus: element =>\n !!element.firstElementChild?.hasAttribute('data-is-focus-trap-zone-bumper'),\n DOMAPI: shadowDOMAPI,\n });\n }, [defaultView, shadowDOMAPI]);\n\n useIsomorphicLayoutEffect(() => {\n return () => {\n if (tabster) {\n disposeTabster(tabster);\n }\n };\n }, [tabster]);\n\n return tabster;\n};\n"],"names":["React","useFluent_unstable","useFluent","createTabster","disposeTabster","useIsomorphicLayoutEffect","getParent","useTabster","targetDocument","defaultView","undefined","shadowDOMAPI","__tabsterShadowDOMAPI","tabster","useMemo","autoRoot","controlTab","checkUncontrolledTrappingFocus","element","firstElementChild","hasAttribute","DOMAPI"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,aAAa,EAAEC,cAAc,QAA+B,UAAU;AAC/E,SAASC,yBAAyB,EAAEC,SAAS,QAAQ,4BAA4B;AAMjF;;;;;;CAMC,GACD,OAAO,MAAMC,aAAa;IACxB,MAAM,EAAEC,cAAc,EAAE,GAAGN;IAE3B,MAAMO,cAAcD,CAAAA,2BAAAA,qCAAAA,eAAgBC,WAAW,KAAIC;IAEnD,MAAMC,eAAgBF,wBAAAA,kCAAD,AAACA,YAA2DG,qBAAqB;IAEtG,MAAMC,UAAUb,MAAMc,OAAO,CAAC;QAC5B,IAAI,CAACL,aAAa;YAChB,OAAO;QACT;QAEA,OAAON,cAAcM,aAAa;YAChCM,UAAU,CAAC;YACXC,YAAY;YACZV;YACAW,gCAAgCC,CAAAA;oBAC5BA;uBAAF,CAAC,GAACA,6BAAAA,QAAQC,iBAAiB,cAAzBD,iDAAAA,2BAA2BE,YAAY,CAAC;;YAC5CC,QAAQV;QACV;IACF,GAAG;QAACF;QAAaE;KAAa;IAE9BN,0BAA0B;QACxB,OAAO;YACL,IAAIQ,SAAS;gBACXT,eAAeS;YACjB;QACF;IACF,GAAG;QAACA;KAAQ;IAEZ,OAAOA;AACT,EAAE"}
|
package/lib/index.js
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
export { useArrowNavigationGroup, useFocusableGroup, useFocusFinders, useFocusVisible, useFocusWithin, useKeyboardNavAttribute, useModalAttributes, useTabsterAttributes, useObservedElement, useFocusObserved, useMergedTabsterAttributes_unstable, useRestoreFocusSource, useRestoreFocusTarget, useUncontrolledFocus, useOnKeyboardNavigationChange } from './hooks/index';
|
1
|
+
export { useArrowNavigationGroup, useFocusableGroup, useFocusFinders, useFocusVisible, useFocusWithin, useKeyboardNavAttribute, useModalAttributes, useTabsterAttributes, useObservedElement, useFocusObserved, useMergedTabsterAttributes_unstable, useRestoreFocusSource, useRestoreFocusTarget, useUncontrolledFocus, useOnKeyboardNavigationChange, useSetKeyboardNavigation } from './hooks/index';
|
2
2
|
export { createCustomFocusIndicatorStyle, createFocusOutlineStyle } from './focus/index';
|
3
3
|
export { applyFocusVisiblePolyfill } from './focus/index';
|
4
|
+
import { Types as TabsterTypes, dispatchGroupperMoveFocusEvent, dispatchMoverMoveFocusEvent } from 'tabster';
|
4
5
|
export { KEYBORG_FOCUSIN } from 'keyborg';
|
6
|
+
// @internal (undocumented)
|
7
|
+
export { TabsterTypes, dispatchGroupperMoveFocusEvent, dispatchMoverMoveFocusEvent };
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export {\n useArrowNavigationGroup,\n useFocusableGroup,\n useFocusFinders,\n useFocusVisible,\n useFocusWithin,\n useKeyboardNavAttribute,\n useModalAttributes,\n useTabsterAttributes,\n useObservedElement,\n useFocusObserved,\n useMergedTabsterAttributes_unstable,\n useRestoreFocusSource,\n useRestoreFocusTarget,\n useUncontrolledFocus,\n useOnKeyboardNavigationChange,\n} from './hooks/index';\nexport type {\n UseArrowNavigationGroupOptions,\n UseFocusableGroupOptions,\n UseModalAttributesOptions,\n} from './hooks/index';\n\nexport { createCustomFocusIndicatorStyle, createFocusOutlineStyle } from './focus/index';\n\nexport type {\n CreateCustomFocusIndicatorStyleOptions,\n CreateFocusOutlineStyleOptions,\n FocusOutlineOffset,\n FocusOutlineStyleOptions,\n} from './focus/index';\n\nexport { applyFocusVisiblePolyfill } from './focus/index';\nimport { Types as TabsterTypes } from 'tabster';\n\nexport type TabsterDOMAttribute = TabsterTypes.TabsterDOMAttribute;\n\nexport type { KeyborgFocusInEvent } from 'keyborg';\nexport { KEYBORG_FOCUSIN } from 'keyborg';\n"],"names":["useArrowNavigationGroup","useFocusableGroup","useFocusFinders","useFocusVisible","useFocusWithin","useKeyboardNavAttribute","useModalAttributes","useTabsterAttributes","useObservedElement","useFocusObserved","useMergedTabsterAttributes_unstable","useRestoreFocusSource","useRestoreFocusTarget","useUncontrolledFocus","useOnKeyboardNavigationChange","createCustomFocusIndicatorStyle","createFocusOutlineStyle","applyFocusVisiblePolyfill","KEYBORG_FOCUSIN"],"mappings":"AAAA,SACEA,uBAAuB,EACvBC,iBAAiB,EACjBC,eAAe,EACfC,eAAe,EACfC,cAAc,EACdC,uBAAuB,EACvBC,kBAAkB,EAClBC,oBAAoB,EACpBC,kBAAkB,EAClBC,gBAAgB,EAChBC,mCAAmC,EACnCC,qBAAqB,EACrBC,qBAAqB,EACrBC,oBAAoB,EACpBC,6BAA6B,
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export {\n useArrowNavigationGroup,\n useFocusableGroup,\n useFocusFinders,\n useFocusVisible,\n useFocusWithin,\n useKeyboardNavAttribute,\n useModalAttributes,\n useTabsterAttributes,\n useObservedElement,\n useFocusObserved,\n useMergedTabsterAttributes_unstable,\n useRestoreFocusSource,\n useRestoreFocusTarget,\n useUncontrolledFocus,\n useOnKeyboardNavigationChange,\n useSetKeyboardNavigation,\n} from './hooks/index';\nexport type {\n UseArrowNavigationGroupOptions,\n UseFocusableGroupOptions,\n UseModalAttributesOptions,\n} from './hooks/index';\n\nexport { createCustomFocusIndicatorStyle, createFocusOutlineStyle } from './focus/index';\n\nexport type {\n CreateCustomFocusIndicatorStyleOptions,\n CreateFocusOutlineStyleOptions,\n FocusOutlineOffset,\n FocusOutlineStyleOptions,\n} from './focus/index';\n\nexport { applyFocusVisiblePolyfill } from './focus/index';\nimport { Types as TabsterTypes, dispatchGroupperMoveFocusEvent, dispatchMoverMoveFocusEvent } from 'tabster';\n\nexport type TabsterDOMAttribute = TabsterTypes.TabsterDOMAttribute;\n\nexport type { KeyborgFocusInEvent } from 'keyborg';\nexport { KEYBORG_FOCUSIN } from 'keyborg';\n\n// @internal (undocumented)\nexport { TabsterTypes, dispatchGroupperMoveFocusEvent, dispatchMoverMoveFocusEvent };\n"],"names":["useArrowNavigationGroup","useFocusableGroup","useFocusFinders","useFocusVisible","useFocusWithin","useKeyboardNavAttribute","useModalAttributes","useTabsterAttributes","useObservedElement","useFocusObserved","useMergedTabsterAttributes_unstable","useRestoreFocusSource","useRestoreFocusTarget","useUncontrolledFocus","useOnKeyboardNavigationChange","useSetKeyboardNavigation","createCustomFocusIndicatorStyle","createFocusOutlineStyle","applyFocusVisiblePolyfill","Types","TabsterTypes","dispatchGroupperMoveFocusEvent","dispatchMoverMoveFocusEvent","KEYBORG_FOCUSIN"],"mappings":"AAAA,SACEA,uBAAuB,EACvBC,iBAAiB,EACjBC,eAAe,EACfC,eAAe,EACfC,cAAc,EACdC,uBAAuB,EACvBC,kBAAkB,EAClBC,oBAAoB,EACpBC,kBAAkB,EAClBC,gBAAgB,EAChBC,mCAAmC,EACnCC,qBAAqB,EACrBC,qBAAqB,EACrBC,oBAAoB,EACpBC,6BAA6B,EAC7BC,wBAAwB,QACnB,gBAAgB;AAOvB,SAASC,+BAA+B,EAAEC,uBAAuB,QAAQ,gBAAgB;AASzF,SAASC,yBAAyB,QAAQ,gBAAgB;AAC1D,SAASC,SAASC,YAAY,EAAEC,8BAA8B,EAAEC,2BAA2B,QAAQ,UAAU;AAK7G,SAASC,eAAe,QAAQ,UAAU;AAE1C,2BAA2B;AAC3B,SAASH,YAAY,EAAEC,8BAA8B,EAAEC,2BAA2B,GAAG"}
|
@@ -17,3 +17,4 @@ _export_star._(require("./useMergeTabsterAttributes"), exports);
|
|
17
17
|
_export_star._(require("./useFocusObserved"), exports);
|
18
18
|
_export_star._(require("./useRestoreFocus"), exports);
|
19
19
|
_export_star._(require("./useUncontrolledFocus"), exports);
|
20
|
+
_export_star._(require("./useSetKeyboardNavigation"), exports);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.js"],"sourcesContent":["export * from './useArrowNavigationGroup';\nexport * from './useFocusableGroup';\nexport * from './useFocusFinders';\nexport * from './useFocusVisible';\nexport * from './useFocusWithin';\nexport * from './useKeyboardNavAttribute';\nexport * from './useOnKeyboardNavigationChange';\nexport * from './useModalAttributes';\nexport * from './useTabsterAttributes';\nexport * from './useObservedElement';\nexport * from './useMergeTabsterAttributes';\nexport * from './useFocusObserved';\nexport * from './useRestoreFocus';\nexport * from './useUncontrolledFocus';\n"],"names":[],"mappings":";;;;;uBAAc;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA"}
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["export * from './useArrowNavigationGroup';\nexport * from './useFocusableGroup';\nexport * from './useFocusFinders';\nexport * from './useFocusVisible';\nexport * from './useFocusWithin';\nexport * from './useKeyboardNavAttribute';\nexport * from './useOnKeyboardNavigationChange';\nexport * from './useModalAttributes';\nexport * from './useTabsterAttributes';\nexport * from './useObservedElement';\nexport * from './useMergeTabsterAttributes';\nexport * from './useFocusObserved';\nexport * from './useRestoreFocus';\nexport * from './useUncontrolledFocus';\nexport * from './useSetKeyboardNavigation';\n"],"names":[],"mappings":";;;;;uBAAc;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA;uBACA"}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "useKeyborg", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return useKeyborg;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
13
|
+
const _keyborg = require("keyborg");
|
14
|
+
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
15
|
+
function useKeyborg() {
|
16
|
+
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
17
|
+
const keyborg = _react.useMemo(()=>targetDocument && (0, _keyborg.createKeyborg)(targetDocument.defaultView), [
|
18
|
+
targetDocument
|
19
|
+
]);
|
20
|
+
_react.useEffect(()=>{
|
21
|
+
return ()=>keyborg && (0, _keyborg.disposeKeyborg)(keyborg);
|
22
|
+
}, [
|
23
|
+
keyborg
|
24
|
+
]);
|
25
|
+
return keyborg;
|
26
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useKeyborg.js"],"sourcesContent":["import * as React from 'react';\nimport { createKeyborg, disposeKeyborg } from 'keyborg';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n/**\n * @internal\n * Instantiates [keyborg](https://github.com/microsoft/keyborg)\n * @returns - keyborg instance\n */ export function useKeyborg() {\n const { targetDocument } = useFluent();\n const keyborg = React.useMemo(()=>targetDocument && createKeyborg(targetDocument.defaultView), [\n targetDocument\n ]);\n React.useEffect(()=>{\n return ()=>keyborg && disposeKeyborg(keyborg);\n }, [\n keyborg\n ]);\n return keyborg;\n}\n"],"names":["useKeyborg","targetDocument","useFluent","keyborg","React","useMemo","createKeyborg","defaultView","useEffect","disposeKeyborg"],"mappings":";;;;+BAOoBA;;;eAAAA;;;;iEAPG;yBACuB;qCACE;AAKrC,SAASA;IAChB,MAAM,EAAEC,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,MAAMC,UAAUC,OAAMC,OAAO,CAAC,IAAIJ,kBAAkBK,IAAAA,sBAAa,EAACL,eAAeM,WAAW,GAAG;QAC3FN;KACH;IACDG,OAAMI,SAAS,CAAC;QACZ,OAAO,IAAIL,WAAWM,IAAAA,uBAAc,EAACN;IACzC,GAAG;QACCA;KACH;IACD,OAAOA;AACX"}
|
@@ -10,14 +10,10 @@ Object.defineProperty(exports, "useOnKeyboardNavigationChange", {
|
|
10
10
|
});
|
11
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
12
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
13
|
-
const _keyborg = require("keyborg");
|
14
|
-
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
15
13
|
const _reactutilities = require("@fluentui/react-utilities");
|
14
|
+
const _useKeyborg = require("./useKeyborg");
|
16
15
|
function useOnKeyboardNavigationChange(callback) {
|
17
|
-
const
|
18
|
-
const keyborg = _react.useMemo(()=>targetDocument && (0, _keyborg.createKeyborg)(targetDocument.defaultView), [
|
19
|
-
targetDocument
|
20
|
-
]);
|
16
|
+
const keyborg = (0, _useKeyborg.useKeyborg)();
|
21
17
|
const eventCallback = (0, _reactutilities.useEventCallback)(callback);
|
22
18
|
_react.useEffect(()=>{
|
23
19
|
if (keyborg) {
|
@@ -31,9 +27,4 @@ function useOnKeyboardNavigationChange(callback) {
|
|
31
27
|
keyborg,
|
32
28
|
eventCallback
|
33
29
|
]);
|
34
|
-
_react.useEffect(()=>{
|
35
|
-
return ()=>keyborg && (0, _keyborg.disposeKeyborg)(keyborg);
|
36
|
-
}, [
|
37
|
-
keyborg
|
38
|
-
]);
|
39
30
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useOnKeyboardNavigationChange.js"],"sourcesContent":["import * as React from 'react';\nimport {
|
1
|
+
{"version":3,"sources":["useOnKeyboardNavigationChange.js"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport { useKeyborg } from './useKeyborg';\n/**\n * Instantiates [keyborg](https://github.com/microsoft/keyborg) and subscribes to changes\n * in the keyboard navigation mode.\n *\n * @param callback - called every time the keyboard navigation state changes\n */ export function useOnKeyboardNavigationChange(callback) {\n const keyborg = useKeyborg();\n const eventCallback = useEventCallback(callback);\n React.useEffect(()=>{\n if (keyborg) {\n const cb = (next)=>{\n eventCallback(next);\n };\n keyborg.subscribe(cb);\n return ()=>keyborg.unsubscribe(cb);\n }\n }, [\n keyborg,\n eventCallback\n ]);\n}\n"],"names":["useOnKeyboardNavigationChange","callback","keyborg","useKeyborg","eventCallback","useEventCallback","React","useEffect","cb","next","subscribe","unsubscribe"],"mappings":";;;;+BAQoBA;;;eAAAA;;;;iEARG;gCACU;4BACN;AAMhB,SAASA,8BAA8BC,QAAQ;IACtD,MAAMC,UAAUC,IAAAA,sBAAU;IAC1B,MAAMC,gBAAgBC,IAAAA,gCAAgB,EAACJ;IACvCK,OAAMC,SAAS,CAAC;QACZ,IAAIL,SAAS;YACT,MAAMM,KAAK,CAACC;gBACRL,cAAcK;YAClB;YACAP,QAAQQ,SAAS,CAACF;YAClB,OAAO,IAAIN,QAAQS,WAAW,CAACH;QACnC;IACJ,GAAG;QACCN;QACAE;KACH;AACL"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "useSetKeyboardNavigation", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return useSetKeyboardNavigation;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
13
|
+
const _useKeyborg = require("./useKeyborg");
|
14
|
+
function useSetKeyboardNavigation() {
|
15
|
+
const keyborg = (0, _useKeyborg.useKeyborg)();
|
16
|
+
return _react.useCallback((isNavigatingWithKeyboard)=>{
|
17
|
+
keyborg === null || keyborg === void 0 ? void 0 : keyborg.setVal(isNavigatingWithKeyboard);
|
18
|
+
}, [
|
19
|
+
keyborg
|
20
|
+
]);
|
21
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useSetKeyboardNavigation.js"],"sourcesContent":["import * as React from 'react';\nimport { useKeyborg } from './useKeyborg';\n/**\n */ export function useSetKeyboardNavigation() {\n const keyborg = useKeyborg();\n return React.useCallback((isNavigatingWithKeyboard)=>{\n keyborg === null || keyborg === void 0 ? void 0 : keyborg.setVal(isNavigatingWithKeyboard);\n }, [\n keyborg\n ]);\n}\n"],"names":["useSetKeyboardNavigation","keyborg","useKeyborg","React","useCallback","isNavigatingWithKeyboard","setVal"],"mappings":";;;;+BAGoBA;;;eAAAA;;;;iEAHG;4BACI;AAEhB,SAASA;IAChB,MAAMC,UAAUC,IAAAA,sBAAU;IAC1B,OAAOC,OAAMC,WAAW,CAAC,CAACC;QACtBJ,YAAY,QAAQA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQK,MAAM,CAACD;IACrE,GAAG;QACCJ;KACH;AACL"}
|
@@ -16,6 +16,7 @@ const _reactutilities = require("@fluentui/react-utilities");
|
|
16
16
|
const useTabster = ()=>{
|
17
17
|
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
18
18
|
const defaultView = (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) || undefined;
|
19
|
+
const shadowDOMAPI = defaultView === null || defaultView === void 0 ? void 0 : defaultView.__tabsterShadowDOMAPI;
|
19
20
|
const tabster = _react.useMemo(()=>{
|
20
21
|
if (!defaultView) {
|
21
22
|
return null;
|
@@ -27,10 +28,12 @@ const useTabster = ()=>{
|
|
27
28
|
checkUncontrolledTrappingFocus: (element)=>{
|
28
29
|
var _element_firstElementChild;
|
29
30
|
return !!((_element_firstElementChild = element.firstElementChild) === null || _element_firstElementChild === void 0 ? void 0 : _element_firstElementChild.hasAttribute('data-is-focus-trap-zone-bumper'));
|
30
|
-
}
|
31
|
+
},
|
32
|
+
DOMAPI: shadowDOMAPI
|
31
33
|
});
|
32
34
|
}, [
|
33
|
-
defaultView
|
35
|
+
defaultView,
|
36
|
+
shadowDOMAPI
|
34
37
|
]);
|
35
38
|
(0, _reactutilities.useIsomorphicLayoutEffect)(()=>{
|
36
39
|
return ()=>{
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useTabster.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { createTabster, disposeTabster } from 'tabster';\nimport { useIsomorphicLayoutEffect, getParent } from '@fluentui/react-utilities';\n/**\n * Tries to get a tabster instance on the current window or creates a new one\n * Since Tabster is single instance only, feel free to call this hook to ensure Tabster exists if necessary\n *\n * @internal\n * @returns Tabster core instance\n */ export const useTabster = ()=>{\n const { targetDocument } = useFluent();\n const defaultView = (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) || undefined;\n const tabster = React.useMemo(()=>{\n if (!defaultView) {\n return null;\n }\n return createTabster(defaultView, {\n autoRoot: {},\n controlTab: false,\n getParent,\n checkUncontrolledTrappingFocus: (element)=>{\n var _element_firstElementChild;\n return !!((_element_firstElementChild = element.firstElementChild) === null || _element_firstElementChild === void 0 ? void 0 : _element_firstElementChild.hasAttribute('data-is-focus-trap-zone-bumper'));\n }\n });\n }, [\n defaultView\n ]);\n useIsomorphicLayoutEffect(()=>{\n return ()=>{\n if (tabster) {\n disposeTabster(tabster);\n }\n };\n }, [\n tabster\n ]);\n return tabster;\n};\n"],"names":["useTabster","targetDocument","useFluent","defaultView","undefined","tabster","React","useMemo","createTabster","autoRoot","controlTab","getParent","checkUncontrolledTrappingFocus","element","_element_firstElementChild","firstElementChild","hasAttribute","useIsomorphicLayoutEffect","disposeTabster"],"mappings":";;;;+BAUiBA;;;eAAAA;;;;iEAVM;qCACyB;yBACF;gCACO;AAO1C,MAAMA,aAAa;IAC1B,MAAM,EAAEC,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,MAAMC,cAAc,AAACF,CAAAA,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeE,WAAW,AAAD,KAAMC;IACpH,MAAMC,UAAUC,OAAMC,OAAO,CAAC;QAC1B,IAAI,
|
1
|
+
{"version":3,"sources":["useTabster.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { createTabster, disposeTabster } from 'tabster';\nimport { useIsomorphicLayoutEffect, getParent } from '@fluentui/react-utilities';\n/**\n * Tries to get a tabster instance on the current window or creates a new one\n * Since Tabster is single instance only, feel free to call this hook to ensure Tabster exists if necessary\n *\n * @internal\n * @returns Tabster core instance\n */ export const useTabster = ()=>{\n const { targetDocument } = useFluent();\n const defaultView = (targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) || undefined;\n const shadowDOMAPI = defaultView === null || defaultView === void 0 ? void 0 : defaultView.__tabsterShadowDOMAPI;\n const tabster = React.useMemo(()=>{\n if (!defaultView) {\n return null;\n }\n return createTabster(defaultView, {\n autoRoot: {},\n controlTab: false,\n getParent,\n checkUncontrolledTrappingFocus: (element)=>{\n var _element_firstElementChild;\n return !!((_element_firstElementChild = element.firstElementChild) === null || _element_firstElementChild === void 0 ? void 0 : _element_firstElementChild.hasAttribute('data-is-focus-trap-zone-bumper'));\n },\n DOMAPI: shadowDOMAPI\n });\n }, [\n defaultView,\n shadowDOMAPI\n ]);\n useIsomorphicLayoutEffect(()=>{\n return ()=>{\n if (tabster) {\n disposeTabster(tabster);\n }\n };\n }, [\n tabster\n ]);\n return tabster;\n};\n"],"names":["useTabster","targetDocument","useFluent","defaultView","undefined","shadowDOMAPI","__tabsterShadowDOMAPI","tabster","React","useMemo","createTabster","autoRoot","controlTab","getParent","checkUncontrolledTrappingFocus","element","_element_firstElementChild","firstElementChild","hasAttribute","DOMAPI","useIsomorphicLayoutEffect","disposeTabster"],"mappings":";;;;+BAUiBA;;;eAAAA;;;;iEAVM;qCACyB;yBACF;gCACO;AAO1C,MAAMA,aAAa;IAC1B,MAAM,EAAEC,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,MAAMC,cAAc,AAACF,CAAAA,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeE,WAAW,AAAD,KAAMC;IACpH,MAAMC,eAAeF,gBAAgB,QAAQA,gBAAgB,KAAK,IAAI,KAAK,IAAIA,YAAYG,qBAAqB;IAChH,MAAMC,UAAUC,OAAMC,OAAO,CAAC;QAC1B,IAAI,CAACN,aAAa;YACd,OAAO;QACX;QACA,OAAOO,IAAAA,sBAAa,EAACP,aAAa;YAC9BQ,UAAU,CAAC;YACXC,YAAY;YACZC,WAAAA,yBAAS;YACTC,gCAAgC,CAACC;gBAC7B,IAAIC;gBACJ,OAAO,CAAC,CAAE,CAAA,AAACA,CAAAA,6BAA6BD,QAAQE,iBAAiB,AAAD,MAAO,QAAQD,+BAA+B,KAAK,IAAI,KAAK,IAAIA,2BAA2BE,YAAY,CAAC,iCAAgC;YAC5M;YACAC,QAAQd;QACZ;IACJ,GAAG;QACCF;QACAE;KACH;IACDe,IAAAA,yCAAyB,EAAC;QACtB,OAAO;YACH,IAAIb,SAAS;gBACTc,IAAAA,uBAAc,EAACd;YACnB;QACJ;IACJ,GAAG;QACCA;KACH;IACD,OAAOA;AACX"}
|
package/lib-commonjs/index.js
CHANGED
@@ -54,6 +54,9 @@ _export(exports, {
|
|
54
54
|
useOnKeyboardNavigationChange: function() {
|
55
55
|
return _index.useOnKeyboardNavigationChange;
|
56
56
|
},
|
57
|
+
useSetKeyboardNavigation: function() {
|
58
|
+
return _index.useSetKeyboardNavigation;
|
59
|
+
},
|
57
60
|
createCustomFocusIndicatorStyle: function() {
|
58
61
|
return _index1.createCustomFocusIndicatorStyle;
|
59
62
|
},
|
@@ -65,8 +68,18 @@ _export(exports, {
|
|
65
68
|
},
|
66
69
|
KEYBORG_FOCUSIN: function() {
|
67
70
|
return _keyborg.KEYBORG_FOCUSIN;
|
71
|
+
},
|
72
|
+
TabsterTypes: function() {
|
73
|
+
return _tabster.Types;
|
74
|
+
},
|
75
|
+
dispatchGroupperMoveFocusEvent: function() {
|
76
|
+
return _tabster.dispatchGroupperMoveFocusEvent;
|
77
|
+
},
|
78
|
+
dispatchMoverMoveFocusEvent: function() {
|
79
|
+
return _tabster.dispatchMoverMoveFocusEvent;
|
68
80
|
}
|
69
81
|
});
|
70
82
|
const _index = require("./hooks/index");
|
71
83
|
const _index1 = require("./focus/index");
|
84
|
+
const _tabster = require("tabster");
|
72
85
|
const _keyborg = require("keyborg");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.js"],"sourcesContent":["export { useArrowNavigationGroup, useFocusableGroup, useFocusFinders, useFocusVisible, useFocusWithin, useKeyboardNavAttribute, useModalAttributes, useTabsterAttributes, useObservedElement, useFocusObserved, useMergedTabsterAttributes_unstable, useRestoreFocusSource, useRestoreFocusTarget, useUncontrolledFocus, useOnKeyboardNavigationChange } from './hooks/index';\nexport { createCustomFocusIndicatorStyle, createFocusOutlineStyle } from './focus/index';\nexport { applyFocusVisiblePolyfill } from './focus/index';\nexport { KEYBORG_FOCUSIN } from 'keyborg';\n"],"names":["useArrowNavigationGroup","useFocusableGroup","useFocusFinders","useFocusVisible","useFocusWithin","useKeyboardNavAttribute","useModalAttributes","useTabsterAttributes","useObservedElement","useFocusObserved","useMergedTabsterAttributes_unstable","useRestoreFocusSource","useRestoreFocusTarget","useUncontrolledFocus","useOnKeyboardNavigationChange","createCustomFocusIndicatorStyle","createFocusOutlineStyle","applyFocusVisiblePolyfill","KEYBORG_FOCUSIN"],"mappings":";;;;;;;;;;;IAASA,uBAAuB;eAAvBA,8BAAuB;;IAAEC,iBAAiB;eAAjBA,wBAAiB;;IAAEC,eAAe;eAAfA,sBAAe;;IAAEC,eAAe;eAAfA,sBAAe;;IAAEC,cAAc;eAAdA,qBAAc;;IAAEC,uBAAuB;eAAvBA,8BAAuB;;IAAEC,kBAAkB;eAAlBA,yBAAkB;;IAAEC,oBAAoB;eAApBA,2BAAoB;;IAAEC,kBAAkB;eAAlBA,yBAAkB;;IAAEC,gBAAgB;eAAhBA,uBAAgB;;IAAEC,mCAAmC;eAAnCA,0CAAmC;;IAAEC,qBAAqB;eAArBA,4BAAqB;;IAAEC,qBAAqB;eAArBA,4BAAqB;;IAAEC,oBAAoB;eAApBA,2BAAoB;;IAAEC,6BAA6B;eAA7BA,oCAA6B;;
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["export { useArrowNavigationGroup, useFocusableGroup, useFocusFinders, useFocusVisible, useFocusWithin, useKeyboardNavAttribute, useModalAttributes, useTabsterAttributes, useObservedElement, useFocusObserved, useMergedTabsterAttributes_unstable, useRestoreFocusSource, useRestoreFocusTarget, useUncontrolledFocus, useOnKeyboardNavigationChange, useSetKeyboardNavigation } from './hooks/index';\nexport { createCustomFocusIndicatorStyle, createFocusOutlineStyle } from './focus/index';\nexport { applyFocusVisiblePolyfill } from './focus/index';\nimport { Types as TabsterTypes, dispatchGroupperMoveFocusEvent, dispatchMoverMoveFocusEvent } from 'tabster';\nexport { KEYBORG_FOCUSIN } from 'keyborg';\n// @internal (undocumented)\nexport { TabsterTypes, dispatchGroupperMoveFocusEvent, dispatchMoverMoveFocusEvent };\n"],"names":["useArrowNavigationGroup","useFocusableGroup","useFocusFinders","useFocusVisible","useFocusWithin","useKeyboardNavAttribute","useModalAttributes","useTabsterAttributes","useObservedElement","useFocusObserved","useMergedTabsterAttributes_unstable","useRestoreFocusSource","useRestoreFocusTarget","useUncontrolledFocus","useOnKeyboardNavigationChange","useSetKeyboardNavigation","createCustomFocusIndicatorStyle","createFocusOutlineStyle","applyFocusVisiblePolyfill","KEYBORG_FOCUSIN","TabsterTypes","dispatchGroupperMoveFocusEvent","dispatchMoverMoveFocusEvent"],"mappings":";;;;;;;;;;;IAASA,uBAAuB;eAAvBA,8BAAuB;;IAAEC,iBAAiB;eAAjBA,wBAAiB;;IAAEC,eAAe;eAAfA,sBAAe;;IAAEC,eAAe;eAAfA,sBAAe;;IAAEC,cAAc;eAAdA,qBAAc;;IAAEC,uBAAuB;eAAvBA,8BAAuB;;IAAEC,kBAAkB;eAAlBA,yBAAkB;;IAAEC,oBAAoB;eAApBA,2BAAoB;;IAAEC,kBAAkB;eAAlBA,yBAAkB;;IAAEC,gBAAgB;eAAhBA,uBAAgB;;IAAEC,mCAAmC;eAAnCA,0CAAmC;;IAAEC,qBAAqB;eAArBA,4BAAqB;;IAAEC,qBAAqB;eAArBA,4BAAqB;;IAAEC,oBAAoB;eAApBA,2BAAoB;;IAAEC,6BAA6B;eAA7BA,oCAA6B;;IAAEC,wBAAwB;eAAxBA,+BAAwB;;IACvWC,+BAA+B;eAA/BA,uCAA+B;;IAAEC,uBAAuB;eAAvBA,+BAAuB;;IACxDC,yBAAyB;eAAzBA,iCAAyB;;IAEzBC,eAAe;eAAfA,wBAAe;;IAEfC,YAAY;eAAZA,cAAY;;IAAEC,8BAA8B;eAA9BA,uCAA8B;;IAAEC,2BAA2B;eAA3BA,oCAA2B;;;uBANsS;wBAC/S;yBAE0B;yBACnE"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-tabster",
|
3
|
-
"version": "9.
|
3
|
+
"version": "9.19.0",
|
4
4
|
"description": "Utilities for focus management and facade for tabster",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -33,11 +33,11 @@
|
|
33
33
|
"dependencies": {
|
34
34
|
"@fluentui/react-shared-contexts": "^9.14.0",
|
35
35
|
"@fluentui/react-theme": "^9.1.16",
|
36
|
-
"@fluentui/react-utilities": "^9.
|
36
|
+
"@fluentui/react-utilities": "^9.18.0",
|
37
37
|
"@griffel/react": "^1.5.14",
|
38
38
|
"@swc/helpers": "^0.5.1",
|
39
|
-
"keyborg": "^2.
|
40
|
-
"tabster": "^
|
39
|
+
"keyborg": "^2.5.0",
|
40
|
+
"tabster": "^6.0.0"
|
41
41
|
},
|
42
42
|
"peerDependencies": {
|
43
43
|
"@types/react": ">=16.14.0 <19.0.0",
|