@ishibashi0112/spreadsheet-grid-core 1.0.1 → 1.1.0

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 (155) hide show
  1. package/dist/controllers/autoHeightMeasurer.cjs +1 -1
  2. package/dist/controllers/autoHeightMeasurer.js +4 -2
  3. package/dist/controllers/clipboardController.cjs +1 -2
  4. package/dist/controllers/clipboardController.d.ts +3 -0
  5. package/dist/controllers/clipboardController.js +78 -59
  6. package/dist/controllers/columnAutosizeRunner.cjs +1 -1
  7. package/dist/controllers/columnAutosizeRunner.d.ts +3 -1
  8. package/dist/controllers/columnAutosizeRunner.js +12 -10
  9. package/dist/controllers/columnHeaderDragController.cjs +1 -1
  10. package/dist/controllers/columnHeaderDragController.js +146 -140
  11. package/dist/controllers/columnMenuController.cjs +1 -1
  12. package/dist/controllers/columnMenuController.js +71 -69
  13. package/dist/controllers/contextMenuController.cjs +1 -1
  14. package/dist/controllers/contextMenuController.d.ts +4 -1
  15. package/dist/controllers/contextMenuController.js +55 -38
  16. package/dist/controllers/editController.cjs +1 -1
  17. package/dist/controllers/editController.js +78 -78
  18. package/dist/controllers/escapeClaimController.cjs +1 -1
  19. package/dist/controllers/escapeClaimController.d.ts +1 -0
  20. package/dist/controllers/escapeClaimController.js +11 -5
  21. package/dist/controllers/fillHandleController.cjs +1 -1
  22. package/dist/controllers/fillHandleController.d.ts +1 -0
  23. package/dist/controllers/fillHandleController.js +148 -147
  24. package/dist/controllers/filterPopoverController.cjs +1 -1
  25. package/dist/controllers/filterPopoverController.js +81 -77
  26. package/dist/controllers/findController.cjs +1 -1
  27. package/dist/controllers/findController.d.ts +1 -0
  28. package/dist/controllers/findController.js +36 -29
  29. package/dist/controllers/historyController.cjs +1 -1
  30. package/dist/controllers/historyController.d.ts +6 -0
  31. package/dist/controllers/historyController.js +79 -37
  32. package/dist/controllers/keyboardController.cjs +1 -1
  33. package/dist/controllers/keyboardController.d.ts +1 -0
  34. package/dist/controllers/keyboardController.js +116 -116
  35. package/dist/controllers/pointerInteractionsController.cjs +1 -1
  36. package/dist/controllers/pointerInteractionsController.d.ts +1 -0
  37. package/dist/controllers/pointerInteractionsController.js +142 -142
  38. package/dist/controllers/popoverSupport.cjs +1 -1
  39. package/dist/controllers/popoverSupport.d.ts +1 -0
  40. package/dist/controllers/popoverSupport.js +17 -7
  41. package/dist/controllers/rowDragController.cjs +1 -1
  42. package/dist/controllers/rowDragController.d.ts +1 -0
  43. package/dist/controllers/rowDragController.js +151 -149
  44. package/dist/controllers/rowEnterController.cjs +1 -1
  45. package/dist/controllers/rowEnterController.d.ts +1 -0
  46. package/dist/controllers/rowEnterController.js +47 -42
  47. package/dist/controllers/toolPanelController.cjs +1 -1
  48. package/dist/controllers/toolPanelController.js +26 -14
  49. package/dist/controllers/tooltipController.cjs +1 -1
  50. package/dist/controllers/tooltipController.js +85 -66
  51. package/dist/controllers/viewportSyncController.cjs +1 -1
  52. package/dist/controllers/viewportSyncController.d.ts +4 -1
  53. package/dist/controllers/viewportSyncController.js +89 -30
  54. package/dist/engine/exportCommands.cjs +1 -1
  55. package/dist/engine/exportCommands.js +16 -9
  56. package/dist/engine/filterPopoverCommands.cjs +1 -1
  57. package/dist/engine/filterPopoverCommands.d.ts +2 -0
  58. package/dist/engine/filterPopoverCommands.js +15 -15
  59. package/dist/engine/fullFeatures.cjs +1 -1
  60. package/dist/engine/fullFeatures.js +17 -17
  61. package/dist/engine/gridApi.cjs +3 -3
  62. package/dist/engine/gridApi.d.ts +7 -2
  63. package/dist/engine/gridApi.js +16 -16
  64. package/dist/engine/rowSelectionCommands.cjs +1 -1
  65. package/dist/engine/rowSelectionCommands.d.ts +1 -0
  66. package/dist/engine/rowSelectionCommands.js +21 -12
  67. package/dist/index.cjs +1 -1
  68. package/dist/index.d.ts +3 -1
  69. package/dist/index.js +7 -6
  70. package/dist/locales/en.cjs +1 -1
  71. package/dist/locales/en.js +10 -4
  72. package/dist/logic/autoScrollGeometry.cjs +1 -1
  73. package/dist/logic/autoScrollGeometry.d.ts +2 -0
  74. package/dist/logic/autoScrollGeometry.js +3 -3
  75. package/dist/logic/columnAutosize.cjs +1 -1
  76. package/dist/logic/columnAutosize.d.ts +8 -2
  77. package/dist/logic/columnAutosize.js +102 -87
  78. package/dist/logic/detailRow.cjs +1 -1
  79. package/dist/logic/detailRow.d.ts +4 -0
  80. package/dist/logic/detailRow.js +18 -15
  81. package/dist/logic/editorValues.cjs +1 -1
  82. package/dist/logic/editorValues.d.ts +1 -0
  83. package/dist/logic/editorValues.js +37 -34
  84. package/dist/logic/exportCsv.cjs +3 -3
  85. package/dist/logic/exportCsv.d.ts +3 -1
  86. package/dist/logic/exportCsv.js +22 -20
  87. package/dist/logic/exportData.cjs +1 -1
  88. package/dist/logic/exportData.d.ts +3 -1
  89. package/dist/logic/exportData.js +40 -36
  90. package/dist/logic/filterSummary.cjs +1 -1
  91. package/dist/logic/filterSummary.js +9 -2
  92. package/dist/logic/filtering.cjs +1 -1
  93. package/dist/logic/filtering.d.ts +2 -1
  94. package/dist/logic/filtering.js +16 -3
  95. package/dist/logic/find.cjs +1 -1
  96. package/dist/logic/find.d.ts +4 -3
  97. package/dist/logic/find.js +27 -13
  98. package/dist/logic/gridAsk.cjs +2 -2
  99. package/dist/logic/gridAsk.d.ts +7 -7
  100. package/dist/logic/gridAsk.js +140 -122
  101. package/dist/logic/gridAskLocaleText.cjs +1 -1
  102. package/dist/logic/gridAskLocaleText.d.ts +2 -0
  103. package/dist/logic/gridAskLocaleText.js +1 -0
  104. package/dist/logic/gridState.d.ts +2 -2
  105. package/dist/logic/groupExport.cjs +1 -1
  106. package/dist/logic/groupExport.js +28 -27
  107. package/dist/logic/grouping.cjs +1 -1
  108. package/dist/logic/grouping.d.ts +1 -0
  109. package/dist/logic/grouping.js +52 -41
  110. package/dist/logic/historyRebase.cjs +1 -0
  111. package/dist/logic/historyRebase.d.ts +5 -0
  112. package/dist/logic/historyRebase.js +36 -0
  113. package/dist/logic/localeText.cjs +1 -1
  114. package/dist/logic/localeText.d.ts +2 -0
  115. package/dist/logic/localeText.js +1 -0
  116. package/dist/logic/localeTextFeatures.cjs +1 -1
  117. package/dist/logic/localeTextFeatures.d.ts +4 -0
  118. package/dist/logic/localeTextFeatures.js +10 -7
  119. package/dist/logic/localeTextFilters.cjs +1 -1
  120. package/dist/logic/localeTextFilters.d.ts +1 -0
  121. package/dist/logic/localeTextFilters.js +1 -0
  122. package/dist/logic/localeTextPopups.cjs +1 -1
  123. package/dist/logic/localeTextPopups.d.ts +1 -0
  124. package/dist/logic/localeTextPopups.js +3 -2
  125. package/dist/logic/numberFilterCondition.cjs +1 -1
  126. package/dist/logic/numberFilterCondition.d.ts +1 -1
  127. package/dist/logic/numberFilterCondition.js +5 -5
  128. package/dist/logic/scrollTargets.cjs +1 -1
  129. package/dist/logic/scrollTargets.js +2 -2
  130. package/dist/logic/selectEditorState.cjs +1 -1
  131. package/dist/logic/selectEditorState.d.ts +1 -0
  132. package/dist/logic/selectEditorState.js +8 -1
  133. package/dist/logic/selectLabels.cjs +1 -0
  134. package/dist/logic/selectLabels.d.ts +3 -0
  135. package/dist/logic/selectLabels.js +41 -0
  136. package/dist/logic/valueFormatters.d.ts +5 -5
  137. package/dist/logic/valueParsers.cjs +1 -0
  138. package/dist/logic/valueParsers.d.ts +14 -0
  139. package/dist/logic/valueParsers.js +23 -0
  140. package/dist/logic/verticalGeometry.cjs +1 -1
  141. package/dist/logic/verticalGeometry.d.ts +1 -0
  142. package/dist/logic/verticalGeometry.js +12 -8
  143. package/dist/model/gridActions.cjs +1 -1
  144. package/dist/model/gridActions.d.ts +2 -1
  145. package/dist/model/gridActions.js +3 -2
  146. package/dist/model/gridReducer.cjs +1 -1
  147. package/dist/model/gridReducer.js +145 -62
  148. package/dist/model/gridTypes.core.d.ts +492 -315
  149. package/dist/utils/clipboard.cjs +4 -6
  150. package/dist/utils/clipboard.d.ts +15 -2
  151. package/dist/utils/clipboard.js +103 -48
  152. package/dist/utils/popupContainer.cjs +1 -0
  153. package/dist/utils/popupContainer.d.ts +8 -0
  154. package/dist/utils/popupContainer.js +60 -0
  155. package/package.json +1 -1
