@neovici/cosmoz-omnitable 7.1.0 → 8.0.0-beta.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.
Files changed (52) hide show
  1. package/README.md +23 -0
  2. package/cosmoz-omnitable-column-amount.js +89 -320
  3. package/cosmoz-omnitable-column-autocomplete.js +36 -47
  4. package/cosmoz-omnitable-column-boolean.js +107 -209
  5. package/cosmoz-omnitable-column-date.js +89 -102
  6. package/cosmoz-omnitable-column-datetime.js +86 -119
  7. package/cosmoz-omnitable-column-list-data.js +4 -1
  8. package/cosmoz-omnitable-column-list-horizontal.js +20 -38
  9. package/cosmoz-omnitable-column-list-mixin.js +133 -140
  10. package/cosmoz-omnitable-column-list.js +19 -28
  11. package/cosmoz-omnitable-column-mixin.js +69 -447
  12. package/cosmoz-omnitable-column-number.js +91 -183
  13. package/cosmoz-omnitable-column-time.js +77 -162
  14. package/cosmoz-omnitable-column.js +49 -93
  15. package/cosmoz-omnitable-group-row.js +8 -87
  16. package/cosmoz-omnitable-header-row.js +9 -6
  17. package/cosmoz-omnitable-item-expand.js +0 -3
  18. package/cosmoz-omnitable-item-row.js +18 -127
  19. package/cosmoz-omnitable-styles.js +22 -5
  20. package/cosmoz-omnitable.js +73 -811
  21. package/lib/cosmoz-omnitable-amount-range-input.js +295 -0
  22. package/{cosmoz-omnitable-column-date-mixin.js → lib/cosmoz-omnitable-date-input-mixin.js} +4 -26
  23. package/lib/cosmoz-omnitable-date-range-input.js +81 -0
  24. package/lib/cosmoz-omnitable-datetime-range-input.js +75 -0
  25. package/lib/cosmoz-omnitable-number-range-input.js +159 -0
  26. package/{cosmoz-omnitable-column-range-mixin.js → lib/cosmoz-omnitable-range-input-mixin.js} +45 -129
  27. package/lib/cosmoz-omnitable-settings.js +22 -4
  28. package/lib/cosmoz-omnitable-time-range-input.js +130 -0
  29. package/lib/generic-sorter.js +35 -0
  30. package/lib/invoke.js +1 -0
  31. package/lib/memoize.js +54 -0
  32. package/lib/polymer-haunted-render-mixin.js +19 -0
  33. package/lib/save-as-csv-action.js +32 -0
  34. package/lib/save-as-xlsx-action.js +25 -0
  35. package/lib/use-canvas-width.js +1 -1
  36. package/lib/use-dom-columns.js +133 -0
  37. package/lib/use-hash-state.js +59 -0
  38. package/lib/use-layout.js +1 -1
  39. package/lib/use-omnitable.js +31 -4
  40. package/lib/use-processed-items.js +132 -0
  41. package/lib/use-saved-settings.js +12 -3
  42. package/lib/use-sort-and-group-options.js +30 -0
  43. package/lib/utils-amount.js +147 -0
  44. package/lib/utils-data.js +36 -0
  45. package/lib/utils-date.js +204 -0
  46. package/lib/utils-datetime.js +71 -0
  47. package/lib/utils-number.js +112 -0
  48. package/lib/utils-time.js +115 -0
  49. package/package.json +1 -1
  50. package/cosmoz-omnitable-repeater-mixin.js +0 -294
  51. package/lib/use-force-render.js +0 -8
  52. package/lib/use-render-on-column-updates.js +0 -18
