@cloudscape-design/components 3.0.56 → 3.0.58
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/{date-picker/calendar → calendar}/grid/day/index.d.ts +1 -1
- package/calendar/grid/day/index.d.ts.map +1 -0
- package/{date-picker/calendar → calendar}/grid/day/index.js +1 -1
- package/calendar/grid/day/index.js.map +1 -0
- package/{date-picker/calendar → calendar}/grid/index.d.ts +2 -2
- package/calendar/grid/index.d.ts.map +1 -0
- package/{date-picker/calendar → calendar}/grid/index.js +2 -2
- package/calendar/grid/index.js.map +1 -0
- package/{date-picker/calendar → calendar}/header/button/index.d.ts +0 -0
- package/calendar/header/button/index.d.ts.map +1 -0
- package/{date-picker/calendar → calendar}/header/button/index.js +2 -2
- package/calendar/header/button/index.js.map +1 -0
- package/{date-picker/calendar → calendar}/header/index.d.ts +1 -2
- package/calendar/header/index.d.ts.map +1 -0
- package/{date-picker/calendar → calendar}/header/index.js +3 -3
- package/calendar/header/index.js.map +1 -0
- package/calendar/index.d.ts +4 -0
- package/calendar/index.d.ts.map +1 -0
- package/calendar/index.js +14 -0
- package/calendar/index.js.map +1 -0
- package/calendar/interfaces.d.ts +56 -0
- package/calendar/interfaces.d.ts.map +1 -0
- package/calendar/interfaces.js +4 -0
- package/calendar/interfaces.js.map +1 -0
- package/calendar/internal.d.ts +4 -0
- package/calendar/internal.d.ts.map +1 -0
- package/{date-picker/calendar/index.js → calendar/internal.js} +9 -13
- package/calendar/internal.js.map +1 -0
- package/calendar/styles.css.js +25 -0
- package/calendar/styles.scoped.css +291 -0
- package/calendar/styles.selectors.js +26 -0
- package/{date-picker/calendar → calendar}/utils/intl.d.ts +2 -2
- package/calendar/utils/intl.d.ts.map +1 -0
- package/{date-picker/calendar → calendar}/utils/intl.js +2 -0
- package/calendar/utils/intl.js.map +1 -0
- package/{date-picker/calendar → calendar}/utils/locales.d.ts +1 -1
- package/calendar/utils/locales.d.ts.map +1 -0
- package/{date-picker/calendar → calendar}/utils/locales.js +1 -1
- package/calendar/utils/locales.js.map +1 -0
- package/{date-picker/calendar → calendar}/utils/memoized-date.d.ts +0 -0
- package/calendar/utils/memoized-date.d.ts.map +1 -0
- package/{date-picker/calendar → calendar}/utils/memoized-date.js +1 -1
- package/calendar/utils/memoized-date.js.map +1 -0
- package/{date-picker/calendar → calendar}/utils/move-focus-handler.d.ts +1 -1
- package/calendar/utils/move-focus-handler.d.ts.map +1 -0
- package/{date-picker/calendar → calendar}/utils/move-focus-handler.js +0 -0
- package/calendar/utils/move-focus-handler.js.map +1 -0
- package/calendar/utils/rotate-day-indexes.d.ts +3 -0
- package/calendar/utils/rotate-day-indexes.d.ts.map +1 -0
- package/{date-picker/calendar → calendar}/utils/rotate-day-indexes.js +2 -0
- package/calendar/utils/rotate-day-indexes.js.map +1 -0
- package/date-picker/index.d.ts.map +1 -1
- package/date-picker/index.js +16 -10
- package/date-picker/index.js.map +1 -1
- package/date-picker/interfaces.d.ts +2 -44
- package/date-picker/interfaces.d.ts.map +1 -1
- package/date-picker/interfaces.js.map +1 -1
- package/date-picker/styles.css.js +7 -24
- package/date-picker/styles.scoped.css +21 -210
- package/date-picker/styles.selectors.js +7 -24
- package/date-range-picker/calendar/get-base-date.js +1 -1
- package/date-range-picker/calendar/get-base-date.js.map +1 -1
- package/date-range-picker/calendar/grids/day/index.js +1 -1
- package/date-range-picker/calendar/grids/day/index.js.map +1 -1
- package/date-range-picker/calendar/grids/grid.js +2 -2
- package/date-range-picker/calendar/grids/grid.js.map +1 -1
- package/date-range-picker/calendar/grids/index.d.ts +1 -1
- package/date-range-picker/calendar/grids/index.d.ts.map +1 -1
- package/date-range-picker/calendar/grids/index.js.map +1 -1
- package/date-range-picker/calendar/header/index.js +1 -1
- package/date-range-picker/calendar/header/index.js.map +1 -1
- package/date-range-picker/calendar/index.js +3 -3
- package/date-range-picker/calendar/index.js.map +1 -1
- package/date-range-picker/index.js +1 -1
- package/date-range-picker/index.js.map +1 -1
- package/input/internal.js +1 -1
- package/input/internal.js.map +1 -1
- package/internal/environment.js +1 -1
- package/package.json +1 -1
- package/test-utils/dom/calendar/index.d.ts +16 -0
- package/test-utils/dom/calendar/index.js +53 -0
- package/test-utils/dom/calendar/index.js.map +1 -0
- package/test-utils/dom/date-picker/index.d.ts +2 -14
- package/test-utils/dom/date-picker/index.js +4 -33
- package/test-utils/dom/date-picker/index.js.map +1 -1
- package/test-utils/selectors/calendar/index.d.ts +16 -0
- package/test-utils/selectors/calendar/index.js +53 -0
- package/test-utils/selectors/calendar/index.js.map +1 -0
- package/test-utils/selectors/date-picker/index.d.ts +2 -14
- package/test-utils/selectors/date-picker/index.js +2 -31
- package/test-utils/selectors/date-picker/index.js.map +1 -1
- package/test-utils/tsconfig.tsbuildinfo +1 -1
- package/date-picker/calendar/grid/day/index.d.ts.map +0 -1
- package/date-picker/calendar/grid/day/index.js.map +0 -1
- package/date-picker/calendar/grid/index.d.ts.map +0 -1
- package/date-picker/calendar/grid/index.js.map +0 -1
- package/date-picker/calendar/header/button/index.d.ts.map +0 -1
- package/date-picker/calendar/header/button/index.js.map +0 -1
- package/date-picker/calendar/header/index.d.ts.map +0 -1
- package/date-picker/calendar/header/index.js.map +0 -1
- package/date-picker/calendar/index.d.ts +0 -17
- package/date-picker/calendar/index.d.ts.map +0 -1
- package/date-picker/calendar/index.js.map +0 -1
- package/date-picker/calendar/utils/intl.d.ts.map +0 -1
- package/date-picker/calendar/utils/intl.js.map +0 -1
- package/date-picker/calendar/utils/locales.d.ts.map +0 -1
- package/date-picker/calendar/utils/locales.js.map +0 -1
- package/date-picker/calendar/utils/memoized-date.d.ts.map +0 -1
- package/date-picker/calendar/utils/memoized-date.js.map +0 -1
- package/date-picker/calendar/utils/move-focus-handler.d.ts.map +0 -1
- package/date-picker/calendar/utils/move-focus-handler.js.map +0 -1
- package/date-picker/calendar/utils/rotate-day-indexes.d.ts +0 -3
- package/date-picker/calendar/utils/rotate-day-indexes.d.ts.map +0 -1
- package/date-picker/calendar/utils/rotate-day-indexes.js.map +0 -1
|
@@ -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_137eg_165",
|
|
12
|
-
"calendar-header": "awsui_calendar-header_145pa_137eg_168",
|
|
13
|
-
"calendar-header-month": "awsui_calendar-header-month_145pa_137eg_173",
|
|
14
|
-
"calendar-next-month-btn": "awsui_calendar-next-month-btn_145pa_137eg_179",
|
|
15
|
-
"calendar-prev-month-btn": "awsui_calendar-prev-month-btn_145pa_137eg_182",
|
|
16
|
-
"calendar-day-names": "awsui_calendar-day-names_145pa_137eg_185",
|
|
17
|
-
"calendar-day-name": "awsui_calendar-day-name_145pa_137eg_185",
|
|
18
|
-
"calendar-dates": "awsui_calendar-dates_145pa_137eg_200",
|
|
19
|
-
"calendar-week": "awsui_calendar-week_145pa_137eg_203",
|
|
20
|
-
"calendar-day": "awsui_calendar-day_145pa_137eg_185",
|
|
21
|
-
"calendar-day-in-last-week": "awsui_calendar-day-in-last-week_145pa_137eg_222",
|
|
22
|
-
"calendar-day-focusable": "awsui_calendar-day-focusable_145pa_137eg_225",
|
|
23
|
-
"calendar-day-enabled": "awsui_calendar-day-enabled_145pa_137eg_228",
|
|
24
|
-
"calendar-day-current-month": "awsui_calendar-day-current-month_145pa_137eg_232",
|
|
25
|
-
"calendar-day-selected": "awsui_calendar-day-selected_145pa_137eg_239",
|
|
26
|
-
"calendar-day-today": "awsui_calendar-day-today_145pa_137eg_243",
|
|
27
|
-
"day-inner": "awsui_day-inner_145pa_137eg_255"
|
|
4
|
+
"root": "awsui_root_145pa_5nu3i_93",
|
|
5
|
+
"calendar": "awsui_calendar_145pa_5nu3i_104",
|
|
6
|
+
"screenreader-only": "awsui_screenreader-only_145pa_5nu3i_114",
|
|
7
|
+
"date-picker-container": "awsui_date-picker-container_145pa_5nu3i_120",
|
|
8
|
+
"date-picker-trigger": "awsui_date-picker-trigger_145pa_5nu3i_125",
|
|
9
|
+
"date-picker-input": "awsui_date-picker-input_145pa_5nu3i_129",
|
|
10
|
+
"open-calendar-button": "awsui_open-calendar-button_145pa_5nu3i_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_137eg_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_137eg_1 {
|
|
98
|
-
from {
|
|
99
|
-
opacity: 0;
|
|
100
|
-
}
|
|
101
|
-
to {
|
|
102
|
-
opacity: 1;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
@media (prefers-reduced-motion: reduce) {
|
|
106
|
-
.awsui_calendar_145pa_137eg_93:not(#\9) {
|
|
107
|
-
animation: none;
|
|
108
|
-
transition: none;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
.awsui-motion-disabled .awsui_calendar_145pa_137eg_93:not(#\9), .awsui-mode-entering .awsui_calendar_145pa_137eg_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_137eg_120:not(#\9) {
|
|
93
|
+
.awsui_root_145pa_5nu3i_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-qnistn, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
|
|
155
128
|
}
|
|
156
129
|
|
|
157
|
-
.
|
|
130
|
+
.awsui_calendar_145pa_5nu3i_104:not(#\9):focus {
|
|
131
|
+
outline: none;
|
|
132
|
+
}
|
|
133
|
+
.awsui_calendar_145pa_5nu3i_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-ujknaf, 8px);
|
|
137
|
+
box-shadow: 0 0 0 2px var(--color-border-item-focused-ap3b6s, #0972d3);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.awsui_screenreader-only_145pa_5nu3i_114:not(#\9) {
|
|
141
|
+
position: absolute !important;
|
|
142
|
+
top: -9999px !important;
|
|
143
|
+
left: -9999px !important;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.awsui_date-picker-container_145pa_5nu3i_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_5nu3i_125:not(#\9) {
|
|
163
152
|
display: flex;
|
|
164
153
|
}
|
|
165
154
|
|
|
166
|
-
.awsui_date-picker-
|
|
155
|
+
.awsui_date-picker-input_145pa_5nu3i_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_5nu3i_134:not(#\9) {
|
|
172
161
|
/* used in test-utils */
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
.awsui_calendar_145pa_137eg_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-ajf1h5, #000716);
|
|
211
|
-
font-weight: 400;
|
|
212
|
-
font-family: var(--font-family-base-qnistn, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
|
|
213
|
-
}
|
|
214
|
-
.awsui_calendar_145pa_137eg_93:not(#\9):focus {
|
|
215
|
-
outline: none;
|
|
216
|
-
}
|
|
217
|
-
.awsui_calendar-inner_145pa_137eg_165:not(#\9) {
|
|
218
|
-
margin: var(--space-xs-rsr2qu, 8px);
|
|
219
|
-
}
|
|
220
|
-
.awsui_calendar-header_145pa_137eg_168:not(#\9) {
|
|
221
|
-
display: flex;
|
|
222
|
-
justify-content: space-between;
|
|
223
|
-
align-items: center;
|
|
224
|
-
}
|
|
225
|
-
.awsui_calendar-header-month_145pa_137eg_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-7tg9p2, #000716);
|
|
230
|
-
}
|
|
231
|
-
.awsui_calendar-next-month-btn_145pa_137eg_179:not(#\9) {
|
|
232
|
-
/* used for identifying element */
|
|
233
|
-
}
|
|
234
|
-
.awsui_calendar-prev-month-btn_145pa_137eg_182:not(#\9) {
|
|
235
|
-
/* used for identifying element */
|
|
236
|
-
}
|
|
237
|
-
.awsui_calendar-day-names_145pa_137eg_185:not(#\9) {
|
|
238
|
-
display: flex;
|
|
239
|
-
justify-content: stretch;
|
|
240
|
-
}
|
|
241
|
-
.awsui_calendar-day-name_145pa_137eg_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-elf7e9, #5f6b7a);
|
|
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-cy0oxj, 0.005em);
|
|
251
|
-
}
|
|
252
|
-
.awsui_calendar-dates_145pa_137eg_200:not(#\9) {
|
|
253
|
-
border: 1px solid var(--color-border-calendar-grid-sshunw, transparent);
|
|
254
|
-
}
|
|
255
|
-
.awsui_calendar-week_145pa_137eg_203:not(#\9) {
|
|
256
|
-
display: flex;
|
|
257
|
-
justify-content: stretch;
|
|
258
|
-
}
|
|
259
|
-
.awsui_calendar-day_145pa_137eg_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-sshunw, transparent);
|
|
265
|
-
border-right: 1px solid var(--color-border-calendar-grid-sshunw, transparent);
|
|
266
|
-
border-radius: var(--border-radius-item-u2ibpi, 8px);
|
|
267
|
-
padding: var(--space-xxs-ynfts5, 4px) 0;
|
|
268
|
-
color: var(--color-text-dropdown-item-disabled-varol7, #9ba7b6);
|
|
269
|
-
position: relative;
|
|
270
|
-
}
|
|
271
|
-
.awsui_calendar-day_145pa_137eg_185:not(#\9):last-child {
|
|
272
|
-
border-right: none;
|
|
273
|
-
}
|
|
274
|
-
.awsui_calendar-day-in-last-week_145pa_137eg_222:not(#\9) {
|
|
275
|
-
border-bottom: none;
|
|
276
|
-
}
|
|
277
|
-
.awsui_calendar-day-focusable_145pa_137eg_225:not(#\9) {
|
|
278
|
-
/* used for identifying element */
|
|
279
|
-
}
|
|
280
|
-
.awsui_calendar-day-enabled_145pa_137eg_228:not(#\9) {
|
|
281
|
-
cursor: pointer;
|
|
282
|
-
color: var(--color-text-dropdown-item-secondary-0me7js, #5f6b7a);
|
|
283
|
-
}
|
|
284
|
-
.awsui_calendar-day-enabled_145pa_137eg_228.awsui_calendar-day-current-month_145pa_137eg_232:not(#\9) {
|
|
285
|
-
color: var(--color-text-dropdown-item-default-7tg9p2, #000716);
|
|
286
|
-
}
|
|
287
|
-
.awsui_calendar-day-enabled_145pa_137eg_228.awsui_calendar-day-current-month_145pa_137eg_232:not(#\9):hover {
|
|
288
|
-
color: var(--color-text-calendar-day-hover-graajh, #000716);
|
|
289
|
-
background-color: var(--color-background-dropdown-item-hover-mqsxkv, #f4f4f4);
|
|
290
|
-
}
|
|
291
|
-
.awsui_calendar-day-enabled_145pa_137eg_228.awsui_calendar-day-current-month_145pa_137eg_232:not(#\9):hover:not(.awsui_calendar-day-selected_145pa_137eg_239)::after {
|
|
292
|
-
border: var(--border-item-width-qbbbsa, 2px) solid var(--color-border-dropdown-item-hover-tyzq9m, #7d8998);
|
|
293
|
-
border-radius: var(--border-radius-item-u2ibpi, 8px);
|
|
294
|
-
}
|
|
295
|
-
.awsui_calendar-day-today_145pa_137eg_243:not(#\9) {
|
|
296
|
-
background-color: var(--color-background-calendar-today-762czq, #f4f4f4);
|
|
297
|
-
}
|
|
298
|
-
.awsui_calendar-day_145pa_137eg_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_137eg_185 > .awsui_day-inner_145pa_137eg_255:not(#\9) {
|
|
308
|
-
position: relative;
|
|
309
|
-
z-index: 1;
|
|
310
|
-
}
|
|
311
|
-
.awsui_calendar-day_145pa_137eg_185:not(#\9):focus {
|
|
312
|
-
outline: none;
|
|
313
|
-
position: relative;
|
|
314
|
-
}
|
|
315
|
-
.awsui_calendar-day_145pa_137eg_185:not(#\9):focus {
|
|
316
|
-
outline: 2px dotted transparent;
|
|
317
|
-
outline-offset: calc(var(--space-calendar-grid-focus-outline-gutter-v3dwvl, -5px) - 1px);
|
|
318
|
-
}
|
|
319
|
-
.awsui_calendar-day_145pa_137eg_185:not(#\9):focus::before {
|
|
320
|
-
content: " ";
|
|
321
|
-
display: block;
|
|
322
|
-
position: absolute;
|
|
323
|
-
left: calc(-1 * var(--space-calendar-grid-focus-outline-gutter-v3dwvl, -5px));
|
|
324
|
-
top: calc(-1 * var(--space-calendar-grid-focus-outline-gutter-v3dwvl, -5px));
|
|
325
|
-
width: calc(100% + 2 * var(--space-calendar-grid-focus-outline-gutter-v3dwvl, -5px));
|
|
326
|
-
height: calc(100% + 2 * var(--space-calendar-grid-focus-outline-gutter-v3dwvl, -5px));
|
|
327
|
-
border-radius: var(--border-radius-calendar-day-focus-ring-a8mlqd, 3px);
|
|
328
|
-
box-shadow: 0 0 0 2px var(--color-border-item-focused-ap3b6s, #0972d3);
|
|
329
|
-
}
|
|
330
|
-
.awsui_calendar-day_145pa_137eg_185:not(#\9):focus::before {
|
|
331
|
-
z-index: 2;
|
|
332
|
-
}
|
|
333
|
-
.awsui_calendar-day-selected_145pa_137eg_239:not(#\9) {
|
|
334
|
-
border-color: transparent;
|
|
335
|
-
position: relative;
|
|
336
|
-
}
|
|
337
|
-
.awsui_calendar-day-selected_145pa_137eg_239:not(#\9)::after {
|
|
338
|
-
background-color: var(--color-background-dropdown-item-selected-8l4mpk, #f2f8fd);
|
|
339
|
-
border: var(--border-item-width-qbbbsa, 2px) solid var(--color-border-dropdown-item-selected-eahq2j, #0972d3);
|
|
340
|
-
border-radius: var(--border-radius-item-u2ibpi, 8px);
|
|
341
|
-
}
|
|
342
|
-
.awsui_calendar-day-selected_145pa_137eg_239 > .awsui_day-inner_145pa_137eg_255:not(#\9) {
|
|
343
|
-
color: var(--color-text-calendar-day-selected-64o9sq, #0972d3);
|
|
344
|
-
position: relative;
|
|
345
|
-
}
|
|
346
|
-
.awsui_calendar_145pa_137eg_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-ujknaf, 8px);
|
|
350
|
-
box-shadow: 0 0 0 2px var(--color-border-item-focused-ap3b6s, #0972d3);
|
|
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_137eg_165",
|
|
13
|
-
"calendar-header": "awsui_calendar-header_145pa_137eg_168",
|
|
14
|
-
"calendar-header-month": "awsui_calendar-header-month_145pa_137eg_173",
|
|
15
|
-
"calendar-next-month-btn": "awsui_calendar-next-month-btn_145pa_137eg_179",
|
|
16
|
-
"calendar-prev-month-btn": "awsui_calendar-prev-month-btn_145pa_137eg_182",
|
|
17
|
-
"calendar-day-names": "awsui_calendar-day-names_145pa_137eg_185",
|
|
18
|
-
"calendar-day-name": "awsui_calendar-day-name_145pa_137eg_185",
|
|
19
|
-
"calendar-dates": "awsui_calendar-dates_145pa_137eg_200",
|
|
20
|
-
"calendar-week": "awsui_calendar-week_145pa_137eg_203",
|
|
21
|
-
"calendar-day": "awsui_calendar-day_145pa_137eg_185",
|
|
22
|
-
"calendar-day-in-last-week": "awsui_calendar-day-in-last-week_145pa_137eg_222",
|
|
23
|
-
"calendar-day-focusable": "awsui_calendar-day-focusable_145pa_137eg_225",
|
|
24
|
-
"calendar-day-enabled": "awsui_calendar-day-enabled_145pa_137eg_228",
|
|
25
|
-
"calendar-day-current-month": "awsui_calendar-day-current-month_145pa_137eg_232",
|
|
26
|
-
"calendar-day-selected": "awsui_calendar-day-selected_145pa_137eg_239",
|
|
27
|
-
"calendar-day-today": "awsui_calendar-day-today_145pa_137eg_243",
|
|
28
|
-
"day-inner": "awsui_day-inner_145pa_137eg_255"
|
|
5
|
+
"root": "awsui_root_145pa_5nu3i_93",
|
|
6
|
+
"calendar": "awsui_calendar_145pa_5nu3i_104",
|
|
7
|
+
"screenreader-only": "awsui_screenreader-only_145pa_5nu3i_114",
|
|
8
|
+
"date-picker-container": "awsui_date-picker-container_145pa_5nu3i_120",
|
|
9
|
+
"date-picker-trigger": "awsui_date-picker-trigger_145pa_5nu3i_125",
|
|
10
|
+
"date-picker-input": "awsui_date-picker-input_145pa_5nu3i_129",
|
|
11
|
+
"open-calendar-button": "awsui_open-calendar-button_145pa_5nu3i_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,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,eAAe,MAAM,0CAA0C,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AA8BlE,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AI,OAAO,EAAE;QACX,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC5B,kBAAkB,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC;KAC7C;IAED,IAAI,SAAS,EAAE;QACb,kBAAkB,CAAC,OAAO,GAAG,cAAM,OAAA,YAAY,CAAC,IAAI,CAAC,EAAlB,CAAkB,CAAC;QACtD,kBAAkB,CAAC,OAAO,GAAG,cAAM,OAAA,WAAW,CAAC,IAAI,CAAC,EAAjB,CAAiB,CAAC;QACrD,kBAAkB,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;KAClC;IAED,IAAI,WAAW,EAAE;QACf,kBAAkB,CAAC,QAAQ,GAAG,CAAC,CAAC;KACjC;IAED,IAAM,SAAS,GAAG,UAAC,KAA0C;QAC3D,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO,CAAC,KAAK,EAAE;YACnC,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,YAAY,CAAC,IAAI,CAAC,CAAC;SACpB;IACH,CAAC,CAAC;IAEF,OAAO,CACL,sCACE,SAAS,EAAE,UAAU,gBACT,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,eAClB,UAAU,CAAC,IAAI,CAAC,EAC3B,IAAI,EAAC,QAAQ,IACT,kBAAkB,IACtB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,IAChB,YAAY;QAEhB,8BAAM,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,IAAG,IAAI,CAAC,OAAO,EAAE,CAAQ,CACzD,CACP,CAAC;AACJ,CAAC,CACF,EACD,aAAa,CACd,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["// Copyright Amazon.com, 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 '../../../../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;AAC/D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,eAAe,MAAM,0CAA0C,CAAC;AACvE,OAAO,EAAE,U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GAAG,UAAU,IAAI,SAAS,CAAC;IAE7D,IAAI,OAAO,EAAE;QACX,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC5B,kBAAkB,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC;KAC7C;IAED,IAAI,SAAS,EAAE;QACb,kBAAkB,CAAC,OAAO,GAAG,cAAM,OAAA,YAAY,CAAC,IAAI,CAAC,EAAlB,CAAkB,CAAC;QACtD,kBAAkB,CAAC,OAAO,GAAG,cAAM,OAAA,WAAW,CAAC,IAAI,CAAC,EAAjB,CAAiB,CAAC;QACrD,kBAAkB,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;KAClC;IAED,IAAI,WAAW,EAAE;QACf,kBAAkB,CAAC,QAAQ,GAAG,CAAC,CAAC;KACjC;IAED,IAAM,SAAS,GAAG,UAAC,KAA0C;QAC3D,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO,CAAC,KAAK,EAAE;YACnC,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,YAAY,CAAC,IAAI,CAAC,CAAC;SACpB;IACH,CAAC,CAAC;IAEF,OAAO,CACL,sCACE,SAAS,EAAE,UAAU,gBACT,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,eAClB,UAAU,CAAC,IAAI,CAAC,EAC3B,IAAI,EAAC,QAAQ,IACT,kBAAkB,IACtB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,IAChB,YAAY;QAEhB,8BAAM,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,IAAG,IAAI,CAAC,OAAO,EAAE,CAAQ,CACzD,CACP,CAAC;AACJ,CAAC,CACF,EACD,aAAa,CACd,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["// Copyright Amazon.com, 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"]}
|
|
@@ -5,8 +5,8 @@ import styles from '../../styles.css.js';
|
|
|
5
5
|
import GridDay from './day';
|
|
6
6
|
import { isSameMonth, isAfter, isBefore, isSameDay, addWeeks, addDays } from 'date-fns';
|
|
7
7
|
import { getCalendarMonth } from 'mnth';
|
|
8
|
-
import rotateDayIndexes from '../../../
|
|
9
|
-
import { renderDayName } from '../../../
|
|
8
|
+
import rotateDayIndexes from '../../../calendar/utils/rotate-day-indexes';
|
|
9
|
+
import { renderDayName } from '../../../calendar/utils/intl';
|
|
10
10
|
import clsx from 'clsx';
|
|
11
11
|
export function Grid(_a) {
|
|
12
12
|
var baseDate = _a.baseDate, selectedStartDate = _a.selectedStartDate, selectedEndDate = _a.selectedEndDate, rangeStartDate = _a.rangeStartDate, rangeEndDate = _a.rangeEndDate, focusedDate = _a.focusedDate, focusedDateRef = _a.focusedDateRef, onSelectDate = _a.onSelectDate, onGridKeyDownHandler = _a.onGridKeyDownHandler, onFocusedDateChange = _a.onFocusedDateChange, isDateEnabled = _a.isDateEnabled, locale = _a.locale, startOfWeek = _a.startOfWeek, todayAriaLabel = _a.todayAriaLabel, className = _a.className;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.js","sourceRoot":"","sources":["../../../../../src/date-range-picker/calendar/grids/grid.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,OAAO,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAGxC,OAAO,gBAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"grid.js","sourceRoot":"","sources":["../../../../../src/date-range-picker/calendar/grids/grid.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,OAAO,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAGxC,OAAO,gBAAgB,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,IAAI,MAAM,MAAM,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E7G,OAAO,OAAO,IAAI,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACzE,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useMemo } from 'react';\nimport styles from '../../styles.css.js';\nimport GridDay from './day';\nimport { isSameMonth, isAfter, isBefore, isSameDay, addWeeks, addDays } from 'date-fns';\nimport { getCalendarMonth } from 'mnth';\nimport { DateChangeHandler, DayIndex } from '../index';\nimport { DateRangePickerProps } from '../../interfaces';\nimport rotateDayIndexes from '../../../calendar/utils/rotate-day-indexes';\nimport { renderDayName } from '../../../calendar/utils/intl';\nimport clsx from 'clsx';\n\nexport interface GridProps {\n baseDate: Date;\n selectedStartDate: Date | null;\n selectedEndDate: Date | null;\n\n rangeStartDate: Date | null;\n rangeEndDate: Date | null;\n\n focusedDate: Date | null;\n focusedDateRef: React.RefObject<HTMLDivElement>;\n\n onSelectDate: DateChangeHandler;\n onGridKeyDownHandler: (e: React.KeyboardEvent) => void;\n onFocusedDateChange: React.Dispatch<React.SetStateAction<Date | null>>;\n\n isDateEnabled: DateRangePickerProps.IsDateEnabledFunction;\n\n locale: string;\n startOfWeek: DayIndex;\n todayAriaLabel: string;\n\n className?: string;\n}\n\nexport function Grid({\n baseDate,\n selectedStartDate,\n selectedEndDate,\n rangeStartDate,\n rangeEndDate,\n focusedDate,\n\n focusedDateRef,\n\n onSelectDate,\n onGridKeyDownHandler,\n onFocusedDateChange,\n\n isDateEnabled,\n\n locale,\n startOfWeek,\n todayAriaLabel,\n\n className,\n}: GridProps) {\n const baseDateTime = baseDate?.getTime();\n // `baseDateTime` is used as a more stable replacement for baseDate\n const weeks = useMemo<Date[][]>(\n () => getCalendarMonth(baseDate, { firstDayOfWeek: startOfWeek }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [baseDateTime, startOfWeek]\n );\n\n return (\n <div className={clsx(styles.grid, className)}>\n <div className={styles['calendar-day-names']}>\n {rotateDayIndexes(startOfWeek).map(i => (\n <div key={`day-name-${i}`} className={styles['calendar-day-name']}>\n {renderDayName(locale, i)}\n </div>\n ))}\n </div>\n <div className={styles['calendar-dates']} onKeyDown={onGridKeyDownHandler}>\n {weeks.map((week, weekIndex) => {\n return (\n <div key={`week-${weekIndex}`} className={styles['calendar-week']}>\n {week.map((date, dateIndex) => {\n const isStartDate = !!selectedStartDate && isSameDay(date, selectedStartDate);\n const isEndDate = !!selectedEndDate && isSameDay(date, selectedEndDate);\n const isSelected = isStartDate || isEndDate;\n const isRangeStartDate = !!rangeStartDate && isSameDay(date, rangeStartDate);\n const isRangeEndDate = !!rangeEndDate && isSameDay(date, rangeEndDate);\n\n const isFocused = !!focusedDate && isSameDay(date, focusedDate) && isSameMonth(date, baseDate);\n\n const dateIsInRange = isStartDate || isEndDate || isInRange(date, rangeStartDate, rangeEndDate);\n const inRangeStartWeek =\n rangeStartDate && isInRange(date, rangeStartDate, addDays(addWeeks(rangeStartDate, 1), -1));\n const inRangeEndWeek =\n rangeEndDate && isInRange(date, rangeEndDate, addDays(addWeeks(rangeEndDate, -1), 1));\n const onlyOneSelected =\n !!rangeStartDate && !!rangeEndDate\n ? isSameDay(rangeStartDate, rangeEndDate)\n : !selectedStartDate || !selectedEndDate;\n\n return (\n <GridDay\n key={`date-${weekIndex}-${dateIndex}`}\n locale={locale}\n baseDate={baseDate}\n isSelected={isSelected}\n isStartDate={isStartDate}\n isEndDate={isEndDate}\n onlyOneSelected={onlyOneSelected}\n isRangeStartDate={isRangeStartDate}\n isRangeEndDate={isRangeEndDate}\n date={date}\n isFocusedDate={isFocused}\n ref={isFocused ? focusedDateRef : undefined}\n todayAriaLabel={todayAriaLabel}\n onSelectDate={onSelectDate}\n onFocusDate={onFocusedDateChange}\n isInRange={dateIsInRange}\n isDateEnabled={isDateEnabled}\n isDateInFirstRow={weekIndex === 0}\n isDateInFirstColumn={dateIndex === 0}\n isDateInLastColumn={dateIndex === week.length - 1}\n isDateInSelectionStartWeek={!!inRangeStartWeek}\n isDateInSelectionEndWeek={!!inRangeEndWeek}\n />\n );\n })}\n </div>\n );\n })}\n </div>\n </div>\n );\n}\n\nfunction isInRange(date: Date, dateOne: Date | null, dateTwo: Date | null) {\n if (!dateOne || !dateTwo || isSameDay(dateOne, dateTwo)) {\n return false;\n }\n\n const inRange =\n (isAfter(date, dateOne) && isBefore(date, dateTwo)) || (isAfter(date, dateTwo) && isBefore(date, dateOne));\n\n return inRange || isSameDay(date, dateOne) || isSameDay(date, dateTwo);\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DateChangeHandler, DayIndex, MonthChangeHandler } from '../index';
|
|
3
|
-
import { MoveFocusHandler } from '../../../
|
|
3
|
+
import { MoveFocusHandler } from '../../../calendar/utils/move-focus-handler';
|
|
4
4
|
import { DateRangePickerProps } from '../../interfaces';
|
|
5
5
|
export interface GridProps {
|
|
6
6
|
baseDate: Date;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/date-range-picker/calendar/grids/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAI3D,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/date-range-picker/calendar/grids/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAI3D,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,k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,EAClB,eAAe,EAAE,eAAe,EAChC,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,EACtD,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAClD,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,EAC1B,oBAAoB,EAAE,oBAAoB,EAC1C,mBAAmB,EAAE,mBAAmB,EACxC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,GAC9B,CACmB,CACnB,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport { KeyCode } from '../../../internal/keycode';\nimport { addDays, addWeeks, isSameMonth, isAfter, isBefore, addMonths, min, max } from 'date-fns';\n\nimport { DateChangeHandler, DayIndex, MonthChangeHandler } from '../index';\nimport { MoveFocusHandler } from '../../../date-picker/calendar/utils/move-focus-handler';\nimport { DateRangePickerProps } from '../../interfaces';\nimport InternalSpaceBetween from '../../../space-between/internal';\nimport { Grid } from './grid';\nimport styles from '../../styles.css.js';\n\nimport useFocusVisible from '../../../internal/hooks/focus-visible/index';\nimport { getBaseDate } from '../get-base-date';\nimport { hasValue } from '../../../internal/utils/has-value';\n\nfunction isVisible(date: Date, baseDate: Date, isSingleGrid: boolean) {\n if (isSingleGrid) {\n return isSameMonth(date, baseDate);\n }\n\n const previousMonth = addMonths(baseDate, -1);\n\n return isSameMonth(date, previousMonth) || isSameMonth(date, baseDate);\n}\n\nexport interface GridProps {\n baseDate: Date;\n selectedStartDate: Date | null;\n selectedEndDate: Date | null;\n\n focusedDate: Date | null;\n onFocusedDateChange: React.Dispatch<React.SetStateAction<Date | null>>;\n\n isDateEnabled: DateRangePickerProps.IsDateEnabledFunction;\n isSingleGrid: boolean;\n\n onSelectDate: DateChangeHandler;\n onChangeMonth: MonthChangeHandler;\n handleFocusMove: MoveFocusHandler;\n\n locale: string;\n startOfWeek: DayIndex;\n todayAriaLabel: string;\n}\n\nexport function selectFocusedDate(\n selected: Date | null,\n baseDate: Date,\n isDateEnabled: DateRangePickerProps.IsDateEnabledFunction\n) {\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\nexport const Grids = ({\n baseDate,\n selectedStartDate,\n selectedEndDate,\n\n focusedDate,\n onFocusedDateChange,\n\n isDateEnabled,\n isSingleGrid,\n\n onSelectDate,\n onChangeMonth,\n handleFocusMove,\n\n locale,\n startOfWeek,\n todayAriaLabel,\n}: GridProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const [gridHasFocus, setGridHasFocus] = useState(false);\n\n const focusedDateRef = useRef<HTMLDivElement>(null);\n\n const baseDateTime = baseDate?.getTime();\n const focusedDateTime = focusedDate?.getTime();\n\n useEffect(() => {\n if (focusedDate && !isVisible(focusedDate, baseDate, isSingleGrid)) {\n // The nearestBaseDate depends on the direction of the month change\n const direction = isAfter(focusedDate, baseDate) ? 'backwards' : 'forwards';\n\n const newMonth = !isSingleGrid && direction === 'backwards' ? addMonths(baseDate, -1) : baseDate;\n const nearestBaseDate = getBaseDate(newMonth, direction === 'backwards' ? -1 : 1, isDateEnabled);\n\n const newFocusedDate = selectFocusedDate(focusedDate, nearestBaseDate, isDateEnabled);\n\n onFocusedDateChange(newFocusedDate);\n }\n // `baseDateTime` and `focusedDateTime` are used as more stable replacements for baseDate and focusedDate\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [focusedDateTime, baseDateTime, isSingleGrid, isDateEnabled, onFocusedDateChange]);\n\n const onGridKeyDownHandler = (e: React.KeyboardEvent) => {\n let updatedFocusDate;\n\n if (focusedDate === null) {\n return;\n }\n\n switch (e.keyCode) {\n case KeyCode.enter:\n e.preventDefault();\n if (focusedDate) {\n onSelectDate(focusedDate);\n }\n return;\n case KeyCode.right:\n e.preventDefault();\n updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, date => addDays(date, 1));\n break;\n case KeyCode.left:\n e.preventDefault();\n updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, date => addDays(date, -1));\n break;\n case KeyCode.up:\n e.preventDefault();\n updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, date => addWeeks(date, -1));\n break;\n case KeyCode.down:\n e.preventDefault();\n updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, date => addWeeks(date, 1));\n break;\n default:\n return;\n }\n\n const updatedDateIsVisible = isVisible(updatedFocusDate, baseDate, isSingleGrid);\n\n if (!updatedDateIsVisible) {\n const newMonthIsOnLeftSide = !isSingleGrid && isBefore(updatedFocusDate, baseDate);\n\n onChangeMonth(newMonthIsOnLeftSide ? addMonths(updatedFocusDate, 1) : updatedFocusDate);\n }\n onFocusedDateChange(updatedFocusDate);\n };\n\n useEffect(() => {\n // focus current date if the focus is already inside the calendar\n if (focusedDate !== null && gridHasFocus) {\n if (focusedDateRef.current && focusedDateRef.current !== document.activeElement) {\n focusedDateRef.current.focus();\n }\n }\n // `focusedDateTime` is used as a more stable replacement for focusedDate\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [focusedDateTime, gridHasFocus]);\n\n const onGridBlur = (event: React.FocusEvent) => {\n /*\n IE11 does not support event.relatedTarget, but sets document.activeElement to the newly\n focused element before the onBlur handler is called.\n\n However, other browsers do not make any guarantees for the value of document.activeElement\n during the execution of an onBlur handler. Therefore, we have to use event.relatedTarget\n instead.\n */\n const newFocusTarget = event.relatedTarget || document.activeElement;\n const newFocusTargetIsInGrid = containerRef.current?.contains(newFocusTarget as Node);\n if (newFocusTarget && !newFocusTargetIsInGrid && gridHasFocus) {\n setGridHasFocus(false);\n }\n };\n\n const onGridFocus = () => {\n if (!gridHasFocus) {\n setGridHasFocus(true);\n }\n };\n\n const focusVisible = useFocusVisible();\n\n const isRangeVisible =\n (selectedStartDate && selectedEndDate) || (gridHasFocus && !!focusVisible['data-awsui-focus-visible']);\n\n const rangeEnds: Date[] = [selectedStartDate ?? focusedDate, selectedEndDate ?? focusedDate].filter(hasValue);\n\n const rangeStartDate = min(rangeEnds);\n const rangeEndDate = max(rangeEnds);\n\n return (\n <div ref={containerRef} onFocus={onGridFocus} onBlur={onGridBlur}>\n <InternalSpaceBetween size=\"xs\" direction=\"horizontal\">\n {!isSingleGrid && (\n <Grid\n className={styles['first-grid']}\n baseDate={addMonths(baseDate, -1)}\n selectedEndDate={selectedEndDate}\n selectedStartDate={selectedStartDate}\n rangeStartDate={isRangeVisible ? rangeStartDate : null}\n rangeEndDate={isRangeVisible ? rangeEndDate : null}\n focusedDate={focusedDate}\n focusedDateRef={focusedDateRef}\n isDateEnabled={isDateEnabled}\n onSelectDate={onSelectDate}\n onGridKeyDownHandler={onGridKeyDownHandler}\n onFocusedDateChange={onFocusedDateChange}\n locale={locale}\n startOfWeek={startOfWeek}\n todayAriaLabel={todayAriaLabel}\n />\n )}\n <Grid\n className={styles['second-grid']}\n baseDate={baseDate}\n selectedEndDate={selectedEndDate}\n selectedStartDate={selectedStartDate}\n rangeStartDate={isRangeVisible ? rangeStartDate : null}\n rangeEndDate={isRangeVisible ? rangeEndDate : null}\n focusedDate={focusedDate}\n focusedDateRef={focusedDateRef}\n isDateEnabled={isDateEnabled}\n onSelectDate={onSelectDate}\n onGridKeyDownHandler={onGridKeyDownHandler}\n onFocusedDateChange={onFocusedDateChange}\n locale={locale}\n startOfWeek={startOfWeek}\n todayAriaLabel={todayAriaLabel}\n />\n </InternalSpaceBetween>\n </div>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/date-range-pic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AE,cAAc,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAClD,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,EAC1B,oBAAoB,EAAE,oBAAoB,EAC1C,mBAAmB,EAAE,mBAAmB,EACxC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,GAC9B,CACH;YACD,oBAAC,IAAI,IACH,SAAS,EAAE,MAAM,CAAC,aAAa,CAAC,EAChC,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,EAChC,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,EACtD,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAClD,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,EAC1B,oBAAoB,EAAE,oBAAoB,EAC1C,mBAAmB,EAAE,mBAAmB,EACxC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,GAC9B,CACmB,CACnB,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport { KeyCode } from '../../../internal/keycode';\nimport { addDays, addWeeks, isSameMonth, isAfter, isBefore, addMonths, min, max } from 'date-fns';\n\nimport { DateChangeHandler, DayIndex, MonthChangeHandler } from '../index';\nimport { MoveFocusHandler } from '../../../calendar/utils/move-focus-handler';\nimport { DateRangePickerProps } from '../../interfaces';\nimport InternalSpaceBetween from '../../../space-between/internal';\nimport { Grid } from './grid';\nimport styles from '../../styles.css.js';\n\nimport useFocusVisible from '../../../internal/hooks/focus-visible/index';\nimport { getBaseDate } from '../get-base-date';\nimport { hasValue } from '../../../internal/utils/has-value';\n\nfunction isVisible(date: Date, baseDate: Date, isSingleGrid: boolean) {\n if (isSingleGrid) {\n return isSameMonth(date, baseDate);\n }\n\n const previousMonth = addMonths(baseDate, -1);\n\n return isSameMonth(date, previousMonth) || isSameMonth(date, baseDate);\n}\n\nexport interface GridProps {\n baseDate: Date;\n selectedStartDate: Date | null;\n selectedEndDate: Date | null;\n\n focusedDate: Date | null;\n onFocusedDateChange: React.Dispatch<React.SetStateAction<Date | null>>;\n\n isDateEnabled: DateRangePickerProps.IsDateEnabledFunction;\n isSingleGrid: boolean;\n\n onSelectDate: DateChangeHandler;\n onChangeMonth: MonthChangeHandler;\n handleFocusMove: MoveFocusHandler;\n\n locale: string;\n startOfWeek: DayIndex;\n todayAriaLabel: string;\n}\n\nexport function selectFocusedDate(\n selected: Date | null,\n baseDate: Date,\n isDateEnabled: DateRangePickerProps.IsDateEnabledFunction\n) {\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\nexport const Grids = ({\n baseDate,\n selectedStartDate,\n selectedEndDate,\n\n focusedDate,\n onFocusedDateChange,\n\n isDateEnabled,\n isSingleGrid,\n\n onSelectDate,\n onChangeMonth,\n handleFocusMove,\n\n locale,\n startOfWeek,\n todayAriaLabel,\n}: GridProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const [gridHasFocus, setGridHasFocus] = useState(false);\n\n const focusedDateRef = useRef<HTMLDivElement>(null);\n\n const baseDateTime = baseDate?.getTime();\n const focusedDateTime = focusedDate?.getTime();\n\n useEffect(() => {\n if (focusedDate && !isVisible(focusedDate, baseDate, isSingleGrid)) {\n // The nearestBaseDate depends on the direction of the month change\n const direction = isAfter(focusedDate, baseDate) ? 'backwards' : 'forwards';\n\n const newMonth = !isSingleGrid && direction === 'backwards' ? addMonths(baseDate, -1) : baseDate;\n const nearestBaseDate = getBaseDate(newMonth, direction === 'backwards' ? -1 : 1, isDateEnabled);\n\n const newFocusedDate = selectFocusedDate(focusedDate, nearestBaseDate, isDateEnabled);\n\n onFocusedDateChange(newFocusedDate);\n }\n // `baseDateTime` and `focusedDateTime` are used as more stable replacements for baseDate and focusedDate\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [focusedDateTime, baseDateTime, isSingleGrid, isDateEnabled, onFocusedDateChange]);\n\n const onGridKeyDownHandler = (e: React.KeyboardEvent) => {\n let updatedFocusDate;\n\n if (focusedDate === null) {\n return;\n }\n\n switch (e.keyCode) {\n case KeyCode.enter:\n e.preventDefault();\n if (focusedDate) {\n onSelectDate(focusedDate);\n }\n return;\n case KeyCode.right:\n e.preventDefault();\n updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, date => addDays(date, 1));\n break;\n case KeyCode.left:\n e.preventDefault();\n updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, date => addDays(date, -1));\n break;\n case KeyCode.up:\n e.preventDefault();\n updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, date => addWeeks(date, -1));\n break;\n case KeyCode.down:\n e.preventDefault();\n updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, date => addWeeks(date, 1));\n break;\n default:\n return;\n }\n\n const updatedDateIsVisible = isVisible(updatedFocusDate, baseDate, isSingleGrid);\n\n if (!updatedDateIsVisible) {\n const newMonthIsOnLeftSide = !isSingleGrid && isBefore(updatedFocusDate, baseDate);\n\n onChangeMonth(newMonthIsOnLeftSide ? addMonths(updatedFocusDate, 1) : updatedFocusDate);\n }\n onFocusedDateChange(updatedFocusDate);\n };\n\n useEffect(() => {\n // focus current date if the focus is already inside the calendar\n if (focusedDate !== null && gridHasFocus) {\n if (focusedDateRef.current && focusedDateRef.current !== document.activeElement) {\n focusedDateRef.current.focus();\n }\n }\n // `focusedDateTime` is used as a more stable replacement for focusedDate\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [focusedDateTime, gridHasFocus]);\n\n const onGridBlur = (event: React.FocusEvent) => {\n /*\n IE11 does not support event.relatedTarget, but sets document.activeElement to the newly\n focused element before the onBlur handler is called.\n\n However, other browsers do not make any guarantees for the value of document.activeElement\n during the execution of an onBlur handler. Therefore, we have to use event.relatedTarget\n instead.\n */\n const newFocusTarget = event.relatedTarget || document.activeElement;\n const newFocusTargetIsInGrid = containerRef.current?.contains(newFocusTarget as Node);\n if (newFocusTarget && !newFocusTargetIsInGrid && gridHasFocus) {\n setGridHasFocus(false);\n }\n };\n\n const onGridFocus = () => {\n if (!gridHasFocus) {\n setGridHasFocus(true);\n }\n };\n\n const focusVisible = useFocusVisible();\n\n const isRangeVisible =\n (selectedStartDate && selectedEndDate) || (gridHasFocus && !!focusVisible['data-awsui-focus-visible']);\n\n const rangeEnds: Date[] = [selectedStartDate ?? focusedDate, selectedEndDate ?? focusedDate].filter(hasValue);\n\n const rangeStartDate = min(rangeEnds);\n const rangeEndDate = max(rangeEnds);\n\n return (\n <div ref={containerRef} onFocus={onGridFocus} onBlur={onGridBlur}>\n <InternalSpaceBetween size=\"xs\" direction=\"horizontal\">\n {!isSingleGrid && (\n <Grid\n className={styles['first-grid']}\n baseDate={addMonths(baseDate, -1)}\n selectedEndDate={selectedEndDate}\n selectedStartDate={selectedStartDate}\n rangeStartDate={isRangeVisible ? rangeStartDate : null}\n rangeEndDate={isRangeVisible ? rangeEndDate : null}\n focusedDate={focusedDate}\n focusedDateRef={focusedDateRef}\n isDateEnabled={isDateEnabled}\n onSelectDate={onSelectDate}\n onGridKeyDownHandler={onGridKeyDownHandler}\n onFocusedDateChange={onFocusedDateChange}\n locale={locale}\n startOfWeek={startOfWeek}\n todayAriaLabel={todayAriaLabel}\n />\n )}\n <Grid\n className={styles['second-grid']}\n baseDate={baseDate}\n selectedEndDate={selectedEndDate}\n selectedStartDate={selectedStartDate}\n rangeStartDate={isRangeVisible ? rangeStartDate : null}\n rangeEndDate={isRangeVisible ? rangeEndDate : null}\n focusedDate={focusedDate}\n focusedDateRef={focusedDateRef}\n isDateEnabled={isDateEnabled}\n onSelectDate={onSelectDate}\n onGridKeyDownHandler={onGridKeyDownHandler}\n onFocusedDateChange={onFocusedDateChange}\n locale={locale}\n startOfWeek={startOfWeek}\n todayAriaLabel={todayAriaLabel}\n />\n </InternalSpaceBetween>\n </div>\n );\n};\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { add } from 'date-fns';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import styles from '../../styles.css.js';
|
|
6
|
-
import { renderMonthAndYear } from '../../../
|
|
6
|
+
import { renderMonthAndYear } from '../../../calendar/utils/intl';
|
|
7
7
|
import HeaderButton from './button';
|
|
8
8
|
var CalendarHeader = function (_a) {
|
|
9
9
|
var baseDate = _a.baseDate, locale = _a.locale, onChangeMonth = _a.onChangeMonth, previousMonthLabel = _a.previousMonthLabel, nextMonthLabel = _a.nextMonthLabel, isSingleGrid = _a.isSingleGrid;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/date-range-picker/calendar/header/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/date-range-picker/calendar/header/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,YAAY,MAAM,UAAU,CAAC;AAWpC,IAAM,cAAc,GAAG,UAAC,EAOF;QANpB,QAAQ,cAAA,EACR,MAAM,YAAA,EACN,aAAa,mBAAA,EACb,kBAAkB,wBAAA,EAClB,cAAc,oBAAA,EACd,YAAY,kBAAA;IAEZ,OAAO,CACL,6BAAK,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC;QACvC,oBAAC,YAAY,IAAC,SAAS,EAAE,kBAAkB,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,GAAI;QAC/F,0CAAe,QAAQ,EAAC,SAAS,EAAE,MAAM,CAAC,gCAAgC,CAAC;YACxE,CAAC,YAAY,IAAI,CAChB,6BAAK,SAAS,EAAE,MAAM,CAAC,uBAAuB,CAAC,IAC5C,kBAAkB,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CACtD,CACP;YACD,6BAAK,SAAS,EAAE,MAAM,CAAC,uBAAuB,CAAC,IAAG,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAO,CACzF;QACN,oBAAC,YAAY,IAAC,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,aAAa,GAAI,CACxF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { add } from 'date-fns';\nimport React from 'react';\nimport styles from '../../styles.css.js';\nimport { renderMonthAndYear } from '../../../calendar/utils/intl';\nimport HeaderButton from './button';\n\ninterface CalendarHeaderProps {\n baseDate: Date;\n locale: string;\n onChangeMonth: (prev?: boolean) => void;\n previousMonthLabel: string;\n nextMonthLabel: string;\n isSingleGrid: boolean;\n}\n\nconst CalendarHeader = ({\n baseDate,\n locale,\n onChangeMonth,\n previousMonthLabel,\n nextMonthLabel,\n isSingleGrid,\n}: CalendarHeaderProps) => {\n return (\n <div className={styles['calendar-header']}>\n <HeaderButton ariaLabel={previousMonthLabel} isPrevious={true} onChangeMonth={onChangeMonth} />\n <div aria-live=\"polite\" className={styles['calendar-header-months-wrapper']}>\n {!isSingleGrid && (\n <div className={styles['calendar-header-month']}>\n {renderMonthAndYear(locale, add(baseDate, { months: -1 }))}\n </div>\n )}\n <div className={styles['calendar-header-month']}>{renderMonthAndYear(locale, baseDate)}</div>\n </div>\n <HeaderButton ariaLabel={nextMonthLabel} isPrevious={false} onChangeMonth={onChangeMonth} />\n </div>\n );\n};\n\nexport default CalendarHeader;\n"]}
|