@chaomingd/design 0.0.68

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 (159) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +23 -0
  3. package/dist/esm/CheckGroup/context.d.ts +9 -0
  4. package/dist/esm/CheckGroup/context.js +6 -0
  5. package/dist/esm/CheckGroup/hooks/useCheckGroup.d.ts +21 -0
  6. package/dist/esm/CheckGroup/hooks/useCheckGroup.js +180 -0
  7. package/dist/esm/CheckGroup/index.d.ts +9 -0
  8. package/dist/esm/CheckGroup/index.js +79 -0
  9. package/dist/esm/CheckGroup/type.d.ts +28 -0
  10. package/dist/esm/CheckGroup/type.js +1 -0
  11. package/dist/esm/Grid/index.d.ts +15 -0
  12. package/dist/esm/Grid/index.js +64 -0
  13. package/dist/esm/Grid/index.less +7 -0
  14. package/dist/esm/KaTeXRenderer/index.d.ts +9 -0
  15. package/dist/esm/KaTeXRenderer/index.js +33 -0
  16. package/dist/esm/KaTeXRenderer/index.less +0 -0
  17. package/dist/esm/PixelPlayer/index.d.ts +28 -0
  18. package/dist/esm/PixelPlayer/index.js +118 -0
  19. package/dist/esm/PixelPlayer/index.less +29 -0
  20. package/dist/esm/PixelPlayer/lib/peer-stream.d.ts +62 -0
  21. package/dist/esm/PixelPlayer/lib/peer-stream.js +876 -0
  22. package/dist/esm/PixelPlayer/useAutoLayoutContainer.d.ts +2 -0
  23. package/dist/esm/PixelPlayer/useAutoLayoutContainer.js +53 -0
  24. package/dist/esm/PixelPlayer/useVideoWithCustomEvent.d.ts +5 -0
  25. package/dist/esm/PixelPlayer/useVideoWithCustomEvent.js +37 -0
  26. package/dist/esm/Resizer/index.d.ts +17 -0
  27. package/dist/esm/Resizer/index.js +73 -0
  28. package/dist/esm/Resizer/index.less +73 -0
  29. package/dist/esm/SetupAntApp/index.d.ts +1 -0
  30. package/dist/esm/SetupAntApp/index.js +10 -0
  31. package/dist/esm/Transition/index.d.ts +4 -0
  32. package/dist/esm/Transition/index.js +132 -0
  33. package/dist/esm/Transition/type.d.ts +33 -0
  34. package/dist/esm/Transition/type.js +12 -0
  35. package/dist/esm/Transition/utils.d.ts +6 -0
  36. package/dist/esm/Transition/utils.js +15 -0
  37. package/dist/esm/UploadFile/components/IconButton/index.d.ts +11 -0
  38. package/dist/esm/UploadFile/components/IconButton/index.js +26 -0
  39. package/dist/esm/UploadFile/components/IconButton/index.less +58 -0
  40. package/dist/esm/UploadFile/components/Slash.d.ts +2 -0
  41. package/dist/esm/UploadFile/components/Slash.js +15 -0
  42. package/dist/esm/UploadFile/components/SvgIcons.d.ts +11 -0
  43. package/dist/esm/UploadFile/components/SvgIcons.js +141 -0
  44. package/dist/esm/UploadFile/hooks/useUploadModel.d.ts +16 -0
  45. package/dist/esm/UploadFile/hooks/useUploadModel.js +376 -0
  46. package/dist/esm/UploadFile/index.d.ts +4 -0
  47. package/dist/esm/UploadFile/index.js +277 -0
  48. package/dist/esm/UploadFile/index.less +274 -0
  49. package/dist/esm/UploadFile/type.d.ts +63 -0
  50. package/dist/esm/UploadFile/type.js +1 -0
  51. package/dist/esm/UploadFile/utils/formatBitString.d.ts +1 -0
  52. package/dist/esm/UploadFile/utils/formatBitString.js +9 -0
  53. package/dist/esm/UploadFile/utils/getExt.d.ts +1 -0
  54. package/dist/esm/UploadFile/utils/getExt.js +6 -0
  55. package/dist/esm/UploadFile/utils/isImage.d.ts +1 -0
  56. package/dist/esm/UploadFile/utils/isImage.js +8 -0
  57. package/dist/esm/UploadFile/utils/normalizeExt.d.ts +1 -0
  58. package/dist/esm/UploadFile/utils/normalizeExt.js +4 -0
  59. package/dist/esm/UploadFile/utils/validateFileTypes.d.ts +13 -0
  60. package/dist/esm/UploadFile/utils/validateFileTypes.js +83 -0
  61. package/dist/esm/UploadFile/utils/validateRule.d.ts +3 -0
  62. package/dist/esm/UploadFile/utils/validateRule.js +22 -0
  63. package/dist/esm/UploadFile/utils/validateUpload.d.ts +5 -0
  64. package/dist/esm/UploadFile/utils/validateUpload.js +35 -0
  65. package/dist/esm/constant/index.d.ts +7 -0
  66. package/dist/esm/constant/index.js +18 -0
  67. package/dist/esm/constants/cssPrefix.d.ts +1 -0
  68. package/dist/esm/constants/cssPrefix.js +1 -0
  69. package/dist/esm/getAntApp/index.d.ts +8 -0
  70. package/dist/esm/getAntApp/index.js +17 -0
  71. package/dist/esm/index.d.ts +10 -0
  72. package/dist/esm/index.js +10 -0
  73. package/dist/esm/interface.d.ts +1 -0
  74. package/dist/esm/interface.js +1 -0
  75. package/dist/esm/styles/cssVar.less +28 -0
  76. package/dist/esm/styles/reset.css +3 -0
  77. package/dist/esm/styles/var.d.ts +1 -0
  78. package/dist/esm/styles/var.js +1 -0
  79. package/dist/esm/styles/var.less +2 -0
  80. package/dist/esm/variable.less +52 -0
  81. package/dist/lib/CheckGroup/context.d.ts +9 -0
  82. package/dist/lib/CheckGroup/context.js +12 -0
  83. package/dist/lib/CheckGroup/hooks/useCheckGroup.d.ts +21 -0
  84. package/dist/lib/CheckGroup/hooks/useCheckGroup.js +164 -0
  85. package/dist/lib/CheckGroup/index.d.ts +9 -0
  86. package/dist/lib/CheckGroup/index.js +93 -0
  87. package/dist/lib/CheckGroup/type.d.ts +28 -0
  88. package/dist/lib/CheckGroup/type.js +5 -0
  89. package/dist/lib/Grid/index.d.ts +15 -0
  90. package/dist/lib/Grid/index.js +77 -0
  91. package/dist/lib/Grid/index.less +7 -0
  92. package/dist/lib/KaTeXRenderer/index.d.ts +9 -0
  93. package/dist/lib/KaTeXRenderer/index.js +41 -0
  94. package/dist/lib/KaTeXRenderer/index.less +0 -0
  95. package/dist/lib/PixelPlayer/index.d.ts +28 -0
  96. package/dist/lib/PixelPlayer/index.js +108 -0
  97. package/dist/lib/PixelPlayer/index.less +29 -0
  98. package/dist/lib/PixelPlayer/lib/peer-stream.d.ts +62 -0
  99. package/dist/lib/PixelPlayer/lib/peer-stream.js +707 -0
  100. package/dist/lib/PixelPlayer/useAutoLayoutContainer.d.ts +2 -0
  101. package/dist/lib/PixelPlayer/useAutoLayoutContainer.js +60 -0
  102. package/dist/lib/PixelPlayer/useVideoWithCustomEvent.d.ts +5 -0
  103. package/dist/lib/PixelPlayer/useVideoWithCustomEvent.js +35 -0
  104. package/dist/lib/Resizer/index.d.ts +17 -0
  105. package/dist/lib/Resizer/index.js +75 -0
  106. package/dist/lib/Resizer/index.less +73 -0
  107. package/dist/lib/SetupAntApp/index.d.ts +1 -0
  108. package/dist/lib/SetupAntApp/index.js +16 -0
  109. package/dist/lib/Transition/index.d.ts +4 -0
  110. package/dist/lib/Transition/index.js +128 -0
  111. package/dist/lib/Transition/type.d.ts +33 -0
  112. package/dist/lib/Transition/type.js +18 -0
  113. package/dist/lib/Transition/utils.d.ts +6 -0
  114. package/dist/lib/Transition/utils.js +22 -0
  115. package/dist/lib/UploadFile/components/IconButton/index.d.ts +11 -0
  116. package/dist/lib/UploadFile/components/IconButton/index.js +29 -0
  117. package/dist/lib/UploadFile/components/IconButton/index.less +58 -0
  118. package/dist/lib/UploadFile/components/Slash.d.ts +2 -0
  119. package/dist/lib/UploadFile/components/Slash.js +22 -0
  120. package/dist/lib/UploadFile/components/SvgIcons.d.ts +11 -0
  121. package/dist/lib/UploadFile/components/SvgIcons.js +158 -0
  122. package/dist/lib/UploadFile/hooks/useUploadModel.d.ts +16 -0
  123. package/dist/lib/UploadFile/hooks/useUploadModel.js +306 -0
  124. package/dist/lib/UploadFile/index.d.ts +4 -0
  125. package/dist/lib/UploadFile/index.js +280 -0
  126. package/dist/lib/UploadFile/index.less +274 -0
  127. package/dist/lib/UploadFile/type.d.ts +63 -0
  128. package/dist/lib/UploadFile/type.js +5 -0
  129. package/dist/lib/UploadFile/utils/formatBitString.d.ts +1 -0
  130. package/dist/lib/UploadFile/utils/formatBitString.js +15 -0
  131. package/dist/lib/UploadFile/utils/getExt.d.ts +1 -0
  132. package/dist/lib/UploadFile/utils/getExt.js +12 -0
  133. package/dist/lib/UploadFile/utils/isImage.d.ts +1 -0
  134. package/dist/lib/UploadFile/utils/isImage.js +14 -0
  135. package/dist/lib/UploadFile/utils/normalizeExt.d.ts +1 -0
  136. package/dist/lib/UploadFile/utils/normalizeExt.js +10 -0
  137. package/dist/lib/UploadFile/utils/validateFileTypes.d.ts +13 -0
  138. package/dist/lib/UploadFile/utils/validateFileTypes.js +87 -0
  139. package/dist/lib/UploadFile/utils/validateRule.d.ts +3 -0
  140. package/dist/lib/UploadFile/utils/validateRule.js +28 -0
  141. package/dist/lib/UploadFile/utils/validateUpload.d.ts +5 -0
  142. package/dist/lib/UploadFile/utils/validateUpload.js +31 -0
  143. package/dist/lib/constant/index.d.ts +7 -0
  144. package/dist/lib/constant/index.js +24 -0
  145. package/dist/lib/constants/cssPrefix.d.ts +1 -0
  146. package/dist/lib/constants/cssPrefix.js +7 -0
  147. package/dist/lib/getAntApp/index.d.ts +8 -0
  148. package/dist/lib/getAntApp/index.js +27 -0
  149. package/dist/lib/index.d.ts +10 -0
  150. package/dist/lib/index.js +69 -0
  151. package/dist/lib/interface.d.ts +1 -0
  152. package/dist/lib/interface.js +5 -0
  153. package/dist/lib/styles/cssVar.less +28 -0
  154. package/dist/lib/styles/reset.css +3 -0
  155. package/dist/lib/styles/var.d.ts +1 -0
  156. package/dist/lib/styles/var.js +7 -0
  157. package/dist/lib/styles/var.less +2 -0
  158. package/dist/lib/variable.less +52 -0
  159. package/package.json +54 -0
