@aiquants/period-slider 0.20.1 → 0.22.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiquants/period-slider",
3
- "version": "0.20.1",
3
+ "version": "0.22.0",
4
4
  "description": "Customizable period slider and year/month/date selectors for React",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -32,7 +32,7 @@
32
32
  "LICENSE"
33
33
  ],
34
34
  "peerDependencies": {
35
- "@aiquants/virtualscroll": "^3.8.0",
35
+ "@aiquants/virtualscroll": "^3.22.1",
36
36
  "react": "^19.2.7",
37
37
  "react-dom": "^19.2.7"
38
38
  },
@@ -40,8 +40,8 @@
40
40
  "date-fns": "^4.1.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@aiquants/virtualscroll": "^3.8.0",
44
- "@playwright/test": "^1.59.1",
43
+ "@aiquants/virtualscroll": "^3.23.0",
44
+ "@playwright/test": "^1.64.1",
45
45
  "@tailwindcss/cli": "^4.1.18",
46
46
  "@tailwindcss/vite": "^4.1.18",
47
47
  "@testing-library/jest-dom": "^6.9.1",
@@ -81,7 +81,9 @@
81
81
  },
82
82
  "main": "./dist/index.cjs",
83
83
  "scripts": {
84
- "build": "vite build && pnpm build:types-cjs && pnpm build:css",
84
+ "build": "pnpm -w run workspace:build \"$PNPM_SCRIPT_SRC_DIR\"",
85
+ "prebuild:self": "pnpm -w run workspace:sync \"$PNPM_SCRIPT_SRC_DIR\"",
86
+ "build:self": "vite build && pnpm build:types-cjs && pnpm build:css",
85
87
  "build:css": "tailwindcss -i src/styles/components.entry.css -o dist/styles/period-slider.css --minify && tailwindcss -i src/styles/standalone.entry.css -o dist/styles/period-slider.standalone.css --minify",
86
88
  "dev": "pnpm run build:css && vite build --watch --no-emptyOutDir",
87
89
  "watch": "pnpm run dev",
@@ -100,9 +102,9 @@
100
102
  "format": "biome format --write src tests demo/src",
101
103
  "format:check": "biome format src tests demo/src",
102
104
  "clean": "rimraf dist",
103
- "publish:patch": "pnpm run typecheck && pnpm run build && pnpm run --if-present test && node ../../.config/scripts/check-publish-leaks.mjs && pnpm version patch --no-git-tag-version --no-git-checks && pnpm publish --no-git-checks",
104
- "publish:minor": "pnpm run typecheck && pnpm run build && pnpm run --if-present test && node ../../.config/scripts/check-publish-leaks.mjs && pnpm version minor --no-git-tag-version --no-git-checks && pnpm publish --no-git-checks",
105
- "publish:major": "pnpm run typecheck && pnpm run build && pnpm run --if-present test && node ../../.config/scripts/check-publish-leaks.mjs && pnpm version major --no-git-tag-version --no-git-checks && pnpm publish --no-git-checks",
105
+ "publish:patch": "pnpm run typecheck && pnpm run build && pnpm run --if-present test && node ../../.config/scripts/check-publish-leaks.mjs && node ../../.config/scripts/check-peer-floors.mjs --bump patch && pnpm version patch --no-git-tag-version --no-git-checks && pnpm publish --no-git-checks",
106
+ "publish:minor": "pnpm run typecheck && pnpm run build && pnpm run --if-present test && node ../../.config/scripts/check-publish-leaks.mjs && node ../../.config/scripts/check-peer-floors.mjs --bump minor && pnpm version minor --no-git-tag-version --no-git-checks && pnpm publish --no-git-checks",
107
+ "publish:major": "pnpm run typecheck && pnpm run build && pnpm run --if-present test && node ../../.config/scripts/check-publish-leaks.mjs && node ../../.config/scripts/check-peer-floors.mjs --bump major && pnpm version major --no-git-tag-version --no-git-checks && pnpm publish --no-git-checks",
106
108
  "build:types-cjs": "node -e \"require('fs').copyFileSync('dist/index.d.ts','dist/index.d.cts')\""
107
109
  }
