From f8f72fd23a0cc1293601d9326525623851ac7d49 Mon Sep 17 00:00:00 2001 From: Anurag Hazra Date: Mon, 12 Oct 2020 16:59:18 +0530 Subject: [PATCH] chore: rename DateFormatTime to prevent key generation (#87) --- src/calendar/CalendarHeader.ts | 4 ++-- src/datepicker/DatePickerState.ts | 8 ++------ src/segment/SegmentState.ts | 4 ++-- src/segment/__utils.ts | 4 ++-- src/timepicker/TimePickerState.ts | 6 +++--- src/utils/__keys.ts | 2 -- src/utils/types.ts | 3 +-- src/utils/useSpinButton.ts | 5 ++--- 8 files changed, 14 insertions(+), 22 deletions(-) delete mode 100644 src/utils/__keys.ts diff --git a/src/calendar/CalendarHeader.ts b/src/calendar/CalendarHeader.ts index 9263d0545..8feaf5b47 100644 --- a/src/calendar/CalendarHeader.ts +++ b/src/calendar/CalendarHeader.ts @@ -4,11 +4,11 @@ import { createComponent, createHook } from "reakit-system"; import { CALENDAR_HEADER_KEYS } from "./__keys"; import { useDateFormatter } from "@react-aria/i18n"; import { CalendarStateReturn } from "./CalendarState"; -import { DateTimeFormatOptions } from "../utils/types"; +import { DateTimeFormatOpts } from "../utils/types"; export type CalendarHeaderOptions = BoxOptions & Pick & { - format?: DateTimeFormatOptions; + format?: DateTimeFormatOpts; }; export type CalendarHeaderHTMLProps = BoxHTMLProps; diff --git a/src/datepicker/DatePickerState.ts b/src/datepicker/DatePickerState.ts index 37e15b1b2..6f0fb5df0 100644 --- a/src/datepicker/DatePickerState.ts +++ b/src/datepicker/DatePickerState.ts @@ -14,15 +14,11 @@ import * as React from "react"; import { isValid } from "date-fns"; import { useControllableState } from "@chakra-ui/hooks"; -import { - DateTimeFormatOptions, - DateValue, - RangeValueBase, -} from "../utils/types"; import { useSegmentState } from "../segment"; import { useCalendarState } from "../calendar"; import { setTime, isInvalid } from "./__utils"; import { PickerBaseInitialState, usePickerBaseState } from "../picker-base"; +import { DateTimeFormatOpts, DateValue, RangeValueBase } from "../utils/types"; export interface DatePickerInitialState extends PickerBaseInitialState, @@ -31,7 +27,7 @@ export interface DatePickerInitialState ValueBase, RangeValueBase { placeholderDate?: DateValue; - formatOptions?: DateTimeFormatOptions; + formatOptions?: DateTimeFormatOpts; } export const useDatePickerState = (props: DatePickerInitialState = {}) => { diff --git a/src/segment/SegmentState.ts b/src/segment/SegmentState.ts index 598a6bf3b..8a1f9bc69 100644 --- a/src/segment/SegmentState.ts +++ b/src/segment/SegmentState.ts @@ -9,7 +9,7 @@ import { useCompositeState } from "reakit"; import { useDateFormatter } from "@react-aria/i18n"; import { useControlledState } from "@react-stately/utils"; -import { DateTimeFormatOptions } from "../utils/types"; +import { DateTimeFormatOpts } from "../utils/types"; import { add, setSegment, convertValue, getSegmentLimits } from "./__utils"; export interface IDateSegment { @@ -48,7 +48,7 @@ const TYPE_MAPPING = { export interface SegmentStateProps { value?: Date; defaultValue?: Date; - formatOptions?: DateTimeFormatOptions; + formatOptions?: DateTimeFormatOpts; placeholderDate?: Date; onChange?: (value: Date, ...args: any[]) => void; } diff --git a/src/segment/__utils.ts b/src/segment/__utils.ts index 2a94fc864..3a4b3cea9 100644 --- a/src/segment/__utils.ts +++ b/src/segment/__utils.ts @@ -14,7 +14,7 @@ import { setYear, } from "date-fns"; -import { DateTimeFormatOptions, DateValue } from "../utils/types"; +import { DateTimeFormatOpts, DateValue } from "../utils/types"; export function convertValue(value: DateValue | undefined): Date | undefined { if (!value) { @@ -27,7 +27,7 @@ export function convertValue(value: DateValue | undefined): Date | undefined { export function getSegmentLimits( date: Date, type: string, - options: DateTimeFormatOptions, + options: DateTimeFormatOpts, ) { let value, minValue, maxValue; switch (type) { diff --git a/src/timepicker/TimePickerState.ts b/src/timepicker/TimePickerState.ts index 5101bd7ea..dbccad24f 100644 --- a/src/timepicker/TimePickerState.ts +++ b/src/timepicker/TimePickerState.ts @@ -3,17 +3,17 @@ import { useControllableState } from "@chakra-ui/hooks"; import { ValueBase, FocusableProps } from "@react-types/shared"; import { useSegmentState } from "../segment"; -import { DateTimeFormatOptions } from "../utils/types"; +import { DateTimeFormatOpts } from "../utils/types"; +import { stringifyTime, parseTime } from "./__utils"; import { useTimePickerColumnState } from "./TimePickerColumnState"; import { PickerBaseInitialState, usePickerBaseState } from "../picker-base"; -import { stringifyTime, parseTime } from "./__utils"; // TODO: Voice Overing all button on dialog open export interface TimePickerStateProps extends PickerBaseInitialState, FocusableProps, ValueBase { - formatOptions?: DateTimeFormatOptions; + formatOptions?: DateTimeFormatOpts; placeholderDate?: Date; } diff --git a/src/utils/__keys.ts b/src/utils/__keys.ts deleted file mode 100644 index 87fe6e0ae..000000000 --- a/src/utils/__keys.ts +++ /dev/null @@ -1,2 +0,0 @@ -// Automatically generated -export const DATE_TIME_FORMAT_KEYS = ["timeStyle", "dateStyle"] as const; diff --git a/src/utils/types.ts b/src/utils/types.ts index d6ff47070..f4e41d955 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -1,5 +1,4 @@ -import { RangeValue } from "@react-types/shared"; -export type DateTimeFormatOptions = Intl.DateTimeFormatOptions & { +export type DateTimeFormatOpts = Intl.DateTimeFormatOptions & { timeStyle?: string; dateStyle?: string; }; diff --git a/src/utils/useSpinButton.ts b/src/utils/useSpinButton.ts index 98ce45eb1..4cb2c078d 100644 --- a/src/utils/useSpinButton.ts +++ b/src/utils/useSpinButton.ts @@ -14,10 +14,10 @@ import { AriaButtonProps } from "@react-types/button"; import { HTMLAttributes, useCallback, useEffect, useRef } from "react"; import { + ValueBase, InputBase, - RangeInputBase, Validation, - ValueBase, + RangeInputBase, } from "@react-types/shared"; export interface SpinButtonProps @@ -60,7 +60,6 @@ export function useSpinButton(props: SpinButtonProps): SpinbuttonAria { const clearAsync = () => clearTimeout(_async.current); - // eslint-disable-next-line arrow-body-style useEffect(() => { return () => clearAsync(); }, []);