Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS Strict Calendar #6076

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

TS Strict Calendar #6076

wants to merge 6 commits into from

Conversation

snowystinger
Copy link
Member

Closes

I need help figuring out useRangeCalendarState I'm getting caught up trying to get the types to work for useControlledState

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

@ishank-s
Copy link
Member

ishank-s commented Apr 9, 2024

hi can work on this if you 're not actively doing this.

@snowystinger
Copy link
Member Author

Thank you @ishank-s you're welcome to have a go at it

@ishank-s ishank-s mentioned this pull request Apr 14, 2024
5 tasks
@ishank-s
Copy link
Member

image

ishank-s and others added 2 commits May 13, 2024 18:35
# Conflicts:
#	packages/@react-stately/calendar/src/useCalendarState.ts
@rspbot
Copy link

rspbot commented May 13, 2024

@rspbot
Copy link

rspbot commented May 13, 2024

@rspbot
Copy link

rspbot commented May 13, 2024

## API Changes

unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any', access: 'private' }
unknown top level export { type: 'any', access: 'private' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'identifier', name: 'Column' }
unknown top level export { type: 'identifier', name: 'Column' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
unknown top level export { type: 'any' }
undefined already in set
undefined already in set

@internationalized/date

minDate

 minDate<A extends DateValue, B extends DateValue> {
-  a: A
-  b: B
+  a?: A
+  b?: B
   returnVal: undefined
 }

maxDate

 maxDate<A extends DateValue, B extends DateValue> {
-  a: A
-  b: B
+  a?: A
+  b?: B
   returnVal: undefined
 }

@react-aria/calendar

CalendarProps

-CalendarProps<T extends DateValue> {
-  autoFocus?: boolean = false
-  defaultFocusedValue?: DateValue
-  errorMessage?: ReactNode
-  focusedValue?: DateValue
-  isDateUnavailable?: (DateValue) => boolean
-  isDisabled?: boolean = false
-  isInvalid?: boolean
-  isReadOnly?: boolean = false
-  maxValue?: DateValue
-  minValue?: DateValue
-  onFocusChange?: (CalendarDate) => void
-  pageBehavior?: PageBehavior = visible
-}
+

RangeCalendarProps

-RangeCalendarProps<T extends DateValue> {
-  allowsNonContiguousRanges?: boolean
-  autoFocus?: boolean = false
-  defaultFocusedValue?: DateValue
-  errorMessage?: ReactNode
-  focusedValue?: DateValue
-  isDateUnavailable?: (DateValue) => boolean
-  isDisabled?: boolean = false
-  isInvalid?: boolean
-  isReadOnly?: boolean = false
-  maxValue?: DateValue
-  minValue?: DateValue
-  onFocusChange?: (CalendarDate) => void
-  pageBehavior?: PageBehavior = visible
-}
+

undefined

-
+CalendarProps<T extends DateValue | null> {
+  autoFocus?: boolean = false
+  defaultFocusedValue?: DateValue
+  errorMessage?: ReactNode
+  focusedValue?: DateValue
+  isDateUnavailable?: (DateValue) => boolean
+  isDisabled?: boolean = false
+  isInvalid?: boolean
+  isReadOnly?: boolean = false
+  maxValue?: DateValue
+  minValue?: DateValue
+  onFocusChange?: (CalendarDate) => void
+  pageBehavior?: PageBehavior = visible
+}

undefined

-
+RangeCalendarProps<T extends DateValue | null> {
+  allowsNonContiguousRanges?: boolean
+  autoFocus?: boolean = false
+  defaultFocusedValue?: DateValue
+  errorMessage?: ReactNode
+  focusedValue?: DateValue
+  isDateUnavailable?: (DateValue) => boolean
+  isDisabled?: boolean = false
+  isInvalid?: boolean
+  isReadOnly?: boolean = false
+  maxValue?: DateValue
+  minValue?: DateValue
+  onFocusChange?: (CalendarDate) => void
+  pageBehavior?: PageBehavior = visible
+}

@react-stately/calendar

CalendarStateOptions

-CalendarStateOptions<T extends DateValue = DateValue> {
-  createCalendar: (string) => Calendar
-  locale: string
-  selectionAlignment?: 'start' | 'center' | 'end'
-  visibleDuration?: DateDuration = {months: 1}
-}
+

it changed:

  • useCalendarState

RangeCalendarState

 RangeCalendarState {
   anchorDate: CalendarDate | null
   focusNextDay: () => void
   focusNextPage: () => void
   focusNextRow: () => void
   focusNextSection: (boolean) => void
   focusPreviousDay: () => void
   focusPreviousPage: () => void
   focusPreviousRow: () => void
   focusPreviousSection: (boolean) => void
   focusSectionEnd: () => void
   focusSectionStart: () => void
   focusedDate: CalendarDate
   getDatesInWeek: (number, CalendarDate) => Array<CalendarDate | null>
   highlightDate: (CalendarDate) => void
-  highlightedRange: RangeValue<CalendarDate>
+  highlightedRange: RangeValue<CalendarDate> | null
   isCellDisabled: (CalendarDate) => boolean
   isCellFocused: (CalendarDate) => boolean
   isCellUnavailable: (CalendarDate) => boolean
   isDisabled: boolean
   isDragging: boolean
   isFocused: boolean
   isInvalid: (CalendarDate) => boolean
   isNextVisibleRangeInvalid: () => boolean
   isPreviousVisibleRangeInvalid: () => boolean
   isReadOnly: boolean
   isSelected: (CalendarDate) => boolean
   isValueInvalid: boolean
   maxValue?: DateValue
   minValue?: DateValue
   selectDate: (CalendarDate) => void
   selectFocusedDate: () => void
   setAnchorDate: (CalendarDate | null) => void
   setDragging: (boolean) => void
   setFocused: (boolean) => void
   setFocusedDate: (CalendarDate) => void
-  setValue: (RangeValue<DateValue>) => void
+  setValue: (RangeValue<DateValue> | null) => void
   timeZone: string
-  value: RangeValue<DateValue>
+  value: RangeValue<DateValue> | null
   visibleRange: RangeValue<CalendarDate>
 }

undefined

-
+CalendarStateOptions<T extends DateValue> {
+  createCalendar: (string) => Calendar
+  locale: string
+  selectionAlignment?: 'start' | 'center' | 'end'
+  visibleDuration?: DateDuration = {months: 1}
+}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants