@aiquants/period-slider 0.18.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +209 -0
  2. package/README.md +26 -7
  3. package/dist/DateSelector.d.ts +9 -9
  4. package/dist/DateSelector.d.ts.map +1 -1
  5. package/dist/MonthSelector.d.ts +5 -4
  6. package/dist/MonthSelector.d.ts.map +1 -1
  7. package/dist/PeriodSlider.d.ts +23 -4
  8. package/dist/PeriodSlider.d.ts.map +1 -1
  9. package/dist/VirtualDateDropdown.d.ts +25 -10
  10. package/dist/VirtualDateDropdown.d.ts.map +1 -1
  11. package/dist/YearSelector.d.ts +7 -4
  12. package/dist/YearSelector.d.ts.map +1 -1
  13. package/dist/index.cjs +1 -1
  14. package/dist/index.js +2859 -2394
  15. package/dist/optionText.d.ts +1 -1
  16. package/dist/optionText.d.ts.map +1 -1
  17. package/dist/renderScope.d.ts +486 -0
  18. package/dist/renderScope.d.ts.map +1 -0
  19. package/dist/selectorMemo.d.ts +42 -22
  20. package/dist/selectorMemo.d.ts.map +1 -1
  21. package/dist/useCommittedRef.d.ts +64 -71
  22. package/dist/useCommittedRef.d.ts.map +1 -1
  23. package/dist/usePeriodSlider.d.ts +56 -12
  24. package/dist/usePeriodSlider.d.ts.map +1 -1
  25. package/dist/useUncontrolledSelection.d.ts +7 -7
  26. package/dist/useUncontrolledSelection.d.ts.map +1 -1
  27. package/package.json +1 -1
  28. package/src/DateSelector.tsx +45 -20
  29. package/src/MonthSelector.tsx +41 -19
  30. package/src/PeriodSlider.tsx +39 -14
  31. package/src/VirtualDateDropdown.tsx +163 -92
  32. package/src/YearSelector.tsx +26 -27
  33. package/src/optionText.ts +6 -4
  34. package/src/renderScope.ts +766 -0
  35. package/src/selectorMemo.ts +53 -25
  36. package/src/useCommittedRef.ts +51 -155
  37. package/src/usePeriodSlider.ts +316 -138
  38. package/src/useUncontrolledSelection.ts +8 -9
@@ -11,7 +11,7 @@ import { PeriodOptionScope, PeriodSliderUnit } from './PeriodSlider.js';
11
11
  * a public entry point whose arguments can arrive from JavaScript, where no union is enforced.
12
12
  * フォーマッタ Props は型検査を受けるが、本関数は公開の入口であり JavaScript からも引数が届くため検証する。
13
13
  *
14
- * @param date - Date to render / 描画対象の日付
14
+ * @param date - Date to render; both built-in tiers read it by its time value in the system time zone / 描画対象の日付 (組み込みのどちらの段も時刻値をシステムのタイムゾーンで読む)
15
15
  * @param unit - Precision to name / 名乗る精度
16
16
  * @param scope - Scope selecting the built-in option set / 組み込みオプション集合を選ぶ区分
17
17
  * @param formatLocale - BCP 47 language tag enabling Intl formatting (the `formatLocale` prop, not the UI chrome `locale`) / Intl 書式を有効化する BCP 47 言語タグ (UI クロームの `locale` ではなく `formatLocale` prop)
