@cloudscape-design/components-themeable 3.0.57 → 3.0.59
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/internal/scss/{date-picker → calendar}/motion.scss +0 -0
- package/lib/internal/scss/calendar/styles.scss +170 -0
- package/lib/internal/scss/date-picker/styles.scss +13 -163
- package/lib/internal/template/autosuggest/internal.d.ts.map +1 -1
- package/lib/internal/template/autosuggest/internal.js +1 -5
- package/lib/internal/template/autosuggest/internal.js.map +1 -1
- package/lib/internal/template/{date-picker/calendar → calendar}/grid/day/index.d.ts +1 -1
- package/lib/internal/template/calendar/grid/day/index.d.ts.map +1 -0
- package/lib/internal/template/{date-picker/calendar → calendar}/grid/day/index.js +1 -1
- package/lib/internal/template/calendar/grid/day/index.js.map +1 -0
- package/lib/internal/template/{date-picker/calendar → calendar}/grid/index.d.ts +2 -2
- package/lib/internal/template/calendar/grid/index.d.ts.map +1 -0
- package/lib/internal/template/{date-picker/calendar → calendar}/grid/index.js +2 -2
- package/lib/internal/template/calendar/grid/index.js.map +1 -0
- package/lib/internal/template/{date-picker/calendar → calendar}/header/button/index.d.ts +0 -0
- package/lib/internal/template/calendar/header/button/index.d.ts.map +1 -0
- package/lib/internal/template/{date-picker/calendar → calendar}/header/button/index.js +2 -2
- package/lib/internal/template/calendar/header/button/index.js.map +1 -0
- package/lib/internal/template/{date-picker/calendar → calendar}/header/index.d.ts +1 -2
- package/lib/internal/template/calendar/header/index.d.ts.map +1 -0
- package/lib/internal/template/{date-picker/calendar → calendar}/header/index.js +3 -3
- package/lib/internal/template/calendar/header/index.js.map +1 -0
- package/lib/internal/template/calendar/index.d.ts +4 -0
- package/lib/internal/template/calendar/index.d.ts.map +1 -0
- package/lib/internal/template/calendar/index.js +14 -0
- package/lib/internal/template/calendar/index.js.map +1 -0
- package/lib/internal/template/calendar/interfaces.d.ts +56 -0
- package/lib/internal/template/calendar/interfaces.d.ts.map +1 -0
- package/lib/internal/template/calendar/interfaces.js +4 -0
- package/lib/internal/template/calendar/interfaces.js.map +1 -0
- package/lib/internal/template/calendar/internal.d.ts +4 -0
- package/lib/internal/template/calendar/internal.d.ts.map +1 -0
- package/lib/internal/template/{date-picker/calendar/index.js → calendar/internal.js} +9 -13
- package/lib/internal/template/calendar/internal.js.map +1 -0
- package/lib/internal/template/calendar/styles.css.js +25 -0
- package/lib/internal/template/calendar/styles.scoped.css +291 -0
- package/lib/internal/template/calendar/styles.selectors.js +26 -0
- package/lib/internal/template/{date-picker/calendar → calendar}/utils/intl.d.ts +2 -2
- package/lib/internal/template/calendar/utils/intl.d.ts.map +1 -0
- package/lib/internal/template/{date-picker/calendar → calendar}/utils/intl.js +2 -0
- package/lib/internal/template/calendar/utils/intl.js.map +1 -0
- package/lib/internal/template/{date-picker/calendar → calendar}/utils/locales.d.ts +1 -1
- package/lib/internal/template/calendar/utils/locales.d.ts.map +1 -0
- package/lib/internal/template/{date-picker/calendar → calendar}/utils/locales.js +1 -1
- package/lib/internal/template/calendar/utils/locales.js.map +1 -0
- package/lib/internal/template/{date-picker/calendar → calendar}/utils/memoized-date.d.ts +0 -0
- package/lib/internal/template/calendar/utils/memoized-date.d.ts.map +1 -0
- package/lib/internal/template/{date-picker/calendar → calendar}/utils/memoized-date.js +1 -1
- package/lib/internal/template/calendar/utils/memoized-date.js.map +1 -0
- package/lib/internal/template/{date-picker/calendar → calendar}/utils/move-focus-handler.d.ts +1 -1
- package/lib/internal/template/calendar/utils/move-focus-handler.d.ts.map +1 -0
- package/lib/internal/template/{date-picker/calendar → calendar}/utils/move-focus-handler.js +0 -0
- package/lib/internal/template/calendar/utils/move-focus-handler.js.map +1 -0
- package/lib/internal/template/calendar/utils/rotate-day-indexes.d.ts +3 -0
- package/lib/internal/template/calendar/utils/rotate-day-indexes.d.ts.map +1 -0
- package/lib/internal/template/{date-picker/calendar → calendar}/utils/rotate-day-indexes.js +2 -0
- package/lib/internal/template/calendar/utils/rotate-day-indexes.js.map +1 -0
- package/lib/internal/template/date-picker/index.d.ts.map +1 -1
- package/lib/internal/template/date-picker/index.js +16 -10
- package/lib/internal/template/date-picker/index.js.map +1 -1
- package/lib/internal/template/date-picker/interfaces.d.ts +2 -44
- package/lib/internal/template/date-picker/interfaces.d.ts.map +1 -1
- package/lib/internal/template/date-picker/interfaces.js.map +1 -1
- package/lib/internal/template/date-picker/styles.css.js +7 -24
- package/lib/internal/template/date-picker/styles.scoped.css +21 -210
- package/lib/internal/template/date-picker/styles.selectors.js +7 -24
- package/lib/internal/template/date-range-picker/calendar/get-base-date.js +1 -1
- package/lib/internal/template/date-range-picker/calendar/get-base-date.js.map +1 -1
- package/lib/internal/template/date-range-picker/calendar/grids/day/index.js +1 -1
- package/lib/internal/template/date-range-picker/calendar/grids/day/index.js.map +1 -1
- package/lib/internal/template/date-range-picker/calendar/grids/grid.js +2 -2
- package/lib/internal/template/date-range-picker/calendar/grids/grid.js.map +1 -1
- package/lib/internal/template/date-range-picker/calendar/grids/index.d.ts +1 -1
- package/lib/internal/template/date-range-picker/calendar/grids/index.d.ts.map +1 -1
- package/lib/internal/template/date-range-picker/calendar/grids/index.js.map +1 -1
- package/lib/internal/template/date-range-picker/calendar/header/index.js +1 -1
- package/lib/internal/template/date-range-picker/calendar/header/index.js.map +1 -1
- package/lib/internal/template/date-range-picker/calendar/index.js +3 -3
- package/lib/internal/template/date-range-picker/calendar/index.js.map +1 -1
- package/lib/internal/template/date-range-picker/index.js +1 -1
- package/lib/internal/template/date-range-picker/index.js.map +1 -1
- package/lib/internal/template/internal/components/autosuggest-input/index.d.ts +1 -1
- package/lib/internal/template/internal/components/autosuggest-input/index.d.ts.map +1 -1
- package/lib/internal/template/internal/components/autosuggest-input/index.js +42 -6
- package/lib/internal/template/internal/components/autosuggest-input/index.js.map +1 -1
- package/lib/internal/template/internal/environment.js +1 -1
- package/lib/internal/template/property-filter/property-filter-autosuggest.d.ts.map +1 -1
- package/lib/internal/template/property-filter/property-filter-autosuggest.js +1 -5
- package/lib/internal/template/property-filter/property-filter-autosuggest.js.map +1 -1
- package/lib/internal/template/test-utils/dom/calendar/index.d.ts +16 -0
- package/lib/internal/template/test-utils/dom/calendar/index.js +53 -0
- package/lib/internal/template/test-utils/dom/calendar/index.js.map +1 -0
- package/lib/internal/template/test-utils/dom/date-picker/index.d.ts +2 -14
- package/lib/internal/template/test-utils/dom/date-picker/index.js +4 -33
- package/lib/internal/template/test-utils/dom/date-picker/index.js.map +1 -1
- package/lib/internal/template/test-utils/selectors/calendar/index.d.ts +16 -0
- package/lib/internal/template/test-utils/selectors/calendar/index.js +53 -0
- package/lib/internal/template/test-utils/selectors/calendar/index.js.map +1 -0
- package/lib/internal/template/test-utils/selectors/date-picker/index.d.ts +2 -14
- package/lib/internal/template/test-utils/selectors/date-picker/index.js +2 -31
- package/lib/internal/template/test-utils/selectors/date-picker/index.js.map +1 -1
- package/lib/internal/template/test-utils/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/lib/internal/template/date-picker/calendar/grid/day/index.d.ts.map +0 -1
- package/lib/internal/template/date-picker/calendar/grid/day/index.js.map +0 -1
- package/lib/internal/template/date-picker/calendar/grid/index.d.ts.map +0 -1
- package/lib/internal/template/date-picker/calendar/grid/index.js.map +0 -1
- package/lib/internal/template/date-picker/calendar/header/button/index.d.ts.map +0 -1
- package/lib/internal/template/date-picker/calendar/header/button/index.js.map +0 -1
- package/lib/internal/template/date-picker/calendar/header/index.d.ts.map +0 -1
- package/lib/internal/template/date-picker/calendar/header/index.js.map +0 -1
- package/lib/internal/template/date-picker/calendar/index.d.ts +0 -17
- package/lib/internal/template/date-picker/calendar/index.d.ts.map +0 -1
- package/lib/internal/template/date-picker/calendar/index.js.map +0 -1
- package/lib/internal/template/date-picker/calendar/utils/intl.d.ts.map +0 -1
- package/lib/internal/template/date-picker/calendar/utils/intl.js.map +0 -1
- package/lib/internal/template/date-picker/calendar/utils/locales.d.ts.map +0 -1
- package/lib/internal/template/date-picker/calendar/utils/locales.js.map +0 -1
- package/lib/internal/template/date-picker/calendar/utils/memoized-date.d.ts.map +0 -1
- package/lib/internal/template/date-picker/calendar/utils/memoized-date.js.map +0 -1
- package/lib/internal/template/date-picker/calendar/utils/move-focus-handler.d.ts.map +0 -1
- package/lib/internal/template/date-picker/calendar/utils/move-focus-handler.js.map +0 -1
- package/lib/internal/template/date-picker/calendar/utils/rotate-day-indexes.d.ts +0 -3
- package/lib/internal/template/date-picker/calendar/utils/rotate-day-indexes.d.ts.map +0 -1
- package/lib/internal/template/date-picker/calendar/utils/rotate-day-indexes.js.map +0 -1
|
@@ -4,10 +4,10 @@ import { __assign, __rest } from "tslib";
|
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import React, { useCallback, useRef, useState } from 'react';
|
|
6
6
|
import styles from './styles.css.js';
|
|
7
|
-
import
|
|
8
|
-
import { normalizeLocale } from '
|
|
9
|
-
import { getDateLabel } from '
|
|
10
|
-
import { memoizedDate } from '
|
|
7
|
+
import InternalCalendar from '../calendar/internal';
|
|
8
|
+
import { normalizeLocale } from '../calendar/utils/locales';
|
|
9
|
+
import { getDateLabel, renderMonthAndYear } from '../calendar/utils/intl';
|
|
10
|
+
import { memoizedDate } from '../calendar/utils/memoized-date';
|
|
11
11
|
import { KeyCode } from '../internal/keycode';
|
|
12
12
|
import { fireNonCancelableEvent } from '../internal/events';
|
|
13
13
|
import Dropdown from '../internal/components/dropdown';
|
|
@@ -22,6 +22,7 @@ import useBaseComponent from '../internal/hooks/use-base-component';
|
|
|
22
22
|
import { useUniqueId } from '../internal/hooks/use-unique-id';
|
|
23
23
|
import { useMergeRefs } from '../internal/hooks/use-merge-refs';
|
|
24
24
|
import FocusLock from '../internal/components/focus-lock';
|
|
25
|
+
import useFocusVisible from '../internal/hooks/focus-visible/index.js';
|
|
25
26
|
var DatePicker = React.forwardRef(function (_a, ref) {
|
|
26
27
|
var _b = _a.locale, locale = _b === void 0 ? '' : _b, startOfWeek = _a.startOfWeek, isDateEnabled = _a.isDateEnabled, nextMonthAriaLabel = _a.nextMonthAriaLabel, previousMonthAriaLabel = _a.previousMonthAriaLabel, todayAriaLabel = _a.todayAriaLabel, _c = _a.placeholder, placeholder = _c === void 0 ? '' : _c, _d = _a.value, value = _d === void 0 ? '' : _d, _e = _a.readOnly, readOnly = _e === void 0 ? false : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, onBlur = _a.onBlur, _g = _a.autoFocus, autoFocus = _g === void 0 ? false : _g, onChange = _a.onChange, onFocus = _a.onFocus, name = _a.name, ariaLabel = _a.ariaLabel, ariaRequired = _a.ariaRequired, ariaLabelledby = _a.ariaLabelledby, ariaDescribedby = _a.ariaDescribedby, controlId = _a.controlId, invalid = _a.invalid, openCalendarAriaLabel = _a.openCalendarAriaLabel, expandToViewport = _a.expandToViewport, rest = __rest(_a, ["locale", "startOfWeek", "isDateEnabled", "nextMonthAriaLabel", "previousMonthAriaLabel", "todayAriaLabel", "placeholder", "value", "readOnly", "disabled", "onBlur", "autoFocus", "onChange", "onFocus", "name", "ariaLabel", "ariaRequired", "ariaLabelledby", "ariaDescribedby", "controlId", "invalid", "openCalendarAriaLabel", "expandToViewport"]);
|
|
27
28
|
var __internalRootRef = useBaseComponent('DatePicker').__internalRootRef;
|
|
@@ -29,11 +30,13 @@ var DatePicker = React.forwardRef(function (_a, ref) {
|
|
|
29
30
|
var baseProps = getBaseProps(rest);
|
|
30
31
|
var _h = useState(false), isDropDownOpen = _h[0], setIsDropDownOpen = _h[1];
|
|
31
32
|
var normalizedLocale = normalizeLocale('DatePicker', locale);
|
|
33
|
+
var focusVisible = useFocusVisible();
|
|
32
34
|
var internalInputRef = useRef(null);
|
|
33
35
|
var buttonRef = useRef(null);
|
|
34
36
|
useForwardFocus(ref, internalInputRef);
|
|
35
37
|
var rootRef = useRef(null);
|
|
36
38
|
var dropdownId = useUniqueId('calender');
|
|
39
|
+
var calendarDescriptionId = useUniqueId('calendar-description-');
|
|
37
40
|
var mergedRef = useMergeRefs(rootRef, __internalRootRef);
|
|
38
41
|
useFocusTracker({ rootRef: rootRef, onBlur: onBlur, onFocus: onFocus, viewportId: expandToViewport ? dropdownId : '' });
|
|
39
42
|
var onDropdownCloseHandler = useCallback(function () { return setIsDropDownOpen(false); }, [setIsDropDownOpen]);
|
|
@@ -58,6 +61,7 @@ var DatePicker = React.forwardRef(function (_a, ref) {
|
|
|
58
61
|
}
|
|
59
62
|
};
|
|
60
63
|
var memoizedValue = memoizedDate('value', value);
|
|
64
|
+
var baseDate = memoizedValue || new Date();
|
|
61
65
|
var DateInputElement = (React.createElement("div", { className: styles['date-picker-trigger'] },
|
|
62
66
|
React.createElement("div", { className: styles['date-picker-input'] },
|
|
63
67
|
React.createElement(InternalDateInput, { name: name, invalid: invalid, controlId: controlId, ariaLabelledby: ariaLabelledby, ariaDescribedby: ariaDescribedby, ariaLabel: ariaLabel, ariaRequired: ariaRequired, value: value, disabled: disabled, readOnly: readOnly, onChange: onInputChangeHandler, onBlur: onInputBlurHandler, placeholder: placeholder, ref: internalInputRef, autoFocus: autoFocus })),
|
|
@@ -74,12 +78,14 @@ var DatePicker = React.forwardRef(function (_a, ref) {
|
|
|
74
78
|
};
|
|
75
79
|
return (React.createElement("div", __assign({}, baseProps, { ref: mergedRef, onKeyDown: onWrapperKeyDownHandler }),
|
|
76
80
|
React.createElement(Dropdown, { stretchWidth: true, stretchHeight: true, open: isDropDownOpen, onDropdownClose: onDropdownCloseHandler, onMouseDown: handleMouseDown, trigger: DateInputElement, expandToViewport: expandToViewport, scrollable: false, dropdownId: dropdownId }, isDropDownOpen && (React.createElement(FocusLock, { autoFocus: true },
|
|
77
|
-
React.createElement(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
React.createElement("div", __assign({}, focusVisible, { tabIndex: 0, className: styles.calendar, role: "application", "aria-describedby": calendarDescriptionId }),
|
|
82
|
+
React.createElement(InternalCalendar, { value: value, onChange: function (e) {
|
|
83
|
+
var _a;
|
|
84
|
+
fireNonCancelableEvent(onChange, e.detail);
|
|
85
|
+
(_a = buttonRef === null || buttonRef === void 0 ? void 0 : buttonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
86
|
+
setIsDropDownOpen(false);
|
|
87
|
+
}, locale: normalizedLocale, startOfWeek: startOfWeek, isDateEnabled: isDateEnabled, todayAriaLabel: todayAriaLabel, nextMonthAriaLabel: nextMonthAriaLabel, previousMonthAriaLabel: previousMonthAriaLabel }),
|
|
88
|
+
React.createElement("div", { id: calendarDescriptionId, className: styles['screenreader-only'], "aria-live": "polite" }, renderMonthAndYear(normalizedLocale, baseDate))))))));
|
|
83
89
|
});
|
|
84
90
|
applyDisplayName(DatePicker, 'DatePicker');
|
|
85
91
|
export default DatePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/date-picker/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,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,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AAC3C,eAAe,UAAU,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { Ref, useCallback, useRef, useState } from 'react';\nimport styles from './styles.css.js';\nimport { DatePickerProps } from './interfaces';\nimport Calendar from './calendar';\nimport { normalizeLocale } from './calendar/utils/locales';\nimport { getDateLabel } from './calendar/utils/intl';\nimport { memoizedDate } from './calendar/utils/memoized-date';\nimport { InputProps } from '../input/interfaces';\nimport { KeyCode } from '../internal/keycode';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport Dropdown from '../internal/components/dropdown';\nimport InternalDateInput from '../date-input/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name.js';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { useFocusTracker } from '../internal/hooks/use-focus-tracker.js';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { ButtonProps } from '../button/interfaces';\nimport { InternalButton } from '../button/internal';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport FocusLock from '../internal/components/focus-lock';\n\nexport { DatePickerProps };\n\nconst DatePicker = React.forwardRef(\n (\n {\n locale = '',\n startOfWeek,\n isDateEnabled,\n nextMonthAriaLabel,\n previousMonthAriaLabel,\n todayAriaLabel,\n placeholder = '',\n value = '',\n readOnly = false,\n disabled = false,\n onBlur,\n autoFocus = false,\n onChange,\n onFocus,\n name,\n ariaLabel,\n ariaRequired,\n ariaLabelledby,\n ariaDescribedby,\n controlId,\n invalid,\n openCalendarAriaLabel,\n expandToViewport,\n ...rest\n }: DatePickerProps,\n ref: Ref<DatePickerProps.Ref>\n ) => {\n const { __internalRootRef } = useBaseComponent('DatePicker');\n checkControlled('DatePicker', 'value', value, 'onChange', onChange);\n\n const baseProps = getBaseProps(rest);\n const [isDropDownOpen, setIsDropDownOpen] = useState<boolean>(false);\n const normalizedLocale = normalizeLocale('DatePicker', locale);\n\n const internalInputRef = useRef<HTMLInputElement>(null);\n const buttonRef = useRef<ButtonProps.Ref>(null);\n useForwardFocus(ref, internalInputRef);\n\n const rootRef = useRef<HTMLDivElement>(null);\n const dropdownId = useUniqueId('calender');\n const mergedRef = useMergeRefs(rootRef, __internalRootRef);\n\n useFocusTracker({ rootRef, onBlur, onFocus, viewportId: expandToViewport ? dropdownId : '' });\n\n const onDropdownCloseHandler = useCallback(() => setIsDropDownOpen(false), [setIsDropDownOpen]);\n\n const onButtonClickHandler = () => {\n if (!isDropDownOpen) {\n setIsDropDownOpen(true);\n }\n };\n\n const onWrapperKeyDownHandler = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.keyCode === KeyCode.escape && isDropDownOpen) {\n buttonRef.current?.focus();\n setIsDropDownOpen(false);\n }\n };\n\n const onInputChangeHandler: InputProps['onChange'] = event => {\n fireNonCancelableEvent(onChange, { value: event.detail.value });\n };\n\n const onInputBlurHandler: InputProps['onBlur'] = () => {\n if (!isDropDownOpen) {\n setIsDropDownOpen(false);\n }\n };\n\n const memoizedValue = memoizedDate('value', value);\n\n const DateInputElement = (\n <div className={styles['date-picker-trigger']}>\n <div className={styles['date-picker-input']}>\n <InternalDateInput\n name={name}\n invalid={invalid}\n controlId={controlId}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n ariaLabel={ariaLabel}\n ariaRequired={ariaRequired}\n value={value}\n disabled={disabled}\n readOnly={readOnly}\n onChange={onInputChangeHandler}\n onBlur={onInputBlurHandler}\n placeholder={placeholder}\n ref={internalInputRef}\n autoFocus={autoFocus}\n />\n </div>\n <div>\n <InternalButton\n iconName=\"calendar\"\n className={styles['open-calendar-button']}\n onClick={onButtonClickHandler}\n ref={buttonRef}\n ariaLabel={\n openCalendarAriaLabel &&\n openCalendarAriaLabel(value.length === 10 ? getDateLabel(normalizedLocale, memoizedValue!) : null)\n }\n disabled={disabled || readOnly}\n formAction=\"none\"\n />\n </div>\n </div>\n );\n\n baseProps.className = clsx(baseProps.className, styles.root, styles['date-picker-container']);\n\n if (readOnly || disabled) {\n return <div {...baseProps}>{DateInputElement}</div>;\n }\n\n const handleMouseDown = (event: React.MouseEvent) => {\n // prevent currently focused element from losing it\n event.preventDefault();\n };\n\n return (\n <div {...baseProps} ref={mergedRef} onKeyDown={onWrapperKeyDownHandler}>\n <Dropdown\n stretchWidth={true}\n stretchHeight={true}\n open={isDropDownOpen}\n onDropdownClose={onDropdownCloseHandler}\n onMouseDown={handleMouseDown}\n trigger={DateInputElement}\n expandToViewport={expandToViewport}\n scrollable={false}\n dropdownId={dropdownId}\n >\n {isDropDownOpen && (\n <FocusLock autoFocus={true}>\n <Calendar\n value={value}\n onChange={e => {\n fireNonCancelableEvent(onChange, e.detail);\n buttonRef?.current?.focus();\n setIsDropDownOpen(false);\n }}\n locale={normalizedLocale}\n startOfWeek={startOfWeek}\n isDateEnabled={isDateEnabled}\n todayAriaLabel={todayAriaLabel}\n nextMonthAriaLabel={nextMonthAriaLabel}\n previousMonthAriaLabel={previousMonthAriaLabel}\n />\n </FocusLock>\n )}\n </Dropdown>\n </div>\n );\n }\n);\n\napplyDisplayName(DatePicker, 'DatePicker');\nexport default DatePicker;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/date-picker/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,gBAAgB,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM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AAgB,EACzB,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,KAAK,EACjB,UAAU,EAAE,UAAU,IAErB,cAAc,IAAI,CACjB,oBAAC,SAAS,IAAC,SAAS,EAAE,IAAI;YACxB,wCACM,YAAY,IAChB,QAAQ,EAAE,CAAC,EACX,SAAS,EAAE,MAAM,CAAC,QAAQ,EAC1B,IAAI,EAAC,aAAa,sBACA,qBAAqB;gBAEvC,oBAAC,gBAAgB,IACf,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,UAAA,CAAC;;wBACT,sBAAsB,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;wBAC3C,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,0CAAE,KAAK,EAAE,CAAC;wBAC5B,iBAAiB,CAAC,KAAK,CAAC,CAAC;oBAC3B,CAAC,EACD,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,EAC9B,kBAAkB,EAAE,kBAAkB,EACtC,sBAAsB,EAAE,sBAAsB,GAC9C;gBACF,6BAAK,EAAE,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,CAAC,mBAAmB,CAAC,eAAY,QAAQ,IACvF,kBAAkB,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAC3C,CACF,CACI,CACb,CACQ,CACP,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AAC3C,eAAe,UAAU,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { Ref, useCallback, useRef, useState } from 'react';\nimport styles from './styles.css.js';\nimport { DatePickerProps } from './interfaces';\nimport InternalCalendar from '../calendar/internal';\nimport { normalizeLocale } from '../calendar/utils/locales';\nimport { getDateLabel, renderMonthAndYear } from '../calendar/utils/intl';\nimport { memoizedDate } from '../calendar/utils/memoized-date';\nimport { InputProps } from '../input/interfaces';\nimport { KeyCode } from '../internal/keycode';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport Dropdown from '../internal/components/dropdown';\nimport InternalDateInput from '../date-input/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name.js';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { useFocusTracker } from '../internal/hooks/use-focus-tracker.js';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { ButtonProps } from '../button/interfaces';\nimport { InternalButton } from '../button/internal';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport FocusLock from '../internal/components/focus-lock';\nimport useFocusVisible from '../internal/hooks/focus-visible/index.js';\n\nexport { DatePickerProps };\n\nconst DatePicker = React.forwardRef(\n (\n {\n locale = '',\n startOfWeek,\n isDateEnabled,\n nextMonthAriaLabel,\n previousMonthAriaLabel,\n todayAriaLabel,\n placeholder = '',\n value = '',\n readOnly = false,\n disabled = false,\n onBlur,\n autoFocus = false,\n onChange,\n onFocus,\n name,\n ariaLabel,\n ariaRequired,\n ariaLabelledby,\n ariaDescribedby,\n controlId,\n invalid,\n openCalendarAriaLabel,\n expandToViewport,\n ...rest\n }: DatePickerProps,\n ref: Ref<DatePickerProps.Ref>\n ) => {\n const { __internalRootRef } = useBaseComponent('DatePicker');\n checkControlled('DatePicker', 'value', value, 'onChange', onChange);\n\n const baseProps = getBaseProps(rest);\n const [isDropDownOpen, setIsDropDownOpen] = useState<boolean>(false);\n const normalizedLocale = normalizeLocale('DatePicker', locale);\n const focusVisible = useFocusVisible();\n\n const internalInputRef = useRef<HTMLInputElement>(null);\n const buttonRef = useRef<ButtonProps.Ref>(null);\n useForwardFocus(ref, internalInputRef);\n\n const rootRef = useRef<HTMLDivElement>(null);\n const dropdownId = useUniqueId('calender');\n const calendarDescriptionId = useUniqueId('calendar-description-');\n const mergedRef = useMergeRefs(rootRef, __internalRootRef);\n\n useFocusTracker({ rootRef, onBlur, onFocus, viewportId: expandToViewport ? dropdownId : '' });\n\n const onDropdownCloseHandler = useCallback(() => setIsDropDownOpen(false), [setIsDropDownOpen]);\n\n const onButtonClickHandler = () => {\n if (!isDropDownOpen) {\n setIsDropDownOpen(true);\n }\n };\n\n const onWrapperKeyDownHandler = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.keyCode === KeyCode.escape && isDropDownOpen) {\n buttonRef.current?.focus();\n setIsDropDownOpen(false);\n }\n };\n\n const onInputChangeHandler: InputProps['onChange'] = event => {\n fireNonCancelableEvent(onChange, { value: event.detail.value });\n };\n\n const onInputBlurHandler: InputProps['onBlur'] = () => {\n if (!isDropDownOpen) {\n setIsDropDownOpen(false);\n }\n };\n\n const memoizedValue = memoizedDate('value', value);\n const baseDate = memoizedValue || new Date();\n\n const DateInputElement = (\n <div className={styles['date-picker-trigger']}>\n <div className={styles['date-picker-input']}>\n <InternalDateInput\n name={name}\n invalid={invalid}\n controlId={controlId}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n ariaLabel={ariaLabel}\n ariaRequired={ariaRequired}\n value={value}\n disabled={disabled}\n readOnly={readOnly}\n onChange={onInputChangeHandler}\n onBlur={onInputBlurHandler}\n placeholder={placeholder}\n ref={internalInputRef}\n autoFocus={autoFocus}\n />\n </div>\n <div>\n <InternalButton\n iconName=\"calendar\"\n className={styles['open-calendar-button']}\n onClick={onButtonClickHandler}\n ref={buttonRef}\n ariaLabel={\n openCalendarAriaLabel &&\n openCalendarAriaLabel(value.length === 10 ? getDateLabel(normalizedLocale, memoizedValue!) : null)\n }\n disabled={disabled || readOnly}\n formAction=\"none\"\n />\n </div>\n </div>\n );\n\n baseProps.className = clsx(baseProps.className, styles.root, styles['date-picker-container']);\n\n if (readOnly || disabled) {\n return <div {...baseProps}>{DateInputElement}</div>;\n }\n\n const handleMouseDown = (event: React.MouseEvent) => {\n // prevent currently focused element from losing it\n event.preventDefault();\n };\n\n return (\n <div {...baseProps} ref={mergedRef} onKeyDown={onWrapperKeyDownHandler}>\n <Dropdown\n stretchWidth={true}\n stretchHeight={true}\n open={isDropDownOpen}\n onDropdownClose={onDropdownCloseHandler}\n onMouseDown={handleMouseDown}\n trigger={DateInputElement}\n expandToViewport={expandToViewport}\n scrollable={false}\n dropdownId={dropdownId}\n >\n {isDropDownOpen && (\n <FocusLock autoFocus={true}>\n <div\n {...focusVisible}\n tabIndex={0}\n className={styles.calendar}\n role=\"application\"\n aria-describedby={calendarDescriptionId}\n >\n <InternalCalendar\n value={value}\n onChange={e => {\n fireNonCancelableEvent(onChange, e.detail);\n buttonRef?.current?.focus();\n setIsDropDownOpen(false);\n }}\n locale={normalizedLocale}\n startOfWeek={startOfWeek}\n isDateEnabled={isDateEnabled}\n todayAriaLabel={todayAriaLabel}\n nextMonthAriaLabel={nextMonthAriaLabel}\n previousMonthAriaLabel={previousMonthAriaLabel}\n />\n <div id={calendarDescriptionId} className={styles['screenreader-only']} aria-live=\"polite\">\n {renderMonthAndYear(normalizedLocale, baseDate)}\n </div>\n </div>\n </FocusLock>\n )}\n </Dropdown>\n </div>\n );\n }\n);\n\napplyDisplayName(DatePicker, 'DatePicker');\nexport default DatePicker;\n"]}
|
|
@@ -2,50 +2,8 @@ import { BaseComponentProps } from '../internal/base-component';
|
|
|
2
2
|
import { FormFieldValidationControlProps } from '../internal/context/form-field-context';
|
|
3
3
|
import { ExpandToViewport } from '../internal/components/dropdown/interfaces';
|
|
4
4
|
import { NonCancelableEventHandler } from '../internal/events';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* The current input value, in YYYY-MM-DD format.
|
|
8
|
-
*/
|
|
9
|
-
value: string;
|
|
10
|
-
/**
|
|
11
|
-
* Defines whether a particular date is enabled in the calendar or not.
|
|
12
|
-
* If you disable a date in the calendar, users can still enter this date using a keyboard.
|
|
13
|
-
* We recommend that you also validate these constraints on the client-side and server-side
|
|
14
|
-
* as you would for other form elements.
|
|
15
|
-
* @param date
|
|
16
|
-
*/
|
|
17
|
-
isDateEnabled?: DatePickerProps.IsDateEnabledFunction;
|
|
18
|
-
/**
|
|
19
|
-
* Specifies the locale to use to render month names and determine the starting day of the week.
|
|
20
|
-
* If you don't provide this, the locale is determined by the page and browser locales.
|
|
21
|
-
* Supported values and formats are listed in the
|
|
22
|
-
* [JavaScript Intl API specification](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
|
|
23
|
-
*/
|
|
24
|
-
locale?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Determines the starting day of the week. The values 0-6 map to Sunday-Saturday.
|
|
27
|
-
* By default the starting day of the week is defined by the locale, but you can use this property to override it.
|
|
28
|
-
*/
|
|
29
|
-
startOfWeek?: number;
|
|
30
|
-
/**
|
|
31
|
-
* Used as part of the `aria-label` for today's date in the calendar.
|
|
32
|
-
*/
|
|
33
|
-
todayAriaLabel: string;
|
|
34
|
-
/**
|
|
35
|
-
* Specifies an `aria-label` for the 'next month' button.
|
|
36
|
-
*/
|
|
37
|
-
nextMonthAriaLabel: string;
|
|
38
|
-
/**
|
|
39
|
-
* Specifies an `aria-label` for the 'previous month' button.
|
|
40
|
-
*/
|
|
41
|
-
previousMonthAriaLabel: string;
|
|
42
|
-
/**
|
|
43
|
-
* Called whenever a user changes the input value (by typing, pasting, or selecting a value).
|
|
44
|
-
* The event `detail` contains the current value of the field.
|
|
45
|
-
*/
|
|
46
|
-
onChange?: NonCancelableEventHandler<DatePickerProps.ChangeDetail>;
|
|
47
|
-
}
|
|
48
|
-
export interface DatePickerProps extends BaseComponentProps, FormFieldValidationControlProps, ExpandToViewport, DatePickerBaseProps {
|
|
5
|
+
import { CalendarProps } from '../calendar/interfaces';
|
|
6
|
+
export interface DatePickerProps extends BaseComponentProps, FormFieldValidationControlProps, ExpandToViewport, CalendarProps {
|
|
49
7
|
/**
|
|
50
8
|
* Specifies the placeholder text rendered when the value is an empty string.
|
|
51
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/date-picker/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/date-picker/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,MAAM,WAAW,eACf,SAAQ,kBAAkB,EACxB,+BAA+B,EAC/B,gBAAgB,EAChB,aAAa;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,eAAe,CAAC,qBAAqB,CAAC;IAE9D;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,OAAO,CAAC,EAAE,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAE1C;;OAEG;IACH,MAAM,CAAC,EAAE,yBAAyB,CAAC,IAAI,CAAC,CAAC;CAC1C;AAED,yBAAiB,eAAe,CAAC;IAC/B,UAAiB,YAAY;QAC3B;;WAEG;QACH,KAAK,EAAE,MAAM,CAAC;KACf;IAED,UAAiB,qBAAqB;QACpC,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC;KACvB;IAED,UAAiB,qBAAqB;QACpC,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC;KACvC;IAED,UAAiB,GAAG;QAClB;;WAEG;QACH,KAAK,IAAI,IAAI,CAAC;KACf;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/date-picker/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport { NonCancelableEventHandler } from '../internal/events';\
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/date-picker/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { ExpandToViewport } from '../internal/components/dropdown/interfaces';\nimport { NonCancelableEventHandler } from '../internal/events';\nimport { CalendarProps } from '../calendar/interfaces';\n\nexport interface DatePickerProps\n extends BaseComponentProps,\n FormFieldValidationControlProps,\n ExpandToViewport,\n CalendarProps {\n /**\n * Specifies the placeholder text rendered when the value is an empty string.\n */\n placeholder?: string;\n\n /**\n * Specifies a function that generates the `aria-label` for the 'open calendar' button. The `selectedDate` parameter is\n * a human-readable localised string representing the current value of the input.\n * (for example, ``selectedDate => 'Choose Date' + (selectedDate ? `, selected date is ${selectedDate}` : '')``)\n */\n openCalendarAriaLabel?: DatePickerProps.OpenCalendarAriaLabel;\n\n /**\n * Specifies the name of the control used in HTML forms.\n */\n name?: string;\n\n /**\n * Specifies if the control is disabled, which prevents the\n * user from modifying the value and prevents the value from\n * being included in a form submission. A disabled control can't\n * receive focus.\n */\n disabled?: boolean;\n\n /**\n * Specifies if the control is read only, which prevents the\n * user from modifying the value but includes it in a form\n * submission. A read-only control can receive focus.\n *\n * Do not use read-only inputs outside of a form.\n */\n readOnly?: boolean;\n\n /**\n * Indicates whether the control should be focused as\n * soon as the page loads, which enables the user to\n * start typing without having to manually focus the control. Don't\n * use this option on pages where the control may be\n * scrolled out of the viewport.\n */\n autoFocus?: boolean;\n\n /**\n * Adds an `aria-label` to the native control.\n *\n * Use this if you don't have a visible label for this control.\n */\n ariaLabel?: string;\n\n /**\n * Specifies whether to add `aria-required` to the native control.\n */\n ariaRequired?: boolean;\n\n /**\n * Called when input focus is moved to the UI control.\n */\n onFocus?: NonCancelableEventHandler<null>;\n\n /**\n * Called when input focus is removed from the UI control.\n */\n onBlur?: NonCancelableEventHandler<null>;\n}\n\nexport namespace DatePickerProps {\n export interface ChangeDetail {\n /**\n * The new value of this date-picker.\n */\n value: string;\n }\n\n export interface IsDateEnabledFunction {\n (date: Date): boolean;\n }\n\n export interface OpenCalendarAriaLabel {\n (selectedDate: string | null): string;\n }\n\n export interface Ref {\n /**\n * Sets the browser focus on the UI control\n */\n focus(): void;\n }\n}\n"]}
|
|
@@ -1,29 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"date-picker-container": "awsui_date-picker-
|
|
8
|
-
"date-picker-trigger": "awsui_date-picker-
|
|
9
|
-
"date-picker-input": "awsui_date-picker-
|
|
10
|
-
"open-calendar-button": "awsui_open-calendar-
|
|
11
|
-
"calendar-inner": "awsui_calendar-inner_145pa_hegy7_165",
|
|
12
|
-
"calendar-header": "awsui_calendar-header_145pa_hegy7_168",
|
|
13
|
-
"calendar-header-month": "awsui_calendar-header-month_145pa_hegy7_173",
|
|
14
|
-
"calendar-next-month-btn": "awsui_calendar-next-month-btn_145pa_hegy7_179",
|
|
15
|
-
"calendar-prev-month-btn": "awsui_calendar-prev-month-btn_145pa_hegy7_182",
|
|
16
|
-
"calendar-day-names": "awsui_calendar-day-names_145pa_hegy7_185",
|
|
17
|
-
"calendar-day-name": "awsui_calendar-day-name_145pa_hegy7_185",
|
|
18
|
-
"calendar-dates": "awsui_calendar-dates_145pa_hegy7_200",
|
|
19
|
-
"calendar-week": "awsui_calendar-week_145pa_hegy7_203",
|
|
20
|
-
"calendar-day": "awsui_calendar-day_145pa_hegy7_185",
|
|
21
|
-
"calendar-day-in-last-week": "awsui_calendar-day-in-last-week_145pa_hegy7_222",
|
|
22
|
-
"calendar-day-focusable": "awsui_calendar-day-focusable_145pa_hegy7_225",
|
|
23
|
-
"calendar-day-enabled": "awsui_calendar-day-enabled_145pa_hegy7_228",
|
|
24
|
-
"calendar-day-current-month": "awsui_calendar-day-current-month_145pa_hegy7_232",
|
|
25
|
-
"calendar-day-selected": "awsui_calendar-day-selected_145pa_hegy7_239",
|
|
26
|
-
"calendar-day-today": "awsui_calendar-day-today_145pa_hegy7_243",
|
|
27
|
-
"day-inner": "awsui_day-inner_145pa_hegy7_255"
|
|
4
|
+
"root": "awsui_root_145pa_1uq9r_93",
|
|
5
|
+
"calendar": "awsui_calendar_145pa_1uq9r_104",
|
|
6
|
+
"screenreader-only": "awsui_screenreader-only_145pa_1uq9r_114",
|
|
7
|
+
"date-picker-container": "awsui_date-picker-container_145pa_1uq9r_120",
|
|
8
|
+
"date-picker-trigger": "awsui_date-picker-trigger_145pa_1uq9r_125",
|
|
9
|
+
"date-picker-input": "awsui_date-picker-input_145pa_1uq9r_129",
|
|
10
|
+
"open-calendar-button": "awsui_open-calendar-button_145pa_1uq9r_134"
|
|
28
11
|
};
|
|
29
12
|
|
|
@@ -90,34 +90,7 @@ 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-0_145pa_hegy7_1 var(--motion-duration-show-quick-tyaalm, 135ms) var(--motion-easing-show-quick-1fcgbv, ease-out);
|
|
95
|
-
animation-fill-mode: both;
|
|
96
|
-
}
|
|
97
|
-
@keyframes awsui_awsui-motion-fade-in-0_145pa_hegy7_1 {
|
|
98
|
-
from {
|
|
99
|
-
opacity: 0;
|
|
100
|
-
}
|
|
101
|
-
to {
|
|
102
|
-
opacity: 1;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
@media (prefers-reduced-motion: reduce) {
|
|
106
|
-
.awsui_calendar_145pa_hegy7_93:not(#\9) {
|
|
107
|
-
animation: none;
|
|
108
|
-
transition: none;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
.awsui-motion-disabled .awsui_calendar_145pa_hegy7_93:not(#\9), .awsui-mode-entering .awsui_calendar_145pa_hegy7_93:not(#\9) {
|
|
112
|
-
animation: none;
|
|
113
|
-
transition: none;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/*
|
|
117
|
-
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
118
|
-
SPDX-License-Identifier: Apache-2.0
|
|
119
|
-
*/
|
|
120
|
-
.awsui_root_145pa_hegy7_120:not(#\9) {
|
|
93
|
+
.awsui_root_145pa_1uq9r_93:not(#\9) {
|
|
121
94
|
/* stylelint-disable-next-line plugin/no-unsupported-browser-features */
|
|
122
95
|
border-collapse: separate;
|
|
123
96
|
border-spacing: 0;
|
|
@@ -154,198 +127,36 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
154
127
|
font-family: var(--font-family-base-mylvzb, "Noto Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
|
|
155
128
|
}
|
|
156
129
|
|
|
157
|
-
.
|
|
130
|
+
.awsui_calendar_145pa_1uq9r_104:not(#\9):focus {
|
|
131
|
+
outline: none;
|
|
132
|
+
}
|
|
133
|
+
.awsui_calendar_145pa_1uq9r_104[data-awsui-focus-visible=true]:not(#\9):focus {
|
|
134
|
+
outline: 2px dotted transparent;
|
|
135
|
+
outline-offset: 2px;
|
|
136
|
+
border-radius: var(--border-radius-dropdown-0c284d, 0px);
|
|
137
|
+
box-shadow: 0 0 0 2px var(--color-border-item-focused-n5kd8g, #0073bb);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.awsui_screenreader-only_145pa_1uq9r_114:not(#\9) {
|
|
141
|
+
position: absolute !important;
|
|
142
|
+
top: -9999px !important;
|
|
143
|
+
left: -9999px !important;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.awsui_date-picker-container_145pa_1uq9r_120:not(#\9) {
|
|
158
147
|
position: relative;
|
|
159
148
|
max-width: 234px;
|
|
160
149
|
}
|
|
161
150
|
|
|
162
|
-
.awsui_date-picker-
|
|
151
|
+
.awsui_date-picker-trigger_145pa_1uq9r_125:not(#\9) {
|
|
163
152
|
display: flex;
|
|
164
153
|
}
|
|
165
154
|
|
|
166
|
-
.awsui_date-picker-
|
|
155
|
+
.awsui_date-picker-input_145pa_1uq9r_129:not(#\9) {
|
|
167
156
|
padding-right: var(--space-xs-rsr2qu, 8px);
|
|
168
157
|
width: 100%;
|
|
169
158
|
}
|
|
170
159
|
|
|
171
|
-
.awsui_open-calendar-
|
|
160
|
+
.awsui_open-calendar-button_145pa_1uq9r_134:not(#\9) {
|
|
172
161
|
/* used in test-utils */
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
.awsui_calendar_145pa_hegy7_93:not(#\9) {
|
|
176
|
-
display: block;
|
|
177
|
-
width: 234px;
|
|
178
|
-
overflow: auto;
|
|
179
|
-
/* stylelint-disable-next-line plugin/no-unsupported-browser-features */
|
|
180
|
-
border-collapse: separate;
|
|
181
|
-
border-spacing: 0;
|
|
182
|
-
caption-side: top;
|
|
183
|
-
cursor: auto;
|
|
184
|
-
direction: ltr;
|
|
185
|
-
empty-cells: show;
|
|
186
|
-
font-family: serif;
|
|
187
|
-
font-size: medium;
|
|
188
|
-
font-style: normal;
|
|
189
|
-
font-variant: normal;
|
|
190
|
-
font-weight: normal;
|
|
191
|
-
font-stretch: normal;
|
|
192
|
-
line-height: normal;
|
|
193
|
-
-webkit-hyphens: none;
|
|
194
|
-
hyphens: none;
|
|
195
|
-
letter-spacing: normal;
|
|
196
|
-
list-style: disc outside none;
|
|
197
|
-
tab-size: 8;
|
|
198
|
-
text-align: left;
|
|
199
|
-
text-align-last: auto;
|
|
200
|
-
text-indent: 0;
|
|
201
|
-
text-shadow: none;
|
|
202
|
-
text-transform: none;
|
|
203
|
-
visibility: visible;
|
|
204
|
-
white-space: normal;
|
|
205
|
-
widows: 2;
|
|
206
|
-
word-spacing: normal;
|
|
207
|
-
box-sizing: border-box;
|
|
208
|
-
font-size: var(--font-body-m-size-sregvd, 14px);
|
|
209
|
-
line-height: var(--font-body-m-line-height-i7xxvv, 22px);
|
|
210
|
-
color: var(--color-text-body-default-7m2b3r, #16191f);
|
|
211
|
-
font-weight: 400;
|
|
212
|
-
font-family: var(--font-family-base-mylvzb, "Noto Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
|
|
213
|
-
}
|
|
214
|
-
.awsui_calendar_145pa_hegy7_93:not(#\9):focus {
|
|
215
|
-
outline: none;
|
|
216
|
-
}
|
|
217
|
-
.awsui_calendar-inner_145pa_hegy7_165:not(#\9) {
|
|
218
|
-
margin: var(--space-xs-rsr2qu, 8px);
|
|
219
|
-
}
|
|
220
|
-
.awsui_calendar-header_145pa_hegy7_168:not(#\9) {
|
|
221
|
-
display: flex;
|
|
222
|
-
justify-content: space-between;
|
|
223
|
-
align-items: center;
|
|
224
|
-
}
|
|
225
|
-
.awsui_calendar-header-month_145pa_hegy7_173:not(#\9) {
|
|
226
|
-
font-size: var(--font-body-m-size-sregvd, 14px);
|
|
227
|
-
line-height: var(--font-body-m-line-height-i7xxvv, 22px);
|
|
228
|
-
font-weight: 700;
|
|
229
|
-
color: var(--color-text-dropdown-item-default-ki8ao1, #16191f);
|
|
230
|
-
}
|
|
231
|
-
.awsui_calendar-next-month-btn_145pa_hegy7_179:not(#\9) {
|
|
232
|
-
/* used for identifying element */
|
|
233
|
-
}
|
|
234
|
-
.awsui_calendar-prev-month-btn_145pa_hegy7_182:not(#\9) {
|
|
235
|
-
/* used for identifying element */
|
|
236
|
-
}
|
|
237
|
-
.awsui_calendar-day-names_145pa_hegy7_185:not(#\9) {
|
|
238
|
-
display: flex;
|
|
239
|
-
justify-content: stretch;
|
|
240
|
-
}
|
|
241
|
-
.awsui_calendar-day-name_145pa_hegy7_185:not(#\9) {
|
|
242
|
-
flex: 1 1 0%;
|
|
243
|
-
width: 0;
|
|
244
|
-
word-break: break-word;
|
|
245
|
-
text-align: center;
|
|
246
|
-
padding: var(--space-s-hv8c1d, 12px) 0 var(--space-xxs-ynfts5, 4px);
|
|
247
|
-
color: var(--color-text-calendar-month-cx7jxx, #545b64);
|
|
248
|
-
font-size: var(--font-body-s-size-ukw2p9, 12px);
|
|
249
|
-
line-height: var(--font-body-s-line-height-kdsbrl, 16px);
|
|
250
|
-
letter-spacing: var(--font-body-s-letter-spacing-p88gax, normal);
|
|
251
|
-
}
|
|
252
|
-
.awsui_calendar-dates_145pa_hegy7_200:not(#\9) {
|
|
253
|
-
border: 1px solid var(--color-border-calendar-grid-54zscx, #eaeded);
|
|
254
|
-
}
|
|
255
|
-
.awsui_calendar-week_145pa_hegy7_203:not(#\9) {
|
|
256
|
-
display: flex;
|
|
257
|
-
justify-content: stretch;
|
|
258
|
-
}
|
|
259
|
-
.awsui_calendar-day_145pa_hegy7_185:not(#\9) {
|
|
260
|
-
flex: 1 1 0%;
|
|
261
|
-
width: 0;
|
|
262
|
-
word-break: break-word;
|
|
263
|
-
text-align: center;
|
|
264
|
-
border-bottom: 1px solid var(--color-border-calendar-grid-54zscx, #eaeded);
|
|
265
|
-
border-right: 1px solid var(--color-border-calendar-grid-54zscx, #eaeded);
|
|
266
|
-
border-radius: var(--border-radius-item-wjpc1f, 0px);
|
|
267
|
-
padding: var(--space-xxs-ynfts5, 4px) 0;
|
|
268
|
-
color: var(--color-text-dropdown-item-disabled-dgi2f4, #aab7b8);
|
|
269
|
-
position: relative;
|
|
270
|
-
}
|
|
271
|
-
.awsui_calendar-day_145pa_hegy7_185:not(#\9):last-child {
|
|
272
|
-
border-right: none;
|
|
273
|
-
}
|
|
274
|
-
.awsui_calendar-day-in-last-week_145pa_hegy7_222:not(#\9) {
|
|
275
|
-
border-bottom: none;
|
|
276
|
-
}
|
|
277
|
-
.awsui_calendar-day-focusable_145pa_hegy7_225:not(#\9) {
|
|
278
|
-
/* used for identifying element */
|
|
279
|
-
}
|
|
280
|
-
.awsui_calendar-day-enabled_145pa_hegy7_228:not(#\9) {
|
|
281
|
-
cursor: pointer;
|
|
282
|
-
color: var(--color-text-dropdown-item-secondary-8hw5go, #687078);
|
|
283
|
-
}
|
|
284
|
-
.awsui_calendar-day-enabled_145pa_hegy7_228.awsui_calendar-day-current-month_145pa_hegy7_232:not(#\9) {
|
|
285
|
-
color: var(--color-text-dropdown-item-default-ki8ao1, #16191f);
|
|
286
|
-
}
|
|
287
|
-
.awsui_calendar-day-enabled_145pa_hegy7_228.awsui_calendar-day-current-month_145pa_hegy7_232:not(#\9):hover {
|
|
288
|
-
color: var(--color-text-calendar-day-hover-p7s945, #16191f);
|
|
289
|
-
background-color: var(--color-background-dropdown-item-hover-hgdj8r, #f2f3f3);
|
|
290
|
-
}
|
|
291
|
-
.awsui_calendar-day-enabled_145pa_hegy7_228.awsui_calendar-day-current-month_145pa_hegy7_232:not(#\9):hover:not(.awsui_calendar-day-selected_145pa_hegy7_239)::after {
|
|
292
|
-
border: var(--border-item-width-yvnixs, 1px) solid var(--color-border-dropdown-item-hover-d32f3f, #879596);
|
|
293
|
-
border-radius: var(--border-radius-item-wjpc1f, 0px);
|
|
294
|
-
}
|
|
295
|
-
.awsui_calendar-day-today_145pa_hegy7_243:not(#\9) {
|
|
296
|
-
background-color: var(--color-background-calendar-today-wm2baz, #f2f3f3);
|
|
297
|
-
}
|
|
298
|
-
.awsui_calendar-day_145pa_hegy7_185:not(#\9)::after {
|
|
299
|
-
content: "";
|
|
300
|
-
position: absolute;
|
|
301
|
-
top: -1px;
|
|
302
|
-
left: -1px;
|
|
303
|
-
bottom: -1px;
|
|
304
|
-
right: -1px;
|
|
305
|
-
background-color: transparent;
|
|
306
|
-
}
|
|
307
|
-
.awsui_calendar-day_145pa_hegy7_185 > .awsui_day-inner_145pa_hegy7_255:not(#\9) {
|
|
308
|
-
position: relative;
|
|
309
|
-
z-index: 1;
|
|
310
|
-
}
|
|
311
|
-
.awsui_calendar-day_145pa_hegy7_185:not(#\9):focus {
|
|
312
|
-
outline: none;
|
|
313
|
-
position: relative;
|
|
314
|
-
}
|
|
315
|
-
.awsui_calendar-day_145pa_hegy7_185:not(#\9):focus {
|
|
316
|
-
outline: 2px dotted transparent;
|
|
317
|
-
outline-offset: calc(var(--space-calendar-grid-focus-outline-gutter-lbmex4, 0px) - 1px);
|
|
318
|
-
}
|
|
319
|
-
.awsui_calendar-day_145pa_hegy7_185:not(#\9):focus::before {
|
|
320
|
-
content: " ";
|
|
321
|
-
display: block;
|
|
322
|
-
position: absolute;
|
|
323
|
-
left: calc(-1 * var(--space-calendar-grid-focus-outline-gutter-lbmex4, 0px));
|
|
324
|
-
top: calc(-1 * var(--space-calendar-grid-focus-outline-gutter-lbmex4, 0px));
|
|
325
|
-
width: calc(100% + 2 * var(--space-calendar-grid-focus-outline-gutter-lbmex4, 0px));
|
|
326
|
-
height: calc(100% + 2 * var(--space-calendar-grid-focus-outline-gutter-lbmex4, 0px));
|
|
327
|
-
border-radius: var(--border-radius-calendar-day-focus-ring-16ha5s, 2px);
|
|
328
|
-
box-shadow: 0 0 0 2px var(--color-border-item-focused-n5kd8g, #0073bb);
|
|
329
|
-
}
|
|
330
|
-
.awsui_calendar-day_145pa_hegy7_185:not(#\9):focus::before {
|
|
331
|
-
z-index: 2;
|
|
332
|
-
}
|
|
333
|
-
.awsui_calendar-day-selected_145pa_hegy7_239:not(#\9) {
|
|
334
|
-
border-color: transparent;
|
|
335
|
-
position: relative;
|
|
336
|
-
}
|
|
337
|
-
.awsui_calendar-day-selected_145pa_hegy7_239:not(#\9)::after {
|
|
338
|
-
background-color: var(--color-background-dropdown-item-selected-w7iegd, #f1faff);
|
|
339
|
-
border: var(--border-item-width-yvnixs, 1px) solid var(--color-border-dropdown-item-selected-bzuxys, #00a1c9);
|
|
340
|
-
border-radius: var(--border-radius-item-wjpc1f, 0px);
|
|
341
|
-
}
|
|
342
|
-
.awsui_calendar-day-selected_145pa_hegy7_239 > .awsui_day-inner_145pa_hegy7_255:not(#\9) {
|
|
343
|
-
color: var(--color-text-calendar-day-selected-fr68ny, #16191f);
|
|
344
|
-
position: relative;
|
|
345
|
-
}
|
|
346
|
-
.awsui_calendar_145pa_hegy7_93[data-awsui-focus-visible=true]:not(#\9):focus {
|
|
347
|
-
outline: 2px dotted transparent;
|
|
348
|
-
outline-offset: 2px;
|
|
349
|
-
border-radius: var(--border-radius-dropdown-0c284d, 0px);
|
|
350
|
-
box-shadow: 0 0 0 2px var(--color-border-item-focused-n5kd8g, #0073bb);
|
|
351
162
|
}
|
|
@@ -2,29 +2,12 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"date-picker-container": "awsui_date-picker-
|
|
9
|
-
"date-picker-trigger": "awsui_date-picker-
|
|
10
|
-
"date-picker-input": "awsui_date-picker-
|
|
11
|
-
"open-calendar-button": "awsui_open-calendar-
|
|
12
|
-
"calendar-inner": "awsui_calendar-inner_145pa_hegy7_165",
|
|
13
|
-
"calendar-header": "awsui_calendar-header_145pa_hegy7_168",
|
|
14
|
-
"calendar-header-month": "awsui_calendar-header-month_145pa_hegy7_173",
|
|
15
|
-
"calendar-next-month-btn": "awsui_calendar-next-month-btn_145pa_hegy7_179",
|
|
16
|
-
"calendar-prev-month-btn": "awsui_calendar-prev-month-btn_145pa_hegy7_182",
|
|
17
|
-
"calendar-day-names": "awsui_calendar-day-names_145pa_hegy7_185",
|
|
18
|
-
"calendar-day-name": "awsui_calendar-day-name_145pa_hegy7_185",
|
|
19
|
-
"calendar-dates": "awsui_calendar-dates_145pa_hegy7_200",
|
|
20
|
-
"calendar-week": "awsui_calendar-week_145pa_hegy7_203",
|
|
21
|
-
"calendar-day": "awsui_calendar-day_145pa_hegy7_185",
|
|
22
|
-
"calendar-day-in-last-week": "awsui_calendar-day-in-last-week_145pa_hegy7_222",
|
|
23
|
-
"calendar-day-focusable": "awsui_calendar-day-focusable_145pa_hegy7_225",
|
|
24
|
-
"calendar-day-enabled": "awsui_calendar-day-enabled_145pa_hegy7_228",
|
|
25
|
-
"calendar-day-current-month": "awsui_calendar-day-current-month_145pa_hegy7_232",
|
|
26
|
-
"calendar-day-selected": "awsui_calendar-day-selected_145pa_hegy7_239",
|
|
27
|
-
"calendar-day-today": "awsui_calendar-day-today_145pa_hegy7_243",
|
|
28
|
-
"day-inner": "awsui_day-inner_145pa_hegy7_255"
|
|
5
|
+
"root": "awsui_root_145pa_1uq9r_93",
|
|
6
|
+
"calendar": "awsui_calendar_145pa_1uq9r_104",
|
|
7
|
+
"screenreader-only": "awsui_screenreader-only_145pa_1uq9r_114",
|
|
8
|
+
"date-picker-container": "awsui_date-picker-container_145pa_1uq9r_120",
|
|
9
|
+
"date-picker-trigger": "awsui_date-picker-trigger_145pa_1uq9r_125",
|
|
10
|
+
"date-picker-input": "awsui_date-picker-input_145pa_1uq9r_129",
|
|
11
|
+
"open-calendar-button": "awsui_open-calendar-button_145pa_1uq9r_134"
|
|
29
12
|
};
|
|
30
13
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { startOfMonth, addDays } from 'date-fns';
|
|
2
|
-
import moveFocusHandler from '../../
|
|
2
|
+
import moveFocusHandler from '../../calendar/utils/move-focus-handler';
|
|
3
3
|
export function getBaseDate(date, daysToMove, isDateEnabled) {
|
|
4
4
|
var startDate = startOfMonth(date);
|
|
5
5
|
if (isDateEnabled(startDate)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-base-date.js","sourceRoot":"","sources":["../../../../src/date-range-picker/calendar/get-base-date.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,gBAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"get-base-date.js","sourceRoot":"","sources":["../../../../src/date-range-picker/calendar/get-base-date.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,gBAAgB,MAAM,yCAAyC,CAAC;AAEvE,MAAM,UAAU,WAAW,CAAC,IAAU,EAAE,UAAkB,EAAE,aAAyD;IACnH,IAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,aAAa,CAAC,SAAS,CAAC,EAAE;QAC5B,OAAO,SAAS,CAAC;KAClB;IACD,OAAO,gBAAgB,CAAC,SAAS,EAAE,aAAa,EAAE,UAAC,IAAU,IAAK,OAAA,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,EAAzB,CAAyB,CAAC,CAAC;AAC/F,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { DateRangePickerProps } from '../interfaces';\nimport { startOfMonth, addDays } from 'date-fns';\nimport moveFocusHandler from '../../calendar/utils/move-focus-handler';\n\nexport function getBaseDate(date: Date, daysToMove: -1 | 1, isDateEnabled: DateRangePickerProps.IsDateEnabledFunction) {\n const startDate = startOfMonth(date);\n if (isDateEnabled(startDate)) {\n return startDate;\n }\n return moveFocusHandler(startDate, isDateEnabled, (date: Date) => addDays(date, daysToMove));\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { __assign } from "tslib";
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import styles from './styles.css.js';
|
|
6
6
|
import { getDaysInMonth, isAfter, isBefore, isLastDayOfMonth, isSameMonth, isToday as isTodayFn } from 'date-fns';
|
|
7
|
-
import { getDateLabel } from '../../../../
|
|
7
|
+
import { getDateLabel } from '../../../../calendar/utils/intl';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
import { KeyCode } from '../../../../internal/keycode.js';
|
|
10
10
|
import useFocusVisible from '../../../../internal/hooks/focus-visible';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/date-range-picker/calendar/grids/day/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,UAAU,CAAC;AAClH,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC3E,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB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ier: Apache-2.0\nimport React from 'react';\nimport styles from './styles.css.js';\nimport { DateRangePickerProps } from '../../../interfaces';\nimport { getDaysInMonth, isAfter, isBefore, isLastDayOfMonth, isSameMonth, isToday as isTodayFn } from 'date-fns';\nimport { getDateLabel } from '../../../../date-picker/calendar/utils/intl';\nimport clsx from 'clsx';\nimport { KeyCode } from '../../../../internal/keycode.js';\nimport useFocusVisible from '../../../../internal/hooks/focus-visible';\nimport { formatDate } from '../../../../internal/utils/date-time';\n\ninterface GridDayProps {\n locale: string;\n baseDate: Date;\n date: Date;\n\n isDateInFirstRow: boolean;\n isDateInFirstColumn: boolean;\n isDateInLastColumn: boolean;\n isDateInSelectionStartWeek: boolean;\n isDateInSelectionEndWeek: boolean;\n\n isFocusedDate: boolean;\n isDateEnabled?: DateRangePickerProps.IsDateEnabledFunction;\n todayAriaLabel: string;\n onSelectDate: (date: Date) => void;\n onFocusDate: (date: Date) => void;\n isInRange: boolean;\n isSelected: boolean;\n\n // these only exist for the test-utils\n isStartDate: boolean;\n isEndDate: boolean;\n // used for refresh styles\n onlyOneSelected: boolean;\n isRangeStartDate: boolean;\n isRangeEndDate: boolean;\n}\n\nfunction propsAreEqual(prevProps: GridDayProps, nextProps: GridDayProps): boolean {\n return (\n prevProps.locale === nextProps.locale &&\n prevProps.baseDate.getTime() === nextProps.baseDate.getTime() &&\n prevProps.date.getTime() === nextProps.date.getTime() &&\n prevProps.isDateInFirstRow === nextProps.isDateInFirstRow &&\n prevProps.isDateInFirstColumn === nextProps.isDateInFirstColumn &&\n prevProps.isDateInLastColumn === nextProps.isDateInLastColumn &&\n prevProps.isDateInSelectionStartWeek === nextProps.isDateInSelectionStartWeek &&\n prevProps.isDateInSelectionEndWeek === nextProps.isDateInSelectionEndWeek &&\n prevProps.isFocusedDate === nextProps.isFocusedDate &&\n prevProps.isDateEnabled === nextProps.isDateEnabled &&\n prevProps.todayAriaLabel === nextProps.todayAriaLabel &&\n prevProps.onSelectDate === nextProps.onSelectDate &&\n prevProps.onFocusDate === nextProps.onFocusDate &&\n prevProps.isInRange === nextProps.isInRange &&\n prevProps.isSelected === nextProps.isSelected &&\n prevProps.isStartDate === nextProps.isStartDate &&\n prevProps.isEndDate === nextProps.isEndDate &&\n prevProps.onlyOneSelected === nextProps.onlyOneSelected &&\n prevProps.isRangeStartDate === nextProps.isRangeStartDate &&\n prevProps.isRangeEndDate === nextProps.isRangeEndDate\n );\n}\n\nconst GridDay = React.memo(\n React.forwardRef<HTMLDivElement, GridDayProps>(\n (\n {\n locale,\n baseDate,\n date,\n isSelected,\n isStartDate,\n isEndDate,\n onlyOneSelected,\n isRangeStartDate,\n isRangeEndDate,\n isFocusedDate,\n isDateEnabled,\n todayAriaLabel,\n onSelectDate,\n onFocusDate,\n isDateInFirstRow,\n isDateInFirstColumn,\n isDateInLastColumn,\n isDateInSelectionStartWeek,\n isDateInSelectionEndWeek,\n isInRange,\n }: GridDayProps,\n ref\n ) => {\n const dayLabel = getDateLabel(locale, date);\n\n const labels = [dayLabel];\n\n const isEnabled = !isDateEnabled || isDateEnabled(date);\n const isFocusable = isFocusedDate && isEnabled;\n const isToday = isTodayFn(date);\n const computedAttributes: React.HTMLAttributes<HTMLDivElement> = {};\n\n const focusVisible = useFocusVisible();\n\n const baseClasses = {\n [styles['in-first-row']]: isDateInFirstRow,\n [styles['in-first-column']]: isDateInFirstColumn,\n };\n\n if (!isSameMonth(date, baseDate)) {\n const classNames = clsx(styles.day, baseClasses, {\n [styles['in-previous-month']]: isBefore(date, baseDate),\n [styles['last-day-of-month']]: isLastDayOfMonth(date),\n [styles['in-next-month']]: isAfter(date, baseDate),\n });\n return <div className={classNames} ref={ref}></div>;\n }\n\n const classNames = clsx(styles.day, baseClasses, {\n [styles['in-current-month']]: isSameMonth(date, baseDate),\n [styles.enabled]: isEnabled,\n [styles.selected]: isSelected,\n [styles['start-date']]: isStartDate,\n [styles['end-date']]: isEndDate,\n [styles['range-start-date']]: isRangeStartDate,\n [styles['range-end-date']]: isRangeEndDate,\n [styles['no-range']]: isSelected && onlyOneSelected,\n [styles['in-range']]: isInRange,\n [styles['in-range-border-top']]: isDateInSelectionStartWeek || date.getDate() <= 7,\n [styles['in-range-border-bottom']]: isDateInSelectionEndWeek || date.getDate() > getDaysInMonth(date) - 7,\n [styles['in-range-border-left']]: isDateInFirstColumn || date.getDate() === 1 || isRangeStartDate,\n [styles['in-range-border-right']]: isDateInLastColumn || isLastDayOfMonth(date) || isRangeEndDate,\n [styles.today]: isToday,\n });\n\n computedAttributes['aria-pressed'] = isSelected || isInRange;\n\n if (isToday) {\n labels.push(todayAriaLabel);\n computedAttributes['aria-current'] = 'date';\n }\n\n if (isEnabled) {\n computedAttributes.onClick = () => onSelectDate(date);\n computedAttributes.onFocus = () => onFocusDate(date);\n computedAttributes.tabIndex = -1;\n }\n\n if (isFocusable) {\n computedAttributes.tabIndex = 0;\n }\n\n const onKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.keyCode === KeyCode.space) {\n event.preventDefault();\n onSelectDate(date);\n }\n };\n\n return (\n <div\n className={classNames}\n aria-label={labels.join('. ')}\n data-date={formatDate(date)}\n role=\"button\"\n {...computedAttributes}\n ref={ref}\n onKeyDown={onKeyDown}\n {...focusVisible}\n >\n <span className={styles['day-inner']}>{date.getDate()}</span>\n </div>\n );\n }\n ),\n propsAreEqual\n);\n\nexport default GridDay;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/date-range-picker/calendar/grids/day/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,UAAU,CAAC;AAClH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AA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Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport styles from './styles.css.js';\nimport { DateRangePickerProps } from '../../../interfaces';\nimport { getDaysInMonth, isAfter, isBefore, isLastDayOfMonth, isSameMonth, isToday as isTodayFn } from 'date-fns';\nimport { getDateLabel } from '../../../../calendar/utils/intl';\nimport clsx from 'clsx';\nimport { KeyCode } from '../../../../internal/keycode.js';\nimport useFocusVisible from '../../../../internal/hooks/focus-visible';\nimport { formatDate } from '../../../../internal/utils/date-time';\n\ninterface GridDayProps {\n locale: string;\n baseDate: Date;\n date: Date;\n\n isDateInFirstRow: boolean;\n isDateInFirstColumn: boolean;\n isDateInLastColumn: boolean;\n isDateInSelectionStartWeek: boolean;\n isDateInSelectionEndWeek: boolean;\n\n isFocusedDate: boolean;\n isDateEnabled?: DateRangePickerProps.IsDateEnabledFunction;\n todayAriaLabel: string;\n onSelectDate: (date: Date) => void;\n onFocusDate: (date: Date) => void;\n isInRange: boolean;\n isSelected: boolean;\n\n // these only exist for the test-utils\n isStartDate: boolean;\n isEndDate: boolean;\n // used for refresh styles\n onlyOneSelected: boolean;\n isRangeStartDate: boolean;\n isRangeEndDate: boolean;\n}\n\nfunction propsAreEqual(prevProps: GridDayProps, nextProps: GridDayProps): boolean {\n return (\n prevProps.locale === nextProps.locale &&\n prevProps.baseDate.getTime() === nextProps.baseDate.getTime() &&\n prevProps.date.getTime() === nextProps.date.getTime() &&\n prevProps.isDateInFirstRow === nextProps.isDateInFirstRow &&\n prevProps.isDateInFirstColumn === nextProps.isDateInFirstColumn &&\n prevProps.isDateInLastColumn === nextProps.isDateInLastColumn &&\n prevProps.isDateInSelectionStartWeek === nextProps.isDateInSelectionStartWeek &&\n prevProps.isDateInSelectionEndWeek === nextProps.isDateInSelectionEndWeek &&\n prevProps.isFocusedDate === nextProps.isFocusedDate &&\n prevProps.isDateEnabled === nextProps.isDateEnabled &&\n prevProps.todayAriaLabel === nextProps.todayAriaLabel &&\n prevProps.onSelectDate === nextProps.onSelectDate &&\n prevProps.onFocusDate === nextProps.onFocusDate &&\n prevProps.isInRange === nextProps.isInRange &&\n prevProps.isSelected === nextProps.isSelected &&\n prevProps.isStartDate === nextProps.isStartDate &&\n prevProps.isEndDate === nextProps.isEndDate &&\n prevProps.onlyOneSelected === nextProps.onlyOneSelected &&\n prevProps.isRangeStartDate === nextProps.isRangeStartDate &&\n prevProps.isRangeEndDate === nextProps.isRangeEndDate\n );\n}\n\nconst GridDay = React.memo(\n React.forwardRef<HTMLDivElement, GridDayProps>(\n (\n {\n locale,\n baseDate,\n date,\n isSelected,\n isStartDate,\n isEndDate,\n onlyOneSelected,\n isRangeStartDate,\n isRangeEndDate,\n isFocusedDate,\n isDateEnabled,\n todayAriaLabel,\n onSelectDate,\n onFocusDate,\n isDateInFirstRow,\n isDateInFirstColumn,\n isDateInLastColumn,\n isDateInSelectionStartWeek,\n isDateInSelectionEndWeek,\n isInRange,\n }: GridDayProps,\n ref\n ) => {\n const dayLabel = getDateLabel(locale, date);\n\n const labels = [dayLabel];\n\n const isEnabled = !isDateEnabled || isDateEnabled(date);\n const isFocusable = isFocusedDate && isEnabled;\n const isToday = isTodayFn(date);\n const computedAttributes: React.HTMLAttributes<HTMLDivElement> = {};\n\n const focusVisible = useFocusVisible();\n\n const baseClasses = {\n [styles['in-first-row']]: isDateInFirstRow,\n [styles['in-first-column']]: isDateInFirstColumn,\n };\n\n if (!isSameMonth(date, baseDate)) {\n const classNames = clsx(styles.day, baseClasses, {\n [styles['in-previous-month']]: isBefore(date, baseDate),\n [styles['last-day-of-month']]: isLastDayOfMonth(date),\n [styles['in-next-month']]: isAfter(date, baseDate),\n });\n return <div className={classNames} ref={ref}></div>;\n }\n\n const classNames = clsx(styles.day, baseClasses, {\n [styles['in-current-month']]: isSameMonth(date, baseDate),\n [styles.enabled]: isEnabled,\n [styles.selected]: isSelected,\n [styles['start-date']]: isStartDate,\n [styles['end-date']]: isEndDate,\n [styles['range-start-date']]: isRangeStartDate,\n [styles['range-end-date']]: isRangeEndDate,\n [styles['no-range']]: isSelected && onlyOneSelected,\n [styles['in-range']]: isInRange,\n [styles['in-range-border-top']]: isDateInSelectionStartWeek || date.getDate() <= 7,\n [styles['in-range-border-bottom']]: isDateInSelectionEndWeek || date.getDate() > getDaysInMonth(date) - 7,\n [styles['in-range-border-left']]: isDateInFirstColumn || date.getDate() === 1 || isRangeStartDate,\n [styles['in-range-border-right']]: isDateInLastColumn || isLastDayOfMonth(date) || isRangeEndDate,\n [styles.today]: isToday,\n });\n\n computedAttributes['aria-pressed'] = isSelected || isInRange;\n\n if (isToday) {\n labels.push(todayAriaLabel);\n computedAttributes['aria-current'] = 'date';\n }\n\n if (isEnabled) {\n computedAttributes.onClick = () => onSelectDate(date);\n computedAttributes.onFocus = () => onFocusDate(date);\n computedAttributes.tabIndex = -1;\n }\n\n if (isFocusable) {\n computedAttributes.tabIndex = 0;\n }\n\n const onKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.keyCode === KeyCode.space) {\n event.preventDefault();\n onSelectDate(date);\n }\n };\n\n return (\n <div\n className={classNames}\n aria-label={labels.join('. ')}\n data-date={formatDate(date)}\n role=\"button\"\n {...computedAttributes}\n ref={ref}\n onKeyDown={onKeyDown}\n {...focusVisible}\n >\n <span className={styles['day-inner']}>{date.getDate()}</span>\n </div>\n );\n }\n ),\n propsAreEqual\n);\n\nexport default GridDay;\n"]}
|