@neovici/cosmoz-omnitable 14.17.0 → 14.19.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 +23 -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 +15 -24
- package/dist/lib/utils-date.d.ts.map +1 -1
- package/dist/lib/utils-date.js +82 -66
- package/dist/lib/utils-datetime.d.ts +9 -15
- package/dist/lib/utils-datetime.d.ts.map +1 -1
- package/dist/lib/utils-datetime.js +42 -21
- 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 +12 -16
- package/dist/lib/utils-time.d.ts.map +1 -1
- package/dist/lib/utils-time.js +61 -42
- package/dist/lib/utils.js +6 -2
- package/dist/ui-helpers/cosmoz-clear-button.js +7 -5
- package/package.json +1 -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
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export const
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}, item:
|
|
15
|
-
export
|
|
16
|
-
export function getInputString({ valuePath }: {
|
|
17
|
-
valuePath: any;
|
|
18
|
-
}, item: any): any;
|
|
19
|
-
export function fromInputString(value: any, property: any): any;
|
|
20
|
-
export function toHashString(value: any): any;
|
|
21
|
-
export function toXlsxValue({ valuePath }: {
|
|
22
|
-
valuePath: any;
|
|
23
|
-
}, item: any): any;
|
|
24
|
-
export function applySingleFilter(column: any, filter: any): (item: any) => boolean;
|
|
1
|
+
import { DateColumn, Item, LimitFunction, Limit } from './types';
|
|
2
|
+
export declare const getTimezoneString: (localISOString: string) => string;
|
|
3
|
+
export declare const getAbsoluteISOString: (localISOString: string) => string;
|
|
4
|
+
export declare const parseDate: (value: unknown) => Date | null | undefined;
|
|
5
|
+
export declare const getComparableValue: <T extends DateColumn>({ valuePath }: T, item: Item) => number | undefined;
|
|
6
|
+
export declare const toDate: (value: unknown, limit?: unknown, limitFunc?: LimitFunction) => Date | null;
|
|
7
|
+
export declare const renderValue: (value: unknown, formatter?: Intl.DateTimeFormat) => string | undefined;
|
|
8
|
+
export declare const getFormatter: (locale?: string) => Intl.DateTimeFormat;
|
|
9
|
+
export declare const getString: <T extends DateColumn>({ valuePath, locale }: T, item: unknown) => string | undefined;
|
|
10
|
+
export declare const toInputString: (value: unknown) => string | null;
|
|
11
|
+
export declare const getInputString: ({ valuePath }: DateColumn, item: unknown) => string | null;
|
|
12
|
+
export declare const fromInputString: (value: unknown, property?: keyof Limit<Date>) => Date | undefined;
|
|
13
|
+
export declare const toHashString: (value: unknown) => string;
|
|
14
|
+
export declare const toXlsxValue: <T extends DateColumn>({ valuePath }: T, item: Item) => "" | Date;
|
|
15
|
+
export declare const applySingleFilter: (column: DateColumn, filter: Limit<Date | undefined>) => (item: Item) => boolean;
|
|
25
16
|
//# sourceMappingURL=utils-date.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-date.d.ts","sourceRoot":"","sources":["../../src/lib/utils-date.
|
|
1
|
+
{"version":3,"file":"utils-date.d.ts","sourceRoot":"","sources":["../../src/lib/utils-date.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEjE,eAAO,MAAM,iBAAiB,GAAI,gBAAgB,MAAM,WAMvD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,gBAAgB,MAAM,WAS1D,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,IAAI,GAAG,IAAI,GAAG,SA4BxD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,UAAU,EACtD,eAAe,CAAC,EAChB,MAAM,IAAI,KACR,MAAM,GAAG,SAkBX,CAAC;AAEF,eAAO,MAAM,MAAM,GAClB,OAAO,OAAO,EACd,QAAQ,OAAO,EACf,YAAY,aAAa,KACvB,IAAI,GAAG,IA2BT,CAAC;AAEF,eAAO,MAAM,WAAW,GACvB,OAAO,OAAO,EACd,YAAY,IAAI,CAAC,cAAc,KAC7B,MAAM,GAAG,SAYX,CAAC;AAIF,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,IAAI,CAAC,cAUnD,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,UAAU,EAC7C,uBAAuB,CAAC,EACxB,MAAM,OAAO,KACX,MAAM,GAAG,SAcX,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,kBAc3C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,eAAe,UAAU,EAAE,MAAM,OAAO,kBACnB,CAAC;AAErD,eAAO,MAAM,eAAe,GAC3B,OAAO,OAAO,EACd,WAAW,MAAM,KAAK,CAAC,IAAI,CAAC,KAC1B,IAAI,GAAG,SAgBT,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,WAQ1C,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,UAAU,EAC/C,eAAe,CAAC,EAChB,MAAM,IAAI,cAqBV,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,UAAU,EAAE,QAAQ,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC,MAAM,MAAM,IAAI,YAqBnE,CAAC"}
|
package/dist/lib/utils-date.js
CHANGED
|
@@ -1,39 +1,37 @@
|
|
|
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.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
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* @param {String} localISOString an ISO date string, without timezone info
|
|
15
|
-
* @return {String} an ISO date string, with timezone info
|
|
16
|
-
*/
|
|
17
|
-
getAbsoluteISOString = (localISOString) => {
|
|
10
|
+
};
|
|
11
|
+
exports.getTimezoneString = getTimezoneString;
|
|
12
|
+
const getAbsoluteISOString = (localISOString) => {
|
|
18
13
|
// Most browsers use local timezone when no timezone is specified
|
|
19
14
|
// but Safari uses UTC, so we set it implicitly
|
|
20
15
|
// TODO: Consider removing this when/if Safari handles local timezone correctly
|
|
21
16
|
if (localISOString.length === 19) {
|
|
22
|
-
return localISOString + getTimezoneString(localISOString);
|
|
17
|
+
return localISOString + (0, exports.getTimezoneString)(localISOString);
|
|
23
18
|
}
|
|
24
19
|
return localISOString;
|
|
25
|
-
}
|
|
20
|
+
};
|
|
21
|
+
exports.getAbsoluteISOString = getAbsoluteISOString;
|
|
22
|
+
const parseDate = (value) => {
|
|
26
23
|
if (value == null || value === '') {
|
|
27
24
|
return;
|
|
28
25
|
}
|
|
29
26
|
// convert value to Date
|
|
30
27
|
let date = value;
|
|
31
|
-
|
|
28
|
+
const isDate = date instanceof Date;
|
|
29
|
+
if (!isDate) {
|
|
32
30
|
// if the value is an ISO string, make sure that it has an explicit timezone
|
|
33
31
|
if (typeof value === 'string') {
|
|
34
|
-
date = getAbsoluteISOString(date);
|
|
32
|
+
date = (0, exports.getAbsoluteISOString)(date);
|
|
35
33
|
}
|
|
36
|
-
date = ensureDate(date);
|
|
34
|
+
date = (0, date_1.ensureDate)(date);
|
|
37
35
|
if (!date) {
|
|
38
36
|
return null;
|
|
39
37
|
}
|
|
@@ -42,84 +40,92 @@ getAbsoluteISOString = (localISOString) => {
|
|
|
42
40
|
return null;
|
|
43
41
|
}
|
|
44
42
|
return date;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
* @param {String} valuePath Property path
|
|
50
|
-
* @param {Object} item Item to be processed
|
|
51
|
-
* @returns {Number|void} Valid value or void
|
|
52
|
-
*/
|
|
53
|
-
getComparableValue = ({ valuePath }, item) => {
|
|
43
|
+
};
|
|
44
|
+
exports.parseDate = parseDate;
|
|
45
|
+
const getComparableValue = ({ valuePath }, item) => {
|
|
54
46
|
if (item == null) {
|
|
55
47
|
return;
|
|
56
48
|
}
|
|
57
49
|
let value = item;
|
|
58
50
|
if (valuePath != null) {
|
|
59
|
-
value = get(item, valuePath);
|
|
51
|
+
value = (0, path_1.get)(item, valuePath);
|
|
60
52
|
}
|
|
61
|
-
|
|
62
|
-
if (
|
|
53
|
+
const date = (0, exports.parseDate)(value);
|
|
54
|
+
if (date == null) {
|
|
63
55
|
return;
|
|
64
56
|
}
|
|
65
|
-
return toNumber(
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
* @param {Date|String} value Value to convert to date
|
|
71
|
-
* @param {Date|String} limit Value used to limit the date
|
|
72
|
-
* @param {Function} limitFunc Function used to limit the date (Math.min|Math.max)
|
|
73
|
-
* @returns {Date|void} Value converted to date optionaly limitated
|
|
74
|
-
*/
|
|
75
|
-
toDate = (value, limit, limitFunc) => {
|
|
76
|
-
const date = parseDate(value);
|
|
57
|
+
return (0, utils_number_1.toNumber)(date.getTime());
|
|
58
|
+
};
|
|
59
|
+
exports.getComparableValue = getComparableValue;
|
|
60
|
+
const toDate = (value, limit, limitFunc) => {
|
|
61
|
+
const date = (0, exports.parseDate)(value);
|
|
77
62
|
if (date == null) {
|
|
78
63
|
return null;
|
|
79
64
|
}
|
|
80
65
|
if (limitFunc == null || limit == null) {
|
|
81
66
|
return date;
|
|
82
67
|
}
|
|
83
|
-
const lDate = toDate(limit);
|
|
68
|
+
const lDate = (0, exports.toDate)(limit);
|
|
84
69
|
if (lDate == null) {
|
|
85
70
|
return date;
|
|
86
71
|
}
|
|
87
|
-
const comparableDate = getComparableValue({}, date), comparableLDate = getComparableValue({}, lDate)
|
|
72
|
+
const comparableDate = (0, exports.getComparableValue)({}, date), comparableLDate = (0, exports.getComparableValue)({}, lDate);
|
|
73
|
+
if (comparableDate == null || comparableLDate == null) {
|
|
74
|
+
return date;
|
|
75
|
+
}
|
|
76
|
+
const limitedValue = limitFunc(comparableDate, comparableLDate);
|
|
88
77
|
return limitedValue === comparableDate ? date : lDate;
|
|
89
|
-
}
|
|
78
|
+
};
|
|
79
|
+
exports.toDate = toDate;
|
|
80
|
+
const renderValue = (value, formatter) => {
|
|
90
81
|
if (formatter == null) {
|
|
91
82
|
return;
|
|
92
83
|
}
|
|
93
|
-
const date = toDate(value);
|
|
84
|
+
const date = (0, exports.toDate)(value);
|
|
94
85
|
if (date == null) {
|
|
95
86
|
return;
|
|
96
87
|
}
|
|
97
88
|
return formatter.format(date);
|
|
98
|
-
}
|
|
89
|
+
};
|
|
90
|
+
exports.renderValue = renderValue;
|
|
91
|
+
const formatters = {};
|
|
92
|
+
const getFormatter = (locale) => {
|
|
99
93
|
const key = locale || '';
|
|
100
94
|
if (formatters[key]) {
|
|
101
95
|
return formatters[key];
|
|
102
96
|
}
|
|
103
97
|
formatters[key] = new Intl.DateTimeFormat(locale || undefined);
|
|
104
98
|
return formatters[key];
|
|
105
|
-
}
|
|
106
|
-
|
|
99
|
+
};
|
|
100
|
+
exports.getFormatter = getFormatter;
|
|
101
|
+
const getString = ({ valuePath, locale }, item) => {
|
|
102
|
+
let value = (0, path_1.get)(item, valuePath || '');
|
|
107
103
|
if (value === undefined) {
|
|
108
104
|
return '';
|
|
109
105
|
}
|
|
110
|
-
value = toDate(value);
|
|
106
|
+
value = (0, exports.toDate)(value);
|
|
111
107
|
if (value === null) {
|
|
112
108
|
return 'Invalid Date';
|
|
113
109
|
}
|
|
114
|
-
return renderValue(value, getFormatter(locale));
|
|
115
|
-
}
|
|
116
|
-
|
|
110
|
+
return (0, exports.renderValue)(value, (0, exports.getFormatter)(locale));
|
|
111
|
+
};
|
|
112
|
+
exports.getString = getString;
|
|
113
|
+
const toInputString = (value) => {
|
|
114
|
+
const date = (0, exports.toDate)(value);
|
|
117
115
|
if (date == null) {
|
|
118
116
|
return null;
|
|
119
117
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
const local = (0, date_1.toLocalISOString)(date);
|
|
119
|
+
if (local == null) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
return local.slice(0, 10);
|
|
123
|
+
};
|
|
124
|
+
exports.toInputString = toInputString;
|
|
125
|
+
const getInputString = ({ valuePath }, item) => (0, exports.toInputString)((0, path_1.get)(item, valuePath || ''));
|
|
126
|
+
exports.getInputString = getInputString;
|
|
127
|
+
const fromInputString = (value, property) => {
|
|
128
|
+
const date = (0, exports.toDate)(value);
|
|
123
129
|
if (date == null) {
|
|
124
130
|
return;
|
|
125
131
|
}
|
|
@@ -130,32 +136,42 @@ toDate = (value, limit, limitFunc) => {
|
|
|
130
136
|
date.setHours(23, 59, 59);
|
|
131
137
|
}
|
|
132
138
|
return date;
|
|
133
|
-
}
|
|
134
|
-
|
|
139
|
+
};
|
|
140
|
+
exports.fromInputString = fromInputString;
|
|
141
|
+
const toHashString = (value) => {
|
|
142
|
+
const string = (0, exports.toInputString)(value);
|
|
135
143
|
if (string == null) {
|
|
136
144
|
return '';
|
|
137
145
|
}
|
|
138
146
|
return string;
|
|
139
|
-
}
|
|
147
|
+
};
|
|
148
|
+
exports.toHashString = toHashString;
|
|
149
|
+
const toXlsxValue = ({ valuePath }, item) => {
|
|
140
150
|
if (!valuePath) {
|
|
141
151
|
return '';
|
|
142
152
|
}
|
|
143
|
-
const date = toDate(get(item, valuePath));
|
|
153
|
+
const date = (0, exports.toDate)((0, path_1.get)(item, valuePath));
|
|
144
154
|
if (!date) {
|
|
145
155
|
return '';
|
|
146
156
|
}
|
|
147
|
-
const localDate = toDate(toLocalISOString(date));
|
|
157
|
+
const localDate = (0, exports.toDate)((0, date_1.toLocalISOString)(date));
|
|
148
158
|
if (!localDate) {
|
|
149
159
|
return '';
|
|
150
160
|
}
|
|
151
161
|
localDate.setHours(0, 0, 0, 0);
|
|
152
162
|
return localDate;
|
|
153
|
-
}
|
|
154
|
-
|
|
163
|
+
};
|
|
164
|
+
exports.toXlsxValue = toXlsxValue;
|
|
165
|
+
const applySingleFilter = (column, filter) => (item) => {
|
|
166
|
+
const value = (0, exports.getComparableValue)(column, item);
|
|
155
167
|
if (value == null) {
|
|
156
168
|
return false;
|
|
157
169
|
}
|
|
158
|
-
const min = getComparableValue({ ...column, valuePath: 'min' }, filter), max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
170
|
+
const min = (0, exports.getComparableValue)({ ...column, valuePath: 'min' }, filter), max = (0, exports.getComparableValue)({ ...column, valuePath: 'max' }, filter);
|
|
171
|
+
if (min == null || max == null) {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
159
174
|
return !(value < min || value > max);
|
|
160
175
|
};
|
|
176
|
+
exports.applySingleFilter = applySingleFilter;
|
|
161
177
|
//# sourceMappingURL=utils-date.js.map
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
}, item:
|
|
10
|
-
export function toHashString(value: any): any;
|
|
11
|
-
export function fromHashString(value: any): any;
|
|
12
|
-
export function toInputString(value: any): any;
|
|
13
|
-
export function getInputString({ valuePath }: {
|
|
14
|
-
valuePath: any;
|
|
15
|
-
}, item: any): any;
|
|
1
|
+
import { DateColumn, Item } from './types';
|
|
2
|
+
export declare const formatters: Record<string, Intl.DateTimeFormat>;
|
|
3
|
+
export declare const getFormatter: (locale?: string) => Intl.DateTimeFormat;
|
|
4
|
+
export declare const getString: <T extends DateColumn>({ valuePath, locale }: T, item: Item) => string | undefined;
|
|
5
|
+
export declare const toXlsxValue: <T extends DateColumn>({ valuePath }: T, item: Item) => any;
|
|
6
|
+
export declare const toHashString: (value: unknown) => string;
|
|
7
|
+
export declare const fromHashString: (value: unknown) => Date | null | undefined;
|
|
8
|
+
export declare const toInputString: (value: unknown) => string | null;
|
|
9
|
+
export declare const getInputString: ({ valuePath }: DateColumn, item: Item) => string | null;
|
|
16
10
|
//# sourceMappingURL=utils-datetime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-datetime.d.ts","sourceRoot":"","sources":["../../src/lib/utils-datetime.
|
|
1
|
+
{"version":3,"file":"utils-datetime.d.ts","sourceRoot":"","sources":["../../src/lib/utils-datetime.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,CAAM,CAAC;AAElE,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,wBAqB3C,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,UAAU,EAC7C,uBAAuB,CAAC,EACxB,MAAM,IAAI,uBAWV,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,UAAU,EAC/C,eAAe,CAAC,EAChB,MAAM,IAAI,QAOV,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,WAO1C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,4BAS5C,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,kBAS3C,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,eAAe,UAAU,EAAE,MAAM,IAAI,kBAC1B,CAAC"}
|
|
@@ -1,10 +1,14 @@
|
|
|
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
|
+
exports.formatters = {};
|
|
8
|
+
const getFormatter = (locale) => {
|
|
5
9
|
const key = locale || '';
|
|
6
|
-
if (formatters[key]) {
|
|
7
|
-
return formatters[key];
|
|
10
|
+
if (exports.formatters[key]) {
|
|
11
|
+
return exports.formatters[key];
|
|
8
12
|
}
|
|
9
13
|
const timeFormatOption = {
|
|
10
14
|
year: 'numeric',
|
|
@@ -13,40 +17,57 @@ export const formatters = {}, getFormatter = (locale) => {
|
|
|
13
17
|
hour: 'numeric',
|
|
14
18
|
minute: 'numeric',
|
|
15
19
|
};
|
|
16
|
-
formatters[key] = new Intl.DateTimeFormat(locale || undefined, timeFormatOption);
|
|
17
|
-
return formatters[key];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
+
exports.formatters[key] = new Intl.DateTimeFormat(locale || undefined, timeFormatOption);
|
|
21
|
+
return exports.formatters[key];
|
|
22
|
+
};
|
|
23
|
+
exports.getFormatter = getFormatter;
|
|
24
|
+
const getString = ({ valuePath, locale }, item) => {
|
|
25
|
+
const value = (0, utils_date_1.toDate)((0, path_1.get)(item, valuePath || ''));
|
|
20
26
|
if (value === undefined) {
|
|
21
27
|
return '';
|
|
22
28
|
}
|
|
23
29
|
if (value === null) {
|
|
24
30
|
return 'Invalid Date';
|
|
25
31
|
}
|
|
26
|
-
return renderValue(value, getFormatter(locale));
|
|
27
|
-
}
|
|
32
|
+
return (0, utils_date_1.renderValue)(value, (0, exports.getFormatter)(locale));
|
|
33
|
+
};
|
|
34
|
+
exports.getString = getString;
|
|
35
|
+
const toXlsxValue = ({ valuePath }, item) => {
|
|
28
36
|
if (!valuePath) {
|
|
29
37
|
return '';
|
|
30
38
|
}
|
|
31
|
-
return get(item, valuePath);
|
|
32
|
-
}
|
|
33
|
-
|
|
39
|
+
return (0, path_1.get)(item, valuePath);
|
|
40
|
+
};
|
|
41
|
+
exports.toXlsxValue = toXlsxValue;
|
|
42
|
+
const toHashString = (value) => {
|
|
43
|
+
const date = (0, utils_date_1.toDate)(value);
|
|
34
44
|
if (date == null) {
|
|
35
45
|
return '';
|
|
36
46
|
}
|
|
37
47
|
//Use utc in hash
|
|
38
48
|
return date.toISOString().slice(0, 19).replace(/:/gu, '.');
|
|
39
|
-
}
|
|
49
|
+
};
|
|
50
|
+
exports.toHashString = toHashString;
|
|
51
|
+
const fromHashString = (value) => {
|
|
40
52
|
if (value == null || value === '') {
|
|
41
53
|
return;
|
|
42
54
|
}
|
|
43
55
|
//Parse utc from hash string
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
if (typeof value !== 'string') {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
return (0, utils_date_1.toDate)(value.replace(/\./gu, ':') + 'Z');
|
|
60
|
+
};
|
|
61
|
+
exports.fromHashString = fromHashString;
|
|
62
|
+
const toInputString = (value) => {
|
|
63
|
+
const date = (0, utils_date_1.toDate)(value);
|
|
47
64
|
if (date == null) {
|
|
48
65
|
return null;
|
|
49
66
|
}
|
|
50
|
-
|
|
51
|
-
|
|
67
|
+
const localISOString = (0, date_1.toLocalISOString)(date);
|
|
68
|
+
return localISOString ? localISOString.slice(0, 19) : localISOString;
|
|
69
|
+
};
|
|
70
|
+
exports.toInputString = toInputString;
|
|
71
|
+
const getInputString = ({ valuePath }, item) => (0, exports.toInputString)((0, path_1.get)(item, valuePath || ''));
|
|
72
|
+
exports.getInputString = getInputString;
|
|
52
73
|
//# sourceMappingURL=utils-datetime.js.map
|