@aiquants/period-slider 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +73 -0
- package/README.md +85 -40
- package/dist/DateSelector.d.ts +2 -2
- package/dist/DateSelector.d.ts.map +1 -1
- package/dist/MonthSelector.d.ts +2 -2
- package/dist/MonthSelector.d.ts.map +1 -1
- package/dist/PeriodSlider.d.ts +203 -15
- package/dist/PeriodSlider.d.ts.map +1 -1
- package/dist/StepperButton.d.ts +58 -0
- package/dist/StepperButton.d.ts.map +1 -0
- package/dist/YearSelector.d.ts +2 -2
- package/dist/YearSelector.d.ts.map +1 -1
- package/dist/dragPresentation.d.ts +191 -0
- package/dist/dragPresentation.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1964 -1683
- package/dist/rangeAreaWheel.d.ts +111 -0
- package/dist/rangeAreaWheel.d.ts.map +1 -0
- package/dist/styles/period-slider.css +1 -1
- package/dist/styles/period-slider.standalone.css +1 -1
- package/dist/usePeriodSlider.d.ts +15 -11
- package/dist/usePeriodSlider.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/DateSelector.tsx +12 -28
- package/src/MonthSelector.tsx +13 -26
- package/src/PeriodSlider.tsx +1545 -572
- package/src/StepperButton.tsx +251 -0
- package/src/YearSelector.tsx +9 -23
- package/src/dragPresentation.ts +273 -0
- package/src/index.ts +8 -4
- package/src/rangeAreaWheel.ts +285 -0
- package/src/styles/period-slider.css +332 -108
- package/src/usePeriodSlider.ts +243 -90
package/src/PeriodSlider.tsx
CHANGED
|
@@ -12,7 +12,28 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { addDays, addMonths, addYears } from "date-fns"
|
|
14
14
|
import type React from "react"
|
|
15
|
-
import { type CSSProperties, memo, useCallback, useEffect, useId, useMemo, useRef, useState } from "react"
|
|
15
|
+
import { type CSSProperties, memo, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react"
|
|
16
|
+
import {
|
|
17
|
+
buildVernierProjectionPath,
|
|
18
|
+
clearDragPresentation,
|
|
19
|
+
DRAG_LABEL_VARIABLE_PREFIXES,
|
|
20
|
+
DRAG_PRESENTATION_VARIABLES,
|
|
21
|
+
DRAG_SNAP_ATTRIBUTE,
|
|
22
|
+
DRAG_SNAP_BACK_MS,
|
|
23
|
+
DRAG_SNAP_DURATION_VARIABLE,
|
|
24
|
+
type DragLabelPlacement,
|
|
25
|
+
type DragLabelPlacementPair,
|
|
26
|
+
type DragPresentationRail,
|
|
27
|
+
dragLabelPlacementValue,
|
|
28
|
+
dragPresentationValue,
|
|
29
|
+
resolveBandDragRatios,
|
|
30
|
+
resolveDraggedEdge,
|
|
31
|
+
resolveEdgeDragRatios,
|
|
32
|
+
writeDragLabelPlacement,
|
|
33
|
+
writeDragPresentation,
|
|
34
|
+
} from "./dragPresentation"
|
|
35
|
+
import { containsEventTarget, ownsPaintedPoint, registerRangeAreaWheelParticipant } from "./rangeAreaWheel"
|
|
36
|
+
import { STEPPER_OUTWARD_RESERVE_CLASSES, STEPPER_ROW_GAP_CLASS, type StepArrowDirection, StepperButton } from "./StepperButton"
|
|
16
37
|
|
|
17
38
|
// ======================================================================
|
|
18
39
|
// 1. Core Domain Types & Public Interfaces
|
|
@@ -212,7 +233,7 @@ export interface BasePeriodSliderProps extends AccessibleSliderLabels {
|
|
|
212
233
|
showStepper?: boolean
|
|
213
234
|
/** Tooltip display strategy (default: "always") / ツールチップ表示方式 (既定: "always") */
|
|
214
235
|
tooltipStyle?: "always" | "hover" | "balloon"
|
|
215
|
-
/** Label position: "top" (default) or "bottom" /
|
|
236
|
+
/** Label position: "top" (default) or "bottom" / ラベル表示位置 ("top": 上側 [既定], "bottom": 下側) */
|
|
216
237
|
labelPosition?: PeriodSliderLabelPosition
|
|
217
238
|
/** Whether to automatically slant labels when a pair comes close, in range mode and on both vernier rails (default: true) / Range モードとノギスの両レールで、対が接近した時に自動斜め表示するか (既定: true) */
|
|
218
239
|
autoSlantLabels?: boolean
|
|
@@ -505,6 +526,33 @@ export const addUnit = (unit: PeriodSliderUnit, d: Date, amount: number): Date =
|
|
|
505
526
|
return addDays(d, amount)
|
|
506
527
|
}
|
|
507
528
|
|
|
529
|
+
/**
|
|
530
|
+
* Calculates the start boundary of a macro window in micro unit resolution.
|
|
531
|
+
* マクロ窓の開始境界を、ミクロ単位の解像度で算出する関数。
|
|
532
|
+
*
|
|
533
|
+
* The end boundary is expanded to the end of the terminal macro period (getMacroWindowEndDate), so the
|
|
534
|
+
* start must be collapsed to the head of the leading one: otherwise a window whose raw start sits mid
|
|
535
|
+
* period opens a rail that begins somewhere the macro handles never claim.
|
|
536
|
+
* 終了境界は末尾マクロ期間の末日まで広げられる (getMacroWindowEndDate) ため、開始境界も先頭マクロ期間の
|
|
537
|
+
* 先頭へ畳む必要がある。畳まないと、生の開始日が期間の途中にある窓で、マクロつまみが一度も名乗らない
|
|
538
|
+
* 位置からミクロレールが始まる。
|
|
539
|
+
*
|
|
540
|
+
* Normalising by the macro unit and then by the micro unit reproduces, for every unit pair, the mirror
|
|
541
|
+
* image of the end-side case table - including the pairs where the macro unit is the finer of the two.
|
|
542
|
+
* マクロ単位で正規化してからミクロ単位で正規化する形は、マクロ側が細かい組み合わせも含め、
|
|
543
|
+
* 全ての単位の組で終了側の場合分けの鏡像と一致する。
|
|
544
|
+
*
|
|
545
|
+
* @param macroUnit - Macro scale unit / マクロ側の時間解像度単位
|
|
546
|
+
* @param microUnit - Micro scale unit / ミクロ側の時間解像度単位
|
|
547
|
+
* @param d - Macro range start date / マクロ範囲の開始日付
|
|
548
|
+
* @returns Corrected boundary Date in micro unit resolution / 補正後のミクロ解像度開始日付
|
|
549
|
+
* @throws RangeError when d is absent or an Invalid Date / d が未指定または Invalid Date の場合
|
|
550
|
+
*/
|
|
551
|
+
export const getMacroWindowStartDate = (macroUnit: PeriodSliderUnit, microUnit: PeriodSliderUnit, d: Date): Date => {
|
|
552
|
+
if (!isValidDate(d)) throw new RangeError(`getMacroWindowStartDate: d must be a valid Date (received: ${describeDateValue(d)})`)
|
|
553
|
+
return normalizeDateByUnit(microUnit, normalizeDateByUnit(macroUnit, d))
|
|
554
|
+
}
|
|
555
|
+
|
|
508
556
|
/**
|
|
509
557
|
* Calculates the end boundary of a macro window in micro unit resolution.
|
|
510
558
|
* When the macro unit is coarser than the micro unit, expands the date to encompass
|
|
@@ -538,6 +586,50 @@ export const getMacroWindowEndDate = (macroUnit: PeriodSliderUnit, microUnit: Pe
|
|
|
538
586
|
return normalizeDateByUnit(microUnit, d)
|
|
539
587
|
}
|
|
540
588
|
|
|
589
|
+
/**
|
|
590
|
+
* Clamps a date into an inclusive boundary pair, returning the input itself when it already fits.
|
|
591
|
+
* 日付を境界の対の内側へ収める関数 (既に内側なら入力をそのまま返す)。
|
|
592
|
+
*
|
|
593
|
+
* @param date - Date to contain / 収める対象の日付
|
|
594
|
+
* @param min - Lower boundary / 下限
|
|
595
|
+
* @param max - Upper boundary / 上限
|
|
596
|
+
* @returns Date guaranteed to lie within [min, max] / [min, max] の内側であることが保証された日付
|
|
597
|
+
*/
|
|
598
|
+
const clampDateInto = (date: Date, min: Date, max: Date): Date => (date < min ? min : date > max ? max : date)
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Resolves the effective micro window: the macro window intersected with [minDate, maxDate].
|
|
602
|
+
* Both boundaries of a macro window are rounded outward to whole macro periods, so on its own the
|
|
603
|
+
* window reaches past the domain whenever minDate or maxDate falls mid period. The rails, the state
|
|
604
|
+
* hooks' containment and the micro selectors must all read the same intersected pair: when one of them
|
|
605
|
+
* uses the raw window instead, it commits a micro date that the component's own domain assertions then
|
|
606
|
+
* reject, and the tree throws during render.
|
|
607
|
+
* 実効ミクロ窓 (マクロ窓と [minDate, maxDate] の交差) を解決する関数。
|
|
608
|
+
* マクロ窓は両端ともマクロ期間の外側へ丸められるため、minDate / maxDate が期間の途中にあると窓単体では
|
|
609
|
+
* 定義域を越える。レール・ステートフックの収め込み・ミクロセレクタが同一の交差結果を共有しないと、
|
|
610
|
+
* 生の窓を見た側が定義域外のミクロ日付を確定させ、本体の定義域表明がそれを弾いて描画中に送出する。
|
|
611
|
+
*
|
|
612
|
+
* @param macroUnit - Macro scale unit / マクロ側の時間解像度単位
|
|
613
|
+
* @param microUnit - Micro scale unit / ミクロ側の時間解像度単位
|
|
614
|
+
* @param macroRange - Current macro window tuple / 現在のマクロ窓タプル
|
|
615
|
+
* @param minDate - Domain lower boundary / 定義域の下限
|
|
616
|
+
* @param maxDate - Domain upper boundary / 定義域の上限
|
|
617
|
+
* @returns Window tuple in micro unit resolution, guaranteed to lie inside [minDate, maxDate] at that resolution / そのミクロ解像度で [minDate, maxDate] の内側であることが保証されたミクロ解像度の窓タプル
|
|
618
|
+
* @throws RangeError naming this function when macroRange is not a usable tuple, when a boundary is absent or an Invalid Date, or when either pair is inverted / macroRange が利用可能なタプルでない場合、境界が未指定または Invalid Date の場合、いずれかの対が逆転している場合 (メッセージは本関数を名指しする)
|
|
619
|
+
*/
|
|
620
|
+
export const resolveMacroWindow = (macroUnit: PeriodSliderUnit, microUnit: PeriodSliderUnit, macroRange: [Date, Date], minDate: Date, maxDate: Date): [Date, Date] => {
|
|
621
|
+
// 公開関数であり、内部の呼び出し元が持つ表明の外からも呼ばれる。自分の引数は自分の名前で拒否する
|
|
622
|
+
assertDateRangeTuple("macroRange", macroRange, "resolveMacroWindow")
|
|
623
|
+
if (!isValidDate(minDate)) throw new RangeError(`resolveMacroWindow: minDate must be a valid Date (received: ${describeDateValue(minDate)})`)
|
|
624
|
+
if (!isValidDate(maxDate)) throw new RangeError(`resolveMacroWindow: maxDate must be a valid Date (received: ${describeDateValue(maxDate)})`)
|
|
625
|
+
if (maxDate.getTime() < minDate.getTime()) throw new RangeError(`resolveMacroWindow: maxDate must not precede minDate (minDate: ${describeDateValue(minDate)}, maxDate: ${describeDateValue(maxDate)})`)
|
|
626
|
+
// クランプの結果は生の minDate / maxDate になり得るため、ミクロ単位へ畳み直す。
|
|
627
|
+
// 畳まないと返り値は「ミクロ解像度」を名乗れず、日付で比較する呼び出し側が符号化で比較する側と食い違う。
|
|
628
|
+
// 境界が期間の途中を指すと畳んだ開始は生の minDate より前の時刻を持つが、それはレールが実際に描く先頭の
|
|
629
|
+
// ミクロ期間そのものであり、定義域の内包もそのミクロ解像度で判定される (assertSelectionWithinDomain)
|
|
630
|
+
return [normalizeDateByUnit(microUnit, clampDateInto(getMacroWindowStartDate(macroUnit, microUnit, macroRange[0]), minDate, maxDate)), normalizeDateByUnit(microUnit, clampDateInto(getMacroWindowEndDate(macroUnit, microUnit, macroRange[1]), minDate, maxDate))]
|
|
631
|
+
}
|
|
632
|
+
|
|
541
633
|
/**
|
|
542
634
|
* Intl option set each unit is formatted with once a locale is supplied.
|
|
543
635
|
* ロケール指定時に各単位を書式化する Intl オプション集合。
|
|
@@ -785,25 +877,6 @@ export const calculateHandleDragValues = (handle: "low" | "high", clampedVal: nu
|
|
|
785
877
|
return [Math.max(rangeMin, Math.min(rangeMax, nextLow)), Math.max(rangeMin, Math.min(rangeMax, nextHigh))]
|
|
786
878
|
}
|
|
787
879
|
|
|
788
|
-
/**
|
|
789
|
-
* Determines which handle ('low' or 'high') is actively under the pointer when dragging.
|
|
790
|
-
* ドラッグ操作中にポインターが現在操作しているハンドル ('low' または 'high') の判定。
|
|
791
|
-
*
|
|
792
|
-
* @param originalHandle - Originally grabbed handle on pointerdown ('low' or 'high')
|
|
793
|
-
* @param pointerVal - Current value calculated from pointer position
|
|
794
|
-
* @param startLowVal - Initial low value when drag began
|
|
795
|
-
* @param startHighVal - Initial high value when drag began
|
|
796
|
-
* @param isPointMode - Whether slider is in single-point mode
|
|
797
|
-
* @returns Handle name corresponding to the active pointer position
|
|
798
|
-
*/
|
|
799
|
-
export const getActiveDragHandle = (originalHandle: "low" | "high", pointerVal: number, startLowVal: number, startHighVal: number, isPointMode: boolean): "low" | "high" => {
|
|
800
|
-
if (isPointMode) return "low"
|
|
801
|
-
if (originalHandle === "low") {
|
|
802
|
-
return pointerVal > startHighVal ? "high" : "low"
|
|
803
|
-
}
|
|
804
|
-
return pointerVal < startLowVal ? "low" : "high"
|
|
805
|
-
}
|
|
806
|
-
|
|
807
880
|
/**
|
|
808
881
|
* Input bundle for translating a connect-bar drag into a new [lower, upper] value pair.
|
|
809
882
|
* 接続バードラッグを新しい上下限値の組へ変換するための入力一式。
|
|
@@ -979,6 +1052,22 @@ const DEFAULT_LABEL_PADDING_PX = 12
|
|
|
979
1052
|
/** Angle the labels reach when the two handles coincide, in degrees / 2 つのつまみが完全一致した時に到達する角度 (度) */
|
|
980
1053
|
const DEFAULT_MAX_SLANT_ANGLE_DEG = 90
|
|
981
1054
|
|
|
1055
|
+
/**
|
|
1056
|
+
* Half extents of the bounding box of a rectangle rotated by an angle, along its unrotated width and across it.
|
|
1057
|
+
* 角度だけ回転した矩形の外接矩形の半寸法 (回転前の幅方向と、その直交方向)。
|
|
1058
|
+
*
|
|
1059
|
+
* @param widthPx - Unrotated width in pixels / 回転前の幅 (ピクセル)
|
|
1060
|
+
* @param heightPx - Unrotated height in pixels / 回転前の高さ (ピクセル)
|
|
1061
|
+
* @param angleDeg - Rotation in degrees / 回転角 (度)
|
|
1062
|
+
* @returns Half extents along and across the unrotated width / 回転前の幅方向と直交方向の半寸法
|
|
1063
|
+
*/
|
|
1064
|
+
export const resolveRotatedHalfExtents = (widthPx: number, heightPx: number, angleDeg: number): { alongPx: number; acrossPx: number } => {
|
|
1065
|
+
const rad = (angleDeg * Math.PI) / 180
|
|
1066
|
+
const sin = Math.abs(Math.sin(rad))
|
|
1067
|
+
const cos = Math.abs(Math.cos(rad))
|
|
1068
|
+
return { alongPx: (widthPx * cos + heightPx * sin) / 2, acrossPx: (widthPx * sin + heightPx * cos) / 2 }
|
|
1069
|
+
}
|
|
1070
|
+
|
|
982
1071
|
/**
|
|
983
1072
|
* Builds the upright placement both labels take whenever no rotation applies.
|
|
984
1073
|
* 回転を行わない場合に両ラベルが取る直立配置を構築する関数。
|
|
@@ -1015,6 +1104,11 @@ const buildHorizontalSlantResult = (labelPosition: PeriodSliderLabelPosition, co
|
|
|
1015
1104
|
* label yields the upright baseline instead of an invented number.
|
|
1016
1105
|
* 幾何計算が使う 2 つの寸法はいずれも描画結果であるため、トラックまたはラベルが未実測なら数値を捏造せず直立基準値を返す。
|
|
1017
1106
|
*
|
|
1107
|
+
* The rotated half extents come from `resolveRotatedHalfExtents`, the same helper the range area reads to know how far
|
|
1108
|
+
* a drawn label reaches from the rail, so the placement and the area can never disagree about a rotated label's size.
|
|
1109
|
+
* 回転後の半寸法は `resolveRotatedHalfExtents` から得る。範囲領域が描かれたラベルのレールからの到達距離を求める際も同じ関数を読むため、
|
|
1110
|
+
* 回転したラベルの寸法について配置と範囲領域が食い違わない。
|
|
1111
|
+
*
|
|
1018
1112
|
* @param lowPct - Percent position of lower handle (0-100) / 下限つまみの位置 (0-100%)
|
|
1019
1113
|
* @param highPct - Percent position of upper handle (0-100) / 上限つまみの位置 (0-100%)
|
|
1020
1114
|
* @param trackWidthPx - Measured pixel width of the track; a non-positive value means "not measured yet" and yields the horizontal baseline / 実測トラック幅 (0 以下は未実測とみなし水平基準値を返す)
|
|
@@ -1057,14 +1151,13 @@ export const calculateLabelSlant = (lowPct: number, highPct: number, trackWidthP
|
|
|
1057
1151
|
|
|
1058
1152
|
// 回転後の外接矩形の半高は (W/2)|sin θ| + (H/2)|cos θ|。
|
|
1059
1153
|
// 中心をこの分だけ離隔に足して押し出さないと、傾けた瞬間にラベル下端がつまみへ食い込む
|
|
1060
|
-
const
|
|
1061
|
-
const
|
|
1062
|
-
const calculatedCenterDist = clearance + halfHeightRotated
|
|
1154
|
+
const rotated = resolveRotatedHalfExtents(labelWidth, labelHeight, angle)
|
|
1155
|
+
const calculatedCenterDist = clearance + rotated.acrossPx
|
|
1063
1156
|
const calculatedOffsetY = labelPosition === "top" ? -calculatedCenterDist : +calculatedCenterDist
|
|
1064
1157
|
|
|
1065
1158
|
// 同角度で回転した合同な 2 矩形は、中心間距離が回転後の水平占有幅 W*|cos θ| + H*|sin θ| 以上になった時点で
|
|
1066
1159
|
// 分離軸定理より必ず分離する。角度ランプだけでは中間距離帯で重なるため、不足分を左右へ等分して押し広げる
|
|
1067
|
-
const rotatedFootprint =
|
|
1160
|
+
const rotatedFootprint = 2 * rotated.alongPx
|
|
1068
1161
|
const shiftX = Math.max(0, (rotatedFootprint + padding - pixelDistance) / 2)
|
|
1069
1162
|
|
|
1070
1163
|
return {
|
|
@@ -1106,9 +1199,63 @@ export type VernierHandle = "macro-low" | "macro-high" | "macro-connect" | "micr
|
|
|
1106
1199
|
*/
|
|
1107
1200
|
export type VernierMicroShape = "range" | "point"
|
|
1108
1201
|
|
|
1202
|
+
/**
|
|
1203
|
+
* Tells which vernier rail a cross-axis offset falls on.
|
|
1204
|
+
* 直交軸オフセットがノギスのどちらのレールに属するかを判定する関数。
|
|
1205
|
+
*
|
|
1206
|
+
* The track carries two rails separated by its centre line, so the sign of the offset - together with
|
|
1207
|
+
* which rail the macro scale was drawn on - is the whole rule. Every gesture that has to pick a scale
|
|
1208
|
+
* (a press, a wheel) reads it here rather than restating it.
|
|
1209
|
+
* トラックは中心線で分かれた 2 本のレールを載せるため、オフセットの符号とマクロレールの側だけが判定規則の全て。
|
|
1210
|
+
* スケールを選ぶ必要のある操作 (押下・ホイール) は、規則を再掲せず本関数を読む。
|
|
1211
|
+
*
|
|
1212
|
+
* The rule is half-open: a negative offset is the first rail (top or left) and offset 0 is the second, because
|
|
1213
|
+
* pixels are addressed by their top-left corner, so the pixel that starts at the centre line is drawn and
|
|
1214
|
+
* hit-tested as part of the second band. An offset far outside the 8px band (over a label, in the lane) reads the
|
|
1215
|
+
* same sign.
|
|
1216
|
+
* 判定は半開区間で、負のオフセットが第一レール (上または左)、0 は第二レール。画素は左上角で番地付けされるため、
|
|
1217
|
+
* 中心線から始まる画素は第二レールの帯として描かれ、ヒットテストされる。8px の帯から離れた位置 (ラベルの上、レーン) も同じ符号で読む。
|
|
1218
|
+
*
|
|
1219
|
+
* @param pointerCrossAxisOffset - Signed pointer offset from the track center line in pixels / トラック中心線からのポインター直交軸オフセット (ピクセル、符号付き)
|
|
1220
|
+
* @param orientation - Which rail the macro scale is drawn on / マクロスケールを描くレール
|
|
1221
|
+
* @returns Rail the offset belongs to / オフセットが属するレール
|
|
1222
|
+
*/
|
|
1223
|
+
export const resolveVernierRailZone = (pointerCrossAxisOffset: number, orientation: "macro-top" | "macro-bottom" | "macro-left" | "macro-right"): "macro" | "micro" => {
|
|
1224
|
+
// orientation に応じて第一レール (上段または左段) がマクロかミクロかを決定
|
|
1225
|
+
const isFirstRailMacro = orientation === "macro-top" || orientation === "macro-left"
|
|
1226
|
+
// 画素は左上角で番地付けされるため、中心線から始まる画素は第二レールの帯に属する (ヒットテストと一致)
|
|
1227
|
+
const isTargetingFirstRail = pointerCrossAxisOffset < 0
|
|
1228
|
+
return (isFirstRailMacro && isTargetingFirstRail) || !(isFirstRailMacro || isTargetingFirstRail) ? "macro" : "micro"
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
/**
|
|
1232
|
+
* Resolves the signed unit step a wheel gesture asks the rail for.
|
|
1233
|
+
* ホイール操作がレールへ要求する符号付き 1 単位ステップを解決する関数。
|
|
1234
|
+
*
|
|
1235
|
+
* Holding Shift makes some platforms report the gesture on deltaX and others on deltaY, so the dominant
|
|
1236
|
+
* component is read as the primary axis instead of trusting either field.
|
|
1237
|
+
* Shift 押下時に deltaX で報告する環境と deltaY で報告する環境があるため、いずれかを信じず支配的な成分を主軸として読む。
|
|
1238
|
+
*
|
|
1239
|
+
* Screen coordinates grow rightwards and downwards, while the rail grows rightwards when horizontal and
|
|
1240
|
+
* upwards when vertical - so the sign is flipped for a vertical rail. This is the axis, not a preference.
|
|
1241
|
+
* 画面座標は右・下方向へ増えるのに対し、レールは横向きなら右、縦向きなら上へ伸びるため、縦向きだけ符号が反転する。
|
|
1242
|
+
* これは好みではなく軸そのもの。
|
|
1243
|
+
*
|
|
1244
|
+
* @param deltaX - Horizontal wheel delta / ホイールの水平デルタ
|
|
1245
|
+
* @param deltaY - Vertical wheel delta / ホイールの垂直デルタ
|
|
1246
|
+
* @param isVertical - Whether the rail runs along the vertical axis / レールが垂直方向か
|
|
1247
|
+
* @returns +1 toward maxDate, -1 toward minDate, or 0 when the gesture carries no usable delta / maxDate 方向なら +1、minDate 方向なら -1、使えるデルタが無ければ 0
|
|
1248
|
+
*/
|
|
1249
|
+
export const resolveWheelStep = (deltaX: number, deltaY: number, isVertical: boolean): number => {
|
|
1250
|
+
const dominant = Math.abs(deltaX) > Math.abs(deltaY) ? deltaX : deltaY
|
|
1251
|
+
if (!Number.isFinite(dominant) || dominant === 0) return 0
|
|
1252
|
+
const isTowardMax = isVertical ? dominant < 0 : dominant > 0
|
|
1253
|
+
return isTowardMax ? 1 : -1
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1109
1256
|
/**
|
|
1110
1257
|
* Resolves the target Vernier handle based on pointer primary-axis ratio and cross-axis offset relative to track center.
|
|
1111
|
-
*
|
|
1258
|
+
* トラック中心線に対するポインターの直交軸オフセットと主軸比率から、操作対象となるノギスハンドル (マクロまたはミクロ) を判定します。
|
|
1112
1259
|
*
|
|
1113
1260
|
* @param pointerPrimaryRatio - Pointer position along the track as a 0-1 ratio / トラック主軸上のポインター位置比率 (0-1)
|
|
1114
1261
|
* @param pointerCrossAxisOffset - Signed pointer offset from the track center line in pixels / トラック中心線からのポインター直交軸オフセット (ピクセル、符号付き)
|
|
@@ -1134,11 +1281,8 @@ export function resolveVernierTargetHandle(
|
|
|
1134
1281
|
allowConnectHandles: boolean = true,
|
|
1135
1282
|
microShape: VernierMicroShape = "range",
|
|
1136
1283
|
): VernierHandle {
|
|
1137
|
-
// orientation
|
|
1138
|
-
|
|
1139
|
-
const isTargetingFirstRail = pointerCrossAxisOffset <= 0
|
|
1140
|
-
|
|
1141
|
-
if ((isFirstRailMacro && isTargetingFirstRail) || !(isFirstRailMacro || isTargetingFirstRail)) {
|
|
1284
|
+
// orientation に応じて第一レール (上段または左段) がマクロかミクロかを決定
|
|
1285
|
+
if (resolveVernierRailZone(pointerCrossAxisOffset, orientation) === "macro") {
|
|
1142
1286
|
// マクロ操作ゾーン
|
|
1143
1287
|
const distLow = Math.abs(pointerPrimaryRatio - macroLowRatio)
|
|
1144
1288
|
const distHigh = Math.abs(pointerPrimaryRatio - macroHighRatio)
|
|
@@ -1189,24 +1333,13 @@ export function resolveVernierTargetHandle(
|
|
|
1189
1333
|
*/
|
|
1190
1334
|
export function calculateVernierMacroDrag(handle: "macro-low" | "macro-high" | "macro-connect", pointerRatio: number, startPointerRatio: number, startMacroLowRatio: number, startMacroHighRatio: number): [number, number, "macro-low" | "macro-high" | "macro-connect"] {
|
|
1191
1335
|
if (handle === "macro-connect") {
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1194
|
-
const nextLow = Math.max(0, Math.min(1 - width, startMacroLowRatio + delta))
|
|
1195
|
-
const nextHigh = nextLow + width
|
|
1196
|
-
return [nextLow, nextHigh, "macro-connect"]
|
|
1197
|
-
}
|
|
1198
|
-
if (handle === "macro-low") {
|
|
1199
|
-
const clamped = Math.max(0, Math.min(1, pointerRatio))
|
|
1200
|
-
if (clamped > startMacroHighRatio) {
|
|
1201
|
-
return [startMacroHighRatio, clamped, "macro-high"]
|
|
1202
|
-
}
|
|
1203
|
-
return [clamped, startMacroHighRatio, "macro-low"]
|
|
1204
|
-
}
|
|
1205
|
-
const clamped = Math.max(0, Math.min(1, pointerRatio))
|
|
1206
|
-
if (clamped < startMacroLowRatio) {
|
|
1207
|
-
return [clamped, startMacroLowRatio, "macro-low"]
|
|
1336
|
+
const [bandLowRatio, bandHighRatio] = resolveBandDragRatios(pointerRatio - startPointerRatio, startMacroLowRatio, startMacroHighRatio)
|
|
1337
|
+
return [bandLowRatio, bandHighRatio, "macro-connect"]
|
|
1208
1338
|
}
|
|
1209
|
-
|
|
1339
|
+
const kind = handle === "macro-low" ? "low" : "high"
|
|
1340
|
+
const [nextLowRatio, nextHighRatio] = resolveEdgeDragRatios(kind, pointerRatio, startMacroLowRatio, startMacroHighRatio)
|
|
1341
|
+
const edge = resolveDraggedEdge(kind, pointerRatio, startMacroLowRatio, startMacroHighRatio)
|
|
1342
|
+
return [nextLowRatio, nextHighRatio, edge === "low" ? "macro-low" : "macro-high"]
|
|
1210
1343
|
}
|
|
1211
1344
|
|
|
1212
1345
|
/**
|
|
@@ -1232,28 +1365,17 @@ export function calculateVernierMicroDrag(
|
|
|
1232
1365
|
startMicroHighRatio: number,
|
|
1233
1366
|
): [number, number, "micro-low" | "micro-high" | "micro-connect" | "micro-point"] {
|
|
1234
1367
|
if (handle === "micro-point") {
|
|
1235
|
-
const
|
|
1236
|
-
return [
|
|
1368
|
+
const [pointRatio] = resolveEdgeDragRatios("point", pointerRatio, startMicroLowRatio, startMicroHighRatio)
|
|
1369
|
+
return [pointRatio, pointRatio, "micro-point"]
|
|
1237
1370
|
}
|
|
1238
1371
|
if (handle === "micro-connect") {
|
|
1239
|
-
const
|
|
1240
|
-
|
|
1241
|
-
const nextLow = Math.max(0, Math.min(1 - width, startMicroLowRatio + delta))
|
|
1242
|
-
const nextHigh = nextLow + width
|
|
1243
|
-
return [nextLow, nextHigh, "micro-connect"]
|
|
1244
|
-
}
|
|
1245
|
-
if (handle === "micro-low") {
|
|
1246
|
-
const clamped = Math.max(0, Math.min(1, pointerRatio))
|
|
1247
|
-
if (clamped > startMicroHighRatio) {
|
|
1248
|
-
return [startMicroHighRatio, clamped, "micro-high"]
|
|
1249
|
-
}
|
|
1250
|
-
return [clamped, startMicroHighRatio, "micro-low"]
|
|
1251
|
-
}
|
|
1252
|
-
const clamped = Math.max(0, Math.min(1, pointerRatio))
|
|
1253
|
-
if (clamped < startMicroLowRatio) {
|
|
1254
|
-
return [clamped, startMicroLowRatio, "micro-low"]
|
|
1372
|
+
const [bandLowRatio, bandHighRatio] = resolveBandDragRatios(pointerRatio - startPointerRatio, startMicroLowRatio, startMicroHighRatio)
|
|
1373
|
+
return [bandLowRatio, bandHighRatio, "micro-connect"]
|
|
1255
1374
|
}
|
|
1256
|
-
|
|
1375
|
+
const kind = handle === "micro-low" ? "low" : "high"
|
|
1376
|
+
const [nextLowRatio, nextHighRatio] = resolveEdgeDragRatios(kind, pointerRatio, startMicroLowRatio, startMicroHighRatio)
|
|
1377
|
+
const edge = resolveDraggedEdge(kind, pointerRatio, startMicroLowRatio, startMicroHighRatio)
|
|
1378
|
+
return [nextLowRatio, nextHighRatio, edge === "low" ? "micro-low" : "micro-high"]
|
|
1257
1379
|
}
|
|
1258
1380
|
|
|
1259
1381
|
/**
|
|
@@ -1319,18 +1441,19 @@ const assertDomainBounds = (minDate: Date, maxDate: Date): void => {
|
|
|
1319
1441
|
*
|
|
1320
1442
|
* @param propName - Prop name quoted in the error message / エラーメッセージへ埋め込む Props 名
|
|
1321
1443
|
* @param value - Raw prop value supplied by the consumer / 利用側が指定した生の Props 値
|
|
1444
|
+
* @param owner - API name the message blames (default: the component) / メッセージが名指しする API 名 (既定: コンポーネント)
|
|
1322
1445
|
* @returns Nothing; the function only throws or returns normally / 戻り値なし (正常時は無返却)
|
|
1323
1446
|
* @throws RangeError when the value is not a two-element tuple, holds an Invalid Date, or is inverted / 2 要素タプルでない場合、Invalid Date を含む場合、または開始と終了が逆転している場合
|
|
1324
1447
|
*/
|
|
1325
|
-
const assertDateRangeTuple = (propName: string, value: unknown): void => {
|
|
1448
|
+
const assertDateRangeTuple = (propName: string, value: unknown, owner: string = "PeriodSlider"): void => {
|
|
1326
1449
|
if (!Array.isArray(value) || value.length !== 2) {
|
|
1327
|
-
throw new RangeError(
|
|
1450
|
+
throw new RangeError(`${owner}: ${propName} is required and must be a [start, end] Date tuple (received: ${describeDateValue(value)})`)
|
|
1328
1451
|
}
|
|
1329
1452
|
const [start, end] = value
|
|
1330
|
-
if (!isValidDate(start)) throw new RangeError(
|
|
1331
|
-
if (!isValidDate(end)) throw new RangeError(
|
|
1453
|
+
if (!isValidDate(start)) throw new RangeError(`${owner}: ${propName}[0] must be a valid Date (received: ${describeDateValue(start)})`)
|
|
1454
|
+
if (!isValidDate(end)) throw new RangeError(`${owner}: ${propName}[1] must be a valid Date (received: ${describeDateValue(end)})`)
|
|
1332
1455
|
if (end.getTime() < start.getTime()) {
|
|
1333
|
-
throw new RangeError(
|
|
1456
|
+
throw new RangeError(`${owner}: ${propName} must not be inverted (start: ${describeDateValue(start)}, end: ${describeDateValue(end)})`)
|
|
1334
1457
|
}
|
|
1335
1458
|
}
|
|
1336
1459
|
|
|
@@ -1348,8 +1471,8 @@ const assertSelectionDate = (propName: string, value: unknown): void => {
|
|
|
1348
1471
|
}
|
|
1349
1472
|
|
|
1350
1473
|
/**
|
|
1351
|
-
* Validates that a selection date lies inside the declared slider domain.
|
|
1352
|
-
*
|
|
1474
|
+
* Validates that a selection date lies inside the declared slider domain, at the resolution of the scale it is on.
|
|
1475
|
+
* 選択日付が、その選択が載るスケールの解像度で、宣言済みのスライダー定義域の内側にあることを検証する関数。
|
|
1353
1476
|
*
|
|
1354
1477
|
* An out-of-domain selection makes the slider report aria-valuenow outside aria-valuemin / aria-valuemax
|
|
1355
1478
|
* and pin the knob to the rail end while its label shows a date the rail does not contain, so it is
|
|
@@ -1357,15 +1480,25 @@ const assertSelectionDate = (propName: string, value: unknown): void => {
|
|
|
1357
1480
|
* 定義域外の選択は aria-valuenow が aria-valuemin / aria-valuemax の外側を指し、レール端に貼り付いたつまみが
|
|
1358
1481
|
* レール上に存在しない日付を表示するため、黙ってクランプせず拒否。
|
|
1359
1482
|
*
|
|
1483
|
+
* Containment is decided on the encoded key, because the rail is: its ends are `encode(unit, minDate)` and
|
|
1484
|
+
* `encode(unit, maxDate)`, so a domain boundary falling mid period puts the whole of that period on the rail. A raw
|
|
1485
|
+
* timestamp comparison would reject the very value the rail's own end draws - which is what every commit path, the
|
|
1486
|
+
* `Home` / `End` keys and the state hooks hand straight back as a controlled prop.
|
|
1487
|
+
* 内包の判定は符号化キーで行う (レールがそう出来ているため)。レール両端は `encode(unit, minDate)` と
|
|
1488
|
+
* `encode(unit, maxDate)` であり、境界が期間の途中を指せばその期間まるごとがレールに載る。生の時刻で比較すると、
|
|
1489
|
+
* レール自身の端が描いている値を拒むことになる (確定経路・`Home` / `End`・ステートフックがそのまま制御 Props として戻す値)。
|
|
1490
|
+
*
|
|
1360
1491
|
* @param propName - Prop name quoted in the error message / エラーメッセージへ埋め込む Props 名
|
|
1361
1492
|
* @param value - Selection date supplied by the consumer / 利用側が指定した選択日付
|
|
1493
|
+
* @param unit - Time resolution unit of the scale the selection sits on / その選択が載るスケールの時間解像度単位
|
|
1362
1494
|
* @param minDate - Lower domain boundary / 定義域下限
|
|
1363
1495
|
* @param maxDate - Upper domain boundary / 定義域上限
|
|
1364
1496
|
* @returns Nothing; the function only throws or returns normally / 戻り値なし (正常時は無返却)
|
|
1365
|
-
* @throws RangeError when the value lies outside [minDate, maxDate] /
|
|
1497
|
+
* @throws RangeError when the value lies outside [minDate, maxDate] at unit resolution / 値が単位解像度で [minDate, maxDate] の外にある場合
|
|
1366
1498
|
*/
|
|
1367
|
-
const assertSelectionWithinDomain = (propName: string, value: Date, minDate: Date, maxDate: Date): void => {
|
|
1368
|
-
|
|
1499
|
+
const assertSelectionWithinDomain = (propName: string, value: Date, unit: PeriodSliderUnit, minDate: Date, maxDate: Date): void => {
|
|
1500
|
+
const encoded = encode(unit, value)
|
|
1501
|
+
if (encoded < encode(unit, minDate) || encoded > encode(unit, maxDate)) {
|
|
1369
1502
|
throw new RangeError(`PeriodSlider: ${propName} must lie within [minDate, maxDate] (received: ${describeDateValue(value)}, minDate: ${describeDateValue(minDate)}, maxDate: ${describeDateValue(maxDate)})`)
|
|
1370
1503
|
}
|
|
1371
1504
|
}
|
|
@@ -1390,8 +1523,8 @@ const assertSelectionProps = (props: PeriodSliderProps, minDate: Date, maxDate:
|
|
|
1390
1523
|
const value = props[propName]
|
|
1391
1524
|
if (value === undefined) continue
|
|
1392
1525
|
assertDateRangeTuple(propName, value)
|
|
1393
|
-
assertSelectionWithinDomain(`${propName}[0]`, value[0], minDate, maxDate)
|
|
1394
|
-
assertSelectionWithinDomain(`${propName}[1]`, value[1], minDate, maxDate)
|
|
1526
|
+
assertSelectionWithinDomain(`${propName}[0]`, value[0], props.unit, minDate, maxDate)
|
|
1527
|
+
assertSelectionWithinDomain(`${propName}[1]`, value[1], props.unit, minDate, maxDate)
|
|
1395
1528
|
}
|
|
1396
1529
|
return
|
|
1397
1530
|
}
|
|
@@ -1400,7 +1533,7 @@ const assertSelectionProps = (props: PeriodSliderProps, minDate: Date, maxDate:
|
|
|
1400
1533
|
const value = props[propName]
|
|
1401
1534
|
if (value === undefined) continue
|
|
1402
1535
|
assertSelectionDate(propName, value)
|
|
1403
|
-
assertSelectionWithinDomain(propName, value, minDate, maxDate)
|
|
1536
|
+
assertSelectionWithinDomain(propName, value, props.unit, minDate, maxDate)
|
|
1404
1537
|
}
|
|
1405
1538
|
}
|
|
1406
1539
|
|
|
@@ -1427,12 +1560,25 @@ interface VernierMicroSelection {
|
|
|
1427
1560
|
* silently preferring one of them would leave the callback of the other silent forever.
|
|
1428
1561
|
* ミクロ 2 系統は相互排他。両方指定するとつまみ数が決まらず、黙って片方を優先すれば他方のコールバックは永久に鳴らない。
|
|
1429
1562
|
*
|
|
1563
|
+
* The micro selection is a value the user must be able to reach, so it is required to lie inside the
|
|
1564
|
+
* declared domain at micro-unit resolution - the resolution the micro rail is drawn at, so "reachable" and
|
|
1565
|
+
* "inside the domain" name the same set. macroRange is deliberately allowed to overhang the domain instead
|
|
1566
|
+
* (the rails intersect the window with the domain, and the macro callback clamps what it emits).
|
|
1567
|
+
* ミクロ選択は利用者が到達できる値であるため、ミクロ単位の解像度で宣言済み定義域の内側を要求する
|
|
1568
|
+
* (ミクロレールが描かれる解像度そのものであり、「到達できる」と「定義域の内側」が同じ集合を指す)。
|
|
1569
|
+
* 定義域からはみ出すことを意図的に許している macroRange とは扱いが異なる
|
|
1570
|
+
* (レールは窓と定義域の積を取り、マクロ通知はクランプ済みの値を配る)。
|
|
1571
|
+
*
|
|
1430
1572
|
* @param props - Raw vernier props the component was rendered with / コンポーネントへ渡された生のノギス Props
|
|
1573
|
+
* @param minDate - Lower domain boundary / 定義域下限
|
|
1574
|
+
* @param maxDate - Upper domain boundary / 定義域上限
|
|
1431
1575
|
* @returns Resolved micro shape and the selection tuple seeding the uncontrolled state / 解決済みのミクロ形態と、非制御ステートの初期値となる選択タプル
|
|
1432
|
-
* @throws RangeError when macroRange is unusable, when both micro families are supplied,
|
|
1576
|
+
* @throws RangeError when macroRange is unusable, when both micro families are supplied, when neither is, or when a supplied micro selection lies outside the domain at micro-unit resolution / macroRange が利用不能な場合、ミクロ 2 系統を同時指定した場合、いずれも未指定の場合、指定されたミクロ選択がミクロ単位の解像度で定義域外の場合
|
|
1433
1577
|
*/
|
|
1434
|
-
const resolveVernierMicroSelection = (props: PeriodSliderVernierProps): VernierMicroSelection => {
|
|
1578
|
+
const resolveVernierMicroSelection = (props: PeriodSliderVernierProps, minDate: Date, maxDate: Date): VernierMicroSelection => {
|
|
1435
1579
|
assertDateRangeTuple("macroRange", props.macroRange)
|
|
1580
|
+
// ミクロ選択が載るのはミクロレールであり、定義域の内包もそのレールの解像度で判定する
|
|
1581
|
+
const microUnit = props.microUnit ?? props.unit
|
|
1436
1582
|
|
|
1437
1583
|
const hasRangeProps = props.microRange !== undefined || props.defaultMicroRange !== undefined || props.onChangeMicroRange !== undefined
|
|
1438
1584
|
const hasPointProps = props.microValue !== undefined || props.defaultMicroValue !== undefined || props.onChangeMicroPoint !== undefined
|
|
@@ -1444,10 +1590,12 @@ const resolveVernierMicroSelection = (props: PeriodSliderVernierProps): VernierM
|
|
|
1444
1590
|
if (hasPointProps) {
|
|
1445
1591
|
if (props.microValue !== undefined) {
|
|
1446
1592
|
assertSelectionDate("microValue", props.microValue)
|
|
1593
|
+
assertSelectionWithinDomain("microValue", props.microValue, microUnit, minDate, maxDate)
|
|
1447
1594
|
return { shape: "point", selection: [props.microValue, props.microValue] }
|
|
1448
1595
|
}
|
|
1449
1596
|
if (props.defaultMicroValue !== undefined) {
|
|
1450
1597
|
assertSelectionDate("defaultMicroValue", props.defaultMicroValue)
|
|
1598
|
+
assertSelectionWithinDomain("defaultMicroValue", props.defaultMicroValue, microUnit, minDate, maxDate)
|
|
1451
1599
|
return { shape: "point", selection: [props.defaultMicroValue, props.defaultMicroValue] }
|
|
1452
1600
|
}
|
|
1453
1601
|
throw new RangeError("PeriodSlider: vernier point mode requires a micro selection; supply microValue (controlled) or defaultMicroValue (uncontrolled)")
|
|
@@ -1455,10 +1603,14 @@ const resolveVernierMicroSelection = (props: PeriodSliderVernierProps): VernierM
|
|
|
1455
1603
|
|
|
1456
1604
|
if (props.microRange !== undefined) {
|
|
1457
1605
|
assertDateRangeTuple("microRange", props.microRange)
|
|
1606
|
+
assertSelectionWithinDomain("microRange[0]", props.microRange[0], microUnit, minDate, maxDate)
|
|
1607
|
+
assertSelectionWithinDomain("microRange[1]", props.microRange[1], microUnit, minDate, maxDate)
|
|
1458
1608
|
return { shape: "range", selection: props.microRange }
|
|
1459
1609
|
}
|
|
1460
1610
|
if (props.defaultMicroRange !== undefined) {
|
|
1461
1611
|
assertDateRangeTuple("defaultMicroRange", props.defaultMicroRange)
|
|
1612
|
+
assertSelectionWithinDomain("defaultMicroRange[0]", props.defaultMicroRange[0], microUnit, minDate, maxDate)
|
|
1613
|
+
assertSelectionWithinDomain("defaultMicroRange[1]", props.defaultMicroRange[1], microUnit, minDate, maxDate)
|
|
1462
1614
|
return { shape: "range", selection: props.defaultMicroRange }
|
|
1463
1615
|
}
|
|
1464
1616
|
// 形態を宣言済みの呼び出し側へ他方の形態の救済を示すと、それは型エラーであり、
|
|
@@ -1507,6 +1659,25 @@ interface PendingEmitSlot {
|
|
|
1507
1659
|
emit: (() => void) | null
|
|
1508
1660
|
}
|
|
1509
1661
|
|
|
1662
|
+
/**
|
|
1663
|
+
* Committed vernier selection as encoded scale positions, the basis every emission is compared against.
|
|
1664
|
+
* 確定しているノギスの選択を符号化した位置 (全ての発火がこれと比較される判定基準)。
|
|
1665
|
+
*/
|
|
1666
|
+
interface CommittedVernierScales {
|
|
1667
|
+
/** Unit the macro window is encoded in / マクロ窓を符号化した単位 */
|
|
1668
|
+
macroUnit: PeriodSliderUnit
|
|
1669
|
+
/** Encoded start of the committed macro window / 確定しているマクロ窓開始位置の符号値 */
|
|
1670
|
+
macroLowEnc: number
|
|
1671
|
+
/** Encoded end of the committed macro window / 確定しているマクロ窓終了位置の符号値 */
|
|
1672
|
+
macroHighEnc: number
|
|
1673
|
+
/** Unit the micro selection is encoded in / ミクロ選択を符号化した単位 */
|
|
1674
|
+
microUnit: PeriodSliderUnit
|
|
1675
|
+
/** Encoded start of the committed micro selection / 確定しているミクロ選択開始位置の符号値 */
|
|
1676
|
+
microLowEnc: number
|
|
1677
|
+
/** Encoded end of the committed micro selection / 確定しているミクロ選択終了位置の符号値 */
|
|
1678
|
+
microHighEnc: number
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1510
1681
|
/**
|
|
1511
1682
|
* Disarms the pending emission of a slot without running it.
|
|
1512
1683
|
* 枠に保留中の発火を、実行せずに取り消す関数。
|
|
@@ -1607,13 +1778,131 @@ const useMeasuredBorderBox = (): [(element: HTMLElement | null) => void, Measure
|
|
|
1607
1778
|
* 衝突回避は 2 枚の実寸で決まる。片方だけでは広い方が分からず押し出し量を誤ってトラックへ食い込ませる
|
|
1608
1779
|
* ため、片方でも未実測なら既定値を捏造せず「寸法なし」として扱う。
|
|
1609
1780
|
*
|
|
1781
|
+
* The pair box is `resolvePairBox`, which the range area's label reach reads too.
|
|
1782
|
+
* 対の箱は `resolvePairBox` が決め、範囲領域のラベル到達距離も同じ関数を読む。
|
|
1783
|
+
*
|
|
1610
1784
|
* @param lowBox - Measured box of the low label, or null while unmeasured / 下限ラベルの実測ボックス (未実測時は null)
|
|
1611
1785
|
* @param highBox - Measured box of the high label, or null while unmeasured / 上限ラベルの実測ボックス (未実測時は null)
|
|
1612
1786
|
* @returns Config built from the larger of the pair, or undefined while either box is missing / 対の大きい方から構築した設定 (片方でも欠ければ undefined)
|
|
1613
1787
|
*/
|
|
1614
1788
|
const buildPairSlantConfig = (lowBox: MeasuredBoxPx | null, highBox: MeasuredBoxPx | null): LabelSlantConfig | undefined => {
|
|
1615
|
-
|
|
1616
|
-
return { estimatedWidthPx:
|
|
1789
|
+
const pairBox = resolvePairBox(lowBox, highBox)
|
|
1790
|
+
return pairBox === null ? undefined : { estimatedWidthPx: pairBox.widthPx, estimatedHeightPx: pairBox.heightPx }
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
/**
|
|
1794
|
+
* Resolves the box a label pair is laid out with: the larger extent of both labels, or nothing while either is unmeasured.
|
|
1795
|
+
* ラベル対の配置に使う箱 (両ラベルの大きい方の寸法。片方でも未実測なら無し) を解決する関数。
|
|
1796
|
+
*
|
|
1797
|
+
* @param lowBox - Measured box of the low label, or null while unmeasured / 下限ラベルの実測ボックス (未実測時は null)
|
|
1798
|
+
* @param highBox - Measured box of the high label, or null while unmeasured / 上限ラベルの実測ボックス (未実測時は null)
|
|
1799
|
+
* @returns Larger extent of the pair, or null while either box is missing / 対の大きい方の寸法 (片方でも欠ければ null)
|
|
1800
|
+
*/
|
|
1801
|
+
const resolvePairBox = (lowBox: MeasuredBoxPx | null, highBox: MeasuredBoxPx | null): MeasuredBoxPx | null => {
|
|
1802
|
+
if (lowBox === null || highBox === null) return null
|
|
1803
|
+
return { widthPx: Math.max(lowBox.widthPx, highBox.widthPx), heightPx: Math.max(lowBox.heightPx, highBox.heightPx) }
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
/**
|
|
1807
|
+
* Side of the rail centre line, named in reading order: before is top (horizontal) or left (vertical).
|
|
1808
|
+
* レール中心線の側 (読み順で命名。before は横向きで上、縦向きで左)。
|
|
1809
|
+
*/
|
|
1810
|
+
export type RailSide = "before" | "after"
|
|
1811
|
+
|
|
1812
|
+
/**
|
|
1813
|
+
* One layer of labels standing on one side of the rail, in the terms the range area needs.
|
|
1814
|
+
* Each layer names the rule its reach follows, so a layer never carries a quantity its rule does not read: a label the
|
|
1815
|
+
* stylesheet stands beside the rail reaches by its own inline size, a label the placement solver rotated reaches by its
|
|
1816
|
+
* rotated half-extent (from the anchor line, or from the rail centre line when the component places its centre there).
|
|
1817
|
+
* レールの片側に立つラベル層を、範囲領域が必要とする量で表したもの。層は到達距離の規則を自ら名乗るため、規則が読まない量を持つことはない
|
|
1818
|
+
* (スタイルシートがレールの横へ置くラベルは自身のインライン方向の寸法、配置解決が回したラベルは回転後の半寸法で届く)。
|
|
1819
|
+
*/
|
|
1820
|
+
export type RailSideLabelLayer = {
|
|
1821
|
+
/** Side of the rail the layer stands on / 層が立つレールの側 */
|
|
1822
|
+
side: RailSide
|
|
1823
|
+
/** Box the layer is laid out with, or null while unmeasured / 層の配置に使う箱 (未実測時は null) */
|
|
1824
|
+
box: MeasuredBoxPx | null
|
|
1825
|
+
} & (
|
|
1826
|
+
| {
|
|
1827
|
+
/** The stylesheet anchors the label's inner edge beside the rail; the reach is the label's own inline size / スタイルシートがラベルの内縁をレールの横の基準線へ置く形。到達距離はラベル自身のインライン方向の寸法 */
|
|
1828
|
+
reach: "inline-size"
|
|
1829
|
+
}
|
|
1830
|
+
| {
|
|
1831
|
+
/** The placement solver rotated the label; the reach comes from the rotated half-extent / 配置解決がラベルを回した形。到達距離は回転後の半寸法から求める */
|
|
1832
|
+
reach: "rotated"
|
|
1833
|
+
/** Rotation the placement solver applied, in degrees / 配置解決が与えた回転角 (度) */
|
|
1834
|
+
angleDeg: number
|
|
1835
|
+
/** Label centre from the rail centre line when the component places it there, or null when the stylesheet anchors the inner edge / コンポーネントが中心線基準で置くときの中心線からのラベル中心距離 (スタイルシートが内縁を基準線へ置くときは null) */
|
|
1836
|
+
centreOffsetPx: number | null
|
|
1837
|
+
/** Push the solver applied along the rail, in pixels / 配置解決がレール方向へ与えた押し出し量 (ピクセル) */
|
|
1838
|
+
alongPushPx: number
|
|
1839
|
+
}
|
|
1840
|
+
)
|
|
1841
|
+
|
|
1842
|
+
/**
|
|
1843
|
+
* How far the drawn labels reach, in the two forms the component needs.
|
|
1844
|
+
* 描かれたラベルの到達距離を、コンポーネントが必要とする 2 つの形で表したもの。
|
|
1845
|
+
*/
|
|
1846
|
+
export interface LabelReach {
|
|
1847
|
+
/** Inline custom properties the root carries for the stylesheet / スタイルシートのためにルートが持つインラインのカスタムプロパティ */
|
|
1848
|
+
style: CSSProperties
|
|
1849
|
+
/** Along-rail reach in integer pixels / レール方向の到達距離 (整数ピクセル) */
|
|
1850
|
+
mainPx: number
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1853
|
+
/**
|
|
1854
|
+
* Resolves how far the drawn labels reach past the lines the stylesheet anchors them to, as inline custom properties.
|
|
1855
|
+
* 描かれたラベルがスタイルシートの基準線からどこまで届くかを、インラインのカスタムプロパティとして解決する関数。
|
|
1856
|
+
*
|
|
1857
|
+
* A label reaches in two directions and the range area needs both: across the rail it reaches from the anchor line of
|
|
1858
|
+
* its own side, and along the rail it reaches from the knob it is centred on - which stands at the very end of the
|
|
1859
|
+
* rail whenever the value is at a domain bound, so the outer half of that label hangs past the rail. The along-rail
|
|
1860
|
+
* reach is one quantity for the whole area, because both ends of the rail carry the same label geometry.
|
|
1861
|
+
* ラベルは 2 方向へ届き、範囲領域はその双方を必要とする (交差軸では自分の側の基準線から、レール方向では中心に置かれた
|
|
1862
|
+
* つまみから)。つまみは値が定義域の端にあるときレールの端そのものに立つため、そのラベルの外側半分はレールの外へ出る。
|
|
1863
|
+
* レール方向の到達距離は領域全体で 1 つの量 (レールの両端とも同じラベル幾何を載せるため)。
|
|
1864
|
+
*
|
|
1865
|
+
* Only the measured reach crosses from TypeScript to CSS: the anchor line and the lane width depend on lengths the
|
|
1866
|
+
* stylesheet owns, so CSS composes the area from this reach.
|
|
1867
|
+
* TypeScript から CSS へ渡すのは実測した到達距離だけ。基準線とレーンの幅はスタイルシートが持つ長さに依存するため、
|
|
1868
|
+
* 範囲領域の組み立ては CSS が行う。
|
|
1869
|
+
*
|
|
1870
|
+
* The along-rail reach is returned as a number as well as a custom property, because the two tiers that need it
|
|
1871
|
+
* read it in different units: the stylesheet composes the drawn lane from the property, and the wheel ownership rule
|
|
1872
|
+
* inflates the measured rectangle by the same pixels rather than growing the element (an element grown past the root
|
|
1873
|
+
* adds that much scrollable overflow to a tight host, for a region that draws nothing).
|
|
1874
|
+
* レール方向の到達距離はカスタムプロパティと数値の双方で返す。必要とする 2 つの層が別の単位で読むため
|
|
1875
|
+
* (スタイルシートは描かれるレーンをプロパティから組み立て、ホイールの持ち主判定は要素を大きくせず実測した矩形を同じ
|
|
1876
|
+
* ピクセルだけ膨らませる。ルートの外へ大きくした要素は、何も描かない領域のために余裕のないホストへ同じ量の
|
|
1877
|
+
* スクロールのはみ出しを足すため)。
|
|
1878
|
+
*
|
|
1879
|
+
* @param layers - Label layers drawn on the rail / レールに描かれたラベル層
|
|
1880
|
+
* @returns Reach per measured side, the along-rail reach and its pixel value, or undefined when no side has a measured layer / 実測済みの側ごとの到達距離・レール方向の到達距離とそのピクセル値 (実測済みの層が無ければ undefined)
|
|
1881
|
+
*/
|
|
1882
|
+
export const resolveLabelReach = (layers: readonly RailSideLabelLayer[]): LabelReach | undefined => {
|
|
1883
|
+
const style: Record<string, string> = {}
|
|
1884
|
+
let mainReachPx = 0
|
|
1885
|
+
for (const layer of layers) {
|
|
1886
|
+
const { side, box } = layer
|
|
1887
|
+
if (box === null) continue
|
|
1888
|
+
let reachPx: number
|
|
1889
|
+
if (layer.reach === "inline-size") {
|
|
1890
|
+
reachPx = box.widthPx
|
|
1891
|
+
// 縦向きのラベルはつまみの高さ中央に置かれるため、レール方向 (縦) へは自身の半分だけ届く
|
|
1892
|
+
mainReachPx = Math.max(mainReachPx, box.heightPx / 2)
|
|
1893
|
+
} else {
|
|
1894
|
+
const rotated = resolveRotatedHalfExtents(box.widthPx, box.heightPx, layer.angleDeg)
|
|
1895
|
+
reachPx = layer.centreOffsetPx === null ? 2 * rotated.acrossPx : Math.abs(layer.centreOffsetPx) + rotated.acrossPx
|
|
1896
|
+
// 押し広げた対はつまみより外へ中心が動く。その分を足さないと、端に着いた対のラベルが領域の外に残る
|
|
1897
|
+
mainReachPx = Math.max(mainReachPx, rotated.alongPx + Math.abs(layer.alongPushPx))
|
|
1898
|
+
}
|
|
1899
|
+
// 整数へ切り上げるのは、傾斜の連続変化で継承カスタムプロパティがフレーム毎に変わり子孫のスタイル再計算を招くため
|
|
1900
|
+
style[`--ps-label-reach-${side}`] = `${Math.ceil(reachPx)}px`
|
|
1901
|
+
}
|
|
1902
|
+
if (Object.keys(style).length === 0) return undefined
|
|
1903
|
+
const mainPx = Math.ceil(mainReachPx)
|
|
1904
|
+
style["--ps-label-reach-main"] = `${mainPx}px`
|
|
1905
|
+
return { style: style as CSSProperties, mainPx }
|
|
1617
1906
|
}
|
|
1618
1907
|
|
|
1619
1908
|
/**
|
|
@@ -1627,6 +1916,8 @@ interface VernierPairPlacement {
|
|
|
1627
1916
|
lowStyle: CSSProperties | undefined
|
|
1628
1917
|
/** Inline placement of the high label, or undefined to keep the rail baseline / 上限ラベルのインライン配置 (undefined はレール基準配置のまま) */
|
|
1629
1918
|
highStyle: CSSProperties | undefined
|
|
1919
|
+
/** Placement of both labels for the presentation tier to write, or null when the pair keeps the rail baseline / 表示層が書き込むための両枚の配置 (対がレール基準配置のままなら null) */
|
|
1920
|
+
placements: DragLabelPlacementPair
|
|
1630
1921
|
}
|
|
1631
1922
|
|
|
1632
1923
|
/**
|
|
@@ -1636,13 +1927,48 @@ interface VernierPairPlacement {
|
|
|
1636
1927
|
* @param offsetX - Horizontal push in pixels / 水平押し出し量 (ピクセル)
|
|
1637
1928
|
* @param offsetYDelta - Extra vertical push the rotation adds, in pixels / 回転により増える垂直押し出し量 (ピクセル)
|
|
1638
1929
|
* @param angleDeg - Rotation in degrees / 回転角 (度)
|
|
1930
|
+
* @returns Placement the tooltip transform composes / ツールチップの transform が合成する配置
|
|
1931
|
+
*/
|
|
1932
|
+
const buildVernierLabelPlacement = (offsetX: number, offsetYDelta: number, angleDeg: number): DragLabelPlacement => ({
|
|
1933
|
+
tx: `calc(-50% + ${offsetX}px)`,
|
|
1934
|
+
ty: `${offsetYDelta}px`,
|
|
1935
|
+
rot: `${angleDeg}deg`,
|
|
1936
|
+
})
|
|
1937
|
+
|
|
1938
|
+
/**
|
|
1939
|
+
* Expresses one flat-rail label placement from the knob centre the stylesheet places it on.
|
|
1940
|
+
* 平レール (Range / Point) のラベル 1 枚の配置を、スタイルシートが基準に置くつまみ中心から表現する関数。
|
|
1941
|
+
*
|
|
1942
|
+
* @param offsetX - Horizontal push in pixels / 水平押し出し量 (ピクセル)
|
|
1943
|
+
* @param offsetY - Vertical distance from the knob centre in pixels / つまみ中心からの垂直距離 (ピクセル)
|
|
1944
|
+
* @param angleDeg - Rotation in degrees / 回転角 (度)
|
|
1945
|
+
* @returns Placement the tooltip transform composes / ツールチップの transform が合成する配置
|
|
1946
|
+
*/
|
|
1947
|
+
const buildFlatLabelPlacement = (offsetX: number, offsetY: number, angleDeg: number): DragLabelPlacement => ({
|
|
1948
|
+
tx: `calc(-50% + ${offsetX}px)`,
|
|
1949
|
+
ty: `calc(-50% + ${offsetY}px)`,
|
|
1950
|
+
rot: `${angleDeg}deg`,
|
|
1951
|
+
})
|
|
1952
|
+
|
|
1953
|
+
/**
|
|
1954
|
+
* Builds the inline style of one label: every placement quantity read as its live variable, committed value as fallback.
|
|
1955
|
+
* ラベル 1 枚のインラインスタイルを構築する関数 (各配置量を実時間の変数として読み、既定値を確定値とする)。
|
|
1956
|
+
*
|
|
1957
|
+
* The drawn distance between two labels is the pointer's, not the committed one, so the anti-collision geometry has to
|
|
1958
|
+
* be solvable while the pointer is down. Reading every quantity through the same `var(<live>, <committed>)` form the
|
|
1959
|
+
* positions use is what lets the presentation tier hand it over without a second write and without a render.
|
|
1960
|
+
* 2 枚のラベルが描かれている距離はポインターのものであり確定値のものではないため、重なり回避の幾何は押している間も解ける必要がある。
|
|
1961
|
+
* 位置と同じ `var(<実時間>, <確定値>)` の形で各量を読むことで、表示層が二度目の書き込みもレンダーも無しに引き渡せる。
|
|
1962
|
+
*
|
|
1963
|
+
* @param prefix - Custom property prefix of this label / このラベルのカスタムプロパティ接頭辞
|
|
1964
|
+
* @param placement - Committed placement of this label / このラベルの確定配置
|
|
1639
1965
|
* @returns Custom properties the stylesheet substitutes into the tooltip transform / スタイルシートがツールチップの transform へ代入するカスタムプロパティ
|
|
1640
1966
|
*/
|
|
1641
|
-
const
|
|
1967
|
+
const buildLabelPlacementStyle = (prefix: string, placement: DragLabelPlacement): CSSProperties =>
|
|
1642
1968
|
({
|
|
1643
|
-
"--ps-tooltip-tx":
|
|
1644
|
-
"--ps-tooltip-ty":
|
|
1645
|
-
"--ps-tooltip-rot":
|
|
1969
|
+
"--ps-tooltip-tx": dragLabelPlacementValue(prefix, "tx", placement.tx),
|
|
1970
|
+
"--ps-tooltip-ty": dragLabelPlacementValue(prefix, "ty", placement.ty),
|
|
1971
|
+
"--ps-tooltip-rot": dragLabelPlacementValue(prefix, "rot", placement.rot),
|
|
1646
1972
|
}) as CSSProperties
|
|
1647
1973
|
|
|
1648
1974
|
/**
|
|
@@ -1664,27 +1990,138 @@ const buildVernierTooltipStyle = (offsetX: number, offsetYDelta: number, angleDe
|
|
|
1664
1990
|
* かつ縦レールの CSS 基準配置が別物 (tx: 0px / ty: -50%) のため、ここの結果を書くと対を離すのではなく
|
|
1665
1991
|
* ラベルを移動させてしまう。
|
|
1666
1992
|
*
|
|
1993
|
+
* Both tiers solve through here: the committed tier for the positions the values name, the presentation tier for the
|
|
1994
|
+
* positions the pointer is at.
|
|
1995
|
+
* 両層ともこの関数を通して解く (確定層は値が名指す位置に対して、表示層はポインターが居る位置に対して)。
|
|
1996
|
+
*
|
|
1997
|
+
* @param rail - Vernier rail this pair belongs to / この対が属するノギスのレール
|
|
1667
1998
|
* @param lowRatio - Low handle position along the track as a 0-1 ratio / トラック上の下限つまみ位置比率 (0-1)
|
|
1668
1999
|
* @param highRatio - High handle position along the track as a 0-1 ratio / トラック上の上限つまみ位置比率 (0-1)
|
|
1669
|
-
* @param
|
|
1670
|
-
* @
|
|
1671
|
-
* @param config - Measured geometry of this pair, or undefined while unmeasured / この対の実測幾何 (未実測時は undefined)
|
|
1672
|
-
* @param isMerged - Whether the pair holds one value and therefore shows one label / 対が同一値で 1 枚だけ見えている状態か
|
|
1673
|
-
* @param isSlantable - Whether this rail may slant at all / このレールが傾斜してよいか
|
|
1674
|
-
* @returns Geometry of the pair and the inline placement of each of its two labels / 対の幾何と 2 枚それぞれのインライン配置
|
|
2000
|
+
* @param input - Everything the placement depends on besides the two positions / 2 つの位置以外に配置が依存するもの一式
|
|
2001
|
+
* @returns Geometry of the pair, the inline placement of each of its two labels, and the placement the presentation tier writes / 対の幾何、2 枚それぞれのインライン配置、および表示層が書き込む配置
|
|
1675
2002
|
*/
|
|
1676
|
-
const solveVernierPairPlacement = (
|
|
1677
|
-
const baseline = buildHorizontalSlantResult(labelPosition, config)
|
|
2003
|
+
const solveVernierPairPlacement = (rail: "macro" | "micro", lowRatio: number, highRatio: number, input: VernierPairPlacementInput): VernierPairPlacement => {
|
|
2004
|
+
const baseline = buildHorizontalSlantResult(input.labelPosition, input.config)
|
|
1678
2005
|
|
|
1679
|
-
if (!isSlantable) return { slant: baseline, lowStyle: undefined, highStyle: undefined }
|
|
2006
|
+
if (!input.isSlantable) return { slant: baseline, lowStyle: undefined, highStyle: undefined, placements: null }
|
|
1680
2007
|
|
|
1681
|
-
const solved = calculateLabelSlant(lowRatio * 100, highRatio * 100, trackLengthPx, labelPosition, config)
|
|
1682
|
-
const slant = isMerged ? withoutHorizontalPush(solved) : solved
|
|
2008
|
+
const solved = calculateLabelSlant(lowRatio * 100, highRatio * 100, input.trackLengthPx, input.labelPosition, input.config)
|
|
2009
|
+
const slant = input.isMerged ? withoutHorizontalPush(solved) : solved
|
|
2010
|
+
const prefixes = DRAG_LABEL_VARIABLE_PREFIXES[rail]
|
|
2011
|
+
const placements = {
|
|
2012
|
+
low: buildVernierLabelPlacement(slant.lowOffsetX, slant.lowOffsetY - baseline.lowOffsetY, slant.lowAngleDeg),
|
|
2013
|
+
high: buildVernierLabelPlacement(slant.highOffsetX, slant.highOffsetY - baseline.highOffsetY, slant.highAngleDeg),
|
|
2014
|
+
}
|
|
1683
2015
|
|
|
1684
2016
|
return {
|
|
1685
2017
|
slant,
|
|
1686
|
-
lowStyle:
|
|
1687
|
-
highStyle:
|
|
2018
|
+
lowStyle: buildLabelPlacementStyle(prefixes.low, placements.low),
|
|
2019
|
+
highStyle: buildLabelPlacementStyle(prefixes.high, placements.high),
|
|
2020
|
+
placements,
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
/**
|
|
2025
|
+
* Everything a vernier label pair's placement depends on besides the two positions it is solved for.
|
|
2026
|
+
* ノギスのラベルの対の配置が、解く対象の 2 つの位置以外に依存するもの一式。
|
|
2027
|
+
*/
|
|
2028
|
+
interface VernierPairPlacementInput {
|
|
2029
|
+
/** Measured track length in pixels / 実測トラック長 (ピクセル) */
|
|
2030
|
+
trackLengthPx: number
|
|
2031
|
+
/** Side of the track this rail draws its labels on / このレールがラベルを描くトラックの側 */
|
|
2032
|
+
labelPosition: PeriodSliderLabelPosition
|
|
2033
|
+
/** Measured geometry of this pair, or undefined while unmeasured / この対の実測幾何 (未実測時は undefined) */
|
|
2034
|
+
config: LabelSlantConfig | undefined
|
|
2035
|
+
/** Whether the pair holds one value and therefore shows one label / 対が同一値で 1 枚だけ見えている状態か */
|
|
2036
|
+
isMerged: boolean
|
|
2037
|
+
/** Whether this rail may slant at all / このレールが傾斜してよいか */
|
|
2038
|
+
isSlantable: boolean
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
/**
|
|
2042
|
+
* Placement the flat rail (`range` / `point`) label pair takes, in both tiers' terms.
|
|
2043
|
+
* 平レール (`range` / `point`) のラベルの対が取る配置を、両層の言葉で表したもの。
|
|
2044
|
+
*/
|
|
2045
|
+
interface FlatPairPlacement {
|
|
2046
|
+
/** Geometry solved for the pair / 対に対して解決した傾斜幾何 */
|
|
2047
|
+
slant: LabelSlantResult
|
|
2048
|
+
/** Inline placement of the low label / 下限ラベルのインライン配置 */
|
|
2049
|
+
lowStyle: CSSProperties
|
|
2050
|
+
/** Inline placement of the high label / 上限ラベルのインライン配置 */
|
|
2051
|
+
highStyle: CSSProperties
|
|
2052
|
+
/** Placement of both labels for the presentation tier to write, or null when the placement does not depend on the positions / 表示層が書き込むための両枚の配置 (配置が位置に依存しないなら null) */
|
|
2053
|
+
placements: DragLabelPlacementPair
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2056
|
+
/**
|
|
2057
|
+
* Everything the flat rail's label placement depends on besides the two positions it is solved for.
|
|
2058
|
+
* 平レールのラベル配置が、解く対象の 2 つの位置以外に依存するもの一式。
|
|
2059
|
+
*/
|
|
2060
|
+
interface FlatPairPlacementInput {
|
|
2061
|
+
/** Whether one handle selects a single point / つまみ 1 つで時点を選ぶ形態か */
|
|
2062
|
+
isPointMode: boolean
|
|
2063
|
+
/** Whether the slider is drawn vertically / 縦向き描画か */
|
|
2064
|
+
isVertical: boolean
|
|
2065
|
+
/** Whether the host allows the anti-collision rotation / ホストが重なり回避の回転を許すか */
|
|
2066
|
+
autoSlantLabels: boolean
|
|
2067
|
+
/** Whether the pair holds one value and therefore shows one label / 対が同一値で 1 枚だけ見えている状態か */
|
|
2068
|
+
isMerged: boolean
|
|
2069
|
+
/** Measured track length in pixels / 実測トラック長 (ピクセル) */
|
|
2070
|
+
trackLengthPx: number
|
|
2071
|
+
/** Side of the track the labels sit on / ラベルが載るトラックの側 */
|
|
2072
|
+
labelPosition: PeriodSliderLabelPosition
|
|
2073
|
+
/** Measured geometry of the pair, or undefined while unmeasured / 対の実測幾何 (未実測時は undefined) */
|
|
2074
|
+
config: LabelSlantConfig | undefined
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
/** Placement of a vertical slider's labels: the stylesheet stands them beside the rail, so no geometry is solved / 縦向きスライダーのラベルの配置 (スタイルシートがレールの横へ立てるため幾何は解かない) */
|
|
2078
|
+
const VERTICAL_FLAT_LABEL_STYLE = {
|
|
2079
|
+
"--ps-tooltip-origin": "100% 50%",
|
|
2080
|
+
"--ps-tooltip-tx": "0px",
|
|
2081
|
+
"--ps-tooltip-ty": "-50%",
|
|
2082
|
+
"--ps-tooltip-rot": "0deg",
|
|
2083
|
+
} as CSSProperties
|
|
2084
|
+
|
|
2085
|
+
/**
|
|
2086
|
+
* Solves the anti-collision placement of the flat rail's label pair for one pair of positions.
|
|
2087
|
+
* 平レールのラベルの対について、指定の位置の対に対する衝突回避配置を解決する関数。
|
|
2088
|
+
*
|
|
2089
|
+
* Both tiers solve through here: the committed tier for the positions the values name, the presentation tier for the
|
|
2090
|
+
* positions the pointer is at. Anything else would separate the labels for a distance they are not drawn at.
|
|
2091
|
+
* 両層ともこの関数を通して解く (確定層は値が名指す位置に対して、表示層はポインターが居る位置に対して)。
|
|
2092
|
+
* 別経路で解くと、描かれていない距離に対してラベルを離すことになる。
|
|
2093
|
+
*
|
|
2094
|
+
* @param lowPct - Lower label position along the track in percent / トラック上の下限ラベル位置 (百分率)
|
|
2095
|
+
* @param highPct - Upper label position along the track in percent / トラック上の上限ラベル位置 (百分率)
|
|
2096
|
+
* @param input - Everything the placement depends on besides the two positions / 2 つの位置以外に配置が依存するもの一式
|
|
2097
|
+
* @returns Geometry of the pair, the inline placement of each label, and the placement the presentation tier writes / 対の幾何、各ラベルのインライン配置、および表示層が書き込む配置
|
|
2098
|
+
*/
|
|
2099
|
+
const solveFlatPairPlacement = (lowPct: number, highPct: number, input: FlatPairPlacementInput): FlatPairPlacement => {
|
|
2100
|
+
const baseline = buildHorizontalSlantResult(input.labelPosition, input.config)
|
|
2101
|
+
// 縦向きは X 軸オフセットしか返さない幾何を適用できない。Point モードは避ける相手そのものが居ない
|
|
2102
|
+
if (input.isVertical) return { slant: baseline, lowStyle: VERTICAL_FLAT_LABEL_STYLE, highStyle: VERTICAL_FLAT_LABEL_STYLE, placements: null }
|
|
2103
|
+
|
|
2104
|
+
const isSolvable = input.autoSlantLabels && !input.isPointMode
|
|
2105
|
+
let slant = baseline
|
|
2106
|
+
if (isSolvable) {
|
|
2107
|
+
const solved = calculateLabelSlant(lowPct, highPct, input.trackLengthPx, input.labelPosition, input.config)
|
|
2108
|
+
// 併合時に残る 1 枚は前面側であり、front は焦点・押下・交差のたび入れ替わる。押し退けを残すと
|
|
2109
|
+
// 唯一のラベルが ±shiftX の間を飛び、離す相手も居ない。角度と垂直オフセットは 90deg のラベルを
|
|
2110
|
+
// つまみから逃がすために必要なので保持し、接近から一致まで角度も位置も連続させる
|
|
2111
|
+
slant = input.isMerged ? withoutHorizontalPush(solved) : solved
|
|
2112
|
+
}
|
|
2113
|
+
|
|
2114
|
+
const prefixes = DRAG_LABEL_VARIABLE_PREFIXES.flat
|
|
2115
|
+
const placements = {
|
|
2116
|
+
low: buildFlatLabelPlacement(slant.lowOffsetX, slant.lowOffsetY, slant.lowAngleDeg),
|
|
2117
|
+
high: buildFlatLabelPlacement(slant.highOffsetX, slant.highOffsetY, slant.highAngleDeg),
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
return {
|
|
2121
|
+
slant,
|
|
2122
|
+
lowStyle: { "--ps-tooltip-origin": "50% 50%", ...buildLabelPlacementStyle(prefixes.low, placements.low) } as CSSProperties,
|
|
2123
|
+
highStyle: { "--ps-tooltip-origin": "50% 50%", ...buildLabelPlacementStyle(prefixes.high, placements.high) } as CSSProperties,
|
|
2124
|
+
placements: isSolvable ? placements : null,
|
|
1688
2125
|
}
|
|
1689
2126
|
}
|
|
1690
2127
|
|
|
@@ -1694,10 +2131,10 @@ const solveVernierPairPlacement = (lowRatio: number, highRatio: number, trackLen
|
|
|
1694
2131
|
*/
|
|
1695
2132
|
type StepDirection = "decrease" | "increase"
|
|
1696
2133
|
|
|
1697
|
-
/**
|
|
1698
|
-
const
|
|
1699
|
-
horizontal: { decrease: "
|
|
1700
|
-
vertical: { decrease: "
|
|
2134
|
+
/** Direction each stepper's arrow points per axis / 軸ごとの各ステッパーの矢印の向き */
|
|
2135
|
+
const STEPPER_ARROWS: Record<"horizontal" | "vertical", Record<StepDirection, StepArrowDirection>> = {
|
|
2136
|
+
horizontal: { decrease: "left", increase: "right" },
|
|
2137
|
+
vertical: { decrease: "down", increase: "up" },
|
|
1701
2138
|
}
|
|
1702
2139
|
|
|
1703
2140
|
/** Position class each stepper direction carries per axis / 軸ごとの各ステッパー方向が持つ配置クラス */
|
|
@@ -1706,6 +2143,58 @@ const STEPPER_POSITION_CLASSES: Record<"horizontal" | "vertical", Record<StepDir
|
|
|
1706
2143
|
vertical: { decrease: "period-slider-stepper-prev period-slider-stepper-down", increase: "period-slider-stepper-next period-slider-stepper-up" },
|
|
1707
2144
|
}
|
|
1708
2145
|
|
|
2146
|
+
/**
|
|
2147
|
+
* Reserve, inside the slider root, of the distance the round knob's target reaches past the end of the rail: half of
|
|
2148
|
+
* `--ps-target-size`, because the target is centred on a knob that stands on the rail's very end whenever the value is
|
|
2149
|
+
* at a domain bound. Only the rail-only root needs it - with steppers the rail sits a stepper box and a row gap further
|
|
2150
|
+
* in than the knob can reach, and `STEPPER_OUTWARD_RESERVE_CLASSES` already holds the steppers' own reach. Without it
|
|
2151
|
+
* the knob's target hit-tests outside the component, where it takes the presses of a host control, of an adjacent
|
|
2152
|
+
* selector's arrow and of a neighbouring slider, and adds the same amount of scrollable overflow to a tight host.
|
|
2153
|
+
* レール端の外へ丸つまみの当たり判定が伸びる量 (`--ps-target-size` の半分) をスライダーのルートの中へ確保するクラス。
|
|
2154
|
+
* 当たり判定は箱の中心に置かれ、値が定義域の端にあるときつまみはレールの端そのものに立つ。必要なのはレールのみのルートだけ
|
|
2155
|
+
* (ステッパー表示時はボタンの箱と行の間隔の分だけレールが内側へ入り、つまみの到達距離を超えるうえ、
|
|
2156
|
+
* ステッパー自身の到達距離は `STEPPER_OUTWARD_RESERVE_CLASSES` が既に確保している)。確保しないと当たり判定が
|
|
2157
|
+
* コンポーネントの外でヒットテストに答え、ホストの部品・隣のセレクタの矢印・隣のスライダーの押下を奪い、
|
|
2158
|
+
* 余裕のないホストへ同じ量のスクロールのはみ出しを足す。
|
|
2159
|
+
*/
|
|
2160
|
+
export const KNOB_OUTWARD_RESERVE_CLASSES: Record<"horizontal" | "vertical", string> = { horizontal: "px-[calc(var(--ps-target-size)/2)]", vertical: "py-[calc(var(--ps-target-size)/2)]" }
|
|
2161
|
+
|
|
2162
|
+
/** Root grid per axis: stepper, rail, stepper when steppers are shown, the rail alone otherwise; either way the outward target reach of the outermost part is reserved inside the root / 軸ごとのルートのグリッド (ステッパー表示時はステッパー・レール・ステッパー、非表示時はレールのみ。いずれも最も外側の部品の当たり判定が外へ伸びる分をルートの中へ確保する) */
|
|
2163
|
+
const ROOT_GRID_CLASSES: Record<"horizontal" | "vertical", Record<"withSteppers" | "railOnly", string>> = {
|
|
2164
|
+
horizontal: { withSteppers: `grid-cols-[auto_minmax(0,1fr)_auto] ${STEPPER_ROW_GAP_CLASS} ${STEPPER_OUTWARD_RESERVE_CLASSES.horizontal}`, railOnly: `grid-cols-[minmax(0,1fr)] ${KNOB_OUTWARD_RESERVE_CLASSES.horizontal}` },
|
|
2165
|
+
vertical: { withSteppers: `grid-rows-[auto_minmax(0,1fr)_auto] ${STEPPER_ROW_GAP_CLASS} ${STEPPER_OUTWARD_RESERVE_CLASSES.vertical}`, railOnly: `grid-rows-[minmax(0,1fr)] ${KNOB_OUTWARD_RESERVE_CLASSES.vertical}` },
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
/** Explicit cell of each root child per axis; the range area spans every cell, so auto-placement would push the rest into a new row / 軸ごとのルートの子の明示セル (範囲領域が全セルを占めるため、自動配置だと残りが次の行へ押し出される) */
|
|
2169
|
+
const ROOT_GRID_CELL_CLASSES: Record<"horizontal" | "vertical", Record<"leading" | "rail" | "railOnly" | "trailing", string>> = {
|
|
2170
|
+
horizontal: { leading: "col-start-1 row-start-1", rail: "col-start-2 row-start-1", railOnly: "col-start-1 row-start-1", trailing: "col-start-3 row-start-1" },
|
|
2171
|
+
vertical: { leading: "col-start-1 row-start-1", rail: "col-start-1 row-start-2", railOnly: "col-start-1 row-start-1", trailing: "col-start-1 row-start-3" },
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
/**
|
|
2175
|
+
* Binds the rest of a pointer gesture to the element it began on.
|
|
2176
|
+
* ポインター操作の残りすべてを、操作が始まった要素へ結び付ける関数。
|
|
2177
|
+
*
|
|
2178
|
+
* Without capture the browser keeps delivering the gesture to whatever lies under the pointer, so a release that
|
|
2179
|
+
* happens over another document (any same-page `<iframe>`) is delivered there and this document's window listeners
|
|
2180
|
+
* never see the end of the gesture: the drag stays live for ever, keeps following a cursor with no button pressed,
|
|
2181
|
+
* keeps publishing values, and keeps out the wheel, the arrow keys and the steppers, which all stand down while a
|
|
2182
|
+
* gesture owns the value. With capture every move and the release are retargeted to the grabbed element, so they
|
|
2183
|
+
* reach this document's window listeners wherever the pointer travels.
|
|
2184
|
+
* 捕捉しなければ、ブラウザは操作をポインターの下にあるものへ配送し続ける。別文書 (同一ページの `<iframe>`) の上で
|
|
2185
|
+
* 離された解放はそちらへ配送され、この文書の window リスナーは操作の終わりを 1 度も見ない。掴みは永久に生き続け、
|
|
2186
|
+
* ボタンを押していないカーソルを追い続け、値を発火し続け、操作が値を持つ間は退く規則のホイール・矢印キー・ステッパーを
|
|
2187
|
+
* 締め出したままになる。捕捉すれば移動も解放も掴んだ要素へ宛て直されるため、ポインターがどこへ行っても
|
|
2188
|
+
* この文書の window リスナーへ届く。
|
|
2189
|
+
*
|
|
2190
|
+
* @param grabbed - Element the press landed on / 押下が当たった要素
|
|
2191
|
+
* @param pointerId - Pointer the gesture owns / 操作が持つポインターの識別子
|
|
2192
|
+
* @returns Nothing / 戻り値なし
|
|
2193
|
+
*/
|
|
2194
|
+
const captureGesturePointer = (grabbed: Element, pointerId: number): void => {
|
|
2195
|
+
grabbed.setPointerCapture(pointerId)
|
|
2196
|
+
}
|
|
2197
|
+
|
|
1709
2198
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: Vernier integrated multi-mode scale requires comprehensive coordinate handling
|
|
1710
2199
|
const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
1711
2200
|
const {
|
|
@@ -1741,14 +2230,13 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
1741
2230
|
// マクロ窓とミクロ選択もノギスの位置計算の根拠そのもの。欠ければ同じくフック前に失敗させる。
|
|
1742
2231
|
// 形態はステートへ写さず毎レンダー Props から解決する。写すと利用側が形態を差し替えた瞬間に、
|
|
1743
2232
|
// 描かれるつまみ数と鳴るコールバックが食い違う
|
|
1744
|
-
const vernierMicro: VernierMicroSelection | null = props.mode === "vernier" ? resolveVernierMicroSelection(props) : null
|
|
2233
|
+
const vernierMicro: VernierMicroSelection | null = props.mode === "vernier" ? resolveVernierMicroSelection(props, minDate, maxDate) : null
|
|
1745
2234
|
const isMicroPointShape = vernierMicro !== null && vernierMicro.shape === "point"
|
|
1746
2235
|
|
|
1747
2236
|
const palette = COLOR_SCHEME_PALETTES[colorScheme]
|
|
1748
2237
|
const vernierGradId = useId()
|
|
1749
2238
|
|
|
1750
2239
|
const propsRef = useRef(props)
|
|
1751
|
-
propsRef.current = props
|
|
1752
2240
|
|
|
1753
2241
|
const minTime = minDate.getTime()
|
|
1754
2242
|
const maxTime = maxDate.getTime()
|
|
@@ -1856,7 +2344,6 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
1856
2344
|
const [draggingValues, setDraggingValues] = useState<[number, number] | null>(null)
|
|
1857
2345
|
const [activeHandle, setActiveHandle] = useState<"low" | "high" | "connect" | null>(null)
|
|
1858
2346
|
const activeHandleRef = useRef<"low" | "high" | "connect" | null>(null)
|
|
1859
|
-
activeHandleRef.current = activeHandle
|
|
1860
2347
|
const [frontHandle, setFrontHandle] = useState<"low" | "high">("high")
|
|
1861
2348
|
|
|
1862
2349
|
const [hoverValue, setHoverValue] = useState<number | null>(null)
|
|
@@ -1868,7 +2355,6 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
1868
2355
|
// 重複発火の判定基準。「最後に発火した値」を覚えると、利用側が別経路で選択を戻した瞬間に基準が実態から外れ、
|
|
1869
2356
|
// その値へ二度と戻れなくなる。いま確定している選択そのものを基準にすればずれようがない
|
|
1870
2357
|
const committedValuesRef = useRef<[number, number]>([currentLowVal, currentHighVal])
|
|
1871
|
-
committedValuesRef.current = [currentLowVal, currentHighVal]
|
|
1872
2358
|
|
|
1873
2359
|
// ------------------------------------------------------------------
|
|
1874
2360
|
// C-2. ノギススケールの境界とドラッグ状態
|
|
@@ -1899,7 +2385,6 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
1899
2385
|
|
|
1900
2386
|
const [activeVernierHandle, setActiveVernierHandle] = useState<VernierHandle | null>(null)
|
|
1901
2387
|
const activeVernierHandleRef = useRef<VernierHandle | null>(null)
|
|
1902
|
-
activeVernierHandleRef.current = activeVernierHandle
|
|
1903
2388
|
// 初期前面は実在するつまみでなければならない。時点形態に micro-high は無く、
|
|
1904
2389
|
// 描かれないハンドルを初期値にすると最初の 1 回だけ前面が誰も指さない状態になる
|
|
1905
2390
|
const [frontVernierHandleState, setFrontVernierHandle] = useState<VernierHandle>(() => (isMicroPointShape ? "micro-point" : "micro-high"))
|
|
@@ -1936,64 +2421,113 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
1936
2421
|
return getSortedAllowedDates(macroAllowedDates, macroUnit, minDate, maxDate)
|
|
1937
2422
|
}, [isVernierMode, macroAllowedDates, macroUnit, minTime, maxTime])
|
|
1938
2423
|
|
|
2424
|
+
// macroRange は定義域をはみ出してよい窓なので、レールに載る対はここで一度だけ定義域へ畳む。
|
|
2425
|
+
// 生の値のまま使うと aria-valuenow が自分の aria-valuemin/max の外を指し、
|
|
2426
|
+
// 平行移動はみ出した分を戻そうとして操作と逆向きに動く
|
|
1939
2427
|
const vernierMacroLowEnc = useMemo(() => {
|
|
1940
2428
|
if (props.mode !== "vernier") return vernierMacroMinEnc
|
|
1941
|
-
return encode(macroUnit, props.macroRange[0])
|
|
1942
|
-
}, [props.mode, macroRangeStartMs, vernierMacroMinEnc, macroUnit])
|
|
2429
|
+
return Math.max(vernierMacroMinEnc, Math.min(vernierMacroMaxEnc, encode(macroUnit, props.macroRange[0])))
|
|
2430
|
+
}, [props.mode, macroRangeStartMs, vernierMacroMinEnc, vernierMacroMaxEnc, macroUnit])
|
|
1943
2431
|
|
|
1944
2432
|
const vernierMacroHighEnc = useMemo(() => {
|
|
1945
2433
|
if (props.mode !== "vernier") return vernierMacroMaxEnc
|
|
1946
|
-
return encode(macroUnit, props.macroRange[1])
|
|
1947
|
-
}, [props.mode, macroRangeEndMs, vernierMacroMaxEnc, macroUnit])
|
|
2434
|
+
return Math.max(vernierMacroMinEnc, Math.min(vernierMacroMaxEnc, encode(macroUnit, props.macroRange[1])))
|
|
2435
|
+
}, [props.mode, macroRangeEndMs, vernierMacroMinEnc, vernierMacroMaxEnc, macroUnit])
|
|
1948
2436
|
|
|
1949
2437
|
// 位置と ARIA は正規化済みエンコード値、表示だけ生 prop という二重の真実を解消する。
|
|
1950
2438
|
// 同じ値なら表示も一致することが構造的に保証される
|
|
1951
2439
|
const vernierMacroLowDate = useMemo(() => decode(macroUnit, vernierMacroLowEnc), [macroUnit, vernierMacroLowEnc])
|
|
1952
2440
|
const vernierMacroHighDate = useMemo(() => decode(macroUnit, vernierMacroHighEnc), [macroUnit, vernierMacroHighEnc])
|
|
1953
2441
|
|
|
1954
|
-
//
|
|
1955
|
-
//
|
|
1956
|
-
//
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
//
|
|
1969
|
-
//
|
|
1970
|
-
const
|
|
2442
|
+
// ミクロレールが張る範囲。マクロ窓は macroUnit へ丸められたうえ末尾期間全体まで広げられるため、
|
|
2443
|
+
// 定義域と交差させないと aria-valuemin/max もドラッグ端も定義域外の日付を指す。
|
|
2444
|
+
// 出発点は生の macroRange ではなく、マクロつまみが実際に名乗る対 — 生の値から解決すると、
|
|
2445
|
+
// 窓が定義域の完全に外側にあるときレールと確定経路が別々の窓を見ることになる
|
|
2446
|
+
const vernierMicroWindow = useMemo<[Date, Date]>(() => {
|
|
2447
|
+
if (props.mode !== "vernier") return [minDate, maxDate]
|
|
2448
|
+
return resolveMacroWindow(macroUnit, microUnit, [vernierMacroLowDate, vernierMacroHighDate], minDate, maxDate)
|
|
2449
|
+
}, [props.mode, vernierMacroLowDate, vernierMacroHighDate, macroUnit, microUnit, minTime, maxTime])
|
|
2450
|
+
|
|
2451
|
+
const vernierMicroMinEnc = useMemo(() => encode(microUnit, vernierMicroWindow[0]), [microUnit, vernierMicroWindow])
|
|
2452
|
+
|
|
2453
|
+
// マクロ窓が 1 単位に収まる場合、ミクロ側の定義域も同じ 1 単位。広げるとマクロ窓外の日付を選択できてしまう
|
|
2454
|
+
const vernierMicroMaxEnc = useMemo(() => encode(microUnit, vernierMicroWindow[1]), [microUnit, vernierMicroWindow])
|
|
2455
|
+
|
|
2456
|
+
// 候補は定義域で解決してからマクロ窓で切り出す。窓を境界にして解決すると、候補を 1 つも含まない窓で
|
|
2457
|
+
// getSortedAllowedDates が送出してしまう。窓が動いた先の候補もこの一覧から絞る
|
|
2458
|
+
const sortedMicroDomainDates = useMemo(() => {
|
|
1971
2459
|
if (!isVernierMode) return []
|
|
1972
|
-
|
|
1973
|
-
|
|
2460
|
+
return getSortedAllowedDates(microAllowedDates, microUnit, minDate, maxDate)
|
|
2461
|
+
}, [isVernierMode, microAllowedDates, microUnit, minTime, maxTime])
|
|
2462
|
+
|
|
2463
|
+
/**
|
|
2464
|
+
* Narrows the domain-resolved micro candidates to those a given micro window contains.
|
|
2465
|
+
* 定義域で解決済みのミクロ候補を、指定のミクロ窓が含むものだけへ絞り込む関数。
|
|
2466
|
+
*
|
|
2467
|
+
* @param windowMinEnc - Encoded window start / エンコード済み窓開始値
|
|
2468
|
+
* @param windowMaxEnc - Encoded window end / エンコード済み窓終了値
|
|
2469
|
+
* @returns Candidates inside the window, ascending / 窓の内側の候補 (昇順)
|
|
2470
|
+
*/
|
|
2471
|
+
const narrowMicroCandidatesToWindow = (windowMinEnc: number, windowMaxEnc: number): Date[] =>
|
|
2472
|
+
sortedMicroDomainDates.filter((d) => {
|
|
1974
2473
|
const enc = encode(microUnit, d)
|
|
1975
|
-
return enc >=
|
|
2474
|
+
return enc >= windowMinEnc && enc <= windowMaxEnc
|
|
1976
2475
|
})
|
|
1977
|
-
|
|
2476
|
+
|
|
2477
|
+
// 窓内に候補が 1 つも無い場合は空配列となり、各操作は離散分岐へ入らず窓内の連続値として扱われる
|
|
2478
|
+
const sortedMicroAllowedDates = useMemo(() => narrowMicroCandidatesToWindow(vernierMicroMinEnc, vernierMicroMaxEnc), [sortedMicroDomainDates, microUnit, vernierMicroMinEnc, vernierMicroMaxEnc])
|
|
1978
2479
|
|
|
1979
2480
|
// 離散指定は窓内に候補が 1 つでも残っているときだけ成立する。空配列のままでは窓内の連続値として扱う
|
|
1980
2481
|
const macroIsDiscreteScale = macroIsDiscrete && sortedMacroAllowedDates.length > 0
|
|
1981
2482
|
const microIsDiscreteScale = microIsDiscrete && sortedMicroAllowedDates.length > 0
|
|
1982
2483
|
|
|
2484
|
+
/**
|
|
2485
|
+
* Resolves the encoded value a micro date takes on the rail as it is currently drawn.
|
|
2486
|
+
* 現在描かれているレール上で、ミクロ日付が取る符号化値を解決する関数。
|
|
2487
|
+
*
|
|
2488
|
+
* A discrete rail draws nothing but its candidate set, so a date that is not a candidate has no
|
|
2489
|
+
* position of its own there and resolves to the nearest one; a continuous rail only clamps into the
|
|
2490
|
+
* window. Position, ARIA, label and every committed value read this one rule, so the rail can never
|
|
2491
|
+
* draw a handle somewhere the published value does not name.
|
|
2492
|
+
* 離散レールは候補集合しか描かないため、候補でない日付はそこに固有の位置を持たず最近傍候補へ解決される。
|
|
2493
|
+
* 連続レールは窓へ収めるだけ。位置・ARIA・ラベル・確定値の全てがこの 1 規則を読むため、
|
|
2494
|
+
* つまみを描く場所と公表する値が食い違わない。
|
|
2495
|
+
*
|
|
2496
|
+
* @param date - Micro date to place / 位置を求めるミクロ日付
|
|
2497
|
+
* @param candidates - Candidates the window contains, ascending (empty for a continuous rail) / 窓が含む候補 (昇順、連続レールでは空)
|
|
2498
|
+
* @param windowMinEnc - Encoded window start / エンコード済み窓開始値
|
|
2499
|
+
* @param windowMaxEnc - Encoded window end / エンコード済み窓終了値
|
|
2500
|
+
* @returns Encoded value on the rail / レール上の符号化値
|
|
2501
|
+
*/
|
|
2502
|
+
const resolveMicroRailEnc = (date: Date, candidates: Date[], windowMinEnc: number, windowMaxEnc: number): number =>
|
|
2503
|
+
candidates.length > 0 ? encode(microUnit, candidates[findNearestDateIndex(candidates, date, microUnit)]) : Math.max(windowMinEnc, Math.min(windowMaxEnc, encode(microUnit, date)))
|
|
2504
|
+
|
|
2505
|
+
/** Candidates the current window contains, empty while the micro rail is continuous / 現在の窓が含む候補 (ミクロレールが連続の間は空) */
|
|
2506
|
+
const railMicroCandidates = microIsDiscreteScale ? sortedMicroAllowedDates : []
|
|
2507
|
+
|
|
2508
|
+
// 定義域の内側でもマクロ窓の外側であり得る (制御下の選択は窓が動いた次のレンダーまで遅れる)。
|
|
2509
|
+
// レールへ載せた値を配ることで、aria-valuenow が自分の aria-valuemin/max を外れる状態も、
|
|
2510
|
+
// 離散レールが候補でない日付を読み上げる状態も構造的に消える
|
|
1983
2511
|
const vernierMicroLowEnc = useMemo(() => {
|
|
1984
2512
|
if (vernierMicroSelection === null) return vernierMicroMinEnc
|
|
1985
|
-
return
|
|
1986
|
-
}, [microLowMs, vernierMicroMinEnc, microUnit, vernierMicroSelection])
|
|
2513
|
+
return resolveMicroRailEnc(vernierMicroSelection[0], railMicroCandidates, vernierMicroMinEnc, vernierMicroMaxEnc)
|
|
2514
|
+
}, [microLowMs, vernierMicroMinEnc, vernierMicroMaxEnc, microUnit, vernierMicroSelection, railMicroCandidates])
|
|
1987
2515
|
|
|
1988
2516
|
const vernierMicroHighEnc = useMemo(() => {
|
|
1989
2517
|
if (vernierMicroSelection === null) return vernierMicroMaxEnc
|
|
1990
|
-
return
|
|
1991
|
-
}, [microHighMs, vernierMicroMaxEnc, microUnit, vernierMicroSelection])
|
|
2518
|
+
return resolveMicroRailEnc(vernierMicroSelection[1], railMicroCandidates, vernierMicroMinEnc, vernierMicroMaxEnc)
|
|
2519
|
+
}, [microHighMs, vernierMicroMinEnc, vernierMicroMaxEnc, microUnit, vernierMicroSelection, railMicroCandidates])
|
|
1992
2520
|
|
|
1993
2521
|
// つまみ位置と同じ enc から復元することで、ラベルと描画位置が食い違う余地をなくす
|
|
1994
2522
|
const vernierMicroLowDate = useMemo(() => decode(microUnit, vernierMicroLowEnc), [microUnit, vernierMicroLowEnc])
|
|
1995
2523
|
const vernierMicroHighDate = useMemo(() => decode(microUnit, vernierMicroHighEnc), [microUnit, vernierMicroHighEnc])
|
|
1996
2524
|
|
|
2525
|
+
// 重複発火の判定基準。ミクロ側は利用側が保持している選択そのものを符号化する (レールへ載せた表示値を基準にすると、
|
|
2526
|
+
// 窓の外へ出た選択を窓の中へ収め直す訂正が、比較の両辺が同値になって発火しなくなる)
|
|
2527
|
+
const committedVernierScales: CommittedVernierScales | null =
|
|
2528
|
+
!isVernierMode || vernierMicroSelection === null ? null : { macroUnit, macroLowEnc: vernierMacroLowEnc, macroHighEnc: vernierMacroHighEnc, microUnit, microLowEnc: encode(microUnit, vernierMicroSelection[0]), microHighEnc: encode(microUnit, vernierMicroSelection[1]) }
|
|
2529
|
+
const committedVernierRef = useRef(committedVernierScales)
|
|
2530
|
+
|
|
1997
2531
|
// 比率 (0.0 〜 1.0)。離散レールは当たり判定と同じ候補空間で描かないと、つまみがポインターから離れて飛ぶ
|
|
1998
2532
|
const macroSpan = Math.max(1, vernierMacroMaxEnc - vernierMacroMinEnc)
|
|
1999
2533
|
const macroLowRatio = macroIsDiscreteScale ? discreteDateToRailRatio(sortedMacroAllowedDates, macroUnit, snapMode, vernierMacroLowDate) : Math.max(0, Math.min(1, (vernierMacroLowEnc - vernierMacroMinEnc) / macroSpan))
|
|
@@ -2109,10 +2643,15 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2109
2643
|
*/
|
|
2110
2644
|
const notifyMacroRange = useCallback(
|
|
2111
2645
|
(lower: Date, upper: Date, immediate = false) => {
|
|
2112
|
-
|
|
2646
|
+
const committed = committedVernierRef.current
|
|
2647
|
+
// 判定基準を持たないのはノギス以外のモードのときだけ
|
|
2648
|
+
if (propsRef.current.mode !== "vernier" || committed === null) return
|
|
2113
2649
|
// 境界は macroUnit の先頭へ丸められるため、そのままでは minDate より前の日付を利用側へ渡してしまう
|
|
2114
2650
|
const clampedLower = clampToDomain(lower)
|
|
2115
2651
|
const clampedUpper = clampToDomain(upper)
|
|
2652
|
+
// 選択が動いていない確定値でコールバックを撃つと、変更駆動の消費側が無意味な再取得を行う。
|
|
2653
|
+
// デバウンス保留中だけは例外で、予約済みの古い値を確定値で上書きしないと最後の位置が消える (notifyChange と同じ規則)
|
|
2654
|
+
if (encode(committed.macroUnit, clampedLower) === committed.macroLowEnc && encode(committed.macroUnit, clampedUpper) === committed.macroHighEnc && macroEmitRef.current.timerId === null) return
|
|
2116
2655
|
scheduleEmit(
|
|
2117
2656
|
macroEmitRef.current,
|
|
2118
2657
|
() => {
|
|
@@ -2142,9 +2681,13 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2142
2681
|
const notifyMicroSelection = useCallback(
|
|
2143
2682
|
(lower: Date, upper: Date, immediate = false) => {
|
|
2144
2683
|
const p = propsRef.current
|
|
2145
|
-
|
|
2684
|
+
const committed = committedVernierRef.current
|
|
2685
|
+
// 判定基準を持たないのはノギス以外のモードのときだけ
|
|
2686
|
+
if (p.mode !== "vernier" || committed === null) return
|
|
2146
2687
|
const clampedLower = clampToDomain(lower)
|
|
2147
2688
|
const clampedUpper = clampToDomain(upper)
|
|
2689
|
+
// マクロ側と同じ規則 (動いていない選択では鳴らさない。デバウンス保留中だけは例外)
|
|
2690
|
+
if (encode(committed.microUnit, clampedLower) === committed.microLowEnc && encode(committed.microUnit, clampedUpper) === committed.microHighEnc && microEmitRef.current.timerId === null) return
|
|
2148
2691
|
// 非制御時はここが唯一の自律更新点。書かなければコールバックだけが鳴り、つまみは初期位置で固まる。
|
|
2149
2692
|
// デバウンス対象は利用側への通知のみで、つまみ追従までは遅らせない
|
|
2150
2693
|
if (isMicroPointShape ? p.microValue === undefined : p.microRange === undefined) {
|
|
@@ -2237,7 +2780,13 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2237
2780
|
// ------------------------------------------------------------------
|
|
2238
2781
|
// F. ポインター座標追跡とトラック実測
|
|
2239
2782
|
// ------------------------------------------------------------------
|
|
2783
|
+
const rootRef = useRef<HTMLDivElement | null>(null)
|
|
2784
|
+
const rangeAreaRef = useRef<HTMLDivElement | null>(null)
|
|
2785
|
+
const labelReachMainRef = useRef(0)
|
|
2240
2786
|
const trackRef = useRef<HTMLDivElement | null>(null)
|
|
2787
|
+
const projectionRef = useRef<SVGPathElement | null>(null)
|
|
2788
|
+
const decreaseStepperRef = useRef<HTMLButtonElement | null>(null)
|
|
2789
|
+
const increaseStepperRef = useRef<HTMLButtonElement | null>(null)
|
|
2241
2790
|
const [trackLength, setTrackLength] = useState<number>(0)
|
|
2242
2791
|
|
|
2243
2792
|
const [lowLabelRef, lowLabelBox] = useMeasuredBorderBox()
|
|
@@ -2250,6 +2799,40 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2250
2799
|
const [microLowLabelRef, microLowLabelBox] = useMeasuredBorderBox()
|
|
2251
2800
|
const [microHighLabelRef, microHighLabelBox] = useMeasuredBorderBox()
|
|
2252
2801
|
|
|
2802
|
+
// Point モードはラベルが 1 枚で、その 1 枚の実寸がそのまま直立基準の高さになる。
|
|
2803
|
+
// 対になる 2 枚の規則 (片方でも未実測なら寸法なし) は buildPairSlantConfig が一手に持つ
|
|
2804
|
+
const labelSlantConfig: LabelSlantConfig | undefined = isPointMode ? (lowLabelBox === null ? undefined : { estimatedWidthPx: lowLabelBox.widthPx, estimatedHeightPx: lowLabelBox.heightPx }) : buildPairSlantConfig(lowLabelBox, highLabelBox)
|
|
2805
|
+
|
|
2806
|
+
// 値が一致するとき 2 枚のラベルは文字列まで同一になる (valueToDate が純粋なので構造的に保証される)。
|
|
2807
|
+
// ピクセル距離では別日と区別できないため判定は必ず値で行う。
|
|
2808
|
+
// point モードは上限値を下限値へ寄せるため素の一致判定が恒真になり、!isPointMode で外さないと成立しない
|
|
2809
|
+
const isLabelMerged = !isPointMode && currentLowVal === currentHighVal
|
|
2810
|
+
|
|
2811
|
+
// ノギスの 2 対も Range と同じ根拠で畳む。マクロ・ミクロとも符号化値から復元した日付を整形するため、
|
|
2812
|
+
// 符号化値が一致すればラベルは文字列まで一致する。しかもノギスには押し退けが無く 2 枚が同一矩形へ
|
|
2813
|
+
// 完全に重なるため、畳まないと同じ値が二重に読み上げられるだけで視覚的な情報も増えない
|
|
2814
|
+
const isVernierMacroLabelMerged = vernierMacroLowEnc === vernierMacroHighEnc
|
|
2815
|
+
// 時点形態のミクロラベルは 1 枚しか無い。畳み込み判定は恒真になるため、Point モードの !isPointMode と
|
|
2816
|
+
// 同じ理由で形態ごと外す (外さないと唯一のラベルが重複として隠れる)
|
|
2817
|
+
const isVernierMicroLabelMerged = !isMicroPointShape && vernierMicroLowEnc === vernierMicroHighEnc
|
|
2818
|
+
|
|
2819
|
+
// ラベルが載る面はつまみと同じ側であり、JSX の data-vernier-pos が示す面と必ず一致する
|
|
2820
|
+
const macroRailLabelPosition: PeriodSliderLabelPosition = isMacroFirstRail ? "top" : "bottom"
|
|
2821
|
+
const microRailLabelPosition: PeriodSliderLabelPosition = isMacroFirstRail ? "bottom" : "top"
|
|
2822
|
+
|
|
2823
|
+
// 傾斜可否はレール単位で決まる。縦向きノギスは縦向き Range と同じ理由で外す (solveVernierPairPlacement 参照)
|
|
2824
|
+
const isVernierSlantable = autoSlantLabels && !isVertical
|
|
2825
|
+
// 傾斜は接近した対を離すための機構であり、時点形態には離す相手が居ない。Point モードが
|
|
2826
|
+
// buildHorizontalSlantResult へ落ちるのと同じく、直立のまま置く
|
|
2827
|
+
const isMicroPairSlantable = isVernierSlantable && !isMicroPointShape
|
|
2828
|
+
|
|
2829
|
+
// 位置以外の入力は 3 レールとも 1 度だけ組む。確定層 (レンダー) と表示層 (ポインター移動) が同じものを読むため、
|
|
2830
|
+
// ラベルを離す距離が「描かれている距離」から外れることが構造的に起こらない。
|
|
2831
|
+
// マクロとミクロは同じトラックの上で比率も単位空間もラベル幅も異なるため、対ごとに独立して解く
|
|
2832
|
+
const flatPlacementInput: FlatPairPlacementInput = { isPointMode, isVertical, autoSlantLabels, isMerged: isLabelMerged, trackLengthPx: trackLength, labelPosition, config: labelSlantConfig }
|
|
2833
|
+
const macroPairInput: VernierPairPlacementInput = { trackLengthPx: trackLength, labelPosition: macroRailLabelPosition, config: buildPairSlantConfig(macroLowLabelBox, macroHighLabelBox), isMerged: isVernierMacroLabelMerged, isSlantable: isVernierSlantable }
|
|
2834
|
+
const microPairInput: VernierPairPlacementInput = { trackLengthPx: trackLength, labelPosition: microRailLabelPosition, config: buildPairSlantConfig(microLowLabelBox, microHighLabelBox), isMerged: isVernierMicroLabelMerged, isSlantable: isMicroPairSlantable }
|
|
2835
|
+
|
|
2253
2836
|
useEffect(() => {
|
|
2254
2837
|
const el = trackRef.current
|
|
2255
2838
|
if (!el) return
|
|
@@ -2275,8 +2858,11 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2275
2858
|
return () => ro.disconnect()
|
|
2276
2859
|
}
|
|
2277
2860
|
|
|
2278
|
-
window
|
|
2279
|
-
|
|
2861
|
+
// ResizeObserver を持たない環境の代替。ここも事象を配送するのはトラックが描かれている文書の window
|
|
2862
|
+
const view = el.ownerDocument.defaultView
|
|
2863
|
+
if (!view) return
|
|
2864
|
+
view.addEventListener("resize", updateDimensions)
|
|
2865
|
+
return () => view.removeEventListener("resize", updateDimensions)
|
|
2280
2866
|
}, [isVertical])
|
|
2281
2867
|
|
|
2282
2868
|
const calcRatioFromPos = useCallback(
|
|
@@ -2302,6 +2888,152 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2302
2888
|
[calcRatioFromPos],
|
|
2303
2889
|
)
|
|
2304
2890
|
|
|
2891
|
+
// ------------------------------------------------------------------
|
|
2892
|
+
// F-2. ドラッグ表示層 (値層とは別に、いま指が居る位置を描く)
|
|
2893
|
+
// ------------------------------------------------------------------
|
|
2894
|
+
const dragPresentationRef = useRef<{ rail: DragPresentationRail; lowRatio: number; highRatio: number } | null>(null)
|
|
2895
|
+
const snapBackTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
2896
|
+
|
|
2897
|
+
// 表示層の書き込みはポインターのイベントから呼ばれ、その時点の向き・確定値・実測寸法を読まなければならない。
|
|
2898
|
+
// useCallback の依存に並べる形では、依存に載せ忘れた 1 つが「離した瞬間だけ古い形へ戻る」形で表に出る (ポインター移動と同じ手)。
|
|
2899
|
+
// 持ち替えはレンダー中ではなくコミット後に行う。破棄されたレンダーでも本体は走るため、レンダー中に書くと
|
|
2900
|
+
// 画面に出ていない値が残り得る (ホストが startTransition の下でこのコンポーネントを駆動する場合に起こる)
|
|
2901
|
+
const projectionGeometryRef = useRef({ macroLowRatio, macroHighRatio, isVertical, isMacroFirstRail })
|
|
2902
|
+
const labelPlacementInputsRef = useRef({ flat: flatPlacementInput, macro: macroPairInput, micro: microPairInput })
|
|
2903
|
+
|
|
2904
|
+
useLayoutEffect(() => {
|
|
2905
|
+
projectionGeometryRef.current = { macroLowRatio, macroHighRatio, isVertical, isMacroFirstRail }
|
|
2906
|
+
labelPlacementInputsRef.current = { flat: flatPlacementInput, macro: macroPairInput, micro: microPairInput }
|
|
2907
|
+
// 事象の時点でレンダーの値を読む口はどれも同じ規則に従う (持ち替えはレンダー中ではなくコミット後)。
|
|
2908
|
+
// Props・確定値・掴んでいるつまみは、破棄されたレンダーの値を残すと、画面に出ていない値で
|
|
2909
|
+
// コールバックの抑止判定と前面の判定が行われる
|
|
2910
|
+
propsRef.current = props
|
|
2911
|
+
committedValuesRef.current = [currentLowVal, currentHighVal]
|
|
2912
|
+
committedVernierRef.current = committedVernierScales
|
|
2913
|
+
activeHandleRef.current = activeHandle
|
|
2914
|
+
activeVernierHandleRef.current = activeVernierHandle
|
|
2915
|
+
})
|
|
2916
|
+
|
|
2917
|
+
/**
|
|
2918
|
+
* Draws the projection cone for a given macro window pair.
|
|
2919
|
+
* 指定のマクロ窓の対に対して、台形プロジェクションを描く関数。
|
|
2920
|
+
*
|
|
2921
|
+
* @param lowRatio - Macro window start as a 0-1 ratio / マクロ窓開始位置の比率 (0-1)
|
|
2922
|
+
* @param highRatio - Macro window end as a 0-1 ratio / マクロ窓終了位置の比率 (0-1)
|
|
2923
|
+
* @returns Nothing / 戻り値なし
|
|
2924
|
+
*/
|
|
2925
|
+
const writeProjectionPath = (lowRatio: number, highRatio: number): void => {
|
|
2926
|
+
const geometry = projectionGeometryRef.current
|
|
2927
|
+
projectionRef.current?.setAttribute("d", buildVernierProjectionPath(lowRatio, highRatio, geometry.isVertical, geometry.isMacroFirstRail))
|
|
2928
|
+
}
|
|
2929
|
+
|
|
2930
|
+
/**
|
|
2931
|
+
* Solves the anti-collision placement of the label pair drawn at a given position pair.
|
|
2932
|
+
* 指定の位置の対へ描かれるラベルの対について、衝突回避配置を解決する関数。
|
|
2933
|
+
*
|
|
2934
|
+
* @param rail - Rail the drag moves / ドラッグが動かすレール
|
|
2935
|
+
* @param lowRatio - Lower label position as a 0-1 ratio / 下限側のラベル位置 (0-1 比率)
|
|
2936
|
+
* @param highRatio - Upper label position as a 0-1 ratio / 上限側のラベル位置 (0-1 比率)
|
|
2937
|
+
* @returns Placement of both labels, or null when the pair's placement does not depend on the positions / 両枚の配置 (対の配置が位置に依存しないなら null)
|
|
2938
|
+
*/
|
|
2939
|
+
const solveLiveLabelPlacement = (rail: DragPresentationRail, lowRatio: number, highRatio: number): DragLabelPlacementPair => {
|
|
2940
|
+
const inputs = labelPlacementInputsRef.current
|
|
2941
|
+
if (rail === "flat") return solveFlatPairPlacement(lowRatio * 100, highRatio * 100, inputs.flat).placements
|
|
2942
|
+
return solveVernierPairPlacement(rail, lowRatio, highRatio, rail === "macro" ? inputs.macro : inputs.micro).placements
|
|
2943
|
+
}
|
|
2944
|
+
|
|
2945
|
+
/**
|
|
2946
|
+
* Draws one rail's parts at the position the pointer is actually at.
|
|
2947
|
+
* 1 つのレールの部品を、ポインターが実際に居る位置へ描く関数。
|
|
2948
|
+
*
|
|
2949
|
+
* @param rail - Rail the drag moves / ドラッグが動かすレール
|
|
2950
|
+
* @param lowRatio - Lower part position as a 0-1 ratio / 下限側の位置 (0-1 比率)
|
|
2951
|
+
* @param highRatio - Upper part position as a 0-1 ratio / 上限側の位置 (0-1 比率)
|
|
2952
|
+
* @returns Nothing / 戻り値なし
|
|
2953
|
+
*/
|
|
2954
|
+
const applyDragPresentation = (rail: DragPresentationRail, lowRatio: number, highRatio: number): void => {
|
|
2955
|
+
const track = trackRef.current
|
|
2956
|
+
if (!track) return
|
|
2957
|
+
dragPresentationRef.current = { rail, lowRatio, highRatio }
|
|
2958
|
+
writeDragPresentation(track, rail, lowRatio, highRatio)
|
|
2959
|
+
const placements = solveLiveLabelPlacement(rail, lowRatio, highRatio)
|
|
2960
|
+
if (placements !== null) writeDragLabelPlacement(track, rail, placements)
|
|
2961
|
+
// コーンの根元はマクロ帯そのもの。マクロを動かしている間だけ、帯と同じ対から描き直す
|
|
2962
|
+
if (rail === "macro") writeProjectionPath(lowRatio, highRatio)
|
|
2963
|
+
}
|
|
2964
|
+
|
|
2965
|
+
/**
|
|
2966
|
+
* Closes the settling window, so the parts it was interpolating stand still again.
|
|
2967
|
+
* 収め戻しの窓を閉じ、補間中だった部品を再び静止させる関数。
|
|
2968
|
+
*
|
|
2969
|
+
* Two callers need it, for one reason each. A fresh grab has to start from a part that is standing still,
|
|
2970
|
+
* otherwise the first `DRAG_SNAP_BACK_MS` of the new drag run through the settling transition and the knob lags
|
|
2971
|
+
* the finger. And a change that did not come from a drag - a key, a wheel, a stepper - must never be interpolated
|
|
2972
|
+
* at all; landing inside the window of a just-released drag is the only way it could be.
|
|
2973
|
+
* 呼び出し元は 2 つあり、理由はそれぞれ別。掴み直しは静止した部品から始めなければならない
|
|
2974
|
+
* (でなければ新しいドラッグの最初の `DRAG_SNAP_BACK_MS` が収め戻しの遷移を通り、つまみが指から遅れる)。
|
|
2975
|
+
* そしてドラッグ以外の変化 (キー・ホイール・ステッパー) は決して補間されてはならず、
|
|
2976
|
+
* 直前に離したドラッグの窓の中で起こることがその唯一の抜け道。
|
|
2977
|
+
*
|
|
2978
|
+
* @returns Nothing / 戻り値なし
|
|
2979
|
+
*/
|
|
2980
|
+
const cancelSnapBack = useCallback((): void => {
|
|
2981
|
+
if (snapBackTimerRef.current !== null) {
|
|
2982
|
+
clearTimeout(snapBackTimerRef.current)
|
|
2983
|
+
snapBackTimerRef.current = null
|
|
2984
|
+
}
|
|
2985
|
+
const track = trackRef.current
|
|
2986
|
+
if (!track) return
|
|
2987
|
+
track.removeAttribute(DRAG_SNAP_ATTRIBUTE)
|
|
2988
|
+
track.style.removeProperty(DRAG_SNAP_DURATION_VARIABLE)
|
|
2989
|
+
}, [])
|
|
2990
|
+
|
|
2991
|
+
/**
|
|
2992
|
+
* Hands every part back to its committed position and opens the window during which it settles there.
|
|
2993
|
+
* 全部品を確定位置へ返し、そこへ収まるまでの窓を開く関数。
|
|
2994
|
+
*
|
|
2995
|
+
* A press that never moved wrote no position, so it opens no window: only a drag that actually left the
|
|
2996
|
+
* committed position has anything to settle back onto.
|
|
2997
|
+
* 一度も動かなかった押下は位置を書いていないため窓を開かない (収め戻す先を持つのは、確定位置から実際に離れたドラッグだけ)。
|
|
2998
|
+
*
|
|
2999
|
+
* @returns Nothing / 戻り値なし
|
|
3000
|
+
*/
|
|
3001
|
+
const endDragPresentation = (): void => {
|
|
3002
|
+
const track = trackRef.current
|
|
3003
|
+
if (dragPresentationRef.current === null || !track) {
|
|
3004
|
+
dragPresentationRef.current = null
|
|
3005
|
+
return
|
|
3006
|
+
}
|
|
3007
|
+
dragPresentationRef.current = null
|
|
3008
|
+
if (snapBackTimerRef.current !== null) clearTimeout(snapBackTimerRef.current)
|
|
3009
|
+
track.style.setProperty(DRAG_SNAP_DURATION_VARIABLE, `${DRAG_SNAP_BACK_MS}ms`)
|
|
3010
|
+
track.setAttribute(DRAG_SNAP_ATTRIBUTE, "true")
|
|
3011
|
+
clearDragPresentation(track)
|
|
3012
|
+
// `d` は CSS 変数を読めないため、確定形状も表示層が書き戻す。React の持つ値と同一なので描画はこの 1 回で終わる
|
|
3013
|
+
writeProjectionPath(projectionGeometryRef.current.macroLowRatio, projectionGeometryRef.current.macroHighRatio)
|
|
3014
|
+
snapBackTimerRef.current = setTimeout(() => {
|
|
3015
|
+
snapBackTimerRef.current = null
|
|
3016
|
+
track.removeAttribute(DRAG_SNAP_ATTRIBUTE)
|
|
3017
|
+
// 窓を閉じたら継続時間も持ち帰る。残すと静止中のトラックが、次の掴みまで意味を持たない宣言を抱えたままになる
|
|
3018
|
+
track.style.removeProperty(DRAG_SNAP_DURATION_VARIABLE)
|
|
3019
|
+
}, DRAG_SNAP_BACK_MS)
|
|
3020
|
+
}
|
|
3021
|
+
|
|
3022
|
+
// 変数はトラックの style 属性にあり React は触れないが、コーンの `d` だけは React が Props として持つ。
|
|
3023
|
+
// ドラッグ中に確定値が 1 段進むと React がそれを書き戻してしまうため、描画のたびに表示層が取り返す
|
|
3024
|
+
useLayoutEffect(() => {
|
|
3025
|
+
const live = dragPresentationRef.current
|
|
3026
|
+
if (live === null) return
|
|
3027
|
+
applyDragPresentation(live.rail, live.lowRatio, live.highRatio)
|
|
3028
|
+
})
|
|
3029
|
+
|
|
3030
|
+
useEffect(
|
|
3031
|
+
() => () => {
|
|
3032
|
+
if (snapBackTimerRef.current !== null) clearTimeout(snapBackTimerRef.current)
|
|
3033
|
+
},
|
|
3034
|
+
[],
|
|
3035
|
+
)
|
|
3036
|
+
|
|
2305
3037
|
// ------------------------------------------------------------------
|
|
2306
3038
|
// G. ドラッグ操作とイベント購読
|
|
2307
3039
|
// ------------------------------------------------------------------
|
|
@@ -2311,6 +3043,8 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2311
3043
|
startPointerPos: number
|
|
2312
3044
|
startLowVal: number
|
|
2313
3045
|
startHighVal: number
|
|
3046
|
+
startLowRatio: number
|
|
3047
|
+
startHighRatio: number
|
|
2314
3048
|
} | null>(null)
|
|
2315
3049
|
|
|
2316
3050
|
const vernierDragContextRef = useRef<{
|
|
@@ -2321,12 +3055,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2321
3055
|
startMacroHighRatio: number
|
|
2322
3056
|
startMicroLowRatio: number
|
|
2323
3057
|
startMicroHighRatio: number
|
|
2324
|
-
startMacroLowEnc: number
|
|
2325
|
-
startMacroHighEnc: number
|
|
2326
|
-
startMicroLowEnc: number
|
|
2327
|
-
startMicroHighEnc: number
|
|
2328
3058
|
startMacroLowDate: Date
|
|
2329
|
-
startMacroHighDate: Date
|
|
2330
3059
|
initialMicroLowDate: Date
|
|
2331
3060
|
initialMicroHighDate: Date
|
|
2332
3061
|
} | null>(null)
|
|
@@ -2335,284 +3064,347 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2335
3064
|
const lastEmittedMacroRangeRef = useRef<string | null>(null)
|
|
2336
3065
|
const lastEmittedMicroRangeRef = useRef<string | null>(null)
|
|
2337
3066
|
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
setActiveVernierHandle(activeMacroHandle)
|
|
2354
|
-
setFrontVernierHandle(activeMacroHandle)
|
|
2355
|
-
}
|
|
3067
|
+
/**
|
|
3068
|
+
* Tells whether a pointer gesture currently owns the value.
|
|
3069
|
+
* いまポインター操作が値の持ち主かどうかを返す関数。
|
|
3070
|
+
*
|
|
3071
|
+
* One gesture owns the value from its press to its release, and every other path that could change the value -
|
|
3072
|
+
* a second pointer, a wheel notch, an arrow key, a stepper - returns while it is live. Without that rule the
|
|
3073
|
+
* drag recomputes the pair from the snapshot it took at the press and silently takes the other path's change
|
|
3074
|
+
* back, after the host has already been handed it as final.
|
|
3075
|
+
* 1 つの操作が押下から解放まで値の持ち主であり、値を変え得る他の経路 (2 本目のポインター・ホイールの 1 段・矢印キー・
|
|
3076
|
+
* ステッパー) はその間ずっと戻る。この規則が無いと、ドラッグは押下時に取った控えから対を計算し直し、確定として
|
|
3077
|
+
* 利用側へ渡した後の他経路の変更を黙って取り消す。
|
|
3078
|
+
*
|
|
3079
|
+
* @returns Whether a flat or vernier drag context is live / 平レール・ノギスのいずれかのドラッグ文脈が生きているか
|
|
3080
|
+
*/
|
|
3081
|
+
const isGestureLive = useCallback((): boolean => dragContextRef.current !== null || vernierDragContextRef.current !== null, [])
|
|
2356
3082
|
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
3083
|
+
/**
|
|
3084
|
+
* Draws and publishes the value under the pointer for the gesture that owns the drag.
|
|
3085
|
+
* ドラッグの持ち主である操作について、ポインターの下の値を描き、発火するハンドラ。
|
|
3086
|
+
*
|
|
3087
|
+
* The listener dispatches through a ref assigned after every commit, so the handler needs no memoised
|
|
3088
|
+
* identity: it is read fresh at event time and closes over the values of the render that is on screen.
|
|
3089
|
+
* リスナーは毎コミット後に持ち替える ref 経由で呼ぶため、この関数はメモ化した同一性を必要としない
|
|
3090
|
+
* (事象の時点で読み直され、画面に出ているレンダーの値を閉じ込める)。
|
|
3091
|
+
*
|
|
3092
|
+
* @param e - Pointer move delivered to the window while a drag is live / ドラッグ中に window へ配送されたポインター移動
|
|
3093
|
+
* @returns Nothing / 戻り値なし
|
|
3094
|
+
*/
|
|
3095
|
+
const handleGlobalPointerMove = (e: PointerEvent): void => {
|
|
3096
|
+
if (disabled) return
|
|
2370
3097
|
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
3098
|
+
if (isVernierMode) {
|
|
3099
|
+
const vCtx = vernierDragContextRef.current
|
|
3100
|
+
if (!vCtx || e.pointerId !== vCtx.pointerId) return
|
|
3101
|
+
if (!trackRef.current) return
|
|
3102
|
+
const pointerRatio = calcRatioFromPos(e.clientX, e.clientY, trackRef.current.getBoundingClientRect())
|
|
3103
|
+
if (pointerRatio === null) return
|
|
3104
|
+
|
|
3105
|
+
if (vCtx.handle === "macro-low" || vCtx.handle === "macro-high" || vCtx.handle === "macro-connect") {
|
|
3106
|
+
const [nextMacroLowRatio, nextMacroHighRatio, activeMacroHandle] = calculateVernierMacroDrag(vCtx.handle, pointerRatio, vCtx.startPointerRatio, vCtx.startMacroLowRatio, vCtx.startMacroHighRatio)
|
|
3107
|
+
applyDragPresentation("macro", nextMacroLowRatio, nextMacroHighRatio)
|
|
3108
|
+
if (activeMacroHandle !== activeVernierHandleRef.current) {
|
|
3109
|
+
activeVernierHandleRef.current = activeMacroHandle
|
|
3110
|
+
setActiveVernierHandle(activeMacroHandle)
|
|
3111
|
+
setFrontVernierHandle(activeMacroHandle)
|
|
3112
|
+
}
|
|
3113
|
+
|
|
3114
|
+
let nextMacroLowDate: Date
|
|
3115
|
+
let nextMacroHighDate: Date
|
|
3116
|
+
if (macroIsDiscreteScale) {
|
|
3117
|
+
const lowIdx = railRatioToDiscreteIndex(sortedMacroAllowedDates, macroUnit, snapMode, nextMacroLowRatio)
|
|
3118
|
+
const highIdx = Math.max(lowIdx, railRatioToDiscreteIndex(sortedMacroAllowedDates, macroUnit, snapMode, nextMacroHighRatio))
|
|
3119
|
+
nextMacroLowDate = sortedMacroAllowedDates[lowIdx]
|
|
3120
|
+
nextMacroHighDate = sortedMacroAllowedDates[highIdx]
|
|
3121
|
+
} else {
|
|
3122
|
+
const nextLowEnc = Math.round(vernierMacroMinEnc + nextMacroLowRatio * macroSpan)
|
|
3123
|
+
const nextHighEnc = Math.round(vernierMacroMinEnc + nextMacroHighRatio * macroSpan)
|
|
3124
|
+
nextMacroLowDate = decode(macroUnit, nextLowEnc)
|
|
3125
|
+
nextMacroHighDate = decode(macroUnit, nextHighEnc)
|
|
3126
|
+
}
|
|
3127
|
+
|
|
3128
|
+
const macroKey = `${nextMacroLowDate.getTime()}_${nextMacroHighDate.getTime()}`
|
|
3129
|
+
if (macroKey !== lastEmittedMacroRangeRef.current) {
|
|
3130
|
+
lastEmittedMacroRangeRef.current = macroKey
|
|
3131
|
+
notifyMacroRange(nextMacroLowDate, nextMacroHighDate)
|
|
3132
|
+
}
|
|
2376
3133
|
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
const minMs = curMacroLowDate.getTime()
|
|
2402
|
-
const maxMs = curMacroHighDate.getTime()
|
|
2403
|
-
const durationMs = vCtx.initialMicroHighDate.getTime() - vCtx.initialMicroLowDate.getTime()
|
|
2404
|
-
let targetLowMs = shiftedLowDate.getTime()
|
|
2405
|
-
let targetHighMs = shiftedHighDate.getTime()
|
|
2406
|
-
|
|
2407
|
-
if (targetLowMs < minMs) {
|
|
2408
|
-
targetLowMs = minMs
|
|
2409
|
-
targetHighMs = Math.min(maxMs, targetLowMs + durationMs)
|
|
2410
|
-
}
|
|
2411
|
-
if (targetHighMs > maxMs) {
|
|
2412
|
-
targetHighMs = maxMs
|
|
2413
|
-
targetLowMs = Math.max(minMs, targetHighMs - durationMs)
|
|
2414
|
-
}
|
|
2415
|
-
|
|
2416
|
-
nextMicroLowDate = normalizeDateByUnit(microUnit, new Date(targetLowMs))
|
|
2417
|
-
nextMicroHighDate = normalizeDateByUnit(microUnit, new Date(targetHighMs))
|
|
3134
|
+
// 両分岐とも同じ窓を見るため、解決は 1 度だけ
|
|
3135
|
+
const [nextWindowStart, nextWindowEnd] = resolveMacroWindow(macroUnit, microUnit, [nextMacroLowDate, nextMacroHighDate], minDate, maxDate)
|
|
3136
|
+
const nextMicroMinEnc = encode(microUnit, nextWindowStart)
|
|
3137
|
+
const nextMicroMaxEnc = encode(microUnit, nextWindowEnd)
|
|
3138
|
+
const nextMicroCandidates = microIsDiscrete ? narrowMicroCandidatesToWindow(nextMicroMinEnc, nextMicroMaxEnc) : []
|
|
3139
|
+
|
|
3140
|
+
// 異単位スケール間 (例: 月×日) でのパン操作時の日数ズレを防ぐため、マクロ単位の暦月・暦年差分に基づいて平行移動
|
|
3141
|
+
let nextMicroLowDate: Date
|
|
3142
|
+
let nextMicroHighDate: Date
|
|
3143
|
+
|
|
3144
|
+
if (vCtx.handle === "macro-connect") {
|
|
3145
|
+
const curMacroLowDate = nextWindowStart
|
|
3146
|
+
const curMacroHighDate = nextWindowEnd
|
|
3147
|
+
|
|
3148
|
+
let shiftedLowDate: Date
|
|
3149
|
+
let shiftedHighDate: Date
|
|
3150
|
+
if (macroUnit === "year") {
|
|
3151
|
+
const yearDelta = nextMacroLowDate.getFullYear() - vCtx.startMacroLowDate.getFullYear()
|
|
3152
|
+
shiftedLowDate = addUnit("year", vCtx.initialMicroLowDate, yearDelta)
|
|
3153
|
+
shiftedHighDate = addUnit("year", vCtx.initialMicroHighDate, yearDelta)
|
|
3154
|
+
} else if (macroUnit === "month") {
|
|
3155
|
+
const monthDelta = (nextMacroLowDate.getFullYear() - vCtx.startMacroLowDate.getFullYear()) * 12 + (nextMacroLowDate.getMonth() - vCtx.startMacroLowDate.getMonth())
|
|
3156
|
+
shiftedLowDate = addUnit("month", vCtx.initialMicroLowDate, monthDelta)
|
|
3157
|
+
shiftedHighDate = addUnit("month", vCtx.initialMicroHighDate, monthDelta)
|
|
2418
3158
|
} else {
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
const maxMs = getMacroWindowEndDate(macroUnit, microUnit, nextMacroHighDate).getTime()
|
|
2423
|
-
const targetLowMs = vCtx.initialMicroLowDate.getTime()
|
|
2424
|
-
const targetHighMs = vCtx.initialMicroHighDate.getTime()
|
|
2425
|
-
|
|
2426
|
-
const clampedLowMs = Math.max(minMs, Math.min(maxMs, targetLowMs))
|
|
2427
|
-
const clampedHighMs = Math.max(clampedLowMs, Math.min(maxMs, targetHighMs))
|
|
2428
|
-
|
|
2429
|
-
nextMicroLowDate = normalizeDateByUnit(microUnit, new Date(clampedLowMs))
|
|
2430
|
-
nextMicroHighDate = normalizeDateByUnit(microUnit, new Date(clampedHighMs))
|
|
3159
|
+
const dayDelta = Math.round((nextMacroLowDate.getTime() - vCtx.startMacroLowDate.getTime()) / (24 * 60 * 60 * 1000))
|
|
3160
|
+
shiftedLowDate = addUnit("day", vCtx.initialMicroLowDate, dayDelta)
|
|
3161
|
+
shiftedHighDate = addUnit("day", vCtx.initialMicroHighDate, dayDelta)
|
|
2431
3162
|
}
|
|
2432
3163
|
|
|
2433
|
-
const
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
3164
|
+
const minMs = curMacroLowDate.getTime()
|
|
3165
|
+
const maxMs = curMacroHighDate.getTime()
|
|
3166
|
+
const durationMs = vCtx.initialMicroHighDate.getTime() - vCtx.initialMicroLowDate.getTime()
|
|
3167
|
+
let targetLowMs = shiftedLowDate.getTime()
|
|
3168
|
+
let targetHighMs = shiftedHighDate.getTime()
|
|
3169
|
+
|
|
3170
|
+
if (targetLowMs < minMs) {
|
|
3171
|
+
targetLowMs = minMs
|
|
3172
|
+
targetHighMs = Math.min(maxMs, targetLowMs + durationMs)
|
|
2437
3173
|
}
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
activeVernierHandleRef.current = activeMicroHandle
|
|
2442
|
-
setActiveVernierHandle(activeMicroHandle)
|
|
2443
|
-
setFrontVernierHandle(activeMicroHandle)
|
|
3174
|
+
if (targetHighMs > maxMs) {
|
|
3175
|
+
targetHighMs = maxMs
|
|
3176
|
+
targetLowMs = Math.max(minMs, targetHighMs - durationMs)
|
|
2444
3177
|
}
|
|
2445
3178
|
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
3179
|
+
nextMicroLowDate = normalizeDateByUnit(microUnit, new Date(targetLowMs))
|
|
3180
|
+
nextMicroHighDate = normalizeDateByUnit(microUnit, new Date(targetHighMs))
|
|
3181
|
+
} else {
|
|
3182
|
+
// マクロ窓境界変更時の弾性復元 (Elastic Range Restoration & Push Clamp)
|
|
3183
|
+
// 記憶した初期境界を毎 move 生きた窓へ当て直すことで、窓を再拡張した際に選択が元位置へ戻る (クランプ後の値を確定させると戻らない)
|
|
3184
|
+
const minMs = nextWindowStart.getTime()
|
|
3185
|
+
const maxMs = nextWindowEnd.getTime()
|
|
3186
|
+
const targetLowMs = vCtx.initialMicroLowDate.getTime()
|
|
3187
|
+
const targetHighMs = vCtx.initialMicroHighDate.getTime()
|
|
3188
|
+
|
|
3189
|
+
const clampedLowMs = Math.max(minMs, Math.min(maxMs, targetLowMs))
|
|
3190
|
+
const clampedHighMs = Math.max(clampedLowMs, Math.min(maxMs, targetHighMs))
|
|
3191
|
+
|
|
3192
|
+
nextMicroLowDate = normalizeDateByUnit(microUnit, new Date(clampedLowMs))
|
|
3193
|
+
nextMicroHighDate = normalizeDateByUnit(microUnit, new Date(clampedHighMs))
|
|
3194
|
+
}
|
|
2459
3195
|
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
3196
|
+
// 離散レールはつまみを最近傍候補の位置に描くため、確定値も同じ規則で解決しないと
|
|
3197
|
+
// 描かれている位置と利用側のステートが食い違う (ミクロつまみのドラッグは既にこの規則で動く)
|
|
3198
|
+
const emitLowEnc = resolveMicroRailEnc(nextMicroLowDate, nextMicroCandidates, nextMicroMinEnc, nextMicroMaxEnc)
|
|
3199
|
+
const emitHighEnc = Math.max(emitLowEnc, resolveMicroRailEnc(nextMicroHighDate, nextMicroCandidates, nextMicroMinEnc, nextMicroMaxEnc))
|
|
3200
|
+
nextMicroLowDate = decode(microUnit, emitLowEnc)
|
|
3201
|
+
nextMicroHighDate = decode(microUnit, emitHighEnc)
|
|
3202
|
+
|
|
3203
|
+
const microKey = `${nextMicroLowDate.getTime()}_${nextMicroHighDate.getTime()}`
|
|
3204
|
+
if (microKey !== lastEmittedMicroRangeRef.current) {
|
|
3205
|
+
lastEmittedMicroRangeRef.current = microKey
|
|
3206
|
+
notifyMicroSelection(nextMicroLowDate, nextMicroHighDate)
|
|
3207
|
+
}
|
|
3208
|
+
} else if (vCtx.handle === "micro-low" || vCtx.handle === "micro-high" || vCtx.handle === "micro-connect" || vCtx.handle === "micro-point") {
|
|
3209
|
+
const [nextMicroLowRatio, nextMicroHighRatio, activeMicroHandle] = calculateVernierMicroDrag(vCtx.handle, pointerRatio, vCtx.startPointerRatio, vCtx.startMicroLowRatio, vCtx.startMicroHighRatio)
|
|
3210
|
+
applyDragPresentation("micro", nextMicroLowRatio, nextMicroHighRatio)
|
|
3211
|
+
if (activeMicroHandle !== activeVernierHandleRef.current) {
|
|
3212
|
+
activeVernierHandleRef.current = activeMicroHandle
|
|
3213
|
+
setActiveVernierHandle(activeMicroHandle)
|
|
3214
|
+
setFrontVernierHandle(activeMicroHandle)
|
|
2465
3215
|
}
|
|
2466
|
-
return
|
|
2467
|
-
}
|
|
2468
3216
|
|
|
2469
|
-
|
|
2470
|
-
|
|
3217
|
+
let nextMicroLowDate: Date
|
|
3218
|
+
let nextMicroHighDate: Date
|
|
3219
|
+
if (microIsDiscreteScale) {
|
|
3220
|
+
const lowIdx = railRatioToDiscreteIndex(sortedMicroAllowedDates, microUnit, snapMode, nextMicroLowRatio)
|
|
3221
|
+
const highIdx = Math.max(lowIdx, railRatioToDiscreteIndex(sortedMicroAllowedDates, microUnit, snapMode, nextMicroHighRatio))
|
|
3222
|
+
nextMicroLowDate = sortedMicroAllowedDates[lowIdx]
|
|
3223
|
+
nextMicroHighDate = sortedMicroAllowedDates[highIdx]
|
|
3224
|
+
} else {
|
|
3225
|
+
// microSpan は比率計算の 0 除算を避けるため 1 で床止めされている。乗数として使うと
|
|
3226
|
+
// 幅 1 単位の窓で窓端の 1 つ先を指すため、他の発火経路と同じレール規則へ通す
|
|
3227
|
+
const lowEnc = resolveMicroRailEnc(decode(microUnit, Math.round(vernierMicroMinEnc + nextMicroLowRatio * microSpan)), railMicroCandidates, vernierMicroMinEnc, vernierMicroMaxEnc)
|
|
3228
|
+
const highEnc = Math.max(lowEnc, resolveMicroRailEnc(decode(microUnit, Math.round(vernierMicroMinEnc + nextMicroHighRatio * microSpan)), railMicroCandidates, vernierMicroMinEnc, vernierMicroMaxEnc))
|
|
3229
|
+
nextMicroLowDate = decode(microUnit, lowEnc)
|
|
3230
|
+
nextMicroHighDate = decode(microUnit, highEnc)
|
|
3231
|
+
}
|
|
2471
3232
|
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
if (!(Number.isFinite(trackLength) && trackLength > 0)) return
|
|
2477
|
-
|
|
2478
|
-
if (ctx.handle === "connect") {
|
|
2479
|
-
const rawDiffPct = isVertical ? (ctx.startPointerPos - currentPos) / trackLength : (currentPos - ctx.startPointerPos) / trackLength
|
|
2480
|
-
|
|
2481
|
-
const res = calculateConnectDragValues({
|
|
2482
|
-
posDiffPct: rawDiffPct,
|
|
2483
|
-
startLowVal: ctx.startLowVal,
|
|
2484
|
-
startHighVal: ctx.startHighVal,
|
|
2485
|
-
rangeMin,
|
|
2486
|
-
rangeMax,
|
|
2487
|
-
isDiscrete,
|
|
2488
|
-
sortedAllowedDates,
|
|
2489
|
-
snapMode,
|
|
2490
|
-
unit,
|
|
2491
|
-
})
|
|
2492
|
-
if (latestDraggingValuesRef.current && latestDraggingValuesRef.current[0] === res[0] && latestDraggingValuesRef.current[1] === res[1]) {
|
|
2493
|
-
return
|
|
3233
|
+
const microKey = `${nextMicroLowDate.getTime()}_${nextMicroHighDate.getTime()}`
|
|
3234
|
+
if (microKey !== lastEmittedMicroRangeRef.current) {
|
|
3235
|
+
lastEmittedMicroRangeRef.current = microKey
|
|
3236
|
+
notifyMicroSelection(nextMicroLowDate, nextMicroHighDate)
|
|
2494
3237
|
}
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
3238
|
+
}
|
|
3239
|
+
return
|
|
3240
|
+
}
|
|
3241
|
+
|
|
3242
|
+
const ctx = dragContextRef.current
|
|
3243
|
+
if (!ctx || e.pointerId !== ctx.pointerId) return
|
|
3244
|
+
|
|
3245
|
+
if (!trackRef.current) return
|
|
3246
|
+
const rect = trackRef.current.getBoundingClientRect()
|
|
3247
|
+
const currentPos = isVertical ? e.clientY : e.clientX
|
|
3248
|
+
const trackLength = isVertical ? rect.height : rect.width
|
|
3249
|
+
if (!(Number.isFinite(trackLength) && trackLength > 0)) return
|
|
3250
|
+
|
|
3251
|
+
if (ctx.handle === "connect") {
|
|
3252
|
+
const rawDiffPct = isVertical ? (ctx.startPointerPos - currentPos) / trackLength : (currentPos - ctx.startPointerPos) / trackLength
|
|
3253
|
+
|
|
3254
|
+
// 値が 1 段も進まない移動でも指には付いて来る必要があるため、値の変化を見る早期脱出より前に置く
|
|
3255
|
+
const [bandLowRatio, bandHighRatio] = resolveBandDragRatios(rawDiffPct, ctx.startLowRatio, ctx.startHighRatio)
|
|
3256
|
+
applyDragPresentation("flat", bandLowRatio, bandHighRatio)
|
|
3257
|
+
|
|
3258
|
+
const res = calculateConnectDragValues({
|
|
3259
|
+
posDiffPct: rawDiffPct,
|
|
3260
|
+
startLowVal: ctx.startLowVal,
|
|
3261
|
+
startHighVal: ctx.startHighVal,
|
|
3262
|
+
rangeMin,
|
|
3263
|
+
rangeMax,
|
|
3264
|
+
isDiscrete,
|
|
3265
|
+
sortedAllowedDates,
|
|
3266
|
+
snapMode,
|
|
3267
|
+
unit,
|
|
3268
|
+
})
|
|
3269
|
+
if (latestDraggingValuesRef.current && latestDraggingValuesRef.current[0] === res[0] && latestDraggingValuesRef.current[1] === res[1]) {
|
|
2498
3270
|
return
|
|
2499
3271
|
}
|
|
3272
|
+
latestDraggingValuesRef.current = res
|
|
3273
|
+
setDraggingValues(res)
|
|
3274
|
+
notifyChange(res[0], res[1], false)
|
|
3275
|
+
return
|
|
3276
|
+
}
|
|
2500
3277
|
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
const clickedVal = pctToValue(ratio * 100)
|
|
3278
|
+
// 長さガードで読んだ矩形を再利用する。読み直すと 1 move につき同期レイアウトが 2 回走る
|
|
3279
|
+
const ratio = calcRatioFromPos(e.clientX, e.clientY, rect)
|
|
3280
|
+
if (ratio === null) return
|
|
2505
3281
|
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
latestDraggingValuesRef.current = [nextLow, nextHigh]
|
|
2509
|
-
setDraggingValues([nextLow, nextHigh])
|
|
2510
|
-
notifyChange(nextLow, nextHigh, false)
|
|
2511
|
-
}
|
|
3282
|
+
const [edgeLowRatio, edgeHighRatio] = resolveEdgeDragRatios(isPointMode ? "point" : ctx.handle, ratio, ctx.startLowRatio, ctx.startHighRatio)
|
|
3283
|
+
applyDragPresentation("flat", edgeLowRatio, edgeHighRatio)
|
|
2512
3284
|
|
|
2513
|
-
|
|
2514
|
-
const currentActive = getActiveDragHandle(ctx.handle, clickedVal, ctx.startLowVal, ctx.startHighVal, isPointMode)
|
|
2515
|
-
if (activeHandleRef.current !== currentActive) {
|
|
2516
|
-
activeHandleRef.current = currentActive
|
|
2517
|
-
setActiveHandle(currentActive)
|
|
2518
|
-
setFrontHandle(currentActive)
|
|
2519
|
-
}
|
|
2520
|
-
}
|
|
2521
|
-
},
|
|
2522
|
-
[
|
|
2523
|
-
disabled,
|
|
2524
|
-
isVernierMode,
|
|
2525
|
-
isVertical,
|
|
2526
|
-
macroUnit,
|
|
2527
|
-
microUnit,
|
|
2528
|
-
macroIsDiscreteScale,
|
|
2529
|
-
microIsDiscreteScale,
|
|
2530
|
-
sortedMacroAllowedDates,
|
|
2531
|
-
sortedMicroAllowedDates,
|
|
2532
|
-
vernierMacroMinEnc,
|
|
2533
|
-
macroSpan,
|
|
2534
|
-
vernierMicroMinEnc,
|
|
2535
|
-
microSpan,
|
|
2536
|
-
rangeMin,
|
|
2537
|
-
rangeMax,
|
|
2538
|
-
isDiscrete,
|
|
2539
|
-
sortedAllowedDates,
|
|
2540
|
-
snapMode,
|
|
2541
|
-
unit,
|
|
2542
|
-
calcRatioFromPos,
|
|
2543
|
-
pctToValue,
|
|
2544
|
-
notifyChange,
|
|
2545
|
-
notifyMacroRange,
|
|
2546
|
-
notifyMicroSelection,
|
|
2547
|
-
isPointMode,
|
|
2548
|
-
],
|
|
2549
|
-
)
|
|
3285
|
+
const clickedVal = pctToValue(ratio * 100)
|
|
2550
3286
|
|
|
2551
|
-
|
|
2552
|
-
(
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
3287
|
+
const [nextLow, nextHigh] = calculateHandleDragValues(ctx.handle, clickedVal, ctx.startLowVal, ctx.startHighVal, rangeMin, rangeMax, isPointMode)
|
|
3288
|
+
if (!latestDraggingValuesRef.current || latestDraggingValuesRef.current[0] !== nextLow || latestDraggingValuesRef.current[1] !== nextHigh) {
|
|
3289
|
+
latestDraggingValuesRef.current = [nextLow, nextHigh]
|
|
3290
|
+
setDraggingValues([nextLow, nextHigh])
|
|
3291
|
+
notifyChange(nextLow, nextHigh, false)
|
|
3292
|
+
}
|
|
3293
|
+
|
|
3294
|
+
if (!isPointMode && (ctx.handle === "low" || ctx.handle === "high")) {
|
|
3295
|
+
// 強調と最前面は、いま指の下に描かれているつまみが持たなければならない。丸めた値で判定すると
|
|
3296
|
+
// 支点を越えてから半目盛りの間、動いていないつまみが強調され、動いているつまみがその背面へ回る
|
|
3297
|
+
const currentActive = resolveDraggedEdge(ctx.handle, ratio, ctx.startLowRatio, ctx.startHighRatio)
|
|
3298
|
+
if (activeHandleRef.current !== currentActive) {
|
|
3299
|
+
activeHandleRef.current = currentActive
|
|
3300
|
+
setActiveHandle(currentActive)
|
|
3301
|
+
setFrontHandle(currentActive)
|
|
2563
3302
|
}
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
|
|
3306
|
+
/**
|
|
3307
|
+
* Ends the gesture that owns the drag, commits its final value and opens the settling window.
|
|
3308
|
+
* ドラッグの持ち主である操作を終え、確定値を発火して収め戻しの窓を開くハンドラ。
|
|
3309
|
+
*
|
|
3310
|
+
* A cancelled pointer ends the gesture exactly as a released one does: the position the gesture was interrupted at
|
|
3311
|
+
* is the committed value, and the pre-drag value is not restored. That is what a native range input does, and the
|
|
3312
|
+
* values along the way have already been published, so restoring would hand the host a change it never made.
|
|
3313
|
+
* 取り消されたポインターは、離されたポインターと全く同じように操作を終える (中断された位置がそのまま確定値であり、
|
|
3314
|
+
* ドラッグ開始前の値へは戻さない)。ネイティブの range 入力と同じ挙動であり、途上の値は既に発火済みのため、
|
|
3315
|
+
* 戻すことは利用者が行っていない変更を利用側へ渡すことになる。
|
|
3316
|
+
*
|
|
3317
|
+
* @param e - Pointer up or pointer cancel delivered to the window / window へ配送された pointerup または pointercancel
|
|
3318
|
+
* @returns Nothing / 戻り値なし
|
|
3319
|
+
*/
|
|
3320
|
+
const handleGlobalPointerUp = (e: PointerEvent): void => {
|
|
3321
|
+
if (isVernierMode) {
|
|
3322
|
+
const vCtx = vernierDragContextRef.current
|
|
3323
|
+
// 別のポインターが離れただけでドラッグを畳むと、指を置いたままのユーザーの手の下で掴みが解け、
|
|
3324
|
+
// さらに収め戻しが走って部品が確定位置へ戻る。持ち主の判定は平レールと同じ規則で行う
|
|
3325
|
+
if (!vCtx || e.pointerId !== vCtx.pointerId) return
|
|
3326
|
+
|
|
3327
|
+
endDragPresentation()
|
|
3328
|
+
lastEmittedMacroRangeRef.current = null
|
|
3329
|
+
lastEmittedMicroRangeRef.current = null
|
|
3330
|
+
vernierDragContextRef.current = null
|
|
3331
|
+
activeVernierHandleRef.current = null
|
|
3332
|
+
setActiveVernierHandle(null)
|
|
3333
|
+
// 予約したままドラッグを終えると、指を離した位置の値が発火されずに消える
|
|
3334
|
+
flushPendingEmit(macroEmitRef.current)
|
|
3335
|
+
flushPendingEmit(microEmitRef.current)
|
|
3336
|
+
return
|
|
3337
|
+
}
|
|
2564
3338
|
|
|
2565
|
-
|
|
2566
|
-
|
|
3339
|
+
const ctx = dragContextRef.current
|
|
3340
|
+
if (!ctx || e.pointerId !== ctx.pointerId) return
|
|
2567
3341
|
|
|
2568
|
-
|
|
2569
|
-
if (finalVals) {
|
|
2570
|
-
notifyChange(finalVals[0], finalVals[1], true)
|
|
2571
|
-
setUncontrolledValues(finalVals)
|
|
2572
|
-
}
|
|
3342
|
+
endDragPresentation()
|
|
2573
3343
|
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
},
|
|
2580
|
-
[isVernierMode, draggingValues, notifyChange, flushPendingEmit],
|
|
2581
|
-
)
|
|
3344
|
+
const finalVals = latestDraggingValuesRef.current ?? draggingValues
|
|
3345
|
+
if (finalVals) {
|
|
3346
|
+
notifyChange(finalVals[0], finalVals[1], true)
|
|
3347
|
+
setUncontrolledValues(finalVals)
|
|
3348
|
+
}
|
|
2582
3349
|
|
|
2583
|
-
|
|
2584
|
-
|
|
3350
|
+
latestDraggingValuesRef.current = null
|
|
3351
|
+
setDraggingValues(null)
|
|
3352
|
+
dragContextRef.current = null
|
|
3353
|
+
activeHandleRef.current = null
|
|
3354
|
+
setActiveHandle(null)
|
|
3355
|
+
}
|
|
2585
3356
|
|
|
3357
|
+
const handlePointerMoveRef = useRef(handleGlobalPointerMove)
|
|
2586
3358
|
const handlePointerUpRef = useRef(handleGlobalPointerUp)
|
|
2587
|
-
|
|
3359
|
+
|
|
3360
|
+
useLayoutEffect(() => {
|
|
3361
|
+
handlePointerMoveRef.current = handleGlobalPointerMove
|
|
3362
|
+
handlePointerUpRef.current = handleGlobalPointerUp
|
|
3363
|
+
})
|
|
2588
3364
|
|
|
2589
3365
|
const isDragging = activeHandle !== null || activeVernierHandle !== null
|
|
2590
3366
|
|
|
2591
3367
|
useEffect(() => {
|
|
2592
3368
|
if (!isDragging) return
|
|
2593
3369
|
|
|
3370
|
+
// 事象を配送するのは、このスライダーが描かれている文書の window (ホイールの登録と同じ規則)。
|
|
3371
|
+
// モジュールの window へ張ると、別文書へポータルされたスライダーには移動も解放も 1 度も届かず、
|
|
3372
|
+
// 掴みが永久に生き続けてホイール・矢印キー・ステッパーを締め出したままになる (6.3)
|
|
3373
|
+
const view = rootRef.current?.ownerDocument.defaultView
|
|
3374
|
+
if (!view) return
|
|
3375
|
+
|
|
2594
3376
|
const onMove = (e: PointerEvent) => handlePointerMoveRef.current(e)
|
|
2595
3377
|
const onUp = (e: PointerEvent) => handlePointerUpRef.current(e)
|
|
2596
3378
|
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
3379
|
+
view.addEventListener("pointermove", onMove)
|
|
3380
|
+
view.addEventListener("pointerup", onUp)
|
|
3381
|
+
view.addEventListener("pointercancel", onUp)
|
|
3382
|
+
// 掴んだ要素が操作中に外されると捕捉は解除され、以後の移動も解放もこの window へは届かない。
|
|
3383
|
+
// 終わりを受け取らないと掴みが永久に生き続け、値を動かせる他の経路すべてが戻り続ける
|
|
3384
|
+
view.addEventListener("lostpointercapture", onUp)
|
|
2600
3385
|
|
|
2601
3386
|
return () => {
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
3387
|
+
view.removeEventListener("pointermove", onMove)
|
|
3388
|
+
view.removeEventListener("pointerup", onUp)
|
|
3389
|
+
view.removeEventListener("pointercancel", onUp)
|
|
3390
|
+
view.removeEventListener("lostpointercapture", onUp)
|
|
2605
3391
|
}
|
|
2606
3392
|
}, [isDragging])
|
|
2607
3393
|
|
|
2608
3394
|
const startDrag = useCallback(
|
|
2609
|
-
(pointerId: number, handle: "low" | "high" | "connect", startPointerPos: number) => {
|
|
3395
|
+
(grabbed: Element, pointerId: number, handle: "low" | "high" | "connect", startPointerPos: number) => {
|
|
3396
|
+
cancelSnapBack()
|
|
3397
|
+
captureGesturePointer(grabbed, pointerId)
|
|
2610
3398
|
dragContextRef.current = {
|
|
2611
3399
|
pointerId,
|
|
2612
3400
|
handle,
|
|
2613
3401
|
startPointerPos,
|
|
2614
3402
|
startLowVal: currentLowVal,
|
|
2615
3403
|
startHighVal: currentHighVal,
|
|
3404
|
+
// 表示の出発点は「いま描かれている位置」。値を基準にすると、時間比例スナップのように
|
|
3405
|
+
// 値と位置が線形でないレールで、掴んでいない側の支点が実際の描画位置からずれる
|
|
3406
|
+
startLowRatio: valueToPct(currentLowVal) / 100,
|
|
3407
|
+
startHighRatio: valueToPct(currentHighVal) / 100,
|
|
2616
3408
|
}
|
|
2617
3409
|
activeHandleRef.current = handle
|
|
2618
3410
|
setActiveHandle(handle)
|
|
@@ -2620,13 +3412,15 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2620
3412
|
setFrontHandle(handle)
|
|
2621
3413
|
}
|
|
2622
3414
|
},
|
|
2623
|
-
[currentLowVal, currentHighVal],
|
|
3415
|
+
[currentLowVal, currentHighVal, valueToPct],
|
|
2624
3416
|
)
|
|
2625
3417
|
|
|
2626
3418
|
const startVernierDrag = useCallback(
|
|
2627
|
-
(pointerId: number, handle: VernierHandle, startPointerRatio: number) => {
|
|
3419
|
+
(grabbed: Element, pointerId: number, handle: VernierHandle, startPointerRatio: number) => {
|
|
2628
3420
|
const p = propsRef.current
|
|
2629
3421
|
if (p.mode !== "vernier") return
|
|
3422
|
+
cancelSnapBack()
|
|
3423
|
+
captureGesturePointer(grabbed, pointerId)
|
|
2630
3424
|
vernierDragContextRef.current = {
|
|
2631
3425
|
pointerId,
|
|
2632
3426
|
handle,
|
|
@@ -2635,12 +3429,10 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2635
3429
|
startMacroHighRatio: macroHighRatio,
|
|
2636
3430
|
startMicroLowRatio: microLowRatio,
|
|
2637
3431
|
startMicroHighRatio: microHighRatio,
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
startMacroLowDate: p.macroRange[0],
|
|
2643
|
-
startMacroHighDate: p.macroRange[1],
|
|
3432
|
+
// 平行移動量は暦差分で求めるため、基準は表示しているマクロ値 (期間先頭・定義域内) でなければならない。
|
|
3433
|
+
// 生の Props を基準にすると、期間の途中や定義域の外を指す開始日で日差分が半端になり、
|
|
3434
|
+
// 動いていない押下でも丸めで 1 単位ずれる
|
|
3435
|
+
startMacroLowDate: vernierMacroLowDate,
|
|
2644
3436
|
initialMicroLowDate: vernierMicroLowDate,
|
|
2645
3437
|
initialMicroHighDate: vernierMicroHighDate,
|
|
2646
3438
|
}
|
|
@@ -2648,16 +3440,16 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2648
3440
|
setActiveVernierHandle(handle)
|
|
2649
3441
|
setFrontVernierHandle(handle)
|
|
2650
3442
|
},
|
|
2651
|
-
[macroLowRatio, macroHighRatio, microLowRatio, microHighRatio,
|
|
3443
|
+
[macroLowRatio, macroHighRatio, microLowRatio, microHighRatio, vernierMacroLowDate, vernierMicroLowDate, vernierMicroHighDate],
|
|
2652
3444
|
)
|
|
2653
3445
|
|
|
2654
3446
|
const handleKnobPointerDown = (handle: "low" | "high") => (e: React.PointerEvent<HTMLDivElement>) => {
|
|
2655
|
-
if (disabled) return
|
|
3447
|
+
if (disabled || isGestureLive()) return
|
|
2656
3448
|
e.stopPropagation()
|
|
2657
3449
|
e.preventDefault()
|
|
2658
3450
|
setFrontHandle(handle)
|
|
2659
3451
|
const pos = isVertical ? e.clientY : e.clientX
|
|
2660
|
-
startDrag(e.pointerId, handle, pos)
|
|
3452
|
+
startDrag(e.currentTarget, e.pointerId, handle, pos)
|
|
2661
3453
|
}
|
|
2662
3454
|
|
|
2663
3455
|
/**
|
|
@@ -2690,26 +3482,26 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2690
3482
|
}
|
|
2691
3483
|
|
|
2692
3484
|
const handleVernierKnobPointerDown = (handle: VernierHandle) => (e: React.PointerEvent<HTMLDivElement>) => {
|
|
2693
|
-
if (disabled) return
|
|
3485
|
+
if (disabled || isGestureLive()) return
|
|
2694
3486
|
e.stopPropagation()
|
|
2695
3487
|
e.preventDefault()
|
|
2696
3488
|
const el = trackRef.current
|
|
2697
3489
|
if (!el) return
|
|
2698
3490
|
const pointerRatio = calcRatioFromPos(e.clientX, e.clientY, el.getBoundingClientRect())
|
|
2699
3491
|
if (pointerRatio === null) return
|
|
2700
|
-
startVernierDrag(e.pointerId, handle, pointerRatio)
|
|
3492
|
+
startVernierDrag(e.currentTarget, e.pointerId, handle, pointerRatio)
|
|
2701
3493
|
}
|
|
2702
3494
|
|
|
2703
3495
|
const handleConnectPointerDown = (e: React.PointerEvent<HTMLDivElement>) => {
|
|
2704
|
-
if (disabled || hideConnectBar) return
|
|
3496
|
+
if (disabled || hideConnectBar || isGestureLive()) return
|
|
2705
3497
|
e.stopPropagation()
|
|
2706
3498
|
e.preventDefault()
|
|
2707
3499
|
const pos = isVertical ? e.clientY : e.clientX
|
|
2708
|
-
startDrag(e.pointerId, "connect", pos)
|
|
3500
|
+
startDrag(e.currentTarget, e.pointerId, "connect", pos)
|
|
2709
3501
|
}
|
|
2710
3502
|
|
|
2711
3503
|
const handleTrackPointerDown = (e: React.PointerEvent<HTMLDivElement>) => {
|
|
2712
|
-
if (disabled) return
|
|
3504
|
+
if (disabled || isGestureLive()) return
|
|
2713
3505
|
|
|
2714
3506
|
if (isVernierMode) {
|
|
2715
3507
|
const el = trackRef.current
|
|
@@ -2720,7 +3512,11 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2720
3512
|
const pointerCrossAxisOffset = isVertical ? e.clientX - (rect.left + rect.width / 2) : e.clientY - (rect.top + rect.height / 2)
|
|
2721
3513
|
// 帯を隠したまま帯ドラッグだけ残ると、描かれていない当たり判定が生き続ける
|
|
2722
3514
|
const targetHandle = resolveVernierTargetHandle(pointerRatio, pointerCrossAxisOffset, macroLowRatio, macroHighRatio, microLowRatio, microHighRatio, vernierOrientation, undefined, !hideConnectBar, isMicroPointShape ? "point" : "range")
|
|
2723
|
-
startVernierDrag(e.pointerId, targetHandle, pointerRatio)
|
|
3515
|
+
startVernierDrag(e.currentTarget, e.pointerId, targetHandle, pointerRatio)
|
|
3516
|
+
// 押しただけで指を動かさない操作にも、単一ポインターの経路が要る (WCAG 2.2 SC 2.5.7。キーボードでは満たせない)。
|
|
3517
|
+
// 押下をその操作の最初の移動として同じ規則へ通すことで、平レールと同じ「押した所へ寄る」動きになり、
|
|
3518
|
+
// 幅を保つ帯の押下は移動量 0 の平行移動として何も動かさない
|
|
3519
|
+
handlePointerMoveRef.current(e.nativeEvent)
|
|
2724
3520
|
return
|
|
2725
3521
|
}
|
|
2726
3522
|
|
|
@@ -2747,11 +3543,19 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2747
3543
|
notifyChange(nextLow, nextHigh, true)
|
|
2748
3544
|
|
|
2749
3545
|
const pos = isVertical ? e.clientY : e.clientX
|
|
2750
|
-
startDrag(e.pointerId, chosenHandle, pos)
|
|
3546
|
+
startDrag(e.currentTarget, e.pointerId, chosenHandle, pos)
|
|
2751
3547
|
}
|
|
2752
3548
|
|
|
2753
|
-
|
|
2754
|
-
|
|
3549
|
+
/**
|
|
3550
|
+
* Tracks the value under the pointer for the hover guide while no knob is being dragged; vernier mode draws no hover guide, so it tracks nothing.
|
|
3551
|
+
* つまみのドラッグ中でない間、ホバーガイド用にポインターの下の値を追跡するハンドラ (ノギスはホバーガイドを描かないため追跡しない)。
|
|
3552
|
+
*
|
|
3553
|
+
* @param e - Pointer move over the track / トラック上のポインター移動
|
|
3554
|
+
* @returns Nothing / 戻り値なし
|
|
3555
|
+
*/
|
|
3556
|
+
const handleTrackPointerMove = (e: React.PointerEvent<HTMLDivElement>): void => {
|
|
3557
|
+
// ノギスはホバーガイドを描かない。状態だけ更新すると移動のたびに矩形の読み取りと再描画が走る
|
|
3558
|
+
if (disabled || isVernierMode || activeHandle !== null) return
|
|
2755
3559
|
const pct = getTrackPctFromPointer(e.clientX, e.clientY)
|
|
2756
3560
|
if (pct === null) return
|
|
2757
3561
|
const val = pctToValue(pct)
|
|
@@ -2768,12 +3572,13 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2768
3572
|
// H. キーボードとステッパー操作
|
|
2769
3573
|
// ------------------------------------------------------------------
|
|
2770
3574
|
const handleKeyDown = (handle: "low" | "high") => (e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
2771
|
-
if (disabled) return
|
|
3575
|
+
if (disabled || isGestureLive()) return
|
|
2772
3576
|
setFrontHandle(handle)
|
|
2773
3577
|
|
|
2774
3578
|
const res = calculateKeyboardActionValues(e.key, handle, currentLowVal, currentHighVal, rangeMin, rangeMax, isPointMode, 1)
|
|
2775
3579
|
if (res) {
|
|
2776
3580
|
e.preventDefault()
|
|
3581
|
+
cancelSnapBack()
|
|
2777
3582
|
if (!isControlled) {
|
|
2778
3583
|
setUncontrolledValues(res)
|
|
2779
3584
|
}
|
|
@@ -2785,22 +3590,33 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2785
3590
|
* Re-contains the micro selection into a newly resolved macro window and emits it only when it moved.
|
|
2786
3591
|
* 新しく確定したマクロ窓へミクロ選択を収め直し、実際に動いた場合のみ発火する関数。
|
|
2787
3592
|
*
|
|
2788
|
-
*
|
|
3593
|
+
* Containment is applied to the two tuple slots with the upper one floored at the lower, so a zero-width
|
|
2789
3594
|
* point selection stays a point: the shape needs no branch of its own here.
|
|
2790
|
-
*
|
|
3595
|
+
* 収め直しは上限を下限で床止めしてタプル 2 枠へ適用するため、幅ゼロの時点選択は時点のまま保たれ、形態別の分岐を持たない。
|
|
3596
|
+
*
|
|
3597
|
+
* A discrete micro rail only draws its candidate set, so the selection is carried to the nearest
|
|
3598
|
+
* candidate of the next window rather than to the window edge; a window holding no candidate at all
|
|
3599
|
+
* is continuous by specification and keeps the plain encoded clamp.
|
|
3600
|
+
* 離散ミクロレールは候補集合しか描かないため、選択は窓端ではなく次の窓の最近傍候補へ運ぶ。
|
|
3601
|
+
* 候補を 1 つも含まない窓は仕様上連続レールとなるため、素のエンコード値クランプのまま。
|
|
2791
3602
|
*
|
|
2792
3603
|
* @param nextMacroLow - Start date of the macro window just resolved / 確定直後のマクロ窓開始日付
|
|
2793
3604
|
* @param nextMacroHigh - End date of the macro window just resolved / 確定直後のマクロ窓終了日付
|
|
2794
3605
|
* @returns Nothing / 戻り値なし
|
|
2795
3606
|
*/
|
|
2796
3607
|
const containMicroSelectionIntoMacroWindow = (nextMacroLow: Date, nextMacroHigh: Date): void => {
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
const
|
|
2800
|
-
const
|
|
2801
|
-
const
|
|
2802
|
-
|
|
2803
|
-
|
|
3608
|
+
if (vernierMicroSelection === null) return
|
|
3609
|
+
// 次のレンダーでミクロレール端はこの窓へ置き換わる。同じ解決器で収め直さないと aria-valuenow が aria-valuemax の外を指し続ける
|
|
3610
|
+
const [nextWindowStart, nextWindowEnd] = resolveMacroWindow(macroUnit, microUnit, [nextMacroLow, nextMacroHigh], minDate, maxDate)
|
|
3611
|
+
const nextMicroMinEnc = encode(microUnit, nextWindowStart)
|
|
3612
|
+
const nextMicroMaxEnc = encode(microUnit, nextWindowEnd)
|
|
3613
|
+
const nextCandidates = microIsDiscrete ? narrowMicroCandidatesToWindow(nextMicroMinEnc, nextMicroMaxEnc) : []
|
|
3614
|
+
// 出発点は利用側が保持している選択そのもの。レールへ載せた表示値から出発すると、新しい窓が選択を
|
|
3615
|
+
// 完全に含む場合でも古い窓の端へ引き戻し、比較の両辺が同じ端になって訂正自体が発火しなくなる。
|
|
3616
|
+
// 動いていない選択を鳴らさない判定は notifyMicroSelection が全経路分まとめて持つ
|
|
3617
|
+
const nextLowEnc = resolveMicroRailEnc(vernierMicroSelection[0], nextCandidates, nextMicroMinEnc, nextMicroMaxEnc)
|
|
3618
|
+
const nextHighEnc = Math.max(nextLowEnc, resolveMicroRailEnc(vernierMicroSelection[1], nextCandidates, nextMicroMinEnc, nextMicroMaxEnc))
|
|
3619
|
+
notifyMicroSelection(decode(microUnit, nextLowEnc), decode(microUnit, nextHighEnc), true)
|
|
2804
3620
|
}
|
|
2805
3621
|
|
|
2806
3622
|
/**
|
|
@@ -2815,7 +3631,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2815
3631
|
* @returns Keyboard event handler for the given handle / 指定ハンドル用のキーボードイベントハンドラ
|
|
2816
3632
|
*/
|
|
2817
3633
|
const handleVernierKeyDown = (handle: "macro-low" | "macro-high" | "micro-low" | "micro-high" | "micro-point") => (e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
2818
|
-
if (disabled || !isVernierMode || props.mode !== "vernier") return
|
|
3634
|
+
if (disabled || !isVernierMode || props.mode !== "vernier" || isGestureLive()) return
|
|
2819
3635
|
setFrontVernierHandle(handle)
|
|
2820
3636
|
let delta = 0
|
|
2821
3637
|
let isHome = false
|
|
@@ -2845,6 +3661,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2845
3661
|
return
|
|
2846
3662
|
}
|
|
2847
3663
|
e.preventDefault()
|
|
3664
|
+
cancelSnapBack()
|
|
2848
3665
|
|
|
2849
3666
|
if (handle === "macro-low") {
|
|
2850
3667
|
const currentLow = decode(macroUnit, vernierMacroLowEnc)
|
|
@@ -2934,10 +3751,66 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
2934
3751
|
}
|
|
2935
3752
|
}
|
|
2936
3753
|
|
|
3754
|
+
/**
|
|
3755
|
+
* Shifts the macro window by delta macro units, preserving its width and clamping it to the domain.
|
|
3756
|
+
* マクロ窓を delta マクロ単位だけ幅を保ったまま平行移動し、定義域へクランプする関数。
|
|
3757
|
+
*
|
|
3758
|
+
* The rule is the one the stepper already applies to the micro selection: keep the span, re-anchor at
|
|
3759
|
+
* whichever end the shift would have crossed, and re-contain the micro selection into the new window.
|
|
3760
|
+
* 規則はステッパーがミクロ選択へ既に適用しているものと同一 (幅を保ち、越えた側の端へ寄せ直し、
|
|
3761
|
+
* ミクロ選択を新しい窓へ収め直す)。
|
|
3762
|
+
*
|
|
3763
|
+
* @param delta - Signed number of macro units to move by / 移動するマクロ単位数 (符号付き)
|
|
3764
|
+
* @returns Nothing / 戻り値なし
|
|
3765
|
+
*/
|
|
3766
|
+
const shiftMacroWindow = (delta: number): void => {
|
|
3767
|
+
if (props.mode !== "vernier") return
|
|
3768
|
+
cancelSnapBack()
|
|
3769
|
+
|
|
3770
|
+
if (macroIsDiscreteScale) {
|
|
3771
|
+
const maxIdx = sortedMacroAllowedDates.length - 1
|
|
3772
|
+
const curLowIdx = findNearestDateIndex(sortedMacroAllowedDates, vernierMacroLowDate, macroUnit)
|
|
3773
|
+
const curHighIdx = findNearestDateIndex(sortedMacroAllowedDates, vernierMacroHighDate, macroUnit)
|
|
3774
|
+
const idxSpan = curHighIdx - curLowIdx
|
|
3775
|
+
let nextLowIdx = curLowIdx + delta
|
|
3776
|
+
let nextHighIdx = curHighIdx + delta
|
|
3777
|
+
if (delta < 0 && nextLowIdx < 0) {
|
|
3778
|
+
nextLowIdx = 0
|
|
3779
|
+
nextHighIdx = Math.min(maxIdx, idxSpan)
|
|
3780
|
+
} else if (delta > 0 && nextHighIdx > maxIdx) {
|
|
3781
|
+
nextHighIdx = maxIdx
|
|
3782
|
+
nextLowIdx = Math.max(0, maxIdx - idxSpan)
|
|
3783
|
+
}
|
|
3784
|
+
if (nextLowIdx === curLowIdx && nextHighIdx === curHighIdx) return
|
|
3785
|
+
const nextLowDate = sortedMacroAllowedDates[nextLowIdx]
|
|
3786
|
+
const nextHighDate = sortedMacroAllowedDates[nextHighIdx]
|
|
3787
|
+
notifyMacroRange(nextLowDate, nextHighDate, true)
|
|
3788
|
+
containMicroSelectionIntoMacroWindow(nextLowDate, nextHighDate)
|
|
3789
|
+
return
|
|
3790
|
+
}
|
|
3791
|
+
|
|
3792
|
+
const span = vernierMacroHighEnc - vernierMacroLowEnc
|
|
3793
|
+
let nextLow = vernierMacroLowEnc + delta
|
|
3794
|
+
let nextHigh = vernierMacroHighEnc + delta
|
|
3795
|
+
if (delta < 0 && nextLow < vernierMacroMinEnc) {
|
|
3796
|
+
nextLow = vernierMacroMinEnc
|
|
3797
|
+
nextHigh = Math.min(vernierMacroMaxEnc, nextLow + span)
|
|
3798
|
+
} else if (delta > 0 && nextHigh > vernierMacroMaxEnc) {
|
|
3799
|
+
nextHigh = vernierMacroMaxEnc
|
|
3800
|
+
nextLow = Math.max(vernierMacroMinEnc, nextHigh - span)
|
|
3801
|
+
}
|
|
3802
|
+
if (nextLow === vernierMacroLowEnc && nextHigh === vernierMacroHighEnc) return
|
|
3803
|
+
const nextLowDate = decode(macroUnit, nextLow)
|
|
3804
|
+
const nextHighDate = decode(macroUnit, nextHigh)
|
|
3805
|
+
notifyMacroRange(nextLowDate, nextHighDate, true)
|
|
3806
|
+
containMicroSelectionIntoMacroWindow(nextLowDate, nextHighDate)
|
|
3807
|
+
}
|
|
3808
|
+
|
|
2937
3809
|
const shift = useCallback(
|
|
2938
3810
|
(delta: number) => {
|
|
2939
3811
|
const p = propsRef.current
|
|
2940
|
-
if (p.disabled) return
|
|
3812
|
+
if (p.disabled || isGestureLive()) return
|
|
3813
|
+
cancelSnapBack()
|
|
2941
3814
|
|
|
2942
3815
|
if (p.mode === "point") {
|
|
2943
3816
|
const nextVal = Math.max(rangeMin, Math.min(rangeMax, currentLowVal + delta))
|
|
@@ -3019,9 +3892,131 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3019
3892
|
sortedMicroAllowedDates,
|
|
3020
3893
|
vernierMicroLowDate,
|
|
3021
3894
|
vernierMicroHighDate,
|
|
3895
|
+
cancelSnapBack,
|
|
3022
3896
|
],
|
|
3023
3897
|
)
|
|
3024
3898
|
|
|
3899
|
+
/**
|
|
3900
|
+
* Tells whether a wheel gesture's hit target is a part this slider draws.
|
|
3901
|
+
* ホイール操作のヒットテストの相手が、このスライダーが描く部品かを返す関数。
|
|
3902
|
+
*
|
|
3903
|
+
* A disabled slider draws parts but owns no point, exactly as it owns no point of its range area: the gesture has
|
|
3904
|
+
* to reach whatever lies under it, and a slider that cannot move must not swallow it.
|
|
3905
|
+
* 無効なスライダーは部品を描くがどの点も持たない (範囲領域のどの点も持たないのと同じ)。操作は下にあるものへ
|
|
3906
|
+
* 届かなければならず、動けないスライダーがそれを飲み込んではならない。
|
|
3907
|
+
*
|
|
3908
|
+
* The target is narrowed structurally (`containsEventTarget`) rather than with `instanceof`, so the rule keeps
|
|
3909
|
+
* answering for the slider this per-document registry exists for: one portalled into another document.
|
|
3910
|
+
* 相手の絞り込みは `instanceof` ではなく構造で行う (`containsEventTarget`)。文書ごとの登録簿が存在する理由である
|
|
3911
|
+
* 「別文書へポータルされたスライダー」でも、この規則が答え続けるため。
|
|
3912
|
+
*
|
|
3913
|
+
* @param target - Hit target the wheel event carries / ホイールイベントが運ぶヒットテストの相手
|
|
3914
|
+
* @returns Whether the target is inside this slider and this slider can move / 相手がこのスライダーの中にあり、かつこのスライダーが動けるか
|
|
3915
|
+
*/
|
|
3916
|
+
const ownsWheelHit = (target: EventTarget | null): boolean => !disabled && containsEventTarget(rootRef.current, target)
|
|
3917
|
+
|
|
3918
|
+
/**
|
|
3919
|
+
* Resolves how far a pointer sits from the rail centre line while it is over this slider's range area.
|
|
3920
|
+
* ポインターがこのスライダーの範囲領域の上にある間、トラック中心線からどれだけ離れているかを解決する関数。
|
|
3921
|
+
*
|
|
3922
|
+
* Across the rail the area is the rectangle the stylesheet lays out (`.period-slider-range-area`), measured rather
|
|
3923
|
+
* than recomputed, so the region that answers the wheel is the same box the stylesheet composes from the lane and
|
|
3924
|
+
* the anchor line; along the rail `ownsPaintedPoint` inflates that measured rectangle by the label reach instead,
|
|
3925
|
+
* because an element grown past the root would add that overhang as scrollable overflow to a tight host for a
|
|
3926
|
+
* region that draws nothing. The element draws nothing and answers no hit test, so the measurement costs the area
|
|
3927
|
+
* no pointer ownership. A disabled slider, an unmeasurable area and a slider that is not painted own no point.
|
|
3928
|
+
* 交差軸では、領域はスタイルシートが組み立てた矩形 (`.period-slider-range-area`) を計算し直さずに実測したもの
|
|
3929
|
+
* (ホイールに答える領域は、レーンと基準線からスタイルシートが組む箱そのもの)。レール方向は代わりに実測した矩形を
|
|
3930
|
+
* `ownsPaintedPoint` がラベル到達距離だけ膨らませる。ルートの外へ大きくした要素は、何も描かない領域のために
|
|
3931
|
+
* 余裕のないホストへそのはみ出し量のスクロールを足すため。この要素は何も描かずヒットテストにも答えないため、
|
|
3932
|
+
* 実測しても領域が押下の持ち主になることはない。無効なスライダー・寸法を持たない領域・描かれていないスライダーは
|
|
3933
|
+
* どの点も持たない。
|
|
3934
|
+
*
|
|
3935
|
+
* @param clientX - Pointer x in client coordinates / ポインターのクライアント座標 x
|
|
3936
|
+
* @param clientY - Pointer y in client coordinates / ポインターのクライアント座標 y
|
|
3937
|
+
* @returns Distance from the rail centre line, or null when the pointer is outside the area / トラック中心線からの距離 (領域の外なら null)
|
|
3938
|
+
*/
|
|
3939
|
+
const distanceToRailPx = (clientX: number, clientY: number): number | null => {
|
|
3940
|
+
const areaEl = rangeAreaRef.current
|
|
3941
|
+
const trackEl = trackRef.current
|
|
3942
|
+
const rootEl = rootRef.current
|
|
3943
|
+
if (disabled || areaEl === null || trackEl === null || rootEl === null) return null
|
|
3944
|
+
if (!ownsPaintedPoint(areaEl, rootEl, labelReachMainRef.current, isVertical, clientX, clientY)) return null
|
|
3945
|
+
const rail = trackEl.getBoundingClientRect()
|
|
3946
|
+
return Math.abs(isVertical ? clientX - (rail.left + rail.width / 2) : clientY - (rail.top + rail.height / 2))
|
|
3947
|
+
}
|
|
3948
|
+
|
|
3949
|
+
/**
|
|
3950
|
+
* Shifts the scale the pointer is over by one unit when the wheel is turned with Shift held anywhere over the range area.
|
|
3951
|
+
* 範囲領域のどこかで Shift 押下中のホイール操作が行われたとき、ポインターが載っているスケールを 1 単位だけ平行移動するハンドラ。
|
|
3952
|
+
*
|
|
3953
|
+
* The range area is the rectangle the stylesheet lays out (the lane around the rail plus every drawn label) together
|
|
3954
|
+
* with every part this slider draws; the pointer does not have to be over a knob or its label. The shared listener
|
|
3955
|
+
* has already decided that this slider owns the point, and that the gesture carries Shift and is still cancelable.
|
|
3956
|
+
* 範囲領域はスタイルシートが組み立てた矩形 (レール周りのレーンと描かれた全ラベル) と、このスライダーが描く全ての部品の和。
|
|
3957
|
+
* ポインターがつまみやラベルの真上にある必要はない。Shift の有無・取り消し可能かと、この点の持ち主が誰かは共有リスナーが決めている。
|
|
3958
|
+
*
|
|
3959
|
+
* In vernier mode the track carries two rails, so the wheel moves the scale under the pointer: the
|
|
3960
|
+
* macro window on the macro rail, the micro selection on the micro rail. Moving the micro selection
|
|
3961
|
+
* while the pointer sits on the macro rail would misreport what the pointer is on.
|
|
3962
|
+
* ノギスではトラックが 2 本のレールを載せるため、ポインターの下のスケールを動かす
|
|
3963
|
+
* (マクロレールならマクロ窓、ミクロレールならミクロ選択)。マクロレール上でミクロ選択が動くのは、
|
|
3964
|
+
* ポインターが何の上に居るかについての嘘になる。
|
|
3965
|
+
*
|
|
3966
|
+
* Over a stepper the wheel does what the stepper's click does (the micro selection), because the button stands
|
|
3967
|
+
* across the centre line and reading the side would move two scales from one highlighted control.
|
|
3968
|
+
* ステッパーの上ではクリックと同じもの (ミクロ選択) を動かす。ボタンは中心線を跨いで立つため、側で読むと
|
|
3969
|
+
* 強調表示された 1 つのボタンの上下で別のスケールが動く。
|
|
3970
|
+
*
|
|
3971
|
+
* @param event - Wheel event the shared listener handed to this slider / 共有リスナーがこのスライダーへ渡したホイールイベント
|
|
3972
|
+
* @returns Nothing / 戻り値なし
|
|
3973
|
+
*/
|
|
3974
|
+
const stepFromRangeAreaWheel = (event: WheelEvent): void => {
|
|
3975
|
+
// 掴んでいる間はポインターが値の持ち主。ここで取り消すと、ドラッグが押下時の控えから計算し直した対が
|
|
3976
|
+
// ホイールの 1 段を無言で取り消すうえ、ページのスクロールまで奪ったまま何も動かないことになる
|
|
3977
|
+
if (disabled || isGestureLive()) return
|
|
3978
|
+
const step = resolveWheelStep(event.deltaX, event.deltaY, isVertical)
|
|
3979
|
+
if (step === 0) return
|
|
3980
|
+
event.preventDefault()
|
|
3981
|
+
|
|
3982
|
+
const target = event.target
|
|
3983
|
+
const isOverStepper = containsEventTarget(decreaseStepperRef.current, target) || containsEventTarget(increaseStepperRef.current, target)
|
|
3984
|
+
if (!isVernierMode || isOverStepper) {
|
|
3985
|
+
shift(step)
|
|
3986
|
+
return
|
|
3987
|
+
}
|
|
3988
|
+
|
|
3989
|
+
const el = trackRef.current
|
|
3990
|
+
if (!el) return
|
|
3991
|
+
const rect = el.getBoundingClientRect()
|
|
3992
|
+
const pointerCrossAxisOffset = isVertical ? event.clientX - (rect.left + rect.width / 2) : event.clientY - (rect.top + rect.height / 2)
|
|
3993
|
+
if (resolveVernierRailZone(pointerCrossAxisOffset, vernierOrientation) === "macro") {
|
|
3994
|
+
shiftMacroWindow(step)
|
|
3995
|
+
return
|
|
3996
|
+
}
|
|
3997
|
+
shift(step)
|
|
3998
|
+
}
|
|
3999
|
+
|
|
4000
|
+
// ハンドラは毎レンダー作り直されるが、登録は 1 度だけ行う。ref 経由で最新を呼ぶことで、
|
|
4001
|
+
// 登録し直しによる取りこぼしも、閉じ込めた古い値も起こらない (ポインター移動と同じ手)
|
|
4002
|
+
const rangeAreaWheelRef = useRef({ ownsWheelHit, distanceToRailPx, stepFromRangeAreaWheel })
|
|
4003
|
+
|
|
4004
|
+
useLayoutEffect(() => {
|
|
4005
|
+
rangeAreaWheelRef.current = { ownsWheelHit, distanceToRailPx, stepFromRangeAreaWheel }
|
|
4006
|
+
})
|
|
4007
|
+
|
|
4008
|
+
useEffect(() => {
|
|
4009
|
+
// 事象を配送するのは、このスライダーが描かれている文書の window。別文書へポータルされたスライダーが
|
|
4010
|
+
// モジュールの window へ登録すると、操作は 1 度も届かない
|
|
4011
|
+
const view = rootRef.current?.ownerDocument.defaultView
|
|
4012
|
+
if (!view) return
|
|
4013
|
+
return registerRangeAreaWheelParticipant(view, {
|
|
4014
|
+
ownsHit: (target) => rangeAreaWheelRef.current.ownsWheelHit(target),
|
|
4015
|
+
distanceToRailPx: (clientX, clientY) => rangeAreaWheelRef.current.distanceToRailPx(clientX, clientY),
|
|
4016
|
+
step: (event) => rangeAreaWheelRef.current.stepFromRangeAreaWheel(event),
|
|
4017
|
+
})
|
|
4018
|
+
}, [])
|
|
4019
|
+
|
|
3025
4020
|
// ------------------------------------------------------------------
|
|
3026
4021
|
// I. 表示位置とスタイル計算
|
|
3027
4022
|
// ------------------------------------------------------------------
|
|
@@ -3031,42 +4026,14 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3031
4026
|
const lowDate = valueToDate(currentLowVal)
|
|
3032
4027
|
const highDate = valueToDate(currentHighVal)
|
|
3033
4028
|
|
|
3034
|
-
//
|
|
3035
|
-
//
|
|
3036
|
-
const
|
|
3037
|
-
|
|
3038
|
-
return buildPairSlantConfig(lowLabelBox, highLabelBox)
|
|
3039
|
-
}, [isPointMode, lowLabelBox, highLabelBox])
|
|
3040
|
-
|
|
3041
|
-
// 値が一致するとき 2 枚のラベルは文字列まで同一になる (valueToDate が純粋なので構造的に保証される)。
|
|
3042
|
-
// ピクセル距離では別日と区別できないため判定は必ず値で行う。
|
|
3043
|
-
// point モードは上限値を下限値へ寄せるため素の一致判定が恒真になり、!isPointMode で外さないと成立しない
|
|
3044
|
-
const isLabelMerged = !isPointMode && currentLowVal === currentHighVal
|
|
3045
|
-
|
|
3046
|
-
const slantResult: LabelSlantResult = useMemo(() => {
|
|
3047
|
-
// 縦向きは X 軸オフセットしか返さない幾何を適用できない。Point モードは避ける相手そのものが居ない
|
|
3048
|
-
if (isPointMode || !autoSlantLabels || isVertical) return buildHorizontalSlantResult(labelPosition, labelSlantConfig)
|
|
3049
|
-
|
|
3050
|
-
const solved = calculateLabelSlant(lowPct, highPct, trackLength, labelPosition, labelSlantConfig)
|
|
3051
|
-
if (!isLabelMerged) return solved
|
|
3052
|
-
|
|
3053
|
-
// 併合時に残る 1 枚は前面側であり、front は焦点・押下・交差のたび入れ替わる。押し退けを残すと
|
|
3054
|
-
// 唯一のラベルが ±shiftX の間を飛び、離す相手も居ない。角度と垂直オフセットは 90deg のラベルを
|
|
3055
|
-
// つまみから逃がすために必要なので保持し、接近から一致まで角度も位置も連続させる
|
|
3056
|
-
return withoutHorizontalPush(solved)
|
|
3057
|
-
}, [isPointMode, isLabelMerged, autoSlantLabels, isVertical, lowPct, highPct, trackLength, labelPosition, labelSlantConfig])
|
|
4029
|
+
// ラベルの配置は位置に対する純粋な幾何であり、掴んでいる間は毎コミット入力が変わるためメモ化しても必ず外れる。
|
|
4030
|
+
// React は style を値で比較するため、同値の新しいオブジェクトは DOM への書き込みを 1 つも生まない
|
|
4031
|
+
const flatPlacement = solveFlatPairPlacement(lowPct, highPct, flatPlacementInput)
|
|
4032
|
+
const slantResult: LabelSlantResult = flatPlacement.slant
|
|
3058
4033
|
|
|
3059
4034
|
const isLowFront = activeHandle === "low" || (activeHandle !== "high" && frontHandle === "low")
|
|
3060
4035
|
const isHighFront = !isPointMode && (activeHandle === "high" || (activeHandle !== "low" && frontHandle === "high"))
|
|
3061
4036
|
|
|
3062
|
-
// ノギスの 2 対も Range と同じ根拠で畳む。マクロ・ミクロとも符号化値から復元した日付を整形するため、
|
|
3063
|
-
// 符号化値が一致すればラベルは文字列まで一致する。しかもノギスには押し退けが無く 2 枚が同一矩形へ
|
|
3064
|
-
// 完全に重なるため、畳まないと同じ値が二重に読み上げられるだけで視覚的な情報も増えない
|
|
3065
|
-
const isVernierMacroLabelMerged = vernierMacroLowEnc === vernierMacroHighEnc
|
|
3066
|
-
// 時点形態のミクロラベルは 1 枚しか無い。畳み込み判定は恒真になるため、Point モードの !isPointMode と
|
|
3067
|
-
// 同じ理由で形態ごと外す (外さないと唯一のラベルが重複として隠れる)
|
|
3068
|
-
const isVernierMicroLabelMerged = !isMicroPointShape && vernierMicroLowEnc === vernierMicroHighEnc
|
|
3069
|
-
|
|
3070
4037
|
// 生存者は対の内側だけで決める。frontVernierHandle は 4 つのつまみで 1 本しか無く、相手の対や
|
|
3071
4038
|
// 連結バーを操作している間は対の両方が非 front になるため、「front でない方を隠す」では両方消える。
|
|
3072
4039
|
// 下限が front のときだけ下限を残し、それ以外は上限を残す (Range の初期前面と同じ上限優先) 全域規則
|
|
@@ -3075,81 +4042,38 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3075
4042
|
const isVernierMicroLowLabelDuplicate = isVernierMicroLabelMerged && frontVernierHandle !== "micro-low"
|
|
3076
4043
|
const isVernierMicroHighLabelDuplicate = isVernierMicroLabelMerged && frontVernierHandle === "micro-low"
|
|
3077
4044
|
|
|
3078
|
-
|
|
3079
|
-
const
|
|
3080
|
-
const microRailLabelPosition: PeriodSliderLabelPosition = isMacroFirstRail ? "bottom" : "top"
|
|
3081
|
-
|
|
3082
|
-
// マクロとミクロは同じトラックの上で比率も単位空間もラベル幅も異なる。1 つの計算を共有すると
|
|
3083
|
-
// 一方の押し退け量が他方の実寸で決まってしまうため、対ごとに独立して解く
|
|
3084
|
-
const macroLabelSlantConfig = useMemo(() => buildPairSlantConfig(macroLowLabelBox, macroHighLabelBox), [macroLowLabelBox, macroHighLabelBox])
|
|
3085
|
-
const microLabelSlantConfig = useMemo(() => buildPairSlantConfig(microLowLabelBox, microHighLabelBox), [microLowLabelBox, microHighLabelBox])
|
|
3086
|
-
|
|
3087
|
-
// 傾斜可否はレール単位で決まる。縦向きノギスは縦向き Range と同じ理由で外す (solveVernierPairPlacement 参照)
|
|
3088
|
-
const isVernierSlantable = autoSlantLabels && !isVertical
|
|
3089
|
-
|
|
3090
|
-
const macroPairPlacement = useMemo(
|
|
3091
|
-
() => solveVernierPairPlacement(macroLowRatio, macroHighRatio, trackLength, macroRailLabelPosition, macroLabelSlantConfig, isVernierMacroLabelMerged, isVernierSlantable),
|
|
3092
|
-
[macroLowRatio, macroHighRatio, trackLength, macroRailLabelPosition, macroLabelSlantConfig, isVernierMacroLabelMerged, isVernierSlantable],
|
|
3093
|
-
)
|
|
3094
|
-
|
|
3095
|
-
// 傾斜は接近した対を離すための機構であり、時点形態には離す相手が居ない。Point モードが
|
|
3096
|
-
// buildHorizontalSlantResult へ落ちるのと同じく、直立のまま置く
|
|
3097
|
-
const isMicroPairSlantable = isVernierSlantable && !isMicroPointShape
|
|
3098
|
-
|
|
3099
|
-
const microPairPlacement = useMemo(
|
|
3100
|
-
() => solveVernierPairPlacement(microLowRatio, microHighRatio, trackLength, microRailLabelPosition, microLabelSlantConfig, isVernierMicroLabelMerged, isMicroPairSlantable),
|
|
3101
|
-
[microLowRatio, microHighRatio, trackLength, microRailLabelPosition, microLabelSlantConfig, isVernierMicroLabelMerged, isMicroPairSlantable],
|
|
3102
|
-
)
|
|
3103
|
-
|
|
3104
|
-
const lowTooltipStyle: CSSProperties = useMemo(() => {
|
|
3105
|
-
if (isVertical) {
|
|
3106
|
-
return {
|
|
3107
|
-
"--ps-tooltip-origin": "100% 50%",
|
|
3108
|
-
"--ps-tooltip-tx": "0px",
|
|
3109
|
-
"--ps-tooltip-ty": "-50%",
|
|
3110
|
-
"--ps-tooltip-rot": "0deg",
|
|
3111
|
-
} as CSSProperties
|
|
3112
|
-
}
|
|
3113
|
-
|
|
3114
|
-
return {
|
|
3115
|
-
"--ps-tooltip-origin": "50% 50%",
|
|
3116
|
-
"--ps-tooltip-tx": `calc(-50% + ${slantResult.lowOffsetX}px)`,
|
|
3117
|
-
"--ps-tooltip-ty": `calc(-50% + ${slantResult.lowOffsetY}px)`,
|
|
3118
|
-
"--ps-tooltip-rot": `${slantResult.lowAngleDeg}deg`,
|
|
3119
|
-
} as CSSProperties
|
|
3120
|
-
}, [isVertical, slantResult.lowOffsetX, slantResult.lowOffsetY, slantResult.lowAngleDeg])
|
|
3121
|
-
|
|
3122
|
-
const highTooltipStyle: CSSProperties = useMemo(() => {
|
|
3123
|
-
if (isVertical) {
|
|
3124
|
-
return {
|
|
3125
|
-
"--ps-tooltip-origin": "100% 50%",
|
|
3126
|
-
"--ps-tooltip-tx": "0px",
|
|
3127
|
-
"--ps-tooltip-ty": "-50%",
|
|
3128
|
-
"--ps-tooltip-rot": "0deg",
|
|
3129
|
-
} as CSSProperties
|
|
3130
|
-
}
|
|
3131
|
-
|
|
3132
|
-
return {
|
|
3133
|
-
"--ps-tooltip-origin": "50% 50%",
|
|
3134
|
-
"--ps-tooltip-tx": `calc(-50% + ${slantResult.highOffsetX}px)`,
|
|
3135
|
-
"--ps-tooltip-ty": `calc(-50% + ${slantResult.highOffsetY}px)`,
|
|
3136
|
-
"--ps-tooltip-rot": `${slantResult.highAngleDeg}deg`,
|
|
3137
|
-
} as CSSProperties
|
|
3138
|
-
}, [isVertical, slantResult.highOffsetX, slantResult.highOffsetY, slantResult.highAngleDeg])
|
|
4045
|
+
const macroPairPlacement = solveVernierPairPlacement("macro", macroLowRatio, macroHighRatio, macroPairInput)
|
|
4046
|
+
const microPairPlacement = solveVernierPairPlacement("micro", microLowRatio, microHighRatio, microPairInput)
|
|
3139
4047
|
|
|
3140
4048
|
const minPct = Math.min(lowPct, highPct)
|
|
3141
4049
|
const maxPct = Math.max(lowPct, highPct)
|
|
4050
|
+
|
|
4051
|
+
// 位置は「いま指が居る場所」を読み、まだ誰も掴んでいない間は確定位置が既定値として描かれる。
|
|
4052
|
+
// 幅は 2 つの端の差として書くため、帯が収め戻される間も両端が別々の位置へ落ちることがない
|
|
4053
|
+
const [flatLowVariable, flatHighVariable] = DRAG_PRESENTATION_VARIABLES.flat
|
|
4054
|
+
const [macroLowVariable, macroHighVariable] = DRAG_PRESENTATION_VARIABLES.macro
|
|
4055
|
+
const [microLowVariable, microHighVariable] = DRAG_PRESENTATION_VARIABLES.micro
|
|
4056
|
+
const flatLowPosition = dragPresentationValue(flatLowVariable, lowPct)
|
|
4057
|
+
const flatHighPosition = dragPresentationValue(flatHighVariable, highPct)
|
|
4058
|
+
const flatBandStart = dragPresentationValue(flatLowVariable, minPct)
|
|
4059
|
+
const flatBandEnd = dragPresentationValue(flatHighVariable, maxPct)
|
|
4060
|
+
const flatBandSpan = `calc(${flatBandEnd} - ${flatBandStart})`
|
|
4061
|
+
const macroLowPosition = dragPresentationValue(macroLowVariable, macroLowRatio * 100)
|
|
4062
|
+
const macroHighPosition = dragPresentationValue(macroHighVariable, macroHighRatio * 100)
|
|
4063
|
+
const microLowPosition = dragPresentationValue(microLowVariable, microLowRatio * 100)
|
|
4064
|
+
const microHighPosition = dragPresentationValue(microHighVariable, microHighRatio * 100)
|
|
4065
|
+
|
|
3142
4066
|
const connectStyle: CSSProperties = isVertical
|
|
3143
4067
|
? {
|
|
3144
|
-
bottom:
|
|
3145
|
-
height:
|
|
4068
|
+
bottom: flatBandStart,
|
|
4069
|
+
height: flatBandSpan,
|
|
3146
4070
|
top: "auto",
|
|
3147
4071
|
left: "0",
|
|
3148
4072
|
right: "0",
|
|
3149
4073
|
}
|
|
3150
4074
|
: {
|
|
3151
|
-
left:
|
|
3152
|
-
width:
|
|
4075
|
+
left: flatBandStart,
|
|
4076
|
+
width: flatBandSpan,
|
|
3153
4077
|
top: "0",
|
|
3154
4078
|
bottom: "0",
|
|
3155
4079
|
}
|
|
@@ -3158,9 +4082,9 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3158
4082
|
const macroSpanRatio = Math.max(0.01, macroHighRatio - macroLowRatio)
|
|
3159
4083
|
const targetMicroOpacity = Math.max(0.06, Math.min(0.25, 0.28 * Math.sqrt(macroSpanRatio)))
|
|
3160
4084
|
|
|
3161
|
-
const lowHandleStyle: CSSProperties = isVertical ? { bottom:
|
|
4085
|
+
const lowHandleStyle: CSSProperties = isVertical ? { bottom: flatLowPosition, left: "50%", transform: "translate(-50%, 50%)", zIndex: isLowFront ? 40 : 30 } : { left: flatLowPosition, top: "50%", transform: "translate(-50%, -50%)", zIndex: isLowFront ? 40 : 30 }
|
|
3162
4086
|
|
|
3163
|
-
const highHandleStyle: CSSProperties = isVertical ? { bottom:
|
|
4087
|
+
const highHandleStyle: CSSProperties = isVertical ? { bottom: flatHighPosition, left: "50%", transform: "translate(-50%, 50%)", zIndex: isHighFront ? 40 : 30 } : { left: flatHighPosition, top: "50%", transform: "translate(-50%, -50%)", zIndex: isHighFront ? 40 : 30 }
|
|
3164
4088
|
|
|
3165
4089
|
const hoverGuideStyle: CSSProperties = isVertical ? { bottom: `${hoverPct}%`, left: "50%", transform: "translate(-50%, 50%)" } : { left: `${hoverPct}%`, top: "50%", transform: "translate(-50%, -50%)" }
|
|
3166
4090
|
|
|
@@ -3176,8 +4100,42 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3176
4100
|
const microStepFloorEnc = microIsDiscreteScale ? encode(microUnit, sortedMicroAllowedDates[0]) : vernierMicroMinEnc
|
|
3177
4101
|
const microStepCeilEnc = microIsDiscreteScale ? encode(microUnit, sortedMicroAllowedDates[sortedMicroAllowedDates.length - 1]) : vernierMicroMaxEnc
|
|
3178
4102
|
|
|
3179
|
-
|
|
3180
|
-
|
|
4103
|
+
// 押しても動かないステッパーを押せるように見せると、ホバーの強調が起こらない動作を約束する。幅を保つ平行移動は
|
|
4104
|
+
// 進む向きの縁が境界に着いた時点で動けない (Point は幅 0 の同じ規則)
|
|
4105
|
+
const canStepDecrease = isVernierMode ? vernierMicroLowEnc > microStepFloorEnc : currentLowVal > rangeMin
|
|
4106
|
+
const canStepIncrease = isVernierMode ? vernierMicroHighEnc < microStepCeilEnc : currentHighVal < rangeMax
|
|
4107
|
+
|
|
4108
|
+
// 範囲領域の厚みは、いま描かれているラベルの外縁で決まる。未実測のラベルは寸法を捏造せず層に数えない
|
|
4109
|
+
const labelReach = resolveLabelReach(
|
|
4110
|
+
isVernierMode
|
|
4111
|
+
? [
|
|
4112
|
+
{
|
|
4113
|
+
side: isMacroFirstRail ? "before" : "after",
|
|
4114
|
+
box: resolvePairBox(macroLowLabelBox, macroHighLabelBox),
|
|
4115
|
+
...(isVertical ? ({ reach: "inline-size" } as const) : ({ reach: "rotated", angleDeg: macroPairPlacement.slant.lowAngleDeg, centreOffsetPx: null, alongPushPx: macroPairPlacement.slant.lowOffsetX } as const)),
|
|
4116
|
+
},
|
|
4117
|
+
{
|
|
4118
|
+
side: isMacroFirstRail ? "after" : "before",
|
|
4119
|
+
box: isMicroPointShape ? microLowLabelBox : resolvePairBox(microLowLabelBox, microHighLabelBox),
|
|
4120
|
+
...(isVertical ? ({ reach: "inline-size" } as const) : ({ reach: "rotated", angleDeg: microPairPlacement.slant.lowAngleDeg, centreOffsetPx: null, alongPushPx: microPairPlacement.slant.lowOffsetX } as const)),
|
|
4121
|
+
},
|
|
4122
|
+
]
|
|
4123
|
+
: [
|
|
4124
|
+
{
|
|
4125
|
+
// 縦向きのラベルは labelPosition に関わらずスタイルシートが左へ置く
|
|
4126
|
+
side: isVertical || labelPosition === "top" ? "before" : "after",
|
|
4127
|
+
box: isPointMode ? lowLabelBox : resolvePairBox(lowLabelBox, highLabelBox),
|
|
4128
|
+
...(isVertical ? ({ reach: "inline-size" } as const) : ({ reach: "rotated", angleDeg: slantResult.lowAngleDeg, centreOffsetPx: slantResult.lowOffsetY, alongPushPx: slantResult.lowOffsetX } as const)),
|
|
4129
|
+
},
|
|
4130
|
+
],
|
|
4131
|
+
)
|
|
4132
|
+
const rootStyle = labelReach === undefined ? props.style : { ...props.style, ...labelReach.style }
|
|
4133
|
+
|
|
4134
|
+
// レール方向の到達距離はホイールの持ち主判定だけが読む。事象の時点で読み直すため、持ち替えはコミット後に行う。
|
|
4135
|
+
// ラベルが 1 枚も実測されていない間はレール方向へ伸びない (スタイルシートが交差軸で持つ既定と同じ 0)
|
|
4136
|
+
useLayoutEffect(() => {
|
|
4137
|
+
labelReachMainRef.current = labelReach === undefined ? 0 : labelReach.mainPx
|
|
4138
|
+
})
|
|
3181
4139
|
|
|
3182
4140
|
// ミクロレールの主つまみ。期間形態では下限つまみ、時点形態では唯一の時点つまみが同じ枠に立つ
|
|
3183
4141
|
const microPrimaryHandle: "micro-low" | "micro-point" = isMicroPointShape ? "micro-point" : "micro-low"
|
|
@@ -3191,36 +4149,51 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3191
4149
|
* Renders one stepper button identified by what it does to the value, never by where it sits.
|
|
3192
4150
|
* 配置ではなく値への作用で識別したステッパーボタン 1 つを描画する関数。
|
|
3193
4151
|
*
|
|
4152
|
+
* The arrow points along the rail (left / right, or down / up when vertical); the button takes its explicit cell
|
|
4153
|
+
* in the root grid (leading or trailing) and registers its element so the range-area wheel can tell a stepper
|
|
4154
|
+
* from the band it stands across. A disabled slider disables the button natively; a stepper whose step cannot move
|
|
4155
|
+
* stays focusable and only becomes unavailable.
|
|
4156
|
+
* 矢印はレールに沿って向き (横は左右、縦は下上)、ボタンはルートのグリッドの明示セル (先頭 / 末尾) に置かれ、
|
|
4157
|
+
* 範囲領域のホイールがステッパーと跨いでいる帯とを区別できるよう要素を登録する。スライダー全体の無効時はネイティブに無効化し、
|
|
4158
|
+
* 1 単位も動けないだけのステッパーはフォーカス可能なまま使用不可になる。
|
|
4159
|
+
*
|
|
3194
4160
|
* @param direction - "decrease" steps toward minDate, "increase" steps toward maxDate / "decrease" は minDate 方向、"increase" は maxDate 方向へ 1 単位
|
|
3195
4161
|
* @returns Stepper button element / ステッパーボタン要素
|
|
3196
4162
|
*/
|
|
3197
4163
|
const renderStepperButton = (direction: StepDirection): React.JSX.Element => {
|
|
3198
4164
|
const axis = isVertical ? "vertical" : "horizontal"
|
|
3199
4165
|
const isDecrease = direction === "decrease"
|
|
3200
|
-
|
|
4166
|
+
// 横向きは左端が下限なので減少が先頭、縦向きは上端が上限なので増加が先頭
|
|
4167
|
+
const isLeading = isVertical ? !isDecrease : isDecrease
|
|
3201
4168
|
|
|
3202
4169
|
return (
|
|
3203
|
-
<
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
disabled={
|
|
3208
|
-
|
|
3209
|
-
{
|
|
3210
|
-
|
|
4170
|
+
<StepperButton
|
|
4171
|
+
ref={isDecrease ? decreaseStepperRef : increaseStepperRef}
|
|
4172
|
+
neighbour="rail"
|
|
4173
|
+
direction={STEPPER_ARROWS[axis][direction]}
|
|
4174
|
+
disabled={disabled}
|
|
4175
|
+
canStep={isDecrease ? canStepDecrease : canStepIncrease}
|
|
4176
|
+
onStep={() => shift(isDecrease ? -1 : 1)}
|
|
4177
|
+
ariaLabel={isDecrease ? decreaseAriaLabel : increaseAriaLabel}
|
|
4178
|
+
className={`period-slider-stepper-btn ${STEPPER_POSITION_CLASSES[axis][direction]} ${ROOT_GRID_CELL_CLASSES[axis][isLeading ? "leading" : "trailing"]}`}
|
|
4179
|
+
/>
|
|
3211
4180
|
)
|
|
3212
4181
|
}
|
|
3213
4182
|
|
|
3214
4183
|
return (
|
|
3215
4184
|
<div
|
|
3216
|
-
|
|
3217
|
-
|
|
4185
|
+
ref={rootRef}
|
|
4186
|
+
style={rootStyle}
|
|
4187
|
+
className={`period-slider grid select-none place-items-center ${ROOT_GRID_CLASSES[isVertical ? "vertical" : "horizontal"][showStepper ? "withSteppers" : "railOnly"]} ${className}`}
|
|
3218
4188
|
data-disabled={disabled ? "true" : undefined}
|
|
3219
4189
|
data-unit={unit}
|
|
3220
4190
|
data-mode={props.mode}
|
|
3221
4191
|
data-orientation={isVertical ? "vertical" : "horizontal"}
|
|
3222
4192
|
data-label-position={labelPosition}
|
|
3223
4193
|
data-color-scheme={colorScheme}>
|
|
4194
|
+
{/* 範囲領域: Shift + ホイールの持ち主を幾何で決めるための矩形。描画もヒットテストも持たない (6.2) */}
|
|
4195
|
+
<div ref={rangeAreaRef} data-range-area="true" aria-hidden="true" className="period-slider-range-area" />
|
|
4196
|
+
|
|
3224
4197
|
{/* 先頭のステッパー: 横向きは左端が定義域の下限なので減少、縦向きは上端が上限なので増加 */}
|
|
3225
4198
|
{showStepper && renderStepperButton(isVertical ? "increase" : "decrease")}
|
|
3226
4199
|
|
|
@@ -3230,7 +4203,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3230
4203
|
data-testid="period-slider-track"
|
|
3231
4204
|
data-orientation={isVertical ? "vertical" : "horizontal"}
|
|
3232
4205
|
data-vernier-orientation={isVernierMode ? vernierOrientation : undefined}
|
|
3233
|
-
className={`period-slider-track relative
|
|
4206
|
+
className={`period-slider-track relative touch-none rounded-full ${ROOT_GRID_CELL_CLASSES[isVertical ? "vertical" : "horizontal"][showStepper ? "rail" : "railOnly"]} ${cursorClass}`}
|
|
3234
4207
|
onPointerDown={handleTrackPointerDown}
|
|
3235
4208
|
onPointerMove={handleTrackPointerMove}
|
|
3236
4209
|
onPointerLeave={handleTrackPointerLeave}>
|
|
@@ -3246,7 +4219,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3246
4219
|
<stop offset="100%" stopColor={isMacroFirstRail ? palette.micro : palette.macro} stopOpacity={targetMicroOpacity} />
|
|
3247
4220
|
</linearGradient>
|
|
3248
4221
|
</defs>
|
|
3249
|
-
<
|
|
4222
|
+
<path ref={projectionRef} data-testid="period-slider-vernier-projection" d={buildVernierProjectionPath(macroLowRatio, macroHighRatio, isVertical, isMacroFirstRail)} fill={`url(#${vernierGradId})`} />
|
|
3250
4223
|
</svg>
|
|
3251
4224
|
) : (
|
|
3252
4225
|
<svg className="period-slider-vernier-projection" role="presentation" aria-hidden="true" width="100%" height="32" viewBox="0 0 100 32" preserveAspectRatio="none">
|
|
@@ -3256,7 +4229,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3256
4229
|
<stop offset="100%" stopColor={isMacroFirstRail ? palette.micro : palette.macro} stopOpacity={targetMicroOpacity} />
|
|
3257
4230
|
</linearGradient>
|
|
3258
4231
|
</defs>
|
|
3259
|
-
<
|
|
4232
|
+
<path ref={projectionRef} data-testid="period-slider-vernier-projection" d={buildVernierProjectionPath(macroLowRatio, macroHighRatio, isVertical, isMacroFirstRail)} fill={`url(#${vernierGradId})`} />
|
|
3260
4233
|
</svg>
|
|
3261
4234
|
))}
|
|
3262
4235
|
|
|
@@ -3269,12 +4242,12 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3269
4242
|
style={
|
|
3270
4243
|
isVertical
|
|
3271
4244
|
? {
|
|
3272
|
-
bottom: `calc(${
|
|
3273
|
-
height: `calc(${
|
|
4245
|
+
bottom: `calc(${macroLowPosition} - 8px)`,
|
|
4246
|
+
height: `calc(${macroHighPosition} - ${macroLowPosition} + 16px)`,
|
|
3274
4247
|
}
|
|
3275
4248
|
: {
|
|
3276
|
-
left: `calc(${
|
|
3277
|
-
width: `calc(${
|
|
4249
|
+
left: `calc(${macroLowPosition} - 8px)`,
|
|
4250
|
+
width: `calc(${macroHighPosition} - ${macroLowPosition} + 16px)`,
|
|
3278
4251
|
}
|
|
3279
4252
|
}
|
|
3280
4253
|
onPointerDown={handleVernierKnobPointerDown("macro-connect")}
|
|
@@ -3287,12 +4260,12 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3287
4260
|
style={
|
|
3288
4261
|
isVertical
|
|
3289
4262
|
? {
|
|
3290
|
-
bottom: `calc(${
|
|
3291
|
-
height: `calc(${
|
|
4263
|
+
bottom: `calc(${microLowPosition} - 8px)`,
|
|
4264
|
+
height: `calc(${microHighPosition} - ${microLowPosition} + 16px)`,
|
|
3292
4265
|
}
|
|
3293
4266
|
: {
|
|
3294
|
-
left: `calc(${
|
|
3295
|
-
width: `calc(${
|
|
4267
|
+
left: `calc(${microLowPosition} - 8px)`,
|
|
4268
|
+
width: `calc(${microHighPosition} - ${microLowPosition} + 16px)`,
|
|
3296
4269
|
}
|
|
3297
4270
|
}
|
|
3298
4271
|
onPointerDown={handleVernierKnobPointerDown("micro-connect")}
|
|
@@ -3327,23 +4300,23 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3327
4300
|
className={`period-slider-handle period-slider-handle-vernier ${isVertical ? "is-vertical" : ""} group absolute touch-none ${
|
|
3328
4301
|
isVertical
|
|
3329
4302
|
? isMacroFirstRail
|
|
3330
|
-
? "after:absolute after
|
|
3331
|
-
: "after:absolute after
|
|
4303
|
+
? "after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4"
|
|
4304
|
+
: "after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0"
|
|
3332
4305
|
: isMacroFirstRail
|
|
3333
|
-
? "after:absolute after
|
|
3334
|
-
: "after:absolute after
|
|
3335
|
-
} after:content-[''] focus:outline-
|
|
4306
|
+
? "after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0"
|
|
4307
|
+
: "after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4"
|
|
4308
|
+
} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${cursorClass}`}
|
|
3336
4309
|
style={
|
|
3337
4310
|
isVertical
|
|
3338
4311
|
? {
|
|
3339
|
-
bottom:
|
|
4312
|
+
bottom: macroLowPosition,
|
|
3340
4313
|
left: isMacroFirstRail ? 0 : "auto",
|
|
3341
4314
|
right: isMacroFirstRail ? "auto" : 0,
|
|
3342
4315
|
transform: isMacroFirstRail ? "translate(-100%, 50%)" : "translate(100%, 50%)",
|
|
3343
4316
|
zIndex: activeVernierHandle === "macro-low" || frontVernierHandle === "macro-low" ? 30 : 15,
|
|
3344
4317
|
}
|
|
3345
4318
|
: {
|
|
3346
|
-
left:
|
|
4319
|
+
left: macroLowPosition,
|
|
3347
4320
|
top: isMacroFirstRail ? 0 : "auto",
|
|
3348
4321
|
bottom: isMacroFirstRail ? "auto" : 0,
|
|
3349
4322
|
transform: isMacroFirstRail ? "translate(-50%, -100%)" : "translate(-50%, 100%)",
|
|
@@ -3358,7 +4331,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3358
4331
|
data-vernier-pos={isVertical ? (isMacroFirstRail ? "left" : "right") : isMacroFirstRail ? "top" : "bottom"}
|
|
3359
4332
|
data-handle-type="macro-low">
|
|
3360
4333
|
<VernierKnobSvg type="macro" isTop={isMacroFirstRail} isVertical={isVertical} isLeft={isMacroFirstRail} />
|
|
3361
|
-
{showHairline && <div className="period-slider-hairline" />}
|
|
4334
|
+
{showHairline && <div data-testid="period-slider-hairline" className="period-slider-hairline" />}
|
|
3362
4335
|
{tooltipStyle !== "hover" && (
|
|
3363
4336
|
<div
|
|
3364
4337
|
className={`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${tooltipStyle === "balloon" ? "period-slider-tooltip-balloon" : ""}`}
|
|
@@ -3386,23 +4359,23 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3386
4359
|
className={`period-slider-handle period-slider-handle-vernier ${isVertical ? "is-vertical" : ""} group absolute touch-none ${
|
|
3387
4360
|
isVertical
|
|
3388
4361
|
? isMacroFirstRail
|
|
3389
|
-
? "after:absolute after
|
|
3390
|
-
: "after:absolute after
|
|
4362
|
+
? "after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4"
|
|
4363
|
+
: "after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0"
|
|
3391
4364
|
: isMacroFirstRail
|
|
3392
|
-
? "after:absolute after
|
|
3393
|
-
: "after:absolute after
|
|
3394
|
-
} after:content-[''] focus:outline-
|
|
4365
|
+
? "after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0"
|
|
4366
|
+
: "after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4"
|
|
4367
|
+
} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${cursorClass}`}
|
|
3395
4368
|
style={
|
|
3396
4369
|
isVertical
|
|
3397
4370
|
? {
|
|
3398
|
-
bottom:
|
|
4371
|
+
bottom: macroHighPosition,
|
|
3399
4372
|
left: isMacroFirstRail ? 0 : "auto",
|
|
3400
4373
|
right: isMacroFirstRail ? "auto" : 0,
|
|
3401
4374
|
transform: isMacroFirstRail ? "translate(-100%, 50%)" : "translate(100%, 50%)",
|
|
3402
4375
|
zIndex: activeVernierHandle === "macro-high" || frontVernierHandle === "macro-high" ? 30 : 15,
|
|
3403
4376
|
}
|
|
3404
4377
|
: {
|
|
3405
|
-
left:
|
|
4378
|
+
left: macroHighPosition,
|
|
3406
4379
|
top: isMacroFirstRail ? 0 : "auto",
|
|
3407
4380
|
bottom: isMacroFirstRail ? "auto" : 0,
|
|
3408
4381
|
transform: isMacroFirstRail ? "translate(-50%, -100%)" : "translate(-50%, 100%)",
|
|
@@ -3417,7 +4390,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3417
4390
|
data-vernier-pos={isVertical ? (isMacroFirstRail ? "left" : "right") : isMacroFirstRail ? "top" : "bottom"}
|
|
3418
4391
|
data-handle-type="macro-high">
|
|
3419
4392
|
<VernierKnobSvg type="macro" isTop={isMacroFirstRail} isVertical={isVertical} isLeft={isMacroFirstRail} />
|
|
3420
|
-
{showHairline && <div className="period-slider-hairline" />}
|
|
4393
|
+
{showHairline && <div data-testid="period-slider-hairline" className="period-slider-hairline" />}
|
|
3421
4394
|
{tooltipStyle !== "hover" && (
|
|
3422
4395
|
<div
|
|
3423
4396
|
className={`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${tooltipStyle === "balloon" ? "period-slider-tooltip-balloon" : ""}`}
|
|
@@ -3445,23 +4418,23 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3445
4418
|
className={`period-slider-handle period-slider-handle-vernier ${isVertical ? "is-vertical" : ""} group absolute touch-none ${
|
|
3446
4419
|
isVertical
|
|
3447
4420
|
? isMacroFirstRail
|
|
3448
|
-
? "after:absolute after
|
|
3449
|
-
: "after:absolute after
|
|
4421
|
+
? "after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0"
|
|
4422
|
+
: "after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4"
|
|
3450
4423
|
: isMacroFirstRail
|
|
3451
|
-
? "after:absolute after
|
|
3452
|
-
: "after:absolute after
|
|
3453
|
-
} after:content-[''] focus:outline-
|
|
4424
|
+
? "after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4"
|
|
4425
|
+
: "after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0"
|
|
4426
|
+
} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${cursorClass}`}
|
|
3454
4427
|
style={
|
|
3455
4428
|
isVertical
|
|
3456
4429
|
? {
|
|
3457
|
-
bottom:
|
|
4430
|
+
bottom: microLowPosition,
|
|
3458
4431
|
left: isMacroFirstRail ? "auto" : 0,
|
|
3459
4432
|
right: isMacroFirstRail ? 0 : "auto",
|
|
3460
4433
|
transform: isMacroFirstRail ? "translate(100%, 50%)" : "translate(-100%, 50%)",
|
|
3461
4434
|
zIndex: activeVernierHandle === microPrimaryHandle || frontVernierHandle === microPrimaryHandle ? 30 : 20,
|
|
3462
4435
|
}
|
|
3463
4436
|
: {
|
|
3464
|
-
left:
|
|
4437
|
+
left: microLowPosition,
|
|
3465
4438
|
top: isMacroFirstRail ? "auto" : 0,
|
|
3466
4439
|
bottom: isMacroFirstRail ? 0 : "auto",
|
|
3467
4440
|
transform: isMacroFirstRail ? "translate(-50%, 100%)" : "translate(-50%, -100%)",
|
|
@@ -3476,7 +4449,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3476
4449
|
data-vernier-pos={isVertical ? (isMacroFirstRail ? "right" : "left") : isMacroFirstRail ? "bottom" : "top"}
|
|
3477
4450
|
data-handle-type={microPrimaryHandle}>
|
|
3478
4451
|
<VernierKnobSvg type="micro" isTop={!isMacroFirstRail} isVertical={isVertical} isLeft={!isMacroFirstRail} />
|
|
3479
|
-
{showHairline && <div className="period-slider-hairline" />}
|
|
4452
|
+
{showHairline && <div data-testid="period-slider-hairline" className="period-slider-hairline" />}
|
|
3480
4453
|
{tooltipStyle !== "hover" && (
|
|
3481
4454
|
<div
|
|
3482
4455
|
className={`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${tooltipStyle === "balloon" ? "period-slider-tooltip-balloon" : ""}`}
|
|
@@ -3505,23 +4478,23 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3505
4478
|
className={`period-slider-handle period-slider-handle-vernier ${isVertical ? "is-vertical" : ""} group absolute touch-none ${
|
|
3506
4479
|
isVertical
|
|
3507
4480
|
? isMacroFirstRail
|
|
3508
|
-
? "after:absolute after
|
|
3509
|
-
: "after:absolute after
|
|
4481
|
+
? "after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0"
|
|
4482
|
+
: "after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4"
|
|
3510
4483
|
: isMacroFirstRail
|
|
3511
|
-
? "after:absolute after
|
|
3512
|
-
: "after:absolute after
|
|
3513
|
-
} after:content-[''] focus:outline-
|
|
4484
|
+
? "after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4"
|
|
4485
|
+
: "after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0"
|
|
4486
|
+
} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${cursorClass}`}
|
|
3514
4487
|
style={
|
|
3515
4488
|
isVertical
|
|
3516
4489
|
? {
|
|
3517
|
-
bottom:
|
|
4490
|
+
bottom: microHighPosition,
|
|
3518
4491
|
left: isMacroFirstRail ? "auto" : 0,
|
|
3519
4492
|
right: isMacroFirstRail ? 0 : "auto",
|
|
3520
4493
|
transform: isMacroFirstRail ? "translate(100%, 50%)" : "translate(-100%, 50%)",
|
|
3521
4494
|
zIndex: activeVernierHandle === "micro-high" || frontVernierHandle === "micro-high" ? 30 : 20,
|
|
3522
4495
|
}
|
|
3523
4496
|
: {
|
|
3524
|
-
left:
|
|
4497
|
+
left: microHighPosition,
|
|
3525
4498
|
top: isMacroFirstRail ? "auto" : 0,
|
|
3526
4499
|
bottom: isMacroFirstRail ? 0 : "auto",
|
|
3527
4500
|
transform: isMacroFirstRail ? "translate(-50%, 100%)" : "translate(-50%, -100%)",
|
|
@@ -3536,7 +4509,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3536
4509
|
data-vernier-pos={isVertical ? (isMacroFirstRail ? "right" : "left") : isMacroFirstRail ? "bottom" : "top"}
|
|
3537
4510
|
data-handle-type="micro-high">
|
|
3538
4511
|
<VernierKnobSvg type="micro" isTop={!isMacroFirstRail} isVertical={isVertical} isLeft={!isMacroFirstRail} />
|
|
3539
|
-
{showHairline && <div className="period-slider-hairline" />}
|
|
4512
|
+
{showHairline && <div data-testid="period-slider-hairline" className="period-slider-hairline" />}
|
|
3540
4513
|
{tooltipStyle !== "hover" && (
|
|
3541
4514
|
<div
|
|
3542
4515
|
className={`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${tooltipStyle === "balloon" ? "period-slider-tooltip-balloon" : ""}`}
|
|
@@ -3563,7 +4536,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3563
4536
|
const enc = encode(unit, d)
|
|
3564
4537
|
const pct = valueToPct(idx)
|
|
3565
4538
|
const tickStyle: CSSProperties = isVertical ? { bottom: `${pct}%`, left: "50%", transform: "translate(-50%, 50%)" } : { left: `${pct}%`, top: "50%", transform: "translate(-50%, -50%)" }
|
|
3566
|
-
return <div key={`tick-${enc}`} data-testid="period-slider-tick" className="period-slider-tick absolute h-1.5 w-1.5 rounded-full
|
|
4539
|
+
return <div key={`tick-${enc}`} data-testid="period-slider-tick" className="period-slider-tick absolute h-1.5 w-1.5 rounded-full" style={tickStyle} />
|
|
3567
4540
|
})}
|
|
3568
4541
|
</div>
|
|
3569
4542
|
)}
|
|
@@ -3592,7 +4565,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3592
4565
|
aria-valuenow={currentLowVal}
|
|
3593
4566
|
aria-valuetext={props.formatAriaValueText ? props.formatAriaValueText(lowDate, unit) : formatScreenReaderLabel(unit, lowDate, props.formatLabel, locale)}
|
|
3594
4567
|
aria-orientation={isVertical ? "vertical" : "horizontal"}
|
|
3595
|
-
className={`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[-
|
|
4568
|
+
className={`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[calc((100%-var(--ps-target-size))/2)] after:content-[''] focus-visible:outline-hidden ${cursorClass}`}
|
|
3596
4569
|
style={lowHandleStyle}
|
|
3597
4570
|
onPointerDown={handleKnobPointerDown("low")}
|
|
3598
4571
|
onKeyDown={handleKeyDown("low")}
|
|
@@ -3601,7 +4574,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3601
4574
|
data-front={isLowFront ? "true" : undefined}>
|
|
3602
4575
|
<div
|
|
3603
4576
|
data-testid="period-slider-knob"
|
|
3604
|
-
className={`period-slider-knob h-full w-full rounded-full border-2 border-white bg-[var(--aqps-accent-color)] group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-[var(--aqps-accent-light)] ${activeHandle === "low" ? "" : "shadow-md"}`}
|
|
4577
|
+
className={`period-slider-knob h-full w-full rounded-full border-2 border-white bg-[var(--aqps-accent-color)] group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-[var(--aqps-accent-light)] dark:group-focus-visible:ring-blue-400 ${activeHandle === "low" ? "" : "shadow-md"}`}
|
|
3605
4578
|
/>
|
|
3606
4579
|
{tooltipStyle !== "hover" && (
|
|
3607
4580
|
<div
|
|
@@ -3612,7 +4585,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3612
4585
|
data-front={isLowFront ? "true" : undefined}
|
|
3613
4586
|
data-duplicate={isLabelMerged && !isLowFront ? "true" : undefined}
|
|
3614
4587
|
ref={lowLabelRef}
|
|
3615
|
-
style={
|
|
4588
|
+
style={flatPlacement.lowStyle}>
|
|
3616
4589
|
{formatLabel(unit, lowDate, props.formatLabel, locale)}
|
|
3617
4590
|
</div>
|
|
3618
4591
|
)}
|
|
@@ -3630,7 +4603,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3630
4603
|
aria-valuenow={currentHighVal}
|
|
3631
4604
|
aria-valuetext={props.formatAriaValueText ? props.formatAriaValueText(highDate, unit) : formatScreenReaderLabel(unit, highDate, props.formatLabel, locale)}
|
|
3632
4605
|
aria-orientation={isVertical ? "vertical" : "horizontal"}
|
|
3633
|
-
className={`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[-
|
|
4606
|
+
className={`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[calc((100%-var(--ps-target-size))/2)] after:content-[''] focus-visible:outline-hidden ${cursorClass}`}
|
|
3634
4607
|
style={highHandleStyle}
|
|
3635
4608
|
onPointerDown={handleKnobPointerDown("high")}
|
|
3636
4609
|
onKeyDown={handleKeyDown("high")}
|
|
@@ -3639,7 +4612,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3639
4612
|
data-front={isHighFront ? "true" : undefined}>
|
|
3640
4613
|
<div
|
|
3641
4614
|
data-testid="period-slider-knob"
|
|
3642
|
-
className={`period-slider-knob h-full w-full rounded-full border-2 border-white bg-[var(--aqps-accent-color)] group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-[var(--aqps-accent-light)] ${activeHandle === "high" ? "" : "shadow-md"}`}
|
|
4615
|
+
className={`period-slider-knob h-full w-full rounded-full border-2 border-white bg-[var(--aqps-accent-color)] group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-[var(--aqps-accent-light)] dark:group-focus-visible:ring-blue-400 ${activeHandle === "high" ? "" : "shadow-md"}`}
|
|
3643
4616
|
/>
|
|
3644
4617
|
{tooltipStyle !== "hover" && (
|
|
3645
4618
|
<div
|
|
@@ -3650,7 +4623,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
|
|
|
3650
4623
|
data-front={isHighFront ? "true" : undefined}
|
|
3651
4624
|
data-duplicate={isLabelMerged && !isHighFront ? "true" : undefined}
|
|
3652
4625
|
ref={highLabelRef}
|
|
3653
|
-
style={
|
|
4626
|
+
style={flatPlacement.highStyle}>
|
|
3654
4627
|
{formatLabel(unit, highDate, props.formatLabel, locale)}
|
|
3655
4628
|
</div>
|
|
3656
4629
|
)}
|