@@ -0,0 +1,141 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import React from 'react';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ import { jsxs as _jsxs } from "react/jsx-runtime";
5
+ export var SlashSvg = function SlashSvg(props) {
6
+ return /*#__PURE__*/_jsx("svg", _objectSpread(_objectSpread({
7
+ width: "1em",
8
+ height: "1em",
9
+ viewBox: "0 0 16 16",
10
+ fill: "currentColor",
11
+ xmlns: "http://www.w3.org/2000/svg"
12
+ }, props), {}, {
13
+ children: /*#__PURE__*/_jsx("path", {
14
+ d: "M4.06689 13.8119L11.0669 1.6875L11.9329 2.1875L4.93292 14.3119L4.06689 13.8119Z"
15
+ })
16
+ }));
17
+ };
18
+ export var ZipSvg = function ZipSvg(props) {
19
+ return /*#__PURE__*/_jsxs("svg", _objectSpread(_objectSpread({}, props), {}, {
20
+ viewBox: "0 0 66 72",
21
+ fill: "none",
22
+ xmlns: "http://www.w3.org/2000/svg",
23
+ children: [/*#__PURE__*/_jsx("path", {
24
+ d: "M42.5 3H5C3.89543 3 3 3.89543 3 5V67C3 68.1046 3.89543 69 5 69H51.5C52.6046 69 53.5 68.1046 53.5 67V15.5L42.5 3Z",
25
+ stroke: "currentColor",
26
+ strokeWidth: "2"
27
+ }), /*#__PURE__*/_jsx("path", {
28
+ d: "M42.5 15.5V3L53.5 15.5H42.5Z",
29
+ stroke: "currentColor",
30
+ strokeWidth: "2",
31
+ strokeLinejoin: "round"
32
+ }), /*#__PURE__*/_jsx("rect", {
33
+ x: "19.5",
34
+ y: "33",
35
+ width: "44",
36
+ height: "24",
37
+ rx: "2",
38
+ fill: "currentColor"
39
+ }), /*#__PURE__*/_jsx("path", {
40
+ d: "M31.256 50V48.306L36.324 41.964L36.31 41.88H31.536V40.284H38.55V41.908L33.426 48.306V48.39H38.9V50H31.256ZM40.6168 50V40.284H42.4508V50H40.6168ZM44.7457 50V40.284H47.8537C50.7097 40.284 51.5917 41.222 51.5917 43.518C51.5917 45.968 50.4997 46.85 47.8537 46.85H46.5797V50H44.7457ZM46.5797 45.366H47.6297C49.1977 45.366 49.7157 44.96 49.7157 43.546C49.7157 42.216 49.1837 41.768 47.6297 41.768H46.5797V45.366Z",
41
+ fill: "white"
42
+ })]
43
+ }));
44
+ };
45
+ export var RarSvg = function RarSvg(props) {
46
+ return /*#__PURE__*/_jsxs("svg", _objectSpread(_objectSpread({
47
+ viewBox: "0 0 66 72",
48
+ fill: "none",
49
+ xmlns: "http://www.w3.org/2000/svg"
50
+ }, props), {}, {
51
+ children: [/*#__PURE__*/_jsx("path", {
52
+ d: "M42.5 3H5C3.89543 3 3 3.89543 3 5V67C3 68.1046 3.89543 69 5 69H51.5C52.6046 69 53.5 68.1046 53.5 67V15.5L42.5 3Z",
53
+ stroke: "currentColor",
54
+ strokeWidth: "2"
55
+ }), /*#__PURE__*/_jsx("path", {
56
+ d: "M42.5 15.5V3L53.5 15.5H42.5Z",
57
+ stroke: "currentColor",
58
+ strokeWidth: "2",
59
+ strokeLinejoin: "round"
60
+ }), /*#__PURE__*/_jsx("rect", {
61
+ x: "19.5",
62
+ y: "33",
63
+ width: "44",
64
+ height: "24",
65
+ rx: "2",
66
+ fill: "currentColor"
67
+ }), /*#__PURE__*/_jsx("path", {
68
+ d: "M36.32 50H34.164L31.742 46.332H31.672H30.482V50H28.648V40.284H31.672C34.304 40.284 35.41 41.096 35.41 43.294C35.41 44.932 34.822 45.772 33.534 46.122L36.32 50ZM30.482 44.932H31.42C32.974 44.932 33.576 44.68 33.576 43.294C33.576 42.034 32.974 41.768 31.42 41.768H30.482V44.932ZM44.2817 50L43.3857 47.424H39.3257L38.4017 50H36.5117L40.1517 40.284H42.6157L46.2277 50H44.2817ZM39.8717 45.884H42.8397L41.4537 41.922H41.2857L39.8717 45.884ZM55.1188 50H52.9628L50.5408 46.332H50.4708H49.2808V50H47.4468V40.284H50.4708C53.1028 40.284 54.2088 41.096 54.2088 43.294C54.2088 44.932 53.6208 45.772 52.3328 46.122L55.1188 50ZM49.2808 44.932H50.2188C51.7728 44.932 52.3748 44.68 52.3748 43.294C52.3748 42.034 51.7728 41.768 50.2188 41.768H49.2808V44.932Z",
69
+ fill: "white"
70
+ })]
71
+ }));
72
+ };
73
+ export var DocSvg = function DocSvg(props) {
74
+ return /*#__PURE__*/_jsx("svg", _objectSpread(_objectSpread({}, props), {}, {
75
+ viewBox: "0 0 1024 1024",
76
+ version: "1.1",
77
+ xmlns: "http://www.w3.org/2000/svg",
78
+ width: "100%",
79
+ children: /*#__PURE__*/_jsx("path", {
80
+ d: "M927.68 698.912c0-0.576 0.32-1.056 0.32-1.664v-564.32C928 77.28 883.552 32 828.928 32H195.04C140.448 32 96 77.28 96 132.928v758.144C96 946.72 140.448 992 195.04 992h480.032a31.872 31.872 0 0 0 20.96-7.84l153.856-133.632a32 32 0 1 0-41.92-48.32L704 892.512V772.96c0-20.384 15.712-36.96 35.072-36.96h157.632a32 32 0 0 0 32-32c-0.032-1.792-0.768-3.36-1.024-5.088zM640 772.928V928H195.04c-19.328 0-35.04-16.576-35.04-36.928V132.928C160 112.576 175.712 96 195.04 96h633.888C848.288 96 864 112.576 864 132.928V672H739.072C684.448 672 640 717.28 640 772.928zM731.36 288h-5.216c-9.536 0-17.504 4.192-23.84 12.576-22.56 40.768-50.464 95.296-83.712 163.52L548.32 322.72c-8.352-23.168-19.936-34.72-34.688-34.72h-7.808c-10.112 0-18.656 5.056-25.6 15.168-36.736 69.408-64.032 123.04-81.984 160.928L327.968 322.72C319.904 299.552 308.32 288 293.312 288h-6.944l-6.528 1.728c-15.872 8.096-23.84 17.632-23.84 28.64v7.808l0.864 5.216c43.68 92.256 77.792 162.208 102.368 209.92C369.056 564.448 380.64 576 393.92 576H400c8.96 0 17.344-4.192 25.152-12.576l83.264-164.384h0.864c30.368 63.904 51.776 107.712 64.192 131.424 12.736 30.368 26.336 45.536 40.8 45.536h6.08c9.824 0 18.784-5.056 26.88-15.168l116.256-231.168v-10.432l-0.864-3.456C752.768 297.248 742.368 288 731.36 288z",
81
+ fill: "currentColor"
82
+ })
83
+ }));
84
+ };
85
+ export var PdfSvg = function PdfSvg(props) {
86
+ return /*#__PURE__*/_jsxs("svg", _objectSpread(_objectSpread({}, props), {}, {
87
+ viewBox: "0 0 1024 1024",
88
+ version: "1.1",
89
+ xmlns: "http://www.w3.org/2000/svg",
90
+ width: "100%",
91
+ children: [/*#__PURE__*/_jsx("path", {
92
+ d: "M582.4 864H170.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V170.666667c0-6.4 4.266667-10.666667 10.666667-10.666667h309.333333V320c0 40.533333 34.133333 74.666667 74.666667 74.666667h160v38.4c0 17.066667 14.933333 32 32 32s32-14.933333 32-32V298.666667c0-8.533333-4.266667-17.066667-8.533334-23.466667l-170.666666-170.666667c-6.4-6.4-14.933333-8.533333-23.466667-8.533333H170.666667C130.133333 96 96 130.133333 96 170.666667v682.666666c0 40.533333 34.133333 74.666667 74.666667 74.666667h411.733333c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32z m132.266667-550.4v17.066667H554.666667c-6.4 0-10.666667-4.266667-10.666667-10.666667V160h19.2l151.466667 153.6z",
93
+ fill: "currentColor"
94
+ }), /*#__PURE__*/_jsx("path", {
95
+ d: "M332.8 533.333333c-12.8 0-19.2 2.133333-25.6 6.4-6.4 4.266667-8.533333 12.8-8.533333 23.466667v206.933333c0 6.4 2.133333 12.8 6.4 19.2 4.266667 4.266667 10.666667 8.533333 21.333333 8.533334s17.066667-4.266667 21.333333-8.533334c4.266667-4.266667 6.4-10.666667 6.4-19.2v-64h32c57.6 0 89.6-29.866667 89.6-87.466666 0-27.733333-8.533333-51.2-23.466666-64-14.933333-14.933333-36.266667-21.333333-66.133334-21.333334h-53.333333z m87.466667 85.333334c0 12.8-2.133333 23.466667-8.533334 27.733333-4.266667 4.266667-14.933333 8.533333-27.733333 8.533333h-32v-70.4H384c12.8 0 21.333333 2.133333 27.733333 8.533334 6.4 4.266667 8.533333 12.8 8.533334 25.6zM667.733333 571.733333c-8.533333-12.8-21.333333-21.333333-34.133333-29.866666-14.933333-4.266667-32-8.533333-51.2-8.533334h-61.866667c-8.533333 0-17.066667 0-23.466666 8.533334-2.133333 4.266667-4.266667 10.666667-4.266667 19.2V768c0 8.533333 2.133333 14.933333 4.266667 19.2 6.4 8.533333 14.933333 8.533333 23.466666 8.533333h64c19.2 0 34.133333-4.266667 49.066667-10.666666 12.8-6.4 25.6-17.066667 34.133333-29.866667 8.533333-12.8 14.933333-25.6 19.2-42.666667 4.266667-14.933333 6.4-32 6.4-49.066666 0-17.066667-2.133333-34.133333-6.4-49.066667-4.266667-14.933333-10.666667-29.866667-19.2-42.666667z m-42.666666 153.6c-8.533333 12.8-21.333333 19.2-38.4 19.2h-38.4v-160H576c21.333333 0 38.4 6.4 46.933333 19.2 10.666667 12.8 14.933333 34.133333 14.933334 59.733334 2.133333 27.733333-4.266667 46.933333-12.8 61.866666zM851.2 533.333333h-106.666667c-8.533333 0-17.066667 2.133333-21.333333 6.4-6.4 4.266667-8.533333 12.8-8.533333 21.333334v209.066666c0 6.4 2.133333 12.8 6.4 17.066667 4.266667 6.4 10.666667 8.533333 21.333333 8.533333 8.533333 0 17.066667-2.133333 21.333333-8.533333 2.133333-4.266667 6.4-8.533333 6.4-19.2v-85.333333h72.533334c12.8 0 23.466667-6.4 25.6-17.066667 2.133333-8.533333 2.133333-14.933333 0-17.066667-2.133333-4.266667-6.4-17.066667-25.6-17.066666H768v-49.066667h81.066667c8.533333 0 14.933333-2.133333 19.2-4.266667 4.266667-2.133333 8.533333-8.533333 8.533333-21.333333 2.133333-12.8-8.533333-23.466667-25.6-23.466667z",
96
+ fill: "currentColor"
97
+ })]
98
+ }));
99
+ };
100
+ export var TxtSvg = function TxtSvg(props) {
101
+ return /*#__PURE__*/_jsx("svg", _objectSpread(_objectSpread({}, props), {}, {
102
+ viewBox: "0 0 1024 1024",
103
+ version: "1.1",
104
+ xmlns: "http://www.w3.org/2000/svg",
105
+ width: "100%",
106
+ children: /*#__PURE__*/_jsx("path", {
107
+ d: "M249.856 389.12v-178.176c0-45.056 36.864-81.92 81.92-81.92h456.704l163.84 167.936v337.92c0 12.288-8.192 20.48-20.48 20.48s-20.48-8.192-20.48-20.48V337.92h-102.4c-34.816 0-61.44-26.624-61.44-61.44v-106.496h-415.744c-22.528 0-40.96 18.432-40.96 40.96v178.176h456.704c22.528 0 40.96 18.432 40.96 40.96v286.72c0 22.528-18.432 40.96-40.96 40.96h-456.704v61.44c0 22.528 18.432 40.96 40.96 40.96h538.624c22.528 0 40.96-18.432 40.96-40.96v-61.44c0-12.288 8.192-20.48 20.48-20.48s20.48 8.192 20.48 20.48v61.44c0 45.056-36.864 81.92-81.92 81.92h-538.624c-45.056 0-81.92-36.864-81.92-81.92v-61.44h-137.216c-22.528 0-40.96-18.432-40.96-40.96v-286.72c0-22.528 18.432-40.96 40.96-40.96h137.216z m538.624-202.752v90.112c0 10.24 8.192 20.48 20.48 20.48h86.016l-106.496-110.592z m-466.944 323.584v-30.72h-172.032v30.72h67.584v167.936h38.912v-167.936h65.536z m131.072 69.632l67.584-100.352h-45.056c-22.528 36.864-34.816 59.392-36.864 63.488-2.048 2.048-4.096 6.144-6.144 10.24-2.048 4.096-4.096 4.096-4.096 6.144 0-2.048-2.048-4.096-4.096-8.192s-4.096-6.144-4.096-6.144c-2.048-4.096-14.336-24.576-38.912-63.488h-45.056l67.584 98.304-75.776 100.352h45.056c28.672-43.008 45.056-65.536 45.056-67.584 4.096-6.144 6.144-10.24 8.192-14.336 2.048 4.096 4.096 8.192 8.192 12.288 2.048 2.048 16.384 24.576 45.056 67.584h47.104l-73.728-98.304z m253.952-69.632v-30.72h-172.032v30.72h67.584v167.936h38.912v-167.936h65.536z",
108
+ fill: "currentColor"
109
+ })
110
+ }));
111
+ };
112
+ export var CloseSvg = function CloseSvg(props) {
113
+ return /*#__PURE__*/_jsx("svg", _objectSpread(_objectSpread({
114
+ width: "1em",
115
+ height: "1em",
116
+ viewBox: "0 0 16 16",
117
+ fill: "currentColor",
118
+ xmlns: "http://www.w3.org/2000/svg"
119
+ }, props), {}, {
120
+ children: /*#__PURE__*/_jsx("path", {
121
+ d: "M15 8C15 4.13401 11.866 1 8 1C4.13401 0.999998 1 4.134 1 8C0.999998 11.866 4.134 15 8 15C11.866 15 15 11.866 15 8ZM5.67091 4.94754L8.00001 7.29075L10.3291 4.94754L11.0384 5.65251L8.70499 8L11.0383 10.3475L10.3291 11.0525L8.00001 8.70925L5.67092 11.0525L4.96168 10.3475L7.29503 8L4.96167 5.65251L5.67091 4.94754Z"
122
+ })
123
+ }));
124
+ };
125
+ export var DeleteSvg = function DeleteSvg(props) {
126
+ return /*#__PURE__*/_jsxs("svg", _objectSpread(_objectSpread({
127
+ width: "1em",
128
+ height: "1em",
129
+ viewBox: "0 0 16 16",
130
+ fill: "currentColor",
131
+ xmlns: "http://www.w3.org/2000/svg"
132
+ }, props), {}, {
133
+ children: [/*#__PURE__*/_jsx("path", {
134
+ d: "M6 12V6H7V12H6Z"
135
+ }), /*#__PURE__*/_jsx("path", {
136
+ d: "M9 6V12H10V6H9Z"
137
+ }), /*#__PURE__*/_jsx("path", {
138
+ d: "M10.5 3H14V4H13V14C13 14.5523 12.5523 15 12 15H4C3.44772 15 3 14.5523 3 14V4H2V3H5.5L5.5 1.8C5.5 1.35817 5.85817 1 6.3 1H9.7C10.1418 1 10.5 1.35817 10.5 1.8V3ZM6.5 3H9.5L9.5 2L6.5 2V3ZM4 4V14H12V4H4Z"
139
+ })]
140
+ }));
141
+ };
@@ -0,0 +1,16 @@
1
+ import { FileListItemProps, UploadFileProps } from '../type';
2
+ export interface UploadState {
3
+ value: FileListItemProps[];
4
+ dragEnter: boolean;
5
+ }
6
+ export declare function useUploadModel(props: UploadFileProps): {
7
+ model: import("@chaomingd/store").Model<UploadState, {
8
+ [x: string]: any;
9
+ }, Record<string, any>>;
10
+ onDragOver: (e: any) => void;
11
+ handleUploadFiles: (files: ArrayLike<File>, options?: {
12
+ replace: boolean;
13
+ replaceId: string;
14
+ }) => Promise<void>;
15
+ onDeleteFileList: (uid: string) => void;
16
+ };
@@ -0,0 +1,376 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
5
+ import { useModel } from '@chaomingd/store';
6
+ import { getAntApp } from "../..";
7
+ import { AsyncTaskQueue, uuid } from '@chaomingd/utils';
8
+ import { message } from 'antd';
9
+ import { useMemo, useRef } from 'react';
10
+ import { formatBitString } from "../utils/formatBitString";
11
+ import { getFileInfo, validateFileTypes } from "../utils/validateFileTypes";
12
+ import { useCreation, useMemoizedFn } from 'ahooks';
13
+ export function useUploadModel(props) {
14
+ var dragOverTimer = useRef();
15
+ var asyncTaskQueue = useCreation(function () {
16
+ return new AsyncTaskQueue(props.uploadConcurrency || 3);
17
+ }, []);
18
+ var model = useModel({
19
+ state: {
20
+ value: [],
21
+ dragEnter: false
22
+ }
23
+ });
24
+ var _props$maxCount = props.maxCount,
25
+ maxCount = _props$maxCount === void 0 ? 1 : _props$maxCount;
26
+ var hasValue = ('value' in props);
27
+ useMemo(function () {
28
+ if (hasValue) {
29
+ if (Array.isArray(props.value)) {
30
+ var value = props.value;
31
+ if (maxCount > 0 && value.length > maxCount) {
32
+ value = value.slice(0, maxCount);
33
+ }
34
+ model.setState({
35
+ value: value
36
+ }, {
37
+ silent: true
38
+ });
39
+ }
40
+ }
41
+ }, [props.value, hasValue]);
42
+ var handleOnChange = useMemoizedFn(function (files) {
43
+ var _props$onChange;
44
+ model.setState({
45
+ value: files
46
+ }, {
47
+ silent: hasValue
48
+ });
49
+ (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, files);
50
+ });
51
+
52
+ // 处理拖拽进入
53
+ var onDragOver = function onDragOver(e) {
54
+ e.preventDefault();
55
+ clearTimeout(dragOverTimer.current);
56
+ var _model$getState = model.getState(),
57
+ dragEnter = _model$getState.dragEnter;
58
+ if (!dragEnter) {
59
+ model.setState({
60
+ dragEnter: true
61
+ });
62
+ }
63
+ dragOverTimer.current = setTimeout(function () {
64
+ model.setState({
65
+ dragEnter: false
66
+ });
67
+ }, 100);
68
+ };
69
+
70
+ // 更新单个文件列表数据
71
+ var updateFileItemByUid = function updateFileItemByUid(uid, data) {
72
+ var _model$getState2 = model.getState(),
73
+ fileList = _model$getState2.value;
74
+ handleOnChange(fileList.map(function (item) {
75
+ if (item.uid === uid) {
76
+ return _objectSpread(_objectSpread({}, item), data);
77
+ }
78
+ return item;
79
+ }));
80
+ };
81
+
82
+ // 处理上传前校验
83
+ var handleBeforeUpload = /*#__PURE__*/function () {
84
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(file) {
85
+ var accepts, maxFileSize, _yield$validateFileTy, isValid;
86
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
87
+ while (1) switch (_context.prev = _context.next) {
88
+ case 0:
89
+ accepts = props.accepts || [];
90
+ maxFileSize = props.maxFileSize || -1;
91
+ if (!accepts) {
92
+ _context.next = 9;
93
+ break;
94
+ }
95
+ _context.next = 5;
96
+ return validateFileTypes(file, accepts);
97
+ case 5:
98
+ _yield$validateFileTy = _context.sent;
99
+ isValid = _yield$validateFileTy.isValid;
100
+ if (isValid) {
101
+ _context.next = 9;
102
+ break;
103
+ }
104
+ return _context.abrupt("return", Promise.reject(new Error("\u6587\u4EF6\u683C\u5F0F\u4E0D\u6B63\u786E\uFF01\u53EA\u652F\u6301 ".concat(accepts.join(', '), " \u7C7B\u578B\u7684\u6587\u4EF6"))));
105
+ case 9:
106
+ if (!(maxFileSize > 0)) {
107
+ _context.next = 12;
108
+ break;
109
+ }
110
+ if (!(file.size > maxFileSize)) {
111
+ _context.next = 12;
112
+ break;
113
+ }
114
+ return _context.abrupt("return", Promise.reject(new Error("\u6587\u4EF6\u5927\u5C0F\u8D85\u51FA ".concat(formatBitString(maxFileSize)))));
115
+ case 12:
116
+ if (!props.beforeUpload) {
117
+ _context.next = 15;
118
+ break;
119
+ }
120
+ _context.next = 15;
121
+ return props.beforeUpload(file);
122
+ case 15:
123
+ case "end":
124
+ return _context.stop();
125
+ }
126
+ }, _callee);
127
+ }));
128
+ return function handleBeforeUpload(_x) {
129
+ return _ref.apply(this, arguments);
130
+ };
131
+ }();
132
+
133
+ // 文件内容校验
134
+ function handleValidation(fileListItem) {
135
+ var _validation$validateR;
136
+ var validation = props.validation;
137
+ var onValidationProgress = function onValidationProgress(percent) {
138
+ updateFileItemByUid(fileListItem.uid, {
139
+ validationPercent: percent
140
+ });
141
+ };
142
+ var onValidationSuccess = function onValidationSuccess() {
143
+ updateFileItemByUid(fileListItem.uid, {
144
+ validationStatus: 'success'
145
+ });
146
+ };
147
+ var onValidationError = function onValidationError(e) {
148
+ updateFileItemByUid(fileListItem.uid, {
149
+ validationStatus: 'error',
150
+ validationError: e
151
+ });
152
+ };
153
+ updateFileItemByUid(fileListItem.uid, {
154
+ validationStatus: 'validating'
155
+ });
156
+ var controller = new AbortController();
157
+ var abort = function abort() {
158
+ controller.abort();
159
+ };
160
+ fileListItem.validationAbort = abort;
161
+ var res = (_validation$validateR = validation.validateRequest) === null || _validation$validateR === void 0 ? void 0 : _validation$validateR.call(validation, {
162
+ onProgress: onValidationProgress,
163
+ onError: onValidationError,
164
+ onSuccess: onValidationSuccess,
165
+ fileItem: fileListItem,
166
+ axiosRequestConfig: {
167
+ signal: controller.signal
168
+ }
169
+ });
170
+ if (res !== null && res !== void 0 && res.abort) {
171
+ fileListItem.validationAbort = abort;
172
+ }
173
+ }
174
+
175
+ // 处理上传逻辑
176
+ var handleUploadFiles = /*#__PURE__*/function () {
177
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(files, options) {
178
+ var Message, fileListPromises, handleUploadFile, fileList, _model$getState3, currentFileList, remainCount;
179
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
180
+ while (1) switch (_context3.prev = _context3.next) {
181
+ case 0:
182
+ handleUploadFile = function _handleUploadFile(fileListItem) {
183
+ return new Promise(function (resolve, reject) {
184
+ var formData = new FormData();
185
+ formData.append(props.name || 'file', fileListItem.file);
186
+ if (props.data) {
187
+ Object.keys(props.data).forEach(function (key) {
188
+ formData.append(key, props.data[key]);
189
+ });
190
+ }
191
+ // 取消上传
192
+ var controller = new AbortController();
193
+ var abort = function abort() {
194
+ controller.abort();
195
+ };
196
+ fileListItem.abort = abort;
197
+ var onProgress = function onProgress(event) {
198
+ updateFileItemByUid(fileListItem.uid, {
199
+ percent: event.percent
200
+ });
201
+ };
202
+ var onError = function onError(e, body) {
203
+ updateFileItemByUid(fileListItem.uid, {
204
+ status: 'error',
205
+ response: body,
206
+ error: e
207
+ });
208
+ reject(e);
209
+ };
210
+ var onSuccess = function onSuccess(body) {
211
+ var url;
212
+ if (typeof body === 'string') {
213
+ url = body;
214
+ } else {
215
+ url = (body === null || body === void 0 ? void 0 : body.url) || '';
216
+ }
217
+ updateFileItemByUid(fileListItem.uid, {
218
+ status: 'done',
219
+ response: body,
220
+ url: url
221
+ });
222
+ resolve(true);
223
+
224
+ // 开始校验文件内容
225
+ if (props.validation) {
226
+ handleValidation(fileListItem);
227
+ }
228
+ };
229
+ updateFileItemByUid(fileListItem.uid, {
230
+ status: 'uploading'
231
+ });
232
+ if (props.customRequest) {
233
+ var customeRequestReturnValue = props.customRequest({
234
+ onError: onError,
235
+ onProgress: onProgress,
236
+ signal: controller.signal,
237
+ file: fileListItem.file,
238
+ fileItem: fileListItem,
239
+ onSuccess: onSuccess
240
+ });
241
+ if (customeRequestReturnValue !== null && customeRequestReturnValue !== void 0 && customeRequestReturnValue.abort) {
242
+ fileListItem.abort = customeRequestReturnValue.abort;
243
+ }
244
+ } else if (props.uploadRequest) {
245
+ var _props$uploadRequest;
246
+ (_props$uploadRequest = props.uploadRequest) === null || _props$uploadRequest === void 0 || _props$uploadRequest.call(props, formData, {
247
+ onUploadProgress: function onUploadProgress(_ref4) {
248
+ var progress = _ref4.progress;
249
+ onProgress({
250
+ percent: (progress || 0) * 100
251
+ });
252
+ },
253
+ signal: controller.signal
254
+ }, fileListItem).then(onSuccess).catch(function (e) {
255
+ var _e$response;
256
+ console.error(e);
257
+ onError(e, (_e$response = e.response) === null || _e$response === void 0 ? void 0 : _e$response.data);
258
+ });
259
+ }
260
+ });
261
+ };
262
+ Message = getAntApp().message || message;
263
+ fileListPromises = Array.from(files).map( /*#__PURE__*/function () {
264
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(file) {
265
+ var fileInfo, fileName, newFile, fileListItem;
266
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
267
+ while (1) switch (_context2.prev = _context2.next) {
268
+ case 0:
269
+ _context2.next = 2;
270
+ return getFileInfo(file);
271
+ case 2:
272
+ fileInfo = _context2.sent;
273
+ fileName = file.name;
274
+ newFile = new File([file], fileName, {
275
+ type: fileInfo.mimeType
276
+ });
277
+ fileListItem = {
278
+ name: newFile.name,
279
+ uid: uuid(),
280
+ status: 'uploading',
281
+ file: newFile,
282
+ percent: 0,
283
+ size: file.size,
284
+ blobUrl: URL.createObjectURL(newFile)
285
+ };
286
+ _context2.prev = 6;
287
+ _context2.next = 9;
288
+ return handleBeforeUpload(newFile);
289
+ case 9:
290
+ return _context2.abrupt("return", fileListItem);
291
+ case 12:
292
+ _context2.prev = 12;
293
+ _context2.t0 = _context2["catch"](6);
294
+ console.error(_context2.t0);
295
+ Message.error(_context2.t0 === null || _context2.t0 === void 0 ? void 0 : _context2.t0.message);
296
+ return _context2.abrupt("return", null);
297
+ case 17:
298
+ case "end":
299
+ return _context2.stop();
300
+ }
301
+ }, _callee2, null, [[6, 12]]);
302
+ }));
303
+ return function (_x4) {
304
+ return _ref3.apply(this, arguments);
305
+ };
306
+ }());
307
+ _context3.next = 5;
308
+ return Promise.all(fileListPromises);
309
+ case 5:
310
+ fileList = _context3.sent.filter(Boolean);
311
+ if (fileList.length) {
312
+ if (options !== null && options !== void 0 && options.replace) {
313
+ asyncTaskQueue.add(function () {
314
+ return handleUploadFile(fileList[0]);
315
+ });
316
+ asyncTaskQueue.start();
317
+ updateFileItemByUid(options.replaceId, fileList[0]);
318
+ } else {
319
+ _model$getState3 = model.getState(), currentFileList = _model$getState3.value;
320
+ if (maxCount > 0) {
321
+ remainCount = maxCount - currentFileList.length;
322
+ fileList = fileList.slice(0, remainCount);
323
+ }
324
+ fileList.forEach(function (fileListItem) {
325
+ asyncTaskQueue.add(function () {
326
+ return handleUploadFile(fileListItem);
327
+ });
328
+ });
329
+ asyncTaskQueue.start();
330
+ handleOnChange([].concat(_toConsumableArray(model.getState().value), _toConsumableArray(fileList)));
331
+ }
332
+ }
333
+ case 7:
334
+ case "end":
335
+ return _context3.stop();
336
+ }
337
+ }, _callee3);
338
+ }));
339
+ return function handleUploadFiles(_x2, _x3) {
340
+ return _ref2.apply(this, arguments);
341
+ };
342
+ }();
343
+
344
+ // 删除文件
345
+ var onDeleteFileList = function onDeleteFileList(uid) {
346
+ var _model$getState4 = model.getState(),
347
+ value = _model$getState4.value;
348
+ var deleteFile = value.find(function (item) {
349
+ return item.uid === uid;
350
+ });
351
+ if (deleteFile) {
352
+ var _props$onRemove;
353
+ handleOnChange(value.filter(function (fileListItem) {
354
+ return fileListItem.uid !== uid;
355
+ }));
356
+ if (deleteFile.status === 'uploading') {
357
+ var _deleteFile$abort;
358
+ (_deleteFile$abort = deleteFile.abort) === null || _deleteFile$abort === void 0 || _deleteFile$abort.call(deleteFile);
359
+ }
360
+ if (deleteFile.validationStatus === 'validating') {
361
+ var _deleteFile$validatio;
362
+ (_deleteFile$validatio = deleteFile.validationAbort) === null || _deleteFile$validatio === void 0 || _deleteFile$validatio.call(deleteFile);
363
+ }
364
+ if (deleteFile.blobUrl) {
365
+ URL.revokeObjectURL(deleteFile.blobUrl);
366
+ }
367
+ (_props$onRemove = props.onRemove) === null || _props$onRemove === void 0 || _props$onRemove.call(props, deleteFile);
368
+ }
369
+ };
370
+ return {
371
+ model: model,
372
+ onDragOver: onDragOver,
373
+ handleUploadFiles: handleUploadFiles,
374
+ onDeleteFileList: onDeleteFileList
375
+ };
376
+ }
@@ -0,0 +1,4 @@
1
+ import './index.less';
2
+ import { UploadFileProps } from './type';
3
+ declare const UploadFile: (props: UploadFileProps) => import("react/jsx-runtime").JSX.Element;
4
+ export default UploadFile;