@etsoo/shared 1.2.52 → 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.
- package/.github/workflows/main.yml +6 -5
- package/lib/cjs/ActionResult.d.ts +1 -1
- package/lib/cjs/ActionResult.js +3 -3
- package/lib/cjs/ArrayUtils.d.ts +1 -1
- package/lib/cjs/ArrayUtils.js +4 -4
- package/lib/cjs/ColorUtils.d.ts +1 -1
- package/lib/cjs/ColorUtils.js +2 -2
- package/lib/cjs/DataTypes.d.ts +6 -6
- package/lib/cjs/DataTypes.js +50 -51
- package/lib/cjs/DateUtils.d.ts +1 -1
- package/lib/cjs/DateUtils.js +27 -28
- package/lib/cjs/DomUtils.d.ts +3 -3
- package/lib/cjs/DomUtils.js +64 -73
- package/lib/cjs/ExtendUtils.d.ts +1 -1
- package/lib/cjs/ExtendUtils.js +6 -6
- package/lib/cjs/IActionResult.d.ts +1 -1
- package/lib/cjs/NumberUtils.d.ts +1 -1
- package/lib/cjs/NumberUtils.js +9 -9
- package/lib/cjs/StorageUtils.js +2 -2
- package/lib/cjs/Utils.d.ts +4 -4
- package/lib/cjs/Utils.js +58 -62
- package/lib/cjs/index.d.ts +22 -22
- package/lib/cjs/storage/WindowStorage.d.ts +1 -1
- package/lib/cjs/types/ContentDisposition.d.ts +2 -2
- package/lib/cjs/types/ContentDisposition.js +11 -13
- package/lib/cjs/types/EColor.js +5 -7
- package/lib/cjs/types/EHistory.d.ts +3 -3
- package/lib/cjs/types/EHistory.js +4 -4
- package/lib/cjs/types/ErrorData.d.ts +1 -1
- package/lib/cjs/types/EventClass.js +1 -1
- package/lib/mjs/ActionResult.d.ts +1 -1
- package/lib/mjs/ActionResult.js +3 -3
- package/lib/mjs/ArrayUtils.d.ts +1 -1
- package/lib/mjs/ArrayUtils.js +5 -5
- package/lib/mjs/ColorUtils.d.ts +1 -1
- package/lib/mjs/ColorUtils.js +3 -3
- package/lib/mjs/DataTypes.d.ts +6 -6
- package/lib/mjs/DataTypes.js +50 -51
- package/lib/mjs/DateUtils.d.ts +1 -1
- package/lib/mjs/DateUtils.js +27 -28
- package/lib/mjs/DomUtils.d.ts +3 -3
- package/lib/mjs/DomUtils.js +67 -76
- package/lib/mjs/ExtendUtils.d.ts +1 -1
- package/lib/mjs/ExtendUtils.js +6 -6
- package/lib/mjs/IActionResult.d.ts +1 -1
- package/lib/mjs/NumberUtils.d.ts +1 -1
- package/lib/mjs/NumberUtils.js +9 -9
- package/lib/mjs/StorageUtils.js +4 -4
- package/lib/mjs/Utils.d.ts +4 -4
- package/lib/mjs/Utils.js +61 -65
- package/lib/mjs/index.d.ts +22 -22
- package/lib/mjs/index.js +22 -22
- package/lib/mjs/storage/WindowStorage.d.ts +1 -1
- package/lib/mjs/storage/WindowStorage.js +2 -2
- package/lib/mjs/types/ContentDisposition.d.ts +2 -2
- package/lib/mjs/types/ContentDisposition.js +12 -14
- package/lib/mjs/types/EColor.js +5 -7
- package/lib/mjs/types/EHistory.d.ts +3 -3
- package/lib/mjs/types/EHistory.js +5 -5
- package/lib/mjs/types/ErrorData.d.ts +1 -1
- package/lib/mjs/types/EventClass.js +1 -1
- package/package.json +61 -63
- package/src/ActionResult.ts +23 -23
- package/src/ArrayUtils.ts +164 -172
- package/src/ColorUtils.ts +80 -82
- package/src/DataTypes.ts +745 -754
- package/src/DateUtils.ts +266 -268
- package/src/DomUtils.ts +806 -831
- package/src/ExtendUtils.ts +191 -191
- package/src/IActionResult.ts +42 -42
- package/src/Keyboard.ts +258 -258
- package/src/NumberUtils.ts +135 -135
- package/src/StorageUtils.ts +117 -117
- package/src/Utils.ts +908 -930
- package/src/index.ts +22 -22
- package/src/node/Storage.ts +53 -53
- package/src/storage/IStorage.ts +62 -62
- package/src/storage/WindowStorage.ts +140 -140
- package/src/types/ContentDisposition.ts +59 -63
- package/src/types/DataError.ts +15 -15
- package/src/types/DelayedExecutorType.ts +15 -15
- package/src/types/EColor.ts +241 -248
- package/src/types/EHistory.ts +151 -151
- package/src/types/ErrorData.ts +11 -11
- package/src/types/EventClass.ts +220 -220
- package/src/types/FormData.ts +25 -25
- package/src/types/ParsedPath.ts +5 -5
- package/tsconfig.cjs.json +16 -16
- package/tsconfig.json +16 -16
- package/.eslintignore +0 -3
- package/.eslintrc.json +0 -29
- package/.prettierignore +0 -5
- package/.prettierrc +0 -6
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
name: Node.js Package
|
|
7
7
|
|
|
8
8
|
# Event to trigger the action
|
|
9
|
-
on:
|
|
9
|
+
on:
|
|
10
|
+
[push]
|
|
10
11
|
# release:
|
|
11
12
|
# types: [created]
|
|
12
13
|
|
|
@@ -23,13 +24,13 @@ jobs:
|
|
|
23
24
|
# https://github.com/actions/checkout, This action checks-out your repository under $GITHUB_WORKSPACE
|
|
24
25
|
# so your workflow can access it.
|
|
25
26
|
- uses: actions/checkout@v4
|
|
26
|
-
|
|
27
|
+
|
|
27
28
|
# Set up your GitHub Actions workflow with a specific version of node.js
|
|
28
29
|
# Setup .npmrc file to publish to npm
|
|
29
30
|
- uses: actions/setup-node@v4
|
|
30
31
|
with:
|
|
31
|
-
node-version:
|
|
32
|
-
registry-url:
|
|
32
|
+
node-version: "latest"
|
|
33
|
+
registry-url: "https://registry.npmjs.org"
|
|
33
34
|
|
|
34
35
|
# Named after Continuous Integration, installs dependencies directly from package-lock.json
|
|
35
36
|
# ci vs install
|
|
@@ -45,4 +46,4 @@ jobs:
|
|
|
45
46
|
# For scoped package, make it public for free service
|
|
46
47
|
- run: npm publish --access public
|
|
47
48
|
env:
|
|
48
|
-
NODE_AUTH_TOKEN: ${{ secrets.ETSOONpmToken }}
|
|
49
|
+
NODE_AUTH_TOKEN: ${{ secrets.ETSOONpmToken }}
|
package/lib/cjs/ActionResult.js
CHANGED
|
@@ -11,14 +11,14 @@ class ActionResult {
|
|
|
11
11
|
*/
|
|
12
12
|
static create(error) {
|
|
13
13
|
// If the error has status / statusCode
|
|
14
|
-
const status =
|
|
14
|
+
const status = "status" in error
|
|
15
15
|
? error.status
|
|
16
|
-
:
|
|
16
|
+
: "statusCode" in error
|
|
17
17
|
? error.statusCode
|
|
18
18
|
: undefined;
|
|
19
19
|
// Result
|
|
20
20
|
const result = {
|
|
21
|
-
status: typeof status ===
|
|
21
|
+
status: typeof status === "number" ? status : undefined,
|
|
22
22
|
ok: false,
|
|
23
23
|
type: error.name,
|
|
24
24
|
title: error.message
|
package/lib/cjs/ArrayUtils.d.ts
CHANGED
package/lib/cjs/ArrayUtils.js
CHANGED
|
@@ -9,7 +9,7 @@ Array.prototype.different = function (target, round) {
|
|
|
9
9
|
return ArrayUtils.differences(this, target, round);
|
|
10
10
|
};
|
|
11
11
|
Array.prototype.toUnique = function () {
|
|
12
|
-
if (this.length === 0 || typeof this[0] !==
|
|
12
|
+
if (this.length === 0 || typeof this[0] !== "object")
|
|
13
13
|
return Array.from(new Set(this));
|
|
14
14
|
const newArray = [];
|
|
15
15
|
this.forEach((item) => {
|
|
@@ -28,7 +28,7 @@ Array.prototype.max = function (field) {
|
|
|
28
28
|
Array.prototype.maxItem = function (field) {
|
|
29
29
|
if (this.length === 0)
|
|
30
30
|
return undefined;
|
|
31
|
-
return this.reduce((prev, curr) => prev[field] > curr[field] ? prev : curr);
|
|
31
|
+
return this.reduce((prev, curr) => (prev[field] > curr[field] ? prev : curr));
|
|
32
32
|
};
|
|
33
33
|
Array.prototype.min = function (field) {
|
|
34
34
|
if (field == null) {
|
|
@@ -39,13 +39,13 @@ Array.prototype.min = function (field) {
|
|
|
39
39
|
Array.prototype.minItem = function (field) {
|
|
40
40
|
if (this.length === 0)
|
|
41
41
|
return undefined;
|
|
42
|
-
return this.reduce((prev, curr) => prev[field] < curr[field] ? prev : curr);
|
|
42
|
+
return this.reduce((prev, curr) => (prev[field] < curr[field] ? prev : curr));
|
|
43
43
|
};
|
|
44
44
|
Array.prototype.remove = function (...items) {
|
|
45
45
|
const funs = [];
|
|
46
46
|
const results = [];
|
|
47
47
|
items.forEach((item) => {
|
|
48
|
-
if (typeof item ===
|
|
48
|
+
if (typeof item === "function") {
|
|
49
49
|
funs.push(item);
|
|
50
50
|
}
|
|
51
51
|
else {
|
package/lib/cjs/ColorUtils.d.ts
CHANGED
package/lib/cjs/ColorUtils.js
CHANGED
|
@@ -15,7 +15,7 @@ var ColorUtils;
|
|
|
15
15
|
* @param hex to HEX or not
|
|
16
16
|
* @returns Result
|
|
17
17
|
*/
|
|
18
|
-
function getColors(init =
|
|
18
|
+
function getColors(init = "#000", factor = 51, adjustOrder = true, hex = true) {
|
|
19
19
|
return getEColors(init, factor, adjustOrder).map((c) => hex ? c.toHEXColor() : c.toRGBColor());
|
|
20
20
|
}
|
|
21
21
|
ColorUtils.getColors = getColors;
|
|
@@ -26,7 +26,7 @@ var ColorUtils;
|
|
|
26
26
|
* @param adjustOrder Adjust order to increase difference
|
|
27
27
|
* @returns Result
|
|
28
28
|
*/
|
|
29
|
-
function getEColors(init =
|
|
29
|
+
function getEColors(init = "#000", factor = 51, adjustOrder = true) {
|
|
30
30
|
// Init color
|
|
31
31
|
const initColor = EColor_1.EColor.parse(init) ?? new EColor_1.EColor(0, 0, 0);
|
|
32
32
|
// Factors elements
|
package/lib/cjs/DataTypes.d.ts
CHANGED
|
@@ -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
|
|
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 =
|
|
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 =
|
|
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> &
|
|
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> &
|
|
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> &
|
|
459
|
+
} ? DataTypes.Keys<T, string> & "title" : DataTypes.Keys<T, string>;
|
package/lib/cjs/DataTypes.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.DataTypes = void 0;
|
|
9
9
|
BigInt.prototype.toJSON = function () {
|
|
10
|
-
return this.toString() +
|
|
10
|
+
return this.toString() + "n";
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* Interface data types
|
|
@@ -18,17 +18,17 @@ var DataTypes;
|
|
|
18
18
|
* Basic type and basic type array names array
|
|
19
19
|
*/
|
|
20
20
|
DataTypes.BasicArray = [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
"number",
|
|
22
|
+
"number[]",
|
|
23
|
+
"bigint",
|
|
24
|
+
"bigint[]",
|
|
25
|
+
"date",
|
|
26
|
+
"date[]",
|
|
27
|
+
"boolean",
|
|
28
|
+
"boolean[]",
|
|
29
|
+
"string",
|
|
30
|
+
"string[]",
|
|
31
|
+
"unknown[]"
|
|
32
32
|
];
|
|
33
33
|
/**
|
|
34
34
|
* Simple type enum
|
|
@@ -136,14 +136,14 @@ var DataTypes;
|
|
|
136
136
|
function convertByType(input, targetType) {
|
|
137
137
|
// null or undefined
|
|
138
138
|
// And avoid empty string to mass up in different type
|
|
139
|
-
if (input == null || (typeof input ===
|
|
139
|
+
if (input == null || (typeof input === "string" && input.trim() === ""))
|
|
140
140
|
return undefined;
|
|
141
141
|
// Array
|
|
142
|
-
if (targetType.endsWith(
|
|
142
|
+
if (targetType.endsWith("[]")) {
|
|
143
143
|
// Input array
|
|
144
144
|
const inputArray = Array.isArray(input)
|
|
145
145
|
? input
|
|
146
|
-
: typeof input ===
|
|
146
|
+
: typeof input === "string"
|
|
147
147
|
? input.split(/,\s*/g) // Support comma separated array
|
|
148
148
|
: [input];
|
|
149
149
|
// Element type
|
|
@@ -158,41 +158,41 @@ var DataTypes;
|
|
|
158
158
|
if (typeof input === targetType)
|
|
159
159
|
return input;
|
|
160
160
|
// Date
|
|
161
|
-
if (targetType ===
|
|
161
|
+
if (targetType === "date") {
|
|
162
162
|
if (input instanceof Date)
|
|
163
163
|
return input;
|
|
164
|
-
if (typeof input ===
|
|
164
|
+
if (typeof input === "string" || typeof input === "number") {
|
|
165
165
|
const date = new Date(input);
|
|
166
166
|
return date == null ? undefined : date;
|
|
167
167
|
}
|
|
168
168
|
return undefined;
|
|
169
169
|
}
|
|
170
170
|
// Bigint
|
|
171
|
-
if (targetType ===
|
|
172
|
-
if (typeof input ===
|
|
173
|
-
typeof input ===
|
|
174
|
-
typeof input ===
|
|
171
|
+
if (targetType === "bigint") {
|
|
172
|
+
if (typeof input === "string" ||
|
|
173
|
+
typeof input === "number" ||
|
|
174
|
+
typeof input === "boolean")
|
|
175
175
|
return BigInt(input);
|
|
176
176
|
return undefined;
|
|
177
177
|
}
|
|
178
178
|
// Boolean
|
|
179
|
-
if (targetType ===
|
|
180
|
-
if (typeof input ===
|
|
179
|
+
if (targetType === "boolean") {
|
|
180
|
+
if (typeof input === "string" || typeof input === "number") {
|
|
181
181
|
// Here are different with official definition
|
|
182
182
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
183
|
-
if (input ===
|
|
183
|
+
if (input === "0" || input === "false")
|
|
184
184
|
return false;
|
|
185
185
|
return Boolean(input);
|
|
186
186
|
}
|
|
187
187
|
return undefined;
|
|
188
188
|
}
|
|
189
189
|
// Number
|
|
190
|
-
if (targetType ===
|
|
190
|
+
if (targetType === "number") {
|
|
191
191
|
const number = Number(input);
|
|
192
192
|
return isNaN(number) ? undefined : number;
|
|
193
193
|
}
|
|
194
194
|
// String
|
|
195
|
-
if (targetType ===
|
|
195
|
+
if (targetType === "string") {
|
|
196
196
|
return String(input);
|
|
197
197
|
}
|
|
198
198
|
// Default
|
|
@@ -210,9 +210,8 @@ var DataTypes;
|
|
|
210
210
|
const value = convertByType(input, type);
|
|
211
211
|
if (value == null)
|
|
212
212
|
return undefined;
|
|
213
|
-
if (typeof value ===
|
|
214
|
-
if (enumType === DataTypes.CombinedEnum.Int ||
|
|
215
|
-
enumType === DataTypes.CombinedEnum.IntMoney)
|
|
213
|
+
if (typeof value === "number") {
|
|
214
|
+
if (enumType === DataTypes.CombinedEnum.Int || enumType === DataTypes.CombinedEnum.IntMoney)
|
|
216
215
|
return Math.round(value);
|
|
217
216
|
if (enumType === DataTypes.CombinedEnum.Money)
|
|
218
217
|
return Math.round(10000 * value) / 10000;
|
|
@@ -228,21 +227,21 @@ var DataTypes;
|
|
|
228
227
|
function getBasicName(enumType) {
|
|
229
228
|
switch (enumType) {
|
|
230
229
|
case DataTypes.CombinedEnum.Array:
|
|
231
|
-
return
|
|
230
|
+
return "unknown[]";
|
|
232
231
|
case DataTypes.CombinedEnum.Bigint:
|
|
233
|
-
return
|
|
232
|
+
return "bigint";
|
|
234
233
|
case DataTypes.CombinedEnum.Boolean:
|
|
235
|
-
return
|
|
234
|
+
return "boolean";
|
|
236
235
|
case DataTypes.CombinedEnum.Date:
|
|
237
236
|
case DataTypes.CombinedEnum.DateTime:
|
|
238
|
-
return
|
|
237
|
+
return "date";
|
|
239
238
|
case DataTypes.CombinedEnum.Number:
|
|
240
239
|
case DataTypes.CombinedEnum.Int:
|
|
241
240
|
case DataTypes.CombinedEnum.IntMoney:
|
|
242
241
|
case DataTypes.CombinedEnum.Money:
|
|
243
|
-
return
|
|
242
|
+
return "number";
|
|
244
243
|
default:
|
|
245
|
-
return
|
|
244
|
+
return "string";
|
|
246
245
|
}
|
|
247
246
|
}
|
|
248
247
|
DataTypes.getBasicName = getBasicName;
|
|
@@ -258,12 +257,12 @@ var DataTypes;
|
|
|
258
257
|
return undefined;
|
|
259
258
|
// Date
|
|
260
259
|
if (value instanceof Date) {
|
|
261
|
-
return isArray ?
|
|
260
|
+
return isArray ? "date[]" : "date";
|
|
262
261
|
}
|
|
263
262
|
// No array
|
|
264
263
|
// Other cases
|
|
265
264
|
const valueType = typeof value;
|
|
266
|
-
const typeName = isArray ? valueType +
|
|
265
|
+
const typeName = isArray ? valueType + "[]" : valueType;
|
|
267
266
|
if (!isBasicName(typeName))
|
|
268
267
|
return undefined;
|
|
269
268
|
return typeName;
|
|
@@ -320,9 +319,9 @@ var DataTypes;
|
|
|
320
319
|
* @returns Result
|
|
321
320
|
*/
|
|
322
321
|
function getListItemLabel(item) {
|
|
323
|
-
return
|
|
322
|
+
return "label" in item
|
|
324
323
|
? item.label
|
|
325
|
-
:
|
|
324
|
+
: "name" in item
|
|
326
325
|
? item.name
|
|
327
326
|
: item.title;
|
|
328
327
|
}
|
|
@@ -333,11 +332,11 @@ var DataTypes;
|
|
|
333
332
|
* @returns Result
|
|
334
333
|
*/
|
|
335
334
|
function getObjectItemLabel(item) {
|
|
336
|
-
return
|
|
335
|
+
return "label" in item
|
|
337
336
|
? `${item.label}`
|
|
338
|
-
:
|
|
337
|
+
: "name" in item
|
|
339
338
|
? `${item.name}`
|
|
340
|
-
:
|
|
339
|
+
: "title" in item
|
|
341
340
|
? `${item.title}`
|
|
342
341
|
: `${item}`;
|
|
343
342
|
}
|
|
@@ -349,7 +348,7 @@ var DataTypes;
|
|
|
349
348
|
* @returns Value
|
|
350
349
|
*/
|
|
351
350
|
function getValue(data, key) {
|
|
352
|
-
if (data != null && typeof key ===
|
|
351
|
+
if (data != null && typeof key === "string" && key in data) {
|
|
353
352
|
return Reflect.get(data, key);
|
|
354
353
|
}
|
|
355
354
|
return undefined;
|
|
@@ -375,7 +374,7 @@ var DataTypes;
|
|
|
375
374
|
const value = getValue(data, key);
|
|
376
375
|
if (value == null)
|
|
377
376
|
return undefined;
|
|
378
|
-
if (typeof value ===
|
|
377
|
+
if (typeof value === "number")
|
|
379
378
|
return value;
|
|
380
379
|
return `${value}`;
|
|
381
380
|
}
|
|
@@ -390,7 +389,7 @@ var DataTypes;
|
|
|
390
389
|
const value = getValue(data, key);
|
|
391
390
|
if (value == null)
|
|
392
391
|
return undefined;
|
|
393
|
-
if (typeof value ===
|
|
392
|
+
if (typeof value === "string")
|
|
394
393
|
return value;
|
|
395
394
|
return `${value}`;
|
|
396
395
|
}
|
|
@@ -411,7 +410,7 @@ var DataTypes;
|
|
|
411
410
|
* @returns Result
|
|
412
411
|
*/
|
|
413
412
|
function isSimpleObject(input, includeArray = true) {
|
|
414
|
-
return (typeof input ===
|
|
413
|
+
return (typeof input === "object" &&
|
|
415
414
|
input != null &&
|
|
416
415
|
Object.values(input).every((value) => isSimpleType(value, includeArray)));
|
|
417
416
|
}
|
|
@@ -440,7 +439,7 @@ var DataTypes;
|
|
|
440
439
|
}
|
|
441
440
|
// Other cases
|
|
442
441
|
const type = typeof input;
|
|
443
|
-
if (type ===
|
|
442
|
+
if (type === "function" || type === "object" || type === "symbol")
|
|
444
443
|
return false;
|
|
445
444
|
return true;
|
|
446
445
|
}
|
|
@@ -452,10 +451,10 @@ var DataTypes;
|
|
|
452
451
|
function jsonReplacer(replacer) {
|
|
453
452
|
const m = new Map();
|
|
454
453
|
return function (key, value) {
|
|
455
|
-
const path = m.get(this) + (Array.isArray(this) ? `[${key}]` :
|
|
454
|
+
const path = m.get(this) + (Array.isArray(this) ? `[${key}]` : "." + key);
|
|
456
455
|
if (value === Object(value))
|
|
457
456
|
m.set(value, path);
|
|
458
|
-
return replacer.call(this, key, value, path.replace(/undefined\.\.?/,
|
|
457
|
+
return replacer.call(this, key, value, path.replace(/undefined\.\.?/, ""));
|
|
459
458
|
};
|
|
460
459
|
}
|
|
461
460
|
DataTypes.jsonReplacer = jsonReplacer;
|
|
@@ -467,8 +466,8 @@ var DataTypes;
|
|
|
467
466
|
function jsonBigintReceiver(...args) {
|
|
468
467
|
return jsonReplacer(function (key, value, path) {
|
|
469
468
|
if ((args.includes(key) || args.includes(path)) &&
|
|
470
|
-
typeof value ===
|
|
471
|
-
if (value.endsWith(
|
|
469
|
+
typeof value === "string") {
|
|
470
|
+
if (value.endsWith("n"))
|
|
472
471
|
return BigInt(value.slice(0, -1));
|
|
473
472
|
else
|
|
474
473
|
return BigInt(value);
|
package/lib/cjs/DateUtils.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare namespace DateUtils {
|
|
|
37
37
|
/**
|
|
38
38
|
* Date format options
|
|
39
39
|
*/
|
|
40
|
-
type FormatOptions = Intl.DateTimeFormatOptions |
|
|
40
|
+
type FormatOptions = Intl.DateTimeFormatOptions | "d" | "dm" | "ds";
|
|
41
41
|
/**
|
|
42
42
|
* Format
|
|
43
43
|
* @param input Input date time
|
package/lib/cjs/DateUtils.js
CHANGED
|
@@ -40,25 +40,25 @@ var DateUtils;
|
|
|
40
40
|
* Day format, YYYY-MM-DD
|
|
41
41
|
*/
|
|
42
42
|
DateUtils.DayFormat = {
|
|
43
|
-
year:
|
|
44
|
-
month:
|
|
45
|
-
day:
|
|
43
|
+
year: "numeric",
|
|
44
|
+
month: "2-digit",
|
|
45
|
+
day: "2-digit"
|
|
46
46
|
};
|
|
47
47
|
/**
|
|
48
48
|
* Minute format, YYYY-MM-DD hh:mm
|
|
49
49
|
*/
|
|
50
50
|
DateUtils.MinuteFormat = {
|
|
51
51
|
...DateUtils.DayFormat,
|
|
52
|
-
hour:
|
|
53
|
-
hourCycle:
|
|
54
|
-
minute:
|
|
52
|
+
hour: "2-digit",
|
|
53
|
+
hourCycle: "h23",
|
|
54
|
+
minute: "2-digit"
|
|
55
55
|
};
|
|
56
56
|
/**
|
|
57
57
|
* Second format, YYYY-MM-DD hh:mm:ss
|
|
58
58
|
*/
|
|
59
59
|
DateUtils.SecondFormat = {
|
|
60
60
|
...DateUtils.MinuteFormat,
|
|
61
|
-
second:
|
|
61
|
+
second: "2-digit"
|
|
62
62
|
};
|
|
63
63
|
/**
|
|
64
64
|
* Format
|
|
@@ -79,13 +79,13 @@ var DateUtils;
|
|
|
79
79
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat
|
|
80
80
|
let opt;
|
|
81
81
|
switch (options) {
|
|
82
|
-
case
|
|
82
|
+
case "d":
|
|
83
83
|
opt = DateUtils.DayFormat;
|
|
84
84
|
break;
|
|
85
|
-
case
|
|
85
|
+
case "dm":
|
|
86
86
|
opt = DateUtils.MinuteFormat;
|
|
87
87
|
break;
|
|
88
|
-
case
|
|
88
|
+
case "ds":
|
|
89
89
|
opt = DateUtils.SecondFormat;
|
|
90
90
|
break;
|
|
91
91
|
default:
|
|
@@ -96,7 +96,7 @@ var DateUtils;
|
|
|
96
96
|
// Return format result
|
|
97
97
|
return new Intl.DateTimeFormat(locale, newOpt)
|
|
98
98
|
.format(parsed)
|
|
99
|
-
.replace(/,\s*/g,
|
|
99
|
+
.replace(/,\s*/g, " ");
|
|
100
100
|
}
|
|
101
101
|
DateUtils.format = format;
|
|
102
102
|
/**
|
|
@@ -106,32 +106,32 @@ var DateUtils;
|
|
|
106
106
|
*/
|
|
107
107
|
function formatForInput(date, hasSecondOrType) {
|
|
108
108
|
// Return when null
|
|
109
|
-
if (date == null || date ===
|
|
109
|
+
if (date == null || date === "")
|
|
110
110
|
return undefined;
|
|
111
111
|
// Parse string as date
|
|
112
|
-
const dt = typeof date ===
|
|
113
|
-
const hasSecond = typeof hasSecondOrType ===
|
|
114
|
-
? hasSecondOrType ===
|
|
112
|
+
const dt = typeof date === "string" ? new Date(date) : date;
|
|
113
|
+
const hasSecond = typeof hasSecondOrType === "string"
|
|
114
|
+
? hasSecondOrType === "date"
|
|
115
115
|
? undefined
|
|
116
116
|
: true
|
|
117
117
|
: hasSecondOrType;
|
|
118
118
|
// Parts
|
|
119
119
|
const parts = [
|
|
120
120
|
dt.getFullYear(),
|
|
121
|
-
(dt.getMonth() + 1).toString().padStart(2,
|
|
122
|
-
dt.getDate().toString().padStart(2,
|
|
121
|
+
(dt.getMonth() + 1).toString().padStart(2, "0"),
|
|
122
|
+
dt.getDate().toString().padStart(2, "0")
|
|
123
123
|
];
|
|
124
124
|
// Date
|
|
125
|
-
const d = parts.join(
|
|
125
|
+
const d = parts.join("-");
|
|
126
126
|
if (hasSecond == null)
|
|
127
127
|
return d;
|
|
128
128
|
const hm = [
|
|
129
|
-
dt.getHours().toString().padStart(2,
|
|
130
|
-
dt.getMinutes().toString().padStart(2,
|
|
129
|
+
dt.getHours().toString().padStart(2, "0"),
|
|
130
|
+
dt.getMinutes().toString().padStart(2, "0")
|
|
131
131
|
];
|
|
132
132
|
if (hasSecond)
|
|
133
|
-
hm.push(dt.getSeconds().toString().padStart(2,
|
|
134
|
-
return `${d}T${hm.join(
|
|
133
|
+
hm.push(dt.getSeconds().toString().padStart(2, "0"));
|
|
134
|
+
return `${d}T${hm.join(":")}`;
|
|
135
135
|
}
|
|
136
136
|
DateUtils.formatForInput = formatForInput;
|
|
137
137
|
/**
|
|
@@ -163,9 +163,9 @@ var DateUtils;
|
|
|
163
163
|
*/
|
|
164
164
|
DateUtils.jsonParser = (keys) => {
|
|
165
165
|
return function (key, value) {
|
|
166
|
-
if (typeof value ===
|
|
166
|
+
if (typeof value === "string" &&
|
|
167
167
|
value != null &&
|
|
168
|
-
value !==
|
|
168
|
+
value !== "" &&
|
|
169
169
|
keys.includes(key)) {
|
|
170
170
|
const parsedDate = parse(value);
|
|
171
171
|
if (parsedDate != null)
|
|
@@ -183,9 +183,9 @@ var DateUtils;
|
|
|
183
183
|
function parse(input) {
|
|
184
184
|
if (input == null)
|
|
185
185
|
return undefined;
|
|
186
|
-
if (typeof input ===
|
|
186
|
+
if (typeof input === "string") {
|
|
187
187
|
const f = input[0];
|
|
188
|
-
if (f >=
|
|
188
|
+
if (f >= "0" && f <= "9" && /[-\/\s]/g.test(input)) {
|
|
189
189
|
const n = Date.parse(input);
|
|
190
190
|
if (!isNaN(n))
|
|
191
191
|
return new Date(n);
|
|
@@ -220,8 +220,7 @@ var DateUtils;
|
|
|
220
220
|
d2 = parse(d2);
|
|
221
221
|
if (d1 == null || d2 == null)
|
|
222
222
|
return false;
|
|
223
|
-
return (d1.getFullYear() === d2.getFullYear() &&
|
|
224
|
-
d1.getMonth() === d2.getMonth());
|
|
223
|
+
return (d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth());
|
|
225
224
|
}
|
|
226
225
|
DateUtils.sameMonth = sameMonth;
|
|
227
226
|
})(DateUtils || (exports.DateUtils = DateUtils = {}));
|
package/lib/cjs/DomUtils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DataTypes } from
|
|
2
|
-
import { ErrorData, ErrorType } from
|
|
3
|
-
import { FormDataFieldValue, IFormData } from
|
|
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
|