@aiquants/period-slider 0.4.1 → 0.4.2
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/dist/DateSelector.d.ts +0 -3
- package/dist/DateSelector.d.ts.map +1 -1
- package/dist/MonthSelector.d.ts +0 -3
- package/dist/MonthSelector.d.ts.map +1 -1
- package/dist/PeriodSlider.d.ts +15 -4
- package/dist/PeriodSlider.d.ts.map +1 -1
- package/dist/YearSelector.d.ts +0 -3
- package/dist/YearSelector.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +1366 -1247
- package/dist/usePeriodSlider.d.ts +25 -1
- package/dist/usePeriodSlider.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/DateSelector.tsx +24 -11
- package/src/MonthSelector.tsx +25 -14
- package/src/PeriodSlider.tsx +361 -91
- package/src/YearSelector.tsx +30 -13
- package/src/usePeriodSlider.ts +24 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { PeriodSliderPointProps, PeriodSliderRangeProps, PeriodSliderUnit, PeriodSliderVernierProps } from './PeriodSlider';
|
|
2
|
+
import { PeriodSliderPointProps, PeriodSliderRangeProps, PeriodSliderUnit, PeriodSliderVernierProps } from './PeriodSlider.js';
|
|
3
3
|
/**
|
|
4
4
|
* Pre-configured props for the bundled YearSelector / MonthSelector / DateSelector components.
|
|
5
5
|
* 同梱の YearSelector・MonthSelector・DateSelector へそのまま渡せる Props。
|
|
@@ -16,6 +16,10 @@ export interface SelectorProps {
|
|
|
16
16
|
/** Time resolution unit of the selector / セレクタの時間解像度単位 */
|
|
17
17
|
unit: PeriodSliderUnit;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Options accepted by the range hook; slider props not owned by the hook pass straight through.
|
|
21
|
+
* レンジフックが受け取るオプション。フックが所有しないスライダー props はそのまま素通し。
|
|
22
|
+
*/
|
|
19
23
|
export interface UsePeriodSliderRangeOptions extends Partial<Omit<PeriodSliderRangeProps, "mode" | "unit" | "minDate" | "maxDate" | "range" | "defaultRange" | "onChangeRange">> {
|
|
20
24
|
/** Time resolution unit / 時間解像度単位 */
|
|
21
25
|
unit: PeriodSliderUnit;
|
|
@@ -28,6 +32,10 @@ export interface UsePeriodSliderRangeOptions extends Partial<Omit<PeriodSliderRa
|
|
|
28
32
|
/** Callback triggered when the selected range changes / 期間変更時コールバック */
|
|
29
33
|
onChangeRange?: (lower: Date, upper: Date) => void;
|
|
30
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* State, mutators and ready-to-spread props returned by the range hook.
|
|
37
|
+
* レンジフックが返す状態・更新関数・スプレッド可能な props 一式。
|
|
38
|
+
*/
|
|
31
39
|
export interface UsePeriodSliderRangeReturn {
|
|
32
40
|
/** Current selected range tuple / 現在の選択期間タプル */
|
|
33
41
|
range: [Date, Date];
|
|
@@ -81,6 +89,10 @@ export interface UsePeriodSliderRangeReturn {
|
|
|
81
89
|
* ```
|
|
82
90
|
*/
|
|
83
91
|
export declare function usePeriodSliderRange(options: UsePeriodSliderRangeOptions): UsePeriodSliderRangeReturn;
|
|
92
|
+
/**
|
|
93
|
+
* Options accepted by the point hook; slider props not owned by the hook pass straight through.
|
|
94
|
+
* ポイントフックが受け取るオプション。フックが所有しないスライダー props はそのまま素通し。
|
|
95
|
+
*/
|
|
84
96
|
export interface UsePeriodSliderPointOptions extends Partial<Omit<PeriodSliderPointProps, "mode" | "unit" | "minDate" | "maxDate" | "value" | "defaultValue" | "onChangePoint">> {
|
|
85
97
|
/** Time resolution unit / 時間解像度単位 */
|
|
86
98
|
unit: PeriodSliderUnit;
|
|
@@ -93,6 +105,10 @@ export interface UsePeriodSliderPointOptions extends Partial<Omit<PeriodSliderPo
|
|
|
93
105
|
/** Callback triggered when point changes / 日付変更時コールバック */
|
|
94
106
|
onChangePoint?: (value: Date) => void;
|
|
95
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* State, mutators and ready-to-spread props returned by the point hook.
|
|
110
|
+
* ポイントフックが返す状態・更新関数・スプレッド可能な props 一式。
|
|
111
|
+
*/
|
|
96
112
|
export interface UsePeriodSliderPointReturn {
|
|
97
113
|
/** Current selected point date / 現在の選択日付 */
|
|
98
114
|
value: Date;
|
|
@@ -135,6 +151,10 @@ export interface UsePeriodSliderPointReturn {
|
|
|
135
151
|
* ```
|
|
136
152
|
*/
|
|
137
153
|
export declare function usePeriodSliderPoint(options: UsePeriodSliderPointOptions): UsePeriodSliderPointReturn;
|
|
154
|
+
/**
|
|
155
|
+
* Options accepted by the vernier hook; slider props not owned by the hook pass straight through.
|
|
156
|
+
* ノギスフックが受け取るオプション。フックが所有しないスライダー props はそのまま素通し。
|
|
157
|
+
*/
|
|
138
158
|
export interface UseVernierSliderOptions extends Partial<Omit<PeriodSliderVernierProps, "mode" | "unit" | "minDate" | "maxDate" | "macroUnit" | "microUnit" | "macroRange" | "microRange" | "defaultMicroRange" | "onChangeMacroRange" | "onChangeMicroRange">> {
|
|
139
159
|
/** Base time resolution unit / 基本時間解像度単位 */
|
|
140
160
|
unit: PeriodSliderUnit;
|
|
@@ -155,6 +175,10 @@ export interface UseVernierSliderOptions extends Partial<Omit<PeriodSliderVernie
|
|
|
155
175
|
/** Callback triggered when micro range changes / ミクロ選択範囲変更時コールバック */
|
|
156
176
|
onChangeMicroRange?: (lower: Date, upper: Date) => void;
|
|
157
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Macro/micro state, mutators and ready-to-spread props returned by the vernier hook.
|
|
180
|
+
* ノギスフックが返すマクロ・ミクロの状態・更新関数・スプレッド可能な props 一式。
|
|
181
|
+
*/
|
|
158
182
|
export interface UseVernierSliderReturn {
|
|
159
183
|
/** Macro window range tuple / マクロ窓期間タプル */
|
|
160
184
|
macroRange: [Date, Date];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePeriodSlider.d.ts","sourceRoot":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AA;IACpC,iGAAiG;IACjG,WAAW,EAAE,wBAAwB,CAAA;CACxC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,sBAAsB,CAqOzF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiquants/period-slider",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Customizable period slider and year/month/date selectors for React",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css"
|
|
@@ -92,14 +92,14 @@
|
|
|
92
92
|
"test:coverage": "vitest --coverage",
|
|
93
93
|
"test:e2e": "playwright test",
|
|
94
94
|
"test:e2e:ui": "playwright test --ui",
|
|
95
|
-
"lint": "biome check src",
|
|
96
|
-
"lint:fix": "biome check --write src",
|
|
97
|
-
"format": "biome format --write src",
|
|
98
|
-
"format:check": "biome format src",
|
|
95
|
+
"lint": "biome check src tests",
|
|
96
|
+
"lint:fix": "biome check --write src tests",
|
|
97
|
+
"format": "biome format --write src tests",
|
|
98
|
+
"format:check": "biome format src tests",
|
|
99
99
|
"clean": "rimraf dist",
|
|
100
|
-
"publish:patch": "pnpm run typecheck && pnpm run --if-present test && pnpm version patch --no-git-tag-version --no-git-checks && pnpm publish --no-git-checks",
|
|
101
|
-
"publish:minor": "pnpm run typecheck && pnpm run --if-present test && pnpm version minor --no-git-tag-version --no-git-checks && pnpm publish --no-git-checks",
|
|
102
|
-
"publish:major": "pnpm run typecheck && pnpm run --if-present test && pnpm version major --no-git-tag-version --no-git-checks && pnpm publish --no-git-checks",
|
|
100
|
+
"publish:patch": "pnpm run typecheck && pnpm run build && pnpm run --if-present test && pnpm version patch --no-git-tag-version --no-git-checks && pnpm publish --no-git-checks",
|
|
101
|
+
"publish:minor": "pnpm run typecheck && pnpm run build && pnpm run --if-present test && pnpm version minor --no-git-tag-version --no-git-checks && pnpm publish --no-git-checks",
|
|
102
|
+
"publish:major": "pnpm run typecheck && pnpm run build && pnpm run --if-present test && pnpm version major --no-git-tag-version --no-git-checks && pnpm publish --no-git-checks",
|
|
103
103
|
"build:types-cjs": "node -e \"require('fs').copyFileSync('dist/index.d.ts','dist/index.d.cts')\""
|
|
104
104
|
}
|
|
105
105
|
}
|
package/src/DateSelector.tsx
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { addDays, format, getDaysInMonth, parseISO } from "date-fns"
|
|
19
19
|
import type React from "react"
|
|
20
20
|
import { memo, useEffect, useMemo, useState } from "react"
|
|
21
|
-
import { formatLabel
|
|
21
|
+
import { formatLabel } from "./PeriodSlider"
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Props of the day-resolution selector.
|
|
@@ -36,8 +36,6 @@ export interface DateSelectorProps {
|
|
|
36
36
|
value?: Date
|
|
37
37
|
/** Initial selected date; required unless `value` is supplied; must be a valid Date / 初期選択日付(非制御用・`value` 未指定時は必須・Invalid Date 不可) */
|
|
38
38
|
initialDate?: Date
|
|
39
|
-
/** Time resolution unit (ignored by selector, accepted for hook interoperability) / 時間解像度単位 (フック相互運用用) */
|
|
40
|
-
unit?: PeriodSliderUnit
|
|
41
39
|
/** Callback triggered when a selectable date is chosen / 選択可能な日付が選ばれた時のコールバック */
|
|
42
40
|
onChange?(date: Date): void
|
|
43
41
|
/** Child elements / 子要素 */
|
|
@@ -309,9 +307,14 @@ const toDescendingOptions = (datesAscending: Date[], locale: string | undefined)
|
|
|
309
307
|
|
|
310
308
|
/**
|
|
311
309
|
* Date (yyyy-MM-dd) selector component supporting bounded ranges, discrete allowed dates, and ±1 stepper buttons.
|
|
310
|
+
* Every control the component presents as enabled is emittable: a stepper whose target date falls
|
|
311
|
+
* outside the selectable set is disabled, and so is a `variant="split-dropdown"` year or month
|
|
312
|
+
* whose combination with the other two parts would be discarded.
|
|
312
313
|
* 日付(年月日)セレクタ共通コンポーネント。
|
|
313
314
|
* ネイティブ日付入力・単一セレクトボックス・3 分割セレクトのいずれかと、両脇のステッパーボタン (◀▶) を描画。
|
|
314
315
|
* 選択可能集合は `allowedDates` (離散) または [minDate/minYear, maxDate/maxYear] (連続) が決定し、集合外の日付は emit されない。
|
|
316
|
+
* 発行できない日へ進むステッパーは無効化し、`variant="split-dropdown"` では他の 2 部位との組合せが
|
|
317
|
+
* emit できない年・月を選択不可の選択肢として提示。
|
|
315
318
|
* `value` / `initialDate` の欠落・不正値、バリアントが要求する境界の欠落・矛盾、`allowedDates` との組合せ違反はいずれも RangeError で即時失敗。
|
|
316
319
|
*/
|
|
317
320
|
const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
@@ -436,6 +439,9 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
|
436
439
|
const activeTime = activeDate.getTime()
|
|
437
440
|
const isActiveSelectable = isSelectable(activeDate)
|
|
438
441
|
|
|
442
|
+
// 保持値が窓の外にある間は、窓へ戻る向きの隣日も窓の外に出る。可否を手前の境界だけで決めると
|
|
443
|
+
// emit が破棄する日でボタンが有効になり、押しても何も起きない死にボタンになる。
|
|
444
|
+
// 押せる日と発行できる日は、どちらも選択可能集合への所属で決める
|
|
439
445
|
const prevDate = useMemo<Date | null>(() => {
|
|
440
446
|
if (selectableDates !== null) {
|
|
441
447
|
for (let i = selectableDates.length - 1; i >= 0; i--) {
|
|
@@ -444,8 +450,8 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
|
444
450
|
return null
|
|
445
451
|
}
|
|
446
452
|
const candidate = addDays(new Date(activeTime), -1)
|
|
447
|
-
return
|
|
448
|
-
}, [selectableDates, activeTime, minBoundTime])
|
|
453
|
+
return isSelectable(candidate) ? candidate : null
|
|
454
|
+
}, [selectableDates, activeTime, minBoundTime, maxBoundTime])
|
|
449
455
|
|
|
450
456
|
const nextDate = useMemo<Date | null>(() => {
|
|
451
457
|
if (selectableDates !== null) {
|
|
@@ -455,8 +461,8 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
|
455
461
|
return null
|
|
456
462
|
}
|
|
457
463
|
const candidate = addDays(new Date(activeTime), 1)
|
|
458
|
-
return
|
|
459
|
-
}, [selectableDates, activeTime, maxBoundTime])
|
|
464
|
+
return isSelectable(candidate) ? candidate : null
|
|
465
|
+
}, [selectableDates, activeTime, minBoundTime, maxBoundTime])
|
|
460
466
|
|
|
461
467
|
const isPrevDisabled = disabled || prevDate === null
|
|
462
468
|
const isNextDisabled = disabled || nextDate === null
|
|
@@ -534,9 +540,16 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
|
534
540
|
return list
|
|
535
541
|
}, [variant, minBoundTime, maxBoundTime, activeTime, currentYear, currentMonth])
|
|
536
542
|
|
|
543
|
+
// 分割セレクトは 3 つの値のうち 1 つだけを差し替えるため、残り 2 つとの組が実在しない日付や
|
|
544
|
+
// 選択可能集合の外へ出る。短い月へ切り替えた際に存在しなくなる日は、月末日へ丸めると
|
|
545
|
+
// 利用者が選んでいない日が親へ伝播するため破棄する
|
|
546
|
+
const isSplitChoiceEmittable = (year: number, month: number, day: number): boolean => {
|
|
547
|
+
if (day > getDaysInMonth(localDate(year, month, 1))) return false
|
|
548
|
+
return isSelectable(localDate(year, month, day))
|
|
549
|
+
}
|
|
550
|
+
|
|
537
551
|
const handleSplitSelectChange = (newYear: number, newMonth: number, newDay: number) => {
|
|
538
|
-
|
|
539
|
-
if (newDay > getDaysInMonth(localDate(newYear, newMonth, 1))) return
|
|
552
|
+
if (!isSplitChoiceEmittable(newYear, newMonth, newDay)) return
|
|
540
553
|
|
|
541
554
|
emit(localDate(newYear, newMonth, newDay))
|
|
542
555
|
}
|
|
@@ -608,7 +621,7 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
|
608
621
|
</option>
|
|
609
622
|
)}
|
|
610
623
|
{yearOptions.map((y) => (
|
|
611
|
-
<option key={y} value={y} className="dark:bg-slate-700 dark:text-slate-100">
|
|
624
|
+
<option key={y} value={y} disabled={!isSplitChoiceEmittable(y, currentMonth, currentDay)} className="dark:bg-slate-700 dark:text-slate-100">
|
|
612
625
|
{renderYearOption(y)}
|
|
613
626
|
</option>
|
|
614
627
|
))}
|
|
@@ -625,7 +638,7 @@ const DateSelectorComponent = (props: DateSelectorProps): React.JSX.Element => {
|
|
|
625
638
|
</option>
|
|
626
639
|
)}
|
|
627
640
|
{monthOptions.map((m) => (
|
|
628
|
-
<option key={m} value={m} className="dark:bg-slate-700 dark:text-slate-100">
|
|
641
|
+
<option key={m} value={m} disabled={!isSplitChoiceEmittable(currentYear, m, currentDay)} className="dark:bg-slate-700 dark:text-slate-100">
|
|
629
642
|
{renderMonthOption(m)}
|
|
630
643
|
</option>
|
|
631
644
|
))}
|
package/src/MonthSelector.tsx
CHANGED
|
@@ -4,18 +4,19 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Provides a month selector rendered either as a native `input[type="month"]` or as a dropdown of
|
|
6
6
|
* yyyy-MM options, always flanked by stepper buttons that move the selection by one month. Bounds
|
|
7
|
-
* are the stricter of the year and date declarations; missing
|
|
8
|
-
*
|
|
9
|
-
* until a `locale` tag opts into Intl formatting, while every
|
|
7
|
+
* are the stricter of the year and date declarations; missing and invalid inputs fail fast rather
|
|
8
|
+
* than being substituted, while an out-of-bounds month is neither clamped nor emitted. Option text
|
|
9
|
+
* is locale-independent ISO 8601 until a `locale` tag opts into Intl formatting, while every
|
|
10
|
+
* machine-read value stays yyyy-MM.
|
|
10
11
|
*
|
|
11
12
|
* ネイティブ `input[type="month"]` または yyyy-MM ドロップダウンと ±1 ヶ月ステッパーによる年月セレクタ。
|
|
12
|
-
*
|
|
13
|
+
* 境界は年指定と日付指定の厳しい方を採用し、欠落値・不正値は代替せず即時エラー、境界外値はクランプも発行もせず破棄。
|
|
13
14
|
* 選択肢テキストは既定でロケール非依存の ISO 8601 表記 (`locale` 指定時のみ Intl 書式)、機械可読値は常に yyyy-MM。
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
17
|
import type React from "react"
|
|
17
18
|
import { memo, useEffect, useMemo, useState } from "react"
|
|
18
|
-
import { formatLabel
|
|
19
|
+
import { formatLabel } from "./PeriodSlider"
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Props of the month-resolution selector.
|
|
@@ -33,8 +34,6 @@ export interface MonthSelectorProps {
|
|
|
33
34
|
value?: Date
|
|
34
35
|
/** Initial selected date; required unless `value` is supplied / 選択日付(非制御用・`value` 未指定時は必須) */
|
|
35
36
|
initialDate?: Date
|
|
36
|
-
/** Time resolution unit (ignored by selector, accepted for hook interoperability) / 時間解像度単位 (フック相互運用用) */
|
|
37
|
-
unit?: PeriodSliderUnit
|
|
38
37
|
/** Callback triggered when month changes / 月変更時コールバック */
|
|
39
38
|
onChange?(date: Date, yyyymm: number): void
|
|
40
39
|
/** Child elements / 子要素 */
|
|
@@ -213,10 +212,13 @@ function generateDropdownOptions(minBound: Date, maxBound: Date, locale: string
|
|
|
213
212
|
|
|
214
213
|
/**
|
|
215
214
|
* Month selector component supporting both input[type="month"] and dropdown (yyyy-mm) modes.
|
|
215
|
+
* A held month outside the resolved bounds is rendered as it stands instead of being clamped or
|
|
216
|
+
* rejected, and a stepper whose target month cannot be emitted is disabled.
|
|
216
217
|
* 月セレクタ共通コンポーネント。
|
|
217
218
|
* `<input type="month">` または `<select>` ドロップダウンと両脇のステッパーボタン (◀▶) で ±1 ヶ月を変更可能。
|
|
218
219
|
* アクセシブル名の既定値は全て英語、選択肢テキストは `locale` 未指定なら ISO 8601 表記。
|
|
219
|
-
* `value` / `initialDate`
|
|
220
|
+
* `value` / `initialDate` の欠落・不正値、境界の欠落・矛盾、不正な `locale` はいずれも RangeError で即時失敗。
|
|
221
|
+
* 境界外の保持値は丸めも即時失敗もせず選択肢へ加えて表示し、発行できない月へ進むステッパーは無効化。
|
|
220
222
|
*/
|
|
221
223
|
const MonthSelectorComponent = (props: MonthSelectorProps): React.JSX.Element => {
|
|
222
224
|
const {
|
|
@@ -295,19 +297,28 @@ const MonthSelectorComponent = (props: MonthSelectorProps): React.JSX.Element =>
|
|
|
295
297
|
onChange?.(nextDate, yyyymm)
|
|
296
298
|
}
|
|
297
299
|
|
|
298
|
-
|
|
300
|
+
// 保持値が窓の外にある間は、窓へ戻る向きの隣月も窓の外に出る。可否を「1 歩が手前の境界を
|
|
301
|
+
// 越えないか」で決めると emit が拒否する月でボタンが有効になり、クリックが RangeError を
|
|
302
|
+
// 利用側へ投げる。押せる月と発行できる月は常に同じ判定で決める
|
|
303
|
+
const prevMonthDate = useMemo<Date | null>(() => {
|
|
304
|
+
const candidate = monthStart(activeDate.getFullYear(), activeDate.getMonth() - 1)
|
|
305
|
+
return isWithinBounds(candidate) ? candidate : null
|
|
306
|
+
}, [activeDate, minDateBound?.getTime(), maxDateBound?.getTime()])
|
|
299
307
|
|
|
300
|
-
const nextMonthDate = useMemo
|
|
308
|
+
const nextMonthDate = useMemo<Date | null>(() => {
|
|
309
|
+
const candidate = monthStart(activeDate.getFullYear(), activeDate.getMonth() + 1)
|
|
310
|
+
return isWithinBounds(candidate) ? candidate : null
|
|
311
|
+
}, [activeDate, minDateBound?.getTime(), maxDateBound?.getTime()])
|
|
301
312
|
|
|
302
|
-
const isPrevDisabled = disabled ||
|
|
303
|
-
const isNextDisabled = disabled ||
|
|
313
|
+
const isPrevDisabled = disabled || prevMonthDate === null
|
|
314
|
+
const isNextDisabled = disabled || nextMonthDate === null
|
|
304
315
|
|
|
305
316
|
const handlePrevious = () => {
|
|
306
|
-
emit(prevMonthDate)
|
|
317
|
+
if (prevMonthDate !== null) emit(prevMonthDate)
|
|
307
318
|
}
|
|
308
319
|
|
|
309
320
|
const handleNext = () => {
|
|
310
|
-
emit(nextMonthDate)
|
|
321
|
+
if (nextMonthDate !== null) emit(nextMonthDate)
|
|
311
322
|
}
|
|
312
323
|
|
|
313
324
|
const handleMonthString = (val: string) => {
|