@@ -1 +1 @@
1
- {"version":3,"file":"optionText.d.ts","sourceRoot":"","sources":["../src/optionText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAsD,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AA4ElI;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,IAAI,EAAE,MAAM,gBAAgB,EAAE,OAAO,iBAAiB,EAAE,eAAe,MAAM,KAAG,MAUtH,CAAA"}
1
+ {"version":3,"file":"optionText.d.ts","sourceRoot":"","sources":["../src/optionText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAsD,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AA8ElI;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,IAAI,EAAE,MAAM,gBAAgB,EAAE,OAAO,iBAAiB,EAAE,eAAe,MAAM,KAAG,MAUtH,CAAA"}
@@ -0,0 +1,486 @@
1
+ import { Dispatch, SetStateAction } from 'react';
2
+ import { CommittedMirror } from './useCommittedRef.js';
3
+ /**
4
+ * A notification a render pass keeps until its render commits.
5
+ * 描画の範囲がその描画の確定まで預かる通知。
6
+ */
7
+ export interface HeldNotification {
8
+ /** Index of the state whose change it reports / 変化を知らせるステートの番号 */
9
+ readonly slot: number;
10
+ /** Calls the consumer's callback / 利用側のコールバックを呼ぶ関数 */
11
+ readonly send: () => void;
12
+ }
13
+ /**
14
+ * A cell whose writes a render pass drafts: a state mirror or a value the consumer knows.
15
+ * 描画の範囲が書き込みを下書きする入れ物 (ステートの写し、または利用側が知っている値)。
16
+ */
17
+ export interface ScopedCell {
18
+ /** Index of the state the cell belongs to / 入れ物が属するステートの番号 */
19
+ readonly slot: number;
20
+ /**
21
+ * Applies what a committed pass drafted into the cell.
22
+ * 確定した描画の範囲が下書きした内容を入れ物へ当てる関数。
23
+ *
24
+ * @param pass - The committed pass / 確定した描画の範囲
25
+ * @param states - The states the committed render holds / 確定した描画が持つステート
26
+ * @returns Nothing / なし
27
+ */
28
+ adopt(pass: RenderPass, states: readonly unknown[]): void;
29
+ }
30
+ /**
31
+ * One render of the hook's host as the calls inside its `duringRender(action)` see it: what they drafted, handed to the states and owe the consumer.
32
+ * `duringRender(action)` の中の呼び出しから見たフックのホストの 1 回の描画。その呼び出しの下書き・ステートへの受け渡し・利用側へ負う通知。
33
+ */
34
+ export declare class RenderPass {
35
+ readonly states: readonly unknown[];
36
+ readonly base: readonly number[];
37
+ readonly superseded: readonly boolean[];
38
+ /** Values the calls wrote into cells / 呼び出しが入れ物へ書いた値 */
39
+ private readonly drafts;
40
+ /** The object each state was last handed, by state index / 各ステートへ最後に渡したオブジェクト (ステートの番号ごと) */
41
+ private readonly handed;
42
+ /** Cells the calls wrote or handed through / 呼び出しが書いた、または受け渡しに使った入れ物 */
43
+ readonly cells: Set<ScopedCell>;
44
+ /** Notifications the calls owe the consumer, in call order / 呼び出しが利用側へ負う通知 (呼んだ順) */
45
+ readonly notes: HeldNotification[];
46
+ /** Whether duringRender(action) no longer accepts this render: it committed, a later body run opened another pass, or the synchronous run that ran the body ended / duringRender(action) がもうこの描画を受け付けないか (確定した・後の本体の実行が別の範囲を開いた・本体を走らせた同期の実行が終わった) */
47
+ closed: boolean;
48
+ /** Whether a duringRender(action) of this render marked the host with this pass (useRenderScope) / この描画の duringRender(action) が、ホストへこの範囲の印を付けたか (useRenderScope) */
49
+ marked: boolean;
50
+ /** Whether this render committed / この描画が確定したか */
51
+ committed: boolean;
52
+ /**
53
+ * Opens the pass.
54
+ * 描画の範囲を開くコンストラクタ。
55
+ *
56
+ * @param states - The states the render holds when the hook body runs / フック本体が走るときに描画が持つステート
57
+ * @param base - The event-time writes of each state so far / ここまでの、ステートごとの事象の時点の書き込みの回数
58
+ * @param superseded - Per state, whether a pending event-time hand-off that the render does not hold supersedes what the pass does to the state / ステートごとに、描画が持たない保留中の事象の時点の受け渡しが、範囲がそのステートにする事を置き換えるか
59
+ */
60
+ constructor(states: readonly unknown[], base: readonly number[], superseded: readonly boolean[]);
61
+ /**
62
+ * Whether a render holds the states this pass leads to: per state, the object the pass last handed, or the state it opened with.
63
+ * 描画が、この範囲の行き着くステートを持つか (ステートごとに、範囲が最後に渡したオブジェクト、渡していなければ開いたときのステート)。
64
+ *
65
+ * @param states - The states a render holds / 描画が持つステート
66
+ * @returns True when every state is that object / どのステートもそのオブジェクトなら true
67
+ */
68
+ leadsTo(states: readonly unknown[]): boolean;
69
+ /**
70
+ * A cell's value as the calls in this pass see it.
71
+ * この範囲の呼び出しから見た入れ物の値。
72
+ *
73
+ * @param cell - The cell / 入れ物
74
+ * @param committed - The cell's value outside the pass / 範囲の外の入れ物の値
75
+ * @returns The draft, or the value outside the pass when the pass wrote none / 下書き (範囲が書いていなければ範囲の外の値)
76
+ */
77
+ read<T>(cell: ScopedCell, committed: T): T;
78
+ /**
79
+ * Drafts a write into a cell.
80
+ * 入れ物への書き込みを下書きする関数。
81
+ *
82
+ * @param cell - The cell / 入れ物
83
+ * @param value - The written value / 書いた値
84
+ * @returns Nothing / なし
85
+ */
86
+ write(cell: ScopedCell, value: unknown): void;
87
+ /**
88
+ * Records the object a call handed to the state a mirror reflects.
89
+ * 呼び出しが写しの写すステートへ渡したオブジェクトを記録する関数。
90
+ *
91
+ * @param cell - The state's mirror / ステートの写し
92
+ * @param value - The handed object / 渡したオブジェクト
93
+ * @returns Nothing / なし
94
+ */
95
+ hand(cell: ScopedCell, value: unknown): void;
96
+ /**
97
+ * Whether the pass handed an object to a state.
98
+ * 範囲がステートへオブジェクトを渡したか。
99
+ *
100
+ * @param slot - Index of the state / ステートの番号
101
+ * @returns True when it did / 渡していれば true
102
+ */
103
+ hasHanded(slot: number): boolean;
104
+ /**
105
+ * The object the pass last handed to a state.
106
+ * 範囲がステートへ最後に渡したオブジェクト。
107
+ *
108
+ * @param slot - Index of a state the pass handed an object to (hasHanded) / 範囲がオブジェクトを渡したステートの番号 (hasHanded)
109
+ * @returns The object / そのオブジェクト
110
+ */
111
+ lastHanded(slot: number): unknown;
112
+ /**
113
+ * Stops duringRender(action) from accepting this render.
114
+ * duringRender(action) がもうこの描画を受け付けないようにする関数。
115
+ *
116
+ * @returns Nothing / なし
117
+ */
118
+ close(): void;
119
+ }
120
+ /**
121
+ * The render scope of one hook instance: runs the host's `duringRender(action)` against the pass of the render in progress, keeps the render passes, and delivers the notifications committed passes owe.
122
+ * フックのインスタンス 1 つの描画の範囲。ホストの `duringRender(action)` を進行中の描画の範囲に対して走らせ、描画の範囲を持ち、確定した範囲が負う通知を届ける。
123
+ *
124
+ * A call is a render-phase call only while an action this scope runs is on the stack; every other call is an event-time
125
+ * call, wherever it is made (a handler, an effect, a microtask, a commit, or a render outside duringRender): it reads
126
+ * and writes the mirror at once and notifies synchronously after the waiting notifications. A pass opens when the hook
127
+ * body runs (begin), and duringRender(action) acts on the latest pass until the pass closes: at its commit, or at the end
128
+ * of the synchronous run that ran the body (a microtask). The first duringRender(action) of a pass marks the host with
129
+ * the pass through a render-phase update of a hook-internal reducer (useRenderScope), and React keeps that update exactly
130
+ * in the continuations of the render (the re-run after a render-phase update, StrictMode's second call, the replay
131
+ * after a suspended render's data resolved) and discards it with a render it unwinds, restarts or holds. A body run
132
+ * continues the latest pass only when the pass has not committed, the run holds its mark, and the run's states are the
133
+ * ones the pass leads to; the commit of that render applies the pass, and any other body run opens a new pass. Inside an
134
+ * action, a returned function reads the committed values overlaid by the pass's drafts, and its writes, hand-off records
135
+ * and notifications go into the pass, while the hand-off itself is React's render-phase update. The pass's commit
136
+ * applies them state by state, except for a state an event-time call wrote after the pass opened, or one that a pending
137
+ * event-time hand-off the render does not hold supersedes (determined when the pass opens): React applies those updates
138
+ * after this commit, so they win. The notifications a commit applies wait in an outbox, which is delivered in the host's
139
+ * layout effect, before any event-time write or notification of the hook, and in a microtask for a commit that runs no
140
+ * layout effects. While any instance runs an action, a returned function whose own scope runs none throws: that call is
141
+ * a render-phase call this scope cannot hold.
142
+ * 呼び出しは、この範囲が走らせる動作が実行中の間だけ描画中の呼び出しで、それ以外はどこで呼んでも (事象の処理・副作用・マイクロタスク・確定・
143
+ * duringRender の外の描画) 事象の時点の呼び出しである (写しをその場で読み書きし、待っている通知を届けてから同期で通知する)。描画の範囲は
144
+ * フック本体が走ると開き (begin)、duringRender(action) は最後の範囲に、それが閉じるまで働く (確定・本体を走らせた同期の実行の終わり
145
+ * (マイクロタスク) のうち先のもの)。範囲の最初の duringRender(action) は、フック内部のリデューサーへの描画中の更新でホストにその範囲の印を付け
146
+ * (useRenderScope)、React はその更新をその描画の続き (描画中の更新の後の走らせ直し・StrictMode の 2 度目の呼び出し・中断した描画のデータが
147
+ * 解決した後の再実行) だけに残し、巻き戻す・やり直す・保留する描画とともに捨てる。本体の実行が最後の範囲を引き継ぐのは、範囲が確定しておらず、
148
+ * 実行がその印を持ち、実行のステートが範囲の行き着くステートのときだけで、その描画の確定が範囲を当てる (それ以外の本体の実行は新しい範囲を開く)。
149
+ * 動作の中の返す関数は確定した値に範囲の下書きを重ねて読み、書き込み・受け渡しの記録・通知は範囲へ入る (受け渡しそのものは React の描画中の更新)。
150
+ * 範囲の確定はそれらをステートごとに当てる。範囲が開いた後に事象の時点の呼び出しが書いたステートと、描画が持たない保留中の事象の時点の受け渡しが
151
+ * 置き換えるステート (範囲が開くときに判定する) の分は当てない (React はその更新をこの確定の後で当て、そちらが勝つ)。確定が当てた通知は
152
+ * 送り箱で待ち、ホストのレイアウト副作用・フックの事象の時点の書き込みと通知の前・レイアウト副作用を走らせない確定ではマイクロタスクで届く。
153
+ * どれかのインスタンスが動作を走らせている間、自分の範囲が動作を走らせていない返す関数は送出する (その呼び出しは、この範囲が預かれない描画中の呼び出し)。
154
+ */
155
+ export declare class RenderScope {
156
+ private readonly owner;
157
+ private readonly setMark;
158
+ /** The pass of the latest body run / 最後に走った本体の描画の範囲 */
159
+ private latest;
160
+ /** The pass the running action of duringRender acts on, or null at event time / 走っている duringRender の動作が働く描画の範囲 (事象の時点なら null) */
161
+ private active;
162
+ /** Event-time writes made so far, per state / これまでの事象の時点の書き込みの回数 (ステートごと) */
163
+ private readonly slotWrites;
164
+ /** Per state, the object a returned function last handed to it, while it can still be the state's last queued update / ステートごとに、返す関数が最後に渡したオブジェクト (それがステートの最後に積んだ更新であり得る間) */
165
+ private readonly records;
166
+ /** Notifications of committed passes not delivered yet, in order / 確定した範囲の、まだ届けていない通知 (順に) */
167
+ private readonly outbox;
168
+ /**
169
+ * Creates the scope with a pass opened over the first render's states; no mark names that pass, so the first body run opens its own (begin).
170
+ * 最初の描画のステートで開いた範囲を持つ描画の範囲を作るコンストラクタ (どの印もその範囲を指さないため、最初の本体の実行は自分の範囲を開く。begin)。
171
+ *
172
+ * @param owner - The hook's name, which the scope's errors name / フックの名前 (範囲のエラーが名乗る)
173
+ * @param states - The states of the first render / 最初の描画のステート
174
+ * @param setMark - Dispatches the host's render-phase mark, with an identity stable for the life of the component (useRenderScope) / ホストへ描画中の印を付ける関数 (同一性はコンポーネントの存続中ずっと変わらない。useRenderScope)
175
+ */
176
+ constructor(owner: string, states: readonly unknown[], setMark: (pass: RenderPass) => void);
177
+ /**
178
+ * Runs an action as part of the host's render in progress: a call to this hook's returned functions made synchronously inside it is a render-phase call of that render, and React keeps or discards what it did together with the render. Keeps its identity for the life of the scope.
179
+ * 進行中のホストの描画の一部として動作を走らせる関数。動作の中で同期に呼んだこのフックの返す関数はその描画の描画中の呼び出しで、
180
+ * 呼び出しがした事は React が描画とともに残すか捨てる。同一性は範囲の存続中ずっと変わらない。
181
+ *
182
+ * The first call for a pass marks the host with the pass through a render-phase update (useRenderScope): React runs the
183
+ * host's body again within the same render, as it does for the action's hand-offs, and only the continuations of this
184
+ * render continue the pass (begin).
185
+ * 範囲への最初の呼び出しは、描画中の更新でホストにその範囲の印を付ける (useRenderScope)。React は動作の受け渡しと同じく同じ描画の中で
186
+ * ホストの本体をもう一度走らせ、範囲を引き継ぐのはこの描画の続きだけになる (begin)。
187
+ *
188
+ * @param action - Calls the hook's returned functions; it may call duringRender again / フックの返す関数を呼ぶ関数 (duringRender を入れ子に呼んでよい)
189
+ * @returns Nothing; an exception thrown by the action propagates / なし (動作が送出した例外はそのまま伝わる)
190
+ * @throws {TypeError} When action is not a function (`<owner>: duringRender(action) must be a function (received: ...)`) / action が関数でない場合
191
+ * @throws {Error} When the hook's render scope closed: the render of its latest pass committed, or the synchronous run that ran the body ended (`<owner>: duringRender(action) must be called during the host's render, after the hook call (...)`) / フックの描画の範囲が閉じている場合 (最後の範囲の描画が確定した・本体を走らせた同期の実行が終わった)
192
+ */
193
+ readonly duringRender: (action: () => void) => void;
194
+ /**
195
+ * The pass a call acts on: the latest pass while an action of this scope runs, or null at event time.
196
+ * 呼び出しが働く描画の範囲 (この範囲の動作が走っている間は最後の範囲、事象の時点なら null)。
197
+ *
198
+ * @returns The active pass, or null at event time / 働いている範囲 (事象の時点なら null)
199
+ * @throws {Error} While another instance runs an action and this scope runs none, before the call does anything (`<owner>: a returned function was called during another hook's duringRender(action); ...`) / ほかのインスタンスが動作を走らせ、この範囲が走らせていない間 (呼び出しが何かをする前に送出)
200
+ */
201
+ get pass(): RenderPass | null;
202
+ /**
203
+ * Whether a render-phase hand-off to a state may still commit: the latest pass has not committed and handed an object to the state.
204
+ * 描画中の受け渡しがまだ確定し得るか (最後の範囲が確定しておらず、ステートへオブジェクトを渡した)。
205
+ *
206
+ * @param slot - Index of the state / ステートの番号
207
+ * @returns True while such a hand-off may commit / そうした受け渡しが確定し得る間は true
208
+ */
209
+ inFlight(slot: number): boolean;
210
+ /**
211
+ * The object a returned function last handed to a state at event time or through a committed pass, while it can still be the state's last queued update.
212
+ * 返す関数が事象の時点に、または確定した範囲を通してステートへ最後に渡したオブジェクト (それがステートの最後に積んだ更新であり得る間)。
213
+ *
214
+ * @param slot - Index of the state / ステートの番号
215
+ * @returns The object, or NOTHING_HANDED when no record is kept / そのオブジェクト (記録が無ければ NOTHING_HANDED)
216
+ */
217
+ handedTo(slot: number): unknown;
218
+ /**
219
+ * Sets or clears the record of the object last handed to a state.
220
+ * ステートへ最後に渡したオブジェクトの記録を置く (または消す) 関数。
221
+ *
222
+ * @param slot - Index of the state / ステートの番号
223
+ * @param value - The handed object, or NOTHING_HANDED to clear the record / 渡したオブジェクト (記録を消すなら NOTHING_HANDED)
224
+ * @returns Nothing / なし
225
+ */
226
+ recordHanded(slot: number, value: unknown): void;
227
+ /**
228
+ * Opens the pass of a hook body run, or continues the latest pass when this run continues the render that marked it.
229
+ * フック本体の実行の描画の範囲を開く関数 (この実行が、最後の範囲に印を付けた描画の続きなら、その範囲を続ける)。
230
+ *
231
+ * @param states - The states this run holds / この実行が持つステート
232
+ * @param mark - The pass this run's render-phase mark names, or null when no duringRender(action) marked the host yet (useRenderScope) / この実行の描画中の印が指す範囲 (まだどの duringRender(action) も印を付けていなければ null。useRenderScope)
233
+ * @returns The pass of this run / この実行の描画の範囲
234
+ */
235
+ begin(states: readonly unknown[], mark: RenderPass | null): RenderPass;
236
+ /**
237
+ * Creates a pass that closes at the end of the synchronous run, flagging each state that a recorded event-time hand-off the run does not hold supersedes.
238
+ * 同期の実行の終わりに閉じる描画の範囲を作る関数 (実行が持たない、記録した事象の時点の受け渡しが置き換えるステートに印を付ける)。
239
+ *
240
+ * @param states - The states of the run / 実行のステート
241
+ * @returns The new pass / 新しい範囲
242
+ */
243
+ private open;
244
+ /**
245
+ * Closes a pass to duringRender(action) once the synchronous run that opened or resumed it ends.
246
+ * 範囲を開いた (引き継いだ) 同期の実行が終わったら、duringRender(action) に対して範囲を閉じる関数。
247
+ *
248
+ * @param pass - The pass / 描画の範囲
249
+ * @returns Nothing / なし
250
+ */
251
+ private closeAtEndOfRun;
252
+ /**
253
+ * Whether a committed pass applies what it did to a state: no event-time call wrote the state after the pass opened, and no pending event-time hand-off supersedes it.
254
+ * 確定した範囲がステートにした事を当てるか (範囲が開いた後に事象の時点の呼び出しがそのステートを書いておらず、保留中の事象の時点の受け渡しにも置き換えられていない)。
255
+ *
256
+ * @param pass - The committed pass / 確定した描画の範囲
257
+ * @param slot - Index of the state / ステートの番号
258
+ * @returns True when the pass's drafts, hand-offs and notifications for the state apply / 範囲のそのステートの下書き・受け渡し・通知を当てるなら true
259
+ */
260
+ private applies;
261
+ /**
262
+ * Applies a committed render's pass: its drafts and hand-off records per state, and its notifications to the outbox.
263
+ * 確定した描画の範囲を当てる関数 (下書きと受け渡しの記録をステートごとに、通知を送り箱へ)。
264
+ *
265
+ * @param pass - The pass of the committed render / 確定した描画の範囲
266
+ * @param states - The states the committed render holds / 確定した描画が持つステート
267
+ * @returns Nothing / なし
268
+ */
269
+ commit(pass: RenderPass, states: readonly unknown[]): void;
270
+ /**
271
+ * Delivers the notifications waiting in the outbox, in order.
272
+ * 送り箱で待つ通知を順に届ける関数。
273
+ *
274
+ * @returns Nothing / なし
275
+ */
276
+ deliver(): void;
277
+ /**
278
+ * Counts an event-time write to a state's cells, after delivering the waiting notifications.
279
+ * 待っている通知を届けてから、ステートの入れ物への事象の時点の書き込みを数える関数。
280
+ *
281
+ * @param slot - Index of the written state / 書いたステートの番号
282
+ * @returns Nothing / なし
283
+ */
284
+ wrote(slot: number): void;
285
+ /**
286
+ * Notifies the consumer: a call inside an action queues the notification in the active pass, and an event-time call sends it after the waiting ones.
287
+ * 利用側へ通知する関数 (動作の中の呼び出しは働いている範囲へ預け、事象の時点の呼び出しは待っている通知の後に送る)。
288
+ *
289
+ * @param slot - Index of the state whose change it reports / 変化を知らせるステートの番号
290
+ * @param send - Calls the consumer's callback / 利用側のコールバックを呼ぶ関数
291
+ * @returns Nothing / なし
292
+ */
293
+ notify(slot: number, send: () => void): void;
294
+ }
295
+ /**
296
+ * The mirror of a hook's state that the returned functions read and write; the record of the object they last handed to that state lives in the render scope. A call inside an action of duringRender acts on the active pass.
297
+ * 返す関数が読み書きするフックのステートの写し (返す関数がそのステートへ最後に渡したオブジェクトの記録は描画の範囲が持つ)。duringRender の動作の中の呼び出しは働いている範囲に働く。
298
+ *
299
+ * Every hand-off a returned function makes is a plain value, never an updater, and React applies a hook's updates in
300
+ * the order they were queued, so while the record names the state's last queued update, the stored state ends at the
301
+ * recorded object. A hand-off made inside an action is recorded by its render's commit, when the committed state is
302
+ * that object: React discards it together with a render it discards, and the record never names it. A hook's state
303
+ * receives two updaters, both guarded by identity and queued from the host's layout effect. One records such a committed
304
+ * hand-off into the state's queue (recordAdopted): React's rebase of an update the committing render skipped replays the
305
+ * queue from its base, which holds no render-phase update, so without the record the stored state would drop a hand-off
306
+ * the hook already reported. The other is the hook's record of its own re-placement (recordPlacement), which clears the
307
+ * hand-off record first, because that updater may resolve to an earlier hand-off instead of the value it carries.
308
+ * 返す関数の受け渡しはすべて値そのもので (関数形の更新ではない)、React はフックの更新を積んだ順に当てるため、記録がステートの最後に積んだ更新を
309
+ * 指している間は、保存されるステートが記録したオブジェクトに行き着く。動作の中の受け渡しはその描画の確定が、確定したステートがそのオブジェクトの
310
+ * ときに記録する (React は捨てる描画とともにその受け渡しも捨て、記録がそれを指すことはない)。フックのステートが受け取る更新関数は 2 つで、
311
+ * どちらも同一性で守り、ホストのレイアウト副作用から積む。1 つは、そうして確定した受け渡しをステートのキューへ記録するもの (recordAdopted。
312
+ * 確定した描画が飛ばした更新を React が積み直すときはキューを基準から当て直し、そこに描画中の更新は無いため、記録しないと保存されるステートが、
313
+ * フックが既に通知した受け渡しを落とす)。もう 1 つはフック自身の収め直しの記録 (recordPlacement) で、それは先に受け渡しの記録を消す
314
+ * (その更新関数は運ぶ値ではなく前の受け渡しへ解け得るため)。
315
+ */
316
+ export declare class StateMirror<T> extends CommittedMirror<T> implements ScopedCell {
317
+ private readonly scope;
318
+ readonly slot: number;
319
+ /** The hand-off the last commit adopted and the state its pass opened with, until the host's layout effect queues its record (recordAdopted), or null / 最後の確定が当てた受け渡しと、その範囲が開いたときのステート (ホストのレイアウト副作用が記録を積むまで。無ければ null) */
320
+ private adopted;
321
+ /**
322
+ * Creates the mirror with the first render's value.
323
+ * 最初の描画の値で写しを作るコンストラクタ。
324
+ *
325
+ * @param initial - The first render's value / 最初の描画の値
326
+ * @param scope - The hook's render scope / フックの描画の範囲
327
+ * @param slot - Index of the state in the scope / 範囲の中のステートの番号
328
+ */
329
+ constructor(initial: T, scope: RenderScope, slot: number);
330
+ /**
331
+ * The value the calls see: the last committed render's value or a later event-time write, overlaid by the active pass's draft inside an action.
332
+ * 呼び出しが見る値 (最後に確定した描画の値かその後の事象の時点の書き込み。動作の中では働いている範囲の下書きを重ねる)。
333
+ *
334
+ * @returns The value / 値
335
+ */
336
+ get current(): T;
337
+ /**
338
+ * Writes a value: into the active pass inside an action, and into the mirror at event time.
339
+ * 値を書く関数 (動作の中は働いている範囲へ、事象の時点は写しへ)。
340
+ *
341
+ * @param next - The written value / 書く値
342
+ */
343
+ set current(next: T);
344
+ /**
345
+ * Records the object a returned function is about to pass to the state's setter: in the active pass inside an action, and in the scope's record at event time.
346
+ * 返す関数がステートの設定関数へ渡そうとしているオブジェクトを記録する関数 (動作の中は働いている範囲へ、事象の時点は範囲の記録へ)。
347
+ *
348
+ * @param value - The object about to be handed over / これから渡すオブジェクト
349
+ * @returns Nothing / なし
350
+ */
351
+ hand(value: T): void;
352
+ /**
353
+ * Whether the object the calls see is the state's last hand-off, so the state's last queued update, or its stored value, already is that object.
354
+ * 呼び出しが見るオブジェクトがステートの最後の受け渡しか (ステートの最後に積んだ更新、または保存済みの値が、既にそのオブジェクトそのものか)。
355
+ *
356
+ * @returns True when the last hand-off (the active pass's, else the record) names the object the calls see; at event time, false while a render-phase hand-off to the state may still commit / 最後の受け渡し (働いている範囲のもの、無ければ記録) が呼び出しの見るオブジェクトを指せば true (事象の時点では、ステートへの描画中の受け渡しがまだ確定し得る間は false)
357
+ */
358
+ get holdsHanded(): boolean;
359
+ /**
360
+ * Drops the record when it names the state the committed render held, so the next commit path that settles on that render's re-placed value hands it over again; a record that names another object is a hand-off that render skipped, still pending in the state's queue, and stays. The hook's record of its own re-placement (recordPlacement) calls it from the host's layout effect before it queues its updater.
361
+ * 記録が確定した描画の持っていたステートを指すときに消す関数 (次にその描画が収め直した値へ落ち着いた確定経路は、もう一度それを渡す)。ほかのオブジェクトを指す記録は、その描画が飛ばしてステートのキューに保留している受け渡しで、残す。フック自身の収め直しの記録 (recordPlacement) が、ホストのレイアウト副作用から更新関数を積む前に呼ぶ。
362
+ *
363
+ * @param held - The state the committed render held / 確定した描画が持っていたステート
364
+ * @returns Nothing / なし
365
+ */
366
+ forgetHanded(held: T): void;
367
+ /**
368
+ * Records the object a committed pass handed to the state, when the committed state is that object, and keeps the hand-off until the host's layout effect records it into the state's queue (recordAdopted).
369
+ * 確定した範囲がステートへ渡したオブジェクトを、確定したステートがそのオブジェクトのときに記録し、ホストのレイアウト副作用がステートのキューへ記録するまで受け渡しを預かる関数 (recordAdopted)。
370
+ *
371
+ * @param pass - The committed pass / 確定した描画の範囲
372
+ * @param states - The states the committed render holds / 確定した描画が持つステート
373
+ * @returns Nothing / なし
374
+ */
375
+ adopt(pass: RenderPass, states: readonly unknown[]): void;
376
+ /**
377
+ * Queues the record of the hand-off the last commit adopted into the state's queue, once: an updater that resolves to the handed object only when the state it meets is the one the pass opened with. The mirror's hook calls it from the host's layout effect, before the hook records its re-placement (recordPlacement).
378
+ * 最後の確定が当てた受け渡しの記録をステートのキューへ 1 度だけ積む関数 (出会ったステートが範囲の開いたときのステートのときだけ、渡したオブジェクトへ解ける更新関数)。写しのフックが、フックが収め直しを記録する (recordPlacement) より前に、ホストのレイアウト副作用から呼ぶ。
379
+ *
380
+ * Without a skipped update, the updater meets the handed object and keeps it, in one render of the host that bails out
381
+ * of its children. When the committing render skipped a lower-priority update of the state, React's rebase applies the
382
+ * skipped update and the ones after it to the base state without the render-phase hand-off, and the updater then meets
383
+ * the opening state and restores the hand-off, so the stored state ends at the value the hook reported. A later
384
+ * hand-off is queued after the updater and wins.
385
+ * 飛ばした更新が無ければ、更新関数は渡したオブジェクトに出会ってそれを保ち、子の描画を省くホストの描画が 1 度走る。確定した描画がステートの
386
+ * 優先度の低い更新を飛ばしていれば、React の積み直しは基準のステートへ飛ばした更新とその後の更新を描画中の受け渡し抜きで当て、更新関数は開いた
387
+ * ときのステートに出会って受け渡しを戻す (保存されるステートはフックが通知した値に行き着く)。後の受け渡しは更新関数の後に積まれ、そちらが勝つ。
388
+ *
389
+ * @param setState - The state's setter / ステートの設定関数
390
+ * @returns Nothing / なし
391
+ */
392
+ recordAdopted(setState: Dispatch<SetStateAction<T>>): void;
393
+ }
394
+ /**
395
+ * A value the hook keeps for its returned functions, such as the value the consumer knows; a write inside an action of duringRender is drafted in the active pass and that pass's commit applies it.
396
+ * フックが返す関数のために持つ値 (利用側が知っている値など)。duringRender の動作の中の書き込みは働いている範囲へ下書きし、範囲の確定が当てる。
397
+ */
398
+ export declare class ScopedRef<T> implements ScopedCell {
399
+ private readonly scope;
400
+ readonly slot: number;
401
+ /** The value outside any pass / 範囲の外の値 */
402
+ private held;
403
+ /**
404
+ * Creates the ref.
405
+ * ref を作るコンストラクタ。
406
+ *
407
+ * @param initial - The value it starts with / 最初の値
408
+ * @param scope - The hook's render scope / フックの描画の範囲
409
+ * @param slot - Index of the state the value belongs to / 値が属するステートの番号
410
+ */
411
+ constructor(initial: T, scope: RenderScope, slot: number);
412
+ /**
413
+ * The value the calls see: the held value, overlaid by the active pass's draft inside an action.
414
+ * 呼び出しが見る値 (保持する値。動作の中では働いている範囲の下書きを重ねる)。
415
+ *
416
+ * @returns The value / 値
417
+ */
418
+ get current(): T;
419
+ /**
420
+ * Writes a value: into the active pass inside an action, and into the ref at event time.
421
+ * 値を書く関数 (動作の中は働いている範囲へ、事象の時点は ref へ)。
422
+ *
423
+ * @param next - The written value / 書く値
424
+ */
425
+ set current(next: T);
426
+ /**
427
+ * Applies the value a committed pass wrote.
428
+ * 確定した範囲が書いた値を当てる関数。
429
+ *
430
+ * @param pass - The committed pass / 確定した描画の範囲
431
+ * @returns Nothing / なし
432
+ */
433
+ adopt(pass: RenderPass): void;
434
+ }
435
+ /**
436
+ * Opens the render scope of a hook body run; the hook calls it right after the states its returned functions hand values to.
437
+ * フック本体の実行の描画の範囲を開くフック (返す関数が値を渡すステートの直後に呼ぶ)。
438
+ *
439
+ * The hook keeps the host's render-phase mark in a hook-internal reducer: the first duringRender(action) of a pass
440
+ * dispatches it during the host's render, and React keeps that update exactly in the continuations of that render, so a
441
+ * body run continues a pass only in those (RenderScope.begin). The scope's insertion effect applies the pass of the
442
+ * committing render before any layout effect of that commit (a descendant's layout effect may call a returned function
443
+ * first), and also for commits inside a hidden Activity. Its layout effect delivers the notifications that commit
444
+ * applied. The hook calls it before the state mirrors, so the scope applies a pass before the mirrors copy the committed
445
+ * render.
446
+ * フックはホストの描画中の印をフック内部のリデューサーに持つ。範囲の最初の duringRender(action) がホストの描画の中でそれを渡し、React はその更新を
447
+ * その描画の続きだけに残すため、本体の実行が範囲を引き継ぐのはその続きだけになる (RenderScope.begin)。範囲の挿入副作用は、確定する描画の範囲を
448
+ * その確定のどのレイアウト副作用よりも前に当て (子孫のレイアウト副作用が先に返す関数を呼び得る)、隠れた Activity の中の確定でも当てる。
449
+ * レイアウト副作用はその確定が当てた通知を届ける。フックはステートの写しより前に呼ぶため、写しが確定した描画を写す前に範囲が当たる。
450
+ *
451
+ * @param owner - The hook's name, which the scope's errors name / フックの名前 (範囲のエラーが名乗る)
452
+ * @param states - The states this run holds, in a fixed order / この実行が持つステート (順序は固定)
453
+ * @returns The hook's render scope, the same object for the life of the component, so its duringRender keeps its identity too / フックの描画の範囲 (コンポーネントの存続中ずっと同じオブジェクトで、その duringRender の同一性も保たれる)
454
+ */
455
+ export declare function useRenderScope(owner: string, states: readonly unknown[]): RenderScope;
456
+ /**
457
+ * Creates the mirror of a state its returned functions read and write, copied from each commit like useCommittedRef, and records into the state's queue each hand-off a commit adopted from a pass.
458
+ * 返す関数が読み書きするステートの写しを作るフック (useCommittedRef と同じく、確定ごとに写す)。確定が範囲から当てた受け渡しはステートのキューへ記録する。
459
+ *
460
+ * The record is queued from the host's layout effect (StateMirror.recordAdopted), because the commit adopts the hand-off
461
+ * in an insertion effect, where React does not allow scheduling updates. The hooks call this before the layout effect
462
+ * that records their re-placement, so a rebase replays the record of a hand-off before the record of its re-placement.
463
+ * A commit inside a hidden Activity runs no layout effects, so its record is queued when the tree is shown, and the
464
+ * identity guard keeps it from overwriting a newer value.
465
+ * 記録はホストのレイアウト副作用から積む (StateMirror.recordAdopted)。確定は挿入副作用で受け渡しを当て、React はそこで更新を積むことを許さない。
466
+ * フックは収め直しを記録するレイアウト副作用より前にこれを呼ぶため、積み直しは受け渡しの記録を収め直しの記録より先に当てる。隠れた Activity の
467
+ * 中の確定はレイアウト副作用を走らせないため、その記録は木が表示されたときに積まれ、同一性の守りが新しい値を上書きさせない。
468
+ *
469
+ * @param scope - The hook's render scope / フックの描画の範囲
470
+ * @param slot - Index of the state in the scope / 範囲の中のステートの番号
471
+ * @param value - The value this render draws for the state / この描画がステートについて描く値
472
+ * @param setState - The state's setter / ステートの設定関数
473
+ * @returns The mirror, the same object for the life of the component / 写し (コンポーネントの存続中ずっと同じオブジェクト)
474
+ */
475
+ export declare function useStateMirror<T>(scope: RenderScope, slot: number, value: T, setState: Dispatch<SetStateAction<T>>): StateMirror<T>;
476
+ /**
477
+ * Creates a value the hook keeps for its returned functions, written through the render scope.
478
+ * フックが返す関数のために持ち、描画の範囲を通して書く値を作るフック。
479
+ *
480
+ * @param scope - The hook's render scope / フックの描画の範囲
481
+ * @param slot - Index of the state the value belongs to / 値が属するステートの番号
482
+ * @param initial - The value it starts with / 最初の値
483
+ * @returns The ref, the same object for the life of the component / ref (コンポーネントの存続中ずっと同じオブジェクト)
484
+ */
485
+ export declare function useScopedRef<T>(scope: RenderScope, slot: number, initial: T): ScopedRef<T>;
486
+ //# sourceMappingURL=renderScope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderScope.d.ts","sourceRoot":"","sources":["../src/renderScope.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAA6D,MAAM,OAAO,CAAA;AAErH,OAAO,EAAE,eAAe,EAAsB,MAAM,mBAAmB,CAAA;AAWvE;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC7B,kEAAkE;IAClE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,IAAI,CAAA;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACvB,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI,CAAA;CAC5D;AAED;;;GAGG;AACH,qBAAa,UAAU;IA+Bf,QAAQ,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE;IACnC,QAAQ,CA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AK,EAAE,WAAW,EAC1B,IAAI,EAAE,MAAM;IAKzB;;;;;OAKG;IACH,IAAI,OAAO,IAAI,CAAC,CAGf;IAED;;;;;OAKG;IACH,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,EAQlB;IAED;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;CAGhC;AAYD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,WAAW,CAarF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAOnI;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAG1F"}
@@ -1,3 +1,4 @@
1
+ import { PeriodSliderUnit } from './PeriodSlider.js';
1
2
  /**
2
3
  * Date-typed props every selector carries.
3
4
  * 全セレクタが持つ Date 型 Props。
@@ -13,39 +14,58 @@ export interface SelectorDateProps {
13
14
  maxDate?: Date;
14
15
  }
15
16
  /**
16
- * Key of a valid Date at a selector's unit: the time of the start of the unit containing it.
17
- * セレクタの単位での有効な Date のキー (その日付を含む単位の始まりの時刻)。
17
+ * Key of a valid Date at a selector's unit: the integer key of the unit containing it, as the selector's validation reads that unit, paired with the year start.
18
+ * セレクタの単位での有効な Date のキー (セレクタの検証が読むとおりの、その日付を含む単位の整数キーと年の開始月の対)。
18
19
  *
19
- * The memo comparators compare the shown date by this key and the uncontrolled selection adopts `initialDate` exactly when it
20
- * changes (`useUncontrolledSelection`), so a render a comparator skips is a render that would not adopt.
21
- * メモ比較器は表示する日付をこのキーで比べ、非制御の選択はこのキーが変わったときにだけ `initialDate` を取り込む
20
+ * The unit key is keyInsideDateRange's, the function encodeInsideDateRange validates the selectors' Date props with, so the key is
21
+ * `NaN` exactly where that validation throws for the date, by construction. yearStartMonth is an integer in [0, 11], so the pair is
22
+ * injective: a render that changes yearStartMonth changes the key even when the year number stays. The memo comparators compare the
23
+ * shown date by this key and the uncontrolled selection adopts `initialDate` exactly when it changes (`useUncontrolledSelection`), so a
24
+ * render a comparator skips is a render that would not adopt.
25
+ * 単位のキーは keyInsideDateRange のもの (encodeInsideDateRange がセレクタの Date 型 Props の検証に使う関数) であり、キーが `NaN` になるのは、
26
+ * その検証がその日付で例外を投げる場合と構成上一致する。yearStartMonth は 0 以上 11 以下の整数であるため対は単射で、yearStartMonth を変えた描画は
27
+ * 年番号が変わらなくてもキーが変わる。メモ比較器は表示する日付をこのキーで比べ、非制御の選択はこのキーが変わったときにだけ `initialDate` を取り込む
22
28
  * (`useUncontrolledSelection`)。比較器が省く描画は、取り込みを起こさない描画と一致する。
23
29
  *
24
- * @param date - Date to key / キー化する日付
25
- * @param unitStart - Start of the selector's unit containing a valid Date, or an Invalid Date where the selector's validation rejects that date / 有効な Date を含むセレクタの単位の始まり (セレクタの検証がその日付を拒む場合は Invalid Date)
26
- * @returns Time of the unit's start; `NaN` where `unitStart` answers an Invalid Date / 単位の始まりの時刻 (`unitStart` が Invalid Date を返す日付では `NaN`)
30
+ * @param date - Valid Date to key / キー化する有効な Date
31
+ * @param unit - Unit the selector draws / セレクタが描く単位
32
+ * @param yearStartMonth - Calendar month a year starts in, 0-based: YearSelector's yearStartMonth, 0 for the other selectors / 1 年が始まる暦月 (0 始まり。YearSelector はその yearStartMonth、他のセレクタは 0)
33
+ * @returns `key * 12 + yearStartMonth` for the key keyInsideDateRange returns, or `NaN` where it returns null (the unit starts outside the Date range) / keyInsideDateRange が返すキーに対する `key * 12 + yearStartMonth` (null を返す日付、つまり単位の始まりが表現範囲の外なら `NaN`)
34
+ * @throws RangeError when date is not a valid Date or yearStartMonth is not an integer in [0, 11] (raised by keyInsideDateRange) / date が有効な Date でない場合、yearStartMonth が 0 以上 11 以下の整数でない場合 (keyInsideDateRange が送出)
27
35
  */
28
- export declare const selectorUnitKey: (date: Date, unitStart: (date: Date) => Date) => number;
36
+ export declare const selectorUnitKey: (date: Date, unit: PeriodSliderUnit, yearStartMonth: number) => number;
29
37
  /**
30
38
  * Whether two renders of a selector carry the same Date-typed props at the selector's unit, never judging an unusable one equal.
31
39
  * 2 つの描画の Date 型 Props がセレクタの単位で等しいかの判定 (使えない値は等しいとみなさない)。
32
40
  *
33
- * Each prop keys to the time of `unitStart` through `optionalDateMemoKey`. `unitStart` answers an Invalid Date exactly where the
34
- * selector's validation rejects a valid Date (a unit that starts outside the Date range and, for `DateSelector variant="split-dropdown"`,
35
- * a date whose year does), so the key is `NaN` exactly where that validation throws for the prop: a non-Date, `null`, an Invalid Date,
36
- * or such a date. The shown date (`value` when controlled, `initialDate` otherwise) and both bounds are compared by that key. A
37
- * controlled render does not draw `initialDate`, so its moves are not compared, but a render that supplies an unusable one is never
38
- * skipped: the selector validates every Date prop on every render.
39
- * 各 Props を `unitStart` の時刻で `optionalDateMemoKey` によりキー化する。`unitStart` が Invalid Date を返すのは、セレクタの検証が有効な Date を
40
- * 拒む場合 (単位の始まりが Date の表現範囲の外。`DateSelector variant="split-dropdown"` では年の始まりが外の日付も) とちょうど一致するため、
41
- * キーが `NaN` になるのは、その検証がその Props で例外を投げる場合 (Date でない値・`null`・Invalid Date・そうした日付) とちょうど一致する。
42
- * 表示する日付 (制御なら `value`、それ以外は `initialDate`) と両境界をそのキーで比べる。制御中は `initialDate` を描かないため
43
- * 動きは比べないが、使えない値を渡した描画は省かない (セレクタは毎描画ですべての Date 型 Props を検証する)。
41
+ * Each prop keys through `optionalDateMemoKey` with `keyOf`, the selector's `selectorUnitKey` closure, so the key is `NaN` exactly
42
+ * where the selector's validation throws for the prop, by construction: a non-Date, `null`, an Invalid Date, or a date whose unit
43
+ * starts outside the Date range (for `DateSelector variant="split-dropdown"`, also a date whose year does). The shown date (`value`
44
+ * when controlled, `initialDate` otherwise) and both bounds are compared by that key. A controlled render does not draw `initialDate`,
45
+ * so its moves are not compared, but a render that supplies an unusable one is never skipped: the selector validates every Date prop
46
+ * on every render.
47
+ * 各 Props を `keyOf` (セレクタの `selectorUnitKey` のクロージャ) で `optionalDateMemoKey` によりキー化するため、キーが `NaN` になるのは、
48
+ * セレクタの検証がその Props で例外を投げる場合 (Date でない値・`null`・Invalid Date・単位の始まりが表現範囲の外の日付。
49
+ * `DateSelector variant="split-dropdown"` では年の始まりが外の日付も) と構成上一致する。表示する日付 (制御なら `value`、それ以外は `initialDate`) と
50
+ * 両境界をそのキーで比べる。制御中は `initialDate` を描かないため動きは比べないが、使えない値を渡した描画は省かない
51
+ * (セレクタは毎描画ですべての Date 型 Props を検証する)。
52
+ *
53
+ * One call runs `keyOf` once for each Date value it reads (the shown date, minDate and maxDate of each render, and the next render's
54
+ * initialDate when that render is controlled) and stops at the first check that fails, so it keys at most seven values whatever the
55
+ * range or the candidate lists (the selectors' `keyOf` runs keyInsideDateRange once per value, and up to twice for
56
+ * `DateSelector variant="split-dropdown"`, which also keys the year). No key is kept between calls: a key cached for a Date object
57
+ * outlives an in-place change of that Date and would skip the render whose validation throws, and a key kept from the previous call
58
+ * may belong to another instance, since one comparator serves every instance, or to a render React discarded.
59
+ * 1 回の呼び出しは、読む Date の値 1 つにつき `keyOf` を 1 回呼び (前回と今回の描画の表示する日付・minDate・maxDate と、今回の描画が制御中なら
60
+ * その initialDate)、最初に成り立たない判定で打ち切る。キー化は範囲や候補の一覧に依らず高々 7 回 (セレクタの `keyOf` は値 1 つにつき
61
+ * keyInsideDateRange を 1 回、年もキーにする `DateSelector variant="split-dropdown"` は高々 2 回呼ぶ)。キーは呼び出しをまたいで保持しない
62
+ * (Date を鍵にしたキャッシュは、その場で書き換えた Date に書き換え前のキーを返して検証が送出する描画を省かせ、前回の呼び出しのキーは、
63
+ * 比較器が全インスタンスで共有されるため別のインスタンスのものにも、React が捨てた描画のものにもなり得る)。
44
64
  *
45
65
  * @param prev - Props of the previous render / 前回の描画の Props
46
66
  * @param next - Props of the next render / 今回の描画の Props
47
- * @param unitStart - Start of the selector's unit (year, month or day) containing a valid Date, or an Invalid Date where the selector's validation rejects that date; it reads the same functions and predicates as that validation / 有効な Date を含むセレクタの単位 (年・月・日) の始まり (セレクタの検証がその日付を拒む場合は Invalid Date)。その検証と同じ関数・述語を読む
67
+ * @param keyOf - Unit key of a valid Date: the selector's `selectorUnitKey` closure, the key its uncontrolled selection adopts by / 有効な Date の単位のキー (セレクタの `selectorUnitKey` のクロージャ。非制御の選択が取り込みを決めるキーと同じ)
48
68
  * @returns `true` when the Date props allow the next render to be skipped / Date 型 Props に関して今回の描画を省けるなら `true`
49
69
  */
50
- export declare const areSelectorDatePropsEqual: (prev: SelectorDateProps, next: SelectorDateProps, unitStart: (date: Date) => Date) => boolean;
70
+ export declare const areSelectorDatePropsEqual: (prev: SelectorDateProps, next: SelectorDateProps, keyOf: (date: Date) => number) => boolean;
51
71
  //# sourceMappingURL=selectorMemo.d.ts.map