@ishibashi0112/spreadsheet-grid-core 1.1.0 → 1.2.1
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/activeRowFollowController.cjs +1 -0
- package/dist/controllers/activeRowFollowController.d.ts +18 -0
- package/dist/controllers/activeRowFollowController.js +68 -0
- package/dist/controllers/autoHeightMeasurer.cjs +1 -1
- package/dist/controllers/autoHeightMeasurer.js +17 -17
- package/dist/controllers/clipboardController.cjs +1 -1
- package/dist/controllers/clipboardController.d.ts +2 -0
- package/dist/controllers/clipboardController.js +74 -64
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.js +10 -10
- package/dist/controllers/contextMenuController.cjs +1 -1
- package/dist/controllers/contextMenuController.d.ts +1 -0
- package/dist/controllers/contextMenuController.js +12 -7
- package/dist/controllers/detailRowController.cjs +1 -0
- package/dist/controllers/detailRowController.d.ts +41 -0
- package/dist/controllers/detailRowController.js +96 -0
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.d.ts +1 -0
- package/dist/controllers/editController.js +106 -99
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.js +78 -78
- package/dist/controllers/filterPopoverController.cjs +1 -1
- package/dist/controllers/filterPopoverController.js +6 -6
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +1 -0
- package/dist/controllers/findController.js +16 -15
- package/dist/controllers/imeInputController.cjs +1 -1
- package/dist/controllers/imeInputController.js +65 -54
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +1 -0
- package/dist/controllers/keyboardController.js +113 -111
- 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 +157 -156
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +1 -0
- package/dist/controllers/rowDragController.js +117 -104
- package/dist/controllers/scrollSyncController.cjs +1 -1
- package/dist/controllers/scrollSyncController.js +45 -43
- package/dist/controllers/serverSideRowModel.cjs +1 -1
- package/dist/controllers/serverSideRowModel.js +19 -19
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.d.ts +1 -0
- package/dist/controllers/viewportSyncController.js +1 -1
- 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.js +113 -113
- package/dist/engine/createGridEngine.cjs +3 -3
- package/dist/engine/createGridEngine.d.ts +2 -0
- package/dist/engine/createGridEngine.js +72 -70
- package/dist/engine/exportCommands.cjs +1 -1
- package/dist/engine/exportCommands.js +4 -2
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +6 -6
- package/dist/engine/gridApi.cjs +6 -6
- package/dist/engine/gridApi.d.ts +4 -0
- package/dist/engine/gridApi.js +208 -192
- package/dist/engine/notifiers.cjs +1 -1
- package/dist/engine/notifiers.d.ts +4 -0
- package/dist/engine/notifiers.js +7 -7
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +2 -0
- 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/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 +4 -0
- package/dist/logic/detailRow.js +10 -7
- package/dist/logic/domGuards.cjs +1 -1
- package/dist/logic/domGuards.d.ts +5 -0
- package/dist/logic/domGuards.js +8 -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/exportCsv.cjs +2 -2
- package/dist/logic/exportCsv.d.ts +2 -1
- package/dist/logic/exportCsv.js +13 -13
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +2 -1
- package/dist/logic/exportData.js +18 -18
- package/dist/logic/geometry.cjs +1 -1
- package/dist/logic/geometry.d.ts +2 -0
- package/dist/logic/geometry.js +41 -20
- 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 +3 -2
- package/dist/logic/gridState.js +32 -23
- package/dist/logic/grouping.cjs +1 -1
- package/dist/logic/grouping.js +1 -1
- package/dist/logic/imeInput.cjs +1 -1
- package/dist/logic/imeInput.js +6 -4
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +4 -0
- package/dist/logic/localeTextFeatures.js +8 -5
- package/dist/logic/pasteFill.cjs +1 -0
- package/dist/logic/pasteFill.d.ts +2 -0
- package/dist/logic/pasteFill.js +25 -0
- package/dist/logic/selectEditorState.cjs +1 -1
- package/dist/logic/selectEditorState.d.ts +28 -2
- package/dist/logic/selectEditorState.js +29 -14
- package/dist/logic/selectionAggregates.cjs +1 -1
- package/dist/logic/selectionAggregates.js +2 -3
- package/dist/logic/validation.cjs +1 -1
- package/dist/logic/validation.d.ts +1 -1
- package/dist/logic/validation.js +21 -21
- package/dist/model/gridActions.cjs +1 -1
- package/dist/model/gridActions.d.ts +13 -0
- package/dist/model/gridActions.js +11 -0
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.js +128 -65
- package/dist/model/gridTypes.core.d.ts +172 -26
- 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/gridVisibleBand.cjs +1 -0
- package/dist/utils/gridVisibleBand.d.ts +4 -0
- package/dist/utils/gridVisibleBand.js +24 -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/scrollBottom.cjs +1 -0
- package/dist/utils/scrollBottom.d.ts +1 -0
- package/dist/utils/scrollBottom.js +4 -0
- package/dist/utils/topAlignedInput.cjs +1 -0
- package/dist/utils/topAlignedInput.d.ts +3 -0
- package/dist/utils/topAlignedInput.js +23 -0
- package/package.json +1 -1
|
@@ -5,14 +5,14 @@ import { resolveElementScale as d } from "../logic/elementScale.js";
|
|
|
5
5
|
import { beginEscapeCancelableDrag as f } from "./escapeClaimController.js";
|
|
6
6
|
import { applySlotToElement as p } from "../logic/slotDom.js";
|
|
7
7
|
import { syncPortalTokens as m } from "../utils/portalTokens.js";
|
|
8
|
-
import { appendToPopupContainer as
|
|
8
|
+
import { appendToPopupContainer as ee, getPopupContainerFor as h } from "../utils/popupContainer.js";
|
|
9
9
|
//#region src/controllers/rowDragController.ts
|
|
10
|
-
var
|
|
10
|
+
var g = 14, _ = 12, v = "0.5", y = "<svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"8 6 12 2 16 6\"/><polyline points=\"16 18 12 22 8 18\"/><line x1=\"12\" y1=\"2\" x2=\"12\" y2=\"22\"/></svg>", te = "<svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"4.9\" y1=\"4.9\" x2=\"19.1\" y2=\"19.1\"/></svg>", ne = 200, b = "cubic-bezier(0.2, 0.7, 0.3, 1)", x = `transform 160ms ${b}`, S = "data-ssg-row-dragging", C = (e) => e?.closest(".ssg-motion-off") != null, w = /translateY\((-?[\d.]+)px\)/, T = (e) => {
|
|
11
11
|
let t = [];
|
|
12
12
|
return e.querySelectorAll(".ssg-body-row[data-row-index]").forEach((n) => {
|
|
13
13
|
r(e, n) || t.push(n);
|
|
14
14
|
}), t;
|
|
15
|
-
},
|
|
15
|
+
}, E = (e) => {
|
|
16
16
|
let t = [], n = /* @__PURE__ */ new Map();
|
|
17
17
|
return e.querySelectorAll(".ssg-detail-band[data-detail-row-index]").forEach((i) => {
|
|
18
18
|
if (r(e, i)) return;
|
|
@@ -23,22 +23,32 @@ var _ = 14, v = 12, y = "0.5", b = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
|
|
|
23
23
|
key: `band|${o}|${a}`
|
|
24
24
|
});
|
|
25
25
|
}), t;
|
|
26
|
-
},
|
|
26
|
+
}, D = (e) => {
|
|
27
27
|
e.style.transition = "", e.style.transform = "", e.style.willChange = "", e.style.zIndex = "";
|
|
28
|
-
},
|
|
29
|
-
let A = null, j = null, M =
|
|
28
|
+
}, O = () => {
|
|
29
|
+
let O = null, k = null, A = null, j = null, M = (e, t) => {
|
|
30
|
+
let n = O?.canDropAt;
|
|
31
|
+
if (!n) return !0;
|
|
32
|
+
if (j !== null && j.from === e && j.slot === t) return j.allowed;
|
|
33
|
+
let r = n(e, t);
|
|
34
|
+
return j = {
|
|
35
|
+
from: e,
|
|
36
|
+
slot: t,
|
|
37
|
+
allowed: r
|
|
38
|
+
}, r;
|
|
39
|
+
}, N = {
|
|
30
40
|
x: 0,
|
|
31
41
|
y: 0
|
|
32
|
-
}, P = null, F = !1, I = null, L = null, R = null, z = null, B = null, V = null, H = 0, U = null, W = () =>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
}, P = null, F = !1, I = null, L = null, R = null, z = null, B = null, V = null, H = 0, U = null, W = () => O?.motion === "live", G = null, K = null, q = null, J = () => [
|
|
43
|
+
O?.leftIndicatorRef.current ?? null,
|
|
44
|
+
O?.centerIndicatorRef.current ?? null,
|
|
45
|
+
O?.rightIndicatorRef.current ?? null
|
|
36
46
|
], Y = () => {
|
|
37
47
|
for (let e of J()) e && (e.style.display = "none");
|
|
38
|
-
},
|
|
48
|
+
}, re = (e) => {
|
|
39
49
|
if (G) return;
|
|
40
50
|
let t = document.createElement("div");
|
|
41
|
-
t.setAttribute("data-grid-drag-ghost", ""),
|
|
51
|
+
t.setAttribute("data-grid-drag-ghost", ""), O?.scrollContainerRef.current?.closest(".ssg-theme-dark") != null && t.classList.add("ssg-theme-dark"), O?.scrollContainerRef.current?.closest(".ssg-theme-class") != null && t.classList.add("ssg-theme-class"), O?.scrollContainerRef.current?.closest(".ssg-motion-off") != null && t.classList.add("ssg-motion-off"), t.style.cssText = [
|
|
42
52
|
"position:fixed",
|
|
43
53
|
"top:0",
|
|
44
54
|
"left:0",
|
|
@@ -63,53 +73,53 @@ var _ = 14, v = 12, y = "0.5", b = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
|
|
|
63
73
|
"z-index:9999",
|
|
64
74
|
"will-change:transform",
|
|
65
75
|
"transform:translate(-9999px,-9999px)"
|
|
66
|
-
].join(";"), p(t,
|
|
76
|
+
].join(";"), p(t, O?.ghostSlot);
|
|
67
77
|
let n = document.createElement("span");
|
|
68
78
|
n.style.cssText = "display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none";
|
|
69
79
|
let r = document.createElement("span");
|
|
70
|
-
r.style.cssText = "overflow:hidden;text-overflow:ellipsis", r.textContent = e, t.appendChild(n), t.appendChild(r),
|
|
71
|
-
},
|
|
80
|
+
r.style.cssText = "overflow:hidden;text-overflow:ellipsis", r.textContent = e, t.appendChild(n), t.appendChild(r), ee(t, h(O?.scrollContainerRef.current)), m(O?.scrollContainerRef.current, t), G = t, K = n, q = null;
|
|
81
|
+
}, ie = (e) => {
|
|
72
82
|
let t = G;
|
|
73
83
|
if (!t) return;
|
|
74
|
-
t.style.transform = "translate(" + (N.x +
|
|
84
|
+
t.style.transform = "translate(" + (N.x + g) + "px," + (N.y + _) + "px)";
|
|
75
85
|
let n = e ? "move" : "out";
|
|
76
86
|
if (q === n) return;
|
|
77
87
|
q = n;
|
|
78
88
|
let r = K;
|
|
79
|
-
n === "out" ? (t.style.opacity =
|
|
89
|
+
n === "out" ? (t.style.opacity = v, r && (r.innerHTML = te)) : (t.style.opacity = "1", r && (r.innerHTML = y));
|
|
80
90
|
}, X = () => {
|
|
81
91
|
G && G.parentNode && G.parentNode.removeChild(G), G = null, K = null, q = null;
|
|
82
92
|
}, Z = (e, t) => {
|
|
83
|
-
let n =
|
|
84
|
-
!n || t && e === null || n.querySelectorAll(t ? `.ssg-body-row[data-row-index="${e}"]` : `.ssg-body-row[${
|
|
85
|
-
r(n, e) || (t ? e.setAttribute(
|
|
93
|
+
let n = O?.scrollContainerRef.current ?? null;
|
|
94
|
+
!n || t && e === null || n.querySelectorAll(t ? `.ssg-body-row[data-row-index="${e}"]` : `.ssg-body-row[${S}]`).forEach((e) => {
|
|
95
|
+
r(n, e) || (t ? e.setAttribute(S, W() ? "live" : "") : e.removeAttribute(S));
|
|
86
96
|
});
|
|
87
|
-
},
|
|
88
|
-
let e =
|
|
97
|
+
}, ae = () => {
|
|
98
|
+
let e = O?.scrollContainerRef.current ?? null;
|
|
89
99
|
if (!e) return null;
|
|
90
100
|
let t = /* @__PURE__ */ new Map();
|
|
91
|
-
for (let n of
|
|
92
|
-
let e =
|
|
101
|
+
for (let n of T(e)) {
|
|
102
|
+
let e = w.exec(n.style.transform);
|
|
93
103
|
e && t.set(n, {
|
|
94
104
|
index: Number(n.getAttribute("data-row-index")),
|
|
95
105
|
baseY: parseFloat(e[1])
|
|
96
106
|
});
|
|
97
107
|
}
|
|
98
108
|
return t;
|
|
99
|
-
},
|
|
100
|
-
let n = V, r =
|
|
101
|
-
if (!n || r === null ||
|
|
102
|
-
let i =
|
|
109
|
+
}, oe = (t) => {
|
|
110
|
+
let n = V, r = k;
|
|
111
|
+
if (!n || r === null || O === null) return;
|
|
112
|
+
let i = O.scrollContainerRef.current;
|
|
103
113
|
if (!i) return;
|
|
104
|
-
for (let e of
|
|
114
|
+
for (let e of T(i)) {
|
|
105
115
|
if (n.has(e)) continue;
|
|
106
|
-
let t =
|
|
116
|
+
let t = w.exec(e.style.transform);
|
|
107
117
|
t && n.set(e, {
|
|
108
118
|
index: Number(e.getAttribute("data-row-index")),
|
|
109
119
|
baseY: parseFloat(t[1])
|
|
110
120
|
});
|
|
111
121
|
}
|
|
112
|
-
let a =
|
|
122
|
+
let a = O.rowMetrics.rowsHeight(r, r), o = (i.scrollTop - H) * O.verticalScaleFactor, s = (P ? N.y - P.y : 0) + o, c = t === null ? null : e(r, t);
|
|
113
123
|
n.forEach((e, t) => {
|
|
114
124
|
let { index: i, baseY: o } = e;
|
|
115
125
|
if (!t.isConnected) {
|
|
@@ -121,52 +131,53 @@ var _ = 14, v = 12, y = "0.5", b = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
|
|
|
121
131
|
return;
|
|
122
132
|
}
|
|
123
133
|
let l = 0;
|
|
124
|
-
c !== null && (r < i && i <= c ? l = -a : c <= i && i < r && (l = a)), t.style.transition =
|
|
134
|
+
c !== null && (r < i && i <= c ? l = -a : c <= i && i < r && (l = a)), t.style.transition = x, t.style.transform = `translateY(${o + l}px)`, e.applied = t.style.transform;
|
|
125
135
|
});
|
|
126
136
|
let l = U ?? /* @__PURE__ */ new Set();
|
|
127
137
|
U = l;
|
|
128
|
-
for (let { el: e, index: t } of
|
|
138
|
+
for (let { el: e, index: t } of E(i)) {
|
|
129
139
|
if (l.add(e), t === r) {
|
|
130
140
|
e.style.transition = "none", e.style.transform = `translateY(${s}px)`, e.style.willChange = "transform", e.style.zIndex = "10";
|
|
131
141
|
continue;
|
|
132
142
|
}
|
|
133
143
|
let n = 0;
|
|
134
|
-
c !== null && (r < t && t <= c ? n = -a : c <= t && t < r && (n = a)), e.style.transition =
|
|
144
|
+
c !== null && (r < t && t <= c ? n = -a : c <= t && t < r && (n = a)), e.style.transition = x, e.style.transform = `translateY(${n}px)`, e.style.zIndex = "";
|
|
135
145
|
}
|
|
136
|
-
},
|
|
137
|
-
if (
|
|
138
|
-
let { scrollContainerRef: o, bodyScrollRef: s, rowMetrics: c, headerHeight: l, verticalScaleFactor: u, windowBaseOffsetPx: d } =
|
|
146
|
+
}, se = (e, r) => {
|
|
147
|
+
if (O === null) return null;
|
|
148
|
+
let { scrollContainerRef: o, bodyScrollRef: s, rowMetrics: c, headerHeight: l, verticalScaleFactor: u, windowBaseOffsetPx: d } = O, f = o.current, p = s.current;
|
|
139
149
|
if (!f || !p) return null;
|
|
140
150
|
let m = f.getBoundingClientRect();
|
|
141
151
|
if (e < m.left || e > m.right || r < m.top || r > m.bottom) return null;
|
|
142
|
-
let
|
|
143
|
-
if (
|
|
144
|
-
let e = t(
|
|
145
|
-
e >
|
|
152
|
+
let ee = a(i(r, m.top + f.clientTop + f.clientHeight, O.footerHeight ?? 0), m.top + f.clientTop, O.stickyTopHeight ?? 0), h = p.getBoundingClientRect(), g = p.scrollTop + ee - h.top - l - f.scrollTop * (1 - u), _ = t(g, c), v = k, y = v !== null && W() ? c.detailHeight(v) : 0;
|
|
153
|
+
if (v !== null && y > 0) {
|
|
154
|
+
let e = t(g + y, c);
|
|
155
|
+
e > v + 1 && (_ = e);
|
|
146
156
|
}
|
|
147
|
-
let
|
|
157
|
+
let te = n(_, c);
|
|
148
158
|
return {
|
|
149
|
-
slot:
|
|
150
|
-
top: l +
|
|
159
|
+
slot: _,
|
|
160
|
+
top: l + te - d
|
|
151
161
|
};
|
|
152
162
|
}, Q = () => {
|
|
153
|
-
let t =
|
|
163
|
+
let t = se(N.x, N.y), n = k;
|
|
154
164
|
if (W()) {
|
|
155
|
-
t && n !== null && (
|
|
165
|
+
t && n !== null && (e(n, t.slot) === null ? A = null : M(n, t.slot) && (A = t.slot)), Y(), oe(A);
|
|
156
166
|
return;
|
|
157
167
|
}
|
|
158
|
-
|
|
159
|
-
|
|
168
|
+
let r = t !== null && n !== null && e(n, t.slot) !== null && !M(n, t.slot);
|
|
169
|
+
if (ie(r ? null : t), !t || n === null || r || e(n, t.slot) === null) {
|
|
170
|
+
A = null, Y();
|
|
160
171
|
return;
|
|
161
172
|
}
|
|
162
|
-
|
|
173
|
+
A = t.slot;
|
|
163
174
|
for (let e of J()) e && (e.style.top = `${t.top}px`, e.style.display = "block");
|
|
164
|
-
},
|
|
165
|
-
if (
|
|
175
|
+
}, ce = () => {
|
|
176
|
+
if (k === null) {
|
|
166
177
|
R = null;
|
|
167
178
|
return;
|
|
168
179
|
}
|
|
169
|
-
let e =
|
|
180
|
+
let e = O?.scrollContainerRef.current ?? null;
|
|
170
181
|
if (e && (F || (!P || s(P, N, 6)) && (F = !0), F)) {
|
|
171
182
|
let t = e.getBoundingClientRect(), n = d(e, t), r = l({
|
|
172
183
|
rectLeft: t.left,
|
|
@@ -176,100 +187,102 @@ var _ = 14, v = 12, y = "0.5", b = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
|
|
|
176
187
|
clientWidth: e.clientWidth,
|
|
177
188
|
clientHeight: e.clientHeight,
|
|
178
189
|
scale: n
|
|
179
|
-
}), i = c(N.y, u(r.top, (
|
|
190
|
+
}), i = c(N.y, u(r.top, (O?.stickyTopHeight ?? 0) * n.y, 24), r.bottom - (O?.footerHeight ?? 0), 24), a = o(e.scrollTop, i, 18, e.scrollHeight - e.clientHeight);
|
|
180
191
|
a !== e.scrollTop && e.scrollTo({
|
|
181
192
|
top: a,
|
|
182
193
|
behavior: "auto"
|
|
183
194
|
});
|
|
184
195
|
}
|
|
185
|
-
Q(), R = requestAnimationFrame(
|
|
186
|
-
},
|
|
187
|
-
let e =
|
|
196
|
+
Q(), R = requestAnimationFrame(ce);
|
|
197
|
+
}, le = (e, t) => `${e.getAttribute("data-pane") ?? ""}|${t}`, ue = () => {
|
|
198
|
+
let e = O?.scrollContainerRef.current ?? null;
|
|
188
199
|
if (!e) return null;
|
|
189
200
|
let t = /* @__PURE__ */ new Map();
|
|
190
|
-
for (let n of
|
|
191
|
-
for (let n of
|
|
201
|
+
for (let n of T(e)) t.set(le(n, Number(n.getAttribute("data-row-index"))), n.getBoundingClientRect().top);
|
|
202
|
+
for (let n of E(e)) t.set(n.key, n.el.getBoundingClientRect().top);
|
|
192
203
|
return t;
|
|
193
204
|
}, $ = (t) => {
|
|
194
205
|
R !== null && (cancelAnimationFrame(R), R = null), document.body.style.cursor = "", Y(), X();
|
|
195
|
-
let n =
|
|
196
|
-
Z(n, !1),
|
|
197
|
-
let a = n === null || r === null ? null : e(n, r), o =
|
|
206
|
+
let n = k, r = A, i = B;
|
|
207
|
+
Z(n, !1), k = null, B = null, A = null, P = null, L = null;
|
|
208
|
+
let a = n === null || r === null ? null : e(n, r), o = a !== null && n !== null && r !== null && t && !M(n, r) ? null : a;
|
|
209
|
+
j = null;
|
|
210
|
+
let s = t && n !== null && o !== null && O !== null, c = V;
|
|
198
211
|
V = null;
|
|
199
|
-
let
|
|
200
|
-
if (U = null,
|
|
201
|
-
e.isConnected && (e.style.transition =
|
|
212
|
+
let l = c && s && O !== null && !C(O.scrollContainerRef.current) ? ue() : null, u = U;
|
|
213
|
+
if (U = null, u && (s ? u.forEach(D) : (u.forEach((e) => {
|
|
214
|
+
e.isConnected && (e.style.transition = x, e.style.transform = "translateY(0px)", e.style.zIndex = "");
|
|
202
215
|
}), window.setTimeout(() => {
|
|
203
|
-
|
|
204
|
-
U?.has(e) ||
|
|
216
|
+
u.forEach((e) => {
|
|
217
|
+
U?.has(e) || D(e);
|
|
205
218
|
});
|
|
206
|
-
}, 200))),
|
|
219
|
+
}, 200))), c) if (s) c.forEach(({ baseY: e }, t) => {
|
|
207
220
|
t.style.transition = "", t.style.willChange = "", t.isConnected && (t.style.transform = `translateY(${e}px)`);
|
|
208
221
|
});
|
|
209
222
|
else {
|
|
210
223
|
let e = [];
|
|
211
|
-
|
|
212
|
-
n.isConnected && (n.style.transition =
|
|
224
|
+
c.forEach(({ baseY: t }, n) => {
|
|
225
|
+
n.isConnected && (n.style.transition = x, n.style.transform = `translateY(${t}px)`, e.push(n));
|
|
213
226
|
}), window.setTimeout(() => {
|
|
214
227
|
for (let t of e) t.style.transition = "", t.style.willChange = "";
|
|
215
228
|
}, 200);
|
|
216
229
|
}
|
|
217
|
-
if (!
|
|
218
|
-
let
|
|
219
|
-
tops:
|
|
230
|
+
if (!s || n === null || o === null || O === null) return;
|
|
231
|
+
let d = l ?? (C(O.scrollContainerRef.current) ? null : ue()), f = d ? {
|
|
232
|
+
tops: d,
|
|
220
233
|
from: n,
|
|
221
|
-
to:
|
|
234
|
+
to: o,
|
|
222
235
|
row: i
|
|
223
236
|
} : null;
|
|
224
|
-
z =
|
|
225
|
-
z ===
|
|
237
|
+
z = f, O.commitRowMove(n, o), f && requestAnimationFrame(() => {
|
|
238
|
+
z === f && (z = null);
|
|
226
239
|
});
|
|
227
|
-
},
|
|
240
|
+
}, de = () => {
|
|
228
241
|
let e = z;
|
|
229
242
|
if (z = null, !e) return;
|
|
230
|
-
let t =
|
|
243
|
+
let t = O?.scrollContainerRef.current ?? null;
|
|
231
244
|
if (!t) return;
|
|
232
245
|
let { tops: n, from: r, to: i } = e;
|
|
233
|
-
if (
|
|
246
|
+
if (O?.locateDragRow && e.row !== null && O.locateDragRow(e.row, i) !== i) return;
|
|
234
247
|
let a = (e) => e === i ? r : r < i && e >= r && e < i ? e + 1 : i < r && e > i && e <= r ? e - 1 : e, o = [], s = /* @__PURE__ */ new Map();
|
|
235
|
-
|
|
236
|
-
let t = n.get(
|
|
248
|
+
T(t).forEach((e) => {
|
|
249
|
+
let t = n.get(le(e, a(Number(e.getAttribute("data-row-index")))));
|
|
237
250
|
if (t === void 0) return;
|
|
238
251
|
let r = t - e.getBoundingClientRect().top;
|
|
239
252
|
if (Math.abs(r) < .5) return;
|
|
240
|
-
let i =
|
|
253
|
+
let i = w.exec(e.style.transform);
|
|
241
254
|
if (!i) return;
|
|
242
255
|
let c = parseFloat(i[1]);
|
|
243
256
|
s.set(e, c), e.style.transition = "none", e.style.transform = `translateY(${c + r}px)`, e.style.willChange = "transform", o.push(e);
|
|
244
257
|
});
|
|
245
258
|
let c = [];
|
|
246
|
-
if (
|
|
259
|
+
if (E(t).forEach(({ el: e, index: t, key: r }) => {
|
|
247
260
|
let i = a(t), o = n.get(r.slice(0, r.lastIndexOf("|") + 1) + i);
|
|
248
261
|
if (o === void 0) return;
|
|
249
262
|
let s = o - e.getBoundingClientRect().top;
|
|
250
263
|
Math.abs(s) < .5 || (e.style.transition = "none", e.style.transform = `translateY(${s}px)`, e.style.willChange = "transform", c.push(e));
|
|
251
264
|
}), !(o.length === 0 && c.length === 0)) {
|
|
252
265
|
t.getBoundingClientRect();
|
|
253
|
-
for (let e of o) e.style.transition = `transform ${
|
|
254
|
-
for (let e of c) e.style.transition = `transform ${
|
|
266
|
+
for (let e of o) e.style.transition = `transform ${ne}ms ${b}`, e.style.transform = `translateY(${s.get(e) ?? 0}px)`;
|
|
267
|
+
for (let e of c) e.style.transition = `transform ${ne}ms ${b}`, e.style.transform = "translateY(0px)";
|
|
255
268
|
window.setTimeout(() => {
|
|
256
269
|
for (let e of o) e.style.transition = "", e.style.willChange = "";
|
|
257
|
-
for (let e of c) U?.has(e) ||
|
|
270
|
+
for (let e of c) U?.has(e) || D(e);
|
|
258
271
|
}, 280);
|
|
259
272
|
}
|
|
260
|
-
},
|
|
261
|
-
if (
|
|
262
|
-
if (t.stopPropagation(), t.preventDefault(),
|
|
273
|
+
}, fe = (e, t) => {
|
|
274
|
+
if (O === null || !O.enabled || t.button !== 0) return;
|
|
275
|
+
if (t.stopPropagation(), t.preventDefault(), O.gridRootRef?.current?.focus({ preventScroll: !0 }), k !== null) {
|
|
263
276
|
if (t.pointerId !== L) return;
|
|
264
277
|
I?.(), $(!1);
|
|
265
278
|
}
|
|
266
|
-
|
|
279
|
+
k = e, B = O.getDragRow?.(e) ?? null, L = t.pointerId, A = null, N = {
|
|
267
280
|
x: t.clientX,
|
|
268
281
|
y: t.clientY
|
|
269
282
|
}, P = {
|
|
270
283
|
x: t.clientX,
|
|
271
284
|
y: t.clientY
|
|
272
|
-
}, F = !1, document.body.style.cursor = "grabbing", W() ? (V =
|
|
285
|
+
}, F = !1, document.body.style.cursor = "grabbing", W() ? (V = ae(), H = O.scrollContainerRef.current?.scrollTop ?? 0) : re(O.getRowDragLabel(e)), Z(e, !0);
|
|
273
286
|
let n = t.currentTarget, r = t.pointerId;
|
|
274
287
|
try {
|
|
275
288
|
n.setPointerCapture(r);
|
|
@@ -297,10 +310,10 @@ var _ = 14, v = 12, y = "0.5", b = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
|
|
|
297
310
|
function u() {
|
|
298
311
|
o(), $(!1);
|
|
299
312
|
}
|
|
300
|
-
window.addEventListener("pointermove", i), window.addEventListener("pointerup", s), window.addEventListener("pointercancel", c), window.addEventListener("keydown", l, !0), window.addEventListener("blur", u), I = o, Q(), R = requestAnimationFrame(
|
|
301
|
-
},
|
|
302
|
-
if (
|
|
303
|
-
let t =
|
|
313
|
+
window.addEventListener("pointermove", i), window.addEventListener("pointerup", s), window.addEventListener("pointercancel", c), window.addEventListener("keydown", l, !0), window.addEventListener("blur", u), I = o, Q(), R = requestAnimationFrame(ce);
|
|
314
|
+
}, pe = (e) => {
|
|
315
|
+
if (k === null || B == null || O?.locateDragRow === void 0) return;
|
|
316
|
+
let t = O.locateDragRow(B, k);
|
|
304
317
|
if (V && V.forEach((e, t) => {
|
|
305
318
|
if (!t.isConnected) {
|
|
306
319
|
V?.delete(t);
|
|
@@ -308,7 +321,7 @@ var _ = 14, v = 12, y = "0.5", b = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
|
|
|
308
321
|
}
|
|
309
322
|
let n = Number(t.getAttribute("data-row-index"));
|
|
310
323
|
if (n === e.index && (e.applied === void 0 || t.style.transform === e.applied)) return;
|
|
311
|
-
let r =
|
|
324
|
+
let r = w.exec(t.style.transform);
|
|
312
325
|
if (!r) {
|
|
313
326
|
V?.delete(t);
|
|
314
327
|
return;
|
|
@@ -318,22 +331,22 @@ var _ = 14, v = 12, y = "0.5", b = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
|
|
|
318
331
|
I?.(), $(!1);
|
|
319
332
|
return;
|
|
320
333
|
}
|
|
321
|
-
V && t !==
|
|
334
|
+
V && t !== k && P !== null && e !== null && (P = {
|
|
322
335
|
x: P.x,
|
|
323
|
-
y: P.y +
|
|
324
|
-
}), t !==
|
|
336
|
+
y: P.y + O.rowMetrics.rowTop(t) - e.rowTop(k)
|
|
337
|
+
}), t !== k && (Z(null, !1), k = t, Z(t, !0)), Q();
|
|
325
338
|
};
|
|
326
339
|
return {
|
|
327
340
|
update: (e) => {
|
|
328
|
-
let t =
|
|
329
|
-
|
|
341
|
+
let t = O;
|
|
342
|
+
O = e, t?.canDropAt !== e.canDropAt && (j = null), k !== null && t !== null && t.locateDragRow !== e.locateDragRow && pe(t.rowMetrics);
|
|
330
343
|
},
|
|
331
|
-
onRowDragHandlePointerDown:
|
|
332
|
-
applyReorderSettle:
|
|
344
|
+
onRowDragHandlePointerDown: fe,
|
|
345
|
+
applyReorderSettle: de,
|
|
333
346
|
dispose: () => {
|
|
334
|
-
I?.(), I = null, R !== null && (cancelAnimationFrame(R), R = null), document.body.style.cursor = "", X(), Z(
|
|
347
|
+
I?.(), I = null, R !== null && (cancelAnimationFrame(R), R = null), document.body.style.cursor = "", X(), Z(k, !1), k = null, B = null, A = null, j = null, V = null, U?.forEach(D), U = null, z = null;
|
|
335
348
|
}
|
|
336
349
|
};
|
|
337
350
|
};
|
|
338
351
|
//#endregion
|
|
339
|
-
export {
|
|
352
|
+
export { O as createRowDragController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/scrollBottom.cjs");var t=`ssg-scroll-container--scrolling`,n=120,r=()=>{let n=null,r=null,i=!1,a=null,o=null,s=null,c=null,l=()=>{o=null;let e=a;a=null,e&&n?.onScroll?.(e)},u=e=>Math.max(e.clientHeight-(n?.footerHeight??0),0),d=d=>{c=d,n?.setViewState({scrollTop:d.scrollTop,viewportHeight:u(d),viewportWidth:d.clientWidth});let f=()=>{n?.setViewState({scrollTop:d.scrollTop}),d.classList.add(t),s!==null&&clearTimeout(s),s=setTimeout(()=>{s=null,d.classList.remove(t)},120);let r=i?`api`:`user`;i=!1;let c=a;a={top:d.scrollTop,left:d.scrollLeft,source:c?.source===`user`?`user`:r,atBottom:e.isScrolledToBottom(d)},n?.onScroll&&o===null&&(o=requestAnimationFrame(l))};d.addEventListener(`scroll`,f,{passive:!0});let p=null,m=new ResizeObserver(()=>{p??=requestAnimationFrame(()=>{p=null,d.clientWidth!==0&&n?.setViewState({viewportHeight:u(d),viewportWidth:d.clientWidth})})});m.observe(d),r=()=>{d.removeEventListener(`scroll`,f),o!==null&&(cancelAnimationFrame(o),o=null),s!==null&&(clearTimeout(s),s=null),d.classList.remove(t),m.disconnect(),p!==null&&cancelAnimationFrame(p),c=null}};return{update:e=>{let t=n?.footerHeight??0;if(n=e,r===null){let t=e.scrollContainerRef.current;t&&d(t);return}let i=e.footerHeight??0;if(i!==t&&c?.clientWidth){let n=c,r=i-t;if(r>0){let e=n.scrollHeight-r-n.clientHeight;e>0&&n.scrollTop>=e-1&&(n.scrollTop=n.scrollHeight-n.clientHeight)}e.setViewState({viewportHeight:u(n)})}},markApiScroll:()=>{let e=i;return i=!0,()=>{i=e}},dispose:()=>{r?.(),r=null}}};exports.SCROLLING_CLASS_NAME=t,exports.SCROLLING_IDLE_MS=n,exports.createScrollSyncController=r;
|
|
@@ -1,69 +1,71 @@
|
|
|
1
|
+
import { isScrolledToBottom as e } from "../utils/scrollBottom.js";
|
|
1
2
|
//#region src/controllers/scrollSyncController.ts
|
|
2
|
-
var
|
|
3
|
-
let
|
|
4
|
-
|
|
5
|
-
let e =
|
|
6
|
-
|
|
7
|
-
},
|
|
8
|
-
|
|
9
|
-
scrollTop:
|
|
10
|
-
viewportHeight:
|
|
11
|
-
viewportWidth:
|
|
3
|
+
var t = "ssg-scroll-container--scrolling", n = 120, r = () => {
|
|
4
|
+
let n = null, r = null, i = !1, a = null, o = null, s = null, c = null, l = () => {
|
|
5
|
+
o = null;
|
|
6
|
+
let e = a;
|
|
7
|
+
a = null, e && n?.onScroll?.(e);
|
|
8
|
+
}, u = (e) => Math.max(e.clientHeight - (n?.footerHeight ?? 0), 0), d = (d) => {
|
|
9
|
+
c = d, n?.setViewState({
|
|
10
|
+
scrollTop: d.scrollTop,
|
|
11
|
+
viewportHeight: u(d),
|
|
12
|
+
viewportWidth: d.clientWidth
|
|
12
13
|
});
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
let f = () => {
|
|
15
|
+
n?.setViewState({ scrollTop: d.scrollTop }), d.classList.add(t), s !== null && clearTimeout(s), s = setTimeout(() => {
|
|
16
|
+
s = null, d.classList.remove(t);
|
|
16
17
|
}, 120);
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
top:
|
|
22
|
-
left:
|
|
23
|
-
source:
|
|
24
|
-
|
|
18
|
+
let r = i ? "api" : "user";
|
|
19
|
+
i = !1;
|
|
20
|
+
let c = a;
|
|
21
|
+
a = {
|
|
22
|
+
top: d.scrollTop,
|
|
23
|
+
left: d.scrollLeft,
|
|
24
|
+
source: c?.source === "user" ? "user" : r,
|
|
25
|
+
atBottom: e(d)
|
|
26
|
+
}, n?.onScroll && o === null && (o = requestAnimationFrame(l));
|
|
25
27
|
};
|
|
26
|
-
|
|
27
|
-
let
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
viewportHeight:
|
|
31
|
-
viewportWidth:
|
|
28
|
+
d.addEventListener("scroll", f, { passive: !0 });
|
|
29
|
+
let p = null, m = new ResizeObserver(() => {
|
|
30
|
+
p ??= requestAnimationFrame(() => {
|
|
31
|
+
p = null, d.clientWidth !== 0 && n?.setViewState({
|
|
32
|
+
viewportHeight: u(d),
|
|
33
|
+
viewportWidth: d.clientWidth
|
|
32
34
|
});
|
|
33
35
|
});
|
|
34
36
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
m.observe(d), r = () => {
|
|
38
|
+
d.removeEventListener("scroll", f), o !== null && (cancelAnimationFrame(o), o = null), s !== null && (clearTimeout(s), s = null), d.classList.remove(t), m.disconnect(), p !== null && cancelAnimationFrame(p), c = null;
|
|
37
39
|
};
|
|
38
40
|
};
|
|
39
41
|
return {
|
|
40
42
|
update: (e) => {
|
|
41
|
-
let
|
|
42
|
-
if (
|
|
43
|
+
let t = n?.footerHeight ?? 0;
|
|
44
|
+
if (n = e, r === null) {
|
|
43
45
|
let t = e.scrollContainerRef.current;
|
|
44
|
-
t &&
|
|
46
|
+
t && d(t);
|
|
45
47
|
return;
|
|
46
48
|
}
|
|
47
49
|
let i = e.footerHeight ?? 0;
|
|
48
|
-
if (i !==
|
|
49
|
-
let
|
|
50
|
-
if (
|
|
51
|
-
let e =
|
|
52
|
-
e > 0 &&
|
|
50
|
+
if (i !== t && c?.clientWidth) {
|
|
51
|
+
let n = c, r = i - t;
|
|
52
|
+
if (r > 0) {
|
|
53
|
+
let e = n.scrollHeight - r - n.clientHeight;
|
|
54
|
+
e > 0 && n.scrollTop >= e - 1 && (n.scrollTop = n.scrollHeight - n.clientHeight);
|
|
53
55
|
}
|
|
54
|
-
e.setViewState({ viewportHeight:
|
|
56
|
+
e.setViewState({ viewportHeight: u(n) });
|
|
55
57
|
}
|
|
56
58
|
},
|
|
57
59
|
markApiScroll: () => {
|
|
58
|
-
let e =
|
|
59
|
-
return
|
|
60
|
-
|
|
60
|
+
let e = i;
|
|
61
|
+
return i = !0, () => {
|
|
62
|
+
i = e;
|
|
61
63
|
};
|
|
62
64
|
},
|
|
63
65
|
dispose: () => {
|
|
64
|
-
|
|
66
|
+
r?.(), r = null;
|
|
65
67
|
}
|
|
66
68
|
};
|
|
67
69
|
};
|
|
68
70
|
//#endregion
|
|
69
|
-
export {
|
|
71
|
+
export { t as SCROLLING_CLASS_NAME, n as SCROLLING_IDLE_MS, r as createScrollSyncController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("../logic/valueStore.cjs"),n=require("../logic/serverSideCache.cjs"),r=require("../logic/serverSideBlocks.cjs"),i=require("../logic/serverSideEdits.cjs");var a=100,o=64,s=120,c=3e3,l=l=>{let u=l,d=l.dataSource?.blockSize??a,f=n.createServerSideRowCache({blockSize:d,maxBlocks:l.dataSource?.maxCachedBlocks??o}),p=i.createServerSidePendingEdits(),m=l.dataSource?.initialRowCount??0,h=null,g=null,_=l.rowKeyGetter,v=new Map,y=new Set,b=new Set,x=null,S={start:0,end:0},C=0,w=0,T=new Set,E=1,D=null,O=null,k=null,A=!1,j,M=l.refreshToken,N=e=>p.getRow(e)??f.getRow(e),P=()=>({getRowCount:()=>m,getRow:e=>N(e),getSourceIndex:e=>e,getRowKey:e=>{let t=N(e);return t===void 0?e:_(t,e)}}),F=P(),I=t.createValueStore({rowModel:F,rowCount:m,loadError:h,writeError:g}),L=()=>{let e=I.getSnapshot();e.rowModel===F&&e.rowCount===m&&e.loadError===h&&e.writeError===g||I.setSnapshot({rowModel:F,rowCount:m,loadError:h,writeError:g})},R=()=>{F=P(),L()},z=()=>{C+=1,p=i.createServerSidePendingEdits(),g=null},B=()=>{k!==null&&(clearTimeout(k),k=null),D=null,O=null},V=()=>{let e=O;B(),e?.()},H=e=>{if(D===null&&T.size===0){e();return}if(D===null)D=new Set(T),k=setTimeout(()=>{k=null,V()},c);else for(let e of T)D.add(e);O=e},U=e=>{T.delete(e),D!==null&&D.delete(e)&&D.size===0&&V()},W=()=>{let e=y.size;h=e===0?null:{failedBlockCount:e},L()},G=()=>{for(let[,e]of v)e.abort();v.clear()},K=()=>{x!==null&&(clearTimeout(x),x=null)},q=e=>{let{dataSource:t,query:n}=u;if(t==null||D!==null||f.hasBlock(e)&&!b.has(e)||v.has(e))return;let r=new AbortController;v.set(e,r);let i=e*d,a=i+d;new Promise(e=>{e(t.getRows({startIndex:i,endIndex:a,query:n,signal:r.signal}))}).then(t=>{if(!r.signal.aborted&&v.get(e)===r){if(v.delete(e),f.setBlock(e,t.rows),b.delete(e),y.delete(e)&&(h=y.size===0?null:{failedBlockCount:y.size}),t.totalRowCount!==m){let n=Math.floor(m/d);t.totalRowCount>m&&m%d!==0&&n!==e&&f.hasBlock(n)&&b.add(n),m=t.totalRowCount}R()}}).catch(t=>{r.signal.aborted||v.get(e)===r&&(v.delete(e),y.add(e),W(),u.onLoadError?.(t,{startIndex:i,endIndex:a}))})},J=()=>{G();for(let e of f.loadedBlockIndexes())b.add(e);Y()},Y=()=>{let{start:e,end:t}=S,n=r.computeBlockIndexes(e,t,d,m),i=new Set(n);for(let[e,t]of v)i.has(e)||(t.abort(),v.delete(e));for(let e of n)y.has(e)||q(e)},X=()=>{K(),x=setTimeout(()=>{x=null,Y()},u.debounceMs??s)},ee=(e,t)=>{u.dataSource!=null&&(S={start:e,end:t},f.touchBlocks(r.computeBlockIndexes(e,t,d,m)),X())},Z=()=>{G(),K(),f.clear(),y.clear(),b.clear(),h=null,z()},Q=()=>{u.dataSource!=null&&(Z(),R(),H(()=>{let{start:e,end:t}=S;if(r.computeBlockIndexes(e,t,d,m).length===0){q(0);return}Y()}))},te=()=>{if(u.dataSource==null||y.size===0)return;let e=Array.from(y);y.clear(),W();for(let t of e)q(t)},ne=t=>{let n=u.dataSource?.updateRows;if(n===void 0||t.length===0)return 0;let r=i.buildServerSideRowUpdates(t,N,u.rowKeyGetter);if(r.length===0)return 0;let a=C,o=w,s=p,c=E;E+=1,T.add(c);let l=new Map;for(let e of t){let t=l.get(e.viewIndex),n={column:e.column,value:e.value};t?t.push(n):l.set(e.viewIndex,[n])}let d=r.map(e=>({viewIndex:e.rowIndex,rowKey:e.rowKey,writeId:s.beginWrite(e.rowIndex,e.row,l.get(e.rowIndex)??[])}));R();let m=r.map(e=>({rowKey:e.rowKey,columnKeys:e.changes.map(e=>e.columnKey)})),h=(e,t=m)=>{u.onWriteStateChange?.({state:e,cells:t})};return h(`pending`),new Promise(e=>{e(n({updates:r}))}).then(e=>{if(w!==o){h(`cleared`);return}let t=C!==a,n=e===void 0?void 0:e.rows,r=d.map((e,r)=>{let i=s.settleWrite(e.viewIndex,e.writeId,{ok:!0,serverRow:n?.[r]},t?void 0:f.getRow(e.viewIndex));return!t&&i.confirmedRow!==void 0&&f.updateRow(e.viewIndex,i.confirmedRow),{rowKey:e.rowKey,columnKeys:i.settledColumnKeys}});t?(D===null||!D.has(c))&&J():R(),h(`ok`,r)}).catch(t=>{if(w!==o){h(`cleared`);return}let n=C!==a,i=d.map(e=>({rowKey:e.rowKey,columnKeys:s.settleWrite(e.viewIndex,e.writeId,{ok:!1},n?void 0:f.getRow(e.viewIndex)).settledColumnKeys})),c=r.flatMap((t,r)=>{let a=i[r]?.columnKeys??[];if(a.length===0)return[];let o=t.changes.filter(e=>a.includes(e.columnKey)),s=n?void 0:N(t.rowIndex);if(s===void 0||u.rowKeyGetter(s,t.rowIndex)!==t.rowKey)return[{...t,changes:o}];let c=s;for(let n of l.get(t.rowIndex)??[])a.includes(n.column.key)&&(c=e.setCellValue(c,n.column,n.value));return[{...t,row:c,changes:o}]});c.length>0&&(g={failedRowCount:c.length},u.onWriteError?.(t,{updates:c})),n?L():R(),h(`failed`,i)}).finally(()=>{U(c)}),r.length},re=()=>{if(j!==void 0&&j===u.queryKey)return;j=u.queryKey;let{dataSource:e}=u;if(e==null)return;Z();let t=!A;if(A=!0,R(),t)(e.initialRowCount??0)<=0&&q(0);else{let e=D!==null||T.size>0;H(()=>{e&&S.end>S.start&&Y(),q(0)})}},ie=()=>{let e=u.refreshToken;if(u.dataSource==null||e===void 0){M=e;return}if(M===void 0){M=e;return}M!==e&&(M=e,Q())},$=!1,ae=()=>{u.dataSource!=null&&(m===0&&!f.hasBlock(0)&&q(0),S.end>S.start&&Y())};return{update:e=>{u=e,e.rowKeyGetter!==_&&(_=e.rowKeyGetter,R()),re(),ie(),$&&($=!1,ae())},subscribe:I.subscribe,getSnapshot:I.getSnapshot,isRowLoaded:e=>N(e)!==void 0,requestRange:ee,refresh:Q,retryFailedBlocks:te,applyCellEdits:ne,dispose:()=>{G(),K(),C+=1,w+=1,p.clear(),B(),T.clear(),$=!0}}};exports.SERVER_SIDE_WRITE_WAIT_MS=c,exports.createServerSideRowModel=l;
|