@ishibashi0112/spreadsheet-grid-core 1.2.1 → 1.4.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 (82) hide show
  1. package/README.md +2 -2
  2. package/dist/controllers/clipboardController.cjs +1 -1
  3. package/dist/controllers/clipboardController.js +79 -71
  4. package/dist/controllers/columnMenuController.cjs +1 -1
  5. package/dist/controllers/columnMenuController.js +75 -73
  6. package/dist/controllers/contextMenuController.cjs +1 -1
  7. package/dist/controllers/contextMenuController.js +63 -61
  8. package/dist/controllers/detailRowController.cjs +1 -1
  9. package/dist/controllers/detailRowController.js +60 -59
  10. package/dist/controllers/detailTabOrder.cjs +1 -1
  11. package/dist/controllers/detailTabOrder.js +17 -16
  12. package/dist/controllers/editController.cjs +1 -1
  13. package/dist/controllers/editController.d.ts +4 -1
  14. package/dist/controllers/editController.js +163 -91
  15. package/dist/controllers/escapeClaimController.cjs +1 -1
  16. package/dist/controllers/escapeClaimController.js +23 -19
  17. package/dist/controllers/fillHandleController.cjs +1 -1
  18. package/dist/controllers/fillHandleController.js +107 -106
  19. package/dist/controllers/filterPopoverController.cjs +1 -1
  20. package/dist/controllers/filterPopoverController.js +1 -0
  21. package/dist/controllers/imeInputController.cjs +1 -1
  22. package/dist/controllers/imeInputController.js +87 -76
  23. package/dist/controllers/keyboardController.cjs +1 -1
  24. package/dist/controllers/keyboardController.d.ts +3 -0
  25. package/dist/controllers/keyboardController.js +15 -13
  26. package/dist/controllers/popoverSupport.cjs +1 -1
  27. package/dist/controllers/popoverSupport.d.ts +3 -0
  28. package/dist/controllers/popoverSupport.js +62 -41
  29. package/dist/controllers/toolPanelController.cjs +1 -1
  30. package/dist/controllers/toolPanelController.js +74 -73
  31. package/dist/controllers/tooltipController.cjs +1 -1
  32. package/dist/controllers/tooltipController.d.ts +1 -1
  33. package/dist/controllers/tooltipController.js +122 -97
  34. package/dist/controllers/viewportSyncController.cjs +1 -1
  35. package/dist/controllers/viewportSyncController.js +55 -54
  36. package/dist/engine/columnCommands.cjs +1 -1
  37. package/dist/engine/columnCommands.d.ts +2 -1
  38. package/dist/engine/columnCommands.js +98 -67
  39. package/dist/engine/exportCommands.cjs +1 -1
  40. package/dist/engine/exportCommands.js +2 -2
  41. package/dist/engine/gridApi.cjs +6 -5
  42. package/dist/engine/gridApi.d.ts +1 -0
  43. package/dist/engine/gridApi.js +151 -143
  44. package/dist/engine/rowSelectionCommands.cjs +1 -1
  45. package/dist/engine/rowSelectionCommands.d.ts +5 -0
  46. package/dist/engine/rowSelectionCommands.js +73 -38
  47. package/dist/locales/en.cjs +1 -1
  48. package/dist/locales/en.js +2 -2
  49. package/dist/logic/contextMenuTarget.cjs +1 -1
  50. package/dist/logic/contextMenuTarget.d.ts +20 -2
  51. package/dist/logic/contextMenuTarget.js +62 -3
  52. package/dist/logic/dateFilterCondition.cjs +1 -1
  53. package/dist/logic/dateFilterCondition.d.ts +1 -0
  54. package/dist/logic/dateFilterCondition.js +17 -13
  55. package/dist/logic/detailRow.cjs +1 -1
  56. package/dist/logic/detailRow.d.ts +2 -1
  57. package/dist/logic/detailRow.js +19 -18
  58. package/dist/logic/domGuards.cjs +1 -1
  59. package/dist/logic/domGuards.d.ts +5 -0
  60. package/dist/logic/domGuards.js +11 -1
  61. package/dist/logic/editorValues.cjs +1 -1
  62. package/dist/logic/editorValues.d.ts +1 -0
  63. package/dist/logic/editorValues.js +10 -7
  64. package/dist/logic/gridState.cjs +1 -1
  65. package/dist/logic/gridState.d.ts +1 -0
  66. package/dist/logic/gridState.js +19 -16
  67. package/dist/logic/localeText.cjs +1 -1
  68. package/dist/logic/localeText.js +2 -2
  69. package/dist/logic/rowDragTarget.cjs +1 -0
  70. package/dist/logic/rowDragTarget.d.ts +14 -0
  71. package/dist/logic/rowDragTarget.js +47 -0
  72. package/dist/logic/selectEditorState.d.ts +4 -4
  73. package/dist/logic/valueFormatters.d.ts +8 -3
  74. package/dist/model/gridTypes.core.d.ts +31 -12
  75. package/dist/utils/clipboard.cjs +4 -4
  76. package/dist/utils/clipboard.js +60 -59
  77. package/dist/utils/popupContainer.cjs +1 -1
  78. package/dist/utils/popupContainer.js +35 -28
  79. package/dist/utils/shadowDom.cjs +1 -0
  80. package/dist/utils/shadowDom.d.ts +5 -0
  81. package/dist/utils/shadowDom.js +33 -0
  82. package/package.json +1 -1
