sense-react-timeline-editor 1.1.11 → 1.1.12

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.
@@ -1,11 +1,12 @@
1
1
  import { DraggableOptions } from "@interactjs/actions/drag/plugin";
2
2
  import { ResizableOptions } from "@interactjs/actions/resize/plugin";
3
3
  import { Interactable } from "@interactjs/types";
4
- import { FC } from "react";
4
+ import { FC, ReactNode } from "react";
5
5
  export declare const InteractComp: FC<{
6
6
  interactRef?: React.MutableRefObject<Interactable>;
7
7
  draggable: boolean;
8
8
  draggableOptions: DraggableOptions;
9
9
  resizable: boolean;
10
10
  resizableOptions: ResizableOptions;
11
+ children: ReactNode;
11
12
  }>;
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import React, { useRef, useEffect, cloneElement, useImperativeHandle, useState, useLayoutEffect, useCallback, useMemo, memo, forwardRef } from 'react';
1
+ import React, { useRef, useEffect, cloneElement, useImperativeHandle, useState, useLayoutEffect, useCallback, useTransition, useMemo, memo, forwardRef } from 'react';
2
2
  import { AutoSizer, Grid, ScrollSync } from 'react-virtualized';
3
3
  import { useThrottleEffect, useThrottleFn } from 'ahooks';
4
4
  import { prefixNames } from 'framework-utils';
@@ -2018,7 +2018,7 @@ var Cursor = /*#__PURE__*/React.forwardRef(function (props, ref) {
2018
2018
  }, [cursorTime, startLeft, scaleWidth, scale], {
2019
2019
  wait: 10
2020
2020
  });
