@aiquants/period-slider 0.16.0 → 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.
Files changed (39) hide show
  1. package/CHANGELOG.md +215 -0
  2. package/README.md +55 -30
  3. package/dist/DateSelector.d.ts +2 -2
  4. package/dist/DateSelector.d.ts.map +1 -1
  5. package/dist/MonthSelector.d.ts +2 -2
  6. package/dist/MonthSelector.d.ts.map +1 -1
  7. package/dist/PeriodSlider.d.ts +235 -40
  8. package/dist/PeriodSlider.d.ts.map +1 -1
  9. package/dist/YearSelector.d.ts +4 -2
  10. package/dist/YearSelector.d.ts.map +1 -1
  11. package/dist/index.cjs +1 -1
  12. package/dist/index.js +2459 -2340
  13. package/dist/inputValue.d.ts +90 -21
  14. package/dist/inputValue.d.ts.map +1 -1
  15. package/dist/selectorMemo.d.ts +14 -0
  16. package/dist/selectorMemo.d.ts.map +1 -1
  17. package/dist/selectorStep.d.ts +13 -10
  18. package/dist/selectorStep.d.ts.map +1 -1
  19. package/dist/useCommittedRef.d.ts +80 -0
  20. package/dist/useCommittedRef.d.ts.map +1 -0
  21. package/dist/usePeriodSlider.d.ts +42 -18
  22. package/dist/usePeriodSlider.d.ts.map +1 -1
  23. package/dist/useUncontrolledSelection.d.ts +27 -0
  24. package/dist/useUncontrolledSelection.d.ts.map +1 -0
  25. package/dist/vernierStep.d.ts +10 -1
  26. package/dist/vernierStep.d.ts.map +1 -1
  27. package/package.json +1 -1
  28. package/src/DateSelector.tsx +15 -17
  29. package/src/MonthSelector.tsx +11 -15
  30. package/src/PeriodSlider.tsx +430 -148
  31. package/src/YearSelector.tsx +20 -13
  32. package/src/inputValue.ts +151 -21
  33. package/src/selectorMemo.ts +18 -3
  34. package/src/selectorStep.ts +24 -29
  35. package/src/useCommittedRef.ts +206 -0
  36. package/src/usePeriodSlider.ts +342 -208
  37. package/src/useUncontrolledSelection.ts +54 -0
  38. package/src/valueSet.ts +1 -1
  39. package/src/vernier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IACnL,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IACvC,mLAAmL;IACnL,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IACvC,kRAAkR;IAClR,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IAClC,ghBAAghB;IAChhB,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACxC,ugBAAugB;IACvgB,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACxC,oEAAoE;IACpE,YAAY,EAAE,MAAM,IAAI,CAAA;IACxB,wEAAwE;IACxE,uBAAuB,EAAE,aAAa,CAAA;IACtC,sEAAsE;IACtE,qBAAqB,EAAE,aAAa,CAAA;IACpC,iIAAiI;IACjI,kBAAkB,EAAE,aAAa,CAAA;IACjC,iGAAiG;IACjG,WAAW,EAAE,6BAA6B,CAAA;CAC7C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,2BAA2B,CAkZxG"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Uncontrolled selection of a selector: adopts `initialDate` during the render that turns the selector uncontrolled or moves `initialDate` to another unit, and otherwise keeps the held value, the user's latest choice included.