@@ -1,136 +1,137 @@
1
- import { createValueStore as e } from "../logic/valueStore.js";
1
+ import { getActiveElement as e } from "../utils/shadowDom.js";
2
+ import { createValueStore as t } from "../logic/valueStore.js";
2
3
  import "./escapeClaimController.js";
3
- import { blurForPopover as t, createPopoverWindowBindings as n, isInsideGridRoot as r, restoreGridFocus as i } from "./popoverSupport.js";
4
- import { clampPanelDragPosition as a } from "../logic/panelDragGeometry.js";
4
+ import { blurForPopover as n, createPopoverWindowBindings as r, isInsideGridRoot as i, restoreGridFocus as a } from "./popoverSupport.js";
5
+ import { clampPanelDragPosition as o } from "../logic/panelDragGeometry.js";
5
6
  //#region src/controllers/toolPanelController.ts
6
- var o = 360, s = 420, c = 336, l = 8, u = 12, d = [
7
+ var s = 360, c = 420, l = 336, u = 8, d = 12, f = [
7
8
  "filter",
8
9
  "columns",
9
10
  "sort"
10
- ], f = (e, t, n) => {
11
- let r = Math.max(0, Math.min(420, t - l * 2)), i = n ? Math.min(c, r) : r, a = e;
12
- a + i > t - l && (a = Math.max(l, t - l - i));
13
- let o = Math.max(0, Math.min(420, t - l - a));
11
+ ], p = (e, t, n) => {
12
+ let r = Math.max(0, Math.min(420, t - u * 2)), i = n ? Math.min(l, r) : r, a = e;
13
+ a + i > t - u && (a = Math.max(u, t - u - i));
14
+ let o = Math.max(0, Math.min(420, t - u - a));
14
15
  return {
15
16
  top: a,
16
17
  maxHeight: o
17
18
  };
18
- }, p = (e) => {
19
+ }, m = (e) => {
19
20
  let t = {
20
21
  filter: e.canUseFilterTab,
21
22
  columns: e.canUseColumnsTab,
22
23
  sort: e.canUseSortTab
23
24
  };
24
- return d.filter((e) => t[e]);
25
- }, m = (e, t) => e === null ? null : t.includes(e) ? e : t[0] ?? null, h = () => {
26
- let s = null, c = e({
25
+ return f.filter((e) => t[e]);
26
+ }, h = (e, t) => e === null ? null : t.includes(e) ? e : t[0] ?? null, g = () => {
27
+ let c = null, l = t({
27
28
  requestedTab: null,
28
29
  layout: null,
29
30
  flashTick: 0
30
- }), d = { current: null }, h = null, g = (e) => {
31
- c.setSnapshot({
32
- ...c.getSnapshot(),
31
+ }), f = { current: null }, g = null, _ = (e) => {
32
+ l.setSnapshot({
33
+ ...l.getSnapshot(),
33
34
  ...e
34
35
  });
35
- }, _ = (e) => {
36
- let t = c.getSnapshot().layout;
37
- t === e || t !== null && e !== null && t.top === e.top && t.left === e.left && t.width === e.width && t.maxHeight === e.maxHeight || g({ layout: e });
38
- }, v = (e) => a({
36
+ }, v = (e) => {
37
+ let t = l.getSnapshot().layout;
38
+ t === e || t !== null && e !== null && t.top === e.top && t.left === e.left && t.width === e.width && t.maxHeight === e.maxHeight || _({ layout: e });
39
+ }, y = (e) => o({
39
40
  top: e.top,
40
41
  left: e.left,
41
- panelWidth: o,
42
+ panelWidth: s,
42
43
  viewportWidth: window.innerWidth,
43
44
  viewportHeight: window.innerHeight
44
- }), y = (e) => {
45
- let t = f(e.top, window.innerHeight, !0);
45
+ }), b = (e) => {
46
+ let t = p(e.top, window.innerHeight, !0);
46
47
  return {
47
48
  top: t.top,
48
49
  left: e.left,
49
- width: o,
50
+ width: s,
50
51
  maxHeight: t.maxHeight
51
52
  };
52
- }, b = () => {
53
- if (h) {
54
- _(y(v(h)));
53
+ }, x = () => {
54
+ if (g) {
55
+ v(b(y(g)));
55
56
  return;
56
57
  }
57
- let e = s?.gridRootRef.current ?? null;
58
+ let e = c?.gridRootRef.current ?? null;
58
59
  if (!e) {
59
- _(null);
60
+ v(null);
60
61
  return;
61
62
  }
62
- let t = e.getBoundingClientRect(), n = t.right - o - u, r = t.top + u;
63
- n = Math.max(l, n), n = Math.min(n, window.innerWidth - o - l), r = Math.max(l, r);
64
- let i = f(r, window.innerHeight, !1);
65
- _({
63
+ let t = e.getBoundingClientRect(), n = t.right - s - d, r = t.top + d;
64
+ n = Math.max(u, n), n = Math.min(n, window.innerWidth - s - u), r = Math.max(u, r);
65
+ let i = p(r, window.innerHeight, !1);
66
+ v({
66
67
  top: i.top,
67
68
  left: n,
68
- width: o,
69
+ width: s,
69
70
  maxHeight: i.maxHeight
70
71
  });
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
+ }, S = () => c !== null && h(l.getSnapshot().requestedTab, m(c)) !== null, C = null, w = (t, n = !1) => {
73
+ let r = C;
74
+ if (C = null, _({
74
75
  requestedTab: null,
75
76
  layout: null
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;
77
+ }), D(), !(c === null || !t)) {
78
+ if (n && r !== null && r.isConnected && r !== c.gridRootRef.current) {
79
+ let t = e(r);
80
+ if (t === r || (t === null || t === document.body || f.current?.contains(t) === !0) && (r.focus({ preventScroll: !0 }), e(r) === r)) return;
80
81
  }
81
- i(s.gridRootRef);
82
+ a(c.gridRootRef);
82
83
  }
83
- }, w = () => C(!0, !0), T = n({
84
- onResize: b,
85
- onScroll: b,
86
- isInside: (e) => d.current?.contains(e) === !0 || s?.alliedRef?.current?.contains(e) === !0,
87
- onOutsidePointerDown: (e) => C(s !== null && r(s.gridRootRef, e)),
88
- getGridRoot: () => s?.gridRootRef.current ?? null,
89
- onGridHidden: () => C(!1),
84
+ }, T = () => w(!0, !0), E = r({
85
+ onResize: x,
86
+ onScroll: x,
87
+ isInside: (e) => f.current?.contains(e) === !0 || c?.alliedRef?.current?.contains(e) === !0,
88
+ onOutsidePointerDown: (e) => w(c !== null && i(c.gridRootRef, e)),
89
+ getGridRoot: () => c?.gridRootRef.current ?? null,
90
+ onGridHidden: () => w(!1),
90
91
  onKeyDown: (e) => {
91
92
  if (e.key === "Escape") {
92
- if (s?.suppressEscape) {
93
- s.onSuppressedEscape?.();
93
+ if (c?.suppressEscape) {
94
+ c.onSuppressedEscape?.();
94
95
  return;
95
96
  }
96
- e.preventDefault(), w();
97
+ e.preventDefault(), T();
97
98
  }
98
99
  }
99
- }), E = () => {
100
- let e = x();
101
- e && !T.isAttached() ? (b(), T.attach()) : !e && T.isAttached() && T.detach();
100
+ }), D = () => {
101
+ let e = S();
102
+ e && !E.isAttached() ? (x(), E.attach()) : !e && E.isAttached() && E.detach();
102
103
  };
103
104
  return {
104
105
  update: (e) => {
105
- s = e, E();
106
+ c = e, D();
106
107
  },
107
- subscribe: c.subscribe,
108
- getSnapshot: c.getSnapshot,
109
- panelRef: d,
110
- open: (e) => {
111
- if (s === null || !p(s).includes(e)) return;
112
- let n = c.getSnapshot();
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;
108
+ subscribe: l.subscribe,
109
+ getSnapshot: l.getSnapshot,
110
+ panelRef: f,
111
+ open: (t) => {
112
+ if (c === null || !m(c).includes(t)) return;
113
+ let r = l.getSnapshot();
114
+ if (r.requestedTab === null) {
115
+ let t = e(c.gridRootRef.current);
116
+ C = t instanceof HTMLElement && t !== document.body && t.closest(".ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover") === null ? t : null;
116
117
  }
117
- d.current?.contains(document.activeElement) !== !0 && t(s.gridRootRef.current), g({
118
- requestedTab: e,
119
- flashTick: n.requestedTab === null ? n.flashTick : n.flashTick + 1
120
- }), E();
118
+ f.current?.contains(e(c.gridRootRef.current)) !== !0 && n(c.gridRootRef.current), _({
119
+ requestedTab: t,
120
+ flashTick: r.requestedTab === null ? r.flashTick : r.flashTick + 1
121
+ }), D();
121
122
  },
122
- close: w,
123
+ close: T,
123
124
  move: (e, t) => {
124
- let n = v({
125
+ let n = y({
125
126
  top: e,
126
127
  left: t
127
128
  });
128
- h = n, g({ layout: y(n) });
129
+ g = n, _({ layout: b(n) });
129
130
  },
130
131
  dispose: () => {
131
- T.detach();
132
+ E.detach();
132
133
  }
133
134
  };
134
135
  };
135
136
  //#endregion
136
- export { s as TOOL_PANEL_MAX_HEIGHT, h as createToolPanelController, m as resolveActiveToolPanelTab, p as resolveAvailableToolPanelTabs, f as resolveToolPanelVerticalPlacement };
137
+ export { c as TOOL_PANEL_MAX_HEIGHT, g as createToolPanelController, h as resolveActiveToolPanelTab, m as resolveAvailableToolPanelTabs, p as resolveToolPanelVerticalPlacement };
@@ -1 +1 @@
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
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/shadowDom.cjs"),t=require("../logic/slotDom.cjs"),n=require("../utils/portalTokens.cjs"),r=require("../utils/popupContainer.cjs"),i=require("../logic/tooltipGeometry.cjs");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=new WeakMap;function b(e){g=t.applySlotToElement(e,h,g)}function x(e){let t=r.getPopupContainerFor(e);if(d!==null)return r.appendToPopupContainer(d,t),d;let n=document.createElement(`div`);return n.className=`ssg-tooltip`,n.setAttribute(`aria-hidden`,`true`),g=void 0,b(n),r.appendToPopupContainer(n,t),d=n,n}function S(){f!==null&&(window.clearTimeout(f),f=null)}var C=null;function w(){C!==null&&(cancelAnimationFrame(C),C=null)}function T(){if(w(),typeof requestAnimationFrame!=`function`)return;let e=()=>{if(C=null,m!==null){if(!m.isConnected){E();return}C=requestAnimationFrame(e)}};C=requestAnimationFrame(e)}function E(){S(),w(),m!==null&&(p=Date.now()+l),m=null,_=null,v=null,d!==null&&d.classList.remove(`ssg-tooltip--visible`)}function D(e){if(!e.isConnected)return;let t=e.getAttribute(a),r=e.getAttribute(o),s=t!==null&&t!==``?t:r!==null&&r!==``?r:(e.textContent??``).trim();if(s===``)return;let c=x(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),n.syncPortalTokens(e,c),c.textContent=s,c.style.left=`0px`,c.style.top=`0px`;let l=i.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`),m=e,T()}function O(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}var k=e=>e.currentTarget;function A(t){let n=e.getEventTarget(t,k(t));if(!(n instanceof Element)||typeof PointerEvent<`u`&&t instanceof PointerEvent&&t.buttons!==0)return;let r=n.closest(s);if(r===null||r===m||!r.hasAttribute(a)&&!O(r))return;let i=m!==null;E(),i||Date.now()<p?D(r):f=window.setTimeout(()=>{f=null,D(r)},c)}function j(t){let n=e.getEventTarget(t,k(t));if(!(n instanceof Element))return;if(t.type===`focusout`&&v!==null&&v.contains(n)){let e=t.relatedTarget;if(!(e instanceof Node&&v.contains(e))){E();return}}let r=n.closest(s);if(r===null||r===_&&typeof PointerEvent<`u`&&t instanceof PointerEvent&&t.pointerType!==`mouse`)return;let i=t.relatedTarget;i instanceof Node&&r.contains(i)||E()}function M(){E()}function N(t){let n=e.getEventTarget(t,k(t));_!==null&&m===_&&typeof PointerEvent<`u`&&t instanceof PointerEvent&&t.pointerType!==`mouse`&&n instanceof Node&&_.contains(n)||E()}function P(t){let n=e.getEventTarget(t,k(t));if(!(n instanceof Element))return;let r=n.closest(`.ssg-shell`),i=r===null?void 0:y.get(r);if(r===null||i===void 0)return;let a=e.findElementById(r,i);a===null||m===a||!a.contains(n)||U(i,r)}function F(e){e.key===`Escape`&&E()}var I=[[`pointerover`,A],[`pointerout`,j],[`focusin`,A],[`focusout`,j],[`pointerdown`,N],[`pointerup`,P],[`scroll`,M],[`keydown`,F]],L=new Map,R=I.map(([e,t])=>[e,e=>{(typeof e.composedPath==`function`?e.composedPath():[]).some(e=>L.has(e))||t(e)}]);function z(e,t=I){for(let[n,r]of t)e.addEventListener(n,r,!0)}function B(e,t=I){for(let[n,r]of t)e.removeEventListener(n,r,!0)}function V(e){let t=L.get(e)??0;t===0&&z(e),L.set(e,t+1)}function H(e){let t=L.get(e)??0;t<=1?(L.delete(e),B(e)):L.set(e,t-1)}function U(t,n){if(typeof requestAnimationFrame!=`function`||u===0)return()=>{};n!==null&&y.set(n,t);let r=requestAnimationFrame(()=>{r=requestAnimationFrame(()=>{if(r=0,n!==null&&y.get(n)!==t)return;let i=e.findElementById(n,t);if(!(i!==null&&n!==null&&n.contains(e.getActiveElement(n))&&i.classList.contains(`ssg-body-cell--invalid`)&&(i.getAttribute(a)??``)!==``)){G(n);return}m!==i&&(E(),D(i)),m===i&&(_=i,v=n)})});return()=>{r!==0&&cancelAnimationFrame(r)}}function W(e){e&&y.delete(e),G(e)}function G(e){_===null||e!==void 0&&e!==v||(m===_&&E(),_=null,v=null)}function K(t,n){u+=1,u===1&&z(window,R);let r=e.getShadowRoot(n);r!==null&&V(r);let i=!1,a=e=>{h=e,d!==null&&b(d)};return a(t),{setSlot:a,dispose:()=>{i||(i=!0,r!==null&&H(r),--u,u===0&&(B(window,R),S(),w(),m=null,_=null,v=null,d!==null&&(d.remove(),d=null)))}}}exports.acquireTooltipController=K,exports.hideActiveCellTooltip=W,exports.scheduleActiveCellTooltip=U;
@@ -5,4 +5,4 @@ export type TooltipController = {
5
5
  };
6
6
  export declare function scheduleActiveCellTooltip(cellId: string, focusRoot: Element | null): () => void;
7
7
  export declare function hideActiveCellTooltip(focusRoot?: Element | null): void;
8
- export declare function acquireTooltipController(slot?: GridResolvedSlot): TooltipController;
8
+ export declare function acquireTooltipController(slot?: GridResolvedSlot, root?: Element | null): TooltipController;
@@ -1,143 +1,168 @@
1
- import { applySlotToElement as e } from "../logic/slotDom.js";
2
- import { syncPortalTokens as t } from "../utils/portalTokens.js";
3
- import { appendToPopupContainer as n, getPopupContainerFor as r } from "../utils/popupContainer.js";
4
- import { computeTooltipPlacement as i } from "../logic/tooltipGeometry.js";
1
+ import { findElementById as e, getActiveElement as t, getEventTarget as n, getShadowRoot as r } from "../utils/shadowDom.js";
2
+ import { applySlotToElement as i } from "../logic/slotDom.js";
3
+ import { syncPortalTokens as a } from "../utils/portalTokens.js";
4
+ import { appendToPopupContainer as o, getPopupContainerFor as s } from "../utils/popupContainer.js";
5
+ import { computeTooltipPlacement as c } from "../logic/tooltipGeometry.js";
5
6
  //#region src/controllers/tooltipController.ts
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);
7
+ var l = "data-ssg-tooltip", u = "data-ssg-tooltip-overflow", d = `[${l}], [${u}]`, f = 350, p = 800, m = 0, h = null, g = null, _ = 0, v = null, y, b, x = null, S = null, C = /* @__PURE__ */ new WeakMap();
8
+ function w(e) {
9
+ b = i(e, y, b);
9
10
  }
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;
11
+ function T(e) {
12
+ let t = s(e);
13
+ if (h !== null) return o(h, t), h;
14
+ let n = document.createElement("div");
15
+ return n.className = "ssg-tooltip", n.setAttribute("aria-hidden", "true"), b = void 0, w(n), o(n, t), h = n, n;
15
16
  }
16
- function S() {
17
- f !== null && (window.clearTimeout(f), f = null);
17
+ function E() {
18
+ g !== null && (window.clearTimeout(g), g = null);
18
19
  }
19
- var C = null;
20
- function w() {
21
- C !== null && (cancelAnimationFrame(C), C = null);
20
+ var D = null;
21
+ function O() {
22
+ D !== null && (cancelAnimationFrame(D), D = null);
22
23
  }
23
- function T() {
24
- if (w(), typeof requestAnimationFrame != "function") return;
24
+ function k() {
25
+ if (O(), typeof requestAnimationFrame != "function") return;
25
26
  let e = () => {
26
- if (C = null, m !== null) {
27
- if (!m.isConnected) {
28
- E();
27
+ if (D = null, v !== null) {
28
+ if (!v.isConnected) {
29
+ A();
29
30
  return;
30
31
  }
31
- C = requestAnimationFrame(e);
32
+ D = requestAnimationFrame(e);
32
33
  }
33
34
  };
34
- C = requestAnimationFrame(e);
35
+ D = requestAnimationFrame(e);
35
36
  }
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");
37
+ function A() {
38
+ E(), O(), v !== null && (_ = Date.now() + p), v = null, x = null, S = null, h !== null && h.classList.remove("ssg-tooltip--visible");
38
39
  }
39
- function D(e) {
40
+ function j(e) {
40
41
  if (!e.isConnected) return;
41
- let n = e.getAttribute(a), r = e.getAttribute(o), s = n !== null && n !== "" ? n : r !== null && r !== "" ? r : (e.textContent ?? "").trim();
42
- if (s === "") return;
43
- let c = x(e);
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";
45
- let l = i({
42
+ let t = e.getAttribute(l), n = e.getAttribute(u), r = t !== null && t !== "" ? t : n !== null && n !== "" ? n : (e.textContent ?? "").trim();
43
+ if (r === "") return;
44
+ let i = T(e);
45
+ i.classList.toggle("ssg-theme-dark", e.closest(".ssg-theme-dark") !== null), i.classList.toggle("ssg-theme-class", e.closest(".ssg-theme-class") !== null), i.classList.toggle("ssg-motion-off", e.closest(".ssg-motion-off") !== null), a(e, i), i.textContent = r, i.style.left = "0px", i.style.top = "0px";
46
+ let o = c({
46
47
  targetRect: e.getBoundingClientRect(),
47
- tipWidth: c.offsetWidth,
48
- tipHeight: c.offsetHeight,
48
+ tipWidth: i.offsetWidth,
49
+ tipHeight: i.offsetHeight,
49
50
  viewportWidth: window.innerWidth
50
51
  });
51
- c.style.left = `${l.left}px`, c.style.top = `${l.top}px`, c.classList.add("ssg-tooltip--visible"), m = e, T();
52
+ i.style.left = `${o.left}px`, i.style.top = `${o.top}px`, i.classList.add("ssg-tooltip--visible"), v = e, k();
52
53
  }
53
- function O(e) {
54
+ function M(e) {
54
55
  if (e.scrollWidth > e.clientWidth + 1) return !0;
55
56
  for (let t of Array.from(e.children)) if (t.scrollWidth > t.clientWidth + 1) return !0;
56
57
  return !1;
57
58
  }
58
- function k(e) {
59
- let t = e.target;
59
+ var N = (e) => e.currentTarget;
60
+ function P(e) {
61
+ let t = n(e, N(e));
60
62
  if (!(t instanceof Element) || typeof PointerEvent < "u" && e instanceof PointerEvent && e.buttons !== 0) return;
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) {
69
- let t = e.target;
63
+ let r = t.closest(d);
64
+ if (r === null || r === v || !r.hasAttribute(l) && !M(r)) return;
65
+ let i = v !== null;
66
+ A(), i || Date.now() < _ ? j(r) : g = window.setTimeout(() => {
67
+ g = null, j(r);
68
+ }, f);
69
+ }
70
+ function F(e) {
71
+ let t = n(e, N(e));
70
72
  if (!(t instanceof Element)) return;
71
- if (e.type === "focusout" && v !== null && v.contains(t)) {
73
+ if (e.type === "focusout" && S !== null && S.contains(t)) {
72
74
  let t = e.relatedTarget;
73
- if (!(t instanceof Node && v.contains(t))) {
74
- E();
75
+ if (!(t instanceof Node && S.contains(t))) {
76
+ A();
75
77
  return;
76
78
  }
77
79
  }
78
- let n = t.closest(s);
79
- if (n === null || n === _ && typeof PointerEvent < "u" && e instanceof PointerEvent && e.pointerType !== "mouse") return;
80
- let r = e.relatedTarget;
81
- r instanceof Node && n.contains(r) || E();
82
- }
83
- function j() {
84
- E();
85
- }
86
- function M(e) {
87
- _ !== null && m === _ && typeof PointerEvent < "u" && e instanceof PointerEvent && e.pointerType !== "mouse" && e.target instanceof Node && _.contains(e.target) || E();
80
+ let r = t.closest(d);
81
+ if (r === null || r === x && typeof PointerEvent < "u" && e instanceof PointerEvent && e.pointerType !== "mouse") return;
82
+ let i = e.relatedTarget;
83
+ i instanceof Node && r.contains(i) || A();
88
84
  }
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);
85
+ function I() {
86
+ A();
96
87
  }
97
- function P(e) {
98
- e.key === "Escape" && E();
88
+ function L(e) {
89
+ let t = n(e, N(e));
90
+ x !== null && v === x && typeof PointerEvent < "u" && e instanceof PointerEvent && e.pointerType !== "mouse" && t instanceof Node && x.contains(t) || A();
99
91
  }
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);
92
+ function R(t) {
93
+ let r = n(t, N(t));
94
+ if (!(r instanceof Element)) return;
95
+ let i = r.closest(".ssg-shell"), a = i === null ? void 0 : C.get(i);
96
+ if (i === null || a === void 0) return;
97
+ let o = e(i, a);
98
+ o === null || v === o || !o.contains(r) || q(a, i);
102
99
  }
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);
109
- let n = requestAnimationFrame(() => {
110
- n = requestAnimationFrame(() => {
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);
100
+ function z(e) {
101
+ e.key === "Escape" && A();
102
+ }
103
+ var B = [
104
+ ["pointerover", P],
105
+ ["pointerout", F],
106
+ ["focusin", P],
107
+ ["focusout", F],
108
+ ["pointerdown", L],
109
+ ["pointerup", R],
110
+ ["scroll", I],
111
+ ["keydown", z]
112
+ ], V = /* @__PURE__ */ new Map(), H = /* @__PURE__ */ B.map(([e, t]) => [e, (e) => {
113
+ (typeof e.composedPath == "function" ? e.composedPath() : []).some((e) => V.has(e)) || t(e);
114
+ }]);
115
+ function U(e, t = B) {
116
+ for (let [n, r] of t) e.addEventListener(n, r, !0);
117
+ }
118
+ function W(e, t = B) {
119
+ for (let [n, r] of t) e.removeEventListener(n, r, !0);
120
+ }
121
+ function G(e) {
122
+ let t = V.get(e) ?? 0;
123
+ t === 0 && U(e), V.set(e, t + 1);
124
+ }
125
+ function K(e) {
126
+ let t = V.get(e) ?? 0;
127
+ t <= 1 ? (V.delete(e), W(e)) : V.set(e, t - 1);
128
+ }
129
+ function q(n, r) {
130
+ if (typeof requestAnimationFrame != "function" || m === 0) return () => {};
131
+ r !== null && C.set(r, n);
132
+ let i = requestAnimationFrame(() => {
133
+ i = requestAnimationFrame(() => {
134
+ if (i = 0, r !== null && C.get(r) !== n) return;
135
+ let a = e(r, n);
136
+ if (!(a !== null && r !== null && r.contains(t(r)) && a.classList.contains("ssg-body-cell--invalid") && (a.getAttribute(l) ?? "") !== "")) {
137
+ Y(r);
115
138
  return;
116
139
  }
117
- m !== r && (E(), D(r)), m === r && (_ = r, v = t);
140
+ v !== a && (A(), j(a)), v === a && (x = a, S = r);
118
141
  });
119
142
  });
120
143
  return () => {
121
- n !== 0 && cancelAnimationFrame(n);
144
+ i !== 0 && cancelAnimationFrame(i);
122
145
  };
123
146
  }
124
- function R(e) {
125
- e && y.delete(e), z(e);
147
+ function J(e) {
148
+ e && C.delete(e), Y(e);
126
149
  }
127
- function z(e) {
128
- _ === null || e !== void 0 && e !== v || (m === _ && E(), _ = null, v = null);
150
+ function Y(e) {
151
+ x === null || e !== void 0 && e !== S || (v === x && A(), x = null, S = null);
129
152
  }
130
- function B(e) {
131
- u += 1, u === 1 && F();
132
- let t = !1, n = (e) => {
133
- h = e, d !== null && b(d);
153
+ function X(e, t) {
154
+ m += 1, m === 1 && U(window, H);
155
+ let n = r(t);
156
+ n !== null && G(n);
157
+ let i = !1, a = (e) => {
158
+ y = e, h !== null && w(h);
134
159
  };
135
- return n(e), {
136
- setSlot: n,
160
+ return a(e), {
161
+ setSlot: a,
137
162
  dispose: () => {
138
- t || (t = !0, --u, u === 0 && (I(), S(), w(), m = null, _ = null, v = null, d !== null && (d.remove(), d = null)));
163
+ i || (i = !0, n !== null && K(n), --m, m === 0 && (W(window, H), E(), O(), v = null, x = null, S = null, h !== null && (h.remove(), h = null)));
139
164
  }
140
165
  };
141
166
  }
142
167
  //#endregion
143
- export { B as acquireTooltipController, R as hideActiveCellTooltip, L as scheduleActiveCellTooltip };
168
+ export { X as acquireTooltipController, J as hideActiveCellTooltip, q 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<_||!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&&s!==null&&o.isRowFollowMove?.(s)===!0?d():!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;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/shadowDom.cjs"),t=require("../logic/verticalGeometry.cjs");var n=(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)},r=(e,n,r)=>{let i=r.headerHeight+n.top,a=i+n.height,o=r.leftPaneWidth+r.centerLeadingWidth+n.left,s=o+n.width,c=t.physicalToLogicalScrollTop(e.scrollTop,r.verticalScaleFactor),l=e.scrollLeft,u=e.clientHeight-(r.footerHeight??0),d=e.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=t.logicalToPhysicalScrollTop(f,r.verticalScaleFactor);return e.scrollTo({top:f>c?Math.ceil(n):n,left:p,behavior:`auto`}),!0}return!1},i=(e,t,n,r)=>e<n?e-n:t>r?Math.min(t-r,e-n):0,a=(n,r,a)=>{let o=n.ownerDocument,s=o.defaultView,c=n.closest(`.ssg-shell`),l=e.getActiveElement(n);if(!s||!c||!l||l!==c&&!(l.classList.contains(`ssg-ime-input`)&&c.contains(l))||c.hasAttribute(`data-ssg-pointer`))return;let u=n.getBoundingClientRect();if(u.height===0)return;let d=t.physicalToLogicalScrollTop(n.scrollTop,a.verticalScaleFactor),f=u.top+n.clientTop+a.headerHeight+r.top-d,p=f+r.height;for(let e=n.parentElement;e&&e!==o.body&&e!==o.documentElement;e=e.parentElement){let t=e.scrollHeight-e.clientHeight;if(t<=0)continue;let n=s.getComputedStyle(e).overflowY;if(n!==`auto`&&n!==`scroll`&&n!==`overlay`)continue;let r=e.getBoundingClientRect().top+e.clientTop,a=i(f,p,r,r+e.clientHeight);if(a===0)continue;let o=e.scrollTop,c=Math.min(Math.max(o+a,0),t);e.scrollTop=c,f-=c-o,p-=c-o}let m=i(f,p,0,s.innerHeight);m!==0&&s.scrollBy({top:m,behavior:`auto`})},o=()=>{let e=null,n=1,r=0;return{update:(i,a,o)=>{let s=e,c=n,l=r;if(e=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=t.logicalToPhysicalScrollTop(t.physicalToLogicalScrollTop(u,c),a);Math.abs(d-u)<1||(i.scrollTop=d,i.scrollTop!==u&&o(i.scrollTop))}}},s=1e3,c=[`wheel`,`touchstart`,`pointerdown`,`pointerup`,`pointermove`,`keydown`],l=(e,t)=>e!==null&&e.top===t.top&&e.height===t.height&&e.left===t.left&&e.width===t.width,u=(e,t,n)=>e===null||n.some(n=>!Object.is(e[n],t[n])),d=()=>{let e=null,t=null,i=null,o=null,d=()=>{i=null,o?.(),o=null},f=e=>{e.type===`pointermove`&&!(e.buttons>0)||d()},p=(e,t)=>{d(),i={cell:t,until:Date.now()+s,left:e.scrollLeft};let n=e.ownerDocument,r=setTimeout(d,s);if(typeof n?.addEventListener!=`function`){o=()=>clearTimeout(r);return}for(let e of c)n.addEventListener(e,f,{capture:!0,passive:!0});o=()=>{clearTimeout(r);for(let e of c)n.removeEventListener(e,f,{capture:!0})}};return{update:o=>{if(u(e,o,[`columnVirtualizer`,`columnMeasurements`])&&o.columnVirtualizer.measure(),u(e,o,[`scrollElement`,`totalScrollWidth`,`physicalBodyHeight`,`headerHeight`,`footerHeight`])&&o.scrollElement&&n(o.scrollElement,o),u(e,o,[`scrollElement`,`activeCellRect`,`activeCellPinned`,`activeCell`,`headerHeight`,`leftPaneWidth`,`rightPaneWidth`,`centerLeadingWidth`,`verticalScaleFactor`,`footerHeight`])){let n=t,{activeCell:s}=o,c=n!==null&&s!==null&&n.row===s.row&&n.col===s.col;t=s,!c&&s!==null&&o.isRowFollowMove?.(s)===!0?d():!c&&o.scrollElement&&o.activeCellRect&&s?(r(o.scrollElement,o.activeCellRect,o),a(o.scrollElement,o.activeCellRect,o),p(o.scrollElement,s)):c&&i!==null&&s!==null&&o.scrollElement&&o.activeCellRect&&i.cell.row===s.row&&i.cell.col===s.col&&!l(e?.activeCellRect??null,o.activeCellRect)&&(Date.now()>i.until||Math.abs(o.scrollElement.scrollLeft-i.left)>1?d():(r(o.scrollElement,o.activeCellRect,o),i={...i,left:o.scrollElement.scrollLeft}))}e=o},cancelFollow:d,dispose:d}};exports.clampScrollToContent=n,exports.createScrollScaleAnchor=o,exports.createViewportSyncController=d,exports.revealActiveCellInPage=a,exports.scrollCellIntoView=r;