@ishibashi0112/spreadsheet-grid-core 0.46.0 → 0.47.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 (62) hide show
  1. package/dist/controllers/changeHighlightController.cjs +1 -0
  2. package/dist/controllers/changeHighlightController.d.ts +31 -0
  3. package/dist/controllers/changeHighlightController.js +97 -0
  4. package/dist/controllers/clipboardController.cjs +1 -1
  5. package/dist/controllers/clipboardController.d.ts +1 -0
  6. package/dist/controllers/clipboardController.js +1 -1
  7. package/dist/controllers/columnHeaderDragController.cjs +1 -1
  8. package/dist/controllers/columnHeaderDragController.d.ts +1 -0
  9. package/dist/controllers/columnHeaderDragController.js +132 -74
  10. package/dist/controllers/findController.cjs +1 -0
  11. package/dist/controllers/findController.d.ts +38 -0
  12. package/dist/controllers/findController.js +137 -0
  13. package/dist/controllers/keyboardController.cjs +1 -1
  14. package/dist/controllers/keyboardController.d.ts +1 -0
  15. package/dist/controllers/keyboardController.js +14 -10
  16. package/dist/controllers/pointerInteractionsController.cjs +1 -1
  17. package/dist/controllers/pointerInteractionsController.d.ts +1 -0
  18. package/dist/controllers/pointerInteractionsController.js +1 -1
  19. package/dist/controllers/reducedMotionStore.cjs +1 -0
  20. package/dist/controllers/reducedMotionStore.d.ts +5 -0
  21. package/dist/controllers/reducedMotionStore.js +18 -0
  22. package/dist/controllers/rowDragController.cjs +1 -1
  23. package/dist/controllers/rowDragController.d.ts +1 -0
  24. package/dist/controllers/rowDragController.js +121 -70
  25. package/dist/controllers/rowEnterController.cjs +1 -0
  26. package/dist/controllers/rowEnterController.d.ts +19 -0
  27. package/dist/controllers/rowEnterController.js +88 -0
  28. package/dist/controllers/saveStatusController.cjs +1 -0
  29. package/dist/controllers/saveStatusController.d.ts +30 -0
  30. package/dist/controllers/saveStatusController.js +74 -0
  31. package/dist/controllers/scrollSyncController.cjs +1 -1
  32. package/dist/controllers/scrollSyncController.d.ts +2 -0
  33. package/dist/controllers/scrollSyncController.js +36 -34
  34. package/dist/controllers/serverSideRowModel.cjs +1 -1
  35. package/dist/controllers/serverSideRowModel.d.ts +8 -0
  36. package/dist/controllers/serverSideRowModel.js +21 -6
  37. package/dist/controllers/tooltipController.cjs +1 -1
  38. package/dist/controllers/tooltipController.js +1 -1
  39. package/dist/engine/createGridEngine.cjs +1 -1
  40. package/dist/engine/createGridEngine.d.ts +10 -0
  41. package/dist/engine/createGridEngine.js +56 -46
  42. package/dist/engine/gridApi.cjs +1 -1
  43. package/dist/engine/gridApi.d.ts +6 -0
  44. package/dist/engine/gridApi.js +12 -0
  45. package/dist/logic/conditionalFormat.cjs +1 -0
  46. package/dist/logic/conditionalFormat.d.ts +19 -0
  47. package/dist/logic/conditionalFormat.js +88 -0
  48. package/dist/logic/find.cjs +1 -0
  49. package/dist/logic/find.d.ts +27 -0
  50. package/dist/logic/find.js +56 -0
  51. package/dist/logic/motion.cjs +1 -0
  52. package/dist/logic/motion.d.ts +4 -0
  53. package/dist/logic/motion.js +4 -0
  54. package/dist/logic/selectionOverlayGeometry.cjs +1 -0
  55. package/dist/logic/selectionOverlayGeometry.d.ts +15 -0
  56. package/dist/logic/selectionOverlayGeometry.js +43 -0
  57. package/dist/model/gridStore.cjs +1 -1
  58. package/dist/model/gridStore.d.ts +13 -1
  59. package/dist/model/gridStore.js +11 -5
  60. package/dist/model/gridTypes.core.d.ts +198 -0
  61. package/dist/model/gridTypes.unbound.d.ts +1 -0
  62. package/package.json +1 -1
@@ -3,25 +3,25 @@ import { isInsideDetailCardOf as r } from "../logic/detailRow.js";
3
3
  import { computeNextScrollPosition as i, hasPointerLeftActivationRadius as a, resolveAutoScrollAxisDirection as o, resolveScrollContentBox as s } from "../logic/autoScrollGeometry.js";
4
4
  import { applySlotToElement as c } from "../logic/slotDom.js";
5
5
  //#region src/controllers/rowDragController.ts
