@wzyjs/uis 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/package.json +49 -0
  2. package/src/antd/form/CheckboxButton/index.module.scss +24 -0
  3. package/src/antd/form/CheckboxButton/index.tsx +31 -0
  4. package/src/antd/form/RadioButton/index.tsx +30 -0
  5. package/src/antd/form/Upload/index.tsx +65 -0
  6. package/src/antd/form/UploadImage/index.tsx +338 -0
  7. package/src/antd/form/index.ts +5 -0
  8. package/src/antd/index.ts +43 -0
  9. package/src/antd/pro/Alert/index.tsx +24 -0
  10. package/src/antd/pro/Button/components/Confirm.tsx +24 -0
  11. package/src/antd/pro/Button/components/Copy.tsx +46 -0
  12. package/src/antd/pro/Button/components/Drawer.tsx +37 -0
  13. package/src/antd/pro/Button/components/Group.tsx +26 -0
  14. package/src/antd/pro/Button/index.tsx +11 -0
  15. package/src/antd/pro/Card/index.tsx +92 -0
  16. package/src/antd/pro/Collapse/components/Item.tsx +30 -0
  17. package/src/antd/pro/Collapse/index.tsx +27 -0
  18. package/src/antd/pro/Image/index.tsx +17 -0
  19. package/src/antd/pro/Input/components/Range.tsx +46 -0
  20. package/src/antd/pro/Input/index.tsx +61 -0
  21. package/src/antd/pro/Popconfirm/index.tsx +16 -0
  22. package/src/antd/pro/Radio/components/Cancel.tsx +30 -0
  23. package/src/antd/pro/Radio/index.tsx +7 -0
  24. package/src/antd/pro/Space/index.tsx +15 -0
  25. package/src/antd/pro/Typography/components/String.tsx +72 -0
  26. package/src/antd/pro/Typography/index.tsx +9 -0
  27. package/src/antd/pro/index.ts +10 -0
  28. package/src/components/BottomBar/index.tsx +28 -0
  29. package/src/components/CodeView/index.tsx +85 -0
  30. package/src/components/Collapse/index.tsx +26 -0
  31. package/src/components/Com2Canvas/index.tsx +60 -0
  32. package/src/components/CompileHtml/index.tsx +26 -0
  33. package/src/components/DateSwitcher/index.module.scss +10 -0
  34. package/src/components/DateSwitcher/index.tsx +75 -0
  35. package/src/components/DownloadLink/index.tsx +36 -0
  36. package/src/components/DragSort/index.tsx +77 -0
  37. package/src/components/DynamicSelect/index.tsx +77 -0
  38. package/src/components/DynamicSelect/utils.ts +47 -0
  39. package/src/components/EnumTag/index.tsx +24 -0
  40. package/src/components/FetchSelect/index.tsx +57 -0
  41. package/src/components/Fold/index.tsx +52 -0
  42. package/src/components/FormPro/index.tsx +28 -0
  43. package/src/components/GroupLayout/index.tsx +45 -0
  44. package/src/components/HtmlPro/index.tsx +18 -0
  45. package/src/components/IframePro/index.tsx +52 -0
  46. package/src/components/JsonRenderer/index.tsx +115 -0
  47. package/src/components/JsonView/index.tsx +21 -0
  48. package/src/components/Markdown/index.tsx +152 -0
  49. package/src/components/Markdown/style.ts +106 -0
  50. package/src/components/MultiImageDisplay/index.tsx +63 -0
  51. package/src/components/SectorButton/index.tsx +247 -0
  52. package/src/components/TextInput/index.tsx +61 -0
  53. package/src/components/Video/index.tsx +37 -0
  54. package/src/components/index.ts +22 -0
  55. package/src/web.ts +2 -0
