deepsea-components 5.7.0 → 5.7.2
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/README.md +23 -23
- package/dist/cjs/components/AutoFit.js +3 -1
- package/dist/cjs/components/AutoFit.js.map +2 -2
- package/dist/cjs/components/AutoScroll.js +16 -1
- package/dist/cjs/components/AutoScroll.js.map +2 -2
- package/dist/cjs/components/AutoSizeTextarea.js.map +1 -1
- package/dist/cjs/components/CircleText.js +31 -2
- package/dist/cjs/components/CircleText.js.map +2 -2
- package/dist/cjs/components/CopyButton.js.map +1 -1
- package/dist/cjs/components/Echart.js.map +2 -2
- package/dist/cjs/components/Flow.js +56 -3
- package/dist/cjs/components/Flow.js.map +2 -2
- package/dist/cjs/components/FormLabel.js.map +1 -1
- package/dist/cjs/components/HlsPlayer.js.map +1 -1
- package/dist/cjs/components/InfiniteScroll.js +15 -1
- package/dist/cjs/components/InfiniteScroll.js.map +2 -2
- package/dist/cjs/components/InputFile.js.map +1 -1
- package/dist/cjs/components/LoopSwiper.js +23 -2
- package/dist/cjs/components/LoopSwiper.js.map +2 -2
- package/dist/cjs/components/Ring.js +13 -1
- package/dist/cjs/components/Ring.js.map +2 -2
- package/dist/cjs/components/Scroll.js.map +2 -2
- package/dist/cjs/components/SectionRing.js +3 -1
- package/dist/cjs/components/SectionRing.js.map +2 -2
- package/dist/cjs/components/Skeleton.js.map +2 -2
- package/dist/cjs/components/Title.js.map +2 -2
- package/dist/cjs/components/TransitionBox.js +9 -1
- package/dist/cjs/components/TransitionBox.js.map +2 -2
- package/dist/cjs/components/TransitionNum.js.map +1 -1
- package/dist/cjs/components/Trapezium.js.map +1 -1
- package/dist/cjs/utils/getReactVersion.js.map +1 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/esm/components/AutoFit.js +9 -9
- package/dist/esm/components/AutoFit.js.map +1 -1
- package/dist/esm/components/AutoScroll.js.map +1 -1
- package/dist/esm/components/AutoSizeTextarea.js +2 -2
- package/dist/esm/components/AutoSizeTextarea.js.map +1 -1
- package/dist/esm/components/CircleText.js.map +1 -1
- package/dist/esm/components/CopyButton.js.map +1 -1
- package/dist/esm/components/Echart.js.map +1 -1
- package/dist/esm/components/Flow.js.map +1 -1
- package/dist/esm/components/FormLabel.js +2 -2
- package/dist/esm/components/FormLabel.js.map +1 -1
- package/dist/esm/components/HlsPlayer.js.map +1 -1
- package/dist/esm/components/InfiniteScroll.js +4 -4
- package/dist/esm/components/InfiniteScroll.js.map +1 -1
- package/dist/esm/components/InputFile.js.map +1 -1
- package/dist/esm/components/LoopSwiper.js.map +1 -1
- package/dist/esm/components/Ring.js.map +1 -1
- package/dist/esm/components/Scroll.js.map +1 -1
- package/dist/esm/components/SectionRing.js.map +1 -1
- package/dist/esm/components/Skeleton.js.map +1 -1
- package/dist/esm/components/Title.js.map +1 -1
- package/dist/esm/components/TransitionBox.js.map +1 -1
- package/dist/esm/components/TransitionNum.js.map +1 -1
- package/dist/esm/components/Trapezium.js.map +1 -1
- package/dist/esm/utils/getReactVersion.js.map +1 -1
- package/dist/esm/utils/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/AutoFit.tsx +103 -101
- package/src/components/AutoScroll.tsx +148 -132
- package/src/components/AutoSizeTextarea.tsx +49 -49
- package/src/components/CircleText.tsx +81 -56
- package/src/components/CopyButton.tsx +29 -29
- package/src/components/Echart.tsx +67 -44
- package/src/components/Flow.tsx +270 -214
- package/src/components/FormLabel.tsx +38 -38
- package/src/components/HlsPlayer.tsx +34 -34
- package/src/components/InfiniteScroll.tsx +161 -135
- package/src/components/InputFile.tsx +234 -234
- package/src/components/LoopSwiper.tsx +125 -101
- package/src/components/Ring.tsx +30 -19
- package/src/components/Scroll.tsx +96 -95
- package/src/components/SectionRing.tsx +39 -36
- package/src/components/Skeleton.tsx +47 -46
- package/src/components/Title.tsx +23 -24
- package/src/components/TransitionBox.tsx +44 -36
- package/src/components/TransitionNum.tsx +54 -54
- package/src/components/Trapezium.tsx +59 -59
- package/src/utils/getReactVersion.ts +7 -7
- package/src/utils/index.ts +33 -33
|
@@ -1,56 +1,81 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { FC, Fragment, HTMLAttributes } from "react"
|
|
4
|
-
|
|
5
|
-
export interface CircleTextProps extends Omit<HTMLAttributes<HTMLSpanElement>, "children"> {
|
|
6
|
-
/** 每一个方块的宽度 */
|
|
7
|
-
width: number
|
|
8
|
-
/** 每一个方块的高度 */
|
|
9
|
-
height: number
|
|
10
|
-
/** 圆弧的半径,不包含方块的高度 */
|
|
11
|
-
radius: number
|
|
12
|
-
/** 开始旋转的弧度,逆时针增加,0 为 x 轴方向 */
|
|
13
|
-
startAngel?: number
|
|
14
|
-
/** 每一个方块之间间隔的弧度 */
|
|
15
|
-
gapAngel?: number
|
|
16
|
-
/** 文字对齐的方式,默认居中 */
|
|
17
|
-
align?: "left" | "center" | "right"
|
|
18
|
-
/** 文字朝向圆心还是外侧,默认外侧 */
|
|
19
|
-
direction?: "inner" | "outer"
|
|
20
|
-
/** 是否反转文字顺序 */
|
|
21
|
-
reverse?: boolean
|
|
22
|
-
/** 分割文字的方法 */
|
|
23
|
-
separator?: string | RegExp | ((text: string) => string[])
|
|
24
|
-
/** 显示的文字 */
|
|
25
|
-
children: string
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** 环形文字 */
|
|
29
|
-
export const CircleText: FC<CircleTextProps> = props => {
|
|
30
|
-
const {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { FC, Fragment, HTMLAttributes } from "react"
|
|
4
|
+
|
|
5
|
+
export interface CircleTextProps extends Omit<HTMLAttributes<HTMLSpanElement>, "children"> {
|
|
6
|
+
/** 每一个方块的宽度 */
|
|
7
|
+
width: number
|
|
8
|
+
/** 每一个方块的高度 */
|
|
9
|
+
height: number
|
|
10
|
+
/** 圆弧的半径,不包含方块的高度 */
|
|
11
|
+
radius: number
|
|
12
|
+
/** 开始旋转的弧度,逆时针增加,0 为 x 轴方向 */
|
|
13
|
+
startAngel?: number
|
|
14
|
+
/** 每一个方块之间间隔的弧度 */
|
|
15
|
+
gapAngel?: number
|
|
16
|
+
/** 文字对齐的方式,默认居中 */
|
|
17
|
+
align?: "left" | "center" | "right"
|
|
18
|
+
/** 文字朝向圆心还是外侧,默认外侧 */
|
|
19
|
+
direction?: "inner" | "outer"
|
|
20
|
+
/** 是否反转文字顺序 */
|
|
21
|
+
reverse?: boolean
|
|
22
|
+
/** 分割文字的方法 */
|
|
23
|
+
separator?: string | RegExp | ((text: string) => string[])
|
|
24
|
+
/** 显示的文字 */
|
|
25
|
+
children: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** 环形文字 */
|
|
29
|
+
export const CircleText: FC<CircleTextProps> = props => {
|
|
30
|
+
const {
|
|
31
|
+
width,
|
|
32
|
+
height,
|
|
33
|
+
radius,
|
|
34
|
+
startAngel = 0,
|
|
35
|
+
gapAngel = 0,
|
|
36
|
+
align = "center",
|
|
37
|
+
style,
|
|
38
|
+
direction = "outer",
|
|
39
|
+
reverse = false,
|
|
40
|
+
separator,
|
|
41
|
+
children,
|
|
42
|
+
...rest
|
|
43
|
+
} = props
|
|
44
|
+
const unitAngle = Math.atan(width / 2 / radius) * 2
|
|
45
|
+
const totalAngle = (unitAngle + gapAngel) * children.length - gapAngel
|
|
46
|
+
const offsetAngle = align === "left" ? 0 : align === "right" ? totalAngle : totalAngle / 2
|
|
47
|
+
|
|
48
|
+
function getTransform(idx: number) {
|
|
49
|
+
const angle = startAngel - idx * (unitAngle + gapAngel) + offsetAngle - unitAngle / 2
|
|
50
|
+
const x = (radius + height / 2) * Math.cos(angle) - width / 2
|
|
51
|
+
const y = (radius + height / 2) * Math.sin(angle) * -1 - height / 2
|
|
52
|
+
const z = Math.PI / 2 - angle + (direction === "inner" ? Math.PI : 0)
|
|
53
|
+
return `translateX(${x}px) translateY(${y}px) rotateZ(${(z / Math.PI) * 180}deg)`
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const words = typeof separator === "function" ? separator(children) : children.split(separator ?? "")
|
|
57
|
+
|
|
58
|
+
if (reverse) words.reverse()
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<Fragment>
|
|
62
|
+
{words.map((w, idx) => (
|
|
63
|
+
<span
|
|
64
|
+
key={idx}
|
|
65
|
+
style={{
|
|
66
|
+
position: "absolute",
|
|
67
|
+
...style,
|
|
68
|
+
transform: getTransform(idx),
|
|
69
|
+
textAlign: "center",
|
|
70
|
+
width,
|
|
71
|
+
lineHeight: `${height}px`,
|
|
72
|
+
height: height,
|
|
73
|
+
}}
|
|
74
|
+
{...rest}
|
|
75
|
+
>
|
|
76
|
+
{w}
|
|
77
|
+
</span>
|
|
78
|
+
))}
|
|
79
|
+
</Fragment>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { useLatest } from "ahooks"
|
|
2
|
-
import ClipboardJS, { Event } from "clipboard"
|
|
3
|
-
import { ComponentProps, forwardRef, useEffect, useImperativeHandle, useRef } from "react"
|
|
4
|
-
|
|
5
|
-
export { Event } from "clipboard"
|
|
6
|
-
|
|
7
|
-
export type CopyButtonProps = ComponentProps<"button"> & {
|
|
8
|
-
text?: string
|
|
9
|
-
onCopySuccess?: (e: Event) => void
|
|
10
|
-
onCopyError?: (e: Event) => void
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>((props, ref) => {
|
|
14
|
-
const { text, onCopySuccess: _onCoptSuccess, onCopyError: _onCopyError, ...rest } = props
|
|
15
|
-
const ele = useRef<HTMLButtonElement>(null)
|
|
16
|
-
const onCopySuccess = useLatest(_onCoptSuccess)
|
|
17
|
-
const onCopyError = useLatest(_onCopyError)
|
|
18
|
-
|
|
19
|
-
useImperativeHandle(ref, () => ele.current!, [ele.current])
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
const clipboard = new ClipboardJS(ele.current!)
|
|
23
|
-
clipboard.on("success", event => onCopySuccess.current?.(event))
|
|
24
|
-
clipboard.on("error", event => onCopyError.current?.(event))
|
|
25
|
-
return () => clipboard.destroy()
|
|
26
|
-
}, [])
|
|
27
|
-
|
|
28
|
-
return <button ref={ele} {...rest} data-clipboard-text={text} />
|
|
29
|
-
})
|
|
1
|
+
import { useLatest } from "ahooks"
|
|
2
|
+
import ClipboardJS, { Event } from "clipboard"
|
|
3
|
+
import { ComponentProps, forwardRef, useEffect, useImperativeHandle, useRef } from "react"
|
|
4
|
+
|
|
5
|
+
export { Event } from "clipboard"
|
|
6
|
+
|
|
7
|
+
export type CopyButtonProps = ComponentProps<"button"> & {
|
|
8
|
+
text?: string
|
|
9
|
+
onCopySuccess?: (e: Event) => void
|
|
10
|
+
onCopyError?: (e: Event) => void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>((props, ref) => {
|
|
14
|
+
const { text, onCopySuccess: _onCoptSuccess, onCopyError: _onCopyError, ...rest } = props
|
|
15
|
+
const ele = useRef<HTMLButtonElement>(null)
|
|
16
|
+
const onCopySuccess = useLatest(_onCoptSuccess)
|
|
17
|
+
const onCopyError = useLatest(_onCopyError)
|
|
18
|
+
|
|
19
|
+
useImperativeHandle(ref, () => ele.current!, [ele.current])
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const clipboard = new ClipboardJS(ele.current!)
|
|
23
|
+
clipboard.on("success", event => onCopySuccess.current?.(event))
|
|
24
|
+
clipboard.on("error", event => onCopyError.current?.(event))
|
|
25
|
+
return () => clipboard.destroy()
|
|
26
|
+
}, [])
|
|
27
|
+
|
|
28
|
+
return <button ref={ele} {...rest} data-clipboard-text={text} />
|
|
29
|
+
})
|
|
@@ -1,44 +1,67 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
import {
|
|
2
|
+
BarSeriesOption,
|
|
3
|
+
ComposeOption,
|
|
4
|
+
DatasetComponentOption,
|
|
5
|
+
ECharts,
|
|
6
|
+
GridComponentOption,
|
|
7
|
+
init,
|
|
8
|
+
LineSeriesOption,
|
|
9
|
+
PieSeriesOption,
|
|
10
|
+
TitleComponentOption,
|
|
11
|
+
TooltipComponentOption,
|
|
12
|
+
} from "echarts"
|
|
13
|
+
import {
|
|
14
|
+
ComponentProps,
|
|
15
|
+
ForwardedRef,
|
|
16
|
+
forwardRef,
|
|
17
|
+
ForwardRefExoticComponent,
|
|
18
|
+
RefAttributes,
|
|
19
|
+
useEffect,
|
|
20
|
+
useImperativeHandle,
|
|
21
|
+
useLayoutEffect,
|
|
22
|
+
useRef,
|
|
23
|
+
} from "react"
|
|
24
|
+
|
|
25
|
+
export type PieOption = ComposeOption<PieSeriesOption | TitleComponentOption | DatasetComponentOption | GridComponentOption | TooltipComponentOption>
|
|
26
|
+
|
|
27
|
+
export type BarOption = ComposeOption<BarSeriesOption | TitleComponentOption | DatasetComponentOption | GridComponentOption | TooltipComponentOption>
|
|
28
|
+
|
|
29
|
+
export type LineOption = ComposeOption<LineSeriesOption | TitleComponentOption | DatasetComponentOption | GridComponentOption | TooltipComponentOption>
|
|
30
|
+
|
|
31
|
+
export interface EchartProps<T extends any = any> extends Omit<ComponentProps<"div">, "children"> {
|
|
32
|
+
width: number
|
|
33
|
+
height: number
|
|
34
|
+
option: T
|
|
35
|
+
chart?: ForwardedRef<ECharts>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type EchartComponent<T extends PieOption | BarOption | LineOption> = ForwardRefExoticComponent<
|
|
39
|
+
Omit<EchartProps<T>, "ref"> & RefAttributes<HTMLDivElement>
|
|
40
|
+
>
|
|
41
|
+
|
|
42
|
+
const Echart = forwardRef<HTMLDivElement, EchartProps>((props, ref) => {
|
|
43
|
+
const { width, height, option, chart, ...rest } = props
|
|
44
|
+
const container = useRef<HTMLDivElement>(null)
|
|
45
|
+
const chartRef = useRef<ECharts | null>(null)
|
|
46
|
+
|
|
47
|
+
useLayoutEffect(() => {
|
|
48
|
+
const ele = container.current!
|
|
49
|
+
chartRef.current = init(ele, option, { width, height })
|
|
50
|
+
return () => chartRef.current?.dispose()
|
|
51
|
+
}, [])
|
|
52
|
+
|
|
53
|
+
useImperativeHandle(ref, () => container.current!, [])
|
|
54
|
+
|
|
55
|
+
useImperativeHandle(chart, () => chartRef.current!, [])
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
chartRef.current?.setOption(option)
|
|
59
|
+
chartRef.current?.resize({ width, height })
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
return <div ref={container} {...rest} />
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
export const Pie = Echart as EchartComponent<PieOption>
|
|
66
|
+
export const Bar = Echart as EchartComponent<BarOption>
|
|
67
|
+
export const Line = Echart as EchartComponent<LineOption>
|