@aiquants/spreadsheet 0.17.3 → 0.18.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.
@@ -84,6 +84,29 @@
84
84
  * アウトセット帯 ([clamp, clamp + 3) / (−3, 0]) に載った非所有クローンは消灯する — 漸進アンツ
85
85
  * アウトセットが幽霊破線を継ぎ目の向こうへ引き戻せないようにするため。帯の外はクリップが元より
86
86
  * 不可視化しており、書込パターンは v0.8 と byte 恒等のまま。
87
+ *
88
+ * v0.18 frame (`frameRange`): every quadrant holds one static frame node right after its divider
89
+ * segments, so the runtime stack becomes bands < fills < dividers < frame < activeFrame < … and
90
+ * both insertion anchors keep landing below it through `chromeFloorOf`. Each quadrant frames only
91
+ * the tracks it paints (`layerTracksOf` / `frameSpanOf`) and marks the sides the range continues
92
+ * past as open (`data-aqsp-frame-open`), so the clipped clones join into one seamless frame; the
93
+ * node is placed by insets (`frameAxisCssOf`) whose open sides follow the quadrant's own size. While
94
+ * a frame is set, every quadrant also leads with a band clip capped at the layer's cells
95
+ * (`layerCellsOf` through `min(100%, …)`) that holds the band groups — their far segments end at
96
+ * the clip, their geometry unchanged — the dividers stop at the same cells
97
+ * (`max(0px, calc(100% - …))`) and the marquee's far headroom ends there, so no cell chrome runs
98
+ * past the frame, and a resize that changes no rendered track (which repaints nothing) keeps all of
99
+ * it right. Without a frame the overlay reproduces the v0.17 DOM and writes exactly.
100
+ *
101
+ * v0.18 外枠 (`frameRange`): 各象限は分割線セグメントの直後に静的な外枠のノードを 1 つ持ち、実行時スタックは
102
+ * 帯 < fill < 分割線 < 外枠 < activeFrame < … になる。動的挿入アンカー 2 つは `chromeFloorOf` 経由で外枠の下へ
103
+ * 着地し続ける。各象限は自分が描くトラックだけを囲み (`layerTracksOf` / `frameSpanOf`)、範囲が先へ続く辺を
104
+ * 開く (`data-aqsp-frame-open`) ので、クリップされた複製は継ぎ目の無い 1 つの枠になる。ノードは
105
+ * 詰め (`frameAxisCssOf`) で置き、開いた辺は象限自身の大きさに従う。枠のある間、各象限はさらに層のセル
106
+ * (`layerCellsOf` を `min(100%, …)` で) に抑えた帯の切り抜きを先頭に持ち、帯の組をその中に入れる (遠い側の片は
107
+ * 切り抜きで端が切れ、帯の幾何は変わらない)。分割線は同じセルで止まり (`max(0px, calc(100% - …))`)、マーキーの
108
+ * 遠い側の余白もそこで終わるので、セルのクロームは枠の外へ出ず、描くトラックの変わらない大きさの変化 (何も描き直さ
109
+ * ない) でもどれも正しいままでいる。枠が無ければ v0.17 の DOM と書き込みを厳密に再現する。
87
110
  */
88
111
 
89
112
  import { useWheelBridge, type VirtualGridHandle } from "@aiquants/virtualscroll"
@@ -126,6 +149,177 @@ const CLIP_MARQUEE_OUTSET = 3
126
149
  */
127
150
  export const clipMarqueeOutset = (headroom: number): string => `${-Math.min(CLIP_MARQUEE_OUTSET, Math.max(0, Math.floor(headroom)))}px`
128
151
 
