/*
* The MIT License (MIT)
*
* Copyright (c) 2015 - present Instructure, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import type {
AsElementType,
CalendarDayTheme,
OtherHTMLAttributes
} from '@instructure/shared-types'
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
import { KeyboardEvent, MouseEvent } from 'react'
import type { ViewProps } from '@instructure/ui-view/latest'
import { Renderable } from '@instructure/shared-types'
type CalendarDayOwnProps = {
/**
* The rendered representation of the corresponding date.
*/
children?: Renderable
/**
* An ISO 8601 formatted string representing the date corresponding to
* this ``
*/
date: string
/**
* Accessible label to provide more context for the date to assistive
* technologies. This should consist of more than just a numerical date value.
* It should also include the month and the year. Ex. instead of just `1`,
* provide `1 August 2019`.
*/
label: string
/**
* Is the `` disabled
*/
interaction?: 'enabled' | 'disabled'
/**
* Is the `` selected
*/
isSelected?: boolean
/**
* Is the `` today
*/
isToday?: boolean
/**
* Is the `` located outside the current rendered month
*/
isOutsideMonth?: boolean
/**
* Callback fired on click.
* @param {Object} event - the click event
* @param {Object} data - additional data
* @param data.date - the date of the corresponding ``
*/
onClick?: (
event: MouseEvent,
date: { date: string }
) => void
/**
* Callback fired on key down.
* @param {Object} event - the key down event
* @param {Object} data - additional data
* @param data.date - the date of the corresponding ``
*/
onKeyDown?: (
event: KeyboardEvent,
data: { date: string }
) => void
/**
* A ref function for the underlying DOM element.
*/
elementRef?: (element: Element | null) => void
/**
* the element type to render as
*/
as?: AsElementType
}
type CalendarDayStyleProps = {
isDisabled: boolean
}
type PropKeys = keyof CalendarDayOwnProps
type AllowedPropKeys = Readonly>
type CalendarDayProps = CalendarDayOwnProps &
WithStyleProps &
OtherHTMLAttributes
type CalendarDayStyle = ComponentStyle<'calendarDay' | 'day'>
const allowedProps: AllowedPropKeys = [
'children',
'date',
'label',
'interaction',
'isSelected',
'isToday',
'isOutsideMonth',
'onClick',
'onKeyDown',
'elementRef',
'as'
]
export type { CalendarDayProps, CalendarDayStyleProps, CalendarDayStyle }
export { allowedProps }