@aiquants/period-slider 0.13.0 → 0.14.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 +81 -3
- package/README.md +194 -78
- package/dist/DateSelector.d.ts +13 -20
- package/dist/DateSelector.d.ts.map +1 -1
- package/dist/MonthSelector.d.ts +13 -14
- package/dist/MonthSelector.d.ts.map +1 -1
- package/dist/PeriodSlider.d.ts +29 -42
- package/dist/PeriodSlider.d.ts.map +1 -1
- package/dist/VirtualDateDropdown.d.ts +8 -0
- package/dist/VirtualDateDropdown.d.ts.map +1 -1
- package/dist/YearSelector.d.ts +13 -14
- package/dist/YearSelector.d.ts.map +1 -1
- package/dist/dateOptionDomain.d.ts +6 -6
- package/dist/dateOptionDomain.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +14 -6
- package/dist/index.d.ts +14 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2129 -2038
- package/dist/labels.d.ts +144 -0
- package/dist/labels.d.ts.map +1 -0
- package/dist/optionText.d.ts +5 -5
- package/dist/optionText.d.ts.map +1 -1
- package/dist/usePeriodSlider.d.ts +16 -8
- package/dist/usePeriodSlider.d.ts.map +1 -1
- package/dist/useResolvedLabels.d.ts +17 -0
- package/dist/useResolvedLabels.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/DateSelector.tsx +51 -73
- package/src/MonthSelector.tsx +48 -64
- package/src/PeriodSlider.tsx +70 -87
- package/src/VirtualDateDropdown.tsx +14 -2
- package/src/YearSelector.tsx +39 -53
- package/src/dateOptionDomain.ts +8 -8
- package/src/index.ts +13 -6
- package/src/labels.ts +407 -0
- package/src/optionText.ts +21 -21
- package/src/usePeriodSlider.ts +46 -18
- package/src/useResolvedLabels.ts +35 -0
package/dist/labels.d.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { VirtualScrollLabels, VirtualScrollLocale } from '@aiquants/virtualscroll';
|
|
2
|
+
/**
|
|
3
|
+
* The UI chrome language of the package (`"en"` | `"ja"`) — the engine's locale set, so the selectors and
|
|
4
|
+
* the embedded scroll chrome always speak one language. A different axis from `formatLocale`, the BCP 47
|
|
5
|
+
* tag that switches the date text to `Intl.DateTimeFormat`.
|
|
6
|
+
* パッケージの UI クローム言語 (`"en"` | `"ja"`) — エンジンのロケール集合そのもので、セレクタと内蔵
|
|
7
|
+
* スクロールクロームが常に同一言語。日付テキストを `Intl.DateTimeFormat` へ切り替える BCP 47 タグ
|
|
8
|
+
* `formatLocale` とは別軸。
|
|
9
|
+
*/
|
|
10
|
+
export type PeriodSliderLocale = VirtualScrollLocale;
|
|
11
|
+
/**
|
|
12
|
+
* The closed label vocabulary: the 7 engine chrome keys of `@aiquants/virtualscroll` plus the 22 own
|
|
13
|
+
* accessible names of the package. Every key has a value in each `PERIOD_SLIDER_LABEL_CATALOGS` entry;
|
|
14
|
+
* consumers override any subset through the `labels` prop (`PeriodSliderLabelOverrides`).
|
|
15
|
+
* 閉じたラベル語彙: `@aiquants/virtualscroll` のエンジンクローム 7 キーとパッケージ固有の 22 アクセシブル名。
|
|
16
|
+
* 全キーが `PERIOD_SLIDER_LABEL_CATALOGS` の各ロケールに値を持ち、利用側は `labels` prop で任意の部分集合を上書き。
|
|
17
|
+
*/
|
|
18
|
+
export type PeriodSliderLabels = VirtualScrollLabels & {
|
|
19
|
+
/** PeriodSlider range mode: lower handle / range モードの下限つまみ (en: "Range start") */
|
|
20
|
+
readonly rangeStart: string;
|
|
21
|
+
/** PeriodSlider range mode: upper handle / range モードの上限つまみ (en: "Range end") */
|
|
22
|
+
readonly rangeEnd: string;
|
|
23
|
+
/** PeriodSlider point mode: the single handle / point モードの単一つまみ (en: "Selected date") */
|
|
24
|
+
readonly selectedDate: string;
|
|
25
|
+
/** PeriodSlider vernier mode: macro lower handle / ノギスのマクロ下限つまみ (en: "Macro range start") */
|
|
26
|
+
readonly macroRangeStart: string;
|
|
27
|
+
/** PeriodSlider vernier mode: macro upper handle / ノギスのマクロ上限つまみ (en: "Macro range end") */
|
|
28
|
+
readonly macroRangeEnd: string;
|
|
29
|
+
/** PeriodSlider vernier range shape: micro lower handle / ノギスのミクロ期間形態の下限つまみ (en: "Micro range start") */
|
|
30
|
+
readonly microRangeStart: string;
|
|
31
|
+
/** PeriodSlider vernier range shape: micro upper handle / ノギスのミクロ期間形態の上限つまみ (en: "Micro range end") */
|
|
32
|
+
readonly microRangeEnd: string;
|
|
33
|
+
/** PeriodSlider vernier point shape: the micro handle / ノギスのミクロ時点形態のつまみ (en: "Micro selected date") */
|
|
34
|
+
readonly microSelectedDate: string;
|
|
35
|
+
/** PeriodSlider stepper moving the value toward minDate / 値を minDate 方向へ動かすステッパー (en: "Decrease") */
|
|
36
|
+
readonly decrease: string;
|
|
37
|
+
/** PeriodSlider stepper moving the value toward maxDate / 値を maxDate 方向へ動かすステッパー (en: "Increase") */
|
|
38
|
+
readonly increase: string;
|
|
39
|
+
/** YearSelector previous-year stepper / YearSelector の前年ステッパー (en: "Previous year") */
|
|
40
|
+
readonly previousYear: string;
|
|
41
|
+
/** YearSelector next-year stepper / YearSelector の翌年ステッパー (en: "Next year") */
|
|
42
|
+
readonly nextYear: string;
|
|
43
|
+
/** YearSelector year select / YearSelector の年セレクト (en: "Year") */
|
|
44
|
+
readonly yearSelect: string;
|
|
45
|
+
/** MonthSelector previous-month stepper / MonthSelector の前月ステッパー (en: "Previous month") */
|
|
46
|
+
readonly previousMonth: string;
|
|
47
|
+
/** MonthSelector next-month stepper / MonthSelector の翌月ステッパー (en: "Next month") */
|
|
48
|
+
readonly nextMonth: string;
|
|
49
|
+
/** MonthSelector year-month select / input[type=month] / MonthSelector の年月セレクト・入力 (en: "Month") */
|
|
50
|
+
readonly monthSelect: string;
|
|
51
|
+
/** DateSelector previous-day stepper / DateSelector の前日ステッパー (en: "Previous day") */
|
|
52
|
+
readonly previousDay: string;
|
|
53
|
+
/** DateSelector next-day stepper / DateSelector の翌日ステッパー (en: "Next day") */
|
|
54
|
+
readonly nextDay: string;
|
|
55
|
+
/** DateSelector date input, and in variant="dropdown" both the combobox and its popup listbox / DateSelector の日付入力 (variant="dropdown" ではコンボボックスとポップアップのリストボックスの双方) (en: "Date") */
|
|
56
|
+
readonly dateSelect: string;
|
|
57
|
+
/** DateSelector variant="split-dropdown" year select / 3 分割の年セレクト (en: "Year") */
|
|
58
|
+
readonly splitYear: string;
|
|
59
|
+
/** DateSelector variant="split-dropdown" month select / 3 分割の月セレクト (en: "Month") */
|
|
60
|
+
readonly splitMonth: string;
|
|
61
|
+
/** DateSelector variant="split-dropdown" day select / 3 分割の日セレクト (en: "Day") */
|
|
62
|
+
readonly splitDay: string;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* The `labels` prop shape: any subset of `PeriodSliderLabels`. An omitted or `undefined` key keeps the catalog
|
|
66
|
+
* value of the chosen locale; keys are closed to `PeriodSliderLabels`.
|
|
67
|
+
* `labels` prop の形: `PeriodSliderLabels` の任意の部分集合。省略・`undefined` のキーは選択ロケールの
|
|
68
|
+
* カタログ値のまま、キーは `PeriodSliderLabels` に閉じる。
|
|
69
|
+
*/
|
|
70
|
+
export type PeriodSliderLabelOverrides = {
|
|
71
|
+
readonly [K in keyof PeriodSliderLabels]?: PeriodSliderLabels[K];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Every label key: the 7 engine keys (`VIRTUAL_SCROLL_LABEL_KEYS`, in engine order) followed by the 22 own
|
|
75
|
+
* keys — the closed key set overrides are validated against.
|
|
76
|
+
* 全ラベルキー: エンジン 7 キー (`VIRTUAL_SCROLL_LABEL_KEYS`、エンジン順) に固有 22 キーを続けたもの —
|
|
77
|
+
* 上書き検証に用いる閉じたキー集合。
|
|
78
|
+
*/
|
|
79
|
+
export declare const PERIOD_SLIDER_LABEL_KEYS: readonly ["scrollUp", "scrollDown", "scrollLeft", "scrollRight", "scrollToTop", "scrollToBottom", "noItems", "rangeStart", "rangeEnd", "selectedDate", "macroRangeStart", "macroRangeEnd", "microRangeStart", "microRangeEnd", "microSelectedDate", "decrease", "increase", "previousYear", "nextYear", "yearSelect", "previousMonth", "nextMonth", "monthSelect", "previousDay", "nextDay", "dateSelect", "splitYear", "splitMonth", "splitDay"];
|
|
80
|
+
/**
|
|
81
|
+
* Frozen full catalogs per locale (outer record and every entry frozen): each entry is the engine catalog
|
|
82
|
+
* `VIRTUAL_SCROLL_LABEL_CATALOGS[locale]` (reused by value — the single source of truth of the 7 chrome
|
|
83
|
+
* strings) overlaid by the own-key catalog of the same locale.
|
|
84
|
+
* ロケール別の凍結済み完全カタログ (外側のレコードと各エントリを凍結): 各エントリはエンジンカタログ
|
|
85
|
+
* `VIRTUAL_SCROLL_LABEL_CATALOGS[locale]` (値を再利用 — 7 クローム文言の単一の真実源) に同ロケールの
|
|
86
|
+
* 固有キーカタログを重ねたもの。
|
|
87
|
+
*/
|
|
88
|
+
export declare const PERIOD_SLIDER_LABEL_CATALOGS: Readonly<Record<PeriodSliderLocale, PeriodSliderLabels>>;
|
|
89
|
+
/**
|
|
90
|
+
* Resolves the effective labels: the catalog of the resolved locale overlaid by `overrides`. Returns the
|
|
91
|
+
* frozen catalog itself (same identity) when `overrides` is `undefined`, otherwise a new frozen object.
|
|
92
|
+
* Inputs are never mutated.
|
|
93
|
+
* 実効ラベルの解決。解決済みロケールのカタログへ `overrides` を重ねた結果。`overrides` が `undefined` なら
|
|
94
|
+
* 凍結カタログそのもの (同一参照)、それ以外は新しい凍結オブジェクトを返却。入力は変更しない。
|
|
95
|
+
*
|
|
96
|
+
* @param locale - UI chrome locale, or `undefined` for the default `"en"` / UI クロームロケール (`undefined` で既定の `"en"`)
|
|
97
|
+
* @param overrides - Per-key overrides, or `undefined` for none / キー単位の上書き (`undefined` で上書きなし)
|
|
98
|
+
* @returns The resolved, frozen labels / 解決済みの凍結ラベル
|
|
99
|
+
* @throws {RangeError} When the locale is unsupported (`"ja-JP"`, `"EN"`, `""`, `null`, ... — no language
|
|
100
|
+
* negotiation; the message starts with `[period-slider] locale is the UI language` and points at `formatLocale`,
|
|
101
|
+
* the engine's `RangeError` is kept as `cause`), `overrides` is `null` or not an object, `overrides` is not a plain object (an array, a class
|
|
102
|
+
* instance, an object inheriting from another object), an own key is not a label key (including the removed
|
|
103
|
+
* `*AriaLabel` names), or a present own value is not a string with non-whitespace content /
|
|
104
|
+
* ロケールが非対応 (`"ja-JP"`・`"EN"`・`""`・`null` など — 言語ネゴシエーションなし。メッセージは
|
|
105
|
+
* `[period-slider] locale is the UI language` で始まり `formatLocale` を案内、エンジンの `RangeError` を `cause` に保持)、`overrides` が `null`
|
|
106
|
+
* または非オブジェクト、素のオブジェクトでない (配列・クラスインスタンス・他オブジェクト継承)、自身のキーが
|
|
107
|
+
* ラベルキー外 (撤去した `*AriaLabel` 名を含む)、または与えられた自身の値が空白以外を含む文字列でない場合
|
|
108
|
+
*/
|
|
109
|
+
export declare const resolvePeriodSliderLabels: (locale: PeriodSliderLocale | undefined, overrides: PeriodSliderLabelOverrides | undefined) => PeriodSliderLabels;
|
|
110
|
+
/**
|
|
111
|
+
* Extracts the 7 engine chrome keys of a resolved label bag as a new frozen `VirtualScrollLabels` object —
|
|
112
|
+
* the `labels` handed to the embedded VirtualScroll.
|
|
113
|
+
* 解決済みラベル集合からエンジンクローム 7 キーを新しい凍結 `VirtualScrollLabels` として抽出 — 内蔵
|
|
114
|
+
* VirtualScroll へ渡す `labels`。
|
|
115
|
+
*
|
|
116
|
+
* @param labels - The resolved label bag / 解決済みラベル集合
|
|
117
|
+
* @returns A new frozen object holding exactly the 7 engine keys / エンジン 7 キーだけを持つ新しい凍結オブジェクト
|
|
118
|
+
*/
|
|
119
|
+
export declare const pickEngineLabels: (labels: PeriodSliderLabels) => VirtualScrollLabels;
|
|
120
|
+
/**
|
|
121
|
+
* Whether two resolved label bags carry the same string under every key — the value-stability test that
|
|
122
|
+
* keeps a resolved bag's identity while a host re-creates an equal `labels` object on every render.
|
|
123
|
+
* 2 つの解決済みラベル集合が全キーで同じ文字列を持つか — ホストが毎描画で等価な `labels` を作り直しても
|
|
124
|
+
* 解決済み集合の identity を保つための値安定性の判定。
|
|
125
|
+
*
|
|
126
|
+
* @param a - First resolved bag / 1 つ目の解決済み集合
|
|
127
|
+
* @param b - Second resolved bag / 2 つ目の解決済み集合
|
|
128
|
+
* @returns `true` when every key is value-equal / 全キーが値等価なら `true`
|
|
129
|
+
*/
|
|
130
|
+
export declare const areResolvedLabelsEqual: (a: PeriodSliderLabels, b: PeriodSliderLabels) => boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Shallow value equality of two `labels` props, for the hand-written memo comparators: equal identities, or
|
|
133
|
+
* two objects with the same own keys holding `Object.is`-equal values. A host that writes `labels={{ ... }}`
|
|
134
|
+
* inline therefore does not re-render a memoised component while the strings stay the same.
|
|
135
|
+
* 手書きのメモ比較器用の、2 つの `labels` prop の浅い値等価判定: 同一参照、または同じ自身のキーが
|
|
136
|
+
* `Object.is` で等しい値を持つ 2 オブジェクト。インラインで `labels={{ ... }}` と書くホストでも、文字列が
|
|
137
|
+
* 変わらない限りメモ化したコンポーネントを再描画しない。
|
|
138
|
+
*
|
|
139
|
+
* @param prev - Previous `labels` prop / 前回の `labels` prop
|
|
140
|
+
* @param next - Next `labels` prop / 今回の `labels` prop
|
|
141
|
+
* @returns `true` when the two props are value-equal / 2 つの prop が値等価なら `true`
|
|
142
|
+
*/
|
|
143
|
+
export declare const areLabelOverridesEqual: (prev: PeriodSliderLabelOverrides | undefined, next: PeriodSliderLabelOverrides | undefined) => boolean;
|
|
144
|
+
//# sourceMappingURL=labels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../src/labels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAsJ,KAAK,mBAAmB,EAAE,KAAK,mBAAmB,EAAE,MAAM,yB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Q,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,kFAAkF;IAClF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,oFAAoF;IACpF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,gFAAgF;IAChF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC5B,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,0BAA0B,GAAG;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,kBAAkB,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC;CAAE,CAAA;AA+B7G;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,mbAA6G,CAAA;AAmElJ;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,MAAM,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAGhG,CAAA;AA0EF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,kBAAkB,GAAG,SAAS,EAAE,WAAW,0BAA0B,GAAG,SAAS,KAAG,kBAgCrI,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,kBAAkB,KAAG,mBAO7D,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,GAAI,GAAG,kBAAkB,EAAE,GAAG,kBAAkB,KAAG,OAAgF,CAAA;AAEtK;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,GAAI,MAAM,0BAA0B,GAAG,SAAS,EAAE,MAAM,0BAA0B,GAAG,SAAS,KAAG,OAUnI,CAAA"}
|
package/dist/optionText.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PeriodOptionScope, PeriodSliderUnit } from './PeriodSlider.js';
|
|
2
2
|
/**
|
|
3
|
-
* Renders one period text with the package's built-in tiers: `
|
|
4
|
-
* 組み込みの段による期間テキストの描画 (`
|
|
3
|
+
* Renders one period text with the package's built-in tiers: `formatLocale` through Intl, otherwise ISO 8601.
|
|
4
|
+
* 組み込みの段による期間テキストの描画 (`formatLocale` 指定時は Intl、未指定時は ISO 8601)。
|
|
5
5
|
*
|
|
6
6
|
* The argument order mirrors `PeriodOptionFormatter` so a consumer that owns only some (unit, scope)
|
|
7
|
-
* combinations forwards the rest verbatim: `if (scope === "part") return formatOptionText(date, unit, scope,
|
|
7
|
+
* combinations forwards the rest verbatim: `if (scope === "part") return formatOptionText(date, unit, scope, formatLocale)`.
|
|
8
8
|
* 引数順は `PeriodOptionFormatter` と同一であり、担当外の組はそのまま転送できる。
|
|
9
9
|
*
|
|
10
10
|
* `unit` and `scope` are validated here although a formatter prop is type-checked, because this function is
|
|
@@ -14,9 +14,9 @@ import { PeriodOptionScope, PeriodSliderUnit } from './PeriodSlider.js';
|
|
|
14
14
|
* @param date - Date to render / 描画対象の日付
|
|
15
15
|
* @param unit - Precision to name / 名乗る精度
|
|
16
16
|
* @param scope - Scope selecting the built-in option set / 組み込みオプション集合を選ぶ区分
|
|
17
|
-
* @param
|
|
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)
|
|
18
18
|
* @returns Built-in rendering, or an empty string when date is absent or an Invalid Date / 組み込み描画 (date が未指定・Invalid Date の場合は空文字列)
|
|
19
19
|
* @throws RangeError when unit or scope is not one of the declared values / unit・scope が宣言値以外の場合
|
|
20
20
|
*/
|
|
21
|
-
export declare const formatOptionText: (date: Date, unit: PeriodSliderUnit, scope: PeriodOptionScope,
|
|
21
|
+
export declare const formatOptionText: (date: Date, unit: PeriodSliderUnit, scope: PeriodOptionScope, formatLocale?: string) => string;
|
|
22
22
|
//# sourceMappingURL=optionText.d.ts.map
|
package/dist/optionText.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optionText.d.ts","sourceRoot":"","sources":["../src/optionText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAA2C,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AA4EvH;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,IAAI,EAAE,MAAM,gBAAgB,EAAE,OAAO,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"optionText.d.ts","sourceRoot":"","sources":["../src/optionText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAA2C,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AA4EvH;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,IAAI,EAAE,MAAM,gBAAgB,EAAE,OAAO,iBAAiB,EAAE,eAAe,MAAM,KAAG,MAYtH,CAAA"}
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { PeriodSliderLabelOverrides, PeriodSliderLocale } from './labels.js';
|
|
2
3
|
import { BasePeriodSliderVernierProps, PeriodOptionFormatter, PeriodSliderPointProps, PeriodSliderRangeProps, PeriodSliderUnit, PeriodSliderVernierPointProps, PeriodSliderVernierRangeProps } from './PeriodSlider.js';
|
|
3
4
|
/**
|
|
4
5
|
* Pre-configured props for the bundled YearSelector / MonthSelector / DateSelector components.
|
|
5
6
|
* 同梱の YearSelector・MonthSelector・DateSelector へそのまま渡せる Props。
|
|
6
7
|
*
|
|
7
8
|
* Everything the hook was told that decides what a period READS AS travels here, not only what it *is*.
|
|
8
|
-
* A host sets `
|
|
9
|
-
* same hook render the same value the same way; before these two fields existed,
|
|
9
|
+
* A host sets `formatLocale` or `formatOption` once on the hook and the rail and every selector wired from that
|
|
10
|
+
* same hook render the same value the same way; before these two fields existed, a format locale of `"ja-JP"` gave a
|
|
10
11
|
* rail announcing `2024/03` beside a selector showing `2024-03` - one screen disagreeing with itself,
|
|
11
|
-
* which is the defect the single formatter contract exists to remove.
|
|
12
|
+
* which is the defect the single formatter contract exists to remove. The UI chrome `locale` and the
|
|
13
|
+
* `labels` overrides travel the same way, so the rail and its selectors also name their controls in one
|
|
14
|
+
* language.
|
|
12
15
|
* 期間の「読まれ方」を決めるものはすべてここを通る (「何であるか」だけではない)。
|
|
13
|
-
* 利用側がフックへ `
|
|
14
|
-
* 同じ値を同じ表記で描く。この 2
|
|
16
|
+
* 利用側がフックへ `formatLocale` や `formatOption` を 1 度与えれば、レールと同じフックから配線した全セレクタが
|
|
17
|
+
* 同じ値を同じ表記で描く。この 2 つが無かった頃は書式ロケール `"ja-JP"` がレールに `2024/03`、
|
|
15
18
|
* 隣のセレクタに `2024-03` を出していた (1 つの画面が自分と食い違う状態であり、統一フォーマッタ契約が
|
|
16
|
-
* 取り除くために存在する欠陥そのもの)。
|
|
19
|
+
* 取り除くために存在する欠陥そのもの)。UI クロームの `locale` と `labels` の上書きも同じ経路を通るため、
|
|
20
|
+
* レールとセレクタは操作要素を 1 つの言語で名乗る。
|
|
17
21
|
*
|
|
18
22
|
* A host that deliberately wants different text on the rail and in a dropdown - their width budgets differ -
|
|
19
23
|
* overrides the selector by passing `formatOption` to it directly, which wins because it comes later in the
|
|
@@ -34,8 +38,12 @@ export interface SelectorProps {
|
|
|
34
38
|
unit: PeriodSliderUnit;
|
|
35
39
|
/** Calendar month a year starts in, 0-based; read by YearSelector only (default: 0) / 1 年が始まる暦月 (0 始まり、YearSelector のみが読む、既定: 0) */
|
|
36
40
|
yearStartMonth?: number;
|
|
37
|
-
/** BCP 47 language tag the hook was given
|
|
38
|
-
|
|
41
|
+
/** BCP 47 language tag the hook was given as `formatLocale`, so the selector renders the value the way the rail does / フックへ `formatLocale` として与えられた BCP 47 言語タグ (セレクタがレールと同じ表記で値を描くため) */
|
|
42
|
+
formatLocale?: string;
|
|
43
|
+
/** UI chrome locale the hook was given, so the selector names its controls in the rail's language / フックへ与えられた UI クロームロケール (セレクタがレールと同じ言語で操作要素を名乗るため) */
|
|
44
|
+
locale?: PeriodSliderLocale;
|
|
45
|
+
/** Label overrides the hook was given; each selector reads only its own keys / フックへ与えられたラベル上書き (各セレクタは自分のキーだけを読む) */
|
|
46
|
+
labels?: PeriodSliderLabelOverrides;
|
|
39
47
|
/** Option formatter the hook was given, so the selector renders the value the way the rail does / フックへ与えられた選択肢フォーマッタ (セレクタがレールと同じ表記で値を描くため) */
|
|
40
48
|
formatOption?: PeriodOptionFormatter;
|
|
41
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePeriodSlider.d.ts","sourceRoot":"","sources":["../src/usePeriodSlider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAEH,KAAK,4BAA4B,EAIjC,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EAGrC,MAAM,gBAAgB,CAAA;AAuOvB
|
|
1
|
+
{"version":3,"file":"usePeriodSlider.d.ts","sourceRoot":"","sources":["../src/usePeriodSlider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC9E,OAAO,EAEH,KAAK,4BAA4B,EAIjC,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EAGrC,MAAM,gBAAgB,CAAA;AAuOvB;;;;;;;;;;;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AAK,CAAC,cAAc,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;IACjE,qCAAqC;IACrC,UAAU,EAAE,IAAI,CAAA;IAChB,kIAAkI;IAClI,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAA;IACzD,mLAAmL;IACnL,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IACvC,mLAAmL;IACnL,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IACvC,oFAAoF;IACpF,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IAClC,oTAAoT;IACpT,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACxC,uPAAuP;IACvP,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;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,2BAA2B,CA+QxG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PeriodSliderLabelOverrides, PeriodSliderLabels, PeriodSliderLocale } from './labels.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the `locale` + `labels` props during render (an unsupported locale or a malformed bag throws the
|
|
4
|
+
* documented RangeError from render, like every other prop check of the package) and keeps the previous
|
|
5
|
+
* bag's identity while every string is value-equal, so a host writing `labels={{ ... }}` inline does not
|
|
6
|
+
* hand a new object to the embedded VirtualScroll on every render.
|
|
7
|
+
* `locale` + `labels` Props を描画中に解決し (非対応ロケールや不正な集合は、パッケージの他の Props 検査と同じく
|
|
8
|
+
* 描画中に文書どおりの RangeError を送出)、全文字列が値等価の間は前回の集合の identity を保つ。インラインで
|
|
9
|
+
* `labels={{ ... }}` と書くホストでも、内蔵 VirtualScroll へ毎描画新しいオブジェクトを渡さない。
|
|
10
|
+
*
|
|
11
|
+
* @param locale - UI chrome locale prop / UI クロームロケール prop
|
|
12
|
+
* @param labels - Label overrides prop / ラベル上書き prop
|
|
13
|
+
* @returns The resolved, frozen, value-stable label bag / 解決済み・凍結・値安定のラベル集合
|
|
14
|
+
* @throws {RangeError} Whatever `resolvePeriodSliderLabels` rejects / `resolvePeriodSliderLabels` が拒否する入力
|
|
15
|
+
*/
|
|
16
|
+
export declare const useResolvedLabels: (locale: PeriodSliderLocale | undefined, labels: PeriodSliderLabelOverrides | undefined) => PeriodSliderLabels;
|
|
17
|
+
//# sourceMappingURL=useResolvedLabels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResolvedLabels.d.ts","sourceRoot":"","sources":["../src/useResolvedLabels.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAA0B,KAAK,0BAA0B,EAAE,KAAK,kBAAkB,EAAE,KAAK,kBAAkB,EAA6B,MAAM,UAAU,CAAA;AAE/J;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,kBAAkB,GAAG,SAAS,EAAE,QAAQ,0BAA0B,GAAG,SAAS,KAAG,kBAQ1H,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiquants/period-slider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Customizable period slider and year/month/date selectors for React",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"LICENSE"
|
|
33
33
|
],
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@aiquants/virtualscroll": "^3.
|
|
35
|
+
"@aiquants/virtualscroll": "^3.7.0",
|
|
36
36
|
"react": "^19.2.7",
|
|
37
37
|
"react-dom": "^19.2.7"
|
|
38
38
|
},
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"date-fns": "^4.1.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@aiquants/virtualscroll": "^3.
|
|
43
|
+
"@aiquants/virtualscroll": "^3.7.0",
|
|
44
44
|
"@playwright/test": "^1.59.1",
|
|
45
45
|
"@tailwindcss/cli": "^4.1.18",
|
|
46
46
|
"@tailwindcss/vite": "^4.1.18",
|
package/src/DateSelector.tsx
CHANGED
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
* the bounds (`dateOptionDomain`) and only the visible rows exist as DOM, so a host that moves
|
|
10
10
|
* `minDate` / `maxDate` per pointer move pays O(1) rather than O(option count).
|
|
11
11
|
*
|
|
12
|
-
* Human-facing option text is locale-independent ISO 8601 until a `
|
|
12
|
+
* Human-facing option text is locale-independent ISO 8601 until a `formatLocale` tag opts into Intl
|
|
13
13
|
* formatting or `formatOption` overrides it, while every machine-read value stays yyyy-MM-dd.
|
|
14
|
+
* The accessible names - and, in `variant="dropdown"`, the scroll chrome of the embedded VirtualScroll -
|
|
15
|
+
* come from the `locale` (UI chrome language) catalog and the `labels` overrides.
|
|
14
16
|
* The previous / next buttons are drawn by `StepperButton`.
|
|
15
17
|
*
|
|
16
18
|
* 年月日セレクタコンポーネントの提供モジュール。
|
|
@@ -19,8 +21,10 @@
|
|
|
19
21
|
* コンボボックスは選択肢配列を実体化せず、選択肢集合は境界から導いた添字空間
|
|
20
22
|
* (`dateOptionDomain`)、DOM に存在するのは可視行のみ。
|
|
21
23
|
* このためポインタ移動ごとに `minDate` / `maxDate` を動かすホストの費用は選択肢数に比例しない。
|
|
22
|
-
* 表示テキストは既定でロケール非依存の ISO 8601 表記 (`
|
|
24
|
+
* 表示テキストは既定でロケール非依存の ISO 8601 表記 (`formatLocale` 指定時は Intl 書式、
|
|
23
25
|
* `formatOption` 指定時はそれが最優先)、機械可読値は常に yyyy-MM-dd。
|
|
26
|
+
* アクセシブル名 (`variant="dropdown"` では内蔵 VirtualScroll のスクロールクロームも) は `locale` (UI クローム言語) の
|
|
27
|
+
* カタログと `labels` の上書きから決まる。
|
|
24
28
|
* 前日/翌日ボタンは `StepperButton` が描く。
|
|
25
29
|
*/
|
|
26
30
|
|
|
@@ -39,21 +43,23 @@ import {
|
|
|
39
43
|
normalizeAllowedDates,
|
|
40
44
|
resolveDiscreteIndexWindow,
|
|
41
45
|
} from "./dateOptionDomain"
|
|
46
|
+
import { areLabelOverridesEqual, type PeriodSliderLabelOverrides, type PeriodSliderLocale } from "./labels"
|
|
42
47
|
import { formatOptionText } from "./optionText"
|
|
43
48
|
import { formatLabel, type PeriodOptionFormatter, type PeriodSliderUnit } from "./PeriodSlider"
|
|
44
49
|
import { STEPPER_ROW_GAP_CLASS, StepperButton } from "./StepperButton"
|
|
50
|
+
import { useResolvedLabels } from "./useResolvedLabels"
|
|
45
51
|
import { VirtualDateDropdown } from "./VirtualDateDropdown"
|
|
46
52
|
|
|
47
53
|
/**
|
|
48
54
|
* Props of the day-resolution selector.
|
|
49
55
|
* 日単位セレクタの Props。
|
|
50
56
|
*
|
|
51
|
-
* Accessible names
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
+
* Accessible names come from the UI chrome catalog of `locale` (default "en") and option text defaults to
|
|
58
|
+
* locale-independent ISO 8601. The two are independent axes: `locale` picks the language of the names,
|
|
59
|
+
* `formatLocale` / `formatOption` pick how the dates read, and neither is derived from the other.
|
|
60
|
+
* アクセシブル名は `locale` (既定 "en") の UI クロームカタログから、選択肢テキストの既定はロケール非依存の
|
|
61
|
+
* ISO 8601 表記。両者は独立した軸で、`locale` は名前の言語、`formatLocale` / `formatOption` は日付の読まれ方を
|
|
62
|
+
* 選び、一方から他方を導出しない。
|
|
57
63
|
*/
|
|
58
64
|
export interface DateSelectorProps {
|
|
59
65
|
/** Controlled selected date; required unless `initialDate` is supplied; must be a valid Date / 選択日付 (外部制御用・`initialDate` 未指定時は必須・Invalid Date 不可) */
|
|
@@ -87,21 +93,13 @@ export interface DateSelectorProps {
|
|
|
87
93
|
style?: React.CSSProperties
|
|
88
94
|
/** Disabled flag / 無効化フラグ */
|
|
89
95
|
disabled?: boolean
|
|
90
|
-
/**
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
|
|
94
|
-
/** Accessible label for the date select / input / 年月日セレクト・入力のアクセシブル名 (既定: "Date") */
|
|
95
|
-
selectAriaLabel?: string
|
|
96
|
-
/** Accessible label for the year select of variant="split-dropdown" / 年セレクトのアクセシブル名 (既定: "Year") */
|
|
97
|
-
yearAriaLabel?: string
|
|
98
|
-
/** Accessible label for the month select of variant="split-dropdown" / 月セレクトのアクセシブル名 (既定: "Month") */
|
|
99
|
-
monthAriaLabel?: string
|
|
100
|
-
/** Accessible label for the day select of variant="split-dropdown" / 日セレクトのアクセシブル名 (既定: "Day") */
|
|
101
|
-
dayAriaLabel?: string
|
|
96
|
+
/** UI chrome language of the accessible names and of the dropdown's scroll chrome ("en" | "ja", default "en"); anything else throws RangeError / アクセシブル名とドロップダウンのスクロールクロームの UI クローム言語 ("en" | "ja"、既定 "en"。それ以外は RangeError) */
|
|
97
|
+
locale?: PeriodSliderLocale
|
|
98
|
+
/** Per-key overrides over the `locale` catalog; this component reads `previousDay`, `nextDay`, `dateSelect`, `splitYear`, `splitMonth`, `splitDay` and, in variant="dropdown", the 7 engine keys / `locale` カタログへのキー単位の上書き (本コンポーネントが読むのは `previousDay`・`nextDay`・`dateSelect`・`splitYear`・`splitMonth`・`splitDay`、variant="dropdown" ではエンジン 7 キーも) */
|
|
99
|
+
labels?: PeriodSliderLabelOverrides
|
|
102
100
|
/** BCP 47 language tag switching option text to Intl formatting; omitted keeps locale-independent ISO 8601, and the input value stays yyyy-MM-dd either way / 選択肢テキストを Intl 書式にする BCP 47 言語タグ (未指定時はロケール非依存の ISO 8601 表記・input の value は常に yyyy-MM-dd) */
|
|
103
|
-
|
|
104
|
-
/** Formatter for every option, placeholder and collapsed-control text this component owns, taking priority over `
|
|
101
|
+
formatLocale?: string
|
|
102
|
+
/** Formatter for every option, placeholder and collapsed-control text this component owns, taking priority over `formatLocale`; `variant="date"` cannot honour it and never invokes it (the browser owns that text) / 本コンポーネントが所有する全選択肢・プレースホルダ・畳んだ表示のフォーマッタ (`formatLocale` より優先)。`variant="date"` は履行不能で呼び出しも行わない (表示はブラウザ所有) */
|
|
105
103
|
formatOption?: PeriodOptionFormatter
|
|
106
104
|
}
|
|
107
105
|
|
|
@@ -136,21 +134,21 @@ const assertValidDateProp = (propName: string, date: Date): void => {
|
|
|
136
134
|
}
|
|
137
135
|
|
|
138
136
|
/**
|
|
139
|
-
* Asserts that a
|
|
140
|
-
*
|
|
137
|
+
* Asserts that a formatLocale prop carries a language tag Intl.DateTimeFormat accepts, failing fast otherwise.
|
|
138
|
+
* formatLocale プロパティが Intl.DateTimeFormat の受理する言語タグであることの表明。無効時は即時失敗。
|
|
141
139
|
*
|
|
142
|
-
* @param
|
|
140
|
+
* @param formatLocale - Prop value to validate / 検証対象のプロパティ値
|
|
143
141
|
* @returns Nothing / 戻り値なし
|
|
144
142
|
* @throws RangeError when the tag is empty or Intl rejects it / 空文字列や Intl が拒否するタグの場合
|
|
145
143
|
*/
|
|
146
|
-
const
|
|
147
|
-
if (
|
|
144
|
+
const assertFormatLocaleProp = (formatLocale: string | undefined): void => {
|
|
145
|
+
if (formatLocale === undefined) return
|
|
148
146
|
try {
|
|
149
147
|
// 空文字列や構造的に不正なタグは Intl の送出する例外でしか判定できない。
|
|
150
148
|
// 自前の正規表現で代用すると ICU が受理するタグを取りこぼす
|
|
151
|
-
Intl.DateTimeFormat.supportedLocalesOf([
|
|
149
|
+
Intl.DateTimeFormat.supportedLocalesOf([formatLocale])
|
|
152
150
|
} catch {
|
|
153
|
-
throw new RangeError(`DateSelector: "
|
|
151
|
+
throw new RangeError(`DateSelector: "formatLocale" must be a valid BCP 47 language tag (received ${JSON.stringify(formatLocale)})`)
|
|
154
152
|
}
|
|
155
153
|
}
|
|
156
154
|
|
|
@@ -199,34 +197,13 @@ const endOfYear = (year: number): Date => localDate(year, 12, 31)
|
|
|
199
197
|
* 選択可能集合は `allowedDates` (離散) または [minDate/minYear, maxDate/maxYear] (連続) が決定し、集合外の日付は emit されない。
|
|
200
198
|
* 発行できない日へ進むステッパーは無効化し、`variant="split-dropdown"` では他の 2 部位との組合せが
|
|
201
199
|
* emit できない年・月・日を選択不可の選択肢として提示。
|
|
202
|
-
* `value` / `initialDate` の欠落・不正値、バリアントが要求する境界の欠落・矛盾、`allowedDates`
|
|
200
|
+
* `value` / `initialDate` の欠落・不正値、バリアントが要求する境界の欠落・矛盾、`allowedDates` との組合せ違反、
|
|
201
|
+
* 不正な `locale` / `labels` / `formatLocale` はいずれも RangeError で即時失敗。
|
|
203
202
|
*/
|
|
204
203
|
const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
205
|
-
const {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
onChange,
|
|
209
|
-
children,
|
|
210
|
-
minYear,
|
|
211
|
-
maxYear,
|
|
212
|
-
minDate,
|
|
213
|
-
maxDate,
|
|
214
|
-
allowedDates,
|
|
215
|
-
variant = "date",
|
|
216
|
-
className = "",
|
|
217
|
-
style,
|
|
218
|
-
disabled = false,
|
|
219
|
-
prevDateAriaLabel = "Previous day",
|
|
220
|
-
nextDateAriaLabel = "Next day",
|
|
221
|
-
selectAriaLabel = "Date",
|
|
222
|
-
yearAriaLabel = "Year",
|
|
223
|
-
monthAriaLabel = "Month",
|
|
224
|
-
dayAriaLabel = "Day",
|
|
225
|
-
locale,
|
|
226
|
-
formatOption,
|
|
227
|
-
} = props
|
|
228
|
-
|
|
229
|
-
assertLocaleProp(locale)
|
|
204
|
+
const { value, initialDate, onChange, children, minYear, maxYear, minDate, maxDate, allowedDates, variant = "date", className = "", style, disabled = false, locale, labels, formatLocale, formatOption } = props
|
|
205
|
+
|
|
206
|
+
assertFormatLocaleProp(formatLocale)
|
|
230
207
|
if (value !== undefined) assertValidDateProp("value", value)
|
|
231
208
|
if (initialDate !== undefined) assertValidDateProp("initialDate", initialDate)
|
|
232
209
|
if (minDate !== undefined) assertValidDateProp("minDate", minDate)
|
|
@@ -246,6 +223,9 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
|
246
223
|
throw new RangeError("DateSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected date is never inferred from the wall clock.")
|
|
247
224
|
}
|
|
248
225
|
|
|
226
|
+
// ラベル解決は最初のフック。日付 Props の検証を全て済ませてから呼び、両方が不正なら日付側を先に報告する
|
|
227
|
+
const resolvedLabels = useResolvedLabels(locale, labels)
|
|
228
|
+
|
|
249
229
|
const [currentDate, setCurrentDate] = useState<Date>(() => toStartOfDay(effectiveDate))
|
|
250
230
|
|
|
251
231
|
const isControlled = value !== undefined
|
|
@@ -302,11 +282,11 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
|
302
282
|
// 日付・値・ラベルは要求時に導出するため、境界が動いても件数に比例した処理は走らない
|
|
303
283
|
const optionDomain = useMemo<DateOptionDomain>(() => {
|
|
304
284
|
if (discreteWindow !== null) {
|
|
305
|
-
return createDiscreteDateOptionDomain(discreteWindow.ascending, discreteWindow.loIndex, discreteWindow.hiIndex,
|
|
285
|
+
return createDiscreteDateOptionDomain(discreteWindow.ascending, discreteWindow.loIndex, discreteWindow.hiIndex, formatLocale, formatOption)
|
|
306
286
|
}
|
|
307
287
|
if (minDateBound === null || maxDateBound === null) return EMPTY_DATE_OPTION_DOMAIN
|
|
308
|
-
return createContinuousDateOptionDomain(minDateBound, maxDateBound,
|
|
309
|
-
}, [discreteWindow, minBoundTime, maxBoundTime,
|
|
288
|
+
return createContinuousDateOptionDomain(minDateBound, maxDateBound, formatLocale, formatOption)
|
|
289
|
+
}, [discreteWindow, minBoundTime, maxBoundTime, formatLocale, formatOption])
|
|
310
290
|
|
|
311
291
|
const isSelectable = (candidate: Date): boolean => {
|
|
312
292
|
if (discreteWindow !== null) {
|
|
@@ -381,7 +361,7 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
|
381
361
|
|
|
382
362
|
// 3 つの選択肢メモが依存する。毎描画で作り直すとメモが常に外れ、利用側フォーマッタが
|
|
383
363
|
// 選択肢の数だけ呼ばれ直す
|
|
384
|
-
const renderPart = useCallback((unit: PeriodSliderUnit, anchor: Date): string => (formatOption ? formatOption(anchor, unit, "part") : formatOptionText(anchor, unit, "part",
|
|
364
|
+
const renderPart = useCallback((unit: PeriodSliderUnit, anchor: Date): string => (formatOption ? formatOption(anchor, unit, "part") : formatOptionText(anchor, unit, "part", formatLocale)), [formatOption, formatLocale])
|
|
385
365
|
|
|
386
366
|
const yearOptions = useMemo(() => {
|
|
387
367
|
if (variant !== "split-dropdown" || minDateBound === null || maxDateBound === null) return []
|
|
@@ -443,7 +423,7 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
|
443
423
|
const formattedDate = formatIsoDay(activeDate)
|
|
444
424
|
// variant="dropdown" の畳んだ表示でしか読まれない。全 variant で組み立てると、履行できない面のために
|
|
445
425
|
// 利用側のフォーマッタが呼ばれ、描かれないテキストの生成が観測されてしまう
|
|
446
|
-
const activeLabel = variant === "dropdown" ? formatLabel("day", activeDate, formatOption,
|
|
426
|
+
const activeLabel = variant === "dropdown" ? formatLabel("day", activeDate, formatOption, formatLocale) : ""
|
|
447
427
|
const minFormatted = minDateBound ? formatIsoDay(minDateBound) : undefined
|
|
448
428
|
const maxFormatted = maxDateBound ? formatIsoDay(maxDateBound) : undefined
|
|
449
429
|
const outOfRangeOptionClassName = "text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400"
|
|
@@ -453,7 +433,7 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
|
453
433
|
|
|
454
434
|
return (
|
|
455
435
|
<div className={`inline-flex items-center ${STEPPER_ROW_GAP_CLASS} ${className}`} style={style} data-variant={variant} data-out-of-range={isActiveSelectable ? undefined : "true"}>
|
|
456
|
-
<StepperButton neighbour="control" direction="left" disabled={disabled} canStep={prevDate !== null} onStep={handlePrevious} ariaLabel={
|
|
436
|
+
<StepperButton neighbour="control" direction="left" disabled={disabled} canStep={prevDate !== null} onStep={handlePrevious} ariaLabel={resolvedLabels.previousDay} />
|
|
457
437
|
|
|
458
438
|
{variant === "dropdown" ? (
|
|
459
439
|
<VirtualDateDropdown
|
|
@@ -462,14 +442,16 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
|
462
442
|
displayLabel={activeLabel}
|
|
463
443
|
machineValue={formattedDate}
|
|
464
444
|
disabled={disabled}
|
|
465
|
-
ariaLabel={
|
|
445
|
+
ariaLabel={resolvedLabels.dateSelect}
|
|
446
|
+
locale={locale}
|
|
447
|
+
labels={resolvedLabels}
|
|
466
448
|
onCommitIndex={(index) => emit(optionDomain.dateAt(index))}
|
|
467
449
|
controlClassName={dateComboboxClassName}
|
|
468
450
|
/>
|
|
469
451
|
) : variant === "split-dropdown" ? (
|
|
470
452
|
<div className="inline-flex items-center gap-1">
|
|
471
453
|
<select
|
|
472
|
-
aria-label={
|
|
454
|
+
aria-label={resolvedLabels.splitYear}
|
|
473
455
|
disabled={disabled}
|
|
474
456
|
className="rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100"
|
|
475
457
|
value={yearInOptions ? currentYear : ""}
|
|
@@ -486,7 +468,7 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
|
486
468
|
))}
|
|
487
469
|
</select>
|
|
488
470
|
<select
|
|
489
|
-
aria-label={
|
|
471
|
+
aria-label={resolvedLabels.splitMonth}
|
|
490
472
|
disabled={disabled}
|
|
491
473
|
className="rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100"
|
|
492
474
|
value={monthInOptions ? currentMonth : ""}
|
|
@@ -503,7 +485,7 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
|
503
485
|
))}
|
|
504
486
|
</select>
|
|
505
487
|
<select
|
|
506
|
-
aria-label={
|
|
488
|
+
aria-label={resolvedLabels.splitDay}
|
|
507
489
|
disabled={disabled}
|
|
508
490
|
className="rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100"
|
|
509
491
|
value={dayInOptions ? currentDay : ""}
|
|
@@ -522,7 +504,7 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
|
522
504
|
</div>
|
|
523
505
|
) : (
|
|
524
506
|
<input
|
|
525
|
-
aria-label={
|
|
507
|
+
aria-label={resolvedLabels.dateSelect}
|
|
526
508
|
disabled={disabled}
|
|
527
509
|
className="period-slider-native-date-field w-28 rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500 dark:placeholder:text-gray-400"
|
|
528
510
|
value={formattedDate}
|
|
@@ -533,7 +515,7 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
|
533
515
|
/>
|
|
534
516
|
)}
|
|
535
517
|
|
|
536
|
-
<StepperButton neighbour="control" direction="right" disabled={disabled} canStep={nextDate !== null} onStep={handleNext} ariaLabel={
|
|
518
|
+
<StepperButton neighbour="control" direction="right" disabled={disabled} canStep={nextDate !== null} onStep={handleNext} ariaLabel={resolvedLabels.nextDay} />
|
|
537
519
|
{children}
|
|
538
520
|
</div>
|
|
539
521
|
)
|
|
@@ -565,13 +547,9 @@ export const DateSelector = memo(DateSelectorComponent, (prev, next) => {
|
|
|
565
547
|
if (prev.onChange !== next.onChange) return false
|
|
566
548
|
if (prev.allowedDates !== next.allowedDates) return false
|
|
567
549
|
if (prev.children !== next.children) return false
|
|
568
|
-
if (prev.prevDateAriaLabel !== next.prevDateAriaLabel) return false
|
|
569
|
-
if (prev.nextDateAriaLabel !== next.nextDateAriaLabel) return false
|
|
570
|
-
if (prev.selectAriaLabel !== next.selectAriaLabel) return false
|
|
571
|
-
if (prev.yearAriaLabel !== next.yearAriaLabel) return false
|
|
572
|
-
if (prev.monthAriaLabel !== next.monthAriaLabel) return false
|
|
573
|
-
if (prev.dayAriaLabel !== next.dayAriaLabel) return false
|
|
574
550
|
if (prev.locale !== next.locale) return false
|
|
551
|
+
if (!areLabelOverridesEqual(prev.labels, next.labels)) return false
|
|
552
|
+
if (prev.formatLocale !== next.formatLocale) return false
|
|
575
553
|
if (prev.formatOption !== next.formatOption) return false
|
|
576
554
|
return true
|
|
577
555
|
})
|