@knockout-js/layout 0.0.3 → 0.0.4-beta.1
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/es2017/components/aggregate-menu/index.d.ts +32 -0
- package/es2017/components/aggregate-menu/index.js +285 -0
- package/es2017/components/aggregate-menu/index.js.map +1 -0
- package/es2017/components/aggregate-menu/index.module.css +168 -0
- package/es2017/components/aggregate-menu/locale/en_US.d.ts +3 -0
- package/es2017/components/aggregate-menu/locale/en_US.js +9 -0
- package/es2017/components/aggregate-menu/locale/en_US.js.map +1 -0
- package/es2017/components/aggregate-menu/locale/zh_CN.d.ts +3 -0
- package/es2017/components/aggregate-menu/locale/zh_CN.js +9 -0
- package/es2017/components/aggregate-menu/locale/zh_CN.js.map +1 -0
- package/es2017/components/collect-providers/index.d.ts +9 -1
- package/es2017/components/collect-providers/index.js +5 -3
- package/es2017/components/collect-providers/index.js.map +1 -1
- package/es2017/components/i18n-dropdown/index.d.ts +1 -1
- package/es2017/components/i18n-dropdown/index.js +2 -2
- package/es2017/components/i18n-dropdown/index.js.map +1 -1
- package/es2017/components/index.d.ts +7 -1
- package/es2017/components/index.js +7 -1
- package/es2017/components/index.js.map +1 -1
- package/es2017/components/layout/index.d.ts +7 -2
- package/es2017/components/layout/index.js +106 -76
- package/es2017/components/layout/index.js.map +1 -1
- package/es2017/components/locale/en_US.js +5 -1
- package/es2017/components/locale/en_US.js.map +1 -1
- package/es2017/components/locale/index.d.ts +4 -15
- package/es2017/components/locale/index.js +3 -23
- package/es2017/components/locale/index.js.map +1 -1
- package/es2017/components/locale/zh_CN.js +5 -1
- package/es2017/components/locale/zh_CN.js.map +1 -1
- package/es2017/components/modal/index.d.ts +18 -0
- package/es2017/components/modal/index.js +89 -0
- package/es2017/components/modal/index.js.map +1 -0
- package/es2017/components/modal/index.module.css +20 -0
- package/es2017/components/provider/index.d.ts +33 -0
- package/es2017/components/provider/index.js +49 -0
- package/es2017/components/provider/index.js.map +1 -0
- package/es2017/components/tenant-dropdown/index.js +1 -1
- package/es2017/components/tenant-dropdown/index.js.map +1 -1
- package/es2017/components/upload-file/index.d.ts +59 -0
- package/es2017/components/upload-file/index.js +15 -0
- package/es2017/components/upload-file/index.js.map +1 -0
- package/es2017/components/upload-file/index.module.css +13 -0
- package/es2017/components/upload-file/locale/en_US.d.ts +3 -0
- package/es2017/components/upload-file/locale/en_US.js +14 -0
- package/es2017/components/upload-file/locale/en_US.js.map +1 -0
- package/es2017/components/upload-file/locale/zh_CN.d.ts +3 -0
- package/es2017/components/upload-file/locale/zh_CN.js +14 -0
- package/es2017/components/upload-file/locale/zh_CN.js.map +1 -0
- package/es2017/components/upload-file/uploadAvatar.d.ts +4 -0
- package/es2017/components/upload-file/uploadAvatar.js +93 -0
- package/es2017/components/upload-file/uploadAvatar.js.map +1 -0
- package/es2017/components/upload-file/uploadMultiple.d.ts +4 -0
- package/es2017/components/upload-file/uploadMultiple.js +155 -0
- package/es2017/components/upload-file/uploadMultiple.js.map +1 -0
- package/es2017/components/upload-file/uploadTemp.d.ts +9 -0
- package/es2017/components/upload-file/uploadTemp.js +167 -0
- package/es2017/components/upload-file/uploadTemp.js.map +1 -0
- package/esm/components/aggregate-menu/index.d.ts +32 -0
- package/esm/components/aggregate-menu/index.js +333 -0
- package/esm/components/aggregate-menu/index.js.map +1 -0
- package/esm/components/aggregate-menu/index.module.css +168 -0
- package/esm/components/aggregate-menu/locale/en_US.d.ts +3 -0
- package/esm/components/aggregate-menu/locale/en_US.js +9 -0
- package/esm/components/aggregate-menu/locale/en_US.js.map +1 -0
- package/esm/components/aggregate-menu/locale/zh_CN.d.ts +3 -0
- package/esm/components/aggregate-menu/locale/zh_CN.js +9 -0
- package/esm/components/aggregate-menu/locale/zh_CN.js.map +1 -0
- package/esm/components/collect-providers/index.d.ts +9 -1
- package/esm/components/collect-providers/index.js +5 -3
- package/esm/components/collect-providers/index.js.map +1 -1
- package/esm/components/i18n-dropdown/index.d.ts +1 -1
- package/esm/components/i18n-dropdown/index.js +2 -2
- package/esm/components/i18n-dropdown/index.js.map +1 -1
- package/esm/components/index.d.ts +7 -1
- package/esm/components/index.js +7 -1
- package/esm/components/index.js.map +1 -1
- package/esm/components/layout/index.d.ts +7 -2
- package/esm/components/layout/index.js +122 -92
- package/esm/components/layout/index.js.map +1 -1
- package/esm/components/locale/en_US.js +5 -1
- package/esm/components/locale/en_US.js.map +1 -1
- package/esm/components/locale/index.d.ts +4 -15
- package/esm/components/locale/index.js +3 -23
- package/esm/components/locale/index.js.map +1 -1
- package/esm/components/locale/zh_CN.js +5 -1
- package/esm/components/locale/zh_CN.js.map +1 -1
- package/esm/components/modal/index.d.ts +18 -0
- package/esm/components/modal/index.js +90 -0
- package/esm/components/modal/index.js.map +1 -0
- package/esm/components/modal/index.module.css +20 -0
- package/esm/components/provider/index.d.ts +33 -0
- package/esm/components/provider/index.js +49 -0
- package/esm/components/provider/index.js.map +1 -0
- package/esm/components/tenant-dropdown/index.js +1 -1
- package/esm/components/tenant-dropdown/index.js.map +1 -1
- package/esm/components/upload-file/index.d.ts +59 -0
- package/esm/components/upload-file/index.js +15 -0
- package/esm/components/upload-file/index.js.map +1 -0
- package/esm/components/upload-file/index.module.css +13 -0
- package/esm/components/upload-file/locale/en_US.d.ts +3 -0
- package/esm/components/upload-file/locale/en_US.js +14 -0
- package/esm/components/upload-file/locale/en_US.js.map +1 -0
- package/esm/components/upload-file/locale/zh_CN.d.ts +3 -0
- package/esm/components/upload-file/locale/zh_CN.js +14 -0
- package/esm/components/upload-file/locale/zh_CN.js.map +1 -0
- package/esm/components/upload-file/uploadAvatar.d.ts +4 -0
- package/esm/components/upload-file/uploadAvatar.js +191 -0
- package/esm/components/upload-file/uploadAvatar.js.map +1 -0
- package/esm/components/upload-file/uploadMultiple.d.ts +4 -0
- package/esm/components/upload-file/uploadMultiple.js +308 -0
- package/esm/components/upload-file/uploadMultiple.js.map +1 -0
- package/esm/components/upload-file/uploadTemp.d.ts +9 -0
- package/esm/components/upload-file/uploadTemp.js +293 -0
- package/esm/components/upload-file/uploadTemp.js.map +1 -0
- package/package.json +8 -4
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs";
|
|
2
|
+
import _sliced_to_array from "@swc/helpers/src/_sliced_to_array.mjs";
|
|
3
|
+
import _ts_generator from "@swc/helpers/src/_ts_generator.mjs";
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runtime/jsx-runtime";
|
|
5
|
+
import { UploadOutlined } from "@ant-design/icons";
|
|
6
|
+
import { Button, Modal, Popconfirm, Space, Typography, Upload, message } from "antd";
|
|
7
|
+
import { useEffect, useRef, useState } from "react";
|
|
8
|
+
import { files as fileApi } from "@knockout-js/api";
|
|
9
|
+
import { useAppCode, useTenantId } from "../provider/index";
|
|
10
|
+
import { randomId, formatFileSize } from "./index";
|
|
11
|
+
import { useLocale } from "../locale/index";
|
|
12
|
+
import styles from "./index.module.css";
|
|
13
|
+
export default function(props) {
|
|
14
|
+
var _props_accept;
|
|
15
|
+
var _props_bucket, _props_appCode, _props_tenantId;
|
|
16
|
+
var bucket = (_props_bucket = props.bucket) !== null && _props_bucket !== void 0 ? _props_bucket : "local", appCode = (_props_appCode = props.appCode) !== null && _props_appCode !== void 0 ? _props_appCode : useAppCode(), tenantId = (_props_tenantId = props.tenantId) !== null && _props_tenantId !== void 0 ? _props_tenantId : useTenantId(), locale = useLocale("UploadFile"), _message_useMessage = _sliced_to_array(message.useMessage(), 1), messageApi = _message_useMessage[0], _useState = _sliced_to_array(useState(false), 2), loading = _useState[0], setLoading = _useState[1], iframeRef = useRef(null), _useState1 = _sliced_to_array(useState(), 2), name = _useState1[0], setName = _useState1[1], _useState2 = _sliced_to_array(useState(), 2), urlSrc = _useState2[0], setUrlSrc = _useState2[1], _useState3 = _sliced_to_array(useState({
|
|
17
|
+
show: false
|
|
18
|
+
}), 2), modal = _useState3[0], setModal = _useState3[1];
|
|
19
|
+
var getUploadKey = function(file) {
|
|
20
|
+
var suffix = file.name.split(".").pop(), keys = [];
|
|
21
|
+
if (props.forceDirectory && props.directory) keys.push(props.directory);
|
|
22
|
+
else {
|
|
23
|
+
if (appCode) keys.push(appCode);
|
|
24
|
+
if (tenantId) keys.push(tenantId);
|
|
25
|
+
if (props.directory) keys.push(props.directory);
|
|
26
|
+
}
|
|
27
|
+
keys.push("".concat(randomId(16), ".").concat(suffix));
|
|
28
|
+
return "/".concat(keys.join("/")).replace("//", "/");
|
|
29
|
+
}, beforeUpload = function() {
|
|
30
|
+
var _ref = _async_to_generator(function(file) {
|
|
31
|
+
var maxSize;
|
|
32
|
+
return _ts_generator(this, function(_state) {
|
|
33
|
+
switch(_state.label){
|
|
34
|
+
case 0:
|
|
35
|
+
maxSize = props.maxSize || 5242880;
|
|
36
|
+
if (file.size > maxSize) {
|
|
37
|
+
messageApi.error("".concat(locale.fileSizeTip, ": ").concat(formatFileSize(maxSize)));
|
|
38
|
+
return [
|
|
39
|
+
2,
|
|
40
|
+
false
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
return [
|
|
44
|
+
4,
|
|
45
|
+
updateFile(file)
|
|
46
|
+
];
|
|
47
|
+
case 1:
|
|
48
|
+
_state.sent();
|
|
49
|
+
return [
|
|
50
|
+
2,
|
|
51
|
+
false
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
return function beforeUpload(file) {
|
|
57
|
+
return _ref.apply(this, arguments);
|
|
58
|
+
};
|
|
59
|
+
}(), updateFile = function() {
|
|
60
|
+
var _ref = _async_to_generator(function(file) {
|
|
61
|
+
var key, result, _props_onChange, _props_onChangePath, error;
|
|
62
|
+
return _ts_generator(this, function(_state) {
|
|
63
|
+
switch(_state.label){
|
|
64
|
+
case 0:
|
|
65
|
+
key = getUploadKey(file);
|
|
66
|
+
setLoading(true);
|
|
67
|
+
if (!(bucket === "local")) return [
|
|
68
|
+
3,
|
|
69
|
+
4
|
|
70
|
+
];
|
|
71
|
+
_state.label = 1;
|
|
72
|
+
case 1:
|
|
73
|
+
_state.trys.push([
|
|
74
|
+
1,
|
|
75
|
+
3,
|
|
76
|
+
,
|
|
77
|
+
4
|
|
78
|
+
]);
|
|
79
|
+
return [
|
|
80
|
+
4,
|
|
81
|
+
fileApi.updateFiles({
|
|
82
|
+
key: key,
|
|
83
|
+
bucket: bucket,
|
|
84
|
+
file: file
|
|
85
|
+
})
|
|
86
|
+
];
|
|
87
|
+
case 2:
|
|
88
|
+
result = _state.sent();
|
|
89
|
+
if (result) {
|
|
90
|
+
;
|
|
91
|
+
(_props_onChange = props.onChange) === null || _props_onChange === void 0 ? void 0 : _props_onChange.call(props, result);
|
|
92
|
+
(_props_onChangePath = props.onChangePath) === null || _props_onChangePath === void 0 ? void 0 : _props_onChangePath.call(props, key);
|
|
93
|
+
}
|
|
94
|
+
return [
|
|
95
|
+
3,
|
|
96
|
+
4
|
|
97
|
+
];
|
|
98
|
+
case 3:
|
|
99
|
+
error = _state.sent();
|
|
100
|
+
return [
|
|
101
|
+
3,
|
|
102
|
+
4
|
|
103
|
+
];
|
|
104
|
+
case 4:
|
|
105
|
+
setLoading(false);
|
|
106
|
+
return [
|
|
107
|
+
2
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
return function updateFile(file) {
|
|
113
|
+
return _ref.apply(this, arguments);
|
|
114
|
+
};
|
|
115
|
+
}(), getValueFile = function() {
|
|
116
|
+
var _ref = _async_to_generator(function() {
|
|
117
|
+
var result, result1;
|
|
118
|
+
return _ts_generator(this, function(_state) {
|
|
119
|
+
switch(_state.label){
|
|
120
|
+
case 0:
|
|
121
|
+
if (!props.value) return [
|
|
122
|
+
3,
|
|
123
|
+
4
|
|
124
|
+
];
|
|
125
|
+
return [
|
|
126
|
+
4,
|
|
127
|
+
fileApi.getFiles(props.value)
|
|
128
|
+
];
|
|
129
|
+
case 1:
|
|
130
|
+
result = _state.sent();
|
|
131
|
+
if (result === null || result === void 0 ? void 0 : result.id) setName(result.name);
|
|
132
|
+
if (!(bucket === "local")) return [
|
|
133
|
+
3,
|
|
134
|
+
3
|
|
135
|
+
];
|
|
136
|
+
return [
|
|
137
|
+
4,
|
|
138
|
+
fileApi.getFilesRaw(props.value, "url")
|
|
139
|
+
];
|
|
140
|
+
case 2:
|
|
141
|
+
result1 = _state.sent();
|
|
142
|
+
if (typeof result1 === "string") setUrlSrc(result1);
|
|
143
|
+
_state.label = 3;
|
|
144
|
+
case 3:
|
|
145
|
+
return [
|
|
146
|
+
3,
|
|
147
|
+
5
|
|
148
|
+
];
|
|
149
|
+
case 4:
|
|
150
|
+
setUrlSrc(undefined);
|
|
151
|
+
_state.label = 5;
|
|
152
|
+
case 5:
|
|
153
|
+
return [
|
|
154
|
+
2
|
|
155
|
+
];
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
return function getValueFile() {
|
|
160
|
+
return _ref.apply(this, arguments);
|
|
161
|
+
};
|
|
162
|
+
}(), updateContent = function() {
|
|
163
|
+
var _ref = _async_to_generator(function() {
|
|
164
|
+
var result, r;
|
|
165
|
+
return _ts_generator(this, function(_state) {
|
|
166
|
+
switch(_state.label){
|
|
167
|
+
case 0:
|
|
168
|
+
if (!props.value) return [
|
|
169
|
+
3,
|
|
170
|
+
2
|
|
171
|
+
];
|
|
172
|
+
return [
|
|
173
|
+
4,
|
|
174
|
+
fileApi.getFilesRaw(props.value)
|
|
175
|
+
];
|
|
176
|
+
case 1:
|
|
177
|
+
result = _state.sent();
|
|
178
|
+
if (result && typeof result != "string") {
|
|
179
|
+
r = new FileReader();
|
|
180
|
+
r.readAsText(result, "utf-8");
|
|
181
|
+
r.onload = function() {
|
|
182
|
+
var _iframeRef_current, _iframeRef_current1;
|
|
183
|
+
if ((_iframeRef_current = iframeRef.current) === null || _iframeRef_current === void 0 ? void 0 : _iframeRef_current.contentWindow) iframeRef.current.contentWindow.document.write(r.result);
|
|
184
|
+
else if ((_iframeRef_current1 = iframeRef.current) === null || _iframeRef_current1 === void 0 ? void 0 : _iframeRef_current1.contentDocument) iframeRef.current.contentDocument.write(r.result);
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
_state.label = 2;
|
|
188
|
+
case 2:
|
|
189
|
+
return [
|
|
190
|
+
2
|
|
191
|
+
];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
return function updateContent() {
|
|
196
|
+
return _ref.apply(this, arguments);
|
|
197
|
+
};
|
|
198
|
+
}();
|
|
199
|
+
useEffect(function() {
|
|
200
|
+
getValueFile();
|
|
201
|
+
}, [
|
|
202
|
+
props.value
|
|
203
|
+
]);
|
|
204
|
+
useEffect(function() {
|
|
205
|
+
if (modal.show) updateContent();
|
|
206
|
+
}, [
|
|
207
|
+
modal.show
|
|
208
|
+
]);
|
|
209
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
210
|
+
children: [
|
|
211
|
+
/*#__PURE__*/ _jsxs(Space, {
|
|
212
|
+
children: [
|
|
213
|
+
/*#__PURE__*/ _jsx(Upload, {
|
|
214
|
+
accept: props.accept,
|
|
215
|
+
showUploadList: false,
|
|
216
|
+
beforeUpload: beforeUpload,
|
|
217
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
218
|
+
loading: loading,
|
|
219
|
+
icon: /*#__PURE__*/ _jsx(UploadOutlined, {
|
|
220
|
+
rev: undefined
|
|
221
|
+
}),
|
|
222
|
+
children: locale.fileUpload
|
|
223
|
+
})
|
|
224
|
+
}),
|
|
225
|
+
/*#__PURE__*/ _jsx(Typography.Text, {
|
|
226
|
+
type: "secondary",
|
|
227
|
+
children: "".concat(locale.supportExtension, ": ").concat((_props_accept = props.accept) === null || _props_accept === void 0 ? void 0 : _props_accept.split(",.").join("、").replace(".", ""))
|
|
228
|
+
})
|
|
229
|
+
]
|
|
230
|
+
}),
|
|
231
|
+
props.value ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
232
|
+
children: [
|
|
233
|
+
/*#__PURE__*/ _jsx("div", {
|
|
234
|
+
style: {
|
|
235
|
+
height: "8px"
|
|
236
|
+
}
|
|
237
|
+
}),
|
|
238
|
+
/*#__PURE__*/ _jsxs(Space, {
|
|
239
|
+
children: [
|
|
240
|
+
/*#__PURE__*/ _jsx("a", {
|
|
241
|
+
onClick: function() {
|
|
242
|
+
setModal({
|
|
243
|
+
show: true
|
|
244
|
+
});
|
|
245
|
+
},
|
|
246
|
+
children: locale.tempViewer
|
|
247
|
+
}),
|
|
248
|
+
/*#__PURE__*/ _jsx("a", {
|
|
249
|
+
target: "_blank",
|
|
250
|
+
href: urlSrc,
|
|
251
|
+
download: name,
|
|
252
|
+
children: locale.tempDown
|
|
253
|
+
}),
|
|
254
|
+
props.showDelBtn ? /*#__PURE__*/ _jsx(Popconfirm, {
|
|
255
|
+
title: locale.del,
|
|
256
|
+
description: locale.confirmDel,
|
|
257
|
+
onConfirm: function() {
|
|
258
|
+
var _props_onChange, _props_onChangePath;
|
|
259
|
+
(_props_onChange = props.onChange) === null || _props_onChange === void 0 ? void 0 : _props_onChange.call(props);
|
|
260
|
+
(_props_onChangePath = props.onChangePath) === null || _props_onChangePath === void 0 ? void 0 : _props_onChangePath.call(props);
|
|
261
|
+
},
|
|
262
|
+
okText: "Yes",
|
|
263
|
+
cancelText: "No",
|
|
264
|
+
children: /*#__PURE__*/ _jsx("a", {
|
|
265
|
+
className: styles.delText,
|
|
266
|
+
children: locale.del
|
|
267
|
+
})
|
|
268
|
+
}) : /*#__PURE__*/ _jsx(_Fragment, {})
|
|
269
|
+
]
|
|
270
|
+
}),
|
|
271
|
+
/*#__PURE__*/ _jsx(Modal, {
|
|
272
|
+
title: locale.tempViewer,
|
|
273
|
+
open: modal.show,
|
|
274
|
+
destroyOnClose: true,
|
|
275
|
+
footer: null,
|
|
276
|
+
width: 800,
|
|
277
|
+
onCancel: function() {
|
|
278
|
+
setModal({
|
|
279
|
+
show: false
|
|
280
|
+
});
|
|
281
|
+
},
|
|
282
|
+
children: /*#__PURE__*/ _jsx("iframe", {
|
|
283
|
+
className: styles.modalIframe,
|
|
284
|
+
ref: iframeRef
|
|
285
|
+
})
|
|
286
|
+
})
|
|
287
|
+
]
|
|
288
|
+
}) : /*#__PURE__*/ _jsx(_Fragment, {})
|
|
289
|
+
]
|
|
290
|
+
});
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
//# sourceMappingURL=D:\codeing\git\github\knockout-js\packages\layout\esm\components\upload-file\uploadTemp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["D:\\codeing\\git\\github\\knockout-js\\packages\\layout\\src\\components\\upload-file\\uploadTemp.tsx"],"sourcesContent":["import { UploadOutlined } from \"@ant-design/icons\";\r\nimport { Button, Modal, Popconfirm, Space, Typography, Upload, message } from \"antd\"\r\nimport { RcFile } from \"antd/es/upload\";\r\nimport { useEffect, useRef, useState } from \"react\";\r\nimport { files as fileApi } from \"@knockout-js/api\";\r\nimport { useAppCode, useTenantId } from \"../provider\";\r\nimport { UploadFileProps, randomId, formatFileSize } from \".\";\r\nimport { useLocale } from \"../locale\";\r\nimport styles from \"./index.module.css\";\r\n\r\nexport default (props: UploadFileProps<string> & {\r\n /**\r\n * 显示删除按钮\r\n */\r\n showDelBtn?: boolean;\r\n}) => {\r\n const\r\n bucket = props.bucket ?? 'local',\r\n appCode = props.appCode ?? useAppCode(),\r\n tenantId = props.tenantId ?? useTenantId(),\r\n locale = useLocale(\"UploadFile\"),\r\n [messageApi] = message.useMessage(),\r\n [loading, setLoading] = useState(false),\r\n iframeRef = useRef<HTMLIFrameElement>(null),\r\n [name, setName] = useState<string>(),\r\n [urlSrc, setUrlSrc] = useState<string>(),\r\n [modal, setModal] = useState<{\r\n show: boolean,\r\n }>({\r\n show: false,\r\n });\r\n\r\n const\r\n getUploadKey = (file: RcFile) => {\r\n const suffix = file.name.split('.').pop(),\r\n keys: string[] = [];\r\n if (props.forceDirectory && props.directory) {\r\n keys.push(props.directory)\r\n } else {\r\n if (appCode) {\r\n keys.push(appCode)\r\n }\r\n if (tenantId) {\r\n keys.push(tenantId)\r\n }\r\n if (props.directory) {\r\n keys.push(props.directory)\r\n }\r\n }\r\n keys.push(`${randomId(16)}.${suffix}`);\r\n return `/${keys.join('/')}`.replace('//', '/');\r\n },\r\n beforeUpload = async (file: RcFile) => {\r\n const maxSize = props.maxSize || (1024 * 1024 * 5);\r\n\r\n if (file.size > maxSize) {\r\n messageApi.error(`${locale.fileSizeTip}: ${formatFileSize(maxSize)}`);\r\n return false;\r\n }\r\n\r\n await updateFile(file);\r\n return false;\r\n },\r\n updateFile = async (file: RcFile) => {\r\n const key = getUploadKey(file);\r\n setLoading(true);\r\n if (bucket === 'local') {\r\n try {\r\n const result = await fileApi.updateFiles({\r\n key,\r\n bucket,\r\n file,\r\n })\r\n if (result) {\r\n props.onChange?.(result)\r\n props.onChangePath?.(key);\r\n }\r\n } catch (error) {\r\n\r\n }\r\n }\r\n setLoading(false)\r\n },\r\n getValueFile = async () => {\r\n if (props.value) {\r\n const result = await fileApi.getFiles(props.value);\r\n if (result?.id) {\r\n setName(result.name)\r\n }\r\n if (bucket === 'local') {\r\n const result = await fileApi.getFilesRaw(props.value, 'url');\r\n if (typeof result === 'string') {\r\n setUrlSrc(result)\r\n }\r\n }\r\n } else {\r\n setUrlSrc(undefined)\r\n }\r\n },\r\n updateContent = async () => {\r\n if (props.value) {\r\n const result = await fileApi.getFilesRaw(props.value)\r\n if (result && typeof result != 'string') {\r\n const r = new FileReader()\r\n r.readAsText(result, 'utf-8')\r\n r.onload = () => {\r\n if (iframeRef.current?.contentWindow) {\r\n iframeRef.current.contentWindow.document.write(r.result as string)\r\n } else if (iframeRef.current?.contentDocument) {\r\n iframeRef.current.contentDocument.write(r.result as string)\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n useEffect(() => {\r\n getValueFile();\r\n }, [props.value]);\r\n\r\n useEffect(() => {\r\n if (modal.show) {\r\n updateContent();\r\n }\r\n }, [modal.show]);\r\n\r\n return <>\r\n <Space>\r\n <Upload\r\n accept={props.accept}\r\n showUploadList={false}\r\n beforeUpload={beforeUpload}\r\n >\r\n <Button loading={loading} icon={<UploadOutlined rev={undefined} />}>{locale.fileUpload}</Button>\r\n </Upload>\r\n <Typography.Text type=\"secondary\">\r\n {`${locale.supportExtension}: ${props.accept?.split(',.').join('、').replace('.', '')}`}\r\n </Typography.Text>\r\n </Space>\r\n {props.value ? <>\r\n <div style={{ height: \"8px\" }}></div>\r\n <Space >\r\n <a onClick={() => {\r\n setModal({ show: true })\r\n }}\r\n >{locale.tempViewer}</a>\r\n <a target=\"_blank\" href={urlSrc} download={name}>{locale.tempDown}</a>\r\n {props.showDelBtn ? <Popconfirm\r\n title={locale.del}\r\n description={locale.confirmDel}\r\n onConfirm={() => {\r\n props.onChange?.()\r\n props.onChangePath?.();\r\n }}\r\n okText=\"Yes\"\r\n cancelText=\"No\"\r\n >\r\n <a className={styles.delText}>{locale.del}</a>\r\n </Popconfirm> : <></>}\r\n </Space>\r\n <Modal\r\n title={locale.tempViewer}\r\n open={modal.show}\r\n destroyOnClose\r\n footer={null}\r\n width={800}\r\n onCancel={() => {\r\n setModal({ show: false })\r\n }}\r\n >\r\n <iframe className={styles.modalIframe} ref={iframeRef}></iframe>\r\n </Modal>\r\n </> : <></>}\r\n </>\r\n}\r\n"],"names":["UploadOutlined","Button","Modal","Popconfirm","Space","Typography","Upload","message","useEffect","useRef","useState","files","fileApi","useAppCode","useTenantId","randomId","formatFileSize","useLocale","styles","props","bucket","appCode","tenantId","locale","useMessage","messageApi","loading","setLoading","iframeRef","name","setName","urlSrc","setUrlSrc","show","modal","setModal","getUploadKey","file","suffix","split","pop","keys","forceDirectory","directory","push","join","replace","beforeUpload","maxSize","size","error","fileSizeTip","updateFile","key","result","updateFiles","onChange","onChangePath","getValueFile","value","getFiles","id","getFilesRaw","undefined","updateContent","r","FileReader","readAsText","onload","current","contentWindow","document","write","contentDocument","accept","showUploadList","icon","rev","fileUpload","Text","type","supportExtension","div","style","height","a","onClick","tempViewer","target","href","download","tempDown","showDelBtn","title","del","description","confirmDel","onConfirm","okText","cancelText","className","delText","open","destroyOnClose","footer","width","onCancel","iframe","modalIframe","ref"],"mappings":";;;;AAAA,SAASA,cAAc,QAAQ,oBAAoB;AACnD,SAASC,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,EAAEC,MAAM,EAAEC,OAAO,QAAQ,OAAM;AAEpF,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AACpD,SAASC,SAASC,OAAO,QAAQ,mBAAmB;AACpD,SAASC,UAAU,EAAEC,WAAW,QAAQ,oBAAc;AACtD,SAA0BC,QAAQ,EAAEC,cAAc,QAAQ,UAAI;AAC9D,SAASC,SAAS,QAAQ,kBAAY;AACtC,OAAOC,YAAY,qBAAqB;AAExC,eAAe,SAACC,OAKV;QAyHkCA;QAvH3BA,eACCA,gBACCA;IAHb,IACEC,SAASD,CAAAA,gBAAAA,MAAMC,MAAM,cAAZD,2BAAAA,gBAAgB,OAAO,EAChCE,UAAUF,CAAAA,iBAAAA,MAAME,OAAO,cAAbF,4BAAAA,iBAAiBN,YAAY,EACvCS,WAAWH,CAAAA,kBAAAA,MAAMG,QAAQ,cAAdH,6BAAAA,kBAAkBL,aAAa,EAC1CS,SAASN,UAAU,eACJV,uCAAAA,QAAQiB,UAAU,QAAhCC,aAAclB,wBACSG,6BAAAA,SAAS,KAAK,OAArCgB,UAAuBhB,cAAdiB,aAAcjB,cACxBkB,YAAYnB,OAA0B,IAAI,GACxBC,8BAAAA,gBAAjBmB,OAAiBnB,eAAXoB,UAAWpB,eACIA,8BAAAA,gBAArBqB,SAAqBrB,eAAbsB,YAAatB,eACFA,8BAAAA,SAEjB;QACDuB,MAAM,KAAK;IACb,QAJCC,QAAmBxB,eAAZyB,WAAY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AA,kBAAAA,MAAMqC,QAAQ,cAAdrC,6BAAAA,KAAAA,IAAAA,gBAAAA,KAAAA;oCACAA,CAAAA,sBAAAA,MAAMsC,YAAY,cAAlBtC,iCAAAA,KAAAA,IAAAA,oBAAAA,KAAAA;gCACF;gCACA+E,QAAO;gCACPC,YAAW;0CAEX,cAAA,KAACd;oCAAEe,WAAWlF,OAAOmF,OAAO;8CAAG9E,OAAOuE,GAAG;;+CAC3B,mBAAK;;;kCAEvB,KAAC5F;wBACC2F,OAAOtE,OAAOgE,UAAU;wBACxBe,MAAMpE,MAAMD,IAAI;wBAChBsE,cAAc;wBACdC,QAAQ,IAAI;wBACZC,OAAO;wBACPC,UAAU,WAAM;4BACdvE,SAAS;gCAAEF,MAAM,KAAK;4BAAC;wBACzB;kCAEA,cAAA,KAAC0E;4BAAOP,WAAWlF,OAAO0F,WAAW;4BAAEC,KAAKjF;;;;+BAE1C,mBAAK;;;AAEf,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knockout-js/layout",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4-beta.1",
|
|
4
4
|
"description": "组件功能描述",
|
|
5
5
|
"files": [
|
|
6
6
|
"esm",
|
|
@@ -36,17 +36,21 @@
|
|
|
36
36
|
"component"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ant-design/icons": "^5.
|
|
39
|
+
"@ant-design/icons": "^5.2.5",
|
|
40
40
|
"@ant-design/pro-layout": "^7.16.6",
|
|
41
41
|
"@ant-design/pro-provider": "^2.12.1",
|
|
42
42
|
"@ant-design/pro-table": "^3.8.2",
|
|
43
|
+
"@dnd-kit/core": "^6.0.8",
|
|
44
|
+
"@dnd-kit/sortable": "^7.0.2",
|
|
45
|
+
"@dnd-kit/utilities": "^3.2.1",
|
|
43
46
|
"@ice/jsx-runtime": "^0.2.0",
|
|
44
47
|
"@ice/runtime": "^1.2.4",
|
|
45
48
|
"@swc/helpers": "^0.5.1",
|
|
46
49
|
"antd": "^5.6.3",
|
|
47
50
|
"react-activation": "^0.12.4",
|
|
48
|
-
"
|
|
49
|
-
"@knockout-js/
|
|
51
|
+
"react-draggable": "^4.4.5",
|
|
52
|
+
"@knockout-js/api": "^0.0.4-beta.1",
|
|
53
|
+
"@knockout-js/ice-urql": "^0.0.4-beta.0"
|
|
50
54
|
},
|
|
51
55
|
"devDependencies": {
|
|
52
56
|
"@ice/pkg": "^1.5.0",
|