@aiquants/virtualscroll 3.9.1 → 3.10.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 +114 -0
- package/README.md +95 -29
- package/dist/ScrollBar.d.cts +41 -35
- package/dist/ScrollBar.d.ts +41 -35
- package/dist/ScrollBar.d.ts.map +1 -1
- package/dist/ScrollPane.d.cts +12 -14
- package/dist/ScrollPane.d.ts +12 -14
- package/dist/ScrollPane.d.ts.map +1 -1
- package/dist/VirtualGrid.d.cts +6 -6
- package/dist/VirtualGrid.d.ts +6 -6
- package/dist/VirtualGrid.d.ts.map +1 -1
- package/dist/VirtualScroll.d.cts +72 -23
- package/dist/VirtualScroll.d.ts +72 -23
- package/dist/VirtualScroll.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2048 -2025
- package/dist/labels.d.cts +38 -7
- package/dist/labels.d.ts +38 -7
- package/dist/labels.d.ts.map +1 -1
- package/dist/styles/virtualscroll.css +1 -1
- package/dist/styles/virtualscroll.standalone.css +1 -1
- package/dist/utils.d.cts +14 -0
- package/dist/utils.d.ts +14 -0
- package/dist/utils.d.ts.map +1 -1
- package/package.json +5 -2
- package/src/ScrollBar.tsx +91 -49
- package/src/ScrollPane.tsx +12 -14
- package/src/VirtualGrid.tsx +6 -6
- package/src/VirtualScroll.tsx +235 -116
- package/src/labels.ts +58 -7
- package/src/styles/virtualscroll.css +51 -3
- package/src/utils.ts +15 -0
package/src/labels.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module labels
|
|
3
|
-
* @description Built-in UI chrome label catalog of the package. Covers exactly the
|
|
4
|
-
* the components render on their own: the ScrollBar
|
|
3
|
+
* @description Built-in UI chrome label catalog of the package. Covers exactly the eleven strings
|
|
4
|
+
* the components render on their own: the ScrollBar accessible names (per orientation, the two
|
|
5
|
+
* arrows, the `role="scrollbar"` bar and its `role="slider"` thumb), the VirtualScroll
|
|
5
6
|
* scroll-to-edge pill texts and the empty-state text. Live-region wording stays consumer-owned
|
|
6
7
|
* (`liveRegion.format` / `liveRegion.buildMessage`) and is not part of this catalog. The default
|
|
7
8
|
* locale is `"en"`; `"ja"` is the second locale. No language negotiation happens here: hosts map
|
|
8
9
|
* `navigator.language` (or anything else) to a supported locale themselves.
|
|
9
10
|
*
|
|
10
|
-
* @description パッケージ内蔵の UI クローム文言カタログ。コンポーネント自身が描画する
|
|
11
|
-
* (ScrollBar
|
|
11
|
+
* @description パッケージ内蔵の UI クローム文言カタログ。コンポーネント自身が描画する 11 文言
|
|
12
|
+
* (向きごとの ScrollBar のアクセシブルネーム — 矢印 2 個・`role="scrollbar"` のバー・その `role="slider"` の
|
|
13
|
+
* つまみ —、VirtualScroll の端スクロールピル文言、空状態文言) だけを対象とし、
|
|
12
14
|
* ライブリージョンの文言は利用側の所有 (`liveRegion.format` / `liveRegion.buildMessage`) で
|
|
13
15
|
* 本カタログの対象外。既定ロケールは `"en"`、第 2 ロケールは `"ja"`。言語ネゴシエーションは行わず、
|
|
14
16
|
* `navigator.language` 等から対応ロケールへの対応付けはホスト側の責務。
|
|
@@ -53,6 +55,30 @@ export type VirtualScrollLabels = {
|
|
|
53
55
|
* 横 ScrollBar 終端 (右) 矢印ボタンの aria-label。
|
|
54
56
|
*/
|
|
55
57
|
readonly scrollRight: string
|
|
58
|
+
/**
|
|
59
|
+
* aria-label of the vertical ScrollBar root (`role="scrollbar"`). Assistive technology appends
|
|
60
|
+
* the role ("scroll bar") itself, so the name carries only what tells the two bars apart.
|
|
61
|
+
* 縦 ScrollBar のルート (`role="scrollbar"`) の aria-label。ロール名 (スクロールバー) は支援技術が
|
|
62
|
+
* 付け足すため、名前は 2 本のバーを区別する情報のみ。
|
|
63
|
+
*/
|
|
64
|
+
readonly verticalScrollBar: string
|
|
65
|
+
/**
|
|
66
|
+
* aria-label of the horizontal ScrollBar root (`role="scrollbar"`).
|
|
67
|
+
* 横 ScrollBar のルート (`role="scrollbar"`) の aria-label。
|
|
68
|
+
*/
|
|
69
|
+
readonly horizontalScrollBar: string
|
|
70
|
+
/**
|
|
71
|
+
* aria-label of the vertical ScrollBar thumb (`role="slider"`), whose value is the scroll
|
|
72
|
+
* position.
|
|
73
|
+
* 縦 ScrollBar のつまみ (`role="slider"`) の aria-label。値はスクロール位置。
|
|
74
|
+
*/
|
|
75
|
+
readonly verticalScrollThumb: string
|
|
76
|
+
/**
|
|
77
|
+
* aria-label of the horizontal ScrollBar thumb (`role="slider"`), whose value is the scroll
|
|
78
|
+
* position.
|
|
79
|
+
* 横 ScrollBar のつまみ (`role="slider"`) の aria-label。値はスクロール位置。
|
|
80
|
+
*/
|
|
81
|
+
readonly horizontalScrollThumb: string
|
|
56
82
|
/**
|
|
57
83
|
* Text of the VirtualScroll scroll-to-top pill, shown when
|
|
58
84
|
* `scrollBarOptions.enableScrollToTopBottomButtons` is on.
|
|
@@ -87,15 +113,32 @@ export type VirtualScrollLabelOverrides = { readonly [K in keyof VirtualScrollLa
|
|
|
87
113
|
* overrides are validated against.
|
|
88
114
|
* {@link VirtualScrollLabels} の全キー (カタログ順)。上書き検証に用いる閉じたキー集合。
|
|
89
115
|
*/
|
|
90
|
-
export const VIRTUAL_SCROLL_LABEL_KEYS = [
|
|
116
|
+
export const VIRTUAL_SCROLL_LABEL_KEYS = [
|
|
117
|
+
"scrollUp",
|
|
118
|
+
"scrollDown",
|
|
119
|
+
"scrollLeft",
|
|
120
|
+
"scrollRight",
|
|
121
|
+
"verticalScrollBar",
|
|
122
|
+
"horizontalScrollBar",
|
|
123
|
+
"verticalScrollThumb",
|
|
124
|
+
"horizontalScrollThumb",
|
|
125
|
+
"scrollToTop",
|
|
126
|
+
"scrollToBottom",
|
|
127
|
+
"noItems",
|
|
128
|
+
] as const satisfies readonly (keyof VirtualScrollLabels)[]
|
|
91
129
|
|
|
92
130
|
// satisfies は部分集合しか保証しないため、キー追加時の登録漏れを型で検出する
|
|
93
131
|
const keysCoverEveryLabel: [Exclude<keyof VirtualScrollLabels, (typeof VIRTUAL_SCROLL_LABEL_KEYS)[number]>] extends [never] ? true : never = true
|
|
94
132
|
void keysCoverEveryLabel
|
|
95
133
|
|
|
96
134
|
/**
|
|
97
|
-
* Frozen built-in catalogs per locale. `en`
|
|
98
|
-
*
|
|
135
|
+
* Frozen built-in catalogs per locale. The arrow, pill and empty-state values of `en` are the
|
|
136
|
+
* package's historical English wording. The bar names state only the orientation, because
|
|
137
|
+
* assistive technology already reads the role as "scroll bar"; the thumb names state what the
|
|
138
|
+
* value measures.
|
|
139
|
+
* ロケールごとの凍結済み内蔵カタログ。`en` の矢印・ピル・空状態の値はパッケージ従来の英語文言。
|
|
140
|
+
* バーの名前は向きのみ (支援技術がロールを既に「スクロールバー」と読むため)、つまみの名前は値が
|
|
141
|
+
* 表すもの。
|
|
99
142
|
*/
|
|
100
143
|
export const VIRTUAL_SCROLL_LABEL_CATALOGS: Readonly<Record<VirtualScrollLocale, VirtualScrollLabels>> = Object.freeze({
|
|
101
144
|
en: Object.freeze({
|
|
@@ -103,6 +146,10 @@ export const VIRTUAL_SCROLL_LABEL_CATALOGS: Readonly<Record<VirtualScrollLocale,
|
|
|
103
146
|
scrollDown: "Scroll down",
|
|
104
147
|
scrollLeft: "Scroll left",
|
|
105
148
|
scrollRight: "Scroll right",
|
|
149
|
+
verticalScrollBar: "Vertical",
|
|
150
|
+
horizontalScrollBar: "Horizontal",
|
|
151
|
+
verticalScrollThumb: "Vertical scroll position",
|
|
152
|
+
horizontalScrollThumb: "Horizontal scroll position",
|
|
106
153
|
scrollToTop: "Top",
|
|
107
154
|
scrollToBottom: "Bottom",
|
|
108
155
|
noItems: "No items",
|
|
@@ -112,6 +159,10 @@ export const VIRTUAL_SCROLL_LABEL_CATALOGS: Readonly<Record<VirtualScrollLocale,
|
|
|
112
159
|
scrollDown: "下へスクロール",
|
|
113
160
|
scrollLeft: "左へスクロール",
|
|
114
161
|
scrollRight: "右へスクロール",
|
|
162
|
+
verticalScrollBar: "縦方向",
|
|
163
|
+
horizontalScrollBar: "横方向",
|
|
164
|
+
verticalScrollThumb: "縦スクロール位置",
|
|
165
|
+
horizontalScrollThumb: "横スクロール位置",
|
|
115
166
|
scrollToTop: "先頭へ",
|
|
116
167
|
scrollToBottom: "末尾へ",
|
|
117
168
|
noItems: "項目がありません",
|
|
@@ -329,6 +329,22 @@
|
|
|
329
329
|
width: 100%;
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
+
/* 行ラッパーの包含ブロックで、配置の境界 (Chromium の relayout boundary)。窓をずらす 1 段が行を足し引きしても、配置はこの箱から
|
|
333
|
+
* 始まって箱の中で終わり、文書の根まで遡らない。境界になるには flex の子でも grid の子でもないことが要る (ペインの中身は flex の子
|
|
334
|
+
* なので、ラッパーの包含ブロックにしても境界にならない)。この箱は位置指定と、大きさと配置の封じ込めで境界になる。
|
|
335
|
+
* 箱はペインの中身のパディングの辺に付いて幅を合わせ、高さは 0 に固定する: 行は箱の外へはみ出して描かれ (描画は封じ込めないので、
|
|
336
|
+
* 切り取りはペインの中身の overflow: hidden のまま)、箱は当たり判定で背景 (background) の前に立たない。行のはみ出しは封じ込めで
|
|
337
|
+
* インクのはみ出しになるので、ペインの中身のスクロールできる範囲にも数えない。そのため、ブラウザが自分で行を見せるスクロール
|
|
338
|
+
* (オーバースキャンの行の中への Tab・ページ内検索) はペインの中身を動かせず、行の箱が外側のスクローラーの外にあればそちらを動かす */
|
|
339
|
+
.aqvs-items-boundary {
|
|
340
|
+
position: absolute;
|
|
341
|
+
top: 0;
|
|
342
|
+
right: 0;
|
|
343
|
+
left: 0;
|
|
344
|
+
height: 0;
|
|
345
|
+
contain: size layout style;
|
|
346
|
+
}
|
|
347
|
+
|
|
332
348
|
.aqvs-items-wrapper {
|
|
333
349
|
position: absolute;
|
|
334
350
|
width: 100%;
|
|
@@ -547,15 +563,47 @@
|
|
|
547
563
|
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
548
564
|
}
|
|
549
565
|
|
|
550
|
-
/*
|
|
551
|
-
*
|
|
552
|
-
*
|
|
566
|
+
/* 強制配色 (forced-colors: active) では、ブラウザがシステム色でない地色をどれも Canvas に置き換える (透明度は残す)。地色だけで
|
|
567
|
+
* 描く部品 (文字色も枠線も輪郭も持たない部品) は周りと区別できなくなるので、どれもここでシステム色の描き方を持つ
|
|
568
|
+
* (forcedColors.spec.tsx がこのファイルから地色だけで描く部品を導いて照合する)。
|
|
569
|
+
* - タップスクロールサークル: グラデーションの視覚は平坦になるので、輪郭で形を残す。
|
|
570
|
+
* - バーとトラック: 縁を GrayText の輪郭で描く (バーは矢印とトラックの下地、トラックはつまみが動く範囲)。
|
|
571
|
+
* - つまみ: ネイティブのスクロールバーと同じくシステム色で塗る。状態の規則 (ホバー・ドラッグ・無効) は同じ選択子でここに
|
|
572
|
+
* 言い直す: 詳細度が同じなので、後に置いたこちらが勝つ。forced-color-adjust: none はホストが塗ったシステム色でない地色を
|
|
573
|
+
* Canvas へ消させない (つまみが溝と同じ色になって消えない)。
|
|
574
|
+
* - サンプルのビジュアルの光と棒: 引いた向きと量を示すので CanvasText で塗る。 */
|
|
553
575
|
@media (forced-colors: active) {
|
|
554
576
|
.aqvs-tap-scroll-circle {
|
|
555
577
|
outline: 1px solid CanvasText;
|
|
556
578
|
outline-offset: -1px;
|
|
557
579
|
border-radius: 50%;
|
|
558
580
|
}
|
|
581
|
+
|
|
582
|
+
.aqvs-scrollbar,
|
|
583
|
+
.aqvs-scrollbar-track {
|
|
584
|
+
outline: 1px solid GrayText;
|
|
585
|
+
outline-offset: -1px;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
.aqvs-scrollbar-thumb {
|
|
589
|
+
forced-color-adjust: none;
|
|
590
|
+
background-color: CanvasText;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
.aqvs-scrollbar-thumb[data-thumb-state="hover"],
|
|
594
|
+
.aqvs-scrollbar-thumb[data-thumb-state="dragging"] {
|
|
595
|
+
background-color: Highlight;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
.aqvs-scrollbar-thumb[data-thumb-state="disabled"] {
|
|
599
|
+
background-color: GrayText;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
.aqvs-sample-visual-highlight,
|
|
603
|
+
.aqvs-sample-visual-rod {
|
|
604
|
+
forced-color-adjust: none;
|
|
605
|
+
background-color: CanvasText;
|
|
606
|
+
}
|
|
559
607
|
}
|
|
560
608
|
|
|
561
609
|
/* 動きを減らす設定 (prefers-reduced-motion: reduce) では、パッケージが動かす部品はどれも遷移もアニメーションも持たず、
|
package/src/utils.ts
CHANGED
|
@@ -56,3 +56,18 @@ export const getAxisScale = (element: HTMLElement, axis: "x" | "y"): number => {
|
|
|
56
56
|
}
|
|
57
57
|
return visualSize / layoutSize
|
|
58
58
|
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Pointer-down handler of pointer-only scroll chrome (the scrollbar and the scroll-to-edge pills of a host that scrolls by
|
|
62
|
+
* keyboard itself): cancels the press's default action, so the press never moves focus — neither onto a part of the chrome
|
|
63
|
+
* nor away from where the host put it — while the press itself, its pointer events and its click still reach the part.
|
|
64
|
+
*
|
|
65
|
+
* ポインタ専用のスクロールの部品 (キーボードのスクロールを自分で持つホストのスクロールバーと端へ戻るピル) の pointerdown の
|
|
66
|
+
* 処理。押下の既定動作を取り消すので、押下はフォーカスを動かさない — 部品の上へも、ホストが置いた場所の外へも — が、押下
|
|
67
|
+
* そのもの (ポインタのイベントと click) は部品へ届く。
|
|
68
|
+
*
|
|
69
|
+
* @param event - The pointer-down event (only its default action is read) / pointerdown のイベント (既定動作だけを扱う)
|
|
70
|
+
*/
|
|
71
|
+
export const keepFocusOnPress = (event: { readonly preventDefault: () => void }): void => {
|
|
72
|
+
event.preventDefault()
|
|
73
|
+
}
|