deepsea-components 5.17.9 → 5.17.11
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/dist/components/DraggableGrid.d.ts +1 -1
- package/dist/components/Echart.d.ts +1 -1
- package/dist/components/InfiniteScroll.d.ts +1 -1
- package/dist/components/LoopSwiper.cjs +1 -8
- package/dist/components/LoopSwiper.js +1 -8
- package/dist/components/Scroll.d.ts +1 -1
- package/dist/components/ScrollMask.d.ts +1 -1
- package/dist/components/Unify.d.ts +1 -1
- package/package.json +9 -9
- package/src/components/AutoFit.tsx +21 -15
- package/src/components/AutoScroll.tsx +6 -1
- package/src/components/AutoSizeTextarea.tsx +4 -1
- package/src/components/CopyButton.tsx +1 -0
- package/src/components/DraggableGrid.tsx +17 -1
- package/src/components/Echart.tsx +6 -5
- package/src/components/Flow.tsx +2 -0
- package/src/components/FormLabel.tsx +1 -1
- package/src/components/HlsPlayer.tsx +4 -1
- package/src/components/IconFileType.tsx +1 -4
- package/src/components/InfiniteScroll.tsx +2 -1
- package/src/components/InputFile.tsx +8 -2
- package/src/components/InputFileButton.tsx +6 -2
- package/src/components/LoopSwiper.tsx +9 -13
- package/src/components/ReadSheet.tsx +2 -1
- package/src/components/Ring.tsx +1 -1
- package/src/components/Scroll.tsx +4 -2
- package/src/components/ScrollMask.tsx +2 -1
- package/src/components/SectionRing.tsx +3 -2
- package/src/components/Skeleton.tsx +2 -1
- package/src/components/Title.tsx +1 -0
- package/src/components/TransitionBox.tsx +2 -1
- package/src/components/TransitionNum.tsx +6 -4
- package/src/components/Trapezium.tsx +2 -1
- package/src/components/Unify.tsx +2 -1
- package/src/components/WriteSheet.tsx +3 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentProps, CSSProperties, Key, ReactNode } from "react";
|
|
2
2
|
import { DragMoveEvents } from "soda-hooks";
|
|
3
3
|
export type MustBeReactNode<T> = false extends (T extends ReactNode ? true : false) ? false : true;
|
|
4
4
|
export type MustBeReactKey<T> = false extends (T extends Key ? true : false) ? false : true;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentProps, FC, ReactNode, Ref } from "react";
|
|
2
|
-
import { AngleAxisComponentOption, AriaComponentOption, AxisPointerComponentOption, BarSeriesOption, BoxplotSeriesOption, BrushComponentOption, CalendarComponentOption, CandlestickSeriesOption, ChordSeriesOption, ComposeOption, ContinousVisualMapComponentOption, CustomSeriesOption,
|
|
2
|
+
import { AngleAxisComponentOption, AriaComponentOption, AxisPointerComponentOption, BarSeriesOption, BoxplotSeriesOption, BrushComponentOption, CalendarComponentOption, CandlestickSeriesOption, ChordSeriesOption, ComposeOption, ContinousVisualMapComponentOption, CustomSeriesOption, DatasetComponentOption, DataZoomComponentOption, ECharts, EChartsInitOpts, EffectScatterSeriesOption, FunnelSeriesOption, GaugeSeriesOption, GeoComponentOption, GraphicComponentOption, GraphSeriesOption, GridComponentOption, HeatmapSeriesOption, InsideDataZoomComponentOption, LegendComponentOption, LineSeriesOption, LinesSeriesOption, MapSeriesOption, MarkAreaComponentOption, MarkLineComponentOption, MarkPointComponentOption, MatrixComponentOption, ParallelSeriesOption, PictorialBarSeriesOption, PiecewiseVisualMapComponentOption, PieSeriesOption, PlainLegendComponentOption, PolarComponentOption, RadarComponentOption, RadarSeriesOption, RadiusAxisComponentOption, SankeySeriesOption, ScatterSeriesOption, ScrollableLegendComponentOption, SeriesOption, SingleAxisComponentOption, SliderDataZoomComponentOption, SunburstSeriesOption, ThemeRiverSeriesOption, ThumbnailComponentOption, TimelineComponentOption, TitleComponentOption, ToolboxComponentOption, TooltipComponentOption, TreemapSeriesOption, TreeSeriesOption, VisualMapComponentOption, XAXisComponentOption, YAXisComponentOption } from "echarts";
|
|
3
3
|
import { ECBasicOption } from "echarts/types/src/util/types.js";
|
|
4
4
|
export type ChartOption<T extends SeriesOption = never> = ComposeOption<T | DatasetComponentOption | GridComponentOption | LegendComponentOption | TitleComponentOption | TooltipComponentOption | AxisPointerComponentOption | GeoComponentOption | MarkLineComponentOption | MarkPointComponentOption | MarkAreaComponentOption | DataZoomComponentOption | AriaComponentOption | BrushComponentOption | PolarComponentOption | RadarComponentOption | XAXisComponentOption | YAXisComponentOption | MatrixComponentOption | GraphicComponentOption | ToolboxComponentOption | CalendarComponentOption | TimelineComponentOption | AngleAxisComponentOption | RadiusAxisComponentOption | SingleAxisComponentOption | VisualMapComponentOption | ThumbnailComponentOption | PlainLegendComponentOption | InsideDataZoomComponentOption | SliderDataZoomComponentOption | PiecewiseVisualMapComponentOption | ContinousVisualMapComponentOption | ScrollableLegendComponentOption>;
|
|
5
5
|
export type BarOption = ChartOption<BarSeriesOption>;
|
|
@@ -76,7 +76,6 @@ const LoopSwiper = ({ ref, className, classNames: { root: rootClassName, contain
|
|
|
76
76
|
transform: translateX(calc(-100% - ${gap}px));
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
|
|
80
79
|
@keyframes deepsea-reverse-horizontal-loop-swipe {
|
|
81
80
|
from {
|
|
82
81
|
transform: translateX(0);
|
|
@@ -85,7 +84,6 @@ const LoopSwiper = ({ ref, className, classNames: { root: rootClassName, contain
|
|
|
85
84
|
transform: translateX(calc(100% + ${gap}px));
|
|
86
85
|
}
|
|
87
86
|
}
|
|
88
|
-
|
|
89
87
|
@keyframes deepsea-vertical-loop-swipe {
|
|
90
88
|
from {
|
|
91
89
|
transform: translateY(0);
|
|
@@ -94,7 +92,6 @@ const LoopSwiper = ({ ref, className, classNames: { root: rootClassName, contain
|
|
|
94
92
|
transform: translateY(calc(-100% - ${gap}px));
|
|
95
93
|
}
|
|
96
94
|
}
|
|
97
|
-
|
|
98
95
|
@keyframes deepsea-reverse-vertical-loop-swipe {
|
|
99
96
|
from {
|
|
100
97
|
transform: translateY(0);
|
|
@@ -107,11 +104,7 @@ const LoopSwiper = ({ ref, className, classNames: { root: rootClassName, contain
|
|
|
107
104
|
display: flex;
|
|
108
105
|
flex-direction: ${flexDirection};
|
|
109
106
|
gap: ${gap}px;
|
|
110
|
-
${"vertical" === direction ? "overflow-y: hidden;" : "overflow-x: hidden;"}
|
|
111
|
-
|
|
112
|
-
${pauseOnHover ? `&:hover > * {
|
|
113
|
-
animation-play-state: paused;
|
|
114
|
-
}` : ""}
|
|
107
|
+
${"vertical" === direction ? "overflow-y: hidden;" : "overflow-x: hidden;"} ${pauseOnHover ? "&:hover > * { animation-play-state: paused; }" : ""}
|
|
115
108
|
`, className, rootClassName),
|
|
116
109
|
...rest,
|
|
117
110
|
children: [
|
|
@@ -48,7 +48,6 @@ const LoopSwiper = ({ ref, className, classNames: { root: rootClassName, contain
|
|
|
48
48
|
transform: translateX(calc(-100% - ${gap}px));
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
|
|
52
51
|
@keyframes deepsea-reverse-horizontal-loop-swipe {
|
|
53
52
|
from {
|
|
54
53
|
transform: translateX(0);
|
|
@@ -57,7 +56,6 @@ const LoopSwiper = ({ ref, className, classNames: { root: rootClassName, contain
|
|
|
57
56
|
transform: translateX(calc(100% + ${gap}px));
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
|
-
|
|
61
59
|
@keyframes deepsea-vertical-loop-swipe {
|
|
62
60
|
from {
|
|
63
61
|
transform: translateY(0);
|
|
@@ -66,7 +64,6 @@ const LoopSwiper = ({ ref, className, classNames: { root: rootClassName, contain
|
|
|
66
64
|
transform: translateY(calc(-100% - ${gap}px));
|
|
67
65
|
}
|
|
68
66
|
}
|
|
69
|
-
|
|
70
67
|
@keyframes deepsea-reverse-vertical-loop-swipe {
|
|
71
68
|
from {
|
|
72
69
|
transform: translateY(0);
|
|
@@ -79,11 +76,7 @@ const LoopSwiper = ({ ref, className, classNames: { root: rootClassName, contain
|
|
|
79
76
|
display: flex;
|
|
80
77
|
flex-direction: ${flexDirection};
|
|
81
78
|
gap: ${gap}px;
|
|
82
|
-
${"vertical" === direction ? "overflow-y: hidden;" : "overflow-x: hidden;"}
|
|
83
|
-
|
|
84
|
-
${pauseOnHover ? `&:hover > * {
|
|
85
|
-
animation-play-state: paused;
|
|
86
|
-
}` : ""}
|
|
79
|
+
${"vertical" === direction ? "overflow-y: hidden;" : "overflow-x: hidden;"} ${pauseOnHover ? "&:hover > * { animation-play-state: paused; }" : ""}
|
|
87
80
|
`, className, rootClassName),
|
|
88
81
|
...rest,
|
|
89
82
|
children: [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CSSProperties, ForwardedRef, HTMLAttributes } from "react";
|
|
2
2
|
import Scrollbar from "smooth-scrollbar";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ScrollbarOptions, ScrollListener } from "smooth-scrollbar/interfaces";
|
|
4
4
|
export { default as Scrollbar } from "smooth-scrollbar";
|
|
5
5
|
export * from "smooth-scrollbar/interfaces";
|
|
6
6
|
export interface ScrollOptions extends Partial<ScrollbarOptions> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentProps, CSSProperties, FC } from "react";
|
|
2
2
|
export type ScrollMaskPosition = "top" | "bottom" | "left" | "right";
|
|
3
3
|
export interface ScrollMaskProps extends Omit<ComponentProps<"div">, "children"> {
|
|
4
4
|
position?: ScrollMaskPosition;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentProps, CSSProperties, FC, JSX, JSXElementConstructor, ReactNode } from "react";
|
|
2
2
|
export interface UnifyConfig {
|
|
3
3
|
className?: string;
|
|
4
4
|
style?: CSSProperties;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deepsea-components",
|
|
3
|
-
"version": "5.17.
|
|
3
|
+
"version": "5.17.11",
|
|
4
4
|
"description": "格数科技自用组件库",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -41,18 +41,18 @@
|
|
|
41
41
|
"hls.js": "^1.6.13",
|
|
42
42
|
"smooth-scrollbar": "^8.8.4",
|
|
43
43
|
"stable-hash": "^0.0.6",
|
|
44
|
-
"soda-hooks": "6.
|
|
45
|
-
"deepsea-tools": "5.43.
|
|
44
|
+
"soda-hooks": "6.16.1",
|
|
45
|
+
"deepsea-tools": "5.43.2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"typescript": "
|
|
48
|
+
"typescript": ">=5.8.3"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@types/node": "
|
|
52
|
-
"@types/react": "
|
|
53
|
-
"@types/react-dom": ">=
|
|
54
|
-
"react": ">=
|
|
55
|
-
"react-dom": ">=
|
|
51
|
+
"@types/node": "^24.10.1",
|
|
52
|
+
"@types/react": "^19.2.7",
|
|
53
|
+
"@types/react-dom": ">=19.2.3",
|
|
54
|
+
"react": ">=19.2.1",
|
|
55
|
+
"react-dom": ">=19.2.1"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"dev": "rslib build --watch",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { forwardRef, HTMLAttributes, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from "react"
|
|
4
|
+
|
|
4
5
|
import { css } from "@emotion/css"
|
|
5
6
|
import { clsx } from "deepsea-tools"
|
|
6
7
|
|
|
@@ -39,33 +40,40 @@ export const AutoFit = forwardRef<HTMLDivElement, AutoFitProps>((props, ref) =>
|
|
|
39
40
|
const [height, setHeight] = useState<string | undefined>(undefined)
|
|
40
41
|
|
|
41
42
|
useImperativeHandle(ref, () => ele.current!, [ele.current])
|
|
43
|
+
|
|
42
44
|
useLayoutEffect(() => {
|
|
43
45
|
const element = ele.current
|
|
44
46
|
const parent = element?.parentElement
|
|
45
47
|
if (!element || !parent) return
|
|
48
|
+
|
|
46
49
|
function listener(entries: ResizeObserverEntry[]) {
|
|
47
50
|
const entry = entries[0]
|
|
48
51
|
const { contentRect } = entry
|
|
52
|
+
|
|
49
53
|
if (direction === "horizontal") {
|
|
50
54
|
const scale = contentRect.width / designWidth
|
|
51
55
|
setTransform(`scale(${scale})`)
|
|
52
56
|
setWidth(px(designWidth))
|
|
53
57
|
setHeight(px(contentRect.height / scale))
|
|
54
|
-
} else if (direction === "vertical") {
|
|
55
|
-
const scale = contentRect.height / designHeight
|
|
56
|
-
setTransform(`scale(${scale})`)
|
|
57
|
-
setWidth(px(contentRect.width / scale))
|
|
58
|
-
setHeight(px(designHeight))
|
|
59
58
|
} else {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
`
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
if (direction === "vertical") {
|
|
60
|
+
const scale = contentRect.height / designHeight
|
|
61
|
+
setTransform(`scale(${scale})`)
|
|
62
|
+
setWidth(px(contentRect.width / scale))
|
|
63
|
+
setHeight(px(designHeight))
|
|
64
|
+
} else {
|
|
65
|
+
const scale = Math.min(contentRect.width / designWidth, contentRect.height / designHeight)
|
|
66
|
+
setTransform(
|
|
67
|
+
`translateX(${(contentRect.width - designWidth * scale) / 2}px) translateY(${(contentRect.height - designHeight * scale) / 2}px) scale(${scale})`,
|
|
68
|
+
)
|
|
69
|
+
setWidth(px(designWidth))
|
|
70
|
+
setHeight(px(designHeight))
|
|
71
|
+
}
|
|
66
72
|
}
|
|
73
|
+
|
|
67
74
|
setShow(true)
|
|
68
75
|
}
|
|
76
|
+
|
|
69
77
|
const observer = new ResizeObserver(listener)
|
|
70
78
|
observer.observe(parent)
|
|
71
79
|
return () => observer.disconnect()
|
|
@@ -76,9 +84,7 @@ export const AutoFit = forwardRef<HTMLDivElement, AutoFitProps>((props, ref) =>
|
|
|
76
84
|
const parent = ele.current?.parentElement
|
|
77
85
|
if (!parent) return
|
|
78
86
|
const style = getComputedStyle(parent)
|
|
79
|
-
if (style.position === "static")
|
|
80
|
-
console.warn("AutoFit 组件的父元素的 position 属性不应该是 static")
|
|
81
|
-
}
|
|
87
|
+
if (style.position === "static") console.warn("AutoFit 组件的父元素的 position 属性不应该是 static")
|
|
82
88
|
}, [ele.current?.parentElement])
|
|
83
89
|
}
|
|
84
90
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { CSSProperties, MouseEvent as ReactMouseEvent,
|
|
3
|
+
import { CSSProperties, forwardRef, MouseEvent as ReactMouseEvent, useEffect, useImperativeHandle, useRef } from "react"
|
|
4
|
+
|
|
4
5
|
import { css } from "@emotion/css"
|
|
5
6
|
import { clsx, getArray } from "deepsea-tools"
|
|
6
7
|
import Scrollbar from "smooth-scrollbar"
|
|
@@ -93,6 +94,7 @@ export const AutoScroll = forwardRef<HTMLDivElement, AutoScrollProps>((props, re
|
|
|
93
94
|
const range = getArray(count, index => (itemHeight + gap) * (index + 1) - (index === count - 1 ? gap : 0))
|
|
94
95
|
const scrollHeight = range[range.length - 1]
|
|
95
96
|
if (height >= scrollHeight) return
|
|
97
|
+
|
|
96
98
|
function scroll(target: number) {
|
|
97
99
|
clearTimeout(timeout.current)
|
|
98
100
|
timeout.current = setTimeout(() => {
|
|
@@ -100,13 +102,16 @@ export const AutoScroll = forwardRef<HTMLDivElement, AutoScrollProps>((props, re
|
|
|
100
102
|
bar.current?.scrollTo(0, target, animation)
|
|
101
103
|
}, duration)
|
|
102
104
|
}
|
|
105
|
+
|
|
103
106
|
scroll(range[0])
|
|
107
|
+
|
|
104
108
|
function listener(status: ScrollStatus) {
|
|
105
109
|
const { y } = status.offset
|
|
106
110
|
const scrollToBottom = Math.abs(y + height - scrollHeight) / itemHeight <= 0.05
|
|
107
111
|
const target = scrollToBottom ? 0 : range.find(item => item > y)!
|
|
108
112
|
scroll(target)
|
|
109
113
|
}
|
|
114
|
+
|
|
110
115
|
bar.current?.addListener(listener)
|
|
111
116
|
return () => {
|
|
112
117
|
clearTimeout(timeout.current)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { forwardRef, TextareaHTMLAttributes, useImperativeHandle, useLayoutEffect, useRef, useState } from "react"
|
|
4
|
+
|
|
4
5
|
import { css } from "@emotion/css"
|
|
5
6
|
import { clsx } from "deepsea-tools"
|
|
6
7
|
|
|
@@ -18,10 +19,12 @@ export const AutoSizeTextArea = forwardRef<HTMLTextAreaElement, TextareaHTMLAttr
|
|
|
18
19
|
|
|
19
20
|
useLayoutEffect(() => {
|
|
20
21
|
const textarea = ele.current!
|
|
22
|
+
|
|
21
23
|
function resizeTextarea() {
|
|
22
24
|
setHeight("auto")
|
|
23
25
|
setHeight(px(textarea.scrollHeight + textarea.offsetHeight - textarea.clientHeight))
|
|
24
26
|
}
|
|
27
|
+
|
|
25
28
|
resizeTextarea()
|
|
26
29
|
textarea.addEventListener("input", resizeTextarea)
|
|
27
30
|
textarea.addEventListener("change", resizeTextarea)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentProps, CSSProperties, Key, ReactNode, useEffect, useMemo, useRef, useState } from "react"
|
|
2
|
+
|
|
2
3
|
import { clsx, getArray, isNullable } from "deepsea-tools"
|
|
3
4
|
import { DragMoveEvent, DragMoveEvents, useDragMove } from "soda-hooks"
|
|
4
5
|
|
|
@@ -41,9 +42,11 @@ export type DraggableGridOrderToKey<K extends Key> = Map<number, K>
|
|
|
41
42
|
|
|
42
43
|
function isTheSameArray<T>(a: T[], b: T[]) {
|
|
43
44
|
if (a.length !== b.length) return false
|
|
45
|
+
|
|
44
46
|
for (let i = 0; i < a.length; i++) {
|
|
45
47
|
if (a[i] !== b[i]) return false
|
|
46
48
|
}
|
|
49
|
+
|
|
47
50
|
return true
|
|
48
51
|
}
|
|
49
52
|
|
|
@@ -69,10 +72,13 @@ function getOrderMap<K extends Key>({ prev, orders, keys, orderPriority }: GetOr
|
|
|
69
72
|
if (!!prev) {
|
|
70
73
|
const entries = Array.from(prev.entries()).toSorted((a, b) => (orderPriority ? orderPriority(b[1], a[1]) : b[1] - a[1]))
|
|
71
74
|
const newPrev = new Map<K, number>()
|
|
75
|
+
|
|
72
76
|
const newOrders = [...orders]
|
|
77
|
+
|
|
73
78
|
for (const [key, order] of entries) {
|
|
74
79
|
if (!keys.includes(key)) continue
|
|
75
80
|
const index = newOrders.indexOf(order)
|
|
81
|
+
|
|
76
82
|
if (index >= 0) {
|
|
77
83
|
newPrev.set(key, order)
|
|
78
84
|
newOrders.length = index
|
|
@@ -81,19 +87,23 @@ function getOrderMap<K extends Key>({ prev, orders, keys, orderPriority }: GetOr
|
|
|
81
87
|
newPrev.set(key, newOrder)
|
|
82
88
|
}
|
|
83
89
|
}
|
|
90
|
+
|
|
84
91
|
prev = newPrev
|
|
85
92
|
}
|
|
86
93
|
|
|
87
94
|
const newKeys = keys.filter(key => {
|
|
88
95
|
if (!prev) return true
|
|
96
|
+
|
|
89
97
|
if (prev.has(key)) {
|
|
90
98
|
const prevOrder = prev.get(key)!
|
|
91
99
|
orderMap.set(key, prevOrder)
|
|
92
100
|
orderSet.delete(prevOrder)
|
|
93
101
|
return false
|
|
94
102
|
}
|
|
103
|
+
|
|
95
104
|
return true
|
|
96
105
|
})
|
|
106
|
+
|
|
97
107
|
orders = Array.from(orderSet)
|
|
98
108
|
newKeys.forEach((key, index) => orderMap.set(key, orders[index]))
|
|
99
109
|
return orderMap
|
|
@@ -290,10 +300,12 @@ export function DraggableGrid<T, K extends Key = T extends Key ? T : never>({
|
|
|
290
300
|
}: DraggableGridProps<T, K>) {
|
|
291
301
|
const keyToItem = useMemo(() => {
|
|
292
302
|
const keyToItem = new Map<K, T>()
|
|
303
|
+
|
|
293
304
|
items.forEach(item => {
|
|
294
305
|
const key = keyExtractor ? keyExtractor(item) : (item as unknown as K)
|
|
295
306
|
keyToItem.set(key, item)
|
|
296
307
|
})
|
|
308
|
+
|
|
297
309
|
return keyToItem
|
|
298
310
|
}, [items, keyExtractor])
|
|
299
311
|
|
|
@@ -358,6 +370,7 @@ export function DraggableGrid<T, K extends Key = T extends Key ? T : never>({
|
|
|
358
370
|
!isTheSameIterable(dragging.keyToOrder.keys(), keyToItem.keys()))
|
|
359
371
|
) {
|
|
360
372
|
setDragging(undefined)
|
|
373
|
+
|
|
361
374
|
if (isTheSameArray(dragging.orders, orders) && isTheSameIterable(dragging.keyToOrder.keys(), keyToItem.keys())) {
|
|
362
375
|
setKeyToOrder(dragging.keyToOrder)
|
|
363
376
|
onOrderMapChange?.(dragging.keyToOrder)
|
|
@@ -368,6 +381,7 @@ export function DraggableGrid<T, K extends Key = T extends Key ? T : never>({
|
|
|
368
381
|
/** 受控 */
|
|
369
382
|
useEffect(() => {
|
|
370
383
|
if (orderMap === keyToOrder) return
|
|
384
|
+
|
|
371
385
|
if (!!orderMap && isLegalOrderMap({ orders, keys: keyToItem.keys(), orderMap })) setKeyToOrder(orderMap)
|
|
372
386
|
else onOrderMapChange?.(keyToOrder)
|
|
373
387
|
}, [orderMap, keyToOrder, onOrderMapChange])
|
|
@@ -376,6 +390,7 @@ export function DraggableGrid<T, K extends Key = T extends Key ? T : never>({
|
|
|
376
390
|
_onDragMoveStart?.(event)
|
|
377
391
|
const position = getPosition({ order: keyToOrder.get(key)!, columns, gapX, gapY, itemWidth, itemHeight })
|
|
378
392
|
recent.current = key
|
|
393
|
+
|
|
379
394
|
setDragging({
|
|
380
395
|
key,
|
|
381
396
|
startX: position.x,
|
|
@@ -426,6 +441,7 @@ export function DraggableGrid<T, K extends Key = T extends Key ? T : never>({
|
|
|
426
441
|
|
|
427
442
|
/** 以元素开始移动前的次序为基准,计算元素当前最近的位置 */
|
|
428
443
|
const newKeyToOrder = new Map(keyToOrder)
|
|
444
|
+
|
|
429
445
|
newKeyToOrder.set(key, nearestOrder)
|
|
430
446
|
|
|
431
447
|
const orderToKey = getOrderToKey(keyToOrder)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { ComponentProps, FC, ReactNode, Ref, useEffect, useImperativeHandle, useLayoutEffect, useRef } from "react"
|
|
4
|
+
|
|
4
5
|
import {
|
|
5
6
|
AngleAxisComponentOption,
|
|
6
7
|
AriaComponentOption,
|
|
@@ -14,18 +15,19 @@ import {
|
|
|
14
15
|
ComposeOption,
|
|
15
16
|
ContinousVisualMapComponentOption,
|
|
16
17
|
CustomSeriesOption,
|
|
17
|
-
DataZoomComponentOption,
|
|
18
18
|
DatasetComponentOption,
|
|
19
|
+
DataZoomComponentOption,
|
|
19
20
|
ECharts,
|
|
20
21
|
EChartsInitOpts,
|
|
21
22
|
EffectScatterSeriesOption,
|
|
22
23
|
FunnelSeriesOption,
|
|
23
24
|
GaugeSeriesOption,
|
|
24
25
|
GeoComponentOption,
|
|
25
|
-
GraphSeriesOption,
|
|
26
26
|
GraphicComponentOption,
|
|
27
|
+
GraphSeriesOption,
|
|
27
28
|
GridComponentOption,
|
|
28
29
|
HeatmapSeriesOption,
|
|
30
|
+
init,
|
|
29
31
|
InsideDataZoomComponentOption,
|
|
30
32
|
LegendComponentOption,
|
|
31
33
|
LineSeriesOption,
|
|
@@ -37,8 +39,8 @@ import {
|
|
|
37
39
|
MatrixComponentOption,
|
|
38
40
|
ParallelSeriesOption,
|
|
39
41
|
PictorialBarSeriesOption,
|
|
40
|
-
PieSeriesOption,
|
|
41
42
|
PiecewiseVisualMapComponentOption,
|
|
43
|
+
PieSeriesOption,
|
|
42
44
|
PlainLegendComponentOption,
|
|
43
45
|
PolarComponentOption,
|
|
44
46
|
RadarComponentOption,
|
|
@@ -57,12 +59,11 @@ import {
|
|
|
57
59
|
TitleComponentOption,
|
|
58
60
|
ToolboxComponentOption,
|
|
59
61
|
TooltipComponentOption,
|
|
60
|
-
TreeSeriesOption,
|
|
61
62
|
TreemapSeriesOption,
|
|
63
|
+
TreeSeriesOption,
|
|
62
64
|
VisualMapComponentOption,
|
|
63
65
|
XAXisComponentOption,
|
|
64
66
|
YAXisComponentOption,
|
|
65
|
-
init,
|
|
66
67
|
} from "echarts"
|
|
67
68
|
import { ECBasicOption } from "echarts/types/src/util/types.js"
|
|
68
69
|
import hash from "stable-hash"
|
package/src/components/Flow.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import { CSSProperties, HTMLAttributes, Key, ReactNode, Ref, useEffect, useImperativeHandle, useRef, useState } from "react"
|
|
4
|
+
|
|
4
5
|
import { css } from "@emotion/css"
|
|
5
6
|
import { clsx } from "deepsea-tools"
|
|
6
7
|
import { useSize } from "soda-hooks"
|
|
@@ -159,6 +160,7 @@ export function ManualFlow<T>(props: ManualFlowProps<T>) {
|
|
|
159
160
|
function task() {
|
|
160
161
|
setGapAndCount(getGapCountAndSize(width, itemWidth, minColumnGap, maxColumnGap))
|
|
161
162
|
}
|
|
163
|
+
|
|
162
164
|
if (throttle === 0) return task()
|
|
163
165
|
const timeout = setTimeout(task, throttle || 200)
|
|
164
166
|
return () => clearTimeout(timeout)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { forwardRef, MediaHTMLAttributes, useEffect, useImperativeHandle, useRef } from "react"
|
|
4
|
+
|
|
4
5
|
import Hls from "hls.js"
|
|
5
6
|
|
|
6
7
|
export interface HlsPlayerProps extends Omit<MediaHTMLAttributes<HTMLVideoElement>, "src"> {
|
|
@@ -16,10 +17,12 @@ export const HlsPlayer = forwardRef<HTMLVideoElement, HlsPlayerProps>((props, re
|
|
|
16
17
|
useEffect(() => {
|
|
17
18
|
const { current: player } = video
|
|
18
19
|
if (!player || !src) return
|
|
20
|
+
|
|
19
21
|
if (player.canPlayType("application/vnd.apple.mpegurl")) {
|
|
20
22
|
player.src = src
|
|
21
23
|
return
|
|
22
24
|
}
|
|
25
|
+
|
|
23
26
|
if (Hls.isSupported()) {
|
|
24
27
|
const hls = new Hls()
|
|
25
28
|
hls.loadSource(src)
|
|
@@ -125,10 +125,7 @@ export const IconFileTypeText: FC<IconFileTypeTextProps> = ({
|
|
|
125
125
|
)
|
|
126
126
|
|
|
127
127
|
export interface IconFileTypeProps
|
|
128
|
-
extends IconFileTypePagePropsBase,
|
|
129
|
-
Omit<IconFileTypeDogEarPropsBase, "pageWidth">,
|
|
130
|
-
IconFileTypeTextPropsBase,
|
|
131
|
-
ComponentProps<"svg"> {}
|
|
128
|
+
extends IconFileTypePagePropsBase, Omit<IconFileTypeDogEarPropsBase, "pageWidth">, IconFileTypeTextPropsBase, ComponentProps<"svg"> {}
|
|
132
129
|
|
|
133
130
|
export const IconFileType: FC<IconFileTypeProps> = ({
|
|
134
131
|
pageColor,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { CSSProperties,
|
|
3
|
+
import { ComponentPropsWithoutRef, CSSProperties, forwardRef, MouseEvent as ReactMouseEvent, useEffect, useImperativeHandle, useRef } from "react"
|
|
4
|
+
|
|
4
5
|
import { css } from "@emotion/css"
|
|
5
6
|
import { clsx } from "deepsea-tools"
|
|
6
7
|
import { useSize } from "soda-hooks"
|
|
@@ -14,6 +14,7 @@ export type InputFileDataType = keyof InputFileDataTypeMap
|
|
|
14
14
|
|
|
15
15
|
export async function getFileData<T extends InputFileDataType>(file: File, type: T): Promise<InputFileDataTypeMap[T]> {
|
|
16
16
|
const fileReader = new FileReader()
|
|
17
|
+
|
|
17
18
|
switch (type) {
|
|
18
19
|
case "arrayBuffer":
|
|
19
20
|
fileReader.readAsArrayBuffer(file)
|
|
@@ -30,6 +31,7 @@ export async function getFileData<T extends InputFileDataType>(file: File, type:
|
|
|
30
31
|
default:
|
|
31
32
|
return file as any
|
|
32
33
|
}
|
|
34
|
+
|
|
33
35
|
return new Promise(resolve => {
|
|
34
36
|
fileReader.addEventListener("load", () => {
|
|
35
37
|
resolve(fileReader.result as any)
|
|
@@ -40,6 +42,7 @@ export async function getFileData<T extends InputFileDataType>(file: File, type:
|
|
|
40
42
|
export interface InputFileBaseProps extends Omit<ComponentProps<"input">, "multiple" | "type"> {}
|
|
41
43
|
|
|
42
44
|
export type FileType<Multiple extends boolean> = Multiple extends true ? File[] : File
|
|
45
|
+
|
|
43
46
|
export type ValueType<Multiple extends boolean, Type extends InputFileDataType> = Multiple extends true
|
|
44
47
|
? InputFileDataTypeMap[Type][]
|
|
45
48
|
: InputFileDataTypeMap[Type]
|
|
@@ -62,8 +65,7 @@ export interface InputFileExtraProps<Multiple extends boolean = false, Type exte
|
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
export interface InputFileProps<Multiple extends boolean = false, Type extends InputFileDataType = "file">
|
|
65
|
-
extends InputFileBaseProps,
|
|
66
|
-
InputFileExtraProps<Multiple, Type> {}
|
|
68
|
+
extends InputFileBaseProps, InputFileExtraProps<Multiple, Type> {}
|
|
67
69
|
|
|
68
70
|
/** 专用于读取文件的组件 */
|
|
69
71
|
export function InputFile<Multiple extends boolean = false, Type extends InputFileDataType = "file">(props: InputFileProps<Multiple, Type>): ReactNode {
|
|
@@ -86,14 +88,18 @@ export function InputFile<Multiple extends boolean = false, Type extends InputFi
|
|
|
86
88
|
const { files } = input
|
|
87
89
|
if (!files || files.length === 0) return
|
|
88
90
|
setDisabled(true)
|
|
91
|
+
|
|
89
92
|
try {
|
|
90
93
|
if (multiple) {
|
|
91
94
|
const files2: File[] = Array.from(files)
|
|
95
|
+
|
|
92
96
|
const values: InputFileDataTypeMap[Type][] = []
|
|
97
|
+
|
|
93
98
|
for (const file of files2) {
|
|
94
99
|
const value = (await getFileData(file, type)) as InputFileDataTypeMap[Type]
|
|
95
100
|
values.push(value)
|
|
96
101
|
}
|
|
102
|
+
|
|
97
103
|
onFileChange?.(files2 as FileType<Multiple>)
|
|
98
104
|
onValueChange?.(values as ValueType<Multiple, Type>)
|
|
99
105
|
onDataChange?.(files2.map((file, index) => ({ file, value: values[index] })) as DataType<Multiple, Type>)
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
import {
|
|
4
4
|
ComponentProps,
|
|
5
5
|
ComponentRef,
|
|
6
|
+
createElement,
|
|
6
7
|
DragEvent,
|
|
7
8
|
Fragment,
|
|
8
9
|
JSX,
|
|
9
10
|
JSXElementConstructor,
|
|
10
11
|
MouseEvent as ReactMouseEvent,
|
|
11
|
-
createElement,
|
|
12
12
|
useImperativeHandle,
|
|
13
13
|
useRef,
|
|
14
14
|
useState,
|
|
@@ -17,13 +17,13 @@ import {
|
|
|
17
17
|
import {
|
|
18
18
|
DataType,
|
|
19
19
|
FileType,
|
|
20
|
+
getFileData,
|
|
20
21
|
InputFile,
|
|
21
22
|
InputFileBaseProps,
|
|
22
23
|
InputFileDataType,
|
|
23
24
|
InputFileDataTypeMap,
|
|
24
25
|
InputFileExtraProps,
|
|
25
26
|
ValueType,
|
|
26
|
-
getFileData,
|
|
27
27
|
} from "./InputFile"
|
|
28
28
|
|
|
29
29
|
export type InputFileButtonProps<
|
|
@@ -81,14 +81,18 @@ export function InputFileButton<
|
|
|
81
81
|
const { files } = e.dataTransfer
|
|
82
82
|
if (!files || files.length === 0) return
|
|
83
83
|
setDisabled(true)
|
|
84
|
+
|
|
84
85
|
try {
|
|
85
86
|
if (multiple) {
|
|
86
87
|
const files2: File[] = Array.from(files)
|
|
88
|
+
|
|
87
89
|
const values: InputFileDataTypeMap[Type][] = []
|
|
90
|
+
|
|
88
91
|
for (const file of files2) {
|
|
89
92
|
const value = (await getFileData(file, type)) as InputFileDataTypeMap[Type]
|
|
90
93
|
values.push(value)
|
|
91
94
|
}
|
|
95
|
+
|
|
92
96
|
onFileChange?.(files2 as FileType<Multiple>)
|
|
93
97
|
onValueChange?.(values as ValueType<Multiple, Type>)
|
|
94
98
|
onDataChange?.(files2.map((file, index) => ({ file, value: values[index] })) as DataType<Multiple, Type>)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { ComponentProps, CSSProperties, FC, useEffect, useImperativeHandle, useRef, useState } from "react"
|
|
4
|
+
|
|
4
5
|
import { css } from "@emotion/css"
|
|
5
6
|
import { clsx } from "deepsea-tools"
|
|
6
7
|
|
|
@@ -66,9 +67,11 @@ export const LoopSwiper: FC<LoopSwiperProps> = ({
|
|
|
66
67
|
if (entry.target === wrapperEle) {
|
|
67
68
|
wrapperWidth = entry.contentRect.width
|
|
68
69
|
wrapperHeight = entry.contentRect.height
|
|
69
|
-
} else
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
} else {
|
|
71
|
+
if (entry.target === containerEle) {
|
|
72
|
+
containerWidth = entry.contentRect.width
|
|
73
|
+
containerHeight = entry.contentRect.height
|
|
74
|
+
}
|
|
72
75
|
}
|
|
73
76
|
})
|
|
74
77
|
|
|
@@ -92,7 +95,6 @@ export const LoopSwiper: FC<LoopSwiperProps> = ({
|
|
|
92
95
|
transform: translateX(calc(-100% - ${gap}px));
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
|
-
|
|
96
98
|
@keyframes deepsea-reverse-horizontal-loop-swipe {
|
|
97
99
|
from {
|
|
98
100
|
transform: translateX(0);
|
|
@@ -101,7 +103,6 @@ export const LoopSwiper: FC<LoopSwiperProps> = ({
|
|
|
101
103
|
transform: translateX(calc(100% + ${gap}px));
|
|
102
104
|
}
|
|
103
105
|
}
|
|
104
|
-
|
|
105
106
|
@keyframes deepsea-vertical-loop-swipe {
|
|
106
107
|
from {
|
|
107
108
|
transform: translateY(0);
|
|
@@ -110,7 +111,6 @@ export const LoopSwiper: FC<LoopSwiperProps> = ({
|
|
|
110
111
|
transform: translateY(calc(-100% - ${gap}px));
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
|
-
|
|
114
114
|
@keyframes deepsea-reverse-vertical-loop-swipe {
|
|
115
115
|
from {
|
|
116
116
|
transform: translateY(0);
|
|
@@ -124,12 +124,8 @@ export const LoopSwiper: FC<LoopSwiperProps> = ({
|
|
|
124
124
|
display: flex;
|
|
125
125
|
flex-direction: ${flexDirection};
|
|
126
126
|
gap: ${gap}px;
|
|
127
|
-
${direction === "vertical" ? "overflow-y: hidden;" : "overflow-x: hidden;"}
|
|
128
|
-
|
|
129
|
-
${pauseOnHover
|
|
130
|
-
? `&:hover > * {
|
|
131
|
-
animation-play-state: paused;
|
|
132
|
-
}`
|
|
127
|
+
${direction === "vertical" ? "overflow-y: hidden;" : "overflow-x: hidden;"} ${pauseOnHover
|
|
128
|
+
? `&:hover > * { animation-play-state: paused; }`
|
|
133
129
|
: ""}
|
|
134
130
|
`,
|
|
135
131
|
className,
|
package/src/components/Ring.tsx
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { CSSProperties, ForwardedRef,
|
|
3
|
+
import { CSSProperties, ForwardedRef, forwardRef, HTMLAttributes, useEffect, useImperativeHandle, useLayoutEffect, useRef } from "react"
|
|
4
|
+
|
|
4
5
|
import { css } from "@emotion/css"
|
|
5
6
|
import { clsx } from "deepsea-tools"
|
|
6
7
|
import Scrollbar from "smooth-scrollbar"
|
|
7
|
-
import type {
|
|
8
|
+
import type { ScrollbarOptions, ScrollListener } from "smooth-scrollbar/interfaces"
|
|
8
9
|
|
|
9
10
|
import { px, transformCSSVariable } from "@/utils"
|
|
10
11
|
|
|
11
12
|
export { default as Scrollbar } from "smooth-scrollbar"
|
|
13
|
+
|
|
12
14
|
export * from "smooth-scrollbar/interfaces"
|
|
13
15
|
|
|
14
16
|
export interface ScrollOptions extends Partial<ScrollbarOptions> {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { forwardRef, HTMLAttributes } from "react"
|
|
4
|
+
|
|
5
|
+
import { drawArc, DrawArcOptions } from "deepsea-tools"
|
|
5
6
|
|
|
6
7
|
export interface SectionRingProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
8
|
outerRadius: number
|
package/src/components/Title.tsx
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { ComponentProps, FC, useImperativeHandle, useLayoutEffect, useRef } from "react"
|
|
4
4
|
import { createPortal } from "react-dom"
|
|
5
5
|
import { renderToString } from "react-dom/server"
|
|
6
|
+
|
|
6
7
|
import { isBrowser } from "deepsea-tools"
|
|
7
8
|
|
|
8
9
|
import { getReactVersion } from "@/utils/getReactVersion"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { CSSProperties, FC,
|
|
3
|
+
import { CSSProperties, FC, forwardRef, HTMLAttributes, useEffect, useRef, useState } from "react"
|
|
4
|
+
|
|
4
5
|
import { useSize } from "soda-hooks"
|
|
5
6
|
|
|
6
7
|
export interface TransitionBoxProps extends HTMLAttributes<HTMLDivElement> {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { ForwardedRef,
|
|
3
|
+
import { ForwardedRef, forwardRef, HTMLAttributes, useEffect, useImperativeHandle, useRef } from "react"
|
|
4
|
+
|
|
4
5
|
import { setFrameInterval } from "deepsea-tools"
|
|
5
6
|
|
|
6
7
|
export interface TransitionNumProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
|
@@ -21,9 +22,7 @@ export interface TransitionNumIns {
|
|
|
21
22
|
/** 渐变数字组件 */
|
|
22
23
|
export const TransitionNum = forwardRef<HTMLDivElement, TransitionNumProps>((props, ref) => {
|
|
23
24
|
const { children: num, period, numToStr, ins, ...rest } = props
|
|
24
|
-
if (!Number.isInteger(num) || !Number.isInteger(period) || period <= 0)
|
|
25
|
-
throw new RangeError("目标数字必须是整数,周期必须是正整数")
|
|
26
|
-
}
|
|
25
|
+
if (!Number.isInteger(num) || !Number.isInteger(period) || period <= 0) throw new RangeError("目标数字必须是整数,周期必须是正整数")
|
|
27
26
|
const ele = useRef<HTMLDivElement>(null)
|
|
28
27
|
const cache = useRef({ num, period, numToStr, show: num })
|
|
29
28
|
cache.current = { ...cache.current, num, period, numToStr }
|
|
@@ -37,13 +36,16 @@ export const TransitionNum = forwardRef<HTMLDivElement, TransitionNumProps>((pro
|
|
|
37
36
|
if (num === show) return
|
|
38
37
|
const div = ele.current!
|
|
39
38
|
const speed = (num - show) / period
|
|
39
|
+
|
|
40
40
|
const cancel = setFrameInterval(() => {
|
|
41
41
|
const { num, numToStr } = cache.current
|
|
42
42
|
cache.current.show += speed
|
|
43
|
+
|
|
43
44
|
if ((speed > 0 && cache.current.show > num) || (speed < 0 && cache.current.show < num)) {
|
|
44
45
|
cancel()
|
|
45
46
|
cache.current.show = num
|
|
46
47
|
}
|
|
48
|
+
|
|
47
49
|
div.innerText = (numToStr || String)(speed > 0 ? Math.floor(cache.current.show) : Math.ceil(cache.current.show))
|
|
48
50
|
}, 1)
|
|
49
51
|
|
package/src/components/Unify.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { ComponentProps, createContext, createElement, CSSProperties, FC, JSX, JSXElementConstructor, ReactNode, useContext } from "react"
|
|
4
|
+
|
|
4
5
|
import { clsx } from "deepsea-tools"
|
|
5
6
|
|
|
6
7
|
export interface UnifyConfig {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import { ComponentProps, JSX, JSXElementConstructor, MouseEvent as ReactMouseEvent
|
|
4
|
-
|
|
3
|
+
import { ComponentProps, createElement, JSX, JSXElementConstructor, MouseEvent as ReactMouseEvent } from "react"
|
|
4
|
+
|
|
5
|
+
import { writeSheet, WriteSheetParams } from "deepsea-tools"
|
|
5
6
|
|
|
6
7
|
export type WriteSheetProps<AS extends keyof JSX.IntrinsicElements | JSXElementConstructor<any> = "button"> = Omit<ComponentProps<AS>, "as" | "excel"> & {
|
|
7
8
|
as?: AS
|