@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.
Files changed (123) hide show
  1. package/dist/cosmoz-omnitable-column-amount.js +27 -29
  2. package/dist/cosmoz-omnitable-column-autocomplete.js +24 -28
  3. package/dist/cosmoz-omnitable-column-boolean.js +17 -25
  4. package/dist/cosmoz-omnitable-column-date.js +26 -28
  5. package/dist/cosmoz-omnitable-column-datetime.js +26 -28
  6. package/dist/cosmoz-omnitable-column-list-data.js +6 -8
  7. package/dist/cosmoz-omnitable-column-list-horizontal.js +15 -17
  8. package/dist/cosmoz-omnitable-column-list-mixin.js +15 -28
  9. package/dist/cosmoz-omnitable-column-list.js +19 -21
  10. package/dist/cosmoz-omnitable-column-mixin.js +8 -12
  11. package/dist/cosmoz-omnitable-column-number.js +27 -29
  12. package/dist/cosmoz-omnitable-column-time.js +24 -26
  13. package/dist/cosmoz-omnitable-column.js +11 -13
  14. package/dist/cosmoz-omnitable-columns.js +9 -11
  15. package/dist/cosmoz-omnitable-group-row.js +4 -6
  16. package/dist/cosmoz-omnitable-header-row.js +15 -17
  17. package/dist/cosmoz-omnitable-item-expand-line.js +5 -7
  18. package/dist/cosmoz-omnitable-item-expand.js +6 -8
  19. package/dist/cosmoz-omnitable-item-row.js +5 -7
  20. package/dist/cosmoz-omnitable-skeleton.js +6 -8
  21. package/dist/cosmoz-omnitable-styles.js +4 -7
  22. package/dist/cosmoz-omnitable.d.ts +1 -1
  23. package/dist/cosmoz-omnitable.d.ts.map +1 -1
  24. package/dist/cosmoz-omnitable.js +31 -37
  25. package/dist/grouped-list/cosmoz-grouped-list-row.js +2 -4
  26. package/dist/grouped-list/cosmoz-grouped-list.js +4 -6
  27. package/dist/grouped-list/index.js +1 -3
  28. package/dist/grouped-list/use-collapsible-items.d.ts +4 -4
  29. package/dist/grouped-list/use-collapsible-items.js +8 -12
  30. package/dist/grouped-list/use-cosmoz-grouped-list.d.ts +1 -1
  31. package/dist/grouped-list/use-cosmoz-grouped-list.js +19 -23
  32. package/dist/grouped-list/use-selected-items.d.ts +10 -10
  33. package/dist/grouped-list/use-selected-items.js +15 -19
  34. package/dist/grouped-list/use-weak-state.d.ts +3 -3
  35. package/dist/grouped-list/use-weak-state.js +6 -10
  36. package/dist/grouped-list/utils.js +1 -11
  37. package/dist/lib/compute-layout.js +7 -12
  38. package/dist/lib/cosmoz-omnitable-amount-range-input.js +14 -16
  39. package/dist/lib/cosmoz-omnitable-date-input-mixin.js +5 -9
  40. package/dist/lib/cosmoz-omnitable-date-range-input.js +12 -14
  41. package/dist/lib/cosmoz-omnitable-datetime-range-input.js +13 -15
  42. package/dist/lib/cosmoz-omnitable-number-range-input.js +12 -14
  43. package/dist/lib/cosmoz-omnitable-range-input-mixin.js +8 -12
  44. package/dist/lib/cosmoz-omnitable-resize-nub.js +5 -7
  45. package/dist/lib/cosmoz-omnitable-time-range-input.js +12 -14
  46. package/dist/lib/generic-sorter.js +1 -5
  47. package/dist/lib/icons.d.ts +4 -4
  48. package/dist/lib/icons.d.ts.map +1 -1
  49. package/dist/lib/icons.js +5 -8
  50. package/dist/lib/layout.js +2 -5
  51. package/dist/lib/polymer-haunted-render-mixin.js +6 -10
  52. package/dist/lib/render-footer.d.ts +1 -1
  53. package/dist/lib/render-footer.d.ts.map +1 -1
  54. package/dist/lib/render-footer.js +12 -16
  55. package/dist/lib/render-header.d.ts +1 -1
  56. package/dist/lib/render-header.d.ts.map +1 -1
  57. package/dist/lib/render-header.js +5 -9
  58. package/dist/lib/render-list.d.ts +1 -1
  59. package/dist/lib/render-list.d.ts.map +1 -1
  60. package/dist/lib/render-list.js +15 -19
  61. package/dist/lib/save-as-csv-action.js +3 -7
  62. package/dist/lib/save-as-xlsx-action.js +5 -9
  63. package/dist/lib/settings/cosmoz-omnitable-settings.js +33 -71
  64. package/dist/lib/settings/cosmoz-omnitable-sort-group.d.ts +3 -3
  65. package/dist/lib/settings/cosmoz-omnitable-sort-group.d.ts.map +1 -1
  66. package/dist/lib/settings/cosmoz-omnitable-sort-group.js +12 -19
  67. package/dist/lib/settings/drivers/context.d.ts +10 -2
  68. package/dist/lib/settings/drivers/context.d.ts.map +1 -1
  69. package/dist/lib/settings/drivers/context.js +6 -13
  70. package/dist/lib/settings/drivers/index.js +3 -25
  71. package/dist/lib/settings/drivers/local.js +1 -3
  72. package/dist/lib/settings/drivers/remote.js +1 -3
  73. package/dist/lib/settings/index.js +2 -9
  74. package/dist/lib/settings/normalize.js +10 -15
  75. package/dist/lib/settings/style.css.js +5 -8
  76. package/dist/lib/settings/use-saved-settings.d.ts +2 -2
  77. package/dist/lib/settings/use-saved-settings.js +9 -11
  78. package/dist/lib/settings/use-settings-ui.js +12 -14
  79. package/dist/lib/settings/use-settings.d.ts +12 -6
  80. package/dist/lib/settings/use-settings.d.ts.map +1 -1
  81. package/dist/lib/settings/use-settings.js +8 -46
  82. package/dist/lib/types.js +1 -2
  83. package/dist/lib/use-canvas-width.js +5 -9
  84. package/dist/lib/use-dom-columns.d.ts +1 -1
  85. package/dist/lib/use-dom-columns.d.ts.map +1 -1
  86. package/dist/lib/use-dom-columns.js +7 -11
  87. package/dist/lib/use-fast-layout.d.ts +1 -1
  88. package/dist/lib/use-fast-layout.js +18 -22
  89. package/dist/lib/use-footer.js +1 -5
  90. package/dist/lib/use-hash-state.js +11 -15
  91. package/dist/lib/use-header.js +5 -9
  92. package/dist/lib/use-layout.d.ts +1 -1
  93. package/dist/lib/use-layout.d.ts.map +1 -1
  94. package/dist/lib/use-layout.js +4 -8
  95. package/dist/lib/use-list.d.ts +10 -2
  96. package/dist/lib/use-list.d.ts.map +1 -1
  97. package/dist/lib/use-list.js +21 -25
  98. package/dist/lib/use-mini.d.ts +1 -1
  99. package/dist/lib/use-mini.js +5 -9
  100. package/dist/lib/use-omnitable.d.ts +10 -2
  101. package/dist/lib/use-omnitable.d.ts.map +1 -1
  102. package/dist/lib/use-omnitable.js +18 -22
  103. package/dist/lib/use-processed-items.d.ts +5 -3
  104. package/dist/lib/use-processed-items.d.ts.map +1 -1
  105. package/dist/lib/use-processed-items.js +23 -27
  106. package/dist/lib/use-public-interface.js +16 -20
  107. package/dist/lib/use-resizable-columns.js +4 -8
  108. package/dist/lib/use-sort-and-group-options.d.ts +25 -2
  109. package/dist/lib/use-sort-and-group-options.d.ts.map +1 -1
  110. package/dist/lib/use-sort-and-group-options.js +12 -16
  111. package/dist/lib/use-track-size.d.ts +1 -1
  112. package/dist/lib/use-track-size.d.ts.map +1 -1
  113. package/dist/lib/use-track-size.js +2 -6
  114. package/dist/lib/use-tween-array.js +10 -14
  115. package/dist/lib/utils-amount.js +29 -25
  116. package/dist/lib/utils-data.js +8 -12
  117. package/dist/lib/utils-date.js +38 -55
  118. package/dist/lib/utils-datetime.js +22 -32
  119. package/dist/lib/utils-number.js +24 -34
  120. package/dist/lib/utils-time.js +34 -46
  121. package/dist/lib/utils.js +2 -6
  122. package/dist/ui-helpers/cosmoz-clear-button.js +5 -7
  123. package/package.json +1 -1