2021
- var clientHeight = ((_document$querySelect = document.querySelector('#time-editor-container')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.clientHeight) || 0;
2021
+ var clientHeight = ((_document$querySelect = document.querySelector('#time-editor-container')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.scrollHeight) || 0;
2022
2022
  return /*#__PURE__*/React.createElement(RowDnd, {
2023
2023
  top: theme === 'light' ? 26 : 0,
2024
2024
  start: startLeft,
@@ -2924,6 +2924,10 @@ var EditRow = function EditRow(props) {
2924
2924
  _useState2 = _slicedToArray(_useState, 2),
2925
2925
  visibleCount = _useState2[0],
2926
2926
  setVisibleCount = _useState2[1];
2927
+ var _useTransition = useTransition(),
2928
+ _useTransition2 = _slicedToArray(_useTransition, 2),
2929
+ isPending = _useTransition2[0],
2930
+ startTransition = _useTransition2[1];
2927
2931
  var classNames = ['edit-row'];
2928
2932
  if (rowData === null || rowData === void 0 ? void 0 : rowData.selected) classNames.push('selected');
2929
2933
  var clientWidth = document.documentElement.clientWidth;
@@ -2949,14 +2953,11 @@ var EditRow = function EditRow(props) {
2949
2953
  }, [visibleActions, visibleCount]);
2950
2954
  useEffect(function () {
2951
2955
  if (visibleCount < visibleActions.length) {
2952
- var timer = requestAnimationFrame(function () {
2956
+ startTransition(function () {
2953
2957
  setVisibleCount(function (prev) {
2954
2958
  return Math.min(prev + 20, visibleActions.length);
2955
2959
  });
2956
2960
  });
2957
- return function () {
2958
- return cancelAnimationFrame(timer);
2959
- };
2960
2961
  }
2961
2962
  }, [visibleCount, visibleActions.length]);
2962
2963
  useEffect(function () {
@@ -4065,7 +4066,8 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
4065
4066
  return prev + (cur.rowHeight || _rowHeight);
4066
4067
  }, 0) + ((className || '').indexOf('1') > -1 ? 12 : 32);
4067
4068
  if (minHeight) {
4068
- _totalHeight = "calc(100% - ".concat(minHeight + 16, "px)");
4069
+ var calcHeight = "calc(100% - ".concat(minHeight + 16, "px)");
4070
+ _totalHeight = "max(".concat(_totalHeight, "px, ").concat(calcHeight, ")");
4069
4071
  }
4070
4072
  return /*#__PURE__*/React.createElement("div", {
4071
4073
  ref: editAreaRef,
@@ -4196,6 +4198,7 @@ var TimeArea = function TimeArea(_ref) {
4196
4198
  var gridRef = useRef();
4197
4199
  /** 是否显示细分刻度 */
4198
4200
  var showUnit = scaleSplitCount > 0;
4201
+ console.log('TimeArea scrollLeft = ', scrollLeft);
4199
4202
  var clientWidth = document.documentElement.clientWidth;
4200
4203
  /** 获取每个 cell 渲染内容 */
4201
4204
  var cellRenderer = function cellRenderer(_ref2) {
@@ -4691,6 +4694,15 @@ var Timeline = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(function (p
4691
4694
  scrollLeft: Math.max(val, 0)
4692
4695
  });
4693
4696
  },
4697
+ setScrollLeftFromTime: function setScrollLeftFromTime(val) {
4698
+ var containerEl = document.querySelector('.timeline-editor');
4699
+ if (!containerEl) return;
4700
+ var left = startLeft + scaleWidth / scale * val;
4701
+ containerEl.scrollLeft = Math.max(left, 0);
4702
+ scrollSync.current && scrollSync.current.setState({
4703
+ scrollLeft: Math.max(left, 0)
4704
+ });
4705
+ },
4694
4706
  setScrollTop: function setScrollTop(val) {
4695
4707
  scrollSync.current && scrollSync.current.setState({
4696
4708
  scrollTop: Math.max(val, 0)
package/dist/index.js CHANGED
@@ -2028,7 +2028,7 @@ var Cursor = /*#__PURE__*/React__default['default'].forwardRef(function (props,
2028
2028
  }, [cursorTime, startLeft, scaleWidth, scale], {
2029
2029
  wait: 10
2030
2030
  });
2031
- var clientHeight = ((_document$querySelect = document.querySelector('#time-editor-container')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.clientHeight) || 0;
2031
+ var clientHeight = ((_document$querySelect = document.querySelector('#time-editor-container')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.scrollHeight) || 0;
2032
2032
  return /*#__PURE__*/React__default['default'].createElement(RowDnd, {
2033
2033
  top: theme === 'light' ? 26 : 0,
2034
2034
  start: startLeft,
@@ -2934,6 +2934,10 @@ var EditRow = function EditRow(props) {
2934
2934
  _useState2 = _slicedToArray(_useState, 2),
2935
2935
  visibleCount = _useState2[0],
2936
2936
  setVisibleCount = _useState2[1];
2937
+ var _useTransition = React.useTransition(),
2938
+ _useTransition2 = _slicedToArray(_useTransition, 2),
2939
+ isPending = _useTransition2[0],
2940
+ startTransition = _useTransition2[1];
2937
2941
  var classNames = ['edit-row'];
2938
2942
  if (rowData === null || rowData === void 0 ? void 0 : rowData.selected) classNames.push('selected');
2939
2943
  var clientWidth = document.documentElement.clientWidth;
@@ -2959,14 +2963,11 @@ var EditRow = function EditRow(props) {
2959
2963
  }, [visibleActions, visibleCount]);
2960
2964
  React.useEffect(function () {
2961
2965
  if (visibleCount < visibleActions.length) {
2962
- var timer = requestAnimationFrame(function () {
2966
+ startTransition(function () {
2963
2967
  setVisibleCount(function (prev) {
2964
2968
  return Math.min(prev + 20, visibleActions.length);
2965
2969
  });
2966
2970
  });
2967
- return function () {
2968
- return cancelAnimationFrame(timer);
2969
- };
2970
2971
  }
2971
2972
  }, [visibleCount, visibleActions.length]);
2972
2973
  React.useEffect(function () {
@@ -4075,7 +4076,8 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
4075
4076
  return prev + (cur.rowHeight || _rowHeight);
4076
4077
  }, 0) + ((className || '').indexOf('1') > -1 ? 12 : 32);
4077
4078
  if (minHeight) {
4078
- _totalHeight = "calc(100% - ".concat(minHeight + 16, "px)");
4079
+ var calcHeight = "calc(100% - ".concat(minHeight + 16, "px)");
4080
+ _totalHeight = "max(".concat(_totalHeight, "px, ").concat(calcHeight, ")");
4079
4081
  }
4080
4082
  return /*#__PURE__*/React__default['default'].createElement("div", {
4081
4083
  ref: editAreaRef,
@@ -4206,6 +4208,7 @@ var TimeArea = function TimeArea(_ref) {
4206
4208
  var gridRef = React.useRef();
4207
4209
  /** 是否显示细分刻度 */
4208
4210
  var showUnit = scaleSplitCount > 0;
4211
+ console.log('TimeArea scrollLeft = ', scrollLeft);
4209
4212
  var clientWidth = document.documentElement.clientWidth;
4210
4213
  /** 获取每个 cell 渲染内容 */
4211
4214
  var cellRenderer = function cellRenderer(_ref2) {
@@ -4701,6 +4704,15 @@ var Timeline = /*#__PURE__*/React__default['default'].memo(/*#__PURE__*/React__d
4701
4704
  scrollLeft: Math.max(val, 0)
4702
4705
  });
4703
4706
  },
4707
+ setScrollLeftFromTime: function setScrollLeftFromTime(val) {
4708
+ var containerEl = document.querySelector('.timeline-editor');
4709
+ if (!containerEl) return;
4710
+ var left = startLeft + scaleWidth / scale * val;
4711
+ containerEl.scrollLeft = Math.max(left, 0);
4712
+ scrollSync.current && scrollSync.current.setState({
4713
+ scrollLeft: Math.max(left, 0)
4714
+ });
4715
+ },
4704
4716
  setScrollTop: function setScrollTop(val) {
4705
4717
  scrollSync.current && scrollSync.current.setState({
4706
4718
  scrollTop: Math.max(val, 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sense-react-timeline-editor",
3
- "version": "1.1.11",
3
+ "version": "1.1.12",
4
4
  "author": "xzdarcy",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -54,8 +54,8 @@
54
54
  "devDependencies": {
55
55
  "@types/howler": "^2.2.4",
56
56
  "@types/lodash": "^4.14.177",
57
- "@types/react": "^17.0.17",
58
- "@types/react-dom": "^17.0.17",
57
+ "@types/react": "^18.3.28",
58
+ "@types/react-dom": "^18.3.7",
59
59
  "@umijs/test": "^3.0.5",
60
60
  "dumi": "^1.0.17",
61
61
  "father-build": "^1.17.2",
@@ -64,8 +64,8 @@
64
64
  "lodash": "^4.17.21",
65
65
  "lottie-web": "^5.8.1",
66
66
  "prettier": "^2.2.1",
67
- "react": "^17.0.0",
68
- "react-dom": "^17.0.0",
67
+ "react": "^18.3.1",
68
+ "react-dom": "^18.3.1",
69
69
  "standard-version": "^9.5.0",
70
70
  "typescript": "^4.8.4",
71
71
  "yorkie": "^2.0.0"