@zykj2024/much-library 1.1.7-beta.10 → 1.1.7-beta.12

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.
Files changed (27) hide show
  1. package/dist/esm/index.d.ts +1 -4
  2. package/dist/esm/index.js +1 -3
  3. package/package.json +2 -2
  4. package/dist/esm/McUpload/comps/McFormUpload/comps/UploadForVal/index.d.ts +0 -38
  5. package/dist/esm/McUpload/comps/McFormUpload/comps/UploadForVal/index.js +0 -209
  6. package/dist/esm/McUpload/comps/McFormUpload/comps/UploadForVal/index.less +0 -6
  7. package/dist/esm/McUpload/comps/McFormUpload/index.d.ts +0 -7
  8. package/dist/esm/McUpload/comps/McFormUpload/index.js +0 -29
  9. package/dist/esm/McUpload/comps/McUploadCmp/index.d.ts +0 -49
  10. package/dist/esm/McUpload/comps/McUploadCmp/index.js +0 -396
  11. package/dist/esm/McUpload/comps/McUploadCmp/index.less +0 -68
  12. package/dist/esm/McUpload/comps/McUploadDragger/index.d.ts +0 -49
  13. package/dist/esm/McUpload/comps/McUploadDragger/index.js +0 -264
  14. package/dist/esm/McUpload/comps/McUploadTrigger/index.d.ts +0 -39
  15. package/dist/esm/McUpload/comps/McUploadTrigger/index.js +0 -318
  16. package/dist/esm/McUpload/comps/McUploadTrigger/index.less +0 -204
  17. package/dist/esm/McUpload/index.d.ts +0 -14
  18. package/dist/esm/McUpload/index.js +0 -9
  19. package/dist/esm/McUpload/tools/calculateMD5/index.d.ts +0 -3
  20. package/dist/esm/McUpload/tools/calculateMD5/index.js +0 -95
  21. package/dist/esm/McUpload/tools/calculateMD5/md5Worker.js +0 -44
  22. package/dist/esm/McUpload/tools/getUid.d.ts +0 -1
  23. package/dist/esm/McUpload/tools/getUid.js +0 -6
  24. package/dist/esm/McUpload/tools/materialVerification.d.ts +0 -50
  25. package/dist/esm/McUpload/tools/materialVerification.js +0 -257
  26. package/dist/esm/McUpload/tools/uploadTools.d.ts +0 -5
  27. package/dist/esm/McUpload/tools/uploadTools.js +0 -56
@@ -13,7 +13,6 @@ import McTag from './McTag';
13
13
  import McThemeConfig from './McThemeConfig';
14
14
  import McTreePanel from './McTreePanel';
15
15
  import McTreeSelect from './McTreeSelect';
16
- import McUpload from './McUpload';
17
16
  import * as Utils from './Utils';
18
17
  export * from './McCascader';
19
18
  export { default as McCascader } from './McCascader';
@@ -29,6 +28,4 @@ export * from './McListSelect';
29
28
  export { default as McListSelect } from './McListSelect';
30
29
  export * from './McSelect';
31
30
  export { default as McSelect } from './McSelect';
32
- export * from './McUpload';
33
- export type { Task, TaskConfig } from './Utils/lib/Queue/types/baseTaskQueue';
34
- export { McFonts, McGroupPanel, McIconFont, McInputNumber, McLazyLoader, McModalProvider, McPeriodSelect, McPopoverButton, McPopoverForm, McProSelect, McResult, McTag, McThemeConfig, McTreePanel, McTreeSelect, McUpload, Utils, };
31
+ export { McFonts, McGroupPanel, McIconFont, McInputNumber, McLazyLoader, McModalProvider, McPeriodSelect, McPopoverButton, McPopoverForm, McProSelect, McResult, McTag, McThemeConfig, McTreePanel, McTreeSelect, Utils, };
package/dist/esm/index.js CHANGED
@@ -13,7 +13,6 @@ import McTag from "./McTag";
13
13
  import McThemeConfig from "./McThemeConfig";
14
14
  import McTreePanel from "./McTreePanel";
15
15
  import McTreeSelect from "./McTreeSelect";
16
- import McUpload from "./McUpload";
17
16
  import * as Utils from "./Utils";
18
17
  export * from "./McCascader";
19
18
  export { default as McCascader } from "./McCascader";
@@ -29,5 +28,4 @@ export * from "./McListSelect";
29
28
  export { default as McListSelect } from "./McListSelect";
