@etsoo/smarterp-core 1.0.49 → 1.0.51

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.
@@ -7,4 +7,6 @@ export * from "./app/StatusList";
7
7
  export * from "./app/UserRoleList";
8
8
  export * from "./org/OrgSwitchPopover";
9
9
  export * from "./org/OrgTiplist";
10
+ export * from "./public/ButtonCultures";
11
+ export * from "./public/ButtonCurrencies";
10
12
  export * from "./user/UserTiplist";
@@ -26,5 +26,8 @@ __exportStar(require("./app/UserRoleList"), exports);
26
26
  // org
27
27
  __exportStar(require("./org/OrgSwitchPopover"), exports);
28
28
  __exportStar(require("./org/OrgTiplist"), exports);
29
+ // public
30
+ __exportStar(require("./public/ButtonCultures"), exports);
31
+ __exportStar(require("./public/ButtonCurrencies"), exports);
29
32
  // user
30
33
  __exportStar(require("./user/UserTiplist"), exports);
@@ -0,0 +1,3 @@
1
+ import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
2
+ import { CultureItem } from "@etsoo/appscript";
3
+ export declare function ButtonCultures(props: Omit<ButtonPopupCheckboxProps<CultureItem>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ButtonCultures = ButtonCultures;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const materialui_1 = require("@etsoo/materialui");
6
+ const shared_1 = require("@etsoo/shared");
7
+ const ICoreServiceApp_1 = require("../../ICoreServiceApp");
8
+ function ButtonCultures(props) {
9
+ // App
10
+ const app = (0, ICoreServiceApp_1.useRequiredAppContext)();
11
+ // Labels
12
+ const labels = app.getLabels("clickToChoose", "cultures");
13
+ // Destruct
14
+ const { inputName = "cultures", label = labels.cultures, labelEnd = labels.clickToChoose, ...rest } = props;
15
+ const defaultCultures = [
16
+ "en",
17
+ "zh-Hans",
18
+ "zh-Hant",
19
+ "fr",
20
+ "de",
21
+ "ja",
22
+ "id",
23
+ "es",
24
+ "ru",
25
+ "ar"
26
+ ];
27
+ defaultCultures.sort((a) => (app.culture.startsWith(a) ? -1 : 0));
28
+ return ((0, jsx_runtime_1.jsx)(materialui_1.ButtonPopupCheckbox, { inputName: inputName, label: label, labelFormatter: (data) => `${data.name === data.id ? data.englishName : data.name} (${data.id})`, labelEnd: labelEnd, labelField: "name", loadData: async (ids) => {
29
+ const queryIds = shared_1.ArrayUtils.mergeArrays(ids ?? [], defaultCultures);
30
+ const data = await app.core.publicApi.getCultures(queryIds);
31
+ return data ?? [];
32
+ }, onAdd: async (ids) => {
33
+ const data = await app.core.publicApi.getCultures(ids);
34
+ if (data == null)
35
+ return false;
36
+ return data;
37
+ }, ...rest }));
38
+ }
@@ -0,0 +1,3 @@
1
+ import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
2
+ import { CurrencyItem } from "../../dto/public/CurrencyItem";
3
+ export declare function ButtonCurrencies(props: Omit<ButtonPopupCheckboxProps<CurrencyItem>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ButtonCurrencies = ButtonCurrencies;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const materialui_1 = require("@etsoo/materialui");
6
+ const shared_1 = require("@etsoo/shared");
7
+ const ICoreServiceApp_1 = require("../../ICoreServiceApp");
8
+ function ButtonCurrencies(props) {
9
+ // App
10
+ const app = (0, ICoreServiceApp_1.useRequiredAppContext)();
11
+ // Labels
12
+ const labels = app.getLabels("clickToChoose", "currencies");
13
+ // Destruct
14
+ const { inputName = "currencies", label = labels.currencies, labelEnd = labels.clickToChoose, ...rest } = props;
15
+ const defaultCurrencies = [
16
+ "USD",
17
+ "CNY",
18
+ "EUR",
19
+ "GBP",
20
+ "JPY",
21
+ "AUD",
22
+ "CAD",
23
+ "SGD",
24
+ "HKD",
25
+ "NZD"
26
+ ];
27
+ defaultCurrencies.sort((a) => (a.startsWith(app.region) ? -1 : 0));
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 (ids) => {
29
+ const queryIds = shared_1.ArrayUtils.mergeArrays(ids ?? [], defaultCurrencies);
30
+ const data = await app.core.publicApi.getCurrencies(queryIds);
31
+ return data ?? [];
32
+ }, onAdd: async (ids) => {
33
+ const data = await app.core.publicApi.getCurrencies(ids);
34
+ if (data == null)
35
+ return false;
36
+ return data;
37
+ }, ...rest }));
38
+ }
@@ -7,4 +7,6 @@ export * from "./app/StatusList";
7
7
  export * from "./app/UserRoleList";
8
8
  export * from "./org/OrgSwitchPopover";
