@neovici/cosmoz-omnitable 8.5.2 → 8.5.3

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,31 +1,47 @@
1
- /* eslint-disable object-curly-newline */
2
1
  import { html, component } from 'haunted';
3
2
  import { repeat } from 'lit-html/directives/repeat';
4
3
  import './lib/cosmoz-omnitable-resize-nub';
5
4
 
6
- const
7
- renderHeaderRow = ({ data, columns, groupOnColumn, filters, setFilterState }) => {
8
- return repeat(columns, column => column.name, column => [
9
- html`<div
10
- class="cell ${ column.headerCellClass } header-cell"
11
- ?hidden=${ column === groupOnColumn }
12
- title=${ column.title }
13
- name=${ column.name }
14
- >${ column.renderHeader(
15
- column,
16
- filters[column.name] ?? {},
17
- state => setFilterState(column.name, state),
18
- column.source(column, data)
19
- ) }</div>`,
20
- html`<cosmoz-omnitable-resize-nub
21
- .column=${ column }
22
- name=${ column.name }
23
- ></cosmoz-omnitable-resize-nub>`
24
- ]);
25
- },
5
+ const renderHeaderRow = ({
6
+ data,
7
+ columns,
8
+ groupOnColumn,
9
+ filters,
10
+ setFilterState,
11
+ }) =>
12
+ repeat(
13
+ columns,
14
+ (column) => column.name,
15
+ (column) => [
16
+ html`<div
17
+ class="cell ${column.headerCellClass} header-cell"
18
+ ?hidden=${column === groupOnColumn}
19
+ title=${column.title}
20
+ name=${column.name}
21
+ >
22
+ ${column.renderHeader(
23
+ column,
24
+ filters[column.name] ?? {},
25
+ (state) => setFilterState(column.name, state),
26
+ column.source(column, data)
27
+ )}
28
+ </div>`,
29
+ html`<cosmoz-omnitable-resize-nub
30
+ .column=${column}
31
+ name=${column.name}
32
+ ></cosmoz-omnitable-resize-nub>`,
33
+ ]
34
+ ),
35
+ HeaderRow = ({ content, columns, ...thru }) => [
36
+ columns &&
37
+ renderHeaderRow({
38
+ columns,
39
+ ...thru,
40
+ }),
41
+ content,
42
+ ];
26
43
 
27
- HeaderRow = ({ data, columns, groupOnColumn, content, filters, setFilterState }) => {
28
- return [columns && renderHeaderRow({ data, columns, groupOnColumn, filters, setFilterState }), content];
29
- };
30
-
31
- customElements.define('cosmoz-omnitable-header-row', component(HeaderRow, { useShadowDOM: false }));
44
+ customElements.define(
45
+ 'cosmoz-omnitable-header-row',
46
+ component(HeaderRow, { useShadowDOM: false })
47
+ );
@@ -28,6 +28,7 @@ import './lib/cosmoz-omnitable-settings';
28
28
  import { saveAsCsvAction } from './lib/save-as-csv-action';
29
29
  import { saveAsXlsxAction } from './lib/save-as-xlsx-action';
30
30
  import { defaultPlacement } from '@neovici/cosmoz-dropdown';
31
+ import { without } from '@neovici/cosmoz-utils/lib/array';
31
32
  /**
32
33
  * @polymer
33
34
  * @customElement
@@ -134,7 +135,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
134
135
  label="[[ _('Group on', t) ]] [[ _computeSortDirection(groupOnDescending, t) ]]" placeholder="[[ _('No grouping', t) ]]"
135
136
  source="[[ _onCompleteValues(columns, 'groupOn', groupOnColumn) ]]" value="[[ groupOnColumn ]]" limit="1" text-property="title"
136
137
  always-float-label item-height="48" item-limit="8"
137
- class="footer-control" on-select="[[ _onCompleteChange('groupOn') ]]" default-index="-1" show-single
138
+ class="footer-control" on-change="[[ _onCompleteChange('groupOn') ]]" on-select="[[ _onCompleteSelect ]]" default-index="-1" show-single
138
139
  >
139
140
  <svg slot="suffix" viewBox="0 0 24 24" preserveAspectRatio="xMidYMid meet" focusable="false" width="24" fill="currentColor"><path d="M7 10l5 5 5-5z"></path></svg>
140
141
  </cosmoz-autocomplete>
@@ -142,7 +143,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
142
143
  label="[[ _('Sort on', t) ]] [[ _computeSortDirection(descending, t) ]]" placeholder="[[ _('No sorting', t) ]]"
143
144
  source="[[ _onCompleteValues(columns, 'sortOn', sortOnColumn) ]]" value="[[ sortOnColumn ]]" limit="1" text-property="title"
144
145
  always-float-label item-height="48" item-limit="8"
145
- class="footer-control" on-select="[[ _onCompleteChange('sortOn') ]]" default-index="-1" show-single
146
+ class="footer-control" on-change="[[ _onCompleteChange('sortOn') ]]" on-select="[[ _onCompleteSelect ]]" default-index="-1" show-single
146
147
  >
147
148
  <svg slot="suffix" viewBox="0 0 24 24" preserveAspectRatio="xMidYMid meet" focusable="false" width="24" fill="currentColor"><path d="M7 10l5 5 5-5z"></path></svg>
148
149
  </cosmoz-autocomplete>
@@ -520,8 +521,13 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
520
521
  return columns?.filter?.(c => c[type]).sort((a, b) => ((b === value) >> 0) - ((a === value) >> 0));
521
522
  }
522
523
 
524
+ _onCompleteSelect(newVal, {value, onChange, onText, limit}) {
525
+ onText('');
526
+ onChange([...without(newVal)(value), newVal].slice(-limit));
527
+ }
528
+
523
529
  _onCompleteChange(type) {
524
- return (val, {setClosed}) => {
530
+ return (val, close) => {
525
531
  const value = (val[0] ?? val)?.name ?? '',
526
532
  setter = type === 'groupOn' ? this.setGroupOn : this.setSortOn,
527
533
  directionSetter = type === 'groupOn' ? this.setGroupOnDescending : this.setDescending;
@@ -535,7 +541,7 @@ class Omnitable extends hauntedPolymer(useOmnitable)(mixin({ isEmpty }, translat
535
541
  return value;
536
542
  });
537
543
 
538
- value && setClosed(true); /* eslint-disable-line no-unused-expressions */
544
+ value && close(); /* eslint-disable-line no-unused-expressions */
539
545
  };
540
546
  }
541
547
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-omnitable",
3
- "version": "8.5.2",
3
+ "version": "8.5.3",
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"
@@ -80,8 +80,6 @@
80
80
  "@neovici/cosmoz-viewinfo": "^3.1.3",
81
81
  "@neovici/eslint-config": "^1.3.3",
82
82
  "@open-wc/testing": "^2.5.28",
83
- "@polymer/iron-component-page": "^4.0.0",
84
- "@polymer/iron-demo-helpers": "^3.0.0",
85
83
  "@polymer/iron-test-helpers": "^3.0.0",
86
84
  "@polymer/paper-button": "^3.0.1",
87
85
  "@polymer/paper-item": "^3.0.1",