@aurodesignsystem/auro-dialog 1.0.9 → 1.1.0-beta.2
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/CHANGELOG.md +15 -0
- package/README.md +1 -1
- package/demo/api.md +22 -1
- package/dist/auro-dialog__bundled.js +820 -26
- package/dist/buttonVersion.d.ts +3 -0
- package/dist/buttonVersion.d.ts.map +1 -0
- package/dist/color-css.d.ts +3 -0
- package/dist/color-css.d.ts.map +1 -0
- package/dist/componentBase.d.ts +5 -5
- package/dist/componentBase.d.ts.map +1 -1
- package/dist/iconVersion.d.ts +3 -0
- package/dist/iconVersion.d.ts.map +1 -0
- package/dist/tokens-css.d.ts +3 -0
- package/dist/tokens-css.d.ts.map +1 -0
- package/package.json +37 -26
- package/src/buttonVersion.js +1 -0
- package/src/color-css.js +2 -0
- package/src/componentBase.js +26 -14
- package/src/iconVersion.js +1 -0
- package/src/style-css.js +1 -1
- package/src/tokens-css.js +2 -0
- package/dist/accessibility.js +0 -12
- package/dist/basic.js +0 -14
- package/dist/componentBase.js +0 -275
- package/dist/custom.js +0 -14
- package/dist/decoupled.js +0 -27
- package/dist/editCloseButton.js +0 -12
- package/dist/modal.js +0 -40
- package/dist/popoverAndDropdown.js +0 -14
- package/dist/sizeOptions.js +0 -40
- package/dist/style-unformatted-css.js +0 -2
package/dist/componentBase.js
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2024 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
2
|
-
// See LICENSE in the project root for license information.
|
|
3
|
-
|
|
4
|
-
// ---------------------------------------------------------------------
|
|
5
|
-
|
|
6
|
-
/* eslint-disable no-underscore-dangle, jsdoc/no-undefined-types, lit-a11y/click-events-have-key-events, jsdoc/require-description-complete-sentence */
|
|
7
|
-
|
|
8
|
-
import { LitElement, html } from "lit";
|
|
9
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
10
|
-
|
|
11
|
-
import styleCss from "./style-css.js";
|
|
12
|
-
import styleUnformattedCss from './style-unformatted-css.js';
|
|
13
|
-
import closeIcon from '@alaskaairux/icons/dist/icons/interface/x-lg.mjs';
|
|
14
|
-
|
|
15
|
-
/* eslint-disable one-var, prefer-destructuring */
|
|
16
|
-
|
|
17
|
-
const ESCAPE_KEYCODE = 27,
|
|
18
|
-
FOCUS_TIMEOUT = 50;
|
|
19
|
-
|
|
20
|
-
// See https://git.io/JJ6SJ for "How to document your components using JSDoc"
|
|
21
|
-
/**
|
|
22
|
-
* auro-dialog appear above the page and require the user's attention.
|
|
23
|
-
*
|
|
24
|
-
* @attr {Boolean} modal - Modal dialog restricts the user to take an action (no default close actions)
|
|
25
|
-
* @attr {Boolean} unformatted - Unformatted dialog window, edge-to-edge fill for content
|
|
26
|
-
* @attr {Boolean} sm - Sets dialog box to small style. Adding both sm and lg will set the dialog to sm for desktop and lg for mobile.
|
|
27
|
-
* @attr {Boolean} md - Sets dialog box to medium style. Adding both md and lg will set the dialog to md for desktop and lg for mobile.
|
|
28
|
-
* @attr {Boolean} onDark - Sets close icon to white for dark backgrounds
|
|
29
|
-
* @attr {Boolean} open - Sets state of dialog to open
|
|
30
|
-
* @prop {HTMLElement} triggerElement - The element to focus when the dialog is closed. If not set, defaults to the value of document.activeElement when the dialog is opened.
|
|
31
|
-
* @slot header - Text to display as the header of the modal
|
|
32
|
-
* @slot content - Injects content into the body of the modal
|
|
33
|
-
* @slot footer - Used for action options, e.g. buttons
|
|
34
|
-
* @function toggleViewable - toggles the 'open' property on the element
|
|
35
|
-
* @event toggle - Event fires when the element is closed
|
|
36
|
-
* @csspart close-button - adjust position of the close X icon in the dialog window
|
|
37
|
-
* @csspart dialog-overlay - apply CSS on the overlay of the dialog
|
|
38
|
-
* @csspart dialog - apply CSS to the entire dialog
|
|
39
|
-
* @csspart dialog-header - apply CSS to the header of the dialog
|
|
40
|
-
* @csspart dialog-content - apply CSS to the content of the dialog
|
|
41
|
-
* @csspart dialog-footer - apply CSS to the footer of the dialog
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
export default class ComponentBase extends LitElement {
|
|
45
|
-
constructor() {
|
|
46
|
-
super();
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @private
|
|
50
|
-
*/
|
|
51
|
-
this.dom = new DOMParser().parseFromString(closeIcon.svg, 'text/html');
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @private
|
|
55
|
-
*/
|
|
56
|
-
this.svg = this.dom.body.firstChild;
|
|
57
|
-
|
|
58
|
-
this.modal = false;
|
|
59
|
-
this.unformatted = false;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
static get properties() {
|
|
63
|
-
return {
|
|
64
|
-
modal: { type: Boolean },
|
|
65
|
-
unformatted: {
|
|
66
|
-
type: Boolean,
|
|
67
|
-
reflect: true
|
|
68
|
-
},
|
|
69
|
-
open: {
|
|
70
|
-
type: Boolean,
|
|
71
|
-
reflect: true
|
|
72
|
-
},
|
|
73
|
-
triggerElement: {
|
|
74
|
-
attribute: false
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
firstUpdated() {
|
|
80
|
-
const slot = this.shadowRoot.querySelector("#footer"),
|
|
81
|
-
slotWrapper = this.shadowRoot.querySelector("#footerWrapper");
|
|
82
|
-
|
|
83
|
-
this.dialog = this.shadowRoot.getElementById('dialog');
|
|
84
|
-
|
|
85
|
-
if (!this.unformatted && slot.assignedNodes().length === 0) {
|
|
86
|
-
slotWrapper.classList.remove("dialog-footer");
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* LitElement lifecycle method. Called after the DOM has been updated.
|
|
92
|
-
* @param {Map<string, any>} changedProperties - Keys are the names of changed properties, values are the corresponding previous values.
|
|
93
|
-
* @returns {void}
|
|
94
|
-
*/
|
|
95
|
-
updated(changedProperties) {
|
|
96
|
-
if (changedProperties.has('open')) {
|
|
97
|
-
if (this.open) {
|
|
98
|
-
this.openDialog();
|
|
99
|
-
} else {
|
|
100
|
-
this.closeDialog();
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
connectedCallback() {
|
|
106
|
-
super.connectedCallback();
|
|
107
|
-
this.keydownEventHandler = this.handleKeydown.bind(this);
|
|
108
|
-
window.addEventListener('keydown', this.keydownEventHandler);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
disconnectedCallback() {
|
|
112
|
-
super.disconnectedCallback();
|
|
113
|
-
window.removeEventListener('keydown', this.keydownEventHandler);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* @private
|
|
118
|
-
* @returns {void}
|
|
119
|
-
*/
|
|
120
|
-
openDialog() {
|
|
121
|
-
this.defaultTrigger = document.activeElement;
|
|
122
|
-
|
|
123
|
-
setTimeout(() => {
|
|
124
|
-
this.focus();
|
|
125
|
-
|
|
126
|
-
this.handleFocusLoss();
|
|
127
|
-
}, FOCUS_TIMEOUT);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* @private
|
|
132
|
-
* @returns {void}
|
|
133
|
-
*/
|
|
134
|
-
closeDialog() {
|
|
135
|
-
this.dispatchToggleEvent();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* @private
|
|
140
|
-
* @returns {void}
|
|
141
|
-
*/
|
|
142
|
-
dispatchToggleEvent() {
|
|
143
|
-
// replace with Event constructor once IE support dropped
|
|
144
|
-
const toggleEvent = document.createEvent("HTMLEvents");
|
|
145
|
-
|
|
146
|
-
toggleEvent.initEvent("toggle", true, false);
|
|
147
|
-
this.dispatchEvent(toggleEvent);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* @private
|
|
152
|
-
* @returns {void} Determines if dropdown bib should be closed on focus change.
|
|
153
|
-
*/
|
|
154
|
-
handleFocusLoss() {
|
|
155
|
-
const focusable = [...this.querySelectorAll('button, auro-button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')];
|
|
156
|
-
|
|
157
|
-
const firstFocusableElement = focusable[0];
|
|
158
|
-
const lastFocusableElement = focusable[focusable.length - 1];
|
|
159
|
-
|
|
160
|
-
const closeButton = this.shadowRoot.getElementById('dialog-close');
|
|
161
|
-
|
|
162
|
-
if (lastFocusableElement) {
|
|
163
|
-
lastFocusableElement.addEventListener('focusout', () => {
|
|
164
|
-
if (closeButton !== null) { // eslint-disable-line no-negated-condition
|
|
165
|
-
closeButton.focus();
|
|
166
|
-
} else {
|
|
167
|
-
firstFocusableElement.focus();
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* @private
|
|
175
|
-
* @returns {void}
|
|
176
|
-
*/
|
|
177
|
-
handleOverlayClick() {
|
|
178
|
-
if (this.open && !this.modal) {
|
|
179
|
-
this.handleCloseButtonClick();
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* @private
|
|
185
|
-
* @returns {void}
|
|
186
|
-
*/
|
|
187
|
-
handleCloseButtonClick() {
|
|
188
|
-
this.open = false;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* @private
|
|
193
|
-
* @param {KeyboardEvent} event - The keyboard event containing the key and keyCode.
|
|
194
|
-
* @returns {void}
|
|
195
|
-
*/
|
|
196
|
-
handleKeydown({ key, keyCode }) {
|
|
197
|
-
if (this.open && !this.modal && (key === 'Escape' || keyCode === ESCAPE_KEYCODE)) {
|
|
198
|
-
this.open = false;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Focus the dialog.
|
|
204
|
-
* @private
|
|
205
|
-
* @returns {void}
|
|
206
|
-
*/
|
|
207
|
-
focus() {
|
|
208
|
-
if (this.open) {
|
|
209
|
-
this.dialog.focus();
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
static get styles() {
|
|
214
|
-
return [
|
|
215
|
-
styleCss,
|
|
216
|
-
styleUnformattedCss
|
|
217
|
-
];
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* @private
|
|
222
|
-
* @returns {TemplateResult} - The close button template.
|
|
223
|
-
*/
|
|
224
|
-
getCloseButton() {
|
|
225
|
-
return this.modal
|
|
226
|
-
? html``
|
|
227
|
-
: html`
|
|
228
|
-
<button class="dialog-header--action" id="dialog-close" @click="${this.handleCloseButtonClick}" part="close-button">
|
|
229
|
-
<span>${this.svg}</span>
|
|
230
|
-
<span class="util_displayHiddenVisually">Close</span>
|
|
231
|
-
</button>
|
|
232
|
-
`;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
render() {
|
|
236
|
-
const classes = {
|
|
237
|
-
'dialogOverlay': true,
|
|
238
|
-
'dialogOverlay--modal': this.modal && this.open,
|
|
239
|
-
'dialogOverlay--open': this.open,
|
|
240
|
-
'util_displayHidden': !this.open
|
|
241
|
-
},
|
|
242
|
-
|
|
243
|
-
contentClasses = {
|
|
244
|
-
'dialog': true,
|
|
245
|
-
'dialog--open': this.open
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
return html`
|
|
249
|
-
<div class="${classMap(classes)}" id="dialog-overlay" part="dialog-overlay" @click=${this.handleOverlayClick}></div>
|
|
250
|
-
|
|
251
|
-
<div role="dialog" id="dialog" class="${classMap(contentClasses)}" part="dialog" aria-labelledby="dialog-header" tabindex="-1">
|
|
252
|
-
${this.unformatted
|
|
253
|
-
? html`
|
|
254
|
-
<slot name="content"></slot>
|
|
255
|
-
${this.getCloseButton()}
|
|
256
|
-
`
|
|
257
|
-
: html`
|
|
258
|
-
<div class="dialog-header" part="dialog-header">
|
|
259
|
-
<h1 class="heading heading--700 util_stackMarginNone--top" id="dialog-header">
|
|
260
|
-
<slot name="header">Default header ...</slot>
|
|
261
|
-
</h1>
|
|
262
|
-
${this.getCloseButton()}
|
|
263
|
-
</div>
|
|
264
|
-
<div class="dialog-content" part="dialog-content">
|
|
265
|
-
<slot name="content"></slot>
|
|
266
|
-
</div>
|
|
267
|
-
<div class="dialog-footer" id="footerWrapper" part="dialog-footer">
|
|
268
|
-
<slot name="footer" id="footer"></slot>
|
|
269
|
-
</div>
|
|
270
|
-
`
|
|
271
|
-
}
|
|
272
|
-
</div>
|
|
273
|
-
`;
|
|
274
|
-
}
|
|
275
|
-
}
|
package/dist/custom.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function initCustomExample() {
|
|
2
|
-
const buttons = [document.querySelector('#openCustom'), document.querySelector('#closeCustom')];
|
|
3
|
-
const dialog = document.querySelector('#defaultDialog');
|
|
4
|
-
|
|
5
|
-
buttons.forEach((button) => {
|
|
6
|
-
button.addEventListener('click', () => {
|
|
7
|
-
if (dialog.hasAttribute('open')) {
|
|
8
|
-
dialog.removeAttribute('open');
|
|
9
|
-
} else {
|
|
10
|
-
dialog.setAttribute('open', true);
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
}
|
package/dist/decoupled.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export function initDecoupledExample() {
|
|
2
|
-
const smLgButtons = [document.querySelector('#openSmLg'), document.querySelector('#closeSmLg')];
|
|
3
|
-
const smLgDialog = document.querySelector('#smLgDialog');
|
|
4
|
-
|
|
5
|
-
const mdLgButtons = [document.querySelector('#openMdLg'), document.querySelector('#closeMdLg')];
|
|
6
|
-
const mdLgDialog = document.querySelector('#mdLgDialog');
|
|
7
|
-
|
|
8
|
-
smLgButtons.forEach((button) => {
|
|
9
|
-
button.addEventListener('click', () => {
|
|
10
|
-
if (smLgDialog.hasAttribute('open')) {
|
|
11
|
-
smLgDialog.removeAttribute('open');
|
|
12
|
-
} else {
|
|
13
|
-
smLgDialog.setAttribute('open', true);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
mdLgButtons.forEach((button) => {
|
|
19
|
-
button.addEventListener('click', () => {
|
|
20
|
-
if (mdLgDialog.hasAttribute('open')) {
|
|
21
|
-
mdLgDialog.removeAttribute('open');
|
|
22
|
-
} else {
|
|
23
|
-
mdLgDialog.setAttribute('open', true);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
}
|
package/dist/editCloseButton.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function initEditCloseButtonExample() {
|
|
2
|
-
const button = document.querySelector('#openEditDialog');
|
|
3
|
-
const dialog = document.querySelector('#unformattedCustomMdDialog');
|
|
4
|
-
|
|
5
|
-
button.addEventListener('click', () => {
|
|
6
|
-
if (dialog.hasAttribute('open')) {
|
|
7
|
-
dialog.removeAttribute('open');
|
|
8
|
-
} else {
|
|
9
|
-
dialog.setAttribute('open', true);
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
}
|
package/dist/modal.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export function initModalExample() {
|
|
2
|
-
const defaultButtons = [document.querySelector('#openDefaultModal'), document.querySelector('#closeDefaultModal')];
|
|
3
|
-
const defaultDialog = document.querySelector('#defaultModalDialog');
|
|
4
|
-
|
|
5
|
-
const mediumButtons = [document.querySelector('#openMediumModal'), document.querySelector('#closeMediumModal')];
|
|
6
|
-
const mediumDialog = document.querySelector('#mediumModalDialog');
|
|
7
|
-
|
|
8
|
-
const smallButtons = [document.querySelector('#openSmallModal'), document.querySelector('#closeSmallModal')];
|
|
9
|
-
const smallDialog = document.querySelector('#smallModalDialog');
|
|
10
|
-
|
|
11
|
-
defaultButtons.forEach((button) => {
|
|
12
|
-
button.addEventListener('click', () => {
|
|
13
|
-
if (defaultDialog.hasAttribute('open')) {
|
|
14
|
-
defaultDialog.removeAttribute('open');
|
|
15
|
-
} else {
|
|
16
|
-
defaultDialog.setAttribute('open', true);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
mediumButtons.forEach((button) => {
|
|
22
|
-
button.addEventListener('click', () => {
|
|
23
|
-
if (mediumDialog.hasAttribute('open')) {
|
|
24
|
-
mediumDialog.removeAttribute('open');
|
|
25
|
-
} else {
|
|
26
|
-
mediumDialog.setAttribute('open', true);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
smallButtons.forEach((button) => {
|
|
32
|
-
button.addEventListener('click', () => {
|
|
33
|
-
if (smallDialog.hasAttribute('open')) {
|
|
34
|
-
smallDialog.removeAttribute('open');
|
|
35
|
-
} else {
|
|
36
|
-
smallDialog.setAttribute('open', true);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function initPopoverAndDropdownExample() {
|
|
2
|
-
const buttons = [document.querySelector('#openPopAndDrop'), document.querySelector('#closePopAndDrop')];
|
|
3
|
-
const dialog = document.querySelector('#popover-dialog');
|
|
4
|
-
|
|
5
|
-
buttons.forEach((button) => {
|
|
6
|
-
button.addEventListener('click', () => {
|
|
7
|
-
if (dialog.hasAttribute('open')) {
|
|
8
|
-
dialog.removeAttribute('open');
|
|
9
|
-
} else {
|
|
10
|
-
dialog.setAttribute('open', true);
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
}
|
package/dist/sizeOptions.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export function initSizeOptionsExample() {
|
|
2
|
-
const defaultButtons = [document.querySelector('#openDefaultSize'), document.querySelector('#closeDefaultSize')];
|
|
3
|
-
const defaultDialog = document.querySelector('#defaultSizeDialog');
|
|
4
|
-
|
|
5
|
-
const mediumButtons = [document.querySelector('#openMediumSize'), document.querySelector('#closeMediumSize')];
|
|
6
|
-
const mediumDialog = document.querySelector('#mediumSizeDialog');
|
|
7
|
-
|
|
8
|
-
const smallButtons = [document.querySelector('#openSmallSize'), document.querySelector('#closeSmallSize')];
|
|
9
|
-
const smallDialog = document.querySelector('#smallSizeDialog');
|
|
10
|
-
|
|
11
|
-
defaultButtons.forEach((button) => {
|
|
12
|
-
button.addEventListener('click', () => {
|
|
13
|
-
if (defaultDialog.hasAttribute('open')) {
|
|
14
|
-
defaultDialog.removeAttribute('open');
|
|
15
|
-
} else {
|
|
16
|
-
defaultDialog.setAttribute('open', true);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
mediumButtons.forEach((button) => {
|
|
22
|
-
button.addEventListener('click', () => {
|
|
23
|
-
if (mediumDialog.hasAttribute('open')) {
|
|
24
|
-
mediumDialog.removeAttribute('open');
|
|
25
|
-
} else {
|
|
26
|
-
mediumDialog.setAttribute('open', true);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
smallButtons.forEach((button) => {
|
|
32
|
-
button.addEventListener('click', () => {
|
|
33
|
-
if (smallDialog.hasAttribute('open')) {
|
|
34
|
-
smallDialog.removeAttribute('open');
|
|
35
|
-
} else {
|
|
36
|
-
smallDialog.setAttribute('open', true);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
}
|