@dynatrace/strato-components 0.85.21 → 0.85.41
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/buttons/button/Button.d.ts +4 -4
- package/buttons/button/Button.js +7 -3
- package/buttons/button/Label.d.ts +1 -1
- package/buttons/button/Prefix.d.ts +1 -1
- package/buttons/button/Suffix.d.ts +1 -1
- package/buttons/intent-button/IntentButton.d.ts +1 -1
- package/content/progress/ProgressBar.d.ts +4 -4
- package/content/progress/ProgressBarIcon.d.ts +1 -1
- package/content/progress/ProgressBarLabel.d.ts +1 -1
- package/content/progress/ProgressBarValue.d.ts +1 -1
- package/content/progress/ProgressCircle.d.ts +1 -1
- package/content/skeleton/Skeleton.d.ts +1 -1
- package/content/skeleton/SkeletonText.d.ts +1 -1
- package/core/components/app-root/AppRoot.d.ts +3 -3
- package/core/components/focus-scope/FocusScope.d.ts +1 -1
- package/core/contexts/FocusContext.d.ts +1 -2
- package/core/index.d.ts +1 -0
- package/core/index.js +2 -0
- package/core/providers/FocusProvider.d.ts +2 -3
- package/core/utils/parse-boolean.d.ts +9 -0
- package/core/utils/parse-boolean.js +31 -0
- package/esm/buttons/button/Button.js +7 -3
- package/esm/buttons/button/Button.js.map +2 -2
- package/esm/core/components/app-root/AppRoot.js.map +2 -2
- package/esm/core/components/focus-scope/FocusScope.js.map +1 -1
- package/esm/core/contexts/FocusContext.js.map +2 -2
- package/esm/core/index.js +2 -0
- package/esm/core/index.js.map +2 -2
- package/esm/core/providers/FocusProvider.js.map +2 -2
- package/esm/core/utils/parse-boolean.js +13 -0
- package/esm/core/utils/parse-boolean.js.map +7 -0
- package/esm/layouts/hooks/useBreakpoint.js +44 -0
- package/esm/layouts/hooks/useBreakpoint.js.map +7 -0
- package/esm/layouts/index.js +9 -1
- package/esm/layouts/index.js.map +2 -2
- package/esm/layouts/input-group/InputGroup.css +8 -0
- package/esm/layouts/input-group/InputGroup.sty.js +8 -0
- package/esm/layouts/input-group/InputGroup.sty.js.map +7 -0
- package/esm/styles/index.js +2 -0
- package/esm/styles/index.js.map +2 -2
- package/esm/typography/text/Text.js.map +2 -2
- package/layouts/divider/Divider.d.ts +1 -1
- package/layouts/hooks/useBreakpoint.d.ts +27 -0
- package/layouts/hooks/useBreakpoint.js +62 -0
- package/layouts/index.d.ts +3 -1
- package/layouts/index.js +6 -1
- package/layouts/input-group/InputGroup.css +8 -0
- package/layouts/input-group/InputGroup.sty.d.ts +4 -0
- package/layouts/input-group/InputGroup.sty.js +26 -0
- package/layouts/surface/variables.sty.d.ts +1 -0
- package/package.json +11 -4
- package/styles/index.d.ts +2 -1
- package/styles/index.js +2 -0
- package/styles/safe-sprinkles.d.ts +1 -1
- package/testing/mocks/table-virtualization-mock.js +6 -3
- package/typography/block-quote/Blockquote.d.ts +1 -1
- package/typography/code/Code.d.ts +1 -1
- package/typography/emphasis/Emphasis.d.ts +1 -1
- package/typography/external-link/ExternalLink.d.ts +1 -1
- package/typography/heading/Heading.d.ts +1 -1
- package/typography/list/List.d.ts +1 -1
- package/typography/paragraph/Paragraph.d.ts +1 -1
- package/typography/strikethrough/Strikethrough.d.ts +1 -1
- package/typography/strong/Strong.d.ts +1 -1
- package/typography/text/Text.d.ts +2 -1
- package/typography/text-ellipsis/TextEllipsis.d.ts +1 -1
|
@@ -86,9 +86,9 @@ export declare const _Button: <E extends ElementType = 'button'>(props: ButtonPr
|
|
|
86
86
|
* `Enter` or `Space` while the button has focus.
|
|
87
87
|
* @public
|
|
88
88
|
*/
|
|
89
|
-
export declare const Button: (<E extends
|
|
90
|
-
Suffix: (props: import("./Suffix.js").ButtonSuffixProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement
|
|
91
|
-
Prefix: (props: import("./Prefix.js").ButtonPrefixProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement
|
|
92
|
-
Label: (props: import("./Label.js").ButtonLabelProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement
|
|
89
|
+
export declare const Button: (<E extends ElementType = "button">(props: ButtonProps<E>) => ReactElement | null) & {
|
|
90
|
+
Suffix: (props: import("./Suffix.js").ButtonSuffixProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
91
|
+
Prefix: (props: import("./Prefix.js").ButtonPrefixProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
92
|
+
Label: (props: import("./Label.js").ButtonLabelProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
93
93
|
};
|
|
94
94
|
export {};
|
package/buttons/button/Button.js
CHANGED
|
@@ -44,8 +44,10 @@ var import_ProgressCircle = require("../../content/progress/ProgressCircle.js");
|
|
|
44
44
|
var import_useAriaLabelingProps = require("../../core/hooks/useAriaLabelingProps.js");
|
|
45
45
|
var import_useFocusRing = require("../../core/styles/useFocusRing.js");
|
|
46
46
|
var import_merge_props = require("../../core/utils/merge-props.js");
|
|
47
|
+
var import_parse_boolean = require("../../core/utils/parse-boolean.js");
|
|
47
48
|
var import_Flex = require("../../layouts/flex/Flex.js");
|
|
48
49
|
var import_Grid = require("../../layouts/grid/Grid.js");
|
|
50
|
+
var import_InputGroup_css = require("../../layouts/input-group/InputGroup.sty.js");
|
|
49
51
|
var import_field_css = require("../../styles/field.sty.js");
|
|
50
52
|
function getButtonSlots(children) {
|
|
51
53
|
const slots = {};
|
|
@@ -67,7 +69,7 @@ function getButtonSlots(children) {
|
|
|
67
69
|
break;
|
|
68
70
|
}
|
|
69
71
|
} else {
|
|
70
|
-
if (child) {
|
|
72
|
+
if (child !== null && child !== void 0) {
|
|
71
73
|
slots.freeform ??= [];
|
|
72
74
|
slots.freeform.push(child);
|
|
73
75
|
}
|
|
@@ -102,7 +104,7 @@ const _Button = /* @__PURE__ */ (0, import_react.forwardRef)(
|
|
|
102
104
|
...remainingProps
|
|
103
105
|
} = props;
|
|
104
106
|
const slots = getButtonSlots(children);
|
|
105
|
-
const ariaDisabled =
|
|
107
|
+
const ariaDisabled = (0, import_parse_boolean.parseBoolean)(ariaDisabledProp);
|
|
106
108
|
const nativeDisabledOrLoading = (0, import_react.useMemo)(
|
|
107
109
|
() => loading ? true : disabled,
|
|
108
110
|
[disabled, loading]
|
|
@@ -180,6 +182,7 @@ const _Button = /* @__PURE__ */ (0, import_react.forwardRef)(
|
|
|
180
182
|
readOnly
|
|
181
183
|
}),
|
|
182
184
|
focusClassName,
|
|
185
|
+
import_InputGroup_css.inputGroupChildCSS,
|
|
183
186
|
{
|
|
184
187
|
[`${import_Button_css.buttonWidthsCSS.content}`]: width === "content",
|
|
185
188
|
[`${import_Button_css.buttonWidthsCSS.full}`]: width === "full"
|
|
@@ -211,7 +214,8 @@ const _Button = /* @__PURE__ */ (0, import_react.forwardRef)(
|
|
|
211
214
|
[`${import_Button_css.buttonWidthsCSS.content}`]: width === "content",
|
|
212
215
|
[`${import_Button_css.buttonWidthsCSS.full}`]: width === "full"
|
|
213
216
|
},
|
|
214
|
-
focusClassName
|
|
217
|
+
focusClassName,
|
|
218
|
+
import_InputGroup_css.inputGroupChildCSS
|
|
215
219
|
),
|
|
216
220
|
style: {
|
|
217
221
|
width: width !== "content" && width !== "full" ? width : void 0,
|
|
@@ -13,4 +13,4 @@ export interface ButtonLabelProps extends StylingProps, DataTestId {
|
|
|
13
13
|
* Button Label component.
|
|
14
14
|
* @public
|
|
15
15
|
*/
|
|
16
|
-
export declare const Label: (props: ButtonLabelProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement
|
|
16
|
+
export declare const Label: (props: ButtonLabelProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
@@ -13,4 +13,4 @@ export interface ButtonPrefixProps extends StylingProps, DataTestId {
|
|
|
13
13
|
* Button Prefix component.
|
|
14
14
|
* @public
|
|
15
15
|
*/
|
|
16
|
-
export declare const Prefix: (props: ButtonPrefixProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement
|
|
16
|
+
export declare const Prefix: (props: ButtonPrefixProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
@@ -13,4 +13,4 @@ export interface ButtonSuffixProps extends StylingProps, DataTestId {
|
|
|
13
13
|
* Button Suffix component.
|
|
14
14
|
* @public
|
|
15
15
|
*/
|
|
16
|
-
export declare const Suffix: (props: ButtonSuffixProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement
|
|
16
|
+
export declare const Suffix: (props: ButtonSuffixProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
@@ -41,4 +41,4 @@ export type IntentButtonProps = IntentButtonPropsBase & ({
|
|
|
41
41
|
* in the AppShell context.
|
|
42
42
|
* @public
|
|
43
43
|
*/
|
|
44
|
-
export declare const IntentButton: (props: IntentButtonProps & React.RefAttributes<HTMLAnchorElement>) => React.ReactElement
|
|
44
|
+
export declare const IntentButton: (props: IntentButtonProps & React.RefAttributes<HTMLAnchorElement>) => React.ReactElement | null;
|
|
@@ -49,8 +49,8 @@ export interface ProgressBarProps extends WithChildren, DOMProps, AriaLabelingPr
|
|
|
49
49
|
* The `ProgressBar` can be used to visualize determinate or indeterminate progress.
|
|
50
50
|
* @public
|
|
51
51
|
*/
|
|
52
|
-
export declare const ProgressBar: ((props: ProgressBarProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement
|
|
53
|
-
Value: (props: import("./ProgressBarValue.js").ProgressBarValueProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement
|
|
54
|
-
Label: (props: import("./ProgressBarLabel.js").ProgressBarLabelProps & React.RefAttributes<HTMLLabelElement>) => React.ReactElement
|
|
55
|
-
Icon: (props: import("./ProgressBarIcon.js").ProgressBarIconProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement
|
|
52
|
+
export declare const ProgressBar: ((props: ProgressBarProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null) & {
|
|
53
|
+
Value: (props: import("./ProgressBarValue.js").ProgressBarValueProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
54
|
+
Label: (props: import("./ProgressBarLabel.js").ProgressBarLabelProps & React.RefAttributes<HTMLLabelElement>) => React.ReactElement | null;
|
|
55
|
+
Icon: (props: import("./ProgressBarIcon.js").ProgressBarIconProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
56
56
|
};
|
|
@@ -12,4 +12,4 @@ export interface ProgressBarIconProps extends WithChildren, StylingProps, DataTe
|
|
|
12
12
|
* The ProgressBarIcon subcomponent is rendered inside the ProgressBar component.
|
|
13
13
|
* @public
|
|
14
14
|
*/
|
|
15
|
-
export declare const ProgressBarIcon: (props: ProgressBarIconProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement
|
|
15
|
+
export declare const ProgressBarIcon: (props: ProgressBarIconProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
@@ -12,4 +12,4 @@ export interface ProgressBarLabelProps extends WithChildren, StylingProps, DataT
|
|
|
12
12
|
* ProgressBarLabel sub-component is rendered inside ProgressBar component.
|
|
13
13
|
* @public
|
|
14
14
|
*/
|
|
15
|
-
export declare const ProgressBarLabel: (props: ProgressBarLabelProps & React.RefAttributes<HTMLLabelElement>) => React.ReactElement
|
|
15
|
+
export declare const ProgressBarLabel: (props: ProgressBarLabelProps & React.RefAttributes<HTMLLabelElement>) => React.ReactElement | null;
|
|
@@ -12,4 +12,4 @@ export interface ProgressBarValueProps extends WithChildren, StylingProps, DataT
|
|
|
12
12
|
* ProgressBarValue sub-component is rendered inside ProgressBar component.
|
|
13
13
|
* @public
|
|
14
14
|
*/
|
|
15
|
-
export declare const ProgressBarValue: (props: ProgressBarValueProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement
|
|
15
|
+
export declare const ProgressBarValue: (props: ProgressBarValueProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
@@ -48,4 +48,4 @@ export interface ProgressCircleProps extends WithChildren, DOMProps, AriaLabelin
|
|
|
48
48
|
* The `ProgressCircle` component is used to indicate the progress or completion status of a task or process.
|
|
49
49
|
* @public
|
|
50
50
|
* */
|
|
51
|
-
export declare const ProgressCircle: (props: ProgressCircleProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement
|
|
51
|
+
export declare const ProgressCircle: (props: ProgressCircleProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
@@ -27,4 +27,4 @@ export interface SkeletonProps extends WithChildren, StylingProps, DataTestId {
|
|
|
27
27
|
* The `Skeleton` component renders a colored block with an animated background, indicating that something is loading.
|
|
28
28
|
* @public
|
|
29
29
|
*/
|
|
30
|
-
export declare const Skeleton: (props: SkeletonProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement
|
|
30
|
+
export declare const Skeleton: (props: SkeletonProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
@@ -21,4 +21,4 @@ export interface SkeletonTextProps extends StylingProps, DataTestId {
|
|
|
21
21
|
* The `SkeletonText` component renders a specified number of placeholder boxes for lines of text with an animated background.
|
|
22
22
|
* @public
|
|
23
23
|
*/
|
|
24
|
-
export declare const SkeletonText: (props: SkeletonTextProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement
|
|
24
|
+
export declare const SkeletonText: (props: SkeletonTextProps & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { type PropsWithChildren } from 'react';
|
|
2
2
|
import 'wicg-inert';
|
|
3
|
-
import './AppRoot.
|
|
3
|
+
import './AppRoot.sty.js';
|
|
4
4
|
import { type DataTestId } from '../../types/data-props.js';
|
|
5
5
|
import { type MaskingProps } from '../../types/masking-props.js';
|
|
6
6
|
import { type StylingProps } from '../../types/styling-props.js';
|
|
@@ -18,5 +18,5 @@ export type AppRootProps = PropsWithChildren<DataTestId & StylingProps & Masking
|
|
|
18
18
|
* @public
|
|
19
19
|
*/
|
|
20
20
|
export declare const AppRoot: (props: DataTestId & StylingProps & MaskingProps & {
|
|
21
|
-
children?: React.ReactNode;
|
|
22
|
-
} & React.RefAttributes<HTMLDivElement>) => React.ReactElement
|
|
21
|
+
children?: React.ReactNode | undefined;
|
|
22
|
+
} & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
@@ -17,11 +17,11 @@ export interface FocusScopeProps extends WithChildren {
|
|
|
17
17
|
contain?: boolean;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* @internal
|
|
21
20
|
* The `FocusScope` helps you manage the focus when opening any overlay. If you
|
|
22
21
|
* want to create a custom overlay, you can wrap the content of your overlay in the
|
|
23
22
|
* `FocusScope` to help you make the overlay accessible and handle focus
|
|
24
23
|
* appropriately.
|
|
24
|
+
* @internal
|
|
25
25
|
*/
|
|
26
26
|
export declare const FocusScope: {
|
|
27
27
|
(props: FocusScopeProps): React.JSX.Element;
|
|
@@ -9,11 +9,10 @@ export type FocusContextProps = {
|
|
|
9
9
|
setBackgroundInertness: (value: boolean) => void;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
|
-
* @internal
|
|
13
|
-
*
|
|
14
12
|
* This context keeps all information needed for proper focus management.
|
|
15
13
|
* @param modality - currently used pointer device
|
|
16
14
|
* @param backgroundInertness - if the background (behind overlays) is currently inert (inactive)
|
|
17
15
|
* @param setBackgroundInertness - updates the backgrounds active status
|
|
16
|
+
* @internal
|
|
18
17
|
*/
|
|
19
18
|
export declare const FocusContext: import("react").Context<FocusContextProps>;
|
package/core/index.d.ts
CHANGED
|
@@ -27,3 +27,4 @@ export { roleVariants } from './types/role-variant.js';
|
|
|
27
27
|
export type { RoleVariantType } from './types/role-variant.js';
|
|
28
28
|
export { uuidv4 as _uuidv4 } from './utils/uuidv4.js';
|
|
29
29
|
export { isStringChildren as _isStringChildren } from './utils/_is-string-children.js';
|
|
30
|
+
export { parseBoolean as _parseBoolean } from './utils/parse-boolean.js';
|
package/core/index.js
CHANGED
|
@@ -28,6 +28,7 @@ __export(core_exports, {
|
|
|
28
28
|
_isFocusable: () => import_is_focusable.isFocusable,
|
|
29
29
|
_isStringChildren: () => import_is_string_children.isStringChildren,
|
|
30
30
|
_mergeProps: () => import_merge_props.mergeProps,
|
|
31
|
+
_parseBoolean: () => import_parse_boolean.parseBoolean,
|
|
31
32
|
_useAriaLabelingProps: () => import_useAriaLabelingProps.useAriaLabelingProps,
|
|
32
33
|
_useFocusContext: () => import_useFocusContext.useFocusContext,
|
|
33
34
|
_useId: () => import_useId.useId,
|
|
@@ -55,3 +56,4 @@ var import_useSafeForwardProps = require("./hooks/useSafeForwardProps.js");
|
|
|
55
56
|
var import_role_variant = require("./types/role-variant.js");
|
|
56
57
|
var import_uuidv4 = require("./utils/uuidv4.js");
|
|
57
58
|
var import_is_string_children = require("./utils/_is-string-children.js");
|
|
59
|
+
var import_parse_boolean = require("./utils/parse-boolean.js");
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { WithChildren } from '../types/with-children.js';
|
|
3
3
|
/**
|
|
4
|
-
* @internal
|
|
5
4
|
* Type defining the modality options for the focus handling.
|
|
5
|
+
* @internal
|
|
6
6
|
*/
|
|
7
7
|
export type Modality = 'keyboard' | 'pointer' | 'touch' | 'unknown';
|
|
8
8
|
/**
|
|
9
|
-
* @internal
|
|
10
|
-
*
|
|
11
9
|
* Provider that can be reused in components for storing the focus context props.
|
|
12
10
|
* Loosely inspired by [what-input-js](https://github.com/ten1seven/what-input/blob/main/src/scripts/what-input.js).
|
|
11
|
+
* @internal
|
|
13
12
|
*/
|
|
14
13
|
export declare const FocusProvider: {
|
|
15
14
|
({ children }: WithChildren): React.JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a `Booleanish` value to `boolean` or `undefined`.
|
|
3
|
+
*
|
|
4
|
+
* Booleanish is used by react to type attributes like `aria-disabled`
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
* @see {@link https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L27 | `Booleanish` from @types/react}
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseBoolean(booleanish: boolean | 'true' | 'false' | undefined): boolean | undefined;
|
|
@@ -0,0 +1,31 @@
|
|
|
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 parse_boolean_exports = {};
|
|
19
|
+
__export(parse_boolean_exports, {
|
|
20
|
+
parseBoolean: () => parseBoolean
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(parse_boolean_exports);
|
|
23
|
+
function parseBoolean(booleanish) {
|
|
24
|
+
if (booleanish === void 0) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (typeof booleanish === "boolean") {
|
|
28
|
+
return booleanish;
|
|
29
|
+
}
|
|
30
|
+
return booleanish === "true";
|
|
31
|
+
}
|
|
@@ -13,8 +13,10 @@ import { ProgressCircle } from "../../content/progress/ProgressCircle.js";
|
|
|
13
13
|
import { useAriaLabelingProps } from "../../core/hooks/useAriaLabelingProps.js";
|
|
14
14
|
import { useFocusRing } from "../../core/styles/useFocusRing.js";
|
|
15
15
|
import { mergeProps } from "../../core/utils/merge-props.js";
|
|
16
|
+
import { parseBoolean } from "../../core/utils/parse-boolean.js";
|
|
16
17
|
import { Flex } from "../../layouts/flex/Flex.js";
|
|
17
18
|
import { Grid } from "../../layouts/grid/Grid.js";
|
|
19
|
+
import { inputGroupChildCSS } from "../../layouts/input-group/InputGroup.sty.js";
|
|
18
20
|
import { fieldColorsCSS } from "../../styles/field.sty.js";
|
|
19
21
|
function getButtonSlots(children) {
|
|
20
22
|
const slots = {};
|
|
@@ -36,7 +38,7 @@ function getButtonSlots(children) {
|
|
|
36
38
|
break;
|
|
37
39
|
}
|
|
38
40
|
} else {
|
|
39
|
-
if (child) {
|
|
41
|
+
if (child !== null && child !== void 0) {
|
|
40
42
|
slots.freeform ??= [];
|
|
41
43
|
slots.freeform.push(child);
|
|
42
44
|
}
|
|
@@ -71,7 +73,7 @@ const _Button = /* @__PURE__ */ forwardRef(
|
|
|
71
73
|
...remainingProps
|
|
72
74
|
} = props;
|
|
73
75
|
const slots = getButtonSlots(children);
|
|
74
|
-
const ariaDisabled = ariaDisabledProp
|
|
76
|
+
const ariaDisabled = parseBoolean(ariaDisabledProp);
|
|
75
77
|
const nativeDisabledOrLoading = useMemo(
|
|
76
78
|
() => loading ? true : disabled,
|
|
77
79
|
[disabled, loading]
|
|
@@ -149,6 +151,7 @@ const _Button = /* @__PURE__ */ forwardRef(
|
|
|
149
151
|
readOnly
|
|
150
152
|
}),
|
|
151
153
|
focusClassName,
|
|
154
|
+
inputGroupChildCSS,
|
|
152
155
|
{
|
|
153
156
|
[`${buttonWidthsCSS.content}`]: width === "content",
|
|
154
157
|
[`${buttonWidthsCSS.full}`]: width === "full"
|
|
@@ -180,7 +183,8 @@ const _Button = /* @__PURE__ */ forwardRef(
|
|
|
180
183
|
[`${buttonWidthsCSS.content}`]: width === "content",
|
|
181
184
|
[`${buttonWidthsCSS.full}`]: width === "full"
|
|
182
185
|
},
|
|
183
|
-
focusClassName
|
|
186
|
+
focusClassName,
|
|
187
|
+
inputGroupChildCSS
|
|
184
188
|
),
|
|
185
189
|
style: {
|
|
186
190
|
width: width !== "content" && width !== "full" ? width : void 0,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/buttons/button/Button.tsx"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport * as CSS from 'csstype';\nimport React, {\n type ElementType,\n type MouseEventHandler,\n type PointerEvent,\n type ReactElement,\n type ReactNode,\n forwardRef,\n useMemo,\n} from 'react';\nimport { useIntl } from 'react-intl';\nimport { isElement } from 'react-is';\n\nimport { buttonCSS, buttonLoadingCSS, buttonWidthsCSS } from './Button.sty.js';\nimport { Label } from './Label.js';\nimport { Prefix } from './Prefix.js';\nimport { Suffix } from './Suffix.js';\nimport { ProgressCircle } from '../../content/progress/ProgressCircle.js';\nimport { useAriaLabelingProps } from '../../core/hooks/useAriaLabelingProps.js';\nimport { useFocusRing } from '../../core/styles/useFocusRing.js';\nimport {\n type AriaDisabledProps,\n type AriaLabelingProps,\n} from '../../core/types/a11y-props.js';\nimport { type DataTestId } from '../../core/types/data-props.js';\nimport { type MaskingProps } from '../../core/types/masking-props.js';\nimport { type PolymorphicComponentProps } from '../../core/types/polymorph.js';\nimport { type StylingProps } from '../../core/types/styling-props.js';\nimport { type WithChildren } from '../../core/types/with-children.js';\nimport { mergeProps } from '../../core/utils/merge-props.js';\nimport { Flex } from '../../layouts/flex/Flex.js';\nimport { Grid } from '../../layouts/grid/Grid.js';\nimport { fieldColorsCSS } from '../../styles/field.sty.js';\n\n//#region Typings\n\n/**\n * Accepted properties for the Button.\n * @public\n */\nexport interface ButtonOwnProps\n extends AriaLabelingProps,\n AriaDisabledProps,\n WithChildren,\n StylingProps,\n DataTestId,\n MaskingProps {\n /**\n * If a button is disabled e.g. it cannot be interacted with.\n * @defaultValue false\n */\n disabled?: boolean;\n\n /**\n * Different variants have different styles.\n * @defaultValue 'default'\n */\n variant?: 'default' | 'emphasized' | 'accent';\n\n /**\n * The HTML button type.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type}\n * @defaultValue 'button'\n */\n type?: 'button' | 'reset' | 'submit';\n\n /** Called when the button is interacted with. */\n onClick?: MouseEventHandler;\n\n /**\n * The width of the button.\n * @defaultValue 'content'\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n width?: 'content' | 'full' | CSS.Property.Width<string & {}>;\n\n /**\n * The color of the button. This should be chosen based on the context\n * the button is used in.\n * @defaultValue 'neutral'\n */\n color?: 'primary' | 'neutral' | 'success' | 'critical' | 'warning';\n\n /**\n * Controls the text alignment inside the button. Only affects the button\n * if the width is not set to 'content'.\n * @defaultValue 'center'\n */\n textAlign?: 'center' | 'start';\n\n /**\n * The size of the button.\n * @defaultValue 'default'\n */\n size?: 'default' | 'condensed';\n\n /**\n * The current loading state of the button. If true, a loading icon is shown and the button is disabled.\n * @defaultValue false\n */\n loading?: boolean;\n\n /**\n * Determines whether the element is in read-only mode.\n * @defaultValue false\n */\n readOnly?: boolean;\n}\n\n/**\n * Merge own props with others inherited from the underlying element type.\n * @public\n */\nexport type ButtonProps<E extends ElementType> = PolymorphicComponentProps<\n E,\n ButtonOwnProps\n>;\n\ntype ButtonSlots = {\n label?: ReactNode;\n prefix?: ReactNode;\n suffix?: ReactNode;\n freeform?: ReactNode[];\n};\n\n//#endregion\n\n/**\n * Iterates over child nodes to extract specific component slots.\n * @public\n */\nexport default function getButtonSlots(children: ReactNode) {\n const slots: ButtonSlots = {};\n\n React.Children.forEach(children, (child) => {\n if (isElement(child)) {\n switch (child.type) {\n case Suffix:\n slots.suffix = child;\n break;\n case Prefix:\n slots.prefix = child;\n break;\n case Label:\n slots.label = child;\n break;\n default:\n slots.freeform ??= [];\n slots.freeform.push(child);\n break;\n }\n } else {\n if (child) {\n slots.freeform ??= [];\n slots.freeform.push(child);\n }\n }\n });\n\n return slots;\n}\n\nexport const _Button: <E extends ElementType = 'button'>(\n props: ButtonProps<E>,\n) => ReactElement | null = /* @__PURE__ */ forwardRef(\n <E extends ElementType>(props: ButtonProps<E>, ref: typeof props.ref) => {\n const {\n children,\n variant = 'default',\n disabled,\n 'aria-disabled': ariaDisabledProp,\n required,\n id: propId,\n type = 'button',\n onClick,\n ariaLabel,\n width = 'content',\n color = 'neutral',\n textAlign = 'center',\n size = 'default',\n loading = false,\n className: consumerClassName,\n style: consumerStyle,\n 'data-testid': dataTestId,\n 'data-dtrum-mask': dataDtrumMask,\n 'data-dtrum-allow': dataDtrumAllow,\n readOnly,\n as,\n ...remainingProps\n }: ButtonProps<E> = props;\n const slots = getButtonSlots(children);\n\n const ariaDisabled =\n ariaDisabledProp === true || ariaDisabledProp === 'true';\n\n const nativeDisabledOrLoading = useMemo(\n () => (loading ? true : disabled),\n [disabled, loading],\n );\n const disabledOrLoading = useMemo(\n () => nativeDisabledOrLoading || ariaDisabled,\n [ariaDisabled, nativeDisabledOrLoading],\n );\n\n const { focusProps, focusClassName } = useFocusRing({\n variant: !disabledOrLoading ? color : 'neutral',\n disabled: nativeDisabledOrLoading,\n });\n\n const ariaLabelingProps = useAriaLabelingProps(remainingProps);\n\n const handleButtonClick: MouseEventHandler<HTMLElement> = (event) => {\n if (nativeDisabledOrLoading) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n onClick?.(event);\n };\n\n const buttonProps = {\n ref,\n 'data-testid': dataTestId,\n 'data-dtrum-mask': dataDtrumMask,\n 'data-dtrum-allow': dataDtrumAllow,\n required,\n disabled: nativeDisabledOrLoading && !ariaDisabled,\n id: propId,\n type,\n ...ariaLabelingProps,\n 'aria-disabled': ariaDisabledProp,\n onClick: handleButtonClick,\n };\n\n // Propagation needs to be disabled on the disabled button because\n // it would still trigger actions on parents that would listen to it.\n // For example the menu or the useOverlay hook.\n const disabledPropagationProps = {\n onPointerDown(evt: PointerEvent) {\n if (nativeDisabledOrLoading) {\n evt.preventDefault();\n evt.stopPropagation();\n }\n },\n onPointerUp(evt: PointerEvent) {\n if (nativeDisabledOrLoading) {\n evt.preventDefault();\n evt.stopPropagation();\n }\n },\n };\n\n const hasChildren = children || children === 0;\n\n const buttonMergedProps = {\n ...mergeProps(\n buttonProps,\n disabledPropagationProps,\n // Need to cast this one as the inference of mergeProps would generate\n // a not allowed overlap. The remainingProps type is too complex due to the\n // polymorphic inheritance.\n remainingProps as Record<string, unknown>,\n focusProps,\n ),\n };\n\n const intl = useIntl();\n\n // Make the component polymorphic\n const Component = as || 'button';\n\n // Render a void element if no children are set and it's not loading (so self-closing polymorphed tags won't break)\n if (!hasChildren) {\n return (\n <Component\n {...buttonMergedProps}\n className={clsx(\n consumerClassName,\n fieldColorsCSS({ variant, color, disabled: disabledOrLoading }),\n buttonCSS({\n disabled: disabledOrLoading,\n textAlign,\n size,\n readOnly,\n }),\n focusClassName,\n {\n [`${buttonWidthsCSS.content}`]: width === 'content',\n [`${buttonWidthsCSS.full}`]: width === 'full',\n },\n )}\n style={{\n width: width !== 'content' && width !== 'full' ? width : undefined,\n }}\n />\n );\n }\n\n return (\n <Component\n className={clsx(\n consumerClassName,\n fieldColorsCSS({\n variant,\n color,\n disabled: disabledOrLoading || ariaDisabled,\n }),\n buttonCSS({\n disabled: disabledOrLoading || ariaDisabled,\n textAlign,\n size,\n readOnly,\n }),\n {\n [`${buttonWidthsCSS.content}`]: width === 'content',\n [`${buttonWidthsCSS.full}`]: width === 'full',\n },\n focusClassName,\n )}\n style={{\n width: width !== 'content' && width !== 'full' ? width : undefined,\n ...consumerStyle,\n }}\n {...buttonMergedProps}\n >\n {loading && (\n <div className={buttonLoadingCSS}>\n <ProgressCircle\n size=\"small\"\n variant={color}\n aria-label={intl.formatMessage({\n defaultMessage: 'Loading',\n id: 'cycz+bYG+VH7Of4e',\n description: 'Label for the loading state.',\n })}\n />\n </div>\n )}\n <Grid\n gap={size === 'default' ? 4 : 2}\n grid=\"auto / auto-flow auto\"\n width={'100%'}\n maxWidth=\"100%\"\n alignItems=\"center\"\n justifyContent={textAlign === 'start' ? 'space-between' : 'center'}\n style={{\n visibility: loading ? 'hidden' : undefined,\n }}\n >\n {textAlign === 'start' ? (\n <Flex minWidth={0} gap={size === 'default' ? 4 : 2}>\n {slots.prefix}\n {slots.label}\n {slots.freeform && <Button.Label>{slots.freeform}</Button.Label>}\n </Flex>\n ) : (\n <>\n {slots.prefix}\n {slots.label}\n {slots.freeform && <Button.Label>{slots.freeform}</Button.Label>}\n </>\n )}\n {slots.suffix}\n </Grid>\n </Component>\n );\n },\n);\n\n(_Button as typeof _Button & { displayName: string }).displayName = 'Button';\n\n/**\n * Buttons allow users to trigger actions or events\n * with a single click anywhere within the button container.\n * Users can also trigger a button by pressing\n * `Enter` or `Space` while the button has focus.\n * @public\n */\nexport const Button = Object.assign(_Button, {\n Suffix,\n Prefix,\n Label,\n});\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,UAAU;AAEjB,OAAO;AAAA,EAML;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAE1B,SAAS,WAAW,kBAAkB,uBAAuB;AAC7D,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAU7B,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,sBAAsB;AAmGhB,SAAR,eAAgC,UAAqB;AAC1D,QAAM,QAAqB,CAAC;AAE5B,QAAM,SAAS,QAAQ,UAAU,CAAC,UAAU;AAC1C,QAAI,UAAU,KAAK,GAAG;AACpB,cAAQ,MAAM,MAAM;AAAA,QAClB,KAAK;AACH,gBAAM,SAAS;AACf;AAAA,QACF,KAAK;AACH,gBAAM,SAAS;AACf;AAAA,QACF,KAAK;AACH,gBAAM,QAAQ;AACd;AAAA,QACF;AACE,gBAAM,aAAa,CAAC;AACpB,gBAAM,SAAS,KAAK,KAAK;AACzB;AAAA,MACJ;AAAA,IACF,OAAO;AACL,UAAI,
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport * as CSS from 'csstype';\nimport React, {\n type ElementType,\n type MouseEventHandler,\n type PointerEvent,\n type ReactElement,\n type ReactNode,\n forwardRef,\n useMemo,\n} from 'react';\nimport { useIntl } from 'react-intl';\nimport { isElement } from 'react-is';\n\nimport { buttonCSS, buttonLoadingCSS, buttonWidthsCSS } from './Button.sty.js';\nimport { Label } from './Label.js';\nimport { Prefix } from './Prefix.js';\nimport { Suffix } from './Suffix.js';\nimport { ProgressCircle } from '../../content/progress/ProgressCircle.js';\nimport { useAriaLabelingProps } from '../../core/hooks/useAriaLabelingProps.js';\nimport { useFocusRing } from '../../core/styles/useFocusRing.js';\nimport {\n type AriaDisabledProps,\n type AriaLabelingProps,\n} from '../../core/types/a11y-props.js';\nimport { type DataTestId } from '../../core/types/data-props.js';\nimport { type MaskingProps } from '../../core/types/masking-props.js';\nimport { type PolymorphicComponentProps } from '../../core/types/polymorph.js';\nimport { type StylingProps } from '../../core/types/styling-props.js';\nimport { type WithChildren } from '../../core/types/with-children.js';\nimport { mergeProps } from '../../core/utils/merge-props.js';\nimport { parseBoolean } from '../../core/utils/parse-boolean.js';\nimport { Flex } from '../../layouts/flex/Flex.js';\nimport { Grid } from '../../layouts/grid/Grid.js';\nimport { inputGroupChildCSS } from '../../layouts/input-group/InputGroup.sty.js';\nimport { fieldColorsCSS } from '../../styles/field.sty.js';\n\n//#region Typings\n\n/**\n * Accepted properties for the Button.\n * @public\n */\nexport interface ButtonOwnProps\n extends AriaLabelingProps,\n AriaDisabledProps,\n WithChildren,\n StylingProps,\n DataTestId,\n MaskingProps {\n /**\n * If a button is disabled e.g. it cannot be interacted with.\n * @defaultValue false\n */\n disabled?: boolean;\n\n /**\n * Different variants have different styles.\n * @defaultValue 'default'\n */\n variant?: 'default' | 'emphasized' | 'accent';\n\n /**\n * The HTML button type.\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type}\n * @defaultValue 'button'\n */\n type?: 'button' | 'reset' | 'submit';\n\n /** Called when the button is interacted with. */\n onClick?: MouseEventHandler;\n\n /**\n * The width of the button.\n * @defaultValue 'content'\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n width?: 'content' | 'full' | CSS.Property.Width<string & {}>;\n\n /**\n * The color of the button. This should be chosen based on the context\n * the button is used in.\n * @defaultValue 'neutral'\n */\n color?: 'primary' | 'neutral' | 'success' | 'critical' | 'warning';\n\n /**\n * Controls the text alignment inside the button. Only affects the button\n * if the width is not set to 'content'.\n * @defaultValue 'center'\n */\n textAlign?: 'center' | 'start';\n\n /**\n * The size of the button.\n * @defaultValue 'default'\n */\n size?: 'default' | 'condensed';\n\n /**\n * The current loading state of the button. If true, a loading icon is shown and the button is disabled.\n * @defaultValue false\n */\n loading?: boolean;\n\n /**\n * Determines whether the element is in read-only mode.\n * @defaultValue false\n */\n readOnly?: boolean;\n}\n\n/**\n * Merge own props with others inherited from the underlying element type.\n * @public\n */\nexport type ButtonProps<E extends ElementType> = PolymorphicComponentProps<\n E,\n ButtonOwnProps\n>;\n\ntype ButtonSlots = {\n label?: ReactNode;\n prefix?: ReactNode;\n suffix?: ReactNode;\n freeform?: ReactNode[];\n};\n\n//#endregion\n\n/**\n * Iterates over child nodes to extract specific component slots.\n * @public\n */\nexport default function getButtonSlots(children: ReactNode) {\n const slots: ButtonSlots = {};\n\n React.Children.forEach(children, (child) => {\n if (isElement(child)) {\n switch (child.type) {\n case Suffix:\n slots.suffix = child;\n break;\n case Prefix:\n slots.prefix = child;\n break;\n case Label:\n slots.label = child;\n break;\n default:\n slots.freeform ??= [];\n slots.freeform.push(child);\n break;\n }\n } else {\n if (child !== null && child !== undefined) {\n slots.freeform ??= [];\n slots.freeform.push(child);\n }\n }\n });\n\n return slots;\n}\n\nexport const _Button: <E extends ElementType = 'button'>(\n props: ButtonProps<E>,\n) => ReactElement | null = /* @__PURE__ */ forwardRef(\n <E extends ElementType>(props: ButtonProps<E>, ref: typeof props.ref) => {\n const {\n children,\n variant = 'default',\n disabled,\n 'aria-disabled': ariaDisabledProp,\n required,\n id: propId,\n type = 'button',\n onClick,\n ariaLabel,\n width = 'content',\n color = 'neutral',\n textAlign = 'center',\n size = 'default',\n loading = false,\n className: consumerClassName,\n style: consumerStyle,\n 'data-testid': dataTestId,\n 'data-dtrum-mask': dataDtrumMask,\n 'data-dtrum-allow': dataDtrumAllow,\n readOnly,\n as,\n ...remainingProps\n }: ButtonProps<E> = props;\n const slots = getButtonSlots(children);\n\n const ariaDisabled = parseBoolean(ariaDisabledProp);\n\n const nativeDisabledOrLoading = useMemo(\n () => (loading ? true : disabled),\n [disabled, loading],\n );\n const disabledOrLoading = useMemo(\n () => nativeDisabledOrLoading || ariaDisabled,\n [ariaDisabled, nativeDisabledOrLoading],\n );\n\n const { focusProps, focusClassName } = useFocusRing({\n variant: !disabledOrLoading ? color : 'neutral',\n disabled: nativeDisabledOrLoading,\n });\n\n const ariaLabelingProps = useAriaLabelingProps(remainingProps);\n\n const handleButtonClick: MouseEventHandler<HTMLElement> = (event) => {\n if (nativeDisabledOrLoading) {\n event.preventDefault();\n event.stopPropagation();\n return;\n }\n\n onClick?.(event);\n };\n\n const buttonProps = {\n ref,\n 'data-testid': dataTestId,\n 'data-dtrum-mask': dataDtrumMask,\n 'data-dtrum-allow': dataDtrumAllow,\n required,\n disabled: nativeDisabledOrLoading && !ariaDisabled,\n id: propId,\n type,\n ...ariaLabelingProps,\n 'aria-disabled': ariaDisabledProp,\n onClick: handleButtonClick,\n };\n\n // Propagation needs to be disabled on the disabled button because\n // it would still trigger actions on parents that would listen to it.\n // For example the menu or the useOverlay hook.\n const disabledPropagationProps = {\n onPointerDown(evt: PointerEvent) {\n if (nativeDisabledOrLoading) {\n evt.preventDefault();\n evt.stopPropagation();\n }\n },\n onPointerUp(evt: PointerEvent) {\n if (nativeDisabledOrLoading) {\n evt.preventDefault();\n evt.stopPropagation();\n }\n },\n };\n\n const hasChildren = children || children === 0;\n\n const buttonMergedProps = {\n ...mergeProps(\n buttonProps,\n disabledPropagationProps,\n // Need to cast this one as the inference of mergeProps would generate\n // a not allowed overlap. The remainingProps type is too complex due to the\n // polymorphic inheritance.\n remainingProps as Record<string, unknown>,\n focusProps,\n ),\n };\n\n const intl = useIntl();\n\n // Make the component polymorphic\n const Component = as || 'button';\n\n // Render a void element if no children are set and it's not loading (so self-closing polymorphed tags won't break)\n if (!hasChildren) {\n return (\n <Component\n {...buttonMergedProps}\n className={clsx(\n consumerClassName,\n fieldColorsCSS({ variant, color, disabled: disabledOrLoading }),\n buttonCSS({\n disabled: disabledOrLoading,\n textAlign,\n size,\n readOnly,\n }),\n focusClassName,\n inputGroupChildCSS,\n {\n [`${buttonWidthsCSS.content}`]: width === 'content',\n [`${buttonWidthsCSS.full}`]: width === 'full',\n },\n )}\n style={{\n width: width !== 'content' && width !== 'full' ? width : undefined,\n }}\n />\n );\n }\n\n return (\n <Component\n className={clsx(\n consumerClassName,\n fieldColorsCSS({\n variant,\n color,\n disabled: disabledOrLoading || ariaDisabled,\n }),\n buttonCSS({\n disabled: disabledOrLoading || ariaDisabled,\n textAlign,\n size,\n readOnly,\n }),\n {\n [`${buttonWidthsCSS.content}`]: width === 'content',\n [`${buttonWidthsCSS.full}`]: width === 'full',\n },\n focusClassName,\n inputGroupChildCSS,\n )}\n style={{\n width: width !== 'content' && width !== 'full' ? width : undefined,\n ...consumerStyle,\n }}\n {...buttonMergedProps}\n >\n {loading && (\n <div className={buttonLoadingCSS}>\n <ProgressCircle\n size=\"small\"\n variant={color}\n aria-label={intl.formatMessage({\n defaultMessage: 'Loading',\n id: 'cycz+bYG+VH7Of4e',\n description: 'Label for the loading state.',\n })}\n />\n </div>\n )}\n <Grid\n gap={size === 'default' ? 4 : 2}\n grid=\"auto / auto-flow auto\"\n width={'100%'}\n maxWidth=\"100%\"\n alignItems=\"center\"\n justifyContent={textAlign === 'start' ? 'space-between' : 'center'}\n style={{\n visibility: loading ? 'hidden' : undefined,\n }}\n >\n {textAlign === 'start' ? (\n <Flex minWidth={0} gap={size === 'default' ? 4 : 2}>\n {slots.prefix}\n {slots.label}\n {slots.freeform && <Button.Label>{slots.freeform}</Button.Label>}\n </Flex>\n ) : (\n <>\n {slots.prefix}\n {slots.label}\n {slots.freeform && <Button.Label>{slots.freeform}</Button.Label>}\n </>\n )}\n {slots.suffix}\n </Grid>\n </Component>\n );\n },\n);\n\n(_Button as typeof _Button & { displayName: string }).displayName = 'Button';\n\n/**\n * Buttons allow users to trigger actions or events\n * with a single click anywhere within the button container.\n * Users can also trigger a button by pressing\n * `Enter` or `Space` while the button has focus.\n * @public\n */\nexport const Button = Object.assign(_Button, {\n Suffix,\n Prefix,\n Label,\n});\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AAEjB,OAAO;AAAA,EAML;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAE1B,SAAS,WAAW,kBAAkB,uBAAuB;AAC7D,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAU7B,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAmGhB,SAAR,eAAgC,UAAqB;AAC1D,QAAM,QAAqB,CAAC;AAE5B,QAAM,SAAS,QAAQ,UAAU,CAAC,UAAU;AAC1C,QAAI,UAAU,KAAK,GAAG;AACpB,cAAQ,MAAM,MAAM;AAAA,QAClB,KAAK;AACH,gBAAM,SAAS;AACf;AAAA,QACF,KAAK;AACH,gBAAM,SAAS;AACf;AAAA,QACF,KAAK;AACH,gBAAM,QAAQ;AACd;AAAA,QACF;AACE,gBAAM,aAAa,CAAC;AACpB,gBAAM,SAAS,KAAK,KAAK;AACzB;AAAA,MACJ;AAAA,IACF,OAAO;AACL,UAAI,UAAU,QAAQ,U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7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/core/components/app-root/AppRoot.tsx"],
|
|
4
|
-
"sourcesContent": ["import { isEmpty } from 'lodash-es';\nimport React, {\n type PropsWithChildren,\n forwardRef,\n useEffect,\n useLayoutEffect,\n useState,\n} from 'react';\nimport { IntlProvider, type MessageFormatElement } from 'react-intl';\n\nimport 'wicg-inert';\nimport { getLanguage, getTimezone } from '@dynatrace-sdk/user-preferences';\n\nimport './AppRoot.sty.js';\nimport { useCurrentTheme } from '../../hooks/useCurrentTheme.js';\nimport { FocusProvider } from '../../providers/FocusProvider.js';\nimport { type DataTestId } from '../../types/data-props.js';\nimport { type MaskingProps } from '../../types/masking-props.js';\nimport { type StylingProps } from '../../types/styling-props.js';\n\n/**\n * Gets the href value set in the <base> element to prefix fetches correctly.\n * Will always end with a `/` value\n */\nfunction getBaseHref(): string {\n const baseElement = document.querySelector('base');\n const href = baseElement?.href ?? '/';\n return href.endsWith('/') ? href : `${href}/`;\n}\n\n/**\n * AppRoot component props.\n * @public\n */\nexport type AppRootProps = PropsWithChildren<\n DataTestId & StylingProps & MaskingProps\n>;\n\nconst defaultLanguage = 'en';\n\n/**\n * In order to have all the providers in place for rendering overlays, applying\n * global styles or internationalization, you need to wrap your app in the\n * `AppRoot`. If you're using the `dt-app` to create your app, this is\n * automatically taken care of and you can start working on your app without\n * further ado.\n * @public\n */\nexport const AppRoot = /* @__PURE__ */ forwardRef<HTMLDivElement, AppRootProps>(\n (props, forwardedRef) => {\n const {\n style: consumerStyle,\n className: consumerClassName,\n 'data-testid': dataTestId = 'app-root',\n 'data-dtrum-mask': dataDtrumMask,\n 'data-dtrum-allow': dataDtrumAllow,\n } = props;\n\n /** Messages that are used for the translation. */\n const [messages, setMessages] = useState<\n Record<string, string> | Record<string, MessageFormatElement[]>\n >({});\n\n const { children } = props;\n\n const theme = useCurrentTheme();\n const language = getLanguage();\n let timezone = getTimezone();\n try {\n new Intl.DateTimeFormat(language, { timeZone: timezone });\n } catch (error) {\n // If the passed timezone is not valid, we can fall back to the browsers\n // configured one.\n timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n }\n\n /** Inject the font link into the head */\n useLayoutEffect(() => {\n //
|
|
5
|
-
"mappings": "AAAA,SAAS,eAAe;AACxB,OAAO;AAAA,EAEL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAA+C;AAExD,OAAO;AACP,SAAS,aAAa,mBAAmB;AAEzC,OAAO;AACP,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAS9B,SAAS,cAAsB;AAC7B,QAAM,cAAc,SAAS,cAAc,MAAM;AACjD,QAAM,OAAO,aAAa,QAAQ;AAClC,SAAO,KAAK,SAAS,GAAG,IAAI,OAAO,GAAG,IAAI;AAC5C;AAUA,MAAM,kBAAkB;AAUjB,MAAM,UAA0B;AAAA,EACrC,CAAC,OAAO,iBAAiB;AACvB,UAAM;AAAA,MACJ,OAAO;AAAA,MACP,WAAW;AAAA,MACX,eAAe,aAAa;AAAA,MAC5B,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,IACtB,IAAI;AAGJ,UAAM,CAAC,UAAU,WAAW,IAAI,SAE9B,CAAC,CAAC;AAEJ,UAAM,EAAE,SAAS,IAAI;AAErB,UAAM,QAAQ,gBAAgB;AAC9B,UAAM,WAAW,YAAY;AAC7B,QAAI,WAAW,YAAY;AAC3B,QAAI;AACF,UAAI,KAAK,eAAe,UAAU,EAAE,UAAU,SAAS,CAAC;AAAA,IAC1D,SAAS,OAAO;AAGd,iBAAW,KAAK,eAAe,EAAE,gBAAgB,EAAE;AAAA,IACrD;AAGA,oBAAgB,MAAM;
|
|
4
|
+
"sourcesContent": ["import { isEmpty } from 'lodash-es';\nimport React, {\n type PropsWithChildren,\n forwardRef,\n useEffect,\n useLayoutEffect,\n useState,\n} from 'react';\nimport { IntlProvider, type MessageFormatElement } from 'react-intl';\n\nimport 'wicg-inert';\nimport { getLanguage, getTimezone } from '@dynatrace-sdk/user-preferences';\n\nimport './AppRoot.sty.js';\nimport { useCurrentTheme } from '../../hooks/useCurrentTheme.js';\nimport { FocusProvider } from '../../providers/FocusProvider.js';\nimport { type DataTestId } from '../../types/data-props.js';\nimport { type MaskingProps } from '../../types/masking-props.js';\nimport { type StylingProps } from '../../types/styling-props.js';\n\n/**\n * Gets the href value set in the <base> element to prefix fetches correctly.\n * Will always end with a `/` value\n */\nfunction getBaseHref(): string {\n const baseElement = document.querySelector('base');\n const href = baseElement?.href ?? '/';\n return href.endsWith('/') ? href : `${href}/`;\n}\n\n/**\n * AppRoot component props.\n * @public\n */\nexport type AppRootProps = PropsWithChildren<\n DataTestId & StylingProps & MaskingProps\n>;\n\nconst defaultLanguage = 'en';\n\n/**\n * In order to have all the providers in place for rendering overlays, applying\n * global styles or internationalization, you need to wrap your app in the\n * `AppRoot`. If you're using the `dt-app` to create your app, this is\n * automatically taken care of and you can start working on your app without\n * further ado.\n * @public\n */\nexport const AppRoot = /* @__PURE__ */ forwardRef<HTMLDivElement, AppRootProps>(\n (props, forwardedRef) => {\n const {\n style: consumerStyle,\n className: consumerClassName,\n 'data-testid': dataTestId = 'app-root',\n 'data-dtrum-mask': dataDtrumMask,\n 'data-dtrum-allow': dataDtrumAllow,\n } = props;\n\n /** Messages that are used for the translation. */\n const [messages, setMessages] = useState<\n Record<string, string> | Record<string, MessageFormatElement[]>\n >({});\n\n const { children } = props;\n\n const theme = useCurrentTheme();\n const language = getLanguage();\n let timezone = getTimezone();\n try {\n new Intl.DateTimeFormat(language, { timeZone: timezone });\n } catch (error) {\n // If the passed timezone is not valid, we can fall back to the browsers\n // configured one.\n timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n }\n\n /** Inject the font link into the head */\n useLayoutEffect(() => {\n // Right now the font css file is not automatically injected into\n // the app index.html file. And as there are no static ways to @import\n // css with vanilla extract, we need to inject the link here.\n const link = document.createElement('link');\n\n link.rel = 'stylesheet';\n link.href = 'https://dt-cdn.net/fonts/fonts-v004.css';\n document.head.appendChild(link);\n return () => {\n document.head.removeChild(link);\n };\n }, []);\n\n /**\n * Synchronize the [data-theme] attribute to the root of the document\n * to have the design tokens defined in the cascade.\n */\n useLayoutEffect(() => {\n if (document !== undefined) {\n document.documentElement.setAttribute('data-theme', theme);\n }\n }, [theme]);\n\n useEffect(() => {\n if (language === 'en') {\n // Don't fetch translations for 'en' to avoid an additional render cycle.\n // The default messages are in english already.\n return;\n }\n\n fetch(`${getBaseHref()}lang/${language}.json`)\n .then((res) => {\n return res.json();\n })\n .then((receivedMessages) => {\n setMessages(receivedMessages);\n })\n .catch(() => {\n // Only set messages to a new empty object if the previous messages were not empty.\n // `setMessages({})` would make react believe that this is a new object and, hence, re-render.\n // By just returning `prev` if the messages were already empty, we can avoid the additional render.\n setMessages((prev) => (isEmpty(prev) ? prev : {}));\n });\n }, [language]);\n\n return (\n <div\n ref={forwardedRef}\n data-testid={dataTestId}\n className={consumerClassName}\n style={consumerStyle}\n data-theme={theme}\n data-dtrum-mask={dataDtrumMask}\n data-dtrum-allow={dataDtrumAllow}\n >\n <IntlProvider\n locale={language}\n timeZone={timezone}\n messages={messages}\n defaultLocale={defaultLanguage}\n >\n <FocusProvider>{children}</FocusProvider>\n </IntlProvider>\n </div>\n );\n },\n);\n\n(AppRoot as typeof AppRoot & { displayName: string }).displayName = 'AppRoot';\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,eAAe;AACxB,OAAO;AAAA,EAEL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAA+C;AAExD,OAAO;AACP,SAAS,aAAa,mBAAmB;AAEzC,OAAO;AACP,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAS9B,SAAS,cAAsB;AAC7B,QAAM,cAAc,SAAS,cAAc,MAAM;AACjD,QAAM,OAAO,aAAa,QAAQ;AAClC,SAAO,KAAK,SAAS,GAAG,IAA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C;AAAA,IACL,GAAG,CAAC,QAAQ,CAAC;AAEb,WACE;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL,eAAa;AAAA,QACb,WAAW;AAAA,QACX,OAAO;AAAA,QACP,cAAY;AAAA,QACZ,mBAAiB;AAAA,QACjB,oBAAkB;AAAA;AAAA,MAElB;AAAA,QAAC;AAAA;AAAA,UACC,QAAQ;AAAA,UACR,UAAU;AAAA,UACV;AAAA,UACA,eAAe;AAAA;AAAA,QAEf,oCAAC,qBAAe,QAAS;AAAA,MAC3B;AAAA,IACF;AAAA,EAEJ;AACF;AAEC,QAAqD,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/core/components/focus-scope/FocusScope.tsx"],
|
|
4
|
-
"sourcesContent": ["import React, { useEffect, useRef } from 'react';\n\nimport { useActiveElement } from '../../hooks/useActiveElement.js';\nimport { useFocusContext } from '../../hooks/useFocusContext.js';\nimport type { WithChildren } from '../../types/with-children.js';\nimport { focusFirstDescendant } from '../../utils/focus-management/focus-first-descendant.js';\n\n// #region Types\n\n/**\n * Prop definition of the `FocusScope` component.\n * @internal\n */\nexport interface FocusScopeProps extends WithChildren {\n /**\n * If set to true, the focus scope automatically focuses the first focusable element inside.\n * @defaultValue false\n */\n autoFocus?: boolean;\n /**\n * If set to true, the focus scope traps the focus inside.\n * @defaultValue false\n */\n contain?: boolean;\n}\n// #endregion Types\n\n/**\n *
|
|
4
|
+
"sourcesContent": ["import React, { useEffect, useRef } from 'react';\n\nimport { useActiveElement } from '../../hooks/useActiveElement.js';\nimport { useFocusContext } from '../../hooks/useFocusContext.js';\nimport type { WithChildren } from '../../types/with-children.js';\nimport { focusFirstDescendant } from '../../utils/focus-management/focus-first-descendant.js';\n\n// #region Types\n\n/**\n * Prop definition of the `FocusScope` component.\n * @internal\n */\nexport interface FocusScopeProps extends WithChildren {\n /**\n * If set to true, the focus scope automatically focuses the first focusable element inside.\n * @defaultValue false\n */\n autoFocus?: boolean;\n /**\n * If set to true, the focus scope traps the focus inside.\n * @defaultValue false\n */\n contain?: boolean;\n}\n// #endregion Types\n\n/**\n * The `FocusScope` helps you manage the focus when opening any overlay. If you\n * want to create a custom overlay, you can wrap the content of your overlay in the\n * `FocusScope` to help you make the overlay accessible and handle focus\n * appropriately.\n * @internal\n */\nexport const FocusScope = (props: FocusScopeProps) => {\n const { autoFocus, contain, children } = props;\n const focusContext = useFocusContext();\n const wrapperRef = useRef<HTMLDivElement>(null);\n const focusedElement = useActiveElement();\n const triggerElement = useRef(focusedElement);\n\n useEffect(() => {\n if (contain || autoFocus) {\n focusFirstDescendant(wrapperRef.current);\n }\n\n if (contain) {\n focusContext.setBackgroundInertness(true);\n const triggerElementCopy = triggerElement.current;\n\n return () => {\n focusContext.setBackgroundInertness(false);\n // The focus must be restored on the trigger after removing the inert prop on\n // AppRoot (rendering complete). SetTimeout creates a macrotask to change queueing order.\n window.setTimeout(() => triggerElementCopy.focus(), 0);\n };\n }\n\n if (!autoFocus && !contain) {\n document.addEventListener('keydown', (e) => {\n if (e.key !== 'Tab') {\n return;\n }\n\n if (e.target === triggerElement.current) {\n e.preventDefault();\n focusFirstDescendant(wrapperRef.current);\n }\n });\n }\n\n const triggerElementCopy = triggerElement.current;\n\n return () => {\n // restore focus on trigger when unmounting the focusscope\n triggerElementCopy.focus();\n };\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [contain, autoFocus]);\n\n return (\n <div\n style={{ display: 'contents' }}\n ref={wrapperRef}\n aria-labelledby={triggerElement.current.id}\n // Prevents that focus is lost when clicking on non-focusable items inside (atm used in the internal Drawer).\n // Probably worth considering moving that to the focusScope when redoing the overlays.\n // tabIndex={-1}\n >\n {children}\n </div>\n );\n};\n\nFocusScope.displayName = 'FocusScope';\n"],
|
|
5
5
|
"mappings": "AAAA,OAAO,SAAS,WAAW,cAAc;AAEzC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|
-
"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 *
|
|
5
|
-
"mappings": "AAAA,SAAS,qBAAqB;
|
|
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 * 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 * @internal\n */\nexport const FocusContext = createContext<FocusContextProps>({\n modality: 'unknown',\n backgroundInertness: undefined,\n setBackgroundInertness: (value) => null,\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,qBAAqB;AAqBvB,MAAM,eAAe,cAAiC;AAAA,EAC3D,UAAU;AAAA,EACV,qBAAqB;AAAA,EACrB,wBAAwB,CAAC,UAAU;AACrC,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/esm/core/index.js
CHANGED
|
@@ -22,6 +22,7 @@ import { useSafeForwardProps } from "./hooks/useSafeForwardProps.js";
|
|
|
22
22
|
import { roleVariants } from "./types/role-variant.js";
|
|
23
23
|
import { uuidv4 } from "./utils/uuidv4.js";
|
|
24
24
|
import { isStringChildren } from "./utils/_is-string-children.js";
|
|
25
|
+
import { parseBoolean } from "./utils/parse-boolean.js";
|
|
25
26
|
export {
|
|
26
27
|
AppRoot,
|
|
27
28
|
FocusProvider as _FocusProvider,
|
|
@@ -34,6 +35,7 @@ export {
|
|
|
34
35
|
isFocusable as _isFocusable,
|
|
35
36
|
isStringChildren as _isStringChildren,
|
|
36
37
|
mergeProps as _mergeProps,
|
|
38
|
+
parseBoolean as _parseBoolean,
|
|
37
39
|
useAriaLabelingProps as _useAriaLabelingProps,
|
|
38
40
|
useFocusContext as _useFocusContext,
|
|
39
41
|
useId as _useId,
|
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 { 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';\nexport type {\n PolymorphOwnProps,\n PolymorphProps,\n PolymorphicComponentProps,\n} from './types/polymorph.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';\nexport { type _HeadingLevel, type _HeadingTag } from './types/heading.js';\nexport { useAriaLabelingProps as _useAriaLabelingProps } from './hooks/useAriaLabelingProps.js';\nexport { useId as _useId } from './hooks/useId.js';\nexport { useSafeForwardProps as _useSafeForwardProps } from './hooks/useSafeForwardProps.js';\nexport type { UseSafeForwardReturnProps as _UseSafeForwardReturnProps } from './hooks/useSafeForwardProps.js';\nexport type {\n AriaDisabledProps,\n AriaLabelingProps,\n} from './types/a11y-props.js';\nexport type { DOMProps } from './types/dom.js';\nexport { roleVariants } from './types/role-variant.js';\nexport type { RoleVariantType } from './types/role-variant.js';\nexport { uuidv4 as _uuidv4 } from './utils/uuidv4.js';\nexport { isStringChildren as _isStringChildren } from './utils/_is-string-children.js';\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,eAAkC;AAC3C;AAAA,EACgB;AAAA,OAET;AAIP,SAAS,uBAAuB;AAChC,SAA4B,uBAAwB;AACpD;AAAA,EACmB;AAAA,OAEZ;AAWP,SAAyB,oBAAqB;AAC9C,SAAiC,4BAA6B;AAC9D,SAAmC,8BAA+B;AAClE,SAAkC,6BAA8B;AAChE,SAAwB,mBAAoB;AAC5C,SAAsB,iBAAkB;AACxC;AAAA,EACgB;AAAA,OAIT;AAEP,SAAiC,4BAA6B;AAC9D,SAAkB,aAAc;AAChC,SAAgC,2BAA4B;AAO5D,SAAS,oBAAoB;AAE7B,SAAmB,cAAe;AAClC,SAA6B,wBAAyB;",
|
|
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';\nexport type {\n PolymorphOwnProps,\n PolymorphProps,\n PolymorphicComponentProps,\n} from './types/polymorph.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';\nexport { type _HeadingLevel, type _HeadingTag } from './types/heading.js';\nexport { useAriaLabelingProps as _useAriaLabelingProps } from './hooks/useAriaLabelingProps.js';\nexport { useId as _useId } from './hooks/useId.js';\nexport { useSafeForwardProps as _useSafeForwardProps } from './hooks/useSafeForwardProps.js';\nexport type { UseSafeForwardReturnProps as _UseSafeForwardReturnProps } from './hooks/useSafeForwardProps.js';\nexport type {\n AriaDisabledProps,\n AriaLabelingProps,\n} from './types/a11y-props.js';\nexport type { DOMProps } from './types/dom.js';\nexport { roleVariants } from './types/role-variant.js';\nexport type { RoleVariantType } from './types/role-variant.js';\nexport { uuidv4 as _uuidv4 } from './utils/uuidv4.js';\nexport { isStringChildren as _isStringChildren } from './utils/_is-string-children.js';\nexport { parseBoolean as _parseBoolean } from './utils/parse-boolean.js';\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,eAAkC;AAC3C;AAAA,EACgB;AAAA,OAET;AAIP,SAAS,uBAAuB;AAChC,SAA4B,uBAAwB;AACpD;AAAA,EACmB;AAAA,OAEZ;AAWP,SAAyB,oBAAqB;AAC9C,SAAiC,4BAA6B;AAC9D,SAAmC,8BAA+B;AAClE,SAAkC,6BAA8B;AAChE,SAAwB,mBAAoB;AAC5C,SAAsB,iBAAkB;AACxC;AAAA,EACgB;AAAA,OAIT;AAEP,SAAiC,4BAA6B;AAC9D,SAAkB,aAAc;AAChC,SAAgC,2BAA4B;AAO5D,SAAS,oBAAoB;AAE7B,SAAmB,cAAe;AAClC,SAA6B,wBAAyB;AACtD,SAAyB,oBAAqB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/providers/FocusProvider.tsx"],
|
|
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 *
|
|
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;
|
|
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 * Type defining the modality options for the focus handling.\n * @internal\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 * 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 * @internal\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,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;AAOO,MAAM,gBAAgB,CAAC,EAAE,SAAS,MAAoB;AAC3D,Q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Ac;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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function parseBoolean(booleanish) {
|
|
2
|
+
if (booleanish === void 0) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
if (typeof booleanish === "boolean") {
|
|
6
|
+
return booleanish;
|
|
7
|
+
}
|
|
8
|
+
return booleanish === "true";
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
parseBoolean
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=parse-boolean.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/core/utils/parse-boolean.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Converts a `Booleanish` value to `boolean` or `undefined`.\n *\n * Booleanish is used by react to type attributes like `aria-disabled`\n *\n * @internal\n * @see {@link https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L27 | `Booleanish` from @types/react}\n */\nexport function parseBoolean(\n booleanish: boolean | 'true' | 'false' | undefined,\n): boolean | undefined {\n if (booleanish === undefined) {\n return;\n }\n if (typeof booleanish === 'boolean') {\n return booleanish;\n }\n return booleanish === 'true';\n}\n"],
|
|
5
|
+
"mappings": "AAQO,SAAS,aACd,YACqB;AACrB,MAAI,eAAe,QAAW;AAC5B;AAAA,EACF;AACA,MAAI,OAAO,eAAe,WAAW;AACnC,WAAO;AAAA,EACT;AACA,SAAO,eAAe;AACxB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|