@neovici/cosmoz-bottom-bar 5.2.0 → 5.2.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,16 +1,16 @@
1
1
  /* eslint-disable max-lines */
2
2
  import {
3
- PolymerElement, html as polymerHtml
3
+ PolymerElement,
4
+ html as polymerHtml,
4
5
  } from '@polymer/polymer/polymer-element.js';
5
6
  import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer';
6
7
  import { Debouncer } from '@polymer/polymer/lib/utils/debounce.js';
7
8
  import { timeOut } from '@polymer/polymer/lib/utils/async';
8
- import template from './cosmoz-bottom-bar.html.js';
9
- import { html } from 'haunted';
9
+ import { html } from 'lit-html';
10
10
  import { defaultPlacement } from '@neovici/cosmoz-dropdown';
11
+ import template from './cosmoz-bottom-bar.html.js';
11
12
 
12
- const
13
- BOTTOM_BAR_TOOLBAR_SLOT = 'bottom-bar-toolbar',
13
+ const BOTTOM_BAR_TOOLBAR_SLOT = 'bottom-bar-toolbar',
14
14
  BOTTOM_BAR_MENU_SLOT = 'bottom-bar-menu',
15
15
  rendered = Symbol('rendered');
16
16
 
@@ -33,9 +33,10 @@ const
33
33
  * @element cosmoz-bottom-bar
34
34
  * @demo demo/bottom-bar.html Basic Demo
35
35
  * @demo demo/bottom-bar-match-parent.html match parent Demo
