@1024pix/pix-ui 61.4.0 → 62.0.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/addon/components/pix-modal.gjs +3 -9
- package/addon/components/pix-overlay.gjs +32 -9
- package/addon/components/pix-side-panel.gjs +3 -10
- package/addon/modifiers/modal-dialog.js +44 -0
- package/addon/modifiers/trap-focus.js +7 -0
- package/addon/styles/_pix-modal.scss +25 -0
- package/addon/styles/_pix-overlay.scss +32 -6
- package/addon/styles/_pix-side-panel.scss +25 -5
- package/addon/styles/addon.scss +2 -2
- package/app/modifiers/modal-dialog.js +1 -0
- package/package.json +2 -2
|
@@ -36,15 +36,9 @@ export default class PixModal extends Component {
|
|
|
36
36
|
@onClose={{@onCloseButtonClick}}
|
|
37
37
|
@focusOnClose={{@focusOnClose}}
|
|
38
38
|
@hasCenteredContent={{true}}
|
|
39
|
+
@labelledBy="modal-title--{{this.id}}"
|
|
39
40
|
>
|
|
40
|
-
<div
|
|
41
|
-
class="pix-modal pix-modal--{{this.variant}}"
|
|
42
|
-
role="dialog"
|
|
43
|
-
aria-labelledby="modal-title--{{this.id}}"
|
|
44
|
-
aria-describedby="modal-content--{{this.id}}"
|
|
45
|
-
aria-modal="true"
|
|
46
|
-
...attributes
|
|
47
|
-
>
|
|
41
|
+
<div class="pix-modal pix-modal--{{this.variant}}" ...attributes>
|
|
48
42
|
<PixModalHeader
|
|
49
43
|
@id="modal-title--{{this.id}}"
|
|
50
44
|
@title={{@title}}
|
|
@@ -55,7 +49,7 @@ export default class PixModal extends Component {
|
|
|
55
49
|
@onCloseButtonClick={{@onCloseButtonClick}}
|
|
56
50
|
/>
|
|
57
51
|
|
|
58
|
-
<div
|
|
52
|
+
<div class="pix-modal__content">
|
|
59
53
|
{{yield to="content"}}
|
|
60
54
|
</div>
|
|
61
55
|
<div class="pix-modal__footer">
|
|
@@ -2,8 +2,7 @@ import { on } from '@ember/modifier';
|
|
|
2
2
|
import { action } from '@ember/object';
|
|
3
3
|
import Component from '@glimmer/component';
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import trapFocus from '../modifiers/trap-focus';
|
|
5
|
+
import modalDialog from '../modifiers/modal-dialog';
|
|
7
6
|
|
|
8
7
|
export default class PixOverlay extends Component {
|
|
9
8
|
@action
|
|
@@ -15,17 +14,41 @@ export default class PixOverlay extends Component {
|
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
|
|
17
|
+
/**
|
|
18
|
+
* A `<dialog>` cancel does not bubble, unlike an `<input type="file">` one when its picker is
|
|
19
|
+
* dismissed. Without `onClose`, the default action is kept so the user is not trapped inside.
|
|
20
|
+
*/
|
|
21
|
+
@action
|
|
22
|
+
onCancel(event) {
|
|
23
|
+
const isCloseRequestOnOverlay = event.target === event.currentTarget;
|
|
24
|
+
|
|
25
|
+
if (!isCloseRequestOnOverlay || !this.args.onClose) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
this.args.onClose(event);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@action
|
|
34
|
+
onDialogClose(event) {
|
|
35
|
+
if (this.args.isVisible && this.args.onClose) {
|
|
36
|
+
this.args.onClose(event);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
18
40
|
<template>
|
|
19
|
-
<
|
|
20
|
-
class="pix-overlay
|
|
21
|
-
|
|
22
|
-
|
|
41
|
+
<dialog
|
|
42
|
+
class="pix-overlay {{if @hasCenteredContent ' pix-overlay--with-centered-content'}}"
|
|
43
|
+
aria-labelledby={{@labelledBy}}
|
|
44
|
+
aria-describedby={{@describedBy}}
|
|
23
45
|
{{on "click" this.onClick}}
|
|
24
|
-
{{
|
|
25
|
-
{{
|
|
46
|
+
{{on "cancel" this.onCancel}}
|
|
47
|
+
{{on "close" this.onDialogClose}}
|
|
48
|
+
{{modalDialog @isVisible @focusOnClose}}
|
|
26
49
|
...attributes
|
|
27
50
|
>
|
|
28
51
|
{{yield}}
|
|
29
|
-
</
|
|
52
|
+
</dialog>
|
|
30
53
|
</template>
|
|
31
54
|
}
|
|
@@ -36,16 +36,9 @@ export default class PixSidePanel extends Component {
|
|
|
36
36
|
@isVisible={{@showSidePanel}}
|
|
37
37
|
@onClose={{@onClose}}
|
|
38
38
|
@focusOnClose={{@focusOnClose}}
|
|
39
|
+
@labelledBy="side-panel-title--{{this.id}}"
|
|
39
40
|
>
|
|
40
|
-
<div
|
|
41
|
-
class="pix-side-panel pix-side-panel--{{this.variant}}
|
|
42
|
-
{{unless @showSidePanel ' pix-side-panel--hidden'}}"
|
|
43
|
-
role="dialog"
|
|
44
|
-
aria-labelledby="side-panel-title--{{this.id}}"
|
|
45
|
-
aria-describedby="side-panel-content--{{this.id}}"
|
|
46
|
-
aria-modal="true"
|
|
47
|
-
...attributes
|
|
48
|
-
>
|
|
41
|
+
<div class="pix-side-panel pix-side-panel--{{this.variant}}" ...attributes>
|
|
49
42
|
<PixModalHeader
|
|
50
43
|
class="pix-side-panel__header"
|
|
51
44
|
@id="side-panel-title--{{this.id}}"
|
|
@@ -56,7 +49,7 @@ export default class PixSidePanel extends Component {
|
|
|
56
49
|
@onCloseButtonClick={{@onClose}}
|
|
57
50
|
/>
|
|
58
51
|
|
|
59
|
-
<div
|
|
52
|
+
<div class="pix-side-panel__content">
|
|
60
53
|
{{yield to="content"}}
|
|
61
54
|
</div>
|
|
62
55
|
<div class="pix-side-panel__footer pix-side-panel__footer--{{this.variant}}">
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { modifier } from 'ember-modifier';
|
|
2
|
+
|
|
3
|
+
const SCROLL_LOCK_CLASS = 'pix-overlay-scroll-lock';
|
|
4
|
+
|
|
5
|
+
const scrollLockingDialogs = new Set();
|
|
6
|
+
|
|
7
|
+
function lockPageScrolling(element) {
|
|
8
|
+
scrollLockingDialogs.add(element);
|
|
9
|
+
document.body.classList.add(SCROLL_LOCK_CLASS);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function unlockPageScrolling(element) {
|
|
13
|
+
scrollLockingDialogs.delete(element);
|
|
14
|
+
|
|
15
|
+
if (scrollLockingDialogs.size === 0) {
|
|
16
|
+
document.body.classList.remove(SCROLL_LOCK_CLASS);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {boolean} isOpen
|
|
22
|
+
* @param {boolean} [focusOnClose=true]
|
|
23
|
+
*/
|
|
24
|
+
export default modifier(function modalDialog(element, [isOpen, focusOnClose = true]) {
|
|
25
|
+
if (isOpen) {
|
|
26
|
+
if (!element.open) {
|
|
27
|
+
element.showModal();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
lockPageScrolling(element);
|
|
31
|
+
} else if (element.open) {
|
|
32
|
+
const hadFocusInside = element.contains(document.activeElement);
|
|
33
|
+
|
|
34
|
+
element.close();
|
|
35
|
+
|
|
36
|
+
if (focusOnClose === false && hadFocusInside) {
|
|
37
|
+
document.activeElement?.blur();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return () => {
|
|
42
|
+
unlockPageScrolling(element);
|
|
43
|
+
};
|
|
44
|
+
});
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
import { warn } from '@ember/debug';
|
|
1
2
|
import { modifier } from 'ember-modifier';
|
|
2
3
|
|
|
3
4
|
let sourceActiveElement = null;
|
|
4
5
|
|
|
5
6
|
export default modifier(function trapFocus(element, [isOpen, focusOnClose = true]) {
|
|
7
|
+
warn(
|
|
8
|
+
'trap-focus is deprecated: it only intercepts Tab, so it cannot keep the virtual cursor of a screen reader inside the element. Use PixModal, PixSidePanel or PixOverlay, which rely on a native <dialog> placed in the top layer.',
|
|
9
|
+
false,
|
|
10
|
+
{ id: 'pix-ui.trap-focus.deprecated' },
|
|
11
|
+
);
|
|
12
|
+
|
|
6
13
|
const [firstFocusableElement] = findFocusableElements(element);
|
|
7
14
|
|
|
8
15
|
if (isOpen) {
|
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
background-color: var(--pix-neutral-0);
|
|
11
11
|
border-radius: var(--pix-spacing-4x);
|
|
12
12
|
transform: translateX(-50%);
|
|
13
|
+
animation: fade-out-modal 0.3s ease-out forwards;
|
|
14
|
+
|
|
15
|
+
.pix-overlay[open] & {
|
|
16
|
+
animation: fade-in-modal 0.3s ease-out forwards;
|
|
17
|
+
}
|
|
13
18
|
|
|
14
19
|
&--default {
|
|
15
20
|
@extend %pix-shadow-default;
|
|
@@ -51,3 +56,23 @@
|
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
58
|
}
|
|
59
|
+
|
|
60
|
+
@keyframes fade-in-modal {
|
|
61
|
+
from {
|
|
62
|
+
opacity: 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
to {
|
|
66
|
+
opacity: 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@keyframes fade-out-modal {
|
|
71
|
+
from {
|
|
72
|
+
opacity: 1;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
to {
|
|
76
|
+
opacity: 0;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -1,19 +1,45 @@
|
|
|
1
1
|
.pix-overlay {
|
|
2
2
|
position: fixed;
|
|
3
3
|
z-index: 1000;
|
|
4
|
+
width: 100%;
|
|
5
|
+
max-width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
max-height: 100%;
|
|
8
|
+
margin: 0;
|
|
9
|
+
padding: 0;
|
|
4
10
|
overflow-y: auto;
|
|
5
|
-
background-color: rgba(var(--pix-neutral-800-inline), 0
|
|
6
|
-
|
|
11
|
+
background-color: rgba(var(--pix-neutral-800-inline), 0);
|
|
12
|
+
border: none;
|
|
13
|
+
transition:
|
|
14
|
+
background-color 0.3s ease-out,
|
|
15
|
+
display 0.3s allow-discrete,
|
|
16
|
+
overlay 0.3s allow-discrete;
|
|
7
17
|
inset: 0;
|
|
8
18
|
|
|
19
|
+
&::backdrop {
|
|
20
|
+
background-color: transparent;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&[open] {
|
|
24
|
+
background-color: rgba(var(--pix-neutral-800-inline), 0.4);
|
|
25
|
+
}
|
|
26
|
+
|
|
9
27
|
&--with-centered-content {
|
|
10
|
-
display: grid;
|
|
11
28
|
align-items: center;
|
|
12
29
|
padding-block: var(--pix-spacing-4x);
|
|
30
|
+
|
|
31
|
+
&[open] {
|
|
32
|
+
display: grid;
|
|
33
|
+
}
|
|
13
34
|
}
|
|
14
35
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
36
|
+
@starting-style {
|
|
37
|
+
&[open] {
|
|
38
|
+
background-color: rgba(var(--pix-neutral-800-inline), 0);
|
|
39
|
+
}
|
|
18
40
|
}
|
|
19
41
|
}
|
|
42
|
+
|
|
43
|
+
.pix-overlay-scroll-lock {
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
@use 'pix-design-tokens/shadows';
|
|
4
4
|
|
|
5
5
|
.pix-side-panel__overlay {
|
|
6
|
-
overflow
|
|
6
|
+
overflow: hidden; // fallback for Safari < 16, which ignores the clip value below
|
|
7
|
+
overflow: clip; // not a scroll container, so focus cannot scroll the sliding panel into place
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
.pix-side-panel {
|
|
@@ -16,15 +17,14 @@
|
|
|
16
17
|
margin-left: auto;
|
|
17
18
|
background: var(--pix-neutral-0);
|
|
18
19
|
border-radius: var(--pix-spacing-4x) 0 0 var(--pix-spacing-4x);
|
|
19
|
-
|
|
20
|
-
transition: transform 0.3s ease-in-out;
|
|
20
|
+
animation: slide-out-side-panel 0.3s ease-in-out forwards;
|
|
21
21
|
|
|
22
22
|
@include breakpoints.device-is('tablet') {
|
|
23
23
|
width: 412px;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
.pix-overlay[open] & {
|
|
27
|
+
animation: slide-in-side-panel 0.3s ease-in-out forwards;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
&--default {
|
|
@@ -84,3 +84,23 @@
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
+
|
|
88
|
+
@keyframes slide-in-side-panel {
|
|
89
|
+
from {
|
|
90
|
+
transform: translate(100%);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
to {
|
|
94
|
+
transform: translate(0);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@keyframes slide-out-side-panel {
|
|
99
|
+
from {
|
|
100
|
+
transform: translate(0);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
to {
|
|
104
|
+
transform: translate(100%);
|
|
105
|
+
}
|
|
106
|
+
}
|
package/addon/styles/addon.scss
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
@use 'pix-design-tokens';
|
|
2
2
|
@use 'normalize-reset';
|
|
3
3
|
@use 'a11y';
|
|
4
|
+
@use 'trap-focus';
|
|
5
|
+
@use 'pix-overlay';
|
|
4
6
|
@use 'pix-icon';
|
|
5
7
|
@use 'pix-background-header';
|
|
6
8
|
@use 'pix-banner-alert';
|
|
@@ -37,7 +39,6 @@
|
|
|
37
39
|
@use 'pix-checkbox';
|
|
38
40
|
@use 'pix-segmented-control';
|
|
39
41
|
@use 'pix-indicator-card';
|
|
40
|
-
@use 'trap-focus';
|
|
41
42
|
@use 'pix-search-input';
|
|
42
43
|
@use 'pix-toast';
|
|
43
44
|
@use 'toast-example';
|
|
@@ -48,7 +49,6 @@
|
|
|
48
49
|
@use 'pix-app-layout';
|
|
49
50
|
@use 'pix-structure-switcher';
|
|
50
51
|
@use 'pix-code';
|
|
51
|
-
@use 'pix-overlay';
|
|
52
52
|
@use 'pix-tabs';
|
|
53
53
|
@use 'pix-gauge';
|
|
54
54
|
@use 'pix-stepper';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@1024pix/pix-ui/modifiers/modal-dialog';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1024pix/pix-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "62.0.0",
|
|
4
4
|
"description": "Pix-UI is the implementation of Pix design principles and guidelines for its products.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"tracked-toolbox": "^2.2.0"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@1024pix/ember-testing-library": "^3.0.
|
|
79
|
+
"@1024pix/ember-testing-library": "^3.0.40",
|
|
80
80
|
"@1024pix/eslint-plugin": "^2.1.12",
|
|
81
81
|
"@1024pix/stylelint-config": "^5.1.37",
|
|
82
82
|
"@babel/eslint-parser": "^7.26.8",
|