@etsoo/smarterp-core 1.0.92 → 1.0.93

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.
@@ -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
@@ -1,3 +1,3 @@
1
1
  import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
2
2
  import { CultureItem } from "@etsoo/appscript";
3
- export declare function ButtonCultures(props: Omit<ButtonPopupCheckboxProps<CultureItem>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
3
+ export declare function ButtonCultures(props: Omit<ButtonPopupCheckboxProps<CultureItem>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element | undefined;
@@ -27,6 +27,13 @@ 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
+ return;
35
+ defaultCultures.unshift(c.name);
36
+ }
30
37
  defaultCultures.sort((a) => (app.culture.startsWith(a) ? -1 : 0));
31
38
  // Load data
32
39
  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 | undefined;
@@ -0,0 +1,47 @@
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
+ function ButtonRadioRegions(props) {
12
+ // App
13
+ const app = (0, ICoreServiceApp_1.useRequiredAppContext)();
14
+ // Labels
15
+ const labels = app.getLabels("clickToChoose", "region");
16
+ // Destruct
17
+ const { inputName = "region", label = labels.region, 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
+ // Add application regions, starting from the end
33
+ for (let i = app.settings.regions.length - 1; i >= 0; i--) {
34
+ const r = app.settings.regions[i];
35
+ if (defaultRegions.includes(r))
36
+ return;
37
+ defaultRegions.unshift(r);
38
+ }
39
+ // Load data
40
+ const loadData = react_1.default.useCallback(async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [], []);
41
+ 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) => {
42
+ const data = await app.core.publicApi.getRegions(ids);
43
+ if (data == null)
44
+ return false;
45
+ return data;
46
+ }, ...rest }));
47
+ }
@@ -1,3 +1,3 @@
1
1
  import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
2
2
  import { RegionData } from "../../dto/public/RegionData";
