@neovici/cosmoz-omnitable 14.21.3 → 14.22.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.
- package/dist/cosmoz-omnitable-column-amount.js +27 -29
- package/dist/cosmoz-omnitable-column-autocomplete.js +24 -28
- package/dist/cosmoz-omnitable-column-boolean.js +17 -25
- package/dist/cosmoz-omnitable-column-date.js +26 -28
- package/dist/cosmoz-omnitable-column-datetime.js +26 -28
- package/dist/cosmoz-omnitable-column-list-data.js +6 -8
- package/dist/cosmoz-omnitable-column-list-horizontal.js +15 -17
- package/dist/cosmoz-omnitable-column-list-mixin.js +15 -28
- package/dist/cosmoz-omnitable-column-list.js +19 -21
- package/dist/cosmoz-omnitable-column-mixin.js +8 -12
- package/dist/cosmoz-omnitable-column-number.js +27 -29
- package/dist/cosmoz-omnitable-column-time.js +24 -26
- package/dist/cosmoz-omnitable-column.js +11 -13
- package/dist/cosmoz-omnitable-columns.js +9 -11
- package/dist/cosmoz-omnitable-group-row.js +4 -6
- package/dist/cosmoz-omnitable-header-row.js +15 -17
- package/dist/cosmoz-omnitable-item-expand-line.js +5 -7
- package/dist/cosmoz-omnitable-item-expand.js +6 -8
- package/dist/cosmoz-omnitable-item-row.js +5 -7
- package/dist/cosmoz-omnitable-skeleton.js +6 -8
- package/dist/cosmoz-omnitable-styles.js +4 -7
- package/dist/cosmoz-omnitable.d.ts +1 -1
- package/dist/cosmoz-omnitable.d.ts.map +1 -1
- package/dist/cosmoz-omnitable.js +31 -37
- package/dist/grouped-list/cosmoz-grouped-list-row.js +2 -4
- package/dist/grouped-list/cosmoz-grouped-list.js +4 -6
- package/dist/grouped-list/index.js +1 -3
- package/dist/grouped-list/use-collapsible-items.d.ts +4 -4
- package/dist/grouped-list/use-collapsible-items.js +8 -12
- package/dist/grouped-list/use-cosmoz-grouped-list.d.ts +1 -1
- package/dist/grouped-list/use-cosmoz-grouped-list.js +19 -23
- package/dist/grouped-list/use-selected-items.d.ts +10 -10
- package/dist/grouped-list/use-selected-items.js +15 -19
- package/dist/grouped-list/use-weak-state.d.ts +3 -3
- package/dist/grouped-list/use-weak-state.js +6 -10
- package/dist/grouped-list/utils.js +1 -11
- package/dist/lib/compute-layout.js +7 -12
- package/dist/lib/cosmoz-omnitable-amount-range-input.js +14 -16
- package/dist/lib/cosmoz-omnitable-date-input-mixin.js +5 -9
- package/dist/lib/cosmoz-omnitable-date-range-input.js +12 -14
- package/dist/lib/cosmoz-omnitable-datetime-range-input.js +13 -15
- package/dist/lib/cosmoz-omnitable-number-range-input.js +12 -14
- package/dist/lib/cosmoz-omnitable-range-input-mixin.js +8 -12
- package/dist/lib/cosmoz-omnitable-resize-nub.js +5 -7
- package/dist/lib/cosmoz-omnitable-time-range-input.js +12 -14
- package/dist/lib/generic-sorter.js +1 -5
- package/dist/lib/icons.d.ts +4 -4
- package/dist/lib/icons.d.ts.map +1 -1
- package/dist/lib/icons.js +5 -8
- package/dist/lib/layout.js +2 -5
- package/dist/lib/polymer-haunted-render-mixin.js +6 -10
- package/dist/lib/render-footer.d.ts +1 -1
- package/dist/lib/render-footer.d.ts.map +1 -1
- package/dist/lib/render-footer.js +12 -16
- package/dist/lib/render-header.d.ts +1 -1
- package/dist/lib/render-header.d.ts.map +1 -1
- package/dist/lib/render-header.js +5 -9
- package/dist/lib/render-list.d.ts +1 -1
- package/dist/lib/render-list.d.ts.map +1 -1
- package/dist/lib/render-list.js +15 -19
- package/dist/lib/save-as-csv-action.js +3 -7
- package/dist/lib/save-as-xlsx-action.js +5 -9
- package/dist/lib/settings/cosmoz-omnitable-settings.js +33 -71
- package/dist/lib/settings/cosmoz-omnitable-sort-group.d.ts +3 -3
- package/dist/lib/settings/cosmoz-omnitable-sort-group.d.ts.map +1 -1
- package/dist/lib/settings/cosmoz-omnitable-sort-group.js +12 -19
- package/dist/lib/settings/drivers/context.d.ts +10 -2
- package/dist/lib/settings/drivers/context.d.ts.map +1 -1
- package/dist/lib/settings/drivers/context.js +6 -13
- package/dist/lib/settings/drivers/index.js +3 -25
- package/dist/lib/settings/drivers/local.js +1 -3
- package/dist/lib/settings/drivers/remote.js +1 -3
- package/dist/lib/settings/index.js +2 -9
- package/dist/lib/settings/normalize.js +10 -15
- package/dist/lib/settings/style.css.js +5 -8
- package/dist/lib/settings/use-saved-settings.d.ts +2 -2
- package/dist/lib/settings/use-saved-settings.js +9 -11
- package/dist/lib/settings/use-settings-ui.js +12 -14
- package/dist/lib/settings/use-settings.d.ts +12 -6
- package/dist/lib/settings/use-settings.d.ts.map +1 -1
- package/dist/lib/settings/use-settings.js +8 -46
- package/dist/lib/types.js +1 -2
- package/dist/lib/use-canvas-width.js +5 -9
- package/dist/lib/use-dom-columns.d.ts +1 -1
- package/dist/lib/use-dom-columns.d.ts.map +1 -1
- package/dist/lib/use-dom-columns.js +7 -11
- package/dist/lib/use-fast-layout.d.ts +1 -1
- package/dist/lib/use-fast-layout.js +18 -22
- package/dist/lib/use-footer.js +1 -5
- package/dist/lib/use-hash-state.js +11 -15
- package/dist/lib/use-header.js +5 -9
- package/dist/lib/use-layout.d.ts +1 -1
- package/dist/lib/use-layout.d.ts.map +1 -1
- package/dist/lib/use-layout.js +4 -8
- package/dist/lib/use-list.d.ts +10 -2
- package/dist/lib/use-list.d.ts.map +1 -1
- package/dist/lib/use-list.js +21 -25
- package/dist/lib/use-mini.d.ts +1 -1
- package/dist/lib/use-mini.js +5 -9
- package/dist/lib/use-omnitable.d.ts +10 -2
- package/dist/lib/use-omnitable.d.ts.map +1 -1
- package/dist/lib/use-omnitable.js +18 -22
- package/dist/lib/use-processed-items.d.ts +5 -3
- package/dist/lib/use-processed-items.d.ts.map +1 -1
- package/dist/lib/use-processed-items.js +23 -27
- package/dist/lib/use-public-interface.js +16 -20
- package/dist/lib/use-resizable-columns.js +4 -8
- package/dist/lib/use-sort-and-group-options.d.ts +25 -2
- package/dist/lib/use-sort-and-group-options.d.ts.map +1 -1
- package/dist/lib/use-sort-and-group-options.js +12 -16
- package/dist/lib/use-track-size.d.ts +1 -1
- package/dist/lib/use-track-size.d.ts.map +1 -1
- package/dist/lib/use-track-size.js +2 -6
- package/dist/lib/use-tween-array.js +10 -14
- package/dist/lib/utils-amount.js +29 -25
- package/dist/lib/utils-data.js +8 -12
- package/dist/lib/utils-date.js +38 -55
- package/dist/lib/utils-datetime.js +22 -32
- package/dist/lib/utils-number.js +24 -34
- package/dist/lib/utils-time.js +34 -46
- package/dist/lib/utils.js +2 -6
- package/dist/ui-helpers/cosmoz-clear-button.js +5 -7
- package/package.json +1 -1
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const pion_1 = require("@pionjs/pion");
|
|
5
|
-
const use_meta_1 = require("@neovici/cosmoz-utils/hooks/use-meta");
|
|
6
|
-
const function_1 = require("@neovici/cosmoz-utils/function");
|
|
1
|
+
import { useCallback, useEffect, useMemo } from '@pionjs/pion';
|
|
2
|
+
import { useMeta } from '@neovici/cosmoz-utils/hooks/use-meta';
|
|
3
|
+
import { noop } from '@neovici/cosmoz-utils/function';
|
|
7
4
|
const useAnimationLoop = (animate, trigger) => {
|
|
8
|
-
const animationLoop =
|
|
5
|
+
const animationLoop = useMemo(() => {
|
|
9
6
|
let running = false, af;
|
|
10
7
|
const animationLoop = () => {
|
|
11
8
|
if (!running)
|
|
@@ -27,22 +24,22 @@ const useAnimationLoop = (animate, trigger) => {
|
|
|
27
24
|
},
|
|
28
25
|
};
|
|
29
26
|
}, []);
|
|
30
|
-
|
|
27
|
+
useEffect(() => {
|
|
31
28
|
animationLoop.start();
|
|
32
29
|
}, trigger);
|
|
33
|
-
|
|
30
|
+
useEffect(() => () => animationLoop.stop(), []);
|
|
34
31
|
};
|
|
35
|
-
const isCloseEnough = (a = 0, b = 0) => Math.abs(a - b) < 0.1, useTweenArray = (target, speedFactor = 1.9, callback =
|
|
36
|
-
const state =
|
|
32
|
+
export const isCloseEnough = (a = 0, b = 0) => Math.abs(a - b) < 0.1, useTweenArray = (target, speedFactor = 1.9, callback = noop) => {
|
|
33
|
+
const state = useMeta({ target }),
|
|
37
34
|
// [tween, setTween] = useState(target),
|
|
38
|
-
animate =
|
|
35
|
+
animate = useCallback(() => {
|
|
39
36
|
if (!state.tween)
|
|
40
37
|
state.tween = state.target;
|
|
41
38
|
if (state.target.every((t, idx) => state.tween[idx] === t)) {
|
|
42
39
|
callback(state.tween);
|
|
43
40
|
return true;
|
|
44
41
|
}
|
|
45
|
-
state.tween = state.target.map((t, idx) =>
|
|
42
|
+
state.tween = state.target.map((t, idx) => isCloseEnough(state.tween[idx], t)
|
|
46
43
|
? t
|
|
47
44
|
: (state.tween[idx] ?? 0) +
|
|
48
45
|
((t ?? 0) - (state.tween[idx] ?? 0)) / speedFactor || 0);
|
|
@@ -50,5 +47,4 @@ const isCloseEnough = (a = 0, b = 0) => Math.abs(a - b) < 0.1, useTweenArray = (
|
|
|
50
47
|
}, []);
|
|
51
48
|
useAnimationLoop(animate, [target]);
|
|
52
49
|
};
|
|
53
|
-
exports.isCloseEnough = isCloseEnough, exports.useTweenArray = useTweenArray;
|
|
54
50
|
//# sourceMappingURL=use-tween-array.js.map
|
package/dist/lib/utils-amount.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { get } from '@polymer/polymer/lib/utils/path';
|
|
2
|
+
import { toNumber } from './utils-number';
|
|
3
|
+
export const /**
|
|
4
|
+
* Converts a value to an amount object optionaly limiting it.
|
|
5
|
+
*
|
|
6
|
+
* @param {Object} rates The rates
|
|
7
|
+
* @param {Object} value The value to convert to number
|
|
8
|
+
* @param {Object} limit The value used to limit the number
|
|
9
|
+
* @param {Function} limitFunc The function used to limit the number (Math.min|Math.max)
|
|
10
|
+
* @returns {Object|void} Value converted to Number or void
|
|
11
|
+
*/ toAmount = (rates = {}, value, limit, limitFunc) => {
|
|
7
12
|
if (value == null || value === '') {
|
|
8
13
|
return;
|
|
9
14
|
}
|
|
@@ -12,7 +17,7 @@ const toAmount = (rates = {}, value, limit, limitFunc) => {
|
|
|
12
17
|
value.currency === '') {
|
|
13
18
|
return null;
|
|
14
19
|
}
|
|
15
|
-
const number =
|
|
20
|
+
const number = toNumber(value.amount);
|
|
16
21
|
if (number == null || Number.isNaN(number)) {
|
|
17
22
|
return null;
|
|
18
23
|
}
|
|
@@ -20,12 +25,12 @@ const toAmount = (rates = {}, value, limit, limitFunc) => {
|
|
|
20
25
|
if (limitFunc == null || limit == null) {
|
|
21
26
|
return amount;
|
|
22
27
|
}
|
|
23
|
-
const lAmount =
|
|
28
|
+
const lAmount = toAmount(rates, limit);
|
|
24
29
|
if (lAmount == null) {
|
|
25
30
|
return amount;
|
|
26
31
|
}
|
|
27
32
|
// calculate value and limit amounts with rates
|
|
28
|
-
const valAmount = amount.amount * (rates[amount.currency] || 1), limAmount = lAmount.amount * (rates[lAmount.currency] || 1), lNumber =
|
|
33
|
+
const valAmount = amount.amount * (rates[amount.currency] || 1), limAmount = lAmount.amount * (rates[lAmount.currency] || 1), lNumber = toNumber(valAmount, limAmount, limitFunc);
|
|
29
34
|
return lNumber === valAmount ? amount : lAmount;
|
|
30
35
|
}, getComparableValue = ({ valuePath, rates }, item) => {
|
|
31
36
|
if (item == null) {
|
|
@@ -33,49 +38,49 @@ const toAmount = (rates = {}, value, limit, limitFunc) => {
|
|
|
33
38
|
}
|
|
34
39
|
let value = item;
|
|
35
40
|
if (valuePath != null) {
|
|
36
|
-
value =
|
|
41
|
+
value = get(item, valuePath);
|
|
37
42
|
}
|
|
38
|
-
value =
|
|
43
|
+
value = toAmount(rates, value);
|
|
39
44
|
if (value == null) {
|
|
40
45
|
return;
|
|
41
46
|
}
|
|
42
|
-
const amount =
|
|
47
|
+
const amount = toNumber(value.amount);
|
|
43
48
|
if (rates == null) {
|
|
44
49
|
return amount;
|
|
45
50
|
}
|
|
46
51
|
return amount * (rates[value.currency] || 1);
|
|
47
52
|
}, applySingleFilter = (column, filter) => (item) => {
|
|
48
|
-
const value =
|
|
53
|
+
const value = getComparableValue(column, item);
|
|
49
54
|
if (value == null) {
|
|
50
55
|
return false;
|
|
51
56
|
}
|
|
52
|
-
const min =
|
|
57
|
+
const min = getComparableValue({ ...column, valuePath: 'min' }, filter), max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
53
58
|
return !(value < min || value > max);
|
|
54
|
-
}, getFormatter = (currency, locale) => {
|
|
59
|
+
}, formatters = {}, getFormatter = (currency, locale) => {
|
|
55
60
|
const id = locale ? locale : '', key = currency + id || '';
|
|
56
|
-
if (
|
|
57
|
-
return
|
|
61
|
+
if (formatters[key]) {
|
|
62
|
+
return formatters[key];
|
|
58
63
|
}
|
|
59
|
-
|
|
64
|
+
formatters[key] = new Intl.NumberFormat(locale || undefined, {
|
|
60
65
|
style: 'currency',
|
|
61
66
|
currency,
|
|
62
67
|
});
|
|
63
|
-
return
|
|
68
|
+
return formatters[key];
|
|
64
69
|
}, renderValue = (rates, value, locale) => {
|
|
65
|
-
const amount =
|
|
70
|
+
const amount = toAmount(rates, value);
|
|
66
71
|
if (amount == null) {
|
|
67
72
|
return '';
|
|
68
73
|
}
|
|
69
|
-
return
|
|
74
|
+
return getFormatter(amount.currency, locale).format(amount.amount);
|
|
70
75
|
}, getString = ({ valuePath, rates, locale }, item) => {
|
|
71
|
-
const value =
|
|
76
|
+
const value = toAmount(rates, get(item, valuePath));
|
|
72
77
|
if (value === undefined) {
|
|
73
78
|
return '';
|
|
74
79
|
}
|
|
75
80
|
if (value === null) {
|
|
76
81
|
return 'Invalid value';
|
|
77
82
|
}
|
|
78
|
-
return
|
|
83
|
+
return renderValue(rates, value, locale);
|
|
79
84
|
}, toHashString = (value) => {
|
|
80
85
|
if (!value) {
|
|
81
86
|
return '';
|
|
@@ -90,6 +95,5 @@ const toAmount = (rates = {}, value, limit, limitFunc) => {
|
|
|
90
95
|
return null;
|
|
91
96
|
}
|
|
92
97
|
return { amount: params[1], currency: params[2] };
|
|
93
|
-
}, getCurrency = ({ valuePath }, item) =>
|
|
94
|
-
exports.toAmount = toAmount, exports.getComparableValue = getComparableValue, exports.applySingleFilter = applySingleFilter, exports.formatters = {}, exports.getFormatter = getFormatter, exports.renderValue = renderValue, exports.getString = getString, exports.toHashString = toHashString, exports.fromHashString = fromHashString, exports.getCurrency = getCurrency, exports.getInputString = getInputString;
|
|
98
|
+
}, getCurrency = ({ valuePath }, item) => get(item, valuePath)?.currency, getInputString = ({ valuePath }, item) => get(item, valuePath)?.amount;
|
|
95
99
|
//# sourceMappingURL=utils-amount.js.map
|
package/dist/lib/utils-data.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const path_1 = require("@polymer/polymer/lib/utils/path");
|
|
5
|
-
const use_dom_columns_1 = require("./use-dom-columns");
|
|
6
|
-
const valuesFrom = (data, valuePath) => Array.isArray(data)
|
|
1
|
+
import { get, set } from '@polymer/polymer/lib/utils/path';
|
|
2
|
+
import { columnSymbol } from './use-dom-columns';
|
|
3
|
+
export const valuesFrom = (data, valuePath) => Array.isArray(data)
|
|
7
4
|
? data
|
|
8
|
-
.map((item) =>
|
|
5
|
+
.map((item) => get(item, valuePath))
|
|
9
6
|
.filter((value, index, self) => value != null && self.indexOf(value) === index)
|
|
10
7
|
: undefined, defaultComputeSource = ({ externalValues, values, valuePath }, data) => externalValues || typeof values === 'function'
|
|
11
8
|
? values
|
|
12
|
-
:
|
|
13
|
-
const { valuePath } = column, oldValue =
|
|
9
|
+
: valuesFrom(data, valuePath), onItemChange = (host, column, item, value) => {
|
|
10
|
+
const { valuePath } = column, oldValue = get(item, valuePath);
|
|
14
11
|
if (value === oldValue) {
|
|
15
12
|
return;
|
|
16
13
|
}
|
|
17
|
-
|
|
14
|
+
set(item, valuePath, value);
|
|
18
15
|
const change = {
|
|
19
16
|
item,
|
|
20
17
|
valuePath,
|
|
21
18
|
value,
|
|
22
19
|
oldValue,
|
|
23
|
-
column: column[
|
|
20
|
+
column: column[columnSymbol],
|
|
24
21
|
};
|
|
25
22
|
host.dispatchEvent(new CustomEvent('column-item-changed', {
|
|
26
23
|
bubbles: true,
|
|
@@ -28,5 +25,4 @@ const valuesFrom = (data, valuePath) => Array.isArray(data)
|
|
|
28
25
|
detail: change,
|
|
29
26
|
}));
|
|
30
27
|
};
|
|
31
|
-
exports.valuesFrom = valuesFrom, exports.defaultComputeSource = defaultComputeSource, exports.onItemChange = onItemChange;
|
|
32
28
|
//# sourceMappingURL=utils-data.js.map
|
package/dist/lib/utils-date.js
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const path_1 = require("@polymer/polymer/lib/utils/path");
|
|
6
|
-
const utils_number_1 = require("./utils-number");
|
|
7
|
-
const getTimezoneString = (localISOString) => {
|
|
1
|
+
import { toLocalISOString, ensureDate } from '@neovici/cosmoz-utils/date';
|
|
2
|
+
import { get } from '@polymer/polymer/lib/utils/path';
|
|
3
|
+
import { toNumber } from './utils-number';
|
|
4
|
+
export const getTimezoneString = (localISOString) => {
|
|
8
5
|
const off = -new Date(localISOString).getTimezoneOffset() / 60;
|
|
9
6
|
return ((off < 0 ? '-' : '+') + ['0', Math.abs(off)].join('').substr(-2) + ':00');
|
|
10
7
|
};
|
|
11
|
-
|
|
12
|
-
const getAbsoluteISOString = (localISOString) => {
|
|
8
|
+
export const getAbsoluteISOString = (localISOString) => {
|
|
13
9
|
// Most browsers use local timezone when no timezone is specified
|
|
14
10
|
// but Safari uses UTC, so we set it implicitly
|
|
15
11
|
// TODO: Consider removing this when/if Safari handles local timezone correctly
|
|
16
12
|
if (localISOString.length === 19) {
|
|
17
|
-
return localISOString +
|
|
13
|
+
return localISOString + getTimezoneString(localISOString);
|
|
18
14
|
}
|
|
19
15
|
return localISOString;
|
|
20
16
|
};
|
|
21
|
-
|
|
22
|
-
const parseDate = (value) => {
|
|
17
|
+
export const parseDate = (value) => {
|
|
23
18
|
if (value == null || value === '') {
|
|
24
19
|
return;
|
|
25
20
|
}
|
|
@@ -29,9 +24,9 @@ const parseDate = (value) => {
|
|
|
29
24
|
if (!isDate) {
|
|
30
25
|
// if the value is an ISO string, make sure that it has an explicit timezone
|
|
31
26
|
if (typeof value === 'string') {
|
|
32
|
-
date =
|
|
27
|
+
date = getAbsoluteISOString(date);
|
|
33
28
|
}
|
|
34
|
-
date =
|
|
29
|
+
date = ensureDate(date);
|
|
35
30
|
if (!date) {
|
|
36
31
|
return null;
|
|
37
32
|
}
|
|
@@ -41,55 +36,51 @@ const parseDate = (value) => {
|
|
|
41
36
|
}
|
|
42
37
|
return date;
|
|
43
38
|
};
|
|
44
|
-
|
|
45
|
-
const getComparableValue = ({ valuePath }, item) => {
|
|
39
|
+
export const getComparableValue = ({ valuePath }, item) => {
|
|
46
40
|
if (item == null) {
|
|
47
41
|
return;
|
|
48
42
|
}
|
|
49
43
|
let value = item;
|
|
50
44
|
if (valuePath != null) {
|
|
51
|
-
value =
|
|
45
|
+
value = get(item, valuePath);
|
|
52
46
|
}
|
|
53
|
-
const date =
|
|
47
|
+
const date = parseDate(value);
|
|
54
48
|
if (date == null) {
|
|
55
49
|
return;
|
|
56
50
|
}
|
|
57
|
-
return
|
|
51
|
+
return toNumber(date.getTime());
|
|
58
52
|
};
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
const date = (0, exports.parseDate)(value);
|
|
53
|
+
export const toDate = (value, limit, limitFunc) => {
|
|
54
|
+
const date = parseDate(value);
|
|
62
55
|
if (date == null) {
|
|
63
56
|
return null;
|
|
64
57
|
}
|
|
65
58
|
if (limitFunc == null || limit == null) {
|
|
66
59
|
return date;
|
|
67
60
|
}
|
|
68
|
-
const lDate =
|
|
61
|
+
const lDate = toDate(limit);
|
|
69
62
|
if (lDate == null) {
|
|
70
63
|
return date;
|
|
71
64
|
}
|
|
72
|
-
const comparableDate =
|
|
65
|
+
const comparableDate = getComparableValue({}, date), comparableLDate = getComparableValue({}, lDate);
|
|
73
66
|
if (comparableDate == null || comparableLDate == null) {
|
|
74
67
|
return date;
|
|
75
68
|
}
|
|
76
69
|
const limitedValue = limitFunc(comparableDate, comparableLDate);
|
|
77
70
|
return limitedValue === comparableDate ? date : lDate;
|
|
78
71
|
};
|
|
79
|
-
|
|
80
|
-
const renderValue = (value, formatter) => {
|
|
72
|
+
export const renderValue = (value, formatter) => {
|
|
81
73
|
if (formatter == null) {
|
|
82
74
|
return;
|
|
83
75
|
}
|
|
84
|
-
const date =
|
|
76
|
+
const date = toDate(value);
|
|
85
77
|
if (date == null) {
|
|
86
78
|
return;
|
|
87
79
|
}
|
|
88
80
|
return formatter.format(date);
|
|
89
81
|
};
|
|
90
|
-
exports.renderValue = renderValue;
|
|
91
82
|
const formatters = {};
|
|
92
|
-
const getFormatter = (locale) => {
|
|
83
|
+
export const getFormatter = (locale) => {
|
|
93
84
|
const key = locale || '';
|
|
94
85
|
if (formatters[key]) {
|
|
95
86
|
return formatters[key];
|
|
@@ -97,35 +88,31 @@ const getFormatter = (locale) => {
|
|
|
97
88
|
formatters[key] = new Intl.DateTimeFormat(locale || undefined);
|
|
98
89
|
return formatters[key];
|
|
99
90
|
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
let value = (0, path_1.get)(item, valuePath || '');
|
|
91
|
+
export const getString = ({ valuePath, locale }, item) => {
|
|
92
|
+
let value = get(item, valuePath || '');
|
|
103
93
|
if (value === undefined) {
|
|
104
94
|
return '';
|
|
105
95
|
}
|
|
106
|
-
value =
|
|
96
|
+
value = toDate(value);
|
|
107
97
|
if (value === null) {
|
|
108
98
|
return 'Invalid Date';
|
|
109
99
|
}
|
|
110
|
-
return
|
|
100
|
+
return renderValue(value, getFormatter(locale));
|
|
111
101
|
};
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
const date = (0, exports.toDate)(value);
|
|
102
|
+
export const toInputString = (value) => {
|
|
103
|
+
const date = toDate(value);
|
|
115
104
|
if (date == null) {
|
|
116
105
|
return null;
|
|
117
106
|
}
|
|
118
|
-
const local =
|
|
107
|
+
const local = toLocalISOString(date);
|
|
119
108
|
if (local == null) {
|
|
120
109
|
return null;
|
|
121
110
|
}
|
|
122
111
|
return local.slice(0, 10);
|
|
123
112
|
};
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
const fromInputString = (value, property) => {
|
|
128
|
-
const date = (0, exports.toDate)(value);
|
|
113
|
+
export const getInputString = ({ valuePath }, item) => toInputString(get(item, valuePath || ''));
|
|
114
|
+
export const fromInputString = (value, property) => {
|
|
115
|
+
const date = toDate(value);
|
|
129
116
|
if (date == null) {
|
|
130
117
|
return;
|
|
131
118
|
}
|
|
@@ -137,41 +124,37 @@ const fromInputString = (value, property) => {
|
|
|
137
124
|
}
|
|
138
125
|
return date;
|
|
139
126
|
};
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
const string = (0, exports.toInputString)(value);
|
|
127
|
+
export const toHashString = (value) => {
|
|
128
|
+
const string = toInputString(value);
|
|
143
129
|
if (string == null) {
|
|
144
130
|
return '';
|
|
145
131
|
}
|
|
146
132
|
return string;
|
|
147
133
|
};
|
|
148
|
-
|
|
149
|
-
const toXlsxValue = ({ valuePath }, item) => {
|
|
134
|
+
export const toXlsxValue = ({ valuePath }, item) => {
|
|
150
135
|
if (!valuePath) {
|
|
151
136
|
return '';
|
|
152
137
|
}
|
|
153
|
-
const date =
|
|
138
|
+
const date = toDate(get(item, valuePath));
|
|
154
139
|
if (!date) {
|
|
155
140
|
return '';
|
|
156
141
|
}
|
|
157
|
-
const localDate =
|
|
142
|
+
const localDate = toDate(toLocalISOString(date));
|
|
158
143
|
if (!localDate) {
|
|
159
144
|
return '';
|
|
160
145
|
}
|
|
161
146
|
localDate.setHours(0, 0, 0, 0);
|
|
162
147
|
return localDate;
|
|
163
148
|
};
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
const value = (0, exports.getComparableValue)(column, item);
|
|
149
|
+
export const applySingleFilter = (column, filter) => (item) => {
|
|
150
|
+
const value = getComparableValue(column, item);
|
|
167
151
|
if (value == null) {
|
|
168
152
|
return false;
|
|
169
153
|
}
|
|
170
|
-
const min =
|
|
154
|
+
const min = getComparableValue({ ...column, valuePath: 'min' }, filter), max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
171
155
|
if (min == null || max == null) {
|
|
172
156
|
return false;
|
|
173
157
|
}
|
|
174
158
|
return !(value < min || value > max);
|
|
175
159
|
};
|
|
176
|
-
exports.applySingleFilter = applySingleFilter;
|
|
177
160
|
//# sourceMappingURL=utils-date.js.map
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const utils_date_1 = require("./utils-date");
|
|
7
|
-
exports.formatters = {};
|
|
8
|
-
const getFormatter = (locale) => {
|
|
1
|
+
import { toLocalISOString } from '@neovici/cosmoz-utils/date';
|
|
2
|
+
import { get } from '@polymer/polymer/lib/utils/path';
|
|
3
|
+
import { renderValue, toDate } from './utils-date';
|
|
4
|
+
export const formatters = {};
|
|
5
|
+
export const getFormatter = (locale) => {
|
|
9
6
|
const key = locale || '';
|
|
10
|
-
if (
|
|
11
|
-
return
|
|
7
|
+
if (formatters[key]) {
|
|
8
|
+
return formatters[key];
|
|
12
9
|
}
|
|
13
10
|
const timeFormatOption = {
|
|
14
11
|
year: 'numeric',
|
|
@@ -17,38 +14,34 @@ const getFormatter = (locale) => {
|
|
|
17
14
|
hour: 'numeric',
|
|
18
15
|
minute: 'numeric',
|
|
19
16
|
};
|
|
20
|
-
|
|
21
|
-
return
|
|
17
|
+
formatters[key] = new Intl.DateTimeFormat(locale || undefined, timeFormatOption);
|
|
18
|
+
return formatters[key];
|
|
22
19
|
};
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const value = (0, utils_date_1.toDate)((0, path_1.get)(item, valuePath || ''));
|
|
20
|
+
export const getString = ({ valuePath, locale }, item) => {
|
|
21
|
+
const value = toDate(get(item, valuePath || ''));
|
|
26
22
|
if (value === undefined) {
|
|
27
23
|
return '';
|
|
28
24
|
}
|
|
29
25
|
if (value === null) {
|
|
30
26
|
return 'Invalid Date';
|
|
31
27
|
}
|
|
32
|
-
return
|
|
28
|
+
return renderValue(value, getFormatter(locale));
|
|
33
29
|
};
|
|
34
|
-
|
|
35
|
-
const toXlsxValue = ({ valuePath }, item) => {
|
|
30
|
+
export const toXlsxValue = ({ valuePath }, item) => {
|
|
36
31
|
if (!valuePath) {
|
|
37
32
|
return '';
|
|
38
33
|
}
|
|
39
|
-
return
|
|
34
|
+
return get(item, valuePath);
|
|
40
35
|
};
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
const date = (0, utils_date_1.toDate)(value);
|
|
36
|
+
export const toHashString = (value) => {
|
|
37
|
+
const date = toDate(value);
|
|
44
38
|
if (date == null) {
|
|
45
39
|
return '';
|
|
46
40
|
}
|
|
47
41
|
//Use utc in hash
|
|
48
42
|
return date.toISOString().slice(0, 19).replace(/:/gu, '.');
|
|
49
43
|
};
|
|
50
|
-
|
|
51
|
-
const fromHashString = (value) => {
|
|
44
|
+
export const fromHashString = (value) => {
|
|
52
45
|
if (value == null || value === '') {
|
|
53
46
|
return;
|
|
54
47
|
}
|
|
@@ -56,18 +49,15 @@ const fromHashString = (value) => {
|
|
|
56
49
|
if (typeof value !== 'string') {
|
|
57
50
|
return;
|
|
58
51
|
}
|
|
59
|
-
return
|
|
52
|
+
return toDate(value.replace(/\./gu, ':') + 'Z');
|
|
60
53
|
};
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
const date = (0, utils_date_1.toDate)(value);
|
|
54
|
+
export const toInputString = (value) => {
|
|
55
|
+
const date = toDate(value);
|
|
64
56
|
if (date == null) {
|
|
65
57
|
return null;
|
|
66
58
|
}
|
|
67
|
-
const localISOString =
|
|
59
|
+
const localISOString = toLocalISOString(date);
|
|
68
60
|
return localISOString ? localISOString.slice(0, 19) : localISOString;
|
|
69
61
|
};
|
|
70
|
-
|
|
71
|
-
const getInputString = ({ valuePath }, item) => (0, exports.toInputString)((0, path_1.get)(item, valuePath || ''));
|
|
72
|
-
exports.getInputString = getInputString;
|
|
62
|
+
export const getInputString = ({ valuePath }, item) => toInputString(get(item, valuePath || ''));
|
|
73
63
|
//# sourceMappingURL=utils-datetime.js.map
|
package/dist/lib/utils-number.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const path_1 = require("@polymer/polymer/lib/utils/path");
|
|
5
|
-
const memoize_1 = require("@neovici/cosmoz-utils/memoize");
|
|
6
|
-
const toNumber = (value, limit, limitFunc) => {
|
|
1
|
+
import { get } from '@polymer/polymer/lib/utils/path';
|
|
2
|
+
import { memoooize } from '@neovici/cosmoz-utils/memoize';
|
|
3
|
+
export const toNumber = (value, limit, limitFunc) => {
|
|
7
4
|
if (value == null || value === '') {
|
|
8
5
|
return;
|
|
9
6
|
}
|
|
@@ -14,50 +11,45 @@ const toNumber = (value, limit, limitFunc) => {
|
|
|
14
11
|
if (limitFunc == null || limit == null) {
|
|
15
12
|
return number;
|
|
16
13
|
}
|
|
17
|
-
const lNumber =
|
|
14
|
+
const lNumber = toNumber(limit);
|
|
18
15
|
if (lNumber == null) {
|
|
19
16
|
return number;
|
|
20
17
|
}
|
|
21
18
|
return limitFunc(number, lNumber);
|
|
22
19
|
};
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const val = (0, exports.toNumber)(value);
|
|
20
|
+
export const toInputString = (value) => {
|
|
21
|
+
const val = toNumber(value);
|
|
26
22
|
if (val == null) {
|
|
27
23
|
return null;
|
|
28
24
|
}
|
|
29
25
|
return val.toString();
|
|
30
26
|
};
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
return (0, exports.toInputString)(value);
|
|
27
|
+
export const getInputString = ({ valuePath }, item) => {
|
|
28
|
+
const value = toNumber(valuePath ? get(item, valuePath) : item);
|
|
29
|
+
return toInputString(value);
|
|
35
30
|
};
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
const string = (0, exports.toInputString)(value);
|
|
31
|
+
export const toHashString = (value) => {
|
|
32
|
+
const string = toInputString(value);
|
|
39
33
|
if (string == null) {
|
|
40
34
|
return '';
|
|
41
35
|
}
|
|
42
36
|
return string;
|
|
43
37
|
};
|
|
44
|
-
|
|
45
|
-
const getComparableValue = ({ valuePath, maximumFractionDigits }, item) => {
|
|
38
|
+
export const getComparableValue = ({ valuePath, maximumFractionDigits }, item) => {
|
|
46
39
|
if (item == null) {
|
|
47
40
|
return;
|
|
48
41
|
}
|
|
49
|
-
const value = valuePath ?
|
|
50
|
-
const numValue =
|
|
42
|
+
const value = valuePath ? get(item, valuePath) : item;
|
|
43
|
+
const numValue = toNumber(value);
|
|
51
44
|
if (numValue == null) {
|
|
52
45
|
return;
|
|
53
46
|
}
|
|
54
47
|
if (maximumFractionDigits !== null) {
|
|
55
|
-
return
|
|
48
|
+
return toNumber(numValue.toFixed(maximumFractionDigits));
|
|
56
49
|
}
|
|
57
50
|
return numValue;
|
|
58
51
|
};
|
|
59
|
-
|
|
60
|
-
exports.makeFormatter = (0, memoize_1.memoooize)((locale, minimumFractionDigits, maximumFractionDigits) => {
|
|
52
|
+
export const makeFormatter = memoooize((locale, minimumFractionDigits, maximumFractionDigits) => {
|
|
61
53
|
const options = {
|
|
62
54
|
localeMatcher: 'best fit', // chrome expects this when using custom options
|
|
63
55
|
};
|
|
@@ -69,27 +61,25 @@ exports.makeFormatter = (0, memoize_1.memoooize)((locale, minimumFractionDigits,
|
|
|
69
61
|
}
|
|
70
62
|
return new Intl.NumberFormat(locale || undefined, options);
|
|
71
63
|
});
|
|
72
|
-
const getString = ({ valuePath, locale, minimumFractionDigits, maximumFractionDigits }, item) => {
|
|
73
|
-
const value = valuePath ?
|
|
64
|
+
export const getString = ({ valuePath, locale, minimumFractionDigits, maximumFractionDigits }, item) => {
|
|
65
|
+
const value = valuePath ? get(item, valuePath) : item;
|
|
74
66
|
if (value == null) {
|
|
75
67
|
return '';
|
|
76
68
|
}
|
|
77
|
-
const number =
|
|
69
|
+
const number = toNumber(value);
|
|
78
70
|
if (number == null) {
|
|
79
71
|
return;
|
|
80
72
|
}
|
|
81
|
-
const formatter =
|
|
73
|
+
const formatter = makeFormatter(locale, minimumFractionDigits, maximumFractionDigits);
|
|
82
74
|
return formatter.format(number);
|
|
83
75
|
};
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
const value = (0, exports.getComparableValue)(column, item);
|
|
76
|
+
export const applySingleFilter = (column, filter) => (item) => {
|
|
77
|
+
const value = getComparableValue(column, item);
|
|
87
78
|
if (value == null) {
|
|
88
79
|
return false;
|
|
89
80
|
}
|
|
90
|
-
const min =
|
|
91
|
-
const max =
|
|
81
|
+
const min = getComparableValue({ ...column, valuePath: 'min' }, filter);
|
|
82
|
+
const max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
92
83
|
return !(value < (min ?? -Infinity) || value > (max ?? Infinity));
|
|
93
84
|
};
|
|
94
|
-
exports.applySingleFilter = applySingleFilter;
|
|
95
85
|
//# sourceMappingURL=utils-number.js.map
|