@wzyjs/uis 0.3.28 → 0.3.30
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/dist/advanced/Com2Canvas/index.d.ts +8 -0
- package/dist/advanced/Com2Canvas/index.js +39 -0
- package/dist/advanced/Crud/components/CardList/index.d.ts +2 -0
- package/dist/advanced/Crud/components/CardList/index.js +90 -0
- package/dist/advanced/Crud/components/CreateUpdate/index.d.ts +2 -0
- package/dist/advanced/Crud/components/CreateUpdate/index.js +78 -0
- package/dist/advanced/Crud/components/ListTabs/index.d.ts +8 -0
- package/dist/advanced/Crud/components/ListTabs/index.js +7 -0
- package/dist/advanced/Crud/components/Provider/index.d.ts +7 -0
- package/dist/advanced/Crud/components/Provider/index.js +42 -0
- package/dist/advanced/Crud/components/QuickFilters/index.d.ts +8 -0
- package/dist/advanced/Crud/components/QuickFilters/index.js +20 -0
- package/dist/advanced/Crud/components/Remove/index.d.ts +2 -0
- package/dist/advanced/Crud/components/Remove/index.js +18 -0
- package/dist/advanced/Crud/components/index.d.ts +6 -0
- package/dist/advanced/Crud/components/index.js +6 -0
- package/dist/advanced/Crud/hooks/index.d.ts +5 -0
- package/dist/advanced/Crud/hooks/index.js +5 -0
- package/dist/advanced/Crud/hooks/useColumns.d.ts +11 -0
- package/dist/advanced/Crud/hooks/useColumns.js +111 -0
- package/dist/advanced/Crud/hooks/useList.d.ts +12 -0
- package/dist/advanced/Crud/hooks/useList.js +53 -0
- package/dist/advanced/Crud/hooks/useListFilters.d.ts +11 -0
- package/dist/advanced/Crud/hooks/useListFilters.js +159 -0
- package/dist/advanced/Crud/hooks/useOrderable.d.ts +15 -0
- package/dist/advanced/Crud/hooks/useOrderable.js +75 -0
- package/dist/advanced/Crud/hooks/useRequest.d.ts +13 -0
- package/dist/advanced/Crud/hooks/useRequest.js +27 -0
- package/dist/advanced/Crud/index.d.ts +3 -0
- package/dist/advanced/Crud/index.js +46 -0
- package/dist/advanced/Crud/types/index.d.ts +176 -0
- package/dist/advanced/Crud/types/index.js +1 -0
- package/dist/advanced/Crud/utils/index.d.ts +7 -0
- package/dist/advanced/Crud/utils/index.js +80 -0
- package/dist/advanced/Crud/utils/query.d.ts +3 -0
- package/dist/advanced/Crud/utils/query.js +34 -0
- package/dist/advanced/MindMap/context.d.ts +12 -0
- package/dist/advanced/MindMap/context.js +12 -0
- package/dist/advanced/MindMap/hooks/useAlignmentSnap.d.ts +15 -0
- package/dist/advanced/MindMap/hooks/useAlignmentSnap.js +164 -0
- package/dist/advanced/MindMap/hooks/useCopyPaste.d.ts +11 -0
- package/dist/advanced/MindMap/hooks/useCopyPaste.js +209 -0
- package/dist/advanced/MindMap/hooks/useDropToReparent.d.ts +21 -0
- package/dist/advanced/MindMap/hooks/useDropToReparent.js +216 -0
- package/dist/advanced/MindMap/hooks/useExpandCollapse.d.ts +18 -0
- package/dist/advanced/MindMap/hooks/useExpandCollapse.js +108 -0
- package/dist/advanced/MindMap/hooks/useMoveDescendants.d.ts +12 -0
- package/dist/advanced/MindMap/hooks/useMoveDescendants.js +98 -0
- package/dist/advanced/MindMap/hooks/useUndoRedo.d.ts +14 -0
- package/dist/advanced/MindMap/hooks/useUndoRedo.js +181 -0
- package/dist/advanced/MindMap/index.d.ts +29 -0
- package/dist/advanced/MindMap/index.js +52 -0
- package/dist/advanced/index.d.ts +5 -0
- package/dist/advanced/index.js +5 -0
- package/dist/antd/index.d.ts +6 -0
- package/dist/antd/index.js +5 -0
- package/dist/buttons/ButtonGroup/index.d.ts +8 -0
- package/dist/buttons/ButtonGroup/index.js +13 -0
- package/dist/buttons/ConfirmButton/index.d.ts +5 -0
- package/dist/buttons/ConfirmButton/index.js +9 -0
- package/dist/buttons/CopyButton/index.d.ts +6 -0
- package/dist/buttons/CopyButton/index.js +26 -0
- package/dist/buttons/DrawerButton/index.d.ts +6 -0
- package/dist/buttons/DrawerButton/index.js +13 -0
- package/dist/buttons/ProgressButton/index.css +63 -0
- package/dist/buttons/ProgressButton/index.d.ts +17 -0
- package/dist/buttons/ProgressButton/index.js +31 -0
- package/dist/buttons/SectorButton/index.d.ts +20 -0
- package/dist/buttons/SectorButton/index.js +130 -0
- package/dist/buttons/index.d.ts +6 -0
- package/dist/buttons/index.js +6 -0
- package/dist/display/CodeView/index.d.ts +26 -0
- package/dist/display/CodeView/index.js +60 -0
- package/dist/display/EnumTag/index.d.ts +12 -0
- package/dist/display/EnumTag/index.js +10 -0
- package/dist/display/HtmlDataRenderer/index.d.ts +6 -0
- package/dist/display/HtmlDataRenderer/index.js +15 -0
- package/dist/display/HtmlView/index.d.ts +6 -0
- package/dist/display/HtmlView/index.js +6 -0
- package/dist/display/IframePro/index.d.ts +8 -0
- package/dist/display/IframePro/index.js +24 -0
- package/dist/display/JsonSchemaRenderer/index.d.ts +11 -0
- package/dist/display/JsonSchemaRenderer/index.js +62 -0
- package/dist/display/JsonView/index.d.ts +3 -0
- package/dist/display/JsonView/index.js +7 -0
- package/dist/display/MarkdownView/index.d.ts +7 -0
- package/dist/display/MarkdownView/index.js +80 -0
- package/dist/display/MarkdownView/style.d.ts +1 -0
- package/{src/components/Markdown/style.ts → dist/display/MarkdownView/style.js} +1 -1
- package/dist/display/VideoPro/index.d.ts +9 -0
- package/dist/display/VideoPro/index.js +15 -0
- package/dist/display/index.d.ts +9 -0
- package/dist/display/index.js +9 -0
- package/dist/inputs/CheckboxButton/index.css +22 -0
- package/dist/inputs/CheckboxButton/index.d.ts +12 -0
- package/dist/inputs/CheckboxButton/index.js +9 -0
- package/dist/inputs/DateSwitcher/index.css +10 -0
- package/dist/inputs/DateSwitcher/index.d.ts +8 -0
- package/dist/inputs/DateSwitcher/index.js +29 -0
- package/dist/inputs/FetchSelect/index.d.ts +3 -0
- package/dist/inputs/FetchSelect/index.js +121 -0
- package/dist/inputs/FetchSelect/types.d.ts +33 -0
- package/dist/inputs/FetchSelect/types.js +1 -0
- package/dist/inputs/FetchSelect/utils.d.ts +21 -0
- package/dist/inputs/FetchSelect/utils.js +67 -0
- package/dist/inputs/FileUploader/index.d.ts +22 -0
- package/dist/inputs/FileUploader/index.js +79 -0
- package/dist/inputs/IconSelect/index.d.ts +89 -0
- package/dist/inputs/IconSelect/index.js +54 -0
- package/dist/inputs/ImageUploader/index.d.ts +12 -0
- package/dist/inputs/ImageUploader/index.js +192 -0
- package/dist/inputs/RadioButton/index.d.ts +15 -0
- package/dist/inputs/RadioButton/index.js +11 -0
- package/dist/inputs/RangeInput/index.d.ts +8 -0
- package/dist/inputs/RangeInput/index.js +17 -0
- package/dist/inputs/TextInput/index.d.ts +6 -0
- package/dist/inputs/TextInput/index.js +30 -0
- package/dist/inputs/index.d.ts +9 -0
- package/dist/inputs/index.js +9 -0
- package/dist/layout/DragSort/index.d.ts +16 -0
- package/dist/layout/DragSort/index.js +12 -0
- package/dist/layout/FoldCard/index.d.ts +9 -0
- package/dist/layout/FoldCard/index.js +69 -0
- package/dist/layout/PageBase/index.d.ts +6 -0
- package/dist/layout/PageBase/index.js +6 -0
- package/dist/layout/ResizableGridLayout/index.d.ts +11 -0
- package/dist/layout/ResizableGridLayout/index.js +13 -0
- package/dist/layout/SideMenu/index.d.ts +27 -0
- package/dist/layout/SideMenu/index.js +40 -0
- package/dist/layout/TabsPro/index.d.ts +9 -0
- package/dist/layout/TabsPro/index.js +87 -0
- package/dist/layout/index.d.ts +6 -0
- package/dist/layout/index.js +6 -0
- package/dist/web.d.ts +6 -0
- package/dist/web.js +6 -0
- package/package.json +28 -12
- package/src/antd/form/CheckboxButton/index.module.scss +0 -24
- package/src/antd/form/CheckboxButton/index.tsx +0 -31
- package/src/antd/form/FileUploader/index.tsx +0 -163
- package/src/antd/form/RadioButton/index.tsx +0 -32
- package/src/antd/form/Upload/index.tsx +0 -65
- package/src/antd/form/UploadImage/index.tsx +0 -338
- package/src/antd/form/index.ts +0 -6
- package/src/antd/index.ts +0 -46
- package/src/antd/pro/Alert/index.tsx +0 -24
- package/src/antd/pro/Button/components/Confirm.tsx +0 -24
- package/src/antd/pro/Button/components/Copy.tsx +0 -47
- package/src/antd/pro/Button/components/Drawer.tsx +0 -37
- package/src/antd/pro/Button/components/Group.tsx +0 -26
- package/src/antd/pro/Button/index.tsx +0 -11
- package/src/antd/pro/Card/index.tsx +0 -92
- package/src/antd/pro/Collapse/components/Item.tsx +0 -30
- package/src/antd/pro/Collapse/index.tsx +0 -27
- package/src/antd/pro/Image/index.tsx +0 -17
- package/src/antd/pro/Input/components/Range.tsx +0 -46
- package/src/antd/pro/Input/index.tsx +0 -61
- package/src/antd/pro/Popconfirm/index.tsx +0 -16
- package/src/antd/pro/Radio/components/Cancel.tsx +0 -30
- package/src/antd/pro/Radio/index.tsx +0 -7
- package/src/antd/pro/Space/index.tsx +0 -15
- package/src/antd/pro/Tabs/index.tsx +0 -135
- package/src/antd/pro/Typography/components/String.tsx +0 -72
- package/src/antd/pro/Typography/index.tsx +0 -9
- package/src/antd/pro/index.ts +0 -11
- package/src/components/BottomBar/index.tsx +0 -28
- package/src/components/CodeView/index.tsx +0 -85
- package/src/components/Collapse/index.tsx +0 -26
- package/src/components/Com2Canvas/index.tsx +0 -60
- package/src/components/CompileHtml/index.tsx +0 -26
- package/src/components/Crud/components/CardList/index.tsx +0 -174
- package/src/components/Crud/components/CreateUpdate/index.tsx +0 -179
- package/src/components/Crud/components/Provider/index.tsx +0 -83
- package/src/components/Crud/components/Remove/index.tsx +0 -56
- package/src/components/Crud/components/index.ts +0 -4
- package/src/components/Crud/hooks/index.ts +0 -4
- package/src/components/Crud/hooks/useColumns.tsx +0 -169
- package/src/components/Crud/hooks/useList.ts +0 -65
- package/src/components/Crud/hooks/useOrderable.tsx +0 -107
- package/src/components/Crud/hooks/useRequest.ts +0 -41
- package/src/components/Crud/index.tsx +0 -91
- package/src/components/Crud/types/index.ts +0 -188
- package/src/components/Crud/utils/index.ts +0 -87
- package/src/components/DateSwitcher/index.module.scss +0 -10
- package/src/components/DateSwitcher/index.tsx +0 -75
- package/src/components/DownloadLink/index.tsx +0 -36
- package/src/components/DragSort/index.tsx +0 -77
- package/src/components/DynamicSelect/index.tsx +0 -74
- package/src/components/DynamicSelect/utils.ts +0 -45
- package/src/components/EnumTag/index.tsx +0 -24
- package/src/components/FetchSelect/index.tsx +0 -57
- package/src/components/Fold/index.tsx +0 -52
- package/src/components/FormPro/index.tsx +0 -28
- package/src/components/GroupLayout/index.tsx +0 -45
- package/src/components/HtmlPro/index.tsx +0 -18
- package/src/components/IframePro/index.tsx +0 -52
- package/src/components/JsonRenderer/index.tsx +0 -114
- package/src/components/JsonView/index.tsx +0 -21
- package/src/components/Markdown/index.tsx +0 -152
- package/src/components/MindMap/context.tsx +0 -29
- package/src/components/MindMap/hooks/useAlignmentSnap.ts +0 -220
- package/src/components/MindMap/hooks/useCopyPaste.ts +0 -272
- package/src/components/MindMap/hooks/useDropToReparent.ts +0 -288
- package/src/components/MindMap/hooks/useExpandCollapse.ts +0 -146
- package/src/components/MindMap/hooks/useMoveDescendants.ts +0 -136
- package/src/components/MindMap/hooks/useUndoRedo.ts +0 -232
- package/src/components/MindMap/index.tsx +0 -117
- package/src/components/MultiImageDisplay/index.tsx +0 -63
- package/src/components/ProgressButton/index.module.scss +0 -65
- package/src/components/ProgressButton/index.tsx +0 -96
- package/src/components/SectorButton/index.tsx +0 -247
- package/src/components/TextInput/index.tsx +0 -61
- package/src/components/TimelineBar/components/CurrentWeekHighlight/index.tsx +0 -64
- package/src/components/TimelineBar/components/Guides/index.tsx +0 -61
- package/src/components/TimelineBar/components/Ticks/index.tsx +0 -56
- package/src/components/TimelineBar/components/TodayIndicator/index.tsx +0 -54
- package/src/components/TimelineBar/components/index.ts +0 -4
- package/src/components/TimelineBar/const.ts +0 -3
- package/src/components/TimelineBar/hooks/index.ts +0 -5
- package/src/components/TimelineBar/hooks/useHighlightRange.ts +0 -21
- package/src/components/TimelineBar/hooks/useMonthGuides.ts +0 -40
- package/src/components/TimelineBar/hooks/useTickValues.ts +0 -18
- package/src/components/TimelineBar/hooks/useVisibleRange.ts +0 -43
- package/src/components/TimelineBar/hooks/useWeekGuides.ts +0 -39
- package/src/components/TimelineBar/index.tsx +0 -63
- package/src/components/TimelineBar/utils.ts +0 -27
- package/src/components/Video/index.tsx +0 -37
- package/src/components/index.ts +0 -27
- package/src/rn.ts +0 -1
- package/src/rns/index.ts +0 -0
- package/src/web.ts +0 -2
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React, { useEffect, useRef, useState } from 'react'
|
|
4
|
-
import { Alert, Button, Modal, Popover, Space, Typography } from 'antd'
|
|
5
|
-
import { DeleteOutlined, PlusOutlined } from '@ant-design/icons'
|
|
6
|
-
|
|
7
|
-
interface UploadImageProps {
|
|
8
|
-
value?: string[];
|
|
9
|
-
onChange?: (value: string[]) => void;
|
|
10
|
-
maxImages?: number;
|
|
11
|
-
enablePreview?: boolean;
|
|
12
|
-
enableDragDrop?: boolean;
|
|
13
|
-
enableFileSelect?: boolean;
|
|
14
|
-
enablePaste?: boolean;
|
|
15
|
-
enablePasteTip?: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const UploadImage = (props: UploadImageProps) => {
|
|
19
|
-
const {
|
|
20
|
-
value = [],
|
|
21
|
-
onChange,
|
|
22
|
-
maxImages = 10,
|
|
23
|
-
enablePreview = false,
|
|
24
|
-
enableDragDrop = false,
|
|
25
|
-
enableFileSelect = false,
|
|
26
|
-
enablePaste = true,
|
|
27
|
-
enablePasteTip = false,
|
|
28
|
-
} = props
|
|
29
|
-
|
|
30
|
-
const [isDragging, setIsDragging] = useState(false)
|
|
31
|
-
const fileInputRef = useRef<HTMLInputElement>(null)
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (!enablePaste) return
|
|
35
|
-
|
|
36
|
-
const handlePaste = (event: ClipboardEvent) => {
|
|
37
|
-
if (event.clipboardData && event.clipboardData.items) {
|
|
38
|
-
const items = event.clipboardData.items
|
|
39
|
-
for (let i = 0; i < items.length; i++) {
|
|
40
|
-
const item = items[i]
|
|
41
|
-
if (item && item.type.indexOf('image') !== -1) {
|
|
42
|
-
const file = item.getAsFile()
|
|
43
|
-
if (file) {
|
|
44
|
-
convertToBase64(file)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
document.addEventListener('paste', handlePaste)
|
|
52
|
-
return () => {
|
|
53
|
-
document.removeEventListener('paste', handlePaste)
|
|
54
|
-
}
|
|
55
|
-
}, [value, enablePaste])
|
|
56
|
-
|
|
57
|
-
const handleDragOver = (e: React.DragEvent<HTMLDivElement>) => {
|
|
58
|
-
if (!enableDragDrop) return
|
|
59
|
-
e.preventDefault()
|
|
60
|
-
e.stopPropagation()
|
|
61
|
-
setIsDragging(true)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const handleDragLeave = (e: React.DragEvent<HTMLDivElement>) => {
|
|
65
|
-
if (!enableDragDrop) return
|
|
66
|
-
e.preventDefault()
|
|
67
|
-
e.stopPropagation()
|
|
68
|
-
setIsDragging(false)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const handleDrop = (e: React.DragEvent<HTMLDivElement>) => {
|
|
72
|
-
if (!enableDragDrop) return
|
|
73
|
-
e.preventDefault()
|
|
74
|
-
e.stopPropagation()
|
|
75
|
-
setIsDragging(false)
|
|
76
|
-
|
|
77
|
-
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
|
78
|
-
const fileList = Array.from(e.dataTransfer.files)
|
|
79
|
-
fileList.forEach((file) => {
|
|
80
|
-
if (file.type.match('image.*')) {
|
|
81
|
-
convertToBase64(file)
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const handleClick = () => {
|
|
88
|
-
if (!enableFileSelect) return
|
|
89
|
-
fileInputRef.current?.click()
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
93
|
-
if (!enableFileSelect) return
|
|
94
|
-
if (e.target.files && e.target.files.length > 0) {
|
|
95
|
-
const fileList = Array.from(e.target.files)
|
|
96
|
-
fileList.forEach((file) => {
|
|
97
|
-
if (file.type.match('image.*')) {
|
|
98
|
-
convertToBase64(file)
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const handlePasteButton = () => {
|
|
105
|
-
if (!enablePaste) return
|
|
106
|
-
navigator.clipboard.read().then((clipboardItems) => {
|
|
107
|
-
for (const clipboardItem of clipboardItems) {
|
|
108
|
-
for (const type of clipboardItem.types) {
|
|
109
|
-
if (type.startsWith('image/')) {
|
|
110
|
-
clipboardItem.getType(type).then((blob) => {
|
|
111
|
-
convertToBase64(blob)
|
|
112
|
-
})
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}).catch(error => {
|
|
117
|
-
console.error('读取剪贴板失败:', error)
|
|
118
|
-
alert('读取剪贴板失败。请尝试使用 Ctrl+V 粘贴或手动上传图片。')
|
|
119
|
-
})
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const convertToBase64 = (file: File | Blob) => {
|
|
123
|
-
if (value.length >= maxImages) {
|
|
124
|
-
alert(`最多允许上传 ${maxImages} 张图片。`)
|
|
125
|
-
return
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
compressImage(file).then(compressedFile => {
|
|
129
|
-
const reader = new FileReader()
|
|
130
|
-
reader.onloadend = () => {
|
|
131
|
-
const base64String = reader.result as string
|
|
132
|
-
if (!value.includes(base64String)) {
|
|
133
|
-
onChange?.([...value, base64String])
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
reader.readAsDataURL(compressedFile)
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const compressImage = (file: File | Blob): Promise<Blob> => {
|
|
141
|
-
return new Promise((resolve) => {
|
|
142
|
-
const originalSize = file.size / 1024
|
|
143
|
-
|
|
144
|
-
const img = new Image()
|
|
145
|
-
img.src = URL.createObjectURL(file)
|
|
146
|
-
|
|
147
|
-
img.onload = () => {
|
|
148
|
-
URL.revokeObjectURL(img.src)
|
|
149
|
-
|
|
150
|
-
const canvas = document.createElement('canvas')
|
|
151
|
-
let width = img.width
|
|
152
|
-
let height = img.height
|
|
153
|
-
|
|
154
|
-
// 计算压缩比例,保持宽高比
|
|
155
|
-
const maxWidth = 1200
|
|
156
|
-
const maxHeight = 1200
|
|
157
|
-
|
|
158
|
-
if (width > maxWidth || height > maxHeight) {
|
|
159
|
-
const ratio = Math.min(maxWidth / width, maxHeight / height)
|
|
160
|
-
width = width * ratio
|
|
161
|
-
height = height * ratio
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
canvas.width = width
|
|
165
|
-
canvas.height = height
|
|
166
|
-
|
|
167
|
-
const ctx = canvas.getContext('2d')
|
|
168
|
-
if (!ctx) {
|
|
169
|
-
resolve(file as Blob)
|
|
170
|
-
return
|
|
171
|
-
}
|
|
172
|
-
ctx.drawImage(img, 0, 0, width, height)
|
|
173
|
-
|
|
174
|
-
// 转换为blob,压缩质量为0.8
|
|
175
|
-
canvas.toBlob(
|
|
176
|
-
(blob) => {
|
|
177
|
-
if (!blob) {
|
|
178
|
-
resolve(file as Blob)
|
|
179
|
-
return
|
|
180
|
-
}
|
|
181
|
-
// 获取压缩后的图片大小
|
|
182
|
-
const compressedSize = blob.size / 1024
|
|
183
|
-
console.log(`原始图片: ${originalSize.toFixed(2)} KB => ${compressedSize.toFixed(2)} KB`)
|
|
184
|
-
console.log(`压缩到了: ${((compressedSize / originalSize) * 100).toFixed(2)}%`)
|
|
185
|
-
resolve(blob)
|
|
186
|
-
},
|
|
187
|
-
'image/jpeg',
|
|
188
|
-
0.8,
|
|
189
|
-
)
|
|
190
|
-
}
|
|
191
|
-
})
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const handleRemoveImage = (index: number) => {
|
|
195
|
-
Modal.confirm({
|
|
196
|
-
title: '确认删除',
|
|
197
|
-
content: '您确定要删除这张图片吗?',
|
|
198
|
-
okText: '确定',
|
|
199
|
-
cancelText: '取消',
|
|
200
|
-
onOk: () => {
|
|
201
|
-
const newImages = [...value]
|
|
202
|
-
newImages.splice(index, 1)
|
|
203
|
-
onChange?.(newImages)
|
|
204
|
-
},
|
|
205
|
-
})
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return (
|
|
209
|
-
<div className='w-full space-y-4'>
|
|
210
|
-
<div className='flex flex-wrap gap-3'>
|
|
211
|
-
{value.map((image, index) => {
|
|
212
|
-
const imageNode = (
|
|
213
|
-
<div
|
|
214
|
-
className='rounded border overflow-hidden relative group bg-white'
|
|
215
|
-
style={{ maxWidth: 200 }}
|
|
216
|
-
>
|
|
217
|
-
<img
|
|
218
|
-
src={image}
|
|
219
|
-
alt={`图片 ${index + 1}`}
|
|
220
|
-
className='object-contain'
|
|
221
|
-
style={{ maxWidth: '100%', height: 'auto', display: 'block' }}
|
|
222
|
-
/>
|
|
223
|
-
<Button
|
|
224
|
-
type='text'
|
|
225
|
-
icon={<DeleteOutlined />}
|
|
226
|
-
onClick={(e) => {
|
|
227
|
-
e.stopPropagation()
|
|
228
|
-
handleRemoveImage(index)
|
|
229
|
-
}}
|
|
230
|
-
style={{ position: 'absolute', top: 0, right: 0 }}
|
|
231
|
-
className='absolute top-0 right-0 bg-black/40 text-white border-none hover:bg-black/60'
|
|
232
|
-
size='small'
|
|
233
|
-
/>
|
|
234
|
-
</div>
|
|
235
|
-
)
|
|
236
|
-
|
|
237
|
-
if (!enablePreview) {
|
|
238
|
-
return (
|
|
239
|
-
<div key={index} className='relative'>
|
|
240
|
-
{imageNode}
|
|
241
|
-
</div>
|
|
242
|
-
)
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return (
|
|
246
|
-
<div key={index} className='relative'>
|
|
247
|
-
<Popover
|
|
248
|
-
trigger='hover'
|
|
249
|
-
placement='top'
|
|
250
|
-
content={(
|
|
251
|
-
<img
|
|
252
|
-
src={image}
|
|
253
|
-
alt={`预览图片 ${index + 1}`}
|
|
254
|
-
style={{
|
|
255
|
-
maxWidth: '400px',
|
|
256
|
-
height: 'auto',
|
|
257
|
-
objectFit: 'contain',
|
|
258
|
-
}}
|
|
259
|
-
/>
|
|
260
|
-
)}
|
|
261
|
-
>
|
|
262
|
-
{imageNode}
|
|
263
|
-
</Popover>
|
|
264
|
-
</div>
|
|
265
|
-
)
|
|
266
|
-
})}
|
|
267
|
-
|
|
268
|
-
{value.length < maxImages && (
|
|
269
|
-
<Space style={{ width: '100%' }}>
|
|
270
|
-
{enableFileSelect && (
|
|
271
|
-
<div
|
|
272
|
-
className={`border-2 border-dashed rounded flex flex-col items-center justify-center cursor-pointer transition-colors ${
|
|
273
|
-
isDragging && enableDragDrop ? 'border-blue-500 bg-blue-50' : 'border-gray-300 hover:border-blue-500'
|
|
274
|
-
}`}
|
|
275
|
-
onDragOver={enableDragDrop ? handleDragOver : undefined}
|
|
276
|
-
onDragLeave={enableDragDrop ? handleDragLeave : undefined}
|
|
277
|
-
onDrop={enableDragDrop ? handleDrop : undefined}
|
|
278
|
-
onClick={handleClick}
|
|
279
|
-
style={{ width: '50px', height: '50px' }}
|
|
280
|
-
>
|
|
281
|
-
<PlusOutlined style={{ fontSize: '24px', color: '#8c8c8c' }} />
|
|
282
|
-
<Typography.Text type='secondary' className='m-2'>上传</Typography.Text>
|
|
283
|
-
</div>
|
|
284
|
-
)}
|
|
285
|
-
|
|
286
|
-
{enablePaste && (
|
|
287
|
-
<div
|
|
288
|
-
style={{ width: '50px', height: '50px' }}
|
|
289
|
-
className={`border-2 border-dashed rounded flex flex-col items-center justify-center cursor-pointer transition-colors ${
|
|
290
|
-
isDragging ? 'border-blue-500 bg-blue-50' : 'border-gray-300 hover:border-blue-500'
|
|
291
|
-
}`}
|
|
292
|
-
onClick={handlePasteButton}
|
|
293
|
-
>
|
|
294
|
-
<PlusOutlined style={{ fontSize: '24px', color: '#8c8c8c' }} />
|
|
295
|
-
<Typography.Text type='secondary' className='m-2'>粘贴</Typography.Text>
|
|
296
|
-
</div>
|
|
297
|
-
)}
|
|
298
|
-
</Space>
|
|
299
|
-
)}
|
|
300
|
-
</div>
|
|
301
|
-
|
|
302
|
-
{enableFileSelect && (
|
|
303
|
-
<input
|
|
304
|
-
type='file'
|
|
305
|
-
ref={fileInputRef}
|
|
306
|
-
onChange={handleFileChange}
|
|
307
|
-
accept='image/*'
|
|
308
|
-
multiple
|
|
309
|
-
style={{ display: 'none' }}
|
|
310
|
-
/>
|
|
311
|
-
)}
|
|
312
|
-
|
|
313
|
-
{(enablePasteTip && enablePaste) && (
|
|
314
|
-
<Alert
|
|
315
|
-
type='info'
|
|
316
|
-
showIcon
|
|
317
|
-
message={
|
|
318
|
-
<Typography.Text type='secondary'>
|
|
319
|
-
提示:您也可以在任意位置按下 <kbd style={{
|
|
320
|
-
padding: '0.1rem 0.4rem',
|
|
321
|
-
background: '#f5f5f5',
|
|
322
|
-
border: '1px solid #d9d9d9',
|
|
323
|
-
borderRadius: '3px',
|
|
324
|
-
fontSize: '12px',
|
|
325
|
-
}}>Ctrl</kbd> + <kbd style={{
|
|
326
|
-
padding: '0.1rem 0.4rem',
|
|
327
|
-
background: '#f5f5f5',
|
|
328
|
-
border: '1px solid #d9d9d9',
|
|
329
|
-
borderRadius: '3px',
|
|
330
|
-
fontSize: '12px',
|
|
331
|
-
}}>V</kbd> 从剪贴板粘贴图片
|
|
332
|
-
</Typography.Text>
|
|
333
|
-
}
|
|
334
|
-
/>
|
|
335
|
-
)}
|
|
336
|
-
</div>
|
|
337
|
-
)
|
|
338
|
-
}
|
package/src/antd/form/index.ts
DELETED
package/src/antd/index.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export * from 'antd'
|
|
2
|
-
|
|
3
|
-
export * from '@ant-design/icons'
|
|
4
|
-
|
|
5
|
-
export { default as zh_CN } from 'antd/locale/zh_CN'
|
|
6
|
-
|
|
7
|
-
export { AntdRegistry } from '@ant-design/nextjs-registry'
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
PageLoading,
|
|
11
|
-
PageHeader,
|
|
12
|
-
|
|
13
|
-
ProCard,
|
|
14
|
-
ProList,
|
|
15
|
-
ProTable,
|
|
16
|
-
ProDescriptions,
|
|
17
|
-
|
|
18
|
-
ProForm,
|
|
19
|
-
ProFormList,
|
|
20
|
-
ProFormText,
|
|
21
|
-
ProFormCaptcha,
|
|
22
|
-
ProFormCheckbox,
|
|
23
|
-
ProFormSelect,
|
|
24
|
-
ProFormUploadButton,
|
|
25
|
-
LoginForm,
|
|
26
|
-
BetaSchemaForm,
|
|
27
|
-
StepsForm,
|
|
28
|
-
|
|
29
|
-
CheckCard,
|
|
30
|
-
EditableProTable,
|
|
31
|
-
DragSortTable,
|
|
32
|
-
|
|
33
|
-
ProProvider,
|
|
34
|
-
} from '@ant-design/pro-components'
|
|
35
|
-
|
|
36
|
-
export type {
|
|
37
|
-
ProTableProps,
|
|
38
|
-
ProFormProps,
|
|
39
|
-
ProColumns,
|
|
40
|
-
ProLayoutProps,
|
|
41
|
-
ProFormInstance,
|
|
42
|
-
ActionType,
|
|
43
|
-
} from '@ant-design/pro-components'
|
|
44
|
-
|
|
45
|
-
export * from './pro'
|
|
46
|
-
export * from './form'
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React, { ReactNode } from 'react'
|
|
4
|
-
import { Alert, AlertProps, Space } from 'antd'
|
|
5
|
-
|
|
6
|
-
export interface AlertProProps extends AlertProps {
|
|
7
|
-
children?: ReactNode,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
// 1. 支持 children 作为 description 显示
|
|
11
|
-
export const AlertPro = (props: AlertProProps) => {
|
|
12
|
-
const { children, description = children } = props
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<Alert
|
|
16
|
-
{...props}
|
|
17
|
-
description={(
|
|
18
|
-
<Space style={{ width: '100%' }} orientation='vertical'>
|
|
19
|
-
{description}
|
|
20
|
-
</Space>
|
|
21
|
-
)}
|
|
22
|
-
/>
|
|
23
|
-
)
|
|
24
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import { _ } from '@wzyjs/utils/web'
|
|
5
|
-
import { Button, Popconfirm, PopconfirmProps, ButtonProps } from 'antd'
|
|
6
|
-
|
|
7
|
-
export interface ConfirmProps extends PopconfirmProps {
|
|
8
|
-
btnProps?: ButtonProps
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// 1. 给按钮增加了确认功能
|
|
12
|
-
export const Confirm = (props: ConfirmProps) => {
|
|
13
|
-
const { children, btnProps } = props
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<Popconfirm
|
|
17
|
-
okText='是'
|
|
18
|
-
cancelText='否'
|
|
19
|
-
{..._.omit(props, ['children', 'btnProps'])}
|
|
20
|
-
>
|
|
21
|
-
<Button type='link' {...btnProps}>{children}</Button>
|
|
22
|
-
</Popconfirm>
|
|
23
|
-
)
|
|
24
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React, { useState, ReactNode } from 'react'
|
|
4
|
-
|
|
5
|
-
import { App, Button, ButtonProps } from 'antd'
|
|
6
|
-
import { CheckOutlined } from '@ant-design/icons'
|
|
7
|
-
|
|
8
|
-
import { copy, readClipboard } from '@wzyjs/utils/web'
|
|
9
|
-
import { useControllableValue } from '@wzyjs/hooks/web'
|
|
10
|
-
|
|
11
|
-
export interface CopyProps extends ButtonProps {
|
|
12
|
-
value?: string,
|
|
13
|
-
canPaste?: boolean,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const Copy = (props: CopyProps) => {
|
|
17
|
-
const [icon, setIcon] = useState<ReactNode>(null)
|
|
18
|
-
const { message } = App.useApp()
|
|
19
|
-
|
|
20
|
-
const [value, setValue] = useControllableValue<string>(props, {
|
|
21
|
-
defaultValue: props.value,
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
const onContextMenu = async () => {
|
|
25
|
-
setValue(await readClipboard())
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<Button
|
|
30
|
-
{...props}
|
|
31
|
-
icon={icon}
|
|
32
|
-
onContextMenu={props.canPaste ? onContextMenu : undefined}
|
|
33
|
-
children={props.children || value || '记录'}
|
|
34
|
-
onClick={(ev: any) => {
|
|
35
|
-
props.onClick?.(ev)
|
|
36
|
-
|
|
37
|
-
copy(value)
|
|
38
|
-
message.success('复制成功')
|
|
39
|
-
|
|
40
|
-
setIcon(<CheckOutlined />)
|
|
41
|
-
setTimeout(() => {
|
|
42
|
-
setIcon(null)
|
|
43
|
-
}, 1000)
|
|
44
|
-
}}
|
|
45
|
-
/>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React, { useState } from 'react'
|
|
4
|
-
import { _ } from '@wzyjs/utils/web'
|
|
5
|
-
import { Button, Drawer as AntdDrawer, DrawerProps as AntdDrawerProps, ButtonProps } from 'antd'
|
|
6
|
-
|
|
7
|
-
export interface DrawerProps extends AntdDrawerProps {
|
|
8
|
-
btnProps?: ButtonProps
|
|
9
|
-
defaultOpen?: boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const Drawer = (props: DrawerProps) => {
|
|
13
|
-
const { children, defaultOpen, btnProps } = props
|
|
14
|
-
const [open, setOpen] = useState<boolean>(defaultOpen ?? false)
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<>
|
|
18
|
-
<Button
|
|
19
|
-
type='link'
|
|
20
|
-
{...btnProps}
|
|
21
|
-
onClick={ev => {
|
|
22
|
-
btnProps?.onClick?.(ev)
|
|
23
|
-
setOpen(true)
|
|
24
|
-
}}
|
|
25
|
-
/>
|
|
26
|
-
<AntdDrawer
|
|
27
|
-
title={btnProps?.children}
|
|
28
|
-
open={open}
|
|
29
|
-
onClose={() => setOpen(false)}
|
|
30
|
-
destroyOnHidden
|
|
31
|
-
{..._.omit(props, ['children', 'btnProps'])}
|
|
32
|
-
>
|
|
33
|
-
{children}
|
|
34
|
-
</AntdDrawer>
|
|
35
|
-
</>
|
|
36
|
-
)
|
|
37
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import { Button } from 'antd'
|
|
5
|
-
import { Confirm, ConfirmProps } from './Confirm'
|
|
6
|
-
|
|
7
|
-
export interface GroupProps {
|
|
8
|
-
list?: (ConfirmProps & { visible?: boolean, title?: string })[]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// 1. 按钮组
|
|
12
|
-
export const Group = (props: GroupProps) => {
|
|
13
|
-
const { list = [] } = props
|
|
14
|
-
|
|
15
|
-
if (!list?.length) {
|
|
16
|
-
return null
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<Button.Group>
|
|
21
|
-
{list.filter(item => item.visible).map((item, index) => (
|
|
22
|
-
<Confirm key={index} {...item}>{item.title}</Confirm>
|
|
23
|
-
))}
|
|
24
|
-
</Button.Group>
|
|
25
|
-
)
|
|
26
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React, { useState, useRef, useEffect, forwardRef } from 'react'
|
|
4
|
-
import { Card, Button, CardProps } from 'antd'
|
|
5
|
-
import { DownOutlined, UpOutlined } from '@ant-design/icons'
|
|
6
|
-
|
|
7
|
-
interface CardProProps extends CardProps {
|
|
8
|
-
collapsedHeight?: number; // 默认折叠高度,可根据需要调整
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const CardPro = forwardRef((props: CardProProps, ref: any) => {
|
|
12
|
-
const { collapsedHeight = 300, children, ...rest } = props
|
|
13
|
-
|
|
14
|
-
const [collapsed, setCollapsed] = useState(true)
|
|
15
|
-
const [hovered, setHovered] = useState(false)
|
|
16
|
-
const [isOverflow, setIsOverflow] = useState(false)
|
|
17
|
-
const contentRef = useRef<HTMLSpanElement>(null)
|
|
18
|
-
|
|
19
|
-
const toggleCollapse = (ev: any) => {
|
|
20
|
-
ev.stopPropagation()
|
|
21
|
-
setCollapsed(!collapsed)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
const contentEl = contentRef.current
|
|
26
|
-
if (contentEl) {
|
|
27
|
-
// 获取内容的实际高度
|
|
28
|
-
const actualHeight = contentEl.scrollHeight
|
|
29
|
-
if (actualHeight > collapsedHeight) {
|
|
30
|
-
setIsOverflow(true)
|
|
31
|
-
} else {
|
|
32
|
-
setIsOverflow(false)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}, [children, collapsedHeight])
|
|
36
|
-
|
|
37
|
-
const cardStyle: React.CSSProperties = {
|
|
38
|
-
position: 'relative',
|
|
39
|
-
overflow: 'hidden',
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const contentStyle: React.CSSProperties = {
|
|
43
|
-
maxHeight: collapsed ? `${collapsedHeight}px` : 'none',
|
|
44
|
-
overflowY: collapsed ? 'auto' : 'visible',
|
|
45
|
-
transition: 'max-height 0.3s ease',
|
|
46
|
-
display: 'block',
|
|
47
|
-
textOverflow: 'ellipsis',
|
|
48
|
-
overflow: 'hidden',
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const buttonContainerStyle: React.CSSProperties = {
|
|
52
|
-
position: 'absolute',
|
|
53
|
-
bottom: hovered ? '10px' : '-40px', // 增加隐藏时的负值,确保按钮完全隐藏
|
|
54
|
-
left: '50%',
|
|
55
|
-
transform: 'translateX(-50%)',
|
|
56
|
-
transition: 'bottom 0.3s ease, opacity 0.3s ease',
|
|
57
|
-
display: 'flex',
|
|
58
|
-
justifyContent: 'center',
|
|
59
|
-
width: '100%',
|
|
60
|
-
pointerEvents: 'none', // 默认情况下,禁止点击
|
|
61
|
-
opacity: hovered && isOverflow ? 1 : 0, // 控制按钮的透明度
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const buttonStyle: React.CSSProperties = {
|
|
65
|
-
pointerEvents: 'auto', // 允许按钮在悬停时可点击
|
|
66
|
-
border: 'none',
|
|
67
|
-
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.15)',
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<Card
|
|
72
|
-
ref={ref}
|
|
73
|
-
style={cardStyle}
|
|
74
|
-
onMouseEnter={() => setHovered(true)}
|
|
75
|
-
onMouseLeave={() => setHovered(false)}
|
|
76
|
-
{...rest}
|
|
77
|
-
>
|
|
78
|
-
<span style={contentStyle} ref={contentRef}>
|
|
79
|
-
{children}
|
|
80
|
-
</span>
|
|
81
|
-
{isOverflow && (
|
|
82
|
-
<div style={buttonContainerStyle}>
|
|
83
|
-
<Button
|
|
84
|
-
icon={collapsed ? <DownOutlined /> : <UpOutlined />}
|
|
85
|
-
onClick={toggleCollapse}
|
|
86
|
-
style={buttonStyle}
|
|
87
|
-
/>
|
|
88
|
-
</div>
|
|
89
|
-
)}
|
|
90
|
-
</Card>
|
|
91
|
-
)
|
|
92
|
-
})
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import { Collapse, CollapsePanelProps, Space } from 'antd'
|
|
5
|
-
|
|
6
|
-
export interface CollapseItemProps extends Omit<CollapsePanelProps, 'key'> {
|
|
7
|
-
step?: boolean; // 为true自动给标题添加 `第{index}步:`
|
|
8
|
-
index?: number; // step为true时才需要
|
|
9
|
-
space?: boolean; // 子元素是否有间距
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const Item = (props: CollapseItemProps) => {
|
|
13
|
-
const { step = true, header, index, space } = props
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<Collapse.Panel
|
|
17
|
-
key={String(header)}
|
|
18
|
-
{...props}
|
|
19
|
-
header={step ? `第${index}步: ${header}` : header}
|
|
20
|
-
>
|
|
21
|
-
{space ? (
|
|
22
|
-
<Space orientation='vertical' size='small' style={{ width: '100%' }}>
|
|
23
|
-
{props.children}
|
|
24
|
-
</Space>
|
|
25
|
-
) : (
|
|
26
|
-
props.children
|
|
27
|
-
)}
|
|
28
|
-
</Collapse.Panel>
|
|
29
|
-
)
|
|
30
|
-
}
|