@aurodesignsystem/auro-dialog 1.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/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/CHANGELOG.md +24 -0
- package/LICENSE +201 -0
- package/README.md +226 -0
- package/demo/api.md +725 -0
- package/demo/index.md +200 -0
- package/dist/auro-dialog.d.ts +22 -0
- package/dist/auro-dialog.d.ts.map +1 -0
- package/dist/auro-dialog__bundled.js +362 -0
- package/dist/componentBase.d.ts +113 -0
- package/dist/componentBase.d.ts.map +1 -0
- package/dist/componentBase.js +278 -0
- package/dist/style-css.d.ts +3 -0
- package/dist/style-css.d.ts.map +1 -0
- package/dist/style-fixed-css.d.ts +3 -0
- package/dist/style-fixed-css.d.ts.map +1 -0
- package/dist/style-fixed-css.js +2 -0
- package/dist/style-unformatted-css.d.ts +3 -0
- package/dist/style-unformatted-css.d.ts.map +1 -0
- package/dist/style-unformatted-css.js +2 -0
- package/dist/style-unformatted-fixed-css.d.ts +3 -0
- package/dist/style-unformatted-fixed-css.d.ts.map +1 -0
- package/dist/style-unformatted-fixed-css.js +2 -0
- package/index.js +15 -0
- package/package.json +160 -0
- package/packageScripts/postinstall.mjs +28 -0
- package/src/auro-dialog.js +36 -0
- package/src/componentBase.js +278 -0
- package/src/style-css.js +2 -0
- package/src/style-fixed-css.js +2 -0
- package/src/style-unformatted-css.js +2 -0
- package/src/style-unformatted-fixed-css.js +2 -0
|
@@ -0,0 +1,278 @@
|
|
|
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 styleCssFixed from './style-fixed-css.js';
|
|
13
|
+
import styleUnformattedCss from './style-unformatted-css.js';
|
|
14
|
+
import styleUnformattedCssFixed from './style-unformatted-fixed-css.js';
|
|
15
|
+
import closeIcon from '@alaskaairux/icons/dist/icons/interface/x-lg_es6.js';
|
|
16
|
+
|
|
17
|
+
/* eslint-disable one-var, prefer-destructuring */
|
|
18
|
+
|
|
19
|
+
const ESCAPE_KEYCODE = 27,
|
|
20
|
+
FOCUS_TIMEOUT = 50;
|
|
21
|
+
|
|
22
|
+
// See https://git.io/JJ6SJ for "How to document your components using JSDoc"
|
|
23
|
+
/**
|
|
24
|
+
* auro-dialog appear above the page and require the user's attention.
|
|
25
|
+
*
|
|
26
|
+
* @attr {Boolean} modal - Modal dialog restricts the user to take an action (no default close actions)
|
|
27
|
+
* @attr {Boolean} fixed - Uses fixed pixel values for element shape
|
|
28
|
+
* @attr {Boolean} unformatted - Unformatted dialog window, edge-to-edge fill for content
|
|
29
|
+
* @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.
|
|
30
|
+
* @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.
|
|
31
|
+
* @attr {Boolean} onDark - Sets close icon to white for dark backgrounds
|
|
32
|
+
* @attr {Boolean} open - Sets state of dialog to open
|
|
33
|
+
* @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.
|
|
34
|
+
* @slot header - Text to display as the header of the modal
|
|
35
|
+
* @slot content - Injects content into the body of the modal
|
|
36
|
+
* @slot footer - Used for action options, e.g. buttons
|
|
37
|
+
* @function toggleViewable - toggles the 'open' property on the element
|
|
38
|
+
* @event toggle - Event fires when the element is closed
|
|
39
|
+
* @csspart close-button - adjust position of the close X icon in the dialog window
|
|
40
|
+
* @csspart dialog-overlay - apply CSS on the overlay of the dialog
|
|
41
|
+
* @csspart dialog - apply CSS to the entire dialog
|
|
42
|
+
* @csspart dialog-header - apply CSS to the header of the dialog
|
|
43
|
+
* @csspart dialog-content - apply CSS to the content of the dialog
|
|
44
|
+
* @csspart dialog-footer - apply CSS to the footer of the dialog
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
export default class ComponentBase extends LitElement {
|
|
48
|
+
constructor() {
|
|
49
|
+
super();
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
this.dom = new DOMParser().parseFromString(closeIcon.svg, 'text/html');
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @private
|
|
58
|
+
*/
|
|
59
|
+
this.svg = this.dom.body.firstChild;
|
|
60
|
+
|
|
61
|
+
this.modal = false;
|
|
62
|
+
this.unformatted = false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static get properties() {
|
|
66
|
+
return {
|
|
67
|
+
modal: { type: Boolean },
|
|
68
|
+
unformatted: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
reflect: true
|
|
71
|
+
},
|
|
72
|
+
open: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
reflect: true
|
|
75
|
+
},
|
|
76
|
+
triggerElement: {
|
|
77
|
+
attribute: false
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
firstUpdated() {
|
|
83
|
+
const slot = this.shadowRoot.querySelector("#footer"),
|
|
84
|
+
slotWrapper = this.shadowRoot.querySelector("#footerWrapper");
|
|
85
|
+
|
|
86
|
+
this.dialog = this.shadowRoot.getElementById('dialog');
|
|
87
|
+
|
|
88
|
+
if (!this.unformatted && slot.assignedNodes().length === 0) {
|
|
89
|
+
slotWrapper.classList.remove("dialog-footer");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* LitElement lifecycle method. Called after the DOM has been updated.
|
|
95
|
+
* @param {Map<string, any>} changedProperties - Keys are the names of changed properties, values are the corresponding previous values.
|
|
96
|
+
* @returns {void}
|
|
97
|
+
*/
|
|
98
|
+
updated(changedProperties) {
|
|
99
|
+
if (changedProperties.has('open')) {
|
|
100
|
+
if (this.open) {
|
|
101
|
+
this.openDialog();
|
|
102
|
+
} else {
|
|
103
|
+
this.closeDialog();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
connectedCallback() {
|
|
109
|
+
super.connectedCallback();
|
|
110
|
+
this.keydownEventHandler = this.handleKeydown.bind(this);
|
|
111
|
+
window.addEventListener('keydown', this.keydownEventHandler);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
disconnectedCallback() {
|
|
115
|
+
super.disconnectedCallback();
|
|
116
|
+
window.removeEventListener('keydown', this.keydownEventHandler);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @private
|
|
121
|
+
* @returns {void}
|
|
122
|
+
*/
|
|
123
|
+
openDialog() {
|
|
124
|
+
this.defaultTrigger = document.activeElement;
|
|
125
|
+
|
|
126
|
+
setTimeout(() => {
|
|
127
|
+
this.focus();
|
|
128
|
+
|
|
129
|
+
this.handleFocusLoss();
|
|
130
|
+
}, FOCUS_TIMEOUT);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @private
|
|
135
|
+
* @returns {void}
|
|
136
|
+
*/
|
|
137
|
+
closeDialog() {
|
|
138
|
+
this.dispatchToggleEvent();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @private
|
|
143
|
+
* @returns {void}
|
|
144
|
+
*/
|
|
145
|
+
dispatchToggleEvent() {
|
|
146
|
+
// replace with Event constructor once IE support dropped
|
|
147
|
+
const toggleEvent = document.createEvent("HTMLEvents");
|
|
148
|
+
|
|
149
|
+
toggleEvent.initEvent("toggle", true, false);
|
|
150
|
+
this.dispatchEvent(toggleEvent);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @private
|
|
155
|
+
* @returns {void} Determines if dropdown bib should be closed on focus change.
|
|
156
|
+
*/
|
|
157
|
+
handleFocusLoss() {
|
|
158
|
+
const focusable = [...this.querySelectorAll('button, auro-button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')];
|
|
159
|
+
|
|
160
|
+
const firstFocusableElement = focusable[0];
|
|
161
|
+
const lastFocusableElement = focusable[focusable.length - 1];
|
|
162
|
+
|
|
163
|
+
const closeButton = this.shadowRoot.getElementById('dialog-close');
|
|
164
|
+
|
|
165
|
+
lastFocusableElement.addEventListener('focusout', () => {
|
|
166
|
+
if (closeButton !== null) { // eslint-disable-line no-negated-condition
|
|
167
|
+
closeButton.focus();
|
|
168
|
+
} else {
|
|
169
|
+
firstFocusableElement.focus();
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @private
|
|
176
|
+
* @returns {void}
|
|
177
|
+
*/
|
|
178
|
+
handleOverlayClick() {
|
|
179
|
+
if (this.open && !this.modal) {
|
|
180
|
+
this.handleCloseButtonClick();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @private
|
|
186
|
+
* @returns {void}
|
|
187
|
+
*/
|
|
188
|
+
handleCloseButtonClick() {
|
|
189
|
+
this.open = false;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @private
|
|
194
|
+
* @param {KeyboardEvent} event - The keyboard event containing the key and keyCode.
|
|
195
|
+
* @returns {void}
|
|
196
|
+
*/
|
|
197
|
+
handleKeydown({ key, keyCode }) {
|
|
198
|
+
if (this.open && !this.modal && (key === 'Escape' || keyCode === ESCAPE_KEYCODE)) {
|
|
199
|
+
this.open = false;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Focus the dialog.
|
|
205
|
+
* @private
|
|
206
|
+
* @returns {void}
|
|
207
|
+
*/
|
|
208
|
+
focus() {
|
|
209
|
+
if (this.open) {
|
|
210
|
+
this.dialog.focus();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
static get styles() {
|
|
215
|
+
return [
|
|
216
|
+
styleCss,
|
|
217
|
+
styleCssFixed,
|
|
218
|
+
styleUnformattedCss,
|
|
219
|
+
styleUnformattedCssFixed
|
|
220
|
+
];
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @private
|
|
225
|
+
* @returns {TemplateResult} - The close button template.
|
|
226
|
+
*/
|
|
227
|
+
getCloseButton() {
|
|
228
|
+
return this.modal
|
|
229
|
+
? html``
|
|
230
|
+
: html`
|
|
231
|
+
<button class="dialog-header--action" id="dialog-close" @click="${this.handleCloseButtonClick}" part="close-button">
|
|
232
|
+
<span>${this.svg}</span>
|
|
233
|
+
<span class="util_displayHiddenVisually">Close</span>
|
|
234
|
+
</button>
|
|
235
|
+
`;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
render() {
|
|
239
|
+
const classes = {
|
|
240
|
+
'dialogOverlay': true,
|
|
241
|
+
'dialogOverlay--modal': this.modal && this.open,
|
|
242
|
+
'dialogOverlay--open': this.open,
|
|
243
|
+
'util_displayHidden': !this.open
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
contentClasses = {
|
|
247
|
+
'dialog': true,
|
|
248
|
+
'dialog--open': this.open
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
return html`
|
|
252
|
+
<div class="${classMap(classes)}" id="dialog-overlay" part="dialog-overlay" @click=${this.handleOverlayClick}></div>
|
|
253
|
+
|
|
254
|
+
<div role="dialog" id="dialog" class="${classMap(contentClasses)}" part="dialog" aria-labelledby="dialog-header" tabindex="-1">
|
|
255
|
+
${this.unformatted
|
|
256
|
+
? html`
|
|
257
|
+
<slot name="content"></slot>
|
|
258
|
+
${this.getCloseButton()}
|
|
259
|
+
`
|
|
260
|
+
: html`
|
|
261
|
+
<div class="dialog-header" part="dialog-header">
|
|
262
|
+
<h1 class="heading heading--700 util_stackMarginNone--top" id="dialog-header">
|
|
263
|
+
<slot name="header">Default header ...</slot>
|
|
264
|
+
</h1>
|
|
265
|
+
${this.getCloseButton()}
|
|
266
|
+
</div>
|
|
267
|
+
<div class="dialog-content" part="dialog-content">
|
|
268
|
+
<slot name="content"></slot>
|
|
269
|
+
</div>
|
|
270
|
+
<div class="dialog-footer" id="footerWrapper" part="dialog-footer">
|
|
271
|
+
<slot name="footer" id="footer"></slot>
|
|
272
|
+
</div>
|
|
273
|
+
`
|
|
274
|
+
}
|
|
275
|
+
</div>
|
|
276
|
+
`;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-css.d.ts","sourceRoot":"","sources":["../src/style-css.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-fixed-css.d.ts","sourceRoot":"","sources":["../src/style-fixed-css.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {css} from 'lit-element';
|
|
2
|
+
export default css`:host([fixed]) *,:host([fixed]) *:before,:host([fixed]) *:after{box-sizing:border-box}@media(prefers-reduced-motion: reduce){:host([fixed]) *,:host([fixed]) *:before,:host([fixed]) *:after{animation-duration:.01ms !important;animation-iteration-count:1 !important;transition-duration:.01ms !important}}:host([fixed]) *:focus-visible{outline:0}:host([fixed]) *:focus-visible{outline:0}:host([fixed]) :focus:not(:focus-visible){outline:3px solid transparent}:host([fixed]) .heading{margin:1.75rem 0;letter-spacing:var(--ds-text-heading-default-spacing, -0.2px);font-weight:var(--ds-text-heading-default-weight, 500)}:host([fixed]) .heading--display{margin-top:0;font-size:var(--ds-text-heading-display-size-breakpoint-sm, 2.75rem);font-weight:var(--ds-text-heading-display-weight, 100);line-height:var(--ds-text-heading-display-height-breakpoint-sm, 3.375rem)}@media screen and (min-width: 768px){:host([fixed]) .heading--display{font-size:var(--ds-text-heading-display-size-breakpoint-md, 3rem);line-height:var(--ds-text-heading-display-height-breakpoint-md, 3.75rem)}}@media screen and (min-width: 1024px){:host([fixed]) .heading--display{font-size:var(--ds-text-heading-display-size-breakpoint-lg, 3.5rem);line-height:var(--ds-text-heading-display-height-breakpoint-lg, 4.25rem)}}:host([fixed]) .heading--800{font-size:var(--ds-text-heading-800-size-breakpoint-sm, 2rem);font-weight:var(--ds-text-heading-800-weight, 500);line-height:var(--ds-text-heading-800-height-breakpoint-sm, 2.375rem)}@media screen and (min-width: 768px){:host([fixed]) .heading--800{font-size:var(--ds-text-heading-800-size-breakpoint-md, 2.25rem);line-height:var(--ds-text-heading-800-height-breakpoint-md, 2.625rem)}}@media screen and (min-width: 1024px){:host([fixed]) .heading--800{font-size:var(--ds-text-heading-800-size-breakpoint-lg, 2.5rem);line-height:var(--ds-text-heading-800-height-breakpoint-lg, 3rem)}}:host([fixed]) .heading--700{font-size:var(--ds-text-heading-700-size-breakpoint-sm, 1.75rem);font-weight:var(--ds-text-heading-700-weight, 500);line-height:var(--ds-text-heading-700-height-breakpoint-sm, 2.125rem)}@media screen and (min-width: 768px){:host([fixed]) .heading--700{font-size:var(--ds-text-heading-700-size-breakpoint-md, 2rem);line-height:var(--ds-text-heading-700-height-breakpoint-md, 2.375rem)}}@media screen and (min-width: 1024px){:host([fixed]) .heading--700{font-size:var(--ds-text-heading-700-size-breakpoint-lg, 2.25rem);line-height:var(--ds-text-heading-700-height-breakpoint-lg, 2.75rem)}}:host([fixed]) .heading--600{margin:1rem 0;font-size:var(--ds-text-heading-600-size-breakpoint-sm, 1.625rem);font-weight:var(--ds-text-heading-600-weight, 300);line-height:var(--ds-text-heading-600-height-breakpoint-sm, 1.875rem)}@media screen and (min-width: 768px){:host([fixed]) .heading--600{font-size:var(--ds-text-heading-600-size-breakpoint-md, 1.75rem);line-height:var(--ds-text-heading-600-height-breakpoint-md, 2.125rem)}}@media screen and (min-width: 1024px){:host([fixed]) .heading--600{font-size:var(--ds-text-heading-600-size-breakpoint-lg, 1.75rem);line-height:var(--ds-text-heading-600-height-breakpoint-lg, 2.25rem)}}:host([fixed]) .heading--500{margin:1rem 0;font-size:var(--ds-text-heading-500-size-breakpoint-sm, 1.375rem);font-weight:var(--ds-text-heading-500-weight, 300);line-height:var(--ds-text-heading-500-height-breakpoint-sm, 1.625rem)}@media screen and (min-width: 768px){:host([fixed]) .heading--500{font-size:var(--ds-text-heading-500-size-breakpoint-md, 1.5rem);line-height:var(--ds-text-heading-500-height-breakpoint-md, 1.875rem)}}@media screen and (min-width: 1024px){:host([fixed]) .heading--500{font-size:var(--ds-text-heading-500-size-breakpoint-lg, 1.5rem);line-height:var(--ds-text-heading-500-height-breakpoint-lg, 2rem)}}:host([fixed]) .heading--400{margin:.75rem 0;font-size:var(--ds-text-heading-400-size, 1.25rem);font-weight:var(--ds-text-heading-400-weight, 300);line-height:var(--ds-text-heading-400-height, 1.625rem)}:host([fixed]) .heading--300{margin:.75rem 0;font-size:var(--ds-text-heading-300-size, 1.125rem);font-weight:var(--ds-text-heading-300-weight, 300);line-height:var(--ds-text-heading-300-height, 1.625rem)}:host([fixed]) .util_displayInline{display:inline}:host([fixed]) .util_displayInlineBlock{display:inline-block}:host([fixed]) .util_displayBlock{display:block}:host([fixed]) .util_displayFlex{display:flex}:host([fixed]) .util_displayHidden{display:none}:host([fixed]) .util_displayHiddenVisually{position:absolute;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);width:1px;height:1px;padding:0;border:0}:host([fixed]) .util_inlinePaddingNone--left{padding-left:0}:host([fixed]) .util_inlinePaddingNone--right{padding-right:0}:host([fixed]) .util_inlineMarginNone--left{margin-left:0}:host([fixed]) .util_inlineMarginNone--right{margin-right:0}:host([fixed]) .util_inlinePadding25--left{padding-left:.125rem}:host([fixed]) .util_inlinePadding25--right{padding-right:.125rem}:host([fixed]) .util_inlineMargin25--left{margin-left:.125rem}:host([fixed]) .util_inlineMargin25--right{margin-right:.125rem}:host([fixed]) .util_inlinePadding50--left{padding-left:.25rem}:host([fixed]) .util_inlinePadding50--right{padding-right:.25rem}:host([fixed]) .util_inlineMargin50--left{margin-left:.25rem}:host([fixed]) .util_inlineMargin50--right{margin-right:.25rem}:host([fixed]) .util_inlinePadding100--left{padding-left:.5rem}:host([fixed]) .util_inlinePadding100--right{padding-right:.5rem}:host([fixed]) .util_inlineMargin100--left{margin-left:.5rem}:host([fixed]) .util_inlineMargin100--right{margin-right:.5rem}:host([fixed]) .util_inlinePadding200--left{padding-left:1rem}:host([fixed]) .util_inlinePadding200--right{padding-right:1rem}:host([fixed]) .util_inlineMargin200--left{margin-left:1rem}:host([fixed]) .util_inlineMargin200--right{margin-right:1rem}:host([fixed]) .util_inlinePadding300--left{padding-left:1.5rem}:host([fixed]) .util_inlinePadding300--right{padding-right:1.5rem}:host([fixed]) .util_inlineMargin300--left{margin-left:1.5rem}:host([fixed]) .util_inlineMargin300--right{margin-right:1.5rem}:host([fixed]) .util_inlinePadding400--left{padding-left:2rem}:host([fixed]) .util_inlinePadding400--right{padding-right:2rem}:host([fixed]) .util_inlineMargin400--left{margin-left:2rem}:host([fixed]) .util_inlineMargin400--right{margin-right:2rem}:host([fixed]) .util_inlinePadding500--left{padding-left:2.5rem}:host([fixed]) .util_inlinePadding500--right{padding-right:2.5rem}:host([fixed]) .util_inlineMargin500--left{margin-left:2.5rem}:host([fixed]) .util_inlineMargin500--right{margin-right:2.5rem}:host([fixed]) .util_inlinePadding600--left{padding-left:3rem}:host([fixed]) .util_inlinePadding600--right{padding-right:3rem}:host([fixed]) .util_inlineMargin600--left{margin-left:3rem}:host([fixed]) .util_inlineMargin600--right{margin-right:3rem}:host([fixed]) .util_inlinePadding700--left{padding-left:3.5rem}:host([fixed]) .util_inlinePadding700--right{padding-right:3.5rem}:host([fixed]) .util_inlineMargin700--left{margin-left:3.5rem}:host([fixed]) .util_inlineMargin700--right{margin-right:3.5rem}:host([fixed]) .util_inlinePadding800--left{padding-left:4rem}:host([fixed]) .util_inlinePadding800--right{padding-right:4rem}:host([fixed]) .util_inlineMargin800--left{margin-left:4rem}:host([fixed]) .util_inlineMargin800--right{margin-right:4rem}:host([fixed]) .util_inlinePadding900--left{padding-left:4.5rem}:host([fixed]) .util_inlinePadding900--right{padding-right:4.5rem}:host([fixed]) .util_inlineMargin900--left{margin-left:4.5rem}:host([fixed]) .util_inlineMargin900--right{margin-right:4.5rem}:host([fixed]) .util_inlinePadding1000--left{padding-left:5rem}:host([fixed]) .util_inlinePadding1000--right{padding-right:5rem}:host([fixed]) .util_inlineMargin1000--left{margin-left:5rem}:host([fixed]) .util_inlineMargin1000--right{margin-right:5rem}:host([fixed]) .util_stackPaddingNone--top{padding-top:0}:host([fixed]) .util_stackPaddingNone--bottom{padding-bottom:0}:host([fixed]) .util_stackMarginNone--top{margin-top:0}:host([fixed]) .util_stackMarginNone--bottom{margin-bottom:0}:host([fixed]) .util_stackPadding25--top{padding-top:.125rem}:host([fixed]) .util_stackPadding25--bottom{padding-bottom:.125rem}:host([fixed]) .util_stackMargin25--top{margin-top:.125rem}:host([fixed]) .util_stackMargin25--bottom{margin-bottom:.125rem}:host([fixed]) .util_stackPadding50--top{padding-top:.25rem}:host([fixed]) .util_stackPadding50--bottom{padding-bottom:.25rem}:host([fixed]) .util_stackMargin50--top{margin-top:.25rem}:host([fixed]) .util_stackMargin50--bottom{margin-bottom:.25rem}:host([fixed]) .util_stackPadding100--top{padding-top:.5rem}:host([fixed]) .util_stackPadding100--bottom{padding-bottom:.5rem}:host([fixed]) .util_stackMargin100--top{margin-top:.5rem}:host([fixed]) .util_stackMargin100--bottom{margin-bottom:.5rem}:host([fixed]) .util_stackPadding200--top{padding-top:1rem}:host([fixed]) .util_stackPadding200--bottom{padding-bottom:1rem}:host([fixed]) .util_stackMargin200--top{margin-top:1rem}:host([fixed]) .util_stackMargin200--bottom{margin-bottom:1rem}:host([fixed]) .util_stackPadding300--top{padding-top:1.5rem}:host([fixed]) .util_stackPadding300--bottom{padding-bottom:1.5rem}:host([fixed]) .util_stackMargin300--top{margin-top:1.5rem}:host([fixed]) .util_stackMargin300--bottom{margin-bottom:1.5rem}:host([fixed]) .util_stackPadding400--top{padding-top:2rem}:host([fixed]) .util_stackPadding400--bottom{padding-bottom:2rem}:host([fixed]) .util_stackMargin400--top{margin-top:2rem}:host([fixed]) .util_stackMargin400--bottom{margin-bottom:2rem}:host([fixed]) .util_stackPadding500--top{padding-top:2.5rem}:host([fixed]) .util_stackPadding500--bottom{padding-bottom:2.5rem}:host([fixed]) .util_stackMargin500--top{margin-top:2.5rem}:host([fixed]) .util_stackMargin500--bottom{margin-bottom:2.5rem}:host([fixed]) .util_stackPadding600--top{padding-top:3rem}:host([fixed]) .util_stackPadding600--bottom{padding-bottom:3rem}:host([fixed]) .util_stackMargin600--top{margin-top:3rem}:host([fixed]) .util_stackMargin600--bottom{margin-bottom:3rem}:host([fixed]) .util_stackPadding700--top{padding-top:3.5rem}:host([fixed]) .util_stackPadding700--bottom{padding-bottom:3.5rem}:host([fixed]) .util_stackMargin700--top{margin-top:3.5rem}:host([fixed]) .util_stackMargin700--bottom{margin-bottom:3.5rem}:host([fixed]) .util_stackPadding800--top{padding-top:4rem}:host([fixed]) .util_stackPadding800--bottom{padding-bottom:4rem}:host([fixed]) .util_stackMargin800--top{margin-top:4rem}:host([fixed]) .util_stackMargin800--bottom{margin-bottom:4rem}:host([fixed]) .util_stackPadding900--top{padding-top:4.5rem}:host([fixed]) .util_stackPadding900--bottom{padding-bottom:4.5rem}:host([fixed]) .util_stackMargin900--top{margin-top:4.5rem}:host([fixed]) .util_stackMargin900--bottom{margin-bottom:4.5rem}:host([fixed]) .util_stackPadding1000--top{padding-top:5rem}:host([fixed]) .util_stackPadding1000--bottom{padding-bottom:5rem}:host([fixed]) .util_stackMargin1000--top{margin-top:5rem}:host([fixed]) .util_stackMargin1000--bottom{margin-bottom:5rem}:host([fixed]) :host{--insetPaddingXl:0 var(--ds-size-400, $ds-size-400) var(--ds-size-400, $ds-size-400) var(--ds-size-400, $ds-size-400);--insetPaddingXxl:0 var(--ds-size-600, $ds-size-600) var(--ds-size-600, $ds-size-600) var(--ds-size-600, $ds-size-600);--insetPaddingXxxl:0 var(--ds-size-800, $ds-size-800) var(--ds-size-800, $ds-size-800) var(--ds-size-800, $ds-size-800)}:host([fixed]) .dialogOverlay{position:fixed;z-index:-1;bottom:0;left:0;width:100%;height:100%}:host([fixed]) .dialogOverlay--open{z-index:var(--ds-depth-overlay);transition:background .3s cubic-bezier(0.4, 0, 0.2, 0);background:rgba(0, 0, 0, 0.2)}:host([fixed]) .dialogOverlay--modal{z-index:var(--ds-depth-overlay);transition:background .3s cubic-bezier(0.4, 0, 0.5, 0);background:rgba(0, 0, 0, 0.5)}:host([fixed]) .dialog{position:fixed;z-index:-1;right:0;bottom:0;left:0;display:block;visibility:hidden;overflow:visible;width:100%;max-height:90%;padding:var(--insetPaddingXl);transform:translateY(100%);opacity:0;border:0;background:var(--ds-color-background-lightest, #ffffff);color:var(--ds-color-text-primary-default, #222222);transition:all .3s ease-in-out}@media screen and (min-width: 768px){:host([fixed]) .dialog{top:10%;bottom:unset;max-width:80%;max-height:80%;margin:auto;padding:var(--insetPaddingXxxl);transform:scale(0);box-shadow:0 10px 20px 0 rgba(0, 0, 0, 0.12),0 1px 10px 0 rgba(0, 0, 0, 0.1)}:host([fixed]) .dialog--open{transform:scale(1)}}@media screen and (min-width: 1024px){:host([fixed]) .dialog{max-width:986px}}:host([fixed]) .dialog--open{z-index:var(--ds-depth-modal, 400);visibility:visible;transform:translateY(0%);opacity:1}:host([fixed]) .dialog-footer{padding-top:var(--ds-size-400, 2rem)}@media screen and (min-width: 768px){:host([fixed]) .dialog-footer ::slotted(*){display:flex;justify-content:flex-end}}:host([fixed]) .dialog-header{display:flex;align-items:flex-start;justify-content:space-between;padding-top:var(--ds-size-800, 4rem)}:host([fixed]) .dialog-header svg{fill:var(--ds-color-text-secondary-default, #626b79)}:host([fixed]) .dialog-header--action{margin:0;padding:0;border:none;border:2px solid transparent;border-radius:var(--ds-border-radius, 0.375rem);background-color:transparent}:host([fixed]) .dialog-header--action:hover{cursor:pointer}:host([fixed]) ::slotted([slot=content]){position:relative}:host([fixed]) :host([unformatted]) .dialog-header--action{position:absolute;top:var(--ds-size-400, 2rem);right:var(--ds-size-400, 2rem)}@media screen and (min-width: 768px){:host([fixed]) :host([unformatted]) .dialog-header--action{top:var(--ds-size-800, 4rem);right:var(--ds-size-800, 4rem)}}:host([fixed]) :host([unformatted][onDark]) .dialog-header--action{color:var(--ds-color-base-white, #ffffff)}:host([fixed]) :host([sm]) .dialog{max-height:30%}@media screen and (min-width: 768px){:host([fixed]) :host([sm]) .dialog{top:10%;max-width:40%;max-height:80%;padding:var(--insetPaddingXxl)}}@media screen and (min-width: 1024px){:host([fixed]) :host([sm]) .dialog{max-width:740px}}:host([fixed]) :host([md]) .dialog{max-height:50%}@media screen and (min-width: 768px){:host([fixed]) :host([md]) .dialog{top:10%;max-width:70%;max-height:80%}}@media screen and (min-width: 1024px){:host([fixed]) :host([md]) .dialog{top:10%;max-width:986px}}@media screen and (min-width: 768px){:host([fixed]) :host([sm][lg]) .dialog,:host([fixed]) :host([md][lg]) .dialog{max-height:80%}}:host([fixed]) :host([sm][lg]) .dialog,:host([fixed]) :host([md][lg]) .dialog{max-height:90%}:host([fixed]) :host([unformatted]) .dialog{padding:0}`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-unformatted-css.d.ts","sourceRoot":"","sources":["../src/style-unformatted-css.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-unformatted-fixed-css.d.ts","sourceRoot":"","sources":["../src/style-unformatted-fixed-css.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {css} from 'lit-element';
|
|
2
|
+
export default css`:host([fixed]) [unformatted] .unformattedWrapper{padding:var(--ds-size-400, 2rem)}@media screen and (min-width: 768px){:host([fixed]) [unformatted] .unformattedWrapper{padding:var(--ds-size-800, 4rem);padding-top:var(--ds-size-400, 2rem)}}`;
|
package/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AuroDialog } from './src/auro-dialog';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Register Custom Element.
|
|
5
|
+
* @param {Object} name - Name to use for custom element.
|
|
6
|
+
* @returns {void}
|
|
7
|
+
*/
|
|
8
|
+
const registerComponent = (name = 'custom-dialog') => {
|
|
9
|
+
// alias definition
|
|
10
|
+
if (!customElements.get(name)) {
|
|
11
|
+
customElements.define(name, class extends AuroDialog {});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { registerComponent }
|
package/package.json
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
{
|
|
2
|
+
"//": [
|
|
3
|
+
"================================================================================",
|
|
4
|
+
"# To work within the development environment, run the following tasks",
|
|
5
|
+
" 1. $ npm run dev",
|
|
6
|
+
" 2. Go to http://localhost:8000",
|
|
7
|
+
"================================================================================"
|
|
8
|
+
],
|
|
9
|
+
"name": "@aurodesignsystem/auro-dialog",
|
|
10
|
+
"version": "1.0.0",
|
|
11
|
+
"description": "auro-dialog HTML custom element",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/AlaskaAirlines/auro-dialog"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "index.js",
|
|
18
|
+
"license": "Apache-2.0",
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": "^18.x || ^20.x"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"chalk": "^5.3.0",
|
|
24
|
+
"lit": "^3.1.1"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@aurodesignsystem/design-tokens": "^4.3.0",
|
|
28
|
+
"@aurodesignsystem/webcorestylesheets": "^5.0.5"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@alaskaairux/icons": "^4.32.0",
|
|
32
|
+
"@aurodesignsystem/auro-library": "^2.2.6",
|
|
33
|
+
"@aurodesignsystem/design-tokens": "^4.3.0",
|
|
34
|
+
"@aurodesignsystem/eslint-config": "^1.3.0",
|
|
35
|
+
"@aurodesignsystem/webcorestylesheets": "^5.0.5",
|
|
36
|
+
"@commitlint/cli": "^18.5.0",
|
|
37
|
+
"@commitlint/config-conventional": "^18.5.0",
|
|
38
|
+
"@open-wc/testing": "^4.0.0",
|
|
39
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
40
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
41
|
+
"@semantic-release/git": "^10.0.1",
|
|
42
|
+
"@semantic-release/npm": "^11.0.2",
|
|
43
|
+
"@web/dev-server": "^0.4.1",
|
|
44
|
+
"@web/test-runner": "^0.18.0",
|
|
45
|
+
"autoprefixer": "^10.4.17",
|
|
46
|
+
"compression": "^1.7.4",
|
|
47
|
+
"concat": "^1.0.3",
|
|
48
|
+
"concurrently": "^8.2.2",
|
|
49
|
+
"copyfiles": "^2.4.1",
|
|
50
|
+
"core-js": "^3.35.1",
|
|
51
|
+
"eslint": "^8.56.0",
|
|
52
|
+
"eslint-plugin-jsdoc": "^48.0.2",
|
|
53
|
+
"husky": "^8.0.0",
|
|
54
|
+
"lodash": "^4.17.21",
|
|
55
|
+
"markdown-magic": "^2.6.1",
|
|
56
|
+
"nodemon": "^3.0.3",
|
|
57
|
+
"npm-run-all": "^4.1.5",
|
|
58
|
+
"postcss": "^8.4.33",
|
|
59
|
+
"postcss-discard-comments": "^6.0.1",
|
|
60
|
+
"postcss-selector-replace": "^1.0.2",
|
|
61
|
+
"rollup": "^4.9.6",
|
|
62
|
+
"rollup-plugin-serve": "^1.1.1",
|
|
63
|
+
"sass": "^1.70.0",
|
|
64
|
+
"semantic-release": "^23.0.0",
|
|
65
|
+
"stylelint": "^16.2.0",
|
|
66
|
+
"stylelint-config-idiomatic-order": "^10.0.0",
|
|
67
|
+
"stylelint-config-standard": "^36.0.0",
|
|
68
|
+
"stylelint-config-standard-scss": "^13.0.0",
|
|
69
|
+
"stylelint-order": "^6.0.4",
|
|
70
|
+
"stylelint-scss": "^6.1.0",
|
|
71
|
+
"typescript": "^5.3.3",
|
|
72
|
+
"wc-sass-render": "^1.4.0",
|
|
73
|
+
"web-component-analyzer": "^2.0.0",
|
|
74
|
+
"whatwg-fetch": "^3.6.20",
|
|
75
|
+
"yaml-lint": "^1.7.0"
|
|
76
|
+
},
|
|
77
|
+
"overrides": {
|
|
78
|
+
"wc-sass-render": {
|
|
79
|
+
"sass": "$sass"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"browserslist": [
|
|
83
|
+
"last 2 Chrome versions",
|
|
84
|
+
"last 2 iOS major versions",
|
|
85
|
+
"last 2 Firefox versions",
|
|
86
|
+
"last 2 Edge versions",
|
|
87
|
+
"last 2 Safari major versions"
|
|
88
|
+
],
|
|
89
|
+
"nodemonConfig": {
|
|
90
|
+
"ignore": [
|
|
91
|
+
"*-css.js",
|
|
92
|
+
"*.css"
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
"release": {
|
|
96
|
+
"branches": [
|
|
97
|
+
"main"
|
|
98
|
+
],
|
|
99
|
+
"plugins": [
|
|
100
|
+
"@semantic-release/commit-analyzer",
|
|
101
|
+
"@semantic-release/release-notes-generator",
|
|
102
|
+
[
|
|
103
|
+
"@semantic-release/changelog",
|
|
104
|
+
{
|
|
105
|
+
"changelogFile": "./CHANGELOG.md",
|
|
106
|
+
"changelogTitle": "# Semantic Release Automated Changelog"
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"@semantic-release/npm",
|
|
110
|
+
[
|
|
111
|
+
"@semantic-release/git",
|
|
112
|
+
{
|
|
113
|
+
"assets": [
|
|
114
|
+
"./package.json",
|
|
115
|
+
"./CHANGELOG.md",
|
|
116
|
+
"./README.md",
|
|
117
|
+
"./docs/api.md"
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
"@semantic-release/github"
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
"publishConfig": {
|
|
125
|
+
"access": "public"
|
|
126
|
+
},
|
|
127
|
+
"keywords": [
|
|
128
|
+
"alaska airlines",
|
|
129
|
+
"auro",
|
|
130
|
+
"design system",
|
|
131
|
+
"web components"
|
|
132
|
+
],
|
|
133
|
+
"scripts": {
|
|
134
|
+
"build": "npm-run-all build:sass sass:render scssLint dist:js bundler build:api build:docs postinstall types",
|
|
135
|
+
"build:ci": "npm-run-all sweep build",
|
|
136
|
+
"build:api": "wca analyze 'src/auro-dialog.js' --outFiles docs/api.md",
|
|
137
|
+
"build:dev:assets": "npm-run-all build:sass:component postCss:component sass:render build:docs",
|
|
138
|
+
"build:docs": "node scripts/generateDocs.mjs",
|
|
139
|
+
"build:sass": "npm-run-all build:sass:component postCss:component sass:render",
|
|
140
|
+
"build:sass:component": "sass --no-source-map src:src",
|
|
141
|
+
"build:watch": "nodemon -e scss,js,html --watch src --watch apiExamples/**/* --exec npm run build:dev:assets",
|
|
142
|
+
"bundler": "rollup -c",
|
|
143
|
+
"bundler:test": "rollup -c -w",
|
|
144
|
+
"scssLint": "stylelint \"./src/**/*.scss\"",
|
|
145
|
+
"dev": "concurrently --kill-others \"npm run build:watch\" \"npm run serve\"",
|
|
146
|
+
"dist:js": "copyfiles -u 1 -V './src/**/*.js' ./dist",
|
|
147
|
+
"esLint": "./node_modules/.bin/eslint src/**/*.js",
|
|
148
|
+
"linters": "npm-run-all scssLint esLint",
|
|
149
|
+
"preCommit": "node scripts/pre-commit.mjs",
|
|
150
|
+
"postCss:component": "node scripts/postCss.mjs",
|
|
151
|
+
"postinstall": "node packageScripts/postinstall.mjs",
|
|
152
|
+
"sass:render": "sass-render src/*.css -t ./scripts/staticStyles-template.js",
|
|
153
|
+
"serve": "web-dev-server --open demo/ --node-resolve --watch",
|
|
154
|
+
"sweep": "rm -rf ./demo/css ./dist | rm ./src/*.css ./src/*-css.js",
|
|
155
|
+
"test": "wtr --coverage",
|
|
156
|
+
"test:watch": "wtr --watch",
|
|
157
|
+
"types": "tsc",
|
|
158
|
+
"prepare": "husky install"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
const pjson = require('../package.json');
|
|
7
|
+
|
|
8
|
+
console.log(chalk.hex('#f26135')(`
|
|
9
|
+
|
|
10
|
+
_______ __ __ __
|
|
11
|
+
| __|.---.-.--.--. | |--.-----.| | |.-----.
|
|
12
|
+
|__ || _ | | | | | -__|| | || _ |
|
|
13
|
+
|_______||___._|___ | |__|__|_____||__|__||_____|
|
|
14
|
+
|_____|
|
|
15
|
+
__ _______ __
|
|
16
|
+
| |_.-----. | _ |.--.--.----.-----.| |
|
|
17
|
+
| _| _ | | || | | _| _ ||__|
|
|
18
|
+
|____|_____| |___|___||_____|__| |_____||__|
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
╭ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ──────────────────────────────╮
|
|
22
|
+
|
|
23
|
+
Thanks for installing the latest version
|
|
24
|
+
of `) + chalk.hex('#ffd200').bold(`${pjson.name} v${pjson.version}.`) + chalk.hex('#f26135')(`
|
|
25
|
+
|
|
26
|
+
╰─────────────────────────────── ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
|
|
27
|
+
`)
|
|
28
|
+
);
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
import ComponentBase from './componentBase';
|
|
7
|
+
|
|
8
|
+
// build the component class
|
|
9
|
+
export class AuroDialog extends ComponentBase {
|
|
10
|
+
// constructor() {
|
|
11
|
+
// super();
|
|
12
|
+
// }
|
|
13
|
+
|
|
14
|
+
// function to define props used within the scope of this component
|
|
15
|
+
static get properties() {
|
|
16
|
+
return {
|
|
17
|
+
...super.properties,
|
|
18
|
+
// use custom accessors on base class
|
|
19
|
+
open: {
|
|
20
|
+
...super.properties.open,
|
|
21
|
+
noAccessor: true
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static get styles() {
|
|
27
|
+
return [super.styles];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* istanbul ignore else */
|
|
32
|
+
// define the name of the custom component
|
|
33
|
+
if (!customElements.get("auro-dialog")) {
|
|
34
|
+
customElements.define("auro-dialog", AuroDialog);
|
|
35
|
+
}
|
|
36
|
+
|