Skip to content

Commit

Permalink
chore(core): export getCalendarLabels to support DateTimeInput reusab…
Browse files Browse the repository at this point in the history
…ility
  • Loading branch information
pedrobonamin committed Sep 2, 2024
1 parent 32b4bba commit aa12f6c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/sanity/src/core/form/inputs/DateInputs/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export {DateInput, type DateInputProps} from './DateInput'
export {DateTimeInput, type DateTimeInputProps} from './DateTimeInput'
export {getCalendarLabels} from './utils'
3 changes: 3 additions & 0 deletions packages/sanity/src/core/form/inputs/DateInputs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export function isValidDate(date: Date): boolean {
return date instanceof Date && !isNaN(date.valueOf())
}

/**
* @internal
*/
export function getCalendarLabels(
t: (key: string, values?: Record<string, unknown>) => string,
): CalendarLabels {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {Box, Card, Container, Stack, Text} from '@sanity/ui'
import {useMemo, useState} from 'react'
import {type ChunkType, useDateTimeFormat, useTranslation} from 'sanity'
import {type ChunkType, getCalendarLabels, useDateTimeFormat, useTranslation} from 'sanity'

import {getCalendarLabels} from '../../../../../core/form/inputs/DateInputs/utils'
import {DateTimeInput} from '../../../../../ui-components/inputs/DateInputs/DateTimeInput'
import {TIMELINE_ITEM_I18N_KEY_MAPPING} from '../timelineI18n'
import {TimelineItem} from '../timelineItem'

const CHUNK_TYPES = Object.keys(TIMELINE_ITEM_I18N_KEY_MAPPING).reverse() as ChunkType[]

export default function TimelineItemStory() {
const {t: coreT} = useTranslation()
const [date, setDate] = useState<Date>(() => new Date())
Expand Down

0 comments on commit aa12f6c

Please sign in to comment.