deepsea-components 5.15.24 → 5.15.26

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 (52) hide show
  1. package/README.md +23 -23
  2. package/dist/components/AutoFit.cjs +6 -6
  3. package/dist/components/AutoFit.js +6 -6
  4. package/dist/components/AutoScroll.cjs +7 -7
  5. package/dist/components/AutoScroll.js +7 -7
  6. package/dist/components/AutoSizeTextarea.cjs +4 -4
  7. package/dist/components/AutoSizeTextarea.js +4 -4
  8. package/dist/components/Flow.cjs +16 -16
  9. package/dist/components/Flow.js +16 -16
  10. package/dist/components/InfiniteScroll.cjs +13 -13
  11. package/dist/components/InfiniteScroll.js +13 -13
  12. package/dist/components/LoopSwiper.cjs +33 -33
  13. package/dist/components/LoopSwiper.js +33 -33
  14. package/dist/components/Scroll.cjs +13 -13
  15. package/dist/components/Scroll.js +13 -13
  16. package/dist/components/Skeleton.cjs +17 -17
  17. package/dist/components/Skeleton.js +17 -17
  18. package/dist/components/Trapezium.cjs +4 -4
  19. package/dist/components/Trapezium.js +4 -4
  20. package/package.json +3 -3
  21. package/src/components/AutoFit.tsx +104 -104
  22. package/src/components/AutoScroll.tsx +150 -150
  23. package/src/components/AutoSizeTextarea.tsx +50 -50
  24. package/src/components/CircleText.tsx +81 -81
  25. package/src/components/CopyButton.tsx +31 -31
  26. package/src/components/Echart.tsx +69 -69
  27. package/src/components/Flow.tsx +271 -271
  28. package/src/components/FormLabel.tsx +41 -41
  29. package/src/components/HlsPlayer.tsx +34 -34
  30. package/src/components/IconFileType.tsx +162 -162
  31. package/src/components/InfiniteScroll.tsx +163 -163
  32. package/src/components/InputFile.tsx +93 -93
  33. package/src/components/InputFileButton.tsx +122 -122
  34. package/src/components/LoopSwiper.tsx +125 -125
  35. package/src/components/ReadExcel.tsx +13 -13
  36. package/src/components/ReadSheet.tsx +17 -17
  37. package/src/components/Ring.tsx +30 -30
  38. package/src/components/Scroll.tsx +97 -97
  39. package/src/components/ScrollMask.module.css +87 -87
  40. package/src/components/ScrollMask.tsx +68 -68
  41. package/src/components/SectionRing.tsx +40 -40
  42. package/src/components/Skeleton.tsx +45 -45
  43. package/src/components/Title.tsx +27 -27
  44. package/src/components/TransitionBox.tsx +44 -44
  45. package/src/components/TransitionNum.tsx +54 -54
  46. package/src/components/Trapezium.tsx +60 -60
  47. package/src/components/Unify.tsx +38 -38
  48. package/src/components/WriteExcel.tsx +13 -13
  49. package/src/components/WriteSheet.tsx +25 -25
  50. package/src/utils/getReactVersion.ts +7 -7
  51. package/src/utils/index.ts +33 -33
  52. package/tsconfig.json +16 -16