3
- export declare function ButtonRegions(props: Omit<ButtonPopupCheckboxProps<RegionData>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
3
+ export declare function ButtonRegions(props: Omit<ButtonPopupCheckboxProps<RegionData>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element | undefined;
@@ -29,6 +29,13 @@ function ButtonRegions(props) {
29
29
  "SG",
30
30
  "HK"
31
31
  ];
32
+ // Add application regions, starting from the end
33
+ for (let i = app.settings.regions.length - 1; i >= 0; i--) {
34
+ const r = app.settings.regions[i];
35
+ if (defaultRegions.includes(r))
36
+ return;
37
+ defaultRegions.unshift(r);
38
+ }
32
39
  // Load data
33
40
  const loadData = react_1.default.useCallback(async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [], []);
34
41
  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) => {
@@ -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
@@ -1,3 +1,3 @@
1
1
  import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
2
2
  import { CultureItem } from "@etsoo/appscript";
3
- export declare function ButtonCultures(props: Omit<ButtonPopupCheckboxProps<CultureItem>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
3
+ export declare function ButtonCultures(props: Omit<ButtonPopupCheckboxProps<CultureItem>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element | undefined;
@@ -21,6 +21,13 @@ 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
+ return;
29
+ defaultCultures.unshift(c.name);
30
+ }
24
31
  defaultCultures.sort((a) => (app.culture.startsWith(a) ? -1 : 0));
25
32
  // Load data
26
33
  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 | undefined;
@@ -0,0 +1,41 @@
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
+ export function ButtonRadioRegions(props) {
6
+ // App
7
+ const app = useRequiredAppContext();
8
+ // Labels
9
+ const labels = app.getLabels("clickToChoose", "region");
10
+ // Destruct
11
+ const { inputName = "region", label = labels.region, 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
+ // Add application regions, starting from the end
27
+ for (let i = app.settings.regions.length - 1; i >= 0; i--) {
28
+ const r = app.settings.regions[i];
29
+ if (defaultRegions.includes(r))
30
+ return;
31
+ defaultRegions.unshift(r);
32
+ }
33
+ // Load data
34
+ const loadData = React.useCallback(async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [], []);
35
+ return (_jsx(ButtonPopupRadio, { inputName: inputName, label: label, labelFormatter: (data) => `${data.name} (${data.id})`, labelEnd: labelEnd, labelField: "name", loadData: loadData, onAdd: async (ids) => {
36
+ const data = await app.core.publicApi.getRegions(ids);
37
+ if (data == null)
38
+ return false;
39
+ return data;
40
+ }, ...rest }));
41
+ }
@@ -1,3 +1,3 @@
1
1
  import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
2
2
  import { RegionData } from "../../dto/public/RegionData";
3
- export declare function ButtonRegions(props: Omit<ButtonPopupCheckboxProps<RegionData>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element;
3
+ export declare function ButtonRegions(props: Omit<ButtonPopupCheckboxProps<RegionData>, "labelField" | "loadData">): import("react/jsx-runtime").JSX.Element | undefined;
@@ -23,6 +23,13 @@ export function ButtonRegions(props) {
23
23
  "SG",
24
24
  "HK"
25
25
  ];
26
+ // Add application regions, starting from the end
27
+ for (let i = app.settings.regions.length - 1; i >= 0; i--) {
28
+ const r = app.settings.regions[i];
29
+ if (defaultRegions.includes(r))
30
+ return;
31
+ defaultRegions.unshift(r);
32
+ }
26
33
  // Load data
27
34
  const loadData = React.useCallback(async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [], []);
28
35
  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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/smarterp-core",
3
- "version": "1.0.92",
3
+ "version": "1.0.93",
4
4
  "description": "TypeScript APIs for SmartERP Core",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -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,13 @@ 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)) return;
43
+ defaultCultures.unshift(c.name);
44
+ }
45
+
39
46
  defaultCultures.sort((a) => (app.culture.startsWith(a) ? -1 : 0));
40
47
 
41
48
  // Load data
@@ -0,0 +1,67 @@
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
+
6
+ export function ButtonRadioRegions(
7
+ props: Omit<ButtonPopupRadioProps<RegionData>, "labelField" | "loadData">
8
+ ) {
9
+ // App
10
+ const app = useRequiredAppContext();
11
+
12
+ // Labels
13
+ const labels = app.getLabels("clickToChoose", "region");
14
+
15
+ // Destruct
16
+ const {
17
+ inputName = "region",
18
+ label = labels.region,
19
+ labelEnd = labels.clickToChoose,
20
+ ...rest
21
+ } = props;
22
+
23
+ const defaultRegions = [
24
+ "CN",
25
+ "US",
26
+ "GB",
27
+ "IE",
28
+ "CA",
29
+ "AU",
30
+ "NZ",
31
+ "DE",
32
+ "FR",
33
+ "JP",
34
+ "SG",
35
+ "HK"
36
+ ];
37
+
38
+ // Add application regions, starting from the end
39
+ for (let i = app.settings.regions.length - 1; i >= 0; i--) {
40
+ const r = app.settings.regions[i];
41
+ if (defaultRegions.includes(r)) return;
42
+ defaultRegions.unshift(r);
43
+ }
44
+
45
+ // Load data
46
+ const loadData = React.useCallback(
47
+ async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [],
48
+ []
49
+ );
50
+
51
+ return (
52
+ <ButtonPopupRadio<RegionData>
53
+ inputName={inputName}
54
+ label={label}
55
+ labelFormatter={(data) => `${data.name} (${data.id})`}
56
+ labelEnd={labelEnd}
57
+ labelField="name"
58
+ loadData={loadData}
59
+ onAdd={async (ids) => {
60
+ const data = await app.core.publicApi.getRegions(ids);
61
+ if (data == null) return false;
62
+ return data;
63
+ }}
64
+ {...rest}
65
+ />
66
+ );
67
+ }
@@ -38,6 +38,13 @@ export function ButtonRegions(
38
38
  "HK"
39
39
  ];
40
40
 
41
+ // Add application regions, starting from the end
42
+ for (let i = app.settings.regions.length - 1; i >= 0; i--) {
43
+ const r = app.settings.regions[i];
44
+ if (defaultRegions.includes(r)) return;
45
+ defaultRegions.unshift(r);
46
+ }
47
+
41
48
  // Load data
42
49
  const loadData = React.useCallback(
43
50
  async () => (await app.core.publicApi.getRegions(defaultRegions)) ?? [],