@cloudscape-design/components-themeable 3.0.72 → 3.0.74

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.
Files changed (154) hide show
  1. package/lib/internal/scss/breadcrumb-group/item/styles.scss +1 -0
  2. package/lib/internal/scss/calendar/styles.scss +19 -28
  3. package/lib/internal/scss/date-range-picker/calendar/grids/{day/styles.scss → styles.scss} +23 -7
  4. package/lib/internal/scss/date-range-picker/styles.scss +5 -27
  5. package/lib/internal/scss/property-filter/styles.scss +16 -6
  6. package/lib/internal/scss/tabs/tab-header-bar.scss +1 -0
  7. package/lib/internal/template/app-layout/toggles/index.d.ts.map +1 -1
  8. package/lib/internal/template/app-layout/toggles/index.js +2 -2
  9. package/lib/internal/template/app-layout/toggles/index.js.map +1 -1
  10. package/lib/internal/template/app-layout/visual-refresh/app-bar.d.ts.map +1 -1
  11. package/lib/internal/template/app-layout/visual-refresh/app-bar.js +2 -2
  12. package/lib/internal/template/app-layout/visual-refresh/app-bar.js.map +1 -1
  13. package/lib/internal/template/app-layout/visual-refresh/navigation.d.ts.map +1 -1
  14. package/lib/internal/template/app-layout/visual-refresh/navigation.js +1 -1
  15. package/lib/internal/template/app-layout/visual-refresh/navigation.js.map +1 -1
  16. package/lib/internal/template/app-layout/visual-refresh/tools.d.ts.map +1 -1
  17. package/lib/internal/template/app-layout/visual-refresh/tools.js +1 -1
  18. package/lib/internal/template/app-layout/visual-refresh/tools.js.map +1 -1
  19. package/lib/internal/template/app-layout/visual-refresh/trigger-button.d.ts.map +1 -1
  20. package/lib/internal/template/app-layout/visual-refresh/trigger-button.js +1 -1
  21. package/lib/internal/template/app-layout/visual-refresh/trigger-button.js.map +1 -1
  22. package/lib/internal/template/breadcrumb-group/item/styles.css.js +7 -7
  23. package/lib/internal/template/breadcrumb-group/item/styles.scoped.css +16 -15
  24. package/lib/internal/template/breadcrumb-group/item/styles.selectors.js +7 -7
  25. package/lib/internal/template/calendar/grid/index.d.ts +2 -2
  26. package/lib/internal/template/calendar/grid/index.d.ts.map +1 -1
  27. package/lib/internal/template/calendar/grid/index.js +64 -23
  28. package/lib/internal/template/calendar/grid/index.js.map +1 -1
  29. package/lib/internal/template/calendar/internal.d.ts.map +1 -1
  30. package/lib/internal/template/calendar/internal.js +3 -15
  31. package/lib/internal/template/calendar/internal.js.map +1 -1
  32. package/lib/internal/template/calendar/styles.css.js +18 -20
  33. package/lib/internal/template/calendar/styles.scoped.css +46 -58
  34. package/lib/internal/template/calendar/styles.selectors.js +18 -20
  35. package/lib/internal/template/date-range-picker/calendar/grids/grid.d.ts +1 -1
  36. package/lib/internal/template/date-range-picker/calendar/grids/grid.d.ts.map +1 -1
  37. package/lib/internal/template/date-range-picker/calendar/grids/grid.js +65 -9
  38. package/lib/internal/template/date-range-picker/calendar/grids/grid.js.map +1 -1
  39. package/lib/internal/template/date-range-picker/calendar/grids/index.d.ts.map +1 -1
  40. package/lib/internal/template/date-range-picker/calendar/grids/index.js +1 -0
  41. package/lib/internal/template/date-range-picker/calendar/grids/index.js.map +1 -1
  42. package/lib/internal/template/date-range-picker/calendar/grids/styles.css.js +30 -0
  43. package/lib/internal/template/date-range-picker/calendar/grids/{day/styles.scoped.css → styles.scoped.css} +60 -40
  44. package/lib/internal/template/date-range-picker/calendar/grids/styles.selectors.js +31 -0
  45. package/lib/internal/template/date-range-picker/index.js +2 -2
  46. package/lib/internal/template/date-range-picker/index.js.map +1 -1
  47. package/lib/internal/template/date-range-picker/styles.css.js +37 -40
  48. package/lib/internal/template/date-range-picker/styles.scoped.css +48 -67
  49. package/lib/internal/template/date-range-picker/styles.selectors.js +37 -40
  50. package/lib/internal/template/expandable-section/expandable-section-header.d.ts +3 -2
  51. package/lib/internal/template/expandable-section/expandable-section-header.d.ts.map +1 -1
  52. package/lib/internal/template/expandable-section/expandable-section-header.js +3 -3
  53. package/lib/internal/template/expandable-section/expandable-section-header.js.map +1 -1
  54. package/lib/internal/template/expandable-section/interfaces.d.ts +5 -0
  55. package/lib/internal/template/expandable-section/interfaces.d.ts.map +1 -1
  56. package/lib/internal/template/expandable-section/interfaces.js.map +1 -1
  57. package/lib/internal/template/expandable-section/internal.d.ts +1 -1
  58. package/lib/internal/template/expandable-section/internal.d.ts.map +1 -1
  59. package/lib/internal/template/expandable-section/internal.js +4 -3
  60. package/lib/internal/template/expandable-section/internal.js.map +1 -1
  61. package/lib/internal/template/internal/base-component/styles.scoped.css +13 -13
  62. package/lib/internal/template/internal/components/dropdown-status/index.d.ts +3 -1
  63. package/lib/internal/template/internal/components/dropdown-status/index.d.ts.map +1 -1
  64. package/lib/internal/template/internal/components/dropdown-status/index.js +7 -4
  65. package/lib/internal/template/internal/components/dropdown-status/index.js.map +1 -1
  66. package/lib/internal/template/internal/components/live-region/index.d.ts.map +1 -1
  67. package/lib/internal/template/internal/components/live-region/index.js +1 -0
  68. package/lib/internal/template/internal/components/live-region/index.js.map +1 -1
  69. package/lib/internal/template/internal/environment.js +1 -1
  70. package/lib/internal/template/internal/generated/styles/tokens.js +2 -2
  71. package/lib/internal/template/internal/generated/theming/index.cjs +3 -3
  72. package/lib/internal/template/internal/generated/theming/index.js +3 -3
  73. package/lib/internal/template/modal/internal.d.ts.map +1 -1
  74. package/lib/internal/template/modal/internal.js +6 -10
  75. package/lib/internal/template/modal/internal.js.map +1 -1
  76. package/lib/internal/template/multiselect/internal.d.ts.map +1 -1
  77. package/lib/internal/template/multiselect/internal.js +3 -2
  78. package/lib/internal/template/multiselect/internal.js.map +1 -1
  79. package/lib/internal/template/package-lock.json +3 -3
  80. package/lib/internal/template/property-filter/controller.d.ts +2 -0
  81. package/lib/internal/template/property-filter/controller.d.ts.map +1 -1
  82. package/lib/internal/template/property-filter/controller.js +37 -0
  83. package/lib/internal/template/property-filter/controller.js.map +1 -1
  84. package/lib/internal/template/property-filter/index.d.ts.map +1 -1
  85. package/lib/internal/template/property-filter/index.js +21 -6
  86. package/lib/internal/template/property-filter/index.js.map +1 -1
  87. package/lib/internal/template/property-filter/interfaces.d.ts +9 -2
  88. package/lib/internal/template/property-filter/interfaces.d.ts.map +1 -1
  89. package/lib/internal/template/property-filter/interfaces.js +2 -0
  90. package/lib/internal/template/property-filter/interfaces.js.map +1 -1
  91. package/lib/internal/template/property-filter/property-editor.d.ts +13 -0
  92. package/lib/internal/template/property-filter/property-editor.d.ts.map +1 -0
  93. package/lib/internal/template/property-filter/property-editor.js +18 -0
  94. package/lib/internal/template/property-filter/property-editor.js.map +1 -0
  95. package/lib/internal/template/property-filter/property-filter-autosuggest.d.ts +1 -0
  96. package/lib/internal/template/property-filter/property-filter-autosuggest.d.ts.map +1 -1
  97. package/lib/internal/template/property-filter/property-filter-autosuggest.js +17 -3
  98. package/lib/internal/template/property-filter/property-filter-autosuggest.js.map +1 -1
  99. package/lib/internal/template/property-filter/styles.css.js +32 -24
  100. package/lib/internal/template/property-filter/styles.scoped.css +45 -27
  101. package/lib/internal/template/property-filter/styles.selectors.js +32 -24
  102. package/lib/internal/template/property-filter/token-editor.d.ts.map +1 -1
  103. package/lib/internal/template/property-filter/token-editor.js +17 -4
  104. package/lib/internal/template/property-filter/token-editor.js.map +1 -1
  105. package/lib/internal/template/property-filter/token.d.ts.map +1 -1
  106. package/lib/internal/template/property-filter/token.js +6 -3
  107. package/lib/internal/template/property-filter/token.js.map +1 -1
  108. package/lib/internal/template/select/internal.d.ts.map +1 -1
  109. package/lib/internal/template/select/internal.js +3 -2
  110. package/lib/internal/template/select/internal.js.map +1 -1
  111. package/lib/internal/template/select/parts/filter.d.ts +1 -1
  112. package/lib/internal/template/select/utils/use-select.d.ts +15 -1
  113. package/lib/internal/template/select/utils/use-select.d.ts.map +1 -1
  114. package/lib/internal/template/select/utils/use-select.js +11 -1
  115. package/lib/internal/template/select/utils/use-select.js.map +1 -1
  116. package/lib/internal/template/split-panel/index.d.ts.map +1 -1
  117. package/lib/internal/template/split-panel/index.js +8 -6
  118. package/lib/internal/template/split-panel/index.js.map +1 -1
  119. package/lib/internal/template/split-panel/interfaces.d.ts +1 -0
  120. package/lib/internal/template/split-panel/interfaces.d.ts.map +1 -1
  121. package/lib/internal/template/split-panel/interfaces.js.map +1 -1
  122. package/lib/internal/template/split-panel/utils/use-pointer-events.d.ts +1 -1
  123. package/lib/internal/template/split-panel/utils/use-pointer-events.d.ts.map +1 -1
  124. package/lib/internal/template/split-panel/utils/use-pointer-events.js +9 -5
  125. package/lib/internal/template/split-panel/utils/use-pointer-events.js.map +1 -1
  126. package/lib/internal/template/table/header-cell/styles.css.js +14 -14
  127. package/lib/internal/template/table/header-cell/styles.scoped.css +25 -25
  128. package/lib/internal/template/table/header-cell/styles.selectors.js +14 -14
  129. package/lib/internal/template/table/internal.d.ts.map +1 -1
  130. package/lib/internal/template/table/internal.js +8 -1
  131. package/lib/internal/template/table/internal.js.map +1 -1
  132. package/lib/internal/template/table/use-mouse-down-target.d.ts +6 -0
  133. package/lib/internal/template/table/use-mouse-down-target.d.ts.map +1 -0
  134. package/lib/internal/template/table/use-mouse-down-target.js +30 -0
  135. package/lib/internal/template/table/use-mouse-down-target.js.map +1 -0
  136. package/lib/internal/template/tabs/styles.css.js +21 -21
  137. package/lib/internal/template/tabs/styles.scoped.css +38 -37
  138. package/lib/internal/template/tabs/styles.selectors.js +21 -21
  139. package/lib/internal/template/test-utils/dom/date-range-picker/index.js +2 -2
  140. package/lib/internal/template/test-utils/dom/date-range-picker/index.js.map +1 -1
  141. package/lib/internal/template/test-utils/selectors/date-range-picker/index.js +2 -2
  142. package/lib/internal/template/test-utils/selectors/date-range-picker/index.js.map +1 -1
  143. package/lib/internal/template/test-utils/tsconfig.tsbuildinfo +1 -1
  144. package/package.json +1 -1
  145. package/lib/internal/template/calendar/grid/day/index.d.ts +0 -15
  146. package/lib/internal/template/calendar/grid/day/index.d.ts.map +0 -1
  147. package/lib/internal/template/calendar/grid/day/index.js +0 -47
  148. package/lib/internal/template/calendar/grid/day/index.js.map +0 -1
  149. package/lib/internal/template/date-range-picker/calendar/grids/day/index.d.ts +0 -27
  150. package/lib/internal/template/date-range-picker/calendar/grids/day/index.d.ts.map +0 -1
  151. package/lib/internal/template/date-range-picker/calendar/grids/day/index.js +0 -95
  152. package/lib/internal/template/date-range-picker/calendar/grids/day/index.js.map +0 -1
  153. package/lib/internal/template/date-range-picker/calendar/grids/day/styles.css.js +0 -26
  154. package/lib/internal/template/date-range-picker/calendar/grids/day/styles.selectors.js +0 -27
