@react-stately/calendar
Advanced tools
Comparing version 3.0.0-nightly.1476 to 3.0.0-nightly.1481
var $hEzMm$internationalizeddate = require("@internationalized/date"); | ||
var $hEzMm$reactstatelyutils = require("@react-stately/utils"); | ||
var $hEzMm$reactariai18n = require("@react-aria/i18n"); | ||
var $hEzMm$react = require("react"); | ||
@@ -80,5 +79,7 @@ | ||
function $6adad0c8536fc209$export$6d095e787d2b5e1f(props) { | ||
let defaultFormatter = $hEzMm$reactariai18n.useDateFormatter(); | ||
let defaultFormatter = $hEzMm$react.useMemo(()=>new $hEzMm$internationalizeddate.DateFormatter(props.locale) | ||
, [ | ||
props.locale | ||
]); | ||
let resolvedOptions = $hEzMm$react.useMemo(()=>defaultFormatter.resolvedOptions() | ||
@@ -85,0 +86,0 @@ , [ |
@@ -1,4 +0,3 @@ | ||
import {toCalendar as $keQhS$toCalendar, toCalendarDate as $keQhS$toCalendarDate, today as $keQhS$today, GregorianCalendar as $keQhS$GregorianCalendar, isSameDay as $keQhS$isSameDay, startOfYear as $keQhS$startOfYear, startOfMonth as $keQhS$startOfMonth, startOfWeek as $keQhS$startOfWeek, maxDate as $keQhS$maxDate, minDate as $keQhS$minDate, isEqualDay as $keQhS$isEqualDay} from "@internationalized/date"; | ||
import {DateFormatter as $keQhS$DateFormatter, toCalendar as $keQhS$toCalendar, toCalendarDate as $keQhS$toCalendarDate, today as $keQhS$today, GregorianCalendar as $keQhS$GregorianCalendar, isSameDay as $keQhS$isSameDay, startOfYear as $keQhS$startOfYear, startOfMonth as $keQhS$startOfMonth, startOfWeek as $keQhS$startOfWeek, maxDate as $keQhS$maxDate, minDate as $keQhS$minDate, isEqualDay as $keQhS$isEqualDay} from "@internationalized/date"; | ||
import {useControlledState as $keQhS$useControlledState} from "@react-stately/utils"; | ||
import {useDateFormatter as $keQhS$useDateFormatter} from "@react-aria/i18n"; | ||
import {useMemo as $keQhS$useMemo, useState as $keQhS$useState, useRef as $keQhS$useRef} from "react"; | ||
@@ -64,5 +63,7 @@ | ||
function $131cf43a05231e1e$export$6d095e787d2b5e1f(props) { | ||
let defaultFormatter = $keQhS$useDateFormatter(); | ||
let defaultFormatter = $keQhS$useMemo(()=>new $keQhS$DateFormatter(props.locale) | ||
, [ | ||
props.locale | ||
]); | ||
let resolvedOptions = $keQhS$useMemo(()=>defaultFormatter.resolvedOptions() | ||
@@ -69,0 +70,0 @@ , [ |
@@ -92,16 +92,47 @@ import { CalendarDate, Calendar, DateDuration } from "@internationalized/date"; | ||
} | ||
interface CalendarStateOptions<T extends DateValue> extends CalendarProps<T> { | ||
interface CalendarStateOptions extends CalendarProps<DateValue> { | ||
/** The locale to display and edit the value according to. */ | ||
locale: string; | ||
/** | ||
* A function that creates a [Calendar](../internationalized/date/Calendar.html) | ||
* object for a given calendar identifier. Such a function may be imported from the | ||
* `@internationalized/date` package, or manually implemented to include support for | ||
* only certain calendars. | ||
*/ | ||
createCalendar: (name: string) => Calendar; | ||
/** | ||
* The amount of days that will be displayed at once. This affects how pagination works. | ||
* @default {months: 1} | ||
*/ | ||
visibleDuration?: DateDuration; | ||
/** Determines how to align the initial selection relative to the visible date range. */ | ||
selectionAlignment?: 'start' | 'center' | 'end'; | ||
} | ||
export function useCalendarState<T extends DateValue>(props: CalendarStateOptions<T>): CalendarState; | ||
interface RangeCalendarStateOptions<T extends DateValue> extends RangeCalendarProps<T> { | ||
/** | ||
* Provides state management for a calendar component. | ||
* A calendar displays one or more date grids and allows users to select a single date. | ||
*/ | ||
export function useCalendarState(props: CalendarStateOptions): CalendarState; | ||
interface RangeCalendarStateOptions extends RangeCalendarProps<DateValue> { | ||
/** The locale to display and edit the value according to. */ | ||
locale: string; | ||
/** | ||
* A function that creates a [Calendar](../internationalized/date/Calendar.html) | ||
* object for a given calendar identifier. Such a function may be imported from the | ||
* `@internationalized/date` package, or manually implemented to include support for | ||
* only certain calendars. | ||
*/ | ||
createCalendar: (name: string) => Calendar; | ||
/** | ||
* The amount of days that will be displayed at once. This affects how pagination works. | ||
* @default {months: 1} | ||
*/ | ||
visibleDuration?: DateDuration; | ||
} | ||
export function useRangeCalendarState<T extends DateValue>(props: RangeCalendarStateOptions<T>): RangeCalendarState; | ||
/** | ||
* Provides state management for a range calendar component. | ||
* A range calendar displays one or more date grids and allows users to select a contiguous range of dates. | ||
*/ | ||
export function useRangeCalendarState(props: RangeCalendarStateOptions): RangeCalendarState; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@react-stately/calendar", | ||
"version": "3.0.0-nightly.1476+91ca94fe5", | ||
"version": "3.0.0-nightly.1481+0bba35ae3", | ||
"description": "Spectrum UI components in React", | ||
@@ -21,8 +21,8 @@ "license": "Apache-2.0", | ||
"@babel/runtime": "^7.6.2", | ||
"@internationalized/date": "3.0.0-nightly.3175+91ca94fe5", | ||
"@react-aria/i18n": "3.0.0-nightly.1476+91ca94fe5", | ||
"@react-stately/utils": "3.0.0-nightly.1476+91ca94fe5", | ||
"@react-types/calendar": "3.0.0-nightly.3175+91ca94fe5", | ||
"@react-types/datepicker": "3.0.0-nightly.3175+91ca94fe5", | ||
"@react-types/shared": "3.0.0-nightly.1476+91ca94fe5", | ||
"@internationalized/date": "3.0.0-nightly.3180+0bba35ae3", | ||
"@react-aria/i18n": "3.0.0-nightly.1481+0bba35ae3", | ||
"@react-stately/utils": "3.0.0-nightly.1481+0bba35ae3", | ||
"@react-types/calendar": "3.0.0-nightly.3180+0bba35ae3", | ||
"@react-types/datepicker": "3.0.0-nightly.3180+0bba35ae3", | ||
"@react-types/shared": "3.0.0-nightly.1481+0bba35ae3", | ||
"date-fns": "^1.30.1" | ||
@@ -36,3 +36,3 @@ }, | ||
}, | ||
"gitHead": "91ca94fe52840b7a32b961ec08208f5fbdf65697" | ||
"gitHead": "0bba35ae36b5d220570385215860d3ca3b549656" | ||
} |
@@ -18,2 +18,3 @@ /* | ||
DateDuration, | ||
DateFormatter, | ||
GregorianCalendar, | ||
@@ -28,14 +29,29 @@ isSameDay, | ||
import {useControlledState} from '@react-stately/utils'; | ||
import {useDateFormatter} from '@react-aria/i18n'; | ||
import {useMemo, useRef, useState} from 'react'; | ||
interface CalendarStateOptions<T extends DateValue> extends CalendarProps<T> { | ||
interface CalendarStateOptions extends CalendarProps<DateValue> { | ||
/** The locale to display and edit the value according to. */ | ||
locale: string, | ||
/** | ||
* A function that creates a [Calendar](../internationalized/date/Calendar.html) | ||
* object for a given calendar identifier. Such a function may be imported from the | ||
* `@internationalized/date` package, or manually implemented to include support for | ||
* only certain calendars. | ||
*/ | ||
createCalendar: (name: string) => Calendar, | ||
/** | ||
* The amount of days that will be displayed at once. This affects how pagination works. | ||
* @default {months: 1} | ||
*/ | ||
visibleDuration?: DateDuration, | ||
/** Determines how to align the initial selection relative to the visible date range. */ | ||
selectionAlignment?: 'start' | 'center' | 'end' | ||
} | ||
export function useCalendarState<T extends DateValue>(props: CalendarStateOptions<T>): CalendarState { | ||
let defaultFormatter = useDateFormatter(); | ||
/** | ||
* Provides state management for a calendar component. | ||
* A calendar displays one or more date grids and allows users to select a single date. | ||
*/ | ||
export function useCalendarState(props: CalendarStateOptions): CalendarState { | ||
let defaultFormatter = useMemo(() => new DateFormatter(props.locale), [props.locale]); | ||
let resolvedOptions = useMemo(() => defaultFormatter.resolvedOptions(), [defaultFormatter]); | ||
@@ -42,0 +58,0 @@ let { |
@@ -23,9 +23,24 @@ /* | ||
interface RangeCalendarStateOptions<T extends DateValue> extends RangeCalendarProps<T> { | ||
interface RangeCalendarStateOptions extends RangeCalendarProps<DateValue> { | ||
/** The locale to display and edit the value according to. */ | ||
locale: string, | ||
/** | ||
* A function that creates a [Calendar](../internationalized/date/Calendar.html) | ||
* object for a given calendar identifier. Such a function may be imported from the | ||
* `@internationalized/date` package, or manually implemented to include support for | ||
* only certain calendars. | ||
*/ | ||
createCalendar: (name: string) => Calendar, | ||
/** | ||
* The amount of days that will be displayed at once. This affects how pagination works. | ||
* @default {months: 1} | ||
*/ | ||
visibleDuration?: DateDuration | ||
} | ||
export function useRangeCalendarState<T extends DateValue>(props: RangeCalendarStateOptions<T>): RangeCalendarState { | ||
/** | ||
* Provides state management for a range calendar component. | ||
* A range calendar displays one or more date grids and allows users to select a contiguous range of dates. | ||
*/ | ||
export function useRangeCalendarState(props: RangeCalendarStateOptions): RangeCalendarState { | ||
let {value: valueProp, defaultValue, onChange, createCalendar, locale, visibleDuration = {months: 1}, minValue, maxValue, ...calendarProps} = props; | ||
@@ -32,0 +47,0 @@ let [value, setValue] = useControlledState<DateRange>( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
169033
1542