@aiquants/spreadsheet 0.16.1 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/README.md +43 -6
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +53 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +4249 -4173
- package/dist/styles/spreadsheet.css +1 -1
- package/dist/styles/spreadsheet.standalone.css +1 -1
- package/package.json +1 -1
- package/src/Spreadsheet.tsx +280 -92
- package/src/header/useHeaderResize.ts +137 -68
- package/src/index.ts +1 -1
- package/src/styles/spreadsheet.css +20 -0
|
@@ -25,7 +25,10 @@
|
|
|
25
25
|
* byte-identical (sign +1, guide `offsetOf + pendingSize`, both writers). Column autofit
|
|
26
26
|
* measures the union `[0, R_eff) ∪ [rowStart, rowEnd] ∪ [rowCount − T_eff, rowCount)` (each
|
|
27
27
|
* filtered by sizeOf > 0 — ADR-21, band counts from a judgment-time `getFrozenSize()` read)
|
|
28
|
-
* and the measured-cell budget gate counts band rows.
|
|
28
|
+
* and the measured-cell budget gate counts band rows. v0.17: autofit measures with the cells' base
|
|
29
|
+
* font, read from the body pane (`fontSourceRef`), so the keyboard twin and the imperative all-rows
|
|
30
|
+
* fit (`autofitColumnsInAllRows` — every row of the named columns, no fan-out, gated at
|
|
31
|
+
* maxOperationCells measured cells) work whether the header bands are shown or not.
|
|
29
32
|
*
|
|
30
33
|
* ヘッダーリサイズ / unhide 機械 (§7 PT-1)。単一フックが両帯を結線 (§7.4 の機械勘定 = 1)。
|
|
31
34
|
* 帯へ wire-once の native capture pointerdown を 1 本 (ストリップはリスナーを持たない —
|
|
@@ -49,7 +52,10 @@
|
|
|
49
52
|
* 即時書込) が予定動く辺 `offsetOf(index) + initialSize − pendingSize` に置く。leading パスは
|
|
50
53
|
* byte 恒等 (符号 +1、ガイド `offsetOf + pendingSize`、両書き手)。列 autofit の測定行集合は
|
|
51
54
|
* 和集合 `[0, R_eff) ∪ [rowStart, rowEnd] ∪ [rowCount − T_eff, rowCount)` (各 sizeOf > 0 —
|
|
52
|
-
* ADR-21。帯件数は判断時 `getFrozenSize()` 読み)、計測セル予算ゲートは帯行を算入する。
|
|
55
|
+
* ADR-21。帯件数は判断時 `getFrozenSize()` 読み)、計測セル予算ゲートは帯行を算入する。v0.17: autofit はセルの
|
|
56
|
+
* 基本の書体を本体ペイン (`fontSourceRef`) から読むので、キーの双子と命令の全部の行の合わせ
|
|
57
|
+
* (`autofitColumnsInAllRows` — 名指した列の全部の行、ファンアウトなし、測るセルは maxOperationCells まで) は
|
|
58
|
+
* 見出しの帯の有無に依らず働く。
|
|
53
59
|
*/
|
|
54
60
|
|
|
55
61
|
import type { VirtualGridHandle } from "@aiquants/virtualscroll"
|
|
@@ -86,6 +92,12 @@ type UseHeaderResizeParams = {
|
|
|
86
92
|
enabled: boolean
|
|
87
93
|
colBandRef: RefObject<HTMLElement | null>
|
|
88
94
|
rowBandRef: RefObject<HTMLElement | null>
|
|
95
|
+
/**
|
|
96
|
+
* The element whose computed font is the cells' base font (the body pane, the cells' parent): autofit measures with it,
|
|
97
|
+
* so it works whether the header bands are shown or not.
|
|
98
|
+
* 計算済みの書体がセルの基本の書体になる要素 (セルの親の本体ペイン)。autofit はこれで測るので、見出しの帯の有無に依らない。
|
|
99
|
+
*/
|
|
100
|
+
fontSourceRef: RefObject<HTMLElement | null>
|
|
89
101
|
colAxis: AxisModel
|
|
90
102
|
rowAxis: AxisModel
|
|
91
103
|
viewStore: ViewStore
|
|
@@ -119,25 +131,25 @@ type UseHeaderResizeParams = {
|
|
|
119
131
|
}
|
|
120
132
|
|
|
121
133
|
/**
|
|
122
|
-
* The canvas `font` shorthand of a painted format over the
|
|
123
|
-
* bold / pt size (× 4/3 px, like cellPaint) / family from the format, the
|
|
124
|
-
* otherwise. Interned per format object (the paint intern keeps one object per distinct
|
|
134
|
+
* The canvas `font` shorthand of a painted format over the cells' base computed style (the body
|
|
135
|
+
* pane's): italic / bold / pt size (× 4/3 px, like cellPaint) / family from the format, the base
|
|
136
|
+
* values otherwise. Interned per format object (the paint intern keeps one object per distinct
|
|
125
137
|
* painted format, so this is one string per distinct font).
|
|
126
|
-
* 塗り書式の canvas `font` 短縮形 (
|
|
127
|
-
* cellPaint と同式) / フォント族を重ねる)。書式 object 毎に intern (塗り intern が書式毎に
|
|
128
|
-
*
|
|
138
|
+
* 塗り書式の canvas `font` 短縮形 (セルの基本の computed style — 本体ペインのもの — の上に italic / bold /
|
|
139
|
+
* pt サイズ (× 4/3 px — cellPaint と同式) / フォント族を重ねる)。書式 object 毎に intern (塗り intern が書式毎に
|
|
140
|
+
* 1 object を保つので、異なりフォント毎に 1 文字列)。
|
|
129
141
|
*/
|
|
130
|
-
const fontKeyOf = (painted: CellFormat, fontKeys: WeakMap<CellFormat, string>,
|
|
142
|
+
const fontKeyOf = (painted: CellFormat, fontKeys: WeakMap<CellFormat, string>, baseStyle: Pick<CSSStyleDeclaration, "fontStyle" | "fontWeight" | "fontSize" | "fontFamily">): string => {
|
|
131
143
|
const cached = fontKeys.get(painted)
|
|
132
144
|
if (cached !== undefined) {
|
|
133
145
|
return cached
|
|
134
146
|
}
|
|
135
147
|
// 真偽値は厳密 true のみ (fail-soft — cellPaint と同じ判定)
|
|
136
|
-
const style = painted.italic === true ? "italic" :
|
|
137
|
-
const weight = painted.bold === true ? "bold" :
|
|
138
|
-
// pt は cellPaint と同じ × 4/3 で px へ (非有限 /
|
|
139
|
-
const size = typeof painted.fontSize === "number" && Number.isFinite(painted.fontSize) && painted.fontSize > 0 ? `${(painted.fontSize * 4) / 3}px` :
|
|
140
|
-
const family = typeof painted.fontFamily === "string" && painted.fontFamily !== "" ? painted.fontFamily :
|
|
148
|
+
const style = painted.italic === true ? "italic" : baseStyle.fontStyle
|
|
149
|
+
const weight = painted.bold === true ? "bold" : baseStyle.fontWeight
|
|
150
|
+
// pt は cellPaint と同じ × 4/3 で px へ (非有限 / 非正は基本の書体の既定のまま)
|
|
151
|
+
const size = typeof painted.fontSize === "number" && Number.isFinite(painted.fontSize) && painted.fontSize > 0 ? `${(painted.fontSize * 4) / 3}px` : baseStyle.fontSize
|
|
152
|
+
const family = typeof painted.fontFamily === "string" && painted.fontFamily !== "" ? painted.fontFamily : baseStyle.fontFamily
|
|
141
153
|
const font = `${style} ${weight} ${size} ${family}`
|
|
142
154
|
fontKeys.set(painted, font)
|
|
143
155
|
return font
|
|
@@ -184,6 +196,14 @@ export type HeaderResizeMachine = SelectionEngine & {
|
|
|
184
196
|
stepTrack: (axis: "row" | "col", index: number, direction: 1 | -1) => boolean
|
|
185
197
|
/** Fits column `index` to its content, as the strip double-click does (false when renderCell is set). / 列 `index` を中身に合わせる (ストリップのダブルクリックと同じ。renderCell があれば false)。 */
|
|
186
198
|
autofitColumn: (index: number) => boolean
|
|
199
|
+
/**
|
|
200
|
+
* Fits the listed columns to the widest text of every row (no fan-out; hidden columns keep their width), gated at
|
|
201
|
+
* maxOperationCells measured cells (false after onOperationRejected; false when renderCell is set or no font source is
|
|
202
|
+
* mounted).
|
|
203
|
+
* 名指した列を全部の行で最も広い文字に合わせる (ファンアウトなし。隠した列は幅を保つ)。測るセルは maxOperationCells まで
|
|
204
|
+
* (超えると onOperationRejected の後に false。renderCell があるか書体の元が未装着なら false)。
|
|
205
|
+
*/
|
|
206
|
+
autofitColumnsInAllRows: (columns: readonly number[]) => boolean
|
|
187
207
|
}
|
|
188
208
|
|
|
189
209
|
/**
|
|
@@ -323,44 +343,28 @@ export const useHeaderResize = (params: UseHeaderResizeParams): HeaderResizeMach
|
|
|
323
343
|
[collectTargets, applyEntries],
|
|
324
344
|
)
|
|
325
345
|
|
|
326
|
-
/**
|
|
327
|
-
|
|
328
|
-
|
|
346
|
+
/**
|
|
347
|
+
* The measuring core of both autofit entries: fits `targets` to the widest painted text of `measuredRows` (per-column
|
|
348
|
+
* canvas measurement in each cell's painted font over the cells' base font from fontSourceRef, bucketed by font key),
|
|
349
|
+
* gated at `measureLimit` measured cells. No row to measure, no 2d context (jsdom) or an all-empty column set changes
|
|
350
|
+
* nothing and still counts as a run (true).
|
|
351
|
+
* 両方の autofit の入口が共有する計測の芯。`targets` を `measuredRows` の最も広い塗りの文字に合わせる (fontSourceRef のセルの
|
|
352
|
+
* 基本の書体の上で、セルごとの塗りの書体で列ごとに canvas で測り、書体の鍵で束ねる)。測るセルは `measureLimit` まで。測る行が無い・
|
|
353
|
+
* 2d の文脈が無い (jsdom)・全部が空の列は何も変えずに走ったものとする (true)。
|
|
354
|
+
*
|
|
355
|
+
* @param targets - The columns to fit. 合わせる列。
|
|
356
|
+
* @param measuredRows - The rows to measure, each with a size above 0. 測る行 (どれも大きさ 0 より大きい)。
|
|
357
|
+
* @param measureLimit - The most measured cells. 測るセルの上限。
|
|
358
|
+
* @param pressedIndex - The pressed track for the §7.2 zero-guard, or null for an imperative fit. §7.2 の 0 化ガードの押下トラック (命令の合わせでは null)。
|
|
359
|
+
* @returns Whether the fit ran (false after a refusal or without a mounted font source). 走ったか (拒んだとき・書体の元が未装着なら false)。
|
|
360
|
+
*/
|
|
361
|
+
const fitColumns = useCallback(
|
|
362
|
+
(targets: readonly number[], measuredRows: readonly number[], measureLimit: number, pressedIndex: number | null): boolean => {
|
|
329
363
|
const p = paramsRef.current
|
|
330
|
-
const
|
|
331
|
-
if (
|
|
364
|
+
const fontSource = p.fontSourceRef.current
|
|
365
|
+
if (fontSource === null) {
|
|
332
366
|
return false
|
|
333
367
|
}
|
|
334
|
-
// 帯件数は判断時ハンドル読み (ADR-21 / ADR-19 の判断時規律 — getFrozenSize().rows /
|
|
335
|
-
// .trailingRows はエンジンクランプ済み実効値)。装着前 (null) は帯集合なし — 測定集合が
|
|
336
|
-
// 窓のみに縮む v0.8 恒等の能力分岐 (値代替フォールバックではない)
|
|
337
|
-
const handle = p.handleRef.current
|
|
338
|
-
const frozenSize = handle === null ? null : handle.getFrozenSize()
|
|
339
|
-
const leadingRows = frozenSize === null ? 0 : frozenSize.rows
|
|
340
|
-
const trailingRows = frozenSize === null ? 0 : frozenSize.trailingRows
|
|
341
|
-
// 測定行集合 = [0, R_eff) ∪ [rowStart, rowEnd] ∪ [rowCount − T_eff, rowCount) の順序付き
|
|
342
|
-
// 和集合 (ADR-21 — v0.9 §4.14)。幅 0 行は計測しない (sizeOf > 0 フィルタ)、重複は Set で
|
|
343
|
-
// 去重 (R = T = 0 は窓のみ = v0.8 恒等)
|
|
344
|
-
const { rowStart, rowEnd } = p.viewStore.get()
|
|
345
|
-
const last = Math.min(rowEnd, p.rowAxis.count - 1)
|
|
346
|
-
const measuredRows: number[] = []
|
|
347
|
-
const seen = new Set<number>()
|
|
348
|
-
const pushRow = (row: number): void => {
|
|
349
|
-
if (!seen.has(row) && p.rowAxis.sizeOf(row) > 0) {
|
|
350
|
-
seen.add(row)
|
|
351
|
-
measuredRows.push(row)
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
for (let row = 0; row < leadingRows; row += 1) {
|
|
355
|
-
pushRow(row)
|
|
356
|
-
}
|
|
357
|
-
for (let row = rowStart; row <= last; row += 1) {
|
|
358
|
-
pushRow(row)
|
|
359
|
-
}
|
|
360
|
-
// 末尾帯の開始 = rowCount − T_eff (エンジンクランプ済みのため常に ≥ R_eff ≥ 0 — §1.2)
|
|
361
|
-
for (let row = p.rowAxis.count - trailingRows; row < p.rowAxis.count; row += 1) {
|
|
362
|
-
pushRow(row)
|
|
363
|
-
}
|
|
364
368
|
// 計測対象の可視行がゼロ (全帯 + 窓が非表示) は no-op — Excel も計測対象
|
|
365
369
|
// なしでは幅を変えない (0 計測 → 9px 潰しの破壊を作らない。R1(B) 所見)
|
|
366
370
|
// 測る行が無い / 測る書体が無い / 全空列は「当てるものが無い」実行で、拒否ではない (true)
|
|
@@ -368,30 +372,28 @@ export const useHeaderResize = (params: UseHeaderResizeParams): HeaderResizeMach
|
|
|
368
372
|
return true
|
|
369
373
|
}
|
|
370
374
|
// 上限ゲートは計測セル数単位 (§7.3 — トラック数単位では 16k 列 × 可視 40 行が素通り
|
|
371
|
-
// する)
|
|
372
|
-
// 帯行も算入する (ADR-21 — measuredRows が帯行を含む)
|
|
375
|
+
// する)。帯行も算入する (ADR-21 — measuredRows が帯行を含む)
|
|
373
376
|
const measuredCells = targets.length * measuredRows.length
|
|
374
|
-
const measureLimit = Math.floor(p.maxOperationCells / AUTOFIT_MEASURE_DIVISOR)
|
|
375
377
|
if (measuredCells > measureLimit) {
|
|
376
378
|
p.onOperationRejected?.("resize", measuredCells, "limit")
|
|
377
379
|
return false
|
|
378
380
|
}
|
|
379
|
-
// canvas 生成 + computed font
|
|
381
|
+
// canvas 生成 + computed font 取得は合わせ 1 回につき 1 度 (§7.3)。font は
|
|
380
382
|
// ロングハンド合成の単一経路 (Firefox は font ショートハンドの computed 値を空で
|
|
381
383
|
// 返すため、合成だけが全ブラウザで決定的)
|
|
382
384
|
const context = document.createElement("canvas").getContext("2d")
|
|
383
385
|
if (context === null) {
|
|
384
386
|
return true // 実ブラウザでは常に成立 (jsdom は 2d 未実装 — 計測面は E2E がピン)
|
|
385
387
|
}
|
|
386
|
-
const
|
|
387
|
-
// 既定フォント (書式なしセル) —
|
|
388
|
-
const baseFont = `${
|
|
388
|
+
const baseStyle = getComputedStyle(fontSource)
|
|
389
|
+
// 既定フォント (書式なしセル) — 本体ペインの computed style のロングハンド合成 (セルは本体ペインの書体を継ぐ)
|
|
390
|
+
const baseFont = `${baseStyle.fontStyle} ${baseStyle.fontWeight} ${baseStyle.fontSize} ${baseStyle.fontFamily}`
|
|
389
391
|
// 見出しの行は書式でなくスタイルシートが太くする — 測る書体もセルと同じ太さにする。スタイルシートが読まれていなければ
|
|
390
|
-
//
|
|
391
|
-
const headerWeight =
|
|
392
|
-
const headerStyle = { fontStyle:
|
|
392
|
+
// 見出しの行も本体と同じ太さで描かれるので、本体の太さがそのまま実際の描画の値
|
|
393
|
+
const headerWeight = baseStyle.getPropertyValue("--_aqsp-header-row-font-weight").trim()
|
|
394
|
+
const headerStyle = { fontStyle: baseStyle.fontStyle, fontWeight: headerWeight === "" ? baseStyle.fontWeight : headerWeight, fontSize: baseStyle.fontSize, fontFamily: baseStyle.fontFamily }
|
|
393
395
|
const headerFont = `${headerStyle.fontStyle} ${headerStyle.fontWeight} ${headerStyle.fontSize} ${headerStyle.fontFamily}`
|
|
394
|
-
// CF は幅に効く規則 (bold / italic 設定) と stopIfTrue の障壁だけを 1
|
|
396
|
+
// CF は幅に効く規則 (bold / italic 設定) と stopIfTrue の障壁だけを 1 回の合わせで 1 回抽出し列毎に
|
|
395
397
|
// スライスする (実測 155 → 56 ms)。障壁を残すため走査は塗りと同じ位置で止まり bold / italic が
|
|
396
398
|
// 厳密一致する。getConditionalFormats は getCellFormat を要する (root がマウント時に保証)
|
|
397
399
|
const cfRules = p.adapter.getConditionalFormats === undefined ? null : widthRelevantRules(p.adapter.getConditionalFormats())
|
|
@@ -411,7 +413,7 @@ export const useHeaderResize = (params: UseHeaderResizeParams): HeaderResizeMach
|
|
|
411
413
|
// 塗り書式 (base ⊕ 幅に効く CF) — raw は既読なので thunk は再読しない
|
|
412
414
|
const painted = p.adapter.getCellFormat === undefined ? undefined : resolvePaintedFormat(p.adapter, colIndex, memo, row, col, () => raw)
|
|
413
415
|
const isHeaderRow = row < p.headerRows
|
|
414
|
-
const font = painted === undefined ? (isHeaderRow ? headerFont : baseFont) : isHeaderRow ? fontKeyOf(painted, headerFontKeys, headerStyle) : fontKeyOf(painted, fontKeys,
|
|
416
|
+
const font = painted === undefined ? (isHeaderRow ? headerFont : baseFont) : isHeaderRow ? fontKeyOf(painted, headerFontKeys, headerStyle) : fontKeyOf(painted, fontKeys, baseStyle)
|
|
415
417
|
const text = formatCellValue(raw, painted === undefined ? undefined : painted.value)
|
|
416
418
|
const bucket = buckets.get(font)
|
|
417
419
|
if (bucket === undefined) {
|
|
@@ -446,7 +448,51 @@ export const useHeaderResize = (params: UseHeaderResizeParams): HeaderResizeMach
|
|
|
446
448
|
}
|
|
447
449
|
return applyEntries("col", entries, pressedIndex)
|
|
448
450
|
},
|
|
449
|
-
[
|
|
451
|
+
[applyEntries],
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
/** Column autofit (§7.3 / v0.8 §4.2.10 / ADR-21): per-column canvas measurement over the union of both frozen bands and the visible window — `[0, R_eff) ∪ [rowStart, rowEnd] ∪ [rowCount − T_eff, rowCount)`, each filtered by sizeOf > 0 — in each cell's painted font, bucketed by font key. / 列 autofit (§7.3 / v0.8 §4.2.10 / ADR-21): 両凍結帯 + 可視ウィンドウの和集合 `[0, R_eff) ∪ [rowStart, rowEnd] ∪ [rowCount − T_eff, rowCount)` (各 sizeOf > 0) をセルの塗りフォントで計測、フォントキーでバケット化。 */
|
|
455
|
+
const autofitColumns = useCallback(
|
|
456
|
+
(pressedIndex: number): boolean => {
|
|
457
|
+
const p = paramsRef.current
|
|
458
|
+
const targets = collectTargets("col", pressedIndex)
|
|
459
|
+
if (targets === null) {
|
|
460
|
+
return false
|
|
461
|
+
}
|
|
462
|
+
// 帯件数は判断時ハンドル読み (ADR-21 / ADR-19 の判断時規律 — getFrozenSize().rows /
|
|
463
|
+
// .trailingRows はエンジンクランプ済み実効値)。装着前 (null) は帯集合なし — 測定集合が
|
|
464
|
+
// 窓のみに縮む v0.8 恒等の能力分岐 (値代替フォールバックではない)
|
|
465
|
+
const handle = p.handleRef.current
|
|
466
|
+
const frozenSize = handle === null ? null : handle.getFrozenSize()
|
|
467
|
+
const leadingRows = frozenSize === null ? 0 : frozenSize.rows
|
|
468
|
+
const trailingRows = frozenSize === null ? 0 : frozenSize.trailingRows
|
|
469
|
+
// 測定行集合 = [0, R_eff) ∪ [rowStart, rowEnd] ∪ [rowCount − T_eff, rowCount) の順序付き
|
|
470
|
+
// 和集合 (ADR-21 — v0.9 §4.14)。幅 0 行は計測しない (sizeOf > 0 フィルタ)、重複は Set で
|
|
471
|
+
// 去重 (R = T = 0 は窓のみ = v0.8 恒等)
|
|
472
|
+
const { rowStart, rowEnd } = p.viewStore.get()
|
|
473
|
+
const last = Math.min(rowEnd, p.rowAxis.count - 1)
|
|
474
|
+
const measuredRows: number[] = []
|
|
475
|
+
const seen = new Set<number>()
|
|
476
|
+
const pushRow = (row: number): void => {
|
|
477
|
+
if (!seen.has(row) && p.rowAxis.sizeOf(row) > 0) {
|
|
478
|
+
seen.add(row)
|
|
479
|
+
measuredRows.push(row)
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
for (let row = 0; row < leadingRows; row += 1) {
|
|
483
|
+
pushRow(row)
|
|
484
|
+
}
|
|
485
|
+
for (let row = rowStart; row <= last; row += 1) {
|
|
486
|
+
pushRow(row)
|
|
487
|
+
}
|
|
488
|
+
// 末尾帯の開始 = rowCount − T_eff (エンジンクランプ済みのため常に ≥ R_eff ≥ 0 — §1.2)
|
|
489
|
+
for (let row = p.rowAxis.count - trailingRows; row < p.rowAxis.count; row += 1) {
|
|
490
|
+
pushRow(row)
|
|
491
|
+
}
|
|
492
|
+
// 上限は autofit 専用の低い係数 (§13 (e) の設計返却 — 実測根拠は定数 docstring)。帯行も算入する (ADR-21)
|
|
493
|
+
return fitColumns(targets, measuredRows, Math.floor(p.maxOperationCells / AUTOFIT_MEASURE_DIVISOR), pressedIndex)
|
|
494
|
+
},
|
|
495
|
+
[collectTargets, fitColumns],
|
|
450
496
|
)
|
|
451
497
|
|
|
452
498
|
const stepTrack = useCallback(
|
|
@@ -473,20 +519,42 @@ export const useHeaderResize = (params: UseHeaderResizeParams): HeaderResizeMach
|
|
|
473
519
|
const autofitColumn = useCallback(
|
|
474
520
|
(index: number): boolean => {
|
|
475
521
|
const p = paramsRef.current
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
if (!p.autofitEnabled || band === null) {
|
|
522
|
+
// renderCell のカスタム DOM は measureText で測れない (帯のダブルクリックと同じ逸脱)。書体の元の未装着は芯が false を返す
|
|
523
|
+
if (!p.autofitEnabled) {
|
|
479
524
|
return false
|
|
480
525
|
}
|
|
481
526
|
// 隠れた列は隠れたまま (戻すのは再表示だけ) — 走ったが何も変えない
|
|
482
527
|
if (p.colAxis.sizeOf(index) === 0) {
|
|
483
528
|
return true
|
|
484
529
|
}
|
|
485
|
-
return autofitColumns(
|
|
530
|
+
return autofitColumns(index)
|
|
486
531
|
},
|
|
487
532
|
[autofitColumns],
|
|
488
533
|
)
|
|
489
534
|
|
|
535
|
+
const autofitColumnsInAllRows = useCallback(
|
|
536
|
+
(columns: readonly number[]): boolean => {
|
|
537
|
+
const p = paramsRef.current
|
|
538
|
+
if (!p.autofitEnabled) {
|
|
539
|
+
return false
|
|
540
|
+
}
|
|
541
|
+
// 隠れた列は隠れたまま (戻すのは再表示だけ)。重複は 1 回
|
|
542
|
+
const targets = [...new Set(columns)].filter((col) => p.colAxis.sizeOf(col) > 0)
|
|
543
|
+
if (targets.length === 0) {
|
|
544
|
+
return true
|
|
545
|
+
}
|
|
546
|
+
const measuredRows: number[] = []
|
|
547
|
+
for (let row = 0; row < p.rowAxis.count; row += 1) {
|
|
548
|
+
if (p.rowAxis.sizeOf(row) > 0) {
|
|
549
|
+
measuredRows.push(row)
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
// ホストが一度だけ呼ぶ合わせなので、上限は操作の予算そのもの (画面の操作の 1/4 の係数は打鍵ごとの応答のためのもの)
|
|
553
|
+
return fitColumns(targets, measuredRows, p.maxOperationCells, null)
|
|
554
|
+
},
|
|
555
|
+
[fitColumns],
|
|
556
|
+
)
|
|
557
|
+
|
|
490
558
|
const { enabled, colBandRef, rowBandRef } = params
|
|
491
559
|
useEffect(() => {
|
|
492
560
|
const colBand = colBandRef.current
|
|
@@ -680,7 +748,7 @@ export const useHeaderResize = (params: UseHeaderResizeParams): HeaderResizeMach
|
|
|
680
748
|
}
|
|
681
749
|
return
|
|
682
750
|
}
|
|
683
|
-
autofitColumns(
|
|
751
|
+
autofitColumns(hit.index)
|
|
684
752
|
}
|
|
685
753
|
|
|
686
754
|
const onLostPointerCapture = (event: PointerEvent) => {
|
|
@@ -717,6 +785,7 @@ export const useHeaderResize = (params: UseHeaderResizeParams): HeaderResizeMach
|
|
|
717
785
|
() => ({
|
|
718
786
|
stepTrack,
|
|
719
787
|
autofitColumn,
|
|
788
|
+
autofitColumnsInAllRows,
|
|
720
789
|
isDragging: () => draggingRef.current,
|
|
721
790
|
// リサイズ / unhide は選択矩形を配送しない — 配送モードは常に加算
|
|
722
791
|
getDragMode: (): "add" | "subtract" | "point" => "add",
|
|
@@ -728,6 +797,6 @@ export const useHeaderResize = (params: UseHeaderResizeParams): HeaderResizeMach
|
|
|
728
797
|
},
|
|
729
798
|
cancelDrag: cleanupDrag,
|
|
730
799
|
}),
|
|
731
|
-
[cleanupDrag, stepTrack, autofitColumn],
|
|
800
|
+
[cleanupDrag, stepTrack, autofitColumn, autofitColumnsInAllRows],
|
|
732
801
|
)
|
|
733
802
|
}
|
package/src/index.ts
CHANGED
|
@@ -122,5 +122,5 @@ export { NoteTip, type NoteTipProps } from "./popover/NoteTip.tsx"
|
|
|
122
122
|
// PopoverContext.anchorRect の型 (層座標系の矩形) — 配置エンジン placePopover 本体は非公開のまま
|
|
123
123
|
export type { PopoverRect } from "./popover/placement.ts"
|
|
124
124
|
export type { CommentPopoverContext, LinkPopoverContext, ListPopoverContext, MessagePopoverContext, NotePopoverContext, NoteTipContext, PopoverContext, PopoverKind, PopoverOverrides } from "./popover/usePopovers.ts"
|
|
125
|
-
export { DEFAULT_CUSTOM_COLORS, type ScrollToCellOptions, Spreadsheet, type SpreadsheetHandle, type SpreadsheetProps } from "./Spreadsheet.tsx"
|
|
125
|
+
export { DEFAULT_CUSTOM_COLORS, type ScrollToCellOptions, Spreadsheet, type SpreadsheetContentSize, type SpreadsheetHandle, type SpreadsheetProps } from "./Spreadsheet.tsx"
|
|
126
126
|
export type { SelectionState } from "./selection/selectionState.ts"
|
|
@@ -113,6 +113,26 @@
|
|
|
113
113
|
transform-origin: 0 0;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
/* 見出し (列の記号・行の番号・角) を出さないグリッド (headings={false}): 格子の 2 本の帯を 0 にし、本体を根の左上から始める */
|
|
117
|
+
.aqsp-root[data-aqsp-headings-hidden] .aqsp-zoom {
|
|
118
|
+
grid-template-columns: 0 minmax(0, 1fr);
|
|
119
|
+
grid-template-rows: 0 minmax(0, 1fr);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/*
|
|
123
|
+
* キーの移動で選んだセルをページの中で見せる印 (位置と大きさは revealCellInPage が書く)。根の直下でズームの包みの外に置き、見えず
|
|
124
|
+
* 押せない。scrollIntoView は可視性に依らず箱の位置へスクロールする
|
|
125
|
+
*/
|
|
126
|
+
.aqsp-reveal {
|
|
127
|
+
position: absolute;
|
|
128
|
+
top: 0;
|
|
129
|
+
left: 0;
|
|
130
|
+
width: 0;
|
|
131
|
+
height: 0;
|
|
132
|
+
pointer-events: none;
|
|
133
|
+
visibility: hidden;
|
|
134
|
+
}
|
|
135
|
+
|
|
116
136
|
.aqsp-corner {
|
|
117
137
|
grid-column: 1;
|
|
118
138
|
grid-row: 1;
|