@sme.up/ketchup 8.0.0 → 8.0.2
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/cjs/{f-button-49b2c37c.js → f-button-9524bbf7.js} +2 -2
- package/dist/cjs/{f-cell-9a6bc55c.js → f-cell-bcb75ade.js} +22 -13
- package/dist/cjs/{f-checkbox-593f72c3.js → f-checkbox-1148e791.js} +1 -1
- package/dist/cjs/{f-chip-dee84122.js → f-chip-2249b386.js} +3 -3
- package/dist/cjs/{f-image-27f965ff.js → f-image-47d74999.js} +2 -2
- package/dist/cjs/{f-paginator-utils-4a30189d.js → f-paginator-utils-b0a9ae5f.js} +64 -63
- package/dist/cjs/{f-text-field-04a663b4.js → f-text-field-579c0fc0.js} +83 -9
- package/dist/cjs/{index-74433248.js → index-1f177abc.js} +0 -3
- package/dist/cjs/ketchup.cjs.js +2 -2
- package/dist/cjs/kup-accordion.cjs.entry.js +3 -3
- package/dist/cjs/kup-autocomplete_27.cjs.entry.js +798 -815
- package/dist/cjs/kup-box.cjs.entry.js +10 -10
- package/dist/cjs/kup-calendar.cjs.entry.js +5 -5
- package/dist/cjs/kup-cell.cjs.entry.js +7 -7
- package/dist/cjs/kup-dash-list.cjs.entry.js +3 -4
- package/dist/cjs/kup-dash_2.cjs.entry.js +2 -2
- package/dist/cjs/kup-dashboard.cjs.entry.js +6 -6
- package/dist/cjs/kup-drawer.cjs.entry.js +2 -2
- package/dist/cjs/kup-echart.cjs.entry.js +2 -2
- package/dist/cjs/kup-family-tree.cjs.entry.js +4 -4
- package/dist/cjs/kup-iframe.cjs.entry.js +2 -2
- package/dist/cjs/kup-image-list.cjs.entry.js +8 -8
- package/dist/cjs/kup-lazy.cjs.entry.js +2 -2
- package/dist/cjs/kup-magic-box.cjs.entry.js +3 -3
- package/dist/cjs/{kup-manager-2ff5d258.js → kup-manager-85b2a756.js} +758 -538
- package/dist/cjs/kup-nav-bar.cjs.entry.js +2 -2
- package/dist/cjs/kup-numeric-picker.cjs.entry.js +3 -3
- package/dist/cjs/kup-photo-frame.cjs.entry.js +2 -2
- package/dist/cjs/kup-planner.cjs.entry.js +3 -3
- package/dist/cjs/kup-probe.cjs.entry.js +2 -2
- package/dist/cjs/kup-qlik.cjs.entry.js +2 -2
- package/dist/cjs/kup-snackbar.cjs.entry.js +12 -4
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/components/kup-card/built-in/kup-card-calendar.js +5 -61
- package/dist/collection/components/kup-card/built-in/kup-card-clock.js +1 -1
- package/dist/collection/components/kup-dash-list/kup-dash-list.js +1 -3
- package/dist/collection/components/kup-data-table/kup-data-table-helper.js +7 -8
- package/dist/collection/components/kup-data-table/kup-data-table.js +5 -4
- package/dist/collection/components/kup-gauge/kup-gauge.js +4 -4
- package/dist/collection/components/kup-snackbar/kup-snackbar.js +27 -0
- package/dist/collection/components/kup-text-field/kup-text-field-declarations.js +3 -0
- package/dist/collection/components/kup-text-field/kup-text-field.js +107 -9
- package/dist/collection/components/kup-time-picker/kup-time-picker.js +7 -7
- package/dist/collection/components/kup-tree/kup-tree.js +2 -2
- package/dist/collection/f-components/f-cell/f-cell.js +16 -8
- package/dist/collection/f-components/f-paginator/f-paginator-utils.js +3 -3
- package/dist/collection/f-components/f-text-field/f-text-field.js +80 -6
- package/dist/collection/managers/kup-data/kup-data.js +3 -1
- package/dist/collection/managers/kup-dates/kup-dates-declarations.js +21 -10
- package/dist/collection/managers/kup-dates/kup-dates.js +312 -1
- package/dist/collection/managers/kup-math/kup-math.js +258 -6
- package/dist/collection/utils/cell-utils.js +5 -6
- package/dist/collection/utils/filters/filters.js +11 -13
- package/dist/collection/utils/utils.js +18 -444
- package/dist/components/kup-autocomplete2.js +1301 -1002
- package/dist/components/kup-box2.js +1 -1
- package/dist/components/kup-calendar.js +1 -1
- package/dist/components/kup-cell.js +1 -1
- package/dist/components/kup-dash-list.js +2 -3
- package/dist/components/kup-dashboard.js +1 -1
- package/dist/components/kup-data-table.js +1 -1
- package/dist/components/kup-date-picker.js +1 -1
- package/dist/components/kup-dialog.js +1 -1
- package/dist/components/kup-dropdown-button.js +1 -1
- package/dist/components/kup-echart2.js +1 -1
- package/dist/components/kup-family-tree.js +1 -1
- package/dist/components/kup-form.js +1 -1
- package/dist/components/kup-gauge.js +1 -1
- package/dist/components/kup-grid2.js +1 -1
- package/dist/components/kup-iframe.js +1 -1
- package/dist/components/kup-image-list.js +1 -1
- package/dist/components/kup-image.js +1 -1
- package/dist/components/kup-list.js +1 -1
- package/dist/components/kup-magic-box.js +1 -1
- package/dist/components/kup-numeric-picker.js +1 -1
- package/dist/components/kup-planner.js +1 -1
- package/dist/components/kup-progress-bar.js +1 -1
- package/dist/components/kup-radio.js +1 -1
- package/dist/components/kup-rating.js +1 -1
- package/dist/components/kup-snackbar.js +8 -0
- package/dist/components/kup-spinner.js +1 -1
- package/dist/components/kup-switch.js +1 -1
- package/dist/components/kup-tab-bar.js +1 -1
- package/dist/components/kup-text-field.js +1 -1
- package/dist/components/kup-time-picker.js +1 -1
- package/dist/components/kup-tree.js +1 -1
- package/dist/esm/{f-button-744cf1f6.js → f-button-024f0cfe.js} +2 -2
- package/dist/esm/{f-cell-b319c869.js → f-cell-90240a8c.js} +22 -13
- package/dist/esm/{f-checkbox-ec85b437.js → f-checkbox-9b3f5f5b.js} +1 -1
- package/dist/esm/{f-chip-7e3e4180.js → f-chip-2238ad43.js} +3 -3
- package/dist/esm/{f-image-098c26ce.js → f-image-f2e9bf79.js} +2 -2
- package/dist/esm/{f-paginator-utils-674cb2ae.js → f-paginator-utils-8cb3c023.js} +64 -63
- package/dist/esm/{f-text-field-c38ef113.js → f-text-field-d231982c.js} +83 -9
- package/dist/esm/{index-b326ffc9.js → index-8bd38435.js} +1 -3
- package/dist/esm/ketchup.js +3 -3
- package/dist/esm/kup-accordion.entry.js +3 -3
- package/dist/esm/kup-autocomplete_27.entry.js +792 -809
- package/dist/esm/kup-box.entry.js +10 -10
- package/dist/esm/kup-calendar.entry.js +5 -5
- package/dist/esm/kup-cell.entry.js +7 -7
- package/dist/esm/kup-dash-list.entry.js +3 -4
- package/dist/esm/kup-dash_2.entry.js +2 -2
- package/dist/esm/kup-dashboard.entry.js +6 -6
- package/dist/esm/kup-drawer.entry.js +2 -2
- package/dist/esm/kup-echart.entry.js +2 -2
- package/dist/esm/kup-family-tree.entry.js +4 -4
- package/dist/esm/kup-iframe.entry.js +2 -2
- package/dist/esm/kup-image-list.entry.js +8 -8
- package/dist/esm/kup-lazy.entry.js +2 -2
- package/dist/esm/kup-magic-box.entry.js +3 -3
- package/dist/esm/{kup-manager-b41eb2a8.js → kup-manager-d1da769e.js} +758 -529
- package/dist/esm/kup-nav-bar.entry.js +2 -2
- package/dist/esm/kup-numeric-picker.entry.js +3 -3
- package/dist/esm/kup-photo-frame.entry.js +2 -2
- package/dist/esm/kup-planner.entry.js +3 -3
- package/dist/esm/kup-probe.entry.js +2 -2
- package/dist/esm/kup-qlik.entry.js +2 -2
- package/dist/esm/kup-snackbar.entry.js +12 -4
- package/dist/esm/loader.js +3 -3
- package/dist/ketchup/ketchup.esm.js +1 -1
- package/dist/ketchup/{p-5ce2b4fc.entry.js → p-063d4c27.entry.js} +1 -1
- package/dist/ketchup/{p-4325d965.entry.js → p-0bcda0e2.entry.js} +1 -1
- package/dist/ketchup/{p-af82131e.entry.js → p-0d7d59c7.entry.js} +1 -1
- package/dist/ketchup/{p-bd42562d.entry.js → p-163b18b9.entry.js} +1 -1
- package/dist/ketchup/{p-b244f5ca.entry.js → p-1ad628fb.entry.js} +1 -1
- package/dist/ketchup/{p-a9b7533b.entry.js → p-33aff1ca.entry.js} +1 -1
- package/dist/ketchup/p-3432ebaf.entry.js +9 -0
- package/dist/ketchup/{p-b032f47d.entry.js → p-35b29b22.entry.js} +1 -1
- package/dist/ketchup/{p-940a5feb.js → p-36dac88e.js} +3 -3
- package/dist/ketchup/{p-395e1960.entry.js → p-37067ee6.entry.js} +1 -1
- package/dist/ketchup/p-39a55c47.js +1 -0
- package/dist/ketchup/p-3cf64473.js +1 -0
- package/dist/ketchup/{p-5d398e42.js → p-410c102a.js} +1 -1
- package/dist/ketchup/p-43b67de4.entry.js +1 -0
- package/dist/ketchup/{p-a7e19620.entry.js → p-489d55ff.entry.js} +1 -1
- package/dist/ketchup/{p-77e3d537.js → p-5f3680f2.js} +1 -1
- package/dist/ketchup/p-651d89c8.entry.js +1 -0
- package/dist/ketchup/{p-da891093.entry.js → p-73c8d651.entry.js} +1 -1
- package/dist/ketchup/{p-bb17c1ba.entry.js → p-83435e6c.entry.js} +1 -1
- package/dist/ketchup/{p-3b41aca7.entry.js → p-89743989.entry.js} +1 -1
- package/dist/ketchup/{p-ef614656.js → p-8b46e7ce.js} +1 -1
- package/dist/ketchup/{p-d4ece435.js → p-9dcfbb1e.js} +2 -2
- package/dist/ketchup/{p-c26975bf.js → p-9f9b6656.js} +1 -1
- package/dist/ketchup/{p-c968e93d.entry.js → p-a84f1d24.entry.js} +1 -1
- package/dist/ketchup/{p-e02b5141.entry.js → p-b2fd2dbf.entry.js} +1 -1
- package/dist/ketchup/{p-d739710a.entry.js → p-c42b80c1.entry.js} +1 -1
- package/dist/ketchup/p-d1b050d0.entry.js +27 -0
- package/dist/ketchup/p-d6ea709e.entry.js +1 -0
- package/dist/ketchup/{p-0b91f5f8.entry.js → p-e1f1e661.entry.js} +1 -1
- package/dist/ketchup/p-eda7f130.js +1 -0
- package/dist/ketchup/{p-4ae2ca6f.entry.js → p-f876125d.entry.js} +1 -1
- package/dist/types/components/kup-snackbar/kup-snackbar.d.ts +5 -0
- package/dist/types/components/kup-text-field/kup-text-field-declarations.d.ts +3 -0
- package/dist/types/components/kup-text-field/kup-text-field.d.ts +20 -2
- package/dist/types/components.d.ts +34 -0
- package/dist/types/f-components/f-text-field/f-text-field-declarations.d.ts +3 -0
- package/dist/types/managers/kup-dates/kup-dates-declarations.d.ts +19 -9
- package/dist/types/managers/kup-dates/kup-dates.d.ts +94 -1
- package/dist/types/managers/kup-math/kup-math-declarations.d.ts +6 -0
- package/dist/types/managers/kup-math/kup-math.d.ts +88 -3
- package/dist/types/utils/utils.d.ts +13 -103
- package/package.json +1 -1
- package/dist/ketchup/p-0b0b61cb.entry.js +0 -1
- package/dist/ketchup/p-3efe7f43.entry.js +0 -27
- package/dist/ketchup/p-9700eb32.js +0 -1
- package/dist/ketchup/p-a877a87b.entry.js +0 -9
- package/dist/ketchup/p-c8b7790a.entry.js +0 -1
- package/dist/ketchup/p-d98fdb9b.js +0 -1
- package/dist/ketchup/p-df316daf.entry.js +0 -1
- package/dist/ketchup/p-e714f4dc.js +0 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { KupTagNames } from '../../types/GenericTypes';
|
|
2
2
|
import { KupDatesFormats, KupDatesNormalize, } from '../../managers/kup-dates/kup-dates-declarations';
|
|
3
|
-
import { formattedStringToCustomUnformattedStringTime, formattedStringToDefaultUnformattedStringTimestamp, formattedStringToUnformattedStringNumber, isValidFormattedStringNumber, isValidFormattedStringTime, stringToNumber, unformattedStringNumberToNumber, isNumber as isNumberThisString, } from '../utils';
|
|
4
3
|
import { FilterInterval, FILTER_ANALIZER, } from './filters-declarations';
|
|
5
4
|
const dom = document.documentElement;
|
|
6
5
|
/**
|
|
@@ -52,8 +51,8 @@ export class Filters {
|
|
|
52
51
|
: KupDatesFormats.ISO_TIME_WITHOUT_SECONDS)) {
|
|
53
52
|
return newValue;
|
|
54
53
|
}
|
|
55
|
-
if (isValidFormattedStringTime(value, manageSeconds)) {
|
|
56
|
-
return
|
|
54
|
+
if (dom.ketchup.dates.isValidFormattedStringTime(value, manageSeconds)) {
|
|
55
|
+
return dom.ketchup.dates.formattedStringToCustomDateTime(value, manageSeconds
|
|
57
56
|
? KupDatesFormats.ISO_TIME
|
|
58
57
|
: KupDatesFormats.ISO_TIME_WITHOUT_SECONDS, manageSeconds);
|
|
59
58
|
}
|
|
@@ -62,13 +61,13 @@ export class Filters {
|
|
|
62
61
|
if (dom.ketchup.dates.isValid(value, KupDatesFormats.ISO_DATE_TIME)) {
|
|
63
62
|
return newValue;
|
|
64
63
|
}
|
|
65
|
-
if (isValidFormattedStringTime(value, true)) {
|
|
66
|
-
return
|
|
64
|
+
if (dom.ketchup.dates.isValidFormattedStringTime(value, true)) {
|
|
65
|
+
return dom.ketchup.dates.formattedStringToTimestampString(value);
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
else if (dom.ketchup.objects.isNumber(smeupObj)) {
|
|
70
|
-
if (
|
|
71
|
-
return
|
|
69
|
+
if (dom.ketchup.math.isStringNumber(value, smeupObj ? smeupObj.p : '')) {
|
|
70
|
+
return dom.ketchup.math.formattedStringToNumberString(value, smeupObj ? smeupObj.p : '');
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
return newValue;
|
|
@@ -190,12 +189,11 @@ export class Filters {
|
|
|
190
189
|
}
|
|
191
190
|
let checkByRegularExpression = true;
|
|
192
191
|
if (dom.ketchup.objects.isNumber(obj)) {
|
|
193
|
-
|
|
194
|
-
let valueNumber = stringToNumber(value);
|
|
192
|
+
let valueNumber = dom.ketchup.math.numberifySafe(value, obj ? obj.p : '');
|
|
195
193
|
if (from != '') {
|
|
196
|
-
if (
|
|
194
|
+
if (dom.ketchup.math.isNumber(from)) {
|
|
197
195
|
checkByRegularExpression = false;
|
|
198
|
-
let fromNumber =
|
|
196
|
+
let fromNumber = dom.ketchup.math.numberifySafe(from);
|
|
199
197
|
if (valueNumber < fromNumber) {
|
|
200
198
|
return false;
|
|
201
199
|
}
|
|
@@ -205,9 +203,9 @@ export class Filters {
|
|
|
205
203
|
}
|
|
206
204
|
}
|
|
207
205
|
if (to != '') {
|
|
208
|
-
if (
|
|
206
|
+
if (dom.ketchup.math.isNumber(to)) {
|
|
209
207
|
checkByRegularExpression = false;
|
|
210
|
-
let toNumber =
|
|
208
|
+
let toNumber = dom.ketchup.math.numberifySafe(to);
|
|
211
209
|
if (valueNumber > toNumber) {
|
|
212
210
|
return false;
|
|
213
211
|
}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import { KupDatesFormats, KupDatesNormalize, } from '../managers/kup-dates/kup-dates-declarations';
|
|
2
1
|
const dom = document.documentElement;
|
|
3
|
-
export var DateTimeFormatOptionsMonth;
|
|
4
|
-
(function (DateTimeFormatOptionsMonth) {
|
|
5
|
-
DateTimeFormatOptionsMonth["NUMERIC"] = "numeric";
|
|
6
|
-
DateTimeFormatOptionsMonth["DIGIT2"] = "2-digit";
|
|
7
|
-
DateTimeFormatOptionsMonth["LONG"] = "long";
|
|
8
|
-
DateTimeFormatOptionsMonth["SHORT"] = "short";
|
|
9
|
-
DateTimeFormatOptionsMonth["NARROW"] = "narrow";
|
|
10
|
-
})(DateTimeFormatOptionsMonth || (DateTimeFormatOptionsMonth = {}));
|
|
11
2
|
export function identify(array) {
|
|
12
3
|
if (array) {
|
|
13
4
|
for (let i = 0; i < array.length; i++) {
|
|
@@ -15,443 +6,14 @@ export function identify(array) {
|
|
|
15
6
|
}
|
|
16
7
|
}
|
|
17
8
|
}
|
|
18
|
-
function getSeparator(locale, separatorType) {
|
|
19
|
-
const numberWithGroupAndDecimalSeparator = 1000.1;
|
|
20
|
-
return Intl.NumberFormat(locale)
|
|
21
|
-
.formatToParts(numberWithGroupAndDecimalSeparator)
|
|
22
|
-
.find((part) => part.type === separatorType).value;
|
|
23
|
-
}
|
|
24
|
-
export function getCurrentDateFormatFromBrowserLocale() {
|
|
25
|
-
const formatObj = new Intl.DateTimeFormat(dom.ketchup.dates.getLocale()).formatToParts(new Date());
|
|
26
|
-
let dateFormat = formatObj
|
|
27
|
-
.map((obj) => {
|
|
28
|
-
switch (obj.type) {
|
|
29
|
-
case 'day':
|
|
30
|
-
return 'DD';
|
|
31
|
-
case 'month':
|
|
32
|
-
return 'MM';
|
|
33
|
-
case 'year':
|
|
34
|
-
return 'YYYY';
|
|
35
|
-
default:
|
|
36
|
-
return obj.value;
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
.join('');
|
|
40
|
-
return dateFormat;
|
|
41
|
-
}
|
|
42
|
-
function getCurrentTimeFormatFromBrowserLocale(manageSeconds) {
|
|
43
|
-
const options = {
|
|
44
|
-
hour: '2-digit',
|
|
45
|
-
minute: '2-digit',
|
|
46
|
-
hour12: false,
|
|
47
|
-
};
|
|
48
|
-
if (manageSeconds == true) {
|
|
49
|
-
options.second = '2-digit';
|
|
50
|
-
}
|
|
51
|
-
const formatObj = new Intl.DateTimeFormat(dom.ketchup.dates.getLocale() + '-u-hc-h23', options).formatToParts(new Date());
|
|
52
|
-
let timeFormat = formatObj
|
|
53
|
-
.map((obj) => {
|
|
54
|
-
switch (obj.type) {
|
|
55
|
-
case 'hour':
|
|
56
|
-
return 'HH';
|
|
57
|
-
case 'minute':
|
|
58
|
-
return 'mm';
|
|
59
|
-
case 'second':
|
|
60
|
-
return 'ss';
|
|
61
|
-
default:
|
|
62
|
-
return obj.value;
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
.join('');
|
|
66
|
-
return timeFormat;
|
|
67
|
-
}
|
|
68
9
|
/**
|
|
69
|
-
*
|
|
70
|
-
* @param
|
|
71
|
-
* @
|
|
10
|
+
* Fills a string with another string, eventually before
|
|
11
|
+
* @param {string} stringIn initial string
|
|
12
|
+
* @param {string} stringForFill string used for fill
|
|
13
|
+
* @param {number} finalLen final string length
|
|
14
|
+
* @param {boolean} addBefore flag for fill on left
|
|
15
|
+
* @returns the input string filled with stringForFill
|
|
72
16
|
*/
|
|
73
|
-
export function isValidFormattedStringNumber(value, type) {
|
|
74
|
-
if (value == null || value.trim() == '') {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
let tmpStr = formattedStringToUnformattedStringNumber(value, type);
|
|
78
|
-
if (isNumber(tmpStr)) {
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
export function isNumber(value) {
|
|
84
|
-
//return typeof value === 'number';
|
|
85
|
-
return !isNaN(value);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* @param input number as string, formatted by locale US, decimal separator . (like java decimal numbers)
|
|
89
|
-
* @returns number
|
|
90
|
-
**/
|
|
91
|
-
export function stringToNumber(input) {
|
|
92
|
-
if (!input || input == null || input.trim() == '') {
|
|
93
|
-
input = '0';
|
|
94
|
-
}
|
|
95
|
-
return dom.ketchup.math.numberify(input);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* @param input number
|
|
99
|
-
* @param decimals number of significant decimal digits for output
|
|
100
|
-
* @returns number as string, formatted by actual browser locale
|
|
101
|
-
**/
|
|
102
|
-
export function numberToString(input, decimals) {
|
|
103
|
-
if (input == null) {
|
|
104
|
-
return '';
|
|
105
|
-
}
|
|
106
|
-
return _numberToString(input, decimals, dom.ketchup.dates.getLocale(), true);
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* @param type - type of number for calculate suffix
|
|
110
|
-
* @returns suffix for number, by type
|
|
111
|
-
**/
|
|
112
|
-
export function getNumericValueSuffixByType(type) {
|
|
113
|
-
type = type.toUpperCase();
|
|
114
|
-
let nstr = '';
|
|
115
|
-
if (type == 'P') {
|
|
116
|
-
nstr = ' %';
|
|
117
|
-
}
|
|
118
|
-
else if (type == 'VE') {
|
|
119
|
-
nstr = ' €';
|
|
120
|
-
}
|
|
121
|
-
else if (type == 'VL') {
|
|
122
|
-
nstr = ' £';
|
|
123
|
-
}
|
|
124
|
-
else if (type == 'VV') {
|
|
125
|
-
nstr = ' $';
|
|
126
|
-
}
|
|
127
|
-
return nstr;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* @param input number
|
|
131
|
-
* @param decimals number of significant decimal digits for output
|
|
132
|
-
* @param type - type of number for calculate suffix
|
|
133
|
-
* @returns number as string, formatted by actual browser locale, with suffix by type
|
|
134
|
-
**/
|
|
135
|
-
export function numberToFormattedStringNumber(input, decimals, type) {
|
|
136
|
-
if (input == null || isNaN(input)) {
|
|
137
|
-
return '';
|
|
138
|
-
}
|
|
139
|
-
let nstr = numberToString(input, decimals);
|
|
140
|
-
nstr = nstr + getNumericValueSuffixByType(type);
|
|
141
|
-
return nstr;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* @param input number as string, formatted by locale US, decimal separator . (like java decimal numbers)
|
|
145
|
-
* @param decimals number of significant decimal digits for output
|
|
146
|
-
* @param type - type of number for calculate suffix
|
|
147
|
-
* @returns number as string, formatted by actual browser locale, with suffix by type
|
|
148
|
-
**/
|
|
149
|
-
export function unformattedStringToFormattedStringNumber(input, decimals, type) {
|
|
150
|
-
return numberToFormattedStringNumber(stringToNumber(input), decimals, type);
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* @param input number as string, formatted by actual browser locale
|
|
154
|
-
* @param type - type of number for calculate suffix
|
|
155
|
-
* @returns number as string, formatted by locale US, decimal separator . (like java decimal numbers), without group separator
|
|
156
|
-
**/
|
|
157
|
-
export function formattedStringToUnformattedStringNumber(input, type) {
|
|
158
|
-
return numberStringToNumberString(input, type, getDecimalSeparator(dom.ketchup.dates.getLocale()));
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* @param input number as string, formatted by locale US, decimal separator . (like java decimal numbers), with group separator
|
|
162
|
-
* @param type - type of number for calculate suffix
|
|
163
|
-
* @returns number as string, formatted by locale US, decimal separator . (like java decimal numbers), without group separator
|
|
164
|
-
**/
|
|
165
|
-
export function unformattedStringNumberToNumber(input, type) {
|
|
166
|
-
return numberStringToNumberString(input, type, '.');
|
|
167
|
-
}
|
|
168
|
-
function numberStringToNumberString(input, type, decFmt) {
|
|
169
|
-
if (input == null || input.trim() == '') {
|
|
170
|
-
return '';
|
|
171
|
-
}
|
|
172
|
-
let originalInputValue = input;
|
|
173
|
-
let suffix = getNumericValueSuffixByType(type);
|
|
174
|
-
if (suffix != '') {
|
|
175
|
-
input = input.replace(suffix, '');
|
|
176
|
-
}
|
|
177
|
-
let regExpr = null;
|
|
178
|
-
if (decFmt == '.') {
|
|
179
|
-
regExpr = /,/g;
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
regExpr = /\./g;
|
|
183
|
-
}
|
|
184
|
-
input = input.replace(regExpr, '');
|
|
185
|
-
if (decFmt != '.') {
|
|
186
|
-
input = input.replace(/,/g, '.');
|
|
187
|
-
}
|
|
188
|
-
if (dom.ketchup.math.numberify(input) == null ||
|
|
189
|
-
isNaN(dom.ketchup.math.numberify(input))) {
|
|
190
|
-
return originalInputValue;
|
|
191
|
-
}
|
|
192
|
-
let unf = stringToNumber(input);
|
|
193
|
-
return _numberToString(unf, -1, 'en-US', false);
|
|
194
|
-
}
|
|
195
|
-
export function getDecimalSeparator(locale) {
|
|
196
|
-
return getSeparator(locale, 'decimal');
|
|
197
|
-
}
|
|
198
|
-
function countDecimals(value) {
|
|
199
|
-
if (Math.floor(value) === value)
|
|
200
|
-
return 0;
|
|
201
|
-
let stringValue = value.toString().split('.')[1];
|
|
202
|
-
if (stringValue) {
|
|
203
|
-
return stringValue.length ? stringValue.length : 0;
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
return 0;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
export function _numberToString(input, decimals, locale, useGrouping) {
|
|
210
|
-
if (input == null) {
|
|
211
|
-
input = 0;
|
|
212
|
-
}
|
|
213
|
-
if (decimals == null || decimals == -1) {
|
|
214
|
-
decimals = countDecimals(input);
|
|
215
|
-
}
|
|
216
|
-
let n = Number(input);
|
|
217
|
-
let f = decimals > -1
|
|
218
|
-
? {
|
|
219
|
-
minimumFractionDigits: decimals,
|
|
220
|
-
maximumFractionDigits: decimals,
|
|
221
|
-
useGrouping: useGrouping,
|
|
222
|
-
}
|
|
223
|
-
: { useGrouping: useGrouping };
|
|
224
|
-
return n.toLocaleString(locale, f);
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* @param time time as Date object
|
|
228
|
-
* @param manageSeconds flag to set seconds managing
|
|
229
|
-
* @return time as string, formatted
|
|
230
|
-
**/
|
|
231
|
-
export function formatTime(time, manageSeconds) {
|
|
232
|
-
const options = {
|
|
233
|
-
hour: '2-digit',
|
|
234
|
-
minute: '2-digit',
|
|
235
|
-
hour12: false,
|
|
236
|
-
};
|
|
237
|
-
if (manageSeconds == true) {
|
|
238
|
-
options.second = '2-digit';
|
|
239
|
-
}
|
|
240
|
-
return time.toLocaleTimeString(dom.ketchup.dates.getLocale() + '-u-hc-h23', options);
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* @param value time string, formatted by actual browser locale
|
|
244
|
-
* @returns true if time string in input is a valid time
|
|
245
|
-
*/
|
|
246
|
-
export function isValidFormattedStringTime(value, manageSeconds) {
|
|
247
|
-
let format = getCurrentTimeFormatFromBrowserLocale(manageSeconds);
|
|
248
|
-
return dom.ketchup.dates.isValid(value, format, true);
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* @param value time as string, formatted by actual browser locale
|
|
252
|
-
* @returns time as string, formatted ISO
|
|
253
|
-
**/
|
|
254
|
-
export function formattedStringToDefaultUnformattedStringTime(value) {
|
|
255
|
-
return formattedStringToCustomUnformattedStringTime(value, KupDatesFormats.ISO_TIME, true);
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* @param value date/time as string, formatted by actual browser locale
|
|
259
|
-
* @returns date/time as string, formatted ISO
|
|
260
|
-
**/
|
|
261
|
-
export function formattedStringToDefaultUnformattedStringTimestamp(value) {
|
|
262
|
-
return formattedStringToCustomUnformattedStringTime(value, KupDatesFormats.ISO_DATE_TIME, true);
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* @param value time as string, formatted by actual browser locale
|
|
266
|
-
* @param outputFormat time format to return
|
|
267
|
-
* @param manageSeconds flag to set seconds managing
|
|
268
|
-
* @returns time as string, formatted
|
|
269
|
-
**/
|
|
270
|
-
export function formattedStringToCustomUnformattedStringTime(value, outputFormat, manageSeconds) {
|
|
271
|
-
let inputFormat = getCurrentTimeFormatFromBrowserLocale(manageSeconds);
|
|
272
|
-
if (dom.ketchup.dates.isValid(value, inputFormat)) {
|
|
273
|
-
return dom.ketchup.dates.format(dom.ketchup.dates.normalize(value, KupDatesNormalize.TIME), outputFormat);
|
|
274
|
-
}
|
|
275
|
-
else {
|
|
276
|
-
return '';
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* @param value time as string, formatted ISO
|
|
281
|
-
* @param manageSeconds flag to set seconds managing
|
|
282
|
-
* @param valueTimeFormat time format (default ISO)
|
|
283
|
-
* @param customedFormat time format from smeupObject
|
|
284
|
-
* @returns time as string, formatted by actual browser locale
|
|
285
|
-
**/
|
|
286
|
-
export function unformattedStringToFormattedStringTime(value, manageSeconds, customedFormat) {
|
|
287
|
-
const options = {
|
|
288
|
-
hour: '2-digit',
|
|
289
|
-
minute: '2-digit',
|
|
290
|
-
hour12: false,
|
|
291
|
-
};
|
|
292
|
-
if (manageSeconds == true) {
|
|
293
|
-
options.second = '2-digit';
|
|
294
|
-
}
|
|
295
|
-
let date = dom.ketchup.dates.toDate(dom.ketchup.dates.normalize(value, KupDatesNormalize.TIME));
|
|
296
|
-
return formatByCustomedOutputTimeFormat(value, date, options, customedFormat);
|
|
297
|
-
}
|
|
298
|
-
function formatByCustomedOutputTimeFormat(valueStr, date, options, customedFormat) {
|
|
299
|
-
if (customedFormat == null) {
|
|
300
|
-
return date.toLocaleTimeString(dom.ketchup.dates.getLocale() + '-u-hc-h23', options);
|
|
301
|
-
}
|
|
302
|
-
switch (customedFormat) {
|
|
303
|
-
case 'I13': {
|
|
304
|
-
//hh:mm
|
|
305
|
-
break;
|
|
306
|
-
}
|
|
307
|
-
case 'I12': {
|
|
308
|
-
//hh:mm:ss
|
|
309
|
-
break;
|
|
310
|
-
}
|
|
311
|
-
case 'I11': {
|
|
312
|
-
//???
|
|
313
|
-
//hh:dddd
|
|
314
|
-
//return moment(date).format('HH:DDDD');
|
|
315
|
-
return valueStr;
|
|
316
|
-
}
|
|
317
|
-
case 'I14': {
|
|
318
|
-
//???
|
|
319
|
-
//sssss
|
|
320
|
-
//return moment(date).format('SSSSS');
|
|
321
|
-
return valueStr;
|
|
322
|
-
}
|
|
323
|
-
case 'I1H': {
|
|
324
|
-
//???
|
|
325
|
-
//Ora,Cen/Min HH,xx
|
|
326
|
-
return valueStr;
|
|
327
|
-
}
|
|
328
|
-
case 'I1M': {
|
|
329
|
-
//???
|
|
330
|
-
//Min,Cen/Sec MMMM,xx
|
|
331
|
-
return valueStr;
|
|
332
|
-
}
|
|
333
|
-
case 'I21': {
|
|
334
|
-
//???
|
|
335
|
-
//Giorni,(4 decim)
|
|
336
|
-
return valueStr;
|
|
337
|
-
}
|
|
338
|
-
case 'I22': {
|
|
339
|
-
//???
|
|
340
|
-
//Ore,(4 decim)
|
|
341
|
-
return valueStr;
|
|
342
|
-
}
|
|
343
|
-
case 'I23': {
|
|
344
|
-
//???
|
|
345
|
-
//Minuti,(4 decim)
|
|
346
|
-
return valueStr;
|
|
347
|
-
}
|
|
348
|
-
case 'I24': {
|
|
349
|
-
//???
|
|
350
|
-
//Secondi
|
|
351
|
-
return valueStr;
|
|
352
|
-
}
|
|
353
|
-
case 'I2H': {
|
|
354
|
-
//???
|
|
355
|
-
//Ora,Cen/Min HHHH,xx
|
|
356
|
-
return valueStr;
|
|
357
|
-
}
|
|
358
|
-
case 'I2D': {
|
|
359
|
-
//???
|
|
360
|
-
//Ore Minuti Secondi HHMMS
|
|
361
|
-
return valueStr;
|
|
362
|
-
}
|
|
363
|
-
case 'I2M': {
|
|
364
|
-
//???
|
|
365
|
-
//Min,Cen/Sec MMMM,xx
|
|
366
|
-
return valueStr;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
return date.toLocaleTimeString(dom.ketchup.dates.getLocale() + '-u-hc-h23', options);
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* @param value date/time as string, formatted ISO
|
|
373
|
-
* @param valueDateFormat date/time format (default ISO)
|
|
374
|
-
* @returns date/time as string, formatted by actual browser locale
|
|
375
|
-
**/
|
|
376
|
-
export function unformattedStringToFormattedStringTimestamp(value) {
|
|
377
|
-
const options = {
|
|
378
|
-
day: '2-digit',
|
|
379
|
-
month: '2-digit',
|
|
380
|
-
year: 'numeric',
|
|
381
|
-
hour: '2-digit',
|
|
382
|
-
minute: '2-digit',
|
|
383
|
-
second: '2-digit',
|
|
384
|
-
hour12: false,
|
|
385
|
-
};
|
|
386
|
-
let date = dom.ketchup.dates.toDate(dom.ketchup.dates.normalize(value, KupDatesNormalize.TIMESTAMP));
|
|
387
|
-
return date.toLocaleString(dom.ketchup.dates.getLocale() + '-u-hc-h23', options);
|
|
388
|
-
}
|
|
389
|
-
export function getMonthAsStringByLocale(month, format) {
|
|
390
|
-
if (month == null) {
|
|
391
|
-
return '';
|
|
392
|
-
}
|
|
393
|
-
const dateTmp = new Date();
|
|
394
|
-
dateTmp.setDate(1);
|
|
395
|
-
dateTmp.setMonth(month - 1);
|
|
396
|
-
const options = {
|
|
397
|
-
month: format,
|
|
398
|
-
};
|
|
399
|
-
const dateTimeFormat = new Intl.DateTimeFormat(dom.ketchup.dates.getLocale(), options);
|
|
400
|
-
return dateTimeFormat.format(dateTmp);
|
|
401
|
-
}
|
|
402
|
-
export function getMonthsAsStringByLocale(format) {
|
|
403
|
-
if (format == null || format.trim() == '') {
|
|
404
|
-
format = DateTimeFormatOptionsMonth.LONG;
|
|
405
|
-
}
|
|
406
|
-
var months = [];
|
|
407
|
-
for (var i = 0; i < 12; i++) {
|
|
408
|
-
months[i] = getMonthAsStringByLocale(i + 1, format);
|
|
409
|
-
}
|
|
410
|
-
return months;
|
|
411
|
-
}
|
|
412
|
-
export function getDayAsStringByLocale(date) {
|
|
413
|
-
if (date == null) {
|
|
414
|
-
return '';
|
|
415
|
-
}
|
|
416
|
-
const options = {
|
|
417
|
-
weekday: 'narrow',
|
|
418
|
-
/** weekday: 'narrow' 'short' 'long' */
|
|
419
|
-
};
|
|
420
|
-
const dateTimeFormat = new Intl.DateTimeFormat(dom.ketchup.dates.getLocale(), options);
|
|
421
|
-
return dateTimeFormat.format(date);
|
|
422
|
-
}
|
|
423
|
-
function firstDayThisWeek(firstDayIndex) {
|
|
424
|
-
var d = new Date();
|
|
425
|
-
const day = d.getDay();
|
|
426
|
-
// dayIndex0
|
|
427
|
-
d.setDate(d.getDate() - day);
|
|
428
|
-
// dayIndexX
|
|
429
|
-
d.setDate(d.getDate() + firstDayIndex);
|
|
430
|
-
return d;
|
|
431
|
-
}
|
|
432
|
-
const offsetDate = (base, count) => {
|
|
433
|
-
const date = new Date(base);
|
|
434
|
-
date.setDate(base.getDate() + count);
|
|
435
|
-
return date;
|
|
436
|
-
};
|
|
437
|
-
function thisWeek(firstDayIndex) {
|
|
438
|
-
const firstDay = firstDayThisWeek(firstDayIndex);
|
|
439
|
-
return {
|
|
440
|
-
startDate: firstDay,
|
|
441
|
-
endDate: offsetDate(firstDay, 6),
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
export function getDaysOfWeekAsStringByLocale(firstDayIndex) {
|
|
445
|
-
var thisWeekDays = thisWeek(firstDayIndex);
|
|
446
|
-
var monday = thisWeekDays.startDate;
|
|
447
|
-
var days = [];
|
|
448
|
-
for (var i = 0; i < 7; i++) {
|
|
449
|
-
var date = new Date(monday.toISOString());
|
|
450
|
-
date.setDate(date.getDate() + i);
|
|
451
|
-
days[i] = getDayAsStringByLocale(date);
|
|
452
|
-
}
|
|
453
|
-
return days;
|
|
454
|
-
}
|
|
455
17
|
export function fillString(stringIn, stringForFill, finalLen, addBefore) {
|
|
456
18
|
let initSize = stringIn.length;
|
|
457
19
|
let stringOut = '';
|
|
@@ -504,3 +66,15 @@ export function setProps(comp, list, props) {
|
|
|
504
66
|
}
|
|
505
67
|
}
|
|
506
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Creates a regular expression object, from a string un-escaped
|
|
71
|
+
* @param s string to use for create regular expression (not escaped)
|
|
72
|
+
* @param flags flags used for the regular expression
|
|
73
|
+
* @returns the regular expression object
|
|
74
|
+
*/
|
|
75
|
+
export function getRegExpFromString(s, flags) {
|
|
76
|
+
return new RegExp(escapeRegExp(s), flags);
|
|
77
|
+
}
|
|
78
|
+
function escapeRegExp(s) {
|
|
79
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
80
|
+
}
|