@neovici/cosmoz-omnitable 14.16.0 → 14.18.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 +29 -27
- package/dist/cosmoz-omnitable-column-autocomplete.d.ts +1 -1
- package/dist/cosmoz-omnitable-column-autocomplete.d.ts.map +1 -1
- package/dist/cosmoz-omnitable-column-autocomplete.js +28 -24
- package/dist/cosmoz-omnitable-column-boolean.d.ts +4 -1
- package/dist/cosmoz-omnitable-column-boolean.d.ts.map +1 -1
- package/dist/cosmoz-omnitable-column-boolean.js +25 -17
- package/dist/cosmoz-omnitable-column-date.js +28 -26
- package/dist/cosmoz-omnitable-column-datetime.js +28 -26
- package/dist/cosmoz-omnitable-column-list-data.js +8 -6
- package/dist/cosmoz-omnitable-column-list-horizontal.js +17 -15
- package/dist/cosmoz-omnitable-column-list-mixin.d.ts +6 -6
- package/dist/cosmoz-omnitable-column-list-mixin.d.ts.map +1 -1
- package/dist/cosmoz-omnitable-column-list-mixin.js +28 -15
- package/dist/cosmoz-omnitable-column-list.js +21 -19
- package/dist/cosmoz-omnitable-column-mixin.js +12 -8
- package/dist/cosmoz-omnitable-column-number.js +29 -27
- package/dist/cosmoz-omnitable-column-time.js +26 -24
- package/dist/cosmoz-omnitable-column.js +13 -11
- package/dist/cosmoz-omnitable-columns.js +11 -9
- package/dist/cosmoz-omnitable-group-row.js +6 -4
- package/dist/cosmoz-omnitable-header-row.js +17 -15
- package/dist/cosmoz-omnitable-item-expand-line.js +7 -5
- package/dist/cosmoz-omnitable-item-expand.js +8 -6
- package/dist/cosmoz-omnitable-item-row.js +7 -5
- package/dist/cosmoz-omnitable-skeleton.js +8 -6
- package/dist/cosmoz-omnitable-styles.js +7 -4
- package/dist/cosmoz-omnitable.d.ts +1 -1
- package/dist/cosmoz-omnitable.d.ts.map +1 -1
- package/dist/cosmoz-omnitable.js +37 -31
- package/dist/grouped-list/cosmoz-grouped-list-row.js +4 -2
- package/dist/grouped-list/cosmoz-grouped-list.js +6 -4
- package/dist/grouped-list/index.js +3 -1
- package/dist/grouped-list/use-collapsible-items.d.ts +4 -4
- package/dist/grouped-list/use-collapsible-items.js +12 -8
- package/dist/grouped-list/use-cosmoz-grouped-list.d.ts +1 -1
- package/dist/grouped-list/use-cosmoz-grouped-list.js +23 -19
- package/dist/grouped-list/use-selected-items.d.ts +10 -10
- package/dist/grouped-list/use-selected-items.js +19 -15
- package/dist/grouped-list/use-weak-state.d.ts +3 -3
- package/dist/grouped-list/use-weak-state.js +10 -6
- package/dist/grouped-list/utils.js +11 -1
- package/dist/lib/compute-layout.js +10 -6
- package/dist/lib/cosmoz-omnitable-amount-range-input.js +16 -14
- package/dist/lib/cosmoz-omnitable-date-input-mixin.js +9 -5
- package/dist/lib/cosmoz-omnitable-date-range-input.js +14 -12
- package/dist/lib/cosmoz-omnitable-datetime-range-input.js +15 -13
- package/dist/lib/cosmoz-omnitable-number-range-input.js +14 -12
- package/dist/lib/cosmoz-omnitable-range-input-mixin.js +12 -8
- package/dist/lib/cosmoz-omnitable-resize-nub.js +7 -5
- package/dist/lib/cosmoz-omnitable-time-range-input.js +14 -12
- package/dist/lib/generic-sorter.js +5 -1
- package/dist/lib/icons.d.ts +4 -4
- package/dist/lib/icons.d.ts.map +1 -1
- package/dist/lib/icons.js +8 -5
- package/dist/lib/layout.js +5 -2
- package/dist/lib/polymer-haunted-render-mixin.js +10 -6
- 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 +16 -12
- 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 +9 -5
- 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 +18 -14
- package/dist/lib/save-as-csv-action.js +7 -3
- package/dist/lib/save-as-xlsx-action.js +9 -5
- package/dist/lib/settings/cosmoz-omnitable-settings.js +71 -33
- 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 +19 -12
- package/dist/lib/settings/drivers/context.d.ts +2 -10
- package/dist/lib/settings/drivers/context.d.ts.map +1 -1
- package/dist/lib/settings/drivers/context.js +13 -6
- package/dist/lib/settings/drivers/index.js +25 -3
- package/dist/lib/settings/drivers/local.js +3 -1
- package/dist/lib/settings/drivers/remote.js +3 -1
- package/dist/lib/settings/index.js +9 -2
- package/dist/lib/settings/normalize.js +15 -10
- package/dist/lib/settings/style.css.js +8 -5
- package/dist/lib/settings/use-saved-settings.d.ts +2 -2
- package/dist/lib/settings/use-saved-settings.js +11 -9
- package/dist/lib/settings/use-settings-ui.js +14 -12
- package/dist/lib/settings/use-settings.d.ts +6 -12
- package/dist/lib/settings/use-settings.d.ts.map +1 -1
- package/dist/lib/settings/use-settings.js +46 -8
- package/dist/lib/types.d.ts +20 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +3 -0
- package/dist/lib/use-canvas-width.js +9 -5
- 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 +11 -7
- package/dist/lib/use-fast-layout.d.ts +1 -1
- package/dist/lib/use-fast-layout.js +22 -18
- package/dist/lib/use-footer.js +5 -1
- package/dist/lib/use-hash-state.js +15 -11
- package/dist/lib/use-header.js +9 -5
- package/dist/lib/use-layout.js +8 -4
- package/dist/lib/use-list.d.ts +2 -10
- package/dist/lib/use-list.d.ts.map +1 -1
- package/dist/lib/use-list.js +25 -21
- package/dist/lib/use-mini.d.ts +1 -1
- package/dist/lib/use-mini.js +9 -5
- package/dist/lib/use-omnitable.d.ts +2 -10
- package/dist/lib/use-omnitable.d.ts.map +1 -1
- package/dist/lib/use-omnitable.js +22 -18
- package/dist/lib/use-processed-items.d.ts +3 -5
- package/dist/lib/use-processed-items.d.ts.map +1 -1
- package/dist/lib/use-processed-items.js +27 -23
- package/dist/lib/use-public-interface.js +20 -16
- package/dist/lib/use-resizable-columns.js +8 -4
- package/dist/lib/use-sort-and-group-options.d.ts +2 -25
- package/dist/lib/use-sort-and-group-options.d.ts.map +1 -1
- package/dist/lib/use-sort-and-group-options.js +16 -12
- 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 +6 -2
- package/dist/lib/use-tween-array.d.ts +1 -1
- package/dist/lib/use-tween-array.d.ts.map +1 -1
- package/dist/lib/use-tween-array.js +14 -10
- package/dist/lib/utils-amount.d.ts +1 -1
- package/dist/lib/utils-amount.d.ts.map +1 -1
- package/dist/lib/utils-amount.js +25 -29
- package/dist/lib/utils-data.js +12 -8
- package/dist/lib/utils-date.d.ts +4 -4
- package/dist/lib/utils-date.d.ts.map +1 -1
- package/dist/lib/utils-date.js +58 -35
- package/dist/lib/utils-datetime.d.ts +2 -2
- package/dist/lib/utils-datetime.d.ts.map +1 -1
- package/dist/lib/utils-datetime.js +20 -16
- package/dist/lib/utils-number.d.ts +11 -18
- package/dist/lib/utils-number.d.ts.map +1 -1
- package/dist/lib/utils-number.js +44 -36
- package/dist/lib/utils-time.d.ts +2 -2
- package/dist/lib/utils-time.d.ts.map +1 -1
- package/dist/lib/utils-time.js +37 -24
- package/dist/lib/utils.js +6 -2
- package/dist/ui-helpers/cosmoz-clear-button.js +7 -5
- package/package.json +2 -1
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTweenArray = exports.isCloseEnough = void 0;
|
|
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");
|
|
4
7
|
const useAnimationLoop = (animate, trigger) => {
|
|
5
|
-
const animationLoop = useMemo(() => {
|
|
8
|
+
const animationLoop = (0, pion_1.useMemo)(() => {
|
|
6
9
|
let running = false, af;
|
|
7
10
|
const animationLoop = () => {
|
|
8
11
|
if (!running)
|
|
@@ -24,22 +27,22 @@ const useAnimationLoop = (animate, trigger) => {
|
|
|
24
27
|
},
|
|
25
28
|
};
|
|
26
29
|
}, []);
|
|
27
|
-
useEffect(() => {
|
|
30
|
+
(0, pion_1.useEffect)(() => {
|
|
28
31
|
animationLoop.start();
|
|
29
32
|
}, trigger);
|
|
30
|
-
useEffect(() => () => animationLoop.stop(), []);
|
|
33
|
+
(0, pion_1.useEffect)(() => () => animationLoop.stop(), []);
|
|
31
34
|
};
|
|
32
|
-
|
|
33
|
-
const state = useMeta({ target }),
|
|
35
|
+
const isCloseEnough = (a = 0, b = 0) => Math.abs(a - b) < 0.1, useTweenArray = (target, speedFactor = 1.9, callback = function_1.noop) => {
|
|
36
|
+
const state = (0, use_meta_1.useMeta)({ target }),
|
|
34
37
|
// [tween, setTween] = useState(target),
|
|
35
|
-
animate = useCallback(() => {
|
|
38
|
+
animate = (0, pion_1.useCallback)(() => {
|
|
36
39
|
if (!state.tween)
|
|
37
40
|
state.tween = state.target;
|
|
38
41
|
if (state.target.every((t, idx) => state.tween[idx] === t)) {
|
|
39
42
|
callback(state.tween);
|
|
40
43
|
return true;
|
|
41
44
|
}
|
|
42
|
-
state.tween = state.target.map((t, idx) => isCloseEnough(state.tween[idx], t)
|
|
45
|
+
state.tween = state.target.map((t, idx) => (0, exports.isCloseEnough)(state.tween[idx], t)
|
|
43
46
|
? t
|
|
44
47
|
: (state.tween[idx] ?? 0) +
|
|
45
48
|
((t ?? 0) - (state.tween[idx] ?? 0)) / speedFactor || 0);
|
|
@@ -47,4 +50,5 @@ export const isCloseEnough = (a = 0, b = 0) => Math.abs(a - b) < 0.1, useTweenAr
|
|
|
47
50
|
}, []);
|
|
48
51
|
useAnimationLoop(animate, [target]);
|
|
49
52
|
};
|
|
53
|
+
exports.isCloseEnough = isCloseEnough, exports.useTweenArray = useTweenArray;
|
|
50
54
|
//# sourceMappingURL=use-tween-array.js.map
|
|
@@ -2,7 +2,7 @@ export function toAmount(rates: {} | undefined, value: any, limit: any, limitFun
|
|
|
2
2
|
export function getComparableValue({ valuePath, rates }: {
|
|
3
3
|
valuePath: any;
|
|
4
4
|
rates: any;
|
|
5
|
-
}, item: any):
|
|
5
|
+
}, item: any): number | undefined;
|
|
6
6
|
export function applySingleFilter(column: any, filter: any): (item: any) => boolean;
|
|
7
7
|
export const formatters: {};
|
|
8
8
|
export function getFormatter(currency: any, locale: any): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-amount.d.ts","sourceRoot":"","sources":["../../src/lib/utils-amount.js"],"names":[],"mappings":"AAGO,6FA+HgE;AA/HhE;;;
|
|
1
|
+
{"version":3,"file":"utils-amount.d.ts","sourceRoot":"","sources":["../../src/lib/utils-amount.js"],"names":[],"mappings":"AAGO,6FA+HgE;AA/HhE;;;kCA+HgE;AA/HhE,8DAiEmC,SAAI,aA8DyB;AAlDtE,4BAAe;AA7ET,8DA+HgE;AA/HhE,sEA+HgE;AA/HhE;;;;mBA+HgE;AA/HhE,8CA+HgE;AA/HhE;;;qBA+HgE;AA/HhE;;mBA+HgE;AA/HhE;;mBA+HgE"}
|
package/dist/lib/utils-amount.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getInputString = exports.getCurrency = exports.fromHashString = exports.toHashString = exports.getString = exports.renderValue = exports.getFormatter = exports.formatters = exports.applySingleFilter = exports.getComparableValue = exports.toAmount = void 0;
|
|
4
|
+
const path_1 = require("@polymer/polymer/lib/utils/path");
|
|
5
|
+
const utils_number_1 = require("./utils-number");
|
|
6
|
+
const toAmount = (rates = {}, value, limit, limitFunc) => {
|
|
12
7
|
if (value == null || value === '') {
|
|
13
8
|
return;
|
|
14
9
|
}
|
|
@@ -17,7 +12,7 @@ export const /**
|
|
|
17
12
|
value.currency === '') {
|
|
18
13
|
return null;
|
|
19
14
|
}
|
|
20
|
-
const number = toNumber(value.amount);
|
|
15
|
+
const number = (0, utils_number_1.toNumber)(value.amount);
|
|
21
16
|
if (number == null || Number.isNaN(number)) {
|
|
22
17
|
return null;
|
|
23
18
|
}
|
|
@@ -25,12 +20,12 @@ export const /**
|
|
|
25
20
|
if (limitFunc == null || limit == null) {
|
|
26
21
|
return amount;
|
|
27
22
|
}
|
|
28
|
-
const lAmount = toAmount(rates, limit);
|
|
23
|
+
const lAmount = (0, exports.toAmount)(rates, limit);
|
|
29
24
|
if (lAmount == null) {
|
|
30
25
|
return amount;
|
|
31
26
|
}
|
|
32
27
|
// calculate value and limit amounts with rates
|
|
33
|
-
const valAmount = amount.amount * (rates[amount.currency] || 1), limAmount = lAmount.amount * (rates[lAmount.currency] || 1), lNumber = toNumber(valAmount, limAmount, limitFunc);
|
|
28
|
+
const valAmount = amount.amount * (rates[amount.currency] || 1), limAmount = lAmount.amount * (rates[lAmount.currency] || 1), lNumber = (0, utils_number_1.toNumber)(valAmount, limAmount, limitFunc);
|
|
34
29
|
return lNumber === valAmount ? amount : lAmount;
|
|
35
30
|
}, getComparableValue = ({ valuePath, rates }, item) => {
|
|
36
31
|
if (item == null) {
|
|
@@ -38,49 +33,49 @@ export const /**
|
|
|
38
33
|
}
|
|
39
34
|
let value = item;
|
|
40
35
|
if (valuePath != null) {
|
|
41
|
-
value = get(item, valuePath);
|
|
36
|
+
value = (0, path_1.get)(item, valuePath);
|
|
42
37
|
}
|
|
43
|
-
value = toAmount(rates, value);
|
|
38
|
+
value = (0, exports.toAmount)(rates, value);
|
|
44
39
|
if (value == null) {
|
|
45
40
|
return;
|
|
46
41
|
}
|
|
47
|
-
const amount = toNumber(value.amount);
|
|
42
|
+
const amount = (0, utils_number_1.toNumber)(value.amount);
|
|
48
43
|
if (rates == null) {
|
|
49
44
|
return amount;
|
|
50
45
|
}
|
|
51
46
|
return amount * (rates[value.currency] || 1);
|
|
52
47
|
}, applySingleFilter = (column, filter) => (item) => {
|
|
53
|
-
const value = getComparableValue(column, item);
|
|
48
|
+
const value = (0, exports.getComparableValue)(column, item);
|
|
54
49
|
if (value == null) {
|
|
55
50
|
return false;
|
|
56
51
|
}
|
|
57
|
-
const min = getComparableValue({ ...column, valuePath: 'min' }, filter), max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
52
|
+
const min = (0, exports.getComparableValue)({ ...column, valuePath: 'min' }, filter), max = (0, exports.getComparableValue)({ ...column, valuePath: 'max' }, filter);
|
|
58
53
|
return !(value < min || value > max);
|
|
59
|
-
},
|
|
54
|
+
}, getFormatter = (currency, locale) => {
|
|
60
55
|
const id = locale ? locale : '', key = currency + id || '';
|
|
61
|
-
if (formatters[key]) {
|
|
62
|
-
return formatters[key];
|
|
56
|
+
if (exports.formatters[key]) {
|
|
57
|
+
return exports.formatters[key];
|
|
63
58
|
}
|
|
64
|
-
formatters[key] = new Intl.NumberFormat(locale || undefined, {
|
|
59
|
+
exports.formatters[key] = new Intl.NumberFormat(locale || undefined, {
|
|
65
60
|
style: 'currency',
|
|
66
61
|
currency,
|
|
67
62
|
});
|
|
68
|
-
return formatters[key];
|
|
63
|
+
return exports.formatters[key];
|
|
69
64
|
}, renderValue = (rates, value, locale) => {
|
|
70
|
-
const amount = toAmount(rates, value);
|
|
65
|
+
const amount = (0, exports.toAmount)(rates, value);
|
|
71
66
|
if (amount == null) {
|
|
72
67
|
return '';
|
|
73
68
|
}
|
|
74
|
-
return getFormatter(amount.currency, locale).format(amount.amount);
|
|
69
|
+
return (0, exports.getFormatter)(amount.currency, locale).format(amount.amount);
|
|
75
70
|
}, getString = ({ valuePath, rates, locale }, item) => {
|
|
76
|
-
const value = toAmount(rates, get(item, valuePath));
|
|
71
|
+
const value = (0, exports.toAmount)(rates, (0, path_1.get)(item, valuePath));
|
|
77
72
|
if (value === undefined) {
|
|
78
73
|
return '';
|
|
79
74
|
}
|
|
80
75
|
if (value === null) {
|
|
81
76
|
return 'Invalid value';
|
|
82
77
|
}
|
|
83
|
-
return renderValue(rates, value, locale);
|
|
78
|
+
return (0, exports.renderValue)(rates, value, locale);
|
|
84
79
|
}, toHashString = (value) => {
|
|
85
80
|
if (!value) {
|
|
86
81
|
return '';
|
|
@@ -95,5 +90,6 @@ export const /**
|
|
|
95
90
|
return null;
|
|
96
91
|
}
|
|
97
92
|
return { amount: params[1], currency: params[2] };
|
|
98
|
-
}, getCurrency = ({ valuePath }, item) => get(item, valuePath)?.currency, getInputString = ({ valuePath }, item) => get(item, valuePath)?.amount;
|
|
93
|
+
}, getCurrency = ({ valuePath }, item) => (0, path_1.get)(item, valuePath)?.currency, getInputString = ({ valuePath }, item) => (0, path_1.get)(item, valuePath)?.amount;
|
|
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;
|
|
99
95
|
//# sourceMappingURL=utils-amount.js.map
|
package/dist/lib/utils-data.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.onItemChange = exports.defaultComputeSource = exports.valuesFrom = void 0;
|
|
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)
|
|
4
7
|
? data
|
|
5
|
-
.map((item) => get(item, valuePath))
|
|
8
|
+
.map((item) => (0, path_1.get)(item, valuePath))
|
|
6
9
|
.filter((value, index, self) => value != null && self.indexOf(value) === index)
|
|
7
10
|
: undefined, defaultComputeSource = ({ externalValues, values, valuePath }, data) => externalValues || typeof values === 'function'
|
|
8
11
|
? values
|
|
9
|
-
: valuesFrom(data, valuePath), onItemChange = (host, column, item, value) => {
|
|
10
|
-
const { valuePath } = column, oldValue = get(item, valuePath);
|
|
12
|
+
: (0, exports.valuesFrom)(data, valuePath), onItemChange = (host, column, item, value) => {
|
|
13
|
+
const { valuePath } = column, oldValue = (0, path_1.get)(item, valuePath);
|
|
11
14
|
if (value === oldValue) {
|
|
12
15
|
return;
|
|
13
16
|
}
|
|
14
|
-
set(item, valuePath, value);
|
|
17
|
+
(0, path_1.set)(item, valuePath, value);
|
|
15
18
|
const change = {
|
|
16
19
|
item,
|
|
17
20
|
valuePath,
|
|
18
21
|
value,
|
|
19
22
|
oldValue,
|
|
20
|
-
column: column[columnSymbol],
|
|
23
|
+
column: column[use_dom_columns_1.columnSymbol],
|
|
21
24
|
};
|
|
22
25
|
host.dispatchEvent(new CustomEvent('column-item-changed', {
|
|
23
26
|
bubbles: true,
|
|
@@ -25,4 +28,5 @@ export const valuesFrom = (data, valuePath) => Array.isArray(data)
|
|
|
25
28
|
detail: change,
|
|
26
29
|
}));
|
|
27
30
|
};
|
|
31
|
+
exports.valuesFrom = valuesFrom, exports.defaultComputeSource = defaultComputeSource, exports.onItemChange = onItemChange;
|
|
28
32
|
//# sourceMappingURL=utils-data.js.map
|
package/dist/lib/utils-date.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export function getAbsoluteISOString(localISOString: any): any;
|
|
|
3
3
|
export function parseDate(value: any): any;
|
|
4
4
|
export function getComparableValue({ valuePath }: {
|
|
5
5
|
valuePath: any;
|
|
6
|
-
}, item: any):
|
|
6
|
+
}, item: any): number | undefined;
|
|
7
7
|
export function toDate(value: any, limit: any, limitFunc: any): any;
|
|
8
8
|
export function renderValue(value: any, formatter: any): any;
|
|
9
9
|
export const formatters: {};
|
|
@@ -12,12 +12,12 @@ export function getString({ valuePath, locale }: {
|
|
|
12
12
|
valuePath: any;
|
|
13
13
|
locale: any;
|
|
14
14
|
}, item: any): any;
|
|
15
|
-
export function toInputString(value: any):
|
|
15
|
+
export function toInputString(value: any): string | null;
|
|
16
16
|
export function getInputString({ valuePath }: {
|
|
17
17
|
valuePath: any;
|
|
18
|
-
}, item: any):
|
|
18
|
+
}, item: any): string | null;
|
|
19
19
|
export function fromInputString(value: any, property: any): any;
|
|
20
|
-
export function toHashString(value: any):
|
|
20
|
+
export function toHashString(value: any): string;
|
|
21
21
|
export function toXlsxValue({ valuePath }: {
|
|
22
22
|
valuePath: any;
|
|
23
23
|
}, item: any): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-date.d.ts","sourceRoot":"","sources":["../../src/lib/utils-date.js"],"names":[],"mappings":"AAIO,+DA6LL;AA7LK,+DA6LL;AA7LK,2CA6LL;AA7LK;;
|
|
1
|
+
{"version":3,"file":"utils-date.d.ts","sourceRoot":"","sources":["../../src/lib/utils-date.js"],"names":[],"mappings":"AAIO,+DA6LL;AA7LK,+DA6LL;AA7LK,2CA6LL;AA7LK;;kCA6LL;AA7LK,oEA6LL;AA7LK,6DA6LL;AA7ED,4BAAe;AAhHT,+CA6LL;AA7LK;;;mBA6LL;AA7LK,yDA6LL;AA7LK;;6BA6LL;AA7LK,gEA6LL;AA7LK,iDA6LL;AA7LK;;mBA6LL;AA7LK,8DAkLmC,SAAI,aAW5C"}
|
package/dist/lib/utils-date.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/ getTimezoneString = (localISOString) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applySingleFilter = exports.toXlsxValue = exports.toHashString = exports.fromInputString = exports.getInputString = exports.toInputString = exports.getString = exports.getFormatter = exports.formatters = exports.renderValue = exports.toDate = exports.getComparableValue = exports.parseDate = exports.getAbsoluteISOString = exports.getTimezoneString = void 0;
|
|
4
|
+
const date_1 = require("@neovici/cosmoz-utils/date");
|
|
5
|
+
const path_1 = require("@polymer/polymer/lib/utils/path");
|
|
6
|
+
const utils_number_1 = require("./utils-number");
|
|
7
|
+
const getTimezoneString = (localISOString) => {
|
|
9
8
|
const off = -new Date(localISOString).getTimezoneOffset() / 60;
|
|
10
9
|
return ((off < 0 ? '-' : '+') + ['0', Math.abs(off)].join('').substr(-2) + ':00');
|
|
11
10
|
},
|
|
@@ -19,7 +18,7 @@ getAbsoluteISOString = (localISOString) => {
|
|
|
19
18
|
// but Safari uses UTC, so we set it implicitly
|
|
20
19
|
// TODO: Consider removing this when/if Safari handles local timezone correctly
|
|
21
20
|
if (localISOString.length === 19) {
|
|
22
|
-
return localISOString + getTimezoneString(localISOString);
|
|
21
|
+
return localISOString + (0, exports.getTimezoneString)(localISOString);
|
|
23
22
|
}
|
|
24
23
|
return localISOString;
|
|
25
24
|
}, parseDate = (value) => {
|
|
@@ -31,9 +30,9 @@ getAbsoluteISOString = (localISOString) => {
|
|
|
31
30
|
if (!(date instanceof Date)) {
|
|
32
31
|
// if the value is an ISO string, make sure that it has an explicit timezone
|
|
33
32
|
if (typeof value === 'string') {
|
|
34
|
-
date = getAbsoluteISOString(date);
|
|
33
|
+
date = (0, exports.getAbsoluteISOString)(date);
|
|
35
34
|
}
|
|
36
|
-
date = ensureDate(date);
|
|
35
|
+
date = (0, date_1.ensureDate)(date);
|
|
37
36
|
if (!date) {
|
|
38
37
|
return null;
|
|
39
38
|
}
|
|
@@ -56,13 +55,13 @@ getComparableValue = ({ valuePath }, item) => {
|
|
|
56
55
|
}
|
|
57
56
|
let value = item;
|
|
58
57
|
if (valuePath != null) {
|
|
59
|
-
value = get(item, valuePath);
|
|
58
|
+
value = (0, path_1.get)(item, valuePath);
|
|
60
59
|
}
|
|
61
|
-
value = parseDate(value);
|
|
60
|
+
value = (0, exports.parseDate)(value);
|
|
62
61
|
if (value == null) {
|
|
63
62
|
return;
|
|
64
63
|
}
|
|
65
|
-
return toNumber(value.getTime());
|
|
64
|
+
return (0, utils_number_1.toNumber)(value.getTime());
|
|
66
65
|
},
|
|
67
66
|
/**
|
|
68
67
|
* Converts an value to date optionaly limiting it.
|
|
@@ -73,53 +72,53 @@ getComparableValue = ({ valuePath }, item) => {
|
|
|
73
72
|
* @returns {Date|void} Value converted to date optionaly limitated
|
|
74
73
|
*/
|
|
75
74
|
toDate = (value, limit, limitFunc) => {
|
|
76
|
-
const date = parseDate(value);
|
|
75
|
+
const date = (0, exports.parseDate)(value);
|
|
77
76
|
if (date == null) {
|
|
78
77
|
return null;
|
|
79
78
|
}
|
|
80
79
|
if (limitFunc == null || limit == null) {
|
|
81
80
|
return date;
|
|
82
81
|
}
|
|
83
|
-
const lDate = toDate(limit);
|
|
82
|
+
const lDate = (0, exports.toDate)(limit);
|
|
84
83
|
if (lDate == null) {
|
|
85
84
|
return date;
|
|
86
85
|
}
|
|
87
|
-
const comparableDate = getComparableValue({}, date), comparableLDate = getComparableValue({}, lDate), limitedValue = limitFunc(comparableDate, comparableLDate);
|
|
86
|
+
const comparableDate = (0, exports.getComparableValue)({}, date), comparableLDate = (0, exports.getComparableValue)({}, lDate), limitedValue = limitFunc(comparableDate, comparableLDate);
|
|
88
87
|
return limitedValue === comparableDate ? date : lDate;
|
|
89
88
|
}, renderValue = (value, formatter) => {
|
|
90
89
|
if (formatter == null) {
|
|
91
90
|
return;
|
|
92
91
|
}
|
|
93
|
-
const date = toDate(value);
|
|
92
|
+
const date = (0, exports.toDate)(value);
|
|
94
93
|
if (date == null) {
|
|
95
94
|
return;
|
|
96
95
|
}
|
|
97
96
|
return formatter.format(date);
|
|
98
|
-
},
|
|
97
|
+
}, getFormatter = (locale) => {
|
|
99
98
|
const key = locale || '';
|
|
100
|
-
if (formatters[key]) {
|
|
101
|
-
return formatters[key];
|
|
99
|
+
if (exports.formatters[key]) {
|
|
100
|
+
return exports.formatters[key];
|
|
102
101
|
}
|
|
103
|
-
formatters[key] = new Intl.DateTimeFormat(locale || undefined);
|
|
104
|
-
return formatters[key];
|
|
102
|
+
exports.formatters[key] = new Intl.DateTimeFormat(locale || undefined);
|
|
103
|
+
return exports.formatters[key];
|
|
105
104
|
}, getString = ({ valuePath, locale }, item) => {
|
|
106
|
-
let value = get(item, valuePath);
|
|
105
|
+
let value = (0, path_1.get)(item, valuePath);
|
|
107
106
|
if (value === undefined) {
|
|
108
107
|
return '';
|
|
109
108
|
}
|
|
110
|
-
value = toDate(value);
|
|
109
|
+
value = (0, exports.toDate)(value);
|
|
111
110
|
if (value === null) {
|
|
112
111
|
return 'Invalid Date';
|
|
113
112
|
}
|
|
114
|
-
return renderValue(value, getFormatter(locale));
|
|
113
|
+
return (0, exports.renderValue)(value, (0, exports.getFormatter)(locale));
|
|
115
114
|
}, toInputString = (value) => {
|
|
116
|
-
const date = toDate(value);
|
|
115
|
+
const date = (0, exports.toDate)(value);
|
|
117
116
|
if (date == null) {
|
|
118
117
|
return null;
|
|
119
118
|
}
|
|
120
|
-
return toLocalISOString(date).slice(0, 10);
|
|
121
|
-
}, getInputString = ({ valuePath }, item) => toInputString(get(item, valuePath)), fromInputString = (value, property) => {
|
|
122
|
-
const date = toDate(value);
|
|
119
|
+
return (0, date_1.toLocalISOString)(date).slice(0, 10);
|
|
120
|
+
}, getInputString = ({ valuePath }, item) => (0, exports.toInputString)((0, path_1.get)(item, valuePath)), fromInputString = (value, property) => {
|
|
121
|
+
const date = (0, exports.toDate)(value);
|
|
123
122
|
if (date == null) {
|
|
124
123
|
return;
|
|
125
124
|
}
|
|
@@ -131,7 +130,7 @@ toDate = (value, limit, limitFunc) => {
|
|
|
131
130
|
}
|
|
132
131
|
return date;
|
|
133
132
|
}, toHashString = (value) => {
|
|
134
|
-
const string = toInputString(value);
|
|
133
|
+
const string = (0, exports.toInputString)(value);
|
|
135
134
|
if (string == null) {
|
|
136
135
|
return '';
|
|
137
136
|
}
|
|
@@ -140,22 +139,46 @@ toDate = (value, limit, limitFunc) => {
|
|
|
140
139
|
if (!valuePath) {
|
|
141
140
|
return '';
|
|
142
141
|
}
|
|
143
|
-
const date = toDate(get(item, valuePath));
|
|
142
|
+
const date = (0, exports.toDate)((0, path_1.get)(item, valuePath));
|
|
144
143
|
if (!date) {
|
|
145
144
|
return '';
|
|
146
145
|
}
|
|
147
|
-
const localDate = toDate(toLocalISOString(date));
|
|
146
|
+
const localDate = (0, exports.toDate)((0, date_1.toLocalISOString)(date));
|
|
148
147
|
if (!localDate) {
|
|
149
148
|
return '';
|
|
150
149
|
}
|
|
151
150
|
localDate.setHours(0, 0, 0, 0);
|
|
152
151
|
return localDate;
|
|
153
152
|
}, applySingleFilter = (column, filter) => (item) => {
|
|
154
|
-
const value = getComparableValue(column, item);
|
|
153
|
+
const value = (0, exports.getComparableValue)(column, item);
|
|
155
154
|
if (value == null) {
|
|
156
155
|
return false;
|
|
157
156
|
}
|
|
158
|
-
const min = getComparableValue({ ...column, valuePath: 'min' }, filter), max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
157
|
+
const min = (0, exports.getComparableValue)({ ...column, valuePath: 'min' }, filter), max = (0, exports.getComparableValue)({ ...column, valuePath: 'max' }, filter);
|
|
159
158
|
return !(value < min || value > max);
|
|
160
159
|
};
|
|
160
|
+
exports.getTimezoneString = getTimezoneString,
|
|
161
|
+
/**
|
|
162
|
+
* Computes the local timezone and adds it to a local ISO string
|
|
163
|
+
* @param {String} localISOString an ISO date string, without timezone info
|
|
164
|
+
* @return {String} an ISO date string, with timezone info
|
|
165
|
+
*/
|
|
166
|
+
exports.getAbsoluteISOString = getAbsoluteISOString, exports.parseDate = parseDate,
|
|
167
|
+
/**
|
|
168
|
+
* Get comparable number from date
|
|
169
|
+
*
|
|
170
|
+
* @param {String} valuePath Property path
|
|
171
|
+
* @param {Object} item Item to be processed
|
|
172
|
+
* @returns {Number|void} Valid value or void
|
|
173
|
+
*/
|
|
174
|
+
exports.getComparableValue = getComparableValue,
|
|
175
|
+
/**
|
|
176
|
+
* Converts an value to date optionaly limiting it.
|
|
177
|
+
*
|
|
178
|
+
* @param {Date|String} value Value to convert to date
|
|
179
|
+
* @param {Date|String} limit Value used to limit the date
|
|
180
|
+
* @param {Function} limitFunc Function used to limit the date (Math.min|Math.max)
|
|
181
|
+
* @returns {Date|void} Value converted to date optionaly limitated
|
|
182
|
+
*/
|
|
183
|
+
exports.toDate = toDate, exports.renderValue = renderValue, exports.formatters = {}, exports.getFormatter = getFormatter, exports.getString = getString, exports.toInputString = toInputString, exports.getInputString = getInputString, exports.fromInputString = fromInputString, exports.toHashString = toHashString, exports.toXlsxValue = toXlsxValue, exports.applySingleFilter = applySingleFilter;
|
|
161
184
|
//# sourceMappingURL=utils-date.js.map
|
|
@@ -9,8 +9,8 @@ export function toXlsxValue({ valuePath }: {
|
|
|
9
9
|
}, item: any): any;
|
|
10
10
|
export function toHashString(value: any): any;
|
|
11
11
|
export function fromHashString(value: any): any;
|
|
12
|
-
export function toInputString(value: any):
|
|
12
|
+
export function toInputString(value: any): string | null;
|
|
13
13
|
export function getInputString({ valuePath }: {
|
|
14
14
|
valuePath: any;
|
|
15
|
-
}, item: any):
|
|
15
|
+
}, item: any): string | null;
|
|
16
16
|
//# sourceMappingURL=utils-datetime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-datetime.d.ts","sourceRoot":"","sources":["../../src/lib/utils-datetime.js"],"names":[],"mappings":"AAIa,4BAAe;AAArB,+CA6DuE;AA7DvE;;;mBA6DuE;AA7DvE;;mBA6DuE;AA7DvE,8CA6DuE;AA7DvE,gDA6DuE;AA7DvE
|
|
1
|
+
{"version":3,"file":"utils-datetime.d.ts","sourceRoot":"","sources":["../../src/lib/utils-datetime.js"],"names":[],"mappings":"AAIa,4BAAe;AAArB,+CA6DuE;AA7DvE;;;mBA6DuE;AA7DvE;;mBA6DuE;AA7DvE,8CA6DuE;AA7DvE,gDA6DuE;AA7DvE,yDA6DuE;AA7DvE;;6BA6DuE"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getInputString = exports.toInputString = exports.fromHashString = exports.toHashString = exports.toXlsxValue = exports.getString = exports.getFormatter = exports.formatters = void 0;
|
|
4
|
+
const date_1 = require("@neovici/cosmoz-utils/date");
|
|
5
|
+
const path_1 = require("@polymer/polymer/lib/utils/path");
|
|
6
|
+
const utils_date_1 = require("./utils-date");
|
|
7
|
+
const getFormatter = (locale) => {
|
|
5
8
|
const key = locale || '';
|
|
6
|
-
if (formatters[key]) {
|
|
7
|
-
return formatters[key];
|
|
9
|
+
if (exports.formatters[key]) {
|
|
10
|
+
return exports.formatters[key];
|
|
8
11
|
}
|
|
9
12
|
const timeFormatOption = {
|
|
10
13
|
year: 'numeric',
|
|
@@ -13,24 +16,24 @@ export const formatters = {}, getFormatter = (locale) => {
|
|
|
13
16
|
hour: 'numeric',
|
|
14
17
|
minute: 'numeric',
|
|
15
18
|
};
|
|
16
|
-
formatters[key] = new Intl.DateTimeFormat(locale || undefined, timeFormatOption);
|
|
17
|
-
return formatters[key];
|
|
19
|
+
exports.formatters[key] = new Intl.DateTimeFormat(locale || undefined, timeFormatOption);
|
|
20
|
+
return exports.formatters[key];
|
|
18
21
|
}, getString = ({ valuePath, locale }, item) => {
|
|
19
|
-
const value = toDate(get(item, valuePath));
|
|
22
|
+
const value = (0, utils_date_1.toDate)((0, path_1.get)(item, valuePath));
|
|
20
23
|
if (value === undefined) {
|
|
21
24
|
return '';
|
|
22
25
|
}
|
|
23
26
|
if (value === null) {
|
|
24
27
|
return 'Invalid Date';
|
|
25
28
|
}
|
|
26
|
-
return renderValue(value, getFormatter(locale));
|
|
29
|
+
return (0, utils_date_1.renderValue)(value, (0, exports.getFormatter)(locale));
|
|
27
30
|
}, toXlsxValue = ({ valuePath }, item) => {
|
|
28
31
|
if (!valuePath) {
|
|
29
32
|
return '';
|
|
30
33
|
}
|
|
31
|
-
return get(item, valuePath);
|
|
34
|
+
return (0, path_1.get)(item, valuePath);
|
|
32
35
|
}, toHashString = (value) => {
|
|
33
|
-
const date = toDate(value);
|
|
36
|
+
const date = (0, utils_date_1.toDate)(value);
|
|
34
37
|
if (date == null) {
|
|
35
38
|
return '';
|
|
36
39
|
}
|
|
@@ -41,12 +44,13 @@ export const formatters = {}, getFormatter = (locale) => {
|
|
|
41
44
|
return;
|
|
42
45
|
}
|
|
43
46
|
//Parse utc from hash string
|
|
44
|
-
return toDate(value.replace(/\./gu, ':') + 'Z');
|
|
47
|
+
return (0, utils_date_1.toDate)(value.replace(/\./gu, ':') + 'Z');
|
|
45
48
|
}, toInputString = (value) => {
|
|
46
|
-
const date = toDate(value);
|
|
49
|
+
const date = (0, utils_date_1.toDate)(value);
|
|
47
50
|
if (date == null) {
|
|
48
51
|
return null;
|
|
49
52
|
}
|
|
50
|
-
return toLocalISOString(date).slice(0, 19);
|
|
51
|
-
}, getInputString = ({ valuePath }, item) => toInputString(get(item, valuePath));
|
|
53
|
+
return (0, date_1.toLocalISOString)(date).slice(0, 19);
|
|
54
|
+
}, getInputString = ({ valuePath }, item) => (0, exports.toInputString)((0, path_1.get)(item, valuePath));
|
|
55
|
+
exports.formatters = {}, exports.getFormatter = getFormatter, exports.getString = getString, exports.toXlsxValue = toXlsxValue, exports.toHashString = toHashString, exports.fromHashString = fromHashString, exports.toInputString = toInputString, exports.getInputString = getInputString;
|
|
52
56
|
//# sourceMappingURL=utils-datetime.js.map
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}, item:
|
|
11
|
-
export const
|
|
12
|
-
export function getString({ valuePath, locale, minimumFractionDigits, maximumFractionDigits }: {
|
|
13
|
-
valuePath: any;
|
|
14
|
-
locale: any;
|
|
15
|
-
minimumFractionDigits: any;
|
|
16
|
-
maximumFractionDigits: any;
|
|
17
|
-
}, item: any): any;
|
|
18
|
-
export function applySingleFilter(column: any, filter: any): (item: any) => boolean;
|
|
1
|
+
import { LimitFunction, GetPath, Item, NumberColumn, AmountLimit } from './types.js';
|
|
2
|
+
export declare const toNumber: (value?: unknown, limit?: unknown, limitFunc?: LimitFunction) => number | undefined;
|
|
3
|
+
export declare const toInputString: (value?: unknown) => string | null;
|
|
4
|
+
export declare const getInputString: ({ valuePath }: {
|
|
5
|
+
valuePath?: GetPath;
|
|
6
|
+
}, item: Item) => string | null;
|
|
7
|
+
export declare const toHashString: (value: unknown) => string;
|
|
8
|
+
export declare const getComparableValue: <T extends NumberColumn>({ valuePath, maximumFractionDigits }: T, item?: Item) => number | undefined;
|
|
9
|
+
export declare const makeFormatter: (locale?: string | undefined, minimumFractionDigits?: number | null | undefined, maximumFractionDigits?: number | null | undefined) => Intl.NumberFormat;
|
|
10
|
+
export declare const getString: <T extends NumberColumn>({ valuePath, locale, minimumFractionDigits, maximumFractionDigits }: T, item: Item) => string | undefined;
|
|
11
|
+
export declare const applySingleFilter: (column: NumberColumn, filter: AmountLimit) => (item: Item) => boolean;
|
|
19
12
|
//# sourceMappingURL=utils-number.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-number.d.ts","sourceRoot":"","sources":["../../src/lib/utils-number.
|
|
1
|
+
{"version":3,"file":"utils-number.d.ts","sourceRoot":"","sources":["../../src/lib/utils-number.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,aAAa,EACb,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,QAAQ,GACpB,QAAQ,OAAO,EACf,QAAQ,OAAO,EACf,YAAY,aAAa,KACvB,MAAM,GAAG,SAsBX,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,QAAQ,OAAO,KAAG,MAAM,GAAG,IAQxD,CAAC;AAEF,eAAO,MAAM,cAAc,GAC1B,eAAe;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,EACtC,MAAM,IAAI,KACR,MAAM,GAAG,IAIX,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,KAAG,MAQ7C,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,YAAY,EACxD,sCAAsC,CAAC,EACvC,OAAO,IAAI,KACT,MAAM,GAAG,SAiBX,CAAC;AAEF,eAAO,MAAM,aAAa,0JAoBzB,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,YAAY,EAC/C,qEAAqE,CAAC,EACtE,MAAM,IAAI,KACR,MAAM,GAAG,SAoBX,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,YAAY,EAAE,QAAQ,WAAW,MACzC,MAAM,IAAI,KAAG,OAWb,CAAC"}
|