@tmagic/utils 1.3.13 → 1.3.14
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/dist/tmagic-utils.js +14 -11
- package/dist/tmagic-utils.js.map +1 -1
- package/dist/tmagic-utils.umd.cjs +14 -11
- package/dist/tmagic-utils.umd.cjs.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +15 -11
- package/types/index.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.3.
|
|
2
|
+
"version": "1.3.14",
|
|
3
3
|
"name": "@tmagic/utils",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/tmagic-utils.umd.cjs",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"url": "https://github.com/Tencent/tmagic-editor.git"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@tmagic/schema": "1.3.
|
|
28
|
+
"@tmagic/schema": "1.3.14",
|
|
29
29
|
"dayjs": "^1.11.4",
|
|
30
30
|
"lodash-es": "^4.17.21"
|
|
31
31
|
},
|
package/src/index.ts
CHANGED
|
@@ -283,32 +283,36 @@ export const compiledNode = (
|
|
|
283
283
|
return node;
|
|
284
284
|
};
|
|
285
285
|
|
|
286
|
-
export const compiledCond = (op: string, fieldValue: any,
|
|
286
|
+
export const compiledCond = (op: string, fieldValue: any, inputValue: any, range: number[] = []): boolean => {
|
|
287
|
+
if (typeof fieldValue === 'string' && typeof inputValue === 'undefined') {
|
|
288
|
+
inputValue = '';
|
|
289
|
+
}
|
|
290
|
+
|
|
287
291
|
switch (op) {
|
|
288
292
|
case 'is':
|
|
289
|
-
return fieldValue ===
|
|
293
|
+
return fieldValue === inputValue;
|
|
290
294
|
case 'not':
|
|
291
|
-
return fieldValue !==
|
|
295
|
+
return fieldValue !== inputValue;
|
|
292
296
|
case '=':
|
|
293
|
-
return fieldValue ===
|
|
297
|
+
return fieldValue === inputValue;
|
|
294
298
|
case '!=':
|
|
295
|
-
return fieldValue !==
|
|
299
|
+
return fieldValue !== inputValue;
|
|
296
300
|
case '>':
|
|
297
|
-
return fieldValue >
|
|
301
|
+
return fieldValue > inputValue;
|
|
298
302
|
case '>=':
|
|
299
|
-
return fieldValue >=
|
|
303
|
+
return fieldValue >= inputValue;
|
|
300
304
|
case '<':
|
|
301
|
-
return fieldValue <
|
|
305
|
+
return fieldValue < inputValue;
|
|
302
306
|
case '<=':
|
|
303
|
-
return fieldValue <=
|
|
307
|
+
return fieldValue <= inputValue;
|
|
304
308
|
case 'between':
|
|
305
309
|
return range.length > 1 && fieldValue >= range[0] && fieldValue <= range[1];
|
|
306
310
|
case 'not_between':
|
|
307
311
|
return range.length < 2 || fieldValue < range[0] || fieldValue > range[1];
|
|
308
312
|
case 'include':
|
|
309
|
-
return fieldValue?.includes?.(
|
|
313
|
+
return fieldValue?.includes?.(inputValue);
|
|
310
314
|
case 'not_include':
|
|
311
|
-
return typeof fieldValue === 'undefined' || !fieldValue.includes?.(
|
|
315
|
+
return typeof fieldValue === 'undefined' || !fieldValue.includes?.(inputValue);
|
|
312
316
|
default:
|
|
313
317
|
break;
|
|
314
318
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export declare const getDepNodeIds: (dataSourceDeps?: DataSourceDeps) => string[
|
|
|
40
40
|
*/
|
|
41
41
|
export declare const replaceChildNode: (newNode: MNode, data?: MNode[], parentId?: Id) => void;
|
|
42
42
|
export declare const compiledNode: (compile: (value: any) => any, node: MNode, dataSourceDeps?: DataSourceDeps, sourceId?: Id) => MNode;
|
|
43
|
-
export declare const compiledCond: (op: string, fieldValue: any,
|
|
43
|
+
export declare const compiledCond: (op: string, fieldValue: any, inputValue: any, range?: number[]) => boolean;
|
|
44
44
|
export declare const getDefaultValueFromFields: (fields: DataSchema[]) => Record<string, any>;
|
|
45
45
|
export declare const DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX = "ds-field::";
|
|
46
46
|
export declare const getKeys: <T extends object>(obj: T) => (keyof T)[];
|