@cloudscape-design/components 3.0.72 → 3.0.73

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 (139) hide show
  1. package/app-layout/toggles/index.d.ts.map +1 -1
  2. package/app-layout/toggles/index.js +2 -2
  3. package/app-layout/toggles/index.js.map +1 -1
  4. package/app-layout/visual-refresh/app-bar.d.ts.map +1 -1
  5. package/app-layout/visual-refresh/app-bar.js +2 -2
  6. package/app-layout/visual-refresh/app-bar.js.map +1 -1
  7. package/app-layout/visual-refresh/navigation.d.ts.map +1 -1
  8. package/app-layout/visual-refresh/navigation.js +1 -1
  9. package/app-layout/visual-refresh/navigation.js.map +1 -1
  10. package/app-layout/visual-refresh/tools.d.ts.map +1 -1
  11. package/app-layout/visual-refresh/tools.js +1 -1
  12. package/app-layout/visual-refresh/tools.js.map +1 -1
  13. package/app-layout/visual-refresh/trigger-button.d.ts.map +1 -1
  14. package/app-layout/visual-refresh/trigger-button.js +1 -1
  15. package/app-layout/visual-refresh/trigger-button.js.map +1 -1
  16. package/breadcrumb-group/item/styles.css.js +7 -7
  17. package/breadcrumb-group/item/styles.scoped.css +16 -15
  18. package/breadcrumb-group/item/styles.selectors.js +7 -7
  19. package/calendar/grid/index.d.ts +2 -2
  20. package/calendar/grid/index.d.ts.map +1 -1
  21. package/calendar/grid/index.js +64 -23
  22. package/calendar/grid/index.js.map +1 -1
  23. package/calendar/internal.d.ts.map +1 -1
  24. package/calendar/internal.js +3 -15
  25. package/calendar/internal.js.map +1 -1
  26. package/calendar/styles.css.js +18 -20
  27. package/calendar/styles.scoped.css +46 -58
  28. package/calendar/styles.selectors.js +18 -20
  29. package/date-range-picker/calendar/grids/grid.d.ts.map +1 -1
  30. package/date-range-picker/calendar/grids/grid.js +61 -6
  31. package/date-range-picker/calendar/grids/grid.js.map +1 -1
  32. package/date-range-picker/calendar/grids/index.d.ts.map +1 -1
  33. package/date-range-picker/calendar/grids/index.js +1 -0
  34. package/date-range-picker/calendar/grids/index.js.map +1 -1
  35. package/date-range-picker/calendar/grids/styles.css.js +26 -0
  36. package/date-range-picker/calendar/grids/{day/styles.scoped.css → styles.scoped.css} +38 -38
  37. package/date-range-picker/calendar/grids/styles.selectors.js +27 -0
  38. package/date-range-picker/index.js +2 -2
  39. package/date-range-picker/index.js.map +1 -1
  40. package/date-range-picker/styles.css.js +41 -40
  41. package/date-range-picker/styles.scoped.css +56 -48
  42. package/date-range-picker/styles.selectors.js +41 -40
  43. package/expandable-section/expandable-section-header.d.ts +3 -2
  44. package/expandable-section/expandable-section-header.d.ts.map +1 -1
  45. package/expandable-section/expandable-section-header.js +3 -3
  46. package/expandable-section/expandable-section-header.js.map +1 -1
  47. package/expandable-section/interfaces.d.ts +5 -0
  48. package/expandable-section/interfaces.d.ts.map +1 -1
  49. package/expandable-section/interfaces.js.map +1 -1
  50. package/expandable-section/internal.d.ts +1 -1
  51. package/expandable-section/internal.d.ts.map +1 -1
  52. package/expandable-section/internal.js +4 -3
  53. package/expandable-section/internal.js.map +1 -1
  54. package/internal/components/dropdown-status/index.d.ts +3 -1
  55. package/internal/components/dropdown-status/index.d.ts.map +1 -1
  56. package/internal/components/dropdown-status/index.js +7 -4
  57. package/internal/components/dropdown-status/index.js.map +1 -1
  58. package/internal/components/live-region/index.d.ts.map +1 -1
  59. package/internal/components/live-region/index.js +1 -0
  60. package/internal/components/live-region/index.js.map +1 -1
  61. package/internal/environment.js +1 -1
  62. package/modal/internal.d.ts.map +1 -1
  63. package/modal/internal.js +6 -10
  64. package/modal/internal.js.map +1 -1
  65. package/multiselect/internal.d.ts.map +1 -1
  66. package/multiselect/internal.js +3 -2
  67. package/multiselect/internal.js.map +1 -1
  68. package/package.json +1 -1
  69. package/property-filter/controller.d.ts +2 -0
  70. package/property-filter/controller.d.ts.map +1 -1
  71. package/property-filter/controller.js +37 -0
  72. package/property-filter/controller.js.map +1 -1
  73. package/property-filter/index.d.ts.map +1 -1
  74. package/property-filter/index.js +21 -6
  75. package/property-filter/index.js.map +1 -1
  76. package/property-filter/interfaces.d.ts +9 -2
  77. package/property-filter/interfaces.d.ts.map +1 -1
  78. package/property-filter/interfaces.js +2 -0
  79. package/property-filter/interfaces.js.map +1 -1
  80. package/property-filter/property-editor.d.ts +13 -0
  81. package/property-filter/property-editor.d.ts.map +1 -0
  82. package/property-filter/property-editor.js +18 -0
  83. package/property-filter/property-editor.js.map +1 -0
  84. package/property-filter/property-filter-autosuggest.d.ts +1 -0
  85. package/property-filter/property-filter-autosuggest.d.ts.map +1 -1
  86. package/property-filter/property-filter-autosuggest.js +17 -3
  87. package/property-filter/property-filter-autosuggest.js.map +1 -1
  88. package/property-filter/styles.css.js +32 -24
  89. package/property-filter/styles.scoped.css +45 -27
  90. package/property-filter/styles.selectors.js +32 -24
  91. package/property-filter/token-editor.d.ts.map +1 -1
  92. package/property-filter/token-editor.js +17 -4
  93. package/property-filter/token-editor.js.map +1 -1
  94. package/property-filter/token.d.ts.map +1 -1
  95. package/property-filter/token.js +6 -3
  96. package/property-filter/token.js.map +1 -1
  97. package/select/internal.d.ts.map +1 -1
  98. package/select/internal.js +3 -2
  99. package/select/internal.js.map +1 -1
  100. package/select/parts/filter.d.ts +1 -1
  101. package/select/utils/use-select.d.ts +15 -1
  102. package/select/utils/use-select.d.ts.map +1 -1
  103. package/select/utils/use-select.js +11 -1
  104. package/select/utils/use-select.js.map +1 -1
  105. package/split-panel/index.d.ts.map +1 -1
  106. package/split-panel/index.js +8 -6
  107. package/split-panel/index.js.map +1 -1
  108. package/split-panel/interfaces.d.ts +1 -0
  109. package/split-panel/interfaces.d.ts.map +1 -1
  110. package/split-panel/interfaces.js.map +1 -1
  111. package/split-panel/utils/use-pointer-events.d.ts +1 -1
  112. package/split-panel/utils/use-pointer-events.d.ts.map +1 -1
  113. package/split-panel/utils/use-pointer-events.js +9 -5
  114. package/split-panel/utils/use-pointer-events.js.map +1 -1
  115. package/table/internal.d.ts.map +1 -1
  116. package/table/internal.js +8 -1
  117. package/table/internal.js.map +1 -1
  118. package/table/use-mouse-down-target.d.ts +6 -0
  119. package/table/use-mouse-down-target.d.ts.map +1 -0
  120. package/table/use-mouse-down-target.js +30 -0
  121. package/table/use-mouse-down-target.js.map +1 -0
  122. package/tabs/styles.css.js +21 -21
  123. package/tabs/styles.scoped.css +38 -37
  124. package/tabs/styles.selectors.js +21 -21
  125. package/test-utils/dom/date-range-picker/index.js +1 -1
  126. package/test-utils/dom/date-range-picker/index.js.map +1 -1
  127. package/test-utils/selectors/date-range-picker/index.js +1 -1
  128. package/test-utils/selectors/date-range-picker/index.js.map +1 -1
  129. package/test-utils/tsconfig.tsbuildinfo +1 -1
  130. package/calendar/grid/day/index.d.ts +0 -15
  131. package/calendar/grid/day/index.d.ts.map +0 -1
  132. package/calendar/grid/day/index.js +0 -47
  133. package/calendar/grid/day/index.js.map +0 -1
  134. package/date-range-picker/calendar/grids/day/index.d.ts +0 -27
  135. package/date-range-picker/calendar/grids/day/index.d.ts.map +0 -1
  136. package/date-range-picker/calendar/grids/day/index.js +0 -95
  137. package/date-range-picker/calendar/grids/day/index.js.map +0 -1
  138. package/date-range-picker/calendar/grids/day/styles.css.js +0 -26
  139. package/date-range-picker/calendar/grids/day/styles.selectors.js +0 -27
