@_tc/template-core 0.2.0-bate.1 → 0.2.0-bate.11
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/.skills/tc-generator/reference/model-schema.md +18 -0
- package/.skills/tc-generator/reference/runtime-extensions.md +20 -0
- package/AGENT_README.md +29 -11
- package/README.md +222 -27
- package/cjs/app/controller/view.js +1 -1
- package/cjs/bundler/buildFE.js +1 -0
- package/cjs/bundler/index.js +1 -1
- package/cjs/bundler/utils.js +1 -1
- package/cjs/packages/common/index.js +1 -1
- package/cjs/packages/common/rafTimer.js +1 -0
- package/esm/app/controller/view.js +4 -1
- package/esm/bundler/buildFE.js +14 -0
- package/esm/bundler/index.js +3 -15
- package/esm/bundler/utils.js +1 -0
- package/esm/packages/common/index.js +3 -2
- package/esm/packages/common/rafTimer.js +47 -0
- package/fe/frontend/apps/dash/Dashboard.js +6 -4
- package/fe/frontend/apps/dash/dash.entry.js +4 -0
- package/fe/frontend/src/common/generateMenuData.d.ts +4 -1
- package/fe/frontend/src/common/generateMenuData.js +3 -3
- package/fe/frontend/src/common/language.d.ts +12 -1
- package/fe/frontend/src/common/language.js +27 -6
- package/fe/frontend/src/common/rafTimer.d.ts +1 -0
- package/fe/frontend/src/common/rafTimer.js +2 -0
- package/fe/frontend/src/common/request.js +1 -0
- package/fe/frontend/src/common/theme.d.ts +7 -0
- package/fe/frontend/src/common/theme.js +33 -0
- package/fe/frontend/src/components/BasePage/HeaderView.js +2 -2
- package/fe/frontend/src/components/LanguageSwitch/LanguageSwitch.js +22 -6
- package/fe/frontend/src/components/ThemeSwitch/ThemeSwitch.d.ts +3 -2
- package/fe/frontend/src/components/ThemeSwitch/ThemeSwitch.js +6 -29
- package/fe/frontend/src/components/ThemeSwitch/index.d.ts +1 -0
- package/fe/frontend/src/components/ThemeSwitch/index.js +3 -2
- package/fe/frontend/src/components/index.js +2 -2
- package/fe/frontend/src/defaultPages/NotFoundPage/index.js +4 -3
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/DetailPanel.js +14 -9
- package/fe/frontend/src/defaultPages/SchemaPage/components/CallCom/PopFrom.js +8 -7
- package/fe/frontend/src/defaultPages/SchemaPage/components/SchemaSearch/index.js +20 -24
- package/fe/frontend/src/defaultPages/SchemaPage/components/SchemaTable/PreviewImage.d.ts +10 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/SchemaTable/PreviewImage.js +17 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/SchemaTable/data.d.ts +5 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/SchemaTable/data.js +8 -0
- package/fe/frontend/src/defaultPages/SchemaPage/components/SchemaTable/index.js +50 -32
- package/fe/frontend/src/defaultPages/SchemaPage/index.css +0 -4
- package/fe/frontend/src/defaultPages/SchemaPage/index.js +5 -3
- package/fe/frontend/src/defaultPages/SlotPage/index.js +6 -3
- package/fe/frontend/src/hooks/useText.d.ts +3 -0
- package/fe/frontend/src/hooks/useText.js +14 -0
- package/fe/frontend/src/index.d.ts +11 -3
- package/fe/frontend/src/index.js +8 -3
- package/fe/frontend/src/language/index.d.ts +0 -2
- package/fe/frontend/src/language/index.js +1 -7
- package/fe/frontend/src/language/resources.d.ts +2 -0
- package/fe/frontend/src/language/resources.js +9 -0
- package/fe/model/types/data/schema.d.ts +24 -2
- package/fe/model/types/index.d.ts +1 -0
- package/fe/packages/common/i18n/default.js +3 -0
- package/fe/packages/common/i18n/en-US.js +5 -2
- package/fe/packages/common/i18n/index.js +13 -0
- package/fe/packages/common/i18n/locales.js +7 -0
- package/fe/packages/common/index.d.ts +1 -0
- package/fe/packages/common/rafTimer.d.ts +7 -0
- package/fe/packages/common/rafTimer.js +168 -0
- package/fe/packages/react/hooks/index.d.ts +9 -0
- package/fe/packages/react/hooks/index.js +8 -0
- package/fe/packages/react/hooks/useRefState.d.ts +4 -12
- package/fe/packages/react/hooks/useRefState.js +18 -8
- package/fe/packages/react/ui/components/DataTable/dataTableWidth.d.ts +12 -0
- package/fe/packages/react/ui/components/DataTable/dataTableWidth.js +33 -0
- package/fe/packages/react/ui/components/DataTable/dataTableWidth.test.js +39 -0
- package/fe/packages/react/ui/components/DataTable/index.d.ts +1 -1
- package/fe/packages/react/ui/components/DataTable/index.js +12 -32
- package/fe/packages/react/ui/components/Textarea/Textarea.d.ts +1 -1
- package/fe/packages/react/ui/components/Textarea/Textarea.js +1 -1
- package/fe/packages/react/ui/components/types/baseType.d.ts +21 -0
- package/fe/packages/react/ui/components/types/baseType.js +0 -0
- package/model/frontend/src/common/language.d.ts +12 -1
- package/model/frontend/src/hooks/useText.d.ts +3 -0
- package/model/frontend/src/language/index.d.ts +0 -2
- package/model/frontend/src/language/resources.d.ts +2 -0
- package/model/model/types/data/schema.d.ts +24 -2
- package/model/model/types/index.d.ts +1 -0
- package/model/packages/common/index.d.ts +1 -0
- package/model/packages/common/rafTimer.d.ts +7 -0
- package/model/packages/react/ui/components/DataTable/dataTableWidth.d.ts +12 -0
- package/model/packages/react/ui/components/DataTable/index.d.ts +1 -1
- package/model/packages/react/ui/components/Textarea/Textarea.d.ts +1 -1
- package/model/packages/react/ui/components/types/baseType.d.ts +21 -0
- package/package.json +5 -5
- package/types/bundler/buildFE.d.ts +2 -0
- package/types/bundler/index.d.ts +1 -2
- package/types/packages/common/i18n/default.d.ts +4 -0
- package/types/packages/common/i18n/en-US.d.ts +6 -2
- package/types/packages/common/i18n/index.d.ts +21 -0
- package/types/packages/common/i18n/locales.d.ts +10 -0
- package/types/packages/common/i18n/types.d.ts +40 -0
- package/types/packages/common/index.d.ts +1 -0
- package/types/packages/common/rafTimer.d.ts +44 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { frontendLangKeys } from "../../../../language/index.js";
|
|
2
|
-
import { getText } from "../../../../common/language.js";
|
|
3
2
|
import { Drawer } from "../../../../../../packages/react/ui/components/Drawer/Drawer.js";
|
|
4
3
|
import "../../../../../../packages/react/ui/components/index.js";
|
|
5
4
|
import { request } from "../../../../common/request.js";
|
|
5
|
+
import { useText } from "../../../../hooks/useText.js";
|
|
6
6
|
import { schemaEventBus } from "../../../../stores/schemaEventBus.js";
|
|
7
7
|
import { handlingRequestErrors } from "../../../../common/fetchErrorShow.js";
|
|
8
8
|
import useExecuteOnce from "../../../../../../packages/react/hooks/useExecuteOnce.js";
|
|
@@ -28,7 +28,7 @@ var getOptionLabel = (options, value) => {
|
|
|
28
28
|
if (!matchedOption || typeof matchedOption !== "object") return void 0;
|
|
29
29
|
return matchedOption.label ?? stringifyValue(value);
|
|
30
30
|
};
|
|
31
|
-
var formatValue = (value, fieldInfo) => {
|
|
31
|
+
var formatValue = (value, fieldInfo, text) => {
|
|
32
32
|
if (isEmptyValue(value)) return EMPTY_TEXT;
|
|
33
33
|
const option = fieldInfo.option;
|
|
34
34
|
const optionLabel = getOptionLabel(option?.options ?? option?.enumList, value);
|
|
@@ -39,28 +39,33 @@ var formatValue = (value, fieldInfo) => {
|
|
|
39
39
|
return stringifyValue(item);
|
|
40
40
|
}).join(", ");
|
|
41
41
|
}
|
|
42
|
-
if (typeof value === "boolean") return value ?
|
|
42
|
+
if (typeof value === "boolean") return value ? text(frontendLangKeys.yes) : text(frontendLangKeys.no);
|
|
43
43
|
return stringifyValue(value);
|
|
44
44
|
};
|
|
45
|
-
var generateFields = (schema, data) => {
|
|
45
|
+
var generateFields = (schema, data, text) => {
|
|
46
46
|
if (!schema?.properties) return [];
|
|
47
47
|
return Object.keys(schema.properties).reduce((fields, key) => {
|
|
48
48
|
const fieldInfo = schema.properties[key];
|
|
49
49
|
if (!fieldInfo?.option || fieldInfo.option.visible === false) return fields;
|
|
50
50
|
fields.push({
|
|
51
51
|
key,
|
|
52
|
-
label:
|
|
53
|
-
value: formatValue(data?.[key], fieldInfo),
|
|
52
|
+
label: text(fieldInfo.label),
|
|
53
|
+
value: formatValue(data?.[key], fieldInfo, text),
|
|
54
54
|
level: fieldInfo.level ?? 10
|
|
55
55
|
});
|
|
56
56
|
return fields;
|
|
57
57
|
}, []).sort((a, b) => a.level - b.level);
|
|
58
58
|
};
|
|
59
59
|
var DetailPanel = memo((props) => {
|
|
60
|
+
const text = useText();
|
|
60
61
|
const [open, setOpen] = useState(true);
|
|
61
62
|
const [data, setData] = useState(props.data);
|
|
62
63
|
const { config, schema, api } = useComConfig({ comName: props.comName });
|
|
63
|
-
const fields = useMemo(() => generateFields(schema, data), [
|
|
64
|
+
const fields = useMemo(() => generateFields(schema, data, text), [
|
|
65
|
+
data,
|
|
66
|
+
schema,
|
|
67
|
+
text
|
|
68
|
+
]);
|
|
64
69
|
useExecuteOnce(async () => {
|
|
65
70
|
const fetchKey = config?.fetchKey;
|
|
66
71
|
if (fetchKey) {
|
|
@@ -73,7 +78,7 @@ var DetailPanel = memo((props) => {
|
|
|
73
78
|
return /* @__PURE__ */ jsx("div", {
|
|
74
79
|
className: "detail-panel",
|
|
75
80
|
children: /* @__PURE__ */ jsx(Drawer, {
|
|
76
|
-
title:
|
|
81
|
+
title: text(config?.title ?? ""),
|
|
77
82
|
open,
|
|
78
83
|
onClose: () => {
|
|
79
84
|
setOpen(false);
|
|
@@ -93,7 +98,7 @@ var DetailPanel = memo((props) => {
|
|
|
93
98
|
}, field.key))
|
|
94
99
|
}) : /* @__PURE__ */ jsx("div", {
|
|
95
100
|
className: "py-8 text-center text-sm text-muted-foreground",
|
|
96
|
-
children:
|
|
101
|
+
children: text(frontendLangKeys.noData)
|
|
97
102
|
})
|
|
98
103
|
})
|
|
99
104
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { frontendLangKeys } from "../../../../language/index.js";
|
|
2
|
-
import { getText } from "../../../../common/language.js";
|
|
3
2
|
import { Modal } from "../../../../../../packages/react/ui/components/Modal/Modal.js";
|
|
4
3
|
import { SchemaForm } from "../../../../../../packages/react/ui/components/Form/SchemaForm/index.js";
|
|
5
4
|
import "../../../../../../packages/react/ui/components/index.js";
|
|
6
5
|
import { post, put, request } from "../../../../common/request.js";
|
|
6
|
+
import { useText } from "../../../../hooks/useText.js";
|
|
7
7
|
import { schemaEventBus } from "../../../../stores/schemaEventBus.js";
|
|
8
8
|
import { handlingRequestErrors } from "../../../../common/fetchErrorShow.js";
|
|
9
9
|
import useExecuteOnce from "../../../../../../packages/react/hooks/useExecuteOnce.js";
|
|
@@ -14,7 +14,7 @@ import { createAjvValidator } from "../../utils/validator.js";
|
|
|
14
14
|
import { memo, useCallback, useMemo, useRef, useState } from "react";
|
|
15
15
|
import { jsx } from "react/jsx-runtime";
|
|
16
16
|
//#region frontend/src/defaultPages/SchemaPage/components/CallCom/PopFrom.tsx
|
|
17
|
-
var generateSchemas = (schema) => {
|
|
17
|
+
var generateSchemas = (schema, text) => {
|
|
18
18
|
if (!schema?.properties) return [];
|
|
19
19
|
return Object.keys(schema.properties).reduce((schemas, key) => {
|
|
20
20
|
const fieldInfo = schema.properties[key];
|
|
@@ -23,12 +23,12 @@ var generateSchemas = (schema) => {
|
|
|
23
23
|
const { comType = "input", default: _defaultValue, visible: _visible, ...fieldProps } = option;
|
|
24
24
|
schemas.push({
|
|
25
25
|
key,
|
|
26
|
-
label:
|
|
26
|
+
label: text(fieldInfo.label),
|
|
27
27
|
type: comType,
|
|
28
28
|
required: schema.required?.includes(key),
|
|
29
29
|
rules: [...schema.required?.includes(key) ? [{
|
|
30
30
|
required: true,
|
|
31
|
-
message:
|
|
31
|
+
message: text(frontendLangKeys.requiredInput, { label: text(fieldInfo.label) })
|
|
32
32
|
}] : [], { validator: createAjvValidator(fieldInfo, { required: schema.required?.includes(key) }) }],
|
|
33
33
|
fieldProps: {
|
|
34
34
|
...fieldProps,
|
|
@@ -48,6 +48,7 @@ var generateDefaultValue = (schema, data) => {
|
|
|
48
48
|
return defaultValue;
|
|
49
49
|
};
|
|
50
50
|
var PopForm = memo((props) => {
|
|
51
|
+
const text = useText();
|
|
51
52
|
const [open, setOpen] = useState(true);
|
|
52
53
|
const [submitting, setSubmitting] = useState(false);
|
|
53
54
|
const { schema, config, api } = useComConfig({ comName: props.comName });
|
|
@@ -64,8 +65,8 @@ var PopForm = memo((props) => {
|
|
|
64
65
|
*
|
|
65
66
|
*/
|
|
66
67
|
const schemas = useMemo(() => {
|
|
67
|
-
return generateSchemas(schema);
|
|
68
|
-
}, [schema]);
|
|
68
|
+
return generateSchemas(schema, text);
|
|
69
|
+
}, [schema, text]);
|
|
69
70
|
const closed = submitting ? void 0 : () => {
|
|
70
71
|
schemaEventBus.getState().emitCom({ type: merge(eventsInfo.closeCom) });
|
|
71
72
|
setOpen(false);
|
|
@@ -98,7 +99,7 @@ var PopForm = memo((props) => {
|
|
|
98
99
|
return /* @__PURE__ */ jsx(Modal, {
|
|
99
100
|
open,
|
|
100
101
|
onClose: closed,
|
|
101
|
-
title:
|
|
102
|
+
title: text(config?.title ?? ""),
|
|
102
103
|
width: 640,
|
|
103
104
|
maskClosable: !submitting,
|
|
104
105
|
children: /* @__PURE__ */ jsx(SchemaForm, {
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { getText } from "../../../../common/language.js";
|
|
2
1
|
import TableSearch from "../../../../../../packages/react/ui/components/TableSearch/TableSearch.js";
|
|
3
2
|
import "../../../../../../packages/react/ui/components/index.js";
|
|
4
|
-
import
|
|
3
|
+
import { useText } from "../../../../hooks/useText.js";
|
|
5
4
|
import { schemaEventBus } from "../../../../stores/schemaEventBus.js";
|
|
6
5
|
import { filterEmpty } from "../../../../../../packages/common/object/filterEmpty.js";
|
|
7
6
|
import { useSchemaStore } from "../../../../stores/schemaStore.js";
|
|
8
|
-
import { memo,
|
|
7
|
+
import { memo, useMemo } from "react";
|
|
9
8
|
import { jsx } from "react/jsx-runtime";
|
|
10
9
|
//#region frontend/src/defaultPages/SchemaPage/components/SchemaSearch/index.tsx
|
|
11
|
-
var generateSchemas = (config) => {
|
|
10
|
+
var generateSchemas = (config, text) => {
|
|
12
11
|
const keys = Object.keys(config);
|
|
13
12
|
const schemas = [];
|
|
14
13
|
let defaultValue = void 0;
|
|
@@ -21,7 +20,7 @@ var generateSchemas = (config) => {
|
|
|
21
20
|
defaultValue[k] = defaultFieldValue;
|
|
22
21
|
}
|
|
23
22
|
schemas.push({
|
|
24
|
-
label:
|
|
23
|
+
label: text(fieldInfo.label),
|
|
25
24
|
key: k,
|
|
26
25
|
type: comType,
|
|
27
26
|
fieldProps
|
|
@@ -34,27 +33,24 @@ var generateSchemas = (config) => {
|
|
|
34
33
|
};
|
|
35
34
|
};
|
|
36
35
|
var SchemaSearch = memo(() => {
|
|
36
|
+
const text = useText();
|
|
37
37
|
const schema = useSchemaStore((s) => s.searchSchema);
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
const { schemas, defaultValue } = useMemo(() => generateSchemas(schema.properties, text), [schema, text]);
|
|
39
|
+
const tsProps = {
|
|
40
|
+
schemas,
|
|
41
|
+
defaultValue,
|
|
42
|
+
onSearch(values) {
|
|
43
|
+
schemaEventBus.getState().emitSearch(filterEmpty(values));
|
|
44
|
+
},
|
|
45
|
+
onReset() {
|
|
46
|
+
schemaEventBus.getState().emitSearch(void 0);
|
|
47
|
+
},
|
|
48
|
+
renderActionBtnArea: () => {}
|
|
49
|
+
};
|
|
45
50
|
return /* @__PURE__ */ jsx("div", {
|
|
46
|
-
className: "schema-search",
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
defaultValue,
|
|
50
|
-
onSearch(values) {
|
|
51
|
-
schemaEventBus.getState().emitSearch(filterEmpty(values));
|
|
52
|
-
},
|
|
53
|
-
onReset() {
|
|
54
|
-
schemaEventBus.getState().emitSearch(void 0);
|
|
55
|
-
},
|
|
56
|
-
renderActionBtnArea: () => {}
|
|
57
|
-
})
|
|
51
|
+
className: "schema-search pb-2",
|
|
52
|
+
style: { display: schemas.length ? "block" : "none" },
|
|
53
|
+
children: /* @__PURE__ */ jsx(TableSearch, { ...tsProps })
|
|
58
54
|
});
|
|
59
55
|
});
|
|
60
56
|
SchemaSearch.displayName = "SchemaSearch";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PreviewImageProps as BasePreviewImageProps } from "../../../../../../packages/react/ui/index";
|
|
2
|
+
export type SchemaTablePreviewImageProps = Omit<BasePreviewImageProps, 'images'> & {
|
|
3
|
+
value?: unknown;
|
|
4
|
+
record?: Record<string, unknown>;
|
|
5
|
+
rowIndex?: number;
|
|
6
|
+
fieldKey?: string;
|
|
7
|
+
images?: BasePreviewImageProps['images'];
|
|
8
|
+
valueToImages?: (value: unknown, record?: Record<string, unknown>, rowIndex?: number, fieldKey?: string) => BasePreviewImageProps['images'];
|
|
9
|
+
};
|
|
10
|
+
export declare function PreviewImage({ value, record, rowIndex, fieldKey, images, valueToImages: customValueToImages, ...props }: SchemaTablePreviewImageProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PreviewImage as PreviewImage$1 } from "../../../../../../packages/react/ui/components/ImagePreview/PreviewImage.js";
|
|
2
|
+
import "../../../../../../packages/react/ui/index.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region frontend/src/defaultPages/SchemaPage/components/SchemaTable/PreviewImage.tsx
|
|
5
|
+
var valueToImages = (value) => {
|
|
6
|
+
if (Array.isArray(value)) return value;
|
|
7
|
+
if (value === void 0 || value === null || value === "") return [];
|
|
8
|
+
return [value];
|
|
9
|
+
};
|
|
10
|
+
function PreviewImage({ value, record, rowIndex, fieldKey, images, valueToImages: customValueToImages, ...props }) {
|
|
11
|
+
return /* @__PURE__ */ jsx(PreviewImage$1, {
|
|
12
|
+
...props,
|
|
13
|
+
images: images ?? (customValueToImages ?? valueToImages)(value, record, rowIndex, fieldKey)
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { PreviewImage };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SchemaTableRenderComponentPropsMap } from "../../../../../../model/types/data/schema";
|
|
2
|
+
import type { ComponentType, LazyExoticComponent } from "react";
|
|
3
|
+
export type SchemaTableRenderComponent = ComponentType<any> | LazyExoticComponent<ComponentType<any>>;
|
|
4
|
+
export type SchemaTableRenderComponentsMap = Partial<Record<Extract<keyof SchemaTableRenderComponentPropsMap, string>, SchemaTableRenderComponent>>;
|
|
5
|
+
export declare const schemaTableRenderComponentMap: SchemaTableRenderComponentsMap;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PreviewImage } from "./PreviewImage.js";
|
|
2
|
+
import consumerRenderComponentMap from "@tc/scalability/SchemaPage/SchemaTable/data";
|
|
3
|
+
var schemaTableRenderComponentMap = {
|
|
4
|
+
PreviewImage,
|
|
5
|
+
...consumerRenderComponentMap
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { schemaTableRenderComponentMap };
|
|
@@ -1,42 +1,58 @@
|
|
|
1
1
|
import { frontendLangKeys } from "../../../../language/index.js";
|
|
2
|
-
import { getText } from "../../../../common/language.js";
|
|
3
2
|
import { Button } from "../../../../../../packages/react/ui/components/Button/Button.js";
|
|
4
3
|
import { modal } from "../../../../../../packages/react/ui/components/Modal/ModalManager.js";
|
|
5
4
|
import { DataTable } from "../../../../../../packages/react/ui/components/DataTable/index.js";
|
|
6
5
|
import "../../../../../../packages/react/ui/components/index.js";
|
|
7
6
|
import { del, get } from "../../../../common/request.js";
|
|
8
|
-
import
|
|
7
|
+
import { useText } from "../../../../hooks/useText.js";
|
|
9
8
|
import { schemaEventBus } from "../../../../stores/schemaEventBus.js";
|
|
10
9
|
import { useSchemaStore } from "../../../../stores/schemaStore.js";
|
|
11
10
|
import { handlingRequestErrors } from "../../../../common/fetchErrorShow.js";
|
|
12
11
|
import useExecuteOnce from "../../../../../../packages/react/hooks/useExecuteOnce.js";
|
|
13
12
|
import { eventsInfo } from "../../data/eventInfo.js";
|
|
14
13
|
import { merge } from "../../utils/permissions.js";
|
|
14
|
+
import { schemaTableRenderComponentMap } from "./data.js";
|
|
15
15
|
import useRefState from "../../../../../../packages/react/hooks/useRefState.js";
|
|
16
16
|
import useWatch from "../../../../../../packages/react/hooks/useWatch.js";
|
|
17
|
-
import { memo, useCallback, useImperativeHandle, useMemo, useState
|
|
17
|
+
import { Suspense, memo, useCallback, useImperativeHandle, useMemo, useState } from "react";
|
|
18
18
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
19
19
|
import { useShallow } from "zustand/react/shallow";
|
|
20
20
|
import { produce } from "immer";
|
|
21
21
|
//#region frontend/src/defaultPages/SchemaPage/components/SchemaTable/index.tsx
|
|
22
22
|
var VALUE_KEY = "$schema::";
|
|
23
|
-
var generateColumns = (config) => {
|
|
23
|
+
var generateColumns = (config, text) => {
|
|
24
24
|
const keys = Object.keys(config);
|
|
25
25
|
const columns = [];
|
|
26
26
|
keys.forEach((k) => {
|
|
27
27
|
const fieldInfo = config[k];
|
|
28
28
|
if (fieldInfo?.option) {
|
|
29
|
-
const { ...fieldProps } = fieldInfo.option;
|
|
29
|
+
const { render: customRender, renderComponent, renderComponentProps, ...fieldProps } = fieldInfo.option;
|
|
30
30
|
columns.push({
|
|
31
|
-
title:
|
|
31
|
+
title: text(fieldInfo.label),
|
|
32
32
|
key: k,
|
|
33
|
-
...fieldProps
|
|
33
|
+
...fieldProps,
|
|
34
|
+
render(v, d, index) {
|
|
35
|
+
if (renderComponent) {
|
|
36
|
+
const Component = schemaTableRenderComponentMap[renderComponent];
|
|
37
|
+
if (Component) return /* @__PURE__ */ jsx(Suspense, {
|
|
38
|
+
fallback: null,
|
|
39
|
+
children: /* @__PURE__ */ jsx(Component, {
|
|
40
|
+
...renderComponentProps,
|
|
41
|
+
value: v,
|
|
42
|
+
record: d,
|
|
43
|
+
rowIndex: index,
|
|
44
|
+
fieldKey: k
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return customRender ? customRender(v, d, index) : v;
|
|
49
|
+
}
|
|
34
50
|
});
|
|
35
51
|
}
|
|
36
52
|
});
|
|
37
53
|
return columns;
|
|
38
54
|
};
|
|
39
|
-
var generateRowActions = (btnConfigs, rowData, api) => {
|
|
55
|
+
var generateRowActions = (btnConfigs, rowData, text, api) => {
|
|
40
56
|
const handleRowAction = (btnConfig) => {
|
|
41
57
|
const { eventKey, eventOption } = btnConfig;
|
|
42
58
|
switch (eventKey) {
|
|
@@ -50,12 +66,12 @@ var generateRowActions = (btnConfigs, rowData, api) => {
|
|
|
50
66
|
case "remove":
|
|
51
67
|
if (api) {
|
|
52
68
|
const apiParams = Object.entries(eventOption.params).reduce((o, [k, v]) => {
|
|
53
|
-
if (("" + v).
|
|
69
|
+
if (("" + v).indexOf(VALUE_KEY) === 0) o[k] = rowData[("" + v).split(VALUE_KEY)[1]];
|
|
54
70
|
else o[k] = v;
|
|
55
71
|
return o;
|
|
56
72
|
}, {});
|
|
57
73
|
modal.confirm({
|
|
58
|
-
content:
|
|
74
|
+
content: text(frontendLangKeys.confirmDelete),
|
|
59
75
|
async onOk() {
|
|
60
76
|
await handlingRequestErrors(del(api, apiParams));
|
|
61
77
|
schemaEventBus.getState().emitCom({ type: merge(eventsInfo.initTable) });
|
|
@@ -68,7 +84,7 @@ var generateRowActions = (btnConfigs, rowData, api) => {
|
|
|
68
84
|
}
|
|
69
85
|
};
|
|
70
86
|
return btnConfigs.map((rb, index) => {
|
|
71
|
-
const label =
|
|
87
|
+
const label = text(rb.label ?? "");
|
|
72
88
|
const bState = rb.eventKey === "remove" ? "danger" : void 0;
|
|
73
89
|
return { render: (_item, { close }) => /* @__PURE__ */ jsx("div", {
|
|
74
90
|
className: " p-2.5",
|
|
@@ -85,26 +101,22 @@ var generateRowActions = (btnConfigs, rowData, api) => {
|
|
|
85
101
|
});
|
|
86
102
|
};
|
|
87
103
|
var SchemaTable = memo(({ ref }) => {
|
|
104
|
+
const text = useText();
|
|
88
105
|
const params = useSchemaStore(useShallow((s) => ({
|
|
89
106
|
config: s.tableConfig,
|
|
90
107
|
schema: s.tableSchema,
|
|
91
108
|
api: s.api
|
|
92
109
|
})));
|
|
93
110
|
const [data, uData] = useState([]);
|
|
94
|
-
const [
|
|
95
|
-
const [loading, uLoading, loadingRef] = useRefState(false);
|
|
111
|
+
const [loading, uLoading, loadingRef] = useRefState(false, 25);
|
|
96
112
|
const [pagination, setPagination, paginationRef] = useRefState({
|
|
97
113
|
current: 1,
|
|
98
114
|
pageSize: 10,
|
|
99
115
|
total: 0
|
|
100
116
|
});
|
|
101
|
-
const [lazyLoading, startTransition] = useTransition();
|
|
102
|
-
const [handleBtn, setHandleBtn] = useState([]);
|
|
103
117
|
const init = useCallback(async (query) => {
|
|
104
118
|
if (loadingRef.current.data) return;
|
|
105
|
-
|
|
106
|
-
uLoading(true);
|
|
107
|
-
});
|
|
119
|
+
uLoading(true);
|
|
108
120
|
try {
|
|
109
121
|
const res = await handlingRequestErrors(get(params.api ? `${params.api}/list` : "", {
|
|
110
122
|
...query,
|
|
@@ -117,9 +129,7 @@ var SchemaTable = memo(({ ref }) => {
|
|
|
117
129
|
}));
|
|
118
130
|
}
|
|
119
131
|
} finally {
|
|
120
|
-
|
|
121
|
-
uLoading(false);
|
|
122
|
-
});
|
|
132
|
+
uLoading(false);
|
|
123
133
|
}
|
|
124
134
|
}, [
|
|
125
135
|
loadingRef,
|
|
@@ -131,29 +141,38 @@ var SchemaTable = memo(({ ref }) => {
|
|
|
131
141
|
useImperativeHandle(ref, () => {
|
|
132
142
|
return { initData: init };
|
|
133
143
|
}, [init]);
|
|
134
|
-
|
|
135
|
-
const contextColumns = generateColumns(params.schema.properties);
|
|
144
|
+
const { columns, handleBtn } = useMemo(() => {
|
|
145
|
+
const contextColumns = generateColumns(params.schema.properties, text);
|
|
136
146
|
const actionColumn = [];
|
|
147
|
+
let handleBtn = [];
|
|
137
148
|
if (params.config) {
|
|
138
149
|
const { rowButtons, headerButtons } = params.config;
|
|
139
150
|
if (rowButtons) actionColumn.push({
|
|
140
151
|
key: "action",
|
|
141
|
-
title:
|
|
142
|
-
actions: (_value, _record, index) => [...generateRowActions(rowButtons, _record, params.api)]
|
|
152
|
+
title: text(frontendLangKeys.operation),
|
|
153
|
+
actions: (_value, _record, index) => [...generateRowActions(rowButtons, _record, text, params.api)]
|
|
143
154
|
});
|
|
144
|
-
|
|
155
|
+
handleBtn = headerButtons?.map((c) => {
|
|
145
156
|
const { label, eventKey, eventOption, ...props } = c;
|
|
146
157
|
return {
|
|
147
|
-
children:
|
|
158
|
+
children: text(label ?? ""),
|
|
148
159
|
onClick: () => {
|
|
149
160
|
if ("comName" in eventOption) schemaEventBus.getState().emitTable(eventOption);
|
|
150
161
|
},
|
|
151
162
|
...props
|
|
152
163
|
};
|
|
153
|
-
}) ?? []
|
|
164
|
+
}) ?? [];
|
|
154
165
|
}
|
|
155
|
-
|
|
156
|
-
|
|
166
|
+
return {
|
|
167
|
+
columns: contextColumns.concat(actionColumn),
|
|
168
|
+
handleBtn
|
|
169
|
+
};
|
|
170
|
+
}, [
|
|
171
|
+
params.api,
|
|
172
|
+
params.config,
|
|
173
|
+
params.schema,
|
|
174
|
+
text
|
|
175
|
+
]);
|
|
157
176
|
useExecuteOnce(() => {
|
|
158
177
|
init();
|
|
159
178
|
}, { executionPhase: "mount" });
|
|
@@ -161,7 +180,7 @@ var SchemaTable = memo(({ ref }) => {
|
|
|
161
180
|
return {
|
|
162
181
|
columns,
|
|
163
182
|
data,
|
|
164
|
-
loading
|
|
183
|
+
loading,
|
|
165
184
|
pagination: {
|
|
166
185
|
...pagination,
|
|
167
186
|
onPageSizeChange(pageSize) {
|
|
@@ -180,7 +199,6 @@ var SchemaTable = memo(({ ref }) => {
|
|
|
180
199
|
columns,
|
|
181
200
|
data,
|
|
182
201
|
loading,
|
|
183
|
-
lazyLoading,
|
|
184
202
|
pagination,
|
|
185
203
|
setPagination
|
|
186
204
|
]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./index.css";
|
|
2
2
|
import { frontendLangKeys } from "../../language/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { useText } from "../../hooks/useText.js";
|
|
4
4
|
import useInit from "../../../../packages/react/hooks/useInit.js";
|
|
5
5
|
import { logIllegalComponentCallback } from "../../common/logFn/index.js";
|
|
6
6
|
import { schemaEventBus } from "../../stores/schemaEventBus.js";
|
|
@@ -19,6 +19,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
19
19
|
//#region frontend/src/defaultPages/SchemaPage/index.tsx
|
|
20
20
|
var Schema = memo(() => {
|
|
21
21
|
const { menu } = useCurrentMenuData();
|
|
22
|
+
const text = useText();
|
|
22
23
|
const [showCompoentKey, setShowCompoentKey] = useState();
|
|
23
24
|
const [comProps, setComProps] = useState({});
|
|
24
25
|
const schemaStoreAvailable = useSchemaStore((s) => s.schemaStoreAvailable);
|
|
@@ -77,12 +78,13 @@ var Schema = memo(() => {
|
|
|
77
78
|
});
|
|
78
79
|
} else return /* @__PURE__ */ jsx("div", {
|
|
79
80
|
className: "flex h-full items-center justify-center text-sm text-muted-foreground",
|
|
80
|
-
children:
|
|
81
|
+
children: text(frontendLangKeys.loading)
|
|
81
82
|
});
|
|
82
83
|
}, [
|
|
83
84
|
comProps,
|
|
84
85
|
schemaStoreAvailable,
|
|
85
|
-
showCompoentKey
|
|
86
|
+
showCompoentKey,
|
|
87
|
+
text
|
|
86
88
|
]);
|
|
87
89
|
});
|
|
88
90
|
Schema.displayName = "SchemaPage";
|
|
@@ -4,18 +4,21 @@ import Iframe from "../Iframe/index.js";
|
|
|
4
4
|
import NotFoundPage from "../NotFoundPage/index.js";
|
|
5
5
|
import Schema from "../SchemaPage/index.js";
|
|
6
6
|
import { memo, useMemo } from "react";
|
|
7
|
+
import { useParams } from "react-router-dom";
|
|
7
8
|
import { jsx } from "react/jsx-runtime";
|
|
8
9
|
//#region frontend/src/defaultPages/SlotPage/index.tsx
|
|
9
10
|
var SlotPage = memo(() => {
|
|
10
11
|
const { menu } = useCurrentMenuData(true);
|
|
12
|
+
const params = useParams();
|
|
13
|
+
const sidek = params.sidek;
|
|
11
14
|
return useMemo(() => {
|
|
12
|
-
if (menu?.moduleType === "iframe") return /* @__PURE__ */ jsx(Iframe, {});
|
|
13
|
-
else if (menu?.moduleType === "schema") return /* @__PURE__ */ jsx(Schema, {});
|
|
15
|
+
if (menu?.moduleType === "iframe") return /* @__PURE__ */ jsx(Iframe, {}, sidek);
|
|
16
|
+
else if (menu?.moduleType === "schema") return /* @__PURE__ */ jsx(Schema, {}, sidek);
|
|
14
17
|
else {
|
|
15
18
|
logPageNotFound();
|
|
16
19
|
return /* @__PURE__ */ jsx(NotFoundPage, {});
|
|
17
20
|
}
|
|
18
|
-
}, [menu?.moduleType]);
|
|
21
|
+
}, [menu?.moduleType, params.sidek]);
|
|
19
22
|
});
|
|
20
23
|
SlotPage.displayName = "SlotPage";
|
|
21
24
|
//#endregion
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { I18nInterpolationValues, I18nTranslateOptions } from "../../../packages/react/ui/i18n/index";
|
|
2
|
+
export type TextTranslator = <T = string>(key: string, fillingData?: I18nInterpolationValues, options?: I18nTranslateOptions) => T | string;
|
|
3
|
+
export declare const useText: () => TextTranslator;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { i18nKeyPrefix } from "../language/index.js";
|
|
2
|
+
import { useI18n } from "../../../packages/react/ui/i18n/useI18n.js";
|
|
3
|
+
import "../../../packages/react/ui/i18n/index.js";
|
|
4
|
+
import { useCallback } from "react";
|
|
5
|
+
//#region frontend/src/hooks/useText.ts
|
|
6
|
+
var useText = () => {
|
|
7
|
+
const translate = useI18n();
|
|
8
|
+
return useCallback((key, fillingData, options) => {
|
|
9
|
+
if (key.startsWith("$i18n::")) return translate(key.slice(i18nKeyPrefix.length), fillingData, options);
|
|
10
|
+
return translate(key, fillingData, options);
|
|
11
|
+
}, [translate]);
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { useText };
|
|
@@ -2,12 +2,20 @@ import "./typing/scalability";
|
|
|
2
2
|
export type * from "../apps/dash/types";
|
|
3
3
|
export * from "./main";
|
|
4
4
|
export type { CallComComponentsMap, CallComRenderer } from "./defaultPages/SchemaPage/schemaType";
|
|
5
|
+
export type { SchemaTableRenderComponent, SchemaTableRenderComponentsMap, } from "./defaultPages/SchemaPage/components/SchemaTable/data";
|
|
5
6
|
export * from "./components/index";
|
|
6
7
|
export type { FormFieldSchema, SchemaFormComponentsMap, SchemaFormNamespace, SelectProps } from "../../packages/react/ui/index";
|
|
7
|
-
export {
|
|
8
|
-
export
|
|
8
|
+
export { renderImportComponent } from "./common/importComponent";
|
|
9
|
+
export { clearRafTimer, rafClearInterval, rafClearTimeout, rafSetInterval, rafSetTimeout } from "../../packages/common/rafTimer";
|
|
10
|
+
export type { RafTimerCallback, RafTimerId } from "../../packages/common/rafTimer";
|
|
11
|
+
export { api, del, FetchAxios, get, patch, post, put, request } from "./common/request";
|
|
12
|
+
export type { AxiosError, BaseResponse, PageParams, PageResponse, RequestConfig, ResponseConfig, } from "./common/request";
|
|
13
|
+
export { applyThemeMode, getCurrentThemeMode, getStoredThemeMode, initThemeMode, persistThemeMode, themeSwitchStorageKey, } from "./common/theme";
|
|
14
|
+
export type { ThemeSwitchMode } from "./common/theme";
|
|
15
|
+
export { clearAuthToken, getAuthToken, localKeyMap, setAuthToken } from "./common/auth/index";
|
|
16
|
+
export * from "./common/language";
|
|
9
17
|
export * from "./defaultPages/SchemaPage/data/eventInfo";
|
|
10
18
|
export { merge } from "./defaultPages/SchemaPage/utils/permissions";
|
|
19
|
+
export { useText, type TextTranslator } from "./hooks/useText";
|
|
11
20
|
export * from "./exportStore";
|
|
12
21
|
export { i18n, i18nStore } from "../../packages/react/ui/i18n/index";
|
|
13
|
-
export { getAuthToken, localKeyMap, setAuthToken } from "./common/auth/index";
|
package/fe/frontend/src/index.js
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
import { getAuthToken, localKeyMap, setAuthToken } from "./common/auth/index.js";
|
|
1
|
+
import { clearAuthToken, getAuthToken, localKeyMap, setAuthToken } from "./common/auth/index.js";
|
|
2
2
|
import { i18n, i18nStore } from "../../packages/common/i18n/index.js";
|
|
3
3
|
import "../../packages/react/ui/i18n/index.js";
|
|
4
|
+
import { addLanguageResources, getCurrentLanguage, getFallbackLanguage, getI18nResources, getSupportedLanguages, getText, registerFrontendI18nResources, setFallbackLanguage, setLanguage, setResources, t } from "./common/language.js";
|
|
4
5
|
import { FreezeState, apiFreezerStore, useApiFreezer } from "./stores/apiFreezer.js";
|
|
6
|
+
import FetchAxios from "../../packages/common/http/index.js";
|
|
5
7
|
import { api, del, get, patch, post, put, request } from "./common/request.js";
|
|
6
8
|
import { modeStore, useModeStore } from "./stores/mode.js";
|
|
9
|
+
import { useText } from "./hooks/useText.js";
|
|
7
10
|
import HeaderView from "./components/BasePage/HeaderView.js";
|
|
11
|
+
import { renderImportComponent } from "./common/importComponent.js";
|
|
12
|
+
import { applyThemeMode, getCurrentThemeMode, getStoredThemeMode, initThemeMode, persistThemeMode, themeSwitchStorageKey } from "./common/theme.js";
|
|
8
13
|
import { generateRouter } from "./components/Router/index.js";
|
|
9
14
|
import { schemaEventBus } from "./stores/schemaEventBus.js";
|
|
15
|
+
import { clearRafTimer, rafClearInterval, rafClearTimeout, rafSetInterval, rafSetTimeout } from "../../packages/common/rafTimer.js";
|
|
10
16
|
import { schemaStore, useSchemaStore } from "./stores/schemaStore.js";
|
|
11
17
|
import "./exportStore.js";
|
|
12
18
|
import { initApp } from "./main.js";
|
|
13
19
|
import AsyncSelect_default from "./components/AsyncSelect/index.js";
|
|
14
20
|
import LanguageSwitch_default from "./components/LanguageSwitch/index.js";
|
|
15
|
-
import { themeSwitchStorageKey } from "./components/ThemeSwitch/ThemeSwitch.js";
|
|
16
21
|
import ThemeSwitch_default from "./components/ThemeSwitch/index.js";
|
|
17
22
|
import "./components/index.js";
|
|
18
23
|
import { eventsInfo } from "./defaultPages/SchemaPage/data/eventInfo.js";
|
|
19
24
|
import { merge } from "./defaultPages/SchemaPage/utils/permissions.js";
|
|
20
|
-
export { AsyncSelect_default as AsyncSelect, FreezeState, HeaderView, LanguageSwitch_default as LanguageSwitch, ThemeSwitch_default as ThemeSwitch, api, apiFreezerStore, del, eventsInfo, generateRouter, get, getAuthToken, i18n, i18nStore, initApp, localKeyMap, merge, modeStore, patch, post, put, request, schemaEventBus, schemaStore, setAuthToken, themeSwitchStorageKey, useApiFreezer, useModeStore, useSchemaStore };
|
|
25
|
+
export { AsyncSelect_default as AsyncSelect, FetchAxios, FreezeState, HeaderView, LanguageSwitch_default as LanguageSwitch, ThemeSwitch_default as ThemeSwitch, addLanguageResources, api, apiFreezerStore, applyThemeMode, clearAuthToken, clearRafTimer, del, eventsInfo, generateRouter, get, getAuthToken, getCurrentLanguage, getCurrentThemeMode, getFallbackLanguage, getI18nResources, getStoredThemeMode, getSupportedLanguages, getText, i18n, i18nStore, initApp, initThemeMode, localKeyMap, merge, modeStore, patch, persistThemeMode, post, put, rafClearInterval, rafClearTimeout, rafSetInterval, rafSetTimeout, registerFrontendI18nResources, renderImportComponent, request, schemaEventBus, schemaStore, setAuthToken, setFallbackLanguage, setLanguage, setResources, t, themeSwitchStorageKey, useApiFreezer, useModeStore, useSchemaStore, useText };
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { I18nResources } from "../../../packages/react/ui/i18n/index";
|
|
2
1
|
export declare const i18nKeyPrefix = "$i18n::";
|
|
3
|
-
export declare const frontendI18nResources: I18nResources;
|
|
4
2
|
export declare const withI18nKey: (key: string) => string;
|
|
5
3
|
export declare const frontendLangKeys: {
|
|
6
4
|
readonly appTitle: string;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import { frontendEnUSResources } from "./en-US.js";
|
|
2
|
-
import { frontendZhCNResources } from "./zh-CN.js";
|
|
3
1
|
//#region frontend/src/language/index.ts
|
|
4
2
|
var i18nKeyPrefix = "$i18n::";
|
|
5
|
-
var frontendI18nResources = {
|
|
6
|
-
"zh-CN": frontendZhCNResources,
|
|
7
|
-
"en-US": frontendEnUSResources
|
|
8
|
-
};
|
|
9
3
|
var withI18nKey = (key) => `${i18nKeyPrefix}${key}`;
|
|
10
4
|
var frontendLangKeys = {
|
|
11
5
|
appTitle: withI18nKey("frontend.app.title"),
|
|
@@ -76,4 +70,4 @@ var frontendLangKeys = {
|
|
|
76
70
|
logApiTamperEn: withI18nKey("frontend.log.apiTamperEn")
|
|
77
71
|
};
|
|
78
72
|
//#endregion
|
|
79
|
-
export {
|
|
73
|
+
export { frontendLangKeys, i18nKeyPrefix, withI18nKey };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { frontendEnUSResources } from "./en-US.js";
|
|
2
|
+
import { frontendZhCNResources } from "./zh-CN.js";
|
|
3
|
+
//#region frontend/src/language/resources.ts
|
|
4
|
+
var frontendI18nResources = {
|
|
5
|
+
"zh-CN": frontendZhCNResources,
|
|
6
|
+
"en-US": frontendEnUSResources
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { frontendI18nResources };
|