@sme.up/ketchup 8.0.1 → 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.
Files changed (132) hide show
  1. package/dist/cjs/{f-button-c0ede055.js → f-button-9524bbf7.js} +1 -1
  2. package/dist/cjs/{f-cell-1c17dbac.js → f-cell-bcb75ade.js} +10 -8
  3. package/dist/cjs/{f-chip-bace36bb.js → f-chip-2249b386.js} +2 -2
  4. package/dist/cjs/{f-image-22174590.js → f-image-47d74999.js} +1 -1
  5. package/dist/cjs/{f-paginator-utils-e21e1f06.js → f-paginator-utils-b0a9ae5f.js} +63 -62
  6. package/dist/cjs/{f-text-field-503f2bb0.js → f-text-field-579c0fc0.js} +1 -1
  7. package/dist/cjs/kup-accordion.cjs.entry.js +2 -2
  8. package/dist/cjs/kup-autocomplete_27.cjs.entry.js +32 -87
  9. package/dist/cjs/kup-box.cjs.entry.js +7 -7
  10. package/dist/cjs/kup-calendar.cjs.entry.js +4 -4
  11. package/dist/cjs/kup-cell.cjs.entry.js +5 -5
  12. package/dist/cjs/kup-dash-list.cjs.entry.js +1 -1
  13. package/dist/cjs/kup-dash_2.cjs.entry.js +1 -1
  14. package/dist/cjs/kup-dashboard.cjs.entry.js +4 -4
  15. package/dist/cjs/kup-drawer.cjs.entry.js +1 -1
  16. package/dist/cjs/kup-echart.cjs.entry.js +1 -1
  17. package/dist/cjs/kup-family-tree.cjs.entry.js +3 -3
  18. package/dist/cjs/kup-iframe.cjs.entry.js +1 -1
  19. package/dist/cjs/kup-image-list.cjs.entry.js +6 -6
  20. package/dist/cjs/kup-lazy.cjs.entry.js +1 -1
  21. package/dist/cjs/kup-magic-box.cjs.entry.js +2 -2
  22. package/dist/cjs/{kup-manager-b994cf71.js → kup-manager-85b2a756.js} +679 -531
  23. package/dist/cjs/kup-nav-bar.cjs.entry.js +1 -1
  24. package/dist/cjs/kup-numeric-picker.cjs.entry.js +2 -2
  25. package/dist/cjs/kup-photo-frame.cjs.entry.js +1 -1
  26. package/dist/cjs/kup-planner.cjs.entry.js +2 -2
  27. package/dist/cjs/kup-probe.cjs.entry.js +1 -1
  28. package/dist/cjs/kup-qlik.cjs.entry.js +1 -1
  29. package/dist/cjs/kup-snackbar.cjs.entry.js +3 -3
  30. package/dist/collection/assets/data-table.js +0 -44
  31. package/dist/collection/components/kup-card/built-in/kup-card-calendar.js +5 -61
  32. package/dist/collection/components/kup-card/built-in/kup-card-clock.js +1 -1
  33. package/dist/collection/components/kup-data-table/kup-data-table-helper.js +7 -8
  34. package/dist/collection/components/kup-data-table/kup-data-table-state.js +1 -1
  35. package/dist/collection/components/kup-data-table/kup-data-table.js +5 -4
  36. package/dist/collection/components/kup-gauge/kup-gauge.js +4 -4
  37. package/dist/collection/components/kup-text-field/kup-text-field.js +4 -5
  38. package/dist/collection/components/kup-time-picker/kup-time-picker.js +7 -7
  39. package/dist/collection/components/kup-tree/kup-tree.js +2 -2
  40. package/dist/collection/f-components/f-cell/f-cell.js +6 -5
  41. package/dist/collection/f-components/f-paginator/f-paginator-utils.js +3 -3
  42. package/dist/collection/managers/kup-data/kup-data.js +3 -1
  43. package/dist/collection/managers/kup-dates/kup-dates-declarations.js +21 -10
  44. package/dist/collection/managers/kup-dates/kup-dates.js +312 -1
  45. package/dist/collection/managers/kup-math/kup-math.js +180 -9
  46. package/dist/collection/utils/cell-utils.js +5 -6
  47. package/dist/collection/utils/filters/filters.js +11 -13
  48. package/dist/collection/utils/utils.js +18 -435
  49. package/dist/components/kup-autocomplete2.js +915 -810
  50. package/dist/components/kup-box2.js +1 -1
  51. package/dist/components/kup-calendar.js +1 -1
  52. package/dist/components/kup-cell.js +1 -1
  53. package/dist/components/kup-dashboard.js +1 -1
  54. package/dist/components/kup-echart2.js +1 -1
  55. package/dist/components/kup-family-tree.js +1 -1
  56. package/dist/components/kup-grid2.js +1 -1
  57. package/dist/components/kup-iframe.js +1 -1
  58. package/dist/components/kup-image-list.js +1 -1
  59. package/dist/components/kup-magic-box.js +1 -1
  60. package/dist/components/kup-numeric-picker.js +1 -1
  61. package/dist/components/kup-planner.js +1 -1
  62. package/dist/esm/{f-button-c377973d.js → f-button-024f0cfe.js} +1 -1
  63. package/dist/esm/{f-cell-e5a98bc8.js → f-cell-90240a8c.js} +10 -8
  64. package/dist/esm/{f-chip-c8a18c48.js → f-chip-2238ad43.js} +2 -2
  65. package/dist/esm/{f-image-5cbdf39d.js → f-image-f2e9bf79.js} +1 -1
  66. package/dist/esm/{f-paginator-utils-a1dab059.js → f-paginator-utils-8cb3c023.js} +63 -62
  67. package/dist/esm/{f-text-field-dafb7c8b.js → f-text-field-d231982c.js} +1 -1
  68. package/dist/esm/kup-accordion.entry.js +2 -2
  69. package/dist/esm/kup-autocomplete_27.entry.js +26 -81
  70. package/dist/esm/kup-box.entry.js +7 -7
  71. package/dist/esm/kup-calendar.entry.js +4 -4
  72. package/dist/esm/kup-cell.entry.js +5 -5
  73. package/dist/esm/kup-dash-list.entry.js +1 -1
  74. package/dist/esm/kup-dash_2.entry.js +1 -1
  75. package/dist/esm/kup-dashboard.entry.js +4 -4
  76. package/dist/esm/kup-drawer.entry.js +1 -1
  77. package/dist/esm/kup-echart.entry.js +1 -1
  78. package/dist/esm/kup-family-tree.entry.js +3 -3
  79. package/dist/esm/kup-iframe.entry.js +1 -1
  80. package/dist/esm/kup-image-list.entry.js +6 -6
  81. package/dist/esm/kup-lazy.entry.js +1 -1
  82. package/dist/esm/kup-magic-box.entry.js +2 -2
  83. package/dist/esm/{kup-manager-3594cde8.js → kup-manager-d1da769e.js} +679 -522
  84. package/dist/esm/kup-nav-bar.entry.js +1 -1
  85. package/dist/esm/kup-numeric-picker.entry.js +2 -2
  86. package/dist/esm/kup-photo-frame.entry.js +1 -1
  87. package/dist/esm/kup-planner.entry.js +2 -2
  88. package/dist/esm/kup-probe.entry.js +1 -1
  89. package/dist/esm/kup-qlik.entry.js +1 -1
  90. package/dist/esm/kup-snackbar.entry.js +3 -3
  91. package/dist/ketchup/ketchup.esm.js +1 -1
  92. package/dist/ketchup/{p-31abf4b6.entry.js → p-063d4c27.entry.js} +1 -1
  93. package/dist/ketchup/{p-9fc6a9a8.entry.js → p-0bcda0e2.entry.js} +1 -1
  94. package/dist/ketchup/{p-473d2bea.entry.js → p-0d7d59c7.entry.js} +1 -1
  95. package/dist/ketchup/{p-b718af72.entry.js → p-163b18b9.entry.js} +1 -1
  96. package/dist/ketchup/{p-37ada0f0.entry.js → p-1ad628fb.entry.js} +1 -1
  97. package/dist/ketchup/{p-5205286a.entry.js → p-33aff1ca.entry.js} +1 -1
  98. package/dist/ketchup/p-3432ebaf.entry.js +9 -0
  99. package/dist/ketchup/{p-80815edf.entry.js → p-35b29b22.entry.js} +1 -1
  100. package/dist/ketchup/{p-acaa171f.js → p-36dac88e.js} +3 -3
  101. package/dist/ketchup/{p-22e72f06.entry.js → p-37067ee6.entry.js} +1 -1
  102. package/dist/ketchup/p-39a55c47.js +1 -0
  103. package/dist/ketchup/{p-8b248655.js → p-3cf64473.js} +1 -1
  104. package/dist/ketchup/p-410c102a.js +1 -0
  105. package/dist/ketchup/{p-d76be079.entry.js → p-43b67de4.entry.js} +1 -1
  106. package/dist/ketchup/{p-ef0b4f19.entry.js → p-489d55ff.entry.js} +1 -1
  107. package/dist/ketchup/{p-2d32e3cd.js → p-5f3680f2.js} +1 -1
  108. package/dist/ketchup/{p-cf322853.entry.js → p-651d89c8.entry.js} +1 -1
  109. package/dist/ketchup/{p-4c56e199.entry.js → p-73c8d651.entry.js} +1 -1
  110. package/dist/ketchup/{p-d1164680.entry.js → p-83435e6c.entry.js} +1 -1
  111. package/dist/ketchup/{p-7f4f5f0f.entry.js → p-89743989.entry.js} +1 -1
  112. package/dist/ketchup/{p-6762d447.js → p-8b46e7ce.js} +1 -1
  113. package/dist/ketchup/p-a84f1d24.entry.js +1 -0
  114. package/dist/ketchup/{p-ed7e118e.entry.js → p-b2fd2dbf.entry.js} +1 -1
  115. package/dist/ketchup/{p-ce5b6ce7.entry.js → p-c42b80c1.entry.js} +1 -1
  116. package/dist/ketchup/p-d1b050d0.entry.js +27 -0
  117. package/dist/ketchup/{p-d4eb9a76.entry.js → p-d6ea709e.entry.js} +1 -1
  118. package/dist/ketchup/{p-7be5ef32.entry.js → p-e1f1e661.entry.js} +1 -1
  119. package/dist/ketchup/p-eda7f130.js +1 -0
  120. package/dist/ketchup/{p-afff7a6e.entry.js → p-f876125d.entry.js} +1 -1
  121. package/dist/types/components/kup-data-table/kup-data-table-state.d.ts +1 -1
  122. package/dist/types/managers/kup-dates/kup-dates-declarations.d.ts +19 -9
  123. package/dist/types/managers/kup-dates/kup-dates.d.ts +94 -1
  124. package/dist/types/managers/kup-math/kup-math.d.ts +68 -7
  125. package/dist/types/utils/utils.d.ts +13 -102
  126. package/package.json +1 -1
  127. package/dist/ketchup/p-017418e7.entry.js +0 -27
  128. package/dist/ketchup/p-38f16697.entry.js +0 -9
  129. package/dist/ketchup/p-4638fbff.js +0 -1
  130. package/dist/ketchup/p-61319cfa.js +0 -1
  131. package/dist/ketchup/p-6c726886.entry.js +0 -1
  132. package/dist/ketchup/p-bf4a881b.js +0 -1
