@etsoo/smarterp-core 1.0.71 → 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.
Files changed (38) hide show
  1. package/lib/cjs/components/app/ButtonIdentityTypes.d.ts +1 -1
  2. package/lib/cjs/components/app/ButtonIdentityTypes.js +1 -1
  3. package/lib/cjs/components/index.d.ts +1 -0
  4. package/lib/cjs/components/index.js +1 -0
  5. package/lib/cjs/components/org/OrgTiplist.d.ts +5 -0
  6. package/lib/cjs/components/org/OrgTiplist.js +3 -3
  7. package/lib/cjs/components/public/ButtonCultures.js +1 -6
  8. package/lib/cjs/components/public/ButtonCurrencies.js +1 -6
  9. package/lib/cjs/components/public/ButtonRegions.d.ts +3 -0
  10. package/lib/cjs/components/public/ButtonRegions.js +34 -0
  11. package/lib/cjs/components/user/UserTiplist.d.ts +5 -0
  12. package/lib/cjs/components/user/UserTiplist.js +3 -3
  13. package/lib/cjs/i18n/zh-Hans.json +1 -1
  14. package/lib/cjs/i18n/zh-Hant.json +1 -1
  15. package/lib/mjs/components/app/ButtonIdentityTypes.d.ts +1 -1
  16. package/lib/mjs/components/app/ButtonIdentityTypes.js +1 -1
  17. package/lib/mjs/components/index.d.ts +1 -0
  18. package/lib/mjs/components/index.js +1 -0
  19. package/lib/mjs/components/org/OrgTiplist.d.ts +5 -0
  20. package/lib/mjs/components/org/OrgTiplist.js +3 -3
  21. package/lib/mjs/components/public/ButtonCultures.js +1 -6
  22. package/lib/mjs/components/public/ButtonCurrencies.js +1 -6
  23. package/lib/mjs/components/public/ButtonRegions.d.ts +3 -0
  24. package/lib/mjs/components/public/ButtonRegions.js +31 -0
  25. package/lib/mjs/components/user/UserTiplist.d.ts +5 -0
  26. package/lib/mjs/components/user/UserTiplist.js +3 -3
  27. package/lib/mjs/i18n/zh-Hans.json +1 -1
  28. package/lib/mjs/i18n/zh-Hant.json +1 -1
  29. package/package.json +9 -9
  30. package/src/components/app/ButtonIdentityTypes.tsx +2 -2
  31. package/src/components/index.ts +1 -0
  32. package/src/components/org/OrgTiplist.tsx +9 -2
  33. package/src/components/public/ButtonCultures.tsx +3 -6
  34. package/src/components/public/ButtonCurrencies.tsx +3 -6
  35. package/src/components/public/ButtonRegions.tsx +58 -0
  36. package/src/components/user/UserTiplist.tsx +9 -2
  37. package/src/i18n/zh-Hans.json +1 -1
  38. package/src/i18n/zh-Hant.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
2
2
  import { ListType } from "@etsoo/shared";
3
3
  import { IdentityTypeFlags } from "@etsoo/appscript";
4
- export type ButtonIdentityTypesProps = Omit<ButtonPopupCheckboxProps<ListType>, "labelField" | "loadData" | "ids" | "value" | "onValueChange"> & {
4
+ export type ButtonIdentityTypesProps = Omit<ButtonPopupCheckboxProps<ListType>, "labelField" | "loadData" | "value" | "onValueChange"> & {
5
5
  /**
6
6
  * Base identity type
7
7
  */
@@ -27,7 +27,7 @@ function ButtonIdentityTypes(props) {
27
27
  }
28
28
  }
29
29
  }