@@ -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,6B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,eAAQ,SAAS,CAAE,EAAE,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC,IAC9D,IAAI,CAAC,GAAG,CAAC,UAAC,IAAI,EAAE,SAAS;gBACxB,OAAO,CACL,oBAAC,OAAO,IACN,GAAG,EAAE,eAAQ,SAAS,cAAI,SAAS,CAAE,EACrC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,UAAA,IAAI,IAAI,OAAA,YAAY,CAAC,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,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAIxC,OAAO,gBAAgB,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,eAAe,MAAM,6CAA6C,CAAC;AAC1E,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AAiBjF,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAajB;QAZV,MAAM,YAAA,EACN,QAAQ,cAAA,EACR,aAAa,mBAAA,EACb,WAAW,iBAAA,EACX,aAAa,mBAAA,EACb,YAAY,kBAAA,EACZ,WAAW,iBAAA,EACX,aAAa,mBAAA,EACb,WAAW,iBAAA,EACX,cAAc,oBAAA,EACd,YAAY,kBAAA,EACZ,eAAe,qBAAA;IAEf,IAAM,cAAc,GAAG,MAAM,CAAuB,IAAI,CAAC,CAAC;IAE1D,IAAM,oBAAoB,GAAG,UAAC,KAA0B;QACtD,IAAI,gBAAgB,CAAC;QAErB,IAAI,aAAa,KAAK,IAAI,EAAE;YA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,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC;oBACnE,GAAC,MAAM,CAAC,sBAAsB,CAAC,IAAG,SAAS;oBAC3C,GAAC,MAAM,CAAC,uBAAuB,CAAC,IAAG,UAAU;oBAC7C,GAAC,MAAM,CAAC,oBAAoB,CAAC,IAAG,eAAe;wBAC/C,IACE,YAAY;gBAEhB,8BAAM,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,iBAAc,MAAM,IACrD,IAAI,CAAC,OAAO,EAAE,CACV,CACJ,CACN,CAAC;QACJ,CAAC,CAAC,CACC,CACN,EAvD+B,CAuD/B,CAAC,CACI,CACF,CACT,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
  //# sourceMapp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,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,qBAAqB,EAClC,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 { 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,O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;QAC9D,cAAc,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC,CAAC;IAEF,IAAM,UAAU,GAAG,UAAC,KAAuB;;QACzC,IAAM,sBAAsB,GAAG,KAAK,CAAC,aAAa,KAAI,MAAA,cAAc,CAAC,OAAO,0CAAE,QAAQ,CAAC,KAAK,CAAC,aAAqB,CAAC,CAAA,CAAC;QACpH,IAAI,CAAC,sBAAsB,EAAE;YAC3B,cAAc,CAAC,IAAI,CAAC,CAAC;SACtB;IACH,CAAC,CAAC;IAEF,OAAO,CACL,sCACE,GAAG,EAAE,iBAAiB,EACtB,IAAI,EAAC,aAAa,IACd,SAAS,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_eulmr_93",
