deepsea-components 5.15.22 → 5.15.24

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 (79) hide show
  1. package/README.md +23 -23
  2. package/dist/components/AutoFit.cjs +7 -7
  3. package/dist/components/AutoFit.js +30 -30
  4. package/dist/components/AutoScroll.cjs +7 -7
  5. package/dist/components/AutoScroll.js +30 -30
  6. package/dist/components/AutoSizeTextarea.cjs +4 -4
  7. package/dist/components/AutoSizeTextarea.js +17 -17
  8. package/dist/components/CircleText.js +4 -4
  9. package/dist/components/CopyButton.cjs +2 -2
  10. package/dist/components/CopyButton.js +13 -14
  11. package/dist/components/Echart.cjs +2 -2
  12. package/dist/components/Echart.js +12 -12
  13. package/dist/components/Flow.cjs +19 -19
  14. package/dist/components/Flow.js +44 -44
  15. package/dist/components/FormLabel.cjs +3 -3
  16. package/dist/components/FormLabel.js +9 -9
  17. package/dist/components/HlsPlayer.js +10 -10
  18. package/dist/components/IconFileType.cjs +4 -4
  19. package/dist/components/IconFileType.js +9 -9
  20. package/dist/components/InfiniteScroll.cjs +13 -13
  21. package/dist/components/InfiniteScroll.js +32 -32
  22. package/dist/components/InputFile.js +4 -4
  23. package/dist/components/InputFileButton.js +11 -11
  24. package/dist/components/LoopSwiper.cjs +33 -33
  25. package/dist/components/LoopSwiper.js +47 -47
  26. package/dist/components/ReadExcel.js +2 -2
  27. package/dist/components/ReadSheet.js +5 -5
  28. package/dist/components/Ring.js +4 -4
  29. package/dist/components/Scroll.cjs +15 -15
  30. package/dist/components/Scroll.js +32 -33
  31. package/dist/components/ScrollMask.js +13 -13
  32. package/dist/components/ScrollMask.module.cjs +2 -2
  33. package/dist/components/ScrollMask.module.js +2 -2
  34. package/dist/components/SectionRing.js +6 -6
  35. package/dist/components/Skeleton.cjs +17 -17
  36. package/dist/components/Skeleton.js +23 -23
  37. package/dist/components/Title.js +12 -12
  38. package/dist/components/TransitionBox.js +10 -10
  39. package/dist/components/TransitionNum.cjs +1 -1
  40. package/dist/components/TransitionNum.js +12 -12
  41. package/dist/components/Trapezium.cjs +4 -4
  42. package/dist/components/Trapezium.js +14 -14
  43. package/dist/components/Unify.js +10 -10
  44. package/dist/components/WriteExcel.js +2 -2
  45. package/dist/components/WriteSheet.js +4 -4
  46. package/dist/utils/getReactVersion.js +2 -2
  47. package/package.json +6 -5
  48. package/src/components/AutoFit.tsx +104 -104
  49. package/src/components/AutoScroll.tsx +150 -150
  50. package/src/components/AutoSizeTextarea.tsx +50 -50
  51. package/src/components/CircleText.tsx +81 -81
  52. package/src/components/CopyButton.tsx +31 -31
  53. package/src/components/Echart.tsx +69 -69
  54. package/src/components/Flow.tsx +271 -271
  55. package/src/components/FormLabel.tsx +41 -41
  56. package/src/components/HlsPlayer.tsx +34 -34
  57. package/src/components/IconFileType.tsx +162 -162
  58. package/src/components/InfiniteScroll.tsx +163 -163
  59. package/src/components/InputFile.tsx +93 -93
  60. package/src/components/InputFileButton.tsx +122 -122
  61. package/src/components/LoopSwiper.tsx +125 -125
  62. package/src/components/ReadExcel.tsx +13 -13
  63. package/src/components/ReadSheet.tsx +17 -17
  64. package/src/components/Ring.tsx +30 -30
  65. package/src/components/Scroll.tsx +97 -97
  66. package/src/components/ScrollMask.module.css +87 -87
  67. package/src/components/ScrollMask.tsx +68 -68
  68. package/src/components/SectionRing.tsx +40 -40
  69. package/src/components/Skeleton.tsx +45 -45
  70. package/src/components/Title.tsx +27 -27
  71. package/src/components/TransitionBox.tsx +44 -44
  72. package/src/components/TransitionNum.tsx +54 -54
  73. package/src/components/Trapezium.tsx +60 -60
  74. package/src/components/Unify.tsx +38 -38
  75. package/src/components/WriteExcel.tsx +13 -13
  76. package/src/components/WriteSheet.tsx +25 -25
  77. package/src/utils/getReactVersion.ts +7 -7
  78. package/src/utils/index.ts +33 -33
  79. package/tsconfig.json +16 -16
