@etsoo/smarterp-core 1.0.72 → 1.0.74

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.
@@ -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, value: 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: 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);
@@ -1,9 +1,13 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.ButtonCultures = ButtonCultures;
4
7
  const jsx_runtime_1 = require("react/jsx-runtime");
5
8
  const materialui_1 = require("@etsoo/materialui");
6
9
  const ICoreServiceApp_1 = require("../../ICoreServiceApp");
10
+ const react_1 = __importDefault(require("react"));
7
11
  function ButtonCultures(props) {
8
12
  // App
9
13
  const app = (0, ICoreServiceApp_1.useRequiredAppContext)();
@@ -24,7 +28,9 @@ function ButtonCultures(props) {
24
28
  "ar"
25
29
  ];
26
30
  defaultCultures.sort((a) => (app.culture.startsWith(a) ? -1 : 0));
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) => {
31
+ // Load data
32
+ const loadData = react_1.default.useCallback(async () => (await app.core.publicApi.getCultures(defaultCultures)) ?? [], []);
33
+ 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: loadData, onAdd: async (ids) => {
28
34
  const data = await app.core.publicApi.getCultures(ids);
29
35
  if (data == null)
30
36
  return false;
@@ -1,9 +1,13 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.ButtonCurrencies = ButtonCurrencies;
4
7
  const jsx_runtime_1 = require("react/jsx-runtime");
5
8
  const materialui_1 = require("@etsoo/materialui");
6
9
  const ICoreServiceApp_1 = require("../../ICoreServiceApp");
10
+ const react_1 = __importDefault(require("react"));
7
11
  function ButtonCurrencies(props) {
8
12
  // App
9
13
  const app = (0, ICoreServiceApp_1.useRequiredAppContext)();
@@ -24,7 +28,9 @@ function ButtonCurrencies(props) {
24
28
  "NZD"
25
29
  ];
26
30
  defaultCurrencies.sort((a) => (a.startsWith(app.region) ? -1 : 0));
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) => {
31
+ // Load data
32
+ const loadData = react_1.default.useCallback(async () => (await app.core.publicApi.getCurrencies(defaultCurrencies)) ?? [], []);
33
+ 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) => {
28
34
  const data = await app.core.publicApi.getCurrencies(ids);
29
35
  if (data == null)
30
36
  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,40 @@
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.ButtonRegions = ButtonRegions;
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
+ function ButtonRegions(props) {
12
+ // App
13
+ const app = (0, ICoreServiceApp_1.useRequiredAppContext)();
14
+ // Labels
15
+ const labels = app.getLabels("clickToChoose", "regions");
16
+ // Destruct
17
+ const { inputName = "regions", label = labels.regions, labelEnd = labels.clickToChoose, ...rest } = props;
18
+ const defaultRegions = [
19
+ "CN",
20
+ "US",
21
+ "GB",
22
+ "IE",
23
+ "CA",
24
+ "AU",
25
+ "NZ",
26
+ "DE",
27
+ "FR",
28
+ "JP",
29
+ "SG",
30
+ "HK"
31
+ ];
32
+ // Load data
33
+ const loadData = react_1.default.useCallback(async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [], []);
34
+ 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) => {
35
+ const data = await app.core.publicApi.getRegions(ids);
36
+ if (data == null)
37
+ return false;
38
+ return data;
39
+ }, ...rest }));
40
+ }
@@ -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, value: ids, onValueChange: (ids) => {
24
+ return (_jsx(ButtonPopupCheckbox, { inputName: inputName, label: label, labelFormatter: (data) => data.label, labelEnd: labelEnd, labelField: "label", loadData: 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";
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { ButtonPopupCheckbox } from "@etsoo/materialui";
3
3
  import { useRequiredAppContext } from "../../ICoreServiceApp";
4
+ import React from "react";
4
5
  export function ButtonCultures(props) {
5
6
  // App
6
7
  const app = useRequiredAppContext();
@@ -21,7 +22,9 @@ export function ButtonCultures(props) {
21
22
  "ar"
22
23
  ];
23
24
  defaultCultures.sort((a) => (app.culture.startsWith(a) ? -1 : 0));
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) => {
25
+ // Load data
26
+ const loadData = React.useCallback(async () => (await app.core.publicApi.getCultures(defaultCultures)) ?? [], []);
27
+ return (_jsx(ButtonPopupCheckbox, { inputName: inputName, label: label, labelFormatter: (data) => `${data.name === data.id ? data.englishName : data.name} (${data.id})`, labelEnd: labelEnd, labelField: "name", loadData: loadData, onAdd: async (ids) => {
25
28
  const data = await app.core.publicApi.getCultures(ids);
26
29
  if (data == null)
27
30
  return false;
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { ButtonPopupCheckbox } from "@etsoo/materialui";
3
3
  import { useRequiredAppContext } from "../../ICoreServiceApp";
4
+ import React from "react";
4
5
  export function ButtonCurrencies(props) {
5
6
  // App
6
7
  const app = useRequiredAppContext();
@@ -21,7 +22,9 @@ export function ButtonCurrencies(props) {
21
22
  "NZD"
22
23
  ];
23
24
  defaultCurrencies.sort((a) => (a.startsWith(app.region) ? -1 : 0));
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) => {
25
+ // Load data
26
+ const loadData = React.useCallback(async () => (await app.core.publicApi.getCurrencies(defaultCurrencies)) ?? [], []);
27
+ return (_jsx(ButtonPopupCheckbox, { inputName: inputName, label: label, labelFormatter: (data) => `${data.name} (${data.id})`, labelEnd: labelEnd, labelField: "name", loadData: loadData, onAdd: async (ids) => {
25
28
  const data = await app.core.publicApi.getCurrencies(ids);
26
29
  if (data == null)
27
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
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ButtonPopupCheckbox } from "@etsoo/materialui";
3
+ import { useRequiredAppContext } from "../../ICoreServiceApp";
4
+ import React from "react";
5
+ export function ButtonRegions(props) {
6
+ // App
7
+ const app = useRequiredAppContext();
8
+ // Labels
9
+ const labels = app.getLabels("clickToChoose", "regions");
10
+ // Destruct
11
+ const { inputName = "regions", label = labels.regions, labelEnd = labels.clickToChoose, ...rest } = props;
12
+ const defaultRegions = [
13
+ "CN",
14
+ "US",
15
+ "GB",
16
+ "IE",
17
+ "CA",
18
+ "AU",
19
+ "NZ",
20
+ "DE",
21
+ "FR",
22
+ "JP",
23
+ "SG",
24
+ "HK"
25
+ ];
26
+ // Load data
27
+ const loadData = React.useCallback(async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [], []);
28
+ return (_jsx(ButtonPopupCheckbox, { inputName: inputName, label: label, labelFormatter: (data) => `${data.name} (${data.id})`, labelEnd: labelEnd, labelField: "name", loadData: loadData, 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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/smarterp-core",
3
- "version": "1.0.72",
3
+ "version": "1.0.74",
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.36",
57
- "@etsoo/materialui": "^1.5.54",
56
+ "@etsoo/appscript": "^1.6.38",
57
+ "@etsoo/materialui": "^1.5.57",
58
58
  "@etsoo/react": "^1.8.45",
59
59
  "@etsoo/shared": "^1.2.74",
60
60
  "@etsoo/toolpad": "^1.0.39",
@@ -70,7 +70,7 @@ export function ButtonIdentityTypes(props: ButtonIdentityTypesProps) {
70
70
  labelFormatter={(data) => data.label}
71
71
  labelEnd={labelEnd}
72
72
  labelField="label"
73
- loadData={async () => identities}
73
+ loadData={identities}
74
74
  value={ids}
75
75
  onValueChange={(ids) => {
76
76
  let newValue = IdentityTypeFlags.None;
@@ -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
@@ -4,6 +4,7 @@ import {
4
4
  } from "@etsoo/materialui";
5
5
  import { useRequiredAppContext } from "../../ICoreServiceApp";
6
6
  import { CultureItem } from "@etsoo/appscript";
7
+ import React from "react";
7
8
 
8
9
  export function ButtonCultures(
9
10
  props: Omit<ButtonPopupCheckboxProps<CultureItem>, "labelField" | "loadData">
@@ -37,6 +38,12 @@ export function ButtonCultures(
37
38
 
38
39
  defaultCultures.sort((a) => (app.culture.startsWith(a) ? -1 : 0));
39
40
 
41
+ // Load data
42
+ const loadData = React.useCallback(
43
+ async () => (await app.core.publicApi.getCultures(defaultCultures)) ?? [],
44
+ []
45
+ );
46
+
40
47
  return (
41
48
  <ButtonPopupCheckbox<CultureItem>
42
49
  inputName={inputName}
@@ -46,9 +53,7 @@ export function ButtonCultures(
46
53
  }
47
54
  labelEnd={labelEnd}
48
55
  labelField="name"
49
- loadData={async () =>
50
- (await app.core.publicApi.getCultures(defaultCultures)) ?? []
51
- }
56
+ loadData={loadData}
52
57
  onAdd={async (ids) => {
53
58
  const data = await app.core.publicApi.getCultures(ids);
54
59
  if (data == null) return false;
@@ -4,6 +4,7 @@ import {
4
4
  } from "@etsoo/materialui";
5
5
  import { CurrencyItem } from "../../dto/public/CurrencyItem";
6
6
  import { useRequiredAppContext } from "../../ICoreServiceApp";
7
+ import React from "react";
7
8
 
8
9
  export function ButtonCurrencies(
9
10
  props: Omit<ButtonPopupCheckboxProps<CurrencyItem>, "labelField" | "loadData">
@@ -37,6 +38,13 @@ export function ButtonCurrencies(
37
38
 
38
39
  defaultCurrencies.sort((a) => (a.startsWith(app.region) ? -1 : 0));
39
40
 
41
+ // Load data
42
+ const loadData = React.useCallback(
43
+ async () =>
44
+ (await app.core.publicApi.getCurrencies(defaultCurrencies)) ?? [],
45
+ []
46
+ );
47
+
40
48
  return (
41
49
  <ButtonPopupCheckbox<CurrencyItem>
42
50
  inputName={inputName}
@@ -44,9 +52,7 @@ export function ButtonCurrencies(
44
52
  labelFormatter={(data) => `${data.name} (${data.id})`}
45
53
  labelEnd={labelEnd}
46
54
  labelField="name"
47
- loadData={async () =>
48
- (await app.core.publicApi.getCurrencies(defaultCurrencies)) ?? []
49
- }
55
+ loadData={loadData}
50
56
  onAdd={async (ids) => {
51
57
  const data = await app.core.publicApi.getCurrencies(ids);
52
58
  if (data == null) return false;
@@ -0,0 +1,63 @@
1
+ import {
2
+ ButtonPopupCheckbox,
3
+ ButtonPopupCheckboxProps
4
+ } from "@etsoo/materialui";
5
+ import { RegionData } from "../../dto/public/RegionData";
6
+ import { useRequiredAppContext } from "../../ICoreServiceApp";
7
+ import React from "react";
8
+
9
+ export function ButtonRegions(
10
+ props: Omit<ButtonPopupCheckboxProps<RegionData>, "labelField" | "loadData">
11
+ ) {
12
+ // App
13
+ const app = useRequiredAppContext();
14
+
15
+ // Labels
16
+ const labels = app.getLabels("clickToChoose", "regions");
17
+
18
+ // Destruct
19
+ const {
20
+ inputName = "regions",
21
+ label = labels.regions,
22
+ labelEnd = labels.clickToChoose,
23
+ ...rest
24
+ } = props;
25
+
26
+ const defaultRegions = [
27
+ "CN",
28
+ "US",
29
+ "GB",
30
+ "IE",
31
+ "CA",
32
+ "AU",
33
+ "NZ",
34
+ "DE",
35
+ "FR",
36
+ "JP",
37
+ "SG",
38
+ "HK"
39
+ ];
40
+
41
+ // Load data
42
+ const loadData = React.useCallback(
43
+ async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [],
44
+ []
45
+ );
46
+
47
+ return (
48
+ <ButtonPopupCheckbox<RegionData>
49
+ inputName={inputName}
50
+ label={label}
51
+ labelFormatter={(data) => `${data.name} (${data.id})`}
52
+ labelEnd={labelEnd}
53
+ labelField="name"
54
+ loadData={loadData}
55
+ onAdd={async (ids) => {
56
+ const data = await app.core.publicApi.getRegions(ids);
57
+ if (data == null) return false;
58
+ return data;
59
+ }}
60
+ {...rest}
61
+ />
62
+ );
63
+ }