@ishibashi0112/spreadsheet-grid-core 1.2.0 → 1.3.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 (118) hide show
  1. package/dist/controllers/clipboardController.cjs +1 -1
  2. package/dist/controllers/clipboardController.d.ts +1 -0
  3. package/dist/controllers/clipboardController.js +79 -70
  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 -0
  9. package/dist/controllers/detailRowController.d.ts +41 -0
  10. package/dist/controllers/detailRowController.js +97 -0
  11. package/dist/controllers/detailTabOrder.cjs +1 -1
  12. package/dist/controllers/detailTabOrder.js +17 -16
  13. package/dist/controllers/editController.cjs +1 -1
  14. package/dist/controllers/editController.d.ts +4 -1
  15. package/dist/controllers/editController.js +163 -91
  16. package/dist/controllers/escapeClaimController.cjs +1 -1
  17. package/dist/controllers/escapeClaimController.js +23 -19
  18. package/dist/controllers/fillHandleController.cjs +1 -1
  19. package/dist/controllers/fillHandleController.js +107 -106
  20. package/dist/controllers/filterPopoverController.cjs +1 -1
  21. package/dist/controllers/filterPopoverController.js +1 -0
  22. package/dist/controllers/imeInputController.cjs +1 -1
  23. package/dist/controllers/imeInputController.js +87 -76
  24. package/dist/controllers/keyboardController.cjs +1 -1
  25. package/dist/controllers/keyboardController.d.ts +4 -0
  26. package/dist/controllers/keyboardController.js +101 -97
  27. package/dist/controllers/liveUiState.cjs +1 -0
  28. package/dist/controllers/liveUiState.d.ts +7 -0
  29. package/dist/controllers/liveUiState.js +4 -0
  30. package/dist/controllers/pointerInteractionsController.cjs +1 -1
  31. package/dist/controllers/pointerInteractionsController.d.ts +1 -0
  32. package/dist/controllers/pointerInteractionsController.js +127 -126
  33. package/dist/controllers/popoverSupport.cjs +1 -1
  34. package/dist/controllers/popoverSupport.d.ts +3 -0
  35. package/dist/controllers/popoverSupport.js +62 -41
  36. package/dist/controllers/toolPanelController.cjs +1 -1
  37. package/dist/controllers/toolPanelController.js +74 -73
  38. package/dist/controllers/tooltipController.cjs +1 -1
  39. package/dist/controllers/tooltipController.d.ts +1 -1
  40. package/dist/controllers/tooltipController.js +122 -97
  41. package/dist/controllers/viewportSyncController.cjs +1 -1
  42. package/dist/controllers/viewportSyncController.js +55 -54
  43. package/dist/engine/cellCommands.cjs +1 -0
  44. package/dist/engine/cellCommands.d.ts +27 -0
  45. package/dist/engine/cellCommands.js +89 -0
  46. package/dist/engine/columnCommands.cjs +1 -1
  47. package/dist/engine/columnCommands.d.ts +2 -1
  48. package/dist/engine/columnCommands.js +98 -67
  49. package/dist/engine/exportCommands.cjs +1 -1
  50. package/dist/engine/exportCommands.js +2 -2
  51. package/dist/engine/gridApi.cjs +6 -5
  52. package/dist/engine/gridApi.d.ts +3 -0
  53. package/dist/engine/gridApi.js +158 -144
  54. package/dist/engine/rowSelectionCommands.cjs +1 -1
  55. package/dist/engine/rowSelectionCommands.d.ts +5 -0
  56. package/dist/engine/rowSelectionCommands.js +73 -38
  57. package/dist/locales/en.cjs +1 -1
  58. package/dist/locales/en.js +2 -2
  59. package/dist/logic/cellPlacement.cjs +1 -0
  60. package/dist/logic/cellPlacement.d.ts +22 -0
  61. package/dist/logic/cellPlacement.js +44 -0
  62. package/dist/logic/contextMenuTarget.cjs +1 -1
  63. package/dist/logic/contextMenuTarget.d.ts +20 -2
  64. package/dist/logic/contextMenuTarget.js +62 -3
  65. package/dist/logic/dateFilterCondition.cjs +1 -1
  66. package/dist/logic/dateFilterCondition.d.ts +1 -0
  67. package/dist/logic/dateFilterCondition.js +17 -13
  68. package/dist/logic/density.cjs +1 -0
  69. package/dist/logic/density.d.ts +5 -0
  70. package/dist/logic/density.js +17 -0
  71. package/dist/logic/detailRow.cjs +1 -1
  72. package/dist/logic/detailRow.d.ts +6 -1
  73. package/dist/logic/detailRow.js +21 -17
  74. package/dist/logic/domGuards.cjs +1 -1
  75. package/dist/logic/domGuards.d.ts +10 -0
  76. package/dist/logic/domGuards.js +18 -2
  77. package/dist/logic/editorKeys.cjs +1 -0
  78. package/dist/logic/editorKeys.d.ts +30 -0
  79. package/dist/logic/editorKeys.js +34 -0
  80. package/dist/logic/editorStart.cjs +1 -0
  81. package/dist/logic/editorStart.d.ts +7 -0
  82. package/dist/logic/editorStart.js +23 -0
  83. package/dist/logic/editorValues.cjs +1 -1
  84. package/dist/logic/editorValues.d.ts +1 -0
  85. package/dist/logic/editorValues.js +10 -7
  86. package/dist/logic/gridBarSummary.cjs +1 -0
  87. package/dist/logic/gridBarSummary.d.ts +27 -0
  88. package/dist/logic/gridBarSummary.js +137 -0
  89. package/dist/logic/gridState.cjs +1 -1
  90. package/dist/logic/gridState.d.ts +1 -0
  91. package/dist/logic/gridState.js +19 -16
  92. package/dist/logic/localeText.cjs +1 -1
  93. package/dist/logic/localeText.js +2 -2
  94. package/dist/logic/rowDragTarget.cjs +1 -0
  95. package/dist/logic/rowDragTarget.d.ts +14 -0
  96. package/dist/logic/rowDragTarget.js +47 -0
  97. package/dist/logic/selectEditorState.cjs +1 -1
  98. package/dist/logic/selectEditorState.d.ts +27 -4
  99. package/dist/logic/selectEditorState.js +29 -14
  100. package/dist/logic/valueFormatters.d.ts +8 -3
  101. package/dist/model/gridTypes.core.d.ts +31 -12
  102. package/dist/utils/clipboard.cjs +4 -4
  103. package/dist/utils/clipboard.js +60 -59
  104. package/dist/utils/editorVisibleBounds.cjs +1 -0
  105. package/dist/utils/editorVisibleBounds.d.ts +10 -0
  106. package/dist/utils/editorVisibleBounds.js +40 -0
  107. package/dist/utils/errorBubblePlacement.cjs +1 -0
  108. package/dist/utils/errorBubblePlacement.d.ts +8 -0
  109. package/dist/utils/errorBubblePlacement.js +26 -0
  110. package/dist/utils/multilineEditor.cjs +2 -0
  111. package/dist/utils/multilineEditor.d.ts +7 -0
  112. package/dist/utils/multilineEditor.js +22 -0
  113. package/dist/utils/popupContainer.cjs +1 -1
  114. package/dist/utils/popupContainer.js +35 -28
  115. package/dist/utils/shadowDom.cjs +1 -0
  116. package/dist/utils/shadowDom.d.ts +5 -0
  117. package/dist/utils/shadowDom.js +33 -0
  118. package/package.json +1 -1
