@cloudscape-design/components 3.0.530 → 3.0.532
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/autosuggest/internal.d.ts.map +1 -1
- package/autosuggest/internal.js +2 -1
- package/autosuggest/internal.js.map +1 -1
- package/calendar/grid/calendar-grid-header.d.ts +6 -0
- package/calendar/grid/calendar-grid-header.d.ts.map +1 -0
- package/calendar/grid/calendar-grid-header.js +16 -0
- package/calendar/grid/calendar-grid-header.js.map +1 -0
- package/calendar/grid/index.d.ts +10 -8
- package/calendar/grid/index.d.ts.map +1 -1
- package/calendar/grid/index.js +12 -65
- package/calendar/grid/index.js.map +1 -1
- package/calendar/grid/use-calendar-grid-keyboard-navigation.d.ts +11 -0
- package/calendar/grid/use-calendar-grid-keyboard-navigation.d.ts.map +1 -0
- package/calendar/grid/use-calendar-grid-keyboard-navigation.js +47 -0
- package/calendar/grid/use-calendar-grid-keyboard-navigation.js.map +1 -0
- package/calendar/grid/use-calendar-grid-rows.d.ts +6 -0
- package/calendar/grid/use-calendar-grid-rows.d.ts.map +1 -0
- package/calendar/grid/use-calendar-grid-rows.js +11 -0
- package/calendar/grid/use-calendar-grid-rows.js.map +1 -0
- package/calendar/header/header-button.d.ts +3 -4
- package/calendar/header/header-button.d.ts.map +1 -1
- package/calendar/header/header-button.js +4 -5
- package/calendar/header/header-button.js.map +1 -1
- package/calendar/header/index.d.ts +5 -6
- package/calendar/header/index.d.ts.map +1 -1
- package/calendar/header/index.js +5 -6
- package/calendar/header/index.js.map +1 -1
- package/calendar/internal.d.ts +1 -2
- package/calendar/internal.d.ts.map +1 -1
- package/calendar/internal.js +34 -19
- package/calendar/internal.js.map +1 -1
- package/calendar/styles.css.js +18 -18
- package/calendar/styles.scoped.css +39 -39
- package/calendar/styles.selectors.js +18 -18
- package/calendar/use-calendar-labels.d.ts +16 -0
- package/calendar/use-calendar-labels.d.ts.map +1 -0
- package/calendar/use-calendar-labels.js +28 -0
- package/calendar/use-calendar-labels.js.map +1 -0
- package/calendar/utils/navigation.d.ts +1 -1
- package/calendar/utils/navigation.d.ts.map +1 -1
- package/calendar/utils/navigation.js +10 -11
- package/calendar/utils/navigation.js.map +1 -1
- package/date-range-picker/calendar/grids/index.js +2 -2
- package/date-range-picker/calendar/grids/index.js.map +1 -1
- package/date-range-picker/calendar/index.js +2 -2
- package/date-range-picker/calendar/index.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
package/calendar/internal.js
CHANGED
|
@@ -2,27 +2,28 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { __rest } from "tslib";
|
|
4
4
|
import React, { useEffect, useRef, useState } from 'react';
|
|
5
|
-
import { isSameMonth } from 'date-fns';
|
|
5
|
+
import { addMonths, isSameDay, isSameMonth } from 'date-fns';
|
|
6
6
|
import styles from './styles.css.js';
|
|
7
7
|
import CalendarHeader from './header';
|
|
8
8
|
import Grid from './grid';
|
|
9
|
-
import { normalizeLocale
|
|
9
|
+
import { normalizeLocale } from '../internal/utils/locale';
|
|
10
10
|
import { formatDate, parseDate } from '../internal/utils/date-time';
|
|
11
11
|
import { fireNonCancelableEvent } from '../internal/events/index.js';
|
|
12
12
|
import checkControlled from '../internal/hooks/check-controlled/index.js';
|
|
13
13
|
import clsx from 'clsx';
|
|
14
14
|
import { getBaseProps } from '../internal/base-component';
|
|
15
|
-
import {
|
|
15
|
+
import { getBaseDay } from './utils/navigation';
|
|
16
16
|
import { useDateCache } from '../internal/hooks/use-date-cache/index.js';
|
|
17
17
|
import { useUniqueId } from '../internal/hooks/use-unique-id/index.js';
|
|
18
|
-
import
|
|
18
|
+
import useCalendarLabels from './use-calendar-labels';
|
|
19
|
+
import useCalendarGridRows from './grid/use-calendar-grid-rows';
|
|
20
|
+
import useCalendarGridKeyboardNavigation from './grid/use-calendar-grid-keyboard-navigation';
|
|
21
|
+
import CalendarGridHeader from './grid/calendar-grid-header';
|
|
19
22
|
export default function Calendar(_a) {
|
|
20
|
-
var
|
|
21
|
-
var { value, locale = '', startOfWeek, isDateEnabled = () => true, ariaLabel, ariaLabelledby, ariaDescribedby, onChange, __internalRootRef, i18nStrings } = _a, rest = __rest(_a, ["value", "locale", "startOfWeek", "isDateEnabled", "ariaLabel", "ariaLabelledby", "ariaDescribedby", "onChange", "__internalRootRef", "i18nStrings"]);
|
|
23
|
+
var { value, locale = '', startOfWeek, isDateEnabled = () => true, ariaLabel, ariaLabelledby, ariaDescribedby, onChange, __internalRootRef, i18nStrings, previousMonthAriaLabel, nextMonthAriaLabel, todayAriaLabel } = _a, rest = __rest(_a, ["value", "locale", "startOfWeek", "isDateEnabled", "ariaLabel", "ariaLabelledby", "ariaDescribedby", "onChange", "__internalRootRef", "i18nStrings", "previousMonthAriaLabel", "nextMonthAriaLabel", "todayAriaLabel"]);
|
|
22
24
|
checkControlled('Calendar', 'value', value, 'onChange', onChange);
|
|
23
25
|
const baseProps = getBaseProps(rest);
|
|
24
26
|
const normalizedLocale = normalizeLocale('Calendar', locale);
|
|
25
|
-
const normalizedStartOfWeek = normalizeStartOfWeek(startOfWeek, normalizedLocale);
|
|
26
27
|
const gridWrapperRef = useRef(null);
|
|
27
28
|
const [focusedDate, setFocusedDate] = useState(null);
|
|
28
29
|
const valueDateCache = useDateCache();
|
|
@@ -33,10 +34,16 @@ export default function Calendar(_a) {
|
|
|
33
34
|
const defaultDisplayedDate = memoizedValue !== null && memoizedValue !== void 0 ? memoizedValue : new Date();
|
|
34
35
|
const [displayedDate, setDisplayedDate] = useState(defaultDisplayedDate);
|
|
35
36
|
const headingId = useUniqueId('calendar-heading');
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
37
|
+
const baseDate = getBaseDay(displayedDate, isDateEnabled);
|
|
38
|
+
const isCurrentPage = (date) => isSameMonth(date, baseDate);
|
|
39
|
+
const { previousButtonLabel, nextButtonLabel, renderDate, renderDateAnnouncement, renderHeaderText } = useCalendarLabels({
|
|
40
|
+
i18nStrings,
|
|
41
|
+
locale: normalizedLocale,
|
|
42
|
+
previousMonthAriaLabel,
|
|
43
|
+
nextMonthAriaLabel,
|
|
44
|
+
todayAriaLabel,
|
|
45
|
+
});
|
|
46
|
+
const gridRows = useCalendarGridRows({ baseDate, startOfWeek, locale: normalizedLocale });
|
|
40
47
|
// Update displayed date if value changes.
|
|
41
48
|
useEffect(() => {
|
|
42
49
|
memoizedValue && setDisplayedDate(prev => (prev.getTime() !== memoizedValue.getTime() ? memoizedValue : prev));
|
|
@@ -54,14 +61,13 @@ export default function Calendar(_a) {
|
|
|
54
61
|
}
|
|
55
62
|
return null;
|
|
56
63
|
};
|
|
57
|
-
const baseDate = getBaseDate(displayedDate, isDateEnabled);
|
|
58
64
|
const focusableDate = focusedDate || selectFocusedDate(memoizedValue, baseDate);
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
const onHeaderChangePageHandler = (amount) => {
|
|
66
|
+
const newDate = addMonths(baseDate, amount);
|
|
67
|
+
onChangePageHandler(newDate);
|
|
62
68
|
};
|
|
63
|
-
const
|
|
64
|
-
setDisplayedDate(
|
|
69
|
+
const onChangePageHandler = (newDate) => {
|
|
70
|
+
setDisplayedDate(newDate);
|
|
65
71
|
setFocusedDate(null);
|
|
66
72
|
};
|
|
67
73
|
const onGridFocusDateHandler = (date) => {
|
|
@@ -80,10 +86,19 @@ export default function Calendar(_a) {
|
|
|
80
86
|
setFocusedDate(null);
|
|
81
87
|
}
|
|
82
88
|
};
|
|
89
|
+
const onGridKeyDownHandler = useCalendarGridKeyboardNavigation({
|
|
90
|
+
baseDate,
|
|
91
|
+
focusableDate,
|
|
92
|
+
isDateEnabled,
|
|
93
|
+
onChangePage: onChangePageHandler,
|
|
94
|
+
onFocusDate: onGridFocusDateHandler,
|
|
95
|
+
onSelectDate: onGridSelectDateHandler,
|
|
96
|
+
});
|
|
97
|
+
const headerText = renderHeaderText(baseDate);
|
|
83
98
|
return (React.createElement("div", Object.assign({ ref: __internalRootRef }, baseProps, { role: "group", "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, className: clsx(styles.root, styles.calendar, baseProps.className) }),
|
|
84
99
|
React.createElement("div", { className: styles['calendar-inner'] },
|
|
85
|
-
React.createElement(CalendarHeader, {
|
|
100
|
+
React.createElement(CalendarHeader, { formattedDate: headerText, onChange: onHeaderChangePageHandler, previousLabel: previousButtonLabel, nextLabel: nextButtonLabel, headingId: headingId }),
|
|
86
101
|
React.createElement("div", { onBlur: onGridBlur, ref: gridWrapperRef },
|
|
87
|
-
React.createElement(Grid, {
|
|
102
|
+
React.createElement(Grid, { isDateEnabled: isDateEnabled, focusedDate: focusedDate, focusableDate: focusableDate, onSelectDate: onGridSelectDateHandler, onFocusDate: onGridFocusDateHandler, onChangePage: onChangePageHandler, selectedDate: memoizedValue, ariaLabelledby: headingId, header: React.createElement(CalendarGridHeader, { locale: normalizedLocale, rows: gridRows }), rows: gridRows, isCurrentPage: isCurrentPage, renderDate: renderDate, renderDateAnnouncement: renderDateAnnouncement, isSameDate: isSameDay, onGridKeyDownHandler: onGridKeyDownHandler })))));
|
|
88
103
|
}
|
|
89
104
|
//# sourceMappingURL=internal.js.map
|
package/calendar/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["calendar/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,cAAc,MAAM,UAAU,CAAC;AACtC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,EAAE,e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zB,CACE,CACF,CACF,CACP,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 { isSameMonth } from 'date-fns';\nimport styles from './styles.css.js';\nimport CalendarHeader from './header';\nimport Grid from './grid';\nimport { normalizeLocale, normalizeStartOfWeek } from '../internal/utils/locale';\nimport { formatDate, parseDate } from '../internal/utils/date-time';\nimport { fireNonCancelableEvent } from '../internal/events/index.js';\nimport checkControlled from '../internal/hooks/check-controlled/index.js';\nimport clsx from 'clsx';\nimport { CalendarProps } from './interfaces.js';\nimport { getBaseProps } from '../internal/base-component';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';\nimport { getBaseDate } from './utils/navigation';\nimport { useDateCache } from '../internal/hooks/use-date-cache/index.js';\nimport { useUniqueId } from '../internal/hooks/use-unique-id/index.js';\nimport { useInternalI18n } from '../i18n/context.js';\n\nexport type DayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\nexport default function Calendar({\n value,\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n ariaLabel,\n ariaLabelledby,\n ariaDescribedby,\n onChange,\n __internalRootRef,\n i18nStrings,\n ...rest\n}: CalendarProps & InternalBaseComponentProps) {\n checkControlled('Calendar', 'value', value, 'onChange', onChange);\n\n const baseProps = getBaseProps(rest);\n const normalizedLocale = normalizeLocale('Calendar', locale);\n const normalizedStartOfWeek = normalizeStartOfWeek(startOfWeek, normalizedLocale);\n const gridWrapperRef = useRef<HTMLDivElement>(null);\n const [focusedDate, setFocusedDate] = useState<Date | null>(null);\n\n const valueDateCache = useDateCache();\n const focusedDateCache = useDateCache();\n\n // Set displayed date to value if defined or to current date otherwise.\n const parsedValue = value && value.length >= 4 ? parseDate(value) : null;\n const memoizedValue = parsedValue ? valueDateCache(parsedValue) : null;\n const defaultDisplayedDate = memoizedValue ?? new Date();\n const [displayedDate, setDisplayedDate] = useState(defaultDisplayedDate);\n\n const headingId = useUniqueId('calendar-heading');\n\n const i18n = useInternalI18n('calendar');\n const nextMonthAriaLabel = i18n('nextMonthAriaLabel', i18nStrings?.nextMonthAriaLabel ?? rest.nextMonthAriaLabel);\n const previousMonthAriaLabel = i18n(\n 'previousMonthAriaLabel',\n i18nStrings?.previousMonthAriaLabel ?? rest.previousMonthAriaLabel\n );\n const todayAriaLabel = i18n('todayAriaLabel', i18nStrings?.todayAriaLabel ?? rest.todayAriaLabel);\n\n // Update displayed date if value changes.\n useEffect(() => {\n memoizedValue && setDisplayedDate(prev => (prev.getTime() !== memoizedValue.getTime() ? memoizedValue : prev));\n }, [memoizedValue]);\n\n const selectFocusedDate = (selected: Date | null, baseDate: Date): Date | null => {\n if (selected && isDateEnabled(selected) && isSameMonth(selected, baseDate)) {\n return selected;\n }\n const today = new Date();\n if (isDateEnabled(today) && isSameMonth(today, baseDate)) {\n return today;\n }\n if (isDateEnabled(baseDate)) {\n return baseDate;\n }\n return null;\n };\n\n const baseDate = getBaseDate(displayedDate, isDateEnabled);\n const focusableDate = focusedDate || selectFocusedDate(memoizedValue, baseDate);\n\n const onHeaderChangeMonthHandler = (date: Date) => {\n setDisplayedDate(date);\n setFocusedDate(null);\n };\n\n const onGridChangeMonthHandler = (newMonth: Date) => {\n setDisplayedDate(newMonth);\n setFocusedDate(null);\n };\n\n const onGridFocusDateHandler = (date: null | Date) => {\n if (date) {\n setFocusedDate(date ? focusedDateCache(date) : null);\n }\n };\n\n const onGridSelectDateHandler = (date: Date) => {\n fireNonCancelableEvent(onChange, { value: formatDate(date) });\n setFocusedDate(null);\n };\n\n const onGridBlur = (event: React.FocusEvent) => {\n const newFocusTargetIsInGrid = event.relatedTarget && gridWrapperRef.current?.contains(event.relatedTarget as Node);\n if (!newFocusTargetIsInGrid) {\n setFocusedDate(null);\n }\n };\n\n return (\n <div\n ref={__internalRootRef}\n {...baseProps}\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n className={clsx(styles.root, styles.calendar, baseProps.className)}\n >\n <div className={styles['calendar-inner']}>\n <CalendarHeader\n baseDate={baseDate}\n locale={normalizedLocale}\n onChangeMonth={onHeaderChangeMonthHandler}\n previousMonthLabel={previousMonthAriaLabel}\n nextMonthLabel={nextMonthAriaLabel}\n headingId={headingId}\n />\n <div onBlur={onGridBlur} ref={gridWrapperRef}>\n <Grid\n locale={normalizedLocale}\n baseDate={baseDate}\n isDateEnabled={isDateEnabled}\n focusedDate={focusedDate}\n focusableDate={focusableDate}\n onSelectDate={onGridSelectDateHandler}\n onFocusDate={onGridFocusDateHandler}\n onChangeMonth={onGridChangeMonthHandler}\n startOfWeek={normalizedStartOfWeek}\n todayAriaLabel={todayAriaLabel}\n selectedDate={memoizedValue}\n ariaLabelledby={headingId}\n />\n </div>\n </div>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["calendar/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,cAAc,MAAM,UAAU,CAAC;AACtC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,eAAe,MAAM,6CAA6C,CAAC;AAC1E,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA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5B,UAAU,EAAE,UAAU,EACtB,sBAAsB,EAAE,sBAAsB,EAC9C,UAAU,EAAE,SAAS,EACrB,oBAAoB,EAAE,oBAAoB,GAC1C,CACE,CACF,CACF,CACP,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 { addMonths, isSameDay, isSameMonth } from 'date-fns';\nimport styles from './styles.css.js';\nimport CalendarHeader from './header';\nimport Grid from './grid';\nimport { normalizeLocale } from '../internal/utils/locale';\nimport { formatDate, parseDate } from '../internal/utils/date-time';\nimport { fireNonCancelableEvent } from '../internal/events/index.js';\nimport checkControlled from '../internal/hooks/check-controlled/index.js';\nimport clsx from 'clsx';\nimport { CalendarProps } from './interfaces.js';\nimport { getBaseProps } from '../internal/base-component';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';\nimport { getBaseDay } from './utils/navigation';\nimport { useDateCache } from '../internal/hooks/use-date-cache/index.js';\nimport { useUniqueId } from '../internal/hooks/use-unique-id/index.js';\nimport useCalendarLabels from './use-calendar-labels';\nimport useCalendarGridRows from './grid/use-calendar-grid-rows';\nimport useCalendarGridKeyboardNavigation from './grid/use-calendar-grid-keyboard-navigation';\nimport CalendarGridHeader from './grid/calendar-grid-header';\n\nexport default function Calendar({\n value,\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n ariaLabel,\n ariaLabelledby,\n ariaDescribedby,\n onChange,\n __internalRootRef,\n i18nStrings,\n previousMonthAriaLabel,\n nextMonthAriaLabel,\n todayAriaLabel,\n ...rest\n}: CalendarProps & InternalBaseComponentProps) {\n checkControlled('Calendar', 'value', value, 'onChange', onChange);\n\n const baseProps = getBaseProps(rest);\n const normalizedLocale = normalizeLocale('Calendar', locale);\n\n const gridWrapperRef = useRef<HTMLDivElement>(null);\n const [focusedDate, setFocusedDate] = useState<Date | null>(null);\n\n const valueDateCache = useDateCache();\n const focusedDateCache = useDateCache();\n\n // Set displayed date to value if defined or to current date otherwise.\n const parsedValue = value && value.length >= 4 ? parseDate(value) : null;\n const memoizedValue = parsedValue ? valueDateCache(parsedValue) : null;\n const defaultDisplayedDate = memoizedValue ?? new Date();\n const [displayedDate, setDisplayedDate] = useState(defaultDisplayedDate);\n\n const headingId = useUniqueId('calendar-heading');\n\n const baseDate = getBaseDay(displayedDate, isDateEnabled);\n\n const isCurrentPage = (date: Date) => isSameMonth(date, baseDate);\n\n const { previousButtonLabel, nextButtonLabel, renderDate, renderDateAnnouncement, renderHeaderText } =\n useCalendarLabels({\n i18nStrings,\n locale: normalizedLocale,\n previousMonthAriaLabel,\n nextMonthAriaLabel,\n todayAriaLabel,\n });\n\n const gridRows = useCalendarGridRows({ baseDate, startOfWeek, locale: normalizedLocale });\n\n // Update displayed date if value changes.\n useEffect(() => {\n memoizedValue && setDisplayedDate(prev => (prev.getTime() !== memoizedValue.getTime() ? memoizedValue : prev));\n }, [memoizedValue]);\n\n const selectFocusedDate = (selected: Date | null, baseDate: Date): Date | null => {\n if (selected && isDateEnabled(selected) && isSameMonth(selected, baseDate)) {\n return selected;\n }\n const today = new Date();\n if (isDateEnabled(today) && isSameMonth(today, baseDate)) {\n return today;\n }\n if (isDateEnabled(baseDate)) {\n return baseDate;\n }\n return null;\n };\n\n const focusableDate = focusedDate || selectFocusedDate(memoizedValue, baseDate);\n\n const onHeaderChangePageHandler = (amount: number) => {\n const newDate = addMonths(baseDate, amount);\n onChangePageHandler(newDate);\n };\n\n const onChangePageHandler = (newDate: Date) => {\n setDisplayedDate(newDate);\n setFocusedDate(null);\n };\n\n const onGridFocusDateHandler = (date: null | Date) => {\n if (date) {\n setFocusedDate(date ? focusedDateCache(date) : null);\n }\n };\n\n const onGridSelectDateHandler = (date: Date) => {\n fireNonCancelableEvent(onChange, { value: formatDate(date) });\n setFocusedDate(null);\n };\n\n const onGridBlur = (event: React.FocusEvent) => {\n const newFocusTargetIsInGrid = event.relatedTarget && gridWrapperRef.current?.contains(event.relatedTarget as Node);\n if (!newFocusTargetIsInGrid) {\n setFocusedDate(null);\n }\n };\n\n const onGridKeyDownHandler = useCalendarGridKeyboardNavigation({\n baseDate,\n focusableDate,\n isDateEnabled,\n onChangePage: onChangePageHandler,\n onFocusDate: onGridFocusDateHandler,\n onSelectDate: onGridSelectDateHandler,\n });\n\n const headerText = renderHeaderText(baseDate);\n\n return (\n <div\n ref={__internalRootRef}\n {...baseProps}\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n className={clsx(styles.root, styles.calendar, baseProps.className)}\n >\n <div className={styles['calendar-inner']}>\n <CalendarHeader\n formattedDate={headerText}\n onChange={onHeaderChangePageHandler}\n previousLabel={previousButtonLabel}\n nextLabel={nextButtonLabel}\n headingId={headingId}\n />\n <div onBlur={onGridBlur} ref={gridWrapperRef}>\n <Grid\n isDateEnabled={isDateEnabled}\n focusedDate={focusedDate}\n focusableDate={focusableDate}\n onSelectDate={onGridSelectDateHandler}\n onFocusDate={onGridFocusDateHandler}\n onChangePage={onChangePageHandler}\n selectedDate={memoizedValue}\n ariaLabelledby={headingId}\n header={<CalendarGridHeader locale={normalizedLocale} rows={gridRows} />}\n rows={gridRows}\n isCurrentPage={isCurrentPage}\n renderDate={renderDate}\n renderDateAnnouncement={renderDateAnnouncement}\n isSameDate={isSameDay}\n onGridKeyDownHandler={onGridKeyDownHandler}\n />\n </div>\n </div>\n </div>\n );\n}\n"]}
|
package/calendar/styles.css.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"calendar": "
|
|
5
|
-
"awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-
|
|
6
|
-
"root": "
|
|
7
|
-
"calendar-inner": "awsui_calendar-
|
|
8
|
-
"calendar-header": "awsui_calendar-
|
|
9
|
-
"calendar-header-
|
|
10
|
-
"calendar-next-btn": "awsui_calendar-next-
|
|
11
|
-
"calendar-prev-btn": "awsui_calendar-prev-
|
|
12
|
-
"calendar-grid": "awsui_calendar-
|
|
13
|
-
"calendar-grid-cell": "awsui_calendar-grid-
|
|
14
|
-
"calendar-date-header": "awsui_calendar-date-
|
|
15
|
-
"calendar-date": "awsui_calendar-
|
|
16
|
-
"calendar-date-enabled": "awsui_calendar-date-
|
|
17
|
-
"calendar-date-current-page": "awsui_calendar-date-current-
|
|
18
|
-
"calendar-date-selected": "awsui_calendar-date-
|
|
19
|
-
"calendar-date-current": "awsui_calendar-date-
|
|
20
|
-
"date-inner": "awsui_date-
|
|
21
|
-
"calendar-row": "awsui_calendar-
|
|
4
|
+
"calendar": "awsui_calendar_1ykar_3o1tp_93",
|
|
5
|
+
"awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_1ykar_3o1tp_1",
|
|
6
|
+
"root": "awsui_root_1ykar_3o1tp_124",
|
|
7
|
+
"calendar-inner": "awsui_calendar-inner_1ykar_3o1tp_165",
|
|
8
|
+
"calendar-header": "awsui_calendar-header_1ykar_3o1tp_169",
|
|
9
|
+
"calendar-header-title": "awsui_calendar-header-title_1ykar_3o1tp_174",
|
|
10
|
+
"calendar-next-btn": "awsui_calendar-next-btn_1ykar_3o1tp_182",
|
|
11
|
+
"calendar-prev-btn": "awsui_calendar-prev-btn_1ykar_3o1tp_185",
|
|
12
|
+
"calendar-grid": "awsui_calendar-grid_1ykar_3o1tp_188",
|
|
13
|
+
"calendar-grid-cell": "awsui_calendar-grid-cell_1ykar_3o1tp_193",
|
|
14
|
+
"calendar-date-header": "awsui_calendar-date-header_1ykar_3o1tp_198",
|
|
15
|
+
"calendar-date": "awsui_calendar-date_1ykar_3o1tp_198",
|
|
16
|
+
"calendar-date-enabled": "awsui_calendar-date-enabled_1ykar_3o1tp_218",
|
|
17
|
+
"calendar-date-current-page": "awsui_calendar-date-current-page_1ykar_3o1tp_228",
|
|
18
|
+
"calendar-date-selected": "awsui_calendar-date-selected_1ykar_3o1tp_239",
|
|
19
|
+
"calendar-date-current": "awsui_calendar-date-current_1ykar_3o1tp_228",
|
|
20
|
+
"date-inner": "awsui_date-inner_1ykar_3o1tp_261",
|
|
21
|
+
"calendar-row": "awsui_calendar-row_1ykar_3o1tp_336"
|
|
22
22
|
};
|
|
23
23
|
|
|
@@ -90,11 +90,11 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
90
90
|
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
91
91
|
SPDX-License-Identifier: Apache-2.0
|
|
92
92
|
*/
|
|
93
|
-
.
|
|
94
|
-
animation: awsui_awsui-motion-fade-in-
|
|
93
|
+
.awsui_calendar_1ykar_3o1tp_93:not(#\9) {
|
|
94
|
+
animation: awsui_awsui-motion-fade-in-0_1ykar_3o1tp_1 var(--motion-duration-show-quick-aq3ump, 135ms) var(--motion-easing-show-quick-vc5zgd, ease-out);
|
|
95
95
|
animation-fill-mode: both;
|
|
96
96
|
}
|
|
97
|
-
@keyframes awsui_awsui-motion-fade-in-
|
|
97
|
+
@keyframes awsui_awsui-motion-fade-in-0_1ykar_3o1tp_1 {
|
|
98
98
|
from {
|
|
99
99
|
opacity: 0;
|
|
100
100
|
}
|
|
@@ -103,12 +103,12 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
@media (prefers-reduced-motion: reduce) {
|
|
106
|
-
.
|
|
106
|
+
.awsui_calendar_1ykar_3o1tp_93:not(#\9) {
|
|
107
107
|
animation: none;
|
|
108
108
|
transition: none;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
.awsui-motion-disabled .
|
|
111
|
+
.awsui-motion-disabled .awsui_calendar_1ykar_3o1tp_93:not(#\9), .awsui-mode-entering .awsui_calendar_1ykar_3o1tp_93:not(#\9) {
|
|
112
112
|
animation: none;
|
|
113
113
|
transition: none;
|
|
114
114
|
}
|
|
@@ -121,11 +121,11 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
121
121
|
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
122
122
|
SPDX-License-Identifier: Apache-2.0
|
|
123
123
|
*/
|
|
124
|
-
.
|
|
124
|
+
.awsui_root_1ykar_3o1tp_124:not(#\9) {
|
|
125
125
|
/* used in test-utils */
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
.
|
|
128
|
+
.awsui_calendar_1ykar_3o1tp_93:not(#\9) {
|
|
129
129
|
display: block;
|
|
130
130
|
inline-size: var(--size-calendar-grid-width-lrunz7, 238px);
|
|
131
131
|
overflow: auto;
|
|
@@ -163,16 +163,16 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
163
163
|
-webkit-font-smoothing: auto;
|
|
164
164
|
-moz-osx-font-smoothing: auto;
|
|
165
165
|
}
|
|
166
|
-
.awsui_calendar-
|
|
166
|
+
.awsui_calendar-inner_1ykar_3o1tp_165:not(#\9) {
|
|
167
167
|
margin-block: var(--space-xs-zb16t3, 8px);
|
|
168
168
|
margin-inline: var(--space-xs-zb16t3, 8px);
|
|
169
169
|
}
|
|
170
|
-
.awsui_calendar-
|
|
170
|
+
.awsui_calendar-header_1ykar_3o1tp_169:not(#\9) {
|
|
171
171
|
display: flex;
|
|
172
172
|
justify-content: space-between;
|
|
173
173
|
align-items: center;
|
|
174
174
|
}
|
|
175
|
-
.awsui_calendar-header-
|
|
175
|
+
.awsui_calendar-header-title_1ykar_3o1tp_174:not(#\9) {
|
|
176
176
|
font-size: var(--font-size-body-m-x4okxb, 14px);
|
|
177
177
|
line-height: var(--line-height-body-m-30ar75, 20px);
|
|
178
178
|
font-weight: 700;
|
|
@@ -180,23 +180,23 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
180
180
|
margin-block: 0;
|
|
181
181
|
margin-inline: 0;
|
|
182
182
|
}
|
|
183
|
-
.awsui_calendar-next-
|
|
183
|
+
.awsui_calendar-next-btn_1ykar_3o1tp_182:not(#\9) {
|
|
184
184
|
/* used for identifying element */
|
|
185
185
|
}
|
|
186
|
-
.awsui_calendar-prev-
|
|
186
|
+
.awsui_calendar-prev-btn_1ykar_3o1tp_185:not(#\9) {
|
|
187
187
|
/* used for identifying element */
|
|
188
188
|
}
|
|
189
|
-
.awsui_calendar-
|
|
189
|
+
.awsui_calendar-grid_1ykar_3o1tp_188:not(#\9) {
|
|
190
190
|
inline-size: 100%;
|
|
191
|
+
table-layout: fixed;
|
|
191
192
|
border-spacing: 0;
|
|
192
193
|
}
|
|
193
|
-
.awsui_calendar-grid-
|
|
194
|
-
inline-size: 14.2857142857%;
|
|
194
|
+
.awsui_calendar-grid-cell_1ykar_3o1tp_193:not(#\9) {
|
|
195
195
|
word-break: break-word;
|
|
196
196
|
text-align: center;
|
|
197
197
|
font-weight: unset;
|
|
198
198
|
}
|
|
199
|
-
.awsui_calendar-date-
|
|
199
|
+
.awsui_calendar-date-header_1ykar_3o1tp_198:not(#\9) {
|
|
200
200
|
padding-block-start: var(--space-s-34lx8l, 12px);
|
|
201
201
|
padding-block-end: var(--space-xxs-p8yyaw, 4px);
|
|
202
202
|
padding-inline: 0;
|
|
@@ -205,7 +205,7 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
205
205
|
line-height: var(--line-height-body-s-7zv1j5, 16px);
|
|
206
206
|
letter-spacing: var(--letter-spacing-body-s-z9jkwp, 0.005em);
|
|
207
207
|
}
|
|
208
|
-
.awsui_calendar-
|
|
208
|
+
.awsui_calendar-date_1ykar_3o1tp_198:not(#\9) {
|
|
209
209
|
border-block-end: 1px solid var(--color-border-calendar-grid-u86q1u, transparent);
|
|
210
210
|
border-inline-end: 1px solid var(--color-border-calendar-grid-u86q1u, transparent);
|
|
211
211
|
padding-block: var(--space-xxs-p8yyaw, 4px);
|
|
@@ -213,23 +213,23 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
213
213
|
color: var(--color-text-dropdown-item-disabled-6oq3n6, #9ba7b6);
|
|
214
214
|
position: relative;
|
|
215
215
|
}
|
|
216
|
-
.awsui_calendar-
|
|
216
|
+
.awsui_calendar-date_1ykar_3o1tp_198:not(#\9):first-child {
|
|
217
217
|
border-inline-start: 1px solid var(--color-border-calendar-grid-u86q1u, transparent);
|
|
218
218
|
}
|
|
219
|
-
.awsui_calendar-date-
|
|
219
|
+
.awsui_calendar-date-enabled_1ykar_3o1tp_218:not(#\9) {
|
|
220
220
|
cursor: pointer;
|
|
221
221
|
color: var(--color-text-dropdown-item-secondary-jho0ju, #5f6b7a);
|
|
222
222
|
}
|
|
223
|
-
.awsui_calendar-date-
|
|
223
|
+
.awsui_calendar-date-enabled_1ykar_3o1tp_218:not(#\9)::after {
|
|
224
224
|
border-start-start-radius: var(--border-radius-item-05df9h, 8px);
|
|
225
225
|
border-start-end-radius: var(--border-radius-item-05df9h, 8px);
|
|
226
226
|
border-end-start-radius: var(--border-radius-item-05df9h, 8px);
|
|
227
227
|
border-end-end-radius: var(--border-radius-item-05df9h, 8px);
|
|
228
228
|
}
|
|
229
|
-
.awsui_calendar-date-
|
|
229
|
+
.awsui_calendar-date-enabled_1ykar_3o1tp_218.awsui_calendar-date-current-page_1ykar_3o1tp_228:not(#\9) {
|
|
230
230
|
color: var(--color-text-dropdown-item-default-4o4hes, #000716);
|
|
231
231
|
}
|
|
232
|
-
.awsui_calendar-date-
|
|
232
|
+
.awsui_calendar-date-enabled_1ykar_3o1tp_218.awsui_calendar-date-current-page_1ykar_3o1tp_228:not(#\9):hover {
|
|
233
233
|
border-start-start-radius: var(--border-radius-item-05df9h, 8px);
|
|
234
234
|
border-start-end-radius: var(--border-radius-item-05df9h, 8px);
|
|
235
235
|
border-end-start-radius: var(--border-radius-item-05df9h, 8px);
|
|
@@ -237,11 +237,11 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
237
237
|
color: var(--color-text-calendar-date-hover-llr4as, #000716);
|
|
238
238
|
background-color: var(--color-background-dropdown-item-hover-swsulg, #f4f4f4);
|
|
239
239
|
}
|
|
240
|
-
.awsui_calendar-date-
|
|
240
|
+
.awsui_calendar-date-enabled_1ykar_3o1tp_218.awsui_calendar-date-current-page_1ykar_3o1tp_228:not(#\9):hover:not(.awsui_calendar-date-selected_1ykar_3o1tp_239)::after {
|
|
241
241
|
border-block: var(--border-item-width-yel47s, 2px) solid var(--color-border-dropdown-item-hover-461g78, #7d8998);
|
|
242
242
|
border-inline: var(--border-item-width-yel47s, 2px) solid var(--color-border-dropdown-item-hover-461g78, #7d8998);
|
|
243
243
|
}
|
|
244
|
-
.awsui_calendar-date-
|
|
244
|
+
.awsui_calendar-date-current_1ykar_3o1tp_228:not(#\9) {
|
|
245
245
|
border-start-start-radius: var(--border-radius-item-05df9h, 8px);
|
|
246
246
|
border-start-end-radius: var(--border-radius-item-05df9h, 8px);
|
|
247
247
|
border-end-start-radius: var(--border-radius-item-05df9h, 8px);
|
|
@@ -249,7 +249,7 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
249
249
|
background-color: var(--color-background-calendar-current-date-kmb0ji, #f4f4f4);
|
|
250
250
|
font-weight: 700;
|
|
251
251
|
}
|
|
252
|
-
.awsui_calendar-
|
|
252
|
+
.awsui_calendar-date_1ykar_3o1tp_198:not(#\9)::after {
|
|
253
253
|
content: "";
|
|
254
254
|
position: absolute;
|
|
255
255
|
z-index: 1;
|
|
@@ -259,21 +259,21 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
259
259
|
inset-inline-end: calc(-1 * var(--border-item-width-yel47s, 2px));
|
|
260
260
|
background-color: transparent;
|
|
261
261
|
}
|
|
262
|
-
.awsui_calendar-
|
|
262
|
+
.awsui_calendar-date_1ykar_3o1tp_198 > .awsui_date-inner_1ykar_3o1tp_261:not(#\9) {
|
|
263
263
|
position: relative;
|
|
264
264
|
z-index: 1;
|
|
265
265
|
}
|
|
266
|
-
.awsui_calendar-
|
|
266
|
+
.awsui_calendar-date_1ykar_3o1tp_198:not(#\9):focus {
|
|
267
267
|
outline: none;
|
|
268
268
|
}
|
|
269
|
-
body[data-awsui-focus-visible=true] .awsui_calendar-
|
|
269
|
+
body[data-awsui-focus-visible=true] .awsui_calendar-date_1ykar_3o1tp_198:not(#\9):focus:focus {
|
|
270
270
|
position: relative;
|
|
271
271
|
}
|
|
272
|
-
body[data-awsui-focus-visible=true] .awsui_calendar-
|
|
272
|
+
body[data-awsui-focus-visible=true] .awsui_calendar-date_1ykar_3o1tp_198:not(#\9):focus:focus {
|
|
273
273
|
outline: 2px dotted transparent;
|
|
274
274
|
outline-offset: calc(var(--space-calendar-grid-focus-outline-gutter-g00bgj, -5px) - 1px);
|
|
275
275
|
}
|
|
276
|
-
body[data-awsui-focus-visible=true] .awsui_calendar-
|
|
276
|
+
body[data-awsui-focus-visible=true] .awsui_calendar-date_1ykar_3o1tp_198:not(#\9):focus:focus::before {
|
|
277
277
|
content: " ";
|
|
278
278
|
display: block;
|
|
279
279
|
position: absolute;
|
|
@@ -287,23 +287,23 @@ body[data-awsui-focus-visible=true] .awsui_calendar-date_1ykar_15kl7_198:not(#\9
|
|
|
287
287
|
border-end-end-radius: var(--border-radius-calendar-day-focus-ring-545h0w, 3px);
|
|
288
288
|
box-shadow: 0 0 0 2px var(--color-border-item-focused-b2ntyl, #0972d3);
|
|
289
289
|
}
|
|
290
|
-
body[data-awsui-focus-visible=true] .awsui_calendar-
|
|
290
|
+
body[data-awsui-focus-visible=true] .awsui_calendar-date_1ykar_3o1tp_198:not(#\9):focus:focus::before {
|
|
291
291
|
z-index: 2;
|
|
292
292
|
}
|
|
293
|
-
.awsui_calendar-date-
|
|
293
|
+
.awsui_calendar-date-selected_1ykar_3o1tp_239:not(#\9) {
|
|
294
294
|
border-color: transparent;
|
|
295
295
|
position: relative;
|
|
296
296
|
z-index: 2;
|
|
297
297
|
font-weight: 700;
|
|
298
298
|
}
|
|
299
|
-
body[data-awsui-focus-visible=true] .awsui_calendar-date-
|
|
299
|
+
body[data-awsui-focus-visible=true] .awsui_calendar-date-selected_1ykar_3o1tp_239:not(#\9):focus:focus {
|
|
300
300
|
position: relative;
|
|
301
301
|
}
|
|
302
|
-
body[data-awsui-focus-visible=true] .awsui_calendar-date-
|
|
302
|
+
body[data-awsui-focus-visible=true] .awsui_calendar-date-selected_1ykar_3o1tp_239:not(#\9):focus:focus {
|
|
303
303
|
outline: 2px dotted transparent;
|
|
304
304
|
outline-offset: calc(var(--space-calendar-grid-focus-outline-gutter-g00bgj, -5px) - 1px);
|
|
305
305
|
}
|
|
306
|
-
body[data-awsui-focus-visible=true] .awsui_calendar-date-
|
|
306
|
+
body[data-awsui-focus-visible=true] .awsui_calendar-date-selected_1ykar_3o1tp_239:not(#\9):focus:focus::before {
|
|
307
307
|
content: " ";
|
|
308
308
|
display: block;
|
|
309
309
|
position: absolute;
|
|
@@ -317,10 +317,10 @@ body[data-awsui-focus-visible=true] .awsui_calendar-date-selected_1ykar_15kl7_23
|
|
|
317
317
|
border-end-end-radius: var(--border-radius-calendar-day-focus-ring-545h0w, 3px);
|
|
318
318
|
box-shadow: 0 0 0 2px var(--color-border-calendar-grid-selected-focus-ring-thqa8y, #fbfbfb);
|
|
319
319
|
}
|
|
320
|
-
body[data-awsui-focus-visible=true] .awsui_calendar-date-
|
|
320
|
+
body[data-awsui-focus-visible=true] .awsui_calendar-date-selected_1ykar_3o1tp_239:not(#\9):focus:focus::before {
|
|
321
321
|
z-index: 2;
|
|
322
322
|
}
|
|
323
|
-
.awsui_calendar-date-
|
|
323
|
+
.awsui_calendar-date-selected_1ykar_3o1tp_239:not(#\9)::after {
|
|
324
324
|
border-start-start-radius: var(--border-radius-item-05df9h, 8px);
|
|
325
325
|
border-start-end-radius: var(--border-radius-item-05df9h, 8px);
|
|
326
326
|
border-end-start-radius: var(--border-radius-item-05df9h, 8px);
|
|
@@ -329,11 +329,11 @@ body[data-awsui-focus-visible=true] .awsui_calendar-date-selected_1ykar_15kl7_23
|
|
|
329
329
|
border-block: var(--border-item-width-yel47s, 2px) solid var(--color-background-control-checked-w517i0, #0972d3);
|
|
330
330
|
border-inline: var(--border-item-width-yel47s, 2px) solid var(--color-background-control-checked-w517i0, #0972d3);
|
|
331
331
|
}
|
|
332
|
-
.awsui_calendar-date-
|
|
332
|
+
.awsui_calendar-date-selected_1ykar_3o1tp_239 > .awsui_date-inner_1ykar_3o1tp_261:not(#\9) {
|
|
333
333
|
z-index: 2;
|
|
334
334
|
color: var(--color-background-control-default-qzruqy, #ffffff);
|
|
335
335
|
position: relative;
|
|
336
336
|
}
|
|
337
|
-
.awsui_calendar-
|
|
337
|
+
.awsui_calendar-row_1ykar_3o1tp_336:not(#\9):first-child > .awsui_calendar-date_1ykar_3o1tp_198 {
|
|
338
338
|
border-block-start: 1px solid var(--color-border-calendar-grid-u86q1u, transparent);
|
|
339
339
|
}
|
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"calendar": "
|
|
6
|
-
"awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-
|
|
7
|
-
"root": "
|
|
8
|
-
"calendar-inner": "awsui_calendar-
|
|
9
|
-
"calendar-header": "awsui_calendar-
|
|
10
|
-
"calendar-header-
|
|
11
|
-
"calendar-next-btn": "awsui_calendar-next-
|
|
12
|
-
"calendar-prev-btn": "awsui_calendar-prev-
|
|
13
|
-
"calendar-grid": "awsui_calendar-
|
|
14
|
-
"calendar-grid-cell": "awsui_calendar-grid-
|
|
15
|
-
"calendar-date-header": "awsui_calendar-date-
|
|
16
|
-
"calendar-date": "awsui_calendar-
|
|
17
|
-
"calendar-date-enabled": "awsui_calendar-date-
|
|
18
|
-
"calendar-date-current-page": "awsui_calendar-date-current-
|
|
19
|
-
"calendar-date-selected": "awsui_calendar-date-
|
|
20
|
-
"calendar-date-current": "awsui_calendar-date-
|
|
21
|
-
"date-inner": "awsui_date-
|
|
22
|
-
"calendar-row": "awsui_calendar-
|
|
5
|
+
"calendar": "awsui_calendar_1ykar_3o1tp_93",
|
|
6
|
+
"awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_1ykar_3o1tp_1",
|
|
7
|
+
"root": "awsui_root_1ykar_3o1tp_124",
|
|
8
|
+
"calendar-inner": "awsui_calendar-inner_1ykar_3o1tp_165",
|
|
9
|
+
"calendar-header": "awsui_calendar-header_1ykar_3o1tp_169",
|
|
10
|
+
"calendar-header-title": "awsui_calendar-header-title_1ykar_3o1tp_174",
|
|
11
|
+
"calendar-next-btn": "awsui_calendar-next-btn_1ykar_3o1tp_182",
|
|
12
|
+
"calendar-prev-btn": "awsui_calendar-prev-btn_1ykar_3o1tp_185",
|
|
13
|
+
"calendar-grid": "awsui_calendar-grid_1ykar_3o1tp_188",
|
|
14
|
+
"calendar-grid-cell": "awsui_calendar-grid-cell_1ykar_3o1tp_193",
|
|
15
|
+
"calendar-date-header": "awsui_calendar-date-header_1ykar_3o1tp_198",
|
|
16
|
+
"calendar-date": "awsui_calendar-date_1ykar_3o1tp_198",
|
|
17
|
+
"calendar-date-enabled": "awsui_calendar-date-enabled_1ykar_3o1tp_218",
|
|
18
|
+
"calendar-date-current-page": "awsui_calendar-date-current-page_1ykar_3o1tp_228",
|
|
19
|
+
"calendar-date-selected": "awsui_calendar-date-selected_1ykar_3o1tp_239",
|
|
20
|
+
"calendar-date-current": "awsui_calendar-date-current_1ykar_3o1tp_228",
|
|
21
|
+
"date-inner": "awsui_date-inner_1ykar_3o1tp_261",
|
|
22
|
+
"calendar-row": "awsui_calendar-row_1ykar_3o1tp_336"
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CalendarProps } from './interfaces';
|
|
2
|
+
export default function useCalendarLabels({ locale, i18nStrings, previousMonthAriaLabel, nextMonthAriaLabel, todayAriaLabel, }: {
|
|
3
|
+
locale: string;
|
|
4
|
+
i18nStrings?: CalendarProps.I18nStrings;
|
|
5
|
+
previousMonthAriaLabel?: string;
|
|
6
|
+
nextMonthAriaLabel?: string;
|
|
7
|
+
previousYearAriaLabel?: string;
|
|
8
|
+
todayAriaLabel?: string;
|
|
9
|
+
}): {
|
|
10
|
+
previousButtonLabel: string | undefined;
|
|
11
|
+
nextButtonLabel: string | undefined;
|
|
12
|
+
renderDate: (date: Date) => string;
|
|
13
|
+
renderDateAnnouncement: (date: Date, isCurrentDate: boolean) => string;
|
|
14
|
+
renderHeaderText: (date: Date) => string;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=use-calendar-labels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-calendar-labels.d.ts","sourceRoot":"lib/default/","sources":["calendar/use-calendar-labels.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,MAAM,EACN,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,GACf,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC;IACxC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;;;uBAY2B,IAAI;mCAEQ,IAAI,iBAAiB,OAAO;6BAQlC,IAAI;EASrC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { useInternalI18n } from '../i18n/context.js';
|
|
4
|
+
import { getDateLabel, renderMonthAndYear } from './utils/intl';
|
|
5
|
+
export default function useCalendarLabels({ locale, i18nStrings, previousMonthAriaLabel, nextMonthAriaLabel, todayAriaLabel, }) {
|
|
6
|
+
var _a, _b, _c;
|
|
7
|
+
const i18n = useInternalI18n('calendar');
|
|
8
|
+
const previousButtonLabel = i18n('previousMonthAriaLabel', (_a = i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.previousMonthAriaLabel) !== null && _a !== void 0 ? _a : previousMonthAriaLabel);
|
|
9
|
+
const nextButtonLabel = i18n('nextMonthAriaLabel', (_b = i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.nextMonthAriaLabel) !== null && _b !== void 0 ? _b : nextMonthAriaLabel);
|
|
10
|
+
const currentDateLabel = i18n('todayAriaLabel', (_c = i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.todayAriaLabel) !== null && _c !== void 0 ? _c : todayAriaLabel);
|
|
11
|
+
const renderDate = (date) => date.getDate().toString();
|
|
12
|
+
const renderDateAnnouncement = (date, isCurrentDate) => {
|
|
13
|
+
const formattedDate = getDateLabel(locale, date, 'short');
|
|
14
|
+
if (isCurrentDate && currentDateLabel) {
|
|
15
|
+
return formattedDate + '. ' + currentDateLabel;
|
|
16
|
+
}
|
|
17
|
+
return formattedDate;
|
|
18
|
+
};
|
|
19
|
+
const renderHeaderText = (date) => renderMonthAndYear(locale, date);
|
|
20
|
+
return {
|
|
21
|
+
previousButtonLabel,
|
|
22
|
+
nextButtonLabel,
|
|
23
|
+
renderDate,
|
|
24
|
+
renderDateAnnouncement,
|
|
25
|
+
renderHeaderText,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=use-calendar-labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-calendar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AAE,IAAI,CAAC,CAAC;IAE1E,OAAO;QACL,mBAAmB;QACnB,eAAe;QACf,UAAU;QACV,sBAAsB;QACtB,gBAAgB;KACjB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { CalendarProps } from './interfaces';\nimport { useInternalI18n } from '../i18n/context.js';\nimport { getDateLabel, renderMonthAndYear } from './utils/intl';\n\nexport default function useCalendarLabels({\n locale,\n i18nStrings,\n previousMonthAriaLabel,\n nextMonthAriaLabel,\n todayAriaLabel,\n}: {\n locale: string;\n i18nStrings?: CalendarProps.I18nStrings;\n previousMonthAriaLabel?: string;\n nextMonthAriaLabel?: string;\n previousYearAriaLabel?: string;\n todayAriaLabel?: string;\n}) {\n const i18n = useInternalI18n('calendar');\n\n const previousButtonLabel = i18n(\n 'previousMonthAriaLabel',\n i18nStrings?.previousMonthAriaLabel ?? previousMonthAriaLabel\n );\n\n const nextButtonLabel = i18n('nextMonthAriaLabel', i18nStrings?.nextMonthAriaLabel ?? nextMonthAriaLabel);\n\n const currentDateLabel = i18n('todayAriaLabel', i18nStrings?.todayAriaLabel ?? todayAriaLabel);\n\n const renderDate = (date: Date) => date.getDate().toString();\n\n const renderDateAnnouncement = (date: Date, isCurrentDate: boolean) => {\n const formattedDate = getDateLabel(locale, date, 'short');\n if (isCurrentDate && currentDateLabel) {\n return formattedDate + '. ' + currentDateLabel;\n }\n return formattedDate;\n };\n\n const renderHeaderText = (date: Date) => renderMonthAndYear(locale, date);\n\n return {\n previousButtonLabel,\n nextButtonLabel,\n renderDate,\n renderDateAnnouncement,\n renderHeaderText,\n };\n}\n"]}
|
|
@@ -2,5 +2,5 @@ export declare function moveNextDay(startDate: Date, isDateEnabled: (date: Date)
|
|
|
2
2
|
export declare function movePrevDay(startDate: Date, isDateEnabled: (date: Date) => boolean): Date;
|
|
3
3
|
export declare function moveNextWeek(startDate: Date, isDateEnabled: (date: Date) => boolean): Date;
|
|
4
4
|
export declare function movePrevWeek(startDate: Date, isDateEnabled: (date: Date) => boolean): Date;
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function getBaseDay(date: Date, isDateEnabled: (date: Date) => boolean): Date;
|
|
6
6
|
//# sourceMappingURL=navigation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.d.ts","sourceRoot":"lib/default/","sources":["calendar/utils/navigation.ts"],"names":[],"mappings":"AAIA,wBAAgB,WAAW,CAAC,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,GAAG,IAAI,CAEzF;AAED,wBAAgB,WAAW,CAAC,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,GAAG,IAAI,CAEzF;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,GAAG,IAAI,CAE1F;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,GAAG,IAAI,CAE1F;AAID,wBAAgB,
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"lib/default/","sources":["calendar/utils/navigation.ts"],"names":[],"mappings":"AAIA,wBAAgB,WAAW,CAAC,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,GAAG,IAAI,CAEzF;AAED,wBAAgB,WAAW,CAAC,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,GAAG,IAAI,CAEzF;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,GAAG,IAAI,CAE1F;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,GAAG,IAAI,CAE1F;AAID,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,QAQ5E"}
|
|
@@ -2,30 +2,29 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { addDays, differenceInYears, isSameMonth, startOfMonth } from 'date-fns';
|
|
4
4
|
export function moveNextDay(startDate, isDateEnabled) {
|
|
5
|
-
return
|
|
5
|
+
return moveDay(startDate, isDateEnabled, 1);
|
|
6
6
|
}
|
|
7
7
|
export function movePrevDay(startDate, isDateEnabled) {
|
|
8
|
-
return
|
|
8
|
+
return moveDay(startDate, isDateEnabled, -1);
|
|
9
9
|
}
|
|
10
10
|
export function moveNextWeek(startDate, isDateEnabled) {
|
|
11
|
-
return
|
|
11
|
+
return moveDay(startDate, isDateEnabled, 7);
|
|
12
12
|
}
|
|
13
13
|
export function movePrevWeek(startDate, isDateEnabled) {
|
|
14
|
-
return
|
|
14
|
+
return moveDay(startDate, isDateEnabled, -7);
|
|
15
15
|
}
|
|
16
|
-
// Returns first enabled date of the month corresponding the given date.
|
|
17
|
-
// If all month's days are disabled the first day of the month is returned.
|
|
18
|
-
export function
|
|
16
|
+
// Returns first enabled date of the month corresponding to the given date.
|
|
17
|
+
// If all month's days are disabled, the first day of the month is returned.
|
|
18
|
+
export function getBaseDay(date, isDateEnabled) {
|
|
19
19
|
const startDate = startOfMonth(date);
|
|
20
20
|
if (isDateEnabled(startDate)) {
|
|
21
21
|
return startDate;
|
|
22
22
|
}
|
|
23
|
-
const firstEnabledDate =
|
|
23
|
+
const firstEnabledDate = moveDay(startDate, isDateEnabled, 1);
|
|
24
24
|
return isSameMonth(startDate, firstEnabledDate) ? firstEnabledDate : startDate;
|
|
25
25
|
}
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
function moveDate(startDate, isDateEnabled, step) {
|
|
26
|
+
// If there is no active day in a year range, the start day is returned.
|
|
27
|
+
function moveDay(startDate, isDateEnabled, step) {
|
|
29
28
|
let current = addDays(startDate, step);
|
|
30
29
|
while (!isDateEnabled(current)) {
|
|
31
30
|
if (Math.abs(differenceInYears(startDate, current)) > 1) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.js","sourceRoot":"lib/default/","sources":["calendar/utils/navigation.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEjF,MAAM,UAAU,WAAW,CAAC,SAAe,EAAE,aAAsC;IACjF,OAAO,
|
|
1
|
+
{"version":3,"file":"navigation.js","sourceRoot":"lib/default/","sources":["calendar/utils/navigation.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEjF,MAAM,UAAU,WAAW,CAAC,SAAe,EAAE,aAAsC;IACjF,OAAO,OAAO,CAAC,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,SAAe,EAAE,aAAsC;IACjF,OAAO,OAAO,CAAC,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,SAAe,EAAE,aAAsC;IAClF,OAAO,OAAO,CAAC,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,SAAe,EAAE,aAAsC;IAClF,OAAO,OAAO,CAAC,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,2EAA2E;AAC3E,4EAA4E;AAC5E,MAAM,UAAU,UAAU,CAAC,IAAU,EAAE,aAAsC;IAC3E,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,aAAa,CAAC,SAAS,CAAC,EAAE;QAC5B,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC;IAC9D,OAAO,WAAW,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC;AACjF,CAAC;AAED,wEAAwE;AACxE,SAAS,OAAO,CAAC,SAAe,EAAE,aAAsC,EAAE,IAAY;IACpF,IAAI,OAAO,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAEvC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;QAC9B,IAAI,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE;YACvD,OAAO,SAAS,CAAC;SAClB;QACD,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;KAClC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { addDays, differenceInYears, isSameMonth, startOfMonth } from 'date-fns';\n\nexport function moveNextDay(startDate: Date, isDateEnabled: (date: Date) => boolean): Date {\n return moveDay(startDate, isDateEnabled, 1);\n}\n\nexport function movePrevDay(startDate: Date, isDateEnabled: (date: Date) => boolean): Date {\n return moveDay(startDate, isDateEnabled, -1);\n}\n\nexport function moveNextWeek(startDate: Date, isDateEnabled: (date: Date) => boolean): Date {\n return moveDay(startDate, isDateEnabled, 7);\n}\n\nexport function movePrevWeek(startDate: Date, isDateEnabled: (date: Date) => boolean): Date {\n return moveDay(startDate, isDateEnabled, -7);\n}\n\n// Returns first enabled date of the month corresponding to the given date.\n// If all month's days are disabled, the first day of the month is returned.\nexport function getBaseDay(date: Date, isDateEnabled: (date: Date) => boolean) {\n const startDate = startOfMonth(date);\n if (isDateEnabled(startDate)) {\n return startDate;\n }\n\n const firstEnabledDate = moveDay(startDate, isDateEnabled, 1);\n return isSameMonth(startDate, firstEnabledDate) ? firstEnabledDate : startDate;\n}\n\n// If there is no active day in a year range, the start day is returned.\nfunction moveDay(startDate: Date, isDateEnabled: (date: Date) => boolean, step: number): Date {\n let current = addDays(startDate, step);\n\n while (!isDateEnabled(current)) {\n if (Math.abs(differenceInYears(startDate, current)) > 1) {\n return startDate;\n }\n current = addDays(current, step);\n }\n\n return current;\n}\n"]}
|