@lumx/core 4.24.0-next.3 → 4.24.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components-and-utils.css +6 -0
- package/js/components/Dialog/DialogContent.d.ts +7 -0
- package/js/components/Dialog/DialogShell.d.ts +5 -0
- package/js/components/Dialog/Stories.d.ts +11 -0
- package/js/components/Dialog/index.d.ts +1 -1
- package/js/utils/focus/index.d.ts +2 -0
- package/js/utils/focus/isFocusWithin.d.ts +10 -0
- package/js/utils/focus/setupFocusTrap.d.ts +4 -14
- package/js/utils/focus/setupInitialFocus.d.ts +29 -0
- package/lumx.css +6 -0
- package/package.json +3 -3
- package/scss/components/dialog/_index.scss +10 -0
package/components-and-utils.css
CHANGED
|
@@ -5410,6 +5410,9 @@ table {
|
|
|
5410
5410
|
.lumx-dialog--is-hidden {
|
|
5411
5411
|
opacity: 0;
|
|
5412
5412
|
}
|
|
5413
|
+
.lumx-dialog--is-non-modal {
|
|
5414
|
+
pointer-events: none;
|
|
5415
|
+
}
|
|
5413
5416
|
.lumx-dialog__overlay {
|
|
5414
5417
|
position: absolute;
|
|
5415
5418
|
top: 0;
|
|
@@ -5464,6 +5467,9 @@ table {
|
|
|
5464
5467
|
flex-direction: column;
|
|
5465
5468
|
background-color: var(--lumx-color-light-N);
|
|
5466
5469
|
}
|
|
5470
|
+
.lumx-dialog--is-non-modal .lumx-dialog__wrapper {
|
|
5471
|
+
pointer-events: auto;
|
|
5472
|
+
}
|
|
5467
5473
|
@media (max-width: 61.24em) {
|
|
5468
5474
|
.lumx-dialog__wrapper {
|
|
5469
5475
|
min-height: 100%;
|
|
@@ -52,6 +52,13 @@ export interface DialogContentProps extends BaseDialogProps {
|
|
|
52
52
|
/** ClickAwayProvider component. */
|
|
53
53
|
ClickAwayProvider: any;
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Whether the dialog is modal: it is, unless `dialogProps['aria-modal']` is `false` (or `'false'`).
|
|
57
|
+
*
|
|
58
|
+
* @param dialogProps Props of the dialog container element.
|
|
59
|
+
* @return whether the dialog is modal.
|
|
60
|
+
*/
|
|
61
|
+
export declare const isDialogModal: (dialogProps?: GenericProps) => boolean;
|
|
55
62
|
/**
|
|
56
63
|
* Dialog content: the `role="dialog"` element + header/body/footer.
|
|
57
64
|
*
|
|
@@ -18,6 +18,11 @@ export interface DialogShellProps extends HasClassName {
|
|
|
18
18
|
size?: DialogSizes;
|
|
19
19
|
/** Z-axis position. */
|
|
20
20
|
zIndex?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the dialog is modal. Defaults to `true`.
|
|
23
|
+
* A non-modal dialog has no overlay and renders in place (no portal), so it follows the page's focus and reading order.
|
|
24
|
+
*/
|
|
25
|
+
isModal?: boolean;
|
|
21
26
|
/** Content rendered inside the overlay + providers (typically a framework `DialogContent` reader). */
|
|
22
27
|
children?: any;
|
|
23
28
|
/** Portal component for rendering outside the DOM hierarchy. */
|
|
@@ -97,4 +97,15 @@ export declare function setup({ component: Dialog, render, decorators: { withChr
|
|
|
97
97
|
children: string;
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
|
+
NonModal: {
|
|
101
|
+
args: {
|
|
102
|
+
dialogProps: {
|
|
103
|
+
'aria-modal': boolean;
|
|
104
|
+
};
|
|
105
|
+
header: string;
|
|
106
|
+
footer: string;
|
|
107
|
+
children: string;
|
|
108
|
+
};
|
|
109
|
+
play(): Promise<void>;
|
|
110
|
+
};
|
|
100
111
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { COMPONENT_NAME, CLASSNAME, block, element, DIALOG_LABEL_KEY } from './constants';
|
|
2
2
|
export { type BaseDialogProps, type DialogSizes } from './types';
|
|
3
3
|
export { DialogShell, DEFAULT_PROPS, type DialogShellProps } from './DialogShell';
|
|
4
|
-
export { DialogContent, type DialogContentProps } from './DialogContent';
|
|
4
|
+
export { DialogContent, isDialogModal, type DialogContentProps } from './DialogContent';
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { getFirstAndLastFocusable } from './getFirstAndLastFocusable';
|
|
2
2
|
export { getFocusableElements } from './getFocusableElements';
|
|
3
|
+
export { isFocusWithin } from './isFocusWithin';
|
|
3
4
|
export { setupFocusTrap, type SetupFocusTrapOptions } from './setupFocusTrap';
|
|
5
|
+
export { setupInitialFocus, type SetupInitialFocusOptions } from './setupInitialFocus';
|
|
4
6
|
export { TABBABLE_ELEMENTS_SELECTOR, DISABLED_SELECTOR } from './constants';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the focus is on the given element or inside it.
|
|
3
|
+
*
|
|
4
|
+
* Reads the active element of the element's own root node (Document or ShadowRoot), so it also works when the
|
|
5
|
+
* element lives in a shadow DOM.
|
|
6
|
+
*
|
|
7
|
+
* @param element The element to check.
|
|
8
|
+
* @return whether the active element is the element itself or one of its descendants.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isFocusWithin(element: Element | null | undefined): boolean;
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The element to focus when the trap is activated.
|
|
6
|
-
* Falls back to the first focusable element inside the zone, then to the zone element itself.
|
|
7
|
-
*/
|
|
8
|
-
focusElement?: HTMLElement | null;
|
|
9
|
-
}
|
|
1
|
+
import { type SetupInitialFocusOptions } from './setupInitialFocus';
|
|
2
|
+
/** Focus trap options: the zone in which to trap the focus, and the element to focus on activation. */
|
|
3
|
+
export type SetupFocusTrapOptions = SetupInitialFocusOptions;
|
|
10
4
|
/**
|
|
11
5
|
* Trap 'Tab' focus switch inside the `focusZoneElement`.
|
|
12
6
|
*
|
|
13
|
-
* Setup behavior:
|
|
14
|
-
* 1. Focus `focusElement` if provided and contained in the zone.
|
|
15
|
-
* 2. Otherwise focus the first focusable descendant.
|
|
16
|
-
* 3. Otherwise focus the zone element itself (falling back to setting `tabindex="-1"` if needed) so that
|
|
17
|
-
* keyboard users (especially screen reader users) land inside the trapped region (e.g. an empty dialog).
|
|
7
|
+
* Setup behavior: move the focus into the zone (see `setupInitialFocus`).
|
|
18
8
|
*
|
|
19
9
|
* Tab key behavior:
|
|
20
10
|
* - With at least one focusable descendant: focus cycles between the first and last focusable in the zone.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface SetupInitialFocusOptions {
|
|
2
|
+
/** The element in which to move the focus. */
|
|
3
|
+
focusZoneElement: HTMLElement;
|
|
4
|
+
/**
|
|
5
|
+
* The element to focus.
|
|
6
|
+
* Falls back to the first focusable element inside the zone, then to the zone element itself.
|
|
7
|
+
*/
|
|
8
|
+
focusElement?: HTMLElement | null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Focus the zone element itself (last-resort fallback, e.g. an empty dialog).
|
|
12
|
+
*
|
|
13
|
+
* Adds a `tabindex="-1"` if needed to make the zone programmatically focusable, removed when the signal aborts.
|
|
14
|
+
*
|
|
15
|
+
* @param focusZoneElement The zone element.
|
|
16
|
+
* @param signal AbortSignal used to remove the added `tabindex`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function focusZoneFallback(focusZoneElement: HTMLElement, signal: AbortSignal): void;
|
|
19
|
+
/**
|
|
20
|
+
* Move the focus into the `focusZoneElement`:
|
|
21
|
+
* 1. Focus `focusElement` if provided and contained in the zone.
|
|
22
|
+
* 2. Otherwise focus the first focusable descendant.
|
|
23
|
+
* 3. Otherwise focus the zone element itself (falling back to setting `tabindex="-1"` if needed) so that
|
|
24
|
+
* keyboard users (especially screen reader users) land inside the zone (e.g. an empty dialog).
|
|
25
|
+
*
|
|
26
|
+
* @param options Initial focus configuration.
|
|
27
|
+
* @param signal AbortSignal used to tear down (removes the fallback `tabindex` if it was added).
|
|
28
|
+
*/
|
|
29
|
+
export declare function setupInitialFocus(options: SetupInitialFocusOptions, signal: AbortSignal): void;
|
package/lumx.css
CHANGED
|
@@ -6091,6 +6091,9 @@ table {
|
|
|
6091
6091
|
.lumx-dialog--is-hidden {
|
|
6092
6092
|
opacity: 0;
|
|
6093
6093
|
}
|
|
6094
|
+
.lumx-dialog--is-non-modal {
|
|
6095
|
+
pointer-events: none;
|
|
6096
|
+
}
|
|
6094
6097
|
.lumx-dialog__overlay {
|
|
6095
6098
|
position: absolute;
|
|
6096
6099
|
top: 0;
|
|
@@ -6145,6 +6148,9 @@ table {
|
|
|
6145
6148
|
flex-direction: column;
|
|
6146
6149
|
background-color: var(--lumx-color-light-N);
|
|
6147
6150
|
}
|
|
6151
|
+
.lumx-dialog--is-non-modal .lumx-dialog__wrapper {
|
|
6152
|
+
pointer-events: auto;
|
|
6153
|
+
}
|
|
6148
6154
|
@media (max-width: 61.24em) {
|
|
6149
6155
|
.lumx-dialog__wrapper {
|
|
6150
6156
|
min-height: 100%;
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@floating-ui/dom": "^1.7.5",
|
|
10
|
-
"@lumx/icons": "^4.24.
|
|
10
|
+
"@lumx/icons": "^4.24.1-alpha.0",
|
|
11
11
|
"classnames": "^2.3.2",
|
|
12
12
|
"focus-visible": "^5.0.2",
|
|
13
13
|
"lodash": "4.18.1",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"update-version-changelog": "yarn version-changelog ../../CHANGELOG.md"
|
|
67
67
|
},
|
|
68
68
|
"sideEffects": false,
|
|
69
|
-
"version": "4.24.
|
|
69
|
+
"version": "4.24.1-alpha.0",
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
72
72
|
"@testing-library/dom": "^10.4.1",
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"vite-tsconfig-paths": "^5.1.4",
|
|
91
91
|
"vitest": "^4.1.11"
|
|
92
92
|
},
|
|
93
|
-
"stableVersion": "4.
|
|
93
|
+
"stableVersion": "4.24.0"
|
|
94
94
|
}
|
|
@@ -30,6 +30,12 @@
|
|
|
30
30
|
opacity: 0;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
// The root and the container cover more than the visible dialog: let clicks go through to the page, only the
|
|
34
|
+
// visible dialog (the wrapper) catches them.
|
|
35
|
+
&--is-non-modal {
|
|
36
|
+
pointer-events: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
33
39
|
&__overlay {
|
|
34
40
|
position: absolute;
|
|
35
41
|
top: 0;
|
|
@@ -82,6 +88,10 @@
|
|
|
82
88
|
flex-direction: column;
|
|
83
89
|
background-color: lumx-color-variant("light", "N");
|
|
84
90
|
|
|
91
|
+
#{$self}--is-non-modal & {
|
|
92
|
+
pointer-events: auto;
|
|
93
|
+
}
|
|
94
|
+
|
|
85
95
|
@include mq($until: desktop) {
|
|
86
96
|
min-height: 100%;
|
|
87
97
|
}
|