@neovici/cosmoz-omnitable 7.0.3 → 7.0.7

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.
@@ -6,6 +6,7 @@ const checkbox = `
6
6
  background: transparent;
7
7
  border-radius: 4px;
8
8
  appearance: none;
9
+ -webkit-appearance: none;
9
10
  outline: none;
10
11
  position: relative;
11
12
  user-select: none;
@@ -20,8 +21,8 @@ const checkbox = `
20
21
  }
21
22
 
22
23
  .checkbox:checked {
23
- background-color: var(--paper-checkbox-checked-color, var(--primary-color));
24
- box-shadow: none;
24
+ background-color: var(--paper-checkbox-checked-color, var(--primary-color));
25
+ box-shadow: none;
25
26
  }
26
27
 
27
28
  .checkbox:checked::before {
@@ -269,6 +270,7 @@ export default `<style>
269
270
  display: flex;
270
271
  align-items: center;
271
272
  flex: auto;
273
+ isolation: isolate;
272
274
  }
273
275
 
274
276
  .footer-control {
@@ -383,6 +385,7 @@ export default `<style>
383
385
  background-color: var(--cosmoz-omnitable-bottom-bar-color, #5f5a92);
384
386
  color: white;
385
387
  overflow: hidden;
388
+ z-index: auto;
386
389
  }
387
390
 
388
391
  cosmoz-bottom-bar::slotted(*) {
@@ -301,7 +301,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
301
301
  groupOnDescending: {
302
302
  type: Boolean,
303
303
  value: false,
304
- observer: '_debounceGroupItems'
304
+ observer: '_debounceProcessItems'
305
305
  },
306
306
  /**
307
307
  * The column name to group on.
@@ -327,7 +327,6 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
327
327
  */
328
328
  filteredItems: {
329
329
  type: Array,
330
- observer: '_debounceGroupItems',
331
330
  value: () => []
332
331
  },
333
332
 
@@ -418,8 +417,8 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
418
417
 
419
418
  static get observers() {
420
419
  return [
421
- '_dataChanged(data.*)',
422
- '_debounceSortItems(sortOn, descending, filteredGroupedItems)',
420
+ '_dataChanged(data.splices)',
421
+ '_debounceProcessItems(sortOn, descending)',
423
422
  '_selectedItemsChanged(selectedItems.*)',
424
423
  'renderFastLayoutCss(layoutCss, $.layoutStyle)'
425
424
  ];
@@ -430,7 +429,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
430
429
 
431
430
  this.debouncers = {};
432
431
  this._updateColumns = this._updateColumns.bind(this);
433
- this._filterItems = this._filterItems.bind(this);
432
+ this._processItems = this._processItems.bind(this);
434
433
  this._groupItems = this._groupItems.bind(this);
435
434
  this._sortFilteredGroupedItems = this._sortFilteredGroupedItems.bind(this);
436
435
  this._onKey = this._onKey.bind(this);
@@ -479,16 +478,8 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
479
478
  this.debouncers._updateColumnsDebouncer.flush();
480
479
  }
481
480
 
482
- if (this.debouncers._filterItemsDebouncer) {
483
- this.debouncers._filterItemsDebouncer.flush();
484
- }
485
-
486
- if (this.debouncers._groupItemsDebouncer) {
487
- this.debouncers._groupItemsDebouncer.flush();
488
- }
489
-
490
- if (this.debouncers._sortItemsDebouncer) {
491
- this.debouncers._sortItemsDebouncer.flush();
481
+ if (this.debouncers._processItemsDebouncer) {
482
+ this.debouncers._processItemsDebouncer.flush();
492
483
  }
493
484
  }
494
485
 
@@ -596,70 +587,12 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
596
587
  requestAnimationFrame(() => requestAnimationFrame(() => this.$.groupedList.$.list._render()));
597
588
  }
598
589
 
599
- _getItemUpdateEffects(splices) {
600
- return splices.reduce((acc, splice) => {
601
- if (acc.refilter) {
602
- return acc;
603
- }
604
- const itemsReplaced = splice.type === 'splice' && splice.addedCount === splice.removed.length;
605
- if (!itemsReplaced) {
606
- acc.refilter = true;
607
- return acc;
608
- }
609
- const filterFunctions = this.columns
610
- .map(col => col.getFilterFn())
611
- .filter(fn => fn !== undefined),
612
- comparer = (oldItem, newItem, path) =>
613
- this.get(path, oldItem) !== this.get(path, newItem);
614
-
615
- splice.removed.some((oldItem, index) => {
616
- const newItem = splice.object[splice.index + index];
617
- if (!acc.refilter) {
618
- const wasFiltered = this.filteredItems.includes(oldItem),
619
- isFiltered = filterFunctions.every(filterFn => filterFn(newItem));
620
- acc.refilter = wasFiltered !== isFiltered;
621
- if (acc.refilter) {
622
- return true;
623
- }
624
- }
625
- acc.regroup = acc.regroup || !!this.groupOnColumn && comparer(oldItem, newItem, this.groupOnColumn.valuePath);
626
- acc.resort = acc.regroup || acc.resort || !!this.sortOnColumn && comparer(oldItem, newItem, this.sortOnColumn.valuePath);
627
- return false;
628
- });
629
- return acc;
630
- }, {
631
- refilter: false,
632
- regroup: false,
633
- resort: false
634
- });
635
- }
636
-
637
- _dataChanged(notify) {
638
- if (!Array.isArray(this.columns) || notify == null || notify.path === 'data.length') {
590
+ _dataChanged() {
591
+ if (!Array.isArray(this.columns)) {
639
592
  return;
640
593
  }
641
594
  this._setColumnValues();
642
-
643
- if (notify.path !== 'data.splices') {
644
- this._debounceFilterItems();
645
- return;
646
- }
647
- const effects = this._getItemUpdateEffects(notify.value.indexSplices);
648
- if (effects.refilter) {
649
- this._debounceFilterItems();
650
- } else if (effects.regroup) {
651
- this._debounceGroupItems();
652
- } else if (effects.resort) {
653
- this._debounceSortItems();
654
- } else if (notify.value.indexSplices.length === 1 && notify.value.indexSplices[0].addedCount === 1 && notify.value.indexSplices[0].removed.length === 1) {
655
- // one item was replaced, but it did not affect the filtering, grouping and sorting
656
- // replace the old item in the sortedFilteredGroupedItems directly
657
- const indexInVisibleData = this.sortedFilteredGroupedItems.indexOf(notify.value.indexSplices[0].removed[0]);
658
- if (indexInVisibleData === -1) {
659
- return;
660
- }
661
- this.splice('sortedFilteredGroupedItems', indexInVisibleData, 1, notify.value.indexSplices[0].object[notify.value.indexSplices[0].index]);
662
- }
595
+ this._debounceProcessItems();
663
596
  }
664
597
 
665
598
  _debounceUpdateColumns() {
@@ -723,7 +656,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
723
656
  this._updateParamsFromHash();
724
657
 
725
658
  if (Array.isArray(this.data)) {
726
- this._debounceFilterItems();
659
+ this._debounceProcessItems();
727
660
  }
728
661
  }
729
662
 
@@ -808,12 +741,26 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
808
741
  if (!Array.isArray(this.columns) || this.columns.length < 1 || this.columns.indexOf(detail.column) < 0) {
809
742
  return;
810
743
  }
811
- this._debounceFilterItems();
744
+ this._debounceProcessItems();
812
745
  this._filterForRouteChanged(detail.column);
813
746
  }
814
747
 
815
- _debounceFilterItems() {
816
- this._debounce('_filterItemsDebouncer', this._filterItems);
748
+ _groupOnColumnChanged(column) {
749
+ if (column && column.hasFilter()) {
750
+ column.resetFilter();
751
+ } else {
752
+ this._debounceProcessItems();
753
+ }
754
+ }
755
+
756
+ _debounceProcessItems() {
757
+ this._debounce('_processItemsDebouncer', this._processItems);
758
+ }
759
+
760
+ _processItems() {
761
+ this._filterItems();
762
+ this._groupItems();
763
+ this._sortFilteredGroupedItems();
817
764
  }
818
765
 
819
766
  _filterItems() {
@@ -838,21 +785,6 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
838
785
  }
839
786
  }
840
787
 
841
- _groupOnColumnChanged(column) {
842
- if (column && column.hasFilter()) {
843
- column.resetFilter();
844
- } else {
845
- this._debounce('_groupItemsDebouncer', this._groupItems);
846
- }
847
- }
848
-
849
- _debounceGroupItems() {
850
- if (!this.isConnected || !Array.isArray(this.filteredItems)) {
851
- return;
852
- }
853
- this._debounce('_groupItemsDebouncer', this._groupItems);
854
- }
855
-
856
788
  /* eslint-disable-next-line max-statements */
857
789
  _groupItems() {
858
790
  // do not attempt to group items if no columns are defined
@@ -912,14 +844,6 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
912
844
  this.filteredGroupedItems = groups;
913
845
  }
914
846
 
915
- _debounceSortItems() {
916
- if (!Array.isArray(this.data) || this.data.length < 1 || !Array.isArray(this.columns)) {
917
- return;
918
- }
919
- this._debounce('_sortItemsDebouncer', this._sortFilteredGroupedItems);
920
- }
921
-
922
-
923
847
  /* eslint-disable-next-line max-statements */
924
848
  _genericSorter(a, b) {
925
849
  if (a === b) {
@@ -1005,7 +929,6 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
1005
929
  return;
1006
930
  }
1007
931
 
1008
-
1009
932
  // No grouping
1010
933
  this.filteredGroupedItems.sort(sorter);
1011
934
  if (this.descending) {
@@ -1,5 +1,5 @@
1
1
  import { html } from 'haunted';
2
- import { FORCE_FIT, layout } from './layout';
2
+ import { layout } from './layout';
3
3
 
4
4
  const
5
5
  _toCss = (layout, config) =>
@@ -22,7 +22,20 @@ export const
22
22
  return computeLayout(columnConfigs.slice(1), canvasWidth, numColumns);
23
23
  }
24
24
 
25
- const widths = layout(columnConfigs, canvasWidth, FORCE_FIT);
25
+ // calculate the index of the last visible column, the one that needs to flex,
26
+ // as the column configs might now be in a different order than displayed
27
+ // due to priority settings
28
+ const lastColumnIndex = columnConfigs.reduce(
29
+ ([max, maxIndex], column, index) => [Math.max(max, column.index), column.index > max ? index : maxIndex],
30
+ [-1, -1]
31
+ )[1];
32
+
33
+ // force the last visible column to flex
34
+ if (lastColumnIndex !== -1) {
35
+ columnConfigs[lastColumnIndex].flex = 1;
36
+ }
37
+
38
+ const widths = layout(columnConfigs, canvasWidth);
26
39
 
27
40
  return widths.reduce((sorted, width, i) => {
28
41
  sorted[columnConfigs[i].index] = width;
@@ -20,11 +20,13 @@ const settingsStyles = `
20
20
  display: flex;
21
21
  flex-direction: column;
22
22
  max-height: 42vh;
23
+ outline: none;
23
24
  }
24
25
  .list {
25
26
  overflow-y: auto;
26
27
  flex: 1;
27
28
  padding-top: 2px;
29
+ min-width: 225px;
28
30
  }
29
31
  .item {
30
32
  display: flex;
@@ -49,7 +51,6 @@ const settingsStyles = `
49
51
  margin-right: 12px;
50
52
  }
51
53
  .title {
52
- min-width: 160px;
53
54
  flex: 1;
54
55
  }
55
56
  ${ checkbox }
@@ -60,6 +61,8 @@ const settingsStyles = `
60
61
  return isFinite(idx) ? idx : undefined;
61
62
  },
62
63
 
64
+ preventDefault = e => e.preventDefault(),
65
+
63
66
  // eslint-disable-next-line max-lines-per-function
64
67
  useSettings = host => {
65
68
  usePosition({ anchor: host.anchor, host });
@@ -190,11 +193,12 @@ const settingsStyles = `
190
193
  background: transparent;
191
194
  cursor: pointer;
192
195
  }
196
+ .anchor * { pointer-events: none; }
193
197
  .anchor:hover {
194
198
  background: #eee;
195
199
  }
196
200
  </style>
197
- <button class="anchor" @focusin=${ onFocus } @focusout=${ onFocus } @click=${ onToggle }>
201
+ <button class="anchor" @focus=${ onFocus } @blur=${ onFocus } @click=${ onToggle } @mousedown=${ preventDefault }>
198
202
  <svg viewBox="0 0 24 24" width="24"><path d="M10 18h5V5h-5v13zm-6 0h5V5H4v13zM16 5v13h5V5h-5z"></path></svg>
199
203
  </button>
200
204
  ${ active
package/lib/layout.js CHANGED
@@ -1,14 +1,8 @@
1
1
  const finite = num => Number.isFinite(num) ? num : 0;
2
2
  export const
3
- FORCE_FIT = true,
4
3
  // eslint-disable-next-line max-lines-per-function, max-statements
5
- layout = (_columns, container, forceFit) => {
4
+ layout = (columns, container) => {
6
5
  const result = [];
7
- let columns = _columns;
8
-
9
- if (forceFit) {
10
- columns = _columns.map((c, index) => index === 0 ? { ...c, flex: 1 } : c);
11
- }
12
6
 
13
7
  // eslint-disable-next-line one-var
14
8
  let [widthSum, lots] = columns.reduce(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-omnitable",
3
- "version": "7.0.3",
3
+ "version": "7.0.7",
4
4
  "description": "[![Build Status](https://travis-ci.org/Neovici/cosmoz-omnitable.svg?branch=master)](https://travis-ci.org/Neovici/cosmoz-omnitable)",
5
5
  "keywords": [
6
6
  "web-components"
@@ -52,7 +52,7 @@
52
52
  ]
53
53
  },
54
54
  "dependencies": {
55
- "@neovici/cosmoz-autocomplete": "^2.17.0",
55
+ "@neovici/cosmoz-autocomplete": "^2.17.1",
56
56
  "@neovici/cosmoz-bottom-bar": "^4.1.0",
57
57
  "@neovici/cosmoz-datetime-input": "^3.0.3",
58
58
  "@neovici/cosmoz-grouped-list": "^3.2.0",
@@ -87,14 +87,14 @@
87
87
  "@polymer/iron-demo-helpers": "^3.0.0",
88
88
  "@polymer/iron-test-helpers": "^3.0.0",
89
89
  "@polymer/paper-toggle-button": "^3.0.0",
90
- "@semantic-release/changelog": "^5.0.0",
91
- "@semantic-release/git": "^9.0.0",
90
+ "@semantic-release/changelog": "^6.0.0",
91
+ "@semantic-release/git": "^10.0.0",
92
92
  "@web/dev-server": "^0.1.10",
93
93
  "@web/test-runner": "^0.13.0",
94
94
  "@web/test-runner-selenium": "^0.5.0",
95
95
  "eslint": "^7.0.0",
96
96
  "husky": "^7.0.0",
97
- "semantic-release": "^17.4.0",
97
+ "semantic-release": "^18.0.0",
98
98
  "sinon": "^11.0.0",
99
99
  "web-animations-js": "^2.3.2"
100
100
  }