@aiquants/period-slider 0.22.0 → 0.24.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.
@@ -284,6 +284,8 @@ export interface BasePeriodSliderProps {
284
284
  labelPosition?: PeriodSliderLabelPosition
285
285
  /** Whether to automatically slant labels when a pair comes close, in range mode and on both vernier rails (default: true) / Range モードとノギスの両レールで、対が接近した時に自動斜め表示するか (既定: true) */
286
286
  autoSlantLabels?: boolean
287
+ /** Stands the one label a pair holding the same value leaves upright on its knob, level with the upright labels of a pair that stands apart, instead of at the angle the approach ramped up to. Such a label reads neither the room nor `labelCeiling` / `labelFloor`, a pair holding two values slants as before, and the angle jumps where the pair merges or separates; a slider that does not slant is unaffected (default: false) / 同じ値に重なった対の残った 1 枚を、接近で上がった角度のまま立てず、離れた対の直立のラベルと同じ高さでつまみの中心に直立させるか。その 1 枚は余白も `labelCeiling` / `labelFloor` も読まず、違う値の対は今までどおり傾き、角度は畳む・離れる所で飛ぶ。傾けないスライダーには効かない (既定: false) */
288
+ keepMergedLabelUpright?: boolean
287
289
  /** Element whose bottom edge the slanted labels of a horizontal slider are never drawn above, besides the viewport and every ancestor that clips them; null or omitted names none, an element not in the document bounds nothing, and anything else (a ref object included) throws RangeError / 横向きのスライダーの傾けたラベルを、その下端より上へ描かない要素 (画面の端とラベルを切る祖先に加える。null・省略は無し、文書に無い要素は何も区切らず、それ以外 (ref オブジェクトを含む) は RangeError) */
288
290
  labelCeiling?: Element | null
289
291
  /** Element whose top edge the slanted labels of a horizontal slider are never drawn below, besides the viewport and every ancestor that clips them; null or omitted names none, an element not in the document bounds nothing, and anything else (a ref object included) throws RangeError / 横向きのスライダーの傾けたラベルを、その上端より下へ描かない要素 (画面の端とラベルを切る祖先に加える。null・省略は無し、文書に無い要素は何も区切らず、それ以外 (ref オブジェクトを含む) は RangeError) */
@@ -1747,14 +1749,6 @@ const DEFAULT_LABEL_PADDING_PX = 12
1747
1749
  /** Angle the labels reach when the two handles coincide, in degrees / 2 つのつまみが完全一致した時に到達する角度 (度) */
1748
1750
  const DEFAULT_MAX_SLANT_ANGLE_DEG = 90
1749
1751
 
1750
- /**
1751
- * Scale the stylesheet draws the label of a grabbed knob at (`--ps-tooltip-scale` under `[data-active="true"]`); the room
1752
- * check reads it so the pair still fits once one of its labels is grabbed, and a unit test pins it to the stylesheet.
1753
- * 掴んだつまみのラベルをスタイルシートが描く倍率 (`[data-active="true"]` の `--ps-tooltip-scale`)。
1754
- * 余白の判定がこれを読むため、対のどちらかを掴んでも収まったままになる。単体テストがスタイルシートとの一致を固定する。
1755
- */
1756
- export const LABEL_EMPHASIS_SCALE = 1.15
1757
-
1758
1752
  /**
1759
1753
  * Half extents of the bounding box of a rectangle rotated by an angle, along its unrotated width and across it.
1760
1754
  * 角度だけ回転した矩形の外接矩形の半寸法 (回転前の幅方向と、その直交方向)。
@@ -2000,6 +1994,48 @@ export const calculateLabelSlant = (lowPct: number, highPct: number, trackWidthP
2000
1994
  */
2001
1995
  const withoutHorizontalPush = (geometry: LabelSlantResult): LabelSlantResult => ({ ...geometry, lowOffsetX: 0, highOffsetX: 0 })
2002
1996
 
1997
+ /**
1998
+ * What the slant of one label pair depends on besides its two positions and its geometry.
1999
+ * 1 対のラベルの傾斜が、2 つの位置と幾何のほかに依存するもの。
2000
+ */
2001
+ interface PairSlantInput {
2002
+ /** Measured track length in pixels / 実測トラック長 (ピクセル) */
2003
+ trackLengthPx: number
2004
+ /** Side of the track the pair's labels stand on / 対のラベルが載るトラックの側 */
2005
+ labelPosition: PeriodSliderLabelPosition
2006
+ /** Whether the pair holds one value and therefore shows one label / 対が同一値で 1 枚だけ見えている状態か */
2007
+ isMerged: boolean
2008
+ /** Whether a merged pair's one label stands upright instead of at the ramp's angle / 畳んだ対の 1 枚を、ランプの角度でなく直立で立てるか */
2009
+ keepMergedLabelUpright: boolean
2010
+ }
2011
+
2012
+ /**
2013
+ * Solves the slant of one label pair for two positions, through what merging changes about it.
2014
+ * 1 対のラベルの傾斜を、畳むことで変わるものを通して 2 つの位置に対して解く関数。
2015
+ *
2016
+ * Every reader of a pair's slant goes through here, so a merged pair the host keeps upright is upright for all of them:
2017
+ * the pair's own placement, both tiers of it, and the other vernier rail, which stands a flipped pair beyond these labels.
2018
+ * Such a pair takes the upright baseline itself rather than a rotation of 0, so it stands where an upright pair stands and
2019
+ * leaves the room out of it, exactly as a pair standing apart does.
2020
+ * 対の傾斜を読む側はすべてここを通る。そのためホストが直立を求めた畳んだ対は、対自身の配置 (両層とも) にも、倒れた対をこのラベルの
2021
+ * 外へ積むもう一方のノギスのレールにも直立に見える。この対は角度 0 の回転ではなく直立の基準配置そのものを取るため、直立の対と同じ位置に
2022
+ * 立ち、離れた対と同じく余白に関わらない。
2023
+ *
2024
+ * @param lowPct - Lower label position along the track in percent / トラック上の下限ラベル位置 (百分率)
2025
+ * @param highPct - Upper label position along the track in percent / トラック上の上限ラベル位置 (百分率)
2026
+ * @param pair - Everything the slant depends on besides the two positions and the geometry / 2 つの位置と幾何のほかに傾斜が依存するもの一式
2027
+ * @param config - Geometry the pair is solved with / 対を解く幾何
2028
+ * @returns Geometry of the pair / 対の幾何
2029
+ */
2030
+ const solvePairSlant = (lowPct: number, highPct: number, pair: PairSlantInput, config: LabelSlantConfig | undefined): LabelSlantResult => {
2031
+ if (pair.isMerged && pair.keepMergedLabelUpright) return buildHorizontalSlantResult(pair.labelPosition, config)
2032
+ const solved = calculateLabelSlant(lowPct, highPct, pair.trackLengthPx, pair.labelPosition, config)
2033
+ // 併合時に残る 1 枚は前面側であり、front は焦点・押下・交差のたび入れ替わる。押し退けを残すと
2034
+ // 唯一のラベルが ±shiftX の間を飛び、離す相手も居ない。角度と垂直オフセットは 90deg のラベルを
2035
+ // つまみから逃がすために必要なので保持し、接近から一致まで角度も位置も連続させる
2036
+ return pair.isMerged ? withoutHorizontalPush(solved) : solved
2037
+ }
2038
+
2003
2039
  /**
2004
2040
  * How a macro window moved, which is what decides whether the micro selection keeps its length.
2005
2041
  * マクロ窓の動き方 (ミクロ選択が長さを保つかを決めるもの)。
@@ -3197,8 +3233,7 @@ const solveVernierPairPlacement = (rail: "macro" | "micro", lowRatio: number, hi
3197
3233
  // 直立のラベルの中心は、自分の側の基準線から高さの半分の所に居る
3198
3234
  if (!input.isSlantable) return { slant: baseline, lowStyle: undefined, highStyle: undefined, lowLeaderStyle: undefined, highLeaderStyle: undefined, centreFromAnchorPx: Math.abs(baseline.lowOffsetY) - resolveLabelClearancePx(config), placements: null }
3199
3235
 
3200
- const solved = calculateLabelSlant(lowRatio * 100, highRatio * 100, input.trackLengthPx, input.labelPosition, config)
3201
- const slant = input.isMerged ? withoutHorizontalPush(solved) : solved
3236
+ const slant = solvePairSlant(lowRatio * 100, highRatio * 100, input, config)
3202
3237
  const prefixes = DRAG_LABEL_VARIABLE_PREFIXES[rail]
3203
3238
  // 範囲領域が読むのは、ラベルが立つ側の基準線からの到達距離。反対側へ倒れた対は、もう一方のレールの基準線の側に立つ
3204
3239
  const anchorLinePx = fit !== null && slant.isFlipped ? fit.oppositeAnchorPx : resolveLabelClearancePx(config)
@@ -3246,7 +3281,6 @@ const resolveVernierRoomFit = (input: VernierPairPlacementInput): { config: Labe
3246
3281
  anchorGapY: input.anchor.anchorPx - KNOB_RADIUS_PX,
3247
3282
  flipClearancePx: input.opposite.anchorPx + input.opposite.reachPx + DEFAULT_LABEL_ANCHOR_GAP_Y_PX,
3248
3283
  room: input.room,
3249
- drawnScale: LABEL_EMPHASIS_SCALE,
3250
3284
  },
3251
3285
  oppositeAnchorPx: input.opposite.anchorPx,
3252
3286
  }
@@ -3256,15 +3290,9 @@ const resolveVernierRoomFit = (input: VernierPairPlacementInput): { config: Labe
3256
3290
  * Everything a vernier label pair's placement depends on besides the two positions it is solved for.
3257
3291
  * ノギスのラベルの対の配置が、解く対象の 2 つの位置以外に依存するもの一式。
3258
3292
  */
3259
- interface VernierPairPlacementInput {
3260
- /** Measured track length in pixels / 実測トラック長 (ピクセル) */
3261
- trackLengthPx: number
3262
- /** Side of the track this rail draws its labels on / このレールがラベルを描くトラックの側 */
3263
- labelPosition: PeriodSliderLabelPosition
3293
+ interface VernierPairPlacementInput extends PairSlantInput {
3264
3294
  /** Measured geometry of this pair, or undefined while unmeasured / この対の実測幾何 (未実測時は undefined) */
3265
3295
  config: LabelSlantConfig | undefined
3266
- /** Whether the pair holds one value and therefore shows one label / 対が同一値で 1 枚だけ見えている状態か */
3267
- isMerged: boolean
3268
3296
  /** Whether this rail may slant at all / このレールが傾斜してよいか */
3269
3297
  isSlantable: boolean
3270
3298
  /** Room around the rail the labels must stay within, or undefined while unmeasured / ラベルが収まるべきレールの周りの余白 (未実測時は undefined) */
@@ -3282,16 +3310,16 @@ interface VernierPairPlacementInput {
3282
3310
  interface VernierOppositeLabels {
3283
3311
  /** Distance from the rail centre line to the anchor line the other rail's labels stand on, in pixels / レール中心線から、もう一方のレールのラベルが立つ基準線までの距離 (ピクセル) */
3284
3312
  anchorPx: number
3285
- /** How far the other rail's labels reach beyond that line while emphasised, in pixels / もう一方のレールのラベルが、強調中にその線から先へ届く距離 (ピクセル) */
3313
+ /** How far the other rail's labels reach beyond that line, in pixels / もう一方のレールのラベルが、その線から先へ届く距離 (ピクセル) */
3286
3314
  reachPx: number
3287
3315
  }
3288
3316
 
3289
3317
  /**
3290
3318
  * Resolves the other vernier rail's labels as a pair that may stand across them sees them: where they start and how far
3291
- * they reach, standing on their own side, rotated as far as their anti-collision ramp asks and drawn at the emphasised
3292
- * scale - that is, before the room is read.
3319
+ * they reach, standing on their own side, rotated as far as their anti-collision ramp asks (upright when they are a merged
3320
+ * pair the host keeps upright) - that is, before the room is read.
3293
3321
  * 反対側へ立ちうる対から見た、もう一方のノギスのレールのラベル (どこから始まり、どこまで届くか) を解決する関数。
3294
- * ラベルは余白を読む前の姿 (自分の側に立ち、衝突回避のランプが求める角度まで回り、強調の倍率で描かれる) で取る。
3322
+ * ラベルは余白を読む前の姿 (自分の側に立ち、衝突回避のランプが求める角度まで回る。ホストが直立を求めた畳んだ対は直立) で取る。
3295
3323
  *
3296
3324
  * That is where they are whenever the pair may stand across them: the pair moves over only when it fits beyond those
3297
3325
  * labels, and the other rail's labels, needing less of the same room, then fit on their own side unmoved and at the full
@@ -3307,9 +3335,8 @@ interface VernierOppositeLabels {
3307
3335
  */
3308
3336
  const resolveVernierOppositeLabels = (lowRatio: number, highRatio: number, other: Omit<VernierPairPlacementInput, "opposite">, box: MeasuredBoxPx | null): VernierOppositeLabels | null => {
3309
3337
  if (other.anchor === null || box === null) return null
3310
- const angleDeg = other.isSlantable ? calculateLabelSlant(lowRatio * 100, highRatio * 100, other.trackLengthPx, other.labelPosition, other.config).lowAngleDeg : 0
3311
- // 強調中のラベルは中心を基準に拡大されるため、外縁は中心から倍率ぶん遠くなる (余白の判定と同じ形)
3312
- return { anchorPx: other.anchor.anchorPx, reachPx: (1 + LABEL_EMPHASIS_SCALE) * resolveRotatedHalfExtents(box.widthPx, box.heightPx, angleDeg).acrossPx }
3338
+ const angleDeg = other.isSlantable ? solvePairSlant(lowRatio * 100, highRatio * 100, other, other.config).lowAngleDeg : 0
3339
+ return { anchorPx: other.anchor.anchorPx, reachPx: 2 * resolveRotatedHalfExtents(box.widthPx, box.heightPx, angleDeg).acrossPx }
3313
3340
  }
3314
3341
 
3315
3342
  /**
@@ -3335,19 +3362,13 @@ interface FlatPairPlacement {
3335
3362
  * Everything the flat rail's label placement depends on besides the two positions it is solved for.
3336
3363
  * 平レールのラベル配置が、解く対象の 2 つの位置以外に依存するもの一式。
3337
3364
  */
3338
- interface FlatPairPlacementInput {
3365
+ interface FlatPairPlacementInput extends PairSlantInput {
3339
3366
  /** Whether one handle selects a single point / つまみ 1 つで時点を選ぶ形態か */
3340
3367
  isPointMode: boolean
3341
3368
  /** Whether the slider is drawn vertically / 縦向き描画か */
3342
3369
  isVertical: boolean
3343
3370
  /** Whether the host allows the anti-collision rotation / ホストが重なり回避の回転を許すか */
3344
3371
  autoSlantLabels: boolean
3345
- /** Whether the pair holds one value and therefore shows one label / 対が同一値で 1 枚だけ見えている状態か */
3346
- isMerged: boolean
3347
- /** Measured track length in pixels / 実測トラック長 (ピクセル) */
3348
- trackLengthPx: number
3349
- /** Side of the track the labels sit on / ラベルが載るトラックの側 */
3350
- labelPosition: PeriodSliderLabelPosition
3351
3372
  /** Measured geometry of the pair, or undefined while unmeasured / 対の実測幾何 (未実測時は undefined) */
3352
3373
  config: LabelSlantConfig | undefined
3353
3374
  /** Room around the rail the labels must stay within, or undefined while unmeasured / ラベルが収まるべきレールの周りの余白 (未実測時は undefined) */
@@ -3384,13 +3405,8 @@ const solveFlatPairPlacement = (lowPct: number, highPct: number, input: FlatPair
3384
3405
  const isSolvable = input.autoSlantLabels && !input.isPointMode
3385
3406
  let slant = baseline
3386
3407
  if (isSolvable) {
3387
- // 強調中の倍率も余白の判定へ渡す。等倍で判定すると、掴んだ瞬間に拡大したラベルだけが余白の外へはみ出す
3388
- const config = input.config === undefined || input.room === undefined ? input.config : { ...input.config, room: input.room, drawnScale: LABEL_EMPHASIS_SCALE }
3389
- const solved = calculateLabelSlant(lowPct, highPct, input.trackLengthPx, input.labelPosition, config)
3390
- // 併合時に残る 1 枚は前面側であり、front は焦点・押下・交差のたび入れ替わる。押し退けを残すと
3391
- // 唯一のラベルが ±shiftX の間を飛び、離す相手も居ない。角度と垂直オフセットは 90deg のラベルを
3392
- // つまみから逃がすために必要なので保持し、接近から一致まで角度も位置も連続させる
3393
- slant = input.isMerged ? withoutHorizontalPush(solved) : solved
3408
+ const config = input.config === undefined || input.room === undefined ? input.config : { ...input.config, room: input.room }
3409
+ slant = solvePairSlant(lowPct, highPct, input, config)
3394
3410
  }
3395
3411
 
3396
3412
  const prefixes = DRAG_LABEL_VARIABLE_PREFIXES.flat
@@ -3493,6 +3509,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
3493
3509
  tooltipStyle = "always",
3494
3510
  labelPosition = "top",
3495
3511
  autoSlantLabels = true,
3512
+ keepMergedLabelUpright = false,
3496
3513
  showLabelLeaderLines = false,
3497
3514
  isVertical = false,
3498
3515
  hideConnectBar = false,
@@ -4186,7 +4203,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
4186
4203
  // ラベルを離す距離が「描かれている距離」から外れることが構造的に起こらない。
4187
4204
  // マクロとミクロは同じトラックの上で比率も単位空間もラベル幅も異なるため、対ごとに独立して解く
4188
4205
  const labelRoom = labelSurroundings === null ? undefined : labelSurroundings.room
4189
- const flatPlacementInput: FlatPairPlacementInput = { isPointMode, isVertical, autoSlantLabels, isMerged: isLabelMerged, trackLengthPx: trackLength, labelPosition, config: labelSlantConfig, room: labelRoom }
4206
+ const flatPlacementInput: FlatPairPlacementInput = { isPointMode, isVertical, autoSlantLabels, isMerged: isLabelMerged, keepMergedLabelUpright, trackLengthPx: trackLength, labelPosition, config: labelSlantConfig, room: labelRoom }
4190
4207
  // 時点形態のミクロはラベルが 1 枚で、その 1 枚の箱がレールのラベルの箱になる。傾かない時点のラベルも、
4191
4208
  // 自分の側の基準線から実寸の高さの半分の所に中心を置くため、その箱から幾何を組む (既定の高さを捏造しない)
4192
4209
  const macroLabelBox = resolvePairBox(macroLowLabelBox, macroHighLabelBox)
@@ -4196,6 +4213,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
4196
4213
  labelPosition: macroRailLabelPosition,
4197
4214
  config: buildBoxSlantConfig(macroLabelBox),
4198
4215
  isMerged: isVernierMacroLabelMerged,
4216
+ keepMergedLabelUpright,
4199
4217
  isSlantable: isVernierSlantable,
4200
4218
  room: labelRoom,
4201
4219
  anchor: labelSurroundings === null ? null : labelSurroundings.macro,
@@ -4205,6 +4223,7 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
4205
4223
  labelPosition: microRailLabelPosition,
4206
4224
  config: buildBoxSlantConfig(microLabelBox),
4207
4225
  isMerged: isVernierMicroLabelMerged,
4226
+ keepMergedLabelUpright,
4208
4227
  isSlantable: isMicroPairSlantable,
4209
4228
  room: labelRoom,
4210
4229
  anchor: labelSurroundings === null ? null : labelSurroundings.micro,
@@ -4818,10 +4837,29 @@ const PeriodSliderComponent: React.FC<PeriodSliderProps> = (props) => {
4818
4837
  }
4819
4838
  }, [isDragging])
4820
4839
 
4840
+ /**
4841
+ * Starts a flat-rail drag of a knob or of the range body: captures the pointer, records where the drag starts and
4842
+ * makes the grabbed handle the active one. The hover guide's value is cleared, because the guide shows the value
4843
+ * under the pointer and the drag moves the pointer away from it: kept, it would come back at the position the drag
4844
+ * started from as soon as the drag ends (on pointerup, pointercancel, a lost capture or a mode switch alike), and it
4845
+ * returns at the pointer's position with the next move over the track.
4846
+ * 平レールのつまみか範囲の帯のドラッグを始める関数。ポインターを捕まえ、ドラッグの始まりを記録し、掴んだつまみを操作中にする。
4847
+ * ホバーガイドの値は消す。ガイドはポインターの下の値を示すもので、ドラッグはポインターをそこから離すため、残すとドラッグが
4848
+ * 終わった瞬間 (pointerup・pointercancel・捕捉の喪失・mode の切り替えのどれでも) にドラッグを始めた位置へ戻ってしまう。
4849
+ * ガイドはトラックの上の次のポインターの移動で、その位置に戻る。
4850
+ *
4851
+ * @param grabbed - Element that received the pointerdown / pointerdown を受けた要素
4852
+ * @param pointerId - Pointer that starts the drag / ドラッグを始めるポインター
4853
+ * @param handle - What is dragged: a knob or the range body / ドラッグするもの (つまみか範囲の帯)
4854
+ * @param startPointerPos - Pointer's client coordinate along the rail at the start (`clientX`, or `clientY` when vertical), in px / 始まりのレール方向のポインターのクライアント座標 (`clientX`。縦向きは `clientY`。px)
4855
+ * @returns Nothing / 戻り値なし
4856
+ */
4821
4857
  const startDrag = useCallback(
4822
4858
  (grabbed: Element, pointerId: number, handle: "low" | "high" | "connect", startPointerPos: number) => {
4823
4859
  cancelSnapBack()
4824
4860
  captureGesturePointer(grabbed, pointerId)
4861
+ setHoverValue(null)
4862
+ setHoverPct(null)
4825
4863
  // 掴んでいない間はスクロールを見張っていない。表示層が対を傾け始める前に、今の画面に対して余白を測り直す
4826
4864
  remeasureLabelSurroundings()
4827
4865
  dragContextRef.current = {
@@ -6262,6 +6300,7 @@ export const arePeriodSliderPropsEqual = (prev: PeriodSliderProps, next: PeriodS
6262
6300
  if (
6263
6301
  prev.labelPosition !== next.labelPosition ||
6264
6302
  prev.autoSlantLabels !== next.autoSlantLabels ||
6303
+ prev.keepMergedLabelUpright !== next.keepMergedLabelUpright ||
6265
6304
  // 境の要素は同一性で比べる。同じ要素の中身や位置の変化は Props ではなく測定が追う
6266
6305
  prev.labelCeiling !== next.labelCeiling ||
6267
6306
  prev.labelFloor !== next.labelFloor ||
@@ -24,6 +24,7 @@ import { assertCandidateListInput, describeValue, isValidDate } from "./inputVal
24
24
  import { areLabelOverridesEqual, type PeriodSliderLabelOverrides, type PeriodSliderLocale } from "./labels"
25
25
  import { assertLocaleTag, encodeInsideDateRange, formatLabel, isYearStartMonth, type PeriodOptionFormatter, resolveYearStartMonth, sentinelBoundRemedy, yearKeyOfCivil } from "./PeriodSlider"
26
26
  import { resolveStepGlyph, STEPPER_ROW_GAP_CLASS, type StepGlyph, StepperButton } from "./StepperButton"
27
+ import { YEAR_SELECTOR_FIELD_CLASSES } from "./selectorField"
27
28
  import { areSelectorDatePropsEqual, selectorUnitKey } from "./selectorMemo"
28
29
  import { assertSelectorStepper, type SelectorStepper } from "./selectorStep"
29
30
  import { useResolvedLabels } from "./useResolvedLabels"
@@ -442,7 +443,7 @@ const YearSelectorComponent = (props: YearSelectorProps): React.JSX.Element => {
442
443
  <select
443
444
  aria-label={resolvedLabels.yearSelect}
444
445
  disabled={disabled}
445
- className="w-18 appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500"
446
+ className={`${YEAR_SELECTOR_FIELD_CLASSES} appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500`}
446
447
  value={currentYear}
447
448
  onChange={(e) => {
448
449
  // 空値の change は選択解除であり、年として解釈しない
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @fileoverview Size contract every selector field shares (internal; nothing here is exported from the package entry).
3
+ * Every field of the three selectors, in every variant - the year `select`, the month `select` and native month
4
+ * input, the date combobox, the year / month / day `select`s and the native date input - carries
5
+ * `SELECTOR_FIELD_CLASS`, so the shipped stylesheet's one rule sizes all of them from the two published variables
6
+ * `--aqps-field-height` and `--aqps-field-font-size`. The fixed widths are multiples of that font size, so a larger font
7
+ * widens the field with it and the value keeps fitting; at the default font they are the widths the fields always had.
8
+ * 3 セレクタの全ての欄が共有する大きさの契約 (内部モジュール。パッケージの入口からは公開しない)。
9
+ * どの変種のどの欄 (年の `select`、年月の `select` とネイティブの年月の入力、日付のコンボボックス、年・月・日の `select`、
10
+ * ネイティブの日付の入力) も `SELECTOR_FIELD_CLASS` を持ち、配布スタイルシートの 1 つの規則が、公開の 2 変数
11
+ * `--aqps-field-height`・`--aqps-field-font-size` から全ての欄の大きさを決める。固定の幅は字の大きさの倍数のため、字を大きくすると
12
+ * 欄も一緒に広がって値が収まり続け、既定の字ではこれまでの幅と同じ。
13
+ */
14
+
15
+ /** Class hooking a field to the stylesheet's size rule (`.period-slider-selector-field`); a field carrying only this one keeps the width its content gives it / 欄を配布スタイルシートの大きさの規則へ繋ぐクラス (これだけを持つ欄は中身の幅のまま) */
16
+ export const SELECTOR_FIELD_CLASS = "period-slider-selector-field"
17
+
18
+ /** Classes of the year field: the size rule and a width of 6 times the font size, 72px at the default 12px font / 年の欄のクラス (大きさの規則と、字の大きさの 6 倍の幅。既定の字 12px で 72px) */
19
+ export const YEAR_SELECTOR_FIELD_CLASSES = `${SELECTOR_FIELD_CLASS} period-slider-selector-field-year`
20
+
21
+ /** Classes of the month and date fields: the size rule and a width of 28 / 3 times the font size, 112px at the default 12px font / 年月と日付の欄のクラス (大きさの規則と、字の大きさの 28 / 3 倍の幅。既定の字 12px で 112px) */
22
+ export const DATE_SELECTOR_FIELD_CLASSES = `${SELECTOR_FIELD_CLASS} period-slider-selector-field-date`
@@ -415,7 +415,6 @@
415
415
  --ps-tooltip-tx: -50%;
416
416
  --ps-tooltip-ty: -50%;
417
417
  --ps-tooltip-rot: 0deg;
418
- --ps-tooltip-scale: 1;
419
418
 
420
419
  position: absolute !important;
421
420
  top: 50% !important;
@@ -423,7 +422,7 @@
423
422
  bottom: auto !important;
424
423
  right: auto !important;
425
424
  transform-origin: var(--ps-tooltip-origin) !important;
426
- transform: translate(var(--ps-tooltip-tx), var(--ps-tooltip-ty)) rotate(var(--ps-tooltip-rot)) scale(var(--ps-tooltip-scale)) !important;
425
+ transform: translate(var(--ps-tooltip-tx), var(--ps-tooltip-ty)) rotate(var(--ps-tooltip-rot)) !important;
427
426
  white-space: nowrap !important;
428
427
  pointer-events: none !important;
429
428
  z-index: var(--aqps-z-label, 31) !important;
@@ -436,9 +435,9 @@
436
435
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
437
436
  }
438
437
 
439
- /* 掴んだ時 (data-active="true"): つまみの縮小に合わせて追従・拡大 */
438
+ /* 掴んだ時 (data-active="true"): ラベルは拡大せず、光の影で示す。
439
+ 拡大した箱は描かれた内容として祖先と文書のスクロールの範囲に数えられ、文書の端に接したラベルを掴むと文書が送れてしまう */
440
440
  .period-slider-handle[data-active="true"] .period-slider-tooltip {
441
- --ps-tooltip-scale: 1.15;
442
441
  box-shadow:
443
442
  0 0 12px #38bdf8,
444
443
  0 0 22px rgba(56, 189, 248, 0.75);
@@ -469,11 +468,6 @@
469
468
  bottom: auto !important;
470
469
  }
471
470
 
472
- .period-slider-track[data-orientation="vertical"] .period-slider-handle[data-active="true"] .period-slider-tooltip,
473
- .period-slider[data-orientation="vertical"] .period-slider-handle[data-active="true"] .period-slider-tooltip {
474
- --ps-tooltip-scale: 1.15;
475
- }
476
-
477
471
  .period-slider-handle[data-active="true"] .period-slider-tooltip::after {
478
472
  animation: period-slider-kirat 0.3s ease-out 0s forwards;
479
473
  }
@@ -996,7 +990,7 @@
996
990
  --ps-tooltip-tx: -50%;
997
991
  --ps-tooltip-ty: 0px;
998
992
  --ps-tooltip-rot: 0deg;
999
- transform: translate(var(--ps-tooltip-tx), var(--ps-tooltip-ty)) rotate(var(--ps-tooltip-rot)) scale(var(--ps-tooltip-scale)) !important;
993
+ transform: translate(var(--ps-tooltip-tx), var(--ps-tooltip-ty)) rotate(var(--ps-tooltip-rot)) !important;
1000
994
  }
1001
995
 
1002
996
  .period-slider-handle-vernier[data-vernier-pos="bottom"] .period-slider-tooltip {
@@ -1008,7 +1002,7 @@
1008
1002
  --ps-tooltip-tx: -50%;
1009
1003
  --ps-tooltip-ty: 0px;
1010
1004
  --ps-tooltip-rot: 0deg;
1011
- transform: translate(var(--ps-tooltip-tx), var(--ps-tooltip-ty)) rotate(var(--ps-tooltip-rot)) scale(var(--ps-tooltip-scale)) !important;
1005
+ transform: translate(var(--ps-tooltip-tx), var(--ps-tooltip-ty)) rotate(var(--ps-tooltip-rot)) !important;
1012
1006
  }
1013
1007
 
1014
1008
  /* 垂直ノギスにおけるツールチップ (左側 / 右側に既定 8px の数学的クリアランス、垂直中央揃えで相互衝突完全ゼロ) */
@@ -1021,7 +1015,7 @@
1021
1015
  --ps-tooltip-tx: 0px;
1022
1016
  --ps-tooltip-ty: -50%;
1023
1017
  --ps-tooltip-rot: 0deg;
1024
- transform: translate(var(--ps-tooltip-tx), var(--ps-tooltip-ty)) rotate(var(--ps-tooltip-rot)) scale(var(--ps-tooltip-scale)) !important;
1018
+ transform: translate(var(--ps-tooltip-tx), var(--ps-tooltip-ty)) rotate(var(--ps-tooltip-rot)) !important;
1025
1019
  }
1026
1020
 
1027
1021
  .period-slider-handle-vernier.is-vertical[data-vernier-pos="right"] .period-slider-tooltip {
@@ -1033,7 +1027,7 @@
1033
1027
  --ps-tooltip-tx: 0px;
1034
1028
  --ps-tooltip-ty: -50%;
1035
1029
  --ps-tooltip-rot: 0deg;
1036
- transform: translate(var(--ps-tooltip-tx), var(--ps-tooltip-ty)) rotate(var(--ps-tooltip-rot)) scale(var(--ps-tooltip-scale)) !important;
1030
+ transform: translate(var(--ps-tooltip-tx), var(--ps-tooltip-ty)) rotate(var(--ps-tooltip-rot)) !important;
1037
1031
  }
1038
1032
 
1039
1033
  /* Vernier ツールチップのカラーセマンティクス連動 (マクロ=青系、ミクロ=赤系) */
@@ -1077,6 +1071,33 @@
1077
1071
  will-change: transform;
1078
1072
  }
1079
1073
 
1074
+ /* ============================================================= */
1075
+ /* セレクタの欄の大きさ: 3 セレクタのどの変種の欄 (年・年月の select、日付のコンボボックス、 */
1076
+ /* 年・月・日の select、ネイティブの年月・日付の入力) も .period-slider-selector-field を持ち、 */
1077
+ /* この 1 つの規則が公開の --aqps-field-height と --aqps-field-font-size から大きさを決める。 */
1078
+ /* 既定は変数化する前の描画そのもの (高さは字と余白と枠で決まる auto、字は 0.75rem)。 */
1079
+ /* ============================================================= */
1080
+ .period-slider-selector-field {
1081
+ /* 高さを渡されたとき、枠と余白を含めた箱がその高さになるように (preflight の無いホストでも) */
1082
+ box-sizing: border-box;
1083
+ /* 変数から供給する 2 項目は、ホストのユーティリティ層に変数ごと奪われないよう !important (ラベルの見た目と同じ理由) */
1084
+ height: var(--aqps-field-height, auto) !important;
1085
+ font-size: var(--aqps-field-font-size, 0.75rem) !important;
1086
+ /* 行送りは字の大きさの 4/3 倍。字の大きさに整数を掛けてから割るため、既定の 0.75rem でちょうど 16px になる
1087
+ (calc(1 / 0.75) は掛ける前に割り切れない小数へ畳まれ、1/64px 低い 15.984px になる) */
1088
+ line-height: calc(var(--aqps-field-font-size, 0.75rem) * 4 / 3);
1089
+ }
1090
+
1091
+ /* 固定の幅も字の大きさの倍数で持ち、字を大きくしても値が収まり続ける。年は 6 倍 (既定で 72px)、
1092
+ 年月と日付は 28/3 倍 (既定で 112px)。em で書くと 28/3 が掛ける前に小数へ畳まれ、既定の幅が 1/64px 狭くなる */
1093
+ .period-slider-selector-field-year {
1094
+ width: calc(var(--aqps-field-font-size, 0.75rem) * 6);
1095
+ }
1096
+
1097
+ .period-slider-selector-field-date {
1098
+ width: calc(var(--aqps-field-font-size, 0.75rem) * 28 / 3);
1099
+ }
1100
+
1080
1101
  /* ============================================================= */
1081
1102
  /* ネイティブ日付入力 (type="date" / type="month") の字送り */
1082
1103
  /* 隣り合うドロップダウン形態と同じ位置に数字が来るようにする。 */