@ni/nimble-components 12.0.2 → 14.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 +412 -1798
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +1772 -1809
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/dialog/index.d.ts +21 -8
- package/dist/esm/dialog/index.js +35 -9
- package/dist/esm/dialog/index.js.map +1 -1
- package/dist/esm/dialog/styles.js +96 -8
- package/dist/esm/dialog/styles.js.map +1 -1
- package/dist/esm/dialog/template.js +20 -4
- package/dist/esm/dialog/template.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
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,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QA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AI,EAAE,SAAS,EAAE,CAAC;8CAC1B;AAoGlC,WAAW,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC;AAEnD,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC;IAChC,QAAQ,EAAE,QAAQ;IAClB,QAAQ;IACR,MAAM;CACT,CAAC,CAAC;AACH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC"}
|
|
@@ -1,84 +1,118 @@
|
|
|
1
1
|
import { css } from '@microsoft/fast-element';
|
|
2
2
|
import { display } from '@microsoft/fast-foundation';
|
|
3
|
-
import { applicationBackgroundColor, bodyFont, bodyFontColor, borderWidth, popupBorderColor, popupBoxShadowColor, standardPadding, titlePlus1Font, drawerWidth,
|
|
3
|
+
import { applicationBackgroundColor, bodyFont, bodyFontColor, borderWidth, popupBorderColor, popupBoxShadowColor, standardPadding, titlePlus1Font, drawerWidth, largeDelay } from '../theme-provider/design-tokens';
|
|
4
|
+
import { modalBackdropColorThemeColorStatic, modalBackdropColorThemeDarkStatic, modalBackdropColorThemeLightStatic, largeDelayStatic } from '../theme-provider/design-tokens-static';
|
|
5
|
+
import { Theme } from '../theme-provider/types';
|
|
6
|
+
import { themeBehavior } from '../utilities/style/theme';
|
|
4
7
|
export const styles = css `
|
|
5
8
|
${display('block')}
|
|
6
9
|
|
|
7
10
|
:host {
|
|
8
|
-
position:
|
|
9
|
-
|
|
10
|
-
bottom: 0;
|
|
11
|
-
width: fit-content;
|
|
11
|
+
position: absolute;
|
|
12
|
+
width: auto;
|
|
12
13
|
height: 100%;
|
|
13
14
|
outline: none;
|
|
14
15
|
font: ${bodyFont};
|
|
15
16
|
color: ${bodyFontColor};
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
right: 0px;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.positioning-region {
|
|
31
|
-
display: block;
|
|
32
|
-
position: relative;
|
|
33
|
-
justify-content: center;
|
|
34
|
-
width: fit-content;
|
|
19
|
+
dialog {
|
|
20
|
+
color: inherit;
|
|
21
|
+
font: inherit;
|
|
22
|
+
background-color: transparent;
|
|
23
|
+
width: auto;
|
|
24
|
+
top: 0px;
|
|
25
|
+
bottom: 0px;
|
|
26
|
+
border-radius: 0px;
|
|
27
|
+
border-width: 0px;
|
|
35
28
|
height: 100%;
|
|
36
|
-
|
|
29
|
+
margin: 0px;
|
|
30
|
+
padding: 0px;
|
|
31
|
+
max-width: none;
|
|
32
|
+
max-height: none;
|
|
37
33
|
overflow: hidden;
|
|
38
|
-
z-index: 999;
|
|
39
34
|
}
|
|
40
35
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
@keyframes ni-private-drawer-fade-in-keyframes {
|
|
37
|
+
0% {
|
|
38
|
+
opacity: 0;
|
|
39
|
+
}
|
|
40
|
+
100% {
|
|
41
|
+
opacity: 1;
|
|
42
|
+
}
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
inset: 0px;
|
|
51
|
-
background: ${modalBackdropColor};
|
|
52
|
-
touch-action: none;
|
|
45
|
+
dialog.animating::backdrop {
|
|
46
|
+
animation: ni-private-drawer-fade-in-keyframes ${largeDelayStatic}
|
|
47
|
+
ease-in;
|
|
53
48
|
}
|
|
54
49
|
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
dialog.closing::backdrop {
|
|
51
|
+
animation-direction: reverse;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.dialog-contents {
|
|
55
|
+
box-sizing: border-box;
|
|
59
56
|
display: flex;
|
|
60
57
|
flex-direction: column;
|
|
61
|
-
|
|
62
|
-
border-radius: 0px;
|
|
63
|
-
border-width: 0px;
|
|
58
|
+
position: absolute;
|
|
64
59
|
width: ${drawerWidth};
|
|
65
60
|
height: 100%;
|
|
66
61
|
background-color: ${applicationBackgroundColor};
|
|
67
62
|
}
|
|
68
63
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
@keyframes ni-private-drawer-slide-in-left-keyframes {
|
|
65
|
+
0% {
|
|
66
|
+
transform: translate(-100%);
|
|
67
|
+
}
|
|
68
|
+
100% {
|
|
69
|
+
transform: translate(0%);
|
|
70
|
+
}
|
|
72
71
|
}
|
|
73
72
|
|
|
74
|
-
:host([location='left']) .
|
|
75
|
-
left: 0px;
|
|
73
|
+
:host([location='left']) .dialog-contents {
|
|
76
74
|
border-right: ${borderWidth} solid ${popupBoxShadowColor};
|
|
75
|
+
box-shadow: 3px 0px 8px ${popupBoxShadowColor};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
:host([location='left']) dialog.animating .dialog-contents {
|
|
79
|
+
animation: ni-private-drawer-slide-in-left-keyframes ${largeDelay}
|
|
80
|
+
ease-in;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:host([location='left']) dialog.closing .dialog-contents {
|
|
84
|
+
animation-direction: reverse;
|
|
77
85
|
}
|
|
78
86
|
|
|
79
|
-
|
|
87
|
+
@keyframes ni-private-drawer-slide-in-right-keyframes {
|
|
88
|
+
0% {
|
|
89
|
+
transform: translate(100%);
|
|
90
|
+
}
|
|
91
|
+
100% {
|
|
92
|
+
transform: translate(0%);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
:host([location='right']) .dialog-contents {
|
|
80
97
|
right: 0px;
|
|
81
98
|
border-left: ${borderWidth} solid ${popupBoxShadowColor};
|
|
99
|
+
box-shadow: -3px 0px 8px ${popupBoxShadowColor};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
:host([location='right']) dialog.animating .dialog-contents {
|
|
103
|
+
animation: ni-private-drawer-slide-in-right-keyframes ${largeDelay}
|
|
104
|
+
ease-in;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
:host([location='right']) dialog.closing .dialog-contents {
|
|
108
|
+
animation-direction: reverse;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@media (prefers-reduced-motion) {
|
|
112
|
+
:host([location='left']) dialog.animating .dialog-contents,
|
|
113
|
+
:host([location='right']) dialog.animating .dialog-contents {
|
|
114
|
+
animation-duration: 1ms;
|
|
115
|
+
}
|
|
82
116
|
}
|
|
83
117
|
|
|
84
118
|
${
|
|
@@ -106,5 +140,22 @@ export const styles = css `
|
|
|
106
140
|
justify-content: flex-end;
|
|
107
141
|
border-top: ${borderWidth} solid ${popupBorderColor};
|
|
108
142
|
}
|
|
109
|
-
|
|
143
|
+
`.withBehaviors(
|
|
144
|
+
/*
|
|
145
|
+
* We cannot use the modalBackdropColor token directly because the backdrop
|
|
146
|
+
* element is not a descendant of the nimble-theme-provider element.
|
|
147
|
+
*/
|
|
148
|
+
themeBehavior(Theme.light, css `
|
|
149
|
+
dialog::backdrop {
|
|
150
|
+
background: ${modalBackdropColorThemeLightStatic};
|
|
151
|
+
}
|
|
152
|
+
`), themeBehavior(Theme.dark, css `
|
|
153
|
+
dialog::backdrop {
|
|
154
|
+
background: ${modalBackdropColorThemeDarkStatic};
|
|
155
|
+
}
|
|
156
|
+
`), themeBehavior(Theme.color, css `
|
|
157
|
+
dialog::backdrop {
|
|
158
|
+
background: ${modalBackdropColorThemeColorStatic};
|
|
159
|
+
}
|
|
160
|
+
`));
|
|
110
161
|
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/drawer/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EACH,0BAA0B,EAC1B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AA;;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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { html, ref } from '@microsoft/fast-element';
|
|
2
|
+
export const template = html `
|
|
3
|
+
<dialog
|
|
4
|
+
${ref('dialog')}
|
|
5
|
+
aria-label="${x => x.ariaLabel}"
|
|
6
|
+
@cancel="${(x, c) => x.cancelHandler(c.event)}"
|
|
7
|
+
>
|
|
8
|
+
<div class="dialog-contents">
|
|
9
|
+
<slot></slot>
|
|
10
|
+
</div>
|
|
11
|
+
</dialog>
|
|
12
|
+
`;
|
|
13
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../src/drawer/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAGpD,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAQ;;UAE1B,GAAG,CAAC,QAAQ,CAAC;sBACD,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;mBACnB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC;;;;;;CAMpD,CAAC"}
|
|
@@ -3,10 +3,3 @@ export declare const DrawerLocation: {
|
|
|
3
3
|
readonly right: "right";
|
|
4
4
|
};
|
|
5
5
|
export declare type DrawerLocation = typeof DrawerLocation[keyof typeof DrawerLocation];
|
|
6
|
-
export declare const DrawerState: {
|
|
7
|
-
readonly opening: "opening";
|
|
8
|
-
readonly opened: "opened";
|
|
9
|
-
readonly closing: "closing";
|
|
10
|
-
readonly closed: "closed";
|
|
11
|
-
};
|
|
12
|
-
export declare type DrawerState = typeof DrawerState[keyof typeof DrawerState];
|
package/dist/esm/drawer/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/drawer/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;CACR,CAAC
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/drawer/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;CACR,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Symbol that is returned as the close reason (from the Promise returned by show()) when
|
|
3
|
+
* the dialog or drawer was closed by pressing the ESC key (vs. calling the close() function).
|
|
4
|
+
*/
|
|
5
|
+
export declare const UserDismissed: unique symbol;
|
|
6
|
+
export declare type UserDismissed = typeof UserDismissed;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Symbol that is returned as the close reason (from the Promise returned by show()) when
|
|
3
|
+
* the dialog or drawer was closed by pressing the ESC key (vs. calling the close() function).
|
|
4
|
+
*/
|
|
5
|
+
export const UserDismissed = Symbol('user dismissed');
|
|
6
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/patterns/dialog/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAkB,MAAM,CAAC,gBAAgB,CAAC,CAAC"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Static tokens to use for styling the `::backdrop` pseduo-element of an HTML dialog, which
|
|
3
|
+
* does not have access to CSS custom properties.
|
|
4
|
+
*
|
|
5
|
+
* See https://github.com/whatwg/fullscreen/issues/124
|
|
6
|
+
*/
|
|
7
|
+
export declare const modalBackdropColorThemeLightStatic: string;
|
|
8
|
+
export declare const modalBackdropColorThemeDarkStatic: string;
|
|
9
|
+
export declare const modalBackdropColorThemeColorStatic: string;
|
|
10
|
+
export declare const largeDelayStatic: string;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import { Black } from '@ni/nimble-tokens/dist/styledictionary/js/tokens';
|
|
1
|
+
import { Black, LargeDelay } from '@ni/nimble-tokens/dist/styledictionary/js/tokens';
|
|
2
2
|
import { hexToRgbaCssColor } from '../utilities/style/colors';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Static tokens to use for styling the `::backdrop` pseduo-element of an HTML dialog, which
|
|
5
|
+
* does not have access to CSS custom properties.
|
|
6
|
+
*
|
|
7
|
+
* See https://github.com/whatwg/fullscreen/issues/124
|
|
8
|
+
*/
|
|
9
|
+
export const modalBackdropColorThemeLightStatic = hexToRgbaCssColor(Black, 0.3);
|
|
10
|
+
export const modalBackdropColorThemeDarkStatic = hexToRgbaCssColor(Black, 0.6);
|
|
11
|
+
export const modalBackdropColorThemeColorStatic = hexToRgbaCssColor(Black, 0.6);
|
|
12
|
+
export const largeDelayStatic = LargeDelay;
|
|
6
13
|
//# sourceMappingURL=design-tokens-static.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"design-tokens-static.js","sourceRoot":"","sources":["../../../src/theme-provider/design-tokens-static.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"design-tokens-static.js","sourceRoot":"","sources":["../../../src/theme-provider/design-tokens-static.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EACL,UAAU,EACb,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,kCAAkC,GAAG,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAChF,MAAM,CAAC,MAAM,iCAAiC,GAAG,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC/E,MAAM,CAAC,MAAM,kCAAkC,GAAG,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAEhF,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DesignToken } from '@microsoft/fast-foundation';
|
|
2
2
|
import hexRgb from 'hex-rgb';
|
|
3
3
|
import { Black7, Black91, Black85, Black15, Black75, Black80, Black88, White, ForestGreen, DigitalGreenLight, Fail100LightUi, SmallDelay, MediumDelay, LargeDelay, Fail100DarkUi, Warning100LightUi, Warning100DarkUi, Pass100LightUi, Pass100DarkUi, BodyFamily, BodySize, BodyWeight, ControlLabel1Family, ControlLabel1Size, ControlLabel1Weight, GroupLabel1Family, GroupLabel1Size, GroupLabel1Weight, Headline2Size, Headline2Family, Headline2Weight, Headline1Size, Headline1Family, Headline1Weight, Title3Size, Title3Family, Title3Weight, Title2Size, Title2Family, Title2Weight, Title1Size, Title1Family, Title1Weight, Subtitle2Size, Subtitle2Family, Subtitle2Weight, Subtitle1Size, Subtitle1Family, Subtitle1Weight, LinkLightUiSize, LinkLightUiFamily, LinkLightUiWeight, PlaceholderSize, PlaceholderFamily, PlaceholderWeight, BodyEmphasizedSize, BodyEmphasizedFamily, BodyEmphasizedWeight, ButtonLabel1Size, ButtonLabel1Family, ButtonLabel1Weight, TooltipCaptionSize, TooltipCaptionFamily, TooltipCaptionWeight, ErrorLightUiSize, ErrorLightUiFamily, ErrorLightUiWeight, Headline2LineHeight, Headline1LineHeight, Title3LineHeight, Title2LineHeight, Title1LineHeight, Subtitle2LineHeight, Subtitle1LineHeight, LinkLineHeight, PlaceholderLineHeight, BodyEmphasizedLineHeight, BodyLineHeight, GroupLabel1LineHeight, ControlLabel1LineHeight, ButtonLabel1LineHeight, TooltipCaptionLineHeight, Information100LightUi, Information100DarkUi } from '@ni/nimble-tokens/dist/styledictionary/js/tokens';
|
|
4
|
-
import {
|
|
4
|
+
import { modalBackdropColorThemeColorStatic, modalBackdropColorThemeDarkStatic, modalBackdropColorThemeLightStatic } from './design-tokens-static';
|
|
5
5
|
import { Theme } from './types';
|
|
6
6
|
import { tokenNames, styleNameFromTokenName } from './design-token-names';
|
|
7
7
|
import { theme } from '.';
|
|
@@ -141,13 +141,13 @@ function getFillDownColorForTheme(element) {
|
|
|
141
141
|
function getModalBackdropForTheme(element) {
|
|
142
142
|
switch (theme.getValueFor(element)) {
|
|
143
143
|
case Theme.light:
|
|
144
|
-
return
|
|
144
|
+
return modalBackdropColorThemeLightStatic;
|
|
145
145
|
case Theme.dark:
|
|
146
|
-
return
|
|
146
|
+
return modalBackdropColorThemeDarkStatic;
|
|
147
147
|
case Theme.color:
|
|
148
|
-
return
|
|
148
|
+
return modalBackdropColorThemeColorStatic;
|
|
149
149
|
default:
|
|
150
|
-
return
|
|
150
|
+
return modalBackdropColorThemeLightStatic;
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
//# sourceMappingURL=design-tokens.js.map
|