@etsoo/smarterp-core 1.0.92 → 1.0.94
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/index.d.ts +1 -0
- package/lib/cjs/components/index.js +1 -0
- package/lib/cjs/components/public/ButtonCultures.js +6 -0
- package/lib/cjs/components/public/ButtonRadioRegions.d.ts +3 -0
- package/lib/cjs/components/public/ButtonRadioRegions.js +43 -0
- package/lib/cjs/components/public/ButtonRegions.js +3 -0
- package/lib/mjs/CoreUtils.d.ts +7 -0
- package/lib/mjs/CoreUtils.js +14 -0
- package/lib/mjs/components/index.d.ts +1 -0
- package/lib/mjs/components/index.js +1 -0
- package/lib/mjs/components/public/ButtonCultures.js +6 -0
- package/lib/mjs/components/public/ButtonRadioRegions.d.ts +3 -0
- package/lib/mjs/components/public/ButtonRadioRegions.js +37 -0
- package/lib/mjs/components/public/ButtonRegions.js +3 -0
- package/package.json +1 -1
- package/src/CoreUtils.ts +13 -0
- package/src/components/index.ts +1 -0
- package/src/components/public/ButtonCultures.tsx +6 -0
- package/src/components/public/ButtonRadioRegions.tsx +64 -0
- package/src/components/public/ButtonRegions.tsx +4 -0
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
|
|
@@ -11,6 +11,7 @@ export * from "./org/OrgSwitchPopover";
|
|
|
11
11
|
export * from "./org/OrgTiplist";
|
|
12
12
|
export * from "./public/ButtonCultures";
|
|
13
13
|
export * from "./public/ButtonCurrencies";
|
|
14
|
+
export * from "./public/ButtonRadioRegions";
|
|
14
15
|
export * from "./public/ButtonRegions";
|
|
15
16
|
export * from "./public/CultureList";
|
|
16
17
|
export * from "./user/UserTiplist";
|
|
@@ -31,6 +31,7 @@ __exportStar(require("./org/OrgTiplist"), exports);
|
|
|
31
31
|
// public
|
|
32
32
|
__exportStar(require("./public/ButtonCultures"), exports);
|
|
33
33
|
__exportStar(require("./public/ButtonCurrencies"), exports);
|
|
34
|
+
__exportStar(require("./public/ButtonRadioRegions"), exports);
|
|
34
35
|
__exportStar(require("./public/ButtonRegions"), exports);
|
|
35
36
|
__exportStar(require("./public/CultureList"), exports);
|
|
36
37
|
// user
|
|
@@ -27,6 +27,12 @@ function ButtonCultures(props) {
|
|
|
27
27
|
"ru",
|
|
28
28
|
"ar"
|
|
29
29
|
];
|
|
30
|
+
// Add application cultures, starting from the end
|
|
31
|
+
for (let i = app.settings.cultures.length - 1; i >= 0; i--) {
|
|
32
|
+
const c = app.settings.cultures[i];
|
|
33
|
+
if (!defaultCultures.includes(c.name))
|
|
34
|
+
defaultCultures.unshift(c.name);
|
|
35
|
+
}
|
|
30
36
|
defaultCultures.sort((a) => (app.culture.startsWith(a) ? -1 : 0));
|
|
31
37
|
// Load data
|
|
32
38
|
const loadData = react_1.default.useCallback(async () => (await app.core.publicApi.getCultures(defaultCultures)) ?? [], []);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ButtonPopupRadioProps } from "@etsoo/materialui";
|
|
2
|
+
import { RegionData } from "../../dto/public/RegionData";
|
|
3
|
+
export declare function ButtonRadioRegions(props: Omit<ButtonPopupRadioProps<RegionData>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ButtonRadioRegions = ButtonRadioRegions;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const materialui_1 = require("@etsoo/materialui");
|
|
9
|
+
const ICoreServiceApp_1 = require("../../ICoreServiceApp");
|
|
10
|
+
const react_1 = __importDefault(require("react"));
|
|
11
|
+
const CoreUtils_1 = require("../../CoreUtils");
|
|
12
|
+
function ButtonRadioRegions(props) {
|
|
13
|
+
// App
|
|
14
|
+
const app = (0, ICoreServiceApp_1.useRequiredAppContext)();
|
|
15
|
+
// Labels
|
|
16
|
+
const labels = app.getLabels("clickToChoose", "region");
|
|
17
|
+
// Destruct
|
|
18
|
+
const { inputName = "region", label = labels.region, labelEnd = labels.clickToChoose, ...rest } = props;
|
|
19
|
+
const defaultRegions = [
|
|
20
|
+
"CN",
|
|
21
|
+
"US",
|
|
22
|
+
"GB",
|
|
23
|
+
"IE",
|
|
24
|
+
"CA",
|
|
25
|
+
"AU",
|
|
26
|
+
"NZ",
|
|
27
|
+
"DE",
|
|
28
|
+
"FR",
|
|
29
|
+
"JP",
|
|
30
|
+
"SG",
|
|
31
|
+
"HK"
|
|
32
|
+
];
|
|
33
|
+
// Add application regions, starting from the end
|
|
34
|
+
CoreUtils_1.CoreUtils.mergeArray(defaultRegions, app.settings.regions);
|
|
35
|
+
// Load data
|
|
36
|
+
const loadData = react_1.default.useCallback(async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [], []);
|
|
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) => {
|
|
38
|
+
const data = await app.core.publicApi.getRegions(ids);
|
|
39
|
+
if (data == null)
|
|
40
|
+
return false;
|
|
41
|
+
return data;
|
|
42
|
+
}, ...rest }));
|
|
43
|
+
}
|
|
@@ -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)();
|
|
@@ -29,6 +30,8 @@ function ButtonRegions(props) {
|
|
|
29
30
|
"SG",
|
|
30
31
|
"HK"
|
|
31
32
|
];
|
|
33
|
+
// Add application regions, starting from the end
|
|
34
|
+
CoreUtils_1.CoreUtils.mergeArray(defaultRegions, app.settings.regions);
|
|
32
35
|
// Load data
|
|
33
36
|
const loadData = react_1.default.useCallback(async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [], []);
|
|
34
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
|
|
@@ -11,6 +11,7 @@ export * from "./org/OrgSwitchPopover";
|
|
|
11
11
|
export * from "./org/OrgTiplist";
|
|
12
12
|
export * from "./public/ButtonCultures";
|
|
13
13
|
export * from "./public/ButtonCurrencies";
|
|
14
|
+
export * from "./public/ButtonRadioRegions";
|
|
14
15
|
export * from "./public/ButtonRegions";
|
|
15
16
|
export * from "./public/CultureList";
|
|
16
17
|
export * from "./user/UserTiplist";
|
|
@@ -15,6 +15,7 @@ export * from "./org/OrgTiplist";
|
|
|
15
15
|
// public
|
|
16
16
|
export * from "./public/ButtonCultures";
|
|
17
17
|
export * from "./public/ButtonCurrencies";
|
|
18
|
+
export * from "./public/ButtonRadioRegions";
|
|
18
19
|
export * from "./public/ButtonRegions";
|
|
19
20
|
export * from "./public/CultureList";
|
|
20
21
|
// user
|
|
@@ -21,6 +21,12 @@ export function ButtonCultures(props) {
|
|
|
21
21
|
"ru",
|
|
22
22
|
"ar"
|
|
23
23
|
];
|
|
24
|
+
// Add application cultures, starting from the end
|
|
25
|
+
for (let i = app.settings.cultures.length - 1; i >= 0; i--) {
|
|
26
|
+
const c = app.settings.cultures[i];
|
|
27
|
+
if (!defaultCultures.includes(c.name))
|
|
28
|
+
defaultCultures.unshift(c.name);
|
|
29
|
+
}
|
|
24
30
|
defaultCultures.sort((a) => (app.culture.startsWith(a) ? -1 : 0));
|
|
25
31
|
// Load data
|
|
26
32
|
const loadData = React.useCallback(async () => (await app.core.publicApi.getCultures(defaultCultures)) ?? [], []);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ButtonPopupRadioProps } from "@etsoo/materialui";
|
|
2
|
+
import { RegionData } from "../../dto/public/RegionData";
|
|
3
|
+
export declare function ButtonRadioRegions(props: Omit<ButtonPopupRadioProps<RegionData>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ButtonPopupRadio } from "@etsoo/materialui";
|
|
3
|
+
import { useRequiredAppContext } from "../../ICoreServiceApp";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { CoreUtils } from "../../CoreUtils";
|
|
6
|
+
export function ButtonRadioRegions(props) {
|
|
7
|
+
// App
|
|
8
|
+
const app = useRequiredAppContext();
|
|
9
|
+
// Labels
|
|
10
|
+
const labels = app.getLabels("clickToChoose", "region");
|
|
11
|
+
// Destruct
|
|
12
|
+
const { inputName = "region", label = labels.region, labelEnd = labels.clickToChoose, ...rest } = props;
|
|
13
|
+
const defaultRegions = [
|
|
14
|
+
"CN",
|
|
15
|
+
"US",
|
|
16
|
+
"GB",
|
|
17
|
+
"IE",
|
|
18
|
+
"CA",
|
|
19
|
+
"AU",
|
|
20
|
+
"NZ",
|
|
21
|
+
"DE",
|
|
22
|
+
"FR",
|
|
23
|
+
"JP",
|
|
24
|
+
"SG",
|
|
25
|
+
"HK"
|
|
26
|
+
];
|
|
27
|
+
// Add application regions, starting from the end
|
|
28
|
+
CoreUtils.mergeArray(defaultRegions, app.settings.regions);
|
|
29
|
+
// Load data
|
|
30
|
+
const loadData = React.useCallback(async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [], []);
|
|
31
|
+
return (_jsx(ButtonPopupRadio, { inputName: inputName, label: label, labelFormatter: (data) => `${data.name} (${data.id})`, labelEnd: labelEnd, labelField: "name", loadData: loadData, onAdd: async (ids) => {
|
|
32
|
+
const data = await app.core.publicApi.getRegions(ids);
|
|
33
|
+
if (data == null)
|
|
34
|
+
return false;
|
|
35
|
+
return data;
|
|
36
|
+
}, ...rest }));
|
|
37
|
+
}
|
|
@@ -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();
|
|
@@ -23,6 +24,8 @@ export function ButtonRegions(props) {
|
|
|
23
24
|
"SG",
|
|
24
25
|
"HK"
|
|
25
26
|
];
|
|
27
|
+
// Add application regions, starting from the end
|
|
28
|
+
CoreUtils.mergeArray(defaultRegions, app.settings.regions);
|
|
26
29
|
// Load data
|
|
27
30
|
const loadData = React.useCallback(async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [], []);
|
|
28
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
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
|
/**
|
package/src/components/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./org/OrgTiplist";
|
|
|
18
18
|
// public
|
|
19
19
|
export * from "./public/ButtonCultures";
|
|
20
20
|
export * from "./public/ButtonCurrencies";
|
|
21
|
+
export * from "./public/ButtonRadioRegions";
|
|
21
22
|
export * from "./public/ButtonRegions";
|
|
22
23
|
export * from "./public/CultureList";
|
|
23
24
|
|
|
@@ -36,6 +36,12 @@ export function ButtonCultures(
|
|
|
36
36
|
"ar"
|
|
37
37
|
];
|
|
38
38
|
|
|
39
|
+
// Add application cultures, starting from the end
|
|
40
|
+
for (let i = app.settings.cultures.length - 1; i >= 0; i--) {
|
|
41
|
+
const c = app.settings.cultures[i];
|
|
42
|
+
if (!defaultCultures.includes(c.name)) defaultCultures.unshift(c.name);
|
|
43
|
+
}
|
|
44
|
+
|
|
39
45
|
defaultCultures.sort((a) => (app.culture.startsWith(a) ? -1 : 0));
|
|
40
46
|
|
|
41
47
|
// Load data
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ButtonPopupRadio, ButtonPopupRadioProps } from "@etsoo/materialui";
|
|
2
|
+
import { useRequiredAppContext } from "../../ICoreServiceApp";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { RegionData } from "../../dto/public/RegionData";
|
|
5
|
+
import { CoreUtils } from "../../CoreUtils";
|
|
6
|
+
|
|
7
|
+
export function ButtonRadioRegions(
|
|
8
|
+
props: Omit<ButtonPopupRadioProps<RegionData>, "labelField" | "loadData">
|
|
9
|
+
) {
|
|
10
|
+
// App
|
|
11
|
+
const app = useRequiredAppContext();
|
|
12
|
+
|
|
13
|
+
// Labels
|
|
14
|
+
const labels = app.getLabels("clickToChoose", "region");
|
|
15
|
+
|
|
16
|
+
// Destruct
|
|
17
|
+
const {
|
|
18
|
+
inputName = "region",
|
|
19
|
+
label = labels.region,
|
|
20
|
+
labelEnd = labels.clickToChoose,
|
|
21
|
+
...rest
|
|
22
|
+
} = props;
|
|
23
|
+
|
|
24
|
+
const defaultRegions = [
|
|
25
|
+
"CN",
|
|
26
|
+
"US",
|
|
27
|
+
"GB",
|
|
28
|
+
"IE",
|
|
29
|
+
"CA",
|
|
30
|
+
"AU",
|
|
31
|
+
"NZ",
|
|
32
|
+
"DE",
|
|
33
|
+
"FR",
|
|
34
|
+
"JP",
|
|
35
|
+
"SG",
|
|
36
|
+
"HK"
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
// Add application regions, starting from the end
|
|
40
|
+
CoreUtils.mergeArray(defaultRegions, app.settings.regions);
|
|
41
|
+
|
|
42
|
+
// Load data
|
|
43
|
+
const loadData = React.useCallback(
|
|
44
|
+
async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [],
|
|
45
|
+
[]
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<ButtonPopupRadio<RegionData>
|
|
50
|
+
inputName={inputName}
|
|
51
|
+
label={label}
|
|
52
|
+
labelFormatter={(data) => `${data.name} (${data.id})`}
|
|
53
|
+
labelEnd={labelEnd}
|
|
54
|
+
labelField="name"
|
|
55
|
+
loadData={loadData}
|
|
56
|
+
onAdd={async (ids) => {
|
|
57
|
+
const data = await app.core.publicApi.getRegions(ids);
|
|
58
|
+
if (data == null) return false;
|
|
59
|
+
return data;
|
|
60
|
+
}}
|
|
61
|
+
{...rest}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
@@ -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">
|
|
@@ -38,6 +39,9 @@ export function ButtonRegions(
|
|
|
38
39
|
"HK"
|
|
39
40
|
];
|
|
40
41
|
|
|
42
|
+
// Add application regions, starting from the end
|
|
43
|
+
CoreUtils.mergeArray(defaultRegions, app.settings.regions);
|
|
44
|
+
|
|
41
45
|
// Load data
|
|
42
46
|
const loadData = React.useCallback(
|
|
43
47
|
async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [],
|