deepsea-components 5.18.3 → 5.18.5
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/AutoFit.cjs +4 -4
- package/dist/components/AutoFit.js +1 -1
- package/dist/components/AutoScroll.cjs +4 -4
- package/dist/components/AutoScroll.js +1 -1
- package/dist/components/AutoSizeTextarea.cjs +4 -4
- package/dist/components/AutoSizeTextarea.js +1 -1
- package/dist/components/CircleText.cjs +4 -4
- package/dist/components/CircleText.js +1 -1
- package/dist/components/CopyButton.cjs +4 -4
- package/dist/components/CopyButton.js +1 -1
- package/dist/components/DraggableGrid.cjs +3 -3
- package/dist/components/DraggableGrid.module.cjs +3 -3
- package/dist/components/DraggableGrid.module.js +1 -1
- package/dist/components/Echart.cjs +20 -20
- package/dist/components/Echart.js +1 -1
- package/dist/components/Flow.cjs +7 -7
- package/dist/components/Flow.js +1 -1
- package/dist/components/FormLabel.cjs +6 -6
- package/dist/components/FormLabel.js +1 -1
- package/dist/components/HlsPlayer.cjs +4 -4
- package/dist/components/HlsPlayer.js +1 -1
- package/dist/components/IconFileType.cjs +6 -6
- package/dist/components/InfiniteScroll.cjs +4 -4
- package/dist/components/InfiniteScroll.js +1 -1
- package/dist/components/InputFile.cjs +33 -22
- package/dist/components/InputFile.js +30 -19
- package/dist/components/InputFileButton.cjs +12 -9
- package/dist/components/InputFileButton.js +9 -6
- package/dist/components/LoopSwiper.cjs +4 -4
- package/dist/components/LoopSwiper.js +1 -1
- package/dist/components/ReadExcel.cjs +4 -4
- package/dist/components/ReadExcel.js +1 -1
- package/dist/components/ReadSheet.cjs +4 -4
- package/dist/components/ReadSheet.js +1 -1
- package/dist/components/Ring.cjs +4 -4
- package/dist/components/Ring.js +1 -1
- package/dist/components/RtspPlayer.cjs +5 -5
- package/dist/components/RtspPlayer.js +2 -2
- package/dist/components/Scroll.cjs +38 -40
- package/dist/components/Scroll.js +1 -1
- package/dist/components/ScrollMask.cjs +3 -3
- package/dist/components/ScrollMask.module.cjs +3 -3
- package/dist/components/ScrollMask.module.js +1 -1
- package/dist/components/ScrollMask_module.css +3 -1
- package/dist/components/SectionRing.cjs +4 -4
- package/dist/components/SectionRing.js +1 -1
- package/dist/components/Skeleton.cjs +4 -4
- package/dist/components/Skeleton.js +1 -1
- package/dist/components/Title.cjs +4 -4
- package/dist/components/Title.js +1 -1
- package/dist/components/TransitionBox.cjs +4 -4
- package/dist/components/TransitionBox.js +1 -1
- package/dist/components/TransitionNum.cjs +4 -4
- package/dist/components/TransitionNum.js +1 -1
- package/dist/components/Trapezium.cjs +4 -4
- package/dist/components/Trapezium.js +1 -1
- package/dist/components/Unify.cjs +4 -4
- package/dist/components/Unify.js +1 -1
- package/dist/components/WriteExcel.cjs +4 -4
- package/dist/components/WriteExcel.js +1 -1
- package/dist/components/WriteSheet.cjs +4 -4
- package/dist/components/WriteSheet.js +1 -1
- package/dist/components/rtspPlayer/reader.cjs +3 -3
- package/dist/index.cjs +162 -226
- package/dist/utils/getReactVersion.cjs +3 -3
- package/dist/utils/index.cjs +3 -3
- package/package.json +4 -4
- package/src/components/AutoFit.tsx +2 -0
- package/src/components/AutoScroll.tsx +1 -0
- package/src/components/CopyButton.tsx +4 -0
- package/src/components/DraggableGrid.tsx +6 -0
- package/src/components/Echart.tsx +2 -0
- package/src/components/Flow.tsx +6 -0
- package/src/components/InfiniteScroll.tsx +5 -0
- package/src/components/InputFile.tsx +34 -19
- package/src/components/InputFileButton.tsx +13 -5
- package/src/components/LoopSwiper.tsx +1 -0
- package/src/components/Scroll.tsx +1 -0
- package/src/components/Title.tsx +3 -0
- package/src/components/Unify.tsx +2 -0
- package/src/components/WriteSheet.tsx +2 -0
- package/src/components/rtspPlayer/reader.ts +2 -0
- package/tsconfig.json +5 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
+
/* eslint-disable no-restricted-syntax */
|
|
4
|
+
|
|
3
5
|
import { ComponentPropsWithoutRef, forwardRef, useEffect, useImperativeHandle, useRef } from "react"
|
|
4
6
|
|
|
5
7
|
import ClipboardJS, { Event } from "clipboard"
|
|
@@ -19,6 +21,7 @@ export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>((props,
|
|
|
19
21
|
const onCopySuccess = useLatest(_onCoptSuccess)
|
|
20
22
|
const onCopyError = useLatest(_onCopyError)
|
|
21
23
|
|
|
24
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
22
25
|
useImperativeHandle(ref, () => ele.current!, [ele.current])
|
|
23
26
|
|
|
24
27
|
useEffect(() => {
|
|
@@ -26,6 +29,7 @@ export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>((props,
|
|
|
26
29
|
clipboard.on("success", event => onCopySuccess.current?.(event))
|
|
27
30
|
clipboard.on("error", event => onCopyError.current?.(event))
|
|
28
31
|
return () => clipboard.destroy()
|
|
32
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
33
|
}, [])
|
|
30
34
|
|
|
31
35
|
return <button ref={ele} {...rest} data-clipboard-text={text} />
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable no-restricted-syntax */
|
|
2
|
+
|
|
1
3
|
import { ComponentProps, CSSProperties, Key, ReactNode, useEffect, useMemo, useRef, useState } from "react"
|
|
2
4
|
|
|
3
5
|
import { clsx, getArray, isNullable } from "deepsea-tools"
|
|
@@ -347,8 +349,10 @@ export function DraggableGrid<T, K extends Key = T extends Key ? T : never>({
|
|
|
347
349
|
setKeyToOrder(newOrderMap)
|
|
348
350
|
onOrderMapChange?.(newOrderMap)
|
|
349
351
|
const newRenderKeys = new Set(newOrderMap.keys())
|
|
352
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
350
353
|
setRenderKeys(prev => prev.intersection(newRenderKeys).union(newRenderKeys.difference(prev)))
|
|
351
354
|
}
|
|
355
|
+
// eslint-disable-next-line react-hooks/refs
|
|
352
356
|
}, [dragging, cache, orders, keyToItem, keyToOrder, orderPriority, onOrderMapChange])
|
|
353
357
|
|
|
354
358
|
/** 渲染的元素的 key,不会随着 keyToOrder 的变化而变化 */
|
|
@@ -384,6 +388,7 @@ export function DraggableGrid<T, K extends Key = T extends Key ? T : never>({
|
|
|
384
388
|
|
|
385
389
|
if (!!orderMap && isLegalOrderMap({ orders, keys: keyToItem.keys(), orderMap })) setKeyToOrder(orderMap)
|
|
386
390
|
else onOrderMapChange?.(keyToOrder)
|
|
391
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
387
392
|
}, [orderMap, keyToOrder, onOrderMapChange])
|
|
388
393
|
|
|
389
394
|
function onDragMoveStart(key: K, event: DragMoveEvent<HTMLDivElement>) {
|
|
@@ -512,6 +517,7 @@ export function DraggableGrid<T, K extends Key = T extends Key ? T : never>({
|
|
|
512
517
|
}
|
|
513
518
|
{...rest}
|
|
514
519
|
>
|
|
520
|
+
{/* eslint-disable-next-line react-hooks/refs */}
|
|
515
521
|
{Array.from(renderKeys).map(key => {
|
|
516
522
|
if (!keyToItem.has(key)) return undefined
|
|
517
523
|
const item = keyToItem.get(key)!
|
|
@@ -180,12 +180,14 @@ export function Echart<T extends ECBasicOption = ECBasicOption>({
|
|
|
180
180
|
const ele = container.current!
|
|
181
181
|
chartRef.current = init(ele, option, { ...initOption, width, height, locale })
|
|
182
182
|
return () => chartRef.current?.dispose()
|
|
183
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
183
184
|
}, [])
|
|
184
185
|
|
|
185
186
|
useImperativeHandle(ref, () => container.current!)
|
|
186
187
|
|
|
187
188
|
useImperativeHandle(chart, () => chartRef.current!)
|
|
188
189
|
|
|
190
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
189
191
|
useEffect(() => chartRef.current?.setOption(option), [hash(option)])
|
|
190
192
|
|
|
191
193
|
// @ts-expect-error width and height can be string
|
package/src/components/Flow.tsx
CHANGED
|
@@ -154,6 +154,7 @@ export function ManualFlow<T>(props: ManualFlowProps<T>) {
|
|
|
154
154
|
return index >= maxRows * columnCount
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps, react-hooks/refs
|
|
157
158
|
useImperativeHandle(element, () => ele.current!, [ele.current])
|
|
158
159
|
|
|
159
160
|
useEffect(() => {
|
|
@@ -180,6 +181,7 @@ export function ManualFlow<T>(props: ManualFlowProps<T>) {
|
|
|
180
181
|
itemCount: data.length,
|
|
181
182
|
maxRows: maxRows ?? null,
|
|
182
183
|
})
|
|
184
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
183
185
|
}, [width, height, columnGapSize, columnCount, rowGap, contentShownRows, data.length, itemWidth, itemHeight, maxRows])
|
|
184
186
|
|
|
185
187
|
return (
|
|
@@ -266,8 +268,12 @@ export function Flow<T>(props: FlowProps<T>): ReactNode {
|
|
|
266
268
|
const ele = useRef<HTMLDivElement>(null)
|
|
267
269
|
const size = useSize(ele)
|
|
268
270
|
const width = useRef(size?.width || 0)
|
|
271
|
+
// eslint-disable-next-line react-hooks/refs
|
|
269
272
|
if (size && size.width !== 0) width.current = size.width
|
|
273
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps, react-hooks/refs
|
|
270
274
|
useImperativeHandle(element, () => ele.current!, [ele.current])
|
|
275
|
+
// eslint-disable-next-line react-hooks/refs
|
|
271
276
|
if (width.current === 0) return <div ref={ele} {...rest} />
|
|
277
|
+
// eslint-disable-next-line react-hooks/refs
|
|
272
278
|
return <ManualFlow element={ele} {...props} width={width.current} />
|
|
273
279
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
+
/* eslint-disable no-restricted-syntax */
|
|
4
|
+
|
|
3
5
|
import { ComponentPropsWithoutRef, CSSProperties, forwardRef, MouseEvent as ReactMouseEvent, useEffect, useImperativeHandle, useRef } from "react"
|
|
4
6
|
|
|
5
7
|
import { css } from "@emotion/css"
|
|
@@ -58,6 +60,7 @@ export const InfiniteScroll = forwardRef<HTMLDivElement, InfiniteScrollProps>((p
|
|
|
58
60
|
|
|
59
61
|
const ele = useRef<HTMLDivElement>(null)
|
|
60
62
|
|
|
63
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
64
|
useImperativeHandle(ref, () => wrapper.current as HTMLDivElement, [wrapper.current])
|
|
62
65
|
|
|
63
66
|
const container = useRef<HTMLDivElement>(null)
|
|
@@ -88,6 +91,7 @@ export const InfiniteScroll = forwardRef<HTMLDivElement, InfiniteScrollProps>((p
|
|
|
88
91
|
{ duration, iterations: Infinity },
|
|
89
92
|
)
|
|
90
93
|
return () => animation.current?.cancel()
|
|
94
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
95
|
}, [wrapperSize, containerSize, overflow, direction, duration])
|
|
92
96
|
|
|
93
97
|
function enter(e: ReactMouseEvent<HTMLDivElement, MouseEvent>) {
|
|
@@ -102,6 +106,7 @@ export const InfiniteScroll = forwardRef<HTMLDivElement, InfiniteScrollProps>((p
|
|
|
102
106
|
|
|
103
107
|
useEffect(() => {
|
|
104
108
|
if (!pauseOnHover && animation.current?.playState === "paused") animation.current?.play()
|
|
109
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
105
110
|
}, [animation.current, pauseOnHover])
|
|
106
111
|
|
|
107
112
|
return (
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
+
/* eslint-disable no-restricted-syntax */
|
|
4
|
+
|
|
3
5
|
import { ChangeEvent, ComponentProps, ReactNode, useState } from "react"
|
|
4
6
|
|
|
5
7
|
export interface InputFileDataTypeMap {
|
|
@@ -12,30 +14,43 @@ export interface InputFileDataTypeMap {
|
|
|
12
14
|
|
|
13
15
|
export type InputFileDataType = keyof InputFileDataTypeMap
|
|
14
16
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
+
export function getFileData<T extends InputFileDataType>(file: File, type: T): Promise<InputFileDataTypeMap[T]> {
|
|
18
|
+
if (type === "file") return Promise.resolve(file as InputFileDataTypeMap[T])
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
case "arrayBuffer":
|
|
20
|
-
fileReader.readAsArrayBuffer(file)
|
|
21
|
-
break
|
|
22
|
-
case "binary":
|
|
23
|
-
fileReader.readAsBinaryString(file)
|
|
24
|
-
break
|
|
25
|
-
case "base64":
|
|
26
|
-
fileReader.readAsDataURL(file)
|
|
27
|
-
break
|
|
28
|
-
case "text":
|
|
29
|
-
fileReader.readAsText(file)
|
|
30
|
-
break
|
|
31
|
-
default:
|
|
32
|
-
return file as any
|
|
33
|
-
}
|
|
20
|
+
const fileReader = new FileReader()
|
|
34
21
|
|
|
35
|
-
return new Promise(resolve => {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
36
23
|
fileReader.addEventListener("load", () => {
|
|
37
24
|
resolve(fileReader.result as any)
|
|
38
25
|
})
|
|
26
|
+
fileReader.addEventListener("error", () => {
|
|
27
|
+
reject(fileReader.error ?? new Error("Failed to read file"))
|
|
28
|
+
})
|
|
29
|
+
fileReader.addEventListener("abort", () => {
|
|
30
|
+
reject(fileReader.error ?? new Error("File reading was aborted"))
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
switch (type) {
|
|
35
|
+
case "arrayBuffer":
|
|
36
|
+
fileReader.readAsArrayBuffer(file)
|
|
37
|
+
break
|
|
38
|
+
case "binary":
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
40
|
+
fileReader.readAsBinaryString(file)
|
|
41
|
+
break
|
|
42
|
+
case "base64":
|
|
43
|
+
fileReader.readAsDataURL(file)
|
|
44
|
+
break
|
|
45
|
+
case "text":
|
|
46
|
+
fileReader.readAsText(file)
|
|
47
|
+
break
|
|
48
|
+
default:
|
|
49
|
+
resolve(file as any)
|
|
50
|
+
}
|
|
51
|
+
} catch (error) {
|
|
52
|
+
reject(error)
|
|
53
|
+
}
|
|
39
54
|
})
|
|
40
55
|
}
|
|
41
56
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
+
/* eslint-disable no-restricted-syntax */
|
|
4
|
+
|
|
3
5
|
import {
|
|
4
6
|
ComponentProps,
|
|
5
7
|
ComponentRef,
|
|
@@ -66,17 +68,20 @@ export function InputFileButton<
|
|
|
66
68
|
const { ref, style, disabled: __disabled, ...restInputProps } = inputProps
|
|
67
69
|
const [disabled, setDisabled] = useState(false)
|
|
68
70
|
const input = useRef<HTMLInputElement>(null)
|
|
71
|
+
const isDisabled = disabled || _disabled || __disabled
|
|
69
72
|
|
|
73
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps, react-hooks/refs
|
|
70
74
|
useImperativeHandle(ref, () => input.current!, [input.current])
|
|
71
75
|
|
|
72
76
|
function onClick(e: ReactMouseEvent<ComponentRef<AS>, MouseEvent>) {
|
|
73
|
-
input.current?.click()
|
|
74
77
|
_onClick?.(e as any)
|
|
78
|
+
if (isDisabled || e.defaultPrevented) return
|
|
79
|
+
input.current?.click()
|
|
75
80
|
}
|
|
76
81
|
|
|
77
82
|
async function onDrop(e: DragEvent<ComponentRef<AS>>) {
|
|
78
83
|
_onDrop?.(e as any)
|
|
79
|
-
if (
|
|
84
|
+
if (isDisabled || !dragFile) return
|
|
80
85
|
e.preventDefault()
|
|
81
86
|
const { files } = e.dataTransfer
|
|
82
87
|
if (!files || files.length === 0) return
|
|
@@ -110,15 +115,16 @@ export function InputFileButton<
|
|
|
110
115
|
|
|
111
116
|
function onDragOver(e: DragEvent<ComponentRef<AS>>) {
|
|
112
117
|
_onDragOver?.(e as any)
|
|
113
|
-
if (
|
|
118
|
+
if (isDisabled || !dragFile) return
|
|
114
119
|
e.preventDefault()
|
|
115
120
|
}
|
|
116
121
|
|
|
122
|
+
/* eslint-disable react-hooks/refs */
|
|
117
123
|
return (
|
|
118
124
|
<Fragment>
|
|
119
125
|
<InputFile<Multiple, Type>
|
|
120
126
|
ref={input}
|
|
121
|
-
disabled={
|
|
127
|
+
disabled={isDisabled}
|
|
122
128
|
style={{ display: "none", ...style }}
|
|
123
129
|
multiple={multiple}
|
|
124
130
|
accept={accept}
|
|
@@ -130,7 +136,8 @@ export function InputFileButton<
|
|
|
130
136
|
{...restInputProps}
|
|
131
137
|
/>
|
|
132
138
|
{createElement(as, {
|
|
133
|
-
disabled:
|
|
139
|
+
disabled: isDisabled,
|
|
140
|
+
type: "button",
|
|
134
141
|
onClick,
|
|
135
142
|
onDrop,
|
|
136
143
|
onDragOver,
|
|
@@ -138,4 +145,5 @@ export function InputFileButton<
|
|
|
138
145
|
})}
|
|
139
146
|
</Fragment>
|
|
140
147
|
)
|
|
148
|
+
/* eslint-enable react-hooks/refs */
|
|
141
149
|
}
|
|
@@ -39,6 +39,7 @@ export const LoopSwiper: FC<LoopSwiperProps> = ({
|
|
|
39
39
|
const container = useRef<HTMLDivElement>(null)
|
|
40
40
|
const [swiper, setSwiper] = useState(false)
|
|
41
41
|
const directionRef = useRef(direction)
|
|
42
|
+
// eslint-disable-next-line react-hooks/refs
|
|
42
43
|
directionRef.current = direction
|
|
43
44
|
const flexDirection: CSSProperties["flexDirection"] = direction === "vertical" ? (reverse ? "column-reverse" : "column") : reverse ? "row-reverse" : "row"
|
|
44
45
|
const animationName = swiper
|
|
@@ -49,6 +49,7 @@ export const Scroll: FC<ScrollProps> = ({
|
|
|
49
49
|
useLayoutEffect(() => {
|
|
50
50
|
bar.current = Scrollbar.init(ele.current!, scrollbarOptions)
|
|
51
51
|
return () => bar.current?.destroy()
|
|
52
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52
53
|
}, [])
|
|
53
54
|
|
|
54
55
|
useImperativeHandle(ref, () => ele.current!, [])
|
package/src/components/Title.tsx
CHANGED
|
@@ -15,10 +15,13 @@ export const Title: FC<ComponentProps<"title">> = ({ ref, children, ...rest }) =
|
|
|
15
15
|
|
|
16
16
|
if (major >= 19) return <title ref={ref} {...rest} children={children} />
|
|
17
17
|
|
|
18
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
18
19
|
const ele = useRef<HTMLTitleElement>(null)
|
|
19
20
|
|
|
21
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks, react-hooks/exhaustive-deps, react-hooks/refs
|
|
20
22
|
useImperativeHandle(ref, () => ele.current as HTMLTitleElement, [ele.current])
|
|
21
23
|
|
|
24
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
22
25
|
useLayoutEffect(() => {
|
|
23
26
|
const title = document.head.querySelector("title")
|
|
24
27
|
if (title === ele.current) return
|
package/src/components/Unify.tsx
CHANGED