@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
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Tabs } from 'antd';
|
|
5
|
+
const getItemKeys = (items) => {
|
|
6
|
+
return (items || [])
|
|
7
|
+
.map(item => item?.key)
|
|
8
|
+
.filter((key) => typeof key === 'string' && !!key);
|
|
9
|
+
};
|
|
10
|
+
const getUrlTabKey = (queryKey) => {
|
|
11
|
+
if (typeof window === 'undefined') {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
const value = new URLSearchParams(window.location.search).get(queryKey);
|
|
15
|
+
return value || undefined;
|
|
16
|
+
};
|
|
17
|
+
const updateUrlTabKey = (queryKey, key, mode) => {
|
|
18
|
+
if (typeof window === 'undefined') {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const url = new URL(window.location.href);
|
|
22
|
+
url.searchParams.set(queryKey, key);
|
|
23
|
+
const nextUrl = `${url.pathname}${url.search}${url.hash}`;
|
|
24
|
+
if (mode === 'push') {
|
|
25
|
+
window.history.pushState(window.history.state, '', nextUrl);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
window.history.replaceState(window.history.state, '', nextUrl);
|
|
29
|
+
};
|
|
30
|
+
export const TabsPro = (props) => {
|
|
31
|
+
const { syncToUrl = false, queryKey = 'tab', historyMode = 'replace', activeKey, defaultActiveKey, items, onChange, ...rest } = props;
|
|
32
|
+
const itemKeys = React.useMemo(() => getItemKeys(items), [items]);
|
|
33
|
+
const initialKey = React.useMemo(() => {
|
|
34
|
+
const urlKey = syncToUrl ? getUrlTabKey(queryKey) : undefined;
|
|
35
|
+
if (urlKey && itemKeys.includes(urlKey)) {
|
|
36
|
+
return urlKey;
|
|
37
|
+
}
|
|
38
|
+
if (typeof defaultActiveKey === 'string' && itemKeys.includes(defaultActiveKey)) {
|
|
39
|
+
return defaultActiveKey;
|
|
40
|
+
}
|
|
41
|
+
return itemKeys[0];
|
|
42
|
+
}, [defaultActiveKey, itemKeys, queryKey, syncToUrl]);
|
|
43
|
+
const [innerActiveKey, setInnerActiveKey] = React.useState(initialKey);
|
|
44
|
+
const mergedActiveKey = typeof activeKey === 'string' ? activeKey : innerActiveKey;
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
if (typeof activeKey === 'string') {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
setInnerActiveKey(prev => {
|
|
50
|
+
if (prev && itemKeys.includes(prev)) {
|
|
51
|
+
return prev;
|
|
52
|
+
}
|
|
53
|
+
return initialKey;
|
|
54
|
+
});
|
|
55
|
+
}, [activeKey, initialKey, itemKeys]);
|
|
56
|
+
React.useEffect(() => {
|
|
57
|
+
if (!syncToUrl || !mergedActiveKey) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
updateUrlTabKey(queryKey, mergedActiveKey, historyMode);
|
|
61
|
+
}, [historyMode, mergedActiveKey, queryKey, syncToUrl]);
|
|
62
|
+
React.useEffect(() => {
|
|
63
|
+
if (!syncToUrl) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const onPopState = () => {
|
|
67
|
+
const urlKey = getUrlTabKey(queryKey);
|
|
68
|
+
if (!urlKey || !itemKeys.includes(urlKey)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (typeof activeKey !== 'string') {
|
|
72
|
+
setInnerActiveKey(urlKey);
|
|
73
|
+
}
|
|
74
|
+
onChange?.(urlKey);
|
|
75
|
+
};
|
|
76
|
+
window.addEventListener('popstate', onPopState);
|
|
77
|
+
return () => {
|
|
78
|
+
window.removeEventListener('popstate', onPopState);
|
|
79
|
+
};
|
|
80
|
+
}, [activeKey, itemKeys, onChange, queryKey, syncToUrl]);
|
|
81
|
+
return (_jsx(Tabs, { ...rest, items: items, activeKey: mergedActiveKey, onChange: key => {
|
|
82
|
+
if (typeof activeKey !== 'string') {
|
|
83
|
+
setInnerActiveKey(key);
|
|
84
|
+
}
|
|
85
|
+
onChange?.(key);
|
|
86
|
+
} }));
|
|
87
|
+
};
|
package/dist/web.d.ts
ADDED
package/dist/web.js
ADDED
package/package.json
CHANGED
|
@@ -1,22 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wzyjs/uis",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.30",
|
|
4
4
|
"description": "description",
|
|
5
5
|
"author": "wzy",
|
|
6
|
-
"
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"**/*.css"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "rm -rf dist && tsc && rsync -a --include='*/' --include='*.css' --exclude='*' src/ dist/"
|
|
12
|
+
},
|
|
7
13
|
"files": [
|
|
8
|
-
"
|
|
14
|
+
"dist"
|
|
9
15
|
],
|
|
10
16
|
"exports": {
|
|
11
17
|
"./web": {
|
|
12
|
-
"import": "./
|
|
18
|
+
"import": "./dist/web.js",
|
|
19
|
+
"types": "./dist/web.d.ts"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"typesVersions": {
|
|
23
|
+
"*": {
|
|
24
|
+
"./web": [
|
|
25
|
+
"./dist/web.d.ts"
|
|
26
|
+
]
|
|
13
27
|
}
|
|
14
28
|
},
|
|
15
29
|
"dependencies": {
|
|
16
30
|
"@ant-design/icons": "^6.0.0",
|
|
17
31
|
"@ant-design/nextjs-registry": "^1.0.2",
|
|
32
|
+
"@ant-design/pro-card": "^2.10.0",
|
|
18
33
|
"@ant-design/pro-components": "^2.8.6",
|
|
19
|
-
"
|
|
34
|
+
"@ant-design/pro-form": "^2.32.0",
|
|
35
|
+
"@ant-design/pro-provider": "^2.16.2",
|
|
36
|
+
"@hello-pangea/dnd": "^18.0.1",
|
|
37
|
+
"@wzyjs/hooks": "0.3.30",
|
|
38
|
+
"@xyflow/react": "^12.5.3",
|
|
20
39
|
"echarts": "^5.4.3",
|
|
21
40
|
"echarts-for-react": "^3.0.2",
|
|
22
41
|
"github-markdown-css": "^5.8.1",
|
|
@@ -26,28 +45,25 @@
|
|
|
26
45
|
"prettier": "^3.5.3",
|
|
27
46
|
"prismjs": "^1.29.0",
|
|
28
47
|
"react": "^19.0.0",
|
|
29
|
-
"react-beautiful-dnd": "^13.1.1",
|
|
30
48
|
"react-grid-layout": "^1.5.1",
|
|
31
49
|
"react-json-view": "^1.21.3",
|
|
32
50
|
"react-markdown": "^10.1.0",
|
|
33
51
|
"react-syntax-highlighter": "^15.5.0",
|
|
34
52
|
"rehype-autolink-headings": "^7.1.0",
|
|
35
53
|
"rehype-slug": "^6.0.0",
|
|
36
|
-
"
|
|
37
|
-
"remark-gfm": "^4.0.1",
|
|
38
|
-
"remark-toc": "^9.0.0"
|
|
54
|
+
"remark-gfm": "^4.0.1"
|
|
39
55
|
},
|
|
40
56
|
"peerDependencies": {
|
|
41
57
|
"@wzyjs/hooks": "^0.2.37",
|
|
42
|
-
"@wzyjs/types": "^0.2.37",
|
|
43
58
|
"@wzyjs/utils": "^0.2.37",
|
|
44
|
-
"antd": "^6.
|
|
59
|
+
"antd": "^6.3.1"
|
|
45
60
|
},
|
|
46
61
|
"devDependencies": {
|
|
47
62
|
"@types/js-beautify": "^1.14.3",
|
|
63
|
+
"@types/react": "^19.1.10",
|
|
48
64
|
"@types/react-grid-layout": "1.3.5"
|
|
49
65
|
},
|
|
50
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "4e50539cd20e721602a057645c9b859530a1b8c5",
|
|
51
67
|
"publishConfig": {
|
|
52
68
|
"access": "public"
|
|
53
69
|
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
.checkcard {
|
|
2
|
-
:global(.ant-pro-checkcard-content) {
|
|
3
|
-
padding: 0 !important;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
:global(.ant-pro-checkcard) {
|
|
7
|
-
margin-bottom: 0 !important;
|
|
8
|
-
text-align: center !important;
|
|
9
|
-
display: flex;
|
|
10
|
-
justify-content: center;
|
|
11
|
-
border-radius: 0 !important;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
:global(.ant-pro-checkcard-title) {
|
|
15
|
-
height: 100%;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
:global(.ant-pro-checkcard div) {
|
|
19
|
-
width: 100%;
|
|
20
|
-
font-weight: 400 !important;
|
|
21
|
-
height: 30px !important;
|
|
22
|
-
line-height: 28px !important;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { Col, Row } from 'antd'
|
|
4
|
-
import { CheckCard } from '@ant-design/pro-components'
|
|
5
|
-
import { CheckCardValueType, CheckGroupValueType } from '@ant-design/pro-card/es/components/CheckCard/Group'
|
|
6
|
-
|
|
7
|
-
import styles from './index.module.scss'
|
|
8
|
-
|
|
9
|
-
interface CheckboxButtonProps {
|
|
10
|
-
options: { label: string; value: CheckCardValueType }[]
|
|
11
|
-
value?: CheckGroupValueType
|
|
12
|
-
onChange?: (value: CheckGroupValueType) => void
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const CheckboxButton = (props: CheckboxButtonProps) => {
|
|
16
|
-
const { options, value, onChange } = props
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<div className={styles.checkcard}>
|
|
20
|
-
<CheckCard.Group style={{ width: '100%' }} size='small' multiple value={value} onChange={onChange}>
|
|
21
|
-
<Row>
|
|
22
|
-
{options.map((item, index) => (
|
|
23
|
-
<Col key={index}>
|
|
24
|
-
<CheckCard title={item.label} value={item.value} style={{ width: 60, height: 30 }} />
|
|
25
|
-
</Col>
|
|
26
|
-
))}
|
|
27
|
-
</Row>
|
|
28
|
-
</CheckCard.Group>
|
|
29
|
-
</div>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { useState, type ReactElement } from 'react'
|
|
4
|
-
|
|
5
|
-
import { Upload, Button, } from 'antd'
|
|
6
|
-
import { UploadOutlined, InboxOutlined } from '@ant-design/icons'
|
|
7
|
-
|
|
8
|
-
import type { UploadProps, UploadFile as AntUploadFile } from 'antd'
|
|
9
|
-
|
|
10
|
-
export interface FileUploaderProps {
|
|
11
|
-
value?: AntUploadFile[]
|
|
12
|
-
onChange?: (fileList: AntUploadFile[]) => void
|
|
13
|
-
|
|
14
|
-
// 模式
|
|
15
|
-
mode?: 'file' | 'http' // http 暂未实现
|
|
16
|
-
|
|
17
|
-
// 限制
|
|
18
|
-
accept?: string
|
|
19
|
-
multiple?: boolean
|
|
20
|
-
maxCount?: number
|
|
21
|
-
|
|
22
|
-
// 展示
|
|
23
|
-
trigger?: 'button' | 'dragger' | ReactElement
|
|
24
|
-
listType?: UploadProps['listType']
|
|
25
|
-
|
|
26
|
-
// 校验
|
|
27
|
-
beforeUpload?: (file: AntUploadFile) => boolean | Promise<void>
|
|
28
|
-
|
|
29
|
-
// 上传行为
|
|
30
|
-
immediateUpload?: boolean
|
|
31
|
-
action?: string
|
|
32
|
-
data?: Record<string, unknown> | ((file: AntUploadFile) => Record<string, unknown>)
|
|
33
|
-
headers?: UploadProps['headers']
|
|
34
|
-
withCredentials?: boolean
|
|
35
|
-
|
|
36
|
-
disabled?: boolean
|
|
37
|
-
showUploadList?: boolean
|
|
38
|
-
onUploadChange?: UploadProps['onChange']
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const FileUploader = (props: FileUploaderProps) => {
|
|
42
|
-
const {
|
|
43
|
-
value,
|
|
44
|
-
onChange,
|
|
45
|
-
mode = 'file',
|
|
46
|
-
accept,
|
|
47
|
-
multiple = true,
|
|
48
|
-
maxCount,
|
|
49
|
-
trigger = 'dragger',
|
|
50
|
-
listType = 'text',
|
|
51
|
-
beforeUpload,
|
|
52
|
-
immediateUpload = false,
|
|
53
|
-
action = '/api/file/upload',
|
|
54
|
-
data,
|
|
55
|
-
headers,
|
|
56
|
-
withCredentials,
|
|
57
|
-
disabled,
|
|
58
|
-
showUploadList = trigger === 'dragger',
|
|
59
|
-
onUploadChange,
|
|
60
|
-
} = props
|
|
61
|
-
|
|
62
|
-
const [internalFileList, setInternalFileList] = useState<AntUploadFile[]>([])
|
|
63
|
-
|
|
64
|
-
const fileList = value || internalFileList
|
|
65
|
-
|
|
66
|
-
const handleChange: UploadProps['onChange'] = (info) => {
|
|
67
|
-
let newFileList = [...info.fileList]
|
|
68
|
-
|
|
69
|
-
// 限制数量
|
|
70
|
-
if (maxCount && newFileList.length > maxCount) {
|
|
71
|
-
newFileList = newFileList.slice(-maxCount)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// 如果不是立即上传模式,我们需要手动管理状态
|
|
75
|
-
if (!immediateUpload) {
|
|
76
|
-
// 这里的逻辑主要依赖 beforeUpload 返回 false 来阻止上传
|
|
77
|
-
// 但 onChange 依然会被触发
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// 更新状态
|
|
81
|
-
if (!value) {
|
|
82
|
-
setInternalFileList(newFileList)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// 通知外部
|
|
86
|
-
onChange?.(newFileList)
|
|
87
|
-
onUploadChange?.(info)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const handleBeforeUpload = async (file: AntUploadFile) => {
|
|
91
|
-
// 1. 外部校验
|
|
92
|
-
if (beforeUpload) {
|
|
93
|
-
const result = await beforeUpload(file)
|
|
94
|
-
if (result === false) {
|
|
95
|
-
return Upload.LIST_IGNORE
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// 2. 立即上传模式
|
|
100
|
-
if (immediateUpload) {
|
|
101
|
-
return true
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// 3. 非立即上传模式,阻止默认上传行为,但添加到列表
|
|
105
|
-
return false
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const uploadProps: UploadProps = {
|
|
109
|
-
fileList,
|
|
110
|
-
accept,
|
|
111
|
-
multiple,
|
|
112
|
-
maxCount,
|
|
113
|
-
listType,
|
|
114
|
-
disabled,
|
|
115
|
-
showUploadList,
|
|
116
|
-
beforeUpload: handleBeforeUpload as UploadProps['beforeUpload'],
|
|
117
|
-
onChange: handleChange,
|
|
118
|
-
onDrop: (e: unknown) => {
|
|
119
|
-
// console.log('Dropped files', e.dataTransfer.files)
|
|
120
|
-
},
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// 立即上传相关配置
|
|
124
|
-
if (immediateUpload) {
|
|
125
|
-
uploadProps.action = action
|
|
126
|
-
uploadProps.data = data
|
|
127
|
-
uploadProps.headers = headers
|
|
128
|
-
uploadProps.withCredentials = withCredentials
|
|
129
|
-
} else {
|
|
130
|
-
// 非立即上传模式,不需要 action
|
|
131
|
-
uploadProps.customRequest = () => undefined // 覆盖默认上传行为,防止自动上传尝试
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (mode === 'http') {
|
|
135
|
-
return <div>HTTP 输入模式暂未支持</div>
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (trigger === 'button') {
|
|
139
|
-
return (
|
|
140
|
-
<Upload {...uploadProps}>
|
|
141
|
-
<Button type="primary" icon={<UploadOutlined />}>
|
|
142
|
-
上传文件
|
|
143
|
-
</Button>
|
|
144
|
-
</Upload>
|
|
145
|
-
)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (trigger === 'dragger') {
|
|
149
|
-
return (
|
|
150
|
-
<Upload.Dragger {...uploadProps}>
|
|
151
|
-
<p className="ant-upload-drag-icon">
|
|
152
|
-
<InboxOutlined />
|
|
153
|
-
</p>
|
|
154
|
-
<p className="ant-upload-text">点击或拖拽文件到此区域上传</p>
|
|
155
|
-
<p className="ant-upload-hint">
|
|
156
|
-
支持单个或批量上传{maxCount ? `,最多 ${maxCount} 个文件` : ''}
|
|
157
|
-
</p>
|
|
158
|
-
</Upload.Dragger>
|
|
159
|
-
)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return trigger
|
|
163
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { CSSProperties } from 'react'
|
|
4
|
-
import { Radio } from 'antd'
|
|
5
|
-
|
|
6
|
-
interface FilterButtonProps<V> {
|
|
7
|
-
options: { label: string; value: V }[]
|
|
8
|
-
value?: V
|
|
9
|
-
buttonStyle?: 'outline' | 'solid'
|
|
10
|
-
onChange?: (value: V) => void
|
|
11
|
-
style?: CSSProperties
|
|
12
|
-
disabled?: boolean
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const RadioButton = <V = string | number | boolean | null>(props: FilterButtonProps<V>) => {
|
|
16
|
-
const { value, options, buttonStyle = 'outline', disabled, style, onChange } = props
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<Radio.Group
|
|
20
|
-
optionType='button'
|
|
21
|
-
buttonStyle={buttonStyle}
|
|
22
|
-
value={value}
|
|
23
|
-
style={style}
|
|
24
|
-
disabled={disabled}
|
|
25
|
-
onChange={e => onChange?.(e.target.value as V)}
|
|
26
|
-
>
|
|
27
|
-
{options.filter(item => item.label).map(item => (
|
|
28
|
-
<Radio key={String(item.value)} value={item.value}>{item.label}</Radio>
|
|
29
|
-
))}
|
|
30
|
-
</Radio.Group>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { Upload } from 'antd'
|
|
4
|
-
import { InboxOutlined } from '@ant-design/icons'
|
|
5
|
-
import { generateUniqueFileName } from '@wzyjs/utils/web'
|
|
6
|
-
|
|
7
|
-
interface item {
|
|
8
|
-
name: string
|
|
9
|
-
url: string
|
|
10
|
-
status: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface UploadFormItemProps {
|
|
14
|
-
oss: any
|
|
15
|
-
multiple?: boolean,
|
|
16
|
-
mode?: 'image' | 'video'
|
|
17
|
-
value?: item[]
|
|
18
|
-
onChange?: (value: item[]) => void
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const UploadFormItem = (props: UploadFormItemProps) => {
|
|
22
|
-
const { oss, mode = 'image', multiple = true, onChange } = props
|
|
23
|
-
|
|
24
|
-
const accept = mode === 'image' ? '.jpg,.png,.jpeg' : '.mp4,.mov'
|
|
25
|
-
|
|
26
|
-
const onUpload = async (info: any) => {
|
|
27
|
-
onChange?.(info.fileList.map((item: any) => ({
|
|
28
|
-
name: item?.response.name,
|
|
29
|
-
url: item?.response.url,
|
|
30
|
-
})))
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const customRequest = async ({ file, onSuccess }: any) => {
|
|
34
|
-
const newName = generateUniqueFileName(file.name)
|
|
35
|
-
const result = await oss.put(newName, file, {
|
|
36
|
-
headers: {
|
|
37
|
-
'Cache-Control': 'public, max-age=31536000, immutable', // 设置缓存时间为365天
|
|
38
|
-
},
|
|
39
|
-
})
|
|
40
|
-
onSuccess(result)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<Upload.Dragger
|
|
45
|
-
multiple={multiple}
|
|
46
|
-
accept={accept}
|
|
47
|
-
listType='picture-card'
|
|
48
|
-
onChange={onUpload}
|
|
49
|
-
customRequest={customRequest}
|
|
50
|
-
>
|
|
51
|
-
<p className='ant-upload-drag-icon'>
|
|
52
|
-
<InboxOutlined />
|
|
53
|
-
</p>
|
|
54
|
-
<p className='ant-upload-text'>
|
|
55
|
-
<span>点击或拖拽文件到这里以上传</span>
|
|
56
|
-
</p>
|
|
57
|
-
{mode === 'image' && (
|
|
58
|
-
<p className='ant-upload-hint'>支持上传多张 JPG 或者 PNG 格式的照片</p>
|
|
59
|
-
)}
|
|
60
|
-
{mode === 'video' && (
|
|
61
|
-
<p className='ant-upload-hint'>支持上传多个 MP4 或者 MOV 格式的视频</p>
|
|
62
|
-
)}
|
|
63
|
-
</Upload.Dragger>
|
|
64
|
-
)
|
|
65
|
-
}
|