@@ -0,0 +1,37 @@
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
+ destroyOnClose
31
+ {..._.omit(props, ['children', 'btnProps'])}
32
+ >
33
+ {children}
34
+ </AntdDrawer>
35
+ </>
36
+ )
37
+ }
@@ -0,0 +1,26 @@
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
+ }
@@ -0,0 +1,11 @@
1
+ import { Group } from './components/Group'
2
+ import { Confirm } from './components/Confirm'
3
+ import { Copy } from './components/Copy'
4
+ import { Drawer } from './components/Drawer'
5
+
6
+ export const ButtonPro = {
7
+ Group,
8
+ Confirm,
9
+ Copy,
10
+ Drawer,
11
+ }
@@ -0,0 +1,92 @@
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
+ })
@@ -0,0 +1,30 @@
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
+ }
@@ -0,0 +1,27 @@
1
+ 'use client'
2
+
3
+ import React from 'react'
4
+ import { Collapse, CollapseProps } from 'antd'
5
+ import { Item, CollapseItemProps } from './components/Item'
6
+
7
+ export interface CollapseProProps extends CollapseProps {
8
+ list?: CollapseItemProps[],
9
+ step?: boolean; // 为true自动给标题添加 `第{index}步:`
10
+ space?: boolean; // 子元素是否有间距
11
+ }
12
+
13
+ export const CollapsePro = (props: CollapseProProps) => {
14
+ const { list = [], step = false, space = true, accordion = true } = props
15
+
16
+ if (!props.children && list.length) {
17
+ props.children = list.map((item, index) => (
18
+ <Item key={index} step={step} space={space} index={index + 1} {...item} />
19
+ ))
20
+ }
21
+
22
+ return (
23
+ <Collapse accordion={accordion} {...props} />
24
+ )
25
+ }
26
+
27
+ CollapsePro.Pane = Item
@@ -0,0 +1,17 @@
1
+ 'use client'
2
+
3
+ import React from 'react'
4
+ import { Image, ImageProps } from 'antd'
5
+
6
+ export type ImageProProps = ImageProps
7
+
8
+ export const ImagePro = (props: ImageProProps) => {
9
+ const { preview = false } = props
10
+
11
+ return (
12
+ <Image
13
+ {...props}
14
+ preview={preview}
15
+ />
16
+ )
17
+ }
@@ -0,0 +1,46 @@
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 RangeProps 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 Range = (props: RangeProps) => {
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
+ }
@@ -0,0 +1,61 @@
1
+ 'use client'
2
+
3
+ import React, { useState, useEffect, useMemo } from 'react'
4
+ import { Input, InputProps } from 'antd'
5
+ import { getStrLength } from '@wzyjs/utils/web'
6
+ import { Range } from './components/Range'
7
+
8
+ export interface InputProProps extends Omit<InputProps, 'onChange'> {
9
+ maxLengthChinese?: boolean; // 限制长度:中文算2个字符
10
+ onChange?: (value: string) => void
11
+ }
12
+
13
+ // 1. 增加对中文字符串的长度限制 (Input的maxLength会认为汉字为1个长度)
14
+ export const InputPro = (props: InputProProps) => {
15
+ const {
16
+ value: _value,
17
+ onChange: _onChange,
18
+ addonAfter: _addonAfter,
19
+ maxLength,
20
+ maxLengthChinese,
21
+ ...rest
22
+ } = props
23
+
24
+ const [value, setValue] = useState<string>('')
25
+
26
+ const addonAfter = useMemo(() => {
27
+ if (!maxLengthChinese) {
28
+ return _addonAfter
29
+ }
30
+
31
+ return (
32
+ <>
33
+ {_addonAfter}
34
+ {maxLength ? `${getStrLength(value)} / ${maxLength}` : null}
35
+ </>
36
+ )
37
+ }, [_addonAfter, value, maxLength])
38
+
39
+ useEffect(() => {
40
+ _onChange?.(value)
41
+ }, [value])
42
+
43
+ const onChange = (ev: React.ChangeEvent<HTMLInputElement>) => {
44
+ if (maxLengthChinese && maxLength && getStrLength(ev.target.value) > maxLength) {
45
+ return
46
+ }
47
+ setValue(ev.target.value)
48
+ }
49
+
50
+ return (
51
+ <Input
52
+ value={value}
53
+ onChange={onChange}
54
+ addonAfter={addonAfter}
55
+ maxLength={maxLength}
56
+ {...rest}
57
+ />
58
+ )
59
+ }
60
+
61
+ InputPro.Range = Range
@@ -0,0 +1,16 @@
1
+ 'use client'
2
+
3
+ import React from 'react'
4
+ import { Popconfirm, PopconfirmProps } from 'antd'
5
+
6
+ export type PopconfirmProProps = PopconfirmProps
7
+
8
+ export const PopconfirmPro = (props: PopconfirmProProps) => {
9
+ return (
10
+ <Popconfirm
11
+ okText="确定"
12
+ cancelText="取消"
13
+ {...props}
14
+ />
15
+ )
16
+ }
@@ -0,0 +1,30 @@
1
+ 'use client'
2
+
3
+ import React from 'react'
4
+ import { Checkbox, CheckboxProps, CheckboxOptionType } from 'antd'
5
+
6
+ export interface CancelProps {
7
+ value: CheckboxProps['value'];
8
+ options: CheckboxOptionType[];
9
+ onChange?: CheckboxProps['onChange'];
10
+ }
11
+
12
+ // 给Radio组件增加取消选择的功能,是用Checkbox组件实现的
13
+ export const Cancel = (props: CancelProps) => {
14
+ const { value, options, onChange } = props
15
+
16
+ const evs = {
17
+ onChange: (checkedValue: CheckboxProps['value'][]) => {
18
+ onChange?.(checkedValue.find(i => i !== value) || '')
19
+ },
20
+ }
21
+
22
+ return (
23
+ <Checkbox.Group
24
+ value={[value]}
25
+ prefixCls='ant-radio'
26
+ options={options}
27
+ onChange={evs.onChange}
28
+ />
29
+ )
30
+ }
@@ -0,0 +1,7 @@
1
+ 'use client'
2
+
3
+ import { Cancel } from './components/Cancel'
4
+
5
+ export const RadioPro = {
6
+ Cancel,
7
+ }
@@ -0,0 +1,15 @@
1
+ 'use client'
2
+
3
+ import React from 'react'
4
+ import { Space, SpaceProps } from 'antd'
5
+
6
+ export type SpaceProProps = SpaceProps
7
+
8
+ export const SpacePro = (props: SpaceProProps) => {
9
+ return (
10
+ <Space
11
+ style={{ width: '100%' }}
12
+ {...props}
13
+ />
14
+ )
15
+ }
@@ -0,0 +1,72 @@
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
+ }
@@ -0,0 +1,9 @@
1
+ 'use client'
2
+
3
+ import { String as String_ } from './components/String'
4
+
5
+ export const TypographyPro = {
6
+ String: String_,
7
+ }
8
+
9
+ export const String = String_
@@ -0,0 +1,10 @@
1
+ export * from './Alert'
2
+ export * from './Button'
3
+ export * from './Card'
4
+ export * from './Collapse'
5
+ export * from './Image'
6
+ export * from './Input'
7
+ export * from './Radio'
8
+ export * from './Space'
9
+ export * from './Typography'
10
+ export * from './Popconfirm'
@@ -0,0 +1,28 @@
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
+ }
@@ -0,0 +1,85 @@
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
+ }
@@ -0,0 +1,26 @@
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
+ }