@neovici/cosmoz-bottom-bar 5.0.0 → 5.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/cosmoz-bottom-bar.html.js +3 -0
- package/cosmoz-bottom-bar.js +26 -8
- package/package.json +1 -1
package/cosmoz-bottom-bar.js
CHANGED
|
@@ -11,7 +11,8 @@ import { defaultPlacement } from '@neovici/cosmoz-dropdown';
|
|
|
11
11
|
|
|
12
12
|
const
|
|
13
13
|
BOTTOM_BAR_TOOLBAR_SLOT = 'bottom-bar-toolbar',
|
|
14
|
-
BOTTOM_BAR_MENU_SLOT = 'bottom-bar-menu'
|
|
14
|
+
BOTTOM_BAR_MENU_SLOT = 'bottom-bar-menu',
|
|
15
|
+
rendered = Symbol('rendered');
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* `<cosmoz-bottom-bar>` is a horizontal responsive bottom toolbar containing items that
|
|
@@ -130,6 +131,16 @@ class CosmozBottomBar extends PolymerElement {
|
|
|
130
131
|
type: Number
|
|
131
132
|
},
|
|
132
133
|
|
|
134
|
+
renderOpen: {
|
|
135
|
+
type: Boolean,
|
|
136
|
+
value: false
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
forceOpen: {
|
|
140
|
+
type: Boolean,
|
|
141
|
+
value: false
|
|
142
|
+
},
|
|
143
|
+
|
|
133
144
|
/**
|
|
134
145
|
* Whether the bar is visible (has actions and is `active`)
|
|
135
146
|
*/
|
|
@@ -137,7 +148,7 @@ class CosmozBottomBar extends PolymerElement {
|
|
|
137
148
|
type: Boolean,
|
|
138
149
|
notify: true,
|
|
139
150
|
readOnly: true,
|
|
140
|
-
computed: '_computeVisible(hasActions, active, hasExtraItems)'
|
|
151
|
+
computed: '_computeVisible(hasActions, active, hasExtraItems, forceOpen)'
|
|
141
152
|
},
|
|
142
153
|
|
|
143
154
|
/**
|
|
@@ -166,7 +177,7 @@ class CosmozBottomBar extends PolymerElement {
|
|
|
166
177
|
|
|
167
178
|
static get observers() {
|
|
168
179
|
return [
|
|
169
|
-
'_showHideBottomBar(visible)'
|
|
180
|
+
'_showHideBottomBar(visible, renderOpen)'
|
|
170
181
|
];
|
|
171
182
|
}
|
|
172
183
|
|
|
@@ -198,6 +209,7 @@ class CosmozBottomBar extends PolymerElement {
|
|
|
198
209
|
|
|
199
210
|
disconnectedCallback() {
|
|
200
211
|
super.disconnectedCallback();
|
|
212
|
+
this[rendered] = false;
|
|
201
213
|
|
|
202
214
|
[...this._nodeObservers, this._hiddenMutationObserver].forEach(e => e.disconnect(e));
|
|
203
215
|
this._layoutDebouncer?.cancel(); /* eslint-disable-line no-unused-expressions */
|
|
@@ -230,8 +242,8 @@ class CosmozBottomBar extends PolymerElement {
|
|
|
230
242
|
return barHeight;
|
|
231
243
|
}
|
|
232
244
|
|
|
233
|
-
_computeVisible(hasActions, active, hasExtraItems) {
|
|
234
|
-
return (hasActions || hasExtraItems) && active;
|
|
245
|
+
_computeVisible(hasActions, active, hasExtraItems, forceOpen) {
|
|
246
|
+
return forceOpen || ((hasActions || hasExtraItems) && active);
|
|
235
247
|
}
|
|
236
248
|
|
|
237
249
|
_debounceLayoutActions() {
|
|
@@ -268,7 +280,7 @@ class CosmozBottomBar extends PolymerElement {
|
|
|
268
280
|
return FlattenedNodesObserver.getFlattenedNodes(this)
|
|
269
281
|
.filter(this._isActionNode)
|
|
270
282
|
.filter(element => !element.hidden)
|
|
271
|
-
.sort((a, b) => a.dataset.index - b.dataset.index);
|
|
283
|
+
.sort((a, b) => (a.dataset.index ?? 0) - (b.dataset.index ?? 0 ));
|
|
272
284
|
}
|
|
273
285
|
/**
|
|
274
286
|
* Layout the actions available as buttons or menu items
|
|
@@ -325,15 +337,21 @@ class CosmozBottomBar extends PolymerElement {
|
|
|
325
337
|
this._computedBarHeightKicker += 1;
|
|
326
338
|
}
|
|
327
339
|
|
|
328
|
-
_showHideBottomBar(visible) {
|
|
340
|
+
_showHideBottomBar(visible, renderOpen) {
|
|
329
341
|
this.style.transitionDuration = 0;
|
|
330
342
|
this.style.display = '';
|
|
331
343
|
this.style.maxHeight = '';
|
|
332
344
|
|
|
333
345
|
const height = this.computedBarHeight,
|
|
334
|
-
from = visible ? '0px' : height + 'px',
|
|
335
346
|
to = !visible ? '0px' : height + 'px';
|
|
336
347
|
|
|
348
|
+
let from = visible ? '0px' : height + 'px';
|
|
349
|
+
|
|
350
|
+
if(visible && renderOpen && !this[rendered]) {
|
|
351
|
+
from = to;
|
|
352
|
+
this[rendered] = true;
|
|
353
|
+
}
|
|
354
|
+
|
|
337
355
|
this.style.maxHeight = from;
|
|
338
356
|
|
|
339
357
|
const onEnd = () => {
|
package/package.json
CHANGED