deepsea-components 5.17.4 → 5.17.6

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 (61) hide show
  1. package/dist/components/AutoFit.cjs +1 -1
  2. package/dist/components/AutoFit.js +1 -1
  3. package/dist/components/AutoScroll.cjs +1 -1
  4. package/dist/components/AutoScroll.js +1 -1
  5. package/dist/components/AutoSizeTextarea.cjs +1 -1
  6. package/dist/components/AutoSizeTextarea.js +1 -1
  7. package/dist/components/CopyButton.cjs +1 -1
  8. package/dist/components/CopyButton.d.ts +1 -1
  9. package/dist/components/CopyButton.js +1 -1
  10. package/dist/components/DraggableGrid.cjs +1 -1
  11. package/dist/components/DraggableGrid.js +1 -1
  12. package/dist/components/Echart.cjs +125 -14
  13. package/dist/components/Echart.d.ts +56 -11
  14. package/dist/components/Echart.js +51 -13
  15. package/dist/components/Flow.cjs +1 -1
  16. package/dist/components/Flow.js +1 -1
  17. package/dist/components/HlsPlayer.cjs +1 -1
  18. package/dist/components/HlsPlayer.js +1 -1
  19. package/dist/components/InfiniteScroll.cjs +1 -1
  20. package/dist/components/InfiniteScroll.js +1 -1
  21. package/dist/components/LoopSwiper.cjs +9 -5
  22. package/dist/components/LoopSwiper.d.ts +1 -0
  23. package/dist/components/LoopSwiper.js +9 -5
  24. package/dist/components/ReadSheet.d.ts +1 -1
  25. package/dist/components/Scroll.cjs +11 -11
  26. package/dist/components/Scroll.js +1 -1
  27. package/dist/components/ScrollMask.cjs +1 -1
  28. package/dist/components/ScrollMask.js +1 -1
  29. package/dist/components/SectionRing.cjs +1 -1
  30. package/dist/components/SectionRing.js +1 -1
  31. package/dist/components/Skeleton.cjs +1 -1
  32. package/dist/components/Skeleton.js +1 -1
  33. package/dist/components/TransitionNum.cjs +1 -1
  34. package/dist/components/TransitionNum.js +1 -1
  35. package/dist/components/Trapezium.cjs +1 -1
  36. package/dist/components/Trapezium.js +1 -1
  37. package/dist/components/Unify.cjs +1 -1
  38. package/dist/components/Unify.js +1 -1
  39. package/dist/components/WriteSheet.cjs +1 -1
  40. package/dist/components/WriteSheet.d.ts +1 -1
  41. package/dist/components/WriteSheet.js +1 -1
  42. package/package.json +4 -3
  43. package/src/components/AutoFit.tsx +1 -1
  44. package/src/components/AutoScroll.tsx +1 -1
  45. package/src/components/AutoSizeTextarea.tsx +1 -1
  46. package/src/components/CopyButton.tsx +1 -1
  47. package/src/components/DraggableGrid.tsx +1 -1
  48. package/src/components/Echart.tsx +209 -36
  49. package/src/components/Flow.tsx +1 -1
  50. package/src/components/HlsPlayer.tsx +1 -1
  51. package/src/components/InfiniteScroll.tsx +1 -1
  52. package/src/components/LoopSwiper.tsx +15 -4
  53. package/src/components/ReadSheet.tsx +1 -1
  54. package/src/components/Scroll.tsx +1 -1
  55. package/src/components/ScrollMask.tsx +1 -1
  56. package/src/components/SectionRing.tsx +1 -1
  57. package/src/components/Skeleton.tsx +1 -1
  58. package/src/components/TransitionNum.tsx +1 -1
  59. package/src/components/Trapezium.tsx +1 -1
  60. package/src/components/Unify.tsx +1 -1
  61. package/src/components/WriteSheet.tsx +1 -1
@@ -3,7 +3,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useImperativeHandle, useRef, useState } from "react";
4
4
  import { css } from "@emotion/css";
5
5
  import { clsx } from "deepsea-tools";