@@ -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,434 +6,14 @@ export function identify(array) {
15
6
  }
16
7
  }
17
8
  }
18
- export function getCurrentDateFormatFromBrowserLocale() {
19
- const formatObj = new Intl.DateTimeFormat(dom.ketchup.dates.getLocale()).formatToParts(new Date());
20
- let dateFormat = formatObj
21
- .map((obj) => {
22
- switch (obj.type) {
23
- case 'day':
24
- return 'DD';
25
- case 'month':
26
- return 'MM';
27
- case 'year':
28
- return 'YYYY';
29
- default:
30
- return obj.value;
31
- }
32
- })
33
- .join('');
34
- return dateFormat;
35
- }
36
- function getCurrentTimeFormatFromBrowserLocale(manageSeconds) {
37
- const options = {
38
- hour: '2-digit',
39
- minute: '2-digit',
40
- hour12: false,
41
- };
42
- if (manageSeconds == true) {
43
- options.second = '2-digit';
44
- }
45
- const formatObj = new Intl.DateTimeFormat(dom.ketchup.dates.getLocale() + '-u-hc-h23', options).formatToParts(new Date());
46
- let timeFormat = formatObj
47
- .map((obj) => {
48
- switch (obj.type) {
49
- case 'hour':
50
- return 'HH';
51
- case 'minute':
52
- return 'mm';
53
- case 'second':
54
- return 'ss';
55
- default:
56
- return obj.value;
57
- }
58
- })
59
- .join('');
60
- return timeFormat;
61
- }
62
9
  /**
63
- * @param value number as string, formatted by actual browser locale
64
- * @param type - type of number for calculate suffix
65
- * @returns true if number string in input is a valid number
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
66
16
  */
