@etsoo/shared 1.2.51 → 1.2.54

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 (94) hide show
  1. package/.github/workflows/main.yml +6 -5
  2. package/README.md +1 -1
  3. package/lib/cjs/ActionResult.d.ts +1 -1
  4. package/lib/cjs/ActionResult.js +3 -3
  5. package/lib/cjs/ArrayUtils.d.ts +1 -1
  6. package/lib/cjs/ArrayUtils.js +4 -4
  7. package/lib/cjs/ColorUtils.d.ts +1 -1
  8. package/lib/cjs/ColorUtils.js +2 -2
  9. package/lib/cjs/DataTypes.d.ts +6 -6
  10. package/lib/cjs/DataTypes.js +50 -51
  11. package/lib/cjs/DateUtils.d.ts +1 -1
  12. package/lib/cjs/DateUtils.js +27 -28
  13. package/lib/cjs/DomUtils.d.ts +3 -3
  14. package/lib/cjs/DomUtils.js +64 -73
  15. package/lib/cjs/ExtendUtils.d.ts +1 -1
  16. package/lib/cjs/ExtendUtils.js +6 -6
  17. package/lib/cjs/IActionResult.d.ts +15 -2
  18. package/lib/cjs/NumberUtils.d.ts +1 -1
  19. package/lib/cjs/NumberUtils.js +9 -9
  20. package/lib/cjs/StorageUtils.js +2 -2
  21. package/lib/cjs/Utils.d.ts +4 -4
  22. package/lib/cjs/Utils.js +58 -62
  23. package/lib/cjs/index.d.ts +22 -22
  24. package/lib/cjs/storage/WindowStorage.d.ts +1 -1
  25. package/lib/cjs/types/ContentDisposition.d.ts +2 -2
  26. package/lib/cjs/types/ContentDisposition.js +11 -13
  27. package/lib/cjs/types/EColor.js +5 -7
  28. package/lib/cjs/types/EHistory.d.ts +3 -3
  29. package/lib/cjs/types/EHistory.js +4 -4
  30. package/lib/cjs/types/ErrorData.d.ts +1 -1
  31. package/lib/cjs/types/EventClass.js +1 -1
  32. package/lib/mjs/ActionResult.d.ts +1 -1
  33. package/lib/mjs/ActionResult.js +3 -3
  34. package/lib/mjs/ArrayUtils.d.ts +1 -1
  35. package/lib/mjs/ArrayUtils.js +5 -5
  36. package/lib/mjs/ColorUtils.d.ts +1 -1
  37. package/lib/mjs/ColorUtils.js +3 -3
  38. package/lib/mjs/DataTypes.d.ts +6 -6
  39. package/lib/mjs/DataTypes.js +50 -51
  40. package/lib/mjs/DateUtils.d.ts +1 -1
  41. package/lib/mjs/DateUtils.js +27 -28
  42. package/lib/mjs/DomUtils.d.ts +3 -3
  43. package/lib/mjs/DomUtils.js +67 -76
  44. package/lib/mjs/ExtendUtils.d.ts +1 -1
  45. package/lib/mjs/ExtendUtils.js +6 -6
  46. package/lib/mjs/IActionResult.d.ts +15 -2
  47. package/lib/mjs/NumberUtils.d.ts +1 -1
  48. package/lib/mjs/NumberUtils.js +9 -9
  49. package/lib/mjs/StorageUtils.js +4 -4
  50. package/lib/mjs/Utils.d.ts +4 -4
  51. package/lib/mjs/Utils.js +61 -65
  52. package/lib/mjs/index.d.ts +22 -22
  53. package/lib/mjs/index.js +22 -22
  54. package/lib/mjs/storage/WindowStorage.d.ts +1 -1
  55. package/lib/mjs/storage/WindowStorage.js +2 -2
  56. package/lib/mjs/types/ContentDisposition.d.ts +2 -2
  57. package/lib/mjs/types/ContentDisposition.js +12 -14
  58. package/lib/mjs/types/EColor.js +5 -7
  59. package/lib/mjs/types/EHistory.d.ts +3 -3
  60. package/lib/mjs/types/EHistory.js +5 -5
  61. package/lib/mjs/types/ErrorData.d.ts +1 -1
  62. package/lib/mjs/types/EventClass.js +1 -1
  63. package/package.json +61 -63
  64. package/src/ActionResult.ts +23 -23
  65. package/src/ArrayUtils.ts +164 -172
  66. package/src/ColorUtils.ts +80 -82
  67. package/src/DataTypes.ts +745 -754
  68. package/src/DateUtils.ts +266 -268
  69. package/src/DomUtils.ts +806 -831
  70. package/src/ExtendUtils.ts +191 -191
  71. package/src/IActionResult.ts +55 -40
  72. package/src/Keyboard.ts +258 -258
  73. package/src/NumberUtils.ts +135 -135
  74. package/src/StorageUtils.ts +117 -117
  75. package/src/Utils.ts +908 -930
  76. package/src/index.ts +22 -22
  77. package/src/node/Storage.ts +53 -53
  78. package/src/storage/IStorage.ts +62 -62
  79. package/src/storage/WindowStorage.ts +140 -140
  80. package/src/types/ContentDisposition.ts +59 -63
  81. package/src/types/DataError.ts +15 -15
  82. package/src/types/DelayedExecutorType.ts +15 -15
  83. package/src/types/EColor.ts +241 -248
  84. package/src/types/EHistory.ts +151 -151
  85. package/src/types/ErrorData.ts +11 -11
  86. package/src/types/EventClass.ts +220 -220
  87. package/src/types/FormData.ts +25 -25
  88. package/src/types/ParsedPath.ts +5 -5
  89. package/tsconfig.cjs.json +16 -16
  90. package/tsconfig.json +16 -16
  91. package/.eslintignore +0 -3
  92. package/.eslintrc.json +0 -29
  93. package/.prettierignore +0 -5
  94. package/.prettierrc +0 -6