36
- */
36
+ */
37
37
  class CosmozBottomBar extends PolymerElement {
38
- static get template() { // eslint-disable-line max-lines-per-function
38
+ static get template() {
39
+ // eslint-disable-line max-lines-per-function
39
40
  return template;
40
41
  }
41
42
 
@@ -49,7 +50,7 @@ class CosmozBottomBar extends PolymerElement {
49
50
  type: Boolean,
50
51
  value: false,
51
52
  notify: true,
52
- reflectToAttribute: true
53
+ reflectToAttribute: true,
53
54
  },
54
55
 
55
56
  /**
@@ -57,7 +58,7 @@ class CosmozBottomBar extends PolymerElement {
57
58
  */
58
59
  barHeight: {
59
60
  type: Number,
60
- value: 64
61
+ value: 64,
61
62
  },
62
63
 
63
64
  /**
@@ -65,7 +66,7 @@ class CosmozBottomBar extends PolymerElement {
65
66
  */
66
67
  matchParent: {
67
68
  type: Boolean,
68
- value: false
69
+ value: false,
69
70
  },
70
71
 
71
72
  /**
@@ -75,12 +76,12 @@ class CosmozBottomBar extends PolymerElement {
75
76
  type: Boolean,
76
77
  value: false,
77
78
  readOnly: true,
78
- notify: true
79
+ notify: true,
79
80
  },
80
81
 
81
82
  hasExtraItems: {
82
83
  type: Boolean,
83
- value: false
84
+ value: false,
84
85
  },
85
86
 
86
87
  /**
@@ -88,7 +89,7 @@ class CosmozBottomBar extends PolymerElement {
88
89
  */
89
90
  selectedClass: {
90
91
  type: String,
91
- value: 'cosmoz-bottom-bar-selected-item'
92
+ value: 'cosmoz-bottom-bar-selected-item',
92
93
  },
93
94
 
94
95
  /**
@@ -96,7 +97,7 @@ class CosmozBottomBar extends PolymerElement {
96
97
  */
97
98
  toolbarClass: {
98
99
  type: String,
99
- value: 'cosmoz-bottom-bar-toolbar'
100
+ value: 'cosmoz-bottom-bar-toolbar',
100
101
  },
101
102
 
102
103
  /**
@@ -104,7 +105,7 @@ class CosmozBottomBar extends PolymerElement {
104
105
  */
105
106
  menuClass: {
106
107
  type: String,
107
- value: 'cosmoz-bottom-bar-menu'
108
+ value: 'cosmoz-bottom-bar-menu',
108
109
  },
109
110
 
110
111
  /**
@@ -112,7 +113,7 @@ class CosmozBottomBar extends PolymerElement {
112
113
  */
113
114
  maxToolbarItems: {
114
115
  type: Number,
115
- value: 1
116
+ value: 1,
116
117
  },
117
118
 
118
119
  /**
@@ -120,25 +121,26 @@ class CosmozBottomBar extends PolymerElement {
120
121
  */
121
122
  computedBarHeight: {
122
123
  type: Number,
123
- computed: '_computeComputedBarHeight(_matchHeightElement, barHeight, _computedBarHeightKicker)',
124
- notify: true
124
+ computed:
125
+ '_computeComputedBarHeight(_matchHeightElement, barHeight, _computedBarHeightKicker)',
126
+ notify: true,
125
127
  },
126
128
 
127
129
  /**
128
130
  * Kicker to make `computedBarHeight` recalculate
129
131
  */
130
132
  _computedBarHeightKicker: {
131
- type: Number
133
+ type: Number,
132
134
  },
133
135
 
134
136
  renderOpen: {
135
137
  type: Boolean,
136
- value: false
138
+ value: false,
137
139
  },
138
140
 
139
141
  forceOpen: {
140
142
  type: Boolean,
141
- value: false
143
+ value: false,
142
144
  },
143
145
 
144
146
  /**
@@ -148,7 +150,8 @@ class CosmozBottomBar extends PolymerElement {
148
150
  type: Boolean,
149
151
  notify: true,
150
152
  readOnly: true,
151
- computed: '_computeVisible(hasActions, active, hasExtraItems, forceOpen)'
153
+ computed:
154
+ '_computeVisible(hasActions, active, hasExtraItems, forceOpen)',
152
155
  },
153
156
 
154
157
  /**
@@ -158,7 +161,7 @@ class CosmozBottomBar extends PolymerElement {
158
161
  type: Boolean,
159
162
  value: false,
160
163
  readOnly: true,
161
- notify: true
164
+ notify: true,
162
165
  },
163
166
 
164
167
  /**
@@ -166,19 +169,17 @@ class CosmozBottomBar extends PolymerElement {
166
169
  */
167
170
  _matchHeightElement: {
168
171
  type: Object,
169
- computed: '_getHeightMatchingElement(matchParent)'
172
+ computed: '_getHeightMatchingElement(matchParent)',
170
173
  },
171
174
 
172
175
  topPlacement: {
173
- value: ['top-right', ...defaultPlacement]
174
- }
176
+ value: ['top-right', ...defaultPlacement],
177
+ },
175
178
  };
176
179
  }
177
180
 
178
181
  static get observers() {
179
- return [
180
- '_showHideBottomBar(visible, renderOpen)'
181
- ];
182
+ return ['_showHideBottomBar(visible, renderOpen)'];
182
183
  }
183
184
 