@@ -1,58 +1,79 @@
1
- import { isFocusInsideDetailCard as e } from "../logic/detailRow.js";
1
+ import { getActiveElement as e, getEventTarget as t } from "../utils/shadowDom.js";
2
+ import { isFocusInsideDetailCard as n } from "../logic/detailRow.js";
2
3
  import "../logic/domGuards.js";
3
4
  import "./escapeClaimController.js";
4
5
  //#region src/controllers/popoverSupport.ts
5
- var t = (e) => {
6
- document.activeElement instanceof HTMLElement && document.activeElement.blur(), e?.blur();
7
- }, n = "input, textarea, select, [contenteditable]:not([contenteditable=\"false\"])", r = (t) => {
8
- let r = t.current, i = r?.ownerDocument.activeElement ?? null;
9
- r !== null && i !== null && !r.contains(i) && i.closest(".ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover") !== null && (i.matches(n) ? queueMicrotask(() => {
10
- let e = t.current, n = e?.ownerDocument.activeElement ?? null;
11
- e !== null && (n === null || n === e.ownerDocument.body) && e.focus({ preventScroll: !0 });
6
+ var r = (t) => {
7
+ let n = e(t);
8
+ n instanceof HTMLElement && n.blur(), t?.blur();
9
+ }, i = "input, textarea, select, [contenteditable]:not([contenteditable=\"false\"])", a = (t) => {
10
+ let r = t.current, a = r === null ? null : e(r);
11
+ r !== null && a !== null && !r.contains(a) && a.closest(".ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover") !== null && (a.matches(i) ? queueMicrotask(() => {
12
+ let n = t.current, r = n === null ? null : e(n);
13
+ n !== null && (r === null || r === n.ownerDocument.body) && n.focus({ preventScroll: !0 });
12
14
  }) : r.focus({ preventScroll: !0 })), requestAnimationFrame(() => {
13
- let n = t.current;
14
- if (n === null || e()) return;
15
- let r = n.ownerDocument.activeElement;
16
- r !== null && r !== n && n.contains(r) && r.closest(".ssg-cell-editor") !== null || r !== null && !n.contains(r) && r.closest(".ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover") !== null || n.focus();
15
+ let r = t.current;
16
+ if (r === null || n(r)) return;
17
+ let i = e(r);
18
+ i !== null && i !== r && r.contains(i) && i.closest(".ssg-cell-editor") !== null || i !== null && !r.contains(i) && i.closest(".ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover") !== null || r.focus();
17
19
  });
18
- }, i = (e, t) => e.current?.contains(t) === !0, a = (e, t, n = "[role=\"menuitem\"]") => {
19
- let r = document.activeElement, i = r instanceof HTMLElement && r !== e && e.contains(r);
20
- if (i && !r.matches(n)) return !1;
21
- let a = t.key;
22
- if (a === "ArrowDown" || a === "ArrowUp" || a === "Home" || a === "End") {
23
- t.preventDefault();
24
- let o = Array.from(e.querySelectorAll(`${n}:not(:disabled):not([aria-disabled="true"])`));
25
- if (o.length === 0) return !0;
26
- let s = i ? o.indexOf(r) : -1, c;
27
- return c = a === "Home" ? 0 : a === "End" ? o.length - 1 : a === "ArrowDown" ? s < 0 ? 0 : (s + 1) % o.length : s < 0 ? o.length - 1 : (s - 1 + o.length) % o.length, o[c]?.focus(), !0;
20
+ }, o = ".ssg-toolpanel, .ssg-filter-popover", s = (t) => {
21
+ let n = t.current, r = n === null ? null : e(n);
22
+ return r !== null && typeof r.closest == "function" && r.closest(o) !== null;
23
+ }, c = (e, t) => e.current?.contains(t) === !0, l = (t, n, r = "[role=\"menuitem\"]") => {
24
+ let i = e(t), a = i instanceof HTMLElement && i !== t && t.contains(i);
25
+ if (a && !i.matches(r)) return !1;
26
+ let o = n.key;
27
+ if (o === "ArrowDown" || o === "ArrowUp" || o === "Home" || o === "End") {
28
+ n.preventDefault();
29
+ let e = Array.from(t.querySelectorAll(`${r}:not(:disabled):not([aria-disabled="true"])`));
30
+ if (e.length === 0) return !0;
31
+ let s = a ? e.indexOf(i) : -1, c;
32
+ return c = o === "Home" ? 0 : o === "End" ? e.length - 1 : o === "ArrowDown" ? s < 0 ? 0 : (s + 1) % e.length : s < 0 ? e.length - 1 : (s - 1 + e.length) % e.length, e[c]?.focus(), !0;
28
33
  }
29
- return !i && (a === "PageUp" || a === "PageDown" || a === " " || a === "ArrowLeft" || a === "ArrowRight") ? (t.preventDefault(), !0) : !1;
30
- }, o = (e, t) => {
31
- if (e === null || !e.isConnected) return;
32
- let n = e.ownerDocument.activeElement, r = n !== null && t != null && (n === t || t.contains(n) && n.hasAttribute("data-ssg-ime-input"));
33
- (n === null || n === e.ownerDocument.body || r) && e.focus({ preventScroll: !0 });
34
- }, s = (e) => {
35
- let t = !1, n = () => e.onResize?.(), r = (t) => e.onScroll?.(t), i = (t) => {
36
- let n = t.target;
37
- n && (e.isInside(n) || e.onOutsidePointerDown(n));
38
- }, a = (t) => e.onKeyDown?.(t), o = null, s = () => {
39
- let n = e.getGridRoot?.() ?? null, r = e.onGridHidden;
40
- !n || !r || typeof ResizeObserver > "u" || (o = new ResizeObserver((e) => {
34
+ return !a && (o === "PageUp" || o === "PageDown" || o === " " || o === "ArrowLeft" || o === "ArrowRight") ? (n.preventDefault(), !0) : !1;
35
+ }, u = (t, n) => {
36
+ if (t === null || !t.isConnected) return;
37
+ let r = e(t), i = r !== null && n != null && (r === n || n.contains(r) && r.hasAttribute("data-ssg-ime-input"));
38
+ (r === null || r === t.ownerDocument.body || i) && t.focus({ preventScroll: !0 });
39
+ }, d = (t) => {
40
+ let n = t.ownerDocument.defaultView;
41
+ n !== null && n.requestAnimationFrame(() => {
42
+ if (!t.isConnected) return;
43
+ let n = e(t);
44
+ (n === null || n === t.ownerDocument.body || n === t.ownerDocument.documentElement) && t.focus({ preventScroll: !0 });
45
+ });
46
+ }, f = /* @__PURE__ */ new Set(), p = (e) => {
47
+ let n = !1, r = () => e.onResize?.(), i = (t) => e.onScroll?.(t), a = (n) => {
48
+ let r = t(n, e.getGridRoot?.() ?? null);
49
+ r && (e.isInside(r) || e.onOutsidePointerDown(r));
50
+ }, o = (t) => e.onKeyDown?.(t), s = null, c = null, l = () => {
51
+ let t = e.onOtherGridPopupOpen, n = e.getGridRoot?.() ?? null;
52
+ if (!(!t || !n)) {
53
+ for (let e of Array.from(f)) e.owner !== n && (f.delete(e), e.close());
54
+ c = {
55
+ owner: n,
56
+ close: t
57
+ }, f.add(c);
58
+ }
59
+ }, u = () => {
60
+ let t = e.getGridRoot?.() ?? null, r = e.onGridHidden;
61
+ !t || !r || typeof ResizeObserver > "u" || (s = new ResizeObserver((e) => {
41
62
  let i = e[e.length - 1];
42
- if (!t || !i || i.contentRect.width !== 0 || i.contentRect.height !== 0) return;
43
- let a = n.getBoundingClientRect();
63
+ if (!n || !i || i.contentRect.width !== 0 || i.contentRect.height !== 0) return;
64
+ let a = t.getBoundingClientRect();
44
65
  a.width === 0 && a.height === 0 && r();
45
- }), o.observe(n));
66
+ }), s.observe(t));
46
67
  };
47
68
  return {
48
69
  attach: () => {
49
- t || (t = !0, window.addEventListener("resize", n), window.addEventListener("scroll", r, !0), window.addEventListener("pointerdown", i), window.addEventListener("keydown", a, !0), s());
70
+ n || (n = !0, window.addEventListener("resize", r), window.addEventListener("scroll", i, !0), window.addEventListener("pointerdown", a), window.addEventListener("keydown", o, !0), u(), l());
50
71
  },
51
72
  detach: () => {
52
- t && (t = !1, o?.disconnect(), o = null, window.removeEventListener("resize", n), window.removeEventListener("scroll", r, !0), window.removeEventListener("pointerdown", i), window.removeEventListener("keydown", a, !0));
73
+ n && (n = !1, c !== null && (f.delete(c), c = null), s?.disconnect(), s = null, window.removeEventListener("resize", r), window.removeEventListener("scroll", i, !0), window.removeEventListener("pointerdown", a), window.removeEventListener("keydown", o, !0));
53
74
  },
54
- isAttached: () => t
75
+ isAttached: () => n
55
76
  };
56
77
  };
57
78
  //#endregion
58
- export { t as blurForPopover, s as createPopoverWindowBindings, o as focusPanelIfIdle, a as handleMenuKeyNavigation, i as isInsideGridRoot, r as restoreGridFocus };
79
+ export { r as blurForPopover, p as createPopoverWindowBindings, u as focusPanelIfIdle, l as handleMenuKeyNavigation, s as isFocusInPopupOpenedFromMenu, c as isInsideGridRoot, d as keepFocusAfterPress, a as restoreGridFocus };
@@ -1 +1 @@
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
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/shadowDom.cjs"),t=require("../logic/valueStore.cjs");require("./escapeClaimController.cjs");const n=require("./popoverSupport.cjs"),r=require("../logic/panelDragGeometry.cjs");var i=360,a=420,o=336,s=8,c=12,l=[`filter`,`columns`,`sort`],u=(e,t,n)=>{let r=Math.max(0,Math.min(420,t-s*2)),i=n?Math.min(o,r):r,a=e;a+i>t-s&&(a=Math.max(s,t-s-i));let c=Math.max(0,Math.min(420,t-s-a));return{top:a,maxHeight:c}},d=e=>{let t={filter:e.canUseFilterTab,columns:e.canUseColumnsTab,sort:e.canUseSortTab};return l.filter(e=>t[e])},f=(e,t)=>e===null?null:t.includes(e)?e:t[0]??null,p=()=>{let a=null,o=t.createValueStore({requestedTab:null,layout:null,flashTick:0}),l={current:null},p=null,m=e=>{o.setSnapshot({...o.getSnapshot(),...e})},h=e=>{let t=o.getSnapshot().layout;t===e||t!==null&&e!==null&&t.top===e.top&&t.left===e.left&&t.width===e.width&&t.maxHeight===e.maxHeight||m({layout:e})},g=e=>r.clampPanelDragPosition({top:e.top,left:e.left,panelWidth:i,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}),_=e=>{let t=u(e.top,window.innerHeight,!0);return{top:t.top,left:e.left,width:i,maxHeight:t.maxHeight}},v=()=>{if(p){h(_(g(p)));return}let e=a?.gridRootRef.current??null;if(!e){h(null);return}let t=e.getBoundingClientRect(),n=t.right-i-c,r=t.top+c;n=Math.max(s,n),n=Math.min(n,window.innerWidth-i-s),r=Math.max(s,r);let o=u(r,window.innerHeight,!1);h({top:o.top,left:n,width:i,maxHeight:o.maxHeight})},y=()=>a!==null&&f(o.getSnapshot().requestedTab,d(a))!==null,b=null,x=(t,r=!1)=>{let i=b;if(b=null,m({requestedTab:null,layout:null}),w(),!(a===null||!t)){if(r&&i!==null&&i.isConnected&&i!==a.gridRootRef.current){let t=e.getActiveElement(i);if(t===i||(t===null||t===document.body||l.current?.contains(t)===!0)&&(i.focus({preventScroll:!0}),e.getActiveElement(i)===i))return}n.restoreGridFocus(a.gridRootRef)}},S=()=>x(!0,!0),C=n.createPopoverWindowBindings({onResize:v,onScroll:v,isInside:e=>l.current?.contains(e)===!0||a?.alliedRef?.current?.contains(e)===!0,onOutsidePointerDown:e=>x(a!==null&&n.isInsideGridRoot(a.gridRootRef,e)),getGridRoot:()=>a?.gridRootRef.current??null,onGridHidden:()=>x(!1),onKeyDown:e=>{if(e.key===`Escape`){if(a?.suppressEscape){a.onSuppressedEscape?.();return}e.preventDefault(),S()}}}),w=()=>{let e=y();e&&!C.isAttached()?(v(),C.attach()):!e&&C.isAttached()&&C.detach()};return{update:e=>{a=e,w()},subscribe:o.subscribe,getSnapshot:o.getSnapshot,panelRef:l,open:t=>{if(a===null||!d(a).includes(t))return;let r=o.getSnapshot();if(r.requestedTab===null){let t=e.getActiveElement(a.gridRootRef.current);b=t instanceof HTMLElement&&t!==document.body&&t.closest(`.ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover`)===null?t:null}l.current?.contains(e.getActiveElement(a.gridRootRef.current))!==!0&&n.blurForPopover(a.gridRootRef.current),m({requestedTab:t,flashTick:r.requestedTab===null?r.flashTick:r.flashTick+1}),w()},close:S,move:(e,t)=>{let n=g({top:e,left:t});p=n,m({layout:_(n)})},dispose:()=>{C.detach()}}};exports.TOOL_PANEL_MAX_HEIGHT=a,exports.createToolPanelController=p,exports.resolveActiveToolPanelTab=f,exports.resolveAvailableToolPanelTabs=d,exports.resolveToolPanelVerticalPlacement=u;
@@ -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;