@@ -1,9 +1,9 @@
1
- import isEqual from 'lodash.isequal';
1
+ import isEqual from "lodash.isequal";
2
2
  Array.prototype.different = function (target, round) {
3
3
  return ArrayUtils.differences(this, target, round);
4
4
  };
5
5
  Array.prototype.toUnique = function () {
6
- if (this.length === 0 || typeof this[0] !== 'object')
6
+ if (this.length === 0 || typeof this[0] !== "object")
7
7
  return Array.from(new Set(this));
8
8
  const newArray = [];
9
9
  this.forEach((item) => {
@@ -22,7 +22,7 @@ Array.prototype.max = function (field) {
22
22
  Array.prototype.maxItem = function (field) {
23
23
  if (this.length === 0)
24
24
  return undefined;
25
- return this.reduce((prev, curr) => prev[field] > curr[field] ? prev : curr);
25
+ return this.reduce((prev, curr) => (prev[field] > curr[field] ? prev : curr));
26
26
  };
27
27
  Array.prototype.min = function (field) {
28
28
  if (field == null) {
@@ -33,13 +33,13 @@ Array.prototype.min = function (field) {
33
33
  Array.prototype.minItem = function (field) {
34
34
  if (this.length === 0)
35
35
  return undefined;
36
- return this.reduce((prev, curr) => prev[field] < curr[field] ? prev : curr);
36
+ return this.reduce((prev, curr) => (prev[field] < curr[field] ? prev : curr));
37
37
  };
38
38
  Array.prototype.remove = function (...items) {
39
39
  const funs = [];
40
40
  const results = [];
41
41
  items.forEach((item) => {
42
- if (typeof item === 'function') {
42
+ if (typeof item === "function") {
43
43
  funs.push(item);
44
44
  }
45
45
  else {
@@ -1,4 +1,4 @@
1
- import { EColor } from './types/EColor';
1
+ import { EColor } from "./types/EColor";
2
2
  /**
3
3
  * Color utils
4
4
  */
@@ -1,4 +1,4 @@
1
- import { EColor } from './types/EColor';
1
+ import { EColor } from "./types/EColor";
2
2
  /**
3
3
  * Color utils
4
4
  */
@@ -12,7 +12,7 @@ export var ColorUtils;
12
12
  * @param hex to HEX or not
13
13
  * @returns Result
14
14
  */
15
- function getColors(init = '#000', factor = 51, adjustOrder = true, hex = true) {
15
+ function getColors(init = "#000", factor = 51, adjustOrder = true, hex = true) {
16
16
  return getEColors(init, factor, adjustOrder).map((c) => hex ? c.toHEXColor() : c.toRGBColor());
17
17
  }
18
18
  ColorUtils.getColors = getColors;
@@ -23,7 +23,7 @@ export var ColorUtils;
23
23
  * @param adjustOrder Adjust order to increase difference
24
24
  * @returns Result
25
25
  */
26
- function getEColors(init = '#000', factor = 51, adjustOrder = true) {
26
+ function getEColors(init = "#000", factor = 51, adjustOrder = true) {
27
27
  // Init color
28
28
  const initColor = EColor.parse(init) ?? new EColor(0, 0, 0);
29
29
  // Factors elements
@@ -39,7 +39,7 @@ export declare namespace DataTypes {
39
39
  /**
40
40
  * Basic conditinal type
41
41
  */
42
- type BasicConditional<T extends BasicNames> = T extends 'string' ? string : T extends 'string[]' ? string[] : T extends 'date' ? Date : T extends 'date[]' ? Date[] : T extends 'boolean' ? boolean : T extends 'boolean[]' ? boolean[] : T extends 'number' ? number : T extends 'number[]' ? number[] : T extends 'bigint' ? bigint : T extends 'bigint[]' ? bigint[] : unknown[];
42
+ type BasicConditional<T extends BasicNames> = T extends "string" ? string : T extends "string[]" ? string[] : T extends "date" ? Date : T extends "date[]" ? Date[] : T extends "boolean" ? boolean : T extends "boolean[]" ? boolean[] : T extends "number" ? number : T extends "number[]" ? number[] : T extends "bigint" ? bigint : T extends "bigint[]" ? bigint[] : unknown[];
43
43
  /**
44
44
  * Basic or basic array type
45
45
  */
@@ -144,7 +144,7 @@ export declare namespace DataTypes {
144
144
  */
145
145
  type AddAndEditType<T extends {
146
146
  [key in D]: IdType;
147
- }, D extends string = 'id'> = (Omit<T, D> & {
147
+ }, D extends string = "id"> = (Omit<T, D> & {
148
148
  [key in D]?: undefined | never;
149
149
  }) | (Partial<T> & Readonly<Pick<T, D>> & {
150
150
  changedFields?: string[];
@@ -157,7 +157,7 @@ export declare namespace DataTypes {
157
157
  [key in D]: IdType;
158
158
  }, // Entity modal
159
159
  E extends boolean, // Editing or not
160
- D extends string = 'id'> = E extends false ? Optional<T, D> : Partial<T> & Readonly<Pick<T, D>> & {
160
+ D extends string = "id"> = E extends false ? Optional<T, D> : Partial<T> & Readonly<Pick<T, D>> & {
161
161
  changedFields?: string[];
162
162
  };
163
163
  /**
@@ -444,16 +444,16 @@ export type ListType2 = {
444
444
  */
445
445
  export type IdDefaultType<T extends object, I extends IdType = IdType> = T extends {
446
446
  id: I;
447
- } ? DataTypes.Keys<T, I> & 'id' : DataTypes.Keys<T, I>;
447
+ } ? DataTypes.Keys<T, I> & "id" : DataTypes.Keys<T, I>;
448
448
  /**
449
449
  * Label default type
450
450
  */
451
451
  export type LabelDefaultType<T extends object> = T extends {
452
452
  label: string;
453
- } ? DataTypes.Keys<T, string> & 'label' : DataTypes.Keys<T, string>;
453
+ } ? DataTypes.Keys<T, string> & "label" : DataTypes.Keys<T, string>;
454
454
  /**
455
455
  * Title default type
456
456
  */
457
457
  export type TitleDefaultType<T extends object> = T extends {
458
458
  title: string;
459
- } ? DataTypes.Keys<T, string> & 'title' : DataTypes.Keys<T, string>;
459
+ } ? DataTypes.Keys<T, string> & "title" : DataTypes.Keys<T, string>;
@@ -4,7 +4,7 @@
4
4
  * Before was wrong with {}, from 4.8 unknown = {} | null | undefined
5
5
  */
6
6
  BigInt.prototype.toJSON = function () {
7
- return this.toString() + 'n';
7
+ return this.toString() + "n";
8
8
  };
9
9
  /**
10
10
  * Interface data types
@@ -15,17 +15,17 @@ export var DataTypes;
15
15
  * Basic type and basic type array names array
16
16
  */
17
17
  DataTypes.BasicArray = [
18
- 'number',
19
- 'number[]',
20
- 'bigint',
21
- 'bigint[]',
22
- 'date',
23
- 'date[]',
24
- 'boolean',
25
- 'boolean[]',
26
- 'string',
27
- 'string[]',
28
- 'unknown[]'
18
+ "number",
19
+ "number[]",
20
+ "bigint",
21
+ "bigint[]",
22
+ "date",
23
+ "date[]",
24
+ "boolean",
25
+ "boolean[]",
26
+ "string",
27
+ "string[]",
28
+ "unknown[]"
29
29
  ];
30
30
  /**
31
31
  * Simple type enum
@@ -133,14 +133,14 @@ export var DataTypes;
133
133
  function convertByType(input, targetType) {
134
134
  // null or undefined
135
135
  // And avoid empty string to mass up in different type
136
- if (input == null || (typeof input === 'string' && input.trim() === ''))
136
+ if (input == null || (typeof input === "string" && input.trim() === ""))
137
137
  return undefined;
138
138
  // Array
139
- if (targetType.endsWith('[]')) {
139
+ if (targetType.endsWith("[]")) {
140
140
  // Input array
141
141
  const inputArray = Array.isArray(input)
142
142
  ? input
143
- : typeof input === 'string'
143
+ : typeof input === "string"
144
144
  ? input.split(/,\s*/g) // Support comma separated array
145
145
  : [input];
146
146
  // Element type
@@ -155,41 +155,41 @@ export var DataTypes;
155
155
  if (typeof input === targetType)
156
156
  return input;
157
157
  // Date
158
- if (targetType === 'date') {
158
+ if (targetType === "date") {
159
159
  if (input instanceof Date)
160
160
  return input;
161
- if (typeof input === 'string' || typeof input === 'number') {
161
+ if (typeof input === "string" || typeof input === "number") {
162
162
  const date = new Date(input);
163
163
  return date == null ? undefined : date;
164
164
  }
165
165
  return undefined;
166
166
  }
167
167
  // Bigint
168
- if (targetType === 'bigint') {
169
- if (typeof input === 'string' ||
170
- typeof input === 'number' ||
171
- typeof input === 'boolean')
168
+ if (targetType === "bigint") {
169
+ if (typeof input === "string" ||
170
+ typeof input === "number" ||
171
+ typeof input === "boolean")
172
172
  return BigInt(input);
173
173
  return undefined;
174
174
  }
175
175
  // Boolean
176
- if (targetType === 'boolean') {
177
- if (typeof input === 'string' || typeof input === 'number') {
176
+ if (targetType === "boolean") {
177
+ if (typeof input === "string" || typeof input === "number") {
178
178
  // Here are different with official definition
179
179
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean
180
- if (input === '0' || input === 'false')
180
+ if (input === "0" || input === "false")
181
181
  return false;
182
182
  return Boolean(input);
183
183
  }
184
184
  return undefined;
185
185
  }
186
186
  // Number
187
- if (targetType === 'number') {
187
+ if (targetType === "number") {
188
188
  const number = Number(input);
189
189
  return isNaN(number) ? undefined : number;
190
190
  }
191
191
  // String
192
- if (targetType === 'string') {
192
+ if (targetType === "string") {
193
193
  return String(input);
194
194
  }
195
195
  // Default
@@ -207,9 +207,8 @@ export var DataTypes;
207
207
  const value = convertByType(input, type);
208
208
  if (value == null)
209
209
  return undefined;
210
- if (typeof value === 'number') {
211
- if (enumType === DataTypes.CombinedEnum.Int ||
212
- enumType === DataTypes.CombinedEnum.IntMoney)
210
+ if (typeof value === "number") {
211
+ if (enumType === DataTypes.CombinedEnum.Int || enumType === DataTypes.CombinedEnum.IntMoney)
213
212
  return Math.round(value);
214
213
  if (enumType === DataTypes.CombinedEnum.Money)
215
214
  return Math.round(10000 * value) / 10000;
@@ -225,21 +224,21 @@ export var DataTypes;
225
224
  function getBasicName(enumType) {
226
225
  switch (enumType) {
227
226
  case DataTypes.CombinedEnum.Array:
228
- return 'unknown[]';
227
+ return "unknown[]";
229
228
  case DataTypes.CombinedEnum.Bigint:
230
- return 'bigint';
229
+ return "bigint";
231
230
  case DataTypes.CombinedEnum.Boolean:
232
- return 'boolean';
231
+ return "boolean";
233
232
  case DataTypes.CombinedEnum.Date:
234
233
  case DataTypes.CombinedEnum.DateTime:
235
- return 'date';
234
+ return "date";
236
235
  case DataTypes.CombinedEnum.Number:
237
236
  case DataTypes.CombinedEnum.Int:
238
237
  case DataTypes.CombinedEnum.IntMoney:
239
238
  case DataTypes.CombinedEnum.Money:
240
- return 'number';
239
+ return "number";
241
240
  default:
242
- return 'string';
241
+ return "string";
243
242
  }
244
243
  }
245
244
  DataTypes.getBasicName = getBasicName;
@@ -255,12 +254,12 @@ export var DataTypes;
255
254
  return undefined;
256
255
  // Date
257
256
  if (value instanceof Date) {
258
- return isArray ? 'date[]' : 'date';
257
+ return isArray ? "date[]" : "date";
259
258
  }
260
259
  // No array
261
260
  // Other cases
262
261
  const valueType = typeof value;
263
- const typeName = isArray ? valueType + '[]' : valueType;
262
+ const typeName = isArray ? valueType + "[]" : valueType;
264
263
  if (!isBasicName(typeName))
265
264
  return undefined;
266
265
  return typeName;
@@ -317,9 +316,9 @@ export var DataTypes;
317
316
  * @returns Result
318
317
  */
319
318
  function getListItemLabel(item) {
320
- return 'label' in item
319
+ return "label" in item
321
320
  ? item.label
322
- : 'name' in item
321
+ : "name" in item
323
322
  ? item.name
324
323
  : item.title;
325
324
  }
@@ -330,11 +329,11 @@ export var DataTypes;
330
329
  * @returns Result
331
330
  */
332
331
  function getObjectItemLabel(item) {
333
- return 'label' in item
332
+ return "label" in item
334
333
  ? `${item.label}`
335
- : 'name' in item
334
+ : "name" in item
336
335
  ? `${item.name}`
337
- : 'title' in item
336
+ : "title" in item
338
337
  ? `${item.title}`
339
338
  : `${item}`;
340
339
  }
@@ -346,7 +345,7 @@ export var DataTypes;
346
345
  * @returns Value
347
346
  */
348
347
  function getValue(data, key) {
349
- if (data != null && typeof key === 'string' && key in data) {
348
+ if (data != null && typeof key === "string" && key in data) {
350
349
  return Reflect.get(data, key);
351
350
  }
352
351
  return undefined;
@@ -372,7 +371,7 @@ export var DataTypes;
372
371
  const value = getValue(data, key);
373
372
  if (value == null)
374
373
  return undefined;
375
- if (typeof value === 'number')
374
+ if (typeof value === "number")
376
375
  return value;
377
376
  return `${value}`;
378
377
  }
@@ -387,7 +386,7 @@ export var DataTypes;
387
386
  const value = getValue(data, key);
388
387
  if (value == null)
389
388
  return undefined;
390
- if (typeof value === 'string')
389
+ if (typeof value === "string")
391
390
  return value;
392
391
  return `${value}`;
393
392
  }
@@ -408,7 +407,7 @@ export var DataTypes;
408
407
  * @returns Result
409
408
  */
410
409
  function isSimpleObject(input, includeArray = true) {
411
- return (typeof input === 'object' &&
410
+ return (typeof input === "object" &&
412
411
  input != null &&
413
412
  Object.values(input).every((value) => isSimpleType(value, includeArray)));
414
413
  }
@@ -437,7 +436,7 @@ export var DataTypes;
437
436
  }
438
437
  // Other cases
439
438
  const type = typeof input;
440
- if (type === 'function' || type === 'object' || type === 'symbol')
439
+ if (type === "function" || type === "object" || type === "symbol")
441
440
  return false;
442
441
  return true;
443
442
  }
@@ -449,10 +448,10 @@ export var DataTypes;
449
448
  function jsonReplacer(replacer) {
450
449
  const m = new Map();
451
450
  return function (key, value) {
452
- const path = m.get(this) + (Array.isArray(this) ? `[${key}]` : '.' + key);
451
+ const path = m.get(this) + (Array.isArray(this) ? `[${key}]` : "." + key);
453
452
  if (value === Object(value))
454
453
  m.set(value, path);
455
- return replacer.call(this, key, value, path.replace(/undefined\.\.?/, ''));
454
+ return replacer.call(this, key, value, path.replace(/undefined\.\.?/, ""));
456
455
  };
457
456
  }
458
457
  DataTypes.jsonReplacer = jsonReplacer;
@@ -464,8 +463,8 @@ export var DataTypes;
464
463
  function jsonBigintReceiver(...args) {
465
464
  return jsonReplacer(function (key, value, path) {
466
465
  if ((args.includes(key) || args.includes(path)) &&
467
- typeof value === 'string') {
468
- if (value.endsWith('n'))
466
+ typeof value === "string") {
467
+ if (value.endsWith("n"))
469
468
  return BigInt(value.slice(0, -1));
470
469
  else
471
470
  return BigInt(value);
@@ -37,7 +37,7 @@ export declare namespace DateUtils {
37
37
  /**
38
38
  * Date format options
39
39
  */
40
- type FormatOptions = Intl.DateTimeFormatOptions | 'd' | 'dm' | 'ds';
40
+ type FormatOptions = Intl.DateTimeFormatOptions | "d" | "dm" | "ds";
41
41
  /**
42
42
  * Format
43
43
  * @param input Input date time
@@ -37,25 +37,25 @@ export var DateUtils;
37
37
  * Day format, YYYY-MM-DD
38
38
  */
39
39
  DateUtils.DayFormat = {
40
- year: 'numeric',
41
- month: '2-digit',
42
- day: '2-digit'
40
+ year: "numeric",
41
+ month: "2-digit",
42
+ day: "2-digit"
43
43
  };
44
44
  /**
45
45
  * Minute format, YYYY-MM-DD hh:mm
46
46
  */
47
47
  DateUtils.MinuteFormat = {
48
48
  ...DateUtils.DayFormat,
49
- hour: '2-digit',
50
- hourCycle: 'h23',
51
- minute: '2-digit'
49
+ hour: "2-digit",
50
+ hourCycle: "h23",
51
+ minute: "2-digit"
52
52
  };
53
53
  /**
54
54
  * Second format, YYYY-MM-DD hh:mm:ss
55
55
  */
56
56
  DateUtils.SecondFormat = {
57
57
  ...DateUtils.MinuteFormat,
58
- second: '2-digit'
58
+ second: "2-digit"
59
59
  };
60
60
  /**
61
61
  * Format
@@ -76,13 +76,13 @@ export var DateUtils;
76
76
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat
77
77
  let opt;
78
78
  switch (options) {
79
- case 'd':
79
+ case "d":
80
80
  opt = DateUtils.DayFormat;
81
81
  break;
82
- case 'dm':
82
+ case "dm":
83
83
  opt = DateUtils.MinuteFormat;
84
84
  break;
85
- case 'ds':
85
+ case "ds":
86
86
  opt = DateUtils.SecondFormat;
87
87
  break;
88
88
  default:
@@ -93,7 +93,7 @@ export var DateUtils;
93
93
  // Return format result
94
94
  return new Intl.DateTimeFormat(locale, newOpt)
95
95
  .format(parsed)
96
- .replace(/,\s*/g, ' ');
96
+ .replace(/,\s*/g, " ");
97
97
  }
98
98
  DateUtils.format = format;
99
99
  /**
@@ -103,32 +103,32 @@ export var DateUtils;
103
103
  */
104
104
  function formatForInput(date, hasSecondOrType) {
105
105
  // Return when null
106
- if (date == null || date === '')
106
+ if (date == null || date === "")
107
107
  return undefined;
108
108
  // Parse string as date
109
- const dt = typeof date === 'string' ? new Date(date) : date;
110
- const hasSecond = typeof hasSecondOrType === 'string'
111
- ? hasSecondOrType === 'date'
109
+ const dt = typeof date === "string" ? new Date(date) : date;
110
+ const hasSecond = typeof hasSecondOrType === "string"
111
+ ? hasSecondOrType === "date"
112
112
  ? undefined
113
113
  : true
114
114
  : hasSecondOrType;
115
115
  // Parts
116
116
  const parts = [
117
117
  dt.getFullYear(),
118
- (dt.getMonth() + 1).toString().padStart(2, '0'),
119
- dt.getDate().toString().padStart(2, '0')
118
+ (dt.getMonth() + 1).toString().padStart(2, "0"),
119
+ dt.getDate().toString().padStart(2, "0")
120
120
  ];
121
121
  // Date
122
- const d = parts.join('-');
122
+ const d = parts.join("-");
123
123
  if (hasSecond == null)
124
124
  return d;
125
125
  const hm = [
126
- dt.getHours().toString().padStart(2, '0'),
127
- dt.getMinutes().toString().padStart(2, '0')
126
+ dt.getHours().toString().padStart(2, "0"),
127
+ dt.getMinutes().toString().padStart(2, "0")
128
128
  ];
129
129
  if (hasSecond)
130
- hm.push(dt.getSeconds().toString().padStart(2, '0'));
131
- return `${d}T${hm.join(':')}`;
130
+ hm.push(dt.getSeconds().toString().padStart(2, "0"));
131
+ return `${d}T${hm.join(":")}`;
132
132
  }
133
133
  DateUtils.formatForInput = formatForInput;
134
134
  /**
@@ -160,9 +160,9 @@ export var DateUtils;
160
160
  */
161
161
  DateUtils.jsonParser = (keys) => {
162
162
  return function (key, value) {
163
- if (typeof value === 'string' &&
163
+ if (typeof value === "string" &&
164
164
  value != null &&
165
- value !== '' &&
165
+ value !== "" &&
166
166
  keys.includes(key)) {
167
167
  const parsedDate = parse(value);
168
168
  if (parsedDate != null)
@@ -180,9 +180,9 @@ export var DateUtils;
180
180
  function parse(input) {
181
181
  if (input == null)
182
182
  return undefined;
183
- if (typeof input === 'string') {
183
+ if (typeof input === "string") {
184
184
  const f = input[0];
185
- if (f >= '0' && f <= '9' && /[-\/\s]/g.test(input)) {
185
+ if (f >= "0" && f <= "9" && /[-\/\s]/g.test(input)) {
186
186
  const n = Date.parse(input);
187
187
  if (!isNaN(n))
188
188
  return new Date(n);
@@ -217,8 +217,7 @@ export var DateUtils;
217
217
  d2 = parse(d2);
218
218
  if (d1 == null || d2 == null)
219
219
  return false;
220
- return (d1.getFullYear() === d2.getFullYear() &&
221
- d1.getMonth() === d2.getMonth());
220
+ return (d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth());
222
221
  }
223
222
  DateUtils.sameMonth = sameMonth;
224
223
  })(DateUtils || (DateUtils = {}));
@@ -1,6 +1,6 @@
1
- import { DataTypes } from './DataTypes';
2
- import { ErrorData, ErrorType } from './types/ErrorData';
3
- import { FormDataFieldValue, IFormData } from './types/FormData';
1
+ import { DataTypes } from "./DataTypes";
2
+ import { ErrorData, ErrorType } from "./types/ErrorData";
3
+ import { FormDataFieldValue, IFormData } from "./types/FormData";
4
4
  /**
5
5
  * User agent data, maybe replaced by navigator.userAgentData in future
6
6
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgentData