@cloudscape-design/components 3.0.73 → 3.0.75

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 (152) hide show
  1. package/alert/interfaces.d.ts +5 -0
  2. package/alert/interfaces.d.ts.map +1 -1
  3. package/alert/interfaces.js.map +1 -1
  4. package/alert/internal.d.ts +1 -1
  5. package/alert/internal.d.ts.map +1 -1
  6. package/alert/internal.js +2 -2
  7. package/alert/internal.js.map +1 -1
  8. package/annotation-context/annotation/styles.css.js +24 -24
  9. package/annotation-context/annotation/styles.scoped.css +30 -30
  10. package/annotation-context/annotation/styles.selectors.js +24 -24
  11. package/app-layout/visual-refresh/styles.css.js +59 -59
  12. package/app-layout/visual-refresh/styles.scoped.css +218 -218
  13. package/app-layout/visual-refresh/styles.selectors.js +59 -59
  14. package/attribute-editor/interfaces.d.ts +7 -0
  15. package/attribute-editor/interfaces.d.ts.map +1 -1
  16. package/attribute-editor/interfaces.js.map +1 -1
  17. package/attribute-editor/internal.d.ts.map +1 -1
  18. package/attribute-editor/internal.js +2 -2
  19. package/attribute-editor/internal.js.map +1 -1
  20. package/attribute-editor/row.d.ts +2 -1
  21. package/attribute-editor/row.d.ts.map +1 -1
  22. package/attribute-editor/row.js +5 -10
  23. package/attribute-editor/row.js.map +1 -1
  24. package/calendar/grid/index.d.ts +15 -3
  25. package/calendar/grid/index.d.ts.map +1 -1
  26. package/calendar/grid/index.js +19 -17
  27. package/calendar/grid/index.js.map +1 -1
  28. package/calendar/internal.d.ts.map +1 -1
  29. package/calendar/internal.js +5 -17
  30. package/calendar/internal.js.map +1 -1
  31. package/calendar/utils/intl.d.ts +2 -3
  32. package/calendar/utils/intl.d.ts.map +1 -1
  33. package/calendar/utils/intl.js +6 -5
  34. package/calendar/utils/intl.js.map +1 -1
  35. package/calendar/utils/navigation.d.ts +6 -0
  36. package/calendar/utils/navigation.d.ts.map +1 -0
  37. package/calendar/utils/navigation.js +38 -0
  38. package/calendar/utils/navigation.js.map +1 -0
  39. package/date-picker/index.d.ts.map +1 -1
  40. package/date-picker/index.js +2 -1
  41. package/date-picker/index.js.map +1 -1
  42. package/date-picker/styles.css.js +6 -7
  43. package/date-picker/styles.scoped.css +7 -13
  44. package/date-picker/styles.selectors.js +6 -7
  45. package/date-range-picker/calendar/grids/grid.d.ts +1 -1
  46. package/date-range-picker/calendar/grids/grid.d.ts.map +1 -1
  47. package/date-range-picker/calendar/grids/grid.js +36 -35
  48. package/date-range-picker/calendar/grids/grid.js.map +1 -1
  49. package/date-range-picker/calendar/grids/index.d.ts +1 -3
  50. package/date-range-picker/calendar/grids/index.d.ts.map +1 -1
  51. package/date-range-picker/calendar/grids/index.js +10 -11
  52. package/date-range-picker/calendar/grids/index.js.map +1 -1
  53. package/date-range-picker/calendar/grids/styles.css.js +25 -21
  54. package/date-range-picker/calendar/grids/styles.scoped.css +60 -40
  55. package/date-range-picker/calendar/grids/styles.selectors.js +25 -21
  56. package/date-range-picker/calendar/header/index.d.ts +2 -2
  57. package/date-range-picker/calendar/header/index.d.ts.map +1 -1
  58. package/date-range-picker/calendar/header/index.js +13 -9
  59. package/date-range-picker/calendar/header/index.js.map +1 -1
  60. package/date-range-picker/calendar/index.d.ts.map +1 -1
  61. package/date-range-picker/calendar/index.js +4 -6
  62. package/date-range-picker/calendar/index.js.map +1 -1
  63. package/date-range-picker/dropdown.js +1 -1
  64. package/date-range-picker/dropdown.js.map +1 -1
  65. package/date-range-picker/interfaces.d.ts +4 -0
  66. package/date-range-picker/interfaces.d.ts.map +1 -1
  67. package/date-range-picker/interfaces.js.map +1 -1
  68. package/date-range-picker/styles.css.js +37 -41
  69. package/date-range-picker/styles.scoped.css +45 -72
  70. package/date-range-picker/styles.selectors.js +37 -41
  71. package/flashbar/index.d.ts.map +1 -1
  72. package/flashbar/index.js +105 -34
  73. package/flashbar/index.js.map +1 -1
  74. package/flashbar/styles.css.js +29 -22
  75. package/flashbar/styles.scoped.css +208 -86
  76. package/flashbar/styles.selectors.js +29 -22
  77. package/form/interfaces.d.ts +5 -0
  78. package/form/interfaces.d.ts.map +1 -1
  79. package/form/interfaces.js.map +1 -1
  80. package/form/internal.d.ts +1 -1
  81. package/form/internal.d.ts.map +1 -1
  82. package/form/internal.js +10 -5
  83. package/form/internal.js.map +1 -1
  84. package/input/internal.d.ts +2 -1
  85. package/input/internal.d.ts.map +1 -1
  86. package/input/internal.js +4 -0
  87. package/input/internal.js.map +1 -1
  88. package/input/utils.js +1 -1
  89. package/input/utils.js.map +1 -1
  90. package/internal/base-component/styles.scoped.css +4 -4
  91. package/internal/components/autosuggest-input/index.js +1 -1
  92. package/internal/components/autosuggest-input/index.js.map +1 -1
  93. package/internal/components/live-region/index.d.ts +3 -2
  94. package/internal/components/live-region/index.d.ts.map +1 -1
  95. package/internal/components/live-region/index.js +5 -2
  96. package/internal/components/live-region/index.js.map +1 -1
  97. package/internal/components/live-region/styles.css.js +1 -1
  98. package/internal/components/live-region/styles.scoped.css +2 -92
  99. package/internal/components/live-region/styles.selectors.js +1 -1
  100. package/internal/components/screenreader-only/index.d.ts +22 -0
  101. package/internal/components/screenreader-only/index.d.ts.map +1 -0
  102. package/internal/components/screenreader-only/index.js +24 -0
  103. package/internal/components/screenreader-only/index.js.map +1 -0
  104. package/internal/components/screenreader-only/styles.css.js +6 -0
  105. package/internal/components/screenreader-only/styles.scoped.css +97 -0
  106. package/internal/components/screenreader-only/styles.selectors.js +7 -0
  107. package/internal/components/visual-context/index.d.ts +7 -0
  108. package/internal/components/visual-context/index.d.ts.map +1 -1
  109. package/internal/components/visual-context/index.js +10 -1
  110. package/internal/components/visual-context/index.js.map +1 -1
  111. package/internal/environment.js +1 -1
  112. package/internal/generated/custom-css-properties/index.d.ts.map +1 -1
  113. package/internal/generated/custom-css-properties/index.js +26 -24
  114. package/internal/generated/custom-css-properties/index.js.map +1 -1
  115. package/internal/generated/styles/tokens.js +2 -2
  116. package/internal/generated/theming/index.cjs +3 -3
  117. package/internal/generated/theming/index.js +3 -3
  118. package/package.json +1 -1
  119. package/select/parts/filter.js +1 -1
  120. package/select/parts/filter.js.map +1 -1
  121. package/tag-editor/index.d.ts.map +1 -1
  122. package/tag-editor/index.js +1 -1
  123. package/tag-editor/index.js.map +1 -1
  124. package/test-utils/dom/date-range-picker/index.js +1 -1
  125. package/test-utils/dom/date-range-picker/index.js.map +1 -1
  126. package/test-utils/selectors/date-range-picker/index.js +1 -1
  127. package/test-utils/selectors/date-range-picker/index.js.map +1 -1
  128. package/test-utils/tsconfig.tsbuildinfo +1 -1
  129. package/tutorial-panel/interfaces.d.ts +2 -1
  130. package/tutorial-panel/interfaces.d.ts.map +1 -1
  131. package/tutorial-panel/interfaces.js.map +1 -1
  132. package/wizard/interfaces.d.ts +3 -0
  133. package/wizard/interfaces.d.ts.map +1 -1
  134. package/wizard/interfaces.js.map +1 -1
  135. package/wizard/wizard-form.d.ts.map +1 -1
  136. package/wizard/wizard-form.js +1 -1
  137. package/wizard/wizard-form.js.map +1 -1
  138. package/wizard/wizard-navigation.d.ts.map +1 -1
  139. package/wizard/wizard-navigation.js +1 -1
  140. package/wizard/wizard-navigation.js.map +1 -1
  141. package/calendar/utils/move-focus-handler.d.ts +0 -7
  142. package/calendar/utils/move-focus-handler.d.ts.map +0 -1
  143. package/calendar/utils/move-focus-handler.js +0 -24
  144. package/calendar/utils/move-focus-handler.js.map +0 -1
  145. package/calendar/utils/rotate-day-indexes.d.ts +0 -3
  146. package/calendar/utils/rotate-day-indexes.d.ts.map +0 -1
  147. package/calendar/utils/rotate-day-indexes.js +0 -11
  148. package/calendar/utils/rotate-day-indexes.js.map +0 -1
  149. package/date-range-picker/calendar/get-base-date.d.ts +0 -3
  150. package/date-range-picker/calendar/get-base-date.d.ts.map +0 -1
  151. package/date-range-picker/calendar/get-base-date.js +0 -10
  152. package/date-range-picker/calendar/get-base-date.js.map +0 -1
