@cloudscape-design/components 3.0.680 → 3.0.682
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/button/index.d.ts.map +1 -1
- package/button/index.js +2 -2
- package/button/index.js.map +1 -1
- package/button/interfaces.d.ts +6 -0
- package/button/interfaces.d.ts.map +1 -1
- package/button/interfaces.js.map +1 -1
- package/button/internal.d.ts.map +1 -1
- package/button/internal.js +15 -4
- package/button/internal.js.map +1 -1
- package/button/styles.css.js +20 -19
- package/button/styles.scoped.css +161 -167
- package/button/styles.selectors.js +20 -19
- package/button/test-classes/styles.css.js +6 -0
- package/button/test-classes/styles.scoped.css +7 -0
- package/button/test-classes/styles.selectors.js +7 -0
- package/button-dropdown/category-elements/expandable-category-element.js +1 -1
- package/button-dropdown/category-elements/expandable-category-element.js.map +1 -1
- package/button-dropdown/category-elements/mobile-expandable-category-element.js +1 -1
- package/button-dropdown/category-elements/mobile-expandable-category-element.js.map +1 -1
- package/button-dropdown/index.d.ts.map +1 -1
- package/button-dropdown/index.js +2 -2
- package/button-dropdown/index.js.map +1 -1
- package/button-dropdown/interfaces.d.ts +7 -0
- package/button-dropdown/interfaces.d.ts.map +1 -1
- package/button-dropdown/interfaces.js.map +1 -1
- package/button-dropdown/internal.d.ts.map +1 -1
- package/button-dropdown/internal.js +4 -2
- package/button-dropdown/internal.js.map +1 -1
- package/button-dropdown/item-element/index.js +1 -1
- package/button-dropdown/item-element/index.js.map +1 -1
- package/calendar/grid/index.d.ts +3 -1
- package/calendar/grid/index.d.ts.map +1 -1
- package/calendar/grid/index.js +26 -6
- package/calendar/grid/index.js.map +1 -1
- package/calendar/grid/use-calendar-grid-keyboard-navigation.d.ts +2 -1
- package/calendar/grid/use-calendar-grid-keyboard-navigation.d.ts.map +1 -1
- package/calendar/grid/use-calendar-grid-keyboard-navigation.js +8 -5
- package/calendar/grid/use-calendar-grid-keyboard-navigation.js.map +1 -1
- package/calendar/interfaces.d.ts +9 -0
- package/calendar/interfaces.d.ts.map +1 -1
- package/calendar/interfaces.js.map +1 -1
- package/calendar/internal.d.ts +1 -1
- package/calendar/internal.d.ts.map +1 -1
- package/calendar/internal.js +7 -5
- package/calendar/internal.js.map +1 -1
- package/calendar/styles.css.js +21 -20
- package/calendar/styles.scoped.css +46 -42
- package/calendar/styles.selectors.js +21 -20
- package/calendar/utils/navigation.d.ts +10 -10
- package/calendar/utils/navigation.d.ts.map +1 -1
- package/calendar/utils/navigation.js +29 -29
- package/calendar/utils/navigation.js.map +1 -1
- package/column-layout/flexible-column-layout/index.d.ts +2 -2
- package/column-layout/flexible-column-layout/index.d.ts.map +1 -1
- package/column-layout/flexible-column-layout/index.js +3 -2
- package/column-layout/flexible-column-layout/index.js.map +1 -1
- package/column-layout/flexible-column-layout/styles.css.js +5 -5
- package/column-layout/flexible-column-layout/styles.scoped.css +99 -4
- package/column-layout/flexible-column-layout/styles.selectors.js +5 -5
- package/column-layout/grid-column-layout.d.ts +2 -2
- package/column-layout/grid-column-layout.d.ts.map +1 -1
- package/column-layout/grid-column-layout.js +2 -2
- package/column-layout/grid-column-layout.js.map +1 -1
- package/column-layout/interfaces.d.ts +4 -0
- package/column-layout/interfaces.d.ts.map +1 -1
- package/column-layout/interfaces.js.map +1 -1
- package/column-layout/internal.d.ts +1 -1
- package/column-layout/internal.d.ts.map +1 -1
- package/column-layout/internal.js +2 -2
- package/column-layout/internal.js.map +1 -1
- package/date-picker/index.d.ts.map +1 -1
- package/date-picker/index.js +2 -2
- package/date-picker/index.js.map +1 -1
- package/date-range-picker/calendar/grids/grid.d.ts +2 -1
- package/date-range-picker/calendar/grids/grid.d.ts.map +1 -1
- package/date-range-picker/calendar/grids/grid.js +55 -7
- package/date-range-picker/calendar/grids/grid.js.map +1 -1
- package/date-range-picker/calendar/grids/index.d.ts +2 -1
- package/date-range-picker/calendar/grids/index.d.ts.map +1 -1
- package/date-range-picker/calendar/grids/index.js +20 -12
- package/date-range-picker/calendar/grids/index.js.map +1 -1
- package/date-range-picker/calendar/grids/styles.css.js +28 -27
- package/date-range-picker/calendar/grids/styles.scoped.css +46 -42
- package/date-range-picker/calendar/grids/styles.selectors.js +28 -27
- package/date-range-picker/calendar/index.d.ts +2 -1
- package/date-range-picker/calendar/index.d.ts.map +1 -1
- package/date-range-picker/calendar/index.js +2 -2
- package/date-range-picker/calendar/index.js.map +1 -1
- package/date-range-picker/dropdown.d.ts +2 -2
- package/date-range-picker/dropdown.d.ts.map +1 -1
- package/date-range-picker/dropdown.js +2 -2
- package/date-range-picker/dropdown.js.map +1 -1
- package/date-range-picker/index.d.ts.map +1 -1
- package/date-range-picker/index.js +2 -2
- package/date-range-picker/index.js.map +1 -1
- package/date-range-picker/interfaces.d.ts +9 -0
- package/date-range-picker/interfaces.d.ts.map +1 -1
- package/date-range-picker/interfaces.js.map +1 -1
- package/grid/internal.d.ts +4 -0
- package/grid/internal.d.ts.map +1 -1
- package/grid/internal.js +3 -2
- package/grid/internal.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/internal/base-component/styles.scoped.css +12 -10
- package/internal/components/option/interfaces.d.ts +2 -0
- package/internal/components/option/interfaces.d.ts.map +1 -1
- package/internal/components/option/interfaces.js.map +1 -1
- package/internal/components/selectable-item/index.d.ts +1 -0
- package/internal/components/selectable-item/index.d.ts.map +1 -1
- package/internal/components/selectable-item/index.js +3 -0
- package/internal/components/selectable-item/index.js.map +1 -1
- package/internal/components/tooltip/index.d.ts +3 -1
- package/internal/components/tooltip/index.d.ts.map +1 -1
- package/internal/components/tooltip/index.js +3 -3
- package/internal/components/tooltip/index.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/generated/styles/tokens.d.ts +2 -0
- package/internal/generated/styles/tokens.js +4 -2
- package/internal/generated/theming/index.cjs +78 -12
- package/internal/generated/theming/index.cjs.d.ts +16 -0
- package/internal/generated/theming/index.d.ts +16 -0
- package/internal/generated/theming/index.js +78 -12
- package/{button-dropdown/utils/use-hidden-description.d.ts → internal/hooks/use-hidden-description/index.d.ts} +2 -1
- package/internal/hooks/use-hidden-description/index.d.ts.map +1 -0
- package/{button-dropdown/utils/use-hidden-description.js → internal/hooks/use-hidden-description/index.js} +3 -2
- package/internal/hooks/use-hidden-description/index.js.map +1 -0
- package/internal/manifest.json +1 -1
- package/key-value-pairs/index.d.ts +5 -0
- package/key-value-pairs/index.d.ts.map +1 -0
- package/key-value-pairs/index.js +18 -0
- package/key-value-pairs/index.js.map +1 -0
- package/key-value-pairs/interfaces.d.ts +42 -0
- package/key-value-pairs/interfaces.d.ts.map +1 -0
- package/key-value-pairs/interfaces.js +2 -0
- package/key-value-pairs/interfaces.js.map +1 -0
- package/key-value-pairs/internal.d.ts +5 -0
- package/key-value-pairs/internal.d.ts.map +1 -0
- package/key-value-pairs/internal.js +41 -0
- package/key-value-pairs/internal.js.map +1 -0
- package/key-value-pairs/styles.css.js +13 -0
- package/key-value-pairs/styles.scoped.css +210 -0
- package/key-value-pairs/styles.selectors.js +14 -0
- package/package.json +2 -1
- package/segmented-control/interfaces.d.ts +2 -0
- package/segmented-control/interfaces.d.ts.map +1 -1
- package/segmented-control/interfaces.js.map +1 -1
- package/segmented-control/internal-segmented-control.d.ts.map +1 -1
- package/segmented-control/internal-segmented-control.js +11 -8
- package/segmented-control/internal-segmented-control.js.map +1 -1
- package/segmented-control/segment.d.ts.map +1 -1
- package/segmented-control/segment.js +14 -4
- package/segmented-control/segment.js.map +1 -1
- package/segmented-control/styles.css.js +15 -14
- package/segmented-control/styles.scoped.css +37 -33
- package/segmented-control/styles.selectors.js +15 -14
- package/select/interfaces.d.ts +1 -0
- package/select/interfaces.d.ts.map +1 -1
- package/select/interfaces.js.map +1 -1
- package/select/parts/filter.d.ts +1 -1
- package/select/parts/item.d.ts.map +1 -1
- package/select/parts/item.js +13 -3
- package/select/parts/item.js.map +1 -1
- package/select/parts/multiselect-item.d.ts.map +1 -1
- package/select/parts/multiselect-item.js +15 -3
- package/select/parts/multiselect-item.js.map +1 -1
- package/select/parts/styles.css.js +17 -16
- package/select/parts/styles.scoped.css +21 -17
- package/select/parts/styles.selectors.js +17 -16
- package/split-panel/icons/styles.css.js +22 -22
- package/split-panel/icons/styles.scoped.css +25 -25
- package/split-panel/icons/styles.selectors.js +22 -22
- package/table/body-cell/disabled-inline-editor.js +1 -1
- package/table/body-cell/disabled-inline-editor.js.map +1 -1
- package/tabs/interfaces.d.ts +5 -0
- package/tabs/interfaces.d.ts.map +1 -1
- package/tabs/interfaces.js.map +1 -1
- package/tabs/styles.css.js +28 -25
- package/tabs/styles.scoped.css +60 -49
- package/tabs/styles.selectors.js +28 -25
- package/tabs/tab-header-bar.d.ts.map +1 -1
- package/tabs/tab-header-bar.js +38 -14
- package/tabs/tab-header-bar.js.map +1 -1
- package/test-utils/dom/button/index.d.ts +1 -0
- package/test-utils/dom/button/index.js +6 -2
- package/test-utils/dom/button/index.js.map +1 -1
- package/test-utils/dom/button-dropdown/index.d.ts +2 -1
- package/test-utils/dom/button-dropdown/index.js +5 -1
- package/test-utils/dom/button-dropdown/index.js.map +1 -1
- package/test-utils/dom/calendar/index.d.ts +4 -1
- package/test-utils/dom/calendar/index.js +8 -1
- package/test-utils/dom/calendar/index.js.map +1 -1
- package/test-utils/dom/date-range-picker/index.d.ts +4 -1
- package/test-utils/dom/date-range-picker/index.js +8 -2
- package/test-utils/dom/date-range-picker/index.js.map +1 -1
- package/test-utils/dom/index.d.ts +3 -0
- package/test-utils/dom/index.js +10 -2
- package/test-utils/dom/index.js.map +1 -1
- package/test-utils/dom/internal/dropdown-host.js.map +1 -1
- package/test-utils/dom/internal/option.d.ts +1 -0
- package/test-utils/dom/internal/option.js +4 -0
- package/test-utils/dom/internal/option.js.map +1 -1
- package/test-utils/dom/key-value-pairs/index.d.ts +14 -0
- package/test-utils/dom/key-value-pairs/index.js +38 -0
- package/test-utils/dom/key-value-pairs/index.js.map +1 -0
- package/test-utils/dom/segmented-control/index.d.ts +9 -0
- package/test-utils/dom/segmented-control/index.js +15 -0
- package/test-utils/dom/segmented-control/index.js.map +1 -1
- package/test-utils/dom/tabs/index.d.ts +9 -2
- package/test-utils/dom/tabs/index.js +15 -2
- package/test-utils/dom/tabs/index.js.map +1 -1
- package/test-utils/selectors/button/index.d.ts +1 -0
- package/test-utils/selectors/button/index.js +6 -2
- package/test-utils/selectors/button/index.js.map +1 -1
- package/test-utils/selectors/button-dropdown/index.d.ts +2 -1
- package/test-utils/selectors/button-dropdown/index.js +5 -1
- package/test-utils/selectors/button-dropdown/index.js.map +1 -1
- package/test-utils/selectors/calendar/index.d.ts +4 -1
- package/test-utils/selectors/calendar/index.js +8 -1
- package/test-utils/selectors/calendar/index.js.map +1 -1
- package/test-utils/selectors/date-range-picker/index.d.ts +4 -1
- package/test-utils/selectors/date-range-picker/index.js +8 -2
- package/test-utils/selectors/date-range-picker/index.js.map +1 -1
- package/test-utils/selectors/index.d.ts +3 -0
- package/test-utils/selectors/index.js +10 -2
- package/test-utils/selectors/index.js.map +1 -1
- package/test-utils/selectors/internal/dropdown-host.js.map +1 -1
- package/test-utils/selectors/internal/option.d.ts +1 -0
- package/test-utils/selectors/internal/option.js +4 -0
- package/test-utils/selectors/internal/option.js.map +1 -1
- package/test-utils/selectors/key-value-pairs/index.d.ts +14 -0
- package/test-utils/selectors/key-value-pairs/index.js +38 -0
- package/test-utils/selectors/key-value-pairs/index.js.map +1 -0
- package/test-utils/selectors/segmented-control/index.d.ts +9 -0
- package/test-utils/selectors/segmented-control/index.js +15 -0
- package/test-utils/selectors/segmented-control/index.js.map +1 -1
- package/test-utils/selectors/tabs/index.d.ts +9 -2
- package/test-utils/selectors/tabs/index.js +15 -2
- package/test-utils/selectors/tabs/index.js.map +1 -1
- package/test-utils/tsconfig.tsbuildinfo +1 -1
- package/button-dropdown/utils/use-hidden-description.d.ts.map +0 -1
- package/button-dropdown/utils/use-hidden-description.js.map +0 -1
|
@@ -1 +1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EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAC3B,iBAAiB,EAAE,KAAK,CAAC,EAAE,CACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,iCAAM,QAAQ,KAAE,KAAK,kCAAO,QAAQ,CAAC,KAAK,KAAE,IAAI,EAAE,KAAK,OAAK,CAAC,EAEpF,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EACvB,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,iCAAM,QAAQ,KAAE,GAAG,kCAAO,QAAQ,CAAC,GAAG,KAAE,IAAI,EAAE,KAAK,OAAK,CAAC,EACxG,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EACvB,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,iCAAM,QAAQ,KAAE,GAAG,kCAAO,QAAQ,CAAC,GAAG,KAAE,IAAI,EAAE,KAAK,OAAK,CAAC,EACxG,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,GAChC;gBACD,0BAA0B,IAAI,iCAAM,0BAA0B,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAO,CACrF,CACX;QACN,oBAAC,UAAU,IAAC,SAAS,EAAE,MAAM,CAAC,oBAAoB,CAAC,IAAG,YAAY,CAAc,CAC/E,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useState } from 'react';\nimport { addMonths, endOfDay, isAfter, isBefore, isSameMonth, startOfDay, startOfMonth } from 'date-fns';\nimport styles from '../styles.css.js';\nimport SpaceBetween from '../../space-between/internal';\nimport { BaseComponentProps } from '../../internal/base-component';\nimport { DateRangePickerProps, RangeCalendarI18nStrings } from '../interfaces';\nimport CalendarHeader from './header';\nimport { Grids } from './grids';\nimport { TimeInputProps } from '../../time-input/interfaces';\nimport clsx from 'clsx';\nimport { useUniqueId } from '../../internal/hooks/use-unique-id';\nimport { getDateLabel, renderTimeLabel } from '../../calendar/utils/intl';\nimport LiveRegion from '../../internal/components/live-region';\nimport { normalizeLocale, normalizeStartOfWeek } from '../../internal/utils/locale';\nimport { parseDate, splitDateTime, formatDateTime } from '../../internal/utils/date-time';\nimport { getBaseDay } from '../../calendar/utils/navigation';\nimport { useMobile } from '../../internal/hooks/use-mobile/index.js';\nimport RangeInputs from './range-inputs.js';\nimport { findDateToFocus, findMonthToDisplay } from './utils';\nimport { useInternalI18n } from '../../i18n/context.js';\n\nexport interface DateRangePickerCalendarProps extends BaseComponentProps {\n value: DateRangePickerProps.PendingAbsoluteValue;\n setValue: React.Dispatch<React.SetStateAction<DateRangePickerProps.PendingAbsoluteValue>>;\n locale?: string;\n startOfWeek?: number;\n isDateEnabled?: (date: Date) => boolean;\n i18nStrings?: RangeCalendarI18nStrings;\n dateOnly?: boolean;\n timeInputFormat?: TimeInputProps.Format;\n customAbsoluteRangeControl: DateRangePickerProps.AbsoluteRangeControl | undefined;\n}\n\nexport default function DateRangePickerCalendar({\n value,\n setValue,\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n i18nStrings,\n dateOnly = false,\n timeInputFormat = 'hh:mm:ss',\n customAbsoluteRangeControl,\n}: DateRangePickerCalendarProps) {\n const isSingleGrid = useMobile();\n const normalizedLocale = normalizeLocale('DateRangePicker', locale);\n const normalizedStartOfWeek = normalizeStartOfWeek(startOfWeek, normalizedLocale);\n const i18n = useInternalI18n('date-range-picker');\n\n const [announcement, setAnnouncement] = useState('');\n const [currentMonth, setCurrentMonth] = useState(() => findMonthToDisplay(value, isSingleGrid));\n const [focusedDate, setFocusedDate] = useState<Date | null>(() => {\n if (value.start.date) {\n const startDate = parseDate(value.start.date);\n if (isSameMonth(startDate, currentMonth)) {\n return startDate;\n }\n if (!isSingleGrid && isSameMonth(startDate, addMonths(currentMonth, -1))) {\n return startDate;\n }\n }\n return findDateToFocus(parseDate(value.start.date), currentMonth, isDateEnabled);\n });\n\n const updateCurrentMonth = (startDate: string) => {\n if (startDate.length >= 8) {\n const newCurrentMonth = startOfMonth(parseDate(startDate));\n setCurrentMonth(isSingleGrid ? newCurrentMonth : addMonths(newCurrentMonth, 1));\n }\n };\n\n // recommended to include the start/end time announced with the selection\n // because the user is not aware of the fact that a start/end time is also set as soon as they select a date\n const announceStart = (startDate: Date) => {\n return (\n i18n('i18nStrings.startDateLabel', i18nStrings?.startDateLabel) +\n ', ' +\n getDateLabel(normalizedLocale, startDate) +\n ', ' +\n i18n('i18nStrings.startTimeLabel', i18nStrings?.startTimeLabel) +\n ', ' +\n renderTimeLabel(normalizedLocale, startDate, timeInputFormat) +\n '. '\n );\n };\n\n const announceEnd = (endDate: Date) => {\n return (\n i18n('i18nStrings.endDateLabel', i18nStrings?.endDateLabel) +\n ', ' +\n getDateLabel(normalizedLocale, endDate) +\n ', ' +\n i18n('i18nStrings.endTimeLabel', i18nStrings?.endTimeLabel) +\n ', ' +\n renderTimeLabel(normalizedLocale, endDate, timeInputFormat) +\n '. '\n );\n };\n\n const renderSelectedAbsoluteRangeAriaLive = i18n(\n 'i18nStrings.renderSelectedAbsoluteRangeAriaLive',\n i18nStrings?.renderSelectedAbsoluteRangeAriaLive,\n format => (startDate, endDate) => format({ startDate, endDate })\n );\n\n const announceRange = (startDate: Date, endDate: Date) => {\n if (!renderSelectedAbsoluteRangeAriaLive) {\n return `${getDateLabel(normalizedLocale, startDate)} – ${getDateLabel(normalizedLocale, endDate)}`;\n }\n return renderSelectedAbsoluteRangeAriaLive(\n getDateLabel(normalizedLocale, startDate),\n getDateLabel(normalizedLocale, endDate)\n );\n };\n\n const onSelectDateHandler = (selectedDate: Date) => {\n const { start, end } = value;\n let newStart: Date | undefined = undefined;\n let newEnd: Date | null | undefined = undefined;\n let announcement = '';\n\n // If both fields are empty, we set the start date\n if (!start.date && !end.date) {\n newStart = startOfDay(selectedDate);\n announcement = announceStart(newStart);\n }\n // If both fields are set, we start new\n else if (start.date && end.date) {\n newStart = startOfDay(selectedDate);\n newEnd = null;\n announcement = announceStart(newStart);\n }\n // If only the END date is empty, we fill it (and swap dates if needed)\n else if (start.date && !end.date) {\n const parsedStartDate = parseDate(start.date);\n\n if (isBefore(selectedDate, parsedStartDate)) {\n // The user has selected the range backwards, so we swap start and end\n newStart = startOfDay(selectedDate);\n newEnd = endOfDay(parsedStartDate);\n announcement = announceStart(newStart) + announceRange(newStart, newEnd);\n } else {\n newEnd = endOfDay(selectedDate);\n announcement = announceEnd(newEnd) + announceRange(parsedStartDate, newEnd);\n }\n }\n // If only the START date is empty, we fill it (and swap dates if needed)\n else if (!start.date && end.date) {\n const existingEndDate = parseDate(end.date);\n\n if (isAfter(selectedDate, existingEndDate)) {\n // The user has selected the range backwards, so we swap start and end\n newStart = startOfDay(existingEndDate);\n newEnd = endOfDay(selectedDate);\n announcement = announceEnd(newEnd) + announceRange(newStart, newEnd);\n } else {\n newStart = startOfDay(selectedDate);\n announcement = announceStart(newStart) + announceRange(newStart, existingEndDate);\n }\n }\n\n const formatValue = (\n date: Date | null | undefined,\n previous: DateRangePickerProps.DateTimeStrings\n ): DateRangePickerProps.DateTimeStrings => {\n if (date === null) {\n // explicitly reset to empty\n return { date: '', time: '' };\n } else if (date === undefined) {\n // keep old value\n return previous;\n }\n return splitDateTime(formatDateTime(date));\n };\n\n setValue({\n start: formatValue(newStart, value.start),\n end: formatValue(newEnd, value.end),\n });\n setAnnouncement(announcement);\n };\n\n const onHeaderChangeMonthHandler = (newCurrentMonth: Date) => {\n setCurrentMonth(newCurrentMonth);\n\n const newBaseDateMonth = isSingleGrid ? newCurrentMonth : addMonths(newCurrentMonth, -1);\n const newBaseDate = getBaseDay(newBaseDateMonth, isDateEnabled);\n setFocusedDate(newBaseDate);\n };\n\n const onChangeStartDate = (value: string) => {\n setValue((oldValue: DateRangePickerProps.PendingAbsoluteValue) => ({\n ...oldValue,\n start: { ...oldValue.start, date: value },\n }));\n updateCurrentMonth(value);\n };\n\n const interceptedSetValue: DateRangePickerCalendarProps['setValue'] = newValue => {\n setValue(oldValue => {\n const updated = typeof newValue === 'function' ? newValue(oldValue) : newValue;\n updateCurrentMonth(updated.start.date);\n return updated;\n });\n };\n\n const headingIdPrefix = useUniqueId('date-range-picker-calendar-heading');\n return (\n <>\n <div\n className={clsx(styles['calendar-container'], {\n [styles['one-grid']]: isSingleGrid,\n })}\n >\n <SpaceBetween size=\"s\">\n <div\n className={clsx(styles.calendar, {\n [styles['one-grid']]: isSingleGrid,\n })}\n >\n <CalendarHeader\n baseDate={currentMonth}\n locale={normalizedLocale}\n onChangeMonth={onHeaderChangeMonthHandler}\n previousMonthLabel={i18nStrings?.previousMonthAriaLabel}\n nextMonthLabel={i18nStrings?.nextMonthAriaLabel}\n isSingleGrid={isSingleGrid}\n headingIdPrefix={headingIdPrefix}\n />\n\n <Grids\n isSingleGrid={isSingleGrid}\n locale={normalizedLocale}\n baseDate={currentMonth}\n focusedDate={focusedDate}\n onFocusedDateChange={setFocusedDate}\n isDateEnabled={isDateEnabled}\n onSelectDate={onSelectDateHandler}\n onChangeMonth={setCurrentMonth}\n startOfWeek={normalizedStartOfWeek}\n todayAriaLabel={i18nStrings?.todayAriaLabel}\n selectedStartDate={parseDate(value.start.date, true)}\n selectedEndDate={parseDate(value.end.date, true)}\n headingIdPrefix={headingIdPrefix}\n />\n </div>\n\n <RangeInputs\n startDate={value.start.date}\n onChangeStartDate={onChangeStartDate}\n startTime={value.start.time}\n onChangeStartTime={value =>\n setValue(oldValue => ({ ...oldValue, start: { ...oldValue.start, time: value } }))\n }\n endDate={value.end.date}\n onChangeEndDate={value => setValue(oldValue => ({ ...oldValue, end: { ...oldValue.end, date: value } }))}\n endTime={value.end.time}\n onChangeEndTime={value => setValue(oldValue => ({ ...oldValue, end: { ...oldValue.end, time: value } }))}\n i18nStrings={i18nStrings}\n dateOnly={dateOnly}\n timeInputFormat={timeInputFormat}\n />\n {customAbsoluteRangeControl && <div>{customAbsoluteRangeControl(value, interceptedSetValue)}</div>}\n </SpaceBetween>\n </div>\n <LiveRegion className={styles['calendar-aria-live']}>{announcement}</LiveRegion>\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/date-range-picker/calendar/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACzG,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,YAAY,MAAM,8BAA8B,CAAC;AAGxD,OAAO,cAAc,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,UAAU,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAC1F,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AACrE,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAexD,MAAM,CAAC,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import React, { useState } from 'react';\nimport { addMonths, endOfDay, isAfter, isBefore, isSameMonth, startOfDay, startOfMonth } from 'date-fns';\nimport styles from '../styles.css.js';\nimport SpaceBetween from '../../space-between/internal';\nimport { BaseComponentProps } from '../../internal/base-component';\nimport { DateRangePickerProps, RangeCalendarI18nStrings } from '../interfaces';\nimport CalendarHeader from './header';\nimport { Grids } from './grids';\nimport { TimeInputProps } from '../../time-input/interfaces';\nimport clsx from 'clsx';\nimport { useUniqueId } from '../../internal/hooks/use-unique-id';\nimport { getDateLabel, renderTimeLabel } from '../../calendar/utils/intl';\nimport LiveRegion from '../../internal/components/live-region';\nimport { normalizeLocale, normalizeStartOfWeek } from '../../internal/utils/locale';\nimport { parseDate, splitDateTime, formatDateTime } from '../../internal/utils/date-time';\nimport { getBaseDay } from '../../calendar/utils/navigation';\nimport { useMobile } from '../../internal/hooks/use-mobile/index.js';\nimport RangeInputs from './range-inputs.js';\nimport { findDateToFocus, findMonthToDisplay } from './utils';\nimport { useInternalI18n } from '../../i18n/context.js';\n\nexport interface DateRangePickerCalendarProps extends BaseComponentProps {\n value: DateRangePickerProps.PendingAbsoluteValue;\n setValue: React.Dispatch<React.SetStateAction<DateRangePickerProps.PendingAbsoluteValue>>;\n locale?: string;\n startOfWeek?: number;\n isDateEnabled?: (date: Date) => boolean;\n dateDisabledReason?: (date: Date) => string;\n i18nStrings?: RangeCalendarI18nStrings;\n dateOnly?: boolean;\n timeInputFormat?: TimeInputProps.Format;\n customAbsoluteRangeControl: DateRangePickerProps.AbsoluteRangeControl | undefined;\n}\n\nexport default function DateRangePickerCalendar({\n value,\n setValue,\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n dateDisabledReason = () => '',\n i18nStrings,\n dateOnly = false,\n timeInputFormat = 'hh:mm:ss',\n customAbsoluteRangeControl,\n}: DateRangePickerCalendarProps) {\n const isSingleGrid = useMobile();\n const normalizedLocale = normalizeLocale('DateRangePicker', locale);\n const normalizedStartOfWeek = normalizeStartOfWeek(startOfWeek, normalizedLocale);\n const i18n = useInternalI18n('date-range-picker');\n\n const [announcement, setAnnouncement] = useState('');\n const [currentMonth, setCurrentMonth] = useState(() => findMonthToDisplay(value, isSingleGrid));\n const [focusedDate, setFocusedDate] = useState<Date | null>(() => {\n if (value.start.date) {\n const startDate = parseDate(value.start.date);\n if (isSameMonth(startDate, currentMonth)) {\n return startDate;\n }\n if (!isSingleGrid && isSameMonth(startDate, addMonths(currentMonth, -1))) {\n return startDate;\n }\n }\n return findDateToFocus(parseDate(value.start.date), currentMonth, isDateEnabled);\n });\n\n const updateCurrentMonth = (startDate: string) => {\n if (startDate.length >= 8) {\n const newCurrentMonth = startOfMonth(parseDate(startDate));\n setCurrentMonth(isSingleGrid ? newCurrentMonth : addMonths(newCurrentMonth, 1));\n }\n };\n\n // recommended to include the start/end time announced with the selection\n // because the user is not aware of the fact that a start/end time is also set as soon as they select a date\n const announceStart = (startDate: Date) => {\n return (\n i18n('i18nStrings.startDateLabel', i18nStrings?.startDateLabel) +\n ', ' +\n getDateLabel(normalizedLocale, startDate) +\n ', ' +\n i18n('i18nStrings.startTimeLabel', i18nStrings?.startTimeLabel) +\n ', ' +\n renderTimeLabel(normalizedLocale, startDate, timeInputFormat) +\n '. '\n );\n };\n\n const announceEnd = (endDate: Date) => {\n return (\n i18n('i18nStrings.endDateLabel', i18nStrings?.endDateLabel) +\n ', ' +\n getDateLabel(normalizedLocale, endDate) +\n ', ' +\n i18n('i18nStrings.endTimeLabel', i18nStrings?.endTimeLabel) +\n ', ' +\n renderTimeLabel(normalizedLocale, endDate, timeInputFormat) +\n '. '\n );\n };\n\n const renderSelectedAbsoluteRangeAriaLive = i18n(\n 'i18nStrings.renderSelectedAbsoluteRangeAriaLive',\n i18nStrings?.renderSelectedAbsoluteRangeAriaLive,\n format => (startDate, endDate) => format({ startDate, endDate })\n );\n\n const announceRange = (startDate: Date, endDate: Date) => {\n if (!renderSelectedAbsoluteRangeAriaLive) {\n return `${getDateLabel(normalizedLocale, startDate)} – ${getDateLabel(normalizedLocale, endDate)}`;\n }\n return renderSelectedAbsoluteRangeAriaLive(\n getDateLabel(normalizedLocale, startDate),\n getDateLabel(normalizedLocale, endDate)\n );\n };\n\n const onSelectDateHandler = (selectedDate: Date) => {\n const { start, end } = value;\n let newStart: Date | undefined = undefined;\n let newEnd: Date | null | undefined = undefined;\n let announcement = '';\n\n // If both fields are empty, we set the start date\n if (!start.date && !end.date) {\n newStart = startOfDay(selectedDate);\n announcement = announceStart(newStart);\n }\n // If both fields are set, we start new\n else if (start.date && end.date) {\n newStart = startOfDay(selectedDate);\n newEnd = null;\n announcement = announceStart(newStart);\n }\n // If only the END date is empty, we fill it (and swap dates if needed)\n else if (start.date && !end.date) {\n const parsedStartDate = parseDate(start.date);\n\n if (isBefore(selectedDate, parsedStartDate)) {\n // The user has selected the range backwards, so we swap start and end\n newStart = startOfDay(selectedDate);\n newEnd = endOfDay(parsedStartDate);\n announcement = announceStart(newStart) + announceRange(newStart, newEnd);\n } else {\n newEnd = endOfDay(selectedDate);\n announcement = announceEnd(newEnd) + announceRange(parsedStartDate, newEnd);\n }\n }\n // If only the START date is empty, we fill it (and swap dates if needed)\n else if (!start.date && end.date) {\n const existingEndDate = parseDate(end.date);\n\n if (isAfter(selectedDate, existingEndDate)) {\n // The user has selected the range backwards, so we swap start and end\n newStart = startOfDay(existingEndDate);\n newEnd = endOfDay(selectedDate);\n announcement = announceEnd(newEnd) + announceRange(newStart, newEnd);\n } else {\n newStart = startOfDay(selectedDate);\n announcement = announceStart(newStart) + announceRange(newStart, existingEndDate);\n }\n }\n\n const formatValue = (\n date: Date | null | undefined,\n previous: DateRangePickerProps.DateTimeStrings\n ): DateRangePickerProps.DateTimeStrings => {\n if (date === null) {\n // explicitly reset to empty\n return { date: '', time: '' };\n } else if (date === undefined) {\n // keep old value\n return previous;\n }\n return splitDateTime(formatDateTime(date));\n };\n\n setValue({\n start: formatValue(newStart, value.start),\n end: formatValue(newEnd, value.end),\n });\n setAnnouncement(announcement);\n };\n\n const onHeaderChangeMonthHandler = (newCurrentMonth: Date) => {\n setCurrentMonth(newCurrentMonth);\n\n const newBaseDateMonth = isSingleGrid ? newCurrentMonth : addMonths(newCurrentMonth, -1);\n const newBaseDate = getBaseDay(newBaseDateMonth, isDateEnabled);\n setFocusedDate(newBaseDate);\n };\n\n const onChangeStartDate = (value: string) => {\n setValue((oldValue: DateRangePickerProps.PendingAbsoluteValue) => ({\n ...oldValue,\n start: { ...oldValue.start, date: value },\n }));\n updateCurrentMonth(value);\n };\n\n const interceptedSetValue: DateRangePickerCalendarProps['setValue'] = newValue => {\n setValue(oldValue => {\n const updated = typeof newValue === 'function' ? newValue(oldValue) : newValue;\n updateCurrentMonth(updated.start.date);\n return updated;\n });\n };\n\n const headingIdPrefix = useUniqueId('date-range-picker-calendar-heading');\n return (\n <>\n <div\n className={clsx(styles['calendar-container'], {\n [styles['one-grid']]: isSingleGrid,\n })}\n >\n <SpaceBetween size=\"s\">\n <div\n className={clsx(styles.calendar, {\n [styles['one-grid']]: isSingleGrid,\n })}\n >\n <CalendarHeader\n baseDate={currentMonth}\n locale={normalizedLocale}\n onChangeMonth={onHeaderChangeMonthHandler}\n previousMonthLabel={i18nStrings?.previousMonthAriaLabel}\n nextMonthLabel={i18nStrings?.nextMonthAriaLabel}\n isSingleGrid={isSingleGrid}\n headingIdPrefix={headingIdPrefix}\n />\n\n <Grids\n isSingleGrid={isSingleGrid}\n locale={normalizedLocale}\n baseDate={currentMonth}\n focusedDate={focusedDate}\n onFocusedDateChange={setFocusedDate}\n isDateEnabled={isDateEnabled}\n dateDisabledReason={dateDisabledReason}\n onSelectDate={onSelectDateHandler}\n onChangeMonth={setCurrentMonth}\n startOfWeek={normalizedStartOfWeek}\n todayAriaLabel={i18nStrings?.todayAriaLabel}\n selectedStartDate={parseDate(value.start.date, true)}\n selectedEndDate={parseDate(value.end.date, true)}\n headingIdPrefix={headingIdPrefix}\n />\n </div>\n\n <RangeInputs\n startDate={value.start.date}\n onChangeStartDate={onChangeStartDate}\n startTime={value.start.time}\n onChangeStartTime={value =>\n setValue(oldValue => ({ ...oldValue, start: { ...oldValue.start, time: value } }))\n }\n endDate={value.end.date}\n onChangeEndDate={value => setValue(oldValue => ({ ...oldValue, end: { ...oldValue.end, date: value } }))}\n endTime={value.end.time}\n onChangeEndTime={value => setValue(oldValue => ({ ...oldValue, end: { ...oldValue.end, time: value } }))}\n i18nStrings={i18nStrings}\n dateOnly={dateOnly}\n timeInputFormat={timeInputFormat}\n />\n {customAbsoluteRangeControl && <div>{customAbsoluteRangeControl(value, interceptedSetValue)}</div>}\n </SpaceBetween>\n </div>\n <LiveRegion className={styles['calendar-aria-live']}>{announcement}</LiveRegion>\n </>\n );\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DateRangePickerProps } from './interfaces';
|
|
3
3
|
export declare const VALID_RANGE: DateRangePickerProps.ValidRangeResult;
|
|
4
|
-
export interface DateRangePickerDropdownProps extends Pick<Required<DateRangePickerProps>, 'locale' | 'isDateEnabled' | 'isValidRange' | 'value' | 'relativeOptions' | 'showClearButton' | 'dateOnly' | 'timeInputFormat' | 'rangeSelectorMode'> {
|
|
4
|
+
export interface DateRangePickerDropdownProps extends Pick<Required<DateRangePickerProps>, 'locale' | 'isDateEnabled' | 'dateDisabledReason' | 'isValidRange' | 'value' | 'relativeOptions' | 'showClearButton' | 'dateOnly' | 'timeInputFormat' | 'rangeSelectorMode'> {
|
|
5
5
|
onClear: () => void;
|
|
6
6
|
onApply: (value: null | DateRangePickerProps.Value) => DateRangePickerProps.ValidationResult;
|
|
7
7
|
startOfWeek: number | undefined;
|
|
@@ -12,5 +12,5 @@ export interface DateRangePickerDropdownProps extends Pick<Required<DateRangePic
|
|
|
12
12
|
ariaDescribedby?: string;
|
|
13
13
|
customAbsoluteRangeControl: DateRangePickerProps.AbsoluteRangeControl | undefined;
|
|
14
14
|
}
|
|
15
|
-
export declare function DateRangePickerDropdown({ locale, startOfWeek, isDateEnabled, isValidRange, value, onClear: clearValue, onApply: applyValue, onDropdownClose, relativeOptions, showClearButton, isSingleGrid, i18nStrings, dateOnly, timeInputFormat, rangeSelectorMode, ariaLabelledby, ariaDescribedby, customAbsoluteRangeControl, }: DateRangePickerDropdownProps): JSX.Element;
|
|
15
|
+
export declare function DateRangePickerDropdown({ locale, startOfWeek, isDateEnabled, dateDisabledReason, isValidRange, value, onClear: clearValue, onApply: applyValue, onDropdownClose, relativeOptions, showClearButton, isSingleGrid, i18nStrings, dateOnly, timeInputFormat, rangeSelectorMode, ariaLabelledby, ariaDescribedby, customAbsoluteRangeControl, }: DateRangePickerDropdownProps): JSX.Element;
|
|
16
16
|
//# sourceMappingURL=dropdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/date-range-picker/dropdown.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAiBpD,eAAO,MAAM,WAAW,EAAE,oBAAoB,CAAC,gBAAkC,CAAC;AAElF,MAAM,WAAW,4BACf,SAAQ,IAAI,CACV,QAAQ,CAAC,oBAAoB,CAAC,EAC5B,QAAQ,GACR,eAAe,GACf,cAAc,GACd,OAAO,GACP,iBAAiB,GACjB,iBAAiB,GACjB,UAAU,GACV,iBAAiB,GACjB,mBAAmB,CACtB;IACD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,oBAAoB,CAAC,KAAK,KAAK,oBAAoB,CAAC,gBAAgB,CAAC;IAC7F,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,oBAAoB,CAAC,WAAW,CAAC;IAE/C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,0BAA0B,EAAE,oBAAoB,CAAC,oBAAoB,GAAG,SAAS,CAAC;CACnF;AAED,wBAAgB,uBAAuB,CAAC,EACtC,MAAW,EACX,WAAW,EACX,aAAa,EACb,YAAY,EACZ,KAAK,EACL,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,UAAU,EACnB,eAAe,EACf,eAAe,EACf,eAAe,EACf,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,0BAA0B,GAC3B,EAAE,4BAA4B,
|
|
1
|
+
{"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/date-range-picker/dropdown.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAiBpD,eAAO,MAAM,WAAW,EAAE,oBAAoB,CAAC,gBAAkC,CAAC;AAElF,MAAM,WAAW,4BACf,SAAQ,IAAI,CACV,QAAQ,CAAC,oBAAoB,CAAC,EAC5B,QAAQ,GACR,eAAe,GACf,oBAAoB,GACpB,cAAc,GACd,OAAO,GACP,iBAAiB,GACjB,iBAAiB,GACjB,UAAU,GACV,iBAAiB,GACjB,mBAAmB,CACtB;IACD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,oBAAoB,CAAC,KAAK,KAAK,oBAAoB,CAAC,gBAAgB,CAAC;IAC7F,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,oBAAoB,CAAC,WAAW,CAAC;IAE/C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,0BAA0B,EAAE,oBAAoB,CAAC,oBAAoB,GAAG,SAAS,CAAC;CACnF;AAED,wBAAgB,uBAAuB,CAAC,EACtC,MAAW,EACX,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,KAAK,EACL,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,UAAU,EACnB,eAAe,EACf,eAAe,EACf,eAAe,EACf,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,0BAA0B,GAC3B,EAAE,4BAA4B,eA8L9B"}
|
|
@@ -15,7 +15,7 @@ import LiveRegion from '../internal/components/live-region';
|
|
|
15
15
|
import { getDefaultMode, joinAbsoluteValue, splitAbsoluteValue } from './utils';
|
|
16
16
|
import { useInternalI18n } from '../i18n/context';
|
|
17
17
|
export const VALID_RANGE = { valid: true };
|
|
18
|
-
export function DateRangePickerDropdown({ locale = '', startOfWeek, isDateEnabled, isValidRange, value, onClear: clearValue, onApply: applyValue, onDropdownClose, relativeOptions, showClearButton, isSingleGrid, i18nStrings, dateOnly, timeInputFormat, rangeSelectorMode, ariaLabelledby, ariaDescribedby, customAbsoluteRangeControl, }) {
|
|
18
|
+
export function DateRangePickerDropdown({ locale = '', startOfWeek, isDateEnabled, dateDisabledReason, isValidRange, value, onClear: clearValue, onApply: applyValue, onDropdownClose, relativeOptions, showClearButton, isSingleGrid, i18nStrings, dateOnly, timeInputFormat, rangeSelectorMode, ariaLabelledby, ariaDescribedby, customAbsoluteRangeControl, }) {
|
|
19
19
|
const i18n = useInternalI18n('date-range-picker');
|
|
20
20
|
const [rangeSelectionMode, setRangeSelectionMode] = useState(getDefaultMode(value, relativeOptions, rangeSelectorMode));
|
|
21
21
|
const [selectedAbsoluteRange, setSelectedAbsoluteRange] = useState(() => splitAbsoluteValue((value === null || value === void 0 ? void 0 : value.type) === 'absolute' ? value : null));
|
|
@@ -73,7 +73,7 @@ export function DateRangePickerDropdown({ locale = '', startOfWeek, isDateEnable
|
|
|
73
73
|
setApplyClicked(false);
|
|
74
74
|
setValidationResult(VALID_RANGE);
|
|
75
75
|
}, i18nStrings: i18nStrings })),
|
|
76
|
-
rangeSelectionMode === 'absolute' && (React.createElement(Calendar, { value: selectedAbsoluteRange, setValue: setSelectedAbsoluteRange, locale: locale, startOfWeek: startOfWeek, isDateEnabled: isDateEnabled, i18nStrings: i18nStrings, dateOnly: dateOnly, timeInputFormat: timeInputFormat, customAbsoluteRangeControl: customAbsoluteRangeControl })),
|
|
76
|
+
rangeSelectionMode === 'absolute' && (React.createElement(Calendar, { value: selectedAbsoluteRange, setValue: setSelectedAbsoluteRange, locale: locale, startOfWeek: startOfWeek, isDateEnabled: isDateEnabled, dateDisabledReason: dateDisabledReason, i18nStrings: i18nStrings, dateOnly: dateOnly, timeInputFormat: timeInputFormat, customAbsoluteRangeControl: customAbsoluteRangeControl })),
|
|
77
77
|
rangeSelectionMode === 'relative' && (React.createElement(RelativeRangePicker, { isSingleGrid: isSingleGrid, options: relativeOptions, dateOnly: dateOnly, initialSelection: selectedRelativeRange, onChange: range => setSelectedRelativeRange(range), i18nStrings: i18nStrings }))),
|
|
78
78
|
React.createElement(InternalBox, { className: styles['validation-section'], margin: !validationResult.valid ? { top: 's' } : undefined }, !validationResult.valid && (React.createElement(React.Fragment, null,
|
|
79
79
|
React.createElement(InternalAlert, { type: "error", statusIconAriaLabel: i18n('i18nStrings.errorIconAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.errorIconAriaLabel) },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.js","sourceRoot":"","sources":["../../../src/date-range-picker/dropdown.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,SAAS,MAAM,mCAAm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B,CAAC,CACrD,CACI,CACnB,CACF,CACe,CACnB,CACF,CACI,CACX,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport { DateRangePickerProps } from './interfaces';\nimport Calendar from './calendar';\nimport { ButtonProps } from '../button/interfaces';\nimport { InternalButton } from '../button/internal';\nimport FocusLock from '../internal/components/focus-lock';\nimport InternalBox from '../box/internal';\nimport InternalSpaceBetween from '../space-between/internal';\n\nimport styles from './styles.css.js';\nimport RelativeRangePicker from './relative-range';\nimport ModeSwitcher from './mode-switcher';\nimport clsx from 'clsx';\nimport InternalAlert from '../alert/internal';\nimport LiveRegion from '../internal/components/live-region';\nimport { getDefaultMode, joinAbsoluteValue, splitAbsoluteValue } from './utils';\nimport { useInternalI18n } from '../i18n/context';\n\nexport const VALID_RANGE: DateRangePickerProps.ValidRangeResult = { valid: true };\n\nexport interface DateRangePickerDropdownProps\n extends Pick<\n Required<DateRangePickerProps>,\n | 'locale'\n | 'isDateEnabled'\n | 'isValidRange'\n | 'value'\n | 'relativeOptions'\n | 'showClearButton'\n | 'dateOnly'\n | 'timeInputFormat'\n | 'rangeSelectorMode'\n > {\n onClear: () => void;\n onApply: (value: null | DateRangePickerProps.Value) => DateRangePickerProps.ValidationResult;\n startOfWeek: number | undefined;\n onDropdownClose: () => void;\n isSingleGrid: boolean;\n i18nStrings?: DateRangePickerProps.I18nStrings;\n\n ariaLabelledby?: string;\n ariaDescribedby?: string;\n customAbsoluteRangeControl: DateRangePickerProps.AbsoluteRangeControl | undefined;\n}\n\nexport function DateRangePickerDropdown({\n locale = '',\n startOfWeek,\n isDateEnabled,\n isValidRange,\n value,\n onClear: clearValue,\n onApply: applyValue,\n onDropdownClose,\n relativeOptions,\n showClearButton,\n isSingleGrid,\n i18nStrings,\n dateOnly,\n timeInputFormat,\n rangeSelectorMode,\n ariaLabelledby,\n ariaDescribedby,\n customAbsoluteRangeControl,\n}: DateRangePickerDropdownProps) {\n const i18n = useInternalI18n('date-range-picker');\n\n const [rangeSelectionMode, setRangeSelectionMode] = useState<'absolute' | 'relative'>(\n getDefaultMode(value, relativeOptions, rangeSelectorMode)\n );\n\n const [selectedAbsoluteRange, setSelectedAbsoluteRange] = useState<DateRangePickerProps.PendingAbsoluteValue>(() =>\n splitAbsoluteValue(value?.type === 'absolute' ? value : null)\n );\n\n const [selectedRelativeRange, setSelectedRelativeRange] = useState<DateRangePickerProps.RelativeValue | null>(\n value?.type === 'relative' ? value : null\n );\n\n const scrollableContainerRef = useRef<HTMLDivElement | null>(null);\n const applyButtonRef = useRef<ButtonProps.Ref>(null);\n\n const [applyClicked, setApplyClicked] = useState<boolean>(false);\n\n const [validationResult, setValidationResult] = useState<\n DateRangePickerProps.ValidRangeResult | DateRangePickerProps.InvalidRangeResult\n >(VALID_RANGE);\n\n const closeDropdown = () => {\n setApplyClicked(false);\n onDropdownClose();\n };\n\n const onClear = () => {\n closeDropdown();\n clearValue();\n };\n\n const onApply = () => {\n const newValue =\n rangeSelectionMode === 'relative' ? selectedRelativeRange : joinAbsoluteValue(selectedAbsoluteRange);\n const newValidationResult = applyValue(newValue);\n if (newValidationResult.valid === false) {\n setApplyClicked(true);\n setValidationResult(newValidationResult);\n } else {\n setApplyClicked(false);\n closeDropdown();\n }\n };\n\n useEffect(() => {\n if (applyClicked) {\n const visibleRange =\n rangeSelectionMode === 'relative' ? selectedRelativeRange : joinAbsoluteValue(selectedAbsoluteRange);\n\n const newValidationResult = isValidRange(visibleRange);\n setValidationResult(newValidationResult || VALID_RANGE);\n }\n }, [\n applyClicked,\n isValidRange,\n rangeSelectionMode,\n selectedRelativeRange,\n selectedAbsoluteRange,\n setValidationResult,\n ]);\n\n useEffect(() => scrollableContainerRef.current?.focus(), [scrollableContainerRef]);\n\n return (\n <>\n <FocusLock className={styles['focus-lock']} autoFocus={true}>\n <div\n ref={scrollableContainerRef}\n className={styles.dropdown}\n tabIndex={0}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={i18nStrings?.ariaLabel}\n aria-labelledby={ariaLabelledby ?? i18nStrings?.ariaLabelledby}\n aria-describedby={ariaDescribedby ?? i18nStrings?.ariaDescribedby}\n >\n <div\n className={clsx(styles['dropdown-content'], {\n [styles['one-grid']]: isSingleGrid,\n })}\n >\n <InternalSpaceBetween size=\"l\">\n <InternalBox padding={{ top: 'm', horizontal: 'l' }}>\n <InternalSpaceBetween direction=\"vertical\" size=\"s\">\n {rangeSelectorMode === 'default' && (\n <ModeSwitcher\n mode={rangeSelectionMode}\n onChange={(mode: 'absolute' | 'relative') => {\n setRangeSelectionMode(mode);\n setApplyClicked(false);\n setValidationResult(VALID_RANGE);\n }}\n i18nStrings={i18nStrings}\n />\n )}\n\n {rangeSelectionMode === 'absolute' && (\n <Calendar\n value={selectedAbsoluteRange}\n setValue={setSelectedAbsoluteRange}\n locale={locale}\n startOfWeek={startOfWeek}\n isDateEnabled={isDateEnabled}\n i18nStrings={i18nStrings}\n dateOnly={dateOnly}\n timeInputFormat={timeInputFormat}\n customAbsoluteRangeControl={customAbsoluteRangeControl}\n />\n )}\n\n {rangeSelectionMode === 'relative' && (\n <RelativeRangePicker\n isSingleGrid={isSingleGrid}\n options={relativeOptions}\n dateOnly={dateOnly}\n initialSelection={selectedRelativeRange}\n onChange={range => setSelectedRelativeRange(range)}\n i18nStrings={i18nStrings}\n />\n )}\n </InternalSpaceBetween>\n\n <InternalBox\n className={styles['validation-section']}\n margin={!validationResult.valid ? { top: 's' } : undefined}\n >\n {!validationResult.valid && (\n <>\n <InternalAlert\n type=\"error\"\n statusIconAriaLabel={i18n('i18nStrings.errorIconAriaLabel', i18nStrings?.errorIconAriaLabel)}\n >\n <span className={styles['validation-error']}>{validationResult.errorMessage}</span>\n </InternalAlert>\n <LiveRegion>{validationResult.errorMessage}</LiveRegion>\n </>\n )}\n </InternalBox>\n </InternalBox>\n\n <div\n className={clsx(styles.footer, {\n [styles['one-grid']]: isSingleGrid,\n [styles['has-clear-button']]: showClearButton,\n })}\n >\n {showClearButton && (\n <div className={styles['footer-button-wrapper']}>\n <InternalButton\n onClick={onClear}\n className={styles['clear-button']}\n variant=\"link\"\n formAction=\"none\"\n >\n {i18n('i18nStrings.clearButtonLabel', i18nStrings?.clearButtonLabel)}\n </InternalButton>\n </div>\n )}\n <div className={styles['footer-button-wrapper']}>\n <InternalSpaceBetween size=\"xs\" direction=\"horizontal\">\n <InternalButton\n onClick={closeDropdown}\n className={styles['cancel-button']}\n variant=\"link\"\n formAction=\"none\"\n >\n {i18n('i18nStrings.cancelButtonLabel', i18nStrings?.cancelButtonLabel)}\n </InternalButton>\n\n <InternalButton\n onClick={onApply}\n className={styles['apply-button']}\n ref={applyButtonRef}\n formAction=\"none\"\n >\n {i18n('i18nStrings.applyButtonLabel', i18nStrings?.applyButtonLabel)}\n </InternalButton>\n </InternalSpaceBetween>\n </div>\n </div>\n </InternalSpaceBetween>\n </div>\n </div>\n </FocusLock>\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dropdown.js","sourceRoot":"","sources":["../../../src/date-range-picker/dropdown.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,SAAS,MAAM,mCAAmC,CAAC;AAC1D,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAE7D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,mBAAmB,MAAM,kBAAkB,CAAC;AACnD,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,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CAAC,MAAM,CAAC,MAAM,EAAE;gCAC7B,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,YAAY;gCAClC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,EAAE,eAAe;6BAC9C,CAAC;4BAED,eAAe,IAAI,CAClB,6BAAK,SAAS,EAAE,MAAM,CAAC,uBAAuB,CAAC;gCAC7C,oBAAC,cAAc,IACb,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,CAAC,cAAc,CAAC,EACjC,OAAO,EAAC,MAAM,EACd,UAAU,EAAC,MAAM,IAEhB,IAAI,CAAC,8BAA8B,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,gBAAgB,CAAC,CACrD,CACb,CACP;4BACD,6BAAK,SAAS,EAAE,MAAM,CAAC,uBAAuB,CAAC;gCAC7C,oBAAC,oBAAoB,IAAC,IAAI,EAAC,IAAI,EAAC,SAAS,EAAC,YAAY;oCACpD,oBAAC,cAAc,IACb,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC,EAClC,OAAO,EAAC,MAAM,EACd,UAAU,EAAC,MAAM,IAEhB,IAAI,CAAC,+BAA+B,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,iBAAiB,CAAC,CACvD;oCAEjB,oBAAC,cAAc,IACb,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,MAAM,CAAC,cAAc,CAAC,EACjC,GAAG,EAAE,cAAc,EACnB,UAAU,EAAC,MAAM,IAEhB,IAAI,CAAC,8BAA8B,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,gBAAgB,CAAC,CACrD,CACI,CACnB,CACF,CACe,CACnB,CACF,CACI,CACX,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport { DateRangePickerProps } from './interfaces';\nimport Calendar from './calendar';\nimport { ButtonProps } from '../button/interfaces';\nimport { InternalButton } from '../button/internal';\nimport FocusLock from '../internal/components/focus-lock';\nimport InternalBox from '../box/internal';\nimport InternalSpaceBetween from '../space-between/internal';\n\nimport styles from './styles.css.js';\nimport RelativeRangePicker from './relative-range';\nimport ModeSwitcher from './mode-switcher';\nimport clsx from 'clsx';\nimport InternalAlert from '../alert/internal';\nimport LiveRegion from '../internal/components/live-region';\nimport { getDefaultMode, joinAbsoluteValue, splitAbsoluteValue } from './utils';\nimport { useInternalI18n } from '../i18n/context';\n\nexport const VALID_RANGE: DateRangePickerProps.ValidRangeResult = { valid: true };\n\nexport interface DateRangePickerDropdownProps\n extends Pick<\n Required<DateRangePickerProps>,\n | 'locale'\n | 'isDateEnabled'\n | 'dateDisabledReason'\n | 'isValidRange'\n | 'value'\n | 'relativeOptions'\n | 'showClearButton'\n | 'dateOnly'\n | 'timeInputFormat'\n | 'rangeSelectorMode'\n > {\n onClear: () => void;\n onApply: (value: null | DateRangePickerProps.Value) => DateRangePickerProps.ValidationResult;\n startOfWeek: number | undefined;\n onDropdownClose: () => void;\n isSingleGrid: boolean;\n i18nStrings?: DateRangePickerProps.I18nStrings;\n\n ariaLabelledby?: string;\n ariaDescribedby?: string;\n customAbsoluteRangeControl: DateRangePickerProps.AbsoluteRangeControl | undefined;\n}\n\nexport function DateRangePickerDropdown({\n locale = '',\n startOfWeek,\n isDateEnabled,\n dateDisabledReason,\n isValidRange,\n value,\n onClear: clearValue,\n onApply: applyValue,\n onDropdownClose,\n relativeOptions,\n showClearButton,\n isSingleGrid,\n i18nStrings,\n dateOnly,\n timeInputFormat,\n rangeSelectorMode,\n ariaLabelledby,\n ariaDescribedby,\n customAbsoluteRangeControl,\n}: DateRangePickerDropdownProps) {\n const i18n = useInternalI18n('date-range-picker');\n\n const [rangeSelectionMode, setRangeSelectionMode] = useState<'absolute' | 'relative'>(\n getDefaultMode(value, relativeOptions, rangeSelectorMode)\n );\n\n const [selectedAbsoluteRange, setSelectedAbsoluteRange] = useState<DateRangePickerProps.PendingAbsoluteValue>(() =>\n splitAbsoluteValue(value?.type === 'absolute' ? value : null)\n );\n\n const [selectedRelativeRange, setSelectedRelativeRange] = useState<DateRangePickerProps.RelativeValue | null>(\n value?.type === 'relative' ? value : null\n );\n\n const scrollableContainerRef = useRef<HTMLDivElement | null>(null);\n const applyButtonRef = useRef<ButtonProps.Ref>(null);\n\n const [applyClicked, setApplyClicked] = useState<boolean>(false);\n\n const [validationResult, setValidationResult] = useState<\n DateRangePickerProps.ValidRangeResult | DateRangePickerProps.InvalidRangeResult\n >(VALID_RANGE);\n\n const closeDropdown = () => {\n setApplyClicked(false);\n onDropdownClose();\n };\n\n const onClear = () => {\n closeDropdown();\n clearValue();\n };\n\n const onApply = () => {\n const newValue =\n rangeSelectionMode === 'relative' ? selectedRelativeRange : joinAbsoluteValue(selectedAbsoluteRange);\n const newValidationResult = applyValue(newValue);\n if (newValidationResult.valid === false) {\n setApplyClicked(true);\n setValidationResult(newValidationResult);\n } else {\n setApplyClicked(false);\n closeDropdown();\n }\n };\n\n useEffect(() => {\n if (applyClicked) {\n const visibleRange =\n rangeSelectionMode === 'relative' ? selectedRelativeRange : joinAbsoluteValue(selectedAbsoluteRange);\n\n const newValidationResult = isValidRange(visibleRange);\n setValidationResult(newValidationResult || VALID_RANGE);\n }\n }, [\n applyClicked,\n isValidRange,\n rangeSelectionMode,\n selectedRelativeRange,\n selectedAbsoluteRange,\n setValidationResult,\n ]);\n\n useEffect(() => scrollableContainerRef.current?.focus(), [scrollableContainerRef]);\n\n return (\n <>\n <FocusLock className={styles['focus-lock']} autoFocus={true}>\n <div\n ref={scrollableContainerRef}\n className={styles.dropdown}\n tabIndex={0}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={i18nStrings?.ariaLabel}\n aria-labelledby={ariaLabelledby ?? i18nStrings?.ariaLabelledby}\n aria-describedby={ariaDescribedby ?? i18nStrings?.ariaDescribedby}\n >\n <div\n className={clsx(styles['dropdown-content'], {\n [styles['one-grid']]: isSingleGrid,\n })}\n >\n <InternalSpaceBetween size=\"l\">\n <InternalBox padding={{ top: 'm', horizontal: 'l' }}>\n <InternalSpaceBetween direction=\"vertical\" size=\"s\">\n {rangeSelectorMode === 'default' && (\n <ModeSwitcher\n mode={rangeSelectionMode}\n onChange={(mode: 'absolute' | 'relative') => {\n setRangeSelectionMode(mode);\n setApplyClicked(false);\n setValidationResult(VALID_RANGE);\n }}\n i18nStrings={i18nStrings}\n />\n )}\n\n {rangeSelectionMode === 'absolute' && (\n <Calendar\n value={selectedAbsoluteRange}\n setValue={setSelectedAbsoluteRange}\n locale={locale}\n startOfWeek={startOfWeek}\n isDateEnabled={isDateEnabled}\n dateDisabledReason={dateDisabledReason}\n i18nStrings={i18nStrings}\n dateOnly={dateOnly}\n timeInputFormat={timeInputFormat}\n customAbsoluteRangeControl={customAbsoluteRangeControl}\n />\n )}\n\n {rangeSelectionMode === 'relative' && (\n <RelativeRangePicker\n isSingleGrid={isSingleGrid}\n options={relativeOptions}\n dateOnly={dateOnly}\n initialSelection={selectedRelativeRange}\n onChange={range => setSelectedRelativeRange(range)}\n i18nStrings={i18nStrings}\n />\n )}\n </InternalSpaceBetween>\n\n <InternalBox\n className={styles['validation-section']}\n margin={!validationResult.valid ? { top: 's' } : undefined}\n >\n {!validationResult.valid && (\n <>\n <InternalAlert\n type=\"error\"\n statusIconAriaLabel={i18n('i18nStrings.errorIconAriaLabel', i18nStrings?.errorIconAriaLabel)}\n >\n <span className={styles['validation-error']}>{validationResult.errorMessage}</span>\n </InternalAlert>\n <LiveRegion>{validationResult.errorMessage}</LiveRegion>\n </>\n )}\n </InternalBox>\n </InternalBox>\n\n <div\n className={clsx(styles.footer, {\n [styles['one-grid']]: isSingleGrid,\n [styles['has-clear-button']]: showClearButton,\n })}\n >\n {showClearButton && (\n <div className={styles['footer-button-wrapper']}>\n <InternalButton\n onClick={onClear}\n className={styles['clear-button']}\n variant=\"link\"\n formAction=\"none\"\n >\n {i18n('i18nStrings.clearButtonLabel', i18nStrings?.clearButtonLabel)}\n </InternalButton>\n </div>\n )}\n <div className={styles['footer-button-wrapper']}>\n <InternalSpaceBetween size=\"xs\" direction=\"horizontal\">\n <InternalButton\n onClick={closeDropdown}\n className={styles['cancel-button']}\n variant=\"link\"\n formAction=\"none\"\n >\n {i18n('i18nStrings.cancelButtonLabel', i18nStrings?.cancelButtonLabel)}\n </InternalButton>\n\n <InternalButton\n onClick={onApply}\n className={styles['apply-button']}\n ref={applyButtonRef}\n formAction=\"none\"\n >\n {i18n('i18nStrings.applyButtonLabel', i18nStrings?.applyButtonLabel)}\n </InternalButton>\n </InternalSpaceBetween>\n </div>\n </div>\n </InternalSpaceBetween>\n </div>\n </div>\n </FocusLock>\n </>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-range-picker/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AA8BpD,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAuEhC,QAAA,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-range-picker/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AA8BpD,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAuEhC,QAAA,MAAM,eAAe,uGA8PpB,CAAC;AAGF,eAAe,eAAe,CAAC"}
|
|
@@ -60,7 +60,7 @@ function isDateOnly(value) {
|
|
|
60
60
|
}
|
|
61
61
|
const DateRangePicker = React.forwardRef((_a, ref) => {
|
|
62
62
|
var _b, _c;
|
|
63
|
-
var { locale = '', startOfWeek, isDateEnabled = () => true, value, placeholder, readOnly = false, disabled = false, onChange, onBlur, onFocus, relativeOptions = [], i18nStrings, isValidRange = () => ({ valid: true }), showClearButton = true, dateOnly = false, timeOffset, getTimeOffset, timeInputFormat = 'hh:mm:ss', expandToViewport = false, rangeSelectorMode = 'default', customAbsoluteRangeControl, absoluteFormat = 'iso', hideTimeOffset } = _a, rest = __rest(_a, ["locale", "startOfWeek", "isDateEnabled", "value", "placeholder", "readOnly", "disabled", "onChange", "onBlur", "onFocus", "relativeOptions", "i18nStrings", "isValidRange", "showClearButton", "dateOnly", "timeOffset", "getTimeOffset", "timeInputFormat", "expandToViewport", "rangeSelectorMode", "customAbsoluteRangeControl", "absoluteFormat", "hideTimeOffset"]);
|
|
63
|
+
var { locale = '', startOfWeek, isDateEnabled = () => true, dateDisabledReason = () => '', value, placeholder, readOnly = false, disabled = false, onChange, onBlur, onFocus, relativeOptions = [], i18nStrings, isValidRange = () => ({ valid: true }), showClearButton = true, dateOnly = false, timeOffset, getTimeOffset, timeInputFormat = 'hh:mm:ss', expandToViewport = false, rangeSelectorMode = 'default', customAbsoluteRangeControl, absoluteFormat = 'iso', hideTimeOffset } = _a, rest = __rest(_a, ["locale", "startOfWeek", "isDateEnabled", "dateDisabledReason", "value", "placeholder", "readOnly", "disabled", "onChange", "onBlur", "onFocus", "relativeOptions", "i18nStrings", "isValidRange", "showClearButton", "dateOnly", "timeOffset", "getTimeOffset", "timeInputFormat", "expandToViewport", "rangeSelectorMode", "customAbsoluteRangeControl", "absoluteFormat", "hideTimeOffset"]);
|
|
64
64
|
const { __internalRootRef } = useBaseComponent('DateRangePicker', {
|
|
65
65
|
props: {
|
|
66
66
|
absoluteFormat,
|
|
@@ -171,7 +171,7 @@ const DateRangePicker = React.forwardRef((_a, ref) => {
|
|
|
171
171
|
const mergedRef = useMergeRefs(rootRef, __internalRootRef);
|
|
172
172
|
return (React.createElement("div", Object.assign({}, baseProps, { ref: mergedRef, className: clsx(baseProps.className, styles.root, absoluteFormat === 'long-localized' && !dateOnly && styles.wide), onKeyDown: onWrapperKeyDownHandler }),
|
|
173
173
|
React.createElement(Dropdown, { stretchWidth: true, stretchHeight: true, open: isDropDownOpen, onDropdownClose: () => closeDropdown(), trigger: trigger, stretchToTriggerWidth: false, expandToViewport: expandToViewport, dropdownId: dropdownId },
|
|
174
|
-
React.createElement(ResetContextsForModal, null, isDropDownOpen && (React.createElement(DateRangePickerDropdown, { startOfWeek: startOfWeek, locale: normalizedLocale, isSingleGrid: isSingleGrid, onDropdownClose: () => closeDropdown(true), value: value, showClearButton: showClearButton, isDateEnabled: isDateEnabled, i18nStrings: i18nStrings, onClear: onClear, onApply: onApply, relativeOptions: relativeOptions, isValidRange: isValidRange, dateOnly: dateOnly, timeInputFormat: timeInputFormat, rangeSelectorMode: rangeSelectorMode, ariaLabelledby: ariaLabelledby, ariaDescribedby: ariaDescribedby, customAbsoluteRangeControl: customAbsoluteRangeControl }))))));
|
|
174
|
+
React.createElement(ResetContextsForModal, null, isDropDownOpen && (React.createElement(DateRangePickerDropdown, { startOfWeek: startOfWeek, locale: normalizedLocale, isSingleGrid: isSingleGrid, onDropdownClose: () => closeDropdown(true), value: value, showClearButton: showClearButton, isDateEnabled: isDateEnabled, dateDisabledReason: dateDisabledReason, i18nStrings: i18nStrings, onClear: onClear, onApply: onApply, relativeOptions: relativeOptions, isValidRange: isValidRange, dateOnly: dateOnly, timeInputFormat: timeInputFormat, rangeSelectorMode: rangeSelectorMode, ariaLabelledby: ariaLabelledby, ariaDescribedby: ariaDescribedby, customAbsoluteRangeControl: customAbsoluteRangeControl }))))));
|
|
175
175
|
});
|
|
176
176
|
applyDisplayName(DateRangePicker, 'DateRangePicker');
|
|
177
177
|
export default DateRangePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/date-range-picker/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAO,SAAS,EAAE,MAAM,EAAE,QAAQ,E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AE,eAAe,EAChC,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,EAChC,0BAA0B,EAAE,0BAA0B,GACtD,CACH,CACqB,CACf,CACP,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;AACrD,eAAe,eAAe,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { Ref, useEffect, useRef, useState } from 'react';\nimport styles from './styles.css.js';\nimport { DateRangePickerProps } from './interfaces';\nimport { normalizeLocale } from '../internal/utils/locale';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { KeyCode } from '../internal/keycode';\nimport clsx from 'clsx';\nimport { getBaseProps } from '../internal/base-component';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport InternalBox from '../box/internal';\nimport { DateRangePickerDropdown } from './dropdown';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport Dropdown from '../internal/components/dropdown';\nimport { useFocusTracker } from '../internal/hooks/use-focus-tracker';\nimport { useMobile } from '../internal/hooks/use-mobile';\nimport ButtonTrigger from '../internal/components/button-trigger';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport InternalIcon from '../icon/internal';\nimport { normalizeTimeOffset, shiftTimeOffset } from './time-offset';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { isDevelopment } from '../internal/is-development.js';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { usePrevious } from '../internal/hooks/use-previous';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { joinStrings } from '../internal/utils/strings/join-strings';\nimport { formatDateRange, isIsoDateOnly } from '../internal/utils/date-time';\nimport { useInternalI18n } from '../i18n/context';\nimport { formatValue } from './utils';\nimport ResetContextsForModal from '../internal/context/reset-contexts-for-modal.js';\n\nexport { DateRangePickerProps };\n\nfunction renderDateRange({\n locale,\n range,\n placeholder = '',\n formatRelativeRange,\n absoluteFormat,\n hideTimeOffset,\n timeOffset,\n}: {\n locale?: string;\n range: null | DateRangePickerProps.Value;\n placeholder?: string;\n formatRelativeRange: DateRangePickerProps.I18nStrings['formatRelativeRange'];\n absoluteFormat: DateRangePickerProps.AbsoluteFormat;\n hideTimeOffset?: boolean;\n timeOffset: { startDate?: number; endDate?: number };\n}) {\n if (!range) {\n return (\n <span className={styles['label-text']} aria-disabled={true}>\n {placeholder}\n </span>\n );\n }\n\n const formatted =\n range.type === 'relative' ? (\n formatRelativeRange?.(range) ?? ''\n ) : (\n <BreakSpaces\n text={formatDateRange({\n startDate: range.startDate,\n endDate: range.endDate,\n timeOffset,\n hideTimeOffset,\n format: absoluteFormat,\n locale,\n })}\n />\n );\n\n return (\n <InternalBox fontWeight=\"normal\" display=\"inline\" color=\"inherit\" variant=\"span\">\n {formatted}\n </InternalBox>\n );\n}\n\nfunction BreakSpaces({ text }: { text: string }) {\n const tokens = text.split(/( )/);\n return (\n <>\n {tokens.map((token, index) => (\n <React.Fragment key={index}>\n {token.length > 1 ? <span className={styles['label-token-nowrap']}>{token}</span> : token}\n {token === ' ' && <wbr />}\n </React.Fragment>\n ))}\n </>\n );\n}\n\nfunction isDateOnly(value: null | DateRangePickerProps.Value) {\n if (!value || value.type !== 'absolute') {\n return false;\n }\n return isIsoDateOnly(value.startDate) && isIsoDateOnly(value.endDate);\n}\n\nconst DateRangePicker = React.forwardRef(\n (\n {\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n value,\n placeholder,\n readOnly = false,\n disabled = false,\n onChange,\n onBlur,\n onFocus,\n relativeOptions = [],\n i18nStrings,\n isValidRange = () => ({ valid: true }),\n showClearButton = true,\n dateOnly = false,\n timeOffset,\n getTimeOffset,\n timeInputFormat = 'hh:mm:ss',\n expandToViewport = false,\n rangeSelectorMode = 'default',\n customAbsoluteRangeControl,\n absoluteFormat = 'iso',\n hideTimeOffset,\n ...rest\n }: DateRangePickerProps,\n ref: Ref<DateRangePickerProps.Ref>\n ) => {\n const { __internalRootRef } = useBaseComponent('DateRangePicker', {\n props: {\n absoluteFormat,\n dateOnly,\n expandToViewport,\n rangeSelectorMode,\n readOnly,\n showClearButton,\n timeInputFormat,\n hideTimeOffset,\n },\n });\n checkControlled('DateRangePicker', 'value', value, 'onChange', onChange);\n\n const normalizedTimeOffset = normalizeTimeOffset(value, getTimeOffset, timeOffset);\n value = isDateOnly(value) ? value : shiftTimeOffset(value, normalizedTimeOffset);\n\n const baseProps = getBaseProps(rest);\n const { invalid, warning, controlId, ariaDescribedby, ariaLabelledby } = useFormFieldContext({\n ariaLabelledby: rest.ariaLabelledby ?? i18nStrings?.ariaLabelledby,\n ariaDescribedby: rest.ariaDescribedby ?? i18nStrings?.ariaDescribedby,\n ...rest,\n });\n const isSingleGrid = useMobile();\n\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n useForwardFocus(ref, triggerRef);\n\n const rootRef = useRef<HTMLDivElement>(null);\n const dropdownId = useUniqueId('date-range-picker-dropdown');\n const triggerContentId = useUniqueId('date-range-picker-trigger');\n\n useFocusTracker({ rootRef, onBlur, onFocus });\n\n const [isDropDownOpen, setIsDropDownOpen] = useState<boolean>(false);\n\n const normalizedLocale = normalizeLocale('DateRangePicker', locale);\n\n const closeDropdown = (focusTrigger = false) => {\n setIsDropDownOpen(false);\n if (focusTrigger) {\n triggerRef.current?.focus();\n }\n };\n\n const onWrapperKeyDownHandler = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.keyCode === KeyCode.escape) {\n if (isDropDownOpen) {\n event.stopPropagation();\n }\n closeDropdown(true);\n }\n };\n\n const onClear = () => {\n fireNonCancelableEvent(onChange, { value: null });\n };\n\n const onApply = (newValue: null | DateRangePickerProps.Value): DateRangePickerProps.ValidationResult => {\n const validationResult = isValidRange(newValue);\n if (validationResult?.valid === false) {\n return validationResult;\n }\n\n if (isDevelopment) {\n if (newValue?.type === 'absolute') {\n const [startDateWithoutTime] = newValue.startDate.split('T');\n const [endDateWithoutTime] = newValue.endDate.split('T');\n if (!startDateWithoutTime || !endDateWithoutTime) {\n warnOnce(\n 'DateRangePicker',\n 'You have provided an `isValidRange` prop that did not catch a missing start or end date.'\n );\n }\n }\n }\n fireNonCancelableEvent(onChange, {\n value: formatValue(newValue, {\n dateOnly,\n timeOffset: normalizeTimeOffset(newValue, getTimeOffset, timeOffset),\n }),\n });\n return validationResult || { valid: true };\n };\n\n const prevDateOnly = usePrevious(dateOnly);\n useEffect(() => {\n if (prevDateOnly !== undefined && prevDateOnly !== dateOnly) {\n warnOnce(\n 'DateRangePicker',\n `The provided \\`dateOnly\\` flag has been changed from \"${prevDateOnly}\" to \"${dateOnly}\" which can lead to unexpected value format. Consider using separate components.`\n );\n }\n }, [prevDateOnly, dateOnly]);\n\n if (value && value.type !== 'absolute' && value.type !== 'relative') {\n warnOnce('DateRangePicker', 'You provided an invalid value. Reverting back to default.');\n value = null;\n }\n\n if (\n (value?.type === 'absolute' && rangeSelectorMode === 'relative-only') ||\n (value?.type === 'relative' && rangeSelectorMode === 'absolute-only')\n ) {\n warnOnce(\n 'DateRangePicker',\n 'The provided value does not correspond to the current range selector mode. Reverting back to default.'\n );\n value = null;\n }\n\n const i18n = useInternalI18n('date-range-picker');\n const formatRelativeRange = i18n(\n 'i18nStrings.formatRelativeRange',\n i18nStrings?.formatRelativeRange,\n format =>\n ({ amount, unit }) =>\n format({ amount, unit })\n );\n\n if (isDevelopment) {\n if (!formatRelativeRange && rangeSelectorMode !== 'absolute-only') {\n warnOnce(\n 'DateRangePicker',\n 'A function for i18nStrings.formatRelativeRange was not provided. Relative ranges will not be correctly rendered.'\n );\n }\n }\n\n const formattedDate: string | JSX.Element = renderDateRange({\n locale: normalizedLocale,\n range: value,\n placeholder,\n formatRelativeRange,\n absoluteFormat,\n hideTimeOffset,\n timeOffset: normalizedTimeOffset,\n });\n\n const trigger = (\n <div className={styles['trigger-wrapper']}>\n <ButtonTrigger\n ref={triggerRef}\n id={controlId}\n invalid={invalid}\n warning={warning}\n ariaLabelledby={joinStrings(ariaLabelledby, triggerContentId)}\n ariaLabel={i18nStrings?.ariaLabel}\n ariaDescribedby={ariaDescribedby}\n className={clsx(styles.label, {\n [styles['label-enabled']]: !readOnly && !disabled,\n })}\n hideCaret={true}\n onClick={() => {\n setIsDropDownOpen(true);\n }}\n disabled={disabled}\n readOnly={readOnly}\n ariaHasPopup=\"dialog\"\n >\n <span className={styles['trigger-flexbox']}>\n <span className={styles['icon-wrapper']}>\n <InternalIcon name=\"calendar\" variant={disabled || readOnly ? 'disabled' : 'normal'} />\n </span>\n <span id={triggerContentId}>{formattedDate}</span>\n </span>\n </ButtonTrigger>\n </div>\n );\n\n const mergedRef = useMergeRefs(rootRef, __internalRootRef);\n\n return (\n <div\n {...baseProps}\n ref={mergedRef}\n className={clsx(\n baseProps.className,\n styles.root,\n absoluteFormat === 'long-localized' && !dateOnly && styles.wide\n )}\n onKeyDown={onWrapperKeyDownHandler}\n >\n <Dropdown\n stretchWidth={true}\n stretchHeight={true}\n open={isDropDownOpen}\n onDropdownClose={() => closeDropdown()}\n trigger={trigger}\n stretchToTriggerWidth={false}\n expandToViewport={expandToViewport}\n dropdownId={dropdownId}\n >\n {/* Reset form field context to prevent a wrapper form field from labelling all inputs inside the dropdown. */}\n <ResetContextsForModal>\n {isDropDownOpen && (\n <DateRangePickerDropdown\n startOfWeek={startOfWeek}\n locale={normalizedLocale}\n isSingleGrid={isSingleGrid}\n onDropdownClose={() => closeDropdown(true)}\n value={value}\n showClearButton={showClearButton}\n isDateEnabled={isDateEnabled}\n i18nStrings={i18nStrings}\n onClear={onClear}\n onApply={onApply}\n relativeOptions={relativeOptions}\n isValidRange={isValidRange}\n dateOnly={dateOnly}\n timeInputFormat={timeInputFormat}\n rangeSelectorMode={rangeSelectorMode}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n customAbsoluteRangeControl={customAbsoluteRangeControl}\n />\n )}\n </ResetContextsForModal>\n </Dropdown>\n </div>\n );\n }\n);\n\napplyDisplayName(DateRangePicker, 'DateRangePicker');\nexport default DateRangePicker;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/date-range-picker/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAO,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,eAAe,MAAM,oCAAoC,CAAC;AACjE,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,aAAa,MAAM,uCAAuC,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kC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oBAAC,uBAAuB,IACtB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,EAC1C,KAAK,EAAE,KAAK,EACZ,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,aAAa,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,EAChC,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,EAChC,0BAA0B,EAAE,0BAA0B,GACtD,CACH,CACqB,CACf,CACP,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;AACrD,eAAe,eAAe,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { Ref, useEffect, useRef, useState } from 'react';\nimport styles from './styles.css.js';\nimport { DateRangePickerProps } from './interfaces';\nimport { normalizeLocale } from '../internal/utils/locale';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { KeyCode } from '../internal/keycode';\nimport clsx from 'clsx';\nimport { getBaseProps } from '../internal/base-component';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport InternalBox from '../box/internal';\nimport { DateRangePickerDropdown } from './dropdown';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport Dropdown from '../internal/components/dropdown';\nimport { useFocusTracker } from '../internal/hooks/use-focus-tracker';\nimport { useMobile } from '../internal/hooks/use-mobile';\nimport ButtonTrigger from '../internal/components/button-trigger';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport InternalIcon from '../icon/internal';\nimport { normalizeTimeOffset, shiftTimeOffset } from './time-offset';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { isDevelopment } from '../internal/is-development.js';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { usePrevious } from '../internal/hooks/use-previous';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { joinStrings } from '../internal/utils/strings/join-strings';\nimport { formatDateRange, isIsoDateOnly } from '../internal/utils/date-time';\nimport { useInternalI18n } from '../i18n/context';\nimport { formatValue } from './utils';\nimport ResetContextsForModal from '../internal/context/reset-contexts-for-modal.js';\n\nexport { DateRangePickerProps };\n\nfunction renderDateRange({\n locale,\n range,\n placeholder = '',\n formatRelativeRange,\n absoluteFormat,\n hideTimeOffset,\n timeOffset,\n}: {\n locale?: string;\n range: null | DateRangePickerProps.Value;\n placeholder?: string;\n formatRelativeRange: DateRangePickerProps.I18nStrings['formatRelativeRange'];\n absoluteFormat: DateRangePickerProps.AbsoluteFormat;\n hideTimeOffset?: boolean;\n timeOffset: { startDate?: number; endDate?: number };\n}) {\n if (!range) {\n return (\n <span className={styles['label-text']} aria-disabled={true}>\n {placeholder}\n </span>\n );\n }\n\n const formatted =\n range.type === 'relative' ? (\n formatRelativeRange?.(range) ?? ''\n ) : (\n <BreakSpaces\n text={formatDateRange({\n startDate: range.startDate,\n endDate: range.endDate,\n timeOffset,\n hideTimeOffset,\n format: absoluteFormat,\n locale,\n })}\n />\n );\n\n return (\n <InternalBox fontWeight=\"normal\" display=\"inline\" color=\"inherit\" variant=\"span\">\n {formatted}\n </InternalBox>\n );\n}\n\nfunction BreakSpaces({ text }: { text: string }) {\n const tokens = text.split(/( )/);\n return (\n <>\n {tokens.map((token, index) => (\n <React.Fragment key={index}>\n {token.length > 1 ? <span className={styles['label-token-nowrap']}>{token}</span> : token}\n {token === ' ' && <wbr />}\n </React.Fragment>\n ))}\n </>\n );\n}\n\nfunction isDateOnly(value: null | DateRangePickerProps.Value) {\n if (!value || value.type !== 'absolute') {\n return false;\n }\n return isIsoDateOnly(value.startDate) && isIsoDateOnly(value.endDate);\n}\n\nconst DateRangePicker = React.forwardRef(\n (\n {\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n dateDisabledReason = () => '',\n value,\n placeholder,\n readOnly = false,\n disabled = false,\n onChange,\n onBlur,\n onFocus,\n relativeOptions = [],\n i18nStrings,\n isValidRange = () => ({ valid: true }),\n showClearButton = true,\n dateOnly = false,\n timeOffset,\n getTimeOffset,\n timeInputFormat = 'hh:mm:ss',\n expandToViewport = false,\n rangeSelectorMode = 'default',\n customAbsoluteRangeControl,\n absoluteFormat = 'iso',\n hideTimeOffset,\n ...rest\n }: DateRangePickerProps,\n ref: Ref<DateRangePickerProps.Ref>\n ) => {\n const { __internalRootRef } = useBaseComponent('DateRangePicker', {\n props: {\n absoluteFormat,\n dateOnly,\n expandToViewport,\n rangeSelectorMode,\n readOnly,\n showClearButton,\n timeInputFormat,\n hideTimeOffset,\n },\n });\n checkControlled('DateRangePicker', 'value', value, 'onChange', onChange);\n\n const normalizedTimeOffset = normalizeTimeOffset(value, getTimeOffset, timeOffset);\n value = isDateOnly(value) ? value : shiftTimeOffset(value, normalizedTimeOffset);\n\n const baseProps = getBaseProps(rest);\n const { invalid, warning, controlId, ariaDescribedby, ariaLabelledby } = useFormFieldContext({\n ariaLabelledby: rest.ariaLabelledby ?? i18nStrings?.ariaLabelledby,\n ariaDescribedby: rest.ariaDescribedby ?? i18nStrings?.ariaDescribedby,\n ...rest,\n });\n const isSingleGrid = useMobile();\n\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n useForwardFocus(ref, triggerRef);\n\n const rootRef = useRef<HTMLDivElement>(null);\n const dropdownId = useUniqueId('date-range-picker-dropdown');\n const triggerContentId = useUniqueId('date-range-picker-trigger');\n\n useFocusTracker({ rootRef, onBlur, onFocus });\n\n const [isDropDownOpen, setIsDropDownOpen] = useState<boolean>(false);\n\n const normalizedLocale = normalizeLocale('DateRangePicker', locale);\n\n const closeDropdown = (focusTrigger = false) => {\n setIsDropDownOpen(false);\n if (focusTrigger) {\n triggerRef.current?.focus();\n }\n };\n\n const onWrapperKeyDownHandler = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.keyCode === KeyCode.escape) {\n if (isDropDownOpen) {\n event.stopPropagation();\n }\n closeDropdown(true);\n }\n };\n\n const onClear = () => {\n fireNonCancelableEvent(onChange, { value: null });\n };\n\n const onApply = (newValue: null | DateRangePickerProps.Value): DateRangePickerProps.ValidationResult => {\n const validationResult = isValidRange(newValue);\n if (validationResult?.valid === false) {\n return validationResult;\n }\n\n if (isDevelopment) {\n if (newValue?.type === 'absolute') {\n const [startDateWithoutTime] = newValue.startDate.split('T');\n const [endDateWithoutTime] = newValue.endDate.split('T');\n if (!startDateWithoutTime || !endDateWithoutTime) {\n warnOnce(\n 'DateRangePicker',\n 'You have provided an `isValidRange` prop that did not catch a missing start or end date.'\n );\n }\n }\n }\n fireNonCancelableEvent(onChange, {\n value: formatValue(newValue, {\n dateOnly,\n timeOffset: normalizeTimeOffset(newValue, getTimeOffset, timeOffset),\n }),\n });\n return validationResult || { valid: true };\n };\n\n const prevDateOnly = usePrevious(dateOnly);\n useEffect(() => {\n if (prevDateOnly !== undefined && prevDateOnly !== dateOnly) {\n warnOnce(\n 'DateRangePicker',\n `The provided \\`dateOnly\\` flag has been changed from \"${prevDateOnly}\" to \"${dateOnly}\" which can lead to unexpected value format. Consider using separate components.`\n );\n }\n }, [prevDateOnly, dateOnly]);\n\n if (value && value.type !== 'absolute' && value.type !== 'relative') {\n warnOnce('DateRangePicker', 'You provided an invalid value. Reverting back to default.');\n value = null;\n }\n\n if (\n (value?.type === 'absolute' && rangeSelectorMode === 'relative-only') ||\n (value?.type === 'relative' && rangeSelectorMode === 'absolute-only')\n ) {\n warnOnce(\n 'DateRangePicker',\n 'The provided value does not correspond to the current range selector mode. Reverting back to default.'\n );\n value = null;\n }\n\n const i18n = useInternalI18n('date-range-picker');\n const formatRelativeRange = i18n(\n 'i18nStrings.formatRelativeRange',\n i18nStrings?.formatRelativeRange,\n format =>\n ({ amount, unit }) =>\n format({ amount, unit })\n );\n\n if (isDevelopment) {\n if (!formatRelativeRange && rangeSelectorMode !== 'absolute-only') {\n warnOnce(\n 'DateRangePicker',\n 'A function for i18nStrings.formatRelativeRange was not provided. Relative ranges will not be correctly rendered.'\n );\n }\n }\n\n const formattedDate: string | JSX.Element = renderDateRange({\n locale: normalizedLocale,\n range: value,\n placeholder,\n formatRelativeRange,\n absoluteFormat,\n hideTimeOffset,\n timeOffset: normalizedTimeOffset,\n });\n\n const trigger = (\n <div className={styles['trigger-wrapper']}>\n <ButtonTrigger\n ref={triggerRef}\n id={controlId}\n invalid={invalid}\n warning={warning}\n ariaLabelledby={joinStrings(ariaLabelledby, triggerContentId)}\n ariaLabel={i18nStrings?.ariaLabel}\n ariaDescribedby={ariaDescribedby}\n className={clsx(styles.label, {\n [styles['label-enabled']]: !readOnly && !disabled,\n })}\n hideCaret={true}\n onClick={() => {\n setIsDropDownOpen(true);\n }}\n disabled={disabled}\n readOnly={readOnly}\n ariaHasPopup=\"dialog\"\n >\n <span className={styles['trigger-flexbox']}>\n <span className={styles['icon-wrapper']}>\n <InternalIcon name=\"calendar\" variant={disabled || readOnly ? 'disabled' : 'normal'} />\n </span>\n <span id={triggerContentId}>{formattedDate}</span>\n </span>\n </ButtonTrigger>\n </div>\n );\n\n const mergedRef = useMergeRefs(rootRef, __internalRootRef);\n\n return (\n <div\n {...baseProps}\n ref={mergedRef}\n className={clsx(\n baseProps.className,\n styles.root,\n absoluteFormat === 'long-localized' && !dateOnly && styles.wide\n )}\n onKeyDown={onWrapperKeyDownHandler}\n >\n <Dropdown\n stretchWidth={true}\n stretchHeight={true}\n open={isDropDownOpen}\n onDropdownClose={() => closeDropdown()}\n trigger={trigger}\n stretchToTriggerWidth={false}\n expandToViewport={expandToViewport}\n dropdownId={dropdownId}\n >\n {/* Reset form field context to prevent a wrapper form field from labelling all inputs inside the dropdown. */}\n <ResetContextsForModal>\n {isDropDownOpen && (\n <DateRangePickerDropdown\n startOfWeek={startOfWeek}\n locale={normalizedLocale}\n isSingleGrid={isSingleGrid}\n onDropdownClose={() => closeDropdown(true)}\n value={value}\n showClearButton={showClearButton}\n isDateEnabled={isDateEnabled}\n dateDisabledReason={dateDisabledReason}\n i18nStrings={i18nStrings}\n onClear={onClear}\n onApply={onApply}\n relativeOptions={relativeOptions}\n isValidRange={isValidRange}\n dateOnly={dateOnly}\n timeInputFormat={timeInputFormat}\n rangeSelectorMode={rangeSelectorMode}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n customAbsoluteRangeControl={customAbsoluteRangeControl}\n />\n )}\n </ResetContextsForModal>\n </Dropdown>\n </div>\n );\n }\n);\n\napplyDisplayName(DateRangePicker, 'DateRangePicker');\nexport default DateRangePicker;\n"]}
|
|
@@ -22,6 +22,12 @@ export interface DateRangePickerBaseProps {
|
|
|
22
22
|
* server-side, in the same way as for other form elements.
|
|
23
23
|
*/
|
|
24
24
|
isDateEnabled?: DateRangePickerProps.IsDateEnabledFunction;
|
|
25
|
+
/**
|
|
26
|
+
* Provides a reason why a particular date in the calendar is not enabled (only when `isDateEnabled` returns `false`).
|
|
27
|
+
* If provided, the date becomes focusable.
|
|
28
|
+
* @param date
|
|
29
|
+
*/
|
|
30
|
+
dateDisabledReason?: DateRangePickerProps.DateDisabledReasonFunction;
|
|
25
31
|
/**
|
|
26
32
|
* The locale to be used for rendering month names and defining the
|
|
27
33
|
* starting date of the week. If not provided, it will be determined
|
|
@@ -201,6 +207,9 @@ export declare namespace DateRangePickerProps {
|
|
|
201
207
|
interface IsDateEnabledFunction {
|
|
202
208
|
(date: Date): boolean;
|
|
203
209
|
}
|
|
210
|
+
interface DateDisabledReasonFunction {
|
|
211
|
+
(date: Date): string;
|
|
212
|
+
}
|
|
204
213
|
interface GetTimeOffsetFunction {
|
|
205
214
|
(date: Date): number;
|
|
206
215
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/date-range-picker/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,KAAK,EAAE,IAAI,GAAG,oBAAoB,CAAC,KAAK,CAAC;IAEzC;;OAEG;IACH,eAAe,EAAE,aAAa,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;IAEpE;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,oBAAoB,CAAC,qBAAqB,CAAC;IAE3D;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,WAAW,CAAC,EAAE,oBAAoB,CAAC,WAAW,CAAC;IAE/C;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAE,oBAAoB,CAAC,iBAAiB,CAAC;IAE3D;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC;IAExC;;;OAGG;IACH,QAAQ,CAAC,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAExE;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,MA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B,gBAAgB,GAChB,cAAc,GACd,cAAc,GACd,wBAAwB,GACxB,qCAAqC,CACxC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/date-range-picker/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { TimeInputProps } from '../time-input/interfaces';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport React from 'react';\n\nexport interface DateRangePickerBaseProps {\n /**\n * The current date range value. Can be either an absolute time range\n * or a relative time range.\n */\n value: null | DateRangePickerProps.Value;\n\n /**\n * A list of relative time ranges that are shown as suggestions.\n */\n relativeOptions: ReadonlyArray<DateRangePickerProps.RelativeOption>;\n\n /**\n * A function that defines whether a particular date should be enabled\n * in the calendar or not. Note that disabling a date in the calendar\n * still allows users to enter this date via keyboard. We therefore\n * recommend that you also validate these constraints client- and\n * server-side, in the same way as for other form elements.\n */\n isDateEnabled?: DateRangePickerProps.IsDateEnabledFunction;\n\n /**\n * The locale to be used for rendering month names and defining the\n * starting date of the week. If not provided, it will be determined\n * from the page and browser locales. Supported values and formats\n * are as-per the [JavaScript Intl API specification](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).\n */\n locale?: string;\n\n /**\n * Starting day of the week. [0-6] maps to [Sunday-Saturday].\n * By default the starting day of the week is defined by the locale,\n * but you can override it using this property.\n */\n startOfWeek?: number;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n * @i18n\n */\n i18nStrings?: DateRangePickerProps.I18nStrings;\n\n /**\n * Hides time inputs and changes the input format to date-only, e.g. 2021-04-06.\n *\n * Do not use `dateOnly` flag conditionally. The component does not trigger the value update\n * when the flag changes which means the value format can become inconsistent.\n *\n * Default: `false`.\n */\n dateOnly?: boolean;\n\n /**\n * Determines the range selector mode as follows:\n *\n * * `default` for combined absolute/relative range selector.\n * * `absolute-only` for absolute-only range selector.\n * * `relative-only` for relative-only range selector.\n *\n * By default, the range selector mode is `default`.\n */\n rangeSelectorMode?: DateRangePickerProps.RangeSelectorMode;\n\n /**\n * Specifies the format of the time input for absolute ranges.\n *\n * Use to restrict the granularity of time that the user can enter.\n *\n * Has no effect when `dateOnly` is true.\n */\n timeInputFormat?: TimeInputProps.Format;\n\n /**\n * Fired whenever a user changes the component's value.\n * The event `detail` contains the current value of the field.\n */\n onChange?: NonCancelableEventHandler<DateRangePickerProps.ChangeDetail>;\n\n /**\n * The time offset from UTC in minutes that should be used to\n * display and produce values.\n *\n * Has no effect when `dateOnly` is true.\n *\n * Default: the user's current time offset as provided by the browser.\n *\n * @deprecated Use `getTimeOffset` instead.\n */\n timeOffset?: number;\n\n /**\n * A function that defines timezone offset from UTC in minutes for selected dates.\n * Use it to define time relative to the desired timezone.\n *\n * The function is called for the start date and the end date and takes a UTC date\n * corresponding the selected value as an argument.\n *\n * Has no effect when `dateOnly` is true.\n *\n * Default: the user's current time offset as provided by the browser.\n */\n getTimeOffset?: DateRangePickerProps.GetTimeOffsetFunction;\n}\nexport interface DateRangePickerProps\n extends BaseComponentProps,\n FormFieldValidationControlProps,\n ExpandToViewport,\n DateRangePickerBaseProps {\n /**\n * Specifies the placeholder text that is rendered when the value is empty.\n */\n placeholder?: string;\n\n /**\n * Specifies that the component is disabled, preventing the user from\n * modifying the value. A disabled component cannot receive focus.\n */\n disabled?: boolean;\n\n /**\n * Specifies that the component is read-only, preventing the user from\n * modifying the value. A read-only component can receive focus.\n */\n readOnly?: boolean;\n\n /**\n * Fired when keyboard focus is set onto the UI control.\n */\n onFocus?: NonCancelableEventHandler<null>;\n\n /**\n * Fired when keyboard focus is removed from the UI control.\n */\n onBlur?: NonCancelableEventHandler<null>;\n\n /**\n * A function that defines whether a particular range is valid or not.\n *\n * Ensure that your function checks for missing fields in the value.\n */\n isValidRange: DateRangePickerProps.ValidationFunction;\n\n /**\n * Specifies whether the component should show a button that\n * allows the user to clear the selected value.\n */\n showClearButton?: boolean;\n\n /**\n * Specifies an additional control displayed in the dropdown, located below the range calendar.\n */\n customAbsoluteRangeControl?: DateRangePickerProps.AbsoluteRangeControl;\n\n /**\n * Specifies the time format to use for displaying the absolute time range.\n *\n * It can take the following values:\n * * `iso`: ISO 8601 format, e.g.: 2024-01-30T13:32:32+01:00 (or 2024-01-30 when `dateOnly` is true)\n * * `long-localized`: a more human-readable, localized format, e.g.: January 30, 2024, 13:32:32 (UTC+1) (or January 30, 2024 when `dateOnly` is true)\n *\n * Defaults to `iso`.\n */\n absoluteFormat?: DateRangePickerProps.AbsoluteFormat;\n\n /**\n * Specifies whether to hide the time offset in the displayed absolute time range.\n * Defaults to `false`.\n */\n hideTimeOffset?: boolean;\n}\n\nexport namespace DateRangePickerProps {\n export type Value = AbsoluteValue | RelativeValue;\n export interface AbsoluteValue {\n /**\n * In ISO8601 format, e.g.: 2021-04-06T17:23:50+02:00 (or 2021-04-06 when `dateOnly` is true)\n */\n startDate: string;\n /**\n * In ISO8601 format, e.g.: 2021-04-06T17:23:50+02:00 (or 2021-04-06 when `dateOnly` is true)\n */\n endDate: string;\n type: 'absolute';\n }\n\n export interface RelativeValue {\n /**\n * If provided, used to match this value\n * to a provided relative option.\n */\n key?: string;\n amount: number;\n unit: TimeUnit;\n type: 'relative';\n }\n export interface RelativeOption {\n /**\n * Used to uniquely identify this relative option.\n */\n key: string;\n amount: number;\n unit: TimeUnit;\n type: 'relative';\n }\n\n export type TimeUnit = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';\n\n export type ValidationFunction = (value: Value | null) => ValidationResult;\n\n export type ValidationResult = ValidRangeResult | InvalidRangeResult;\n\n export interface ValidRangeResult {\n valid: true;\n }\n\n export interface InvalidRangeResult {\n valid: false;\n errorMessage: string;\n }\n\n export interface ChangeDetail {\n /**\n * The newly selected range of this date range picker.\n */\n value: null | Value;\n }\n\n export interface IsDateEnabledFunction {\n (date: Date): boolean;\n }\n\n export interface GetTimeOffsetFunction {\n (date: Date): number;\n }\n\n export interface DateTimeStrings {\n date: string;\n time: string;\n }\n\n export interface PendingAbsoluteValue {\n start: DateTimeStrings;\n end: DateTimeStrings;\n }\n\n export type AbsoluteRangeControl = (\n selectedRange: PendingAbsoluteValue,\n setSelectedRange: React.Dispatch<React.SetStateAction<PendingAbsoluteValue>>\n ) => React.ReactNode;\n\n export type RangeSelectorMode = 'default' | 'absolute-only' | 'relative-only';\n\n export interface Ref {\n /**\n * Sets the browser focus on the UI control\n */\n focus(): void;\n }\n\n export interface I18nStrings {\n /**\n * Adds `aria-label` to the trigger and dropdown.\n */\n ariaLabel?: string;\n\n /**\n * Adds `aria-labelledby` to the trigger and dropdown.\n */\n ariaLabelledby?: string;\n\n /**\n * Adds `aria-describedby` to the trigger and dropdown.\n */\n ariaDescribedby?: string;\n\n /**\n * Label of the mode selection group. In the standard view, it adds 'aria-label' to the group of segments.\n * In a narrow container the label is visible and attached to the select component.\n */\n modeSelectionLabel?: string;\n\n /**\n * Segment title of the relative range selection mode\n */\n relativeModeTitle?: string;\n\n /**\n * Segment title of the absolute range selection mode\n */\n absoluteModeTitle?: string;\n\n /**\n * Heading for the relative range selection area\n */\n relativeRangeSelectionHeading?: string;\n\n /**\n * Visible label of the Cancel button\n */\n cancelButtonLabel?: string;\n /**\n * Visible label of the Clear and dismiss button\n */\n clearButtonLabel?: string;\n /**\n * Visible label of the Apply button\n */\n applyButtonLabel?: string;\n\n /**\n * Formatting function for relative ranges.\n * This function must convert a relative range to a human-readable string.\n */\n formatRelativeRange?: (value: RelativeValue) => string;\n\n /**\n * Formatting function for time units.\n *\n * This function must return a localized form of the unit that fits the provided time value.\n */\n formatUnit?: (unit: TimeUnit, value: number) => string;\n\n /**\n * Visible label for the option for selecting\n * a custom relative range.\n */\n customRelativeRangeOptionLabel?: string;\n\n /**\n * Visible description for the option for selecting\n * a custom relative range.\n */\n customRelativeRangeOptionDescription?: string;\n\n /**\n * Visible label for the duration selector for\n * the custom relative range.\n */\n customRelativeRangeDurationLabel?: string;\n /**\n * Placeholder for the duration selector for\n * the custom relative range.\n */\n customRelativeRangeDurationPlaceholder?: string;\n /**\n * Visible label for the unit selector for the\n * custom relative range.\n */\n customRelativeRangeUnitLabel?: string;\n\n /**\n * Used as part of the aria label for today's date in the calendar.\n */\n todayAriaLabel?: string;\n\n /**\n * An aria label for the 'next month' button.\n */\n nextMonthAriaLabel?: string;\n\n /**\n * An aria label for the 'previous month' button.\n */\n previousMonthAriaLabel?: string;\n\n /**\n * Visible label for the Start Date input for the\n * absolute range.\n */\n startDateLabel?: string;\n /**\n * Visible label for the Start Time input for the\n * absolute range.\n */\n startTimeLabel?: string;\n /**\n * Visible label for the End Date input for the\n * absolute range.\n */\n endDateLabel?: string;\n /**\n * Visible label for the End Time input for the\n * absolute range.\n */\n endTimeLabel?: string;\n\n /**\n * Constraint text for the input fields for the\n * absolute range.\n */\n dateTimeConstraintText?: string;\n\n /**\n * Provides a text alternative for the error icon in the error alert.\n */\n errorIconAriaLabel?: string;\n\n /**\n * When the property is set, screen readers announce the selected range when the absolute range gets selected.\n */\n renderSelectedAbsoluteRangeAriaLive?: (startDate: string, endDate: string) => string;\n }\n\n export type AbsoluteFormat = 'iso' | 'long-localized';\n}\n\nexport type DayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\nexport type RangeCalendarI18nStrings = Pick<\n DateRangePickerProps.I18nStrings,\n | 'todayAriaLabel'\n | 'nextMonthAriaLabel'\n | 'previousMonthAriaLabel'\n | 'startDateLabel'\n | 'startTimeLabel'\n | 'endDateLabel'\n | 'endTimeLabel'\n | 'dateTimeConstraintText'\n | 'renderSelectedAbsoluteRangeAriaLive'\n>;\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/date-range-picker/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { TimeInputProps } from '../time-input/interfaces';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport React from 'react';\n\nexport interface DateRangePickerBaseProps {\n /**\n * The current date range value. Can be either an absolute time range\n * or a relative time range.\n */\n value: null | DateRangePickerProps.Value;\n\n /**\n * A list of relative time ranges that are shown as suggestions.\n */\n relativeOptions: ReadonlyArray<DateRangePickerProps.RelativeOption>;\n\n /**\n * A function that defines whether a particular date should be enabled\n * in the calendar or not. Note that disabling a date in the calendar\n * still allows users to enter this date via keyboard. We therefore\n * recommend that you also validate these constraints client- and\n * server-side, in the same way as for other form elements.\n */\n isDateEnabled?: DateRangePickerProps.IsDateEnabledFunction;\n\n /**\n * Provides a reason why a particular date in the calendar is not enabled (only when `isDateEnabled` returns `false`).\n * If provided, the date becomes focusable.\n * @param date\n */\n dateDisabledReason?: DateRangePickerProps.DateDisabledReasonFunction;\n\n /**\n * The locale to be used for rendering month names and defining the\n * starting date of the week. If not provided, it will be determined\n * from the page and browser locales. Supported values and formats\n * are as-per the [JavaScript Intl API specification](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).\n */\n locale?: string;\n\n /**\n * Starting day of the week. [0-6] maps to [Sunday-Saturday].\n * By default the starting day of the week is defined by the locale,\n * but you can override it using this property.\n */\n startOfWeek?: number;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n * @i18n\n */\n i18nStrings?: DateRangePickerProps.I18nStrings;\n\n /**\n * Hides time inputs and changes the input format to date-only, e.g. 2021-04-06.\n *\n * Do not use `dateOnly` flag conditionally. The component does not trigger the value update\n * when the flag changes which means the value format can become inconsistent.\n *\n * Default: `false`.\n */\n dateOnly?: boolean;\n\n /**\n * Determines the range selector mode as follows:\n *\n * * `default` for combined absolute/relative range selector.\n * * `absolute-only` for absolute-only range selector.\n * * `relative-only` for relative-only range selector.\n *\n * By default, the range selector mode is `default`.\n */\n rangeSelectorMode?: DateRangePickerProps.RangeSelectorMode;\n\n /**\n * Specifies the format of the time input for absolute ranges.\n *\n * Use to restrict the granularity of time that the user can enter.\n *\n * Has no effect when `dateOnly` is true.\n */\n timeInputFormat?: TimeInputProps.Format;\n\n /**\n * Fired whenever a user changes the component's value.\n * The event `detail` contains the current value of the field.\n */\n onChange?: NonCancelableEventHandler<DateRangePickerProps.ChangeDetail>;\n\n /**\n * The time offset from UTC in minutes that should be used to\n * display and produce values.\n *\n * Has no effect when `dateOnly` is true.\n *\n * Default: the user's current time offset as provided by the browser.\n *\n * @deprecated Use `getTimeOffset` instead.\n */\n timeOffset?: number;\n\n /**\n * A function that defines timezone offset from UTC in minutes for selected dates.\n * Use it to define time relative to the desired timezone.\n *\n * The function is called for the start date and the end date and takes a UTC date\n * corresponding the selected value as an argument.\n *\n * Has no effect when `dateOnly` is true.\n *\n * Default: the user's current time offset as provided by the browser.\n */\n getTimeOffset?: DateRangePickerProps.GetTimeOffsetFunction;\n}\nexport interface DateRangePickerProps\n extends BaseComponentProps,\n FormFieldValidationControlProps,\n ExpandToViewport,\n DateRangePickerBaseProps {\n /**\n * Specifies the placeholder text that is rendered when the value is empty.\n */\n placeholder?: string;\n\n /**\n * Specifies that the component is disabled, preventing the user from\n * modifying the value. A disabled component cannot receive focus.\n */\n disabled?: boolean;\n\n /**\n * Specifies that the component is read-only, preventing the user from\n * modifying the value. A read-only component can receive focus.\n */\n readOnly?: boolean;\n\n /**\n * Fired when keyboard focus is set onto the UI control.\n */\n onFocus?: NonCancelableEventHandler<null>;\n\n /**\n * Fired when keyboard focus is removed from the UI control.\n */\n onBlur?: NonCancelableEventHandler<null>;\n\n /**\n * A function that defines whether a particular range is valid or not.\n *\n * Ensure that your function checks for missing fields in the value.\n */\n isValidRange: DateRangePickerProps.ValidationFunction;\n\n /**\n * Specifies whether the component should show a button that\n * allows the user to clear the selected value.\n */\n showClearButton?: boolean;\n\n /**\n * Specifies an additional control displayed in the dropdown, located below the range calendar.\n */\n customAbsoluteRangeControl?: DateRangePickerProps.AbsoluteRangeControl;\n\n /**\n * Specifies the time format to use for displaying the absolute time range.\n *\n * It can take the following values:\n * * `iso`: ISO 8601 format, e.g.: 2024-01-30T13:32:32+01:00 (or 2024-01-30 when `dateOnly` is true)\n * * `long-localized`: a more human-readable, localized format, e.g.: January 30, 2024, 13:32:32 (UTC+1) (or January 30, 2024 when `dateOnly` is true)\n *\n * Defaults to `iso`.\n */\n absoluteFormat?: DateRangePickerProps.AbsoluteFormat;\n\n /**\n * Specifies whether to hide the time offset in the displayed absolute time range.\n * Defaults to `false`.\n */\n hideTimeOffset?: boolean;\n}\n\nexport namespace DateRangePickerProps {\n export type Value = AbsoluteValue | RelativeValue;\n export interface AbsoluteValue {\n /**\n * In ISO8601 format, e.g.: 2021-04-06T17:23:50+02:00 (or 2021-04-06 when `dateOnly` is true)\n */\n startDate: string;\n /**\n * In ISO8601 format, e.g.: 2021-04-06T17:23:50+02:00 (or 2021-04-06 when `dateOnly` is true)\n */\n endDate: string;\n type: 'absolute';\n }\n\n export interface RelativeValue {\n /**\n * If provided, used to match this value\n * to a provided relative option.\n */\n key?: string;\n amount: number;\n unit: TimeUnit;\n type: 'relative';\n }\n export interface RelativeOption {\n /**\n * Used to uniquely identify this relative option.\n */\n key: string;\n amount: number;\n unit: TimeUnit;\n type: 'relative';\n }\n\n export type TimeUnit = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';\n\n export type ValidationFunction = (value: Value | null) => ValidationResult;\n\n export type ValidationResult = ValidRangeResult | InvalidRangeResult;\n\n export interface ValidRangeResult {\n valid: true;\n }\n\n export interface InvalidRangeResult {\n valid: false;\n errorMessage: string;\n }\n\n export interface ChangeDetail {\n /**\n * The newly selected range of this date range picker.\n */\n value: null | Value;\n }\n\n export interface IsDateEnabledFunction {\n (date: Date): boolean;\n }\n\n export interface DateDisabledReasonFunction {\n (date: Date): string;\n }\n\n export interface GetTimeOffsetFunction {\n (date: Date): number;\n }\n\n export interface DateTimeStrings {\n date: string;\n time: string;\n }\n\n export interface PendingAbsoluteValue {\n start: DateTimeStrings;\n end: DateTimeStrings;\n }\n\n export type AbsoluteRangeControl = (\n selectedRange: PendingAbsoluteValue,\n setSelectedRange: React.Dispatch<React.SetStateAction<PendingAbsoluteValue>>\n ) => React.ReactNode;\n\n export type RangeSelectorMode = 'default' | 'absolute-only' | 'relative-only';\n\n export interface Ref {\n /**\n * Sets the browser focus on the UI control\n */\n focus(): void;\n }\n\n export interface I18nStrings {\n /**\n * Adds `aria-label` to the trigger and dropdown.\n */\n ariaLabel?: string;\n\n /**\n * Adds `aria-labelledby` to the trigger and dropdown.\n */\n ariaLabelledby?: string;\n\n /**\n * Adds `aria-describedby` to the trigger and dropdown.\n */\n ariaDescribedby?: string;\n\n /**\n * Label of the mode selection group. In the standard view, it adds 'aria-label' to the group of segments.\n * In a narrow container the label is visible and attached to the select component.\n */\n modeSelectionLabel?: string;\n\n /**\n * Segment title of the relative range selection mode\n */\n relativeModeTitle?: string;\n\n /**\n * Segment title of the absolute range selection mode\n */\n absoluteModeTitle?: string;\n\n /**\n * Heading for the relative range selection area\n */\n relativeRangeSelectionHeading?: string;\n\n /**\n * Visible label of the Cancel button\n */\n cancelButtonLabel?: string;\n /**\n * Visible label of the Clear and dismiss button\n */\n clearButtonLabel?: string;\n /**\n * Visible label of the Apply button\n */\n applyButtonLabel?: string;\n\n /**\n * Formatting function for relative ranges.\n * This function must convert a relative range to a human-readable string.\n */\n formatRelativeRange?: (value: RelativeValue) => string;\n\n /**\n * Formatting function for time units.\n *\n * This function must return a localized form of the unit that fits the provided time value.\n */\n formatUnit?: (unit: TimeUnit, value: number) => string;\n\n /**\n * Visible label for the option for selecting\n * a custom relative range.\n */\n customRelativeRangeOptionLabel?: string;\n\n /**\n * Visible description for the option for selecting\n * a custom relative range.\n */\n customRelativeRangeOptionDescription?: string;\n\n /**\n * Visible label for the duration selector for\n * the custom relative range.\n */\n customRelativeRangeDurationLabel?: string;\n /**\n * Placeholder for the duration selector for\n * the custom relative range.\n */\n customRelativeRangeDurationPlaceholder?: string;\n /**\n * Visible label for the unit selector for the\n * custom relative range.\n */\n customRelativeRangeUnitLabel?: string;\n\n /**\n * Used as part of the aria label for today's date in the calendar.\n */\n todayAriaLabel?: string;\n\n /**\n * An aria label for the 'next month' button.\n */\n nextMonthAriaLabel?: string;\n\n /**\n * An aria label for the 'previous month' button.\n */\n previousMonthAriaLabel?: string;\n\n /**\n * Visible label for the Start Date input for the\n * absolute range.\n */\n startDateLabel?: string;\n /**\n * Visible label for the Start Time input for the\n * absolute range.\n */\n startTimeLabel?: string;\n /**\n * Visible label for the End Date input for the\n * absolute range.\n */\n endDateLabel?: string;\n /**\n * Visible label for the End Time input for the\n * absolute range.\n */\n endTimeLabel?: string;\n\n /**\n * Constraint text for the input fields for the\n * absolute range.\n */\n dateTimeConstraintText?: string;\n\n /**\n * Provides a text alternative for the error icon in the error alert.\n */\n errorIconAriaLabel?: string;\n\n /**\n * When the property is set, screen readers announce the selected range when the absolute range gets selected.\n */\n renderSelectedAbsoluteRangeAriaLive?: (startDate: string, endDate: string) => string;\n }\n\n export type AbsoluteFormat = 'iso' | 'long-localized';\n}\n\nexport type DayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\nexport type RangeCalendarI18nStrings = Pick<\n DateRangePickerProps.I18nStrings,\n | 'todayAriaLabel'\n | 'nextMonthAriaLabel'\n | 'previousMonthAriaLabel'\n | 'startDateLabel'\n | 'startTimeLabel'\n | 'endDateLabel'\n | 'endTimeLabel'\n | 'dateTimeConstraintText'\n | 'renderSelectedAbsoluteRangeAriaLive'\n>;\n"]}
|
package/grid/internal.d.ts
CHANGED
|
@@ -9,6 +9,10 @@ export interface InternalGridProps extends GridProps, InternalBaseComponentProps
|
|
|
9
9
|
* The handler that fires when the grid breakpoint changes.
|
|
10
10
|
*/
|
|
11
11
|
__responsiveClassName?: (breakpoint: Breakpoint | null) => ClassValue;
|
|
12
|
+
/**
|
|
13
|
+
* Overrides the default wrapper HTML tag.
|
|
14
|
+
*/
|
|
15
|
+
__tagOverride?: string;
|
|
12
16
|
}
|
|
13
17
|
declare const InternalGrid: React.ForwardRefExoticComponent<InternalGridProps & React.RefAttributes<HTMLDivElement>>;
|
|
14
18
|
export default InternalGrid;
|
package/grid/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/grid/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAa,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGxC,OAAO,EAAE,UAAU,EAA0B,MAAM,yBAAyB,CAAC;AAI7E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAGlF,MAAM,WAAW,iBAAkB,SAAQ,SAAS,EAAE,0BAA0B;IAC9E,YAAY,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAEjC;;OAEG;IACH,qBAAqB,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,KAAK,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/grid/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAa,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGxC,OAAO,EAAE,UAAU,EAA0B,MAAM,yBAAyB,CAAC;AAI7E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAGlF,MAAM,WAAW,iBAAkB,SAAQ,SAAS,EAAE,0BAA0B;IAC9E,YAAY,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAEjC;;OAEG;IACH,qBAAqB,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,KAAK,UAAU,CAAC;IACtE;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,YAAY,0FA2EjB,CAAC;AAgBF,eAAe,YAAY,CAAC"}
|
package/grid/internal.js
CHANGED
|
@@ -12,7 +12,7 @@ import styles from './styles.css.js';
|
|
|
12
12
|
import { useContainerBreakpoints } from '../internal/hooks/container-queries';
|
|
13
13
|
import { useMergeRefs } from '../internal/hooks/use-merge-refs';
|
|
14
14
|
const InternalGrid = React.forwardRef((_a, ref) => {
|
|
15
|
-
var { __breakpoint, gridDefinition = [], disableGutters = false, children, __responsiveClassName, __internalRootRef = null } = _a, restProps = __rest(_a, ["__breakpoint", "gridDefinition", "disableGutters", "children", "__responsiveClassName", "__internalRootRef"]);
|
|
15
|
+
var { __breakpoint, gridDefinition = [], disableGutters = false, children, __tagOverride, __responsiveClassName, __internalRootRef = null } = _a, restProps = __rest(_a, ["__breakpoint", "gridDefinition", "disableGutters", "children", "__tagOverride", "__responsiveClassName", "__internalRootRef"]);
|
|
16
16
|
let [defaultBreakpoint, defaultRef] = useContainerBreakpoints(undefined);
|
|
17
17
|
if (__breakpoint !== undefined) {
|
|
18
18
|
defaultBreakpoint = __breakpoint;
|
|
@@ -23,6 +23,7 @@ const InternalGrid = React.forwardRef((_a, ref) => {
|
|
|
23
23
|
Flattening the children allows us to "see through" React Fragments and nested arrays.
|
|
24
24
|
*/
|
|
25
25
|
const flattenedChildren = flattenChildren(children);
|
|
26
|
+
const Tag = (__tagOverride !== null && __tagOverride !== void 0 ? __tagOverride : 'div');
|
|
26
27
|
if (isDevelopment) {
|
|
27
28
|
const columnCount = gridDefinition.length;
|
|
28
29
|
const childCount = flattenedChildren.length;
|
|
@@ -31,7 +32,7 @@ const InternalGrid = React.forwardRef((_a, ref) => {
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
const mergedRef = useMergeRefs(defaultRef, __internalRootRef);
|
|
34
|
-
return (React.createElement(
|
|
35
|
+
return (React.createElement(Tag, Object.assign({}, baseProps, { className: clsx(styles.grid, baseProps.className, { [styles['no-gutters']]: disableGutters }, __responsiveClassName ? __responsiveClassName(defaultBreakpoint) : null), ref: mergedRef }), flattenedChildren.map((child, i) => {
|
|
35
36
|
var _a, _b, _c, _d;
|
|
36
37
|
// If this react child is a primitive value, the key will be undefined
|
|
37
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
package/grid/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/grid/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAoB,MAAM,MAAM,CAAC;AACxC,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAc,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AACzE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAE9E,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/grid/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OA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IACJ,CAAC,CAAC,CACE,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,SAAS,mBAAmB,CAC1B,IAAY,EACZ,OAAyD,EACzD,UAA6B;IAE7B,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,OAAO,MAAM,CAAC,GAAG,IAAI,IAAI,OAAO,EAAE,CAAC,CAAC;KACrC;IACD,IAAI,UAAU,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE;QAChD,OAAO,IAAI,CAAC;KACb;IACD,OAAO,MAAM,CAAC,GAAG,IAAI,IAAI,sBAAsB,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED,eAAe,YAAY,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx, { ClassValue } from 'clsx';\nimport flattenChildren from 'react-keyed-flatten-children';\nimport { getBaseProps } from '../internal/base-component';\nimport { Breakpoint, matchBreakpointMapping } from '../internal/breakpoints';\nimport { isDevelopment } from '../internal/is-development';\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport styles from './styles.css.js';\nimport { GridProps } from './interfaces';\nimport { useContainerBreakpoints } from '../internal/hooks/container-queries';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\n\nexport interface InternalGridProps extends GridProps, InternalBaseComponentProps {\n __breakpoint?: Breakpoint | null;\n\n /**\n * The handler that fires when the grid breakpoint changes.\n */\n __responsiveClassName?: (breakpoint: Breakpoint | null) => ClassValue;\n /**\n * Overrides the default wrapper HTML tag.\n */\n __tagOverride?: string;\n}\n\nconst InternalGrid = React.forwardRef(\n (\n {\n __breakpoint,\n gridDefinition = [],\n disableGutters = false,\n children,\n __tagOverride,\n __responsiveClassName,\n __internalRootRef = null,\n ...restProps\n }: InternalGridProps,\n ref: React.Ref<HTMLDivElement>\n ) => {\n let [defaultBreakpoint, defaultRef]: [Breakpoint | null, React.Ref<HTMLDivElement>] =\n useContainerBreakpoints(undefined);\n if (__breakpoint !== undefined) {\n defaultBreakpoint = __breakpoint;\n defaultRef = ref;\n }\n\n const baseProps = getBaseProps(restProps);\n /*\n Flattening the children allows us to \"see through\" React Fragments and nested arrays.\n */\n const flattenedChildren = flattenChildren(children);\n const Tag = (__tagOverride ?? 'div') as 'div';\n\n if (isDevelopment) {\n const columnCount = gridDefinition.length;\n const childCount = flattenedChildren.length;\n if (columnCount !== childCount) {\n warnOnce(\n 'Grid',\n `The number of children (${childCount}) does not match the number of columns defined (${columnCount}).`\n );\n }\n }\n\n const mergedRef = useMergeRefs(defaultRef, __internalRootRef);\n\n return (\n <Tag\n {...baseProps}\n className={clsx(\n styles.grid,\n baseProps.className,\n { [styles['no-gutters']]: disableGutters },\n __responsiveClassName ? __responsiveClassName(defaultBreakpoint) : null\n )}\n ref={mergedRef}\n >\n {flattenedChildren.map((child, i) => {\n // If this react child is a primitive value, the key will be undefined\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const key = (child as Record<'key', unknown>).key;\n\n return (\n <div\n key={key ? String(key) : undefined}\n className={clsx(\n styles['grid-column'],\n getColumnClassNames('colspan', gridDefinition[i]?.colspan, defaultBreakpoint),\n getColumnClassNames('offset', gridDefinition[i]?.offset, defaultBreakpoint),\n getColumnClassNames('pull', gridDefinition[i]?.pull, defaultBreakpoint),\n getColumnClassNames('push', gridDefinition[i]?.push, defaultBreakpoint)\n )}\n >\n <div className={styles['restore-pointer-events']}>{child}</div>\n </div>\n );\n })}\n </Tag>\n );\n }\n);\n\nfunction getColumnClassNames(\n prop: string,\n mapping: undefined | number | GridProps.BreakpointMapping,\n breakpoint: Breakpoint | null\n): string | null {\n if (typeof mapping === 'number') {\n return styles[`${prop}-${mapping}`];\n }\n if (breakpoint === null || mapping === undefined) {\n return null;\n }\n return styles[`${prop}-${matchBreakpointMapping(mapping, breakpoint)}`];\n}\n\nexport default InternalGrid;\n"]}
|
package/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export { default as HelpPanel, HelpPanelProps } from './help-panel';
|
|
|
35
35
|
export { default as Hotspot, HotspotProps } from './hotspot';
|
|
36
36
|
export { default as Icon, IconProps } from './icon';
|
|
37
37
|
export { default as Input, InputProps } from './input';
|
|
38
|
+
export { default as KeyValuePairs, KeyValuePairsProps } from './key-value-pairs';
|
|
38
39
|
export { default as LineChart, LineChartProps } from './line-chart';
|
|
39
40
|
export { default as Link, LinkProps } from './link';
|
|
40
41
|
export { default as MixedLineBarChart, MixedLineBarChartProps } from './mixed-line-bar-chart';
|