5
- "awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_1ykar_eulmr_1",
6
- "root": "awsui_root_1ykar_eulmr_124",
7
- "calendar-inner": "awsui_calendar-inner_1ykar_eulmr_141",
8
- "calendar-header": "awsui_calendar-header_1ykar_eulmr_144",
9
- "calendar-header-month": "awsui_calendar-header-month_1ykar_eulmr_149",
10
- "calendar-next-month-btn": "awsui_calendar-next-month-btn_1ykar_eulmr_155",
11
- "calendar-prev-month-btn": "awsui_calendar-prev-month-btn_1ykar_eulmr_158",
12
- "calendar-day-names": "awsui_calendar-day-names_1ykar_eulmr_161",
13
- "calendar-day-name": "awsui_calendar-day-name_1ykar_eulmr_161",
14
- "calendar-dates": "awsui_calendar-dates_1ykar_eulmr_176",
15
- "calendar-week": "awsui_calendar-week_1ykar_eulmr_179",
16
- "calendar-day": "awsui_calendar-day_1ykar_eulmr_161",
17
- "calendar-day-in-last-week": "awsui_calendar-day-in-last-week_1ykar_eulmr_197",
18
- "calendar-day-focusable": "awsui_calendar-day-focusable_1ykar_eulmr_200",
19
- "calendar-day-enabled": "awsui_calendar-day-enabled_1ykar_eulmr_203",
20
- "calendar-day-current-month": "awsui_calendar-day-current-month_1ykar_eulmr_210",
21
- "calendar-day-selected": "awsui_calendar-day-selected_1ykar_eulmr_217",
22
- "calendar-day-today": "awsui_calendar-day-today_1ykar_eulmr_220",
23
- "day-inner": "awsui_day-inner_1ykar_eulmr_234"
4
+ "calendar": "awsui_calendar_1ykar_in88p_93",
5
+ "awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_1ykar_in88p_1",
6
+ "root": "awsui_root_1ykar_in88p_124",
7
+ "calendar-inner": "awsui_calendar-inner_1ykar_in88p_141",
8
+ "calendar-header": "awsui_calendar-header_1ykar_in88p_144",
9
+ "calendar-header-month": "awsui_calendar-header-month_1ykar_in88p_149",
10
+ "calendar-next-month-btn": "awsui_calendar-next-month-btn_1ykar_in88p_155",
11
+ "calendar-prev-month-btn": "awsui_calendar-prev-month-btn_1ykar_in88p_158",
12
+ "calendar-grid": "awsui_calendar-grid_1ykar_in88p_161",
13
+ "calendar-grid-cell": "awsui_calendar-grid-cell_1ykar_in88p_165",
14
+ "calendar-day-header": "awsui_calendar-day-header_1ykar_in88p_171",
15
+ "calendar-day": "awsui_calendar-day_1ykar_in88p_171",
16
+ "calendar-day-enabled": "awsui_calendar-day-enabled_1ykar_in88p_188",
17
+ "calendar-day-current-month": "awsui_calendar-day-current-month_1ykar_in88p_195",
18
+ "calendar-day-selected": "awsui_calendar-day-selected_1ykar_in88p_202",
19
+ "calendar-day-today": "awsui_calendar-day-today_1ykar_in88p_205",
20
+ "day-inner": "awsui_day-inner_1ykar_in88p_219",
21
+ "calendar-week": "awsui_calendar-week_1ykar_in88p_283"
24
22
  };
25
23
 
@@ -90,11 +90,11 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
90
90
  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
91
91
  SPDX-License-Identifier: Apache-2.0
92
92
  */