@@ -1,97 +1,97 @@
1
- "use client"
2
-
3
- import { css } from "@emotion/css"
4
- import { clsx } from "deepsea-tools"
5
- import { CSSProperties, ForwardedRef, HTMLAttributes, forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useRef } from "react"
6
- import Scrollbar from "smooth-scrollbar"
7
- import type { ScrollListener, ScrollbarOptions } from "smooth-scrollbar/interfaces"
8
-
9
- import { px, transformCSSVariable } from "@/utils"
10
-
11
- export { default as Scrollbar } from "smooth-scrollbar"
12
- export * from "smooth-scrollbar/interfaces"
13
-
14
- export interface ScrollOptions extends Partial<ScrollbarOptions> {
15
- /** 滑块宽度 */
16
- thumbWidth?: number | string
17
- /** 滑块圆角大小 */
18
- thumbRadius?: number | string
19
- /** 滑块背景颜色 */
20
- thumbColor?: CSSProperties["backgroundColor"]
21
- /** 滚动条背景颜色 */
22
- trackColor?: CSSProperties["backgroundColor"]
23
- }
24
-
25
- export interface ScrollProps extends HTMLAttributes<HTMLDivElement> {
26
- /** 滚动的配置 */
27
- options?: ScrollOptions
28
- /** 滚动条实例 */
29
- scrollbar?: ForwardedRef<Scrollbar>
30
- /** 滚动条滚动事件 */
31
- onScrollbar?: ScrollListener
32
- }
33
-
34
- export const Scroll = forwardRef<HTMLDivElement, ScrollProps>((props, ref) => {
35
- const { children, options, className, style, scrollbar, onScrollbar, ...rest } = props
36
- const { thumbWidth, thumbRadius, thumbColor, trackColor, ...scrollbarOptions } = options || {}
37
- const ele = useRef<HTMLDivElement>(null)
38
- const bar = useRef<Scrollbar | null>(null)
39
-
40
- useLayoutEffect(() => {
41
- bar.current = Scrollbar.init(ele.current!, scrollbarOptions)
42
- return () => bar.current?.destroy()
43
- }, [])
44
-
45
- useImperativeHandle(ref, () => ele.current!, [])
46
-
47
- useImperativeHandle(scrollbar, () => bar.current!, [])
48
-
49
- useEffect(() => {
50
- if (!onScrollbar) return
51
- bar.current?.addListener(onScrollbar)
52
- return () => bar.current?.removeListener(onScrollbar)
53
- }, [onScrollbar])
54
-
55
- return (
56
- <div
57
- ref={ele}
58
- className={clsx(
59
- css`
60
- .scrollbar-track.scrollbar-track-x {
61
- ${thumbWidth !== undefined ? "height: var(--thumb-width);" : ""} ${trackColor !== undefined
62
- ? "background-color: var(--track-color);"
63
- : ""}
64
- }
65
- .scrollbar-thumb.scrollbar-thumb-x {
66
- ${thumbWidth !== undefined ? "height: var(--thumb-width);" : ""} ${thumbRadius !== undefined
67
- ? "border-radius: var(--thumb-radius);"
68
- : ""} ${thumbColor !== undefined ? "background-color: var(--thumb-color);" : ""}
69
- }
70
- .scrollbar-track.scrollbar-track-y {
71
- ${thumbWidth !== undefined ? "width: var(--thumb-width);" : ""} ${trackColor !== undefined
72
- ? "background-color: var(--track-color);"
73
- : ""}
74
- }
75
- .scrollbar-thumb.scrollbar-thumb-y {
76
- ${thumbWidth !== undefined ? "width: var(--thumb-width);" : ""} ${thumbRadius !== undefined
77
- ? "border-radius: var(--thumb-radius);"
78
- : ""} ${thumbColor !== undefined ? "background-color: var(--thumb-color);" : ""}
79
- }
80
- `,
81
- className,
82
- )}
83
- style={transformCSSVariable(
84
- {
85
- thumbWidth: px(thumbWidth),
86
- thumbRadius: px(thumbRadius),
87
- thumbColor,
88
- trackColor,
89
- },
90
- style,
91
- )}
92
- {...rest}
93
- >
94
- {children}
95
- </div>
96
- )
97
- })
1
+ "use client"
2
+
3
+ import { css } from "@emotion/css"
4
+ import { clsx } from "deepsea-tools"
5
+ import { CSSProperties, ForwardedRef, HTMLAttributes, forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useRef } from "react"
6
+ import Scrollbar from "smooth-scrollbar"
7
+ import type { ScrollListener, ScrollbarOptions } from "smooth-scrollbar/interfaces"
8
+
9
+ import { px, transformCSSVariable } from "@/utils"
10
+
11
+ export { default as Scrollbar } from "smooth-scrollbar"
12
+ export * from "smooth-scrollbar/interfaces"
13
+
14
+ export interface ScrollOptions extends Partial<ScrollbarOptions> {
15
+ /** 滑块宽度 */
16
+ thumbWidth?: number | string
17
+ /** 滑块圆角大小 */
18
+ thumbRadius?: number | string
19
+ /** 滑块背景颜色 */
20
+ thumbColor?: CSSProperties["backgroundColor"]
21
+ /** 滚动条背景颜色 */
22
+ trackColor?: CSSProperties["backgroundColor"]
23
+ }
24
+
25
+ export interface ScrollProps extends HTMLAttributes<HTMLDivElement> {
26
+ /** 滚动的配置 */
27
+ options?: ScrollOptions
28
+ /** 滚动条实例 */
29
+ scrollbar?: ForwardedRef<Scrollbar>
30
+ /** 滚动条滚动事件 */
31
+ onScrollbar?: ScrollListener
32
+ }
33
+
34
+ export const Scroll = forwardRef<HTMLDivElement, ScrollProps>((props, ref) => {
35
+ const { children, options, className, style, scrollbar, onScrollbar, ...rest } = props
36
+ const { thumbWidth, thumbRadius, thumbColor, trackColor, ...scrollbarOptions } = options || {}
37
+ const ele = useRef<HTMLDivElement>(null)
38
+ const bar = useRef<Scrollbar | null>(null)
39
+
40
+ useLayoutEffect(() => {
41
+ bar.current = Scrollbar.init(ele.current!, scrollbarOptions)
42
+ return () => bar.current?.destroy()
43
+ }, [])
44
+
45
+ useImperativeHandle(ref, () => ele.current!, [])
46
+
47
+ useImperativeHandle(scrollbar, () => bar.current!, [])
48
+
49
+ useEffect(() => {
50
+ if (!onScrollbar) return
51
+ bar.current?.addListener(onScrollbar)
52
+ return () => bar.current?.removeListener(onScrollbar)
53
+ }, [onScrollbar])
54
+
55
+ return (
56
+ <div
57
+ ref={ele}
58
+ className={clsx(
59
+ css`
60
+ .scrollbar-track.scrollbar-track-x {
61
+ ${thumbWidth !== undefined ? "height: var(--thumb-width);" : ""} ${trackColor !== undefined
62
+ ? "background-color: var(--track-color);"
63
+ : ""}
64
+ }
65
+ .scrollbar-thumb.scrollbar-thumb-x {
66
+ ${thumbWidth !== undefined ? "height: var(--thumb-width);" : ""} ${thumbRadius !== undefined
67
+ ? "border-radius: var(--thumb-radius);"
68
+ : ""} ${thumbColor !== undefined ? "background-color: var(--thumb-color);" : ""}
69
+ }
70
+ .scrollbar-track.scrollbar-track-y {
71
+ ${thumbWidth !== undefined ? "width: var(--thumb-width);" : ""} ${trackColor !== undefined
72
+ ? "background-color: var(--track-color);"
73
+ : ""}
74
+ }
75
+ .scrollbar-thumb.scrollbar-thumb-y {
76
+ ${thumbWidth !== undefined ? "width: var(--thumb-width);" : ""} ${thumbRadius !== undefined
77
+ ? "border-radius: var(--thumb-radius);"
78
+ : ""} ${thumbColor !== undefined ? "background-color: var(--thumb-color);" : ""}
79
+ }
80
+ `,
81
+ className,
82
+ )}
83
+ style={transformCSSVariable(
84
+ {
85
+ thumbWidth: px(thumbWidth),
86
+ thumbRadius: px(thumbRadius),
87
+ thumbColor,
88
+ trackColor,
89
+ },
90
+ style,
91
+ )}
92
+ {...rest}
93
+ >
94
+ {children}
95
+ </div>
96
+ )
97
+ })
@@ -1,87 +1,87 @@
1
- .scroll-mask {
2
- position: sticky;
3
- z-index: 10;
4
- pointer-events: none;
5
- }
6
-
7
- .top-scroll-mask {
8
- width: 100%;
9
- height: 0;
10
- top: 0;
11
- right: 0;
12
- bottom: 100%;
13
- left: 0;
14
- }
15
-
16
- .scroll-mask-content {
17
- position: absolute;
18
- background-image: linear-gradient(
19
- to var(--scroll-mask-direction),
20
- var(--scroll-mask-color-from, rgba(0, 0, 0, 0.1)),
21
- var(--scroll-mask-color-to, rgba(0, 0, 0, 0))
22
- );
23
- clip-path: var(--scroll-mask-clip-path, none);
24
- }
25
-
26
- .top-scroll-mask-content {
27
- width: 100%;
28
- height: var(--scroll-mask-size, 8px);
29
- top: 0;
30
- right: 50%;
31
- transform: translateX(50%);
32
- --scroll-mask-direction: bottom;
33
- }
34
-
35
- .bottom-scroll-mask {
36
- width: 100%;
37
- height: 0;
38
- top: 100%;
39
- right: 0;
40
- bottom: 0;
41
- left: 0;
42
- }
43
-
44
- .bottom-scroll-mask-content {
45
- width: 100%;
46
- height: var(--scroll-mask-size, 8px);
47
- bottom: 0;
48
- left: 50%;
49
- transform: translateX(-50%);
50
- --scroll-mask-direction: top;
51
- }
52
-
53
- .left-scroll-mask {
54
- width: 0;
55
- height: 100%;
56
- top: 0;
57
- right: 100%;
58
- bottom: 0;
59
- left: 0;
60
- }
61
-
62
- .left-scroll-mask-content {
63
- width: var(--scroll-mask-size, 8px);
64
- height: 100%;
65
- left: 0;
66
- top: 50%;
67
- transform: translateY(-50%);
68
- --scroll-mask-direction: right;
69
- }
70
-
71
- .right-scroll-mask {
72
- width: 0;
73
- height: 100%;
74
- top: 0;
75
- right: 0;
76
- bottom: 0;
77
- left: 100%;
78
- }
79
-
80
- .right-scroll-mask-content {
81
- width: var(--scroll-mask-size, 8px);
82
- height: 100%;
83
- right: 0;
84
- bottom: 50%;
85
- transform: translateY(50%);
86
- --scroll-mask-direction: left;
87
- }
1
+ .scroll-mask {
2
+ position: sticky;
3
+ z-index: 10;
4
+ pointer-events: none;
5
+ }
6
+
7
+ .top-scroll-mask {
8
+ width: 100%;
9
+ height: 0;
10
+ top: 0;
11
+ right: 0;
12
+ bottom: 100%;
13
+ left: 0;
14
+ }
15
+
16
+ .scroll-mask-content {
17
+ position: absolute;
18
+ background-image: linear-gradient(
19
+ to var(--scroll-mask-direction),
20
+ var(--scroll-mask-color-from, rgba(0, 0, 0, 0.1)),
21
+ var(--scroll-mask-color-to, rgba(0, 0, 0, 0))
22
+ );
23
+ clip-path: var(--scroll-mask-clip-path, none);
24
+ }
25
+
26
+ .top-scroll-mask-content {
27
+ width: 100%;
28
+ height: var(--scroll-mask-size, 8px);
29
+ top: 0;
30
+ right: 50%;
31
+ transform: translateX(50%);
32
+ --scroll-mask-direction: bottom;
33
+ }
34
+
35
+ .bottom-scroll-mask {
36
+ width: 100%;
37
+ height: 0;
38
+ top: 100%;
39
+ right: 0;
40
+ bottom: 0;
41
+ left: 0;
42
+ }
43
+
44
+ .bottom-scroll-mask-content {
45
+ width: 100%;
46
+ height: var(--scroll-mask-size, 8px);
47
+ bottom: 0;
48
+ left: 50%;
49
+ transform: translateX(-50%);
50
+ --scroll-mask-direction: top;
51
+ }
52
+
53
+ .left-scroll-mask {
54
+ width: 0;
55
+ height: 100%;
56
+ top: 0;
57
+ right: 100%;
58
+ bottom: 0;
59
+ left: 0;
60
+ }
61
+
62
+ .left-scroll-mask-content {
63
+ width: var(--scroll-mask-size, 8px);
64
+ height: 100%;
65
+ left: 0;
66
+ top: 50%;
67
+ transform: translateY(-50%);
68
+ --scroll-mask-direction: right;
69
+ }
70
+
71
+ .right-scroll-mask {
72
+ width: 0;
73
+ height: 100%;
74
+ top: 0;
75
+ right: 0;
76
+ bottom: 0;
77
+ left: 100%;
78
+ }
79
+
80
+ .right-scroll-mask-content {
81
+ width: var(--scroll-mask-size, 8px);
82
+ height: 100%;
83
+ right: 0;
84
+ bottom: 50%;
85
+ transform: translateY(50%);
86
+ --scroll-mask-direction: left;
87
+ }
@@ -1,68 +1,68 @@
1
- import { clsx, isNonNullable } from "deepsea-tools"
2
- import { CSSProperties, ComponentProps, FC, useRef } from "react"
3
- import { useSize } from "soda-hooks"
4
-
5
- import styles from "./ScrollMask.module.css"
6
-
7
- export type ScrollMaskPosition = "top" | "bottom" | "left" | "right"
8
-
9
- export interface ScrollMaskProps extends Omit<ComponentProps<"div">, "children"> {
10
- position?: ScrollMaskPosition
11
- size?: number
12
- from?: CSSProperties["color"]
13
- to?: CSSProperties["color"]
14
- contentClassName?: string
15
- contentStyle?: CSSProperties
16
- showRadian?: boolean
17
- }
18
-
19
- export const ScrollMask: FC<ScrollMaskProps> = ({
20
- className,
21
- style,
22
- position = "top",
23
- size = 8,
24
- from = "rgba(0, 0, 0, 0.1)",
25
- to = "rgba(0, 0, 0, 0)",
26
- contentClassName,
27
- contentStyle,
28
- showRadian = false,
29
- ...rest
30
- }) => {
31
- const ref = useRef<HTMLDivElement>(null)
32
- const contentSize = useSize(ref)
33
- const radius = isNonNullable(contentSize)
34
- ? position === "top" || position === "bottom"
35
- ? (contentSize.width ** 2 / 4 + contentSize.height ** 2) / (contentSize.height * 2)
36
- : (contentSize.height ** 2 / 4 + contentSize.width ** 2) / (contentSize.width * 2)
37
- : undefined
38
- const clipPath =
39
- showRadian && isNonNullable(radius)
40
- ? position === "top"
41
- ? `circle(${radius}px at 50% -${radius - contentSize!.height}px)`
42
- : position === "bottom"
43
- ? `circle(${radius}px at 50% ${radius}px)`
44
- : position === "left"
45
- ? `circle(${radius}px at -${radius - contentSize!.width}px 50%)`
46
- : position === "right"
47
- ? `circle(${radius}px at ${radius}px 50%)`
48
- : "none"
49
- : "none"
50
-
51
- return (
52
- <div
53
- className={clsx(styles["scroll-mask"], styles[`${position}-scroll-mask`], className)}
54
- style={
55
- {
56
- "--scroll-mask-size": `${size}px`,
57
- "--scroll-mask-color-from": from,
58
- "--scroll-mask-color-to": to,
59
- "--scroll-mask-clip-path": clipPath,
60
- ...style,
61
- } as CSSProperties
62
- }
63
- {...rest}
64
- >
65
- <div ref={ref} className={clsx(styles["scroll-mask-content"], styles[`${position}-scroll-mask-content`], contentClassName)} style={contentStyle} />
66
- </div>
67
- )
68
- }
1
+ import { clsx, isNonNullable } from "deepsea-tools"
2
+ import { CSSProperties, ComponentProps, FC, useRef } from "react"
3
+ import { useSize } from "soda-hooks"
4
+
5
+ import styles from "./ScrollMask.module.css"
6
+
7
+ export type ScrollMaskPosition = "top" | "bottom" | "left" | "right"
8
+
9
+ export interface ScrollMaskProps extends Omit<ComponentProps<"div">, "children"> {
10
+ position?: ScrollMaskPosition
11
+ size?: number
12
+ from?: CSSProperties["color"]
13
+ to?: CSSProperties["color"]
14
+ contentClassName?: string
15
+ contentStyle?: CSSProperties
16
+ showRadian?: boolean
17
+ }
18
+
19
+ export const ScrollMask: FC<ScrollMaskProps> = ({
20
+ className,
21
+ style,
22
+ position = "top",
23
+ size = 8,
24
+ from = "rgba(0, 0, 0, 0.1)",
25
+ to = "rgba(0, 0, 0, 0)",
26
+ contentClassName,
27
+ contentStyle,
28
+ showRadian = false,
29
+ ...rest
30
+ }) => {
31
+ const ref = useRef<HTMLDivElement>(null)
32
+ const contentSize = useSize(ref)
33
+ const radius = isNonNullable(contentSize)
34
+ ? position === "top" || position === "bottom"
35
+ ? (contentSize.width ** 2 / 4 + contentSize.height ** 2) / (contentSize.height * 2)
36
+ : (contentSize.height ** 2 / 4 + contentSize.width ** 2) / (contentSize.width * 2)
37
+ : undefined
38
+ const clipPath =
39
+ showRadian && isNonNullable(radius)
40
+ ? position === "top"
41
+ ? `circle(${radius}px at 50% -${radius - contentSize!.height}px)`
42
+ : position === "bottom"
43
+ ? `circle(${radius}px at 50% ${radius}px)`
44
+ : position === "left"
45
+ ? `circle(${radius}px at -${radius - contentSize!.width}px 50%)`
46
+ : position === "right"
47
+ ? `circle(${radius}px at ${radius}px 50%)`
48
+ : "none"
49
+ : "none"
50
+
51
+ return (
52
+ <div
53
+ className={clsx(styles["scroll-mask"], styles[`${position}-scroll-mask`], className)}
54
+ style={
55
+ {
56
+ "--scroll-mask-size": `${size}px`,
57
+ "--scroll-mask-color-from": from,
58
+ "--scroll-mask-color-to": to,
59
+ "--scroll-mask-clip-path": clipPath,
60
+ ...style,
61
+ } as CSSProperties
62
+ }
63
+ {...rest}
64
+ >
65
+ <div ref={ref} className={clsx(styles["scroll-mask-content"], styles[`${position}-scroll-mask-content`], contentClassName)} style={contentStyle} />
66
+ </div>
67
+ )
68
+ }
@@ -1,40 +1,40 @@
1
- "use client"
2
-
3
- import { DrawArcOptions, drawArc } from "deepsea-tools"
4
- import { HTMLAttributes, forwardRef } 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 = forwardRef<HTMLDivElement, SectionRingProps>((props, ref) => {
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
- ref={ref}
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
- ...style,
36
- }}
37
- {...rest}
38
- />
39
- )
40
- })
1
+ "use client"
2
+
3
+ import { DrawArcOptions, drawArc } from "deepsea-tools"
4
+ import { HTMLAttributes, forwardRef } 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 = forwardRef<HTMLDivElement, SectionRingProps>((props, ref) => {
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
+ ref={ref}
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
+ ...style,
36
+ }}
37
+ {...rest}
38
+ />
39
+ )
40
+ })