🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@react-stately/calendar

Package Overview
Dependencies
Maintainers
2
Versions
805
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-stately/calendar - npm Package Compare versions

Comparing version

to
3.0.0-nightly-ef27de089-250509

6

dist/types.d.ts

@@ -1,2 +0,2 @@

import { CalendarDate, Calendar, DateDuration } from "@internationalized/date";
import { CalendarDate, Calendar, CalendarIdentifier, DateDuration } from "@internationalized/date";
import { DateValue, CalendarProps, RangeCalendarProps } from "@react-types/calendar";

@@ -121,3 +121,3 @@ import { RangeValue, ValidationState } from "@react-types/shared";

*/
createCalendar: (name: string) => Calendar;
createCalendar: (name: CalendarIdentifier) => Calendar;
/**

@@ -145,3 +145,3 @@ * The amount of days that will be displayed at once. This affects how pagination works.

*/
createCalendar: (name: string) => Calendar;
createCalendar: (name: CalendarIdentifier) => Calendar;
/**

@@ -148,0 +148,0 @@ * The amount of days that will be displayed at once. This affects how pagination works.

@@ -35,3 +35,3 @@ var $4301262d71f567b9$exports = require("./utils.main.js");

months: 1
}, minValue: minValue, maxValue: maxValue, selectionAlignment: selectionAlignment, isDateUnavailable: isDateUnavailable, pageBehavior: pageBehavior = 'visible' } = props;
}, minValue: minValue, maxValue: maxValue, selectionAlignment: selectionAlignment, isDateUnavailable: isDateUnavailable, pageBehavior: pageBehavior = 'visible', firstDayOfWeek: firstDayOfWeek } = props;
let calendar = (0, $cpRwL$react.useMemo)(()=>createCalendar(resolvedOptions.calendar), [

@@ -90,8 +90,8 @@ createCalendar,

// Reset focused date and visible range when calendar changes.
let [lastCalendarIdentifier, setLastCalendarIdentifier] = (0, $cpRwL$react.useState)(calendar.identifier);
if (calendar.identifier !== lastCalendarIdentifier) {
let [lastCalendar, setLastCalendar] = (0, $cpRwL$react.useState)(calendar);
if (!(0, $cpRwL$internationalizeddate.isEqualCalendar)(calendar, lastCalendar)) {
let newFocusedDate = (0, $cpRwL$internationalizeddate.toCalendar)(focusedDate, calendar);
setStartDate((0, $4301262d71f567b9$exports.alignCenter)(newFocusedDate, visibleDuration, locale, minValue, maxValue));
setFocusedDate(newFocusedDate);
setLastCalendarIdentifier(calendar.identifier);
setLastCalendar(calendar);
}

@@ -270,3 +270,2 @@ if ((0, $4301262d71f567b9$exports.isInvalid)(focusedDate, minValue, maxValue)) // If the focused date was moved to an invalid value, it can't be focused, so constrain it.

getDatesInWeek (weekIndex, from = startDate) {
// let date = startOfWeek(from, locale);
let date = from.add({

@@ -276,6 +275,6 @@ weeks: weekIndex

let dates = [];
date = (0, $cpRwL$internationalizeddate.startOfWeek)(date, locale);
date = (0, $cpRwL$internationalizeddate.startOfWeek)(date, locale, firstDayOfWeek);
// startOfWeek will clamp dates within the calendar system's valid range, which may
// start in the middle of a week. In this case, add null placeholders.
let dayOfWeek = (0, $cpRwL$internationalizeddate.getDayOfWeek)(date, locale);
let dayOfWeek = (0, $cpRwL$internationalizeddate.getDayOfWeek)(date, locale, firstDayOfWeek);
for(let i = 0; i < dayOfWeek; i++)dates.push(null);

@@ -282,0 +281,0 @@ while(dates.length < 7){

import {alignCenter as $f62d864046160412$export$f4a51ff076cc9a09, alignEnd as $f62d864046160412$export$530edbfc915b2b04, alignStart as $f62d864046160412$export$144a00ba6044eb9, constrainStart as $f62d864046160412$export$5bb865b12696a77d, constrainValue as $f62d864046160412$export$4f5203c0d889109e, isInvalid as $f62d864046160412$export$eac50920cf2fd59a, previousAvailableDate as $f62d864046160412$export$a1d3911297b952d7} from "./utils.module.js";
import {DateFormatter as $7G4ZY$DateFormatter, toCalendar as $7G4ZY$toCalendar, toCalendarDate as $7G4ZY$toCalendarDate, today as $7G4ZY$today, GregorianCalendar as $7G4ZY$GregorianCalendar, startOfWeek as $7G4ZY$startOfWeek, startOfMonth as $7G4ZY$startOfMonth, endOfWeek as $7G4ZY$endOfWeek, endOfMonth as $7G4ZY$endOfMonth, isSameDay as $7G4ZY$isSameDay, getDayOfWeek as $7G4ZY$getDayOfWeek} from "@internationalized/date";
import {DateFormatter as $7G4ZY$DateFormatter, toCalendar as $7G4ZY$toCalendar, toCalendarDate as $7G4ZY$toCalendarDate, today as $7G4ZY$today, isEqualCalendar as $7G4ZY$isEqualCalendar, GregorianCalendar as $7G4ZY$GregorianCalendar, startOfWeek as $7G4ZY$startOfWeek, startOfMonth as $7G4ZY$startOfMonth, endOfWeek as $7G4ZY$endOfWeek, endOfMonth as $7G4ZY$endOfMonth, isSameDay as $7G4ZY$isSameDay, getDayOfWeek as $7G4ZY$getDayOfWeek} from "@internationalized/date";
import {useControlledState as $7G4ZY$useControlledState} from "@react-stately/utils";

@@ -29,3 +29,3 @@ import {useMemo as $7G4ZY$useMemo, useState as $7G4ZY$useState} from "react";

months: 1
}, minValue: minValue, maxValue: maxValue, selectionAlignment: selectionAlignment, isDateUnavailable: isDateUnavailable, pageBehavior: pageBehavior = 'visible' } = props;
}, minValue: minValue, maxValue: maxValue, selectionAlignment: selectionAlignment, isDateUnavailable: isDateUnavailable, pageBehavior: pageBehavior = 'visible', firstDayOfWeek: firstDayOfWeek } = props;
let calendar = (0, $7G4ZY$useMemo)(()=>createCalendar(resolvedOptions.calendar), [

@@ -84,8 +84,8 @@ createCalendar,

// Reset focused date and visible range when calendar changes.
let [lastCalendarIdentifier, setLastCalendarIdentifier] = (0, $7G4ZY$useState)(calendar.identifier);
if (calendar.identifier !== lastCalendarIdentifier) {
let [lastCalendar, setLastCalendar] = (0, $7G4ZY$useState)(calendar);
if (!(0, $7G4ZY$isEqualCalendar)(calendar, lastCalendar)) {
let newFocusedDate = (0, $7G4ZY$toCalendar)(focusedDate, calendar);
setStartDate((0, $f62d864046160412$export$f4a51ff076cc9a09)(newFocusedDate, visibleDuration, locale, minValue, maxValue));
setFocusedDate(newFocusedDate);
setLastCalendarIdentifier(calendar.identifier);
setLastCalendar(calendar);
}

@@ -264,3 +264,2 @@ if ((0, $f62d864046160412$export$eac50920cf2fd59a)(focusedDate, minValue, maxValue)) // If the focused date was moved to an invalid value, it can't be focused, so constrain it.

getDatesInWeek (weekIndex, from = startDate) {
// let date = startOfWeek(from, locale);
let date = from.add({

@@ -270,6 +269,6 @@ weeks: weekIndex

let dates = [];
date = (0, $7G4ZY$startOfWeek)(date, locale);
date = (0, $7G4ZY$startOfWeek)(date, locale, firstDayOfWeek);
// startOfWeek will clamp dates within the calendar system's valid range, which may
// start in the middle of a week. In this case, add null placeholders.
let dayOfWeek = (0, $7G4ZY$getDayOfWeek)(date, locale);
let dayOfWeek = (0, $7G4ZY$getDayOfWeek)(date, locale, firstDayOfWeek);
for(let i = 0; i < dayOfWeek; i++)dates.push(null);

@@ -276,0 +275,0 @@ while(dates.length < 7){

{
"name": "@react-stately/calendar",
"version": "3.0.0-nightly-ec25ca46d-241211",
"version": "3.0.0-nightly-ef27de089-250509",
"description": "Spectrum UI components in React",

@@ -25,6 +25,6 @@ "license": "Apache-2.0",

"dependencies": {
"@internationalized/date": "3.0.0-nightly-ec25ca46d-241211",
"@react-stately/utils": "3.0.0-nightly-ec25ca46d-241211",
"@react-types/calendar": "3.0.0-nightly-ec25ca46d-241211",
"@react-types/shared": "3.0.0-nightly-ec25ca46d-241211",
"@internationalized/date": "3.0.0-nightly-ef27de089-250509",
"@react-stately/utils": "3.0.0-nightly-ef27de089-250509",
"@react-types/calendar": "3.0.0-nightly-ef27de089-250509",
"@react-types/shared": "3.0.0-nightly-ef27de089-250509",
"@swc/helpers": "^0.5.0"

@@ -31,0 +31,0 @@ },

@@ -17,2 +17,3 @@ /*

CalendarDate,
CalendarIdentifier,
DateDuration,

@@ -24,2 +25,3 @@ DateFormatter,

GregorianCalendar,
isEqualCalendar,
isSameDay,

@@ -47,3 +49,3 @@ startOfMonth,

*/
createCalendar: (name: string) => Calendar,
createCalendar: (name: CalendarIdentifier) => Calendar,
/**

@@ -72,5 +74,6 @@ * The amount of days that will be displayed at once. This affects how pagination works.

isDateUnavailable,
pageBehavior = 'visible'
pageBehavior = 'visible',
firstDayOfWeek
} = props;
let calendar = useMemo(() => createCalendar(resolvedOptions.calendar), [createCalendar, resolvedOptions.calendar]);
let calendar = useMemo(() => createCalendar(resolvedOptions.calendar as CalendarIdentifier), [createCalendar, resolvedOptions.calendar]);

@@ -119,8 +122,8 @@ let [value, setControlledValue] = useControlledState<DateValue | null, MappedDateValue<T>>(props.value!, props.defaultValue ?? null!, props.onChange);

// Reset focused date and visible range when calendar changes.
let [lastCalendarIdentifier, setLastCalendarIdentifier] = useState(calendar.identifier);
if (calendar.identifier !== lastCalendarIdentifier) {
let [lastCalendar, setLastCalendar] = useState(calendar);
if (!isEqualCalendar(calendar, lastCalendar)) {
let newFocusedDate = toCalendar(focusedDate, calendar);
setStartDate(alignCenter(newFocusedDate, visibleDuration, locale, minValue, maxValue));
setFocusedDate(newFocusedDate);
setLastCalendarIdentifier(calendar.identifier);
setLastCalendar(calendar);
}

@@ -334,11 +337,10 @@

getDatesInWeek(weekIndex, from = startDate) {
// let date = startOfWeek(from, locale);
let date = from.add({weeks: weekIndex});
let dates: (CalendarDate | null)[] = [];
date = startOfWeek(date, locale);
date = startOfWeek(date, locale, firstDayOfWeek);
// startOfWeek will clamp dates within the calendar system's valid range, which may
// start in the middle of a week. In this case, add null placeholders.
let dayOfWeek = getDayOfWeek(date, locale);
let dayOfWeek = getDayOfWeek(date, locale, firstDayOfWeek);
for (let i = 0; i < dayOfWeek; i++) {

@@ -345,0 +347,0 @@ dates.push(null);

@@ -14,3 +14,3 @@ /*

import {alignCenter, constrainValue, isInvalid, previousAvailableDate} from './utils';
import {Calendar, CalendarDate, DateDuration, GregorianCalendar, isEqualDay, maxDate, minDate, toCalendar, toCalendarDate} from '@internationalized/date';
import {Calendar, CalendarDate, CalendarIdentifier, DateDuration, GregorianCalendar, isEqualDay, maxDate, minDate, toCalendar, toCalendarDate} from '@internationalized/date';
import {CalendarState, RangeCalendarState} from './types';

@@ -32,3 +32,3 @@ import {DateValue, MappedDateValue, RangeCalendarProps} from '@react-types/calendar';

*/
createCalendar: (name: string) => Calendar,
createCalendar: (name: CalendarIdentifier) => Calendar,
/**

@@ -35,0 +35,0 @@ * The amount of days that will be displayed at once. This affects how pagination works.

@@ -24,3 +24,3 @@ /*

export function isInvalid(date: DateValue, minValue?: DateValue | null, maxValue?: DateValue | null) {
export function isInvalid(date: DateValue, minValue?: DateValue | null, maxValue?: DateValue | null): boolean {
return (minValue != null && date.compare(minValue) < 0) ||

@@ -30,3 +30,3 @@ (maxValue != null && date.compare(maxValue) > 0);

export function alignCenter(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue | null, maxValue?: DateValue | null) {
export function alignCenter(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue | null, maxValue?: DateValue | null): CalendarDate {
let halfDuration: DateDuration = {};

@@ -44,3 +44,3 @@ for (let key in duration) {

export function alignStart(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue | null, maxValue?: DateValue | null) {
export function alignStart(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue | null, maxValue?: DateValue | null): CalendarDate {
// align to the start of the largest unit

@@ -59,3 +59,3 @@ let aligned = date;

export function alignEnd(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue | null, maxValue?: DateValue | null) {
export function alignEnd(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue | null, maxValue?: DateValue | null): CalendarDate {
let d = {...duration};

@@ -83,3 +83,3 @@ // subtract 1 from the smallest unit

minValue?: DateValue | null,
maxValue?: DateValue | null) {
maxValue?: DateValue | null): CalendarDate {
if (minValue && date.compare(minValue) >= 0) {

@@ -108,3 +108,3 @@ let newDate = maxDate(

export function constrainValue(date: CalendarDate, minValue?: DateValue | null, maxValue?: DateValue | null) {
export function constrainValue(date: CalendarDate, minValue?: DateValue | null, maxValue?: DateValue | null): CalendarDate {
if (minValue) {

@@ -111,0 +111,0 @@ let newDate = maxDate(date, toCalendarDate(minValue));

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet