sense-react-timeline-editor 1.1.25 → 1.1.27
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.
|
@@ -12,6 +12,7 @@ export interface UseRowSelectionOptions {
|
|
|
12
12
|
export declare const useRowSelection: (options: UseRowSelectionOptions) => {
|
|
13
13
|
DragSelection: () => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
14
14
|
selectedActionIds: string[];
|
|
15
|
+
justFinishedSelectionRef: import("react").MutableRefObject<boolean>;
|
|
15
16
|
clearSelection: () => void;
|
|
16
17
|
onClickOutside: (target: HTMLElement) => void;
|
|
17
18
|
onCtrlClick: (actionId: string, event: MouseEvent) => void;
|
package/dist/index.esm.js
CHANGED
|
@@ -2961,7 +2961,6 @@ var css_248z$3 = ".timeline-editor-edit-row {\n background-repeat: no-repeat, r
|
|
|
2961
2961
|
styleInject(css_248z$3);
|
|
2962
2962
|
|
|
2963
2963
|
var EditRow = function EditRow(props) {
|
|
2964
|
-
var _areaRef$current;
|
|
2965
2964
|
var rowData = props.rowData,
|
|
2966
2965
|
_props$style = props.style,
|
|
2967
2966
|
style = _props$style === void 0 ? {} : _props$style,
|
|
@@ -2983,8 +2982,8 @@ var EditRow = function EditRow(props) {
|
|
|
2983
2982
|
var classNames = ['edit-row'];
|
|
2984
2983
|
if (rowData === null || rowData === void 0 ? void 0 : rowData.selected) classNames.push('selected');
|
|
2985
2984
|
if (rowData === null || rowData === void 0 ? void 0 : rowData.isPreview) classNames.push('preview-row');
|
|
2986
|
-
var viewportWidth =
|
|
2987
|
-
var overscanPx = Math.max(
|
|
2985
|
+
var viewportWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
2986
|
+
var overscanPx = Math.max(400, viewportWidth * 0.7);
|
|
2988
2987
|
var timeStart = parserPixelToTime(scrollLeft - overscanPx, {
|
|
2989
2988
|
startLeft: startLeft,
|
|
2990
2989
|
scale: scale,
|
|
@@ -3095,6 +3094,8 @@ var useRowSelection = function useRowSelection(options) {
|
|
|
3095
3094
|
_useState2 = _slicedToArray(_useState, 2),
|
|
3096
3095
|
selectedActionIds = _useState2[0],
|
|
3097
3096
|
setSelectedActionIds = _useState2[1];
|
|
3097
|
+
var justFinishedSelectionRef = useRef(false);
|
|
3098
|
+
var selectionResetTimerRef = useRef(null);
|
|
3098
3099
|
// 计算框选区域与 action 的交集
|
|
3099
3100
|
var getIntersectedActions = useCallback(function (box) {
|
|
3100
3101
|
var _containerRef$current, _containerRef$current2;
|
|
@@ -3160,6 +3161,14 @@ var useRowSelection = function useRowSelection(options) {
|
|
|
3160
3161
|
}
|
|
3161
3162
|
},
|
|
3162
3163
|
onSelectionEnd: function onSelectionEnd() {
|
|
3164
|
+
justFinishedSelectionRef.current = true;
|
|
3165
|
+
if (selectionResetTimerRef.current) {
|
|
3166
|
+
clearTimeout(selectionResetTimerRef.current);
|
|
3167
|
+
}
|
|
3168
|
+
selectionResetTimerRef.current = setTimeout(function () {
|
|
3169
|
+
justFinishedSelectionRef.current = false;
|
|
3170
|
+
selectionResetTimerRef.current = null;
|
|
3171
|
+
}, 0);
|
|
3163
3172
|
// 清除框选框
|
|
3164
3173
|
setTimeout(function () {
|
|
3165
3174
|
var selectionBoxes = document.querySelectorAll('.timeline-editor-selection-box');
|
|
@@ -3230,11 +3239,15 @@ var useRowSelection = function useRowSelection(options) {
|
|
|
3230
3239
|
document.addEventListener('keydown', handleKeyDown);
|
|
3231
3240
|
return function () {
|
|
3232
3241
|
document.removeEventListener('keydown', handleKeyDown);
|
|
3242
|
+
if (selectionResetTimerRef.current) {
|
|
3243
|
+
clearTimeout(selectionResetTimerRef.current);
|
|
3244
|
+
}
|
|
3233
3245
|
};
|
|
3234
3246
|
}, [handleKeyDown]);
|
|
3235
3247
|
return {
|
|
3236
3248
|
DragSelection: DragSelection,
|
|
3237
3249
|
selectedActionIds: Array.from(selectedActionIds),
|
|
3250
|
+
justFinishedSelectionRef: justFinishedSelectionRef,
|
|
3238
3251
|
clearSelection: clearSelection,
|
|
3239
3252
|
onClickOutside: handleClickOutside,
|
|
3240
3253
|
onCtrlClick: handleCtrlClick,
|
|
@@ -3904,6 +3917,7 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3904
3917
|
}),
|
|
3905
3918
|
DragSelection = _useRowSelection.DragSelection,
|
|
3906
3919
|
selectedActionIds = _useRowSelection.selectedActionIds,
|
|
3920
|
+
justFinishedSelectionRef = _useRowSelection.justFinishedSelectionRef,
|
|
3907
3921
|
onClickOutside = _useRowSelection.onClickOutside,
|
|
3908
3922
|
onCtrlClick = _useRowSelection.onCtrlClick,
|
|
3909
3923
|
setSelectedActionIds = _useRowSelection.setSelectedActionIds;
|
|
@@ -4172,6 +4186,11 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
4172
4186
|
return /*#__PURE__*/React.createElement("div", {
|
|
4173
4187
|
ref: editAreaRef,
|
|
4174
4188
|
className: prefix('edit-area') + " ".concat((className || '').replace('timeline-editor', '') || ''),
|
|
4189
|
+
onClickCapture: function onClickCapture(e) {
|
|
4190
|
+
if (!justFinishedSelectionRef.current) return;
|
|
4191
|
+
e.preventDefault();
|
|
4192
|
+
e.stopPropagation();
|
|
4193
|
+
},
|
|
4175
4194
|
style: {
|
|
4176
4195
|
height: isMulti ? _totalHeight : 'unset',
|
|
4177
4196
|
maxHeight: isMulti ? _totalHeight : 'unset',
|
|
@@ -4303,7 +4322,7 @@ var TimeArea = function TimeArea(_ref) {
|
|
|
4303
4322
|
var gridRef = useRef();
|
|
4304
4323
|
/** 是否显示细分刻度 */
|
|
4305
4324
|
var showUnit = scaleSplitCount > 0;
|
|
4306
|
-
var visibleWidth =
|
|
4325
|
+
var visibleWidth = document.documentElement.clientWidth;
|
|
4307
4326
|
/** 获取每个 cell 渲染内容 */
|
|
4308
4327
|
var cellRenderer = function cellRenderer(_ref2) {
|
|
4309
4328
|
var columnIndex = _ref2.columnIndex,
|
package/dist/index.js
CHANGED
|
@@ -2971,7 +2971,6 @@ var css_248z$3 = ".timeline-editor-edit-row {\n background-repeat: no-repeat, r
|
|
|
2971
2971
|
styleInject(css_248z$3);
|
|
2972
2972
|
|
|
2973
2973
|
var EditRow = function EditRow(props) {
|
|
2974
|
-
var _areaRef$current;
|
|
2975
2974
|
var rowData = props.rowData,
|
|
2976
2975
|
_props$style = props.style,
|
|
2977
2976
|
style = _props$style === void 0 ? {} : _props$style,
|
|
@@ -2993,8 +2992,8 @@ var EditRow = function EditRow(props) {
|
|
|
2993
2992
|
var classNames = ['edit-row'];
|
|
2994
2993
|
if (rowData === null || rowData === void 0 ? void 0 : rowData.selected) classNames.push('selected');
|
|
2995
2994
|
if (rowData === null || rowData === void 0 ? void 0 : rowData.isPreview) classNames.push('preview-row');
|
|
2996
|
-
var viewportWidth =
|
|
2997
|
-
var overscanPx = Math.max(
|
|
2995
|
+
var viewportWidth = window.innerWidth || document.documentElement.clientWidth;
|
|
2996
|
+
var overscanPx = Math.max(400, viewportWidth * 0.7);
|
|
2998
2997
|
var timeStart = parserPixelToTime(scrollLeft - overscanPx, {
|
|
2999
2998
|
startLeft: startLeft,
|
|
3000
2999
|
scale: scale,
|
|
@@ -3105,6 +3104,8 @@ var useRowSelection = function useRowSelection(options) {
|
|
|
3105
3104
|
_useState2 = _slicedToArray(_useState, 2),
|
|
3106
3105
|
selectedActionIds = _useState2[0],
|
|
3107
3106
|
setSelectedActionIds = _useState2[1];
|
|
3107
|
+
var justFinishedSelectionRef = React.useRef(false);
|
|
3108
|
+
var selectionResetTimerRef = React.useRef(null);
|
|
3108
3109
|
// 计算框选区域与 action 的交集
|
|
3109
3110
|
var getIntersectedActions = React.useCallback(function (box) {
|
|
3110
3111
|
var _containerRef$current, _containerRef$current2;
|
|
@@ -3170,6 +3171,14 @@ var useRowSelection = function useRowSelection(options) {
|
|
|
3170
3171
|
}
|
|
3171
3172
|
},
|
|
3172
3173
|
onSelectionEnd: function onSelectionEnd() {
|
|
3174
|
+
justFinishedSelectionRef.current = true;
|
|
3175
|
+
if (selectionResetTimerRef.current) {
|
|
3176
|
+
clearTimeout(selectionResetTimerRef.current);
|
|
3177
|
+
}
|
|
3178
|
+
selectionResetTimerRef.current = setTimeout(function () {
|
|
3179
|
+
justFinishedSelectionRef.current = false;
|
|
3180
|
+
selectionResetTimerRef.current = null;
|
|
3181
|
+
}, 0);
|
|
3173
3182
|
// 清除框选框
|
|
3174
3183
|
setTimeout(function () {
|
|
3175
3184
|
var selectionBoxes = document.querySelectorAll('.timeline-editor-selection-box');
|
|
@@ -3240,11 +3249,15 @@ var useRowSelection = function useRowSelection(options) {
|
|
|
3240
3249
|
document.addEventListener('keydown', handleKeyDown);
|
|
3241
3250
|
return function () {
|
|
3242
3251
|
document.removeEventListener('keydown', handleKeyDown);
|
|
3252
|
+
if (selectionResetTimerRef.current) {
|
|
3253
|
+
clearTimeout(selectionResetTimerRef.current);
|
|
3254
|
+
}
|
|
3243
3255
|
};
|
|
3244
3256
|
}, [handleKeyDown]);
|
|
3245
3257
|
return {
|
|
3246
3258
|
DragSelection: DragSelection,
|
|
3247
3259
|
selectedActionIds: Array.from(selectedActionIds),
|
|
3260
|
+
justFinishedSelectionRef: justFinishedSelectionRef,
|
|
3248
3261
|
clearSelection: clearSelection,
|
|
3249
3262
|
onClickOutside: handleClickOutside,
|
|
3250
3263
|
onCtrlClick: handleCtrlClick,
|
|
@@ -3914,6 +3927,7 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3914
3927
|
}),
|
|
3915
3928
|
DragSelection = _useRowSelection.DragSelection,
|
|
3916
3929
|
selectedActionIds = _useRowSelection.selectedActionIds,
|
|
3930
|
+
justFinishedSelectionRef = _useRowSelection.justFinishedSelectionRef,
|
|
3917
3931
|
onClickOutside = _useRowSelection.onClickOutside,
|
|
3918
3932
|
onCtrlClick = _useRowSelection.onCtrlClick,
|
|
3919
3933
|
setSelectedActionIds = _useRowSelection.setSelectedActionIds;
|
|
@@ -4182,6 +4196,11 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
4182
4196
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4183
4197
|
ref: editAreaRef,
|
|
4184
4198
|
className: prefix('edit-area') + " ".concat((className || '').replace('timeline-editor', '') || ''),
|
|
4199
|
+
onClickCapture: function onClickCapture(e) {
|
|
4200
|
+
if (!justFinishedSelectionRef.current) return;
|
|
4201
|
+
e.preventDefault();
|
|
4202
|
+
e.stopPropagation();
|
|
4203
|
+
},
|
|
4185
4204
|
style: {
|
|
4186
4205
|
height: isMulti ? _totalHeight : 'unset',
|
|
4187
4206
|
maxHeight: isMulti ? _totalHeight : 'unset',
|
|
@@ -4313,7 +4332,7 @@ var TimeArea = function TimeArea(_ref) {
|
|
|
4313
4332
|
var gridRef = React.useRef();
|
|
4314
4333
|
/** 是否显示细分刻度 */
|
|
4315
4334
|
var showUnit = scaleSplitCount > 0;
|
|
4316
|
-
var visibleWidth =
|
|
4335
|
+
var visibleWidth = document.documentElement.clientWidth;
|
|
4317
4336
|
/** 获取每个 cell 渲染内容 */
|
|
4318
4337
|
var cellRenderer = function cellRenderer(_ref2) {
|
|
4319
4338
|
var columnIndex = _ref2.columnIndex,
|