@wzyjs/uis 0.3.29 → 0.3.31
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.css +363 -0
- package/dist/web.d.ts +7 -0
- package/dist/web.js +7 -0
- package/package.json +34 -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/FoldCard/index.tsx +0 -131
- package/src/antd/pro/RangeInput/index.tsx +0 -46
- 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/buttons/ButtonGroup.tsx +0 -26
- package/src/antd/pro/buttons/ConfirmButton.tsx +0 -24
- package/src/antd/pro/buttons/CopyButton.tsx +0 -47
- package/src/antd/pro/buttons/DrawerButton.tsx +0 -37
- package/src/antd/pro/buttons/index.tsx +0 -4
- package/src/antd/pro/index.ts +0 -5
- 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 -76
- package/src/components/DynamicSelect/types.ts +0 -8
- package/src/components/DynamicSelect/utils.ts +0 -47
- package/src/components/EnumTag/index.tsx +0 -24
- package/src/components/FetchSelect/index.tsx +0 -57
- 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 -26
- package/src/rn.ts +0 -1
- package/src/rns/index.ts +0 -0
- package/src/web.ts +0 -2
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React, { useState, useRef, useEffect, forwardRef, CSSProperties } from 'react'
|
|
4
|
-
import { Card, Button, CardProps } from 'antd'
|
|
5
|
-
import { DownOutlined, UpOutlined } from '@ant-design/icons'
|
|
6
|
-
|
|
7
|
-
export interface FoldCardProps extends CardProps {
|
|
8
|
-
max?: number; // 默认折叠高度,可根据需要调整
|
|
9
|
-
buttonStyle?: CSSProperties;
|
|
10
|
-
defaultCollapsed?: boolean;
|
|
11
|
-
showButtonOnHover?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const FoldCard = forwardRef((props: FoldCardProps, ref: any) => {
|
|
15
|
-
const {
|
|
16
|
-
max,
|
|
17
|
-
buttonStyle,
|
|
18
|
-
defaultCollapsed = true,
|
|
19
|
-
showButtonOnHover = true,
|
|
20
|
-
children,
|
|
21
|
-
style,
|
|
22
|
-
onMouseEnter,
|
|
23
|
-
onMouseLeave,
|
|
24
|
-
...rest
|
|
25
|
-
} = props
|
|
26
|
-
|
|
27
|
-
const maxHeight = max ?? 300
|
|
28
|
-
|
|
29
|
-
const [collapsed, setCollapsed] = useState(defaultCollapsed)
|
|
30
|
-
const [hovered, setHovered] = useState(false)
|
|
31
|
-
const [isOverflow, setIsOverflow] = useState(false)
|
|
32
|
-
const contentRef = useRef<HTMLDivElement>(null)
|
|
33
|
-
|
|
34
|
-
const measureOverflow = () => {
|
|
35
|
-
const contentEl = contentRef.current
|
|
36
|
-
if (!contentEl) {
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
setIsOverflow(contentEl.scrollHeight > maxHeight)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const toggleCollapse = (ev: React.MouseEvent<HTMLElement>) => {
|
|
44
|
-
ev.stopPropagation()
|
|
45
|
-
setCollapsed(value => !value)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
measureOverflow()
|
|
50
|
-
|
|
51
|
-
const contentEl = contentRef.current
|
|
52
|
-
if (!contentEl || typeof ResizeObserver === 'undefined') {
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const observer = new ResizeObserver(measureOverflow)
|
|
57
|
-
observer.observe(contentEl)
|
|
58
|
-
return () => observer.disconnect()
|
|
59
|
-
}, [children, maxHeight])
|
|
60
|
-
|
|
61
|
-
const contentStyle: CSSProperties = {
|
|
62
|
-
maxHeight: collapsed ? maxHeight : undefined,
|
|
63
|
-
transition: 'max-height 0.3s ease',
|
|
64
|
-
overflow: collapsed ? 'hidden' : 'visible',
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const hoverButtonContainerStyle: CSSProperties = {
|
|
68
|
-
position: 'absolute',
|
|
69
|
-
bottom: hovered ? 10 : -40,
|
|
70
|
-
left: '50%',
|
|
71
|
-
transform: 'translateX(-50%)',
|
|
72
|
-
transition: 'bottom 0.3s ease, opacity 0.3s ease',
|
|
73
|
-
display: 'flex',
|
|
74
|
-
justifyContent: 'center',
|
|
75
|
-
width: '100%',
|
|
76
|
-
pointerEvents: 'none',
|
|
77
|
-
opacity: hovered && isOverflow ? 1 : 0,
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const inlineButtonContainerStyle: CSSProperties = {
|
|
81
|
-
textAlign: 'center',
|
|
82
|
-
marginTop: 8,
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const finalButtonStyle: CSSProperties = {
|
|
86
|
-
pointerEvents: 'auto',
|
|
87
|
-
border: 'none',
|
|
88
|
-
boxShadow: showButtonOnHover ? '0 2px 8px rgba(0, 0, 0, 0.15)' : undefined,
|
|
89
|
-
...buttonStyle,
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const button = (
|
|
93
|
-
<Button
|
|
94
|
-
size='small'
|
|
95
|
-
icon={collapsed ? <DownOutlined /> : <UpOutlined />}
|
|
96
|
-
onClick={toggleCollapse}
|
|
97
|
-
style={finalButtonStyle}
|
|
98
|
-
/>
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
<Card
|
|
103
|
-
ref={ref}
|
|
104
|
-
style={{ position: 'relative', overflow: 'hidden', ...style }}
|
|
105
|
-
onMouseEnter={(ev) => {
|
|
106
|
-
setHovered(true)
|
|
107
|
-
onMouseEnter?.(ev)
|
|
108
|
-
}}
|
|
109
|
-
onMouseLeave={(ev) => {
|
|
110
|
-
setHovered(false)
|
|
111
|
-
onMouseLeave?.(ev)
|
|
112
|
-
}}
|
|
113
|
-
{...rest}
|
|
114
|
-
>
|
|
115
|
-
<div style={contentStyle} ref={contentRef}>
|
|
116
|
-
{children}
|
|
117
|
-
</div>
|
|
118
|
-
{isOverflow && (
|
|
119
|
-
showButtonOnHover ? (
|
|
120
|
-
<div style={hoverButtonContainerStyle}>
|
|
121
|
-
{button}
|
|
122
|
-
</div>
|
|
123
|
-
) : (
|
|
124
|
-
<div style={inlineButtonContainerStyle}>
|
|
125
|
-
{button}
|
|
126
|
-
</div>
|
|
127
|
-
)
|
|
128
|
-
)}
|
|
129
|
-
</Card>
|
|
130
|
-
)
|
|
131
|
-
})
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import { InputNumber, InputNumberProps, Space } from 'antd'
|
|
5
|
-
import { _ } from '@wzyjs/utils/web'
|
|
6
|
-
|
|
7
|
-
export interface RangeInputProps extends Omit<InputNumberProps, 'value' | 'onChange'> {
|
|
8
|
-
value?: number[];
|
|
9
|
-
min?: number;
|
|
10
|
-
max?: number;
|
|
11
|
-
onChange?: (numbers: number[]) => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// 最小值 最大值 的输入框
|
|
15
|
-
export const RangeInput = (props: RangeInputProps) => {
|
|
16
|
-
const { value = [], min, max, onChange } = props
|
|
17
|
-
|
|
18
|
-
const onNumberChange = (index: 0 | 1, v: number | null) => {
|
|
19
|
-
if (Number.isNaN(v) || v === null) {
|
|
20
|
-
return
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const numbers = _.cloneDeep(value) || []
|
|
24
|
-
numbers[index] = v
|
|
25
|
-
|
|
26
|
-
onChange?.(numbers)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<Space>
|
|
31
|
-
<InputNumber
|
|
32
|
-
min={min}
|
|
33
|
-
max={max}
|
|
34
|
-
value={value[0]}
|
|
35
|
-
onChange={(v: number | null) => onNumberChange(0, v)}
|
|
36
|
-
/>
|
|
37
|
-
<span style={{ margin: '0 3px' }}> - </span>
|
|
38
|
-
<InputNumber
|
|
39
|
-
min={min}
|
|
40
|
-
max={max}
|
|
41
|
-
value={value[1]}
|
|
42
|
-
onChange={(v: number | null) => onNumberChange(1, v)}
|
|
43
|
-
/>
|
|
44
|
-
</Space>
|
|
45
|
-
)
|
|
46
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import { Tabs, type TabsProps } from 'antd'
|
|
5
|
-
|
|
6
|
-
type SyncMode = 'replace' | 'push'
|
|
7
|
-
|
|
8
|
-
export interface TabsProProps extends TabsProps {
|
|
9
|
-
syncToUrl?: boolean
|
|
10
|
-
queryKey?: string
|
|
11
|
-
historyMode?: SyncMode
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const getItemKeys = (items?: TabsProps['items']): string[] => {
|
|
15
|
-
return (items || [])
|
|
16
|
-
.map(item => item?.key)
|
|
17
|
-
.filter((key): key is string => typeof key === 'string' && !!key)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const getUrlTabKey = (queryKey: string): string | undefined => {
|
|
21
|
-
if (typeof window === 'undefined') {
|
|
22
|
-
return undefined
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const value = new URLSearchParams(window.location.search).get(queryKey)
|
|
26
|
-
return value || undefined
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const updateUrlTabKey = (queryKey: string, key: string, mode: SyncMode) => {
|
|
30
|
-
if (typeof window === 'undefined') {
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const url = new URL(window.location.href)
|
|
35
|
-
url.searchParams.set(queryKey, key)
|
|
36
|
-
|
|
37
|
-
const nextUrl = `${url.pathname}${url.search}${url.hash}`
|
|
38
|
-
if (mode === 'push') {
|
|
39
|
-
window.history.pushState(window.history.state, '', nextUrl)
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
window.history.replaceState(window.history.state, '', nextUrl)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const TabsPro = (props: TabsProProps) => {
|
|
47
|
-
const {
|
|
48
|
-
syncToUrl = false,
|
|
49
|
-
queryKey = 'tab',
|
|
50
|
-
historyMode = 'replace',
|
|
51
|
-
activeKey,
|
|
52
|
-
defaultActiveKey,
|
|
53
|
-
items,
|
|
54
|
-
onChange,
|
|
55
|
-
...rest
|
|
56
|
-
} = props
|
|
57
|
-
|
|
58
|
-
const itemKeys = React.useMemo(() => getItemKeys(items), [items])
|
|
59
|
-
|
|
60
|
-
const initialKey = React.useMemo(() => {
|
|
61
|
-
const urlKey = syncToUrl ? getUrlTabKey(queryKey) : undefined
|
|
62
|
-
if (urlKey && itemKeys.includes(urlKey)) {
|
|
63
|
-
return urlKey
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (typeof defaultActiveKey === 'string' && itemKeys.includes(defaultActiveKey)) {
|
|
67
|
-
return defaultActiveKey
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return itemKeys[0]
|
|
71
|
-
}, [defaultActiveKey, itemKeys, queryKey, syncToUrl])
|
|
72
|
-
|
|
73
|
-
const [innerActiveKey, setInnerActiveKey] = React.useState<string | undefined>(initialKey)
|
|
74
|
-
|
|
75
|
-
const mergedActiveKey = typeof activeKey === 'string' ? activeKey : innerActiveKey
|
|
76
|
-
|
|
77
|
-
React.useEffect(() => {
|
|
78
|
-
if (typeof activeKey === 'string') {
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
setInnerActiveKey(prev => {
|
|
83
|
-
if (prev && itemKeys.includes(prev)) {
|
|
84
|
-
return prev
|
|
85
|
-
}
|
|
86
|
-
return initialKey
|
|
87
|
-
})
|
|
88
|
-
}, [activeKey, initialKey, itemKeys])
|
|
89
|
-
|
|
90
|
-
React.useEffect(() => {
|
|
91
|
-
if (!syncToUrl || !mergedActiveKey) {
|
|
92
|
-
return
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
updateUrlTabKey(queryKey, mergedActiveKey, historyMode)
|
|
96
|
-
}, [historyMode, mergedActiveKey, queryKey, syncToUrl])
|
|
97
|
-
|
|
98
|
-
React.useEffect(() => {
|
|
99
|
-
if (!syncToUrl) {
|
|
100
|
-
return
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const onPopState = () => {
|
|
104
|
-
const urlKey = getUrlTabKey(queryKey)
|
|
105
|
-
if (!urlKey || !itemKeys.includes(urlKey)) {
|
|
106
|
-
return
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (typeof activeKey !== 'string') {
|
|
110
|
-
setInnerActiveKey(urlKey)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
onChange?.(urlKey)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
window.addEventListener('popstate', onPopState)
|
|
117
|
-
return () => {
|
|
118
|
-
window.removeEventListener('popstate', onPopState)
|
|
119
|
-
}
|
|
120
|
-
}, [activeKey, itemKeys, onChange, queryKey, syncToUrl])
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<Tabs
|
|
124
|
-
{...rest}
|
|
125
|
-
items={items}
|
|
126
|
-
activeKey={mergedActiveKey}
|
|
127
|
-
onChange={key => {
|
|
128
|
-
if (typeof activeKey !== 'string') {
|
|
129
|
-
setInnerActiveKey(key)
|
|
130
|
-
}
|
|
131
|
-
onChange?.(key)
|
|
132
|
-
}}
|
|
133
|
-
/>
|
|
134
|
-
)
|
|
135
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React, { useMemo } from 'react'
|
|
4
|
-
|
|
5
|
-
import { Typography } from 'antd'
|
|
6
|
-
import { TextProps } from 'antd/lib/typography/Text'
|
|
7
|
-
|
|
8
|
-
import { replaceByRules } from '@wzyjs/utils/web'
|
|
9
|
-
|
|
10
|
-
export interface StringProps extends TextProps {
|
|
11
|
-
isCopy?: boolean;
|
|
12
|
-
isEllipsis?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const String = (props: StringProps) => {
|
|
16
|
-
const { isEllipsis, isCopy, children } = props
|
|
17
|
-
|
|
18
|
-
const { source = '', __html = '' } = useMemo<{ source?: string, __html?: string }>(() => {
|
|
19
|
-
if (typeof children !== 'string') {
|
|
20
|
-
return {}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (!children.includes('’')) {
|
|
24
|
-
return {
|
|
25
|
-
source: children.trim(),
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
source: children.trim(),
|
|
31
|
-
__html: replaceByRules(children.trim(), [
|
|
32
|
-
[
|
|
33
|
-
'‘',
|
|
34
|
-
'<xmp style="display: inline-block; color: #d56161; margin: 0 3px; font-family: Consolas, Monaco, monospace;">',
|
|
35
|
-
],
|
|
36
|
-
['’', '</xmp>'],
|
|
37
|
-
]),
|
|
38
|
-
}
|
|
39
|
-
}, [])
|
|
40
|
-
|
|
41
|
-
const ellipsis = useMemo(() => {
|
|
42
|
-
if (!isEllipsis) {
|
|
43
|
-
return false
|
|
44
|
-
}
|
|
45
|
-
return { rows: 100, expandable: true }
|
|
46
|
-
}, [isEllipsis])
|
|
47
|
-
|
|
48
|
-
const copyable = useMemo(() => {
|
|
49
|
-
if (!isCopy) {
|
|
50
|
-
return
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
text: replaceByRules(source, [
|
|
54
|
-
['‘', ''],
|
|
55
|
-
['’', ''],
|
|
56
|
-
]),
|
|
57
|
-
}
|
|
58
|
-
}, [isCopy, source])
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<Typography.Paragraph
|
|
62
|
-
{...props}
|
|
63
|
-
ellipsis={ellipsis}
|
|
64
|
-
copyable={copyable}
|
|
65
|
-
>
|
|
66
|
-
<span
|
|
67
|
-
style={{ whiteSpace: 'pre' }}
|
|
68
|
-
dangerouslySetInnerHTML={{ __html: __html || source }}
|
|
69
|
-
/>
|
|
70
|
-
</Typography.Paragraph>
|
|
71
|
-
)
|
|
72
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import { Space } from 'antd'
|
|
5
|
-
import { ConfirmButton, ConfirmButtonProps } from './ConfirmButton'
|
|
6
|
-
|
|
7
|
-
export interface ButtonGroupProps {
|
|
8
|
-
list?: (ConfirmButtonProps & { visible?: boolean, title?: string })[]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// 1. 按钮组
|
|
12
|
-
export const ButtonGroup = (props: ButtonGroupProps) => {
|
|
13
|
-
const { list = [] } = props
|
|
14
|
-
|
|
15
|
-
if (!list?.length) {
|
|
16
|
-
return null
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<Space.Compact>
|
|
21
|
-
{list.filter(item => item.visible).map((item, index) => (
|
|
22
|
-
<ConfirmButton key={index} {...item}>{item.title}</ConfirmButton>
|
|
23
|
-
))}
|
|
24
|
-
</Space.Compact>
|
|
25
|
-
)
|
|
26
|
-
}
|
|
@@ -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 ConfirmButtonProps extends PopconfirmProps {
|
|
8
|
-
btnProps?: ButtonProps
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// 1. 给按钮增加了确认功能
|
|
12
|
-
export const ConfirmButton = (props: ConfirmButtonProps) => {
|
|
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 CopyButtonProps extends ButtonProps {
|
|
12
|
-
value?: string,
|
|
13
|
-
canPaste?: boolean,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const CopyButton = (props: CopyButtonProps) => {
|
|
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 DrawerButtonProps extends AntdDrawerProps {
|
|
8
|
-
btnProps?: ButtonProps
|
|
9
|
-
defaultOpen?: boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const DrawerButton = (props: DrawerButtonProps) => {
|
|
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
|
-
}
|
package/src/antd/pro/index.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { ReactNode } from 'react'
|
|
4
|
-
|
|
5
|
-
interface BottomBarProps {
|
|
6
|
-
children?: ReactNode
|
|
7
|
-
collapsed?: boolean
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const style = {
|
|
11
|
-
display: 'flex',
|
|
12
|
-
justifyContent: 'center',
|
|
13
|
-
padding: 10,
|
|
14
|
-
right: 0,
|
|
15
|
-
bottom: 0,
|
|
16
|
-
boxShadow: '0 0 2px 0 rgba(0, 0, 0, 0.1)',
|
|
17
|
-
background: '#fff',
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const BottomBar = (props: BottomBarProps) => {
|
|
21
|
-
const { children, collapsed } = props
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<div style={{ ...style, left: collapsed ? 64 : 256, position: 'fixed' }}>
|
|
25
|
-
{children}
|
|
26
|
-
</div>
|
|
27
|
-
)
|
|
28
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React, { CSSProperties, useEffect, useMemo, useRef } from 'react'
|
|
4
|
-
|
|
5
|
-
import Prism from 'prismjs'
|
|
6
|
-
import { format } from 'prettier/standalone'
|
|
7
|
-
import parserBabel from 'prettier/parser-babel'
|
|
8
|
-
import parserTs from 'prettier/parser-typescript'
|
|
9
|
-
import { js_beautify, html_beautify, css_beautify } from 'js-beautify'
|
|
10
|
-
|
|
11
|
-
import 'prismjs/components/prism-jsx'
|
|
12
|
-
import 'prismjs/components/prism-tsx'
|
|
13
|
-
import 'prismjs/components/prism-json'
|
|
14
|
-
|
|
15
|
-
import 'prismjs/components/prism-javascript'
|
|
16
|
-
import 'prismjs/components/prism-typescript'
|
|
17
|
-
|
|
18
|
-
import 'prismjs/components/prism-css'
|
|
19
|
-
import 'prismjs/components/prism-less'
|
|
20
|
-
import 'prismjs/components/prism-sass'
|
|
21
|
-
import 'prismjs/components/prism-scss'
|
|
22
|
-
|
|
23
|
-
import 'prismjs/components/prism-bash'
|
|
24
|
-
import 'prismjs/components/prism-http'
|
|
25
|
-
import 'prismjs/components/prism-editorconfig'
|
|
26
|
-
import 'prismjs/components/prism-docker'
|
|
27
|
-
import 'prismjs/components/prism-git'
|
|
28
|
-
import 'prismjs/components/prism-ignore'
|
|
29
|
-
import 'prismjs/components/prism-yaml'
|
|
30
|
-
|
|
31
|
-
import 'prismjs/themes/prism.css'
|
|
32
|
-
|
|
33
|
-
interface CodeViewProps {
|
|
34
|
-
language?: 'html' | 'jsx' | 'tsx' | 'vue' | 'json' | 'javascript' | 'typescript' | 'css' | 'less' | 'sass' | 'scss' | 'bash' | 'http' | 'editorconfig' | 'dockerfile' | 'git' | 'ignore' | 'yaml'
|
|
35
|
-
code?: string,
|
|
36
|
-
children?: any,
|
|
37
|
-
style?: CSSProperties,
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const CodeView = (props: CodeViewProps) => {
|
|
41
|
-
const { language = 'javascript', style, children, code = children } = props
|
|
42
|
-
|
|
43
|
-
const preRef = useRef(null)
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
if (!preRef.current) {
|
|
46
|
-
return
|
|
47
|
-
}
|
|
48
|
-
Prism.highlightElement(preRef.current)
|
|
49
|
-
}, [])
|
|
50
|
-
|
|
51
|
-
const beautifydCode = useMemo(() => {
|
|
52
|
-
if (language === 'html') {
|
|
53
|
-
return html_beautify(code, { indent_size: 2 })
|
|
54
|
-
}
|
|
55
|
-
if (language === 'css') {
|
|
56
|
-
return css_beautify(code, { indent_size: 2 })
|
|
57
|
-
}
|
|
58
|
-
if (language === 'javascript') {
|
|
59
|
-
return js_beautify(code, { indent_size: 2 })
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
return format(code, {
|
|
64
|
-
semi: false,
|
|
65
|
-
parser: 'babel',
|
|
66
|
-
singleQuote: true,
|
|
67
|
-
tabWidth: 2,
|
|
68
|
-
jsxSingleQuote: true,
|
|
69
|
-
plugins: [parserBabel, parserTs],
|
|
70
|
-
})
|
|
71
|
-
} catch (e) {
|
|
72
|
-
return code
|
|
73
|
-
}
|
|
74
|
-
}, [code])
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<div style={{ overflow: 'scroll', ...style }}>
|
|
78
|
-
<pre style={{ margin: 0, backgroundColor: 'transparent' }}>
|
|
79
|
-
<code ref={preRef} className={`language-${language}`}>
|
|
80
|
-
{beautifydCode}
|
|
81
|
-
</code>
|
|
82
|
-
</pre>
|
|
83
|
-
</div>
|
|
84
|
-
)
|
|
85
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { ReactNode } from 'react'
|
|
4
|
-
import { useBoolean } from '@wzyjs/hooks/web'
|
|
5
|
-
import { RightOutlined, LeftOutlined } from '@ant-design/icons'
|
|
6
|
-
|
|
7
|
-
interface CollapseProps {
|
|
8
|
-
children: ReactNode
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const Collapse = (props: CollapseProps) => {
|
|
12
|
-
const { children } = props
|
|
13
|
-
|
|
14
|
-
const [collapse, { setTrue, setFalse }] = useBoolean(false)
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<div>
|
|
18
|
-
<div style={{ transform: 'translateY(100px)' }}>
|
|
19
|
-
{collapse ? <LeftOutlined onClick={setFalse} /> : <RightOutlined onClick={setTrue} />}
|
|
20
|
-
</div>
|
|
21
|
-
<div style={{ width: collapse ? 0 : 'auto', visibility: collapse ? 'hidden' : 'visible' }}>
|
|
22
|
-
{children}
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
)
|
|
26
|
-
}
|