@@ -1,11 +1,8 @@
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");
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 = (0, pion_1.useMemo)(() => {
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
- (0, pion_1.useEffect)(() => {
27
+ useEffect(() => {
31
28
  animationLoop.start();
32
29
  }, trigger);
33
- (0, pion_1.useEffect)(() => () => animationLoop.stop(), []);
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 = function_1.noop) => {
36
- const state = (0, use_meta_1.useMeta)({ target }),
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 = (0, pion_1.useCallback)(() => {
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) => (0, exports.isCloseEnough)(state.tween[idx], t)
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
@@ -1,9 +1,14 @@
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) => {
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 = (0, utils_number_1.toNumber)(value.amount);
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 = (0, exports.toAmount)(rates, limit);
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 = (0, utils_number_1.toNumber)(valAmount, limAmount, limitFunc);
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 = (0, path_1.get)(item, valuePath);
41
+ value = get(item, valuePath);
37
42
  }
38
- value = (0, exports.toAmount)(rates, value);
43
+ value = toAmount(rates, value);
39
44
  if (value == null) {
40
45
  return;
41
46
  }
42
- const amount = (0, utils_number_1.toNumber)(value.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 = (0, exports.getComparableValue)(column, item);
53
+ const value = getComparableValue(column, item);
49
54
  if (value == null) {
50
55
  return false;
51
56
  }
52
- const min = (0, exports.getComparableValue)({ ...column, valuePath: 'min' }, filter), max = (0, exports.getComparableValue)({ ...column, valuePath: 'max' }, filter);
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 (exports.formatters[key]) {
57
- return exports.formatters[key];
61
+ if (formatters[key]) {
62
+ return formatters[key];
58
63
  }
59
- exports.formatters[key] = new Intl.NumberFormat(locale || undefined, {
64
+ formatters[key] = new Intl.NumberFormat(locale || undefined, {
60
65
  style: 'currency',
61
66
  currency,
62
67
  });
63
- return exports.formatters[key];
68
+ return formatters[key];
64
69
  }, renderValue = (rates, value, locale) => {
65
- const amount = (0, exports.toAmount)(rates, value);
70
+ const amount = toAmount(rates, value);
66
71
  if (amount == null) {
67
72
  return '';
68
73
  }
69
- return (0, exports.getFormatter)(amount.currency, locale).format(amount.amount);
74
+ return getFormatter(amount.currency, locale).format(amount.amount);
70
75
  }, getString = ({ valuePath, rates, locale }, item) => {
71
- const value = (0, exports.toAmount)(rates, (0, path_1.get)(item, valuePath));
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 (0, exports.renderValue)(rates, value, locale);
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) => (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;
98
+ }, getCurrency = ({ valuePath }, item) => get(item, valuePath)?.currency, getInputString = ({ valuePath }, item) => get(item, valuePath)?.amount;
95
99
  //# sourceMappingURL=utils-amount.js.map
@@ -1,26 +1,23 @@
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)
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) => (0, path_1.get)(item, valuePath))
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
- : (0, exports.valuesFrom)(data, valuePath), onItemChange = (host, column, item, value) => {
13
- const { valuePath } = column, oldValue = (0, path_1.get)(item, valuePath);
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
- (0, path_1.set)(item, valuePath, value);
14
+ set(item, valuePath, value);
18
15
  const change = {
19
16
  item,
20
17
  valuePath,
21
18
  value,
22
19
  oldValue,
23
- column: column[use_dom_columns_1.columnSymbol],
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
@@ -1,25 +1,20 @@
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) => {
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
- exports.getTimezoneString = getTimezoneString;
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 + (0, exports.getTimezoneString)(localISOString);
13
+ return localISOString + getTimezoneString(localISOString);
18
14
  }
19
15
  return localISOString;
20
16
  };
21
- exports.getAbsoluteISOString = getAbsoluteISOString;
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 = (0, exports.getAbsoluteISOString)(date);
27
+ date = getAbsoluteISOString(date);
33
28
  }
34
- date = (0, date_1.ensureDate)(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
- exports.parseDate = parseDate;
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 = (0, path_1.get)(item, valuePath);
45
+ value = get(item, valuePath);
52
46
  }
53
- const date = (0, exports.parseDate)(value);
47
+ const date = parseDate(value);
54
48
  if (date == null) {
55
49
  return;
56
50
  }
57
- return (0, utils_number_1.toNumber)(date.getTime());
51
+ return toNumber(date.getTime());
58
52
  };
59
- exports.getComparableValue = getComparableValue;
60
- const toDate = (value, limit, limitFunc) => {
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 = (0, exports.toDate)(limit);
61
+ const lDate = toDate(limit);
69
62
  if (lDate == null) {
70
63
  return date;
71
64
  }
72
- const comparableDate = (0, exports.getComparableValue)({}, date), comparableLDate = (0, exports.getComparableValue)({}, lDate);
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
- exports.toDate = toDate;
80
- const renderValue = (value, formatter) => {
72
+ export const renderValue = (value, formatter) => {
81
73
  if (formatter == null) {
82
74
  return;
83
75
  }
84
- const date = (0, exports.toDate)(value);
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
- exports.getFormatter = getFormatter;
101
- const getString = ({ valuePath, locale }, item) => {
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 = (0, exports.toDate)(value);
96
+ value = toDate(value);
107
97
  if (value === null) {
108
98
  return 'Invalid Date';
109
99
  }
110
- return (0, exports.renderValue)(value, (0, exports.getFormatter)(locale));
100
+ return renderValue(value, getFormatter(locale));
111
101
  };
112
- exports.getString = getString;
113
- const toInputString = (value) => {
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 = (0, date_1.toLocalISOString)(date);
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
- 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);
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
- exports.fromInputString = fromInputString;
141
- const toHashString = (value) => {
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
- exports.toHashString = toHashString;
149
- const toXlsxValue = ({ valuePath }, item) => {
134
+ export const toXlsxValue = ({ valuePath }, item) => {
150
135
  if (!valuePath) {
151
136
  return '';
152
137
  }
153
- const date = (0, exports.toDate)((0, path_1.get)(item, valuePath));
138
+ const date = toDate(get(item, valuePath));
154
139
  if (!date) {
155
140
  return '';
156
141
  }
157
- const localDate = (0, exports.toDate)((0, date_1.toLocalISOString)(date));
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
- exports.toXlsxValue = toXlsxValue;
165
- const applySingleFilter = (column, filter) => (item) => {
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 = (0, exports.getComparableValue)({ ...column, valuePath: 'min' }, filter), max = (0, exports.getComparableValue)({ ...column, valuePath: 'max' }, filter);
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
- "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) => {
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 (exports.formatters[key]) {
11
- return exports.formatters[key];
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
- exports.formatters[key] = new Intl.DateTimeFormat(locale || undefined, timeFormatOption);
21
- return exports.formatters[key];
17
+ formatters[key] = new Intl.DateTimeFormat(locale || undefined, timeFormatOption);
18
+ return formatters[key];
22
19
  };
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
+ 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 (0, utils_date_1.renderValue)(value, (0, exports.getFormatter)(locale));
28
+ return renderValue(value, getFormatter(locale));
33
29
  };
34
- exports.getString = getString;
35
- const toXlsxValue = ({ valuePath }, item) => {
30
+ export const toXlsxValue = ({ valuePath }, item) => {
36
31
  if (!valuePath) {
37
32
  return '';
38
33
  }
39
- return (0, path_1.get)(item, valuePath);
34
+ return get(item, valuePath);
40
35
  };
41
- exports.toXlsxValue = toXlsxValue;
42
- const toHashString = (value) => {
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
- exports.toHashString = toHashString;
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 (0, utils_date_1.toDate)(value.replace(/\./gu, ':') + 'Z');
52
+ return toDate(value.replace(/\./gu, ':') + 'Z');
60
53
  };
61
- exports.fromHashString = fromHashString;
62
- const toInputString = (value) => {
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 = (0, date_1.toLocalISOString)(date);
59
+ const localISOString = toLocalISOString(date);
68
60
  return localISOString ? localISOString.slice(0, 19) : localISOString;
69
61
  };
70
- exports.toInputString = toInputString;
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
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applySingleFilter = exports.getString = exports.makeFormatter = exports.getComparableValue = exports.toHashString = exports.getInputString = exports.toInputString = exports.toNumber = void 0;
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 = (0, exports.toNumber)(limit);
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
- exports.toNumber = toNumber;
24
- const toInputString = (value) => {
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
- exports.toInputString = toInputString;
32
- const getInputString = ({ valuePath }, item) => {
33
- const value = (0, exports.toNumber)(valuePath ? (0, path_1.get)(item, valuePath) : item);
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
- exports.getInputString = getInputString;
37
- const toHashString = (value) => {
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
- exports.toHashString = toHashString;
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 ? (0, path_1.get)(item, valuePath) : item;
50
- const numValue = (0, exports.toNumber)(value);
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 (0, exports.toNumber)(numValue.toFixed(maximumFractionDigits));
48
+ return toNumber(numValue.toFixed(maximumFractionDigits));
56
49
  }
57
50
  return numValue;
58
51
  };
59
- exports.getComparableValue = getComparableValue;
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 ? (0, path_1.get)(item, valuePath) : item;
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 = (0, exports.toNumber)(value);
69
+ const number = toNumber(value);
78
70
  if (number == null) {
79
71
  return;
80
72
  }
81
- const formatter = (0, exports.makeFormatter)(locale, minimumFractionDigits, maximumFractionDigits);
73
+ const formatter = makeFormatter(locale, minimumFractionDigits, maximumFractionDigits);
82
74
  return formatter.format(number);
83
75
  };
84
- exports.getString = getString;
85
- const applySingleFilter = (column, filter) => (item) => {
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 = (0, exports.getComparableValue)({ ...column, valuePath: 'min' }, filter);
91
- const max = (0, exports.getComparableValue)({ ...column, valuePath: 'max' }, filter);
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