@aiquants/period-slider 0.2.0 → 0.3.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.
@@ -1,11 +1,34 @@
1
+ /**
2
+ * @fileoverview Year (yyyy) selector component
3
+ * @package @aiquants/period-slider
4
+ *
5
+ * Provides a year selector rendered as a dropdown flanked by stepper buttons that move the
6
+ * selection by one year. Missing and invalid inputs fail fast rather than being substituted.
7
+ * Option text is locale-independent ISO 8601 until a `locale` tag opts into Intl formatting.
8
+ *
9
+ * ドロップダウンと ±1 年ステッパーによる年セレクタ。欠落値・不正値は代替せず即時エラー。
10
+ * 選択肢テキストは既定でロケール非依存の ISO 8601 表記、`locale` 指定時のみ Intl 書式。
11
+ */
12
+
1
13
  import type React from "react"
2
14
  import { memo, useEffect, useMemo, useState } from "react"
3
- import type { PeriodSliderUnit } from "./PeriodSlider"
15
+ import { formatLabel, type PeriodSliderUnit } from "./PeriodSlider"
4
16
 
17
+ /**
18
+ * Props of the year-resolution selector.
19
+ * 年単位セレクタの Props。
20
+ *
21
+ * Accessible names default to English and option text to locale-independent ISO 8601, because a
22
+ * generic package cannot know the host application's language: localisation is the consumer's
23
+ * decision, expressed through `locale` or the aria-label props.
24
+ * アクセシブル名の既定は英語、選択肢テキストの既定はロケール非依存の ISO 8601 表記。
25
+ * 汎用パッケージは利用側アプリの言語を知り得ないため、地域化は `locale`・アクセシブル名 Props を
26
+ * 通じた利用側の選択。
27
+ */
5
28
  export interface YearSelectorProps {
6
- /** Controlled selected date / 選択日付(外部制御用) */
29
+ /** Controlled selected date; required unless `initialDate` is supplied / 選択日付(外部制御用・`initialDate` 未指定時は必須) */
7
30
  value?: Date
8
- /** Initial selected date (defaults to current date) / 選択日付(未指定時は現在日) */
31
+ /** Initial selected date; required unless `value` is supplied / 選択日付(非制御用・`value` 未指定時は必須) */
9
32
  initialDate?: Date
10
33
  /** Time resolution unit (ignored by selector, accepted for hook interoperability) / 時間解像度単位 (フック相互運用用) */
11
34
  unit?: PeriodSliderUnit
@@ -13,13 +36,13 @@ export interface YearSelectorProps {
13
36
  onChange?(date: Date, year: number): void
14
37
  /** Child elements / 子要素 */
15
38
  children?: React.ReactNode
16
- /** Minimum selectable year / ドロップダウン・可能範囲の最小年 */
39
+ /** Minimum selectable year; combined with `minDate` as the stricter of the two, and at least one of them is required / 選択可能な最小年。`minDate` とは厳しい方を採用し、少なくとも一方が必須 */
17
40
  minYear?: number
18
- /** Maximum selectable year / ドロップダウン・可能範囲の最大年 */
41
+ /** Maximum selectable year; combined with `maxDate` as the stricter of the two, and at least one of them is required / 選択可能な最大年。`maxDate` とは厳しい方を採用し、少なくとも一方が必須 */
19
42
  maxYear?: number
20
- /** Minimum selectable date / 選択可能範囲の最小日付 */
43
+ /** Minimum selectable date (its year is used); combined with `minYear` as the stricter of the two / 選択可能範囲の最小日付 (年のみ使用)。`minYear` とは厳しい方を採用 */
21
44
  minDate?: Date
22
- /** Maximum selectable date / 選択可能範囲の最大日付 */
45
+ /** Maximum selectable date (its year is used); combined with `maxYear` as the stricter of the two / 選択可能範囲の最大日付 (年のみ使用)。`maxYear` とは厳しい方を採用 */
23
46
  maxDate?: Date
24
47
  /** Additional CSS class name / 追加の CSS クラス名 */
25
48
  className?: string
@@ -27,84 +50,173 @@ export interface YearSelectorProps {
27
50
  style?: React.CSSProperties
28
51
  /** Disabled flag / 無効化フラグ */
29
52
  disabled?: boolean
30
- /** Accessible label for previous year button / 前年ボタンのアクセシブル名 */
53
+ /** Accessible label for previous year button / 前年ボタンのアクセシブル名 (既定: "Previous year") */
31
54
  prevYearAriaLabel?: string
32
- /** Accessible label for next year button / 翌年ボタンのアクセシブル名 */
55
+ /** Accessible label for next year button / 翌年ボタンのアクセシブル名 (既定: "Next year") */
33
56
  nextYearAriaLabel?: string
34
- /** Accessible label for year select combobox / 会計年セレクトのアクセシブル名 */
57
+ /** Accessible label for year select combobox / 年セレクトのアクセシブル名 (既定: "Year") */
35
58
  selectAriaLabel?: string
59
+ /** BCP 47 language tag switching option text to Intl formatting; omitted keeps locale-independent ISO 8601 / 選択肢テキストを Intl 書式にする BCP 47 言語タグ (未指定時はロケール非依存の ISO 8601 表記) */
60
+ locale?: string
61
+ }
62
+
63
+ /**
64
+ * Build January 1st of the given year as a local Date.
65
+ * 指定年の 1 月 1 日を表すローカル Date の生成。
66
+ *
67
+ * @param year - Calendar year / 暦年
68
+ * @returns January 1st of that year / その年の 1 月 1 日
69
+ */
70
+ function yearStart(year: number): Date {
71
+ const d = new Date(year, 0, 1)
72
+ // 0-99 年が 1900 年代へ丸められる Date の仕様を打ち消す
73
+ d.setFullYear(year)
74
+ return d
75
+ }
76
+
77
+ /**
78
+ * Throw when a Date-typed prop does not hold a real calendar date.
79
+ * Date 型 prop が実在日付でない場合の即時エラー送出。
80
+ *
81
+ * @param date - Prop value to validate / 検証対象の prop 値
82
+ * @param propName - Prop name used in the error message / エラーメッセージ用 prop 名
83
+ * @returns Nothing; throws RangeError on an invalid Date / 戻り値なし (不正日付は RangeError)
84
+ */
85
+ function assertValidDateProp(date: Date | undefined, propName: string): void {
86
+ if (date === undefined) return
87
+ if (!(date instanceof Date) || Number.isNaN(date.getTime())) {
88
+ throw new RangeError(`YearSelector: \`${propName}\` must be a valid Date, received ${String(date)}.`)
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Throw when a year-typed prop does not hold a finite integer year.
94
+ * 年 prop が有限の整数年でない場合の即時エラー送出。
95
+ *
96
+ * @param year - Prop value to validate / 検証対象の prop 値
97
+ * @param propName - Prop name used in the error message / エラーメッセージ用 prop 名
98
+ * @returns Nothing; throws RangeError on an invalid year / 戻り値なし (不正年は RangeError)
99
+ */
100
+ function assertValidYearProp(year: number | undefined, propName: string): void {
101
+ if (year === undefined) return
102
+ if (!Number.isInteger(year)) {
103
+ throw new RangeError(`YearSelector: \`${propName}\` must be an integer year, received ${String(year)}.`)
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Throw when the locale prop does not hold a language tag Intl.DateTimeFormat accepts.
109
+ * locale prop が Intl.DateTimeFormat の受理する言語タグでない場合の即時エラー送出。
110
+ *
111
+ * @param locale - Prop value to validate / 検証対象の prop 値
112
+ * @returns Nothing; throws RangeError on a tag Intl rejects / 戻り値なし (Intl が拒否するタグは RangeError)
113
+ */
114
+ function assertLocaleProp(locale: string | undefined): void {
115
+ if (locale === undefined) return
116
+ try {
117
+ // 空文字列や構造的に不正なタグは Intl の送出する例外でしか判定できない。
118
+ // 自前の正規表現で代用すると ICU が受理するタグを取りこぼす
119
+ Intl.DateTimeFormat.supportedLocalesOf([locale])
120
+ } catch {
121
+ throw new RangeError(`YearSelector: \`locale\` must be a valid BCP 47 language tag, received ${JSON.stringify(locale)}.`)
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Resolve the strictest bound year declared by a year prop and a date prop.
127
+ * 年 prop と日付 prop の双方を満たす最も厳しい境界年の解決。
128
+ *
129
+ * @param boundYear - Bound declared as a year / 年で宣言された境界
130
+ * @param boundDate - Bound declared as a date / 日付で宣言された境界
131
+ * @param pick - Combiner selecting the stricter of two candidate years / 2 つの候補年から厳しい方を選ぶ合成関数
132
+ * @returns Strictest declared bound year, or null when neither is declared / 最も厳しい境界年。いずれも未宣言なら null
133
+ */
134
+ function resolveBoundYear(boundYear: number | undefined, boundDate: Date | undefined, pick: (a: number, b: number) => number): number | null {
135
+ const fromYear = boundYear === undefined ? null : boundYear
136
+ const fromDate = boundDate === undefined ? null : boundDate.getFullYear()
137
+ if (fromYear !== null && fromDate !== null) return pick(fromYear, fromDate)
138
+ if (fromYear !== null) return fromYear
139
+ return fromDate
36
140
  }
37
141
 
38
142
  /**
39
143
  * Year selector component supporting min/max boundaries and stepper buttons (◀▶).
40
- * 年(会計年)セレクタ共通コンポーネント。
144
+ * 年セレクタ共通コンポーネント。
41
145
  * 中央のドロップダウン (`<select>`) と両脇のステッパーボタン (◀▶) で ±1 年を変更可能。
146
+ * アクセシブル名の既定値は全て英語、選択肢テキストは `locale` 未指定なら ISO 8601 表記。
147
+ * `value` / `initialDate` の欠落・不正値、境界の欠落・矛盾、境界外の選択値、不正な `locale` はいずれも RangeError で即時失敗。
42
148
  */
43
149
  const YearSelectorComponent = (props: YearSelectorProps): React.JSX.Element => {
44
- const { value, initialDate, onChange, children, minYear, maxYear, minDate, maxDate, className = "", style, disabled = false, prevYearAriaLabel = "前年", nextYearAriaLabel = "翌年", selectAriaLabel = "会計年" } = props
150
+ const { value, initialDate, onChange, children, minYear, maxYear, minDate, maxDate, className = "", style, disabled = false, prevYearAriaLabel = "Previous year", nextYearAriaLabel = "Next year", selectAriaLabel = "Year", locale } = props
151
+
152
+ assertValidDateProp(value, "value")
153
+ assertValidDateProp(initialDate, "initialDate")
154
+ assertValidDateProp(minDate, "minDate")
155
+ assertValidDateProp(maxDate, "maxDate")
156
+ assertValidYearProp(minYear, "minYear")
157
+ assertValidYearProp(maxYear, "maxYear")
158
+ assertLocaleProp(locale)
159
+
45
160
  const effectiveDate = value ?? initialDate
46
- const [year, setYear] = useState<number>(() => (effectiveDate ?? new Date()).getFullYear())
161
+ if (effectiveDate === undefined) {
162
+ throw new RangeError("YearSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected year is never inferred from the wall clock.")
163
+ }
164
+
165
+ const [year, setYear] = useState<number>(() => effectiveDate.getFullYear())
47
166
 
48
167
  const minTime = minDate?.getTime()
49
168
  const maxTime = maxDate?.getTime()
50
169
 
51
- const minYearBound = useMemo(() => {
52
- if (minYear !== undefined) return minYear
53
- if (minDate) return minDate.getFullYear()
54
- return undefined
55
- }, [minYear, minTime])
170
+ const minYearBound = useMemo(() => resolveBoundYear(minYear, minDate, Math.max), [minYear, minTime])
171
+ const maxYearBound = useMemo(() => resolveBoundYear(maxYear, maxDate, Math.min), [maxYear, maxTime])
56
172
 
57
- const maxYearBound = useMemo(() => {
58
- if (maxYear !== undefined) return maxYear
59
- if (maxDate) return maxDate.getFullYear()
60
- return undefined
61
- }, [maxYear, maxTime])
173
+ if (minYearBound === null || maxYearBound === null) {
174
+ throw new RangeError("YearSelector: a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`) are both required; the year option list is never invented.")
175
+ }
176
+ if (minYearBound > maxYearBound) {
177
+ throw new RangeError(`YearSelector: the resolved lower bound ${minYearBound} is after the resolved upper bound ${maxYearBound}.`)
178
+ }
62
179
 
63
180
  const isControlled = value !== undefined
64
- const currentYear = isControlled ? (value && !Number.isNaN(value.getTime()) ? value.getFullYear() : (minYearBound ?? new Date().getFullYear())) : year
181
+ const currentYear = value !== undefined ? value.getFullYear() : year
65
182
 
66
- // 外部からの value または initialDate 変更に追従
67
- const effectiveTime = effectiveDate?.getTime()
183
+ const isSelectionOutsideBounds = currentYear < minYearBound || currentYear > maxYearBound
184
+
185
+ // 外部からの initialDate 変更に追従 (制御時は value がそのまま真実の源)
186
+ const effectiveTime = effectiveDate.getTime()
68
187
  useEffect(() => {
69
- if (!isControlled && effectiveDate && !Number.isNaN(effectiveDate.getTime())) {
70
- setYear(effectiveDate.getFullYear())
71
- }
188
+ if (isControlled) return
189
+ setYear(effectiveDate.getFullYear())
72
190
  }, [isControlled, effectiveTime])
73
191
 
74
192
  const emit = (nextYear: number) => {
75
193
  if (disabled) return
76
- let clamped = nextYear
77
- if (minYearBound !== undefined && clamped < minYearBound) {
78
- clamped = minYearBound
79
- }
80
- if (maxYearBound !== undefined && clamped > maxYearBound) {
81
- clamped = maxYearBound
194
+ if (nextYear < minYearBound || nextYear > maxYearBound) {
195
+ throw new RangeError(`YearSelector: refusing to emit ${nextYear}, which lies outside the declared bounds ${minYearBound}-${maxYearBound}.`)
82
196
  }
83
197
 
84
198
  if (!isControlled) {
85
- setYear(clamped)
199
+ setYear(nextYear)
86
200
  }
87
- const nextDate = new Date(clamped, 0, 1)
88
- nextDate.setFullYear(clamped)
89
- onChange?.(nextDate, clamped)
201
+ onChange?.(yearStart(nextYear), nextYear)
90
202
  }
91
203
 
92
- const isPrevDisabled = disabled || (minYearBound !== undefined && currentYear - 1 < minYearBound)
93
- const isNextDisabled = disabled || (maxYearBound !== undefined && currentYear + 1 > maxYearBound)
94
-
95
- const lower = minYearBound ?? Math.min(currentYear - 10, currentYear)
96
- const upper = maxYearBound ?? Math.max(currentYear + 1, currentYear)
97
- const start = Math.min(lower, currentYear)
98
- const end = Math.max(upper, currentYear)
99
- const yearsKey = `${start}_${end}`
204
+ const isPrevDisabled = disabled || currentYear - 1 < minYearBound
205
+ const isNextDisabled = disabled || currentYear + 1 > maxYearBound
100
206
 
101
207
  const years = useMemo(() => {
102
208
  const list: number[] = []
103
- for (let y = end; y >= start; y--) {
209
+ for (let y = maxYearBound; y >= minYearBound; y--) {
104
210
  list.push(y)
105
211
  }
212
+ // 境界が動的に狭まると、値が追従するまでの 1 描画だけ選択年が窓の外に出る。
213
+ // その年を選択肢に加えないと select は別の年を表示し、保持値と画面が食い違う
214
+ if (isSelectionOutsideBounds) {
215
+ list.push(currentYear)
216
+ list.sort((a, b) => b - a)
217
+ }
106
218
  return list
107
- }, [yearsKey])
219
+ }, [minYearBound, maxYearBound, isSelectionOutsideBounds, currentYear])
108
220
 
109
221
  return (
110
222
  <div className={`inline-flex w-32 items-center ${className}`} style={style}>
@@ -122,13 +234,15 @@ const YearSelectorComponent = (props: YearSelectorProps): React.JSX.Element => {
122
234
  className="mx-1 my-auto w-18 appearance-none 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 [text-align-last:center] [text-align:center] 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"
123
235
  value={currentYear}
124
236
  onChange={(e) => {
125
- if (e.target.value) {
126
- emit(Number(e.target.value))
127
- }
237
+ // 空値の change は選択解除であり、年として解釈しない
238
+ if (!e.target.value) return
239
+ const selected = Number(e.target.value)
240
+ if (!Number.isInteger(selected)) return
241
+ emit(selected)
128
242
  }}>
129
243
  {years.map((y) => (
130
244
  <option key={y} value={y} className="text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100">
131
- {y}
245
+ {formatLabel("year", yearStart(y), undefined, locale)}
132
246
  </option>
133
247
  ))}
134
248
  </select>
@@ -145,11 +259,15 @@ const YearSelectorComponent = (props: YearSelectorProps): React.JSX.Element => {
145
259
  )
146
260
  }
147
261
 
262
+ /**
263
+ * Year-resolution selector re-rendering only when a prop its output depends on changes.
264
+ * 描画結果が依存する Props の変化時のみ再描画する年単位セレクタ。
265
+ */
148
266
  export const YearSelector = memo(YearSelectorComponent, (prev, next) => {
149
267
  const prevDate = prev.value ?? prev.initialDate
150
268
  const nextDate = next.value ?? next.initialDate
151
- const prevYear = prevDate && !Number.isNaN(prevDate.getTime()) ? prevDate.getFullYear() : null
152
- const nextYear = nextDate && !Number.isNaN(nextDate.getTime()) ? nextDate.getFullYear() : null
269
+ const prevYear = prevDate ? prevDate.getFullYear() : null
270
+ const nextYear = nextDate ? nextDate.getFullYear() : null
153
271
  if (prevYear !== nextYear) return false
154
272
  if (prev.disabled !== next.disabled) return false
155
273
  if (prev.className !== next.className) return false
@@ -163,6 +281,7 @@ export const YearSelector = memo(YearSelectorComponent, (prev, next) => {
163
281
  if (prev.prevYearAriaLabel !== next.prevYearAriaLabel) return false
164
282
  if (prev.nextYearAriaLabel !== next.nextYearAriaLabel) return false
165
283
  if (prev.selectAriaLabel !== next.selectAriaLabel) return false
284
+ if (prev.locale !== next.locale) return false
166
285
  return true
167
286
  })
168
287
  YearSelector.displayName = "YearSelector"
package/src/index.ts CHANGED
@@ -5,8 +5,15 @@
5
5
  * This package provides range and point period slider components as well as
6
6
  * specialized year, month, and date selector inputs for time series analysis and navigation.
7
7
  *
8
+ * Every built-in string is locale-neutral: accessible names default to English, and value text
9
+ * defaults to locale-independent ISO 8601. A `locale` (BCP 47) prop switches the built-in value
10
+ * text to `Intl.DateTimeFormat`, and the per-label and per-option formatter props override both.
11
+ *
8
12
  * このパッケージは、時系列分析や期間移動のためのレンジ・ポイント期間スライダーコンポーネント、
9
13
  * および年・年月・年月日セレクタを提供します。
14
+ * 組み込み文字列はロケール中立で、アクセシブル名の既定は英語、値テキストの既定はロケール非依存の
15
+ * ISO 8601 表記。`locale` (BCP 47) 指定で `Intl.DateTimeFormat` 書式へ切替、
16
+ * ラベル・選択肢のフォーマッタ Props はその双方に優先。
10
17
  */
11
18
 
12
19
  export type { DateSelectorProps } from "./DateSelector"
@@ -17,6 +24,7 @@ export type {
17
24
  AccessibleSliderLabels,
18
25
  BasePeriodSliderProps,
19
26
  ColorSchemePalette,
27
+ ConnectDragValueOptions,
20
28
  LabelSlantConfig,
21
29
  LabelSlantResult,
22
30
  PeriodSliderColorScheme,
@@ -24,23 +32,27 @@ export type {
24
32
  PeriodSliderPointProps,
25
33
  PeriodSliderProps,
26
34
  PeriodSliderRangeProps,
35
+ PeriodSliderSnapMode,
27
36
  PeriodSliderUnit,
28
37
  PeriodSliderVernierProps,
29
38
  VernierHandle,
30
39
  } from "./PeriodSlider"
31
40
  export {
32
41
  addUnit,
42
+ areStylesEqual,
33
43
  COLOR_SCHEME_PALETTES,
34
44
  calculateConnectDragValues,
35
45
  calculateHandleDragValues,
36
46
  calculateKeyboardActionValues,
37
47
  calculateLabelSlant,
38
48
  calculateVernierMacroDrag,
49
+ calculateVernierMicroDrag,
39
50
  decode,
40
51
  encode,
41
52
  findNearestDateIndex,
42
53
  formatLabel,
43
54
  formatScreenReaderLabel,
55
+ getActiveDragHandle,
44
56
  getMacroWindowEndDate,
45
57
  getSortedAllowedDates,
46
58
  normalizeDateByUnit,
@@ -51,6 +63,7 @@ export {
51
63
  // State Management Hooks (Zero-Boilerplate React Hooks)
52
64
  // ======================================================================
53
65
  export type {
66
+ SelectorProps,
54
67
  UsePeriodSliderPointOptions,
55
68
  UsePeriodSliderPointReturn,
56
69
  UsePeriodSliderRangeOptions,
@@ -2,15 +2,19 @@
2
2
 
3
3
  /* ============================================================= */
4
4
  /* カラーテーマ別 CSS カスタムプロパティ (ベースカラー切替) */
5
+ /* --aqps-*-on-color は各スウォッチ上で 4.5:1 以上 (WCAG 1.4.3 AA) を満たす前景色。 */
6
+ /* スウォッチ側は COLOR_SCHEME_PALETTES と同値を保つ必要があるため、色を暗くせず前景で比を確保する。 */
5
7
  /* ============================================================= */
6
8
  :root,
7
9
  [data-color-scheme="blue-rose"] {
8
10
  --aqps-macro-color: #0284c7;
9
11
  --aqps-macro-light: #38bdf8;
10
12
  --aqps-macro-glow: rgba(56, 189, 248, 0.4);
13
+ --aqps-macro-on-color: #020617;
11
14
  --aqps-micro-color: #e11d48;
12
15
  --aqps-micro-light: #fb7185;
13
16
  --aqps-micro-glow: rgba(244, 63, 94, 0.4);
17
+ --aqps-micro-on-color: #ffffff;
14
18
  --aqps-accent-color: #0284c7;
15
19
  --aqps-accent-light: #38bdf8;
16
20
  --aqps-accent-glow: rgba(56, 189, 248, 0.4);
@@ -20,9 +24,11 @@
20
24
  --aqps-macro-color: #4f46e5;
21
25
  --aqps-macro-light: #818cf8;
22
26
  --aqps-macro-glow: rgba(99, 102, 241, 0.4);
27
+ --aqps-macro-on-color: #ffffff;
23
28
  --aqps-micro-color: #d97706;
24
29
  --aqps-micro-light: #fbbf24;
25
30
  --aqps-micro-glow: rgba(217, 119, 6, 0.4);
31
+ --aqps-micro-on-color: #020617;
26
32
  --aqps-accent-color: #4f46e5;
27
33
  --aqps-accent-light: #818cf8;
28
34
  --aqps-accent-glow: rgba(99, 102, 241, 0.4);
@@ -32,9 +38,11 @@
32
38
  --aqps-macro-color: #0d9488;
33
39
  --aqps-macro-light: #2dd4bf;
34
40
  --aqps-macro-glow: rgba(13, 148, 136, 0.4);
41
+ --aqps-macro-on-color: #020617;
35
42
  --aqps-micro-color: #059669;
36
43
  --aqps-micro-light: #34d399;
37
44
  --aqps-micro-glow: rgba(5, 150, 105, 0.4);
45
+ --aqps-micro-on-color: #020617;
38
46
  --aqps-accent-color: #0d9488;
39
47
  --aqps-accent-light: #2dd4bf;
40
48
  --aqps-accent-glow: rgba(13, 148, 136, 0.4);
@@ -44,9 +52,11 @@
44
52
  --aqps-macro-color: #7c3aed;
45
53
  --aqps-macro-light: #a78bfa;
46
54
  --aqps-macro-glow: rgba(124, 58, 237, 0.4);
55
+ --aqps-macro-on-color: #ffffff;
47
56
  --aqps-micro-color: #c026d3;
48
57
  --aqps-micro-light: #e879f9;
49
58
  --aqps-micro-glow: rgba(192, 38, 211, 0.4);
59
+ --aqps-micro-on-color: #ffffff;
50
60
  --aqps-accent-color: #7c3aed;
51
61
  --aqps-accent-light: #a78bfa;
52
62
  --aqps-accent-glow: rgba(124, 58, 237, 0.4);
@@ -56,9 +66,11 @@
56
66
  --aqps-macro-color: #475569;
57
67
  --aqps-macro-light: #94a3b8;
58
68
  --aqps-macro-glow: rgba(71, 85, 105, 0.4);
69
+ --aqps-macro-on-color: #ffffff;
59
70
  --aqps-micro-color: #0284c7;
60
71
  --aqps-micro-light: #38bdf8;
61
72
  --aqps-micro-glow: rgba(56, 189, 248, 0.4);
73
+ --aqps-micro-on-color: #020617;
62
74
  --aqps-accent-color: #475569;
63
75
  --aqps-accent-light: #94a3b8;
64
76
  --aqps-accent-glow: rgba(71, 85, 105, 0.4);
@@ -68,9 +80,11 @@
68
80
  --aqps-macro-color: #52525b;
69
81
  --aqps-macro-light: #a1a1aa;
70
82
  --aqps-macro-glow: rgba(82, 82, 91, 0.4);
83
+ --aqps-macro-on-color: #ffffff;
71
84
  --aqps-micro-color: #18181b;
72
85
  --aqps-micro-light: #71717a;
73
86
  --aqps-micro-glow: rgba(24, 24, 27, 0.4);
87
+ --aqps-micro-on-color: #ffffff;
74
88
  --aqps-accent-color: #27272a;
75
89
  --aqps-accent-light: #71717a;
76
90
  --aqps-accent-glow: rgba(39, 39, 42, 0.4);
@@ -86,7 +100,8 @@
86
100
  margin-top: 2px;
87
101
  align-self: center;
88
102
  background-color: #e2e8f0;
89
- box-shadow: inset 0 0 0 1px #94a3b8;
103
+ /* #94a3b8 は白背景に対し 2.56:1 で SC 1.4.11 の 3:1 を満たさない。 */
104
+ box-shadow: inset 0 0 0 1px #64748b;
90
105
  border-radius: 4px;
91
106
  cursor: ew-resize;
92
107
  touch-action: none;
@@ -108,11 +123,13 @@
108
123
  }
109
124
 
110
125
  /* 連結範囲バー (通常 Range モード) */
126
+ /* 背景色の !important は必須: 本シートは components 層に載るため、同じ要素に付く Tailwind */
127
+ /* ユーティリティ (utilities 層) が詳細度に関係なく後勝ちし、colorScheme が無効化される。 */
111
128
  .period-slider-connect {
112
129
  position: absolute;
113
130
  top: 0;
114
131
  bottom: 0;
115
- background-color: var(--aqps-accent-color, #0284c7);
132
+ background-color: var(--aqps-accent-color, #0284c7) !important;
116
133
  border-radius: 4px;
117
134
  cursor: ew-resize;
118
135
  touch-action: none;
@@ -138,7 +155,16 @@
138
155
  }
139
156
 
140
157
  .dark .period-slider-connect {
141
- background-color: var(--aqps-accent-light, #38bdf8);
158
+ background-color: var(--aqps-accent-light, #38bdf8) !important;
159
+ }
160
+
161
+ /* ホバーはアクセント対の反対側へ振ることで、明暗どちらのモードでも変化が視認できる。 */
162
+ .period-slider-connect:hover {
163
+ background-color: var(--aqps-accent-light, #38bdf8) !important;
164
+ }
165
+
166
+ .dark .period-slider-connect:hover {
167
+ background-color: var(--aqps-accent-color, #0284c7) !important;
142
168
  }
143
169
 
144
170
  /* つまみラッパー (位置決め) */
@@ -168,6 +194,7 @@
168
194
  /* つまみ丸グラフィック (.period-slider-knob) */
169
195
  .period-slider-knob {
170
196
  position: relative;
197
+ background-color: var(--aqps-accent-color, #0284c7) !important;
171
198
  overflow: visible;
172
199
  transition:
173
200
  transform 0.15s cubic-bezier(0.2, 0, 0, 1),
@@ -176,6 +203,10 @@
176
203
  transform-origin: center center;
177
204
  }
178
205
 
206
+ .dark .period-slider-knob {
207
+ background-color: var(--aqps-accent-light, #38bdf8) !important;
208
+ }
209
+
179
210
  .period-slider-handle:hover .period-slider-knob {
180
211
  transform: scale(1.1);
181
212
  }
@@ -247,14 +278,14 @@
247
278
  box-shadow:
248
279
  0 0 0 2px #ffffff,
249
280
  0 0 16px var(--aqps-accent-light, #38bdf8),
250
- 0 0 28px var(--aqps-accent-glow, rgba(56, 189, 248, 0.85));
281
+ 0 0 28px var(--aqps-accent-glow, rgba(56, 189, 248, 0.85)) !important;
251
282
  }
252
283
 
253
284
  .dark .period-slider-handle[data-active="true"] .period-slider-knob {
254
285
  box-shadow:
255
286
  0 0 0 2px #0f172a,
256
287
  0 0 16px var(--aqps-accent-light, #38bdf8),
257
- 0 0 28px var(--aqps-accent-glow, rgba(56, 189, 248, 0.85));
288
+ 0 0 28px var(--aqps-accent-glow, rgba(56, 189, 248, 0.85)) !important;
258
289
  }
259
290
 
260
291
  .period-slider-handle[data-active="true"] .period-slider-knob::after {
@@ -608,9 +639,10 @@
608
639
  filter: drop-shadow(0 0 2px var(--aqps-micro-glow, rgba(244, 63, 94, 0.45))) drop-shadow(0 0 6px var(--aqps-micro-glow, rgba(244, 63, 94, 0.2)));
609
640
  }
610
641
 
611
- /* キーボードフォーカス時のアクセシブルなフォーカスリング (WCAG 2.1 AAA 準拠) */
642
+ /* キーボードフォーカス時のアクセシブルなフォーカスリング。 */
643
+ /* drop-shadow() は spread を取らない (長さは最大 3 つ) ため、4 つ書くと宣言全体が無効化され待機時グローのままになる。 */
612
644
  .period-slider-handle-vernier:focus-visible .period-slider-knob-svg {
613
- filter: drop-shadow(0 0 0 2px #3b82f6) drop-shadow(0 0 6px rgba(59, 130, 246, 0.8)) !important;
645
+ filter: drop-shadow(0 0 2px #3b82f6) drop-shadow(0 0 2px #3b82f6) drop-shadow(0 0 6px rgba(59, 130, 246, 0.8)) !important;
614
646
  }
615
647
 
616
648
  .period-slider-knob-path-macro {
@@ -882,12 +914,14 @@
882
914
  /* Vernier ツールチップのカラーセマンティクス連動 (マクロ=青系、ミクロ=赤系) */
883
915
  .period-slider-handle-vernier[data-handle-type^="macro-"] .period-slider-tooltip {
884
916
  background-color: var(--aqps-macro-color, #0284c7) !important;
917
+ color: var(--aqps-macro-on-color) !important;
885
918
  border-color: var(--aqps-macro-light, #38bdf8) !important;
886
919
  box-shadow: 0 2px 6px var(--aqps-macro-glow, rgba(56, 189, 248, 0.35)) !important;
887
920
  }
888
921
 
889
922
  .period-slider-handle-vernier[data-handle-type^="micro-"] .period-slider-tooltip {
890
923
  background-color: var(--aqps-micro-color, #e11d48) !important;
924
+ color: var(--aqps-micro-on-color) !important;
891
925
  border-color: var(--aqps-micro-light, #fb7185) !important;
892
926
  box-shadow: 0 2px 6px var(--aqps-micro-glow, rgba(244, 63, 94, 0.35)) !important;
893
927
  }