@1024pix/pix-ui 61.4.1 → 62.0.1

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.
@@ -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 id="modal-content--{{this.id}}" class="pix-modal__content">
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 onEscapeAction from '../modifiers/on-escape-action';
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
- <div
20
- class="pix-overlay
21
- {{unless @isVisible ' pix-overlay--hidden'}}
22
- {{if @hasCenteredContent ' pix-overlay--with-centered-content'}}"
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
- {{trapFocus @isVisible @focusOnClose}}
25
- {{onEscapeAction @onClose}}
46
+ {{on "cancel" this.onCancel}}
47
+ {{on "close" this.onDialogClose}}
48
+ {{modalDialog @isVisible @focusOnClose}}
26
49
  ...attributes
27
50
  >
28
51
  {{yield}}
29
- </div>
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 id="side-panel-content--{{this.id}}" class="pix-side-panel__content">
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}}">
@@ -10,6 +10,7 @@ import PixBlock from './pix-block';
10
10
  export default class PixTable extends Component {
11
11
  get variant() {
12
12
  const value = this.args.variant ?? 'primary';
13
+
13
14
  warn(
14
15
  `PixTable: @variant "${value}" should be ${VARIANTS.join(', ')}`,
15
16
  VARIANTS.includes(value),
@@ -25,11 +26,11 @@ export default class PixTable extends Component {
25
26
  warn(`PixTable: @caption is required`, Boolean(this.args.caption), {
26
27
  id: 'pix-ui.pix-table.caption.required',
27
28
  });
29
+
28
30
  return this.args.caption;
29
31
  }
30
32
 
31
33
  get tableClass() {
32
- const tableClass = ['pix-table'];
33
34
  warn(
34
35
  'PixTable: @condensed must be a boolean, default undefined',
35
36
  [true, false, undefined].includes(this.args.condensed),
@@ -37,15 +38,14 @@ export default class PixTable extends Component {
37
38
  id: 'pix-ui.pix-table.condensed.not-boolean',
38
39
  },
39
40
  );
40
- if (this.args.condensed) {
41
- tableClass.push('pix-table--condensed');
42
- }
43
41
 
42
+ const tableClass = ['pix-table'];
43
+ if (this.args.condensed) tableClass.push('pix-table--condensed');
44
44
  return tableClass.join(' ');
45
45
  }
46
46
 
47
47
  get headerClass() {
48
- return `pix-table-header--${this.variant}`;
48
+ return `pix-table-header pix-table-header--${this.variant}`;
49
49
  }
50
50
 
51
51
  get captionClass() {
@@ -59,6 +59,7 @@ export default class PixTable extends Component {
59
59
  @action
60
60
  onClick(row, event) {
61
61
  event.stopPropagation();
62
+
62
63
  if (this.hasOnRowClick) {
63
64
  this.args.onRowClick(row);
64
65
  }
@@ -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.4);
6
- transition: all 0.3s ease-in-out;
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
- &--hidden {
16
- visibility: hidden;
17
- opacity: 0;
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-x: hidden;
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
- transform: translate(0);
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
- &--hidden {
27
- transform: translate(100%);
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
+ }
@@ -2,6 +2,8 @@
2
2
  @use "pix-design-tokens/typography";
3
3
 
4
4
  .pix-table {
5
+ @extend %pix-body-s;
6
+
5
7
  min-width: 100%;
6
8
  overflow: auto;
7
9
 
@@ -9,106 +11,100 @@
9
11
  overflow: unset;
10
12
  }
11
13
 
12
- @extend %pix-body-s;
13
-
14
- &__caption {
15
- margin-bottom: var(--pix-spacing-3x);
16
- text-align: left;
17
- caption-side: top;
14
+ table {
15
+ width: 100%;
16
+ border-collapse: collapse;
17
+ }
18
18
 
19
- @extend %pix-title-xxs;
19
+ tbody > tr:nth-of-type(even) > :is(td, th) {
20
+ background-color: rgba(var(--pix-neutral-20-inline), 0.80);
20
21
  }
21
22
 
22
- &__clickable-row {
23
+ tbody > tr.pix-table__clickable-row {
23
24
  cursor: pointer;
24
25
 
25
- &:hover, &:focus, &:active {
26
- transition: 0.25s ease;
26
+ & > :is(td, th) {
27
+ transition: background-color 0.25s ease;
27
28
  }
28
29
 
29
- &:hover {
30
+ &:hover > :is(td, th) {
30
31
  background-color: rgba(var(--pix-neutral-100-inline), 0.50);
31
32
  }
32
33
 
33
- &:focus {
34
+ &:focus > :is(td, th) {
34
35
  background-color: rgba(var(--pix-neutral-100-inline), 0.40);
35
36
  }
36
37
 
37
- &:active {
38
+ &:active > :is(td, th) {
38
39
  background-color: rgba(var(--pix-neutral-100-inline), 0.75);
39
40
  }
40
41
  }
41
42
 
42
- table {
43
- width: 100%;
44
- border-collapse: collapse;
45
- }
46
-
47
- tbody > tr:nth-of-type(even):not(.pix-table__clickable-row:hover, .pix-table__clickable-row:focus, .pix-table__clickable-row:active) {
48
- background-color: rgba(var(--pix-neutral-20-inline), 0.80);
49
- }
50
-
51
- thead.pix-table-header {
52
- &--primary {
53
- background: var(--pix-primary-10);
54
- }
55
-
56
- &--orga {
57
- background: var(--pix-orga-50);
58
- }
59
-
60
- &--certif {
61
- background: var(--pix-certif-50);
62
- }
63
-
64
- &--admin {
65
- background: var(--pix-primary-100);
66
- }
67
- }
43
+ td, th {
44
+ padding: var(--pix-spacing-4x);
68
45
 
69
- .pix-table-header-container {
70
- display: flex;
71
- gap: var(--pix-spacing-1x);
72
- align-items: center;
46
+ &:first-child {
47
+ border-top-left-radius: var(--pix-spacing-2x);
48
+ border-bottom-left-radius: var(--pix-spacing-2x);
73
49
  }
74
50
 
75
- th[scope='col'] {
76
- font-weight: var(--pix-font-bold);
77
- text-align: start;
78
- vertical-align: middle;
51
+ &:last-child {
52
+ border-top-right-radius: var(--pix-spacing-2x);
53
+ border-bottom-right-radius: var(--pix-spacing-2x);
79
54
  }
55
+ }
56
+ }
80
57
 
81
- th[scope='row'] {
82
- font-weight: var(--pix-font-normal);
83
- }
58
+ .pix-table--condensed {
59
+ th, td {
60
+ padding: var(--pix-spacing-2x) var(--pix-spacing-4x);
61
+ }
84
62
 
63
+ td.pix-table-column--tag,
64
+ td.pix-table-column--link {
65
+ padding-top: 0.375rem;
66
+ padding-bottom: 0.375rem;
67
+ }
68
+ }
85
69
 
86
- td, th {
87
- padding: var(--pix-spacing-4x) var(--pix-spacing-4x);
70
+ .pix-table-header {
71
+ &--primary th {
72
+ background: var(--pix-primary-10);
73
+ }
88
74
 
89
- &:first-child {
90
- border-radius: var(--pix-spacing-2x) 0 0 var(--pix-spacing-2x);
91
- }
75
+ &--orga th {
76
+ background: var(--pix-orga-50);
77
+ }
92
78
 
93
- &:last-child {
94
- border-radius: 0 var(--pix-spacing-2x) var(--pix-spacing-2x) 0;
95
- }
96
- }
79
+ &--certif th {
80
+ background: var(--pix-certif-50);
81
+ }
97
82
 
98
- &--condensed {
99
- th, td {
100
- padding: .5rem var(--pix-spacing-4x);
101
- }
83
+ &--admin th {
84
+ background: var(--pix-primary-100);
85
+ }
102
86
 
103
- td.pix-table-column--tag {
104
- padding-top: 0.375rem;
105
- padding-bottom: 0.375rem;
106
- }
87
+ th[scope='col'] {
88
+ font-weight: var(--pix-font-bold);
89
+ text-align: start;
90
+ vertical-align: middle;
91
+ }
107
92
 
108
- td.pix-table-column--link {
109
- padding-top: 0.375rem;
110
- padding-bottom: 0.375rem;
111
- }
93
+ th[scope='row'] {
94
+ font-weight: var(--pix-font-normal);
112
95
  }
113
96
  }
114
97
 
98
+ .pix-table-header-container {
99
+ display: flex;
100
+ gap: var(--pix-spacing-1x);
101
+ align-items: center;
102
+ }
103
+
104
+ .pix-table__caption {
105
+ margin-bottom: var(--pix-spacing-3x);
106
+ text-align: left;
107
+ caption-side: top;
108
+
109
+ @extend %pix-title-xxs;
110
+ }
@@ -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": "61.4.1",
3
+ "version": "62.0.1",
4
4
  "description": "Pix-UI is the implementation of Pix design principles and guidelines for its products.",
5
5
  "keywords": [
6
6
  "ember-addon"