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.
- 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.d.ts +9 -0
- package/dist/cjs/components/CopyButton.js +59 -0
- package/dist/cjs/components/CopyButton.js.map +7 -0
- 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/index.d.ts +1 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +2 -2
- 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.d.ts +9 -0
- package/dist/esm/components/CopyButton.js +29 -0
- package/dist/esm/components/CopyButton.js.map +1 -0
- 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/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.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 +4 -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 -0
- 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/index.ts +1 -0
- package/src/utils/getReactVersion.ts +7 -7
- package/src/utils/index.ts +33 -33
package/src/components/Title.tsx
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import { ComponentProps, forwardRef, useImperativeHandle, useLayoutEffect, useRef } from "react"
|
|
2
|
-
import { createPortal } from "react-dom"
|
|
3
|
-
import { getReactVersion } from "../utils/getReactVersion"
|
|
4
|
-
|
|
5
|
-
export type TitleProps = ComponentProps<"title">
|
|
6
|
-
|
|
7
|
-
const [major] = getReactVersion()
|
|
8
|
-
|
|
9
|
-
export const Title = forwardRef<HTMLTitleElement, TitleProps>((props, ref) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
})
|
|
1
|
+
import { ComponentProps, forwardRef, useImperativeHandle, useLayoutEffect, useRef } from "react"
|
|
2
|
+
import { createPortal } from "react-dom"
|
|
3
|
+
import { getReactVersion } from "../utils/getReactVersion"
|
|
4
|
+
|
|
5
|
+
export type TitleProps = ComponentProps<"title">
|
|
6
|
+
|
|
7
|
+
const [major] = getReactVersion()
|
|
8
|
+
|
|
9
|
+
export const Title = forwardRef<HTMLTitleElement, TitleProps>((props, ref) => {
|
|
10
|
+
if (major >= 19) return <title ref={ref} {...props} />
|
|
11
|
+
|
|
12
|
+
const ele = useRef<HTMLTitleElement>(null)
|
|
13
|
+
|
|
14
|
+
useImperativeHandle(ref, () => ele.current as HTMLTitleElement, [ele.current])
|
|
15
|
+
|
|
16
|
+
useLayoutEffect(() => {
|
|
17
|
+
const title = document.head.querySelector("title")
|
|
18
|
+
if (title === ele.current) return
|
|
19
|
+
document.head.insertBefore(ele.current as HTMLTitleElement, title)
|
|
20
|
+
}, [])
|
|
21
|
+
|
|
22
|
+
return createPortal(<title ref={ele} {...props} />, document.head)
|
|
23
|
+
})
|
|
@@ -1,36 +1,44 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { useSize } from "ahooks"
|
|
4
|
-
import { CSSProperties, FC, forwardRef, HTMLAttributes, useEffect, useRef, useState } from "react"
|
|
5
|
-
|
|
6
|
-
export interface TransitionBoxProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
-
containerClassName?: string
|
|
8
|
-
containerStyle?: CSSProperties
|
|
9
|
-
vertical?: boolean
|
|
10
|
-
horizontal?: boolean
|
|
11
|
-
time?: number
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/** 尺寸渐变的组件 */
|
|
15
|
-
export const TransitionBox: FC<TransitionBoxProps> = forwardRef<HTMLDivElement, TransitionBoxProps>((props, ref) => {
|
|
16
|
-
const { style, containerClassName, containerStyle, children, vertical = true, horizontal = true, time = 3000, ...rest } = props
|
|
17
|
-
const container = useRef<HTMLDivElement>(null)
|
|
18
|
-
const size = useSize(container)
|
|
19
|
-
const width = size?.width ?? 0
|
|
20
|
-
const height = size?.height ?? 0
|
|
21
|
-
const [count, setCount] = useState(0)
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
setCount(count => Math.min(count + 1, 3))
|
|
25
|
-
}, [width, height])
|
|
26
|
-
|
|
27
|
-
const outerStyle: CSSProperties = {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { useSize } from "ahooks"
|
|
4
|
+
import { CSSProperties, FC, forwardRef, HTMLAttributes, useEffect, useRef, useState } from "react"
|
|
5
|
+
|
|
6
|
+
export interface TransitionBoxProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
containerClassName?: string
|
|
8
|
+
containerStyle?: CSSProperties
|
|
9
|
+
vertical?: boolean
|
|
10
|
+
horizontal?: boolean
|
|
11
|
+
time?: number
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** 尺寸渐变的组件 */
|
|
15
|
+
export const TransitionBox: FC<TransitionBoxProps> = forwardRef<HTMLDivElement, TransitionBoxProps>((props, ref) => {
|
|
16
|
+
const { style, containerClassName, containerStyle, children, vertical = true, horizontal = true, time = 3000, ...rest } = props
|
|
17
|
+
const container = useRef<HTMLDivElement>(null)
|
|
18
|
+
const size = useSize(container)
|
|
19
|
+
const width = size?.width ?? 0
|
|
20
|
+
const height = size?.height ?? 0
|
|
21
|
+
const [count, setCount] = useState(0)
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
setCount(count => Math.min(count + 1, 3))
|
|
25
|
+
}, [width, height])
|
|
26
|
+
|
|
27
|
+
const outerStyle: CSSProperties = {
|
|
28
|
+
transitionProperty: count === 3 ? [horizontal && "width", vertical && "height"].filter(Boolean).join(", ") : undefined,
|
|
29
|
+
transitionDuration: count === 3 ? `${time}ms` : undefined,
|
|
30
|
+
width,
|
|
31
|
+
height,
|
|
32
|
+
overflow: "hidden",
|
|
33
|
+
position: "relative",
|
|
34
|
+
...style,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div ref={ref} style={outerStyle} {...rest}>
|
|
39
|
+
<div className={containerClassName} style={{ position: "absolute", ...containerStyle }} ref={container}>
|
|
40
|
+
{children}
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
)
|
|
44
|
+
})
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { setFrameInterval } from "deepsea-tools"
|
|
4
|
-
import { ForwardedRef, HTMLAttributes, forwardRef, useEffect, useImperativeHandle, useRef } from "react"
|
|
5
|
-
|
|
6
|
-
export interface TransitionNumProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
|
7
|
-
/** 当前数字 */
|
|
8
|
-
children: number
|
|
9
|
-
/** 变换周期,单位帧 */
|
|
10
|
-
period: number
|
|
11
|
-
/** 数字转换为字符串的方法 */
|
|
12
|
-
numToStr?: (num: number) => string
|
|
13
|
-
/** 实例 */
|
|
14
|
-
ins?: ForwardedRef<TransitionNumIns>
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface TransitionNumIns {
|
|
18
|
-
get(): number
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** 渐变数字组件 */
|
|
22
|
-
export const TransitionNum = forwardRef<HTMLDivElement, TransitionNumProps>((props, ref) => {
|
|
23
|
-
const { children: num, period, numToStr, ins, ...rest } = props
|
|
24
|
-
if (!Number.isInteger(num) || !Number.isInteger(period) || period <= 0) {
|
|
25
|
-
throw new RangeError("目标数字必须是整数,周期必须是正整数")
|
|
26
|
-
}
|
|
27
|
-
const ele = useRef<HTMLDivElement>(null)
|
|
28
|
-
const cache = useRef({ num, period, numToStr, show: num })
|
|
29
|
-
cache.current = { ...cache.current, num, period, numToStr }
|
|
30
|
-
|
|
31
|
-
useImperativeHandle(ref, () => ele.current!, [])
|
|
32
|
-
useImperativeHandle(ins, () => ({ get: () => cache.current.show }), [])
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
const { num, period, show, numToStr } = cache.current
|
|
36
|
-
ele.current!.innerText = (numToStr || String)(show)
|
|
37
|
-
if (num === show) return
|
|
38
|
-
const div = ele.current!
|
|
39
|
-
const speed = (num - show) / period
|
|
40
|
-
const cancel = setFrameInterval(() => {
|
|
41
|
-
const { num, numToStr } = cache.current
|
|
42
|
-
cache.current.show += speed
|
|
43
|
-
if ((speed > 0 && cache.current.show > num) || (speed < 0 && cache.current.show < num)) {
|
|
44
|
-
cancel()
|
|
45
|
-
cache.current.show = num
|
|
46
|
-
}
|
|
47
|
-
div.innerText = (numToStr || String)(speed > 0 ? Math.floor(cache.current.show) : Math.ceil(cache.current.show))
|
|
48
|
-
}, 1)
|
|
49
|
-
|
|
50
|
-
return cancel
|
|
51
|
-
}, [num])
|
|
52
|
-
|
|
53
|
-
return <div ref={ele} {...rest} />
|
|
54
|
-
})
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { setFrameInterval } from "deepsea-tools"
|
|
4
|
+
import { ForwardedRef, HTMLAttributes, forwardRef, useEffect, useImperativeHandle, useRef } from "react"
|
|
5
|
+
|
|
6
|
+
export interface TransitionNumProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
|
7
|
+
/** 当前数字 */
|
|
8
|
+
children: number
|
|
9
|
+
/** 变换周期,单位帧 */
|
|
10
|
+
period: number
|
|
11
|
+
/** 数字转换为字符串的方法 */
|
|
12
|
+
numToStr?: (num: number) => string
|
|
13
|
+
/** 实例 */
|
|
14
|
+
ins?: ForwardedRef<TransitionNumIns>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface TransitionNumIns {
|
|
18
|
+
get(): number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** 渐变数字组件 */
|
|
22
|
+
export const TransitionNum = forwardRef<HTMLDivElement, TransitionNumProps>((props, ref) => {
|
|
23
|
+
const { children: num, period, numToStr, ins, ...rest } = props
|
|
24
|
+
if (!Number.isInteger(num) || !Number.isInteger(period) || period <= 0) {
|
|
25
|
+
throw new RangeError("目标数字必须是整数,周期必须是正整数")
|
|
26
|
+
}
|
|
27
|
+
const ele = useRef<HTMLDivElement>(null)
|
|
28
|
+
const cache = useRef({ num, period, numToStr, show: num })
|
|
29
|
+
cache.current = { ...cache.current, num, period, numToStr }
|
|
30
|
+
|
|
31
|
+
useImperativeHandle(ref, () => ele.current!, [])
|
|
32
|
+
useImperativeHandle(ins, () => ({ get: () => cache.current.show }), [])
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const { num, period, show, numToStr } = cache.current
|
|
36
|
+
ele.current!.innerText = (numToStr || String)(show)
|
|
37
|
+
if (num === show) return
|
|
38
|
+
const div = ele.current!
|
|
39
|
+
const speed = (num - show) / period
|
|
40
|
+
const cancel = setFrameInterval(() => {
|
|
41
|
+
const { num, numToStr } = cache.current
|
|
42
|
+
cache.current.show += speed
|
|
43
|
+
if ((speed > 0 && cache.current.show > num) || (speed < 0 && cache.current.show < num)) {
|
|
44
|
+
cancel()
|
|
45
|
+
cache.current.show = num
|
|
46
|
+
}
|
|
47
|
+
div.innerText = (numToStr || String)(speed > 0 ? Math.floor(cache.current.show) : Math.ceil(cache.current.show))
|
|
48
|
+
}, 1)
|
|
49
|
+
|
|
50
|
+
return cancel
|
|
51
|
+
}, [num])
|
|
52
|
+
|
|
53
|
+
return <div ref={ele} {...rest} />
|
|
54
|
+
})
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { css } from "@emotion/css"
|
|
4
|
-
import { clsx } from "deepsea-tools"
|
|
5
|
-
import { HTMLAttributes, forwardRef } from "react"
|
|
6
|
-
import { px, transformCSSVariable } from "../utils"
|
|
7
|
-
|
|
8
|
-
export interface TrapeziumProps extends HTMLAttributes<HTMLDivElement> {
|
|
9
|
-
top: number
|
|
10
|
-
bottom: number
|
|
11
|
-
height: number
|
|
12
|
-
borderRadius: number
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/** 梯形组件 */
|
|
16
|
-
export const Trapezium = forwardRef<HTMLDivElement, TrapeziumProps>((props, ref) => {
|
|
17
|
-
const { top, bottom, height, borderRadius, className, style, ...rest } = props
|
|
18
|
-
|
|
19
|
-
const diff = (bottom - top) / 2
|
|
20
|
-
|
|
21
|
-
const a = Math.atan(height / diff) / 2
|
|
22
|
-
|
|
23
|
-
const b = borderRadius / Math.tan(a)
|
|
24
|
-
|
|
25
|
-
const c = b * Math.cos(a * 2)
|
|
26
|
-
|
|
27
|
-
const d = b * Math.sin(a * 2)
|
|
28
|
-
|
|
29
|
-
const e = Math.PI / 2 - a
|
|
30
|
-
|
|
31
|
-
const f = borderRadius / Math.tan(e)
|
|
32
|
-
|
|
33
|
-
const g = f * Math.cos(a * 2)
|
|
34
|
-
|
|
35
|
-
const h = f * Math.sin(a * 2)
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<div
|
|
39
|
-
ref={ref}
|
|
40
|
-
className={clsx(
|
|
41
|
-
css`
|
|
42
|
-
width: var(--width);
|
|
43
|
-
height: var(--height);
|
|
44
|
-
clip-path: var(--clip-path);
|
|
45
|
-
`,
|
|
46
|
-
className
|
|
47
|
-
)}
|
|
48
|
-
style={transformCSSVariable(
|
|
49
|
-
{
|
|
50
|
-
width: px(bottom),
|
|
51
|
-
height: px(height),
|
|
52
|
-
clipath: `path("M ${diff + f} ${0} A ${borderRadius} ${borderRadius} 0 0 0 ${diff - g} ${h} L ${c} ${height - d} A ${borderRadius} ${borderRadius} 0 0 0 ${b} ${height} L ${bottom - b} ${height} A ${borderRadius} ${borderRadius} 0 0 0 ${bottom - c} ${height - d} L ${top + diff + g} ${h} A ${borderRadius} ${borderRadius} 0 0 0 ${top + diff - f} ${0} Z")
|
|
53
|
-
},
|
|
54
|
-
style
|
|
55
|
-
)}
|
|
56
|
-
{...rest}
|
|
57
|
-
/>
|
|
58
|
-
)
|
|
59
|
-
})
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { css } from "@emotion/css"
|
|
4
|
+
import { clsx } from "deepsea-tools"
|
|
5
|
+
import { HTMLAttributes, forwardRef } from "react"
|
|
6
|
+
import { px, transformCSSVariable } from "../utils"
|
|
7
|
+
|
|
8
|
+
export interface TrapeziumProps extends HTMLAttributes<HTMLDivElement> {
|
|
9
|
+
top: number
|
|
10
|
+
bottom: number
|
|
11
|
+
height: number
|
|
12
|
+
borderRadius: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** 梯形组件 */
|
|
16
|
+
export const Trapezium = forwardRef<HTMLDivElement, TrapeziumProps>((props, ref) => {
|
|
17
|
+
const { top, bottom, height, borderRadius, className, style, ...rest } = props
|
|
18
|
+
|
|
19
|
+
const diff = (bottom - top) / 2
|
|
20
|
+
|
|
21
|
+
const a = Math.atan(height / diff) / 2
|
|
22
|
+
|
|
23
|
+
const b = borderRadius / Math.tan(a)
|
|
24
|
+
|
|
25
|
+
const c = b * Math.cos(a * 2)
|
|
26
|
+
|
|
27
|
+
const d = b * Math.sin(a * 2)
|
|
28
|
+
|
|
29
|
+
const e = Math.PI / 2 - a
|
|
30
|
+
|
|
31
|
+
const f = borderRadius / Math.tan(e)
|
|
32
|
+
|
|
33
|
+
const g = f * Math.cos(a * 2)
|
|
34
|
+
|
|
35
|
+
const h = f * Math.sin(a * 2)
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
ref={ref}
|
|
40
|
+
className={clsx(
|
|
41
|
+
css`
|
|
42
|
+
width: var(--width);
|
|
43
|
+
height: var(--height);
|
|
44
|
+
clip-path: var(--clip-path);
|
|
45
|
+
`,
|
|
46
|
+
className,
|
|
47
|
+
)}
|
|
48
|
+
style={transformCSSVariable(
|
|
49
|
+
{
|
|
50
|
+
width: px(bottom),
|
|
51
|
+
height: px(height),
|
|
52
|
+
clipath: `path("M ${diff + f} ${0} A ${borderRadius} ${borderRadius} 0 0 0 ${diff - g} ${h} L ${c} ${height - d} A ${borderRadius} ${borderRadius} 0 0 0 ${b} ${height} L ${bottom - b} ${height} A ${borderRadius} ${borderRadius} 0 0 0 ${bottom - c} ${height - d} L ${top + diff + g} ${h} A ${borderRadius} ${borderRadius} 0 0 0 ${top + diff - f} ${0} Z")`,
|
|
53
|
+
},
|
|
54
|
+
style,
|
|
55
|
+
)}
|
|
56
|
+
{...rest}
|
|
57
|
+
/>
|
|
58
|
+
)
|
|
59
|
+
})
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "@components/AutoFit"
|
|
|
2
2
|
export * from "@components/AutoScroll"
|
|
3
3
|
export * from "@components/AutoSizeTextarea"
|
|
4
4
|
export * from "@components/CircleText"
|
|
5
|
+
export * from "@components/CopyButton"
|
|
5
6
|
export * from "@components/Echart"
|
|
6
7
|
export * from "@components/Flow"
|
|
7
8
|
export * from "@components/FormLabel"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { version } from "react"
|
|
2
|
-
|
|
3
|
-
const reg = /(\d+)\.(\d+)\.(\d+)/
|
|
4
|
-
|
|
5
|
-
export function getReactVersion() {
|
|
6
|
-
return version.match(reg)!.slice(1).map(Number)
|
|
7
|
-
}
|
|
1
|
+
import { version } from "react"
|
|
2
|
+
|
|
3
|
+
const reg = /(\d+)\.(\d+)\.(\d+)/
|
|
4
|
+
|
|
5
|
+
export function getReactVersion() {
|
|
6
|
+
return version.match(reg)!.slice(1).map(Number)
|
|
7
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { CSSProperties } from "react"
|
|
2
|
-
|
|
3
|
-
export type CSSVariableName = `--${string}`
|
|
4
|
-
|
|
5
|
-
export type CSSVariableValue = string | number | undefined
|
|
6
|
-
|
|
7
|
-
export interface StyleWithCSSVariable extends CSSProperties {
|
|
8
|
-
[X: CSSVariableName]: CSSVariableValue
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const cssVariableReg = /[A-Z]/
|
|
12
|
-
|
|
13
|
-
function addCSSVariableLine(match: string): string {
|
|
14
|
-
return `-${match}`
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function transformCSSVariableName(name: string): CSSVariableName {
|
|
18
|
-
return `--${name.replace(cssVariableReg, addCSSVariableLine).toLowerCase()}`
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function transformCSSVariable(style: Partial<Record<string, CSSVariableValue>>, style2?: CSSProperties): CSSProperties {
|
|
22
|
-
return Object.assign(
|
|
23
|
-
Object.entries(style).reduce((acc: StyleWithCSSVariable, [key, value]) => {
|
|
24
|
-
acc[transformCSSVariableName(key)] = value
|
|
25
|
-
return acc
|
|
26
|
-
}, {}),
|
|
27
|
-
style2
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function px(value: string | number | undefined): string | undefined {
|
|
32
|
-
return typeof value === "number" ? `${value}px` : value
|
|
33
|
-
}
|
|
1
|
+
import { CSSProperties } from "react"
|
|
2
|
+
|
|
3
|
+
export type CSSVariableName = `--${string}`
|
|
4
|
+
|
|
5
|
+
export type CSSVariableValue = string | number | undefined
|
|
6
|
+
|
|
7
|
+
export interface StyleWithCSSVariable extends CSSProperties {
|
|
8
|
+
[X: CSSVariableName]: CSSVariableValue
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const cssVariableReg = /[A-Z]/
|
|
12
|
+
|
|
13
|
+
function addCSSVariableLine(match: string): string {
|
|
14
|
+
return `-${match}`
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function transformCSSVariableName(name: string): CSSVariableName {
|
|
18
|
+
return `--${name.replace(cssVariableReg, addCSSVariableLine).toLowerCase()}`
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function transformCSSVariable(style: Partial<Record<string, CSSVariableValue>>, style2?: CSSProperties): CSSProperties {
|
|
22
|
+
return Object.assign(
|
|
23
|
+
Object.entries(style).reduce((acc: StyleWithCSSVariable, [key, value]) => {
|
|
24
|
+
acc[transformCSSVariableName(key)] = value
|
|
25
|
+
return acc
|
|
26
|
+
}, {}),
|
|
27
|
+
style2,
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function px(value: string | number | undefined): string | undefined {
|
|
32
|
+
return typeof value === "number" ? `${value}px` : value
|
|
33
|
+
}
|