@aurodesignsystem/auro-dialog 2.0.1 → 2.2.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/CHANGELOG.md +25 -0
- package/demo/api.js +3 -0
- package/demo/api.min.js +338 -0
- package/demo/index.js +5 -0
- package/demo/index.md +3 -4
- package/demo/index.min.js +339 -0
- package/dist/auro-dialog.d.ts +9 -0
- package/dist/auro-dialog.d.ts.map +1 -1
- package/dist/auro-dialog__bundled.js +108 -82
- package/dist/buttonVersion.d.ts +1 -1
- package/dist/iconVersion.d.ts +1 -1
- package/index.js +1 -2
- package/package.json +16 -16
- package/src/auro-dialog.js +12 -6
- package/src/buttonVersion.js +1 -1
- package/src/componentBase.js +1 -1
- package/src/iconVersion.js +1 -1
- package/src/style-css.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Semantic Release Automated Changelog
|
|
2
2
|
|
|
3
|
+
# [2.2.0](https://github.com/AlaskaAirlines/auro-dialog/compare/v2.1.0...v2.2.0) (2024-11-01)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* apply latest token ds-auro-icon-size [#28](https://github.com/AlaskaAirlines/auro-dialog/issues/28) ([a0f0f45](https://github.com/AlaskaAirlines/auro-dialog/commit/a0f0f451866f435e12e769dafdadffe056927973))
|
|
9
|
+
* update auro-icon package [#28](https://github.com/AlaskaAirlines/auro-dialog/issues/28) ([7eb9665](https://github.com/AlaskaAirlines/auro-dialog/commit/7eb96656f66fa619f0a0d38ef4d126c4e7f68d7d))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Performance Improvements
|
|
13
|
+
|
|
14
|
+
* update dependencies ([af459cf](https://github.com/AlaskaAirlines/auro-dialog/commit/af459cfd5db990bb930df17facbad18bd24ae4fd))
|
|
15
|
+
|
|
16
|
+
# [2.1.0](https://github.com/AlaskaAirlines/auro-dialog/compare/v2.0.1...v2.1.0) (2024-10-25)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* **api:** add register static method [#26](https://github.com/AlaskaAirlines/auro-dialog/issues/26) ([a5882af](https://github.com/AlaskaAirlines/auro-dialog/commit/a5882af95970c0973bd97eed2a86c653948c8ef3))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Performance Improvements
|
|
25
|
+
|
|
26
|
+
* update dependency versions ([ac77559](https://github.com/AlaskaAirlines/auro-dialog/commit/ac775591e2aa2bbd07a06e90434410f4398684ae))
|
|
27
|
+
|
|
3
28
|
## [2.0.1](https://github.com/AlaskaAirlines/auro-dialog/compare/v2.0.0...v2.0.1) (2024-10-08)
|
|
4
29
|
|
|
5
30
|
|
package/demo/api.js
CHANGED
|
@@ -5,6 +5,9 @@ import { initEditCloseButtonExample } from "../apiExamples/editCloseButton";
|
|
|
5
5
|
import { initModalExample } from "../apiExamples/modal";
|
|
6
6
|
import { initPopoverAndDropdownExample } from "../apiExamples/popoverAndDropdown";
|
|
7
7
|
import { initSizeOptionsExample } from "../apiExamples/sizeOptions";
|
|
8
|
+
import { AuroDialog } from '../src/auro-dialog.js';
|
|
9
|
+
|
|
10
|
+
AuroDialog.register();
|
|
8
11
|
|
|
9
12
|
export function initExamples(initCount) {
|
|
10
13
|
initCount = initCount || 0;
|
package/demo/api.min.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import AuroLibraryRuntimeUtils from '@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs';
|
|
2
|
+
import { css, LitElement } from 'lit';
|
|
3
|
+
import { html } from 'lit/static-html.js';
|
|
4
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
5
|
+
import { AuroDependencyVersioning } from '@aurodesignsystem/auro-library/scripts/runtime/dependencyTagVersioning.mjs';
|
|
6
|
+
import { AuroButton } from '@aurodesignsystem/auro-button/src/auro-button.js';
|
|
7
|
+
import { AuroIcon } from '@aurodesignsystem/auro-icon/src/auro-icon.js';
|
|
8
|
+
|
|
1
9
|
function initBasicExample() {
|
|
2
10
|
const buttons = [document.querySelector('#openBasic'), document.querySelector('#closeBasic')];
|
|
3
11
|
const dialog = document.querySelector('#defaultDialog');
|
|
@@ -164,6 +172,336 @@ function initSizeOptionsExample() {
|
|
|
164
172
|
});
|
|
165
173
|
}
|
|
166
174
|
|
|
175
|
+
var styleCss = css`*,*:before,*:after{box-sizing:border-box}@media(prefers-reduced-motion: reduce){*,*:before,*:after{animation-duration:.01ms !important;animation-iteration-count:1 !important;transition-duration:.01ms !important}}*:focus-visible{outline:0}*:focus-visible{outline:0}:focus:not(:focus-visible){outline:3px solid transparent}.heading{margin:1.75rem 0;letter-spacing:var(--ds-text-heading-default-spacing, -0.2px);font-weight:var(--ds-text-heading-default-weight, 500)}.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){.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){.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)}}.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){.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){.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)}}.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){.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){.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)}}.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){.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){.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)}}.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){.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){.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)}}.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)}.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)}.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock{display:block}.util_displayFlex{display:flex}.util_displayHidden{display:none}.util_displayHiddenVisually{position:absolute;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);width:1px;height:1px;padding:0;border:0}.util_inlinePaddingNone--left{padding-left:0}.util_inlinePaddingNone--right{padding-right:0}.util_inlineMarginNone--left{margin-left:0}.util_inlineMarginNone--right{margin-right:0}.util_inlinePadding25--left{padding-left:.125rem}.util_inlinePadding25--right{padding-right:.125rem}.util_inlineMargin25--left{margin-left:.125rem}.util_inlineMargin25--right{margin-right:.125rem}.util_inlinePadding50--left{padding-left:.25rem}.util_inlinePadding50--right{padding-right:.25rem}.util_inlineMargin50--left{margin-left:.25rem}.util_inlineMargin50--right{margin-right:.25rem}.util_inlinePadding100--left{padding-left:.5rem}.util_inlinePadding100--right{padding-right:.5rem}.util_inlineMargin100--left{margin-left:.5rem}.util_inlineMargin100--right{margin-right:.5rem}.util_inlinePadding200--left{padding-left:1rem}.util_inlinePadding200--right{padding-right:1rem}.util_inlineMargin200--left{margin-left:1rem}.util_inlineMargin200--right{margin-right:1rem}.util_inlinePadding300--left{padding-left:1.5rem}.util_inlinePadding300--right{padding-right:1.5rem}.util_inlineMargin300--left{margin-left:1.5rem}.util_inlineMargin300--right{margin-right:1.5rem}.util_inlinePadding400--left{padding-left:2rem}.util_inlinePadding400--right{padding-right:2rem}.util_inlineMargin400--left{margin-left:2rem}.util_inlineMargin400--right{margin-right:2rem}.util_inlinePadding500--left{padding-left:2.5rem}.util_inlinePadding500--right{padding-right:2.5rem}.util_inlineMargin500--left{margin-left:2.5rem}.util_inlineMargin500--right{margin-right:2.5rem}.util_inlinePadding600--left{padding-left:3rem}.util_inlinePadding600--right{padding-right:3rem}.util_inlineMargin600--left{margin-left:3rem}.util_inlineMargin600--right{margin-right:3rem}.util_inlinePadding700--left{padding-left:3.5rem}.util_inlinePadding700--right{padding-right:3.5rem}.util_inlineMargin700--left{margin-left:3.5rem}.util_inlineMargin700--right{margin-right:3.5rem}.util_inlinePadding800--left{padding-left:4rem}.util_inlinePadding800--right{padding-right:4rem}.util_inlineMargin800--left{margin-left:4rem}.util_inlineMargin800--right{margin-right:4rem}.util_inlinePadding900--left{padding-left:4.5rem}.util_inlinePadding900--right{padding-right:4.5rem}.util_inlineMargin900--left{margin-left:4.5rem}.util_inlineMargin900--right{margin-right:4.5rem}.util_inlinePadding1000--left{padding-left:5rem}.util_inlinePadding1000--right{padding-right:5rem}.util_inlineMargin1000--left{margin-left:5rem}.util_inlineMargin1000--right{margin-right:5rem}.util_stackPaddingNone--top{padding-top:0}.util_stackPaddingNone--bottom{padding-bottom:0}.util_stackMarginNone--top{margin-top:0}.util_stackMarginNone--bottom{margin-bottom:0}.util_stackPadding25--top{padding-top:.125rem}.util_stackPadding25--bottom{padding-bottom:.125rem}.util_stackMargin25--top{margin-top:.125rem}.util_stackMargin25--bottom{margin-bottom:.125rem}.util_stackPadding50--top{padding-top:.25rem}.util_stackPadding50--bottom{padding-bottom:.25rem}.util_stackMargin50--top{margin-top:.25rem}.util_stackMargin50--bottom{margin-bottom:.25rem}.util_stackPadding100--top{padding-top:.5rem}.util_stackPadding100--bottom{padding-bottom:.5rem}.util_stackMargin100--top{margin-top:.5rem}.util_stackMargin100--bottom{margin-bottom:.5rem}.util_stackPadding200--top{padding-top:1rem}.util_stackPadding200--bottom{padding-bottom:1rem}.util_stackMargin200--top{margin-top:1rem}.util_stackMargin200--bottom{margin-bottom:1rem}.util_stackPadding300--top{padding-top:1.5rem}.util_stackPadding300--bottom{padding-bottom:1.5rem}.util_stackMargin300--top{margin-top:1.5rem}.util_stackMargin300--bottom{margin-bottom:1.5rem}.util_stackPadding400--top{padding-top:2rem}.util_stackPadding400--bottom{padding-bottom:2rem}.util_stackMargin400--top{margin-top:2rem}.util_stackMargin400--bottom{margin-bottom:2rem}.util_stackPadding500--top{padding-top:2.5rem}.util_stackPadding500--bottom{padding-bottom:2.5rem}.util_stackMargin500--top{margin-top:2.5rem}.util_stackMargin500--bottom{margin-bottom:2.5rem}.util_stackPadding600--top{padding-top:3rem}.util_stackPadding600--bottom{padding-bottom:3rem}.util_stackMargin600--top{margin-top:3rem}.util_stackMargin600--bottom{margin-bottom:3rem}.util_stackPadding700--top{padding-top:3.5rem}.util_stackPadding700--bottom{padding-bottom:3.5rem}.util_stackMargin700--top{margin-top:3.5rem}.util_stackMargin700--bottom{margin-bottom:3.5rem}.util_stackPadding800--top{padding-top:4rem}.util_stackPadding800--bottom{padding-bottom:4rem}.util_stackMargin800--top{margin-top:4rem}.util_stackMargin800--bottom{margin-bottom:4rem}.util_stackPadding900--top{padding-top:4.5rem}.util_stackPadding900--bottom{padding-bottom:4.5rem}.util_stackMargin900--top{margin-top:4.5rem}.util_stackMargin900--bottom{margin-bottom:4.5rem}.util_stackPadding1000--top{padding-top:5rem}.util_stackPadding1000--bottom{padding-bottom:5rem}.util_stackMargin1000--top{margin-top:5rem}.util_stackMargin1000--bottom{margin-bottom:5rem}: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)}[auro-icon]{--ds-auro-icon-size: var(--ds-size-300, $ds-size-300)}.dialogOverlay{position:fixed;z-index:-1;bottom:0;left:0;width:100%;height:100%}.dialogOverlay--open{z-index:var(--ds-depth-overlay);transition:background .3s cubic-bezier(0.4, 0, 0.2, 0)}.dialogOverlay--modal{z-index:var(--ds-depth-overlay);transition:background .3s cubic-bezier(0.4, 0, 0.5, 0)}.dialog{position:fixed;z-index:-1;right:0;bottom:0;left:0;display:flex;flex-direction:column;visibility:hidden;overflow:visible;width:100%;max-height:90%;padding:var(--insetPaddingXl);transform:translateY(100%);opacity:0;border:0;transition:all .3s ease-in-out}@media screen and (min-width: 768px){.dialog{top:10%;bottom:unset;max-width:80%;max-height:80%;margin:auto;padding:var(--insetPaddingXxxl);transform:scale(0)}.dialog--open{transform:scale(1)}}@media screen and (min-width: 1024px){.dialog{max-width:986px}}.dialog--open{z-index:var(--ds-depth-modal, 400);visibility:visible;transform:translateY(0%);opacity:1}.dialog-footer{padding-top:var(--ds-size-400, 2rem)}@media screen and (min-width: 768px){.dialog-footer ::slotted(*){display:flex;justify-content:flex-end}}.dialog-header{display:flex;align-items:flex-start;justify-content:space-between;padding-top:var(--ds-size-800, 4rem)}.dialog-header--action{margin:0;padding:0}.dialog-header--action:hover{cursor:pointer}.dialog-content{flex:1;overflow:auto;overscroll-behavior:contain}::slotted([slot=content]){position:relative}: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([unformatted]) .dialog-header--action{top:var(--ds-size-800, 4rem);right:var(--ds-size-800, 4rem)}}:host([sm]) .dialog{max-height:30%}@media screen and (min-width: 768px){:host([sm]) .dialog{top:10%;max-width:40%;max-height:80%;padding:var(--insetPaddingXxl)}}@media screen and (min-width: 1024px){:host([sm]) .dialog{max-width:740px}}:host([md]) .dialog{max-height:50%}@media screen and (min-width: 768px){:host([md]) .dialog{top:10%;max-width:70%;max-height:80%}}@media screen and (min-width: 1024px){:host([md]) .dialog{top:10%;max-width:986px}}@media screen and (min-width: 768px){:host([sm][lg]) .dialog,:host([md][lg]) .dialog{max-height:80%}}:host([sm][lg]) .dialog,:host([md][lg]) .dialog{max-height:90%}:host([unformatted]) .dialog{padding:0}`;
|
|
176
|
+
|
|
177
|
+
var styleUnformattedCss = css`[unformatted] .unformattedWrapper{padding:var(--ds-size-400, 2rem)}@media screen and (min-width: 768px){[unformatted] .unformattedWrapper{padding:var(--ds-size-800, 4rem);padding-top:var(--ds-size-400, 2rem)}}`;
|
|
178
|
+
|
|
179
|
+
var colorCss = css`.dialogOverlay--open{background:var(--ds-auro-dialog-overlay-open-background-color)}.dialogOverlay--modal{background:var(--ds-auro-dialog-overlay-modal-background-color)}.dialog{background:var(--ds-auro-dialog-container-color);color:var(--ds-auro-dialog-text-color)}@media screen and (min-width: 768px){.dialog{box-shadow:var(--ds-auro-dialog-boxshadow-color)}}.dialog-header--action{border:2px solid transparent;border-radius:var(--ds-border-radius, 0.375rem);background-color:transparent}`;
|
|
180
|
+
|
|
181
|
+
var tokensCss = css`:host{--ds-auro-dialog-container-color: var(--ds-color-container-primary-default, #ffffff);--ds-auro-dialog-boxshadow-color: var(--ds-elevation-300, 0px 0px 15px rgba(0, 0, 0, 0.2));--ds-auro-dialog-overlay-modal-background-color: var(--ds-color-background-scrimmed-default, rgba(0, 0, 0, 0.5));--ds-auro-dialog-overlay-open-background-color: var(--ds-color-background-scrimmed-default, rgba(0, 0, 0, 0.5));--ds-auro-dialog-text-color: var(--ds-color-text-primary-default, #2a2a2a)}`;
|
|
182
|
+
|
|
183
|
+
var buttonVersion = '8.1.0';
|
|
184
|
+
|
|
185
|
+
var iconVersion = '6.0.1';
|
|
186
|
+
|
|
187
|
+
// Copyright (c) 2024 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
188
|
+
// See LICENSE in the project root for license information.
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
const ESCAPE_KEYCODE = 27,
|
|
192
|
+
FOCUS_TIMEOUT = 50;
|
|
193
|
+
|
|
194
|
+
// See https://git.io/JJ6SJ for "How to document your components using JSDoc"
|
|
195
|
+
/**
|
|
196
|
+
* auro-dialog appear above the page and require the user's attention.
|
|
197
|
+
*
|
|
198
|
+
* @attr {Boolean} modal - Modal dialog restricts the user to take an action (no default close actions)
|
|
199
|
+
* @attr {Boolean} unformatted - Unformatted dialog window, edge-to-edge fill for content
|
|
200
|
+
* @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.
|
|
201
|
+
* @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.
|
|
202
|
+
* @attr {Boolean} onDark - Sets close icon to white for dark backgrounds
|
|
203
|
+
* @attr {Boolean} open - Sets state of dialog to open
|
|
204
|
+
* @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.
|
|
205
|
+
* @slot header - Text to display as the header of the modal
|
|
206
|
+
* @slot content - Injects content into the body of the modal
|
|
207
|
+
* @slot footer - Used for action options, e.g. buttons
|
|
208
|
+
* @function toggleViewable - toggles the 'open' property on the element
|
|
209
|
+
* @event toggle - Event fires when the element is closed
|
|
210
|
+
* @csspart close-button - adjust position of the close X icon in the dialog window
|
|
211
|
+
* @csspart dialog-overlay - apply CSS on the overlay of the dialog
|
|
212
|
+
* @csspart dialog - apply CSS to the entire dialog
|
|
213
|
+
* @csspart dialog-header - apply CSS to the header of the dialog
|
|
214
|
+
* @csspart dialog-content - apply CSS to the content of the dialog
|
|
215
|
+
* @csspart dialog-footer - apply CSS to the footer of the dialog
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
class ComponentBase extends LitElement {
|
|
219
|
+
constructor() {
|
|
220
|
+
super();
|
|
221
|
+
|
|
222
|
+
this.modal = false;
|
|
223
|
+
this.unformatted = false;
|
|
224
|
+
|
|
225
|
+
const versioning = new AuroDependencyVersioning();
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @private
|
|
229
|
+
*/
|
|
230
|
+
this.buttonTag = versioning.generateTag('auro-button', buttonVersion, AuroButton);
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* @private
|
|
234
|
+
*/
|
|
235
|
+
this.iconTag = versioning.generateTag('auro-icon', iconVersion, AuroIcon);
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* @private
|
|
240
|
+
*/
|
|
241
|
+
this.runtimeUtils = new AuroLibraryRuntimeUtils();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
static get properties() {
|
|
245
|
+
return {
|
|
246
|
+
modal: { type: Boolean },
|
|
247
|
+
unformatted: {
|
|
248
|
+
type: Boolean,
|
|
249
|
+
reflect: true
|
|
250
|
+
},
|
|
251
|
+
open: {
|
|
252
|
+
type: Boolean,
|
|
253
|
+
reflect: true
|
|
254
|
+
},
|
|
255
|
+
triggerElement: {
|
|
256
|
+
attribute: false
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
firstUpdated() {
|
|
262
|
+
// Add the tag name as an attribute if it is different than the component name
|
|
263
|
+
this.runtimeUtils.handleComponentTagRename(this, 'auro-dialog');
|
|
264
|
+
|
|
265
|
+
const slot = this.shadowRoot.querySelector("#footer"),
|
|
266
|
+
slotWrapper = this.shadowRoot.querySelector("#footerWrapper");
|
|
267
|
+
|
|
268
|
+
this.dialog = this.shadowRoot.getElementById('dialog');
|
|
269
|
+
|
|
270
|
+
if (!this.unformatted && slot.assignedNodes().length === 0) {
|
|
271
|
+
slotWrapper.classList.remove("dialog-footer");
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* LitElement lifecycle method. Called after the DOM has been updated.
|
|
277
|
+
* @param {Map<string, any>} changedProperties - Keys are the names of changed properties, values are the corresponding previous values.
|
|
278
|
+
* @returns {void}
|
|
279
|
+
*/
|
|
280
|
+
updated(changedProperties) {
|
|
281
|
+
if (changedProperties.has('open')) {
|
|
282
|
+
if (this.open) {
|
|
283
|
+
this.openDialog();
|
|
284
|
+
} else {
|
|
285
|
+
this.closeDialog();
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
connectedCallback() {
|
|
291
|
+
super.connectedCallback();
|
|
292
|
+
this.keydownEventHandler = this.handleKeydown.bind(this);
|
|
293
|
+
window.addEventListener('keydown', this.keydownEventHandler);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
disconnectedCallback() {
|
|
297
|
+
super.disconnectedCallback();
|
|
298
|
+
window.removeEventListener('keydown', this.keydownEventHandler);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* @private
|
|
303
|
+
* @returns {void}
|
|
304
|
+
*/
|
|
305
|
+
openDialog() {
|
|
306
|
+
this.defaultTrigger = document.activeElement;
|
|
307
|
+
|
|
308
|
+
setTimeout(() => {
|
|
309
|
+
this.focus();
|
|
310
|
+
|
|
311
|
+
this.handleFocusLoss();
|
|
312
|
+
}, FOCUS_TIMEOUT);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* @private
|
|
317
|
+
* @returns {void}
|
|
318
|
+
*/
|
|
319
|
+
closeDialog() {
|
|
320
|
+
this.dispatchToggleEvent();
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* @private
|
|
325
|
+
* @returns {void}
|
|
326
|
+
*/
|
|
327
|
+
dispatchToggleEvent() {
|
|
328
|
+
// replace with Event constructor once IE support dropped
|
|
329
|
+
const toggleEvent = document.createEvent("HTMLEvents");
|
|
330
|
+
|
|
331
|
+
toggleEvent.initEvent("toggle", true, false);
|
|
332
|
+
this.dispatchEvent(toggleEvent);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* @private
|
|
337
|
+
* @returns {void} Determines if dropdown bib should be closed on focus change.
|
|
338
|
+
*/
|
|
339
|
+
handleFocusLoss() {
|
|
340
|
+
const focusable = [...this.querySelectorAll('button, auro-button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')];
|
|
341
|
+
|
|
342
|
+
const firstFocusableElement = focusable[0];
|
|
343
|
+
const lastFocusableElement = focusable[focusable.length - 1];
|
|
344
|
+
|
|
345
|
+
const closeButton = this.shadowRoot.getElementById('dialog-close');
|
|
346
|
+
|
|
347
|
+
if (lastFocusableElement) {
|
|
348
|
+
lastFocusableElement.addEventListener('focusout', () => {
|
|
349
|
+
if (closeButton !== null) {
|
|
350
|
+
closeButton.focus();
|
|
351
|
+
} else {
|
|
352
|
+
firstFocusableElement.focus();
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* @private
|
|
360
|
+
* @returns {void}
|
|
361
|
+
*/
|
|
362
|
+
handleOverlayClick() {
|
|
363
|
+
if (this.open && !this.modal) {
|
|
364
|
+
this.handleCloseButtonClick();
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* @private
|
|
370
|
+
* @returns {void}
|
|
371
|
+
*/
|
|
372
|
+
handleCloseButtonClick() {
|
|
373
|
+
this.open = false;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* @private
|
|
378
|
+
* @param {KeyboardEvent} event - The keyboard event containing the key and keyCode.
|
|
379
|
+
* @returns {void}
|
|
380
|
+
*/
|
|
381
|
+
handleKeydown({ key, keyCode }) {
|
|
382
|
+
if (this.open && !this.modal && (key === 'Escape' || keyCode === ESCAPE_KEYCODE)) {
|
|
383
|
+
this.open = false;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Focus the dialog.
|
|
389
|
+
* @private
|
|
390
|
+
* @returns {void}
|
|
391
|
+
*/
|
|
392
|
+
focus() {
|
|
393
|
+
if (this.open) {
|
|
394
|
+
this.dialog.focus();
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
static get styles() {
|
|
399
|
+
return [
|
|
400
|
+
styleCss,
|
|
401
|
+
styleUnformattedCss,
|
|
402
|
+
colorCss,
|
|
403
|
+
tokensCss
|
|
404
|
+
];
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* @private
|
|
409
|
+
* @returns {TemplateResult} - The close button template.
|
|
410
|
+
*/
|
|
411
|
+
getCloseButton() {
|
|
412
|
+
return this.modal
|
|
413
|
+
? html``
|
|
414
|
+
: html`
|
|
415
|
+
<${this.buttonTag} variant="flat" ?onDark=${this.hasAttribute('onDark')} class="dialog-header--action" id="dialog-close" @click="${this.handleCloseButtonClick}" part="close-button">
|
|
416
|
+
<${this.iconTag} customColor category="interface" name="x-lg"></${this.iconTag}>
|
|
417
|
+
<span class="util_displayHiddenVisually">Close</span>
|
|
418
|
+
</${this.buttonTag}>
|
|
419
|
+
`;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
render() {
|
|
423
|
+
const classes = {
|
|
424
|
+
'dialogOverlay': true,
|
|
425
|
+
'dialogOverlay--modal': this.modal && this.open,
|
|
426
|
+
'dialogOverlay--open': this.open,
|
|
427
|
+
'util_displayHidden': !this.open
|
|
428
|
+
},
|
|
429
|
+
|
|
430
|
+
contentClasses = {
|
|
431
|
+
'dialog': true,
|
|
432
|
+
'dialog--open': this.open
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
return html`
|
|
436
|
+
<div class="${classMap(classes)}" id="dialog-overlay" part="dialog-overlay" @click=${this.handleOverlayClick}></div>
|
|
437
|
+
|
|
438
|
+
<div role="dialog" id="dialog" class="${classMap(contentClasses)}" part="dialog" aria-labelledby="dialog-header" tabindex="-1">
|
|
439
|
+
${this.unformatted
|
|
440
|
+
? html`
|
|
441
|
+
<slot name="content"></slot>
|
|
442
|
+
${this.getCloseButton()}
|
|
443
|
+
`
|
|
444
|
+
: html`
|
|
445
|
+
<div class="dialog-header" part="dialog-header">
|
|
446
|
+
<h1 class="heading heading--700 util_stackMarginNone--top" id="dialog-header">
|
|
447
|
+
<slot name="header">Default header ...</slot>
|
|
448
|
+
</h1>
|
|
449
|
+
${this.getCloseButton()}
|
|
450
|
+
</div>
|
|
451
|
+
<div class="dialog-content" part="dialog-content">
|
|
452
|
+
<slot name="content"></slot>
|
|
453
|
+
</div>
|
|
454
|
+
<div class="dialog-footer" id="footerWrapper" part="dialog-footer">
|
|
455
|
+
<slot name="footer" id="footer"></slot>
|
|
456
|
+
</div>
|
|
457
|
+
`
|
|
458
|
+
}
|
|
459
|
+
</div>
|
|
460
|
+
`;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// Copyright (c) 2024 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license
|
|
465
|
+
// See LICENSE in the project root for license information.
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
// build the component class
|
|
469
|
+
class AuroDialog extends ComponentBase {
|
|
470
|
+
// constructor() {
|
|
471
|
+
// super();
|
|
472
|
+
// }
|
|
473
|
+
|
|
474
|
+
// function to define props used within the scope of this component
|
|
475
|
+
static get properties() {
|
|
476
|
+
return {
|
|
477
|
+
...super.properties,
|
|
478
|
+
// use custom accessors on base class
|
|
479
|
+
open: {
|
|
480
|
+
...super.properties.open,
|
|
481
|
+
noAccessor: true
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
static get styles() {
|
|
487
|
+
return [super.styles];
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* This will register this element with the browser.
|
|
492
|
+
* @param {string} [name="auro-dialog"] - The name of element that you want to register to.
|
|
493
|
+
*
|
|
494
|
+
* @example
|
|
495
|
+
* AuroDialog.register("custom-dialog") // this will register this element to <custom-dialog/>
|
|
496
|
+
*
|
|
497
|
+
*/
|
|
498
|
+
static register(name = "auro-dialog") {
|
|
499
|
+
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroDialog);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
AuroDialog.register();
|
|
504
|
+
|
|
167
505
|
function initExamples(initCount) {
|
|
168
506
|
initCount = initCount || 0;
|
|
169
507
|
|
package/demo/index.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { initBasicExample } from "../apiExamples/basic";
|
|
2
2
|
import { initCustomExample } from "../apiExamples/custom";
|
|
3
3
|
|
|
4
|
+
import { AuroDialog } from '../src/auro-dialog.js';
|
|
5
|
+
|
|
6
|
+
AuroDialog.register();
|
|
7
|
+
AuroDialog.register('custom-dialog');
|
|
8
|
+
|
|
4
9
|
export function initExamples(initCount) {
|
|
5
10
|
initCount = initCount || 0;
|
|
6
11
|
|
package/demo/index.md
CHANGED
|
@@ -132,15 +132,14 @@ Having a closing statement about your example helps to really complete the thoug
|
|
|
132
132
|
|
|
133
133
|
## Recommended Use and Version Control
|
|
134
134
|
|
|
135
|
-
There are two important parts of every Auro component. The <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes">class</a> and the custom
|
|
135
|
+
There are two important parts of every Auro component. The <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes">class</a> and the custom element. The class is exported and then used as part of defining the Web Component. When importing this component as described in the <a href="#install">install</a> section, the class is imported and the `auro-dialog` custom element is defined automatically.
|
|
136
136
|
|
|
137
|
-
To protect from versioning conflicts with other instances of the component being loaded, it is recommended to use our `
|
|
137
|
+
To protect from versioning conflicts with other instances of the component being loaded, it is recommended to use our `AuroDialog.register(name)` method and pass in a unique name.
|
|
138
138
|
|
|
139
139
|
```js
|
|
140
140
|
import { AuroDialog } from './src/auro-dialog.js';
|
|
141
|
-
import * as RuntimeUtils from '@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs';
|
|
142
141
|
|
|
143
|
-
|
|
142
|
+
AuroDialog.register('custom-dialog');
|
|
144
143
|
```
|
|
145
144
|
|
|
146
145
|
This will create a new custom element that you can use in your HTML that will function identically to the `auro-dialog` element.
|