9
9
  export * from "./org/OrgTiplist";
10
+ export * from "./public/ButtonCultures";
11
+ export * from "./public/ButtonCurrencies";
10
12
  export * from "./user/UserTiplist";
@@ -10,5 +10,8 @@ export * from "./app/UserRoleList";
10
10
  // org
11
11
  export * from "./org/OrgSwitchPopover";
12
12
  export * from "./org/OrgTiplist";
13
+ // public
14
+ export * from "./public/ButtonCultures";
15
+ export * from "./public/ButtonCurrencies";
13
16
  // user
14
17
  export * from "./user/UserTiplist";
@@ -0,0 +1,3 @@
1
+ import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
2
+ import { CultureItem } from "@etsoo/appscript";
3
+ export declare function ButtonCultures(props: Omit<ButtonPopupCheckboxProps<CultureItem>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ButtonPopupCheckbox } from "@etsoo/materialui";
3
+ import { ArrayUtils } from "@etsoo/shared";
4
+ import { useRequiredAppContext } from "../../ICoreServiceApp";
5
+ export function ButtonCultures(props) {
6
+ // App
7
+ const app = useRequiredAppContext();
8
+ // Labels
9
+ const labels = app.getLabels("clickToChoose", "cultures");
10
+ // Destruct
11
+ const { inputName = "cultures", label = labels.cultures, labelEnd = labels.clickToChoose, ...rest } = props;
12
+ const defaultCultures = [
13
+ "en",
14
+ "zh-Hans",
15
+ "zh-Hant",
16
+ "fr",
17
+ "de",
18
+ "ja",
19
+ "id",
20
+ "es",
21
+ "ru",
22
+ "ar"
23
+ ];
24
+ defaultCultures.sort((a) => (app.culture.startsWith(a) ? -1 : 0));
25
+ return (_jsx(ButtonPopupCheckbox, { inputName: inputName, label: label, labelFormatter: (data) => `${data.name === data.id ? data.englishName : data.name} (${data.id})`, labelEnd: labelEnd, labelField: "name", loadData: async (ids) => {
26
+ const queryIds = ArrayUtils.mergeArrays(ids ?? [], defaultCultures);
27
+ const data = await app.core.publicApi.getCultures(queryIds);
28
+ return data ?? [];
29
+ }, onAdd: async (ids) => {
30
+ const data = await app.core.publicApi.getCultures(ids);
31
+ if (data == null)
32
+ return false;
33
+ return data;
34
+ }, ...rest }));
35
+ }
@@ -0,0 +1,3 @@
1
+ import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
2
+ import { CurrencyItem } from "../../dto/public/CurrencyItem";
3
+ export declare function ButtonCurrencies(props: Omit<ButtonPopupCheckboxProps<CurrencyItem>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ButtonPopupCheckbox } from "@etsoo/materialui";
3
+ import { ArrayUtils } from "@etsoo/shared";
4
+ import { useRequiredAppContext } from "../../ICoreServiceApp";
5
+ export function ButtonCurrencies(props) {
6
+ // App
7
+ const app = useRequiredAppContext();
8
+ // Labels
9
+ const labels = app.getLabels("clickToChoose", "currencies");
10
+ // Destruct
11
+ const { inputName = "currencies", label = labels.currencies, labelEnd = labels.clickToChoose, ...rest } = props;
12
+ const defaultCurrencies = [
13
+ "USD",
14
+ "CNY",
15
+ "EUR",
16
+ "GBP",
17
+ "JPY",
18
+ "AUD",
19
+ "CAD",
20
+ "SGD",
21
+ "HKD",
22
+ "NZD"
23
+ ];
24
+ defaultCurrencies.sort((a) => (a.startsWith(app.region) ? -1 : 0));
25
+ return (_jsx(ButtonPopupCheckbox, { inputName: inputName, label: label, labelFormatter: (data) => `${data.name} (${data.id})`, labelEnd: labelEnd, labelField: "name", loadData: async (ids) => {
26
+ const queryIds = ArrayUtils.mergeArrays(ids ?? [], defaultCurrencies);
27
+ const data = await app.core.publicApi.getCurrencies(queryIds);
28
+ return data ?? [];
29
+ }, onAdd: async (ids) => {
30
+ const data = await app.core.publicApi.getCurrencies(ids);
31
+ if (data == null)
32
+ return false;
33
+ return data;
34
+ }, ...rest }));
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/smarterp-core",
3
- "version": "1.0.49",
3
+ "version": "1.0.51",
4
4
  "description": "TypeScript APIs for SmartERP Core",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -54,9 +54,9 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@etsoo/appscript": "^1.6.29",
57
- "@etsoo/materialui": "^1.5.35",
57
+ "@etsoo/materialui": "^1.5.36",
58
58
  "@etsoo/react": "^1.8.40",
59
- "@etsoo/shared": "^1.2.69",
59
+ "@etsoo/shared": "^1.2.70",
60
60
  "@etsoo/toolpad": "^1.0.26",
61
61
  "@mui/material": "^7.0.2",
62
62
  "react": "^18.3.1",
@@ -13,5 +13,9 @@ export * from "./app/UserRoleList";
13
13
  export * from "./org/OrgSwitchPopover";
14
14
  export * from "./org/OrgTiplist";
15
15
 
16
+ // public
17
+ export * from "./public/ButtonCultures";
18
+ export * from "./public/ButtonCurrencies";
19
+
16
20
  // user
17
21
  export * from "./user/UserTiplist";
@@ -0,0 +1,63 @@
1
+ import {
2
+ ButtonPopupCheckbox,
3
+ ButtonPopupCheckboxProps
4
+ } from "@etsoo/materialui";
5
+ import { ArrayUtils } from "@etsoo/shared";
6
+ import { useRequiredAppContext } from "../../ICoreServiceApp";
7
+ import { CultureItem } from "@etsoo/appscript";
8
+
9
+ export function ButtonCultures(
10
+ props: Omit<ButtonPopupCheckboxProps<CultureItem>, "labelField" | "loadData">
11
+ ) {
12
+ // App
13
+ const app = useRequiredAppContext();
14
+
15
+ // Labels
16
+ const labels = app.getLabels("clickToChoose", "cultures");
17
+
18
+ // Destruct
19
+ const {
20
+ inputName = "cultures",
21
+ label = labels.cultures,
22
+ labelEnd = labels.clickToChoose,
23
+ ...rest
24
+ } = props;
25
+
26
+ const defaultCultures = [
27
+ "en",
28
+ "zh-Hans",
29
+ "zh-Hant",
30
+ "fr",
31
+ "de",
32
+ "ja",
33
+ "id",
34
+ "es",
35
+ "ru",
36
+ "ar"
37
+ ];
38
+
39
+ defaultCultures.sort((a) => (app.culture.startsWith(a) ? -1 : 0));
40
+
41
+ return (
42
+ <ButtonPopupCheckbox<CultureItem>
43
+ inputName={inputName}
44
+ label={label}
45
+ labelFormatter={(data) =>
46
+ `${data.name === data.id ? data.englishName : data.name} (${data.id})`
47
+ }
48
+ labelEnd={labelEnd}
49
+ labelField="name"
50
+ loadData={async (ids) => {
51
+ const queryIds = ArrayUtils.mergeArrays(ids ?? [], defaultCultures);
52
+ const data = await app.core.publicApi.getCultures(queryIds);
53
+ return data ?? [];
54
+ }}
55
+ onAdd={async (ids) => {
56
+ const data = await app.core.publicApi.getCultures(ids);
57
+ if (data == null) return false;
58
+ return data;
59
+ }}
60
+ {...rest}
61
+ />
62
+ );
63
+ }
@@ -0,0 +1,61 @@
1
+ import {
2
+ ButtonPopupCheckbox,
3
+ ButtonPopupCheckboxProps
4
+ } from "@etsoo/materialui";
5
+ import { CurrencyItem } from "../../dto/public/CurrencyItem";
6
+ import { ArrayUtils } from "@etsoo/shared";
7
+ import { useRequiredAppContext } from "../../ICoreServiceApp";
8
+
9
+ export function ButtonCurrencies(
10
+ props: Omit<ButtonPopupCheckboxProps<CurrencyItem>, "labelField" | "loadData">
11
+ ) {
12
+ // App
13
+ const app = useRequiredAppContext();
14
+
15
+ // Labels
16
+ const labels = app.getLabels("clickToChoose", "currencies");
17
+
18
+ // Destruct
19
+ const {
20
+ inputName = "currencies",
21
+ label = labels.currencies,
22
+ labelEnd = labels.clickToChoose,
23
+ ...rest
24
+ } = props;
25
+
26
+ const defaultCurrencies = [
27
+ "USD",
28
+ "CNY",
29
+ "EUR",
30
+ "GBP",
31
+ "JPY",
32
+ "AUD",
33
+ "CAD",
34
+ "SGD",
35
+ "HKD",
36
+ "NZD"
37
+ ];
38
+
39
+ defaultCurrencies.sort((a) => (a.startsWith(app.region) ? -1 : 0));
40
+
41
+ return (
42
+ <ButtonPopupCheckbox<CurrencyItem>
43
+ inputName={inputName}
44
+ label={label}
45
+ labelFormatter={(data) => `${data.name} (${data.id})`}
46
+ labelEnd={labelEnd}
47
+ labelField="name"
48
+ loadData={async (ids) => {
49
+ const queryIds = ArrayUtils.mergeArrays(ids ?? [], defaultCurrencies);
50
+ const data = await app.core.publicApi.getCurrencies(queryIds);
51
+ return data ?? [];
52
+ }}
53
+ onAdd={async (ids) => {
54
+ const data = await app.core.publicApi.getCurrencies(ids);
55
+ if (data == null) return false;
56
+ return data;
57
+ }}
58
+ {...rest}
59
+ />
60
+ );
61
+ }