93
- .awsui_calendar_1ykar_eulmr_93:not(#\9) {
94
- animation: awsui_awsui-motion-fade-in-0_1ykar_eulmr_1 var(--motion-duration-show-quick-tyaalm, 135ms) var(--motion-easing-show-quick-1fcgbv, ease-out);
93
+ .awsui_calendar_1ykar_in88p_93:not(#\9) {
94
+ animation: awsui_awsui-motion-fade-in-0_1ykar_in88p_1 var(--motion-duration-show-quick-tyaalm, 135ms) var(--motion-easing-show-quick-1fcgbv, ease-out);
95
95
  animation-fill-mode: both;
96
96
  }
97
- @keyframes awsui_awsui-motion-fade-in-0_1ykar_eulmr_1 {
97
+ @keyframes awsui_awsui-motion-fade-in-0_1ykar_in88p_1 {
98
98
  from {
99
99
  opacity: 0;
100
100
  }
@@ -103,12 +103,12 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
103
103
  }
104
104
  }
105
105
  @media (prefers-reduced-motion: reduce) {
106
- .awsui_calendar_1ykar_eulmr_93:not(#\9) {
106
+ .awsui_calendar_1ykar_in88p_93:not(#\9) {
107
107
  animation: none;
108
108
  transition: none;
109
109
  }
110
110
  }
111
- .awsui-motion-disabled .awsui_calendar_1ykar_eulmr_93:not(#\9), .awsui-mode-entering .awsui_calendar_1ykar_eulmr_93:not(#\9) {
111
+ .awsui-motion-disabled .awsui_calendar_1ykar_in88p_93:not(#\9), .awsui-mode-entering .awsui_calendar_1ykar_in88p_93:not(#\9) {
112
112
  animation: none;
113
113
  transition: none;
114
114
  }
@@ -121,11 +121,11 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
121
121
  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
122
122
  SPDX-License-Identifier: Apache-2.0
123
123
  */
124
- .awsui_root_1ykar_eulmr_124:not(#\9) {
124
+ .awsui_root_1ykar_in88p_124:not(#\9) {
125
125
  /* used in test-utils */
126
126
  }
127
127
 
128
- .awsui_calendar_1ykar_eulmr_93:not(#\9) {
128
+ .awsui_calendar_1ykar_in88p_93:not(#\9) {
129
129
  display: block;
130
130
  width: var(--size-calendar-grid-width-lxsx0p, 238px);
131
131
  overflow: auto;
@@ -164,90 +164,75 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
164
164
  font-weight: 400;
165
165
  font-family: var(--font-family-base-qnistn, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
166
166
  }
167
- .awsui_calendar-inner_1ykar_eulmr_141:not(#\9) {
167
+ .awsui_calendar-inner_1ykar_in88p_141:not(#\9) {
168
168
  margin: var(--space-xs-rsr2qu, 8px);
169
169
  }
170
- .awsui_calendar-header_1ykar_eulmr_144:not(#\9) {
170
+ .awsui_calendar-header_1ykar_in88p_144:not(#\9) {
171
171
  display: flex;
172
172
  justify-content: space-between;
173
173
  align-items: center;
174
174
  }
175
- .awsui_calendar-header-month_1ykar_eulmr_149:not(#\9) {
175
+ .awsui_calendar-header-month_1ykar_in88p_149:not(#\9) {
176
176
  font-size: var(--font-body-m-size-sregvd, 14px);
177
177
  line-height: var(--font-body-m-line-height-i7xxvv, 22px);
178
178
  font-weight: 700;
179
179
  color: var(--color-text-dropdown-item-default-7tg9p2, #000716);
180
180
  }
181
- .awsui_calendar-next-month-btn_1ykar_eulmr_155:not(#\9) {
181
+ .awsui_calendar-next-month-btn_1ykar_in88p_155:not(#\9) {
182
182
  /* used for identifying element */
183
183
  }
184
- .awsui_calendar-prev-month-btn_1ykar_eulmr_158:not(#\9) {
184
+ .awsui_calendar-prev-month-btn_1ykar_in88p_158:not(#\9) {
185
185
  /* used for identifying element */
186
186
  }
187
- .awsui_calendar-day-names_1ykar_eulmr_161:not(#\9) {
188
- display: flex;
189
- justify-content: stretch;
187
+ .awsui_calendar-grid_1ykar_in88p_161:not(#\9) {
188
+ width: 100%;
189
+ border-spacing: 0;
190
190
  }
191
- .awsui_calendar-day-name_1ykar_eulmr_161:not(#\9) {
192
- flex: 1 1 0%;
193
- width: 0;
191
+ .awsui_calendar-grid-cell_1ykar_in88p_165:not(#\9) {
192
+ width: 14.2857142857%;
194
193
  word-break: break-word;
195
194
  text-align: center;
195
+ font-weight: unset;
196
+ }
197
+ .awsui_calendar-day-header_1ykar_in88p_171:not(#\9) {
196
198
  padding: var(--space-s-hv8c1d, 12px) 0 var(--space-xxs-ynfts5, 4px);
197
199
  color: var(--color-text-calendar-month-elf7e9, #5f6b7a);
198
200
  font-size: var(--font-body-s-size-ukw2p9, 12px);
199
201
  line-height: var(--font-body-s-line-height-kdsbrl, 16px);
200
202
  letter-spacing: var(--font-body-s-letter-spacing-cy0oxj, 0.005em);
201
203
  }
202
- .awsui_calendar-dates_1ykar_eulmr_176:not(#\9) {
203
- border: 1px solid var(--color-border-calendar-grid-sshunw, transparent);
204
- }
205
- .awsui_calendar-week_1ykar_eulmr_179:not(#\9) {
206
- display: flex;
207
- justify-content: stretch;
208
- }
209
- .awsui_calendar-day_1ykar_eulmr_161:not(#\9) {
210
- flex: 1 1 0%;
211
- width: 0;
212
- word-break: break-word;
213
- text-align: center;
204
+ .awsui_calendar-day_1ykar_in88p_171:not(#\9) {
214
205
  border-bottom: 1px solid var(--color-border-calendar-grid-sshunw, transparent);
215
206
  border-right: 1px solid var(--color-border-calendar-grid-sshunw, transparent);
216
207
  padding: var(--space-xxs-ynfts5, 4px) 0;
217
208
  color: var(--color-text-dropdown-item-disabled-varol7, #9ba7b6);
218
209
  position: relative;
219
210
  }
220
- .awsui_calendar-day_1ykar_eulmr_161:not(#\9):last-child {
221
- border-right: none;
222
- }
223
- .awsui_calendar-day-in-last-week_1ykar_eulmr_197:not(#\9) {
224
- border-bottom: none;
211
+ .awsui_calendar-day_1ykar_in88p_171:not(#\9):first-child {
212
+ border-left: 1px solid var(--color-border-calendar-grid-sshunw, transparent);
225
213
  }
226
- .awsui_calendar-day-focusable_1ykar_eulmr_200:not(#\9) {
227
- /* used for identifying element */
228
- }
229
- .awsui_calendar-day-enabled_1ykar_eulmr_203:not(#\9) {
214
+ .awsui_calendar-day-enabled_1ykar_in88p_188:not(#\9) {
230
215
  cursor: pointer;
231
216
  color: var(--color-text-dropdown-item-secondary-0me7js, #5f6b7a);
232
217
  }
233
- .awsui_calendar-day-enabled_1ykar_eulmr_203:not(#\9)::after {
218
+ .awsui_calendar-day-enabled_1ykar_in88p_188:not(#\9)::after {
234
219
  border-radius: var(--border-radius-item-u2ibpi, 8px);
235
220
  }
236
- .awsui_calendar-day-enabled_1ykar_eulmr_203.awsui_calendar-day-current-month_1ykar_eulmr_210:not(#\9) {
221
+ .awsui_calendar-day-enabled_1ykar_in88p_188.awsui_calendar-day-current-month_1ykar_in88p_195:not(#\9) {
237
222
  color: var(--color-text-dropdown-item-default-7tg9p2, #000716);
238
223
  }
239
- .awsui_calendar-day-enabled_1ykar_eulmr_203.awsui_calendar-day-current-month_1ykar_eulmr_210:not(#\9):hover {
224
+ .awsui_calendar-day-enabled_1ykar_in88p_188.awsui_calendar-day-current-month_1ykar_in88p_195:not(#\9):hover {
240
225
  color: var(--color-text-calendar-day-hover-graajh, #000716);
241
226
  background-color: var(--color-background-dropdown-item-hover-mqsxkv, #f4f4f4);
242
227
  }
243
- .awsui_calendar-day-enabled_1ykar_eulmr_203.awsui_calendar-day-current-month_1ykar_eulmr_210:not(#\9):hover:not(.awsui_calendar-day-selected_1ykar_eulmr_217)::after {
228
+ .awsui_calendar-day-enabled_1ykar_in88p_188.awsui_calendar-day-current-month_1ykar_in88p_195:not(#\9):hover:not(.awsui_calendar-day-selected_1ykar_in88p_202)::after {
244
229
  border: var(--border-item-width-qbbbsa, 2px) solid var(--color-border-dropdown-item-hover-tyzq9m, #7d8998);
245
230
  }
246
- .awsui_calendar-day-today_1ykar_eulmr_220:not(#\9) {
231
+ .awsui_calendar-day-today_1ykar_in88p_205:not(#\9) {
247
232
  background-color: var(--color-background-calendar-today-762czq, #f4f4f4);
248
233
  border-radius: var(--border-radius-item-u2ibpi, 8px);
249
234
  }
250
- .awsui_calendar-day_1ykar_eulmr_161:not(#\9)::after {
235
+ .awsui_calendar-day_1ykar_in88p_171:not(#\9)::after {
251
236
  content: "";
252
237
  position: absolute;
253
238
  z-index: 1;
@@ -257,21 +242,21 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
257
242
  right: calc(-1 * var(--border-item-width-qbbbsa, 2px));
258
243
  background-color: transparent;
259
244
  }
260
- .awsui_calendar-day_1ykar_eulmr_161 > .awsui_day-inner_1ykar_eulmr_234:not(#\9) {
245
+ .awsui_calendar-day_1ykar_in88p_171 > .awsui_day-inner_1ykar_in88p_219:not(#\9) {
261
246
  position: relative;
262
247
  z-index: 1;
263
248
  }
264
- .awsui_calendar-day_1ykar_eulmr_161:not(#\9):focus {
249
+ .awsui_calendar-day_1ykar_in88p_171:not(#\9):focus {
265
250
  outline: none;
266
251
  }
267
- .awsui_calendar-day_1ykar_eulmr_161:not(#\9):focus[data-awsui-focus-visible=true]:focus {
252
+ .awsui_calendar-day_1ykar_in88p_171:not(#\9):focus[data-awsui-focus-visible=true]:focus {
268
253
  position: relative;
269
254
  }
270
- .awsui_calendar-day_1ykar_eulmr_161:not(#\9):focus[data-awsui-focus-visible=true]:focus {
255
+ .awsui_calendar-day_1ykar_in88p_171:not(#\9):focus[data-awsui-focus-visible=true]:focus {
271
256
  outline: 2px dotted transparent;
272
257
  outline-offset: calc(var(--space-calendar-grid-focus-outline-gutter-v3dwvl, -5px) - 1px);
273
258
  }
274
- .awsui_calendar-day_1ykar_eulmr_161:not(#\9):focus[data-awsui-focus-visible=true]:focus::before {
259
+ .awsui_calendar-day_1ykar_in88p_171:not(#\9):focus[data-awsui-focus-visible=true]:focus::before {
275
260
  content: " ";
276
261
  display: block;
277
262
  position: absolute;
@@ -282,22 +267,22 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
282
267
  border-radius: var(--border-radius-calendar-day-focus-ring-a8mlqd, 3px);
283
268
  box-shadow: 0 0 0 2px var(--color-border-item-focused-ap3b6s, #0972d3);
284
269
  }
285
- .awsui_calendar-day_1ykar_eulmr_161:not(#\9):focus[data-awsui-focus-visible=true]:focus::before {
270
+ .awsui_calendar-day_1ykar_in88p_171:not(#\9):focus[data-awsui-focus-visible=true]:focus::before {
286
271
  z-index: 2;
287
272
  }
288
- .awsui_calendar-day-selected_1ykar_eulmr_217:not(#\9) {
273
+ .awsui_calendar-day-selected_1ykar_in88p_202:not(#\9) {
289
274
  border-color: transparent;
290
275
  position: relative;
291
276
  z-index: 2;
292
277
  }
293
- .awsui_calendar-day-selected_1ykar_eulmr_217:not(#\9):focus[data-awsui-focus-visible=true]:focus {
278
+ .awsui_calendar-day-selected_1ykar_in88p_202:not(#\9):focus[data-awsui-focus-visible=true]:focus {
294
279
  position: relative;
295
280
  }
296
- .awsui_calendar-day-selected_1ykar_eulmr_217:not(#\9):focus[data-awsui-focus-visible=true]:focus {
281
+ .awsui_calendar-day-selected_1ykar_in88p_202:not(#\9):focus[data-awsui-focus-visible=true]:focus {
297
282
  outline: 2px dotted transparent;
298
283
  outline-offset: calc(var(--space-calendar-grid-focus-outline-gutter-v3dwvl, -5px) - 1px);
299
284
  }
300
- .awsui_calendar-day-selected_1ykar_eulmr_217:not(#\9):focus[data-awsui-focus-visible=true]:focus::before {
285
+ .awsui_calendar-day-selected_1ykar_in88p_202:not(#\9):focus[data-awsui-focus-visible=true]:focus::before {
301
286
  content: " ";
302
287
  display: block;
303
288
  position: absolute;
@@ -308,16 +293,19 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
308
293
  border-radius: var(--border-radius-calendar-day-focus-ring-a8mlqd, 3px);
309
294
  box-shadow: 0 0 0 2px var(--color-border-calendar-grid-selected-focus-ring-cxqa0s, #fbfbfb);
310
295
  }
311
- .awsui_calendar-day-selected_1ykar_eulmr_217:not(#\9):focus[data-awsui-focus-visible=true]:focus::before {
296
+ .awsui_calendar-day-selected_1ykar_in88p_202:not(#\9):focus[data-awsui-focus-visible=true]:focus::before {
312
297
  z-index: 2;
313
298
  }
314
- .awsui_calendar-day-selected_1ykar_eulmr_217:not(#\9)::after {
299
+ .awsui_calendar-day-selected_1ykar_in88p_202:not(#\9)::after {
315
300
  background-color: var(--color-background-control-checked-9admlu, #0972d3);
316
301
  border: var(--border-item-width-qbbbsa, 2px) solid var(--color-background-control-checked-9admlu, #0972d3);
317
302
  border-radius: var(--border-radius-item-u2ibpi, 8px);
318
303
  }
319
- .awsui_calendar-day-selected_1ykar_eulmr_217 > .awsui_day-inner_1ykar_eulmr_234:not(#\9) {
304
+ .awsui_calendar-day-selected_1ykar_in88p_202 > .awsui_day-inner_1ykar_in88p_219:not(#\9) {
320
305
  z-index: 2;
321
306
  color: var(--color-background-control-default-4pa05r, #ffffff);
322
307
  position: relative;
308
+ }
309
+ .awsui_calendar-week_1ykar_in88p_283:not(#\9):first-child > .awsui_calendar-day_1ykar_in88p_171 {
310
+ border-top: 1px solid var(--color-border-calendar-grid-sshunw, transparent);
323
311
  }
@@ -2,25 +2,23 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "calendar": "awsui_calendar_1ykar_eulmr_93",
6
- "awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_1ykar_eulmr_1",
7
- "root": "awsui_root_1ykar_eulmr_124",
8
- "calendar-inner": "awsui_calendar-inner_1ykar_eulmr_141",
9
- "calendar-header": "awsui_calendar-header_1ykar_eulmr_144",
10
- "calendar-header-month": "awsui_calendar-header-month_1ykar_eulmr_149",
11
- "calendar-next-month-btn": "awsui_calendar-next-month-btn_1ykar_eulmr_155",
12
- "calendar-prev-month-btn": "awsui_calendar-prev-month-btn_1ykar_eulmr_158",
13
- "calendar-day-names": "awsui_calendar-day-names_1ykar_eulmr_161",
14
- "calendar-day-name": "awsui_calendar-day-name_1ykar_eulmr_161",
15
- "calendar-dates": "awsui_calendar-dates_1ykar_eulmr_176",
16
- "calendar-week": "awsui_calendar-week_1ykar_eulmr_179",
17
- "calendar-day": "awsui_calendar-day_1ykar_eulmr_161",
18
- "calendar-day-in-last-week": "awsui_calendar-day-in-last-week_1ykar_eulmr_197",
19
- "calendar-day-focusable": "awsui_calendar-day-focusable_1ykar_eulmr_200",
20
- "calendar-day-enabled": "awsui_calendar-day-enabled_1ykar_eulmr_203",
21
- "calendar-day-current-month": "awsui_calendar-day-current-month_1ykar_eulmr_210",
22
- "calendar-day-selected": "awsui_calendar-day-selected_1ykar_eulmr_217",
23
- "calendar-day-today": "awsui_calendar-day-today_1ykar_eulmr_220",
24
- "day-inner": "awsui_day-inner_1ykar_eulmr_234"
5
+ "calendar": "awsui_calendar_1ykar_in88p_93",
6
+ "awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_1ykar_in88p_1",
7
+ "root": "awsui_root_1ykar_in88p_124",
8
+ "calendar-inner": "awsui_calendar-inner_1ykar_in88p_141",
9
+ "calendar-header": "awsui_calendar-header_1ykar_in88p_144",
10
+ "calendar-header-month": "awsui_calendar-header-month_1ykar_in88p_149",
11
+ "calendar-next-month-btn": "awsui_calendar-next-month-btn_1ykar_in88p_155",
12
+ "calendar-prev-month-btn": "awsui_calendar-prev-month-btn_1ykar_in88p_158",
13
+ "calendar-grid": "awsui_calendar-grid_1ykar_in88p_161",
14
+ "calendar-grid-cell": "awsui_calendar-grid-cell_1ykar_in88p_165",
15
+ "calendar-day-header": "awsui_calendar-day-header_1ykar_in88p_171",
16
+ "calendar-day": "awsui_calendar-day_1ykar_in88p_171",
17
+ "calendar-day-enabled": "awsui_calendar-day-enabled_1ykar_in88p_188",
18
+ "calendar-day-current-month": "awsui_calendar-day-current-month_1ykar_in88p_195",
19
+ "calendar-day-selected": "awsui_calendar-day-selected_1ykar_in88p_202",
20
+ "calendar-day-today": "awsui_calendar-day-today_1ykar_in88p_205",
21
+ "day-inner": "awsui_day-inner_1ykar_in88p_219",
22
+ "calendar-week": "awsui_calendar-week_1ykar_in88p_283"
25
23
  };
26
24
 
@@ -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;AAKvC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAKxD,MAAM,WAAW,SAAS;IACxB,QAA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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,cAAc,CAAC,CAAC;IAEhD,YAAY,EAAE,iBAAiB,CAAC;IAChC,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;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,EAEd,SAAS,GACV,EAAE,SAAS,eAiIX"}
@@ -1,13 +1,16 @@
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
4
  import React, { useMemo } from 'react';
4
5
  import styles from '../../styles.css.js';
5
- import GridDay from './day';
6
- import { isSameMonth, isAfter, isBefore, isSameDay, addWeeks, addDays } from 'date-fns';
6
+ import dayStyles from './styles.css.js';
7
+ import { isSameMonth, isAfter, isBefore, isSameDay, addWeeks, addDays, isLastDayOfMonth, getDaysInMonth, isToday, } from 'date-fns';
7
8
  import { getCalendarMonth } from 'mnth';
8
9
  import rotateDayIndexes from '../../../calendar/utils/rotate-day-indexes';
9
- import { renderDayName } from '../../../calendar/utils/intl';
10
+ import { getDateLabel, renderDayName } from '../../../calendar/utils/intl';
10
11
  import clsx from 'clsx';
12
+ import { formatDate } from '../../../internal/utils/date-time';
13
+ import useFocusVisible from '../../../internal/hooks/focus-visible/index.js';
11
14
  export function Grid(_a) {
12
15
  var baseDate = _a.baseDate, selectedStartDate = _a.selectedStartDate, selectedEndDate = _a.selectedEndDate, rangeStartDate = _a.rangeStartDate, rangeEndDate = _a.rangeEndDate, focusedDate = _a.focusedDate, focusedDateRef = _a.focusedDateRef, onSelectDate = _a.onSelectDate, onGridKeyDownHandler = _a.onGridKeyDownHandler, onFocusedDateChange = _a.onFocusedDateChange, isDateEnabled = _a.isDateEnabled, locale = _a.locale, startOfWeek = _a.startOfWeek, todayAriaLabel = _a.todayAriaLabel, className = _a.className;
13
16
  var baseDateTime = baseDate === null || baseDate === void 0 ? void 0 : baseDate.getTime();
@@ -15,10 +18,12 @@ export function Grid(_a) {
15
18
  var weeks = useMemo(function () { return getCalendarMonth(baseDate, { firstDayOfWeek: startOfWeek }); },
16
19
  // eslint-disable-next-line react-hooks/exhaustive-deps
17
20
  [baseDateTime, startOfWeek]);
21
+ var focusVisible = useFocusVisible();
18
22
  return (React.createElement("div", { className: clsx(styles.grid, className) },
19
- 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))); })),
23
+ React.createElement("div", { className: styles['calendar-day-names'] }, rotateDayIndexes(startOfWeek).map(function (dayIndex) { return (React.createElement("div", { key: dayIndex, className: styles['calendar-day-name'] }, renderDayName(locale, dayIndex))); })),
20
24
  React.createElement("div", { className: styles['calendar-dates'], onKeyDown: onGridKeyDownHandler }, weeks.map(function (week, weekIndex) {
21
- return (React.createElement("div", { key: "week-".concat(weekIndex), className: styles['calendar-week'] }, week.map(function (date, dateIndex) {
25
+ return (React.createElement("div", { key: weekIndex, className: styles['calendar-week'] }, week.map(function (date, dateIndex) {
26
+ var _a, _b, _c;
22
27
  var isStartDate = !!selectedStartDate && isSameDay(date, selectedStartDate);
23
28
  var isEndDate = !!selectedEndDate && isSameDay(date, selectedEndDate);
24
29
  var isSelected = isStartDate || isEndDate;
@@ -31,7 +36,57 @@ export function Grid(_a) {
31
36
  var onlyOneSelected = !!rangeStartDate && !!rangeEndDate
32
37
  ? isSameDay(rangeStartDate, rangeEndDate)
33
38
  : !selectedStartDate || !selectedEndDate;
34
- return (React.createElement(GridDay, { key: "date-".concat(weekIndex, "-").concat(dateIndex), locale: locale, baseDate: baseDate, isSelected: isSelected, isStartDate: isStartDate, isEndDate: isEndDate, onlyOneSelected: onlyOneSelected, isRangeStartDate: isRangeStartDate, isRangeEndDate: isRangeEndDate, date: date, isFocusedDate: isFocused, ref: isFocused ? focusedDateRef : undefined, todayAriaLabel: todayAriaLabel, onSelectDate: onSelectDate, onFocusDate: onFocusedDateChange, isInRange: dateIsInRange, isDateEnabled: isDateEnabled, isDateInFirstRow: weekIndex === 0, isDateInFirstColumn: dateIndex === 0, isDateInLastColumn: dateIndex === week.length - 1, isDateInSelectionStartWeek: !!inRangeStartWeek, isDateInSelectionEndWeek: !!inRangeEndWeek }));
39
+ var isEnabled = !isDateEnabled || isDateEnabled(date);
40
+ var isFocusable = isFocused && isEnabled;
41
+ var computedAttributes = {};
42
+ var baseClasses = (_a = {},
43
+ _a[dayStyles.day] = true,
44
+ _a[dayStyles['in-first-row']] = weekIndex === 0,
45
+ _a[dayStyles['in-first-column']] = dateIndex === 0,
46
+ _a);
47
+ if (!isSameMonth(date, baseDate)) {
48
+ return (React.createElement("div", { key: "".concat(weekIndex, ":").concat(dateIndex), className: clsx(baseClasses, (_b = {},
49
+ _b[dayStyles['in-previous-month']] = isBefore(date, baseDate),
50
+ _b[dayStyles['last-day-of-month']] = isLastDayOfMonth(date),
51
+ _b[dayStyles['in-next-month']] = isAfter(date, baseDate),
52
+ _b)), ref: isFocused ? focusedDateRef : undefined }));
53
+ }
54
+ if (isEnabled) {
55
+ computedAttributes.onClick = function () { return onSelectDate(date); };
56
+ computedAttributes.onFocus = function () { return onFocusedDateChange(date); };
57
+ }
58
+ // Can't be focused.
59
+ var tabIndex = undefined;
60
+ if (isFocusable && isEnabled) {
61
+ // Next focus target.
62
+ tabIndex = 0;
63
+ }
64
+ else if (isEnabled) {
65
+ // Can be focused programmatically.
66
+ tabIndex = -1;
67
+ }
68
+ // Screen-reader announcement for the focused day.
69
+ var dayAnnouncement = getDateLabel(locale, date);
70
+ if (isToday(date)) {
71
+ dayAnnouncement += '. ' + todayAriaLabel;
72
+ }
73
+ return (React.createElement("div", __assign({ key: "".concat(weekIndex, ":").concat(dateIndex), className: clsx(baseClasses, (_c = {},
74
+ _c[dayStyles['in-current-month']] = isSameMonth(date, baseDate),
75
+ _c[dayStyles.enabled] = isEnabled,
76
+ _c[dayStyles.selected] = isSelected,
77
+ _c[dayStyles['start-date']] = isStartDate,
78
+ _c[dayStyles['end-date']] = isEndDate,
79
+ _c[dayStyles['range-start-date']] = isRangeStartDate,
80
+ _c[dayStyles['range-end-date']] = isRangeEndDate,
81
+ _c[dayStyles['no-range']] = isSelected && onlyOneSelected,
82
+ _c[dayStyles['in-range']] = dateIsInRange,
83
+ _c[dayStyles['in-range-border-top']] = !!inRangeStartWeek || date.getDate() <= 7,
84
+ _c[dayStyles['in-range-border-bottom']] = !!inRangeEndWeek || date.getDate() > getDaysInMonth(date) - 7,
85
+ _c[dayStyles['in-range-border-left']] = dateIndex === 0 || date.getDate() === 1 || isRangeStartDate,
86
+ _c[dayStyles['in-range-border-right']] = dateIndex === week.length - 1 || isLastDayOfMonth(date) || isRangeEndDate,
87
+ _c[dayStyles.today] = isToday(date),
88
+ _c)), "aria-label": dayAnnouncement, "aria-pressed": isSelected || dateIsInRange, "aria-current": isToday(date) ? 'date' : undefined, "data-date": formatDate(date), role: "button", tabIndex: tabIndex }, computedAttributes, { ref: isFocused ? focusedDateRef : undefined }, focusVisible),
89
+ React.createElement("span", { className: dayStyles['day-inner'] }, date.getDate())));
35
90
  })));
36
91
  }))));
37
92
  }