@ishibashi0112/spreadsheet-grid-core 0.41.3 → 0.42.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 (47) hide show
  1. package/dist/controllers/clipboardController.cjs +1 -1
  2. package/dist/controllers/clipboardController.js +24 -24
  3. package/dist/controllers/columnMenuController.cjs +1 -1
  4. package/dist/controllers/columnMenuController.js +60 -60
  5. package/dist/controllers/contextMenuController.cjs +1 -1
  6. package/dist/controllers/contextMenuController.js +32 -32
  7. package/dist/controllers/editController.cjs +1 -1
  8. package/dist/controllers/editController.d.ts +3 -1
  9. package/dist/controllers/editController.js +77 -72
  10. package/dist/controllers/filterPopoverController.cjs +1 -1
  11. package/dist/controllers/filterPopoverController.js +78 -78
  12. package/dist/controllers/keyboardController.cjs +1 -1
  13. package/dist/controllers/keyboardController.js +2 -0
  14. package/dist/controllers/popoverSupport.cjs +1 -1
  15. package/dist/controllers/popoverSupport.d.ts +2 -1
  16. package/dist/controllers/popoverSupport.js +3 -3
  17. package/dist/controllers/serverSideRowModel.cjs +1 -1
  18. package/dist/controllers/serverSideRowModel.js +1 -1
  19. package/dist/controllers/toolPanelController.cjs +1 -1
  20. package/dist/controllers/toolPanelController.js +53 -53
  21. package/dist/engine/columnCommands.cjs +1 -1
  22. package/dist/engine/columnCommands.js +1 -1
  23. package/dist/engine/createGridEngine.cjs +1 -1
  24. package/dist/engine/createGridEngine.js +1 -1
  25. package/dist/engine/gridApi.cjs +1 -1
  26. package/dist/engine/gridApi.d.ts +2 -0
  27. package/dist/engine/gridApi.js +108 -82
  28. package/dist/engine/rowPipeline.cjs +1 -1
  29. package/dist/engine/rowPipeline.d.ts +1 -1
  30. package/dist/engine/rowPipeline.js +1 -1
  31. package/dist/logic/columnWidthState.cjs +1 -0
  32. package/dist/logic/columnWidthState.d.ts +2 -0
  33. package/dist/logic/columnWidthState.js +30 -0
  34. package/dist/logic/sorting.cjs +1 -1
  35. package/dist/logic/sorting.d.ts +1 -0
  36. package/dist/logic/sorting.js +81 -50
  37. package/dist/model/gridActions.cjs +1 -1
  38. package/dist/model/gridActions.d.ts +10 -1
  39. package/dist/model/gridActions.js +9 -0
  40. package/dist/model/gridReducer.cjs +1 -1
  41. package/dist/model/gridReducer.d.ts +2 -2
  42. package/dist/model/gridReducer.js +178 -110
  43. package/dist/model/gridTypes.core.d.ts +39 -8
  44. package/dist/utils/clipboard.cjs +6 -5
  45. package/dist/utils/clipboard.d.ts +2 -0
  46. package/dist/utils/clipboard.js +52 -17
  47. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("../model/gridActions.cjs"),n=require("../logic/geometry.cjs"),r=require("../logic/domGuards.cjs"),i=require("../utils/clipboard.cjs"),a=require("../logic/labelRows.cjs");var o=(e,t,n)=>{if(t===0||n===0||e?.type!==`cell`)return!1;let{start:r,end:i}=e.range,a=Math.min(r.row,i.row),o=Math.min(r.col,i.col),s=Math.max(r.row,i.row),c=Math.max(r.col,i.col);return a===0&&o===0&&s===t-1&&c===n-1},s=()=>{let s=null,c=e=>{s=e},l=e=>{let{isRowExportable:t,rowModel:n}=e;if(t)return(e,r)=>t(e,{viewRowIndex:r,rowKey:n.getRowKey(r)??r})},u=t=>{let{rowModel:n,visibleColumns:r}=t,i=n.getRowCount();if(i===0||r.length===0)return``;let a=l(t),o=[];for(let t=0;t<i;t+=1){let i=n.getRow(t);if(!i||a&&!a(i,t))continue;let s=r.map(t=>{let n=e.getCellValue(i,t);return t.formatClipboardValue?t.formatClipboardValue(n,i):String(n??``)});o.push(s.join(` `))}return o.join(`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("../model/gridActions.cjs"),n=require("../logic/geometry.cjs"),r=require("../logic/domGuards.cjs"),i=require("../utils/clipboard.cjs"),a=require("../logic/labelRows.cjs");var o=(e,t,n)=>{if(t===0||n===0||e?.type!==`cell`)return!1;let{start:r,end:i}=e.range,a=Math.min(r.row,i.row),o=Math.min(r.col,i.col),s=Math.max(r.row,i.row),c=Math.max(r.col,i.col);return a===0&&o===0&&s===t-1&&c===n-1},s=()=>{let s=null,c=e=>{s=e},l=e=>{let{isRowExportable:t,rowModel:n}=e;if(t)return(e,r)=>t(e,{viewRowIndex:r,rowKey:n.getRowKey(r)??r})},u=t=>{let{rowModel:n,visibleColumns:r}=t,a=n.getRowCount();if(a===0||r.length===0)return``;let o=l(t),s=[];for(let t=0;t<a;t+=1){let a=n.getRow(t);if(!a||o&&!o(a,t))continue;let c=r.map(t=>{let n=e.getCellValue(a,t);return t.formatClipboardValue?t.formatClipboardValue(n,a):String(n??``)});s.push(i.joinTsvRow(c))}return s.join(`
2
2
  `)};return{update:c,handleCopy:async()=>{if(s===null)return;let e=s,{rowModel:t,visibleColumns:n,uiState:r}=e,a=o(r.selection,t.getRowCount(),n.length)?u(e):i.serializeSelectionToTsv(t.getRow,t.getRowCount(),n,r.selection,l(e));a&&await i.writeTextToClipboard(a)},handlePaste:o=>{if(s===null)return;let{rows:c,rowModel:l,columns:u,visibleColumns:d,uiState:f,readOnly:p,canEditCell:m,createRow:h,createOverflowColumn:g,onRowsChange:_,onColumnsChange:v,applyServerSideCellEdits:y,dispatch:b}=s;if(f.editingCell||r.shouldIgnoreGridKeydown(o.target??null)||p||!_&&!y||!f.activeCell)return;let x=o.clipboardData?.getData(`text/plain`)??``;if(!x)return;o.preventDefault();let S=i.parseClipboardText(x);if(S.length===0)return;let C=S.reduce((e,t)=>Math.max(e,t.length),0);if(C===0)return;let w=f.activeCell.row,T=f.activeCell.col,E=l.getLabelRow===void 0?null:a.resolvePasteTargetViewIndexes(l,w,S.length),D=e=>E?E[e-w]:e,O=E?E[E.length-1]:f.activeCell.row+Math.max(S.length-1,0);if(y){let r=i.buildClipboardCellEdits(e=>l.getRow(D(e)),d,S,w,T,(t,n,r,i)=>e.isCellEditable({readOnly:p,canEditCell:m},D(t),n,r,i)).map(e=>({...e,viewIndex:D(e.viewIndex)}));r.length>0&&y(r);let a=n.clamp(O,0,Math.max(l.getRowCount()-1,0)),o=n.clamp(f.activeCell.col+Math.max(C-1,0),0,Math.max(d.length-1,0));b(t.gridActions.startSelection(f.activeCell)),b(t.gridActions.updateSelection({row:a,col:o})),b(t.gridActions.endSelection()),b(t.gridActions.activateCell(f.activeCell));return}if(!_||l.getSourceIndex(w)===void 0)return;let k=f.activeCell.col,A=[...c],j=[...d],M=l.getRowCount(),N=A.length,P=e=>{let t=D(e);return t<M?l.getSourceIndex(t):N+(t-M)},F=Math.max(O+1-M,0),I=A.length+F;if(I>A.length&&h)for(;A.length<I;)A.push(h());let L=k+C;if(L>j.length&&v&&g){let e=[];for(;j.length<L;){let t=g(j.length);j.push(t),e.push(t)}v(u?[...u,...e]:j)}let R=i.applyClipboardMatrixToRows(A,P,j,S,w,k,(t,n,r,i)=>e.isCellEditable({readOnly:p,canEditCell:m},t,n,r,i)),z=n.clamp(O,0,Math.max(Math.max(l.getRowCount()-1,0),O)),B=n.clamp(f.activeCell.col+Math.max((S[0]?.length??1)-1,0),0,Math.max(Math.max(j.length-1,0),k+C-1));_(R),b(t.gridActions.startSelection(f.activeCell)),b(t.gridActions.updateSelection({row:z,col:B})),b(t.gridActions.endSelection()),b(t.gridActions.activateCell(f.activeCell))}}};exports.computeIsWholeGridSelected=o,exports.createClipboardController=s;
@@ -2,58 +2,58 @@ import { getCellValue as e, isCellEditable as t } from "../utils/permissions.js"
2
2
  import { gridActions as n } from "../model/gridActions.js";
3
3
  import { clamp as r } from "../logic/geometry.js";
4
4
  import { shouldIgnoreGridKeydown as i } from "../logic/domGuards.js";
5
- import { applyClipboardMatrixToRows as a, buildClipboardCellEdits as o, parseClipboardText as s, serializeSelectionToTsv as c, writeTextToClipboard as l } from "../utils/clipboard.js";
6
- import { resolvePasteTargetViewIndexes as u } from "../logic/labelRows.js";
5
+ import { applyClipboardMatrixToRows as a, buildClipboardCellEdits as o, joinTsvRow as s, parseClipboardText as c, serializeSelectionToTsv as l, writeTextToClipboard as u } from "../utils/clipboard.js";
6
+ import { resolvePasteTargetViewIndexes as d } from "../logic/labelRows.js";
7
7
  //#region src/controllers/clipboardController.ts
8
- var d = (e, t, n) => {
8
+ var f = (e, t, n) => {
9
9
  if (t === 0 || n === 0 || e?.type !== "cell") return !1;
10
10
  let { start: r, end: i } = e.range, a = Math.min(r.row, i.row), o = Math.min(r.col, i.col), s = Math.max(r.row, i.row), c = Math.max(r.col, i.col);
11
11
  return a === 0 && o === 0 && s === t - 1 && c === n - 1;
12
- }, f = () => {
13
- let f = null, p = (e) => {
14
- f = e;
15
- }, m = (e) => {
12
+ }, p = () => {
13
+ let p = null, m = (e) => {
14
+ p = e;
15
+ }, h = (e) => {
16
16
  let { isRowExportable: t, rowModel: n } = e;
17
17
  if (t) return (e, r) => t(e, {
18
18
  viewRowIndex: r,
19
19
  rowKey: n.getRowKey(r) ?? r
20
20
  });
21
- }, h = (t) => {
21
+ }, g = (t) => {
22
22
  let { rowModel: n, visibleColumns: r } = t, i = n.getRowCount();
23
23
  if (i === 0 || r.length === 0) return "";
24
- let a = m(t), o = [];
24
+ let a = h(t), o = [];
25
25
  for (let t = 0; t < i; t += 1) {
26
26
  let i = n.getRow(t);
27
27
  if (!i || a && !a(i, t)) continue;
28
- let s = r.map((t) => {
28
+ let c = r.map((t) => {
29
29
  let n = e(i, t);
30
30
  return t.formatClipboardValue ? t.formatClipboardValue(n, i) : String(n ?? "");
31
31
  });
32
- o.push(s.join(" "));
32
+ o.push(s(c));
33
33
  }
34
34
  return o.join("\n");
35
35
  };
36
36
  return {
37
- update: p,
37
+ update: m,
38
38
  handleCopy: async () => {
39
- if (f === null) return;
40
- let e = f, { rowModel: t, visibleColumns: n, uiState: r } = e, i = d(r.selection, t.getRowCount(), n.length) ? h(e) : c(t.getRow, t.getRowCount(), n, r.selection, m(e));
41
- i && await l(i);
39
+ if (p === null) return;
40
+ let e = p, { rowModel: t, visibleColumns: n, uiState: r } = e, i = f(r.selection, t.getRowCount(), n.length) ? g(e) : l(t.getRow, t.getRowCount(), n, r.selection, h(e));
41
+ i && await u(i);
42
42
  },
43
43
  handlePaste: (e) => {
44
- if (f === null) return;
45
- let { rows: c, rowModel: l, columns: d, visibleColumns: p, uiState: m, readOnly: h, canEditCell: g, createRow: _, createOverflowColumn: v, onRowsChange: y, onColumnsChange: b, applyServerSideCellEdits: x, dispatch: S } = f;
44
+ if (p === null) return;
45
+ let { rows: s, rowModel: l, columns: u, visibleColumns: f, uiState: m, readOnly: h, canEditCell: g, createRow: _, createOverflowColumn: v, onRowsChange: y, onColumnsChange: b, applyServerSideCellEdits: x, dispatch: S } = p;
46
46
  if (m.editingCell || i(e.target ?? null) || h || !y && !x || !m.activeCell) return;
47
47
  let C = e.clipboardData?.getData("text/plain") ?? "";
48
48
  if (!C) return;
49
49
  e.preventDefault();
50
- let w = s(C);
50
+ let w = c(C);
51
51
  if (w.length === 0) return;
52
52
  let T = w.reduce((e, t) => Math.max(e, t.length), 0);
53
53
  if (T === 0) return;
54
- let E = m.activeCell.row, D = m.activeCell.col, O = l.getLabelRow === void 0 ? null : u(l, E, w.length), k = (e) => O ? O[e - E] : e, A = O ? O[O.length - 1] : m.activeCell.row + Math.max(w.length - 1, 0);
54
+ let E = m.activeCell.row, D = m.activeCell.col, O = l.getLabelRow === void 0 ? null : d(l, E, w.length), k = (e) => O ? O[e - E] : e, A = O ? O[O.length - 1] : m.activeCell.row + Math.max(w.length - 1, 0);
55
55
  if (x) {
56
- let e = o((e) => l.getRow(k(e)), p, w, E, D, (e, n, r, i) => t({
56
+ let e = o((e) => l.getRow(k(e)), f, w, E, D, (e, n, r, i) => t({
57
57
  readOnly: h,
58
58
  canEditCell: g
59
59
  }, k(e), n, r, i)).map((e) => ({
@@ -61,7 +61,7 @@ var d = (e, t, n) => {
61
61
  viewIndex: k(e.viewIndex)
62
62
  }));
63
63
  e.length > 0 && x(e);
64
- let i = r(A, 0, Math.max(l.getRowCount() - 1, 0)), a = r(m.activeCell.col + Math.max(T - 1, 0), 0, Math.max(p.length - 1, 0));
64
+ let i = r(A, 0, Math.max(l.getRowCount() - 1, 0)), a = r(m.activeCell.col + Math.max(T - 1, 0), 0, Math.max(f.length - 1, 0));
65
65
  S(n.startSelection(m.activeCell)), S(n.updateSelection({
66
66
  row: i,
67
67
  col: a
@@ -69,7 +69,7 @@ var d = (e, t, n) => {
69
69
  return;
70
70
  }
71
71
  if (!y || l.getSourceIndex(E) === void 0) return;
72
- let j = m.activeCell.col, M = [...c], N = [...p], P = l.getRowCount(), F = M.length, I = (e) => {
72
+ let j = m.activeCell.col, M = [...s], N = [...f], P = l.getRowCount(), F = M.length, I = (e) => {
73
73
  let t = k(e);
74
74
  return t < P ? l.getSourceIndex(t) : F + (t - P);
75
75
  }, L = Math.max(A + 1 - P, 0), R = M.length + L;
@@ -81,7 +81,7 @@ var d = (e, t, n) => {
81
81
  let t = v(N.length);
82
82
  N.push(t), e.push(t);
83
83
  }
84
- b(d ? [...d, ...e] : N);
84
+ b(u ? [...u, ...e] : N);
85
85
  }
86
86
  let B = a(M, I, N, w, E, j, (e, n, r, i) => t({
87
87
  readOnly: h,
@@ -95,4 +95,4 @@ var d = (e, t, n) => {
95
95
  };
96
96
  };
97
97
  //#endregion
98
- export { d as computeIsWholeGridSelected, f as createClipboardController };
98
+ export { f as computeIsWholeGridSelected, p as createClipboardController };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("./popoverSupport.cjs");var n=200,r=8,i=6,a=289,o=()=>{let o=null,s=e.createValueStore({columnKey:null,layout:null}),c={current:null},l=null,u=null,d=null,f=null,p=e=>{let t=s.getSnapshot(),n=t.layout;n===e||n!==null&&e!==null&&n.top===e.top&&n.left===e.left&&n.width===e.width&&n.maxHeight===e.maxHeight||s.setSnapshot({...t,layout:e})},m=()=>{f!==null&&(cancelAnimationFrame(f),f=null),_.detach(),s.setSnapshot({columnKey:null,layout:null})},h=()=>{if(s.getSnapshot().columnKey===null){p(null);return}let e,t,o,d=c.current,f=d?d.scrollHeight+(d.offsetHeight-d.clientHeight):a;if(l){if(!l.isConnected){l=null,m();return}let r=l.getBoundingClientRect();t=r.right-n,e=r.bottom+i,o=r.top-f-i}else if(u)t=u.x,e=u.y,o=u.y-f;else{p(null);return}t=Math.max(r,t),t=Math.min(t,window.innerWidth-n-r);let h=window.innerHeight-r;e+f>h&&o>=r&&(e=o),e=Math.max(r,e);let g=h-e;p({top:e,left:t,width:n,maxHeight:f>g?Math.max(g,0):void 0})},g=()=>{m(),l=null,u=null,o!==null&&t.restoreGridFocus(o.gridRootRef)},_=t.createPopoverWindowBindings({onResize:h,onScroll:()=>{if(u){g();return}h()},isInside:e=>c.current?.contains(e)===!0||l?.contains(e)===!0,onOutsidePointerDown:g,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),g())}}),v=e=>{s.setSnapshot({...s.getSnapshot(),columnKey:e}),h(),f!==null&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{f=null,h()}),_.attach()},y=(e,n)=>{t.blurForPopover(o?.gridRootRef.current??null),l=n,u=null,v(e.key)};return{update:e=>{o=e},subscribe:s.subscribe,getSnapshot:s.getSnapshot,panelRef:c,openFromButton:(e,t)=>{if(t.preventDefault(),t.stopPropagation(),!o?.enableColumnMenu||t.button!==0)return;let n=t.currentTarget;if(s.getSnapshot().columnKey===e.key&&l===n){g();return}if(t.pointerType===`touch`){d=n;return}y(e,n)},openFromButtonClick:(e,t)=>{let n=d;d=null,!(!o?.enableColumnMenu||n!==t.currentTarget)&&(t.preventDefault(),t.stopPropagation(),y(e,t.currentTarget))},openFromContextMenu:(e,n)=>{o?.enableColumnMenu&&(n.preventDefault(),n.stopPropagation(),t.blurForPopover(o.gridRootRef.current),l=null,u={x:n.clientX,y:n.clientY},v(e.key))},close:g,dispose:()=>{f!==null&&(cancelAnimationFrame(f),f=null),_.detach()}}};exports.createColumnMenuController=o;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("./popoverSupport.cjs");var n=200,r=8,i=6,a=289,o=()=>{let o=null,s=e.createValueStore({columnKey:null,layout:null}),c={current:null},l=null,u=null,d=null,f=null,p=e=>{let t=s.getSnapshot(),n=t.layout;n===e||n!==null&&e!==null&&n.top===e.top&&n.left===e.left&&n.width===e.width&&n.maxHeight===e.maxHeight||s.setSnapshot({...t,layout:e})},m=()=>{f!==null&&(cancelAnimationFrame(f),f=null),v.detach(),s.setSnapshot({columnKey:null,layout:null})},h=()=>{if(s.getSnapshot().columnKey===null){p(null);return}let e,t,o,d=c.current,f=d?d.scrollHeight+(d.offsetHeight-d.clientHeight):a;if(l){if(!l.isConnected){l=null,m();return}let r=l.getBoundingClientRect();t=r.right-n,e=r.bottom+i,o=r.top-f-i}else if(u)t=u.x,e=u.y,o=u.y-f;else{p(null);return}t=Math.max(r,t),t=Math.min(t,window.innerWidth-n-r);let h=window.innerHeight-r;e+f>h&&o>=r&&(e=o),e=Math.max(r,e);let g=h-e;p({top:e,left:t,width:n,maxHeight:f>g?Math.max(g,0):void 0})},g=e=>{m(),l=null,u=null,o!==null&&e&&t.restoreGridFocus(o.gridRootRef)},_=()=>g(!0),v=t.createPopoverWindowBindings({onResize:h,onScroll:()=>{if(u){_();return}h()},isInside:e=>c.current?.contains(e)===!0||l?.contains(e)===!0,onOutsidePointerDown:e=>g(o!==null&&t.isInsideGridRoot(o.gridRootRef,e)),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),_())}}),y=e=>{s.setSnapshot({...s.getSnapshot(),columnKey:e}),h(),f!==null&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{f=null,h()}),v.attach()},b=(e,n)=>{t.blurForPopover(o?.gridRootRef.current??null),l=n,u=null,y(e.key)};return{update:e=>{o=e},subscribe:s.subscribe,getSnapshot:s.getSnapshot,panelRef:c,openFromButton:(e,t)=>{if(t.preventDefault(),t.stopPropagation(),!o?.enableColumnMenu||t.button!==0)return;let n=t.currentTarget;if(s.getSnapshot().columnKey===e.key&&l===n){_();return}if(t.pointerType===`touch`){d=n;return}b(e,n)},openFromButtonClick:(e,t)=>{let n=d;d=null,!(!o?.enableColumnMenu||n!==t.currentTarget)&&(t.preventDefault(),t.stopPropagation(),b(e,t.currentTarget))},openFromContextMenu:(e,n)=>{o?.enableColumnMenu&&(n.preventDefault(),n.stopPropagation(),t.blurForPopover(o.gridRootRef.current),l=null,u={x:n.clientX,y:n.clientY},y(e.key))},close:_,dispose:()=>{f!==null&&(cancelAnimationFrame(f),f=null),v.detach()}}};exports.createColumnMenuController=o;
@@ -1,110 +1,110 @@
1
1
  import { createValueStore as e } from "../logic/valueStore.js";
2
- import { blurForPopover as t, createPopoverWindowBindings as n, restoreGridFocus as r } from "./popoverSupport.js";
2
+ import { blurForPopover as t, createPopoverWindowBindings as n, isInsideGridRoot as r, restoreGridFocus as i } from "./popoverSupport.js";
3
3
  //#region src/controllers/columnMenuController.ts
4
- var i = 200, a = 8, o = 6, s = 289, c = () => {
5
- let c = null, l = e({
4
+ var a = 200, o = 8, s = 6, c = 289, l = () => {
5
+ let l = null, u = e({
6
6
  columnKey: null,
7
7
  layout: null
8
- }), u = { current: null }, d = null, f = null, p = null, m = null, h = (e) => {
9
- let t = l.getSnapshot(), n = t.layout;
10
- n === e || n !== null && e !== null && n.top === e.top && n.left === e.left && n.width === e.width && n.maxHeight === e.maxHeight || l.setSnapshot({
8
+ }), d = { current: null }, f = null, p = null, m = null, h = null, g = (e) => {
9
+ let t = u.getSnapshot(), n = t.layout;
10
+ n === e || n !== null && e !== null && n.top === e.top && n.left === e.left && n.width === e.width && n.maxHeight === e.maxHeight || u.setSnapshot({
11
11
  ...t,
12
12
  layout: e
13
13
  });
14
- }, g = () => {
15
- m !== null && (cancelAnimationFrame(m), m = null), y.detach(), l.setSnapshot({
14
+ }, _ = () => {
15
+ h !== null && (cancelAnimationFrame(h), h = null), x.detach(), u.setSnapshot({
16
16
  columnKey: null,
17
17
  layout: null
18
18
  });
19
- }, _ = () => {
20
- if (l.getSnapshot().columnKey === null) {
21
- h(null);
19
+ }, v = () => {
20
+ if (u.getSnapshot().columnKey === null) {
21
+ g(null);
22
22
  return;
23
23
  }
24
- let e, t, n, r = u.current, c = r ? r.scrollHeight + (r.offsetHeight - r.clientHeight) : s;
25
- if (d) {
26
- if (!d.isConnected) {
27
- d = null, g();
24
+ let e, t, n, r = d.current, i = r ? r.scrollHeight + (r.offsetHeight - r.clientHeight) : c;
25
+ if (f) {
26
+ if (!f.isConnected) {
27
+ f = null, _();
28
28
  return;
29
29
  }
30
- let r = d.getBoundingClientRect();
31
- t = r.right - i, e = r.bottom + o, n = r.top - c - o;
32
- } else if (f) t = f.x, e = f.y, n = f.y - c;
30
+ let r = f.getBoundingClientRect();
31
+ t = r.right - a, e = r.bottom + s, n = r.top - i - s;
32
+ } else if (p) t = p.x, e = p.y, n = p.y - i;
33
33
  else {
34
- h(null);
34
+ g(null);
35
35
  return;
36
36
  }
37
- t = Math.max(a, t), t = Math.min(t, window.innerWidth - i - a);
38
- let p = window.innerHeight - a;
39
- e + c > p && n >= a && (e = n), e = Math.max(a, e);
40
- let m = p - e;
41
- h({
37
+ t = Math.max(o, t), t = Math.min(t, window.innerWidth - a - o);
38
+ let l = window.innerHeight - o;
39
+ e + i > l && n >= o && (e = n), e = Math.max(o, e);
40
+ let m = l - e;
41
+ g({
42
42
  top: e,
43
43
  left: t,
44
- width: i,
45
- maxHeight: c > m ? Math.max(m, 0) : void 0
44
+ width: a,
45
+ maxHeight: i > m ? Math.max(m, 0) : void 0
46
46
  });
47
- }, v = () => {
48
- g(), d = null, f = null, c !== null && r(c.gridRootRef);
49
- }, y = n({
50
- onResize: _,
47
+ }, y = (e) => {
48
+ _(), f = null, p = null, l !== null && e && i(l.gridRootRef);
49
+ }, b = () => y(!0), x = n({
50
+ onResize: v,
51
51
  onScroll: () => {
52
- if (f) {
53
- v();
52
+ if (p) {
53
+ b();
54
54
  return;
55
55
  }
56
- _();
56
+ v();
57
57
  },
58
- isInside: (e) => u.current?.contains(e) === !0 || d?.contains(e) === !0,
59
- onOutsidePointerDown: v,
58
+ isInside: (e) => d.current?.contains(e) === !0 || f?.contains(e) === !0,
59
+ onOutsidePointerDown: (e) => y(l !== null && r(l.gridRootRef, e)),
60
60
  onKeyDown: (e) => {
61
- e.key === "Escape" && (e.preventDefault(), v());
61
+ e.key === "Escape" && (e.preventDefault(), b());
62
62
  }
63
- }), b = (e) => {
64
- l.setSnapshot({
65
- ...l.getSnapshot(),
63
+ }), S = (e) => {
64
+ u.setSnapshot({
65
+ ...u.getSnapshot(),
66
66
  columnKey: e
67
- }), _(), m !== null && cancelAnimationFrame(m), m = requestAnimationFrame(() => {
68
- m = null, _();
69
- }), y.attach();
70
- }, x = (e, n) => {
71
- t(c?.gridRootRef.current ?? null), d = n, f = null, b(e.key);
67
+ }), v(), h !== null && cancelAnimationFrame(h), h = requestAnimationFrame(() => {
68
+ h = null, v();
69
+ }), x.attach();
70
+ }, C = (e, n) => {
71
+ t(l?.gridRootRef.current ?? null), f = n, p = null, S(e.key);
72
72
  };
73
73
  return {
74
74
  update: (e) => {
75
- c = e;
75
+ l = e;
76
76
  },
77
- subscribe: l.subscribe,
78
- getSnapshot: l.getSnapshot,
79
- panelRef: u,
77
+ subscribe: u.subscribe,
78
+ getSnapshot: u.getSnapshot,
79
+ panelRef: d,
80
80
  openFromButton: (e, t) => {
81
- if (t.preventDefault(), t.stopPropagation(), !c?.enableColumnMenu || t.button !== 0) return;
81
+ if (t.preventDefault(), t.stopPropagation(), !l?.enableColumnMenu || t.button !== 0) return;
82
82
  let n = t.currentTarget;
83
- if (l.getSnapshot().columnKey === e.key && d === n) {
84
- v();
83
+ if (u.getSnapshot().columnKey === e.key && f === n) {
84
+ b();
85
85
  return;
86
86
  }
87
87
  if (t.pointerType === "touch") {
88
- p = n;
88
+ m = n;
89
89
  return;
90
90
  }
91
- x(e, n);
91
+ C(e, n);
92
92
  },
93
93
  openFromButtonClick: (e, t) => {
94
- let n = p;
95
- p = null, !(!c?.enableColumnMenu || n !== t.currentTarget) && (t.preventDefault(), t.stopPropagation(), x(e, t.currentTarget));
94
+ let n = m;
95
+ m = null, !(!l?.enableColumnMenu || n !== t.currentTarget) && (t.preventDefault(), t.stopPropagation(), C(e, t.currentTarget));
96
96
  },
97
97
  openFromContextMenu: (e, n) => {
98
- c?.enableColumnMenu && (n.preventDefault(), n.stopPropagation(), t(c.gridRootRef.current), d = null, f = {
98
+ l?.enableColumnMenu && (n.preventDefault(), n.stopPropagation(), t(l.gridRootRef.current), f = null, p = {
99
99
  x: n.clientX,
100
100
  y: n.clientY
101
- }, b(e.key));
101
+ }, S(e.key));
102
102
  },
103
- close: v,
103
+ close: b,
104
104
  dispose: () => {
105
- m !== null && (cancelAnimationFrame(m), m = null), y.detach();
105
+ h !== null && (cancelAnimationFrame(h), h = null), x.detach();
106
106
  }
107
107
  };
108
108
  };
109
109
  //#endregion
110
- export { c as createColumnMenuController };
110
+ export { l as createColumnMenuController };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("./popoverSupport.cjs");var n=220,r=8,i=34,a=16,o=()=>{let o=null,s=e.createValueStore({state:null,layout:null}),c={current:null},l=null,u=0,d=e=>{let t=s.getSnapshot();t.layout===e||t.layout!==null&&e!==null&&t.layout.top===e.top&&t.layout.left===e.left&&t.layout.width===e.width||s.setSnapshot({...t,layout:e})},f=()=>{if(!l){d(null);return}let e=u*i+a,t=l.x,o=l.y,s=l.y-e;t=Math.max(r,t),t=Math.min(t,window.innerWidth-n-r),o+e>window.innerHeight-r&&(o=s),o=Math.max(r,o),d({top:o,left:t,width:n})},p=()=>{s.setSnapshot({state:null,layout:null}),l=null,u=0,m.detach(),o!==null&&t.restoreGridFocus(o.gridRootRef)},m=t.createPopoverWindowBindings({onResize:f,onScroll:p,isInside:e=>c.current?.contains(e)===!0,onOutsidePointerDown:p,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),p())}});return{update:e=>{o=e},subscribe:s.subscribe,getSnapshot:s.getSnapshot,panelRef:c,open:(e,n)=>{t.blurForPopover(o?.gridRootRef.current??null),l={x:e.clientX,y:e.clientY},u=n.length,s.setSnapshot({...s.getSnapshot(),state:{params:e,items:n}}),f(),m.attach()},close:p,dispose:()=>{m.detach()}}};exports.createContextMenuController=o;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("./popoverSupport.cjs");var n=220,r=8,i=34,a=16,o=()=>{let o=null,s=e.createValueStore({state:null,layout:null}),c={current:null},l=null,u=0,d=e=>{let t=s.getSnapshot();t.layout===e||t.layout!==null&&e!==null&&t.layout.top===e.top&&t.layout.left===e.left&&t.layout.width===e.width||s.setSnapshot({...t,layout:e})},f=()=>{if(!l){d(null);return}let e=u*i+a,t=l.x,o=l.y,s=l.y-e;t=Math.max(r,t),t=Math.min(t,window.innerWidth-n-r),o+e>window.innerHeight-r&&(o=s),o=Math.max(r,o),d({top:o,left:t,width:n})},p=e=>{s.setSnapshot({state:null,layout:null}),l=null,u=0,h.detach(),o!==null&&e&&t.restoreGridFocus(o.gridRootRef)},m=()=>p(!0),h=t.createPopoverWindowBindings({onResize:f,onScroll:m,isInside:e=>c.current?.contains(e)===!0,onOutsidePointerDown:e=>p(o!==null&&t.isInsideGridRoot(o.gridRootRef,e)),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),m())}});return{update:e=>{o=e},subscribe:s.subscribe,getSnapshot:s.getSnapshot,panelRef:c,open:(e,n)=>{t.blurForPopover(o?.gridRootRef.current??null),l={x:e.clientX,y:e.clientY},u=n.length,s.setSnapshot({...s.getSnapshot(),state:{params:e,items:n}}),f(),h.attach()},close:m,dispose:()=>{h.detach()}}};exports.createContextMenuController=o;
@@ -1,65 +1,65 @@
1
1
  import { createValueStore as e } from "../logic/valueStore.js";
2
- import { blurForPopover as t, createPopoverWindowBindings as n, restoreGridFocus as r } from "./popoverSupport.js";
2
+ import { blurForPopover as t, createPopoverWindowBindings as n, isInsideGridRoot as r, restoreGridFocus as i } from "./popoverSupport.js";
3
3
  //#region src/controllers/contextMenuController.ts
4
- var i = 220, a = 8, o = 34, s = 16, c = () => {
5
- let c = null, l = e({
4
+ var a = 220, o = 8, s = 34, c = 16, l = () => {
5
+ let l = null, u = e({
6
6
  state: null,
7
7
  layout: null
8
- }), u = { current: null }, d = null, f = 0, p = (e) => {
9
- let t = l.getSnapshot();
10
- t.layout === e || t.layout !== null && e !== null && t.layout.top === e.top && t.layout.left === e.left && t.layout.width === e.width || l.setSnapshot({
8
+ }), d = { current: null }, f = null, p = 0, m = (e) => {
9
+ let t = u.getSnapshot();
10
+ t.layout === e || t.layout !== null && e !== null && t.layout.top === e.top && t.layout.left === e.left && t.layout.width === e.width || u.setSnapshot({
11
11
  ...t,
12
12
  layout: e
13
13
  });
14
- }, m = () => {
15
- if (!d) {
16
- p(null);
14
+ }, h = () => {
15
+ if (!f) {
16
+ m(null);
17
17
  return;
18
18
  }
19
- let e = f * o + s, t = d.x, n = d.y, r = d.y - e;
20
- t = Math.max(a, t), t = Math.min(t, window.innerWidth - i - a), n + e > window.innerHeight - a && (n = r), n = Math.max(a, n), p({
19
+ let e = p * s + c, t = f.x, n = f.y, r = f.y - e;
20
+ t = Math.max(o, t), t = Math.min(t, window.innerWidth - a - o), n + e > window.innerHeight - o && (n = r), n = Math.max(o, n), m({
21
21
  top: n,
22
22
  left: t,
23
- width: i
23
+ width: a
24
24
  });
25
- }, h = () => {
26
- l.setSnapshot({
25
+ }, g = (e) => {
26
+ u.setSnapshot({
27
27
  state: null,
28
28
  layout: null
29
- }), d = null, f = 0, g.detach(), c !== null && r(c.gridRootRef);
30
- }, g = n({
31
- onResize: m,
32
- onScroll: h,
33
- isInside: (e) => u.current?.contains(e) === !0,
34
- onOutsidePointerDown: h,
29
+ }), f = null, p = 0, v.detach(), l !== null && e && i(l.gridRootRef);
30
+ }, _ = () => g(!0), v = n({
31
+ onResize: h,
32
+ onScroll: _,
33
+ isInside: (e) => d.current?.contains(e) === !0,
34
+ onOutsidePointerDown: (e) => g(l !== null && r(l.gridRootRef, e)),
35
35
  onKeyDown: (e) => {
36
- e.key === "Escape" && (e.preventDefault(), h());
36
+ e.key === "Escape" && (e.preventDefault(), _());
37
37
  }
38
38
  });
39
39
  return {
40
40
  update: (e) => {
41
- c = e;
41
+ l = e;
42
42
  },
43
- subscribe: l.subscribe,
44
- getSnapshot: l.getSnapshot,
45
- panelRef: u,
43
+ subscribe: u.subscribe,
44
+ getSnapshot: u.getSnapshot,
45
+ panelRef: d,
46
46
  open: (e, n) => {
47
- t(c?.gridRootRef.current ?? null), d = {
47
+ t(l?.gridRootRef.current ?? null), f = {
48
48
  x: e.clientX,
49
49
  y: e.clientY
50
- }, f = n.length, l.setSnapshot({
51
- ...l.getSnapshot(),
50
+ }, p = n.length, u.setSnapshot({
51
+ ...u.getSnapshot(),
52
52
  state: {
53
53
  params: e,
54
54
  items: n
55
55
  }
56
- }), m(), g.attach();
56
+ }), h(), v.attach();
57
57
  },
58
- close: h,
58
+ close: _,
59
59
  dispose: () => {
60
- g.detach();
60
+ v.detach();
61
61
  }
62
62
  };
63
63
  };
64
64
  //#endregion
65
- export { c as createContextMenuController };
65
+ export { l as createContextMenuController };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs"),t=require("../model/gridActions.cjs"),n=require("../logic/geometry.cjs"),r=require("../logic/editorValues.cjs"),i=require("../logic/validation.cjs");var a=()=>{let a=null,o=null,s=(e,t)=>{let n=e.visibleColumns[t.col];return!n||t.row<0||t.row>=e.rowModel.getRowCount()||e.rowModel.getRow(t.row)===void 0?null:{rowKey:e.rowModel.getRowKey(t.row),columnKey:n.key}},c=(e,t)=>{let n=e.visibleColumns.findIndex(e=>e.key===t.columnKey);if(n<0)return null;let r=e.rowModel.getRowCount();for(let i=0;i<r;i+=1)if(e.rowModel.getRow(i)!==void 0&&Object.is(e.rowModel.getRowKey(i),t.rowKey))return{row:i,col:n};return null},l=e=>{a=e;let n=e.uiState.editingCell;if(!n){o=null;return}let r=s(e,n);if(o!==null&&r!==null&&Object.is(r.rowKey,o.rowKey)&&r.columnKey===o.columnKey){o={...o,cell:n};return}let i=o!==null&&o.cell.row===n.row&&o.cell.col===n.col;if(o===null||!i){o=r?{...r,cell:n}:null;return}let l=c(e,o);l?(o={...o,cell:l},e.dispatch(t.gridActions.startEdit(l))):(o=null,e.dispatch(t.gridActions.stopEdit()))},u=e=>{a!==null&&(a.dispatch(t.gridActions.startSelection(e)),a.dispatch(t.gridActions.endSelection()),a.dispatch(t.gridActions.activateCell(e)))},d=(e,n)=>{a!==null&&(a.setEditorInitialValue(n),a.dispatch(t.gridActions.startEdit(e)))},f=t=>{let r=a;r!==null&&requestAnimationFrame(()=>{if(e.isFocusInsideDetailCard()||r.gridRootRef.current?.focus(),t!==null&&a!==null){let e=a.rowModel.getRowCount(),r=a.visibleColumns.length;u({row:n.clamp(t.row,0,Math.max(e-1,0)),col:n.clamp(t.col,0,Math.max(r-1,0))})}r.editorActionGuardRef.current=!1})};return{update:l,activateSingleCell:u,startEditWithValue:d,commitEdit:(e,n)=>{if(a===null)return{status:`noop`};let{uiState:o,visibleColumns:s,rowModel:c,rows:l,applyServerSideCellEdits:u,onRowsChange:d,dispatch:p,editorActionGuardRef:m}=a;if(m.current||!o.editingCell)return{status:`noop`};let h=o.editingCell,g=n===`down`?{row:h.row+1,col:h.col}:n===`up`?{row:h.row-1,col:h.col}:n===`right`?{row:h.row,col:h.col+1}:n===`left`?{row:h.row,col:h.col-1}:h,_=s[h.col],v=c.getSourceIndex(h.row),y=u?c.getRow(h.row):l[v];if(!_||!y)return p(t.gridActions.stopEdit()),{status:`noop`};if(u){let t=r.parseCommittedValue(_,e,y),n=i.decideCellWrite(_,y,t);if(n.action===`reject`)return{status:`rejected`,message:n.message};u([{viewIndex:h.row,column:_,value:t}])}else if(d){let t=r.parseCommittedValue(_,e,y),n=i.decideCellWrite(_,y,t);if(n.action===`reject`)return{status:`rejected`,message:n.message};d(r.writeRowsCell(l,v,_,t))}return m.current=!0,f(g),p(t.gridActions.stopEdit()),{status:`committed`}},cancelEdit:()=>{a===null||a.editorActionGuardRef.current||(a.editorActionGuardRef.current=!0,a.dispatch(t.gridActions.stopEdit()),f(null))}}};exports.createEditController=a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("../logic/detailRow.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/geometry.cjs"),i=require("../logic/editorValues.cjs"),a=require("../logic/validation.cjs");var o=()=>{let o=null,s=null,c=(e,t)=>{let n=e.visibleColumns[t.col];return!n||t.row<0||t.row>=e.rowModel.getRowCount()||e.rowModel.getRow(t.row)===void 0?null:{rowKey:e.rowModel.getRowKey(t.row),columnKey:n.key}},l=(e,t)=>{let n=e.visibleColumns.findIndex(e=>e.key===t.columnKey);if(n<0)return null;let r=e.rowModel.getRowCount();for(let i=0;i<r;i+=1)if(e.rowModel.getRow(i)!==void 0&&Object.is(e.rowModel.getRowKey(i),t.rowKey))return{row:i,col:n};return null},u=e=>{o=e;let t=e.uiState.editingCell;if(!t){s=null;return}let r=c(e,t);if(s!==null&&r!==null&&Object.is(r.rowKey,s.rowKey)&&r.columnKey===s.columnKey){s={...s,cell:t};return}let i=s!==null&&s.cell.row===t.row&&s.cell.col===t.col;if(s===null||!i){s=r?{...r,cell:t}:null;return}let a=l(e,s);a?(s={...s,cell:a},e.dispatch(n.gridActions.startEdit(a))):(s=null,e.dispatch(n.gridActions.stopEdit()))},d=e=>{o!==null&&(o.dispatch(n.gridActions.startSelection(e)),o.dispatch(n.gridActions.endSelection()),o.dispatch(n.gridActions.activateCell(e)))},f=(e,t)=>{o!==null&&(o.setEditorInitialValue(t),o.dispatch(n.gridActions.startEdit(e)))},p=e=>{let n=o;n!==null&&requestAnimationFrame(()=>{if(t.isFocusInsideDetailCard()||n.gridRootRef.current?.focus(),e!==null&&o!==null){let t=o.rowModel.getRowCount(),n=o.visibleColumns.length;d({row:r.clamp(e.row,0,Math.max(t-1,0)),col:r.clamp(e.col,0,Math.max(n-1,0))})}n.editorActionGuardRef.current=!1})};return{update:u,activateSingleCell:d,startEditWithValue:f,commitEdit:(t,r)=>{if(o===null)return{status:`noop`};let{uiState:s,visibleColumns:c,rowModel:l,rows:u,applyServerSideCellEdits:d,onRowsChange:f,dispatch:m,editorActionGuardRef:h}=o;if(h.current||!s.editingCell)return{status:`noop`};let g=s.editingCell,_=r===`down`?{row:g.row+1,col:g.col}:r===`up`?{row:g.row-1,col:g.col}:r===`right`?{row:g.row,col:g.col+1}:r===`left`?{row:g.row,col:g.col-1}:g,v=c[g.col],y=l.getSourceIndex(g.row),b=d?l.getRow(g.row):u[y];if(!v||!b)return m(n.gridActions.stopEdit()),{status:`noop`};if(!e.isCellEditable({readOnly:o.readOnly,canEditCell:o.canEditCell},g.row,g.col,b,v))return h.current=!0,m(n.gridActions.stopEdit()),p(null),{status:`noop`};if(d){let e=i.parseCommittedValue(v,t,b),n=a.decideCellWrite(v,b,e);if(n.action===`reject`)return{status:`rejected`,message:n.message};d([{viewIndex:g.row,column:v,value:e}])}else if(f){let e=i.parseCommittedValue(v,t,b),n=a.decideCellWrite(v,b,e);if(n.action===`reject`)return{status:`rejected`,message:n.message};f(i.writeRowsCell(u,y,v,e))}return h.current=!0,p(_),m(n.gridActions.stopEdit()),{status:`committed`}},cancelEdit:()=>{o===null||o.editorActionGuardRef.current||(o.editorActionGuardRef.current=!0,o.dispatch(n.gridActions.stopEdit()),p(null))}}};exports.createEditController=o;
@@ -1,5 +1,5 @@
1
1
  import { type GridUiAction } from '../model/gridActions.js';
2
- import type { CellCoord, EditorCommitDirection, EditorCommitResult, GridColumn, GridUiState, RowModel } from '../model/gridTypes.unbound.js';
2
+ import type { CellCoord, EditorCommitDirection, EditorCommitResult, GridColumn, GridUiState, RowModel, SpreadsheetGridProps } from '../model/gridTypes.unbound.js';
3
3
  import type { ServerSideCellEditInput } from '../logic/serverSideEdits.js';
4
4
  export type EditControllerArgs<T extends object> = {
5
5
  uiState: GridUiState;
@@ -16,6 +16,8 @@ export type EditControllerArgs<T extends object> = {
16
16
  editorActionGuardRef: {
17
17
  current: boolean;
18
18
  };
19
+ readOnly?: boolean;
20
+ canEditCell?: SpreadsheetGridProps<T>['canEditCell'];
19
21
  };
20
22
  export type EditController<T extends object> = {
21
23
  update: (args: EditControllerArgs<T>) => void;