deepsea-components 5.6.0 → 5.7.1

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 (92) hide show
  1. package/README.md +23 -23
  2. package/dist/cjs/components/AutoFit.js +3 -1
  3. package/dist/cjs/components/AutoFit.js.map +2 -2
  4. package/dist/cjs/components/AutoScroll.js +16 -1
  5. package/dist/cjs/components/AutoScroll.js.map +2 -2
  6. package/dist/cjs/components/AutoSizeTextarea.js.map +1 -1
  7. package/dist/cjs/components/CircleText.js +31 -2
  8. package/dist/cjs/components/CircleText.js.map +2 -2
  9. package/dist/cjs/components/CopyButton.d.ts +9 -0
  10. package/dist/cjs/components/CopyButton.js +59 -0
  11. package/dist/cjs/components/CopyButton.js.map +7 -0
  12. package/dist/cjs/components/Echart.js.map +2 -2
  13. package/dist/cjs/components/Flow.js +56 -3
  14. package/dist/cjs/components/Flow.js.map +2 -2
  15. package/dist/cjs/components/FormLabel.js.map +1 -1
  16. package/dist/cjs/components/HlsPlayer.js.map +1 -1
  17. package/dist/cjs/components/InfiniteScroll.js +15 -1
  18. package/dist/cjs/components/InfiniteScroll.js.map +2 -2
  19. package/dist/cjs/components/InputFile.js.map +1 -1
  20. package/dist/cjs/components/LoopSwiper.js +23 -2
  21. package/dist/cjs/components/LoopSwiper.js.map +2 -2
  22. package/dist/cjs/components/Ring.js +13 -1
  23. package/dist/cjs/components/Ring.js.map +2 -2
  24. package/dist/cjs/components/Scroll.js.map +2 -2
  25. package/dist/cjs/components/SectionRing.js +3 -1
  26. package/dist/cjs/components/SectionRing.js.map +2 -2
  27. package/dist/cjs/components/Skeleton.js.map +2 -2
  28. package/dist/cjs/components/Title.js.map +2 -2
  29. package/dist/cjs/components/TransitionBox.js +9 -1
  30. package/dist/cjs/components/TransitionBox.js.map +2 -2
  31. package/dist/cjs/components/TransitionNum.js.map +1 -1
  32. package/dist/cjs/components/Trapezium.js.map +1 -1
  33. package/dist/cjs/index.d.ts +1 -0
  34. package/dist/cjs/index.js +2 -0
  35. package/dist/cjs/index.js.map +2 -2
  36. package/dist/cjs/utils/getReactVersion.js.map +1 -1
  37. package/dist/cjs/utils/index.js.map +1 -1
  38. package/dist/esm/components/AutoFit.js +9 -9
  39. package/dist/esm/components/AutoFit.js.map +1 -1
  40. package/dist/esm/components/AutoScroll.js.map +1 -1
  41. package/dist/esm/components/AutoSizeTextarea.js +2 -2
  42. package/dist/esm/components/AutoSizeTextarea.js.map +1 -1
  43. package/dist/esm/components/CircleText.js.map +1 -1
  44. package/dist/esm/components/CopyButton.d.ts +9 -0
  45. package/dist/esm/components/CopyButton.js +29 -0
  46. package/dist/esm/components/CopyButton.js.map +1 -0
  47. package/dist/esm/components/Echart.js.map +1 -1
  48. package/dist/esm/components/Flow.js.map +1 -1
  49. package/dist/esm/components/FormLabel.js +2 -2
  50. package/dist/esm/components/FormLabel.js.map +1 -1
  51. package/dist/esm/components/HlsPlayer.js.map +1 -1
  52. package/dist/esm/components/InfiniteScroll.js +4 -4
  53. package/dist/esm/components/InfiniteScroll.js.map +1 -1
  54. package/dist/esm/components/InputFile.js.map +1 -1
  55. package/dist/esm/components/LoopSwiper.js.map +1 -1
  56. package/dist/esm/components/Ring.js.map +1 -1
  57. package/dist/esm/components/Scroll.js.map +1 -1
  58. package/dist/esm/components/SectionRing.js.map +1 -1
  59. package/dist/esm/components/Skeleton.js.map +1 -1
  60. package/dist/esm/components/Title.js.map +1 -1
  61. package/dist/esm/components/TransitionBox.js.map +1 -1
  62. package/dist/esm/components/TransitionNum.js.map +1 -1
  63. package/dist/esm/components/Trapezium.js.map +1 -1
  64. package/dist/esm/index.d.ts +1 -0
  65. package/dist/esm/index.js +1 -0
  66. package/dist/esm/index.js.map +1 -1
  67. package/dist/esm/utils/getReactVersion.js.map +1 -1
  68. package/dist/esm/utils/index.js.map +1 -1
  69. package/package.json +4 -2
  70. package/src/components/AutoFit.tsx +103 -101
  71. package/src/components/AutoScroll.tsx +148 -132
  72. package/src/components/AutoSizeTextarea.tsx +49 -49
  73. package/src/components/CircleText.tsx +81 -56
  74. package/src/components/CopyButton.tsx +29 -0
  75. package/src/components/Echart.tsx +67 -44
  76. package/src/components/Flow.tsx +270 -214
  77. package/src/components/FormLabel.tsx +38 -38
  78. package/src/components/HlsPlayer.tsx +34 -34
  79. package/src/components/InfiniteScroll.tsx +161 -135
  80. package/src/components/InputFile.tsx +234 -234
  81. package/src/components/LoopSwiper.tsx +125 -101
  82. package/src/components/Ring.tsx +30 -19
  83. package/src/components/Scroll.tsx +96 -95
  84. package/src/components/SectionRing.tsx +39 -36
  85. package/src/components/Skeleton.tsx +47 -46
  86. package/src/components/Title.tsx +23 -24
  87. package/src/components/TransitionBox.tsx +44 -36
  88. package/src/components/TransitionNum.tsx +54 -54
  89. package/src/components/Trapezium.tsx +59 -59
  90. package/src/index.ts +1 -0
  91. package/src/utils/getReactVersion.ts +7 -7
  92. package/src/utils/index.ts +33 -33
