Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename DateTimeFormatOptions to prevent key generation #87

Merged
merged 1 commit into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/calendar/CalendarHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CalendarStateReturn, "calendarId" | "currentMonth"> & {
format?: DateTimeFormatOptions;
format?: DateTimeFormatOpts;
};

export type CalendarHeaderHTMLProps = BoxHTMLProps;
Expand Down
8 changes: 2 additions & 6 deletions src/datepicker/DatePickerState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -31,7 +27,7 @@ export interface DatePickerInitialState
ValueBase<DateValue>,
RangeValueBase<DateValue> {
placeholderDate?: DateValue;
formatOptions?: DateTimeFormatOptions;
formatOptions?: DateTimeFormatOpts;
}

export const useDatePickerState = (props: DatePickerInitialState = {}) => {
Expand Down
4 changes: 2 additions & 2 deletions src/segment/SegmentState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/segment/__utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/timepicker/TimePickerState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
formatOptions?: DateTimeFormatOptions;
formatOptions?: DateTimeFormatOpts;
placeholderDate?: Date;
}

Expand Down
2 changes: 0 additions & 2 deletions src/utils/__keys.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/utils/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { RangeValue } from "@react-types/shared";
export type DateTimeFormatOptions = Intl.DateTimeFormatOptions & {
export type DateTimeFormatOpts = Intl.DateTimeFormatOptions & {
timeStyle?: string;
dateStyle?: string;
};
Expand Down
5 changes: 2 additions & 3 deletions src/utils/useSpinButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
}, []);
Expand Down