@leankylin-sheet/react 7.0.25 → 7.0.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.
package/dist/index.esm.js CHANGED
@@ -8179,6 +8179,20 @@ var SheetItem = function SheetItem(_ref) {
8179
8179
  });
8180
8180
  });
8181
8181
  var isActive = context.currentSheetId === sheet.id;
8182
+ useEffect(function () {
8183
+ if (!isActive) return undefined;
8184
+ var rafId = requestAnimationFrame(function () {
8185
+ var _containerRef$current;
8186
+ (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.scrollIntoView({
8187
+ block: "nearest",
8188
+ inline: "nearest",
8189
+ behavior: "smooth"
8190
+ });
8191
+ });
8192
+ return function () {
8193
+ return cancelAnimationFrame(rafId);
8194
+ };
8195
+ }, [isActive]);
8182
8196
  return /*#__PURE__*/React.createElement("div", {
8183
8197
  onDragOver: function onDragOver(e) {
8184
8198
  e.preventDefault();
@@ -8415,8 +8429,42 @@ var SheetTab = function SheetTab() {
8415
8429
  }, []);
8416
8430
  useEffect(function () {
8417
8431
  var tabCurrent = tabContainerRef.current;
8418
- if (!tabCurrent) return;
8419
- setIsShowScrollBtn(tabCurrent.scrollWidth - 2 > tabCurrent.clientWidth);
8432
+ if (!tabCurrent) return undefined;
8433
+ var rafId = 0;
8434
+ var syncScrollBtn = function syncScrollBtn() {
8435
+ cancelAnimationFrame(rafId);
8436
+ rafId = requestAnimationFrame(function () {
8437
+ setIsShowScrollBtn(tabCurrent.scrollWidth - 2 > tabCurrent.clientWidth);
8438
+ });
8439
+ };
8440
+ var syncBoundary = function syncBoundary() {
8441
+ setIsShowBoundary(tabCurrent.scrollLeft <= 0);
8442
+ };
8443
+ syncScrollBtn();
8444
+ syncBoundary();
8445
+ tabCurrent.addEventListener("scroll", syncBoundary, {
8446
+ passive: true
8447
+ });
8448
+ var resizeObserver;
8449
+ if (typeof ResizeObserver !== "undefined") {
8450
+ var ro = new ResizeObserver(syncScrollBtn);
8451
+ resizeObserver = ro;
8452
+ ro.observe(tabCurrent);
8453
+ Array.from(tabCurrent.children).forEach(function (child) {
8454
+ return ro.observe(child);
8455
+ });
8456
+ } else {
8457
+ window.addEventListener("resize", syncScrollBtn);
8458
+ }
8459
+ return function () {
8460
+ cancelAnimationFrame(rafId);
8461
+ tabCurrent.removeEventListener("scroll", syncBoundary);
8462
+ if (resizeObserver) {
8463
+ resizeObserver.disconnect();
8464
+ } else {
8465
+ window.removeEventListener("resize", syncScrollBtn);
8466
+ }
8467
+ };
8420
8468
  }, [context.luckysheetfile]);
8421
8469
  var onAddSheetClick = useCallback(function () {
8422
8470
  return setTimeout(function () {
@@ -8455,7 +8503,6 @@ var SheetTab = function SheetTab() {
8455
8503
  }, /*#__PURE__*/React.createElement("div", {
8456
8504
  id: "all-sheets",
8457
8505
  className: "leankylin-sheettab-button",
8458
- ref: tabContainerRef,
8459
8506
  onMouseDown: function onMouseDown(e) {
8460
8507
  e.stopPropagation();
8461
8508
  setContext(function (ctx) {
@@ -12040,6 +12087,21 @@ var SheetListItem = function SheetListItem(_ref) {
12040
12087
  });
12041
12088
  }, [context.currentSheetId, context.sheetScrollRecord, setContext]);
12042
12089
  var isActive = sheet.id === context.currentSheetId;
12090
+ var scrollToVisible = useCallback(function () {
12091
+ var _containerRef$current;
12092
+ (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.scrollIntoView({
12093
+ block: "nearest",
12094
+ inline: "nearest",
12095
+ behavior: "smooth"
12096
+ });
12097
+ }, []);
12098
+ useEffect(function () {
12099
+ if (!isActive) return undefined;
12100
+ var rafId = requestAnimationFrame(scrollToVisible);
12101
+ return function () {
12102
+ return cancelAnimationFrame(rafId);
12103
+ };
12104
+ }, [isActive, scrollToVisible]);
12043
12105
  return /*#__PURE__*/React.createElement("div", {
12044
12106
  className: "leankylin-sheet-list-item",
12045
12107
  key: sheet.id,
@@ -12050,6 +12112,7 @@ var SheetListItem = function SheetListItem(_ref) {
12050
12112
  },
12051
12113
  onClick: function onClick() {
12052
12114
  if (isDropPlaceholder) return;
12115
+ scrollToVisible();
12053
12116
  setContext(function (draftCtx) {
12054
12117
  draftCtx.sheetScrollRecord[draftCtx.currentSheetId] = {
12055
12118
  scrollLeft: draftCtx.scrollLeft,
package/dist/index.js CHANGED
@@ -8189,6 +8189,20 @@ var SheetItem = function SheetItem(_ref) {
8189
8189
  });
8190
8190
  });
8191
8191
  var isActive = context.currentSheetId === sheet.id;
8192
+ React.useEffect(function () {
8193
+ if (!isActive) return undefined;
8194
+ var rafId = requestAnimationFrame(function () {
8195
+ var _containerRef$current;
8196
+ (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.scrollIntoView({
8197
+ block: "nearest",
8198
+ inline: "nearest",
8199
+ behavior: "smooth"
8200
+ });
8201
+ });
8202
+ return function () {
8203
+ return cancelAnimationFrame(rafId);
8204
+ };
8205
+ }, [isActive]);
8192
8206
  return /*#__PURE__*/React__default['default'].createElement("div", {
8193
8207
  onDragOver: function onDragOver(e) {
8194
8208
  e.preventDefault();
@@ -8425,8 +8439,42 @@ var SheetTab = function SheetTab() {
8425
8439
  }, []);
8426
8440
  React.useEffect(function () {
8427
8441
  var tabCurrent = tabContainerRef.current;
8428
- if (!tabCurrent) return;
8429
- setIsShowScrollBtn(tabCurrent.scrollWidth - 2 > tabCurrent.clientWidth);
8442
+ if (!tabCurrent) return undefined;
8443
+ var rafId = 0;
8444
+ var syncScrollBtn = function syncScrollBtn() {
8445
+ cancelAnimationFrame(rafId);
8446
+ rafId = requestAnimationFrame(function () {
8447
+ setIsShowScrollBtn(tabCurrent.scrollWidth - 2 > tabCurrent.clientWidth);
8448
+ });
8449
+ };
8450
+ var syncBoundary = function syncBoundary() {
8451
+ setIsShowBoundary(tabCurrent.scrollLeft <= 0);
8452
+ };
8453
+ syncScrollBtn();
8454
+ syncBoundary();
8455
+ tabCurrent.addEventListener("scroll", syncBoundary, {
8456
+ passive: true
8457
+ });
8458
+ var resizeObserver;
8459
+ if (typeof ResizeObserver !== "undefined") {
8460
+ var ro = new ResizeObserver(syncScrollBtn);
8461
+ resizeObserver = ro;
8462
+ ro.observe(tabCurrent);
8463
+ Array.from(tabCurrent.children).forEach(function (child) {
8464
+ return ro.observe(child);
8465
+ });
8466
+ } else {
8467
+ window.addEventListener("resize", syncScrollBtn);
8468
+ }
8469
+ return function () {
8470
+ cancelAnimationFrame(rafId);
8471
+ tabCurrent.removeEventListener("scroll", syncBoundary);
8472
+ if (resizeObserver) {
8473
+ resizeObserver.disconnect();
8474
+ } else {
8475
+ window.removeEventListener("resize", syncScrollBtn);
8476
+ }
8477
+ };
8430
8478
  }, [context.luckysheetfile]);
8431
8479
  var onAddSheetClick = React.useCallback(function () {
8432
8480
  return setTimeout(function () {
@@ -8465,7 +8513,6 @@ var SheetTab = function SheetTab() {
8465
8513
  }, /*#__PURE__*/React__default['default'].createElement("div", {
8466
8514
  id: "all-sheets",
8467
8515
  className: "leankylin-sheettab-button",
8468
- ref: tabContainerRef,
8469
8516
  onMouseDown: function onMouseDown(e) {
8470
8517
  e.stopPropagation();
8471
8518
  setContext(function (ctx) {
@@ -12050,6 +12097,21 @@ var SheetListItem = function SheetListItem(_ref) {
12050
12097
  });
12051
12098
  }, [context.currentSheetId, context.sheetScrollRecord, setContext]);
12052
12099
  var isActive = sheet.id === context.currentSheetId;
12100
+ var scrollToVisible = React.useCallback(function () {
12101
+ var _containerRef$current;
12102
+ (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.scrollIntoView({
12103
+ block: "nearest",
12104
+ inline: "nearest",
12105
+ behavior: "smooth"
12106
+ });
12107
+ }, []);
12108
+ React.useEffect(function () {
12109
+ if (!isActive) return undefined;
12110
+ var rafId = requestAnimationFrame(scrollToVisible);
12111
+ return function () {
12112
+ return cancelAnimationFrame(rafId);
12113
+ };
12114
+ }, [isActive, scrollToVisible]);
12053
12115
  return /*#__PURE__*/React__default['default'].createElement("div", {
12054
12116
  className: "leankylin-sheet-list-item",
12055
12117
  key: sheet.id,
@@ -12060,6 +12122,7 @@ var SheetListItem = function SheetListItem(_ref) {
12060
12122
  },
12061
12123
  onClick: function onClick() {
12062
12124
  if (isDropPlaceholder) return;
12125
+ scrollToVisible();
12063
12126
  setContext(function (draftCtx) {
12064
12127
  draftCtx.sheetScrollRecord[draftCtx.currentSheetId] = {
12065
12128
  scrollLeft: draftCtx.scrollLeft,
package/dist/index.umd.js CHANGED
@@ -27263,6 +27263,20 @@
27263
27263
  });
27264
27264
  });
27265
27265
  var isActive = context.currentSheetId === sheet.id;
27266
+ React.useEffect(function () {
27267
+ if (!isActive) return undefined;
27268
+ var rafId = requestAnimationFrame(function () {
27269
+ var _containerRef$current;
27270
+ (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.scrollIntoView({
27271
+ block: "nearest",
27272
+ inline: "nearest",
27273
+ behavior: "smooth"
27274
+ });
27275
+ });
27276
+ return function () {
27277
+ return cancelAnimationFrame(rafId);
27278
+ };
27279
+ }, [isActive]);
27266
27280
  return /*#__PURE__*/React__default['default'].createElement("div", {
27267
27281
  onDragOver: function onDragOver(e) {
27268
27282
  e.preventDefault();
@@ -27499,8 +27513,42 @@
27499
27513
  }, []);
27500
27514
  React.useEffect(function () {
27501
27515
  var tabCurrent = tabContainerRef.current;
27502
- if (!tabCurrent) return;
27503
- setIsShowScrollBtn(tabCurrent.scrollWidth - 2 > tabCurrent.clientWidth);
27516
+ if (!tabCurrent) return undefined;
27517
+ var rafId = 0;
27518
+ var syncScrollBtn = function syncScrollBtn() {
27519
+ cancelAnimationFrame(rafId);
27520
+ rafId = requestAnimationFrame(function () {
27521
+ setIsShowScrollBtn(tabCurrent.scrollWidth - 2 > tabCurrent.clientWidth);
27522
+ });
27523
+ };
27524
+ var syncBoundary = function syncBoundary() {
27525
+ setIsShowBoundary(tabCurrent.scrollLeft <= 0);
27526
+ };
27527
+ syncScrollBtn();
27528
+ syncBoundary();
27529
+ tabCurrent.addEventListener("scroll", syncBoundary, {
27530
+ passive: true
27531
+ });
27532
+ var resizeObserver;
27533
+ if (typeof ResizeObserver !== "undefined") {
27534
+ var ro = new ResizeObserver(syncScrollBtn);
27535
+ resizeObserver = ro;
27536
+ ro.observe(tabCurrent);
27537
+ Array.from(tabCurrent.children).forEach(function (child) {
27538
+ return ro.observe(child);
27539
+ });
27540
+ } else {
27541
+ window.addEventListener("resize", syncScrollBtn);
27542
+ }
27543
+ return function () {
27544
+ cancelAnimationFrame(rafId);
27545
+ tabCurrent.removeEventListener("scroll", syncBoundary);
27546
+ if (resizeObserver) {
27547
+ resizeObserver.disconnect();
27548
+ } else {
27549
+ window.removeEventListener("resize", syncScrollBtn);
27550
+ }
27551
+ };
27504
27552
  }, [context.luckysheetfile]);
27505
27553
  var onAddSheetClick = React.useCallback(function () {
27506
27554
  return setTimeout(function () {
@@ -27539,7 +27587,6 @@
27539
27587
  }, /*#__PURE__*/React__default['default'].createElement("div", {
27540
27588
  id: "all-sheets",
27541
27589
  className: "leankylin-sheettab-button",
27542
- ref: tabContainerRef,
27543
27590
  onMouseDown: function onMouseDown(e) {
27544
27591
  e.stopPropagation();
27545
27592
  setContext(function (ctx) {
@@ -31124,6 +31171,21 @@
31124
31171
  });
31125
31172
  }, [context.currentSheetId, context.sheetScrollRecord, setContext]);
31126
31173
  var isActive = sheet.id === context.currentSheetId;
31174
+ var scrollToVisible = React.useCallback(function () {
31175
+ var _containerRef$current;
31176
+ (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.scrollIntoView({
31177
+ block: "nearest",
31178
+ inline: "nearest",
31179
+ behavior: "smooth"
31180
+ });
31181
+ }, []);
31182
+ React.useEffect(function () {
31183
+ if (!isActive) return undefined;
31184
+ var rafId = requestAnimationFrame(scrollToVisible);
31185
+ return function () {
31186
+ return cancelAnimationFrame(rafId);
31187
+ };
31188
+ }, [isActive, scrollToVisible]);
31127
31189
  return /*#__PURE__*/React__default['default'].createElement("div", {
31128
31190
  className: "leankylin-sheet-list-item",
31129
31191
  key: sheet.id,
@@ -31134,6 +31196,7 @@
31134
31196
  },
31135
31197
  onClick: function onClick() {
31136
31198
  if (isDropPlaceholder) return;
31199
+ scrollToVisible();
31137
31200
  setContext(function (draftCtx) {
31138
31201
  draftCtx.sheetScrollRecord[draftCtx.currentSheetId] = {
31139
31202
  scrollLeft: draftCtx.scrollLeft,