30
29
  export * from "./McSelect";
31
30
  export { default as McSelect } from "./McSelect";
32
- export * from "./McUpload";
33
- export { McFonts, McGroupPanel, McIconFont, McInputNumber, McLazyLoader, McModalProvider, McPeriodSelect, McPopoverButton, McPopoverForm, McProSelect, McResult, McTag, McThemeConfig, McTreePanel, McTreeSelect, McUpload, Utils };
31
+ export { McFonts, McGroupPanel, McIconFont, McInputNumber, McLazyLoader, McModalProvider, McPeriodSelect, McPopoverButton, McPopoverForm, McProSelect, McResult, McTag, McThemeConfig, McTreePanel, McTreeSelect, Utils };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zykj2024/much-library",
3
- "version": "1.1.7-beta.10",
3
+ "version": "1.1.7-beta.12",
4
4
  "description": "react library",
5
5
  "license": "MIT",
6
6
  "module": "dist/esm/index.js",
@@ -48,7 +48,7 @@
48
48
  "@dnd-kit/core": "^6.1.0",
49
49
  "@dnd-kit/sortable": "^8.0.0",
50
50
  "@makotot/ghostui": "^2.0.0",
51
- "@zykj2024/much-hooks": "1.1.4-beta.3",
51
+ "@zykj2024/much-hooks": "1.1.3",
52
52
  "@zykj2024/much-icons": "^1.0.9",
53
53
  "antd": "^5.16.2",
54
54
  "antd-style": "^3.6.2",
