@xfe-repo/web-utils 1.0.1 → 1.0.3
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/chunk-6BSPRPK2.mjs +41 -0
- package/dist/env.d.mts +2 -1
- package/dist/env.d.ts +2 -1
- package/dist/env.js +3 -0
- package/dist/env.mjs +3 -1
- package/dist/loadScript.mjs +1 -1
- package/dist/token.mjs +1 -1
- package/dist/tools.d.mts +27 -1
- package/dist/tools.d.ts +27 -1
- package/dist/tools.js +53 -0
- package/dist/tools.mjs +39 -1
- package/dist/valid.mjs +1 -1
- package/package.json +2 -5
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __async = (__this, __arguments, generator) => {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
var fulfilled = (value) => {
|
|
20
|
+
try {
|
|
21
|
+
step(generator.next(value));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
reject(e);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var rejected = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.throw(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
34
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
__spreadValues,
|
|
40
|
+
__async
|
|
41
|
+
};
|
package/dist/env.d.mts
CHANGED
|
@@ -10,6 +10,7 @@ declare const isWeiXin: boolean;
|
|
|
10
10
|
declare const isProduction: boolean;
|
|
11
11
|
declare const release: string;
|
|
12
12
|
declare const apiEnv: ApiEnv;
|
|
13
|
+
declare const business: Business;
|
|
13
14
|
declare const assetsHost = "https://imgs.xianghuanji.com/";
|
|
14
15
|
declare const getErpSaasOrigin: (_apiEnv: ApiEnv) => string;
|
|
15
16
|
declare const getMSaasOrigin: (_apiEnv: ApiEnv) => string;
|
|
@@ -23,4 +24,4 @@ declare const sentryConfig: {
|
|
|
23
24
|
debug: boolean;
|
|
24
25
|
};
|
|
25
26
|
|
|
26
|
-
export { type ApiEnv, type Business, type TestEnv, apiEnv, assetsHost, getBffApi, getEnvDomain, getErpSaasOrigin, getMSaasOrigin, isAndroid, isClient, isIos, isProduction, isSSR, isServer, isWeiXin, release, sentryConfig };
|
|
27
|
+
export { type ApiEnv, type Business, type TestEnv, apiEnv, assetsHost, business, getBffApi, getEnvDomain, getErpSaasOrigin, getMSaasOrigin, isAndroid, isClient, isIos, isProduction, isSSR, isServer, isWeiXin, release, sentryConfig };
|
package/dist/env.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ declare const isWeiXin: boolean;
|
|
|
10
10
|
declare const isProduction: boolean;
|
|
11
11
|
declare const release: string;
|
|
12
12
|
declare const apiEnv: ApiEnv;
|
|
13
|
+
declare const business: Business;
|
|
13
14
|
declare const assetsHost = "https://imgs.xianghuanji.com/";
|
|
14
15
|
declare const getErpSaasOrigin: (_apiEnv: ApiEnv) => string;
|
|
15
16
|
declare const getMSaasOrigin: (_apiEnv: ApiEnv) => string;
|
|
@@ -23,4 +24,4 @@ declare const sentryConfig: {
|
|
|
23
24
|
debug: boolean;
|
|
24
25
|
};
|
|
25
26
|
|
|
26
|
-
export { type ApiEnv, type Business, type TestEnv, apiEnv, assetsHost, getBffApi, getEnvDomain, getErpSaasOrigin, getMSaasOrigin, isAndroid, isClient, isIos, isProduction, isSSR, isServer, isWeiXin, release, sentryConfig };
|
|
27
|
+
export { type ApiEnv, type Business, type TestEnv, apiEnv, assetsHost, business, getBffApi, getEnvDomain, getErpSaasOrigin, getMSaasOrigin, isAndroid, isClient, isIos, isProduction, isSSR, isServer, isWeiXin, release, sentryConfig };
|
package/dist/env.js
CHANGED
|
@@ -22,6 +22,7 @@ var env_exports = {};
|
|
|
22
22
|
__export(env_exports, {
|
|
23
23
|
apiEnv: () => apiEnv,
|
|
24
24
|
assetsHost: () => assetsHost,
|
|
25
|
+
business: () => business,
|
|
25
26
|
getBffApi: () => getBffApi,
|
|
26
27
|
getEnvDomain: () => getEnvDomain,
|
|
27
28
|
getErpSaasOrigin: () => getErpSaasOrigin,
|
|
@@ -52,6 +53,7 @@ var isWeiXin = /MicroMessenger/i.test(navigator.userAgent);
|
|
|
52
53
|
var isProduction = process.env["NODE_ENV"] === "production";
|
|
53
54
|
var release = process.env["REACT_APP_RELEASE"] || "dev";
|
|
54
55
|
var apiEnv = process.env["REACT_APP_API_ENV"];
|
|
56
|
+
var business = process.env["REACT_APP_BUSINESS"];
|
|
55
57
|
var assetsHost = "https://imgs.xianghuanji.com/";
|
|
56
58
|
var erpSaasOriginDic = {
|
|
57
59
|
dev: `http://test.erp-saas.t.eshetang.com`,
|
|
@@ -115,6 +117,7 @@ var sentryConfig = {
|
|
|
115
117
|
0 && (module.exports = {
|
|
116
118
|
apiEnv,
|
|
117
119
|
assetsHost,
|
|
120
|
+
business,
|
|
118
121
|
getBffApi,
|
|
119
122
|
getEnvDomain,
|
|
120
123
|
getErpSaasOrigin,
|
package/dist/env.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./chunk-
|
|
1
|
+
import "./chunk-6BSPRPK2.mjs";
|
|
2
2
|
|
|
3
3
|
// src/env.ts
|
|
4
4
|
var isServer = typeof window === "undefined";
|
|
@@ -16,6 +16,7 @@ var isWeiXin = /MicroMessenger/i.test(navigator.userAgent);
|
|
|
16
16
|
var isProduction = process.env["NODE_ENV"] === "production";
|
|
17
17
|
var release = process.env["REACT_APP_RELEASE"] || "dev";
|
|
18
18
|
var apiEnv = process.env["REACT_APP_API_ENV"];
|
|
19
|
+
var business = process.env["REACT_APP_BUSINESS"];
|
|
19
20
|
var assetsHost = "https://imgs.xianghuanji.com/";
|
|
20
21
|
var erpSaasOriginDic = {
|
|
21
22
|
dev: `http://test.erp-saas.t.eshetang.com`,
|
|
@@ -78,6 +79,7 @@ var sentryConfig = {
|
|
|
78
79
|
export {
|
|
79
80
|
apiEnv,
|
|
80
81
|
assetsHost,
|
|
82
|
+
business,
|
|
81
83
|
getBffApi,
|
|
82
84
|
getEnvDomain,
|
|
83
85
|
getErpSaasOrigin,
|
package/dist/loadScript.mjs
CHANGED
package/dist/token.mjs
CHANGED
package/dist/tools.d.mts
CHANGED
|
@@ -12,5 +12,31 @@ declare const throttle: (delay: number, callback: any) => {
|
|
|
12
12
|
declare const widthThrottle: (delay: number) => (target: any, _name: string, descriptor: PropertyDescriptor) => void;
|
|
13
13
|
declare const debounce: <T extends (...args: any) => any>(delay: number, callback: T) => T;
|
|
14
14
|
declare const resizeAliYun: (imgUrl?: string, width?: number) => string;
|
|
15
|
+
type FieldsWithoutArray<FS extends Record<string, any>> = {
|
|
16
|
+
[K in keyof FS]: FS[K] extends any[] | undefined ? string | undefined : FS[K];
|
|
17
|
+
};
|
|
18
|
+
declare const fieldsArrayToString: <FS extends Record<string, any>>(fields: FS) => FieldsWithoutArray<FS>;
|
|
19
|
+
type FieldsWithUndefined<FS extends Record<string, any>> = {
|
|
20
|
+
[K in keyof FS]: undefined;
|
|
21
|
+
};
|
|
22
|
+
declare const fieldsReset: <FS extends Record<string, any>>(fields: FS) => FieldsWithUndefined<FS>;
|
|
23
|
+
type ComboBox<Value = number> = {
|
|
24
|
+
name?: string;
|
|
25
|
+
id?: Value;
|
|
26
|
+
};
|
|
27
|
+
type OptionsType = {
|
|
28
|
+
label: string;
|
|
29
|
+
value: string | number;
|
|
30
|
+
}[];
|
|
31
|
+
type OptionsRecordType<Keys extends string | number | symbol = any> = {
|
|
32
|
+
[key in Keys]?: OptionsType;
|
|
33
|
+
};
|
|
34
|
+
type OptionsMapType<Keys extends string | number | symbol = any> = {
|
|
35
|
+
[key in Keys]?: Record<string, string>;
|
|
36
|
+
};
|
|
37
|
+
declare const combobox2Options: <CB extends Record<string, (ComboBox<number> | ComboBox<string>)[]>>(comboBox: CB) => {
|
|
38
|
+
options: OptionsRecordType<keyof CB>;
|
|
39
|
+
optionsMap: OptionsMapType<keyof CB>;
|
|
40
|
+
};
|
|
15
41
|
|
|
16
|
-
export { debounce, delayHandle, formatterPrice, formatterTax, getBase64, getObjectURL, mockSkeletons, resizeAliYun, throttle, widthThrottle };
|
|
42
|
+
export { type ComboBox, type OptionsMapType, type OptionsRecordType, type OptionsType, combobox2Options, debounce, delayHandle, fieldsArrayToString, fieldsReset, formatterPrice, formatterTax, getBase64, getObjectURL, mockSkeletons, resizeAliYun, throttle, widthThrottle };
|
package/dist/tools.d.ts
CHANGED
|
@@ -12,5 +12,31 @@ declare const throttle: (delay: number, callback: any) => {
|
|
|
12
12
|
declare const widthThrottle: (delay: number) => (target: any, _name: string, descriptor: PropertyDescriptor) => void;
|
|
13
13
|
declare const debounce: <T extends (...args: any) => any>(delay: number, callback: T) => T;
|
|
14
14
|
declare const resizeAliYun: (imgUrl?: string, width?: number) => string;
|
|
15
|
+
type FieldsWithoutArray<FS extends Record<string, any>> = {
|
|
16
|
+
[K in keyof FS]: FS[K] extends any[] | undefined ? string | undefined : FS[K];
|
|
17
|
+
};
|
|
18
|
+
declare const fieldsArrayToString: <FS extends Record<string, any>>(fields: FS) => FieldsWithoutArray<FS>;
|
|
19
|
+
type FieldsWithUndefined<FS extends Record<string, any>> = {
|
|
20
|
+
[K in keyof FS]: undefined;
|
|
21
|
+
};
|
|
22
|
+
declare const fieldsReset: <FS extends Record<string, any>>(fields: FS) => FieldsWithUndefined<FS>;
|
|
23
|
+
type ComboBox<Value = number> = {
|
|
24
|
+
name?: string;
|
|
25
|
+
id?: Value;
|
|
26
|
+
};
|
|
27
|
+
type OptionsType = {
|
|
28
|
+
label: string;
|
|
29
|
+
value: string | number;
|
|
30
|
+
}[];
|
|
31
|
+
type OptionsRecordType<Keys extends string | number | symbol = any> = {
|
|
32
|
+
[key in Keys]?: OptionsType;
|
|
33
|
+
};
|
|
34
|
+
type OptionsMapType<Keys extends string | number | symbol = any> = {
|
|
35
|
+
[key in Keys]?: Record<string, string>;
|
|
36
|
+
};
|
|
37
|
+
declare const combobox2Options: <CB extends Record<string, (ComboBox<number> | ComboBox<string>)[]>>(comboBox: CB) => {
|
|
38
|
+
options: OptionsRecordType<keyof CB>;
|
|
39
|
+
optionsMap: OptionsMapType<keyof CB>;
|
|
40
|
+
};
|
|
15
41
|
|
|
16
|
-
export { debounce, delayHandle, formatterPrice, formatterTax, getBase64, getObjectURL, mockSkeletons, resizeAliYun, throttle, widthThrottle };
|
|
42
|
+
export { type ComboBox, type OptionsMapType, type OptionsRecordType, type OptionsType, combobox2Options, debounce, delayHandle, fieldsArrayToString, fieldsReset, formatterPrice, formatterTax, getBase64, getObjectURL, mockSkeletons, resizeAliYun, throttle, widthThrottle };
|
package/dist/tools.js
CHANGED
|
@@ -2,7 +2,21 @@
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
6
20
|
var __export = (target, all) => {
|
|
7
21
|
for (var name in all)
|
|
8
22
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -20,8 +34,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
34
|
// src/tools.ts
|
|
21
35
|
var tools_exports = {};
|
|
22
36
|
__export(tools_exports, {
|
|
37
|
+
combobox2Options: () => combobox2Options,
|
|
23
38
|
debounce: () => debounce,
|
|
24
39
|
delayHandle: () => delayHandle,
|
|
40
|
+
fieldsArrayToString: () => fieldsArrayToString,
|
|
41
|
+
fieldsReset: () => fieldsReset,
|
|
25
42
|
formatterPrice: () => formatterPrice,
|
|
26
43
|
formatterTax: () => formatterTax,
|
|
27
44
|
getBase64: () => getBase64,
|
|
@@ -134,10 +151,46 @@ var resizeAliYun = (imgUrl = "", width = 300) => {
|
|
|
134
151
|
imgUrl = imgUrl.replace(/[?#].*/g, "");
|
|
135
152
|
return `${imgUrl}?x-oss-process=image/resize,w_${width}`;
|
|
136
153
|
};
|
|
154
|
+
var fieldsArrayToString = (fields) => {
|
|
155
|
+
const fieldsCopy = __spreadValues({}, fields);
|
|
156
|
+
Object.keys(fieldsCopy).forEach((key) => {
|
|
157
|
+
const typeKey = key;
|
|
158
|
+
const value = fieldsCopy[typeKey];
|
|
159
|
+
if (Array.isArray(value))
|
|
160
|
+
fieldsCopy[typeKey] = value.join(",");
|
|
161
|
+
});
|
|
162
|
+
return fieldsCopy;
|
|
163
|
+
};
|
|
164
|
+
var fieldsReset = (fields) => {
|
|
165
|
+
const fieldsCopy = __spreadValues({}, fields);
|
|
166
|
+
Object.keys(fieldsCopy).forEach((key) => {
|
|
167
|
+
const typeKey = key;
|
|
168
|
+
fieldsCopy[typeKey] = void 0;
|
|
169
|
+
});
|
|
170
|
+
return fieldsCopy;
|
|
171
|
+
};
|
|
172
|
+
var combobox2Options = (comboBox) => {
|
|
173
|
+
const options = {};
|
|
174
|
+
const optionsMap = {};
|
|
175
|
+
Object.keys(comboBox).forEach((key) => {
|
|
176
|
+
const optionsKey = key;
|
|
177
|
+
const optionsList = comboBox[optionsKey];
|
|
178
|
+
options[optionsKey] = (optionsList == null ? void 0 : optionsList.map(({ name = "", id = "" }) => {
|
|
179
|
+
if (!optionsMap[optionsKey])
|
|
180
|
+
optionsMap[optionsKey] = {};
|
|
181
|
+
optionsMap[optionsKey][id] = name;
|
|
182
|
+
return { label: name, value: id };
|
|
183
|
+
})) || [];
|
|
184
|
+
});
|
|
185
|
+
return { options, optionsMap };
|
|
186
|
+
};
|
|
137
187
|
// Annotate the CommonJS export names for ESM import in node:
|
|
138
188
|
0 && (module.exports = {
|
|
189
|
+
combobox2Options,
|
|
139
190
|
debounce,
|
|
140
191
|
delayHandle,
|
|
192
|
+
fieldsArrayToString,
|
|
193
|
+
fieldsReset,
|
|
141
194
|
formatterPrice,
|
|
142
195
|
formatterTax,
|
|
143
196
|
getBase64,
|
package/dist/tools.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
__spreadValues
|
|
3
|
+
} from "./chunk-6BSPRPK2.mjs";
|
|
2
4
|
|
|
3
5
|
// src/tools.ts
|
|
4
6
|
var mockSkeletons = (length, fn) => {
|
|
@@ -103,9 +105,45 @@ var resizeAliYun = (imgUrl = "", width = 300) => {
|
|
|
103
105
|
imgUrl = imgUrl.replace(/[?#].*/g, "");
|
|
104
106
|
return `${imgUrl}?x-oss-process=image/resize,w_${width}`;
|
|
105
107
|
};
|
|
108
|
+
var fieldsArrayToString = (fields) => {
|
|
109
|
+
const fieldsCopy = __spreadValues({}, fields);
|
|
110
|
+
Object.keys(fieldsCopy).forEach((key) => {
|
|
111
|
+
const typeKey = key;
|
|
112
|
+
const value = fieldsCopy[typeKey];
|
|
113
|
+
if (Array.isArray(value))
|
|
114
|
+
fieldsCopy[typeKey] = value.join(",");
|
|
115
|
+
});
|
|
116
|
+
return fieldsCopy;
|
|
117
|
+
};
|
|
118
|
+
var fieldsReset = (fields) => {
|
|
119
|
+
const fieldsCopy = __spreadValues({}, fields);
|
|
120
|
+
Object.keys(fieldsCopy).forEach((key) => {
|
|
121
|
+
const typeKey = key;
|
|
122
|
+
fieldsCopy[typeKey] = void 0;
|
|
123
|
+
});
|
|
124
|
+
return fieldsCopy;
|
|
125
|
+
};
|
|
126
|
+
var combobox2Options = (comboBox) => {
|
|
127
|
+
const options = {};
|
|
128
|
+
const optionsMap = {};
|
|
129
|
+
Object.keys(comboBox).forEach((key) => {
|
|
130
|
+
const optionsKey = key;
|
|
131
|
+
const optionsList = comboBox[optionsKey];
|
|
132
|
+
options[optionsKey] = (optionsList == null ? void 0 : optionsList.map(({ name = "", id = "" }) => {
|
|
133
|
+
if (!optionsMap[optionsKey])
|
|
134
|
+
optionsMap[optionsKey] = {};
|
|
135
|
+
optionsMap[optionsKey][id] = name;
|
|
136
|
+
return { label: name, value: id };
|
|
137
|
+
})) || [];
|
|
138
|
+
});
|
|
139
|
+
return { options, optionsMap };
|
|
140
|
+
};
|
|
106
141
|
export {
|
|
142
|
+
combobox2Options,
|
|
107
143
|
debounce,
|
|
108
144
|
delayHandle,
|
|
145
|
+
fieldsArrayToString,
|
|
146
|
+
fieldsReset,
|
|
109
147
|
formatterPrice,
|
|
110
148
|
formatterTax,
|
|
111
149
|
getBase64,
|
package/dist/valid.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xfe-repo/web-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"exports": {
|
|
6
6
|
"./*": {
|
|
@@ -18,11 +18,8 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/js-cookie": "^3.0.5",
|
|
20
20
|
"@types/node": "^20.10.3",
|
|
21
|
-
"eslint": "^8.53.0",
|
|
22
|
-
"tsup": "^8.0.1",
|
|
23
|
-
"typescript": "^5.2.2",
|
|
24
21
|
"@xfe-repo/eslint-config": "0.0.1",
|
|
25
|
-
"@xfe-repo/typescript-config": "0.0.
|
|
22
|
+
"@xfe-repo/typescript-config": "0.0.2"
|
|
26
23
|
},
|
|
27
24
|
"scripts": {
|
|
28
25
|
"build": "tsup",
|