@ni/nimble-components 12.0.2 → 13.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/dist/all-components-bundle.js +214 -1733
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +1675 -1805
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/dialog/index.d.ts +4 -8
- package/dist/esm/dialog/index.js +5 -8
- package/dist/esm/dialog/index.js.map +1 -1
- package/dist/esm/dialog/styles.js +4 -4
- package/dist/esm/dialog/styles.js.map +1 -1
- package/dist/esm/drawer/index.d.ts +34 -33
- package/dist/esm/drawer/index.js +73 -167
- package/dist/esm/drawer/index.js.map +1 -1
- package/dist/esm/drawer/styles.js +99 -48
- package/dist/esm/drawer/styles.js.map +1 -1
- package/dist/esm/drawer/template.d.ts +2 -0
- package/dist/esm/drawer/template.js +13 -0
- package/dist/esm/drawer/template.js.map +1 -0
- package/dist/esm/drawer/types.d.ts +0 -7
- package/dist/esm/drawer/types.js +0 -6
- package/dist/esm/drawer/types.js.map +1 -1
- package/dist/esm/patterns/dialog/types.d.ts +6 -0
- package/dist/esm/patterns/dialog/types.js +6 -0
- package/dist/esm/patterns/dialog/types.js.map +1 -0
- package/dist/esm/theme-provider/design-tokens-static.d.ts +10 -3
- package/dist/esm/theme-provider/design-tokens-static.js +11 -4
- package/dist/esm/theme-provider/design-tokens-static.js.map +1 -1
- package/dist/esm/theme-provider/design-tokens.js +5 -5
- package/dist/esm/theme-provider/design-tokens.js.map +1 -1
- package/package.json +1 -2
- package/dist/esm/drawer/animations.d.ts +0 -14
- package/dist/esm/drawer/animations.js +0 -52
- package/dist/esm/drawer/animations.js.map +0 -1
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { ARIAGlobalStatesAndProperties, FoundationElement } from '@microsoft/fast-foundation';
|
|
2
|
+
import { UserDismissed } from '../patterns/dialog/types';
|
|
3
|
+
export { UserDismissed };
|
|
2
4
|
declare global {
|
|
3
5
|
interface HTMLElementTagNameMap {
|
|
4
6
|
'nimble-dialog': Dialog;
|
|
5
7
|
}
|
|
6
8
|
}
|
|
7
|
-
/**
|
|
8
|
-
* Symbol that is returned as the dialog close reason (from the Promise returned by show()) when
|
|
9
|
-
* the dialog was closed by pressing the ESC key (vs. calling the close() function).
|
|
10
|
-
*/
|
|
11
|
-
export declare const USER_DISMISSED: unique symbol;
|
|
12
|
-
export declare type UserDismissed = typeof USER_DISMISSED;
|
|
13
9
|
/**
|
|
14
10
|
* This is a workaround for an incomplete definition of the native dialog element:
|
|
15
11
|
* https://github.com/microsoft/TypeScript/issues/48267
|
|
@@ -23,7 +19,7 @@ export interface ExtendedDialog extends HTMLDialogElement {
|
|
|
23
19
|
* A nimble-styled dialog.
|
|
24
20
|
*/
|
|
25
21
|
export declare class Dialog<CloseReason = void> extends FoundationElement {
|
|
26
|
-
static readonly
|
|
22
|
+
static readonly UserDismissed: symbol;
|
|
27
23
|
/**
|
|
28
24
|
* @public
|
|
29
25
|
* @description
|
|
@@ -43,7 +39,7 @@ export declare class Dialog<CloseReason = void> extends FoundationElement {
|
|
|
43
39
|
private resolveShow?;
|
|
44
40
|
/**
|
|
45
41
|
* Opens the dialog
|
|
46
|
-
* @returns Promise that is resolved when the dialog is closed. The value of the resolved Promise is the reason value passed to the close() method, or
|
|
42
|
+
* @returns Promise that is resolved when the dialog is closed. The value of the resolved Promise is the reason value passed to the close() method, or UserDismissed if the dialog was closed via the ESC key.
|
|
47
43
|
*/
|
|
48
44
|
show(): Promise<CloseReason | UserDismissed>;
|
|
49
45
|
/**
|
package/dist/esm/dialog/index.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { attr } from '@microsoft/fast-element';
|
|
3
3
|
import { applyMixins, ARIAGlobalStatesAndProperties, DesignSystem, FoundationElement } from '@microsoft/fast-foundation';
|
|
4
|
+
import { UserDismissed } from '../patterns/dialog/types';
|
|
4
5
|
import { styles } from './styles';
|
|
5
6
|
import { template } from './template';
|
|
6
|
-
|
|
7
|
-
* Symbol that is returned as the dialog close reason (from the Promise returned by show()) when
|
|
8
|
-
* the dialog was closed by pressing the ESC key (vs. calling the close() function).
|
|
9
|
-
*/
|
|
10
|
-
export const USER_DISMISSED = Symbol('user dismissed');
|
|
7
|
+
export { UserDismissed };
|
|
11
8
|
/**
|
|
12
9
|
* A nimble-styled dialog.
|
|
13
10
|
*/
|
|
@@ -30,7 +27,7 @@ export class Dialog extends FoundationElement {
|
|
|
30
27
|
}
|
|
31
28
|
/**
|
|
32
29
|
* Opens the dialog
|
|
33
|
-
* @returns Promise that is resolved when the dialog is closed. The value of the resolved Promise is the reason value passed to the close() method, or
|
|
30
|
+
* @returns Promise that is resolved when the dialog is closed. The value of the resolved Promise is the reason value passed to the close() method, or UserDismissed if the dialog was closed via the ESC key.
|
|
34
31
|
*/
|
|
35
32
|
async show() {
|
|
36
33
|
if (this.open) {
|
|
@@ -61,7 +58,7 @@ export class Dialog extends FoundationElement {
|
|
|
61
58
|
event.preventDefault();
|
|
62
59
|
}
|
|
63
60
|
else {
|
|
64
|
-
this.resolveShow(
|
|
61
|
+
this.resolveShow(UserDismissed);
|
|
65
62
|
this.resolveShow = undefined;
|
|
66
63
|
}
|
|
67
64
|
return true;
|
|
@@ -69,7 +66,7 @@ export class Dialog extends FoundationElement {
|
|
|
69
66
|
}
|
|
70
67
|
// We want the member to match the name of the constant
|
|
71
68
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
72
|
-
Dialog.
|
|
69
|
+
Dialog.UserDismissed = UserDismissed;
|
|
73
70
|
__decorate([
|
|
74
71
|
attr({ attribute: 'prevent-dismiss', mode: 'boolean' })
|
|
75
72
|
], Dialog.prototype, "preventDismiss", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dialog/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAA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ACD,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC3B,IAAI,CAAC,WAAY,CAAC,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,aAAa,CAAC,KAAY;QAC7B,IAAI,IAAI,CAAC,cAAc,EAAE;YACrB,KAAK,CAAC,cAAc,EAAE,CAAC;SAC1B;aAAM;YACH,IAAI,CAAC,WAAY,CAAC,aAAa,CAAC,CAAC;YACjC,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;SAChC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;;AAlED,uDAAuD;AACvD,gEAAgE;AACzC,oBAAa,GAAG,aAAa,CAAC;AAQrD;IADC,IAAI,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;8CAC1B;AA6DlC,WAAW,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC;AAEnD,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC;IAChC,QAAQ,EAAE,QAAQ;IAClB,QAAQ;IACR,MAAM;IACN,SAAS,EAAE,MAAM;CACpB,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { css } from '@microsoft/fast-element';
|
|
2
2
|
import { display } from '@microsoft/fast-foundation';
|
|
3
3
|
import { applicationBackgroundColor, borderWidth, popupBoxShadowColor, popupBorderColor } from '../theme-provider/design-tokens';
|
|
4
|
-
import {
|
|
4
|
+
import { modalBackdropColorThemeColorStatic, modalBackdropColorThemeDarkStatic, modalBackdropColorThemeLightStatic } from '../theme-provider/design-tokens-static';
|
|
5
5
|
import { Theme } from '../theme-provider/types';
|
|
6
6
|
import { themeBehavior } from '../utilities/style/theme';
|
|
7
7
|
export const styles = css `
|
|
@@ -20,15 +20,15 @@ export const styles = css `
|
|
|
20
20
|
*/
|
|
21
21
|
themeBehavior(Theme.light, css `
|
|
22
22
|
dialog::backdrop {
|
|
23
|
-
background: ${
|
|
23
|
+
background: ${modalBackdropColorThemeLightStatic};
|
|
24
24
|
}
|
|
25
25
|
`), themeBehavior(Theme.dark, css `
|
|
26
26
|
dialog::backdrop {
|
|
27
|
-
background: ${
|
|
27
|
+
background: ${modalBackdropColorThemeDarkStatic};
|
|
28
28
|
}
|
|
29
29
|
`), themeBehavior(Theme.color, css `
|
|
30
30
|
dialog::backdrop {
|
|
31
|
-
background: ${
|
|
31
|
+
background: ${modalBackdropColorThemeColorStatic};
|
|
32
32
|
}
|
|
33
33
|
`));
|
|
34
34
|
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/dialog/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,OAAO,EACH,0BAA0B,EAC1B,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EACnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/dialog/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,OAAO,EACH,0BAA0B,EAC1B,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EACnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,kCAAkC,EAClC,iCAAiC,EACjC,kCAAkC,EACrC,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;MACnB,OAAO,CAAC,MAAM,CAAC;;;4BAGO,0BAA0B;kBACpC,WAAW,UAAU,gBAAgB;kCACrB,mBAAmB;;;CAGpD,CAAC,aAAa;AACX;;;GAGG;AACH,aAAa,CACT,KAAK,CAAC,KAAK,EACX,GAAG,CAAA;;8BAEmB,kCAAkC;;SAEvD,CACJ,EACD,aAAa,CACT,KAAK,CAAC,IAAI,EACV,GAAG,CAAA;;8BAEmB,iCAAiC;;SAEtD,CACJ,EACD,aAAa,CACT,KAAK,CAAC,KAAK,EACX,GAAG,CAAA;;8BAEmB,kCAAkC;;SAEvD,CACJ,CACJ,CAAC"}
|
|
@@ -1,48 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ARIAGlobalStatesAndProperties, FoundationElement } from '@microsoft/fast-foundation';
|
|
2
|
+
import { UserDismissed } from '../patterns/dialog/types';
|
|
3
|
+
import { DrawerLocation } from './types';
|
|
4
|
+
export { UserDismissed };
|
|
3
5
|
declare global {
|
|
4
6
|
interface HTMLElementTagNameMap {
|
|
5
7
|
'nimble-drawer': Drawer;
|
|
6
8
|
}
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
|
-
* Drawer
|
|
11
|
+
* Drawer control. Shows content in a panel on the left / right side of the screen,
|
|
10
12
|
* which animates to be visible with a slide-in / slide-out animation.
|
|
11
|
-
* Configured via 'location', 'state', 'modal', 'preventDismiss' properties.
|
|
12
13
|
*/
|
|
13
|
-
export declare class Drawer extends
|
|
14
|
+
export declare class Drawer<CloseReason = void> extends FoundationElement {
|
|
15
|
+
static readonly UserDismissed: symbol;
|
|
14
16
|
location: DrawerLocation;
|
|
15
|
-
|
|
17
|
+
preventDismiss: boolean;
|
|
18
|
+
dialog: HTMLDialogElement;
|
|
19
|
+
private closing;
|
|
20
|
+
private resolveShow?;
|
|
21
|
+
private closeReason;
|
|
16
22
|
/**
|
|
17
|
-
* True
|
|
18
|
-
* Only applicable when 'modal' is set to true (i.e. when the overlay is used).
|
|
19
|
-
* HTML Attribute: prevent-dismiss
|
|
23
|
+
* True if the drawer is open, opening, or closing. Otherwise, false.
|
|
20
24
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
get open(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Opens the drawer
|
|
28
|
+
* @returns Promise that is resolved when the drawer finishes closing. The value of the resolved
|
|
29
|
+
* Promise is the reason value passed to the close() method, or UserDismissed if the drawer was
|
|
30
|
+
* closed via the ESC key.
|
|
31
|
+
*/
|
|
32
|
+
show(): Promise<CloseReason | UserDismissed>;
|
|
33
|
+
/**
|
|
34
|
+
* Closes the drawer
|
|
35
|
+
* @param reason An optional value indicating how/why the drawer was closed.
|
|
36
|
+
*/
|
|
37
|
+
close(reason: CloseReason): void;
|
|
34
38
|
/**
|
|
35
|
-
* Handler for overlay clicks (user-initiated dismiss requests) only.
|
|
36
39
|
* @internal
|
|
37
40
|
*/
|
|
38
|
-
|
|
39
|
-
private
|
|
40
|
-
private
|
|
41
|
-
private
|
|
42
|
-
private
|
|
43
|
-
private
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
private animateOpenClose;
|
|
47
|
-
private cancelCurrentAnimation;
|
|
41
|
+
cancelHandler(event: Event): boolean;
|
|
42
|
+
private readonly animationEndHandlerFunction;
|
|
43
|
+
private openDialog;
|
|
44
|
+
private closeDialog;
|
|
45
|
+
private triggerAnimation;
|
|
46
|
+
private animationEndHandler;
|
|
47
|
+
}
|
|
48
|
+
export interface Drawer extends ARIAGlobalStatesAndProperties {
|
|
48
49
|
}
|
package/dist/esm/drawer/index.js
CHANGED
|
@@ -1,201 +1,107 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { prefersReducedMotionMediaQuery } from '../utilities/style/prefers-reduced-motion';
|
|
7
|
-
import { animationConfig } from './animations';
|
|
2
|
+
import { attr } from '@microsoft/fast-element';
|
|
3
|
+
import { applyMixins, ARIAGlobalStatesAndProperties, DesignSystem, FoundationElement } from '@microsoft/fast-foundation';
|
|
4
|
+
import { eventAnimationEnd } from '@microsoft/fast-web-utilities';
|
|
5
|
+
import { UserDismissed } from '../patterns/dialog/types';
|
|
8
6
|
import { styles } from './styles';
|
|
9
|
-
import {
|
|
10
|
-
|
|
7
|
+
import { template } from './template';
|
|
8
|
+
import { DrawerLocation } from './types';
|
|
9
|
+
export { UserDismissed };
|
|
11
10
|
/**
|
|
12
|
-
* Drawer
|
|
11
|
+
* Drawer control. Shows content in a panel on the left / right side of the screen,
|
|
13
12
|
* which animates to be visible with a slide-in / slide-out animation.
|
|
14
|
-
* Configured via 'location', 'state', 'modal', 'preventDismiss' properties.
|
|
15
13
|
*/
|
|
16
|
-
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
15
|
+
export class Drawer extends FoundationElement {
|
|
17
16
|
constructor() {
|
|
18
17
|
super(...arguments);
|
|
19
|
-
this.location = DrawerLocation.
|
|
20
|
-
this.state = DrawerState.closed;
|
|
21
|
-
/**
|
|
22
|
-
* True to prevent dismissing the drawer when the overlay outside the drawer is clicked.
|
|
23
|
-
* Only applicable when 'modal' is set to true (i.e. when the overlay is used).
|
|
24
|
-
* HTML Attribute: prevent-dismiss
|
|
25
|
-
*/
|
|
18
|
+
this.location = DrawerLocation.right;
|
|
26
19
|
this.preventDismiss = false;
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
}
|
|
30
|
-
/** @internal */
|
|
31
|
-
connectedCallback() {
|
|
32
|
-
// disable trapFocus before super.connectedCallback as FAST Dialog will immediately queue work to
|
|
33
|
-
// change focus if it's true before connectedCallback
|
|
34
|
-
this.trapFocus = false;
|
|
35
|
-
super.connectedCallback();
|
|
36
|
-
this.updateAnimationDuration();
|
|
37
|
-
this.animationsEnabledChangedHandler = () => this.updateAnimationDuration();
|
|
38
|
-
prefersReducedMotionMediaQuery.addEventListener('change', this.animationsEnabledChangedHandler);
|
|
39
|
-
this.onStateChanged();
|
|
40
|
-
const notifier = Observable.getNotifier(this);
|
|
41
|
-
const subscriber = {
|
|
42
|
-
handleChange: (_source, propertyName) => this.onPropertyChange(propertyName)
|
|
43
|
-
};
|
|
44
|
-
this.propertiesToWatch.forEach(propertyName => notifier.subscribe(subscriber, propertyName));
|
|
45
|
-
this.propertyChangeSubscriber = subscriber;
|
|
46
|
-
this.propertyChangeNotifier = notifier;
|
|
47
|
-
}
|
|
48
|
-
/** @internal */
|
|
49
|
-
disconnectedCallback() {
|
|
50
|
-
super.disconnectedCallback();
|
|
51
|
-
this.cancelCurrentAnimation();
|
|
52
|
-
if (this.propertyChangeNotifier && this.propertyChangeSubscriber) {
|
|
53
|
-
this.propertiesToWatch.forEach(propertyName => this.propertyChangeNotifier.unsubscribe(this.propertyChangeSubscriber, propertyName));
|
|
54
|
-
this.propertyChangeNotifier = undefined;
|
|
55
|
-
this.propertyChangeSubscriber = undefined;
|
|
56
|
-
}
|
|
57
|
-
if (this.animationsEnabledChangedHandler) {
|
|
58
|
-
prefersReducedMotionMediaQuery.removeEventListener('change', this.animationsEnabledChangedHandler);
|
|
59
|
-
this.animationsEnabledChangedHandler = undefined;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
show() {
|
|
63
|
-
// Not calling super.show() as that will immediately show the drawer, whereas 'Opening' state will animate
|
|
64
|
-
this.state = DrawerState.opening;
|
|
65
|
-
}
|
|
66
|
-
hide() {
|
|
67
|
-
// Not calling super.hide() as that will immediately hide the drawer, whereas 'Closing' state will animate
|
|
68
|
-
this.state = DrawerState.closing;
|
|
20
|
+
this.closing = false;
|
|
21
|
+
this.animationEndHandlerFunction = () => this.animationEndHandler();
|
|
69
22
|
}
|
|
70
23
|
/**
|
|
71
|
-
*
|
|
72
|
-
* @internal
|
|
24
|
+
* True if the drawer is open, opening, or closing. Otherwise, false.
|
|
73
25
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const shouldDismiss = this.$emit('cancel', {},
|
|
77
|
-
// Aligned with the configuration of HTMLDialogElement cancel event:
|
|
78
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/cancel_event
|
|
79
|
-
{ bubbles: false, cancelable: true, composed: false });
|
|
80
|
-
if (shouldDismiss && !this.preventDismiss) {
|
|
81
|
-
this.$emit('dismiss');
|
|
82
|
-
this.hide();
|
|
83
|
-
}
|
|
26
|
+
get open() {
|
|
27
|
+
return this.resolveShow !== undefined;
|
|
84
28
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.onStateChanged();
|
|
95
|
-
break;
|
|
96
|
-
default:
|
|
97
|
-
break;
|
|
29
|
+
/**
|
|
30
|
+
* Opens the drawer
|
|
31
|
+
* @returns Promise that is resolved when the drawer finishes closing. The value of the resolved
|
|
32
|
+
* Promise is the reason value passed to the close() method, or UserDismissed if the drawer was
|
|
33
|
+
* closed via the ESC key.
|
|
34
|
+
*/
|
|
35
|
+
async show() {
|
|
36
|
+
if (this.open) {
|
|
37
|
+
throw new Error('Drawer is already open');
|
|
98
38
|
}
|
|
39
|
+
this.openDialog();
|
|
40
|
+
return new Promise((resolve, _reject) => {
|
|
41
|
+
this.resolveShow = resolve;
|
|
42
|
+
});
|
|
99
43
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Closes the drawer
|
|
46
|
+
* @param reason An optional value indicating how/why the drawer was closed.
|
|
47
|
+
*/
|
|
48
|
+
close(reason) {
|
|
49
|
+
if (!this.open || this.closing) {
|
|
50
|
+
throw new Error('Drawer is not open or already closing');
|
|
106
51
|
}
|
|
52
|
+
this.closeReason = reason;
|
|
53
|
+
this.closeDialog();
|
|
107
54
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
break;
|
|
119
|
-
case DrawerState.opened:
|
|
120
|
-
this.hidden = false;
|
|
121
|
-
break;
|
|
122
|
-
case DrawerState.closing:
|
|
123
|
-
this.hidden = false;
|
|
124
|
-
this.animateClosing();
|
|
125
|
-
break;
|
|
126
|
-
case DrawerState.closed:
|
|
127
|
-
this.hidden = true;
|
|
128
|
-
break;
|
|
129
|
-
default:
|
|
130
|
-
throw new Error('Unsupported state value. Expected: opening/opened/closing/closed');
|
|
131
|
-
}
|
|
132
|
-
this.$emit('state-change');
|
|
55
|
+
/**
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
cancelHandler(event) {
|
|
59
|
+
// Allowing the dialog to close itself bypasses the drawer's animation logic, so we
|
|
60
|
+
// should close the drawer ourselves when preventDismiss is false.
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
if (!this.preventDismiss) {
|
|
63
|
+
this.closeReason = UserDismissed;
|
|
64
|
+
this.closeDialog();
|
|
133
65
|
}
|
|
66
|
+
return true;
|
|
134
67
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
this.animationDurationMilliseconds = animationDurationWhenDisabledMilliseconds;
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
// string ends in 's' unit specifier
|
|
142
|
-
const secondsString = largeDelay.getValueFor(this);
|
|
143
|
-
const secondsNumber = parseFloat(secondsString);
|
|
144
|
-
this.animationDurationMilliseconds = 1000 * secondsNumber;
|
|
145
|
-
}
|
|
68
|
+
openDialog() {
|
|
69
|
+
this.dialog.showModal();
|
|
70
|
+
this.triggerAnimation();
|
|
146
71
|
}
|
|
147
|
-
|
|
148
|
-
this.
|
|
72
|
+
closeDialog() {
|
|
73
|
+
this.closing = true;
|
|
74
|
+
this.triggerAnimation();
|
|
149
75
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
else {
|
|
155
|
-
this.state = DrawerState.closed;
|
|
76
|
+
triggerAnimation() {
|
|
77
|
+
this.dialog.classList.add('animating');
|
|
78
|
+
if (this.closing) {
|
|
79
|
+
this.dialog.classList.add('closing');
|
|
156
80
|
}
|
|
81
|
+
this.dialog.addEventListener(eventAnimationEnd, this.animationEndHandlerFunction);
|
|
157
82
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
: animationConfig.slideLeftKeyframes;
|
|
168
|
-
const dialogAnimation = new AnimateTo(this.dialog, undefined, options);
|
|
169
|
-
dialogAnimation.addKeyframes(drawerKeyframes);
|
|
170
|
-
const animations = [dialogAnimation];
|
|
171
|
-
const overlay = this.shadowRoot?.querySelector('.overlay');
|
|
172
|
-
if (overlay) {
|
|
173
|
-
const overlayAnimation = new AnimateTo(overlay, undefined, options);
|
|
174
|
-
overlayAnimation.addKeyframes(animationConfig.fadeOverlayKeyframes);
|
|
175
|
-
animations.push(overlayAnimation);
|
|
83
|
+
animationEndHandler() {
|
|
84
|
+
this.dialog.removeEventListener(eventAnimationEnd, this.animationEndHandlerFunction);
|
|
85
|
+
this.dialog.classList.remove('animating');
|
|
86
|
+
if (this.closing) {
|
|
87
|
+
this.dialog.classList.remove('closing');
|
|
88
|
+
this.dialog.close();
|
|
89
|
+
this.closing = false;
|
|
90
|
+
this.resolveShow(this.closeReason);
|
|
91
|
+
this.resolveShow = undefined;
|
|
176
92
|
}
|
|
177
|
-
const animationGroup = new AnimateGroup(animations);
|
|
178
|
-
animationGroup.onFinish = () => {
|
|
179
|
-
this.state = drawerOpening
|
|
180
|
-
? DrawerState.opened
|
|
181
|
-
: DrawerState.closed;
|
|
182
|
-
};
|
|
183
|
-
this.animationGroup = animationGroup;
|
|
184
|
-
animationGroup.play();
|
|
185
|
-
}
|
|
186
|
-
cancelCurrentAnimation() {
|
|
187
|
-
this.animationGroup?.cancel();
|
|
188
93
|
}
|
|
189
94
|
}
|
|
95
|
+
// We want the member to match the name of the constant
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
97
|
+
Drawer.UserDismissed = UserDismissed;
|
|
190
98
|
__decorate([
|
|
191
99
|
attr
|
|
192
100
|
], Drawer.prototype, "location", void 0);
|
|
193
|
-
__decorate([
|
|
194
|
-
attr
|
|
195
|
-
], Drawer.prototype, "state", void 0);
|
|
196
101
|
__decorate([
|
|
197
102
|
attr({ attribute: 'prevent-dismiss', mode: 'boolean' })
|
|
198
103
|
], Drawer.prototype, "preventDismiss", void 0);
|
|
104
|
+
applyMixins(Drawer, ARIAGlobalStatesAndProperties);
|
|
199
105
|
const nimbleDrawer = Drawer.compose({
|
|
200
106
|
baseName: 'drawer',
|
|
201
107
|
template,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drawer/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/drawer/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EACH,WAAW,EACX,6BAA6B,EAC7B,YAAY,EACZ,iBAAiB,EACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAA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