@etsoo/shared 1.2.57 → 1.2.59
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 +257 -240
- package/__tests__/Utils.ts +2 -1
- package/__tests__/tsconfig.json +1 -1
- package/lib/cjs/DataTypes.d.ts +21 -0
- package/lib/cjs/DataTypes.js +22 -0
- package/lib/cjs/Utils.d.ts +39 -37
- package/lib/cjs/Utils.js +3 -2
- package/lib/mjs/DataTypes.d.ts +21 -0
- package/lib/mjs/DataTypes.js +22 -0
- package/lib/mjs/Utils.d.ts +39 -37
- package/lib/mjs/Utils.js +3 -2
- package/package.json +2 -2
- package/src/DataTypes.ts +24 -0
- package/src/Utils.ts +6 -4
- package/tsconfig.cjs.json +1 -1
- package/tsconfig.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# Shared
|
|
2
|
+
|
|
2
3
|
**TypeScript shared utilities and functions.**
|
|
3
4
|
|
|
4
5
|
## Installing
|
|
@@ -16,303 +17,319 @@ $ yarn add @etsoo/shared
|
|
|
16
17
|
```
|
|
17
18
|
|
|
18
19
|
## ActionResult / IActionResult, IdActionResult, MsgActionResult, IdMsgActionResult, DynamicActionResult
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
20
|
+
|
|
21
|
+
| Name | Description |
|
|
22
|
+
| ------------: | -------------------------- |
|
|
23
|
+
| static create | Create a result from error |
|
|
24
|
+
| data | Result data |
|
|
25
|
+
| detail | Details |
|
|
26
|
+
| errors | Result errors |
|
|
27
|
+
| field | Related field |
|
|
28
|
+
| ok | Success or failure |
|
|
29
|
+
| status | Status code |
|
|
30
|
+
| title | Title |
|
|
31
|
+
| traceId | Trace id |
|
|
32
|
+
| type | Type |
|
|
31
33
|
|
|
32
34
|
## storage
|
|
35
|
+
|
|
33
36
|
Storage interface and browser storage implementation
|
|
34
37
|
|
|
35
38
|
## ContentDisposition
|
|
39
|
+
|
|
36
40
|
Content disposition of HTTP
|
|
37
41
|
|
|
38
|
-
|Name|Description|
|
|
39
|
-
|
|
40
|
-
|static parse|Parse header value|
|
|
41
|
-
|Methods
|
|
42
|
-
|format|Format to standard output|
|
|
42
|
+
| Name | Description |
|
|
43
|
+
| -----------: | ------------------------- |
|
|
44
|
+
| static parse | Parse header value |
|
|
45
|
+
| Methods | |
|
|
46
|
+
| format | Format to standard output |
|
|
43
47
|
|
|
44
48
|
## DataError
|
|
49
|
+
|
|
45
50
|
Error with custom data
|
|
46
51
|
|
|
47
52
|
## EColor
|
|
53
|
+
|
|
48
54
|
Etsoo implmented Color
|
|
49
55
|
|
|
50
|
-
|Name|Description|
|
|
51
|
-
|
|
52
|
-
|static getColors|Get HEX or RGB colors|
|
|
53
|
-
|static getEColors|Get EColors|
|
|
54
|
-
|static parse|Parse HTML color to EColor|
|
|
55
|
-
|Methods
|
|
56
|
-
|clone|Clone color with adjustments|
|
|
57
|
-
|getContrastRatio|Get contrast ratio, a value between 0 and 1|
|
|
58
|
-
|getDeltaValue|Get Delta value (perceptible by human eyes)|
|
|
59
|
-
|getLuminance|Get luminance|
|
|
60
|
-
|toHEXColor|To HEX color string|
|
|
61
|
-
|toLabValue|To Lab value|
|
|
62
|
-
|toRGBColor|To RGB color string|
|
|
56
|
+
| Name | Description |
|
|
57
|
+
| ----------------: | ------------------------------------------- |
|
|
58
|
+
| static getColors | Get HEX or RGB colors |
|
|
59
|
+
| static getEColors | Get EColors |
|
|
60
|
+
| static parse | Parse HTML color to EColor |
|
|
61
|
+
| Methods | |
|
|
62
|
+
| clone | Clone color with adjustments |
|
|
63
|
+
| getContrastRatio | Get contrast ratio, a value between 0 and 1 |
|
|
64
|
+
| getDeltaValue | Get Delta value (perceptible by human eyes) |
|
|
65
|
+
| getLuminance | Get luminance |
|
|
66
|
+
| toHEXColor | To HEX color string |
|
|
67
|
+
| toLabValue | To Lab value |
|
|
68
|
+
| toRGBColor | To RGB color string |
|
|
63
69
|
|
|
64
70
|
## EventClass
|
|
71
|
+
|
|
65
72
|
Etsoo implmented abstract Event Class
|
|
66
73
|
|
|
67
|
-
|Name|Description|
|
|
68
|
-
|
|
69
|
-
|hasEvents|Has specific type and callback events|
|
|
70
|
-
|off|Remove specific type and callback event|
|
|
71
|
-
|on|Add event listener|
|
|
72
|
-
|trigger|Trigger event|
|
|
74
|
+
| Name | Description |
|
|
75
|
+
| --------: | --------------------------------------- |
|
|
76
|
+
| hasEvents | Has specific type and callback events |
|
|
77
|
+
| off | Remove specific type and callback event |
|
|
78
|
+
| on | Add event listener |
|
|
79
|
+
| trigger | Trigger event |
|
|
73
80
|
|
|
74
81
|
## Keyboard
|
|
82
|
+
|
|
75
83
|
Keyboard keys and codes
|
|
76
84
|
|
|
77
|
-
|Name|Description|
|
|
78
|
-
|
|
79
|
-
|Keys|KeyboardEvent.key constants|
|
|
80
|
-
|Codes|KeyboardEvent.code constants|
|
|
85
|
+
| Name | Description |
|
|
86
|
+
| ----: | ---------------------------- |
|
|
87
|
+
| Keys | KeyboardEvent.key constants |
|
|
88
|
+
| Codes | KeyboardEvent.code constants |
|
|
81
89
|
|
|
82
90
|
|isTypingContent|Is typing content or press command key|
|
|
83
91
|
|
|
84
92
|
## EHistory
|
|
93
|
+
|
|
85
94
|
ETSOO Extended abstract history class
|
|
86
95
|
|
|
87
|
-
|Name|Description|
|
|
88
|
-
|
|
89
|
-
|index|Current index|
|
|
90
|
-
|length|States length|
|
|
91
|
-
|state|Current state|
|
|
92
|
-
|states|States|
|
|
93
|
-
|Methods
|
|
94
|
-
|back|Back to the previous state|
|
|
95
|
-
|clear|Clear all states but keep event listeners|
|
|
96
|
-
|forward|Forward to the next state|
|
|
97
|
-
|getStatus|Get [undo, redo] status|
|
|
98
|
-
|go|Go to the specific state|
|
|
99
|
-
|pushState|Adds an entry to the history stack|
|
|
100
|
-
|replaceState|Modifies the current history entry|
|
|
96
|
+
| Name | Description |
|
|
97
|
+
| -----------: | ----------------------------------------- |
|
|
98
|
+
| index | Current index |
|
|
99
|
+
| length | States length |
|
|
100
|
+
| state | Current state |
|
|
101
|
+
| states | States |
|
|
102
|
+
| Methods | |
|
|
103
|
+
| back | Back to the previous state |
|
|
104
|
+
| clear | Clear all states but keep event listeners |
|
|
105
|
+
| forward | Forward to the next state |
|
|
106
|
+
| getStatus | Get [undo, redo] status |
|
|
107
|
+
| go | Go to the specific state |
|
|
108
|
+
| pushState | Adds an entry to the history stack |
|
|
109
|
+
| replaceState | Modifies the current history entry |
|
|
101
110
|
|
|
102
111
|
## ArrayUtils
|
|
112
|
+
|
|
103
113
|
Array related utilities
|
|
104
114
|
|
|
105
|
-
|Name|Description|
|
|
106
|
-
|
|
107
|
-
|differences|Array 1 items do not exist in Array 2 or reverse match|
|
|
108
|
-
|max|Get max number item or number item property|
|
|
109
|
-
|maxItem|Get max field value item|
|
|
110
|
-
|min|Get min number item or number item property|
|
|
111
|
-
|minItem|Get min field value item|
|
|
112
|
-
|remove|Remove items by value or condition|
|
|
113
|
-
|sum|Sum number items or number item properties|
|
|
114
|
-
|toUnique|Make all items are unique|
|
|
115
|
+
| Name | Description |
|
|
116
|
+
| ----------: | ------------------------------------------------------ |
|
|
117
|
+
| differences | Array 1 items do not exist in Array 2 or reverse match |
|
|
118
|
+
| max | Get max number item or number item property |
|
|
119
|
+
| maxItem | Get max field value item |
|
|
120
|
+
| min | Get min number item or number item property |
|
|
121
|
+
| minItem | Get min field value item |
|
|
122
|
+
| remove | Remove items by value or condition |
|
|
123
|
+
| sum | Sum number items or number item properties |
|
|
124
|
+
| toUnique | Make all items are unique |
|
|
115
125
|
|
|
116
126
|
## DataTypes
|
|
117
|
-
Data type definitions and type safe functions. ListItemType, ListItemType1 and ListItemType2 are sugar types.
|
|
118
127
|
|
|
119
|
-
|
|
120
|
-
|---:|---|
|
|
121
|
-
|DataType|Data type enum|
|
|
122
|
-
|AddAndEditType|Add and edit data type|
|
|
123
|
-
|AddOrEditType|Add or edit conditional type|
|
|
124
|
-
|addUrlParam|Add parameter to URL|
|
|
125
|
-
|addUrlParams|Add parameters to URL|
|
|
126
|
-
|Basic|Basic types, includes number, bigint, Date, boolean, string|
|
|
127
|
-
|BasicArray|Basic type name array|
|
|
128
|
-
|BasicConditional|Conditional type based on BasicNames|
|
|
129
|
-
|BasicNames|Basic type and basic type array names array|
|
|
130
|
-
|BasicTemplate|Basic type template|
|
|
131
|
-
|BasicTemplateType|Basic template type|
|
|
132
|
-
|CombinedEnum|Combined type enum|
|
|
133
|
-
|CultureDefinition|Culture definition|
|
|
134
|
-
|DI|Dynamic interface with multiple properties|
|
|
135
|
-
|DIS|Dynamic interface with single property|
|
|
136
|
-
|EnumBase|Enum base type|
|
|
137
|
-
|EnumValue|Enum value type|
|
|
138
|
-
|ExtendedEnum|Extended type enum|
|
|
139
|
-
|Func<R>|Function type, R is return type|
|
|
140
|
-
|HAlign|Horizontal align|
|
|
141
|
-
|HAlignEnum|Horizontal align enum|
|
|
142
|
-
|IdDefaultType|Id default type|
|
|
143
|
-
|IdType|Number and string combination id type|
|
|
144
|
-
|IdItem|Item with id or id generator|
|
|
145
|
-
|IdLabelItem|Item with id and label|
|
|
146
|
-
|IdLabelType|Item with id and label dynamic type|
|
|
147
|
-
|IdNameItem|Item with id and name|
|
|
148
|
-
|IdTitleItem|Item with id and title|
|
|
149
|
-
|KeyCollection|Key collection, like { key1: {}, key2: {} }|
|
|
150
|
-
|Keys|Get specific type keys|
|
|
151
|
-
|LabelDefaultType|Label default type|
|
|
152
|
-
|MConstructor|Mixins constructor|
|
|
153
|
-
|ObjType|Generic object type|
|
|
154
|
-
|Optional|Make properties optional|
|
|
155
|
-
|PlacementEnum|Placement enum|
|
|
156
|
-
|Placement|Placement type|
|
|
157
|
-
|RequireAtLeastOne|Require at least one property of the keys|
|
|
158
|
-
|Simple|Basic or basic array type|
|
|
159
|
-
|SimpleEnum|Simple type enum|
|
|
160
|
-
|SimpleNames|Simple type names|
|
|
161
|
-
|SimpleObject|Simple object, string key, simple type and null value Record|
|
|
162
|
-
|StringDictionary|String key, string value Record|
|
|
163
|
-
|StringRecord|String key, unknown value Record|
|
|
164
|
-
|TitleDefaultType|Title default type|
|
|
165
|
-
|VAlign|Vertical align|
|
|
166
|
-
|VAlignEnum|Vertical align enum|
|
|
167
|
-
|Methods||
|
|
168
|
-
|convert|Convert value to target type|
|
|
169
|
-
|convertByType|Convert by type name like 'string'|
|
|
170
|
-
|convertSimple|Convert value to target enum type|
|
|
171
|
-
|getBasicName|Get basic type name from Enum type|
|
|
172
|
-
|getBasicNameByValue|Get value's basic type name|
|
|
173
|
-
|getEnumByKey|Get enum item from key|
|
|
174
|
-
|getEnumByValue|Get enum item from value|
|
|
175
|
-
|getEnumKey|Get enum string literal type value|
|
|
176
|
-
|getEnumKeys|Get Enum keys|
|
|
177
|
-
|getListItemLabel|Get ListType2 item label|
|
|
178
|
-
|getIdValue|Get object id field value|
|
|
179
|
-
|getIdValue1|Get object id field value 1|
|
|
180
|
-
|getObjectItemLabel|Get object item label|
|
|
181
|
-
|getResult|Get input function or value result|
|
|
182
|
-
|getStringValue|Get object string field value|
|
|
183
|
-
|getValue|Get object field value|
|
|
184
|
-
|isBasicName|Check the type is a basic type or not (type guard)|
|
|
185
|
-
|isSimpleObject|Is the target a simple object, all values are simple type (Type guard)|
|
|
186
|
-
|isSimpleType|Is the input value simple type, include null and undefined|
|
|
187
|
-
|jsonReplacer|JSON.stringify replacer with full path|
|
|
128
|
+
Data type definitions and type safe functions. ListItemType, ListItemType1 and ListItemType2 are sugar types.
|
|
188
129
|
|
|
130
|
+
| Name | Description |
|
|
131
|
+
| ------------------: | ---------------------------------------------------------------------- |
|
|
132
|
+
| DataType | Data type enum |
|
|
133
|
+
| AddAndEditType | Add and edit data type |
|
|
134
|
+
| AddOrEditType | Add or edit conditional type |
|
|
135
|
+
| addUrlParam | Add parameter to URL |
|
|
136
|
+
| addUrlParams | Add parameters to URL |
|
|
137
|
+
| Basic | Basic types, includes number, bigint, Date, boolean, string |
|
|
138
|
+
| BasicArray | Basic type name array |
|
|
139
|
+
| BasicConditional | Conditional type based on BasicNames |
|
|
140
|
+
| BasicNames | Basic type and basic type array names array |
|
|
141
|
+
| BasicTemplate | Basic type template |
|
|
142
|
+
| BasicTemplateType | Basic template type |
|
|
143
|
+
| CombinedEnum | Combined type enum |
|
|
144
|
+
| CultureDefinition | Culture definition |
|
|
145
|
+
| DI | Dynamic interface with multiple properties |
|
|
146
|
+
| DIS | Dynamic interface with single property |
|
|
147
|
+
| EnumBase | Enum base type |
|
|
148
|
+
| EnumValue | Enum value type |
|
|
149
|
+
| ExtendedEnum | Extended type enum |
|
|
150
|
+
| Func<R> | Function type, R is return type |
|
|
151
|
+
| HAlign | Horizontal align |
|
|
152
|
+
| HAlignEnum | Horizontal align enum |
|
|
153
|
+
| IdDefaultType | Id default type |
|
|
154
|
+
| IdType | Number and string combination id type |
|
|
155
|
+
| IdItem | Item with id or id generator |
|
|
156
|
+
| IdLabelItem | Item with id and label |
|
|
157
|
+
| IdLabelType | Item with id and label dynamic type |
|
|
158
|
+
| IdNameItem | Item with id and name |
|
|
159
|
+
| IdTitleItem | Item with id and title |
|
|
160
|
+
| KeyCollection | Key collection, like { key1: {}, key2: {} } |
|
|
161
|
+
| Keys | Get specific type keys |
|
|
162
|
+
| LabelDefaultType | Label default type |
|
|
163
|
+
| MConstructor | Mixins constructor |
|
|
164
|
+
| ObjType | Generic object type |
|
|
165
|
+
| Optional | Make properties optional |
|
|
166
|
+
| PlacementEnum | Placement enum |
|
|
167
|
+
| Placement | Placement type |
|
|
168
|
+
| RequireAtLeastOne | Require at least one property of the keys |
|
|
169
|
+
| Simple | Basic or basic array type |
|
|
170
|
+
| SimpleEnum | Simple type enum |
|
|
171
|
+
| SimpleNames | Simple type names |
|
|
172
|
+
| SimpleObject | Simple object, string key, simple type and null value Record |
|
|
173
|
+
| StringDictionary | String key, string value Record |
|
|
174
|
+
| StringRecord | String key, unknown value Record |
|
|
175
|
+
| TitleDefaultType | Title default type |
|
|
176
|
+
| TristateEnum | Tristate enum |
|
|
177
|
+
| VAlign | Vertical align |
|
|
178
|
+
| VAlignEnum | Vertical align enum |
|
|
179
|
+
| Methods | |
|
|
180
|
+
| convert | Convert value to target type |
|
|
181
|
+
| convertByType | Convert by type name like 'string' |
|
|
182
|
+
| convertSimple | Convert value to target enum type |
|
|
183
|
+
| getBasicName | Get basic type name from Enum type |
|
|
184
|
+
| getBasicNameByValue | Get value's basic type name |
|
|
185
|
+
| getEnumByKey | Get enum item from key |
|
|
186
|
+
| getEnumByValue | Get enum item from value |
|
|
187
|
+
| getEnumKey | Get enum string literal type value |
|
|
188
|
+
| getEnumKeys | Get Enum keys |
|
|
189
|
+
| getListItemLabel | Get ListType2 item label |
|
|
190
|
+
| getIdValue | Get object id field value |
|
|
191
|
+
| getIdValue1 | Get object id field value 1 |
|
|
192
|
+
| getObjectItemLabel | Get object item label |
|
|
193
|
+
| getResult | Get input function or value result |
|
|
194
|
+
| getStringValue | Get object string field value |
|
|
195
|
+
| getValue | Get object field value |
|
|
196
|
+
| isBasicName | Check the type is a basic type or not (type guard) |
|
|
197
|
+
| isSimpleObject | Is the target a simple object, all values are simple type (Type guard) |
|
|
198
|
+
| isSimpleType | Is the input value simple type, include null and undefined |
|
|
199
|
+
| jsonReplacer | JSON.stringify replacer with full path |
|
|
189
200
|
|
|
190
201
|
## DateUtils
|
|
202
|
+
|
|
191
203
|
Dates related utilities
|
|
192
204
|
|
|
193
|
-
|Name|Description|
|
|
194
|
-
|
|
195
|
-
|DayFormat|YYYY-MM-DD|
|
|
196
|
-
|MinuteFormat|YYYY-MM-DD hh:mm|
|
|
197
|
-
|SecondFormat|YYYY-MM-DD hh:mm:ss|
|
|
198
|
-
|Methods
|
|
199
|
-
|getDays|Get month's days|
|
|
200
|
-
|forma|Format dates|
|
|
201
|
-
|formatForInput|Format to 'yyyy-MM-dd' or 'yyyy-MM-ddThh:mm:ss, especially used for date input min/max property|
|
|
202
|
-
|jsonParser|JSON parser|
|
|
203
|
-
|parse|Parse string to date|
|
|
204
|
-
|sameDay|Two dates are in the same day|
|
|
205
|
-
|sameMonth|Two dates are in the same month|
|
|
206
|
-
|substract|Date extended method, substract a date|
|
|
205
|
+
| Name | Description |
|
|
206
|
+
| -------------: | ----------------------------------------------------------------------------------------------- |
|
|
207
|
+
| DayFormat | YYYY-MM-DD |
|
|
208
|
+
| MinuteFormat | YYYY-MM-DD hh:mm |
|
|
209
|
+
| SecondFormat | YYYY-MM-DD hh:mm:ss |
|
|
210
|
+
| Methods | |
|
|
211
|
+
| getDays | Get month's days |
|
|
212
|
+
| forma | Format dates |
|
|
213
|
+
| formatForInput | Format to 'yyyy-MM-dd' or 'yyyy-MM-ddThh:mm:ss, especially used for date input min/max property |
|
|
214
|
+
| jsonParser | JSON parser |
|
|
215
|
+
| parse | Parse string to date |
|
|
216
|
+
| sameDay | Two dates are in the same day |
|
|
217
|
+
| sameMonth | Two dates are in the same month |
|
|
218
|
+
| substract | Date extended method, substract a date |
|
|
207
219
|
|
|
208
220
|
## DomUtils
|
|
221
|
+
|
|
209
222
|
DOM/window related utilities
|
|
210
223
|
|
|
211
|
-
|Name|Description|
|
|
212
|
-
|
|
213
|
-
|clearFormData|Clear form data|
|
|
214
|
-
|CultureMatch|Culture match case Enum|
|
|
215
|
-
|dataAs|Cast data as template format|
|
|
216
|
-
|detectedCountry|Current detected country|
|
|
217
|
-
|detectedCulture|Current detected culture|
|
|
218
|
-
|dimensionEqual|Check two rectangles equality|
|
|
219
|
-
|downloadFile|Download file from API fetch response body|
|
|
220
|
-
|en|Get English resources definition|
|
|
221
|
-
|fileToDataURL|File to data URL|
|
|
222
|
-
|formDataToObject|Form data to object|
|
|
223
|
-
|getCulture|Get the available culture definition|
|
|
224
|
-
|getDataChanges|Get data changed fields with input data updated|
|
|
225
|
-
|getInputValue|Get input value depending on its type|
|
|
226
|
-
|getLocationKey|Get an unique key combined with current URL|
|
|
227
|
-
|headersToObject|Convert headers to object|
|
|
228
|
-
|isFormData|Is IFormData type guard|
|
|
229
|
-
|isJSONContentType|Is JSON content type|
|
|
230
|
-
|isWechatClient|Is Wechat client|
|
|
231
|
-
|mergeFormData|Merge form data to primary one|
|
|
232
|
-
|mergeURLSearchParams|Merge URL search parameters|
|
|
233
|
-
|parseUserAgent|parseUserAgent|
|
|
234
|
-
|setFocus|Set HTML element focus by name|
|
|
235
|
-
|setupLogging|Setup frontend logging|
|
|
236
|
-
|verifyPermission|Verify file system permission|
|
|
237
|
-
|zhHans|Get simplified Chinese resources definition|
|
|
238
|
-
|zhHant|Get traditional Chinese resources definition|
|
|
224
|
+
| Name | Description |
|
|
225
|
+
| -------------------: | ----------------------------------------------------------------------- |
|
|
226
|
+
| clearFormData | Clear form data |
|
|
227
|
+
| CultureMatch | Culture match case Enum |
|
|
228
|
+
| dataAs | Cast data as template format |
|
|
229
|
+
| detectedCountry | Current detected country |
|
|
230
|
+
| detectedCulture | Current detected culture |
|
|
231
|
+
| dimensionEqual | Check two rectangles equality |
|
|
232
|
+
| downloadFile | Download file from API fetch response body |
|
|
233
|
+
| en | Get English resources definition |
|
|
234
|
+
| fileToDataURL | File to data URL |
|
|
235
|
+
| formDataToObject | Form data to object |
|
|
236
|
+
| getCulture | Get the available culture definition |
|
|
237
|
+
| getDataChanges | Get data changed fields (ignored changedFields) with input data updated |
|
|
238
|
+
| getInputValue | Get input value depending on its type |
|
|
239
|
+
| getLocationKey | Get an unique key combined with current URL |
|
|
240
|
+
| headersToObject | Convert headers to object |
|
|
241
|
+
| isFormData | Is IFormData type guard |
|
|
242
|
+
| isJSONContentType | Is JSON content type |
|
|
243
|
+
| isWechatClient | Is Wechat client |
|
|
244
|
+
| mergeFormData | Merge form data to primary one |
|
|
245
|
+
| mergeURLSearchParams | Merge URL search parameters |
|
|
246
|
+
| parseUserAgent | parseUserAgent |
|
|
247
|
+
| setFocus | Set HTML element focus by name |
|
|
248
|
+
| setupLogging | Setup frontend logging |
|
|
249
|
+
| verifyPermission | Verify file system permission |
|
|
250
|
+
| zhHans | Get simplified Chinese resources definition |
|
|
251
|
+
| zhHant | Get traditional Chinese resources definition |
|
|
239
252
|
|
|
240
253
|
## ExtendUtils
|
|
254
|
+
|
|
241
255
|
Extend current class/object functioning
|
|
242
256
|
|
|
243
|
-
|Name|Description|
|
|
244
|
-
|
|
245
|
-
|applyMixins|Apply mixins to current class|
|
|
246
|
-
|delayedExecutor|Create delayed executor|
|
|
247
|
-
|intervalFor|Repeat interval for callback|
|
|
248
|
-
|promiseHandler|Promise handler to catch error|
|
|
249
|
-
|sleep|Delay promise|
|
|
250
|
-
|waitFor|Wait for condition meets and execute callback|
|
|
257
|
+
| Name | Description |
|
|
258
|
+
| --------------: | --------------------------------------------- |
|
|
259
|
+
| applyMixins | Apply mixins to current class |
|
|
260
|
+
| delayedExecutor | Create delayed executor |
|
|
261
|
+
| intervalFor | Repeat interval for callback |
|
|
262
|
+
| promiseHandler | Promise handler to catch error |
|
|
263
|
+
| sleep | Delay promise |
|
|
264
|
+
| waitFor | Wait for condition meets and execute callback |
|
|
251
265
|
|
|
252
266
|
## NumberUtils
|
|
267
|
+
|
|
253
268
|
Numbers related utilities
|
|
254
269
|
|
|
255
|
-
|Name|Description|
|
|
256
|
-
|
|
257
|
-
|format|Format number|
|
|
258
|
-
|formatFileSize|Format file size|
|
|
259
|
-
|formatMoney|Format money number|
|
|
260
|
-
|getCurrencySymbol|Get currency symbol or name from ISO code|
|
|
261
|
-
|parse|Parse to number, with or without default value|
|
|
262
|
-
|toExact|To the exact precision number avoiding precision lost|
|
|
270
|
+
| Name | Description |
|
|
271
|
+
| ----------------: | ----------------------------------------------------- |
|
|
272
|
+
| format | Format number |
|
|
273
|
+
| formatFileSize | Format file size |
|
|
274
|
+
| formatMoney | Format money number |
|
|
275
|
+
| getCurrencySymbol | Get currency symbol or name from ISO code |
|
|
276
|
+
| parse | Parse to number, with or without default value |
|
|
277
|
+
| toExact | To the exact precision number avoiding precision lost |
|
|
263
278
|
|
|
264
279
|
## StorageUtils
|
|
280
|
+
|
|
265
281
|
Storage related utilities
|
|
266
282
|
|
|
267
|
-
|Name|Description|
|
|
268
|
-
|
|
269
|
-
|setLocalData|Set local storage data|
|
|
270
|
-
|setSessionData|Set session storage data|
|
|
271
|
-
|getLocalData|Get local storage data|
|
|
272
|
-
|getLocalObject|Get local storage object data|
|
|
273
|
-
|getSessionData|Get session storage data|
|
|
274
|
-
|getSessionObject|Get session storage object data|
|
|
283
|
+
| Name | Description |
|
|
284
|
+
| ---------------: | ------------------------------- |
|
|
285
|
+
| setLocalData | Set local storage data |
|
|
286
|
+
| setSessionData | Set session storage data |
|
|
287
|
+
| getLocalData | Get local storage data |
|
|
288
|
+
| getLocalObject | Get local storage object data |
|
|
289
|
+
| getSessionData | Get session storage data |
|
|
290
|
+
| getSessionObject | Get session storage object data |
|
|
275
291
|
|
|
276
292
|
## Utils
|
|
293
|
+
|
|
277
294
|
String and other related utilities
|
|
278
295
|
|
|
279
|
-
|Name|Description|
|
|
280
|
-
|
|
281
|
-
|addBlankItem|Add blank item to collection|
|
|
282
|
-
|charsToNumber|Base64 chars to number|
|
|
283
|
-
|containChinese|Check the input string contains Chinese character or not|
|
|
284
|
-
|correctTypes|Correct object's property value type|
|
|
285
|
-
|equals|Two values equal|
|
|
286
|
-
|exclude|Exclude specific items|
|
|
287
|
-
|excludeAsync|Async exclude specific items|
|
|
288
|
-
|formatInitial|Format inital character to lower case or upper case|
|
|
289
|
-
|formatString|Format string with parameters|
|
|
290
|
-
|getDataChanges|Get data changed fields with input data updated|
|
|
291
|
-
|getNestedValue|Get nested value from object|
|
|
292
|
-
|getTimeZone|Get time zone|
|
|
293
|
-
|hideData|Hide data|
|
|
294
|
-
|hideEmail|Hide email data|
|
|
295
|
-
|isDigits|Is digits string|
|
|
296
|
-
|isEmail|Is email string|
|
|
297
|
-
|joinItems|Join items as a string|
|
|
298
|
-
|mergeFormData|Merge form data to primary one|
|
|
299
|
-
|mergeClasses|Merge class names|
|
|
300
|
-
|newGUID|Create a GUID|
|
|
301
|
-
|numberToChars|Number to base64 chars|
|
|
302
|
-
|objectEqual|Test two objects are equal or not|
|
|
303
|
-
|objectKeys|Get two object's unqiue properties|
|
|
304
|
-
|objectUpdated|Get the new object's updated fields contrast to the previous object|
|
|
305
|
-
|parseJsonArray|Try to parse JSON input to array|
|
|
306
|
-
|parsePath|Parse path similar with node.js path.parse|
|
|
307
|
-
|parseString|Parse string (JSON) to specific type|
|
|
308
|
-
|removeEmptyValues|Remove empty values (null, undefined, '') from the input object|
|
|
309
|
-
|removeNonLetters|Remove non letters (0-9, a-z, A-Z)|
|
|
310
|
-
|replaceNullOrEmpty|Replace null or empty with default value|
|
|
311
|
-
|setLabels|Set source with new labels|
|
|
312
|
-
|setNestedValue|Set nested value to object|
|
|
313
|
-
|snakeNameToWord|Snake name to works, 'snake_name' to 'Snake Name'|
|
|
314
|
-
|sortByFavor|Sort array by favored values|
|
|
315
|
-
|sortByFieldFavor|Sort array by favored field values|
|
|
316
|
-
|trim|Trim chars|
|
|
317
|
-
|trimEnd|Trim end chars|
|
|
318
|
-
|trimStart|Trim start chars|
|
|
296
|
+
| Name | Description |
|
|
297
|
+
| -----------------: | ------------------------------------------------------------------- |
|
|
298
|
+
| addBlankItem | Add blank item to collection |
|
|
299
|
+
| charsToNumber | Base64 chars to number |
|
|
300
|
+
| containChinese | Check the input string contains Chinese character or not |
|
|
301
|
+
| correctTypes | Correct object's property value type |
|
|
302
|
+
| equals | Two values equal |
|
|
303
|
+
| exclude | Exclude specific items |
|
|
304
|
+
| excludeAsync | Async exclude specific items |
|
|
305
|
+
| formatInitial | Format inital character to lower case or upper case |
|
|
306
|
+
| formatString | Format string with parameters |
|
|
307
|
+
| getDataChanges | Get data changed fields with input data updated |
|
|
308
|
+
| getNestedValue | Get nested value from object |
|
|
309
|
+
| getTimeZone | Get time zone |
|
|
310
|
+
| hideData | Hide data |
|
|
311
|
+
| hideEmail | Hide email data |
|
|
312
|
+
| isDigits | Is digits string |
|
|
313
|
+
| isEmail | Is email string |
|
|
314
|
+
| joinItems | Join items as a string |
|
|
315
|
+
| mergeFormData | Merge form data to primary one |
|
|
316
|
+
| mergeClasses | Merge class names |
|
|
317
|
+
| newGUID | Create a GUID |
|
|
318
|
+
| numberToChars | Number to base64 chars |
|
|
319
|
+
| objectEqual | Test two objects are equal or not |
|
|
320
|
+
| objectKeys | Get two object's unqiue properties |
|
|
321
|
+
| objectUpdated | Get the new object's updated fields contrast to the previous object |
|
|
322
|
+
| parseJsonArray | Try to parse JSON input to array |
|
|
323
|
+
| parsePath | Parse path similar with node.js path.parse |
|
|
324
|
+
| parseString | Parse string (JSON) to specific type |
|
|
325
|
+
| removeEmptyValues | Remove empty values (null, undefined, '') from the input object |
|
|
326
|
+
| removeNonLetters | Remove non letters (0-9, a-z, A-Z) |
|
|
327
|
+
| replaceNullOrEmpty | Replace null or empty with default value |
|
|
328
|
+
| setLabels | Set source with new labels |
|
|
329
|
+
| setNestedValue | Set nested value to object |
|
|
330
|
+
| snakeNameToWord | Snake name to works, 'snake_name' to 'Snake Name' |
|
|
331
|
+
| sortByFavor | Sort array by favored values |
|
|
332
|
+
| sortByFieldFavor | Sort array by favored field values |
|
|
333
|
+
| trim | Trim chars |
|
|
334
|
+
| trimEnd | Trim end chars |
|
|
335
|
+
| trimStart | Trim start chars |
|
package/__tests__/Utils.ts
CHANGED
|
@@ -114,7 +114,8 @@ test("Tests for getDataChanges", () => {
|
|
|
114
114
|
value: undefined,
|
|
115
115
|
date: new Date("2023/03/18"),
|
|
116
116
|
ids: [1, 2],
|
|
117
|
-
data: { d1: 1, d2: false, d3: 1.2, d4: "Hello" }
|
|
117
|
+
data: { d1: 1, d2: false, d3: 1.2, d4: "Hello" },
|
|
118
|
+
changedFields: ["gender", "brand", "date"]
|
|
118
119
|
};
|
|
119
120
|
const initData = {
|
|
120
121
|
id: 1,
|
package/__tests__/tsconfig.json
CHANGED
package/lib/cjs/DataTypes.d.ts
CHANGED
|
@@ -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
|