@@ -2,11 +2,10 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { __assign, __rest } from "tslib";
4
4
  import React, { useEffect, useRef, useState } from 'react';
5
- import { addDays, addMonths, getDaysInMonth, isSameMonth, startOfMonth } from 'date-fns';
5
+ import { addMonths, isSameMonth } from 'date-fns';
6
6
  import styles from './styles.css.js';
7
7
  import CalendarHeader from './header';
8
8
  import Grid from './grid';
9
- import moveFocusHandler from './utils/move-focus-handler';
10
9
  import { memoizedDate } from './utils/memoized-date.js';
11
10
  import { normalizeLocale, normalizeStartOfWeek } from './utils/locales.js';
12
11
  import { formatDate } from '../internal/utils/date-time';
@@ -14,6 +13,7 @@ import { fireNonCancelableEvent } from '../internal/events/index.js';
14
13
  import checkControlled from '../internal/hooks/check-controlled/index.js';
15
14
  import clsx from 'clsx';
16
15
  import { getBaseProps } from '../internal/base-component';
16
+ import { getBaseDate } from './utils/navigation';
17
17
  export default function Calendar(_a) {
18
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"]);
19
19
  checkControlled('Calendar', 'value', value, 'onChange', onChange);
@@ -43,19 +43,7 @@ export default function Calendar(_a) {
43
43
  }
44
44
  return null;
45
45
  };
46
- // Get the first enabled date of the month. If no day is enabled in the given month, return the first day of the month.
47
- // This is needed because `baseDate` is used as the first focusable date, for example when navigating to the calendar area.
48
- var getBaseDate = function (date) {
49
- var startDate = startOfMonth(date);
50
- for (var i = 0; i < getDaysInMonth(date); i++) {
51
- var currentDate = addDays(startDate, i);
52
- if (isDateEnabled(currentDate)) {
53
- return currentDate;
54
- }
55
- }
56
- return startDate;
57
- };
58
- var baseDate = getBaseDate(displayedDate);
46
+ var baseDate = getBaseDate(displayedDate, isDateEnabled);
59
47
  var focusableDate = focusedDate || selectFocusedDate(memoizedValue, baseDate);
60
48
  var onHeaderChangeMonthHandler = function (isPreviousButtonClick) {
61
49
  setDisplayedDate(addMonths(baseDate, isPreviousButtonClick ? -1 : 1));
@@ -82,10 +70,10 @@ export default function Calendar(_a) {
82
70
  setFocusedDate(null);
83
71
  }
84
72
  };
85
- return (React.createElement("div", __assign({ ref: __internalRootRef, role: "application" }, baseProps, { className: clsx(styles.root, styles.calendar, baseProps.className) }),
73
+ return (React.createElement("div", __assign({ ref: __internalRootRef }, baseProps, { className: clsx(styles.root, styles.calendar, baseProps.className) }),
86
74
  React.createElement("div", { className: styles['calendar-inner'] },
87
75
  React.createElement(CalendarHeader, { baseDate: baseDate, locale: normalizedLocale, onChangeMonth: onHeaderChangeMonthHandler, previousMonthLabel: previousMonthAriaLabel, nextMonthLabel: nextMonthAriaLabel }),
88
76
  React.createElement("div", { onBlur: onGridBlur, ref: gridWrapperRef },
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 })))));
77
+ 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 })))));
90
78
  }
91
79
  //# sourceMappingURL=internal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/calendar/internal.tsx"],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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
+ {"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,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,cAAc,MAAM,UAAU,CAAC;AACtC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,eAAe,MAAM,6CAA6C,CAAC;AAC1E,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIjD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAWY;IAV3C,IAAA,KAAK,WAAA,EACL,cAAW,EAAX,MAAM,mBAAG,EAAE,KAAA,EACX,WAAW,iBAAA,EACX,qBAA0B,EAA1B,aAAa,mBAAG,cAAM,OAAA,IAAI,EAAJ,CAAI,KAAA,EA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C;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,sCAAK,GAAG,EAAE,iBAAiB,IAAM,SAAS,IAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC;QAC5G,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,GAC3B,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 { addMonths, isSameMonth } from 'date-fns';\nimport styles from './styles.css.js';\nimport CalendarHeader from './header';\nimport Grid from './grid';\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';\nimport { getBaseDate } from './utils/navigation';\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 const baseDate = getBaseDate(displayedDate, isDateEnabled);\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 ref={__internalRootRef} {...baseProps} className={clsx(styles.root, styles.calendar, baseProps.className)}>\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 />\n </div>\n </div>\n </div>\n );\n}\n"]}
@@ -1,7 +1,6 @@
1
- import { DayIndex } from '../internal';
2
1
  import { TimeInputProps } from '../../time-input/interfaces';
3
- export declare function renderDayName(locale: string, dayIndex: DayIndex): string;
2
+ export declare function renderDayName(locale: string, dayIndex: number, mode: 'short' | 'long'): string;
4
3
  export declare function renderMonthAndYear(locale: string, baseDate: Date): string;
5
- export declare function getDateLabel(locale: string, date: Date): string;
4
+ export declare function getDateLabel(locale: string, date: Date, mode?: 'full' | 'short'): string;
6
5
  export declare function renderTimeLabel(locale: string, date: Date, format?: TimeInputProps.Format): string;
7
6
  //# sourceMappingURL=intl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"intl.d.ts","sourceRoot":"","sources":["../../../../src/calendar/utils/intl.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAO7D,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAIxE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAG,MAAM,CAOzE;AAMD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAc/D;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,cAAc,CAAC,MAAM,GAAG,MAAM,CAUlG"}
1
+ {"version":3,"file":"intl.d.ts","sourceRoot":"","sources":["../../../../src/calendar/utils/intl.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAO7D,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAI9F;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAG,MAAM,CAOzE;AAMD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAE,MAAM,GAAG,OAAgB,GAAG,MAAM,CAchG;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,cAAc,CAAC,MAAM,GAAG,MAAM,CAUlG"}
@@ -4,10 +4,10 @@ function setDayIndex(date, dayIndex) {
4
4
  var diff = dayIndex - date.getDay();
5
5
  date.setDate(date.getDate() + diff);
6
6
  }
7
- export function renderDayName(locale, dayIndex) {
7
+ export function renderDayName(locale, dayIndex, mode) {
8
8
  var tempDate = new Date();
9
9
  setDayIndex(tempDate, dayIndex);
10
- return tempDate.toLocaleDateString(locale, { weekday: 'short' });
10
+ return tempDate.toLocaleDateString(locale, { weekday: mode });
11
11
  }
12
12
  export function renderMonthAndYear(locale, baseDate) {
13
13
  var result = baseDate.toLocaleDateString(locale, {
@@ -20,14 +20,15 @@ export function renderMonthAndYear(locale, baseDate) {
20
20
  `toLocaleDateString` is expensive (10+ ms) to calculate in IE11.
21
21
  */
22
22
  var dayLabelCache = new Map();
23
- export function getDateLabel(locale, date) {
24
- var cacheKey = locale + date.getTime();
23
+ export function getDateLabel(locale, date, mode) {
24
+ if (mode === void 0) { mode = 'full'; }
25
+ var cacheKey = locale + date.getTime() + mode;
25
26
  var cachedValue = dayLabelCache.get(cacheKey);
26
27
  if (cachedValue) {
27
28
  return cachedValue;
28
29
  }
29
30
  var value = date.toLocaleDateString(locale, {
30
- weekday: 'long',
31
+ weekday: mode === 'full' ? 'long' : undefined,
31
32
  month: 'long',
32
33
  day: 'numeric',
33
34
  year: 'numeric'
@@ -1 +1 @@
1
- {"version":3,"file":"intl.js","sourceRoot":"","sources":["../../../../src/calendar/utils/intl.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAKtC,SAAS,WAAW,CAAC,IAAU,EAAE,QAAkB;IACjD,IAAM,IAAI,GAAG,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IACtC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,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AG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;KAC/B;IACD,IAAI,MAAM,KAAK,OAAO,EAAE;QACtB,OAAO,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;KAClD;IACD,IAAM,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { DayIndex } from '../internal';\nimport { TimeInputProps } from '../../time-input/interfaces';\n\nfunction setDayIndex(date: Date, dayIndex: DayIndex): void {\n const diff = dayIndex - date.getDay();\n date.setDate(date.getDate() + diff);\n}\n\nexport function renderDayName(locale: string, dayIndex: DayIndex): string {\n const tempDate = new Date();\n setDayIndex(tempDate, dayIndex);\n return tempDate.toLocaleDateString(locale, { weekday: 'short' });\n}\n\nexport function renderMonthAndYear(locale: string, baseDate: Date): string {\n const result = baseDate.toLocaleDateString(locale, {\n year: 'numeric',\n month: 'long',\n });\n\n return result;\n}\n\n/*\n `toLocaleDateString` is expensive (10+ ms) to calculate in IE11.\n*/\nconst dayLabelCache = new Map<string, string>();\nexport function getDateLabel(locale: string, date: Date): string {\n const cacheKey = locale + date.getTime();\n const cachedValue = dayLabelCache.get(cacheKey);\n if (cachedValue) {\n return cachedValue;\n }\n const value = date.toLocaleDateString(locale, {\n weekday: 'long',\n month: 'long',\n day: 'numeric',\n year: 'numeric',\n });\n dayLabelCache.set(cacheKey, value);\n return value;\n}\n\nexport function renderTimeLabel(locale: string, date: Date, format?: TimeInputProps.Format): string {\n let options: Intl.DateTimeFormatOptions = {};\n if (format === 'hh') {\n options = { hour: '2-digit' };\n }\n if (format === 'hh:mm') {\n options = { hour: '2-digit', minute: '2-digit' };\n }\n const value = date.toLocaleTimeString(locale, options);\n return value;\n}\n"]}
1
+ {"version":3,"file":"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CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;QAC7C,KAAK,EAAE,MAAM;QACb,GAAG,EAAE,SAAS;QACd,IAAI,EAAE,SAAS;KAChB,CAAC,CAAC;IACH,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAc,EAAE,IAAU,EAAE,MAA8B;IACxF,IAAI,OAAO,GAA+B,EAAE,CAAC;IAC7C,IAAI,MAAM,KAAK,IAAI,EAAE;QACnB,OAAO,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;KAC/B;IACD,IAAI,MAAM,KAAK,OAAO,EAAE;QACtB,OAAO,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;KAClD;IACD,IAAM,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { TimeInputProps } from '../../time-input/interfaces';\n\nfunction setDayIndex(date: Date, dayIndex: number): void {\n const diff = dayIndex - date.getDay();\n date.setDate(date.getDate() + diff);\n}\n\nexport function renderDayName(locale: string, dayIndex: number, mode: 'short' | 'long'): string {\n const tempDate = new Date();\n setDayIndex(tempDate, dayIndex);\n return tempDate.toLocaleDateString(locale, { weekday: mode });\n}\n\nexport function renderMonthAndYear(locale: string, baseDate: Date): string {\n const result = baseDate.toLocaleDateString(locale, {\n year: 'numeric',\n month: 'long',\n });\n\n return result;\n}\n\n/*\n `toLocaleDateString` is expensive (10+ ms) to calculate in IE11.\n*/\nconst dayLabelCache = new Map<string, string>();\nexport function getDateLabel(locale: string, date: Date, mode: 'full' | 'short' = 'full'): string {\n const cacheKey = locale + date.getTime() + mode;\n const cachedValue = dayLabelCache.get(cacheKey);\n if (cachedValue) {\n return cachedValue;\n }\n const value = date.toLocaleDateString(locale, {\n weekday: mode === 'full' ? 'long' : undefined,\n month: 'long',\n day: 'numeric',\n year: 'numeric',\n });\n dayLabelCache.set(cacheKey, value);\n return value;\n}\n\nexport function renderTimeLabel(locale: string, date: Date, format?: TimeInputProps.Format): string {\n let options: Intl.DateTimeFormatOptions = {};\n if (format === 'hh') {\n options = { hour: '2-digit' };\n }\n if (format === 'hh:mm') {\n options = { hour: '2-digit', minute: '2-digit' };\n }\n const value = date.toLocaleTimeString(locale, options);\n return value;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ export declare function moveNextDay(startDate: Date, isDateEnabled: (date: Date) => boolean): Date;
2
+ export declare function movePrevDay(startDate: Date, isDateEnabled: (date: Date) => boolean): Date;
3
+ export declare function moveNextWeek(startDate: Date, isDateEnabled: (date: Date) => boolean): Date;
4
+ export declare function movePrevWeek(startDate: Date, isDateEnabled: (date: Date) => boolean): Date;
5
+ export declare function getBaseDate(date: Date, isDateEnabled: (date: Date) => boolean): Date;
6
+ //# sourceMappingURL=navigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../../src/calendar/utils/navigation.ts"],"names":[],"mappings":"AAIA,wBAAgB,WAAW,CAAC,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,GAAG,IAAI,CAEzF;AAED,wBAAgB,WAAW,CAAC,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,GAAG,IAAI,CAEzF;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,GAAG,IAAI,CAE1F;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,GAAG,IAAI,CAE1F;AAID,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,QAQ7E"}
@@ -0,0 +1,38 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { addDays, differenceInYears, isSameMonth, startOfMonth } from 'date-fns';
4
+ export function moveNextDay(startDate, isDateEnabled) {
5
+ return moveDate(startDate, isDateEnabled, 1);
6
+ }
7
+ export function movePrevDay(startDate, isDateEnabled) {
8
+ return moveDate(startDate, isDateEnabled, -1);
9
+ }
10
+ export function moveNextWeek(startDate, isDateEnabled) {
11
+ return moveDate(startDate, isDateEnabled, 7);
12
+ }
13
+ export function movePrevWeek(startDate, isDateEnabled) {
14
+ return moveDate(startDate, isDateEnabled, -7);
15
+ }
16
+ // Returns first enabled date of the month corresponding the given date.
17
+ // If all month's days are disabled the first day of the month is returned.
18
+ export function getBaseDate(date, isDateEnabled) {
19
+ var startDate = startOfMonth(date);
20
+ if (isDateEnabled(startDate)) {
21
+ return startDate;
22
+ }
23
+ var firstEnabledDate = moveDate(startDate, isDateEnabled, 1);
24
+ return isSameMonth(startDate, firstEnabledDate) ? firstEnabledDate : startDate;
25
+ }
26
+ // Iterates dates forwards or backwards until the next active date is found.
27
+ // If there is no active date in a year range the start date is returned.
28
+ function moveDate(startDate, isDateEnabled, step) {
29
+ var current = addDays(startDate, step);
30
+ while (!isDateEnabled(current)) {
31
+ if (Math.abs(differenceInYears(startDate, current)) > 1) {
32
+ return startDate;
33
+ }
34
+ current = addDays(current, step);
35
+ }
36
+ return current;
37
+ }
38
+ //# sourceMappingURL=navigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../../../src/calendar/utils/navigation.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAA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GAAG,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE;YACvD,OAAO,SAAS,CAAC;SAClB;QACD,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;KAClC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { addDays, differenceInYears, isSameMonth, startOfMonth } from 'date-fns';\n\nexport function moveNextDay(startDate: Date, isDateEnabled: (date: Date) => boolean): Date {\n return moveDate(startDate, isDateEnabled, 1);\n}\n\nexport function movePrevDay(startDate: Date, isDateEnabled: (date: Date) => boolean): Date {\n return moveDate(startDate, isDateEnabled, -1);\n}\n\nexport function moveNextWeek(startDate: Date, isDateEnabled: (date: Date) => boolean): Date {\n return moveDate(startDate, isDateEnabled, 7);\n}\n\nexport function movePrevWeek(startDate: Date, isDateEnabled: (date: Date) => boolean): Date {\n return moveDate(startDate, isDateEnabled, -7);\n}\n\n// Returns first enabled date of the month corresponding the given date.\n// If all month's days are disabled the first day of the month is returned.\nexport function getBaseDate(date: Date, isDateEnabled: (date: Date) => boolean) {\n const startDate = startOfMonth(date);\n if (isDateEnabled(startDate)) {\n return startDate;\n }\n\n const firstEnabledDate = moveDate(startDate, isDateEnabled, 1);\n return isSameMonth(startDate, firstEnabledDate) ? firstEnabledDate : startDate;\n}\n\n// Iterates dates forwards or backwards until the next active date is found.\n// If there is no active date in a year range the start date is returned.\nfunction moveDate(startDate: Date, isDateEnabled: (date: Date) => boolean, step: number): Date {\n let current = addDays(startDate, step);\n\n while (!isDateEnabled(current)) {\n if (Math.abs(differenceInYears(startDate, current)) > 1) {\n return startDate;\n }\n current = addDays(current, step);\n }\n\n return current;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-picker/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAuB/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,QAAA,MAAM,UAAU,6FA8Kf,CAAC;AAGF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-picker/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAwB/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,QAAA,MAAM,UAAU,6FA4Kf,CAAC;AAGF,eAAe,UAAU,CAAC"}
@@ -23,6 +23,7 @@ import { useUniqueId } from '../internal/hooks/use-unique-id';
23
23
  import { useMergeRefs } from '../internal/hooks/use-merge-refs';
24
24
  import FocusLock from '../internal/components/focus-lock';
25
25
  import useFocusVisible from '../internal/hooks/focus-visible/index.js';
26
+ import LiveRegion from '../internal/components/live-region';
26
27
  var DatePicker = React.forwardRef(function (_a, ref) {
27
28
  var _b = _a.locale, locale = _b === void 0 ? '' : _b, startOfWeek = _a.startOfWeek, isDateEnabled = _a.isDateEnabled, nextMonthAriaLabel = _a.nextMonthAriaLabel, previousMonthAriaLabel = _a.previousMonthAriaLabel, todayAriaLabel = _a.todayAriaLabel, _c = _a.placeholder, placeholder = _c === void 0 ? '' : _c, _d = _a.value, value = _d === void 0 ? '' : _d, _e = _a.readOnly, readOnly = _e === void 0 ? false : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, onBlur = _a.onBlur, _g = _a.autoFocus, autoFocus = _g === void 0 ? false : _g, onChange = _a.onChange, onFocus = _a.onFocus, name = _a.name, ariaLabel = _a.ariaLabel, ariaRequired = _a.ariaRequired, ariaLabelledby = _a.ariaLabelledby, ariaDescribedby = _a.ariaDescribedby, controlId = _a.controlId, invalid = _a.invalid, openCalendarAriaLabel = _a.openCalendarAriaLabel, expandToViewport = _a.expandToViewport, rest = __rest(_a, ["locale", "startOfWeek", "isDateEnabled", "nextMonthAriaLabel", "previousMonthAriaLabel", "todayAriaLabel", "placeholder", "value", "readOnly", "disabled", "onBlur", "autoFocus", "onChange", "onFocus", "name", "ariaLabel", "ariaRequired", "ariaLabelledby", "ariaDescribedby", "controlId", "invalid", "openCalendarAriaLabel", "expandToViewport"]);
28
29
  var __internalRootRef = useBaseComponent('DatePicker').__internalRootRef;
@@ -85,7 +86,7 @@ var DatePicker = React.forwardRef(function (_a, ref) {
85
86
  (_a = buttonRef === null || buttonRef === void 0 ? void 0 : buttonRef.current) === null || _a === void 0 ? void 0 : _a.focus();
86
87
  setIsDropDownOpen(false);
87
88
  }, locale: normalizedLocale, startOfWeek: startOfWeek, isDateEnabled: isDateEnabled, todayAriaLabel: todayAriaLabel, nextMonthAriaLabel: nextMonthAriaLabel, previousMonthAriaLabel: previousMonthAriaLabel }),
88
- React.createElement("div", { id: calendarDescriptionId, className: styles['screenreader-only'], "aria-live": "polite" }, renderMonthAndYear(normalizedLocale, baseDate))))))));
89
+ React.createElement(LiveRegion, { id: calendarDescriptionId }, renderMonthAndYear(normalizedLocale, baseDate))))))));
89
90
  });
90
91
  applyDisplayName(DatePicker, 'DatePicker');
91
92
  export default DatePicker;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/date-picker/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,gBAAgB,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC1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B,cAAc,IAAI,CACjB,oBAAC,SAAS,IAAC,SAAS,EAAE,IAAI;YACxB,wCACM,YAAY,IAChB,QAAQ,EAAE,CAAC,EACX,SAAS,EAAE,MAAM,CAAC,QAAQ,EAC1B,IAAI,EAAC,QAAQ,sBACK,qBAAqB,gBAC3B,SAAS,qBACJ,cAAc;gBAE/B,oBAAC,gBAAgB,IACf,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,UAAA,CAAC;;wBACT,sBAAsB,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;wBAC3C,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,0CAAE,KAAK,EAAE,CAAC;wBAC5B,iBAAiB,CAAC,KAAK,CAAC,CAAC;oBAC3B,CAAC,EACD,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,EAC9B,kBAAkB,EAAE,kBAAkB,EACtC,sBAAsB,EAAE,sBAAsB,GAC9C;gBACF,6BAAK,EAAE,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,CAAC,mBAAmB,CAAC,eAAY,QAAQ,IACvF,kBAAkB,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAC3C,CACF,CACI,CACb,CACQ,CACP,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AAC3C,eAAe,UAAU,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { Ref, useCallback, useRef, useState } from 'react';\nimport styles from './styles.css.js';\nimport { DatePickerProps } from './interfaces';\nimport InternalCalendar from '../calendar/internal';\nimport { normalizeLocale } from '../calendar/utils/locales';\nimport { getDateLabel, renderMonthAndYear } from '../calendar/utils/intl';\nimport { memoizedDate } from '../calendar/utils/memoized-date';\nimport { InputProps } from '../input/interfaces';\nimport { KeyCode } from '../internal/keycode';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport Dropdown from '../internal/components/dropdown';\nimport InternalDateInput from '../date-input/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name.js';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { useFocusTracker } from '../internal/hooks/use-focus-tracker.js';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { ButtonProps } from '../button/interfaces';\nimport { InternalButton } from '../button/internal';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport FocusLock from '../internal/components/focus-lock';\nimport useFocusVisible from '../internal/hooks/focus-visible/index.js';\n\nexport { DatePickerProps };\n\nconst DatePicker = React.forwardRef(\n (\n {\n locale = '',\n startOfWeek,\n isDateEnabled,\n nextMonthAriaLabel,\n previousMonthAriaLabel,\n todayAriaLabel,\n placeholder = '',\n value = '',\n readOnly = false,\n disabled = false,\n onBlur,\n autoFocus = false,\n onChange,\n onFocus,\n name,\n ariaLabel,\n ariaRequired,\n ariaLabelledby,\n ariaDescribedby,\n controlId,\n invalid,\n openCalendarAriaLabel,\n expandToViewport,\n ...rest\n }: DatePickerProps,\n ref: Ref<DatePickerProps.Ref>\n ) => {\n const { __internalRootRef } = useBaseComponent('DatePicker');\n checkControlled('DatePicker', 'value', value, 'onChange', onChange);\n\n const baseProps = getBaseProps(rest);\n const [isDropDownOpen, setIsDropDownOpen] = useState<boolean>(false);\n const normalizedLocale = normalizeLocale('DatePicker', locale);\n const focusVisible = useFocusVisible();\n\n const internalInputRef = useRef<HTMLInputElement>(null);\n const buttonRef = useRef<ButtonProps.Ref>(null);\n useForwardFocus(ref, internalInputRef);\n\n const rootRef = useRef<HTMLDivElement>(null);\n const dropdownId = useUniqueId('calender');\n const calendarDescriptionId = useUniqueId('calendar-description-');\n const mergedRef = useMergeRefs(rootRef, __internalRootRef);\n\n useFocusTracker({ rootRef, onBlur, onFocus, viewportId: expandToViewport ? dropdownId : '' });\n\n const onDropdownCloseHandler = useCallback(() => setIsDropDownOpen(false), [setIsDropDownOpen]);\n\n const onButtonClickHandler = () => {\n if (!isDropDownOpen) {\n setIsDropDownOpen(true);\n }\n };\n\n const onWrapperKeyDownHandler = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.keyCode === KeyCode.escape && isDropDownOpen) {\n buttonRef.current?.focus();\n setIsDropDownOpen(false);\n }\n };\n\n const onInputChangeHandler: InputProps['onChange'] = event => {\n fireNonCancelableEvent(onChange, { value: event.detail.value });\n };\n\n const onInputBlurHandler: InputProps['onBlur'] = () => {\n if (!isDropDownOpen) {\n setIsDropDownOpen(false);\n }\n };\n\n const memoizedValue = memoizedDate('value', value);\n const baseDate = memoizedValue || new Date();\n\n const DateInputElement = (\n <div className={styles['date-picker-trigger']}>\n <div className={styles['date-picker-input']}>\n <InternalDateInput\n name={name}\n invalid={invalid}\n controlId={controlId}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n ariaLabel={ariaLabel}\n ariaRequired={ariaRequired}\n value={value}\n disabled={disabled}\n readOnly={readOnly}\n onChange={onInputChangeHandler}\n onBlur={onInputBlurHandler}\n placeholder={placeholder}\n ref={internalInputRef}\n autoFocus={autoFocus}\n />\n </div>\n <div>\n <InternalButton\n iconName=\"calendar\"\n className={styles['open-calendar-button']}\n onClick={onButtonClickHandler}\n ref={buttonRef}\n ariaLabel={\n openCalendarAriaLabel &&\n openCalendarAriaLabel(value.length === 10 ? getDateLabel(normalizedLocale, memoizedValue!) : null)\n }\n disabled={disabled || readOnly}\n formAction=\"none\"\n />\n </div>\n </div>\n );\n\n baseProps.className = clsx(baseProps.className, styles.root, styles['date-picker-container']);\n\n if (readOnly || disabled) {\n return <div {...baseProps}>{DateInputElement}</div>;\n }\n\n const handleMouseDown = (event: React.MouseEvent) => {\n // prevent currently focused element from losing it\n event.preventDefault();\n };\n\n return (\n <div {...baseProps} ref={mergedRef} onKeyDown={onWrapperKeyDownHandler}>\n <Dropdown\n stretchWidth={true}\n stretchHeight={true}\n open={isDropDownOpen}\n onDropdownClose={onDropdownCloseHandler}\n onMouseDown={handleMouseDown}\n trigger={DateInputElement}\n expandToViewport={expandToViewport}\n scrollable={false}\n dropdownId={dropdownId}\n >\n {isDropDownOpen && (\n <FocusLock autoFocus={true}>\n <div\n {...focusVisible}\n tabIndex={0}\n className={styles.calendar}\n role=\"dialog\"\n aria-describedby={calendarDescriptionId}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n >\n <InternalCalendar\n value={value}\n onChange={e => {\n fireNonCancelableEvent(onChange, e.detail);\n buttonRef?.current?.focus();\n setIsDropDownOpen(false);\n }}\n locale={normalizedLocale}\n startOfWeek={startOfWeek}\n isDateEnabled={isDateEnabled}\n todayAriaLabel={todayAriaLabel}\n nextMonthAriaLabel={nextMonthAriaLabel}\n previousMonthAriaLabel={previousMonthAriaLabel}\n />\n <div id={calendarDescriptionId} className={styles['screenreader-only']} aria-live=\"polite\">\n {renderMonthAndYear(normalizedLocale, baseDate)}\n </div>\n </div>\n </FocusLock>\n )}\n </Dropdown>\n </div>\n );\n }\n);\n\napplyDisplayName(DatePicker, 'DatePicker');\nexport default DatePicker;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/date-picker/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAO,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,gBAAgB,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE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ACzB,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,KAAK,EACjB,UAAU,EAAE,UAAU,IAErB,cAAc,IAAI,CACjB,oBAAC,SAAS,IAAC,SAAS,EAAE,IAAI;YACxB,wCACM,YAAY,IAChB,QAAQ,EAAE,CAAC,EACX,SAAS,EAAE,MAAM,CAAC,QAAQ,EAC1B,IAAI,EAAC,QAAQ,sBACK,qBAAqB,gBAC3B,SAAS,qBACJ,cAAc;gBAE/B,oBAAC,gBAAgB,IACf,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,UAAA,CAAC;;wBACT,sBAAsB,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;wBAC3C,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,0CAAE,KAAK,EAAE,CAAC;wBAC5B,iBAAiB,CAAC,KAAK,CAAC,CAAC;oBAC3B,CAAC,EACD,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,EAC9B,kBAAkB,EAAE,kBAAkB,EACtC,sBAAsB,EAAE,sBAAsB,GAC9C;gBACF,oBAAC,UAAU,IAAC,EAAE,EAAE,qBAAqB,IAAG,kBAAkB,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAc,CAChG,CACI,CACb,CACQ,CACP,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AAC3C,eAAe,UAAU,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { Ref, useCallback, useRef, useState } from 'react';\nimport styles from './styles.css.js';\nimport { DatePickerProps } from './interfaces';\nimport InternalCalendar from '../calendar/internal';\nimport { normalizeLocale } from '../calendar/utils/locales';\nimport { getDateLabel, renderMonthAndYear } from '../calendar/utils/intl';\nimport { memoizedDate } from '../calendar/utils/memoized-date';\nimport { InputProps } from '../input/interfaces';\nimport { KeyCode } from '../internal/keycode';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport Dropdown from '../internal/components/dropdown';\nimport InternalDateInput from '../date-input/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name.js';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { useFocusTracker } from '../internal/hooks/use-focus-tracker.js';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport { ButtonProps } from '../button/interfaces';\nimport { InternalButton } from '../button/internal';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport FocusLock from '../internal/components/focus-lock';\nimport useFocusVisible from '../internal/hooks/focus-visible/index.js';\nimport LiveRegion from '../internal/components/live-region';\n\nexport { DatePickerProps };\n\nconst DatePicker = React.forwardRef(\n (\n {\n locale = '',\n startOfWeek,\n isDateEnabled,\n nextMonthAriaLabel,\n previousMonthAriaLabel,\n todayAriaLabel,\n placeholder = '',\n value = '',\n readOnly = false,\n disabled = false,\n onBlur,\n autoFocus = false,\n onChange,\n onFocus,\n name,\n ariaLabel,\n ariaRequired,\n ariaLabelledby,\n ariaDescribedby,\n controlId,\n invalid,\n openCalendarAriaLabel,\n expandToViewport,\n ...rest\n }: DatePickerProps,\n ref: Ref<DatePickerProps.Ref>\n ) => {\n const { __internalRootRef } = useBaseComponent('DatePicker');\n checkControlled('DatePicker', 'value', value, 'onChange', onChange);\n\n const baseProps = getBaseProps(rest);\n const [isDropDownOpen, setIsDropDownOpen] = useState<boolean>(false);\n const normalizedLocale = normalizeLocale('DatePicker', locale);\n const focusVisible = useFocusVisible();\n\n const internalInputRef = useRef<HTMLInputElement>(null);\n const buttonRef = useRef<ButtonProps.Ref>(null);\n useForwardFocus(ref, internalInputRef);\n\n const rootRef = useRef<HTMLDivElement>(null);\n const dropdownId = useUniqueId('calender');\n const calendarDescriptionId = useUniqueId('calendar-description-');\n const mergedRef = useMergeRefs(rootRef, __internalRootRef);\n\n useFocusTracker({ rootRef, onBlur, onFocus, viewportId: expandToViewport ? dropdownId : '' });\n\n const onDropdownCloseHandler = useCallback(() => setIsDropDownOpen(false), [setIsDropDownOpen]);\n\n const onButtonClickHandler = () => {\n if (!isDropDownOpen) {\n setIsDropDownOpen(true);\n }\n };\n\n const onWrapperKeyDownHandler = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.keyCode === KeyCode.escape && isDropDownOpen) {\n buttonRef.current?.focus();\n setIsDropDownOpen(false);\n }\n };\n\n const onInputChangeHandler: InputProps['onChange'] = event => {\n fireNonCancelableEvent(onChange, { value: event.detail.value });\n };\n\n const onInputBlurHandler: InputProps['onBlur'] = () => {\n if (!isDropDownOpen) {\n setIsDropDownOpen(false);\n }\n };\n\n const memoizedValue = memoizedDate('value', value);\n const baseDate = memoizedValue || new Date();\n\n const DateInputElement = (\n <div className={styles['date-picker-trigger']}>\n <div className={styles['date-picker-input']}>\n <InternalDateInput\n name={name}\n invalid={invalid}\n controlId={controlId}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n ariaLabel={ariaLabel}\n ariaRequired={ariaRequired}\n value={value}\n disabled={disabled}\n readOnly={readOnly}\n onChange={onInputChangeHandler}\n onBlur={onInputBlurHandler}\n placeholder={placeholder}\n ref={internalInputRef}\n autoFocus={autoFocus}\n />\n </div>\n <div>\n <InternalButton\n iconName=\"calendar\"\n className={styles['open-calendar-button']}\n onClick={onButtonClickHandler}\n ref={buttonRef}\n ariaLabel={\n openCalendarAriaLabel &&\n openCalendarAriaLabel(value.length === 10 ? getDateLabel(normalizedLocale, memoizedValue!) : null)\n }\n disabled={disabled || readOnly}\n formAction=\"none\"\n />\n </div>\n </div>\n );\n\n baseProps.className = clsx(baseProps.className, styles.root, styles['date-picker-container']);\n\n if (readOnly || disabled) {\n return <div {...baseProps}>{DateInputElement}</div>;\n }\n\n const handleMouseDown = (event: React.MouseEvent) => {\n // prevent currently focused element from losing it\n event.preventDefault();\n };\n\n return (\n <div {...baseProps} ref={mergedRef} onKeyDown={onWrapperKeyDownHandler}>\n <Dropdown\n stretchWidth={true}\n stretchHeight={true}\n open={isDropDownOpen}\n onDropdownClose={onDropdownCloseHandler}\n onMouseDown={handleMouseDown}\n trigger={DateInputElement}\n expandToViewport={expandToViewport}\n scrollable={false}\n dropdownId={dropdownId}\n >\n {isDropDownOpen && (\n <FocusLock autoFocus={true}>\n <div\n {...focusVisible}\n tabIndex={0}\n className={styles.calendar}\n role=\"dialog\"\n aria-describedby={calendarDescriptionId}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n >\n <InternalCalendar\n value={value}\n onChange={e => {\n fireNonCancelableEvent(onChange, e.detail);\n buttonRef?.current?.focus();\n setIsDropDownOpen(false);\n }}\n locale={normalizedLocale}\n startOfWeek={startOfWeek}\n isDateEnabled={isDateEnabled}\n todayAriaLabel={todayAriaLabel}\n nextMonthAriaLabel={nextMonthAriaLabel}\n previousMonthAriaLabel={previousMonthAriaLabel}\n />\n <LiveRegion id={calendarDescriptionId}>{renderMonthAndYear(normalizedLocale, baseDate)}</LiveRegion>\n </div>\n </FocusLock>\n )}\n </Dropdown>\n </div>\n );\n }\n);\n\napplyDisplayName(DatePicker, 'DatePicker');\nexport default DatePicker;\n"]}