@@ -90,18 +90,18 @@ 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
- .awsui_link_1kosq_1lntj_93:not(#\9):after {
93
+ .awsui_link_1kosq_w4ewt_93:not(#\9):after {
94
94
  display: none;
95
95
  }
96
96
 
97
- .awsui_breadcrumb_1kosq_1lntj_97:not(#\9) {
97
+ .awsui_breadcrumb_1kosq_w4ewt_97:not(#\9) {
98
98
  display: flex;
99
99
  }
100
- .awsui_breadcrumb_1kosq_1lntj_97 > .awsui_icon_1kosq_1lntj_100:not(#\9) {
100
+ .awsui_breadcrumb_1kosq_w4ewt_97 > .awsui_icon_1kosq_w4ewt_100:not(#\9) {
101
101
  margin: 0 var(--space-xs-rsr2qu, 8px);
102
102
  color: var(--color-text-breadcrumb-icon-73h18g, #687078);
103
103
  }
104
- .awsui_breadcrumb_1kosq_1lntj_97 > .awsui_anchor_1kosq_1lntj_104:not(#\9) {
104
+ .awsui_breadcrumb_1kosq_w4ewt_97 > .awsui_anchor_1kosq_w4ewt_104:not(#\9) {
105
105
  color: var(--color-text-link-default-753y4e, #0073bb);
106
106
  font-weight: inherit;
107
107
  letter-spacing: normal;
@@ -114,31 +114,31 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
114
114
  transition-duration: var(--motion-duration-refresh-only-medium-5flen2, 165ms);
115
115
  }
116
116
  @media (prefers-reduced-motion: reduce) {
117
- .awsui_breadcrumb_1kosq_1lntj_97 > .awsui_anchor_1kosq_1lntj_104:not(#\9) {
117
+ .awsui_breadcrumb_1kosq_w4ewt_97 > .awsui_anchor_1kosq_w4ewt_104:not(#\9) {
118
118
  animation: none;
119
119
  transition: none;
120
120
  }
121
121
  }
122
- .awsui-motion-disabled .awsui_breadcrumb_1kosq_1lntj_97 > .awsui_anchor_1kosq_1lntj_104:not(#\9), .awsui-mode-entering .awsui_breadcrumb_1kosq_1lntj_97 > .awsui_anchor_1kosq_1lntj_104:not(#\9) {
122
+ .awsui-motion-disabled .awsui_breadcrumb_1kosq_w4ewt_97 > .awsui_anchor_1kosq_w4ewt_104:not(#\9), .awsui-mode-entering .awsui_breadcrumb_1kosq_w4ewt_97 > .awsui_anchor_1kosq_w4ewt_104:not(#\9) {
123
123
  animation: none;
124
124
  transition: none;
125
125
  }
126
- .awsui_breadcrumb_1kosq_1lntj_97 > .awsui_anchor_1kosq_1lntj_104:not(#\9):hover {
126
+ .awsui_breadcrumb_1kosq_w4ewt_97 > .awsui_anchor_1kosq_w4ewt_104:not(#\9):hover {
127
127
  cursor: pointer;
128
128
  color: var(--color-text-link-hover-ok01xk, #0073bb);
129
129
  }
130
- .awsui_breadcrumb_1kosq_1lntj_97 > .awsui_anchor_1kosq_1lntj_104:not(#\9):focus {
130
+ .awsui_breadcrumb_1kosq_w4ewt_97 > .awsui_anchor_1kosq_w4ewt_104:not(#\9):focus {
131
131
  outline: none;
132
132
  }
133
- .awsui_breadcrumb_1kosq_1lntj_97 > .awsui_anchor_1kosq_1lntj_104:not(#\9):active {
133
+ .awsui_breadcrumb_1kosq_w4ewt_97 > .awsui_anchor_1kosq_w4ewt_104:not(#\9):active {
134
134
  color: var(--color-text-link-hover-ok01xk, #0073bb);
135
135
  }
136
- .awsui_breadcrumb_1kosq_1lntj_97 > .awsui_anchor_1kosq_1lntj_104:not(#\9):active, .awsui_breadcrumb_1kosq_1lntj_97 > .awsui_anchor_1kosq_1lntj_104:not(#\9):focus, .awsui_breadcrumb_1kosq_1lntj_97 > .awsui_anchor_1kosq_1lntj_104:not(#\9):hover {
136
+ .awsui_breadcrumb_1kosq_w4ewt_97 > .awsui_anchor_1kosq_w4ewt_104:not(#\9):active, .awsui_breadcrumb_1kosq_w4ewt_97 > .awsui_anchor_1kosq_w4ewt_104:not(#\9):focus, .awsui_breadcrumb_1kosq_w4ewt_97 > .awsui_anchor_1kosq_w4ewt_104:not(#\9):hover {
137
137
  text-decoration: underline;
138
138
  /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
139
139
  text-decoration-color: currentColor;
140
140
  }
141
- .awsui_breadcrumb_1kosq_1lntj_97 > .awsui_anchor_1kosq_1lntj_104[data-awsui-focus-visible=true]:not(#\9):focus {
141
+ .awsui_breadcrumb_1kosq_w4ewt_97 > .awsui_anchor_1kosq_w4ewt_104[data-awsui-focus-visible=true]:not(#\9):focus {
142
142
  outline: thin dotted;
143
143
  outline: var(--border-link-focus-ring-outline-67z0xv, 5px auto Highlight);
144
144
  outline-offset: 2px;
@@ -146,21 +146,22 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
146
146
  border-radius: var(--border-radius-control-default-focus-ring-hekmgc, 2px);
147
147
  box-shadow: 0 0 0 var(--border-link-focus-ring-shadow-spread-e3dct9, 0px) var(--color-border-item-focused-n5kd8g, #0073bb);
148
148
  }
149
- .awsui_breadcrumb_1kosq_1lntj_97.awsui_last_1kosq_1lntj_147 > .awsui_icon_1kosq_1lntj_100:not(#\9) {
149
+ .awsui_breadcrumb_1kosq_w4ewt_97.awsui_last_1kosq_w4ewt_147 > .awsui_icon_1kosq_w4ewt_100:not(#\9) {
150
150
  display: none;
151
151
  }
152
- .awsui_breadcrumb_1kosq_1lntj_97.awsui_last_1kosq_1lntj_147 > .awsui_anchor_1kosq_1lntj_104:not(#\9) {
152
+ .awsui_breadcrumb_1kosq_w4ewt_97.awsui_last_1kosq_w4ewt_147 > .awsui_anchor_1kosq_w4ewt_104:not(#\9) {
153
153
  color: var(--color-text-breadcrumb-current-t6gbyx, #687078);
154
+ font-weight: 700;
154
155
  text-decoration: none;
155
156
  cursor: default;
156
157
  pointer-events: none;
157
158
  }
158
159
 
159
- .awsui_compressed_1kosq_1lntj_157:not(#\9) {
160
+ .awsui_compressed_1kosq_w4ewt_158:not(#\9) {
160
161
  min-width: 0;
161
162
  overflow: hidden;
162
163
  }
163
- .awsui_compressed_1kosq_1lntj_157 > .awsui_text_1kosq_1lntj_161:not(#\9) {
164
+ .awsui_compressed_1kosq_w4ewt_158 > .awsui_text_1kosq_w4ewt_162:not(#\9) {
164
165
  overflow: hidden;
165
166
  text-overflow: ellipsis;
166
167
  white-space: nowrap;
@@ -2,12 +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
- "link": "awsui_link_1kosq_1lntj_93",
6
- "breadcrumb": "awsui_breadcrumb_1kosq_1lntj_97",
7
- "icon": "awsui_icon_1kosq_1lntj_100",
8
- "anchor": "awsui_anchor_1kosq_1lntj_104",
9
- "last": "awsui_last_1kosq_1lntj_147",
10
- "compressed": "awsui_compressed_1kosq_1lntj_157",
11
- "text": "awsui_text_1kosq_1lntj_161"
5
+ "link": "awsui_link_1kosq_w4ewt_93",
6
+ "breadcrumb": "awsui_breadcrumb_1kosq_w4ewt_97",
7
+ "icon": "awsui_icon_1kosq_w4ewt_100",
8
+ "anchor": "awsui_anchor_1kosq_w4ewt_104",
9
+ "last": "awsui_last_1kosq_w4ewt_147",
10
+ "compressed": "awsui_compressed_1kosq_w4ewt_158",
11
+ "text": "awsui_text_1kosq_w4ewt_162"
12
12
  };
13
13
 
@@ -6,6 +6,7 @@ export interface GridProps {
6
6
  baseDate: Date;
7
7
  isDateEnabled: DatePickerProps.IsDateEnabledFunction;
8
8
  focusedDate: Date | null;
9
+ focusableDate: Date | null;
9
10
  onSelectDate: (date: Date) => void;
10
11
  onFocusDate: (date: null | Date) => void;
11
12
  onChangeMonth: (date: Date) => void;
@@ -14,6 +15,5 @@ export interface GridProps {
14
15
  selectedDate: Date | null;
15
16
  handleFocusMove: MoveFocusHandler;
16
17
  }
17
- declare const Grid: ({ locale, baseDate, isDateEnabled, focusedDate, onSelectDate, onFocusDate, onChangeMonth, startOfWeek, todayAriaLabel, selectedDate, handleFocusMove, }: GridProps) => JSX.Element;
18
- export default Grid;
18
+ export default function Grid({ locale, baseDate, isDateEnabled, focusedDate, focusableDate, onSelectDate, onFocusDate, onChangeMonth, startOfWeek, todayAriaLabel, selectedDate, handleFocusMove, }: GridProps): JSX.Element;
19
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/calendar/grid/index.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAI/D,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,IAAI,CAAC;IACf,aAAa,EAAE,eAAe,CAAC,qBAAqB,CAAC;IACrD,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACpC,WAAW,EAAE,QAAQ,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,eAAe,EAAE,gBAAgB,CAAC;CACnC;AAED,QAAA,MAAM,IAAI,4JAYP,SAAS,gBAmFX,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/calendar/grid/index.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAO/D,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,IAAI,CAAC;IACf,aAAa,EAAE,eAAe,CAAC,qBAAqB,CAAC;IACrD,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,aAAa,EAAE,IAAI,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACpC,WAAW,EAAE,QAAQ,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,eAAe,EAAE,gBAAgB,CAAC;CACnC;AAED,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAC3B,MAAM,EACN,QAAQ,EACR,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,WAAW,EACX,aAAa,EACb,WAAW,EACX,cAAc,EACd,YAAY,EACZ,eAAe,GAChB,EAAE,SAAS,eAuIX"}
@@ -1,43 +1,48 @@
1
+ import { __assign } from "tslib";
1
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
3
  // SPDX-License-Identifier: Apache-2.0
3
- import React, { useMemo } from 'react';
4
+ import React, { useMemo, useRef } from 'react';
4
5
  import styles from '../styles.css.js';
5
- import GridDay from './day';
6
6
  import { KeyCode } from '../../internal/keycode';
7
- import { addDays, addWeeks, isSameMonth } from 'date-fns';
7
+ import { addDays, addWeeks, isSameDay, isSameMonth } from 'date-fns';
8
8
  import { getCalendarMonth } from 'mnth';
9
9
  import rotateDayIndexes from '../utils/rotate-day-indexes';
10
- import { renderDayName } from '../utils/intl';
11
- var Grid = function (_a) {
12
- var locale = _a.locale, baseDate = _a.baseDate, isDateEnabled = _a.isDateEnabled, focusedDate = _a.focusedDate, onSelectDate = _a.onSelectDate, onFocusDate = _a.onFocusDate, onChangeMonth = _a.onChangeMonth, startOfWeek = _a.startOfWeek, todayAriaLabel = _a.todayAriaLabel, selectedDate = _a.selectedDate, handleFocusMove = _a.handleFocusMove;
10
+ import { getDateLabel, renderDayName } from '../utils/intl';
11
+ import useFocusVisible from '../../internal/hooks/focus-visible/index.js';
12
+ import clsx from 'clsx';
13
+ import { useEffectOnUpdate } from '../../internal/hooks/use-effect-on-update.js';
14
+ export default function Grid(_a) {
15
+ var locale = _a.locale, baseDate = _a.baseDate, isDateEnabled = _a.isDateEnabled, focusedDate = _a.focusedDate, focusableDate = _a.focusableDate, onSelectDate = _a.onSelectDate, onFocusDate = _a.onFocusDate, onChangeMonth = _a.onChangeMonth, startOfWeek = _a.startOfWeek, todayAriaLabel = _a.todayAriaLabel, selectedDate = _a.selectedDate, handleFocusMove = _a.handleFocusMove;
16
+ var focusedDateRef = useRef(null);
13
17
  var onGridKeyDownHandler = function (event) {
14
18
  var updatedFocusDate;
15
- if (focusedDate === null) {
19
+ if (focusableDate === null) {
16
20
  return;
17
21
  }
18
22
  switch (event.keyCode) {
23
+ case KeyCode.space:
19
24
  case KeyCode.enter:
20
25
  event.preventDefault();
21
- if (focusedDate) {
26
+ if (focusableDate) {
22
27
  onFocusDate(null);
23
- onSelectDate(focusedDate);
28
+ onSelectDate(focusableDate);
24
29
  }
25
30
  return;
26
31
  case KeyCode.right:
27
32
  event.preventDefault();
28
- updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, function (date) { return addDays(date, 1); });
33
+ updatedFocusDate = handleFocusMove(focusableDate, isDateEnabled, function (date) { return addDays(date, 1); });
29
34
  break;
30
35
  case KeyCode.left:
31
36
  event.preventDefault();
32
- updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, function (date) { return addDays(date, -1); });
37
+ updatedFocusDate = handleFocusMove(focusableDate, isDateEnabled, function (date) { return addDays(date, -1); });
33
38
  break;
34
39
  case KeyCode.up:
35
40
  event.preventDefault();
36
- updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, function (date) { return addWeeks(date, -1); });
41
+ updatedFocusDate = handleFocusMove(focusableDate, isDateEnabled, function (date) { return addWeeks(date, -1); });
37
42
  break;
38
43
  case KeyCode.down:
39
44
  event.preventDefault();
40
- updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, function (date) { return addWeeks(date, 1); });
45
+ updatedFocusDate = handleFocusMove(focusableDate, isDateEnabled, function (date) { return addWeeks(date, 1); });
41
46
  break;
42
47
  default:
43
48
  return;
@@ -47,15 +52,51 @@ var Grid = function (_a) {
47
52
  }
48
53
  onFocusDate(updatedFocusDate);
49
54
  };
55
+ // The focused date changes as a feedback to keyboard navigation in the grid.
56
+ // Once changed, the corresponding day button needs to receive the actual focus.
57
+ useEffectOnUpdate(function () {
58
+ if (focusedDate && focusedDateRef.current) {
59
+ focusedDateRef.current.focus();
60
+ }
61
+ }, [focusedDate]);
50
62
  var weeks = useMemo(function () { return getCalendarMonth(baseDate, { firstDayOfWeek: startOfWeek }); }, [baseDate, startOfWeek]);
51
- return (React.createElement("div", null,
52
- React.createElement("div", { className: styles['calendar-day-names'] }, rotateDayIndexes(startOfWeek).map(function (i) { return (React.createElement("div", { key: "day-name-".concat(i), className: styles['calendar-day-name'] }, renderDayName(locale, i))); })),
53
- React.createElement("div", { className: styles['calendar-dates'], onKeyDown: onGridKeyDownHandler }, weeks.map(function (week, weekIndex) {
54
- var isDateInLastWeek = weeks.length - 1 === weekIndex;
55
- return (React.createElement("div", { key: "week-".concat(weekIndex), className: styles['calendar-week'] }, week.map(function (date, dateIndex) {
56
- return (React.createElement(GridDay, { key: "date-".concat(weekIndex, "-").concat(dateIndex), locale: locale, baseDate: baseDate, selectedDate: selectedDate, date: date, focusedDate: focusedDate, todayAriaLabel: todayAriaLabel, onSelectDate: function (date) { return onSelectDate(date); }, isDateEnabled: isDateEnabled, isDateInLastWeek: isDateInLastWeek }));
57
- })));
58
- }))));
59
- };
60
- export default Grid;
63
+ var focusVisible = useFocusVisible();
64
+ return (React.createElement("table", { role: "none", className: styles['calendar-grid'] },
65
+ React.createElement("thead", null,
66
+ React.createElement("tr", null, rotateDayIndexes(startOfWeek).map(function (dayIndex) { return (React.createElement("th", { key: dayIndex, scope: "col", className: clsx(styles['calendar-grid-cell'], styles['calendar-day-header']) }, renderDayName(locale, dayIndex))); }))),
67
+ React.createElement("tbody", { onKeyDown: onGridKeyDownHandler }, weeks.map(function (week, weekIndex) { return (React.createElement("tr", { key: weekIndex, className: styles['calendar-week'] }, week.map(function (date, dateIndex) {
68
+ var _a;
69
+ var isFocusable = !!focusableDate && isSameDay(date, focusableDate);
70
+ var isSelected = !!selectedDate && isSameDay(date, selectedDate);
71
+ var isEnabled = !isDateEnabled || isDateEnabled(date);
72
+ var isDateOnSameDay = isSameDay(date, new Date());
73
+ // Can't be focused.
74
+ var tabIndex = undefined;
75
+ if (isFocusable && isEnabled) {
76
+ // Next focus target.
77
+ tabIndex = 0;
78
+ }
79
+ else if (isEnabled) {
80
+ // Can be focused programmatically.
81
+ tabIndex = -1;
82
+ }
83
+ // Screen-reader announcement for the focused day.
84
+ var dayAnnouncement = getDateLabel(locale, date);
85
+ if (isDateOnSameDay) {
86
+ dayAnnouncement += '. ' + todayAriaLabel;
87
+ }
88
+ var onClick = function () {
89
+ if (isEnabled) {
90
+ onSelectDate(date);
91
+ }
92
+ };
93
+ return (React.createElement("td", __assign({ key: "".concat(weekIndex, ":").concat(dateIndex), ref: tabIndex === 0 ? focusedDateRef : undefined, role: "button", tabIndex: tabIndex, "aria-label": dayAnnouncement, "aria-current": isSelected ? 'date' : undefined, "aria-disabled": !isEnabled, onClick: onClick, className: clsx(styles['calendar-grid-cell'], styles['calendar-day'], (_a = {},
94
+ _a[styles['calendar-day-current-month']] = isSameMonth(date, baseDate),
95
+ _a[styles['calendar-day-enabled']] = isEnabled,
96
+ _a[styles['calendar-day-selected']] = isSelected,
97
+ _a[styles['calendar-day-today']] = isDateOnSameDay,
98
+ _a)) }, focusVisible),
99
+ React.createElement("span", { className: styles['day-inner'], "aria-hidden": "true" }, date.getDate())));
100
+ }))); }))));
101
+ }
61
102
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/calendar/grid/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,OAAO,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAIxC,OAAO,gBAAgB,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAgB9C,IAAM,IAAI,GAAG,UAAC,EAYF;QAXV,MAAM,YAAA,EACN,QAAQ,cAAA,EACR,aAAa,mBAAA,EACb,WAAW,iBAAA,EACX,YAAY,kBAAA,EACZ,WAAW,iBAAA,EACX,aAAa,mBAAA,EACb,WAAW,iBAAA,EACX,cAAc,oBAAA,EACd,YAAY,kBAAA,EACZ,eAAe,qBAAA;IAEf,IAAM,oBAAoB,GAAG,UAAC,KAA0B;QACtD,IAAI,gBAAgB,CAAC;QAErB,IAAI,WAAW,KAAK,IAA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AC,IAAI,CAAC,EAAlB,CAAkB,EACxC,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,GAClC,CACH,CAAC;YACJ,CAAC,CAAC,CACE,CACP,CAAC;QACJ,CAAC,CAAC,CACE,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,IAAI,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 { KeyCode } from '../../internal/keycode';\nimport { addDays, addWeeks, isSameMonth } from 'date-fns';\nimport { getCalendarMonth } from 'mnth';\nimport { DayIndex } from '../internal';\nimport { MoveFocusHandler } from '../utils/move-focus-handler';\nimport { DatePickerProps } from '../../date-picker/interfaces';\nimport rotateDayIndexes from '../utils/rotate-day-indexes';\nimport { renderDayName } from '../utils/intl';\n\nexport interface GridProps {\n locale: string;\n baseDate: Date;\n isDateEnabled: DatePickerProps.IsDateEnabledFunction;\n focusedDate: Date | null;\n onSelectDate: (date: Date) => void;\n onFocusDate: (date: null | Date) => void;\n onChangeMonth: (date: Date) => void;\n startOfWeek: DayIndex;\n todayAriaLabel: string;\n selectedDate: Date | null;\n handleFocusMove: MoveFocusHandler;\n}\n\nconst Grid = ({\n locale,\n baseDate,\n isDateEnabled,\n focusedDate,\n onSelectDate,\n onFocusDate,\n onChangeMonth,\n startOfWeek,\n todayAriaLabel,\n selectedDate,\n handleFocusMove,\n}: GridProps) => {\n const onGridKeyDownHandler = (event: React.KeyboardEvent) => {\n let updatedFocusDate;\n\n if (focusedDate === null) {\n return;\n }\n\n switch (event.keyCode) {\n case KeyCode.enter:\n event.preventDefault();\n if (focusedDate) {\n onFocusDate(null);\n onSelectDate(focusedDate);\n }\n return;\n case KeyCode.right:\n event.preventDefault();\n updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, date => addDays(date, 1));\n break;\n case KeyCode.left:\n event.preventDefault();\n updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, date => addDays(date, -1));\n break;\n case KeyCode.up:\n event.preventDefault();\n updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, date => addWeeks(date, -1));\n break;\n case KeyCode.down:\n event.preventDefault();\n updatedFocusDate = handleFocusMove(focusedDate, isDateEnabled, date => addWeeks(date, 1));\n break;\n default:\n return;\n }\n\n if (!isSameMonth(updatedFocusDate, baseDate)) {\n onChangeMonth(updatedFocusDate);\n }\n onFocusDate(updatedFocusDate);\n };\n\n const weeks = useMemo<Date[][]>(\n () => getCalendarMonth(baseDate, { firstDayOfWeek: startOfWeek }),\n [baseDate, startOfWeek]\n );\n\n return (\n <div>\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 const isDateInLastWeek = weeks.length - 1 === weekIndex;\n return (\n <div key={`week-${weekIndex}`} className={styles['calendar-week']}>\n {week.map((date, dateIndex) => {\n return (\n <GridDay\n key={`date-${weekIndex}-${dateIndex}`}\n locale={locale}\n baseDate={baseDate}\n selectedDate={selectedDate}\n date={date}\n focusedDate={focusedDate}\n todayAriaLabel={todayAriaLabel}\n onSelectDate={date => onSelectDate(date)}\n isDateEnabled={isDateEnabled}\n isDateInLastWeek={isDateInLastWeek}\n />\n );\n })}\n </div>\n );\n })}\n </div>\n </div>\n );\n};\n\nexport default Grid;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/calendar/grid/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,E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T,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useMemo, useRef } from 'react';\nimport styles from '../styles.css.js';\nimport { KeyCode } from '../../internal/keycode';\nimport { addDays, addWeeks, isSameDay, isSameMonth } from 'date-fns';\nimport { getCalendarMonth } from 'mnth';\nimport { DayIndex } from '../internal';\nimport { MoveFocusHandler } from '../utils/move-focus-handler';\nimport { DatePickerProps } from '../../date-picker/interfaces';\nimport rotateDayIndexes from '../utils/rotate-day-indexes';\nimport { getDateLabel, renderDayName } from '../utils/intl';\nimport useFocusVisible from '../../internal/hooks/focus-visible/index.js';\nimport clsx from 'clsx';\nimport { useEffectOnUpdate } from '../../internal/hooks/use-effect-on-update.js';\n\nexport interface GridProps {\n locale: string;\n baseDate: Date;\n isDateEnabled: DatePickerProps.IsDateEnabledFunction;\n focusedDate: Date | null;\n focusableDate: Date | null;\n onSelectDate: (date: Date) => void;\n onFocusDate: (date: null | Date) => void;\n onChangeMonth: (date: Date) => void;\n startOfWeek: DayIndex;\n todayAriaLabel: string;\n selectedDate: Date | null;\n handleFocusMove: MoveFocusHandler;\n}\n\nexport default function Grid({\n locale,\n baseDate,\n isDateEnabled,\n focusedDate,\n focusableDate,\n onSelectDate,\n onFocusDate,\n onChangeMonth,\n startOfWeek,\n todayAriaLabel,\n selectedDate,\n handleFocusMove,\n}: GridProps) {\n const focusedDateRef = useRef<HTMLTableCellElement>(null);\n\n const onGridKeyDownHandler = (event: React.KeyboardEvent) => {\n let updatedFocusDate;\n\n if (focusableDate === null) {\n return;\n }\n\n switch (event.keyCode) {\n case KeyCode.space:\n case KeyCode.enter:\n event.preventDefault();\n if (focusableDate) {\n onFocusDate(null);\n onSelectDate(focusableDate);\n }\n return;\n case KeyCode.right:\n event.preventDefault();\n updatedFocusDate = handleFocusMove(focusableDate, isDateEnabled, date => addDays(date, 1));\n break;\n case KeyCode.left:\n event.preventDefault();\n updatedFocusDate = handleFocusMove(focusableDate, isDateEnabled, date => addDays(date, -1));\n break;\n case KeyCode.up:\n event.preventDefault();\n updatedFocusDate = handleFocusMove(focusableDate, isDateEnabled, date => addWeeks(date, -1));\n break;\n case KeyCode.down:\n event.preventDefault();\n updatedFocusDate = handleFocusMove(focusableDate, isDateEnabled, date => addWeeks(date, 1));\n break;\n default:\n return;\n }\n\n if (!isSameMonth(updatedFocusDate, baseDate)) {\n onChangeMonth(updatedFocusDate);\n }\n onFocusDate(updatedFocusDate);\n };\n\n // The focused date changes as a feedback to keyboard navigation in the grid.\n // Once changed, the corresponding day button needs to receive the actual focus.\n useEffectOnUpdate(() => {\n if (focusedDate && focusedDateRef.current) {\n (focusedDateRef.current as HTMLDivElement).focus();\n }\n }, [focusedDate]);\n\n const weeks = useMemo<Date[][]>(\n () => getCalendarMonth(baseDate, { firstDayOfWeek: startOfWeek }),\n [baseDate, startOfWeek]\n );\n\n const focusVisible = useFocusVisible();\n\n return (\n <table role=\"none\" className={styles['calendar-grid']}>\n <thead>\n <tr>\n {rotateDayIndexes(startOfWeek).map(dayIndex => (\n <th\n key={dayIndex}\n scope=\"col\"\n className={clsx(styles['calendar-grid-cell'], styles['calendar-day-header'])}\n >\n {renderDayName(locale, dayIndex)}\n </th>\n ))}\n </tr>\n </thead>\n <tbody onKeyDown={onGridKeyDownHandler}>\n {weeks.map((week, weekIndex) => (\n <tr key={weekIndex} className={styles['calendar-week']}>\n {week.map((date, dateIndex) => {\n const isFocusable = !!focusableDate && isSameDay(date, focusableDate);\n const isSelected = !!selectedDate && isSameDay(date, selectedDate);\n const isEnabled = !isDateEnabled || isDateEnabled(date);\n const isDateOnSameDay = isSameDay(date, new Date());\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);\n if (isDateOnSameDay) {\n dayAnnouncement += '. ' + todayAriaLabel;\n }\n\n const onClick = () => {\n if (isEnabled) {\n onSelectDate(date);\n }\n };\n\n return (\n <td\n key={`${weekIndex}:${dateIndex}`}\n ref={tabIndex === 0 ? focusedDateRef : undefined}\n role=\"button\"\n tabIndex={tabIndex}\n aria-label={dayAnnouncement}\n aria-current={isSelected ? 'date' : undefined}\n aria-disabled={!isEnabled}\n onClick={onClick}\n className={clsx(styles['calendar-grid-cell'], styles['calendar-day'], {\n [styles['calendar-day-current-month']]: isSameMonth(date, baseDate),\n [styles['calendar-day-enabled']]: isEnabled,\n [styles['calendar-day-selected']]: isSelected,\n [styles['calendar-day-today']]: isDateOnSameDay,\n })}\n {...focusVisible}\n >\n <span className={styles['day-inner']} aria-hidden=\"true\">\n {date.getDate()}\n </span>\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/calendar/internal.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAG3F,oBAAY,QAAQ,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,KAAK,EACL,MAAW,EACX,WAAW,EACX,aAA0B,EAC1B,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,QAAQ,EACR,iBAAiB,EACjB,GAAG,IAAI,EACR,EAAE,aAAa,GAAG,0BAA0B,eAyH5C"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/calendar/internal.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAE3F,oBAAY,QAAQ,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,KAAK,EACL,MAAW,EACX,WAAW,EACX,aAA0B,EAC1B,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,QAAQ,EACR,iBAAiB,EACjB,GAAG,IAAI,EACR,EAAE,aAAa,GAAG,0BAA0B,eAgH5C"}
@@ -8,24 +8,20 @@ import CalendarHeader from './header';
8
8
  import Grid from './grid';
9
9
  import moveFocusHandler from './utils/move-focus-handler';
10
10
  import { memoizedDate } from './utils/memoized-date.js';
11
- import { useEffectOnUpdate } from '../internal/hooks/use-effect-on-update.js';
12
11
  import { normalizeLocale, normalizeStartOfWeek } from './utils/locales.js';
13
12
  import { formatDate } from '../internal/utils/date-time';
14
13
  import { fireNonCancelableEvent } from '../internal/events/index.js';
15
14
  import checkControlled from '../internal/hooks/check-controlled/index.js';
16
15
  import clsx from 'clsx';
17
16
  import { getBaseProps } from '../internal/base-component';
18
- import { useMergeRefs } from '../internal/hooks/use-merge-refs/index.js';
19
17
  export default function Calendar(_a) {
20
18
  var value = _a.value, _b = _a.locale, locale = _b === void 0 ? '' : _b, startOfWeek = _a.startOfWeek, _c = _a.isDateEnabled, isDateEnabled = _c === void 0 ? function () { return true; } : _c, todayAriaLabel = _a.todayAriaLabel, nextMonthAriaLabel = _a.nextMonthAriaLabel, previousMonthAriaLabel = _a.previousMonthAriaLabel, onChange = _a.onChange, __internalRootRef = _a.__internalRootRef, rest = __rest(_a, ["value", "locale", "startOfWeek", "isDateEnabled", "todayAriaLabel", "nextMonthAriaLabel", "previousMonthAriaLabel", "onChange", "__internalRootRef"]);
21
19
  checkControlled('Calendar', 'value', value, 'onChange', onChange);
22
20
  var baseProps = getBaseProps(rest);
23
21
  var normalizedLocale = normalizeLocale('Calendar', locale);
24
22
  var normalizedStartOfWeek = normalizeStartOfWeek(startOfWeek, normalizedLocale);
25
- var elementRef = useRef(null);
26
23
  var gridWrapperRef = useRef(null);
27
24
  var _d = useState(null), focusedDate = _d[0], setFocusedDate = _d[1];
28
- var ref = useMergeRefs(elementRef, __internalRootRef);
29
25
  // Set displayed date to value if defined or to current date otherwise.
30
26
  var memoizedValue = memoizedDate('value', value);
31
27
  var defaultDisplayedDate = memoizedValue !== null && memoizedValue !== void 0 ? memoizedValue : new Date();
@@ -60,7 +56,7 @@ export default function Calendar(_a) {
60
56
  return startDate;
61
57
  };
62
58
  var baseDate = getBaseDate(displayedDate);
63
- var focusedOrSelectedDate = focusedDate || selectFocusedDate(memoizedValue, baseDate);
59
+ var focusableDate = focusedDate || selectFocusedDate(memoizedValue, baseDate);
64
60
  var onHeaderChangeMonthHandler = function (isPreviousButtonClick) {
65
61
  setDisplayedDate(addMonths(baseDate, isPreviousButtonClick ? -1 : 1));
66
62
  setFocusedDate(null);
@@ -79,14 +75,6 @@ export default function Calendar(_a) {
79
75
  fireNonCancelableEvent(onChange, { value: formatDate(date) });
80
76
  setFocusedDate(null);
81
77
  };
82
- // The focused date changes as a feedback to keyboard navigation in the grid.
83
- // Once changed, the corresponding day button needs to receive the actual focus.
84
- useEffectOnUpdate(function () {
85
- var _a, _b;
86
- if (focusedDate) {
87
- (_b = (_a = elementRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(".".concat(styles['calendar-day-focusable']))) === null || _b === void 0 ? void 0 : _b.focus();
88
- }
89
- }, [focusedDate]);
90
78
  var onGridBlur = function (event) {
91
79
  var _a;
92
80
  var newFocusTargetIsInGrid = event.relatedTarget && ((_a = gridWrapperRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.relatedTarget));
@@ -94,10 +82,10 @@ export default function Calendar(_a) {
94
82
  setFocusedDate(null);
95
83
  }
96
84
  };
97
- return (React.createElement("div", __assign({ ref: ref, role: "application" }, baseProps, { className: clsx(styles.root, styles.calendar, baseProps.className) }),
85
+ return (React.createElement("div", __assign({ ref: __internalRootRef, role: "application" }, baseProps, { className: clsx(styles.root, styles.calendar, baseProps.className) }),
98
86
  React.createElement("div", { className: styles['calendar-inner'] },
99
87
  React.createElement(CalendarHeader, { baseDate: baseDate, locale: normalizedLocale, onChangeMonth: onHeaderChangeMonthHandler, previousMonthLabel: previousMonthAriaLabel, nextMonthLabel: nextMonthAriaLabel }),
100
88
  React.createElement("div", { onBlur: onGridBlur, ref: gridWrapperRef },
101
- React.createElement(Grid, { locale: normalizedLocale, baseDate: baseDate, isDateEnabled: isDateEnabled, focusedDate: focusedOrSelectedDate, onSelectDate: onGridSelectDateHandler, onFocusDate: onGridFocusDateHandler, onChangeMonth: onGridChangeMonthHandler, startOfWeek: normalizedStartOfWeek, todayAriaLabel: todayAriaLabel, selectedDate: memoizedValue, handleFocusMove: moveFocusHandler })))));
89
+ React.createElement(Grid, { locale: normalizedLocale, baseDate: baseDate, isDateEnabled: isDateEnabled, focusedDate: focusedDate, focusableDate: focusableDate, onSelectDate: onGridSelectDateHandler, onFocusDate: onGridFocusDateHandler, onChangeMonth: onGridChangeMonthHandler, startOfWeek: normalizedStartOfWeek, todayAriaLabel: todayAriaLabel, selectedDate: memoizedValue, handleFocusMove: moveFocusHandler })))));
102
90
  }
103
91
  //# sourceMappingURL=internal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/calendar/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACzF,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,cAAc,MAAM,UAAU,CAAC;AACtC,O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,EAAE,cAAc,EAC9B,YAAY,EAAE,aAAa,EAC3B,eAAe,EAAE,gBAAgB,GACjC,CACE,CACF,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport { addDays, addMonths, getDaysInMonth, isSameMonth, startOfMonth } from 'date-fns';\nimport styles from './styles.css.js';\nimport CalendarHeader from './header';\nimport Grid from './grid';\nimport moveFocusHandler from './utils/move-focus-handler';\nimport { memoizedDate } from './utils/memoized-date.js';\nimport { useEffectOnUpdate } from '../internal/hooks/use-effect-on-update.js';\nimport { normalizeLocale, normalizeStartOfWeek } from './utils/locales.js';\nimport { formatDate } from '../internal/utils/date-time';\nimport { fireNonCancelableEvent } from '../internal/events/index.js';\nimport checkControlled from '../internal/hooks/check-controlled/index.js';\nimport clsx from 'clsx';\nimport { CalendarProps } from './interfaces.js';\nimport { getBaseProps } from '../internal/base-component';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs/index.js';\n\nexport type DayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\nexport default function Calendar({\n value,\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n todayAriaLabel,\n nextMonthAriaLabel,\n previousMonthAriaLabel,\n onChange,\n __internalRootRef,\n ...rest\n}: CalendarProps & InternalBaseComponentProps) {\n checkControlled('Calendar', 'value', value, 'onChange', onChange);\n\n const baseProps = getBaseProps(rest);\n const normalizedLocale = normalizeLocale('Calendar', locale);\n const normalizedStartOfWeek = normalizeStartOfWeek(startOfWeek, normalizedLocale);\n const elementRef = useRef<HTMLDivElement>(null);\n const gridWrapperRef = useRef<HTMLDivElement>(null);\n const [focusedDate, setFocusedDate] = useState<Date | null>(null);\n const ref = useMergeRefs(elementRef, __internalRootRef);\n\n // Set displayed date to value if defined or to current date otherwise.\n const memoizedValue = memoizedDate('value', value);\n const defaultDisplayedDate = memoizedValue ?? new Date();\n const [displayedDate, setDisplayedDate] = useState(defaultDisplayedDate);\n\n // Update displayed date if value changes.\n useEffect(() => {\n memoizedValue && setDisplayedDate(prev => (prev.getTime() !== memoizedValue.getTime() ? memoizedValue : prev));\n }, [memoizedValue]);\n\n const selectFocusedDate = (selected: Date | null, baseDate: Date): Date | null => {\n if (selected && isDateEnabled(selected) && isSameMonth(selected, baseDate)) {\n return selected;\n }\n const today = new Date();\n if (isDateEnabled(today) && isSameMonth(today, baseDate)) {\n return today;\n }\n if (isDateEnabled(baseDate)) {\n return baseDate;\n }\n return null;\n };\n\n // Get the first enabled date of the month. If no day is enabled in the given month, return the first day of the month.\n // This is needed because `baseDate` is used as the first focusable date, for example when navigating to the calendar area.\n const getBaseDate = (date: Date) => {\n const startDate = startOfMonth(date);\n for (let i = 0; i < getDaysInMonth(date); i++) {\n const currentDate = addDays(startDate, i);\n if (isDateEnabled(currentDate)) {\n return currentDate;\n }\n }\n return startDate;\n };\n\n const baseDate: Date = getBaseDate(displayedDate);\n const focusedOrSelectedDate = focusedDate || selectFocusedDate(memoizedValue, baseDate);\n\n const onHeaderChangeMonthHandler = (isPreviousButtonClick?: boolean) => {\n setDisplayedDate(addMonths(baseDate, isPreviousButtonClick ? -1 : 1));\n setFocusedDate(null);\n };\n\n const onGridChangeMonthHandler = (newMonth: Date) => {\n setDisplayedDate(newMonth);\n setFocusedDate(null);\n };\n\n const onGridFocusDateHandler = (date: null | Date) => {\n if (date) {\n const value = memoizedDate('focused', formatDate(date));\n setFocusedDate(value);\n }\n };\n\n const onGridSelectDateHandler = (date: Date) => {\n fireNonCancelableEvent(onChange, { value: formatDate(date) });\n setFocusedDate(null);\n };\n\n // The focused date changes as a feedback to keyboard navigation in the grid.\n // Once changed, the corresponding day button needs to receive the actual focus.\n useEffectOnUpdate(() => {\n if (focusedDate) {\n (elementRef.current?.querySelector(`.${styles['calendar-day-focusable']}`) as HTMLDivElement)?.focus();\n }\n }, [focusedDate]);\n\n const onGridBlur = (event: React.FocusEvent) => {\n const newFocusTargetIsInGrid = event.relatedTarget && gridWrapperRef.current?.contains(event.relatedTarget as Node);\n if (!newFocusTargetIsInGrid) {\n setFocusedDate(null);\n }\n };\n\n return (\n <div\n ref={ref}\n role=\"application\"\n {...baseProps}\n className={clsx(styles.root, styles.calendar, baseProps.className)}\n >\n <div className={styles['calendar-inner']}>\n <CalendarHeader\n baseDate={baseDate}\n locale={normalizedLocale}\n onChangeMonth={onHeaderChangeMonthHandler}\n previousMonthLabel={previousMonthAriaLabel}\n nextMonthLabel={nextMonthAriaLabel}\n />\n <div onBlur={onGridBlur} ref={gridWrapperRef}>\n <Grid\n locale={normalizedLocale}\n baseDate={baseDate}\n isDateEnabled={isDateEnabled}\n focusedDate={focusedOrSelectedDate}\n onSelectDate={onGridSelectDateHandler}\n onFocusDate={onGridFocusDateHandler}\n onChangeMonth={onGridChangeMonthHandler}\n startOfWeek={normalizedStartOfWeek}\n todayAriaLabel={todayAriaLabel}\n selectedDate={memoizedValue}\n handleFocusMove={moveFocusHandler}\n />\n </div>\n </div>\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/calendar/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACzF,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,cAAc,MAAM,UAAU,CAAC;AACtC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,E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AS,IACb,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC;QAElE,6BAAK,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC;YACtC,oBAAC,cAAc,IACb,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,gBAAgB,EACxB,aAAa,EAAE,0BAA0B,EACzC,kBAAkB,EAAE,sBAAsB,EAC1C,cAAc,EAAE,kBAAkB,GAClC;YACF,6BAAK,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,cAAc;gBAC1C,oBAAC,IAAI,IACH,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,uBAAuB,EACrC,WAAW,EAAE,sBAAsB,EACnC,aAAa,EAAE,wBAAwB,EACvC,WAAW,EAAE,qBAAqB,EAClC,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,aAAa,EAC3B,eAAe,EAAE,gBAAgB,GACjC,CACE,CACF,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport { addDays, addMonths, getDaysInMonth, isSameMonth, startOfMonth } from 'date-fns';\nimport styles from './styles.css.js';\nimport CalendarHeader from './header';\nimport Grid from './grid';\nimport moveFocusHandler from './utils/move-focus-handler';\nimport { memoizedDate } from './utils/memoized-date.js';\nimport { normalizeLocale, normalizeStartOfWeek } from './utils/locales.js';\nimport { formatDate } from '../internal/utils/date-time';\nimport { fireNonCancelableEvent } from '../internal/events/index.js';\nimport checkControlled from '../internal/hooks/check-controlled/index.js';\nimport clsx from 'clsx';\nimport { CalendarProps } from './interfaces.js';\nimport { getBaseProps } from '../internal/base-component';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';\n\nexport type DayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\nexport default function Calendar({\n value,\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n todayAriaLabel,\n nextMonthAriaLabel,\n previousMonthAriaLabel,\n onChange,\n __internalRootRef,\n ...rest\n}: CalendarProps & InternalBaseComponentProps) {\n checkControlled('Calendar', 'value', value, 'onChange', onChange);\n\n const baseProps = getBaseProps(rest);\n const normalizedLocale = normalizeLocale('Calendar', locale);\n const normalizedStartOfWeek = normalizeStartOfWeek(startOfWeek, normalizedLocale);\n const gridWrapperRef = useRef<HTMLDivElement>(null);\n const [focusedDate, setFocusedDate] = useState<Date | null>(null);\n\n // Set displayed date to value if defined or to current date otherwise.\n const memoizedValue = memoizedDate('value', value);\n const defaultDisplayedDate = memoizedValue ?? new Date();\n const [displayedDate, setDisplayedDate] = useState(defaultDisplayedDate);\n\n // Update displayed date if value changes.\n useEffect(() => {\n memoizedValue && setDisplayedDate(prev => (prev.getTime() !== memoizedValue.getTime() ? memoizedValue : prev));\n }, [memoizedValue]);\n\n const selectFocusedDate = (selected: Date | null, baseDate: Date): Date | null => {\n if (selected && isDateEnabled(selected) && isSameMonth(selected, baseDate)) {\n return selected;\n }\n const today = new Date();\n if (isDateEnabled(today) && isSameMonth(today, baseDate)) {\n return today;\n }\n if (isDateEnabled(baseDate)) {\n return baseDate;\n }\n return null;\n };\n\n // Get the first enabled date of the month. If no day is enabled in the given month, return the first day of the month.\n // This is needed because `baseDate` is used as the first focusable date, for example when navigating to the calendar area.\n const getBaseDate = (date: Date) => {\n const startDate = startOfMonth(date);\n for (let i = 0; i < getDaysInMonth(date); i++) {\n const currentDate = addDays(startDate, i);\n if (isDateEnabled(currentDate)) {\n return currentDate;\n }\n }\n return startDate;\n };\n\n const baseDate: Date = getBaseDate(displayedDate);\n const focusableDate = focusedDate || selectFocusedDate(memoizedValue, baseDate);\n\n const onHeaderChangeMonthHandler = (isPreviousButtonClick?: boolean) => {\n setDisplayedDate(addMonths(baseDate, isPreviousButtonClick ? -1 : 1));\n setFocusedDate(null);\n };\n\n const onGridChangeMonthHandler = (newMonth: Date) => {\n setDisplayedDate(newMonth);\n setFocusedDate(null);\n };\n\n const onGridFocusDateHandler = (date: null | Date) => {\n if (date) {\n const value = memoizedDate('focused', formatDate(date));\n setFocusedDate(value);\n }\n };\n\n const onGridSelectDateHandler = (date: Date) => {\n fireNonCancelableEvent(onChange, { value: formatDate(date) });\n setFocusedDate(null);\n };\n\n const onGridBlur = (event: React.FocusEvent) => {\n const newFocusTargetIsInGrid = event.relatedTarget && gridWrapperRef.current?.contains(event.relatedTarget as Node);\n if (!newFocusTargetIsInGrid) {\n setFocusedDate(null);\n }\n };\n\n return (\n <div\n ref={__internalRootRef}\n role=\"application\"\n {...baseProps}\n className={clsx(styles.root, styles.calendar, baseProps.className)}\n >\n <div className={styles['calendar-inner']}>\n <CalendarHeader\n baseDate={baseDate}\n locale={normalizedLocale}\n onChangeMonth={onHeaderChangeMonthHandler}\n previousMonthLabel={previousMonthAriaLabel}\n nextMonthLabel={nextMonthAriaLabel}\n />\n <div onBlur={onGridBlur} ref={gridWrapperRef}>\n <Grid\n locale={normalizedLocale}\n baseDate={baseDate}\n isDateEnabled={isDateEnabled}\n focusedDate={focusedDate}\n focusableDate={focusableDate}\n onSelectDate={onGridSelectDateHandler}\n onFocusDate={onGridFocusDateHandler}\n onChangeMonth={onGridChangeMonthHandler}\n startOfWeek={normalizedStartOfWeek}\n todayAriaLabel={todayAriaLabel}\n selectedDate={memoizedValue}\n handleFocusMove={moveFocusHandler}\n />\n </div>\n </div>\n </div>\n );\n}\n"]}
@@ -1,25 +1,23 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "calendar": "awsui_calendar_1ykar_16ssf_93",
5
- "awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_1ykar_16ssf_1",
6
- "root": "awsui_root_1ykar_16ssf_124",
7
- "calendar-inner": "awsui_calendar-inner_1ykar_16ssf_141",
8
- "calendar-header": "awsui_calendar-header_1ykar_16ssf_144",
9
- "calendar-header-month": "awsui_calendar-header-month_1ykar_16ssf_149",
10
- "calendar-next-month-btn": "awsui_calendar-next-month-btn_1ykar_16ssf_155",
11
- "calendar-prev-month-btn": "awsui_calendar-prev-month-btn_1ykar_16ssf_158",
12
- "calendar-day-names": "awsui_calendar-day-names_1ykar_16ssf_161",
13
- "calendar-day-name": "awsui_calendar-day-name_1ykar_16ssf_161",
14
- "calendar-dates": "awsui_calendar-dates_1ykar_16ssf_176",
15
- "calendar-week": "awsui_calendar-week_1ykar_16ssf_179",
16
- "calendar-day": "awsui_calendar-day_1ykar_16ssf_161",
17
- "calendar-day-in-last-week": "awsui_calendar-day-in-last-week_1ykar_16ssf_197",
18
- "calendar-day-focusable": "awsui_calendar-day-focusable_1ykar_16ssf_200",
19
- "calendar-day-enabled": "awsui_calendar-day-enabled_1ykar_16ssf_203",
20
- "calendar-day-current-month": "awsui_calendar-day-current-month_1ykar_16ssf_210",
21
- "calendar-day-selected": "awsui_calendar-day-selected_1ykar_16ssf_217",
22
- "calendar-day-today": "awsui_calendar-day-today_1ykar_16ssf_220",
23
- "day-inner": "awsui_day-inner_1ykar_16ssf_234"
4
+ "calendar": "awsui_calendar_1ykar_1y06z_93",
5
+ "awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_1ykar_1y06z_1",
6
+ "root": "awsui_root_1ykar_1y06z_124",
7
+ "calendar-inner": "awsui_calendar-inner_1ykar_1y06z_141",
8
+ "calendar-header": "awsui_calendar-header_1ykar_1y06z_144",
9
+ "calendar-header-month": "awsui_calendar-header-month_1ykar_1y06z_149",
10
+ "calendar-next-month-btn": "awsui_calendar-next-month-btn_1ykar_1y06z_155",
11
+ "calendar-prev-month-btn": "awsui_calendar-prev-month-btn_1ykar_1y06z_158",
12
+ "calendar-grid": "awsui_calendar-grid_1ykar_1y06z_161",
13
+ "calendar-grid-cell": "awsui_calendar-grid-cell_1ykar_1y06z_165",
14
+ "calendar-day-header": "awsui_calendar-day-header_1ykar_1y06z_171",
15
+ "calendar-day": "awsui_calendar-day_1ykar_1y06z_171",
16
+ "calendar-day-enabled": "awsui_calendar-day-enabled_1ykar_1y06z_188",
17
+ "calendar-day-current-month": "awsui_calendar-day-current-month_1ykar_1y06z_195",
18
+ "calendar-day-selected": "awsui_calendar-day-selected_1ykar_1y06z_202",
19
+ "calendar-day-today": "awsui_calendar-day-today_1ykar_1y06z_205",
20
+ "day-inner": "awsui_day-inner_1ykar_1y06z_219",
21
+ "calendar-week": "awsui_calendar-week_1ykar_1y06z_283"
24
22
  };
25
23