@ni/nimble-components 1.0.0-beta.101 → 1.0.0-beta.102
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/README.md +20 -20
- package/dist/esm/button/behaviors.d.ts +12 -12
- package/dist/esm/button/behaviors.js +13 -13
- package/dist/esm/button/index.d.ts +17 -17
- package/dist/esm/button/index.js +37 -37
- package/dist/esm/button/styles.d.ts +1 -1
- package/dist/esm/button/styles.js +178 -178
- package/dist/esm/button/types.d.ts +9 -9
- package/dist/esm/button/types.js +10 -10
- package/dist/esm/checkbox/index.d.ts +2 -2
- package/dist/esm/checkbox/index.js +11 -11
- package/dist/esm/checkbox/styles.d.ts +1 -1
- package/dist/esm/checkbox/styles.js +91 -91
- package/dist/esm/drawer/animations.d.ts +14 -14
- package/dist/esm/drawer/animations.js +51 -51
- package/dist/esm/drawer/index.d.ts +39 -39
- package/dist/esm/drawer/index.js +189 -189
- package/dist/esm/drawer/styles.d.ts +1 -1
- package/dist/esm/drawer/styles.js +114 -114
- package/dist/esm/drawer/types.d.ts +10 -10
- package/dist/esm/drawer/types.js +12 -12
- package/dist/esm/icon-base/index.d.ts +12 -12
- package/dist/esm/icon-base/index.js +21 -21
- package/dist/esm/icon-base/styles.d.ts +1 -1
- package/dist/esm/icon-base/styles.js +37 -37
- package/dist/esm/icon-base/template.d.ts +2 -2
- package/dist/esm/icon-base/template.js +6 -6
- package/dist/esm/icons/access-control.d.ts +7 -7
- package/dist/esm/icons/access-control.js +11 -11
- package/dist/esm/icons/admin.d.ts +7 -7
- package/dist/esm/icons/admin.js +11 -11
- package/dist/esm/icons/administration.d.ts +7 -7
- package/dist/esm/icons/administration.js +11 -11
- package/dist/esm/icons/all-icons.d.ts +13 -13
- package/dist/esm/icons/all-icons.js +13 -13
- package/dist/esm/icons/check.d.ts +7 -7
- package/dist/esm/icons/check.js +11 -11
- package/dist/esm/icons/custom-applications.d.ts +7 -7
- package/dist/esm/icons/custom-applications.js +11 -11
- package/dist/esm/icons/delete.d.ts +7 -7
- package/dist/esm/icons/delete.js +11 -11
- package/dist/esm/icons/login.d.ts +7 -7
- package/dist/esm/icons/login.js +11 -11
- package/dist/esm/icons/logout.d.ts +7 -7
- package/dist/esm/icons/logout.js +11 -11
- package/dist/esm/icons/managed-systems.d.ts +7 -7
- package/dist/esm/icons/managed-systems.js +11 -11
- package/dist/esm/icons/measurement-data-analysis.d.ts +7 -7
- package/dist/esm/icons/measurement-data-analysis.js +11 -11
- package/dist/esm/icons/settings.d.ts +7 -7
- package/dist/esm/icons/settings.js +11 -11
- package/dist/esm/icons/test-insights.d.ts +7 -7
- package/dist/esm/icons/test-insights.js +11 -11
- package/dist/esm/icons/utilities.d.ts +7 -7
- package/dist/esm/icons/utilities.js +11 -11
- package/dist/esm/listbox-option/index.d.ts +10 -10
- package/dist/esm/listbox-option/index.js +28 -28
- package/dist/esm/listbox-option/styles.d.ts +1 -1
- package/dist/esm/listbox-option/styles.js +59 -59
- package/dist/esm/menu/index.d.ts +5 -5
- package/dist/esm/menu/index.js +21 -21
- package/dist/esm/menu/styles.d.ts +1 -1
- package/dist/esm/menu/styles.js +39 -39
- package/dist/esm/menu-item/index.d.ts +15 -15
- package/dist/esm/menu-item/index.js +21 -21
- package/dist/esm/menu-item/styles.d.ts +1 -1
- package/dist/esm/menu-item/styles.js +63 -63
- package/dist/esm/number-field/index.d.ts +6 -6
- package/dist/esm/number-field/index.js +22 -22
- package/dist/esm/number-field/styles.d.ts +1 -1
- package/dist/esm/number-field/styles.js +117 -117
- package/dist/esm/select/index.d.ts +12 -12
- package/dist/esm/select/index.js +45 -45
- package/dist/esm/select/styles.d.ts +1 -1
- package/dist/esm/select/styles.js +140 -140
- package/dist/esm/tab/index.d.ts +2 -2
- package/dist/esm/tab/index.js +8 -8
- package/dist/esm/tab/styles.d.ts +1 -1
- package/dist/esm/tab/styles.js +52 -52
- package/dist/esm/tab-panel/index.d.ts +2 -2
- package/dist/esm/tab-panel/index.js +8 -8
- package/dist/esm/tab-panel/styles.d.ts +1 -1
- package/dist/esm/tab-panel/styles.js +14 -14
- package/dist/esm/tabs/index.d.ts +2 -2
- package/dist/esm/tabs/index.js +8 -8
- package/dist/esm/tabs/styles.d.ts +1 -1
- package/dist/esm/tabs/styles.js +42 -42
- package/dist/esm/tabs-toolbar/index.d.ts +6 -6
- package/dist/esm/tabs-toolbar/index.js +14 -14
- package/dist/esm/tabs-toolbar/styles.d.ts +1 -1
- package/dist/esm/tabs-toolbar/styles.js +22 -22
- package/dist/esm/tabs-toolbar/template.d.ts +1 -1
- package/dist/esm/tabs-toolbar/template.js +7 -7
- package/dist/esm/testing/dom-next-update.d.ts +4 -4
- package/dist/esm/testing/dom-next-update.js +5 -5
- package/dist/esm/text-field/index.d.ts +6 -6
- package/dist/esm/text-field/index.js +13 -13
- package/dist/esm/text-field/styles.d.ts +1 -1
- package/dist/esm/text-field/styles.js +141 -141
- package/dist/esm/theme-provider/design-tokens.d.ts +48 -48
- package/dist/esm/theme-provider/design-tokens.js +163 -163
- package/dist/esm/theme-provider/index.d.ts +10 -10
- package/dist/esm/theme-provider/index.js +42 -42
- package/dist/esm/theme-provider/template.d.ts +2 -2
- package/dist/esm/theme-provider/template.js +2 -2
- package/dist/esm/theme-provider/themes.d.ts +6 -6
- package/dist/esm/theme-provider/themes.js +7 -7
- package/dist/esm/tree-item/index.d.ts +28 -28
- package/dist/esm/tree-item/index.js +115 -115
- package/dist/esm/tree-item/styles.d.ts +3 -3
- package/dist/esm/tree-item/styles.js +194 -194
- package/dist/esm/tree-view/index.d.ts +16 -16
- package/dist/esm/tree-view/index.js +33 -33
- package/dist/esm/tree-view/styles.d.ts +1 -1
- package/dist/esm/tree-view/styles.js +16 -16
- package/dist/esm/tree-view/types.d.ts +6 -6
- package/dist/esm/tree-view/types.js +7 -7
- package/dist/esm/utilities/style/focus.d.ts +11 -11
- package/dist/esm/utilities/style/focus.js +13 -13
- package/package.json +95 -94
package/dist/esm/drawer/index.js
CHANGED
|
@@ -1,190 +1,190 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { AnimateGroup, AnimateTo } from '@microsoft/fast-animation';
|
|
3
|
-
import { attr, Observable } from '@microsoft/fast-element';
|
|
4
|
-
import { DesignSystem, Dialog as FoundationDialog, dialogTemplate as template } from '@microsoft/fast-foundation';
|
|
5
|
-
import { drawerAnimationDurationMs } from '../theme-provider/design-tokens';
|
|
6
|
-
import { animationConfig } from './animations';
|
|
7
|
-
import { styles } from './styles';
|
|
8
|
-
import { DrawerLocation, DrawerState } from './types';
|
|
9
|
-
const animationDurationWhenDisabledMilliseconds = 0.001;
|
|
10
|
-
/**
|
|
11
|
-
* Drawer/Sidenav control. Shows content in a panel on the left / right side of the screen,
|
|
12
|
-
* which animates to be visible with a slide-in / slide-out animation.
|
|
13
|
-
* Configured via 'location', 'state', 'modal', 'preventDismiss' properties.
|
|
14
|
-
*/
|
|
15
|
-
export class Drawer extends FoundationDialog {
|
|
16
|
-
constructor() {
|
|
17
|
-
super(...arguments);
|
|
18
|
-
this.location = DrawerLocation.Left;
|
|
19
|
-
this.state = DrawerState.Closed;
|
|
20
|
-
/**
|
|
21
|
-
* True to prevent dismissing the drawer when the overlay outside the drawer is clicked.
|
|
22
|
-
* Only applicable when 'modal' is set to true (i.e. when the overlay is used).
|
|
23
|
-
* HTML Attribute: prevent-dismiss
|
|
24
|
-
*/
|
|
25
|
-
this.preventDismiss = false;
|
|
26
|
-
this.propertiesToWatch = ['hidden', 'location', 'state'];
|
|
27
|
-
this.animationDurationMilliseconds = animationDurationWhenDisabledMilliseconds;
|
|
28
|
-
}
|
|
29
|
-
connectedCallback() {
|
|
30
|
-
// disable trapFocus before super.connectedCallback as FAST Dialog will immediately queue work to
|
|
31
|
-
// change focus if it's true before connectedCallback
|
|
32
|
-
this.trapFocus = false;
|
|
33
|
-
super.connectedCallback();
|
|
34
|
-
this.prefersReducedMotionMediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
35
|
-
this.updateAnimationDuration();
|
|
36
|
-
this.animationsEnabledChangedHandler = () => this.updateAnimationDuration();
|
|
37
|
-
this.prefersReducedMotionMediaQuery.addEventListener('change', this.animationsEnabledChangedHandler);
|
|
38
|
-
this.onStateChanged();
|
|
39
|
-
const notifier = Observable.getNotifier(this);
|
|
40
|
-
const subscriber = {
|
|
41
|
-
handleChange: (_source, propertyName) => this.onPropertyChange(propertyName)
|
|
42
|
-
};
|
|
43
|
-
this.propertiesToWatch.forEach(propertyName => notifier.subscribe(subscriber, propertyName));
|
|
44
|
-
this.propertyChangeSubscriber = subscriber;
|
|
45
|
-
this.propertyChangeNotifier = notifier;
|
|
46
|
-
}
|
|
47
|
-
disconnectedCallback() {
|
|
48
|
-
super.disconnectedCallback();
|
|
49
|
-
this.cancelCurrentAnimation();
|
|
50
|
-
if (this.propertyChangeNotifier && this.propertyChangeSubscriber) {
|
|
51
|
-
this.propertiesToWatch.forEach(propertyName => this.propertyChangeNotifier.unsubscribe(this.propertyChangeSubscriber, propertyName));
|
|
52
|
-
this.propertyChangeNotifier = undefined;
|
|
53
|
-
this.propertyChangeSubscriber = undefined;
|
|
54
|
-
}
|
|
55
|
-
if (this.prefersReducedMotionMediaQuery
|
|
56
|
-
&& this.animationsEnabledChangedHandler) {
|
|
57
|
-
this.prefersReducedMotionMediaQuery.removeEventListener('change', this.animationsEnabledChangedHandler);
|
|
58
|
-
this.prefersReducedMotionMediaQuery = undefined;
|
|
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;
|
|
69
|
-
}
|
|
70
|
-
dismiss() {
|
|
71
|
-
if (!this.preventDismiss) {
|
|
72
|
-
super.dismiss();
|
|
73
|
-
this.hide();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
onPropertyChange(propertyName) {
|
|
77
|
-
switch (propertyName) {
|
|
78
|
-
case 'hidden':
|
|
79
|
-
this.onHiddenChanged();
|
|
80
|
-
break;
|
|
81
|
-
case 'location':
|
|
82
|
-
this.onLocationChanged();
|
|
83
|
-
break;
|
|
84
|
-
case 'state':
|
|
85
|
-
this.onStateChanged();
|
|
86
|
-
break;
|
|
87
|
-
default:
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
onHiddenChanged() {
|
|
92
|
-
if (this.hidden && this.state !== DrawerState.Closed) {
|
|
93
|
-
this.state = DrawerState.Closed;
|
|
94
|
-
}
|
|
95
|
-
else if (!this.hidden && this.state === DrawerState.Closed) {
|
|
96
|
-
this.state = DrawerState.Opened;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
onLocationChanged() {
|
|
100
|
-
this.cancelCurrentAnimation();
|
|
101
|
-
}
|
|
102
|
-
onStateChanged() {
|
|
103
|
-
if (this.isConnected) {
|
|
104
|
-
this.cancelCurrentAnimation();
|
|
105
|
-
switch (this.state) {
|
|
106
|
-
case DrawerState.Opening:
|
|
107
|
-
this.animateOpening();
|
|
108
|
-
this.hidden = false;
|
|
109
|
-
break;
|
|
110
|
-
case DrawerState.Opened:
|
|
111
|
-
this.hidden = false;
|
|
112
|
-
break;
|
|
113
|
-
case DrawerState.Closing:
|
|
114
|
-
this.hidden = false;
|
|
115
|
-
this.animateClosing();
|
|
116
|
-
break;
|
|
117
|
-
case DrawerState.Closed:
|
|
118
|
-
this.hidden = true;
|
|
119
|
-
break;
|
|
120
|
-
default:
|
|
121
|
-
throw new Error('Unsupported state value. Expected: opening/opened/closing/closed');
|
|
122
|
-
}
|
|
123
|
-
this.$emit('state-change');
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
updateAnimationDuration() {
|
|
127
|
-
const disableAnimations = this.prefersReducedMotionMediaQuery?.matches;
|
|
128
|
-
this.animationDurationMilliseconds = disableAnimations
|
|
129
|
-
? animationDurationWhenDisabledMilliseconds
|
|
130
|
-
: drawerAnimationDurationMs.getValueFor(this);
|
|
131
|
-
}
|
|
132
|
-
animateOpening() {
|
|
133
|
-
this.animateOpenClose(true);
|
|
134
|
-
}
|
|
135
|
-
animateClosing() {
|
|
136
|
-
if (!this.hidden) {
|
|
137
|
-
this.animateOpenClose(false);
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
this.state = DrawerState.Closed;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
animateOpenClose(drawerOpening) {
|
|
144
|
-
const options = {
|
|
145
|
-
...(drawerOpening
|
|
146
|
-
? animationConfig.slideInOptions
|
|
147
|
-
: animationConfig.slideOutOptions),
|
|
148
|
-
duration: this.animationDurationMilliseconds
|
|
149
|
-
};
|
|
150
|
-
const drawerKeyframes = this.location === DrawerLocation.Right
|
|
151
|
-
? animationConfig.slideRightKeyframes
|
|
152
|
-
: animationConfig.slideLeftKeyframes;
|
|
153
|
-
const dialogAnimation = new AnimateTo(this.dialog, undefined, options);
|
|
154
|
-
dialogAnimation.addKeyframes(drawerKeyframes);
|
|
155
|
-
const animations = [dialogAnimation];
|
|
156
|
-
const overlay = this.shadowRoot?.querySelector('.overlay');
|
|
157
|
-
if (overlay) {
|
|
158
|
-
const overlayAnimation = new AnimateTo(overlay, undefined, options);
|
|
159
|
-
overlayAnimation.addKeyframes(animationConfig.fadeOverlayKeyframes);
|
|
160
|
-
animations.push(overlayAnimation);
|
|
161
|
-
}
|
|
162
|
-
const animationGroup = new AnimateGroup(animations);
|
|
163
|
-
animationGroup.onFinish = () => {
|
|
164
|
-
this.state = drawerOpening
|
|
165
|
-
? DrawerState.Opened
|
|
166
|
-
: DrawerState.Closed;
|
|
167
|
-
};
|
|
168
|
-
this.animationGroup = animationGroup;
|
|
169
|
-
animationGroup.play();
|
|
170
|
-
}
|
|
171
|
-
cancelCurrentAnimation() {
|
|
172
|
-
this.animationGroup?.cancel();
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
__decorate([
|
|
176
|
-
attr
|
|
177
|
-
], Drawer.prototype, "location", void 0);
|
|
178
|
-
__decorate([
|
|
179
|
-
attr
|
|
180
|
-
], Drawer.prototype, "state", void 0);
|
|
181
|
-
__decorate([
|
|
182
|
-
attr({ attribute: 'prevent-dismiss', mode: 'boolean' })
|
|
183
|
-
], Drawer.prototype, "preventDismiss", void 0);
|
|
184
|
-
export const nimbleDrawer = Drawer.compose({
|
|
185
|
-
baseName: 'drawer',
|
|
186
|
-
template,
|
|
187
|
-
styles
|
|
188
|
-
});
|
|
189
|
-
DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleDrawer());
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { AnimateGroup, AnimateTo } from '@microsoft/fast-animation';
|
|
3
|
+
import { attr, Observable } from '@microsoft/fast-element';
|
|
4
|
+
import { DesignSystem, Dialog as FoundationDialog, dialogTemplate as template } from '@microsoft/fast-foundation';
|
|
5
|
+
import { drawerAnimationDurationMs } from '../theme-provider/design-tokens';
|
|
6
|
+
import { animationConfig } from './animations';
|
|
7
|
+
import { styles } from './styles';
|
|
8
|
+
import { DrawerLocation, DrawerState } from './types';
|
|
9
|
+
const animationDurationWhenDisabledMilliseconds = 0.001;
|
|
10
|
+
/**
|
|
11
|
+
* Drawer/Sidenav control. Shows content in a panel on the left / right side of the screen,
|
|
12
|
+
* which animates to be visible with a slide-in / slide-out animation.
|
|
13
|
+
* Configured via 'location', 'state', 'modal', 'preventDismiss' properties.
|
|
14
|
+
*/
|
|
15
|
+
export class Drawer extends FoundationDialog {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.location = DrawerLocation.Left;
|
|
19
|
+
this.state = DrawerState.Closed;
|
|
20
|
+
/**
|
|
21
|
+
* True to prevent dismissing the drawer when the overlay outside the drawer is clicked.
|
|
22
|
+
* Only applicable when 'modal' is set to true (i.e. when the overlay is used).
|
|
23
|
+
* HTML Attribute: prevent-dismiss
|
|
24
|
+
*/
|
|
25
|
+
this.preventDismiss = false;
|
|
26
|
+
this.propertiesToWatch = ['hidden', 'location', 'state'];
|
|
27
|
+
this.animationDurationMilliseconds = animationDurationWhenDisabledMilliseconds;
|
|
28
|
+
}
|
|
29
|
+
connectedCallback() {
|
|
30
|
+
// disable trapFocus before super.connectedCallback as FAST Dialog will immediately queue work to
|
|
31
|
+
// change focus if it's true before connectedCallback
|
|
32
|
+
this.trapFocus = false;
|
|
33
|
+
super.connectedCallback();
|
|
34
|
+
this.prefersReducedMotionMediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
35
|
+
this.updateAnimationDuration();
|
|
36
|
+
this.animationsEnabledChangedHandler = () => this.updateAnimationDuration();
|
|
37
|
+
this.prefersReducedMotionMediaQuery.addEventListener('change', this.animationsEnabledChangedHandler);
|
|
38
|
+
this.onStateChanged();
|
|
39
|
+
const notifier = Observable.getNotifier(this);
|
|
40
|
+
const subscriber = {
|
|
41
|
+
handleChange: (_source, propertyName) => this.onPropertyChange(propertyName)
|
|
42
|
+
};
|
|
43
|
+
this.propertiesToWatch.forEach(propertyName => notifier.subscribe(subscriber, propertyName));
|
|
44
|
+
this.propertyChangeSubscriber = subscriber;
|
|
45
|
+
this.propertyChangeNotifier = notifier;
|
|
46
|
+
}
|
|
47
|
+
disconnectedCallback() {
|
|
48
|
+
super.disconnectedCallback();
|
|
49
|
+
this.cancelCurrentAnimation();
|
|
50
|
+
if (this.propertyChangeNotifier && this.propertyChangeSubscriber) {
|
|
51
|
+
this.propertiesToWatch.forEach(propertyName => this.propertyChangeNotifier.unsubscribe(this.propertyChangeSubscriber, propertyName));
|
|
52
|
+
this.propertyChangeNotifier = undefined;
|
|
53
|
+
this.propertyChangeSubscriber = undefined;
|
|
54
|
+
}
|
|
55
|
+
if (this.prefersReducedMotionMediaQuery
|
|
56
|
+
&& this.animationsEnabledChangedHandler) {
|
|
57
|
+
this.prefersReducedMotionMediaQuery.removeEventListener('change', this.animationsEnabledChangedHandler);
|
|
58
|
+
this.prefersReducedMotionMediaQuery = undefined;
|
|
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;
|
|
69
|
+
}
|
|
70
|
+
dismiss() {
|
|
71
|
+
if (!this.preventDismiss) {
|
|
72
|
+
super.dismiss();
|
|
73
|
+
this.hide();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
onPropertyChange(propertyName) {
|
|
77
|
+
switch (propertyName) {
|
|
78
|
+
case 'hidden':
|
|
79
|
+
this.onHiddenChanged();
|
|
80
|
+
break;
|
|
81
|
+
case 'location':
|
|
82
|
+
this.onLocationChanged();
|
|
83
|
+
break;
|
|
84
|
+
case 'state':
|
|
85
|
+
this.onStateChanged();
|
|
86
|
+
break;
|
|
87
|
+
default:
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
onHiddenChanged() {
|
|
92
|
+
if (this.hidden && this.state !== DrawerState.Closed) {
|
|
93
|
+
this.state = DrawerState.Closed;
|
|
94
|
+
}
|
|
95
|
+
else if (!this.hidden && this.state === DrawerState.Closed) {
|
|
96
|
+
this.state = DrawerState.Opened;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
onLocationChanged() {
|
|
100
|
+
this.cancelCurrentAnimation();
|
|
101
|
+
}
|
|
102
|
+
onStateChanged() {
|
|
103
|
+
if (this.isConnected) {
|
|
104
|
+
this.cancelCurrentAnimation();
|
|
105
|
+
switch (this.state) {
|
|
106
|
+
case DrawerState.Opening:
|
|
107
|
+
this.animateOpening();
|
|
108
|
+
this.hidden = false;
|
|
109
|
+
break;
|
|
110
|
+
case DrawerState.Opened:
|
|
111
|
+
this.hidden = false;
|
|
112
|
+
break;
|
|
113
|
+
case DrawerState.Closing:
|
|
114
|
+
this.hidden = false;
|
|
115
|
+
this.animateClosing();
|
|
116
|
+
break;
|
|
117
|
+
case DrawerState.Closed:
|
|
118
|
+
this.hidden = true;
|
|
119
|
+
break;
|
|
120
|
+
default:
|
|
121
|
+
throw new Error('Unsupported state value. Expected: opening/opened/closing/closed');
|
|
122
|
+
}
|
|
123
|
+
this.$emit('state-change');
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
updateAnimationDuration() {
|
|
127
|
+
const disableAnimations = this.prefersReducedMotionMediaQuery?.matches;
|
|
128
|
+
this.animationDurationMilliseconds = disableAnimations
|
|
129
|
+
? animationDurationWhenDisabledMilliseconds
|
|
130
|
+
: drawerAnimationDurationMs.getValueFor(this);
|
|
131
|
+
}
|
|
132
|
+
animateOpening() {
|
|
133
|
+
this.animateOpenClose(true);
|
|
134
|
+
}
|
|
135
|
+
animateClosing() {
|
|
136
|
+
if (!this.hidden) {
|
|
137
|
+
this.animateOpenClose(false);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
this.state = DrawerState.Closed;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
animateOpenClose(drawerOpening) {
|
|
144
|
+
const options = {
|
|
145
|
+
...(drawerOpening
|
|
146
|
+
? animationConfig.slideInOptions
|
|
147
|
+
: animationConfig.slideOutOptions),
|
|
148
|
+
duration: this.animationDurationMilliseconds
|
|
149
|
+
};
|
|
150
|
+
const drawerKeyframes = this.location === DrawerLocation.Right
|
|
151
|
+
? animationConfig.slideRightKeyframes
|
|
152
|
+
: animationConfig.slideLeftKeyframes;
|
|
153
|
+
const dialogAnimation = new AnimateTo(this.dialog, undefined, options);
|
|
154
|
+
dialogAnimation.addKeyframes(drawerKeyframes);
|
|
155
|
+
const animations = [dialogAnimation];
|
|
156
|
+
const overlay = this.shadowRoot?.querySelector('.overlay');
|
|
157
|
+
if (overlay) {
|
|
158
|
+
const overlayAnimation = new AnimateTo(overlay, undefined, options);
|
|
159
|
+
overlayAnimation.addKeyframes(animationConfig.fadeOverlayKeyframes);
|
|
160
|
+
animations.push(overlayAnimation);
|
|
161
|
+
}
|
|
162
|
+
const animationGroup = new AnimateGroup(animations);
|
|
163
|
+
animationGroup.onFinish = () => {
|
|
164
|
+
this.state = drawerOpening
|
|
165
|
+
? DrawerState.Opened
|
|
166
|
+
: DrawerState.Closed;
|
|
167
|
+
};
|
|
168
|
+
this.animationGroup = animationGroup;
|
|
169
|
+
animationGroup.play();
|
|
170
|
+
}
|
|
171
|
+
cancelCurrentAnimation() {
|
|
172
|
+
this.animationGroup?.cancel();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
__decorate([
|
|
176
|
+
attr
|
|
177
|
+
], Drawer.prototype, "location", void 0);
|
|
178
|
+
__decorate([
|
|
179
|
+
attr
|
|
180
|
+
], Drawer.prototype, "state", void 0);
|
|
181
|
+
__decorate([
|
|
182
|
+
attr({ attribute: 'prevent-dismiss', mode: 'boolean' })
|
|
183
|
+
], Drawer.prototype, "preventDismiss", void 0);
|
|
184
|
+
export const nimbleDrawer = Drawer.compose({
|
|
185
|
+
baseName: 'drawer',
|
|
186
|
+
template,
|
|
187
|
+
styles
|
|
188
|
+
});
|
|
189
|
+
DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleDrawer());
|
|
190
190
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const styles: import("@microsoft/fast-element").ElementStyles;
|
|
1
|
+
export declare const styles: import("@microsoft/fast-element").ElementStyles;
|
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
import { css } from '@microsoft/fast-element';
|
|
2
|
-
import { display } from '@microsoft/fast-foundation';
|
|
3
|
-
import { applicationBackgroundColor, borderWidth, contentFontColor, contentFontSize, drawerHeaderFontFamily, drawerHeaderFontSize, fontFamily, popupBorderColor, popupBoxShadowColor } from '../theme-provider/design-tokens';
|
|
4
|
-
export const styles = css `
|
|
5
|
-
${display('block')}
|
|
6
|
-
|
|
7
|
-
:host {
|
|
8
|
-
position: relative;
|
|
9
|
-
top: 0;
|
|
10
|
-
bottom: 0;
|
|
11
|
-
width: fit-content;
|
|
12
|
-
height: 100%;
|
|
13
|
-
outline: none;
|
|
14
|
-
font-family: ${fontFamily};
|
|
15
|
-
font-size: ${contentFontSize};
|
|
16
|
-
color: ${contentFontColor};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
:host([modal]) {
|
|
20
|
-
position: absolute;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
:host([location='left']) {
|
|
24
|
-
left: 0px;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
:host([location='right']) {
|
|
28
|
-
right: 0px;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.positioning-region {
|
|
32
|
-
display: block;
|
|
33
|
-
position: relative;
|
|
34
|
-
justify-content: center;
|
|
35
|
-
width: fit-content;
|
|
36
|
-
height: 100%;
|
|
37
|
-
inset: 0px;
|
|
38
|
-
overflow: hidden;
|
|
39
|
-
z-index: 999;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
:host([modal]) .positioning-region {
|
|
43
|
-
width: 100%;
|
|
44
|
-
position: fixed;
|
|
45
|
-
display: flex;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.overlay {
|
|
49
|
-
position: fixed;
|
|
50
|
-
inset: 0px;
|
|
51
|
-
background: ${popupBorderColor};
|
|
52
|
-
touch-action: none;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.control {
|
|
56
|
-
position: relative;
|
|
57
|
-
top: 0px;
|
|
58
|
-
bottom: 0px;
|
|
59
|
-
width: fit-content;
|
|
60
|
-
height: 100%;
|
|
61
|
-
display: grid;
|
|
62
|
-
grid-template-rows: max-content auto max-content;
|
|
63
|
-
flex-direction: column;
|
|
64
|
-
box-sizing: border-box;
|
|
65
|
-
border-radius: 0px;
|
|
66
|
-
border-width: 0px;
|
|
67
|
-
width: var(--drawer-width);
|
|
68
|
-
background-color: ${applicationBackgroundColor};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
:host([modal]) .control {
|
|
72
|
-
position: absolute;
|
|
73
|
-
height: 100%;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
:host(.hidden) .control {
|
|
77
|
-
visibility: hidden;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
:host([location='left']) .control {
|
|
81
|
-
left: 0px;
|
|
82
|
-
border-right: ${borderWidth} solid ${popupBoxShadowColor};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
:host([location='right']) .control {
|
|
86
|
-
right: 0px;
|
|
87
|
-
border-left: ${borderWidth} solid ${popupBoxShadowColor};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
${
|
|
91
|
-
/*
|
|
92
|
-
Styling for a 3-panel drawer with header, footer, and a content
|
|
93
|
-
region filling the remaining space/height
|
|
94
|
-
*/ ''}
|
|
95
|
-
|
|
96
|
-
::slotted(header) {
|
|
97
|
-
padding: var(--standard-padding);
|
|
98
|
-
font-family: ${drawerHeaderFontFamily};
|
|
99
|
-
font-size: ${drawerHeaderFontSize};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
::slotted(section) {
|
|
103
|
-
padding: var(--standard-padding);
|
|
104
|
-
grid-row: 2;
|
|
105
|
-
overflow-y: auto;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
::slotted(footer) {
|
|
109
|
-
padding: var(--standard-padding);
|
|
110
|
-
display: flex;
|
|
111
|
-
justify-content: flex-end;
|
|
112
|
-
border-top: ${borderWidth} solid ${popupBorderColor};
|
|
113
|
-
}
|
|
114
|
-
`;
|
|
1
|
+
import { css } from '@microsoft/fast-element';
|
|
2
|
+
import { display } from '@microsoft/fast-foundation';
|
|
3
|
+
import { applicationBackgroundColor, borderWidth, contentFontColor, contentFontSize, drawerHeaderFontFamily, drawerHeaderFontSize, fontFamily, popupBorderColor, popupBoxShadowColor } from '../theme-provider/design-tokens';
|
|
4
|
+
export const styles = css `
|
|
5
|
+
${display('block')}
|
|
6
|
+
|
|
7
|
+
:host {
|
|
8
|
+
position: relative;
|
|
9
|
+
top: 0;
|
|
10
|
+
bottom: 0;
|
|
11
|
+
width: fit-content;
|
|
12
|
+
height: 100%;
|
|
13
|
+
outline: none;
|
|
14
|
+
font-family: ${fontFamily};
|
|
15
|
+
font-size: ${contentFontSize};
|
|
16
|
+
color: ${contentFontColor};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:host([modal]) {
|
|
20
|
+
position: absolute;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:host([location='left']) {
|
|
24
|
+
left: 0px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
:host([location='right']) {
|
|
28
|
+
right: 0px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.positioning-region {
|
|
32
|
+
display: block;
|
|
33
|
+
position: relative;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
width: fit-content;
|
|
36
|
+
height: 100%;
|
|
37
|
+
inset: 0px;
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
z-index: 999;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
:host([modal]) .positioning-region {
|
|
43
|
+
width: 100%;
|
|
44
|
+
position: fixed;
|
|
45
|
+
display: flex;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.overlay {
|
|
49
|
+
position: fixed;
|
|
50
|
+
inset: 0px;
|
|
51
|
+
background: ${popupBorderColor};
|
|
52
|
+
touch-action: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.control {
|
|
56
|
+
position: relative;
|
|
57
|
+
top: 0px;
|
|
58
|
+
bottom: 0px;
|
|
59
|
+
width: fit-content;
|
|
60
|
+
height: 100%;
|
|
61
|
+
display: grid;
|
|
62
|
+
grid-template-rows: max-content auto max-content;
|
|
63
|
+
flex-direction: column;
|
|
64
|
+
box-sizing: border-box;
|
|
65
|
+
border-radius: 0px;
|
|
66
|
+
border-width: 0px;
|
|
67
|
+
width: var(--drawer-width);
|
|
68
|
+
background-color: ${applicationBackgroundColor};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host([modal]) .control {
|
|
72
|
+
position: absolute;
|
|
73
|
+
height: 100%;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
:host(.hidden) .control {
|
|
77
|
+
visibility: hidden;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
:host([location='left']) .control {
|
|
81
|
+
left: 0px;
|
|
82
|
+
border-right: ${borderWidth} solid ${popupBoxShadowColor};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
:host([location='right']) .control {
|
|
86
|
+
right: 0px;
|
|
87
|
+
border-left: ${borderWidth} solid ${popupBoxShadowColor};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
${
|
|
91
|
+
/*
|
|
92
|
+
Styling for a 3-panel drawer with header, footer, and a content
|
|
93
|
+
region filling the remaining space/height
|
|
94
|
+
*/ ''}
|
|
95
|
+
|
|
96
|
+
::slotted(header) {
|
|
97
|
+
padding: var(--standard-padding);
|
|
98
|
+
font-family: ${drawerHeaderFontFamily};
|
|
99
|
+
font-size: ${drawerHeaderFontSize};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
::slotted(section) {
|
|
103
|
+
padding: var(--standard-padding);
|
|
104
|
+
grid-row: 2;
|
|
105
|
+
overflow-y: auto;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
::slotted(footer) {
|
|
109
|
+
padding: var(--standard-padding);
|
|
110
|
+
display: flex;
|
|
111
|
+
justify-content: flex-end;
|
|
112
|
+
border-top: ${borderWidth} solid ${popupBorderColor};
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
115
115
|
//# sourceMappingURL=styles.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare enum DrawerLocation {
|
|
2
|
-
Left = "left",
|
|
3
|
-
Right = "right"
|
|
4
|
-
}
|
|
5
|
-
export declare enum DrawerState {
|
|
6
|
-
Opening = "opening",
|
|
7
|
-
Opened = "opened",
|
|
8
|
-
Closing = "closing",
|
|
9
|
-
Closed = "closed"
|
|
10
|
-
}
|
|
1
|
+
export declare enum DrawerLocation {
|
|
2
|
+
Left = "left",
|
|
3
|
+
Right = "right"
|
|
4
|
+
}
|
|
5
|
+
export declare enum DrawerState {
|
|
6
|
+
Opening = "opening",
|
|
7
|
+
Opened = "opened",
|
|
8
|
+
Closing = "closing",
|
|
9
|
+
Closed = "closed"
|
|
10
|
+
}
|
package/dist/esm/drawer/types.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export var DrawerLocation;
|
|
2
|
-
(function (DrawerLocation) {
|
|
3
|
-
DrawerLocation["Left"] = "left";
|
|
4
|
-
DrawerLocation["Right"] = "right";
|
|
5
|
-
})(DrawerLocation || (DrawerLocation = {}));
|
|
6
|
-
export var DrawerState;
|
|
7
|
-
(function (DrawerState) {
|
|
8
|
-
DrawerState["Opening"] = "opening";
|
|
9
|
-
DrawerState["Opened"] = "opened";
|
|
10
|
-
DrawerState["Closing"] = "closing";
|
|
11
|
-
DrawerState["Closed"] = "closed";
|
|
12
|
-
})(DrawerState || (DrawerState = {}));
|
|
1
|
+
export var DrawerLocation;
|
|
2
|
+
(function (DrawerLocation) {
|
|
3
|
+
DrawerLocation["Left"] = "left";
|
|
4
|
+
DrawerLocation["Right"] = "right";
|
|
5
|
+
})(DrawerLocation || (DrawerLocation = {}));
|
|
6
|
+
export var DrawerState;
|
|
7
|
+
(function (DrawerState) {
|
|
8
|
+
DrawerState["Opening"] = "opening";
|
|
9
|
+
DrawerState["Opened"] = "opened";
|
|
10
|
+
DrawerState["Closing"] = "closing";
|
|
11
|
+
DrawerState["Closed"] = "closed";
|
|
12
|
+
})(DrawerState || (DrawerState = {}));
|
|
13
13
|
//# sourceMappingURL=types.js.map
|