3
+ * セレクタの非制御の選択 (非制御になった描画と `initialDate` が別の単位へ動いた描画で `initialDate` を描画中に取り込み、それ以外は利用者の最後の選択を含む保持値を持ち越す)。
4
+ *
5
+ * The unit key is `selectorUnitKey(shownDate, unitStart)`, the key the selector's memo comparator compares the shown date by, so a
6
+ * render the comparator skips is one that would not adopt, and a move within the unit keeps the user's choice whether or not the
7
+ * render is skipped. The mount seeds the state; a later adoption is recorded with a render-phase state update (React's "adjusting
8
+ * state when a prop changes") and the adopted value is returned in the same pass, so no commit draws the value held before. A
9
+ * controlled render records `null`, so switching back adopts `initialDate` even when it did not move. Removing the null record
10
+ * would let a pick made before a controlled interlude come back when the host drops "value" with an unchanged "initialDate". The
11
+ * key recorded is the key the re-run computes, so the update is idempotent and StrictMode's double render or a discarded
12
+ * concurrent render leaves nothing behind.
13
+ * 単位のキーは `selectorUnitKey(shownDate, unitStart)` で、セレクタのメモ比較器が表示する日付を比べるキーと同じ。このため比較器が省く描画は
14
+ * 取り込みを起こさない描画であり、単位の中の移動は、描画が省かれても省かれなくても利用者の選択を残す。マウントは状態の初期化で取り込み、
15
+ * それ以降の取り込みは描画中の状態更新 (React の「Props の変化に合わせて状態を調整する」) で記録し、同じ描画で取り込んだ値を返すため、
16
+ * どの確定も以前の保持値を描かない。制御の描画は `null` を記録するため、非制御へ戻した描画は `initialDate` が動いていなくても取り込む。
17
+ * null の記録を省くと、制御を挟む前の選択が、initialDate を変えずに value を外した描画で戻る。記録するキーは再実行が求めるキーと等しく、
18
+ * 更新は冪等であり、StrictMode の二重描画も捨てられた並行描画も何も残さない。
19
+ *
20
+ * @param shownDate - Date the render shows (`value` when controlled, `initialDate` otherwise), validated by the selector before its first hook so that its unit start is a valid Date (a `NaN` key would never equal itself) / 描画が示す日付 (制御なら `value`、それ以外は `initialDate`)。単位の始まりが有効な Date になるよう、セレクタが最初のフックより前に検証済み (`NaN` のキーは自身と等しくならないため)
21
+ * @param isControlled - Whether the render is controlled (`value !== undefined`) / 制御の描画か (`value !== undefined`)
22
+ * @param unitStart - Start of the selector's unit containing a date, the function its memo comparator keys the shown date with / 日付を含むセレクタの単位の始まり (メモ比較器が表示する日付のキーに使う関数)
23
+ * @param adopt - Held value adopted from a date / 日付から取り込む保持値
24
+ * @returns The held value the render draws when uncontrolled, and the setter recording the user's choice / 非制御の描画が描く保持値と、利用者の選択を記録する更新関数
25
+ */
26
+ export declare function useUncontrolledSelection<T>(shownDate: Date, isControlled: boolean, unitStart: (date: Date) => Date, adopt: (date: Date) => T): readonly [T, (choice: T) => void];
27
+ //# sourceMappingURL=useUncontrolledSelection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useUncontrolledSelection.d.ts","sourceRoot":"","sources":["../src/useUncontrolledSelection.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC,CAUhL"}
@@ -132,6 +132,15 @@ export interface VernierSelectorStepTargets {
132
132
  /** Commit of ▶, or null when ▶ is unavailable / ▶ の確定内容 (押せなければ null) */
133
133
  readonly next: VernierSelectorStep | null;
134
134
  }
135
+ /**
136
+ * Whether two date pairs name the same instants.
137
+ * 2 つの日付の組が同じ時刻を指すか。
138
+ *
139
+ * @param a - First pair / 1 つ目の組
140
+ * @param b - Second pair / 2 つ目の組
141
+ * @returns True when both ends are the same instants / 両端が同じ時刻なら true
142
+ */
143
+ export declare const isSamePair: (a: readonly [Date, Date], b: readonly [Date, Date]) => boolean;
135
144
  /**
136
145
  * What each of a vernier selector's ◀▶ commits: the macro window and the micro selection, per direction.
137
146
  * ノギスのセレクタの ◀▶ がそれぞれ確定するもの (マクロ窓とミクロ選択) を向きごとに求める関数。
@@ -173,7 +182,7 @@ export interface VernierSelectorStepTargets {
173
182
  *
174
183
  * @param options - The vernier as it stands, the pressed row and its rules / 今のノギス・押された行とその規則
175
184
  * @returns Commit per direction, or null where a direction is unavailable / 向きごとの確定内容 (押せない向きは null)
176
- * @throws RangeError when an option is missing or malformed: an unknown `row`, `shows` or unit, an invalid `yearStartMonth`, bounds that are invalid or not strictly ordered, a macro window or micro selection that is not two valid Dates in order (the macro window also in time, as the component requires), candidates that are malformed (a hole of a sparse list included) or all outside the domain, or a malformed rule / オプションが欠落・不正な場合 (未知の `row`・`shows`・単位、不正な `yearStartMonth`、不正または厳密に順序づいていない境界、順序どおりの有効な 2 つの Date でないマクロ窓・ミクロ選択 (マクロ窓は本体と同じく時刻でも)、不正 (疎配列の穴を含む) または全て定義域外の候補、整っていない規則)
185
+ * @throws RangeError when an option is missing or malformed: an unknown `row`, `shows` or unit, an invalid `yearStartMonth`, bounds that are invalid or not strictly ordered, a minDate whose macroUnit or microUnit starts outside the Date range (`resolveVernierSelectorSteps: minDate must fall in a <unit> that starts inside the Date range (received: ...)`, macroUnit first), a macro window or micro selection that is not two valid Dates in order (the macro window also in time, as the component requires), candidates that are malformed (a hole of a sparse list included) or all outside the domain, or a malformed rule / オプションが欠落・不正な場合 (未知の `row`・`shows`・単位、不正な `yearStartMonth`、不正または厳密に順序づいていない境界、macroUnit または microUnit の始まりが Date の表現範囲の外にある minDate (macroUnit を先に判定)、順序どおりの有効な 2 つの Date でないマクロ窓・ミクロ選択 (マクロ窓は本体と同じく時刻でも)、不正 (疎配列の穴を含む) または全て定義域外の候補、整っていない規則)
177
186
  */
178
187
  export declare const resolveVernierSelectorSteps: (options: ResolveVernierSelectorStepsOptions) => VernierSelectorStepTargets;
179
188
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"vernierStep.d.ts","sourceRoot":"","sources":["../src/vernierStep.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAkB,KAAK,iBAAiB,EAAuB,KAAK,gBAAgB,EAAuE,MAAM,gBAAgB,CAAA;AACxL,OAAO,EAA0G,KAAK,iBAAiB,EAA+B,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AACvN,OAAO,EAAE,KAAK,WAAW,EAAiL,MAAM,YAAY,CAAA;AAE5N;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAA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AAA;IACjC,oFAAoF;IACpF,QAAQ,CAAC,cAAc,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;CACxC;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACvC,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAAA;IAC7C,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAA;CAC5C;AA6ED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GAAI,GAAG,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,GAAG,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,KAAG,OAAiF,CAAA;AA0BjK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,2BAA2B,GAAI,SAAS,kCAAkC,KAAG,0BAuNzF,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiquants/period-slider",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "Customizable period slider and year/month/date selectors for React",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -31,7 +31,7 @@
31
31
 
32
32
  import { parseISO } from "date-fns"
33
33
  import type React from "react"
34
- import { memo, useCallback, useEffect, useMemo, useState } from "react"
34
+ import { memo, useCallback, useMemo } from "react"
35
35
  import {
36
36
  createContinuousDateOptionDomain,
37
37
  createDiscreteDateOptionDomain,
@@ -45,7 +45,7 @@ import {
45
45
  resolveDiscreteIndexWindow,
46
46
  toDaySerial,
47
47
  } from "./dateOptionDomain"
48
- import { dateMemoKey, describeValue, isValidDate } from "./inputValue"
48
+ import { dateMemoKey, describeValue, isCandidateListInput, isValidDate } from "./inputValue"
49
49
  import { areLabelOverridesEqual, type PeriodSliderLabelOverrides, type PeriodSliderLocale } from "./labels"
50
50
  import { formatOptionText } from "./optionText"
51
51
  import { formatLabel, type PeriodOptionFormatter, type PeriodSliderUnit } from "./PeriodSlider"
@@ -53,6 +53,7 @@ import { STEPPER_ROW_GAP_CLASS, StepperButton } from "./StepperButton"
53
53
  import { areSelectorDatePropsEqual } from "./selectorMemo"
54
54
  import { findSelectorStepperFault, type SelectorStepper } from "./selectorStep"
55
55
  import { useResolvedLabels } from "./useResolvedLabels"
56
+ import { useUncontrolledSelection } from "./useUncontrolledSelection"
56
57
  import { VirtualDateDropdown } from "./VirtualDateDropdown"
57
58
  import { type DrawnValues, drawnValuesHas, drawnValuesNeighbour } from "./valueSet"
58
59
 
@@ -70,7 +71,7 @@ import { type DrawnValues, drawnValuesHas, drawnValuesNeighbour } from "./valueS
70
71
  export interface DateSelectorProps {
71
72
  /** Controlled selected date; required unless `initialDate` is supplied; must be a valid Date / 選択日付 (外部制御用・`initialDate` 未指定時は必須・Invalid Date 不可) */
72
73
  value?: Date
73
- /** Initial selected date; required unless `value` is supplied; must be a valid Date / 初期選択日付 (非制御用・`value` 未指定時は必須・Invalid Date 不可) */
74
+ /** Initial selected date; required unless `value` is supplied; must be a valid Date; adopted during the render that turns the selector uncontrolled or moves it to another day, while a move within the day keeps the user's choice / 初期選択日付 (非制御用・`value` 未指定時は必須・Invalid Date 不可。非制御になった描画と別の日へ動かした描画のうちに取り込み、同じ日の中の移動では利用者の選択を置き換えない) */
74
75
  initialDate?: Date
75
76
  /** Callback triggered when a selectable date is chosen; the ◀▶ call it too unless `stepper` takes them over / 選択可能な日付が選ばれた時のコールバック (`stepper` が引き受けない限り ◀▶ もこれを呼ぶ) */
76
77
  onChange?(date: Date): void
@@ -91,7 +92,7 @@ export interface DateSelectorProps {
91
92
  minDate?: Date
92
93
  /** Maximum selectable date; intersected with maxYear when both are given / 選択可能範囲の最大日付 (maxYear 併用時は厳しい方を採用) */
93
94
  maxDate?: Date
94
- /** Discrete allowed dates list; an empty array means nothing is selectable. `undefined` is accepted explicitly, so `allowedDates={undefined}` after spreading a hook's selector props opts out of its candidates / 選択可能な離散日付配列 (空配列は「選択可能日なし」)。`undefined` を明示でき、フックのセレクタ Props を広げた後ろの `allowedDates={undefined}` で候補を外せる */
95
+ /** Discrete allowed dates list; an empty array means nothing is selectable, and a supplied value that is not an array (`null` included) throws RangeError. `undefined` is accepted explicitly, so `allowedDates={undefined}` after spreading a hook's selector props opts out of its candidates / 選択可能な離散日付配列 (空配列は「選択可能日なし」、配列でない指定値 (`null` を含む) は RangeError)。`undefined` を明示でき、フックのセレクタ Props を広げた後ろの `allowedDates={undefined}` で候補を外せる */
95
96
  allowedDates?: Date[] | undefined
96
97
  /**
97
98
  * UI Variant:
@@ -414,6 +415,11 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
414
415
  if (variant === "split-dropdown" && allowedDates !== undefined) {
415
416
  throw new RangeError('DateSelector: variant="split-dropdown" cannot honour "allowedDates"; use variant="dropdown" or variant="date" for a discrete date set')
416
417
  }
418
+ // 配列でない値 (null・単独の Date・文字列) は、下の境界の要否の判定を `=== undefined` で素通りし、キーの文字列化の `.map` で
419
+ // 名前を名乗らない TypeError になる
420
+ if (!isCandidateListInput(allowedDates)) {
421
+ throw new RangeError(`DateSelector: "allowedDates" must be an array of Dates (received ${describeValue(allowedDates)})`)
422
+ }
417
423
 
418
424
  const effectiveDate = value ?? initialDate
419
425
  if (effectiveDate === undefined) {
@@ -433,15 +439,14 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
433
439
  // ラベル解決は最初のフック。日付 Props の検証を全て済ませてから呼び、両方が不正なら日付側を先に報告する
434
440
  const resolvedLabels = useResolvedLabels(locale, labels)
435
441
 
436
- const [currentDate, setCurrentDate] = useState<Date>(() => toStartOfDay(effectiveDate))
437
-
438
442
  const isControlled = value !== undefined
443
+ // 分割セレクトの比較器が読む splitDropdownDayStart は、最初のフックより前の検証が拒む日付でだけ toStartOfDay と異なるため、キーはどの変種でも同じ
444
+ const [currentDate, setCurrentDate] = useUncontrolledSelection(effectiveDate, isControlled, toStartOfDay, toStartOfDay)
439
445
  const valueTime = value?.getTime()
440
446
  const activeDate = useMemo(() => (value !== undefined ? toStartOfDay(value) : currentDate), [valueTime, currentDate])
441
- // 非制御の選択は以前の描画から持ち越す。日だけを描く変種のあいだに -271821 年へ動かした選択は境界を後から狭めても残り、制御中は
442
- // 更新されないため、その前の非制御の描画が残した選択も制御から非制御へ戻したときに現れる。どちらも Props の検証を全て通ったまま
443
- // 年の部位を名指せない日を描かせるため、ここで止める。initialDate の取り込みは描画の確定後なので、分割セレクトへの切り替えでも
444
- // 制御から非制御への切り替えでも、同じ描画で渡した initialDate はこの描画に届かない
447
+ // 非制御の選択は、非制御になった描画と initialDate が別の日へ動いた描画でこの描画のうちに取り込み、それ以外は利用者の選択を
448
+ // 持ち越す。日だけを描く変種のあいだに利用者が -271821 年へ動かした選択は、境界を後から狭めても残り、initialDate を同じ日に
449
+ // 置いたまま分割セレクトへ切り替えると、Props の検証を全て通ったまま年の部位を名指せない日を描かせるため、ここで止める
445
450
  if (variant === "split-dropdown" && !isControlled && !yearStartsInsideDateRange(activeDate)) {
446
451
  throw new RangeError(
447
452
  `DateSelector: variant="split-dropdown" cannot draw the uncontrolled selection held from an earlier render (holding ${describeValue(activeDate)}), because that selection's year starts outside the Date range; control the date with "value" to decide what the split dropdown holds`,
@@ -517,13 +522,6 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
517
522
  // 分割セレクトが表現範囲の端の年・月の可否を尋ねただけで描画が止まる
518
523
  const isSelectable = (candidate: Date): boolean => !Number.isNaN(candidate.getTime()) && drawnValuesHas(dayDrawn, toDaySerial(candidate))
519
524
 
520
- // 外部からの initialDate 変更に追従 (制御時は value がそのまま真実の源)
521
- const effectiveTime = effectiveDate.getTime()
522
- useEffect(() => {
523
- if (isControlled) return
524
- setCurrentDate(toStartOfDay(effectiveDate))
525
- }, [isControlled, effectiveTime])
526
-
527
525
  const emit = (nextDate: Date) => {
528
526
  if (disabled) return
529
527
  const normalized = toStartOfDay(nextDate)
@@ -22,14 +22,15 @@
22
22
  */
23
23
 
24
24
  import type React from "react"
25
- import { memo, useEffect, useMemo, useState } from "react"
26
- import { describeValue, isValidDate } from "./inputValue"
25
+ import { memo, useMemo } from "react"
26
+ import { describeValue, isCandidateListInput, isValidDate } from "./inputValue"
27
27
  import { areLabelOverridesEqual, type PeriodSliderLabelOverrides, type PeriodSliderLocale } from "./labels"
28
28
  import { formatIsoYear, formatLabel, type PeriodOptionFormatter } from "./PeriodSlider"
29
29
  import { STEPPER_ROW_GAP_CLASS, StepperButton } from "./StepperButton"
30
30
  import { areSelectorDatePropsEqual } from "./selectorMemo"
31
31
  import { findSelectorStepperFault, type SelectorStepper } from "./selectorStep"
32
32
  import { useResolvedLabels } from "./useResolvedLabels"
33
+ import { useUncontrolledSelection } from "./useUncontrolledSelection"
33
34
  import { type DrawnValues, drawnValuesHas, drawnValuesNeighbour } from "./valueSet"
34
35
 
35
36
  /**
@@ -46,7 +47,7 @@ import { type DrawnValues, drawnValuesHas, drawnValuesNeighbour } from "./valueS
46
47
  export interface MonthSelectorProps {
47
48
  /** Controlled selected date; required unless `initialDate` is supplied / 選択日付 (外部制御用・`initialDate` 未指定時は必須) */
48
49
  value?: Date
49
- /** Initial selected date; required unless `value` is supplied / 選択日付 (非制御用・`value` 未指定時は必須) */
50
+ /** Initial selected date; required unless `value` is supplied; adopted during the render that turns the selector uncontrolled or moves it to another month, while a move within the month keeps the user's choice / 選択日付 (非制御用・`value` 未指定時は必須。非制御になった描画と別の月へ動かした描画のうちに取り込み、同じ月の中の移動では利用者の選択を置き換えない) */
50
51
  initialDate?: Date
51
52
  /** Callback triggered when a selectable month is chosen; the ◀▶ call it too unless `stepper` takes them over / 選択可能な月が選ばれた時のコールバック (`stepper` が引き受けない限り ◀▶ もこれを呼ぶ) */
52
53
  onChange?(date: Date, yyyymm: number): void
@@ -72,7 +73,7 @@ export interface MonthSelectorProps {
72
73
  minDate?: Date
73
74
  /** Upper bound date (truncated to its month); combined with `maxYear` as the stricter of the two / 可能範囲の最大日付 (月単位に切り捨て)。`maxYear` とは厳しい方を採用 */
74
75
  maxDate?: Date
75
- /** Discrete allowed months (day part ignored), intersected with the bounds; an empty array means nothing is selectable / 選択可能な離散月配列 (日は無視・境界と積を取る・空配列は「選択可能月なし」) */
76
+ /** Discrete allowed months (day part ignored), intersected with the bounds; an empty array means nothing is selectable, and a supplied value that is not an array (`null` or a string included) throws RangeError naming the list / 選択可能な離散月配列 (日は無視・境界と積を取る・空配列は「選択可能月なし」・配列でない指定値 (`null`・文字列を含む) は一覧を名指す RangeError) */
76
77
  allowedMonths?: Date[] | undefined
77
78
  /** Warning style flag / 警告枠スタイル適用フラグ */
78
79
  isWarning?: boolean
@@ -381,6 +382,11 @@ const MonthSelectorComponent = (props: MonthSelectorProps): React.JSX.Element =>
381
382
  assertValidDateProp(maxDate, "maxDate", SENTINEL_BOUND_REMEDY)
382
383
  assertValidYearProp(minYear, "minYear", 0)
383
384
  assertValidYearProp(maxYear, "maxYear", 11)
385
+ // 配列でない値を要素の検証へ回すと、文字列は 1 文字ずつ要素として読まれて一覧ではなく `allowedMonths[0]` を名指し、null や単独の Date は
386
+ // 名前を名乗らない TypeError になる
387
+ if (!isCandidateListInput(allowedMonths)) {
388
+ throw new RangeError(`MonthSelector: \`allowedMonths\` must be an array of Dates, received ${describeValue(allowedMonths)}.`)
389
+ }
384
390
  if (allowedMonths !== undefined) {
385
391
  // 添字で回すのは疎配列の穴も要素として名指すため (forEach は穴を飛ばし、後段の走査が undefined を読んで落ちる)
386
392
  for (let index = 0; index < allowedMonths.length; index++) {
@@ -406,9 +412,8 @@ const MonthSelectorComponent = (props: MonthSelectorProps): React.JSX.Element =>
406
412
  // ラベル解決は最初のフック。日付 Props の検証を全て済ませてから呼び、両方が不正なら日付側を先に報告する
407
413
  const resolvedLabels = useResolvedLabels(locale, labels)
408
414
 
409
- const [currentDate, setCurrentDate] = useState<Date>(() => monthStart(effectiveDate.getFullYear(), effectiveDate.getMonth()))
410
-
411
415
  const isControlled = value !== undefined
416
+ const [currentDate, setCurrentDate] = useUncontrolledSelection(effectiveDate, isControlled, monthStartOf, monthStartOf)
412
417
  const activeDate = useMemo(() => (value !== undefined ? monthStart(value.getFullYear(), value.getMonth()) : currentDate), [value?.getTime(), currentDate])
413
418
 
414
419
  const minTime = minDate?.getTime()
@@ -444,15 +449,6 @@ const MonthSelectorComponent = (props: MonthSelectorProps): React.JSX.Element =>
444
449
  // 存在しない月 (表現範囲の端を越えて組み立てた年月) はどの集合にも属さない。月通番へ写す前に落とす
445
450
  const isSelectable = (candidate: Date): boolean => !Number.isNaN(candidate.getTime()) && drawnValuesHas(monthDrawn, monthIndexOf(candidate))
446
451
 
447
- // 外部からの initialDate 変更に追従 (制御時は value がそのまま真実の源)
448
- const effectiveTime = effectiveDate.getTime()
449
- useEffect(() => {
450
- if (isControlled) return
451
- const next = monthStart(effectiveDate.getFullYear(), effectiveDate.getMonth())
452
- // 同一月の再設定で描画を走らせない
453
- setCurrentDate((prev) => (prev.getTime() === next.getTime() ? prev : next))
454
- }, [isControlled, effectiveTime])
455
-
456
452
  const emit = (nextDate: Date) => {
457
453
  if (disabled) return
458
454
  if (!isSelectable(nextDate)) {