30
- return ((0, jsx_runtime_1.jsx)(materialui_1.ButtonPopupCheckbox, { inputName: inputName, label: label, labelFormatter: (data) => data.label, labelEnd: labelEnd, labelField: "label", loadData: async () => identities, ids: ids, onValueChange: (ids) => {
30
+ return ((0, jsx_runtime_1.jsx)(materialui_1.ButtonPopupCheckbox, { inputName: inputName, label: label, labelFormatter: (data) => data.label, labelEnd: labelEnd, labelField: "label", loadData: async () => identities, value: ids, onValueChange: (ids) => {
31
31
  let newValue = appscript_1.IdentityTypeFlags.None;
32
32
  for (const id of ids) {
33
33
  newValue |= id;
@@ -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);
@@ -18,6 +18,11 @@ export type OrgTiplistProps = Omit<TiplistProps<OrgListDto, "id">, "loadData" |
18
18
  * Default request data
19
19
  */
20
20
  rq?: Partial<OrgListRQ>;
21
+ /**
22
+ * Load data handler
23
+ * @param rq Request data
24
+ */
25
+ onLoadData?: (rq: OrgListRQ) => OrgListRQ;
21
26
  };
22
27
  /**
23
28
  * Organization tiplist
@@ -14,9 +14,9 @@ function OrgTiplist(props) {
14
14
  // App
15
15
  const app = (0, ICoreServiceApp_1.useRequiredAppContext)();
16
16
  // Destruct
17
- const { fullWidth = true, label = app.get("org"), maxItems = 10, getOptionLabel = (data) => data.name + "(" + data.pin + ")", name = "organizationId", rq = { enabled: true }, ...rest } = props;
17
+ const { fullWidth = true, label = app.get("org"), maxItems = 10, getOptionLabel = (data) => data.name + "(" + data.pin + ")", onLoadData = (rq) => rq, name = "organizationId", rq = { enabled: true }, ...rest } = props;
18
18
  // Layout
19
- return ((0, jsx_runtime_1.jsx)(materialui_1.Tiplist, { label: label, getOptionLabel: getOptionLabel, name: name, fullWidth: fullWidth, maxItems: maxItems, loadData: (keyword, id, maxItems) => app.core.orgApi.list({
19
+ return ((0, jsx_runtime_1.jsx)(materialui_1.Tiplist, { label: label, getOptionLabel: getOptionLabel, name: name, fullWidth: fullWidth, maxItems: maxItems, loadData: (keyword, id, maxItems) => app.core.orgApi.list(onLoadData({
20
20
  ...rq,
21
21
  keyword,
22
22
  id,
@@ -24,5 +24,5 @@ function OrgTiplist(props) {
24
24
  batchSize: maxItems,
25
25
  orderBy: [{ field: "CoreOrganization.Name" }]
26
26
  }
27
- }, { showLoading: false, defaultValue: [] }), ...rest }));
27
+ }), { showLoading: false, defaultValue: [] }), ...rest }));
28
28
  }
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ButtonCultures = ButtonCultures;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const materialui_1 = require("@etsoo/materialui");
6
- const shared_1 = require("@etsoo/shared");
7
6
  const ICoreServiceApp_1 = require("../../ICoreServiceApp");
8
7
  function ButtonCultures(props) {
9
8
  // App
@@ -25,11 +24,7 @@ function ButtonCultures(props) {
25
24
  "ar"
26
25
  ];
27
26
  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) => {
27
+ 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 () => (await app.core.publicApi.getCultures(defaultCultures)) ?? [], onAdd: async (ids) => {
33
28
  const data = await app.core.publicApi.getCultures(ids);
34
29
  if (data == null)
35
30
  return false;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ButtonCurrencies = ButtonCurrencies;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const materialui_1 = require("@etsoo/materialui");
6
- const shared_1 = require("@etsoo/shared");
7
6
  const ICoreServiceApp_1 = require("../../ICoreServiceApp");
8
7
  function ButtonCurrencies(props) {
9
8
  // App
@@ -25,11 +24,7 @@ function ButtonCurrencies(props) {
25
24
  "NZD"
26
25
  ];
27
26
  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) => {
27
+ 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.getCurrencies(defaultCurrencies)) ?? [], onAdd: async (ids) => {
33
28
  const data = await app.core.publicApi.getCurrencies(ids);
34
29
  if (data == null)
35
30
  return false;
@@ -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
+ }
@@ -18,6 +18,11 @@ export type UserTiplistProps = Omit<TiplistProps<MemberListDto, "id">, "loadData
18
18
  * Default request data
19
19
  */
20
20
  rq?: Partial<MemberListRQ>;
21
+ /**
22
+ * Load data handler
23
+ * @param rq Request data
24
+ */
25
+ onLoadData?: (rq: MemberListRQ) => MemberListRQ;
21
26
  };
22
27
  /**
23
28
  * User tiplist
@@ -14,14 +14,14 @@ function UserTiplist(props) {
14
14
  // App
15
15
  const app = (0, ICoreServiceApp_1.useRequiredAppContext)();
16
16
  // Destruct
17
- const { fullWidth = true, label = app.get("user"), maxItems = 10, getOptionLabel = (data) => data.name, name = "userId", rq = { enabled: true }, ...rest } = props;
17
+ const { fullWidth = true, label = app.get("user"), maxItems = 10, getOptionLabel = (data) => data.name, onLoadData = (rq) => rq, name = "userId", rq = { enabled: true }, ...rest } = props;
18
18
  // Layout
19
- return ((0, jsx_runtime_1.jsx)(materialui_1.Tiplist, { label: label, getOptionLabel: getOptionLabel, name: name, fullWidth: fullWidth, maxItems: maxItems, loadData: (keyword, id, maxItems) => app.core.memberApi.list({
19
+ return ((0, jsx_runtime_1.jsx)(materialui_1.Tiplist, { label: label, getOptionLabel: getOptionLabel, name: name, fullWidth: fullWidth, maxItems: maxItems, loadData: (keyword, id, maxItems) => app.core.memberApi.list(onLoadData({
20
20
  ...rq,
21
21
  keyword,
22
22
  id,
23
23
  queryPaging: {
24
24
  batchSize: maxItems
25
25
  }
26
- }, { showLoading: false, defaultValue: [] }), ...rest }));
26
+ }), { showLoading: false, defaultValue: [] }), ...rest }));
27
27
  }
@@ -59,7 +59,7 @@
59
59
  "owner": "所有者",
60
60
  "parentOrg": "上级机构",
61
61
  "pin": "身份证号码",
62
- "preferredName": "首选姓名",
62
+ "preferredName": "首选名称",
63
63
  "queryKeyword": "查询关键字",
64
64
  "refreshTime": "刷新时间",
65
65
  "relatedTarget": "关联对象",
@@ -59,7 +59,7 @@
59
59
  "owner": "所有者",
60
60
  "parentOrg": "上級機構",
61
61
  "pin": "身份證號碼",
62
- "preferredName": "首選姓名",
62
+ "preferredName": "首選名稱",
63
63
  "queryKeyword": "查詢關鍵字",
64
64
  "refreshTime": "刷新時間",
65
65
  "relatedTarget": "關聯對象",
@@ -1,7 +1,7 @@
1
1
  import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
2
2
  import { ListType } from "@etsoo/shared";
3
3
  import { IdentityTypeFlags } from "@etsoo/appscript";
4
- export type ButtonIdentityTypesProps = Omit<ButtonPopupCheckboxProps<ListType>, "labelField" | "loadData" | "ids" | "value" | "onValueChange"> & {
4
+ export type ButtonIdentityTypesProps = Omit<ButtonPopupCheckboxProps<ListType>, "labelField" | "loadData" | "value" | "onValueChange"> & {
5
5
  /**
6
6
  * Base identity type
7
7
  */
@@ -21,7 +21,7 @@ export function ButtonIdentityTypes(props) {
21
21
  }
22
22
  }
23
23
  }
24
- return (_jsx(ButtonPopupCheckbox, { inputName: inputName, label: label, labelFormatter: (data) => data.label, labelEnd: labelEnd, labelField: "label", loadData: async () => identities, ids: ids, onValueChange: (ids) => {
24
+ return (_jsx(ButtonPopupCheckbox, { inputName: inputName, label: label, labelFormatter: (data) => data.label, labelEnd: labelEnd, labelField: "label", loadData: async () => identities, value: ids, onValueChange: (ids) => {
25
25
  let newValue = IdentityTypeFlags.None;
26
26
  for (const id of ids) {
27
27
  newValue |= id;
@@ -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";
@@ -18,6 +18,11 @@ export type OrgTiplistProps = Omit<TiplistProps<OrgListDto, "id">, "loadData" |
18
18
  * Default request data
19
19
  */
20
20
  rq?: Partial<OrgListRQ>;
21
+ /**
22
+ * Load data handler
23
+ * @param rq Request data
24
+ */
25
+ onLoadData?: (rq: OrgListRQ) => OrgListRQ;
21
26
  };
22
27
  /**
23
28
  * Organization tiplist
@@ -11,9 +11,9 @@ export function OrgTiplist(props) {
11
11
  // App
12
12
  const app = useRequiredAppContext();
13
13
  // Destruct
14
- const { fullWidth = true, label = app.get("org"), maxItems = 10, getOptionLabel = (data) => data.name + "(" + data.pin + ")", name = "organizationId", rq = { enabled: true }, ...rest } = props;
14
+ const { fullWidth = true, label = app.get("org"), maxItems = 10, getOptionLabel = (data) => data.name + "(" + data.pin + ")", onLoadData = (rq) => rq, name = "organizationId", rq = { enabled: true }, ...rest } = props;
15
15
  // Layout
16
- return (_jsx(Tiplist, { label: label, getOptionLabel: getOptionLabel, name: name, fullWidth: fullWidth, maxItems: maxItems, loadData: (keyword, id, maxItems) => app.core.orgApi.list({
16
+ return (_jsx(Tiplist, { label: label, getOptionLabel: getOptionLabel, name: name, fullWidth: fullWidth, maxItems: maxItems, loadData: (keyword, id, maxItems) => app.core.orgApi.list(onLoadData({
17
17
  ...rq,
18
18
  keyword,
19
19
  id,
@@ -21,5 +21,5 @@ export function OrgTiplist(props) {
21
21
  batchSize: maxItems,
22
22
  orderBy: [{ field: "CoreOrganization.Name" }]
23
23
  }
24
- }, { showLoading: false, defaultValue: [] }), ...rest }));
24
+ }), { showLoading: false, defaultValue: [] }), ...rest }));
25
25
  }
@@ -1,6 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { ButtonPopupCheckbox } from "@etsoo/materialui";
3
- import { ArrayUtils } from "@etsoo/shared";
4
3
  import { useRequiredAppContext } from "../../ICoreServiceApp";
5
4
  export function ButtonCultures(props) {
6
5
  // App
@@ -22,11 +21,7 @@ export function ButtonCultures(props) {
22
21
  "ar"
23
22
  ];
24
23
  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) => {
24
+ 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 () => (await app.core.publicApi.getCultures(defaultCultures)) ?? [], onAdd: async (ids) => {
30
25
  const data = await app.core.publicApi.getCultures(ids);
31
26
  if (data == null)
32
27
  return false;
@@ -1,6 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { ButtonPopupCheckbox } from "@etsoo/materialui";
3
- import { ArrayUtils } from "@etsoo/shared";
4
3
  import { useRequiredAppContext } from "../../ICoreServiceApp";
5
4
  export function ButtonCurrencies(props) {
6
5
  // App
@@ -22,11 +21,7 @@ export function ButtonCurrencies(props) {
22
21
  "NZD"
23
22
  ];
24
23
  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) => {
24
+ return (_jsx(ButtonPopupCheckbox, { inputName: inputName, label: label, labelFormatter: (data) => `${data.name} (${data.id})`, labelEnd: labelEnd, labelField: "name", loadData: async () => (await app.core.publicApi.getCurrencies(defaultCurrencies)) ?? [], onAdd: async (ids) => {
30
25
  const data = await app.core.publicApi.getCurrencies(ids);
31
26
  if (data == null)
32
27
  return false;
@@ -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
+ }
@@ -18,6 +18,11 @@ export type UserTiplistProps = Omit<TiplistProps<MemberListDto, "id">, "loadData
18
18
  * Default request data
19
19
  */
20
20
  rq?: Partial<MemberListRQ>;
21
+ /**
22
+ * Load data handler
23
+ * @param rq Request data
24
+ */
25
+ onLoadData?: (rq: MemberListRQ) => MemberListRQ;
21
26
  };
22
27
  /**
23
28
  * User tiplist
@@ -11,14 +11,14 @@ export function UserTiplist(props) {
11
11
  // App
12
12
  const app = useRequiredAppContext();
13
13
  // Destruct
14
- const { fullWidth = true, label = app.get("user"), maxItems = 10, getOptionLabel = (data) => data.name, name = "userId", rq = { enabled: true }, ...rest } = props;
14
+ const { fullWidth = true, label = app.get("user"), maxItems = 10, getOptionLabel = (data) => data.name, onLoadData = (rq) => rq, name = "userId", rq = { enabled: true }, ...rest } = props;
15
15
  // Layout
16
- return (_jsx(Tiplist, { label: label, getOptionLabel: getOptionLabel, name: name, fullWidth: fullWidth, maxItems: maxItems, loadData: (keyword, id, maxItems) => app.core.memberApi.list({
16
+ return (_jsx(Tiplist, { label: label, getOptionLabel: getOptionLabel, name: name, fullWidth: fullWidth, maxItems: maxItems, loadData: (keyword, id, maxItems) => app.core.memberApi.list(onLoadData({
17
17
  ...rq,
18
18
  keyword,
19
19
  id,
20
20
  queryPaging: {
21
21
  batchSize: maxItems
22
22
  }
23
- }, { showLoading: false, defaultValue: [] }), ...rest }));
23
+ }), { showLoading: false, defaultValue: [] }), ...rest }));
24
24
  }
@@ -59,7 +59,7 @@
59
59
  "owner": "所有者",
60
60
  "parentOrg": "上级机构",
61
61
  "pin": "身份证号码",
62
- "preferredName": "首选姓名",
62
+ "preferredName": "首选名称",
63
63
  "queryKeyword": "查询关键字",
64
64
  "refreshTime": "刷新时间",
65
65
  "relatedTarget": "关联对象",
@@ -59,7 +59,7 @@
59
59
  "owner": "所有者",
60
60
  "parentOrg": "上級機構",
61
61
  "pin": "身份證號碼",
62
- "preferredName": "首選姓名",
62
+ "preferredName": "首選名稱",
63
63
  "queryKeyword": "查詢關鍵字",
64
64
  "refreshTime": "刷新時間",
65
65
  "relatedTarget": "關聯對象",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/smarterp-core",
3
- "version": "1.0.71",
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",
@@ -41,24 +41,24 @@
41
41
  "homepage": "https://github.com/ETSOO/etsoo-smarterp-core#readme",
42
42
  "devDependencies": {
43
43
  "@babel/cli": "^7.27.2",
44
- "@babel/core": "^7.27.1",
45
- "@babel/plugin-transform-runtime": "^7.27.1",
44
+ "@babel/core": "^7.27.4",
45
+ "@babel/plugin-transform-runtime": "^7.27.4",
46
46
  "@babel/preset-env": "^7.27.2",
47
- "@babel/runtime-corejs3": "^7.27.1",
47
+ "@babel/runtime-corejs3": "^7.27.6",
48
48
  "@types/react": "^18.3.23",
49
49
  "@types/react-dom": "^18.3.7",
50
- "@vitejs/plugin-react": "^4.5.0",
50
+ "@vitejs/plugin-react": "^4.5.1",
51
51
  "jsdom": "^26.1.0",
52
52
  "typescript": "^5.8.3",
53
- "vitest": "^3.1.4"
53
+ "vitest": "^3.2.2"
54
54
  },
55
55
  "dependencies": {
56
- "@etsoo/appscript": "^1.6.36",
57
- "@etsoo/materialui": "^1.5.52",
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",
61
- "@mui/material": "^7.1.0",
61
+ "@mui/material": "^7.1.1",
62
62
  "react": "^18.3.1",
63
63
  "react-dom": "^18.3.1"
64
64
  }
@@ -9,7 +9,7 @@ import { useRequiredAppContext } from "../../ICoreServiceApp";
9
9
 
10
10
  export type ButtonIdentityTypesProps = Omit<
11
11
  ButtonPopupCheckboxProps<ListType>,
12
- "labelField" | "loadData" | "ids" | "value" | "onValueChange"
12
+ "labelField" | "loadData" | "value" | "onValueChange"
13
13
  > & {
14
14
  /**
15
15
  * Base identity type
@@ -71,7 +71,7 @@ export function ButtonIdentityTypes(props: ButtonIdentityTypesProps) {
71
71
  labelEnd={labelEnd}
72
72
  labelField="label"
73
73
  loadData={async () => identities}
74
- ids={ids}
74
+ value={ids}
75
75
  onValueChange={(ids) => {
76
76
  let newValue = IdentityTypeFlags.None;
77
77
  for (const id of ids) {
@@ -17,6 +17,7 @@ export * from "./org/OrgTiplist";
17
17
  // public
18
18
  export * from "./public/ButtonCultures";
19
19
  export * from "./public/ButtonCurrencies";
20
+ export * from "./public/ButtonRegions";
20
21
  export * from "./public/CultureList";
21
22
 
22
23
  // user
@@ -25,6 +25,12 @@ export type OrgTiplistProps = Omit<
25
25
  * Default request data
26
26
  */
27
27
  rq?: Partial<OrgListRQ>;
28
+
29
+ /**
30
+ * Load data handler
31
+ * @param rq Request data
32
+ */
33
+ onLoadData?: (rq: OrgListRQ) => OrgListRQ;
28
34
  };
29
35
 
30
36
  /**
@@ -43,6 +49,7 @@ export function OrgTiplist(props: OrgTiplistProps) {
43
49
  label = app.get("org")!,
44
50
  maxItems = 10,
45
51
  getOptionLabel = (data) => data.name + "(" + data.pin + ")",
52
+ onLoadData = (rq) => rq,
46
53
  name = "organizationId",
47
54
  rq = { enabled: true },
48
55
  ...rest
@@ -58,7 +65,7 @@ export function OrgTiplist(props: OrgTiplistProps) {
58
65
  maxItems={maxItems}
59
66
  loadData={(keyword, id, maxItems) =>
60
67
  app.core.orgApi.list(
61
- {
68
+ onLoadData({
62
69
  ...rq,
63
70
  keyword,
64
71
  id,
@@ -66,7 +73,7 @@ export function OrgTiplist(props: OrgTiplistProps) {
66
73
  batchSize: maxItems,
67
74
  orderBy: [{ field: "CoreOrganization.Name" }]
68
75
  }
69
- },
76
+ }),
70
77
  { showLoading: false, defaultValue: [] }
71
78
  )
72
79
  }
@@ -2,7 +2,6 @@ import {
2
2
  ButtonPopupCheckbox,
3
3
  ButtonPopupCheckboxProps
4
4
  } from "@etsoo/materialui";
5
- import { ArrayUtils } from "@etsoo/shared";
6
5
  import { useRequiredAppContext } from "../../ICoreServiceApp";
7
6
  import { CultureItem } from "@etsoo/appscript";
8
7
 
@@ -47,11 +46,9 @@ export function ButtonCultures(
47
46
  }
48
47
  labelEnd={labelEnd}
49
48
  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
- }}
49
+ loadData={async () =>
50
+ (await app.core.publicApi.getCultures(defaultCultures)) ?? []
51
+ }
55
52
  onAdd={async (ids) => {
56
53
  const data = await app.core.publicApi.getCultures(ids);
57
54
  if (data == null) return false;
@@ -3,7 +3,6 @@ import {
3
3
  ButtonPopupCheckboxProps
4
4
  } from "@etsoo/materialui";
5
5
  import { CurrencyItem } from "../../dto/public/CurrencyItem";
6
- import { ArrayUtils } from "@etsoo/shared";
7
6
  import { useRequiredAppContext } from "../../ICoreServiceApp";
8
7
 
9
8
  export function ButtonCurrencies(
@@ -45,11 +44,9 @@ export function ButtonCurrencies(
45
44
  labelFormatter={(data) => `${data.name} (${data.id})`}
46
45
  labelEnd={labelEnd}
47
46
  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
- }}
47
+ loadData={async () =>
48
+ (await app.core.publicApi.getCurrencies(defaultCurrencies)) ?? []
49
+ }
53
50
  onAdd={async (ids) => {
54
51
  const data = await app.core.publicApi.getCurrencies(ids);
55
52
  if (data == null) return false;
@@ -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
+ }
@@ -25,6 +25,12 @@ export type UserTiplistProps = Omit<
25
25
  * Default request data
26
26
  */
27
27
  rq?: Partial<MemberListRQ>;
28
+
29
+ /**
30
+ * Load data handler
31
+ * @param rq Request data
32
+ */
33
+ onLoadData?: (rq: MemberListRQ) => MemberListRQ;
28
34
  };
29
35
 
30
36
  /**
@@ -43,6 +49,7 @@ export function UserTiplist(props: UserTiplistProps) {
43
49
  label = app.get("user")!,
44
50
  maxItems = 10,
45
51
  getOptionLabel = (data) => data.name,
52
+ onLoadData = (rq) => rq,
46
53
  name = "userId",
47
54
  rq = { enabled: true },
48
55
  ...rest
@@ -58,14 +65,14 @@ export function UserTiplist(props: UserTiplistProps) {
58
65
  maxItems={maxItems}
59
66
  loadData={(keyword, id, maxItems) =>
60
67
  app.core.memberApi.list(
61
- {
68
+ onLoadData({
62
69
  ...rq,
63
70
  keyword,
64
71
  id,
65
72
  queryPaging: {
66
73
  batchSize: maxItems
67
74
  }
68
- },
75
+ }),
69
76
  { showLoading: false, defaultValue: [] }
70
77
  )
71
78
  }
@@ -59,7 +59,7 @@
59
59
  "owner": "所有者",
60
60
  "parentOrg": "上级机构",
61
61
  "pin": "身份证号码",
62
- "preferredName": "首选姓名",
62
+ "preferredName": "首选名称",
63
63
  "queryKeyword": "查询关键字",
64
64
  "refreshTime": "刷新时间",
65
65
  "relatedTarget": "关联对象",
@@ -59,7 +59,7 @@
59
59
  "owner": "所有者",
60
60
  "parentOrg": "上級機構",
61
61
  "pin": "身份證號碼",
62
- "preferredName": "首選姓名",
62
+ "preferredName": "首選名稱",
63
63
  "queryKeyword": "查詢關鍵字",
64
64
  "refreshTime": "刷新時間",
65
65
  "relatedTarget": "關聯對象",