@@ -1,12 +1,11 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "root": "awsui_root_145pa_5nu3i_93",
5
- "calendar": "awsui_calendar_145pa_5nu3i_104",
6
- "screenreader-only": "awsui_screenreader-only_145pa_5nu3i_114",
7
- "date-picker-container": "awsui_date-picker-container_145pa_5nu3i_120",
8
- "date-picker-trigger": "awsui_date-picker-trigger_145pa_5nu3i_125",
9
- "date-picker-input": "awsui_date-picker-input_145pa_5nu3i_129",
10
- "open-calendar-button": "awsui_open-calendar-button_145pa_5nu3i_134"
4
+ "root": "awsui_root_145pa_1jxcd_93",
5
+ "calendar": "awsui_calendar_145pa_1jxcd_104",
6
+ "date-picker-container": "awsui_date-picker-container_145pa_1jxcd_114",
7
+ "date-picker-trigger": "awsui_date-picker-trigger_145pa_1jxcd_119",
8
+ "date-picker-input": "awsui_date-picker-input_145pa_1jxcd_123",
9
+ "open-calendar-button": "awsui_open-calendar-button_145pa_1jxcd_128"
11
10
  };
12
11
 
@@ -90,7 +90,7 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
90
90
  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
91
91
  SPDX-License-Identifier: Apache-2.0
