@pisell/materials 1.0.499 → 1.0.501
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +5 -5
- package/build/lowcode/preview.js +7 -7
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +14 -14
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +14 -14
- package/es/components/dataSourceComponents/dataSourceForm/utils.js +2 -6
- package/es/components/dataSourceComponents/dataSourceTable/filter/utils.js +2 -1
- package/es/components/dataSourceComponents/fields/Input.Phone/WithMode.js +2 -6
- package/es/components/dataSourceComponents/fields/Translation/BaseTranslation.d.ts +5 -0
- package/es/components/dataSourceComponents/fields/Translation/BaseTranslation.js +108 -0
- package/es/components/dataSourceComponents/fields/Translation/ReadPretty.d.ts +5 -0
- package/es/components/dataSourceComponents/fields/Translation/ReadPretty.js +13 -0
- package/es/components/dataSourceComponents/fields/Translation/ReadPretty.less +11 -0
- package/es/components/dataSourceComponents/fields/Translation/WithMode.d.ts +4 -0
- package/es/components/dataSourceComponents/fields/Translation/WithMode.js +5 -0
- package/es/components/dataSourceComponents/fields/Translation/index.d.ts +3 -0
- package/es/components/dataSourceComponents/fields/Translation/index.js +4 -0
- package/es/components/dataSourceComponents/fields/Translation/index.less +58 -0
- package/es/components/dataSourceComponents/fields/Translation/type.d.ts +15 -0
- package/es/components/dataSourceComponents/fields/Translation/type.js +1 -0
- package/es/components/dataSourceComponents/fields/Upload/BaseUpload.js +142 -39
- package/es/components/dataSourceComponents/fields/Upload/ReadPretty.d.ts +1 -1
- package/es/components/dataSourceComponents/fields/Upload/ReadPretty.js +35 -11
- package/es/components/dataSourceComponents/fields/Upload/index.less +7 -0
- package/es/components/dataSourceComponents/fields/Upload/utils.js +3 -0
- package/es/components/dataSourceComponents/fields/index.d.ts +2 -1
- package/es/components/dataSourceComponents/fields/index.js +3 -1
- package/es/hooks/useTranslationOriginal.d.ts +2 -0
- package/es/hooks/useTranslationOriginal.js +9 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/locales/en-US.d.ts +1 -0
- package/es/locales/en-US.js +7 -2
- package/es/locales/zh-CN.d.ts +1 -0
- package/es/locales/zh-CN.js +2 -1
- package/es/locales/zh-TW.d.ts +1 -0
- package/es/locales/zh-TW.js +2 -1
- package/lib/components/dataSourceComponents/dataSourceForm/utils.js +2 -4
- package/lib/components/dataSourceComponents/dataSourceTable/filter/utils.js +2 -1
- package/lib/components/dataSourceComponents/fields/Input.Phone/WithMode.js +2 -4
- package/lib/components/dataSourceComponents/fields/Translation/BaseTranslation.d.ts +5 -0
- package/lib/components/dataSourceComponents/fields/Translation/BaseTranslation.js +112 -0
- package/lib/components/dataSourceComponents/fields/Translation/ReadPretty.d.ts +5 -0
- package/lib/components/dataSourceComponents/fields/Translation/ReadPretty.js +50 -0
- package/lib/components/dataSourceComponents/fields/Translation/ReadPretty.less +11 -0
- package/lib/components/dataSourceComponents/fields/Translation/WithMode.d.ts +4 -0
- package/lib/components/dataSourceComponents/fields/Translation/WithMode.js +39 -0
- package/lib/components/dataSourceComponents/fields/Translation/index.d.ts +3 -0
- package/lib/components/dataSourceComponents/fields/Translation/index.js +38 -0
- package/lib/components/dataSourceComponents/fields/Translation/index.less +58 -0
- package/lib/components/dataSourceComponents/fields/Translation/type.d.ts +15 -0
- package/lib/components/dataSourceComponents/fields/Translation/type.js +17 -0
- package/lib/components/dataSourceComponents/fields/Upload/BaseUpload.js +67 -2
- package/lib/components/dataSourceComponents/fields/Upload/ReadPretty.d.ts +1 -1
- package/lib/components/dataSourceComponents/fields/Upload/ReadPretty.js +24 -4
- package/lib/components/dataSourceComponents/fields/Upload/index.less +7 -0
- package/lib/components/dataSourceComponents/fields/Upload/utils.js +2 -0
- package/lib/components/dataSourceComponents/fields/index.d.ts +2 -1
- package/lib/components/dataSourceComponents/fields/index.js +3 -1
- package/lib/hooks/useTranslationOriginal.d.ts +2 -0
- package/lib/hooks/useTranslationOriginal.js +41 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -0
- package/lib/locales/en-US.d.ts +1 -0
- package/lib/locales/en-US.js +3 -1
- package/lib/locales/zh-CN.d.ts +1 -0
- package/lib/locales/zh-CN.js +2 -1
- package/lib/locales/zh-TW.d.ts +1 -0
- package/lib/locales/zh-TW.js +2 -1
- package/lowcode/data-source-form/constants.ts +1 -0
- package/lowcode/data-source-form/utils.ts +12 -1
- package/lowcode/form-item-translation/meta.ts +249 -0
- package/lowcode/form-item-translation/snippets.ts +13 -0
- package/package.json +1 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/dataSourceComponents/fields/Translation/BaseTranslation.tsx
|
|
30
|
+
var BaseTranslation_exports = {};
|
|
31
|
+
__export(BaseTranslation_exports, {
|
|
32
|
+
default: () => BaseTranslation_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(BaseTranslation_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_antd = require("antd");
|
|
37
|
+
var import_icons = require("@ant-design/icons");
|
|
38
|
+
var import_locales = require("../../../../locales");
|
|
39
|
+
var import_index = require("./index.less");
|
|
40
|
+
var defaultValue = {
|
|
41
|
+
en: "",
|
|
42
|
+
"zh-CN": "",
|
|
43
|
+
"zh-HK": "",
|
|
44
|
+
original: ""
|
|
45
|
+
};
|
|
46
|
+
var languageConfig = [
|
|
47
|
+
{ key: "original", label: (0, import_locales.getText)("pisell-translation-original") },
|
|
48
|
+
{ key: "en", label: "English" },
|
|
49
|
+
{ key: "zh-CN", label: "简体中文" },
|
|
50
|
+
{ key: "zh-HK", label: "繁體中文" }
|
|
51
|
+
];
|
|
52
|
+
var Translation = ({
|
|
53
|
+
value = defaultValue,
|
|
54
|
+
onChange,
|
|
55
|
+
placeholder,
|
|
56
|
+
disabled
|
|
57
|
+
}) => {
|
|
58
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
59
|
+
const hasAnyTranslation = (0, import_react.useCallback)(() => {
|
|
60
|
+
return Object.entries(value).some(([key, val]) => val);
|
|
61
|
+
}, [value]);
|
|
62
|
+
const handleInputChange = (0, import_react.useCallback)(
|
|
63
|
+
(lang) => (e) => {
|
|
64
|
+
const newValue = {
|
|
65
|
+
...value,
|
|
66
|
+
[lang]: e.target.value
|
|
67
|
+
};
|
|
68
|
+
onChange == null ? void 0 : onChange(newValue);
|
|
69
|
+
},
|
|
70
|
+
[value, onChange]
|
|
71
|
+
);
|
|
72
|
+
const content = /* @__PURE__ */ import_react.default.createElement("div", { className: "translation-popover" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Space, { direction: "vertical", style: { width: "100%" }, size: 16 }, languageConfig.map(({ key, label }) => /* @__PURE__ */ import_react.default.createElement("div", { key, className: "translation-field" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "translation-label" }, label), /* @__PURE__ */ import_react.default.createElement(
|
|
73
|
+
import_antd.Input,
|
|
74
|
+
{
|
|
75
|
+
value: value[key],
|
|
76
|
+
onChange: handleInputChange(key),
|
|
77
|
+
allowClear: true
|
|
78
|
+
}
|
|
79
|
+
)))));
|
|
80
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { className: "translation-wrapper" }, /* @__PURE__ */ import_react.default.createElement(
|
|
81
|
+
import_antd.Input,
|
|
82
|
+
{
|
|
83
|
+
value: value.original,
|
|
84
|
+
onChange: handleInputChange("original"),
|
|
85
|
+
placeholder,
|
|
86
|
+
disabled,
|
|
87
|
+
className: "translation-input"
|
|
88
|
+
}
|
|
89
|
+
), /* @__PURE__ */ import_react.default.createElement(
|
|
90
|
+
import_antd.Popover,
|
|
91
|
+
{
|
|
92
|
+
content,
|
|
93
|
+
trigger: "click",
|
|
94
|
+
open,
|
|
95
|
+
onOpenChange: (open2) => {
|
|
96
|
+
if (disabled) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
setOpen(open2);
|
|
100
|
+
},
|
|
101
|
+
placement: "bottomRight"
|
|
102
|
+
},
|
|
103
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
104
|
+
"div",
|
|
105
|
+
{
|
|
106
|
+
className: `translation-icon-wrapper ${hasAnyTranslation() ? "has-translation" : ""} ${disabled ? "disabled" : ""}`
|
|
107
|
+
},
|
|
108
|
+
/* @__PURE__ */ import_react.default.createElement(import_icons.GlobalOutlined, { className: "translation-icon" })
|
|
109
|
+
)
|
|
110
|
+
));
|
|
111
|
+
};
|
|
112
|
+
var BaseTranslation_default = Translation;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/dataSourceComponents/fields/Translation/ReadPretty.tsx
|
|
30
|
+
var ReadPretty_exports = {};
|
|
31
|
+
__export(ReadPretty_exports, {
|
|
32
|
+
default: () => ReadPretty_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(ReadPretty_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_classnames = __toESM(require("classnames"));
|
|
37
|
+
var import_ReadPretty = require("./ReadPretty.less");
|
|
38
|
+
var TranslationReadPretty = (props) => {
|
|
39
|
+
const { value, renderMode } = props;
|
|
40
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
41
|
+
"span",
|
|
42
|
+
{
|
|
43
|
+
className: (0, import_classnames.default)("pisell-translation-read-pretty", {
|
|
44
|
+
"pisell-translation-read-pretty-table-view": renderMode === "tableView"
|
|
45
|
+
})
|
|
46
|
+
},
|
|
47
|
+
(value == null ? void 0 : value.original) || ""
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
var ReadPretty_default = TranslationReadPretty;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/dataSourceComponents/fields/Translation/WithMode.ts
|
|
30
|
+
var WithMode_exports = {};
|
|
31
|
+
__export(WithMode_exports, {
|
|
32
|
+
default: () => WithMode_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(WithMode_exports);
|
|
35
|
+
var import_ReadPretty = __toESM(require("./ReadPretty"));
|
|
36
|
+
var import_utils = require("../../dataSourceForm/utils");
|
|
37
|
+
var import_BaseTranslation = __toESM(require("./BaseTranslation"));
|
|
38
|
+
var TranslationWithMode = (0, import_utils.withMode)(import_BaseTranslation.default, import_ReadPretty.default);
|
|
39
|
+
var WithMode_default = TranslationWithMode;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/dataSourceComponents/fields/Translation/index.tsx
|
|
30
|
+
var Translation_exports = {};
|
|
31
|
+
__export(Translation_exports, {
|
|
32
|
+
default: () => Translation_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(Translation_exports);
|
|
35
|
+
var import_utils = require("../../dataSourceForm/utils");
|
|
36
|
+
var import_WithMode = __toESM(require("./WithMode"));
|
|
37
|
+
var Translation = (0, import_utils.withFormItem)(import_WithMode.default);
|
|
38
|
+
var Translation_default = Translation;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
.translation-wrapper {
|
|
2
|
+
position: relative;
|
|
3
|
+
|
|
4
|
+
.translation-input {
|
|
5
|
+
padding-right: 40px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.translation-icon-wrapper {
|
|
9
|
+
position: absolute;
|
|
10
|
+
right: 0;
|
|
11
|
+
top: 0;
|
|
12
|
+
height: 100%;
|
|
13
|
+
padding: 0 13px;
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
border-radius: 0 6px 6px 0;
|
|
17
|
+
transition: all 0.3s;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
.translation-icon {
|
|
20
|
+
color: #d9d9d9;
|
|
21
|
+
transition: all 0.3s;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&.has-translation {
|
|
25
|
+
background-color: var(--theme-color, #7F56D9);
|
|
26
|
+
transition: all 0.3s;
|
|
27
|
+
.translation-icon {
|
|
28
|
+
transition: all 0.3s;
|
|
29
|
+
color: #fff;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&:hover {
|
|
34
|
+
.translation-icon {
|
|
35
|
+
color: #a481e6;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&.disabled {
|
|
40
|
+
cursor: not-allowed;
|
|
41
|
+
|
|
42
|
+
.translation-icon {
|
|
43
|
+
color: #d9d9d9;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.translation-popover {
|
|
50
|
+
min-width: 300px;
|
|
51
|
+
padding: 8px;
|
|
52
|
+
|
|
53
|
+
.translation-field {
|
|
54
|
+
.translation-label {
|
|
55
|
+
margin-bottom: 8px;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ModeType } from "../../dataSourceForm/type";
|
|
2
|
+
export interface TranslationValue {
|
|
3
|
+
en: string;
|
|
4
|
+
'zh-CN': string;
|
|
5
|
+
'zh-HK': string;
|
|
6
|
+
original: string;
|
|
7
|
+
}
|
|
8
|
+
export interface TranslationProps {
|
|
9
|
+
renderMode: ModeType;
|
|
10
|
+
value?: TranslationValue;
|
|
11
|
+
onChange?: (value: TranslationValue) => void;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/components/dataSourceComponents/fields/Translation/type.ts
|
|
16
|
+
var type_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(type_exports);
|
|
@@ -45,6 +45,7 @@ var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContex
|
|
|
45
45
|
var import_locales = require("../../../../locales");
|
|
46
46
|
var import_constants = require("./constants");
|
|
47
47
|
var import_utils2 = require("./utils");
|
|
48
|
+
var import_fallback = __toESM(require("./fallback.png"));
|
|
48
49
|
var import_index = require("./index.less");
|
|
49
50
|
var BaseUpload = (props) => {
|
|
50
51
|
const {
|
|
@@ -69,14 +70,52 @@ var BaseUpload = (props) => {
|
|
|
69
70
|
const [previewOpen, setPreviewOpen] = (0, import_react.useState)(false);
|
|
70
71
|
const [open, setOpen] = (0, import_react.useState)(false);
|
|
71
72
|
const [editMultilingualFile, setEditMultilingualFile] = (0, import_react.useState)(null);
|
|
73
|
+
const [errorImageMap, setErrorImageMap] = (0, import_react.useState)({});
|
|
72
74
|
const { appHelper } = (0, import_useEngineContext.default)();
|
|
73
75
|
const { mediaUploadUrl, getHeaders } = appHelper == null ? void 0 : appHelper.constants;
|
|
76
|
+
const handleImageError = (0, import_react.useCallback)((file) => {
|
|
77
|
+
setErrorImageMap((prev) => ({
|
|
78
|
+
...prev,
|
|
79
|
+
[file.uid]: true
|
|
80
|
+
}));
|
|
81
|
+
}, []);
|
|
82
|
+
const checkImageUrl = (0, import_react.useCallback)((url) => {
|
|
83
|
+
return new Promise((resolve) => {
|
|
84
|
+
const img = document.createElement("img");
|
|
85
|
+
img.onload = () => resolve(true);
|
|
86
|
+
img.onerror = () => resolve(false);
|
|
87
|
+
img.src = url;
|
|
88
|
+
});
|
|
89
|
+
}, []);
|
|
90
|
+
const getItemUrl = (0, import_react.useCallback)(async (file) => {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
if (errorImageMap[file.uid]) {
|
|
93
|
+
return import_fallback.default;
|
|
94
|
+
}
|
|
95
|
+
const url = file.url || ((_b = (_a = file.response) == null ? void 0 : _a.data) == null ? void 0 : _b.url) || "";
|
|
96
|
+
if (!url)
|
|
97
|
+
return "";
|
|
98
|
+
try {
|
|
99
|
+
const isValid = await checkImageUrl(url);
|
|
100
|
+
if (!isValid) {
|
|
101
|
+
setErrorImageMap((prev) => ({
|
|
102
|
+
...prev,
|
|
103
|
+
[file.uid]: true
|
|
104
|
+
}));
|
|
105
|
+
return import_fallback.default;
|
|
106
|
+
}
|
|
107
|
+
return url;
|
|
108
|
+
} catch (error) {
|
|
109
|
+
return import_fallback.default;
|
|
110
|
+
}
|
|
111
|
+
}, [errorImageMap]);
|
|
74
112
|
(0, import_react.useEffect)(() => {
|
|
75
113
|
const fileList2 = (0, import_utils2.getDefaultFileList)(value, {
|
|
76
114
|
enableMultilingual: !!enableMultilingual,
|
|
77
115
|
multiple: !!multiple
|
|
78
116
|
});
|
|
79
117
|
setFileList(fileList2);
|
|
118
|
+
setErrorImageMap({});
|
|
80
119
|
}, [value, enableMultilingual, multiple]);
|
|
81
120
|
const calcMaxCount = (0, import_react.useMemo)(
|
|
82
121
|
() => multiple ? maxCount || import_constants.DEFAULT_MAX_COUNT : 1,
|
|
@@ -373,7 +412,32 @@ var BaseUpload = (props) => {
|
|
|
373
412
|
}),
|
|
374
413
|
headers: getHeaders == null ? void 0 : getHeaders(),
|
|
375
414
|
beforeUpload,
|
|
376
|
-
className: "pisell-data-source-upload"
|
|
415
|
+
className: "pisell-data-source-upload",
|
|
416
|
+
itemRender: (originNode, file) => {
|
|
417
|
+
const [itemUrl, setItemUrl] = (0, import_react.useState)("");
|
|
418
|
+
(0, import_react.useEffect)(() => {
|
|
419
|
+
getItemUrl(file).then(setItemUrl);
|
|
420
|
+
}, [file]);
|
|
421
|
+
const newNode = import_react.default.cloneElement(originNode, {
|
|
422
|
+
children: import_react.default.Children.map(originNode.props.children, (child) => {
|
|
423
|
+
if ((child == null ? void 0 : child.type) === "a") {
|
|
424
|
+
return import_react.default.cloneElement(child, {
|
|
425
|
+
children: import_react.default.Children.map(child.props.children, (grandChild) => {
|
|
426
|
+
if ((grandChild == null ? void 0 : grandChild.type) === "img") {
|
|
427
|
+
return import_react.default.cloneElement(grandChild, {
|
|
428
|
+
src: itemUrl,
|
|
429
|
+
onError: () => handleImageError(file)
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
return grandChild;
|
|
433
|
+
})
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
return child;
|
|
437
|
+
})
|
|
438
|
+
});
|
|
439
|
+
return newNode;
|
|
440
|
+
}
|
|
377
441
|
};
|
|
378
442
|
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_pisellUpload.default, { ...uploadProps, fileList }, fileList.length >= calcMaxCount ? null : renderUploadButton(!!enableMultilingual)), /* @__PURE__ */ import_react.default.createElement(
|
|
379
443
|
import_pisellModal.default,
|
|
@@ -413,7 +477,8 @@ var BaseUpload = (props) => {
|
|
|
413
477
|
onVisibleChange: (visible) => setPreviewOpen(visible),
|
|
414
478
|
afterOpenChange: (visible) => !visible && setPreviewImage("")
|
|
415
479
|
},
|
|
416
|
-
src: previewImage
|
|
480
|
+
src: previewImage,
|
|
481
|
+
fallback: import_fallback.default
|
|
417
482
|
}
|
|
418
483
|
));
|
|
419
484
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { UploadProps } from './type';
|
|
3
3
|
import './ReadPretty.less';
|
|
4
|
-
declare const UploadReadPretty: (props: UploadProps) => React.JSX.Element | null;
|
|
4
|
+
declare const UploadReadPretty: (props: UploadProps) => React.JSX.Element[] | null;
|
|
5
5
|
export default UploadReadPretty;
|
|
@@ -34,17 +34,37 @@ __export(ReadPretty_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(ReadPretty_exports);
|
|
35
35
|
var import_react = __toESM(require("react"));
|
|
36
36
|
var import_antd = require("antd");
|
|
37
|
+
var import_utils = require("@pisell/utils");
|
|
38
|
+
var import_useTranslationOriginal = __toESM(require("../../../../hooks/useTranslationOriginal"));
|
|
37
39
|
var import_fallback = __toESM(require("./fallback.png"));
|
|
38
40
|
var import_ReadPretty = require("./ReadPretty.less");
|
|
39
41
|
var UploadReadPretty = (props) => {
|
|
40
|
-
|
|
42
|
+
const { value, enableMultilingual } = props;
|
|
43
|
+
const translationOriginal = (0, import_useTranslationOriginal.default)();
|
|
44
|
+
const normalizedValue = (0, import_react.useMemo)(() => {
|
|
45
|
+
if (!value)
|
|
46
|
+
return [];
|
|
47
|
+
let processedValue = (0, import_utils.isArr)(value) ? value : [value];
|
|
48
|
+
processedValue = processedValue.map((item) => {
|
|
49
|
+
if (!item) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
if ((0, import_utils.isString)(item)) {
|
|
53
|
+
return item;
|
|
54
|
+
}
|
|
55
|
+
return translationOriginal(item);
|
|
56
|
+
});
|
|
57
|
+
return processedValue.filter((item) => !!item);
|
|
58
|
+
}, [value, enableMultilingual, translationOriginal]);
|
|
59
|
+
if (!normalizedValue.length) {
|
|
41
60
|
return null;
|
|
42
61
|
}
|
|
43
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
62
|
+
return normalizedValue.map((item, index) => /* @__PURE__ */ import_react.default.createElement(
|
|
44
63
|
import_antd.Image,
|
|
45
64
|
{
|
|
65
|
+
key: `${String(item)}-${index}`,
|
|
46
66
|
className: "pisell-upload-read-pretty",
|
|
47
|
-
src:
|
|
67
|
+
src: String(item),
|
|
48
68
|
width: 100,
|
|
49
69
|
height: 100,
|
|
50
70
|
fallback: import_fallback.default,
|
|
@@ -52,6 +72,6 @@ var UploadReadPretty = (props) => {
|
|
|
52
72
|
maskClassName: "pisell-upload-read-pretty-mask"
|
|
53
73
|
}
|
|
54
74
|
}
|
|
55
|
-
);
|
|
75
|
+
));
|
|
56
76
|
};
|
|
57
77
|
var ReadPretty_default = UploadReadPretty;
|
|
@@ -183,6 +183,8 @@ var handleMultilingualObject = (value, index = 1) => {
|
|
|
183
183
|
var getDefaultFileList = (value, options) => {
|
|
184
184
|
if (!value)
|
|
185
185
|
return [];
|
|
186
|
+
if (Object.values(value).filter((item) => !!item).length === 0)
|
|
187
|
+
return [];
|
|
186
188
|
const { enableMultilingual, multiple } = options;
|
|
187
189
|
if (enableMultilingual) {
|
|
188
190
|
if ((0, import_utils.isString)(value)) {
|
|
@@ -40,6 +40,7 @@ declare const formFieldMap: {
|
|
|
40
40
|
'FormItemCheckbox.Group': import("react").FC<import("./Checkbox/type").CheckboxGroupProps & import("../dataSourceForm/utils").WithModeProps>;
|
|
41
41
|
FormItemDateRangePicker: import("react").FC<import("./DateRangePicker/type").DateRangePickerProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps>;
|
|
42
42
|
FormItemUpload: import("react").FC<import("./Upload/type").UploadProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps>;
|
|
43
|
+
FormItemTranslation: import("react").FC<import("./Translation/type").TranslationProps & import("../dataSourceForm/utils").WithFormItemProps>;
|
|
43
44
|
};
|
|
44
45
|
declare const getFieldComponent: (fieldComponent: string) => import("react").FC<import("./Checkbox/type").CheckboxGroupProps & import("../dataSourceForm/utils").WithModeProps> | import("react").FC<any> | (import("react").FC<{}> & {
|
|
45
46
|
Group: import("react").FC<import("./Checkbox/type").CheckboxGroupProps & import("../dataSourceForm/utils").WithModeProps>;
|
|
@@ -63,5 +64,5 @@ declare const getFieldComponent: (fieldComponent: string) => import("react").FC<
|
|
|
63
64
|
valueField: string;
|
|
64
65
|
} & {
|
|
65
66
|
dataSource?: any;
|
|
66
|
-
}) => import("react").JSX.Element) | import("react").FC<import("./TimePicker/type").TimePickerProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./DateRangePicker/type").DateRangePickerProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./Upload/type").UploadProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps>;
|
|
67
|
+
}) => import("react").JSX.Element) | import("react").FC<import("./TimePicker/type").TimePickerProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./DateRangePicker/type").DateRangePickerProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./Upload/type").UploadProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps> | import("react").FC<import("./Translation/type").TranslationProps & import("../dataSourceForm/utils").WithFormItemProps>;
|
|
67
68
|
export { getFieldComponent, formFieldMap };
|
|
@@ -43,6 +43,7 @@ var import_InputNumber = __toESM(require("./InputNumber"));
|
|
|
43
43
|
var import_TimePicker = __toESM(require("./TimePicker"));
|
|
44
44
|
var import_DateRangePicker = __toESM(require("./DateRangePicker"));
|
|
45
45
|
var import_Upload = __toESM(require("./Upload"));
|
|
46
|
+
var import_Translation = __toESM(require("./Translation"));
|
|
46
47
|
var formFieldMap = {
|
|
47
48
|
FormItemCheckbox: import_Checkbox.default,
|
|
48
49
|
FormItemColorPicker: import_ColorPicker.default,
|
|
@@ -61,7 +62,8 @@ var formFieldMap = {
|
|
|
61
62
|
"FormItemRadio.Group": import_Radio.default.Group,
|
|
62
63
|
"FormItemCheckbox.Group": import_Checkbox.default.Group,
|
|
63
64
|
FormItemDateRangePicker: import_DateRangePicker.default,
|
|
64
|
-
FormItemUpload: import_Upload.default
|
|
65
|
+
FormItemUpload: import_Upload.default,
|
|
66
|
+
FormItemTranslation: import_Translation.default
|
|
65
67
|
};
|
|
66
68
|
var getFieldComponent = (fieldComponent) => {
|
|
67
69
|
return formFieldMap[fieldComponent];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/hooks/useTranslationOriginal.ts
|
|
30
|
+
var useTranslationOriginal_exports = {};
|
|
31
|
+
__export(useTranslationOriginal_exports, {
|
|
32
|
+
default: () => useTranslationOriginal_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(useTranslationOriginal_exports);
|
|
35
|
+
var import_useEngineContext = __toESM(require("./useEngineContext"));
|
|
36
|
+
var useTranslationOriginal = () => {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
const context = (0, import_useEngineContext.default)();
|
|
39
|
+
return ((_b = (_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils) == null ? void 0 : _b.translationOriginal) || ((val) => val == null ? void 0 : val.original);
|
|
40
|
+
};
|
|
41
|
+
var useTranslationOriginal_default = useTranslationOriginal;
|
package/lib/index.d.ts
CHANGED
|
@@ -136,6 +136,7 @@ export { default as FormItemRadio } from './components/dataSourceComponents/fiel
|
|
|
136
136
|
export { default as FormItemSelect } from './components/dataSourceComponents/fields/Select';
|
|
137
137
|
export { default as FormItemTimePicker } from './components/dataSourceComponents/fields/TimePicker';
|
|
138
138
|
export { default as FormItemUpload } from './components/dataSourceComponents/fields/Upload';
|
|
139
|
+
export { default as FormItemTranslation } from './components/dataSourceComponents/fields/Translation';
|
|
139
140
|
export { default as DataSourceTable } from './components/dataSourceComponents/dataSourceTable';
|
|
140
141
|
export { default as DataSourceWrapper } from './components/dataSourceComponents/dataSourceWrapper';
|
|
141
142
|
export { default as DataSourceTypography } from './components/dataSourceComponents/dataSourceShow/dataSourceTypography';
|