67
- export function isValidFormattedStringNumber(value, type) {
68
- if (value == null || value.trim() == '') {
69
- return false;
70
- }
71
- let tmpStr = formattedStringToUnformattedStringNumber(value, type);
72
- if (isNumber(tmpStr)) {
73
- return true;
74
- }
75
- return false;
76
- }
77
- export function isNumber(value) {
78
- //return typeof value === 'number';
79
- return !isNaN(value);
80
- }
81
- /**
82
- * @param input number as string, formatted by locale US, decimal separator . (like java decimal numbers)
83
- * @returns number
84
- **/
85
- export function stringToNumber(input) {
86
- if (!input || input == null || input.trim() == '') {
87
- input = '0';
88
- }
89
- return dom.ketchup.math.numberify(input);
90
- }
91
- /**
92
- * @param input number
93
- * @param decimals number of significant decimal digits for output
94
- * @returns number as string, formatted by actual browser locale
95
- **/
96
- export function numberToString(input, decimals) {
97
- if (input == null) {
98
- return '';
99
- }
100
- return _numberToString(input, decimals, dom.ketchup.dates.getLocale(), true);
101
- }
102
- /**
103
- * @param type - type of number for calculate suffix
104
- * @returns suffix for number, by type
105
- **/
106
- export function getNumericValueSuffixByType(type) {
107
- type = type.toUpperCase();
108
- let nstr = '';
109
- if (type == 'P') {
110
- nstr = ' %';
111
- }
112
- else if (type == 'VE') {
113
- nstr = ' €';
114
- }
115
- else if (type == 'VL') {
116
- nstr = ' £';
117
- }
118
- else if (type == 'VV') {
119
- nstr = ' $';
120
- }
121
- return nstr;
122
- }
123
- /**
124
- * @param input number
125
- * @param decimals number of significant decimal digits for output
126
- * @param type - type of number for calculate suffix
127
- * @returns number as string, formatted by actual browser locale, with suffix by type
128
- **/
129
- export function numberToFormattedStringNumber(input, decimals, type) {
130
- if (input == null || isNaN(input)) {
131
- return '';
132
- }
133
- let nstr = numberToString(input, decimals);
134
- nstr = nstr + getNumericValueSuffixByType(type);
135
- return nstr;
136
- }
137
- /**
138
- * @param input number as string, formatted by locale US, decimal separator . (like java decimal numbers)
139
- * @param decimals number of significant decimal digits for output
140
- * @param type - type of number for calculate suffix
141
- * @returns number as string, formatted by actual browser locale, with suffix by type
142
- **/
143
- export function unformattedStringToFormattedStringNumber(input, decimals, type) {
144
- return numberToFormattedStringNumber(stringToNumber(input), decimals, type);
145
- }
146
- /**
147
- * @param input number as string, formatted by actual browser locale
148
- * @param type - type of number for calculate suffix
149
- * @returns number as string, formatted by locale US, decimal separator . (like java decimal numbers), without group separator
150
- **/
151
- export function formattedStringToUnformattedStringNumber(input, type) {
152
- return numberStringToNumberString(input, type, dom.ketchup.math.decimalSeparator());
153
- }
154
- /**
155
- * @param input number as string, formatted by locale US, decimal separator . (like java decimal numbers), with group separator
156
- * @param type - type of number for calculate suffix
157
- * @returns number as string, formatted by locale US, decimal separator . (like java decimal numbers), without group separator
158
- **/
159
- export function unformattedStringNumberToNumber(input, type) {
160
- return numberStringToNumberString(input, type, '.');
161
- }
162
- function numberStringToNumberString(input, type, decFmt) {
163
- if (input == null || input.trim() == '') {
164
- return '';
165
- }
166
- let originalInputValue = input;
167
- let suffix = getNumericValueSuffixByType(type);
168
- if (suffix != '') {
169
- input = input.replace(suffix, '');
170
- }
171
- let regExpr = null;
172
- if (decFmt == '.') {
173
- regExpr = /,/g;
174
- }
175
- else {
176
- regExpr = /\./g;
177
- }
178
- input = input.replace(regExpr, '');
179
- if (decFmt != '.') {
180
- input = input.replace(/,/g, '.');
181
- }
182
- if (dom.ketchup.math.numberify(input) == null ||
183
- isNaN(dom.ketchup.math.numberify(input))) {
184
- return originalInputValue;
185
- }
186
- let unf = stringToNumber(input);
187
- return _numberToString(unf, -1, 'en-US', false);
188
- }
189
- function countDecimals(value) {
190
- if (Math.floor(value) === value)
191
- return 0;
192
- let stringValue = value.toString().split('.')[1];
193
- if (stringValue) {
194
- return stringValue.length ? stringValue.length : 0;
195
- }
196
- else {
197
- return 0;
198
- }
199
- }
200
- export function _numberToString(input, decimals, locale, useGrouping) {
201
- if (input == null) {
202
- input = 0;
203
- }
204
- if (decimals == null || decimals == -1) {
205
- decimals = countDecimals(input);
206
- }
207
- let n = Number(input);
208
- let f = decimals > -1
209
- ? {
210
- minimumFractionDigits: decimals,
211
- maximumFractionDigits: decimals,
212
- useGrouping: useGrouping,
213
- }
214
- : { useGrouping: useGrouping };
215
- return n.toLocaleString(locale, f);
216
- }
217
- /**
218
- * @param time time as Date object
219
- * @param manageSeconds flag to set seconds managing
220
- * @return time as string, formatted
221
- **/
222
- export function formatTime(time, manageSeconds) {
223
- const options = {
224
- hour: '2-digit',
225
- minute: '2-digit',
226
- hour12: false,
227
- };
228
- if (manageSeconds == true) {
229
- options.second = '2-digit';
230
- }
231
- return time.toLocaleTimeString(dom.ketchup.dates.getLocale() + '-u-hc-h23', options);
232
- }
233
- /**
234
- * @param value time string, formatted by actual browser locale
235
- * @returns true if time string in input is a valid time
236
- */
237
- export function isValidFormattedStringTime(value, manageSeconds) {
238
- let format = getCurrentTimeFormatFromBrowserLocale(manageSeconds);
239
- return dom.ketchup.dates.isValid(value, format, true);
240
- }
241
- /**
242
- * @param value time as string, formatted by actual browser locale
243
- * @returns time as string, formatted ISO
244
- **/
245
- export function formattedStringToDefaultUnformattedStringTime(value) {
246
- return formattedStringToCustomUnformattedStringTime(value, KupDatesFormats.ISO_TIME, true);
247
- }
248
- /**
249
- * @param value date/time as string, formatted by actual browser locale
250
- * @returns date/time as string, formatted ISO
251
- **/
252
- export function formattedStringToDefaultUnformattedStringTimestamp(value) {
253
- return formattedStringToCustomUnformattedStringTime(value, KupDatesFormats.ISO_DATE_TIME, true);
254
- }
255
- /**
256
- * @param value time as string, formatted by actual browser locale
257
- * @param outputFormat time format to return
258
- * @param manageSeconds flag to set seconds managing
259
- * @returns time as string, formatted
260
- **/
261
- export function formattedStringToCustomUnformattedStringTime(value, outputFormat, manageSeconds) {
262
- let inputFormat = getCurrentTimeFormatFromBrowserLocale(manageSeconds);
263
- if (dom.ketchup.dates.isValid(value, inputFormat)) {
264
- return dom.ketchup.dates.format(dom.ketchup.dates.normalize(value, KupDatesNormalize.TIME), outputFormat);
265
- }
266
- else {
267
- return '';
268
- }
269
- }
270
- /**
271
- * @param value time as string, formatted ISO
272
- * @param manageSeconds flag to set seconds managing
273
- * @param valueTimeFormat time format (default ISO)
274
- * @param customedFormat time format from smeupObject
275
- * @returns time as string, formatted by actual browser locale
276
- **/
277
- export function unformattedStringToFormattedStringTime(value, manageSeconds, customedFormat) {
278
- const options = {
279
- hour: '2-digit',
280
- minute: '2-digit',
281
- hour12: false,
282
- };
283
- if (manageSeconds == true) {
284
- options.second = '2-digit';
285
- }
286
- let date = dom.ketchup.dates.toDate(dom.ketchup.dates.normalize(value, KupDatesNormalize.TIME));
287
- return formatByCustomedOutputTimeFormat(value, date, options, customedFormat);
288
- }
289
- function formatByCustomedOutputTimeFormat(valueStr, date, options, customedFormat) {
290
- if (customedFormat == null) {
291
- return date.toLocaleTimeString(dom.ketchup.dates.getLocale() + '-u-hc-h23', options);
292
- }
293
- switch (customedFormat) {
294
- case 'I13': {
295
- //hh:mm
296
- break;
297
- }
298
- case 'I12': {
299
- //hh:mm:ss
300
- break;
301
- }
302
- case 'I11': {
303
- //???
304
- //hh:dddd
305
- //return moment(date).format('HH:DDDD');
306
- return valueStr;
307
- }
308
- case 'I14': {
309
- //???
310
- //sssss
311
- //return moment(date).format('SSSSS');
312
- return valueStr;
313
- }
314
- case 'I1H': {
315
- //???
316
- //Ora,Cen/Min HH,xx
317
- return valueStr;
318
- }
319
- case 'I1M': {
320
- //???
321
- //Min,Cen/Sec MMMM,xx
322
- return valueStr;
323
- }
324
- case 'I21': {
325
- //???
326
- //Giorni,(4 decim)
327
- return valueStr;
328
- }
329
- case 'I22': {
330
- //???
331
- //Ore,(4 decim)
332
- return valueStr;
333
- }
334
- case 'I23': {
335
- //???
336
- //Minuti,(4 decim)
337
- return valueStr;
338
- }
339
- case 'I24': {
340
- //???
341
- //Secondi
342
- return valueStr;
343
- }
344
- case 'I2H': {
345
- //???
346
- //Ora,Cen/Min HHHH,xx
347
- return valueStr;
348
- }
349
- case 'I2D': {
350
- //???
351
- //Ore Minuti Secondi HHMMS
352
- return valueStr;
353
- }
354
- case 'I2M': {
355
- //???
356
- //Min,Cen/Sec MMMM,xx
357
- return valueStr;
358
- }
359
- }
360
- return date.toLocaleTimeString(dom.ketchup.dates.getLocale() + '-u-hc-h23', options);
361
- }
362
- /**
363
- * @param value date/time as string, formatted ISO
364
- * @param valueDateFormat date/time format (default ISO)
365
- * @returns date/time as string, formatted by actual browser locale
366
- **/
367
- export function unformattedStringToFormattedStringTimestamp(value) {
368
- const options = {
369
- day: '2-digit',
370
- month: '2-digit',
371
- year: 'numeric',
372
- hour: '2-digit',
373
- minute: '2-digit',
374
- second: '2-digit',
375
- hour12: false,
376
- };
377
- let date = dom.ketchup.dates.toDate(dom.ketchup.dates.normalize(value, KupDatesNormalize.TIMESTAMP));
378
- return date.toLocaleString(dom.ketchup.dates.getLocale() + '-u-hc-h23', options);
379
- }
380
- export function getMonthAsStringByLocale(month, format) {
381
- if (month == null) {
382
- return '';
383
- }
384
- const dateTmp = new Date();
385
- dateTmp.setDate(1);
386
- dateTmp.setMonth(month - 1);
387
- const options = {
388
- month: format,
389
- };
390
- const dateTimeFormat = new Intl.DateTimeFormat(dom.ketchup.dates.getLocale(), options);
391
- return dateTimeFormat.format(dateTmp);
392
- }
393
- export function getMonthsAsStringByLocale(format) {
394
- if (format == null || format.trim() == '') {
395
- format = DateTimeFormatOptionsMonth.LONG;
396
- }
397
- var months = [];
398
- for (var i = 0; i < 12; i++) {
399
- months[i] = getMonthAsStringByLocale(i + 1, format);
400
- }
401
- return months;
402
- }
403
- export function getDayAsStringByLocale(date) {
404
- if (date == null) {
405
- return '';
406
- }
407
- const options = {
408
- weekday: 'narrow',
409
- /** weekday: 'narrow' 'short' 'long' */
410
- };
411
- const dateTimeFormat = new Intl.DateTimeFormat(dom.ketchup.dates.getLocale(), options);
412
- return dateTimeFormat.format(date);
413
- }
414
- function firstDayThisWeek(firstDayIndex) {
415
- var d = new Date();
416
- const day = d.getDay();
417
- // dayIndex0
418
- d.setDate(d.getDate() - day);
419
- // dayIndexX
420
- d.setDate(d.getDate() + firstDayIndex);
421
- return d;
422
- }
423
- const offsetDate = (base, count) => {
424
- const date = new Date(base);
425
- date.setDate(base.getDate() + count);
426
- return date;
427
- };
428
- function thisWeek(firstDayIndex) {
429
- const firstDay = firstDayThisWeek(firstDayIndex);
430
- return {
431
- startDate: firstDay,
432
- endDate: offsetDate(firstDay, 6),
433
- };
434
- }
435
- export function getDaysOfWeekAsStringByLocale(firstDayIndex) {
436
- var thisWeekDays = thisWeek(firstDayIndex);
437
- var monday = thisWeekDays.startDate;
438
- var days = [];
439
- for (var i = 0; i < 7; i++) {
440
- var date = new Date(monday.toISOString());
441
- date.setDate(date.getDate() + i);
442
- days[i] = getDayAsStringByLocale(date);
443
- }
444
- return days;
445
- }
446
17
  export function fillString(stringIn, stringForFill, finalLen, addBefore) {
447
18
  let initSize = stringIn.length;
448
19
  let stringOut = '';
@@ -495,3 +66,15 @@ export function setProps(comp, list, props) {
495
66
  }
496
67
  }
497
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
+ }