@neovici/cosmoz-omnitable 12.22.0 → 12.23.0

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.
@@ -7,12 +7,10 @@ import { when } from 'lit-html/directives/when.js';
7
7
 
8
8
  import { columnMixin, getString } from './cosmoz-omnitable-column-mixin.js';
9
9
  import {
10
- computeSource,
11
10
  listColumnMixin,
12
11
  onChange,
13
12
  onFocus,
14
13
  onText,
15
- toAutocompleteSource,
16
14
  } from './cosmoz-omnitable-column-list-mixin';
17
15
  import { prop, strProp } from '@neovici/cosmoz-utils/object';
18
16
  import { array } from '@neovici/cosmoz-utils/array';
@@ -80,11 +78,7 @@ class OmnitableColumnAutocomplete extends listColumnMixin(
80
78
  ?keep-query=${column.keepQuery}
81
79
  .textual=${column.textual}
82
80
  .label=${column.title}
83
- .source=${toAutocompleteSource(
84
- source,
85
- column.valueProperty,
86
- column.textProperty
87
- )}
81
+ .source=${source}
88
82
  .textProperty=${column.textProperty}
89
83
  .valueProperty=${column.valueProperty}
90
84
  .itemRenderer=${column[columnSymbol]?.itemRenderer}
@@ -108,12 +102,6 @@ class OmnitableColumnAutocomplete extends listColumnMixin(
108
102
  getComparableValue(column, item) {
109
103
  return getComparableValue(column, item);
110
104
  }
111
-
112
- computeSource(column, data) {
113
- return column.externalValues || typeof column.values === 'function'
114
- ? column.values
115
- : computeSource(column, data);
116
- }
117
105
  }
118
106
  customElements.define(
119
107
  'cosmoz-omnitable-column-autocomplete',
@@ -1,5 +1,6 @@
1
1
  import { prop } from '@neovici/cosmoz-utils/object';
2
2
  import { array } from '@neovici/cosmoz-utils/array';
3
+ import { invoke } from '@neovici/cosmoz-utils/function';
3
4
  import { get } from '@polymer/polymer/lib/utils/path';
4
5
  import { valuesFrom } from './lib/utils-data';
5
6
 
@@ -89,26 +90,17 @@ const unique = (values, valueProperty) => {
89
90
  setState((state) => ({ ...state, headerFocused: focused })),
90
91
  onText = (setState) => (text) =>
91
92
  setState((state) => ({ ...state, query: text })),
92
- computeSource = (
93
- {
94
- valuePath,
95
- valueProperty,
96
- textProperty,
97
- emptyLabel,
98
- emptyValue,
99
- emptyProperty,
100
- },
101
- data
93
+ computeValues = (
94
+ { emptyValue, emptyLabel, emptyProperty, textProperty, valueProperty },
95
+ rawSource
102
96
  ) => {
103
- const values = valuesFrom(data, valuePath),
104
- source = toAutocompleteSource(values, valueProperty, textProperty);
105
-
97
+ const source = toAutocompleteSource(rawSource, valueProperty, textProperty);
106
98
  if (
107
99
  !emptyLabel ||
108
100
  emptyValue === undefined ||
109
101
  !textProperty ||
110
102
  !(emptyProperty || valueProperty) ||
111
- source.length < 0
103
+ !source
112
104
  ) {
113
105
  return source;
114
106
  }
@@ -120,6 +112,8 @@ const unique = (values, valueProperty) => {
120
112
  ...source,
121
113
  ];
122
114
  },
115
+ computeSource = (column, data) =>
116
+ computeValues(column, valuesFrom(data, column.valuePath)),
123
117
  listColumnMixin = (base) =>
124
118
  class extends base {
125
119
  static get properties() {
@@ -180,7 +174,7 @@ const unique = (values, valueProperty) => {
180
174
 
181
175
  computeSource(column, data) {
182
176
  return column.externalValues || typeof column.values === 'function'
183
- ? column.values
177
+ ? (...args) => computeValues(column, invoke(column.values, ...args))
184
178
  : computeSource(column, data);
185
179
  }
186
180
  };
@@ -1,7 +1,6 @@
1
1
  import { useCallback, useState } from 'haunted';
2
2
  import { navigate } from '@neovici/cosmoz-router';
3
- import { identity } from '@neovici/cosmoz-utils/function';
4
- import { invoke } from './invoke';
3
+ import { identity, invoke } from '@neovici/cosmoz-utils/function';
5
4
 
6
5
  const
7
6
  hashUrl = () => new URL(location.hash.replace(/^#!?/iu, '').replace('%23', '#'), location.origin),
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useEffect, useMemo } from 'haunted';
2
+ import { invoke } from '@neovici/cosmoz-utils/function';
2
3
  import { genericSorter } from './generic-sorter';
3
- import { invoke } from './invoke';
4
4
  import { columnSymbol } from './use-dom-columns';
5
5
  import { useHashState } from './use-hash-state';
6
6
  import { indexSymbol } from './utils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-omnitable",
3
- "version": "12.22.0",
3
+ "version": "12.23.0",
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"
package/lib/invoke.js DELETED
@@ -1 +0,0 @@
1
- export const invoke = (fn, ...args) => typeof fn === 'function' ? fn(...args) : fn;