UNPKG

@ozen-ui/kit

Version:

React component library

24 lines (23 loc) 1.56 kB
import { __assign, __rest } from "tslib"; import './Calendar.css'; import React, { forwardRef } from 'react'; import { useThemeProps } from '../../hooks/useThemeProps'; import { getByMap } from '../../utils/getByMap'; import { CalendarModeRange, CalendarModeSingle } from './components'; import { CALENDAR_DEFAULT_CALENDARS, CALENDAR_DEFAULT_MODE, CALENDAR_DEFAULT_SIZE, CALENDAR_DEFAULT_START_DAY, } from './constants'; import { getPeriodSwitchAriaLabel as createPeriodSwitchAriaLabel } from './utils'; var typeMap = { range: CalendarModeRange, single: CalendarModeSingle, }; export var Calendar = forwardRef(function (inProps, ref) { var props = useThemeProps({ props: inProps, name: 'Calendar', }); var _a = props.size, size = _a === void 0 ? CALENDAR_DEFAULT_SIZE : _a, _b = props.mode, mode = _b === void 0 ? CALENDAR_DEFAULT_MODE : _b, _c = props.startDay, startDay = _c === void 0 ? CALENDAR_DEFAULT_START_DAY : _c, _d = props.calendars, calendars = _d === void 0 ? CALENDAR_DEFAULT_CALENDARS : _d, getPeriodSwitchAriaLabelProp = props.getPeriodSwitchAriaLabel, other = __rest(props, ["size", "mode", "startDay", "calendars", "getPeriodSwitchAriaLabel"]); var getPeriodSwitchAriaLabel = getPeriodSwitchAriaLabelProp || createPeriodSwitchAriaLabel; var Component = getByMap(typeMap, mode); return (React.createElement(Component, __assign({ size: size, startDay: startDay, calendars: calendars, getPeriodSwitchAriaLabel: getPeriodSwitchAriaLabel }, other, { ref: ref }))); }); Calendar.displayName = 'Calendar';