@pega/cosmos-react-core 3.0.0-dev.17.0 → 3.0.0-dev.18.2
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/lib/components/Badges/Keyboard.d.ts.map +1 -1
- package/lib/components/Badges/Keyboard.js +2 -0
- package/lib/components/Badges/Keyboard.js.map +1 -1
- package/lib/components/Badges/Selection.d.ts +1 -1
- package/lib/components/Badges/Selection.d.ts.map +1 -1
- package/lib/components/Badges/Selection.js +4 -2
- package/lib/components/Badges/Selection.js.map +1 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.d.ts +2 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
- package/lib/components/Breadcrumbs/Breadcrumbs.js +27 -7
- package/lib/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
- package/lib/components/ComboBox/ComboBox.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBox.js +55 -23
- package/lib/components/ComboBox/ComboBox.js.map +1 -1
- package/lib/components/ComboBox/ComboBox.types.d.ts +3 -1
- package/lib/components/ComboBox/ComboBox.types.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBox.types.js.map +1 -1
- package/lib/components/ComboBox/ComboBoxInput.d.ts +7 -0
- package/lib/components/ComboBox/ComboBoxInput.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBoxInput.js +5 -2
- package/lib/components/ComboBox/ComboBoxInput.js.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.d.ts.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js +113 -36
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.js.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.d.ts +8 -0
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.d.ts.map +1 -1
- package/lib/components/ComboBox/MultiSelectInput/MultiSelectInput.types.js.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.d.ts.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.js +2 -2
- package/lib/components/CompositeInput/CompositeInput.js.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.styles.d.ts.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.styles.js +20 -17
- package/lib/components/CompositeInput/CompositeInput.styles.js.map +1 -1
- package/lib/components/Currency/utils.d.ts.map +1 -1
- package/lib/components/Currency/utils.js +3 -2
- package/lib/components/Currency/utils.js.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.js +6 -12
- package/lib/components/DateTime/Picker/Calendar.js.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.styles.d.ts +2 -4
- package/lib/components/DateTime/Picker/Calendar.styles.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/Calendar.styles.js +12 -54
- package/lib/components/DateTime/Picker/Calendar.styles.js.map +1 -1
- package/lib/components/DateTime/Picker/DatePicker.d.ts.map +1 -1
- package/lib/components/DateTime/Picker/DatePicker.js +2 -1
- package/lib/components/DateTime/Picker/DatePicker.js.map +1 -1
- package/lib/components/DateTime/Picker/DatePicker.styles.d.ts +3 -0
- package/lib/components/DateTime/Picker/DatePicker.styles.d.ts.map +1 -0
- package/lib/components/DateTime/Picker/DatePicker.styles.js +39 -0
- package/lib/components/DateTime/Picker/DatePicker.styles.js.map +1 -0
- package/lib/components/DateTime/Picker/DateRangePicker.js +1 -1
- package/lib/components/DateTime/Picker/DateRangePicker.js.map +1 -1
- package/lib/components/DateTime/index.d.ts +2 -0
- package/lib/components/DateTime/index.d.ts.map +1 -1
- package/lib/components/DateTime/index.js +2 -0
- package/lib/components/DateTime/index.js.map +1 -1
- package/lib/components/Dialog/Dialog.d.ts.map +1 -1
- package/lib/components/Dialog/Dialog.js +3 -2
- package/lib/components/Dialog/Dialog.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.js +64 -9
- package/lib/components/ListToolbar/ListToolbar.js.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.types.d.ts +2 -0
- package/lib/components/ListToolbar/ListToolbar.types.d.ts.map +1 -1
- package/lib/components/ListToolbar/ListToolbar.types.js.map +1 -1
- package/lib/components/ListToolbar/PresetMenuPopover.d.ts +12 -0
- package/lib/components/ListToolbar/PresetMenuPopover.d.ts.map +1 -0
- package/lib/components/ListToolbar/PresetMenuPopover.js +36 -0
- package/lib/components/ListToolbar/PresetMenuPopover.js.map +1 -0
- package/lib/components/ListToolbar/QueryOptionPopover.d.ts.map +1 -1
- package/lib/components/ListToolbar/QueryOptionPopover.js +14 -44
- package/lib/components/ListToolbar/QueryOptionPopover.js.map +1 -1
- package/lib/components/Menu/Menu.d.ts.map +1 -1
- package/lib/components/Menu/Menu.js +8 -5
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/Menu/Menu.styles.js +1 -1
- package/lib/components/Menu/Menu.styles.js.map +1 -1
- package/lib/components/Menu/Menu.types.d.ts +13 -0
- package/lib/components/Menu/Menu.types.d.ts.map +1 -1
- package/lib/components/Menu/Menu.types.js.map +1 -1
- package/lib/components/Menu/MenuGroup.d.ts.map +1 -1
- package/lib/components/Menu/MenuGroup.js +3 -3
- package/lib/components/Menu/MenuGroup.js.map +1 -1
- package/lib/components/Menu/MenuItem.d.ts.map +1 -1
- package/lib/components/Menu/MenuItem.js +3 -5
- package/lib/components/Menu/MenuItem.js.map +1 -1
- package/lib/components/Menu/MenuList.d.ts.map +1 -1
- package/lib/components/Menu/MenuList.js +14 -14
- package/lib/components/Menu/MenuList.js.map +1 -1
- package/lib/components/PageTemplates/DashboardPage.d.ts.map +1 -1
- package/lib/components/PageTemplates/DashboardPage.js +1 -4
- package/lib/components/PageTemplates/DashboardPage.js.map +1 -1
- package/lib/components/Skeleton/ParagraphSkeleton.d.ts.map +1 -1
- package/lib/components/Skeleton/ParagraphSkeleton.js +2 -2
- package/lib/components/Skeleton/ParagraphSkeleton.js.map +1 -1
- package/lib/hooks/useActiveDescendant.d.ts +5 -1
- package/lib/hooks/useActiveDescendant.d.ts.map +1 -1
- package/lib/hooks/useActiveDescendant.js +162 -94
- package/lib/hooks/useActiveDescendant.js.map +1 -1
- package/lib/hooks/useI18n.d.ts +26 -0
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/hooks/useI18n.js +2 -1
- package/lib/hooks/useI18n.js.map +1 -1
- package/lib/i18n/default.d.ts +26 -0
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +39 -13
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +52 -0
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/i18n/translate.d.ts +3 -0
- package/lib/i18n/translate.d.ts.map +1 -1
- package/lib/i18n/translate.js.map +1 -1
- package/lib/init.js +1 -1
- package/lib/init.js.map +1 -1
- package/lib/theme/themes/darkTheme.json +3 -1
- package/package.json +1 -1
|
@@ -95,13 +95,12 @@ const Calendar = forwardRef(({ selected, current = selected ? new Date(selected.
|
|
|
95
95
|
};
|
|
96
96
|
return betweenHighlightAndBoundary('startDate') || betweenHighlightAndBoundary('endDate');
|
|
97
97
|
};
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (hasFocus)
|
|
100
|
+
containerRef.current?.querySelector('button[tabindex="0"]')?.focus();
|
|
101
|
+
}, [hasFocus, focusedDay]);
|
|
98
102
|
const days = getDaysOfMonth(current, calendarType ?? CALENDAR_TYPES.ISO_8601).map(day => {
|
|
99
|
-
return (_jsx(StyledDay, {
|
|
100
|
-
? (focusedRef) => {
|
|
101
|
-
if (hasFocus)
|
|
102
|
-
focusedRef?.focus();
|
|
103
|
-
}
|
|
104
|
-
: undefined, tabIndex: isFocused(day) ? 0 : -1, disabled: disabled || mode === 'week' || isDisabled(day), current: toUTCDateString(day) === today, highlighted: isInRange(day) || isHighlighted(day), "aria-selected": isSelected(day) || undefined, "aria-current": isSelected(day) ? 'date' : undefined, dayInNexOrPrevMonth: day.getUTCMonth() !== current.getUTCMonth(), "aria-label": toUTCDateString(day, Intl.DateTimeFormat(locale, ariaOpts)), onMouseOver: showHighlight ? () => setHighlightBoundary(day) : undefined, onMouseOut: showHighlight ? () => setHighlightBoundary(undefined) : undefined, onMouseDown: () => {
|
|
103
|
+
return (_jsx(StyledDay, { tabIndex: isFocused(day) ? 0 : -1, disabled: disabled || mode === 'week' || isDisabled(day), current: toUTCDateString(day) === today, highlighted: isInRange(day) || isHighlighted(day), "aria-selected": isSelected(day) || undefined, "aria-current": isSelected(day) ? 'date' : undefined, dayInNexOrPrevMonth: day.getUTCMonth() !== current.getUTCMonth(), "aria-label": toUTCDateString(day, Intl.DateTimeFormat(locale, ariaOpts)), onMouseOver: showHighlight ? () => setHighlightBoundary(day) : undefined, onMouseOut: showHighlight ? () => setHighlightBoundary(undefined) : undefined, onMouseDown: () => {
|
|
105
104
|
setFocusedDay(day);
|
|
106
105
|
onFocus?.(day);
|
|
107
106
|
onSelect?.(day);
|
|
@@ -117,12 +116,7 @@ const Calendar = forwardRef(({ selected, current = selected ? new Date(selected.
|
|
|
117
116
|
const dateOfISOWeek = getDateOfISOWeek(weekNo, current.getUTCFullYear());
|
|
118
117
|
const lastDayOfWeek = new Date(dateOfISOWeek);
|
|
119
118
|
lastDayOfWeek.setDate(dateOfISOWeek.getDate() + 6);
|
|
120
|
-
return (_jsxs(StyledPick, {
|
|
121
|
-
? (focusedRef) => {
|
|
122
|
-
if (hasFocus)
|
|
123
|
-
focusedRef?.focus();
|
|
124
|
-
}
|
|
125
|
-
: undefined, tabIndex: isWeekFocused(dateOfISOWeek) ? 0 : -1, disabled: disabled || mode === 'date' || isDisabled(dateOfISOWeek), "aria-selected": isWeekSelected(dateOfISOWeek) || undefined, "aria-label": `${t('week_label_a11y')} ${weekNo.toString()} ${toUTCDateString(dateOfISOWeek, Intl.DateTimeFormat(locale, ariaOpts))} - ${toUTCDateString(lastDayOfWeek, Intl.DateTimeFormat(locale, ariaOpts))}`, "aria-current": isWeekFocused(dateOfISOWeek) ? 'date' : undefined, onMouseDown: () => {
|
|
119
|
+
return (_jsxs(StyledPick, { tabIndex: isWeekFocused(dateOfISOWeek) ? 0 : -1, disabled: disabled || mode === 'date' || isDisabled(dateOfISOWeek), "aria-selected": isWeekSelected(dateOfISOWeek) || undefined, "aria-label": `${t('week_label_a11y')} ${weekNo.toString()} ${toUTCDateString(dateOfISOWeek, Intl.DateTimeFormat(locale, ariaOpts))} - ${toUTCDateString(lastDayOfWeek, Intl.DateTimeFormat(locale, ariaOpts))}`, "aria-current": isWeekFocused(dateOfISOWeek) ? 'date' : undefined, onMouseDown: () => {
|
|
126
120
|
setFocusedDay(dateOfISOWeek);
|
|
127
121
|
onFocus?.(dateOfISOWeek);
|
|
128
122
|
onSelect?.(dateOfISOWeek);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.js","sourceRoot":"","sources":["../../../../src/components/DateTime/Picker/Calendar.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,OAAO,EAGP,QAAQ,EACR,UAAU,EAGV,SAAS,EACT,WAAW,EACZ,MAAM,OAAO,CAAC;AAEf,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,OAAO,EACP,WAAW,EACX,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAI/F,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AA0C3B,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Component,\n KeyboardEvent,\n useState,\n forwardRef,\n PropsWithoutRef,\n Ref,\n useEffect,\n useCallback\n} from 'react';\n\nimport Text from '../../Text';\nimport { CALENDAR_TYPES } from '../Input/local';\nimport {\n getCalendarTypeFromLocale,\n getDateOfISOWeek,\n getWeek,\n parseToDate,\n toUTCDateString\n} from '../Input/utils';\nimport { useConfiguration, useConsolidatedRef, useFocusWithin, useI18n } from '../../../hooks';\nimport { ForwardProps } from '../../../types';\nimport { FormControlProps } from '../../FormControl';\n\nimport { getDaysOfMonth, getLocalizedDays, getWeeksOfMonth } from './utils';\nimport {\n StyledColumnLabel,\n ScreenReaderOnly,\n StyledPick,\n StyledDay,\n StyledCalendar,\n StyledWeekGrid,\n StyledWeekLabel,\n StyledWeekNumber\n} from './Calendar.styles';\n\nexport interface CalendarProps {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /**\n * Defines default date that will be selected initially when the Calendar is visible.\n */\n selected?: Date;\n /**\n * Defines currently visible month.\n * @default new Date()\n */\n current?: Date;\n /** Defines dates range with start date and end date that can be set by the user. */\n selectedRange?: { startDate: Date | undefined; endDate: Date | undefined };\n /** Defines if days should be highlighted for range selection */\n showHighlight?: boolean;\n /** Defines if week numbers should be displayed in calendar */\n showWeekNumber?: boolean;\n /**\n * The mode of the calendar that will be rendered, ie. whether single date or week are selectable.\n * @default \"date\"\n */\n mode?: 'date' | 'week';\n /** Callback fired when new day is selected. */\n onSelect?: (date: Date) => void;\n /** Callback fired when user focuses new day. */\n onFocus?: (date: Date) => void;\n /** Sets the type of calendar to be used. This will be determined by locale if no value is provided. */\n calendarType?: string;\n /** Defines minimum available value that can be selected by the user. */\n min?: string | number | Date;\n /** Defines maximum available value that can be selected by the user. */\n max?: string | number | Date;\n /** Set the calendar to disabled state, ie. non-interactive. */\n disabled?: boolean;\n}\n\nconst ariaOpts = { day: 'numeric', month: 'long', year: 'numeric' } as const;\n\nconst Calendar: FunctionComponent<CalendarProps & ForwardProps> = forwardRef(\n (\n {\n selected,\n current = selected ? new Date(selected.getTime()) : new Date(),\n selectedRange,\n showHighlight,\n mode = 'date',\n showWeekNumber,\n calendarType: calendar = CALENDAR_TYPES.ISO_8601,\n onSelect,\n onFocus,\n disabled,\n min: minProp,\n max: maxProp\n }: PropsWithoutRef<CalendarProps>,\n ref: Ref<HTMLTableElement>\n ) => {\n const { locale } = useConfiguration();\n const min = minProp ? parseToDate(minProp) : -Infinity;\n const max = maxProp ? parseToDate(maxProp) : Infinity;\n\n const showWeekLabel = mode === 'week' ? false : showWeekNumber;\n const [focusedDay, setFocusedDay] = useState(current);\n useEffect(() => {\n setFocusedDay(current);\n }, [current.getUTCFullYear(), current.getUTCMonth()]);\n\n const calendarType = useMemo(\n () => calendar ?? getCalendarTypeFromLocale(locale),\n [locale, calendar]\n );\n\n const [highlightBoundary, setHighlightBoundary] = useState<Date>();\n\n const onKeyDown = useCallback(\n (e: KeyboardEvent<HTMLElement>) => {\n if (\n (mode === 'date'\n ? ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']\n : ['ArrowUp', 'ArrowDown']\n ).includes(e.key)\n ) {\n e.preventDefault();\n const newFocused = new Date(focusedDay);\n switch (e.key) {\n case 'ArrowUp':\n newFocused.setUTCDate(focusedDay.getUTCDate() - 7);\n break;\n case 'ArrowDown':\n newFocused.setUTCDate(focusedDay.getUTCDate() + 7);\n break;\n case 'ArrowRight':\n newFocused.setUTCDate(focusedDay.getUTCDate() + 1);\n break;\n case 'ArrowLeft':\n newFocused.setUTCDate(focusedDay.getUTCDate() - 1);\n break;\n default:\n }\n if (newFocused < min || newFocused > max) return;\n setFocusedDay(newFocused);\n onFocus?.(newFocused);\n setHighlightBoundary(newFocused);\n }\n if (e.key === 'Enter') {\n e.preventDefault();\n onSelect?.(focusedDay);\n }\n },\n [mode, focusedDay, onFocus, onSelect]\n );\n\n const containerRef = useConsolidatedRef<HTMLTableElement>(ref);\n const hasFocus = useFocusWithin([containerRef]);\n\n const today = toUTCDateString(new Date());\n\n const isDisabled = (day: Date) => {\n return min > day.getTime() || day.getTime() > max;\n };\n\n const isSelected = (day: Date) => {\n return [\n selected && toUTCDateString(selected),\n selectedRange?.startDate && toUTCDateString(selectedRange?.startDate),\n selectedRange?.endDate && toUTCDateString(selectedRange?.endDate)\n ].includes(toUTCDateString(day));\n };\n\n const isWeekSelected = (day: Date) => {\n return (\n selected &&\n toUTCDateString(day) ===\n toUTCDateString(getDateOfISOWeek(getWeek(selected, calendarType), selected.getFullYear()))\n );\n };\n\n const isFocused = (day: Date) => {\n return toUTCDateString(day) === toUTCDateString(focusedDay);\n };\n\n const isWeekFocused = (day: Date) => {\n return (\n toUTCDateString(day) ===\n toUTCDateString(\n getDateOfISOWeek(getWeek(focusedDay, calendarType), focusedDay.getFullYear())\n )\n );\n };\n\n const isInRange = (day: Date) => {\n return (\n selectedRange &&\n selectedRange.startDate &&\n selectedRange.endDate &&\n day >= selectedRange.startDate &&\n day <= selectedRange.endDate\n );\n };\n\n const isHighlighted = (day: Date) => {\n if (!selectedRange || !showHighlight || !highlightBoundary) return false;\n const betweenHighlightAndBoundary = (rangeBoundaryType: 'startDate' | 'endDate') => {\n const rangeBoundary = selectedRange[rangeBoundaryType];\n if (!rangeBoundary) return false;\n return !!(\n rangeBoundary &&\n ((day >= rangeBoundary && day <= highlightBoundary) ||\n (day <= rangeBoundary && day >= highlightBoundary))\n );\n };\n return betweenHighlightAndBoundary('startDate') || betweenHighlightAndBoundary('endDate');\n };\n\n const days = getDaysOfMonth(current, calendarType ?? CALENDAR_TYPES.ISO_8601).map(day => {\n return (\n <StyledDay\n key={day.getTime()}\n variant='simple'\n icon={false}\n type='button'\n loading={false}\n ref={\n isFocused(day)\n ? (focusedRef: HTMLButtonElement) => {\n if (hasFocus) focusedRef?.focus();\n }\n : undefined\n }\n tabIndex={isFocused(day) ? 0 : -1}\n disabled={disabled || mode === 'week' || isDisabled(day)}\n current={toUTCDateString(day) === today}\n highlighted={isInRange(day) || isHighlighted(day)}\n aria-selected={isSelected(day) || undefined}\n aria-current={isSelected(day) ? 'date' : undefined}\n dayInNexOrPrevMonth={day.getUTCMonth() !== current.getUTCMonth()}\n aria-label={toUTCDateString(day, Intl.DateTimeFormat(locale, ariaOpts))}\n onMouseOver={showHighlight ? () => setHighlightBoundary(day) : undefined}\n onMouseOut={showHighlight ? () => setHighlightBoundary(undefined) : undefined}\n onMouseDown={() => {\n setFocusedDay(day);\n onFocus?.(day);\n onSelect?.(day);\n }}\n >\n {day.getUTCDate()}\n </StyledDay>\n );\n });\n\n const names = useMemo(() => getLocalizedDays(calendarType, locale), [locale, calendarType]);\n\n const t = useI18n();\n\n const weekText = t('week_label_a11y');\n\n const weeks = getWeeksOfMonth(current, calendarType).map(weekNo => {\n return (\n <>\n <Text as={StyledWeekNumber} key={weekNo} aria-hidden='true'>\n {weekNo.toString()}\n </Text>\n <ScreenReaderOnly>\n {`${weekText} ${weekNo.toString()} ${current.getUTCFullYear().toString()}`}\n </ScreenReaderOnly>\n </>\n );\n });\n\n const weeksButtons = getWeeksOfMonth(current, calendarType).map(weekNo => {\n const dateOfISOWeek = getDateOfISOWeek(weekNo, current.getUTCFullYear());\n const lastDayOfWeek = new Date(dateOfISOWeek);\n lastDayOfWeek.setDate(dateOfISOWeek.getDate() + 6);\n return (\n <StyledPick\n key={weekNo}\n variant='simple'\n icon={false}\n type='button'\n loading={false}\n ref={\n isWeekFocused(dateOfISOWeek)\n ? (focusedRef: HTMLButtonElement) => {\n if (hasFocus) focusedRef?.focus();\n }\n : undefined\n }\n tabIndex={isWeekFocused(dateOfISOWeek) ? 0 : -1}\n disabled={disabled || mode === 'date' || isDisabled(dateOfISOWeek)}\n aria-selected={isWeekSelected(dateOfISOWeek) || undefined}\n aria-label={`${t('week_label_a11y')} ${weekNo.toString()} ${toUTCDateString(\n dateOfISOWeek,\n Intl.DateTimeFormat(locale, ariaOpts)\n )} - ${toUTCDateString(lastDayOfWeek, Intl.DateTimeFormat(locale, ariaOpts))}`}\n aria-current={isWeekFocused(dateOfISOWeek) ? 'date' : undefined}\n onMouseDown={() => {\n setFocusedDay(dateOfISOWeek);\n onFocus?.(dateOfISOWeek);\n onSelect?.(dateOfISOWeek);\n }}\n >\n {`${weekText} `}\n {weekNo.toString()}\n </StyledPick>\n );\n });\n\n const weekLabel =\n mode === 'date' ? (\n <>\n <Text as={StyledWeekLabel} forwardedAs='abbr' title={weekText} aria-hidden='true'>\n {t('week_text_short')}\n </Text>\n <ScreenReaderOnly>{weekText}</ScreenReaderOnly>\n </>\n ) : (\n <Text as={StyledWeekLabel}>{weekText}</Text>\n );\n\n const headerLabels = names.map(([name, abbr]) => (\n <th role='columnheader' key={name}>\n <Text as={StyledColumnLabel} forwardedAs='abbr' key={name} title={name} aria-hidden='true'>\n {abbr}\n </Text>\n <ScreenReaderOnly>{name}</ScreenReaderOnly>\n </th>\n ));\n\n const splitToWeeks = (resultArray: JSX.Element[][], item: JSX.Element, index: number) => {\n const chunkIndex = Math.floor(index / 7);\n\n if (!resultArray[chunkIndex]) {\n resultArray[chunkIndex] = [] as JSX.Element[];\n }\n\n resultArray[chunkIndex].push(item);\n return resultArray;\n };\n\n const cells = days.reduce(splitToWeeks, []).map((week, index) => {\n const rowHeader = mode === 'week' ? weeksButtons[index] : weeks[index];\n return (\n // eslint-disable-next-line react/no-array-index-key\n <tr key={`week-${index}`}>\n {showWeekLabel && <th scope='row'>{rowHeader}</th>}\n {week.map((day, dayIndex) => {\n // eslint-disable-next-line react/no-array-index-key\n return <td key={`day-${dayIndex}`}>{day}</td>;\n })}\n </tr>\n );\n });\n\n const weeksCells = weeksButtons.map((week, index) => {\n return (\n // eslint-disable-next-line react/no-array-index-key\n <tr key={`week-${index}`}>\n <td>{week}</td>\n </tr>\n );\n });\n\n const weeksGrid = (\n <StyledWeekGrid role='grid' onKeyDown={onKeyDown} ref={containerRef}>\n <thead>\n <tr>\n <th>{weekLabel}</th>\n </tr>\n </thead>\n <tbody>{weeksCells}</tbody>\n </StyledWeekGrid>\n );\n\n return (\n <>\n {mode === 'week' && weeksGrid}\n <StyledCalendar\n ref={mode === 'date' ? containerRef : undefined}\n aria-label={current.toLocaleString(locale, {\n month: 'long',\n year: 'numeric',\n timeZone: 'UTC'\n })}\n onKeyDown={onKeyDown}\n aria-hidden={mode === 'week' ? true : undefined}\n role='grid'\n >\n <thead>\n <tr>\n {showWeekLabel && <th>{weekLabel}</th>}\n {headerLabels}\n </tr>\n </thead>\n <tbody>{cells}</tbody>\n </StyledCalendar>\n <ScreenReaderOnly aria-live='polite' role='alert'>\n {t('calendar_assist')}\n </ScreenReaderOnly>\n </>\n );\n }\n);\n\nexport default Calendar;\n"]}
|
|
1
|
+
{"version":3,"file":"Calendar.js","sourceRoot":"","sources":["../../../../src/components/DateTime/Picker/Calendar.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,OAAO,EAGP,QAAQ,EACR,UAAU,EAGV,SAAS,EACT,WAAW,EACZ,MAAM,OAAO,CAAC;AAEf,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,OAAO,EACP,WAAW,EACX,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAI/F,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AA0C3B,MAAM,QAAQ,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS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,uBACE,uBAAK,SAAS,GAAM,GACjB,GACC,EACR,0BAAQ,UAAU,GAAS,IACZ,CAClB,CAAC;IAEF,OAAO,CACL,8BACG,IAAI,KAAK,MAAM,IAAI,SAAS,EAC7B,MAAC,cAAc,IACb,GAAG,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,gBACnC,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE;oBACzC,KAAK,EAAE,MAAM;oBACb,IAAI,EAAE,SAAS;oBACf,QAAQ,EAAE,KAAK;iBAChB,CAAC,EACF,SAAS,EAAE,SAAS,iBACP,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EAC/C,IAAI,EAAC,MAAM,aAEX,0BACE,yBACG,aAAa,IAAI,uBAAK,SAAS,GAAM,EACrC,YAAY,IACV,GACC,EACR,0BAAQ,KAAK,GAAS,IACP,EACjB,KAAC,gBAAgB,iBAAW,QAAQ,EAAC,IAAI,EAAC,OAAO,YAC9C,CAAC,CAAC,iBAAiB,CAAC,GACJ,IAClB,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import {\n useMemo,\n FunctionComponent,\n KeyboardEvent,\n useState,\n forwardRef,\n PropsWithoutRef,\n Ref,\n useEffect,\n useCallback\n} from 'react';\n\nimport Text from '../../Text';\nimport { CALENDAR_TYPES } from '../Input/local';\nimport {\n getCalendarTypeFromLocale,\n getDateOfISOWeek,\n getWeek,\n parseToDate,\n toUTCDateString\n} from '../Input/utils';\nimport { useConfiguration, useConsolidatedRef, useFocusWithin, useI18n } from '../../../hooks';\nimport { ForwardProps } from '../../../types';\nimport { FormControlProps } from '../../FormControl';\n\nimport { getDaysOfMonth, getLocalizedDays, getWeeksOfMonth } from './utils';\nimport {\n StyledColumnLabel,\n ScreenReaderOnly,\n StyledPick,\n StyledDay,\n StyledCalendar,\n StyledWeekGrid,\n StyledWeekLabel,\n StyledWeekNumber\n} from './Calendar.styles';\n\nexport interface CalendarProps {\n /**\n * Sets DOM id for the control and associates label element via 'for' attribute.\n * If an id is not pass, a random id will be generated for any render.\n */\n id?: FormControlProps['id'];\n /**\n * Defines default date that will be selected initially when the Calendar is visible.\n */\n selected?: Date;\n /**\n * Defines currently visible month.\n * @default new Date()\n */\n current?: Date;\n /** Defines dates range with start date and end date that can be set by the user. */\n selectedRange?: { startDate: Date | undefined; endDate: Date | undefined };\n /** Defines if days should be highlighted for range selection */\n showHighlight?: boolean;\n /** Defines if week numbers should be displayed in calendar */\n showWeekNumber?: boolean;\n /**\n * The mode of the calendar that will be rendered, ie. whether single date or week are selectable.\n * @default \"date\"\n */\n mode?: 'date' | 'week';\n /** Callback fired when new day is selected. */\n onSelect?: (date: Date) => void;\n /** Callback fired when user focuses new day. */\n onFocus?: (date: Date) => void;\n /** Sets the type of calendar to be used. This will be determined by locale if no value is provided. */\n calendarType?: string;\n /** Defines minimum available value that can be selected by the user. */\n min?: string | number | Date;\n /** Defines maximum available value that can be selected by the user. */\n max?: string | number | Date;\n /** Set the calendar to disabled state, ie. non-interactive. */\n disabled?: boolean;\n}\n\nconst ariaOpts = { day: 'numeric', month: 'long', year: 'numeric' } as const;\n\nconst Calendar: FunctionComponent<CalendarProps & ForwardProps> = forwardRef(\n (\n {\n selected,\n current = selected ? new Date(selected.getTime()) : new Date(),\n selectedRange,\n showHighlight,\n mode = 'date',\n showWeekNumber,\n calendarType: calendar = CALENDAR_TYPES.ISO_8601,\n onSelect,\n onFocus,\n disabled,\n min: minProp,\n max: maxProp\n }: PropsWithoutRef<CalendarProps>,\n ref: Ref<HTMLTableElement>\n ) => {\n const { locale } = useConfiguration();\n const min = minProp ? parseToDate(minProp) : -Infinity;\n const max = maxProp ? parseToDate(maxProp) : Infinity;\n\n const showWeekLabel = mode === 'week' ? false : showWeekNumber;\n const [focusedDay, setFocusedDay] = useState(current);\n useEffect(() => {\n setFocusedDay(current);\n }, [current.getUTCFullYear(), current.getUTCMonth()]);\n\n const calendarType = useMemo(\n () => calendar ?? getCalendarTypeFromLocale(locale),\n [locale, calendar]\n );\n\n const [highlightBoundary, setHighlightBoundary] = useState<Date>();\n\n const onKeyDown = useCallback(\n (e: KeyboardEvent<HTMLElement>) => {\n if (\n (mode === 'date'\n ? ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']\n : ['ArrowUp', 'ArrowDown']\n ).includes(e.key)\n ) {\n e.preventDefault();\n const newFocused = new Date(focusedDay);\n switch (e.key) {\n case 'ArrowUp':\n newFocused.setUTCDate(focusedDay.getUTCDate() - 7);\n break;\n case 'ArrowDown':\n newFocused.setUTCDate(focusedDay.getUTCDate() + 7);\n break;\n case 'ArrowRight':\n newFocused.setUTCDate(focusedDay.getUTCDate() + 1);\n break;\n case 'ArrowLeft':\n newFocused.setUTCDate(focusedDay.getUTCDate() - 1);\n break;\n default:\n }\n if (newFocused < min || newFocused > max) return;\n setFocusedDay(newFocused);\n onFocus?.(newFocused);\n setHighlightBoundary(newFocused);\n }\n if (e.key === 'Enter') {\n e.preventDefault();\n onSelect?.(focusedDay);\n }\n },\n [mode, focusedDay, onFocus, onSelect]\n );\n\n const containerRef = useConsolidatedRef<HTMLTableElement>(ref);\n const hasFocus = useFocusWithin([containerRef]);\n\n const today = toUTCDateString(new Date());\n\n const isDisabled = (day: Date) => {\n return min > day.getTime() || day.getTime() > max;\n };\n\n const isSelected = (day: Date) => {\n return [\n selected && toUTCDateString(selected),\n selectedRange?.startDate && toUTCDateString(selectedRange?.startDate),\n selectedRange?.endDate && toUTCDateString(selectedRange?.endDate)\n ].includes(toUTCDateString(day));\n };\n\n const isWeekSelected = (day: Date) => {\n return (\n selected &&\n toUTCDateString(day) ===\n toUTCDateString(getDateOfISOWeek(getWeek(selected, calendarType), selected.getFullYear()))\n );\n };\n\n const isFocused = (day: Date) => {\n return toUTCDateString(day) === toUTCDateString(focusedDay);\n };\n\n const isWeekFocused = (day: Date) => {\n return (\n toUTCDateString(day) ===\n toUTCDateString(\n getDateOfISOWeek(getWeek(focusedDay, calendarType), focusedDay.getFullYear())\n )\n );\n };\n\n const isInRange = (day: Date) => {\n return (\n selectedRange &&\n selectedRange.startDate &&\n selectedRange.endDate &&\n day >= selectedRange.startDate &&\n day <= selectedRange.endDate\n );\n };\n\n const isHighlighted = (day: Date) => {\n if (!selectedRange || !showHighlight || !highlightBoundary) return false;\n const betweenHighlightAndBoundary = (rangeBoundaryType: 'startDate' | 'endDate') => {\n const rangeBoundary = selectedRange[rangeBoundaryType];\n if (!rangeBoundary) return false;\n return !!(\n rangeBoundary &&\n ((day >= rangeBoundary && day <= highlightBoundary) ||\n (day <= rangeBoundary && day >= highlightBoundary))\n );\n };\n return betweenHighlightAndBoundary('startDate') || betweenHighlightAndBoundary('endDate');\n };\n\n useEffect(() => {\n if (hasFocus)\n containerRef.current?.querySelector<HTMLButtonElement>('button[tabindex=\"0\"]')?.focus();\n }, [hasFocus, focusedDay]);\n\n const days = getDaysOfMonth(current, calendarType ?? CALENDAR_TYPES.ISO_8601).map(day => {\n return (\n <StyledDay\n key={day.getTime()}\n tabIndex={isFocused(day) ? 0 : -1}\n disabled={disabled || mode === 'week' || isDisabled(day)}\n current={toUTCDateString(day) === today}\n highlighted={isInRange(day) || isHighlighted(day)}\n aria-selected={isSelected(day) || undefined}\n aria-current={isSelected(day) ? 'date' : undefined}\n dayInNexOrPrevMonth={day.getUTCMonth() !== current.getUTCMonth()}\n aria-label={toUTCDateString(day, Intl.DateTimeFormat(locale, ariaOpts))}\n onMouseOver={showHighlight ? () => setHighlightBoundary(day) : undefined}\n onMouseOut={showHighlight ? () => setHighlightBoundary(undefined) : undefined}\n onMouseDown={() => {\n setFocusedDay(day);\n onFocus?.(day);\n onSelect?.(day);\n }}\n >\n {day.getUTCDate()}\n </StyledDay>\n );\n });\n\n const names = useMemo(() => getLocalizedDays(calendarType, locale), [locale, calendarType]);\n\n const t = useI18n();\n\n const weekText = t('week_label_a11y');\n\n const weeks = getWeeksOfMonth(current, calendarType).map(weekNo => {\n return (\n <>\n <Text as={StyledWeekNumber} key={weekNo} aria-hidden='true'>\n {weekNo.toString()}\n </Text>\n <ScreenReaderOnly>\n {`${weekText} ${weekNo.toString()} ${current.getUTCFullYear().toString()}`}\n </ScreenReaderOnly>\n </>\n );\n });\n\n const weeksButtons = getWeeksOfMonth(current, calendarType).map(weekNo => {\n const dateOfISOWeek = getDateOfISOWeek(weekNo, current.getUTCFullYear());\n const lastDayOfWeek = new Date(dateOfISOWeek);\n lastDayOfWeek.setDate(dateOfISOWeek.getDate() + 6);\n return (\n <StyledPick\n key={weekNo}\n tabIndex={isWeekFocused(dateOfISOWeek) ? 0 : -1}\n disabled={disabled || mode === 'date' || isDisabled(dateOfISOWeek)}\n aria-selected={isWeekSelected(dateOfISOWeek) || undefined}\n aria-label={`${t('week_label_a11y')} ${weekNo.toString()} ${toUTCDateString(\n dateOfISOWeek,\n Intl.DateTimeFormat(locale, ariaOpts)\n )} - ${toUTCDateString(lastDayOfWeek, Intl.DateTimeFormat(locale, ariaOpts))}`}\n aria-current={isWeekFocused(dateOfISOWeek) ? 'date' : undefined}\n onMouseDown={() => {\n setFocusedDay(dateOfISOWeek);\n onFocus?.(dateOfISOWeek);\n onSelect?.(dateOfISOWeek);\n }}\n >\n {`${weekText} `}\n {weekNo.toString()}\n </StyledPick>\n );\n });\n\n const weekLabel =\n mode === 'date' ? (\n <>\n <Text as={StyledWeekLabel} forwardedAs='abbr' title={weekText} aria-hidden='true'>\n {t('week_text_short')}\n </Text>\n <ScreenReaderOnly>{weekText}</ScreenReaderOnly>\n </>\n ) : (\n <Text as={StyledWeekLabel}>{weekText}</Text>\n );\n\n const headerLabels = names.map(([name, abbr]) => (\n <th role='columnheader' key={name}>\n <Text as={StyledColumnLabel} forwardedAs='abbr' key={name} title={name} aria-hidden='true'>\n {abbr}\n </Text>\n <ScreenReaderOnly>{name}</ScreenReaderOnly>\n </th>\n ));\n\n const splitToWeeks = (resultArray: JSX.Element[][], item: JSX.Element, index: number) => {\n const chunkIndex = Math.floor(index / 7);\n\n if (!resultArray[chunkIndex]) {\n resultArray[chunkIndex] = [] as JSX.Element[];\n }\n\n resultArray[chunkIndex].push(item);\n return resultArray;\n };\n\n const cells = days.reduce(splitToWeeks, []).map((week, index) => {\n const rowHeader = mode === 'week' ? weeksButtons[index] : weeks[index];\n return (\n // eslint-disable-next-line react/no-array-index-key\n <tr key={`week-${index}`}>\n {showWeekLabel && <th scope='row'>{rowHeader}</th>}\n {week.map((day, dayIndex) => {\n // eslint-disable-next-line react/no-array-index-key\n return <td key={`day-${dayIndex}`}>{day}</td>;\n })}\n </tr>\n );\n });\n\n const weeksCells = weeksButtons.map((week, index) => {\n return (\n // eslint-disable-next-line react/no-array-index-key\n <tr key={`week-${index}`}>\n <td>{week}</td>\n </tr>\n );\n });\n\n const weeksGrid = (\n <StyledWeekGrid role='grid' onKeyDown={onKeyDown} ref={containerRef}>\n <thead>\n <tr>\n <th>{weekLabel}</th>\n </tr>\n </thead>\n <tbody>{weeksCells}</tbody>\n </StyledWeekGrid>\n );\n\n return (\n <>\n {mode === 'week' && weeksGrid}\n <StyledCalendar\n ref={mode === 'date' ? containerRef : undefined}\n aria-label={current.toLocaleString(locale, {\n month: 'long',\n year: 'numeric',\n timeZone: 'UTC'\n })}\n onKeyDown={onKeyDown}\n aria-hidden={mode === 'week' ? true : undefined}\n role='grid'\n >\n <thead>\n <tr>\n {showWeekLabel && <th>{weekLabel}</th>}\n {headerLabels}\n </tr>\n </thead>\n <tbody>{cells}</tbody>\n </StyledCalendar>\n <ScreenReaderOnly aria-live='polite' role='alert'>\n {t('calendar_assist')}\n </ScreenReaderOnly>\n </>\n );\n }\n);\n\nexport default Calendar;\n"]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
export declare const StyledPick: import("styled-components").StyledComponent<
|
|
2
|
-
export declare const StyledMonthPicker: import("styled-components").StyledComponent<"fieldset", import("styled-components").DefaultTheme, {}, never>;
|
|
3
|
-
export declare const StyledDatePicker: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
1
|
+
export declare const StyledPick: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../../Button").ButtonProps & import("../../..").ForwardProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
4
2
|
export declare const StyledColumnLabel: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
|
|
5
3
|
export declare const ScreenReaderOnly: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
|
|
6
|
-
export declare const StyledDay: import("styled-components").StyledComponent<
|
|
4
|
+
export declare const StyledDay: import("styled-components").StyledComponent<import("react").FunctionComponent<import("../../Button").ButtonProps & import("../../..").ForwardProps>, import("styled-components").DefaultTheme, {
|
|
7
5
|
current: boolean;
|
|
8
6
|
highlighted: boolean;
|
|
9
7
|
dayInNexOrPrevMonth: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/DateTime/Picker/Calendar.styles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Calendar.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/DateTime/Picker/Calendar.styles.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,UAAU,2MAiCrB,CAAC;AAIH,eAAO,MAAM,iBAAiB,0GAI7B,CAAC;AAIF,eAAO,MAAM,gBAAgB,0GAE5B,CAAC;AAEF,eAAO,MAAM,SAAS;aACX,OAAO;iBACH,OAAO;yBACC,OAAO;SAkC5B,CAAC;AAIH,eAAO,MAAM,eAAe,0GAc1B,CAAC;AAIH,eAAO,MAAM,gBAAgB,0GA8B3B,CAAC;AAIH,eAAO,MAAM,cAAc,2GAoBzB,CAAC;AAIH,eAAO,MAAM,cAAc,2GA2CzB,CAAC"}
|
|
@@ -1,72 +1,30 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
|
-
import { hideVisually, rgba } from 'polished';
|
|
2
|
+
import { hideVisually, mix, readableColor, rgba, transparentize } from 'polished';
|
|
3
3
|
import { defaultThemeProp } from '../../../theme';
|
|
4
|
-
import { StyledSelect } from '../../Select/Select';
|
|
5
|
-
import { StyledButton } from '../../Button';
|
|
6
4
|
import { tryCatch } from '../../../utils';
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import Button from '../../Button';
|
|
6
|
+
export const StyledPick = styled(Button)(props => {
|
|
7
|
+
const { theme: { base: { 'border-radius': borderRadius, palette: { interactive, dark }, spacing }, components: { card: { background } } } } = props;
|
|
8
|
+
const textColor = tryCatch(() => readableColor(interactive));
|
|
9
|
+
const disabledBackground = tryCatch(() => transparentize(0.5, mix(0.8, background, dark)));
|
|
9
10
|
return css `
|
|
10
11
|
height: 2.625rem;
|
|
11
12
|
border-radius: calc(0.5 * ${borderRadius});
|
|
12
13
|
padding: 0 ${spacing};
|
|
13
14
|
background-color: transparent;
|
|
14
15
|
|
|
15
|
-
& + & {
|
|
16
|
-
margin-inline-start: 0;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
16
|
&[aria-selected]:enabled {
|
|
20
17
|
background-color: ${interactive};
|
|
21
|
-
color: ${
|
|
18
|
+
color: ${textColor};
|
|
22
19
|
}
|
|
23
20
|
|
|
24
21
|
&:disabled {
|
|
25
|
-
background-color: ${
|
|
22
|
+
background-color: ${disabledBackground};
|
|
26
23
|
border-radius: 0;
|
|
27
24
|
}
|
|
28
|
-
|
|
29
|
-
&:focus {
|
|
30
|
-
outline: none;
|
|
31
|
-
box-shadow: inset 0 0 0 0.125rem ${colors.blue.light};
|
|
32
|
-
}
|
|
33
25
|
`;
|
|
34
26
|
});
|
|
35
27
|
StyledPick.defaultProps = defaultThemeProp;
|
|
36
|
-
export const StyledMonthPicker = styled.fieldset(props => {
|
|
37
|
-
const { theme: { base: { spacing, 'border-radius': baseBorderRadius, palette: { 'foreground-color': color } }, components: { 'form-control': formControl } } } = props;
|
|
38
|
-
return css `
|
|
39
|
-
margin: calc(2 * ${spacing}) calc(0.5 * ${spacing});
|
|
40
|
-
font-size: 0.875rem;
|
|
41
|
-
border: none;
|
|
42
|
-
|
|
43
|
-
${StyledSelect} {
|
|
44
|
-
border-radius: calc(${baseBorderRadius} * ${formControl['border-radius']});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
${StyledButton} {
|
|
48
|
-
border-radius: calc(${baseBorderRadius} * ${formControl['border-radius']});
|
|
49
|
-
border: 0;
|
|
50
|
-
&:enabled {
|
|
51
|
-
color: ${color};
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
`;
|
|
55
|
-
});
|
|
56
|
-
StyledMonthPicker.defaultProps = defaultThemeProp;
|
|
57
|
-
export const StyledDatePicker = styled.div(props => {
|
|
58
|
-
const { theme: { base: { spacing }, components: { 'form-control': { 'foreground-color': foreground } } } } = props;
|
|
59
|
-
return css `
|
|
60
|
-
width: max-content;
|
|
61
|
-
|
|
62
|
-
${StyledButton} {
|
|
63
|
-
border: transparent;
|
|
64
|
-
color: ${foreground};
|
|
65
|
-
}
|
|
66
|
-
padding: 0 ${spacing} ${spacing} ${spacing};
|
|
67
|
-
`;
|
|
68
|
-
});
|
|
69
|
-
StyledDatePicker.defaultProps = defaultThemeProp;
|
|
70
28
|
export const StyledColumnLabel = styled.span `
|
|
71
29
|
text-align: center;
|
|
72
30
|
margin: 0 auto;
|
|
@@ -77,7 +35,7 @@ export const ScreenReaderOnly = styled.span `
|
|
|
77
35
|
${hideVisually}
|
|
78
36
|
`;
|
|
79
37
|
export const StyledDay = styled(StyledPick)(props => {
|
|
80
|
-
const { theme: { base: {
|
|
38
|
+
const { theme: { base: { palette: { interactive }, 'disabled-opacity': disabledOpacity } }, current, highlighted, dayInNexOrPrevMonth } = props;
|
|
81
39
|
const highlightedBgColor = tryCatch(() => rgba(interactive, 0.1));
|
|
82
40
|
return css `
|
|
83
41
|
background-color: ${highlighted ? highlightedBgColor : 'transparent'};
|
|
@@ -94,7 +52,6 @@ export const StyledDay = styled(StyledPick)(props => {
|
|
|
94
52
|
|
|
95
53
|
${current &&
|
|
96
54
|
css `
|
|
97
|
-
color: ${colors.slate.dark};
|
|
98
55
|
font-weight: bold;
|
|
99
56
|
`}
|
|
100
57
|
`;
|
|
@@ -112,12 +69,13 @@ export const StyledWeekLabel = styled(StyledColumnLabel)(props => {
|
|
|
112
69
|
});
|
|
113
70
|
StyledWeekLabel.defaultProps = defaultThemeProp;
|
|
114
71
|
export const StyledWeekNumber = styled.span(props => {
|
|
115
|
-
const { theme: { base: { breakpoints, spacing,
|
|
72
|
+
const { theme: { base: { breakpoints, spacing, 'disabled-opacity': disabledOpacity, palette: { dark } }, components: { card: { background: cardBackground } } } } = props;
|
|
73
|
+
const background = tryCatch(() => transparentize(0.5, mix(0.8, cardBackground, dark)));
|
|
116
74
|
return css `
|
|
117
75
|
line-height: 2.625rem;
|
|
118
76
|
padding: 0;
|
|
119
77
|
margin-inline-end: 0;
|
|
120
|
-
background-color: ${
|
|
78
|
+
background-color: ${background};
|
|
121
79
|
display: inline-block;
|
|
122
80
|
opacity: ${disabledOpacity};
|
|
123
81
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.styles.js","sourceRoot":"","sources":["../../../../src/components/DateTime/Picker/Calendar.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"Calendar.styles.js","sourceRoot":"","sources":["../../../../src/components/DateTime/Picker/Calendar.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAElF,OAAO,EAAE,gBAAgB,EAAE,MAA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,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAEvF,OAAO,GAAG,CAAA;;;;wBAIY,UAAU;;eAEnB,eAAe;;yBAEL,WAAW,CAAC,EAAE;mBACpB,OAAO;2BACC,OAAO;;GAE/B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAEjD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;IACjD,MAAM,EACJ,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,OAAO,EAAE,EAClB,EACF,GAAG,KAAK,CAAC;IACV,OAAO,GAAG,CAAA;;;;;;;0BAOc,OAAO;;;MAG3B,UAAU;2BACW,OAAO;;GAE/B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE/C,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;IACjD,MAAM,EACJ,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,eAAe,EAAE,YAAY,EAAE,OAAO,EAAE,EACjD,EACF,GAAG,KAAK,CAAC;IACV,OAAO,GAAG,CAAA;;;;;;;;;;;0BAWc,OAAO;;;;;;;;QAQzB,SAAS;;;;;;;UAOP,gBAAgB;sCACY,YAAY,gBAAgB,YAAY;;;;UAIpE,gBAAgB;0CACgB,YAAY,gBAAgB,YAAY;;;;GAI/E,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,cAAc,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\nimport { hideVisually, mix, readableColor, rgba, transparentize } from 'polished';\n\nimport { defaultThemeProp } from '../../../theme';\nimport { tryCatch } from '../../../utils';\nimport Button from '../../Button';\n\nexport const StyledPick = styled(Button)(props => {\n const {\n theme: {\n base: {\n 'border-radius': borderRadius,\n palette: { interactive, dark },\n spacing\n },\n components: {\n card: { background }\n }\n }\n } = props;\n\n const textColor = tryCatch(() => readableColor(interactive));\n const disabledBackground = tryCatch(() => transparentize(0.5, mix(0.8, background, dark)));\n\n return css`\n height: 2.625rem;\n border-radius: calc(0.5 * ${borderRadius});\n padding: 0 ${spacing};\n background-color: transparent;\n\n &[aria-selected]:enabled {\n background-color: ${interactive};\n color: ${textColor};\n }\n\n &:disabled {\n background-color: ${disabledBackground};\n border-radius: 0;\n }\n `;\n});\n\nStyledPick.defaultProps = defaultThemeProp;\n\nexport const StyledColumnLabel = styled.span`\n text-align: center;\n margin: 0 auto;\n font-size: 0.75rem;\n`;\n\nStyledColumnLabel.defaultProps = defaultThemeProp;\n\nexport const ScreenReaderOnly = styled.span`\n ${hideVisually}\n`;\n\nexport const StyledDay = styled(StyledPick)<{\n current: boolean;\n highlighted: boolean;\n dayInNexOrPrevMonth: boolean;\n}>(props => {\n const {\n theme: {\n base: {\n palette: { interactive },\n 'disabled-opacity': disabledOpacity\n }\n },\n current,\n highlighted,\n dayInNexOrPrevMonth\n } = props;\n\n const highlightedBgColor = tryCatch(() => rgba(interactive, 0.1));\n\n return css`\n background-color: ${highlighted ? highlightedBgColor : 'transparent'};\n\n ${highlighted &&\n css`\n border-radius: 0;\n `}\n\n ${dayInNexOrPrevMonth &&\n css`\n opacity: ${disabledOpacity};\n `}\n\n ${current &&\n css`\n font-weight: bold;\n `}\n `;\n});\n\nStyledDay.defaultProps = defaultThemeProp;\n\nexport const StyledWeekLabel = styled(StyledColumnLabel)(props => {\n const {\n theme: {\n base: { spacing, breakpoints }\n }\n } = props;\n\n return css`\n margin-inline-end: 0;\n\n @media (min-width: ${breakpoints.sm}) {\n margin-inline-end: ${spacing};\n }\n `;\n});\n\nStyledWeekLabel.defaultProps = defaultThemeProp;\n\nexport const StyledWeekNumber = styled.span(props => {\n const {\n theme: {\n base: {\n breakpoints,\n spacing,\n 'disabled-opacity': disabledOpacity,\n palette: { dark }\n },\n components: {\n card: { background: cardBackground }\n }\n }\n } = props;\n\n const background = tryCatch(() => transparentize(0.5, mix(0.8, cardBackground, dark)));\n\n return css`\n line-height: 2.625rem;\n padding: 0;\n margin-inline-end: 0;\n background-color: ${background};\n display: inline-block;\n opacity: ${disabledOpacity};\n\n @media (min-width: ${breakpoints.sm}) {\n padding: 0 ${spacing};\n margin-inline-end: ${spacing};\n }\n `;\n});\n\nStyledWeekNumber.defaultProps = defaultThemeProp;\n\nexport const StyledWeekGrid = styled.table(props => {\n const {\n theme: {\n base: { spacing }\n }\n } = props;\n return css`\n table-layout: fixed;\n border-collapse: collapse;\n border-spacing: 0;\n\n thead {\n th {\n padding-bottom: ${spacing};\n }\n }\n ${StyledPick} {\n margin-inline-end: ${spacing};\n }\n `;\n});\n\nStyledWeekGrid.defaultProps = defaultThemeProp;\n\nexport const StyledCalendar = styled.table(props => {\n const {\n theme: {\n base: { 'border-radius': borderRadius, spacing }\n }\n } = props;\n return css`\n table-layout: fixed;\n border-collapse: collapse;\n border-spacing: 0;\n\n th {\n max-width: 2.625rem;\n }\n\n thead {\n th {\n padding-bottom: ${spacing};\n }\n }\n\n td {\n width: 2.625rem;\n max-width: 2.625rem;\n\n ${StyledDay} {\n width: 100%;\n }\n }\n\n tr {\n &:first-child {\n ${StyledWeekNumber} {\n border-radius: calc(0.5 * ${borderRadius}) calc(0.5 * ${borderRadius}) 0 0;\n }\n }\n &:last-child {\n ${StyledWeekNumber} {\n border-radius: 0 0 calc(0.5 * ${borderRadius}) calc(0.5 * ${borderRadius});\n }\n }\n }\n `;\n});\n\nStyledCalendar.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../../src/components/DateTime/Picker/DatePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA+B,MAAM,OAAO,CAAC;AAavE,OAAO,eAAe,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../../src/components/DateTime/Picker/DatePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA+B,MAAM,OAAO,CAAC;AAavE,OAAO,eAAe,MAAM,oBAAoB,CAAC;AAgBjD,QAAA,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CA4FlD,CAAC;AAIF,eAAe,UAAU,CAAC"}
|
|
@@ -10,8 +10,9 @@ import { useConfiguration, useDirection, useI18n } from '../../../hooks';
|
|
|
10
10
|
import { getCalendarTypeFromLocale, toUTCDateString } from '../Input/utils';
|
|
11
11
|
import { CALENDAR_TYPES } from '../Input/local';
|
|
12
12
|
import Calendar from './Calendar';
|
|
13
|
-
import { ScreenReaderOnly
|
|
13
|
+
import { ScreenReaderOnly } from './Calendar.styles';
|
|
14
14
|
import { isValidDate } from './utils';
|
|
15
|
+
import { StyledDatePicker, StyledMonthPicker } from './DatePicker.styles';
|
|
15
16
|
registerIcon(caretLeftIcon, caretRightIcon);
|
|
16
17
|
const defaultProps = {
|
|
17
18
|
showWeekNumber: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../../src/components/DateTime/Picker/DatePicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAC7C,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,aAAa,MAAM,kCAAkC,CAAC;AAClE,OAAO,KAAK,cAAc,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC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n\nimport Flex from '../../Flex';\nimport MonthInput from '../Input/MonthInput';\nimport Button from '../../Button';\nimport Icon, { registerIcon } from '../../Icon';\nimport * as caretLeftIcon from '../../Icon/icons/caret-left.icon';\nimport * as caretRightIcon from '../../Icon/icons/caret-right.icon';\nimport { useConfiguration, useDirection, useI18n } from '../../../hooks';\nimport { getCalendarTypeFromLocale, toUTCDateString } from '../Input/utils';\nimport { CALENDAR_TYPES } from '../Input/local';\n\nimport Calendar from './Calendar';\nimport DatePickerProps from './DatePicker.types';\nimport { ScreenReaderOnly } from './Calendar.styles';\nimport { isValidDate } from './utils';\nimport { StyledDatePicker, StyledMonthPicker } from './DatePicker.styles';\n\nregisterIcon(caretLeftIcon, caretRightIcon);\n\nconst defaultProps: Partial<DatePickerProps> = {\n showWeekNumber: false,\n mode: 'date'\n};\n\nfunction toDateString(date: Date | undefined) {\n return date ? toUTCDateString(date) : undefined;\n}\n\nconst DatePicker: FunctionComponent<DatePickerProps> = (props: DatePickerProps) => {\n const { locale } = useConfiguration();\n const { selected: initial, onChange, min, max, mode, showWeekNumber, ...restProps } = props;\n\n const [selected, setSelected] = useState(initial);\n const [current, setCurrent] = useState(selected && isValidDate(selected) ? selected : new Date());\n\n useEffect(() => {\n if (toDateString(initial) !== toDateString(selected)) {\n setSelected(initial);\n setCurrent(initial || new Date());\n }\n }, [toDateString(initial)]);\n\n const calendarRef = useRef<HTMLTableElement>(null);\n useEffect(() => {\n // need to postpone focusing to make sure onFocusWithin has been attached\n setTimeout(() => {\n calendarRef.current?.querySelector<HTMLElement>('button[tabindex=\"0\"]:enabled')?.focus();\n });\n }, []);\n\n const calendarType = getCalendarTypeFromLocale(locale);\n const t = useI18n();\n const { start, end } = useDirection();\n\n return (\n <StyledDatePicker aria-label={t('calendar')} role='region' {...restProps}>\n <Flex as={StyledMonthPicker} container={{ justify: 'between', alignItems: 'center' }}>\n <Button\n variant='simple'\n icon\n onClick={() => {\n const newCurrent = new Date(current);\n newCurrent.setUTCMonth(newCurrent.getUTCMonth() - 1);\n setCurrent(newCurrent);\n }}\n aria-label={t('picker_prev_month')}\n >\n <Icon name={`caret-${start}`} />\n </Button>\n <MonthInput\n value={current}\n required\n role='group'\n aria-label={t('picker_jump_to_month_and_year')}\n onChange={({ valueAsTimestamp }) => {\n const newCurrent = new Date(valueAsTimestamp!);\n newCurrent.setUTCDate(current.getUTCDate());\n setCurrent(newCurrent);\n }}\n min={min}\n max={max}\n />\n <ScreenReaderOnly aria-live='polite' role='alert'>\n {current.toLocaleString(locale, { month: 'long', year: 'numeric', timeZone: 'UTC' })}\n </ScreenReaderOnly>\n <Button\n variant='simple'\n icon\n onClick={() => {\n const newCurrent = new Date(current);\n newCurrent.setUTCMonth(newCurrent.getUTCMonth() + 1);\n setCurrent(newCurrent);\n }}\n aria-label={t('picker_next_month')}\n >\n <Icon name={`caret-${end}`} />\n </Button>\n </Flex>\n <Flex container={{ wrap: 'nowrap' }} dir='ltr'>\n <Calendar\n ref={calendarRef}\n selected={selected && isValidDate(selected) ? selected : undefined}\n current={current}\n calendarType={mode === 'date' ? calendarType : CALENDAR_TYPES.ISO_8601}\n showWeekNumber={showWeekNumber}\n mode={mode}\n onFocus={date => {\n setCurrent(date);\n }}\n onSelect={date => {\n setCurrent(date);\n setSelected(date);\n onChange?.(date);\n }}\n min={min}\n max={max}\n />\n </Flex>\n </StyledDatePicker>\n );\n};\n\nDatePicker.defaultProps = defaultProps;\n\nexport default DatePicker;\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const StyledMonthPicker: import("styled-components").StyledComponent<"fieldset", import("styled-components").DefaultTheme, {}, never>;
|
|
2
|
+
export declare const StyledDatePicker: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
3
|
+
//# sourceMappingURL=DatePicker.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatePicker.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/DateTime/Picker/DatePicker.styles.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,iBAAiB,8GA4B5B,CAAC;AAIH,eAAO,MAAM,gBAAgB,yGAkB3B,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { defaultThemeProp } from '../../../theme';
|
|
3
|
+
import { StyledButton } from '../../Button';
|
|
4
|
+
import { StyledSelect } from '../../Select/Select';
|
|
5
|
+
export const StyledMonthPicker = styled.fieldset(props => {
|
|
6
|
+
const { theme: { base: { spacing, 'border-radius': baseBorderRadius, palette: { 'foreground-color': color } }, components: { 'form-control': formControl } } } = props;
|
|
7
|
+
return css `
|
|
8
|
+
margin: calc(2 * ${spacing}) calc(0.5 * ${spacing});
|
|
9
|
+
font-size: 0.875rem;
|
|
10
|
+
border: none;
|
|
11
|
+
|
|
12
|
+
${StyledSelect} {
|
|
13
|
+
border-radius: calc(${baseBorderRadius} * ${formControl['border-radius']});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
${StyledButton} {
|
|
17
|
+
border-radius: calc(${baseBorderRadius} * ${formControl['border-radius']});
|
|
18
|
+
border: 0;
|
|
19
|
+
&:enabled {
|
|
20
|
+
color: ${color};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
});
|
|
25
|
+
StyledMonthPicker.defaultProps = defaultThemeProp;
|
|
26
|
+
export const StyledDatePicker = styled.div(props => {
|
|
27
|
+
const { theme: { base: { spacing }, components: { 'form-control': { 'foreground-color': foreground } } } } = props;
|
|
28
|
+
return css `
|
|
29
|
+
width: max-content;
|
|
30
|
+
|
|
31
|
+
${StyledButton} {
|
|
32
|
+
border: transparent;
|
|
33
|
+
color: ${foreground};
|
|
34
|
+
}
|
|
35
|
+
padding: 0 ${spacing} ${spacing} ${spacing};
|
|
36
|
+
`;
|
|
37
|
+
});
|
|
38
|
+
StyledDatePicker.defaultProps = defaultThemeProp;
|
|
39
|
+
//# sourceMappingURL=DatePicker.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatePicker.styles.js","sourceRoot":"","sources":["../../../../src/components/DateTime/Picker/DatePicker.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;IACvD,MAAM,EACJ,KAAK,EAAE,EACL,IAAI,EAAE,EACJ,OAAO,EACP,eAAe,EAAE,gBAAgB,EACjC,OAAO,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,EACvC,EACD,UAAU,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,EAC5C,EACF,GAAG,KAAK,CAAC;IACV,OAAO,GAAG,CAAA;uBACW,OAAO,gBAAgB,OAAO;;;;MAI/C,YAAY;4BACU,gBAAgB,MAAM,WAAW,CAAC,eAAe,CAAC;;;MAGxE,YAAY;4BACU,gBAAgB,MAAM,WAAW,CAAC,eAAe,CAAC;;;iBAG7D,KAAK;;;GAGnB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,iBAAiB,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAElD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;IACjD,MAAM,EACJ,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,OAAO,EAAE,EACjB,UAAU,EAAE,EACV,cAAc,EAAE,EAAE,kBAAkB,EAAE,UAAU,EAAE,EACnD,EACF,EACF,GAAG,KAAK,CAAC;IACV,OAAO,GAAG,CAAA;;;MAGN,YAAY;;eAEH,UAAU;;iBAER,OAAO,IAAI,OAAO,IAAI,OAAO;GAC3C,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,gBAAgB,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '../../../theme';\nimport { StyledButton } from '../../Button';\nimport { StyledSelect } from '../../Select/Select';\n\nexport const StyledMonthPicker = styled.fieldset(props => {\n const {\n theme: {\n base: {\n spacing,\n 'border-radius': baseBorderRadius,\n palette: { 'foreground-color': color }\n },\n components: { 'form-control': formControl }\n }\n } = props;\n return css`\n margin: calc(2 * ${spacing}) calc(0.5 * ${spacing});\n font-size: 0.875rem;\n border: none;\n\n ${StyledSelect} {\n border-radius: calc(${baseBorderRadius} * ${formControl['border-radius']});\n }\n\n ${StyledButton} {\n border-radius: calc(${baseBorderRadius} * ${formControl['border-radius']});\n border: 0;\n &:enabled {\n color: ${color};\n }\n }\n `;\n});\n\nStyledMonthPicker.defaultProps = defaultThemeProp;\n\nexport const StyledDatePicker = styled.div(props => {\n const {\n theme: {\n base: { spacing },\n components: {\n 'form-control': { 'foreground-color': foreground }\n }\n }\n } = props;\n return css`\n width: max-content;\n\n ${StyledButton} {\n border: transparent;\n color: ${foreground};\n }\n padding: 0 ${spacing} ${spacing} ${spacing};\n `;\n});\n\nStyledDatePicker.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -10,7 +10,7 @@ import { useConfiguration, useI18n } from '../../../hooks';
|
|
|
10
10
|
import { getCalendarTypeFromLocale, toUTCDateString } from '../Input/utils';
|
|
11
11
|
import Calendar from './Calendar';
|
|
12
12
|
import Weeks from './Weeks';
|
|
13
|
-
import { StyledDatePicker, StyledMonthPicker } from './
|
|
13
|
+
import { StyledDatePicker, StyledMonthPicker } from './DatePicker.styles';
|
|
14
14
|
import { isValidDate } from './utils';
|
|
15
15
|
registerIcon(caretLeftIcon, caretRightIcon);
|
|
16
16
|
function toDateString(date) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangePicker.js","sourceRoot":"","sources":["../../../../src/components/DateTime/Picker/DateRangePicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAC7C,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,aAAa,MAAM,kCAAkC,CAAC;AAClE,OAAO,KAAK,cAAc,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE5E,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"DateRangePicker.js","sourceRoot":"","sources":["../../../../src/components/DateTime/Picker/DateRangePicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAqB,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEvE,OAAO,IAAI,MAAM,YAAY,CAAC;AAC9B,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAC7C,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,IAAI,EAAE,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,aAAa,MAAM,kCAAkC,CAAC;AAClE,OAAO,KAAK,cAAc,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,eA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, useRef } from 'react';\n\nimport Flex from '../../Flex';\nimport MonthInput from '../Input/MonthInput';\nimport Button from '../../Button';\nimport Icon, { registerIcon } from '../../Icon';\nimport * as caretLeftIcon from '../../Icon/icons/caret-left.icon';\nimport * as caretRightIcon from '../../Icon/icons/caret-right.icon';\nimport { useConfiguration, useI18n } from '../../../hooks';\nimport { getCalendarTypeFromLocale, toUTCDateString } from '../Input/utils';\n\nimport Calendar from './Calendar';\nimport DatePickerProps from './DatePicker.types';\nimport Weeks from './Weeks';\nimport { StyledDatePicker, StyledMonthPicker } from './DatePicker.styles';\nimport { isValidDate } from './utils';\n\nregisterIcon(caretLeftIcon, caretRightIcon);\n\nexport interface DateRangePickerProps extends DatePickerProps {\n /** Defines dates range that can be set by the user. */\n selectedRange?: { startDate: Date | undefined; endDate: Date | undefined };\n}\n\nfunction toDateString(date: Date | undefined) {\n return date ? toUTCDateString(date) : undefined;\n}\n\nconst DateRangePicker: FunctionComponent<DateRangePickerProps> = (props: DateRangePickerProps) => {\n const { locale } = useConfiguration();\n const {\n selected: initial,\n selectedRange,\n onChange,\n min,\n max,\n mode,\n showWeekNumber,\n ...restProps\n } = props;\n\n const [selected, setSelected] = useState(initial);\n const [current, setCurrent] = useState(selected && isValidDate(selected) ? selected : new Date());\n\n useEffect(() => {\n if (toDateString(initial) !== toDateString(selected)) {\n setSelected(initial);\n setCurrent(initial || new Date());\n }\n }, [toDateString(initial)]);\n\n const calendarRef = useRef<HTMLDivElement>(null);\n useEffect(() => {\n // need to postpone focusing to make sure onFocusWithin has been attached\n setTimeout(() => {\n calendarRef.current?.querySelector<HTMLElement>('button[tabindex=\"0\"]:enabled')?.focus();\n });\n }, []);\n\n const calendarType = getCalendarTypeFromLocale(locale);\n const t = useI18n();\n\n return (\n <StyledDatePicker aria-label={t('calendar')} role='region' {...restProps}>\n <Flex as={StyledMonthPicker} container={{ justify: 'between', alignItems: 'center' }}>\n <Button\n variant='simple'\n icon\n onClick={() => {\n const newCurrent = new Date(current);\n newCurrent.setUTCMonth(newCurrent.getUTCMonth() - 1);\n setCurrent(newCurrent);\n }}\n aria-label={t('picker_prev_month')}\n >\n <Icon name='caret-left' />\n </Button>\n <MonthInput\n value={current}\n required\n role='group'\n aria-label={t('picker_jump_to_month_and_year')}\n onChange={({ valueAsTimestamp }) => {\n const newCurrent = new Date(valueAsTimestamp!);\n newCurrent.setUTCDate(current.getUTCDate());\n setCurrent(newCurrent);\n }}\n min={min}\n max={max}\n />\n <Button\n variant='simple'\n icon\n onClick={() => {\n const newCurrent = new Date(current);\n newCurrent.setUTCMonth(newCurrent.getUTCMonth() + 1);\n setCurrent(newCurrent);\n }}\n aria-label={t('picker_next_month')}\n >\n <Icon name='caret-right' />\n </Button>\n </Flex>\n <Flex container={{ wrap: 'nowrap' }}>\n {showWeekNumber && <Weeks current={current} calendarType={calendarType} disabled />}\n <Calendar\n ref={calendarRef}\n selected={selected && isValidDate(selected) ? selected : undefined}\n current={current}\n selectedRange={selectedRange}\n showHighlight\n calendarType={calendarType}\n onFocus={date => {\n setCurrent(date);\n }}\n onSelect={date => {\n setCurrent(date);\n setSelected(date);\n onChange?.(date);\n }}\n min={min}\n max={max}\n />\n </Flex>\n </StyledDatePicker>\n );\n};\n\nexport default DateRangePicker;\n"]}
|
|
@@ -26,4 +26,6 @@ export type { DateTimeDisplayProps } from './DateTimeDisplay';
|
|
|
26
26
|
export { default as DurationDisplay } from './DurationDisplay';
|
|
27
27
|
export type { DurationDisplayProps } from './DurationDisplay';
|
|
28
28
|
export { formatDateTime, formatDuration } from './utils';
|
|
29
|
+
export { parseToDate } from './Input/utils';
|
|
30
|
+
export { isValidDate } from './Picker/utils';
|
|
29
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/DateTime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACz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uB,CAAC;AACjE,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACnE,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/D,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC5D,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC5D,YAAY,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5E,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -13,4 +13,6 @@ export { default as DatePicker } from './Picker/DatePicker';
|
|
|
13
13
|
export { default as DateTimeDisplay } from './DateTimeDisplay';
|
|
14
14
|
export { default as DurationDisplay } from './DurationDisplay';
|
|
15
15
|
export { formatDateTime, formatDuration } from './utils';
|
|
16
|
+
export { parseToDate } from './Input/utils';
|
|
17
|
+
export { isValidDate } from './Picker/utils';
|
|
16
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/DateTime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE1E,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG/D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAG5D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE/D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC","sourcesContent":["export { default as DateInput } from './Input/DateInput';\nexport type { DateInputProps } from './Input/DateInput';\nexport { default as WeekInput } from './Input/WeekInput';\nexport type { WeekInputProps } from './Input/WeekInput';\nexport { default as MonthInput } from './Input/MonthInput';\nexport type { MonthInputProps } from './Input/MonthInput';\nexport { default as TimeInput } from './Input/TimeInput';\nexport type { TimeInputProps } from './Input/TimeInput';\nexport { default as DateRangeInput } from './Input/DateRangeInput';\nexport type { DateRangeInputProps } from './Input/DateRangeInput';\nexport { default as DurationInput } from './Input/Duration/DurationInput';\nexport type { default as DurationInputProps } from './Input/Duration/DurationInput.types';\nexport { Format } from './Input/Duration/DurationInput.types';\nexport { default as DateTimeInput } from './Input/DateTimeInput';\nexport type { DateTimeInputProps } from './Input/DateTimeInput';\nexport { default as DayOfWeekInput } from './Input/DayOfWeekInput';\nexport type { DayOfWeekInputProps } from './Input/DayOfWeekInput';\nexport { default as QuarterInput } from './Input/QuarterInput';\nexport type { QuarterInputProps } from './Input/QuarterInput';\n\nexport { default as TimePicker } from './Picker/TimePicker';\nexport type { TimePickerProps } from './Picker/TimePicker';\nexport { default as DatePicker } from './Picker/DatePicker';\nexport type { default as DatePickerProps } from './Picker/DatePicker.types';\n\nexport { default as DateTimeDisplay } from './DateTimeDisplay';\nexport type { DateTimeDisplayProps } from './DateTimeDisplay';\nexport { default as DurationDisplay } from './DurationDisplay';\nexport type { DurationDisplayProps } from './DurationDisplay';\nexport { formatDateTime, formatDuration } from './utils';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/DateTime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE1E,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG/D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAG5D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE/D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["export { default as DateInput } from './Input/DateInput';\nexport type { DateInputProps } from './Input/DateInput';\nexport { default as WeekInput } from './Input/WeekInput';\nexport type { WeekInputProps } from './Input/WeekInput';\nexport { default as MonthInput } from './Input/MonthInput';\nexport type { MonthInputProps } from './Input/MonthInput';\nexport { default as TimeInput } from './Input/TimeInput';\nexport type { TimeInputProps } from './Input/TimeInput';\nexport { default as DateRangeInput } from './Input/DateRangeInput';\nexport type { DateRangeInputProps } from './Input/DateRangeInput';\nexport { default as DurationInput } from './Input/Duration/DurationInput';\nexport type { default as DurationInputProps } from './Input/Duration/DurationInput.types';\nexport { Format } from './Input/Duration/DurationInput.types';\nexport { default as DateTimeInput } from './Input/DateTimeInput';\nexport type { DateTimeInputProps } from './Input/DateTimeInput';\nexport { default as DayOfWeekInput } from './Input/DayOfWeekInput';\nexport type { DayOfWeekInputProps } from './Input/DayOfWeekInput';\nexport { default as QuarterInput } from './Input/QuarterInput';\nexport type { QuarterInputProps } from './Input/QuarterInput';\n\nexport { default as TimePicker } from './Picker/TimePicker';\nexport type { TimePickerProps } from './Picker/TimePicker';\nexport { default as DatePicker } from './Picker/DatePicker';\nexport type { default as DatePickerProps } from './Picker/DatePicker.types';\n\nexport { default as DateTimeDisplay } from './DateTimeDisplay';\nexport type { DateTimeDisplayProps } from './DateTimeDisplay';\nexport { default as DurationDisplay } from './DurationDisplay';\nexport type { DurationDisplayProps } from './DurationDisplay';\nexport { formatDateTime, formatDuration } from './utils';\nexport { parseToDate } from './Input/utils';\nexport { isValidDate } from './Picker/utils';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAEjB,GAAG,EAKH,UAAU,IAAI,eAAe,EAC7B,aAAa,IAAI,kBAAkB,EACpC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAEjB,GAAG,EAKH,UAAU,IAAI,eAAe,EAC7B,aAAa,IAAI,kBAAkB,EACpC,MAAM,OAAO,CAAC;AAcf,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKtD,OAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAKnD,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,SAAS,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;IACtC,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE;QAAE,KAAK,EAAE,MAAM,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;IAChD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CAC3B;AA4CD,eAAO,MAAM,SAAS;;;;;yBAeC,eAAe;uBAGjB,kBAAkB;;4BAdN,eAAe,GAAG,kBAAkB;CAsBpE,CAAC;AAEF,QAAA,MAAM,MAAM,EAAE,iBAAiB,CAAC,WAAW,GAAG,YAAY,CA8JzD,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
|
-
import { useConsolidatedRef, useElement, useEscape, useFocusTrap, useI18n, useOuterEvent, usePrevious } from '../../hooks';
|
|
4
|
+
import { useConsolidatedRef, useElement, useEscape, useFocusTrap, useI18n, useOuterEvent, usePrevious, useUID } from '../../hooks';
|
|
5
5
|
import { defaultThemeProp } from '../../theme';
|
|
6
6
|
import { getFocusables } from '../../utils';
|
|
7
7
|
import Button from '../Button';
|
|
@@ -64,6 +64,7 @@ export const useDialog = () => {
|
|
|
64
64
|
};
|
|
65
65
|
const Dialog = forwardRef(({ target, placement, heading, headingHidden = false, onSubmit, onClose, onOpen, loading, children }, ref) => {
|
|
66
66
|
const t = useI18n();
|
|
67
|
+
const headingId = useUID();
|
|
67
68
|
const [popoverEl, setPopoverEl] = useElement();
|
|
68
69
|
const popoverRef = useConsolidatedRef(ref, setPopoverEl);
|
|
69
70
|
const headingRef = useRef(null);
|
|
@@ -142,7 +143,7 @@ const Dialog = forwardRef(({ target, placement, heading, headingHidden = false,
|
|
|
142
143
|
}
|
|
143
144
|
};
|
|
144
145
|
const progress = loading ? _jsx(Progress, { placement: 'local' }) : null;
|
|
145
|
-
return (_jsxs(Popover, { as: StyledDialog, ref: popoverRef, target: currentTarget, placement: placement, show: show, open: show, children: [_jsx(CardHeader, { actions: !onSubmit ? (_jsx(Button, { icon: true, variant: 'simple', onClick: () => setShow(false), "aria-label": t('close'), children: _jsx(Icon, { name: 'times' }) })) : undefined, children: headingHidden ? (_jsx(VisuallyHiddenText, { children: heading })) : (_jsx(StyledDialogTitle, { variant: 'h2', tabIndex: -1, ref: headingRef, onKeyDown: onTitleKeyDown, children: heading })) }), _jsxs(CardContent, { children: [children, progress] }), onSubmit && (_jsxs(CardFooter, { justify: 'between', children: [_jsx(Button, { variant: 'secondary', onClick: () => setShow(false), children: t('cancel') }), _jsx(Button, { variant: 'primary', onClick: () => onSubmit({ close: () => setShow(false) }), disabled: loading, children: t('submit') })] }))] }));
|
|
146
|
+
return (_jsxs(Popover, { as: StyledDialog, ref: popoverRef, target: currentTarget, placement: placement, show: show, open: show, "aria-labelledby": headingId, children: [_jsx(CardHeader, { actions: !onSubmit ? (_jsx(Button, { icon: true, variant: 'simple', onClick: () => setShow(false), "aria-label": t('close'), children: _jsx(Icon, { name: 'times' }) })) : undefined, children: headingHidden ? (_jsx(VisuallyHiddenText, { id: headingId, children: heading })) : (_jsx(StyledDialogTitle, { variant: 'h2', tabIndex: -1, ref: headingRef, onKeyDown: onTitleKeyDown, id: headingId, children: heading })) }), _jsxs(CardContent, { children: [children, progress] }), onSubmit && (_jsxs(CardFooter, { justify: 'between', children: [_jsx(Button, { variant: 'secondary', onClick: () => setShow(false), children: t('cancel') }), _jsx(Button, { variant: 'primary', onClick: () => onSubmit({ close: () => setShow(false) }), disabled: loading, children: t('submit') })] }))] }));
|
|
146
147
|
});
|
|
147
148
|
export default Dialog;
|
|
148
149
|
//# sourceMappingURL=Dialog.js.map
|