152
+ /**
153
+ * The part of a frame range inside a grid of the given counts, or null when no cell of it is (v0.18). The range's bounds
154
+ * are validated non-negative integers with each start at most its end, so only the ends can lie outside. Exported for
155
+ * the direct value pins (barrel-private).
156
+ * 外枠の範囲のうち、行と列の数のグリッドの中にある部分 (v0.18。1 つのセルも無ければ null)。範囲の境は検め済み (非負の整数で
157
+ * 始まりは終わり以下) のため、外へ出うるのは終わりだけ。値ピン用にモジュール export (バレル非公開)。
158
+ */
159
+ export const frameRangeWithin = (range: CellRange, rowCount: number, colCount: number): CellRange | null => {
160
+ const endRow = Math.min(range.endRow, rowCount - 1)
161
+ const endCol = Math.min(range.endCol, colCount - 1)
162
+ return range.startRow > endRow || range.startCol > endCol ? null : { startRow: range.startRow, startCol: range.startCol, endRow, endCol }
163
+ }
164
+
165
+ /**
166
+ * The length of the cells one layer can paint along one axis from its origin (v0.18), from the tracks alone: all the
167
+ * tracks for an unsplit axis (m), the scroll tracks between the frozen bands for s, and null for a frozen band (f, t),
168
+ * whose tracks always fill it. A layer longer than this (a box wider or taller than the table) has no cells past it.
169
+ * The value does not depend on the viewport, so CSS can cap the layer with it (`min(100%, …)`) and a resize that
170
+ * changes no rendered track — which repaints nothing — keeps it right. Exported for the direct value pins
171
+ * (barrel-private).
172
+ * 1 つの層が 1 つの軸で原点から描けるセルの長さ (v0.18)。トラックだけから決まる: 分けない軸 (m) は全部のトラック、s は凍結の帯の
173
+ * 間のスクロールのトラック、凍結の帯 (f・t) はトラックがいつも層を満たすため null。層がこれより長ければ (表より広いか高い箱)、
174
+ * その先にセルは無い。ビューポートに依らないため、CSS で層を抑えられ (`min(100%, …)`)、描くトラックの変わらない大きさの変化 (何も
175
+ * 描き直さない) でも正しいままでいる。値ピン用にモジュール export (バレル非公開)。
176
+ *
177
+ * @param kind - The layer's band kind on this axis. この軸の層の帯の種別。
178
+ * @param total - The axis's tree size (px). 軸の木の大きさ (px)。
179
+ * @param frozen - The leading frozen band's tree size (px). 先頭の凍結の帯の木の大きさ (px)。
180
+ * @param trailing - The trailing frozen band's tree size (px). 末尾の凍結の帯の木の大きさ (px)。
181
+ * @returns The length (px), or null for a frozen band. 長さ (px)。凍結の帯は null。
182
+ */
183
+ export const layerCellsOf = (kind: AxisKind, total: number, frozen: number, trailing: number): number | null => {
184
+ if (kind === "m") {
185
+ return total
186
+ }
187
+ if (kind === "s") {
188
+ return Math.max(0, total - frozen - trailing)
189
+ }
190
+ return null
191
+ }
192
+
193
+ /**
194
+ * The length one layer paints cells over along one axis (v0.18): its cells (`layerCellsOf`) cut to the layer, or the
195
+ * whole layer for a frozen band. Exported for the direct value pins (barrel-private).
196
+ * 1 つの層が 1 つの軸でセルを描く長さ (v0.18): セル (`layerCellsOf`) を層で切ったもの。凍結の帯は層そのもの。値ピン用にモジュール
197
+ * export (バレル非公開)。
198
+ *
199
+ * @param layer - The layer's clamp extent (px). 層のクランプ範囲 (px)。
200
+ * @param cells - The layer's cells (`layerCellsOf`). 層のセル (`layerCellsOf`)。
201
+ * @returns The painted length (px). セルを描く長さ (px)。
202
+ */
203
+ export const paintedExtentOf = (layer: number, cells: number | null): number => (cells === null ? layer : Math.min(layer, cells))
204
+
205
+ /**
206
+ * The CSS size that caps a box at a layer's cells (v0.18): `100%` of the quadrant for a frozen band, else
207
+ * `min(100%, <cells>px)`. Exported for the direct value pins (barrel-private).
208
+ * 箱を層のセルで抑える CSS の大きさ (v0.18): 凍結の帯は象限の `100%`、ほかは `min(100%, <セル>px)`。値ピン用にモジュール export
209
+ * (バレル非公開)。
210
+ *
211
+ * @param cells - The layer's cells (`layerCellsOf`). 層のセル (`layerCellsOf`)。
212
+ * @returns The CSS size. CSS の大きさ。
213
+ */
214
+ export const cellsSizeCssOf = (cells: number | null): string => (cells === null ? "100%" : `min(100%, ${cells}px)`)
215
+
216
+ /**
217
+ * The CSS end inset that stops a divider at a layer's cells (v0.18): `0px` for a frozen band, else
218
+ * `max(0px, calc(100% - <cells>px))` — the part of the quadrant past the cells. Exported for the direct value pins
219
+ * (barrel-private).
220
+ * 分割線を層のセルで止める CSS の端の詰め (v0.18): 凍結の帯は `0px`、ほかは `max(0px, calc(100% - <セル>px))` — 象限のうちセルより
221
+ * 先の部分。値ピン用にモジュール export (バレル非公開)。
222
+ *
223
+ * @param cells - The layer's cells (`layerCellsOf`). 層のセル (`layerCellsOf`)。
224
+ * @returns The CSS inset. CSS の詰め。
225
+ */
226
+ export const cellsEndCssOf = (cells: number | null): string => (cells === null ? "0px" : `max(0px, calc(100% - ${cells}px))`)
227
+
228
+ /**
229
+ * The tracks one layer paints along one axis (v0.18) as `[first, last]`: the leading frozen tracks for f, the trailing
230
+ * ones for t, those between for s and all of them for m — `last < first` when the layer paints none. The counts are the
231
+ * engine's clamped ones (`getFrozenSize`). Exported for the direct value pins (barrel-private).
232
+ * 1 つの層が 1 つの軸で描くトラック (v0.18) を `[first, last]` で返す。f は先頭の凍結のトラック、t は末尾の凍結、s はその間、m は
233
+ * 全部 — 描かなければ `last < first`。数はエンジンがクランプした値 (`getFrozenSize`)。値ピン用にモジュール export (バレル非公開)。
234
+ *
235
+ * @param kind - The layer's band kind on this axis. この軸の層の帯の種別。
236
+ * @param count - The axis's track count. 軸のトラックの数。
237
+ * @param frozenCount - The leading frozen tracks. 先頭の凍結のトラックの数。
238
+ * @param trailingCount - The trailing frozen tracks. 末尾の凍結のトラックの数。
239
+ * @returns The first and last painted track. 描く最初と最後のトラック。
240
+ */
241
+ export const layerTracksOf = (kind: AxisKind, count: number, frozenCount: number, trailingCount: number): readonly [number, number] => {
242
+ switch (kind) {
243
+ case "f":
244
+ return [0, frozenCount - 1]
245
+ case "s":
246
+ return [frozenCount, count - trailingCount - 1]
247
+ case "t":
248
+ return [count - trailingCount, count - 1]
249
+ case "m":
250
+ return [0, count - 1]
251
+ }
252
+ }
253
+
254
+ /** The track interval of a layer in an unframed grid, where nothing reads it (paints none). / 枠の無いグリッドの層のトラックの区間 (読まれないので、描かない区間)。 */
255
+ const NO_TRACKS: readonly [number, number] = Object.freeze([0, -1] as const)
256
+
257
+ /** One axis of a frame inside one layer: its near and far edges in layer px and whether each is open (not drawn there). / 1 つの層の中の外枠の 1 つの軸: 層の px の近い辺と遠い辺、それぞれが開いている (そこに描かない) か。 */
258
+ export type FrameSpan = { near: number; far: number; nearOpen: boolean; farOpen: boolean }
259
+
260
+ /**
261
+ * One axis of a frame inside one layer (v0.18), or null when the layer paints none of the range on this axis or the
262
+ * range lies wholly beyond the layer's ± 1 screen margin. The layer paints the tracks `first..last`; a side whose range
263
+ * edge lies before `first` or after `last` continues into another pane (or past the axis's scrolled-away part), so it
264
+ * is pushed to the margin and marked open — every pane frames only the cells it paints and the panes join into one
265
+ * frame without a seam. An edge clamped into the margin is open too (it is not there). Exported for the direct value
266
+ * pins (barrel-private).
267
+ * 1 つの層の中の外枠の 1 つの軸 (v0.18)。層がこの軸で範囲のどこも描かないか、範囲が層の ±1 画面の余白より外にあれば null。層は
268
+ * トラック `first..last` を描く。範囲の端が `first` より前か `last` より後にある側は別のペイン (かスクロールで外れた部分) へ続くため、
269
+ * 余白の端に置いて開く — ペインはどれも自分が描くセルだけを囲み、継ぎ目の無い 1 つの枠になる。余白へ詰めた辺も (そこに無いので)
270
+ * 開く。値ピン用にモジュール export (バレル非公開)。
271
+ *
272
+ * @param start - The range's first track on this axis. 範囲のこの軸の最初のトラック。
273
+ * @param end - The range's last track on this axis. 範囲のこの軸の最後のトラック。
274
+ * @param first - The layer's first painted track. 層が描く最初のトラック。
275
+ * @param last - The layer's last painted track (below `first` when it paints none). 層が描く最後のトラック (描かなければ `first` より小さい)。
276
+ * @param nearEdge - The range's near edge through the layer's map (px). 層の写像を通した範囲の近い辺 (px)。
277
+ * @param farEdge - The range's far edge through the layer's map (px). 層の写像を通した範囲の遠い辺 (px)。
278
+ * @param clamp - The layer's clamp extent (px). 層のクランプ範囲 (px)。
279
+ * @returns The span, or null. 軸の範囲、または null。
280
+ */
281
+ export const frameSpanOf = (start: number, end: number, first: number, last: number, nearEdge: number, farEdge: number, clamp: number): FrameSpan | null => {
282
+ if (clamp <= 0 || last < first || end < first || start > last) {
283
+ return null
284
+ }
285
+ const low = -clamp * CLAMP_MARGIN_SCREENS
286
+ const high = clamp * (1 + CLAMP_MARGIN_SCREENS)
287
+ const nearInside = start >= first
288
+ const farInside = end <= last
289
+ const near = nearInside ? nearEdge : low
290
+ const far = farInside ? farEdge : high
291
+ if (far <= low || near >= high) {
292
+ return null
293
+ }
294
+ return { near: Math.max(near, low), far: Math.min(far, high), nearOpen: !nearInside || near < low, farOpen: !farInside || far > high }
295
+ }
296
+
297
+ /** The frame's sides in the CSS order, bit i of an open-side mask naming side i (v0.18). / CSS の順の外枠の辺 (v0.18)。開いた辺のマスクの bit i が辺 i。 */
298
+ const FRAME_SIDES = Object.freeze(["top", "right", "bottom", "left"] as const)
299
+
300
+ /**
301
+ * The open-side mask of a frame in one layer (v0.18): bit 1 top, 2 right, 4 bottom, 8 left. Exported for the direct
302
+ * value pins (barrel-private).
303
+ * 1 つの層の外枠の開いた辺のマスク (v0.18): bit 1 上・2 右・4 下・8 左。値ピン用にモジュール export (バレル非公開)。
304
+ *
305
+ * @param x - The horizontal span. 横の軸の範囲。
306
+ * @param y - The vertical span. 縦の軸の範囲。
307
+ * @returns The mask. マスク。
308
+ */
309
+ export const frameOpenMaskOf = (x: FrameSpan, y: FrameSpan): number => (y.nearOpen ? 1 : 0) | (x.farOpen ? 2 : 0) | (y.farOpen ? 4 : 0) | (x.nearOpen ? 8 : 0)
310
+
311
+ /**
312
+ * The `data-aqsp-frame-open` value of an open-side mask: the open sides in the CSS order, space-separated (the empty
313
+ * string for mask 0, which removes the attribute instead). Built only when the mask changes. Exported for the direct
314
+ * value pins (barrel-private).
315
+ * 開いた辺のマスクの `data-aqsp-frame-open` の値: 開いた辺を CSS の順に空白で区切る (マスク 0 は空文字で、属性を外す)。マスクが
316
+ * 変わったときだけ作る。値ピン用にモジュール export (バレル非公開)。
317
+ *
318
+ * @param mask - The open-side mask. 開いた辺のマスク。
319
+ * @returns The attribute value. 属性の値。
320
+ */
321
+ export const frameOpenSidesOf = (mask: number): string => FRAME_SIDES.filter((_side, bit) => (mask & (1 << bit)) !== 0).join(" ")
322
+
129
323
  /** Row / column / intersection highlight switches (v0.8 §2.4 — default all off = zero band nodes). / 行 / 列 / 交点強調のスイッチ (v0.8 §2.4 — 既定全 off = 帯ノード 0)。 */
