@cloudscape-design/components 3.0.94 → 3.0.96
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/THIRD-PARTY-LICENSES +225 -1
- package/date-range-picker/calendar/grids/grid.d.ts +1 -2
- package/date-range-picker/calendar/grids/grid.d.ts.map +1 -1
- package/date-range-picker/calendar/grids/grid.js.map +1 -1
- package/date-range-picker/calendar/grids/index.d.ts +1 -2
- 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/index.d.ts +7 -12
- package/date-range-picker/calendar/index.d.ts.map +1 -1
- package/date-range-picker/calendar/index.js +34 -46
- package/date-range-picker/calendar/index.js.map +1 -1
- package/date-range-picker/calendar/range-inputs.d.ts +20 -0
- package/date-range-picker/calendar/range-inputs.d.ts.map +1 -0
- package/date-range-picker/calendar/range-inputs.js +23 -0
- package/date-range-picker/calendar/range-inputs.js.map +1 -0
- package/date-range-picker/index.js +1 -1
- package/date-range-picker/index.js.map +1 -1
- package/date-range-picker/interfaces.d.ts +6 -0
- package/date-range-picker/interfaces.d.ts.map +1 -1
- package/date-range-picker/interfaces.js.map +1 -1
- package/internal/components/cartesian-chart/scales.d.ts +1 -1
- package/internal/components/cartesian-chart/scales.d.ts.map +1 -1
- package/internal/components/cartesian-chart/scales.js +1 -1
- package/internal/components/cartesian-chart/scales.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/vendor/d3-scale.d.ts +2 -0
- package/internal/vendor/d3-scale.d.ts.map +1 -0
- package/internal/vendor/d3-scale.js +2995 -0
- package/internal/vendor/d3-scale.js.map +1 -0
- package/mixed-line-bar-chart/bar-series.js.map +1 -1
- package/package.json +1 -2
- package/popover/utils/positions.js +8 -8
- package/popover/utils/positions.js.map +1 -1
- package/test-utils/tsconfig.tsbuildinfo +1 -1
package/THIRD-PARTY-LICENSES
CHANGED
|
@@ -21,4 +21,228 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
21
21
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
22
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
23
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
-
SOFTWARE.
|
|
24
|
+
SOFTWARE.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
Name: d3-array
|
|
30
|
+
Version: 3.2.0
|
|
31
|
+
License: ISC
|
|
32
|
+
Private: false
|
|
33
|
+
Description: Array manipulation, ordering, searching, summarizing, etc.
|
|
34
|
+
Repository: git+https://github.com/d3/d3-array.git
|
|
35
|
+
Homepage: https://d3js.org/d3-array/
|
|
36
|
+
Author: Mike Bostock (http://bost.ocks.org/mike)
|
|
37
|
+
License Copyright:
|
|
38
|
+
===
|
|
39
|
+
|
|
40
|
+
Copyright 2010-2022 Mike Bostock
|
|
41
|
+
|
|
42
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
43
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
44
|
+
and this permission notice appear in all copies.
|
|
45
|
+
|
|
46
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
47
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
48
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
49
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
50
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
51
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
52
|
+
THIS SOFTWARE.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
Name: internmap
|
|
58
|
+
Version: 2.0.3
|
|
59
|
+
License: ISC
|
|
60
|
+
Private: false
|
|
61
|
+
Description: Map and Set with automatic key interning
|
|
62
|
+
Repository: git+https://github.com/mbostock/internmap.git
|
|
63
|
+
Homepage: https://github.com/mbostock/internmap/
|
|
64
|
+
Author: Mike Bostock (https://bost.ocks.org/mike)
|
|
65
|
+
License Copyright:
|
|
66
|
+
===
|
|
67
|
+
|
|
68
|
+
Copyright 2021 Mike Bostock
|
|
69
|
+
|
|
70
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
71
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
72
|
+
and this permission notice appear in all copies.
|
|
73
|
+
|
|
74
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
75
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
76
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
77
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
78
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
79
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
80
|
+
THIS SOFTWARE.
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
Name: d3-scale
|
|
86
|
+
Version: 4.0.2
|
|
87
|
+
License: ISC
|
|
88
|
+
Private: false
|
|
89
|
+
Description: Encodings that map abstract data to visual representation.
|
|
90
|
+
Repository: git+https://github.com/d3/d3-scale.git
|
|
91
|
+
Homepage: https://d3js.org/d3-scale/
|
|
92
|
+
Author: Mike Bostock (https://bost.ocks.org/mike)
|
|
93
|
+
License Copyright:
|
|
94
|
+
===
|
|
95
|
+
|
|
96
|
+
Copyright 2010-2021 Mike Bostock
|
|
97
|
+
|
|
98
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
99
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
100
|
+
and this permission notice appear in all copies.
|
|
101
|
+
|
|
102
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
103
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
104
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
105
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
106
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
107
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
108
|
+
THIS SOFTWARE.
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
Name: d3-color
|
|
114
|
+
Version: 3.1.0
|
|
115
|
+
License: ISC
|
|
116
|
+
Private: false
|
|
117
|
+
Description: Color spaces! RGB, HSL, Cubehelix, Lab and HCL (Lch).
|
|
118
|
+
Repository: git+https://github.com/d3/d3-color.git
|
|
119
|
+
Homepage: https://d3js.org/d3-color/
|
|
120
|
+
Author: Mike Bostock (http://bost.ocks.org/mike)
|
|
121
|
+
License Copyright:
|
|
122
|
+
===
|
|
123
|
+
|
|
124
|
+
Copyright 2010-2022 Mike Bostock
|
|
125
|
+
|
|
126
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
127
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
128
|
+
and this permission notice appear in all copies.
|
|
129
|
+
|
|
130
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
131
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
132
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
133
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
134
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
135
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
136
|
+
THIS SOFTWARE.
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
Name: d3-interpolate
|
|
142
|
+
Version: 3.0.1
|
|
143
|
+
License: ISC
|
|
144
|
+
Private: false
|
|
145
|
+
Description: Interpolate numbers, colors, strings, arrays, objects, whatever!
|
|
146
|
+
Repository: git+https://github.com/d3/d3-interpolate.git
|
|
147
|
+
Homepage: https://d3js.org/d3-interpolate/
|
|
148
|
+
Author: Mike Bostock (http://bost.ocks.org/mike)
|
|
149
|
+
License Copyright:
|
|
150
|
+
===
|
|
151
|
+
|
|
152
|
+
Copyright 2010-2021 Mike Bostock
|
|
153
|
+
|
|
154
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
155
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
156
|
+
and this permission notice appear in all copies.
|
|
157
|
+
|
|
158
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
159
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
160
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
161
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
162
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
163
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
164
|
+
THIS SOFTWARE.
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
Name: d3-format
|
|
170
|
+
Version: 3.1.0
|
|
171
|
+
License: ISC
|
|
172
|
+
Private: false
|
|
173
|
+
Description: Format numbers for human consumption.
|
|
174
|
+
Repository: git+https://github.com/d3/d3-format.git
|
|
175
|
+
Homepage: https://d3js.org/d3-format/
|
|
176
|
+
Author: Mike Bostock (http://bost.ocks.org/mike)
|
|
177
|
+
License Copyright:
|
|
178
|
+
===
|
|
179
|
+
|
|
180
|
+
Copyright 2010-2021 Mike Bostock
|
|
181
|
+
|
|
182
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
183
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
184
|
+
and this permission notice appear in all copies.
|
|
185
|
+
|
|
186
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
187
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
188
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
189
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
190
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
191
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
192
|
+
THIS SOFTWARE.
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
Name: d3-time
|
|
198
|
+
Version: 3.0.0
|
|
199
|
+
License: ISC
|
|
200
|
+
Private: false
|
|
201
|
+
Description: A calculator for humanity’s peculiar conventions of time.
|
|
202
|
+
Repository: git+https://github.com/d3/d3-time.git
|
|
203
|
+
Homepage: https://d3js.org/d3-time/
|
|
204
|
+
Author: Mike Bostock (http://bost.ocks.org/mike)
|
|
205
|
+
License Copyright:
|
|
206
|
+
===
|
|
207
|
+
|
|
208
|
+
Copyright 2010-2021 Mike Bostock
|
|
209
|
+
|
|
210
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
211
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
212
|
+
and this permission notice appear in all copies.
|
|
213
|
+
|
|
214
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
215
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
216
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
217
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
218
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
219
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
220
|
+
THIS SOFTWARE.
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
Name: d3-time-format
|
|
226
|
+
Version: 4.1.0
|
|
227
|
+
License: ISC
|
|
228
|
+
Private: false
|
|
229
|
+
Description: A JavaScript time formatter and parser inspired by strftime and strptime.
|
|
230
|
+
Repository: git+https://github.com/d3/d3-time-format.git
|
|
231
|
+
Homepage: https://d3js.org/d3-time-format/
|
|
232
|
+
Author: Mike Bostock (http://bost.ocks.org/mike)
|
|
233
|
+
License Copyright:
|
|
234
|
+
===
|
|
235
|
+
|
|
236
|
+
Copyright 2010-2021 Mike Bostock
|
|
237
|
+
|
|
238
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
239
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
240
|
+
and this permission notice appear in all copies.
|
|
241
|
+
|
|
242
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
243
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
244
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
245
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
246
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
247
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
248
|
+
THIS SOFTWARE.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { DayIndex } from '
|
|
3
|
-
import { DateRangePickerProps } from '../../interfaces';
|
|
2
|
+
import { DateRangePickerProps, DayIndex } from '../../interfaces';
|
|
4
3
|
/**
|
|
5
4
|
* Calendar grid supports two mechanisms of keyboard navigation:
|
|
6
5
|
* - Native screen-reader table navigation (semantic table markup);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../../../src/date-range-picker/calendar/grids/grid.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAcvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../../../src/date-range-picker/calendar/grids/grid.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAcvC,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAOlE;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,IAAI,CAAC;IACf,iBAAiB,EAAE,IAAI,GAAG,IAAI,CAAC;IAC/B,eAAe,EAAE,IAAI,GAAG,IAAI,CAAC;IAE7B,cAAc,EAAE,IAAI,GAAG,IAAI,CAAC;IAC5B,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAE1B,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;IAEtD,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,oBAAoB,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;IACvD,mBAAmB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC;IAEvE,aAAa,EAAE,oBAAoB,CAAC,qBAAqB,CAAC;IAE1D,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,QAAQ,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IAEvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,IAAI,CAAC,EACnB,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,WAAW,EAEX,cAAc,EAEd,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,EAEnB,aAAa,EAEb,MAAM,EACN,WAAW,EACX,cAAc,EACd,cAAc,EAEd,SAAS,GACV,EAAE,SAAS,eAuIX"}
|
|
@@ -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,iBAAiB,CAAC;AACrC,OAAO,EACL,WAAW,EACX,OAAO,EACP,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,OAAO,GACR,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,eAAe,MAAM,gDAAgD,CAAC;AAC7E,OAAO,gBAAgB,MAAM,yDAAyD,CAAC;AA0CvF,MAAM,UAAU,IAAI,CAAC,EAsBT;QArBV,QAAQ,cAAA,EACR,iBAAiB,uBAAA,EACjB,eAAe,qBAAA,EACf,cAAc,oBAAA,EACd,YAAY,kBAAA,EACZ,WAAW,iBAAA,EAEX,cAAc,oBAAA,EAEd,YAAY,kBAAA,EACZ,oBAAoB,0BAAA,EACpB,mBAAmB,yBAAA,EAEnB,aAAa,mBAAA,EAEb,MAAM,YAAA,EACN,WAAW,iBAAA,EACX,cAAc,oBAAA,EACd,cAAc,oBAAA,EAEd,SAAS,eAAA;IAET,IAAM,YAAY,GAAG,QAAQ,aAAR,QAAQ,uBAAR,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["// 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 {\n isSameMonth,\n isAfter,\n isBefore,\n isSameDay,\n addWeeks,\n addDays,\n isLastDayOfMonth,\n getDaysInMonth,\n isToday,\n} from 'date-fns';\nimport { getCalendarMonth } from 'mnth';\nimport { DayIndex } from '../index';\nimport { DateRangePickerProps } from '../../interfaces';\nimport { getDateLabel, renderDayName } from '../../../calendar/utils/intl';\nimport clsx from 'clsx';\nimport { formatDate } from '../../../internal/utils/date-time';\nimport useFocusVisible from '../../../internal/hooks/focus-visible/index.js';\nimport ScreenreaderOnly from '../../../internal/components/screenreader-only/index.js';\n\n/**\n * Calendar grid supports two mechanisms of keyboard navigation:\n * - Native screen-reader table navigation (semantic table markup);\n * - Keyboard arrow-keys navigation (a custom key-down handler).\n *\n * The implementation largely follows the w3 example (https://www.w3.org/WAI/ARIA/apg/example-index/dialog-modal/datepicker-dialog) and shares the following issues:\n * - (table navigation) Chrome+VO - weekday is announced twice when navigating to the calendar's header;\n * - (table navigation) Safari+VO - \"dimmed\" state is announced twice;\n * - (table navigation) Firefox/Chrome+NVDA - cannot use table navigation if any cell has a focus;\n * - (keyboard navigation) Firefox+NVDA - every day is announced as \"not selected\";\n * - (keyboard navigation) Safari/Chrome+VO - weekdays are not announced;\n * - (keyboard navigation) Safari/Chrome+VO - days are not announced as interactive (clickable or selectable);\n * - (keyboard navigation) Safari/Chrome+VO - day announcements are not interruptive and can be missed if navigating fast.\n */\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<HTMLTableCellElement>;\n\n onSelectDate: (date: Date) => void;\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 ariaLabelledby: 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 ariaLabelledby,\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 const weekdays = weeks[0].map(date => date.getDay());\n\n const focusVisible = useFocusVisible();\n\n return (\n <table role=\"grid\" aria-labelledby={ariaLabelledby} className={clsx(styles.grid, className)}>\n <thead>\n <tr>\n {weekdays.map(dayIndex => (\n <th key={dayIndex} scope=\"col\" className={clsx(styles['grid-cell'], styles['day-header'])}>\n <span aria-hidden=\"true\">{renderDayName(locale, dayIndex, 'short')}</span>\n <ScreenreaderOnly>{renderDayName(locale, dayIndex, 'long')}</ScreenreaderOnly>\n </th>\n ))}\n </tr>\n </thead>\n <tbody onKeyDown={onGridKeyDownHandler}>\n {weeks.map((week, weekIndex) => {\n return (\n <tr key={weekIndex} className={styles.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 const isEnabled = !isDateEnabled || isDateEnabled(date);\n const isFocusable = isFocused && isEnabled;\n\n const baseClasses = {\n [styles.day]: true,\n [styles['grid-cell']]: true,\n [styles['in-first-row']]: weekIndex === 0,\n [styles['in-first-column']]: dateIndex === 0,\n };\n\n if (!isSameMonth(date, baseDate)) {\n return (\n <td\n key={`${weekIndex}:${dateIndex}`}\n ref={isFocused ? focusedDateRef : undefined}\n className={clsx(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 ></td>\n );\n }\n\n const handlers: React.HTMLAttributes<HTMLDivElement> = {};\n if (isEnabled) {\n handlers.onClick = () => onSelectDate(date);\n handlers.onFocus = () => onFocusedDateChange(date);\n }\n\n // Can't be focused.\n let tabIndex = undefined;\n if (isFocusable && isEnabled) {\n // Next focus target.\n tabIndex = 0;\n } else if (isEnabled) {\n // Can be focused programmatically.\n tabIndex = -1;\n }\n\n // Screen-reader announcement for the focused day.\n let dayAnnouncement = getDateLabel(locale, date, 'short');\n if (isToday(date)) {\n dayAnnouncement += '. ' + todayAriaLabel;\n }\n\n return (\n <td\n ref={isFocused ? focusedDateRef : undefined}\n key={`${weekIndex}:${dateIndex}`}\n className={clsx(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']]: dateIsInRange,\n [styles['in-range-border-top']]: !!inRangeStartWeek || date.getDate() <= 7,\n [styles['in-range-border-bottom']]: !!inRangeEndWeek || date.getDate() > getDaysInMonth(date) - 7,\n [styles['in-range-border-left']]: dateIndex === 0 || date.getDate() === 1 || isRangeStartDate,\n [styles['in-range-border-right']]:\n dateIndex === week.length - 1 || isLastDayOfMonth(date) || isRangeEndDate,\n [styles.today]: isToday(date),\n })}\n aria-selected={isEnabled ? isSelected || dateIsInRange : undefined}\n aria-current={isToday(date) ? 'date' : undefined}\n data-date={formatDate(date)}\n aria-disabled={!isEnabled}\n tabIndex={tabIndex}\n {...handlers}\n {...focusVisible}\n >\n <span className={styles['day-inner']} aria-hidden=\"true\">\n {date.getDate()}\n </span>\n <ScreenreaderOnly>{dayAnnouncement}</ScreenreaderOnly>\n </td>\n );\n })}\n </tr>\n );\n })}\n </tbody>\n </table>\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
|
+
{"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,iBAAiB,CAAC;AACrC,OAAO,EACL,WAAW,EACX,OAAO,EACP,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,OAAO,GACR,MAAM,UAAU,CAAC;AACl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O,EAAE,CACV;oBACP,oBAAC,gBAAgB,QAAE,eAAe,CAAoB,CACnD,CACN,CAAC;YACJ,CAAC,CAAC,CACC,CACN,CAAC;QACJ,CAAC,CAAC,CACI,CACF,CACT,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,IAAU,EAAE,OAAoB,EAAE,OAAoB;IACvE,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE;QACvD,OAAO,KAAK,CAAC;KACd;IAED,IAAM,OAAO,GACX,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAE7G,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 {\n isSameMonth,\n isAfter,\n isBefore,\n isSameDay,\n addWeeks,\n addDays,\n isLastDayOfMonth,\n getDaysInMonth,\n isToday,\n} from 'date-fns';\nimport { getCalendarMonth } from 'mnth';\nimport { DateRangePickerProps, DayIndex } from '../../interfaces';\nimport { getDateLabel, renderDayName } from '../../../calendar/utils/intl';\nimport clsx from 'clsx';\nimport { formatDate } from '../../../internal/utils/date-time';\nimport useFocusVisible from '../../../internal/hooks/focus-visible/index.js';\nimport ScreenreaderOnly from '../../../internal/components/screenreader-only/index.js';\n\n/**\n * Calendar grid supports two mechanisms of keyboard navigation:\n * - Native screen-reader table navigation (semantic table markup);\n * - Keyboard arrow-keys navigation (a custom key-down handler).\n *\n * The implementation largely follows the w3 example (https://www.w3.org/WAI/ARIA/apg/example-index/dialog-modal/datepicker-dialog) and shares the following issues:\n * - (table navigation) Chrome+VO - weekday is announced twice when navigating to the calendar's header;\n * - (table navigation) Safari+VO - \"dimmed\" state is announced twice;\n * - (table navigation) Firefox/Chrome+NVDA - cannot use table navigation if any cell has a focus;\n * - (keyboard navigation) Firefox+NVDA - every day is announced as \"not selected\";\n * - (keyboard navigation) Safari/Chrome+VO - weekdays are not announced;\n * - (keyboard navigation) Safari/Chrome+VO - days are not announced as interactive (clickable or selectable);\n * - (keyboard navigation) Safari/Chrome+VO - day announcements are not interruptive and can be missed if navigating fast.\n */\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<HTMLTableCellElement>;\n\n onSelectDate: (date: Date) => void;\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 ariaLabelledby: 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 ariaLabelledby,\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 const weekdays = weeks[0].map(date => date.getDay());\n\n const focusVisible = useFocusVisible();\n\n return (\n <table role=\"grid\" aria-labelledby={ariaLabelledby} className={clsx(styles.grid, className)}>\n <thead>\n <tr>\n {weekdays.map(dayIndex => (\n <th key={dayIndex} scope=\"col\" className={clsx(styles['grid-cell'], styles['day-header'])}>\n <span aria-hidden=\"true\">{renderDayName(locale, dayIndex, 'short')}</span>\n <ScreenreaderOnly>{renderDayName(locale, dayIndex, 'long')}</ScreenreaderOnly>\n </th>\n ))}\n </tr>\n </thead>\n <tbody onKeyDown={onGridKeyDownHandler}>\n {weeks.map((week, weekIndex) => {\n return (\n <tr key={weekIndex} className={styles.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 const isEnabled = !isDateEnabled || isDateEnabled(date);\n const isFocusable = isFocused && isEnabled;\n\n const baseClasses = {\n [styles.day]: true,\n [styles['grid-cell']]: true,\n [styles['in-first-row']]: weekIndex === 0,\n [styles['in-first-column']]: dateIndex === 0,\n };\n\n if (!isSameMonth(date, baseDate)) {\n return (\n <td\n key={`${weekIndex}:${dateIndex}`}\n ref={isFocused ? focusedDateRef : undefined}\n className={clsx(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 ></td>\n );\n }\n\n const handlers: React.HTMLAttributes<HTMLDivElement> = {};\n if (isEnabled) {\n handlers.onClick = () => onSelectDate(date);\n handlers.onFocus = () => onFocusedDateChange(date);\n }\n\n // Can't be focused.\n let tabIndex = undefined;\n if (isFocusable && isEnabled) {\n // Next focus target.\n tabIndex = 0;\n } else if (isEnabled) {\n // Can be focused programmatically.\n tabIndex = -1;\n }\n\n // Screen-reader announcement for the focused day.\n let dayAnnouncement = getDateLabel(locale, date, 'short');\n if (isToday(date)) {\n dayAnnouncement += '. ' + todayAriaLabel;\n }\n\n return (\n <td\n ref={isFocused ? focusedDateRef : undefined}\n key={`${weekIndex}:${dateIndex}`}\n className={clsx(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']]: dateIsInRange,\n [styles['in-range-border-top']]: !!inRangeStartWeek || date.getDate() <= 7,\n [styles['in-range-border-bottom']]: !!inRangeEndWeek || date.getDate() > getDaysInMonth(date) - 7,\n [styles['in-range-border-left']]: dateIndex === 0 || date.getDate() === 1 || isRangeStartDate,\n [styles['in-range-border-right']]:\n dateIndex === week.length - 1 || isLastDayOfMonth(date) || isRangeEndDate,\n [styles.today]: isToday(date),\n })}\n aria-selected={isEnabled ? isSelected || dateIsInRange : undefined}\n aria-current={isToday(date) ? 'date' : undefined}\n data-date={formatDate(date)}\n aria-disabled={!isEnabled}\n tabIndex={tabIndex}\n {...handlers}\n {...focusVisible}\n >\n <span className={styles['day-inner']} aria-hidden=\"true\">\n {date.getDate()}\n </span>\n <ScreenreaderOnly>{dayAnnouncement}</ScreenreaderOnly>\n </td>\n );\n })}\n </tr>\n );\n })}\n </tbody>\n </table>\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,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { DayIndex } from '
|
|
3
|
-
import { DateRangePickerProps } from '../../interfaces';
|
|
2
|
+
import { DateRangePickerProps, DayIndex } from '../../interfaces';
|
|
4
3
|
export interface GridProps {
|
|
5
4
|
baseDate: Date;
|
|
6
5
|
selectedStartDate: Date | null;
|
|
@@ -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,
|
|
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,oBAAoB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAoBlE,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,IAAI,CAAC;IACf,iBAAiB,EAAE,IAAI,GAAG,IAAI,CAAC;IAC/B,eAAe,EAAE,IAAI,GAAG,IAAI,CAAC;IAE7B,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,mBAAmB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC;IAEvE,aAAa,EAAE,oBAAoB,CAA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ache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport { KeyCode } from '../../../internal/keycode';\nimport { isSameMonth, isAfter, isBefore, addMonths, min, max } from 'date-fns';\n\nimport { DayIndex } from '../index';\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 { hasValue } from '../../../internal/utils/has-value';\nimport { useDateCache } from '../../../internal/hooks/use-date-cache';\nimport { moveNextDay, movePrevDay, moveNextWeek, movePrevWeek, getBaseDate } from '../../../calendar/utils/navigation';\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: (date: Date) => void;\n onChangeMonth: (date: Date) => void;\n\n locale: string;\n startOfWeek: DayIndex;\n todayAriaLabel: string;\n headingIdPrefix: 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\n locale,\n startOfWeek,\n todayAriaLabel,\n headingIdPrefix,\n}: GridProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const [gridHasFocus, setGridHasFocus] = useState(false);\n\n const focusedDateRef = useRef<HTMLTableCellElement>(null);\n\n const dateCache = useDateCache();\n baseDate = dateCache(baseDate);\n focusedDate = focusedDate ? dateCache(focusedDate) : null;\n\n useEffect(() => {\n if (focusedDate && !isVisible(focusedDate, baseDate, isSingleGrid)) {\n const direction = isAfter(focusedDate, baseDate) ? -1 : 1;\n\n const newMonth = !isSingleGrid && direction === -1 ? addMonths(baseDate, -1) : baseDate;\n const nearestBaseDate = getBaseDate(newMonth, isDateEnabled);\n\n const newFocusedDate = selectFocusedDate(focusedDate, nearestBaseDate, isDateEnabled);\n\n onFocusedDateChange(newFocusedDate);\n }\n }, [baseDate, focusedDate, 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.space:\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 = moveNextDay(focusedDate, isDateEnabled);\n break;\n case KeyCode.left:\n e.preventDefault();\n updatedFocusDate = movePrevDay(focusedDate, isDateEnabled);\n break;\n case KeyCode.up:\n e.preventDefault();\n updatedFocusDate = movePrevWeek(focusedDate, isDateEnabled);\n break;\n case KeyCode.down:\n e.preventDefault();\n updatedFocusDate = moveNextWeek(focusedDate, isDateEnabled);\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 }, [focusedDate, 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 ariaLabelledby={`${headingIdPrefix}-prevmonth`}\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 ariaLabelledby={`${headingIdPrefix}-currentmonth`}\n />\n </InternalSpaceBetween>\n </div>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/date-range-picker/calendar/grids/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAG/E,OAAO,oBAAoB,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,MAAM,MAAM,qBAAqB,CAAC;AAEzC,OAAO,eAAe,MAAM,6CAA6C,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEvH,SAAS,SAAS,CAAC,IAAU,EAAE,Q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AAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EACjC,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,EAC9B,cAAc,EAAE,UAAG,eAAe,eAAY,GAC9C,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,EAC9B,cAAc,EAAE,UAAG,eAAe,kBAAe,GACjD,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 { isSameMonth, isAfter, isBefore, addMonths, min, max } from 'date-fns';\n\nimport { DateRangePickerProps, DayIndex } 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 { hasValue } from '../../../internal/utils/has-value';\nimport { useDateCache } from '../../../internal/hooks/use-date-cache';\nimport { moveNextDay, movePrevDay, moveNextWeek, movePrevWeek, getBaseDate } from '../../../calendar/utils/navigation';\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: (date: Date) => void;\n onChangeMonth: (date: Date) => void;\n\n locale: string;\n startOfWeek: DayIndex;\n todayAriaLabel: string;\n headingIdPrefix: 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\n locale,\n startOfWeek,\n todayAriaLabel,\n headingIdPrefix,\n}: GridProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const [gridHasFocus, setGridHasFocus] = useState(false);\n\n const focusedDateRef = useRef<HTMLTableCellElement>(null);\n\n const dateCache = useDateCache();\n baseDate = dateCache(baseDate);\n focusedDate = focusedDate ? dateCache(focusedDate) : null;\n\n useEffect(() => {\n if (focusedDate && !isVisible(focusedDate, baseDate, isSingleGrid)) {\n const direction = isAfter(focusedDate, baseDate) ? -1 : 1;\n\n const newMonth = !isSingleGrid && direction === -1 ? addMonths(baseDate, -1) : baseDate;\n const nearestBaseDate = getBaseDate(newMonth, isDateEnabled);\n\n const newFocusedDate = selectFocusedDate(focusedDate, nearestBaseDate, isDateEnabled);\n\n onFocusedDateChange(newFocusedDate);\n }\n }, [baseDate, focusedDate, 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.space:\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 = moveNextDay(focusedDate, isDateEnabled);\n break;\n case KeyCode.left:\n e.preventDefault();\n updatedFocusDate = movePrevDay(focusedDate, isDateEnabled);\n break;\n case KeyCode.up:\n e.preventDefault();\n updatedFocusDate = movePrevWeek(focusedDate, isDateEnabled);\n break;\n case KeyCode.down:\n e.preventDefault();\n updatedFocusDate = moveNextWeek(focusedDate, isDateEnabled);\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 }, [focusedDate, 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 ariaLabelledby={`${headingIdPrefix}-prevmonth`}\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 ariaLabelledby={`${headingIdPrefix}-currentmonth`}\n />\n </InternalSpaceBetween>\n </div>\n );\n};\n"]}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BaseComponentProps } from '../../internal/base-component';
|
|
3
|
-
import {
|
|
3
|
+
import { Focusable, RangeCalendarI18nStrings, RangeCalendarValue } from '../interfaces';
|
|
4
4
|
import { TimeInputProps } from '../../time-input/interfaces';
|
|
5
|
-
export
|
|
6
|
-
export interface RangeCalendarValue {
|
|
7
|
-
startDate: string;
|
|
8
|
-
endDate: string;
|
|
9
|
-
}
|
|
10
|
-
export interface CalendarProps extends BaseComponentProps {
|
|
5
|
+
export interface DateRangePickerCalendarProps extends BaseComponentProps {
|
|
11
6
|
value: null | RangeCalendarValue;
|
|
12
7
|
onChange: (value: RangeCalendarValue) => void;
|
|
13
|
-
locale
|
|
14
|
-
startOfWeek
|
|
15
|
-
isDateEnabled
|
|
16
|
-
i18nStrings:
|
|
8
|
+
locale?: string;
|
|
9
|
+
startOfWeek?: number;
|
|
10
|
+
isDateEnabled?: (date: Date) => boolean;
|
|
11
|
+
i18nStrings: RangeCalendarI18nStrings;
|
|
17
12
|
dateOnly?: boolean;
|
|
18
13
|
timeInputFormat?: TimeInputProps.Format;
|
|
19
14
|
}
|
|
20
|
-
declare const _default: React.ForwardRefExoticComponent<
|
|
15
|
+
declare const _default: React.ForwardRefExoticComponent<DateRangePickerCalendarProps & React.RefAttributes<Focusable>>;
|
|
21
16
|
export default _default;
|
|
22
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/date-range-picker/calendar/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuE,MAAM,OAAO,CAAC;AAG5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/date-range-picker/calendar/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuE,MAAM,OAAO,CAAC;AAG5F,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGxF,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAW7D,MAAM,WAAW,4BAA6B,SAAQ,kBAAkB;IACtE,KAAK,EAAE,IAAI,GAAG,kBAAkB,CAAC;IACjC,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;IACxC,WAAW,EAAE,wBAAwB,CAAC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC;CACzC;;AAED,wBAAmD"}
|
|
@@ -5,25 +5,24 @@ import { addMonths, endOfDay, isBefore, startOfDay, startOfMonth, isAfter, isSam
|
|
|
5
5
|
import styles from '../styles.css.js';
|
|
6
6
|
import CalendarHeader from './header';
|
|
7
7
|
import { Grids, selectFocusedDate } from './grids';
|
|
8
|
-
import InternalFormField from '../../form-field/internal';
|
|
9
|
-
import InternalDateInput from '../../date-input/internal';
|
|
10
|
-
import InternalTimeInput from '../../time-input/internal';
|
|
11
8
|
import clsx from 'clsx';
|
|
12
9
|
import { useUniqueId } from '../../internal/hooks/use-unique-id';
|
|
13
10
|
import { getDateLabel, renderTimeLabel } from '../../calendar/utils/intl';
|
|
14
11
|
import LiveRegion from '../../internal/components/live-region';
|
|
15
|
-
import { normalizeStartOfWeek } from '../../calendar/utils/locales';
|
|
12
|
+
import { normalizeLocale, normalizeStartOfWeek } from '../../calendar/utils/locales';
|
|
16
13
|
import { formatDate, formatTime, joinDateTime, parseDate } from '../../internal/utils/date-time';
|
|
17
14
|
import { getBaseDate } from '../../calendar/utils/navigation';
|
|
18
15
|
import { useMobile } from '../../internal/hooks/use-mobile/index.js';
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
import RangeInputs from './range-inputs.js';
|
|
17
|
+
export default forwardRef(DateRangePickerCalendar);
|
|
18
|
+
function DateRangePickerCalendar(_a, ref) {
|
|
21
19
|
var _b, _c;
|
|
22
20
|
var _d, _e;
|
|
23
|
-
var value = _a.value, onChange = _a.onChange,
|
|
21
|
+
var value = _a.value, onChange = _a.onChange, _f = _a.locale, locale = _f === void 0 ? '' : _f, startOfWeek = _a.startOfWeek, _g = _a.isDateEnabled, isDateEnabled = _g === void 0 ? function () { return true; } : _g, i18nStrings = _a.i18nStrings, _h = _a.dateOnly, dateOnly = _h === void 0 ? false : _h, _j = _a.timeInputFormat, timeInputFormat = _j === void 0 ? 'hh:mm:ss' : _j;
|
|
24
22
|
var elementRef = useRef(null);
|
|
25
23
|
var isSingleGrid = useMobile();
|
|
26
|
-
var
|
|
24
|
+
var normalizedLocale = normalizeLocale('DateRangePicker', locale);
|
|
25
|
+
var normalizedStartOfWeek = normalizeStartOfWeek(startOfWeek, normalizedLocale);
|
|
27
26
|
useImperativeHandle(ref, function () { return ({
|
|
28
27
|
focus: function () {
|
|
29
28
|
if (elementRef.current) {
|
|
@@ -34,16 +33,16 @@ function RangeCalendar(_a, ref) {
|
|
|
34
33
|
}); });
|
|
35
34
|
var initialStartDate = (_d = value === null || value === void 0 ? void 0 : value.startDate) !== null && _d !== void 0 ? _d : '';
|
|
36
35
|
var initialEndDate = (_e = value === null || value === void 0 ? void 0 : value.endDate) !== null && _e !== void 0 ? _e : '';
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
36
|
+
var _k = initialStartDate.split('T'), _l = _k[0], initialStartDateString = _l === void 0 ? '' : _l, _m = _k[1], initialStartTimeString = _m === void 0 ? '' : _m;
|
|
37
|
+
var _o = initialEndDate.split('T'), _p = _o[0], initialEndDateString = _p === void 0 ? '' : _p, _q = _o[1], initialEndTimeString = _q === void 0 ? '' : _q;
|
|
38
|
+
var _r = useState(initialStartDateString), startDateString = _r[0], setStartDateString = _r[1];
|
|
39
|
+
var _s = useState(initialStartTimeString), startTimeString = _s[0], setStartTimeString = _s[1];
|
|
40
|
+
var _t = useState(initialEndDateString), endDateString = _t[0], setEndDateString = _t[1];
|
|
41
|
+
var _u = useState(initialEndTimeString), endTimeString = _u[0], setEndTimeString = _u[1];
|
|
43
42
|
var selectedStartDate = parseDate(startDateString, true);
|
|
44
43
|
var selectedEndDate = parseDate(endDateString, true);
|
|
45
|
-
var
|
|
46
|
-
var
|
|
44
|
+
var _v = useState(''), announcement = _v[0], setAnnouncement = _v[1];
|
|
45
|
+
var _w = useState(function () {
|
|
47
46
|
if (startDateString) {
|
|
48
47
|
var startDate = parseDate(startDateString);
|
|
49
48
|
if (isSingleGrid) {
|
|
@@ -55,8 +54,8 @@ function RangeCalendar(_a, ref) {
|
|
|
55
54
|
return startOfMonth(parseDate(endDateString));
|
|
56
55
|
}
|
|
57
56
|
return startOfMonth(Date.now());
|
|
58
|
-
}), currentMonth =
|
|
59
|
-
var
|
|
57
|
+
}), currentMonth = _w[0], setCurrentMonth = _w[1];
|
|
58
|
+
var _x = useState(function () {
|
|
60
59
|
if (selectedStartDate) {
|
|
61
60
|
if (isSameMonth(selectedStartDate, currentMonth)) {
|
|
62
61
|
return selectedStartDate;
|
|
@@ -66,9 +65,9 @@ function RangeCalendar(_a, ref) {
|
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
return selectFocusedDate(selectedStartDate, currentMonth, isDateEnabled);
|
|
69
|
-
}), focusedDate =
|
|
68
|
+
}), focusedDate = _x[0], setFocusedDate = _x[1];
|
|
69
|
+
// This effect "synchronizes" the local state update back up to the parent component.
|
|
70
70
|
useEffect(function () {
|
|
71
|
-
// This effect "synchronizes" the local state update back up to the overall DateRangePicker component
|
|
72
71
|
var startDate = joinDateTime(startDateString, startTimeString);
|
|
73
72
|
var endDate = joinDateTime(endDateString, endTimeString);
|
|
74
73
|
if (startDate !== initialStartDate || endDate !== initialEndDate) {
|
|
@@ -81,28 +80,28 @@ function RangeCalendar(_a, ref) {
|
|
|
81
80
|
var announceStart = function (startDate) {
|
|
82
81
|
return (i18nStrings.startDateLabel +
|
|
83
82
|
', ' +
|
|
84
|
-
getDateLabel(
|
|
83
|
+
getDateLabel(normalizedLocale, startDate) +
|
|
85
84
|
', ' +
|
|
86
85
|
i18nStrings.startTimeLabel +
|
|
87
86
|
', ' +
|
|
88
|
-
renderTimeLabel(
|
|
87
|
+
renderTimeLabel(normalizedLocale, startDate, timeInputFormat) +
|
|
89
88
|
'. ');
|
|
90
89
|
};
|
|
91
90
|
var announceEnd = function (endDate) {
|
|
92
91
|
return (i18nStrings.endDateLabel +
|
|
93
92
|
', ' +
|
|
94
|
-
getDateLabel(
|
|
93
|
+
getDateLabel(normalizedLocale, endDate) +
|
|
95
94
|
', ' +
|
|
96
95
|
i18nStrings.endTimeLabel +
|
|
97
96
|
', ' +
|
|
98
|
-
renderTimeLabel(
|
|
97
|
+
renderTimeLabel(normalizedLocale, endDate, timeInputFormat) +
|
|
99
98
|
'. ');
|
|
100
99
|
};
|
|
101
100
|
var announceRange = function (startDate, endDate) {
|
|
102
101
|
if (!i18nStrings.renderSelectedAbsoluteRangeAriaLive) {
|
|
103
|
-
return "".concat(getDateLabel(
|
|
102
|
+
return "".concat(getDateLabel(normalizedLocale, startDate), " \u2013 ").concat(getDateLabel(normalizedLocale, endDate));
|
|
104
103
|
}
|
|
105
|
-
return i18nStrings.renderSelectedAbsoluteRangeAriaLive(getDateLabel(
|
|
104
|
+
return i18nStrings.renderSelectedAbsoluteRangeAriaLive(getDateLabel(normalizedLocale, startDate), getDateLabel(normalizedLocale, endDate));
|
|
106
105
|
};
|
|
107
106
|
// If both fields are empty, we set the start date
|
|
108
107
|
if (!startDateString && !endDateString) {
|
|
@@ -173,15 +172,15 @@ function RangeCalendar(_a, ref) {
|
|
|
173
172
|
var newBaseDate = getBaseDate(newBaseDateMonth, isDateEnabled);
|
|
174
173
|
setFocusedDate(newBaseDate);
|
|
175
174
|
};
|
|
176
|
-
var onChangeStartDate = function (
|
|
177
|
-
setStartDateString(
|
|
178
|
-
if (
|
|
179
|
-
var newCurrentMonth = startOfMonth(parseDate(
|
|
175
|
+
var onChangeStartDate = function (value) {
|
|
176
|
+
setStartDateString(value);
|
|
177
|
+
if (value.length >= 8) {
|
|
178
|
+
var newCurrentMonth = startOfMonth(parseDate(value));
|
|
180
179
|
setCurrentMonth(isSingleGrid ? newCurrentMonth : addMonths(newCurrentMonth, 1));
|
|
181
180
|
}
|
|
182
181
|
};
|
|
183
|
-
var onChangeEndDate = function (
|
|
184
|
-
setEndDateString(
|
|
182
|
+
var onChangeEndDate = function (value) {
|
|
183
|
+
setEndDateString(value);
|
|
185
184
|
};
|
|
186
185
|
var headingIdPrefix = useUniqueId('date-range-picker-calendar-heading');
|
|
187
186
|
return (React.createElement(React.Fragment, null,
|
|
@@ -191,20 +190,9 @@ function RangeCalendar(_a, ref) {
|
|
|
191
190
|
React.createElement("div", { ref: elementRef, className: clsx(styles.calendar, (_c = {},
|
|
192
191
|
_c[styles['one-grid']] = isSingleGrid,
|
|
193
192
|
_c)) },
|
|
194
|
-
React.createElement(CalendarHeader, { baseDate: currentMonth, locale:
|
|
195
|
-
React.createElement(Grids, { isSingleGrid: isSingleGrid, locale:
|
|
196
|
-
React.createElement(
|
|
197
|
-
React.createElement("div", { className: styles['date-and-time-container'] },
|
|
198
|
-
React.createElement("div", { className: styles['date-and-time-wrapper'] },
|
|
199
|
-
React.createElement(InternalFormField, { label: i18nStrings.startDateLabel, stretch: true },
|
|
200
|
-
React.createElement(InternalDateInput, { value: startDateString, className: styles['start-date-input'], onChange: onChangeStartDate, placeholder: "YYYY/MM/DD" })),
|
|
201
|
-
!dateOnly && (React.createElement(InternalFormField, { label: i18nStrings.startTimeLabel, stretch: true },
|
|
202
|
-
React.createElement(InternalTimeInput, { value: startTimeString, onChange: function (e) { return setStartTimeString(e.detail.value); }, format: timeInputFormat, placeholder: timeInputFormat, className: styles['start-time-input'] })))),
|
|
203
|
-
React.createElement("div", { className: styles['date-and-time-wrapper'] },
|
|
204
|
-
React.createElement(InternalFormField, { label: i18nStrings.endDateLabel, stretch: true },
|
|
205
|
-
React.createElement(InternalDateInput, { value: endDateString, className: styles['end-date-input'], onChange: onChangeEndDate, placeholder: "YYYY/MM/DD" })),
|
|
206
|
-
!dateOnly && (React.createElement(InternalFormField, { label: i18nStrings.endTimeLabel, stretch: true },
|
|
207
|
-
React.createElement(InternalTimeInput, { value: endTimeString, onChange: function (e) { return setEndTimeString(e.detail.value); }, format: timeInputFormat, placeholder: timeInputFormat, className: styles['end-time-input'] }))))))),
|
|
193
|
+
React.createElement(CalendarHeader, { baseDate: currentMonth, locale: normalizedLocale, onChangeMonth: onHeaderChangeMonthHandler, previousMonthLabel: i18nStrings.previousMonthAriaLabel, nextMonthLabel: i18nStrings.nextMonthAriaLabel, isSingleGrid: isSingleGrid, headingIdPrefix: headingIdPrefix }),
|
|
194
|
+
React.createElement(Grids, { isSingleGrid: isSingleGrid, locale: normalizedLocale, baseDate: currentMonth, focusedDate: focusedDate, onFocusedDateChange: setFocusedDate, isDateEnabled: isDateEnabled, onSelectDate: onSelectDateHandler, onChangeMonth: setCurrentMonth, startOfWeek: normalizedStartOfWeek, todayAriaLabel: i18nStrings.todayAriaLabel, selectedStartDate: selectedStartDate, selectedEndDate: selectedEndDate, headingIdPrefix: headingIdPrefix })),
|
|
195
|
+
React.createElement(RangeInputs, { startDate: startDateString, onChangeStartDate: onChangeStartDate, startTime: startTimeString, onChangeStartTime: setStartTimeString, endDate: endDateString, onChangeEndDate: onChangeEndDate, endTime: endTimeString, onChangeEndTime: setEndTimeString, i18nStrings: i18nStrings, dateOnly: dateOnly, timeInputFormat: timeInputFormat })),
|
|
208
196
|
React.createElement(LiveRegion, { className: styles['calendar-aria-live'] }, announcement)));
|
|
209
197
|
}
|
|
210
198
|
//# sourceMappingURL=index.js.map
|