@@ -1,38 +1,38 @@
1
- import { css } from "@emotion/css"
2
- import { clsx } from "deepsea-tools"
3
- import { ComponentProps, FC, Fragment } from "react"
4
-
5
- export type FormLabelProps = ComponentProps<"div"> & {
6
- /**
7
- * Label 的宽度.
8
- */
9
- width: number
10
- /**
11
- * 是否在 Label 前面添加一个空白区域,只有当前 Label 为非必选,而存在其他 Label 为必选的时候开启
12
- */
13
- before?: boolean
14
- }
15
-
16
- /**
17
- * 为 Ant Design 的 FormItem 设计的 Label 组件
18
- */
19
- export const FormLabel: FC<FormLabelProps> = props => {
20
- const { className, style, before, width, ...rest } = props
21
-
22
- return (
23
- <Fragment>
24
- {!!before && <div style={{ width: 11 }}>&ensp;</div>}
25
- <div
26
- className={clsx(
27
- css`
28
- text-align: justify;
29
- text-align-last: justify;
30
- `,
31
- className
32
- )}
33
- style={{ width, ...style }}
34
- {...rest}
35
- />
36
- </Fragment>
37
- )
38
- }
1
+ import { css } from "@emotion/css"
2
+ import { clsx } from "deepsea-tools"
3
+ import { ComponentProps, FC, Fragment } from "react"
4
+
5
+ export type FormLabelProps = ComponentProps<"div"> & {
6
+ /**
7
+ * Label 的宽度.
8
+ */
9
+ width: number
10
+ /**
11
+ * 是否在 Label 前面添加一个空白区域,只有当前 Label 为非必选,而存在其他 Label 为必选的时候开启
12
+ */
13
+ before?: boolean
14
+ }
15
+
16
+ /**
17
+ * 为 Ant Design 的 FormItem 设计的 Label 组件
18
+ */
19
+ export const FormLabel: FC<FormLabelProps> = props => {
20
+ const { className, style, before, width, ...rest } = props
21
+
22
+ return (
23
+ <Fragment>
24
+ {!!before && <div style={{ width: 11 }}>&ensp;</div>}
25
+ <div
26
+ className={clsx(
27
+ css`
28
+ text-align: justify;
29
+ text-align-last: justify;
30
+ `,
31
+ className,
32
+ )}
33
+ style={{ width, ...style }}
34
+ {...rest}
35
+ />
36
+ </Fragment>
37
+ )
38
+ }
@@ -1,34 +1,34 @@
1
- "use client"
2
-
3
- import Hls from "hls.js"
4
- import { MediaHTMLAttributes, forwardRef, useEffect, useImperativeHandle, useRef } from "react"
5
-
6
- export interface HlsPlayerProps extends Omit<MediaHTMLAttributes<HTMLVideoElement>, "src"> {
7
- src: string
8
- }
9
-
10
- export const HlsPlayer = forwardRef<HTMLVideoElement, HlsPlayerProps>((props, ref) => {
11
- const { src, ...rest } = props
12
- const video = useRef<HTMLVideoElement>(null)
13
-
14
- useImperativeHandle(ref, () => video.current!, [])
15
-
16
- useEffect(() => {
17
- const { current: player } = video
18
- if (!player || !src) return
19
- if (player.canPlayType("application/vnd.apple.mpegurl")) {
20
- player.src = src
21
- return
22
- }
23
- if (Hls.isSupported()) {
24
- const hls = new Hls()
25
- hls.loadSource(src)
26
- hls.attachMedia(player)
27
- return () => {
28
- hls.destroy()
29
- }
30
- }
31
- }, [src])
32
-
33
- return <video ref={video} {...rest} />
34
- })
1
+ "use client"
2
+
3
+ import Hls from "hls.js"
4
+ import { MediaHTMLAttributes, forwardRef, useEffect, useImperativeHandle, useRef } from "react"
5
+
6
+ export interface HlsPlayerProps extends Omit<MediaHTMLAttributes<HTMLVideoElement>, "src"> {
7
+ src: string
8
+ }
9
+
10
+ export const HlsPlayer = forwardRef<HTMLVideoElement, HlsPlayerProps>((props, ref) => {
11
+ const { src, ...rest } = props
12
+ const video = useRef<HTMLVideoElement>(null)
13
+
14
+ useImperativeHandle(ref, () => video.current!, [])
15
+
16
+ useEffect(() => {
17
+ const { current: player } = video
18
+ if (!player || !src) return
19
+ if (player.canPlayType("application/vnd.apple.mpegurl")) {
20
+ player.src = src
21
+ return
22
+ }
23
+ if (Hls.isSupported()) {
24
+ const hls = new Hls()
25
+ hls.loadSource(src)
26
+ hls.attachMedia(player)
27
+ return () => {
28
+ hls.destroy()
29
+ }
30
+ }
31
+ }, [src])
32
+
33
+ return <video ref={video} {...rest} />
34
+ })
@@ -1,135 +1,161 @@
1
- import { css } from "@emotion/css"
2
- import { useSize } from "ahooks"
3
- import { clsx } from "deepsea-tools"
4
- import { ComponentProps, CSSProperties, forwardRef, MouseEvent as ReactMouseEvent, useEffect, useImperativeHandle, useRef } from "react"
5
-
6
- export type InfiniteScrollProps = ComponentProps<"div"> & {
7
- /**
8
- * 滚动的方向
9
- * @default "vertical"
10
- */
11
- direction?: "vertical" | "horizontal"
12
- /** 渲染 children 的容器的类名 */
13
- containerClassName?: string
14
- /** 渲染 children 的容器的样式 */
15
- containerStyle?: CSSProperties
16
- /**
17
- * 两个 children 容器之间的间距
18
- * @default 0
19
- */
20
- gap?: number
21
- /** 一个周期的时间,单位:毫秒 */
22
- duration: number
23
- /** 是否将 gap 的距离也加入 overflow 的计算 */
24
- withGap?: boolean
25
- /** 尺寸刚好相同时,是否视为溢出 */
26
- withEqual?: boolean
27
- /** 鼠标移入时,是否停止动画 */
28
- pauseOnHover?: boolean
29
- }
30
-
31
- /**
32
- * 无限滚动的组件
33
- * 子元素会内置的容器中被渲染两次,首尾相连,形成无限滚动的效果
34
- * 但是,如果内部检测到并没有溢出,那么不会渲染两次,并且没有动画
35
- */
36
- export const InfiniteScroll = forwardRef<HTMLDivElement, InfiniteScrollProps>((props, ref) => {
37
- const { className, direction = "vertical", children, containerClassName, containerStyle, gap = 0, duration, withGap, withEqual, pauseOnHover, onMouseEnter, onMouseLeave, ...rest } = props
38
-
39
- const wrapper = useRef<HTMLDivElement>(null)
40
- const wrapperSize = useSize(wrapper)
41
-
42
- const ele = useRef<HTMLDivElement>(null)
43
-
44
- useImperativeHandle(ref, () => wrapper.current as HTMLDivElement, [wrapper.current])
45
-
46
- const container = useRef<HTMLDivElement>(null)
47
- const containerSize = useSize(container)
48
-
49
- function bigger(containerSize: number, wrapperSize: number) {
50
- return withEqual ? containerSize + (withGap ? gap : 0) >= wrapperSize : containerSize + (withGap ? gap : 0) > wrapperSize
51
- }
52
-
53
- const overflow = wrapperSize && containerSize ? (direction === "vertical" ? bigger(containerSize.height, wrapperSize.height) : bigger(containerSize.width, wrapperSize.width)) : false
54
-
55
- const animation = useRef<Animation | undefined>(undefined)
56
-
57
- useEffect(() => {
58
- if (!wrapperSize || !containerSize || !overflow) return
59
- animation.current = ele.current?.animate(
60
- {
61
- transform: direction === "vertical" ? [`translateY(0)`, `translateY(-${containerSize.height + gap}px)`] : [`translateX(0)`, `translateX(-${containerSize.width + gap}px)`]
62
- },
63
- { duration, iterations: Infinity }
64
- )
65
- return () => animation.current?.cancel()
66
- }, [wrapperSize, containerSize, overflow, direction, duration])
67
-
68
- function enter(e: ReactMouseEvent<HTMLDivElement, MouseEvent>) {
69
- if (pauseOnHover) animation.current?.pause()
70
- onMouseEnter?.(e)
71
- }
72
-
73
- function leave(e: ReactMouseEvent<HTMLDivElement, MouseEvent>) {
74
- if (pauseOnHover) animation.current?.play()
75
- onMouseLeave?.(e)
76
- }
77
-
78
- useEffect(() => {
79
- if (!pauseOnHover && animation.current?.playState === "paused") animation.current?.play()
80
- }, [animation.current, pauseOnHover])
81
-
82
- return (
83
- <div
84
- ref={wrapper}
85
- className={clsx(
86
- css`
87
- position: relative;
88
- ${direction === "vertical" ? "overflow-y: hidden;" : "overflow-x: hidden;"}
89
- `,
90
- className
91
- )}
92
- onMouseEnter={enter}
93
- onMouseLeave={leave}
94
- {...rest}>
95
- <div
96
- ref={ele}
97
- style={{
98
- position: "absolute",
99
- width: direction === "vertical" ? "100%" : containerSize && (overflow ? containerSize.width * 2 + gap : containerSize.width),
100
- height: direction === "horizontal" ? "100%" : containerSize && (overflow ? containerSize.height * 2 + gap : containerSize.width)
101
- }}>
102
- <div
103
- ref={container}
104
- className={clsx(
105
- css`
106
- position: absolute;
107
- left: 0;
108
- top: 0;
109
- ${direction === "vertical" ? "width: 100%;" : "height: 100%;"}
110
- `,
111
- containerClassName
112
- )}
113
- style={containerStyle}>
114
- {children}
115
- </div>
116
- {overflow && (
117
- <div
118
- ref={container}
119
- className={clsx(
120
- css`
121
- position: absolute;
122
- right: 0;
123
- bottom: 0;
124
- ${direction === "vertical" ? "width: 100%;" : "height: 100%;"}
125
- `,
126
- containerClassName
127
- )}
128
- style={containerStyle}>
129
- {children}
130
- </div>
131
- )}
132
- </div>
133
- </div>
134
- )
135
- })
1
+ import { css } from "@emotion/css"
2
+ import { useSize } from "ahooks"
3
+ import { clsx } from "deepsea-tools"
4
+ import { ComponentProps, CSSProperties, forwardRef, MouseEvent as ReactMouseEvent, useEffect, useImperativeHandle, useRef } from "react"
5
+
6
+ export type InfiniteScrollProps = ComponentProps<"div"> & {
7
+ /**
8
+ * 滚动的方向
9
+ * @default "vertical"
10
+ */
11
+ direction?: "vertical" | "horizontal"
12
+ /** 渲染 children 的容器的类名 */
13
+ containerClassName?: string
14
+ /** 渲染 children 的容器的样式 */
15
+ containerStyle?: CSSProperties
16
+ /**
17
+ * 两个 children 容器之间的间距
18
+ * @default 0
19
+ */
20
+ gap?: number
21
+ /** 一个周期的时间,单位:毫秒 */
22
+ duration: number
23
+ /** 是否将 gap 的距离也加入 overflow 的计算 */
24
+ withGap?: boolean
25
+ /** 尺寸刚好相同时,是否视为溢出 */
26
+ withEqual?: boolean
27
+ /** 鼠标移入时,是否停止动画 */
28
+ pauseOnHover?: boolean
29
+ }
30
+
31
+ /**
32
+ * 无限滚动的组件
33
+ * 子元素会内置的容器中被渲染两次,首尾相连,形成无限滚动的效果
34
+ * 但是,如果内部检测到并没有溢出,那么不会渲染两次,并且没有动画
35
+ */
36
+ export const InfiniteScroll = forwardRef<HTMLDivElement, InfiniteScrollProps>((props, ref) => {
37
+ const {
38
+ className,
39
+ direction = "vertical",
40
+ children,
41
+ containerClassName,
42
+ containerStyle,
43
+ gap = 0,
44
+ duration,
45
+ withGap,
46
+ withEqual,
47
+ pauseOnHover,
48
+ onMouseEnter,
49
+ onMouseLeave,
50
+ ...rest
51
+ } = props
52
+
53
+ const wrapper = useRef<HTMLDivElement>(null)
54
+ const wrapperSize = useSize(wrapper)
55
+
56
+ const ele = useRef<HTMLDivElement>(null)
57
+
58
+ useImperativeHandle(ref, () => wrapper.current as HTMLDivElement, [wrapper.current])
59
+
60
+ const container = useRef<HTMLDivElement>(null)
61
+ const containerSize = useSize(container)
62
+
63
+ function bigger(containerSize: number, wrapperSize: number) {
64
+ return withEqual ? containerSize + (withGap ? gap : 0) >= wrapperSize : containerSize + (withGap ? gap : 0) > wrapperSize
65
+ }
66
+
67
+ const overflow =
68
+ wrapperSize && containerSize
69
+ ? direction === "vertical"
70
+ ? bigger(containerSize.height, wrapperSize.height)
71
+ : bigger(containerSize.width, wrapperSize.width)
72
+ : false
73
+
74
+ const animation = useRef<Animation | undefined>(undefined)
75
+
76
+ useEffect(() => {
77
+ if (!wrapperSize || !containerSize || !overflow) return
78
+ animation.current = ele.current?.animate(
79
+ {
80
+ transform:
81
+ direction === "vertical"
82
+ ? [`translateY(0)`, `translateY(-${containerSize.height + gap}px)`]
83
+ : [`translateX(0)`, `translateX(-${containerSize.width + gap}px)`],
84
+ },
85
+ { duration, iterations: Infinity },
86
+ )
87
+ return () => animation.current?.cancel()
88
+ }, [wrapperSize, containerSize, overflow, direction, duration])
89
+
90
+ function enter(e: ReactMouseEvent<HTMLDivElement, MouseEvent>) {
91
+ if (pauseOnHover) animation.current?.pause()
92
+ onMouseEnter?.(e)
93
+ }
94
+
95
+ function leave(e: ReactMouseEvent<HTMLDivElement, MouseEvent>) {
96
+ if (pauseOnHover) animation.current?.play()
97
+ onMouseLeave?.(e)
98
+ }
99
+
100
+ useEffect(() => {
101
+ if (!pauseOnHover && animation.current?.playState === "paused") animation.current?.play()
102
+ }, [animation.current, pauseOnHover])
103
+
104
+ return (
105
+ <div
106
+ ref={wrapper}
107
+ className={clsx(
108
+ css`
109
+ position: relative;
110
+ ${direction === "vertical" ? "overflow-y: hidden;" : "overflow-x: hidden;"}
111
+ `,
112
+ className,
113
+ )}
114
+ onMouseEnter={enter}
115
+ onMouseLeave={leave}
116
+ {...rest}
117
+ >
118
+ <div
119
+ ref={ele}
120
+ style={{
121
+ position: "absolute",
122
+ width: direction === "vertical" ? "100%" : containerSize && (overflow ? containerSize.width * 2 + gap : containerSize.width),
123
+ height: direction === "horizontal" ? "100%" : containerSize && (overflow ? containerSize.height * 2 + gap : containerSize.width),
124
+ }}
125
+ >
126
+ <div
127
+ ref={container}
128
+ className={clsx(
129
+ css`
130
+ position: absolute;
131
+ left: 0;
132
+ top: 0;
133
+ ${direction === "vertical" ? "width: 100%;" : "height: 100%;"}
134
+ `,
135
+ containerClassName,
136
+ )}
137
+ style={containerStyle}
138
+ >
139
+ {children}
140
+ </div>
141
+ {overflow && (
142
+ <div
143
+ ref={container}
144
+ className={clsx(
145
+ css`
146
+ position: absolute;
147
+ right: 0;
148
+ bottom: 0;
149
+ ${direction === "vertical" ? "width: 100%;" : "height: 100%;"}
150
+ `,
151
+ containerClassName,
152
+ )}
153
+ style={containerStyle}
154
+ >
155
+ {children}
156
+ </div>
157
+ )}
158
+ </div>
159
+ </div>
160
+ )
161
+ })