@cloudscape-design/components 3.0.235 → 3.0.236
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app-layout/drawer/index.d.ts +2 -5
- package/app-layout/drawer/index.d.ts.map +1 -1
- package/app-layout/drawer/index.js.map +1 -1
- package/app-layout/index.d.ts.map +1 -1
- package/app-layout/index.js +20 -15
- package/app-layout/index.js.map +1 -1
- package/app-layout/utils/use-focus-control.d.ts +8 -6
- package/app-layout/utils/use-focus-control.d.ts.map +1 -1
- package/app-layout/utils/use-focus-control.js +21 -10
- package/app-layout/utils/use-focus-control.js.map +1 -1
- package/app-layout/utils/use-split-panel-focus-control.d.ts +21 -0
- package/app-layout/utils/use-split-panel-focus-control.d.ts.map +1 -0
- package/app-layout/utils/use-split-panel-focus-control.js +32 -0
- package/app-layout/utils/use-split-panel-focus-control.js.map +1 -0
- package/app-layout/visual-refresh/app-bar.d.ts.map +1 -1
- package/app-layout/visual-refresh/app-bar.js +3 -6
- package/app-layout/visual-refresh/app-bar.js.map +1 -1
- package/app-layout/visual-refresh/context.d.ts +6 -2
- package/app-layout/visual-refresh/context.d.ts.map +1 -1
- package/app-layout/visual-refresh/context.js +24 -11
- package/app-layout/visual-refresh/context.js.map +1 -1
- package/app-layout/visual-refresh/navigation.d.ts.map +1 -1
- package/app-layout/visual-refresh/navigation.js +3 -5
- package/app-layout/visual-refresh/navigation.js.map +1 -1
- package/app-layout/visual-refresh/split-panel.d.ts.map +1 -1
- package/app-layout/visual-refresh/split-panel.js +4 -8
- package/app-layout/visual-refresh/split-panel.js.map +1 -1
- package/app-layout/visual-refresh/tools.js +5 -6
- package/app-layout/visual-refresh/tools.js.map +1 -1
- package/autosuggest/internal.d.ts.map +1 -1
- package/autosuggest/internal.js +10 -4
- package/autosuggest/internal.js.map +1 -1
- package/breadcrumb-group/internal.d.ts.map +1 -1
- package/breadcrumb-group/internal.js +2 -2
- package/breadcrumb-group/internal.js.map +1 -1
- package/breadcrumb-group/styles.css.js +7 -6
- package/breadcrumb-group/styles.scoped.css +14 -11
- package/breadcrumb-group/styles.selectors.js +7 -6
- package/calendar/grid/index.d.ts +1 -1
- package/calendar/grid/index.d.ts.map +1 -1
- package/calendar/grid/index.js.map +1 -1
- package/calendar/header/header-button.d.ts +1 -1
- package/calendar/header/header-button.d.ts.map +1 -1
- package/calendar/header/header-button.js.map +1 -1
- package/calendar/header/index.d.ts +2 -2
- package/calendar/header/index.d.ts.map +1 -1
- package/calendar/header/index.js.map +1 -1
- package/calendar/interfaces.d.ts +3 -3
- package/calendar/interfaces.d.ts.map +1 -1
- package/calendar/interfaces.js.map +1 -1
- package/calendar/internal.d.ts +1 -1
- package/calendar/internal.d.ts.map +1 -1
- package/calendar/internal.js +6 -1
- package/calendar/internal.js.map +1 -1
- package/date-picker/index.d.ts.map +1 -1
- package/date-picker/index.js +6 -4
- package/date-picker/index.js.map +1 -1
- package/internal/context/split-panel-context.d.ts +2 -8
- package/internal/context/split-panel-context.d.ts.map +1 -1
- package/internal/context/split-panel-context.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/i18n/context.d.ts +6 -1
- package/internal/i18n/context.d.ts.map +1 -1
- package/internal/i18n/context.js +8 -2
- package/internal/i18n/context.js.map +1 -1
- package/internal/i18n/messages/all.all.js +219 -210
- package/internal/i18n/messages/all.all.json +231 -231
- package/internal/i18n/messages/all.de.js +20 -20
- package/internal/i18n/messages/all.de.json +20 -20
- package/internal/i18n/messages/all.en-GB.js +20 -20
- package/internal/i18n/messages/all.en-GB.json +20 -20
- package/internal/i18n/messages/all.en.js +20 -20
- package/internal/i18n/messages/all.en.json +20 -20
- package/internal/i18n/messages/all.es.js +20 -20
- package/internal/i18n/messages/all.es.json +20 -20
- package/internal/i18n/messages/all.fr.js +20 -20
- package/internal/i18n/messages/all.fr.json +20 -20
- package/internal/i18n/messages/all.id.js +20 -20
- package/internal/i18n/messages/all.id.json +20 -20
- package/internal/i18n/messages/all.it.js +20 -20
- package/internal/i18n/messages/all.it.json +20 -20
- package/internal/i18n/messages/all.ja.js +20 -20
- package/internal/i18n/messages/all.ja.json +20 -20
- package/internal/i18n/messages/all.ko.js +22 -19
- package/internal/i18n/messages/all.ko.json +20 -20
- package/internal/i18n/messages/all.pt-BR.js +20 -20
- package/internal/i18n/messages/all.pt-BR.json +20 -20
- package/internal/i18n/messages/all.zh-CN.js +24 -21
- package/internal/i18n/messages/all.zh-CN.json +22 -22
- package/internal/i18n/messages/all.zh-TW.js +23 -20
- package/internal/i18n/messages/all.zh-TW.json +21 -21
- package/internal/i18n/provider.js +1 -1
- package/internal/i18n/provider.js.map +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
- package/property-filter/index.js.map +1 -1
- package/select/parts/styles.css.js +9 -9
- package/select/parts/styles.scoped.css +9 -27
- package/select/parts/styles.selectors.js +9 -9
- package/split-panel/index.d.ts.map +1 -1
- package/split-panel/index.js +6 -24
- package/split-panel/index.js.map +1 -1
- package/table/body-cell/use-stable-scroll-position.d.ts.map +1 -1
- package/table/body-cell/use-stable-scroll-position.js +10 -4
- package/table/body-cell/use-stable-scroll-position.js.map +1 -1
- package/table/header-cell/index.js +2 -3
- package/table/header-cell/index.js.map +1 -1
- package/table/use-table-focus-navigation.d.ts +1 -1
- package/table/use-table-focus-navigation.d.ts.map +1 -1
- package/table/use-table-focus-navigation.js +4 -4
- package/table/use-table-focus-navigation.js.map +1 -1
- package/tutorial-panel/components/tutorial-list/index.d.ts +0 -1
- package/tutorial-panel/components/tutorial-list/index.d.ts.map +1 -1
- package/tutorial-panel/components/tutorial-list/index.js +3 -15
- package/tutorial-panel/components/tutorial-list/index.js.map +1 -1
- package/tutorial-panel/index.d.ts.map +1 -1
- package/tutorial-panel/index.js +2 -14
- package/tutorial-panel/index.js.map +1 -1
- package/tutorial-panel/interfaces.d.ts +1 -1
- package/tutorial-panel/interfaces.d.ts.map +1 -1
- package/tutorial-panel/interfaces.js.map +1 -1
- package/wizard/index.d.ts +1 -1
- package/wizard/index.d.ts.map +1 -1
- package/wizard/index.js +4 -1
- package/wizard/index.js.map +1 -1
- package/wizard/interfaces.d.ts +5 -5
- package/wizard/interfaces.d.ts.map +1 -1
- package/wizard/interfaces.js.map +1 -1
- package/wizard/wizard-actions.d.ts +3 -3
- package/wizard/wizard-actions.d.ts.map +1 -1
- package/wizard/wizard-actions.js.map +1 -1
- package/wizard/wizard-form.js +2 -1
- package/wizard/wizard-form.js.map +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"placeholder": "
|
|
5
|
-
"item": "
|
|
6
|
-
"checkbox": "
|
|
7
|
-
"filter": "
|
|
8
|
-
"trigger": "
|
|
9
|
-
"layout-strut": "awsui_layout-
|
|
10
|
-
"list-bottom": "awsui_list-
|
|
11
|
-
"selected-icon": "awsui_selected-
|
|
12
|
-
"show-label-tag": "awsui_show-label-
|
|
4
|
+
"placeholder": "awsui_placeholder_dwuol_33ljx_93",
|
|
5
|
+
"item": "awsui_item_dwuol_33ljx_98",
|
|
6
|
+
"checkbox": "awsui_checkbox_dwuol_33ljx_102",
|
|
7
|
+
"filter": "awsui_filter_dwuol_33ljx_111",
|
|
8
|
+
"trigger": "awsui_trigger_dwuol_33ljx_116",
|
|
9
|
+
"layout-strut": "awsui_layout-strut_dwuol_33ljx_122",
|
|
10
|
+
"list-bottom": "awsui_list-bottom_dwuol_33ljx_128",
|
|
11
|
+
"selected-icon": "awsui_selected-icon_dwuol_33ljx_132",
|
|
12
|
+
"show-label-tag": "awsui_show-label-tag_dwuol_33ljx_136"
|
|
13
13
|
};
|
|
14
14
|
|
|
@@ -90,16 +90,16 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
90
90
|
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
91
91
|
SPDX-License-Identifier: Apache-2.0
|
|
92
92
|
*/
|
|
93
|
-
.
|
|
93
|
+
.awsui_placeholder_dwuol_33ljx_93:not(#\9) {
|
|
94
94
|
color: var(--color-text-input-placeholder-j53j3c, #5f6b7a);
|
|
95
95
|
font-style: italic;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
.
|
|
98
|
+
.awsui_item_dwuol_33ljx_98:not(#\9) {
|
|
99
99
|
display: flex;
|
|
100
100
|
align-items: center;
|
|
101
101
|
}
|
|
102
|
-
.
|
|
102
|
+
.awsui_item_dwuol_33ljx_98 > .awsui_checkbox_dwuol_33ljx_102:not(#\9) {
|
|
103
103
|
position: relative;
|
|
104
104
|
min-height: var(--size-control-n9i4yo, 16px);
|
|
105
105
|
min-width: var(--size-control-n9i4yo, 16px);
|
|
@@ -108,49 +108,31 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
108
108
|
margin-right: var(--space-field-horizontal-89h2yr, 12px);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
.
|
|
111
|
+
.awsui_filter_dwuol_33ljx_111:not(#\9) {
|
|
112
112
|
z-index: 4;
|
|
113
113
|
flex-shrink: 0;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
.
|
|
116
|
+
.awsui_trigger_dwuol_33ljx_116:not(#\9) {
|
|
117
117
|
white-space: nowrap;
|
|
118
118
|
overflow: hidden;
|
|
119
119
|
text-overflow: ellipsis;
|
|
120
120
|
}
|
|
121
|
-
.awsui_trigger_dwuol_zur0f_116[data-awsui-focus-visible=true]:not(#\9):focus {
|
|
122
|
-
position: relative;
|
|
123
|
-
}
|
|
124
|
-
.awsui_trigger_dwuol_zur0f_116[data-awsui-focus-visible=true]:not(#\9):focus {
|
|
125
|
-
outline: 2px dotted transparent;
|
|
126
|
-
outline-offset: calc(calc(-1 * var(--space-scaled-xs-6859qs, 8px)) - 1px);
|
|
127
|
-
}
|
|
128
|
-
.awsui_trigger_dwuol_zur0f_116[data-awsui-focus-visible=true]:not(#\9):focus::before {
|
|
129
|
-
content: " ";
|
|
130
|
-
display: block;
|
|
131
|
-
position: absolute;
|
|
132
|
-
left: calc(-1 * calc(-1 * var(--space-scaled-xs-6859qs, 8px)));
|
|
133
|
-
top: calc(-1 * calc(-1 * var(--space-scaled-xxs-95dhkm, 4px)));
|
|
134
|
-
width: calc(100% + 2 * calc(-1 * var(--space-scaled-xs-6859qs, 8px)));
|
|
135
|
-
height: calc(100% + 2 * calc(-1 * var(--space-scaled-xxs-95dhkm, 4px)));
|
|
136
|
-
border-radius: var(--border-radius-control-default-focus-ring-7661kz, 4px);
|
|
137
|
-
box-shadow: 0 0 0 2px var(--color-border-item-focused-ap3b6s, #0972d3);
|
|
138
|
-
}
|
|
139
121
|
|
|
140
|
-
.awsui_layout-
|
|
122
|
+
.awsui_layout-strut_dwuol_33ljx_122:not(#\9) {
|
|
141
123
|
width: 100%;
|
|
142
124
|
position: relative;
|
|
143
125
|
transform: translate3d(0, 0, 0);
|
|
144
126
|
}
|
|
145
127
|
|
|
146
|
-
.awsui_list-
|
|
128
|
+
.awsui_list-bottom_dwuol_33ljx_128:not(#\9) {
|
|
147
129
|
/* used in unit-tests */
|
|
148
130
|
}
|
|
149
131
|
|
|
150
|
-
.awsui_selected-
|
|
132
|
+
.awsui_selected-icon_dwuol_33ljx_132:not(#\9) {
|
|
151
133
|
color: var(--color-border-item-focused-ap3b6s, #0972d3);
|
|
152
134
|
}
|
|
153
135
|
|
|
154
|
-
.awsui_show-label-
|
|
136
|
+
.awsui_show-label-tag_dwuol_33ljx_136 > .awsui_selected-icon_dwuol_33ljx_132:not(#\9) {
|
|
155
137
|
padding-left: var(--space-scaled-s-cu1hzn, 12px);
|
|
156
138
|
}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"placeholder": "
|
|
6
|
-
"item": "
|
|
7
|
-
"checkbox": "
|
|
8
|
-
"filter": "
|
|
9
|
-
"trigger": "
|
|
10
|
-
"layout-strut": "awsui_layout-
|
|
11
|
-
"list-bottom": "awsui_list-
|
|
12
|
-
"selected-icon": "awsui_selected-
|
|
13
|
-
"show-label-tag": "awsui_show-label-
|
|
5
|
+
"placeholder": "awsui_placeholder_dwuol_33ljx_93",
|
|
6
|
+
"item": "awsui_item_dwuol_33ljx_98",
|
|
7
|
+
"checkbox": "awsui_checkbox_dwuol_33ljx_102",
|
|
8
|
+
"filter": "awsui_filter_dwuol_33ljx_111",
|
|
9
|
+
"trigger": "awsui_trigger_dwuol_33ljx_116",
|
|
10
|
+
"layout-strut": "awsui_layout-strut_dwuol_33ljx_122",
|
|
11
|
+
"list-bottom": "awsui_list-bottom_dwuol_33ljx_128",
|
|
12
|
+
"selected-icon": "awsui_selected-icon_dwuol_33ljx_132",
|
|
13
|
+
"show-label-tag": "awsui_show-label-tag_dwuol_33ljx_136"
|
|
14
14
|
};
|
|
15
15
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/split-panel/index.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,eAAe,EAAoB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/split-panel/index.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAE,eAAe,EAAoB,MAAM,cAAc,CAAC;AAiBjE,OAAO,EAAE,eAAe,EAAE,CAAC;AAK3B,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,MAAM,EACN,QAAQ,EACR,qBAA6B,EAC7B,aAA0B,EAC1B,WAAW,EACX,GAAG,SAAS,EACb,EAAE,eAAe,eAgRjB"}
|
package/split-panel/index.js
CHANGED
|
@@ -18,7 +18,6 @@ import { useMergeRefs } from '../internal/hooks/use-merge-refs';
|
|
|
18
18
|
import { AppLayoutContext } from '../internal/context/app-layout-context';
|
|
19
19
|
import { getLimitedValue } from './utils/size-utils';
|
|
20
20
|
import { Transition } from '../internal/components/transition';
|
|
21
|
-
import { useEffectOnUpdate } from '../internal/hooks/use-effect-on-update';
|
|
22
21
|
import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
|
|
23
22
|
import { useUniqueId } from '../internal/hooks/use-unique-id';
|
|
24
23
|
import { SplitPanelContentSide } from './side';
|
|
@@ -29,7 +28,7 @@ export default function SplitPanel(_a) {
|
|
|
29
28
|
var { header, children, hidePreferencesButton = false, closeBehavior = 'collapse', i18nStrings } = _a, restProps = __rest(_a, ["header", "children", "hidePreferencesButton", "closeBehavior", "i18nStrings"]);
|
|
30
29
|
const isRefresh = useVisualRefresh();
|
|
31
30
|
const { __internalRootRef } = useBaseComponent('SplitPanel');
|
|
32
|
-
const { size, getMaxWidth, getMaxHeight, position, topOffset, bottomOffset, rightOffset, contentWidthStyles, isOpen, isForcedPosition,
|
|
31
|
+
const { size, getMaxWidth, getMaxHeight, position, topOffset, bottomOffset, rightOffset, contentWidthStyles, isOpen, isForcedPosition, onPreferencesChange, onResize, onToggle, reportSize, setSplitPanelToggle, refs, } = useSplitPanelContext();
|
|
33
32
|
const baseProps = getBaseProps(restProps);
|
|
34
33
|
const focusVisible = useFocusVisible();
|
|
35
34
|
const [isPreferencesOpen, setPreferencesOpen] = useState(false);
|
|
@@ -74,32 +73,15 @@ export default function SplitPanel(_a) {
|
|
|
74
73
|
}
|
|
75
74
|
};
|
|
76
75
|
const splitPanelRefObject = useRef(null);
|
|
77
|
-
const handleRef = useRef(null);
|
|
78
76
|
const sizeControlProps = {
|
|
79
77
|
position,
|
|
80
78
|
splitPanelRef: splitPanelRefObject,
|
|
81
|
-
handleRef,
|
|
79
|
+
handleRef: refs.slider,
|
|
82
80
|
setSidePanelWidth,
|
|
83
81
|
setBottomPanelHeight,
|
|
84
82
|
};
|
|
85
83
|
const onSliderPointerDown = usePointerEvents(sizeControlProps);
|
|
86
84
|
const onKeyDown = useKeyboardEvents(sizeControlProps);
|
|
87
|
-
const toggleRef = useRef(null);
|
|
88
|
-
const closeRef = useRef(null);
|
|
89
|
-
const preferencesRef = useRef(null);
|
|
90
|
-
useEffectOnUpdate(() => {
|
|
91
|
-
var _a, _b, _c;
|
|
92
|
-
switch (lastInteraction === null || lastInteraction === void 0 ? void 0 : lastInteraction.type) {
|
|
93
|
-
case 'open':
|
|
94
|
-
return (_a = handleRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
95
|
-
case 'close':
|
|
96
|
-
return (_b = toggleRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
97
|
-
case 'position':
|
|
98
|
-
return (_c = preferencesRef.current) === null || _c === void 0 ? void 0 : _c.focus();
|
|
99
|
-
default:
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
}, [lastInteraction]);
|
|
103
85
|
const wrappedChildren = (React.createElement(AppLayoutContext.Provider, { value: {
|
|
104
86
|
stickyOffsetTop: topOffset,
|
|
105
87
|
stickyOffsetBottom: bottomOffset,
|
|
@@ -110,10 +92,10 @@ export default function SplitPanel(_a) {
|
|
|
110
92
|
React.createElement("h2", { className: styles['header-text'], id: panelHeaderId }, header),
|
|
111
93
|
React.createElement("div", { className: styles['header-actions'] },
|
|
112
94
|
!hidePreferencesButton && isOpen && (React.createElement(React.Fragment, null,
|
|
113
|
-
React.createElement(InternalButton, { className: styles['preferences-button'], iconName: "settings", variant: "icon", onClick: () => setPreferencesOpen(true), formAction: "none", ariaLabel: i18nStrings.preferencesTitle, ref:
|
|
95
|
+
React.createElement(InternalButton, { className: styles['preferences-button'], iconName: "settings", variant: "icon", onClick: () => setPreferencesOpen(true), formAction: "none", ariaLabel: i18nStrings.preferencesTitle, ref: refs.preferences }),
|
|
114
96
|
React.createElement("span", { className: styles.divider }))),
|
|
115
|
-
isOpen ? (React.createElement(InternalButton, { className: styles['close-button'], iconName: isRefresh && closeBehavior === 'collapse' ? (position === 'side' ? 'angle-right' : 'angle-down') : 'close', variant: "icon", onClick: onToggle, formAction: "none", ariaLabel: i18nStrings.closeButtonAriaLabel,
|
|
116
|
-
const resizeHandle = (React.createElement("div", Object.assign({ ref:
|
|
97
|
+
isOpen ? (React.createElement(InternalButton, { className: styles['close-button'], iconName: isRefresh && closeBehavior === 'collapse' ? (position === 'side' ? 'angle-right' : 'angle-down') : 'close', variant: "icon", onClick: onToggle, formAction: "none", ariaLabel: i18nStrings.closeButtonAriaLabel, ariaExpanded: isOpen })) : position === 'side' ? null : (React.createElement(InternalButton, { className: styles['open-button'], iconName: "angle-up", variant: "icon", formAction: "none", ariaLabel: i18nStrings.openButtonAriaLabel, ref: refs.toggle, ariaExpanded: isOpen })))));
|
|
98
|
+
const resizeHandle = (React.createElement("div", Object.assign({ ref: refs.slider, role: "slider", tabIndex: 0, "aria-label": i18nStrings.resizeHandleAriaLabel, "aria-valuemax": 100, "aria-valuemin": 0, "aria-valuenow": relativeSize, className: clsx(styles.slider, styles[`slider-${position}`]), onKeyDown: onKeyDown, onPointerDown: onSliderPointerDown }, focusVisible),
|
|
117
99
|
React.createElement(ResizeHandler, { className: clsx(styles['slider-icon'], styles[`slider-icon-${position}`]) })));
|
|
118
100
|
/*
|
|
119
101
|
This effect forces the browser to recalculate the layout
|
|
@@ -149,7 +131,7 @@ export default function SplitPanel(_a) {
|
|
|
149
131
|
return React.createElement(React.Fragment, null);
|
|
150
132
|
}
|
|
151
133
|
return (React.createElement(Transition, { in: isOpen !== null && isOpen !== void 0 ? isOpen : false }, (state, transitioningElementRef) => (React.createElement(React.Fragment, null,
|
|
152
|
-
position === 'side' && (React.createElement(SplitPanelContentSide, { resizeHandle: resizeHandle, baseProps: baseProps, isOpen: isOpen, splitPanelRef: mergedRef, cappedSize: cappedSize, onToggle: onToggle, i18nStrings: i18nStrings, toggleRef:
|
|
134
|
+
position === 'side' && (React.createElement(SplitPanelContentSide, { resizeHandle: resizeHandle, baseProps: baseProps, isOpen: isOpen, splitPanelRef: mergedRef, cappedSize: cappedSize, onToggle: onToggle, i18nStrings: i18nStrings, toggleRef: refs.toggle, header: wrappedHeader, panelHeaderId: panelHeaderId }, wrappedChildren)),
|
|
153
135
|
position === 'bottom' && (React.createElement(SplitPanelContentBottom, { resizeHandle: resizeHandle, baseProps: baseProps, isOpen: isOpen, splitPanelRef: mergedRef, cappedSize: cappedSize, onToggle: onToggle, header: wrappedHeader, panelHeaderId: panelHeaderId, state: state, transitioningElementRef: transitioningElementRef, appLayoutMaxWidth: appLayoutMaxWidth }, wrappedChildren)),
|
|
154
136
|
isPreferencesOpen && (React.createElement(PreferencesModal, { visible: true, preferences: { position }, disabledSidePosition: position === 'bottom' && isForcedPosition, isRefresh: isRefresh, i18nStrings: {
|
|
155
137
|
header: i18nStrings.preferencesTitle,
|
package/split-panel/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/split-panel/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAGxE,OAAO,aAAa,MAAM,wBAAwB,CAAC;AACnD,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,gBAAgB,MAA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cAAc,EAAE,WAAW,CAAC,yBAAyB;gBACrD,YAAY,EAAE,WAAW,CAAC,uBAAuB;aAClD,EACD,SAAS,EAAE,WAAW,CAAC,EAAE;gBACvB,mBAAmB,mBAAM,WAAW,EAAG,CAAC;gBACxC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC,EACD,SAAS,EAAE,GAAG,EAAE;gBACd,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC,GACD,CACH,CACA,CACJ,CACU,CACd,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState, useEffect, useLayoutEffect, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { InternalButton } from '../button/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { useSplitPanelContext } from '../internal/context/split-panel-context';\nimport useFocusVisible from '../internal/hooks/focus-visible';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\n\nimport { SplitPanelProps, SizeControlProps } from './interfaces';\nimport ResizeHandler from './icons/resize-handler';\nimport PreferencesModal from './preferences-modal';\nimport { usePointerEvents } from './utils/use-pointer-events';\nimport { useKeyboardEvents } from './utils/use-keyboard-events';\n\nimport styles from './styles.css.js';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { AppLayoutContext } from '../internal/context/app-layout-context';\nimport { getLimitedValue } from './utils/size-utils';\nimport { Transition } from '../internal/components/transition';\nimport { ButtonProps } from '../button/interfaces';\nimport { useEffectOnUpdate } from '../internal/hooks/use-effect-on-update';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { SplitPanelContentSide } from './side';\nimport { SplitPanelContentBottom } from './bottom';\n\nexport { SplitPanelProps };\n\nconst MIN_HEIGHT = 160;\nconst MIN_WIDTH = 280;\n\nexport default function SplitPanel({\n header,\n children,\n hidePreferencesButton = false,\n closeBehavior = 'collapse',\n i18nStrings,\n ...restProps\n}: SplitPanelProps) {\n const isRefresh = useVisualRefresh();\n const { __internalRootRef } = useBaseComponent('SplitPanel');\n const {\n size,\n getMaxWidth,\n getMaxHeight,\n position,\n topOffset,\n bottomOffset,\n rightOffset,\n contentWidthStyles,\n isOpen,\n isForcedPosition,\n lastInteraction,\n onPreferencesChange,\n onResize,\n onToggle,\n reportSize,\n setSplitPanelToggle,\n } = useSplitPanelContext();\n const baseProps = getBaseProps(restProps);\n const focusVisible = useFocusVisible();\n const [isPreferencesOpen, setPreferencesOpen] = useState<boolean>(false);\n const [relativeSize, setRelativeSize] = useState(0);\n const [maxSize, setMaxSize] = useState(size);\n const minSize = position === 'bottom' ? MIN_HEIGHT : MIN_WIDTH;\n const cappedSize = getLimitedValue(minSize, size, maxSize);\n const appLayoutMaxWidth = isRefresh && position === 'bottom' ? contentWidthStyles : undefined;\n\n useEffect(() => {\n setSplitPanelToggle({ displayed: closeBehavior === 'collapse', ariaLabel: i18nStrings.openButtonAriaLabel });\n }, [setSplitPanelToggle, i18nStrings.openButtonAriaLabel, closeBehavior]);\n\n useEffect(() => {\n // effects are called inside out in the components tree\n // wait one frame to allow app-layout to complete its calculations\n const handle = requestAnimationFrame(() => {\n const maxSize = position === 'bottom' ? getMaxHeight() : getMaxWidth();\n setRelativeSize((size / maxSize) * 100);\n setMaxSize(maxSize);\n });\n return () => cancelAnimationFrame(handle);\n }, [size, position, getMaxHeight, getMaxWidth]);\n\n useEffect(() => {\n reportSize(cappedSize);\n }, [reportSize, cappedSize]);\n\n useEffect(() => {\n const handler = () => setMaxSize(position === 'bottom' ? getMaxHeight() : getMaxWidth());\n window.addEventListener('resize', handler);\n return () => window.removeEventListener('resize', handler);\n }, [position, getMaxWidth, getMaxHeight]);\n\n const setSidePanelWidth = (width: number) => {\n const maxWidth = getMaxWidth();\n const size = getLimitedValue(MIN_WIDTH, width, maxWidth);\n\n if (isOpen && maxWidth >= MIN_WIDTH) {\n onResize({ size });\n }\n };\n\n const setBottomPanelHeight = (height: number) => {\n const maxHeight = getMaxHeight();\n const size = getLimitedValue(MIN_HEIGHT, height, maxHeight);\n\n if (isOpen && maxHeight >= MIN_HEIGHT) {\n onResize({ size });\n }\n };\n\n const splitPanelRefObject = useRef<HTMLDivElement>(null);\n const handleRef = useRef<HTMLDivElement>(null);\n\n const sizeControlProps: SizeControlProps = {\n position,\n splitPanelRef: splitPanelRefObject,\n handleRef,\n setSidePanelWidth,\n setBottomPanelHeight,\n };\n const onSliderPointerDown = usePointerEvents(sizeControlProps);\n const onKeyDown = useKeyboardEvents(sizeControlProps);\n\n const toggleRef = useRef<ButtonProps.Ref>(null);\n const closeRef = useRef<ButtonProps.Ref>(null);\n const preferencesRef = useRef<ButtonProps.Ref>(null);\n\n useEffectOnUpdate(() => {\n switch (lastInteraction?.type) {\n case 'open':\n return handleRef.current?.focus();\n case 'close':\n return toggleRef.current?.focus();\n case 'position':\n return preferencesRef.current?.focus();\n default:\n return;\n }\n }, [lastInteraction]);\n\n const wrappedChildren = (\n <AppLayoutContext.Provider\n value={{\n stickyOffsetTop: topOffset,\n stickyOffsetBottom: bottomOffset,\n hasBreadcrumbs: false,\n }}\n >\n {children}\n </AppLayoutContext.Provider>\n );\n\n const panelHeaderId = useUniqueId('split-panel-header');\n\n const wrappedHeader = (\n <div className={styles.header} style={appLayoutMaxWidth}>\n <h2 className={styles['header-text']} id={panelHeaderId}>\n {header}\n </h2>\n <div className={styles['header-actions']}>\n {!hidePreferencesButton && isOpen && (\n <>\n <InternalButton\n className={styles['preferences-button']}\n iconName=\"settings\"\n variant=\"icon\"\n onClick={() => setPreferencesOpen(true)}\n formAction=\"none\"\n ariaLabel={i18nStrings.preferencesTitle}\n ref={preferencesRef}\n />\n <span className={styles.divider} />\n </>\n )}\n\n {isOpen ? (\n <InternalButton\n className={styles['close-button']}\n iconName={\n isRefresh && closeBehavior === 'collapse' ? (position === 'side' ? 'angle-right' : 'angle-down') : 'close'\n }\n variant=\"icon\"\n onClick={onToggle}\n formAction=\"none\"\n ariaLabel={i18nStrings.closeButtonAriaLabel}\n ref={closeRef}\n ariaExpanded={isOpen}\n />\n ) : position === 'side' ? null : (\n <InternalButton\n className={styles['open-button']}\n iconName=\"angle-up\"\n variant=\"icon\"\n formAction=\"none\"\n ariaLabel={i18nStrings.openButtonAriaLabel}\n ref={toggleRef}\n ariaExpanded={isOpen}\n />\n )}\n </div>\n </div>\n );\n\n const resizeHandle = (\n <div\n ref={handleRef}\n role=\"slider\"\n tabIndex={0}\n aria-label={i18nStrings.resizeHandleAriaLabel}\n aria-valuemax={100}\n aria-valuemin={0}\n aria-valuenow={relativeSize}\n className={clsx(styles.slider, styles[`slider-${position}`])}\n onKeyDown={onKeyDown}\n onPointerDown={onSliderPointerDown}\n {...focusVisible}\n >\n <ResizeHandler className={clsx(styles['slider-icon'], styles[`slider-icon-${position}`])} />\n </div>\n );\n\n /*\n This effect forces the browser to recalculate the layout\n whenever the split panel might have moved.\n\n This is needed as a workaround for a bug in Safari, which does\n not automatically calculate the new position of the split panel\n _content_ when the split panel moves.\n */\n useLayoutEffect(() => {\n const root = __internalRootRef.current;\n\n if (root) {\n const property = 'transform';\n const temporaryValue = 'translateZ(0)';\n\n const valueBefore = root.style[property];\n root.style[property] = temporaryValue;\n\n // This line forces the browser to recalculate the layout\n void root.offsetHeight;\n\n root.style[property] = valueBefore;\n }\n }, [rightOffset, __internalRootRef]);\n\n const mergedRef = useMergeRefs(splitPanelRefObject, __internalRootRef);\n\n if (closeBehavior === 'hide' && !isOpen) {\n return <></>;\n }\n\n /**\n * The AppLayout factor moved the circular buttons out of the\n * SplitPanel and into the Tools component. This conditional\n * is still needed for the early return to prevent execution\n * of the following code.\n */\n if (isRefresh && !isOpen && position === 'side') {\n return <></>;\n }\n\n return (\n <Transition in={isOpen ?? false}>\n {(state, transitioningElementRef) => (\n <>\n {position === 'side' && (\n <SplitPanelContentSide\n resizeHandle={resizeHandle}\n baseProps={baseProps}\n isOpen={isOpen}\n splitPanelRef={mergedRef}\n cappedSize={cappedSize}\n onToggle={onToggle}\n i18nStrings={i18nStrings}\n toggleRef={toggleRef}\n header={wrappedHeader}\n panelHeaderId={panelHeaderId}\n >\n {wrappedChildren}\n </SplitPanelContentSide>\n )}\n\n {position === 'bottom' && (\n <SplitPanelContentBottom\n resizeHandle={resizeHandle}\n baseProps={baseProps}\n isOpen={isOpen}\n splitPanelRef={mergedRef}\n cappedSize={cappedSize}\n onToggle={onToggle}\n header={wrappedHeader}\n panelHeaderId={panelHeaderId}\n state={state}\n transitioningElementRef={transitioningElementRef}\n appLayoutMaxWidth={appLayoutMaxWidth}\n >\n {wrappedChildren}\n </SplitPanelContentBottom>\n )}\n {isPreferencesOpen && (\n <PreferencesModal\n visible={true}\n preferences={{ position }}\n disabledSidePosition={position === 'bottom' && isForcedPosition}\n isRefresh={isRefresh}\n i18nStrings={{\n header: i18nStrings.preferencesTitle,\n confirm: i18nStrings.preferencesConfirm,\n cancel: i18nStrings.preferencesCancel,\n positionLabel: i18nStrings.preferencesPositionLabel,\n positionDescription: i18nStrings.preferencesPositionDescription,\n positionBottom: i18nStrings.preferencesPositionBottom,\n positionSide: i18nStrings.preferencesPositionSide,\n }}\n onConfirm={preferences => {\n onPreferencesChange({ ...preferences });\n setPreferencesOpen(false);\n }}\n onDismiss={() => {\n setPreferencesOpen(false);\n }}\n />\n )}\n </>\n )}\n </Transition>\n );\n}\n\napplyDisplayName(SplitPanel, 'SplitPanel');\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/split-panel/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,IAAI,MAAM,MAAM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mB,mBAAM,WAAW,EAAG,CAAC;gBACxC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC,EACD,SAAS,EAAE,GAAG,EAAE;gBACd,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC,GACD,CACH,CACA,CACJ,CACU,CACd,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useState, useEffect, useLayoutEffect, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { InternalButton } from '../button/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { useSplitPanelContext } from '../internal/context/split-panel-context';\nimport useFocusVisible from '../internal/hooks/focus-visible';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\n\nimport { SplitPanelProps, SizeControlProps } from './interfaces';\nimport ResizeHandler from './icons/resize-handler';\nimport PreferencesModal from './preferences-modal';\nimport { usePointerEvents } from './utils/use-pointer-events';\nimport { useKeyboardEvents } from './utils/use-keyboard-events';\n\nimport styles from './styles.css.js';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { AppLayoutContext } from '../internal/context/app-layout-context';\nimport { getLimitedValue } from './utils/size-utils';\nimport { Transition } from '../internal/components/transition';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { SplitPanelContentSide } from './side';\nimport { SplitPanelContentBottom } from './bottom';\n\nexport { SplitPanelProps };\n\nconst MIN_HEIGHT = 160;\nconst MIN_WIDTH = 280;\n\nexport default function SplitPanel({\n header,\n children,\n hidePreferencesButton = false,\n closeBehavior = 'collapse',\n i18nStrings,\n ...restProps\n}: SplitPanelProps) {\n const isRefresh = useVisualRefresh();\n const { __internalRootRef } = useBaseComponent('SplitPanel');\n const {\n size,\n getMaxWidth,\n getMaxHeight,\n position,\n topOffset,\n bottomOffset,\n rightOffset,\n contentWidthStyles,\n isOpen,\n isForcedPosition,\n onPreferencesChange,\n onResize,\n onToggle,\n reportSize,\n setSplitPanelToggle,\n refs,\n } = useSplitPanelContext();\n const baseProps = getBaseProps(restProps);\n const focusVisible = useFocusVisible();\n const [isPreferencesOpen, setPreferencesOpen] = useState<boolean>(false);\n const [relativeSize, setRelativeSize] = useState(0);\n const [maxSize, setMaxSize] = useState(size);\n const minSize = position === 'bottom' ? MIN_HEIGHT : MIN_WIDTH;\n const cappedSize = getLimitedValue(minSize, size, maxSize);\n const appLayoutMaxWidth = isRefresh && position === 'bottom' ? contentWidthStyles : undefined;\n\n useEffect(() => {\n setSplitPanelToggle({ displayed: closeBehavior === 'collapse', ariaLabel: i18nStrings.openButtonAriaLabel });\n }, [setSplitPanelToggle, i18nStrings.openButtonAriaLabel, closeBehavior]);\n\n useEffect(() => {\n // effects are called inside out in the components tree\n // wait one frame to allow app-layout to complete its calculations\n const handle = requestAnimationFrame(() => {\n const maxSize = position === 'bottom' ? getMaxHeight() : getMaxWidth();\n setRelativeSize((size / maxSize) * 100);\n setMaxSize(maxSize);\n });\n return () => cancelAnimationFrame(handle);\n }, [size, position, getMaxHeight, getMaxWidth]);\n\n useEffect(() => {\n reportSize(cappedSize);\n }, [reportSize, cappedSize]);\n\n useEffect(() => {\n const handler = () => setMaxSize(position === 'bottom' ? getMaxHeight() : getMaxWidth());\n window.addEventListener('resize', handler);\n return () => window.removeEventListener('resize', handler);\n }, [position, getMaxWidth, getMaxHeight]);\n\n const setSidePanelWidth = (width: number) => {\n const maxWidth = getMaxWidth();\n const size = getLimitedValue(MIN_WIDTH, width, maxWidth);\n\n if (isOpen && maxWidth >= MIN_WIDTH) {\n onResize({ size });\n }\n };\n\n const setBottomPanelHeight = (height: number) => {\n const maxHeight = getMaxHeight();\n const size = getLimitedValue(MIN_HEIGHT, height, maxHeight);\n\n if (isOpen && maxHeight >= MIN_HEIGHT) {\n onResize({ size });\n }\n };\n\n const splitPanelRefObject = useRef<HTMLDivElement>(null);\n\n const sizeControlProps: SizeControlProps = {\n position,\n splitPanelRef: splitPanelRefObject,\n handleRef: refs.slider,\n setSidePanelWidth,\n setBottomPanelHeight,\n };\n const onSliderPointerDown = usePointerEvents(sizeControlProps);\n const onKeyDown = useKeyboardEvents(sizeControlProps);\n\n const wrappedChildren = (\n <AppLayoutContext.Provider\n value={{\n stickyOffsetTop: topOffset,\n stickyOffsetBottom: bottomOffset,\n hasBreadcrumbs: false,\n }}\n >\n {children}\n </AppLayoutContext.Provider>\n );\n\n const panelHeaderId = useUniqueId('split-panel-header');\n\n const wrappedHeader = (\n <div className={styles.header} style={appLayoutMaxWidth}>\n <h2 className={styles['header-text']} id={panelHeaderId}>\n {header}\n </h2>\n <div className={styles['header-actions']}>\n {!hidePreferencesButton && isOpen && (\n <>\n <InternalButton\n className={styles['preferences-button']}\n iconName=\"settings\"\n variant=\"icon\"\n onClick={() => setPreferencesOpen(true)}\n formAction=\"none\"\n ariaLabel={i18nStrings.preferencesTitle}\n ref={refs.preferences}\n />\n <span className={styles.divider} />\n </>\n )}\n\n {isOpen ? (\n <InternalButton\n className={styles['close-button']}\n iconName={\n isRefresh && closeBehavior === 'collapse' ? (position === 'side' ? 'angle-right' : 'angle-down') : 'close'\n }\n variant=\"icon\"\n onClick={onToggle}\n formAction=\"none\"\n ariaLabel={i18nStrings.closeButtonAriaLabel}\n ariaExpanded={isOpen}\n />\n ) : position === 'side' ? null : (\n <InternalButton\n className={styles['open-button']}\n iconName=\"angle-up\"\n variant=\"icon\"\n formAction=\"none\"\n ariaLabel={i18nStrings.openButtonAriaLabel}\n ref={refs.toggle}\n ariaExpanded={isOpen}\n />\n )}\n </div>\n </div>\n );\n\n const resizeHandle = (\n <div\n ref={refs.slider}\n role=\"slider\"\n tabIndex={0}\n aria-label={i18nStrings.resizeHandleAriaLabel}\n aria-valuemax={100}\n aria-valuemin={0}\n aria-valuenow={relativeSize}\n className={clsx(styles.slider, styles[`slider-${position}`])}\n onKeyDown={onKeyDown}\n onPointerDown={onSliderPointerDown}\n {...focusVisible}\n >\n <ResizeHandler className={clsx(styles['slider-icon'], styles[`slider-icon-${position}`])} />\n </div>\n );\n\n /*\n This effect forces the browser to recalculate the layout\n whenever the split panel might have moved.\n\n This is needed as a workaround for a bug in Safari, which does\n not automatically calculate the new position of the split panel\n _content_ when the split panel moves.\n */\n useLayoutEffect(() => {\n const root = __internalRootRef.current;\n\n if (root) {\n const property = 'transform';\n const temporaryValue = 'translateZ(0)';\n\n const valueBefore = root.style[property];\n root.style[property] = temporaryValue;\n\n // This line forces the browser to recalculate the layout\n void root.offsetHeight;\n\n root.style[property] = valueBefore;\n }\n }, [rightOffset, __internalRootRef]);\n\n const mergedRef = useMergeRefs(splitPanelRefObject, __internalRootRef);\n\n if (closeBehavior === 'hide' && !isOpen) {\n return <></>;\n }\n\n /**\n * The AppLayout factor moved the circular buttons out of the\n * SplitPanel and into the Tools component. This conditional\n * is still needed for the early return to prevent execution\n * of the following code.\n */\n if (isRefresh && !isOpen && position === 'side') {\n return <></>;\n }\n\n return (\n <Transition in={isOpen ?? false}>\n {(state, transitioningElementRef) => (\n <>\n {position === 'side' && (\n <SplitPanelContentSide\n resizeHandle={resizeHandle}\n baseProps={baseProps}\n isOpen={isOpen}\n splitPanelRef={mergedRef}\n cappedSize={cappedSize}\n onToggle={onToggle}\n i18nStrings={i18nStrings}\n toggleRef={refs.toggle}\n header={wrappedHeader}\n panelHeaderId={panelHeaderId}\n >\n {wrappedChildren}\n </SplitPanelContentSide>\n )}\n\n {position === 'bottom' && (\n <SplitPanelContentBottom\n resizeHandle={resizeHandle}\n baseProps={baseProps}\n isOpen={isOpen}\n splitPanelRef={mergedRef}\n cappedSize={cappedSize}\n onToggle={onToggle}\n header={wrappedHeader}\n panelHeaderId={panelHeaderId}\n state={state}\n transitioningElementRef={transitioningElementRef}\n appLayoutMaxWidth={appLayoutMaxWidth}\n >\n {wrappedChildren}\n </SplitPanelContentBottom>\n )}\n {isPreferencesOpen && (\n <PreferencesModal\n visible={true}\n preferences={{ position }}\n disabledSidePosition={position === 'bottom' && isForcedPosition}\n isRefresh={isRefresh}\n i18nStrings={{\n header: i18nStrings.preferencesTitle,\n confirm: i18nStrings.preferencesConfirm,\n cancel: i18nStrings.preferencesCancel,\n positionLabel: i18nStrings.preferencesPositionLabel,\n positionDescription: i18nStrings.preferencesPositionDescription,\n positionBottom: i18nStrings.preferencesPositionBottom,\n positionSide: i18nStrings.preferencesPositionSide,\n }}\n onConfirm={preferences => {\n onPreferencesChange({ ...preferences });\n setPreferencesOpen(false);\n }}\n onDismiss={() => {\n setPreferencesOpen(false);\n }}\n />\n )}\n </>\n )}\n </Transition>\n );\n}\n\napplyDisplayName(SplitPanel, 'SplitPanel');\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-stable-scroll-position.d.ts","sourceRoot":"","sources":["../../../../src/table/body-cell/use-stable-scroll-position.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,WAK5C;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,GAAG,WAAW,CAMxE;AAED,MAAM,WAAW,6BAA6B;IAC5C,8EAA8E;IAC9E,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,oGAAoG;IACpG,qBAAqB,EAAE,MAAM,IAAI,CAAC;CACnC;AAMD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,WAAW,EAC3D,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GACnC,6BAA6B,
|
|
1
|
+
{"version":3,"file":"use-stable-scroll-position.d.ts","sourceRoot":"","sources":["../../../../src/table/body-cell/use-stable-scroll-position.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,WAK5C;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,GAAG,WAAW,CAMxE;AAED,MAAM,WAAW,6BAA6B;IAC5C,8EAA8E;IAC9E,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,oGAAoG;IACpG,qBAAqB,EAAE,MAAM,IAAI,CAAC;CACnC;AAMD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,WAAW,EAC3D,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GACnC,6BAA6B,CAgC/B"}
|
|
@@ -24,16 +24,22 @@ const shouldScroll = ([cx, cy], [px, py]) => {
|
|
|
24
24
|
*/
|
|
25
25
|
export function useStableScrollPosition(activeElementRef) {
|
|
26
26
|
const scrollRef = useRef();
|
|
27
|
+
const scrollableParentRef = useRef();
|
|
27
28
|
const storeScrollPosition = useCallback(() => {
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
if (!activeElementRef.current) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const scrollableParent = getScrollableParent(activeElementRef.current);
|
|
30
33
|
if (scrollableParent) {
|
|
34
|
+
scrollableParentRef.current = scrollableParent;
|
|
31
35
|
scrollRef.current = [scrollableParent.scrollLeft, scrollableParent.scrollTop];
|
|
32
36
|
}
|
|
33
37
|
}, [activeElementRef]);
|
|
34
38
|
const restoreScrollPosition = useCallback(() => {
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
if (!activeElementRef.current || !scrollableParentRef.current) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const scrollableParent = scrollableParentRef.current;
|
|
37
43
|
if (scrollRef.current &&
|
|
38
44
|
scrollRef.current.toString() !== '0,0' &&
|
|
39
45
|
shouldScroll(scrollRef.current, [scrollableParent.scrollLeft, scrollableParent.scrollTop])) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-stable-scroll-position.js","sourceRoot":"","sources":["../../../../src/table/body-cell/use-stable-scroll-position.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAc,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEnD,MAAM,UAAU,YAAY,CAAC,GAAgB;IAC3C,MAAM,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC;IAC9D,MAAM,gBAAgB,GAAG,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IAEjE,OAAO,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,IAAI,CAAC,gBAAgB,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,GAAuB;IACzD,OAAO,CAAC,GAAG,IAAI,GAAG,KAAK,QAAQ,CAAC,IAAI;QAClC,CAAC,CAAC,QAAQ,CAAC,IAAI;QACf,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC;YACnB,CAAC,CAAC,GAAG;YACL,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AAC7C,CAAC;AASD,MAAM,YAAY,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAmB,EAAE,CAAC,EAAE,EAAE,EAAE,CAAmB,EAAE,EAAE;IAC9E,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACpC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CACrC,gBAAoC;IAEpC,MAAM,SAAS,GAAG,MAAM,EAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"use-stable-scroll-position.js","sourceRoot":"","sources":["../../../../src/table/body-cell/use-stable-scroll-position.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAc,EAA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AgB,CAAC;YAC/C,SAAS,CAAC,OAAO,GAAG,CAAC,gBAAgB,CAAC,UAAU,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;SAC/E;IACH,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEvB,MAAM,qBAAqB,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7C,IAAI,CAAC,gBAAgB,CAAC,OAAO,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE;YAC7D,OAAO;SACR;QAED,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,OAAO,CAAC;QACrD,IACE,SAAS,CAAC,OAAO;YACjB,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,KAAK;YACtC,YAAY,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,gBAAgB,CAAC,UAAU,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC,EAC1F;YACA,CAAC,gBAAgB,CAAC,UAAU,EAAE,gBAAgB,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;SAC/E;IACH,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEvB,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,CAAC;AACxD,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useCallback, useRef } from 'react';\n\nexport function isScrollable(ele: HTMLElement) {\n const overflowXStyle = window.getComputedStyle(ele).overflowX;\n const isOverflowHidden = overflowXStyle.indexOf('hidden') !== -1;\n\n return ele.scrollWidth > ele.clientWidth && !isOverflowHidden;\n}\n\nexport function getScrollableParent(ele: HTMLElement | null): HTMLElement {\n return !ele || ele === document.body\n ? document.body\n : isScrollable(ele)\n ? ele\n : getScrollableParent(ele.parentElement);\n}\n\nexport interface UseStableScrollPositionResult {\n /** Stores the current scroll position of the nearest scrollable container. */\n storeScrollPosition: () => void;\n /** Restores the scroll position of the nearest scrollable container to the last stored position. */\n restoreScrollPosition: () => void;\n}\n\nconst shouldScroll = ([cx, cy]: [number, number], [px, py]: [number, number]) => {\n return cx - px > 5 || cy - py > 5;\n};\n\n/**\n * This hook stores the scroll position of the nearest scrollable parent of the\n * `activeElementRef` when `storeScrollPosition` is called, and restores it when\n * `restoreScrollPosition` is called.\n * @param activeElementRef Ref to an active element in the table. This is used to find the nearest scrollable parent.\n */\nexport function useStableScrollPosition<T extends HTMLElement>(\n activeElementRef: React.RefObject<T>\n): UseStableScrollPositionResult {\n const scrollRef = useRef<Parameters<HTMLBodyElement['scroll']>>();\n const scrollableParentRef = useRef<HTMLElement>();\n\n const storeScrollPosition = useCallback(() => {\n if (!activeElementRef.current) {\n return;\n }\n\n const scrollableParent = getScrollableParent(activeElementRef.current);\n if (scrollableParent) {\n scrollableParentRef.current = scrollableParent;\n scrollRef.current = [scrollableParent.scrollLeft, scrollableParent.scrollTop];\n }\n }, [activeElementRef]);\n\n const restoreScrollPosition = useCallback(() => {\n if (!activeElementRef.current || !scrollableParentRef.current) {\n return;\n }\n\n const scrollableParent = scrollableParentRef.current;\n if (\n scrollRef.current &&\n scrollRef.current.toString() !== '0,0' &&\n shouldScroll(scrollRef.current, [scrollableParent.scrollLeft, scrollableParent.scrollTop])\n ) {\n [scrollableParent.scrollLeft, scrollableParent.scrollTop] = scrollRef.current;\n }\n }, [activeElementRef]);\n\n return { storeScrollPosition, restoreScrollPosition };\n}\n"]}
|
|
@@ -49,9 +49,8 @@ export function TableHeaderCell({ className, style, tabIndex, column, activeSort
|
|
|
49
49
|
descending: sorted && !!sortingDescending,
|
|
50
50
|
disabled: !!sortingDisabled,
|
|
51
51
|
})
|
|
52
|
-
: undefined }, (
|
|
53
|
-
? {
|
|
54
|
-
: Object.assign(Object.assign({ onKeyPress: handleKeyPress, tabIndex: tabIndex, role: 'button' }, focusVisible), { onClick: handleClick, onFocus: () => onFocusedComponentChange === null || onFocusedComponentChange === void 0 ? void 0 : onFocusedComponentChange({ type: 'column', col: colIndex }), onBlur: () => onFocusedComponentChange === null || onFocusedComponentChange === void 0 ? void 0 : onFocusedComponentChange(null) }))),
|
|
52
|
+
: undefined }, (sortingStatus && !sortingDisabled
|
|
53
|
+
? Object.assign(Object.assign({ onKeyPress: handleKeyPress, tabIndex: tabIndex, role: 'button' }, focusVisible), { onClick: handleClick, onFocus: () => onFocusedComponentChange === null || onFocusedComponentChange === void 0 ? void 0 : onFocusedComponentChange({ type: 'column', col: colIndex }), onBlur: () => onFocusedComponentChange === null || onFocusedComponentChange === void 0 ? void 0 : onFocusedComponentChange(null) }) : {})),
|
|
55
54
|
React.createElement("div", { className: clsx(styles['header-cell-text'], wrapLines && styles['header-cell-text-wrap']), id: headerId },
|
|
56
55
|
column.header,
|
|
57
56
|
isEditable ? (React.createElement("span", { className: styles['edit-icon'], role: "img", "aria-label": (_a = column.editConfig) === null || _a === void 0 ? void 0 : _a.editIconAriaLabel },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/table/header-cell/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAC/C,OAAO,eAAe,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtF,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AA0BjE,MAAM,UAAU,eAAe,CAAW,EACxC,SAAS,EACT,KAAK,EACL,QAAQ,EACR,MAAM,EACN,m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aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,IAAI,MAAK,SAAS;oBACpC,gBAAgB,CAAC,GAAG,KAAK,QAAQ;oBACjC,YAAY,CAAC,0BAA0B,CAAC,EAE1C,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,EACxD,QAAQ,EAAE,cAAc,EACxB,cAAc,EAAE,QAAQ,EACxB,OAAO,EAAE,GAAG,EAAE,CAAC,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CAAG,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,EAC7E,MAAM,EAAE,GAAG,EAAE,CAAC,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CAAG,IAAI,CAAC,EAC9C,QAAQ,EAAE,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,GAC3F,CACD,CACJ,CACE,CACN,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React from 'react';\nimport InternalIcon from '../../icon/internal';\nimport useFocusVisible from '../../internal/hooks/focus-visible';\nimport { KeyCode } from '../../internal/keycode';\nimport { TableProps } from '../interfaces';\nimport { getAriaSort, getSortingIconName, getSortingStatus, isSorted } from './utils';\nimport styles from './styles.css.js';\nimport { Resizer } from '../resizer';\nimport { useUniqueId } from '../../internal/hooks/use-unique-id';\nimport { InteractiveComponent } from '../thead';\n\ninterface TableHeaderCellProps<ItemType> {\n className?: string;\n style?: React.CSSProperties;\n tabIndex: number;\n column: TableProps.ColumnDefinition<ItemType>;\n activeSortingColumn?: TableProps.SortingColumn<ItemType>;\n sortingDescending?: boolean;\n sortingDisabled?: boolean;\n wrapLines?: boolean;\n hidden?: boolean;\n onClick(detail: TableProps.SortingState<any>): void;\n onResizeFinish: () => void;\n colIndex: number;\n updateColumn: (colIndex: number, newWidth: number) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n resizableColumns?: boolean;\n isEditable?: boolean;\n\n focusedComponent?: InteractiveComponent | null;\n onFocusedComponentChange?: (element: InteractiveComponent | null) => void;\n}\n\nexport function TableHeaderCell<ItemType>({\n className,\n style,\n tabIndex,\n column,\n activeSortingColumn,\n sortingDescending,\n sortingDisabled,\n wrapLines,\n focusedComponent,\n onFocusedComponentChange,\n hidden,\n onClick,\n colIndex,\n updateColumn,\n resizableColumns,\n onResizeFinish,\n isEditable,\n}: TableHeaderCellProps<ItemType>) {\n const focusVisible = useFocusVisible();\n const sortable = !!column.sortingComparator || !!column.sortingField;\n const sorted = !!activeSortingColumn && isSorted(column, activeSortingColumn);\n const sortingStatus = getSortingStatus(sortable, sorted, !!sortingDescending, !!sortingDisabled);\n const handleClick = () =>\n onClick({\n sortingColumn: column,\n isDescending: sorted ? !sortingDescending : false,\n });\n\n // Elements with role=\"button\" do not have the default behavior of <button>, where pressing\n // Enter or Space will trigger a click event. Therefore we need to add this ourselves.\n // The native <button> element cannot be used due to a misaligned implementation in Firefox:\n // https://bugzilla.mozilla.org/show_bug.cgi?id=843003\n const handleKeyPress = ({ nativeEvent: e }: React.KeyboardEvent) => {\n if (e.keyCode === KeyCode.enter || e.keyCode === KeyCode.space) {\n e.preventDefault();\n handleClick();\n }\n };\n\n const headerId = useUniqueId('table-header-');\n\n return (\n <th\n className={clsx(className, {\n [styles['header-cell-resizable']]: !!resizableColumns,\n [styles['header-cell-sortable']]: sortingStatus,\n [styles['header-cell-sorted']]: sortingStatus === 'ascending' || sortingStatus === 'descending',\n [styles['header-cell-disabled']]: sortingDisabled,\n [styles['header-cell-ascending']]: sortingStatus === 'ascending',\n [styles['header-cell-descending']]: sortingStatus === 'descending',\n [styles['header-cell-hidden']]: hidden,\n })}\n aria-sort={sortingStatus && getAriaSort(sortingStatus)}\n style={style}\n scope=\"col\"\n >\n <div\n className={clsx(styles['header-cell-content'], {\n [styles['header-cell-fake-focus']]:\n focusedComponent?.type === 'column' &&\n focusedComponent.col === colIndex &&\n focusVisible['data-awsui-focus-visible'],\n })}\n aria-label={\n column.ariaLabel\n ? column.ariaLabel({\n sorted: sorted,\n descending: sorted && !!sortingDescending,\n disabled: !!sortingDisabled,\n })\n : undefined\n }\n {...(sortingStatus && !sortingDisabled\n ? {\n onKeyPress: handleKeyPress,\n tabIndex: tabIndex,\n role: 'button',\n ...focusVisible,\n onClick: handleClick,\n onFocus: () => onFocusedComponentChange?.({ type: 'column', col: colIndex }),\n onBlur: () => onFocusedComponentChange?.(null),\n }\n : {})}\n >\n <div className={clsx(styles['header-cell-text'], wrapLines && styles['header-cell-text-wrap'])} id={headerId}>\n {column.header}\n {isEditable ? (\n <span className={styles['edit-icon']} role=\"img\" aria-label={column.editConfig?.editIconAriaLabel}>\n <InternalIcon name=\"edit\" />\n </span>\n ) : null}\n </div>\n {sortingStatus && (\n <span className={styles['sorting-icon']}>\n <InternalIcon name={getSortingIconName(sortingStatus)} />\n </span>\n )}\n </div>\n {resizableColumns && (\n <>\n <Resizer\n tabIndex={tabIndex}\n showFocusRing={\n focusedComponent?.type === 'resizer' &&\n focusedComponent.col === colIndex &&\n focusVisible['data-awsui-focus-visible']\n }\n onDragMove={newWidth => updateColumn(colIndex, newWidth)}\n onFinish={onResizeFinish}\n ariaLabelledby={headerId}\n onFocus={() => onFocusedComponentChange?.({ type: 'resizer', col: colIndex })}\n onBlur={() => onFocusedComponentChange?.(null)}\n minWidth={typeof column.minWidth === 'string' ? parseInt(column.minWidth) : column.minWidth}\n />\n </>\n )}\n </th>\n );\n}\n"]}
|
|
@@ -11,6 +11,6 @@ import { TableProps } from './interfaces';
|
|
|
11
11
|
*/
|
|
12
12
|
declare function useTableFocusNavigation<T extends {
|
|
13
13
|
editConfig?: TableProps.EditConfig<any>;
|
|
14
|
-
}>(selectionType:
|
|
14
|
+
}>(selectionType: TableProps['selectionType'], tableRoot: RefObject<HTMLTableElement>, columnDefinitions: Readonly<T[]>, numRows: number): void;
|
|
15
15
|
export default useTableFocusNavigation;
|
|
16
16
|
//# sourceMappingURL=use-table-focus-navigation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-table-focus-navigation.d.ts","sourceRoot":"","sources":["../../../src/table/use-table-focus-navigation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAA2C,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAa1C;;;;;;;;GAQG;AACH,iBAAS,uBAAuB,CAAC,CAAC,SAAS;IAAE,UAAU,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;CAAE,EACpF,aAAa,
|
|
1
|
+
{"version":3,"file":"use-table-focus-navigation.d.ts","sourceRoot":"","sources":["../../../src/table/use-table-focus-navigation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAA2C,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAa1C;;;;;;;;GAQG;AACH,iBAAS,uBAAuB,CAAC,CAAC,SAAS;IAAE,UAAU,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;CAAE,EACpF,aAAa,EAAE,UAAU,CAAC,eAAe,CAAC,EAC1C,SAAS,EAAE,SAAS,CAAC,gBAAgB,CAAC,EACtC,iBAAiB,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAChC,OAAO,EAAE,MAAM,QAqIhB;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -17,17 +17,17 @@ function iterateTableCells(table, func) {
|
|
|
17
17
|
* @param columnDefinitions - The column definitions for the table.
|
|
18
18
|
* @param numRows - The number of rows in the table.
|
|
19
19
|
*/
|
|
20
|
-
function useTableFocusNavigation(selectionType
|
|
20
|
+
function useTableFocusNavigation(selectionType, tableRoot, columnDefinitions, numRows) {
|
|
21
21
|
const currentFocusCell = useRef(null);
|
|
22
22
|
const focusableColumns = useMemo(() => {
|
|
23
23
|
const cols = columnDefinitions.map(column => !!column.editConfig);
|
|
24
|
-
if (selectionType
|
|
24
|
+
if (selectionType) {
|
|
25
25
|
cols.unshift(false);
|
|
26
26
|
}
|
|
27
27
|
return cols;
|
|
28
28
|
}, [columnDefinitions, selectionType]);
|
|
29
|
-
const maxColumnIndex =
|
|
30
|
-
const minColumnIndex =
|
|
29
|
+
const maxColumnIndex = focusableColumns.length - 1;
|
|
30
|
+
const minColumnIndex = selectionType ? 1 : 0;
|
|
31
31
|
const focusCell = useCallback((rowIndex, columnIndex) => {
|
|
32
32
|
if (tableRoot === null || tableRoot === void 0 ? void 0 : tableRoot.current) {
|
|
33
33
|
iterateTableCells(tableRoot.current, (cell, rIndex, cIndex) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-table-focus-navigation.js","sourceRoot":"","sources":["../../../src/table/use-table-focus-navigation.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAa,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG3E,SAAS,iBAAiB,CACxB,KAAQ,EACR,IAAiF;IAEjF,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAwB,EAAE,QAAgB,EAAE,EAAE;QAClF,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;YACrD,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,uBAAuB,CAC9B,gBAA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AC,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;iBACxD;YACH,CAAC,CAAC,CAAC;YACH,YAAY,CAAC,mBAAmB,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QACpE,CAAC;QAED,iBAAiB,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE;YAC5D,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE;gBAChC,OAAO;aACR;YACD,MAAM,WAAW,GAAG;gBAClB,OAAO,EAAE,GAAG,EAAE;oBACZ,gBAAgB,CAAC,OAAO,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;gBACnD,CAAC;aACF,CAAC;YACF,cAAc,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,WAAW,CAAC,CAAC;YACvD,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3E,CAAC,CAAC,CAAC;QACH,YAAY,CAAC,gBAAgB,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAE/D,OAAO,GAAG,EAAE,CAAC,YAAY,IAAI,gBAAgB,EAAE,CAAC;IAClD,CAAC,EAAE,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,SAAS,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED,eAAe,uBAAuB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { RefObject, useCallback, useEffect, useMemo, useRef } from 'react';\nimport { TableProps } from './interfaces';\n\nfunction iterateTableCells<T extends HTMLElement>(\n table: T,\n func: (cell: HTMLTableCellElement, rowIndex: number, columnIndex: number) => void\n) {\n table.querySelectorAll('tr').forEach((row: HTMLTableRowElement, rowIndex: number) => {\n row.querySelectorAll('td').forEach((cell, cellIndex) => {\n func(cell, rowIndex, cellIndex);\n });\n });\n}\n\n/**\n * This hook is used to navigate between table cells using the keyboard arrow keys.\n * All the functionality is implemented in the hook, so the table component does not\n * need to implement any keyboard event handlers.\n * @param enable - Toggle functionality of the hook\n * @param tableRoot - A ref to a table container. Ideally the root element of the table (<table>); tbody is also acceptable.\n * @param columnDefinitions - The column definitions for the table.\n * @param numRows - The number of rows in the table.\n */\nfunction useTableFocusNavigation<T extends { editConfig?: TableProps.EditConfig<any> }>(\n selectionType: 'single' | 'multi' | 'none' = 'none',\n tableRoot: RefObject<HTMLTableElement>,\n columnDefinitions: Readonly<T[]>,\n numRows: number\n) {\n const currentFocusCell = useRef<[number, number] | null>(null);\n\n const focusableColumns = useMemo(() => {\n const cols = columnDefinitions.map(column => !!column.editConfig);\n if (selectionType !== 'none') {\n cols.unshift(false);\n }\n return cols;\n }, [columnDefinitions, selectionType]);\n\n const maxColumnIndex = useMemo(() => focusableColumns.length - 1, [focusableColumns]);\n const minColumnIndex = useMemo(() => (selectionType !== 'none' ? 1 : 0), [selectionType]);\n\n const focusCell = useCallback(\n (rowIndex: number, columnIndex: number) => {\n if (tableRoot?.current) {\n iterateTableCells(tableRoot.current, (cell, rIndex, cIndex) => {\n if (rIndex === rowIndex && cIndex === columnIndex) {\n const editButton = cell.querySelector('button:last-child') as HTMLButtonElement | null;\n editButton?.focus?.({ preventScroll: true });\n }\n });\n }\n },\n [tableRoot]\n );\n\n const shiftFocus = useCallback(\n (vertical: -1 | 0 | 1, horizontal: -1 | 0 | 1) => {\n // istanbul ignore if next\n if (!currentFocusCell.current) {\n return;\n }\n const [rowIndex, columnIndex] = currentFocusCell.current.slice();\n let newRowIndex = rowIndex;\n let newColumnIndex = columnIndex;\n\n if (vertical !== 0) {\n newRowIndex = Math.min(numRows, Math.max(rowIndex + vertical, 0));\n }\n\n if (horizontal !== 0) {\n while (newColumnIndex <= maxColumnIndex && newColumnIndex >= minColumnIndex) {\n newColumnIndex += horizontal;\n if (focusableColumns[newColumnIndex]) {\n break;\n }\n }\n }\n\n if (\n (rowIndex !== newRowIndex || columnIndex !== newColumnIndex) &&\n currentFocusCell.current &&\n tableRoot.current\n ) {\n focusCell(newRowIndex, newColumnIndex);\n }\n },\n [focusCell, focusableColumns, maxColumnIndex, minColumnIndex, numRows, tableRoot]\n );\n\n const handleArrowKeyEvents = useCallback(\n (event: KeyboardEvent) => {\n const abort =\n !!tableRoot.current?.querySelector('[data-inline-editing-active = \"true\"]') ||\n !document.activeElement?.closest('[data-inline-editing-active]');\n\n if (abort) {\n return;\n }\n switch (event.key) {\n case 'ArrowUp':\n event.preventDefault();\n shiftFocus(-1, 0);\n break;\n case 'ArrowDown':\n event.preventDefault();\n shiftFocus(1, 0);\n break;\n case 'ArrowLeft':\n event.preventDefault();\n shiftFocus(0, -1);\n break;\n case 'ArrowRight':\n event.preventDefault();\n shiftFocus(0, 1);\n break;\n // istanbul ignore next (default case = do nothing, not testable)\n default:\n return;\n }\n },\n [shiftFocus, tableRoot]\n );\n\n useEffect(() => {\n const eventListeners = new Map<[number, number], { focusin(evt: any): void }>();\n // istanbul ignore if\n if (!tableRoot.current) {\n return;\n }\n\n const tableElement = tableRoot.current;\n\n // istanbul ignore next (tested in use-focus-navigation.test.tsx#L210)\n function cleanUpListeners() {\n iterateTableCells(tableElement, (cell, rowIndex, columnIndex) => {\n const listeners = eventListeners.get([rowIndex, columnIndex]);\n if (listeners?.focusin) {\n cell.removeEventListener('focusin', listeners.focusin);\n }\n });\n tableElement.removeEventListener('keydown', handleArrowKeyEvents);\n }\n\n iterateTableCells(tableElement, (cell, rowIndex, cellIndex) => {\n if (!focusableColumns[cellIndex]) {\n return;\n }\n const listenerFns = {\n focusin: () => {\n currentFocusCell.current = [rowIndex, cellIndex];\n },\n };\n eventListeners.set([rowIndex, cellIndex], listenerFns);\n cell.addEventListener('focusin', listenerFns.focusin, { passive: true });\n });\n tableElement.addEventListener('keydown', handleArrowKeyEvents);\n\n return () => tableElement && cleanUpListeners();\n }, [focusableColumns, handleArrowKeyEvents, tableRoot]);\n}\n\nexport default useTableFocusNavigation;\n"]}
|
|
1
|
+
{"version":3,"file":"use-table-focus-navigation.js","sourceRoot":"","sources":["../../../src/table/use-table-focus-navigation.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAa,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG3E,SAAS,iBAAiB,CACxB,KAAQ,EACR,IAAiF;IAEjF,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAwB,EAAE,QAAgB,EAAE,EAAE;QAClF,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;YACrD,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,uBAAuB,CAC9B,aAA0C,EAC1C,SAAsC,EACtC,iBAAgC,EAChC,OAAe;IAEf,MAAM,gBAAgB,GAAG,MAAM,CAA0B,IAAI,CAAC,CAAC;IAE/D,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,EAAE;QACpC,MAAM,IAAI,GAAG,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAClE,IAAI,aAAa,EAAE;YACjB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SACrB;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC,CAAC;IAEvC,MAAM,cAAc,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;IACnD,MAAM,cAAc,GAAG,aAAa,CAAC,CAAC,CAAC,CAA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,oBAAoB,CAAC,CAAC;QAE/D,OAAO,GAAG,EAAE,CAAC,YAAY,IAAI,gBAAgB,EAAE,CAAC;IAClD,CAAC,EAAE,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,SAAS,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED,eAAe,uBAAuB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { RefObject, useCallback, useEffect, useMemo, useRef } from 'react';\nimport { TableProps } from './interfaces';\n\nfunction iterateTableCells<T extends HTMLElement>(\n table: T,\n func: (cell: HTMLTableCellElement, rowIndex: number, columnIndex: number) => void\n) {\n table.querySelectorAll('tr').forEach((row: HTMLTableRowElement, rowIndex: number) => {\n row.querySelectorAll('td').forEach((cell, cellIndex) => {\n func(cell, rowIndex, cellIndex);\n });\n });\n}\n\n/**\n * This hook is used to navigate between table cells using the keyboard arrow keys.\n * All the functionality is implemented in the hook, so the table component does not\n * need to implement any keyboard event handlers.\n * @param enable - Toggle functionality of the hook\n * @param tableRoot - A ref to a table container. Ideally the root element of the table (<table>); tbody is also acceptable.\n * @param columnDefinitions - The column definitions for the table.\n * @param numRows - The number of rows in the table.\n */\nfunction useTableFocusNavigation<T extends { editConfig?: TableProps.EditConfig<any> }>(\n selectionType: TableProps['selectionType'],\n tableRoot: RefObject<HTMLTableElement>,\n columnDefinitions: Readonly<T[]>,\n numRows: number\n) {\n const currentFocusCell = useRef<[number, number] | null>(null);\n\n const focusableColumns = useMemo(() => {\n const cols = columnDefinitions.map(column => !!column.editConfig);\n if (selectionType) {\n cols.unshift(false);\n }\n return cols;\n }, [columnDefinitions, selectionType]);\n\n const maxColumnIndex = focusableColumns.length - 1;\n const minColumnIndex = selectionType ? 1 : 0;\n\n const focusCell = useCallback(\n (rowIndex: number, columnIndex: number) => {\n if (tableRoot?.current) {\n iterateTableCells(tableRoot.current, (cell, rIndex, cIndex) => {\n if (rIndex === rowIndex && cIndex === columnIndex) {\n const editButton = cell.querySelector('button:last-child') as HTMLButtonElement | null;\n editButton?.focus?.({ preventScroll: true });\n }\n });\n }\n },\n [tableRoot]\n );\n\n const shiftFocus = useCallback(\n (vertical: -1 | 0 | 1, horizontal: -1 | 0 | 1) => {\n // istanbul ignore if next\n if (!currentFocusCell.current) {\n return;\n }\n const [rowIndex, columnIndex] = currentFocusCell.current.slice();\n let newRowIndex = rowIndex;\n let newColumnIndex = columnIndex;\n\n if (vertical !== 0) {\n newRowIndex = Math.min(numRows, Math.max(rowIndex + vertical, 0));\n }\n\n if (horizontal !== 0) {\n while (newColumnIndex <= maxColumnIndex && newColumnIndex >= minColumnIndex) {\n newColumnIndex += horizontal;\n if (focusableColumns[newColumnIndex]) {\n break;\n }\n }\n }\n\n if (\n (rowIndex !== newRowIndex || columnIndex !== newColumnIndex) &&\n currentFocusCell.current &&\n tableRoot.current\n ) {\n focusCell(newRowIndex, newColumnIndex);\n }\n },\n [focusCell, focusableColumns, maxColumnIndex, minColumnIndex, numRows, tableRoot]\n );\n\n const handleArrowKeyEvents = useCallback(\n (event: KeyboardEvent) => {\n const abort =\n !!tableRoot.current?.querySelector('[data-inline-editing-active = \"true\"]') ||\n !document.activeElement?.closest('[data-inline-editing-active]');\n\n if (abort) {\n return;\n }\n switch (event.key) {\n case 'ArrowUp':\n event.preventDefault();\n shiftFocus(-1, 0);\n break;\n case 'ArrowDown':\n event.preventDefault();\n shiftFocus(1, 0);\n break;\n case 'ArrowLeft':\n event.preventDefault();\n shiftFocus(0, -1);\n break;\n case 'ArrowRight':\n event.preventDefault();\n shiftFocus(0, 1);\n break;\n // istanbul ignore next (default case = do nothing, not testable)\n default:\n return;\n }\n },\n [shiftFocus, tableRoot]\n );\n\n useEffect(() => {\n const eventListeners = new Map<[number, number], { focusin(evt: any): void }>();\n // istanbul ignore if\n if (!tableRoot.current) {\n return;\n }\n\n const tableElement = tableRoot.current;\n\n // istanbul ignore next (tested in use-focus-navigation.test.tsx#L210)\n function cleanUpListeners() {\n iterateTableCells(tableElement, (cell, rowIndex, columnIndex) => {\n const listeners = eventListeners.get([rowIndex, columnIndex]);\n if (listeners?.focusin) {\n cell.removeEventListener('focusin', listeners.focusin);\n }\n });\n tableElement.removeEventListener('keydown', handleArrowKeyEvents);\n }\n\n iterateTableCells(tableElement, (cell, rowIndex, cellIndex) => {\n if (!focusableColumns[cellIndex]) {\n return;\n }\n const listenerFns = {\n focusin: () => {\n currentFocusCell.current = [rowIndex, cellIndex];\n },\n };\n eventListeners.set([rowIndex, cellIndex], listenerFns);\n cell.addEventListener('focusin', listenerFns.focusin, { passive: true });\n });\n tableElement.addEventListener('keydown', handleArrowKeyEvents);\n\n return () => tableElement && cleanUpListeners();\n }, [focusableColumns, handleArrowKeyEvents, tableRoot]);\n}\n\nexport default useTableFocusNavigation;\n"]}
|
|
@@ -5,7 +5,6 @@ export interface TutorialListProps {
|
|
|
5
5
|
loading?: boolean;
|
|
6
6
|
tutorials: TutorialPanelProps['tutorials'];
|
|
7
7
|
onStartTutorial: HotspotContext['onStartTutorial'];
|
|
8
|
-
filteringFunction: (tutorial: TutorialPanelProps.Tutorial, searchTerm: string) => boolean;
|
|
9
8
|
i18nStrings: TutorialPanelProps['i18nStrings'];
|
|
10
9
|
downloadUrl: TutorialPanelProps['downloadUrl'];
|
|
11
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/tutorial-panel/components/tutorial-list/index.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAWtD,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAOxE,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAC3C,eAAe,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAC;IACnD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/tutorial-panel/components/tutorial-list/index.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAWtD,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAOxE,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAC3C,eAAe,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAC;IACnD,WAAW,EAAE,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAC/C,WAAW,EAAE,kBAAkB,CAAC,aAAa,CAAC,CAAC;CAChD;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,WAAW,EACX,SAAS,EACT,OAAe,EACf,eAAe,EACf,WAAW,GACZ,EAAE,iBAAiB,eAgDnB"}
|
|
@@ -19,17 +19,6 @@ import { checkSafeUrl } from '../../../internal/utils/check-safe-url';
|
|
|
19
19
|
import LiveRegion from '../../../internal/components/live-region/index.js';
|
|
20
20
|
export default function TutorialList({ i18nStrings, tutorials, loading = false, onStartTutorial, downloadUrl, }) {
|
|
21
21
|
checkSafeUrl('TutorialPanel', downloadUrl);
|
|
22
|
-
/*
|
|
23
|
-
// Filtering is not available in the Beta release.
|
|
24
|
-
|
|
25
|
-
const [searchTerm, setSearchTerm] = useState('');
|
|
26
|
-
|
|
27
|
-
const onSearchChangeCallback: InputProps['onChange'] = useCallback(event => setSearchTerm(event.detail.value), [
|
|
28
|
-
setSearchTerm
|
|
29
|
-
]);
|
|
30
|
-
|
|
31
|
-
const filteredTutorials = tutorials.filter(tutorial => filteringFunction(tutorial, searchTerm))
|
|
32
|
-
*/
|
|
33
22
|
const focusVisible = useFocusVisible();
|
|
34
23
|
const isRefresh = useVisualRefresh();
|
|
35
24
|
return (React.createElement(React.Fragment, null,
|
|
@@ -38,12 +27,11 @@ export default function TutorialList({ i18nStrings, tutorials, loading = false,
|
|
|
38
27
|
React.createElement(InternalBox, { variant: "h2", fontSize: isRefresh ? 'heading-m' : 'heading-l', padding: { bottom: 'n' } }, i18nStrings.tutorialListTitle),
|
|
39
28
|
React.createElement(InternalBox, { variant: "p", color: "text-body-secondary", padding: "n" }, i18nStrings.tutorialListDescription)),
|
|
40
29
|
React.createElement(InternalSpaceBetween, { size: "l" },
|
|
41
|
-
React.createElement("a", Object.assign({}, focusVisible, { href: downloadUrl, target: "_blank", rel: "noopener noreferrer", className: styles['download-link'], "aria-label": i18nStrings.labelTutorialListDownloadLink }),
|
|
30
|
+
downloadUrl && (React.createElement("a", Object.assign({}, focusVisible, { href: downloadUrl, target: "_blank", rel: "noopener noreferrer", className: styles['download-link'], "aria-label": i18nStrings.labelTutorialListDownloadLink }),
|
|
42
31
|
React.createElement(InternalIcon, { name: "download" }),
|
|
43
|
-
React.createElement(InternalBox, { padding: { left: 'xs' }, color: "inherit", fontWeight: "bold", display: "inline" }, i18nStrings.tutorialListDownloadLinkText)),
|
|
32
|
+
React.createElement(InternalBox, { padding: { left: 'xs' }, color: "inherit", fontWeight: "bold", display: "inline" }, i18nStrings.tutorialListDownloadLinkText))),
|
|
44
33
|
loading ? (React.createElement(InternalStatusIndicator, { type: "loading" },
|
|
45
|
-
React.createElement(LiveRegion, { visible: true }, i18nStrings.loadingText))) : (React.createElement(React.
|
|
46
|
-
React.createElement("ul", { className: styles['tutorial-list'], role: "list" }, tutorials.map((tutorial, index) => (React.createElement(Tutorial, { tutorial: tutorial, key: index, onStartTutorial: onStartTutorial, i18nStrings: i18nStrings }))))))))));
|
|
34
|
+
React.createElement(LiveRegion, { visible: true }, i18nStrings.loadingText))) : (React.createElement("ul", { className: styles['tutorial-list'], role: "list" }, tutorials.map((tutorial, index) => (React.createElement(Tutorial, { tutorial: tutorial, key: index, onStartTutorial: onStartTutorial, i18nStrings: i18nStrings })))))))));
|
|
47
35
|
}
|
|
48
36
|
function Tutorial({ tutorial, onStartTutorial: onStartTutorialEventHandler, i18nStrings, }) {
|
|
49
37
|
var _a;
|