@fluentui/react-tabster 9.9.2 → 9.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.json CHANGED
@@ -2,7 +2,37 @@
2
2
  "name": "@fluentui/react-tabster",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 03 Jul 2023 11:54:00 GMT",
5
+ "date": "Tue, 25 Jul 2023 13:26:25 GMT",
6
+ "tag": "@fluentui/react-tabster_v9.11.0",
7
+ "version": "9.11.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "lingfan.gao@microsoft.com",
12
+ "package": "@fluentui/react-tabster",
13
+ "commit": "c0c62f9383781f0dbebd800eaa2c64ef761075a2",
14
+ "comment": "feat: Implement useRestoreFocusSource and useRestoreFocusTarget based on the tabster restorer API"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Mon, 03 Jul 2023 13:34:27 GMT",
21
+ "tag": "@fluentui/react-tabster_v9.10.0",
22
+ "version": "9.10.0",
23
+ "comments": {
24
+ "minor": [
25
+ {
26
+ "author": "lingfan.gao@microsoft.com",
27
+ "package": "@fluentui/react-tabster",
28
+ "commit": "d2c95969c67521ea1df57e1339f8743b09b68772",
29
+ "comment": "feat: Implmenent useMergeTabsterAttributes_unstable"
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ {
35
+ "date": "Mon, 03 Jul 2023 11:57:13 GMT",
6
36
  "tag": "@fluentui/react-tabster_v9.9.2",
7
37
  "version": "9.9.2",
8
38
  "comments": {
@@ -19,13 +49,13 @@
19
49
  "author": "beachball",
20
50
  "package": "@fluentui/react-tabster",
21
51
  "comment": "Bump @fluentui/react-shared-contexts to v9.6.0",
22
- "commit": "e7a838bfd1ce4b077d265295fcbef8dc2177e724"
52
+ "commit": "61633ba5de03e0ddf4839dba6da325e30c7ce9bd"
23
53
  },
24
54
  {
25
55
  "author": "beachball",
26
56
  "package": "@fluentui/react-tabster",
27
57
  "comment": "Bump @fluentui/react-utilities to v9.10.1",
28
- "commit": "e7a838bfd1ce4b077d265295fcbef8dc2177e724"
58
+ "commit": "61633ba5de03e0ddf4839dba6da325e30c7ce9bd"
29
59
  }
30
60
  ]
31
61
  }
package/CHANGELOG.md CHANGED
@@ -1,18 +1,36 @@
1
1
  # Change Log - @fluentui/react-tabster
2
2
 
3
- This log was last generated on Mon, 03 Jul 2023 11:54:00 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 25 Jul 2023 13:26:25 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.11.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-tabster_v9.11.0)
8
+
9
+ Tue, 25 Jul 2023 13:26:25 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tabster_v9.10.0..@fluentui/react-tabster_v9.11.0)
11
+
12
+ ### Minor changes
13
+
14
+ - feat: Implement useRestoreFocusSource and useRestoreFocusTarget based on the tabster restorer API ([PR #28530](https://github.com/microsoft/fluentui/pull/28530) by lingfan.gao@microsoft.com)
15
+
16
+ ## [9.10.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-tabster_v9.10.0)
17
+
18
+ Mon, 03 Jul 2023 13:34:27 GMT
19
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tabster_v9.9.2..@fluentui/react-tabster_v9.10.0)
20
+
21
+ ### Minor changes
22
+
23
+ - feat: Implmenent useMergeTabsterAttributes_unstable ([PR #28394](https://github.com/microsoft/fluentui/pull/28394) by lingfan.gao@microsoft.com)
24
+
7
25
  ## [9.9.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-tabster_v9.9.2)
8
26
 
9
- Mon, 03 Jul 2023 11:54:00 GMT
27
+ Mon, 03 Jul 2023 11:57:13 GMT
10
28
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tabster_v9.9.1..@fluentui/react-tabster_v9.9.2)
11
29
 
12
30
  ### Patches
13
31
 
14
- - Bump @fluentui/react-shared-contexts to v9.6.0 ([PR #28399](https://github.com/microsoft/fluentui/pull/28399) by beachball)
15
- - Bump @fluentui/react-utilities to v9.10.1 ([PR #28399](https://github.com/microsoft/fluentui/pull/28399) by beachball)
32
+ - Bump @fluentui/react-shared-contexts to v9.6.0 ([PR #28412](https://github.com/microsoft/fluentui/pull/28412) by beachball)
33
+ - Bump @fluentui/react-utilities to v9.10.1 ([PR #28412](https://github.com/microsoft/fluentui/pull/28412) by beachball)
16
34
 
17
35
  ## [9.9.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-tabster_v9.9.1)
18
36
 
package/dist/index.d.ts CHANGED
@@ -67,6 +67,8 @@ export declare type FocusOutlineStyleOptions = {
67
67
 
68
68
  declare type GriffelResetStyle = Parameters<typeof makeResetStyles>[0];
69
69
 
70
+ export declare type TabsterDOMAttribute = Types.TabsterDOMAttribute;
71
+
70
72
  /**
71
73
  * A hook that returns the necessary tabster attributes to support arrow key navigation
72
74
  * @param options - Options to configure keyboard navigation
@@ -162,6 +164,16 @@ export declare function useFocusWithin<TElement extends HTMLElement = HTMLElemen
162
164
  */
163
165
  export declare function useKeyboardNavAttribute<E extends HTMLElement>(): RefObject<E>;
164
166
 
167
+ /**
168
+ * Merges a collection of tabster attributes.
169
+ *
170
+ * ⚠️The attributes passed as arguments to this hook cannot change at runtime.
171
+ * @internal
172
+ * @param attributes - collection of tabster attributes from other react-tabster hooks
173
+ * @returns single merged tabster attribute
174
+ */
175
+ export declare const useMergedTabsterAttributes_unstable: (...attributes: Types.TabsterDOMAttribute[]) => Types.TabsterDOMAttribute;
176
+
165
177
  /**
166
178
  * Applies modal dialog behaviour through DOM attributes
167
179
  * Modal element will focus trap and hide other content on the page
@@ -201,6 +213,18 @@ export declare interface UseModalAttributesOptions {
201
213
 
202
214
  export declare function useObservedElement(name: string | string[]): Types.TabsterDOMAttribute;
203
215
 
216
+ /**
217
+ * Focus will be restored to the most recent target element when it is lost from a source
218
+ * @returns Attribute to apply to the element that might lose focus
219
+ */
220
+ export declare function useRestoreFocusSource(): Types.TabsterDOMAttribute;
221
+
222
+ /**
223
+ * Focus will be restored to the most recent target element when it is lost from a source
224
+ * @returns Attribute to apply to the target element where focus is restored
225
+ */
226
+ export declare function useRestoreFocusTarget(): Types.TabsterDOMAttribute;
227
+
204
228
  /**
205
229
  * @internal
206
230
  * Hook that returns tabster attributes while ensuring tabster exists
@@ -7,4 +7,6 @@ export * from './useKeyboardNavAttribute';
7
7
  export * from './useModalAttributes';
8
8
  export * from './useTabsterAttributes';
9
9
  export * from './useObservedElement';
10
+ export * from './useMergeTabsterAttributes';
10
11
  export * from './useFocusObserved';
12
+ export * from './useRestoreFocus';
@@ -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 './useModalAttributes';\nexport * from './useTabsterAttributes';\nexport * from './useObservedElement';\nexport * from './useFocusObserved';\n"],"names":[],"mappings":"AAAA,cAAc,4BAA4B;AAC1C,cAAc,sBAAsB;AACpC,cAAc,oBAAoB;AAClC,cAAc,oBAAoB;AAClC,cAAc,mBAAmB;AACjC,cAAc,4BAA4B;AAC1C,cAAc,uBAAuB;AACrC,cAAc,yBAAyB;AACvC,cAAc,uBAAuB;AACrC,cAAc,qBAAqB"}
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 './useModalAttributes';\nexport * from './useTabsterAttributes';\nexport * from './useObservedElement';\nexport * from './useMergeTabsterAttributes';\nexport * from './useFocusObserved';\nexport * from './useRestoreFocus';\n"],"names":[],"mappings":"AAAA,cAAc,4BAA4B;AAC1C,cAAc,sBAAsB;AACpC,cAAc,oBAAoB;AAClC,cAAc,oBAAoB;AAClC,cAAc,mBAAmB;AACjC,cAAc,4BAA4B;AAC1C,cAAc,uBAAuB;AACrC,cAAc,yBAAyB;AACvC,cAAc,uBAAuB;AACrC,cAAc,8BAA8B;AAC5C,cAAc,qBAAqB;AACnC,cAAc,oBAAoB"}
@@ -0,0 +1,47 @@
1
+ import * as React from 'react';
2
+ import { Types } from 'tabster';
3
+ /**
4
+ * Merges a collection of tabster attributes.
5
+ *
6
+ * ⚠️The attributes passed as arguments to this hook cannot change at runtime.
7
+ * @internal
8
+ * @param attributes - collection of tabster attributes from other react-tabster hooks
9
+ * @returns single merged tabster attribute
10
+ */ export const useMergedTabsterAttributes_unstable = (...attributes)=>{
11
+ const stringAttributes = attributes.map((attribute)=>attribute[Types.TabsterAttributeName]).filter(Boolean);
12
+ const mergedStrigAttribute = React.useMemo(()=>{
13
+ let attribute = stringAttributes[0];
14
+ attributes.shift();
15
+ for (const attr of stringAttributes){
16
+ attribute = mergeAttributes(attribute, attr);
17
+ }
18
+ return attribute;
19
+ // eslint-disable-next-line react-hooks/exhaustive-deps
20
+ }, stringAttributes);
21
+ return {
22
+ [Types.TabsterAttributeName]: mergedStrigAttribute
23
+ };
24
+ };
25
+ function mergeAttributes(a, b) {
26
+ if (!b) {
27
+ return a;
28
+ }
29
+ let aParsed = {};
30
+ let bParsed = {};
31
+ if (a) {
32
+ try {
33
+ aParsed = JSON.parse(a);
34
+ // eslint-disable-next-line no-empty
35
+ } catch {}
36
+ }
37
+ if (b) {
38
+ try {
39
+ bParsed = JSON.parse(b);
40
+ // eslint-disable-next-line no-empty
41
+ } catch {}
42
+ }
43
+ return JSON.stringify({
44
+ ...aParsed,
45
+ ...bParsed
46
+ });
47
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useMergeTabsterAttributes.ts"],"sourcesContent":["import * as React from 'react';\nimport { Types } from 'tabster';\n\n/**\n * Merges a collection of tabster attributes.\n *\n * ⚠️The attributes passed as arguments to this hook cannot change at runtime.\n * @internal\n * @param attributes - collection of tabster attributes from other react-tabster hooks\n * @returns single merged tabster attribute\n */\nexport const useMergedTabsterAttributes_unstable: (\n ...attributes: Types.TabsterDOMAttribute[]\n) => Types.TabsterDOMAttribute = (...attributes) => {\n const stringAttributes = attributes\n .map(attribute => attribute[Types.TabsterAttributeName])\n .filter(Boolean) as string[];\n\n const mergedStrigAttribute = React.useMemo(() => {\n let attribute = stringAttributes[0];\n attributes.shift();\n\n for (const attr of stringAttributes) {\n attribute = mergeAttributes(attribute, attr);\n }\n\n return attribute;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, stringAttributes);\n\n return { [Types.TabsterAttributeName]: mergedStrigAttribute };\n};\n\nfunction mergeAttributes(a: string, b?: string): string {\n if (!b) {\n return a;\n }\n\n let aParsed = {};\n let bParsed = {};\n if (a) {\n try {\n aParsed = JSON.parse(a);\n // eslint-disable-next-line no-empty\n } catch {}\n }\n\n if (b) {\n try {\n bParsed = JSON.parse(b);\n // eslint-disable-next-line no-empty\n } catch {}\n }\n\n return JSON.stringify({ ...aParsed, ...bParsed });\n}\n"],"names":["React","Types","useMergedTabsterAttributes_unstable","attributes","stringAttributes","map","attribute","TabsterAttributeName","filter","Boolean","mergedStrigAttribute","useMemo","shift","attr","mergeAttributes","a","b","aParsed","bParsed","JSON","parse","stringify"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,KAAK,QAAQ,UAAU;AAEhC;;;;;;;CAOC,GACD,OAAO,MAAMC,sCAEoB,CAAC,GAAGC,aAAe;IAClD,MAAMC,mBAAmBD,WACtBE,GAAG,CAACC,CAAAA,YAAaA,SAAS,CAACL,MAAMM,oBAAoB,CAAC,EACtDC,MAAM,CAACC;IAEV,MAAMC,uBAAuBV,MAAMW,OAAO,CAAC,IAAM;QAC/C,IAAIL,YAAYF,gBAAgB,CAAC,EAAE;QACnCD,WAAWS,KAAK;QAEhB,KAAK,MAAMC,QAAQT,iBAAkB;YACnCE,YAAYQ,gBAAgBR,WAAWO;QACzC;QAEA,OAAOP;IACP,uDAAuD;IACzD,GAAGF;IAEH,OAAO;QAAE,CAACH,MAAMM,oBAAoB,CAAC,EAAEG;IAAqB;AAC9D,EAAE;AAEF,SAASI,gBAAgBC,CAAS,EAAEC,CAAU,EAAU;IACtD,IAAI,CAACA,GAAG;QACN,OAAOD;IACT,CAAC;IAED,IAAIE,UAAU,CAAC;IACf,IAAIC,UAAU,CAAC;IACf,IAAIH,GAAG;QACL,IAAI;YACFE,UAAUE,KAAKC,KAAK,CAACL;QACrB,oCAAoC;QACtC,EAAE,OAAM,CAAC;IACX,CAAC;IAED,IAAIC,GAAG;QACL,IAAI;YACFE,UAAUC,KAAKC,KAAK,CAACJ;QACrB,oCAAoC;QACtC,EAAE,OAAM,CAAC;IACX,CAAC;IAED,OAAOG,KAAKE,SAAS,CAAC;QAAE,GAAGJ,OAAO;QAAE,GAAGC,OAAO;IAAC;AACjD"}
@@ -1,6 +1,6 @@
1
1
  import { useId } from '@fluentui/react-utilities';
2
2
  import { useTabsterAttributes } from './useTabsterAttributes';
3
- import { getDeloser, getModalizer } from 'tabster';
3
+ import { getModalizer, getRestorer, Types as TabsterTypes } from 'tabster';
4
4
  import { useTabster } from './useTabster';
5
5
  /**
6
6
  * Applies modal dialog behaviour through DOM attributes
@@ -11,14 +11,16 @@ import { useTabster } from './useTabster';
11
11
  */ export const useModalAttributes = (options = {})=>{
12
12
  const { trapFocus , alwaysFocusable , legacyTrapFocus } = options;
13
13
  const tabster = useTabster();
14
- // Initializes the modalizer and deloser APIs
14
+ // Initializes the modalizer and restorer APIs
15
15
  if (tabster) {
16
16
  getModalizer(tabster);
17
- getDeloser(tabster);
17
+ getRestorer(tabster);
18
18
  }
19
19
  const id = useId('modal-', options.id);
20
20
  const modalAttributes = useTabsterAttributes({
21
- deloser: {},
21
+ restorer: {
22
+ type: TabsterTypes.RestorerTypes.Source
23
+ },
22
24
  modalizer: {
23
25
  id,
24
26
  isOthersAccessible: !trapFocus,
@@ -27,7 +29,9 @@ import { useTabster } from './useTabster';
27
29
  }
28
30
  });
29
31
  const triggerAttributes = useTabsterAttributes({
30
- deloser: {}
32
+ restorer: {
33
+ type: TabsterTypes.RestorerTypes.Target
34
+ }
31
35
  });
32
36
  return {
33
37
  modalAttributes,
@@ -1 +1 @@
1
- {"version":3,"sources":["useModalAttributes.ts"],"sourcesContent":["import { useId } from '@fluentui/react-utilities';\nimport { useTabsterAttributes } from './useTabsterAttributes';\nimport { getDeloser, getModalizer, Types as TabsterTypes } from 'tabster';\nimport { useTabster } from './useTabster';\n\nexport interface UseModalAttributesOptions {\n /**\n * Traps focus inside the elements the attributes are applied.\n * Prefer this to `legacyTrapFocus`\n * it forbids users to tab out of the focus trap into the actual browser.\n */\n trapFocus?: boolean;\n\n /**\n * Traps focus inside the elements the attributes are applied.\n * This prop enables legacy behavior to match previous versions of Fluent and is not\n * recommended for general use.\n * Enabling `legacyTrapFocus` prevents users from tabbing out of the focus trap and into\n * the actual browser. Prefer using `trapFocus` instead of this prop.\n */\n legacyTrapFocus?: boolean;\n\n /**\n * Always reachabled in Tab order\n */\n alwaysFocusable?: boolean;\n\n /**\n * Id to use for the modalizer. An id will be generated if not provided.\n */\n id?: string;\n}\n\n/**\n * Applies modal dialog behaviour through DOM attributes\n * Modal element will focus trap and hide other content on the page\n * The trigger element will be focused if focus is lost after the modal element is removed\n *\n * @returns DOM attributes to apply to the modal element and its trigger\n */\nexport const useModalAttributes = (\n options: UseModalAttributesOptions = {},\n): { modalAttributes: TabsterTypes.TabsterDOMAttribute; triggerAttributes: TabsterTypes.TabsterDOMAttribute } => {\n const { trapFocus, alwaysFocusable, legacyTrapFocus } = options;\n const tabster = useTabster();\n // Initializes the modalizer and deloser APIs\n if (tabster) {\n getModalizer(tabster);\n getDeloser(tabster);\n }\n\n const id = useId('modal-', options.id);\n const modalAttributes = useTabsterAttributes({\n deloser: {},\n modalizer: {\n id,\n isOthersAccessible: !trapFocus,\n isAlwaysAccessible: alwaysFocusable,\n isTrapped: legacyTrapFocus && trapFocus,\n },\n });\n\n const triggerAttributes = useTabsterAttributes({\n deloser: {},\n });\n\n return { modalAttributes, triggerAttributes };\n};\n"],"names":["useId","useTabsterAttributes","getDeloser","getModalizer","useTabster","useModalAttributes","options","trapFocus","alwaysFocusable","legacyTrapFocus","tabster","id","modalAttributes","deloser","modalizer","isOthersAccessible","isAlwaysAccessible","isTrapped","triggerAttributes"],"mappings":"AAAA,SAASA,KAAK,QAAQ,4BAA4B;AAClD,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,UAAU,EAAEC,YAAY,QAA+B,UAAU;AAC1E,SAASC,UAAU,QAAQ,eAAe;AA8B1C;;;;;;CAMC,GACD,OAAO,MAAMC,qBAAqB,CAChCC,UAAqC,CAAC,CAAC,GACwE;IAC/G,MAAM,EAAEC,UAAS,EAAEC,gBAAe,EAAEC,gBAAe,EAAE,GAAGH;IACxD,MAAMI,UAAUN;IAChB,6CAA6C;IAC7C,IAAIM,SAAS;QACXP,aAAaO;QACbR,WAAWQ;IACb,CAAC;IAED,MAAMC,KAAKX,MAAM,UAAUM,QAAQK,EAAE;IACrC,MAAMC,kBAAkBX,qBAAqB;QAC3CY,SAAS,CAAC;QACVC,WAAW;YACTH;YACAI,oBAAoB,CAACR;YACrBS,oBAAoBR;YACpBS,WAAWR,mBAAmBF;QAChC;IACF;IAEA,MAAMW,oBAAoBjB,qBAAqB;QAC7CY,SAAS,CAAC;IACZ;IAEA,OAAO;QAAED;QAAiBM;IAAkB;AAC9C,EAAE"}
1
+ {"version":3,"sources":["useModalAttributes.ts"],"sourcesContent":["import { useId } from '@fluentui/react-utilities';\nimport { useTabsterAttributes } from './useTabsterAttributes';\nimport { getModalizer, getRestorer, Types as TabsterTypes } from 'tabster';\nimport { useTabster } from './useTabster';\n\nexport interface UseModalAttributesOptions {\n /**\n * Traps focus inside the elements the attributes are applied.\n * Prefer this to `legacyTrapFocus`\n * it forbids users to tab out of the focus trap into the actual browser.\n */\n trapFocus?: boolean;\n\n /**\n * Traps focus inside the elements the attributes are applied.\n * This prop enables legacy behavior to match previous versions of Fluent and is not\n * recommended for general use.\n * Enabling `legacyTrapFocus` prevents users from tabbing out of the focus trap and into\n * the actual browser. Prefer using `trapFocus` instead of this prop.\n */\n legacyTrapFocus?: boolean;\n\n /**\n * Always reachabled in Tab order\n */\n alwaysFocusable?: boolean;\n\n /**\n * Id to use for the modalizer. An id will be generated if not provided.\n */\n id?: string;\n}\n\n/**\n * Applies modal dialog behaviour through DOM attributes\n * Modal element will focus trap and hide other content on the page\n * The trigger element will be focused if focus is lost after the modal element is removed\n *\n * @returns DOM attributes to apply to the modal element and its trigger\n */\nexport const useModalAttributes = (\n options: UseModalAttributesOptions = {},\n): { modalAttributes: TabsterTypes.TabsterDOMAttribute; triggerAttributes: TabsterTypes.TabsterDOMAttribute } => {\n const { trapFocus, alwaysFocusable, legacyTrapFocus } = options;\n const tabster = useTabster();\n // Initializes the modalizer and restorer APIs\n if (tabster) {\n getModalizer(tabster);\n getRestorer(tabster);\n }\n\n const id = useId('modal-', options.id);\n const modalAttributes = useTabsterAttributes({\n restorer: { type: TabsterTypes.RestorerTypes.Source },\n modalizer: {\n id,\n isOthersAccessible: !trapFocus,\n isAlwaysAccessible: alwaysFocusable,\n isTrapped: legacyTrapFocus && trapFocus,\n },\n });\n\n const triggerAttributes = useTabsterAttributes({\n restorer: { type: TabsterTypes.RestorerTypes.Target },\n });\n\n return { modalAttributes, triggerAttributes };\n};\n"],"names":["useId","useTabsterAttributes","getModalizer","getRestorer","Types","TabsterTypes","useTabster","useModalAttributes","options","trapFocus","alwaysFocusable","legacyTrapFocus","tabster","id","modalAttributes","restorer","type","RestorerTypes","Source","modalizer","isOthersAccessible","isAlwaysAccessible","isTrapped","triggerAttributes","Target"],"mappings":"AAAA,SAASA,KAAK,QAAQ,4BAA4B;AAClD,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,YAAY,EAAEC,WAAW,EAAEC,SAASC,YAAY,QAAQ,UAAU;AAC3E,SAASC,UAAU,QAAQ,eAAe;AA8B1C;;;;;;CAMC,GACD,OAAO,MAAMC,qBAAqB,CAChCC,UAAqC,CAAC,CAAC,GACwE;IAC/G,MAAM,EAAEC,UAAS,EAAEC,gBAAe,EAAEC,gBAAe,EAAE,GAAGH;IACxD,MAAMI,UAAUN;IAChB,8CAA8C;IAC9C,IAAIM,SAAS;QACXV,aAAaU;QACbT,YAAYS;IACd,CAAC;IAED,MAAMC,KAAKb,MAAM,UAAUQ,QAAQK,EAAE;IACrC,MAAMC,kBAAkBb,qBAAqB;QAC3Cc,UAAU;YAAEC,MAAMX,aAAaY,aAAa,CAACC,MAAM;QAAC;QACpDC,WAAW;YACTN;YACAO,oBAAoB,CAACX;YACrBY,oBAAoBX;YACpBY,WAAWX,mBAAmBF;QAChC;IACF;IAEA,MAAMc,oBAAoBtB,qBAAqB;QAC7Cc,UAAU;YAAEC,MAAMX,aAAaY,aAAa,CAACO,MAAM;QAAC;IACtD;IAEA,OAAO;QAAEV;QAAiBS;IAAkB;AAC9C,EAAE"}
@@ -0,0 +1,32 @@
1
+ import { getRestorer, getTabsterAttribute, Types as TabsterTypes } from 'tabster';
2
+ import { useTabster } from './useTabster';
3
+ /**
4
+ * Focus will be restored to the most recent target element when it is lost from a source
5
+ * @returns Attribute to apply to the target element where focus is restored
6
+ */ export function useRestoreFocusTarget() {
7
+ const tabster = useTabster();
8
+ // Initializes the restorer API
9
+ if (tabster) {
10
+ getRestorer(tabster);
11
+ }
12
+ return getTabsterAttribute({
13
+ restorer: {
14
+ type: TabsterTypes.RestorerTypes.Target
15
+ }
16
+ });
17
+ }
18
+ /**
19
+ * Focus will be restored to the most recent target element when it is lost from a source
20
+ * @returns Attribute to apply to the element that might lose focus
21
+ */ export function useRestoreFocusSource() {
22
+ const tabster = useTabster();
23
+ // Initializes the restorer API
24
+ if (tabster) {
25
+ getRestorer(tabster);
26
+ }
27
+ return getTabsterAttribute({
28
+ restorer: {
29
+ type: TabsterTypes.RestorerTypes.Source
30
+ }
31
+ });
32
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useRestoreFocus.ts"],"sourcesContent":["import { getRestorer, getTabsterAttribute, Types as TabsterTypes } from 'tabster';\nimport { useTabster } from './useTabster';\n\n/**\n * Focus will be restored to the most recent target element when it is lost from a source\n * @returns Attribute to apply to the target element where focus is restored\n */\nexport function useRestoreFocusTarget(): TabsterTypes.TabsterDOMAttribute {\n const tabster = useTabster();\n // Initializes the restorer API\n if (tabster) {\n getRestorer(tabster);\n }\n\n return getTabsterAttribute({ restorer: { type: TabsterTypes.RestorerTypes.Target } });\n}\n\n/**\n * Focus will be restored to the most recent target element when it is lost from a source\n * @returns Attribute to apply to the element that might lose focus\n */\nexport function useRestoreFocusSource(): TabsterTypes.TabsterDOMAttribute {\n const tabster = useTabster();\n // Initializes the restorer API\n if (tabster) {\n getRestorer(tabster);\n }\n\n return getTabsterAttribute({ restorer: { type: TabsterTypes.RestorerTypes.Source } });\n}\n"],"names":["getRestorer","getTabsterAttribute","Types","TabsterTypes","useTabster","useRestoreFocusTarget","tabster","restorer","type","RestorerTypes","Target","useRestoreFocusSource","Source"],"mappings":"AAAA,SAASA,WAAW,EAAEC,mBAAmB,EAAEC,SAASC,YAAY,QAAQ,UAAU;AAClF,SAASC,UAAU,QAAQ,eAAe;AAE1C;;;CAGC,GACD,OAAO,SAASC,wBAA0D;IACxE,MAAMC,UAAUF;IAChB,+BAA+B;IAC/B,IAAIE,SAAS;QACXN,YAAYM;IACd,CAAC;IAED,OAAOL,oBAAoB;QAAEM,UAAU;YAAEC,MAAML,aAAaM,aAAa,CAACC,MAAM;QAAC;IAAE;AACrF,CAAC;AAED;;;CAGC,GACD,OAAO,SAASC,wBAA0D;IACxE,MAAML,UAAUF;IAChB,+BAA+B;IAC/B,IAAIE,SAAS;QACXN,YAAYM;IACd,CAAC;IAED,OAAOL,oBAAoB;QAAEM,UAAU;YAAEC,MAAML,aAAaM,aAAa,CAACG,MAAM;QAAC;IAAE;AACrF,CAAC"}
package/lib/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { useArrowNavigationGroup, useFocusableGroup, useFocusFinders, useFocusVisible, useFocusWithin, useKeyboardNavAttribute, useModalAttributes, useTabsterAttributes, useObservedElement, useFocusObserved } from './hooks/index';
1
+ export { useArrowNavigationGroup, useFocusableGroup, useFocusFinders, useFocusVisible, useFocusWithin, useKeyboardNavAttribute, useModalAttributes, useTabsterAttributes, useObservedElement, useFocusObserved, useMergedTabsterAttributes_unstable, useRestoreFocusSource, useRestoreFocusTarget } from './hooks/index';
2
2
  export { createCustomFocusIndicatorStyle, createFocusOutlineStyle } from './focus/index';
3
3
  export { applyFocusVisiblePolyfill } from './focus/index';
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} 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';\n"],"names":["useArrowNavigationGroup","useFocusableGroup","useFocusFinders","useFocusVisible","useFocusWithin","useKeyboardNavAttribute","useModalAttributes","useTabsterAttributes","useObservedElement","useFocusObserved","createCustomFocusIndicatorStyle","createFocusOutlineStyle","applyFocusVisiblePolyfill"],"mappings":"AAAA,SACEA,uBAAuB,EACvBC,iBAAiB,EACjBC,eAAe,EACfC,eAAe,EACfC,cAAc,EACdC,uBAAuB,EACvBC,kBAAkB,EAClBC,oBAAoB,EACpBC,kBAAkB,EAClBC,gBAAgB,QACX,gBAAgB;AAOvB,SAASC,+BAA+B,EAAEC,uBAAuB,QAAQ,gBAAgB;AASzF,SAASC,yBAAyB,QAAQ,gBAAgB"}
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} 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"],"names":["useArrowNavigationGroup","useFocusableGroup","useFocusFinders","useFocusVisible","useFocusWithin","useKeyboardNavAttribute","useModalAttributes","useTabsterAttributes","useObservedElement","useFocusObserved","useMergedTabsterAttributes_unstable","useRestoreFocusSource","useRestoreFocusTarget","createCustomFocusIndicatorStyle","createFocusOutlineStyle","applyFocusVisiblePolyfill"],"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,QAChB,gBAAgB;AAOvB,SAASC,+BAA+B,EAAEC,uBAAuB,QAAQ,gBAAgB;AASzF,SAASC,yBAAyB,QAAQ,gBAAgB"}
@@ -12,4 +12,6 @@ _exportStar(require("./useKeyboardNavAttribute"), exports);
12
12
  _exportStar(require("./useModalAttributes"), exports);
13
13
  _exportStar(require("./useTabsterAttributes"), exports);
14
14
  _exportStar(require("./useObservedElement"), exports);
15
+ _exportStar(require("./useMergeTabsterAttributes"), exports);
15
16
  _exportStar(require("./useFocusObserved"), exports);
17
+ _exportStar(require("./useRestoreFocus"), 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 './useModalAttributes';\nexport * from './useTabsterAttributes';\nexport * from './useObservedElement';\nexport * from './useFocusObserved';\n"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA"}
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 './useModalAttributes';\nexport * from './useTabsterAttributes';\nexport * from './useObservedElement';\nexport * from './useMergeTabsterAttributes';\nexport * from './useFocusObserved';\nexport * from './useRestoreFocus';\n"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useMergedTabsterAttributes_unstable", {
6
+ enumerable: true,
7
+ get: ()=>useMergedTabsterAttributes_unstable
8
+ });
9
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ const _tabster = require("tabster");
12
+ const useMergedTabsterAttributes_unstable = (...attributes)=>{
13
+ const stringAttributes = attributes.map((attribute)=>attribute[_tabster.Types.TabsterAttributeName]).filter(Boolean);
14
+ const mergedStrigAttribute = _react.useMemo(()=>{
15
+ let attribute = stringAttributes[0];
16
+ attributes.shift();
17
+ for (const attr of stringAttributes){
18
+ attribute = mergeAttributes(attribute, attr);
19
+ }
20
+ return attribute;
21
+ // eslint-disable-next-line react-hooks/exhaustive-deps
22
+ }, stringAttributes);
23
+ return {
24
+ [_tabster.Types.TabsterAttributeName]: mergedStrigAttribute
25
+ };
26
+ };
27
+ function mergeAttributes(a, b) {
28
+ if (!b) {
29
+ return a;
30
+ }
31
+ let aParsed = {};
32
+ let bParsed = {};
33
+ if (a) {
34
+ try {
35
+ aParsed = JSON.parse(a);
36
+ // eslint-disable-next-line no-empty
37
+ } catch {}
38
+ }
39
+ if (b) {
40
+ try {
41
+ bParsed = JSON.parse(b);
42
+ // eslint-disable-next-line no-empty
43
+ } catch {}
44
+ }
45
+ return JSON.stringify({
46
+ ...aParsed,
47
+ ...bParsed
48
+ });
49
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useMergeTabsterAttributes.js"],"sourcesContent":["import * as React from 'react';\nimport { Types } from 'tabster';\n/**\n * Merges a collection of tabster attributes.\n *\n * ⚠️The attributes passed as arguments to this hook cannot change at runtime.\n * @internal\n * @param attributes - collection of tabster attributes from other react-tabster hooks\n * @returns single merged tabster attribute\n */ export const useMergedTabsterAttributes_unstable = (...attributes)=>{\n const stringAttributes = attributes.map((attribute)=>attribute[Types.TabsterAttributeName]).filter(Boolean);\n const mergedStrigAttribute = React.useMemo(()=>{\n let attribute = stringAttributes[0];\n attributes.shift();\n for (const attr of stringAttributes){\n attribute = mergeAttributes(attribute, attr);\n }\n return attribute;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, stringAttributes);\n return {\n [Types.TabsterAttributeName]: mergedStrigAttribute\n };\n};\nfunction mergeAttributes(a, b) {\n if (!b) {\n return a;\n }\n let aParsed = {};\n let bParsed = {};\n if (a) {\n try {\n aParsed = JSON.parse(a);\n // eslint-disable-next-line no-empty\n } catch {}\n }\n if (b) {\n try {\n bParsed = JSON.parse(b);\n // eslint-disable-next-line no-empty\n } catch {}\n }\n return JSON.stringify({\n ...aParsed,\n ...bParsed\n });\n}\n"],"names":["useMergedTabsterAttributes_unstable","attributes","stringAttributes","map","attribute","Types","TabsterAttributeName","filter","Boolean","mergedStrigAttribute","React","useMemo","shift","attr","mergeAttributes","a","b","aParsed","bParsed","JSON","parse","stringify"],"mappings":";;;;+BASiBA;;aAAAA;;;6DATM;yBACD;AAQX,MAAMA,sCAAsC,CAAC,GAAGC,aAAa;IACpE,MAAMC,mBAAmBD,WAAWE,GAAG,CAAC,CAACC,YAAYA,SAAS,CAACC,cAAK,CAACC,oBAAoB,CAAC,EAAEC,MAAM,CAACC;IACnG,MAAMC,uBAAuBC,OAAMC,OAAO,CAAC,IAAI;QAC3C,IAAIP,YAAYF,gBAAgB,CAAC,EAAE;QACnCD,WAAWW,KAAK;QAChB,KAAK,MAAMC,QAAQX,iBAAiB;YAChCE,YAAYU,gBAAgBV,WAAWS;QAC3C;QACA,OAAOT;IACX,uDAAuD;IACvD,GAAGF;IACH,OAAO;QACH,CAACG,cAAK,CAACC,oBAAoB,CAAC,EAAEG;IAClC;AACJ;AACA,SAASK,gBAAgBC,CAAC,EAAEC,CAAC,EAAE;IAC3B,IAAI,CAACA,GAAG;QACJ,OAAOD;IACX,CAAC;IACD,IAAIE,UAAU,CAAC;IACf,IAAIC,UAAU,CAAC;IACf,IAAIH,GAAG;QACH,IAAI;YACAE,UAAUE,KAAKC,KAAK,CAACL;QACzB,oCAAoC;QACpC,EAAE,OAAO,CAAC;IACd,CAAC;IACD,IAAIC,GAAG;QACH,IAAI;YACAE,UAAUC,KAAKC,KAAK,CAACJ;QACzB,oCAAoC;QACpC,EAAE,OAAO,CAAC;IACd,CAAC;IACD,OAAOG,KAAKE,SAAS,CAAC;QAClB,GAAGJ,OAAO;QACV,GAAGC,OAAO;IACd;AACJ"}
@@ -13,14 +13,16 @@ const _useTabster = require("./useTabster");
13
13
  const useModalAttributes = (options = {})=>{
14
14
  const { trapFocus , alwaysFocusable , legacyTrapFocus } = options;
15
15
  const tabster = (0, _useTabster.useTabster)();
16
- // Initializes the modalizer and deloser APIs
16
+ // Initializes the modalizer and restorer APIs
17
17
  if (tabster) {
18
18
  (0, _tabster.getModalizer)(tabster);
19
- (0, _tabster.getDeloser)(tabster);
19
+ (0, _tabster.getRestorer)(tabster);
20
20
  }
21
21
  const id = (0, _reactUtilities.useId)('modal-', options.id);
22
22
  const modalAttributes = (0, _useTabsterAttributes.useTabsterAttributes)({
23
- deloser: {},
23
+ restorer: {
24
+ type: _tabster.Types.RestorerTypes.Source
25
+ },
24
26
  modalizer: {
25
27
  id,
26
28
  isOthersAccessible: !trapFocus,
@@ -29,7 +31,9 @@ const useModalAttributes = (options = {})=>{
29
31
  }
30
32
  });
31
33
  const triggerAttributes = (0, _useTabsterAttributes.useTabsterAttributes)({
32
- deloser: {}
34
+ restorer: {
35
+ type: _tabster.Types.RestorerTypes.Target
36
+ }
33
37
  });
34
38
  return {
35
39
  modalAttributes,
@@ -1 +1 @@
1
- {"version":3,"sources":["useModalAttributes.js"],"sourcesContent":["import { useId } from '@fluentui/react-utilities';\nimport { useTabsterAttributes } from './useTabsterAttributes';\nimport { getDeloser, getModalizer } from 'tabster';\nimport { useTabster } from './useTabster';\n/**\n * Applies modal dialog behaviour through DOM attributes\n * Modal element will focus trap and hide other content on the page\n * The trigger element will be focused if focus is lost after the modal element is removed\n *\n * @returns DOM attributes to apply to the modal element and its trigger\n */ export const useModalAttributes = (options = {})=>{\n const { trapFocus , alwaysFocusable , legacyTrapFocus } = options;\n const tabster = useTabster();\n // Initializes the modalizer and deloser APIs\n if (tabster) {\n getModalizer(tabster);\n getDeloser(tabster);\n }\n const id = useId('modal-', options.id);\n const modalAttributes = useTabsterAttributes({\n deloser: {},\n modalizer: {\n id,\n isOthersAccessible: !trapFocus,\n isAlwaysAccessible: alwaysFocusable,\n isTrapped: legacyTrapFocus && trapFocus\n }\n });\n const triggerAttributes = useTabsterAttributes({\n deloser: {}\n });\n return {\n modalAttributes,\n triggerAttributes\n };\n};\n"],"names":["useModalAttributes","options","trapFocus","alwaysFocusable","legacyTrapFocus","tabster","useTabster","getModalizer","getDeloser","id","useId","modalAttributes","useTabsterAttributes","deloser","modalizer","isOthersAccessible","isAlwaysAccessible","isTrapped","triggerAttributes"],"mappings":";;;;+BAUiBA;;aAAAA;;gCAVK;sCACe;yBACI;4BACd;AAOhB,MAAMA,qBAAqB,CAACC,UAAU,CAAC,CAAC,GAAG;IAClD,MAAM,EAAEC,UAAS,EAAGC,gBAAe,EAAGC,gBAAe,EAAG,GAAGH;IAC3D,MAAMI,UAAUC,IAAAA,sBAAU;IAC1B,6CAA6C;IAC7C,IAAID,SAAS;QACTE,IAAAA,qBAAY,EAACF;QACbG,IAAAA,mBAAU,EAACH;IACf,CAAC;IACD,MAAMI,KAAKC,IAAAA,qBAAK,EAAC,UAAUT,QAAQQ,EAAE;IACrC,MAAME,kBAAkBC,IAAAA,0CAAoB,EAAC;QACzCC,SAAS,CAAC;QACVC,WAAW;YACPL;YACAM,oBAAoB,CAACb;YACrBc,oBAAoBb;YACpBc,WAAWb,mBAAmBF;QAClC;IACJ;IACA,MAAMgB,oBAAoBN,IAAAA,0CAAoB,EAAC;QAC3CC,SAAS,CAAC;IACd;IACA,OAAO;QACHF;QACAO;IACJ;AACJ"}
1
+ {"version":3,"sources":["useModalAttributes.js"],"sourcesContent":["import { useId } from '@fluentui/react-utilities';\nimport { useTabsterAttributes } from './useTabsterAttributes';\nimport { getModalizer, getRestorer, Types as TabsterTypes } from 'tabster';\nimport { useTabster } from './useTabster';\n/**\n * Applies modal dialog behaviour through DOM attributes\n * Modal element will focus trap and hide other content on the page\n * The trigger element will be focused if focus is lost after the modal element is removed\n *\n * @returns DOM attributes to apply to the modal element and its trigger\n */ export const useModalAttributes = (options = {})=>{\n const { trapFocus , alwaysFocusable , legacyTrapFocus } = options;\n const tabster = useTabster();\n // Initializes the modalizer and restorer APIs\n if (tabster) {\n getModalizer(tabster);\n getRestorer(tabster);\n }\n const id = useId('modal-', options.id);\n const modalAttributes = useTabsterAttributes({\n restorer: {\n type: TabsterTypes.RestorerTypes.Source\n },\n modalizer: {\n id,\n isOthersAccessible: !trapFocus,\n isAlwaysAccessible: alwaysFocusable,\n isTrapped: legacyTrapFocus && trapFocus\n }\n });\n const triggerAttributes = useTabsterAttributes({\n restorer: {\n type: TabsterTypes.RestorerTypes.Target\n }\n });\n return {\n modalAttributes,\n triggerAttributes\n };\n};\n"],"names":["useModalAttributes","options","trapFocus","alwaysFocusable","legacyTrapFocus","tabster","useTabster","getModalizer","getRestorer","id","useId","modalAttributes","useTabsterAttributes","restorer","type","TabsterTypes","RestorerTypes","Source","modalizer","isOthersAccessible","isAlwaysAccessible","isTrapped","triggerAttributes","Target"],"mappings":";;;;+BAUiBA;;aAAAA;;gCAVK;sCACe;yBAC4B;4BACtC;AAOhB,MAAMA,qBAAqB,CAACC,UAAU,CAAC,CAAC,GAAG;IAClD,MAAM,EAAEC,UAAS,EAAGC,gBAAe,EAAGC,gBAAe,EAAG,GAAGH;IAC3D,MAAMI,UAAUC,IAAAA,sBAAU;IAC1B,8CAA8C;IAC9C,IAAID,SAAS;QACTE,IAAAA,qBAAY,EAACF;QACbG,IAAAA,oBAAW,EAACH;IAChB,CAAC;IACD,MAAMI,KAAKC,IAAAA,qBAAK,EAAC,UAAUT,QAAQQ,EAAE;IACrC,MAAME,kBAAkBC,IAAAA,0CAAoB,EAAC;QACzCC,UAAU;YACNC,MAAMC,cAAY,CAACC,aAAa,CAACC,MAAM;QAC3C;QACAC,WAAW;YACPT;YACAU,oBAAoB,CAACjB;YACrBkB,oBAAoBjB;YACpBkB,WAAWjB,mBAAmBF;QAClC;IACJ;IACA,MAAMoB,oBAAoBV,IAAAA,0CAAoB,EAAC;QAC3CC,UAAU;YACNC,MAAMC,cAAY,CAACC,aAAa,CAACO,MAAM;QAC3C;IACJ;IACA,OAAO;QACHZ;QACAW;IACJ;AACJ"}
@@ -0,0 +1,40 @@
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
+ useRestoreFocusTarget: ()=>useRestoreFocusTarget,
13
+ useRestoreFocusSource: ()=>useRestoreFocusSource
14
+ });
15
+ const _tabster = require("tabster");
16
+ const _useTabster = require("./useTabster");
17
+ function useRestoreFocusTarget() {
18
+ const tabster = (0, _useTabster.useTabster)();
19
+ // Initializes the restorer API
20
+ if (tabster) {
21
+ (0, _tabster.getRestorer)(tabster);
22
+ }
23
+ return (0, _tabster.getTabsterAttribute)({
24
+ restorer: {
25
+ type: _tabster.Types.RestorerTypes.Target
26
+ }
27
+ });
28
+ }
29
+ function useRestoreFocusSource() {
30
+ const tabster = (0, _useTabster.useTabster)();
31
+ // Initializes the restorer API
32
+ if (tabster) {
33
+ (0, _tabster.getRestorer)(tabster);
34
+ }
35
+ return (0, _tabster.getTabsterAttribute)({
36
+ restorer: {
37
+ type: _tabster.Types.RestorerTypes.Source
38
+ }
39
+ });
40
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useRestoreFocus.js"],"sourcesContent":["import { getRestorer, getTabsterAttribute, Types as TabsterTypes } from 'tabster';\nimport { useTabster } from './useTabster';\n/**\n * Focus will be restored to the most recent target element when it is lost from a source\n * @returns Attribute to apply to the target element where focus is restored\n */ export function useRestoreFocusTarget() {\n const tabster = useTabster();\n // Initializes the restorer API\n if (tabster) {\n getRestorer(tabster);\n }\n return getTabsterAttribute({\n restorer: {\n type: TabsterTypes.RestorerTypes.Target\n }\n });\n}\n/**\n * Focus will be restored to the most recent target element when it is lost from a source\n * @returns Attribute to apply to the element that might lose focus\n */ export function useRestoreFocusSource() {\n const tabster = useTabster();\n // Initializes the restorer API\n if (tabster) {\n getRestorer(tabster);\n }\n return getTabsterAttribute({\n restorer: {\n type: TabsterTypes.RestorerTypes.Source\n }\n });\n}\n"],"names":["useRestoreFocusTarget","useRestoreFocusSource","tabster","useTabster","getRestorer","getTabsterAttribute","restorer","type","TabsterTypes","RestorerTypes","Target","Source"],"mappings":";;;;;;;;;;;IAKoBA,qBAAqB,MAArBA;IAeAC,qBAAqB,MAArBA;;yBApBoD;4BAC7C;AAIhB,SAASD,wBAAwB;IACxC,MAAME,UAAUC,IAAAA,sBAAU;IAC1B,+BAA+B;IAC/B,IAAID,SAAS;QACTE,IAAAA,oBAAW,EAACF;IAChB,CAAC;IACD,OAAOG,IAAAA,4BAAmB,EAAC;QACvBC,UAAU;YACNC,MAAMC,cAAY,CAACC,aAAa,CAACC,MAAM;QAC3C;IACJ;AACJ;AAIW,SAAST,wBAAwB;IACxC,MAAMC,UAAUC,IAAAA,sBAAU;IAC1B,+BAA+B;IAC/B,IAAID,SAAS;QACTE,IAAAA,oBAAW,EAACF;IAChB,CAAC;IACD,OAAOG,IAAAA,4BAAmB,EAAC;QACvBC,UAAU;YACNC,MAAMC,cAAY,CAACC,aAAa,CAACE,MAAM;QAC3C;IACJ;AACJ"}
@@ -19,6 +19,9 @@ _export(exports, {
19
19
  useTabsterAttributes: ()=>_index.useTabsterAttributes,
20
20
  useObservedElement: ()=>_index.useObservedElement,
21
21
  useFocusObserved: ()=>_index.useFocusObserved,
22
+ useMergedTabsterAttributes_unstable: ()=>_index.useMergedTabsterAttributes_unstable,
23
+ useRestoreFocusSource: ()=>_index.useRestoreFocusSource,
24
+ useRestoreFocusTarget: ()=>_index.useRestoreFocusTarget,
22
25
  createCustomFocusIndicatorStyle: ()=>_index1.createCustomFocusIndicatorStyle,
23
26
  createFocusOutlineStyle: ()=>_index1.createFocusOutlineStyle,
24
27
  applyFocusVisiblePolyfill: ()=>_index1.applyFocusVisiblePolyfill
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js"],"sourcesContent":["export { useArrowNavigationGroup, useFocusableGroup, useFocusFinders, useFocusVisible, useFocusWithin, useKeyboardNavAttribute, useModalAttributes, useTabsterAttributes, useObservedElement, useFocusObserved } from './hooks/index';\nexport { createCustomFocusIndicatorStyle, createFocusOutlineStyle } from './focus/index';\nexport { applyFocusVisiblePolyfill } from './focus/index';\n"],"names":["useArrowNavigationGroup","useFocusableGroup","useFocusFinders","useFocusVisible","useFocusWithin","useKeyboardNavAttribute","useModalAttributes","useTabsterAttributes","useObservedElement","useFocusObserved","createCustomFocusIndicatorStyle","createFocusOutlineStyle","applyFocusVisiblePolyfill"],"mappings":";;;;;;;;;;;IAASA,uBAAuB,MAAvBA,8BAAuB;IAAEC,iBAAiB,MAAjBA,wBAAiB;IAAEC,eAAe,MAAfA,sBAAe;IAAEC,eAAe,MAAfA,sBAAe;IAAEC,cAAc,MAAdA,qBAAc;IAAEC,uBAAuB,MAAvBA,8BAAuB;IAAEC,kBAAkB,MAAlBA,yBAAkB;IAAEC,oBAAoB,MAApBA,2BAAoB;IAAEC,kBAAkB,MAAlBA,yBAAkB;IAAEC,gBAAgB,MAAhBA,uBAAgB;IACrMC,+BAA+B,MAA/BA,uCAA+B;IAAEC,uBAAuB,MAAvBA,+BAAuB;IACxDC,yBAAyB,MAAzBA,iCAAyB;;uBAFoL;wBAC7I"}
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["export { useArrowNavigationGroup, useFocusableGroup, useFocusFinders, useFocusVisible, useFocusWithin, useKeyboardNavAttribute, useModalAttributes, useTabsterAttributes, useObservedElement, useFocusObserved, useMergedTabsterAttributes_unstable, useRestoreFocusSource, useRestoreFocusTarget } from './hooks/index';\nexport { createCustomFocusIndicatorStyle, createFocusOutlineStyle } from './focus/index';\nexport { applyFocusVisiblePolyfill } from './focus/index';\n"],"names":["useArrowNavigationGroup","useFocusableGroup","useFocusFinders","useFocusVisible","useFocusWithin","useKeyboardNavAttribute","useModalAttributes","useTabsterAttributes","useObservedElement","useFocusObserved","useMergedTabsterAttributes_unstable","useRestoreFocusSource","useRestoreFocusTarget","createCustomFocusIndicatorStyle","createFocusOutlineStyle","applyFocusVisiblePolyfill"],"mappings":";;;;;;;;;;;IAASA,uBAAuB,MAAvBA,8BAAuB;IAAEC,iBAAiB,MAAjBA,wBAAiB;IAAEC,eAAe,MAAfA,sBAAe;IAAEC,eAAe,MAAfA,sBAAe;IAAEC,cAAc,MAAdA,qBAAc;IAAEC,uBAAuB,MAAvBA,8BAAuB;IAAEC,kBAAkB,MAAlBA,yBAAkB;IAAEC,oBAAoB,MAApBA,2BAAoB;IAAEC,kBAAkB,MAAlBA,yBAAkB;IAAEC,gBAAgB,MAAhBA,uBAAgB;IAAEC,mCAAmC,MAAnCA,0CAAmC;IAAEC,qBAAqB,MAArBA,4BAAqB;IAAEC,qBAAqB,MAArBA,4BAAqB;IACxRC,+BAA+B,MAA/BA,uCAA+B;IAAEC,uBAAuB,MAAvBA,+BAAuB;IACxDC,yBAAyB,MAAzBA,iCAAyB;;uBAFuQ;wBAChO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-tabster",
3
- "version": "9.9.2",
3
+ "version": "9.11.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",
@@ -37,7 +37,7 @@
37
37
  "@griffel/react": "^1.5.7",
38
38
  "@swc/helpers": "^0.4.14",
39
39
  "keyborg": "^2.0.0",
40
- "tabster": "^4.5.1"
40
+ "tabster": "^4.7.0"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "@types/react": ">=16.8.0 <19.0.0",