@cloudscape-design/components 3.0.10 → 3.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app-layout/visual-refresh/hooks/use-dynamic-overlap.d.ts +14 -0
- package/app-layout/visual-refresh/hooks/use-dynamic-overlap.d.ts.map +1 -0
- package/app-layout/visual-refresh/hooks/use-dynamic-overlap.js +29 -0
- package/app-layout/visual-refresh/hooks/use-dynamic-overlap.js.map +1 -0
- package/container/internal.d.ts.map +1 -1
- package/container/internal.js +4 -15
- package/container/internal.js.map +1 -1
- package/date-picker/calendar/header/button/index.d.ts +1 -2
- package/date-picker/calendar/header/button/index.d.ts.map +1 -1
- package/date-picker/calendar/header/button/index.js +2 -3
- package/date-picker/calendar/header/button/index.js.map +1 -1
- package/date-picker/calendar/header/index.d.ts +1 -2
- package/date-picker/calendar/header/index.d.ts.map +1 -1
- package/date-picker/calendar/header/index.js +3 -3
- package/date-picker/calendar/header/index.js.map +1 -1
- package/date-picker/calendar/index.d.ts +1 -6
- package/date-picker/calendar/index.d.ts.map +1 -1
- package/date-picker/calendar/index.js +35 -34
- package/date-picker/calendar/index.js.map +1 -1
- package/date-picker/index.d.ts.map +1 -1
- package/date-picker/index.js +7 -25
- package/date-picker/index.js.map +1 -1
- package/internal/components/content-layout/index.d.ts.map +1 -1
- package/internal/components/content-layout/index.js +4 -10
- package/internal/components/content-layout/index.js.map +1 -1
- package/internal/components/focus-lock/index.d.ts +8 -0
- package/internal/components/focus-lock/index.d.ts.map +1 -0
- package/internal/components/focus-lock/index.js +31 -0
- package/internal/components/focus-lock/index.js.map +1 -0
- package/internal/components/focus-lock/utils.d.ts +4 -0
- package/internal/components/focus-lock/utils.d.ts.map +1 -0
- package/internal/components/focus-lock/utils.js +37 -0
- package/internal/components/focus-lock/utils.js.map +1 -0
- package/internal/components/tab-trap/index.d.ts +1 -2
- package/internal/components/tab-trap/index.d.ts.map +1 -1
- package/internal/components/tab-trap/index.js +2 -3
- package/internal/components/tab-trap/index.js.map +1 -1
- package/internal/environment.js +1 -1
- package/link/internal.d.ts.map +1 -1
- package/link/internal.js +2 -7
- package/link/internal.js.map +1 -1
- package/package.json +1 -1
- package/table/styles.css.js +32 -32
- package/table/styles.scoped.css +38 -37
- package/table/styles.selectors.js +32 -32
- package/test-utils/dom/attribute-editor/index.d.ts +2 -1
- package/test-utils/dom/attribute-editor/index.js +6 -5
- package/test-utils/dom/attribute-editor/index.js.map +1 -1
- package/test-utils/selectors/attribute-editor/index.d.ts +2 -1
- package/test-utils/selectors/attribute-editor/index.js +6 -5
- package/test-utils/selectors/attribute-editor/index.js.map +1 -1
- package/test-utils/tsconfig.tsbuildinfo +1 -1
- package/wizard/wizard-form-header.d.ts.map +1 -1
- package/wizard/wizard-form-header.js +3 -14
- package/wizard/wizard-form-header.js.map +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface UseDynamicOverlapProps {
|
|
2
|
+
/**
|
|
3
|
+
* Disables hook if not needed. By default, `false`.
|
|
4
|
+
*/
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Observes the height of an element referenced by the returning ref and sets the value as overlapping
|
|
9
|
+
* height for the surrounding AppLayout component.
|
|
10
|
+
* @param props.disabled disables hook if not applicable
|
|
11
|
+
* @returns ref to be measured as overlapping height
|
|
12
|
+
*/
|
|
13
|
+
export declare function useDynamicOverlap(props?: UseDynamicOverlapProps): import("react").Ref<any>;
|
|
14
|
+
//# sourceMappingURL=use-dynamic-overlap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-dynamic-overlap.d.ts","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh/hooks/use-dynamic-overlap.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,EAAE,sBAAsB,4BAqB/D"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { useContext, useLayoutEffect } from 'react';
|
|
4
|
+
import { AppLayoutContext } from '../context';
|
|
5
|
+
import { useContainerQuery } from '../../../internal/hooks/container-queries';
|
|
6
|
+
/**
|
|
7
|
+
* Observes the height of an element referenced by the returning ref and sets the value as overlapping
|
|
8
|
+
* height for the surrounding AppLayout component.
|
|
9
|
+
* @param props.disabled disables hook if not applicable
|
|
10
|
+
* @returns ref to be measured as overlapping height
|
|
11
|
+
*/
|
|
12
|
+
export function useDynamicOverlap(props) {
|
|
13
|
+
var _a;
|
|
14
|
+
var disabled = (_a = props === null || props === void 0 ? void 0 : props.disabled) !== null && _a !== void 0 ? _a : false;
|
|
15
|
+
var setDynamicOverlapHeight = useContext(AppLayoutContext).setDynamicOverlapHeight;
|
|
16
|
+
var _b = useContainerQuery(function (rect) { return rect.height; }), overlapContainerQuery = _b[0], overlapElementRef = _b[1];
|
|
17
|
+
useLayoutEffect(function handleDynamicOverlapHeight() {
|
|
18
|
+
if (!disabled) {
|
|
19
|
+
setDynamicOverlapHeight(overlapContainerQuery !== null && overlapContainerQuery !== void 0 ? overlapContainerQuery : 0);
|
|
20
|
+
}
|
|
21
|
+
return function () {
|
|
22
|
+
if (!disabled) {
|
|
23
|
+
setDynamicOverlapHeight(0);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}, [disabled, overlapContainerQuery, setDynamicOverlapHeight]);
|
|
27
|
+
return overlapElementRef;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=use-dynamic-overlap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-dynamic-overlap.js","sourceRoot":"","sources":["../../../../../src/app-layout/visual-refresh/hooks/use-dynamic-overlap.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAS9E;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA8B;;IAC9D,IAAM,QAAQ,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,mCAAI,KAAK,CAAC;IAClC,IAAA,uBAAuB,GAAK,UAAU,CAAC,gBAAgB,CAAC,wBAAjC,CAAkC;IAC3D,IAAA,KAA6C,iBAAiB,CAAC,UAAA,IAAI,IAAI,OAAA,IAAI,CAAC,MAAM,EAAX,CAAW,CAAC,EAAlF,qBAAqB,QAAA,EAAE,iBAAiB,QAA0C,CAAC;IAE1F,eAAe,CACb,SAAS,0BAA0B;QACjC,IAAI,CAAC,QAAQ,EAAE;YACb,uBAAuB,CAAC,qBAAqB,aAArB,qBAAqB,cAArB,qBAAqB,GAAI,CAAC,CAAC,CAAC;SACrD;QAED,OAAO;YACL,IAAI,CAAC,QAAQ,EAAE;gBACb,uBAAuB,CAAC,CAAC,CAAC,CAAC;aAC5B;QACH,CAAC,CAAC;IACJ,CAAC,EACD,CAAC,QAAQ,EAAE,qBAAqB,EAAE,uBAAuB,CAAC,CAC3D,CAAC;IAEF,OAAO,iBAAiB,CAAC;AAC3B,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useContext, useLayoutEffect } from 'react';\n\nimport { AppLayoutContext } from '../context';\nimport { useContainerQuery } from '../../../internal/hooks/container-queries';\n\nexport interface UseDynamicOverlapProps {\n /**\n * Disables hook if not needed. By default, `false`.\n */\n disabled?: boolean;\n}\n\n/**\n * Observes the height of an element referenced by the returning ref and sets the value as overlapping\n * height for the surrounding AppLayout component.\n * @param props.disabled disables hook if not applicable\n * @returns ref to be measured as overlapping height\n */\nexport function useDynamicOverlap(props?: UseDynamicOverlapProps) {\n const disabled = props?.disabled ?? false;\n const { setDynamicOverlapHeight } = useContext(AppLayoutContext);\n const [overlapContainerQuery, overlapElementRef] = useContainerQuery(rect => rect.height);\n\n useLayoutEffect(\n function handleDynamicOverlapHeight() {\n if (!disabled) {\n setDynamicOverlapHeight(overlapContainerQuery ?? 0);\n }\n\n return () => {\n if (!disabled) {\n setDynamicOverlapHeight(0);\n }\n };\n },\n [disabled, overlapContainerQuery, setDynamicOverlapHeight]\n );\n\n return overlapElementRef;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/container/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/container/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAMlF,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,EAAE,0BAA0B;IACzG,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC9C;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC;CAC1E;AAED,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,MAAM,EACN,MAAM,EACN,QAAQ,EACR,OAAmB,EACnB,qBAA6B,EAC7B,sBAA8B,EAC9B,cAAc,EACd,cAAsB,EACtB,iBAAwB,EACxB,sBAA8B,EAC9B,uBAA+B,EAC/B,WAAW,EACX,GAAG,SAAS,EACb,EAAE,sBAAsB,eA0DxB"}
|
package/container/internal.js
CHANGED
|
@@ -2,11 +2,10 @@ import { __assign, __rest } 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 clsx from 'clsx';
|
|
5
|
-
import React, {
|
|
6
|
-
import {
|
|
5
|
+
import React, { useRef } from 'react';
|
|
6
|
+
import { useDynamicOverlap } from '../app-layout/visual-refresh/hooks/use-dynamic-overlap';
|
|
7
7
|
import { getBaseProps } from '../internal/base-component';
|
|
8
8
|
import { StickyHeaderContext, useStickyHeader } from './use-sticky-header';
|
|
9
|
-
import { useContainerQuery } from '../internal/hooks/container-queries';
|
|
10
9
|
import { useMergeRefs } from '../internal/hooks/use-merge-refs';
|
|
11
10
|
import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
|
|
12
11
|
import styles from './styles.css.js';
|
|
@@ -16,20 +15,10 @@ export default function InternalContainer(_a) {
|
|
|
16
15
|
var baseProps = getBaseProps(restProps);
|
|
17
16
|
var rootRef = useRef(null);
|
|
18
17
|
var headerRef = useRef(null);
|
|
18
|
+
var _m = useStickyHeader(rootRef, headerRef, __stickyHeader, __stickyOffset), isSticky = _m.isSticky, isStuck = _m.isStuck, stickyStyles = _m.stickyStyles;
|
|
19
19
|
var isRefresh = useVisualRefresh(rootRef);
|
|
20
20
|
var hasDynamicHeight = isRefresh && variant === 'full-page';
|
|
21
|
-
var
|
|
22
|
-
/**
|
|
23
|
-
* Observe the dynamic height of the full page container variant in
|
|
24
|
-
* visual refresh and update the AppLayout dynamicOverlapHeight property.
|
|
25
|
-
*/
|
|
26
|
-
var setDynamicOverlapHeight = useContext(AppLayoutContext).setDynamicOverlapHeight;
|
|
27
|
-
var _o = useContainerQuery(function (rect) { return rect.height; }), overlapContainerQuery = _o[0], overlapElement = _o[1];
|
|
28
|
-
useLayoutEffect(function handleDynamicOverlapHeight() {
|
|
29
|
-
if (hasDynamicHeight) {
|
|
30
|
-
setDynamicOverlapHeight(overlapContainerQuery !== null && overlapContainerQuery !== void 0 ? overlapContainerQuery : 0);
|
|
31
|
-
}
|
|
32
|
-
}, [hasDynamicHeight, overlapContainerQuery, setDynamicOverlapHeight]);
|
|
21
|
+
var overlapElement = useDynamicOverlap({ disabled: !hasDynamicHeight });
|
|
33
22
|
var mergedRef = useMergeRefs(rootRef, __internalRootRef);
|
|
34
23
|
var headerMergedRef = useMergeRefs(headerRef, overlapElement, __headerRef);
|
|
35
24
|
return (React.createElement("div", __assign({}, baseProps, { className: clsx(baseProps.className, styles.root, styles["variant-".concat(variant)]), ref: mergedRef }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/container/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/container/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAE3F,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,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BAAuB;oBACnD,IAED,MAAM,CACH,CACP,CACG,CACP,CAAC;AACJ,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, { useRef } from 'react';\nimport { useDynamicOverlap } from '../app-layout/visual-refresh/hooks/use-dynamic-overlap';\nimport { ContainerProps } from './interfaces';\nimport { getBaseProps } from '../internal/base-component';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { StickyHeaderContext, useStickyHeader } from './use-sticky-header';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport styles from './styles.css.js';\n\nexport interface InternalContainerProps extends Omit<ContainerProps, 'variant'>, InternalBaseComponentProps {\n __stickyHeader?: boolean;\n __stickyOffset?: number;\n __disableFooterDivider?: boolean;\n __disableFooterPaddings?: boolean;\n __headerRef?: React.RefObject<HTMLDivElement>;\n /**\n * Additional internal variant:\n * * `embedded` - Use this variant within a parent container (such as a modal,\n * expandable section, container or split panel).\n * * `full-page` – Only for internal use in table, cards and other components\n */\n variant?: ContainerProps['variant'] | 'embedded' | 'full-page' | 'cards';\n}\n\nexport default function InternalContainer({\n header,\n footer,\n children,\n variant = 'default',\n disableHeaderPaddings = false,\n disableContentPaddings = false,\n __stickyOffset,\n __stickyHeader = false,\n __internalRootRef = null,\n __disableFooterDivider = false,\n __disableFooterPaddings = false,\n __headerRef,\n ...restProps\n}: InternalContainerProps) {\n const baseProps = getBaseProps(restProps);\n const rootRef = useRef<HTMLDivElement>(null);\n const headerRef = useRef<HTMLDivElement>(null);\n const { isSticky, isStuck, stickyStyles } = useStickyHeader(rootRef, headerRef, __stickyHeader, __stickyOffset);\n const isRefresh = useVisualRefresh(rootRef);\n const hasDynamicHeight = isRefresh && variant === 'full-page';\n const overlapElement = useDynamicOverlap({ disabled: !hasDynamicHeight });\n\n const mergedRef = useMergeRefs(rootRef, __internalRootRef);\n const headerMergedRef = useMergeRefs(headerRef, overlapElement, __headerRef);\n\n return (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.root, styles[`variant-${variant}`])}\n ref={mergedRef}\n >\n {header && (\n <StickyHeaderContext.Provider value={{ isStuck }}>\n <div\n className={clsx(styles.header, styles[`header-variant-${variant}`], {\n [styles['header-sticky-disabled']]: __stickyHeader && !isSticky,\n [styles['header-sticky-enabled']]: isSticky,\n [styles['header-dynamic-height']]: hasDynamicHeight,\n [styles['header-stuck']]: isStuck,\n [styles['with-paddings']]: !disableHeaderPaddings,\n })}\n {...stickyStyles}\n ref={headerMergedRef}\n >\n {hasDynamicHeight ? (\n <div className={clsx(styles['dark-header'], 'awsui-context-content-header')}>{header}</div>\n ) : (\n header\n )}\n </div>\n </StickyHeaderContext.Provider>\n )}\n <div\n className={clsx(styles.content, {\n [styles['with-paddings']]: !disableContentPaddings,\n })}\n >\n {children}\n </div>\n {footer && (\n <div\n className={clsx(styles.footer, {\n [styles['with-divider']]: !__disableFooterDivider,\n [styles['with-paddings']]: !__disableFooterPaddings,\n })}\n >\n {footer}\n </div>\n )}\n </div>\n );\n}\n"]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
interface HeaderButtonProps {
|
|
2
2
|
ariaLabel: string;
|
|
3
3
|
isPrevious: boolean;
|
|
4
|
-
focusable: boolean;
|
|
5
4
|
onChangeMonth: (isPrevious: boolean) => void;
|
|
6
5
|
}
|
|
7
|
-
declare const HeaderButton: ({ ariaLabel, isPrevious, onChangeMonth
|
|
6
|
+
declare const HeaderButton: ({ ariaLabel, isPrevious, onChangeMonth }: HeaderButtonProps) => JSX.Element;
|
|
8
7
|
export default HeaderButton;
|
|
9
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/date-picker/calendar/header/button/index.tsx"],"names":[],"mappings":"AAQA,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/date-picker/calendar/header/button/index.tsx"],"names":[],"mappings":"AAQA,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C;AAED,QAAA,MAAM,YAAY,6CAA8C,iBAAiB,gBAoBhF,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -5,11 +5,10 @@ import React from 'react';
|
|
|
5
5
|
import { InternalButton } from '../../../../button/internal';
|
|
6
6
|
import styles from '../../../styles.css.js';
|
|
7
7
|
var HeaderButton = function (_a) {
|
|
8
|
-
var ariaLabel = _a.ariaLabel, isPrevious = _a.isPrevious, onChangeMonth = _a.onChangeMonth
|
|
8
|
+
var ariaLabel = _a.ariaLabel, isPrevious = _a.isPrevious, onChangeMonth = _a.onChangeMonth;
|
|
9
9
|
var iconName = isPrevious ? 'angle-left' : 'angle-right';
|
|
10
10
|
var additionalAttributes = {
|
|
11
|
-
className: isPrevious ? styles['calendar-prev-month-btn'] : styles['calendar-next-month-btn']
|
|
12
|
-
tabIndex: focusable ? 0 : -1
|
|
11
|
+
className: isPrevious ? styles['calendar-prev-month-btn'] : styles['calendar-next-month-btn']
|
|
13
12
|
};
|
|
14
13
|
var onClick = function (e) {
|
|
15
14
|
e.preventDefault();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/date-picker/calendar/header/button/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,MAAM,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/date-picker/calendar/header/button/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAQ5C,IAAM,YAAY,GAAG,UAAC,EAA2D;QAAzD,SAAS,eAAA,EAAE,UAAU,gBAAA,EAAE,aAAa,mBAAA;IAC1D,IAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC;IAC3D,IAAM,oBAAoB,GAA4C;QACpE,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,yBAAyB,CAAC;KAC9F,CAAC;IAEF,IAAM,OAAO,GAAoD,UAAA,CAAC;QAChE,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,aAAa,CAAC,UAAU,CAAC,CAAC;IAC5B,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,cAAc,eACT,oBAAoB,IACxB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,IAChB,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { CancelableEventHandler } from '../../../../internal/events';\nimport { ButtonProps } from '../../../../button/interfaces';\nimport { InternalButton } from '../../../../button/internal';\nimport styles from '../../../styles.css.js';\n\ninterface HeaderButtonProps {\n ariaLabel: string;\n isPrevious: boolean;\n onChangeMonth: (isPrevious: boolean) => void;\n}\n\nconst HeaderButton = ({ ariaLabel, isPrevious, onChangeMonth }: HeaderButtonProps) => {\n const iconName = isPrevious ? 'angle-left' : 'angle-right';\n const additionalAttributes: React.HTMLAttributes<HTMLButtonElement> = {\n className: isPrevious ? styles['calendar-prev-month-btn'] : styles['calendar-next-month-btn'],\n };\n\n const onClick: CancelableEventHandler<ButtonProps.ClickDetail> = e => {\n e.preventDefault();\n onChangeMonth(isPrevious);\n };\n\n return (\n <InternalButton\n {...additionalAttributes}\n iconName={iconName}\n ariaLabel={ariaLabel}\n variant={'icon'}\n onClick={onClick}\n />\n );\n};\n\nexport default HeaderButton;\n"]}
|
|
@@ -5,8 +5,7 @@ interface CalendarHeaderProps {
|
|
|
5
5
|
onChangeMonth: (prev?: boolean) => void;
|
|
6
6
|
previousMonthLabel: string;
|
|
7
7
|
nextMonthLabel: string;
|
|
8
|
-
calendarHasFocus: boolean;
|
|
9
8
|
}
|
|
10
|
-
declare const CalendarHeader: ({ headerId, baseDate, locale, onChangeMonth, previousMonthLabel, nextMonthLabel,
|
|
9
|
+
declare const CalendarHeader: ({ headerId, baseDate, locale, onChangeMonth, previousMonthLabel, nextMonthLabel, }: CalendarHeaderProps) => JSX.Element;
|
|
11
10
|
export default CalendarHeader;
|
|
12
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/date-picker/calendar/header/index.tsx"],"names":[],"mappings":"AAOA,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,IAAI,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/date-picker/calendar/header/index.tsx"],"names":[],"mappings":"AAOA,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,IAAI,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,cAAc,uFAOjB,mBAAmB,gBAUrB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -5,11 +5,11 @@ import styles from '../../styles.css.js';
|
|
|
5
5
|
import { renderMonthAndYear } from '../utils/intl';
|
|
6
6
|
import HeaderButton from './button';
|
|
7
7
|
var CalendarHeader = function (_a) {
|
|
8
|
-
var headerId = _a.headerId, baseDate = _a.baseDate, locale = _a.locale, onChangeMonth = _a.onChangeMonth, previousMonthLabel = _a.previousMonthLabel, nextMonthLabel = _a.nextMonthLabel
|
|
8
|
+
var headerId = _a.headerId, baseDate = _a.baseDate, locale = _a.locale, onChangeMonth = _a.onChangeMonth, previousMonthLabel = _a.previousMonthLabel, nextMonthLabel = _a.nextMonthLabel;
|
|
9
9
|
return (React.createElement("div", { className: styles['calendar-header'] },
|
|
10
|
-
React.createElement(HeaderButton, { ariaLabel: previousMonthLabel, isPrevious: true, onChangeMonth: onChangeMonth
|
|
10
|
+
React.createElement(HeaderButton, { ariaLabel: previousMonthLabel, isPrevious: true, onChangeMonth: onChangeMonth }),
|
|
11
11
|
React.createElement("div", { className: styles['calendar-header-month'], id: headerId, "aria-live": "polite" }, renderMonthAndYear(locale, baseDate)),
|
|
12
|
-
React.createElement(HeaderButton, { ariaLabel: nextMonthLabel, isPrevious: false, onChangeMonth: onChangeMonth
|
|
12
|
+
React.createElement(HeaderButton, { ariaLabel: nextMonthLabel, isPrevious: false, onChangeMonth: onChangeMonth })));
|
|
13
13
|
};
|
|
14
14
|
export default CalendarHeader;
|
|
15
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/date-picker/calendar/header/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,YAAY,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/date-picker/calendar/header/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,YAAY,MAAM,UAAU,CAAC;AAWpC,IAAM,cAAc,GAAG,UAAC,EAOF;QANpB,QAAQ,cAAA,EACR,QAAQ,cAAA,EACR,MAAM,YAAA,EACN,aAAa,mBAAA,EACb,kBAAkB,wBAAA,EAClB,cAAc,oBAAA;IAEd,OAAO,CACL,6BAAK,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC;QACvC,oBAAC,YAAY,IAAC,SAAS,EAAE,kBAAkB,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,GAAI;QAC/F,6BAAK,SAAS,EAAE,MAAM,CAAC,uBAAuB,CAAC,EAAE,EAAE,EAAE,QAAQ,eAAY,QAAQ,IAC9E,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,CACjC;QACN,oBAAC,YAAY,IAAC,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,aAAa,GAAI,CACxF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport styles from '../../styles.css.js';\nimport { renderMonthAndYear } from '../utils/intl';\nimport HeaderButton from './button';\n\ninterface CalendarHeaderProps {\n headerId: string;\n baseDate: Date;\n locale: string;\n onChangeMonth: (prev?: boolean) => void;\n previousMonthLabel: string;\n nextMonthLabel: string;\n}\n\nconst CalendarHeader = ({\n headerId,\n baseDate,\n locale,\n onChangeMonth,\n previousMonthLabel,\n nextMonthLabel,\n}: CalendarHeaderProps) => {\n return (\n <div className={styles['calendar-header']}>\n <HeaderButton ariaLabel={previousMonthLabel} isPrevious={true} onChangeMonth={onChangeMonth} />\n <div className={styles['calendar-header-month']} id={headerId} aria-live=\"polite\">\n {renderMonthAndYear(locale, baseDate)}\n </div>\n <HeaderButton ariaLabel={nextMonthLabel} isPrevious={false} onChangeMonth={onChangeMonth} />\n </div>\n );\n};\n\nexport default CalendarHeader;\n"]}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { BaseComponentProps } from '../../internal/base-component';
|
|
3
2
|
import { DatePickerProps } from '../interfaces';
|
|
4
3
|
import { CalendarTypes } from './definitions';
|
|
5
|
-
import { DateChangeHandlerNullable } from './grid';
|
|
6
4
|
export interface DateChangeHandler {
|
|
7
5
|
(detail: CalendarTypes.DateDetail): void;
|
|
8
6
|
}
|
|
@@ -15,16 +13,13 @@ interface CalendarProps extends BaseComponentProps {
|
|
|
15
13
|
startOfWeek: DayIndex;
|
|
16
14
|
selectedDate: Date | null;
|
|
17
15
|
displayedDate: Date;
|
|
18
|
-
focusedDate?: Date | null;
|
|
19
16
|
isDateEnabled: DatePickerProps.IsDateEnabledFunction;
|
|
20
|
-
calendarHasFocus: boolean;
|
|
21
17
|
nextMonthLabel: string;
|
|
22
18
|
previousMonthLabel: string;
|
|
23
19
|
todayAriaLabel: string;
|
|
24
20
|
onChangeMonth: MonthChangeHandler;
|
|
25
21
|
onSelectDate: DateChangeHandler;
|
|
26
|
-
onFocusDate: DateChangeHandlerNullable;
|
|
27
22
|
}
|
|
28
|
-
declare const Calendar:
|
|
23
|
+
declare const Calendar: ({ locale, startOfWeek, displayedDate, todayAriaLabel, selectedDate, isDateEnabled, onChangeMonth, onSelectDate, previousMonthLabel, nextMonthLabel, }: CalendarProps) => JSX.Element;
|
|
29
24
|
export default Calendar;
|
|
30
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/date-picker/calendar/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/date-picker/calendar/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAQ9C,MAAM,WAAW,iBAAiB;IAChC,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,GAAG,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,kBAAkB;IACjC,CAAC,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;CACxB;AAED,oBAAY,QAAQ,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAMjD,UAAU,aAAc,SAAQ,kBAAkB;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,QAAQ,CAAC;IACtB,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,IAAI,CAAC;IACpB,aAAa,EAAE,eAAe,CAAC,qBAAqB,CAAC;IACrD,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IAEvB,aAAa,EAAE,kBAAkB,CAAC;IAClC,YAAY,EAAE,iBAAiB,CAAC;CACjC;AAED,QAAA,MAAM,QAAQ,0JAWX,aAAa,gBAyGf,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
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
|
-
import React, {
|
|
4
|
+
import React, { useRef, useState } from 'react';
|
|
5
5
|
import { addDays, addMonths, isSameMonth, startOfMonth } from 'date-fns';
|
|
6
6
|
import styles from '../styles.css.js';
|
|
7
7
|
import useFocusVisible from '../../internal/hooks/focus-visible/index.js';
|
|
@@ -9,15 +9,15 @@ import CalendarHeader from './header';
|
|
|
9
9
|
import Grid from './grid';
|
|
10
10
|
import moveFocusHandler from './utils/move-focus-handler';
|
|
11
11
|
import { useUniqueId } from '../../internal/hooks/use-unique-id/index.js';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
import { formatDate, memoizedDate } from './utils/date.js';
|
|
13
|
+
import { useEffectOnUpdate } from '../../internal/hooks/use-effect-on-update.js';
|
|
14
|
+
var Calendar = function (_a) {
|
|
15
|
+
var locale = _a.locale, startOfWeek = _a.startOfWeek, displayedDate = _a.displayedDate, todayAriaLabel = _a.todayAriaLabel, selectedDate = _a.selectedDate, isDateEnabled = _a.isDateEnabled, onChangeMonth = _a.onChangeMonth, onSelectDate = _a.onSelectDate, previousMonthLabel = _a.previousMonthLabel, nextMonthLabel = _a.nextMonthLabel;
|
|
15
16
|
var focusVisible = useFocusVisible();
|
|
16
17
|
var headerId = useUniqueId('calendar-dialog-title-');
|
|
17
18
|
var elementRef = useRef(null);
|
|
18
|
-
var calendarRef = useMergeRefs(elementRef, ref);
|
|
19
19
|
var gridWrapperRef = useRef(null);
|
|
20
|
-
var
|
|
20
|
+
var _b = useState(null), focusedDate = _b[0], setFocusedDate = _b[1];
|
|
21
21
|
var selectFocusedDate = function (selected, baseDate) {
|
|
22
22
|
if (selected && isDateEnabled(selected) && isSameMonth(selected, baseDate)) {
|
|
23
23
|
return selected;
|
|
@@ -39,45 +39,46 @@ var Calendar = React.forwardRef(function (_a, ref) {
|
|
|
39
39
|
return moveFocusHandler(startDate, isDateEnabled, function (date) { return addDays(date, 1); });
|
|
40
40
|
};
|
|
41
41
|
var baseDate = getBaseDate(displayedDate);
|
|
42
|
-
var
|
|
42
|
+
var focusedOrSelectedDate = focusedDate || selectFocusedDate(selectedDate, baseDate);
|
|
43
43
|
var onHeaderChangeMonthHandler = function (isPrevious) {
|
|
44
|
-
|
|
44
|
+
onChangeMonth(addMonths(baseDate, isPrevious ? -1 : 1));
|
|
45
|
+
setFocusedDate(null);
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
var onGridChangeMonthHandler = function (newMonth) {
|
|
48
|
+
onChangeMonth(newMonth);
|
|
49
|
+
setFocusedDate(null);
|
|
50
|
+
};
|
|
51
|
+
var onGridFocusDateHandler = function (_a) {
|
|
52
|
+
var date = _a.date;
|
|
53
|
+
if (date) {
|
|
54
|
+
var value = memoizedDate('focused', formatDate(date));
|
|
55
|
+
setFocusedDate(value);
|
|
50
56
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
57
|
+
};
|
|
58
|
+
var onGridSelectDateHandler = function (detail) {
|
|
59
|
+
onSelectDate(detail);
|
|
60
|
+
setFocusedDate(null);
|
|
61
|
+
};
|
|
62
|
+
// The focused date changes as a feedback to keyboard navigation in the grid.
|
|
63
|
+
// Once changed, the corresponding day button needs to receive the actual focus.
|
|
64
|
+
useEffectOnUpdate(function () {
|
|
53
65
|
var _a, _b;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (calendarShouldHaveFocus && !calendarActuallyHasFocus) {
|
|
57
|
-
(_b = elementRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
66
|
+
if (focusedDate) {
|
|
67
|
+
(_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();
|
|
58
68
|
}
|
|
59
|
-
|
|
60
|
-
}, [calendarHasFocus, baseDate, isDateEnabled]);
|
|
61
|
-
if (calendarHasFocus && !focusedDate) {
|
|
62
|
-
focusedDate = selectFocusedDate(selectedDate, baseDate);
|
|
63
|
-
}
|
|
69
|
+
}, [focusedDate]);
|
|
64
70
|
var onGridBlur = function (event) {
|
|
65
71
|
var _a;
|
|
66
72
|
var newFocusTargetIsInGrid = event.relatedTarget && ((_a = gridWrapperRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.relatedTarget));
|
|
67
73
|
if (!newFocusTargetIsInGrid) {
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
var onGridFocus = function () {
|
|
72
|
-
if (!gridHasFocus) {
|
|
73
|
-
setGridHasFocus(true);
|
|
74
|
+
setFocusedDate(null);
|
|
74
75
|
}
|
|
75
76
|
};
|
|
76
|
-
return (React.createElement("div", __assign({}, focusVisible, { className: styles.calendar, tabIndex: 0, role: "application", "aria-describedby": headerId, ref:
|
|
77
|
+
return (React.createElement("div", __assign({}, focusVisible, { className: styles.calendar, tabIndex: 0, role: "application", "aria-describedby": headerId, ref: elementRef }),
|
|
77
78
|
React.createElement("div", { className: styles['calendar-inner'] },
|
|
78
|
-
React.createElement(CalendarHeader, { headerId: headerId, baseDate: baseDate, locale: locale, onChangeMonth: onHeaderChangeMonthHandler, previousMonthLabel: previousMonthLabel, nextMonthLabel: nextMonthLabel
|
|
79
|
-
React.createElement("div", { onBlur: onGridBlur,
|
|
80
|
-
React.createElement(Grid, { locale: locale, baseDate: baseDate, isDateEnabled: isDateEnabled, focusedDate:
|
|
81
|
-
}
|
|
79
|
+
React.createElement(CalendarHeader, { headerId: headerId, baseDate: baseDate, locale: locale, onChangeMonth: onHeaderChangeMonthHandler, previousMonthLabel: previousMonthLabel, nextMonthLabel: nextMonthLabel }),
|
|
80
|
+
React.createElement("div", { onBlur: onGridBlur, ref: gridWrapperRef },
|
|
81
|
+
React.createElement(Grid, { locale: locale, baseDate: baseDate, isDateEnabled: isDateEnabled, focusedDate: focusedOrSelectedDate, onSelectDate: onGridSelectDateHandler, onFocusDate: onGridFocusDateHandler, onChangeMonth: onGridChangeMonthHandler, startOfWeek: startOfWeek, todayAriaLabel: todayAriaLabel, selectedDate: selectedDate, handleFocusMove: moveFocusHandler })))));
|
|
82
|
+
};
|
|
82
83
|
export default Calendar;
|
|
83
84
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/date-picker/calendar/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/date-picker/calendar/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACzE,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAEtC,OAAO,eAAe,MAAM,6CAA6C,CAAC;AAG1E,OAAO,cAAc,MAAM,UAAU,CAAC;AACtC,OAAO,IAAmC,MAAM,QAAQ,CAAC;AACzD,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AA8BjF,IAAM,QAAQ,GAAG,UA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I,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,wCACM,YAAY,IAChB,SAAS,EAAE,MAAM,CAAC,QAAQ,EAC1B,QAAQ,EAAE,CAAC,EACX,IAAI,EAAC,aAAa,sBACA,QAAQ,EAC1B,GAAG,EAAE,UAAU;QAEf,6BAAK,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC;YACtC,oBAAC,cAAc,IACb,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,0BAA0B,EACzC,kBAAkB,EAAE,kBAAkB,EACtC,cAAc,EAAE,cAAc,GAC9B;YACF,6BAAK,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,cAAc;gBAC1C,oBAAC,IAAI,IACH,MAAM,EAAE,MAAM,EACd,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,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,gBAAgB,GACjC,CACE,CACF,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef, useState } from 'react';\nimport { addDays, addMonths, isSameMonth, startOfMonth } from 'date-fns';\nimport styles from '../styles.css.js';\nimport { BaseComponentProps } from '../../internal/base-component';\nimport useFocusVisible from '../../internal/hooks/focus-visible/index.js';\nimport { DatePickerProps } from '../interfaces';\nimport { CalendarTypes } from './definitions';\nimport CalendarHeader from './header';\nimport Grid, { DateChangeHandlerNullable } from './grid';\nimport moveFocusHandler from './utils/move-focus-handler';\nimport { useUniqueId } from '../../internal/hooks/use-unique-id/index.js';\nimport { formatDate, memoizedDate } from './utils/date.js';\nimport { useEffectOnUpdate } from '../../internal/hooks/use-effect-on-update.js';\n\nexport interface DateChangeHandler {\n (detail: CalendarTypes.DateDetail): void;\n}\n\nexport interface MonthChangeHandler {\n (newMonth: Date): void;\n}\n\nexport type DayIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6;\n\ninterface HeaderChangeMonthHandler {\n (isPreviousButtonClick?: boolean): void;\n}\n\ninterface CalendarProps extends BaseComponentProps {\n locale: string;\n startOfWeek: DayIndex;\n selectedDate: Date | null;\n displayedDate: Date;\n isDateEnabled: DatePickerProps.IsDateEnabledFunction;\n nextMonthLabel: string;\n previousMonthLabel: string;\n todayAriaLabel: string;\n\n onChangeMonth: MonthChangeHandler;\n onSelectDate: DateChangeHandler;\n}\n\nconst Calendar = ({\n locale,\n startOfWeek,\n displayedDate,\n todayAriaLabel,\n selectedDate,\n isDateEnabled,\n onChangeMonth,\n onSelectDate,\n previousMonthLabel,\n nextMonthLabel,\n}: CalendarProps) => {\n const focusVisible = useFocusVisible();\n const headerId = useUniqueId('calendar-dialog-title-');\n const elementRef = useRef<HTMLDivElement>(null);\n const gridWrapperRef = useRef<HTMLDivElement>(null);\n const [focusedDate, setFocusedDate] = useState<Date | null>(null);\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 getBaseDate = (date: Date) => {\n const startDate = startOfMonth(date);\n if (isDateEnabled(startDate)) {\n return startDate;\n }\n return moveFocusHandler(startDate, isDateEnabled, (date: Date) => addDays(date, 1));\n };\n\n const baseDate: Date = getBaseDate(displayedDate);\n const focusedOrSelectedDate = focusedDate || selectFocusedDate(selectedDate, baseDate);\n\n const onHeaderChangeMonthHandler: HeaderChangeMonthHandler = isPrevious => {\n onChangeMonth(addMonths(baseDate, isPrevious ? -1 : 1));\n setFocusedDate(null);\n };\n\n const onGridChangeMonthHandler: MonthChangeHandler = newMonth => {\n onChangeMonth(newMonth);\n setFocusedDate(null);\n };\n\n const onGridFocusDateHandler: DateChangeHandlerNullable = ({ date }) => {\n if (date) {\n const value = memoizedDate('focused', formatDate(date));\n setFocusedDate(value);\n }\n };\n\n const onGridSelectDateHandler: DateChangeHandler = detail => {\n onSelectDate(detail);\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 {...focusVisible}\n className={styles.calendar}\n tabIndex={0}\n role=\"application\"\n aria-describedby={headerId}\n ref={elementRef}\n >\n <div className={styles['calendar-inner']}>\n <CalendarHeader\n headerId={headerId}\n baseDate={baseDate}\n locale={locale}\n onChangeMonth={onHeaderChangeMonthHandler}\n previousMonthLabel={previousMonthLabel}\n nextMonthLabel={nextMonthLabel}\n />\n <div onBlur={onGridBlur} ref={gridWrapperRef}>\n <Grid\n locale={locale}\n baseDate={baseDate}\n isDateEnabled={isDateEnabled}\n focusedDate={focusedOrSelectedDate}\n onSelectDate={onGridSelectDateHandler}\n onFocusDate={onGridFocusDateHandler}\n onChangeMonth={onGridChangeMonthHandler}\n startOfWeek={startOfWeek}\n todayAriaLabel={todayAriaLabel}\n selectedDate={selectedDate}\n handleFocusMove={moveFocusHandler}\n />\n </div>\n </div>\n </div>\n );\n};\n\nexport default Calendar;\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;AAGlE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAwB/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,QAAA,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/date-picker/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAGlE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAwB/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,QAAA,MAAM,UAAU,6FA2Mf,CAAC;AAGF,eAAe,UAAU,CAAC"}
|
package/date-picker/index.js
CHANGED
|
@@ -23,23 +23,20 @@ import { InternalButton } from '../button/internal';
|
|
|
23
23
|
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
24
24
|
import { useUniqueId } from '../internal/hooks/use-unique-id';
|
|
25
25
|
import { useMergeRefs } from '../internal/hooks/use-merge-refs';
|
|
26
|
-
import
|
|
26
|
+
import FocusLock from '../internal/components/focus-lock';
|
|
27
27
|
var DatePicker = React.forwardRef(function (_a, ref) {
|
|
28
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"]);
|
|
29
29
|
var __internalRootRef = useBaseComponent('DatePicker').__internalRootRef;
|
|
30
30
|
var baseProps = getBaseProps(rest);
|
|
31
31
|
var _h = useState(false), isDropDownOpen = _h[0], setIsDropDownOpen = _h[1];
|
|
32
|
-
var _j = useState(false), calendarHasFocus = _j[0], setCalendarHasFocus = _j[1];
|
|
33
32
|
var normalizedLocale = normalizeLocale('DatePicker', locale !== null && locale !== void 0 ? locale : '');
|
|
34
33
|
var normalizedStartOfWeek = (typeof startOfWeek === 'number' ? startOfWeek : getWeekStartByLocale(normalizedLocale));
|
|
35
34
|
var defaultSelectedDate = value.length >= 10 ? value : null;
|
|
36
|
-
var
|
|
35
|
+
var _j = useState(defaultSelectedDate), selectedDate = _j[0], setSelectedDate = _j[1];
|
|
37
36
|
var defaultDisplayedDate = value.length >= 10 ? value : formatDate(new Date());
|
|
38
|
-
var
|
|
39
|
-
var _m = useState(null), focusedDate = _m[0], setFocusedDate = _m[1];
|
|
37
|
+
var _k = useState(defaultDisplayedDate), displayedDate = _k[0], setDisplayedDate = _k[1];
|
|
40
38
|
var internalInputRef = useRef(null);
|
|
41
39
|
var buttonRef = useRef(null);
|
|
42
|
-
var calendarRef = useRef(null);
|
|
43
40
|
useForwardFocus(ref, internalInputRef);
|
|
44
41
|
var rootRef = useRef(null);
|
|
45
42
|
var dropdownId = useUniqueId('calender');
|
|
@@ -47,7 +44,6 @@ var DatePicker = React.forwardRef(function (_a, ref) {
|
|
|
47
44
|
useFocusTracker({ rootRef: rootRef, onBlur: onBlur, onFocus: onFocus, viewportId: expandToViewport ? dropdownId : '' });
|
|
48
45
|
var onChangeMonthHandler = function (newMonth) {
|
|
49
46
|
setDisplayedDate(formatDate(newMonth));
|
|
50
|
-
setFocusedDate(null);
|
|
51
47
|
};
|
|
52
48
|
var onSelectDateHandler = function (_a) {
|
|
53
49
|
var _b;
|
|
@@ -57,26 +53,15 @@ var DatePicker = React.forwardRef(function (_a, ref) {
|
|
|
57
53
|
setIsDropDownOpen(false);
|
|
58
54
|
setSelectedDate(formattedDate);
|
|
59
55
|
setDisplayedDate(formattedDate);
|
|
60
|
-
setCalendarHasFocus(false);
|
|
61
|
-
setFocusedDate(null);
|
|
62
56
|
fireNonCancelableEvent(onChange, { value: formattedDate });
|
|
63
57
|
};
|
|
64
|
-
var onDateFocusHandler = function (_a) {
|
|
65
|
-
var date = _a.date;
|
|
66
|
-
if (date) {
|
|
67
|
-
var value_1 = formatDate(date);
|
|
68
|
-
setFocusedDate(value_1);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
58
|
var onDropdownCloseHandler = useCallback(function () {
|
|
72
59
|
setDisplayedDate(defaultDisplayedDate);
|
|
73
|
-
setCalendarHasFocus(false);
|
|
74
60
|
setIsDropDownOpen(false);
|
|
75
61
|
}, [defaultDisplayedDate]);
|
|
76
62
|
var onButtonClickHandler = function () {
|
|
77
63
|
if (!isDropDownOpen) {
|
|
78
64
|
setIsDropDownOpen(true);
|
|
79
|
-
setCalendarHasFocus(true);
|
|
80
65
|
}
|
|
81
66
|
};
|
|
82
67
|
var onWrapperKeyDownHandler = function (event) {
|
|
@@ -91,7 +76,7 @@ var DatePicker = React.forwardRef(function (_a, ref) {
|
|
|
91
76
|
fireNonCancelableEvent(onChange, { value: isoDateString });
|
|
92
77
|
};
|
|
93
78
|
var onInputBlurHandler = function () {
|
|
94
|
-
if (!
|
|
79
|
+
if (!isDropDownOpen) {
|
|
95
80
|
setDisplayedDate(defaultDisplayedDate);
|
|
96
81
|
setIsDropDownOpen(false);
|
|
97
82
|
}
|
|
@@ -111,10 +96,9 @@ var DatePicker = React.forwardRef(function (_a, ref) {
|
|
|
111
96
|
setSelectedDate(value);
|
|
112
97
|
}
|
|
113
98
|
}
|
|
114
|
-
var focusCurrentDate = function () { var _a, _b; return (_b = (_a = calendarRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(".".concat(styles['calendar-day-focusable']))) === null || _b === void 0 ? void 0 : _b.focus(); };
|
|
115
99
|
var DateInputElement = (React.createElement("div", { className: styles['date-picker-trigger'] },
|
|
116
100
|
React.createElement("div", { className: styles['date-picker-input'] },
|
|
117
|
-
React.createElement(DateInput, { name: name, invalid: invalid, controlId: controlId, ariaLabelledby: ariaLabelledby, ariaDescribedby: ariaDescribedby, ariaLabel: ariaLabel, ariaRequired: ariaRequired, value: isoToDisplay(value), autoComplete: false, disableBrowserAutocorrect: true, disableAutocompleteOnBlur:
|
|
101
|
+
React.createElement(DateInput, { name: name, invalid: invalid, controlId: controlId, ariaLabelledby: ariaLabelledby, ariaDescribedby: ariaDescribedby, ariaLabel: ariaLabel, ariaRequired: ariaRequired, value: isoToDisplay(value), autoComplete: false, disableBrowserAutocorrect: true, disableAutocompleteOnBlur: isDropDownOpen, disabled: disabled, readOnly: readOnly, onChange: onInputChangeHandler, onBlur: onInputBlurHandler, placeholder: placeholder, ref: internalInputRef, autoFocus: autoFocus })),
|
|
118
102
|
React.createElement("div", null,
|
|
119
103
|
React.createElement(InternalButton, { iconName: "calendar", className: styles['open-calendar-button'], onClick: onButtonClickHandler, ref: buttonRef, ariaLabel: openCalendarAriaLabel &&
|
|
120
104
|
openCalendarAriaLabel(value.length === 10 ? getDateLabel(normalizedLocale, memoizedDate('value', value)) : null), disabled: disabled || readOnly, formAction: "none" }))));
|
|
@@ -128,10 +112,8 @@ var DatePicker = React.forwardRef(function (_a, ref) {
|
|
|
128
112
|
event.preventDefault();
|
|
129
113
|
};
|
|
130
114
|
return (React.createElement("div", __assign({}, baseProps, { ref: mergedRef, onKeyDown: onWrapperKeyDownHandler }),
|
|
131
|
-
React.createElement(Dropdown, { stretchWidth: true, stretchHeight: true, open: isDropDownOpen, onDropdownClose: onDropdownCloseHandler, onMouseDown: handleMouseDown, trigger: DateInputElement, expandToViewport: expandToViewport, scrollable: false, dropdownId: dropdownId }, isDropDownOpen && (React.createElement(
|
|
132
|
-
|
|
133
|
-
React.createElement(Calendar, { ref: calendarRef, selectedDate: memoizedDate('value', selectedDate), focusedDate: memoizedDate('focused', focusedDate), displayedDate: memoizedDate('displayed', displayedDate), locale: normalizedLocale, startOfWeek: normalizedStartOfWeek, isDateEnabled: isDateEnabled ? isDateEnabled : function () { return true; }, calendarHasFocus: calendarHasFocus, nextMonthLabel: nextMonthAriaLabel, previousMonthLabel: previousMonthAriaLabel, todayAriaLabel: todayAriaLabel, onChangeMonth: onChangeMonthHandler, onSelectDate: onSelectDateHandler, onFocusDate: onDateFocusHandler }),
|
|
134
|
-
calendarHasFocus && React.createElement(TabTrap, { focusNextCallback: function () { var _a; return (_a = calendarRef.current) === null || _a === void 0 ? void 0 : _a.focus(); } }))))));
|
|
115
|
+
React.createElement(Dropdown, { stretchWidth: true, stretchHeight: true, open: isDropDownOpen, onDropdownClose: onDropdownCloseHandler, onMouseDown: handleMouseDown, trigger: DateInputElement, expandToViewport: expandToViewport, scrollable: false, dropdownId: dropdownId }, isDropDownOpen && (React.createElement(FocusLock, { autoFocus: true },
|
|
116
|
+
React.createElement(Calendar, { selectedDate: memoizedDate('value', selectedDate), displayedDate: memoizedDate('displayed', displayedDate), locale: normalizedLocale, startOfWeek: normalizedStartOfWeek, isDateEnabled: isDateEnabled ? isDateEnabled : function () { return true; }, nextMonthLabel: nextMonthAriaLabel, previousMonthLabel: previousMonthAriaLabel, todayAriaLabel: todayAriaLabel, onChangeMonth: onChangeMonthHandler, onSelectDate: onSelectDateHandler }))))));
|
|
135
117
|
});
|
|
136
118
|
applyDisplayName(DatePicker, 'DatePicker');
|
|
137
119
|
export default DatePicker;
|