@aquera/nile-elements 0.0.11 → 0.0.12
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/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-dialog/nile-dialog.css.js +3 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-dialog/nile-dialog.css.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-dialog/nile-dialog.d.ts +4 -0
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-dialog/nile-dialog.js +64 -17
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/src/nile-dialog/nile-dialog.js.map +1 -1
- package/.rollup.cache/opt/atlassian/pipelines/agent/build/packages/nile-elements/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/index.iife.js +17 -4
- package/dist/nile-dialog/nile-dialog.cjs.js +1 -1
- package/dist/nile-dialog/nile-dialog.cjs.js.map +1 -1
- package/dist/nile-dialog/nile-dialog.css.cjs.js +1 -1
- package/dist/nile-dialog/nile-dialog.css.cjs.js.map +1 -1
- package/dist/nile-dialog/nile-dialog.css.esm.js +3 -0
- package/dist/nile-dialog/nile-dialog.esm.js +14 -4
- package/dist/src/nile-dialog/nile-dialog.css.js +3 -0
- package/dist/src/nile-dialog/nile-dialog.css.js.map +1 -1
- package/dist/src/nile-dialog/nile-dialog.d.ts +4 -0
- package/dist/src/nile-dialog/nile-dialog.js +64 -17
- package/dist/src/nile-dialog/nile-dialog.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-dialog/nile-dialog.css.ts +3 -0
- package/src/nile-dialog/nile-dialog.ts +82 -24
package/package.json
CHANGED
@@ -30,7 +30,6 @@ import NileElement from '../internal/nile-element';
|
|
30
30
|
*/
|
31
31
|
@customElement('nile-dialog')
|
32
32
|
export class NileDialog extends NileElement {
|
33
|
-
|
34
33
|
static styles: CSSResultGroup = styles;
|
35
34
|
|
36
35
|
private readonly hasSlotController = new HasSlotController(this, 'footer');
|
@@ -61,6 +60,16 @@ export class NileDialog extends NileElement {
|
|
61
60
|
|
62
61
|
@property({ type: Boolean, reflect: true }) preventOverlayClose = false;
|
63
62
|
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Added to resolve conflicts between Angular Material's mat-drawer components.
|
66
|
+
*/
|
67
|
+
private drawerStyle = `
|
68
|
+
<style id="drawer-style">
|
69
|
+
.mat-drawer.mat-drawer-side { z-index: 1; }
|
70
|
+
</style>
|
71
|
+
`;
|
72
|
+
|
64
73
|
connectedCallback() {
|
65
74
|
super.connectedCallback();
|
66
75
|
this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);
|
@@ -74,6 +83,7 @@ export class NileDialog extends NileElement {
|
|
74
83
|
this.addOpenListeners();
|
75
84
|
this.modal.activate();
|
76
85
|
lockBodyScrolling(this);
|
86
|
+
document.head.insertAdjacentHTML('beforeend', this.drawerStyle);
|
77
87
|
}
|
78
88
|
}
|
79
89
|
|
@@ -83,19 +93,20 @@ export class NileDialog extends NileElement {
|
|
83
93
|
}
|
84
94
|
|
85
95
|
private requestClose(source: 'close-button' | 'keyboard' | 'overlay') {
|
86
|
-
|
87
96
|
const nileRequestClose = this.emit('nile-request-close', {
|
88
97
|
cancelable: true,
|
89
|
-
detail: { source }
|
98
|
+
detail: { source },
|
90
99
|
});
|
91
100
|
|
92
|
-
if(source === 'close-button'){
|
101
|
+
if (source === 'close-button') {
|
93
102
|
this.hide();
|
94
103
|
return;
|
95
104
|
}
|
96
105
|
|
97
|
-
if (nileRequestClose.defaultPrevented || this.preventOverlayClose
|
98
|
-
const animation = getAnimation(this, 'dialog.denyClose', {
|
106
|
+
if (nileRequestClose.defaultPrevented || this.preventOverlayClose) {
|
107
|
+
const animation = getAnimation(this, 'dialog.denyClose', {
|
108
|
+
dir: 'right',
|
109
|
+
});
|
99
110
|
animateTo(this.panel, animation.keyframes, animation.options);
|
100
111
|
return;
|
101
112
|
}
|
@@ -121,12 +132,11 @@ export class NileDialog extends NileElement {
|
|
121
132
|
@watch('open', { waitUntilFirstUpdate: true })
|
122
133
|
async handleOpenChange() {
|
123
134
|
if (this.open) {
|
124
|
-
// Show
|
125
135
|
this.emit('nile-show');
|
126
136
|
this.addOpenListeners();
|
127
137
|
this.originalTrigger = document.activeElement as HTMLElement;
|
128
138
|
this.modal.activate();
|
129
|
-
|
139
|
+
document.head.insertAdjacentHTML('beforeend', this.drawerStyle);
|
130
140
|
lockBodyScrolling(this);
|
131
141
|
|
132
142
|
// When the dialog is shown, Safari will attempt to set focus on whatever element has autofocus. This can cause
|
@@ -140,17 +150,24 @@ export class NileDialog extends NileElement {
|
|
140
150
|
autoFocusTarget.removeAttribute('autofocus');
|
141
151
|
}
|
142
152
|
|
143
|
-
await Promise.all([
|
153
|
+
await Promise.all([
|
154
|
+
stopAnimations(this.dialog),
|
155
|
+
stopAnimations(this.overlay),
|
156
|
+
]);
|
144
157
|
this.dialog.hidden = false;
|
145
158
|
|
146
159
|
// Set initial focus
|
147
160
|
requestAnimationFrame(() => {
|
148
|
-
const nileInitialFocus = this.emit('nile-initial-focus', {
|
161
|
+
const nileInitialFocus = this.emit('nile-initial-focus', {
|
162
|
+
cancelable: true,
|
163
|
+
});
|
149
164
|
|
150
165
|
if (!nileInitialFocus.defaultPrevented) {
|
151
166
|
// Set focus to the autofocus target and restore the attribute
|
152
167
|
if (autoFocusTarget) {
|
153
|
-
(autoFocusTarget as HTMLInputElement).focus({
|
168
|
+
(autoFocusTarget as HTMLInputElement).focus({
|
169
|
+
preventScroll: true,
|
170
|
+
});
|
154
171
|
} else {
|
155
172
|
this.panel.focus({ preventScroll: true });
|
156
173
|
}
|
@@ -162,11 +179,19 @@ export class NileDialog extends NileElement {
|
|
162
179
|
}
|
163
180
|
});
|
164
181
|
|
165
|
-
const panelAnimation = getAnimation(this, 'dialog.show', {
|
166
|
-
|
182
|
+
const panelAnimation = getAnimation(this, 'dialog.show', {
|
183
|
+
dir: 'right',
|
184
|
+
});
|
185
|
+
const overlayAnimation = getAnimation(this, 'dialog.overlay.show', {
|
186
|
+
dir: 'right',
|
187
|
+
});
|
167
188
|
await Promise.all([
|
168
189
|
animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options),
|
169
|
-
animateTo(
|
190
|
+
animateTo(
|
191
|
+
this.overlay,
|
192
|
+
overlayAnimation.keyframes,
|
193
|
+
overlayAnimation.options
|
194
|
+
),
|
170
195
|
]);
|
171
196
|
|
172
197
|
this.emit('nile-after-show');
|
@@ -176,20 +201,39 @@ export class NileDialog extends NileElement {
|
|
176
201
|
this.removeOpenListeners();
|
177
202
|
this.modal.deactivate();
|
178
203
|
|
179
|
-
await Promise.all([
|
180
|
-
|
181
|
-
|
204
|
+
await Promise.all([
|
205
|
+
stopAnimations(this.dialog),
|
206
|
+
stopAnimations(this.overlay),
|
207
|
+
]);
|
208
|
+
const panelAnimation = getAnimation(this, 'dialog.hide', {
|
209
|
+
dir: 'right',
|
210
|
+
});
|
211
|
+
const overlayAnimation = getAnimation(this, 'dialog.overlay.hide', {
|
212
|
+
dir: 'right',
|
213
|
+
});
|
182
214
|
|
215
|
+
const styleTag = document.getElementById('drawer-style');
|
216
|
+
if (styleTag) {
|
217
|
+
document.head.removeChild(styleTag);
|
218
|
+
}
|
183
219
|
// Animate the overlay and the panel at the same time. Because animation durations might be different, we need to
|
184
220
|
// hide each one individually when the animation finishes, otherwise the first one that finishes will reappear
|
185
221
|
// unexpectedly. We'll unhide them after all animations have completed.
|
186
222
|
await Promise.all([
|
187
|
-
animateTo(
|
223
|
+
animateTo(
|
224
|
+
this.overlay,
|
225
|
+
overlayAnimation.keyframes,
|
226
|
+
overlayAnimation.options
|
227
|
+
).then(() => {
|
188
228
|
this.overlay.hidden = true;
|
189
229
|
}),
|
190
|
-
animateTo(
|
230
|
+
animateTo(
|
231
|
+
this.panel,
|
232
|
+
panelAnimation.keyframes,
|
233
|
+
panelAnimation.options
|
234
|
+
).then(() => {
|
191
235
|
this.panel.hidden = true;
|
192
|
-
})
|
236
|
+
}),
|
193
237
|
]);
|
194
238
|
|
195
239
|
this.dialog.hidden = true;
|
@@ -237,10 +281,15 @@ export class NileDialog extends NileElement {
|
|
237
281
|
class=${classMap({
|
238
282
|
dialog: true,
|
239
283
|
'dialog--open': this.open,
|
240
|
-
'dialog--has-footer': this.hasSlotController.test('footer')
|
284
|
+
'dialog--has-footer': this.hasSlotController.test('footer'),
|
241
285
|
})}
|
242
286
|
>
|
243
|
-
<div
|
287
|
+
<div
|
288
|
+
part="overlay"
|
289
|
+
class="dialog__overlay"
|
290
|
+
@click=${() => this.requestClose('overlay')}
|
291
|
+
tabindex="-1"
|
292
|
+
></div>
|
244
293
|
|
245
294
|
<div
|
246
295
|
part="panel"
|
@@ -256,7 +305,11 @@ export class NileDialog extends NileElement {
|
|
256
305
|
? html`
|
257
306
|
<header part="header" class="dialog__header">
|
258
307
|
<h2 part="title" class="dialog__title" id="title">
|
259
|
-
<slot name="label">
|
308
|
+
<slot name="label">
|
309
|
+
${this.label.length > 0
|
310
|
+
? this.label
|
311
|
+
: String.fromCharCode(65279)}
|
312
|
+
</slot>
|
260
313
|
</h2>
|
261
314
|
<div part="header-actions" class="dialog__header-actions">
|
262
315
|
<slot name="header-actions"></slot>
|
@@ -274,7 +327,12 @@ export class NileDialog extends NileElement {
|
|
274
327
|
`
|
275
328
|
: ''}
|
276
329
|
|
277
|
-
<slot
|
330
|
+
<slot
|
331
|
+
part="body"
|
332
|
+
class="dialog__body ${this.noHeader
|
333
|
+
? 'dialog__body-noheader'
|
334
|
+
: ''}"
|
335
|
+
></slot>
|
278
336
|
|
279
337
|
<footer part="footer" class="dialog__footer">
|
280
338
|
<slot name="footer"></slot>
|