184
185
  constructor() {
@@ -194,15 +195,20 @@ class CosmozBottomBar extends PolymerElement {
194
195
  connectedCallback() {
195
196
  super.connectedCallback();
196
197
 
197
-
198
- const layoutOnRemove = info => info.removedNodes.filter(this._isActionNode) && this._debounceLayoutActions();
198
+ const layoutOnRemove = (info) =>
199
+ info.removedNodes.filter(this._isActionNode) &&
200
+ this._debounceLayoutActions();
199
201
  this._nodeObservers = [
200
202
  new FlattenedNodesObserver(this.$.content, this._boundChildrenUpdated),
201
- new FlattenedNodesObserver(this.$.extraSlot, info => this.set('hasExtraItems', info.addedNodes.length > 0)),
203
+ new FlattenedNodesObserver(this.$.extraSlot, (info) =>
204
+ this.set('hasExtraItems', info.addedNodes.length > 0)
205
+ ),
202
206
  new FlattenedNodesObserver(this.$.bottomBarToolbar, layoutOnRemove),
203
- new FlattenedNodesObserver(this.$.bottomBarMenu, layoutOnRemove)
207
+ new FlattenedNodesObserver(this.$.bottomBarMenu, layoutOnRemove),
204
208
  ];
205
- this._hiddenMutationObserver = new MutationObserver(() => this._debounceLayoutActions());
209
+ this._hiddenMutationObserver = new MutationObserver(() =>
210
+ this._debounceLayoutActions()
211
+ );
206
212
  this._resizeObserver.observe(this);
207
213
  this._computedBarHeightKicker = 0;
208
214
  }
@@ -211,7 +217,9 @@ class CosmozBottomBar extends PolymerElement {
211
217
  super.disconnectedCallback();
212
218
  this[rendered] = false;
213
219
 
214
- [...this._nodeObservers, this._hiddenMutationObserver].forEach(e => e.disconnect(e));
220
+ [...this._nodeObservers, this._hiddenMutationObserver].forEach((e) =>
221
+ e.disconnect(e)
222
+ );
215
223
  this._layoutDebouncer?.cancel(); /* eslint-disable-line no-unused-expressions */
216
224
  this._resizeObserver.unobserve(this);
217
225
  }
@@ -219,15 +227,18 @@ class CosmozBottomBar extends PolymerElement {
219
227
  _childrenUpdated(info) {
220
228
  const addedNodes = info.addedNodes.filter(this._isActionNode),
221
229
  removedNodes = info.removedNodes.filter(this._isActionNode),
222
- newNodes = addedNodes.filter(node => !removedNodes.includes(node));
230
+ newNodes = addedNodes.filter((node) => !removedNodes.includes(node));
223
231
 
224
- if (addedNodes.length === 0 && removedNodes.length === 0 || newNodes.length === 0) {
232
+ if (
233
+ (addedNodes.length === 0 && removedNodes.length === 0) ||
234
+ newNodes.length === 0
235
+ ) {
225
236
  return;
226
237
  }
227
- newNodes.forEach(node => {
238
+ newNodes.forEach((node) => {
228
239
  this._hiddenMutationObserver.observe(node, {
229
240
  attributes: true,
230
- attributeFilter: ['hidden']
241
+ attributeFilter: ['hidden'],
231
242
  });
232
243
  this._moveElement(node, false);
233
244
  });
@@ -267,20 +278,22 @@ class CosmozBottomBar extends PolymerElement {
267
278
  }
268
279
 
269
280
  _isActionNode(node) {
270
- return node.nodeType === Node.ELEMENT_NODE &&
281
+ return (
282
+ node.nodeType === Node.ELEMENT_NODE &&
271
283
  node.getAttribute('slot') !== 'info' &&
272
284
  node.tagName !== 'TEMPLATE' &&
273
285
  node.tagName !== 'STYLE' &&
274
286
  node.tagName !== 'DOM-REPEAT' &&
275
287
  node.tagName !== 'DOM-IF' &&
276
- node.getAttribute('slot') !== 'extra';
288
+ node.getAttribute('slot') !== 'extra'
289
+ );
277
290
  }
278
291
 
279
292
  _getElements() {
280
293
  return FlattenedNodesObserver.getFlattenedNodes(this)
281
294
  .filter(this._isActionNode)
282
- .filter(element => !element.hidden)
283
- .sort((a, b) => (a.dataset.index ?? 0) - (b.dataset.index ?? 0 ));
295
+ .filter((element) => !element.hidden)
296
+ .sort((a, b) => (a.dataset.index ?? 0) - (b.dataset.index ?? 0));
284
297
  }
285
298
  /**
286
299
  * Layout the actions available as buttons or menu items
@@ -302,7 +315,8 @@ class CosmozBottomBar extends PolymerElement {
302
315
  *
303
316
  * @returns {void}
304
317
  */
305
- _layoutActions() { // eslint-disable-line max-statements
318
+ _layoutActions() {
319
+ // eslint-disable-line max-statements
306
320
  const elements = this._getElements(),
307
321
  hasActions = elements.length > 0 || this.hasExtraItems;
308
322
  this._setHasActions(hasActions);
@@ -314,8 +328,8 @@ class CosmozBottomBar extends PolymerElement {
314
328
 
315
329
  const toolbarElements = elements.slice(0, this.maxToolbarItems),
316
330
  menuElements = elements.slice(toolbarElements.length);
317
- toolbarElements.forEach(el => this._moveElement(el, true));
318
- menuElements.forEach(el => this._moveElement(el));
331
+ toolbarElements.forEach((el) => this._moveElement(el, true));
332
+ menuElements.forEach((el) => this._moveElement(el));
319
333
  this._setHasMenuItems(menuElements.length > 0);
320
334
  }
321
335
 
@@ -330,7 +344,9 @@ class CosmozBottomBar extends PolymerElement {
330
344
  }
331
345
 
332
346
  _onResize([entry]) {
333
- const hidden = entry.borderBoxSize?.[0]?.inlineSize === 0 || entry.contentRect?.width === 0;
347
+ const hidden =
348
+ entry.borderBoxSize?.[0]?.inlineSize === 0 ||
349
+ entry.contentRect?.width === 0;
334
350
  if (hidden) {
335
351
  return;
336
352
  }
@@ -346,8 +362,8 @@ class CosmozBottomBar extends PolymerElement {
346
362
  to = !visible ? '0px' : height + 'px';
347
363
 
348
364
  let from = visible ? '0px' : height + 'px';
349
-
350
- if(visible && renderOpen && !this[rendered]) {
365
+
366
+ if (visible && renderOpen && !this[rendered]) {
351
367
  from = to;
352
368
  this[rendered] = true;
353
369
  }
@@ -375,6 +391,5 @@ const tmplt = `
375
391
  <slot name="bottom-bar-menu" slot="bottom-bar-menu"></slot>
376
392
  `;
377
393
 
378
- export const
379
- bottomBarSlots = html([tmplt]),
380
- bottomBarSlotsPolymer = polymerHtml([tmplt]);
394
+ export const bottomBarSlots = html(Object.assign([tmplt], { raw: [tmplt] })),
395
+ bottomBarSlotsPolymer = polymerHtml(Object.assign([tmplt], { raw: [tmplt] }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-bottom-bar",
3
- "version": "5.2.0",
3
+ "version": "5.2.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",
@@ -53,12 +53,11 @@
53
53
  "dependencies": {
54
54
  "@neovici/cosmoz-dropdown": "^1.1.0",
55
55
  "@polymer/polymer": "^3.3.1",
56
- "haunted": "^4.8.0",
57
56
  "lit-html": "^1.4.0"
58
57
  },
59
58
  "devDependencies": {
60
- "@commitlint/cli": "^16.0.0",
61
- "@commitlint/config-conventional": "^16.0.0",
59
+ "@commitlint/cli": "^17.0.0",
60
+ "@commitlint/config-conventional": "^17.0.0",
62
61
  "@neovici/cfg": "^1.13.0",
63
62
  "@open-wc/testing": "^2.5.0",
64
63
  "@polymer/iron-icon": "^3.0.1",
@@ -70,8 +69,8 @@
70
69
  "@web/dev-server": "^0.1.0",
71
70
  "@web/test-runner": "^0.13.0",
72
71
  "@webcomponents/webcomponentsjs": "^2.5.0",
73
- "husky": "^7.0.0",
72
+ "husky": "^8.0.0",
74
73
  "semantic-release": "^19.0.0",
75
- "sinon": "^13.0.0"
74
+ "sinon": "^14.0.0"
76
75
  }
77
76
  }