@qn-pandora/pandora-component 4.4.3 → 4.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. package/CHANGELOG.json +17 -0
  2. package/CHANGELOG.md +8 -1
  3. package/es/components/FileResumable/index.js +53 -62
  4. package/es/components/FileResumable/utils.d.ts +2 -0
  5. package/es/components/FileResumable/utils.js +17 -0
  6. package/es/components/Table/ColumnSetting/index.d.ts +1 -0
  7. package/es/components/Table/ColumnSetting/index.js +16 -8
  8. package/es/components/Table/ColumnSetting/style.css +10 -1
  9. package/es/components/Table/ColumnSetting/style.less +6 -1
  10. package/es/components/Table/constant.d.ts +3 -1
  11. package/es/components/Table/constant.js +2 -0
  12. package/es/components/Table/index.d.ts +30 -4
  13. package/es/components/Table/index.js +280 -30
  14. package/es/components/Table/style.css +1 -0
  15. package/es/components/Table/style.less +1 -0
  16. package/es/index.css +7634 -7624
  17. package/es/index.d.ts +1 -1
  18. package/es/index.js +1 -1
  19. package/es/index.less +19 -19
  20. package/lib/components/FileResumable/index.js +52 -61
  21. package/lib/components/FileResumable/utils.d.ts +2 -0
  22. package/lib/components/FileResumable/utils.js +21 -0
  23. package/lib/components/Table/ColumnSetting/index.d.ts +1 -0
  24. package/lib/components/Table/ColumnSetting/index.js +15 -7
  25. package/lib/components/Table/ColumnSetting/style.css +10 -1
  26. package/lib/components/Table/ColumnSetting/style.less +6 -1
  27. package/lib/components/Table/constant.d.ts +3 -1
  28. package/lib/components/Table/constant.js +2 -0
  29. package/lib/components/Table/index.d.ts +30 -4
  30. package/lib/components/Table/index.js +279 -29
  31. package/lib/components/Table/style.css +1 -0
  32. package/lib/components/Table/style.less +1 -0
  33. package/lib/index.css +2830 -2820
  34. package/lib/index.d.ts +1 -1
  35. package/lib/index.js +1 -0
  36. package/lib/index.less +14 -14
  37. package/package.json +4 -3