@@ -1,30 +1,30 @@
1
1
  import { isInsideDetailCardOf as e } from "../logic/detailRow.js";
2
2
  //#region src/controllers/rowEnterController.ts
3
- var t = "ssg-body-row--enter", n = "--ssg-row-enter-index", r = 12, i = 1500, a = (e) => Number(e.getAttribute("data-row-index")), o = /(?:^|;)\s*transform\s*:\s*([^;]+)/, s = (e) => {
3
+ var t = "ssg-body-row--enter", n = "--ssg-row-enter-index", r = 12, i = 1500, a = 1e3, o = (e) => Number(e.getAttribute("data-row-index")), s = /(?:^|;)\s*transform\s*:\s*([^;]+)/, c = (e) => {
4
4
  if (!e) return null;
5
- let t = o.exec(e);
5
+ let t = s.exec(e);
6
6
  return t ? t[1].trim() : null;
7
- }, c = (e) => e instanceof HTMLElement && e.classList.contains("ssg-body-row"), l = "ssg-scroll-container--scrolling", u = () => {
8
- let r = null, o = null, u = !1, d = {
7
+ }, l = (e) => e instanceof HTMLElement && e.classList.contains("ssg-body-row"), u = "ssg-scroll-container--scrolling", d = () => {
8
+ let r = null, s = null, d = !1, f = {
9
9
  skeletonEnter: !1,
10
10
  mountEnter: !1
11
- }, f = /* @__PURE__ */ new Map(), p = (e) => {
11
+ }, p = /* @__PURE__ */ new Map(), m = -Infinity, h = (e) => {
12
12
  e.classList.remove(t), e.style.removeProperty(n);
13
- let r = f.get(e);
14
- r !== void 0 && (clearTimeout(r), f.delete(e));
15
- }, m = (e, r) => {
13
+ let r = p.get(e);
14
+ r !== void 0 && (clearTimeout(r), p.delete(e));
15
+ }, g = (e, r) => {
16
16
  e.style.setProperty(n, String(r)), e.classList.add(t);
17
17
  let a = () => {
18
- e.removeEventListener("animationend", a), p(e);
18
+ e.removeEventListener("animationend", a), h(e);
19
19
  };
20
- e.addEventListener("animationend", a), f.set(e, setTimeout(() => {
21
- e.removeEventListener("animationend", a), p(e);
20
+ e.addEventListener("animationend", a), p.set(e, setTimeout(() => {
21
+ e.removeEventListener("animationend", a), h(e);
22
22
  }, i));
23
- }, h = (e, t) => {
23
+ }, _ = (e, t) => {
24
24
  let n = [];
25
25
  for (let r of e) {
26
26
  if (r.style.transition) continue;
27
- let e = s(t.get(r) ?? null), i = r.style.transform;
27
+ let e = c(t.get(r) ?? null), i = r.style.transform;
28
28
  !e || !i || e === i || n.push({
29
29
  el: r,
30
30
  from: e,
@@ -33,46 +33,51 @@ var t = "ssg-body-row--enter", n = "--ssg-row-enter-index", r = 12, i = 1500, a
33
33
  }
34
34
  if (n.length !== 0) {
35
35
  for (let { el: e, from: t } of n) e.style.transform = t;
36
- o?.getBoundingClientRect();
36
+ s?.getBoundingClientRect();
37
37
  for (let { el: e, to: t } of n) e.style.transform = t;
38
38
  }
39
- }, g = (t) => c(t) && (o === null || !e(o, t)), _ = (t) => {
40
- let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), s = [];
41
- for (let l of t) {
42
- if (l.type === "attributes") {
43
- let e = l.target;
44
- g(e) && !r.has(e) && r.set(e, l.oldValue);
39
+ }, v = (t) => l(t) && (s === null || !e(s, t)), y = (t) => {
40
+ let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), c = [];
41
+ for (let a of t) {
42
+ if (a.type === "attributes") {
43
+ let e = a.target;
44
+ v(e) && !r.has(e) && r.set(e, a.oldValue);
45
45
  continue;
46
46
  }
47
- let t = o !== null && l.target instanceof Element && e(o, l.target);
48
- l.removedNodes.forEach((e) => {
49
- t || !c(e) || (e.hasAttribute("data-skeleton-row") ? n.add(a(e)) : i.add(e));
50
- }), l.addedNodes.forEach((e) => {
51
- g(e) && !e.hasAttribute("data-skeleton-row") && s.push(e);
47
+ let t = s !== null && a.target instanceof Element && e(s, a.target);
48
+ a.removedNodes.forEach((e) => {
49
+ t || !l(e) || (e.hasAttribute("data-skeleton-row") ? n.add(o(e)) : i.add(e));
50
+ }), a.addedNodes.forEach((e) => {
51
+ v(e) && !e.hasAttribute("data-skeleton-row") && c.push(e);
52
52
  });
53
53
  }
54
- if (s.length === 0) return;
55
- let u = o?.classList.contains(l) === !0;
56
- d.mountEnter && !u && h(s.filter((e) => i.has(e)), r);
57
- let f = s.filter((e) => d.mountEnter && !u && !i.has(e) || d.skeletonEnter && n.has(a(e)));
58
- if (f.length === 0) return;
59
- let p = Array.from(new Set(f.map(a))).sort((e, t) => e - t), _ = /* @__PURE__ */ new Map();
60
- p.forEach((e, t) => {
61
- _.set(e, Math.min(t, 12));
54
+ if (c.length === 0) return;
55
+ let d = s?.classList.contains(u) === !0;
56
+ f.mountEnter && !d && _(c.filter((e) => i.has(e)), r);
57
+ let p = f.mountEnter && !d;
58
+ if (p && c.some((e) => !i.has(e))) {
59
+ let e = Date.now();
60
+ p = e - m >= a, m = e;
61
+ }
62
+ let h = c.filter((e) => p && !i.has(e) || f.skeletonEnter && n.has(o(e)));
63
+ if (h.length === 0) return;
64
+ let y = Array.from(new Set(h.map(o))).sort((e, t) => e - t), b = /* @__PURE__ */ new Map();
65
+ y.forEach((e, t) => {
66
+ b.set(e, Math.min(t, 12));
62
67
  });
63
- for (let e of f) m(e, _.get(a(e)) ?? 0);
64
- }, v = () => {
65
- r?.disconnect(), r = null, o = null, u = !1;
66
- for (let e of Array.from(f.keys())) p(e);
68
+ for (let e of h) g(e, b.get(o(e)) ?? 0);
69
+ }, b = () => {
70
+ r?.disconnect(), r = null, s = null, d = !1;
71
+ for (let e of Array.from(p.keys())) h(e);
67
72
  };
68
73
  return {
69
74
  update: ({ scrollContainerRef: e, skeletonEnter: t, mountEnter: n }) => {
70
- d = {
75
+ f = {
71
76
  skeletonEnter: t,
72
77
  mountEnter: n
73
78
  };
74
79
  let i = t || n ? e.current : null;
75
- i === o && n === u || (v(), !(!i || typeof MutationObserver > "u") && (r = new MutationObserver(_), r.observe(i, n ? {
80
+ i === s && n === d || (b(), !(!i || typeof MutationObserver > "u") && (r = new MutationObserver(y), r.observe(i, n ? {
76
81
  childList: !0,
77
82
  subtree: !0,
78
83
  attributes: !0,
@@ -81,10 +86,10 @@ var t = "ssg-body-row--enter", n = "--ssg-row-enter-index", r = 12, i = 1500, a
81
86
  } : {
82
87
  childList: !0,
83
88
  subtree: !0
84
- }), o = i, u = n));
89
+ }), s = i, d = n));
85
90
  },
86
- dispose: v
91
+ dispose: b
87
92
  };
88
93
  };
89
94
  //#endregion
90
- export { t as ROW_ENTER_CLASS_NAME, i as ROW_ENTER_FALLBACK_MS, n as ROW_ENTER_INDEX_VAR, r as ROW_ENTER_STAGGER_CAP, u as createRowEnterController, s as transformOfStyleText };
95
+ export { t as ROW_ENTER_CLASS_NAME, i as ROW_ENTER_FALLBACK_MS, n as ROW_ENTER_INDEX_VAR, a as ROW_ENTER_LIVE_WINDOW_MS, r as ROW_ENTER_STAGGER_CAP, d as createRowEnterController, c as transformOfStyleText };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("./popoverSupport.cjs"),n=require("../logic/panelDragGeometry.cjs");var r=360,i=420,a=336,o=8,s=12,c=[`filter`,`columns`,`sort`],l=(e,t,n)=>{let r=Math.max(0,Math.min(420,t-o*2)),i=n?Math.min(a,r):r,s=e;s+i>t-o&&(s=Math.max(o,t-o-i));let c=Math.max(0,Math.min(420,t-o-s));return{top:s,maxHeight:c}},u=e=>{let t={filter:e.canUseFilterTab,columns:e.canUseColumnsTab,sort:e.canUseSortTab};return c.filter(e=>t[e])},d=(e,t)=>e===null?null:t.includes(e)?e:t[0]??null,f=()=>{let i=null,a=e.createValueStore({requestedTab:null,layout:null,flashTick:0}),c={current:null},f=null,p=e=>{a.setSnapshot({...a.getSnapshot(),...e})},m=e=>{let t=a.getSnapshot().layout;t===e||t!==null&&e!==null&&t.top===e.top&&t.left===e.left&&t.width===e.width&&t.maxHeight===e.maxHeight||p({layout:e})},h=e=>n.clampPanelDragPosition({top:e.top,left:e.left,panelWidth:r,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}),g=e=>{let t=l(e.top,window.innerHeight,!0);return{top:t.top,left:e.left,width:r,maxHeight:t.maxHeight}},_=()=>{if(f){m(g(h(f)));return}let e=i?.gridRootRef.current??null;if(!e){m(null);return}let t=e.getBoundingClientRect(),n=t.right-r-s,a=t.top+s;n=Math.max(o,n),n=Math.min(n,window.innerWidth-r-o),a=Math.max(o,a);let c=l(a,window.innerHeight,!1);m({top:c.top,left:n,width:r,maxHeight:c.maxHeight})},v=()=>i!==null&&d(a.getSnapshot().requestedTab,u(i))!==null,y=e=>{p({requestedTab:null,layout:null}),S(),i!==null&&e&&t.restoreGridFocus(i.gridRootRef)},b=()=>y(!0),x=t.createPopoverWindowBindings({onResize:_,onScroll:_,isInside:e=>c.current?.contains(e)===!0||i?.alliedRef?.current?.contains(e)===!0,onOutsidePointerDown:e=>y(i!==null&&t.isInsideGridRoot(i.gridRootRef,e)),getGridRoot:()=>i?.gridRootRef.current??null,onGridHidden:()=>y(!1),onKeyDown:e=>{if(e.key===`Escape`){if(i?.suppressEscape){i.onSuppressedEscape?.();return}e.preventDefault(),b()}}}),S=()=>{let e=v();e&&!x.isAttached()?(_(),x.attach()):!e&&x.isAttached()&&x.detach()};return{update:e=>{i=e,S()},subscribe:a.subscribe,getSnapshot:a.getSnapshot,panelRef:c,open:e=>{if(i===null||!u(i).includes(e))return;let n=a.getSnapshot();t.blurForPopover(i.gridRootRef.current),p({requestedTab:e,flashTick:n.requestedTab===null?n.flashTick:n.flashTick+1}),S()},close:b,move:(e,t)=>{let n=h({top:e,left:t});f=n,p({layout:g(n)})},dispose:()=>{x.detach()}}};exports.TOOL_PANEL_MAX_HEIGHT=i,exports.createToolPanelController=f,exports.resolveActiveToolPanelTab=d,exports.resolveAvailableToolPanelTabs=u,exports.resolveToolPanelVerticalPlacement=l;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs");require("./escapeClaimController.cjs");const t=require("./popoverSupport.cjs"),n=require("../logic/panelDragGeometry.cjs");var r=360,i=420,a=336,o=8,s=12,c=[`filter`,`columns`,`sort`],l=(e,t,n)=>{let r=Math.max(0,Math.min(420,t-o*2)),i=n?Math.min(a,r):r,s=e;s+i>t-o&&(s=Math.max(o,t-o-i));let c=Math.max(0,Math.min(420,t-o-s));return{top:s,maxHeight:c}},u=e=>{let t={filter:e.canUseFilterTab,columns:e.canUseColumnsTab,sort:e.canUseSortTab};return c.filter(e=>t[e])},d=(e,t)=>e===null?null:t.includes(e)?e:t[0]??null,f=()=>{let i=null,a=e.createValueStore({requestedTab:null,layout:null,flashTick:0}),c={current:null},f=null,p=e=>{a.setSnapshot({...a.getSnapshot(),...e})},m=e=>{let t=a.getSnapshot().layout;t===e||t!==null&&e!==null&&t.top===e.top&&t.left===e.left&&t.width===e.width&&t.maxHeight===e.maxHeight||p({layout:e})},h=e=>n.clampPanelDragPosition({top:e.top,left:e.left,panelWidth:r,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}),g=e=>{let t=l(e.top,window.innerHeight,!0);return{top:t.top,left:e.left,width:r,maxHeight:t.maxHeight}},_=()=>{if(f){m(g(h(f)));return}let e=i?.gridRootRef.current??null;if(!e){m(null);return}let t=e.getBoundingClientRect(),n=t.right-r-s,a=t.top+s;n=Math.max(o,n),n=Math.min(n,window.innerWidth-r-o),a=Math.max(o,a);let c=l(a,window.innerHeight,!1);m({top:c.top,left:n,width:r,maxHeight:c.maxHeight})},v=()=>i!==null&&d(a.getSnapshot().requestedTab,u(i))!==null,y=null,b=(e,n=!1)=>{let r=y;if(y=null,p({requestedTab:null,layout:null}),C(),!(i===null||!e)){if(n&&r!==null&&r.isConnected&&r!==i.gridRootRef.current){let e=document.activeElement;if(e===r||(e===null||e===document.body||c.current?.contains(e)===!0)&&(r.focus({preventScroll:!0}),document.activeElement===r))return}t.restoreGridFocus(i.gridRootRef)}},x=()=>b(!0,!0),S=t.createPopoverWindowBindings({onResize:_,onScroll:_,isInside:e=>c.current?.contains(e)===!0||i?.alliedRef?.current?.contains(e)===!0,onOutsidePointerDown:e=>b(i!==null&&t.isInsideGridRoot(i.gridRootRef,e)),getGridRoot:()=>i?.gridRootRef.current??null,onGridHidden:()=>b(!1),onKeyDown:e=>{if(e.key===`Escape`){if(i?.suppressEscape){i.onSuppressedEscape?.();return}e.preventDefault(),x()}}}),C=()=>{let e=v();e&&!S.isAttached()?(_(),S.attach()):!e&&S.isAttached()&&S.detach()};return{update:e=>{i=e,C()},subscribe:a.subscribe,getSnapshot:a.getSnapshot,panelRef:c,open:e=>{if(i===null||!u(i).includes(e))return;let n=a.getSnapshot();if(n.requestedTab===null){let e=document.activeElement;y=e instanceof HTMLElement&&e!==document.body&&e.closest(`.ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover`)===null?e:null}c.current?.contains(document.activeElement)!==!0&&t.blurForPopover(i.gridRootRef.current),p({requestedTab:e,flashTick:n.requestedTab===null?n.flashTick:n.flashTick+1}),C()},close:x,move:(e,t)=>{let n=h({top:e,left:t});f=n,p({layout:g(n)})},dispose:()=>{S.detach()}}};exports.TOOL_PANEL_MAX_HEIGHT=i,exports.createToolPanelController=f,exports.resolveActiveToolPanelTab=d,exports.resolveAvailableToolPanelTabs=u,exports.resolveToolPanelVerticalPlacement=l;
@@ -1,4 +1,5 @@
1
1
  import { createValueStore as e } from "../logic/valueStore.js";
2
+ import "./escapeClaimController.js";
2
3
  import { blurForPopover as t, createPopoverWindowBindings as n, isInsideGridRoot as r, restoreGridFocus as i } from "./popoverSupport.js";
3
4
  import { clampPanelDragPosition as a } from "../logic/panelDragGeometry.js";
4
5
  //#region src/controllers/toolPanelController.ts
@@ -67,34 +68,41 @@ var o = 360, s = 420, c = 336, l = 8, u = 12, d = [
67
68
  width: o,
68
69
  maxHeight: i.maxHeight
69
70
  });
70
- }, x = () => s !== null && m(c.getSnapshot().requestedTab, p(s)) !== null, S = (e) => {
71
- g({
71
+ }, x = () => s !== null && m(c.getSnapshot().requestedTab, p(s)) !== null, S = null, C = (e, t = !1) => {
72
+ let n = S;
73
+ if (S = null, g({
72
74
  requestedTab: null,
73
75
  layout: null
74
- }), T(), s !== null && e && i(s.gridRootRef);
75
- }, C = () => S(!0), w = n({
76
+ }), E(), !(s === null || !e)) {
77
+ if (t && n !== null && n.isConnected && n !== s.gridRootRef.current) {
78
+ let e = document.activeElement;
79
+ if (e === n || (e === null || e === document.body || d.current?.contains(e) === !0) && (n.focus({ preventScroll: !0 }), document.activeElement === n)) return;
80
+ }
81
+ i(s.gridRootRef);
82
+ }
83
+ }, w = () => C(!0, !0), T = n({
76
84
  onResize: b,
77
85
  onScroll: b,
78
86
  isInside: (e) => d.current?.contains(e) === !0 || s?.alliedRef?.current?.contains(e) === !0,
79
- onOutsidePointerDown: (e) => S(s !== null && r(s.gridRootRef, e)),
87
+ onOutsidePointerDown: (e) => C(s !== null && r(s.gridRootRef, e)),
80
88
  getGridRoot: () => s?.gridRootRef.current ?? null,
81
- onGridHidden: () => S(!1),
89
+ onGridHidden: () => C(!1),
82
90
  onKeyDown: (e) => {
83
91
  if (e.key === "Escape") {
84
92
  if (s?.suppressEscape) {
85
93
  s.onSuppressedEscape?.();
86
94
  return;
87
95
  }
88
- e.preventDefault(), C();
96
+ e.preventDefault(), w();
89
97
  }
90
98
  }
91
- }), T = () => {
99
+ }), E = () => {
92
100
  let e = x();
93
- e && !w.isAttached() ? (b(), w.attach()) : !e && w.isAttached() && w.detach();
101
+ e && !T.isAttached() ? (b(), T.attach()) : !e && T.isAttached() && T.detach();
94
102
  };
95
103
  return {
96
104
  update: (e) => {
97
- s = e, T();
105
+ s = e, E();
98
106
  },
99
107
  subscribe: c.subscribe,
100
108
  getSnapshot: c.getSnapshot,
@@ -102,12 +110,16 @@ var o = 360, s = 420, c = 336, l = 8, u = 12, d = [
102
110
  open: (e) => {
103
111
  if (s === null || !p(s).includes(e)) return;
104
112
  let n = c.getSnapshot();
105
- t(s.gridRootRef.current), g({
113
+ if (n.requestedTab === null) {
114
+ let e = document.activeElement;
115
+ S = e instanceof HTMLElement && e !== document.body && e.closest(".ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover") === null ? e : null;
116
+ }
117
+ d.current?.contains(document.activeElement) !== !0 && t(s.gridRootRef.current), g({
106
118
  requestedTab: e,
107
119
  flashTick: n.requestedTab === null ? n.flashTick : n.flashTick + 1
108
- }), T();
120
+ }), E();
109
121
  },
110
- close: C,
122
+ close: w,
111
123
  move: (e, t) => {
112
124
  let n = v({
113
125
  top: e,
@@ -116,7 +128,7 @@ var o = 360, s = 420, c = 336, l = 8, u = 12, d = [
116
128
  h = n, g({ layout: y(n) });
117
129
  },
118
130
  dispose: () => {
119
- w.detach();
131
+ T.detach();
120
132
  }
121
133
  };
122
134
  };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/slotDom.cjs"),t=require("../utils/portalTokens.cjs"),n=require("../logic/tooltipGeometry.cjs");var r=`data-ssg-tooltip`,i=`data-ssg-tooltip-overflow`,a=`[${r}], [${i}]`,o=350,s=800,c=0,l=null,u=null,d=0,f=null,p,m,h=null,g=null;function _(t){m=e.applySlotToElement(t,p,m)}function v(){if(l!==null)return l;let e=document.createElement(`div`);return e.className=`ssg-tooltip`,e.setAttribute(`aria-hidden`,`true`),m=void 0,_(e),document.body.appendChild(e),l=e,e}function y(){u!==null&&(window.clearTimeout(u),u=null)}var b=null;function x(){b!==null&&(cancelAnimationFrame(b),b=null)}function S(){if(x(),typeof requestAnimationFrame!=`function`)return;let e=()=>{if(b=null,f!==null){if(!f.isConnected){C();return}b=requestAnimationFrame(e)}};b=requestAnimationFrame(e)}function C(){y(),x(),f!==null&&(d=Date.now()+s),f=null,h=null,g=null,l!==null&&l.classList.remove(`ssg-tooltip--visible`)}function w(e){if(!e.isConnected)return;let a=e.getAttribute(r),o=e.getAttribute(i),s=a!==null&&a!==``?a:o!==null&&o!==``?o:(e.textContent??``).trim();if(s===``)return;let c=v();c.classList.toggle(`ssg-theme-dark`,e.closest(`.ssg-theme-dark`)!==null),c.classList.toggle(`ssg-theme-class`,e.closest(`.ssg-theme-class`)!==null),c.classList.toggle(`ssg-motion-off`,e.closest(`.ssg-motion-off`)!==null),t.syncPortalTokens(e,c),c.textContent=s,c.style.left=`0px`,c.style.top=`0px`;let l=n.computeTooltipPlacement({targetRect:e.getBoundingClientRect(),tipWidth:c.offsetWidth,tipHeight:c.offsetHeight,viewportWidth:window.innerWidth});c.style.left=`${l.left}px`,c.style.top=`${l.top}px`,c.classList.add(`ssg-tooltip--visible`),f=e,S()}function T(e){let t=e.target;if(!(t instanceof Element)||typeof PointerEvent<`u`&&e instanceof PointerEvent&&e.buttons!==0)return;let n=t.closest(a);if(n===null||n===f||!n.hasAttribute(r)&&n.scrollWidth<=n.clientWidth+1)return;let i=f!==null;C(),i||Date.now()<d?w(n):u=window.setTimeout(()=>{u=null,w(n)},o)}function E(e){let t=e.target;if(!(t instanceof Element))return;if(e.type===`focusout`&&g!==null&&g.contains(t)){let t=e.relatedTarget;if(!(t instanceof Node&&g.contains(t))){C();return}}let n=t.closest(a);if(n===null||n===h&&typeof PointerEvent<`u`&&e instanceof PointerEvent&&e.pointerType!==`mouse`)return;let r=e.relatedTarget;r instanceof Node&&n.contains(r)||C()}function D(){C()}function O(e){h!==null&&f===h&&typeof PointerEvent<`u`&&e instanceof PointerEvent&&e.pointerType!==`mouse`&&e.target instanceof Node&&h.contains(e.target)||C()}function k(e){e.key===`Escape`&&C()}function A(){window.addEventListener(`pointerover`,T,!0),window.addEventListener(`pointerout`,E,!0),window.addEventListener(`focusin`,T,!0),window.addEventListener(`focusout`,E,!0),window.addEventListener(`pointerdown`,O,!0),window.addEventListener(`scroll`,D,!0),window.addEventListener(`keydown`,k,!0)}function j(){window.removeEventListener(`pointerover`,T,!0),window.removeEventListener(`pointerout`,E,!0),window.removeEventListener(`focusin`,T,!0),window.removeEventListener(`focusout`,E,!0),window.removeEventListener(`pointerdown`,O,!0),window.removeEventListener(`scroll`,D,!0),window.removeEventListener(`keydown`,k,!0)}function M(e,t){if(typeof requestAnimationFrame!=`function`||c===0)return()=>{};let n=requestAnimationFrame(()=>{n=requestAnimationFrame(()=>{n=0;let i=document.getElementById(e);if(!(i!==null&&t!==null&&t.contains(document.activeElement)&&i.classList.contains(`ssg-body-cell--invalid`)&&(i.getAttribute(r)??``)!==``)){N(t);return}f!==i&&(C(),w(i)),f===i&&(h=i,g=t)})});return()=>{n!==0&&cancelAnimationFrame(n)}}function N(e){h===null||e!==void 0&&e!==g||(f===h&&C(),h=null,g=null)}function P(e){c+=1,c===1&&A();let t=!1,n=e=>{p=e,l!==null&&_(l)};return n(e),{setSlot:n,dispose:()=>{t||(t=!0,--c,c===0&&(j(),y(),x(),f=null,h=null,g=null,l!==null&&(l.remove(),l=null)))}}}exports.acquireTooltipController=P,exports.hideActiveCellTooltip=N,exports.scheduleActiveCellTooltip=M;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/slotDom.cjs"),t=require("../utils/portalTokens.cjs"),n=require("../utils/popupContainer.cjs"),r=require("../logic/tooltipGeometry.cjs");var i=`data-ssg-tooltip`,a=`data-ssg-tooltip-overflow`,o=`[${i}], [${a}]`,s=350,c=800,l=0,u=null,d=null,f=0,p=null,m,h,g=null,_=null,v=new WeakMap;function y(t){h=e.applySlotToElement(t,m,h)}function b(e){let t=n.getPopupContainerFor(e);if(u!==null)return n.appendToPopupContainer(u,t),u;let r=document.createElement(`div`);return r.className=`ssg-tooltip`,r.setAttribute(`aria-hidden`,`true`),h=void 0,y(r),n.appendToPopupContainer(r,t),u=r,r}function x(){d!==null&&(window.clearTimeout(d),d=null)}var S=null;function C(){S!==null&&(cancelAnimationFrame(S),S=null)}function w(){if(C(),typeof requestAnimationFrame!=`function`)return;let e=()=>{if(S=null,p!==null){if(!p.isConnected){T();return}S=requestAnimationFrame(e)}};S=requestAnimationFrame(e)}function T(){x(),C(),p!==null&&(f=Date.now()+c),p=null,g=null,_=null,u!==null&&u.classList.remove(`ssg-tooltip--visible`)}function E(e){if(!e.isConnected)return;let n=e.getAttribute(i),o=e.getAttribute(a),s=n!==null&&n!==``?n:o!==null&&o!==``?o:(e.textContent??``).trim();if(s===``)return;let c=b(e);c.classList.toggle(`ssg-theme-dark`,e.closest(`.ssg-theme-dark`)!==null),c.classList.toggle(`ssg-theme-class`,e.closest(`.ssg-theme-class`)!==null),c.classList.toggle(`ssg-motion-off`,e.closest(`.ssg-motion-off`)!==null),t.syncPortalTokens(e,c),c.textContent=s,c.style.left=`0px`,c.style.top=`0px`;let l=r.computeTooltipPlacement({targetRect:e.getBoundingClientRect(),tipWidth:c.offsetWidth,tipHeight:c.offsetHeight,viewportWidth:window.innerWidth});c.style.left=`${l.left}px`,c.style.top=`${l.top}px`,c.classList.add(`ssg-tooltip--visible`),p=e,w()}function D(e){if(e.scrollWidth>e.clientWidth+1)return!0;for(let t of Array.from(e.children))if(t.scrollWidth>t.clientWidth+1)return!0;return!1}function O(e){let t=e.target;if(!(t instanceof Element)||typeof PointerEvent<`u`&&e instanceof PointerEvent&&e.buttons!==0)return;let n=t.closest(o);if(n===null||n===p||!n.hasAttribute(i)&&!D(n))return;let r=p!==null;T(),r||Date.now()<f?E(n):d=window.setTimeout(()=>{d=null,E(n)},s)}function k(e){let t=e.target;if(!(t instanceof Element))return;if(e.type===`focusout`&&_!==null&&_.contains(t)){let t=e.relatedTarget;if(!(t instanceof Node&&_.contains(t))){T();return}}let n=t.closest(o);if(n===null||n===g&&typeof PointerEvent<`u`&&e instanceof PointerEvent&&e.pointerType!==`mouse`)return;let r=e.relatedTarget;r instanceof Node&&n.contains(r)||T()}function A(){T()}function j(e){g!==null&&p===g&&typeof PointerEvent<`u`&&e instanceof PointerEvent&&e.pointerType!==`mouse`&&e.target instanceof Node&&g.contains(e.target)||T()}function M(e){let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`.ssg-shell`),r=n===null?void 0:v.get(n);if(n===null||r===void 0)return;let i=document.getElementById(r);i===null||p===i||!i.contains(t)||I(r,n)}function N(e){e.key===`Escape`&&T()}function P(){window.addEventListener(`pointerover`,O,!0),window.addEventListener(`pointerout`,k,!0),window.addEventListener(`focusin`,O,!0),window.addEventListener(`focusout`,k,!0),window.addEventListener(`pointerdown`,j,!0),window.addEventListener(`pointerup`,M,!0),window.addEventListener(`scroll`,A,!0),window.addEventListener(`keydown`,N,!0)}function F(){window.removeEventListener(`pointerover`,O,!0),window.removeEventListener(`pointerout`,k,!0),window.removeEventListener(`focusin`,O,!0),window.removeEventListener(`focusout`,k,!0),window.removeEventListener(`pointerdown`,j,!0),window.removeEventListener(`pointerup`,M,!0),window.removeEventListener(`scroll`,A,!0),window.removeEventListener(`keydown`,N,!0)}function I(e,t){if(typeof requestAnimationFrame!=`function`||l===0)return()=>{};t!==null&&v.set(t,e);let n=requestAnimationFrame(()=>{n=requestAnimationFrame(()=>{if(n=0,t!==null&&v.get(t)!==e)return;let r=document.getElementById(e);if(!(r!==null&&t!==null&&t.contains(document.activeElement)&&r.classList.contains(`ssg-body-cell--invalid`)&&(r.getAttribute(i)??``)!==``)){R(t);return}p!==r&&(T(),E(r)),p===r&&(g=r,_=t)})});return()=>{n!==0&&cancelAnimationFrame(n)}}function L(e){e&&v.delete(e),R(e)}function R(e){g===null||e!==void 0&&e!==_||(p===g&&T(),g=null,_=null)}function z(e){l+=1,l===1&&P();let t=!1,n=e=>{m=e,u!==null&&y(u)};return n(e),{setSlot:n,dispose:()=>{t||(t=!0,--l,l===0&&(F(),x(),C(),p=null,g=null,_=null,u!==null&&(u.remove(),u=null)))}}}exports.acquireTooltipController=z,exports.hideActiveCellTooltip=L,exports.scheduleActiveCellTooltip=I;
@@ -1,124 +1,143 @@
1
1
  import { applySlotToElement as e } from "../logic/slotDom.js";
2
2
  import { syncPortalTokens as t } from "../utils/portalTokens.js";
3
- import { computeTooltipPlacement as n } from "../logic/tooltipGeometry.js";
3
+ import { appendToPopupContainer as n, getPopupContainerFor as r } from "../utils/popupContainer.js";
4
+ import { computeTooltipPlacement as i } from "../logic/tooltipGeometry.js";
4
5
  //#region src/controllers/tooltipController.ts
5
- var r = "data-ssg-tooltip", i = "data-ssg-tooltip-overflow", a = `[${r}], [${i}]`, o = 350, s = 800, c = 0, l = null, u = null, d = 0, f = null, p, m, h = null, g = null;
6
- function _(t) {
7
- m = e(t, p, m);
6
+ var a = "data-ssg-tooltip", o = "data-ssg-tooltip-overflow", s = `[${a}], [${o}]`, c = 350, l = 800, u = 0, d = null, f = null, p = 0, m = null, h, g, _ = null, v = null, y = /* @__PURE__ */ new WeakMap();
7
+ function b(t) {
8
+ g = e(t, h, g);
8
9
  }
9
- function v() {
10
- if (l !== null) return l;
11
- let e = document.createElement("div");
12
- return e.className = "ssg-tooltip", e.setAttribute("aria-hidden", "true"), m = void 0, _(e), document.body.appendChild(e), l = e, e;
10
+ function x(e) {
11
+ let t = r(e);
12
+ if (d !== null) return n(d, t), d;
13
+ let i = document.createElement("div");
14
+ return i.className = "ssg-tooltip", i.setAttribute("aria-hidden", "true"), g = void 0, b(i), n(i, t), d = i, i;
13
15
  }
14
- function y() {
15
- u !== null && (window.clearTimeout(u), u = null);
16
+ function S() {
17
+ f !== null && (window.clearTimeout(f), f = null);
16
18
  }
17
- var b = null;
18
- function x() {
19
- b !== null && (cancelAnimationFrame(b), b = null);
19
+ var C = null;
20
+ function w() {
21
+ C !== null && (cancelAnimationFrame(C), C = null);
20
22
  }
21
- function S() {
22
- if (x(), typeof requestAnimationFrame != "function") return;
23
+ function T() {
24
+ if (w(), typeof requestAnimationFrame != "function") return;
23
25
  let e = () => {
24
- if (b = null, f !== null) {
25
- if (!f.isConnected) {
26
- C();
26
+ if (C = null, m !== null) {
27
+ if (!m.isConnected) {
28
+ E();
27
29
  return;
28
30
  }
29
- b = requestAnimationFrame(e);
31
+ C = requestAnimationFrame(e);
30
32
  }
31
33
  };
32
- b = requestAnimationFrame(e);
34
+ C = requestAnimationFrame(e);
33
35
  }
34
- function C() {
35
- y(), x(), f !== null && (d = Date.now() + s), f = null, h = null, g = null, l !== null && l.classList.remove("ssg-tooltip--visible");
36
+ function E() {
37
+ S(), w(), m !== null && (p = Date.now() + l), m = null, _ = null, v = null, d !== null && d.classList.remove("ssg-tooltip--visible");
36
38
  }
37
- function w(e) {
39
+ function D(e) {
38
40
  if (!e.isConnected) return;
39
- let a = e.getAttribute(r), o = e.getAttribute(i), s = a !== null && a !== "" ? a : o !== null && o !== "" ? o : (e.textContent ?? "").trim();
41
+ let n = e.getAttribute(a), r = e.getAttribute(o), s = n !== null && n !== "" ? n : r !== null && r !== "" ? r : (e.textContent ?? "").trim();
40
42
  if (s === "") return;
41
- let c = v();
43
+ let c = x(e);
42
44
  c.classList.toggle("ssg-theme-dark", e.closest(".ssg-theme-dark") !== null), c.classList.toggle("ssg-theme-class", e.closest(".ssg-theme-class") !== null), c.classList.toggle("ssg-motion-off", e.closest(".ssg-motion-off") !== null), t(e, c), c.textContent = s, c.style.left = "0px", c.style.top = "0px";
43
- let l = n({
45
+ let l = i({
44
46
  targetRect: e.getBoundingClientRect(),
45
47
  tipWidth: c.offsetWidth,
46
48
  tipHeight: c.offsetHeight,
47
49
  viewportWidth: window.innerWidth
48
50
  });
49
- c.style.left = `${l.left}px`, c.style.top = `${l.top}px`, c.classList.add("ssg-tooltip--visible"), f = e, S();
51
+ c.style.left = `${l.left}px`, c.style.top = `${l.top}px`, c.classList.add("ssg-tooltip--visible"), m = e, T();
50
52
  }
51
- function T(e) {
53
+ function O(e) {
54
+ if (e.scrollWidth > e.clientWidth + 1) return !0;
55
+ for (let t of Array.from(e.children)) if (t.scrollWidth > t.clientWidth + 1) return !0;
56
+ return !1;
57
+ }
58
+ function k(e) {
52
59
  let t = e.target;
53
60
  if (!(t instanceof Element) || typeof PointerEvent < "u" && e instanceof PointerEvent && e.buttons !== 0) return;
54
- let n = t.closest(a);
55
- if (n === null || n === f || !n.hasAttribute(r) && n.scrollWidth <= n.clientWidth + 1) return;
56
- let i = f !== null;
57
- C(), i || Date.now() < d ? w(n) : u = window.setTimeout(() => {
58
- u = null, w(n);
59
- }, o);
60
- }
61
- function E(e) {
61
+ let n = t.closest(s);
62
+ if (n === null || n === m || !n.hasAttribute(a) && !O(n)) return;
63
+ let r = m !== null;
64
+ E(), r || Date.now() < p ? D(n) : f = window.setTimeout(() => {
65
+ f = null, D(n);
66
+ }, c);
67
+ }
68
+ function A(e) {
62
69
  let t = e.target;
63
70
  if (!(t instanceof Element)) return;
64
- if (e.type === "focusout" && g !== null && g.contains(t)) {
71
+ if (e.type === "focusout" && v !== null && v.contains(t)) {
65
72
  let t = e.relatedTarget;
66
- if (!(t instanceof Node && g.contains(t))) {
67
- C();
73
+ if (!(t instanceof Node && v.contains(t))) {
74
+ E();
68
75
  return;
69
76
  }
70
77
  }
71
- let n = t.closest(a);
72
- if (n === null || n === h && typeof PointerEvent < "u" && e instanceof PointerEvent && e.pointerType !== "mouse") return;
78
+ let n = t.closest(s);
79
+ if (n === null || n === _ && typeof PointerEvent < "u" && e instanceof PointerEvent && e.pointerType !== "mouse") return;
73
80
  let r = e.relatedTarget;
74
- r instanceof Node && n.contains(r) || C();
81
+ r instanceof Node && n.contains(r) || E();
75
82
  }
76
- function D() {
77
- C();
83
+ function j() {
84
+ E();
78
85
  }
79
- function O(e) {
80
- h !== null && f === h && typeof PointerEvent < "u" && e instanceof PointerEvent && e.pointerType !== "mouse" && e.target instanceof Node && h.contains(e.target) || C();
86
+ function M(e) {
87
+ _ !== null && m === _ && typeof PointerEvent < "u" && e instanceof PointerEvent && e.pointerType !== "mouse" && e.target instanceof Node && _.contains(e.target) || E();
81
88
  }
82
- function k(e) {
83
- e.key === "Escape" && C();
89
+ function N(e) {
90
+ let t = e.target;
91
+ if (!(t instanceof Element)) return;
92
+ let n = t.closest(".ssg-shell"), r = n === null ? void 0 : y.get(n);
93
+ if (n === null || r === void 0) return;
94
+ let i = document.getElementById(r);
95
+ i === null || m === i || !i.contains(t) || L(r, n);
84
96
  }
85
- function A() {
86
- window.addEventListener("pointerover", T, !0), window.addEventListener("pointerout", E, !0), window.addEventListener("focusin", T, !0), window.addEventListener("focusout", E, !0), window.addEventListener("pointerdown", O, !0), window.addEventListener("scroll", D, !0), window.addEventListener("keydown", k, !0);
97
+ function P(e) {
98
+ e.key === "Escape" && E();
87
99
  }
88
- function j() {
89
- window.removeEventListener("pointerover", T, !0), window.removeEventListener("pointerout", E, !0), window.removeEventListener("focusin", T, !0), window.removeEventListener("focusout", E, !0), window.removeEventListener("pointerdown", O, !0), window.removeEventListener("scroll", D, !0), window.removeEventListener("keydown", k, !0);
100
+ function F() {
101
+ window.addEventListener("pointerover", k, !0), window.addEventListener("pointerout", A, !0), window.addEventListener("focusin", k, !0), window.addEventListener("focusout", A, !0), window.addEventListener("pointerdown", M, !0), window.addEventListener("pointerup", N, !0), window.addEventListener("scroll", j, !0), window.addEventListener("keydown", P, !0);
90
102
  }
91
- function M(e, t) {
92
- if (typeof requestAnimationFrame != "function" || c === 0) return () => {};
103
+ function I() {
104
+ window.removeEventListener("pointerover", k, !0), window.removeEventListener("pointerout", A, !0), window.removeEventListener("focusin", k, !0), window.removeEventListener("focusout", A, !0), window.removeEventListener("pointerdown", M, !0), window.removeEventListener("pointerup", N, !0), window.removeEventListener("scroll", j, !0), window.removeEventListener("keydown", P, !0);
105
+ }
106
+ function L(e, t) {
107
+ if (typeof requestAnimationFrame != "function" || u === 0) return () => {};
108
+ t !== null && y.set(t, e);
93
109
  let n = requestAnimationFrame(() => {
94
110
  n = requestAnimationFrame(() => {
95
- n = 0;
96
- let i = document.getElementById(e);
97
- if (!(i !== null && t !== null && t.contains(document.activeElement) && i.classList.contains("ssg-body-cell--invalid") && (i.getAttribute(r) ?? "") !== "")) {
98
- N(t);
111
+ if (n = 0, t !== null && y.get(t) !== e) return;
112
+ let r = document.getElementById(e);
113
+ if (!(r !== null && t !== null && t.contains(document.activeElement) && r.classList.contains("ssg-body-cell--invalid") && (r.getAttribute(a) ?? "") !== "")) {
114
+ z(t);
99
115
  return;
100
116
  }
101
- f !== i && (C(), w(i)), f === i && (h = i, g = t);
117
+ m !== r && (E(), D(r)), m === r && (_ = r, v = t);
102
118
  });
103
119
  });
104
120
  return () => {
105
121
  n !== 0 && cancelAnimationFrame(n);
106
122
  };
107
123
  }
108
- function N(e) {
109
- h === null || e !== void 0 && e !== g || (f === h && C(), h = null, g = null);
124
+ function R(e) {
125
+ e && y.delete(e), z(e);
110
126
  }
111
- function P(e) {
112
- c += 1, c === 1 && A();
127
+ function z(e) {
128
+ _ === null || e !== void 0 && e !== v || (m === _ && E(), _ = null, v = null);
129
+ }
130
+ function B(e) {
131
+ u += 1, u === 1 && F();
113
132
  let t = !1, n = (e) => {
114
- p = e, l !== null && _(l);
133
+ h = e, d !== null && b(d);
115
134
  };
116
135
  return n(e), {
117
136
  setSlot: n,
118
137
  dispose: () => {
119
- t || (t = !0, --c, c === 0 && (j(), y(), x(), f = null, h = null, g = null, l !== null && (l.remove(), l = null)));
138
+ t || (t = !0, --u, u === 0 && (I(), S(), w(), m = null, _ = null, v = null, d !== null && (d.remove(), d = null)));
120
139
  }
121
140
  };
122
141
  }
123
142
  //#endregion
124
- export { P as acquireTooltipController, N as hideActiveCellTooltip, M as scheduleActiveCellTooltip };
143
+ export { B as acquireTooltipController, R as hideActiveCellTooltip, L as scheduleActiveCellTooltip };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/verticalGeometry.cjs");var t=(e,t)=>{let n=Math.max(t.totalScrollWidth-e.clientWidth,0),r=Math.max(t.headerHeight+t.physicalBodyHeight+(t.footerHeight??0)-e.clientHeight,0);e.scrollLeft>n&&(e.scrollLeft=n),e.scrollTop>r&&(e.scrollTop=r)},n=(t,n,r)=>{let i=r.headerHeight+n.top,a=i+n.height,o=r.leftPaneWidth+r.centerLeadingWidth+n.left,s=o+n.width,c=e.physicalToLogicalScrollTop(t.scrollTop,r.verticalScaleFactor),l=t.scrollLeft,u=t.clientHeight-(r.footerHeight??0),d=t.clientWidth,f=c,p=l,m=c+r.headerHeight+(r.stickyTopInset?.visibleAt(c)??0),h=c+u,g=()=>Math.max(i-r.headerHeight-(r.stickyTopInset?.coveringRowAt(n.top)??0),0);i<m?f=g():a>h&&(f=n.height>h-m?g():Math.max(a-u,0));let _=l+r.leftPaneWidth,v=l+d-r.rightPaneWidth,y=r.activeCellPinned===!0;if(!y&&o<_?p=Math.max(o-r.leftPaneWidth,0):!y&&s>v&&(p=Math.max(s-d+r.rightPaneWidth,0)),f!==c||p!==l){let n=e.logicalToPhysicalScrollTop(f,r.verticalScaleFactor);t.scrollTo({top:f>c?Math.ceil(n):n,left:p,behavior:`auto`})}},r=()=>{let t=null,n=1,r=0;return{update:(i,a,o)=>{let s=t,c=n,l=r;if(t=i,n=a,r=i!==null&&a!==1?Math.max(i.scrollHeight-i.clientHeight,0):0,i===null||i!==s||c===a)return;let u=i.scrollTop;if(l>0&&u>=l-1)return;let d=e.logicalToPhysicalScrollTop(e.physicalToLogicalScrollTop(u,c),a);Math.abs(d-u)<1||(i.scrollTop=d,i.scrollTop!==u&&o(i.scrollTop))}}},i=(e,t,n)=>e===null||n.some(n=>!Object.is(e[n],t[n])),a=()=>{let e=null,r=null;return{update:a=>{if(i(e,a,[`columnVirtualizer`,`columnMeasurements`])&&a.columnVirtualizer.measure(),i(e,a,[`scrollElement`,`totalScrollWidth`,`physicalBodyHeight`,`headerHeight`,`footerHeight`])&&a.scrollElement&&t(a.scrollElement,a),i(e,a,[`scrollElement`,`activeCellRect`,`activeCellPinned`,`activeCell`,`headerHeight`,`leftPaneWidth`,`rightPaneWidth`,`centerLeadingWidth`,`verticalScaleFactor`,`footerHeight`])){let e=r,{activeCell:t}=a,i=e!==null&&t!==null&&e.row===t.row&&e.col===t.col;r=t,!i&&a.scrollElement&&a.activeCellRect&&n(a.scrollElement,a.activeCellRect,a)}e=a}}};exports.clampScrollToContent=t,exports.createScrollScaleAnchor=r,exports.createViewportSyncController=a,exports.scrollCellIntoView=n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/verticalGeometry.cjs");var t=(e,t)=>{let n=Math.max(t.totalScrollWidth-e.clientWidth,0),r=Math.max(t.headerHeight+t.physicalBodyHeight+(t.footerHeight??0)-e.clientHeight,0);e.scrollLeft>n&&(e.scrollLeft=n),e.scrollTop>r&&(e.scrollTop=r)},n=(t,n,r)=>{let i=r.headerHeight+n.top,a=i+n.height,o=r.leftPaneWidth+r.centerLeadingWidth+n.left,s=o+n.width,c=e.physicalToLogicalScrollTop(t.scrollTop,r.verticalScaleFactor),l=t.scrollLeft,u=t.clientHeight-(r.footerHeight??0),d=t.clientWidth,f=c,p=l,m=c+r.headerHeight+(r.stickyTopInset?.visibleAt(c)??0),h=c+u,g=()=>Math.max(i-r.headerHeight-(r.stickyTopInset?.coveringRowAt(n.top)??0),0);i<m?f=g():a>h&&(f=n.height>h-m?g():Math.max(a-u,0));let _=l+r.leftPaneWidth,v=l+d-r.rightPaneWidth,y=r.activeCellPinned===!0;if(!y&&o<_||!y&&s>v&&n.width>v-_?p=Math.max(o-r.leftPaneWidth,0):!y&&s>v&&(p=Math.max(s-d+r.rightPaneWidth,0)),f!==c||p!==l){let n=e.logicalToPhysicalScrollTop(f,r.verticalScaleFactor);return t.scrollTo({top:f>c?Math.ceil(n):n,left:p,behavior:`auto`}),!0}return!1},r=(e,t,n,r)=>e<n?e-n:t>r?Math.min(t-r,e-n):0,i=(t,n,i)=>{let a=t.ownerDocument,o=a.defaultView,s=t.closest(`.ssg-shell`),c=a.activeElement;if(!o||!s||!c||c!==s&&!(c.classList.contains(`ssg-ime-input`)&&s.contains(c))||s.hasAttribute(`data-ssg-pointer`))return;let l=t.getBoundingClientRect();if(l.height===0)return;let u=e.physicalToLogicalScrollTop(t.scrollTop,i.verticalScaleFactor),d=l.top+t.clientTop+i.headerHeight+n.top-u,f=d+n.height;for(let e=t.parentElement;e&&e!==a.body&&e!==a.documentElement;e=e.parentElement){let t=e.scrollHeight-e.clientHeight;if(t<=0)continue;let n=o.getComputedStyle(e).overflowY;if(n!==`auto`&&n!==`scroll`&&n!==`overlay`)continue;let i=e.getBoundingClientRect().top+e.clientTop,a=r(d,f,i,i+e.clientHeight);if(a===0)continue;let s=e.scrollTop,c=Math.min(Math.max(s+a,0),t);e.scrollTop=c,d-=c-s,f-=c-s}let p=r(d,f,0,o.innerHeight);p!==0&&o.scrollBy({top:p,behavior:`auto`})},a=()=>{let t=null,n=1,r=0;return{update:(i,a,o)=>{let s=t,c=n,l=r;if(t=i,n=a,r=i!==null&&a!==1?Math.max(i.scrollHeight-i.clientHeight,0):0,i===null||i!==s||c===a)return;let u=i.scrollTop;if(l>0&&u>=l-1)return;let d=e.logicalToPhysicalScrollTop(e.physicalToLogicalScrollTop(u,c),a);Math.abs(d-u)<1||(i.scrollTop=d,i.scrollTop!==u&&o(i.scrollTop))}}},o=1e3,s=[`wheel`,`touchstart`,`pointerdown`,`pointerup`,`pointermove`,`keydown`],c=(e,t)=>e!==null&&e.top===t.top&&e.height===t.height&&e.left===t.left&&e.width===t.width,l=(e,t,n)=>e===null||n.some(n=>!Object.is(e[n],t[n])),u=()=>{let e=null,r=null,a=null,u=null,d=()=>{a=null,u?.(),u=null},f=e=>{e.type===`pointermove`&&!(e.buttons>0)||d()},p=(e,t)=>{d(),a={cell:t,until:Date.now()+o,left:e.scrollLeft};let n=e.ownerDocument,r=setTimeout(d,o);if(typeof n?.addEventListener!=`function`){u=()=>clearTimeout(r);return}for(let e of s)n.addEventListener(e,f,{capture:!0,passive:!0});u=()=>{clearTimeout(r);for(let e of s)n.removeEventListener(e,f,{capture:!0})}};return{update:o=>{if(l(e,o,[`columnVirtualizer`,`columnMeasurements`])&&o.columnVirtualizer.measure(),l(e,o,[`scrollElement`,`totalScrollWidth`,`physicalBodyHeight`,`headerHeight`,`footerHeight`])&&o.scrollElement&&t(o.scrollElement,o),l(e,o,[`scrollElement`,`activeCellRect`,`activeCellPinned`,`activeCell`,`headerHeight`,`leftPaneWidth`,`rightPaneWidth`,`centerLeadingWidth`,`verticalScaleFactor`,`footerHeight`])){let t=r,{activeCell:s}=o,l=t!==null&&s!==null&&t.row===s.row&&t.col===s.col;r=s,!l&&o.scrollElement&&o.activeCellRect&&s?(n(o.scrollElement,o.activeCellRect,o),i(o.scrollElement,o.activeCellRect,o),p(o.scrollElement,s)):l&&a!==null&&s!==null&&o.scrollElement&&o.activeCellRect&&a.cell.row===s.row&&a.cell.col===s.col&&!c(e?.activeCellRect??null,o.activeCellRect)&&(Date.now()>a.until||Math.abs(o.scrollElement.scrollLeft-a.left)>1?d():(n(o.scrollElement,o.activeCellRect,o),a={...a,left:o.scrollElement.scrollLeft}))}e=o},cancelFollow:d,dispose:d}};exports.clampScrollToContent=t,exports.createScrollScaleAnchor=a,exports.createViewportSyncController=u,exports.revealActiveCellInPage=i,exports.scrollCellIntoView=n;
@@ -28,9 +28,12 @@ export type ViewportSyncArgs<T> = {
28
28
  };
29
29
  export type ViewportSyncController<T> = {
30
30
  update: (args: ViewportSyncArgs<T>) => void;
31
+ cancelFollow: () => void;
32
+ dispose: () => void;
31
33
  };
32
34
  export declare const clampScrollToContent: (scrollElement: HTMLElement, args: Pick<ViewportSyncArgs<unknown>, "totalScrollWidth" | "physicalBodyHeight" | "headerHeight" | "footerHeight">) => void;
33
- export declare const scrollCellIntoView: (scrollElement: HTMLElement, rect: ViewportCellRect, args: Pick<ViewportSyncArgs<unknown>, "headerHeight" | "leftPaneWidth" | "rightPaneWidth" | "centerLeadingWidth" | "verticalScaleFactor" | "footerHeight" | "activeCellPinned" | "stickyTopInset">) => void;
35
+ export declare const scrollCellIntoView: (scrollElement: HTMLElement, rect: ViewportCellRect, args: Pick<ViewportSyncArgs<unknown>, "headerHeight" | "leftPaneWidth" | "rightPaneWidth" | "centerLeadingWidth" | "verticalScaleFactor" | "footerHeight" | "activeCellPinned" | "stickyTopInset">) => boolean;
36
+ export declare const revealActiveCellInPage: (scrollElement: HTMLElement, rect: ViewportCellRect, args: Pick<ViewportSyncArgs<unknown>, "headerHeight" | "verticalScaleFactor">) => void;
34
37
  export type ScrollScaleAnchor = {
35
38
  update: (scrollElement: HTMLElement | null, verticalScaleFactor: number, onAnchored: (scrollTop: number) => void) => void;
36
39
  };