@etsoo/smarterp-core 1.0.72 → 1.0.73
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/components/index.d.ts +1 -0
- package/lib/cjs/components/index.js +1 -0
- package/lib/cjs/components/public/ButtonRegions.d.ts +3 -0
- package/lib/cjs/components/public/ButtonRegions.js +34 -0
- package/lib/mjs/components/index.d.ts +1 -0
- package/lib/mjs/components/index.js +1 -0
- package/lib/mjs/components/public/ButtonRegions.d.ts +3 -0
- package/lib/mjs/components/public/ButtonRegions.js +31 -0
- package/package.json +3 -3
- package/src/components/index.ts +1 -0
- package/src/components/public/ButtonRegions.tsx +58 -0
|
@@ -10,5 +10,6 @@ export * from "./org/OrgSwitchPopover";
|
|
|
10
10
|
export * from "./org/OrgTiplist";
|
|
11
11
|
export * from "./public/ButtonCultures";
|
|
12
12
|
export * from "./public/ButtonCurrencies";
|
|
13
|
+
export * from "./public/ButtonRegions";
|
|
13
14
|
export * from "./public/CultureList";
|
|
14
15
|
export * from "./user/UserTiplist";
|
|
@@ -30,6 +30,7 @@ __exportStar(require("./org/OrgTiplist"), exports);
|
|
|
30
30
|
// public
|
|
31
31
|
__exportStar(require("./public/ButtonCultures"), exports);
|
|
32
32
|
__exportStar(require("./public/ButtonCurrencies"), exports);
|
|
33
|
+
__exportStar(require("./public/ButtonRegions"), exports);
|
|
33
34
|
__exportStar(require("./public/CultureList"), exports);
|
|
34
35
|
// user
|
|
35
36
|
__exportStar(require("./user/UserTiplist"), exports);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
|
|
2
|
+
import { RegionData } from "../../dto/public/RegionData";
|
|
3
|
+
export declare function ButtonRegions(props: Omit<ButtonPopupCheckboxProps<RegionData>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ButtonRegions = ButtonRegions;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const materialui_1 = require("@etsoo/materialui");
|
|
6
|
+
const ICoreServiceApp_1 = require("../../ICoreServiceApp");
|
|
7
|
+
function ButtonRegions(props) {
|
|
8
|
+
// App
|
|
9
|
+
const app = (0, ICoreServiceApp_1.useRequiredAppContext)();
|
|
10
|
+
// Labels
|
|
11
|
+
const labels = app.getLabels("clickToChoose", "regions");
|
|
12
|
+
// Destruct
|
|
13
|
+
const { inputName = "regions", label = labels.regions, labelEnd = labels.clickToChoose, ...rest } = props;
|
|
14
|
+
const defaultRegions = [
|
|
15
|
+
"CN",
|
|
16
|
+
"US",
|
|
17
|
+
"GB",
|
|
18
|
+
"IE",
|
|
19
|
+
"CA",
|
|
20
|
+
"AU",
|
|
21
|
+
"NZ",
|
|
22
|
+
"DE",
|
|
23
|
+
"FR",
|
|
24
|
+
"JP",
|
|
25
|
+
"SG",
|
|
26
|
+
"HK"
|
|
27
|
+
];
|
|
28
|
+
return ((0, jsx_runtime_1.jsx)(materialui_1.ButtonPopupCheckbox, { inputName: inputName, label: label, labelFormatter: (data) => `${data.name} (${data.id})`, labelEnd: labelEnd, labelField: "name", loadData: async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [], onAdd: async (ids) => {
|
|
29
|
+
const data = await app.core.publicApi.getRegions(ids);
|
|
30
|
+
if (data == null)
|
|
31
|
+
return false;
|
|
32
|
+
return data;
|
|
33
|
+
}, ...rest }));
|
|
34
|
+
}
|
|
@@ -10,5 +10,6 @@ export * from "./org/OrgSwitchPopover";
|
|
|
10
10
|
export * from "./org/OrgTiplist";
|
|
11
11
|
export * from "./public/ButtonCultures";
|
|
12
12
|
export * from "./public/ButtonCurrencies";
|
|
13
|
+
export * from "./public/ButtonRegions";
|
|
13
14
|
export * from "./public/CultureList";
|
|
14
15
|
export * from "./user/UserTiplist";
|
|
@@ -14,6 +14,7 @@ export * from "./org/OrgTiplist";
|
|
|
14
14
|
// public
|
|
15
15
|
export * from "./public/ButtonCultures";
|
|
16
16
|
export * from "./public/ButtonCurrencies";
|
|
17
|
+
export * from "./public/ButtonRegions";
|
|
17
18
|
export * from "./public/CultureList";
|
|
18
19
|
// user
|
|
19
20
|
export * from "./user/UserTiplist";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
|
|
2
|
+
import { RegionData } from "../../dto/public/RegionData";
|
|
3
|
+
export declare function ButtonRegions(props: Omit<ButtonPopupCheckboxProps<RegionData>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ButtonPopupCheckbox } from "@etsoo/materialui";
|
|
3
|
+
import { useRequiredAppContext } from "../../ICoreServiceApp";
|
|
4
|
+
export function ButtonRegions(props) {
|
|
5
|
+
// App
|
|
6
|
+
const app = useRequiredAppContext();
|
|
7
|
+
// Labels
|
|
8
|
+
const labels = app.getLabels("clickToChoose", "regions");
|
|
9
|
+
// Destruct
|
|
10
|
+
const { inputName = "regions", label = labels.regions, labelEnd = labels.clickToChoose, ...rest } = props;
|
|
11
|
+
const defaultRegions = [
|
|
12
|
+
"CN",
|
|
13
|
+
"US",
|
|
14
|
+
"GB",
|
|
15
|
+
"IE",
|
|
16
|
+
"CA",
|
|
17
|
+
"AU",
|
|
18
|
+
"NZ",
|
|
19
|
+
"DE",
|
|
20
|
+
"FR",
|
|
21
|
+
"JP",
|
|
22
|
+
"SG",
|
|
23
|
+
"HK"
|
|
24
|
+
];
|
|
25
|
+
return (_jsx(ButtonPopupCheckbox, { inputName: inputName, label: label, labelFormatter: (data) => `${data.name} (${data.id})`, labelEnd: labelEnd, labelField: "name", loadData: async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [], onAdd: async (ids) => {
|
|
26
|
+
const data = await app.core.publicApi.getRegions(ids);
|
|
27
|
+
if (data == null)
|
|
28
|
+
return false;
|
|
29
|
+
return data;
|
|
30
|
+
}, ...rest }));
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/smarterp-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.73",
|
|
4
4
|
"description": "TypeScript APIs for SmartERP Core",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"vitest": "^3.2.2"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@etsoo/appscript": "^1.6.
|
|
57
|
-
"@etsoo/materialui": "^1.5.
|
|
56
|
+
"@etsoo/appscript": "^1.6.38",
|
|
57
|
+
"@etsoo/materialui": "^1.5.55",
|
|
58
58
|
"@etsoo/react": "^1.8.45",
|
|
59
59
|
"@etsoo/shared": "^1.2.74",
|
|
60
60
|
"@etsoo/toolpad": "^1.0.39",
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ButtonPopupCheckbox,
|
|
3
|
+
ButtonPopupCheckboxProps
|
|
4
|
+
} from "@etsoo/materialui";
|
|
5
|
+
import { RegionData } from "../../dto/public/RegionData";
|
|
6
|
+
import { useRequiredAppContext } from "../../ICoreServiceApp";
|
|
7
|
+
|
|
8
|
+
export function ButtonRegions(
|
|
9
|
+
props: Omit<ButtonPopupCheckboxProps<RegionData>, "labelField" | "loadData">
|
|
10
|
+
) {
|
|
11
|
+
// App
|
|
12
|
+
const app = useRequiredAppContext();
|
|
13
|
+
|
|
14
|
+
// Labels
|
|
15
|
+
const labels = app.getLabels("clickToChoose", "regions");
|
|
16
|
+
|
|
17
|
+
// Destruct
|
|
18
|
+
const {
|
|
19
|
+
inputName = "regions",
|
|
20
|
+
label = labels.regions,
|
|
21
|
+
labelEnd = labels.clickToChoose,
|
|
22
|
+
...rest
|
|
23
|
+
} = props;
|
|
24
|
+
|
|
25
|
+
const defaultRegions = [
|
|
26
|
+
"CN",
|
|
27
|
+
"US",
|
|
28
|
+
"GB",
|
|
29
|
+
"IE",
|
|
30
|
+
"CA",
|
|
31
|
+
"AU",
|
|
32
|
+
"NZ",
|
|
33
|
+
"DE",
|
|
34
|
+
"FR",
|
|
35
|
+
"JP",
|
|
36
|
+
"SG",
|
|
37
|
+
"HK"
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<ButtonPopupCheckbox<RegionData>
|
|
42
|
+
inputName={inputName}
|
|
43
|
+
label={label}
|
|
44
|
+
labelFormatter={(data) => `${data.name} (${data.id})`}
|
|
45
|
+
labelEnd={labelEnd}
|
|
46
|
+
labelField="name"
|
|
47
|
+
loadData={async () =>
|
|
48
|
+
(await app.core.publicApi.getRegions(defaultRegions)) ?? []
|
|
49
|
+
}
|
|
50
|
+
onAdd={async (ids) => {
|
|
51
|
+
const data = await app.core.publicApi.getRegions(ids);
|
|
52
|
+
if (data == null) return false;
|
|
53
|
+
return data;
|
|
54
|
+
}}
|
|
55
|
+
{...rest}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|