6
- const LoopSwiper = ({ ref, className, classNames: { root: rootClassName, container: containerClassName, mirror: mirrorClassName } = {}, children, direction, period, reverse, gap = 0, ...rest })=>{
6
+ const LoopSwiper = ({ ref, className, classNames: { root: rootClassName, container: containerClassName, mirror: mirrorClassName } = {}, children, direction, period, reverse, pauseOnHover = true, gap = 0, ...rest })=>{
7
7
  const wrapper = useRef(null);
8
8
  const container = useRef(null);
9
9
  const [swiper, setSwiper] = useState(false);
@@ -50,7 +50,7 @@ const LoopSwiper = ({ ref, className, classNames: { root: rootClassName, contain
50
50
  transform: translateX(0);
51
51
  }
52
52
  to {
53
- transform: translateX(-100%);
53
+ transform: translateX(calc(-100% - ${gap}px));
54
54
  }
55
55
  }
56
56
 
@@ -59,7 +59,7 @@ const LoopSwiper = ({ ref, className, classNames: { root: rootClassName, contain
59
59
  transform: translateX(0);
60
60
  }
61
61
  to {
62
- transform: translateX(100%);
62
+ transform: translateX(calc(100% + ${gap}px));
63
63
  }
64
64
  }
65
65
 
@@ -68,7 +68,7 @@ const LoopSwiper = ({ ref, className, classNames: { root: rootClassName, contain
68
68
  transform: translateY(0);
69
69
  }
70
70
  to {
71
- transform: translateY(-100%);
71
+ transform: translateY(calc(-100% - ${gap}px));
72
72
  }
73
73
  }
74
74
 
@@ -77,9 +77,13 @@ const LoopSwiper = ({ ref, className, classNames: { root: rootClassName, contain
77
77
  transform: translateY(0);
78
78
  }
79
79
  to {
80
- transform: translateY(100%);
80
+ transform: translateY(calc(100% + ${gap}px));
81
81
  }
82
82
  }
83
+
84
+ ${pauseOnHover ? `&:hover > * {
85
+ animation-play-state: paused;
86
+ }` : ""}
83
87
  `, className, rootClassName),
84
88
  ...rest,
85
89
  children: [
@@ -1,5 +1,5 @@
1
- import { WorkBookData, WorkSheetData } from "deepsea-tools";
2
1
  import { FC } from "react";
2
+ import { WorkBookData, WorkSheetData } from "deepsea-tools";
3
3
  import { InputFileProps } from "./InputFile";
4
4
  export interface ReadSheetProps extends Omit<InputFileProps<false, "arrayBuffer">, "multiple" | "accept" | "type" | "onValueChange"> {
5
5
  onValueChange?: <Sheet = WorkSheetData>(data: WorkBookData<Sheet>) => void;
@@ -71,9 +71,9 @@ var __webpack_exports__ = {};
71
71
  Scrollbar: ()=>smooth_scrollbar__WEBPACK_IMPORTED_MODULE_4___default.a
72
72
  });
73
73
  var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("react/jsx-runtime");
74
- var _emotion_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("@emotion/css");
75
- var deepsea_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("deepsea-tools");
76
- var react__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("react");
74
+ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("react");
75
+ var _emotion_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("@emotion/css");
76
+ var deepsea_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("deepsea-tools");
77
77
  var smooth_scrollbar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("smooth-scrollbar");
78
78
  var smooth_scrollbar__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/ __webpack_require__.n(smooth_scrollbar__WEBPACK_IMPORTED_MODULE_4__);
79
79
  var _utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("@/utils");
@@ -87,21 +87,21 @@ var __webpack_exports__ = {};
87
87
  return smooth_scrollbar_interfaces__WEBPACK_IMPORTED_MODULE_6__[key];
88
88
  }).bind(0, __WEBPACK_IMPORT_KEY__);
89
89
  __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
90
- const Scroll = /*#__PURE__*/ (0, react__WEBPACK_IMPORTED_MODULE_3__.forwardRef)((props, ref)=>{
90
+ const Scroll = /*#__PURE__*/ (0, react__WEBPACK_IMPORTED_MODULE_1__.forwardRef)((props, ref)=>{
91
91
  const { children, options, className, style, scrollbar, onScrollbar, ...rest } = props;
92
92
  const { thumbWidth, thumbRadius, thumbColor, trackColor, ...scrollbarOptions } = options || {};
93
- const ele = (0, react__WEBPACK_IMPORTED_MODULE_3__.useRef)(null);
94
- const bar = (0, react__WEBPACK_IMPORTED_MODULE_3__.useRef)(null);
95
- (0, react__WEBPACK_IMPORTED_MODULE_3__.useLayoutEffect)(()=>{
93
+ const ele = (0, react__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);
94
+ const bar = (0, react__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);
95
+ (0, react__WEBPACK_IMPORTED_MODULE_1__.useLayoutEffect)(()=>{
96
96
  bar.current = smooth_scrollbar__WEBPACK_IMPORTED_MODULE_4___default().init(ele.current, scrollbarOptions);
97
97
  return ()=>{
98
98
  var _bar_current;
99
99
  return null == (_bar_current = bar.current) ? void 0 : _bar_current.destroy();
100
100
  };
101
101
  }, []);
102
- (0, react__WEBPACK_IMPORTED_MODULE_3__.useImperativeHandle)(ref, ()=>ele.current, []);
103
- (0, react__WEBPACK_IMPORTED_MODULE_3__.useImperativeHandle)(scrollbar, ()=>bar.current, []);
104
- (0, react__WEBPACK_IMPORTED_MODULE_3__.useEffect)(()=>{
102
+ (0, react__WEBPACK_IMPORTED_MODULE_1__.useImperativeHandle)(ref, ()=>ele.current, []);
103
+ (0, react__WEBPACK_IMPORTED_MODULE_1__.useImperativeHandle)(scrollbar, ()=>bar.current, []);
104
+ (0, react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(()=>{
105
105
  var _bar_current;
106
106
  if (!onScrollbar) return;
107
107
  null == (_bar_current = bar.current) || _bar_current.addListener(onScrollbar);
@@ -114,7 +114,7 @@ var __webpack_exports__ = {};
114
114
  ]);
115
115
  return /*#__PURE__*/ (0, react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", {
116
116
  ref: ele,
117
- className: (0, deepsea_tools__WEBPACK_IMPORTED_MODULE_2__.clsx)((0, _emotion_css__WEBPACK_IMPORTED_MODULE_1__.css)`
117
+ className: (0, deepsea_tools__WEBPACK_IMPORTED_MODULE_3__.clsx)((0, _emotion_css__WEBPACK_IMPORTED_MODULE_2__.css)`
118
118
  .scrollbar-track.scrollbar-track-x {
119
119
  ${void 0 !== thumbWidth ? "height: var(--thumb-width);" : ""} ${void 0 !== trackColor ? "background-color: var(--track-color);" : ""}
120
120
  }
@@ -1,8 +1,8 @@
1
1
  "use client"
2
2
  import { jsx } from "react/jsx-runtime";
3
+ import { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useRef } from "react";
3
4
  import { css } from "@emotion/css";
4
5
  import { clsx } from "deepsea-tools";
5
- import { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useRef } from "react";
6
6
  import smooth_scrollbar from "smooth-scrollbar";
7
7
  import { px, transformCSSVariable } from "../utils/index.js";
8
8
  export * from "smooth-scrollbar/interfaces";
@@ -36,8 +36,8 @@ __webpack_require__.d(__webpack_exports__, {
36
36
  ScrollMask: ()=>ScrollMask
37
37
  });
38
38
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
39
- const external_deepsea_tools_namespaceObject = require("deepsea-tools");
40
39
  const external_react_namespaceObject = require("react");
40
+ const external_deepsea_tools_namespaceObject = require("deepsea-tools");
41
41
  const external_soda_hooks_namespaceObject = require("soda-hooks");
42
42
  const external_ScrollMask_module_cjs_namespaceObject = require("./ScrollMask.module.cjs");
43
43
  var external_ScrollMask_module_cjs_default = /*#__PURE__*/ __webpack_require__.n(external_ScrollMask_module_cjs_namespaceObject);
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { clsx, isNonNullable } from "deepsea-tools";
3
2
  import { useRef } from "react";
3
+ import { clsx, isNonNullable } from "deepsea-tools";
4
4
  import { useSize } from "soda-hooks";
5
5
  import ScrollMask_module from "./ScrollMask.module.js";
6
6
  const ScrollMask = ({ className, style, position = "top", size = 8, from = "rgba(0, 0, 0, 0.1)", to = "rgba(0, 0, 0, 0)", contentClassName, contentStyle, showRadian = false, ...rest })=>{
@@ -28,8 +28,8 @@ __webpack_require__.d(__webpack_exports__, {
28
28
  SectionRing: ()=>SectionRing
29
29
  });
30
30
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
31
- const external_deepsea_tools_namespaceObject = require("deepsea-tools");
32
31
  const external_react_namespaceObject = require("react");
32
+ const external_deepsea_tools_namespaceObject = require("deepsea-tools");
33
33
  const SectionRing = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)((props, ref)=>{
34
34
  const { outerRadius: o, innerRadius: i, count: c, angel: a, style, ...rest } = props;
35
35
  const s = 2 * Math.PI / c - a;
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { drawArc } from "deepsea-tools";
4
3
  import { forwardRef } from "react";
4
+ import { drawArc } from "deepsea-tools";
5
5
  const SectionRing = /*#__PURE__*/ forwardRef((props, ref)=>{
6
6
  const { outerRadius: o, innerRadius: i, count: c, angel: a, style, ...rest } = props;
7
7
  const s = 2 * Math.PI / c - a;
@@ -28,9 +28,9 @@ __webpack_require__.d(__webpack_exports__, {
28
28
  Skeleton: ()=>Skeleton
29
29
  });
30
30
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
31
+ const external_react_namespaceObject = require("react");
31
32
  const css_namespaceObject = require("@emotion/css");
32
33
  const external_deepsea_tools_namespaceObject = require("deepsea-tools");
33
- const external_react_namespaceObject = require("react");
34
34
  const Skeleton = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)((props, ref)=>{
35
35
  const { className, children, loading = null == children, ...rest } = props;
36
36
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
@@ -1,8 +1,8 @@
1
1
  "use client"
2
2
  import { jsx } from "react/jsx-runtime";
3
+ import { forwardRef } from "react";
3
4
  import { css } from "@emotion/css";
4
5
  import { clsx } from "deepsea-tools";
5
- import { forwardRef } from "react";
6
6
  const Skeleton = /*#__PURE__*/ forwardRef((props, ref)=>{
7
7
  const { className, children, loading = null == children, ...rest } = props;
8
8
  return /*#__PURE__*/ jsx("div", {
@@ -28,8 +28,8 @@ __webpack_require__.d(__webpack_exports__, {
28
28
  TransitionNum: ()=>TransitionNum
29
29
  });
30
30
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
31
- const external_deepsea_tools_namespaceObject = require("deepsea-tools");
32
31
  const external_react_namespaceObject = require("react");
32
+ const external_deepsea_tools_namespaceObject = require("deepsea-tools");
33
33
  const TransitionNum = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)((props, ref)=>{
34
34
  const { children: num, period, numToStr, ins, ...rest } = props;
35
35
  if (!Number.isInteger(num) || !Number.isInteger(period) || period <= 0) throw new RangeError("目标数字必须是整数,周期必须是正整数");
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { setFrameInterval } from "deepsea-tools";
4
3
  import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
4
+ import { setFrameInterval } from "deepsea-tools";
5
5
  const TransitionNum = /*#__PURE__*/ forwardRef((props, ref)=>{
6
6
  const { children: num, period, numToStr, ins, ...rest } = props;
7
7
  if (!Number.isInteger(num) || !Number.isInteger(period) || period <= 0) throw new RangeError("目标数字必须是整数,周期必须是正整数");
@@ -28,9 +28,9 @@ __webpack_require__.d(__webpack_exports__, {
28
28
  Trapezium: ()=>Trapezium
29
29
  });
30
30
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
31
+ const external_react_namespaceObject = require("react");
31
32
  const css_namespaceObject = require("@emotion/css");
32
33
  const external_deepsea_tools_namespaceObject = require("deepsea-tools");
33
- const external_react_namespaceObject = require("react");
34
34
  const index_cjs_namespaceObject = require("../utils/index.cjs");
35
35
  const Trapezium = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)((props, ref)=>{
36
36
  const { top, bottom, height, borderRadius, className, style, ...rest } = props;
@@ -1,8 +1,8 @@
1
1
  "use client"
2
2
  import { jsx } from "react/jsx-runtime";
3
+ import { forwardRef } from "react";
3
4
  import { css } from "@emotion/css";
4
5
  import { clsx } from "deepsea-tools";
5
- import { forwardRef } from "react";
6
6
  import { px, transformCSSVariable } from "../utils/index.js";
7
7
  const Trapezium = /*#__PURE__*/ forwardRef((props, ref)=>{
8
8
  const { top, bottom, height, borderRadius, className, style, ...rest } = props;
@@ -29,8 +29,8 @@ __webpack_require__.d(__webpack_exports__, {
29
29
  UnifyConfigProvider: ()=>UnifyConfigProvider
30
30
  });
31
31
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
32
- const external_deepsea_tools_namespaceObject = require("deepsea-tools");
33
32
  const external_react_namespaceObject = require("react");
33
+ const external_deepsea_tools_namespaceObject = require("deepsea-tools");
34
34
  const UnifyConfigContext = /*#__PURE__*/ (0, external_react_namespaceObject.createContext)({});
35
35
  const UnifyConfigProvider = ({ className, style, children })=>{
36
36
  const { className: _className, style: _style } = (0, external_react_namespaceObject.useContext)(UnifyConfigContext);
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { clsx } from "deepsea-tools";
4
3
  import { createContext, createElement, useContext } from "react";
4
+ import { clsx } from "deepsea-tools";
5
5
  const UnifyConfigContext = /*#__PURE__*/ createContext({});
6
6
  const UnifyConfigProvider = ({ className, style, children })=>{
7
7
  const { className: _className, style: _style } = useContext(UnifyConfigContext);
@@ -27,8 +27,8 @@ __webpack_require__.r(__webpack_exports__);
27
27
  __webpack_require__.d(__webpack_exports__, {
28
28
  WriteSheet: ()=>WriteSheet
29
29
  });
30
- const external_deepsea_tools_namespaceObject = require("deepsea-tools");
31
30
  const external_react_namespaceObject = require("react");
31
+ const external_deepsea_tools_namespaceObject = require("deepsea-tools");
32
32
  function WriteSheet(props) {
33
33
  const { as, excel, onClick: _onClick, ...rest } = props;
34
34
  function onClick(e) {
@@ -1,5 +1,5 @@
1
- import { WriteSheetParams } from "deepsea-tools";
2
1
  import { ComponentProps, JSX, JSXElementConstructor } from "react";
2
+ import { WriteSheetParams } from "deepsea-tools";
3
3
  export type WriteSheetProps<AS extends keyof JSX.IntrinsicElements | JSXElementConstructor<any> = "button"> = Omit<ComponentProps<AS>, "as" | "excel"> & {
4
4
  as?: AS;
5
5
  excel?: WriteSheetParams;
@@ -1,6 +1,6 @@
1
1
  "use client"
2
- import { writeSheet } from "deepsea-tools";
3
2
  import { createElement } from "react";
3
+ import { writeSheet } from "deepsea-tools";
4
4
  function WriteSheet(props) {
5
5
  const { as, excel, onClick: _onClick, ...rest } = props;
6
6
  function onClick(e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepsea-components",
3
- "version": "5.17.4",
3
+ "version": "5.17.6",
4
4
  "description": "格数科技自用组件库",
5
5
  "type": "module",
6
6
  "exports": {
@@ -40,8 +40,9 @@
40
40
  "echarts": "^6.0.0",
41
41
  "hls.js": "^1.6.13",
42
42
  "smooth-scrollbar": "^8.8.4",
43
- "soda-hooks": "6.15.2",
44
- "deepsea-tools": "5.42.4"
43
+ "stable-hash": "^0.0.6",
44
+ "deepsea-tools": "5.42.4",
45
+ "soda-hooks": "6.15.2"
45
46
  },
46
47
  "devDependencies": {
47
48
  "typescript": "^5.9.3"
@@ -1,8 +1,8 @@
1
1
  "use client"
2
2
 
3
+ import { HTMLAttributes, forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from "react"
3
4
  import { css } from "@emotion/css"
4
5
  import { clsx } from "deepsea-tools"
5
- import { HTMLAttributes, forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from "react"
6
6
 
7
7
  import { px, transformCSSVariable } from "@/utils"
8
8
 
@@ -1,8 +1,8 @@
1
1
  "use client"
2
2
 
3
+ import { CSSProperties, MouseEvent as ReactMouseEvent, forwardRef, useEffect, useImperativeHandle, useRef } from "react"
3
4
  import { css } from "@emotion/css"
4
5
  import { clsx, getArray } from "deepsea-tools"
5
- import { CSSProperties, MouseEvent as ReactMouseEvent, forwardRef, useEffect, useImperativeHandle, useRef } from "react"
6
6
  import Scrollbar from "smooth-scrollbar"
7
7
  import { ScrollStatus } from "smooth-scrollbar/interfaces/scrollbar"
8
8
  import { useSize } from "soda-hooks"
@@ -1,8 +1,8 @@
1
1
  "use client"
2
2
 
3
+ import { TextareaHTMLAttributes, forwardRef, useImperativeHandle, useLayoutEffect, useRef, useState } from "react"
3
4
  import { css } from "@emotion/css"
4
5
  import { clsx } from "deepsea-tools"
5
- import { TextareaHTMLAttributes, forwardRef, useImperativeHandle, useLayoutEffect, useRef, useState } from "react"
6
6
 
7
7
  import { px, transformCSSVariable } from "@/utils"
8
8
 
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
 
3
- import ClipboardJS, { Event } from "clipboard"
4
3
  import { ComponentPropsWithoutRef, forwardRef, useEffect, useImperativeHandle, useRef } from "react"
4
+ import ClipboardJS, { Event } from "clipboard"
5
5
  import { useLatest } from "soda-hooks"
6
6
 
7
7
  export { Event } from "clipboard"
@@ -1,5 +1,5 @@
1
- import { clsx, getArray, isNullable } from "deepsea-tools"
2
1
  import { CSSProperties, ComponentProps, Key, ReactNode, useEffect, useMemo, useRef, useState } from "react"
2
+ import { clsx, getArray, isNullable } from "deepsea-tools"
3
3
  import { DragMoveEvent, DragMoveEvents, useDragMove } from "soda-hooks"
4
4
 
5
5
  import styles from "./DraggableGrid.module.css"
@@ -1,69 +1,242 @@
1
1
  "use client"
2
2
 
3
+ import { ComponentProps, FC, ReactNode, Ref, useEffect, useImperativeHandle, useLayoutEffect, useRef } from "react"
3
4
  import {
5
+ AngleAxisComponentOption,
6
+ AriaComponentOption,
7
+ AxisPointerComponentOption,
4
8
  BarSeriesOption,
9
+ BoxplotSeriesOption,
10
+ BrushComponentOption,
11
+ CalendarComponentOption,
12
+ CandlestickSeriesOption,
13
+ ChordSeriesOption,
5
14
  ComposeOption,
15
+ ContinousVisualMapComponentOption,
16
+ CustomSeriesOption,
17
+ DataZoomComponentOption,
6
18
  DatasetComponentOption,
7
19
  ECharts,
20
+ EChartsInitOpts,
21
+ EffectScatterSeriesOption,
22
+ FunnelSeriesOption,
23
+ GaugeSeriesOption,
24
+ GeoComponentOption,
25
+ GraphSeriesOption,
26
+ GraphicComponentOption,
8
27
  GridComponentOption,
28
+ HeatmapSeriesOption,
29
+ InsideDataZoomComponentOption,
30
+ LegendComponentOption,
9
31
  LineSeriesOption,
32
+ LinesSeriesOption,
33
+ MapSeriesOption,
34
+ MarkAreaComponentOption,
35
+ MarkLineComponentOption,
36
+ MarkPointComponentOption,
37
+ MatrixComponentOption,
38
+ ParallelSeriesOption,
39
+ PictorialBarSeriesOption,
10
40
  PieSeriesOption,
41
+ PiecewiseVisualMapComponentOption,
42
+ PlainLegendComponentOption,
43
+ PolarComponentOption,
44
+ RadarComponentOption,
45
+ RadarSeriesOption,
46
+ RadiusAxisComponentOption,
47
+ SankeySeriesOption,
48
+ ScatterSeriesOption,
49
+ ScrollableLegendComponentOption,
50
+ SeriesOption,
51
+ SingleAxisComponentOption,
52
+ SliderDataZoomComponentOption,
53
+ SunburstSeriesOption,
54
+ ThemeRiverSeriesOption,
55
+ ThumbnailComponentOption,
56
+ TimelineComponentOption,
11
57
  TitleComponentOption,
58
+ ToolboxComponentOption,
12
59
  TooltipComponentOption,
60
+ TreeSeriesOption,
61
+ TreemapSeriesOption,
62
+ VisualMapComponentOption,
63
+ XAXisComponentOption,
64
+ YAXisComponentOption,
13
65
  init,
14
66
  } 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
67
+ import { ECBasicOption } from "echarts/types/src/util/types.js"
68
+ import hash from "stable-hash"
69
+
70
+ export type ChartOption<T extends SeriesOption = never> = ComposeOption<
71
+ | T
72
+ | DatasetComponentOption
73
+ | GridComponentOption
74
+ | LegendComponentOption
75
+ | TitleComponentOption
76
+ | TooltipComponentOption
77
+ | AxisPointerComponentOption
78
+ | GeoComponentOption
79
+ | MarkLineComponentOption
80
+ | MarkPointComponentOption
81
+ | MarkAreaComponentOption
82
+ | DataZoomComponentOption
83
+ | AriaComponentOption
84
+ | BrushComponentOption
85
+ | PolarComponentOption
86
+ | RadarComponentOption
87
+ | XAXisComponentOption
88
+ | YAXisComponentOption
89
+ | MatrixComponentOption
90
+ | GraphicComponentOption
91
+ | ToolboxComponentOption
92
+ | CalendarComponentOption
93
+ | TimelineComponentOption
94
+ | AngleAxisComponentOption
95
+ | RadiusAxisComponentOption
96
+ | SingleAxisComponentOption
97
+ | VisualMapComponentOption
98
+ | ThumbnailComponentOption
99
+ | PlainLegendComponentOption
100
+ | InsideDataZoomComponentOption
101
+ | SliderDataZoomComponentOption
102
+ | PiecewiseVisualMapComponentOption
103
+ | ContinousVisualMapComponentOption
104
+ | ScrollableLegendComponentOption
105
+ >
106
+
107
+ export type BarOption = ChartOption<BarSeriesOption>
108
+
109
+ export type BoxplotOption = ChartOption<BoxplotSeriesOption>
110
+
111
+ export type CandlestickOption = ChartOption<CandlestickSeriesOption>
112
+
113
+ export type ChordOption = ChartOption<ChordSeriesOption>
114
+
115
+ export type CustomOption = ChartOption<CustomSeriesOption>
116
+
117
+ export type EffectScatterOption = ChartOption<EffectScatterSeriesOption>
118
+
119
+ export type FunnelOption = ChartOption<FunnelSeriesOption>
120
+
121
+ export type GaugeOption = ChartOption<GaugeSeriesOption>
122
+
123
+ export type GraphOption = ChartOption<GraphSeriesOption>
124
+
125
+ export type HeatmapOption = ChartOption<HeatmapSeriesOption>
126
+
127
+ export type LineOption = ChartOption<LineSeriesOption>
128
+
129
+ export type LinesOption = ChartOption<LinesSeriesOption>
130
+
131
+ export type MapOption = ChartOption<MapSeriesOption>
132
+
133
+ export type ParallelOption = ChartOption<ParallelSeriesOption>
134
+
135
+ export type PictorialBarOption = ChartOption<PictorialBarSeriesOption>
136
+
137
+ export type PieOption = ChartOption<PieSeriesOption>
138
+
139
+ export type RadarOption = ChartOption<RadarSeriesOption>
140
+
141
+ export type SankeyOption = ChartOption<SankeySeriesOption>
142
+
143
+ export type ScatterOption = ChartOption<ScatterSeriesOption>
144
+
145
+ export type SunburstOption = ChartOption<SunburstSeriesOption>
146
+
147
+ export type ThemeRiverOption = ChartOption<ThemeRiverSeriesOption>
148
+
149
+ export type TreeOption = ChartOption<TreeSeriesOption>
150
+
151
+ export type TreemapOption = ChartOption<TreemapSeriesOption>
152
+
153
+ export type ModifiableEChartsInitOpts = Pick<EChartsInitOpts, "width" | "height" | "locale">
154
+
155
+ export interface EChartInitOption extends Omit<EChartsInitOpts, keyof ModifiableEChartsInitOpts> {}
156
+
157
+ export interface EchartProps<T extends ECBasicOption = ECBasicOption> extends Omit<ComponentProps<"div">, "children">, ModifiableEChartsInitOpts {
158
+ init?: EChartInitOption
36
159
  option: T
37
- chart?: ForwardedRef<ECharts>
160
+ chart?: Ref<ECharts>
38
161
  }
39
162
 
40
- export type EchartComponent<T extends PieOption | BarOption | LineOption> = ForwardRefExoticComponent<
41
- Omit<EchartProps<T>, "ref"> & RefAttributes<HTMLDivElement>
42
- >
163
+ export type EchartComponent<T extends ECBasicOption = ECBasicOption> = FC<EchartProps<T>>
43
164
 
44
- const Echart = forwardRef<HTMLDivElement, EchartProps>((props, ref) => {
45
- const { width, height, option, chart, ...rest } = props
165
+ export function Echart<T extends ECBasicOption = ECBasicOption>({
166
+ ref,
167
+ width,
168
+ height,
169
+ locale,
170
+ init: initOption,
171
+ option,
172
+ chart,
173
+ ...rest
174
+ }: EchartProps<T>): ReactNode {
46
175
  const container = useRef<HTMLDivElement>(null)
47
176
  const chartRef = useRef<ECharts | null>(null)
48
177
 
49
178
  useLayoutEffect(() => {
50
179
  const ele = container.current!
51
- chartRef.current = init(ele, option, { width, height })
180
+ chartRef.current = init(ele, option, { ...initOption, width, height, locale })
52
181
  return () => chartRef.current?.dispose()
53
182
  }, [])
54
183
 
55
- useImperativeHandle(ref, () => container.current!, [])
184
+ useImperativeHandle(ref, () => container.current!)
185
+
186
+ useImperativeHandle(chart, () => chartRef.current!)
56
187
 
57
- useImperativeHandle(chart, () => chartRef.current!, [])
188
+ useEffect(() => chartRef.current?.setOption(option), [hash(option)])
58
189
 
59
- useEffect(() => {
60
- chartRef.current?.setOption(option)
61
- chartRef.current?.resize({ width, height })
62
- })
190
+ // @ts-expect-error width and height can be string
191
+ useEffect(() => chartRef.current?.resize({ width, height }), [width, height])
192
+
193
+ useEffect(() => chartRef.current?.setOption({ locale }), [locale])
63
194
 
64
195
  return <div ref={container} {...rest} />
65
- })
196
+ }
66
197
 
67
- export const Pie = Echart as EchartComponent<PieOption>
68
198
  export const Bar = Echart as EchartComponent<BarOption>
199
+
200
+ export const Boxplot = Echart as EchartComponent<BoxplotOption>
201
+
202
+ export const Candlestick = Echart as EchartComponent<CandlestickOption>
203
+
204
+ export const Chord = Echart as EchartComponent<ChordOption>
205
+
206
+ export const Custom = Echart as EchartComponent<CustomOption>
207
+
208
+ export const EffectScatter = Echart as EchartComponent<EffectScatterOption>
209
+
210
+ export const Funnel = Echart as EchartComponent<FunnelOption>
211
+
212
+ export const Gauge = Echart as EchartComponent<GaugeOption>
213
+
214
+ export const Graph = Echart as EchartComponent<GraphOption>
215
+
216
+ export const Heatmap = Echart as EchartComponent<HeatmapOption>
217
+
69
218
  export const Line = Echart as EchartComponent<LineOption>
219
+
220
+ export const Lines = Echart as EchartComponent<LinesOption>
221
+
222
+ export const Map = Echart as EchartComponent<MapOption>
223
+
224
+ export const Parallel = Echart as EchartComponent<ParallelOption>
225
+
226
+ export const PictorialBar = Echart as EchartComponent<PictorialBarOption>
227
+
228
+ export const Pie = Echart as EchartComponent<PieOption>
229
+
230
+ export const Radar = Echart as EchartComponent<RadarOption>
231
+
232
+ export const Sankey = Echart as EchartComponent<SankeyOption>
233
+
234
+ export const Scatter = Echart as EchartComponent<ScatterOption>
235
+
236
+ export const Sunburst = Echart as EchartComponent<SunburstOption>
237
+
238
+ export const ThemeRiver = Echart as EchartComponent<ThemeRiverOption>
239
+
240
+ export const Tree = Echart as EchartComponent<TreeOption>
241
+
242
+ export const Treemap = Echart as EchartComponent<TreemapOption>
@@ -1,8 +1,8 @@
1
1
  "use client"
2
2
 
3
+ import { CSSProperties, HTMLAttributes, Key, ReactNode, Ref, useEffect, useImperativeHandle, useRef, useState } from "react"
3
4
  import { css } from "@emotion/css"
4
5
  import { clsx } from "deepsea-tools"
5
- import { CSSProperties, HTMLAttributes, Key, ReactNode, Ref, useEffect, useImperativeHandle, useRef, useState } from "react"
6
6
  import { useSize } from "soda-hooks"
7
7
 
8
8
  import { px, transformCSSVariable } from "@/utils"
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
 
3
- import Hls from "hls.js"
4
3
  import { MediaHTMLAttributes, forwardRef, useEffect, useImperativeHandle, useRef } from "react"
4
+ import Hls from "hls.js"
5
5
 
6
6
  export interface HlsPlayerProps extends Omit<MediaHTMLAttributes<HTMLVideoElement>, "src"> {
7
7
  src: string