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,101 +1,125 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { css } from "@emotion/css"
|
|
4
|
-
import { clsx } from "deepsea-tools"
|
|
5
|
-
import { CSSProperties, forwardRef, HTMLAttributes, useEffect, useImperativeHandle, useRef, useState } from "react"
|
|
6
|
-
|
|
7
|
-
export interface LoopSwiperProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
|
-
direction?: "horizontal" | "vertical"
|
|
9
|
-
reverse?: boolean
|
|
10
|
-
period: number
|
|
11
|
-
gap?: CSSProperties["gap"]
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/** 循环播放组件 */
|
|
15
|
-
export const LoopSwiper = forwardRef<HTMLDivElement, LoopSwiperProps>((props, ref) => {
|
|
16
|
-
const { className, style, children, direction, period, reverse, gap, ...rest } = props
|
|
17
|
-
const wrapper = useRef<HTMLDivElement>(null)
|
|
18
|
-
const container = useRef<HTMLDivElement>(null)
|
|
19
|
-
const [swiper, setSwiper] = useState(false)
|
|
20
|
-
const directionRef = useRef(direction)
|
|
21
|
-
directionRef.current = direction
|
|
22
|
-
const flexDirection: CSSProperties["flexDirection"] = direction === "vertical" ? (reverse ? "column-reverse" : "column") : reverse ? "row-reverse" : "row"
|
|
23
|
-
const animationName = swiper
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
@keyframes deepsea-
|
|
67
|
-
from {
|
|
68
|
-
transform: translateX(0);
|
|
69
|
-
}
|
|
70
|
-
to {
|
|
71
|
-
transform: translateX(100%);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
@keyframes deepsea-
|
|
75
|
-
from {
|
|
76
|
-
transform:
|
|
77
|
-
}
|
|
78
|
-
to {
|
|
79
|
-
transform:
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
@keyframes deepsea-
|
|
83
|
-
from {
|
|
84
|
-
transform: translateY(0);
|
|
85
|
-
}
|
|
86
|
-
to {
|
|
87
|
-
transform: translateY(100%);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { css } from "@emotion/css"
|
|
4
|
+
import { clsx } from "deepsea-tools"
|
|
5
|
+
import { CSSProperties, forwardRef, HTMLAttributes, useEffect, useImperativeHandle, useRef, useState } from "react"
|
|
6
|
+
|
|
7
|
+
export interface LoopSwiperProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
direction?: "horizontal" | "vertical"
|
|
9
|
+
reverse?: boolean
|
|
10
|
+
period: number
|
|
11
|
+
gap?: CSSProperties["gap"]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** 循环播放组件 */
|
|
15
|
+
export const LoopSwiper = forwardRef<HTMLDivElement, LoopSwiperProps>((props, ref) => {
|
|
16
|
+
const { className, style, children, direction, period, reverse, gap, ...rest } = props
|
|
17
|
+
const wrapper = useRef<HTMLDivElement>(null)
|
|
18
|
+
const container = useRef<HTMLDivElement>(null)
|
|
19
|
+
const [swiper, setSwiper] = useState(false)
|
|
20
|
+
const directionRef = useRef(direction)
|
|
21
|
+
directionRef.current = direction
|
|
22
|
+
const flexDirection: CSSProperties["flexDirection"] = direction === "vertical" ? (reverse ? "column-reverse" : "column") : reverse ? "row-reverse" : "row"
|
|
23
|
+
const animationName = swiper
|
|
24
|
+
? direction === "vertical"
|
|
25
|
+
? reverse
|
|
26
|
+
? "deepsea-reverse-vertical-loop-swipe"
|
|
27
|
+
: "deepsea-vertical-loop-swipe"
|
|
28
|
+
: reverse
|
|
29
|
+
? "deepsea-reverse-horizontal-loop-swipe"
|
|
30
|
+
: "deepsea-horizontal-loop-swipe"
|
|
31
|
+
: "none"
|
|
32
|
+
const animationDuration = `${period}ms`
|
|
33
|
+
const animationTimingFunction = "linear"
|
|
34
|
+
const animationIterationCount = "infinite"
|
|
35
|
+
|
|
36
|
+
useImperativeHandle(ref, () => wrapper.current!, [])
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const wrapperEle = wrapper.current!
|
|
40
|
+
const containerEle = container.current!
|
|
41
|
+
let wrapperWidth = 0
|
|
42
|
+
let wrapperHeight = 0
|
|
43
|
+
let containerWidth = 0
|
|
44
|
+
let containerHeight = 0
|
|
45
|
+
const observer = new ResizeObserver(entries => {
|
|
46
|
+
entries.forEach(entry => {
|
|
47
|
+
if (entry.target === wrapperEle) {
|
|
48
|
+
wrapperWidth = entry.contentRect.width
|
|
49
|
+
wrapperHeight = entry.contentRect.height
|
|
50
|
+
} else if (entry.target === containerEle) {
|
|
51
|
+
containerWidth = entry.contentRect.width
|
|
52
|
+
containerHeight = entry.contentRect.height
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
setSwiper(directionRef.current === "vertical" ? containerHeight > wrapperHeight : containerWidth > wrapperWidth)
|
|
56
|
+
})
|
|
57
|
+
observer.observe(wrapperEle)
|
|
58
|
+
observer.observe(containerEle)
|
|
59
|
+
}, [])
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<div
|
|
63
|
+
ref={wrapper}
|
|
64
|
+
className={clsx(
|
|
65
|
+
css`
|
|
66
|
+
@keyframes deepsea-horizontal-loop-swipe {
|
|
67
|
+
from {
|
|
68
|
+
transform: translateX(0);
|
|
69
|
+
}
|
|
70
|
+
to {
|
|
71
|
+
transform: translateX(-100%);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
@keyframes deepsea-reverse-horizontal-loop-swipe {
|
|
75
|
+
from {
|
|
76
|
+
transform: translateX(0);
|
|
77
|
+
}
|
|
78
|
+
to {
|
|
79
|
+
transform: translateX(100%);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
@keyframes deepsea-vertical-loop-swipe {
|
|
83
|
+
from {
|
|
84
|
+
transform: translateY(0);
|
|
85
|
+
}
|
|
86
|
+
to {
|
|
87
|
+
transform: translateY(-100%);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
@keyframes deepsea-reverse-vertical-loop-swipe {
|
|
91
|
+
from {
|
|
92
|
+
transform: translateY(0);
|
|
93
|
+
}
|
|
94
|
+
to {
|
|
95
|
+
transform: translateY(100%);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
`,
|
|
99
|
+
className,
|
|
100
|
+
)}
|
|
101
|
+
style={{ display: "flex", flexDirection, gap, ...style }}
|
|
102
|
+
{...rest}
|
|
103
|
+
>
|
|
104
|
+
<div
|
|
105
|
+
ref={container}
|
|
106
|
+
style={{ display: "flex", flexDirection, gap, animationName, animationTimingFunction, animationDuration, animationIterationCount }}
|
|
107
|
+
>
|
|
108
|
+
{children}
|
|
109
|
+
</div>
|
|
110
|
+
<div
|
|
111
|
+
style={{
|
|
112
|
+
display: swiper ? "flex" : "none",
|
|
113
|
+
flexDirection,
|
|
114
|
+
gap,
|
|
115
|
+
animationName,
|
|
116
|
+
animationTimingFunction,
|
|
117
|
+
animationDuration,
|
|
118
|
+
animationIterationCount,
|
|
119
|
+
}}
|
|
120
|
+
>
|
|
121
|
+
{children}
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
)
|
|
125
|
+
})
|
package/src/components/Ring.tsx
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { forwardRef, HTMLAttributes } from "react"
|
|
4
|
-
|
|
5
|
-
export interface RingProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
-
outerWidth: number
|
|
7
|
-
innerWidth: number
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/** 环形组件 */
|
|
11
|
-
export const Ring = forwardRef<HTMLDivElement, RingProps>((props, ref) => {
|
|
12
|
-
const { outerWidth, innerWidth, style, ...rest } = props
|
|
13
|
-
|
|
14
|
-
const outerRadius = outerWidth / 2
|
|
15
|
-
|
|
16
|
-
const innerRadius = innerWidth / 2
|
|
17
|
-
|
|
18
|
-
return
|
|
19
|
-
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { forwardRef, HTMLAttributes } from "react"
|
|
4
|
+
|
|
5
|
+
export interface RingProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
outerWidth: number
|
|
7
|
+
innerWidth: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** 环形组件 */
|
|
11
|
+
export const Ring = forwardRef<HTMLDivElement, RingProps>((props, ref) => {
|
|
12
|
+
const { outerWidth, innerWidth, style, ...rest } = props
|
|
13
|
+
|
|
14
|
+
const outerRadius = outerWidth / 2
|
|
15
|
+
|
|
16
|
+
const innerRadius = innerWidth / 2
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
ref={ref}
|
|
21
|
+
style={{
|
|
22
|
+
...style,
|
|
23
|
+
width: `${outerWidth}px`,
|
|
24
|
+
height: `${outerWidth}px`,
|
|
25
|
+
clipPath: `path("M0,${outerRadius} a${outerRadius},${outerRadius},0,1,0,${outerWidth},0 a${outerRadius},${outerRadius},0,1,0,-${outerWidth},0 l${outerRadius - innerRadius},0 a${innerRadius},${innerRadius},0,0,1,${innerRadius * 2},0 a${innerRadius},${innerRadius},0,0,1,-${innerRadius * 2},0 Z")`,
|
|
26
|
+
}}
|
|
27
|
+
{...rest}
|
|
28
|
+
/>
|
|
29
|
+
)
|
|
30
|
+
})
|
|
@@ -1,95 +1,96 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { css } from "@emotion/css"
|
|
4
|
-
import { clsx } from "deepsea-tools"
|
|
5
|
-
import { CSSProperties, ForwardedRef, forwardRef, HTMLAttributes, useEffect, useImperativeHandle, useLayoutEffect, useRef } from "react"
|
|
6
|
-
import Scrollbar from "smooth-scrollbar"
|
|
7
|
-
import type { ScrollbarOptions, ScrollListener } from "smooth-scrollbar/interfaces"
|
|
8
|
-
import { px, transformCSSVariable } from "../utils"
|
|
9
|
-
export { default as Scrollbar } from "smooth-scrollbar"
|
|
10
|
-
export * from "smooth-scrollbar/interfaces"
|
|
11
|
-
|
|
12
|
-
export interface ScrollOptions extends Partial<ScrollbarOptions> {
|
|
13
|
-
/** 滑块宽度 */
|
|
14
|
-
thumbWidth?: number | string
|
|
15
|
-
/** 滑块圆角大小 */
|
|
16
|
-
thumbRadius?: number | string
|
|
17
|
-
/** 滑块背景颜色 */
|
|
18
|
-
thumbColor?: CSSProperties["backgroundColor"]
|
|
19
|
-
/** 滚动条背景颜色 */
|
|
20
|
-
trackColor?: CSSProperties["backgroundColor"]
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface ScrollProps extends HTMLAttributes<HTMLDivElement> {
|
|
24
|
-
/** 滚动的配置 */
|
|
25
|
-
options?: ScrollOptions
|
|
26
|
-
/** 滚动条实例 */
|
|
27
|
-
scrollbar?: ForwardedRef<Scrollbar>
|
|
28
|
-
/** 滚动条滚动事件 */
|
|
29
|
-
onScrollbar?: ScrollListener
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const Scroll = forwardRef<HTMLDivElement, ScrollProps>((props, ref) => {
|
|
33
|
-
const { children, options, className, style, scrollbar, onScrollbar, ...rest } = props
|
|
34
|
-
const { thumbWidth, thumbRadius, thumbColor, trackColor, ...scrollbarOptions } = options || {}
|
|
35
|
-
const ele = useRef<HTMLDivElement>(null)
|
|
36
|
-
const bar = useRef<Scrollbar | null>(null)
|
|
37
|
-
|
|
38
|
-
useLayoutEffect(() => {
|
|
39
|
-
bar.current = Scrollbar.init(ele.current!, scrollbarOptions)
|
|
40
|
-
return () => bar.current?.destroy()
|
|
41
|
-
}, [])
|
|
42
|
-
|
|
43
|
-
useImperativeHandle(ref, () => ele.current!, [])
|
|
44
|
-
|
|
45
|
-
useImperativeHandle(scrollbar, () => bar.current!, [])
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
if (!onScrollbar) return
|
|
49
|
-
bar.current?.addListener(onScrollbar)
|
|
50
|
-
return () => bar.current?.removeListener(onScrollbar)
|
|
51
|
-
}, [onScrollbar])
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<div
|
|
55
|
-
ref={ele}
|
|
56
|
-
className={clsx(
|
|
57
|
-
css`
|
|
58
|
-
.scrollbar-track.scrollbar-track-x {
|
|
59
|
-
${thumbWidth !== undefined ? "height: var(--thumb-width);" : ""}
|
|
60
|
-
${trackColor !== undefined ? "background-color: var(--track-color);" : ""}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.scrollbar-thumb.scrollbar-thumb-x {
|
|
64
|
-
${thumbWidth !== undefined ? "height: var(--thumb-width);" : ""}
|
|
65
|
-
${thumbRadius !== undefined ? "border-radius: var(--thumb-radius);" : ""}
|
|
66
|
-
${thumbColor !== undefined ? "background-color: var(--thumb-color);" : ""}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.scrollbar-track.scrollbar-track-y {
|
|
70
|
-
${thumbWidth !== undefined ? "width: var(--thumb-width);" : ""}
|
|
71
|
-
${trackColor !== undefined ? "background-color: var(--track-color);" : ""}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.scrollbar-thumb.scrollbar-thumb-y {
|
|
75
|
-
${thumbWidth !== undefined ? "width: var(--thumb-width);" : ""}
|
|
76
|
-
${thumbRadius !== undefined ? "border-radius: var(--thumb-radius);" : ""}
|
|
77
|
-
${thumbColor !== undefined ? "background-color: var(--thumb-color);" : ""}
|
|
78
|
-
}
|
|
79
|
-
`,
|
|
80
|
-
className
|
|
81
|
-
)}
|
|
82
|
-
style={transformCSSVariable(
|
|
83
|
-
{
|
|
84
|
-
thumbWidth: px(thumbWidth),
|
|
85
|
-
thumbRadius: px(thumbRadius),
|
|
86
|
-
thumbColor,
|
|
87
|
-
trackColor
|
|
88
|
-
},
|
|
89
|
-
style
|
|
90
|
-
)}
|
|
91
|
-
{...rest}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { css } from "@emotion/css"
|
|
4
|
+
import { clsx } from "deepsea-tools"
|
|
5
|
+
import { CSSProperties, ForwardedRef, forwardRef, HTMLAttributes, useEffect, useImperativeHandle, useLayoutEffect, useRef } from "react"
|
|
6
|
+
import Scrollbar from "smooth-scrollbar"
|
|
7
|
+
import type { ScrollbarOptions, ScrollListener } from "smooth-scrollbar/interfaces"
|
|
8
|
+
import { px, transformCSSVariable } from "../utils"
|
|
9
|
+
export { default as Scrollbar } from "smooth-scrollbar"
|
|
10
|
+
export * from "smooth-scrollbar/interfaces"
|
|
11
|
+
|
|
12
|
+
export interface ScrollOptions extends Partial<ScrollbarOptions> {
|
|
13
|
+
/** 滑块宽度 */
|
|
14
|
+
thumbWidth?: number | string
|
|
15
|
+
/** 滑块圆角大小 */
|
|
16
|
+
thumbRadius?: number | string
|
|
17
|
+
/** 滑块背景颜色 */
|
|
18
|
+
thumbColor?: CSSProperties["backgroundColor"]
|
|
19
|
+
/** 滚动条背景颜色 */
|
|
20
|
+
trackColor?: CSSProperties["backgroundColor"]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ScrollProps extends HTMLAttributes<HTMLDivElement> {
|
|
24
|
+
/** 滚动的配置 */
|
|
25
|
+
options?: ScrollOptions
|
|
26
|
+
/** 滚动条实例 */
|
|
27
|
+
scrollbar?: ForwardedRef<Scrollbar>
|
|
28
|
+
/** 滚动条滚动事件 */
|
|
29
|
+
onScrollbar?: ScrollListener
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const Scroll = forwardRef<HTMLDivElement, ScrollProps>((props, ref) => {
|
|
33
|
+
const { children, options, className, style, scrollbar, onScrollbar, ...rest } = props
|
|
34
|
+
const { thumbWidth, thumbRadius, thumbColor, trackColor, ...scrollbarOptions } = options || {}
|
|
35
|
+
const ele = useRef<HTMLDivElement>(null)
|
|
36
|
+
const bar = useRef<Scrollbar | null>(null)
|
|
37
|
+
|
|
38
|
+
useLayoutEffect(() => {
|
|
39
|
+
bar.current = Scrollbar.init(ele.current!, scrollbarOptions)
|
|
40
|
+
return () => bar.current?.destroy()
|
|
41
|
+
}, [])
|
|
42
|
+
|
|
43
|
+
useImperativeHandle(ref, () => ele.current!, [])
|
|
44
|
+
|
|
45
|
+
useImperativeHandle(scrollbar, () => bar.current!, [])
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!onScrollbar) return
|
|
49
|
+
bar.current?.addListener(onScrollbar)
|
|
50
|
+
return () => bar.current?.removeListener(onScrollbar)
|
|
51
|
+
}, [onScrollbar])
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div
|
|
55
|
+
ref={ele}
|
|
56
|
+
className={clsx(
|
|
57
|
+
css`
|
|
58
|
+
.scrollbar-track.scrollbar-track-x {
|
|
59
|
+
${thumbWidth !== undefined ? "height: var(--thumb-width);" : ""}
|
|
60
|
+
${trackColor !== undefined ? "background-color: var(--track-color);" : ""}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.scrollbar-thumb.scrollbar-thumb-x {
|
|
64
|
+
${thumbWidth !== undefined ? "height: var(--thumb-width);" : ""}
|
|
65
|
+
${thumbRadius !== undefined ? "border-radius: var(--thumb-radius);" : ""}
|
|
66
|
+
${thumbColor !== undefined ? "background-color: var(--thumb-color);" : ""}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.scrollbar-track.scrollbar-track-y {
|
|
70
|
+
${thumbWidth !== undefined ? "width: var(--thumb-width);" : ""}
|
|
71
|
+
${trackColor !== undefined ? "background-color: var(--track-color);" : ""}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.scrollbar-thumb.scrollbar-thumb-y {
|
|
75
|
+
${thumbWidth !== undefined ? "width: var(--thumb-width);" : ""}
|
|
76
|
+
${thumbRadius !== undefined ? "border-radius: var(--thumb-radius);" : ""}
|
|
77
|
+
${thumbColor !== undefined ? "background-color: var(--thumb-color);" : ""}
|
|
78
|
+
}
|
|
79
|
+
`,
|
|
80
|
+
className,
|
|
81
|
+
)}
|
|
82
|
+
style={transformCSSVariable(
|
|
83
|
+
{
|
|
84
|
+
thumbWidth: px(thumbWidth),
|
|
85
|
+
thumbRadius: px(thumbRadius),
|
|
86
|
+
thumbColor,
|
|
87
|
+
trackColor,
|
|
88
|
+
},
|
|
89
|
+
style,
|
|
90
|
+
)}
|
|
91
|
+
{...rest}
|
|
92
|
+
>
|
|
93
|
+
{children}
|
|
94
|
+
</div>
|
|
95
|
+
)
|
|
96
|
+
})
|
|
@@ -1,36 +1,39 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { DrawArcOptions, drawArc } from "deepsea-tools"
|
|
4
|
-
import { FC, HTMLAttributes } from "react"
|
|
5
|
-
|
|
6
|
-
export interface SectionRingProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
-
outerRadius: number
|
|
8
|
-
innerRadius: number
|
|
9
|
-
count: number
|
|
10
|
-
angel: number
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const SectionRing: FC<SectionRingProps> = props => {
|
|
14
|
-
const { outerRadius: o, innerRadius: i, count: c, angel: a, style, ...rest } = props
|
|
15
|
-
|
|
16
|
-
const s = (Math.PI * 2) / c - a
|
|
17
|
-
|
|
18
|
-
function arc(radius: number, startAngle: number, endAngle: number, options: DrawArcOptions = {}) {
|
|
19
|
-
return drawArc(o, o, radius, startAngle, endAngle, options)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<div
|
|
24
|
-
style={{
|
|
25
|
-
...style,
|
|
26
|
-
width: o * 2,
|
|
27
|
-
height: o * 2,
|
|
28
|
-
clipPath: `path("${Array(c)
|
|
29
|
-
.fill(0)
|
|
30
|
-
.map(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { DrawArcOptions, drawArc } from "deepsea-tools"
|
|
4
|
+
import { FC, HTMLAttributes } from "react"
|
|
5
|
+
|
|
6
|
+
export interface SectionRingProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
outerRadius: number
|
|
8
|
+
innerRadius: number
|
|
9
|
+
count: number
|
|
10
|
+
angel: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const SectionRing: FC<SectionRingProps> = props => {
|
|
14
|
+
const { outerRadius: o, innerRadius: i, count: c, angel: a, style, ...rest } = props
|
|
15
|
+
|
|
16
|
+
const s = (Math.PI * 2) / c - a
|
|
17
|
+
|
|
18
|
+
function arc(radius: number, startAngle: number, endAngle: number, options: DrawArcOptions = {}) {
|
|
19
|
+
return drawArc(o, o, radius, startAngle, endAngle, options)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div
|
|
24
|
+
style={{
|
|
25
|
+
...style,
|
|
26
|
+
width: o * 2,
|
|
27
|
+
height: o * 2,
|
|
28
|
+
clipPath: `path("${Array(c)
|
|
29
|
+
.fill(0)
|
|
30
|
+
.map(
|
|
31
|
+
(it, idx) =>
|
|
32
|
+
`${arc(o, idx * (a + s), idx * (a + s) + a)} ${arc(i, idx * (a + s) + a, idx * (a + s), { line: true, anticlockwise: true })}`,
|
|
33
|
+
)
|
|
34
|
+
.join(" ")} Z")`,
|
|
35
|
+
}}
|
|
36
|
+
{...rest}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { css } from "@emotion/css"
|
|
4
|
-
import { clsx } from "deepsea-tools"
|
|
5
|
-
import { forwardRef, HTMLAttributes } from "react"
|
|
6
|
-
|
|
7
|
-
export interface SkeletonProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
|
-
loading?: boolean
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const Skeleton = forwardRef<HTMLDivElement, SkeletonProps>((props, ref) => {
|
|
12
|
-
let { className, loading, children, ...rest } = props
|
|
13
|
-
|
|
14
|
-
loading ??= children === undefined || children === null
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<div
|
|
18
|
-
ref={ref}
|
|
19
|
-
className={clsx(
|
|
20
|
-
css`
|
|
21
|
-
@keyframes shimmer {
|
|
22
|
-
0% {
|
|
23
|
-
background-position: -400px 0px;
|
|
24
|
-
}
|
|
25
|
-
100% {
|
|
26
|
-
background-position: 400px 0px;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
`,
|
|
30
|
-
loading &&
|
|
31
|
-
css`
|
|
32
|
-
background-image: linear-gradient(to right, rgba(0, 0, 0, 0.067) 8%, rgba(0, 0, 0, 0.133) 18%, rgba(0, 0, 0, 0.067) 33%);
|
|
33
|
-
animation-duration: 1s;
|
|
34
|
-
animation-fill-mode: forwards;
|
|
35
|
-
animation-iteration-count: infinite;
|
|
36
|
-
animation-name: shimmer;
|
|
37
|
-
animation-timing-function: linear;
|
|
38
|
-
background-size: 800px 104px;
|
|
39
|
-
`,
|
|
40
|
-
className
|
|
41
|
-
)}
|
|
42
|
-
{...rest}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { css } from "@emotion/css"
|
|
4
|
+
import { clsx } from "deepsea-tools"
|
|
5
|
+
import { forwardRef, HTMLAttributes } from "react"
|
|
6
|
+
|
|
7
|
+
export interface SkeletonProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
loading?: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const Skeleton = forwardRef<HTMLDivElement, SkeletonProps>((props, ref) => {
|
|
12
|
+
let { className, loading, children, ...rest } = props
|
|
13
|
+
|
|
14
|
+
loading ??= children === undefined || children === null
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div
|
|
18
|
+
ref={ref}
|
|
19
|
+
className={clsx(
|
|
20
|
+
css`
|
|
21
|
+
@keyframes shimmer {
|
|
22
|
+
0% {
|
|
23
|
+
background-position: -400px 0px;
|
|
24
|
+
}
|
|
25
|
+
100% {
|
|
26
|
+
background-position: 400px 0px;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
`,
|
|
30
|
+
loading &&
|
|
31
|
+
css`
|
|
32
|
+
background-image: linear-gradient(to right, rgba(0, 0, 0, 0.067) 8%, rgba(0, 0, 0, 0.133) 18%, rgba(0, 0, 0, 0.067) 33%);
|
|
33
|
+
animation-duration: 1s;
|
|
34
|
+
animation-fill-mode: forwards;
|
|
35
|
+
animation-iteration-count: infinite;
|
|
36
|
+
animation-name: shimmer;
|
|
37
|
+
animation-timing-function: linear;
|
|
38
|
+
background-size: 800px 104px;
|
|
39
|
+
`,
|
|
40
|
+
className,
|
|
41
|
+
)}
|
|
42
|
+
{...rest}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</div>
|
|
46
|
+
)
|
|
47
|
+
})
|