92
92
  */
93
- .awsui_root_145pa_5nu3i_93:not(#\9) {
93
+ .awsui_root_145pa_1jxcd_93:not(#\9) {
94
94
  /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
95
95
  border-collapse: separate;
96
96
  border-spacing: 0;
@@ -127,36 +127,30 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
127
127
  font-family: var(--font-family-base-qnistn, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
128
128
  }
129
129
 
130
- .awsui_calendar_145pa_5nu3i_104:not(#\9):focus {
130
+ .awsui_calendar_145pa_1jxcd_104:not(#\9):focus {
131
131
  outline: none;
132
132
  }
133
- .awsui_calendar_145pa_5nu3i_104[data-awsui-focus-visible=true]:not(#\9):focus {
133
+ .awsui_calendar_145pa_1jxcd_104[data-awsui-focus-visible=true]:not(#\9):focus {
134
134
  outline: 2px dotted transparent;
135
135
  outline-offset: 2px;
136
136
  border-radius: var(--border-radius-dropdown-ujknaf, 8px);
137
137
  box-shadow: 0 0 0 2px var(--color-border-item-focused-ap3b6s, #0972d3);
138
138
  }
139
139
 
140
- .awsui_screenreader-only_145pa_5nu3i_114:not(#\9) {
141
- position: absolute !important;
142
- top: -9999px !important;
143
- left: -9999px !important;
144
- }
145
-
146
- .awsui_date-picker-container_145pa_5nu3i_120:not(#\9) {
140
+ .awsui_date-picker-container_145pa_1jxcd_114:not(#\9) {
147
141
  position: relative;
148
142
  max-width: 234px;
149
143
  }
150
144
 
151
- .awsui_date-picker-trigger_145pa_5nu3i_125:not(#\9) {
145
+ .awsui_date-picker-trigger_145pa_1jxcd_119:not(#\9) {
152
146
  display: flex;
153
147
  }
154
148
 
155
- .awsui_date-picker-input_145pa_5nu3i_129:not(#\9) {
149
+ .awsui_date-picker-input_145pa_1jxcd_123:not(#\9) {
156
150
  padding-right: var(--space-xs-rsr2qu, 8px);
157
151
  width: 100%;
158
152
  }
159
153
 
160
- .awsui_open-calendar-button_145pa_5nu3i_134:not(#\9) {
154
+ .awsui_open-calendar-button_145pa_1jxcd_128:not(#\9) {
161
155
  /* used in test-utils */
162
156
  }
@@ -2,12 +2,11 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "root": "awsui_root_145pa_5nu3i_93",
6
- "calendar": "awsui_calendar_145pa_5nu3i_104",
7
- "screenreader-only": "awsui_screenreader-only_145pa_5nu3i_114",
8
- "date-picker-container": "awsui_date-picker-container_145pa_5nu3i_120",
9
- "date-picker-trigger": "awsui_date-picker-trigger_145pa_5nu3i_125",
10
- "date-picker-input": "awsui_date-picker-input_145pa_5nu3i_129",
11
- "open-calendar-button": "awsui_open-calendar-button_145pa_5nu3i_134"
5
+ "root": "awsui_root_145pa_1jxcd_93",
6
+ "calendar": "awsui_calendar_145pa_1jxcd_104",
7
+ "date-picker-container": "awsui_date-picker-container_145pa_1jxcd_114",
8
+ "date-picker-trigger": "awsui_date-picker-trigger_145pa_1jxcd_119",
9
+ "date-picker-input": "awsui_date-picker-input_145pa_1jxcd_123",
10
+ "open-calendar-button": "awsui_open-calendar-button_145pa_1jxcd_128"
12
11
  };
13
12
 
@@ -8,7 +8,7 @@ export interface GridProps {
8
8
  rangeStartDate: Date | null;
9
9
  rangeEndDate: Date | null;
10
10
  focusedDate: Date | null;
11
- focusedDateRef: React.RefObject<HTMLDivElement>;
11
+ focusedDateRef: React.RefObject<HTMLTableCellElement>;
12
12
  onSelectDate: DateChangeHandler;
13
13
  onGridKeyDownHandler: (e: React.KeyboardEvent) => void;
14
14
  onFocusedDateChange: React.Dispatch<React.SetStateAction<Date | null>>;
@@ -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;AAevC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAOxD,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,IAAI,CAAC;IACf,iBAAiB,EAAE,IAAI,GAAG,IAAI,CAAC;IAC/B,eAAe,EAAE,IAAI,GAAG,IAAI,CAAC;IAE7B,cAAc,EAAE,IAAI,GAAG,IAAI,CAAC;IAC5B,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAE1B,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,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,QA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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,eAoIX"}
@@ -2,11 +2,9 @@ import { __assign } from "tslib";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  import React, { useMemo } from 'react';
5
- import styles from '../../styles.css.js';
6
- import dayStyles from './styles.css.js';
5
+ import styles from './styles.css.js';
7
6
  import { isSameMonth, isAfter, isBefore, isSameDay, addWeeks, addDays, isLastDayOfMonth, getDaysInMonth, isToday, } from 'date-fns';
8
7
  import { getCalendarMonth } from 'mnth';
9
- import rotateDayIndexes from '../../../calendar/utils/rotate-day-indexes';
10
8
  import { getDateLabel, renderDayName } from '../../../calendar/utils/intl';
11
9
  import clsx from 'clsx';
12
10
  import { formatDate } from '../../../internal/utils/date-time';
@@ -18,11 +16,13 @@ export function Grid(_a) {
18
16
  var weeks = useMemo(function () { return getCalendarMonth(baseDate, { firstDayOfWeek: startOfWeek }); },
19
17
  // eslint-disable-next-line react-hooks/exhaustive-deps
20
18
  [baseDateTime, startOfWeek]);
19
+ var weekdays = weeks[0].map(function (date) { return date.getDay(); });
21
20
  var focusVisible = useFocusVisible();
22
- return (React.createElement("div", { className: clsx(styles.grid, className) },
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))); })),
24
- React.createElement("div", { className: styles['calendar-dates'], onKeyDown: onGridKeyDownHandler }, weeks.map(function (week, weekIndex) {
25
- return (React.createElement("div", { key: weekIndex, className: styles['calendar-week'] }, week.map(function (date, dateIndex) {
21
+ return (React.createElement("table", { role: "none", className: clsx(styles.grid, className) },
22
+ React.createElement("thead", null,
23
+ React.createElement("tr", null, weekdays.map(function (dayIndex) { return (React.createElement("th", { key: dayIndex, scope: "col", className: clsx(styles['grid-cell'], styles['day-header']) }, renderDayName(locale, dayIndex, 'short'))); }))),
24
+ React.createElement("tbody", { onKeyDown: onGridKeyDownHandler }, weeks.map(function (week, weekIndex) {
25
+ return (React.createElement("tr", { key: weekIndex, className: styles.week }, week.map(function (date, dateIndex) {
26
26
  var _a, _b, _c;
27
27
  var isStartDate = !!selectedStartDate && isSameDay(date, selectedStartDate);
28
28
  var isEndDate = !!selectedEndDate && isSameDay(date, selectedEndDate);
@@ -38,22 +38,23 @@ export function Grid(_a) {
38
38
  : !selectedStartDate || !selectedEndDate;
39
39
  var isEnabled = !isDateEnabled || isDateEnabled(date);
40
40
  var isFocusable = isFocused && isEnabled;
41
- var computedAttributes = {};
42
41
  var baseClasses = (_a = {},
43
- _a[dayStyles.day] = true,
44
- _a[dayStyles['in-first-row']] = weekIndex === 0,
45
- _a[dayStyles['in-first-column']] = dateIndex === 0,
42
+ _a[styles.day] = true,
43
+ _a[styles['grid-cell']] = true,
44
+ _a[styles['in-first-row']] = weekIndex === 0,
45
+ _a[styles['in-first-column']] = dateIndex === 0,
46
46
  _a);
47
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 }));
48
+ return (React.createElement("td", { key: "".concat(weekIndex, ":").concat(dateIndex), ref: isFocused ? focusedDateRef : undefined, className: clsx(baseClasses, (_b = {},
49
+ _b[styles['in-previous-month']] = isBefore(date, baseDate),
50
+ _b[styles['last-day-of-month']] = isLastDayOfMonth(date),
51
+ _b[styles['in-next-month']] = isAfter(date, baseDate),
52
+ _b)) }));
53
53
  }
54
+ var handlers = {};
54
55
  if (isEnabled) {
55
- computedAttributes.onClick = function () { return onSelectDate(date); };
56
- computedAttributes.onFocus = function () { return onFocusedDateChange(date); };
56
+ handlers.onClick = function () { return onSelectDate(date); };
57
+ handlers.onFocus = function () { return onFocusedDateChange(date); };
57
58
  }
58
59
  // Can't be focused.
59
60
  var tabIndex = undefined;
@@ -70,23 +71,23 @@ export function Grid(_a) {
70
71
  if (isToday(date)) {
71
72
  dayAnnouncement += '. ' + todayAriaLabel;
72
73
  }
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())));
74
+ return (React.createElement("td", __assign({ ref: isFocused ? focusedDateRef : undefined, key: "".concat(weekIndex, ":").concat(dateIndex), className: clsx(baseClasses, (_c = {},
75
+ _c[styles['in-current-month']] = isSameMonth(date, baseDate),
76
+ _c[styles.enabled] = isEnabled,
77
+ _c[styles.selected] = isSelected,
78
+ _c[styles['start-date']] = isStartDate,
79
+ _c[styles['end-date']] = isEndDate,
80
+ _c[styles['range-start-date']] = isRangeStartDate,
81
+ _c[styles['range-end-date']] = isRangeEndDate,
82
+ _c[styles['no-range']] = isSelected && onlyOneSelected,
83
+ _c[styles['in-range']] = dateIsInRange,
84
+ _c[styles['in-range-border-top']] = !!inRangeStartWeek || date.getDate() <= 7,
85
+ _c[styles['in-range-border-bottom']] = !!inRangeEndWeek || date.getDate() > getDaysInMonth(date) - 7,
86
+ _c[styles['in-range-border-left']] = dateIndex === 0 || date.getDate() === 1 || isRangeStartDate,
87
+ _c[styles['in-range-border-right']] = dateIndex === week.length - 1 || isLastDayOfMonth(date) || isRangeEndDate,
88
+ _c[styles.today] = isToday(date),
89
+ _c)), "aria-label": dayAnnouncement, "aria-pressed": isSelected || dateIsInRange, "aria-current": isToday(date) ? 'date' : undefined, "data-date": formatDate(date), role: "button", tabIndex: tabIndex }, handlers, focusVisible),
90
+ React.createElement("span", { className: styles['day-inner'] }, date.getDate())));
90
91
  })));
91
92
  }))));
92
93
  }