130
324
  export type HighlightState = { row: boolean; column: boolean; intersection: boolean }
131
325
 
@@ -508,6 +702,13 @@ type SelectionOverlayProps = {
508
702
  * 帯ノード 0 (v0.7 の DOM 恒等)。
509
703
  */
510
704
  highlightRef?: RefObject<HighlightState>
705
+ /**
706
+ * v0.18 capability: the range to frame (the root's `frame` prop, validated there; the root repaints when it changes).
707
+ * Absent ⇒ no frame node, and the bands and dividers keep the clamp extents (v0.17 DOM and writes).
708
+ * v0.18 能力: 外枠を描く範囲 (root の `frame` prop。検めは root。変わったら root が repaint)。未指定 ⇒ 枠のノードは無く、帯と
709
+ * 分割線はクランプ範囲のまま (v0.17 の DOM と書き込み)。
710
+ */
711
+ frameRange?: CellRange
511
712
  /** v0.8 capability: identity-stable band palette written to `--aqsp-band-*` by a layout effect; the variables are removed again when the palette retires (undefined / identity change / unmount). Absent ⇒ no variable writes (CSS defaults apply — the v0.7 style attribute). / v0.8 能力: identity 安定の帯パレット (layout effect が `--aqsp-band-*` へ書き、パレットの退役 (undefined / identity 交代 / unmount) で変数を外す)。未指定 ⇒ 変数書込なし (CSS 既定 = v0.7 の style 属性)。 */
512
713
  highlightColors?: HighlightColors
513
714
  /** v0.8 capability: popover anchor cells to position (interactive + tip). Absent ⇒ anchors untouched. / v0.8 能力: 配置するポップオーバーアンカーのセル (interactive + tip)。未指定 ⇒ アンカーに触れない。 */
@@ -540,6 +741,31 @@ export type ResizeGuide = { axis: "row" | "col"; position: number; anchor: "lead
540
741
  */
541
742
  type FillSlot = { node: HTMLDivElement; last: { shown: boolean; width: number; height: number; transform: string } }
542
743
 
744
+ /**
745
+ * The frame node of one quadrant plus its last-written values (v0.18 — same-value suppressed like a fill slot): the
746
+ * insets and sizes as CSS ("" = cleared) and the open-side mask of `data-aqsp-frame-open` (-1 = never written).
747
+ * 象限 1 つの外枠のノードと直近の書き込み値 (v0.18 — fill のスロットと同じく同値抑止): CSS の詰めと大きさ ("" は外した値) と、
748
+ * `data-aqsp-frame-open` の開いた辺のマスク (-1 は未書込)。
749
+ */
750
+ type FrameSlot = { node: HTMLDivElement; last: { shown: boolean; left: string; top: string; right: string; bottom: string; width: string; height: string; open: number } }
751
+
752
+ /**
753
+ * One axis of a frame node's CSS placement (v0.18): a closed near side at its mapped position and an open one at the
754
+ * quadrant's edge (0); a closed far side through the size and an open one pinned to the quadrant's far edge (end inset
755
+ * 0, size auto). Open sides follow the quadrant's own size, so a resize that repaints nothing still runs the frame's
756
+ * other lines to the quadrant's edge. Exported for the direct value pins (barrel-private).
757
+ * 外枠のノードの 1 つの軸の CSS の置き方 (v0.18): 閉じた近い辺は写像の位置、開いた近い辺は象限の端 (0)。閉じた遠い辺は大きさで、
758
+ * 開いた遠い辺は象限の遠い端に付ける (端の詰め 0、大きさ auto)。開いた辺は象限自身の大きさに従うため、何も描き直さない大きさの変化
759
+ * でも、枠のほかの線は象限の端まで届く。値ピン用にモジュール export (バレル非公開)。
760
+ *
761
+ * @param span - The axis's span (`frameSpanOf`). 軸の範囲 (`frameSpanOf`)。
762
+ * @returns The start inset, the end inset and the size as CSS ("" = cleared). 始まりの詰め・終わりの詰め・大きさの CSS ("" は外す)。
763
+ */
764
+ export const frameAxisCssOf = (span: FrameSpan): { start: string; end: string; size: string } => {
765
+ const start = span.nearOpen ? 0 : span.near
766
+ return span.farOpen ? { start: `${start}px`, end: "0px", size: "" } : { start: `${start}px`, end: "", size: `${span.far - start}px` }
767
+ }
768
+
543
769
  /** Resident node set of one overlay layer (v0.5 layer split; every layer owns a dedicated container). / overlay 1 層ぶんの常設ノード束 (v0.5 の層分割。全層が専用コンテナを持つ)。 */
544
770
  type LayerNodes = {
545
771
  container: HTMLDivElement | null
@@ -560,22 +786,68 @@ type LayerNodes = {
560
786
  dividerSlots: (HTMLDivElement | null)[]
561
787
  /** Last-written shown state per divider slot (equality-suppressed `display` heal — v0.9 §2.4). / 分割線スロット毎の直近書込 shown 状態 (等値抑制 `display` heal — v0.9 §2.4)。 */
562
788
  dividerShown: boolean[]
563
- /** Identity-stable compact array of the quad's mounted segments (≤ 4, DOM order — the `chromeFloorOf` source, v0.9 §2.5). / 象限のマウント済みセグメントの identity 安定な圧縮配列 (≤ 4、DOM 順 — `chromeFloorOf` の源、v0.9 §2.5)。 */
564
- dividers: HTMLDivElement[]
789
+ /**
790
+ * Last-written end inset per divider slot as CSS — `bottom` of the vertical slots, `right` of the horizontal ones (v0.18:
791
+ * a framed grid stops its dividers at the layer's cells, `cellsEndCssOf`; `0px` = the JSX's initial end,
792
+ * equality-suppressed).
793
+ * 分割線スロット毎の直近書込の端の詰め (CSS) — 縦のスロットは `bottom`、横は `right` (v0.18: 枠のあるグリッドは分割線を層のセルで
794
+ * 止める。`cellsEndCssOf`。`0px` は JSX の初めの端で、等値抑止)。
795
+ */
796
+ dividerEnd: string[]
797
+ /** Mounted frame node of the quadrant (v0.18 — null without a frame). / 象限のマウント済みの外枠のノード (v0.18 — 枠が無ければ null)。 */
798
+ frame: FrameSlot | null
799
+ /**
800
+ * The quadrant's band clip (v0.18 — null without a frame): the first child of the quadrant, sized to the cells the
801
+ * layer paints, holding the band groups. A band's far segments end at the layer's clip, so a framed grid gives them
802
+ * this clip to stop them at the last painted cell (the band geometry itself is unchanged).
803
+ * 象限の帯の切り抜き (v0.18 — 枠が無ければ null): 象限の最初の子で、層が描くセルの大きさを持ち、帯の組を入れる。帯の遠い側の
804
+ * 片は層の切り抜きで端が切れるため、枠のあるグリッドはこの切り抜きを与えて最後に描くセルで止める (帯の幾何は変えない)。
805
+ */
806
+ bandClip: HTMLDivElement | null
807
+ /** Last-written band-clip size as CSS (`cellsSizeCssOf`; "" = never written). / 帯の切り抜きの直近の書き込みの大きさ (CSS。`cellsSizeCssOf`。"" は未書込)。 */
808
+ bandClipWidth: string
809
+ bandClipHeight: string
810
+ /**
811
+ * Identity-stable compact array of the quad's mounted static chrome below the active frame — the divider segments in
812
+ * slot order, then the frame (≤ 5, DOM order — the `chromeFloorOf` source, v0.9 §2.5 / v0.18).
813
+ * 象限のマウント済みの、アクティブ枠より下の静的クロームの identity 安定な圧縮配列 — スロット順の分割線、続いて外枠 (≤ 5、
814
+ * DOM 順 — `chromeFloorOf` の源、v0.9 §2.5 / v0.18)。
815
+ */
816
+ chrome: HTMLDivElement[]
565
817
  }
566
818
 
567
819
  /**
568
820
  * The canonical "first static chrome child" anchor of a quadrant (v0.9 §2.5 — ADR-24): the
569
- * quad's first mounted divider segment, else the active frame. A structural ordering definition
570
- * with a single source shared by BOTH dynamic insertion anchors (fill pool census #24 / band
571
- * groups census #25) — not a value fallback. A fill or band created AFTER dividers exist must
572
- * still land BELOW them, or the divider's seam absorption breaks.
573
- * 象限の「最初の静的クローム子」正準アンカー (v0.9 §2.5 — ADR-24): マウント済み分割線セグメントの
574
- * 先頭、無ければアクティブ枠。動的挿入アンカー 2 つ (fill プール census #24 / 帯組 census #25) が
575
- * 共有する構造的順序定義の単一源 — 値フォールバックではない。分割線マウント後に生成された fill /
576
- * 帯もその下へ着地しないと、分割線の継ぎ目吸収が破れる。
821
+ * quad's first mounted static chrome node (a divider segment, else the v0.18 frame), else the
822
+ * active frame. A structural ordering definition with a single source shared by BOTH dynamic
823
+ * insertion anchors (fill pool census #24 / band groups census #25) — not a value fallback. A
824
+ * fill or band created AFTER dividers or a frame exist must still land BELOW them, or the
825
+ * divider's seam absorption breaks and the bands tint over the frame.
826
+ * 象限の「最初の静的クローム子」正準アンカー (v0.9 §2.5 — ADR-24): マウント済みの静的クロームの
827
+ * 先頭 (分割線セグメント、無ければ v0.18 の外枠)、無ければアクティブ枠。動的挿入アンカー 2 つ
828
+ * (fill プール census #24 / 帯組 census #25) が共有する構造的順序定義の単一源 — 値フォールバック
829
+ * ではない。分割線か外枠のマウント後に生成された fill / 帯もその下へ着地しないと、分割線の継ぎ目
830
+ * 吸収が破れ、帯が外枠の上を染める。
831
+ */
832
+ const chromeFloorOf = (nodes: LayerNodes): HTMLDivElement | null => nodes.chrome[0] ?? nodes.active
833
+
834
+ /**
835
+ * Rebuilds a quadrant's static chrome array in DOM order — the mounted divider segments in slot order, then the v0.18
836
+ * frame — keeping the array's identity (the `chromeFloorOf` source). Runs only on a mount or unmount of one of them.
837
+ * 象限の静的クロームの配列を DOM の順 (スロット順のマウント済み分割線、続いて v0.18 の外枠) で組み直す。配列の identity は保つ
838
+ * (`chromeFloorOf` の読み先)。走るのはどれかのマウントとアンマウントのときだけ。
577
839
  */
578
- const chromeFloorOf = (nodes: LayerNodes): HTMLDivElement | null => nodes.dividers[0] ?? nodes.active
840
+ const rebuildChrome = (nodes: LayerNodes): void => {
841
+ nodes.chrome.length = 0
842
+ for (const node of nodes.dividerSlots) {
843
+ if (node !== null) {
844
+ nodes.chrome.push(node)
845
+ }
846
+ }
847
+ if (nodes.frame !== null) {
848
+ nodes.chrome.push(nodes.frame.node)
849
+ }
850
+ }
579
851
 
580
852
  /** Inline container geometry of one x-split ("" clears the property). / x 分割 1 本のコンテナインライン形状 ("" はプロパティ解除)。 */
581
853
  type XSplitStyle = { left: string; right: string; width: string }
@@ -596,11 +868,33 @@ type LayerCtx = {
596
868
  xStyle: XSplitStyle
597
869
  xSeamLead: boolean
598
870
  xSeamTrail: boolean
871
+ /** First and last column the layer paints (v0.18 — read by the frame; last < first when it paints none). / 層が描く最初と最後の列 (v0.18 — 外枠が読む。描かなければ last < first)。 */
872
+ xFirst: number
873
+ xLast: number
599
874
  mapY: (treeY: number) => number
600
875
  clampHeight: number
601
876
  yStyle: YSplitStyle
602
877
  ySeamLead: boolean
603
878
  ySeamTrail: boolean
879
+ /** First and last row the layer paints (v0.18). / 層が描く最初と最後の行 (v0.18)。 */
880
+ yFirst: number
881
+ yLast: number
882
+ /**
883
+ * The extents of the cells the layer paints (v0.18): the clamp extents, except that a framed grid limits them to the
884
+ * painted cells (`paintedExtentOf`). They give the marquee's far headroom, so the ants stay inside the frame.
885
+ * 層が描くセルの範囲 (v0.18): クランプ範囲。ただし枠のあるグリッドはセルを描く長さ (`paintedExtentOf`) までにする。マーキーの遠い
886
+ * 側の余白に使い、アンツを枠の内に保つ。
887
+ */
888
+ cells: BandExtents
889
+ /**
890
+ * The layer's cells per axis from the tracks alone (`layerCellsOf`, v0.18) — null for a frozen band and in an unframed
891
+ * grid. They size the band clip and stop the dividers through CSS (`cellsSizeCssOf` / `cellsEndCssOf`), so both keep up
892
+ * with a resize that repaints nothing.
893
+ * 層の軸ごとのトラックだけから決まるセル (`layerCellsOf`、v0.18) — 凍結の帯と枠の無いグリッドは null。帯の切り抜きの大きさと
894
+ * 分割線の止まる所を CSS で決め (`cellsSizeCssOf` / `cellsEndCssOf`)、何も描き直さない大きさの変化にも追いつく。
895
+ */
896
+ xCells: number | null
897
+ yCells: number | null
604
898
  }
605
899
 
606
900
  /**
@@ -630,6 +924,17 @@ type SplitCache = {
630
924
  trailingVisibleHeight: number
631
925
  bodyWidth: number
632
926
  bodyHeight: number
927
+ /**
928
+ * v0.18 frame keys: whether a frame is drawn and, only while one is, the track counts and tree sizes the painted
929
+ * extents and the frame's track intervals read (-1 without a frame, so an unframed grid rebuilds exactly as before).
930
+ * v0.18 の外枠の鍵: 枠を描くかと、描く間だけ、セルを描く長さと枠のトラックの区間が読むトラックの数と木の大きさ (枠が無ければ
931
+ * -1 で、枠の無いグリッドは今までと同じ時にだけ組み直す)。
932
+ */
933
+ framed: boolean
934
+ rowCount: number
935
+ colCount: number
936
+ rowsTotal: number
937
+ colsTotal: number
633
938
  ctxs: LayerCtx[]
634
939
  }
635
940
 
@@ -652,7 +957,12 @@ const emptyLayerNodes = (): LayerNodes => ({
652
957
  bandClampHeight: -1,
653
958
  dividerSlots: [null, null, null, null],
654
959
  dividerShown: [false, false, false, false],
655
- dividers: [],
960
+ dividerEnd: ["0px", "0px", "0px", "0px"],
961
+ frame: null,
962
+ bandClip: null,
963
+ bandClipWidth: "",
964
+ bandClipHeight: "",
965
+ chrome: [],
656
966
  })
657
967
 
658
968
  /** All quadrant keys ever rendered — the full {m,f,s,t}² pre-seed (v0.9 §2.5: identity-stable ref-bundle life structure). / 描画され得る全象限キー — {m,f,s,t}² のフル事前シード (v0.9 §2.5: identity 安定な ref 束の生活構造)。 */
@@ -692,12 +1002,17 @@ export const SelectionOverlay = ({
692
1002
  onSinkMouseDown,
693
1003
  editPaintRef,
694
1004
  highlightRef,
1005
+ frameRange,
695
1006
  highlightColors,
696
1007
  popoverAnchors,
697
1008
  interactiveAnchorRef,
698
1009
  tipAnchorRef,
699
1010
  }: SelectionOverlayProps): ReactNode => {
700
1011
  const overlayRef = useRef<HTMLDivElement | null>(null)
1012
+ /** Live frame range read by the write passes (render-time assignment, as the root's highlight ref). / 書込パスが読む外枠の範囲 (root の強調の ref と同じくレンダー時代入)。 */
1013
+ const frameRangeRef = useRef(frameRange)
1014
+ frameRangeRef.current = frameRange
1015
+ const framed = frameRange !== undefined
701
1016
  /** Live fill-preview rect (source ∪ band) for scroll-follow repositioning (§8.2). / 生存中 fill プレビュー矩形 (スクロール追随用)。 */
702
1017
  const liveFillPreviewRef = useRef<CellRange | null>(null)
703
1018
  /** Live resize guideline for scroll-follow repositioning (§7.2). / 生存中ガイドライン (スクロール追随用)。 */
@@ -790,6 +1105,46 @@ export const SelectionOverlay = ({
790
1105
  nodes.dividerShown[slot] = shown
791
1106
  node.style.display = shown ? "" : "none"
792
1107
  }, [])
1108
+ /**
1109
+ * Equality-suppressed end heal of one divider slot (v0.18): a framed grid stops its dividers at the last painted
1110
+ * cell, so the vertical slots (0, 1) take `bottom` and the horizontal ones (2, 3) take `right` — the layer's clamp
1111
+ * extent minus its painted extent. An unframed grid computes 0, the JSX's end, and writes nothing.
1112
+ * 分割線スロット 1 つの端の等値抑制 heal (v0.18): 枠のあるグリッドは分割線を最後に描くセルで止めるため、縦のスロット (0・1) は
1113
+ * `bottom`、横 (2・3) は `right` に、層のクランプ範囲からセルを描く長さを引いた値を書く。枠の無いグリッドは JSX の端と同じ 0 に
1114
+ * なり、何も書かない。
1115
+ */
1116
+ /**
1117
+ * Equality-suppressed size heal of the quadrant's band clip (v0.18): the cells the layer paints, so the band groups
1118
+ * inside it end at the last painted cell. A quadrant without a clip (no frame) writes nothing.
1119
+ * 象限の帯の切り抜きの大きさの等値抑制 heal (v0.18): 層が描くセルの大きさにし、中の帯の組を最後に描くセルで止める。切り抜きの
1120
+ * 無い象限 (枠が無い) は何も書かない。
1121
+ */
1122
+ const healBandClip = useCallback((nodes: LayerNodes, width: string, height: string) => {
1123
+ const clip = nodes.bandClip
1124
+ if (clip === null) {
1125
+ return
1126
+ }
1127
+ if (nodes.bandClipWidth !== width) {
1128
+ nodes.bandClipWidth = width
1129
+ clip.style.width = width
1130
+ }
1131
+ if (nodes.bandClipHeight !== height) {
1132
+ nodes.bandClipHeight = height
1133
+ clip.style.height = height
1134
+ }
1135
+ }, [])
1136
+ const healDividerEnd = useCallback((nodes: LayerNodes, slot: number, inset: string) => {
1137
+ const node = nodes.dividerSlots[slot]
1138
+ if (node === null || nodes.dividerEnd[slot] === inset) {
1139
+ return
1140
+ }
1141
+ nodes.dividerEnd[slot] = inset
1142
+ if (slot < 2) {
1143
+ node.style.bottom = inset
1144
+ } else {
1145
+ node.style.right = inset
1146
+ }
1147
+ }, [])
793
1148
  /** Live scroll snapshot the cached split maps read (`layersFor` refreshes it on every call). / キャッシュ済み分割写像が読む生スクロール快照 (`layersFor` が毎呼び更新)。 */
794
1149
  const scrollSnapshotRef = useRef({ x: 0, y: 0 })
795
1150
  /** Split-descriptor cache — invalidated by freeze / viewport geometry change, never by scroll. / 分割記述子キャッシュ — 凍結 / viewport 幾何の変化で無効化 (スクロールでは無効化しない)。 */
@@ -815,9 +1170,21 @@ export const SelectionOverlay = ({
815
1170
  const scroll = scrollSnapshotRef.current
816
1171
  scroll.x = hx
817
1172
  scroll.y = vy
1173
+ // 外枠の鍵 (v0.18): 枠のある間だけ、トラックの数と木の大きさを鍵にする。枠の無いグリッドは -1 で、今までと同じ時にだけ組み直す
1174
+ const framed = frameRangeRef.current !== undefined
1175
+ const axes = axesRef.current
1176
+ const rowCount = framed ? axes.rowAxis.count : -1
1177
+ const colCount = framed ? axes.colAxis.count : -1
1178
+ const rowsTotal = framed ? axes.rowAxis.totalSize() : -1
1179
+ const colsTotal = framed ? axes.colAxis.totalSize() : -1
818
1180
  let cache = splitCacheRef.current
819
1181
  if (
820
1182
  cache === null ||
1183
+ cache.framed !== framed ||
1184
+ cache.rowCount !== rowCount ||
1185
+ cache.colCount !== colCount ||
1186
+ cache.rowsTotal !== rowsTotal ||
1187
+ cache.colsTotal !== colsTotal ||
821
1188
  cache.frozenCols !== frozen.cols ||
822
1189
  cache.frozenWidth !== frozen.width ||
823
1190
  cache.frozenRows !== frozen.rows ||
@@ -882,7 +1249,13 @@ export const SelectionOverlay = ({
882
1249
  ]
883
1250
  const ctxs: LayerCtx[] = []
884
1251
  for (const xs of xSplits) {
1252
+ // 枠のあるグリッドだけ、層のセル (帯の切り抜き・分割線の端・マーキーの余白) と枠が読むトラックの区間を持つ (枠が無ければ
1253
+ // セルは層いっぱいで、区間は読まれない)
1254
+ const xCells = framed ? layerCellsOf(xs.kind, colsTotal, frozen.width, frozen.trailingWidth) : null
1255
+ const [xFirst, xLast] = framed ? layerTracksOf(xs.kind, colCount, frozen.cols, frozen.trailingCols) : NO_TRACKS
885
1256
  for (const ys of ySplits) {
1257
+ const yCells = framed ? layerCellsOf(ys.kind, rowsTotal, frozen.height, frozen.trailingHeight) : null
1258
+ const [yFirst, yLast] = framed ? layerTracksOf(ys.kind, rowCount, frozen.rows, frozen.trailingRows) : NO_TRACKS
886
1259
  ctxs.push({
887
1260
  nodes: nodeSetFor(`${xs.kind}${ys.kind}`),
888
1261
  xKind: xs.kind,
@@ -892,11 +1265,18 @@ export const SelectionOverlay = ({
892
1265
  xStyle: xs.style,
893
1266
  xSeamLead: xs.seamLead,
894
1267
  xSeamTrail: xs.seamTrail,
1268
+ xFirst,
1269
+ xLast,
895
1270
  mapY: ys.map,
896
1271
  clampHeight: ys.clamp,
897
1272
  yStyle: ys.style,
898
1273
  ySeamLead: ys.seamLead,
899
1274
  ySeamTrail: ys.seamTrail,
1275
+ yFirst,
1276
+ yLast,
1277
+ cells: { clampWidth: paintedExtentOf(xs.clamp, xCells), clampHeight: paintedExtentOf(ys.clamp, yCells) },
1278
+ xCells,
1279
+ yCells,
900
1280
  })
901
1281
  }
902
1282
  }
@@ -913,6 +1293,11 @@ export const SelectionOverlay = ({
913
1293
  trailingVisibleHeight: frozen.trailingVisibleHeight,
914
1294
  bodyWidth,
915
1295
  bodyHeight,
1296
+ framed,
1297
+ rowCount,
1298
+ colCount,
1299
+ rowsTotal,
1300
+ colsTotal,
916
1301
  ctxs,
917
1302
  }
918
1303
  splitCacheRef.current = cache
@@ -934,10 +1319,19 @@ export const SelectionOverlay = ({
934
1319
  healDivider(ctx.nodes, 1, showXTrail)
935
1320
  healDivider(ctx.nodes, 2, showYLead)
936
1321
  healDivider(ctx.nodes, 3, showYTrail)
1322
+ // 枠のあるグリッドの分割線は層のセルで止める (縦は下、横は右を詰める。枠が無ければ 0px で書かない)
1323
+ const endY = cellsEndCssOf(ctx.yCells)
1324
+ const endX = cellsEndCssOf(ctx.xCells)
1325
+ healDividerEnd(ctx.nodes, 0, endY)
1326
+ healDividerEnd(ctx.nodes, 1, endY)
1327
+ healDividerEnd(ctx.nodes, 2, endX)
1328
+ healDividerEnd(ctx.nodes, 3, endX)
1329
+ // 帯の切り抜きは層のセルの大きさ (枠の無いグリッドには切り抜きが無い)
1330
+ healBandClip(ctx.nodes, cellsSizeCssOf(ctx.xCells), cellsSizeCssOf(ctx.yCells))
937
1331
  }
938
1332
  return cache.ctxs
939
1333
  },
940
- [handleRef, nodeSetFor, healContainer, healLayerBands, healDivider],
1334
+ [handleRef, nodeSetFor, healContainer, healLayerBands, healDivider, healDividerEnd, healBandClip],
941
1335
  )
942
1336
  /**
943
1337
  * Stable ref-callback set for one layer (❗ identity-stable via useMemo — a per-render
@@ -959,14 +1353,47 @@ export const SelectionOverlay = ({
959
1353
  */
960
1354
  const setDividerSlot = useCallback((n: LayerNodes, slot: number, el: HTMLDivElement | null) => {
961
1355
  n.dividerSlots[slot] = el
962
- // JSX 初期 display は "none" — 等値抑制キャッシュを初期値へ同期 (空砲抑制の防止)
1356
+ // JSX 初期 display は "none"、端は 0 — 等値抑制キャッシュを初期値へ同期 (空砲抑制の防止)
963
1357
  n.dividerShown[slot] = false
964
- // 圧縮配列は identity を保ったまま中身だけ再構成 (chromeFloorOf の読み先)
965
- n.dividers.length = 0
966
- for (const node of n.dividerSlots) {
967
- if (node !== null) {
968
- n.dividers.push(node)
969
- }
1358
+ n.dividerEnd[slot] = "0px"
1359
+ rebuildChrome(n)
1360
+ }, [])
1361
+ /**
1362
+ * Registers the quadrant's frame node (v0.18) with an empty write cache and rebuilds the static chrome array. Runs
1363
+ * only when the frame mounts or unmounts — never per frame.
1364
+ * 象限の外枠のノードを空の書き込みキャッシュで登録し、静的クロームの配列を組み直す (v0.18)。走るのは枠のマウントとアンマウント
1365
+ * のときだけで、毎フレームでは走らない。
1366
+ */
1367
+ const setFrameSlot = useCallback((n: LayerNodes, el: HTMLDivElement | null) => {
1368
+ n.frame = el === null ? null : { node: el, last: { shown: false, left: "", top: "", right: "", bottom: "", width: "", height: "", open: -1 } }
1369
+ rebuildChrome(n)
1370
+ }, [])
1371
+ /**
1372
+ * Registers the quadrant's band clip (v0.18) and retires the quadrant's band groups, which the next repaint creates
1373
+ * again inside the clip (on mount) or the quadrant (on unmount — React removed the clip with the groups in it). On
1374
+ * mount the clip moves to the quadrant's front: React inserts it before its next JSX sibling, above any fill already
1375
+ * inserted there, while the bands must stay below the fills.
1376
+ * 象限の帯の切り抜きを登録し (v0.18)、象限の帯の組を退役させる。次の repaint が組を切り抜きの中 (マウント) か象限 (アンマウント
1377
+ * — React が組ごと切り抜きを外した) に作り直す。マウントでは切り抜きを象限の先頭へ動かす: React は次の JSX の兄弟の前へ入れるため、
1378
+ * そこに既にある fill より上になるが、帯は fill より下でなければならない。
1379
+ */
1380
+ const setBandClip = useCallback((n: LayerNodes, el: HTMLDivElement | null) => {
1381
+ for (const group of n.bandPool) {
1382
+ removeBandNodes(group)
1383
+ }
1384
+ n.bandPool.length = 0
1385
+ if (n.dragBand !== null) {
1386
+ removeBandNodes(n.dragBand)
1387
+ n.dragBand = null
1388
+ }
1389
+ n.bandClampWidth = -1
1390
+ n.bandClampHeight = -1
1391
+ n.bandClip = el
1392
+ n.bandClipWidth = ""
1393
+ n.bandClipHeight = ""
1394
+ const quad = el === null ? null : el.parentElement
1395
+ if (el !== null && quad !== null && quad.firstChild !== el) {
1396
+ quad.insertBefore(el, quad.firstChild)
970
1397
  }
971
1398
  }, [])
972
1399
  const makeLayerRefs = useCallback(
@@ -991,6 +1418,9 @@ export const SelectionOverlay = ({
991
1418
  dividerXTrailing: (el: HTMLDivElement | null) => setDividerSlot(nodes(), 1, el),
992
1419
  dividerYLeading: (el: HTMLDivElement | null) => setDividerSlot(nodes(), 2, el),
993
1420
  dividerYTrailing: (el: HTMLDivElement | null) => setDividerSlot(nodes(), 3, el),
1421
+ // 外枠と帯の切り抜き (v0.18 — 存在は枠の有無の JSX 分岐、React が mount / unmount で装着・解除する)
1422
+ frame: (el: HTMLDivElement | null) => setFrameSlot(nodes(), el),
1423
+ bandClip: (el: HTMLDivElement | null) => setBandClip(nodes(), el),
994
1424
  active: (el: HTMLDivElement | null) => {
995
1425
  nodes().active = el
996
1426
  },
@@ -1008,7 +1438,7 @@ export const SelectionOverlay = ({
1008
1438
  },
1009
1439
  }
1010
1440
  },
1011
- [nodeSetFor, setDividerSlot],
1441
+ [nodeSetFor, setDividerSlot, setFrameSlot, setBandClip],
1012
1442
  )
1013
1443
  // 象限キーごとに identity 安定な ref 束を用意 (空 deps — 毎レンダー生成だと React が detach /
1014
1444
  // attach してプールが空になり塗りが二重化する)。JSX は実効 F / R に応じて必要な象限だけ描く
@@ -1119,12 +1549,94 @@ export const SelectionOverlay = ({
1119
1549
 
1120
1550
  /** Inserts a band group under the layer's fills (before the first fill, else before the chrome floor — v0.9 §2.5 census #25: the old `nodes.active` anchor could not land a band group below a mounted divider). / 帯組を層の fill の下へ挿入 (先頭 fill の手前、無ければ静的クローム床の手前 — v0.9 §2.5 census #25: 旧 `nodes.active` 直指しではマウント済み分割線の下へ帯組を入れられない)。 */
1121
1551
  const insertBandGroup = useCallback((container: HTMLDivElement, nodes: LayerNodes, group: BandNodes) => {
1552
+ // 枠のあるグリッド (v0.18) は帯を象限の先頭の帯の切り抜きへ入れ、最後に描くセルで切る (切り抜きは fill より下)
1553
+ if (nodes.bandClip !== null) {
1554
+ for (const node of bandNodeList(group)) {
1555
+ nodes.bandClip.appendChild(node)
1556
+ }
1557
+ return
1558
+ }
1122
1559
  const before = nodes.fillPool[0]?.node ?? chromeFloorOf(nodes)
1123
1560
  for (const node of bandNodeList(group)) {
1124
1561
  container.insertBefore(node, before)
1125
1562
  }
1126
1563
  }, [])
1127
1564
 
1565
+ /**
1566
+ * Places one quadrant's frame (v0.18): the part of the frame range the layer paints (`frameSpanOf` on both axes, the
1567
+ * range first cut to the grid by `frameRangeWithin`), with the sides the range continues past marked open
1568
+ * (`data-aqsp-frame-open`), hidden when the layer paints none of it, placed by insets (`frameAxisCssOf`) so its open
1569
+ * sides follow the quadrant's size. Every write is same-value suppressed (the fill slot's census #23 discipline): a
1570
+ * steady scroll frame writes at most one inset per scrolled axis — the frame is one leaf node per quadrant, so the
1571
+ * layout an inset costs is negligible next to keeping the open sides right without a repaint.
1572
+ * 象限 1 つの外枠を置く (v0.18): 範囲 (先に `frameRangeWithin` でグリッドへ切る) のうち層が描く部分 (両軸の `frameSpanOf`) を
1573
+ * 囲み、範囲が先へ続く辺は開く (`data-aqsp-frame-open`)。層が範囲のどこも描かなければ隠す。詰め (`frameAxisCssOf`) で置き、開いた
1574
+ * 辺は象限の大きさに従う。書き込みはどれも同値抑止 (fill のスロットの census #23 の規律) で、定常のスクロールのフレームが書くのは
1575
+ * スクロールした軸の詰め 1 つまで — 外枠は象限に 1 つの葉のノードで、詰めが起こす配置の手間は、描き直さずに開いた辺を正しく保つ
1576
+ * ことに比べて小さい。
1577
+ */
1578
+ const placeFrame = useCallback(
1579
+ (ctx: LayerCtx) => {
1580
+ const slot = ctx.nodes.frame
1581
+ if (slot === null) {
1582
+ return
1583
+ }
1584
+ const range = frameRangeRef.current
1585
+ const within = range === undefined ? null : frameRangeWithin(range, rowAxis.count, colAxis.count)
1586
+ const x = within === null ? null : frameSpanOf(within.startCol, within.endCol, ctx.xFirst, ctx.xLast, ctx.mapX(colAxis.offsetOf(within.startCol)), ctx.mapX(colAxis.offsetOf(within.endCol) + colAxis.sizeOf(within.endCol)), ctx.clampWidth)
1587
+ const y = within === null ? null : frameSpanOf(within.startRow, within.endRow, ctx.yFirst, ctx.yLast, ctx.mapY(rowAxis.offsetOf(within.startRow)), ctx.mapY(rowAxis.offsetOf(within.endRow) + rowAxis.sizeOf(within.endRow)), ctx.clampHeight)
1588
+ const last = slot.last
1589
+ const style = slot.node.style
1590
+ if (x === null || y === null) {
1591
+ if (last.shown) {
1592
+ last.shown = false
1593
+ style.display = "none"
1594
+ }
1595
+ return
1596
+ }
1597
+ if (!last.shown) {
1598
+ last.shown = true
1599
+ style.display = "block"
1600
+ }
1601
+ const horizontal = frameAxisCssOf(x)
1602
+ const vertical = frameAxisCssOf(y)
1603
+ if (horizontal.start !== last.left) {
1604
+ last.left = horizontal.start
1605
+ style.left = horizontal.start
1606
+ }
1607
+ if (horizontal.end !== last.right) {
1608
+ last.right = horizontal.end
1609
+ style.right = horizontal.end
1610
+ }
1611
+ if (horizontal.size !== last.width) {
1612
+ last.width = horizontal.size
1613
+ style.width = horizontal.size
1614
+ }
1615
+ if (vertical.start !== last.top) {
1616
+ last.top = vertical.start
1617
+ style.top = vertical.start
1618
+ }
1619
+ if (vertical.end !== last.bottom) {
1620
+ last.bottom = vertical.end
1621
+ style.bottom = vertical.end
1622
+ }
1623
+ if (vertical.size !== last.height) {
1624
+ last.height = vertical.size
1625
+ style.height = vertical.size
1626
+ }
1627
+ const open = frameOpenMaskOf(x, y)
1628
+ if (open !== last.open) {
1629
+ last.open = open
1630
+ if (open === 0) {
1631
+ slot.node.removeAttribute("data-aqsp-frame-open")
1632
+ } else {
1633
+ slot.node.setAttribute("data-aqsp-frame-open", frameOpenSidesOf(open))
1634
+ }
1635
+ }
1636
+ },
1637
+ [rowAxis, colAxis],
1638
+ )
1639
+
1128
1640
  /** Places one band group for a range in a layer (hidden when the quadrant has no extent). / 層内のレンジ 1 つに帯組を配置 (象限に範囲が無ければ消灯)。 */
1129
1641
  const placeBandGroup = useCallback(
1130
1642
  (group: BandNodes, range: CellRange, ctx: LayerCtx, highlight: HighlightState) => {
@@ -1422,7 +1934,7 @@ export const SelectionOverlay = ({
1422
1934
  node.setAttribute("data-aqsp-fill", "")
1423
1935
  // 生成時のみ display を初期化 — 以後は同値キャッシュが管理 (v0.9 §2.5 census #23)
1424
1936
  node.style.display = "none"
1425
- // 静的クローム床 (分割線先頭 or アクティブ枠 — chromeFloorOf) の手前へ挿入
1937
+ // 静的クローム床 (分割線か外枠の先頭、無ければアクティブ枠 — chromeFloorOf) の手前へ挿入
1426
1938
  // (v0.9 §2.5 census #24: 分割線マウント後に生成された fill が分割線の上へ来る
1427
1939
  // 継ぎ目吸収の破れを塞ぐ)。append だと DOM 順でシンクより上に描かれ、Phase 3 の
1428
1940
  // セル面積エディタが半透明 fill の下に沈む (従来規律は不変)
@@ -1469,6 +1981,9 @@ export const SelectionOverlay = ({
1469
1981
  // アクティブセル枠 (常設ノードは ref 直読み — dragRect と同じ規律)
1470
1982
  applyRect(ctx.nodes.active, rangeToLayerRect(makeRange(state.active, state.active), ctx))
1471
1983
 
1984
+ // 外枠 (v0.18): 層が描くトラックの部分を囲み、範囲が先へ続く辺は開く。枠の無いグリッドはノードが無く何も書かない
1985
+ placeFrame(ctx)
1986
+
1472
1987
  // 強調帯 (v0.8 §2.4): 末尾 BAND_RANGE_CAP レンジに 5 ノードずつ、fill の下。全 off は
1473
1988
  // プール縮退 (ノード除去) で帯 0 = v0.7 恒等
1474
1989
  syncLayerBands(ctx, container, bandRanges, highlight)
@@ -1522,8 +2037,10 @@ export const SelectionOverlay = ({
1522
2037
  // ctx.clampHeight へ。凍結行帯のマーキー帯が帯下限で正しく切られる。横は従来どおり)
1523
2038
  const outTop = clipMarqueeOutset(rect.top)
1524
2039
  const outLeft = clipMarqueeOutset(rect.left)
1525
- const outBottom = clipMarqueeOutset(ctx.clampHeight - (rect.top + rect.height))
1526
- const outRight = clipMarqueeOutset(ctx.clampWidth - (rect.left + rect.width))
2040
+ // 下と右の余白は層が描くセルの端まで (v0.18: 枠のあるグリッドでは表の端で、上と左と同じくアンツを枠の外へ出さない。
2041
+ // 枠の無いグリッドではクランプ範囲と同じ)
2042
+ const outBottom = clipMarqueeOutset(ctx.cells.clampHeight - (rect.top + rect.height))
2043
+ const outRight = clipMarqueeOutset(ctx.cells.clampWidth - (rect.left + rect.width))
1527
2044
  const signature = `${outTop} ${outRight} ${outBottom} ${outLeft}`
1528
2045
  if (signature !== marquee.dataset.aqspOutsetSig) {
1529
2046
  marquee.dataset.aqspOutsetSig = signature
@@ -1688,6 +2205,7 @@ export const SelectionOverlay = ({
1688
2205
  colAxis,
1689
2206
  activeHighlight,
1690
2207
  syncLayerBands,
2208
+ placeFrame,
1691
2209
  editPaintRef,
1692
2210
  placePopoverAnchors,
1693
2211
  ])
@@ -1876,6 +2394,8 @@ export const SelectionOverlay = ({
1876
2394
  const refs = quadRefs[key]
1877
2395
  return (
1878
2396
  <div key={key} className="aqsp-overlay-quad" data-aqsp-overlay-quad={key} {...legacyAttr(key)} style={style} ref={refs.container}>
2397
+ {/* 帯の切り抜き (v0.18): 枠のある象限の最初の子で、層が描くセルの大きさ。帯の組はこの中に入り、fill より下で、表の外へ出ない */}
2398
+ {framed ? <div className="aqsp-band-clip" data-aqsp-band-clip="" ref={refs.bandClip} /> : null}
1879
2399
  {/* 分割線セグメント (v0.9 §2.4 — ADR-24 挿入のみ): scroll 種象限の子に限定
1880
2400
  (構造強制 — 中央帯外に分割線画素が存在できず、overlap 縮退では象限クリップ
1881
2401
  ごと消える)。位置は activeFrame の直前 = 実行時挿入の fill / 帯の後 ⇒
@@ -1890,6 +2410,9 @@ export const SelectionOverlay = ({
1890
2410
  {xk === "s" && effectiveTrailingCols > 0 ? <div className="aqsp-freeze-divider aqsp-freeze-divider-v" data-aqsp-freeze-divider="x-trailing" style={{ right: 0, top: 0, bottom: 0, display: "none" }} ref={refs.dividerXTrailing} /> : null}
1891
2411
  {yk === "s" && effectiveFrozenRows > 0 ? <div className="aqsp-freeze-divider aqsp-freeze-divider-h" data-aqsp-freeze-divider="y-leading" style={{ top: 0, left: 0, right: 0, display: "none" }} ref={refs.dividerYLeading} /> : null}
1892
2412
  {yk === "s" && effectiveTrailingRows > 0 ? <div className="aqsp-freeze-divider aqsp-freeze-divider-h" data-aqsp-freeze-divider="y-trailing" style={{ bottom: 0, left: 0, right: 0, display: "none" }} ref={refs.dividerYTrailing} /> : null}
2413
+ {/* 外枠 (v0.18): 分割線の後・アクティブ枠の前 ⇒ 帯 < fill < 分割線 < 外枠 < activeFrame。分割線と帯の端を覆い、
2414
+ 焦点の印に覆われない。どの象限も同じ枠を自分の写像で描き、象限のクリップが分けて継ぎ目の無い 1 つの枠にする */}
2415
+ {framed ? <div className="aqsp-frame" data-aqsp-frame="" style={{ display: "none" }} ref={refs.frame} /> : null}
1893
2416
  <div className="aqsp-active-frame" data-aqsp-active="" style={{ display: "none" }} ref={refs.active} />
1894
2417
  <div className="aqsp-drag-rect" data-aqsp-drag-rect="" style={{ display: "none" }} ref={refs.dragRect} />
1895
2418
  <div className="aqsp-clip-marquee" data-aqsp-clip-marquee="" style={{ display: "none" }} ref={refs.marquee} />