@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.
- package/dist/controllers/clipboardController.cjs +1 -1
- package/dist/controllers/clipboardController.d.ts +1 -0
- package/dist/controllers/clipboardController.js +79 -70
- package/dist/controllers/columnMenuController.cjs +1 -1
- package/dist/controllers/columnMenuController.js +75 -73
- package/dist/controllers/contextMenuController.cjs +1 -1
- package/dist/controllers/contextMenuController.js +63 -61
- package/dist/controllers/detailRowController.cjs +1 -0
- package/dist/controllers/detailRowController.d.ts +41 -0
- package/dist/controllers/detailRowController.js +97 -0
- package/dist/controllers/detailTabOrder.cjs +1 -1
- package/dist/controllers/detailTabOrder.js +17 -16
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.d.ts +4 -1
- package/dist/controllers/editController.js +163 -91
- package/dist/controllers/escapeClaimController.cjs +1 -1
- package/dist/controllers/escapeClaimController.js +23 -19
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.js +107 -106
- package/dist/controllers/filterPopoverController.cjs +1 -1
- package/dist/controllers/filterPopoverController.js +1 -0
- package/dist/controllers/imeInputController.cjs +1 -1
- package/dist/controllers/imeInputController.js +87 -76
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +4 -0
- package/dist/controllers/keyboardController.js +101 -97
- package/dist/controllers/liveUiState.cjs +1 -0
- package/dist/controllers/liveUiState.d.ts +7 -0
- package/dist/controllers/liveUiState.js +4 -0
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.d.ts +1 -0
- package/dist/controllers/pointerInteractionsController.js +127 -126
- package/dist/controllers/popoverSupport.cjs +1 -1
- package/dist/controllers/popoverSupport.d.ts +3 -0
- package/dist/controllers/popoverSupport.js +62 -41
- package/dist/controllers/toolPanelController.cjs +1 -1
- package/dist/controllers/toolPanelController.js +74 -73
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.d.ts +1 -1
- package/dist/controllers/tooltipController.js +122 -97
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.js +55 -54
- package/dist/engine/cellCommands.cjs +1 -0
- package/dist/engine/cellCommands.d.ts +27 -0
- package/dist/engine/cellCommands.js +89 -0
- package/dist/engine/columnCommands.cjs +1 -1
- package/dist/engine/columnCommands.d.ts +2 -1
- package/dist/engine/columnCommands.js +98 -67
- package/dist/engine/exportCommands.cjs +1 -1
- package/dist/engine/exportCommands.js +2 -2
- package/dist/engine/gridApi.cjs +6 -5
- package/dist/engine/gridApi.d.ts +3 -0
- package/dist/engine/gridApi.js +158 -144
- package/dist/engine/rowSelectionCommands.cjs +1 -1
- package/dist/engine/rowSelectionCommands.d.ts +5 -0
- package/dist/engine/rowSelectionCommands.js +73 -38
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +2 -2
- package/dist/logic/cellPlacement.cjs +1 -0
- package/dist/logic/cellPlacement.d.ts +22 -0
- package/dist/logic/cellPlacement.js +44 -0
- package/dist/logic/contextMenuTarget.cjs +1 -1
- package/dist/logic/contextMenuTarget.d.ts +20 -2
- package/dist/logic/contextMenuTarget.js +62 -3
- package/dist/logic/dateFilterCondition.cjs +1 -1
- package/dist/logic/dateFilterCondition.d.ts +1 -0
- package/dist/logic/dateFilterCondition.js +17 -13
- package/dist/logic/density.cjs +1 -0
- package/dist/logic/density.d.ts +5 -0
- package/dist/logic/density.js +17 -0
- package/dist/logic/detailRow.cjs +1 -1
- package/dist/logic/detailRow.d.ts +6 -1
- package/dist/logic/detailRow.js +21 -17
- package/dist/logic/domGuards.cjs +1 -1
- package/dist/logic/domGuards.d.ts +10 -0
- package/dist/logic/domGuards.js +18 -2
- package/dist/logic/editorKeys.cjs +1 -0
- package/dist/logic/editorKeys.d.ts +30 -0
- package/dist/logic/editorKeys.js +34 -0
- package/dist/logic/editorStart.cjs +1 -0
- package/dist/logic/editorStart.d.ts +7 -0
- package/dist/logic/editorStart.js +23 -0
- package/dist/logic/editorValues.cjs +1 -1
- package/dist/logic/editorValues.d.ts +1 -0
- package/dist/logic/editorValues.js +10 -7
- package/dist/logic/gridBarSummary.cjs +1 -0
- package/dist/logic/gridBarSummary.d.ts +27 -0
- package/dist/logic/gridBarSummary.js +137 -0
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +1 -0
- package/dist/logic/gridState.js +19 -16
- package/dist/logic/localeText.cjs +1 -1
- package/dist/logic/localeText.js +2 -2
- package/dist/logic/rowDragTarget.cjs +1 -0
- package/dist/logic/rowDragTarget.d.ts +14 -0
- package/dist/logic/rowDragTarget.js +47 -0
- package/dist/logic/selectEditorState.cjs +1 -1
- package/dist/logic/selectEditorState.d.ts +27 -4
- package/dist/logic/selectEditorState.js +29 -14
- package/dist/logic/valueFormatters.d.ts +8 -3
- package/dist/model/gridTypes.core.d.ts +31 -12
- package/dist/utils/clipboard.cjs +4 -4
- package/dist/utils/clipboard.js +60 -59
- package/dist/utils/editorVisibleBounds.cjs +1 -0
- package/dist/utils/editorVisibleBounds.d.ts +10 -0
- package/dist/utils/editorVisibleBounds.js +40 -0
- package/dist/utils/errorBubblePlacement.cjs +1 -0
- package/dist/utils/errorBubblePlacement.d.ts +8 -0
- package/dist/utils/errorBubblePlacement.js +26 -0
- package/dist/utils/multilineEditor.cjs +2 -0
- package/dist/utils/multilineEditor.d.ts +7 -0
- package/dist/utils/multilineEditor.js +22 -0
- package/dist/utils/popupContainer.cjs +1 -1
- package/dist/utils/popupContainer.js +35 -28
- package/dist/utils/shadowDom.cjs +1 -0
- package/dist/utils/shadowDom.d.ts +5 -0
- package/dist/utils/shadowDom.js +33 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../logic/sorting.cjs"),n=require("../logic/detailRow.cjs"),r=require("../logic/geometry.cjs"),i=require("../logic/autoScrollGeometry.cjs"),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../logic/sorting.cjs"),n=require("../logic/detailRow.cjs"),r=require("../logic/geometry.cjs"),i=require("./liveUiState.cjs"),a=require("../logic/autoScrollGeometry.cjs"),o=require("../logic/elementScale.cjs"),s=require("../logic/verticalGeometry.cjs");var c=10,l=300,u=()=>{let c=null,l=!1,u=!1,d=null,f=null,p=`mouse`,m=null,h=null,g=!1,_=!1,v=()=>c===null?null:i.readLiveUiState(c).dragState??null,y=null,b=e=>{let t=c?.footerHeight??0,n=c?.stickyTopHeight??0,r=c?.scrollContainerRef.current??null;if(t<=0&&n<=0||!r)return e;let i=r.getBoundingClientRect(),s=o.resolveElementScale(r,i);return a.clampClientYBelowHeader(a.clampClientYAboveFooter(e,i.top+(r.clientTop+r.clientHeight)*s.y,t*s.y),i.top+r.clientTop*s.y,n*s.y)},x=(e,t)=>{if(c===null)return null;let{bodyScrollRef:n,scrollContainerRef:i,leftPaneScrollRef:a,rightPaneScrollRef:l,filteredRowsLength:u,visibleColumnsLength:d,paneLayout:f,leftLeadingWidth:p,centerLeadingWidth:m,rightLeadingWidth:h,headerHeight:g,rowMetrics:_,verticalScaleFactor:v}=c,y=n.current;if(!y||u===0||d===0)return null;let x=y.getBoundingClientRect(),S=o.resolveElementScale(y,x),C=s.clientYToRowIndex(y.scrollTop+(b(t)-x.top)/S.y-g,i.current?.scrollTop??0,v,_),w=null,T=a.current;if(w===null&&T&&f.left.entries.length>0){let t=T.getBoundingClientRect();if(e<t.right){let n=(e-t.left)/S.x-p;w=r.findLogicalIndexFromPaneOffset(f.left,n)}}let E=l.current;if(w===null&&E&&f.right.entries.length>0){let t=E.getBoundingClientRect();if(e>=t.left){let n=(e-t.left)/S.x-h;w=r.findLogicalIndexFromPaneOffset(f.right,n)}}if(w===null&&f.center.entries.length>0){let t=T&&f.left.entries.length===0?Math.max(e,T.getBoundingClientRect().left+p*S.x):e,n=y.scrollLeft+(t-x.left)/S.x-m;w=r.findLogicalIndexFromPaneOffset(f.center,Math.max(n,0))}return w===null?null:{row:C,col:r.clamp(w,0,d-1)}},S=(t,n)=>{let r=v();if(c===null||!r||r.type!==`selection`)return;let i=x(t,n);if(i){if(r.selectionKind===`cell`){c.dispatch(e.gridActions.updateSelection(i));return}if(r.selectionKind===`row`){c.dispatch(e.gridActions.updateRowSelection(i.row));return}r.selectionKind===`col`&&c.dispatch(e.gridActions.updateColumnSelection(i.col))}},C=(t,n)=>{let r=n.timeStamp;if(c===null)return;let{gridRootRef:i,dispatch:a,enableRangeSelection:o,enableRowSelection:s,onGutterRowSelect:l,onCellDoubleClickRef:u,resolveFirstDataCell:d}=c;i.current?.focus({preventScroll:!0});let{target:p}=t;if(p.kind===`cell`){let t=f;if(t&&t.cell.row===p.cell.row&&t.cell.col===p.cell.col&&r-t.time<300){f=null,u.current(p.cell,n);return}f={cell:p.cell,time:r},a(e.gridActions.activateCell(p.cell)),o&&(a(e.gridActions.startSelection(p.cell)),a(e.gridActions.endSelection()));return}if(f=null,p.kind===`row`){if(s){l(p.rowIndex,{shiftKey:!1});return}a(e.gridActions.startRowSelection(p.rowIndex,d?.().col)),a(e.gridActions.endSelection());return}a(e.gridActions.startColumnSelection(p.colIndex,d?.().row)),a(e.gridActions.endSelection())},w=()=>{c!==null&&(u=!1,c.dispatch(e.gridActions.endSelection()),c.dispatch(e.gridActions.endColumnResize()))},T=t=>{if(c===null)return;c.pointerClientRef.current={x:t.clientX,y:t.clientY};let n=v();if(n?.type===`columnResize`){(y===null||y.drag!==n)&&(y={drag:n,x:o.resolveElementScale(c.scrollContainerRef.current).x});let r=y.x===1?t.clientX:n.startX+(t.clientX-n.startX)/y.x;c.dispatch(e.gridActions.updateColumnResize(r))}},E=e=>{let t=d;t&&(d=null,e.pointerId===t.pointerId&&Math.abs(e.clientX-t.x)<10&&Math.abs(e.clientY-t.y)<10&&C(t,e)),w()},D=()=>{d=null,w()},O=()=>{l||(l=!0,window.addEventListener(`pointermove`,T),window.addEventListener(`pointerup`,E),window.addEventListener(`pointercancel`,D))},k=()=>{l&&(l=!1,window.removeEventListener(`pointermove`,T),window.removeEventListener(`pointerup`,E),window.removeEventListener(`pointercancel`,D))},A=()=>{_=!1,c!==null&&c.autoScrollFrameRef.current!==null&&(cancelAnimationFrame(c.autoScrollFrameRef.current),c.autoScrollFrameRef.current=null)},j=()=>{if(c===null||!_)return;let{scrollContainerRef:e,pointerClientRef:t,autoScrollFrameRef:n}=c,r=e.current,i=t.current;if(!r||!i){n.current=requestAnimationFrame(j);return}if(!g){let e=h;if(e&&!a.hasPointerLeftActivationRadius(e,i,6)){n.current=requestAnimationFrame(j);return}g=!0}let s=r.getBoundingClientRect(),l=o.resolveElementScale(r,s),u=a.resolveScrollContentBox({rectLeft:s.left,rectTop:s.top,clientLeft:r.clientLeft,clientTop:r.clientTop,clientWidth:r.clientWidth,clientHeight:r.clientHeight,scale:l}),d=v(),f=d?.type===`selection`&&d.selectionKind===`col`,p=d?.type===`selection`&&d.selectionKind===`row`,m=f?0:a.resolveAutoScrollAxisDirection(i.y,a.resolveTopAutoScrollStart(u.top,(c.stickyTopHeight??0)*l.y,24),u.bottom-(c.footerHeight??0),24),y=p?0:a.resolveAutoScrollAxisDirection(i.x,u.left,u.right,24),b=a.computeNextScrollPosition(r.scrollTop,m,18,r.scrollHeight-r.clientHeight),x=a.computeNextScrollPosition(r.scrollLeft,y,18,r.scrollWidth-r.clientWidth);(b!==r.scrollTop||x!==r.scrollLeft)&&(r.scrollTo({top:b,left:x,behavior:`auto`}),S(i.x,i.y)),n.current=requestAnimationFrame(j)},M=()=>{let e=v()?.type===`selection`;e&&!_?(_=!0,c!==null&&(c.autoScrollFrameRef.current=requestAnimationFrame(j))):!e&&_&&A()},N=()=>{if(m!==null)return;let e=()=>{if(!u||c===null){m=null;return}let{scrollContainerRef:t,pointerClientRef:n,onGutterRowSelectDrag:r}=c,i=t.current,s=n.current;if(!i||!s){m=requestAnimationFrame(e);return}if(!g){let t=h;if(t&&!a.hasPointerLeftActivationRadius(t,s,6)){m=requestAnimationFrame(e);return}g=!0}let l=i.getBoundingClientRect(),d=o.resolveElementScale(i,l),f=a.resolveScrollContentBox({rectLeft:l.left,rectTop:l.top,clientLeft:i.clientLeft,clientTop:i.clientTop,clientWidth:i.clientWidth,clientHeight:i.clientHeight,scale:d}),p=a.resolveAutoScrollAxisDirection(s.y,a.resolveTopAutoScrollStart(f.top,(c.stickyTopHeight??0)*d.y,24),f.bottom-(c.footerHeight??0),24),_=a.computeNextScrollPosition(i.scrollTop,p,18,i.scrollHeight-i.clientHeight);if(_!==i.scrollTop){i.scrollTo({top:_,left:i.scrollLeft,behavior:`auto`});let e=x(s.x,s.y);e&&r(e.row)}m=requestAnimationFrame(e)};m=requestAnimationFrame(e)},P=(e,t)=>(e.preventDefault(),c===null||e.button!==0?!1:(p=e.pointerType,e.pointerType===`touch`?(d={pointerId:e.pointerId,x:e.clientX,y:e.clientY,target:t},!1):(c.gridRootRef.current?.focus({preventScroll:!0}),c.pointerClientRef.current={x:e.clientX,y:e.clientY},h={x:e.clientX,y:e.clientY},g=!1,!0)));return{update:e=>{c=e,O(),M()},getCellCoordFromClientPoint:x,updateSelectionFromPointer:S,handleCellPointerDown:(t,n)=>{if(!(!P(n,{kind:`cell`,cell:t})||c===null)){if(n.shiftKey&&c.enableRangeSelection){let{selection:n,activeCell:r}=i.readLiveUiState(c),a=n?.type===`cell`?n.range.start:r;if(a){c.dispatch(e.gridActions.startSelection(a)),c.dispatch(e.gridActions.updateSelection(t));return}}c.dispatch(e.gridActions.activateCell(t)),c.enableRangeSelection&&c.dispatch(e.gridActions.startSelection(t))}},handleCellDoubleClick:(e,t)=>{p===`touch`||c===null||c.onCellDoubleClickRef.current(e,t)},handleCellPointerEnter:(t,n)=>{if(c===null||(c.enableRowHover&&c.setHoveredRowIndex(t.row),c.enableColumnHover&&c.setHoveredColumnIndex(t.col),!c.enableRangeSelection))return;let r=v();r?.type!==`selection`||r.selectionKind!==`cell`||(c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.dispatch(e.gridActions.updateSelection(t)))},handleNativeDragStart:e=>{e.preventDefault()},handleRowHeaderPointerDown:(t,n)=>{if(!(!P(n,{kind:`row`,rowIndex:t})||c===null)){if(c.enableRowSelection){u=!0,c.onGutterRowSelect(t,{shiftKey:n.shiftKey}),N();return}if(n.shiftKey){let{selection:n,activeCell:r}=i.readLiveUiState(c),a=n?.type===`row`?n.startRow:r?.row;if(a!==void 0){c.dispatch(e.gridActions.startRowSelection(a,c.resolveFirstDataCell?.().col)),c.dispatch(e.gridActions.updateRowSelection(t));return}}c.dispatch(e.gridActions.startRowSelection(t,c.resolveFirstDataCell?.().col))}},handleRowHeaderPointerEnter:(t,n)=>{if(c===null)return;if(c.enableRowHover&&c.setHoveredRowIndex(t),u){c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.onGutterRowSelectDrag(t);return}let r=v();r?.type!==`selection`||r.selectionKind!==`row`||(c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.dispatch(e.gridActions.updateRowSelection(t)))},handleColumnHeaderPointerDown:(r,a)=>{if(!(!P(a,{kind:`col`,colIndex:r})||c===null)){if(a.shiftKey&&c.enableSorting){let a=c.orderedColumns[r];if(a&&!n.isSyntheticColumnKey(a.key)){let n=i.readLiveUiState(c).sort,r=n.find(e=>e.columnKey===a.key)?.direction?`desc`:`asc`,o=t.nextSortEntries(n,a.key,r,!0);c.dispatch(o.length===0?e.gridActions.clearSort():e.gridActions.setSort(o))}return}c.dispatch(e.gridActions.startColumnSelection(r,c.resolveFirstDataCell?.().row))}},handleColumnHeaderPointerEnter:(t,n)=>{if(c===null)return;c.setHoveredRowIndex(null),c.enableColumnHeaderHover&&c.setHoveredColumnIndex(t);let r=v();r?.type!==`selection`||r.selectionKind!==`col`||(c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.dispatch(e.gridActions.updateColumnSelection(t)))},dispose:()=>{k(),A(),m!==null&&(cancelAnimationFrame(m),m=null)}}};exports.TOUCH_DOUBLE_TAP_MS=l,exports.TOUCH_TAP_SLOP_PX=c,exports.createPointerInteractionsController=u;
|
|
@@ -31,6 +31,7 @@ export type PointerInteractionsArgs<T> = {
|
|
|
31
31
|
} | null>;
|
|
32
32
|
autoScrollFrameRef: MutableRef<number | null>;
|
|
33
33
|
uiState: GridUiState;
|
|
34
|
+
getUiState?: (() => GridUiState) | undefined;
|
|
34
35
|
dispatch: (action: GridUiAction) => void;
|
|
35
36
|
enableRangeSelection: boolean;
|
|
36
37
|
enableSorting: boolean;
|
|
@@ -2,21 +2,22 @@ import { gridActions as e } from "../model/gridActions.js";
|
|
|
2
2
|
import { nextSortEntries as t } from "../logic/sorting.js";
|
|
3
3
|
import { isSyntheticColumnKey as n } from "../logic/detailRow.js";
|
|
4
4
|
import { clamp as r, findLogicalIndexFromPaneOffset as i } from "../logic/geometry.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { readLiveUiState as a } from "./liveUiState.js";
|
|
6
|
+
import { clampClientYAboveFooter as o, clampClientYBelowHeader as s, computeNextScrollPosition as c, hasPointerLeftActivationRadius as l, resolveAutoScrollAxisDirection as u, resolveScrollContentBox as d, resolveTopAutoScrollStart as f } from "../logic/autoScrollGeometry.js";
|
|
7
|
+
import { resolveElementScale as p } from "../logic/elementScale.js";
|
|
8
|
+
import { clientYToRowIndex as m } from "../logic/verticalGeometry.js";
|
|
8
9
|
//#region src/controllers/pointerInteractionsController.ts
|
|
9
|
-
var
|
|
10
|
-
let
|
|
11
|
-
let t =
|
|
10
|
+
var h = 10, g = 300, _ = () => {
|
|
11
|
+
let h = null, g = !1, _ = !1, v = null, y = null, b = "mouse", x = null, S = null, C = !1, w = !1, T = () => h === null ? null : a(h).dragState ?? null, E = null, D = (e) => {
|
|
12
|
+
let t = h?.footerHeight ?? 0, n = h?.stickyTopHeight ?? 0, r = h?.scrollContainerRef.current ?? null;
|
|
12
13
|
if (t <= 0 && n <= 0 || !r) return e;
|
|
13
|
-
let i = r.getBoundingClientRect(),
|
|
14
|
-
return o(
|
|
15
|
-
},
|
|
16
|
-
if (
|
|
17
|
-
let { bodyScrollRef: n, scrollContainerRef: a, leftPaneScrollRef: o, rightPaneScrollRef: s, filteredRowsLength: c, visibleColumnsLength: l, paneLayout: u, leftLeadingWidth: d, centerLeadingWidth:
|
|
14
|
+
let i = r.getBoundingClientRect(), a = p(r, i);
|
|
15
|
+
return s(o(e, i.top + (r.clientTop + r.clientHeight) * a.y, t * a.y), i.top + r.clientTop * a.y, n * a.y);
|
|
16
|
+
}, O = (e, t) => {
|
|
17
|
+
if (h === null) return null;
|
|
18
|
+
let { bodyScrollRef: n, scrollContainerRef: a, leftPaneScrollRef: o, rightPaneScrollRef: s, filteredRowsLength: c, visibleColumnsLength: l, paneLayout: u, leftLeadingWidth: d, centerLeadingWidth: f, rightLeadingWidth: g, headerHeight: _, rowMetrics: v, verticalScaleFactor: y } = h, b = n.current;
|
|
18
19
|
if (!b || c === 0 || l === 0) return null;
|
|
19
|
-
let x = b.getBoundingClientRect(), S =
|
|
20
|
+
let x = b.getBoundingClientRect(), S = p(b, x), C = m(b.scrollTop + (D(t) - x.top) / S.y - _, a.current?.scrollTop ?? 0, y, v), w = null, T = o.current;
|
|
20
21
|
if (w === null && T && u.left.entries.length > 0) {
|
|
21
22
|
let t = T.getBoundingClientRect();
|
|
22
23
|
if (e < t.right) {
|
|
@@ -24,56 +25,56 @@ var m = 10, h = 300, g = () => {
|
|
|
24
25
|
w = i(u.left, n);
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
|
-
let
|
|
28
|
-
if (w === null &&
|
|
29
|
-
let t =
|
|
28
|
+
let E = s.current;
|
|
29
|
+
if (w === null && E && u.right.entries.length > 0) {
|
|
30
|
+
let t = E.getBoundingClientRect();
|
|
30
31
|
if (e >= t.left) {
|
|
31
32
|
let n = (e - t.left) / S.x - g;
|
|
32
33
|
w = i(u.right, n);
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
if (w === null && u.center.entries.length > 0) {
|
|
36
|
-
let t = T && u.left.entries.length === 0 ? Math.max(e, T.getBoundingClientRect().left + d * S.x) : e, n = b.scrollLeft + (t - x.left) / S.x -
|
|
37
|
+
let t = T && u.left.entries.length === 0 ? Math.max(e, T.getBoundingClientRect().left + d * S.x) : e, n = b.scrollLeft + (t - x.left) / S.x - f;
|
|
37
38
|
w = i(u.center, Math.max(n, 0));
|
|
38
39
|
}
|
|
39
40
|
return w === null ? null : {
|
|
40
41
|
row: C,
|
|
41
42
|
col: r(w, 0, l - 1)
|
|
42
43
|
};
|
|
43
|
-
},
|
|
44
|
-
let r =
|
|
45
|
-
if (
|
|
46
|
-
let i =
|
|
44
|
+
}, k = (t, n) => {
|
|
45
|
+
let r = T();
|
|
46
|
+
if (h === null || !r || r.type !== "selection") return;
|
|
47
|
+
let i = O(t, n);
|
|
47
48
|
if (i) {
|
|
48
49
|
if (r.selectionKind === "cell") {
|
|
49
|
-
|
|
50
|
+
h.dispatch(e.updateSelection(i));
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
53
|
if (r.selectionKind === "row") {
|
|
53
|
-
|
|
54
|
+
h.dispatch(e.updateRowSelection(i.row));
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
|
-
r.selectionKind === "col" &&
|
|
57
|
+
r.selectionKind === "col" && h.dispatch(e.updateColumnSelection(i.col));
|
|
57
58
|
}
|
|
58
|
-
},
|
|
59
|
+
}, A = (t, n) => {
|
|
59
60
|
let r = n.timeStamp;
|
|
60
|
-
if (
|
|
61
|
-
let { gridRootRef: i, dispatch: a, enableRangeSelection: o, enableRowSelection: s, onGutterRowSelect: c, onCellDoubleClickRef: l, resolveFirstDataCell: u } =
|
|
61
|
+
if (h === null) return;
|
|
62
|
+
let { gridRootRef: i, dispatch: a, enableRangeSelection: o, enableRowSelection: s, onGutterRowSelect: c, onCellDoubleClickRef: l, resolveFirstDataCell: u } = h;
|
|
62
63
|
i.current?.focus({ preventScroll: !0 });
|
|
63
64
|
let { target: d } = t;
|
|
64
65
|
if (d.kind === "cell") {
|
|
65
|
-
let t =
|
|
66
|
+
let t = y;
|
|
66
67
|
if (t && t.cell.row === d.cell.row && t.cell.col === d.cell.col && r - t.time < 300) {
|
|
67
|
-
|
|
68
|
+
y = null, l.current(d.cell, n);
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
+
y = {
|
|
71
72
|
cell: d.cell,
|
|
72
73
|
time: r
|
|
73
74
|
}, a(e.activateCell(d.cell)), o && (a(e.startSelection(d.cell)), a(e.endSelection()));
|
|
74
75
|
return;
|
|
75
76
|
}
|
|
76
|
-
if (
|
|
77
|
+
if (y = null, d.kind === "row") {
|
|
77
78
|
if (s) {
|
|
78
79
|
c(d.rowIndex, { shiftKey: !1 });
|
|
79
80
|
return;
|
|
@@ -82,50 +83,50 @@ var m = 10, h = 300, g = () => {
|
|
|
82
83
|
return;
|
|
83
84
|
}
|
|
84
85
|
a(e.startColumnSelection(d.colIndex, u?.().row)), a(e.endSelection());
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
},
|
|
88
|
-
if (
|
|
89
|
-
|
|
86
|
+
}, j = () => {
|
|
87
|
+
h !== null && (_ = !1, h.dispatch(e.endSelection()), h.dispatch(e.endColumnResize()));
|
|
88
|
+
}, M = (t) => {
|
|
89
|
+
if (h === null) return;
|
|
90
|
+
h.pointerClientRef.current = {
|
|
90
91
|
x: t.clientX,
|
|
91
92
|
y: t.clientY
|
|
92
93
|
};
|
|
93
|
-
let n =
|
|
94
|
+
let n = T();
|
|
94
95
|
if (n?.type === "columnResize") {
|
|
95
|
-
(
|
|
96
|
+
(E === null || E.drag !== n) && (E = {
|
|
96
97
|
drag: n,
|
|
97
|
-
x:
|
|
98
|
+
x: p(h.scrollContainerRef.current).x
|
|
98
99
|
});
|
|
99
|
-
let r =
|
|
100
|
-
|
|
100
|
+
let r = E.x === 1 ? t.clientX : n.startX + (t.clientX - n.startX) / E.x;
|
|
101
|
+
h.dispatch(e.updateColumnResize(r));
|
|
101
102
|
}
|
|
102
|
-
},
|
|
103
|
-
let t =
|
|
104
|
-
t && (
|
|
105
|
-
}, N = () => {
|
|
106
|
-
_ = null, A();
|
|
103
|
+
}, N = (e) => {
|
|
104
|
+
let t = v;
|
|
105
|
+
t && (v = null, e.pointerId === t.pointerId && Math.abs(e.clientX - t.x) < 10 && Math.abs(e.clientY - t.y) < 10 && A(t, e)), j();
|
|
107
106
|
}, P = () => {
|
|
108
|
-
|
|
107
|
+
v = null, j();
|
|
109
108
|
}, F = () => {
|
|
110
|
-
|
|
109
|
+
g || (g = !0, window.addEventListener("pointermove", M), window.addEventListener("pointerup", N), window.addEventListener("pointercancel", P));
|
|
111
110
|
}, I = () => {
|
|
112
|
-
|
|
111
|
+
g && (g = !1, window.removeEventListener("pointermove", M), window.removeEventListener("pointerup", N), window.removeEventListener("pointercancel", P));
|
|
113
112
|
}, L = () => {
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
w = !1, h !== null && h.autoScrollFrameRef.current !== null && (cancelAnimationFrame(h.autoScrollFrameRef.current), h.autoScrollFrameRef.current = null);
|
|
114
|
+
}, R = () => {
|
|
115
|
+
if (h === null || !w) return;
|
|
116
|
+
let { scrollContainerRef: e, pointerClientRef: t, autoScrollFrameRef: n } = h, r = e.current, i = t.current;
|
|
116
117
|
if (!r || !i) {
|
|
117
|
-
n.current = requestAnimationFrame(
|
|
118
|
+
n.current = requestAnimationFrame(R);
|
|
118
119
|
return;
|
|
119
120
|
}
|
|
120
|
-
if (!
|
|
121
|
-
let e =
|
|
122
|
-
if (e && !
|
|
123
|
-
n.current = requestAnimationFrame(
|
|
121
|
+
if (!C) {
|
|
122
|
+
let e = S;
|
|
123
|
+
if (e && !l(e, i, 6)) {
|
|
124
|
+
n.current = requestAnimationFrame(R);
|
|
124
125
|
return;
|
|
125
126
|
}
|
|
126
|
-
|
|
127
|
+
C = !0;
|
|
127
128
|
}
|
|
128
|
-
let a = r.getBoundingClientRect(), o =
|
|
129
|
+
let a = r.getBoundingClientRect(), o = p(r, a), s = d({
|
|
129
130
|
rectLeft: a.left,
|
|
130
131
|
rectTop: a.top,
|
|
131
132
|
clientLeft: r.clientLeft,
|
|
@@ -133,166 +134,166 @@ var m = 10, h = 300, g = () => {
|
|
|
133
134
|
clientWidth: r.clientWidth,
|
|
134
135
|
clientHeight: r.clientHeight,
|
|
135
136
|
scale: o
|
|
136
|
-
}),
|
|
137
|
-
(b !== r.scrollTop ||
|
|
137
|
+
}), m = T(), g = m?.type === "selection" && m.selectionKind === "col", _ = m?.type === "selection" && m.selectionKind === "row", v = g ? 0 : u(i.y, f(s.top, (h.stickyTopHeight ?? 0) * o.y, 24), s.bottom - (h.footerHeight ?? 0), 24), y = _ ? 0 : u(i.x, s.left, s.right, 24), b = c(r.scrollTop, v, 18, r.scrollHeight - r.clientHeight), x = c(r.scrollLeft, y, 18, r.scrollWidth - r.clientWidth);
|
|
138
|
+
(b !== r.scrollTop || x !== r.scrollLeft) && (r.scrollTo({
|
|
138
139
|
top: b,
|
|
139
|
-
left:
|
|
140
|
+
left: x,
|
|
140
141
|
behavior: "auto"
|
|
141
|
-
}),
|
|
142
|
-
}, R = () => {
|
|
143
|
-
let e = w()?.type === "selection";
|
|
144
|
-
e && !C ? (C = !0, m !== null && (m.autoScrollFrameRef.current = requestAnimationFrame(L))) : !e && C && I();
|
|
142
|
+
}), k(i.x, i.y)), n.current = requestAnimationFrame(R);
|
|
145
143
|
}, z = () => {
|
|
146
|
-
|
|
144
|
+
let e = T()?.type === "selection";
|
|
145
|
+
e && !w ? (w = !0, h !== null && (h.autoScrollFrameRef.current = requestAnimationFrame(R))) : !e && w && L();
|
|
146
|
+
}, B = () => {
|
|
147
|
+
if (x !== null) return;
|
|
147
148
|
let e = () => {
|
|
148
|
-
if (!
|
|
149
|
-
|
|
149
|
+
if (!_ || h === null) {
|
|
150
|
+
x = null;
|
|
150
151
|
return;
|
|
151
152
|
}
|
|
152
|
-
let { scrollContainerRef: t, pointerClientRef: n, onGutterRowSelectDrag: r } =
|
|
153
|
+
let { scrollContainerRef: t, pointerClientRef: n, onGutterRowSelectDrag: r } = h, i = t.current, a = n.current;
|
|
153
154
|
if (!i || !a) {
|
|
154
|
-
|
|
155
|
+
x = requestAnimationFrame(e);
|
|
155
156
|
return;
|
|
156
157
|
}
|
|
157
|
-
if (!
|
|
158
|
-
let t =
|
|
159
|
-
if (t && !
|
|
160
|
-
|
|
158
|
+
if (!C) {
|
|
159
|
+
let t = S;
|
|
160
|
+
if (t && !l(t, a, 6)) {
|
|
161
|
+
x = requestAnimationFrame(e);
|
|
161
162
|
return;
|
|
162
163
|
}
|
|
163
|
-
|
|
164
|
+
C = !0;
|
|
164
165
|
}
|
|
165
|
-
let o = i.getBoundingClientRect(),
|
|
166
|
+
let o = i.getBoundingClientRect(), s = p(i, o), m = d({
|
|
166
167
|
rectLeft: o.left,
|
|
167
168
|
rectTop: o.top,
|
|
168
169
|
clientLeft: i.clientLeft,
|
|
169
170
|
clientTop: i.clientTop,
|
|
170
171
|
clientWidth: i.clientWidth,
|
|
171
172
|
clientHeight: i.clientHeight,
|
|
172
|
-
scale:
|
|
173
|
-
}),
|
|
173
|
+
scale: s
|
|
174
|
+
}), g = u(a.y, f(m.top, (h.stickyTopHeight ?? 0) * s.y, 24), m.bottom - (h.footerHeight ?? 0), 24), v = c(i.scrollTop, g, 18, i.scrollHeight - i.clientHeight);
|
|
174
175
|
if (v !== i.scrollTop) {
|
|
175
176
|
i.scrollTo({
|
|
176
177
|
top: v,
|
|
177
178
|
left: i.scrollLeft,
|
|
178
179
|
behavior: "auto"
|
|
179
180
|
});
|
|
180
|
-
let e =
|
|
181
|
+
let e = O(a.x, a.y);
|
|
181
182
|
e && r(e.row);
|
|
182
183
|
}
|
|
183
|
-
|
|
184
|
+
x = requestAnimationFrame(e);
|
|
184
185
|
};
|
|
185
|
-
|
|
186
|
-
},
|
|
186
|
+
x = requestAnimationFrame(e);
|
|
187
|
+
}, V = (e, t) => (e.preventDefault(), h === null || e.button !== 0 ? !1 : (b = e.pointerType, e.pointerType === "touch" ? (v = {
|
|
187
188
|
pointerId: e.pointerId,
|
|
188
189
|
x: e.clientX,
|
|
189
190
|
y: e.clientY,
|
|
190
191
|
target: t
|
|
191
|
-
}, !1) : (
|
|
192
|
+
}, !1) : (h.gridRootRef.current?.focus({ preventScroll: !0 }), h.pointerClientRef.current = {
|
|
192
193
|
x: e.clientX,
|
|
193
194
|
y: e.clientY
|
|
194
|
-
},
|
|
195
|
+
}, S = {
|
|
195
196
|
x: e.clientX,
|
|
196
197
|
y: e.clientY
|
|
197
|
-
},
|
|
198
|
+
}, C = !1, !0)));
|
|
198
199
|
return {
|
|
199
200
|
update: (e) => {
|
|
200
|
-
|
|
201
|
+
h = e, F(), z();
|
|
201
202
|
},
|
|
202
|
-
getCellCoordFromClientPoint:
|
|
203
|
-
updateSelectionFromPointer:
|
|
203
|
+
getCellCoordFromClientPoint: O,
|
|
204
|
+
updateSelectionFromPointer: k,
|
|
204
205
|
handleCellPointerDown: (t, n) => {
|
|
205
|
-
if (!(!
|
|
206
|
+
if (!(!V(n, {
|
|
206
207
|
kind: "cell",
|
|
207
208
|
cell: t
|
|
208
|
-
}) ||
|
|
209
|
-
if (n.shiftKey &&
|
|
210
|
-
let { selection: n, activeCell: r } =
|
|
209
|
+
}) || h === null)) {
|
|
210
|
+
if (n.shiftKey && h.enableRangeSelection) {
|
|
211
|
+
let { selection: n, activeCell: r } = a(h), i = n?.type === "cell" ? n.range.start : r;
|
|
211
212
|
if (i) {
|
|
212
|
-
|
|
213
|
+
h.dispatch(e.startSelection(i)), h.dispatch(e.updateSelection(t));
|
|
213
214
|
return;
|
|
214
215
|
}
|
|
215
216
|
}
|
|
216
|
-
|
|
217
|
+
h.dispatch(e.activateCell(t)), h.enableRangeSelection && h.dispatch(e.startSelection(t));
|
|
217
218
|
}
|
|
218
219
|
},
|
|
219
220
|
handleCellDoubleClick: (e, t) => {
|
|
220
|
-
|
|
221
|
+
b === "touch" || h === null || h.onCellDoubleClickRef.current(e, t);
|
|
221
222
|
},
|
|
222
223
|
handleCellPointerEnter: (t, n) => {
|
|
223
|
-
if (
|
|
224
|
-
let r =
|
|
225
|
-
r?.type !== "selection" || r.selectionKind !== "cell" || (
|
|
224
|
+
if (h === null || (h.enableRowHover && h.setHoveredRowIndex(t.row), h.enableColumnHover && h.setHoveredColumnIndex(t.col), !h.enableRangeSelection)) return;
|
|
225
|
+
let r = T();
|
|
226
|
+
r?.type !== "selection" || r.selectionKind !== "cell" || (h.pointerClientRef.current = {
|
|
226
227
|
x: n.clientX,
|
|
227
228
|
y: n.clientY
|
|
228
|
-
},
|
|
229
|
+
}, h.dispatch(e.updateSelection(t)));
|
|
229
230
|
},
|
|
230
231
|
handleNativeDragStart: (e) => {
|
|
231
232
|
e.preventDefault();
|
|
232
233
|
},
|
|
233
234
|
handleRowHeaderPointerDown: (t, n) => {
|
|
234
|
-
if (!(!
|
|
235
|
+
if (!(!V(n, {
|
|
235
236
|
kind: "row",
|
|
236
237
|
rowIndex: t
|
|
237
|
-
}) ||
|
|
238
|
-
if (
|
|
239
|
-
|
|
238
|
+
}) || h === null)) {
|
|
239
|
+
if (h.enableRowSelection) {
|
|
240
|
+
_ = !0, h.onGutterRowSelect(t, { shiftKey: n.shiftKey }), B();
|
|
240
241
|
return;
|
|
241
242
|
}
|
|
242
243
|
if (n.shiftKey) {
|
|
243
|
-
let { selection: n, activeCell: r } =
|
|
244
|
+
let { selection: n, activeCell: r } = a(h), i = n?.type === "row" ? n.startRow : r?.row;
|
|
244
245
|
if (i !== void 0) {
|
|
245
|
-
|
|
246
|
+
h.dispatch(e.startRowSelection(i, h.resolveFirstDataCell?.().col)), h.dispatch(e.updateRowSelection(t));
|
|
246
247
|
return;
|
|
247
248
|
}
|
|
248
249
|
}
|
|
249
|
-
|
|
250
|
+
h.dispatch(e.startRowSelection(t, h.resolveFirstDataCell?.().col));
|
|
250
251
|
}
|
|
251
252
|
},
|
|
252
253
|
handleRowHeaderPointerEnter: (t, n) => {
|
|
253
|
-
if (
|
|
254
|
-
if (
|
|
255
|
-
|
|
254
|
+
if (h === null) return;
|
|
255
|
+
if (h.enableRowHover && h.setHoveredRowIndex(t), _) {
|
|
256
|
+
h.pointerClientRef.current = {
|
|
256
257
|
x: n.clientX,
|
|
257
258
|
y: n.clientY
|
|
258
|
-
},
|
|
259
|
+
}, h.onGutterRowSelectDrag(t);
|
|
259
260
|
return;
|
|
260
261
|
}
|
|
261
|
-
let r =
|
|
262
|
-
r?.type !== "selection" || r.selectionKind !== "row" || (
|
|
262
|
+
let r = T();
|
|
263
|
+
r?.type !== "selection" || r.selectionKind !== "row" || (h.pointerClientRef.current = {
|
|
263
264
|
x: n.clientX,
|
|
264
265
|
y: n.clientY
|
|
265
|
-
},
|
|
266
|
+
}, h.dispatch(e.updateRowSelection(t)));
|
|
266
267
|
},
|
|
267
268
|
handleColumnHeaderPointerDown: (r, i) => {
|
|
268
|
-
if (!(!
|
|
269
|
+
if (!(!V(i, {
|
|
269
270
|
kind: "col",
|
|
270
271
|
colIndex: r
|
|
271
|
-
}) ||
|
|
272
|
-
if (i.shiftKey &&
|
|
273
|
-
let i =
|
|
272
|
+
}) || h === null)) {
|
|
273
|
+
if (i.shiftKey && h.enableSorting) {
|
|
274
|
+
let i = h.orderedColumns[r];
|
|
274
275
|
if (i && !n(i.key)) {
|
|
275
|
-
let n =
|
|
276
|
-
|
|
276
|
+
let n = a(h).sort, r = n.find((e) => e.columnKey === i.key)?.direction ? "desc" : "asc", o = t(n, i.key, r, !0);
|
|
277
|
+
h.dispatch(o.length === 0 ? e.clearSort() : e.setSort(o));
|
|
277
278
|
}
|
|
278
279
|
return;
|
|
279
280
|
}
|
|
280
|
-
|
|
281
|
+
h.dispatch(e.startColumnSelection(r, h.resolveFirstDataCell?.().row));
|
|
281
282
|
}
|
|
282
283
|
},
|
|
283
284
|
handleColumnHeaderPointerEnter: (t, n) => {
|
|
284
|
-
if (
|
|
285
|
-
|
|
286
|
-
let r =
|
|
287
|
-
r?.type !== "selection" || r.selectionKind !== "col" || (
|
|
285
|
+
if (h === null) return;
|
|
286
|
+
h.setHoveredRowIndex(null), h.enableColumnHeaderHover && h.setHoveredColumnIndex(t);
|
|
287
|
+
let r = T();
|
|
288
|
+
r?.type !== "selection" || r.selectionKind !== "col" || (h.pointerClientRef.current = {
|
|
288
289
|
x: n.clientX,
|
|
289
290
|
y: n.clientY
|
|
290
|
-
},
|
|
291
|
+
}, h.dispatch(e.updateColumnSelection(t)));
|
|
291
292
|
},
|
|
292
293
|
dispose: () => {
|
|
293
|
-
|
|
294
|
+
I(), L(), x !== null && (cancelAnimationFrame(x), x = null);
|
|
294
295
|
}
|
|
295
296
|
};
|
|
296
297
|
};
|
|
297
298
|
//#endregion
|
|
298
|
-
export {
|
|
299
|
+
export { g as TOUCH_DOUBLE_TAP_MS, h as TOUCH_TAP_SLOP_PX, _ as createPointerInteractionsController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs");require("../logic/domGuards.cjs"),require("./escapeClaimController.cjs");var t=e
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/shadowDom.cjs"),t=require("../logic/detailRow.cjs");require("../logic/domGuards.cjs"),require("./escapeClaimController.cjs");var n=t=>{let n=e.getActiveElement(t);n instanceof HTMLElement&&n.blur(),t?.blur()},r=`input, textarea, select, [contenteditable]:not([contenteditable="false"])`,i=n=>{let i=n.current,a=i===null?null:e.getActiveElement(i);i!==null&&a!==null&&!i.contains(a)&&a.closest(`.ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover`)!==null&&(a.matches(r)?queueMicrotask(()=>{let t=n.current,r=t===null?null:e.getActiveElement(t);t!==null&&(r===null||r===t.ownerDocument.body)&&t.focus({preventScroll:!0})}):i.focus({preventScroll:!0})),requestAnimationFrame(()=>{let r=n.current;if(r===null||t.isFocusInsideDetailCard(r))return;let i=e.getActiveElement(r);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()})},a=`.ssg-toolpanel, .ssg-filter-popover`,o=t=>{let n=t.current,r=n===null?null:e.getActiveElement(n);return r!==null&&typeof r.closest==`function`&&r.closest(a)!==null},s=(e,t)=>e.current?.contains(t)===!0,c=(t,n,r=`[role="menuitem"]`)=>{let i=e.getActiveElement(t),a=i instanceof HTMLElement&&i!==t&&t.contains(i);if(a&&!i.matches(r))return!1;let o=n.key;if(o===`ArrowDown`||o===`ArrowUp`||o===`Home`||o===`End`){n.preventDefault();let e=Array.from(t.querySelectorAll(`${r}:not(:disabled):not([aria-disabled="true"])`));if(e.length===0)return!0;let s=a?e.indexOf(i):-1,c;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}return!a&&(o===`PageUp`||o===`PageDown`||o===` `||o===`ArrowLeft`||o===`ArrowRight`)?(n.preventDefault(),!0):!1},l=(t,n)=>{if(t===null||!t.isConnected)return;let r=e.getActiveElement(t),i=r!==null&&n!=null&&(r===n||n.contains(r)&&r.hasAttribute(`data-ssg-ime-input`));(r===null||r===t.ownerDocument.body||i)&&t.focus({preventScroll:!0})},u=t=>{let n=t.ownerDocument.defaultView;n!==null&&n.requestAnimationFrame(()=>{if(!t.isConnected)return;let n=e.getActiveElement(t);(n===null||n===t.ownerDocument.body||n===t.ownerDocument.documentElement)&&t.focus({preventScroll:!0})})},d=new Set,f=t=>{let n=!1,r=()=>t.onResize?.(),i=e=>t.onScroll?.(e),a=n=>{let r=e.getEventTarget(n,t.getGridRoot?.()??null);r&&(t.isInside(r)||t.onOutsidePointerDown(r))},o=e=>t.onKeyDown?.(e),s=null,c=null,l=()=>{let e=t.onOtherGridPopupOpen,n=t.getGridRoot?.()??null;if(!(!e||!n)){for(let e of Array.from(d))e.owner!==n&&(d.delete(e),e.close());c={owner:n,close:e},d.add(c)}},u=()=>{let e=t.getGridRoot?.()??null,r=t.onGridHidden;!e||!r||typeof ResizeObserver>`u`||(s=new ResizeObserver(t=>{let i=t[t.length-1];if(!n||!i||i.contentRect.width!==0||i.contentRect.height!==0)return;let a=e.getBoundingClientRect();a.width===0&&a.height===0&&r()}),s.observe(e))};return{attach:()=>{n||(n=!0,window.addEventListener(`resize`,r),window.addEventListener(`scroll`,i,!0),window.addEventListener(`pointerdown`,a),window.addEventListener(`keydown`,o,!0),u(),l())},detach:()=>{n&&(n=!1,c!==null&&(d.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))},isAttached:()=>n}};exports.blurForPopover=n,exports.createPopoverWindowBindings=f,exports.focusPanelIfIdle=l,exports.handleMenuKeyNavigation=c,exports.isFocusInPopupOpenedFromMenu=o,exports.isInsideGridRoot=s,exports.keepFocusAfterPress=u,exports.restoreGridFocus=i;
|
|
@@ -3,9 +3,11 @@ export type ReadonlyElementRef<E extends HTMLElement = HTMLElement> = {
|
|
|
3
3
|
};
|
|
4
4
|
export declare const blurForPopover: (gridRoot: HTMLElement | null) => void;
|
|
5
5
|
export declare const restoreGridFocus: (gridRootRef: ReadonlyElementRef) => void;
|
|
6
|
+
export declare const isFocusInPopupOpenedFromMenu: (gridRootRef: ReadonlyElementRef) => boolean;
|
|
6
7
|
export declare const isInsideGridRoot: (gridRootRef: ReadonlyElementRef, target: Node) => boolean;
|
|
7
8
|
export declare const handleMenuKeyNavigation: (panel: HTMLElement, event: KeyboardEvent, itemSelector?: string) => boolean;
|
|
8
9
|
export declare const focusPanelIfIdle: (panel: HTMLElement | null, gridRoot?: HTMLElement | null) => void;
|
|
10
|
+
export declare const keepFocusAfterPress: (trigger: HTMLElement) => void;
|
|
9
11
|
export type PopoverWindowHandlers = {
|
|
10
12
|
onResize?: () => void;
|
|
11
13
|
onScroll?: (event: Event) => void;
|
|
@@ -14,6 +16,7 @@ export type PopoverWindowHandlers = {
|
|
|
14
16
|
onKeyDown?: (event: KeyboardEvent) => void;
|
|
15
17
|
getGridRoot?: () => HTMLElement | null;
|
|
16
18
|
onGridHidden?: () => void;
|
|
19
|
+
onOtherGridPopupOpen?: () => void;
|
|
17
20
|
};
|
|
18
21
|
export type PopoverWindowBindings = {
|
|
19
22
|
attach: () => void;
|