package/CHANGELOG.json CHANGED
@@ -1,6 +1,23 @@
1
1
  {
2
2
  "name": "@qn-pandora/pandora-component",
3
3
  "entries": [
4
+ {
5
+ "version": "4.4.4",
6
+ "tag": "@qn-pandora/pandora-component_v4.4.4",
7
+ "date": "Tue, 27 Feb 2024 12:57:54 GMT",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "comment": "2024-02-27发包"
12
+ }
13
+ ],
14
+ "dependency": [
15
+ {
16
+ "comment": "Updating dependency \"@qn-pandora/app-sdk\" from `^3.4.3` to `^3.4.4`"
17
+ }
18
+ ]
19
+ }
20
+ },
4
21
  {
5
22
  "version": "4.4.3",
6
23
  "tag": "@qn-pandora/pandora-component_v4.4.3",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Change Log - @qn-pandora/pandora-component
2
2
 
3
- This log was last generated on Fri, 23 Feb 2024 06:02:50 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 27 Feb 2024 12:57:54 GMT and should not be manually modified.
4
+
5
+ ## 4.4.4
6
+ Tue, 27 Feb 2024 12:57:54 GMT
7
+
8
+ ### Patches
9
+
10
+ - 2024-02-27发包
4
11
 
5
12
  ## 4.4.3
6
13
  Fri, 23 Feb 2024 06:02:50 GMT
@@ -75,7 +75,6 @@ var __read = (this && this.__read) || function (o, n) {
75
75
  import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
76
76
  import Resumablejs from 'resumablejs';
77
77
  import uuid from 'uuid';
78
- import md5 from 'crypto-js/md5';
79
78
  import { Progress, Tooltip, Upload } from 'antd';
80
79
  import { ConfigContext } from 'antd/es/config-provider';
81
80
  import classnames from 'classnames';
@@ -85,7 +84,7 @@ import { appEnv, fileIsExit } from '@qn-pandora/app-sdk';
85
84
  import { formatString } from '../../utils/language';
86
85
  import { UploadLocale } from '../../constants/language/upload/type';
87
86
  import { SDK_PREFIX } from '../../constants/style';
88
- import { isJpgOrPngOrSvg } from './utils';
87
+ import { calculateFileMd5, isJpgOrPngOrSvg } from './utils';
89
88
  var Dragger = Upload.Dragger;
90
89
  export default function FileResumable(props) {
91
90
  var _a, _b;
@@ -261,67 +260,59 @@ export default function FileResumable(props) {
261
260
  onError
262
261
  ]);
263
262
  var handleStart = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
264
- var params, realFile_1, reader, extension_1;
265
- var _this = this;
266
- return __generator(this, function (_a) {
267
- params = __assign(__assign({}, query), { persistence: persistence });
268
- if (fileList.length === 1) {
269
- realFile_1 = fileList[0];
270
- reader = new FileReader();
271
- reader.readAsText(realFile_1.size > 50 * 1024 * 1024
272
- ? realFile_1.slice(0, 2 * 1024 * 1024)
273
- : realFile_1);
274
- extension_1 = realFile_1.name.split('.').pop().toLowerCase();
275
- reader.onloadend = function (e) { return __awaiter(_this, void 0, void 0, function () {
276
- var md5Str, id, fileId, error_1;
277
- var _a, _b, _c;
278
- return __generator(this, function (_d) {
279
- switch (_d.label) {
280
- case 0:
281
- if (!(e.target.readyState === FileReader.DONE)) return [3 /*break*/, 5];
282
- md5Str = md5(e.target.result).toString();
283
- id = '';
284
- _d.label = 1;
285
- case 1:
286
- _d.trys.push([1, 3, , 4]);
287
- return [4 /*yield*/, fileIsExit({
288
- resumableModifyTime: realFile_1.lastModified,
289
- resumableFilename: realFile_1.name,
290
- resumableType: realFile_1.type || "application/" + extension_1,
291
- resumableFileMd5: md5Str,
292
- resumableTotalSize: realFile_1.size
293
- })];
294
- case 2:
295
- fileId = (_d.sent()).fileId;
296
- id = fileId;
297
- return [3 /*break*/, 4];
298
- case 3:
299
- error_1 = _d.sent();
300
- handleError(get(error_1, 'message'));
301
- return [3 /*break*/, 4];
302
- case 4:
303
- if (!id) {
304
- params.resumableFileMd5 = md5Str;
305
- params.resumableModifyTime = realFile_1.lastModified;
306
- params.resumableIdentifier = uuid();
307
- params.resumableType = realFile_1.type || "application/" + extension_1;
308
- (_a = resumable.current) === null || _a === void 0 ? void 0 : _a.updateQuery(params);
309
- (_b = resumable.current) === null || _b === void 0 ? void 0 : _b.upload();
310
- }
311
- else {
312
- handleFileSuccess(JSON.stringify({
313
- fileId: id
314
- }));
315
- (_c = resumable.current) === null || _c === void 0 ? void 0 : _c.cancel();
316
- }
317
- _d.label = 5;
318
- case 5: return [2 /*return*/];
319
- }
320
- });
321
- }); };
263
+ var params, realFile, extension, md5Str, id, fileId, error_1;
264
+ var _a, _b, _c;
265
+ return __generator(this, function (_d) {
266
+ switch (_d.label) {
267
+ case 0:
268
+ params = __assign(__assign({}, query), { persistence: persistence });
269
+ if (!(fileList.length === 1)) return [3 /*break*/, 6];
270
+ realFile = fileList[0];
271
+ extension = realFile.name.split('.').pop().toLowerCase();
272
+ return [4 /*yield*/, calculateFileMd5(realFile.size > 50 * 1024 * 1024
273
+ ? realFile.slice(0, 2 * 1024 * 1024)
274
+ : realFile)];
275
+ case 1:
276
+ md5Str = _d.sent();
277
+ id = '';
278
+ _d.label = 2;
279
+ case 2:
280
+ _d.trys.push([2, 4, , 5]);
281
+ return [4 /*yield*/, fileIsExit({
282
+ resumableModifyTime: realFile.lastModified,
283
+ resumableFilename: realFile.name,
284
+ resumableType: realFile.type || "application/" + extension,
285
+ resumableFileMd5: md5Str,
286
+ resumableTotalSize: realFile.size
287
+ })];
288
+ case 3:
289
+ fileId = (_d.sent()).fileId;
290
+ id = fileId;
291
+ return [3 /*break*/, 5];
292
+ case 4:
293
+ error_1 = _d.sent();
294
+ handleError(get(error_1, 'message'));
295
+ return [3 /*break*/, 5];
296
+ case 5:
297
+ if (!id) {
298
+ params.resumableFileMd5 = md5Str;
299
+ params.resumableModifyTime = realFile.lastModified;
300
+ params.resumableIdentifier = uuid();
301
+ params.resumableType = realFile.type || "application/" + extension;
302
+ (_a = resumable.current) === null || _a === void 0 ? void 0 : _a.updateQuery(params);
303
+ (_b = resumable.current) === null || _b === void 0 ? void 0 : _b.upload();
304
+ }
305
+ else {
306
+ handleFileSuccess(JSON.stringify({
307
+ fileId: id
308
+ }));
309
+ (_c = resumable.current) === null || _c === void 0 ? void 0 : _c.cancel();
310
+ }
311
+ _d.label = 6;
312
+ case 6:
313
+ setShowTool(true);
314
+ return [2 /*return*/];
322
315
  }
323
- setShowTool(true);
324
- return [2 /*return*/];
325
316
  });
326
317
  }); }, [
327
318
  query,
@@ -1 +1,3 @@
1
+ import { RcFile } from 'antd/es/upload';
1
2
  export declare const isJpgOrPngOrSvg: (type?: string, hexValue?: string) => boolean;
3
+ export declare function calculateFileMd5(file: RcFile): Promise<string>;
@@ -1,4 +1,5 @@
1
1
  import { includes } from 'lodash';
2
+ import CryptoJS from 'crypto-js';
2
3
  var MIME_IMAGE_TYPE = [
3
4
  'image/png',
4
5
  'image/jpeg',
@@ -15,3 +16,19 @@ export var isJpgOrPngOrSvg = function (type, hexValue) {
15
16
  includes(hexValue.toLowerCase(), '3c3f786d') || // svg
16
17
  includes(hexValue.toLowerCase(), '89504e47')));
17
18
  };
19
+ // 读取文件并计算 MD5
20
+ export function calculateFileMd5(file) {
21
+ return new Promise(function (resolve) {
22
+ var reader = new FileReader();
23
+ reader.onload = function (event) {
24
+ var _a;
25
+ var arrayBuffer = (_a = event.target) === null || _a === void 0 ? void 0 : _a.result;
26
+ if (!arrayBuffer)
27
+ return;
28
+ var wordArray = CryptoJS.lib.WordArray.create(arrayBuffer);
29
+ var md5 = CryptoJS.MD5(wordArray).toString();
30
+ resolve(md5);
31
+ };
32
+ reader.readAsArrayBuffer(file);
33
+ });
34
+ }
@@ -7,6 +7,7 @@ export interface IOption {
7
7
  export interface ISettingBtnProps {
8
8
  overlayClass?: string;
9
9
  onHiddenKeysChange?: (value: string[]) => void;
10
+ onMove?: (keys: string[]) => void;
10
11
  hiddenKeys?: string[];
11
12
  options?: IOption[];
12
13
  loading?: boolean;
@@ -21,8 +21,9 @@ var __spread = (this && this.__spread) || function () {
21
21
  import React, { useMemo, useCallback, useState, useContext } from 'react';
22
22
  import classnames from 'classnames';
23
23
  import { includes } from 'lodash';
24
+ import ReactSortable from 'react-sortablejs';
24
25
  import { Popover, Checkbox, Spin } from 'antd';
25
- import { SettingOutlined } from '@ant-design/icons';
26
+ import { HolderOutlined, SettingOutlined } from '@ant-design/icons';
26
27
  import { ConfigContext } from 'antd/es/config-provider';
27
28
  import { formatString } from '../../../utils/language';
28
29
  import { TableLocale } from '../../../constants/language/table/type';
@@ -31,7 +32,7 @@ import NameLimiter from '../../NameLimiter';
31
32
  import Input from '../../Input';
32
33
  export var All = '_all';
33
34
  export function ColumnSetting(props) {
34
- var overlayClass = props.overlayClass, _a = props.hiddenKeys, hiddenKeys = _a === void 0 ? [] : _a, onHiddenKeysChange = props.onHiddenKeysChange, _b = props.options, options = _b === void 0 ? [] : _b, loading = props.loading;
35
+ var overlayClass = props.overlayClass, _a = props.hiddenKeys, hiddenKeys = _a === void 0 ? [] : _a, onHiddenKeysChange = props.onHiddenKeysChange, onMove = props.onMove, _b = props.options, options = _b === void 0 ? [] : _b, loading = props.loading;
35
36
  var locale = useContext(ConfigContext).locale;
36
37
  var _c = __read(useState(''), 2), prefix = _c[0], setPrefix = _c[1];
37
38
  var allKeys = useMemo(function () {
@@ -80,12 +81,19 @@ export function ColumnSetting(props) {
80
81
  React.createElement(Checkbox, { value: All, checked: hiddenKeys.length === 0, onChange: allCheckChange, className: SDK_PREFIX + "-table-column-setting-all-check" }, formatString(TableLocale.check_all, locale)),
81
82
  React.createElement(Input, { value: prefix, allowClear: true, onChange: handlePrefixChange, placeholder: formatString(TableLocale.search, locale), className: SDK_PREFIX + "-table-column-setting-search-input" })),
82
83
  React.createElement("div", null,
83
- React.createElement("div", { className: SDK_PREFIX + "-table-column-setting-content" }, realOptions.map(function (item) {
84
- return (React.createElement("div", { key: item.value },
85
- React.createElement("div", { className: SDK_PREFIX + "-table-column-setting-checkbox-container" },
86
- React.createElement(Checkbox, { checked: !!realValues.find(function (v) { return v === item.value; }), value: item.value, className: SDK_PREFIX + "-table-column-setting-checkbox", onChange: handleChange },
87
- React.createElement("span", { className: SDK_PREFIX + "-table-column-setting-value" }, typeof item.label === 'string' ? (React.createElement(NameLimiter, { name: item.label })) : (item.label))))));
88
- }))))) },
84
+ React.createElement("div", { className: SDK_PREFIX + "-table-column-setting-content" },
85
+ React.createElement(ReactSortable, { onChange: onMove, options: {
86
+ group: 'setting-config',
87
+ animation: 150,
88
+ preventOnFilter: false
89
+ } }, realOptions.map(function (item) {
90
+ return (React.createElement("div", { key: item.value, "data-id": item.value },
91
+ React.createElement("div", { className: SDK_PREFIX + "-table-column-setting-checkbox-container" },
92
+ React.createElement("div", { className: SDK_PREFIX + "-table-column-setting-dragholder" },
93
+ React.createElement(HolderOutlined, null)),
94
+ React.createElement(Checkbox, { checked: !!realValues.find(function (v) { return v === item.value; }), value: item.value, className: SDK_PREFIX + "-table-column-setting-checkbox", onChange: handleChange },
95
+ React.createElement("span", { className: SDK_PREFIX + "-table-column-setting-value" }, typeof item.label === 'string' ? (React.createElement(NameLimiter, { name: item.label })) : (item.label))))));
96
+ })))))) },
89
97
  React.createElement(SettingOutlined, { className: SDK_PREFIX + "-table-column-setting-icon", onClick: function (e) {
90
98
  e.stopPropagation();
91
99
  e.preventDefault();
@@ -38,8 +38,17 @@
38
38
  overflow: hidden;
39
39
  text-overflow: ellipsis;
40
40
  }
41
+ .pandora-sdk-table-column-setting-content > div .pandora-sdk-table-column-setting-checkbox-container {
42
+ margin: 4px 0;
43
+ display: -webkit-box;
44
+ display: -ms-flexbox;
45
+ display: flex;
46
+ }
47
+ .pandora-sdk-table-column-setting-content > div .pandora-sdk-table-column-setting-checkbox-container .pandora-sdk-table-column-setting-dragholder {
48
+ cursor: move;
49
+ }
41
50
  .pandora-sdk-table-column-setting-content > div .pandora-sdk-table-column-setting-checkbox-container .pandora-sdk-table-column-setting-checkbox {
42
- width: 100%;
51
+ width: 120px;
43
52
  overflow: hidden;
44
53
  }
45
54
  .pandora-sdk-table-column-setting-content > div .pandora-sdk-table-column-setting-checkbox-container .pandora-sdk-table-column-setting-checkbox > span:nth-child(2) {
@@ -35,8 +35,13 @@
35
35
  overflow: hidden;
36
36
  text-overflow: ellipsis;
37
37
  .@{sdk-prefix}-table-column-setting-checkbox-container {
38
+ margin: 4px 0;
39
+ display: flex;
40
+ .@{sdk-prefix}-table-column-setting-dragholder {
41
+ cursor: move;
42
+ }
38
43
  .@{sdk-prefix}-table-column-setting-checkbox {
39
- width: 100%;
44
+ width: 120px;
40
45
  overflow: hidden;
41
46
  }
42
47
  .@{sdk-prefix}-table-column-setting-checkbox > span:nth-child(2) {
@@ -16,5 +16,7 @@ export declare enum ETableDragSaveKey {
16
16
  /** 仪表盘 */
17
17
  Dashboard = "Keta_drag_table_dashboard",
18
18
  /** 采集任务 */
19
- CollectionTask = "Keta_drag_collection_task"
19
+ CollectionTask = "Keta_drag_collection_task",
20
+ /** 北冥事件 */
21
+ NeuralertEvent = "Keta_drag_neuralert_event"
20
22
  }
@@ -19,4 +19,6 @@ export var ETableDragSaveKey;
19
19
  ETableDragSaveKey["Dashboard"] = "Keta_drag_table_dashboard";
20
20
  /** 采集任务 */
21
21
  ETableDragSaveKey["CollectionTask"] = "Keta_drag_collection_task";
22
+ /** 北冥事件 */
23
+ ETableDragSaveKey["NeuralertEvent"] = "Keta_drag_neuralert_event";
22
24
  })(ETableDragSaveKey || (ETableDragSaveKey = {}));
@@ -21,6 +21,17 @@ export interface IOptionItem {
21
21
  */
22
22
  disabled?: boolean | ((selectItems: any[]) => boolean);
23
23
  }
24
+ export interface ISaveFieldItem {
25
+ field: string;
26
+ hide?: boolean;
27
+ width?: number;
28
+ index?: number;
29
+ fixed?: boolean | 'right' | 'left';
30
+ }
31
+ export declare enum ETableSettingType {
32
+ SORT = "sort",
33
+ RESIZE = "resize"
34
+ }
24
35
  export interface IColumnType<T> extends ColumnType<T> {
25
36
  colTitle?: string | React.ReactNode;
26
37
  configurable?: boolean;
@@ -47,9 +58,9 @@ export interface ITableProps<T> extends Omit<TableProps<T>, 'columns'> {
47
58
  hiddenColumns?: string[];
48
59
  onHiddenColumnsChange?: (keys: string[]) => void;
49
60
  columnSettingOverlayClass?: string;
50
- draggable?: boolean;
51
- dragSaveKey?: string;
52
- onDraggableChange?: (fieldsWidth: IKeyValues<number>) => void;
61
+ draggable?: boolean | ETableSettingType;
62
+ saveSettingKey?: string;
63
+ onSettingChange?: (fields: ISaveFieldItem[]) => void;
53
64
  }
54
65
  /**
55
66
  * pandora2.0风格的表格
@@ -66,6 +77,12 @@ declare class Table<T = any> extends React.Component<ITableProps<T>, any> {
66
77
  checkAll: boolean;
67
78
  hiddenColumn: string[] | undefined;
68
79
  columns: IKeyValues[];
80
+ sortConfig: {
81
+ sortKeys: string[];
82
+ fixedRightKeys: string[];
83
+ fixedLeftKeys: string[];
84
+ };
85
+ settingFields: ISaveFieldItem[];
69
86
  UNSAFE_componentWillReceiveProps(nextProps: ITableProps<T>): void;
70
87
  get selectedRowKeys(): React.ReactText[];
71
88
  get rowSelection(): TableRowSelection<T> | undefined;
@@ -78,13 +95,22 @@ declare class Table<T = any> extends React.Component<ITableProps<T>, any> {
78
95
  unconfigableKeys: string[];
79
96
  resetKeys: string[];
80
97
  };
98
+ get resizable(): boolean;
99
+ get sortable(): boolean;
100
+ initSettingConfig(): void;
81
101
  handleHideColumnsChange(keys: string[]): Promise<void> | undefined;
82
- getColumns(): IKeyValues<any>[];
102
+ getSortedColumns(): (IKeyValues<any> | undefined)[];
103
+ getColumns(): (IKeyValues<any> | undefined)[];
83
104
  getRowKey(row: any, index: number): any;
105
+ getSortCoulmns(columns: IKeyValues[]): (IKeyValues<any> | undefined)[];
84
106
  setIndeterminate(indeterminate: boolean): void;
85
107
  setCheckAll(checkAll: boolean): void;
86
108
  setHiddenColumn(hiddenColumn?: string[]): void;
87
109
  setColumns(columns: IKeyValues[]): void;
110
+ setSortKeys(columns: string[]): void;
111
+ setSettingFields(columns: ISaveFieldItem[]): void;
112
+ setFixedRightKeys(columns: string[]): void;
113
+ setFixedLeftKeys(columns: string[]): void;
88
114
  setCheckboxStatus(selectedRowsOfCurrentPage?: T[], dataSource?: T[]): void;
89
115
  handleSelectionChange(selectedRowKeys: React.Key[], selectedRowsOfCurrentPage: any[]): void;
90
116
  onRowSelectionChange(selectedRowKeys: React.Key[], selectedRowsOfCurrentPage: any[]): void;