@dynatrace/strato-components 0.84.12 → 0.84.31
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/core/components/app-root/AppRoot.css +1 -0
- package/core/components/app-root/AppRoot.d.ts +8 -3
- package/core/components/app-root/AppRoot.js +116 -1
- package/core/components/app-root/AppRoot.sty.js +1 -1
- package/core/components/focus-scope/FocusScope.js +81 -1
- package/core/contexts/FocusContext.d.ts +1 -1
- package/core/contexts/FocusContext.js +28 -1
- package/core/hooks/useActiveElement.js +36 -1
- package/core/hooks/useCurrentTheme.d.ts +4 -1
- package/core/hooks/useCurrentTheme.js +54 -1
- package/core/hooks/useFocusContext.js +27 -1
- package/core/index.d.ts +1 -0
- package/core/index.js +45 -1
- package/core/providers/FocusProvider.js +146 -1
- package/core/types/data-props.d.ts +1 -0
- package/core/types/data-props.js +15 -1
- package/core/types/masking-props.d.ts +9 -0
- package/core/types/masking-props.js +15 -0
- package/core/types/styling-props.d.ts +3 -2
- package/core/types/styling-props.js +15 -1
- package/core/types/with-children.d.ts +4 -1
- package/core/types/with-children.js +15 -1
- package/core/utils/focus-management/attempt-focus.js +33 -1
- package/core/utils/focus-management/focus-first-descendant.js +35 -1
- package/core/utils/focus-management/get-first-focusable-child.js +32 -1
- package/core/utils/focus-management/get-last-focusable-child.js +35 -1
- package/core/utils/focus-management/is-focusable.js +39 -1
- package/core/utils/isBrowser.js +25 -1
- package/core/utils/merge-props.js +50 -1
- package/esm/core/components/app-root/AppRoot.css +1 -0
- package/esm/core/components/app-root/AppRoot.js +92 -1
- package/esm/core/components/app-root/AppRoot.js.map +3 -3
- package/esm/core/components/app-root/AppRoot.sty.js +1 -1
- package/esm/core/components/app-root/AppRoot.sty.js.map +1 -1
- package/esm/core/components/focus-scope/FocusScope.js +52 -1
- package/esm/core/components/focus-scope/FocusScope.js.map +2 -2
- package/esm/core/contexts/FocusContext.js +9 -1
- package/esm/core/contexts/FocusContext.js.map +3 -3
- package/esm/core/hooks/useActiveElement.js +17 -1
- package/esm/core/hooks/useActiveElement.js.map +2 -2
- package/esm/core/hooks/useCurrentTheme.js +35 -1
- package/esm/core/hooks/useCurrentTheme.js.map +3 -3
- package/esm/core/hooks/useFocusContext.js +10 -1
- package/esm/core/hooks/useFocusContext.js.map +2 -2
- package/esm/core/index.js +32 -1
- package/esm/core/index.js.map +3 -3
- package/esm/core/providers/FocusProvider.js +117 -1
- package/esm/core/providers/FocusProvider.js.map +2 -2
- package/esm/core/types/masking-props.js +1 -0
- package/esm/core/types/masking-props.js.map +7 -0
- package/esm/core/utils/focus-management/attempt-focus.js +14 -1
- package/esm/core/utils/focus-management/attempt-focus.js.map +2 -2
- package/esm/core/utils/focus-management/focus-first-descendant.js +16 -1
- package/esm/core/utils/focus-management/focus-first-descendant.js.map +2 -2
- package/esm/core/utils/focus-management/get-first-focusable-child.js +13 -1
- package/esm/core/utils/focus-management/get-first-focusable-child.js.map +2 -2
- package/esm/core/utils/focus-management/get-last-focusable-child.js +16 -1
- package/esm/core/utils/focus-management/get-last-focusable-child.js.map +2 -2
- package/esm/core/utils/focus-management/is-focusable.js +20 -1
- package/esm/core/utils/focus-management/is-focusable.js.map +2 -2
- package/esm/core/utils/isBrowser.js +6 -1
- package/esm/core/utils/isBrowser.js.map +2 -2
- package/esm/core/utils/merge-props.js +31 -1
- package/esm/core/utils/merge-props.js.map +2 -2
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/index.js +17 -1
- package/package.json +2 -2
- package/testing/custom-render.d.ts +1 -1
- package/testing/custom-render.js +62 -1
- package/testing/index.js +91 -1
- package/testing/mocks/bounding-client-rect-mock.js +36 -1
- package/testing/mocks/canvas-mock.js +187 -1
- package/testing/mocks/create-mock-element.js +99 -1
- package/testing/mocks/create-range-mock.js +47 -1
- package/testing/mocks/dom-rect-mock.js +56 -1
- package/testing/mocks/fetch-mock.js +38 -1
- package/testing/mocks/intersection-observer-mock.js +58 -1
- package/testing/mocks/match-media-mock.js +45 -1
- package/testing/mocks/offset-height-mock.js +39 -1
- package/testing/mocks/offset-width-mock.js +39 -1
- package/testing/mocks/pointer-event-mock.js +42 -1
- package/testing/mocks/resize-observer-mock.d.ts +1 -1
- package/testing/mocks/resize-observer-mock.js +42 -1
- package/testing/mocks/screen-size-mock.js +34 -1
- package/testing/mocks/scroll-into-view-mock.js +34 -1
- package/testing/mocks/scroll-width-mock.js +39 -1
- package/testing/mocks/select-mock.js +45 -1
- package/testing/mocks/table-virtualization-mock.js +47 -1
- package/testing/mocks/text-ellipsis-mock.js +38 -1
- package/testing/setup.js +57 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/contexts/FocusContext.tsx"],
|
|
4
|
-
"sourcesContent": ["import { createContext } from 'react';\n\nimport { Modality } from '../providers/FocusProvider.js';\n\n/**\n * Defines the contents of the FocusContext.\n * @internal\n */\nexport type FocusContextProps = {\n backgroundInertness?: boolean;\n modality: Modality;\n setBackgroundInertness: (value: boolean) => void;\n};\n\n/**\n * @internal\n *\n * This context keeps all information needed for proper focus management.\n * @param modality - currently used pointer device\n * @param backgroundInertness - if the background (behind overlays) is currently inert (inactive)\n * @param setBackgroundInertness - updates the backgrounds active status\n */\nexport const FocusContext = createContext<FocusContextProps>({\n modality: 'unknown',\n backgroundInertness: undefined,\n setBackgroundInertness: (value) => null,\n});\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import { createContext } from 'react';\n\nimport type { Modality } from '../providers/FocusProvider.js';\n\n/**\n * Defines the contents of the FocusContext.\n * @internal\n */\nexport type FocusContextProps = {\n backgroundInertness?: boolean;\n modality: Modality;\n setBackgroundInertness: (value: boolean) => void;\n};\n\n/**\n * @internal\n *\n * This context keeps all information needed for proper focus management.\n * @param modality - currently used pointer device\n * @param backgroundInertness - if the background (behind overlays) is currently inert (inactive)\n * @param setBackgroundInertness - updates the backgrounds active status\n */\nexport const FocusContext = createContext<FocusContextProps>({\n modality: 'unknown',\n backgroundInertness: undefined,\n setBackgroundInertness: (value) => null,\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,qBAAqB;AAsBvB,MAAM,eAAe,cAAiC;AAAA,EAC3D,UAAU;AAAA,EACV,qBAAqB;AAAA,EACrB,wBAAwB,CAAC,UAAU;AACrC,CAAC;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
import{useState
|
|
1
|
+
import { useState, useEffect } from "react";
|
|
2
|
+
const useActiveElement = () => {
|
|
3
|
+
const [active, setActive] = useState(document.activeElement);
|
|
4
|
+
const handleFocusIn = (e) => {
|
|
5
|
+
setActive(document.activeElement);
|
|
6
|
+
};
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
document.addEventListener("focusin", handleFocusIn);
|
|
9
|
+
return () => {
|
|
10
|
+
document.removeEventListener("focusin", handleFocusIn);
|
|
11
|
+
};
|
|
12
|
+
}, []);
|
|
13
|
+
return active;
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
useActiveElement
|
|
17
|
+
};
|
|
2
18
|
//# sourceMappingURL=useActiveElement.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/hooks/useActiveElement.ts"],
|
|
4
4
|
"sourcesContent": ["import { useState, useEffect } from 'react';\n\n/**\n * @internal\n * Hook used for getting the active element.\n * @returns the currently focused element.\n */\nexport const useActiveElement = (): HTMLElement => {\n const [active, setActive] = useState(document.activeElement as HTMLElement);\n\n const handleFocusIn = (e: FocusEvent) => {\n setActive(document.activeElement as HTMLElement);\n };\n\n useEffect(() => {\n document.addEventListener('focusin', handleFocusIn);\n return () => {\n document.removeEventListener('focusin', handleFocusIn);\n };\n }, []);\n\n return active;\n};\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,UAAU,iBAAiB;AAO7B,MAAM,mBAAmB,MAAmB;AACjD,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,SAAS,aAA4B;AAE1E,QAAM,gBAAgB,CAAC,MAAkB;AACvC,cAAU,SAAS,aAA4B;AAAA,EACjD;AAEA,YAAU,MAAM;AACd,aAAS,iBAAiB,WAAW,aAAa;AAClD,WAAO,MAAM;AACX,eAAS,oBAAoB,WAAW,aAAa;AAAA,IACvD;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,36 @@
|
|
|
1
|
-
import{useEffect
|
|
1
|
+
import { useEffect, useMemo, useState } from "react";
|
|
2
|
+
import { getTheme } from "@dynatrace-sdk/user-preferences";
|
|
3
|
+
import { isBrowser } from "../utils/isBrowser.js";
|
|
4
|
+
function useCurrentTheme() {
|
|
5
|
+
const sdkTheme = useMemo(() => {
|
|
6
|
+
return getTheme();
|
|
7
|
+
}, []);
|
|
8
|
+
if (sdkTheme === "dark" || sdkTheme === "light") {
|
|
9
|
+
return sdkTheme;
|
|
10
|
+
}
|
|
11
|
+
if (!isBrowser) {
|
|
12
|
+
return "light";
|
|
13
|
+
}
|
|
14
|
+
const themeQuery = useMemo(
|
|
15
|
+
() => window && window.matchMedia("(prefers-color-scheme: dark)"),
|
|
16
|
+
[]
|
|
17
|
+
);
|
|
18
|
+
const [currentTheme, setCurrentTheme] = useState(
|
|
19
|
+
themeQuery.matches ? "dark" : "light"
|
|
20
|
+
);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const handlePrefersColorSchemeChange = () => {
|
|
23
|
+
const prefersDark = themeQuery.matches;
|
|
24
|
+
setCurrentTheme(prefersDark ? "dark" : "light");
|
|
25
|
+
};
|
|
26
|
+
themeQuery.addEventListener("change", handlePrefersColorSchemeChange);
|
|
27
|
+
return () => {
|
|
28
|
+
themeQuery.removeEventListener("change", handlePrefersColorSchemeChange);
|
|
29
|
+
};
|
|
30
|
+
}, [themeQuery]);
|
|
31
|
+
return currentTheme;
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
useCurrentTheme
|
|
35
|
+
};
|
|
2
36
|
//# sourceMappingURL=useCurrentTheme.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/hooks/useCurrentTheme.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useEffect, useMemo, useState } from 'react';\n\nimport { getTheme } from '@dynatrace-sdk/user-preferences';\n\nimport { isBrowser } from '../utils/isBrowser.js';\n\n
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import { useEffect, useMemo, useState } from 'react';\n\nimport { getTheme } from '@dynatrace-sdk/user-preferences';\n\nimport { isBrowser } from '../utils/isBrowser.js';\n\n/**\n * @public\n * Returns the current theme based on sdk-setting or browsers preferred color-scheme\n */\nexport function useCurrentTheme(): 'light' | 'dark' {\n const sdkTheme = useMemo(() => {\n return getTheme();\n }, []);\n\n if (sdkTheme === 'dark' || sdkTheme === 'light') {\n return sdkTheme;\n }\n\n if (!isBrowser) {\n return 'light';\n }\n\n // suppressing the rules of hooks because the sdkTheme is a constant that cannot\n // change through the applications' lifecycle.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const themeQuery = useMemo(\n () => window && window.matchMedia('(prefers-color-scheme: dark)'),\n [],\n );\n\n // suppressing the rules of hooks because the sdkTheme is a constant that cannot\n // change through the applications' lifecycle.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [currentTheme, setCurrentTheme] = useState<'light' | 'dark'>(\n themeQuery.matches ? 'dark' : 'light',\n );\n\n // suppressing the rules of hooks because the sdkTheme is a constant that cannot\n // change through the applications' lifecycle.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useEffect(() => {\n const handlePrefersColorSchemeChange = () => {\n const prefersDark = themeQuery.matches;\n setCurrentTheme(prefersDark ? 'dark' : 'light');\n };\n\n themeQuery.addEventListener('change', handlePrefersColorSchemeChange);\n return () => {\n themeQuery.removeEventListener('change', handlePrefersColorSchemeChange);\n };\n }, [themeQuery]);\n\n return currentTheme;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW,SAAS,gBAAgB;AAE7C,SAAS,gBAAgB;AAEzB,SAAS,iBAAiB;AAMnB,SAAS,kBAAoC;AAClD,QAAM,WAAW,QAAQ,MAAM;AAC7B,WAAO,SAAS;AAAA,EAClB,GAAG,CAAC,CAAC;AAEL,MAAI,aAAa,UAAU,aAAa,SAAS;AAC/C,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,EACT;AAKA,QAAM,aAAa;AAAA,IACjB,MAAM,UAAU,OAAO,WAAW,8BAA8B;AAAA,IAChE,CAAC;AAAA,EACH;AAKA,QAAM,CAAC,cAAc,eAAe,IAAI;AAAA,IACtC,WAAW,UAAU,SAAS;AAAA,EAChC;AAKA,YAAU,MAAM;AACd,UAAM,iCAAiC,MAAM;AAC3C,YAAM,cAAc,WAAW;AAC/B,sBAAgB,cAAc,SAAS,OAAO;AAAA,IAChD;AAEA,eAAW,iBAAiB,UAAU,8BAA8B;AACpE,WAAO,MAAM;AACX,iBAAW,oBAAoB,UAAU,8BAA8B;AAAA,IACzE;AAAA,EACF,GAAG,CAAC,UAAU,CAAC;AAEf,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
import{useContext
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import {
|
|
3
|
+
FocusContext
|
|
4
|
+
} from "../contexts/FocusContext.js";
|
|
5
|
+
const useFocusContext = () => {
|
|
6
|
+
return useContext(FocusContext);
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
useFocusContext
|
|
10
|
+
};
|
|
2
11
|
//# sourceMappingURL=useFocusContext.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/hooks/useFocusContext.ts"],
|
|
4
4
|
"sourcesContent": ["import { useContext } from 'react';\n\nimport {\n type FocusContextProps,\n FocusContext,\n} from '../contexts/FocusContext.js';\n\n/**\n * Internal hook wrapper for accessing the FocusContext.\n * @internal\n */\nexport const useFocusContext = (): FocusContextProps => {\n return useContext(FocusContext);\n};\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,kBAAkB;AAE3B;AAAA,EAEE;AAAA,OACK;AAMA,MAAM,kBAAkB,MAAyB;AACtD,SAAO,WAAW,YAAY;AAChC;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/esm/core/index.js
CHANGED
|
@@ -1,2 +1,33 @@
|
|
|
1
|
-
import{AppRoot
|
|
1
|
+
import { AppRoot } from "./components/app-root/AppRoot.js";
|
|
2
|
+
import {
|
|
3
|
+
FocusScope
|
|
4
|
+
} from "./components/focus-scope/FocusScope.js";
|
|
5
|
+
import { useCurrentTheme } from "./hooks/useCurrentTheme.js";
|
|
6
|
+
import { useFocusContext } from "./hooks/useFocusContext.js";
|
|
7
|
+
import {
|
|
8
|
+
FocusProvider
|
|
9
|
+
} from "./providers/FocusProvider.js";
|
|
10
|
+
import { attemptFocus } from "./utils/focus-management/attempt-focus.js";
|
|
11
|
+
import { focusFirstDescendant } from "./utils/focus-management/focus-first-descendant.js";
|
|
12
|
+
import { getFirstFocusableChild } from "./utils/focus-management/get-first-focusable-child.js";
|
|
13
|
+
import { getLastFocusableChild } from "./utils/focus-management/get-last-focusable-child.js";
|
|
14
|
+
import { isFocusable } from "./utils/focus-management/is-focusable.js";
|
|
15
|
+
import { isBrowser } from "./utils/isBrowser.js";
|
|
16
|
+
import {
|
|
17
|
+
mergeProps
|
|
18
|
+
} from "./utils/merge-props.js";
|
|
19
|
+
export {
|
|
20
|
+
AppRoot,
|
|
21
|
+
FocusProvider as _FocusProvider,
|
|
22
|
+
FocusScope as _FocusScope,
|
|
23
|
+
attemptFocus as _attemptFocus,
|
|
24
|
+
focusFirstDescendant as _focusFirstDescendant,
|
|
25
|
+
getFirstFocusableChild as _getFirstFocusableChild,
|
|
26
|
+
getLastFocusableChild as _getLastFocusableChild,
|
|
27
|
+
isBrowser as _isBrowser,
|
|
28
|
+
isFocusable as _isFocusable,
|
|
29
|
+
mergeProps as _mergeProps,
|
|
30
|
+
useFocusContext as _useFocusContext,
|
|
31
|
+
useCurrentTheme
|
|
32
|
+
};
|
|
2
33
|
//# sourceMappingURL=index.js.map
|
package/esm/core/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/core/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { AppRoot, type AppRootProps } from './components/app-root/AppRoot.js';\nexport {\n FocusScope as _FocusScope,\n type FocusScopeProps as _FocusScopeProps,\n} from './components/focus-scope/FocusScope.js';\n\nexport { type FocusContextProps as _FocusContextProps } from './contexts/FocusContext.js';\n\nexport { useCurrentTheme } from './hooks/useCurrentTheme.js';\nexport { useFocusContext as _useFocusContext } from './hooks/useFocusContext.js';\nexport {\n FocusProvider as _FocusProvider,\n type Modality as _Modality,\n} from './providers/FocusProvider.js';\nexport type { DataTestId } from './types/data-props.js';\nexport type { StylingProps } from './types/styling-props.js';\nexport type { WithChildren } from './types/with-children.js';\n\nexport { attemptFocus as _attemptFocus } from './utils/focus-management/attempt-focus.js';\nexport { focusFirstDescendant as _focusFirstDescendant } from './utils/focus-management/focus-first-descendant.js';\nexport { getFirstFocusableChild as _getFirstFocusableChild } from './utils/focus-management/get-first-focusable-child.js';\nexport { getLastFocusableChild as _getLastFocusableChild } from './utils/focus-management/get-last-focusable-child.js';\nexport { isFocusable as _isFocusable } from './utils/focus-management/is-focusable.js';\nexport { isBrowser as _isBrowser } from './utils/isBrowser.js';\nexport {\n mergeProps as _mergeProps,\n type NullToObject as _NullToObject,\n type TupleTypes as _TupleTypes,\n type UnionToIntersection as _UnionToIntersection,\n} from './utils/merge-props.js';\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["export { AppRoot, type AppRootProps } from './components/app-root/AppRoot.js';\nexport {\n FocusScope as _FocusScope,\n type FocusScopeProps as _FocusScopeProps,\n} from './components/focus-scope/FocusScope.js';\n\nexport { type FocusContextProps as _FocusContextProps } from './contexts/FocusContext.js';\n\nexport { useCurrentTheme } from './hooks/useCurrentTheme.js';\nexport { useFocusContext as _useFocusContext } from './hooks/useFocusContext.js';\nexport {\n FocusProvider as _FocusProvider,\n type Modality as _Modality,\n} from './providers/FocusProvider.js';\nexport type { MaskingProps } from './types/masking-props.js';\nexport type { DataTestId } from './types/data-props.js';\nexport type { StylingProps } from './types/styling-props.js';\nexport type { WithChildren } from './types/with-children.js';\n\nexport { attemptFocus as _attemptFocus } from './utils/focus-management/attempt-focus.js';\nexport { focusFirstDescendant as _focusFirstDescendant } from './utils/focus-management/focus-first-descendant.js';\nexport { getFirstFocusableChild as _getFirstFocusableChild } from './utils/focus-management/get-first-focusable-child.js';\nexport { getLastFocusableChild as _getLastFocusableChild } from './utils/focus-management/get-last-focusable-child.js';\nexport { isFocusable as _isFocusable } from './utils/focus-management/is-focusable.js';\nexport { isBrowser as _isBrowser } from './utils/isBrowser.js';\nexport {\n mergeProps as _mergeProps,\n type NullToObject as _NullToObject,\n type TupleTypes as _TupleTypes,\n type UnionToIntersection as _UnionToIntersection,\n} from './utils/merge-props.js';\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,eAAkC;AAC3C;AAAA,EACgB;AAAA,OAET;AAIP,SAAS,uBAAuB;AAChC,SAA4B,uBAAwB;AACpD;AAAA,EACmB;AAAA,OAEZ;AAMP,SAAyB,oBAAqB;AAC9C,SAAiC,4BAA6B;AAC9D,SAAmC,8BAA+B;AAClE,SAAkC,6BAA8B;AAChE,SAAwB,mBAAoB;AAC5C,SAAsB,iBAAkB;AACxC;AAAA,EACgB;AAAA,OAIT;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,118 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
2
|
+
import { FocusContext } from "../contexts/FocusContext.js";
|
|
3
|
+
import { useFocusContext } from "../hooks/useFocusContext.js";
|
|
4
|
+
import { mergeProps } from "../utils/merge-props.js";
|
|
5
|
+
const ignoreMap = [
|
|
6
|
+
"Alt",
|
|
7
|
+
"AltGraph",
|
|
8
|
+
"CapsLock",
|
|
9
|
+
"Control",
|
|
10
|
+
"Fn",
|
|
11
|
+
"FnLock",
|
|
12
|
+
"Hyper",
|
|
13
|
+
"Meta",
|
|
14
|
+
// Command (Mac), in some browsers also Windows-key
|
|
15
|
+
"NumLock",
|
|
16
|
+
"OS",
|
|
17
|
+
// Windows-key
|
|
18
|
+
"ScrollLock",
|
|
19
|
+
"Super",
|
|
20
|
+
// Virtual keyboard key
|
|
21
|
+
"Symbol",
|
|
22
|
+
"SymbolLock"
|
|
23
|
+
];
|
|
24
|
+
const eventTypeMap = {
|
|
25
|
+
keydown: "keyboard",
|
|
26
|
+
keyup: "keyboard",
|
|
27
|
+
mousedown: "mouse",
|
|
28
|
+
mousemove: "mouse",
|
|
29
|
+
MSPointerDown: "pointer",
|
|
30
|
+
MSPointerMove: "pointer",
|
|
31
|
+
pointerdown: "pointer",
|
|
32
|
+
pointermove: "pointer",
|
|
33
|
+
touchstart: "touch",
|
|
34
|
+
touchend: "touch",
|
|
35
|
+
wheel: "wheel"
|
|
36
|
+
};
|
|
37
|
+
const navigationalKeys = [
|
|
38
|
+
"Tab",
|
|
39
|
+
"Esc",
|
|
40
|
+
"Escape",
|
|
41
|
+
" ",
|
|
42
|
+
"ArrowDown",
|
|
43
|
+
"Down",
|
|
44
|
+
"ArrowUp",
|
|
45
|
+
"Up",
|
|
46
|
+
"ArrowLeft",
|
|
47
|
+
"Left",
|
|
48
|
+
"ArrowRight",
|
|
49
|
+
"Right",
|
|
50
|
+
"End",
|
|
51
|
+
"Home",
|
|
52
|
+
"PageDown",
|
|
53
|
+
"PageUp"
|
|
54
|
+
];
|
|
55
|
+
const FocusProvider = ({ children }) => {
|
|
56
|
+
const [backgroundInertness, setBackgroundInertness] = useState(false);
|
|
57
|
+
const focusContext = useFocusContext();
|
|
58
|
+
const [modality, setModality] = useState("unknown");
|
|
59
|
+
const setKeyboardInputModality = useCallback((event) => {
|
|
60
|
+
if (ignoreMap.includes(event.key)) {
|
|
61
|
+
setModality("pointer");
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (!event.target || navigationalKeys.includes(event.key)) {
|
|
65
|
+
setModality("keyboard");
|
|
66
|
+
}
|
|
67
|
+
}, []);
|
|
68
|
+
const setMouseInputModality = useCallback((event) => {
|
|
69
|
+
switch (eventTypeMap[event.type]) {
|
|
70
|
+
case "touch":
|
|
71
|
+
case "pen":
|
|
72
|
+
return setModality("touch");
|
|
73
|
+
case "mouse":
|
|
74
|
+
case "pointer":
|
|
75
|
+
case "wheel":
|
|
76
|
+
return setModality("pointer");
|
|
77
|
+
default:
|
|
78
|
+
return "unknown";
|
|
79
|
+
}
|
|
80
|
+
}, []);
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
window.addEventListener("pointerdown", setMouseInputModality);
|
|
83
|
+
window.addEventListener("keydown", setKeyboardInputModality, {
|
|
84
|
+
capture: true
|
|
85
|
+
});
|
|
86
|
+
window.addEventListener("wheel", setMouseInputModality);
|
|
87
|
+
return () => {
|
|
88
|
+
window.removeEventListener("pointerdown", setMouseInputModality);
|
|
89
|
+
window.removeEventListener("keydown", setKeyboardInputModality, {
|
|
90
|
+
capture: true
|
|
91
|
+
});
|
|
92
|
+
window.removeEventListener("wheel", setMouseInputModality);
|
|
93
|
+
};
|
|
94
|
+
}, [setKeyboardInputModality, setMouseInputModality]);
|
|
95
|
+
const focusProps = backgroundInertness ? {
|
|
96
|
+
inert: "true",
|
|
97
|
+
tabIndex: -1,
|
|
98
|
+
"aria-hidden": true
|
|
99
|
+
} : { inert: void 0, tabIndex: void 0, "aria-hidden": false };
|
|
100
|
+
return /* @__PURE__ */ React.createElement(
|
|
101
|
+
FocusContext.Provider,
|
|
102
|
+
{
|
|
103
|
+
value: {
|
|
104
|
+
...mergeProps(focusContext, {
|
|
105
|
+
backgroundInertness,
|
|
106
|
+
setBackgroundInertness,
|
|
107
|
+
modality
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
/* @__PURE__ */ React.createElement("div", { ...focusProps }, children)
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
FocusProvider["displayName"] = "FocusProvider";
|
|
115
|
+
export {
|
|
116
|
+
FocusProvider
|
|
117
|
+
};
|
|
2
118
|
//# sourceMappingURL=FocusProvider.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/providers/FocusProvider.tsx"],
|
|
4
4
|
"sourcesContent": ["import React, { useCallback, useEffect, useState } from 'react';\n\nimport { FocusContext } from '../contexts/FocusContext.js';\nimport { useFocusContext } from '../hooks/useFocusContext.js';\nimport type { WithChildren } from '../types/with-children.js';\nimport { mergeProps } from '../utils/merge-props.js';\n\n// list of modifier keys commonly used in a mouse or keyboard combination,\n// see https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values#modifier_keys.\nconst ignoreMap = [\n 'Alt',\n 'AltGraph',\n 'CapsLock',\n 'Control',\n 'Fn',\n 'FnLock',\n 'Hyper',\n 'Meta', // Command (Mac), in some browsers also Windows-key\n 'NumLock',\n 'OS', // Windows-key\n 'ScrollLock',\n 'Super', // Virtual keyboard key\n 'Symbol',\n 'SymbolLock',\n];\n\n/** Look-up map of all event types and the corresponding modalities. */\nconst eventTypeMap: Record<string, string> = {\n keydown: 'keyboard',\n keyup: 'keyboard',\n mousedown: 'mouse',\n mousemove: 'mouse',\n MSPointerDown: 'pointer',\n MSPointerMove: 'pointer',\n pointerdown: 'pointer',\n pointermove: 'pointer',\n touchstart: 'touch',\n touchend: 'touch',\n wheel: 'wheel',\n};\n\n/**\n * @internal\n * Type defining the modality options for the focus handling.\n */\nexport type Modality = 'keyboard' | 'pointer' | 'touch' | 'unknown';\n\n/**\n * All navigational keys that should be considered keyboard users,\n * see https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values#navigation_keys\n */\nconst navigationalKeys = [\n 'Tab',\n 'Esc',\n 'Escape',\n ' ',\n 'ArrowDown',\n 'Down',\n 'ArrowUp',\n 'Up',\n 'ArrowLeft',\n 'Left',\n 'ArrowRight',\n 'Right',\n 'End',\n 'Home',\n 'PageDown',\n 'PageUp',\n];\n\n/**\n * @internal\n *\n * Provider that can be reused in components for storing the focus context props.\n * Loosely inspired by [what-input-js](https://github.com/ten1seven/what-input/blob/main/src/scripts/what-input.js).\n */\nexport const FocusProvider = ({ children }: WithChildren) => {\n const [backgroundInertness, setBackgroundInertness] = useState(false);\n const focusContext = useFocusContext();\n const [modality, setModality] = useState<Modality>('unknown');\n\n const setKeyboardInputModality = useCallback((event: KeyboardEvent) => {\n if (ignoreMap.includes(event.key)) {\n setModality('pointer');\n return;\n }\n\n if (!event.target || navigationalKeys.includes(event.key)) {\n setModality('keyboard');\n }\n }, []);\n\n const setMouseInputModality = useCallback((event: MouseEvent) => {\n switch (eventTypeMap[event.type]) {\n case 'touch':\n case 'pen':\n return setModality('touch');\n case 'mouse':\n case 'pointer':\n case 'wheel':\n return setModality('pointer');\n default:\n return 'unknown';\n }\n }, []);\n\n useEffect(() => {\n window.addEventListener('pointerdown', setMouseInputModality);\n // we need to rely on the keydown event (already in the capture phase) here so we don't break usages where the event default behavior is prevented or propagation is stopped,\n // which would otherwise get the wrong, initial, modality (unknown); by using the capture phase, we can ensure we set the modality correctly before the other events occur\n window.addEventListener('keydown', setKeyboardInputModality, {\n capture: true,\n });\n window.addEventListener('wheel', setMouseInputModality);\n\n return () => {\n window.removeEventListener('pointerdown', setMouseInputModality);\n window.removeEventListener('keydown', setKeyboardInputModality, {\n capture: true,\n });\n window.removeEventListener('wheel', setMouseInputModality);\n };\n }, [setKeyboardInputModality, setMouseInputModality]);\n\n const focusProps = backgroundInertness\n ? {\n inert: 'true',\n tabIndex: -1,\n 'aria-hidden': true,\n }\n : { inert: undefined, tabIndex: undefined, 'aria-hidden': false };\n\n return (\n <FocusContext.Provider\n value={{\n ...mergeProps(focusContext, {\n backgroundInertness,\n setBackgroundInertness,\n modality,\n }),\n }}\n >\n <div {...focusProps}>{children}</div>\n </FocusContext.Provider>\n );\n};\n\nFocusProvider['displayName'] = 'FocusProvider';\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,aAAa,WAAW,gBAAgB;AAExD,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAEhC,SAAS,kBAAkB;AAI3B,MAAM,YAAY;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AACF;AAGA,MAAM,eAAuC;AAAA,EAC3C,SAAS;AAAA,EACT,OAAO;AAAA,EACP,WAAW;AAAA,EACX,WAAW;AAAA,EACX,eAAe;AAAA,EACf,eAAe;AAAA,EACf,aAAa;AAAA,EACb,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,OAAO;AACT;AAYA,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAQO,MAAM,gBAAgB,CAAC,EAAE,SAAS,MAAoB;AAC3D,QAAM,CAAC,qBAAqB,sBAAsB,IAAI,SAAS,KAAK;AACpE,QAAM,eAAe,gBAAgB;AACrC,QAAM,CAAC,UAAU,WAAW,IAAI,SAAmB,SAAS;AAE5D,QAAM,2BAA2B,YAAY,CAAC,UAAyB;AACrE,QAAI,UAAU,SAAS,MAAM,GAAG,GAAG;AACjC,kBAAY,SAAS;AACrB;AAAA,IACF;AAEA,QAAI,CAAC,MAAM,UAAU,iBAAiB,SAAS,MAAM,GAAG,GAAG;AACzD,kBAAY,UAAU;AAAA,IACxB;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,wBAAwB,YAAY,CAAC,UAAsB;AAC/D,YAAQ,aAAa,MAAM,IAAI,GAAG;AAAA,MAChC,KAAK;AAAA,MACL,KAAK;AACH,eAAO,YAAY,OAAO;AAAA,MAC5B,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AACH,eAAO,YAAY,SAAS;AAAA,MAC9B;AACE,eAAO;AAAA,IACX;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACd,WAAO,iBAAiB,eAAe,qBAAqB;AAG5D,WAAO,iBAAiB,WAAW,0BAA0B;AAAA,MAC3D,SAAS;AAAA,IACX,CAAC;AACD,WAAO,iBAAiB,SAAS,qBAAqB;AAEtD,WAAO,MAAM;AACX,aAAO,oBAAoB,eAAe,qBAAqB;AAC/D,aAAO,oBAAoB,WAAW,0BAA0B;AAAA,QAC9D,SAAS;AAAA,MACX,CAAC;AACD,aAAO,oBAAoB,SAAS,qBAAqB;AAAA,IAC3D;AAAA,EACF,GAAG,CAAC,0BAA0B,qBAAqB,CAAC;AAEpD,QAAM,aAAa,sBACf;AAAA,IACE,OAAO;AAAA,IACP,UAAU;AAAA,IACV,eAAe;AAAA,EACjB,IACA,EAAE,OAAO,QAAW,UAAU,QAAW,eAAe,MAAM;AAElE,SACE;AAAA,IAAC,aAAa;AAAA,IAAb;AAAA,MACC,OAAO;AAAA,QACL,GAAG,WAAW,cAAc;AAAA,UAC1B;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA;AAAA,IAEA,oCAAC,SAAK,GAAG,cAAa,QAAS;AAAA,EACjC;AAEJ;AAEA,cAAc,aAAa,IAAI;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=masking-props.js.map
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
import{isFocusable
|
|
1
|
+
import { isFocusable } from "./is-focusable.js";
|
|
2
|
+
const attemptFocus = (element) => {
|
|
3
|
+
if (!isFocusable(element)) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
try {
|
|
7
|
+
element.focus({ preventScroll: true });
|
|
8
|
+
} catch (e) {
|
|
9
|
+
}
|
|
10
|
+
return document.activeElement === element;
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
attemptFocus
|
|
14
|
+
};
|
|
2
15
|
//# sourceMappingURL=attempt-focus.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/core/utils/focus-management/attempt-focus.ts"],
|
|
4
4
|
"sourcesContent": ["import { isFocusable } from './is-focusable.js';\n\n/**\n * @internal\n *\n * Set Attempt to set focus on the current node.\n * @param element - The node to attempt to focus on.\n * @returns - true if element is focused.\n */\nexport const attemptFocus = (element: HTMLElement) => {\n if (!isFocusable(element)) {\n return false;\n }\n\n try {\n element.focus({ preventScroll: true });\n } catch (e) {\n // continue regardless of error\n }\n\n return document.activeElement === element;\n};\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB;AASrB,MAAM,eAAe,CAAC,YAAyB;AACpD,MAAI,CAAC,YAAY,OAAO,GAAG;AACzB,WAAO;AAAA,EACT;AAEA,MAAI;AACF,YAAQ,MAAM,EAAE,eAAe,KAAK,CAAC;AAAA,EACvC,SAAS,GAAG;AAAA,EAEZ;AAEA,SAAO,SAAS,kBAAkB;AACpC;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
import{attemptFocus
|
|
1
|
+
import { attemptFocus } from "./attempt-focus.js";
|
|
2
|
+
const focusFirstDescendant = (element) => {
|
|
3
|
+
if (!element) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
for (let i = 0; i < element.children.length; i++) {
|
|
7
|
+
const child = element.children[i];
|
|
8
|
+
if (attemptFocus(child) || focusFirstDescendant(child)) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
focusFirstDescendant
|
|
16
|
+
};
|
|
2
17
|
//# sourceMappingURL=focus-first-descendant.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/core/utils/focus-management/focus-first-descendant.ts"],
|
|
4
4
|
"sourcesContent": ["import { attemptFocus } from './attempt-focus.js';\n\n/**\n * @internal\n *\n * Set focus on descendant nodes until the first focusable element is found.\n * @param element - DOM node for which to find the first focusable descendant.\n * @returns true if a focusable element is found and focus is set.\n */\nexport const focusFirstDescendant = (element: HTMLElement | null) => {\n if (!element) {\n return false;\n }\n\n for (let i = 0; i < element.children.length; i++) {\n const child = element.children[i] as HTMLElement;\n if (attemptFocus(child) || focusFirstDescendant(child)) {\n return true;\n }\n }\n\n return false;\n};\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAStB,MAAM,uBAAuB,CAAC,YAAgC;AACnE,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AAEA,WAAS,IAAI,GAAG,IAAI,QAAQ,SAAS,QAAQ,KAAK;AAChD,UAAM,QAAQ,QAAQ,SAAS,CAAC;AAChC,QAAI,aAAa,KAAK,KAAK,qBAAqB,KAAK,GAAG;AACtD,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
import{isFocusable
|
|
1
|
+
import { isFocusable } from "./is-focusable.js";
|
|
2
|
+
function getFirstFocusableChild(container) {
|
|
3
|
+
const treeWalker = document.createTreeWalker(container);
|
|
4
|
+
while (treeWalker.nextNode()) {
|
|
5
|
+
if (isFocusable(treeWalker.currentNode)) {
|
|
6
|
+
return treeWalker.currentNode;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
getFirstFocusableChild
|
|
13
|
+
};
|
|
2
14
|
//# sourceMappingURL=get-first-focusable-child.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/core/utils/focus-management/get-first-focusable-child.ts"],
|
|
4
4
|
"sourcesContent": ["import { isFocusable } from './is-focusable.js';\n\n/**\n * @internal\n *\n * If you need access to the first focusable descendant of a container, you can use\n * `getFirstFocusableChild`. The function uses the\n * https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker to\n * iterate over the children of the container and returns either a `Node` if a\n * focusable element is found, or `null`.\n */\nexport function getFirstFocusableChild(\n container: HTMLElement | Node,\n): Node | null {\n const treeWalker = document.createTreeWalker(container);\n\n // Iterate over all the nodes inside the container and return the current node if it is focusable.\n while (treeWalker.nextNode()) {\n if (isFocusable(treeWalker.currentNode)) {\n return treeWalker.currentNode;\n }\n }\n\n return null;\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAWrB,SAAS,uBACd,WACa;AACb,QAAM,aAAa,SAAS,iBAAiB,SAAS;AAGtD,SAAO,WAAW,SAAS,GAAG;AAC5B,QAAI,YAAY,WAAW,WAAW,GAAG;AACvC,aAAO,WAAW;AAAA,IACpB;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
import{isFocusable
|
|
1
|
+
import { isFocusable } from "./is-focusable.js";
|
|
2
|
+
function getLastFocusableChild(container) {
|
|
3
|
+
const treeWalker = document.createTreeWalker(container);
|
|
4
|
+
while (treeWalker.lastChild()) {
|
|
5
|
+
treeWalker.lastChild();
|
|
6
|
+
}
|
|
7
|
+
do {
|
|
8
|
+
if (isFocusable(treeWalker.currentNode)) {
|
|
9
|
+
return treeWalker.currentNode;
|
|
10
|
+
}
|
|
11
|
+
} while (treeWalker.previousNode());
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
getLastFocusableChild
|
|
16
|
+
};
|
|
2
17
|
//# sourceMappingURL=get-last-focusable-child.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/core/utils/focus-management/get-last-focusable-child.ts"],
|
|
4
4
|
"sourcesContent": ["import { isFocusable } from './is-focusable.js';\n\n/**\n * @internal\n *\n * If you need access to the last focusable descendant of a container, you can use\n * `getLastFocusableChild`. The function uses the\n * https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker to\n * iterate over the children of the container and returns either a `Node` if a\n * focusable element is found, or `null`.\n */\nexport function getLastFocusableChild(container: HTMLElement): Node | null {\n const treeWalker = document.createTreeWalker(container);\n\n // Move the current node to the last node of the container.\n while (treeWalker.lastChild()) {\n treeWalker.lastChild();\n }\n\n // Iterate backwards over all the nodes inside the container and return the current node if it is focusable.\n do {\n if (isFocusable(treeWalker.currentNode)) {\n return treeWalker.currentNode;\n }\n } while (treeWalker.previousNode());\n\n return null;\n}\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAWrB,SAAS,sBAAsB,WAAqC;AACzE,QAAM,aAAa,SAAS,iBAAiB,SAAS;AAGtD,SAAO,WAAW,UAAU,GAAG;AAC7B,eAAW,UAAU;AAAA,EACvB;AAGA,KAAG;AACD,QAAI,YAAY,WAAW,WAAW,GAAG;AACvC,aAAO,WAAW;AAAA,IACpB;AAAA,EACF,SAAS,WAAW,aAAa;AAEjC,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,21 @@
|
|
|
1
|
-
function
|
|
1
|
+
function isFocusable(element) {
|
|
2
|
+
if (element.tabIndex < 0 || element.disabled) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
switch (element.nodeName) {
|
|
6
|
+
case "A":
|
|
7
|
+
return !!element.href;
|
|
8
|
+
case "INPUT":
|
|
9
|
+
return element.type !== "hidden";
|
|
10
|
+
case "BUTTON":
|
|
11
|
+
case "SELECT":
|
|
12
|
+
case "TEXTAREA":
|
|
13
|
+
return true;
|
|
14
|
+
default:
|
|
15
|
+
return element.tabIndex >= 0;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
isFocusable
|
|
20
|
+
};
|
|
2
21
|
//# sourceMappingURL=is-focusable.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/core/utils/focus-management/is-focusable.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * @internal\n *\n * Use the `isFocusable` utility function to check whether an element can receive\n * focus.\n */\nexport function isFocusable(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n element: any,\n) {\n if (element.tabIndex < 0 || element.disabled) {\n return false;\n }\n\n switch (element.nodeName) {\n case 'A':\n return !!element.href;\n case 'INPUT':\n return element.type !== 'hidden';\n case 'BUTTON':\n case 'SELECT':\n case 'TEXTAREA':\n return true;\n default:\n return element.tabIndex >= 0;\n }\n}\n"],
|
|
5
|
-
"mappings": "AAMO,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAMO,SAAS,YAEd,SACA;AACA,MAAI,QAAQ,WAAW,KAAK,QAAQ,UAAU;AAC5C,WAAO;AAAA,EACT;AAEA,UAAQ,QAAQ,UAAU;AAAA,IACxB,KAAK;AACH,aAAO,CAAC,CAAC,QAAQ;AAAA,IACnB,KAAK;AACH,aAAO,QAAQ,SAAS;AAAA,IAC1B,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO,QAAQ,YAAY;AAAA,EAC/B;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const isBrowser = (() => {
|
|
2
|
+
return !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
3
|
+
})();
|
|
4
|
+
export {
|
|
5
|
+
isBrowser
|
|
6
|
+
};
|
|
2
7
|
//# sourceMappingURL=isBrowser.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/utils/isBrowser.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * @internal\n *\n * Whether the code is currently executed in a browser\n * @see https://github.com/chakra-ui/chakra-ui/blob/main/packages/utils/src/dom.ts\n */\nexport const isBrowser = (() => {\n return !!(\n typeof window !== 'undefined' &&\n window.document &&\n window.document.createElement\n );\n})();\n"],
|
|
5
|
-
"mappings": "AAMO,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAMO,MAAM,aAAa,MAAM;AAC9B,SAAO,CAAC,EACN,OAAO,WAAW,eAClB,OAAO,YACP,OAAO,SAAS;AAEpB,GAAG;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,32 @@
|
|
|
1
|
-
function
|
|
1
|
+
function chain(...callbacks) {
|
|
2
|
+
return (...args) => {
|
|
3
|
+
for (const callback of callbacks) {
|
|
4
|
+
if (typeof callback === "function") {
|
|
5
|
+
callback(...args);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function mergeProps(...args) {
|
|
11
|
+
const result = { ...args[0] };
|
|
12
|
+
for (let i = 1; i < args.length; i++) {
|
|
13
|
+
const props = args[i];
|
|
14
|
+
for (const key in props) {
|
|
15
|
+
const a = result[key];
|
|
16
|
+
const b = props[key];
|
|
17
|
+
if (typeof a === "function" && typeof b === "function" && // This is a lot faster than a regex.
|
|
18
|
+
key[0] === "o" && key[1] === "n" && key.charCodeAt(2) >= /* 'A' */
|
|
19
|
+
65 && key.charCodeAt(2) <= /* 'Z' */
|
|
20
|
+
90) {
|
|
21
|
+
result[key] = chain(a, b);
|
|
22
|
+
} else {
|
|
23
|
+
result[key] = b !== void 0 ? b : a;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
mergeProps
|
|
31
|
+
};
|
|
2
32
|
//# sourceMappingURL=merge-props.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/utils/merge-props.ts"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Calls all functions in the order they were chained with the same arguments.\n */\nfunction chain(...callbacks: any[]): (...args: any[]) => void {\n return (...args: any[]) => {\n for (const callback of callbacks) {\n if (typeof callback === 'function') {\n callback(...args);\n }\n }\n };\n}\n\n// taken from: https://stackoverflow.com/questions/51603250/typescript-3-parameter-list-intersection-type/51604379#51604379\n/**\n * @internal\n * Internal helper mapper type for mergeProps\n */\nexport type TupleTypes<T> = { [P in keyof T]: T[P] } extends {\n [key: number]: infer V;\n}\n ? NullToObject<V>\n : never;\n\n/**\n * @internal\n * Internal helper mapper type for mergeProps\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type NullToObject<T> = T extends null | undefined ? {} : T;\n\n/**\n * @internal\n * Internal helper mapper type for mergeProps\n */\n// eslint-disable-next-line no-undef, @typescript-eslint/no-unused-vars\nexport type UnionToIntersection<U> = (\n U extends any ? (k: U) => void : never\n) extends (k: infer I) => void\n ? I\n : never;\n\n/**\n * @internal\n *\n * Merges multiple props objects together. Event handlers are chained,\n * classNames are combined, and ids are deduplicated - different ids\n * will trigger a side-effect and re-render components hooked up with `useId`.\n * For all other props, the last prop object overrides all previous ones.\n * @param args - Multiple sets of props to merge together.\n */\nexport function mergeProps<\n T extends (\n | {\n [key: string]: any;\n }\n | null\n | undefined\n )[],\n>(...args: T): UnionToIntersection<TupleTypes<T>> {\n // Start with a base clone of the first argument. This is a lot faster than starting\n // with an empty object and adding properties as we go.\n const result = { ...args[0] };\n for (let i = 1; i < args.length; i++) {\n const props = args[i];\n for (const key in props) {\n const a = result[key];\n const b = props[key];\n\n // Chain events\n if (\n typeof a === 'function' &&\n typeof b === 'function' &&\n // This is a lot faster than a regex.\n key[0] === 'o' &&\n key[1] === 'n' &&\n key.charCodeAt(2) >= /* 'A' */ 65 &&\n key.charCodeAt(2) <= /* 'Z' */ 90\n ) {\n result[key] = chain(a, b);\n } else {\n result[key] = b !== undefined ? b : a;\n }\n }\n }\n\n return result as UnionToIntersection<TupleTypes<T>>;\n}\n"],
|
|
5
|
-
"mappings": "AAKA,
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": "AAKA,SAAS,SAAS,WAA4C;AAC5D,SAAO,IAAI,SAAgB;AACzB,eAAW,YAAY,WAAW;AAChC,UAAI,OAAO,aAAa,YAAY;AAClC,iBAAS,GAAG,IAAI;AAAA,MAClB;AAAA,IACF;AAAA,EACF;AACF;AAwCO,SAAS,cAQX,MAA6C;AAGhD,QAAM,SAAS,EAAE,GAAG,KAAK,CAAC,EAAE;AAC5B,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,QAAQ,KAAK,CAAC;AACpB,eAAW,OAAO,OAAO;AACvB,YAAM,IAAI,OAAO,GAAG;AACpB,YAAM,IAAI,MAAM,GAAG;AAGnB,UACE,OAAO,MAAM,cACb,OAAO,MAAM;AAAA,MAEb,IAAI,CAAC,MAAM,OACX,IAAI,CAAC,MAAM,OACX,IAAI,WAAW,CAAC;AAAA,MAAe,MAC/B,IAAI,WAAW,CAAC;AAAA,MAAe,IAC/B;AACA,eAAO,GAAG,IAAI,MAAM,GAAG,CAAC;AAAA,MAC1B,OAAO;AACL,eAAO,GAAG,IAAI,MAAM,SAAY,IAAI;AAAA,MACtC;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export*from"./core/index.js";
|
|
1
|
+
export * from "./core/index.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|