108
110
  }
@@ -49,7 +49,7 @@ import { assertCandidateListInput, dateMemoKey, describeValue, isValidDate } fro
49
49
  import { areLabelOverridesEqual, type PeriodSliderLabelOverrides, type PeriodSliderLocale } from "./labels"
50
50
  import { formatOptionText } from "./optionText"
51
51
  import { assertLocaleTag, encodeInsideDateRange, formatLabel, keyInsideDateRange, type PeriodOptionFormatter, type PeriodSliderUnit, sentinelBoundRemedy } from "./PeriodSlider"
52
- import { STEPPER_ROW_GAP_CLASS, StepperButton } from "./StepperButton"
52
+ import { resolveStepGlyph, STEPPER_ROW_GAP_CLASS, type StepGlyph, StepperButton } from "./StepperButton"
53
53
  import { areSelectorDatePropsEqual, selectorUnitKey } from "./selectorMemo"
54
54
  import { assertSelectorStepper, type SelectorStepper } from "./selectorStep"
55
55
  import { useResolvedLabels } from "./useResolvedLabels"
@@ -82,6 +82,16 @@ export interface DateSelectorProps {
82
82
  * セレクタは自分の値を動かさなくなるため、制御の `value` を要求する。
83
83
  */
84
84
  stepper?: SelectorStepper | undefined
85
+ /**
86
+ * How the ◀▶ draw their arrow (default "single"): "single" is one triangle, for a step of one unit; "double" is two triangles
87
+ * in a row, for a larger step such as a window or a whole period that a `stepper` owner takes. The box, the target, the hover,
88
+ * the focus ring and the unavailable look are the same for both, the arrow stays `aria-hidden`, and the accessible names still
89
+ * come from `labels`, so the glyph and the names are chosen independently. Anything else, `null` and `""` included, throws RangeError.
90
+ * ◀▶ の矢印の描き方 (既定 "single")。"single" は三角形 1 つで 1 単位の送り、"double" は三角形 2 つを並べたもので、`stepper` の所有者が
91
+ * 引き受ける窓や期間ごとの大きな送り。箱・当たり判定・ホバー・フォーカスリング・使用不可の見た目はどちらも同じで、矢印は `aria-hidden` のまま、
92
+ * アクセシブル名は引き続き `labels` から決まるため、字形と名前は別々に選べる。それ以外の値 (`null`・`""` を含む) は RangeError。
93
+ */
94
+ stepGlyph?: StepGlyph
85
95
  /** Child elements / 子要素 */
86
96
  children?: React.ReactNode
87
97
  /** Minimum selectable year; intersected with minDate when both are given / 選択可能範囲の最小年 (minDate 併用時は厳しい方を採用) */
@@ -110,7 +120,7 @@ export interface DateSelectorProps {
110
120
  disabled?: boolean
111
121
  /** UI chrome language of the accessible names and of the dropdown's scroll chrome ("en" | "ja", default "en"); anything else throws RangeError / アクセシブル名とドロップダウンのスクロールクロームの UI クローム言語 ("en" | "ja"、既定 "en"。それ以外は RangeError) */
112
122
  locale?: PeriodSliderLocale
113
- /** Per-key overrides over the `locale` catalog; this component reads `previousDay`, `nextDay`, `dateSelect`, `splitYear`, `splitMonth`, `splitDay` and, in variant="dropdown", the 7 engine keys / `locale` カタログへのキー単位の上書き (本コンポーネントが読むのは `previousDay`・`nextDay`・`dateSelect`・`splitYear`・`splitMonth`・`splitDay`、variant="dropdown" ではエンジン 7 キーも) */
123
+ /** Per-key overrides over the `locale` catalog; this component reads `previousDay`, `nextDay`, `dateSelect`, `splitYear`, `splitMonth`, `splitDay` and, in variant="dropdown", the engine keys (`VIRTUAL_SCROLL_LABEL_KEYS`) / `locale` カタログへのキー単位の上書き (本コンポーネントが読むのは `previousDay`・`nextDay`・`dateSelect`・`splitYear`・`splitMonth`・`splitDay`、variant="dropdown" ではエンジンキー全件も) */
114
124
  labels?: PeriodSliderLabelOverrides
115
125
  /** BCP 47 language tag switching option text to Intl formatting; omitted keeps locale-independent ISO 8601, and the input value stays yyyy-MM-dd either way / 選択肢テキストを Intl 書式にする BCP 47 言語タグ (未指定時はロケール非依存の ISO 8601 表記・input の value は常に yyyy-MM-dd) */
116
126
  formatLocale?: string
@@ -371,7 +381,7 @@ const listPartOptions = (first: number, last: number, anchorOf: (value: number)
371
381
  * outside the selectable set is disabled, and so is a `variant="split-dropdown"` year or month
372
382
  * whose combination with the other two parts would be discarded. With `stepper`, the owner takes the
373
383
  * ◀▶ over: a press goes to `stepper.onStep` and the owner's `canStepPrevious` / `canStepNext` decide
374
- * which arrows are available. Under `variant="split-dropdown"`, which also draws the year and the month of the held and bound
384
+ * which arrows are available, and `stepGlyph` draws them as one triangle or two. Under `variant="split-dropdown"`, which also draws the year and the month of the held and bound
375
385
  * dates, a Date prop in a year whose January 1 lies outside the Date range throws a RangeError naming the prop, an uncontrolled
376
386
  * selection held from an earlier render in such a year throws one naming `variant="split-dropdown"`, the month and day lists end
377
387
  * at the Date range edge, and the day list offers only the days the local calendar has (a day the time zone skipped is no option).
@@ -382,13 +392,13 @@ const listPartOptions = (first: number, last: number, anchorOf: (value: number)
382
392
  * emit できない年・月・日を選択不可の選択肢として提示。
383
393
  * `value` / `initialDate` の欠落・不正値、バリアントが要求する境界の欠落・矛盾、`allowedDates` との組合せ違反、
384
394
  * `variant="split-dropdown"` での 1 月 1 日が表現範囲外の年の Date Props と、以前の描画から保持している非制御の選択がその年にある描画、
385
- * 不正な `locale` / `labels` / `formatLocale` はいずれも RangeError で即時失敗。`variant="split-dropdown"` の月と日の一覧は表現範囲の端で終わり、
395
+ * 不正な `locale` / `labels` / `formatLocale` / `stepGlyph` はいずれも RangeError で即時失敗。`variant="split-dropdown"` の月と日の一覧は表現範囲の端で終わり、
386
396
  * 日の一覧はローカルの暦に実在する日だけを提示 (タイムゾーンが飛ばした日は選択肢にならない)。
387
397
  * `stepper` を渡すと ◀▶ は所有者が引き受け (押下は `stepper.onStep` へ、押せる矢印は所有者の `canStepPrevious` / `canStepNext` が決める)、
388
- * 不整合な `stepper` と非制御での `stepper` は RangeError。
398
+ * 不整合な `stepper` と非制御での `stepper` は RangeError。`stepGlyph` は ◀▶ を三角形 1 つか 2 つで描き分け、それ以外は字形に依らない。
389
399
  */
390
400
  const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
391
- const { value, initialDate, onChange, stepper, children, minYear, maxYear, minDate, maxDate, allowedDates, variant = "date", className = "", style, disabled = false, locale, labels, formatLocale, formatOption } = props
401
+ const { value, initialDate, onChange, stepper, stepGlyph, children, minYear, maxYear, minDate, maxDate, allowedDates, variant = "date", className = "", style, disabled = false, locale, labels, formatLocale, formatOption } = props
392
402
 
393
403
  if (formatLocale !== undefined) assertLocaleTag("DateSelector", "formatLocale", formatLocale)
394
404
  // 分割セレクトは境界の双方を要し allowedDates も拒む。境界を省く・許可日で宣言するという直し方は、従うと別の RangeError になる
@@ -429,6 +439,7 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
429
439
  throw new RangeError("DateSelector: either value (controlled) or initialDate (uncontrolled) is required; the selected date is never inferred from the wall clock")
430
440
  }
431
441
  if (stepper !== undefined) assertSelectorStepper("DateSelector", stepper, value !== undefined)
442
+ const glyph = resolveStepGlyph("DateSelector", stepGlyph)
432
443
 
433
444
  // ラベル解決は最初のフック。日付 Props の検証を全て済ませてから呼び、両方が不正なら日付側を先に報告する
434
445
  const resolvedLabels = useResolvedLabels(locale, labels)
@@ -655,7 +666,7 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
655
666
 
656
667
  return (
657
668
  <div className={`inline-flex items-center ${STEPPER_ROW_GAP_CLASS} ${className}`} style={style} data-variant={variant} data-out-of-range={isActiveSelectable ? undefined : "true"}>
658
- <StepperButton neighbour="control" direction="left" disabled={disabled} canStep={stepper === undefined ? prevDate !== null : stepper.canStepPrevious} onStep={handlePrevious} ariaLabel={resolvedLabels.previousDay} />
669
+ <StepperButton neighbour="control" direction="left" glyph={glyph} disabled={disabled} canStep={stepper === undefined ? prevDate !== null : stepper.canStepPrevious} onStep={handlePrevious} ariaLabel={resolvedLabels.previousDay} />
659
670
 
660
671
  {variant === "dropdown" ? (
661
672
  <VirtualDateDropdown
@@ -738,7 +749,7 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
738
749
  />
739
750
  )}
740
751
 
741
- <StepperButton neighbour="control" direction="right" disabled={disabled} canStep={stepper === undefined ? nextDate !== null : stepper.canStepNext} onStep={handleNext} ariaLabel={resolvedLabels.nextDay} />
752
+ <StepperButton neighbour="control" direction="right" glyph={glyph} disabled={disabled} canStep={stepper === undefined ? nextDate !== null : stepper.canStepNext} onStep={handleNext} ariaLabel={resolvedLabels.nextDay} />
742
753
  {children}
743
754
  </div>
744
755
  )
@@ -781,6 +792,7 @@ export const areDateSelectorPropsEqual = (prev: DateSelectorProps, next: DateSel
781
792
  if (prev.stepper?.onStep !== next.stepper?.onStep) return false
782
793
  if (prev.stepper?.canStepPrevious !== next.stepper?.canStepPrevious) return false
783
794
  if (prev.stepper?.canStepNext !== next.stepper?.canStepNext) return false
795
+ if (prev.stepGlyph !== next.stepGlyph) return false
784
796
  if (prev.allowedDates !== next.allowedDates) return false
785
797
  if (prev.children !== next.children) return false
786
798
  if (prev.locale !== next.locale) return false
@@ -26,7 +26,7 @@ import { memo, useMemo } from "react"
26
26
  import { assertCandidateListInput, describeValue, isValidDate } from "./inputValue"
27
27
  import { areLabelOverridesEqual, type PeriodSliderLabelOverrides, type PeriodSliderLocale } from "./labels"
28
28
  import { assertLocaleTag, decode, encodeInsideDateRange, formatIsoYear, formatLabel, keyInsideDateRange, type PeriodOptionFormatter, sentinelBoundRemedy } from "./PeriodSlider"
29
- import { STEPPER_ROW_GAP_CLASS, StepperButton } from "./StepperButton"
29
+ import { resolveStepGlyph, STEPPER_ROW_GAP_CLASS, type StepGlyph, StepperButton } from "./StepperButton"
30
30
  import { areSelectorDatePropsEqual, selectorUnitKey } from "./selectorMemo"
31
31
  import { assertSelectorStepper, type SelectorStepper } from "./selectorStep"
32
32
  import { useResolvedLabels } from "./useResolvedLabels"
@@ -58,6 +58,16 @@ export interface MonthSelectorProps {
58
58
  * セレクタは自分の値を動かさなくなるため、制御の `value` を要求する。
59
59
  */
60
60
  stepper?: SelectorStepper | undefined
61
+ /**
62
+ * How the ◀▶ draw their arrow (default "single"): "single" is one triangle, for a step of one unit; "double" is two triangles
63
+ * in a row, for a larger step such as a window or a whole period that a `stepper` owner takes. The box, the target, the hover,
64
+ * the focus ring and the unavailable look are the same for both, the arrow stays `aria-hidden`, and the accessible names still
65
+ * come from `labels`, so the glyph and the names are chosen independently. Anything else, `null` and `""` included, throws RangeError.
66
+ * ◀▶ の矢印の描き方 (既定 "single")。"single" は三角形 1 つで 1 単位の送り、"double" は三角形 2 つを並べたもので、`stepper` の所有者が
67
+ * 引き受ける窓や期間ごとの大きな送り。箱・当たり判定・ホバー・フォーカスリング・使用不可の見た目はどちらも同じで、矢印は `aria-hidden` のまま、
68
+ * アクセシブル名は引き続き `labels` から決まるため、字形と名前は別々に選べる。それ以外の値 (`null`・`""` を含む) は RangeError。
69
+ */
70
+ stepGlyph?: StepGlyph
61
71
  /** Child elements / 子要素 */
62
72
  children?: React.ReactNode
63
73
  /**
@@ -364,19 +374,21 @@ function toDescendingOptions(monthsAscending: Date[], formatLocale: string | und
364
374
  * emittable: a stepper whose target month is outside the selectable set is disabled, and a held
365
375
  * month outside the set is rendered as it stands instead of being clamped or rejected. With
366
376
  * `stepper`, the owner takes the ◀▶ over: a press goes to `stepper.onStep` and the owner's
367
- * `canStepPrevious` / `canStepNext` decide which arrows are available.
377
+ * `canStepPrevious` / `canStepNext` decide which arrows are available. `stepGlyph` draws the ◀▶ as one
378
+ * triangle or two, and nothing else about them depends on it.
368
379
  * 月セレクタ共通コンポーネント。
369
380
  * `<input type="month">` または `<select>` ドロップダウンと両脇のステッパーボタン (◀▶) で隣接する選択可能月へ移動。
370
381
  * 選択可能集合は `allowedMonths` (離散・境界と積) または [minDate/minYear, maxDate/maxYear] (連続) が決定し、集合外の月は emit されない。
371
382
  * アクセシブル名は `locale` のカタログ (既定は英語)、選択肢テキストは `formatLocale` 未指定なら ISO 8601 表記。
372
383
  * `value` / `initialDate` の欠落・不正値、境界の矛盾、`allowedMonths` 無しの `variant="dropdown"` での境界欠落、
373
- * `allowedMonths` の不正要素、不正な `locale` / `labels` / `formatLocale` はいずれも RangeError で即時失敗。
384
+ * `allowedMonths` の不正要素、不正な `locale` / `labels` / `formatLocale` / `stepGlyph` はいずれも RangeError で即時失敗。
374
385
  * 集合外の保持値は丸めも即時失敗もせずそのまま表示し (ルートに `data-out-of-range="true"`、`<select>` には選択不可の
375
386
  * プレースホルダ)、発行できない月へ進むステッパーは無効化。`stepper` を渡すと ◀▶ は所有者が引き受け (押下は `stepper.onStep` へ、
376
387
  * 押せる矢印は所有者の `canStepPrevious` / `canStepNext` が決める)、不整合な `stepper` と非制御での `stepper` は RangeError。
388
+ * `stepGlyph` は ◀▶ を三角形 1 つか 2 つで描き分け、それ以外は字形に依らない。
377
389
  */
378
390
  const MonthSelectorComponent = (props: MonthSelectorProps): React.JSX.Element => {
379
- const { value, initialDate, onChange, stepper, children, variant = "date", minYear, maxYear, minDate, maxDate, allowedMonths, isWarning = false, className = "", style, disabled = false, locale, labels, formatLocale, formatOption } = props
391
+ const { value, initialDate, onChange, stepper, stepGlyph, children, variant = "date", minYear, maxYear, minDate, maxDate, allowedMonths, isWarning = false, className = "", style, disabled = false, locale, labels, formatLocale, formatOption } = props
380
392
 
381
393
  if (formatLocale !== undefined) assertLocaleTag("MonthSelector", "formatLocale", formatLocale)
382
394
  assertValidDateProp(value, "value", "")
@@ -400,6 +412,7 @@ const MonthSelectorComponent = (props: MonthSelectorProps): React.JSX.Element =>
400
412
  throw new RangeError("MonthSelector: either value (controlled) or initialDate (uncontrolled) is required; the selected month is never inferred from the wall clock")
401
413
  }
402
414
  if (stepper !== undefined) assertSelectorStepper("MonthSelector", stepper, value !== undefined)
415
+ const glyph = resolveStepGlyph("MonthSelector", stepGlyph)
403
416
 
404
417
  // ラベル解決は最初のフック。日付 Props の検証を全て済ませてから呼び、両方が不正なら日付側を先に報告する
405
418
  const resolvedLabels = useResolvedLabels(locale, labels)
@@ -545,7 +558,7 @@ const MonthSelectorComponent = (props: MonthSelectorProps): React.JSX.Element =>
545
558
 
546
559
  return (
547
560
  <div className={`inline-flex items-center ${STEPPER_ROW_GAP_CLASS} ${className}`} style={style} data-out-of-range={isActiveSelectable ? undefined : "true"}>
548
- <StepperButton neighbour="control" direction="left" disabled={disabled} canStep={stepper === undefined ? prevMonthDate !== null : stepper.canStepPrevious} onStep={handlePrevious} ariaLabel={resolvedLabels.previousMonth} />
561
+ <StepperButton neighbour="control" direction="left" glyph={glyph} disabled={disabled} canStep={stepper === undefined ? prevMonthDate !== null : stepper.canStepPrevious} onStep={handlePrevious} ariaLabel={resolvedLabels.previousMonth} />
549
562
  {variant === "dropdown" ? (
550
563
  <select aria-label={resolvedLabels.monthSelect} disabled={disabled} className={selectClassName} value={selectValue} onChange={handleSelectChange}>
551
564
  {isActiveSelectable ? null : (
@@ -562,7 +575,7 @@ const MonthSelectorComponent = (props: MonthSelectorProps): React.JSX.Element =>
562
575
  ) : (
563
576
  <input aria-label={resolvedLabels.monthSelect} disabled={disabled} className={inputClassName} value={formattedValue} min={minFormatted} max={maxFormatted} onChange={handleInputChange} type="month" />
564
577
  )}
565
- <StepperButton neighbour="control" direction="right" disabled={disabled} canStep={stepper === undefined ? nextMonthDate !== null : stepper.canStepNext} onStep={handleNext} ariaLabel={resolvedLabels.nextMonth} />
578
+ <StepperButton neighbour="control" direction="right" glyph={glyph} disabled={disabled} canStep={stepper === undefined ? nextMonthDate !== null : stepper.canStepNext} onStep={handleNext} ariaLabel={resolvedLabels.nextMonth} />
566
579
  {children}
567
580
  </div>
568
581
  )
@@ -602,6 +615,7 @@ export const areMonthSelectorPropsEqual = (prev: MonthSelectorProps, next: Month
602
615
  if (prev.stepper?.onStep !== next.stepper?.onStep) return false
603
616
  if (prev.stepper?.canStepPrevious !== next.stepper?.canStepPrevious) return false
604
617
  if (prev.stepper?.canStepNext !== next.stepper?.canStepNext) return false
618
+ if (prev.stepGlyph !== next.stepGlyph) return false
605
619
  if (prev.children !== next.children) return false
606
620
  if (prev.locale !== next.locale) return false
607
621
  if (!areLabelOverridesEqual(prev.labels, next.labels)) return false