index
int64
0
0
repo_id
stringlengths
16
181
file_path
stringlengths
28
270
content
stringlengths
1
11.6M
__index_level_0__
int64
0
10k
0
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker/labels/labelDay.ts
import { format } from 'date-fns'; import { DayLabel } from 'types/Labels'; /** * The default ARIA label for the day button. */ export const labelDay: DayLabel = (day, activeModifiers, options): string => { return format(day, 'do MMMM (EEEE)', options); };
3,500
0
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker/labels/labelMonthDropdown.test.ts
import { labelMonthDropdown } from './labelMonthDropdown'; test('should return the label', () => { expect(labelMonthDropdown()).toEqual('Month: '); });
3,501
0
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker/labels/labelMonthDropdown.ts
/** * The default ARIA label for the WeekNumber element. */ export const labelMonthDropdown = (): string => { return 'Month: '; };
3,502
0
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker/labels/labelNext.test.ts
import { labelNext } from './labelNext'; test('should return the label', () => { expect(labelNext()).toEqual('Go to next month'); });
3,503
0
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker/labels/labelNext.ts
import { NavButtonLabel } from 'types/Labels'; /** * The default ARIA label for next month button in navigation */ export const labelNext: NavButtonLabel = (): string => { return 'Go to next month'; };
3,504
0
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker/labels/labelPrevious.test.ts
import { labelPrevious } from './labelPrevious'; test('should return the label', () => { expect(labelPrevious()).toEqual('Go to previous month'); });
3,505
0
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker/labels/labelPrevious.ts
import { NavButtonLabel } from 'types/Labels'; /** * The default ARIA label for previous month button in navigation */ export const labelPrevious: NavButtonLabel = (): string => { return 'Go to previous month'; };
3,506
0
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker/labels/labelWeekNumber.test.ts
import { labelWeekNumber } from './labelWeekNumber'; test('should return the label', () => { expect(labelWeekNumber(2)).toEqual('Week n. 2'); });
3,507
0
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker/labels/labelWeekNumber.ts
import { WeekNumberLabel } from 'types/Labels'; /** * The default ARIA label for the WeekNumber element. */ export const labelWeekNumber: WeekNumberLabel = (n): string => { return `Week n. ${n}`; };
3,508
0
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker/labels/labelWeekday.test.ts
import { es } from 'date-fns/locale'; import { labelWeekday } from './labelWeekday'; const weekDay = new Date(2022, 10, 21); test('should return the formatted weekday name', () => { expect(labelWeekday(weekDay)).toEqual('Monday'); }); describe('when a locale is passed in', () => { test('should format using the ...
3,509
0
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker/labels/labelWeekday.ts
import { format } from 'date-fns'; import { WeekdayLabel } from 'types/Labels'; /** * The default ARIA label for the Weekday element. */ export const labelWeekday: WeekdayLabel = (day, options): string => { return format(day, 'cccc', options); };
3,510
0
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker/labels/labelYearDropdown.test.ts
import { labelYearDropdown } from './labelYearDropdown'; test('should return the label', () => { expect(labelYearDropdown()).toEqual('Year: '); });
3,511
0
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker/labels/labelYearDropdown.ts
/** * The default ARIA label for the WeekNumber element. */ export const labelYearDropdown = (): string => { return 'Year: '; };
3,512
0
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker/utils/index.ts
export * from './parseFromToProps';
3,513
0
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker/utils/parseFromToProps.test.ts
import { parseFromToProps } from 'contexts/DayPicker/utils'; describe('when "fromMonth" is passed in', () => { const fromMonth = new Date(2021, 4, 3); const expectedFromDate = new Date(2021, 4, 1); const { fromDate } = parseFromToProps({ fromMonth }); test('"fromDate" should be the start of that month', () => ...
3,514
0
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker
petrpan-code/gpbl/react-day-picker/src/contexts/DayPicker/utils/parseFromToProps.ts
import { endOfMonth, startOfDay, startOfMonth } from 'date-fns'; import { DayPickerBase } from 'types/DayPickerBase'; /** Return the `fromDate` and `toDate` prop values values parsing the DayPicker props. */ export function parseFromToProps( props: Pick< DayPickerBase, 'fromYear' | 'toYear' | 'fromDate' | '...
3,515
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/Focus/FocusContext.test.ts
import { act } from '@testing-library/react'; import { addDays, addMonths, addWeeks, addYears, endOfWeek, startOfWeek } from 'date-fns'; import { renderDayPickerHook, RenderHookResult } from 'test/render'; import { freezeBeforeAll } from 'test/utils'; import { FocusContextValue, useFocusContext } from 'co...
3,516
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/Focus/FocusContext.tsx
import { createContext, ReactNode, useContext, useState } from 'react'; import { isSameDay } from 'date-fns'; import { useDayPicker } from 'contexts/DayPicker'; import { useModifiers } from '../Modifiers'; import { useNavigation } from '../Navigation'; import { getInitialFocusTarget } from './utils/getInitialFocusTa...
3,517
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/Focus/index.ts
export * from './FocusContext';
3,518
0
petrpan-code/gpbl/react-day-picker/src/contexts/Focus
petrpan-code/gpbl/react-day-picker/src/contexts/Focus/utils/getInitialFocusTarget.test.ts
import { Modifiers } from 'types/Modifiers'; import { getInitialFocusTarget } from './getInitialFocusTarget'; describe('when no days are selected is selected', () => { test('should return the first day of month', () => { const displayMonth = new Date(2022, 7); const modifiers: Modifiers = { outside: [...
3,519
0
petrpan-code/gpbl/react-day-picker/src/contexts/Focus
petrpan-code/gpbl/react-day-picker/src/contexts/Focus/utils/getInitialFocusTarget.ts
import { addDays, endOfMonth, startOfMonth } from 'date-fns'; import { getActiveModifiers } from 'contexts/Modifiers'; import { Modifiers } from 'types/Modifiers'; /** * Returns the day that should be the target of the focus when DayPicker is * rendered the first time. * * TODO: this function doesn't consider if ...
3,520
0
petrpan-code/gpbl/react-day-picker/src/contexts/Focus
petrpan-code/gpbl/react-day-picker/src/contexts/Focus/utils/getNextFocus.test.ts
/* eslint-disable jest/no-standalone-expect */ import { addDays, format, parseISO } from 'date-fns'; import { InternalModifier, InternalModifiers, Modifiers } from 'types/Modifiers'; import { FocusDayPickerContext, getNextFocus, MoveFocusBy, MoveFocusDirection } from './getNextFocus'; type test = { f...
3,521
0
petrpan-code/gpbl/react-day-picker/src/contexts/Focus
petrpan-code/gpbl/react-day-picker/src/contexts/Focus/utils/getNextFocus.ts
import { addDays, addMonths, addWeeks, addYears, endOfISOWeek, endOfWeek, max, min, startOfISOWeek, startOfWeek } from 'date-fns'; import { DayPickerContextValue } from 'contexts/DayPicker'; import { getActiveModifiers } from 'contexts/Modifiers'; import { Modifiers } from 'types/Modifiers'; expor...
3,522
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers/ModifiersContext.test.ts
import { DayPickerProps } from 'DayPicker'; import { renderDayPickerHook } from 'test/render'; import { useModifiers } from 'contexts/Modifiers'; import { DayModifiers, InternalModifier, Modifiers } from 'types/Modifiers'; const internalModifiers = Object.values(InternalModifier); function renderHook(dayPickerProps...
3,523
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers/ModifiersContext.tsx
import { createContext, useContext, ReactNode } from 'react'; import { useDayPicker } from 'contexts/DayPicker'; import { useSelectMultiple } from 'contexts/SelectMultiple'; import { useSelectRange } from 'contexts/SelectRange'; import { CustomModifiers, InternalModifiers, Modifiers } from 'types/Modifiers'; import {...
3,524
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers/index.ts
export * from './ModifiersContext'; export * from './utils/getActiveModifiers';
3,525
0
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers/utils/getActiveModifiers.test.ts
import { addMonths } from 'date-fns'; import { InternalModifier, InternalModifiers, Modifiers } from 'types/Modifiers'; import { getActiveModifiers } from './getActiveModifiers'; const day = new Date(); const internalModifiers: InternalModifiers = { [InternalModifier.Outside]: [], [InternalModifier.Disabl...
3,526
0
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers/utils/getActiveModifiers.ts
import { isSameMonth } from 'date-fns'; import { ActiveModifiers, Modifiers } from 'types/Modifiers'; import { isMatch } from './isMatch'; /** Return the active modifiers for the given day. */ export function getActiveModifiers( day: Date, /** The modifiers to match for the given date. */ modifiers: Modifiers,...
3,527
0
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers/utils/getCustomModifiers.test.ts
import { DayModifiers } from 'index'; import { getCustomModifiers } from './getCustomModifiers'; describe('when some modifiers are not an array', () => { const date = new Date(); const dayModifiers: DayModifiers = { foo: date }; const result = getCustomModifiers(dayModifiers); test('should return as arr...
3,528
0
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers/utils/getCustomModifiers.ts
import { CustomModifiers, DayModifiers } from 'types/Modifiers'; import { matcherToArray } from './matcherToArray'; /** Create CustomModifiers from dayModifiers */ export function getCustomModifiers( dayModifiers: DayModifiers ): CustomModifiers { const customModifiers: CustomModifiers = {}; Object.entries(dayM...
3,529
0
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers/utils/getInternalModifiers.test.ts
import { addDays } from 'date-fns'; import { DayPickerContextValue } from 'contexts/DayPicker'; import { getDefaultContextValues } from 'contexts/DayPicker/defaultContextValues'; import { SelectRangeContextValue } from 'contexts/SelectRange'; import { InternalModifier, InternalModifiers } from 'types/Modifiers'; impo...
3,530
0
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers/utils/getInternalModifiers.ts
import { DayPickerContextValue } from 'contexts/DayPicker'; import { SelectMultipleContextValue } from 'contexts/SelectMultiple'; import { SelectRangeContextValue } from 'contexts/SelectRange'; import { isDayPickerMultiple } from 'types/DayPickerMultiple'; import { isDayPickerRange } from 'types/DayPickerRange'; import...
3,531
0
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers/utils/isDateInRange.test.ts
import { addDays } from 'date-fns'; import { DateRange } from 'index'; import { isDateInRange } from './isDateInRange'; const date = new Date(); describe('when range is missing the "from" date', () => { const range: DateRange = { from: undefined }; const result = isDateInRange(date, range); test('should return...
3,532
0
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers/utils/isDateInRange.ts
import { differenceInCalendarDays, isSameDay } from 'date-fns'; import { DateRange } from 'types/Matchers'; /** Return `true` whether `date` is inside `range`. */ export function isDateInRange(date: Date, range: DateRange): boolean { let { from, to } = range; if (from && to) { const isRangeInverted = differen...
3,533
0
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers/utils/isMatch.test.ts
import { addDays, subDays } from 'date-fns'; import { DateAfter, DateBefore, DateInterval, DateRange, DayOfWeek } from 'types/Matchers'; import { isMatch } from './isMatch'; const testDay = new Date(); describe('when the matcher is a boolean', () => { const matcher = true; const result = isMatch(testD...
3,534
0
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers/utils/isMatch.ts
import { differenceInCalendarDays, isAfter, isDate, isSameDay } from 'date-fns'; import { isDateAfterType, isDateBeforeType, isDateInterval, isDateRange, isDayOfWeekType, Matcher } from 'types/Matchers'; import { isDateInRange } from './isDateInRange'; /** Returns true if `value` is a Date type. */ funct...
3,535
0
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers/utils/matcherToArray.test.ts
import { matcherToArray } from 'contexts/Modifiers/utils/matcherToArray'; import { Matcher } from 'types/Matchers'; const matcher: Matcher = jest.fn(); describe('when a Matcher is passed in', () => { test('should return an array with the Matcher', () => { expect(matcherToArray(matcher)).toStrictEqual([matcher])...
3,536
0
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers
petrpan-code/gpbl/react-day-picker/src/contexts/Modifiers/utils/matcherToArray.ts
import { Matcher } from 'types/Matchers'; /** Normalize to array a matcher input. */ export function matcherToArray( matcher: Matcher | Matcher[] | undefined ): Matcher[] { if (Array.isArray(matcher)) { return [...matcher]; } else if (matcher !== undefined) { return [matcher]; } else { return []; ...
3,537
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation/NavigationContext.test.ts
import { act } from '@testing-library/react'; import { addMonths, startOfMonth, subMonths } from 'date-fns'; import { DayPickerProps } from 'DayPicker'; import { renderDayPickerHook, RenderHookResult } from 'test/render'; import { freezeBeforeAll } from 'test/utils'; import { NavigationContextValue, useNavigation } f...
3,538
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation/NavigationContext.tsx
import { createContext, ReactNode, useContext } from 'react'; import { addMonths, isBefore, isSameMonth } from 'date-fns'; import { useDayPicker } from '../DayPicker'; import { useNavigationState } from './useNavigationState'; import { getDisplayMonths } from './utils/getDisplayMonths'; import { getNextMonth } from '...
3,539
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation/index.ts
export * from './NavigationContext';
3,540
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation/useNavigationState.test.ts
import { act } from '@testing-library/react'; import { addMonths, startOfMonth } from 'date-fns'; import { DayPickerProps } from 'DayPicker'; import { renderDayPickerHook } from 'test/render'; import { freezeBeforeAll } from 'test/utils'; import { NavigationState, useNavigationState } from './useNavigationState'; co...
3,541
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation/useNavigationState.ts
import { startOfMonth } from 'date-fns'; import { useDayPicker } from 'contexts/DayPicker'; import { useControlledValue } from 'hooks/useControlledValue'; import { getInitialMonth } from './utils/getInitialMonth'; export type NavigationState = [ /** The month DayPicker is navigating at */ month: Date, /** Go t...
3,542
0
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation/utils/getDisplayMonths.ts
import { addMonths, differenceInCalendarMonths, startOfMonth } from 'date-fns'; /** * Return the months to display in the component according to the number of * months and the from/to date. */ export function getDisplayMonths( month: Date, { reverseMonths, numberOfMonths }: { reverseMonths?: boole...
3,543
0
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation/utils/getInitialMonth.test.ts
import { addMonths, isSameMonth } from 'date-fns'; import { getInitialMonth } from './getInitialMonth'; describe('when no toDate is given', () => { describe('when month is in context', () => { const month = new Date(2010, 11, 12); it('return that month', () => { const initialMonth = getInitialMonth({ ...
3,544
0
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation/utils/getInitialMonth.ts
import { addMonths, differenceInCalendarMonths, startOfMonth } from 'date-fns'; import { DayPickerContextValue } from 'contexts/DayPicker'; /** Return the initial month according to the given options. */ export function getInitialMonth(context: Partial<DayPickerContextValue>): Date { const { month, defaultMonth, to...
3,545
0
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation/utils/getNextMonth.test.ts
import { addMonths, isSameMonth } from 'date-fns'; import { getNextMonth } from './getNextMonth'; const startingMonth = new Date(2020, 4, 31); describe('when number of months is 1', () => { describe('when the navigation is disabled', () => { const disableNavigation = true; it('the next month is undefined',...
3,546
0
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation/utils/getNextMonth.ts
import { addMonths, differenceInCalendarMonths, startOfMonth } from 'date-fns'; /** * Returns the next month the user can navigate to according to the given * options. * * Please note that the next month is not always the next calendar month: * * - if after the `toDate` range, is undefined; * - if the navigatio...
3,547
0
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation/utils/getPreviousMonth.test.ts
import { addMonths, isSameMonth } from 'date-fns'; import { getPreviousMonth } from './getPreviousMonth'; const startingMonth = new Date(2020, 4, 31); describe('when number of months is 1', () => { describe('when the navigation is disabled', () => { const disableNavigation = true; it('the previous month is...
3,548
0
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation
petrpan-code/gpbl/react-day-picker/src/contexts/Navigation/utils/getPreviousMonth.ts
import { addMonths, differenceInCalendarMonths, startOfMonth } from 'date-fns'; /** * Returns the next previous the user can navigate to, according to the given * options. * * Please note that the previous month is not always the previous calendar * month: * * - if before the `fromDate` date, is `undefined`; *...
3,549
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/SelectMultiple/SelectMultipleContext.test.ts
import { MouseEvent } from 'react'; import { addDays, addMonths } from 'date-fns'; import { DayPickerProps } from 'DayPicker'; import { renderDayPickerHook } from 'test/render'; import { freezeBeforeAll } from 'test/utils'; import { isMatch } from 'contexts/Modifiers/utils/isMatch'; import { DayPickerMultipleProps }...
3,550
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/SelectMultiple/SelectMultipleContext.tsx
import { createContext, ReactNode, useContext } from 'react'; import { isSameDay } from 'date-fns'; import { DayPickerBase } from 'types/DayPickerBase'; import { DayPickerMultipleProps, isDayPickerMultiple } from 'types/DayPickerMultiple'; import { DayClickEventHandler } from 'types/EventHandlers'; import { Inter...
3,551
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/SelectMultiple/index.ts
export * from './SelectMultipleContext';
3,552
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/SelectRange/SelectRangeContext.test.ts
import { MouseEvent } from 'react'; import { addDays, addMonths, differenceInCalendarDays, subDays } from 'date-fns'; import { DayPickerProps } from 'DayPicker'; import { renderDayPickerHook } from 'test/render'; import { freezeBeforeAll } from 'test/utils'; import { isMatch } from 'contexts/Modifiers/utils/...
3,553
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/SelectRange/SelectRangeContext.tsx
import { createContext, ReactNode, useContext } from 'react'; import { addDays, differenceInCalendarDays, isSameDay, subDays } from 'date-fns'; import { DayPickerBase } from 'types/DayPickerBase'; import { DayPickerRangeProps, isDayPickerRange } from 'types/DayPickerRange'; import { DayClickEventHandler } fro...
3,554
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/SelectRange/index.ts
export * from './SelectRangeContext';
3,555
0
petrpan-code/gpbl/react-day-picker/src/contexts/SelectRange
petrpan-code/gpbl/react-day-picker/src/contexts/SelectRange/utils/addToRange.test.ts
import { addDays, subDays } from 'date-fns'; import { DateRange } from 'types/Matchers'; import { addToRange } from './addToRange'; describe('when no "from" is the range', () => { const range = { from: undefined }; const day = new Date(); let result: DateRange | undefined; beforeAll(() => { result = addT...
3,556
0
petrpan-code/gpbl/react-day-picker/src/contexts/SelectRange
petrpan-code/gpbl/react-day-picker/src/contexts/SelectRange/utils/addToRange.ts
import { isAfter, isBefore, isSameDay } from 'date-fns'; import { DateRange } from 'types/Matchers'; /** * Add a day to an existing range. * * The returned range takes in account the `undefined` values and if the added * day is already present in the range. */ export function addToRange( day: Date, range?: D...
3,557
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/SelectSingle/SelectSingleContext.test.ts
import { MouseEvent } from 'react'; import { DayPickerProps } from 'DayPicker'; import { renderDayPickerHook } from 'test/render'; import { freezeBeforeAll } from 'test/utils'; import { DayPickerSingleProps } from 'types/DayPickerSingle'; import { ActiveModifiers } from 'types/Modifiers'; import { SelectSingleCon...
3,558
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/SelectSingle/SelectSingleContext.tsx
import { createContext, ReactNode, useContext } from 'react'; import { DayPickerBase } from 'types/DayPickerBase'; import { DayPickerSingleProps, isDayPickerSingle } from 'types/DayPickerSingle'; import { DayClickEventHandler } from 'types/EventHandlers'; /** Represents the value of a {@link SelectSingleContext}. */ ...
3,559
0
petrpan-code/gpbl/react-day-picker/src/contexts
petrpan-code/gpbl/react-day-picker/src/contexts/SelectSingle/index.ts
export * from './SelectSingleContext';
3,560
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useActiveModifiers/index.ts
export * from './useActiveModifiers';
3,561
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useActiveModifiers/useActiveModifiers.test.tsx
import { addMonths } from 'date-fns'; import { renderDayPickerHook } from 'test/render'; import { ActiveModifiers } from 'types/Modifiers'; import { useActiveModifiers } from './useActiveModifiers'; const date = new Date(2010, 5, 23); describe('when in the same month', () => { const displayMonth = date; test('...
3,562
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useActiveModifiers/useActiveModifiers.tsx
import { getActiveModifiers, useModifiers } from 'contexts/Modifiers'; import { ActiveModifiers } from 'types/Modifiers'; /** * Return the active modifiers for the specified day. * * This hook is meant to be used inside internal or custom components. * * @param day * @param displayMonth */ export function useAc...
3,563
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useControlledValue/index.ts
export * from './useControlledValue';
3,564
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useControlledValue/useControlledValue.test.ts
import { act } from 'react-dom/test-utils'; import { renderDayPickerHook } from 'test/render'; import { useControlledValue } from './useControlledValue'; function renderHook(defaultValue: string, controlledValue: string | undefined) { return renderDayPickerHook(() => useControlledValue<string>(defaultValue, co...
3,565
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useControlledValue/useControlledValue.ts
import { Dispatch, SetStateAction, useState } from 'react'; export type DispatchStateAction<T> = Dispatch<SetStateAction<T>>; /** * Helper hook for using controlled/uncontrolled values from a component props. * * When the value is not controlled, pass `undefined` as `controlledValue` and * use the returned setter...
3,566
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useDayEventHandlers/index.ts
export * from './useDayEventHandlers';
3,567
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useDayEventHandlers/useDayEventHandlers.test.tsx
import { DayPickerProps } from 'DayPicker'; import { mockedContexts } from 'test/mockedContexts'; import { renderDayPickerHook } from 'test/render'; import { FocusContextValue } from 'contexts/Focus'; import { DayEventName, EventName, useDayEventHandlers } from 'hooks/useDayEventHandlers'; import { ActiveModifi...
3,568
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useDayEventHandlers/useDayEventHandlers.tsx
import { FocusEventHandler, HTMLProps, KeyboardEventHandler, MouseEventHandler, PointerEventHandler, TouchEventHandler } from 'react'; import { useDayPicker } from 'contexts/DayPicker'; import { useFocusContext } from 'contexts/Focus'; import { useSelectMultiple } from 'contexts/SelectMultiple'; import { u...
3,569
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useDayRender/index.ts
export * from './useDayRender';
3,570
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useDayRender/useDayRender.test.tsx
import { createRef } from 'react'; import { addDays, addMonths } from 'date-fns'; import { DayPickerProps } from 'DayPicker'; import { mockedContexts } from 'test/mockedContexts'; import { renderDayPickerHook } from 'test/render'; import { freezeBeforeAll } from 'test/utils'; import { defaultClassNames } from 'conte...
3,571
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useDayRender/useDayRender.tsx
import { RefObject, useEffect } from 'react'; import { isSameDay } from 'date-fns'; import { ButtonProps } from 'components/Button'; import { DayContent } from 'components/DayContent'; import { useDayPicker } from 'contexts/DayPicker'; import { useFocusContext } from 'contexts/Focus'; import { useActiveModifiers } fr...
3,572
0
petrpan-code/gpbl/react-day-picker/src/hooks/useDayRender
petrpan-code/gpbl/react-day-picker/src/hooks/useDayRender/utils/getDayClassNames.test.ts
import { DayPickerContextValue } from 'contexts/DayPicker'; import { defaultClassNames } from 'contexts/DayPicker/defaultClassNames'; import { ActiveModifiers, InternalModifier } from 'types/Modifiers'; import { getDayClassNames } from './getDayClassNames'; type DayPickerOptions = Pick< DayPickerContextValue, 'mo...
3,573
0
petrpan-code/gpbl/react-day-picker/src/hooks/useDayRender
petrpan-code/gpbl/react-day-picker/src/hooks/useDayRender/utils/getDayClassNames.ts
import { DayPickerContextValue } from 'contexts/DayPicker'; import { ActiveModifiers, InternalModifier } from 'types/Modifiers'; function isInternalModifier(modifier: string): modifier is InternalModifier { return Object.values(InternalModifier).includes(modifier as InternalModifier); } /** * Return the class name...
3,574
0
petrpan-code/gpbl/react-day-picker/src/hooks/useDayRender
petrpan-code/gpbl/react-day-picker/src/hooks/useDayRender/utils/getDayStyle.ts
import { CSSProperties } from 'react'; import { DayPickerContextValue } from 'contexts/DayPicker'; import { ActiveModifiers } from 'types/Modifiers'; /** Return the style for the Day element, according to the given active modifiers. */ export function getDayStyle( dayPicker: Pick<DayPickerContextValue, 'modifiersSt...
3,575
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useId/index.ts
export * from './useId';
3,576
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useId/useId.ts
/* The MIT License (MIT) Copyright (c) 2018-present, React Training LLC 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, ...
3,577
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useId/useIsomorphicLayoutEffect.ts
import { useEffect, useLayoutEffect } from 'react'; import { canUseDOM } from './useId'; /** * React currently throws a warning when using useLayoutEffect on the server. To * get around it, we can conditionally useEffect on the server (no-op) and * useLayoutEffect in the browser. We occasionally need useLayoutEffe...
3,578
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useInput/index.ts
export * from './useInput';
3,579
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useInput/useInput.ts
import { ChangeEventHandler, FocusEventHandler, InputHTMLAttributes, useState } from 'react'; import { differenceInCalendarDays, format as _format, parse } from 'date-fns'; import { enUS } from 'date-fns/locale'; import { parseFromToProps } from 'contexts/DayPicker/utils'; import { DayPickerBase } from 'types...
3,580
0
petrpan-code/gpbl/react-day-picker/src/hooks/useInput
petrpan-code/gpbl/react-day-picker/src/hooks/useInput/utils/isValidDate.tsx
/** @private */ export function isValidDate(day: Date): boolean { return !isNaN(day.getTime()); }
3,581
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useSelectedDays/index.ts
export * from './useSelectedDays';
3,582
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useSelectedDays/useSelectedDays.test.ts
import { DayPickerProps } from 'DayPicker'; import { mockedContexts } from 'test/mockedContexts'; import { renderDayPickerHook } from 'test/render'; import { freezeBeforeAll } from 'test/utils'; import { useSelectedDays } from './useSelectedDays'; const today = new Date(2021, 11, 8); freezeBeforeAll(today); functio...
3,583
0
petrpan-code/gpbl/react-day-picker/src/hooks
petrpan-code/gpbl/react-day-picker/src/hooks/useSelectedDays/useSelectedDays.ts
import { useDayPicker } from 'contexts/DayPicker'; import { useSelectMultiple } from 'contexts/SelectMultiple'; import { useSelectRange } from 'contexts/SelectRange'; import { useSelectSingle } from 'contexts/SelectSingle'; import { isDayPickerMultiple } from 'types/DayPickerMultiple'; import { isDayPickerRange } from ...
3,584
0
petrpan-code/gpbl/react-day-picker/src
petrpan-code/gpbl/react-day-picker/src/types/DayPickerBase.ts
import { CSSProperties, ReactNode } from 'react'; import { Locale } from 'date-fns'; import { CaptionLayout, CaptionProps } from 'components/Caption'; import { CaptionLabelProps } from 'components/CaptionLabel'; import { DayProps } from 'components/Day'; import { DayContentProps } from 'components/DayContent'; import...
3,585
0
petrpan-code/gpbl/react-day-picker/src
petrpan-code/gpbl/react-day-picker/src/types/DayPickerDefault.ts
import { DayPickerProps } from 'DayPicker'; import { DayPickerBase } from './DayPickerBase'; /** The props for the {@link DayPicker} component when using `mode="default"` or `undefined`. */ export interface DayPickerDefaultProps extends DayPickerBase { mode?: undefined | 'default'; } /** Returns true when the prop...
3,586
0
petrpan-code/gpbl/react-day-picker/src
petrpan-code/gpbl/react-day-picker/src/types/DayPickerMultiple.ts
import { DayPickerProps } from 'DayPicker'; import { DayPickerContextValue } from 'contexts/DayPicker'; import { DayPickerBase } from './DayPickerBase'; import { SelectMultipleEventHandler } from './EventHandlers'; /** The props for the {@link DayPicker} component when using `mode="multiple"`. */ export interface Da...
3,587
0
petrpan-code/gpbl/react-day-picker/src
petrpan-code/gpbl/react-day-picker/src/types/DayPickerRange.ts
import { DayPickerProps } from 'DayPicker'; import { DayPickerContextValue } from 'contexts/DayPicker'; import { DayPickerBase } from './DayPickerBase'; import { SelectRangeEventHandler } from './EventHandlers'; import { DateRange } from './Matchers'; /** The props for the {@link DayPicker} component when using `mod...
3,588
0
petrpan-code/gpbl/react-day-picker/src
petrpan-code/gpbl/react-day-picker/src/types/DayPickerSingle.ts
import { DayPickerProps } from 'DayPicker'; import { DayPickerContextValue } from 'contexts/DayPicker'; import { DayPickerBase } from './DayPickerBase'; import { SelectSingleEventHandler } from './EventHandlers'; /** The props for the {@link DayPicker} component when using `mode="single"`. */ export interface DayPic...
3,589
0
petrpan-code/gpbl/react-day-picker/src
petrpan-code/gpbl/react-day-picker/src/types/EventHandlers.ts
import { FocusEvent, KeyboardEvent, MouseEvent, PointerEvent, TouchEvent } from 'react'; import { DateRange } from './Matchers'; import { ActiveModifiers } from './Modifiers'; /** The event handler when a day is clicked. */ export type DayClickEventHandler = ( day: Date, activeModifiers: ActiveModifier...
3,590
0
petrpan-code/gpbl/react-day-picker/src
petrpan-code/gpbl/react-day-picker/src/types/Formatters.ts
import { ReactNode } from 'react'; import { Locale } from 'date-fns'; /** Represents a function to format a date. */ export type DateFormatter = ( date: Date, options?: { locale?: Locale; } ) => ReactNode; /** Represent a map of formatters used to render localized content. */ export type Formatters = { /...
3,591
0
petrpan-code/gpbl/react-day-picker/src
petrpan-code/gpbl/react-day-picker/src/types/Labels.ts
import { Locale } from 'date-fns'; import { ActiveModifiers } from 'types/Modifiers'; /** Map of functions to translate ARIA labels for the relative elements. */ export type Labels = { labelMonthDropdown: () => string; labelYearDropdown: () => string; labelNext: NavButtonLabel; labelPrevious: NavButtonLabel; ...
3,592
0
petrpan-code/gpbl/react-day-picker/src
petrpan-code/gpbl/react-day-picker/src/types/Matchers.ts
/** * A value or a function that matches a specific day. * * * Matchers are passed to DayPicker via {@link DayPickerBase.disabled}, * {@link DayPickerBase.hidden]] or [[DayPickerProps.selected} and are used to * determine if a day should get a {@link Modifier}. * * Matchers can be of different types: * * ``` ...
3,593
0
petrpan-code/gpbl/react-day-picker/src
petrpan-code/gpbl/react-day-picker/src/types/Modifiers.ts
import { CSSProperties } from 'react'; import { Matcher } from './Matchers'; /** A _modifier_ represents different styles or states of a day displayed in the calendar. */ export type Modifier = string; /** The modifiers used by DayPicker. */ export type Modifiers = CustomModifiers & InternalModifiers; /** The name ...
3,594
0
petrpan-code/gpbl/react-day-picker/src
petrpan-code/gpbl/react-day-picker/src/types/Styles.ts
import { CSSProperties, ReactNode } from 'react'; /** The style (either via class names or via in-line styles) of an element. */ export type StyledElement<T = string | CSSProperties> = { /** The root element. */ readonly root: T; /** The root element when `numberOfMonths > 1`. */ readonly multiple_months: T; ...
3,595
0
petrpan-code/gpbl/react-day-picker
petrpan-code/gpbl/react-day-picker/test/mockedContexts.ts
import { FocusContextValue, SelectMultipleContextValue, SelectRangeContextValue, SelectSingleContextValue } from 'index'; const singleContext: SelectSingleContextValue = { selected: new Date(), onDayClick: jest.fn() }; const multipleContext: SelectMultipleContextValue = { selected: [new Date()], modif...
3,596
0
petrpan-code/gpbl/react-day-picker
petrpan-code/gpbl/react-day-picker/test/selectors.ts
import { screen } from '@testing-library/react'; import { format } from 'date-fns'; export function getDayButton(day: Date, index = 0) { return screen.getAllByRole('gridcell', { name: day.getDate().toString() })[index]; } export function getAllSelectedDays() { const buttons = screen .getByRole('grid') ...
3,597
0
petrpan-code/gpbl/react-day-picker
petrpan-code/gpbl/react-day-picker/test/setup.ts
import '@testing-library/jest-dom';
3,598
0
petrpan-code/gpbl/react-day-picker
petrpan-code/gpbl/react-day-picker/test/user.ts
import { userEvent } from '@testing-library/user-event'; export const user = userEvent.setup();
3,599