@neovici/cosmoz-omnitable 14.14.2 → 14.15.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.d.ts +2 -0
- package/dist/cosmoz-omnitable-column-amount.d.ts.map +1 -0
- package/dist/cosmoz-omnitable-column-amount.js +113 -0
- package/dist/cosmoz-omnitable-column-autocomplete.d.ts +6 -0
- package/dist/cosmoz-omnitable-column-autocomplete.d.ts.map +1 -0
- package/dist/cosmoz-omnitable-column-autocomplete.js +87 -0
- package/dist/cosmoz-omnitable-column-boolean.d.ts +17 -0
- package/dist/cosmoz-omnitable-column-boolean.d.ts.map +1 -0
- package/dist/cosmoz-omnitable-column-boolean.js +105 -0
- package/dist/cosmoz-omnitable-column-date.d.ts +2 -0
- package/dist/cosmoz-omnitable-column-date.d.ts.map +1 -0
- package/dist/cosmoz-omnitable-column-date.js +97 -0
- package/dist/cosmoz-omnitable-column-datetime.d.ts +2 -0
- package/dist/cosmoz-omnitable-column-datetime.d.ts.map +1 -0
- package/dist/cosmoz-omnitable-column-datetime.js +106 -0
- package/dist/cosmoz-omnitable-column-list-data.d.ts +2 -0
- package/dist/cosmoz-omnitable-column-list-data.d.ts.map +1 -0
- package/dist/cosmoz-omnitable-column-list-data.js +123 -0
- package/dist/cosmoz-omnitable-column-list-horizontal.d.ts +2 -0
- package/dist/cosmoz-omnitable-column-list-horizontal.d.ts.map +1 -0
- package/{cosmoz-omnitable-column-list-horizontal.js → dist/cosmoz-omnitable-column-list-horizontal.js} +15 -37
- package/dist/cosmoz-omnitable-column-list-mixin.d.ts +59 -0
- package/dist/cosmoz-omnitable-column-list-mixin.d.ts.map +1 -0
- package/dist/cosmoz-omnitable-column-list-mixin.js +139 -0
- package/dist/cosmoz-omnitable-column-list.d.ts +2 -0
- package/dist/cosmoz-omnitable-column-list.d.ts.map +1 -0
- package/{cosmoz-omnitable-column-list.js → dist/cosmoz-omnitable-column-list.js} +28 -47
- package/dist/cosmoz-omnitable-column-mixin.d.ts +161 -0
- package/dist/cosmoz-omnitable-column-mixin.d.ts.map +1 -0
- package/dist/cosmoz-omnitable-column-mixin.js +121 -0
- package/dist/cosmoz-omnitable-column-number.d.ts +2 -0
- package/dist/cosmoz-omnitable-column-number.d.ts.map +1 -0
- package/dist/cosmoz-omnitable-column-number.js +112 -0
- package/dist/cosmoz-omnitable-column-time.d.ts +2 -0
- package/dist/cosmoz-omnitable-column-time.d.ts.map +1 -0
- package/dist/cosmoz-omnitable-column-time.js +102 -0
- package/dist/cosmoz-omnitable-column.d.ts +2 -0
- package/dist/cosmoz-omnitable-column.d.ts.map +1 -0
- package/dist/cosmoz-omnitable-column.js +75 -0
- package/dist/cosmoz-omnitable-columns.d.ts +2 -0
- package/dist/cosmoz-omnitable-columns.d.ts.map +1 -0
- package/{cosmoz-omnitable-columns.js → dist/cosmoz-omnitable-columns.js} +1 -0
- package/dist/cosmoz-omnitable-group-row.d.ts +2 -0
- package/dist/cosmoz-omnitable-group-row.d.ts.map +1 -0
- package/dist/cosmoz-omnitable-group-row.js +15 -0
- package/dist/cosmoz-omnitable-header-row.d.ts +2 -0
- package/dist/cosmoz-omnitable-header-row.d.ts.map +1 -0
- package/{cosmoz-omnitable-header-row.js → dist/cosmoz-omnitable-header-row.js} +12 -45
- package/dist/cosmoz-omnitable-item-expand-line.d.ts +2 -0
- package/dist/cosmoz-omnitable-item-expand-line.d.ts.map +1 -0
- package/{cosmoz-omnitable-item-expand-line.js → dist/cosmoz-omnitable-item-expand-line.js} +4 -9
- package/dist/cosmoz-omnitable-item-expand.d.ts +2 -0
- package/dist/cosmoz-omnitable-item-expand.d.ts.map +1 -0
- package/{cosmoz-omnitable-item-expand.js → dist/cosmoz-omnitable-item-expand.js} +10 -18
- package/dist/cosmoz-omnitable-item-row.d.ts +2 -0
- package/dist/cosmoz-omnitable-item-row.d.ts.map +1 -0
- package/dist/cosmoz-omnitable-item-row.js +19 -0
- package/dist/cosmoz-omnitable-skeleton.d.ts +2 -0
- package/dist/cosmoz-omnitable-skeleton.d.ts.map +1 -0
- package/{cosmoz-omnitable-skeleton.js → dist/cosmoz-omnitable-skeleton.js} +9 -25
- package/dist/cosmoz-omnitable-styles.d.ts +4 -0
- package/dist/cosmoz-omnitable-styles.d.ts.map +1 -0
- package/{cosmoz-omnitable-styles.js → dist/cosmoz-omnitable-styles.js} +3 -4
- package/dist/cosmoz-omnitable.d.ts +3 -0
- package/dist/cosmoz-omnitable.d.ts.map +1 -0
- package/{cosmoz-omnitable.js → dist/cosmoz-omnitable.js} +27 -40
- package/dist/grouped-list/cosmoz-grouped-list-row.d.ts +2 -0
- package/dist/grouped-list/cosmoz-grouped-list-row.d.ts.map +1 -0
- package/dist/grouped-list/cosmoz-grouped-list-row.js +31 -0
- package/dist/grouped-list/cosmoz-grouped-list.d.ts +2 -0
- package/dist/grouped-list/cosmoz-grouped-list.d.ts.map +1 -0
- package/dist/grouped-list/cosmoz-grouped-list.js +5 -0
- package/dist/grouped-list/index.d.ts +2 -0
- package/dist/grouped-list/index.d.ts.map +1 -0
- package/{grouped-list → dist/grouped-list}/index.js +1 -0
- package/dist/grouped-list/use-collapsible-items.d.ts +7 -0
- package/dist/grouped-list/use-collapsible-items.d.ts.map +1 -0
- package/dist/grouped-list/use-collapsible-items.js +27 -0
- package/dist/grouped-list/use-cosmoz-grouped-list.d.ts +15 -0
- package/dist/grouped-list/use-cosmoz-grouped-list.d.ts.map +1 -0
- package/dist/grouped-list/use-cosmoz-grouped-list.js +66 -0
- package/dist/grouped-list/use-selected-items.d.ts +19 -0
- package/dist/grouped-list/use-selected-items.d.ts.map +1 -0
- package/dist/grouped-list/use-selected-items.js +105 -0
- package/dist/grouped-list/use-weak-state.d.ts +6 -0
- package/dist/grouped-list/use-weak-state.d.ts.map +1 -0
- package/dist/grouped-list/use-weak-state.js +15 -0
- package/dist/grouped-list/utils.d.ts +11 -0
- package/dist/grouped-list/utils.d.ts.map +1 -0
- package/dist/grouped-list/utils.js +57 -0
- package/dist/lib/compute-layout.d.ts +3 -0
- package/dist/lib/compute-layout.d.ts.map +1 -0
- package/dist/lib/compute-layout.js +46 -0
- package/dist/lib/cosmoz-omnitable-amount-range-input.d.ts +2 -0
- package/dist/lib/cosmoz-omnitable-amount-range-input.d.ts.map +1 -0
- package/dist/lib/cosmoz-omnitable-amount-range-input.js +304 -0
- package/dist/lib/cosmoz-omnitable-date-input-mixin.d.ts +2 -0
- package/dist/lib/cosmoz-omnitable-date-input-mixin.d.ts.map +1 -0
- package/dist/lib/cosmoz-omnitable-date-input-mixin.js +149 -0
- package/dist/lib/cosmoz-omnitable-date-range-input.d.ts +2 -0
- package/dist/lib/cosmoz-omnitable-date-range-input.d.ts.map +1 -0
- package/{lib → dist/lib}/cosmoz-omnitable-date-range-input.js +32 -41
- package/dist/lib/cosmoz-omnitable-datetime-range-input.d.ts +2 -0
- package/dist/lib/cosmoz-omnitable-datetime-range-input.d.ts.map +1 -0
- package/{lib → dist/lib}/cosmoz-omnitable-datetime-range-input.js +27 -38
- package/dist/lib/cosmoz-omnitable-number-range-input.d.ts +2 -0
- package/dist/lib/cosmoz-omnitable-number-range-input.d.ts.map +1 -0
- package/{lib → dist/lib}/cosmoz-omnitable-number-range-input.js +73 -83
- package/dist/lib/cosmoz-omnitable-range-input-mixin.d.ts +2 -0
- package/dist/lib/cosmoz-omnitable-range-input-mixin.d.ts.map +1 -0
- package/dist/lib/cosmoz-omnitable-range-input-mixin.js +337 -0
- package/dist/lib/cosmoz-omnitable-resize-nub.d.ts +2 -0
- package/dist/lib/cosmoz-omnitable-resize-nub.d.ts.map +1 -0
- package/dist/lib/cosmoz-omnitable-resize-nub.js +33 -0
- package/dist/lib/cosmoz-omnitable-time-range-input.d.ts +2 -0
- package/dist/lib/cosmoz-omnitable-time-range-input.d.ts.map +1 -0
- package/dist/lib/cosmoz-omnitable-time-range-input.js +125 -0
- package/dist/lib/generic-sorter.d.ts +2 -0
- package/dist/lib/generic-sorter.d.ts.map +1 -0
- package/dist/lib/generic-sorter.js +29 -0
- package/dist/lib/icons.d.ts +5 -0
- package/dist/lib/icons.d.ts.map +1 -0
- package/{lib → dist/lib}/icons.js +5 -8
- package/dist/lib/layout.d.ts +2 -0
- package/dist/lib/layout.d.ts.map +1 -0
- package/dist/lib/layout.js +41 -0
- package/dist/lib/polymer-haunted-render-mixin.d.ts +10 -0
- package/dist/lib/polymer-haunted-render-mixin.d.ts.map +1 -0
- package/dist/lib/polymer-haunted-render-mixin.js +16 -0
- package/dist/lib/render-footer.d.ts +9 -0
- package/dist/lib/render-footer.d.ts.map +1 -0
- package/{lib → dist/lib}/render-footer.js +4 -17
- package/dist/lib/render-header.d.ts +14 -0
- package/dist/lib/render-header.d.ts.map +1 -0
- package/{lib → dist/lib}/render-header.js +6 -27
- package/dist/lib/render-list.d.ts +2 -0
- package/dist/lib/render-list.d.ts.map +1 -0
- package/{lib → dist/lib}/render-list.js +12 -45
- package/dist/lib/save-as-csv-action.d.ts +2 -0
- package/dist/lib/save-as-csv-action.d.ts.map +1 -0
- package/dist/lib/save-as-csv-action.js +26 -0
- package/dist/lib/save-as-xlsx-action.d.ts +3 -0
- package/dist/lib/save-as-xlsx-action.d.ts.map +1 -0
- package/dist/lib/save-as-xlsx-action.js +18 -0
- package/dist/lib/settings/cosmoz-omnitable-settings.d.ts +2 -0
- package/dist/lib/settings/cosmoz-omnitable-settings.d.ts.map +1 -0
- package/{lib → dist/lib}/settings/cosmoz-omnitable-settings.js +27 -69
- package/dist/lib/settings/cosmoz-omnitable-sort-group.d.ts +14 -0
- package/dist/lib/settings/cosmoz-omnitable-sort-group.d.ts.map +1 -0
- package/dist/lib/settings/cosmoz-omnitable-sort-group.js +55 -0
- package/dist/lib/settings/drivers/context.d.ts +12 -0
- package/dist/lib/settings/drivers/context.d.ts.map +1 -0
- package/dist/lib/settings/drivers/context.js +11 -0
- package/dist/lib/settings/drivers/index.d.ts +4 -0
- package/dist/lib/settings/drivers/index.d.ts.map +1 -0
- package/{lib → dist/lib}/settings/drivers/index.js +1 -0
- package/dist/lib/settings/drivers/local.d.ts +8 -0
- package/dist/lib/settings/drivers/local.d.ts.map +1 -0
- package/dist/lib/settings/drivers/local.js +33 -0
- package/dist/lib/settings/drivers/remote.d.ts +8 -0
- package/dist/lib/settings/drivers/remote.d.ts.map +1 -0
- package/dist/lib/settings/drivers/remote.js +25 -0
- package/dist/lib/settings/index.d.ts +2 -0
- package/dist/lib/settings/index.d.ts.map +1 -0
- package/{lib → dist/lib}/settings/index.js +1 -1
- package/dist/lib/settings/normalize.d.ts +11 -0
- package/dist/lib/settings/normalize.d.ts.map +1 -0
- package/dist/lib/settings/normalize.js +47 -0
- package/dist/lib/settings/style.css.d.ts +4 -0
- package/dist/lib/settings/style.css.d.ts.map +1 -0
- package/{lib → dist/lib}/settings/style.css.js +3 -4
- package/dist/lib/settings/use-saved-settings.d.ts +9 -0
- package/dist/lib/settings/use-saved-settings.d.ts.map +1 -0
- package/dist/lib/settings/use-saved-settings.js +35 -0
- package/dist/lib/settings/use-settings-ui.d.ts +3 -0
- package/dist/lib/settings/use-settings-ui.d.ts.map +1 -0
- package/dist/lib/settings/use-settings-ui.js +78 -0
- package/dist/lib/settings/use-settings.d.ts +23 -0
- package/dist/lib/settings/use-settings.d.ts.map +1 -0
- package/dist/lib/settings/use-settings.js +26 -0
- package/dist/lib/use-canvas-width.d.ts +2 -0
- package/dist/lib/use-canvas-width.d.ts.map +1 -0
- package/dist/lib/use-canvas-width.js +8 -0
- package/dist/lib/use-dom-columns.d.ts +5 -0
- package/dist/lib/use-dom-columns.d.ts.map +1 -0
- package/dist/lib/use-dom-columns.js +127 -0
- package/dist/lib/use-fast-layout.d.ts +13 -0
- package/dist/lib/use-fast-layout.d.ts.map +1 -0
- package/dist/lib/use-fast-layout.js +47 -0
- package/dist/lib/use-footer.d.ts +10 -0
- package/dist/lib/use-footer.d.ts.map +1 -0
- package/dist/lib/use-footer.js +11 -0
- package/dist/lib/use-hash-state.d.ts +4 -0
- package/dist/lib/use-hash-state.d.ts.map +1 -0
- package/dist/lib/use-hash-state.js +32 -0
- package/dist/lib/use-header.d.ts +21 -0
- package/dist/lib/use-header.d.ts.map +1 -0
- package/dist/lib/use-header.js +38 -0
- package/dist/lib/use-layout.d.ts +7 -0
- package/dist/lib/use-layout.d.ts.map +1 -0
- package/dist/lib/use-layout.js +21 -0
- package/dist/lib/use-list.d.ts +31 -0
- package/dist/lib/use-list.d.ts.map +1 -0
- package/dist/lib/use-list.js +198 -0
- package/dist/lib/use-mini.d.ts +10 -0
- package/dist/lib/use-mini.d.ts.map +1 -0
- package/dist/lib/use-mini.js +19 -0
- package/dist/lib/use-omnitable.d.ts +37 -0
- package/dist/lib/use-omnitable.d.ts.map +1 -0
- package/dist/lib/use-omnitable.js +74 -0
- package/dist/lib/use-processed-items.d.ts +17 -0
- package/dist/lib/use-processed-items.d.ts.map +1 -0
- package/dist/lib/use-processed-items.js +151 -0
- package/dist/lib/use-public-interface.d.ts +7 -0
- package/dist/lib/use-public-interface.d.ts.map +1 -0
- package/dist/lib/use-public-interface.js +82 -0
- package/dist/lib/use-resizable-columns.d.ts +7 -0
- package/dist/lib/use-resizable-columns.d.ts.map +1 -0
- package/dist/lib/use-resizable-columns.js +38 -0
- package/dist/lib/use-sort-and-group-options.d.ts +26 -0
- package/dist/lib/use-sort-and-group-options.d.ts.map +1 -0
- package/dist/lib/use-sort-and-group-options.js +36 -0
- package/dist/lib/use-track-size.d.ts +2 -0
- package/dist/lib/use-track-size.d.ts.map +1 -0
- package/dist/lib/use-track-size.js +15 -0
- package/dist/lib/use-tween-array.d.ts +3 -0
- package/dist/lib/use-tween-array.d.ts.map +1 -0
- package/dist/lib/use-tween-array.js +50 -0
- package/dist/lib/utils-amount.d.ts +26 -0
- package/dist/lib/utils-amount.d.ts.map +1 -0
- package/dist/lib/utils-amount.js +99 -0
- package/dist/lib/utils-data.d.ts +8 -0
- package/dist/lib/utils-data.d.ts.map +1 -0
- package/dist/lib/utils-data.js +28 -0
- package/dist/lib/utils-date.d.ts +25 -0
- package/dist/lib/utils-date.d.ts.map +1 -0
- package/dist/lib/utils-date.js +161 -0
- package/dist/lib/utils-datetime.d.ts +16 -0
- package/dist/lib/utils-datetime.d.ts.map +1 -0
- package/dist/lib/utils-datetime.js +52 -0
- package/dist/lib/utils-number.d.ts +19 -0
- package/dist/lib/utils-number.d.ts.map +1 -0
- package/dist/lib/utils-number.js +87 -0
- package/dist/lib/utils-time.d.ts +17 -0
- package/dist/lib/utils-time.d.ts.map +1 -0
- package/dist/lib/utils-time.js +88 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +14 -0
- package/dist/ui-helpers/cosmoz-clear-button.d.ts +2 -0
- package/dist/ui-helpers/cosmoz-clear-button.d.ts.map +1 -0
- package/{ui-helpers → dist/ui-helpers}/cosmoz-clear-button.js +3 -5
- package/package.json +39 -9
- package/cosmoz-omnitable-column-amount.js +0 -162
- package/cosmoz-omnitable-column-autocomplete.js +0 -113
- package/cosmoz-omnitable-column-boolean.js +0 -168
- package/cosmoz-omnitable-column-date.js +0 -133
- package/cosmoz-omnitable-column-datetime.js +0 -145
- package/cosmoz-omnitable-column-list-data.js +0 -141
- package/cosmoz-omnitable-column-list-mixin.js +0 -198
- package/cosmoz-omnitable-column-mixin.js +0 -149
- package/cosmoz-omnitable-column-number.js +0 -157
- package/cosmoz-omnitable-column-time.js +0 -137
- package/cosmoz-omnitable-column.js +0 -99
- package/cosmoz-omnitable-group-row.js +0 -20
- package/cosmoz-omnitable-item-row.js +0 -38
- package/grouped-list/cosmoz-grouped-list-row.js +0 -41
- package/grouped-list/cosmoz-grouped-list.js +0 -13
- package/grouped-list/use-collapsible-items.js +0 -32
- package/grouped-list/use-cosmoz-grouped-list.js +0 -102
- package/grouped-list/use-selected-items.js +0 -140
- package/grouped-list/use-weak-state.js +0 -21
- package/grouped-list/utils.js +0 -89
- package/lib/compute-layout.js +0 -74
- package/lib/cosmoz-omnitable-amount-range-input.js +0 -353
- package/lib/cosmoz-omnitable-date-input-mixin.js +0 -182
- package/lib/cosmoz-omnitable-range-input-mixin.js +0 -451
- package/lib/cosmoz-omnitable-resize-nub.js +0 -41
- package/lib/cosmoz-omnitable-time-range-input.js +0 -154
- package/lib/generic-sorter.js +0 -35
- package/lib/layout.js +0 -61
- package/lib/polymer-haunted-render-mixin.js +0 -19
- package/lib/save-as-csv-action.js +0 -36
- package/lib/save-as-xlsx-action.js +0 -27
- package/lib/settings/cosmoz-omnitable-sort-group.js +0 -74
- package/lib/settings/drivers/context.js +0 -16
- package/lib/settings/drivers/local.js +0 -29
- package/lib/settings/drivers/remote.js +0 -22
- package/lib/settings/normalize.js +0 -76
- package/lib/settings/use-saved-settings.js +0 -43
- package/lib/settings/use-settings-ui.js +0 -125
- package/lib/settings/use-settings.js +0 -53
- package/lib/use-canvas-width.js +0 -12
- package/lib/use-dom-columns.js +0 -166
- package/lib/use-fast-layout.js +0 -73
- package/lib/use-footer.js +0 -16
- package/lib/use-hash-state.js +0 -71
- package/lib/use-header.js +0 -71
- package/lib/use-layout.js +0 -32
- package/lib/use-list.js +0 -263
- package/lib/use-mini.js +0 -30
- package/lib/use-omnitable.js +0 -99
- package/lib/use-processed-items.js +0 -254
- package/lib/use-public-interface.js +0 -107
- package/lib/use-resizable-columns.js +0 -63
- package/lib/use-sort-and-group-options.js +0 -95
- package/lib/use-track-size.js +0 -23
- package/lib/use-tween-array.js +0 -60
- package/lib/utils-amount.js +0 -131
- package/lib/utils-data.js +0 -42
- package/lib/utils-date.js +0 -194
- package/lib/utils-datetime.js +0 -66
- package/lib/utils-number.js +0 -111
- package/lib/utils-time.js +0 -112
- package/lib/utils.js +0 -17
|
@@ -0,0 +1,99 @@
|
|
|
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) => {
|
|
12
|
+
if (value == null || value === '') {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (typeof value !== 'object' ||
|
|
16
|
+
value.currency == null ||
|
|
17
|
+
value.currency === '') {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const number = toNumber(value.amount);
|
|
21
|
+
if (number == null || Number.isNaN(number)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const amount = { currency: value.currency, amount: number };
|
|
25
|
+
if (limitFunc == null || limit == null) {
|
|
26
|
+
return amount;
|
|
27
|
+
}
|
|
28
|
+
const lAmount = toAmount(rates, limit);
|
|
29
|
+
if (lAmount == null) {
|
|
30
|
+
return amount;
|
|
31
|
+
}
|
|
32
|
+
// 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);
|
|
34
|
+
return lNumber === valAmount ? amount : lAmount;
|
|
35
|
+
}, getComparableValue = ({ valuePath, rates }, item) => {
|
|
36
|
+
if (item == null) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
let value = item;
|
|
40
|
+
if (valuePath != null) {
|
|
41
|
+
value = get(item, valuePath);
|
|
42
|
+
}
|
|
43
|
+
value = toAmount(rates, value);
|
|
44
|
+
if (value == null) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const amount = toNumber(value.amount);
|
|
48
|
+
if (rates == null) {
|
|
49
|
+
return amount;
|
|
50
|
+
}
|
|
51
|
+
return amount * (rates[value.currency] || 1);
|
|
52
|
+
}, applySingleFilter = (column, filter) => (item) => {
|
|
53
|
+
const value = getComparableValue(column, item);
|
|
54
|
+
if (value == null) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
const min = getComparableValue({ ...column, valuePath: 'min' }, filter), max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
58
|
+
return !(value < min || value > max);
|
|
59
|
+
}, formatters = {}, getFormatter = (currency, locale) => {
|
|
60
|
+
const id = locale ? locale : '', key = currency + id || '';
|
|
61
|
+
if (formatters[key]) {
|
|
62
|
+
return formatters[key];
|
|
63
|
+
}
|
|
64
|
+
formatters[key] = new Intl.NumberFormat(locale || undefined, {
|
|
65
|
+
style: 'currency',
|
|
66
|
+
currency,
|
|
67
|
+
});
|
|
68
|
+
return formatters[key];
|
|
69
|
+
}, renderValue = (rates, value, locale) => {
|
|
70
|
+
const amount = toAmount(rates, value);
|
|
71
|
+
if (amount == null) {
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
74
|
+
return getFormatter(amount.currency, locale).format(amount.amount);
|
|
75
|
+
}, getString = ({ valuePath, rates, locale }, item) => {
|
|
76
|
+
const value = toAmount(rates, get(item, valuePath));
|
|
77
|
+
if (value === undefined) {
|
|
78
|
+
return '';
|
|
79
|
+
}
|
|
80
|
+
if (value === null) {
|
|
81
|
+
return 'Invalid value';
|
|
82
|
+
}
|
|
83
|
+
return renderValue(rates, value, locale);
|
|
84
|
+
}, toHashString = (value) => {
|
|
85
|
+
if (!value) {
|
|
86
|
+
return '';
|
|
87
|
+
}
|
|
88
|
+
return value.amount + value.currency;
|
|
89
|
+
}, fromHashString = (value) => {
|
|
90
|
+
if (value == null || value === '') {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const params = value.match(/^(-?[\d]+)([\D]+?)$/iu);
|
|
94
|
+
if (!Array.isArray(params) || params.length < 0) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return { amount: params[1], currency: params[2] };
|
|
98
|
+
}, getCurrency = ({ valuePath }, item) => get(item, valuePath)?.currency, getInputString = ({ valuePath }, item) => get(item, valuePath)?.amount;
|
|
99
|
+
//# sourceMappingURL=utils-amount.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function valuesFrom(data: any, valuePath: any): any[] | undefined;
|
|
2
|
+
export function defaultComputeSource({ externalValues, values, valuePath }: {
|
|
3
|
+
externalValues: any;
|
|
4
|
+
values: any;
|
|
5
|
+
valuePath: any;
|
|
6
|
+
}, data: any): any;
|
|
7
|
+
export function onItemChange(host: any, column: any, item: any, value: any): void;
|
|
8
|
+
//# sourceMappingURL=utils-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-data.d.ts","sourceRoot":"","sources":["../../src/lib/utils-data.js"],"names":[],"mappings":"AAGO,yEAsCL;AAtCK;;;;mBAsCL;AAtCK,kFAsCL"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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)
|
|
4
|
+
? data
|
|
5
|
+
.map((item) => get(item, valuePath))
|
|
6
|
+
.filter((value, index, self) => value != null && self.indexOf(value) === index)
|
|
7
|
+
: undefined, defaultComputeSource = ({ externalValues, values, valuePath }, data) => externalValues || typeof values === 'function'
|
|
8
|
+
? values
|
|
9
|
+
: valuesFrom(data, valuePath), onItemChange = (host, column, item, value) => {
|
|
10
|
+
const { valuePath } = column, oldValue = get(item, valuePath);
|
|
11
|
+
if (value === oldValue) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
set(item, valuePath, value);
|
|
15
|
+
const change = {
|
|
16
|
+
item,
|
|
17
|
+
valuePath,
|
|
18
|
+
value,
|
|
19
|
+
oldValue,
|
|
20
|
+
column: column[columnSymbol],
|
|
21
|
+
};
|
|
22
|
+
host.dispatchEvent(new CustomEvent('column-item-changed', {
|
|
23
|
+
bubbles: true,
|
|
24
|
+
composed: true,
|
|
25
|
+
detail: change,
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=utils-data.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function getTimezoneString(localISOString: any): string;
|
|
2
|
+
export function getAbsoluteISOString(localISOString: any): any;
|
|
3
|
+
export function parseDate(value: any): any;
|
|
4
|
+
export function getComparableValue({ valuePath }: {
|
|
5
|
+
valuePath: any;
|
|
6
|
+
}, item: any): any;
|
|
7
|
+
export function toDate(value: any, limit: any, limitFunc: any): any;
|
|
8
|
+
export function renderValue(value: any, formatter: any): any;
|
|
9
|
+
export const formatters: {};
|
|
10
|
+
export function getFormatter(locale: any): any;
|
|
11
|
+
export function getString({ valuePath, locale }: {
|
|
12
|
+
valuePath: any;
|
|
13
|
+
locale: any;
|
|
14
|
+
}, item: any): any;
|
|
15
|
+
export function toInputString(value: any): any;
|
|
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;
|
|
25
|
+
//# sourceMappingURL=utils-date.d.ts.map
|
|
@@ -0,0 +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;;mBA6LL;AA7LK,oEA6LL;AA7LK,6DA6LL;AA7ED,4BAAe;AAhHT,+CA6LL;AA7LK;;;mBA6LL;AA7LK,+CA6LL;AA7LK;;mBA6LL;AA7LK,gEA6LL;AA7LK,8CA6LL;AA7LK;;mBA6LL;AA7LK,8DAkLmC,SAAI,aAW5C"}
|
|
@@ -0,0 +1,161 @@
|
|
|
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 /**
|
|
5
|
+
* Calculates the local timezone offset and formats it to ISO Timezone string.
|
|
6
|
+
* @param {String} localISOString an ISO date string
|
|
7
|
+
* @return {String} the ISO timezone
|
|
8
|
+
*/ getTimezoneString = (localISOString) => {
|
|
9
|
+
const off = -new Date(localISOString).getTimezoneOffset() / 60;
|
|
10
|
+
return ((off < 0 ? '-' : '+') + ['0', Math.abs(off)].join('').substr(-2) + ':00');
|
|
11
|
+
},
|
|
12
|
+
/**
|
|
13
|
+
* Computes the local timezone and adds it to a local ISO string
|
|
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) => {
|
|
18
|
+
// Most browsers use local timezone when no timezone is specified
|
|
19
|
+
// but Safari uses UTC, so we set it implicitly
|
|
20
|
+
// TODO: Consider removing this when/if Safari handles local timezone correctly
|
|
21
|
+
if (localISOString.length === 19) {
|
|
22
|
+
return localISOString + getTimezoneString(localISOString);
|
|
23
|
+
}
|
|
24
|
+
return localISOString;
|
|
25
|
+
}, parseDate = (value) => {
|
|
26
|
+
if (value == null || value === '') {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
// convert value to Date
|
|
30
|
+
let date = value;
|
|
31
|
+
if (!(date instanceof Date)) {
|
|
32
|
+
// if the value is an ISO string, make sure that it has an explicit timezone
|
|
33
|
+
if (typeof value === 'string') {
|
|
34
|
+
date = getAbsoluteISOString(date);
|
|
35
|
+
}
|
|
36
|
+
date = ensureDate(date);
|
|
37
|
+
if (!date) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (Number.isNaN(date.getTime())) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return date;
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* Get comparable number from date
|
|
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) => {
|
|
54
|
+
if (item == null) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
let value = item;
|
|
58
|
+
if (valuePath != null) {
|
|
59
|
+
value = get(item, valuePath);
|
|
60
|
+
}
|
|
61
|
+
value = parseDate(value);
|
|
62
|
+
if (value == null) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
return toNumber(value.getTime());
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* Converts an value to date optionaly limiting it.
|
|
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);
|
|
77
|
+
if (date == null) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
if (limitFunc == null || limit == null) {
|
|
81
|
+
return date;
|
|
82
|
+
}
|
|
83
|
+
const lDate = toDate(limit);
|
|
84
|
+
if (lDate == null) {
|
|
85
|
+
return date;
|
|
86
|
+
}
|
|
87
|
+
const comparableDate = getComparableValue({}, date), comparableLDate = getComparableValue({}, lDate), limitedValue = limitFunc(comparableDate, comparableLDate);
|
|
88
|
+
return limitedValue === comparableDate ? date : lDate;
|
|
89
|
+
}, renderValue = (value, formatter) => {
|
|
90
|
+
if (formatter == null) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const date = toDate(value);
|
|
94
|
+
if (date == null) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
return formatter.format(date);
|
|
98
|
+
}, formatters = {}, getFormatter = (locale) => {
|
|
99
|
+
const key = locale || '';
|
|
100
|
+
if (formatters[key]) {
|
|
101
|
+
return formatters[key];
|
|
102
|
+
}
|
|
103
|
+
formatters[key] = new Intl.DateTimeFormat(locale || undefined);
|
|
104
|
+
return formatters[key];
|
|
105
|
+
}, getString = ({ valuePath, locale }, item) => {
|
|
106
|
+
let value = get(item, valuePath);
|
|
107
|
+
if (value === undefined) {
|
|
108
|
+
return '';
|
|
109
|
+
}
|
|
110
|
+
value = toDate(value);
|
|
111
|
+
if (value === null) {
|
|
112
|
+
return 'Invalid Date';
|
|
113
|
+
}
|
|
114
|
+
return renderValue(value, getFormatter(locale));
|
|
115
|
+
}, toInputString = (value) => {
|
|
116
|
+
const date = toDate(value);
|
|
117
|
+
if (date == null) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
return toLocalISOString(date).slice(0, 10);
|
|
121
|
+
}, getInputString = ({ valuePath }, item) => toInputString(get(item, valuePath)), fromInputString = (value, property) => {
|
|
122
|
+
const date = toDate(value);
|
|
123
|
+
if (date == null) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (property === 'min') {
|
|
127
|
+
date.setHours(0, 0, 0, 0);
|
|
128
|
+
}
|
|
129
|
+
if (property === 'max') {
|
|
130
|
+
date.setHours(23, 59, 59);
|
|
131
|
+
}
|
|
132
|
+
return date;
|
|
133
|
+
}, toHashString = (value) => {
|
|
134
|
+
const string = toInputString(value);
|
|
135
|
+
if (string == null) {
|
|
136
|
+
return '';
|
|
137
|
+
}
|
|
138
|
+
return string;
|
|
139
|
+
}, toXlsxValue = ({ valuePath }, item) => {
|
|
140
|
+
if (!valuePath) {
|
|
141
|
+
return '';
|
|
142
|
+
}
|
|
143
|
+
const date = toDate(get(item, valuePath));
|
|
144
|
+
if (!date) {
|
|
145
|
+
return '';
|
|
146
|
+
}
|
|
147
|
+
const localDate = toDate(toLocalISOString(date));
|
|
148
|
+
if (!localDate) {
|
|
149
|
+
return '';
|
|
150
|
+
}
|
|
151
|
+
localDate.setHours(0, 0, 0, 0);
|
|
152
|
+
return localDate;
|
|
153
|
+
}, applySingleFilter = (column, filter) => (item) => {
|
|
154
|
+
const value = getComparableValue(column, item);
|
|
155
|
+
if (value == null) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
const min = getComparableValue({ ...column, valuePath: 'min' }, filter), max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
159
|
+
return !(value < min || value > max);
|
|
160
|
+
};
|
|
161
|
+
//# sourceMappingURL=utils-date.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const formatters: {};
|
|
2
|
+
export function getFormatter(locale: any): any;
|
|
3
|
+
export function getString({ valuePath, locale }: {
|
|
4
|
+
valuePath: any;
|
|
5
|
+
locale: any;
|
|
6
|
+
}, item: any): any;
|
|
7
|
+
export function toXlsxValue({ valuePath }: {
|
|
8
|
+
valuePath: any;
|
|
9
|
+
}, item: any): any;
|
|
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;
|
|
16
|
+
//# sourceMappingURL=utils-datetime.d.ts.map
|
|
@@ -0,0 +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,+CA6DuE;AA7DvE;;mBA6DuE"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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 = {}, getFormatter = (locale) => {
|
|
5
|
+
const key = locale || '';
|
|
6
|
+
if (formatters[key]) {
|
|
7
|
+
return formatters[key];
|
|
8
|
+
}
|
|
9
|
+
const timeFormatOption = {
|
|
10
|
+
year: 'numeric',
|
|
11
|
+
month: 'numeric',
|
|
12
|
+
day: 'numeric',
|
|
13
|
+
hour: 'numeric',
|
|
14
|
+
minute: 'numeric',
|
|
15
|
+
};
|
|
16
|
+
formatters[key] = new Intl.DateTimeFormat(locale || undefined, timeFormatOption);
|
|
17
|
+
return formatters[key];
|
|
18
|
+
}, getString = ({ valuePath, locale }, item) => {
|
|
19
|
+
const value = toDate(get(item, valuePath));
|
|
20
|
+
if (value === undefined) {
|
|
21
|
+
return '';
|
|
22
|
+
}
|
|
23
|
+
if (value === null) {
|
|
24
|
+
return 'Invalid Date';
|
|
25
|
+
}
|
|
26
|
+
return renderValue(value, getFormatter(locale));
|
|
27
|
+
}, toXlsxValue = ({ valuePath }, item) => {
|
|
28
|
+
if (!valuePath) {
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
return get(item, valuePath);
|
|
32
|
+
}, toHashString = (value) => {
|
|
33
|
+
const date = toDate(value);
|
|
34
|
+
if (date == null) {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
//Use utc in hash
|
|
38
|
+
return date.toISOString().slice(0, 19).replace(/:/gu, '.');
|
|
39
|
+
}, fromHashString = (value) => {
|
|
40
|
+
if (value == null || value === '') {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
//Parse utc from hash string
|
|
44
|
+
return toDate(value.replace(/\./gu, ':') + 'Z');
|
|
45
|
+
}, toInputString = (value) => {
|
|
46
|
+
const date = toDate(value);
|
|
47
|
+
if (date == null) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return toLocalISOString(date).slice(0, 19);
|
|
51
|
+
}, getInputString = ({ valuePath }, item) => toInputString(get(item, valuePath));
|
|
52
|
+
//# sourceMappingURL=utils-datetime.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function toNumber(value: any, limit: any, limitFunc: any): any;
|
|
2
|
+
export function toInputString(value: any): any;
|
|
3
|
+
export function getInputString({ valuePath }: {
|
|
4
|
+
valuePath: any;
|
|
5
|
+
}, item: any): any;
|
|
6
|
+
export function toHashString(value: any): any;
|
|
7
|
+
export function getComparableValue({ valuePath, maximumFractionDigits }: {
|
|
8
|
+
valuePath: any;
|
|
9
|
+
maximumFractionDigits: any;
|
|
10
|
+
}, item: any): any;
|
|
11
|
+
export const makeFormatter: any;
|
|
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;
|
|
19
|
+
//# sourceMappingURL=utils-number.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-number.d.ts","sourceRoot":"","sources":["../../src/lib/utils-number.js"],"names":[],"mappings":"AAGO,sEA2GL;AA3GK,+CA2GL;AA3GK;;mBA2GL;AA3GK,8CA2GL;AA3GK;;;mBA2GL;AA9CD,gCAaC;AA1EK;;;;;mBA2GL;AA3GK,8DAgGmC,SAAI,aAW5C"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { get } from '@polymer/polymer/lib/utils/path';
|
|
2
|
+
import { memoooize } from '@neovici/cosmoz-utils/memoize';
|
|
3
|
+
export const /**
|
|
4
|
+
* Converts a value to number optionaly limiting it.
|
|
5
|
+
*
|
|
6
|
+
* @param {Number|*} value The value to convert to number
|
|
7
|
+
* @param {Number|*} limit The value used to limit the number
|
|
8
|
+
* @param {Function} limitFunc The function used to limit the number (Math.min|Math.max)
|
|
9
|
+
* @returns {Number|void} Value converted to Number or void
|
|
10
|
+
*/ toNumber = (value, limit, limitFunc) => {
|
|
11
|
+
if (value == null || value === '') {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const number = typeof value === 'number' ? value : Number(value);
|
|
15
|
+
if (Number.isNaN(number)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (limitFunc == null || limit == null) {
|
|
19
|
+
return number;
|
|
20
|
+
}
|
|
21
|
+
const lNumber = toNumber(limit);
|
|
22
|
+
if (lNumber == null) {
|
|
23
|
+
return number;
|
|
24
|
+
}
|
|
25
|
+
return limitFunc(number, lNumber);
|
|
26
|
+
}, toInputString = (value) => {
|
|
27
|
+
const val = toNumber(value);
|
|
28
|
+
if (val == null) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return val.toString();
|
|
32
|
+
}, getInputString = ({ valuePath }, item) => {
|
|
33
|
+
const value = toNumber(get(item, valuePath));
|
|
34
|
+
return toInputString(value);
|
|
35
|
+
}, toHashString = (value) => {
|
|
36
|
+
const string = toInputString(value);
|
|
37
|
+
if (string == null) {
|
|
38
|
+
return '';
|
|
39
|
+
}
|
|
40
|
+
return string;
|
|
41
|
+
}, getComparableValue = ({ valuePath, maximumFractionDigits }, item) => {
|
|
42
|
+
if (item == null) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
let value = item;
|
|
46
|
+
if (valuePath != null) {
|
|
47
|
+
value = get(item, valuePath);
|
|
48
|
+
}
|
|
49
|
+
value = toNumber(value);
|
|
50
|
+
if (value == null) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (maximumFractionDigits !== null) {
|
|
54
|
+
return toNumber(value.toFixed(maximumFractionDigits));
|
|
55
|
+
}
|
|
56
|
+
return value;
|
|
57
|
+
}, makeFormatter = memoooize((locale, minimumFractionDigits, maximumFractionDigits) => {
|
|
58
|
+
const options = {
|
|
59
|
+
localeMatcher: 'best fit', // chrome expects this when using custom options
|
|
60
|
+
};
|
|
61
|
+
if (minimumFractionDigits !== null) {
|
|
62
|
+
options.minimumFractionDigits = minimumFractionDigits;
|
|
63
|
+
}
|
|
64
|
+
if (maximumFractionDigits !== null) {
|
|
65
|
+
options.maximumFractionDigits = maximumFractionDigits;
|
|
66
|
+
}
|
|
67
|
+
return new Intl.NumberFormat(locale || undefined, options);
|
|
68
|
+
}), getString = ({ valuePath, locale, minimumFractionDigits, maximumFractionDigits }, item) => {
|
|
69
|
+
const value = get(item, valuePath);
|
|
70
|
+
if (value == null) {
|
|
71
|
+
return '';
|
|
72
|
+
}
|
|
73
|
+
const number = toNumber(value);
|
|
74
|
+
if (number == null) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const formatter = makeFormatter(locale, minimumFractionDigits, maximumFractionDigits);
|
|
78
|
+
return formatter.format(number);
|
|
79
|
+
}, applySingleFilter = (column, filter) => (item) => {
|
|
80
|
+
const value = getComparableValue(column, item);
|
|
81
|
+
if (value == null) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
const min = getComparableValue({ ...column, valuePath: 'min' }, filter), max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
85
|
+
return !(value < min || value > max);
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=utils-number.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const _fixedDate: "1970-01-01";
|
|
2
|
+
export function toDate(value: any, limit: any, limitFunc: any): any;
|
|
3
|
+
export const formatters: {};
|
|
4
|
+
export function getFormatter(locale: any): any;
|
|
5
|
+
export function getString({ valuePath, locale }: {
|
|
6
|
+
valuePath: any;
|
|
7
|
+
locale: any;
|
|
8
|
+
}, item: any): any;
|
|
9
|
+
export function toXlsxValue(column: any, item: any): any;
|
|
10
|
+
export function toInputString(value: any): any;
|
|
11
|
+
export function getComparableValue({ valuePath }: {
|
|
12
|
+
valuePath: any;
|
|
13
|
+
}, item: any): any;
|
|
14
|
+
export function applySingleFilter(column: any, filter: any): (item: any) => boolean;
|
|
15
|
+
export function toHashString(value: any): any;
|
|
16
|
+
export function fromHashString(value: any): any;
|
|
17
|
+
//# sourceMappingURL=utils-time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-time.d.ts","sourceRoot":"","sources":["../../src/lib/utils-time.js"],"names":[],"mappings":"AASa,yBAAa,YAAY,CAAA;AAA/B,oEAsGL;AAnFD,4BAAe;AAnBT,+CAsGL;AAtGK;;;mBAsGL;AAtGK,yDAsGL;AAtGK,+CAsGL;AAtGK;;mBAsGL;AAtGK,8DA4EmC,SAAI,aA0B5C;AAtGK,8CAsGL;AAtGK,gDAsGL"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { toLocalISOString } from '@neovici/cosmoz-utils/date';
|
|
2
|
+
import { get } from '@polymer/polymer/lib/utils/path';
|
|
3
|
+
import { getAbsoluteISOString, renderValue, toDate as superToDate, } from './utils-date';
|
|
4
|
+
import { toNumber } from './utils-number';
|
|
5
|
+
export const _fixedDate = '1970-01-01',
|
|
6
|
+
/**
|
|
7
|
+
* Converts time to date optionaly limiting it.
|
|
8
|
+
*
|
|
9
|
+
* @param {Date|Number} value Date or Timestamp ( miliseconds since property _fixedDate ) to be converted
|
|
10
|
+
* @param {Date|Number} limit Optional value to limit the date.
|
|
11
|
+
* @param {Function} limitFunc Function used to limit the date (Math.min|Math.max)
|
|
12
|
+
* @returns {Date|void} Value converted to date optionaly limitated
|
|
13
|
+
*/
|
|
14
|
+
toDate = (value, limit, limitFunc) => {
|
|
15
|
+
// Most browsers use local timezone when no timezone is specified
|
|
16
|
+
// but Safari uses UTC, so we set it implicitly
|
|
17
|
+
// TODO: Consider removing this when/if Safari handles local timezone correctly
|
|
18
|
+
const date = typeof value === 'string' && value.length > 3 && value.length <= 9
|
|
19
|
+
? getAbsoluteISOString(_fixedDate + 'T' + value)
|
|
20
|
+
: value;
|
|
21
|
+
return superToDate(date, limit, limitFunc);
|
|
22
|
+
}, formatters = {}, getFormatter = (locale) => {
|
|
23
|
+
const key = locale || '';
|
|
24
|
+
if (formatters[key]) {
|
|
25
|
+
return formatters[key];
|
|
26
|
+
}
|
|
27
|
+
const timeFormatOption = {
|
|
28
|
+
hour: 'numeric',
|
|
29
|
+
minute: 'numeric',
|
|
30
|
+
second: 'numeric',
|
|
31
|
+
};
|
|
32
|
+
formatters[key] = new Intl.DateTimeFormat(locale || undefined, timeFormatOption);
|
|
33
|
+
return formatters[key];
|
|
34
|
+
}, getString = ({ valuePath, locale }, item) => {
|
|
35
|
+
const value = toDate(get(item, valuePath));
|
|
36
|
+
if (value === undefined) {
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
if (value === null) {
|
|
40
|
+
return 'Invalid Date';
|
|
41
|
+
}
|
|
42
|
+
return renderValue(value, getFormatter(locale));
|
|
43
|
+
}, toXlsxValue = (column, item) => {
|
|
44
|
+
if (!column.valuePath) {
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
return getString(column, item);
|
|
48
|
+
}, toInputString = (value) => {
|
|
49
|
+
const date = toDate(value);
|
|
50
|
+
if (date == null) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return toLocalISOString(date).slice(11, 19);
|
|
54
|
+
}, getComparableValue = ({ valuePath }, item) => {
|
|
55
|
+
if (item == null) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
let value = toInputString(valuePath == null ? item : get(item, valuePath));
|
|
59
|
+
if (value == null) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
value = toDate(getAbsoluteISOString(_fixedDate + 'T' + value));
|
|
63
|
+
if (value == null) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
return toNumber(value.getTime());
|
|
67
|
+
}, applySingleFilter = (column, filter) => (item) => {
|
|
68
|
+
const value = getComparableValue(column, item);
|
|
69
|
+
if (value == null) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const min = getComparableValue({ ...column, valuePath: 'min' }, filter), max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
73
|
+
return !(value < min || value > max);
|
|
74
|
+
}, toHashString = (value) => {
|
|
75
|
+
const date = toDate(value);
|
|
76
|
+
if (date == null) {
|
|
77
|
+
return '';
|
|
78
|
+
}
|
|
79
|
+
//Use utc in hash
|
|
80
|
+
return date.toISOString().slice(11, 19).replace(/:/gu, '.');
|
|
81
|
+
}, fromHashString = (value) => {
|
|
82
|
+
if (value == null || value === '') {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
//Parse utc from hash string
|
|
86
|
+
return toDate(value.replace(/\./gu, ':') + 'Z');
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=utils-time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.js"],"names":[],"mappings":"AAIO,+DAYN;AAhBD,wCAAoC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const indexSymbol = Symbol('index');
|
|
2
|
+
export { indexSymbol };
|
|
3
|
+
export const findLastIndex = (array, predicate) => {
|
|
4
|
+
if (Array.prototype.findLastIndex) {
|
|
5
|
+
return array.findLastIndex(predicate);
|
|
6
|
+
}
|
|
7
|
+
for (let i = array.length - 1; i >= 0; i--) {
|
|
8
|
+
if (predicate(array[i], i, array)) {
|
|
9
|
+
return i;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return -1;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cosmoz-clear-button.d.ts","sourceRoot":"","sources":["../../src/ui-helpers/cosmoz-clear-button.js"],"names":[],"mappings":""}
|