Skip to content

Commit

Permalink
refactor(sanity): Move date inputs UI Components to ui-components (#7410
Browse files Browse the repository at this point in the history
)

* refactor(sanity): move base components from form/inputs/DateInputs to ui-components

* refactor(sanity): update the imports
  • Loading branch information
RitaDias authored Aug 23, 2024
1 parent 6fdfcac commit 0d1dcd7
Show file tree
Hide file tree
Showing 18 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {
useState,
} from 'react'

import {type CalendarLabels} from '../../../../ui-components/inputs/DateInputs/calendar/types'
import {DateTimeInput} from '../../../../ui-components/inputs/DateInputs/DateTimeInput'
import {useTranslation} from '../../../i18n/hooks/useTranslation'
import {type CalendarLabels} from './base/calendar/types'
import {DateTimeInput} from './base/DateTimeInput'
import {type ParseResult} from './types'

export interface CommonDateTimeInputProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {DEFAULT_DATE_FORMAT, format, parse} from '@sanity/util/legacyDateFormat'
import {useCallback, useMemo} from 'react'

import {type CalendarLabels} from '../../../../ui-components/inputs/DateInputs/calendar/types'
import {useTranslation} from '../../../i18n'
import {set, unset} from '../../patch'
import {type StringInputProps} from '../../types'
import {type CalendarLabels} from './base/calendar/types'
import {CommonDateTimeInput} from './CommonDateTimeInput'
import {getCalendarLabels} from './utils'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
import {getMinutes, parseISO, setMinutes} from 'date-fns'
import {useCallback, useMemo} from 'react'

import {type CalendarLabels} from '../../../../ui-components/inputs/DateInputs/calendar/types'
import {useTranslation} from '../../../i18n'
import {set, unset} from '../../patch'
import {type StringInputProps} from '../../types'
import {type CalendarLabels} from './base/calendar/types'
import {CommonDateTimeInput} from './CommonDateTimeInput'
import {type ParseResult} from './types'
import {getCalendarLabels, isValidDate} from './utils'
Expand Down
2 changes: 1 addition & 1 deletion packages/sanity/src/core/form/inputs/DateInputs/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {type CalendarLabels} from './base/calendar/types'
import {type CalendarLabels} from '../../../../ui-components/inputs/DateInputs/calendar/types'

export function isValidDate(date: Date): boolean {
return date instanceof Date && !isNaN(date.valueOf())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
import FocusLock from 'react-focus-lock'

import {Popover} from '../../../../../ui-components'
import {LazyTextInput} from '../../../../form/inputs/DateInputs/base/LazyTextInput'
import {LazyTextInput} from '../../../../../ui-components/inputs/DateInputs/LazyTextInput'
import {DatePicker} from './DatePicker'

type Props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {type ChangeEvent, type ComponentProps, type FocusEvent, useCallback} from 'react'

import {LazyTextInput} from '../../../../../form/inputs/DateInputs/base/LazyTextInput'
import {LazyTextInput} from '../../../../../../ui-components/inputs/DateInputs/LazyTextInput'

type Props = Omit<ComponentProps<typeof LazyTextInput>, 'onChange' | 'value'> & {
value?: number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {type KeyboardEvent, useCallback, useMemo, useRef, useState} from 'react'
import ReactFocusLock from 'react-focus-lock'

import {Button, Popover} from '../../../../../ui-components'
import {type CalendarLabels} from '../../../../../ui-components/inputs/DateInputs/calendar/types'
import {DatePicker} from '../../../../../ui-components/inputs/DateInputs/DatePicker'
import {type FormPatch, type PatchEvent, set, unset} from '../../../../form'
import {type CalendarLabels} from '../../../../form/inputs/DateInputs/base/calendar/types'
import {DatePicker} from '../../../../form/inputs/DateInputs/base/DatePicker'
import {getCalendarLabels} from '../../../../form/inputs/DateInputs/utils'
import {useDateTimeFormat} from '../../../../hooks'
import {useTranslation} from '../../../../i18n'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
} from 'react'
import FocusLock from 'react-focus-lock'

import {Button, Popover} from '../../../../../ui-components'
import {Button} from '../../button'
import {Popover} from '../../popover'
import {type CalendarLabels} from './calendar/types'
import {DatePicker} from './DatePicker'
import {LazyTextInput} from './LazyTextInput'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
useRef,
} from 'react'

import {Button} from '../../../../../../ui-components'
import {Button} from '../../../button'
import {CalendarMonth} from './CalendarMonth'
import {ARROW_KEYS, DEFAULT_TIME_PRESETS, HOURS_24} from './constants'
import {features} from './features'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Box, Grid, Text} from '@sanity/ui'
import {isSameDay, isSameMonth} from 'date-fns'

import {useCurrentLocale} from '../../../../../i18n/hooks/useLocale'
import {useCurrentLocale} from '../../../../core/i18n/hooks/useLocale'
import {CalendarDay} from './CalendarDay'
import {useWeeksOfMonth} from './utils'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {addDays, eachWeekOfInterval, getWeek, lastDayOfMonth, startOfMonth} from 'date-fns'

import {useCurrentLocale} from '../../../../../i18n/hooks/useLocale'
import {useCurrentLocale} from '../../../../core/i18n/hooks/useLocale'
import {TAIL_WEEKDAYS} from './constants'

/**
Expand Down

0 comments on commit 0d1dcd7

Please sign in to comment.