@@ -1,38 +0,0 @@
1
- import { GetProps, UploadFile } from 'antd';
2
- import McUploadCmp from '../../../McUploadCmp';
3
- import { RcFile } from 'antd/es/upload';
4
- import { FileCheckedResult } from '../../../../tools/materialVerification';
5
- import { TaskQueue } from '../../../../../Utils';
6
- import './index.less';
7
- type McUploadProps = GetProps<typeof McUploadCmp>;
8
- type FormUploadParams = {
9
- file: RcFile;
10
- fileList: RcFile[];
11
- basicVerifier: (file: RcFile) => Promise<FileCheckedResult>;
12
- getMD5: (file: RcFile) => Promise<string>;
13
- taskQueue: TaskQueue;
14
- setValue?: (value: UploadFile[]) => void;
15
- };
16
- export type CustomUploadFile = (params: FormUploadParams) => Promise<UploadFile[]> | UploadFile[];
17
- type BathParams = {
18
- fileList: RcFile[];
19
- basicVerifier: (file: RcFile) => Promise<FileCheckedResult>;
20
- getMD5: (file: RcFile) => Promise<string>;
21
- taskQueue: TaskQueue;
22
- setValue?: (value: UploadFile[]) => void;
23
- };
24
- export type BatchUploadFile = (params: BathParams) => Promise<UploadFile[]> | UploadFile[];
25
- export type UploadFileProps = {
26
- batchProcess: true;
27
- uploadFile?: BatchUploadFile;
28
- } | {
29
- batchProcess?: false;
30
- uploadFile?: CustomUploadFile;
31
- };
32
- type Props = Omit<McUploadProps, 'beforeUpload' | 'batchProcess'> & {
33
- value?: UploadFile[];
34
- onChange?: (value: UploadFile[]) => void;
35
- uploadOnChange?: McUploadProps['onChange'];
36
- } & UploadFileProps;
37
- declare const UploadForVal: ({ value, onChange, uploadFile, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
38
- export default UploadForVal;
@@ -1,209 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
3
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
6
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
7
- var _excluded = ["value", "onChange", "uploadFile"];
8
- import { message } from 'antd';
9
- import McUploadCmp from "../../../McUploadCmp";
10
- import { isEqual } from 'lodash';
11
- import { useEffect, useState } from 'react';
12
- import { isNumber } from "../../../../tools/materialVerification";
13
- import { E_McUploadTriggerStatus, E_McUploadTriggerType } from "../../../McUploadTrigger";
14
- import "./index.less";
15
- import { jsx as _jsx } from "react/jsx-runtime";
16
- var defaultProps = {
17
- listType: E_McUploadTriggerType.BUTTON
18
- };
19
- var UploadForVal = function UploadForVal(_ref) {
20
- var value = _ref.value,
21
- _onChange = _ref.onChange,
22
- uploadFile = _ref.uploadFile,
23
- rest = _objectWithoutProperties(_ref, _excluded);
24
- // 判断是不是批量操作
25
- var isBatchProcess = rest === null || rest === void 0 ? void 0 : rest.batchProcess;
26
- var _useState = useState([]),
27
- _useState2 = _slicedToArray(_useState, 2),
28
- selfValue = _useState2[0],
29
- setSelfValue = _useState2[1];
30
- var handleUpload = /*#__PURE__*/function () {
31
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(fileList, isBath, info) {
32
- var basicVerifier, getMD5, taskQueue, res;
33
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
34
- while (1) switch (_context2.prev = _context2.next) {
35
- case 0:
36
- basicVerifier = info.basicVerifier, getMD5 = info.getMD5, taskQueue = info.taskQueue;
37
- setSelfValue === null || setSelfValue === void 0 || setSelfValue(function (pre) {
38
- var newVal = fileList.map(function (file) {
39
- return {
40
- uid: file.uid,
41
- name: file.name,
42
- status: E_McUploadTriggerStatus.UPLOADING,
43
- url: ''
44
- };
45
- });
46
- var val = [].concat(_toConsumableArray(pre || []), _toConsumableArray(newVal));
47
- _onChange === null || _onChange === void 0 || _onChange(val);
48
- return val;
49
- });
50
- if (!isBath) {
51
- _context2.next = 9;
52
- break;
53
- }
54
- _context2.next = 5;
55
- return uploadFile === null || uploadFile === void 0 ? void 0 : uploadFile({
56
- fileList: fileList,
57
- basicVerifier: basicVerifier,
58
- getMD5: getMD5,
59
- taskQueue: taskQueue,
60
- setValue: _onChange
61
- });
62
- case 5:
63
- res = _context2.sent;
64
- if (Array.isArray(res)) {
65
- setSelfValue(function (pre) {
66
- var tempVal = pre === null || pre === void 0 ? void 0 : pre.filter(function (item) {
67
- return !fileList.find(function (tempFile) {
68
- return tempFile.uid === item.uid;
69
- });
70
- });
71
- var val = [].concat(_toConsumableArray(tempVal || []), _toConsumableArray(res || []));
72
- _onChange === null || _onChange === void 0 || _onChange(val);
73
- return val;
74
- });
75
- } else {
76
- setSelfValue === null || setSelfValue === void 0 || setSelfValue(function (pre) {
77
- var val = pre === null || pre === void 0 ? void 0 : pre.filter(function (item) {
78
- return !fileList.find(function (tempFile) {
79
- return (tempFile === null || tempFile === void 0 ? void 0 : tempFile.uid) === (item === null || item === void 0 ? void 0 : item.uid);
80
- });
81
- });
82
- _onChange === null || _onChange === void 0 || _onChange(val);
83
- return val;
84
- });
85
- }
86
- _context2.next = 10;
87
- break;
88
- case 9:
89
- fileList.forEach( /*#__PURE__*/function () {
90
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(file) {
91
- var uid, res;
92
- return _regeneratorRuntime().wrap(function _callee$(_context) {
93
- while (1) switch (_context.prev = _context.next) {
94
- case 0:
95
- uid = file === null || file === void 0 ? void 0 : file.uid;
96
- _context.next = 3;
97
- return uploadFile === null || uploadFile === void 0 ? void 0 : uploadFile({
98
- file: file,
99
- fileList: fileList,
100
- basicVerifier: basicVerifier,
101
- getMD5: getMD5,
102
- taskQueue: taskQueue,
103
- setValue: _onChange
104
- });
105
- case 3:
106
- res = _context.sent;
107
- if (Array.isArray(res)) {
108
- setSelfValue(function (pre) {
109
- var tempVal = pre === null || pre === void 0 ? void 0 : pre.filter(function (tempFile) {
110
- return (tempFile === null || tempFile === void 0 ? void 0 : tempFile.uid) !== uid;
111
- });
112
- var val = [].concat(_toConsumableArray(tempVal || []), _toConsumableArray(res || []));
113
- _onChange === null || _onChange === void 0 || _onChange(val);
114
- return val;
115
- });
116
- } else {
117
- setSelfValue(function (pre) {
118
- var tempVal = pre === null || pre === void 0 ? void 0 : pre.filter(function (tempFile) {
119
- return (tempFile === null || tempFile === void 0 ? void 0 : tempFile.uid) !== (file === null || file === void 0 ? void 0 : file.uid);
120
- });
121
- _onChange === null || _onChange === void 0 || _onChange(tempVal);
122
- return tempVal;
123
- });
124
- }
125
- case 5:
126
- case "end":
127
- return _context.stop();
128
- }
129
- }, _callee);
130
- }));
131
- return function (_x4) {
132
- return _ref3.apply(this, arguments);
133
- };
134
- }());
135
- case 10:
136
- case "end":
137
- return _context2.stop();
138
- }
139
- }, _callee2);
140
- }));
141
- return function handleUpload(_x, _x2, _x3) {
142
- return _ref2.apply(this, arguments);
143
- };
144
- }();
145
-
146
- //受控组件
147
- useEffect(function () {
148
- if (!isEqual(value, selfValue) || !(selfValue !== null && selfValue !== void 0 && selfValue.length) && !(value !== null && value !== void 0 && value.length)) {
149
- setSelfValue(value || []);
150
- }
151
- }, [value]);
152
- return /*#__PURE__*/_jsx("div", {
153
- className: "uploadContainer",
154
- style: rest !== null && rest !== void 0 && rest.listType ? {
155
- minHeight: (rest === null || rest === void 0 ? void 0 : rest.listType) === E_McUploadTriggerType.RECTANGLE ? 120 : 102
156
- } : {},
157
- children: /*#__PURE__*/_jsx(McUploadCmp, _objectSpread(_objectSpread(_objectSpread({}, defaultProps), rest), {}, {
158
- fileList: selfValue,
159
- batchProcess: true,
160
- beforeUpload: ( /*#__PURE__*/function () {
161
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(info) {
162
- var fileList, baseLength, shortfall;
163
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
164
- while (1) switch (_context3.prev = _context3.next) {
165
- case 0:
166
- fileList = info.fileList;
167
- if (isNumber(rest === null || rest === void 0 ? void 0 : rest.maxCount) && (rest === null || rest === void 0 ? void 0 : rest.maxCount) >= 0) {
168
- baseLength = (selfValue === null || selfValue === void 0 ? void 0 : selfValue.length) || 0;
169
- shortfall = (rest === null || rest === void 0 ? void 0 : rest.maxCount) - baseLength;
170
- if (shortfall > 0) {
171
- handleUpload(fileList.slice(0, shortfall), !!isBatchProcess, info);
172
- } else {
173
- message.warning("\u6700\u591A\u4E0A\u4F20".concat(rest === null || rest === void 0 ? void 0 : rest.maxCount, "\u4E2A\u6587\u4EF6"));
174
- }
175
- } else {
176
- handleUpload(fileList, !!isBatchProcess, info);
177
- }
178
- return _context3.abrupt("return", false);
179
- case 3:
180
- case "end":
181
- return _context3.stop();
182
- }
183
- }, _callee3);
184
- }));
185
- return function (_x5) {
186
- return _ref4.apply(this, arguments);
187
- };
188
- }()),
189
- onChange: function onChange(info) {
190
- var _rest$uploadOnChange;
191
- var _info$file = info === null || info === void 0 ? void 0 : info.file,
192
- status = _info$file.status;
193
- var isDelete = status === 'removed';
194
- if (isDelete) {
195
- setSelfValue === null || setSelfValue === void 0 || setSelfValue(function (pre) {
196
- var val = (pre === null || pre === void 0 ? void 0 : pre.filter(function (item) {
197
- var _info$file2;
198
- return item.uid !== (info === null || info === void 0 || (_info$file2 = info.file) === null || _info$file2 === void 0 ? void 0 : _info$file2.uid);
199
- })) || [];
200
- _onChange === null || _onChange === void 0 || _onChange(val);
201
- return val;
202
- });
203
- }
204
- rest === null || rest === void 0 || (_rest$uploadOnChange = rest.uploadOnChange) === null || _rest$uploadOnChange === void 0 || _rest$uploadOnChange.call(rest, info);
205
- }
206
- }))
207
- });
208
- };
209
- export default UploadForVal;
@@ -1,6 +0,0 @@
1
- .uploadContainer {
2
- display: flex;
3
- flex-flow: nowrap;
4
- gap: 10px;
5
- align-items: center;
6
- }
@@ -1,7 +0,0 @@
1
- import { Form, GetProps } from 'antd';
2
- import UploadForVal from './comps/UploadForVal';
3
- type McProFormUploadProps = GetProps<typeof Form.Item> & {
4
- fieldProps: GetProps<typeof UploadForVal>;
5
- };
6
- declare const McFormUpload: ({ fieldProps, ...props }: McProFormUploadProps) => import("react/jsx-runtime").JSX.Element;
7
- export default McFormUpload;
@@ -1,29 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
- import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- var _excluded = ["fieldProps"];
5
- import { Form } from 'antd';
6
- import UploadForVal from "./comps/UploadForVal";
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- var McFormUpload = function McFormUpload(_ref) {
9
- var fieldProps = _ref.fieldProps,
10
- props = _objectWithoutProperties(_ref, _excluded);
11
- return /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({}, props), {}, {
12
- rules: [{
13
- validateTrigger: 'onFinsh',
14
- validator: function validator(rule, value) {
15
- if ((value || []).some(function (item) {
16
- return !item.url;
17
- })) {
18
- return Promise.reject('图片未上传完成或存在上传错误');
19
- } else {
20
- return Promise.resolve();
21
- }
22
- }
23
- }].concat(_toConsumableArray(props.rules || [])),
24
- children: /*#__PURE__*/_jsx(UploadForVal, _objectSpread(_objectSpread({}, fieldProps), {}, {
25
- children: props === null || props === void 0 ? void 0 : props.children
26
- }))
27
- }));
28
- };
29
- export default McFormUpload;
@@ -1,49 +0,0 @@
1
- import { GetProps, Upload } from 'antd';
2
- import { RcFile } from 'antd/es/upload';
3
- import { UploadRef } from 'antd/es/upload/Upload';
4
- import { MutableRefObject, ReactNode } from 'react';
5
- import { FileCheckedResult, VerifyConfig } from '../../tools/materialVerification';
6
- import { TaskQueue } from '../../../Utils';
7
- import { E_McUploadTriggerType } from '../McUploadTrigger';
8
- import './index.less';
9
- export type ExtractReturnTypeIfFunction<T> = T extends (...args: any[]) => infer R ? R : never;
10
- type UploadProps = GetProps<typeof Upload>;
11
- type UploadParams = {
12
- file: RcFile;
13
- fileList: RcFile[];
14
- basicVerifier: (file: RcFile) => Promise<FileCheckedResult>;
15
- getMD5: (file: RcFile) => Promise<string | MessageEvent['data']['error'] | ProgressEvent<FileReader>>;
16
- taskQueue: TaskQueue;
17
- };
18
- export type BeforeUpload = (params: UploadParams) => ExtractReturnTypeIfFunction<UploadProps['beforeUpload']>;
19
- type BatchProcessBeforeUploadParams = {
20
- fileList: RcFile[];
21
- basicVerifier: (file: RcFile) => Promise<FileCheckedResult>;
22
- getMD5: (file: RcFile) => Promise<string | MessageEvent['data']['error'] | ProgressEvent<FileReader>>;
23
- taskQueue: TaskQueue;
24
- };
25
- export type BatchProcessBeforeUpload = (params: BatchProcessBeforeUploadParams) => ExtractReturnTypeIfFunction<UploadProps['beforeUpload']>;
26
- export type BeforeUploadProps = {
27
- batchProcess: true;
28
- beforeUpload?: BatchProcessBeforeUpload;
29
- } | {
30
- batchProcess?: false;
31
- beforeUpload?: BeforeUpload;
32
- };
33
- type ExtractParameters<T> = T extends (...args: infer P) => any ? P[0] : undefined;
34
- export type ExtractNonUndefined<T> = T extends undefined ? never : T;
35
- type customRequest = (options: ExtractNonUndefined<ExtractParameters<UploadProps['customRequest']>>, taskQueue: TaskQueue) => void;
36
- export type McUploadProps = Omit<UploadProps, 'beforeUpload' | 'customRequest' | 'listType'> & {
37
- uploadRef?: MutableRefObject<Partial<UploadRef & {
38
- open: () => void;
39
- }> | undefined>;
40
- customRequest?: customRequest;
41
- listType?: E_McUploadTriggerType;
42
- verifierConfig?: VerifyConfig;
43
- verifyErrorMessage?: boolean | string | ((errRes: FileCheckedResult) => string);
44
- taskQueueRef?: MutableRefObject<TaskQueue | undefined>;
45
- maxTaskCounts?: number;
46
- placeholder?: ReactNode;
47
- } & BeforeUploadProps;
48
- declare const McUploadCmp: ({ itemRender, listType, ...rest }: McUploadProps) => import("react/jsx-runtime").JSX.Element;
49
- export default McUploadCmp;