@cloudscape-design/components 3.0.310 → 3.0.311
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/button/internal.d.ts +6 -0
- package/button/internal.d.ts.map +1 -1
- package/button/internal.js +6 -8
- package/button/internal.js.map +1 -1
- package/collection-preferences/content-display/index.js +1 -1
- package/collection-preferences/content-display/index.js.map +1 -1
- package/date-range-picker/calendar/header/index.d.ts.map +1 -1
- package/date-range-picker/calendar/header/index.js +4 -2
- package/date-range-picker/calendar/header/index.js.map +1 -1
- package/date-range-picker/calendar/index.js +1 -1
- package/date-range-picker/calendar/index.js.map +1 -1
- package/form/index.d.ts.map +1 -1
- package/form/index.js +14 -1
- package/form/index.js.map +1 -1
- package/form/internal.d.ts.map +1 -1
- package/form/internal.js +3 -4
- package/form/internal.js.map +1 -1
- package/form-field/internal.js +2 -3
- package/form-field/internal.js.map +1 -1
- package/i18n/context.d.ts +14 -7
- package/i18n/context.d.ts.map +1 -1
- package/i18n/context.js.map +1 -1
- package/i18n/messages/all.all.js +3692 -538
- package/i18n/messages/all.all.json +3756 -577
- package/i18n/messages/all.de.js +317 -22
- package/i18n/messages/all.de.json +324 -27
- package/i18n/messages/all.en-GB.js +306 -21
- package/i18n/messages/all.en-GB.json +309 -24
- package/i18n/messages/all.en.js +11 -11
- package/i18n/messages/all.en.json +11 -11
- package/i18n/messages/all.es.js +311 -22
- package/i18n/messages/all.es.json +318 -25
- package/i18n/messages/all.fr.js +335 -27
- package/i18n/messages/all.fr.json +343 -30
- package/i18n/messages/all.id.js +319 -28
- package/i18n/messages/all.id.json +322 -31
- package/i18n/messages/all.it.js +320 -27
- package/i18n/messages/all.it.json +326 -30
- package/i18n/messages/all.ja.js +312 -28
- package/i18n/messages/all.ja.json +315 -30
- package/i18n/messages/all.ko.js +304 -24
- package/i18n/messages/all.ko.json +312 -25
- package/i18n/messages/all.pt-BR.js +313 -28
- package/i18n/messages/all.pt-BR.json +325 -31
- package/i18n/messages/all.zh-CN.js +301 -29
- package/i18n/messages/all.zh-CN.json +300 -31
- package/i18n/messages/all.zh-TW.js +295 -23
- package/i18n/messages/all.zh-TW.json +294 -25
- package/i18n/messages-types.d.ts +435 -0
- package/i18n/messages-types.d.ts.map +1 -0
- package/i18n/messages-types.js +5 -0
- package/i18n/messages-types.js.map +1 -0
- package/i18n/provider.js.map +1 -1
- package/internal/analytics/components/analytics-funnel.d.ts +2 -1
- package/internal/analytics/components/analytics-funnel.d.ts.map +1 -1
- package/internal/analytics/components/analytics-funnel.js +6 -4
- package/internal/analytics/components/analytics-funnel.js.map +1 -1
- package/internal/analytics/context/analytics-context.d.ts +2 -0
- package/internal/analytics/context/analytics-context.d.ts.map +1 -1
- package/internal/analytics/context/analytics-context.js +2 -0
- package/internal/analytics/context/analytics-context.js.map +1 -1
- package/internal/analytics/hooks/use-funnel.d.ts +3 -7
- package/internal/analytics/hooks/use-funnel.d.ts.map +1 -1
- package/internal/analytics/hooks/use-funnel.js +2 -7
- package/internal/analytics/hooks/use-funnel.js.map +1 -1
- package/internal/components/cartesian-chart/bottom-labels.js +1 -1
- package/internal/components/cartesian-chart/bottom-labels.js.map +1 -1
- package/internal/components/cartesian-chart/left-labels.js +1 -1
- package/internal/components/cartesian-chart/left-labels.js.map +1 -1
- package/internal/components/focus-lock/index.js +20 -19
- package/internal/components/focus-lock/index.js.map +1 -1
- package/internal/context/button-context.d.ts +10 -0
- package/internal/context/button-context.d.ts.map +1 -0
- package/internal/context/button-context.js +10 -0
- package/internal/context/button-context.js.map +1 -0
- package/internal/environment.js +1 -1
- package/internal/i18n/messages/all.all.js +3692 -538
- package/internal/i18n/messages/all.all.json +3756 -577
- package/internal/i18n/messages/all.de.js +317 -22
- package/internal/i18n/messages/all.de.json +324 -27
- package/internal/i18n/messages/all.en-GB.js +306 -21
- package/internal/i18n/messages/all.en-GB.json +309 -24
- package/internal/i18n/messages/all.en.js +11 -11
- package/internal/i18n/messages/all.en.json +11 -11
- package/internal/i18n/messages/all.es.js +311 -22
- package/internal/i18n/messages/all.es.json +318 -25
- package/internal/i18n/messages/all.fr.js +335 -27
- package/internal/i18n/messages/all.fr.json +343 -30
- package/internal/i18n/messages/all.id.js +319 -28
- package/internal/i18n/messages/all.id.json +322 -31
- package/internal/i18n/messages/all.it.js +320 -27
- package/internal/i18n/messages/all.it.json +326 -30
- package/internal/i18n/messages/all.ja.js +312 -28
- package/internal/i18n/messages/all.ja.json +315 -30
- package/internal/i18n/messages/all.ko.js +304 -24
- package/internal/i18n/messages/all.ko.json +312 -25
- package/internal/i18n/messages/all.pt-BR.js +313 -28
- package/internal/i18n/messages/all.pt-BR.json +325 -31
- package/internal/i18n/messages/all.zh-CN.js +301 -29
- package/internal/i18n/messages/all.zh-CN.json +300 -31
- package/internal/i18n/messages/all.zh-TW.js +295 -23
- package/internal/i18n/messages/all.zh-TW.json +294 -25
- package/internal/manifest.json +1 -1
- package/package.json +1 -2
- package/pagination/internal.d.ts.map +1 -1
- package/pagination/internal.js +4 -4
- package/pagination/internal.js.map +1 -1
- package/pie-chart/utils.d.ts +1 -1
- package/pie-chart/utils.d.ts.map +1 -1
- package/pie-chart/utils.js.map +1 -1
- package/property-filter/index.d.ts.map +1 -1
- package/property-filter/index.js +1 -1
- package/property-filter/index.js.map +1 -1
- package/s3-resource-selector/interfaces.d.ts +3 -0
- package/s3-resource-selector/interfaces.d.ts.map +1 -1
- package/s3-resource-selector/interfaces.js.map +1 -1
- package/s3-resource-selector/s3-in-context/index.js +1 -1
- package/s3-resource-selector/s3-in-context/index.js.map +1 -1
- package/s3-resource-selector/s3-in-context/validation.d.ts +1 -1
- package/s3-resource-selector/s3-in-context/validation.d.ts.map +1 -1
- package/s3-resource-selector/s3-in-context/validation.js.map +1 -1
- package/s3-resource-selector/s3-modal/basic-table.d.ts +3 -1
- package/s3-resource-selector/s3-modal/basic-table.d.ts.map +1 -1
- package/s3-resource-selector/s3-modal/basic-table.js +2 -1
- package/s3-resource-selector/s3-modal/basic-table.js.map +1 -1
- package/s3-resource-selector/s3-modal/index.js +1 -1
- package/s3-resource-selector/s3-modal/index.js.map +1 -1
- package/s3-resource-selector/s3-modal/table-utils.d.ts +1 -1
- package/s3-resource-selector/s3-modal/table-utils.d.ts.map +1 -1
- package/s3-resource-selector/s3-modal/table-utils.js.map +1 -1
- package/select/parts/filter.d.ts +1 -1
- package/space-between/interfaces.d.ts +5 -0
- package/space-between/interfaces.d.ts.map +1 -1
- package/space-between/interfaces.js.map +1 -1
- package/space-between/internal.d.ts +1 -1
- package/space-between/internal.d.ts.map +1 -1
- package/space-between/internal.js +2 -2
- package/space-between/internal.js.map +1 -1
- package/space-between/styles.css.js +21 -20
- package/space-between/styles.scoped.css +25 -21
- package/space-between/styles.selectors.js +21 -20
- package/tag-editor/interfaces.d.ts +1 -0
- package/tag-editor/interfaces.d.ts.map +1 -1
- package/tag-editor/interfaces.js.map +1 -1
- package/tag-editor/validation.d.ts +1 -1
- package/tag-editor/validation.d.ts.map +1 -1
- package/tag-editor/validation.js.map +1 -1
- package/top-navigation/parts/overflow-menu/views/submenu.js +2 -2
- package/top-navigation/parts/overflow-menu/views/submenu.js.map +1 -1
- package/top-navigation/parts/overflow-menu/views/utilities.js +2 -2
- package/top-navigation/parts/overflow-menu/views/utilities.js.map +1 -1
- package/wizard/internal.d.ts.map +1 -1
- package/wizard/internal.js +4 -2
- package/wizard/internal.js.map +1 -1
- package/wizard/wizard-form.d.ts.map +1 -1
- package/wizard/wizard-form.js +1 -2
- package/wizard/wizard-form.js.map +1 -1
package/button/internal.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ButtonProps } from './interfaces';
|
|
3
3
|
import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
|
|
4
|
+
export type InternalButtonProps = Omit<ButtonProps, 'variant'> & {
|
|
5
|
+
variant?: ButtonProps['variant'] | 'flashbar-icon' | 'breadcrumb-group' | 'menu-trigger' | 'modal-dismiss';
|
|
6
|
+
__nativeAttributes?: Record<string, any>;
|
|
7
|
+
__iconClass?: string;
|
|
8
|
+
__activated?: boolean;
|
|
9
|
+
} & InternalBaseComponentProps;
|
|
4
10
|
export declare const InternalButton: React.ForwardRefExoticComponent<Omit<ButtonProps, "variant"> & {
|
|
5
11
|
variant?: ButtonProps['variant'] | 'flashbar-icon' | 'breadcrumb-group' | 'menu-trigger' | 'modal-dismiss';
|
|
6
12
|
__nativeAttributes?: Record<string, any> | undefined;
|
package/button/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["button/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["button/internal.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAKtC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAMlF,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG;IAC/D,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG,eAAe,GAAG,kBAAkB,GAAG,cAAc,GAAG,eAAe,CAAC;IAC3G,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,0BAA0B,CAAC;AAE/B,eAAO,MAAM,cAAc;cANf,WAAW,CAAC,SAAS,CAAC,GAAG,eAAe,GAAG,kBAAkB,GAAG,cAAc,GAAG,eAAe;;;;sEAyI3G,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
package/button/internal.js
CHANGED
|
@@ -2,7 +2,7 @@ import { __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, {
|
|
5
|
+
import React, { useRef } from 'react';
|
|
6
6
|
import { fireCancelableEvent, isPlainLeftClick } from '../internal/events';
|
|
7
7
|
import useForwardFocus from '../internal/hooks/forward-focus';
|
|
8
8
|
import styles from './styles.css.js';
|
|
@@ -10,7 +10,7 @@ import { LeftIcon, RightIcon } from './icon-helper';
|
|
|
10
10
|
import { checkSafeUrl } from '../internal/utils/check-safe-url';
|
|
11
11
|
import { useMergeRefs } from '../internal/hooks/use-merge-refs';
|
|
12
12
|
import LiveRegion from '../internal/components/live-region';
|
|
13
|
-
import {
|
|
13
|
+
import { useButtonContext } from '../internal/context/button-context';
|
|
14
14
|
export const InternalButton = React.forwardRef((_a, ref) => {
|
|
15
15
|
var { children, iconName, __iconClass, onClick, onFollow, iconAlign = 'left', iconUrl, iconSvg, iconAlt, variant = 'normal', loading = false, loadingText, disabled = false, wrapText = true, href, target, rel, download, formAction = 'submit', ariaLabel, ariaDescribedby, ariaExpanded, fullWidth, __nativeAttributes, __internalRootRef = null, __activated = false } = _a, props = __rest(_a, ["children", "iconName", "__iconClass", "onClick", "onFollow", "iconAlign", "iconUrl", "iconSvg", "iconAlt", "variant", "loading", "loadingText", "disabled", "wrapText", "href", "target", "rel", "download", "formAction", "ariaLabel", "ariaDescribedby", "ariaExpanded", "fullWidth", "__nativeAttributes", "__internalRootRef", "__activated"]);
|
|
16
16
|
checkSafeUrl('Button', href);
|
|
@@ -19,20 +19,18 @@ export const InternalButton = React.forwardRef((_a, ref) => {
|
|
|
19
19
|
const shouldHaveContent = children && ['icon', 'inline-icon', 'flashbar-icon', 'modal-dismiss'].indexOf(variant) === -1;
|
|
20
20
|
const buttonRef = useRef(null);
|
|
21
21
|
useForwardFocus(ref, buttonRef);
|
|
22
|
-
const
|
|
23
|
-
const handleClick =
|
|
22
|
+
const buttonContext = useButtonContext();
|
|
23
|
+
const handleClick = (event) => {
|
|
24
24
|
if (isNotInteractive) {
|
|
25
25
|
return event.preventDefault();
|
|
26
26
|
}
|
|
27
27
|
if (isAnchor && isPlainLeftClick(event)) {
|
|
28
28
|
fireCancelableEvent(onFollow, { href, target }, event);
|
|
29
29
|
}
|
|
30
|
-
if (funnelInteractionId && variant === 'primary') {
|
|
31
|
-
funnelSubmit();
|
|
32
|
-
}
|
|
33
30
|
const { altKey, button, ctrlKey, metaKey, shiftKey } = event;
|
|
34
31
|
fireCancelableEvent(onClick, { altKey, button, ctrlKey, metaKey, shiftKey }, event);
|
|
35
|
-
|
|
32
|
+
buttonContext.onClick({ variant });
|
|
33
|
+
};
|
|
36
34
|
const buttonClass = clsx(props.className, styles.button, styles[`variant-${variant}`], {
|
|
37
35
|
[styles.disabled]: isNotInteractive,
|
|
38
36
|
[styles['button-no-wrap']]: !wrapText,
|
package/button/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["button/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":"lib/default/","sources":["button/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,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAmB,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGrE,OAAO,EAAE,YAAY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QACR,OAAO,IAAI,WAAW,IAAI,oBAAC,UAAU,QAAE,WAAW,CAAc,CAChE,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,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 { fireCancelableEvent, isPlainLeftClick } from '../internal/events';\nimport useForwardFocus from '../internal/hooks/forward-focus';\nimport styles from './styles.css.js';\nimport { ButtonIconProps, LeftIcon, RightIcon } from './icon-helper';\nimport { ButtonProps } from './interfaces';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport LiveRegion from '../internal/components/live-region';\nimport { useButtonContext } from '../internal/context/button-context';\n\nexport type InternalButtonProps = Omit<ButtonProps, 'variant'> & {\n variant?: ButtonProps['variant'] | 'flashbar-icon' | 'breadcrumb-group' | 'menu-trigger' | 'modal-dismiss';\n __nativeAttributes?: Record<string, any>;\n __iconClass?: string;\n __activated?: boolean;\n} & InternalBaseComponentProps;\n\nexport const InternalButton = React.forwardRef(\n (\n {\n children,\n iconName,\n __iconClass,\n onClick,\n onFollow,\n iconAlign = 'left',\n iconUrl,\n iconSvg,\n iconAlt,\n variant = 'normal',\n loading = false,\n loadingText,\n disabled = false,\n wrapText = true,\n href,\n target,\n rel,\n download,\n formAction = 'submit',\n ariaLabel,\n ariaDescribedby,\n ariaExpanded,\n fullWidth,\n __nativeAttributes,\n __internalRootRef = null,\n __activated = false,\n ...props\n }: InternalButtonProps,\n ref: React.Ref<ButtonProps.Ref>\n ) => {\n checkSafeUrl('Button', href);\n const isAnchor = Boolean(href);\n const isNotInteractive = loading || disabled;\n const shouldHaveContent =\n children && ['icon', 'inline-icon', 'flashbar-icon', 'modal-dismiss'].indexOf(variant) === -1;\n\n const buttonRef = useRef<HTMLElement>(null);\n useForwardFocus(ref, buttonRef);\n\n const buttonContext = useButtonContext();\n\n const handleClick = (event: React.MouseEvent) => {\n if (isNotInteractive) {\n return event.preventDefault();\n }\n\n if (isAnchor && isPlainLeftClick(event)) {\n fireCancelableEvent(onFollow, { href, target }, event);\n }\n\n const { altKey, button, ctrlKey, metaKey, shiftKey } = event;\n fireCancelableEvent(onClick, { altKey, button, ctrlKey, metaKey, shiftKey }, event);\n buttonContext.onClick({ variant });\n };\n\n const buttonClass = clsx(props.className, styles.button, styles[`variant-${variant}`], {\n [styles.disabled]: isNotInteractive,\n [styles['button-no-wrap']]: !wrapText,\n [styles['button-no-text']]: !shouldHaveContent,\n [styles['is-activated']]: __activated,\n [styles['full-width']]: shouldHaveContent && fullWidth,\n });\n\n const buttonProps = {\n ...props,\n ...__nativeAttributes,\n // https://github.com/microsoft/TypeScript/issues/36659\n ref: useMergeRefs(buttonRef as any, __internalRootRef),\n 'aria-label': ariaLabel,\n 'aria-describedby': ariaDescribedby,\n 'aria-expanded': ariaExpanded,\n className: buttonClass,\n onClick: handleClick,\n } as const;\n const iconProps: ButtonIconProps = {\n loading,\n iconName,\n iconAlign,\n iconUrl,\n iconSvg,\n iconAlt,\n variant,\n iconClass: __iconClass,\n iconSize: variant === 'modal-dismiss' ? 'medium' : 'normal',\n };\n const buttonContent = (\n <>\n <LeftIcon {...iconProps} />\n {shouldHaveContent && <span className={styles.content}>{children}</span>}\n <RightIcon {...iconProps} />\n </>\n );\n\n if (isAnchor) {\n return (\n // https://github.com/yannickcr/eslint-plugin-react/issues/2962\n // eslint-disable-next-line react/jsx-no-target-blank\n <>\n <a\n {...buttonProps}\n href={href}\n target={target}\n // security recommendation: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target\n rel={rel ?? (target === '_blank' ? 'noopener noreferrer' : undefined)}\n tabIndex={isNotInteractive ? -1 : undefined}\n aria-disabled={isNotInteractive ? true : undefined}\n download={download}\n >\n {buttonContent}\n </a>\n {loading && loadingText && <LiveRegion>{loadingText}</LiveRegion>}\n </>\n );\n }\n return (\n <>\n <button\n {...buttonProps}\n type={formAction === 'none' ? 'button' : 'submit'}\n disabled={disabled}\n aria-disabled={loading && !disabled ? true : undefined}\n >\n {buttonContent}\n </button>\n {loading && loadingText && <LiveRegion>{loadingText}</LiveRegion>}\n </>\n );\n }\n);\n\nexport default InternalButton;\n"]}
|
|
@@ -33,7 +33,7 @@ export default function ContentDisplayPreference({ title, description, options,
|
|
|
33
33
|
const announcements = useLiveAnnouncements({
|
|
34
34
|
isDragging: activeItem !== null,
|
|
35
35
|
liveAnnouncementDndStarted: i18n('contentDisplayPreference.liveAnnouncementDndStarted', liveAnnouncementDndStarted, format => (position, total) => format({ position, total })),
|
|
36
|
-
liveAnnouncementDndItemReordered: i18n('contentDisplayPreference.liveAnnouncementDndItemReordered', liveAnnouncementDndItemReordered, format => (initialPosition, currentPosition, total) => format({
|
|
36
|
+
liveAnnouncementDndItemReordered: i18n('contentDisplayPreference.liveAnnouncementDndItemReordered', liveAnnouncementDndItemReordered, format => (initialPosition, currentPosition, total) => format({ currentPosition, total, isInitialPosition: `${initialPosition === currentPosition}` })),
|
|
37
37
|
liveAnnouncementDndItemCommitted: i18n('contentDisplayPreference.liveAnnouncementDndItemCommitted', liveAnnouncementDndItemCommitted, format => (initialPosition, finalPosition, total) => format({ initialPosition, finalPosition, total, isInitialPosition: `${initialPosition === finalPosition}` })),
|
|
38
38
|
liveAnnouncementDndDiscarded: i18n('contentDisplayPreference.liveAnnouncementDndDiscarded', liveAnnouncementDndDiscarded),
|
|
39
39
|
sortedOptions: value,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["collection-preferences/content-display/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAGjE,OAAO,M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C,EAAE,mBAAmB,CAAC,EAC9F,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,YAAY,GACpB,CACH,CACW,CACP,CACE,CACT,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { useUniqueId } from '../../internal/hooks/use-unique-id';\n\nimport { CollectionPreferencesProps } from '../interfaces';\nimport styles from '../styles.css.js';\nimport { getSortedOptions, OptionWithVisibility } from './utils';\nimport { DndContext, DragOverlay } from '@dnd-kit/core';\nimport { arrayMove, SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';\nimport DraggableOption from './draggable-option';\nimport useDragAndDropReorder from './use-drag-and-drop-reorder';\nimport useLiveAnnouncements from './use-live-announcements';\nimport Portal from '../../internal/components/portal';\nimport ContentDisplayOption from './content-display-option';\nimport { useInternalI18n } from '../../internal/i18n/context';\n\nconst componentPrefix = 'content-display';\n\nconst getClassName = (suffix: string) => styles[`${componentPrefix}-${suffix}`];\n\ninterface ContentDisplayPreferenceProps extends CollectionPreferencesProps.ContentDisplayPreference {\n onChange: (value: ReadonlyArray<CollectionPreferencesProps.ContentDisplayItem>) => void;\n value?: ReadonlyArray<CollectionPreferencesProps.ContentDisplayItem>;\n}\n\nexport default function ContentDisplayPreference({\n title,\n description,\n options,\n value = options.map(({ id }) => ({\n id,\n visible: true,\n })),\n onChange,\n liveAnnouncementDndStarted,\n liveAnnouncementDndItemReordered,\n liveAnnouncementDndItemCommitted,\n liveAnnouncementDndDiscarded,\n dragHandleAriaDescription,\n dragHandleAriaLabel,\n}: ContentDisplayPreferenceProps) {\n const idPrefix = useUniqueId(componentPrefix);\n const i18n = useInternalI18n('collection-preferences');\n\n const onToggle = (option: OptionWithVisibility) => {\n onChange(value.map(item => (item.id === option.id ? { ...item, visible: !option.visible } : item)));\n };\n\n const titleId = `${idPrefix}-title`;\n const descriptionId = `${idPrefix}-description`;\n\n const sortedOptions = getSortedOptions({ options, contentDisplay: value });\n\n const { activeItem, collisionDetection, handleKeyDown, sensors, setActiveItem } = useDragAndDropReorder({\n sortedOptions,\n });\n\n const activeOption = activeItem ? sortedOptions.find(({ id }) => id === activeItem) : null;\n\n const announcements = useLiveAnnouncements({\n isDragging: activeItem !== null,\n liveAnnouncementDndStarted: i18n(\n 'contentDisplayPreference.liveAnnouncementDndStarted',\n liveAnnouncementDndStarted,\n format => (position, total) => format({ position, total })\n ),\n liveAnnouncementDndItemReordered: i18n(\n 'contentDisplayPreference.liveAnnouncementDndItemReordered',\n liveAnnouncementDndItemReordered,\n format => (initialPosition, currentPosition, total) =>\n format({ initialPosition, currentPosition, total, isInitialPosition: `${initialPosition === currentPosition}` })\n ),\n liveAnnouncementDndItemCommitted: i18n(\n 'contentDisplayPreference.liveAnnouncementDndItemCommitted',\n liveAnnouncementDndItemCommitted,\n format => (initialPosition, finalPosition, total) =>\n format({ initialPosition, finalPosition, total, isInitialPosition: `${initialPosition === finalPosition}` })\n ),\n liveAnnouncementDndDiscarded: i18n(\n 'contentDisplayPreference.liveAnnouncementDndDiscarded',\n liveAnnouncementDndDiscarded\n ),\n sortedOptions: value,\n });\n\n const renderedDragHandleAriaDescription = i18n(\n 'contentDisplayPreference.dragHandleAriaDescription',\n dragHandleAriaDescription\n );\n\n return (\n <div className={styles[componentPrefix]}>\n <h3 className={getClassName('title')} id={titleId}>\n {i18n('contentDisplayPreference.title', title)}\n </h3>\n <p className={getClassName('description')} id={descriptionId}>\n {i18n('contentDisplayPreference.description', description)}\n </p>\n <DndContext\n sensors={sensors}\n collisionDetection={collisionDetection}\n accessibility={{\n announcements,\n restoreFocus: false,\n screenReaderInstructions: renderedDragHandleAriaDescription\n ? { draggable: renderedDragHandleAriaDescription }\n : undefined,\n }}\n onDragStart={({ active }) => setActiveItem(active.id)}\n onDragEnd={event => {\n setActiveItem(null);\n const { active, over } = event;\n\n if (over && active.id !== over.id) {\n const oldIndex = value.findIndex(({ id }) => id === active.id);\n const newIndex = value.findIndex(({ id }) => id === over.id);\n onChange(arrayMove([...value], oldIndex, newIndex));\n }\n }}\n onDragCancel={() => setActiveItem(null)}\n >\n {/* Use explicit list role to work around Safari not announcing lists as such when list-style is set to none.\n See https://bugs.webkit.org/show_bug.cgi?id=170179 */}\n <ul\n className={getClassName('option-list')}\n aria-describedby={descriptionId}\n aria-labelledby={titleId}\n role=\"list\"\n >\n <SortableContext items={sortedOptions.map(({ id }) => id)} strategy={verticalListSortingStrategy}>\n {sortedOptions.map(option => {\n return (\n <DraggableOption\n dragHandleAriaLabel={i18n('contentDisplayPreference.dragHandleAriaLabel', dragHandleAriaLabel)}\n key={option.id}\n onKeyDown={handleKeyDown}\n onToggle={onToggle}\n option={option}\n />\n );\n })}\n </SortableContext>\n </ul>\n <Portal>\n {/* Make sure that the drag overlay is above the modal\n by assigning the z-index as inline style\n so that it prevails over dnd-kit's inline z-index of 999 */}\n {/* className is a documented prop of the DragOverlay component:\n https://docs.dndkit.com/api-documentation/draggable/drag-overlay#class-name-and-inline-styles */\n /* eslint-disable-next-line react/forbid-component-props */}\n <DragOverlay className={styles['drag-overlay']} dropAnimation={null} style={{ zIndex: 5000 }}>\n {activeOption && (\n <ContentDisplayOption\n listeners={{ onKeyDown: handleKeyDown }}\n dragHandleAriaLabel={i18n('contentDisplayPreference.dragHandleAriaLabel', dragHandleAriaLabel)}\n onToggle={onToggle}\n option={activeOption}\n />\n )}\n </DragOverlay>\n </Portal>\n </DndContext>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["collection-preferences/content-display/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAGjE,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAwB,MAAM,SAAS,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H,CACW,CACP,CACE,CACT,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { useUniqueId } from '../../internal/hooks/use-unique-id';\n\nimport { CollectionPreferencesProps } from '../interfaces';\nimport styles from '../styles.css.js';\nimport { getSortedOptions, OptionWithVisibility } from './utils';\nimport { DndContext, DragOverlay } from '@dnd-kit/core';\nimport { arrayMove, SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';\nimport DraggableOption from './draggable-option';\nimport useDragAndDropReorder from './use-drag-and-drop-reorder';\nimport useLiveAnnouncements from './use-live-announcements';\nimport Portal from '../../internal/components/portal';\nimport ContentDisplayOption from './content-display-option';\nimport { useInternalI18n } from '../../internal/i18n/context';\n\nconst componentPrefix = 'content-display';\n\nconst getClassName = (suffix: string) => styles[`${componentPrefix}-${suffix}`];\n\ninterface ContentDisplayPreferenceProps extends CollectionPreferencesProps.ContentDisplayPreference {\n onChange: (value: ReadonlyArray<CollectionPreferencesProps.ContentDisplayItem>) => void;\n value?: ReadonlyArray<CollectionPreferencesProps.ContentDisplayItem>;\n}\n\nexport default function ContentDisplayPreference({\n title,\n description,\n options,\n value = options.map(({ id }) => ({\n id,\n visible: true,\n })),\n onChange,\n liveAnnouncementDndStarted,\n liveAnnouncementDndItemReordered,\n liveAnnouncementDndItemCommitted,\n liveAnnouncementDndDiscarded,\n dragHandleAriaDescription,\n dragHandleAriaLabel,\n}: ContentDisplayPreferenceProps) {\n const idPrefix = useUniqueId(componentPrefix);\n const i18n = useInternalI18n('collection-preferences');\n\n const onToggle = (option: OptionWithVisibility) => {\n onChange(value.map(item => (item.id === option.id ? { ...item, visible: !option.visible } : item)));\n };\n\n const titleId = `${idPrefix}-title`;\n const descriptionId = `${idPrefix}-description`;\n\n const sortedOptions = getSortedOptions({ options, contentDisplay: value });\n\n const { activeItem, collisionDetection, handleKeyDown, sensors, setActiveItem } = useDragAndDropReorder({\n sortedOptions,\n });\n\n const activeOption = activeItem ? sortedOptions.find(({ id }) => id === activeItem) : null;\n\n const announcements = useLiveAnnouncements({\n isDragging: activeItem !== null,\n liveAnnouncementDndStarted: i18n(\n 'contentDisplayPreference.liveAnnouncementDndStarted',\n liveAnnouncementDndStarted,\n format => (position, total) => format({ position, total })\n ),\n liveAnnouncementDndItemReordered: i18n(\n 'contentDisplayPreference.liveAnnouncementDndItemReordered',\n liveAnnouncementDndItemReordered,\n format => (initialPosition, currentPosition, total) =>\n format({ currentPosition, total, isInitialPosition: `${initialPosition === currentPosition}` })\n ),\n liveAnnouncementDndItemCommitted: i18n(\n 'contentDisplayPreference.liveAnnouncementDndItemCommitted',\n liveAnnouncementDndItemCommitted,\n format => (initialPosition, finalPosition, total) =>\n format({ initialPosition, finalPosition, total, isInitialPosition: `${initialPosition === finalPosition}` })\n ),\n liveAnnouncementDndDiscarded: i18n(\n 'contentDisplayPreference.liveAnnouncementDndDiscarded',\n liveAnnouncementDndDiscarded\n ),\n sortedOptions: value,\n });\n\n const renderedDragHandleAriaDescription = i18n(\n 'contentDisplayPreference.dragHandleAriaDescription',\n dragHandleAriaDescription\n );\n\n return (\n <div className={styles[componentPrefix]}>\n <h3 className={getClassName('title')} id={titleId}>\n {i18n('contentDisplayPreference.title', title)}\n </h3>\n <p className={getClassName('description')} id={descriptionId}>\n {i18n('contentDisplayPreference.description', description)}\n </p>\n <DndContext\n sensors={sensors}\n collisionDetection={collisionDetection}\n accessibility={{\n announcements,\n restoreFocus: false,\n screenReaderInstructions: renderedDragHandleAriaDescription\n ? { draggable: renderedDragHandleAriaDescription }\n : undefined,\n }}\n onDragStart={({ active }) => setActiveItem(active.id)}\n onDragEnd={event => {\n setActiveItem(null);\n const { active, over } = event;\n\n if (over && active.id !== over.id) {\n const oldIndex = value.findIndex(({ id }) => id === active.id);\n const newIndex = value.findIndex(({ id }) => id === over.id);\n onChange(arrayMove([...value], oldIndex, newIndex));\n }\n }}\n onDragCancel={() => setActiveItem(null)}\n >\n {/* Use explicit list role to work around Safari not announcing lists as such when list-style is set to none.\n See https://bugs.webkit.org/show_bug.cgi?id=170179 */}\n <ul\n className={getClassName('option-list')}\n aria-describedby={descriptionId}\n aria-labelledby={titleId}\n role=\"list\"\n >\n <SortableContext items={sortedOptions.map(({ id }) => id)} strategy={verticalListSortingStrategy}>\n {sortedOptions.map(option => {\n return (\n <DraggableOption\n dragHandleAriaLabel={i18n('contentDisplayPreference.dragHandleAriaLabel', dragHandleAriaLabel)}\n key={option.id}\n onKeyDown={handleKeyDown}\n onToggle={onToggle}\n option={option}\n />\n );\n })}\n </SortableContext>\n </ul>\n <Portal>\n {/* Make sure that the drag overlay is above the modal\n by assigning the z-index as inline style\n so that it prevails over dnd-kit's inline z-index of 999 */}\n {/* className is a documented prop of the DragOverlay component:\n https://docs.dndkit.com/api-documentation/draggable/drag-overlay#class-name-and-inline-styles */\n /* eslint-disable-next-line react/forbid-component-props */}\n <DragOverlay className={styles['drag-overlay']} dropAnimation={null} style={{ zIndex: 5000 }}>\n {activeOption && (\n <ContentDisplayOption\n listeners={{ onKeyDown: handleKeyDown }}\n dragHandleAriaLabel={i18n('contentDisplayPreference.dragHandleAriaLabel', dragHandleAriaLabel)}\n onToggle={onToggle}\n option={activeOption}\n />\n )}\n </DragOverlay>\n </Portal>\n </DndContext>\n </div>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["date-range-picker/calendar/header/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["date-range-picker/calendar/header/index.tsx"],"names":[],"mappings":";AAUA,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,IAAI,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACpC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,QAAQ,EACR,MAAM,EACN,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,eAAe,GAChB,EAAE,mBAAmB,eAgCrB"}
|
|
@@ -6,16 +6,18 @@ import styles from '../../styles.css.js';
|
|
|
6
6
|
import { renderMonthAndYear } from '../../../calendar/utils/intl';
|
|
7
7
|
import { PrevMonthButton, NextMonthButton } from './header-button';
|
|
8
8
|
import LiveRegion from '../../../internal/components/live-region';
|
|
9
|
+
import { useInternalI18n } from '../../../i18n/context.js';
|
|
9
10
|
export default function CalendarHeader({ baseDate, locale, onChangeMonth, previousMonthLabel, nextMonthLabel, isSingleGrid, headingIdPrefix, }) {
|
|
11
|
+
const i18n = useInternalI18n('calendar');
|
|
10
12
|
const prevMonthLabel = renderMonthAndYear(locale, add(baseDate, { months: -1 }));
|
|
11
13
|
const currentMonthLabel = renderMonthAndYear(locale, baseDate);
|
|
12
14
|
return (React.createElement(React.Fragment, null,
|
|
13
15
|
React.createElement("div", { className: styles['calendar-header'] },
|
|
14
|
-
React.createElement(PrevMonthButton, { ariaLabel: previousMonthLabel, baseDate: baseDate, onChangeMonth: onChangeMonth }),
|
|
16
|
+
React.createElement(PrevMonthButton, { ariaLabel: i18n('previousMonthAriaLabel', previousMonthLabel), baseDate: baseDate, onChangeMonth: onChangeMonth }),
|
|
15
17
|
React.createElement("h2", { className: styles['calendar-header-months-wrapper'] },
|
|
16
18
|
!isSingleGrid && (React.createElement("span", { className: styles['calendar-header-month'], id: `${headingIdPrefix}-prevmonth` }, prevMonthLabel)),
|
|
17
19
|
React.createElement("span", { className: styles['calendar-header-month'], id: `${headingIdPrefix}-currentmonth` }, currentMonthLabel)),
|
|
18
|
-
React.createElement(NextMonthButton, { ariaLabel: nextMonthLabel, baseDate: baseDate, onChangeMonth: onChangeMonth })),
|
|
20
|
+
React.createElement(NextMonthButton, { ariaLabel: i18n('nextMonthAriaLabel', nextMonthLabel), baseDate: baseDate, onChangeMonth: onChangeMonth })),
|
|
19
21
|
React.createElement(LiveRegion, null, isSingleGrid ? currentMonthLabel : `${prevMonthLabel}, ${currentMonthLabel}`)));
|
|
20
22
|
}
|
|
21
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["date-range-picker/calendar/header/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,UAAU,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["date-range-picker/calendar/header/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,UAAU,MAAM,0CAA0C,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAY3D,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,QAAQ,EACR,MAAM,EACN,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,eAAe,GACK;IACpB,MAAM,IAAI,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;IACzC,MAAM,cAAc,GAAG,kBAAkB,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjF,MAAM,iBAAiB,GAAG,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAE/D,OAAO,CACL;QACE,6BAAK,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC;YACvC,oBAAC,eAAe,IACd,SAAS,EAAE,IAAI,CAAC,wBAAwB,EAAE,kBAAkB,CAAC,EAC7D,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,aAAa,GAC5B;YACF,4BAAI,SAAS,EAAE,MAAM,CAAC,gCAAgC,CAAC;gBACpD,CAAC,YAAY,IAAI,CAChB,8BAAM,SAAS,EAAE,MAAM,CAAC,uBAAuB,CAAC,EAAE,EAAE,EAAE,GAAG,eAAe,YAAY,IACjF,cAAc,CACV,CACR;gBACD,8BAAM,SAAS,EAAE,MAAM,CAAC,uBAAuB,CAAC,EAAE,EAAE,EAAE,GAAG,eAAe,eAAe,IACpF,iBAAiB,CACb,CACJ;YACL,oBAAC,eAAe,IACd,SAAS,EAAE,IAAI,CAAC,oBAAoB,EAAE,cAAc,CAAC,EACrD,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,aAAa,GAC5B,CACE;QACN,oBAAC,UAAU,QAAE,YAAY,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,cAAc,KAAK,iBAAiB,EAAE,CAAc,CACtG,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { add } from 'date-fns';\nimport React from 'react';\nimport styles from '../../styles.css.js';\nimport { renderMonthAndYear } from '../../../calendar/utils/intl';\nimport { PrevMonthButton, NextMonthButton } from './header-button';\nimport LiveRegion from '../../../internal/components/live-region';\nimport { useInternalI18n } from '../../../i18n/context.js';\n\ninterface CalendarHeaderProps {\n baseDate: Date;\n locale: string;\n onChangeMonth: (date: Date) => void;\n previousMonthLabel?: string;\n nextMonthLabel?: string;\n isSingleGrid: boolean;\n headingIdPrefix: string;\n}\n\nexport default function CalendarHeader({\n baseDate,\n locale,\n onChangeMonth,\n previousMonthLabel,\n nextMonthLabel,\n isSingleGrid,\n headingIdPrefix,\n}: CalendarHeaderProps) {\n const i18n = useInternalI18n('calendar');\n const prevMonthLabel = renderMonthAndYear(locale, add(baseDate, { months: -1 }));\n const currentMonthLabel = renderMonthAndYear(locale, baseDate);\n\n return (\n <>\n <div className={styles['calendar-header']}>\n <PrevMonthButton\n ariaLabel={i18n('previousMonthAriaLabel', previousMonthLabel)}\n baseDate={baseDate}\n onChangeMonth={onChangeMonth}\n />\n <h2 className={styles['calendar-header-months-wrapper']}>\n {!isSingleGrid && (\n <span className={styles['calendar-header-month']} id={`${headingIdPrefix}-prevmonth`}>\n {prevMonthLabel}\n </span>\n )}\n <span className={styles['calendar-header-month']} id={`${headingIdPrefix}-currentmonth`}>\n {currentMonthLabel}\n </span>\n </h2>\n <NextMonthButton\n ariaLabel={i18n('nextMonthAriaLabel', nextMonthLabel)}\n baseDate={baseDate}\n onChangeMonth={onChangeMonth}\n />\n </div>\n <LiveRegion>{isSingleGrid ? currentMonthLabel : `${prevMonthLabel}, ${currentMonthLabel}`}</LiveRegion>\n </>\n );\n}\n"]}
|
|
@@ -158,7 +158,7 @@ export default function DateRangePickerCalendar({ value, setValue, locale = '',
|
|
|
158
158
|
React.createElement("div", { className: clsx(styles.calendar, {
|
|
159
159
|
[styles['one-grid']]: isSingleGrid,
|
|
160
160
|
}) },
|
|
161
|
-
React.createElement(CalendarHeader, { baseDate: currentMonth, locale: normalizedLocale, onChangeMonth: onHeaderChangeMonthHandler, previousMonthLabel:
|
|
161
|
+
React.createElement(CalendarHeader, { baseDate: currentMonth, locale: normalizedLocale, onChangeMonth: onHeaderChangeMonthHandler, previousMonthLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.previousMonthAriaLabel, nextMonthLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.nextMonthAriaLabel, isSingleGrid: isSingleGrid, headingIdPrefix: headingIdPrefix }),
|
|
162
162
|
React.createElement(Grids, { isSingleGrid: isSingleGrid, locale: normalizedLocale, baseDate: currentMonth, focusedDate: focusedDate, onFocusedDateChange: setFocusedDate, isDateEnabled: isDateEnabled, onSelectDate: onSelectDateHandler, onChangeMonth: setCurrentMonth, startOfWeek: normalizedStartOfWeek, todayAriaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.todayAriaLabel, selectedStartDate: parseDate(value.start.date, true), selectedEndDate: parseDate(value.end.date, true), headingIdPrefix: headingIdPrefix })),
|
|
163
163
|
React.createElement(RangeInputs, { startDate: value.start.date, onChangeStartDate: onChangeStartDate, startTime: value.start.time, onChangeStartTime: value => setValue(oldValue => (Object.assign(Object.assign({}, oldValue), { start: Object.assign(Object.assign({}, oldValue.start), { time: value }) }))), endDate: value.end.date, onChangeEndDate: value => setValue(oldValue => (Object.assign(Object.assign({}, oldValue), { end: Object.assign(Object.assign({}, oldValue.end), { date: value }) }))), endTime: value.end.time, onChangeEndTime: value => setValue(oldValue => (Object.assign(Object.assign({}, oldValue), { end: Object.assign(Object.assign({}, oldValue.end), { time: value }) }))), i18nStrings: i18nStrings, dateOnly: dateOnly, timeInputFormat: timeInputFormat }),
|
|
164
164
|
customAbsoluteRangeControl && React.createElement("div", null, customAbsoluteRangeControl(value, interceptedSetValue)))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["date-range-picker/calendar/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,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AQ,CAAC,QAAQ,CAAC,EAAE,CAAC,iCAAM,QAAQ,KAAE,KAAK,kCAAO,QAAQ,CAAC,KAAK,KAAE,IAAI,EAAE,KAAK,OAAK,CAAC,EAEpF,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EACvB,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,iCAAM,QAAQ,KAAE,GAAG,kCAAO,QAAQ,CAAC,GAAG,KAAE,IAAI,EAAE,KAAK,OAAK,CAAC,EACxG,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EACvB,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,iCAAM,QAAQ,KAAE,GAAG,kCAAO,QAAQ,CAAC,GAAG,KAAE,IAAI,EAAE,KAAK,OAAK,CAAC,EACxG,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,GAChC;gBACD,0BAA0B,IAAI,iCAAM,0BAA0B,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAO,CACrF,CACX;QACN,oBAAC,UAAU,IAAC,SAAS,EAAE,MAAM,CAAC,oBAAoB,CAAC,IAAG,YAAY,CAAc,CAC/E,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useState } from 'react';\nimport { addMonths, endOfDay, isAfter, isBefore, isSameMonth, startOfDay, startOfMonth } from 'date-fns';\nimport styles from '../styles.css.js';\nimport SpaceBetween from '../../space-between/internal';\nimport { BaseComponentProps } from '../../internal/base-component';\nimport { DateRangePickerProps, RangeCalendarI18nStrings } from '../interfaces';\nimport CalendarHeader from './header';\nimport { Grids } from './grids';\nimport { TimeInputProps } from '../../time-input/interfaces';\nimport clsx from 'clsx';\nimport { useUniqueId } from '../../internal/hooks/use-unique-id';\nimport { getDateLabel, renderTimeLabel } from '../../calendar/utils/intl';\nimport LiveRegion from '../../internal/components/live-region';\nimport { normalizeLocale, normalizeStartOfWeek } from '../../internal/utils/locale';\nimport { parseDate, splitDateTime, formatDateTime } from '../../internal/utils/date-time';\nimport { getBaseDate } from '../../calendar/utils/navigation';\nimport { useMobile } from '../../internal/hooks/use-mobile/index.js';\nimport RangeInputs from './range-inputs.js';\nimport { findDateToFocus, findMonthToDisplay } from './utils';\nimport { useInternalI18n } from '../../internal/i18n/context.js';\n\nexport interface DateRangePickerCalendarProps extends BaseComponentProps {\n value: DateRangePickerProps.PendingAbsoluteValue;\n setValue: React.Dispatch<React.SetStateAction<DateRangePickerProps.PendingAbsoluteValue>>;\n locale?: string;\n startOfWeek?: number;\n isDateEnabled?: (date: Date) => boolean;\n i18nStrings?: RangeCalendarI18nStrings;\n dateOnly?: boolean;\n timeInputFormat?: TimeInputProps.Format;\n customAbsoluteRangeControl: DateRangePickerProps.AbsoluteRangeControl | undefined;\n}\n\nexport default function DateRangePickerCalendar({\n value,\n setValue,\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n i18nStrings,\n dateOnly = false,\n timeInputFormat = 'hh:mm:ss',\n customAbsoluteRangeControl,\n}: DateRangePickerCalendarProps) {\n const isSingleGrid = useMobile();\n const normalizedLocale = normalizeLocale('DateRangePicker', locale);\n const normalizedStartOfWeek = normalizeStartOfWeek(startOfWeek, normalizedLocale);\n const i18n = useInternalI18n('date-range-picker');\n\n const [announcement, setAnnouncement] = useState('');\n const [currentMonth, setCurrentMonth] = useState(() => findMonthToDisplay(value, isSingleGrid));\n const [focusedDate, setFocusedDate] = useState<Date | null>(() => {\n if (value.start.date) {\n const startDate = parseDate(value.start.date);\n if (isSameMonth(startDate, currentMonth)) {\n return startDate;\n }\n if (!isSingleGrid && isSameMonth(startDate, addMonths(currentMonth, -1))) {\n return startDate;\n }\n }\n return findDateToFocus(parseDate(value.start.date), currentMonth, isDateEnabled);\n });\n\n const updateCurrentMonth = (startDate: string) => {\n if (startDate.length >= 8) {\n const newCurrentMonth = startOfMonth(parseDate(startDate));\n setCurrentMonth(isSingleGrid ? newCurrentMonth : addMonths(newCurrentMonth, 1));\n }\n };\n\n // recommended to include the start/end time announced with the selection\n // because the user is not aware of the fact that a start/end time is also set as soon as they select a date\n const announceStart = (startDate: Date) => {\n return (\n i18n('i18nStrings.startDateLabel', i18nStrings?.startDateLabel) +\n ', ' +\n getDateLabel(normalizedLocale, startDate) +\n ', ' +\n i18n('i18nStrings.startTimeLabel', i18nStrings?.startTimeLabel) +\n ', ' +\n renderTimeLabel(normalizedLocale, startDate, timeInputFormat) +\n '. '\n );\n };\n\n const announceEnd = (endDate: Date) => {\n return (\n i18n('i18nStrings.endDateLabel', i18nStrings?.endDateLabel) +\n ', ' +\n getDateLabel(normalizedLocale, endDate) +\n ', ' +\n i18n('i18nStrings.endTimeLabel', i18nStrings?.endTimeLabel) +\n ', ' +\n renderTimeLabel(normalizedLocale, endDate, timeInputFormat) +\n '. '\n );\n };\n\n const renderSelectedAbsoluteRangeAriaLive = i18n(\n 'i18nStrings.renderSelectedAbsoluteRangeAriaLive',\n i18nStrings?.renderSelectedAbsoluteRangeAriaLive,\n format => (startDate, endDate) => format({ startDate, endDate })\n );\n\n const announceRange = (startDate: Date, endDate: Date) => {\n if (!renderSelectedAbsoluteRangeAriaLive) {\n return `${getDateLabel(normalizedLocale, startDate)} – ${getDateLabel(normalizedLocale, endDate)}`;\n }\n return renderSelectedAbsoluteRangeAriaLive(\n getDateLabel(normalizedLocale, startDate),\n getDateLabel(normalizedLocale, endDate)\n );\n };\n\n const onSelectDateHandler = (selectedDate: Date) => {\n const { start, end } = value;\n let newStart: Date | undefined = undefined;\n let newEnd: Date | null | undefined = undefined;\n let announcement = '';\n\n // If both fields are empty, we set the start date\n if (!start.date && !end.date) {\n newStart = startOfDay(selectedDate);\n announcement = announceStart(newStart);\n }\n // If both fields are set, we start new\n else if (start.date && end.date) {\n newStart = startOfDay(selectedDate);\n newEnd = null;\n announcement = announceStart(newStart);\n }\n // If only the END date is empty, we fill it (and swap dates if needed)\n else if (start.date && !end.date) {\n const parsedStartDate = parseDate(start.date);\n\n if (isBefore(selectedDate, parsedStartDate)) {\n // The user has selected the range backwards, so we swap start and end\n newStart = startOfDay(selectedDate);\n newEnd = endOfDay(parsedStartDate);\n announcement = announceStart(newStart) + announceRange(newStart, newEnd);\n } else {\n newEnd = endOfDay(selectedDate);\n announcement = announceEnd(newEnd) + announceRange(parsedStartDate, newEnd);\n }\n }\n // If only the START date is empty, we fill it (and swap dates if needed)\n else if (!start.date && end.date) {\n const existingEndDate = parseDate(end.date);\n\n if (isAfter(selectedDate, existingEndDate)) {\n // The user has selected the range backwards, so we swap start and end\n newStart = startOfDay(existingEndDate);\n newEnd = endOfDay(selectedDate);\n announcement = announceEnd(newEnd) + announceRange(newStart, newEnd);\n } else {\n newStart = startOfDay(selectedDate);\n announcement = announceStart(newStart) + announceRange(newStart, existingEndDate);\n }\n }\n\n const formatValue = (\n date: Date | null | undefined,\n previous: DateRangePickerProps.DateTimeStrings\n ): DateRangePickerProps.DateTimeStrings => {\n if (date === null) {\n // explicitly reset to empty\n return { date: '', time: '' };\n } else if (date === undefined) {\n // keep old value\n return previous;\n }\n return splitDateTime(formatDateTime(date));\n };\n\n setValue({\n start: formatValue(newStart, value.start),\n end: formatValue(newEnd, value.end),\n });\n setAnnouncement(announcement);\n };\n\n const onHeaderChangeMonthHandler = (newCurrentMonth: Date) => {\n setCurrentMonth(newCurrentMonth);\n\n const newBaseDateMonth = isSingleGrid ? newCurrentMonth : addMonths(newCurrentMonth, -1);\n const newBaseDate = getBaseDate(newBaseDateMonth, isDateEnabled);\n setFocusedDate(newBaseDate);\n };\n\n const onChangeStartDate = (value: string) => {\n setValue((oldValue: DateRangePickerProps.PendingAbsoluteValue) => ({\n ...oldValue,\n start: { ...oldValue.start, date: value },\n }));\n updateCurrentMonth(value);\n };\n\n const interceptedSetValue: DateRangePickerCalendarProps['setValue'] = newValue => {\n setValue(oldValue => {\n const updated = typeof newValue === 'function' ? newValue(oldValue) : newValue;\n updateCurrentMonth(updated.start.date);\n return updated;\n });\n };\n\n const headingIdPrefix = useUniqueId('date-range-picker-calendar-heading');\n return (\n <>\n <div\n className={clsx(styles['calendar-container'], {\n [styles['one-grid']]: isSingleGrid,\n })}\n >\n <SpaceBetween size=\"s\">\n <div\n className={clsx(styles.calendar, {\n [styles['one-grid']]: isSingleGrid,\n })}\n >\n <CalendarHeader\n baseDate={currentMonth}\n locale={normalizedLocale}\n onChangeMonth={onHeaderChangeMonthHandler}\n previousMonthLabel={i18n('i18nStrings.previousMonthAriaLabel', i18nStrings?.previousMonthAriaLabel)}\n nextMonthLabel={i18n('i18nStrings.nextMonthAriaLabel', i18nStrings?.nextMonthAriaLabel)}\n isSingleGrid={isSingleGrid}\n headingIdPrefix={headingIdPrefix}\n />\n\n <Grids\n isSingleGrid={isSingleGrid}\n locale={normalizedLocale}\n baseDate={currentMonth}\n focusedDate={focusedDate}\n onFocusedDateChange={setFocusedDate}\n isDateEnabled={isDateEnabled}\n onSelectDate={onSelectDateHandler}\n onChangeMonth={setCurrentMonth}\n startOfWeek={normalizedStartOfWeek}\n todayAriaLabel={i18nStrings?.todayAriaLabel}\n selectedStartDate={parseDate(value.start.date, true)}\n selectedEndDate={parseDate(value.end.date, true)}\n headingIdPrefix={headingIdPrefix}\n />\n </div>\n\n <RangeInputs\n startDate={value.start.date}\n onChangeStartDate={onChangeStartDate}\n startTime={value.start.time}\n onChangeStartTime={value =>\n setValue(oldValue => ({ ...oldValue, start: { ...oldValue.start, time: value } }))\n }\n endDate={value.end.date}\n onChangeEndDate={value => setValue(oldValue => ({ ...oldValue, end: { ...oldValue.end, date: value } }))}\n endTime={value.end.time}\n onChangeEndTime={value => setValue(oldValue => ({ ...oldValue, end: { ...oldValue.end, time: value } }))}\n i18nStrings={i18nStrings}\n dateOnly={dateOnly}\n timeInputFormat={timeInputFormat}\n />\n {customAbsoluteRangeControl && <div>{customAbsoluteRangeControl(value, interceptedSetValue)}</div>}\n </SpaceBetween>\n </div>\n <LiveRegion className={styles['calendar-aria-live']}>{announcement}</LiveRegion>\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["date-range-picker/calendar/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACzG,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,YAAY,MAAM,8BAA8B,CAAC;AAGxD,OAAO,cAAc,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,UAAU,MAAM,uCAAuC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AACrE,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAcjE,MAAM,CAAC,OAAO,UAAU,uBAAuB,CA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AAE,eAAe,GAChC,CACE;gBAEN,oBAAC,WAAW,IACV,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAC3B,iBAAiB,EAAE,iBAAiB,EACpC,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,EAC3B,iBAAiB,EAAE,KAAK,CAAC,EAAE,CACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,iCAAM,QAAQ,KAAE,KAAK,kCAAO,QAAQ,CAAC,KAAK,KAAE,IAAI,EAAE,KAAK,OAAK,CAAC,EAEpF,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EACvB,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,iCAAM,QAAQ,KAAE,GAAG,kCAAO,QAAQ,CAAC,GAAG,KAAE,IAAI,EAAE,KAAK,OAAK,CAAC,EACxG,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,EACvB,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,iCAAM,QAAQ,KAAE,GAAG,kCAAO,QAAQ,CAAC,GAAG,KAAE,IAAI,EAAE,KAAK,OAAK,CAAC,EACxG,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,GAChC;gBACD,0BAA0B,IAAI,iCAAM,0BAA0B,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAO,CACrF,CACX;QACN,oBAAC,UAAU,IAAC,SAAS,EAAE,MAAM,CAAC,oBAAoB,CAAC,IAAG,YAAY,CAAc,CAC/E,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useState } from 'react';\nimport { addMonths, endOfDay, isAfter, isBefore, isSameMonth, startOfDay, startOfMonth } from 'date-fns';\nimport styles from '../styles.css.js';\nimport SpaceBetween from '../../space-between/internal';\nimport { BaseComponentProps } from '../../internal/base-component';\nimport { DateRangePickerProps, RangeCalendarI18nStrings } from '../interfaces';\nimport CalendarHeader from './header';\nimport { Grids } from './grids';\nimport { TimeInputProps } from '../../time-input/interfaces';\nimport clsx from 'clsx';\nimport { useUniqueId } from '../../internal/hooks/use-unique-id';\nimport { getDateLabel, renderTimeLabel } from '../../calendar/utils/intl';\nimport LiveRegion from '../../internal/components/live-region';\nimport { normalizeLocale, normalizeStartOfWeek } from '../../internal/utils/locale';\nimport { parseDate, splitDateTime, formatDateTime } from '../../internal/utils/date-time';\nimport { getBaseDate } from '../../calendar/utils/navigation';\nimport { useMobile } from '../../internal/hooks/use-mobile/index.js';\nimport RangeInputs from './range-inputs.js';\nimport { findDateToFocus, findMonthToDisplay } from './utils';\nimport { useInternalI18n } from '../../internal/i18n/context.js';\n\nexport interface DateRangePickerCalendarProps extends BaseComponentProps {\n value: DateRangePickerProps.PendingAbsoluteValue;\n setValue: React.Dispatch<React.SetStateAction<DateRangePickerProps.PendingAbsoluteValue>>;\n locale?: string;\n startOfWeek?: number;\n isDateEnabled?: (date: Date) => boolean;\n i18nStrings?: RangeCalendarI18nStrings;\n dateOnly?: boolean;\n timeInputFormat?: TimeInputProps.Format;\n customAbsoluteRangeControl: DateRangePickerProps.AbsoluteRangeControl | undefined;\n}\n\nexport default function DateRangePickerCalendar({\n value,\n setValue,\n locale = '',\n startOfWeek,\n isDateEnabled = () => true,\n i18nStrings,\n dateOnly = false,\n timeInputFormat = 'hh:mm:ss',\n customAbsoluteRangeControl,\n}: DateRangePickerCalendarProps) {\n const isSingleGrid = useMobile();\n const normalizedLocale = normalizeLocale('DateRangePicker', locale);\n const normalizedStartOfWeek = normalizeStartOfWeek(startOfWeek, normalizedLocale);\n const i18n = useInternalI18n('date-range-picker');\n\n const [announcement, setAnnouncement] = useState('');\n const [currentMonth, setCurrentMonth] = useState(() => findMonthToDisplay(value, isSingleGrid));\n const [focusedDate, setFocusedDate] = useState<Date | null>(() => {\n if (value.start.date) {\n const startDate = parseDate(value.start.date);\n if (isSameMonth(startDate, currentMonth)) {\n return startDate;\n }\n if (!isSingleGrid && isSameMonth(startDate, addMonths(currentMonth, -1))) {\n return startDate;\n }\n }\n return findDateToFocus(parseDate(value.start.date), currentMonth, isDateEnabled);\n });\n\n const updateCurrentMonth = (startDate: string) => {\n if (startDate.length >= 8) {\n const newCurrentMonth = startOfMonth(parseDate(startDate));\n setCurrentMonth(isSingleGrid ? newCurrentMonth : addMonths(newCurrentMonth, 1));\n }\n };\n\n // recommended to include the start/end time announced with the selection\n // because the user is not aware of the fact that a start/end time is also set as soon as they select a date\n const announceStart = (startDate: Date) => {\n return (\n i18n('i18nStrings.startDateLabel', i18nStrings?.startDateLabel) +\n ', ' +\n getDateLabel(normalizedLocale, startDate) +\n ', ' +\n i18n('i18nStrings.startTimeLabel', i18nStrings?.startTimeLabel) +\n ', ' +\n renderTimeLabel(normalizedLocale, startDate, timeInputFormat) +\n '. '\n );\n };\n\n const announceEnd = (endDate: Date) => {\n return (\n i18n('i18nStrings.endDateLabel', i18nStrings?.endDateLabel) +\n ', ' +\n getDateLabel(normalizedLocale, endDate) +\n ', ' +\n i18n('i18nStrings.endTimeLabel', i18nStrings?.endTimeLabel) +\n ', ' +\n renderTimeLabel(normalizedLocale, endDate, timeInputFormat) +\n '. '\n );\n };\n\n const renderSelectedAbsoluteRangeAriaLive = i18n(\n 'i18nStrings.renderSelectedAbsoluteRangeAriaLive',\n i18nStrings?.renderSelectedAbsoluteRangeAriaLive,\n format => (startDate, endDate) => format({ startDate, endDate })\n );\n\n const announceRange = (startDate: Date, endDate: Date) => {\n if (!renderSelectedAbsoluteRangeAriaLive) {\n return `${getDateLabel(normalizedLocale, startDate)} – ${getDateLabel(normalizedLocale, endDate)}`;\n }\n return renderSelectedAbsoluteRangeAriaLive(\n getDateLabel(normalizedLocale, startDate),\n getDateLabel(normalizedLocale, endDate)\n );\n };\n\n const onSelectDateHandler = (selectedDate: Date) => {\n const { start, end } = value;\n let newStart: Date | undefined = undefined;\n let newEnd: Date | null | undefined = undefined;\n let announcement = '';\n\n // If both fields are empty, we set the start date\n if (!start.date && !end.date) {\n newStart = startOfDay(selectedDate);\n announcement = announceStart(newStart);\n }\n // If both fields are set, we start new\n else if (start.date && end.date) {\n newStart = startOfDay(selectedDate);\n newEnd = null;\n announcement = announceStart(newStart);\n }\n // If only the END date is empty, we fill it (and swap dates if needed)\n else if (start.date && !end.date) {\n const parsedStartDate = parseDate(start.date);\n\n if (isBefore(selectedDate, parsedStartDate)) {\n // The user has selected the range backwards, so we swap start and end\n newStart = startOfDay(selectedDate);\n newEnd = endOfDay(parsedStartDate);\n announcement = announceStart(newStart) + announceRange(newStart, newEnd);\n } else {\n newEnd = endOfDay(selectedDate);\n announcement = announceEnd(newEnd) + announceRange(parsedStartDate, newEnd);\n }\n }\n // If only the START date is empty, we fill it (and swap dates if needed)\n else if (!start.date && end.date) {\n const existingEndDate = parseDate(end.date);\n\n if (isAfter(selectedDate, existingEndDate)) {\n // The user has selected the range backwards, so we swap start and end\n newStart = startOfDay(existingEndDate);\n newEnd = endOfDay(selectedDate);\n announcement = announceEnd(newEnd) + announceRange(newStart, newEnd);\n } else {\n newStart = startOfDay(selectedDate);\n announcement = announceStart(newStart) + announceRange(newStart, existingEndDate);\n }\n }\n\n const formatValue = (\n date: Date | null | undefined,\n previous: DateRangePickerProps.DateTimeStrings\n ): DateRangePickerProps.DateTimeStrings => {\n if (date === null) {\n // explicitly reset to empty\n return { date: '', time: '' };\n } else if (date === undefined) {\n // keep old value\n return previous;\n }\n return splitDateTime(formatDateTime(date));\n };\n\n setValue({\n start: formatValue(newStart, value.start),\n end: formatValue(newEnd, value.end),\n });\n setAnnouncement(announcement);\n };\n\n const onHeaderChangeMonthHandler = (newCurrentMonth: Date) => {\n setCurrentMonth(newCurrentMonth);\n\n const newBaseDateMonth = isSingleGrid ? newCurrentMonth : addMonths(newCurrentMonth, -1);\n const newBaseDate = getBaseDate(newBaseDateMonth, isDateEnabled);\n setFocusedDate(newBaseDate);\n };\n\n const onChangeStartDate = (value: string) => {\n setValue((oldValue: DateRangePickerProps.PendingAbsoluteValue) => ({\n ...oldValue,\n start: { ...oldValue.start, date: value },\n }));\n updateCurrentMonth(value);\n };\n\n const interceptedSetValue: DateRangePickerCalendarProps['setValue'] = newValue => {\n setValue(oldValue => {\n const updated = typeof newValue === 'function' ? newValue(oldValue) : newValue;\n updateCurrentMonth(updated.start.date);\n return updated;\n });\n };\n\n const headingIdPrefix = useUniqueId('date-range-picker-calendar-heading');\n return (\n <>\n <div\n className={clsx(styles['calendar-container'], {\n [styles['one-grid']]: isSingleGrid,\n })}\n >\n <SpaceBetween size=\"s\">\n <div\n className={clsx(styles.calendar, {\n [styles['one-grid']]: isSingleGrid,\n })}\n >\n <CalendarHeader\n baseDate={currentMonth}\n locale={normalizedLocale}\n onChangeMonth={onHeaderChangeMonthHandler}\n previousMonthLabel={i18nStrings?.previousMonthAriaLabel}\n nextMonthLabel={i18nStrings?.nextMonthAriaLabel}\n isSingleGrid={isSingleGrid}\n headingIdPrefix={headingIdPrefix}\n />\n\n <Grids\n isSingleGrid={isSingleGrid}\n locale={normalizedLocale}\n baseDate={currentMonth}\n focusedDate={focusedDate}\n onFocusedDateChange={setFocusedDate}\n isDateEnabled={isDateEnabled}\n onSelectDate={onSelectDateHandler}\n onChangeMonth={setCurrentMonth}\n startOfWeek={normalizedStartOfWeek}\n todayAriaLabel={i18nStrings?.todayAriaLabel}\n selectedStartDate={parseDate(value.start.date, true)}\n selectedEndDate={parseDate(value.end.date, true)}\n headingIdPrefix={headingIdPrefix}\n />\n </div>\n\n <RangeInputs\n startDate={value.start.date}\n onChangeStartDate={onChangeStartDate}\n startTime={value.start.time}\n onChangeStartTime={value =>\n setValue(oldValue => ({ ...oldValue, start: { ...oldValue.start, time: value } }))\n }\n endDate={value.end.date}\n onChangeEndDate={value => setValue(oldValue => ({ ...oldValue, end: { ...oldValue.end, date: value } }))}\n endTime={value.end.time}\n onChangeEndTime={value => setValue(oldValue => ({ ...oldValue, end: { ...oldValue.end, time: value } }))}\n i18nStrings={i18nStrings}\n dateOnly={dateOnly}\n timeInputFormat={timeInputFormat}\n />\n {customAbsoluteRangeControl && <div>{customAbsoluteRangeControl(value, interceptedSetValue)}</div>}\n </SpaceBetween>\n </div>\n <LiveRegion className={styles['calendar-aria-live']}>{announcement}</LiveRegion>\n </>\n );\n}\n"]}
|
package/form/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["form/index.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["form/index.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AASzC,OAAO,EAAE,SAAS,EAAE,CAAC;AA2BrB,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAAE,OAAqB,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,eAU1E"}
|
package/form/index.js
CHANGED
|
@@ -7,12 +7,25 @@ import InternalForm from './internal';
|
|
|
7
7
|
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
8
8
|
import { AnalyticsFunnel, AnalyticsFunnelStep } from '../internal/analytics/components/analytics-funnel';
|
|
9
9
|
import { getFunnelNameSelector } from '../internal/analytics/selectors';
|
|
10
|
+
import { ButtonContext } from '../internal/context/button-context';
|
|
11
|
+
import { useFunnel, useFunnelStep } from '../internal/analytics/hooks/use-funnel';
|
|
12
|
+
const FormWithAnalytics = (_a) => {
|
|
13
|
+
var { variant = 'full-page', actions } = _a, props = __rest(_a, ["variant", "actions"]);
|
|
14
|
+
const { funnelProps, funnelSubmit } = useFunnel();
|
|
15
|
+
const { funnelStepProps } = useFunnelStep();
|
|
16
|
+
const handleActionButtonClick = ({ variant }) => {
|
|
17
|
+
if (variant === 'primary') {
|
|
18
|
+
funnelSubmit();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
return (React.createElement(InternalForm, Object.assign({ variant: variant, actions: actions && (React.createElement(ButtonContext.Provider, { value: { onClick: handleActionButtonClick } }, actions)) }, props, funnelProps, funnelStepProps)));
|
|
22
|
+
};
|
|
10
23
|
export default function Form(_a) {
|
|
11
24
|
var { variant = 'full-page' } = _a, props = __rest(_a, ["variant"]);
|
|
12
25
|
const baseComponentProps = useBaseComponent('Form');
|
|
13
26
|
return (React.createElement(AnalyticsFunnel, { funnelType: "single-page", optionalStepNumbers: [], totalFunnelSteps: 1 },
|
|
14
27
|
React.createElement(AnalyticsFunnelStep, { stepNumber: 1, stepNameSelector: getFunnelNameSelector() },
|
|
15
|
-
React.createElement(
|
|
28
|
+
React.createElement(FormWithAnalytics, Object.assign({ variant: variant }, props, baseComponentProps)))));
|
|
16
29
|
}
|
|
17
30
|
applyDisplayName(Form, 'Form');
|
|
18
31
|
//# sourceMappingURL=index.js.map
|
package/form/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["form/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,YAAY,MAAM,YAAY,CAAC;AACtC,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AACzG,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["form/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAA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O,CACL,oBAAC,eAAe,IAAC,UAAU,EAAC,aAAa,EAAC,mBAAmB,EAAE,EAAE,EAAE,gBAAgB,EAAE,CAAC;QACpF,oBAAC,mBAAmB,IAAC,UAAU,EAAE,CAAC,EAAE,gBAAgB,EAAE,qBAAqB,EAAE;YAC3E,oBAAC,iBAAiB,kBAAC,OAAO,EAAE,OAAO,IAAM,KAAK,EAAM,kBAAkB,EAAI,CACtD,CACN,CACnB,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,IAAI,EAAE,MAAM,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 { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { FormProps } from './interfaces';\nimport InternalForm from './internal';\nimport useBaseComponent from '../internal/hooks/use-base-component';\n\nimport { AnalyticsFunnel, AnalyticsFunnelStep } from '../internal/analytics/components/analytics-funnel';\nimport { getFunnelNameSelector } from '../internal/analytics/selectors';\nimport { ButtonContext, ButtonContextProps } from '../internal/context/button-context';\nimport { useFunnel, useFunnelStep } from '../internal/analytics/hooks/use-funnel';\n\nexport { FormProps };\n\nconst FormWithAnalytics = ({ variant = 'full-page', actions, ...props }: FormProps) => {\n const { funnelProps, funnelSubmit } = useFunnel();\n const { funnelStepProps } = useFunnelStep();\n\n const handleActionButtonClick: ButtonContextProps['onClick'] = ({ variant }) => {\n if (variant === 'primary') {\n funnelSubmit();\n }\n };\n\n return (\n <InternalForm\n variant={variant}\n actions={\n actions && (\n <ButtonContext.Provider value={{ onClick: handleActionButtonClick }}>{actions}</ButtonContext.Provider>\n )\n }\n {...props}\n {...funnelProps}\n {...funnelStepProps}\n />\n );\n};\n\nexport default function Form({ variant = 'full-page', ...props }: FormProps) {\n const baseComponentProps = useBaseComponent('Form');\n\n return (\n <AnalyticsFunnel funnelType=\"single-page\" optionalStepNumbers={[]} totalFunnelSteps={1}>\n <AnalyticsFunnelStep stepNumber={1} stepNameSelector={getFunnelNameSelector()}>\n <FormWithAnalytics variant={variant} {...props} {...baseComponentProps} />\n </AnalyticsFunnelStep>\n </AnalyticsFunnel>\n );\n}\n\napplyDisplayName(Form, 'Form');\n"]}
|
package/form/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["form/internal.tsx"],"names":[],"mappings":";AASA,OAAO,EAAmB,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAOlF,KAAK,iBAAiB,GAAG,SAAS,GAAG,0BAA0B,CAAC;AAEhE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,QAAQ,EACR,MAAM,EACN,SAAS,EACT,kBAAkB,EAAE,0BAA0B,EAC9C,OAAO,EACP,gBAAgB,EAChB,OAAO,EACP,iBAAiB,EACjB,GAAG,KAAK,EACT,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["form/internal.tsx"],"names":[],"mappings":";AASA,OAAO,EAAmB,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAOlF,KAAK,iBAAiB,GAAG,SAAS,GAAG,0BAA0B,CAAC;AAEhE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,QAAQ,EACR,MAAM,EACN,SAAS,EACT,kBAAkB,EAAE,0BAA0B,EAC9C,OAAO,EACP,gBAAgB,EAChB,OAAO,EACP,iBAAiB,EACjB,GAAG,KAAK,EACT,EAAE,iBAAiB,eA6CnB"}
|
package/form/internal.js
CHANGED
|
@@ -10,21 +10,20 @@ import InternalContentLayout from '../content-layout/internal';
|
|
|
10
10
|
import styles from './styles.css.js';
|
|
11
11
|
import LiveRegion from '../internal/components/live-region';
|
|
12
12
|
import { useInternalI18n } from '../internal/i18n/context';
|
|
13
|
+
import { useFunnel } from '../internal/analytics/hooks/use-funnel';
|
|
13
14
|
import { FunnelMetrics } from '../internal/analytics';
|
|
14
|
-
import { useFunnel, useFunnelStep } from '../internal/analytics/hooks/use-funnel';
|
|
15
15
|
export default function InternalForm(_a) {
|
|
16
16
|
var { children, header, errorText, errorIconAriaLabel: errorIconAriaLabelOverride, actions, secondaryActions, variant, __internalRootRef } = _a, props = __rest(_a, ["children", "header", "errorText", "errorIconAriaLabel", "actions", "secondaryActions", "variant", "__internalRootRef"]);
|
|
17
17
|
const baseProps = getBaseProps(props);
|
|
18
18
|
const i18n = useInternalI18n('form');
|
|
19
19
|
const errorIconAriaLabel = i18n('errorIconAriaLabel', errorIconAriaLabelOverride);
|
|
20
|
-
const { funnelInteractionId
|
|
21
|
-
const { funnelStepProps } = useFunnelStep();
|
|
20
|
+
const { funnelInteractionId } = useFunnel();
|
|
22
21
|
useEffect(() => {
|
|
23
22
|
if (funnelInteractionId && errorText) {
|
|
24
23
|
FunnelMetrics.funnelError({ funnelInteractionId });
|
|
25
24
|
}
|
|
26
25
|
}, [funnelInteractionId, errorText]);
|
|
27
|
-
return (React.createElement("div", Object.assign({}, baseProps,
|
|
26
|
+
return (React.createElement("div", Object.assign({}, baseProps, { ref: __internalRootRef, className: clsx(styles.root, baseProps.className) }),
|
|
28
27
|
React.createElement(FormLayout, { header: header && React.createElement("div", { className: clsx(styles.header, variant === 'full-page' && styles['full-page']) }, header), variant: variant },
|
|
29
28
|
children && React.createElement("div", { className: styles.content }, children),
|
|
30
29
|
errorText && (React.createElement(InternalBox, { margin: { top: 'l' } },
|
package/form/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["form/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,IAAI,MAAM,M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AAgB,IAAI,6BAAK,SAAS,EAAE,MAAM,CAAC,mBAAmB,CAAC,IAAG,gBAAgB,CAAO,CACtF,CACF,CACP;YACA,SAAS,IAAI,CACZ,oBAAC,UAAU,IAAC,SAAS,EAAE,IAAI;gBACxB,kBAAkB;;gBAAI,SAAS,CACrB,CACd,CACU,CACT,CACP,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAmB;IAChE,OAAO,OAAO,KAAK,WAAW,IAAI,MAAM,CAAC,CAAC,CAAC,CACzC,oBAAC,qBAAqB,IAAC,MAAM,EAAE,MAAM,IAAG,QAAQ,CAAyB,CAC1E,CAAC,CAAC,CAAC,CACF;QACG,MAAM;QACN,QAAQ,CACR,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect } from 'react';\nimport clsx from 'clsx';\nimport { getBaseProps } from '../internal/base-component';\nimport InternalAlert from '../alert/internal';\nimport InternalBox from '../box/internal';\nimport InternalContentLayout from '../content-layout/internal';\nimport styles from './styles.css.js';\nimport { FormLayoutProps, FormProps } from './interfaces';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport LiveRegion from '../internal/components/live-region';\nimport { useInternalI18n } from '../internal/i18n/context';\n\nimport { useFunnel } from '../internal/analytics/hooks/use-funnel';\nimport { FunnelMetrics } from '../internal/analytics';\n\ntype InternalFormProps = FormProps & InternalBaseComponentProps;\n\nexport default function InternalForm({\n children,\n header,\n errorText,\n errorIconAriaLabel: errorIconAriaLabelOverride,\n actions,\n secondaryActions,\n variant,\n __internalRootRef,\n ...props\n}: InternalFormProps) {\n const baseProps = getBaseProps(props);\n const i18n = useInternalI18n('form');\n const errorIconAriaLabel = i18n('errorIconAriaLabel', errorIconAriaLabelOverride);\n\n const { funnelInteractionId } = useFunnel();\n\n useEffect(() => {\n if (funnelInteractionId && errorText) {\n FunnelMetrics.funnelError({ funnelInteractionId });\n }\n }, [funnelInteractionId, errorText]);\n\n return (\n <div {...baseProps} ref={__internalRootRef} className={clsx(styles.root, baseProps.className)}>\n <FormLayout\n header={\n header && <div className={clsx(styles.header, variant === 'full-page' && styles['full-page'])}>{header}</div>\n }\n variant={variant}\n >\n {children && <div className={styles.content}>{children}</div>}\n {errorText && (\n <InternalBox margin={{ top: 'l' }}>\n <InternalAlert type=\"error\" statusIconAriaLabel={errorIconAriaLabel}>\n <div className={styles.error}>{errorText}</div>\n </InternalAlert>\n </InternalBox>\n )}\n {(actions || secondaryActions) && (\n <div className={styles.footer}>\n <div className={styles['actions-section']}>\n {actions && <div className={styles.actions}>{actions}</div>}\n {secondaryActions && <div className={styles['secondary-actions']}>{secondaryActions}</div>}\n </div>\n </div>\n )}\n {errorText && (\n <LiveRegion assertive={true}>\n {errorIconAriaLabel}, {errorText}\n </LiveRegion>\n )}\n </FormLayout>\n </div>\n );\n}\n\nfunction FormLayout({ children, header, variant }: FormLayoutProps) {\n return variant === 'full-page' && header ? (\n <InternalContentLayout header={header}>{children}</InternalContentLayout>\n ) : (\n <>\n {header}\n {children}\n </>\n );\n}\n"]}
|
package/form-field/internal.js
CHANGED
|
@@ -29,7 +29,6 @@ export function ConstraintText({ id, hasError, children, }) {
|
|
|
29
29
|
return (React.createElement("div", { id: id, className: clsx(styles.constraint, hasError && styles['constraint-has-error']) }, children));
|
|
30
30
|
}
|
|
31
31
|
export default function InternalFormField(_a) {
|
|
32
|
-
var _b, _c;
|
|
33
32
|
var { controlId, stretch = false, label, info, i18nStrings, children, secondaryControl, description, constraintText, errorText, __hideLabel, __internalRootRef = null, __disableGutters = false } = _a, rest = __rest(_a, ["controlId", "stretch", "label", "info", "i18nStrings", "children", "secondaryControl", "description", "constraintText", "errorText", "__hideLabel", "__internalRootRef", "__disableGutters"]);
|
|
34
33
|
const baseProps = getBaseProps(rest);
|
|
35
34
|
const isRefresh = useVisualRefresh();
|
|
@@ -47,8 +46,8 @@ export default function InternalFormField(_a) {
|
|
|
47
46
|
invalid: !!errorText || !!parentInvalid,
|
|
48
47
|
};
|
|
49
48
|
const analyticsAttributes = {
|
|
50
|
-
[DATA_ATTR_FIELD_LABEL]:
|
|
51
|
-
[DATA_ATTR_FIELD_ERROR]:
|
|
49
|
+
[DATA_ATTR_FIELD_LABEL]: slotIds.label ? getFieldSlotSeletor(slotIds.label) : undefined,
|
|
50
|
+
[DATA_ATTR_FIELD_ERROR]: slotIds.error ? getFieldSlotSeletor(slotIds.error) : undefined,
|
|
52
51
|
};
|
|
53
52
|
useEffect(() => {
|
|
54
53
|
if (funnelInteractionId && errorText) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["form-field/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE3E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAEnF,OA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AM,CAAC,QAAQ,EAAE,WAAW,IAAI,MAAM,CAAC,cAAc,CAAC,CAAC;YAC1E,oBAAC,YAAY,IAAC,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB;gBAC5E,oBAAC,gBAAgB,CAAC,QAAQ,IACxB,KAAK,kBACH,SAAS,EAAE,kBAAkB,IAC1B,6BAA6B,KAGjC,QAAQ,IAAI,6BAAK,SAAS,EAAE,MAAM,CAAC,OAAO,IAAG,QAAQ,CAAO,CACnC;gBAE3B,gBAAgB,IAAI,CACnB,oBAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,6BAA6B;oBAC7D,6BAAK,SAAS,EAAE,MAAM,CAAC,mBAAmB,CAAC,IAAG,gBAAgB,CAAO,CAC3C,CAC7B,CACY,CACX;QAEL,CAAC,cAAc,IAAI,SAAS,CAAC,IAAI,CAChC,6BAAK,SAAS,EAAE,MAAM,CAAC,KAAK;YACzB,SAAS,IAAI,CACZ,oBAAC,cAAc,IAAC,EAAE,EAAE,OAAO,CAAC,KAAK,EAAE,kBAAkB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,kBAAkB,IACnF,SAAS,CACK,CAClB;YACA,cAAc,IAAI,CACjB,oBAAC,cAAc,IAAC,EAAE,EAAE,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC,SAAS,IAC1D,cAAc,CACA,CAClB,CACG,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 React, { useEffect } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { FormFieldContext, useFormFieldContext } from '../internal/context/form-field-context';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\n\nimport InternalGrid from '../grid/internal';\nimport InternalIcon from '../icon/internal';\nimport { getAriaDescribedBy, getGridDefinition, getSlotIds } from './util';\n\nimport styles from './styles.css.js';\nimport { InternalFormFieldProps } from './interfaces';\nimport { joinStrings } from '../internal/utils/strings';\nimport { useInternalI18n } from '../internal/i18n/context';\nimport { InfoLinkLabelContext } from '../internal/context/info-link-label-context';\n\nimport { FunnelMetrics } from '../internal/analytics';\nimport { useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';\nimport {\n DATA_ATTR_FIELD_ERROR,\n DATA_ATTR_FIELD_LABEL,\n getFieldSlotSeletor,\n getSubStepAllSelector,\n} from '../internal/analytics/selectors';\n\ninterface FormFieldErrorProps {\n id?: string;\n children?: React.ReactNode;\n errorIconAriaLabel?: string;\n}\n\nexport function FormFieldError({ id, children, errorIconAriaLabel }: FormFieldErrorProps) {\n const i18n = useInternalI18n('form-field');\n\n return (\n <div id={id} className={styles.error}>\n <div className={styles['error-icon-shake-wrapper']}>\n <div\n role=\"img\"\n aria-label={i18n('i18nStrings.errorIconAriaLabel', errorIconAriaLabel)}\n className={styles['error-icon-scale-wrapper']}\n >\n <InternalIcon name=\"status-warning\" size=\"small\" />\n </div>\n </div>\n <span className={styles.error__message}>{children}</span>\n </div>\n );\n}\n\nexport function ConstraintText({\n id,\n hasError,\n children,\n}: {\n id?: string;\n hasError: boolean;\n children: React.ReactNode;\n}) {\n return (\n <div id={id} className={clsx(styles.constraint, hasError && styles['constraint-has-error'])}>\n {children}\n </div>\n );\n}\n\nexport default function InternalFormField({\n controlId,\n stretch = false,\n label,\n info,\n i18nStrings,\n children,\n secondaryControl,\n description,\n constraintText,\n errorText,\n __hideLabel,\n __internalRootRef = null,\n __disableGutters = false,\n ...rest\n}: InternalFormFieldProps) {\n const baseProps = getBaseProps(rest);\n const isRefresh = useVisualRefresh();\n\n const instanceUniqueId = useUniqueId('formField');\n const generatedControlId = controlId || instanceUniqueId;\n const formFieldId = controlId || generatedControlId;\n\n const { funnelInteractionId, stepNumber, stepNameSelector, subStepSelector, subStepNameSelector } =\n useFunnelSubStep();\n\n const slotIds = getSlotIds(formFieldId, label, description, constraintText, errorText);\n\n const ariaDescribedBy = getAriaDescribedBy(slotIds);\n\n const gridDefinition = getGridDefinition(stretch, !!secondaryControl, isRefresh);\n\n const {\n ariaLabelledby: parentAriaLabelledby,\n ariaDescribedby: parentAriaDescribedby,\n invalid: parentInvalid,\n } = useFormFieldContext({});\n\n const contextValuesWithoutControlId = {\n ariaLabelledby: joinStrings(parentAriaLabelledby, slotIds.label) || undefined,\n ariaDescribedby: joinStrings(parentAriaDescribedby, ariaDescribedBy) || undefined,\n invalid: !!errorText || !!parentInvalid,\n };\n\n const analyticsAttributes = {\n [DATA_ATTR_FIELD_LABEL]: slotIds.label ?? getFieldSlotSeletor(slotIds.label),\n [DATA_ATTR_FIELD_ERROR]: slotIds.error ?? getFieldSlotSeletor(slotIds.error),\n };\n\n useEffect(() => {\n if (funnelInteractionId && errorText) {\n FunnelMetrics.funnelSubStepError({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n stepNumber,\n stepNameSelector,\n fieldErrorSelector: getFieldSlotSeletor(slotIds.error),\n fieldLabelSelector: getFieldSlotSeletor(slotIds.label),\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [funnelInteractionId, errorText]);\n\n return (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.root)}\n ref={__internalRootRef}\n {...analyticsAttributes}\n >\n <div className={clsx(__hideLabel && styles['visually-hidden'])}>\n {label && (\n <label className={styles.label} id={slotIds.label} htmlFor={generatedControlId}>\n {label}\n </label>\n )}\n <InfoLinkLabelContext.Provider value={slotIds.label}>\n {!__hideLabel && info && <span className={styles.info}>{info}</span>}\n </InfoLinkLabelContext.Provider>\n </div>\n\n {description && (\n <div className={styles.description} id={slotIds.description}>\n {description}\n </div>\n )}\n\n <div className={clsx(styles.controls, __hideLabel && styles['label-hidden'])}>\n <InternalGrid gridDefinition={gridDefinition} disableGutters={__disableGutters}>\n <FormFieldContext.Provider\n value={{\n controlId: generatedControlId,\n ...contextValuesWithoutControlId,\n }}\n >\n {children && <div className={styles.control}>{children}</div>}\n </FormFieldContext.Provider>\n\n {secondaryControl && (\n <FormFieldContext.Provider value={contextValuesWithoutControlId}>\n <div className={styles['secondary-control']}>{secondaryControl}</div>\n </FormFieldContext.Provider>\n )}\n </InternalGrid>\n </div>\n\n {(constraintText || errorText) && (\n <div className={styles.hints}>\n {errorText && (\n <FormFieldError id={slotIds.error} errorIconAriaLabel={i18nStrings?.errorIconAriaLabel}>\n {errorText}\n </FormFieldError>\n )}\n {constraintText && (\n <ConstraintText id={slotIds.constraint} hasError={!!errorText}>\n {constraintText}\n </ConstraintText>\n )}\n </div>\n )}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["form-field/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE3E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MA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AE,OAAO,CAAC,WAAW,IACxD,WAAW,CACR,CACP;QAED,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,IAAI,MAAM,CAAC,cAAc,CAAC,CAAC;YAC1E,oBAAC,YAAY,IAAC,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB;gBAC5E,oBAAC,gBAAgB,CAAC,QAAQ,IACxB,KAAK,kBACH,SAAS,EAAE,kBAAkB,IAC1B,6BAA6B,KAGjC,QAAQ,IAAI,6BAAK,SAAS,EAAE,MAAM,CAAC,OAAO,IAAG,QAAQ,CAAO,CACnC;gBAE3B,gBAAgB,IAAI,CACnB,oBAAC,gBAAgB,CAAC,QAAQ,IAAC,KAAK,EAAE,6BAA6B;oBAC7D,6BAAK,SAAS,EAAE,MAAM,CAAC,mBAAmB,CAAC,IAAG,gBAAgB,CAAO,CAC3C,CAC7B,CACY,CACX;QAEL,CAAC,cAAc,IAAI,SAAS,CAAC,IAAI,CAChC,6BAAK,SAAS,EAAE,MAAM,CAAC,KAAK;YACzB,SAAS,IAAI,CACZ,oBAAC,cAAc,IAAC,EAAE,EAAE,OAAO,CAAC,KAAK,EAAE,kBAAkB,EAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,kBAAkB,IACnF,SAAS,CACK,CAClB;YACA,cAAc,IAAI,CACjB,oBAAC,cAAc,IAAC,EAAE,EAAE,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC,SAAS,IAC1D,cAAc,CACA,CAClB,CACG,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 React, { useEffect } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { FormFieldContext, useFormFieldContext } from '../internal/context/form-field-context';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\n\nimport InternalGrid from '../grid/internal';\nimport InternalIcon from '../icon/internal';\nimport { getAriaDescribedBy, getGridDefinition, getSlotIds } from './util';\n\nimport styles from './styles.css.js';\nimport { InternalFormFieldProps } from './interfaces';\nimport { joinStrings } from '../internal/utils/strings';\nimport { useInternalI18n } from '../internal/i18n/context';\nimport { InfoLinkLabelContext } from '../internal/context/info-link-label-context';\n\nimport { FunnelMetrics } from '../internal/analytics';\nimport { useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';\nimport {\n DATA_ATTR_FIELD_ERROR,\n DATA_ATTR_FIELD_LABEL,\n getFieldSlotSeletor,\n getSubStepAllSelector,\n} from '../internal/analytics/selectors';\n\ninterface FormFieldErrorProps {\n id?: string;\n children?: React.ReactNode;\n errorIconAriaLabel?: string;\n}\n\nexport function FormFieldError({ id, children, errorIconAriaLabel }: FormFieldErrorProps) {\n const i18n = useInternalI18n('form-field');\n\n return (\n <div id={id} className={styles.error}>\n <div className={styles['error-icon-shake-wrapper']}>\n <div\n role=\"img\"\n aria-label={i18n('i18nStrings.errorIconAriaLabel', errorIconAriaLabel)}\n className={styles['error-icon-scale-wrapper']}\n >\n <InternalIcon name=\"status-warning\" size=\"small\" />\n </div>\n </div>\n <span className={styles.error__message}>{children}</span>\n </div>\n );\n}\n\nexport function ConstraintText({\n id,\n hasError,\n children,\n}: {\n id?: string;\n hasError: boolean;\n children: React.ReactNode;\n}) {\n return (\n <div id={id} className={clsx(styles.constraint, hasError && styles['constraint-has-error'])}>\n {children}\n </div>\n );\n}\n\nexport default function InternalFormField({\n controlId,\n stretch = false,\n label,\n info,\n i18nStrings,\n children,\n secondaryControl,\n description,\n constraintText,\n errorText,\n __hideLabel,\n __internalRootRef = null,\n __disableGutters = false,\n ...rest\n}: InternalFormFieldProps) {\n const baseProps = getBaseProps(rest);\n const isRefresh = useVisualRefresh();\n\n const instanceUniqueId = useUniqueId('formField');\n const generatedControlId = controlId || instanceUniqueId;\n const formFieldId = controlId || generatedControlId;\n\n const { funnelInteractionId, stepNumber, stepNameSelector, subStepSelector, subStepNameSelector } =\n useFunnelSubStep();\n\n const slotIds = getSlotIds(formFieldId, label, description, constraintText, errorText);\n\n const ariaDescribedBy = getAriaDescribedBy(slotIds);\n\n const gridDefinition = getGridDefinition(stretch, !!secondaryControl, isRefresh);\n\n const {\n ariaLabelledby: parentAriaLabelledby,\n ariaDescribedby: parentAriaDescribedby,\n invalid: parentInvalid,\n } = useFormFieldContext({});\n\n const contextValuesWithoutControlId = {\n ariaLabelledby: joinStrings(parentAriaLabelledby, slotIds.label) || undefined,\n ariaDescribedby: joinStrings(parentAriaDescribedby, ariaDescribedBy) || undefined,\n invalid: !!errorText || !!parentInvalid,\n };\n\n const analyticsAttributes = {\n [DATA_ATTR_FIELD_LABEL]: slotIds.label ? getFieldSlotSeletor(slotIds.label) : undefined,\n [DATA_ATTR_FIELD_ERROR]: slotIds.error ? getFieldSlotSeletor(slotIds.error) : undefined,\n };\n\n useEffect(() => {\n if (funnelInteractionId && errorText) {\n FunnelMetrics.funnelSubStepError({\n funnelInteractionId,\n subStepSelector,\n subStepNameSelector,\n stepNumber,\n stepNameSelector,\n fieldErrorSelector: getFieldSlotSeletor(slotIds.error),\n fieldLabelSelector: getFieldSlotSeletor(slotIds.label),\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [funnelInteractionId, errorText]);\n\n return (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.root)}\n ref={__internalRootRef}\n {...analyticsAttributes}\n >\n <div className={clsx(__hideLabel && styles['visually-hidden'])}>\n {label && (\n <label className={styles.label} id={slotIds.label} htmlFor={generatedControlId}>\n {label}\n </label>\n )}\n <InfoLinkLabelContext.Provider value={slotIds.label}>\n {!__hideLabel && info && <span className={styles.info}>{info}</span>}\n </InfoLinkLabelContext.Provider>\n </div>\n\n {description && (\n <div className={styles.description} id={slotIds.description}>\n {description}\n </div>\n )}\n\n <div className={clsx(styles.controls, __hideLabel && styles['label-hidden'])}>\n <InternalGrid gridDefinition={gridDefinition} disableGutters={__disableGutters}>\n <FormFieldContext.Provider\n value={{\n controlId: generatedControlId,\n ...contextValuesWithoutControlId,\n }}\n >\n {children && <div className={styles.control}>{children}</div>}\n </FormFieldContext.Provider>\n\n {secondaryControl && (\n <FormFieldContext.Provider value={contextValuesWithoutControlId}>\n <div className={styles['secondary-control']}>{secondaryControl}</div>\n </FormFieldContext.Provider>\n )}\n </InternalGrid>\n </div>\n\n {(constraintText || errorText) && (\n <div className={styles.hints}>\n {errorText && (\n <FormFieldError id={slotIds.error} errorIconAriaLabel={i18nStrings?.errorIconAriaLabel}>\n {errorText}\n </FormFieldError>\n )}\n {constraintText && (\n <ConstraintText id={slotIds.constraint} hasError={!!errorText}>\n {constraintText}\n </ConstraintText>\n )}\n </div>\n )}\n </div>\n );\n}\n"]}
|
package/i18n/context.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
import { I18nFormatArgTypes } from './messages-types';
|
|
3
|
+
export type CustomHandler<ReturnValue, FormatFnArgs> = (formatFn: (args: FormatFnArgs) => string) => ReturnValue;
|
|
3
4
|
export interface FormatFunction {
|
|
4
5
|
(namespace: string, component: string, key: string, provided: string): string;
|
|
5
6
|
(namespace: string, component: string, key: string, provided: string | undefined): string | undefined;
|
|
6
|
-
<T>(namespace: string, component: string, key: string, provided: T, handler?: CustomHandler<T>): T;
|
|
7
|
+
<T, A = unknown>(namespace: string, component: string, key: string, provided: T, handler?: CustomHandler<T, A>): T;
|
|
7
8
|
}
|
|
8
9
|
export interface InternalI18nContextProps {
|
|
9
10
|
locale: string | null;
|
|
@@ -11,10 +12,16 @@ export interface InternalI18nContextProps {
|
|
|
11
12
|
}
|
|
12
13
|
export declare const InternalI18nContext: React.Context<InternalI18nContextProps>;
|
|
13
14
|
export declare function useLocale(): string | null;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Utility to get "keyof T" but exclude number or symbol types.
|
|
17
|
+
* TypeScript allows those types because JS implicitly casts them to string.
|
|
18
|
+
*/
|
|
19
|
+
type StringKeyOf<T> = Extract<keyof T, string>;
|
|
20
|
+
export interface ComponentFormatFunction<ComponentName extends StringKeyOf<I18nFormatArgTypes>> {
|
|
21
|
+
<MessageKey extends StringKeyOf<I18nFormatArgTypes[ComponentName]>>(key: MessageKey, provided: string, handler?: CustomHandler<string, I18nFormatArgTypes[ComponentName][MessageKey]>): string;
|
|
22
|
+
<MessageKey extends StringKeyOf<I18nFormatArgTypes[ComponentName]>>(key: MessageKey, provided: string | undefined, handler?: CustomHandler<string, I18nFormatArgTypes[ComponentName][MessageKey]>): string | undefined;
|
|
23
|
+
<MessageKey extends StringKeyOf<I18nFormatArgTypes[ComponentName]>, ReturnValue>(key: MessageKey, provided: ReturnValue, handler: I18nFormatArgTypes[ComponentName][MessageKey] extends never ? never : CustomHandler<ReturnValue, I18nFormatArgTypes[ComponentName][MessageKey]>): ReturnValue;
|
|
18
24
|
}
|
|
19
|
-
export declare function useInternalI18n(componentName:
|
|
25
|
+
export declare function useInternalI18n<ComponentName extends StringKeyOf<I18nFormatArgTypes>>(componentName: ComponentName): ComponentFormatFunction<ComponentName>;
|
|
26
|
+
export {};
|
|
20
27
|
//# sourceMappingURL=context.d.ts.map
|