@cloudscape-design/components 3.0.74 → 3.0.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/alert/interfaces.d.ts +5 -0
- package/alert/interfaces.d.ts.map +1 -1
- package/alert/interfaces.js.map +1 -1
- package/alert/internal.d.ts +1 -1
- package/alert/internal.d.ts.map +1 -1
- package/alert/internal.js +2 -2
- package/alert/internal.js.map +1 -1
- package/annotation-context/annotation/styles.css.js +24 -24
- package/annotation-context/annotation/styles.scoped.css +30 -30
- package/annotation-context/annotation/styles.selectors.js +24 -24
- package/app-layout/visual-refresh/styles.css.js +59 -59
- package/app-layout/visual-refresh/styles.scoped.css +218 -218
- package/app-layout/visual-refresh/styles.selectors.js +59 -59
- package/attribute-editor/interfaces.d.ts +7 -0
- package/attribute-editor/interfaces.d.ts.map +1 -1
- package/attribute-editor/interfaces.js.map +1 -1
- package/attribute-editor/internal.d.ts.map +1 -1
- package/attribute-editor/internal.js +2 -2
- package/attribute-editor/internal.js.map +1 -1
- package/attribute-editor/row.d.ts +2 -1
- package/attribute-editor/row.d.ts.map +1 -1
- package/attribute-editor/row.js +5 -10
- package/attribute-editor/row.js.map +1 -1
- package/calendar/grid/index.d.ts +15 -3
- package/calendar/grid/index.d.ts.map +1 -1
- package/calendar/grid/index.js +19 -17
- package/calendar/grid/index.js.map +1 -1
- package/calendar/internal.d.ts.map +1 -1
- package/calendar/internal.js +5 -17
- package/calendar/internal.js.map +1 -1
- package/calendar/utils/intl.d.ts +2 -3
- package/calendar/utils/intl.d.ts.map +1 -1
- package/calendar/utils/intl.js +6 -5
- package/calendar/utils/intl.js.map +1 -1
- package/calendar/utils/navigation.d.ts +6 -0
- package/calendar/utils/navigation.d.ts.map +1 -0
- package/calendar/utils/navigation.js +38 -0
- package/calendar/utils/navigation.js.map +1 -0
- package/date-picker/index.d.ts.map +1 -1
- package/date-picker/index.js +2 -1
- package/date-picker/index.js.map +1 -1
- package/date-picker/styles.css.js +6 -7
- package/date-picker/styles.scoped.css +7 -13
- package/date-picker/styles.selectors.js +6 -7
- package/date-range-picker/calendar/grids/grid.d.ts.map +1 -1
- package/date-range-picker/calendar/grids/grid.js +2 -2
- package/date-range-picker/calendar/grids/grid.js.map +1 -1
- package/date-range-picker/calendar/grids/index.d.ts +1 -3
- package/date-range-picker/calendar/grids/index.d.ts.map +1 -1
- package/date-range-picker/calendar/grids/index.js +10 -11
- package/date-range-picker/calendar/grids/index.js.map +1 -1
- package/date-range-picker/calendar/header/index.d.ts +2 -2
- package/date-range-picker/calendar/header/index.d.ts.map +1 -1
- package/date-range-picker/calendar/header/index.js +13 -9
- package/date-range-picker/calendar/header/index.js.map +1 -1
- package/date-range-picker/calendar/index.d.ts.map +1 -1
- package/date-range-picker/calendar/index.js +4 -6
- package/date-range-picker/calendar/index.js.map +1 -1
- package/date-range-picker/dropdown.js +1 -1
- package/date-range-picker/dropdown.js.map +1 -1
- package/date-range-picker/interfaces.d.ts +4 -0
- package/date-range-picker/interfaces.d.ts.map +1 -1
- package/date-range-picker/interfaces.js.map +1 -1
- package/flashbar/index.d.ts.map +1 -1
- package/flashbar/index.js +105 -34
- package/flashbar/index.js.map +1 -1
- package/flashbar/styles.css.js +29 -22
- package/flashbar/styles.scoped.css +208 -86
- package/flashbar/styles.selectors.js +29 -22
- package/form/interfaces.d.ts +5 -0
- package/form/interfaces.d.ts.map +1 -1
- package/form/interfaces.js.map +1 -1
- package/form/internal.d.ts +1 -1
- package/form/internal.d.ts.map +1 -1
- package/form/internal.js +10 -5
- package/form/internal.js.map +1 -1
- package/input/internal.d.ts +2 -1
- package/input/internal.d.ts.map +1 -1
- package/input/internal.js +4 -0
- package/input/internal.js.map +1 -1
- package/input/utils.js +1 -1
- package/input/utils.js.map +1 -1
- package/internal/components/autosuggest-input/index.js +1 -1
- package/internal/components/autosuggest-input/index.js.map +1 -1
- package/internal/components/live-region/index.d.ts +3 -2
- package/internal/components/live-region/index.d.ts.map +1 -1
- package/internal/components/live-region/index.js +5 -2
- package/internal/components/live-region/index.js.map +1 -1
- package/internal/components/live-region/styles.css.js +1 -1
- package/internal/components/live-region/styles.scoped.css +2 -92
- package/internal/components/live-region/styles.selectors.js +1 -1
- package/internal/components/screenreader-only/index.d.ts +22 -0
- package/internal/components/screenreader-only/index.d.ts.map +1 -0
- package/internal/components/screenreader-only/index.js +24 -0
- package/internal/components/screenreader-only/index.js.map +1 -0
- package/internal/components/screenreader-only/styles.css.js +6 -0
- package/internal/components/screenreader-only/styles.scoped.css +97 -0
- package/internal/components/screenreader-only/styles.selectors.js +7 -0
- package/internal/components/visual-context/index.d.ts +7 -0
- package/internal/components/visual-context/index.d.ts.map +1 -1
- package/internal/components/visual-context/index.js +10 -1
- package/internal/components/visual-context/index.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/generated/custom-css-properties/index.d.ts.map +1 -1
- package/internal/generated/custom-css-properties/index.js +26 -24
- package/internal/generated/custom-css-properties/index.js.map +1 -1
- package/package.json +1 -1
- package/select/parts/filter.js +1 -1
- package/select/parts/filter.js.map +1 -1
- package/tag-editor/index.d.ts.map +1 -1
- package/tag-editor/index.js +1 -1
- package/tag-editor/index.js.map +1 -1
- package/tutorial-panel/interfaces.d.ts +2 -1
- package/tutorial-panel/interfaces.d.ts.map +1 -1
- package/tutorial-panel/interfaces.js.map +1 -1
- package/wizard/interfaces.d.ts +3 -0
- package/wizard/interfaces.d.ts.map +1 -1
- package/wizard/interfaces.js.map +1 -1
- package/wizard/wizard-form.d.ts.map +1 -1
- package/wizard/wizard-form.js +1 -1
- package/wizard/wizard-form.js.map +1 -1
- package/wizard/wizard-navigation.d.ts.map +1 -1
- package/wizard/wizard-navigation.js +1 -1
- package/wizard/wizard-navigation.js.map +1 -1
- package/calendar/utils/move-focus-handler.d.ts +0 -7
- package/calendar/utils/move-focus-handler.d.ts.map +0 -1
- package/calendar/utils/move-focus-handler.js +0 -24
- package/calendar/utils/move-focus-handler.js.map +0 -1
- package/calendar/utils/rotate-day-indexes.d.ts +0 -3
- package/calendar/utils/rotate-day-indexes.d.ts.map +0 -1
- package/calendar/utils/rotate-day-indexes.js +0 -11
- package/calendar/utils/rotate-day-indexes.js.map +0 -1
- package/date-range-picker/calendar/get-base-date.d.ts +0 -3
- package/date-range-picker/calendar/get-base-date.d.ts.map +0 -1
- package/date-range-picker/calendar/get-base-date.js +0 -10
- package/date-range-picker/calendar/get-base-date.js.map +0 -1
|
@@ -2,64 +2,64 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"appbar": "
|
|
6
|
-
"appbar-nav": "awsui_appbar-
|
|
7
|
-
"breadcrumbs": "
|
|
8
|
-
"appbar-tools": "awsui_appbar-
|
|
9
|
-
"has-breadcrumbs": "awsui_has-
|
|
10
|
-
"has-notifications-content": "awsui_has-notifications-
|
|
11
|
-
"has-header": "awsui_has-
|
|
12
|
-
"has-dynamic-overlap-height": "awsui_has-dynamic-overlap-
|
|
13
|
-
"content-type-wizard": "awsui_content-type-
|
|
14
|
-
"content-type-cards": "awsui_content-type-
|
|
15
|
-
"content-type-table": "awsui_content-type-
|
|
16
|
-
"background": "
|
|
17
|
-
"notifications-appbar-header": "awsui_notifications-appbar-
|
|
18
|
-
"sticky-notifications": "awsui_sticky-
|
|
19
|
-
"overlap": "
|
|
20
|
-
"content": "
|
|
21
|
-
"layout": "
|
|
22
|
-
"has-max-content-width": "awsui_has-max-content-
|
|
23
|
-
"is-overlap-disabled": "awsui_is-overlap-
|
|
24
|
-
"disable-body-scroll": "awsui_disable-body-
|
|
25
|
-
"has-sticky-notifications": "awsui_has-sticky-
|
|
26
|
-
"has-split-panel": "awsui_has-split-
|
|
27
|
-
"split-panel-position-bottom": "awsui_split-panel-position-
|
|
28
|
-
"has-content-gap-left": "awsui_has-content-gap-
|
|
29
|
-
"has-content-gap-right": "awsui_has-content-gap-
|
|
30
|
-
"block-body-scroll": "awsui_block-body-
|
|
31
|
-
"container": "
|
|
32
|
-
"disable-content-paddings": "awsui_disable-content-
|
|
33
|
-
"is-navigation-open": "awsui_is-navigation-
|
|
34
|
-
"is-tools-open": "awsui_is-tools-
|
|
35
|
-
"is-split-panel-open": "awsui_is-split-panel-
|
|
36
|
-
"split-panel-position-side": "awsui_split-panel-position-
|
|
37
|
-
"content-type-default": "awsui_content-type-
|
|
38
|
-
"content-type-form": "awsui_content-type-
|
|
39
|
-
"unfocusable": "
|
|
40
|
-
"navigation-container": "awsui_navigation-
|
|
41
|
-
"show-navigation": "awsui_show-
|
|
42
|
-
"animating": "
|
|
43
|
-
"showButtons": "
|
|
44
|
-
"navigation": "
|
|
45
|
-
"openNavigation": "
|
|
46
|
-
"animated-content": "awsui_animated-
|
|
47
|
-
"hide-navigation": "awsui_hide-
|
|
48
|
-
"notifications": "
|
|
49
|
-
"split-panel-bottom": "awsui_split-panel-
|
|
50
|
-
"position-bottom": "awsui_position-
|
|
51
|
-
"openSplitPanelBottom": "
|
|
52
|
-
"split-panel-side": "awsui_split-panel-
|
|
53
|
-
"position-side": "awsui_position-
|
|
54
|
-
"openSplitPanelSide": "
|
|
55
|
-
"tools-container": "awsui_tools-
|
|
56
|
-
"tools": "
|
|
57
|
-
"openTools": "
|
|
58
|
-
"has-tools-form-persistence": "awsui_has-tools-form-
|
|
59
|
-
"hide-tools": "awsui_hide-
|
|
60
|
-
"show-tools": "awsui_show-
|
|
61
|
-
"has-tools-form": "awsui_has-tools-
|
|
62
|
-
"trigger": "
|
|
63
|
-
"selected": "
|
|
5
|
+
"appbar": "awsui_appbar_hyvsj_1al7x_93",
|
|
6
|
+
"appbar-nav": "awsui_appbar-nav_hyvsj_1al7x_117",
|
|
7
|
+
"breadcrumbs": "awsui_breadcrumbs_hyvsj_1al7x_121",
|
|
8
|
+
"appbar-tools": "awsui_appbar-tools_hyvsj_1al7x_125",
|
|
9
|
+
"has-breadcrumbs": "awsui_has-breadcrumbs_hyvsj_1al7x_160",
|
|
10
|
+
"has-notifications-content": "awsui_has-notifications-content_hyvsj_1al7x_167",
|
|
11
|
+
"has-header": "awsui_has-header_hyvsj_1al7x_173",
|
|
12
|
+
"has-dynamic-overlap-height": "awsui_has-dynamic-overlap-height_hyvsj_1al7x_173",
|
|
13
|
+
"content-type-wizard": "awsui_content-type-wizard_hyvsj_1al7x_174",
|
|
14
|
+
"content-type-cards": "awsui_content-type-cards_hyvsj_1al7x_177",
|
|
15
|
+
"content-type-table": "awsui_content-type-table_hyvsj_1al7x_178",
|
|
16
|
+
"background": "awsui_background_hyvsj_1al7x_213",
|
|
17
|
+
"notifications-appbar-header": "awsui_notifications-appbar-header_hyvsj_1al7x_216",
|
|
18
|
+
"sticky-notifications": "awsui_sticky-notifications_hyvsj_1al7x_228",
|
|
19
|
+
"overlap": "awsui_overlap_hyvsj_1al7x_234",
|
|
20
|
+
"content": "awsui_content_hyvsj_1al7x_174",
|
|
21
|
+
"layout": "awsui_layout_hyvsj_1al7x_322",
|
|
22
|
+
"has-max-content-width": "awsui_has-max-content-width_hyvsj_1al7x_404",
|
|
23
|
+
"is-overlap-disabled": "awsui_is-overlap-disabled_hyvsj_1al7x_431",
|
|
24
|
+
"disable-body-scroll": "awsui_disable-body-scroll_hyvsj_1al7x_434",
|
|
25
|
+
"has-sticky-notifications": "awsui_has-sticky-notifications_hyvsj_1al7x_438",
|
|
26
|
+
"has-split-panel": "awsui_has-split-panel_hyvsj_1al7x_452",
|
|
27
|
+
"split-panel-position-bottom": "awsui_split-panel-position-bottom_hyvsj_1al7x_452",
|
|
28
|
+
"has-content-gap-left": "awsui_has-content-gap-left_hyvsj_1al7x_464",
|
|
29
|
+
"has-content-gap-right": "awsui_has-content-gap-right_hyvsj_1al7x_467",
|
|
30
|
+
"block-body-scroll": "awsui_block-body-scroll_hyvsj_1al7x_482",
|
|
31
|
+
"container": "awsui_container_hyvsj_1al7x_490",
|
|
32
|
+
"disable-content-paddings": "awsui_disable-content-paddings_hyvsj_1al7x_507",
|
|
33
|
+
"is-navigation-open": "awsui_is-navigation-open_hyvsj_1al7x_512",
|
|
34
|
+
"is-tools-open": "awsui_is-tools-open_hyvsj_1al7x_515",
|
|
35
|
+
"is-split-panel-open": "awsui_is-split-panel-open_hyvsj_1al7x_515",
|
|
36
|
+
"split-panel-position-side": "awsui_split-panel-position-side_hyvsj_1al7x_515",
|
|
37
|
+
"content-type-default": "awsui_content-type-default_hyvsj_1al7x_535",
|
|
38
|
+
"content-type-form": "awsui_content-type-form_hyvsj_1al7x_535",
|
|
39
|
+
"unfocusable": "awsui_unfocusable_hyvsj_1al7x_576",
|
|
40
|
+
"navigation-container": "awsui_navigation-container_hyvsj_1al7x_584",
|
|
41
|
+
"show-navigation": "awsui_show-navigation_hyvsj_1al7x_608",
|
|
42
|
+
"animating": "awsui_animating_hyvsj_1al7x_630",
|
|
43
|
+
"showButtons": "awsui_showButtons_hyvsj_1al7x_1",
|
|
44
|
+
"navigation": "awsui_navigation_hyvsj_1al7x_584",
|
|
45
|
+
"openNavigation": "awsui_openNavigation_hyvsj_1al7x_1",
|
|
46
|
+
"animated-content": "awsui_animated-content_hyvsj_1al7x_690",
|
|
47
|
+
"hide-navigation": "awsui_hide-navigation_hyvsj_1al7x_699",
|
|
48
|
+
"notifications": "awsui_notifications_hyvsj_1al7x_216",
|
|
49
|
+
"split-panel-bottom": "awsui_split-panel-bottom_hyvsj_1al7x_766",
|
|
50
|
+
"position-bottom": "awsui_position-bottom_hyvsj_1al7x_801",
|
|
51
|
+
"openSplitPanelBottom": "awsui_openSplitPanelBottom_hyvsj_1al7x_1",
|
|
52
|
+
"split-panel-side": "awsui_split-panel-side_hyvsj_1al7x_830",
|
|
53
|
+
"position-side": "awsui_position-side_hyvsj_1al7x_857",
|
|
54
|
+
"openSplitPanelSide": "awsui_openSplitPanelSide_hyvsj_1al7x_1",
|
|
55
|
+
"tools-container": "awsui_tools-container_hyvsj_1al7x_894",
|
|
56
|
+
"tools": "awsui_tools_hyvsj_1al7x_894",
|
|
57
|
+
"openTools": "awsui_openTools_hyvsj_1al7x_1",
|
|
58
|
+
"has-tools-form-persistence": "awsui_has-tools-form-persistence_hyvsj_1al7x_977",
|
|
59
|
+
"hide-tools": "awsui_hide-tools_hyvsj_1al7x_987",
|
|
60
|
+
"show-tools": "awsui_show-tools_hyvsj_1al7x_999",
|
|
61
|
+
"has-tools-form": "awsui_has-tools-form_hyvsj_1al7x_977",
|
|
62
|
+
"trigger": "awsui_trigger_hyvsj_1al7x_1056",
|
|
63
|
+
"selected": "awsui_selected_hyvsj_1al7x_1094"
|
|
64
64
|
};
|
|
65
65
|
|
|
@@ -24,6 +24,9 @@ export declare namespace AttributeEditorProps {
|
|
|
24
24
|
interface Ref {
|
|
25
25
|
focusRemoveButton(itemIndex: number): void;
|
|
26
26
|
}
|
|
27
|
+
interface I18nStrings {
|
|
28
|
+
errorIconAriaLabel?: string;
|
|
29
|
+
}
|
|
27
30
|
}
|
|
28
31
|
export interface AttributeEditorProps<T> extends BaseComponentProps {
|
|
29
32
|
/**
|
|
@@ -78,5 +81,9 @@ export interface AttributeEditorProps<T> extends BaseComponentProps {
|
|
|
78
81
|
* The event `detail` contains the index of the corresponding item.
|
|
79
82
|
*/
|
|
80
83
|
onRemoveButtonClick?: NonCancelableEventHandler<AttributeEditorProps.RemoveButtonClickDetail>;
|
|
84
|
+
/**
|
|
85
|
+
* An object containing all the necessary localized strings required by the component.
|
|
86
|
+
*/
|
|
87
|
+
i18nStrings?: AttributeEditorProps.I18nStrings;
|
|
81
88
|
}
|
|
82
89
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/attribute-editor/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAA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;IACH,WAAW,CAAC,EAAE,oBAAoB,CAAC,WAAW,CAAC;CAChD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/attribute-editor/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\n/*\n * HACK: Cast the component to a named parametrized interface.\n *\n * This lets us use React.forwardRef and still let the component have type\n * parameters, and the naming convention lets the documenter know that this is\n * a forwardRef-wrapped component.\n *\n * We don't need to expose this type to customers because it's just a simple\n * function type.\n */\nexport interface AttributeEditorForwardRefType {\n <T>(props: AttributeEditorProps<T> & { ref?: React.Ref<AttributeEditorProps.Ref> }): JSX.Element;\n}\n\nexport namespace AttributeEditorProps {\n export interface IsItemRemovableFunction<T> {\n (item: T): boolean;\n }\n\n export type FieldRenderable<T> = (item: T, itemIndex: number) => React.ReactNode;\n export interface FieldDefinition<T> {\n label?: React.ReactNode;\n info?: React.ReactNode;\n control?: FieldRenderable<T> | React.ReactNode;\n errorText?: FieldRenderable<T> | React.ReactNode;\n constraintText?: FieldRenderable<T> | React.ReactNode;\n }\n\n export interface RemoveButtonClickDetail {\n itemIndex: number;\n }\n\n export interface Ref {\n focusRemoveButton(itemIndex: number): void;\n }\n}\n\nexport interface AttributeEditorProps<T> extends BaseComponentProps {\n /**\n * Displayed when there are no items to display.\n */\n empty?: React.ReactNode;\n\n /**\n * Displayed below the add button. Use it for additional information related to the attribute editor.\n */\n additionalInfo?: React.ReactNode;\n\n /**\n * Specifies the text that's displayed in the add button.\n */\n addButtonText: string;\n\n /**\n * Specifies the text that's displayed in the remove button.\n */\n removeButtonText: string;\n\n /**\n * Specifies the items that serve as the data source for all rows.\n * The display of a row is handled by the `definition` property.\n */\n items?: ReadonlyArray<T>;\n\n /**\n * Function that determines whether an item is removable. When this function returns `false`, the remove\n * button is not rendered and the user can't remove the item.\n * By default, all items are removable.\n */\n isItemRemovable?: AttributeEditorProps.IsItemRemovableFunction<T>;\n\n /**\n * Determines whether the add button is disabled.\n */\n disableAddButton?: boolean;\n\n /**\n * Defines the editor configuration. Each object in the array represents one form field in the row.\n * * `label` (ReactNode) - Text label for the form field.\n * * `info` (ReactNode) - Info link for the form field.\n * * `errorText` ((item, itemIndex) => ReactNode) - Error message text to display as a control validation message.\n * It renders the form field as invalid if the returned value is not `null` or `undefined`.\n * * `constraintText` ((item, itemIndex) => ReactNode) - Text to display as a constraint message below the field.\n * * `control` ((item, itemIndex) => ReactNode) - A control to use as the input for the field.\n *\n * A maximum of four fields are supported.\n */\n definition: ReadonlyArray<AttributeEditorProps.FieldDefinition<T>>;\n\n /**\n * Called when add button is clicked.\n */\n onAddButtonClick?: NonCancelableEventHandler;\n\n /**\n * Called when remove button is clicked.\n * The event `detail` contains the index of the corresponding item.\n */\n onRemoveButtonClick?: NonCancelableEventHandler<AttributeEditorProps.RemoveButtonClickDetail>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/attribute-editor/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\n/*\n * HACK: Cast the component to a named parametrized interface.\n *\n * This lets us use React.forwardRef and still let the component have type\n * parameters, and the naming convention lets the documenter know that this is\n * a forwardRef-wrapped component.\n *\n * We don't need to expose this type to customers because it's just a simple\n * function type.\n */\nexport interface AttributeEditorForwardRefType {\n <T>(props: AttributeEditorProps<T> & { ref?: React.Ref<AttributeEditorProps.Ref> }): JSX.Element;\n}\n\nexport namespace AttributeEditorProps {\n export interface IsItemRemovableFunction<T> {\n (item: T): boolean;\n }\n\n export type FieldRenderable<T> = (item: T, itemIndex: number) => React.ReactNode;\n export interface FieldDefinition<T> {\n label?: React.ReactNode;\n info?: React.ReactNode;\n control?: FieldRenderable<T> | React.ReactNode;\n errorText?: FieldRenderable<T> | React.ReactNode;\n constraintText?: FieldRenderable<T> | React.ReactNode;\n }\n\n export interface RemoveButtonClickDetail {\n itemIndex: number;\n }\n\n export interface Ref {\n focusRemoveButton(itemIndex: number): void;\n }\n\n export interface I18nStrings {\n errorIconAriaLabel?: string;\n }\n}\n\nexport interface AttributeEditorProps<T> extends BaseComponentProps {\n /**\n * Displayed when there are no items to display.\n */\n empty?: React.ReactNode;\n\n /**\n * Displayed below the add button. Use it for additional information related to the attribute editor.\n */\n additionalInfo?: React.ReactNode;\n\n /**\n * Specifies the text that's displayed in the add button.\n */\n addButtonText: string;\n\n /**\n * Specifies the text that's displayed in the remove button.\n */\n removeButtonText: string;\n\n /**\n * Specifies the items that serve as the data source for all rows.\n * The display of a row is handled by the `definition` property.\n */\n items?: ReadonlyArray<T>;\n\n /**\n * Function that determines whether an item is removable. When this function returns `false`, the remove\n * button is not rendered and the user can't remove the item.\n * By default, all items are removable.\n */\n isItemRemovable?: AttributeEditorProps.IsItemRemovableFunction<T>;\n\n /**\n * Determines whether the add button is disabled.\n */\n disableAddButton?: boolean;\n\n /**\n * Defines the editor configuration. Each object in the array represents one form field in the row.\n * * `label` (ReactNode) - Text label for the form field.\n * * `info` (ReactNode) - Info link for the form field.\n * * `errorText` ((item, itemIndex) => ReactNode) - Error message text to display as a control validation message.\n * It renders the form field as invalid if the returned value is not `null` or `undefined`.\n * * `constraintText` ((item, itemIndex) => ReactNode) - Text to display as a constraint message below the field.\n * * `control` ((item, itemIndex) => ReactNode) - A control to use as the input for the field.\n *\n * A maximum of four fields are supported.\n */\n definition: ReadonlyArray<AttributeEditorProps.FieldDefinition<T>>;\n\n /**\n * Called when add button is clicked.\n */\n onAddButtonClick?: NonCancelableEventHandler;\n\n /**\n * Called when remove button is clicked.\n * The event `detail` contains the index of the corresponding item.\n */\n onRemoveButtonClick?: NonCancelableEventHandler<AttributeEditorProps.RemoveButtonClickDetail>;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n */\n i18nStrings?: AttributeEditorProps.I18nStrings;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/attribute-editor/internal.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,6BAA6B,EAAwB,MAAM,cAAc,CAAC;AAanF,QAAA,MAAM,uBAAuB,+
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/attribute-editor/internal.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,6BAA6B,EAAwB,MAAM,cAAc,CAAC;AAanF,QAAA,MAAM,uBAAuB,+BAgEK,CAAC;AAEnC,eAAe,uBAAuB,CAAC"}
|
|
@@ -12,7 +12,7 @@ import { useContainerBreakpoints } from '../internal/hooks/container-queries';
|
|
|
12
12
|
import InternalBox from '../box/internal';
|
|
13
13
|
import { useMergeRefs } from '../internal/hooks/use-merge-refs';
|
|
14
14
|
var InternalAttributeEditor = React.forwardRef(function (_a, ref) {
|
|
15
|
-
var additionalInfo = _a.additionalInfo, disableAddButton = _a.disableAddButton, definition = _a.definition, items = _a.items, _b = _a.isItemRemovable, isItemRemovable = _b === void 0 ? function () { return true; } : _b, empty = _a.empty, addButtonText = _a.addButtonText, removeButtonText = _a.removeButtonText, onAddButtonClick = _a.onAddButtonClick, onRemoveButtonClick = _a.onRemoveButtonClick, _c = _a.__internalRootRef, __internalRootRef = _c === void 0 ? null : _c, props = __rest(_a, ["additionalInfo", "disableAddButton", "definition", "items", "isItemRemovable", "empty", "addButtonText", "removeButtonText", "onAddButtonClick", "onRemoveButtonClick", "__internalRootRef"]);
|
|
15
|
+
var additionalInfo = _a.additionalInfo, disableAddButton = _a.disableAddButton, definition = _a.definition, items = _a.items, _b = _a.isItemRemovable, isItemRemovable = _b === void 0 ? function () { return true; } : _b, empty = _a.empty, addButtonText = _a.addButtonText, removeButtonText = _a.removeButtonText, i18nStrings = _a.i18nStrings, onAddButtonClick = _a.onAddButtonClick, onRemoveButtonClick = _a.onRemoveButtonClick, _c = _a.__internalRootRef, __internalRootRef = _c === void 0 ? null : _c, props = __rest(_a, ["additionalInfo", "disableAddButton", "definition", "items", "isItemRemovable", "empty", "addButtonText", "removeButtonText", "i18nStrings", "onAddButtonClick", "onRemoveButtonClick", "__internalRootRef"]);
|
|
16
16
|
var _d = useContainerBreakpoints(['default', 'xxs', 'xs']), breakpoint = _d[0], breakpointRef = _d[1];
|
|
17
17
|
var removeButtonRefs = useRef([]);
|
|
18
18
|
var baseProps = getBaseProps(props);
|
|
@@ -27,7 +27,7 @@ var InternalAttributeEditor = React.forwardRef(function (_a, ref) {
|
|
|
27
27
|
return (React.createElement("div", __assign({}, baseProps, { ref: mergedRef, className: clsx(baseProps.className, styles.root) }),
|
|
28
28
|
React.createElement(InternalBox, { margin: { bottom: 'l' } },
|
|
29
29
|
isEmpty && React.createElement("div", { className: styles.empty }, empty),
|
|
30
|
-
items.map(function (item, index) { return (React.createElement(Row, { key: index, index: index, breakpoint: breakpoint, item: item, definition: definition, removable: isItemRemovable(item), removeButtonText: removeButtonText, removeButtonRefs: removeButtonRefs.current, onRemoveButtonClick: onRemoveButtonClick })); })),
|
|
30
|
+
items.map(function (item, index) { return (React.createElement(Row, { key: index, index: index, breakpoint: breakpoint, item: item, definition: definition, i18nStrings: i18nStrings, removable: isItemRemovable(item), removeButtonText: removeButtonText, removeButtonRefs: removeButtonRefs.current, onRemoveButtonClick: onRemoveButtonClick })); })),
|
|
31
31
|
React.createElement(InternalButton, { className: styles['add-button'], disabled: disableAddButton, onClick: onAddButtonClick, formAction: "none" }, addButtonText),
|
|
32
32
|
additionalInfo && React.createElement(AdditionalInfo, null, additionalInfo)));
|
|
33
33
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/attribute-editor/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG1D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAKhE,IAAM,uBAAuB,GAAG,KAAK,CAAC,UAAU,CAC9C,UACE,
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/attribute-editor/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG1D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,YAAY,EA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AAM,EAAE,GAAG,EAAE;YACjC,OAAO,IAAI,6BAAK,SAAS,EAAE,MAAM,CAAC,KAAK,IAAG,KAAK,CAAO;YACtD,KAAK,CAAC,GAAG,CAAC,UAAC,IAAI,EAAE,KAAK,IAAK,OAAA,CAC1B,oBAAC,GAAG,IACF,GAAG,EAAE,KAAK,EACV,KAAK,EAAE,KAAK,EACZ,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,eAAe,CAAC,IAAI,CAAC,EAChC,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,gBAAgB,CAAC,OAAO,EAC1C,mBAAmB,EAAE,mBAAmB,GACxC,CACH,EAb2B,CAa3B,CAAC,CACU;QACd,oBAAC,cAAc,IACb,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC,EAC/B,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE,gBAAgB,EACzB,UAAU,EAAC,MAAM,IAEhB,aAAa,CACC;QAChB,cAAc,IAAI,oBAAC,cAAc,QAAE,cAAc,CAAkB,CAChE,CACP,CAAC;AACJ,CAAC,CAC+B,CAAC;AAEnC,eAAe,uBAAuB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useImperativeHandle, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\n\nimport { ButtonProps } from '../button/interfaces';\nimport { InternalButton } from '../button/internal';\n\nimport { AttributeEditorForwardRefType, AttributeEditorProps } from './interfaces';\nimport { AdditionalInfo } from './additional-info';\nimport { Row } from './row';\n\nimport styles from './styles.css.js';\nimport { useContainerBreakpoints } from '../internal/hooks/container-queries';\nimport InternalBox from '../box/internal';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { SomeRequired } from '../internal/types';\n\ntype InternalAttributeEditorProps<T> = SomeRequired<AttributeEditorProps<T>, 'items'> & InternalBaseComponentProps;\n\nconst InternalAttributeEditor = React.forwardRef(\n <T,>(\n {\n additionalInfo,\n disableAddButton,\n definition,\n items,\n isItemRemovable = () => true,\n empty,\n addButtonText,\n removeButtonText,\n i18nStrings,\n onAddButtonClick,\n onRemoveButtonClick,\n __internalRootRef = null,\n ...props\n }: InternalAttributeEditorProps<T>,\n ref: React.Ref<AttributeEditorProps.Ref>\n ) => {\n const [breakpoint, breakpointRef] = useContainerBreakpoints(['default', 'xxs', 'xs']);\n const removeButtonRefs = useRef<Array<ButtonProps.Ref | undefined>>([]);\n\n const baseProps = getBaseProps(props);\n const isEmpty = items && items.length === 0;\n\n useImperativeHandle(ref, () => ({\n focusRemoveButton(rowIndex: number) {\n removeButtonRefs.current[rowIndex]?.focus();\n },\n }));\n\n const mergedRef = useMergeRefs(breakpointRef, __internalRootRef);\n\n return (\n <div {...baseProps} ref={mergedRef} className={clsx(baseProps.className, styles.root)}>\n <InternalBox margin={{ bottom: 'l' }}>\n {isEmpty && <div className={styles.empty}>{empty}</div>}\n {items.map((item, index) => (\n <Row\n key={index}\n index={index}\n breakpoint={breakpoint}\n item={item}\n definition={definition}\n i18nStrings={i18nStrings}\n removable={isItemRemovable(item)}\n removeButtonText={removeButtonText}\n removeButtonRefs={removeButtonRefs.current}\n onRemoveButtonClick={onRemoveButtonClick}\n />\n ))}\n </InternalBox>\n <InternalButton\n className={styles['add-button']}\n disabled={disableAddButton}\n onClick={onAddButtonClick}\n formAction=\"none\"\n >\n {addButtonText}\n </InternalButton>\n {additionalInfo && <AdditionalInfo>{additionalInfo}</AdditionalInfo>}\n </div>\n );\n }\n) as AttributeEditorForwardRefType;\n\nexport default InternalAttributeEditor;\n"]}
|
|
@@ -7,11 +7,12 @@ export interface RowProps<T> {
|
|
|
7
7
|
breakpoint: ColumnLayoutBreakpoint | null;
|
|
8
8
|
item: T;
|
|
9
9
|
definition: ReadonlyArray<AttributeEditorProps.FieldDefinition<T>>;
|
|
10
|
+
i18nStrings: AttributeEditorProps.I18nStrings | undefined;
|
|
10
11
|
index: number;
|
|
11
12
|
removable: boolean;
|
|
12
13
|
removeButtonText: string;
|
|
13
14
|
removeButtonRefs: Array<ButtonProps.Ref | undefined>;
|
|
14
15
|
onRemoveButtonClick?: NonCancelableEventHandler<AttributeEditorProps.RemoveButtonClickDetail>;
|
|
15
16
|
}
|
|
16
|
-
export declare const Row: React.MemoExoticComponent<(<T>({ breakpoint, item, definition, index, removable, removeButtonText, removeButtonRefs, onRemoveButtonClick, }: RowProps<T>) => JSX.Element)>;
|
|
17
|
+
export declare const Row: React.MemoExoticComponent<(<T>({ breakpoint, item, definition, i18nStrings, index, removable, removeButtonText, removeButtonRefs, onRemoveButtonClick, }: RowProps<T>) => JSX.Element)>;
|
|
17
18
|
//# sourceMappingURL=row.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row.d.ts","sourceRoot":"","sources":["../../../src/attribute-editor/row.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAE3C,OAA6B,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAA0B,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"row.d.ts","sourceRoot":"","sources":["../../../src/attribute-editor/row.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAE3C,OAA6B,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAA0B,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAOvF,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,UAAU,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAC1C,IAAI,EAAE,CAAC,CAAC;IACR,UAAU,EAAE,aAAa,CAAC,oBAAoB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IACnE,WAAW,EAAE,oBAAoB,CAAC,WAAW,GAAG,SAAS,CAAC;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,GAAG,SAAS,CAAC,CAAC;IACrD,mBAAmB,CAAC,EAAE,yBAAyB,CAAC,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;CAC/F;AAYD,eAAO,MAAM,GAAG,yLA6Df,CAAC"}
|
package/attribute-editor/row.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __assign, __rest } from "tslib";
|
|
2
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
3
|
import InternalBox from '../box/internal';
|
|
@@ -11,27 +10,23 @@ import InternalGrid from '../grid/internal';
|
|
|
11
10
|
import { InternalButton } from '../button/internal';
|
|
12
11
|
import clsx from 'clsx';
|
|
13
12
|
var Divider = function () { return React.createElement(InternalBox, { className: styles.divider, padding: { top: 'l' } }); };
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
13
|
+
function render(item, itemIndex, slot) {
|
|
14
|
+
return typeof slot === 'function' ? slot(item, itemIndex) : slot;
|
|
15
|
+
}
|
|
18
16
|
var GRID_DEFINITION = [{ colspan: { "default": 12, xs: 9 } }];
|
|
19
17
|
var REMOVABLE_GRID_DEFINITION = [{ colspan: { "default": 12, xs: 9 } }, { colspan: { "default": 12, xs: 3 } }];
|
|
20
18
|
export var Row = React.memo(function (_a) {
|
|
21
|
-
var breakpoint = _a.breakpoint, item = _a.item, definition = _a.definition, index = _a.index, removable = _a.removable, removeButtonText = _a.removeButtonText, removeButtonRefs = _a.removeButtonRefs, onRemoveButtonClick = _a.onRemoveButtonClick;
|
|
19
|
+
var breakpoint = _a.breakpoint, item = _a.item, definition = _a.definition, _b = _a.i18nStrings, i18nStrings = _b === void 0 ? {} : _b, index = _a.index, removable = _a.removable, removeButtonText = _a.removeButtonText, removeButtonRefs = _a.removeButtonRefs, onRemoveButtonClick = _a.onRemoveButtonClick;
|
|
22
20
|
var isNarrowViewport = breakpoint === 'default' || breakpoint === 'xxs';
|
|
23
21
|
var isWideViewport = !isNarrowViewport;
|
|
24
22
|
var handleRemoveClick = useCallback(function () {
|
|
25
23
|
fireNonCancelableEvent(onRemoveButtonClick, { itemIndex: index });
|
|
26
24
|
}, [onRemoveButtonClick, index]);
|
|
27
|
-
var render = function (item, itemIndex, slot) {
|
|
28
|
-
return typeof slot === 'function' ? slot(item, itemIndex) : slot;
|
|
29
|
-
};
|
|
30
25
|
return (React.createElement(InternalBox, { className: styles.row, margin: { bottom: 's' } },
|
|
31
26
|
React.createElement(InternalGrid, { __breakpoint: breakpoint, gridDefinition: removable ? REMOVABLE_GRID_DEFINITION : GRID_DEFINITION },
|
|
32
27
|
React.createElement(InternalColumnLayout, { className: styles['row-control'], columns: definition.length, __breakpoint: breakpoint }, definition.map(function (_a, defIndex) {
|
|
33
28
|
var info = _a.info, label = _a.label, constraintText = _a.constraintText, errorText = _a.errorText, control = _a.control;
|
|
34
|
-
return (React.createElement(
|
|
29
|
+
return (React.createElement(InternalFormField, { key: defIndex, className: styles.field, label: label, info: info, constraintText: render(item, index, constraintText), errorText: render(item, index, errorText), stretch: true, i18nStrings: { errorIconAriaLabel: i18nStrings.errorIconAriaLabel }, __hideLabel: isWideViewport && index > 0 }, render(item, index, control)));
|
|
35
30
|
})),
|
|
36
31
|
removable && (React.createElement(ButtonContainer, { index: index, isNarrowViewport: isNarrowViewport },
|
|
37
32
|
React.createElement(InternalButton, { className: styles['remove-button'], formAction: "none", ref: function (ref) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row.js","sourceRoot":"","sources":["../../../src/attribute-editor/row.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"row.js","sourceRoot":"","sources":["../../../src/attribute-editor/row.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAC1C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AACvD,OAAO,oBAAgD,MAAM,2BAA2B,CAAC;AAGzF,OAAO,EAAE,sBAAsB,EAA6B,MAAM,oBAAoB,CAAC;AACvF,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,IAAM,OAAO,GAAG,cAAM,OAAA,oBAAC,WAAW,IAAC,SAAS,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAI,EAAjE,CAAiE,CAAC;AAcxF,SAAS,MAAM,CACb,IAAO,EACP,SAAiB,EACjB,IAA2E;IAE3E,OAAO,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACnE,CAAC;AAED,IAAM,eAAe,GAAG,CAAC,EAAE,OAAO,EAAE,EAAE,SAAO,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAC9D,IAAM,yBAAyB,GAAG,CAAC,EAAE,OAAO,EAAE,EA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ACzC,IAED,QAAQ,CACL,CACP;AATmF,CASnF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport InternalBox from '../box/internal';\nimport styles from './styles.css.js';\nimport React, { useCallback } from 'react';\nimport InternalFormField from '../form-field/internal';\nimport InternalColumnLayout, { ColumnLayoutBreakpoint } from '../column-layout/internal';\nimport { AttributeEditorProps } from './interfaces';\nimport { ButtonProps } from '../button/interfaces';\nimport { fireNonCancelableEvent, NonCancelableEventHandler } from '../internal/events';\nimport InternalGrid from '../grid/internal';\nimport { InternalButton } from '../button/internal';\nimport clsx from 'clsx';\n\nconst Divider = () => <InternalBox className={styles.divider} padding={{ top: 'l' }} />;\n\nexport interface RowProps<T> {\n breakpoint: ColumnLayoutBreakpoint | null;\n item: T;\n definition: ReadonlyArray<AttributeEditorProps.FieldDefinition<T>>;\n i18nStrings: AttributeEditorProps.I18nStrings | undefined;\n index: number;\n removable: boolean;\n removeButtonText: string;\n removeButtonRefs: Array<ButtonProps.Ref | undefined>;\n onRemoveButtonClick?: NonCancelableEventHandler<AttributeEditorProps.RemoveButtonClickDetail>;\n}\n\nfunction render<T>(\n item: T,\n itemIndex: number,\n slot: AttributeEditorProps.FieldRenderable<T> | React.ReactNode | undefined\n) {\n return typeof slot === 'function' ? slot(item, itemIndex) : slot;\n}\n\nconst GRID_DEFINITION = [{ colspan: { default: 12, xs: 9 } }];\nconst REMOVABLE_GRID_DEFINITION = [{ colspan: { default: 12, xs: 9 } }, { colspan: { default: 12, xs: 3 } }];\nexport const Row = React.memo(\n <T,>({\n breakpoint,\n item,\n definition,\n i18nStrings = {},\n index,\n removable,\n removeButtonText,\n removeButtonRefs,\n onRemoveButtonClick,\n }: RowProps<T>) => {\n const isNarrowViewport = breakpoint === 'default' || breakpoint === 'xxs';\n const isWideViewport = !isNarrowViewport;\n\n const handleRemoveClick = useCallback(() => {\n fireNonCancelableEvent(onRemoveButtonClick, { itemIndex: index });\n }, [onRemoveButtonClick, index]);\n\n return (\n <InternalBox className={styles.row} margin={{ bottom: 's' }}>\n <InternalGrid\n __breakpoint={breakpoint}\n gridDefinition={removable ? REMOVABLE_GRID_DEFINITION : GRID_DEFINITION}\n >\n <InternalColumnLayout className={styles['row-control']} columns={definition.length} __breakpoint={breakpoint}>\n {definition.map(({ info, label, constraintText, errorText, control }, defIndex) => (\n <InternalFormField\n key={defIndex}\n className={styles.field}\n label={label}\n info={info}\n constraintText={render(item, index, constraintText)}\n errorText={render(item, index, errorText)}\n stretch={true}\n i18nStrings={{ errorIconAriaLabel: i18nStrings.errorIconAriaLabel }}\n __hideLabel={isWideViewport && index > 0}\n >\n {render(item, index, control)}\n </InternalFormField>\n ))}\n </InternalColumnLayout>\n {removable && (\n <ButtonContainer index={index} isNarrowViewport={isNarrowViewport}>\n <InternalButton\n className={styles['remove-button']}\n formAction=\"none\"\n ref={ref => {\n removeButtonRefs[index] = ref ?? undefined;\n }}\n onClick={handleRemoveClick}\n >\n {removeButtonText}\n </InternalButton>\n </ButtonContainer>\n )}\n </InternalGrid>\n {isNarrowViewport && <Divider />}\n </InternalBox>\n );\n }\n);\n\ninterface ButtonContainer {\n index: number;\n children: React.ReactNode;\n isNarrowViewport: boolean;\n}\n\nconst ButtonContainer = ({ index, children, isNarrowViewport }: ButtonContainer) => (\n <div\n className={clsx({\n [styles['button-container']]: !isNarrowViewport && index === 0,\n [styles['right-align']]: isNarrowViewport,\n })}\n >\n {children}\n </div>\n);\n"]}
|
package/calendar/grid/index.d.ts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { DayIndex } from '../internal';
|
|
2
|
-
import { MoveFocusHandler } from '../utils/move-focus-handler';
|
|
3
2
|
import { DatePickerProps } from '../../date-picker/interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Calendar grid supports two mechanisms of keyboard navigation:
|
|
5
|
+
* - Native screen-reader table navigation (semantic table markup);
|
|
6
|
+
* - Keyboard arrow-keys navigation (a custom key-down handler).
|
|
7
|
+
*
|
|
8
|
+
* The implementation largely follows the w3 example (https://www.w3.org/WAI/ARIA/apg/example-index/dialog-modal/datepicker-dialog) and shares the following issues:
|
|
9
|
+
* - (table navigation) Chrome+VO - weekday is announced twice when navigating to the calendar's header;
|
|
10
|
+
* - (table navigation) Safari+VO - "dimmed" state is announced twice;
|
|
11
|
+
* - (table navigation) Firefox/Chrome+NVDA - cannot use table navigation if any cell has a focus;
|
|
12
|
+
* - (keyboard navigation) Firefox+NVDA - every day is announced as "not selected";
|
|
13
|
+
* - (keyboard navigation) Safari/Chrome+VO - weekdays are not announced;
|
|
14
|
+
* - (keyboard navigation) Safari/Chrome+VO - days are not announced as interactive (clickable or selectable);
|
|
15
|
+
* - (keyboard navigation) Safari/Chrome+VO - day announcements are not interruptive and can be missed if navigating fast.
|
|
16
|
+
*/
|
|
4
17
|
export interface GridProps {
|
|
5
18
|
locale: string;
|
|
6
19
|
baseDate: Date;
|
|
@@ -13,7 +26,6 @@ export interface GridProps {
|
|
|
13
26
|
startOfWeek: DayIndex;
|
|
14
27
|
todayAriaLabel: string;
|
|
15
28
|
selectedDate: Date | null;
|
|
16
|
-
handleFocusMove: MoveFocusHandler;
|
|
17
29
|
}
|
|
18
|
-
export default function Grid({ locale, baseDate, isDateEnabled, focusedDate, focusableDate, onSelectDate, onFocusDate, onChangeMonth, startOfWeek, todayAriaLabel, selectedDate,
|
|
30
|
+
export default function Grid({ locale, baseDate, isDateEnabled, focusedDate, focusableDate, onSelectDate, onFocusDate, onChangeMonth, startOfWeek, todayAriaLabel, selectedDate, }: GridProps): JSX.Element;
|
|
19
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/calendar/grid/index.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/calendar/grid/index.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAQ/D;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,IAAI,CAAC;IACf,aAAa,EAAE,eAAe,CAAC,qBAAqB,CAAC;IACrD,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,aAAa,EAAE,IAAI,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACnC,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACpC,WAAW,EAAE,QAAQ,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAC3B,MAAM,EACN,QAAQ,EACR,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,WAAW,EACX,aAAa,EACb,WAAW,EACX,cAAc,EACd,YAAY,GACb,EAAE,SAAS,eAoIX"}
|
package/calendar/grid/index.js
CHANGED
|
@@ -4,15 +4,16 @@ import { __assign } from "tslib";
|
|
|
4
4
|
import React, { useMemo, useRef } from 'react';
|
|
5
5
|
import styles from '../styles.css.js';
|
|
6
6
|
import { KeyCode } from '../../internal/keycode';
|
|
7
|
-
import {
|
|
7
|
+
import { isSameDay, isSameMonth } from 'date-fns';
|
|
8
8
|
import { getCalendarMonth } from 'mnth';
|
|
9
|
-
import rotateDayIndexes from '../utils/rotate-day-indexes';
|
|
10
9
|
import { getDateLabel, renderDayName } from '../utils/intl';
|
|
11
10
|
import useFocusVisible from '../../internal/hooks/focus-visible/index.js';
|
|
12
11
|
import clsx from 'clsx';
|
|
13
12
|
import { useEffectOnUpdate } from '../../internal/hooks/use-effect-on-update.js';
|
|
13
|
+
import ScreenreaderOnly from '../../internal/components/screenreader-only/index.js';
|
|
14
|
+
import { moveNextDay, movePrevDay, moveNextWeek, movePrevWeek } from '../utils/navigation';
|
|
14
15
|
export default function Grid(_a) {
|
|
15
|
-
var locale = _a.locale, baseDate = _a.baseDate, isDateEnabled = _a.isDateEnabled, focusedDate = _a.focusedDate, focusableDate = _a.focusableDate, onSelectDate = _a.onSelectDate, onFocusDate = _a.onFocusDate, onChangeMonth = _a.onChangeMonth, startOfWeek = _a.startOfWeek, todayAriaLabel = _a.todayAriaLabel, selectedDate = _a.selectedDate
|
|
16
|
+
var locale = _a.locale, baseDate = _a.baseDate, isDateEnabled = _a.isDateEnabled, focusedDate = _a.focusedDate, focusableDate = _a.focusableDate, onSelectDate = _a.onSelectDate, onFocusDate = _a.onFocusDate, onChangeMonth = _a.onChangeMonth, startOfWeek = _a.startOfWeek, todayAriaLabel = _a.todayAriaLabel, selectedDate = _a.selectedDate;
|
|
16
17
|
var focusedDateRef = useRef(null);
|
|
17
18
|
var onGridKeyDownHandler = function (event) {
|
|
18
19
|
var updatedFocusDate;
|
|
@@ -30,19 +31,19 @@ export default function Grid(_a) {
|
|
|
30
31
|
return;
|
|
31
32
|
case KeyCode.right:
|
|
32
33
|
event.preventDefault();
|
|
33
|
-
updatedFocusDate =
|
|
34
|
+
updatedFocusDate = moveNextDay(focusableDate, isDateEnabled);
|
|
34
35
|
break;
|
|
35
36
|
case KeyCode.left:
|
|
36
37
|
event.preventDefault();
|
|
37
|
-
updatedFocusDate =
|
|
38
|
+
updatedFocusDate = movePrevDay(focusableDate, isDateEnabled);
|
|
38
39
|
break;
|
|
39
40
|
case KeyCode.up:
|
|
40
41
|
event.preventDefault();
|
|
41
|
-
updatedFocusDate =
|
|
42
|
+
updatedFocusDate = movePrevWeek(focusableDate, isDateEnabled);
|
|
42
43
|
break;
|
|
43
44
|
case KeyCode.down:
|
|
44
45
|
event.preventDefault();
|
|
45
|
-
updatedFocusDate =
|
|
46
|
+
updatedFocusDate = moveNextWeek(focusableDate, isDateEnabled);
|
|
46
47
|
break;
|
|
47
48
|
default:
|
|
48
49
|
return;
|
|
@@ -60,10 +61,13 @@ export default function Grid(_a) {
|
|
|
60
61
|
}
|
|
61
62
|
}, [focusedDate]);
|
|
62
63
|
var weeks = useMemo(function () { return getCalendarMonth(baseDate, { firstDayOfWeek: startOfWeek }); }, [baseDate, startOfWeek]);
|
|
64
|
+
var weekdays = weeks[0].map(function (date) { return date.getDay(); });
|
|
63
65
|
var focusVisible = useFocusVisible();
|
|
64
|
-
return (React.createElement("table", { role: "
|
|
66
|
+
return (React.createElement("table", { role: "grid", className: styles['calendar-grid'] },
|
|
65
67
|
React.createElement("thead", null,
|
|
66
|
-
React.createElement("tr", null,
|
|
68
|
+
React.createElement("tr", null, weekdays.map(function (dayIndex) { return (React.createElement("th", { key: dayIndex, scope: "col", className: clsx(styles['calendar-grid-cell'], styles['calendar-day-header']) },
|
|
69
|
+
React.createElement("span", { "aria-hidden": "true" }, renderDayName(locale, dayIndex, 'short')),
|
|
70
|
+
React.createElement(ScreenreaderOnly, null, renderDayName(locale, dayIndex, 'long')))); }))),
|
|
67
71
|
React.createElement("tbody", { onKeyDown: onGridKeyDownHandler }, weeks.map(function (week, weekIndex) { return (React.createElement("tr", { key: weekIndex, className: styles['calendar-week'] }, week.map(function (date, dateIndex) {
|
|
68
72
|
var _a;
|
|
69
73
|
var isFocusable = !!focusableDate && isSameDay(date, focusableDate);
|
|
@@ -81,22 +85,20 @@ export default function Grid(_a) {
|
|
|
81
85
|
tabIndex = -1;
|
|
82
86
|
}
|
|
83
87
|
// Screen-reader announcement for the focused day.
|
|
84
|
-
var dayAnnouncement = getDateLabel(locale, date);
|
|
88
|
+
var dayAnnouncement = getDateLabel(locale, date, 'short');
|
|
85
89
|
if (isDateOnSameDay) {
|
|
86
90
|
dayAnnouncement += '. ' + todayAriaLabel;
|
|
87
91
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
return (React.createElement("td", __assign({ key: "".concat(weekIndex, ":").concat(dateIndex), ref: tabIndex === 0 ? focusedDateRef : undefined, role: "button", tabIndex: tabIndex, "aria-label": dayAnnouncement, "aria-current": isSelected ? 'date' : undefined, "aria-disabled": !isEnabled, onClick: onClick, className: clsx(styles['calendar-grid-cell'], styles['calendar-day'], (_a = {},
|
|
92
|
+
return (React.createElement("td", __assign({ key: "".concat(weekIndex, ":").concat(dateIndex), ref: tabIndex === 0 ? focusedDateRef : undefined, tabIndex: tabIndex, "aria-current": isDateOnSameDay ? 'date' : undefined, "aria-selected": isEnabled ? isSelected : undefined, "aria-disabled": !isEnabled,
|
|
93
|
+
// Do not attach click event when the date is disabled, otherwise VO+safari announces clickable
|
|
94
|
+
onClick: isEnabled ? function () { return onSelectDate(date); } : undefined, className: clsx(styles['calendar-grid-cell'], styles['calendar-day'], (_a = {},
|
|
94
95
|
_a[styles['calendar-day-current-month']] = isSameMonth(date, baseDate),
|
|
95
96
|
_a[styles['calendar-day-enabled']] = isEnabled,
|
|
96
97
|
_a[styles['calendar-day-selected']] = isSelected,
|
|
97
98
|
_a[styles['calendar-day-today']] = isDateOnSameDay,
|
|
98
99
|
_a)) }, focusVisible),
|
|
99
|
-
React.createElement("span", { className: styles['day-inner'], "aria-hidden": "true" }, date.getDate())
|
|
100
|
+
React.createElement("span", { className: styles['day-inner'], "aria-hidden": "true" }, date.getDate()),
|
|
101
|
+
React.createElement(ScreenreaderOnly, null, dayAnnouncement)));
|
|
100
102
|
}))); }))));
|
|
101
103
|
}
|
|
102
104
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../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,YAAY;gBAEhB,8BAAM,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,iBAAc,MAAM,IACrD,IAAI,CAAC,OAAO,EAAE,CACV,CACJ,CACN,CAAC;QACJ,CAAC,CAAC,CACC,CACN,EAvD+B,CAuD/B,CAAC,CACI,CACF,CACT,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useMemo, useRef } from 'react';\nimport styles from '../styles.css.js';\nimport { KeyCode } from '../../internal/keycode';\nimport { addDays, addWeeks, isSameDay, isSameMonth } from 'date-fns';\nimport { getCalendarMonth } from 'mnth';\nimport { DayIndex } from '../internal';\nimport { MoveFocusHandler } from '../utils/move-focus-handler';\nimport { DatePickerProps } from '../../date-picker/interfaces';\nimport rotateDayIndexes from '../utils/rotate-day-indexes';\nimport { getDateLabel, renderDayName } from '../utils/intl';\nimport useFocusVisible from '../../internal/hooks/focus-visible/index.js';\nimport clsx from 'clsx';\nimport { useEffectOnUpdate } from '../../internal/hooks/use-effect-on-update.js';\n\nexport interface GridProps {\n locale: string;\n baseDate: Date;\n isDateEnabled: DatePickerProps.IsDateEnabledFunction;\n focusedDate: Date | null;\n focusableDate: Date | null;\n onSelectDate: (date: Date) => void;\n onFocusDate: (date: null | Date) => void;\n onChangeMonth: (date: Date) => void;\n startOfWeek: DayIndex;\n todayAriaLabel: string;\n selectedDate: Date | null;\n handleFocusMove: MoveFocusHandler;\n}\n\nexport default function Grid({\n locale,\n baseDate,\n isDateEnabled,\n focusedDate,\n focusableDate,\n onSelectDate,\n onFocusDate,\n onChangeMonth,\n startOfWeek,\n todayAriaLabel,\n selectedDate,\n handleFocusMove,\n}: GridProps) {\n const focusedDateRef = useRef<HTMLTableCellElement>(null);\n\n const onGridKeyDownHandler = (event: React.KeyboardEvent) => {\n let updatedFocusDate;\n\n if (focusableDate === null) {\n return;\n }\n\n switch (event.keyCode) {\n case KeyCode.space:\n case KeyCode.enter:\n event.preventDefault();\n if (focusableDate) {\n onFocusDate(null);\n onSelectDate(focusableDate);\n }\n return;\n case KeyCode.right:\n event.preventDefault();\n updatedFocusDate = handleFocusMove(focusableDate, isDateEnabled, date => addDays(date, 1));\n break;\n case KeyCode.left:\n event.preventDefault();\n updatedFocusDate = handleFocusMove(focusableDate, isDateEnabled, date => addDays(date, -1));\n break;\n case KeyCode.up:\n event.preventDefault();\n updatedFocusDate = handleFocusMove(focusableDate, isDateEnabled, date => addWeeks(date, -1));\n break;\n case KeyCode.down:\n event.preventDefault();\n updatedFocusDate = handleFocusMove(focusableDate, isDateEnabled, date => addWeeks(date, 1));\n break;\n default:\n return;\n }\n\n if (!isSameMonth(updatedFocusDate, baseDate)) {\n onChangeMonth(updatedFocusDate);\n }\n onFocusDate(updatedFocusDate);\n };\n\n // The focused date changes as a feedback to keyboard navigation in the grid.\n // Once changed, the corresponding day button needs to receive the actual focus.\n useEffectOnUpdate(() => {\n if (focusedDate && focusedDateRef.current) {\n (focusedDateRef.current as HTMLDivElement).focus();\n }\n }, [focusedDate]);\n\n const weeks = useMemo<Date[][]>(\n () => getCalendarMonth(baseDate, { firstDayOfWeek: startOfWeek }),\n [baseDate, startOfWeek]\n );\n\n const focusVisible = useFocusVisible();\n\n return (\n <table role=\"none\" className={styles['calendar-grid']}>\n <thead>\n <tr>\n {rotateDayIndexes(startOfWeek).map(dayIndex => (\n <th\n key={dayIndex}\n scope=\"col\"\n className={clsx(styles['calendar-grid-cell'], styles['calendar-day-header'])}\n >\n {renderDayName(locale, dayIndex)}\n </th>\n ))}\n </tr>\n </thead>\n <tbody onKeyDown={onGridKeyDownHandler}>\n {weeks.map((week, weekIndex) => (\n <tr key={weekIndex} className={styles['calendar-week']}>\n {week.map((date, dateIndex) => {\n const isFocusable = !!focusableDate && isSameDay(date, focusableDate);\n const isSelected = !!selectedDate && isSameDay(date, selectedDate);\n const isEnabled = !isDateEnabled || isDateEnabled(date);\n const isDateOnSameDay = isSameDay(date, new Date());\n\n // Can't be focused.\n let tabIndex = undefined;\n if (isFocusable && isEnabled) {\n // Next focus target.\n tabIndex = 0;\n } else if (isEnabled) {\n // Can be focused programmatically.\n tabIndex = -1;\n }\n\n // Screen-reader announcement for the focused day.\n let dayAnnouncement = getDateLabel(locale, date);\n if (isDateOnSameDay) {\n dayAnnouncement += '. ' + todayAriaLabel;\n }\n\n const onClick = () => {\n if (isEnabled) {\n onSelectDate(date);\n }\n };\n\n return (\n <td\n key={`${weekIndex}:${dateIndex}`}\n ref={tabIndex === 0 ? focusedDateRef : undefined}\n role=\"button\"\n tabIndex={tabIndex}\n aria-label={dayAnnouncement}\n aria-current={isSelected ? 'date' : undefined}\n aria-disabled={!isEnabled}\n onClick={onClick}\n className={clsx(styles['calendar-grid-cell'], styles['calendar-day'], {\n [styles['calendar-day-current-month']]: isSameMonth(date, baseDate),\n [styles['calendar-day-enabled']]: isEnabled,\n [styles['calendar-day-selected']]: isSelected,\n [styles['calendar-day-today']]: isDateOnSameDay,\n })}\n {...focusVisible}\n >\n <span className={styles['day-inner']} aria-hidden=\"true\">\n {date.getDate()}\n </span>\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/calendar/grid/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,eAAe,MAAM,6CAA6C,CAA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,OAAO,CACL,qCACE,GAAG,EAAE,UAAG,SAAS,cAAI,SAAS,CAAE,EAChC,GAAG,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,EAChD,QAAQ,EAAE,QAAQ,kBACJ,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,mBACnC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,mBAClC,CAAC,SAAS;gBACzB,+FAA+F;gBAC/F,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,cAAM,OAAA,YAAY,CAAC,IAAI,CAAC,EAAlB,CAAkB,CAAC,CAAC,CAAC,SAAS,EACzD,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;oBAClE,GAAC,MAAM,CAAC,4BAA4B,CAAC,IAAG,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC;oBACnE,GAAC,MAAM,CAAC,sBAAsB,CAAC,IAAG,SAAS;oBAC3C,GAAC,MAAM,CAAC,uBAAuB,CAAC,IAAG,UAAU;oBAC7C,GAAC,MAAM,CAAC,oBAAoB,CAAC,IAAG,eAAe;wBAC/C,IACE,YAAY;gBAEhB,8BAAM,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,iBAAc,MAAM,IACrD,IAAI,CAAC,OAAO,EAAE,CACV;gBACP,oBAAC,gBAAgB,QAAE,eAAe,CAAoB,CACnD,CACN,CAAC;QACJ,CAAC,CAAC,CACC,CACN,EAlD+B,CAkD/B,CAAC,CACI,CACF,CACT,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useMemo, useRef } from 'react';\nimport styles from '../styles.css.js';\nimport { KeyCode } from '../../internal/keycode';\nimport { isSameDay, isSameMonth } from 'date-fns';\nimport { getCalendarMonth } from 'mnth';\nimport { DayIndex } from '../internal';\nimport { DatePickerProps } from '../../date-picker/interfaces';\nimport { getDateLabel, renderDayName } from '../utils/intl';\nimport useFocusVisible from '../../internal/hooks/focus-visible/index.js';\nimport clsx from 'clsx';\nimport { useEffectOnUpdate } from '../../internal/hooks/use-effect-on-update.js';\nimport ScreenreaderOnly from '../../internal/components/screenreader-only/index.js';\nimport { moveNextDay, movePrevDay, moveNextWeek, movePrevWeek } from '../utils/navigation';\n\n/**\n * Calendar grid supports two mechanisms of keyboard navigation:\n * - Native screen-reader table navigation (semantic table markup);\n * - Keyboard arrow-keys navigation (a custom key-down handler).\n *\n * The implementation largely follows the w3 example (https://www.w3.org/WAI/ARIA/apg/example-index/dialog-modal/datepicker-dialog) and shares the following issues:\n * - (table navigation) Chrome+VO - weekday is announced twice when navigating to the calendar's header;\n * - (table navigation) Safari+VO - \"dimmed\" state is announced twice;\n * - (table navigation) Firefox/Chrome+NVDA - cannot use table navigation if any cell has a focus;\n * - (keyboard navigation) Firefox+NVDA - every day is announced as \"not selected\";\n * - (keyboard navigation) Safari/Chrome+VO - weekdays are not announced;\n * - (keyboard navigation) Safari/Chrome+VO - days are not announced as interactive (clickable or selectable);\n * - (keyboard navigation) Safari/Chrome+VO - day announcements are not interruptive and can be missed if navigating fast.\n */\n\nexport interface GridProps {\n locale: string;\n baseDate: Date;\n isDateEnabled: DatePickerProps.IsDateEnabledFunction;\n focusedDate: Date | null;\n focusableDate: Date | null;\n onSelectDate: (date: Date) => void;\n onFocusDate: (date: null | Date) => void;\n onChangeMonth: (date: Date) => void;\n startOfWeek: DayIndex;\n todayAriaLabel: string;\n selectedDate: Date | null;\n}\n\nexport default function Grid({\n locale,\n baseDate,\n isDateEnabled,\n focusedDate,\n focusableDate,\n onSelectDate,\n onFocusDate,\n onChangeMonth,\n startOfWeek,\n todayAriaLabel,\n selectedDate,\n}: GridProps) {\n const focusedDateRef = useRef<HTMLTableCellElement>(null);\n\n const onGridKeyDownHandler = (event: React.KeyboardEvent) => {\n let updatedFocusDate;\n\n if (focusableDate === null) {\n return;\n }\n\n switch (event.keyCode) {\n case KeyCode.space:\n case KeyCode.enter:\n event.preventDefault();\n if (focusableDate) {\n onFocusDate(null);\n onSelectDate(focusableDate);\n }\n return;\n case KeyCode.right:\n event.preventDefault();\n updatedFocusDate = moveNextDay(focusableDate, isDateEnabled);\n break;\n case KeyCode.left:\n event.preventDefault();\n updatedFocusDate = movePrevDay(focusableDate, isDateEnabled);\n break;\n case KeyCode.up:\n event.preventDefault();\n updatedFocusDate = movePrevWeek(focusableDate, isDateEnabled);\n break;\n case KeyCode.down:\n event.preventDefault();\n updatedFocusDate = moveNextWeek(focusableDate, isDateEnabled);\n break;\n default:\n return;\n }\n\n if (!isSameMonth(updatedFocusDate, baseDate)) {\n onChangeMonth(updatedFocusDate);\n }\n onFocusDate(updatedFocusDate);\n };\n\n // The focused date changes as a feedback to keyboard navigation in the grid.\n // Once changed, the corresponding day button needs to receive the actual focus.\n useEffectOnUpdate(() => {\n if (focusedDate && focusedDateRef.current) {\n (focusedDateRef.current as HTMLDivElement).focus();\n }\n }, [focusedDate]);\n\n const weeks = useMemo<Date[][]>(\n () => getCalendarMonth(baseDate, { firstDayOfWeek: startOfWeek }),\n [baseDate, startOfWeek]\n );\n const weekdays = weeks[0].map(date => date.getDay());\n\n const focusVisible = useFocusVisible();\n\n return (\n <table role=\"grid\" className={styles['calendar-grid']}>\n <thead>\n <tr>\n {weekdays.map(dayIndex => (\n <th\n key={dayIndex}\n scope=\"col\"\n className={clsx(styles['calendar-grid-cell'], styles['calendar-day-header'])}\n >\n <span aria-hidden=\"true\">{renderDayName(locale, dayIndex, 'short')}</span>\n <ScreenreaderOnly>{renderDayName(locale, dayIndex, 'long')}</ScreenreaderOnly>\n </th>\n ))}\n </tr>\n </thead>\n <tbody onKeyDown={onGridKeyDownHandler}>\n {weeks.map((week, weekIndex) => (\n <tr key={weekIndex} className={styles['calendar-week']}>\n {week.map((date, dateIndex) => {\n const isFocusable = !!focusableDate && isSameDay(date, focusableDate);\n const isSelected = !!selectedDate && isSameDay(date, selectedDate);\n const isEnabled = !isDateEnabled || isDateEnabled(date);\n const isDateOnSameDay = isSameDay(date, new Date());\n\n // Can't be focused.\n let tabIndex = undefined;\n if (isFocusable && isEnabled) {\n // Next focus target.\n tabIndex = 0;\n } else if (isEnabled) {\n // Can be focused programmatically.\n tabIndex = -1;\n }\n\n // Screen-reader announcement for the focused day.\n let dayAnnouncement = getDateLabel(locale, date, 'short');\n if (isDateOnSameDay) {\n dayAnnouncement += '. ' + todayAriaLabel;\n }\n\n return (\n <td\n key={`${weekIndex}:${dateIndex}`}\n ref={tabIndex === 0 ? focusedDateRef : undefined}\n tabIndex={tabIndex}\n aria-current={isDateOnSameDay ? 'date' : undefined}\n aria-selected={isEnabled ? isSelected : undefined}\n aria-disabled={!isEnabled}\n // Do not attach click event when the date is disabled, otherwise VO+safari announces clickable\n onClick={isEnabled ? () => onSelectDate(date) : undefined}\n className={clsx(styles['calendar-grid-cell'], styles['calendar-day'], {\n [styles['calendar-day-current-month']]: isSameMonth(date, baseDate),\n [styles['calendar-day-enabled']]: isEnabled,\n [styles['calendar-day-selected']]: isSelected,\n [styles['calendar-day-today']]: isDateOnSameDay,\n })}\n {...focusVisible}\n >\n <span className={styles['day-inner']} aria-hidden=\"true\">\n {date.getDate()}\n </span>\n <ScreenreaderOnly>{dayAnnouncement}</ScreenreaderOnly>\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/calendar/internal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/calendar/internal.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAG3F,oBAAY,QAAQ,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,KAAK,EACL,MAAW,EACX,WAAW,EACX,aAA0B,EAC1B,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,QAAQ,EACR,iBAAiB,EACjB,GAAG,IAAI,EACR,EAAE,aAAa,GAAG,0BAA0B,eA6F5C"}
|