@neovici/cosmoz-bottom-bar 7.5.0 → 7.5.1

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.
@@ -1,4 +1,3 @@
1
- /* eslint-disable max-lines */
2
1
  import {
3
2
  PolymerElement,
4
3
  html as polymerHtml,
@@ -7,10 +6,10 @@ import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nod
7
6
  import { Debouncer } from '@polymer/polymer/lib/utils/debounce.js';
8
7
  import { timeOut } from '@polymer/polymer/lib/utils/async';
9
8
  import { html } from 'lit-html';
9
+ import { hauntedPolymer } from '@neovici/cosmoz-utils';
10
10
  import { useActivity } from '@neovici/cosmoz-utils/keybindings/use-activity';
11
11
  import { defaultPlacement } from '@neovici/cosmoz-dropdown';
12
12
  import template from './cosmoz-bottom-bar.html.js';
13
- import { hauntedPolymer } from '@neovici/cosmoz-utils';
14
13
 
15
14
  const BOTTOM_BAR_TOOLBAR_SLOT = 'bottom-bar-toolbar',
16
15
  BOTTOM_BAR_MENU_SLOT = 'bottom-bar-menu',
@@ -63,11 +62,9 @@ const openActionsMenu = (host) => {
63
62
  */
64
63
  class CosmozBottomBar extends hauntedPolymer(useBottomBar)(PolymerElement) {
65
64
  static get template() {
66
- // eslint-disable-line max-lines-per-function
67
65
  return template;
68
66
  }
69
67
 
70
- // eslint-disable-next-line max-lines-per-function
71
68
  static get properties() {
72
69
  return {
73
70
  /**
@@ -241,7 +238,7 @@ class CosmozBottomBar extends hauntedPolymer(useBottomBar)(PolymerElement) {
241
238
  [...this._nodeObservers, this._hiddenMutationObserver].forEach((e) =>
242
239
  e.disconnect(e),
243
240
  );
244
- this._layoutDebouncer?.cancel(); /* eslint-disable-line no-unused-expressions */
241
+ this._layoutDebouncer?.cancel();
245
242
  this._resizeObserver.unobserve(this);
246
243
  }
247
244
 
@@ -336,6 +333,18 @@ class CosmozBottomBar extends hauntedPolymer(useBottomBar)(PolymerElement) {
336
333
  ...elements.filter((e) => e !== topPriorityAction),
337
334
  ];
338
335
  }
336
+
337
+ _distribute(hostWidth) {
338
+ const elements = this._getElements();
339
+
340
+ const tooNarrow = hostWidth <= 480,
341
+ toolbarElements = elements.slice(0, tooNarrow ? 0 : this.maxToolbarItems),
342
+ menuElements = elements.slice(toolbarElements.length);
343
+ toolbarElements.forEach((el) => this._moveElement(el, true));
344
+ menuElements.forEach((el) => this._moveElement(el));
345
+ this._setHasMenuItems(menuElements.length > 0);
346
+ }
347
+
339
348
  /**
340
349
  * Layout the actions available as buttons or menu items
341
350
  *
@@ -357,7 +366,6 @@ class CosmozBottomBar extends hauntedPolymer(useBottomBar)(PolymerElement) {
357
366
  * @returns {void}
358
367
  */
359
368
  _layoutActions() {
360
- // eslint-disable-line max-statements
361
369
  const elements = this._getElements(),
362
370
  hasActions = elements.length > 0 || this.hasExtraItems;
363
371
  this._setHasActions(hasActions);
@@ -367,11 +375,7 @@ class CosmozBottomBar extends hauntedPolymer(useBottomBar)(PolymerElement) {
367
375
  return this._setHasMenuItems(false);
368
376
  }
369
377
 
370
- const toolbarElements = elements.slice(0, this.maxToolbarItems),
371
- menuElements = elements.slice(toolbarElements.length);
372
- toolbarElements.forEach((el) => this._moveElement(el, true));
373
- menuElements.forEach((el) => this._moveElement(el));
374
- this._setHasMenuItems(menuElements.length > 0);
378
+ this._distribute(this.getBoundingClientRect().width);
375
379
  }
376
380
 
377
381
  _moveElement(element, toToolbar) {
@@ -395,6 +399,7 @@ class CosmozBottomBar extends hauntedPolymer(useBottomBar)(PolymerElement) {
395
399
  this._matchHeightElement,
396
400
  this.barHeight,
397
401
  );
402
+ this._distribute(entry.contentRect?.width);
398
403
  }
399
404
 
400
405
  _showHideBottomBar(visible) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-bottom-bar",
3
- "version": "7.5.0",
3
+ "version": "7.5.1",
4
4
  "description": "A responsive bottom-bar that can house buttons/actions and a menu for the buttons that won't fit the available width.",
5
5
  "keywords": [
6
6
  "polymer",