@@ -1,50 +1,50 @@
1
- "use client"
2
-
3
- import { css } from "@emotion/css"
4
- import { clsx } from "deepsea-tools"
5
- import { TextareaHTMLAttributes, forwardRef, useImperativeHandle, useLayoutEffect, useRef, useState } from "react"
6
-
7
- import { px, transformCSSVariable } from "@/utils"
8
-
9
- /**
10
- * 自适应高度的文本域
11
- */
12
- export const AutoSizeTextArea = forwardRef<HTMLTextAreaElement, TextareaHTMLAttributes<HTMLTextAreaElement>>((props, ref) => {
13
- const { className, style, ...rest } = props
14
- const [height, setHeight] = useState<string | undefined>(undefined)
15
- const ele = useRef<HTMLTextAreaElement>(null)
16
-
17
- useImperativeHandle(ref, () => ele.current!, [])
18
-
19
- useLayoutEffect(() => {
20
- const textarea = ele.current!
21
- function resizeTextarea() {
22
- setHeight("auto")
23
- setHeight(px(textarea.scrollHeight + textarea.offsetHeight - textarea.clientHeight))
24
- }
25
- resizeTextarea()
26
- textarea.addEventListener("input", resizeTextarea)
27
- textarea.addEventListener("change", resizeTextarea)
28
-
29
- return () => {
30
- textarea.removeEventListener("input", resizeTextarea)
31
- textarea.removeEventListener("change", resizeTextarea)
32
- }
33
- }, [])
34
-
35
- return (
36
- <textarea
37
- ref={ele}
38
- className={clsx(
39
- css`
40
- height: var(--height);
41
- resize: none;
42
- overflow-y: hidden;
43
- `,
44
- className,
45
- )}
46
- style={transformCSSVariable({ height }, style)}
47
- {...rest}
48
- />
49
- )
50
- })
1
+ "use client"
2
+
3
+ import { css } from "@emotion/css"
4
+ import { clsx } from "deepsea-tools"
5
+ import { TextareaHTMLAttributes, forwardRef, useImperativeHandle, useLayoutEffect, useRef, useState } from "react"
6
+
7
+ import { px, transformCSSVariable } from "@/utils"
8
+
9
+ /**
10
+ * 自适应高度的文本域
11
+ */
12
+ export const AutoSizeTextArea = forwardRef<HTMLTextAreaElement, TextareaHTMLAttributes<HTMLTextAreaElement>>((props, ref) => {
13
+ const { className, style, ...rest } = props
14
+ const [height, setHeight] = useState<string | undefined>(undefined)
15
+ const ele = useRef<HTMLTextAreaElement>(null)
16
+
17
+ useImperativeHandle(ref, () => ele.current!, [])
18
+
19
+ useLayoutEffect(() => {
20
+ const textarea = ele.current!
21
+ function resizeTextarea() {
22
+ setHeight("auto")
23
+ setHeight(px(textarea.scrollHeight + textarea.offsetHeight - textarea.clientHeight))
24
+ }
25
+ resizeTextarea()
26
+ textarea.addEventListener("input", resizeTextarea)
27
+ textarea.addEventListener("change", resizeTextarea)
28
+
29
+ return () => {
30
+ textarea.removeEventListener("input", resizeTextarea)
31
+ textarea.removeEventListener("change", resizeTextarea)
32
+ }
33
+ }, [])
34
+
35
+ return (
36
+ <textarea
37
+ ref={ele}
38
+ className={clsx(
39
+ css`
40
+ height: var(--height);
41
+ resize: none;
42
+ overflow-y: hidden;
43
+ `,
44
+ className,
45
+ )}
46
+ style={transformCSSVariable({ height }, style)}
47
+ {...rest}
48
+ />
49
+ )
50
+ })
@@ -1,81 +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
- 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
+ "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,31 +1,31 @@
1
- "use client"
2
-
3
- import ClipboardJS, { Event } from "clipboard"
4
- import { ComponentPropsWithoutRef, forwardRef, useEffect, useImperativeHandle, useRef } from "react"
5
- import { useLatest } from "soda-hooks"
6
-
7
- export { Event } from "clipboard"
8
-
9
- export type CopyButtonProps = ComponentPropsWithoutRef<"button"> & {
10
- text?: string
11
- onCopySuccess?: (e: Event) => void
12
- onCopyError?: (e: Event) => void
13
- }
14
-
15
- export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>((props, ref) => {
16
- const { text, onCopySuccess: _onCoptSuccess, onCopyError: _onCopyError, ...rest } = props
17
- const ele = useRef<HTMLButtonElement>(null)
18
- const onCopySuccess = useLatest(_onCoptSuccess)
19
- const onCopyError = useLatest(_onCopyError)
20
-
21
- useImperativeHandle(ref, () => ele.current!, [ele.current])
22
-
23
- useEffect(() => {
24
- const clipboard = new ClipboardJS(ele.current!)
25
- clipboard.on("success", event => onCopySuccess.current?.(event))
26
- clipboard.on("error", event => onCopyError.current?.(event))
27
- return () => clipboard.destroy()
28
- }, [])
29
-
30
- return <button ref={ele} {...rest} data-clipboard-text={text} />
31
- })
1
+ "use client"
2
+
3
+ import ClipboardJS, { Event } from "clipboard"
4
+ import { ComponentPropsWithoutRef, forwardRef, useEffect, useImperativeHandle, useRef } from "react"
5
+ import { useLatest } from "soda-hooks"
6
+
7
+ export { Event } from "clipboard"
8
+
9
+ export type CopyButtonProps = ComponentPropsWithoutRef<"button"> & {
10
+ text?: string
11
+ onCopySuccess?: (e: Event) => void
12
+ onCopyError?: (e: Event) => void
13
+ }
14
+
15
+ export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>((props, ref) => {
16
+ const { text, onCopySuccess: _onCoptSuccess, onCopyError: _onCopyError, ...rest } = props
17
+ const ele = useRef<HTMLButtonElement>(null)
18
+ const onCopySuccess = useLatest(_onCoptSuccess)
19
+ const onCopyError = useLatest(_onCopyError)
20
+
21
+ useImperativeHandle(ref, () => ele.current!, [ele.current])
22
+
23
+ useEffect(() => {
24
+ const clipboard = new ClipboardJS(ele.current!)
25
+ clipboard.on("success", event => onCopySuccess.current?.(event))
26
+ clipboard.on("error", event => onCopyError.current?.(event))
27
+ return () => clipboard.destroy()
28
+ }, [])
29
+
30
+ return <button ref={ele} {...rest} data-clipboard-text={text} />
31
+ })
@@ -1,69 +1,69 @@
1
- "use client"
2
-
3
- import {
4
- BarSeriesOption,
5
- ComposeOption,
6
- DatasetComponentOption,
7
- ECharts,
8
- GridComponentOption,
9
- LineSeriesOption,
10
- PieSeriesOption,
11
- TitleComponentOption,
12
- TooltipComponentOption,
13
- init,
14
- } from "echarts"
15
- import {
16
- ComponentPropsWithoutRef,
17
- ForwardRefExoticComponent,
18
- ForwardedRef,
19
- RefAttributes,
20
- forwardRef,
21
- useEffect,
22
- useImperativeHandle,
23
- useLayoutEffect,
24
- useRef,
25
- } from "react"
26
-
27
- export type PieOption = ComposeOption<PieSeriesOption | TitleComponentOption | DatasetComponentOption | GridComponentOption | TooltipComponentOption>
28
-
29
- export type BarOption = ComposeOption<BarSeriesOption | TitleComponentOption | DatasetComponentOption | GridComponentOption | TooltipComponentOption>
30
-
31
- export type LineOption = ComposeOption<LineSeriesOption | TitleComponentOption | DatasetComponentOption | GridComponentOption | TooltipComponentOption>
32
-
33
- export interface EchartProps<T extends any = any> extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
34
- width: number
35
- height: number
36
- option: T
37
- chart?: ForwardedRef<ECharts>
38
- }
39
-
40
- export type EchartComponent<T extends PieOption | BarOption | LineOption> = ForwardRefExoticComponent<
41
- Omit<EchartProps<T>, "ref"> & RefAttributes<HTMLDivElement>
42
- >
43
-
44
- const Echart = forwardRef<HTMLDivElement, EchartProps>((props, ref) => {
45
- const { width, height, option, chart, ...rest } = props
46
- const container = useRef<HTMLDivElement>(null)
47
- const chartRef = useRef<ECharts | null>(null)
48
-
49
- useLayoutEffect(() => {
50
- const ele = container.current!
51
- chartRef.current = init(ele, option, { width, height })
52
- return () => chartRef.current?.dispose()
53
- }, [])
54
-
55
- useImperativeHandle(ref, () => container.current!, [])
56
-
57
- useImperativeHandle(chart, () => chartRef.current!, [])
58
-
59
- useEffect(() => {
60
- chartRef.current?.setOption(option)
61
- chartRef.current?.resize({ width, height })
62
- })
63
-
64
- return <div ref={container} {...rest} />
65
- })
66
-
67
- export const Pie = Echart as EchartComponent<PieOption>
68
- export const Bar = Echart as EchartComponent<BarOption>
69
- export const Line = Echart as EchartComponent<LineOption>
1
+ "use client"
2
+
3
+ import {
4
+ BarSeriesOption,
5
+ ComposeOption,
6
+ DatasetComponentOption,
7
+ ECharts,
8
+ GridComponentOption,
9
+ LineSeriesOption,
10
+ PieSeriesOption,
11
+ TitleComponentOption,
12
+ TooltipComponentOption,
13
+ init,
14
+ } from "echarts"
15
+ import {
16
+ ComponentPropsWithoutRef,
17
+ ForwardRefExoticComponent,
18
+ ForwardedRef,
19
+ RefAttributes,
20
+ forwardRef,
21
+ useEffect,
22
+ useImperativeHandle,
23
+ useLayoutEffect,
24
+ useRef,
25
+ } from "react"
26
+
27
+ export type PieOption = ComposeOption<PieSeriesOption | TitleComponentOption | DatasetComponentOption | GridComponentOption | TooltipComponentOption>
28
+
29
+ export type BarOption = ComposeOption<BarSeriesOption | TitleComponentOption | DatasetComponentOption | GridComponentOption | TooltipComponentOption>
30
+
31
+ export type LineOption = ComposeOption<LineSeriesOption | TitleComponentOption | DatasetComponentOption | GridComponentOption | TooltipComponentOption>
32
+
33
+ export interface EchartProps<T extends any = any> extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
34
+ width: number
35
+ height: number
36
+ option: T
37
+ chart?: ForwardedRef<ECharts>
38
+ }
39
+
40
+ export type EchartComponent<T extends PieOption | BarOption | LineOption> = ForwardRefExoticComponent<
41
+ Omit<EchartProps<T>, "ref"> & RefAttributes<HTMLDivElement>
42
+ >
43
+
44
+ const Echart = forwardRef<HTMLDivElement, EchartProps>((props, ref) => {
45
+ const { width, height, option, chart, ...rest } = props
46
+ const container = useRef<HTMLDivElement>(null)
47
+ const chartRef = useRef<ECharts | null>(null)
48
+
49
+ useLayoutEffect(() => {
50
+ const ele = container.current!
51
+ chartRef.current = init(ele, option, { width, height })
52
+ return () => chartRef.current?.dispose()
53
+ }, [])
54
+
55
+ useImperativeHandle(ref, () => container.current!, [])
56
+
57
+ useImperativeHandle(chart, () => chartRef.current!, [])
58
+
59
+ useEffect(() => {
60
+ chartRef.current?.setOption(option)
61
+ chartRef.current?.resize({ width, height })
62
+ })
63
+
64
+ return <div ref={container} {...rest} />
65
+ })
66
+
67
+ export const Pie = Echart as EchartComponent<PieOption>
68
+ export const Bar = Echart as EchartComponent<BarOption>
69
+ export const Line = Echart as EchartComponent<LineOption>