@aiquants/virtualscroll 3.10.0 → 3.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/logger.d.cts CHANGED
@@ -44,7 +44,7 @@ export interface ILogger {
44
44
  */
45
45
  export declare class Logger implements ILogger {
46
46
  private level;
47
- private prefix;
47
+ private readonly prefix;
48
48
  private impl;
49
49
  /**
50
50
  * @constructor
@@ -82,20 +82,6 @@ export declare class Logger implements ILogger {
82
82
  * @param {ILogger} impl - The new logger implementation.
83
83
  */
84
84
  setImplementation(impl: ILogger): void;
85
- /**
86
- * @method setPrefix
87
- * @description Updates the log prefix for the static instance.
88
- * @description 静的インスタンスのログのプレフィックスを更新します。
89
- * @param {string} prefix - The new prefix.
90
- */
91
- static setPrefix(prefix: string): void;
92
- /**
93
- * @method setPrefix
94
- * @description Updates the log prefix.
95
- * @description ログのプレフィックスを更新します。
96
- * @param {string} prefix - The new prefix.
97
- */
98
- setPrefix(prefix: string): void;
99
85
  /**
100
86
  * @method isEnabled
101
87
  * @description Returns whether the given level would be emitted at the current level (static instance).
@@ -136,7 +122,6 @@ export declare class Logger implements ILogger {
136
122
  private formatMessage;
137
123
  static debug(message?: unknown, ...optionalParams: unknown[]): void;
138
124
  debug(message?: unknown, ...optionalParams: unknown[]): void;
139
- static info(message?: unknown, ...optionalParams: unknown[]): void;
140
125
  info(message?: unknown, ...optionalParams: unknown[]): void;
141
126
  static warn(message?: unknown, ...optionalParams: unknown[]): void;
142
127
  warn(message?: unknown, ...optionalParams: unknown[]): void;
package/dist/logger.d.ts CHANGED
@@ -44,7 +44,7 @@ export interface ILogger {
44
44
  */
45
45
  export declare class Logger implements ILogger {
46
46
  private level;
47
- private prefix;
47
+ private readonly prefix;
48
48
  private impl;
49
49
  /**
50
50
  * @constructor
@@ -82,20 +82,6 @@ export declare class Logger implements ILogger {
82
82
  * @param {ILogger} impl - The new logger implementation.
83
83
  */
84
84
  setImplementation(impl: ILogger): void;
85
- /**
86
- * @method setPrefix
87
- * @description Updates the log prefix for the static instance.
88
- * @description 静的インスタンスのログのプレフィックスを更新します。
89
- * @param {string} prefix - The new prefix.
90
- */
91
- static setPrefix(prefix: string): void;
92
- /**
93
- * @method setPrefix
94
- * @description Updates the log prefix.
95
- * @description ログのプレフィックスを更新します。
96
- * @param {string} prefix - The new prefix.
97
- */
98
- setPrefix(prefix: string): void;
99
85
  /**
100
86
  * @method isEnabled
101
87
  * @description Returns whether the given level would be emitted at the current level (static instance).
@@ -136,7 +122,6 @@ export declare class Logger implements ILogger {
136
122
  private formatMessage;
137
123
  static debug(message?: unknown, ...optionalParams: unknown[]): void;
138
124
  debug(message?: unknown, ...optionalParams: unknown[]): void;
139
- static info(message?: unknown, ...optionalParams: unknown[]): void;
140
125
  info(message?: unknown, ...optionalParams: unknown[]): void;
141
126
  static warn(message?: unknown, ...optionalParams: unknown[]): void;
142
127
  warn(message?: unknown, ...optionalParams: unknown[]): void;
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,oBAAY,QAAQ;IAChB,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;IACT,IAAI,IAAI;CACX;AAED;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACpB,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC5D,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC3D,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC3D,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,G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EAAE,OAAO,EAAE,GAAG,IAAI;IAM3D,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;IAInE,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI;CAK/D"}
@@ -17,6 +17,20 @@ type ValueUpdate = {
17
17
  index: number;
18
18
  value: number;
19
19
  };
20
+ /**
21
+ * The options of a tree read that only looks rows up and never materialises them (`prefixSum`, `get`, `getTotal`,
22
+ * `findIndexAtOrAfter`, `findIndexAtOrBefore`): the read leaves the stored values, the size and `revision` as they are. One
23
+ * frozen value that every lookup passes, so no caller spells the option out. Internal to the package (not in the barrel).
24
+ *
25
+ * 行を引くだけで具現化しない木の読み取り (`prefixSum`・`get`・`getTotal`・`findIndexAtOrAfter`・`findIndexAtOrBefore`) の選択肢。
26
+ * 読み取りは保持する値・要素数・`revision` をそのまま残す。どの引き当ても渡す凍結した 1 つの値で、呼び出し側は選択肢を書き下さない。
27
+ * パッケージの内部用 (バレル非公開)。
28
+ */
29
+ export declare const FENWICK_LOOKUP_ONLY: Readonly<{
30
+ materializeOption: Readonly<{
31
+ materialize: false;
32
+ }>;
33
+ }>;
20
34
  /**
21
35
  * @class FenwickTree
22
36
  * @classdesc Implements a Fenwick Tree (or Binary Indexed Tree).
@@ -73,6 +87,12 @@ export declare class FenwickMapTree {
73
87
  */
74
88
  private valueFn?;
75
89
  private total?;
90
+ /**
91
+ * @private
92
+ * @property {number} revisionCount - The counter behind `revision`: raised by every change of a stored value or of the size.
93
+ * @property {number} revisionCount - `revision` の元の数。保持する値か要素数が変わるたびに上がる。
94
+ */
95
+ private revisionCount;
76
96
  /**
77
97
  * @constructor
78
98
  * @description Initializes the Fenwick Tree.
@@ -291,7 +311,7 @@ export declare class FenwickMapTree {
291
311
  * @description Rebuilds the Fenwick Tree from the existing `baseValue` and `deltas`. This corrects any discrepancies in the tree's internal state, such as those caused by floating-point errors, by recalculating the tree structure and the total sum from the source `deltas`. This method does not re-materialize values from `valueFn`.
292
312
  * @description 既存の `baseValue` と `deltas` から Fenwick Tree を再構築します。これにより、`deltas` からツリー構造と合計値を再計算することで、浮動小数点誤差などによって生じた内部状態の不一致を修正します。このメソッドは `valueFn` から値を再具現化しません。
293
313
  * @param {object} [options] - Optional settings for rebuilding.
294
- * @param {boolean} [options.materialize=false] - If true and `valueFn` is provided, re-materializes all values, recalculating `deltas` and `baseValue`.
314
+ * @param {boolean} [options.materialize=false] - If true and `valueFn` is set, rebuilds from `valueFn` instead: a reset with materialization (`reset(size, valueFn, { materialize: true })`) that re-samples `baseValue`, materializes the initial window (rows 0 to `SAMPLE_COUNT - 1`) and discards every other measured delta. A tree with a uniform value (no `valueFn`) rebuilds from its deltas either way. / true かつ `valueFn` があれば、代わりに `valueFn` から作り直す。具現化付きのリセット (`reset(size, valueFn, { materialize: true })`) で、`baseValue` を標本で決め直し、初期の窓 (行 0〜`SAMPLE_COUNT - 1`) を具現化し、ほかの測った差分はすべて捨てる。一様な値の木 (`valueFn` 無し) はどちらでも差分から作り直す。
295
315
  */
296
316
  rebuildTree(options?: {
297
317
  materialize?: boolean;
@@ -408,6 +428,20 @@ export declare class FenwickMapTree {
408
428
  * @returns {number} The base value. 基準値。
409
429
  */
410
430
  get base(): number;
431
+ /**
432
+ * @description Gets the tree's revision: a counter that rises whenever a value the tree stores or its size changes — an
433
+ * update, a materialization that changes a row, a reset, a resize, a new uniform value or a rebuild — and stays the same
434
+ * otherwise (reads, a materialization that finds the stored value, an update to the same value, a resize to the same size).
435
+ * The tree keeps its identity while its contents change, so a caller that derives anything from the prefix sums (row tops,
436
+ * a rendering range) compares two reads: equal reads mean nothing it derived became stale in between. The counter only
437
+ * rises; how far it rises per change is unspecified.
438
+ * @description 木の版を取得。木が保持する値か要素数が変わるたび (更新・行を変える具現化・リセット・要素数の変更・一様な値の
439
+ * 差し替え・再構築) に上がり、それ以外 (読み取り・保持する値と同じ値を見つけた具現化・同じ値への更新・同じ要素数への変更) では
440
+ * 変わらない数。木は中身が変わっても同一性を保つため、接頭辞和から何か (行の上端・描画範囲) を導く呼び出し側は 2 回の読み取りを
441
+ * 比べ、等しければその間に導いたものは古くなっていない。数は上がるだけで、1 回の変化でいくつ上がるかは決めない。
442
+ * @returns {number} The revision. 版。
443
+ */
444
+ get revision(): number;
411
445
  /**
412
446
  * @method findIndexAtOrAfter
413
447
  * @description Finds the first index where the cumulative sum is greater than or equal to a target value.
@@ -493,4 +527,38 @@ export declare const useFenwickMapTree: (size: number, valueOrFn: number | ((ind
493
527
  resetOnValueFnChange?: boolean;
494
528
  baseValue?: number;
495
529
  }) => FenwickMapTree;
530
+ /**
531
+ * What `useFenwickTreeRevision` returns: the revision the memos that read one tree depend on, and the one way to change that
532
+ * tree outside render so that they see the change.
533
+ *
534
+ * `useFenwickTreeRevision` の戻り値。1 本の木を読む memo が依存する版数と、memo が変化に気付くように描画の外でその木を変える
535
+ * ただ 1 つの方法。
536
+ */
537
+ export type FenwickTreeRevision = {
538
+ /** Advances by one per change made through `change` that moved the tree's revision / `change` を通した変更が木の版を動かすたびに 1 つ進む数 */
539
+ readonly revision: number;
540
+ /** Runs one change of the tree made outside render and returns its result; advances `revision` only when the tree's revision moved / 描画の外で行う木の変更を 1 回実行してその結果を返し、木の版が動いたときだけ `revision` を進める処理 */
541
+ readonly change: <Result>(mutate: () => Result) => Result;
542
+ };
543
+ /**
544
+ * Ties the memos of a component to the contents of a Fenwick tree. The tree keeps its identity while its contents change
545
+ * (`useFenwickMapTree`), so a memo that derives anything from its prefix sums (row tops, a rendering range, the placed
546
+ * columns) cannot see a change through the tree itself, and the total is no signal either: a batch of changes that cancel out
547
+ * leaves it as it was. Every change made outside render goes through `change`, which advances `revision` exactly when the
548
+ * tree's own revision (`FenwickMapTree.revision`) moved, so the next commit recomputes the memos that depend on `revision`,
549
+ * and a change that stores the same values (an update to the value a row already has, a materialisation that finds the stored
550
+ * value) adds no commit. Changes made during render (a reset or a resize by `useFenwickMapTree`) come with new props, which the
551
+ * memos depend on already. Internal to the package (not in the barrel).
552
+ *
553
+ * コンポーネントの memo を Fenwick 木の中身に結び付けるフック。木は中身が変わっても同一性を保つ (`useFenwickMapTree`) ので、
554
+ * 接頭辞和から何か (行の上端・描画範囲・配置した列) を導く memo は木そのものからは変化に気付けず、総和も合図にならない (打ち消し合う
555
+ * 変更の組は総和を変えない)。描画の外の変更はすべて `change` を通し、`change` は木自身の版 (`FenwickMapTree.revision`) が動いたとき
556
+ * ちょうどに `revision` を進める。だから次の確定は `revision` に依存する memo を計算し直し、同じ値を保つ変更 (行が既に持つ値への更新・
557
+ * 保持する値と同じ値を見つけた具現化) は確定を足さない。描画中の変更 (`useFenwickMapTree` のリセットと大きさの変更) は新しい props と
558
+ * 一緒に来るので、memo は既にそれに依存している。パッケージの内部用 (バレル非公開)。
559
+ *
560
+ * @param tree - The tree whose changes the memos must see / memo が変化に気付くべき木
561
+ * @returns The revision and the change runner / 版数と変更の実行関数
562
+ */
563
+ export declare const useFenwickTreeRevision: (tree: FenwickMapTree) => FenwickTreeRevision;
496
564
  export {};
@@ -17,6 +17,20 @@ type ValueUpdate = {
17
17
  index: number;
18
18
  value: number;
19
19
  };
20
+ /**
21
+ * The options of a tree read that only looks rows up and never materialises them (`prefixSum`, `get`, `getTotal`,
22
+ * `findIndexAtOrAfter`, `findIndexAtOrBefore`): the read leaves the stored values, the size and `revision` as they are. One
23
+ * frozen value that every lookup passes, so no caller spells the option out. Internal to the package (not in the barrel).
24
+ *
25
+ * 行を引くだけで具現化しない木の読み取り (`prefixSum`・`get`・`getTotal`・`findIndexAtOrAfter`・`findIndexAtOrBefore`) の選択肢。
26
+ * 読み取りは保持する値・要素数・`revision` をそのまま残す。どの引き当ても渡す凍結した 1 つの値で、呼び出し側は選択肢を書き下さない。
27
+ * パッケージの内部用 (バレル非公開)。
28
+ */
29
+ export declare const FENWICK_LOOKUP_ONLY: Readonly<{
30
+ materializeOption: Readonly<{
31
+ materialize: false;
32
+ }>;
33
+ }>;
20
34
  /**
21
35
  * @class FenwickTree
22
36
  * @classdesc Implements a Fenwick Tree (or Binary Indexed Tree).
@@ -73,6 +87,12 @@ export declare class FenwickMapTree {
73
87
  */
74
88
  private valueFn?;
75
89
  private total?;
90
+ /**
91
+ * @private
92
+ * @property {number} revisionCount - The counter behind `revision`: raised by every change of a stored value or of the size.
93
+ * @property {number} revisionCount - `revision` の元の数。保持する値か要素数が変わるたびに上がる。
94
+ */
95
+ private revisionCount;
76
96
  /**
77
97
  * @constructor
78
98
  * @description Initializes the Fenwick Tree.
@@ -291,7 +311,7 @@ export declare class FenwickMapTree {
291
311
  * @description Rebuilds the Fenwick Tree from the existing `baseValue` and `deltas`. This corrects any discrepancies in the tree's internal state, such as those caused by floating-point errors, by recalculating the tree structure and the total sum from the source `deltas`. This method does not re-materialize values from `valueFn`.
292
312
  * @description 既存の `baseValue` と `deltas` から Fenwick Tree を再構築します。これにより、`deltas` からツリー構造と合計値を再計算することで、浮動小数点誤差などによって生じた内部状態の不一致を修正します。このメソッドは `valueFn` から値を再具現化しません。
293
313
  * @param {object} [options] - Optional settings for rebuilding.
294
- * @param {boolean} [options.materialize=false] - If true and `valueFn` is provided, re-materializes all values, recalculating `deltas` and `baseValue`.
314
+ * @param {boolean} [options.materialize=false] - If true and `valueFn` is set, rebuilds from `valueFn` instead: a reset with materialization (`reset(size, valueFn, { materialize: true })`) that re-samples `baseValue`, materializes the initial window (rows 0 to `SAMPLE_COUNT - 1`) and discards every other measured delta. A tree with a uniform value (no `valueFn`) rebuilds from its deltas either way. / true かつ `valueFn` があれば、代わりに `valueFn` から作り直す。具現化付きのリセット (`reset(size, valueFn, { materialize: true })`) で、`baseValue` を標本で決め直し、初期の窓 (行 0〜`SAMPLE_COUNT - 1`) を具現化し、ほかの測った差分はすべて捨てる。一様な値の木 (`valueFn` 無し) はどちらでも差分から作り直す。
295
315
  */
296
316
  rebuildTree(options?: {
297
317
  materialize?: boolean;
@@ -408,6 +428,20 @@ export declare class FenwickMapTree {
408
428
  * @returns {number} The base value. 基準値。
409
429
  */
410
430
  get base(): number;
431
+ /**
432
+ * @description Gets the tree's revision: a counter that rises whenever a value the tree stores or its size changes — an
433
+ * update, a materialization that changes a row, a reset, a resize, a new uniform value or a rebuild — and stays the same
434
+ * otherwise (reads, a materialization that finds the stored value, an update to the same value, a resize to the same size).
435
+ * The tree keeps its identity while its contents change, so a caller that derives anything from the prefix sums (row tops,
436
+ * a rendering range) compares two reads: equal reads mean nothing it derived became stale in between. The counter only
437
+ * rises; how far it rises per change is unspecified.
438
+ * @description 木の版を取得。木が保持する値か要素数が変わるたび (更新・行を変える具現化・リセット・要素数の変更・一様な値の
439
+ * 差し替え・再構築) に上がり、それ以外 (読み取り・保持する値と同じ値を見つけた具現化・同じ値への更新・同じ要素数への変更) では
440
+ * 変わらない数。木は中身が変わっても同一性を保つため、接頭辞和から何か (行の上端・描画範囲) を導く呼び出し側は 2 回の読み取りを
441
+ * 比べ、等しければその間に導いたものは古くなっていない。数は上がるだけで、1 回の変化でいくつ上がるかは決めない。
442
+ * @returns {number} The revision. 版。
443
+ */
444
+ get revision(): number;
411
445
  /**
412
446
  * @method findIndexAtOrAfter
413
447
  * @description Finds the first index where the cumulative sum is greater than or equal to a target value.
@@ -493,5 +527,39 @@ export declare const useFenwickMapTree: (size: number, valueOrFn: number | ((ind
493
527
  resetOnValueFnChange?: boolean;
494
528
  baseValue?: number;
495
529
  }) => FenwickMapTree;
530
+ /**
531
+ * What `useFenwickTreeRevision` returns: the revision the memos that read one tree depend on, and the one way to change that
532
+ * tree outside render so that they see the change.
533
+ *
534
+ * `useFenwickTreeRevision` の戻り値。1 本の木を読む memo が依存する版数と、memo が変化に気付くように描画の外でその木を変える
535
+ * ただ 1 つの方法。
536
+ */
537
+ export type FenwickTreeRevision = {
538
+ /** Advances by one per change made through `change` that moved the tree's revision / `change` を通した変更が木の版を動かすたびに 1 つ進む数 */
539
+ readonly revision: number;
540
+ /** Runs one change of the tree made outside render and returns its result; advances `revision` only when the tree's revision moved / 描画の外で行う木の変更を 1 回実行してその結果を返し、木の版が動いたときだけ `revision` を進める処理 */
541
+ readonly change: <Result>(mutate: () => Result) => Result;
542
+ };
543
+ /**
544
+ * Ties the memos of a component to the contents of a Fenwick tree. The tree keeps its identity while its contents change
545
+ * (`useFenwickMapTree`), so a memo that derives anything from its prefix sums (row tops, a rendering range, the placed
546
+ * columns) cannot see a change through the tree itself, and the total is no signal either: a batch of changes that cancel out
547
+ * leaves it as it was. Every change made outside render goes through `change`, which advances `revision` exactly when the
548
+ * tree's own revision (`FenwickMapTree.revision`) moved, so the next commit recomputes the memos that depend on `revision`,
549
+ * and a change that stores the same values (an update to the value a row already has, a materialisation that finds the stored
550
+ * value) adds no commit. Changes made during render (a reset or a resize by `useFenwickMapTree`) come with new props, which the
551
+ * memos depend on already. Internal to the package (not in the barrel).
552
+ *
553
+ * コンポーネントの memo を Fenwick 木の中身に結び付けるフック。木は中身が変わっても同一性を保つ (`useFenwickMapTree`) ので、
554
+ * 接頭辞和から何か (行の上端・描画範囲・配置した列) を導く memo は木そのものからは変化に気付けず、総和も合図にならない (打ち消し合う
555
+ * 変更の組は総和を変えない)。描画の外の変更はすべて `change` を通し、`change` は木自身の版 (`FenwickMapTree.revision`) が動いたとき
556
+ * ちょうどに `revision` を進める。だから次の確定は `revision` に依存する memo を計算し直し、同じ値を保つ変更 (行が既に持つ値への更新・
557
+ * 保持する値と同じ値を見つけた具現化) は確定を足さない。描画中の変更 (`useFenwickMapTree` のリセットと大きさの変更) は新しい props と
558
+ * 一緒に来るので、memo は既にそれに依存している。パッケージの内部用 (バレル非公開)。
559
+ *
560
+ * @param tree - The tree whose changes the memos must see / memo が変化に気付くべき木
561
+ * @returns The revision and the change runner / 版数と変更の実行関数
562
+ */
563
+ export declare const useFenwickTreeRevision: (tree: FenwickMapTree) => FenwickTreeRevision;
496
564
  export {};
497
565
  //# sourceMapp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;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM;eAwDhB,CAAC,KAAG,CAAC,GAAG,SAAS;eAqBjB,CAAC,SAAS,CAAC;eA6CX,CAAC,KAAG,OAAO;kBAWR,CAAC;;EA2BrC"}
1
+ {"version":3,"file":"useLruCache.d.ts","sourceRoot":"","sources":["../src/useLruCache.ts"],"names":[],"mappings":"AAsIA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM;eAoDhB,CAAC,KAAG,CAAC,GAAG,SAAS;eAqBjB,CAAC,SAAS,CAAC;eA6CX,CAAC,KAAG,OAAO;kBAWR,CAAC;;EA2BrC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiquants/virtualscroll",
3
- "version": "3.10.0",
3
+ "version": "3.11.1",
4
4
  "description": "High-performance virtual scrolling component for React with variable item heights",
5
5
  "sideEffects": [
6
6
  "**/*.css"
package/src/ScrollBar.tsx CHANGED
@@ -7,7 +7,7 @@ import type { CSSProperties, ReactNode } from "react"
7
7
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react"
8
8
  import { twMerge } from "tailwind-merge"
9
9
  import { snapToDevicePixelGrid, usePaintingDevicePixelRatio } from "./devicePixelGrid.ts"
10
- import { resolveVirtualScrollLabels, type VirtualScrollLabelOverrides, type VirtualScrollLabels, type VirtualScrollLocale } from "./labels.ts"
10
+ import { resolveVirtualScrollLabels, resolveVirtualScrollLocale, type VirtualScrollLabelOverrides, type VirtualScrollLabels, type VirtualScrollLocale } from "./labels.ts"
11
11
  import { Logger } from "./logger.ts"
12
12
  import { capturePointer, releaseCapturedPointer } from "./pointerCapture.ts"
13
13
  import { TapScrollCircle, type TapScrollCircleDragState, type TapScrollCircleHandle, type TapScrollCircleRenderProps } from "./TapScrollCircle.tsx"
@@ -40,6 +40,13 @@ type ArrowAutoRepeatOptions = {
40
40
  canUseArrowButtons: boolean
41
41
  /** Whether arrow buttons are enabled in configuration / 設定で矢印ボタンが有効化されているか */
42
42
  enableArrowButtons: boolean
43
+ /**
44
+ * Whether a focused arrow takes Enter / Space: `false` under the pointer-only signal (`enableArrowButtonTabStops: false`),
45
+ * where the bar is hidden from assistive technology and its arrows answer the pointer only, even when a script focuses one.
46
+ * フォーカスした矢印が Enter / Space を受けるか。ポインタ専用の合図 (`enableArrowButtonTabStops: false`) の下では `false` で、
47
+ * バーは支援技術から隠れ、矢印はスクリプトがフォーカスしてもポインタにだけ応える。
48
+ */
49
+ keyboardOperable: boolean
43
50
  /** Function to reset tap scroll state / タップスクロール状態をリセットする関数 */
44
51
  resetTapScroll: () => void
45
52
  /** Function to scroll by a step / ステップ単位でスクロールする関数 */
@@ -154,8 +161,8 @@ export type ScrollBarProps = {
154
161
  viewportSize: number
155
162
  /** The current scroll position. / 現在のスクロール位置。 */
156
163
  scrollPosition: number
157
- /** A callback function invoked to adjust scroll position. Accepts next position or updater. / スクロール位置を調整するためのコールバック。次位置または更新関数を受け取る。 */
158
- onScroll?: (scrollPosition: number | ((prevPosition: number) => number), prevPosition?: number) => number | undefined
164
+ /** A callback function invoked to adjust scroll position. Accepts next position or updater, and always receives the position the bar resolved the request from. / スクロール位置を調整するためのコールバック。次位置または更新関数と、バーが要求を解いた元の位置 (必ず渡す) を受け取る。 */
165
+ onScroll?: (scrollPosition: number | ((prevPosition: number) => number), prevPosition: number) => number | undefined
159
166
  /** Whether grabbing the scrollbar thumb is allowed. / スクロールバーのつまみ操作を許可するかどうか。 */
160
167
  enableThumbDrag?: boolean
161
168
  /** Whether clicking on the track moves the scrollbar. / スクロールバーのトラッククリック操作を許可するかどうか。 */
@@ -235,10 +242,11 @@ export type ScrollBarProps = {
235
242
  /** The index of the last visible item. / 最後の可視アイテムのインデックス。 */
236
243
  visibleEndIndex?: number
237
244
  /**
238
- * UI chrome locale of the built-in accessible names of the bar, its thumb and its arrows (default `"en"`). An
239
- * unsupported value throws a RangeError at render; no language negotiation happens.
240
- * バー・つまみ・矢印の内蔵アクセシブルネームの UI クロームロケール (既定 `"en"`)。非対応値は描画時に RangeError、
241
- * 言語ネゴシエーションなし。
245
+ * UI chrome locale of the built-in accessible names of the bar, its thumb and its arrows, and of the percentage the bar
246
+ * and the thumb announce as their value text (default `"en"`). An unsupported value throws a RangeError at render; no
247
+ * language negotiation happens.
248
+ * バー・つまみ・矢印の内蔵アクセシブルネームと、バーとつまみが値の文字として知らせる百分率の UI クロームロケール (既定
249
+ * `"en"`)。非対応値は描画時に RangeError、言語ネゴシエーションなし。
242
250
  */
243
251
  locale?: VirtualScrollLocale
244
252
  /**
@@ -255,6 +263,39 @@ export type ScrollBarProps = {
255
263
 
256
264
  /** The minimum size of the scrollbar thumb. / スクロールバーのつまみの最小サイズ。 */
257
265
  const MIN_THUMB_SIZE = 20
266
+
267
+ /**
268
+ * One whole percent: the precision of the value text the bar and its thumb announce (`maximumFractionDigits: 0`), and how far
269
+ * inside the two ends every position between them is held before it is rounded.
270
+ *
271
+ * 1 パーセント。バーとつまみが知らせる値の文字の精度 (`maximumFractionDigits: 0`) で、両端の間のどの位置も丸める前にこれだけ
272
+ * 端の内側へ留める幅。
273
+ */
274
+ const VALUE_TEXT_PERCENT = 0.01
275
+
276
+ /**
277
+ * Resolves the fraction of the scroll range the bar and its thumb announce as their value text (formatted as a whole
278
+ * percent): 0 at the top and for a bar with nothing to scroll, 1 at or past the maximum (a list that shrank before the pane
279
+ * clamped), and every position strictly between them held in [0.01, 0.99], so the rounding never announces an end the list
280
+ * has not reached ("99%" while 999 of 200,000 rows are still below the window, "1%" one pixel below the top).
281
+ *
282
+ * バーとつまみが値の文字として知らせるスクロール範囲の割合 (整数の百分率で書く) を決める処理。先頭とスクロールできないバーは 0、
283
+ * 最大位置とそれを越えた位置 (ペインがクランプする前に縮んだ一覧) は 1、その間のどの位置も [0.01, 0.99] に留めるので、丸めが
284
+ * まだ着いていない端を知らせることはない (200,000 行のうち 999 行が窓の下に残れば "99%"、先頭から 1 px 下なら "1%")。
285
+ *
286
+ * @param scrollPosition - Scroll position (px) / スクロール位置 (px)
287
+ * @param maxScrollPosition - Maximum scroll position (px; 0 when nothing scrolls) / 最大スクロール位置 (px。スクロールできなければ 0)
288
+ * @returns The fraction to format / 書式にかける割合
289
+ */
290
+ const resolveValueTextFraction = (scrollPosition: number, maxScrollPosition: number): number => {
291
+ if (maxScrollPosition <= 0 || scrollPosition <= 0) {
292
+ return 0
293
+ }
294
+ if (scrollPosition >= maxScrollPosition) {
295
+ return 1
296
+ }
297
+ return minmax(scrollPosition / maxScrollPosition, VALUE_TEXT_PERCENT, 1 - VALUE_TEXT_PERCENT)
298
+ }
258
299
  const ARROW_HOLD_DELAY = 250
259
300
  const ARROW_HOLD_INTERVAL = 60
260
301
  const MIN_ARROW_STEP = 20
@@ -407,7 +448,7 @@ const useThumbVisualFeedback = ({ isDragging, isThumbHovered, enableThumbDrag }:
407
448
  *
408
449
  * スクロールバー矢印の自動リピート操作向けハンドラーを提供。
409
450
  */
410
- const useArrowAutoRepeat = ({ canUseArrowButtons, enableArrowButtons, resetTapScroll, scrollByStep }: ArrowAutoRepeatOptions): ArrowAutoRepeatHandlers => {
451
+ const useArrowAutoRepeat = ({ canUseArrowButtons, enableArrowButtons, keyboardOperable, resetTapScroll, scrollByStep }: ArrowAutoRepeatOptions): ArrowAutoRepeatHandlers => {
411
452
  const arrowHoldIntervalRef = useRef<number | null>(null)
412
453
  const arrowHoldTimeoutRef = useRef<number | null>(null)
413
454
  // 長押し中に張るグローバル解除リスナ (disabled 化やウィンドウ blur でボタンに pointerup が届かない保険)。
@@ -463,7 +504,9 @@ const useArrowAutoRepeat = ({ canUseArrowButtons, enableArrowButtons, resetTapSc
463
504
 
464
505
  const handleArrowKeyDown = useCallback(
465
506
  (direction: 1 | -1) => (event: React.KeyboardEvent<HTMLButtonElement>) => {
466
- if (!enableArrowButtons) {
507
+ // ポインタ専用のバーは支援技術から隠れていて、キーボードのスクロールはホストが持つ。スクリプトがフォーカスした矢印でも
508
+ // キーを受けると、隠れた部品がホストのキー操作と重なって一覧を動かす
509
+ if (!(enableArrowButtons && keyboardOperable)) {
467
510
  return
468
511
  }
469
512
  if (event.key === "Enter" || event.key === " " || event.key === "Spacebar") {
@@ -471,7 +514,7 @@ const useArrowAutoRepeat = ({ canUseArrowButtons, enableArrowButtons, resetTapSc
471
514
  scrollByStep(direction)
472
515
  }
473
516
  },
474
- [enableArrowButtons, scrollByStep],
517
+ [enableArrowButtons, keyboardOperable, scrollByStep],
475
518
  )
476
519
 
477
520
  // 矢印ボタンが操作不能 (canUseArrowButtons=false) になったら進行中のリピートを即停止する。
@@ -729,6 +772,8 @@ export const ScrollBar = ({
729
772
  const orientationConfig = useMemo(() => createOrientationConfig(horizontal), [horizontal])
730
773
  const resolvedLabels = useMemo(() => resolveVirtualScrollLabels(locale, labels), [locale, labels])
731
774
  const names = pickScrollBarNames(resolvedLabels, horizontal)
775
+ // 値の文字はスクロールの割合。px の値 (aria-valuenow) は長い一覧で数千万になり、読み上げても位置が分からない
776
+ const valueTextFormat = useMemo(() => new Intl.NumberFormat(resolveVirtualScrollLocale(locale), { style: "percent", maximumFractionDigits: 0 }), [locale])
732
777
  // ホストがキーボードのスクロールを持つと、バーはその経路の重複になる。支援技術にもキーボードにも同じ操作を 2 度見せない
733
778
  const pointerOnly = !enableArrowButtonTabStops
734
779
  const {
@@ -768,6 +813,8 @@ export const ScrollBar = ({
768
813
  // 負値が aria-valuemax へ露出して ARIA 違反 (valuemax < valuemin) になる。644 行の
769
814
  // getScrollBarMetrics と同一のクランプ規約)
770
815
  const maxScrollPosition = Math.max(contentSize - viewportSize, 0)
816
+ // ポインタ専用のバーは支援技術から隠れるので値の文字を持たない
817
+ const valueText = pointerOnly ? undefined : valueTextFormat.format(resolveValueTextFraction(scrollPosition, maxScrollPosition))
771
818
  const effectiveTrackLength = Math.max(trackLength - thumbSize, 0)
772
819
  // scrollPosition が範囲外 (コンテンツ縮小直後の未クランプ 1 フレームや iOS バウンス値) でも
773
820
  // サムがトラック外へはみ出さないよう、レンダー時に [0, effectiveTrackLength] へクランプする。
@@ -1303,6 +1350,7 @@ export const ScrollBar = ({
1303
1350
  const { handleArrowPointerDown, handleArrowPointerUp, handleArrowKeyDown } = useArrowAutoRepeat({
1304
1351
  canUseArrowButtons,
1305
1352
  enableArrowButtons,
1353
+ keyboardOperable: !pointerOnly,
1306
1354
  resetTapScroll,
1307
1355
  scrollByStep,
1308
1356
  })
@@ -1598,6 +1646,7 @@ export const ScrollBar = ({
1598
1646
  aria-valuenow={scrollPosition}
1599
1647
  aria-valuemin={0}
1600
1648
  aria-valuemax={maxScrollPosition}
1649
+ aria-valuetext={valueText}
1601
1650
  aria-orientation={horizontal ? "horizontal" : "vertical"}>
1602
1651
  {(!horizontal || enableHorizontalTapCircle) && scrollBarVisible && tapCircleEnabled && (
1603
1652
  <TapScrollCircle
@@ -1653,6 +1702,7 @@ export const ScrollBar = ({
1653
1702
  aria-valuenow={scrollPosition}
1654
1703
  aria-valuemin={0}
1655
1704
  aria-valuemax={maxScrollPosition}
1705
+ aria-valuetext={valueText}
1656
1706
  aria-disabled={!enableThumbDrag}
1657
1707
  tabIndex={pointerOnly ? undefined : -1}>
1658
1708
  {/* スクロールバーのつまみ(可視部分) */}
@@ -382,6 +382,44 @@ export const ScrollPane = forwardRef<ScrollPaneHandle, ScrollPaneProps>(
382
382
  // 同一内容の警告を繰り返さないための最後の警告キー。
383
383
  const lastViewportWarningRef = useRef<string | null>(null)
384
384
 
385
+ // 0 の帯の警告が読む中身の寸法。自己計測の副作用の依存にすると、中身の寸法が変わるたびに監視を作り直して offsetHeight を
386
+ // 確定の中で読み直し (レイアウトを強いる)、長い一覧の追記のたびにその代価を払う
387
+ const contentSizeRef = useRef(contentSize)
388
+ // 最後の計測が、レイアウトされているのに高さ 0 の帯を見つけたか。中身が後から届いたときの警告は DOM を読まずにこれで決める
389
+ const isZeroBandMeasuredRef = useRef(false)
390
+
391
+ /**
392
+ * Warns once when the last measurement found the content band laid out yet 0 px high while there is content: the host
393
+ * gave the pane no height (the self-measurement's precondition). Reads the last measurement and the content size, never
394
+ * the DOM, so a change of the content size can run it without a forced layout.
395
+ *
396
+ * 最後の計測が、中身があるのにレイアウトされた高さ 0 の帯を見つけたとき、1 度だけ警告する処理 (ホストがペインに高さを与えて
397
+ * いない = 自己計測の前提破り)。最後の計測と中身の寸法だけを読み、DOM は読まないので、中身の寸法の変化から呼んでもレイアウトを
398
+ * 強いない。
399
+ */
400
+ const warnIfHostGivesNoHeight = useCallback(() => {
401
+ if (!isZeroBandMeasuredRef.current || contentSizeRef.current <= 0 || lastViewportWarningRef.current === "zero") {
402
+ return
403
+ }
404
+ lastViewportWarningRef.current = "zero"
405
+ Logger.warn("[ScrollPane] The self-measured viewport is 0px. Give the scroll pane's host element a definite height (e.g. h-full, flex-1 + min-h-0, an explicit px height), or pass viewportSize explicitly.")
406
+ }, [])
407
+
408
+ /**
409
+ * Keeps the content size the zero-band warning reads, and runs that warning when content arrives after a 0 px
410
+ * measurement (content that loads after the pane mounted in a host without a height).
411
+ * 0 の帯の警告が読む中身の寸法を保ち、0 px の計測の後に中身が届いたとき (高さの無いホストでペインの後に読み込まれた中身)
412
+ * にその警告を走らせる副作用。
413
+ *
414
+ * 目的: 中身の寸法を自己計測の依存にせずに警告へ届ける。
415
+ * 依存関係: [contentSize, warnIfHostGivesNoHeight]
416
+ * クリーンアップ: 不要。
417
+ */
418
+ useLayoutEffect(() => {
419
+ contentSizeRef.current = contentSize
420
+ warnIfHostGivesNoHeight()
421
+ }, [contentSize, warnIfHostGivesNoHeight])
422
+
385
423
  /**
386
424
  * Tracks the real height of the content band so the pane can size itself.
387
425
  * ペインが自分の帯の実高さを追跡し、自己サイズ決定できるようにする副作用。
@@ -391,14 +429,18 @@ export const ScrollPane = forwardRef<ScrollPaneHandle, ScrollPaneProps>(
391
429
  * 「計測した数値を書き戻して自分のサイズを変える」フィードバックループが構造的に起こらない。
392
430
  * ルート要素を測ると、消費側がルートへ付けた padding の分だけ帯を過大評価してしまう。
393
431
  *
432
+ * 読み取りはマウントの 1 回だけが同期で (確定の中なのでレイアウトを 1 回強いる。最初の描画を実寸で出すため)、以後は
433
+ * ペインの生涯に 1 つの ResizeObserver の通知から読む (通知はレイアウトの後・描画の前に届くので強制リフローにならない)。
434
+ * 中身の寸法の変化はこの副作用を走らせない。
435
+ *
394
436
  * ❗ **0 の計測は採用しない。** `display: none` のタブに置かれている等でレイアウトされて
395
437
  * いないとき `offsetHeight` は 0 になる。0 を採ると `isScrollable` が偽になり、サイズ調整
396
438
  * エフェクト (§9) が `scrollTo(0)` を発行して**タブ切替でスクロール位置が失われる**。
397
439
  * 0 は「帯が 0」ではなく「まだ測れない」と解釈し、直前の値を保つ。
398
440
  *
399
441
  * 目的: 自己計測モードで帯の高さを State へ反映する。
400
- * 依存関係: [contentSize, isSelfMeasuringViewport]
401
- * クリーンアップ: ResizeObserver を切断する。
442
+ * 依存関係: [isSelfMeasuringViewport, warnIfHostGivesNoHeight]
443
+ * クリーンアップ: ResizeObserver を切断し、0 の帯の記録を消す。
402
444
  */
403
445
  useLayoutEffect(() => {
404
446
  if (!isSelfMeasuringViewport) {
@@ -408,31 +450,32 @@ export const ScrollPane = forwardRef<ScrollPaneHandle, ScrollPaneProps>(
408
450
  if (!element) {
409
451
  return
410
452
  }
411
- // ResizeObserver の通知は layout の後・paint の前に届くため、ここでの読み取りは強制リフローにならない。
412
- // transform: scale(...) の下でもレイアウト px を得るため rect ではなく offsetHeight を使う (整数丸め)。
453
+ /**
454
+ * Reads the content band's height into the measured viewport size, or records a 0 px band for the warning.
455
+ * コンテンツの帯の高さを計測したビューポートの高さへ読み込み、0 px なら警告のために記録する処理。
456
+ */
413
457
  const applyMeasuredSize = () => {
458
+ // transform: scale(...) の下でもレイアウト px を得るため rect ではなく offsetHeight を使う (整数丸め)。
414
459
  const measured = element.offsetHeight
415
460
  if (measured > 0) {
461
+ isZeroBandMeasuredRef.current = false
416
462
  setMeasuredViewportSize((previous) => (previous === measured ? previous : measured))
417
463
  return
418
464
  }
419
465
  // offsetParent が null なら display: none 等で非表示 = 正常な未計測状態なので黙る。
420
466
  // レイアウトされているのに 0 の場合はホストが高さを確定させていない (自己計測の前提破り)。
421
- if (element.offsetParent !== null && contentSize > 0 && lastViewportWarningRef.current !== "zero") {
422
- lastViewportWarningRef.current = "zero"
423
- Logger.warn("[ScrollPane] The self-measured viewport is 0px. Give the scroll pane's host element a definite height (e.g. h-full, flex-1 + min-h-0, an explicit px height), or pass viewportSize explicitly.")
424
- }
467
+ isZeroBandMeasuredRef.current = element.offsetParent !== null
468
+ warnIfHostGivesNoHeight()
425
469
  }
426
470
  applyMeasuredSize()
427
- if (typeof ResizeObserver !== "function") {
428
- return
429
- }
430
- const observer = new ResizeObserver(applyMeasuredSize)
431
- observer.observe(element)
471
+ const observer = typeof ResizeObserver === "function" ? new ResizeObserver(applyMeasuredSize) : null
472
+ observer?.observe(element)
432
473
  return () => {
433
- observer.disconnect()
474
+ observer?.disconnect()
475
+ // 明示の viewportSize へ切り替えた後に中身が届いても、測っていない帯の警告を出さない
476
+ isZeroBandMeasuredRef.current = false
434
477
  }
435
- }, [contentSize, isSelfMeasuringViewport])
478
+ }, [isSelfMeasuringViewport, warnIfHostGivesNoHeight])
436
479
 
437
480
  /**
438
481
  * Publishes the self-measured viewport size to the owner.