@etsoo/shared 1.2.58 → 1.2.60

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/README.md CHANGED
@@ -173,6 +173,7 @@ Data type definitions and type safe functions. ListItemType, ListItemType1 and L
173
173
  | StringDictionary | String key, string value Record |
174
174
  | StringRecord | String key, unknown value Record |
175
175
  | TitleDefaultType | Title default type |
176
+ | TristateEnum | Tristate enum |
176
177
  | VAlign | Vertical align |
177
178
  | VAlignEnum | Vertical align enum |
178
179
  | Methods | |
@@ -283,6 +283,27 @@ export declare namespace DataTypes {
283
283
  type DIS<K extends string, T> = {
284
284
  [P in K]: T;
285
285
  };
286
+ /**
287
+ * Tristate enum
288
+ * 三态枚举
289
+ */
290
+ enum TristateEnum {
291
+ /**
292
+ * False
293
+ * 假
294
+ */
295
+ False = 0,
296
+ /**
297
+ * True
298
+ * 真
299
+ */
300
+ True = 1,
301
+ /**
302
+ * Unsure
303
+ * 无法判断
304
+ */
305
+ Unsure = 9
306
+ }
286
307
  /**
287
308
  * Convert value to target type
288
309
  * @param input Input value
@@ -98,6 +98,28 @@ var DataTypes;
98
98
  PlacementEnum[PlacementEnum["BottomRight"] = 8] = "BottomRight";
99
99
  PlacementEnum[PlacementEnum["Unknown"] = 9] = "Unknown"; // Reserved for modal, only one instance held at the same time
100
100
  })(PlacementEnum = DataTypes.PlacementEnum || (DataTypes.PlacementEnum = {}));
101
+ /**
102
+ * Tristate enum
103
+ * 三态枚举
104
+ */
105
+ let TristateEnum;
106
+ (function (TristateEnum) {
107
+ /**
108
+ * False
109
+ * 假
110
+ */
111
+ TristateEnum[TristateEnum["False"] = 0] = "False";
112
+ /**
113
+ * True
114
+ * 真
115
+ */
116
+ TristateEnum[TristateEnum["True"] = 1] = "True";
117
+ /**
118
+ * Unsure
119
+ * 无法判断
120
+ */
121
+ TristateEnum[TristateEnum["Unsure"] = 9] = "Unsure";
122
+ })(TristateEnum = DataTypes.TristateEnum || (DataTypes.TristateEnum = {}));
101
123
  /**
102
124
  * Convert value to target type
103
125
  * @param input Input value
@@ -176,9 +176,10 @@ export declare namespace Utils {
176
176
  export const getResult: <R, T = R | DataTypes.Func<R>>(input: T, ...args: T extends DataTypes.Func<R> ? Parameters<typeof input> : never | []) => T extends DataTypes.Func<R> ? ReturnType<T> : T;
177
177
  /**
178
178
  * Get time zone
179
+ * @param tz Default timezone, default is UTC
179
180
  * @returns Timezone
180
181
  */
181
- export const getTimeZone: () => string | undefined;
182
+ export const getTimeZone: (tz?: string) => string;
182
183
  /**
183
184
  * Is digits string
184
185
  * @param input Input string
package/lib/cjs/Utils.js CHANGED
@@ -343,12 +343,15 @@ var Utils;
343
343
  };
344
344
  /**
345
345
  * Get time zone
346
+ * @param tz Default timezone, default is UTC
346
347
  * @returns Timezone
347
348
  */
348
- Utils.getTimeZone = () => {
349
+ Utils.getTimeZone = (tz) => {
349
350
  // If Intl supported
350
351
  if (typeof Intl === "object" && typeof Intl.DateTimeFormat === "function")
351
352
  return Intl.DateTimeFormat().resolvedOptions().timeZone;
353
+ // Default timezone
354
+ return tz ?? "UTC";
352
355
  };
353
356
  /**
354
357
  * Is digits string
@@ -283,6 +283,27 @@ export declare namespace DataTypes {
283
283
  type DIS<K extends string, T> = {
284
284
  [P in K]: T;
285
285
  };
286
+ /**
287
+ * Tristate enum
288
+ * 三态枚举
289
+ */
290
+ enum TristateEnum {
291
+ /**
292
+ * False
293
+ * 假
294
+ */
295
+ False = 0,
296
+ /**
297
+ * True
298
+ * 真
299
+ */
300
+ True = 1,
301
+ /**
302
+ * Unsure
303
+ * 无法判断
304
+ */
305
+ Unsure = 9
306
+ }
286
307
  /**
287
308
  * Convert value to target type
288
309
  * @param input Input value
@@ -95,6 +95,28 @@ export var DataTypes;
95
95
  PlacementEnum[PlacementEnum["BottomRight"] = 8] = "BottomRight";
96
96
  PlacementEnum[PlacementEnum["Unknown"] = 9] = "Unknown"; // Reserved for modal, only one instance held at the same time
97
97
  })(PlacementEnum = DataTypes.PlacementEnum || (DataTypes.PlacementEnum = {}));
98
+ /**
99
+ * Tristate enum
100
+ * 三态枚举
101
+ */
102
+ let TristateEnum;
103
+ (function (TristateEnum) {
104
+ /**
105
+ * False
106
+ * 假
107
+ */
108
+ TristateEnum[TristateEnum["False"] = 0] = "False";
109
+ /**
110
+ * True
111
+ * 真
112
+ */
113
+ TristateEnum[TristateEnum["True"] = 1] = "True";
114
+ /**
115
+ * Unsure
116
+ * 无法判断
117
+ */
118
+ TristateEnum[TristateEnum["Unsure"] = 9] = "Unsure";
119
+ })(TristateEnum = DataTypes.TristateEnum || (DataTypes.TristateEnum = {}));
98
120
  /**
99
121
  * Convert value to target type
100
122
  * @param input Input value
@@ -176,9 +176,10 @@ export declare namespace Utils {
176
176
  export const getResult: <R, T = R | DataTypes.Func<R>>(input: T, ...args: T extends DataTypes.Func<R> ? Parameters<typeof input> : never | []) => T extends DataTypes.Func<R> ? ReturnType<T> : T;
177
177
  /**
178
178
  * Get time zone
179
+ * @param tz Default timezone, default is UTC
179
180
  * @returns Timezone
180
181
  */
181
- export const getTimeZone: () => string | undefined;
182
+ export const getTimeZone: (tz?: string) => string;
182
183
  /**
183
184
  * Is digits string
184
185
  * @param input Input string
package/lib/mjs/Utils.js CHANGED
@@ -337,12 +337,15 @@ export var Utils;
337
337
  };
338
338
  /**
339
339
  * Get time zone
340
+ * @param tz Default timezone, default is UTC
340
341
  * @returns Timezone
341
342
  */
342
- Utils.getTimeZone = () => {
343
+ Utils.getTimeZone = (tz) => {
343
344
  // If Intl supported
344
345
  if (typeof Intl === "object" && typeof Intl.DateTimeFormat === "function")
345
346
  return Intl.DateTimeFormat().resolvedOptions().timeZone;
347
+ // Default timezone
348
+ return tz ?? "UTC";
346
349
  };
347
350
  /**
348
351
  * Is digits string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/shared",
3
- "version": "1.2.58",
3
+ "version": "1.2.60",
4
4
  "description": "TypeScript shared utilities and functions",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -40,7 +40,7 @@
40
40
  "@vitejs/plugin-react": "^4.3.4",
41
41
  "jsdom": "^26.0.0",
42
42
  "typescript": "^5.7.3",
43
- "vitest": "^2.1.8"
43
+ "vitest": "^3.0.4"
44
44
  },
45
45
  "dependencies": {
46
46
  "lodash.isequal": "^4.5.0"
package/src/DataTypes.ts CHANGED
@@ -356,6 +356,30 @@ export namespace DataTypes {
356
356
  */
357
357
  export type DIS<K extends string, T> = { [P in K]: T };
358
358
 
359
+ /**
360
+ * Tristate enum
361
+ * 三态枚举
362
+ */
363
+ export enum TristateEnum {
364
+ /**
365
+ * False
366
+ * 假
367
+ */
368
+ False = 0,
369
+
370
+ /**
371
+ * True
372
+ * 真
373
+ */
374
+ True = 1,
375
+
376
+ /**
377
+ * Unsure
378
+ * 无法判断
379
+ */
380
+ Unsure = 9
381
+ }
382
+
359
383
  /**
360
384
  * Convert value to target type
361
385
  * @param input Input value
package/src/Utils.ts CHANGED
@@ -504,12 +504,16 @@ export namespace Utils {
504
504
 
505
505
  /**
506
506
  * Get time zone
507
+ * @param tz Default timezone, default is UTC
507
508
  * @returns Timezone
508
509
  */
509
- export const getTimeZone = () => {
510
+ export const getTimeZone = (tz?: string) => {
510
511
  // If Intl supported
511
512
  if (typeof Intl === "object" && typeof Intl.DateTimeFormat === "function")
512
513
  return Intl.DateTimeFormat().resolvedOptions().timeZone;
514
+
515
+ // Default timezone
516
+ return tz ?? "UTC";
513
517
  };
514
518
 
515
519
  /**