@etsoo/smarterp-core 1.0.93 → 1.0.95
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/lib/cjs/CoreUtils.d.ts +7 -0
- package/lib/cjs/CoreUtils.js +14 -0
- package/lib/cjs/components/public/ButtonCultures.d.ts +1 -1
- package/lib/cjs/components/public/ButtonCultures.js +2 -3
- package/lib/cjs/components/public/ButtonRadioRegions.d.ts +1 -1
- package/lib/cjs/components/public/ButtonRadioRegions.js +2 -6
- package/lib/cjs/components/public/ButtonRegions.d.ts +1 -1
- package/lib/cjs/components/public/ButtonRegions.js +2 -6
- package/lib/mjs/CoreUtils.d.ts +7 -0
- package/lib/mjs/CoreUtils.js +14 -0
- package/lib/mjs/components/public/ButtonCultures.d.ts +1 -1
- package/lib/mjs/components/public/ButtonCultures.js +2 -3
- package/lib/mjs/components/public/ButtonRadioRegions.d.ts +1 -1
- package/lib/mjs/components/public/ButtonRadioRegions.js +2 -6
- package/lib/mjs/components/public/ButtonRegions.d.ts +1 -1
- package/lib/mjs/components/public/ButtonRegions.js +2 -6
- package/package.json +3 -3
- package/src/CoreUtils.ts +13 -0
- package/src/components/public/ButtonCultures.tsx +1 -2
- package/src/components/public/ButtonRadioRegions.tsx +2 -5
- package/src/components/public/ButtonRegions.tsx +2 -5
package/lib/cjs/CoreUtils.d.ts
CHANGED
|
@@ -10,6 +10,13 @@ export declare namespace CoreUtils {
|
|
|
10
10
|
* @returns Styles
|
|
11
11
|
*/
|
|
12
12
|
function avatarStyles(isOrg?: boolean): React.CSSProperties;
|
|
13
|
+
/**
|
|
14
|
+
* Merge an array with another array, starting from the end
|
|
15
|
+
* 合并数组,从末尾开始
|
|
16
|
+
* @param source Source array
|
|
17
|
+
* @param target Target array
|
|
18
|
+
*/
|
|
19
|
+
function mergeArray(source: string[], target: string[]): void;
|
|
13
20
|
/**
|
|
14
21
|
* Validate JSON input against a schema
|
|
15
22
|
* 验证 JSON 输入是否符合架构
|
package/lib/cjs/CoreUtils.js
CHANGED
|
@@ -24,6 +24,20 @@ var CoreUtils;
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
CoreUtils.avatarStyles = avatarStyles;
|
|
27
|
+
/**
|
|
28
|
+
* Merge an array with another array, starting from the end
|
|
29
|
+
* 合并数组,从末尾开始
|
|
30
|
+
* @param source Source array
|
|
31
|
+
* @param target Target array
|
|
32
|
+
*/
|
|
33
|
+
function mergeArray(source, target) {
|
|
34
|
+
for (let i = target.length - 1; i >= 0; i--) {
|
|
35
|
+
const r = source[i];
|
|
36
|
+
if (!source.includes(r))
|
|
37
|
+
source.unshift(r);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
CoreUtils.mergeArray = mergeArray;
|
|
27
41
|
let ajv = null;
|
|
28
42
|
/**
|
|
29
43
|
* Validate JSON input against a schema
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
|
|
2
2
|
import { CultureItem } from "@etsoo/appscript";
|
|
3
|
-
export declare function ButtonCultures(props: Omit<ButtonPopupCheckboxProps<CultureItem>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element
|
|
3
|
+
export declare function ButtonCultures(props: Omit<ButtonPopupCheckboxProps<CultureItem>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -30,9 +30,8 @@ function ButtonCultures(props) {
|
|
|
30
30
|
// Add application cultures, starting from the end
|
|
31
31
|
for (let i = app.settings.cultures.length - 1; i >= 0; i--) {
|
|
32
32
|
const c = app.settings.cultures[i];
|
|
33
|
-
if (defaultCultures.includes(c.name))
|
|
34
|
-
|
|
35
|
-
defaultCultures.unshift(c.name);
|
|
33
|
+
if (!defaultCultures.includes(c.name))
|
|
34
|
+
defaultCultures.unshift(c.name);
|
|
36
35
|
}
|
|
37
36
|
defaultCultures.sort((a) => (app.culture.startsWith(a) ? -1 : 0));
|
|
38
37
|
// Load data
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ButtonPopupRadioProps } from "@etsoo/materialui";
|
|
2
2
|
import { RegionData } from "../../dto/public/RegionData";
|
|
3
|
-
export declare function ButtonRadioRegions(props: Omit<ButtonPopupRadioProps<RegionData>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element
|
|
3
|
+
export declare function ButtonRadioRegions(props: Omit<ButtonPopupRadioProps<RegionData>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -8,6 +8,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const materialui_1 = require("@etsoo/materialui");
|
|
9
9
|
const ICoreServiceApp_1 = require("../../ICoreServiceApp");
|
|
10
10
|
const react_1 = __importDefault(require("react"));
|
|
11
|
+
const CoreUtils_1 = require("../../CoreUtils");
|
|
11
12
|
function ButtonRadioRegions(props) {
|
|
12
13
|
// App
|
|
13
14
|
const app = (0, ICoreServiceApp_1.useRequiredAppContext)();
|
|
@@ -30,12 +31,7 @@ function ButtonRadioRegions(props) {
|
|
|
30
31
|
"HK"
|
|
31
32
|
];
|
|
32
33
|
// Add application regions, starting from the end
|
|
33
|
-
|
|
34
|
-
const r = app.settings.regions[i];
|
|
35
|
-
if (defaultRegions.includes(r))
|
|
36
|
-
return;
|
|
37
|
-
defaultRegions.unshift(r);
|
|
38
|
-
}
|
|
34
|
+
CoreUtils_1.CoreUtils.mergeArray(defaultRegions, app.settings.regions);
|
|
39
35
|
// Load data
|
|
40
36
|
const loadData = react_1.default.useCallback(async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [], []);
|
|
41
37
|
return ((0, jsx_runtime_1.jsx)(materialui_1.ButtonPopupRadio, { inputName: inputName, label: label, labelFormatter: (data) => `${data.name} (${data.id})`, labelEnd: labelEnd, labelField: "name", loadData: loadData, onAdd: async (ids) => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
|
|
2
2
|
import { RegionData } from "../../dto/public/RegionData";
|
|
3
|
-
export declare function ButtonRegions(props: Omit<ButtonPopupCheckboxProps<RegionData>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element
|
|
3
|
+
export declare function ButtonRegions(props: Omit<ButtonPopupCheckboxProps<RegionData>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -8,6 +8,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const materialui_1 = require("@etsoo/materialui");
|
|
9
9
|
const ICoreServiceApp_1 = require("../../ICoreServiceApp");
|
|
10
10
|
const react_1 = __importDefault(require("react"));
|
|
11
|
+
const CoreUtils_1 = require("../../CoreUtils");
|
|
11
12
|
function ButtonRegions(props) {
|
|
12
13
|
// App
|
|
13
14
|
const app = (0, ICoreServiceApp_1.useRequiredAppContext)();
|
|
@@ -30,12 +31,7 @@ function ButtonRegions(props) {
|
|
|
30
31
|
"HK"
|
|
31
32
|
];
|
|
32
33
|
// Add application regions, starting from the end
|
|
33
|
-
|
|
34
|
-
const r = app.settings.regions[i];
|
|
35
|
-
if (defaultRegions.includes(r))
|
|
36
|
-
return;
|
|
37
|
-
defaultRegions.unshift(r);
|
|
38
|
-
}
|
|
34
|
+
CoreUtils_1.CoreUtils.mergeArray(defaultRegions, app.settings.regions);
|
|
39
35
|
// Load data
|
|
40
36
|
const loadData = react_1.default.useCallback(async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [], []);
|
|
41
37
|
return ((0, jsx_runtime_1.jsx)(materialui_1.ButtonPopupCheckbox, { inputName: inputName, label: label, labelFormatter: (data) => `${data.name} (${data.id})`, labelEnd: labelEnd, labelField: "name", loadData: loadData, onAdd: async (ids) => {
|
package/lib/mjs/CoreUtils.d.ts
CHANGED
|
@@ -10,6 +10,13 @@ export declare namespace CoreUtils {
|
|
|
10
10
|
* @returns Styles
|
|
11
11
|
*/
|
|
12
12
|
function avatarStyles(isOrg?: boolean): React.CSSProperties;
|
|
13
|
+
/**
|
|
14
|
+
* Merge an array with another array, starting from the end
|
|
15
|
+
* 合并数组,从末尾开始
|
|
16
|
+
* @param source Source array
|
|
17
|
+
* @param target Target array
|
|
18
|
+
*/
|
|
19
|
+
function mergeArray(source: string[], target: string[]): void;
|
|
13
20
|
/**
|
|
14
21
|
* Validate JSON input against a schema
|
|
15
22
|
* 验证 JSON 输入是否符合架构
|
package/lib/mjs/CoreUtils.js
CHANGED
|
@@ -18,6 +18,20 @@ export var CoreUtils;
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
CoreUtils.avatarStyles = avatarStyles;
|
|
21
|
+
/**
|
|
22
|
+
* Merge an array with another array, starting from the end
|
|
23
|
+
* 合并数组,从末尾开始
|
|
24
|
+
* @param source Source array
|
|
25
|
+
* @param target Target array
|
|
26
|
+
*/
|
|
27
|
+
function mergeArray(source, target) {
|
|
28
|
+
for (let i = target.length - 1; i >= 0; i--) {
|
|
29
|
+
const r = source[i];
|
|
30
|
+
if (!source.includes(r))
|
|
31
|
+
source.unshift(r);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
CoreUtils.mergeArray = mergeArray;
|
|
21
35
|
let ajv = null;
|
|
22
36
|
/**
|
|
23
37
|
* Validate JSON input against a schema
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
|
|
2
2
|
import { CultureItem } from "@etsoo/appscript";
|
|
3
|
-
export declare function ButtonCultures(props: Omit<ButtonPopupCheckboxProps<CultureItem>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element
|
|
3
|
+
export declare function ButtonCultures(props: Omit<ButtonPopupCheckboxProps<CultureItem>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -24,9 +24,8 @@ export function ButtonCultures(props) {
|
|
|
24
24
|
// Add application cultures, starting from the end
|
|
25
25
|
for (let i = app.settings.cultures.length - 1; i >= 0; i--) {
|
|
26
26
|
const c = app.settings.cultures[i];
|
|
27
|
-
if (defaultCultures.includes(c.name))
|
|
28
|
-
|
|
29
|
-
defaultCultures.unshift(c.name);
|
|
27
|
+
if (!defaultCultures.includes(c.name))
|
|
28
|
+
defaultCultures.unshift(c.name);
|
|
30
29
|
}
|
|
31
30
|
defaultCultures.sort((a) => (app.culture.startsWith(a) ? -1 : 0));
|
|
32
31
|
// Load data
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ButtonPopupRadioProps } from "@etsoo/materialui";
|
|
2
2
|
import { RegionData } from "../../dto/public/RegionData";
|
|
3
|
-
export declare function ButtonRadioRegions(props: Omit<ButtonPopupRadioProps<RegionData>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element
|
|
3
|
+
export declare function ButtonRadioRegions(props: Omit<ButtonPopupRadioProps<RegionData>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { ButtonPopupRadio } from "@etsoo/materialui";
|
|
3
3
|
import { useRequiredAppContext } from "../../ICoreServiceApp";
|
|
4
4
|
import React from "react";
|
|
5
|
+
import { CoreUtils } from "../../CoreUtils";
|
|
5
6
|
export function ButtonRadioRegions(props) {
|
|
6
7
|
// App
|
|
7
8
|
const app = useRequiredAppContext();
|
|
@@ -24,12 +25,7 @@ export function ButtonRadioRegions(props) {
|
|
|
24
25
|
"HK"
|
|
25
26
|
];
|
|
26
27
|
// Add application regions, starting from the end
|
|
27
|
-
|
|
28
|
-
const r = app.settings.regions[i];
|
|
29
|
-
if (defaultRegions.includes(r))
|
|
30
|
-
return;
|
|
31
|
-
defaultRegions.unshift(r);
|
|
32
|
-
}
|
|
28
|
+
CoreUtils.mergeArray(defaultRegions, app.settings.regions);
|
|
33
29
|
// Load data
|
|
34
30
|
const loadData = React.useCallback(async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [], []);
|
|
35
31
|
return (_jsx(ButtonPopupRadio, { inputName: inputName, label: label, labelFormatter: (data) => `${data.name} (${data.id})`, labelEnd: labelEnd, labelField: "name", loadData: loadData, onAdd: async (ids) => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
|
|
2
2
|
import { RegionData } from "../../dto/public/RegionData";
|
|
3
|
-
export declare function ButtonRegions(props: Omit<ButtonPopupCheckboxProps<RegionData>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element
|
|
3
|
+
export declare function ButtonRegions(props: Omit<ButtonPopupCheckboxProps<RegionData>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { ButtonPopupCheckbox } from "@etsoo/materialui";
|
|
3
3
|
import { useRequiredAppContext } from "../../ICoreServiceApp";
|
|
4
4
|
import React from "react";
|
|
5
|
+
import { CoreUtils } from "../../CoreUtils";
|
|
5
6
|
export function ButtonRegions(props) {
|
|
6
7
|
// App
|
|
7
8
|
const app = useRequiredAppContext();
|
|
@@ -24,12 +25,7 @@ export function ButtonRegions(props) {
|
|
|
24
25
|
"HK"
|
|
25
26
|
];
|
|
26
27
|
// Add application regions, starting from the end
|
|
27
|
-
|
|
28
|
-
const r = app.settings.regions[i];
|
|
29
|
-
if (defaultRegions.includes(r))
|
|
30
|
-
return;
|
|
31
|
-
defaultRegions.unshift(r);
|
|
32
|
-
}
|
|
28
|
+
CoreUtils.mergeArray(defaultRegions, app.settings.regions);
|
|
33
29
|
// Load data
|
|
34
30
|
const loadData = React.useCallback(async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [], []);
|
|
35
31
|
return (_jsx(ButtonPopupCheckbox, { inputName: inputName, label: label, labelFormatter: (data) => `${data.name} (${data.id})`, labelEnd: labelEnd, labelField: "name", loadData: loadData, onAdd: async (ids) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/smarterp-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.95",
|
|
4
4
|
"description": "TypeScript APIs for SmartERP Core",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
"@babel/runtime-corejs3": "^7.28.0",
|
|
48
48
|
"@types/react": "^18.3.23",
|
|
49
49
|
"@types/react-dom": "^18.3.7",
|
|
50
|
-
"@vitejs/plugin-react": "^4.
|
|
50
|
+
"@vitejs/plugin-react": "^4.7.0",
|
|
51
51
|
"jsdom": "^26.1.0",
|
|
52
52
|
"typescript": "^5.8.3",
|
|
53
53
|
"vitest": "^3.2.4"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@etsoo/appscript": "^1.6.43",
|
|
57
|
-
"@etsoo/materialui": "^1.5.
|
|
57
|
+
"@etsoo/materialui": "^1.5.67",
|
|
58
58
|
"@etsoo/react": "^1.8.49",
|
|
59
59
|
"@etsoo/shared": "^1.2.75",
|
|
60
60
|
"@etsoo/toolpad": "^1.0.40",
|
package/src/CoreUtils.ts
CHANGED
|
@@ -20,6 +20,19 @@ export namespace CoreUtils {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Merge an array with another array, starting from the end
|
|
25
|
+
* 合并数组,从末尾开始
|
|
26
|
+
* @param source Source array
|
|
27
|
+
* @param target Target array
|
|
28
|
+
*/
|
|
29
|
+
export function mergeArray(source: string[], target: string[]) {
|
|
30
|
+
for (let i = target.length - 1; i >= 0; i--) {
|
|
31
|
+
const r = source[i];
|
|
32
|
+
if (!source.includes(r)) source.unshift(r);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
23
36
|
let ajv: Ajv | null = null;
|
|
24
37
|
|
|
25
38
|
/**
|
|
@@ -39,8 +39,7 @@ export function ButtonCultures(
|
|
|
39
39
|
// Add application cultures, starting from the end
|
|
40
40
|
for (let i = app.settings.cultures.length - 1; i >= 0; i--) {
|
|
41
41
|
const c = app.settings.cultures[i];
|
|
42
|
-
if (defaultCultures.includes(c.name))
|
|
43
|
-
defaultCultures.unshift(c.name);
|
|
42
|
+
if (!defaultCultures.includes(c.name)) defaultCultures.unshift(c.name);
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
defaultCultures.sort((a) => (app.culture.startsWith(a) ? -1 : 0));
|
|
@@ -2,6 +2,7 @@ import { ButtonPopupRadio, ButtonPopupRadioProps } from "@etsoo/materialui";
|
|
|
2
2
|
import { useRequiredAppContext } from "../../ICoreServiceApp";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { RegionData } from "../../dto/public/RegionData";
|
|
5
|
+
import { CoreUtils } from "../../CoreUtils";
|
|
5
6
|
|
|
6
7
|
export function ButtonRadioRegions(
|
|
7
8
|
props: Omit<ButtonPopupRadioProps<RegionData>, "labelField" | "loadData">
|
|
@@ -36,11 +37,7 @@ export function ButtonRadioRegions(
|
|
|
36
37
|
];
|
|
37
38
|
|
|
38
39
|
// Add application regions, starting from the end
|
|
39
|
-
|
|
40
|
-
const r = app.settings.regions[i];
|
|
41
|
-
if (defaultRegions.includes(r)) return;
|
|
42
|
-
defaultRegions.unshift(r);
|
|
43
|
-
}
|
|
40
|
+
CoreUtils.mergeArray(defaultRegions, app.settings.regions);
|
|
44
41
|
|
|
45
42
|
// Load data
|
|
46
43
|
const loadData = React.useCallback(
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
import { RegionData } from "../../dto/public/RegionData";
|
|
6
6
|
import { useRequiredAppContext } from "../../ICoreServiceApp";
|
|
7
7
|
import React from "react";
|
|
8
|
+
import { CoreUtils } from "../../CoreUtils";
|
|
8
9
|
|
|
9
10
|
export function ButtonRegions(
|
|
10
11
|
props: Omit<ButtonPopupCheckboxProps<RegionData>, "labelField" | "loadData">
|
|
@@ -39,11 +40,7 @@ export function ButtonRegions(
|
|
|
39
40
|
];
|
|
40
41
|
|
|
41
42
|
// Add application regions, starting from the end
|
|
42
|
-
|
|
43
|
-
const r = app.settings.regions[i];
|
|
44
|
-
if (defaultRegions.includes(r)) return;
|
|
45
|
-
defaultRegions.unshift(r);
|
|
46
|
-
}
|
|
43
|
+
CoreUtils.mergeArray(defaultRegions, app.settings.regions);
|
|
47
44
|
|
|
48
45
|
// Load data
|
|
49
46
|
const loadData = React.useCallback(
|