@salt-ds/lab 1.0.0-alpha.52 → 1.0.0-alpha.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/salt-lab.css +279 -38
- package/dist-cjs/breadcrumbs/internal/BreadcrumbsCollapsed.js +3 -2
- package/dist-cjs/breadcrumbs/internal/BreadcrumbsCollapsed.js.map +1 -1
- package/dist-cjs/calendar/Calendar.js +55 -26
- package/dist-cjs/calendar/Calendar.js.map +1 -1
- package/dist-cjs/calendar/CalendarDateGrid.css.js +6 -0
- package/dist-cjs/calendar/CalendarDateGrid.css.js.map +1 -0
- package/dist-cjs/calendar/{internal/CalendarCarousel.js → CalendarDateGrid.js} +37 -14
- package/dist-cjs/calendar/CalendarDateGrid.js.map +1 -0
- package/dist-cjs/calendar/CalendarNavigation.js +7 -5
- package/dist-cjs/calendar/CalendarNavigation.js.map +1 -1
- package/dist-cjs/calendar/{internal/CalendarWeekHeader.js → CalendarWeekHeader.js} +4 -3
- package/dist-cjs/calendar/CalendarWeekHeader.js.map +1 -0
- package/dist-cjs/calendar/internal/CalendarDay.css.js +1 -1
- package/dist-cjs/calendar/internal/CalendarMonth.js.map +1 -1
- package/dist-cjs/calendar/useCalendar.js +2 -4
- package/dist-cjs/calendar/useCalendar.js.map +1 -1
- package/dist-cjs/calendar/useCalendarSelection.js +16 -43
- package/dist-cjs/calendar/useCalendarSelection.js.map +1 -1
- package/dist-cjs/carousel/Carousel.js +5 -5
- package/dist-cjs/carousel/Carousel.js.map +1 -1
- package/dist-cjs/cascading-menu/CascadingMenuItem.js +2 -2
- package/dist-cjs/cascading-menu/CascadingMenuItem.js.map +1 -1
- package/dist-cjs/contact-details/ContactMetadata.js +2 -2
- package/dist-cjs/contact-details/ContactMetadata.js.map +1 -1
- package/dist-cjs/date-input/DateInputRange.js +2 -0
- package/dist-cjs/date-input/DateInputRange.js.map +1 -1
- package/dist-cjs/date-input/DateInputSingle.js +2 -0
- package/dist-cjs/date-input/DateInputSingle.js.map +1 -1
- package/dist-cjs/date-picker/DatePicker.js +40 -5
- package/dist-cjs/date-picker/DatePicker.js.map +1 -1
- package/dist-cjs/date-picker/DatePickerActions.js +7 -3
- package/dist-cjs/date-picker/DatePickerActions.js.map +1 -1
- package/dist-cjs/date-picker/DatePickerRangeInput.js +5 -4
- package/dist-cjs/date-picker/DatePickerRangeInput.js.map +1 -1
- package/dist-cjs/date-picker/DatePickerRangePanel.js +33 -9
- package/dist-cjs/date-picker/DatePickerRangePanel.js.map +1 -1
- package/dist-cjs/date-picker/DatePickerSingleInput.js +5 -4
- package/dist-cjs/date-picker/DatePickerSingleInput.js.map +1 -1
- package/dist-cjs/date-picker/DatePickerSinglePanel.js +19 -5
- package/dist-cjs/date-picker/DatePickerSinglePanel.js.map +1 -1
- package/dist-cjs/date-picker/useDatePicker.js +91 -63
- package/dist-cjs/date-picker/useDatePicker.js.map +1 -1
- package/dist-cjs/dropdown/DropdownButton.js +4 -2
- package/dist-cjs/dropdown/DropdownButton.js.map +1 -1
- package/dist-cjs/index.js +10 -0
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/menu-button/MenuButtonTrigger.js +2 -2
- package/dist-cjs/menu-button/MenuButtonTrigger.js.map +1 -1
- package/dist-cjs/query-input/internal/CategoryListItem.js +2 -2
- package/dist-cjs/query-input/internal/CategoryListItem.js.map +1 -1
- package/dist-cjs/query-input/internal/ValueList.js +2 -2
- package/dist-cjs/query-input/internal/ValueList.js.map +1 -1
- package/dist-cjs/search-input/SearchInput.js +2 -1
- package/dist-cjs/search-input/SearchInput.js.map +1 -1
- package/dist-cjs/static-list/StaticList.css.js +6 -0
- package/dist-cjs/static-list/StaticList.css.js.map +1 -0
- package/dist-cjs/static-list/StaticList.js +32 -0
- package/dist-cjs/static-list/StaticList.js.map +1 -0
- package/dist-cjs/static-list/StaticListItem.css.js +6 -0
- package/dist-cjs/static-list/StaticListItem.css.js.map +1 -0
- package/dist-cjs/static-list/StaticListItem.js +33 -0
- package/dist-cjs/static-list/StaticListItem.js.map +1 -0
- package/dist-cjs/static-list/StaticListItemContent.css.js +6 -0
- package/dist-cjs/static-list/StaticListItemContent.css.js.map +1 -0
- package/dist-cjs/static-list/StaticListItemContent.js +30 -0
- package/dist-cjs/static-list/StaticListItemContent.js.map +1 -0
- package/dist-cjs/stepped-tracker/TrackerStep/TrackerStep.js +8 -8
- package/dist-cjs/stepped-tracker/TrackerStep/TrackerStep.js.map +1 -1
- package/dist-cjs/stepper-input/StepperInput.css.js +1 -1
- package/dist-cjs/stepper-input/StepperInput.js +214 -29
- package/dist-cjs/stepper-input/StepperInput.js.map +1 -1
- package/dist-cjs/stepper-input/internal/useActivateWhileMouseDown.js +54 -0
- package/dist-cjs/stepper-input/internal/useActivateWhileMouseDown.js.map +1 -0
- package/dist-cjs/stepper-input/internal/utils.js +43 -0
- package/dist-cjs/stepper-input/internal/utils.js.map +1 -0
- package/dist-cjs/stepper-input/useStepperInput.js +88 -172
- package/dist-cjs/stepper-input/useStepperInput.js.map +1 -1
- package/dist-cjs/tabs/Tab.js +14 -12
- package/dist-cjs/tabs/Tab.js.map +1 -1
- package/dist-cjs/tabs/Tabstrip.js +2 -1
- package/dist-cjs/tabs/Tabstrip.js.map +1 -1
- package/dist-cjs/tabs-next/OverflowMenu.js +2 -2
- package/dist-cjs/tabs-next/OverflowMenu.js.map +1 -1
- package/dist-cjs/tokenized-input/TokenizedInputBase.js +3 -3
- package/dist-cjs/tokenized-input/TokenizedInputBase.js.map +1 -1
- package/dist-cjs/tokenized-input/internal/InputPill.js +2 -2
- package/dist-cjs/tokenized-input/internal/InputPill.js.map +1 -1
- package/dist-cjs/tokenized-input-next/TokenizedInputNext.js +3 -3
- package/dist-cjs/tokenized-input-next/TokenizedInputNext.js.map +1 -1
- package/dist-cjs/tokenized-input-next/internal/InputPill.js +2 -2
- package/dist-cjs/tokenized-input-next/internal/InputPill.js.map +1 -1
- package/dist-cjs/toolbar/overflow-panel/OverflowPanel.js +2 -2
- package/dist-cjs/toolbar/overflow-panel/OverflowPanel.js.map +1 -1
- package/dist-es/breadcrumbs/internal/BreadcrumbsCollapsed.js +3 -2
- package/dist-es/breadcrumbs/internal/BreadcrumbsCollapsed.js.map +1 -1
- package/dist-es/calendar/Calendar.js +57 -28
- package/dist-es/calendar/Calendar.js.map +1 -1
- package/dist-es/calendar/CalendarDateGrid.css.js +4 -0
- package/dist-es/calendar/CalendarDateGrid.css.js.map +1 -0
- package/dist-es/calendar/{internal/CalendarCarousel.js → CalendarDateGrid.js} +37 -14
- package/dist-es/calendar/CalendarDateGrid.js.map +1 -0
- package/dist-es/calendar/CalendarNavigation.js +8 -6
- package/dist-es/calendar/CalendarNavigation.js.map +1 -1
- package/dist-es/calendar/{internal/CalendarWeekHeader.js → CalendarWeekHeader.js} +4 -3
- package/dist-es/calendar/CalendarWeekHeader.js.map +1 -0
- package/dist-es/calendar/internal/CalendarDay.css.js +1 -1
- package/dist-es/calendar/internal/CalendarMonth.js.map +1 -1
- package/dist-es/calendar/useCalendar.js +2 -4
- package/dist-es/calendar/useCalendar.js.map +1 -1
- package/dist-es/calendar/useCalendarSelection.js +16 -43
- package/dist-es/calendar/useCalendarSelection.js.map +1 -1
- package/dist-es/carousel/Carousel.js +6 -6
- package/dist-es/carousel/Carousel.js.map +1 -1
- package/dist-es/cascading-menu/CascadingMenuItem.js +3 -3
- package/dist-es/cascading-menu/CascadingMenuItem.js.map +1 -1
- package/dist-es/contact-details/ContactMetadata.js +3 -3
- package/dist-es/contact-details/ContactMetadata.js.map +1 -1
- package/dist-es/date-input/DateInputRange.js +2 -0
- package/dist-es/date-input/DateInputRange.js.map +1 -1
- package/dist-es/date-input/DateInputSingle.js +2 -0
- package/dist-es/date-input/DateInputSingle.js.map +1 -1
- package/dist-es/date-picker/DatePicker.js +40 -5
- package/dist-es/date-picker/DatePicker.js.map +1 -1
- package/dist-es/date-picker/DatePickerActions.js +7 -3
- package/dist-es/date-picker/DatePickerActions.js.map +1 -1
- package/dist-es/date-picker/DatePickerRangeInput.js +5 -4
- package/dist-es/date-picker/DatePickerRangeInput.js.map +1 -1
- package/dist-es/date-picker/DatePickerRangePanel.js +33 -9
- package/dist-es/date-picker/DatePickerRangePanel.js.map +1 -1
- package/dist-es/date-picker/DatePickerSingleInput.js +5 -4
- package/dist-es/date-picker/DatePickerSingleInput.js.map +1 -1
- package/dist-es/date-picker/DatePickerSinglePanel.js +19 -5
- package/dist-es/date-picker/DatePickerSinglePanel.js.map +1 -1
- package/dist-es/date-picker/useDatePicker.js +92 -64
- package/dist-es/date-picker/useDatePicker.js.map +1 -1
- package/dist-es/dropdown/DropdownButton.js +6 -4
- package/dist-es/dropdown/DropdownButton.js.map +1 -1
- package/dist-es/index.js +5 -0
- package/dist-es/index.js.map +1 -1
- package/dist-es/menu-button/MenuButtonTrigger.js +3 -3
- package/dist-es/menu-button/MenuButtonTrigger.js.map +1 -1
- package/dist-es/query-input/internal/CategoryListItem.js +3 -3
- package/dist-es/query-input/internal/CategoryListItem.js.map +1 -1
- package/dist-es/query-input/internal/ValueList.js +3 -3
- package/dist-es/query-input/internal/ValueList.js.map +1 -1
- package/dist-es/search-input/SearchInput.js +3 -2
- package/dist-es/search-input/SearchInput.js.map +1 -1
- package/dist-es/static-list/StaticList.css.js +4 -0
- package/dist-es/static-list/StaticList.css.js.map +1 -0
- package/dist-es/static-list/StaticList.js +28 -0
- package/dist-es/static-list/StaticList.js.map +1 -0
- package/dist-es/static-list/StaticListItem.css.js +4 -0
- package/dist-es/static-list/StaticListItem.css.js.map +1 -0
- package/dist-es/static-list/StaticListItem.js +29 -0
- package/dist-es/static-list/StaticListItem.js.map +1 -0
- package/dist-es/static-list/StaticListItemContent.css.js +4 -0
- package/dist-es/static-list/StaticListItemContent.css.js.map +1 -0
- package/dist-es/static-list/StaticListItemContent.js +26 -0
- package/dist-es/static-list/StaticListItemContent.js.map +1 -0
- package/dist-es/stepped-tracker/TrackerStep/TrackerStep.js +9 -9
- package/dist-es/stepped-tracker/TrackerStep/TrackerStep.js.map +1 -1
- package/dist-es/stepper-input/StepperInput.css.js +1 -1
- package/dist-es/stepper-input/StepperInput.js +216 -31
- package/dist-es/stepper-input/StepperInput.js.map +1 -1
- package/dist-es/stepper-input/internal/useActivateWhileMouseDown.js +50 -0
- package/dist-es/stepper-input/internal/useActivateWhileMouseDown.js.map +1 -0
- package/dist-es/stepper-input/internal/utils.js +32 -0
- package/dist-es/stepper-input/internal/utils.js.map +1 -0
- package/dist-es/stepper-input/useStepperInput.js +88 -172
- package/dist-es/stepper-input/useStepperInput.js.map +1 -1
- package/dist-es/tabs/Tab.js +15 -13
- package/dist-es/tabs/Tab.js.map +1 -1
- package/dist-es/tabs/Tabstrip.js +4 -3
- package/dist-es/tabs/Tabstrip.js.map +1 -1
- package/dist-es/tabs-next/OverflowMenu.js +3 -3
- package/dist-es/tabs-next/OverflowMenu.js.map +1 -1
- package/dist-es/tokenized-input/TokenizedInputBase.js +3 -3
- package/dist-es/tokenized-input/TokenizedInputBase.js.map +1 -1
- package/dist-es/tokenized-input/internal/InputPill.js +2 -2
- package/dist-es/tokenized-input/internal/InputPill.js.map +1 -1
- package/dist-es/tokenized-input-next/TokenizedInputNext.js +3 -3
- package/dist-es/tokenized-input-next/TokenizedInputNext.js.map +1 -1
- package/dist-es/tokenized-input-next/internal/InputPill.js +2 -2
- package/dist-es/tokenized-input-next/internal/InputPill.js.map +1 -1
- package/dist-es/toolbar/overflow-panel/OverflowPanel.js +3 -3
- package/dist-es/toolbar/overflow-panel/OverflowPanel.js.map +1 -1
- package/dist-types/calendar/Calendar.d.ts +2 -15
- package/dist-types/calendar/CalendarDateGrid.d.ts +10 -0
- package/dist-types/calendar/{internal/CalendarWeekHeader.d.ts → CalendarWeekHeader.d.ts} +1 -1
- package/dist-types/calendar/index.d.ts +2 -0
- package/dist-types/calendar/internal/CalendarMonth.d.ts +9 -1
- package/dist-types/calendar/useCalendarSelection.d.ts +0 -7
- package/dist-types/date-picker/DatePickerRangePanel.d.ts +17 -1
- package/dist-types/date-picker/DatePickerSinglePanel.d.ts +9 -1
- package/dist-types/index.d.ts +1 -0
- package/dist-types/static-list/StaticList.d.ts +8 -0
- package/dist-types/static-list/StaticListItem.d.ts +4 -0
- package/dist-types/static-list/StaticListItemContent.d.ts +8 -0
- package/dist-types/static-list/index.d.ts +3 -0
- package/dist-types/stepper-input/StepperInput.d.ts +66 -19
- package/dist-types/stepper-input/internal/useActivateWhileMouseDown.d.ts +5 -0
- package/dist-types/stepper-input/internal/utils.d.ts +8 -0
- package/dist-types/stepper-input/useStepperInput.d.ts +21 -8
- package/package.json +2 -2
- package/dist-cjs/calendar/internal/CalendarCarousel.css.js +0 -6
- package/dist-cjs/calendar/internal/CalendarCarousel.css.js.map +0 -1
- package/dist-cjs/calendar/internal/CalendarCarousel.js.map +0 -1
- package/dist-cjs/calendar/internal/CalendarWeekHeader.js.map +0 -1
- package/dist-cjs/stepper-input/internal/useSpinner.js +0 -33
- package/dist-cjs/stepper-input/internal/useSpinner.js.map +0 -1
- package/dist-es/calendar/internal/CalendarCarousel.css.js +0 -4
- package/dist-es/calendar/internal/CalendarCarousel.css.js.map +0 -1
- package/dist-es/calendar/internal/CalendarCarousel.js.map +0 -1
- package/dist-es/calendar/internal/CalendarWeekHeader.js.map +0 -1
- package/dist-es/stepper-input/internal/useSpinner.js +0 -29
- package/dist-es/stepper-input/internal/useSpinner.js.map +0 -1
- package/dist-types/calendar/internal/CalendarCarousel.d.ts +0 -3
- package/dist-types/stepper-input/internal/useSpinner.d.ts +0 -5
- /package/dist-cjs/calendar/{internal/CalendarWeekHeader.css.js → CalendarWeekHeader.css.js} +0 -0
- /package/dist-cjs/calendar/{internal/CalendarWeekHeader.css.js.map → CalendarWeekHeader.css.js.map} +0 -0
- /package/dist-es/calendar/{internal/CalendarWeekHeader.css.js → CalendarWeekHeader.css.js} +0 -0
- /package/dist-es/calendar/{internal/CalendarWeekHeader.css.js.map → CalendarWeekHeader.css.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCalendar.js","sources":["../src/calendar/useCalendar.ts"],"sourcesContent":["import {\n type DateValue,\n endOfMonth,\n endOfYear,\n getLocalTimeZone,\n isSameDay,\n isSameMonth,\n startOfMonth,\n startOfYear,\n today,\n} from \"@internationalized/date\";\nimport { useControlled } from \"@salt-ds/core\";\nimport {\n type SyntheticEvent,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport { getCurrentLocale } from \"./formatDate\";\nimport { generateDatesForMonth } from \"./internal/utils\";\nimport {\n type UseCalendarSelectionMultiSelectProps,\n type UseCalendarSelectionOffsetProps,\n type UseCalendarSelectionProps,\n type UseCalendarSelectionRangeProps,\n type UseCalendarSelectionSingleProps,\n isDateRangeSelection,\n useCalendarSelection,\n} from \"./useCalendarSelection\";\n\n/**\n * Interface representing the base properties UseCalendar hook.\n */\ninterface UseCalendarBaseProps {\n /**\n * The default visible month.\n */\n defaultVisibleMonth?: DateValue;\n /**\n * Callback fired when the visible month changes.\n * @param event - The synthetic event.\n * @param visibleMonth - The new visible month.\n */\n onVisibleMonthChange?: (\n event: SyntheticEvent,\n visibleMonth: DateValue,\n ) => void;\n /**\n * Function to determine if a day is unselectable.\n * @param date - The date to check.\n * @returns A string reason if the day is unselectable, otherwise `false` or `undefined`.\n */\n isDayUnselectable?: (date: DateValue) => string | false | undefined;\n /**\n * Function to determine if a day is highlighted.\n * @param date - The date to check.\n * @returns A string reason if the day is highlighted, otherwise `false` or `undefined`.\n */\n isDayHighlighted?: (date: DateValue) => string | false | undefined;\n /**\n * Function to determine if a day is disabled.\n * @param date - The date to check.\n * @returns A string reason if the day is disabled, otherwise `false` or `undefined`.\n */\n isDayDisabled?: (date: DateValue) => string | false | undefined;\n /**\n * The currently visible month.\n */\n visibleMonth?: DateValue;\n /**\n * If `true`, hides dates that are out of the selectable range.\n */\n hideOutOfRangeDates?: boolean;\n /**\n * The minimum selectable date.\n */\n minDate?: DateValue;\n /**\n * The maximum selectable date.\n */\n maxDate?: DateValue;\n /**\n * The time zone used for date calculations.\n */\n timeZone?: string;\n /**\n * The locale used for date formatting.\n */\n locale?: string;\n}\n\n/**\n * UseCalendar hook props for a single date selection Calendar.\n */\nexport interface UseCalendarSingleProps\n extends UseCalendarSelectionSingleProps,\n UseCalendarBaseProps {\n /**\n * The selection variant, set to \"single\".\n */\n selectionVariant: \"single\";\n}\n\n/**\n * UseCalendar hook props for a date range selection Calendar.\n */\nexport interface UseCalendarRangeProps\n extends UseCalendarSelectionRangeProps,\n UseCalendarBaseProps {\n /**\n * The selection variant, set to \"range\".\n */\n selectionVariant: \"range\";\n}\n\n/**\n * UseCalendar hook props for a multi-select Calendar.\n */\nexport interface UseCalendarMultiSelectProps\n extends UseCalendarSelectionMultiSelectProps,\n UseCalendarBaseProps {\n /**\n * The selection variant, set to \"multiselect\".\n */\n selectionVariant: \"multiselect\";\n}\n\n/**\n * UseCalendar hook props for an offset date selection Calendar.\n */\nexport interface UseCalendarOffsetProps\n extends UseCalendarSelectionOffsetProps,\n UseCalendarBaseProps {\n /**\n * The selection variant, set to \"offset\".\n */\n selectionVariant: \"offset\";\n}\n\n/**\n * UseCalendar hook props, wth the selection variant determining the return type of the date selection\n */\nexport type UseCalendarProps =\n | UseCalendarSingleProps\n | UseCalendarRangeProps\n | UseCalendarMultiSelectProps\n | UseCalendarOffsetProps;\n\n/**\n * Default function to determine if a day is unselectable.\n * @returns `false` indicating the day is selectable.\n */\nconst defaultIsDayUnselectable = (): string | false => false;\n\n/**\n * Default function to determine if a day is highlighted.\n * @returns `false` indicating the day is not highlighted.\n */\nconst defaultIsDayHighlighted = (): string | false => false;\n\n/**\n * Default function to determine if a day is disabled.\n * @returns `false` indicating the day is not disabled.\n */\nconst defaultIsDayDisabled = (): false => false;\n\nexport function useCalendar(props: UseCalendarProps) {\n const {\n selectedDate,\n defaultSelectedDate,\n visibleMonth: visibleMonthProp,\n hideOutOfRangeDates,\n timeZone = getLocalTimeZone(),\n locale = getCurrentLocale(),\n defaultVisibleMonth = today(timeZone),\n onSelectedDateChange,\n onVisibleMonthChange,\n isDayUnselectable = defaultIsDayUnselectable,\n isDayHighlighted = defaultIsDayHighlighted,\n isDayDisabled = defaultIsDayDisabled,\n minDate,\n maxDate,\n selectionVariant,\n onHoveredDateChange,\n hoveredDate,\n select,\n // startDateOffset,\n // endDateOffset,\n } = props;\n const [visibleMonth, setVisibleMonthState] = useControlled({\n controlled: visibleMonthProp ? startOfMonth(visibleMonthProp) : undefined,\n default: startOfMonth(defaultVisibleMonth),\n name: \"Calendar\",\n state: \"visibleMonth\",\n });\n\n const isOutsideAllowedDates = useCallback(\n (date: DateValue) => {\n return (\n (minDate && date.compare(minDate) < 0) ||\n (maxDate && date.compare(maxDate) > 0)\n );\n },\n [maxDate, minDate],\n );\n\n const isOutsideAllowedMonths = useCallback(\n (date: DateValue) => {\n return (\n (minDate && endOfMonth(date).compare(minDate) < 0) ||\n (maxDate && startOfMonth(date).compare(maxDate) > 0)\n );\n },\n [minDate, maxDate],\n );\n\n const isOutsideAllowedYears = useCallback(\n (date: DateValue) => {\n return (\n (minDate && endOfYear(date).compare(minDate) < 0) ||\n (maxDate && startOfYear(date).compare(maxDate) > 0)\n );\n },\n [minDate, maxDate],\n );\n\n const isDaySelectable = useCallback(\n (date?: DateValue) =>\n !(\n date &&\n (isDayUnselectable(date) ||\n isDayDisabled(date) ||\n isOutsideAllowedDates(date))\n ),\n [isDayUnselectable, isDayDisabled, isOutsideAllowedDates],\n );\n\n const selectionManager = useCalendarSelection({\n defaultSelectedDate: defaultSelectedDate,\n selectedDate,\n onSelectedDateChange,\n startDateOffset:\n props.selectionVariant === \"offset\" ? props.startDateOffset : undefined,\n endDateOffset:\n props.selectionVariant === \"offset\" ? props.endDateOffset : undefined,\n isDaySelectable,\n selectionVariant,\n onHoveredDateChange,\n hoveredDate,\n select,\n } as UseCalendarSelectionProps);\n\n const [calendarFocused, setCalendarFocused] = useState(false);\n\n const isInVisibleMonth = useCallback(\n (date: DateValue | undefined | null): date is DateValue =>\n date != null && isSameMonth(date, visibleMonth),\n [visibleMonth],\n );\n\n const getInitialFocusedDate = useCallback(() => {\n const selectedDate = selectionManager.state.selectedDate;\n if (\n (selectionVariant === \"range\" || selectionVariant === \"offset\") &&\n isDateRangeSelection(selectedDate)\n ) {\n if (isInVisibleMonth(selectedDate?.startDate)) {\n return selectedDate.startDate;\n }\n if (isInVisibleMonth(selectedDate?.endDate)) {\n return selectedDate.endDate;\n }\n } else if (\n selectionVariant === \"multiselect\" &&\n Array.isArray(selectedDate)\n ) {\n // return first selected day in visible month\n const selectionInMonth = selectedDate\n .filter((day) => isInVisibleMonth(day))\n .sort((a, b) => a.compare(b));\n if (selectionInMonth.length > 0) {\n return selectionInMonth[0];\n }\n } else if (\n selectionVariant === \"single\" &&\n !isDateRangeSelection(selectedDate) &&\n !Array.isArray(selectedDate) &&\n isInVisibleMonth(selectedDate)\n ) {\n return selectedDate;\n }\n // Defaults\n if (isDaySelectable(today(timeZone)) && isInVisibleMonth(today(timeZone))) {\n return today(timeZone);\n }\n const firstSelectableDate = generateDatesForMonth(visibleMonth).find(\n (visibleDay) => isDaySelectable(visibleDay),\n );\n if (firstSelectableDate) {\n return firstSelectableDate;\n }\n return null;\n }, [\n isInVisibleMonth,\n selectionVariant,\n selectionManager.state.selectedDate,\n timeZone,\n visibleMonth,\n ]);\n\n const [focusedDate, setFocusedDateState] = useState<DateValue | null>(\n getInitialFocusedDate,\n );\n\n const isDayVisible = useCallback(\n (date: DateValue) => {\n const startInsideDays = startOfMonth(visibleMonth);\n\n if (date.compare(startInsideDays) < 0) return false;\n\n const endInsideDays = endOfMonth(visibleMonth);\n\n return !(date.compare(endInsideDays) > 0);\n },\n [visibleMonth],\n );\n\n const setVisibleMonth = useCallback(\n (event: SyntheticEvent, newVisibleMonth: DateValue) => {\n setVisibleMonthState(newVisibleMonth);\n onVisibleMonthChange?.(event, newVisibleMonth);\n },\n [onVisibleMonthChange],\n );\n\n const setFocusedDate = useCallback(\n (event: SyntheticEvent, date: DateValue) => {\n if (\n !focusedDate ||\n isSameDay(date, focusedDate) ||\n isOutsideAllowedDates(date)\n )\n return;\n\n setFocusedDateState(date);\n\n const shouldTransition =\n !isDayVisible(date) &&\n isDaySelectable(date) &&\n !isOutsideAllowedDates(date);\n if (shouldTransition) {\n setVisibleMonth(event, startOfMonth(date));\n }\n },\n [\n focusedDate,\n isDaySelectable,\n isDayVisible,\n isOutsideAllowedDates,\n setVisibleMonth,\n ],\n );\n\n useEffect(() => {\n if (visibleMonth && focusedDate && !isDayVisible(focusedDate)) {\n const focusableDate = getInitialFocusedDate();\n if (focusableDate) {\n setFocusedDateState(focusableDate);\n }\n }\n }, [isDayVisible, focusedDate, getInitialFocusedDate, visibleMonth]);\n\n return useMemo(\n () => ({\n state: {\n visibleMonth,\n focusedDate,\n minDate,\n maxDate,\n selectionVariant,\n hideOutOfRangeDates,\n calendarFocused,\n timeZone,\n locale,\n ...selectionManager.state,\n },\n helpers: {\n setVisibleMonth,\n setFocusedDate,\n setCalendarFocused,\n isDayUnselectable,\n isDayHighlighted,\n isDayDisabled,\n isDayVisible,\n isOutsideAllowedDates,\n isOutsideAllowedMonths,\n isOutsideAllowedYears,\n ...selectionManager.helpers,\n },\n }),\n [\n visibleMonth,\n focusedDate,\n minDate,\n maxDate,\n selectionVariant,\n hideOutOfRangeDates,\n calendarFocused,\n timeZone,\n locale,\n setVisibleMonth,\n setFocusedDate,\n isDayUnselectable,\n isDayHighlighted,\n isDayDisabled,\n isDayVisible,\n isOutsideAllowedDates,\n isOutsideAllowedMonths,\n isOutsideAllowedYears,\n selectionManager,\n ],\n );\n}\n"],"names":["selectedDate"],"mappings":";;;;;;;AAyJA,MAAM,2BAA2B,MAAsB,KAAA,CAAA;AAMvD,MAAM,0BAA0B,MAAsB,KAAA,CAAA;AAMtD,MAAM,uBAAuB,MAAa,KAAA,CAAA;AAEnC,SAAS,YAAY,KAAyB,EAAA;AACnD,EAAM,MAAA;AAA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QACA,OAAA;AAAA,QACA,OAAA;AAAA,QACA,gBAAA;AAAA,QACA,mBAAA;AAAA,QACA,eAAA;AAAA,QACA,QAAA;AAAA,QACA,MAAA;AAAA,QACA,GAAG,gBAAiB,CAAA,KAAA;AAAA,OACtB;AAAA,MACA,OAAS,EAAA;AAAA,QACP,eAAA;AAAA,QACA,cAAA;AAAA,QACA,kBAAA;AAAA,QACA,iBAAA;AAAA,QACA,gBAAA;AAAA,QACA,aAAA;AAAA,QACA,YAAA;AAAA,QACA,qBAAA;AAAA,QACA,sBAAA;AAAA,QACA,qBAAA;AAAA,QACA,GAAG,gBAAiB,CAAA,OAAA;AAAA,OACtB;AAAA,KACF,CAAA;AAAA,IACA;AAAA,MACE,YAAA;AAAA,MACA,WAAA;AAAA,MACA,OAAA;AAAA,MACA,OAAA;AAAA,MACA,gBAAA;AAAA,MACA,mBAAA;AAAA,MACA,eAAA;AAAA,MACA,QAAA;AAAA,MACA,MAAA;AAAA,MACA,eAAA;AAAA,MACA,cAAA;AAAA,MACA,iBAAA;AAAA,MACA,gBAAA;AAAA,MACA,aAAA;AAAA,MACA,YAAA;AAAA,MACA,qBAAA;AAAA,MACA,sBAAA;AAAA,MACA,qBAAA;AAAA,MACA,gBAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"useCalendar.js","sources":["../src/calendar/useCalendar.ts"],"sourcesContent":["import {\n type DateValue,\n endOfMonth,\n endOfYear,\n getLocalTimeZone,\n isSameDay,\n isSameMonth,\n startOfMonth,\n startOfYear,\n today,\n} from \"@internationalized/date\";\nimport { useControlled } from \"@salt-ds/core\";\nimport {\n type SyntheticEvent,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport { getCurrentLocale } from \"./formatDate\";\nimport { generateDatesForMonth } from \"./internal/utils\";\nimport {\n type UseCalendarSelectionMultiSelectProps,\n type UseCalendarSelectionOffsetProps,\n type UseCalendarSelectionProps,\n type UseCalendarSelectionRangeProps,\n type UseCalendarSelectionSingleProps,\n isDateRangeSelection,\n useCalendarSelection,\n} from \"./useCalendarSelection\";\n\n/**\n * Interface representing the base properties UseCalendar hook.\n */\ninterface UseCalendarBaseProps {\n /**\n * The default visible month.\n */\n defaultVisibleMonth?: DateValue;\n /**\n * Callback fired when the visible month changes.\n * @param event - The synthetic event.\n * @param visibleMonth - The new visible month.\n */\n onVisibleMonthChange?: (\n event: SyntheticEvent,\n visibleMonth: DateValue,\n ) => void;\n /**\n * Function to determine if a day is unselectable.\n * @param date - The date to check.\n * @returns A string reason if the day is unselectable, otherwise `false` or `undefined`.\n */\n isDayUnselectable?: (date: DateValue) => string | false | undefined;\n /**\n * Function to determine if a day is highlighted.\n * @param date - The date to check.\n * @returns A string reason if the day is highlighted, otherwise `false` or `undefined`.\n */\n isDayHighlighted?: (date: DateValue) => string | false | undefined;\n /**\n * Function to determine if a day is disabled.\n * @param date - The date to check.\n * @returns A string reason if the day is disabled, otherwise `false` or `undefined`.\n */\n isDayDisabled?: (date: DateValue) => string | false | undefined;\n /**\n * The currently visible month.\n */\n visibleMonth?: DateValue;\n /**\n * If `true`, hides dates that are out of the selectable range.\n */\n hideOutOfRangeDates?: boolean;\n /**\n * The minimum selectable date.\n */\n minDate?: DateValue;\n /**\n * The maximum selectable date.\n */\n maxDate?: DateValue;\n /**\n * The time zone used for date calculations.\n */\n timeZone?: string;\n /**\n * The locale used for date formatting.\n */\n locale?: string;\n}\n\n/**\n * UseCalendar hook props for a single date selection Calendar.\n */\nexport interface UseCalendarSingleProps\n extends UseCalendarSelectionSingleProps,\n UseCalendarBaseProps {\n /**\n * The selection variant, set to \"single\".\n */\n selectionVariant: \"single\";\n}\n\n/**\n * UseCalendar hook props for a date range selection Calendar.\n */\nexport interface UseCalendarRangeProps\n extends UseCalendarSelectionRangeProps,\n UseCalendarBaseProps {\n /**\n * The selection variant, set to \"range\".\n */\n selectionVariant: \"range\";\n}\n\n/**\n * UseCalendar hook props for a multi-select Calendar.\n */\nexport interface UseCalendarMultiSelectProps\n extends UseCalendarSelectionMultiSelectProps,\n UseCalendarBaseProps {\n /**\n * The selection variant, set to \"multiselect\".\n */\n selectionVariant: \"multiselect\";\n}\n\n/**\n * UseCalendar hook props for an offset date selection Calendar.\n */\nexport interface UseCalendarOffsetProps\n extends UseCalendarSelectionOffsetProps,\n UseCalendarBaseProps {\n /**\n * The selection variant, set to \"offset\".\n */\n selectionVariant: \"offset\";\n}\n\n/**\n * UseCalendar hook props, wth the selection variant determining the return type of the date selection\n */\nexport type UseCalendarProps =\n | UseCalendarSingleProps\n | UseCalendarRangeProps\n | UseCalendarMultiSelectProps\n | UseCalendarOffsetProps;\n\n/**\n * Default function to determine if a day is unselectable.\n * @returns `false` indicating the day is selectable.\n */\nconst defaultIsDayUnselectable = (): string | false => false;\n\n/**\n * Default function to determine if a day is highlighted.\n * @returns `false` indicating the day is not highlighted.\n */\nconst defaultIsDayHighlighted = (): string | false => false;\n\n/**\n * Default function to determine if a day is disabled.\n * @returns `false` indicating the day is not disabled.\n */\nconst defaultIsDayDisabled = (): false => false;\n\nexport function useCalendar(props: UseCalendarProps) {\n const {\n selectedDate,\n defaultSelectedDate,\n visibleMonth: visibleMonthProp,\n hideOutOfRangeDates,\n timeZone = getLocalTimeZone(),\n locale = getCurrentLocale(),\n defaultVisibleMonth = today(timeZone),\n onSelectedDateChange,\n onVisibleMonthChange,\n isDayUnselectable = defaultIsDayUnselectable,\n isDayHighlighted = defaultIsDayHighlighted,\n isDayDisabled = defaultIsDayDisabled,\n minDate,\n maxDate,\n selectionVariant,\n onHoveredDateChange,\n hoveredDate,\n // startDateOffset,\n // endDateOffset,\n } = props;\n const [visibleMonth, setVisibleMonthState] = useControlled({\n controlled: visibleMonthProp ? startOfMonth(visibleMonthProp) : undefined,\n default: startOfMonth(defaultVisibleMonth),\n name: \"Calendar\",\n state: \"visibleMonth\",\n });\n\n const isOutsideAllowedDates = useCallback(\n (date: DateValue) => {\n return (\n (minDate && date.compare(minDate) < 0) ||\n (maxDate && date.compare(maxDate) > 0)\n );\n },\n [maxDate, minDate],\n );\n\n const isOutsideAllowedMonths = useCallback(\n (date: DateValue) => {\n return (\n (minDate && endOfMonth(date).compare(minDate) < 0) ||\n (maxDate && startOfMonth(date).compare(maxDate) > 0)\n );\n },\n [minDate, maxDate],\n );\n\n const isOutsideAllowedYears = useCallback(\n (date: DateValue) => {\n return (\n (minDate && endOfYear(date).compare(minDate) < 0) ||\n (maxDate && startOfYear(date).compare(maxDate) > 0)\n );\n },\n [minDate, maxDate],\n );\n\n const isDaySelectable = useCallback(\n (date?: DateValue) =>\n !(\n date &&\n (isDayUnselectable(date) ||\n isDayDisabled(date) ||\n isOutsideAllowedDates(date))\n ),\n [isDayUnselectable, isDayDisabled, isOutsideAllowedDates],\n );\n\n const selectionManager = useCalendarSelection({\n defaultSelectedDate: defaultSelectedDate,\n selectedDate,\n onSelectedDateChange,\n startDateOffset:\n props.selectionVariant === \"offset\" ? props.startDateOffset : undefined,\n endDateOffset:\n props.selectionVariant === \"offset\" ? props.endDateOffset : undefined,\n isDaySelectable,\n selectionVariant,\n onHoveredDateChange,\n hoveredDate,\n } as UseCalendarSelectionProps);\n\n const [calendarFocused, setCalendarFocused] = useState(false);\n\n const isInVisibleMonth = useCallback(\n (date: DateValue | undefined | null): date is DateValue =>\n date != null && isSameMonth(date, visibleMonth),\n [visibleMonth],\n );\n\n const getInitialFocusedDate = useCallback(() => {\n const selectedDate = selectionManager.state.selectedDate;\n if (\n (selectionVariant === \"range\" || selectionVariant === \"offset\") &&\n isDateRangeSelection(selectedDate)\n ) {\n if (isInVisibleMonth(selectedDate?.startDate)) {\n return selectedDate.startDate;\n }\n if (isInVisibleMonth(selectedDate?.endDate)) {\n return selectedDate.endDate;\n }\n } else if (\n selectionVariant === \"multiselect\" &&\n Array.isArray(selectedDate)\n ) {\n // return first selected day in visible month\n const selectionInMonth = selectedDate\n .filter((day) => isInVisibleMonth(day))\n .sort((a, b) => a.compare(b));\n if (selectionInMonth.length > 0) {\n return selectionInMonth[0];\n }\n } else if (\n selectionVariant === \"single\" &&\n !isDateRangeSelection(selectedDate) &&\n !Array.isArray(selectedDate) &&\n isInVisibleMonth(selectedDate)\n ) {\n return selectedDate;\n }\n // Defaults\n if (isDaySelectable(today(timeZone)) && isInVisibleMonth(today(timeZone))) {\n return today(timeZone);\n }\n const firstSelectableDate = generateDatesForMonth(visibleMonth).find(\n (visibleDay) => isDaySelectable(visibleDay),\n );\n if (firstSelectableDate) {\n return firstSelectableDate;\n }\n return null;\n }, [\n isInVisibleMonth,\n selectionVariant,\n selectionManager.state.selectedDate,\n timeZone,\n visibleMonth,\n ]);\n\n const [focusedDate, setFocusedDateState] = useState<DateValue | null>(\n getInitialFocusedDate,\n );\n\n const isDayVisible = useCallback(\n (date: DateValue) => {\n const startInsideDays = startOfMonth(visibleMonth);\n\n if (date.compare(startInsideDays) < 0) return false;\n\n const endInsideDays = endOfMonth(visibleMonth);\n\n return !(date.compare(endInsideDays) > 0);\n },\n [visibleMonth],\n );\n\n const setVisibleMonth = useCallback(\n (event: SyntheticEvent, newVisibleMonth: DateValue) => {\n setVisibleMonthState(newVisibleMonth);\n onVisibleMonthChange?.(event, newVisibleMonth);\n },\n [onVisibleMonthChange],\n );\n\n const setFocusedDate = useCallback(\n (event: SyntheticEvent, date: DateValue) => {\n if (\n !focusedDate ||\n isSameDay(date, focusedDate) ||\n isOutsideAllowedDates(date)\n )\n return;\n\n setFocusedDateState(date);\n\n const shouldTransition =\n !isDayVisible(date) &&\n isDaySelectable(date) &&\n !isOutsideAllowedDates(date);\n if (shouldTransition) {\n setVisibleMonth(event, startOfMonth(date));\n }\n },\n [\n focusedDate,\n isDaySelectable,\n isDayVisible,\n isOutsideAllowedDates,\n setVisibleMonth,\n ],\n );\n\n useEffect(() => {\n if (visibleMonth && focusedDate && !isDayVisible(focusedDate)) {\n const focusableDate = getInitialFocusedDate();\n if (focusableDate) {\n setFocusedDateState(focusableDate);\n }\n }\n }, [isDayVisible, focusedDate, getInitialFocusedDate, visibleMonth]);\n\n return useMemo(\n () => ({\n state: {\n visibleMonth,\n focusedDate,\n minDate,\n maxDate,\n selectionVariant,\n hideOutOfRangeDates,\n calendarFocused,\n timeZone,\n locale,\n ...selectionManager.state,\n },\n helpers: {\n setVisibleMonth,\n setFocusedDate,\n setCalendarFocused,\n isDayUnselectable,\n isDayHighlighted,\n isDayDisabled,\n isDayVisible,\n isOutsideAllowedDates,\n isOutsideAllowedMonths,\n isOutsideAllowedYears,\n ...selectionManager.helpers,\n },\n }),\n [\n visibleMonth,\n focusedDate,\n minDate,\n maxDate,\n selectionVariant,\n hideOutOfRangeDates,\n calendarFocused,\n timeZone,\n locale,\n setVisibleMonth,\n setFocusedDate,\n isDayUnselectable,\n isDayHighlighted,\n isDayDisabled,\n isDayVisible,\n isOutsideAllowedDates,\n isOutsideAllowedMonths,\n isOutsideAllowedYears,\n selectionManager,\n ],\n );\n}\n"],"names":["selectedDate"],"mappings":";;;;;;;AAyJA,MAAM,2BAA2B,MAAsB,KAAA,CAAA;AAMvD,MAAM,0BAA0B,MAAsB,KAAA,CAAA;AAMtD,MAAM,uBAAuB,MAAa,KAAA,CAAA;AAEnC,SAAS,YAAY,KAAyB,EAAA;AACnD,EAAM,MAAA;AAAA,IACJ,YAAA;AAAA,IACA,mBAAA;AAAA,IACA,YAAc,EAAA,gBAAA;AAAA,IACd,mBAAA;AAAA,IACA,WAAW,gBAAiB,EAAA;AAAA,IAC5B,SAAS,gBAAiB,EAAA;AAAA,IAC1B,mBAAA,GAAsB,MAAM,QAAQ,CAAA;AAAA,IACpC,oBAAA;AAAA,IACA,oBAAA;AAAA,IACA,iBAAoB,GAAA,wBAAA;AAAA,IACpB,gBAAmB,GAAA,uBAAA;AAAA,IACnB,aAAgB,GAAA,oBAAA;AAAA,IAChB,OAAA;AAAA,IACA,OAAA;AAAA,IACA,gBAAA;AAAA,IACA,mBAAA;AAAA,IACA,WAAA;AAAA,GAGE,GAAA,KAAA,CA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A,MACA,OAAA;AAAA,MACA,OAAA;AAAA,MACA,gBAAA;AAAA,MACA,mBAAA;AAAA,MACA,eAAA;AAAA,MACA,QAAA;AAAA,MACA,MAAA;AAAA,MACA,eAAA;AAAA,MACA,cAAA;AAAA,MACA,iBAAA;AAAA,MACA,gBAAA;AAAA,MACA,aAAA;AAAA,MACA,YAAA;AAAA,MACA,qBAAA;AAAA,MACA,sBAAA;AAAA,MACA,qBAAA;AAAA,MACA,gBAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
|
|
@@ -15,6 +15,7 @@ function isDateRangeSelection(value) {
|
|
|
15
15
|
function isMultipleDateSelection(value) {
|
|
16
16
|
return Array.isArray(value) && value.every((item) => isSingleSelectionValueType(item));
|
|
17
17
|
}
|
|
18
|
+
const withBaseName = makePrefixer("saltCalendarDay");
|
|
18
19
|
function addOrRemoveFromArray(array, item) {
|
|
19
20
|
if (Array.isArray(array)) {
|
|
20
21
|
if (array.find((element) => isSameDay(element, item))) {
|
|
@@ -24,15 +25,7 @@ function addOrRemoveFromArray(array, item) {
|
|
|
24
25
|
}
|
|
25
26
|
return [item];
|
|
26
27
|
}
|
|
27
|
-
const
|
|
28
|
-
const withBaseName = makePrefixer("saltCalendarDay");
|
|
29
|
-
const defaultSingleSelectionHandler = (_currentSelectedDate, newSelectedDate) => {
|
|
30
|
-
return newSelectedDate;
|
|
31
|
-
};
|
|
32
|
-
const defaultMultiSelectHandler = (currentSelectedDate, newSelectedDate) => {
|
|
33
|
-
return addOrRemoveFromArray(currentSelectedDate, newSelectedDate);
|
|
34
|
-
};
|
|
35
|
-
const defaultRangeSelectionHandler = (currentSelectedDate, newSelectedDate) => {
|
|
28
|
+
const updateRangeSelection = (currentSelectedDate, newSelectedDate) => {
|
|
36
29
|
let base = { ...currentSelectedDate };
|
|
37
30
|
if ((base == null ? void 0 : base.startDate) && (base == null ? void 0 : base.endDate)) {
|
|
38
31
|
base = { startDate: newSelectedDate };
|
|
@@ -45,12 +38,6 @@ const defaultRangeSelectionHandler = (currentSelectedDate, newSelectedDate) => {
|
|
|
45
38
|
}
|
|
46
39
|
return base;
|
|
47
40
|
};
|
|
48
|
-
const defaultOffsetSelectionHandler = (_currentSelectedDate, newSelectedDate) => {
|
|
49
|
-
return {
|
|
50
|
-
startDate: newSelectedDate,
|
|
51
|
-
endDate: newSelectedDate
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
41
|
function useCalendarSelection(props) {
|
|
55
42
|
const {
|
|
56
43
|
hoveredDate: hoveredDateProp,
|
|
@@ -59,8 +46,7 @@ function useCalendarSelection(props) {
|
|
|
59
46
|
onSelectedDateChange,
|
|
60
47
|
onHoveredDateChange,
|
|
61
48
|
isDaySelectable,
|
|
62
|
-
selectionVariant
|
|
63
|
-
select: selectProp
|
|
49
|
+
selectionVariant
|
|
64
50
|
} = props;
|
|
65
51
|
const [selectedDate, setSelectedDateState] = useControlled({
|
|
66
52
|
controlled: selectedDateProp,
|
|
@@ -75,7 +61,7 @@ function useCalendarSelection(props) {
|
|
|
75
61
|
if (selectionVariant === "offset" && startDateOffset) {
|
|
76
62
|
return startDateOffset(date);
|
|
77
63
|
}
|
|
78
|
-
return
|
|
64
|
+
return date;
|
|
79
65
|
},
|
|
80
66
|
[selectionVariant, startDateOffset]
|
|
81
67
|
);
|
|
@@ -84,27 +70,22 @@ function useCalendarSelection(props) {
|
|
|
84
70
|
if (selectionVariant === "offset" && endDateOffset) {
|
|
85
71
|
return endDateOffset(date);
|
|
86
72
|
}
|
|
87
|
-
return
|
|
73
|
+
return date;
|
|
88
74
|
},
|
|
89
75
|
[selectionVariant, endDateOffset]
|
|
90
76
|
);
|
|
91
77
|
const setSelectedDate = useCallback(
|
|
92
78
|
(event, newSelectedDate) => {
|
|
79
|
+
var _a;
|
|
93
80
|
if (!isDaySelectable || isDaySelectable(newSelectedDate)) {
|
|
94
81
|
switch (selectionVariant) {
|
|
95
82
|
case "single": {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
selectedDate,
|
|
99
|
-
newSelectedDate
|
|
100
|
-
);
|
|
101
|
-
setSelectedDateState(newSingleDate);
|
|
102
|
-
onSelectedDateChange == null ? void 0 : onSelectedDateChange(event, newSingleDate);
|
|
83
|
+
setSelectedDateState(newSelectedDate);
|
|
84
|
+
onSelectedDateChange == null ? void 0 : onSelectedDateChange(event, newSelectedDate);
|
|
103
85
|
break;
|
|
104
86
|
}
|
|
105
87
|
case "multiselect": {
|
|
106
|
-
const
|
|
107
|
-
const newMultiSelectDate = multiSelect(
|
|
88
|
+
const newMultiSelectDate = addOrRemoveFromArray(
|
|
108
89
|
selectedDate,
|
|
109
90
|
newSelectedDate
|
|
110
91
|
);
|
|
@@ -113,8 +94,7 @@ function useCalendarSelection(props) {
|
|
|
113
94
|
break;
|
|
114
95
|
}
|
|
115
96
|
case "range": {
|
|
116
|
-
const
|
|
117
|
-
const newRangeDate = rangeSelect(
|
|
97
|
+
const newRangeDate = updateRangeSelection(
|
|
118
98
|
selectedDate,
|
|
119
99
|
newSelectedDate
|
|
120
100
|
);
|
|
@@ -123,25 +103,18 @@ function useCalendarSelection(props) {
|
|
|
123
103
|
break;
|
|
124
104
|
}
|
|
125
105
|
case "offset": {
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
);
|
|
106
|
+
const newOffsetDate = {
|
|
107
|
+
startDate: getStartDateOffset(newSelectedDate),
|
|
108
|
+
endDate: getEndDateOffset(newSelectedDate)
|
|
109
|
+
};
|
|
131
110
|
setSelectedDateState(newOffsetDate);
|
|
132
|
-
onSelectedDateChange == null ? void 0 :
|
|
111
|
+
(_a = props.onSelectedDateChange) == null ? void 0 : _a.call(props, event, newOffsetDate);
|
|
133
112
|
break;
|
|
134
113
|
}
|
|
135
114
|
}
|
|
136
115
|
}
|
|
137
116
|
},
|
|
138
|
-
[
|
|
139
|
-
isDaySelectable,
|
|
140
|
-
selectProp,
|
|
141
|
-
selectedDate,
|
|
142
|
-
selectionVariant,
|
|
143
|
-
onSelectedDateChange
|
|
144
|
-
]
|
|
117
|
+
[isDaySelectable, selectedDate, selectionVariant, onSelectedDateChange]
|
|
145
118
|
);
|
|
146
119
|
const isSelected = useCallback(
|
|
147
120
|
(date) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCalendarSelection.js","sources":["../src/calendar/useCalendarSelection.ts"],"sourcesContent":["import {\n CalendarDate,\n CalendarDateTime,\n type DateValue,\n ZonedDateTime,\n isSameDay,\n} from \"@internationalized/date\";\nimport { makePrefixer, useControlled } from \"@salt-ds/core\";\nimport { clsx } from \"clsx\";\nimport type {\n KeyboardEventHandler,\n MouseEventHandler,\n SyntheticEvent,\n} from \"react\";\nimport { useCallback, useMemo } from \"react\";\nimport { useCalendarContext } from \"./internal/CalendarContext\";\n\n/**\n * Type representing a single date selection.\n */\nexport type SingleDateSelection = DateValue;\n\n/**\n * Type representing multiple date selections.\n */\nexport type MultipleDateSelection = DateValue[];\n\n/**\n * Type representing a date range selection.\n */\nexport type DateRangeSelection = {\n /**\n * The start date of the range.\n */\n startDate?: DateValue | null;\n /**\n * The end date of the range.\n */\n endDate?: DateValue | null;\n};\n\n/**\n * Type representing all possible selection value types.\n */\nexport type AllSelectionValueType =\n | SingleDateSelection\n | MultipleDateSelection\n | DateRangeSelection\n | null;\n\n/**\n * The default minimum year used by the calendar.\n */\nexport const CALENDAR_MIN_YEAR = 1900;\n\n/**\n * The default maximum year used by the calendar.\n */\nexport const CALENDAR_MAX_YEAR = 2100;\n\n/**\n * Checks if a value is a single date selection.\n * @param value - The value to check.\n * @returns `true` if the value is a single date selection, otherwise `false`.\n */\n// biome-ignore lint/suspicious/noExplicitAny: type guard\nexport function isSingleSelectionValueType(value: any): value is DateValue {\n return (\n value instanceof CalendarDate ||\n value instanceof CalendarDateTime ||\n value instanceof ZonedDateTime\n );\n}\n\n/**\n * Checks if a value is a date range selection.\n * @param value - The value to check.\n * @returns `true` if the value is a date range selection, otherwise `false`.\n */\n// biome-ignore lint/suspicious/noExplicitAny: type guard\nexport function isDateRangeSelection(value: any): value is DateRangeSelection {\n return (\n value &&\n typeof value === \"object\" &&\n (\"startDate\" in value || \"endDate\" in value)\n );\n}\n\n/**\n * Checks if a value is a multiple date selection.\n * @param value - The value to check.\n * @returns `true` if the value is a multiple date selection, otherwise `false`.\n */\nexport function isMultipleDateSelection(\n // biome-ignore lint/suspicious/noExplicitAny: type guard\n value: any,\n): value is MultipleDateSelection {\n return (\n Array.isArray(value) &&\n value.every((item) => isSingleSelectionValueType(item))\n );\n}\n\n/**\n * Base properties for calendar UseCalendarSelection hook.\n * @template SelectionVariantType - The type of the selection variant.\n */\ninterface UseCalendarSelectionBaseProps<SelectionVariantType> {\n /**\n * The currently hovered date.\n */\n hoveredDate?: DateValue | null;\n /**\n * The currently selected date.\n */\n selectedDate?: SelectionVariantType | null;\n /**\n * The default selected date.\n */\n defaultSelectedDate?: SelectionVariantType;\n /**\n * Callback fired when the selected date changes.\n * @param event - The synthetic event.\n * @param selectedDate - The new selected date.\n */\n onSelectedDateChange?: (\n event: SyntheticEvent,\n selectedDate: SelectionVariantType | null,\n ) => void;\n /**\n * Function to determine if a day is selectable.\n * @param date - The date to check.\n * @returns `true` if the day is selectable, otherwise `false`.\n */\n isDaySelectable?: (date: DateValue) => boolean;\n /**\n * Callback fired when the hovered date changes.\n * @param event - The synthetic event.\n * @param hoveredDate - The new hovered date.\n */\n onHoveredDateChange?: (\n event: SyntheticEvent,\n hoveredDate: DateValue | null,\n ) => void;\n /**\n * Function to select a new date.\n * @param currentSelectedDate - The current selected date.\n * @param newSelectedDate - The new date to select.\n * @returns The updated selection variant type.\n */\n select?: (\n currentSelectedDate: SelectionVariantType,\n newSelectedDate: DateValue,\n ) => SelectionVariantType;\n}\n\n/**\n * UseCalendar hook props to return a calendar day's status\n */\nexport interface UseCalendarSelectionOffsetProps\n extends Omit<\n UseCalendarSelectionBaseProps<DateRangeSelection>,\n \"startDateOffset\" | \"endDateOffset\"\n > {\n /**\n * The selection variant, set to \"offset\".\n */\n selectionVariant: \"offset\";\n /**\n * Function to calculate the start date offset.\n * @param date - The date to offset.\n * @returns The offset start date.\n */\n startDateOffset?: (date: DateValue) => DateValue;\n /**\n * Function to calculate the end date offset.\n * @param date - The date to offset.\n * @returns The offset end date.\n */\n endDateOffset?: (date: DateValue) => DateValue;\n}\n\n/**\n * Properties for the range date selection hook.\n */\nexport interface UseCalendarSelectionRangeProps\n extends UseCalendarSelectionBaseProps<DateRangeSelection> {\n /**\n * The selection variant, set to \"range\".\n */\n selectionVariant: \"range\";\n}\n\n/**\n * Properties for the multi-select date selection hook.\n */\nexport interface UseCalendarSelectionMultiSelectProps\n extends UseCalendarSelectionBaseProps<MultipleDateSelection> {\n /**\n * The selection variant, set to \"multiselect\".\n */\n selectionVariant: \"multiselect\";\n}\n\n/**\n * Properties for the single date selection hook.\n */\nexport interface UseCalendarSelectionSingleProps\n extends UseCalendarSelectionBaseProps<SingleDateSelection> {\n /**\n * The selection variant, set to \"single\".\n */\n selectionVariant: \"single\";\n}\n\n/**\n * UseCalendarSelection hook props, wth the selection variant determining the return type of the date selection\n */\nexport type UseCalendarSelectionProps =\n | UseCalendarSelectionSingleProps\n | UseCalendarSelectionMultiSelectProps\n | UseCalendarSelectionRangeProps\n | UseCalendarSelectionOffsetProps;\n\nfunction addOrRemoveFromArray(array: AllSelectionValueType, item: DateValue) {\n if (Array.isArray(array)) {\n if (array.find((element) => isSameDay(element, item))) {\n return array.filter((element) => !isSameDay(element, item));\n }\n return array.concat(item);\n }\n return [item];\n}\n\nconst defaultOffset = (date: DateValue) => date;\n\nconst withBaseName = makePrefixer(\"saltCalendarDay\");\n\nconst defaultSingleSelectionHandler = (\n _currentSelectedDate: DateValue,\n newSelectedDate: DateValue,\n): DateValue => {\n return newSelectedDate;\n};\n\nconst defaultMultiSelectHandler = (\n currentSelectedDate: DateValue[],\n newSelectedDate: DateValue,\n): DateValue[] => {\n return addOrRemoveFromArray(currentSelectedDate, newSelectedDate);\n};\n\nconst defaultRangeSelectionHandler = (\n currentSelectedDate: DateRangeSelection,\n newSelectedDate: DateValue,\n): DateRangeSelection => {\n let base = { ...currentSelectedDate };\n if (base?.startDate && base?.endDate) {\n base = { startDate: newSelectedDate };\n } else if (base?.startDate && newSelectedDate.compare(base.startDate) < 0) {\n base = { startDate: newSelectedDate };\n } else if (base?.startDate && newSelectedDate.compare(base.startDate) >= 0) {\n base = { ...base, endDate: newSelectedDate };\n } else {\n base = { startDate: newSelectedDate };\n }\n return base;\n};\n\nconst defaultOffsetSelectionHandler = (\n _currentSelectedDate: DateRangeSelection,\n newSelectedDate: DateValue,\n): DateRangeSelection => {\n return {\n startDate: newSelectedDate,\n endDate: newSelectedDate,\n };\n};\n\nexport function useCalendarSelection(props: UseCalendarSelectionProps) {\n const {\n hoveredDate: hoveredDateProp,\n selectedDate: selectedDateProp,\n defaultSelectedDate,\n onSelectedDateChange,\n onHoveredDateChange,\n isDaySelectable,\n selectionVariant,\n select: selectProp,\n // startDateOffset,\n // endDateOffset,\n } = props;\n const [selectedDate, setSelectedDateState] = useControlled({\n controlled: selectedDateProp,\n default: defaultSelectedDate,\n name: \"Calendar\",\n state: \"selectedDate\",\n });\n\n const startDateOffset =\n selectionVariant === \"offset\" ? props.startDateOffset : undefined;\n const endDateOffset =\n selectionVariant === \"offset\" ? props.endDateOffset : undefined;\n\n const getStartDateOffset = useCallback(\n (date: DateValue) => {\n if (selectionVariant === \"offset\" && startDateOffset) {\n return startDateOffset(date);\n }\n return defaultOffset(date);\n },\n [selectionVariant, startDateOffset],\n );\n\n const getEndDateOffset = useCallback(\n (date: DateValue) => {\n if (selectionVariant === \"offset\" && endDateOffset) {\n return endDateOffset(date);\n }\n return defaultOffset(date);\n },\n [selectionVariant, endDateOffset],\n );\n\n const setSelectedDate = useCallback(\n (event: SyntheticEvent<HTMLButtonElement>, newSelectedDate: DateValue) => {\n if (!isDaySelectable || isDaySelectable(newSelectedDate)) {\n switch (selectionVariant) {\n case \"single\": {\n const singleSelect = selectProp || defaultSingleSelectionHandler;\n const newSingleDate = singleSelect(\n selectedDate as DateValue,\n newSelectedDate,\n );\n setSelectedDateState(newSingleDate);\n onSelectedDateChange?.(event, newSingleDate);\n break;\n }\n case \"multiselect\": {\n const multiSelect = selectProp || defaultMultiSelectHandler;\n const newMultiSelectDate = multiSelect(\n selectedDate as DateValue[],\n newSelectedDate,\n );\n setSelectedDateState(newMultiSelectDate);\n onSelectedDateChange?.(event, newMultiSelectDate);\n break;\n }\n case \"range\": {\n const rangeSelect = selectProp || defaultRangeSelectionHandler;\n const newRangeDate = rangeSelect(\n selectedDate as DateRangeSelection,\n newSelectedDate,\n );\n setSelectedDateState(newRangeDate);\n onSelectedDateChange?.(event, newRangeDate);\n break;\n }\n case \"offset\": {\n const offsetSelect = selectProp || defaultOffsetSelectionHandler;\n const newOffsetDate = offsetSelect(\n selectedDate as DateRangeSelection,\n newSelectedDate,\n );\n setSelectedDateState(newOffsetDate);\n onSelectedDateChange?.(event, newOffsetDate);\n break;\n }\n }\n }\n },\n [\n isDaySelectable,\n selectProp,\n selectedDate,\n selectionVariant,\n onSelectedDateChange,\n ],\n );\n\n const isSelected = useCallback(\n (date: DateValue) => {\n switch (selectionVariant) {\n case \"single\":\n return (\n isSingleSelectionValueType(selectedDate) &&\n isSameDay(selectedDate, date)\n );\n case \"multiselect\":\n return (\n Array.isArray(selectedDate) &&\n !!selectedDate.find((element) => isSameDay(element, date))\n );\n default:\n return false;\n }\n },\n [selectionVariant, selectedDate],\n );\n\n const [hoveredDate, setHoveredDateState] = useControlled({\n controlled: hoveredDateProp,\n default: undefined,\n name: \"Calendar\",\n state: \"hoveredDate\",\n });\n\n const setHoveredDate = useCallback(\n (event: SyntheticEvent, date: DateValue | null) => {\n setHoveredDateState(date);\n onHoveredDateChange?.(event, date);\n },\n [onHoveredDateChange],\n );\n\n const isHovered = useCallback(\n (date: DateValue) => {\n return !!hoveredDate && isSameDay(date, hoveredDate);\n },\n [hoveredDate],\n );\n\n const isSelectedSpan = useCallback(\n (date: DateValue) => {\n if (\n (selectionVariant === \"range\" || selectionVariant === \"offset\") &&\n isDateRangeSelection(selectedDate) &&\n selectedDate?.startDate &&\n selectedDate?.endDate\n ) {\n return (\n date.compare(selectedDate.startDate) > 0 &&\n date.compare(selectedDate.endDate) < 0\n );\n }\n return false;\n },\n [selectionVariant, selectedDate],\n );\n const isHoveredSpan = useCallback(\n (date: DateValue) => {\n if (\n (selectionVariant === \"range\" || selectionVariant === \"offset\") &&\n isDateRangeSelection(selectedDate) &&\n selectedDate.startDate &&\n !selectedDate.endDate &&\n hoveredDate\n ) {\n const isForwardRange =\n hoveredDate.compare(selectedDate.startDate) > 0 &&\n ((date.compare(selectedDate.startDate) > 0 &&\n date.compare(hoveredDate) < 0) ||\n isSameDay(date, hoveredDate));\n\n const isValidDayHovered =\n !isDaySelectable || isDaySelectable(hoveredDate);\n\n return isForwardRange && isValidDayHovered;\n }\n return false;\n },\n [selectionVariant, selectedDate, hoveredDate, isDaySelectable],\n );\n\n const isSelectedStart = useCallback(\n (date: DateValue) => {\n if (\n (selectionVariant === \"range\" || selectionVariant === \"offset\") &&\n isDateRangeSelection(selectedDate) &&\n selectedDate.startDate\n ) {\n return isSameDay(selectedDate.startDate, date);\n }\n return false;\n },\n [selectionVariant, selectedDate],\n );\n\n const isSelectedEnd = useCallback(\n (date: DateValue) => {\n if (\n (selectionVariant === \"range\" || selectionVariant === \"offset\") &&\n isDateRangeSelection(selectedDate) &&\n selectedDate.endDate\n ) {\n return isSameDay(selectedDate.endDate, date);\n }\n return false;\n },\n [selectionVariant, selectedDate],\n );\n\n const isHoveredOffset = useCallback(\n (date: DateValue) => {\n if (hoveredDate && selectionVariant === \"offset\") {\n const startDate = getStartDateOffset(hoveredDate);\n const endDate = getEndDateOffset(hoveredDate);\n\n return (\n date.compare(startDate) >= 0 &&\n date.compare(endDate) <= 0 &&\n (!isDaySelectable || isDaySelectable(date))\n );\n }\n\n return false;\n },\n [\n getStartDateOffset,\n getEndDateOffset,\n hoveredDate,\n isDaySelectable,\n selectionVariant,\n ],\n );\n\n return useMemo(\n () => ({\n state: {\n selectedDate,\n hoveredDate,\n },\n helpers: {\n setSelectedDate,\n isSelected,\n setHoveredDate,\n isHovered,\n isSelectedSpan,\n isHoveredSpan,\n isSelectedStart,\n isSelectedEnd,\n isHoveredOffset,\n isDaySelectable,\n },\n }),\n [\n selectedDate,\n hoveredDate,\n setSelectedDate,\n isSelected,\n setHoveredDate,\n isHovered,\n isSelectedSpan,\n isHoveredSpan,\n isSelectedStart,\n isSelectedEnd,\n isHoveredOffset,\n isDaySelectable,\n ],\n );\n}\n\nexport function useCalendarSelectionDay({ date }: { date: DateValue }) {\n const {\n helpers: {\n setSelectedDate,\n isSelected,\n setHoveredDate,\n isSelectedSpan,\n isHoveredSpan,\n isSelectedStart,\n isSelectedEnd,\n isHovered,\n isHoveredOffset,\n isDaySelectable,\n },\n } = useCalendarContext();\n\n const handleClick: MouseEventHandler<HTMLButtonElement> = useCallback(\n (event) => {\n setSelectedDate(event, date);\n },\n [date, setSelectedDate],\n );\n\n const handleKeyDown: KeyboardEventHandler<HTMLButtonElement> = useCallback(\n (event) => {\n switch (event.key) {\n case \"Space\":\n case \"Enter\":\n setSelectedDate(event, date);\n event.preventDefault();\n }\n },\n [date, setSelectedDate],\n );\n\n const handleMouseOver: MouseEventHandler<HTMLButtonElement> = useCallback(\n (event) => {\n setHoveredDate(event, date);\n },\n [date, setHoveredDate],\n );\n\n const handleMouseLeave: MouseEventHandler<HTMLButtonElement> = useCallback(\n (event) => {\n setHoveredDate(event, null);\n },\n [setHoveredDate],\n );\n\n const selected = isSelected(date);\n const selectedSpan = isSelectedSpan(date);\n const hoveredSpan = isHoveredSpan(date);\n const selectedStart = isSelectedStart(date);\n const selectedEnd = isSelectedEnd(date);\n const hovered = isHovered(date);\n const hoveredOffset = isHoveredOffset(date);\n\n return {\n handleClick,\n handleKeyDown,\n handleMouseOver,\n handleMouseLeave,\n status: {\n selected,\n selectedSpan,\n hoveredSpan,\n selectedStart,\n selectedEnd,\n hovered,\n hoveredOffset,\n },\n dayProps: {\n className: clsx({\n [withBaseName(\"selected\")]: selected,\n [withBaseName(\"selectedSpan\")]: selectedSpan,\n [withBaseName(\"hoveredSpan\")]: hoveredSpan,\n [withBaseName(\"selectedStart\")]: selectedStart,\n [withBaseName(\"selectedEnd\")]: selectedEnd,\n [withBaseName(\"hovered\")]: hovered,\n [withBaseName(\"hoveredOffset\")]: hoveredOffset,\n }),\n \"aria-pressed\":\n selected || selectedEnd || selectedStart || selectedSpan\n ? \"true\"\n : undefined,\n \"aria-disabled\":\n isDaySelectable && !isDaySelectable(date) ? \"true\" : undefined,\n },\n };\n}\n"],"names":[],"mappings":";;;;;;AAqDO,MAAM,iBAAoB,GAAA,KAAA;AAK1B,MAAM,iBAAoB,GAAA,KAAA;AAQ1B,SAAS,2BAA2B,KAAgC,EAAA;AACzE,EAAA,OACE,KAAiB,YAAA,YAAA,IACjB,KAAiB,YAAA,gBAAA,IACjB,KAAiB,YAAA,aAAA,CAAA;AAErB,CAAA;AAQO,SAAS,qBAAqB,KAAyC,EAAA;AAC5E,EAAA,OACE,SACA,OAAO,KAAA,KAAU,QAChB,KAAA,WAAA,IAAe,SAAS,SAAa,IAAA,KAAA,CAAA,CAAA;AAE1C,CAAA;AAOO,SAAS,wBAEd,KACgC,EAAA;AAChC,EACE,OAAA,KAAA,CAAM,OAAQ,CAAA,KAAK,CACnB,IAAA,KAAA,CAAM,MAAM,CAAC,IAAA,KAAS,0BAA2B,CAAA,IAAI,CAAC,CAAA,CAAA;AAE1D,CAAA;AA2HA,SAAS,oBAAA,CAAqB,OAA8B,IAAiB,EAAA;AAC3E,EAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,KAAK,CAAG,EAAA;AACxB,IAAI,IAAA,KAAA,CAAM,KAAK,CAAC,OAAA,KAAY,UAAU,OAAS,EAAA,IAAI,CAAC,CAAG,EAAA;AACrD,MAAO,OAA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,OAAA;AAAA,QAC3B,CAAC,YAAa,CAAA,eAAe,CAAI,GAAA,aAAA;AAAA,OAClC,CAAA;AAAA,MACD,cACE,EAAA,QAAA,IAAY,WAAe,IAAA,aAAA,IAAiB,eACxC,MACA,GAAA,KAAA,CAAA;AAAA,MACN,iBACE,eAAmB,IAAA,CAAC,eAAgB,CAAA,IAAI,IAAI,MAAS,GAAA,KAAA,CAAA;AAAA,KACzD;AAAA,GACF,CAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"useCalendarSelection.js","sources":["../src/calendar/useCalendarSelection.ts"],"sourcesContent":["import {\n CalendarDate,\n CalendarDateTime,\n type DateValue,\n ZonedDateTime,\n isSameDay,\n} from \"@internationalized/date\";\nimport { makePrefixer, useControlled } from \"@salt-ds/core\";\nimport { clsx } from \"clsx\";\nimport type {\n KeyboardEventHandler,\n MouseEventHandler,\n SyntheticEvent,\n} from \"react\";\nimport { useCallback, useMemo } from \"react\";\nimport { useCalendarContext } from \"./internal/CalendarContext\";\n\n/**\n * Type representing a single date selection.\n */\nexport type SingleDateSelection = DateValue;\n\n/**\n * Type representing multiple date selections.\n */\nexport type MultipleDateSelection = DateValue[];\n\n/**\n * Type representing a date range selection.\n */\nexport type DateRangeSelection = {\n /**\n * The start date of the range.\n */\n startDate?: DateValue | null;\n /**\n * The end date of the range.\n */\n endDate?: DateValue | null;\n};\n\n/**\n * Type representing all possible selection value types.\n */\nexport type AllSelectionValueType =\n | SingleDateSelection\n | MultipleDateSelection\n | DateRangeSelection\n | null;\n\n/**\n * The default minimum year used by the calendar.\n */\nexport const CALENDAR_MIN_YEAR = 1900;\n\n/**\n * The default maximum year used by the calendar.\n */\nexport const CALENDAR_MAX_YEAR = 2100;\n\n/**\n * Checks if a value is a single date selection.\n * @param value - The value to check.\n * @returns `true` if the value is a single date selection, otherwise `false`.\n */\n// biome-ignore lint/suspicious/noExplicitAny: type guard\nexport function isSingleSelectionValueType(value: any): value is DateValue {\n return (\n value instanceof CalendarDate ||\n value instanceof CalendarDateTime ||\n value instanceof ZonedDateTime\n );\n}\n\n/**\n * Checks if a value is a date range selection.\n * @param value - The value to check.\n * @returns `true` if the value is a date range selection, otherwise `false`.\n */\n// biome-ignore lint/suspicious/noExplicitAny: type guard\nexport function isDateRangeSelection(value: any): value is DateRangeSelection {\n return (\n value &&\n typeof value === \"object\" &&\n (\"startDate\" in value || \"endDate\" in value)\n );\n}\n\n/**\n * Checks if a value is a multiple date selection.\n * @param value - The value to check.\n * @returns `true` if the value is a multiple date selection, otherwise `false`.\n */\nexport function isMultipleDateSelection(\n // biome-ignore lint/suspicious/noExplicitAny: type guard\n value: any,\n): value is MultipleDateSelection {\n return (\n Array.isArray(value) &&\n value.every((item) => isSingleSelectionValueType(item))\n );\n}\n\n/**\n * Base properties for calendar UseCalendarSelection hook.\n * @template SelectionVariantType - The type of the selection variant.\n */\ninterface UseCalendarSelectionBaseProps<SelectionVariantType> {\n /**\n * The currently hovered date.\n */\n hoveredDate?: DateValue | null;\n /**\n * The currently selected date.\n */\n selectedDate?: SelectionVariantType | null;\n /**\n * The default selected date.\n */\n defaultSelectedDate?: SelectionVariantType;\n /**\n * Callback fired when the selected date changes.\n * @param event - The synthetic event.\n * @param selectedDate - The new selected date.\n */\n onSelectedDateChange?: (\n event: SyntheticEvent,\n selectedDate: SelectionVariantType | null,\n ) => void;\n /**\n * Function to determine if a day is selectable.\n * @param date - The date to check.\n * @returns `true` if the day is selectable, otherwise `false`.\n */\n isDaySelectable?: (date: DateValue) => boolean;\n /**\n * Callback fired when the hovered date changes.\n * @param event - The synthetic event.\n * @param hoveredDate - The new hovered date.\n */\n onHoveredDateChange?: (\n event: SyntheticEvent,\n hoveredDate: DateValue | null,\n ) => void;\n}\n\n/**\n * UseCalendar hook props to return a calendar day's status\n */\nexport interface UseCalendarSelectionOffsetProps\n extends Omit<\n UseCalendarSelectionBaseProps<DateRangeSelection>,\n \"startDateOffset\" | \"endDateOffset\"\n > {\n /**\n * The selection variant, set to \"offset\".\n */\n selectionVariant: \"offset\";\n /**\n * Function to calculate the start date offset.\n * @param date - The date to offset.\n * @returns The offset start date.\n */\n startDateOffset?: (date: DateValue) => DateValue;\n /**\n * Function to calculate the end date offset.\n * @param date - The date to offset.\n * @returns The offset end date.\n */\n endDateOffset?: (date: DateValue) => DateValue;\n}\n\n/**\n * Properties for the range date selection hook.\n */\nexport interface UseCalendarSelectionRangeProps\n extends UseCalendarSelectionBaseProps<DateRangeSelection> {\n /**\n * The selection variant, set to \"range\".\n */\n selectionVariant: \"range\";\n}\n\n/**\n * Properties for the multi-select date selection hook.\n */\nexport interface UseCalendarSelectionMultiSelectProps\n extends UseCalendarSelectionBaseProps<MultipleDateSelection> {\n /**\n * The selection variant, set to \"multiselect\".\n */\n selectionVariant: \"multiselect\";\n}\n\n/**\n * Properties for the single date selection hook.\n */\nexport interface UseCalendarSelectionSingleProps\n extends UseCalendarSelectionBaseProps<SingleDateSelection> {\n /**\n * The selection variant, set to \"single\".\n */\n selectionVariant: \"single\";\n}\n\n/**\n * UseCalendarSelection hook props, wth the selection variant determining the return type of the date selection\n */\nexport type UseCalendarSelectionProps =\n | UseCalendarSelectionSingleProps\n | UseCalendarSelectionMultiSelectProps\n | UseCalendarSelectionRangeProps\n | UseCalendarSelectionOffsetProps;\n\nconst withBaseName = makePrefixer(\"saltCalendarDay\");\n\nfunction addOrRemoveFromArray(array: AllSelectionValueType, item: DateValue) {\n if (Array.isArray(array)) {\n if (array.find((element) => isSameDay(element, item))) {\n return array.filter((element) => !isSameDay(element, item));\n }\n return array.concat(item);\n }\n return [item];\n}\n\nconst updateRangeSelection = (\n currentSelectedDate: DateRangeSelection,\n newSelectedDate: DateValue,\n): DateRangeSelection => {\n let base = { ...currentSelectedDate };\n if (base?.startDate && base?.endDate) {\n base = { startDate: newSelectedDate };\n } else if (base?.startDate && newSelectedDate.compare(base.startDate) < 0) {\n base = { startDate: newSelectedDate };\n } else if (base?.startDate && newSelectedDate.compare(base.startDate) >= 0) {\n base = { ...base, endDate: newSelectedDate };\n } else {\n base = { startDate: newSelectedDate };\n }\n return base;\n};\n\nexport function useCalendarSelection(props: UseCalendarSelectionProps) {\n const {\n hoveredDate: hoveredDateProp,\n selectedDate: selectedDateProp,\n defaultSelectedDate,\n onSelectedDateChange,\n onHoveredDateChange,\n isDaySelectable,\n selectionVariant,\n // startDateOffset,\n // endDateOffset,\n } = props;\n const [selectedDate, setSelectedDateState] = useControlled({\n controlled: selectedDateProp,\n default: defaultSelectedDate,\n name: \"Calendar\",\n state: \"selectedDate\",\n });\n\n const startDateOffset =\n selectionVariant === \"offset\" ? props.startDateOffset : undefined;\n const endDateOffset =\n selectionVariant === \"offset\" ? props.endDateOffset : undefined;\n\n const getStartDateOffset = useCallback(\n (date: DateValue) => {\n if (selectionVariant === \"offset\" && startDateOffset) {\n return startDateOffset(date);\n }\n return date;\n },\n [selectionVariant, startDateOffset],\n );\n\n const getEndDateOffset = useCallback(\n (date: DateValue) => {\n if (selectionVariant === \"offset\" && endDateOffset) {\n return endDateOffset(date);\n }\n return date;\n },\n [selectionVariant, endDateOffset],\n );\n\n const setSelectedDate = useCallback(\n (event: SyntheticEvent<HTMLButtonElement>, newSelectedDate: DateValue) => {\n if (!isDaySelectable || isDaySelectable(newSelectedDate)) {\n switch (selectionVariant) {\n case \"single\": {\n setSelectedDateState(newSelectedDate);\n onSelectedDateChange?.(event, newSelectedDate);\n break;\n }\n case \"multiselect\": {\n const newMultiSelectDate = addOrRemoveFromArray(\n selectedDate as DateValue[],\n newSelectedDate,\n );\n setSelectedDateState(newMultiSelectDate);\n onSelectedDateChange?.(event, newMultiSelectDate);\n break;\n }\n case \"range\": {\n const newRangeDate = updateRangeSelection(\n selectedDate as DateRangeSelection,\n newSelectedDate,\n );\n setSelectedDateState(newRangeDate);\n onSelectedDateChange?.(event, newRangeDate);\n break;\n }\n case \"offset\": {\n const newOffsetDate: DateRangeSelection = {\n startDate: getStartDateOffset(newSelectedDate),\n endDate: getEndDateOffset(newSelectedDate),\n };\n setSelectedDateState(newOffsetDate);\n props.onSelectedDateChange?.(event, newOffsetDate);\n break;\n }\n }\n }\n },\n [isDaySelectable, selectedDate, selectionVariant, onSelectedDateChange],\n );\n\n const isSelected = useCallback(\n (date: DateValue) => {\n switch (selectionVariant) {\n case \"single\":\n return (\n isSingleSelectionValueType(selectedDate) &&\n isSameDay(selectedDate, date)\n );\n case \"multiselect\":\n return (\n Array.isArray(selectedDate) &&\n !!selectedDate.find((element) => isSameDay(element, date))\n );\n default:\n return false;\n }\n },\n [selectionVariant, selectedDate],\n );\n\n const [hoveredDate, setHoveredDateState] = useControlled({\n controlled: hoveredDateProp,\n default: undefined,\n name: \"Calendar\",\n state: \"hoveredDate\",\n });\n\n const setHoveredDate = useCallback(\n (event: SyntheticEvent, date: DateValue | null) => {\n setHoveredDateState(date);\n onHoveredDateChange?.(event, date);\n },\n [onHoveredDateChange],\n );\n\n const isHovered = useCallback(\n (date: DateValue) => {\n return !!hoveredDate && isSameDay(date, hoveredDate);\n },\n [hoveredDate],\n );\n\n const isSelectedSpan = useCallback(\n (date: DateValue) => {\n if (\n (selectionVariant === \"range\" || selectionVariant === \"offset\") &&\n isDateRangeSelection(selectedDate) &&\n selectedDate?.startDate &&\n selectedDate?.endDate\n ) {\n return (\n date.compare(selectedDate.startDate) > 0 &&\n date.compare(selectedDate.endDate) < 0\n );\n }\n return false;\n },\n [selectionVariant, selectedDate],\n );\n const isHoveredSpan = useCallback(\n (date: DateValue) => {\n if (\n (selectionVariant === \"range\" || selectionVariant === \"offset\") &&\n isDateRangeSelection(selectedDate) &&\n selectedDate.startDate &&\n !selectedDate.endDate &&\n hoveredDate\n ) {\n const isForwardRange =\n hoveredDate.compare(selectedDate.startDate) > 0 &&\n ((date.compare(selectedDate.startDate) > 0 &&\n date.compare(hoveredDate) < 0) ||\n isSameDay(date, hoveredDate));\n\n const isValidDayHovered =\n !isDaySelectable || isDaySelectable(hoveredDate);\n\n return isForwardRange && isValidDayHovered;\n }\n return false;\n },\n [selectionVariant, selectedDate, hoveredDate, isDaySelectable],\n );\n\n const isSelectedStart = useCallback(\n (date: DateValue) => {\n if (\n (selectionVariant === \"range\" || selectionVariant === \"offset\") &&\n isDateRangeSelection(selectedDate) &&\n selectedDate.startDate\n ) {\n return isSameDay(selectedDate.startDate, date);\n }\n return false;\n },\n [selectionVariant, selectedDate],\n );\n\n const isSelectedEnd = useCallback(\n (date: DateValue) => {\n if (\n (selectionVariant === \"range\" || selectionVariant === \"offset\") &&\n isDateRangeSelection(selectedDate) &&\n selectedDate.endDate\n ) {\n return isSameDay(selectedDate.endDate, date);\n }\n return false;\n },\n [selectionVariant, selectedDate],\n );\n\n const isHoveredOffset = useCallback(\n (date: DateValue) => {\n if (hoveredDate && selectionVariant === \"offset\") {\n const startDate = getStartDateOffset(hoveredDate);\n const endDate = getEndDateOffset(hoveredDate);\n\n return (\n date.compare(startDate) >= 0 &&\n date.compare(endDate) <= 0 &&\n (!isDaySelectable || isDaySelectable(date))\n );\n }\n\n return false;\n },\n [\n getStartDateOffset,\n getEndDateOffset,\n hoveredDate,\n isDaySelectable,\n selectionVariant,\n ],\n );\n\n return useMemo(\n () => ({\n state: {\n selectedDate,\n hoveredDate,\n },\n helpers: {\n setSelectedDate,\n isSelected,\n setHoveredDate,\n isHovered,\n isSelectedSpan,\n isHoveredSpan,\n isSelectedStart,\n isSelectedEnd,\n isHoveredOffset,\n isDaySelectable,\n },\n }),\n [\n selectedDate,\n hoveredDate,\n setSelectedDate,\n isSelected,\n setHoveredDate,\n isHovered,\n isSelectedSpan,\n isHoveredSpan,\n isSelectedStart,\n isSelectedEnd,\n isHoveredOffset,\n isDaySelectable,\n ],\n );\n}\n\nexport function useCalendarSelectionDay({ date }: { date: DateValue }) {\n const {\n helpers: {\n setSelectedDate,\n isSelected,\n setHoveredDate,\n isSelectedSpan,\n isHoveredSpan,\n isSelectedStart,\n isSelectedEnd,\n isHovered,\n isHoveredOffset,\n isDaySelectable,\n },\n } = useCalendarContext();\n\n const handleClick: MouseEventHandler<HTMLButtonElement> = useCallback(\n (event) => {\n setSelectedDate(event, date);\n },\n [date, setSelectedDate],\n );\n\n const handleKeyDown: KeyboardEventHandler<HTMLButtonElement> = useCallback(\n (event) => {\n switch (event.key) {\n case \"Space\":\n case \"Enter\":\n setSelectedDate(event, date);\n event.preventDefault();\n }\n },\n [date, setSelectedDate],\n );\n\n const handleMouseOver: MouseEventHandler<HTMLButtonElement> = useCallback(\n (event) => {\n setHoveredDate(event, date);\n },\n [date, setHoveredDate],\n );\n\n const handleMouseLeave: MouseEventHandler<HTMLButtonElement> = useCallback(\n (event) => {\n setHoveredDate(event, null);\n },\n [setHoveredDate],\n );\n\n const selected = isSelected(date);\n const selectedSpan = isSelectedSpan(date);\n const hoveredSpan = isHoveredSpan(date);\n const selectedStart = isSelectedStart(date);\n const selectedEnd = isSelectedEnd(date);\n const hovered = isHovered(date);\n const hoveredOffset = isHoveredOffset(date);\n\n return {\n handleClick,\n handleKeyDown,\n handleMouseOver,\n handleMouseLeave,\n status: {\n selected,\n selectedSpan,\n hoveredSpan,\n selectedStart,\n selectedEnd,\n hovered,\n hoveredOffset,\n },\n dayProps: {\n className: clsx({\n [withBaseName(\"selected\")]: selected,\n [withBaseName(\"selectedSpan\")]: selectedSpan,\n [withBaseName(\"hoveredSpan\")]: hoveredSpan,\n [withBaseName(\"selectedStart\")]: selectedStart,\n [withBaseName(\"selectedEnd\")]: selectedEnd,\n [withBaseName(\"hovered\")]: hovered,\n [withBaseName(\"hoveredOffset\")]: hoveredOffset,\n }),\n \"aria-pressed\":\n selected || selectedEnd || selectedStart || selectedSpan\n ? \"true\"\n : undefined,\n \"aria-disabled\":\n isDaySelectable && !isDaySelectable(date) ? \"true\" : undefined,\n },\n };\n}\n"],"names":[],"mappings":";;;;;;AAqDO,MAAM,iBAAoB,GAAA,KAAA;AAK1B,MAAM,iBAAoB,GAAA,KAAA;AAQ1B,SAAS,2BAA2B,KAAgC,EAAA;AACzE,EAAA,OACE,KAAiB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A,aAAA,IAAiB,eACxC,MACA,GAAA,KAAA,CAAA;AAAA,MACN,iBACE,eAAmB,IAAA,CAAC,eAAgB,CAAA,IAAI,IAAI,MAAS,GAAA,KAAA,CAAA;AAAA,KACzD;AAAA,GACF,CAAA;AACF;;;;"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { forwardRef, Children, useEffect, createElement } from 'react';
|
|
3
|
-
import { makePrefixer, useId, GridLayout, Button, RadioButtonGroup, RadioButton } from '@salt-ds/core';
|
|
4
|
-
import { ChevronLeftIcon, ChevronRightIcon } from '@salt-ds/icons';
|
|
5
|
-
import { clsx } from 'clsx';
|
|
6
|
-
import { DeckLayout } from '../deck-layout/DeckLayout.js';
|
|
3
|
+
import { makePrefixer, useIcon, useId, GridLayout, Button, RadioButtonGroup, RadioButton } from '@salt-ds/core';
|
|
7
4
|
import { useComponentCssInjection } from '@salt-ds/styles';
|
|
8
5
|
import { useWindow } from '@salt-ds/window';
|
|
6
|
+
import { clsx } from 'clsx';
|
|
7
|
+
import { DeckLayout } from '../deck-layout/DeckLayout.js';
|
|
9
8
|
import { useSlideSelection } from '../utils/useSlideSelection.js';
|
|
10
9
|
import css_248z from './Carousel.css.js';
|
|
11
10
|
|
|
@@ -27,6 +26,7 @@ const Carousel = forwardRef(
|
|
|
27
26
|
css: css_248z,
|
|
28
27
|
window: targetWindow
|
|
29
28
|
});
|
|
29
|
+
const { NextIcon, PreviousIcon } = useIcon();
|
|
30
30
|
const id = useId(idProp);
|
|
31
31
|
const slidesCount = Children.count(children);
|
|
32
32
|
const [_, selectedSlide, handleSlideSelection] = useSlideSelection(initialIndex);
|
|
@@ -70,7 +70,7 @@ const Carousel = forwardRef(
|
|
|
70
70
|
variant: "secondary",
|
|
71
71
|
className: withBaseName("prev-button"),
|
|
72
72
|
onClick: () => moveSlide("left"),
|
|
73
|
-
children: /* @__PURE__ */ jsx(
|
|
73
|
+
children: /* @__PURE__ */ jsx(PreviousIcon, {
|
|
74
74
|
size: 2
|
|
75
75
|
})
|
|
76
76
|
}),
|
|
@@ -84,7 +84,7 @@ const Carousel = forwardRef(
|
|
|
84
84
|
variant: "secondary",
|
|
85
85
|
className: withBaseName("next-button"),
|
|
86
86
|
onClick: () => moveSlide("right"),
|
|
87
|
-
children: /* @__PURE__ */ jsx(
|
|
87
|
+
children: /* @__PURE__ */ jsx(NextIcon, {
|
|
88
88
|
size: 2
|
|
89
89
|
})
|
|
90
90
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Carousel.js","sources":["../src/carousel/Carousel.tsx"],"sourcesContent":["import {\n Button,\n GridLayout,\n RadioButton,\n RadioButtonGroup,\n makePrefixer,\n useId,\n} from \"@salt-ds/core\";\nimport {
|
|
1
|
+
{"version":3,"file":"Carousel.js","sources":["../src/carousel/Carousel.tsx"],"sourcesContent":["import {\n Button,\n GridLayout,\n RadioButton,\n RadioButtonGroup,\n makePrefixer,\n useIcon,\n useId,\n} from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport {\n type ChangeEventHandler,\n Children,\n type HTMLAttributes,\n type ReactElement,\n forwardRef,\n useEffect,\n} from \"react\";\nimport { DeckLayout } from \"../deck-layout\";\nimport { useSlideSelection } from \"../utils\";\nimport type { CarouselSlideProps } from \"./CarouselSlide\";\n\nimport carouselCss from \"./Carousel.css\";\n\nconst withBaseName = makePrefixer(\"saltCarousel\");\n\nexport interface CarouselProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * The initial Index enables you to select the active slide in the carousel.\n * Optional, default 0.\n **/\n initialIndex?: number;\n /**\n * The animation when the slides are shown.\n * Optional. Defaults to `slide`\n **/\n animation?: \"slide\" | \"fade\";\n /**\n * If this props is passed it will set the aria-label with value to the carousel container.\n * Optional. Defaults to undefined\n */\n carouselDescription?: string;\n /**\n * Collection of slides to render\n * Component must implement CarouselSlideProps. Mandatory.\n */\n children: Array<ReactElement<CarouselSlideProps>>;\n /**\n * This prop will enable compact / reduced width mode.\n * The navigation buttons would be part of indicators\n * Optional. Defaults to false\n **/\n compact?: boolean;\n /**\n * It sets the id for the Carousel Container.\n * String. Optional\n */\n id?: string;\n}\n\nexport const Carousel = forwardRef<HTMLDivElement, CarouselProps>(\n function Carousel(\n {\n initialIndex,\n animation = \"slide\",\n carouselDescription,\n children,\n className,\n compact,\n id: idProp,\n ...rest\n },\n ref,\n ) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-carousel\",\n css: carouselCss,\n window: targetWindow,\n });\n const { NextIcon, PreviousIcon } = useIcon();\n const id = useId(idProp);\n const slidesCount = Children.count(children);\n\n const [_, selectedSlide, handleSlideSelection] =\n useSlideSelection(initialIndex);\n\n const moveSlide = (direction: \"left\" | \"right\") => {\n const moveLeft =\n selectedSlide === 0 ? slidesCount - 1 : selectedSlide - 1;\n const moveRight =\n selectedSlide === slidesCount - 1 ? 0 : selectedSlide + 1;\n const newSelection = direction === \"left\" ? moveLeft : moveRight;\n const newTransition = direction === \"left\" ? \"decrease\" : \"increase\";\n handleSlideSelection(newSelection, newTransition);\n };\n\n const handleRadioChange: ChangeEventHandler<HTMLInputElement> = ({\n target: { value },\n }) => {\n handleSlideSelection(Number(value));\n };\n\n useEffect(() => {\n if (process.env.NODE_ENV !== \"production\") {\n if (slidesCount < 1) {\n console.warn(\n \"Carousel component requires more than one children to render. At least two elements should be provided.\",\n );\n }\n }\n }, [slidesCount]);\n\n return (\n <GridLayout\n aria-label={carouselDescription}\n aria-roledescription=\"carousel\"\n id={id}\n role=\"region\"\n ref={ref}\n gap={0}\n columns={3}\n className={clsx(\n withBaseName(),\n compact && withBaseName(\"compact\"),\n className,\n )}\n {...rest}\n >\n <Button\n variant=\"secondary\"\n className={withBaseName(\"prev-button\")}\n onClick={() => moveSlide(\"left\")}\n >\n <PreviousIcon size={2} />\n </Button>\n <DeckLayout\n activeIndex={selectedSlide}\n animation={animation}\n className={withBaseName(\"slider\")}\n >\n {children}\n </DeckLayout>\n <Button\n variant=\"secondary\"\n className={withBaseName(\"next-button\")}\n onClick={() => moveSlide(\"right\")}\n >\n <NextIcon size={2} />\n </Button>\n <div className={withBaseName(\"dots\")}>\n <RadioButtonGroup\n aria-label=\"Carousel buttons\"\n onChange={handleRadioChange}\n value={`${selectedSlide}`}\n direction={\"horizontal\"}\n >\n {Array.from({ length: slidesCount }, (_, index) => ({\n value: `${index}`,\n })).map((radio) => (\n <RadioButton {...radio} key={radio.value} />\n ))}\n </RadioButtonGroup>\n </div>\n </GridLayout>\n );\n },\n);\n"],"names":["Carousel","carouselCss","_"],"mappings":";;;;;;;;;;AA0BA,MAAM,YAAA,GAAe,aAAa,cAAc,CAAA,CAAA;AAoCzC,MAAM,QAAW,GAAA,UAAA;AAAA,EACtB,SAASA,SACP,CAAA;AAAA,IACE,YAAA;AAAA,IACA,SAAY,GAAA,OAAA;AAAA,IACZ,mBAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,OAAA;AAAA,IACA,EAAI,EAAA,MAAA;AAAA,IACD,GAAA,IAAA;AAAA,KAEL,GACA,EAAA;AACA,IAAA,MAAM,eAAe,SAAU,EAAA,CAAA;AAC/B,IAAyB,wBAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,eAAA;AAAA,MACR,GAAK,EAAAC,QAAA;AAAA,MACL,MAAQ,EAAA,YAAA;AAAA,KACT,CAAA,CAAA;AACD,IAAA,MAAM,EAAE,QAAA,EAAU,YAAa,EAAA,GAAI,OAAQ,EAAA,CAAA;AAC3C,IAAM,MAAA,EAAA,GAAK,MAAM,MAAM,CAAA,CAAA;AACvB,IAAM,MAAA,WAAA,GAAc,QAAS,CAAA,KAAA,CAAM,QAAQ,CAAA,CAAA;AAE3C,IAAA,MAAM,CAAC,CAAG,EAAA,aAAA,EAAe,oBAAoB,CAAA,GAC3C,kBAAkB,YAAY,CAA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CAAA,CAAA,CAAE,GAAI,CAAA,CAAC,0BACN,aAAA,CAAA,WAAA,EAAA;AAAA,cAAa,GAAG,KAAA;AAAA,cAAO,KAAK,KAAM,CAAA,KAAA;AAAA,aAAO,CAC3C,CAAA;AAAA,WACH,CAAA;AAAA,SACF,CAAA;AAAA,OAAA;AAAA,KACF,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { makePrefixer, Tooltip } from '@salt-ds/core';
|
|
3
|
-
import { ChevronRightIcon } from '@salt-ds/icons';
|
|
2
|
+
import { makePrefixer, useIcon, Tooltip } from '@salt-ds/core';
|
|
4
3
|
import { clsx } from 'clsx';
|
|
5
4
|
import { forwardRef, useRef, useState, useEffect } from 'react';
|
|
6
5
|
import '../list-deprecated/List.js';
|
|
@@ -51,6 +50,7 @@ const DefaultMenuItem = forwardRef(
|
|
|
51
50
|
css: css_248z,
|
|
52
51
|
window: targetWindow
|
|
53
52
|
});
|
|
53
|
+
const { ExpandGroupIcon } = useIcon();
|
|
54
54
|
const menuTextRef = useRef(null);
|
|
55
55
|
const [hasTooltip, setHasTooltip] = useState(false);
|
|
56
56
|
const menuText = itemToString(sourceItem);
|
|
@@ -121,7 +121,7 @@ const DefaultMenuItem = forwardRef(
|
|
|
121
121
|
className: clsx(withBaseName("menuItemEndAdornmentContainer"), {
|
|
122
122
|
[withBaseName("menuItemAdornmentHidden")]: !hasSubMenu
|
|
123
123
|
}),
|
|
124
|
-
children: /* @__PURE__ */ jsx(
|
|
124
|
+
children: /* @__PURE__ */ jsx(ExpandGroupIcon, {
|
|
125
125
|
className: clsx(withBaseName("menuItemEndAdornment"), {
|
|
126
126
|
[withBaseName("menuItemDisabled")]: isDisabled
|
|
127
127
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CascadingMenuItem.js","sources":["../src/cascading-menu/CascadingMenuItem.tsx"],"sourcesContent":["import { Tooltip, makePrefixer } from \"@salt-ds/core\";\nimport {
|
|
1
|
+
{"version":3,"file":"CascadingMenuItem.js","sources":["../src/cascading-menu/CascadingMenuItem.tsx"],"sourcesContent":["import { Tooltip, makePrefixer, useIcon } from \"@salt-ds/core\";\nimport { clsx } from \"clsx\";\nimport {\n type KeyboardEvent,\n type MouseEvent,\n forwardRef,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { ListItem, type ListItemProps } from \"../list-deprecated\";\nimport type { MenuDescriptor } from \"./CascadingMenuProps\";\n\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\n\nimport cascadingMenuItemCss from \"./CascadingMenuItem.css\";\n\nconst noop = () => undefined;\nconst withBaseName = makePrefixer(\"saltMenuItem\");\n\nconst getIcon = (sourceItem: MenuDescriptor, isDisabled = false) => {\n const CustomIcon = sourceItem.icon;\n if (CustomIcon) {\n return (\n <CustomIcon\n className={clsx(withBaseName(\"menuItemStartAdornment\"), {\n [withBaseName(\"menuItemDisabled\")]: isDisabled,\n })}\n />\n );\n }\n return null;\n};\n\nexport interface MenuItemProps extends ListItemProps<MenuDescriptor> {\n blurSelected: boolean;\n className?: string;\n hasEndAdornment: boolean;\n hasScrollbar: boolean;\n hasStartAdornment: boolean;\n hasSubMenu: boolean;\n isInteracted: boolean;\n isChildMenuOpen: boolean;\n isNavigatingWithKeyboard: boolean;\n itemToString: Required<ListItemProps<MenuDescriptor>>[\"itemToString\"];\n onItemClick?: (\n sourceItem: MenuDescriptor,\n event: MouseEvent | KeyboardEvent,\n ) => void;\n sourceItem: MenuDescriptor;\n tooltipEnterDelay: number;\n tooltipLeaveDelay: number;\n}\n\nexport const DefaultMenuItem = forwardRef<HTMLDivElement, MenuItemProps>(\n (props, ref) => {\n const {\n blurSelected,\n className,\n hasEndAdornment,\n hasScrollbar,\n hasStartAdornment,\n onItemClick,\n itemToString,\n isInteracted,\n isNavigatingWithKeyboard,\n isChildMenuOpen,\n hasSubMenu,\n sourceItem,\n tooltipEnterDelay,\n tooltipLeaveDelay,\n ...restProps\n } = props;\n\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-cascading-menu-item\",\n css: cascadingMenuItemCss,\n window: targetWindow,\n });\n const { ExpandGroupIcon } = useIcon();\n const menuTextRef = useRef<HTMLDivElement>(null);\n const [hasTooltip, setHasTooltip] = useState(false);\n const menuText = itemToString(sourceItem);\n\n useEffect(() => {\n const element = menuTextRef.current;\n if (element) {\n if (element.offsetWidth < element.scrollWidth) {\n setHasTooltip(true);\n }\n }\n }, [menuText]);\n\n const isDisabled = sourceItem.disabled;\n const divider = sourceItem.divider;\n\n const onClick = isDisabled || hasSubMenu ? noop : onItemClick;\n\n const handleOnClick = (event: MouseEvent) => {\n if (!isDisabled && !hasSubMenu) {\n onClick?.(sourceItem, event);\n }\n };\n const interactionClasses = isNavigatingWithKeyboard\n ? {\n [withBaseName(\"menuItemKeyboardActive\")]:\n !isDisabled && isInteracted && !blurSelected,\n [withBaseName(\"menuItemKeyboardDisabled\")]:\n isDisabled && isInteracted,\n }\n : {\n [withBaseName(\"menuItemHover\")]: !isDisabled && !blurSelected,\n };\n\n const icon = hasStartAdornment ? getIcon(sourceItem, isDisabled) : null;\n const tooltipTitle = sourceItem.tooltip || menuText;\n\n return (\n <Tooltip\n disableFocusListener\n disableHoverListener\n enterDelay={tooltipEnterDelay}\n leaveDelay={tooltipLeaveDelay}\n placement=\"top\"\n disabled={!tooltipTitle || !hasTooltip || isChildMenuOpen}\n content={tooltipTitle}\n >\n <ListItem\n ref={ref}\n aria-expanded={isChildMenuOpen || undefined}\n className={clsx(\n withBaseName(),\n {\n [withBaseName(\"menuItemDivider\")]: divider,\n [withBaseName(\"menuItemBlurSelected\")]: blurSelected,\n [withBaseName(\"menuItemSelected\")]:\n !isDisabled && !hasSubMenu && isInteracted,\n ...interactionClasses,\n [withBaseName(\"menuItemWithScrollbar\")]: hasScrollbar,\n },\n className,\n )}\n disabled={isDisabled}\n role=\"menuitem\"\n onClick={handleOnClick}\n item={sourceItem}\n // TODO highlightProps - see original code?\n {...restProps}\n >\n {hasStartAdornment && (\n <div className={withBaseName(\"menuItemStartAdornmentContainer\")}>\n {icon}\n </div>\n )}\n <div\n className={clsx(withBaseName(\"menuItemText\"), {\n [withBaseName(\"menuItemDisabled\")]: isDisabled,\n })}\n ref={menuTextRef}\n >\n {menuText}\n </div>\n {hasEndAdornment && (\n <div\n className={clsx(withBaseName(\"menuItemEndAdornmentContainer\"), {\n [withBaseName(\"menuItemAdornmentHidden\")]: !hasSubMenu,\n })}\n >\n <ExpandGroupIcon\n className={clsx(withBaseName(\"menuItemEndAdornment\"), {\n [withBaseName(\"menuItemDisabled\")]: isDisabled,\n })}\n />\n </div>\n )}\n {divider && <div role=\"separator\" />}\n </ListItem>\n </Tooltip>\n );\n },\n);\n"],"names":["cascadingMenuItemCss","ListItem"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAM,OAAO,MAAM,KAAA,CAAA,CAAA;AACnB,MAAM,YAAA,GAAe,aAAa,cAAc,CAAA,CAAA;AAEhD,MAAM,OAAU,GAAA,CAAC,UAA4B,EAAA,UAAA,GAAa,KAAU,KAAA;AAClE,EAAA,MAAM,aAAa,UAAW,CAAA,IAAA,CAAA;AAC9B,EAAA,IAAI,UAAY,EAAA;AACd,IAAA,uBACG,GAAA,CAAA,UAAA,EAAA;AAAA,MACC,SAAW,EAAA,IAAA,CAAK,YAAa,CAAA,wBAAwB,CAAG,EAAA;AAAA,QACtD,CAAC,YAAa,CAAA,kBAAkB,CAAI,GAAA,UAAA;AAAA,OACrC,CAAA;AAAA,KACH,CAAA,CAAA;AAAA,GAEJ;AACA,EAAO,OAAA,IAAA,CAAA;AACT,CAAA,CAAA;AAsBO,MAAM,eAAkB,GAAA,UAAA;AAAA,EAC7B,CAAC,OAAO,GAAQ,KAAA;AACd,IAAM,MAAA;AAAA,MACJ,YAAA;AAAA,MACA,SAAA;AAAA,MACA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AA;AAAA,SAAA;AAAA,OACpC,CAAA;AAAA,KACF,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { makePrefixer, useId, Button } from '@salt-ds/core';
|
|
3
|
-
import { ChevronUpIcon, ChevronDownIcon } from '@salt-ds/icons';
|
|
2
|
+
import { makePrefixer, useIcon, useId, Button } from '@salt-ds/core';
|
|
4
3
|
import { clsx } from 'clsx';
|
|
5
4
|
import { forwardRef, useState } from 'react';
|
|
6
5
|
import './internal/FavoriteToggleWithTooltip.js';
|
|
@@ -11,6 +10,7 @@ const ContactMetadata = forwardRef(
|
|
|
11
10
|
function ContactMetadata2(props, ref) {
|
|
12
11
|
const { collapsible, children, collapseButtonId, className, ...restProps } = props;
|
|
13
12
|
const { primaryId, variant, isStacked } = useContactDetailsContext();
|
|
13
|
+
const { CollapseIcon, ExpandIcon } = useIcon();
|
|
14
14
|
const [showMetadata, setShowMetadata] = useState(!collapsible);
|
|
15
15
|
const toggleShowMetadata = () => {
|
|
16
16
|
setShowMetadata(!showMetadata);
|
|
@@ -30,7 +30,7 @@ const ContactMetadata = forwardRef(
|
|
|
30
30
|
onClick: toggleShowMetadata,
|
|
31
31
|
variant: "secondary",
|
|
32
32
|
className: withBaseName("expander"),
|
|
33
|
-
children: showMetadata ? /* @__PURE__ */ jsx(
|
|
33
|
+
children: showMetadata ? /* @__PURE__ */ jsx(CollapseIcon, {}) : /* @__PURE__ */ jsx(ExpandIcon, {})
|
|
34
34
|
}) : null,
|
|
35
35
|
!collapsible || showMetadata ? /* @__PURE__ */ jsxs("div", {
|
|
36
36
|
...restProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContactMetadata.js","sources":["../src/contact-details/ContactMetadata.tsx"],"sourcesContent":["import { Button, makePrefixer, useId } from \"@salt-ds/core\";\nimport {
|
|
1
|
+
{"version":3,"file":"ContactMetadata.js","sources":["../src/contact-details/ContactMetadata.tsx"],"sourcesContent":["import { Button, makePrefixer, useIcon, useId } from \"@salt-ds/core\";\nimport { clsx } from \"clsx\";\nimport { type HTMLAttributes, forwardRef, useState } from \"react\";\nimport { useContactDetailsContext } from \"./internal\";\n\nconst withBaseName = makePrefixer(\"saltContactMetadata\");\n\nexport interface ContactMetadataProps extends HTMLAttributes<HTMLDivElement> {\n collapsible?: boolean;\n collapseButtonId?: string;\n}\n\nexport const ContactMetadata = forwardRef<HTMLDivElement, ContactMetadataProps>(\n function ContactMetadata(props, ref) {\n const { collapsible, children, collapseButtonId, className, ...restProps } =\n props;\n const { primaryId, variant, isStacked } = useContactDetailsContext();\n const { CollapseIcon, ExpandIcon } = useIcon();\n const [showMetadata, setShowMetadata] = useState<boolean>(!collapsible);\n\n const toggleShowMetadata = () => {\n setShowMetadata(!showMetadata);\n };\n\n if (variant !== \"default\") {\n return null;\n }\n\n const variantClassName = withBaseName(isStacked ? \"stacked\" : \"default\");\n\n const id = useId(collapseButtonId);\n\n return (\n <>\n {collapsible ? (\n <Button\n aria-expanded={showMetadata}\n aria-label={showMetadata ? \"Collapse\" : \"Expand\"}\n aria-labelledby={`${id} ${primaryId}`}\n id={id}\n onClick={toggleShowMetadata}\n variant=\"secondary\"\n className={withBaseName(\"expander\")}\n >\n {showMetadata ? <CollapseIcon /> : <ExpandIcon />}\n </Button>\n ) : null}\n {!collapsible || showMetadata ? (\n <div\n {...restProps}\n ref={ref}\n className={clsx(withBaseName(), variantClassName, className)}\n >\n {collapsible ? <div className={withBaseName(\"separator\")} /> : null}\n {children}\n </div>\n ) : null}\n </>\n );\n },\n);\n"],"names":["ContactMetadata"],"mappings":";;;;;;;AAKA,MAAM,YAAA,GAAe,aAAa,qBAAqB,CAAA,CAAA;AAOhD,MAAM,eAAkB,GAAA,UAAA;AAAA,EAC7B,SAASA,gBAAgB,CAAA,KAAA,EAAO,GAAK,EAAA;AACnC,IAAA,MAAM,EAAE,WAA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;AAAA,UACE,GAAG,SAAA;AAAA,UACJ,GAAA;AAAA,UACA,SAAW,EAAA,IAAA,CAAK,YAAa,EAAA,EAAG,kBAAkB,SAAS,CAAA;AAAA,UAE1D,QAAA,EAAA;AAAA,YAAA,WAAA,mBAAe,GAAA,CAAA,KAAA,EAAA;AAAA,cAAI,SAAA,EAAW,aAAa,WAAW,CAAA;AAAA,aAAG,CAAK,GAAA,IAAA;AAAA,YAC9D,QAAA;AAAA,WAAA;AAAA,SACH,CACE,GAAA,IAAA;AAAA,OAAA;AAAA,KACN,CAAA,CAAA;AAAA,GAEJ;AACF;;;;"}
|
|
@@ -7,6 +7,8 @@ import { clsx } from 'clsx';
|
|
|
7
7
|
import { forwardRef, useRef, useCallback, useEffect, useState } from 'react';
|
|
8
8
|
import '../calendar/Calendar.js';
|
|
9
9
|
import '../calendar/CalendarNavigation.js';
|
|
10
|
+
import '../calendar/CalendarWeekHeader.js';
|
|
11
|
+
import '../calendar/CalendarDateGrid.js';
|
|
10
12
|
import '../calendar/internal/CalendarContext.js';
|
|
11
13
|
import { getCurrentLocale, formatDate } from '../calendar/formatDate.js';
|
|
12
14
|
import '../calendar/useCalendarSelection.js';
|