package/README.md CHANGED
@@ -5,3 +5,26 @@ cosmoz-omnitable
5
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/6b16292868f47977eee2/maintainability)](https://codeclimate.com/github/Neovici/cosmoz-omnitable/maintainability)
6
6
  [![codecov](https://codecov.io/gh/Neovici/cosmoz-omnitable/branch/master/graph/badge.svg?token=j46iVMxjcs)](https://codecov.io/gh/Neovici/cosmoz-omnitable)
7
7
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
8
+
9
+
10
+ migration TODO:
11
+
12
+ * check if dropping the visibility code has any adverse effect (might be related to hash-params)
13
+ x add legacy ots compatibility layer: dispatch filter-changed and other similar events from the columns
14
+ * verify each custom render function in FE
15
+ x convert DOM columns to config
16
+ x empty columns of all state
17
+ x hash params
18
+ x xlsx + csv export
19
+ * test for source
20
+
21
+ FE editable columns in:
22
+ views/administration/accounting-model/dimension-values.html.js
23
+ views/administration/periods/list.js
24
+
25
+ FE column-item-changed in:
26
+ views/administration/periods/list.js
27
+
28
+ BUGS:
29
+ * when navigating the queue, filters are not reset when view-core is reused
30
+ * autocomplete columns without valueProperty might not work
@@ -5,369 +5,138 @@ import './ui-helpers/cosmoz-clear-button';
5
5
 
6
6
  import { PolymerElement } from '@polymer/polymer/polymer-element';
7
7
  import { html } from 'lit-html';
8
- import { ifDefined } from 'lit-html/directives/if-defined';
9
8
 
10
9
  import { columnMixin } from './cosmoz-omnitable-column-mixin';
11
- import { rangeColumnMixin } from './cosmoz-omnitable-column-range-mixin';
12
- import {
13
- translatable, _
14
- } from '@neovici/cosmoz-i18next';
15
-
10
+ import { valuesFrom } from './lib/utils-data';
11
+ import './lib/cosmoz-omnitable-amount-range-input';
12
+ import { getComparableValue, getCurrency, applySingleFilter, getString, getInputString, toAmount, toHashString, fromHashString } from './lib/utils-amount';
13
+ import { get } from '@polymer/polymer/lib/utils/path';
16
14
 
17
15
  /**
18
16
  * @polymer
19
17
  * @customElement
20
- * @appliesMixin rangeColumnMixin
21
18
  * @appliesMixin columnMixin
22
- * @appliesMixin translatable
23
19
  */
24
- class OmnitableColumnAmount extends rangeColumnMixin(columnMixin(translatable(
25
- PolymerElement
26
- ))) {
27
- static get is() {
28
- return 'cosmoz-omnitable-column-amount';
29
- }
30
- static get observers() {
31
- return [
32
- '_valuesChanged(autodetect, currency, values)'
33
- ];
34
- }
20
+ class OmnitableColumnAmount extends columnMixin(PolymerElement) {
35
21
  static get properties() {
36
22
  return {
37
- /**
38
- * Base Currency used in filters
39
- */
40
- currency: {
41
- type: String
42
- },
43
-
44
- /**
45
- * If this is set true then currency property will be the currency with highest occurrence in values
46
- */
47
- autodetect: {
48
- type: Boolean,
49
- value: false
50
- },
51
-
52
- /**
53
- * Exchange rates of currencies. Example: {"EUR": 1, "USD":0.8169982616, "AUD":0.6529827192, "SEK": 0.1019271438}'
54
- * Default exchange rate is 1 and it is used for every currency that is present on column values but missing from exchange rates object.
55
- */
56
- rates: {
57
- type: Object
58
- },
59
- width: {
60
- type: String,
61
- value: '70px'
62
- },
63
- editWidth: {
64
- type: String,
65
- value: '70px'
66
- },
67
-
68
- cellClass: {
69
- type: String,
70
- value: 'amount-cell align-right'
71
- },
72
- headerCellClass: {
73
- type: String,
74
- value: 'amount-header-cell'
75
- },
76
- // trigger filter updates manually
77
- autoupdate: {
78
- type: String,
79
- value: false
80
- },
81
- _filterText: {
82
- type: String,
83
- computed: '_computeFilterText(filter.*, _formatters)'
84
- }
23
+ min: { type: Number, value: null, notify: true },
24
+ max: { type: Number, value: null, notify: true },
25
+ locale: { type: String, value: null, notify: true },
26
+ autoupdate: { type: Boolean, value: false, notify: true },
27
+ currency: { type: String, notify: true },
28
+ autodetect: { type: Boolean, value: false, notify: true },
29
+ rates: { type: Object, notify: true },
30
+ width: { type: String, value: '70px' },
31
+ cellClass: { type: String, value: 'amount-cell align-right' },
32
+ headerCellClass: { type: String, value: 'amount-header-cell' }
85
33
  };
86
34
  }
87
35
 
88
- renderCell(column, { item }) {
89
- return html`<span>${ column.getString(item, column.valuePath, column.locale) }</span>`;
90
- }
36
+ getFilterFn(column, filter) {
37
+ const
38
+ min = getComparableValue(filter, 'min', column),
39
+ max = getComparableValue(filter, 'max', column);
91
40
 
92
- renderEditCell(column, { item }) {
93
- const onChange = event => {
94
- event.model = { item };
95
- return column._amountValueChanged(event);
96
- };
97
- return html`<paper-input no-label-float type="number" @change=${ onChange } .value=${ column.getInputString(item, column.valuePath) }>
98
- <div suffix>${ column.getCurrency(item, column.valuePath) }</div>
99
- </paper-input>`;
100
- }
101
-
102
- // eslint-disable-next-line max-lines-per-function
103
- renderHeader(column) {
104
- const onOpenedChanged = event => {
105
- column.headerFocused = event.detail.value;
106
- column._onDropdownOpenedChanged(event);
107
- };
108
-
109
- return html`
110
- <cosmoz-clear-button @click=${ () => column.resetFilter() } ?visible=${ column.hasFilter() }></cosmoz-clear-button>
111
- <paper-dropdown-menu
112
- label=${ column.title }
113
- placeholder=${ ifDefined(column._filterText) }
114
- class="external-values-${ column.externalValues }"
115
- title=${ column._tooltip }
116
- horizontal-align=${ column.preferredDropdownHorizontalAlign }
117
- ?opened=${ column.headerFocused }
118
- @opened-changed=${ onOpenedChanged }
119
- >
120
- <div class="dropdown-content" slot="dropdown-content" style="padding: 15px; min-width: 150px;">
121
- <h3 style="margin: 0;">${ column.title }</h3>
122
- <paper-input
123
- class=${ column._fromClasses }
124
- type="number"
125
- label=${ _('Min amount') }
126
- title=${ _('Minimum amount') }
127
- .value=${ column._filterInput.min }
128
- @value-changed=${ event => column.set('_filterInput.min', event.detail.value) }
129
- @blur=${ event => column._onBlur(event) }
130
- @keydown=${ event => column._onKeyDown(event) }
131
- min=${ column._toInputStringAmount(column._limit.fromMin) }
132
- max=${ column._toInputStringAmount(column._limit.fromMax) }
133
- ><div slot="suffix" suffix>${ column.filter.min?.currency }</div></paper-input>
134
- <paper-input
135
- class=${ column._toClasses }
136
- type="number"
137
- label=${ _('Max amount') }
138
- title=${ _('Maximum amount') }
139
- .value=${ column._filterInput.max }
140
- @value-changed=${ event => column.set('_filterInput.max', event.detail.value) }
141
- @blur=${ event => column._onBlur(event) }
142
- @keydown=${ event => column._onKeyDown(event) }
143
- min=${ column._toInputStringAmount(column._limit.toMin) }
144
- max=${ column._toInputStringAmount(column._limit.toMax) }
145
- ><div slot="suffix" suffix>${ column.filter.max?.currency }</div></paper-input>
146
- </div>
147
- </paper-dropdown-menu>
148
- `;
149
- }
150
-
151
- /**
152
- * Auto-detect currency property: Most frequently occurring currency
153
- * @param {boolean} autodetect Whether the currency property will be the currency with highest occurrence in values or not.
154
- * @param {string} currency Base currency used in filters.
155
- * @param {Array} values Array of amounts
156
- * @returns {void}
157
- */
158
- _valuesChanged(autodetect, currency, values) {
159
- if (!Array.isArray(values) || values.length < 1) {
160
- return;
161
- }
162
- if (!autodetect && currency) {
41
+ if (min == null && max == null) {
163
42
  return;
164
43
  }
165
- // array with currencies as keys and occurence as value
166
- const currencies = values.reduce((p, n) => {
167
- if (n.currency) {
168
- const c = n.currency;
169
- p[c] = (p[c] || 0) + 1;
170
- }
171
- return p;
172
- }, {});
173
-
174
- let key = Object.keys(currencies)[0];
175
- Object.keys(currencies).reduce((p, n) => {
176
- const max = Math.max(p, currencies[n]);
177
- if (max === currencies[n]) {
178
- key = n;
179
- }
180
- return max;
181
- }, 0);
182
- this.set('currency', key);
44
+ return applySingleFilter(column, filter);
183
45
  }
184
46
 
185
- /**
186
- * Converts a value to an amount object optionaly limiting it.
187
- *
188
- * @param {Object} value The value to convert to number
189
- * @param {Object} limit The value used to limit the number
190
- * @param {Function} limitFunc The function used to limit the number (Math.min|Math.max)
191
- * @returns {Object|void} Value converted to Number or void
192
- */
193
- toAmount(value, limit, limitFunc) { // eslint-disable-line max-statements
194
- if (value == null || value === '') {
195
- return;
196
- }
197
-
198
- if (typeof value !== 'object' || value.currency == null || value.currency === '') {
199
- return null;
200
- }
201
-
202
- const number = this.toNumber(value.amount);
203
- if (number == null || Number.isNaN(number)) {
204
- return null;
205
- }
206
- const amount = {
207
- currency: value.currency,
208
- amount: number
209
- };
210
-
211
- if (limitFunc == null || limit == null) {
212
- return amount;
213
- }
214
- const lAmount = this.toAmount(limit);
215
- if (lAmount == null) {
216
- return amount;
217
- }
218
-
219
- // calculate value and limit amounts with rates
220
- const rates = this.rates || {},
221
- valAmount = amount.amount * (rates[amount.currency] || 1),
222
- limAmount = lAmount.amount * (rates[lAmount.currency] || 1),
223
- lNumber = this.toNumber(valAmount, limAmount, limitFunc);
224
- return lNumber === valAmount ? amount : lAmount;
47
+ getString(column, item) {
48
+ return getString(column, item);
225
49
  }
226
50
 
227
- toValue() {
228
- return this.toAmount.apply(this, arguments);
51
+ toXlsxValue(column, item) {
52
+ return getString(column, item);
229
53
  }
230
54
 
231
- toXlsxValue(item, valuePath = this.valuePath) {
232
- return this.getString(item, valuePath);
55
+ cellTitleFn(column, item) {
56
+ return getString(column, item);
233
57
  }
234
58
 
235
- /**
236
- * Get the comparable value of an item.
237
- *
238
- * @param {Object} item Item to be processed
239
- * @param {String} valuePath Property path
240
- * @returns {Number|void} Valid value or void
241
- */
242
- getComparableValue(item, valuePath) {
243
- const value = super.getComparableValue(item, valuePath);
59
+ getComparableValue(item, valuePath, column) {
60
+ return getComparableValue(item, valuePath, column);
61
+ }
244
62
 
245
- if (value == null) {
63
+ serializeFilter({ rates }, filter) {
64
+ if (filter == null) {
246
65
  return;
247
66
  }
248
- const amount = this.toNumber(value.amount),
249
- rates = this.rates;
67
+ const
68
+ min = toAmount(rates, filter.min),
69
+ max = toAmount(rates, filter.max);
250
70
 
251
- if (rates == null) {
252
- return amount;
253
- }
254
-
255
- return amount * (rates[value.currency] || 1);
256
- }
257
- getString(item, valuePath = this.valuePath) {
258
- const value = this.toValue(this.get(valuePath, item));
259
- if (value === undefined) {
260
- return '';
261
- }
262
- if (value === null) {
263
- return 'Invalid value';
71
+ if (min == null && max == null) {
72
+ return;
264
73
  }
265
- return this.renderValue(value);
74
+ return toHashString(min) + '~' + toHashString(max);
266
75
  }
267
76
 
268
- getCurrency(item, valuePath) {
269
- const value = this.get(valuePath, item);
270
- return value && value.currency;
271
- }
272
-
273
- getFormatter(currency, locale) {
274
- const id = locale ? locale : '',
275
- key = currency + id || '',
276
- formatters = this._formatters = this._formatters || {};
277
- if (formatters[key]) {
278
- return formatters[key];
77
+ deserializeFilter(column, filter) {
78
+ if (filter == null || filter === '') {
79
+ return null;
279
80
  }
81
+ const matches = filter.match(/^([^~]+)?~([^~]+)?/iu);
280
82
 
281
- formatters[key] = new Intl.NumberFormat(locale || undefined, {
282
- style: 'currency',
283
- currency
284
- });
285
-
286
- return formatters[key];
287
- }
288
- /**
289
- * Converts an amount to symbol and value to be rendered.
290
- *
291
- * @param {Object} value Amount to be formated
292
- * @param {Object} _formatters = this._formatters All possible formatters.
293
- * @returns {String} Formated value or empty string.
294
- */
295
- renderValue(value) {
296
- const amount = this.toAmount(value);
297
- if (amount == null) {
298
- return '';
83
+ if (!Array.isArray(matches)) {
84
+ return null;
299
85
  }
300
- return this.getFormatter(amount.currency, this.locale)
301
- .format(value.amount);
302
- }
303
-
304
- _amountValueChanged(event) {
305
- const input = event.target,
306
- value = input.value,
307
- item = event.model.item,
308
- originalValue = this.get(this.valuePath, item),
309
- amountValue = Number(value),
310
- newValue = {
311
- amount: amountValue,
312
- currency: originalValue.currency
313
- };
314
86
 
315
- this.set(this.valuePath, newValue, item);
316
- this._fireItemChangeEvent(item, this.valuePath, originalValue, this.renderValue.bind(this));
317
- }
318
-
319
- _toInputString(value) {
320
- const amount = this.toValue(value);
321
- if (amount == null) {
322
- return null; //Need null to clear input
323
- }
324
- return this.toNumber(amount.amount);
87
+ return {
88
+ min: fromHashString(matches[1]),
89
+ max: fromHashString(matches[2])
90
+ };
325
91
  }
326
92
 
327
- _toInputStringAmount(value) {
328
- const rates = this.rates;
329
- if (rates == null) {
330
- return this._toInputString(value);
331
- }
332
- const amount = this.toValue(value);
333
- if (amount == null) {
334
- return null;
335
- }
336
- const toCurrency = this.toNumber(amount.amount) * (rates[amount.currency] || 1) / (rates[this.currency] || 1);
337
- return toCurrency.toFixed(2);
93
+ renderCell(column, { item }) {
94
+ return html`<span>${ column.getString(column, item) }</span>`;
338
95
  }
339
96
 
340
- _fromInputString(value, property) {
341
- const number = this.toNumber(value);
342
- if (number == null) {
343
- return;
344
- }
345
- return this.toValue({
346
- amount: number,
347
- currency: property && this.get(['filter', property, 'currency']) || this.currency
97
+ renderEditCell(column, { item }, onItemChange) {
98
+ const onChange = event => onItemChange({
99
+ amount: event.target.value,
100
+ currency: get(item, column.valuePath)?.currency
348
101
  });
349
- }
350
102
 
351
- _toHashString(value) {
352
- if (!value) {
353
- return '';
354
- }
355
- return value.amount + value.currency;
103
+ return html`<paper-input no-label-float type="number" @change=${ onChange } .value=${ getInputString(column, item) }>
104
+ <div slot="suffix">${ getCurrency(column, item) }</div>
105
+ </paper-input>`;
356
106
  }
357
107
 
358
- _fromHashString(value) {
359
- if (value == null || value === '') {
360
- return;
361
- }
362
- const params = value.match(/^(-?[\d]+)([\D]+?)$/iu);
363
- if (!Array.isArray(params) || params.length < 0) {
364
- return null;
365
- }
366
- return {
367
- amount: params[1],
368
- currency: params[2]
369
- };
108
+ renderHeader(
109
+ { title,
110
+ min,
111
+ max,
112
+ locale,
113
+ rates,
114
+ currency,
115
+ autoupdate,
116
+ autodetect },
117
+ { filter },
118
+ setState,
119
+ source
120
+ ) {
121
+ return html`<cosmoz-omnitable-amount-range-input
122
+ .title=${ title }
123
+ .filter=${ filter }
124
+ .values=${ source }
125
+ .rates=${ rates }
126
+ .min=${ min }
127
+ .max=${ max }
128
+ .locale=${ locale }
129
+ .currency=${ currency }
130
+ .autoupdate=${ autoupdate }
131
+ .autodetect=${ autodetect }
132
+ @filter-changed=${ ({ detail: { value }}) => setState(state => ({ ...state, filter: value })) }
133
+ @header-focused-changed=${ ({ detail: { value }}) => setState(state => ({ ...state, headerFocused: value })) }
134
+ ></cosmoz-omnitable-amount-range-input>`;
135
+ }
136
+
137
+ computeSource({ valuePath }, data) {
138
+ return valuesFrom(data, valuePath);
370
139
  }
371
140
  }
372
141
 
373
- customElements.define(OmnitableColumnAmount.is, OmnitableColumnAmount);
142
+ customElements.define('cosmoz-omnitable-column-amount', OmnitableColumnAmount);
@@ -6,11 +6,19 @@ import {
6
6
  html, nothing
7
7
  } from 'lit-html';
8
8
 
9
- import { columnMixin } from './cosmoz-omnitable-column-mixin.js';
10
- import { listColumnMixin } from './cosmoz-omnitable-column-list-mixin';
9
+ import { columnMixin, getString } from './cosmoz-omnitable-column-mixin.js';
10
+ import { computeSource, listColumnMixin, onChange, onFocus, onText, toAutocompleteSource } from './cosmoz-omnitable-column-list-mixin';
11
11
  import {
12
12
  prop, strProp, array
13
13
  } from '@neovici/cosmoz-autocomplete/lib/utils';
14
+ import { get } from '@polymer/polymer/lib/utils/path';
15
+
16
+ export const
17
+ getComparableValue = (item, valuePath, { textProperty, valueProperty } = {}) => {
18
+ const property = textProperty ? strProp(textProperty) : prop(valueProperty),
19
+ values = array(valuePath && get(item, valuePath)).map(property);
20
+ return values.length > 1 ? values.filter(Boolean).join(',') : values[0];
21
+ };
14
22
 
15
23
  /**
16
24
  * @polymer
@@ -18,69 +26,50 @@ import {
18
26
  * @appliesMixin columnMixin
19
27
  */
20
28
  class OmnitableColumnAutocomplete extends listColumnMixin(columnMixin(PolymerElement)) {
21
- static get is() {
22
- return 'cosmoz-omnitable-column-autocomplete';
23
- }
24
-
25
29
  static get properties() {
26
30
  return {
27
- headerCellClass: {
28
- type: String,
29
- value: 'autocomplete-header-cell'
30
- },
31
-
32
- minWidth: {
33
- type: String,
34
- value: '55px'
35
- },
36
-
37
- editMinWidth: {
38
- type: String,
39
- value: '55px'
40
- }
31
+ headerCellClass: { type: String, value: 'autocomplete-header-cell' },
32
+ minWidth: { type: String, value: '55px' },
33
+ editMinWidth: { type: String, value: '55px' }
41
34
  };
42
35
  }
43
36
 
44
37
  renderCell(column, { item }) {
45
- return html`<span class="default-column">${ column.getString(item, column.valuePath) }</span>`;
38
+ return html`<span class="default-column">${ column.getString(column, item) }</span>`;
46
39
  }
47
40
 
48
- renderEditCell(column, { item }) {
49
- const onChange = event => {
50
- event.model = { item };
51
- return column._valueChanged(event);
52
- };
53
- return html`<paper-input
54
- no-label-float
55
- type="text"
56
- @change=${ onChange }
57
- .value=${ column.getString(item, column.valuePath) }
58
- ></paper-input>`;
41
+ renderEditCell(column, { item }, onItemChange) {
42
+ const onChange = event => onItemChange(event.target.value);
43
+ return html`<paper-input no-label-float type="text" @change=${ onChange } .value=${ getString(column, item) }></paper-input>`;
59
44
  }
60
45
 
61
- renderHeader(column) {
62
- const spinner = column.loading
63
- ? html`<paper-spinner-lite style="width: 20px; height: 20px;" suffix slot="suffix" active></paper-spinner-lite>`
64
- : nothing;
46
+ renderHeader(column, { filter, query }, setState, source) {
47
+ const
48
+ spinner = column.loading
49
+ ? html`<paper-spinner-lite style="width: 20px; height: 20px;" suffix slot="suffix" active></paper-spinner-lite>`
50
+ : nothing;
65
51
 
66
52
  return html`<cosmoz-autocomplete-ui
67
53
  class="external-values-${ column.externalValues }"
68
54
  .label=${ column.title }
69
- .source=${ column._source }
55
+ .source=${ toAutocompleteSource(source, column.valueProperty, column.textProperty) }
70
56
  .textProperty=${ column.textProperty }
71
57
  .valueProperty=${ column.valueProperty }
72
- .value=${ column._computeValue(column.filter, column._source) }
73
- .text=${ column.query }
74
- .onChange=${ column._onChange }
75
- .onFocus=${ column._onFocus }
76
- .onText=${ column._onText }
58
+ .value=${ filter }
59
+ .text=${ query }
60
+ .onChange=${ onChange(setState) }
61
+ .onFocus=${ onFocus(setState) }
62
+ .onText=${ onText(setState) }
77
63
  >${ spinner }</cosmoz-autocomplete-ui>`;
78
64
  }
79
65
 
80
- getComparableValue(item, valuePath = this.valuePath) {
81
- const property = this.textProperty ? strProp(this.textProperty) : prop(this.valueProperty),
82
- values = array(valuePath && this.get(valuePath, item)).map(property);
83
- return values.length > 1 ? values.filter(Boolean).join(',') : values[0];
66
+ getComparableValue(item, valuePath, column) {
67
+ return getComparableValue(item, valuePath, column);
84
68
  }
69
+
70
+ computeSource(column, data) {
71
+ return computeSource(column, data);
72
+ }
73
+
85
74
  }
86
- customElements.define(OmnitableColumnAutocomplete.is, OmnitableColumnAutocomplete);
75
+ customElements.define('cosmoz-omnitable-column-autocomplete', OmnitableColumnAutocomplete);