@tmagic/utils 1.8.0-beta.28 → 1.8.0-beta.29
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/es/index.js +4 -2
- package/dist/tmagic-utils.umd.cjs +10 -6
- package/package.json +2 -2
- package/types/index.d.ts +63 -64
package/dist/es/index.js
CHANGED
|
@@ -100,8 +100,10 @@ var setUrlParam = (name, value, url = globalThis.location.href) => {
|
|
|
100
100
|
const first = strArr.charAt(0);
|
|
101
101
|
url = url.replace(strArr, key);
|
|
102
102
|
url = url.replace(key, value ? first + extra : "");
|
|
103
|
-
} else if (value)
|
|
104
|
-
|
|
103
|
+
} else if (value) {
|
|
104
|
+
if (url.indexOf("?") > -1) url += `&${extra}`;
|
|
105
|
+
else url += `?${extra}`;
|
|
106
|
+
}
|
|
105
107
|
return url;
|
|
106
108
|
};
|
|
107
109
|
var getSearchObj = (search = globalThis.location.search ? globalThis.location.search.substring(1) : "") => {
|
|
@@ -43,8 +43,10 @@
|
|
|
43
43
|
var unmasked = true;
|
|
44
44
|
} catch (e) {}
|
|
45
45
|
var result = nativeObjectToString$1.call(value);
|
|
46
|
-
if (unmasked)
|
|
47
|
-
|
|
46
|
+
if (unmasked) {
|
|
47
|
+
if (isOwn) value[symToStringTag$1] = tag;
|
|
48
|
+
else delete value[symToStringTag$1];
|
|
49
|
+
}
|
|
48
50
|
return result;
|
|
49
51
|
}
|
|
50
52
|
//#endregion
|
|
@@ -181,7 +183,7 @@
|
|
|
181
183
|
//#endregion
|
|
182
184
|
//#region node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_baseToString.js
|
|
183
185
|
/** Used as references for various `Number` constants. */
|
|
184
|
-
var INFINITY$1 =
|
|
186
|
+
var INFINITY$1 = 1 / 0;
|
|
185
187
|
/** Used to convert symbols to primitives and strings. */
|
|
186
188
|
var symbolProto$1 = Symbol ? Symbol.prototype : void 0;
|
|
187
189
|
var symbolToString = symbolProto$1 ? symbolProto$1.toString : void 0;
|
|
@@ -1497,7 +1499,7 @@
|
|
|
1497
1499
|
//#endregion
|
|
1498
1500
|
//#region node_modules/.pnpm/lodash-es@4.18.1/node_modules/lodash-es/_toKey.js
|
|
1499
1501
|
/** Used as references for various `Number` constants. */
|
|
1500
|
-
var INFINITY =
|
|
1502
|
+
var INFINITY = 1 / 0;
|
|
1501
1503
|
/**
|
|
1502
1504
|
* Converts `value` to a string key if it's not a string or symbol.
|
|
1503
1505
|
*
|
|
@@ -2555,8 +2557,10 @@
|
|
|
2555
2557
|
const first = strArr.charAt(0);
|
|
2556
2558
|
url = url.replace(strArr, key);
|
|
2557
2559
|
url = url.replace(key, value ? first + extra : "");
|
|
2558
|
-
} else if (value)
|
|
2559
|
-
|
|
2560
|
+
} else if (value) {
|
|
2561
|
+
if (url.indexOf("?") > -1) url += `&${extra}`;
|
|
2562
|
+
else url += `?${extra}`;
|
|
2563
|
+
}
|
|
2560
2564
|
return url;
|
|
2561
2565
|
};
|
|
2562
2566
|
var getSearchObj = (search = globalThis.location.search ? globalThis.location.search.substring(1) : "") => {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.8.0-beta.
|
|
2
|
+
"version": "1.8.0-beta.29",
|
|
3
3
|
"name": "@tmagic/utils",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"typescript": "^6.0.3",
|
|
38
|
-
"@tmagic/schema": "1.8.0-beta.
|
|
38
|
+
"@tmagic/schema": "1.8.0-beta.29"
|
|
39
39
|
},
|
|
40
40
|
"peerDependenciesMeta": {
|
|
41
41
|
"typescript": {
|
package/types/index.d.ts
CHANGED
|
@@ -2233,52 +2233,52 @@ interface UpdateOptions extends HistoryOpOptionsWithChangeRecords {
|
|
|
2233
2233
|
}
|
|
2234
2234
|
//#endregion
|
|
2235
2235
|
//#region temp/packages/utils/src/dom.d.ts
|
|
2236
|
-
declare const asyncLoadJs: (url: string, crossOrigin?: string, document?: Document) => any;
|
|
2237
|
-
declare const asyncLoadCss: (url: string, document?: Document) => any;
|
|
2238
|
-
declare const addClassName: (el: Element, doc: Document, className: string) => void;
|
|
2239
|
-
declare const removeClassName: (el: Element, ...className: string[]) => void;
|
|
2240
|
-
declare const removeClassNameByClassName: (doc: Document, className: string) => HTMLElement | null;
|
|
2241
|
-
declare const injectStyle: (doc: Document, style: string) => HTMLStyleElement;
|
|
2242
|
-
declare const createDiv: ({ className, cssText }: {
|
|
2236
|
+
export declare const asyncLoadJs: (url: string, crossOrigin?: string, document?: Document) => any;
|
|
2237
|
+
export declare const asyncLoadCss: (url: string, document?: Document) => any;
|
|
2238
|
+
export declare const addClassName: (el: Element, doc: Document, className: string) => void;
|
|
2239
|
+
export declare const removeClassName: (el: Element, ...className: string[]) => void;
|
|
2240
|
+
export declare const removeClassNameByClassName: (doc: Document, className: string) => HTMLElement | null;
|
|
2241
|
+
export declare const injectStyle: (doc: Document, style: string) => HTMLStyleElement;
|
|
2242
|
+
export declare const createDiv: ({ className, cssText }: {
|
|
2243
2243
|
className: string;
|
|
2244
2244
|
cssText: string;
|
|
2245
2245
|
}) => HTMLDivElement;
|
|
2246
|
-
declare const getDocument: () => Document;
|
|
2247
|
-
declare const calcValueByFontsize: (doc: Document | undefined, value: number) => number;
|
|
2246
|
+
export declare const getDocument: () => Document;
|
|
2247
|
+
export declare const calcValueByFontsize: (doc: Document | undefined, value: number) => number;
|
|
2248
2248
|
declare const dslDomRelateConfig: {
|
|
2249
2249
|
getIdFromEl: (el?: HTMLElement | SVGElement | null) => string | undefined;
|
|
2250
2250
|
getElById: (doc?: Document, id?: string | number) => HTMLElement;
|
|
2251
2251
|
setIdToEl: (el: HTMLElement | SVGElement, id: string | number) => void;
|
|
2252
2252
|
};
|
|
2253
|
-
declare const setDslDomRelateConfig: <K extends keyof typeof dslDomRelateConfig, T extends (typeof dslDomRelateConfig)[K]>(name: K, value: T) => void;
|
|
2254
|
-
declare const getIdFromEl: () => (el?: HTMLElement | SVGElement | null) => string | undefined;
|
|
2255
|
-
declare const getElById: () => (doc?: Document, id?: string | number) => HTMLElement;
|
|
2256
|
-
declare const setIdToEl: () => (el: HTMLElement | SVGElement, id: string | number) => void;
|
|
2253
|
+
export declare const setDslDomRelateConfig: <K extends keyof typeof dslDomRelateConfig, T extends (typeof dslDomRelateConfig)[K]>(name: K, value: T) => void;
|
|
2254
|
+
export declare const getIdFromEl: () => (el?: HTMLElement | SVGElement | null) => string | undefined;
|
|
2255
|
+
export declare const getElById: () => (doc?: Document, id?: string | number) => HTMLElement;
|
|
2256
|
+
export declare const setIdToEl: () => (el: HTMLElement | SVGElement, id: string | number) => void;
|
|
2257
2257
|
//#endregion
|
|
2258
2258
|
//#region temp/packages/utils/src/const.d.ts
|
|
2259
|
-
declare const DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX = "ds-field::";
|
|
2260
|
-
declare const DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX = "ds-field-changed";
|
|
2261
|
-
declare const DATA_SOURCE_SET_DATA_METHOD_NAME = "setDataFromEvent";
|
|
2259
|
+
export declare const DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX = "ds-field::";
|
|
2260
|
+
export declare const DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX = "ds-field-changed";
|
|
2261
|
+
export declare const DATA_SOURCE_SET_DATA_METHOD_NAME = "setDataFromEvent";
|
|
2262
2262
|
//#endregion
|
|
2263
2263
|
//#region temp/packages/utils/src/index.d.ts
|
|
2264
|
-
declare const getGlobalThis: () => any;
|
|
2265
|
-
declare const sleep: (ms: number) => Promise<void>;
|
|
2266
|
-
declare const toLine: (name?: string) => string;
|
|
2267
|
-
declare const toHump: (name?: string) => string;
|
|
2268
|
-
declare const emptyFn: () => any;
|
|
2264
|
+
export declare const getGlobalThis: () => any;
|
|
2265
|
+
export declare const sleep: (ms: number) => Promise<void>;
|
|
2266
|
+
export declare const toLine: (name?: string) => string;
|
|
2267
|
+
export declare const toHump: (name?: string) => string;
|
|
2268
|
+
export declare const emptyFn: () => any;
|
|
2269
2269
|
/**
|
|
2270
2270
|
* 通过id获取组件在应用的子孙路径
|
|
2271
2271
|
* @param {number | string} id 组件id
|
|
2272
2272
|
* @param {Array} data 要查找的根容器节点
|
|
2273
2273
|
* @return {Array} 组件在data中的子孙路径
|
|
2274
2274
|
*/
|
|
2275
|
-
declare const getNodePath: (id: Id, data?: MNode[], skip?: MNode | null) => MNode[];
|
|
2276
|
-
declare const getNodeInfo: (id: Id, root: {
|
|
2275
|
+
export declare const getNodePath: (id: Id, data?: MNode[], skip?: MNode | null) => MNode[];
|
|
2276
|
+
export declare const getNodeInfo: (id: Id, root: {
|
|
2277
2277
|
id: Id;
|
|
2278
2278
|
items?: MNode[];
|
|
2279
2279
|
} | null, skip?: MNode | null) => EditorNodeInfo;
|
|
2280
|
-
declare const filterXSS: (str: string) => string;
|
|
2281
|
-
declare const getUrlParam: (param: string, url?: string) => string;
|
|
2280
|
+
export declare const filterXSS: (str: string) => string;
|
|
2281
|
+
export declare const getUrlParam: (param: string, url?: string) => string;
|
|
2282
2282
|
/**
|
|
2283
2283
|
* 设置url中指定的参数
|
|
2284
2284
|
*
|
|
@@ -2290,68 +2290,67 @@ declare const getUrlParam: (param: string, url?: string) => string;
|
|
|
2290
2290
|
* url [发生替换的url地址|默认为location.href]
|
|
2291
2291
|
* @return {string} [返回处理后的url]
|
|
2292
2292
|
*/
|
|
2293
|
-
declare const setUrlParam: (name: string, value: string, url?: string) => string;
|
|
2294
|
-
declare const getSearchObj: (search?: string) => Record<string, string>;
|
|
2295
|
-
declare const delQueStr: (url: string, ref: string[] | string) => string;
|
|
2296
|
-
declare const isObject: (obj: any) => boolean;
|
|
2297
|
-
declare const isPop: (node: Pick<MComponent, "type"> | null) => boolean;
|
|
2298
|
-
declare const isPage: (node?: Pick<MComponent, "type"> | null) => boolean;
|
|
2299
|
-
declare const isPageFragment: (node?: Pick<MComponent, "type"> | null) => boolean;
|
|
2293
|
+
export declare const setUrlParam: (name: string, value: string, url?: string) => string;
|
|
2294
|
+
export declare const getSearchObj: (search?: string) => Record<string, string>;
|
|
2295
|
+
export declare const delQueStr: (url: string, ref: string[] | string) => string;
|
|
2296
|
+
export declare const isObject: (obj: any) => boolean;
|
|
2297
|
+
export declare const isPop: (node: Pick<MComponent, "type"> | null) => boolean;
|
|
2298
|
+
export declare const isPage: (node?: Pick<MComponent, "type"> | null) => boolean;
|
|
2299
|
+
export declare const isPageFragment: (node?: Pick<MComponent, "type"> | null) => boolean;
|
|
2300
2300
|
/** 是否为页面或页面片 */
|
|
2301
|
-
declare const isPageOrFragment: (node?: Pick<MComponent, "type"> | null) => boolean;
|
|
2302
|
-
declare const isNumber: (value: any) => boolean;
|
|
2303
|
-
declare const getHost: (targetUrl: string) => string | undefined;
|
|
2304
|
-
declare const isSameDomain: (targetUrl?: string, source?: string) => boolean;
|
|
2301
|
+
export declare const isPageOrFragment: (node?: Pick<MComponent, "type"> | null) => boolean;
|
|
2302
|
+
export declare const isNumber: (value: any) => boolean;
|
|
2303
|
+
export declare const getHost: (targetUrl: string) => string | undefined;
|
|
2304
|
+
export declare const isSameDomain: (targetUrl?: string, source?: string) => boolean;
|
|
2305
2305
|
/**
|
|
2306
2306
|
* 生成指定位数的GUID,无【-】格式
|
|
2307
2307
|
* @param digit 位数,默认值8
|
|
2308
2308
|
* @returns
|
|
2309
2309
|
*/
|
|
2310
|
-
declare const guid: (digit?: number) => string;
|
|
2311
|
-
declare const getKeysArray: (keys: string | number) => string[];
|
|
2310
|
+
export declare const guid: (digit?: number) => string;
|
|
2311
|
+
export declare const getKeysArray: (keys: string | number) => string[];
|
|
2312
2312
|
/**
|
|
2313
2313
|
* 判断某一层 key 是否为数组下标(纯数字)
|
|
2314
2314
|
* @param key 单层 key
|
|
2315
2315
|
* @returns 是否为数组下标
|
|
2316
2316
|
*/
|
|
2317
|
-
declare const isArrayIndex: (key: string | number) => boolean;
|
|
2318
|
-
declare const getValueByKeyPath: (keys?: number | string | string[], data?: Record<string | number, any>) => any;
|
|
2319
|
-
declare const setValueByKeyPath: (keys: string | number, value: any, data?: Record<string | number, any>) => any;
|
|
2320
|
-
declare const getNodes: (ids: Id[], data?: MNode[]) => MNode[];
|
|
2321
|
-
declare const getDepKeys: (dataSourceDeps: DataSourceDeps | undefined, nodeId: Id) => Id[];
|
|
2322
|
-
declare const getDepNodeIds: (dataSourceDeps?: DataSourceDeps) => string[];
|
|
2317
|
+
export declare const isArrayIndex: (key: string | number) => boolean;
|
|
2318
|
+
export declare const getValueByKeyPath: (keys?: number | string | string[], data?: Record<string | number, any>) => any;
|
|
2319
|
+
export declare const setValueByKeyPath: (keys: string | number, value: any, data?: Record<string | number, any>) => any;
|
|
2320
|
+
export declare const getNodes: (ids: Id[], data?: MNode[]) => MNode[];
|
|
2321
|
+
export declare const getDepKeys: (dataSourceDeps: DataSourceDeps | undefined, nodeId: Id) => Id[];
|
|
2322
|
+
export declare const getDepNodeIds: (dataSourceDeps?: DataSourceDeps) => string[];
|
|
2323
2323
|
/**
|
|
2324
2324
|
* 将新节点更新到data或者parentId对应的节点的子节点中
|
|
2325
2325
|
* @param newNode 新节点
|
|
2326
2326
|
* @param data 需要修改的数据
|
|
2327
2327
|
* @param parentId 父节点 id
|
|
2328
2328
|
*/
|
|
2329
|
-
declare const replaceChildNode: (newNode: MNode, data?: MNode[], parentId?: Id) => void;
|
|
2330
|
-
declare const DSL_NODE_KEY_COPY_PREFIX = "__tmagic__";
|
|
2331
|
-
declare const IS_DSL_NODE_KEY = "__tmagic__dslNode";
|
|
2332
|
-
declare const PAGE_FRAGMENT_CONTAINER_ID_KEY = "tmagic-page-fragment-container-id";
|
|
2333
|
-
declare const compiledNode: (compile: (value: any) => any, node: MNode, dataSourceDeps?: DataSourceDeps, sourceId?: Id) => MNode;
|
|
2334
|
-
declare const compiledCond: (op: string, fieldValue: any, inputValue: any, range?: number[]) => boolean;
|
|
2335
|
-
declare const getDefaultValueFromFields: (fields: DataSchema[]) => Record<string, any>;
|
|
2336
|
-
declare const getKeys: <T extends object>(obj: T) => Array<keyof T>;
|
|
2337
|
-
declare const calculatePercentage: (value: number, percentageStr: string) => number;
|
|
2338
|
-
declare const isPercentage: (value: number | string) => boolean;
|
|
2339
|
-
declare const convertToNumber: (value: number | string, parentValue?: number) => number;
|
|
2329
|
+
export declare const replaceChildNode: (newNode: MNode, data?: MNode[], parentId?: Id) => void;
|
|
2330
|
+
export declare const DSL_NODE_KEY_COPY_PREFIX = "__tmagic__";
|
|
2331
|
+
export declare const IS_DSL_NODE_KEY = "__tmagic__dslNode";
|
|
2332
|
+
export declare const PAGE_FRAGMENT_CONTAINER_ID_KEY = "tmagic-page-fragment-container-id";
|
|
2333
|
+
export declare const compiledNode: (compile: (value: any) => any, node: MNode, dataSourceDeps?: DataSourceDeps, sourceId?: Id) => MNode;
|
|
2334
|
+
export declare const compiledCond: (op: string, fieldValue: any, inputValue: any, range?: number[]) => boolean;
|
|
2335
|
+
export declare const getDefaultValueFromFields: (fields: DataSchema[]) => Record<string, any>;
|
|
2336
|
+
export declare const getKeys: <T extends object>(obj: T) => Array<keyof T>;
|
|
2337
|
+
export declare const calculatePercentage: (value: number, percentageStr: string) => number;
|
|
2338
|
+
export declare const isPercentage: (value: number | string) => boolean;
|
|
2339
|
+
export declare const convertToNumber: (value: number | string, parentValue?: number) => number;
|
|
2340
2340
|
/**
|
|
2341
2341
|
* 添加参数到URL
|
|
2342
2342
|
* @param obj 参数对象
|
|
2343
2343
|
* @param global window对象
|
|
2344
2344
|
* @param needReload 是否需要刷新
|
|
2345
2345
|
*/
|
|
2346
|
-
declare const addParamToUrl: (obj: Record<string, any>, global?: typeof globalThis, needReload?: boolean) => void;
|
|
2347
|
-
declare const dataSourceTemplateRegExp: RegExp;
|
|
2348
|
-
declare const isDslNode: (config: MNodeInstance) => boolean;
|
|
2349
|
-
interface NodeItem {
|
|
2346
|
+
export declare const addParamToUrl: (obj: Record<string, any>, global?: typeof globalThis, needReload?: boolean) => void;
|
|
2347
|
+
export declare const dataSourceTemplateRegExp: RegExp;
|
|
2348
|
+
export declare const isDslNode: (config: MNodeInstance) => boolean;
|
|
2349
|
+
export interface NodeItem {
|
|
2350
2350
|
items?: NodeItem[];
|
|
2351
2351
|
[key: string]: any;
|
|
2352
2352
|
}
|
|
2353
|
-
declare const traverseNode: <T extends NodeItem = NodeItem>(node: T, cb: (node: T, parents: T[]) => void, parents?: T[], evalCbAfter?: boolean) => void;
|
|
2354
|
-
declare const isValueIncludeDataSource: (value: any) => boolean;
|
|
2355
|
-
declare const removeDataSourceFieldPrefix: (id?: string) => string;
|
|
2356
|
-
//#endregion
|
|
2357
|
-
export { DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX, DATA_SOURCE_SET_DATA_METHOD_NAME, DSL_NODE_KEY_COPY_PREFIX, IS_DSL_NODE_KEY, NodeItem, PAGE_FRAGMENT_CONTAINER_ID_KEY, addClassName, addParamToUrl, asyncLoadCss, asyncLoadJs, calcValueByFontsize, calculatePercentage, compiledCond, compiledNode, convertToNumber, createDiv, dataSourceTemplateRegExp, delQueStr, emptyFn, filterXSS, getDefaultValueFromFields, getDepKeys, getDepNodeIds, getDocument, getElById, getGlobalThis, getHost, getIdFromEl, getKeys, getKeysArray, getNodeInfo, getNodePath, getNodes, getSearchObj, getUrlParam, getValueByKeyPath, guid, injectStyle, isArrayIndex, isDslNode, isNumber, isObject, isPage, isPageFragment, isPageOrFragment, isPercentage, isPop, isSameDomain, isValueIncludeDataSource, removeClassName, removeClassNameByClassName, removeDataSourceFieldPrefix, replaceChildNode, setDslDomRelateConfig, setIdToEl, setUrlParam, setValueByKeyPath, sleep, toHump, toLine, traverseNode };
|
|
2353
|
+
export declare const traverseNode: <T extends NodeItem = NodeItem>(node: T, cb: (node: T, parents: T[]) => void, parents?: T[], evalCbAfter?: boolean) => void;
|
|
2354
|
+
export declare const isValueIncludeDataSource: (value: any) => boolean;
|
|
2355
|
+
export declare const removeDataSourceFieldPrefix: (id?: string) => string;
|
|
2356
|
+
//#endregion
|