@etsoo/smarterp-core 1.0.69 → 1.0.70
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/app/ButtonIdentityTypes.d.ts +20 -0
- package/lib/cjs/components/app/ButtonIdentityTypes.js +37 -0
- package/lib/cjs/components/index.d.ts +1 -0
- package/lib/cjs/components/index.js +1 -0
- package/lib/mjs/components/app/ButtonIdentityTypes.d.ts +20 -0
- package/lib/mjs/components/app/ButtonIdentityTypes.js +31 -0
- package/lib/mjs/components/index.d.ts +1 -0
- package/lib/mjs/components/index.js +1 -0
- package/package.json +3 -3
- package/src/components/app/ButtonIdentityTypes.tsx +85 -0
- package/src/components/index.ts +1 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
|
|
2
|
+
import { ListType } from "@etsoo/shared";
|
|
3
|
+
import { IdentityTypeFlags } from "@etsoo/appscript";
|
|
4
|
+
export type ButtonIdentityTypesProps = Omit<ButtonPopupCheckboxProps<ListType>, "labelField" | "loadData" | "ids" | "value" | "onValueChange"> & {
|
|
5
|
+
/**
|
|
6
|
+
* Base identity type
|
|
7
|
+
*/
|
|
8
|
+
baseIdentity?: IdentityTypeFlags;
|
|
9
|
+
/**
|
|
10
|
+
* Value
|
|
11
|
+
* 值
|
|
12
|
+
*/
|
|
13
|
+
value?: IdentityTypeFlags;
|
|
14
|
+
/**
|
|
15
|
+
* Value change handler
|
|
16
|
+
* @param value New value
|
|
17
|
+
*/
|
|
18
|
+
onValueChange: (value: IdentityTypeFlags) => void;
|
|
19
|
+
};
|
|
20
|
+
export declare function ButtonIdentityTypes(props: ButtonIdentityTypesProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,37 @@
|
|
|
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.ButtonIdentityTypes = ButtonIdentityTypes;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const materialui_1 = require("@etsoo/materialui");
|
|
9
|
+
const appscript_1 = require("@etsoo/appscript");
|
|
10
|
+
const react_1 = __importDefault(require("react"));
|
|
11
|
+
const ICoreServiceApp_1 = require("../../ICoreServiceApp");
|
|
12
|
+
function ButtonIdentityTypes(props) {
|
|
13
|
+
// App
|
|
14
|
+
const app = (0, ICoreServiceApp_1.useRequiredAppContext)();
|
|
15
|
+
// Labels
|
|
16
|
+
const labels = app.getLabels("clickToChoose", "identityType");
|
|
17
|
+
// Destruct
|
|
18
|
+
const { inputName = "identityType", label = labels.identityType, labelEnd = labels.clickToChoose, baseIdentity, onValueChange, value, ...rest } = props;
|
|
19
|
+
// Identities
|
|
20
|
+
const identities = react_1.default.useMemo(() => app.core.getIdentityFlags(baseIdentity).filter((d) => d.id > 0), [baseIdentity]);
|
|
21
|
+
const ids = [];
|
|
22
|
+
if (value != null) {
|
|
23
|
+
// Convert to ids
|
|
24
|
+
for (const identity of identities) {
|
|
25
|
+
if ((value & identity.id) === identity.id) {
|
|
26
|
+
ids.push(identity.id);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
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) => {
|
|
31
|
+
let newValue = appscript_1.IdentityTypeFlags.None;
|
|
32
|
+
for (const id of ids) {
|
|
33
|
+
newValue |= id;
|
|
34
|
+
}
|
|
35
|
+
onValueChange(newValue);
|
|
36
|
+
}, ...rest }));
|
|
37
|
+
}
|
|
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
__exportStar(require("./DefaultUI"), exports);
|
|
19
19
|
// app
|
|
20
20
|
__exportStar(require("./app/AppSwitchPopover"), exports);
|
|
21
|
+
__exportStar(require("./app/ButtonIdentityTypes"), exports);
|
|
21
22
|
__exportStar(require("./app/IdentityFlagsList"), exports);
|
|
22
23
|
__exportStar(require("./app/IdentityTypeList"), exports);
|
|
23
24
|
__exportStar(require("./app/SearchDays"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ButtonPopupCheckboxProps } from "@etsoo/materialui";
|
|
2
|
+
import { ListType } from "@etsoo/shared";
|
|
3
|
+
import { IdentityTypeFlags } from "@etsoo/appscript";
|
|
4
|
+
export type ButtonIdentityTypesProps = Omit<ButtonPopupCheckboxProps<ListType>, "labelField" | "loadData" | "ids" | "value" | "onValueChange"> & {
|
|
5
|
+
/**
|
|
6
|
+
* Base identity type
|
|
7
|
+
*/
|
|
8
|
+
baseIdentity?: IdentityTypeFlags;
|
|
9
|
+
/**
|
|
10
|
+
* Value
|
|
11
|
+
* 值
|
|
12
|
+
*/
|
|
13
|
+
value?: IdentityTypeFlags;
|
|
14
|
+
/**
|
|
15
|
+
* Value change handler
|
|
16
|
+
* @param value New value
|
|
17
|
+
*/
|
|
18
|
+
onValueChange: (value: IdentityTypeFlags) => void;
|
|
19
|
+
};
|
|
20
|
+
export declare function ButtonIdentityTypes(props: ButtonIdentityTypesProps): 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 { IdentityTypeFlags } from "@etsoo/appscript";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { useRequiredAppContext } from "../../ICoreServiceApp";
|
|
6
|
+
export function ButtonIdentityTypes(props) {
|
|
7
|
+
// App
|
|
8
|
+
const app = useRequiredAppContext();
|
|
9
|
+
// Labels
|
|
10
|
+
const labels = app.getLabels("clickToChoose", "identityType");
|
|
11
|
+
// Destruct
|
|
12
|
+
const { inputName = "identityType", label = labels.identityType, labelEnd = labels.clickToChoose, baseIdentity, onValueChange, value, ...rest } = props;
|
|
13
|
+
// Identities
|
|
14
|
+
const identities = React.useMemo(() => app.core.getIdentityFlags(baseIdentity).filter((d) => d.id > 0), [baseIdentity]);
|
|
15
|
+
const ids = [];
|
|
16
|
+
if (value != null) {
|
|
17
|
+
// Convert to ids
|
|
18
|
+
for (const identity of identities) {
|
|
19
|
+
if ((value & identity.id) === identity.id) {
|
|
20
|
+
ids.push(identity.id);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return (_jsx(ButtonPopupCheckbox, { inputName: inputName, label: label, labelFormatter: (data) => data.label, labelEnd: labelEnd, labelField: "label", loadData: async () => identities, ids: ids, onValueChange: (ids) => {
|
|
25
|
+
let newValue = IdentityTypeFlags.None;
|
|
26
|
+
for (const id of ids) {
|
|
27
|
+
newValue |= id;
|
|
28
|
+
}
|
|
29
|
+
onValueChange(newValue);
|
|
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.70",
|
|
4
4
|
"description": "TypeScript APIs for SmartERP Core",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@babel/plugin-transform-runtime": "^7.27.1",
|
|
46
46
|
"@babel/preset-env": "^7.27.2",
|
|
47
47
|
"@babel/runtime-corejs3": "^7.27.1",
|
|
48
|
-
"@types/react": "^18.3.
|
|
48
|
+
"@types/react": "^18.3.23",
|
|
49
49
|
"@types/react-dom": "^18.3.7",
|
|
50
50
|
"@vitejs/plugin-react": "^4.5.0",
|
|
51
51
|
"jsdom": "^26.1.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@etsoo/appscript": "^1.6.36",
|
|
57
|
-
"@etsoo/materialui": "^1.5.
|
|
57
|
+
"@etsoo/materialui": "^1.5.52",
|
|
58
58
|
"@etsoo/react": "^1.8.45",
|
|
59
59
|
"@etsoo/shared": "^1.2.74",
|
|
60
60
|
"@etsoo/toolpad": "^1.0.39",
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ButtonPopupCheckbox,
|
|
3
|
+
ButtonPopupCheckboxProps
|
|
4
|
+
} from "@etsoo/materialui";
|
|
5
|
+
import { ListType } from "@etsoo/shared";
|
|
6
|
+
import { IdentityTypeFlags } from "@etsoo/appscript";
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { useRequiredAppContext } from "../../ICoreServiceApp";
|
|
9
|
+
|
|
10
|
+
export type ButtonIdentityTypesProps = Omit<
|
|
11
|
+
ButtonPopupCheckboxProps<ListType>,
|
|
12
|
+
"labelField" | "loadData" | "ids" | "value" | "onValueChange"
|
|
13
|
+
> & {
|
|
14
|
+
/**
|
|
15
|
+
* Base identity type
|
|
16
|
+
*/
|
|
17
|
+
baseIdentity?: IdentityTypeFlags;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Value
|
|
21
|
+
* 值
|
|
22
|
+
*/
|
|
23
|
+
value?: IdentityTypeFlags;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Value change handler
|
|
27
|
+
* @param value New value
|
|
28
|
+
*/
|
|
29
|
+
onValueChange: (value: IdentityTypeFlags) => void;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export function ButtonIdentityTypes(props: ButtonIdentityTypesProps) {
|
|
33
|
+
// App
|
|
34
|
+
const app = useRequiredAppContext();
|
|
35
|
+
|
|
36
|
+
// Labels
|
|
37
|
+
const labels = app.getLabels("clickToChoose", "identityType");
|
|
38
|
+
|
|
39
|
+
// Destruct
|
|
40
|
+
const {
|
|
41
|
+
inputName = "identityType",
|
|
42
|
+
label = labels.identityType,
|
|
43
|
+
labelEnd = labels.clickToChoose,
|
|
44
|
+
baseIdentity,
|
|
45
|
+
onValueChange,
|
|
46
|
+
value,
|
|
47
|
+
...rest
|
|
48
|
+
} = props;
|
|
49
|
+
|
|
50
|
+
// Identities
|
|
51
|
+
const identities = React.useMemo(
|
|
52
|
+
() => app.core.getIdentityFlags(baseIdentity).filter((d) => d.id > 0),
|
|
53
|
+
[baseIdentity]
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const ids: number[] = [];
|
|
57
|
+
if (value != null) {
|
|
58
|
+
// Convert to ids
|
|
59
|
+
for (const identity of identities) {
|
|
60
|
+
if ((value & identity.id) === identity.id) {
|
|
61
|
+
ids.push(identity.id);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<ButtonPopupCheckbox<ListType>
|
|
68
|
+
inputName={inputName}
|
|
69
|
+
label={label}
|
|
70
|
+
labelFormatter={(data) => data.label}
|
|
71
|
+
labelEnd={labelEnd}
|
|
72
|
+
labelField="label"
|
|
73
|
+
loadData={async () => identities}
|
|
74
|
+
ids={ids}
|
|
75
|
+
onValueChange={(ids) => {
|
|
76
|
+
let newValue = IdentityTypeFlags.None;
|
|
77
|
+
for (const id of ids) {
|
|
78
|
+
newValue |= id;
|
|
79
|
+
}
|
|
80
|
+
onValueChange(newValue);
|
|
81
|
+
}}
|
|
82
|
+
{...rest}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
}
|
package/src/components/index.ts
CHANGED