@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
|
@@ -2,16 +2,21 @@ import React, { type PropsWithChildren } from 'react';
|
|
|
2
2
|
import 'wicg-inert';
|
|
3
3
|
import './AppRoot.css.js';
|
|
4
4
|
import { type DataTestId } from '../../types/data-props.js';
|
|
5
|
+
import { type MaskingProps } from '../../types/masking-props.js';
|
|
5
6
|
import { type StylingProps } from '../../types/styling-props.js';
|
|
6
|
-
/** AppRoot component props. */
|
|
7
|
-
export type AppRootProps = PropsWithChildren<DataTestId & StylingProps>;
|
|
8
7
|
/**
|
|
8
|
+
* @public
|
|
9
|
+
* AppRoot component props.
|
|
10
|
+
*/
|
|
11
|
+
export type AppRootProps = PropsWithChildren<DataTestId & StylingProps & MaskingProps>;
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
9
14
|
* In order to have all the providers in place for rendering overlays, applying
|
|
10
15
|
* global styles or internationalization, you need to wrap your app in the
|
|
11
16
|
* `AppRoot`. If you're using the `dt-app` to create your app, this is
|
|
12
17
|
* automatically taken care of and you can start working on your app without
|
|
13
18
|
* further ado.
|
|
14
19
|
*/
|
|
15
|
-
export declare const AppRoot: React.ForwardRefExoticComponent<DataTestId & StylingProps & {
|
|
20
|
+
export declare const AppRoot: React.ForwardRefExoticComponent<DataTestId & StylingProps & MaskingProps & {
|
|
16
21
|
children?: React.ReactNode;
|
|
17
22
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1,116 @@
|
|
|
1
|
-
var
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var AppRoot_exports = {};
|
|
29
|
+
__export(AppRoot_exports, {
|
|
30
|
+
AppRoot: () => AppRoot
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(AppRoot_exports);
|
|
33
|
+
var import_lodash_es = require("lodash");
|
|
34
|
+
var import_react = __toESM(require("react"));
|
|
35
|
+
var import_react_intl = require("react-intl");
|
|
36
|
+
var import_wicg_inert = require("wicg-inert");
|
|
37
|
+
var import_user_preferences = require("@dynatrace-sdk/user-preferences");
|
|
38
|
+
var import_AppRoot_css = require("./AppRoot.sty.js");
|
|
39
|
+
var import_useCurrentTheme = require("../../hooks/useCurrentTheme.js");
|
|
40
|
+
var import_FocusProvider = require("../../providers/FocusProvider.js");
|
|
41
|
+
function getBaseHref() {
|
|
42
|
+
const baseElement = document.querySelector("base");
|
|
43
|
+
const href = baseElement?.href ?? "/";
|
|
44
|
+
return href.endsWith("/") ? href : `${href}/`;
|
|
45
|
+
}
|
|
46
|
+
const defaultLanguage = "en";
|
|
47
|
+
const AppRoot = /* @__PURE__ */ (0, import_react.forwardRef)(
|
|
48
|
+
(props, forwardedRef) => {
|
|
49
|
+
const {
|
|
50
|
+
style: consumerStyle,
|
|
51
|
+
className: consumerClassName,
|
|
52
|
+
"data-testid": dataTestId = "app-root",
|
|
53
|
+
"data-dtrum-mask": dataDtrumMask,
|
|
54
|
+
"data-dtrum-allow": dataDtrumAllow
|
|
55
|
+
} = props;
|
|
56
|
+
const [messages, setMessages] = (0, import_react.useState)({});
|
|
57
|
+
const { children } = props;
|
|
58
|
+
const theme = (0, import_useCurrentTheme.useCurrentTheme)();
|
|
59
|
+
const language = (0, import_user_preferences.getLanguage)();
|
|
60
|
+
let timezone = (0, import_user_preferences.getTimezone)();
|
|
61
|
+
try {
|
|
62
|
+
new Intl.DateTimeFormat(language, { timeZone: timezone });
|
|
63
|
+
} catch (error) {
|
|
64
|
+
timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
65
|
+
}
|
|
66
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
67
|
+
const link = document.createElement("link");
|
|
68
|
+
link.rel = "stylesheet";
|
|
69
|
+
link.href = "https://dt-cdn.net/fonts/fonts-v004.css";
|
|
70
|
+
document.head.appendChild(link);
|
|
71
|
+
return () => {
|
|
72
|
+
document.head.removeChild(link);
|
|
73
|
+
};
|
|
74
|
+
}, []);
|
|
75
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
76
|
+
if (document !== void 0) {
|
|
77
|
+
document.documentElement.setAttribute("data-theme", theme);
|
|
78
|
+
}
|
|
79
|
+
}, [theme]);
|
|
80
|
+
(0, import_react.useEffect)(() => {
|
|
81
|
+
if (language === "en") {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
fetch(`${getBaseHref()}lang/${language}.json`).then((res) => {
|
|
85
|
+
return res.json();
|
|
86
|
+
}).then((receivedMessages) => {
|
|
87
|
+
setMessages(receivedMessages);
|
|
88
|
+
}).catch(() => {
|
|
89
|
+
setMessages((prev) => (0, import_lodash_es.isEmpty)(prev) ? prev : {});
|
|
90
|
+
});
|
|
91
|
+
}, [language]);
|
|
92
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
93
|
+
"div",
|
|
94
|
+
{
|
|
95
|
+
ref: forwardedRef,
|
|
96
|
+
"data-testid": dataTestId,
|
|
97
|
+
className: consumerClassName,
|
|
98
|
+
style: consumerStyle,
|
|
99
|
+
"data-theme": theme,
|
|
100
|
+
"data-dtrum-mask": dataDtrumMask,
|
|
101
|
+
"data-dtrum-allow": dataDtrumAllow
|
|
102
|
+
},
|
|
103
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
104
|
+
import_react_intl.IntlProvider,
|
|
105
|
+
{
|
|
106
|
+
locale: language,
|
|
107
|
+
timeZone: timezone,
|
|
108
|
+
messages,
|
|
109
|
+
defaultLocale: defaultLanguage
|
|
110
|
+
},
|
|
111
|
+
/* @__PURE__ */ import_react.default.createElement(import_FocusProvider.FocusProvider, null, children)
|
|
112
|
+
)
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
AppRoot.displayName = "AppRoot";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var import_AppRoot_css_ts_vanilla = require("./AppRoot.css");
|
|
@@ -1 +1,81 @@
|
|
|
1
|
-
var
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var FocusScope_exports = {};
|
|
29
|
+
__export(FocusScope_exports, {
|
|
30
|
+
FocusScope: () => FocusScope
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(FocusScope_exports);
|
|
33
|
+
var import_react = __toESM(require("react"));
|
|
34
|
+
var import_useActiveElement = require("../../hooks/useActiveElement.js");
|
|
35
|
+
var import_useFocusContext = require("../../hooks/useFocusContext.js");
|
|
36
|
+
var import_focus_first_descendant = require("../../utils/focus-management/focus-first-descendant.js");
|
|
37
|
+
const FocusScope = (props) => {
|
|
38
|
+
const { autoFocus, contain, children } = props;
|
|
39
|
+
const focusContext = (0, import_useFocusContext.useFocusContext)();
|
|
40
|
+
const wrapperRef = (0, import_react.useRef)(null);
|
|
41
|
+
const focusedElement = (0, import_useActiveElement.useActiveElement)();
|
|
42
|
+
const triggerElement = (0, import_react.useRef)(focusedElement);
|
|
43
|
+
(0, import_react.useEffect)(() => {
|
|
44
|
+
if (contain || autoFocus) {
|
|
45
|
+
(0, import_focus_first_descendant.focusFirstDescendant)(wrapperRef.current);
|
|
46
|
+
}
|
|
47
|
+
if (contain) {
|
|
48
|
+
focusContext.setBackgroundInertness(true);
|
|
49
|
+
const triggerElementCopy2 = triggerElement.current;
|
|
50
|
+
return () => {
|
|
51
|
+
focusContext.setBackgroundInertness(false);
|
|
52
|
+
window.setTimeout(() => triggerElementCopy2.focus(), 0);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (!autoFocus && !contain) {
|
|
56
|
+
document.addEventListener("keydown", (e) => {
|
|
57
|
+
if (e.key !== "Tab") {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (e.target === triggerElement.current) {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
(0, import_focus_first_descendant.focusFirstDescendant)(wrapperRef.current);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const triggerElementCopy = triggerElement.current;
|
|
67
|
+
return () => {
|
|
68
|
+
triggerElementCopy.focus();
|
|
69
|
+
};
|
|
70
|
+
}, [contain, autoFocus]);
|
|
71
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
style: { display: "contents" },
|
|
75
|
+
ref: wrapperRef,
|
|
76
|
+
"aria-labelledby": triggerElement.current.id
|
|
77
|
+
},
|
|
78
|
+
children
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
FocusScope.displayName = "FocusScope";
|
|
@@ -1 +1,28 @@
|
|
|
1
|
-
var
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var FocusContext_exports = {};
|
|
19
|
+
__export(FocusContext_exports, {
|
|
20
|
+
FocusContext: () => FocusContext
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(FocusContext_exports);
|
|
23
|
+
var import_react = require("react");
|
|
24
|
+
const FocusContext = (0, import_react.createContext)({
|
|
25
|
+
modality: "unknown",
|
|
26
|
+
backgroundInertness: void 0,
|
|
27
|
+
setBackgroundInertness: (value) => null
|
|
28
|
+
});
|
|
@@ -1 +1,36 @@
|
|
|
1
|
-
var
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var useActiveElement_exports = {};
|
|
19
|
+
__export(useActiveElement_exports, {
|
|
20
|
+
useActiveElement: () => useActiveElement
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(useActiveElement_exports);
|
|
23
|
+
var import_react = require("react");
|
|
24
|
+
const useActiveElement = () => {
|
|
25
|
+
const [active, setActive] = (0, import_react.useState)(document.activeElement);
|
|
26
|
+
const handleFocusIn = (e) => {
|
|
27
|
+
setActive(document.activeElement);
|
|
28
|
+
};
|
|
29
|
+
(0, import_react.useEffect)(() => {
|
|
30
|
+
document.addEventListener("focusin", handleFocusIn);
|
|
31
|
+
return () => {
|
|
32
|
+
document.removeEventListener("focusin", handleFocusIn);
|
|
33
|
+
};
|
|
34
|
+
}, []);
|
|
35
|
+
return active;
|
|
36
|
+
};
|
|
@@ -1 +1,54 @@
|
|
|
1
|
-
var
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var useCurrentTheme_exports = {};
|
|
19
|
+
__export(useCurrentTheme_exports, {
|
|
20
|
+
useCurrentTheme: () => useCurrentTheme
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(useCurrentTheme_exports);
|
|
23
|
+
var import_react = require("react");
|
|
24
|
+
var import_user_preferences = require("@dynatrace-sdk/user-preferences");
|
|
25
|
+
var import_isBrowser = require("../utils/isBrowser.js");
|
|
26
|
+
function useCurrentTheme() {
|
|
27
|
+
const sdkTheme = (0, import_react.useMemo)(() => {
|
|
28
|
+
return (0, import_user_preferences.getTheme)();
|
|
29
|
+
}, []);
|
|
30
|
+
if (sdkTheme === "dark" || sdkTheme === "light") {
|
|
31
|
+
return sdkTheme;
|
|
32
|
+
}
|
|
33
|
+
if (!import_isBrowser.isBrowser) {
|
|
34
|
+
return "light";
|
|
35
|
+
}
|
|
36
|
+
const themeQuery = (0, import_react.useMemo)(
|
|
37
|
+
() => window && window.matchMedia("(prefers-color-scheme: dark)"),
|
|
38
|
+
[]
|
|
39
|
+
);
|
|
40
|
+
const [currentTheme, setCurrentTheme] = (0, import_react.useState)(
|
|
41
|
+
themeQuery.matches ? "dark" : "light"
|
|
42
|
+
);
|
|
43
|
+
(0, import_react.useEffect)(() => {
|
|
44
|
+
const handlePrefersColorSchemeChange = () => {
|
|
45
|
+
const prefersDark = themeQuery.matches;
|
|
46
|
+
setCurrentTheme(prefersDark ? "dark" : "light");
|
|
47
|
+
};
|
|
48
|
+
themeQuery.addEventListener("change", handlePrefersColorSchemeChange);
|
|
49
|
+
return () => {
|
|
50
|
+
themeQuery.removeEventListener("change", handlePrefersColorSchemeChange);
|
|
51
|
+
};
|
|
52
|
+
}, [themeQuery]);
|
|
53
|
+
return currentTheme;
|
|
54
|
+
}
|
|
@@ -1 +1,27 @@
|
|
|
1
|
-
var
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var useFocusContext_exports = {};
|
|
19
|
+
__export(useFocusContext_exports, {
|
|
20
|
+
useFocusContext: () => useFocusContext
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(useFocusContext_exports);
|
|
23
|
+
var import_react = require("react");
|
|
24
|
+
var import_FocusContext = require("../contexts/FocusContext.js");
|
|
25
|
+
const useFocusContext = () => {
|
|
26
|
+
return (0, import_react.useContext)(import_FocusContext.FocusContext);
|
|
27
|
+
};
|
package/core/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { type FocusContextProps as _FocusContextProps } from './contexts/FocusCo
|
|
|
4
4
|
export { useCurrentTheme } from './hooks/useCurrentTheme.js';
|
|
5
5
|
export { useFocusContext as _useFocusContext } from './hooks/useFocusContext.js';
|
|
6
6
|
export { FocusProvider as _FocusProvider, type Modality as _Modality, } from './providers/FocusProvider.js';
|
|
7
|
+
export type { MaskingProps } from './types/masking-props.js';
|
|
7
8
|
export type { DataTestId } from './types/data-props.js';
|
|
8
9
|
export type { StylingProps } from './types/styling-props.js';
|
|
9
10
|
export type { WithChildren } from './types/with-children.js';
|
package/core/index.js
CHANGED
|
@@ -1 +1,45 @@
|
|
|
1
|
-
var
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var core_exports = {};
|
|
19
|
+
__export(core_exports, {
|
|
20
|
+
AppRoot: () => import_AppRoot.AppRoot,
|
|
21
|
+
_FocusProvider: () => import_FocusProvider.FocusProvider,
|
|
22
|
+
_FocusScope: () => import_FocusScope.FocusScope,
|
|
23
|
+
_attemptFocus: () => import_attempt_focus.attemptFocus,
|
|
24
|
+
_focusFirstDescendant: () => import_focus_first_descendant.focusFirstDescendant,
|
|
25
|
+
_getFirstFocusableChild: () => import_get_first_focusable_child.getFirstFocusableChild,
|
|
26
|
+
_getLastFocusableChild: () => import_get_last_focusable_child.getLastFocusableChild,
|
|
27
|
+
_isBrowser: () => import_isBrowser.isBrowser,
|
|
28
|
+
_isFocusable: () => import_is_focusable.isFocusable,
|
|
29
|
+
_mergeProps: () => import_merge_props.mergeProps,
|
|
30
|
+
_useFocusContext: () => import_useFocusContext.useFocusContext,
|
|
31
|
+
useCurrentTheme: () => import_useCurrentTheme.useCurrentTheme
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(core_exports);
|
|
34
|
+
var import_AppRoot = require("./components/app-root/AppRoot.js");
|
|
35
|
+
var import_FocusScope = require("./components/focus-scope/FocusScope.js");
|
|
36
|
+
var import_useCurrentTheme = require("./hooks/useCurrentTheme.js");
|
|
37
|
+
var import_useFocusContext = require("./hooks/useFocusContext.js");
|
|
38
|
+
var import_FocusProvider = require("./providers/FocusProvider.js");
|
|
39
|
+
var import_attempt_focus = require("./utils/focus-management/attempt-focus.js");
|
|
40
|
+
var import_focus_first_descendant = require("./utils/focus-management/focus-first-descendant.js");
|
|
41
|
+
var import_get_first_focusable_child = require("./utils/focus-management/get-first-focusable-child.js");
|
|
42
|
+
var import_get_last_focusable_child = require("./utils/focus-management/get-last-focusable-child.js");
|
|
43
|
+
var import_is_focusable = require("./utils/focus-management/is-focusable.js");
|
|
44
|
+
var import_isBrowser = require("./utils/isBrowser.js");
|
|
45
|
+
var import_merge_props = require("./utils/merge-props.js");
|
|
@@ -1 +1,146 @@
|
|
|
1
|
-
var
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var FocusProvider_exports = {};
|
|
29
|
+
__export(FocusProvider_exports, {
|
|
30
|
+
FocusProvider: () => FocusProvider
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(FocusProvider_exports);
|
|
33
|
+
var import_react = __toESM(require("react"));
|
|
34
|
+
var import_FocusContext = require("../contexts/FocusContext.js");
|
|
35
|
+
var import_useFocusContext = require("../hooks/useFocusContext.js");
|
|
36
|
+
var import_merge_props = require("../utils/merge-props.js");
|
|
37
|
+
const ignoreMap = [
|
|
38
|
+
"Alt",
|
|
39
|
+
"AltGraph",
|
|
40
|
+
"CapsLock",
|
|
41
|
+
"Control",
|
|
42
|
+
"Fn",
|
|
43
|
+
"FnLock",
|
|
44
|
+
"Hyper",
|
|
45
|
+
"Meta",
|
|
46
|
+
// Command (Mac), in some browsers also Windows-key
|
|
47
|
+
"NumLock",
|
|
48
|
+
"OS",
|
|
49
|
+
// Windows-key
|
|
50
|
+
"ScrollLock",
|
|
51
|
+
"Super",
|
|
52
|
+
// Virtual keyboard key
|
|
53
|
+
"Symbol",
|
|
54
|
+
"SymbolLock"
|
|
55
|
+
];
|
|
56
|
+
const eventTypeMap = {
|
|
57
|
+
keydown: "keyboard",
|
|
58
|
+
keyup: "keyboard",
|
|
59
|
+
mousedown: "mouse",
|
|
60
|
+
mousemove: "mouse",
|
|
61
|
+
MSPointerDown: "pointer",
|
|
62
|
+
MSPointerMove: "pointer",
|
|
63
|
+
pointerdown: "pointer",
|
|
64
|
+
pointermove: "pointer",
|
|
65
|
+
touchstart: "touch",
|
|
66
|
+
touchend: "touch",
|
|
67
|
+
wheel: "wheel"
|
|
68
|
+
};
|
|
69
|
+
const navigationalKeys = [
|
|
70
|
+
"Tab",
|
|
71
|
+
"Esc",
|
|
72
|
+
"Escape",
|
|
73
|
+
" ",
|
|
74
|
+
"ArrowDown",
|
|
75
|
+
"Down",
|
|
76
|
+
"ArrowUp",
|
|
77
|
+
"Up",
|
|
78
|
+
"ArrowLeft",
|
|
79
|
+
"Left",
|
|
80
|
+
"ArrowRight",
|
|
81
|
+
"Right",
|
|
82
|
+
"End",
|
|
83
|
+
"Home",
|
|
84
|
+
"PageDown",
|
|
85
|
+
"PageUp"
|
|
86
|
+
];
|
|
87
|
+
const FocusProvider = ({ children }) => {
|
|
88
|
+
const [backgroundInertness, setBackgroundInertness] = (0, import_react.useState)(false);
|
|
89
|
+
const focusContext = (0, import_useFocusContext.useFocusContext)();
|
|
90
|
+
const [modality, setModality] = (0, import_react.useState)("unknown");
|
|
91
|
+
const setKeyboardInputModality = (0, import_react.useCallback)((event) => {
|
|
92
|
+
if (ignoreMap.includes(event.key)) {
|
|
93
|
+
setModality("pointer");
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (!event.target || navigationalKeys.includes(event.key)) {
|
|
97
|
+
setModality("keyboard");
|
|
98
|
+
}
|
|
99
|
+
}, []);
|
|
100
|
+
const setMouseInputModality = (0, import_react.useCallback)((event) => {
|
|
101
|
+
switch (eventTypeMap[event.type]) {
|
|
102
|
+
case "touch":
|
|
103
|
+
case "pen":
|
|
104
|
+
return setModality("touch");
|
|
105
|
+
case "mouse":
|
|
106
|
+
case "pointer":
|
|
107
|
+
case "wheel":
|
|
108
|
+
return setModality("pointer");
|
|
109
|
+
default:
|
|
110
|
+
return "unknown";
|
|
111
|
+
}
|
|
112
|
+
}, []);
|
|
113
|
+
(0, import_react.useEffect)(() => {
|
|
114
|
+
window.addEventListener("pointerdown", setMouseInputModality);
|
|
115
|
+
window.addEventListener("keydown", setKeyboardInputModality, {
|
|
116
|
+
capture: true
|
|
117
|
+
});
|
|
118
|
+
window.addEventListener("wheel", setMouseInputModality);
|
|
119
|
+
return () => {
|
|
120
|
+
window.removeEventListener("pointerdown", setMouseInputModality);
|
|
121
|
+
window.removeEventListener("keydown", setKeyboardInputModality, {
|
|
122
|
+
capture: true
|
|
123
|
+
});
|
|
124
|
+
window.removeEventListener("wheel", setMouseInputModality);
|
|
125
|
+
};
|
|
126
|
+
}, [setKeyboardInputModality, setMouseInputModality]);
|
|
127
|
+
const focusProps = backgroundInertness ? {
|
|
128
|
+
inert: "true",
|
|
129
|
+
tabIndex: -1,
|
|
130
|
+
"aria-hidden": true
|
|
131
|
+
} : { inert: void 0, tabIndex: void 0, "aria-hidden": false };
|
|
132
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
133
|
+
import_FocusContext.FocusContext.Provider,
|
|
134
|
+
{
|
|
135
|
+
value: {
|
|
136
|
+
...(0, import_merge_props.mergeProps)(focusContext, {
|
|
137
|
+
backgroundInertness,
|
|
138
|
+
setBackgroundInertness,
|
|
139
|
+
modality
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
/* @__PURE__ */ import_react.default.createElement("div", { ...focusProps }, children)
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
FocusProvider["displayName"] = "FocusProvider";
|
package/core/types/data-props.js
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
var
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var data_props_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(data_props_exports);
|