@cloudscape-design/components 3.0.1287 → 3.0.1289
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/action-card/styles.css.js +17 -17
- package/action-card/styles.scoped.css +92 -92
- package/action-card/styles.selectors.js +17 -17
- package/alert/styles.css.js +27 -27
- package/alert/styles.scoped.css +42 -42
- package/alert/styles.selectors.js +27 -27
- package/anchor-navigation/styles.css.js +8 -8
- package/anchor-navigation/styles.scoped.css +22 -22
- package/anchor-navigation/styles.selectors.js +8 -8
- package/annotation-context/annotation/styles.css.js +13 -13
- package/annotation-context/annotation/styles.scoped.css +21 -21
- package/annotation-context/annotation/styles.selectors.js +13 -13
- package/app-layout/visual-refresh/styles.css.js +86 -86
- package/app-layout/visual-refresh/styles.scoped.css +165 -165
- package/app-layout/visual-refresh/styles.selectors.js +86 -86
- package/app-layout/visual-refresh-toolbar/drawer/styles.css.js +32 -32
- package/app-layout/visual-refresh-toolbar/drawer/styles.scoped.css +84 -84
- package/app-layout/visual-refresh-toolbar/drawer/styles.selectors.js +32 -32
- package/app-layout/visual-refresh-toolbar/skeleton/styles.css.js +27 -27
- package/app-layout/visual-refresh-toolbar/skeleton/styles.scoped.css +47 -47
- package/app-layout/visual-refresh-toolbar/skeleton/styles.selectors.js +27 -27
- package/app-layout/visual-refresh-toolbar/toolbar/styles.css.js +14 -14
- package/app-layout/visual-refresh-toolbar/toolbar/styles.scoped.css +32 -32
- package/app-layout/visual-refresh-toolbar/toolbar/styles.selectors.js +14 -14
- package/attribute-editor/styles.css.js +15 -15
- package/attribute-editor/styles.scoped.css +26 -26
- package/attribute-editor/styles.selectors.js +15 -15
- package/badge/styles.css.js +10 -10
- package/badge/styles.scoped.css +11 -11
- package/badge/styles.selectors.js +10 -10
- package/box/styles.css.js +192 -192
- package/box/styles.scoped.css +243 -243
- package/box/styles.selectors.js +192 -192
- package/breadcrumb-group/item/styles.css.js +7 -7
- package/breadcrumb-group/item/styles.scoped.css +26 -26
- package/breadcrumb-group/item/styles.selectors.js +7 -7
- package/breadcrumb-group/styles.css.js +14 -14
- package/breadcrumb-group/styles.scoped.css +27 -27
- package/breadcrumb-group/styles.selectors.js +14 -14
- package/button/styles.css.js +22 -22
- package/button/styles.scoped.css +70 -70
- package/button/styles.selectors.js +22 -22
- package/button-dropdown/category-elements/styles.css.js +18 -18
- package/button-dropdown/category-elements/styles.scoped.css +30 -30
- package/button-dropdown/category-elements/styles.selectors.js +18 -18
- package/button-dropdown/item-element/styles.css.js +21 -21
- package/button-dropdown/item-element/styles.scoped.css +35 -35
- package/button-dropdown/item-element/styles.selectors.js +21 -21
- package/button-dropdown/mobile-expandable-group/styles.css.js +5 -5
- package/button-dropdown/mobile-expandable-group/styles.scoped.css +6 -6
- package/button-dropdown/mobile-expandable-group/styles.selectors.js +5 -5
- package/button-group/styles.css.js +4 -4
- package/button-group/styles.scoped.css +5 -5
- package/button-group/styles.selectors.js +4 -4
- package/calendar/styles.css.js +21 -21
- package/calendar/styles.scoped.css +47 -47
- package/calendar/styles.selectors.js +21 -21
- package/cards/styles.css.js +38 -38
- package/cards/styles.scoped.css +40 -40
- package/cards/styles.selectors.js +38 -38
- package/checkbox/styles.css.js +3 -3
- package/checkbox/styles.scoped.css +6 -6
- package/checkbox/styles.selectors.js +3 -3
- package/code-editor/styles.css.js +33 -33
- package/code-editor/styles.scoped.css +141 -141
- package/code-editor/styles.selectors.js +33 -33
- package/collection-preferences/styles.css.js +36 -36
- package/collection-preferences/styles.scoped.css +38 -38
- package/collection-preferences/styles.selectors.js +36 -36
- package/column-layout/styles.css.js +13 -13
- package/column-layout/styles.scoped.css +44 -44
- package/column-layout/styles.selectors.js +13 -13
- package/container/styles.css.js +33 -33
- package/container/styles.scoped.css +57 -57
- package/container/styles.selectors.js +33 -33
- package/date-picker/styles.css.js +7 -7
- package/date-picker/styles.scoped.css +10 -10
- package/date-picker/styles.selectors.js +7 -7
- package/date-range-picker/calendar/grids/styles.css.js +30 -30
- package/date-range-picker/calendar/grids/styles.scoped.css +58 -58
- package/date-range-picker/calendar/grids/styles.selectors.js +30 -30
- package/date-range-picker/styles.css.js +23 -23
- package/date-range-picker/styles.scoped.css +34 -34
- package/date-range-picker/styles.selectors.js +23 -23
- package/drawer/implementation.d.ts +14 -1
- package/drawer/implementation.d.ts.map +1 -1
- package/drawer/implementation.js +90 -17
- package/drawer/implementation.js.map +1 -1
- package/drawer/interfaces.d.ts +93 -0
- package/drawer/interfaces.d.ts.map +1 -1
- package/drawer/interfaces.js.map +1 -1
- package/drawer/next.d.ts +2 -13
- package/drawer/next.d.ts.map +1 -1
- package/drawer/next.js +18 -11
- package/drawer/next.js.map +1 -1
- package/drawer/styles.css.js +25 -16
- package/drawer/styles.scoped.css +84 -21
- package/drawer/styles.selectors.js +25 -16
- package/drawer/test-classes/styles.css.js +8 -0
- package/drawer/test-classes/styles.scoped.css +9 -0
- package/drawer/test-classes/styles.selectors.js +9 -0
- package/drawer/use-sticky-footer.d.ts +2 -0
- package/drawer/use-sticky-footer.d.ts.map +1 -1
- package/drawer/use-sticky-footer.js +5 -4
- package/drawer/use-sticky-footer.js.map +1 -1
- package/dropdown/styles.css.js +20 -20
- package/dropdown/styles.scoped.css +39 -39
- package/dropdown/styles.selectors.js +20 -20
- package/expandable-section/styles.css.js +35 -35
- package/expandable-section/styles.scoped.css +67 -67
- package/expandable-section/styles.selectors.js +35 -35
- package/file-token-group/styles.css.js +23 -23
- package/file-token-group/styles.scoped.css +34 -34
- package/file-token-group/styles.selectors.js +23 -23
- package/flashbar/styles.css.js +50 -50
- package/flashbar/styles.scoped.css +149 -149
- package/flashbar/styles.selectors.js +50 -50
- package/form/styles.css.js +8 -8
- package/form/styles.scoped.css +9 -9
- package/form/styles.selectors.js +8 -8
- package/form-field/styles.css.js +24 -24
- package/form-field/styles.scoped.css +39 -39
- package/form-field/styles.selectors.js +24 -24
- package/grid/styles.css.js +53 -53
- package/grid/styles.scoped.css +55 -55
- package/grid/styles.selectors.js +53 -53
- package/header/styles.css.js +34 -34
- package/header/styles.scoped.css +54 -54
- package/header/styles.selectors.js +34 -34
- package/help-panel/styles.css.js +6 -6
- package/help-panel/styles.scoped.css +70 -70
- package/help-panel/styles.selectors.js +6 -6
- package/input/styles.css.js +18 -18
- package/input/styles.scoped.css +35 -35
- package/input/styles.selectors.js +18 -18
- package/internal/base-component/styles.scoped.css +8 -1
- package/internal/components/button-trigger/styles.css.js +14 -14
- package/internal/components/button-trigger/styles.scoped.css +29 -29
- package/internal/components/button-trigger/styles.selectors.js +14 -14
- package/internal/components/cartesian-chart/styles.css.js +28 -28
- package/internal/components/cartesian-chart/styles.scoped.css +169 -33
- package/internal/components/cartesian-chart/styles.selectors.js +28 -28
- package/internal/components/chart-filter/styles.css.js +3 -3
- package/internal/components/chart-filter/styles.scoped.css +4 -4
- package/internal/components/chart-filter/styles.selectors.js +3 -3
- package/internal/components/chart-legend/styles.css.js +6 -6
- package/internal/components/chart-legend/styles.scoped.css +15 -15
- package/internal/components/chart-legend/styles.selectors.js +6 -6
- package/internal/components/chart-popover/styles.css.js +3 -3
- package/internal/components/chart-popover/styles.scoped.css +5 -5
- package/internal/components/chart-popover/styles.selectors.js +3 -3
- package/internal/components/chart-series-details/styles.css.js +19 -19
- package/internal/components/chart-series-details/styles.scoped.css +35 -35
- package/internal/components/chart-series-details/styles.selectors.js +19 -19
- package/internal/components/chart-series-marker/styles.css.js +5 -5
- package/internal/components/chart-series-marker/styles.scoped.css +8 -8
- package/internal/components/chart-series-marker/styles.selectors.js +5 -5
- package/internal/components/chart-wrapper/styles.css.js +9 -9
- package/internal/components/chart-wrapper/styles.scoped.css +10 -10
- package/internal/components/chart-wrapper/styles.selectors.js +9 -9
- package/internal/components/dropdown-footer/styles.css.js +3 -3
- package/internal/components/dropdown-footer/styles.scoped.css +4 -4
- package/internal/components/dropdown-footer/styles.selectors.js +3 -3
- package/internal/components/dropdown-status/styles.css.js +2 -2
- package/internal/components/dropdown-status/styles.scoped.css +3 -3
- package/internal/components/dropdown-status/styles.selectors.js +2 -2
- package/internal/components/expand-toggle-button/styles.css.js +4 -4
- package/internal/components/expand-toggle-button/styles.scoped.css +14 -14
- package/internal/components/expand-toggle-button/styles.selectors.js +4 -4
- package/internal/components/menu-dropdown/styles.css.js +7 -7
- package/internal/components/menu-dropdown/styles.scoped.css +14 -14
- package/internal/components/menu-dropdown/styles.selectors.js +7 -7
- package/internal/components/option/styles.css.js +17 -17
- package/internal/components/option/styles.scoped.css +33 -33
- package/internal/components/option/styles.selectors.js +17 -17
- package/internal/components/options-list/styles.css.js +3 -3
- package/internal/components/options-list/styles.scoped.css +4 -4
- package/internal/components/options-list/styles.selectors.js +3 -3
- package/internal/components/selectable-item/styles.css.js +22 -22
- package/internal/components/selectable-item/styles.scoped.css +61 -61
- package/internal/components/selectable-item/styles.selectors.js +22 -22
- package/internal/components/sortable-area/styles.css.js +8 -8
- package/internal/components/sortable-area/styles.scoped.css +16 -16
- package/internal/components/sortable-area/styles.selectors.js +8 -8
- package/internal/components/structured-item/styles.css.js +7 -7
- package/internal/components/structured-item/styles.scoped.css +9 -9
- package/internal/components/structured-item/styles.selectors.js +7 -7
- package/internal/components/token-list/styles.css.js +10 -10
- package/internal/components/token-list/styles.scoped.css +23 -23
- package/internal/components/token-list/styles.selectors.js +10 -10
- package/internal/environment.js +2 -2
- package/internal/environment.json +2 -2
- package/internal/generated/styles/tokens.d.ts +4 -0
- package/internal/generated/styles/tokens.js +4 -0
- package/internal/generated/theming/index.cjs +48 -0
- package/internal/generated/theming/index.cjs.d.ts +36 -0
- package/internal/generated/theming/index.d.ts +36 -0
- package/internal/generated/theming/index.js +48 -0
- package/internal/manifest.json +1 -1
- package/item-card/styles.css.js +14 -14
- package/item-card/styles.scoped.css +51 -51
- package/item-card/styles.selectors.js +14 -14
- package/key-value-pairs/styles.css.js +8 -8
- package/key-value-pairs/styles.scoped.css +11 -11
- package/key-value-pairs/styles.selectors.js +8 -8
- package/link/styles.css.js +21 -21
- package/link/styles.scoped.css +104 -104
- package/link/styles.selectors.js +21 -21
- package/list/styles.css.js +5 -5
- package/list/styles.scoped.css +8 -8
- package/list/styles.selectors.js +5 -5
- package/mixed-line-bar-chart/chart-container.js +1 -1
- package/mixed-line-bar-chart/chart-container.js.map +1 -1
- package/modal/styles.css.js +31 -31
- package/modal/styles.scoped.css +48 -48
- package/modal/styles.selectors.js +31 -31
- package/multiselect/styles.css.js +3 -3
- package/multiselect/styles.scoped.css +5 -5
- package/multiselect/styles.selectors.js +3 -3
- package/package.json +1 -1
- package/pagination/styles.css.js +11 -11
- package/pagination/styles.scoped.css +26 -26
- package/pagination/styles.selectors.js +11 -11
- package/panel-layout/styles.css.js +7 -7
- package/panel-layout/styles.scoped.css +11 -11
- package/panel-layout/styles.selectors.js +7 -7
- package/pie-chart/styles.css.js +27 -27
- package/pie-chart/styles.scoped.css +49 -49
- package/pie-chart/styles.selectors.js +27 -27
- package/popover/styles.css.js +58 -58
- package/popover/styles.scoped.css +94 -94
- package/popover/styles.selectors.js +58 -58
- package/progress-bar/styles.css.js +18 -18
- package/progress-bar/styles.scoped.css +28 -28
- package/progress-bar/styles.selectors.js +18 -18
- package/prompt-input/styles.css.js +26 -26
- package/prompt-input/styles.scoped.css +57 -57
- package/prompt-input/styles.selectors.js +26 -26
- package/property-filter/filtering-token/styles.css.js +18 -18
- package/property-filter/filtering-token/styles.scoped.css +42 -42
- package/property-filter/filtering-token/styles.selectors.js +18 -18
- package/property-filter/styles.css.js +39 -39
- package/property-filter/styles.scoped.css +48 -48
- package/property-filter/styles.selectors.js +39 -39
- package/radio-button/styles.css.js +1 -1
- package/radio-button/styles.scoped.css +2 -2
- package/radio-button/styles.selectors.js +1 -1
- package/radio-group/styles.css.js +5 -5
- package/radio-group/styles.scoped.css +7 -7
- package/radio-group/styles.selectors.js +5 -5
- package/segmented-control/styles.css.js +16 -16
- package/segmented-control/styles.scoped.css +33 -33
- package/segmented-control/styles.selectors.js +16 -16
- package/select/styles.css.js +1 -1
- package/select/styles.scoped.css +2 -2
- package/select/styles.selectors.js +1 -1
- package/side-navigation/styles.css.js +30 -30
- package/side-navigation/styles.scoped.css +49 -49
- package/side-navigation/styles.selectors.js +30 -30
- package/slider/styles.css.js +26 -26
- package/slider/styles.scoped.css +77 -77
- package/slider/styles.selectors.js +26 -26
- package/split-panel/styles.css.js +38 -38
- package/split-panel/styles.scoped.css +57 -57
- package/split-panel/styles.selectors.js +38 -38
- package/status-indicator/styles.css.js +24 -24
- package/status-indicator/styles.scoped.css +31 -31
- package/status-indicator/styles.selectors.js +24 -24
- package/steps/styles.css.js +9 -9
- package/steps/styles.scoped.css +16 -16
- package/steps/styles.selectors.js +9 -9
- package/table/resizer/styles.css.js +13 -13
- package/table/resizer/styles.scoped.css +20 -20
- package/table/resizer/styles.selectors.js +13 -13
- package/table/styles.css.js +34 -34
- package/table/styles.scoped.css +42 -42
- package/table/styles.selectors.js +34 -34
- package/tabs/styles.css.js +30 -30
- package/tabs/styles.scoped.css +51 -51
- package/tabs/styles.selectors.js +30 -30
- package/test-utils/dom/drawer/index.js +2 -1
- package/test-utils/dom/drawer/index.js.map +1 -1
- package/test-utils/selectors/drawer/index.js +2 -1
- package/test-utils/selectors/drawer/index.js.map +1 -1
- package/text-content/styles.css.js +1 -1
- package/text-content/styles.scoped.css +63 -63
- package/text-content/styles.selectors.js +1 -1
- package/text-filter/styles.css.js +3 -3
- package/text-filter/styles.scoped.css +4 -4
- package/text-filter/styles.selectors.js +3 -3
- package/textarea/styles.css.js +5 -5
- package/textarea/styles.scoped.css +14 -14
- package/textarea/styles.selectors.js +5 -5
- package/tiles/styles.css.js +30 -30
- package/tiles/styles.scoped.css +74 -74
- package/tiles/styles.selectors.js +30 -30
- package/toggle/styles.css.js +10 -10
- package/toggle/styles.scoped.css +18 -18
- package/toggle/styles.selectors.js +10 -10
- package/token/styles.css.js +14 -14
- package/token/styles.scoped.css +29 -29
- package/token/styles.selectors.js +14 -14
- package/token-group/styles.css.js +5 -5
- package/token-group/styles.scoped.css +5 -5
- package/token-group/styles.selectors.js +5 -5
- package/top-navigation/styles.css.js +47 -47
- package/top-navigation/styles.scoped.css +71 -71
- package/top-navigation/styles.selectors.js +47 -47
- package/tree-view/styles.css.js +2 -2
- package/tree-view/styles.scoped.css +3 -3
- package/tree-view/styles.selectors.js +2 -2
- package/tutorial-panel/components/tutorial-detail-view/styles.css.js +20 -20
- package/tutorial-panel/components/tutorial-detail-view/styles.scoped.css +23 -23
- package/tutorial-panel/components/tutorial-detail-view/styles.selectors.js +20 -20
- package/tutorial-panel/components/tutorial-list/styles.css.js +18 -18
- package/tutorial-panel/components/tutorial-list/styles.scoped.css +30 -30
- package/tutorial-panel/components/tutorial-list/styles.selectors.js +18 -18
- package/tutorial-panel/styles.css.js +1 -1
- package/tutorial-panel/styles.scoped.css +6 -6
- package/tutorial-panel/styles.selectors.js +1 -1
- package/wizard/styles.css.js +30 -30
- package/wizard/styles.scoped.css +63 -63
- package/wizard/styles.selectors.js +30 -30
|
@@ -2,28 +2,28 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"calendar": "
|
|
6
|
-
"awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-
|
|
7
|
-
"root": "
|
|
8
|
-
"wide": "
|
|
9
|
-
"focus-lock": "awsui_focus-
|
|
10
|
-
"trigger-flexbox": "awsui_trigger-
|
|
11
|
-
"calendar-container": "awsui_calendar-
|
|
12
|
-
"one-grid": "awsui_one-
|
|
13
|
-
"calendar-header": "awsui_calendar-
|
|
14
|
-
"calendar-header-pages-wrapper": "awsui_calendar-header-pages-
|
|
15
|
-
"calendar-header-page": "awsui_calendar-header-
|
|
16
|
-
"date-and-time-container": "awsui_date-and-time-
|
|
17
|
-
"date-and-time-wrapper": "awsui_date-and-time-
|
|
18
|
-
"footer": "
|
|
19
|
-
"has-clear-button": "awsui_has-clear-
|
|
20
|
-
"footer-button-wrapper": "awsui_footer-button-
|
|
21
|
-
"icon-wrapper": "awsui_icon-
|
|
22
|
-
"label": "
|
|
23
|
-
"label-enabled": "awsui_label-
|
|
24
|
-
"label-text": "awsui_label-
|
|
25
|
-
"label-token-nowrap": "awsui_label-token-
|
|
26
|
-
"dropdown": "
|
|
27
|
-
"dropdown-content": "awsui_dropdown-
|
|
5
|
+
"calendar": "awsui_calendar_mgja0_195n8_153",
|
|
6
|
+
"awsui-motion-fade-in-0": "awsui_awsui-motion-fade-in-0_mgja0_195n8_1",
|
|
7
|
+
"root": "awsui_root_mgja0_195n8_176",
|
|
8
|
+
"wide": "awsui_wide_mgja0_195n8_207",
|
|
9
|
+
"focus-lock": "awsui_focus-lock_mgja0_195n8_214",
|
|
10
|
+
"trigger-flexbox": "awsui_trigger-flexbox_mgja0_195n8_218",
|
|
11
|
+
"calendar-container": "awsui_calendar-container_mgja0_195n8_222",
|
|
12
|
+
"one-grid": "awsui_one-grid_mgja0_195n8_225",
|
|
13
|
+
"calendar-header": "awsui_calendar-header_mgja0_195n8_229",
|
|
14
|
+
"calendar-header-pages-wrapper": "awsui_calendar-header-pages-wrapper_mgja0_195n8_235",
|
|
15
|
+
"calendar-header-page": "awsui_calendar-header-page_mgja0_195n8_235",
|
|
16
|
+
"date-and-time-container": "awsui_date-and-time-container_mgja0_195n8_255",
|
|
17
|
+
"date-and-time-wrapper": "awsui_date-and-time-wrapper_mgja0_195n8_261",
|
|
18
|
+
"footer": "awsui_footer_mgja0_195n8_268",
|
|
19
|
+
"has-clear-button": "awsui_has-clear-button_mgja0_195n8_277",
|
|
20
|
+
"footer-button-wrapper": "awsui_footer-button-wrapper_mgja0_195n8_286",
|
|
21
|
+
"icon-wrapper": "awsui_icon-wrapper_mgja0_195n8_293",
|
|
22
|
+
"label": "awsui_label_mgja0_195n8_298",
|
|
23
|
+
"label-enabled": "awsui_label-enabled_mgja0_195n8_302",
|
|
24
|
+
"label-text": "awsui_label-text_mgja0_195n8_306",
|
|
25
|
+
"label-token-nowrap": "awsui_label-token-nowrap_mgja0_195n8_311",
|
|
26
|
+
"dropdown": "awsui_dropdown_mgja0_195n8_315",
|
|
27
|
+
"dropdown-content": "awsui_dropdown-content_mgja0_195n8_337"
|
|
28
28
|
};
|
|
29
29
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { InternalBaseComponentProps } from '../internal/hooks/use-base-component';
|
|
2
3
|
import { NextDrawerProps } from './interfaces';
|
|
3
|
-
type DrawerInternalProps = NextDrawerProps & InternalBaseComponentProps
|
|
4
|
+
type DrawerInternalProps = NextDrawerProps & InternalBaseComponentProps & {
|
|
5
|
+
__ref?: React.Ref<NextDrawerProps.Ref>;
|
|
6
|
+
};
|
|
4
7
|
export declare function DrawerImplementation({
|
|
5
8
|
header,
|
|
6
9
|
footer,
|
|
@@ -9,12 +12,22 @@ export declare function DrawerImplementation({
|
|
|
9
12
|
i18nStrings,
|
|
10
13
|
disableContentPaddings,
|
|
11
14
|
__internalRootRef,
|
|
15
|
+
__ref,
|
|
12
16
|
headerActions,
|
|
13
17
|
position,
|
|
14
18
|
placement,
|
|
15
19
|
offset,
|
|
16
20
|
stickyOffset,
|
|
17
21
|
zIndex,
|
|
22
|
+
closeAction,
|
|
23
|
+
hideCloseAction,
|
|
24
|
+
backdrop,
|
|
25
|
+
open,
|
|
26
|
+
onClose,
|
|
27
|
+
ariaLabel,
|
|
28
|
+
ariaLabelledby,
|
|
29
|
+
focusBehavior,
|
|
30
|
+
role,
|
|
18
31
|
...restProps
|
|
19
32
|
}: DrawerInternalProps): JSX.Element;
|
|
20
33
|
export declare const createWidgetizedDrawer: (Loader?: typeof DrawerImplementation | undefined) => typeof DrawerImplementation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.d.ts","sourceRoot":"","sources":["../../../src/drawer/implementation.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"implementation.d.ts","sourceRoot":"","sources":["../../../src/drawer/implementation.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAcjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAKlF,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAO/C,KAAK,mBAAmB,GAAG,eAAe,GACxC,0BAA0B,GAAG;IAC3B,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;CACxC,CAAC;AAEJ,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,MAAM,EACN,QAAQ,EACR,OAAO,EACP,WAAW,EACX,sBAAsB,EACtB,iBAAiB,EACjB,KAAK,EACL,aAAa,EACb,QAAmB,EACnB,SAAiB,EACjB,MAAM,EACN,YAAY,EACZ,MAAM,EACN,WAAW,EACX,eAAuB,EACvB,QAAgB,EAChB,IAAI,EACJ,OAAO,EACP,SAAS,EACT,cAAc,EACd,aAAa,EACb,IAAI,EACJ,GAAG,SAAS,EACb,EAAE,mBAAmB,eAwKrB;AAED,eAAO,MAAM,sBAAsB,mFAAkD,CAAC"}
|
package/drawer/implementation.js
CHANGED
|
@@ -1,46 +1,119 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import React, { useRef } from 'react';
|
|
3
|
+
import React, { useEffect, useImperativeHandle, useRef } from 'react';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
+
import { useStableCallback, useUniqueId } from '@cloudscape-design/component-toolkit/internal';
|
|
5
6
|
import { useRuntimeDrawerContext } from '../app-layout/runtime-drawer/use-runtime-drawer-context';
|
|
6
7
|
import { useAppLayoutToolbarDesignEnabled } from '../app-layout/utils/feature-flags';
|
|
8
|
+
import InternalButton from '../button/internal';
|
|
7
9
|
import { BuiltInErrorBoundary } from '../error-boundary/internal';
|
|
8
10
|
import { useInternalI18n } from '../i18n/context';
|
|
9
11
|
import { getBaseProps } from '../internal/base-component';
|
|
12
|
+
import FocusLock from '../internal/components/focus-lock';
|
|
13
|
+
import { getAllFocusables, isFocusable } from '../internal/components/focus-lock/utils';
|
|
14
|
+
import { fireNonCancelableEvent } from '../internal/events';
|
|
15
|
+
import { useEffectOnUpdate } from '../internal/hooks/use-effect-on-update';
|
|
10
16
|
import { createWidgetizedComponent } from '../internal/widgets';
|
|
11
17
|
import InternalLiveRegion from '../live-region/internal';
|
|
12
18
|
import InternalStatusIndicator from '../status-indicator/internal';
|
|
13
19
|
import { useStickyFooter } from './use-sticky-footer';
|
|
14
20
|
import { getPositionStyles } from './utils';
|
|
15
21
|
import styles from './styles.css.js';
|
|
16
|
-
|
|
22
|
+
import testClasses from './test-classes/styles.css.js';
|
|
23
|
+
export function DrawerImplementation({ header, footer, children, loading, i18nStrings, disableContentPaddings, __internalRootRef, __ref, headerActions, position = 'static', placement = 'end', offset, stickyOffset, zIndex, closeAction, hideCloseAction = false, backdrop = false, open, onClose, ariaLabel, ariaLabelledby, focusBehavior, role, ...restProps }) {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const containerRef = useRef(null);
|
|
26
|
+
const footerRef = useRef(null);
|
|
27
|
+
const returnFocusTargetRef = useRef(null);
|
|
17
28
|
const baseProps = getBaseProps(restProps);
|
|
18
29
|
const isToolbar = useAppLayoutToolbarDesignEnabled();
|
|
19
30
|
const i18n = useInternalI18n('drawer');
|
|
20
31
|
const positionStyles = getPositionStyles({ position, placement, offset, stickyOffset, zIndex });
|
|
32
|
+
const headerId = useUniqueId('drawer-header');
|
|
33
|
+
const defaultRegionLabelledBy = header ? headerId : undefined;
|
|
34
|
+
ariaLabelledby = ariaLabelledby !== null && ariaLabelledby !== void 0 ? ariaLabelledby : (ariaLabel ? undefined : defaultRegionLabelledBy);
|
|
35
|
+
role = role !== null && role !== void 0 ? role : (position === 'static' ? 'presentation' : 'region');
|
|
36
|
+
const roleProps = role === 'region'
|
|
37
|
+
? { role: 'region', tabIndex: -1, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby }
|
|
38
|
+
: {};
|
|
21
39
|
const containerProps = {
|
|
22
|
-
|
|
40
|
+
ref: containerRef,
|
|
41
|
+
...roleProps,
|
|
23
42
|
style: positionStyles.style,
|
|
24
|
-
className: clsx(
|
|
43
|
+
className: clsx(styles.drawer, loading && styles['content-with-paddings'], isToolbar && styles['with-toolbar'], !!footer && styles['with-footer'], closeAction && !hideCloseAction && styles['has-close-action'], positionStyles.className),
|
|
25
44
|
};
|
|
26
|
-
const
|
|
45
|
+
const focusIn = useStableCallback(() => {
|
|
46
|
+
var _a;
|
|
47
|
+
returnFocusTargetRef.current = document.activeElement;
|
|
48
|
+
if (containerRef.current && isFocusable(containerRef.current)) {
|
|
49
|
+
containerRef.current.focus();
|
|
50
|
+
}
|
|
51
|
+
else if (containerRef.current) {
|
|
52
|
+
(_a = getAllFocusables(containerRef.current)[0]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const focusOut = useStableCallback(() => {
|
|
56
|
+
if (focusBehavior === null || focusBehavior === void 0 ? void 0 : focusBehavior.returnFocus) {
|
|
57
|
+
focusBehavior.returnFocus();
|
|
58
|
+
}
|
|
59
|
+
else if (returnFocusTargetRef.current && returnFocusTargetRef.current.isConnected) {
|
|
60
|
+
returnFocusTargetRef.current.focus();
|
|
61
|
+
}
|
|
62
|
+
returnFocusTargetRef.current = null;
|
|
63
|
+
});
|
|
64
|
+
const autoFocusRef = useRef(false);
|
|
65
|
+
autoFocusRef.current = (_a = focusBehavior === null || focusBehavior === void 0 ? void 0 : focusBehavior.autoFocus) !== null && _a !== void 0 ? _a : true;
|
|
66
|
+
// The use-effect-on-update ensures no focus transition on component's initial render.
|
|
67
|
+
// If focus transition is needed - the drawerRef.current.focus() should be used instead.
|
|
68
|
+
useEffectOnUpdate(() => {
|
|
69
|
+
if (open === undefined) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (open && autoFocusRef.current) {
|
|
73
|
+
focusIn();
|
|
74
|
+
}
|
|
75
|
+
if (!open) {
|
|
76
|
+
focusOut();
|
|
77
|
+
}
|
|
78
|
+
}, [open, focusIn, focusOut]);
|
|
79
|
+
const handleClose = useStableCallback((method) => fireNonCancelableEvent(onClose, { method }));
|
|
80
|
+
useImperativeHandle(__ref, () => ({ focus: () => { var _a; return (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.focus(); } }), []);
|
|
27
81
|
const runtimeDrawerContext = useRuntimeDrawerContext({ rootRef: __internalRootRef });
|
|
28
82
|
const hasAdditionalDrawerAction = !!(runtimeDrawerContext === null || runtimeDrawerContext === void 0 ? void 0 : runtimeDrawerContext.isExpandable);
|
|
29
83
|
const { isSticky: isFooterSticky } = useStickyFooter({
|
|
30
|
-
|
|
84
|
+
rootRef: __internalRootRef,
|
|
85
|
+
drawerRef: containerRef,
|
|
31
86
|
footerRef,
|
|
32
87
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
88
|
+
const showBackdrop = backdrop && (position === 'fixed' || position === 'absolute');
|
|
89
|
+
const trapFocus = (_b = focusBehavior === null || focusBehavior === void 0 ? void 0 : focusBehavior.trapFocus) !== null && _b !== void 0 ? _b : showBackdrop;
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (!showBackdrop) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const onKeyDown = (event) => {
|
|
95
|
+
if (event.key === 'Escape') {
|
|
96
|
+
handleClose('escape');
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
document.addEventListener('keydown', onKeyDown);
|
|
100
|
+
return () => document.removeEventListener('keydown', onKeyDown);
|
|
101
|
+
}, [showBackdrop, handleClose]);
|
|
102
|
+
return (React.createElement("div", { ...baseProps, className: clsx(baseProps.className, styles.root, testClasses.root, open === false && styles.hidden), ref: __internalRootRef },
|
|
103
|
+
showBackdrop && (React.createElement("div", { className: clsx(styles.backdrop, testClasses.backdrop, styles[`backdrop-${position}`]), style: { zIndex }, onClick: () => handleClose('backdrop-click') })),
|
|
104
|
+
React.createElement(FocusLock, { disabled: !trapFocus, className: styles['focus-trap'] },
|
|
105
|
+
React.createElement("div", { ...containerProps }, loading ? (React.createElement(InternalStatusIndicator, { type: "loading" },
|
|
106
|
+
React.createElement(InternalLiveRegion, { tagName: "span" }, i18n('i18nStrings.loadingText', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.loadingText)))) : (React.createElement(React.Fragment, null,
|
|
107
|
+
header && (React.createElement("div", { className: clsx(styles.header, runtimeDrawerContext && styles['with-runtime-context'], hasAdditionalDrawerAction && styles['with-additional-action'], hideCloseAction && styles['hide-close-action']) },
|
|
108
|
+
React.createElement("span", { id: headerId }, header),
|
|
109
|
+
headerActions && React.createElement("div", { className: styles['header-actions'] }, headerActions))),
|
|
110
|
+
closeAction && !hideCloseAction && (React.createElement("div", { className: styles['close-action'] },
|
|
111
|
+
React.createElement(InternalButton, { variant: "icon", iconName: "close", ...closeAction, className: testClasses['close-action'], onClick: () => handleClose('close-action') }))),
|
|
112
|
+
React.createElement("div", { className: clsx(styles['test-utils-drawer-content'], styles.content, !disableContentPaddings && styles['content-with-paddings']) },
|
|
113
|
+
React.createElement(BuiltInErrorBoundary, null, children)),
|
|
114
|
+
footer && (React.createElement("div", { ref: footerRef, className: clsx(styles.footer, {
|
|
115
|
+
[styles['is-sticky']]: isFooterSticky,
|
|
116
|
+
}) }, footer))))))));
|
|
44
117
|
}
|
|
45
118
|
export const createWidgetizedDrawer = createWidgetizedComponent(DrawerImplementation);
|
|
46
119
|
//# sourceMappingURL=implementation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../../src/drawer/implementation.tsx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AI,6BAAK,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,IAAG,aAAa,CAAO,CAC7E,CACP;QACD,6BACE,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,2BAA2B,CAAC,EACnC,MAAM,CAAC,OAAO,EACd,CAAC,sBAAsB,IAAI,MAAM,CAAC,uBAAuB,CAAC,CAC3D;YAED,oBAAC,oBAAoB,QAAE,QAAQ,CAAwB,CACnD;QACL,MAAM,IAAI,CACT,6BACE,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;gBAC7B,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,cAAc;aACtC,CAAC,IAED,MAAM,CACH,CACP,CACG,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC,oBAAoB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { RefObject, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useRuntimeDrawerContext } from '../app-layout/runtime-drawer/use-runtime-drawer-context';\nimport { useAppLayoutToolbarDesignEnabled } from '../app-layout/utils/feature-flags';\nimport { BuiltInErrorBoundary } from '../error-boundary/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { getBaseProps } from '../internal/base-component';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { createWidgetizedComponent } from '../internal/widgets';\nimport InternalLiveRegion from '../live-region/internal';\nimport InternalStatusIndicator from '../status-indicator/internal';\nimport { NextDrawerProps } from './interfaces';\nimport { useStickyFooter } from './use-sticky-footer';\nimport { getPositionStyles } from './utils';\n\nimport styles from './styles.css.js';\n\ntype DrawerInternalProps = NextDrawerProps & InternalBaseComponentProps;\n\nexport function DrawerImplementation({\n header,\n footer,\n children,\n loading,\n i18nStrings,\n disableContentPaddings,\n __internalRootRef,\n headerActions,\n position = 'static',\n placement = 'end',\n offset,\n stickyOffset,\n zIndex,\n ...restProps\n}: DrawerInternalProps) {\n const baseProps = getBaseProps(restProps);\n const isToolbar = useAppLayoutToolbarDesignEnabled();\n const i18n = useInternalI18n('drawer');\n const positionStyles = getPositionStyles({ position, placement, offset, stickyOffset, zIndex });\n const containerProps = {\n ...baseProps,\n style: positionStyles.style,\n className: clsx(\n baseProps.className,\n styles.drawer,\n isToolbar && styles['with-toolbar'],\n !!footer && styles['with-footer'],\n positionStyles.className\n ),\n };\n const footerRef = useRef<HTMLDivElement>(null);\n\n const runtimeDrawerContext = useRuntimeDrawerContext({ rootRef: __internalRootRef as RefObject<HTMLElement> });\n const hasAdditionalDrawerAction = !!runtimeDrawerContext?.isExpandable;\n const { isSticky: isFooterSticky } = useStickyFooter({\n drawerRef: __internalRootRef as RefObject<HTMLElement>,\n footerRef,\n });\n\n return loading ? (\n <div\n {...containerProps}\n className={clsx(containerProps.className, styles['content-with-paddings'])}\n ref={__internalRootRef}\n >\n <InternalStatusIndicator type=\"loading\">\n <InternalLiveRegion tagName=\"span\">\n {i18n('i18nStrings.loadingText', i18nStrings?.loadingText)}\n </InternalLiveRegion>\n </InternalStatusIndicator>\n </div>\n ) : (\n <div {...containerProps} ref={__internalRootRef}>\n {header && (\n <div\n className={clsx(\n styles.header,\n runtimeDrawerContext && styles['with-runtime-context'],\n hasAdditionalDrawerAction && styles['with-additional-action']\n )}\n >\n {header}\n {headerActions && <div className={styles['header-actions']}>{headerActions}</div>}\n </div>\n )}\n <div\n className={clsx(\n styles['test-utils-drawer-content'],\n styles.content,\n !disableContentPaddings && styles['content-with-paddings']\n )}\n >\n <BuiltInErrorBoundary>{children}</BuiltInErrorBoundary>\n </div>\n {footer && (\n <div\n ref={footerRef}\n className={clsx(styles.footer, {\n [styles['is-sticky']]: isFooterSticky,\n })}\n >\n {footer}\n </div>\n )}\n </div>\n );\n}\n\nexport const createWidgetizedDrawer = createWidgetizedComponent(DrawerImplementation);\n"]}
|
|
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WAAW,CAAC,CAAC,EAAE,cAAc;qBACtC,CAAC,IAED,MAAM,CACH,CACP,CACA,CACJ,CACG,CACI,CACR,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC,oBAAoB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { RefObject, useEffect, useImperativeHandle, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useStableCallback, useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useRuntimeDrawerContext } from '../app-layout/runtime-drawer/use-runtime-drawer-context';\nimport { useAppLayoutToolbarDesignEnabled } from '../app-layout/utils/feature-flags';\nimport InternalButton from '../button/internal';\nimport { BuiltInErrorBoundary } from '../error-boundary/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { getBaseProps } from '../internal/base-component';\nimport FocusLock from '../internal/components/focus-lock';\nimport { getAllFocusables, isFocusable } from '../internal/components/focus-lock/utils';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useEffectOnUpdate } from '../internal/hooks/use-effect-on-update';\nimport { createWidgetizedComponent } from '../internal/widgets';\nimport InternalLiveRegion from '../live-region/internal';\nimport InternalStatusIndicator from '../status-indicator/internal';\nimport { NextDrawerProps } from './interfaces';\nimport { useStickyFooter } from './use-sticky-footer';\nimport { getPositionStyles } from './utils';\n\nimport styles from './styles.css.js';\nimport testClasses from './test-classes/styles.css.js';\n\ntype DrawerInternalProps = NextDrawerProps &\n InternalBaseComponentProps & {\n __ref?: React.Ref<NextDrawerProps.Ref>;\n };\n\nexport function DrawerImplementation({\n header,\n footer,\n children,\n loading,\n i18nStrings,\n disableContentPaddings,\n __internalRootRef,\n __ref,\n headerActions,\n position = 'static',\n placement = 'end',\n offset,\n stickyOffset,\n zIndex,\n closeAction,\n hideCloseAction = false,\n backdrop = false,\n open,\n onClose,\n ariaLabel,\n ariaLabelledby,\n focusBehavior,\n role,\n ...restProps\n}: DrawerInternalProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const footerRef = useRef<HTMLDivElement>(null);\n const returnFocusTargetRef = useRef<HTMLElement | null>(null);\n\n const baseProps = getBaseProps(restProps);\n const isToolbar = useAppLayoutToolbarDesignEnabled();\n const i18n = useInternalI18n('drawer');\n const positionStyles = getPositionStyles({ position, placement, offset, stickyOffset, zIndex });\n const headerId = useUniqueId('drawer-header');\n const defaultRegionLabelledBy = header ? headerId : undefined;\n ariaLabelledby = ariaLabelledby ?? (ariaLabel ? undefined : defaultRegionLabelledBy);\n role = role ?? (position === 'static' ? 'presentation' : 'region');\n const roleProps =\n role === 'region'\n ? { role: 'region', tabIndex: -1, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby }\n : {};\n const containerProps = {\n ref: containerRef,\n ...roleProps,\n style: positionStyles.style,\n className: clsx(\n styles.drawer,\n loading && styles['content-with-paddings'],\n isToolbar && styles['with-toolbar'],\n !!footer && styles['with-footer'],\n closeAction && !hideCloseAction && styles['has-close-action'],\n positionStyles.className\n ),\n };\n\n const focusIn = useStableCallback(() => {\n returnFocusTargetRef.current = document.activeElement as HTMLElement;\n if (containerRef.current && isFocusable(containerRef.current)) {\n containerRef.current.focus();\n } else if (containerRef.current) {\n getAllFocusables(containerRef.current)[0]?.focus();\n }\n });\n\n const focusOut = useStableCallback(() => {\n if (focusBehavior?.returnFocus) {\n focusBehavior.returnFocus();\n } else if (returnFocusTargetRef.current && returnFocusTargetRef.current.isConnected) {\n returnFocusTargetRef.current.focus();\n }\n returnFocusTargetRef.current = null;\n });\n\n const autoFocusRef = useRef(false);\n autoFocusRef.current = focusBehavior?.autoFocus ?? true;\n\n // The use-effect-on-update ensures no focus transition on component's initial render.\n // If focus transition is needed - the drawerRef.current.focus() should be used instead.\n useEffectOnUpdate(() => {\n if (open === undefined) {\n return;\n }\n if (open && autoFocusRef.current) {\n focusIn();\n }\n if (!open) {\n focusOut();\n }\n }, [open, focusIn, focusOut]);\n\n const handleClose = useStableCallback((method: 'close-action' | 'backdrop-click' | 'escape') =>\n fireNonCancelableEvent(onClose, { method })\n );\n\n useImperativeHandle(__ref, () => ({ focus: () => containerRef.current?.focus() }), []);\n\n const runtimeDrawerContext = useRuntimeDrawerContext({ rootRef: __internalRootRef as RefObject<HTMLElement> });\n const hasAdditionalDrawerAction = !!runtimeDrawerContext?.isExpandable;\n const { isSticky: isFooterSticky } = useStickyFooter({\n rootRef: __internalRootRef as RefObject<HTMLElement>,\n drawerRef: containerRef,\n footerRef,\n });\n\n const showBackdrop = backdrop && (position === 'fixed' || position === 'absolute');\n const trapFocus = focusBehavior?.trapFocus ?? showBackdrop;\n\n useEffect(() => {\n if (!showBackdrop) {\n return;\n }\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n handleClose('escape');\n }\n };\n document.addEventListener('keydown', onKeyDown);\n return () => document.removeEventListener('keydown', onKeyDown);\n }, [showBackdrop, handleClose]);\n\n return (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.root, testClasses.root, open === false && styles.hidden)}\n ref={__internalRootRef}\n >\n {showBackdrop && (\n <div\n className={clsx(styles.backdrop, testClasses.backdrop, styles[`backdrop-${position}`])}\n style={{ zIndex }}\n onClick={() => handleClose('backdrop-click')}\n />\n )}\n <FocusLock disabled={!trapFocus} className={styles['focus-trap']}>\n <div {...containerProps}>\n {loading ? (\n <InternalStatusIndicator type=\"loading\">\n <InternalLiveRegion tagName=\"span\">\n {i18n('i18nStrings.loadingText', i18nStrings?.loadingText)}\n </InternalLiveRegion>\n </InternalStatusIndicator>\n ) : (\n <>\n {header && (\n <div\n className={clsx(\n styles.header,\n runtimeDrawerContext && styles['with-runtime-context'],\n hasAdditionalDrawerAction && styles['with-additional-action'],\n hideCloseAction && styles['hide-close-action']\n )}\n >\n <span id={headerId}>{header}</span>\n {headerActions && <div className={styles['header-actions']}>{headerActions}</div>}\n </div>\n )}\n {closeAction && !hideCloseAction && (\n <div className={styles['close-action']}>\n <InternalButton\n variant=\"icon\"\n iconName=\"close\"\n {...closeAction}\n className={testClasses['close-action']}\n onClick={() => handleClose('close-action')}\n />\n </div>\n )}\n <div\n className={clsx(\n styles['test-utils-drawer-content'],\n styles.content,\n !disableContentPaddings && styles['content-with-paddings']\n )}\n >\n <BuiltInErrorBoundary>{children}</BuiltInErrorBoundary>\n </div>\n {footer && (\n <div\n ref={footerRef}\n className={clsx(styles.footer, {\n [styles['is-sticky']]: isFooterSticky,\n })}\n >\n {footer}\n </div>\n )}\n </>\n )}\n </div>\n </FocusLock>\n </div>\n );\n}\n\nexport const createWidgetizedDrawer = createWidgetizedComponent(DrawerImplementation);\n"]}
|
package/drawer/interfaces.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ButtonProps } from '../button/interfaces';
|
|
2
3
|
import { BaseComponentProps } from '../internal/base-component';
|
|
4
|
+
import { NonCancelableEventHandler } from '../internal/events';
|
|
3
5
|
export interface DrawerProps extends BaseComponentProps {
|
|
4
6
|
/**
|
|
5
7
|
* Header of the drawer.
|
|
@@ -43,6 +45,30 @@ export declare namespace DrawerProps {
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
export interface NextDrawerProps extends DrawerProps {
|
|
48
|
+
/**
|
|
49
|
+
* Sets the ARIA role of the drawer.
|
|
50
|
+
* - `"region"` (default for non-`static` positions) — exposes the drawer as a
|
|
51
|
+
* landmark region. The drawer receives focus when opened.
|
|
52
|
+
* - `"presentation"` (default for `position="static"`) — removes landmark semantics
|
|
53
|
+
* from the drawer body. Use this when the containing element already provides the
|
|
54
|
+
* appropriate semantic role (e.g. a wrapping `<nav>` or `<aside>`). The drawer does not
|
|
55
|
+
* receive focus when opened.
|
|
56
|
+
*/
|
|
57
|
+
role?: 'region' | 'presentation';
|
|
58
|
+
/**
|
|
59
|
+
* Sets the `aria-label` on the drawer body.
|
|
60
|
+
* By default the body is labelled by the drawer's `header` content. Use this when you need a different
|
|
61
|
+
* or more specific label (e.g. to include additional context or exclude parts of the header).
|
|
62
|
+
* Does not apply when `role="presentation"`. Don't use `ariaLabel` and `ariaLabelledby` at the same time.
|
|
63
|
+
*/
|
|
64
|
+
ariaLabel?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Sets the `aria-labelledby` on the drawer body.
|
|
67
|
+
* By default the body is labelled by the drawer's `header` content. Use this when you need a different
|
|
68
|
+
* or more specific label (e.g. to include additional context or exclude parts of the header).
|
|
69
|
+
* Does not apply when `role="presentation"`. Don't use `ariaLabel` and `ariaLabelledby` at the same time.
|
|
70
|
+
*/
|
|
71
|
+
ariaLabelledby?: string;
|
|
46
72
|
/**
|
|
47
73
|
* Specifies the CSS positioning mode of the drawer, and supports the following options:
|
|
48
74
|
* * `static` (default) - The drawer is positioned in the normal document flow.
|
|
@@ -85,6 +111,57 @@ export interface NextDrawerProps extends DrawerProps {
|
|
|
85
111
|
* Applicable when using `position="sticky"`, `position="absolute"`, or `position="fixed"`.
|
|
86
112
|
*/
|
|
87
113
|
zIndex?: number;
|
|
114
|
+
/**
|
|
115
|
+
* When defined, renders a close button in the header with the provided configuration.
|
|
116
|
+
* The close button fires the `onClose` event with method `'close-action'` when
|
|
117
|
+
* clicked.
|
|
118
|
+
*/
|
|
119
|
+
closeAction?: Pick<ButtonProps, 'ariaLabel' | 'disabled' | 'disabledReason' | 'iconName' | 'iconSvg' | 'iconUrl' | 'iconAlt'>;
|
|
120
|
+
/**
|
|
121
|
+
* Hides the close action slot next to the header actions, which is present even
|
|
122
|
+
* when close action is not set. Use it when a close action is not needed, or a
|
|
123
|
+
* custom close action implementation is used.
|
|
124
|
+
*/
|
|
125
|
+
hideCloseAction?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Called when the user performs a close action. The `event.detail.method` indicates the trigger:
|
|
128
|
+
* * `'close-action'` - The close button was clicked.
|
|
129
|
+
* * `'backdrop-click'` - The backdrop was clicked (only when `backdrop=true`).
|
|
130
|
+
* * `'escape'` - The Escape key was pressed (only when `backdrop=true`).
|
|
131
|
+
*/
|
|
132
|
+
onClose?: NonCancelableEventHandler<NextDrawerProps.CloseDetail>;
|
|
133
|
+
/**
|
|
134
|
+
* Drawer open state. Set to `true` to show the drawer, `false` to hide it.
|
|
135
|
+
* Handle the `onClose` event to update this value when the user requests to close the drawer.
|
|
136
|
+
*
|
|
137
|
+
* When the property is unset - the drawer is always visible, and the built-in focus in/out behaviors are disabled.
|
|
138
|
+
*/
|
|
139
|
+
open?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Shows a semi-transparent backdrop behind the drawer when open. Used with `absolute`
|
|
142
|
+
* and `fixed` positions.
|
|
143
|
+
*
|
|
144
|
+
* When a backdrop is set, the keyboard focus is trapped inside the drawer by default
|
|
145
|
+
* to prevent it from moving to elements covered by the backdrop. This can be overridden
|
|
146
|
+
* with `focusBehavior.trapFocus`.
|
|
147
|
+
*/
|
|
148
|
+
backdrop?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Customizes focus-related behavior:
|
|
151
|
+
*
|
|
152
|
+
* - `autoFocus` - Whether focus moves into the drawer when `open` changes from `false` to `true`,
|
|
153
|
+
* and captures the previously focused element for default return-focus on close.
|
|
154
|
+
* Defaults to `true`. Set to `false` to manage focus-in manually via `ref.current.focus()`.
|
|
155
|
+
*
|
|
156
|
+
* - `trapFocus` - Whether keyboard focus is constrained to elements inside the drawer.
|
|
157
|
+
* Defaults to `true` when `backdrop` is set, `false` otherwise.
|
|
158
|
+
*
|
|
159
|
+
* - `returnFocus` - Called instead of the default return-focus behavior when the drawer closes.
|
|
160
|
+
* Use this to override where focus lands on close (e.g. a specific trigger element).
|
|
161
|
+
* If omitted, focus returns to the element that was focused when the drawer opened.
|
|
162
|
+
* If that element is no longer in the DOM, the behavior silently no-ops.
|
|
163
|
+
*/
|
|
164
|
+
focusBehavior?: NextDrawerProps.FocusBehavior;
|
|
88
165
|
}
|
|
89
166
|
export declare namespace NextDrawerProps {
|
|
90
167
|
type Position = 'static' | 'sticky' | 'absolute' | 'fixed';
|
|
@@ -99,4 +176,20 @@ export declare namespace NextDrawerProps {
|
|
|
99
176
|
top?: number;
|
|
100
177
|
bottom?: number;
|
|
101
178
|
}
|
|
179
|
+
interface CloseDetail {
|
|
180
|
+
method: 'close-action' | 'backdrop-click' | 'escape';
|
|
181
|
+
}
|
|
182
|
+
interface FocusBehavior {
|
|
183
|
+
autoFocus?: boolean;
|
|
184
|
+
trapFocus?: boolean;
|
|
185
|
+
returnFocus?: () => void;
|
|
186
|
+
}
|
|
187
|
+
interface Ref {
|
|
188
|
+
/**
|
|
189
|
+
* Moves focus to the drawer element. Use in controlled mode when `focusBehavior.autoFocus`
|
|
190
|
+
* is disabled and you need to manage focus manually, or to focus a drawer, initially rendered
|
|
191
|
+
* with `open=true`. The drawer with `role="presentation"` cannot be focused.
|
|
192
|
+
*/
|
|
193
|
+
focus(): void;
|
|
194
|
+
}
|
|
102
195
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/drawer/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/drawer/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,WAAW,WAAY,SAAQ,kBAAkB;IACrD;;;;OAIG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;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AAE,yBAAyB,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;IAEjE;;;;;OAKG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;;;;;;;;;;OAcG;IACH,aAAa,CAAC,EAAE,eAAe,CAAC,aAAa,CAAC;CAC/C;AAED,yBAAiB,eAAe,CAAC;IAC/B,KAAY,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;IAElE,KAAY,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,CAAC;IAE3D,UAAiB,MAAM;QACrB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAED,UAAiB,YAAY;QAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAED,UAAiB,WAAW;QAC1B,MAAM,EAAE,cAAc,GAAG,gBAAgB,GAAG,QAAQ,CAAC;KACtD;IAED,UAAiB,aAAa;QAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;KAC1B;IAED,UAAiB,GAAG;QAClB;;;;WAIG;QACH,KAAK,IAAI,IAAI,CAAC;KACf;CACF"}
|
package/drawer/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/drawer/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\n\nimport { BaseComponentProps } from '../internal/base-component';\n\nexport interface DrawerProps extends BaseComponentProps {\n /**\n * Header of the drawer.\n *\n * It should contain the only `h2` used in the drawer.\n */\n header?: React.ReactNode;\n\n /**\n * Main content of the drawer.\n */\n children?: React.ReactNode;\n\n /**\n * Renders the drawer in a loading state. We recommend that you also set a `i18nStrings.loadingText`.\n */\n loading?: boolean;\n\n /**\n * Determines whether the drawer content has padding. If `true`, removes the default padding from the content area.\n */\n disableContentPaddings?: boolean;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n * - `loadingText` - The text that's displayed when the drawer is in a loading state.\n * @i18n\n */\n i18nStrings?: DrawerProps.I18nStrings;\n\n /**\n * Actions for the header. Available only if you specify the `header` property.\n */\n headerActions?: React.ReactNode;\n\n /**\n * Sticky footer content that remains visible at the bottom during scroll.\n *\n * Automatically becomes non-sticky when scrollable content area is too small\n * to ensure content remains accessible (not covered by the footer).\n */\n footer?: React.ReactNode;\n}\n\nexport namespace DrawerProps {\n export interface I18nStrings {\n loadingText?: string;\n }\n}\n\n// Props for a future release\nexport interface NextDrawerProps extends DrawerProps {\n /**\n * Specifies the CSS positioning mode of the drawer, and supports the following options:\n * * `static` (default) - The drawer is positioned in the normal document flow.\n * * `sticky` - The drawer sticks to its nearest scrolling ancestor. Only meaningful with `placement=\"top\"` or `placement=\"bottom\"`.\n * Using `sticky` with `placement=\"start\"` or `placement=\"end\"` falls back to `static`.\n * * `absolute` - The drawer is positioned relative to its nearest positioned ancestor.\n * * `fixed` - The drawer is positioned relative to the viewport.\n */\n position?: NextDrawerProps.Position;\n\n /**\n * Specifies which edge of its container the drawer is anchored to, and supports these options:\n * * `start` - Anchored to the inline-start edge.\n * * `end` - (default) Anchored to the inline-end edge.\n * * `top` - Anchored to the top edge.\n * * `bottom` - Anchored to the bottom edge.\n */\n placement?: NextDrawerProps.Placement;\n\n /**\n * Specifies the distance in pixels between the drawer and the edges of its container.\n * Applicable when using `position=\"absolute\"` or `position=\"fixed\"`.\n * Supported properties:\n * * `start` - Distance from the inline-start edge. Not applicable when `placement` is `\"end\"`.\n * * `end` - Distance from the inline-end edge. Not applicable when `placement` is `\"start\"`.\n * * `top` - Distance from the top edge. Not applicable when `placement` is `\"bottom\"`.\n * * `bottom` - Distance from the bottom edge. Not applicable when `placement` is `\"top\"`.\n */\n offset?: NextDrawerProps.Offset;\n\n /**\n * Specifies the distance in pixels from the top or bottom edge of the scrolling container\n * at which the drawer sticks. Applicable only when using `position=\"sticky\"` with `placement=\"top\"` or `placement=\"bottom\"`.\n * * Supported properties:\n * * `top` - Distance from the top of the scrolling container.\n * * `bottom` - Distance from the bottom of the scrolling container.\n */\n stickyOffset?: NextDrawerProps.StickyOffset;\n\n /**\n * Sets the CSS `z-index` of the drawer. Use this to control stacking order when the drawer\n * overlaps other positioned elements on the page.\n *\n * Applicable when using `position=\"sticky\"`, `position=\"absolute\"`, or `position=\"fixed\"`.\n */\n zIndex?: number;\n}\n\nexport namespace NextDrawerProps {\n export type Position = 'static' | 'sticky' | 'absolute' | 'fixed';\n\n export type Placement = 'start' | 'end' | 'top' | 'bottom';\n\n export interface Offset {\n start?: number;\n end?: number;\n top?: number;\n bottom?: number;\n }\n\n export interface StickyOffset {\n top?: number;\n bottom?: number;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/drawer/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\n\nimport { ButtonProps } from '../button/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface DrawerProps extends BaseComponentProps {\n /**\n * Header of the drawer.\n *\n * It should contain the only `h2` used in the drawer.\n */\n header?: React.ReactNode;\n\n /**\n * Main content of the drawer.\n */\n children?: React.ReactNode;\n\n /**\n * Renders the drawer in a loading state. We recommend that you also set a `i18nStrings.loadingText`.\n */\n loading?: boolean;\n\n /**\n * Determines whether the drawer content has padding. If `true`, removes the default padding from the content area.\n */\n disableContentPaddings?: boolean;\n\n /**\n * An object containing all the necessary localized strings required by the component.\n * - `loadingText` - The text that's displayed when the drawer is in a loading state.\n * @i18n\n */\n i18nStrings?: DrawerProps.I18nStrings;\n\n /**\n * Actions for the header. Available only if you specify the `header` property.\n */\n headerActions?: React.ReactNode;\n\n /**\n * Sticky footer content that remains visible at the bottom during scroll.\n *\n * Automatically becomes non-sticky when scrollable content area is too small\n * to ensure content remains accessible (not covered by the footer).\n */\n footer?: React.ReactNode;\n}\n\nexport namespace DrawerProps {\n export interface I18nStrings {\n loadingText?: string;\n }\n}\n\n// Props for a future release\nexport interface NextDrawerProps extends DrawerProps {\n /**\n * Sets the ARIA role of the drawer.\n * - `\"region\"` (default for non-`static` positions) — exposes the drawer as a\n * landmark region. The drawer receives focus when opened.\n * - `\"presentation\"` (default for `position=\"static\"`) — removes landmark semantics\n * from the drawer body. Use this when the containing element already provides the\n * appropriate semantic role (e.g. a wrapping `<nav>` or `<aside>`). The drawer does not\n * receive focus when opened.\n */\n role?: 'region' | 'presentation';\n\n /**\n * Sets the `aria-label` on the drawer body.\n * By default the body is labelled by the drawer's `header` content. Use this when you need a different\n * or more specific label (e.g. to include additional context or exclude parts of the header).\n * Does not apply when `role=\"presentation\"`. Don't use `ariaLabel` and `ariaLabelledby` at the same time.\n */\n ariaLabel?: string;\n\n /**\n * Sets the `aria-labelledby` on the drawer body.\n * By default the body is labelled by the drawer's `header` content. Use this when you need a different\n * or more specific label (e.g. to include additional context or exclude parts of the header).\n * Does not apply when `role=\"presentation\"`. Don't use `ariaLabel` and `ariaLabelledby` at the same time.\n */\n ariaLabelledby?: string;\n\n /**\n * Specifies the CSS positioning mode of the drawer, and supports the following options:\n * * `static` (default) - The drawer is positioned in the normal document flow.\n * * `sticky` - The drawer sticks to its nearest scrolling ancestor. Only meaningful with `placement=\"top\"` or `placement=\"bottom\"`.\n * Using `sticky` with `placement=\"start\"` or `placement=\"end\"` falls back to `static`.\n * * `absolute` - The drawer is positioned relative to its nearest positioned ancestor.\n * * `fixed` - The drawer is positioned relative to the viewport.\n */\n position?: NextDrawerProps.Position;\n\n /**\n * Specifies which edge of its container the drawer is anchored to, and supports these options:\n * * `start` - Anchored to the inline-start edge.\n * * `end` - (default) Anchored to the inline-end edge.\n * * `top` - Anchored to the top edge.\n * * `bottom` - Anchored to the bottom edge.\n */\n placement?: NextDrawerProps.Placement;\n\n /**\n * Specifies the distance in pixels between the drawer and the edges of its container.\n * Applicable when using `position=\"absolute\"` or `position=\"fixed\"`.\n * Supported properties:\n * * `start` - Distance from the inline-start edge. Not applicable when `placement` is `\"end\"`.\n * * `end` - Distance from the inline-end edge. Not applicable when `placement` is `\"start\"`.\n * * `top` - Distance from the top edge. Not applicable when `placement` is `\"bottom\"`.\n * * `bottom` - Distance from the bottom edge. Not applicable when `placement` is `\"top\"`.\n */\n offset?: NextDrawerProps.Offset;\n\n /**\n * Specifies the distance in pixels from the top or bottom edge of the scrolling container\n * at which the drawer sticks. Applicable only when using `position=\"sticky\"` with `placement=\"top\"` or `placement=\"bottom\"`.\n * * Supported properties:\n * * `top` - Distance from the top of the scrolling container.\n * * `bottom` - Distance from the bottom of the scrolling container.\n */\n stickyOffset?: NextDrawerProps.StickyOffset;\n\n /**\n * Sets the CSS `z-index` of the drawer. Use this to control stacking order when the drawer\n * overlaps other positioned elements on the page.\n *\n * Applicable when using `position=\"sticky\"`, `position=\"absolute\"`, or `position=\"fixed\"`.\n */\n zIndex?: number;\n\n /**\n * When defined, renders a close button in the header with the provided configuration.\n * The close button fires the `onClose` event with method `'close-action'` when\n * clicked.\n */\n closeAction?: Pick<\n ButtonProps,\n 'ariaLabel' | 'disabled' | 'disabledReason' | 'iconName' | 'iconSvg' | 'iconUrl' | 'iconAlt'\n >;\n\n /**\n * Hides the close action slot next to the header actions, which is present even\n * when close action is not set. Use it when a close action is not needed, or a\n * custom close action implementation is used.\n */\n hideCloseAction?: boolean;\n\n /**\n * Called when the user performs a close action. The `event.detail.method` indicates the trigger:\n * * `'close-action'` - The close button was clicked.\n * * `'backdrop-click'` - The backdrop was clicked (only when `backdrop=true`).\n * * `'escape'` - The Escape key was pressed (only when `backdrop=true`).\n */\n onClose?: NonCancelableEventHandler<NextDrawerProps.CloseDetail>;\n\n /**\n * Drawer open state. Set to `true` to show the drawer, `false` to hide it.\n * Handle the `onClose` event to update this value when the user requests to close the drawer.\n *\n * When the property is unset - the drawer is always visible, and the built-in focus in/out behaviors are disabled.\n */\n open?: boolean;\n\n /**\n * Shows a semi-transparent backdrop behind the drawer when open. Used with `absolute`\n * and `fixed` positions.\n *\n * When a backdrop is set, the keyboard focus is trapped inside the drawer by default\n * to prevent it from moving to elements covered by the backdrop. This can be overridden\n * with `focusBehavior.trapFocus`.\n */\n backdrop?: boolean;\n\n /**\n * Customizes focus-related behavior:\n *\n * - `autoFocus` - Whether focus moves into the drawer when `open` changes from `false` to `true`,\n * and captures the previously focused element for default return-focus on close.\n * Defaults to `true`. Set to `false` to manage focus-in manually via `ref.current.focus()`.\n *\n * - `trapFocus` - Whether keyboard focus is constrained to elements inside the drawer.\n * Defaults to `true` when `backdrop` is set, `false` otherwise.\n *\n * - `returnFocus` - Called instead of the default return-focus behavior when the drawer closes.\n * Use this to override where focus lands on close (e.g. a specific trigger element).\n * If omitted, focus returns to the element that was focused when the drawer opened.\n * If that element is no longer in the DOM, the behavior silently no-ops.\n */\n focusBehavior?: NextDrawerProps.FocusBehavior;\n}\n\nexport namespace NextDrawerProps {\n export type Position = 'static' | 'sticky' | 'absolute' | 'fixed';\n\n export type Placement = 'start' | 'end' | 'top' | 'bottom';\n\n export interface Offset {\n start?: number;\n end?: number;\n top?: number;\n bottom?: number;\n }\n\n export interface StickyOffset {\n top?: number;\n bottom?: number;\n }\n\n export interface CloseDetail {\n method: 'close-action' | 'backdrop-click' | 'escape';\n }\n\n export interface FocusBehavior {\n autoFocus?: boolean;\n trapFocus?: boolean;\n returnFocus?: () => void;\n }\n\n export interface Ref {\n /**\n * Moves focus to the drawer element. Use in controlled mode when `focusBehavior.autoFocus`\n * is disabled and you need to manage focus manually, or to focus a drawer, initially rendered\n * with `open=true`. The drawer with `role=\"presentation\"` cannot be focused.\n */\n focus(): void;\n }\n}\n"]}
|
package/drawer/next.d.ts
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { NextDrawerProps } from './interfaces';
|
|
2
3
|
export { NextDrawerProps };
|
|
3
|
-
declare const Drawer:
|
|
4
|
-
header,
|
|
5
|
-
headerActions,
|
|
6
|
-
footer,
|
|
7
|
-
disableContentPaddings,
|
|
8
|
-
loading,
|
|
9
|
-
position,
|
|
10
|
-
placement,
|
|
11
|
-
offset,
|
|
12
|
-
stickyOffset,
|
|
13
|
-
zIndex,
|
|
14
|
-
...props
|
|
15
|
-
}: NextDrawerProps) => JSX.Element;
|
|
4
|
+
declare const Drawer: React.ForwardRefExoticComponent<NextDrawerProps & React.RefAttributes<NextDrawerProps.Ref>>;
|
|
16
5
|
export default Drawer;
|
package/drawer/next.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../../../src/drawer/next.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../../../src/drawer/next.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAO1C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAK3B,QAAA,MAAM,MAAM,6FAwEV,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
package/drawer/next.js
CHANGED
|
@@ -2,30 +2,37 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
// eslint-disable-next-line @cloudscape-design/build-tools/react-server-components-directive
|
|
4
4
|
'use client';
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { forwardRef } from 'react';
|
|
6
|
+
import { warnOnce } from '@cloudscape-design/component-toolkit/internal';
|
|
6
7
|
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
7
8
|
import { applyDisplayName } from '../internal/utils/apply-display-name';
|
|
8
9
|
import { getExternalProps } from '../internal/utils/external-props';
|
|
9
10
|
import { InternalDrawer } from './internal';
|
|
10
|
-
|
|
11
|
+
// Matches App Layout drawers z-index.
|
|
12
|
+
const DEFAULT_Z_INDEX = 830;
|
|
13
|
+
const Drawer = forwardRef(function Drawer({ header, headerActions, footer, disableContentPaddings = false, loading = false, position = 'static', placement = 'end', offset, stickyOffset, zIndex = DEFAULT_Z_INDEX, closeAction, hideCloseAction = false, open, backdrop = false, onClose, focusBehavior, role, ...props }, ref) {
|
|
14
|
+
if (backdrop && position !== 'fixed' && position !== 'absolute') {
|
|
15
|
+
warnOnce('Drawer', `\`backdrop\` is not supported with position="${position}" and will be ignored.`);
|
|
16
|
+
}
|
|
17
|
+
if (open !== undefined && !onClose) {
|
|
18
|
+
warnOnce('Drawer', 'You provided `open` without an `onClose` handler. The drawer will not respond to close actions.');
|
|
19
|
+
}
|
|
11
20
|
const baseComponentProps = useBaseComponent('Drawer', {
|
|
12
|
-
props: {
|
|
13
|
-
disableContentPaddings,
|
|
14
|
-
loading,
|
|
15
|
-
placement,
|
|
16
|
-
position,
|
|
17
|
-
zIndex,
|
|
18
|
-
},
|
|
21
|
+
props: { disableContentPaddings, loading, placement, position, zIndex, hideCloseAction, backdrop, role },
|
|
19
22
|
metadata: {
|
|
20
23
|
hasHeader: !!header,
|
|
21
24
|
hasHeaderActions: !!headerActions,
|
|
22
25
|
hasFooter: !!footer,
|
|
23
26
|
hasOffset: !!offset,
|
|
24
27
|
hasStickyOffset: !!stickyOffset,
|
|
28
|
+
hasCloseAction: !!closeAction,
|
|
29
|
+
autoFocus: !!(focusBehavior === null || focusBehavior === void 0 ? void 0 : focusBehavior.autoFocus),
|
|
30
|
+
trapFocus: !!(focusBehavior === null || focusBehavior === void 0 ? void 0 : focusBehavior.trapFocus),
|
|
31
|
+
returnFocus: !!(focusBehavior === null || focusBehavior === void 0 ? void 0 : focusBehavior.returnFocus),
|
|
25
32
|
},
|
|
26
33
|
});
|
|
27
|
-
return (React.createElement(InternalDrawer, { ...getExternalProps(props), ...baseComponentProps, header: header, headerActions: headerActions, footer: footer, disableContentPaddings: disableContentPaddings, loading: loading, placement: placement, position: position, offset: offset, stickyOffset: stickyOffset, zIndex: zIndex }));
|
|
28
|
-
};
|
|
34
|
+
return (React.createElement(InternalDrawer, { ...getExternalProps(props), ...baseComponentProps, __ref: ref, header: header, headerActions: headerActions, footer: footer, disableContentPaddings: disableContentPaddings, loading: loading, placement: placement, position: position, offset: offset, stickyOffset: stickyOffset, zIndex: zIndex, closeAction: closeAction, hideCloseAction: hideCloseAction, open: open, backdrop: backdrop, onClose: onClose, focusBehavior: focusBehavior, role: role }));
|
|
35
|
+
});
|
|
29
36
|
export default Drawer;
|
|
30
37
|
applyDisplayName(Drawer, 'Drawer');
|
|
31
38
|
//# sourceMappingURL=next.js.map
|
package/drawer/next.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.js","sourceRoot":"","sources":["../../../src/drawer/next.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,4FAA4F;AAC5F,YAAY,CAAC;AACb,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"next.js","sourceRoot":"","sources":["../../../src/drawer/next.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,4FAA4F;AAC5F,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAA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CAAC,MAAM;YACnB,eAAe,EAAE,CAAC,CAAC,YAAY;YAC/B,cAAc,EAAE,CAAC,CAAC,WAAW;YAC7B,SAAS,EAAE,CAAC,CAAC,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,SAAS,CAAA;YACrC,SAAS,EAAE,CAAC,CAAC,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,SAAS,CAAA;YACrC,WAAW,EAAE,CAAC,CAAC,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,WAAW,CAAA;SAC1C;KACF,CAAC,CAAC;IAEH,OAAO,CACL,oBAAC,cAAc,OACT,gBAAgB,CAAC,KAAK,CAAC,KACvB,kBAAkB,EACtB,KAAK,EAAE,GAAG,EACV,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,MAAM,EACd,sBAAsB,EAAE,sBAAsB,EAC9C,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,IAAI,GACV,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,MAAM,CAAC;AAEtB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n// eslint-disable-next-line @cloudscape-design/build-tools/react-server-components-directive\n'use client';\nimport React, { forwardRef } from 'react';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport { getExternalProps } from '../internal/utils/external-props';\nimport { NextDrawerProps } from './interfaces';\nimport { InternalDrawer } from './internal';\n\nexport { NextDrawerProps };\n\n// Matches App Layout drawers z-index.\nconst DEFAULT_Z_INDEX = 830;\n\nconst Drawer = forwardRef(function Drawer(\n {\n header,\n headerActions,\n footer,\n disableContentPaddings = false,\n loading = false,\n position = 'static',\n placement = 'end',\n offset,\n stickyOffset,\n zIndex = DEFAULT_Z_INDEX,\n closeAction,\n hideCloseAction = false,\n open,\n backdrop = false,\n onClose,\n focusBehavior,\n role,\n ...props\n }: NextDrawerProps,\n ref: React.Ref<NextDrawerProps.Ref>\n) {\n if (backdrop && position !== 'fixed' && position !== 'absolute') {\n warnOnce('Drawer', `\\`backdrop\\` is not supported with position=\"${position}\" and will be ignored.`);\n }\n if (open !== undefined && !onClose) {\n warnOnce(\n 'Drawer',\n 'You provided `open` without an `onClose` handler. The drawer will not respond to close actions.'\n );\n }\n\n const baseComponentProps = useBaseComponent('Drawer', {\n props: { disableContentPaddings, loading, placement, position, zIndex, hideCloseAction, backdrop, role },\n metadata: {\n hasHeader: !!header,\n hasHeaderActions: !!headerActions,\n hasFooter: !!footer,\n hasOffset: !!offset,\n hasStickyOffset: !!stickyOffset,\n hasCloseAction: !!closeAction,\n autoFocus: !!focusBehavior?.autoFocus,\n trapFocus: !!focusBehavior?.trapFocus,\n returnFocus: !!focusBehavior?.returnFocus,\n },\n });\n\n return (\n <InternalDrawer\n {...getExternalProps(props)}\n {...baseComponentProps}\n __ref={ref}\n header={header}\n headerActions={headerActions}\n footer={footer}\n disableContentPaddings={disableContentPaddings}\n loading={loading}\n placement={placement}\n position={position}\n offset={offset}\n stickyOffset={stickyOffset}\n zIndex={zIndex}\n closeAction={closeAction}\n hideCloseAction={hideCloseAction}\n open={open}\n backdrop={backdrop}\n onClose={onClose}\n focusBehavior={focusBehavior}\n role={role}\n />\n );\n});\n\nexport default Drawer;\n\napplyDisplayName(Drawer, 'Drawer');\n"]}
|
package/drawer/styles.css.js
CHANGED
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"position-
|
|
8
|
-
"
|
|
9
|
-
"position-
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
4
|
+
"root": "awsui_root_1sxt8_1cneo_193",
|
|
5
|
+
"drawer": "awsui_drawer_1sxt8_1cneo_197",
|
|
6
|
+
"has-close-action": "awsui_has-close-action_1sxt8_1cneo_230",
|
|
7
|
+
"position-absolute": "awsui_position-absolute_1sxt8_1cneo_233",
|
|
8
|
+
"position-sticky": "awsui_position-sticky_1sxt8_1cneo_233",
|
|
9
|
+
"position-fixed": "awsui_position-fixed_1sxt8_1cneo_233",
|
|
10
|
+
"with-footer": "awsui_with-footer_1sxt8_1cneo_236",
|
|
11
|
+
"position-static": "awsui_position-static_1sxt8_1cneo_240",
|
|
12
|
+
"content": "awsui_content_1sxt8_1cneo_243",
|
|
13
|
+
"header": "awsui_header_1sxt8_1cneo_271",
|
|
14
|
+
"hide-close-action": "awsui_hide-close-action_1sxt8_1cneo_287",
|
|
15
|
+
"with-additional-action": "awsui_with-additional-action_1sxt8_1cneo_291",
|
|
16
|
+
"with-runtime-context": "awsui_with-runtime-context_1sxt8_1cneo_299",
|
|
17
|
+
"with-toolbar": "awsui_with-toolbar_1sxt8_1cneo_302",
|
|
18
|
+
"header-actions": "awsui_header-actions_1sxt8_1cneo_321",
|
|
19
|
+
"close-action": "awsui_close-action_1sxt8_1cneo_327",
|
|
20
|
+
"content-with-paddings": "awsui_content-with-paddings_1sxt8_1cneo_333",
|
|
21
|
+
"footer": "awsui_footer_1sxt8_1cneo_340",
|
|
22
|
+
"is-sticky": "awsui_is-sticky_1sxt8_1cneo_346",
|
|
23
|
+
"test-utils-drawer-content": "awsui_test-utils-drawer-content_1sxt8_1cneo_354",
|
|
24
|
+
"hidden": "awsui_hidden_1sxt8_1cneo_358",
|
|
25
|
+
"focus-trap": "awsui_focus-trap_1sxt8_1cneo_362",
|
|
26
|
+
"backdrop": "awsui_backdrop_1sxt8_1cneo_366",
|
|
27
|
+
"backdrop-fixed": "awsui_backdrop-fixed_1sxt8_1cneo_370",
|
|
28
|
+
"backdrop-absolute": "awsui_backdrop-absolute_1sxt8_1cneo_373"
|
|
20
29
|
};
|
|
21
30
|
|