6
- var l = 14, u = 12, d = "0.5", f = "<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>", p = "<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>", m = 200, h = "cubic-bezier(0.2, 0.7, 0.3, 1)", g = "data-ssg-row-dragging", _ = () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, v = /translateY\((-?[\d.]+)px\)/, y = (e) => {
6
+ var l = 14, u = 12, d = "0.5", f = "<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>", p = "<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>", m = 200, h = "cubic-bezier(0.2, 0.7, 0.3, 1)", g = `transform 160ms ${h}`, _ = "data-ssg-row-dragging", v = (e) => e?.closest(".ssg-motion-off") != null, y = /translateY\((-?[\d.]+)px\)/, b = (e) => {
7
7
  let t = [];
8
8
  return e.querySelectorAll(".ssg-body-row[data-row-index]").forEach((n) => {
9
9
  r(e, n) || t.push(n);
10
10
  }), t;
11
- }, b = () => {
12
- let b = null, x = null, S = null, C = {
11
+ }, x = () => {
12
+ let x = null, S = null, C = null, w = {
13
13
  x: 0,
14
14
  y: 0
15
- }, w = null, T = !1, E = null, D = null, O = null, k = null, A = null, j = null, M = () => [
16
- b?.leftIndicatorRef.current ?? null,
17
- b?.centerIndicatorRef.current ?? null,
18
- b?.rightIndicatorRef.current ?? null
19
- ], N = () => {
20
- for (let e of M()) e && (e.style.display = "none");
21
- }, P = (e) => {
22
- if (k) return;
15
+ }, T = null, E = !1, D = null, O = null, k = null, A = null, j = 0, M = () => x?.motion === "live", N = null, P = null, F = null, I = () => [
16
+ x?.leftIndicatorRef.current ?? null,
17
+ x?.centerIndicatorRef.current ?? null,
18
+ x?.rightIndicatorRef.current ?? null
19
+ ], L = () => {
20
+ for (let e of I()) e && (e.style.display = "none");
21
+ }, R = (e) => {
22
+ if (N) return;
23
23
  let t = document.createElement("div");
24
- t.setAttribute("data-grid-drag-ghost", ""), b?.scrollContainerRef.current?.closest(".ssg-theme-dark") != null && t.classList.add("ssg-theme-dark"), t.style.cssText = [
24
+ t.setAttribute("data-grid-drag-ghost", ""), x?.scrollContainerRef.current?.closest(".ssg-theme-dark") != null && t.classList.add("ssg-theme-dark"), x?.scrollContainerRef.current?.closest(".ssg-motion-off") != null && t.classList.add("ssg-motion-off"), t.style.cssText = [
25
25
  "position:fixed",
26
26
  "top:0",
27
27
  "left:0",
@@ -46,30 +46,68 @@ var l = 14, u = 12, d = "0.5", f = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
46
46
  "z-index:9999",
47
47
  "will-change:transform",
48
48
  "transform:translate(-9999px,-9999px)"
49
- ].join(";"), c(t, b?.ghostSlot);
49
+ ].join(";"), c(t, x?.ghostSlot);
50
50
  let n = document.createElement("span");
51
51
  n.style.cssText = "display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none";
52
52
  let r = document.createElement("span");
53
- r.style.cssText = "overflow:hidden;text-overflow:ellipsis", r.textContent = e, t.appendChild(n), t.appendChild(r), document.body.appendChild(t), k = t, A = n, j = null;
54
- }, F = (e) => {
55
- let t = k;
53
+ r.style.cssText = "overflow:hidden;text-overflow:ellipsis", r.textContent = e, t.appendChild(n), t.appendChild(r), document.body.appendChild(t), N = t, P = n, F = null;
54
+ }, z = (e) => {
55
+ let t = N;
56
56
  if (!t) return;
57
- t.style.transform = "translate(" + (C.x + l) + "px," + (C.y + u) + "px)";
57
+ t.style.transform = "translate(" + (w.x + l) + "px," + (w.y + u) + "px)";
58
58
  let n = e ? "move" : "out";
59
- if (j === n) return;
60
- j = n;
61
- let r = A;
59
+ if (F === n) return;
60
+ F = n;
61
+ let r = P;
62
62
  n === "out" ? (t.style.opacity = d, r && (r.innerHTML = p)) : (t.style.opacity = "1", r && (r.innerHTML = f));
63
- }, I = () => {
64
- k && k.parentNode && k.parentNode.removeChild(k), k = null, A = null, j = null;
65
- }, L = (e, t) => {
66
- let n = b?.scrollContainerRef.current ?? null;
63
+ }, B = () => {
64
+ N && N.parentNode && N.parentNode.removeChild(N), N = null, P = null, F = null;
65
+ }, V = (e, t) => {
66
+ let n = x?.scrollContainerRef.current ?? null;
67
67
  !n || e === null || n.querySelectorAll(`.ssg-body-row[data-row-index="${e}"]`).forEach((e) => {
68
- r(n, e) || (t ? e.setAttribute(g, "") : e.removeAttribute(g));
68
+ r(n, e) || (t ? e.setAttribute(_, M() ? "live" : "") : e.removeAttribute(_));
69
+ });
70
+ }, H = () => {
71
+ let e = x?.scrollContainerRef.current ?? null;
72
+ if (!e) return null;
73
+ let t = /* @__PURE__ */ new Map();
74
+ for (let n of b(e)) {
75
+ let e = y.exec(n.style.transform);
76
+ e && t.set(n, {
77
+ index: Number(n.getAttribute("data-row-index")),
78
+ baseY: parseFloat(e[1])
79
+ });
80
+ }
81
+ return t;
82
+ }, U = (t) => {
83
+ let n = A, r = S;
84
+ if (!n || r === null || x === null) return;
85
+ let i = x.scrollContainerRef.current;
86
+ if (!i) return;
87
+ for (let e of b(i)) {
88
+ if (n.has(e)) continue;
89
+ let t = y.exec(e.style.transform);
90
+ t && n.set(e, {
91
+ index: Number(e.getAttribute("data-row-index")),
92
+ baseY: parseFloat(t[1])
93
+ });
94
+ }
95
+ let a = x.rowMetrics.rowsHeight(r, r), o = (i.scrollTop - j) * x.verticalScaleFactor, s = (T ? w.y - T.y : 0) + o, c = t === null ? null : e(r, t);
96
+ n.forEach(({ index: e, baseY: t }, i) => {
97
+ if (!i.isConnected) {
98
+ n.delete(i);
99
+ return;
100
+ }
101
+ if (e === r) {
102
+ i.style.transition = "none", i.style.transform = `translateY(${t + s}px)`, i.style.willChange = "transform";
103
+ return;
104
+ }
105
+ let o = 0;
106
+ c !== null && (r < e && e <= c ? o = -a : c <= e && e < r && (o = a)), i.style.transition = g, i.style.transform = `translateY(${t + o}px)`;
69
107
  });
70
- }, R = (e, r) => {
71
- if (b === null) return null;
72
- let { scrollContainerRef: i, bodyScrollRef: a, rowMetrics: o, headerHeight: s, verticalScaleFactor: c, windowBaseOffsetPx: l } = b, u = i.current, d = a.current;
108
+ }, W = (e, r) => {
109
+ if (x === null) return null;
110
+ let { scrollContainerRef: i, bodyScrollRef: a, rowMetrics: o, headerHeight: s, verticalScaleFactor: c, windowBaseOffsetPx: l } = x, u = i.current, d = a.current;
73
111
  if (!u || !d) return null;
74
112
  let f = u.getBoundingClientRect();
75
113
  if (e < f.left || e > f.right || r < f.top || r > f.bottom) return null;
@@ -78,23 +116,25 @@ var l = 14, u = 12, d = "0.5", f = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
78
116
  slot: m,
79
117
  top: s + n(m, o) - l
80
118
  };
81
- }, z = () => {
82
- let t = R(C.x, C.y);
83
- F(t);
84
- let n = x;
85
- if (!t || n === null || e(n, t.slot) === null) {
86
- S = null, N();
119
+ }, G = () => {
120
+ let t = W(w.x, w.y), n = S;
121
+ if (M()) {
122
+ t && n !== null && (C = e(n, t.slot) === null ? null : t.slot), L(), U(C);
87
123
  return;
88
124
  }
89
- S = t.slot;
90
- for (let e of M()) e && (e.style.top = `${t.top}px`, e.style.display = "block");
91
- }, B = () => {
92
- if (x === null) {
93
- D = null;
125
+ if (z(t), !t || n === null || e(n, t.slot) === null) {
126
+ C = null, L();
94
127
  return;
95
128
  }
96
- let e = b?.scrollContainerRef.current ?? null;
97
- if (e && (T || (!w || a(w, C, 6)) && (T = !0), T)) {
129
+ C = t.slot;
130
+ for (let e of I()) e && (e.style.top = `${t.top}px`, e.style.display = "block");
131
+ }, K = () => {
132
+ if (S === null) {
133
+ O = null;
134
+ return;
135
+ }
136
+ let e = x?.scrollContainerRef.current ?? null;
137
+ if (e && (E || (!T || a(T, w, 6)) && (E = !0), E)) {
98
138
  let t = e.getBoundingClientRect(), n = s({
99
139
  rectLeft: t.left,
100
140
  rectTop: t.top,
@@ -102,76 +142,87 @@ var l = 14, u = 12, d = "0.5", f = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
102
142
  clientTop: e.clientTop,
103
143
  clientWidth: e.clientWidth,
104
144
  clientHeight: e.clientHeight
105
- }), r = o(C.y, n.top, n.bottom, 24), a = i(e.scrollTop, r, 18, e.scrollHeight - e.clientHeight);
145
+ }), r = o(w.y, n.top, n.bottom, 24), a = i(e.scrollTop, r, 18, e.scrollHeight - e.clientHeight);
106
146
  a !== e.scrollTop && e.scrollTo({
107
147
  top: a,
108
148
  behavior: "auto"
109
149
  });
110
150
  }
111
- z(), D = requestAnimationFrame(B);
112
- }, V = () => {
113
- let e = b?.scrollContainerRef.current ?? null;
151
+ G(), O = requestAnimationFrame(K);
152
+ }, q = () => {
153
+ let e = x?.scrollContainerRef.current ?? null;
114
154
  if (!e) return null;
115
155
  let t = /* @__PURE__ */ new Map();
116
- for (let n of y(e)) t.set(n, n.getBoundingClientRect().top);
156
+ for (let n of b(e)) t.set(n, n.getBoundingClientRect().top);
117
157
  return t;
118
- }, H = (t) => {
119
- D !== null && (cancelAnimationFrame(D), D = null), document.body.style.cursor = "", N(), I();
120
- let n = x, r = S;
121
- if (L(n, !1), x = null, S = null, w = null, !t || n === null || r === null || b === null) return;
122
- let i = e(n, r);
123
- i !== null && (O = _() ? null : V(), b.commitRowMove(n, i));
158
+ }, J = (t) => {
159
+ O !== null && (cancelAnimationFrame(O), O = null), document.body.style.cursor = "", L(), B();
160
+ let n = S, r = C;
161
+ V(n, !1), S = null, C = null, T = null;
162
+ let i = n === null || r === null ? null : e(n, r), a = t && n !== null && i !== null && x !== null, o = A;
163
+ if (A = null, o) if (a) o.forEach((e, t) => {
164
+ t.style.transition = "", t.style.willChange = "";
165
+ });
166
+ else {
167
+ let e = [];
168
+ o.forEach(({ baseY: t }, n) => {
169
+ n.isConnected && (n.style.transition = g, n.style.transform = `translateY(${t}px)`, e.push(n));
170
+ }), window.setTimeout(() => {
171
+ for (let t of e) t.style.transition = "", t.style.willChange = "";
172
+ }, 200);
173
+ }
174
+ !a || n === null || i === null || x === null || (k = v(x.scrollContainerRef.current) ? null : q(), x.commitRowMove(n, i));
124
175
  };
125
176
  return {
126
177
  update: (e) => {
127
- b = e;
178
+ x = e;
128
179
  },
129
180
  onRowDragHandlePointerDown: (e, t) => {
130
- if (b === null || !b.enabled || t.button !== 0) return;
131
- t.stopPropagation(), t.preventDefault(), x = e, S = null, C = {
181
+ if (x === null || !x.enabled || t.button !== 0) return;
182
+ t.stopPropagation(), t.preventDefault(), S = e, C = null, w = {
132
183
  x: t.clientX,
133
184
  y: t.clientY
134
- }, w = {
185
+ }, T = {
135
186
  x: t.clientX,
136
187
  y: t.clientY
137
- }, T = !1, document.body.style.cursor = "grabbing", P(b.getRowDragLabel(e)), L(e, !0);
188
+ }, E = !1, document.body.style.cursor = "grabbing", M() ? (A = H(), j = x.scrollContainerRef.current?.scrollTop ?? 0) : R(x.getRowDragLabel(e)), V(e, !0);
138
189
  let n = t.currentTarget, r = t.pointerId;
139
190
  try {
140
191
  n.setPointerCapture(r);
141
192
  } catch {}
142
193
  let i = (e) => {
143
- e.pointerId === r && (C = {
194
+ e.pointerId === r && (w = {
144
195
  x: e.clientX,
145
196
  y: e.clientY
146
- }, z());
197
+ }, G());
147
198
  }, a = () => {
148
- window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", o), window.removeEventListener("pointercancel", s), window.removeEventListener("keydown", c), E = null;
199
+ window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", o), window.removeEventListener("pointercancel", s), window.removeEventListener("keydown", c), D = null;
149
200
  try {
150
201
  n.releasePointerCapture(r);
151
202
  } catch {}
152
203
  };
153
204
  function o(e) {
154
- e.pointerId === r && (a(), H(!0));
205
+ e.pointerId === r && (a(), J(!0));
155
206
  }
156
207
  function s(e) {
157
- e.pointerId === r && (a(), H(!1));
208
+ e.pointerId === r && (a(), J(!1));
158
209
  }
159
210
  function c(e) {
160
- e.key === "Escape" && (a(), H(!1));
211
+ e.key === "Escape" && (a(), J(!1));
161
212
  }
162
- window.addEventListener("pointermove", i), window.addEventListener("pointerup", o), window.addEventListener("pointercancel", s), window.addEventListener("keydown", c), E = a, z(), D = requestAnimationFrame(B);
213
+ window.addEventListener("pointermove", i), window.addEventListener("pointerup", o), window.addEventListener("pointercancel", s), window.addEventListener("keydown", c), D = a, G(), O = requestAnimationFrame(K);
163
214
  },
164
215
  applyReorderSettle: () => {
165
- let e = O;
166
- if (O = null, !e) return;
167
- let t = b?.scrollContainerRef.current ?? null;
216
+ let e = k;
217
+ if (k = null, !e) return;
218
+ let t = x?.scrollContainerRef.current ?? null;
168
219
  if (!t) return;
169
220
  let n = [], r = /* @__PURE__ */ new Map();
170
221
  if (e.forEach((e, t) => {
171
222
  if (!t.isConnected) return;
172
223
  let i = e - t.getBoundingClientRect().top;
173
224
  if (Math.abs(i) < .5) return;
174
- let a = v.exec(t.style.transform);
225
+ let a = y.exec(t.style.transform);
175
226
  if (!a) return;
176
227
  let o = parseFloat(a[1]);
177
228
  r.set(t, o), t.style.transition = "none", t.style.transform = `translateY(${o + i}px)`, t.style.willChange = "transform", n.push(t);
@@ -184,9 +235,9 @@ var l = 14, u = 12, d = "0.5", f = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
184
235
  }
185
236
  },
186
237
  dispose: () => {
187
- E?.(), E = null, D !== null && (cancelAnimationFrame(D), D = null), document.body.style.cursor = "", I(), L(x, !1), x = null, S = null;
238
+ D?.(), D = null, O !== null && (cancelAnimationFrame(O), O = null), document.body.style.cursor = "", B(), V(S, !1), S = null, C = null, A = null;
188
239
  }
189
240
  };
190
241
  };
191
242
  //#endregion
192
- export { b as createRowDragController };
243
+ export { x as createRowDragController };
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`ssg-body-row--enter`,t=`--ssg-row-enter-index`,n=12,r=1500,i=e=>Number(e.getAttribute(`data-row-index`)),a=/(?:^|;)\s*transform\s*:\s*([^;]+)/,o=e=>{if(!e)return null;let t=a.exec(e);return t?t[1].trim():null},s=e=>e instanceof HTMLElement&&e.classList.contains(`ssg-body-row`),c=`ssg-scroll-container--scrolling`,l=()=>{let n=null,a=null,l=!1,u={skeletonEnter:!1,mountEnter:!1},d=new Map,f=n=>{n.classList.remove(e),n.style.removeProperty(t);let r=d.get(n);r!==void 0&&(clearTimeout(r),d.delete(n))},p=(n,i)=>{n.style.setProperty(t,String(i)),n.classList.add(e);let a=()=>{n.removeEventListener(`animationend`,a),f(n)};n.addEventListener(`animationend`,a),d.set(n,setTimeout(()=>{n.removeEventListener(`animationend`,a),f(n)},r))},m=(e,t)=>{let n=[];for(let r of e){if(r.style.transition)continue;let e=o(t.get(r)??null),i=r.style.transform;!e||!i||e===i||n.push({el:r,from:e,to:i})}if(n.length!==0){for(let{el:e,from:t}of n)e.style.transform=t;a?.getBoundingClientRect();for(let{el:e,to:t}of n)e.style.transform=t}},h=e=>{let t=new Set,n=new Map,r=new Set,o=[];for(let a of e){if(a.type===`attributes`){let e=a.target;s(e)&&!n.has(e)&&n.set(e,a.oldValue);continue}a.removedNodes.forEach(e=>{s(e)&&(e.hasAttribute(`data-skeleton-row`)?t.add(i(e)):r.add(e))}),a.addedNodes.forEach(e=>{s(e)&&!e.hasAttribute(`data-skeleton-row`)&&o.push(e)})}if(o.length===0)return;let l=a?.classList.contains(c)===!0;u.mountEnter&&!l&&m(o.filter(e=>r.has(e)),n);let d=o.filter(e=>u.mountEnter&&!l&&!r.has(e)||u.skeletonEnter&&t.has(i(e)));if(d.length===0)return;let f=Array.from(new Set(d.map(i))).sort((e,t)=>e-t),h=new Map;f.forEach((e,t)=>{h.set(e,Math.min(t,12))});for(let e of d)p(e,h.get(i(e))??0)},g=()=>{n?.disconnect(),n=null,a=null,l=!1;for(let e of Array.from(d.keys()))f(e)};return{update:({scrollContainerRef:e,skeletonEnter:t,mountEnter:r})=>{u={skeletonEnter:t,mountEnter:r};let i=t||r?e.current:null;i===a&&r===l||(g(),!(!i||typeof MutationObserver>`u`)&&(n=new MutationObserver(h),n.observe(i,r?{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`],attributeOldValue:!0}:{childList:!0,subtree:!0}),a=i,l=r))},dispose:g}};exports.ROW_ENTER_CLASS_NAME=e,exports.ROW_ENTER_FALLBACK_MS=r,exports.ROW_ENTER_INDEX_VAR=t,exports.ROW_ENTER_STAGGER_CAP=n,exports.createRowEnterController=l,exports.transformOfStyleText=o;
@@ -0,0 +1,19 @@
1
+ type ReadonlyRef<V> = {
2
+ readonly current: V;
3
+ };
4
+ export type RowEnterArgs = {
5
+ scrollContainerRef: ReadonlyRef<HTMLElement | null>;
6
+ skeletonEnter: boolean;
7
+ mountEnter: boolean;
8
+ };
9
+ export type RowEnterController = {
10
+ update: (args: RowEnterArgs) => void;
11
+ dispose: () => void;
12
+ };
13
+ export declare const ROW_ENTER_CLASS_NAME = "ssg-body-row--enter";
14
+ export declare const ROW_ENTER_INDEX_VAR = "--ssg-row-enter-index";
15
+ export declare const ROW_ENTER_STAGGER_CAP = 12;
16
+ export declare const ROW_ENTER_FALLBACK_MS = 1500;
17
+ export declare const transformOfStyleText: (styleText: string | null) => string | null;
18
+ export declare const createRowEnterController: () => RowEnterController;
19
+ export {};
@@ -0,0 +1,88 @@
1
+ //#region src/controllers/rowEnterController.ts
2
+ var e = "ssg-body-row--enter", t = "--ssg-row-enter-index", n = 12, r = 1500, i = (e) => Number(e.getAttribute("data-row-index")), a = /(?:^|;)\s*transform\s*:\s*([^;]+)/, o = (e) => {
3
+ if (!e) return null;
4
+ let t = a.exec(e);
5
+ return t ? t[1].trim() : null;
6
+ }, s = (e) => e instanceof HTMLElement && e.classList.contains("ssg-body-row"), c = "ssg-scroll-container--scrolling", l = () => {
7
+ let n = null, a = null, l = !1, u = {
8
+ skeletonEnter: !1,
9
+ mountEnter: !1
10
+ }, d = /* @__PURE__ */ new Map(), f = (n) => {
11
+ n.classList.remove(e), n.style.removeProperty(t);
12
+ let r = d.get(n);
13
+ r !== void 0 && (clearTimeout(r), d.delete(n));
14
+ }, p = (n, i) => {
15
+ n.style.setProperty(t, String(i)), n.classList.add(e);
16
+ let a = () => {
17
+ n.removeEventListener("animationend", a), f(n);
18
+ };
19
+ n.addEventListener("animationend", a), d.set(n, setTimeout(() => {
20
+ n.removeEventListener("animationend", a), f(n);
21
+ }, r));
22
+ }, m = (e, t) => {
23
+ let n = [];
24
+ for (let r of e) {
25
+ if (r.style.transition) continue;
26
+ let e = o(t.get(r) ?? null), i = r.style.transform;
27
+ !e || !i || e === i || n.push({
28
+ el: r,
29
+ from: e,
30
+ to: i
31
+ });
32
+ }
33
+ if (n.length !== 0) {
34
+ for (let { el: e, from: t } of n) e.style.transform = t;
35
+ a?.getBoundingClientRect();
36
+ for (let { el: e, to: t } of n) e.style.transform = t;
37
+ }
38
+ }, h = (e) => {
39
+ let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), o = [];
40
+ for (let a of e) {
41
+ if (a.type === "attributes") {
42
+ let e = a.target;
43
+ s(e) && !n.has(e) && n.set(e, a.oldValue);
44
+ continue;
45
+ }
46
+ a.removedNodes.forEach((e) => {
47
+ s(e) && (e.hasAttribute("data-skeleton-row") ? t.add(i(e)) : r.add(e));
48
+ }), a.addedNodes.forEach((e) => {
49
+ s(e) && !e.hasAttribute("data-skeleton-row") && o.push(e);
50
+ });
51
+ }
52
+ if (o.length === 0) return;
53
+ let l = a?.classList.contains(c) === !0;
54
+ u.mountEnter && !l && m(o.filter((e) => r.has(e)), n);
55
+ let d = o.filter((e) => u.mountEnter && !l && !r.has(e) || u.skeletonEnter && t.has(i(e)));
56
+ if (d.length === 0) return;
57
+ let f = Array.from(new Set(d.map(i))).sort((e, t) => e - t), h = /* @__PURE__ */ new Map();
58
+ f.forEach((e, t) => {
59
+ h.set(e, Math.min(t, 12));
60
+ });
61
+ for (let e of d) p(e, h.get(i(e)) ?? 0);
62
+ }, g = () => {
63
+ n?.disconnect(), n = null, a = null, l = !1;
64
+ for (let e of Array.from(d.keys())) f(e);
65
+ };
66
+ return {
67
+ update: ({ scrollContainerRef: e, skeletonEnter: t, mountEnter: r }) => {
68
+ u = {
69
+ skeletonEnter: t,
70
+ mountEnter: r
71
+ };
72
+ let i = t || r ? e.current : null;
73
+ i === a && r === l || (g(), !(!i || typeof MutationObserver > "u") && (n = new MutationObserver(h), n.observe(i, r ? {
74
+ childList: !0,
75
+ subtree: !0,
76
+ attributes: !0,
77
+ attributeFilter: ["style"],
78
+ attributeOldValue: !0
79
+ } : {
80
+ childList: !0,
81
+ subtree: !0
82
+ }), a = i, l = r));
83
+ },
84
+ dispose: g
85
+ };
86
+ };
87
+ //#endregion
88
+ export { e as ROW_ENTER_CLASS_NAME, r as ROW_ENTER_FALLBACK_MS, t as ROW_ENTER_INDEX_VAR, n as ROW_ENTER_STAGGER_CAP, l as createRowEnterController, o as transformOfStyleText };
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`data-ssg-save`,t=`ssg-save-indicator`,n=`ssg-save-failed-chip`,r=1300,i=1300,a=4e3,o=`保存に失敗しました。値を戻しました`,s=e=>typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(e):e.replace(/["\\]/g,`\\$&`),c=()=>{let c=null,l=new Set,u=new Set,d=null,f=null,p=null,m=(e,t)=>{let n=setTimeout(()=>{l.delete(n),t()},e);l.add(n)},h=e=>{let t=c?.scrollContainerRef.current;if(!t)return[];let n=[];for(let r of e.cells){let e=`.ssg-body-row[data-row-key="${s(String(r.rowKey))}"]`;for(let i of r.columnKeys)t.querySelectorAll(`${e} .ssg-body-cell[data-ssg-col-key="${s(i)}"]`).forEach(e=>n.push(e))}return n},g=(e,n)=>{let r=e.querySelector(`:scope > .${t}`);if(n===null){r?.remove();return}r||(r=document.createElement(`span`),r.className=t,r.setAttribute(`aria-hidden`,`true`),e.appendChild(r)),r.setAttribute(`data-kind`,n),r.textContent=n===`ok`?`✓`:n===`failed`?`✕`:``},_=t=>{t.removeAttribute(e),g(t,null)},v=()=>{d?.remove(),d=null,f!==null&&(clearTimeout(f),l.delete(f),f=null),p&&=(p.removeEventListener(`scroll`,v),null)},y=e=>{v();let t=c?.scrollContainerRef.current,r=c?.shellRef?.current??t;if(!t||!r)return;let i=e.getBoundingClientRect(),s=r.getBoundingClientRect();d=document.createElement(`div`),d.className=n,d.setAttribute(`role`,`status`),d.textContent=o,d.style.left=`${Math.max(0,i.left-s.left)}px`,d.style.top=`${i.bottom-s.top+4}px`,r.appendChild(d),p=t,t.addEventListener(`scroll`,v,{passive:!0}),f=setTimeout(()=>{f=null,v()},a),l.add(f)},b=t=>{let n=h(t);for(let a of n){if(t.state===`cleared`){_(a);continue}a.setAttribute(e,t.state),g(a,t.state),t.state===`ok`?m(r,()=>{a.getAttribute(`data-ssg-save`)===`ok`&&_(a)}):t.state===`failed`&&m(i,()=>{a.getAttribute(`data-ssg-save`)===`failed`&&_(a)})}t.state===`failed`&&n.length>0&&y(n[0])};return{update:e=>{c=e},handle:e=>{if(!c?.enabled)return;if(typeof requestAnimationFrame!=`function`){b(e);return}let t=requestAnimationFrame(()=>{u.delete(t),b(e)});u.add(t)},dispose:()=>{for(let e of l)clearTimeout(e);if(l.clear(),typeof cancelAnimationFrame==`function`)for(let e of u)cancelAnimationFrame(e);u.clear(),v(),(c?.scrollContainerRef.current)?.querySelectorAll(`[${e}]`).forEach(_),c=null}}};exports.FAILED_BADGE_MS=i,exports.FAILED_CHIP_MS=a,exports.FAILED_CHIP_TEXT=o,exports.OK_BADGE_MS=r,exports.SAVE_FAILED_CHIP_CLASS_NAME=n,exports.SAVE_INDICATOR_CLASS_NAME=t,exports.SAVE_STATE_ATTRIBUTE=e,exports.createSaveStatusController=c;
@@ -0,0 +1,30 @@
1
+ import type { GridRowKey } from '../model/gridTypes.unbound.js';
2
+ type ReadonlyRef<V> = {
3
+ readonly current: V;
4
+ };
5
+ export type SaveStatusEvent = {
6
+ state: 'pending' | 'ok' | 'failed' | 'cleared';
7
+ cells: ReadonlyArray<{
8
+ rowKey: GridRowKey;
9
+ columnKeys: readonly string[];
10
+ }>;
11
+ };
12
+ export type SaveStatusArgs = {
13
+ scrollContainerRef: ReadonlyRef<HTMLElement | null>;
14
+ shellRef?: ReadonlyRef<HTMLElement | null>;
15
+ enabled: boolean;
16
+ };
17
+ export type SaveStatusController = {
18
+ update: (args: SaveStatusArgs) => void;
19
+ handle: (event: SaveStatusEvent) => void;
20
+ dispose: () => void;
21
+ };
22
+ export declare const SAVE_STATE_ATTRIBUTE = "data-ssg-save";
23
+ export declare const SAVE_INDICATOR_CLASS_NAME = "ssg-save-indicator";
24
+ export declare const SAVE_FAILED_CHIP_CLASS_NAME = "ssg-save-failed-chip";
25
+ export declare const OK_BADGE_MS = 1300;
26
+ export declare const FAILED_BADGE_MS = 1300;
27
+ export declare const FAILED_CHIP_MS = 4000;
28
+ export declare const FAILED_CHIP_TEXT = "\u4FDD\u5B58\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002\u5024\u3092\u623B\u3057\u307E\u3057\u305F";
29
+ export declare const createSaveStatusController: () => SaveStatusController;
30
+ export {};
@@ -0,0 +1,74 @@
1
+ //#region src/controllers/saveStatusController.ts
2
+ var e = "data-ssg-save", t = "ssg-save-indicator", n = "ssg-save-failed-chip", r = 1300, i = 1300, a = 4e3, o = "保存に失敗しました。値を戻しました", s = (e) => typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&"), c = () => {
3
+ let c = null, l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), d = null, f = null, p = null, m = (e, t) => {
4
+ let n = setTimeout(() => {
5
+ l.delete(n), t();
6
+ }, e);
7
+ l.add(n);
8
+ }, h = (e) => {
9
+ let t = c?.scrollContainerRef.current;
10
+ if (!t) return [];
11
+ let n = [];
12
+ for (let r of e.cells) {
13
+ let e = `.ssg-body-row[data-row-key="${s(String(r.rowKey))}"]`;
14
+ for (let i of r.columnKeys) t.querySelectorAll(`${e} .ssg-body-cell[data-ssg-col-key="${s(i)}"]`).forEach((e) => n.push(e));
15
+ }
16
+ return n;
17
+ }, g = (e, n) => {
18
+ let r = e.querySelector(`:scope > .${t}`);
19
+ if (n === null) {
20
+ r?.remove();
21
+ return;
22
+ }
23
+ r || (r = document.createElement("span"), r.className = t, r.setAttribute("aria-hidden", "true"), e.appendChild(r)), r.setAttribute("data-kind", n), r.textContent = n === "ok" ? "✓" : n === "failed" ? "✕" : "";
24
+ }, _ = (t) => {
25
+ t.removeAttribute(e), g(t, null);
26
+ }, v = () => {
27
+ d?.remove(), d = null, f !== null && (clearTimeout(f), l.delete(f), f = null), p &&= (p.removeEventListener("scroll", v), null);
28
+ }, y = (e) => {
29
+ v();
30
+ let t = c?.scrollContainerRef.current, r = c?.shellRef?.current ?? t;
31
+ if (!t || !r) return;
32
+ let i = e.getBoundingClientRect(), s = r.getBoundingClientRect();
33
+ d = document.createElement("div"), d.className = n, d.setAttribute("role", "status"), d.textContent = o, d.style.left = `${Math.max(0, i.left - s.left)}px`, d.style.top = `${i.bottom - s.top + 4}px`, r.appendChild(d), p = t, t.addEventListener("scroll", v, { passive: !0 }), f = setTimeout(() => {
34
+ f = null, v();
35
+ }, a), l.add(f);
36
+ }, b = (t) => {
37
+ let n = h(t);
38
+ for (let a of n) {
39
+ if (t.state === "cleared") {
40
+ _(a);
41
+ continue;
42
+ }
43
+ a.setAttribute(e, t.state), g(a, t.state), t.state === "ok" ? m(r, () => {
44
+ a.getAttribute("data-ssg-save") === "ok" && _(a);
45
+ }) : t.state === "failed" && m(i, () => {
46
+ a.getAttribute("data-ssg-save") === "failed" && _(a);
47
+ });
48
+ }
49
+ t.state === "failed" && n.length > 0 && y(n[0]);
50
+ };
51
+ return {
52
+ update: (e) => {
53
+ c = e;
54
+ },
55
+ handle: (e) => {
56
+ if (!c?.enabled) return;
57
+ if (typeof requestAnimationFrame != "function") {
58
+ b(e);
59
+ return;
60
+ }
61
+ let t = requestAnimationFrame(() => {
62
+ u.delete(t), b(e);
63
+ });
64
+ u.add(t);
65
+ },
66
+ dispose: () => {
67
+ for (let e of l) clearTimeout(e);
68
+ if (l.clear(), typeof cancelAnimationFrame == "function") for (let e of u) cancelAnimationFrame(e);
69
+ u.clear(), v(), (c?.scrollContainerRef.current)?.querySelectorAll(`[${e}]`).forEach(_), c = null;
70
+ }
71
+ };
72
+ };
73
+ //#endregion
74
+ export { i as FAILED_BADGE_MS, a as FAILED_CHIP_MS, o as FAILED_CHIP_TEXT, r as OK_BADGE_MS, n as SAVE_FAILED_CHIP_CLASS_NAME, t as SAVE_INDICATOR_CLASS_NAME, e as SAVE_STATE_ATTRIBUTE, c as createSaveStatusController };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=()=>{let e=null,t=null,n=0,r=null,i=null,a=()=>{i=null;let t=r;r=null,t&&e?.onScroll?.(t)},o=o=>{e?.setViewState({scrollTop:o.scrollTop,viewportHeight:o.clientHeight,viewportWidth:o.clientWidth});let s=()=>{e?.setViewState({scrollTop:o.scrollTop});let t=n>0?`api`:`user`;t===`api`&&--n;let s=r;r={top:o.scrollTop,left:o.scrollLeft,source:s?.source===`user`?`user`:t},e?.onScroll&&i===null&&(i=requestAnimationFrame(a))};o.addEventListener(`scroll`,s,{passive:!0});let c=new ResizeObserver(()=>{e?.setViewState({viewportHeight:o.clientHeight,viewportWidth:o.clientWidth})});c.observe(o),t=()=>{o.removeEventListener(`scroll`,s),i!==null&&(cancelAnimationFrame(i),i=null),c.disconnect()}};return{update:n=>{if(e=n,t===null){let e=n.scrollContainerRef.current;e&&o(e)}},markApiScroll:()=>{n+=1},dispose:()=>{t?.(),t=null}}};exports.createScrollSyncController=e;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`ssg-scroll-container--scrolling`,t=120,n=()=>{let t=null,n=null,r=0,i=null,a=null,o=null,s=()=>{a=null;let e=i;i=null,e&&t?.onScroll?.(e)},c=c=>{t?.setViewState({scrollTop:c.scrollTop,viewportHeight:c.clientHeight,viewportWidth:c.clientWidth});let l=()=>{t?.setViewState({scrollTop:c.scrollTop}),c.classList.add(e),o!==null&&clearTimeout(o),o=setTimeout(()=>{o=null,c.classList.remove(e)},120);let n=r>0?`api`:`user`;n===`api`&&--r;let l=i;i={top:c.scrollTop,left:c.scrollLeft,source:l?.source===`user`?`user`:n},t?.onScroll&&a===null&&(a=requestAnimationFrame(s))};c.addEventListener(`scroll`,l,{passive:!0});let u=new ResizeObserver(()=>{t?.setViewState({viewportHeight:c.clientHeight,viewportWidth:c.clientWidth})});u.observe(c),n=()=>{c.removeEventListener(`scroll`,l),a!==null&&(cancelAnimationFrame(a),a=null),o!==null&&(clearTimeout(o),o=null),c.classList.remove(e),u.disconnect()}};return{update:e=>{if(t=e,n===null){let t=e.scrollContainerRef.current;t&&c(t)}},markApiScroll:()=>{r+=1},dispose:()=>{n?.(),n=null}}};exports.SCROLLING_CLASS_NAME=e,exports.SCROLLING_IDLE_MS=t,exports.createScrollSyncController=n;
@@ -13,5 +13,7 @@ export type ScrollSyncController = {
13
13
  markApiScroll: () => void;
14
14
  dispose: () => void;
15
15
  };
16
+ export declare const SCROLLING_CLASS_NAME = "ssg-scroll-container--scrolling";
17
+ export declare const SCROLLING_IDLE_MS = 120;
16
18
  export declare const createScrollSyncController: () => ScrollSyncController;
17
19
  export {};
@@ -1,51 +1,53 @@
1
1
  //#region src/controllers/scrollSyncController.ts
2
- var e = () => {
3
- let e = null, t = null, n = 0, r = null, i = null, a = () => {
4
- i = null;
5
- let t = r;
6
- r = null, t && e?.onScroll?.(t);
7
- }, o = (o) => {
8
- e?.setViewState({
9
- scrollTop: o.scrollTop,
10
- viewportHeight: o.clientHeight,
11
- viewportWidth: o.clientWidth
2
+ var e = "ssg-scroll-container--scrolling", t = 120, n = () => {
3
+ let t = null, n = null, r = 0, i = null, a = null, o = null, s = () => {
4
+ a = null;
5
+ let e = i;
6
+ i = null, e && t?.onScroll?.(e);
7
+ }, c = (c) => {
8
+ t?.setViewState({
9
+ scrollTop: c.scrollTop,
10
+ viewportHeight: c.clientHeight,
11
+ viewportWidth: c.clientWidth
12
12
  });
13
- let s = () => {
14
- e?.setViewState({ scrollTop: o.scrollTop });
15
- let t = n > 0 ? "api" : "user";
16
- t === "api" && --n;
17
- let s = r;
18
- r = {
19
- top: o.scrollTop,
20
- left: o.scrollLeft,
21
- source: s?.source === "user" ? "user" : t
22
- }, e?.onScroll && i === null && (i = requestAnimationFrame(a));
13
+ let l = () => {
14
+ t?.setViewState({ scrollTop: c.scrollTop }), c.classList.add(e), o !== null && clearTimeout(o), o = setTimeout(() => {
15
+ o = null, c.classList.remove(e);
16
+ }, 120);
17
+ let n = r > 0 ? "api" : "user";
18
+ n === "api" && --r;
19
+ let l = i;
20
+ i = {
21
+ top: c.scrollTop,
22
+ left: c.scrollLeft,
23
+ source: l?.source === "user" ? "user" : n
24
+ }, t?.onScroll && a === null && (a = requestAnimationFrame(s));
23
25
  };
24
- o.addEventListener("scroll", s, { passive: !0 });
25
- let c = new ResizeObserver(() => {
26
- e?.setViewState({
27
- viewportHeight: o.clientHeight,
28
- viewportWidth: o.clientWidth
26
+ c.addEventListener("scroll", l, { passive: !0 });
27
+ let u = new ResizeObserver(() => {
28
+ t?.setViewState({
29
+ viewportHeight: c.clientHeight,
30
+ viewportWidth: c.clientWidth
29
31
  });
30
32
  });
31
- c.observe(o), t = () => {
32
- o.removeEventListener("scroll", s), i !== null && (cancelAnimationFrame(i), i = null), c.disconnect();
33
+ u.observe(c), n = () => {
34
+ c.removeEventListener("scroll", l), a !== null && (cancelAnimationFrame(a), a = null), o !== null && (clearTimeout(o), o = null), c.classList.remove(e), u.disconnect();
33
35
  };
34
36
  };
35
37
  return {
36
- update: (n) => {
37
- if (e = n, t === null) {
38
- let e = n.scrollContainerRef.current;
39
- e && o(e);
38
+ update: (e) => {
39
+ if (t = e, n === null) {
40
+ let t = e.scrollContainerRef.current;
41
+ t && c(t);
40
42
  }
41
43
  },
42
44
  markApiScroll: () => {
43
- n += 1;
45
+ r += 1;
44
46
  },
45
47
  dispose: () => {
46
- t?.(), t = null;
48
+ n?.(), n = null;
47
49
  }
48
50
  };
49
51
  };
50
52
  //#endregion
51
- export { e as createScrollSyncController };
53
+ export { e as SCROLLING_CLASS_NAME, t as SCROLLING_IDLE_MS, n as createScrollSyncController };