@cloudscape-design/components 3.0.1411 → 3.0.1413
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/internal.d.ts +10 -2
- package/action-card/internal.d.ts.map +1 -1
- package/action-card/internal.js +5 -5
- package/action-card/internal.js.map +1 -1
- package/action-card/styles.css.js +18 -17
- package/action-card/styles.scoped.css +274 -202
- package/action-card/styles.selectors.js +18 -17
- package/app-layout/visual-refresh-toolbar/skeleton/toolbar-container.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/skeleton/toolbar-container.js +3 -1
- package/app-layout/visual-refresh-toolbar/skeleton/toolbar-container.js.map +1 -1
- package/button-dropdown/filter.d.ts +1 -1
- package/expandable-section/expandable-section-header.js +1 -1
- package/expandable-section/expandable-section-header.js.map +1 -1
- package/header/interfaces.d.ts +4 -0
- package/header/interfaces.d.ts.map +1 -1
- package/header/interfaces.js.map +1 -1
- package/header/internal.d.ts +1 -6
- package/header/internal.d.ts.map +1 -1
- package/header/internal.js +2 -2
- package/header/internal.js.map +1 -1
- package/header/styles.css.js +36 -36
- package/header/styles.scoped.css +55 -55
- package/header/styles.selectors.js +36 -36
- package/i18n/messages/all.all.js +1 -1
- package/i18n/messages/all.all.json +1 -1
- package/i18n/messages/all.de.js +1 -1
- package/i18n/messages/all.de.json +1 -1
- package/i18n/messages/all.en-GB.js +1 -1
- package/i18n/messages/all.en-GB.json +1 -1
- package/i18n/messages/all.en.js +1 -1
- package/i18n/messages/all.en.json +1 -1
- package/i18n/messages/all.es.js +1 -1
- package/i18n/messages/all.es.json +1 -1
- package/i18n/messages/all.fr.js +1 -1
- package/i18n/messages/all.fr.json +1 -1
- package/i18n/messages/all.id.js +1 -1
- package/i18n/messages/all.id.json +1 -1
- package/i18n/messages/all.it.js +1 -1
- package/i18n/messages/all.it.json +1 -1
- package/i18n/messages/all.ja.js +1 -1
- package/i18n/messages/all.ja.json +1 -1
- package/i18n/messages/all.ko.js +1 -1
- package/i18n/messages/all.ko.json +1 -1
- package/i18n/messages/all.pt-BR.js +1 -1
- package/i18n/messages/all.pt-BR.json +1 -1
- package/i18n/messages/all.tr.js +1 -1
- package/i18n/messages/all.tr.json +1 -1
- package/i18n/messages/all.zh-CN.js +1 -1
- package/i18n/messages/all.zh-CN.json +1 -1
- package/i18n/messages/all.zh-TW.js +1 -1
- package/i18n/messages/all.zh-TW.json +1 -1
- package/i18n/messages-types.d.ts +3 -0
- package/i18n/messages-types.d.ts.map +1 -1
- package/i18n/messages-types.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/internal/base-component/styles.scoped.css +1 -1
- package/internal/components/focus-lock/utils.d.ts +2 -0
- package/internal/components/focus-lock/utils.d.ts.map +1 -1
- package/internal/components/focus-lock/utils.js +5 -1
- package/internal/components/focus-lock/utils.js.map +1 -1
- package/internal/components/listbox/interfaces.d.ts +12 -0
- package/internal/components/listbox/interfaces.d.ts.map +1 -0
- package/internal/components/listbox/interfaces.js +2 -0
- package/internal/components/listbox/interfaces.js.map +1 -0
- package/internal/components/listbox/parts/get-item-props.d.ts +1 -3
- package/internal/components/listbox/parts/get-item-props.d.ts.map +1 -1
- package/internal/components/listbox/parts/get-item-props.js +1 -2
- package/internal/components/listbox/parts/get-item-props.js.map +1 -1
- package/internal/components/listbox/parts/item.d.ts +45 -0
- package/internal/components/listbox/parts/item.d.ts.map +1 -0
- package/internal/components/listbox/parts/item.js +184 -0
- package/internal/components/listbox/parts/item.js.map +1 -0
- package/internal/components/listbox/parts/plain-list.d.ts +29 -0
- package/internal/components/listbox/parts/plain-list.d.ts.map +1 -0
- package/{select → internal/components/listbox}/parts/plain-list.js +12 -12
- package/internal/components/listbox/parts/plain-list.js.map +1 -0
- package/internal/components/listbox/parts/render-options.d.ts +3 -4
- package/internal/components/listbox/parts/render-options.d.ts.map +1 -1
- package/internal/components/listbox/parts/render-options.js +3 -6
- package/internal/components/listbox/parts/render-options.js.map +1 -1
- package/internal/components/listbox/parts/scroll-to-index.d.ts +11 -0
- package/internal/components/listbox/parts/scroll-to-index.d.ts.map +1 -1
- package/internal/components/listbox/parts/scroll-to-index.js +16 -0
- package/internal/components/listbox/parts/scroll-to-index.js.map +1 -1
- package/internal/components/listbox/use-listbox.d.ts +95 -0
- package/internal/components/listbox/use-listbox.d.ts.map +1 -0
- package/internal/components/listbox/use-listbox.js +117 -0
- package/internal/components/listbox/use-listbox.js.map +1 -0
- package/internal/components/listbox/use-type-ahead.d.ts +18 -0
- package/internal/components/listbox/use-type-ahead.d.ts.map +1 -0
- package/{select/utils/use-native-search.js → internal/components/listbox/use-type-ahead.js} +8 -8
- package/internal/components/listbox/use-type-ahead.js.map +1 -0
- package/internal/components/listbox/utils/navigation.d.ts +27 -0
- package/internal/components/listbox/utils/navigation.d.ts.map +1 -0
- package/internal/components/listbox/utils/navigation.js +22 -0
- package/internal/components/listbox/utils/navigation.js.map +1 -0
- package/internal/components/listbox/utils/option-props.d.ts +35 -0
- package/internal/components/listbox/utils/option-props.d.ts.map +1 -0
- package/internal/components/listbox/utils/option-props.js +51 -0
- package/internal/components/listbox/utils/option-props.js.map +1 -0
- package/internal/components/options-list/index.d.ts +4 -1
- package/internal/components/options-list/index.d.ts.map +1 -1
- package/internal/components/options-list/index.js +1 -1
- package/internal/components/options-list/index.js.map +1 -1
- package/internal/components/options-list/utils/use-keyboard.d.ts +2 -1
- package/internal/components/options-list/utils/use-keyboard.d.ts.map +1 -1
- package/internal/components/options-list/utils/use-keyboard.js +5 -3
- package/internal/components/options-list/utils/use-keyboard.js.map +1 -1
- package/internal/components/selectable-item/index.d.ts +1 -0
- package/internal/components/selectable-item/index.d.ts.map +1 -1
- package/internal/components/selectable-item/index.js +2 -1
- package/internal/components/selectable-item/index.js.map +1 -1
- package/internal/components/selectable-item/interfaces.d.ts +1 -0
- package/internal/components/selectable-item/interfaces.d.ts.map +1 -1
- package/internal/components/selectable-item/interfaces.js.map +1 -1
- package/internal/components/selectable-item/styles.css.js +23 -22
- package/internal/components/selectable-item/styles.scoped.css +52 -49
- package/internal/components/selectable-item/styles.selectors.js +23 -22
- package/internal/components/sticky-header/use-untabbable-descendants.d.ts +2 -0
- package/internal/components/sticky-header/use-untabbable-descendants.d.ts.map +1 -0
- package/internal/components/sticky-header/use-untabbable-descendants.js +16 -0
- package/internal/components/sticky-header/use-untabbable-descendants.js.map +1 -0
- package/internal/environment.js +2 -2
- package/internal/environment.json +2 -2
- package/internal/manifest.json +1 -1
- package/item-card/internal.d.ts +11 -1
- package/item-card/internal.d.ts.map +1 -1
- package/item-card/internal.js +4 -4
- package/item-card/internal.js.map +1 -1
- package/item-card/style.d.ts.map +1 -1
- package/item-card/style.js +6 -1
- package/item-card/style.js.map +1 -1
- package/item-card/styles.css.js +14 -14
- package/item-card/styles.scoped.css +125 -63
- package/item-card/styles.selectors.js +14 -14
- package/manifest.json +2 -2
- package/multiselect/embedded.d.ts.map +1 -1
- package/multiselect/embedded.js +2 -2
- package/multiselect/embedded.js.map +1 -1
- package/multiselect/internal.d.ts.map +1 -1
- package/multiselect/internal.js +2 -2
- package/multiselect/internal.js.map +1 -1
- package/multiselect/use-multiselect.d.ts +3 -4
- package/multiselect/use-multiselect.d.ts.map +1 -1
- package/multiselect/use-multiselect.js +7 -18
- package/multiselect/use-multiselect.js.map +1 -1
- package/option-list/index.d.ts +5 -0
- package/option-list/index.d.ts.map +1 -0
- package/option-list/index.js +21 -0
- package/option-list/index.js.map +1 -0
- package/option-list/interfaces.d.ts +131 -0
- package/option-list/interfaces.d.ts.map +1 -0
- package/option-list/interfaces.js +2 -0
- package/option-list/interfaces.js.map +1 -0
- package/option-list/internal.d.ts +5 -0
- package/option-list/internal.d.ts.map +1 -0
- package/option-list/internal.js +138 -0
- package/option-list/internal.js.map +1 -0
- package/option-list/styles.css.js +6 -0
- package/option-list/styles.scoped.css +40 -0
- package/option-list/styles.selectors.js +7 -0
- package/option-list/test-classes/styles.css.js +8 -0
- package/option-list/test-classes/styles.scoped.css +9 -0
- package/option-list/test-classes/styles.selectors.js +9 -0
- package/option-list/use-option-list.d.ts +36 -0
- package/option-list/use-option-list.d.ts.map +1 -0
- package/option-list/use-option-list.js +69 -0
- package/option-list/use-option-list.js.map +1 -0
- package/package.json +4 -1
- package/select/internal.d.ts.map +1 -1
- package/select/internal.js +9 -19
- package/select/internal.js.map +1 -1
- package/select/parts/filter.d.ts +1 -1
- package/select/parts/virtual-list.d.ts +3 -2
- package/select/parts/virtual-list.d.ts.map +1 -1
- package/select/parts/virtual-list.js +7 -8
- package/select/parts/virtual-list.js.map +1 -1
- package/select/utils/use-select.d.ts +18 -11
- package/select/utils/use-select.d.ts.map +1 -1
- package/select/utils/use-select.js +41 -117
- package/select/utils/use-select.js.map +1 -1
- package/styling/action-card.scss +56 -0
- package/styling/item-card.scss +81 -0
- package/table-root/index.js +1 -1
- package/table-root/index.js.map +1 -1
- package/table-root/interfaces.d.ts +15 -1
- package/table-root/interfaces.d.ts.map +1 -1
- package/table-root/interfaces.js.map +1 -1
- package/table-root/internal.d.ts +2 -0
- package/table-root/internal.d.ts.map +1 -1
- package/table-root/internal.js +23 -11
- package/table-root/internal.js.map +1 -1
- package/table-root/sticky-header-slot.d.ts +24 -0
- package/table-root/sticky-header-slot.d.ts.map +1 -0
- package/table-root/sticky-header-slot.js +13 -0
- package/table-root/sticky-header-slot.js.map +1 -0
- package/table-root/styles.css.js +10 -5
- package/table-root/styles.scoped.css +52 -7
- package/table-root/styles.selectors.js +10 -5
- package/table-root/use-sticky-header.d.ts +33 -0
- package/table-root/use-sticky-header.d.ts.map +1 -0
- package/table-root/use-sticky-header.js +141 -0
- package/table-root/use-sticky-header.js.map +1 -0
- package/test-utils/dom/header/index.d.ts +1 -0
- package/test-utils/dom/header/index.js +3 -0
- package/test-utils/dom/header/index.js.map +1 -1
- package/test-utils/dom/index.d.ts +28 -0
- package/test-utils/dom/index.js +21 -2
- package/test-utils/dom/index.js.map +1 -1
- package/test-utils/dom/option-list/index.d.ts +69 -0
- package/test-utils/dom/option-list/index.js +132 -0
- package/test-utils/dom/option-list/index.js.map +1 -0
- package/test-utils/selectors/header/index.d.ts +1 -0
- package/test-utils/selectors/header/index.js +3 -0
- package/test-utils/selectors/header/index.js.map +1 -1
- package/test-utils/selectors/index.d.ts +18 -0
- package/test-utils/selectors/index.js +16 -2
- package/test-utils/selectors/index.js.map +1 -1
- package/test-utils/selectors/option-list/index.d.ts +66 -0
- package/test-utils/selectors/option-list/index.js +108 -0
- package/test-utils/selectors/option-list/index.js.map +1 -0
- package/select/parts/item.d.ts +0 -33
- package/select/parts/item.d.ts.map +0 -1
- package/select/parts/item.js +0 -94
- package/select/parts/item.js.map +0 -1
- package/select/parts/multiselect-item.d.ts +0 -14
- package/select/parts/multiselect-item.d.ts.map +0 -1
- package/select/parts/multiselect-item.js +0 -112
- package/select/parts/multiselect-item.js.map +0 -1
- package/select/parts/plain-list.d.ts +0 -26
- package/select/parts/plain-list.d.ts.map +0 -1
- package/select/parts/plain-list.js.map +0 -1
- package/select/utils/use-native-search.d.ts +0 -18
- package/select/utils/use-native-search.d.ts.map +0 -1
- package/select/utils/use-native-search.js.map +0 -1
|
@@ -2,10 +2,15 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"root": "
|
|
6
|
-
"body-scroller": "awsui_body-
|
|
7
|
-
"table": "
|
|
8
|
-
"table-auto": "awsui_table-
|
|
9
|
-
"table-grid": "awsui_table-
|
|
5
|
+
"root": "awsui_root_1pkvc_fhcug_9",
|
|
6
|
+
"body-scroller": "awsui_body-scroller_1pkvc_fhcug_46",
|
|
7
|
+
"table": "awsui_table_1pkvc_fhcug_63",
|
|
8
|
+
"table-auto": "awsui_table-auto_1pkvc_fhcug_69",
|
|
9
|
+
"table-grid": "awsui_table-grid_1pkvc_fhcug_73",
|
|
10
|
+
"table-copy-fixed": "awsui_table-copy-fixed_1pkvc_fhcug_77",
|
|
11
|
+
"sticky-slot": "awsui_sticky-slot_1pkvc_fhcug_81",
|
|
12
|
+
"sticky-slot-stuck": "awsui_sticky-slot-stuck_1pkvc_fhcug_88",
|
|
13
|
+
"sticky-copy-scroller": "awsui_sticky-copy-scroller_1pkvc_fhcug_92",
|
|
14
|
+
"sticky-copy-focus": "awsui_sticky-copy-focus_1pkvc_fhcug_100"
|
|
10
15
|
};
|
|
11
16
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { RefObject } from 'react';
|
|
2
|
+
interface UseTableRootStickyHeaderProps {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
verticalOffset?: number;
|
|
5
|
+
isGrid: boolean;
|
|
6
|
+
rootRef: RefObject<HTMLElement>;
|
|
7
|
+
scrollerRef: RefObject<HTMLElement>;
|
|
8
|
+
}
|
|
9
|
+
export declare function useTableRootStickyHeader({
|
|
10
|
+
enabled,
|
|
11
|
+
verticalOffset,
|
|
12
|
+
isGrid,
|
|
13
|
+
rootRef,
|
|
14
|
+
scrollerRef
|
|
15
|
+
}: UseTableRootStickyHeaderProps): {
|
|
16
|
+
isSticky: boolean;
|
|
17
|
+
isStuck: boolean;
|
|
18
|
+
stickyStyles: {
|
|
19
|
+
style: {
|
|
20
|
+
top: string;
|
|
21
|
+
};
|
|
22
|
+
} | {
|
|
23
|
+
style?: undefined;
|
|
24
|
+
};
|
|
25
|
+
slotRef: React.RefObject<HTMLDivElement>;
|
|
26
|
+
copyScrollerRef: React.RefObject<HTMLDivElement>;
|
|
27
|
+
realTableRef: React.RefObject<HTMLTableElement>;
|
|
28
|
+
copyTableRef: React.RefObject<HTMLTableElement>;
|
|
29
|
+
onCopyFocus: (event: React.FocusEvent) => void;
|
|
30
|
+
onScrollerFocus: (event: React.FocusEvent) => void;
|
|
31
|
+
onScrollerBlur: () => void;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-sticky-header.d.ts","sourceRoot":"","sources":["../../../src/table-root/use-sticky-header.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAkD,MAAM,OAAO,CAAC;AAYzF,UAAU,6BAA6B;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IAChC,WAAW,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;CACrC;AAkBD,wBAAgB,wBAAwB,CAAC,EACvC,OAAO,EACP,cAAc,EACd,MAAM,EACN,OAAO,EACP,WAAW,GACZ,EAAE,6BAA6B;;;;;;;;;;;;;;yBAiEF,KAAK,CAAC,UAAU;6BA8BZ,KAAK,CAAC,UAAU;;EA+BjD"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
4
|
+
import { useCellsResizeObserver } from '../internal/components/sticky-header/use-cells-resize-observer';
|
|
5
|
+
import { useStickyHeaderCopy } from '../internal/components/sticky-header/use-sticky-header-copy';
|
|
6
|
+
import { useStickyPosition } from '../internal/components/sticky-header/use-sticky-position';
|
|
7
|
+
import { useUntabbableDescendants } from '../internal/components/sticky-header/use-untabbable-descendants';
|
|
8
|
+
import useMouseDownTarget from '../internal/hooks/use-mouse-down-target';
|
|
9
|
+
import { setElementWidths } from '../table/column-widths-utils';
|
|
10
|
+
import abstractSwitchStyles from '../internal/components/abstract-switch/styles.css.js';
|
|
11
|
+
import styles from './styles.css.js';
|
|
12
|
+
const getHeaderCells = (head) => head ? Array.from(head.rows).flatMap(row => Array.from(row.cells)) : [];
|
|
13
|
+
// The copy renders the same header, so an element's child-index path finds its counterpart in the copy.
|
|
14
|
+
function pathFrom(root, element) {
|
|
15
|
+
const path = [];
|
|
16
|
+
for (let current = element; current !== root && current.parentElement; current = current.parentElement) {
|
|
17
|
+
path.unshift(Array.prototype.indexOf.call(current.parentElement.children, current));
|
|
18
|
+
}
|
|
19
|
+
return path;
|
|
20
|
+
}
|
|
21
|
+
function elementAtPath(root, path) {
|
|
22
|
+
var _a;
|
|
23
|
+
return (_a = path.reduce((element, index) => element === null || element === void 0 ? void 0 : element.children[index], root)) !== null && _a !== void 0 ? _a : null;
|
|
24
|
+
}
|
|
25
|
+
export function useTableRootStickyHeader({ enabled, verticalOffset, isGrid, rootRef, scrollerRef, }) {
|
|
26
|
+
const slotRef = useRef(null);
|
|
27
|
+
const copyScrollerRef = useRef(null);
|
|
28
|
+
const realTableRef = useRef(null);
|
|
29
|
+
const copyTableRef = useRef(null);
|
|
30
|
+
const realHeaderRef = useRef(null);
|
|
31
|
+
const copyHeaderRef = useRef(null);
|
|
32
|
+
useLayoutEffect(() => {
|
|
33
|
+
var _a, _b, _c, _d;
|
|
34
|
+
realHeaderRef.current = (_b = (_a = realTableRef.current) === null || _a === void 0 ? void 0 : _a.tHead) !== null && _b !== void 0 ? _b : null;
|
|
35
|
+
copyHeaderRef.current = (_d = (_c = copyTableRef.current) === null || _c === void 0 ? void 0 : _c.tHead) !== null && _d !== void 0 ? _d : null;
|
|
36
|
+
});
|
|
37
|
+
const { isSticky, isStuck, stickyStyles } = useStickyPosition(rootRef, slotRef, {
|
|
38
|
+
sticky: enabled,
|
|
39
|
+
offset: verticalOffset,
|
|
40
|
+
});
|
|
41
|
+
const { scrollToRow } = useStickyHeaderCopy({
|
|
42
|
+
tableRef: realTableRef,
|
|
43
|
+
theadRef: realHeaderRef,
|
|
44
|
+
secondaryTheadRef: copyHeaderRef,
|
|
45
|
+
secondaryTableRef: copyTableRef,
|
|
46
|
+
tableWrapperRef: scrollerRef,
|
|
47
|
+
});
|
|
48
|
+
// useStickyHeaderCopy pulls the scroller up to hide the real header under the copy, but doesn't undo it.
|
|
49
|
+
useLayoutEffect(() => {
|
|
50
|
+
if (!isSticky && scrollerRef.current) {
|
|
51
|
+
scrollerRef.current.style.marginBlockStart = '';
|
|
52
|
+
}
|
|
53
|
+
}, [isSticky, scrollerRef]);
|
|
54
|
+
// In grid layout the copy shares the column template; in auto layout it copies the real cells' widths.
|
|
55
|
+
// The layout is read from a ref so the callback never changes, as the resize observer can call an older one.
|
|
56
|
+
const isGridRef = useRef(isGrid);
|
|
57
|
+
useLayoutEffect(() => {
|
|
58
|
+
isGridRef.current = isGrid;
|
|
59
|
+
});
|
|
60
|
+
const syncColumnWidths = useCallback(() => {
|
|
61
|
+
if (!copyHeaderRef.current) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const copyCells = getHeaderCells(copyHeaderRef.current);
|
|
65
|
+
const widths = isGridRef.current
|
|
66
|
+
? []
|
|
67
|
+
: getHeaderCells(realHeaderRef.current).map(cell => cell.getBoundingClientRect().width);
|
|
68
|
+
copyCells.forEach((cell, index) => setElementWidths(cell, { width: widths[index] }));
|
|
69
|
+
}, []);
|
|
70
|
+
useLayoutEffect(() => {
|
|
71
|
+
syncColumnWidths();
|
|
72
|
+
});
|
|
73
|
+
useCellsResizeObserver(() => (isSticky && !isGrid ? getHeaderCells(realHeaderRef.current) : []), syncColumnWidths);
|
|
74
|
+
// The scroll sync only reacts to scroll events, so a copy that mounts after the body has scrolled starts aligned.
|
|
75
|
+
useLayoutEffect(() => {
|
|
76
|
+
if (isSticky && copyScrollerRef.current && scrollerRef.current) {
|
|
77
|
+
copyScrollerRef.current.scrollLeft = scrollerRef.current.scrollLeft;
|
|
78
|
+
}
|
|
79
|
+
}, [isSticky, scrollerRef]);
|
|
80
|
+
useUntabbableDescendants(slotRef);
|
|
81
|
+
// The copy is hidden from assistive technology, so focus that lands in it (from a click) moves to the
|
|
82
|
+
// matching control in the real header. The click itself still reaches the copy.
|
|
83
|
+
const onCopyFocus = (event) => {
|
|
84
|
+
const target = event.target;
|
|
85
|
+
const copyHeader = copyHeaderRef.current;
|
|
86
|
+
const realHeader = realHeaderRef.current;
|
|
87
|
+
if (copyHeader && realHeader && copyHeader.contains(target)) {
|
|
88
|
+
const realElement = elementAtPath(realHeader, pathFrom(copyHeader, target));
|
|
89
|
+
realElement === null || realElement === void 0 ? void 0 : realElement.focus({ preventScroll: true });
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
// The real header is covered by the copy, so the copy shows its focus ring. A checkbox or radio draws its
|
|
93
|
+
// ring on the outline next to its hidden input, which is shown only for keyboard focus, like other rings.
|
|
94
|
+
const [focusedHeaderPath, setFocusedHeaderPath] = useState(null);
|
|
95
|
+
useLayoutEffect(() => {
|
|
96
|
+
var _a;
|
|
97
|
+
const copyElement = focusedHeaderPath && copyHeaderRef.current ? elementAtPath(copyHeaderRef.current, focusedHeaderPath) : null;
|
|
98
|
+
const isKeyboardFocus = document.body.hasAttribute('data-awsui-focus-visible');
|
|
99
|
+
const switchOutline = isKeyboardFocus && ((_a = copyElement === null || copyElement === void 0 ? void 0 : copyElement.nextElementSibling) === null || _a === void 0 ? void 0 : _a.classList.contains(abstractSwitchStyles.outline))
|
|
100
|
+
? copyElement.nextElementSibling
|
|
101
|
+
: null;
|
|
102
|
+
copyElement === null || copyElement === void 0 ? void 0 : copyElement.classList.add(styles['sticky-copy-focus']);
|
|
103
|
+
switchOutline === null || switchOutline === void 0 ? void 0 : switchOutline.classList.add(abstractSwitchStyles['show-outline']);
|
|
104
|
+
return () => {
|
|
105
|
+
copyElement === null || copyElement === void 0 ? void 0 : copyElement.classList.remove(styles['sticky-copy-focus']);
|
|
106
|
+
switchOutline === null || switchOutline === void 0 ? void 0 : switchOutline.classList.remove(abstractSwitchStyles['show-outline']);
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
const getMouseDownTarget = useMouseDownTarget();
|
|
110
|
+
const onScrollerFocus = (event) => {
|
|
111
|
+
const target = event.target;
|
|
112
|
+
const realHeader = realHeaderRef.current;
|
|
113
|
+
if (!isSticky) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (realHeader === null || realHeader === void 0 ? void 0 : realHeader.contains(target)) {
|
|
117
|
+
setFocusedHeaderPath(pathFrom(realHeader, target));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
// Keeps a focused body row from scrolling under the copy. Skipped for clicks: moving the row
|
|
121
|
+
// between mouse down and mouse up would stop the click reaching its target.
|
|
122
|
+
const row = target.closest('tr');
|
|
123
|
+
if (row && !row.contains(getMouseDownTarget())) {
|
|
124
|
+
scrollToRow(row);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const onScrollerBlur = () => setFocusedHeaderPath(null);
|
|
128
|
+
return {
|
|
129
|
+
isSticky,
|
|
130
|
+
isStuck,
|
|
131
|
+
stickyStyles,
|
|
132
|
+
slotRef,
|
|
133
|
+
copyScrollerRef,
|
|
134
|
+
realTableRef,
|
|
135
|
+
copyTableRef,
|
|
136
|
+
onCopyFocus,
|
|
137
|
+
onScrollerFocus,
|
|
138
|
+
onScrollerBlur,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=use-sticky-header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-sticky-header.js","sourceRoot":"","sources":["../../../src/table-root/use-sticky-header.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAc,EAAa,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gEAAgE,CAAC;AACxG,OAAO,EAAE,mBAAmB,EAAE,MAAM,6DAA6D,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAC;AAC7F,OAAO,EAAE,wBAAwB,EAAE,MAAM,iEAAiE,CAAC;AAC3G,OAAO,kBAAkB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QACP,eAAe;QACf,YAAY;QACZ,YAAY;QACZ,WAAW;QACX,eAAe;QACf,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { RefObject, useCallback, useLayoutEffect, useRef, useState } from 'react';\n\nimport { useCellsResizeObserver } from '../internal/components/sticky-header/use-cells-resize-observer';\nimport { useStickyHeaderCopy } from '../internal/components/sticky-header/use-sticky-header-copy';\nimport { useStickyPosition } from '../internal/components/sticky-header/use-sticky-position';\nimport { useUntabbableDescendants } from '../internal/components/sticky-header/use-untabbable-descendants';\nimport useMouseDownTarget from '../internal/hooks/use-mouse-down-target';\nimport { setElementWidths } from '../table/column-widths-utils';\n\nimport abstractSwitchStyles from '../internal/components/abstract-switch/styles.css.js';\nimport styles from './styles.css.js';\n\ninterface UseTableRootStickyHeaderProps {\n enabled: boolean;\n verticalOffset?: number;\n isGrid: boolean;\n rootRef: RefObject<HTMLElement>;\n scrollerRef: RefObject<HTMLElement>;\n}\n\nconst getHeaderCells = (head: HTMLTableSectionElement | null) =>\n head ? Array.from(head.rows).flatMap(row => Array.from(row.cells)) : [];\n\n// The copy renders the same header, so an element's child-index path finds its counterpart in the copy.\nfunction pathFrom(root: Element, element: Element) {\n const path: number[] = [];\n for (let current = element; current !== root && current.parentElement; current = current.parentElement) {\n path.unshift(Array.prototype.indexOf.call(current.parentElement.children, current));\n }\n return path;\n}\n\nfunction elementAtPath(root: Element, path: number[]) {\n return path.reduce<Element | undefined>((element, index) => element?.children[index], root) ?? null;\n}\n\nexport function useTableRootStickyHeader({\n enabled,\n verticalOffset,\n isGrid,\n rootRef,\n scrollerRef,\n}: UseTableRootStickyHeaderProps) {\n const slotRef = useRef<HTMLDivElement>(null);\n const copyScrollerRef = useRef<HTMLDivElement>(null);\n const realTableRef = useRef<HTMLTableElement>(null);\n const copyTableRef = useRef<HTMLTableElement>(null);\n const realHeaderRef = useRef<HTMLTableSectionElement | null>(null);\n const copyHeaderRef = useRef<HTMLTableSectionElement | null>(null);\n\n useLayoutEffect(() => {\n realHeaderRef.current = realTableRef.current?.tHead ?? null;\n copyHeaderRef.current = copyTableRef.current?.tHead ?? null;\n });\n\n const { isSticky, isStuck, stickyStyles } = useStickyPosition(rootRef, slotRef, {\n sticky: enabled,\n offset: verticalOffset,\n });\n\n const { scrollToRow } = useStickyHeaderCopy({\n tableRef: realTableRef,\n theadRef: realHeaderRef,\n secondaryTheadRef: copyHeaderRef,\n secondaryTableRef: copyTableRef,\n tableWrapperRef: scrollerRef,\n });\n\n // useStickyHeaderCopy pulls the scroller up to hide the real header under the copy, but doesn't undo it.\n useLayoutEffect(() => {\n if (!isSticky && scrollerRef.current) {\n scrollerRef.current.style.marginBlockStart = '';\n }\n }, [isSticky, scrollerRef]);\n\n // In grid layout the copy shares the column template; in auto layout it copies the real cells' widths.\n // The layout is read from a ref so the callback never changes, as the resize observer can call an older one.\n const isGridRef = useRef(isGrid);\n useLayoutEffect(() => {\n isGridRef.current = isGrid;\n });\n const syncColumnWidths = useCallback(() => {\n if (!copyHeaderRef.current) {\n return;\n }\n const copyCells = getHeaderCells(copyHeaderRef.current);\n const widths = isGridRef.current\n ? []\n : getHeaderCells(realHeaderRef.current).map(cell => cell.getBoundingClientRect().width);\n copyCells.forEach((cell, index) => setElementWidths(cell, { width: widths[index] }));\n }, []);\n useLayoutEffect(() => {\n syncColumnWidths();\n });\n useCellsResizeObserver(() => (isSticky && !isGrid ? getHeaderCells(realHeaderRef.current) : []), syncColumnWidths);\n\n // The scroll sync only reacts to scroll events, so a copy that mounts after the body has scrolled starts aligned.\n useLayoutEffect(() => {\n if (isSticky && copyScrollerRef.current && scrollerRef.current) {\n copyScrollerRef.current.scrollLeft = scrollerRef.current.scrollLeft;\n }\n }, [isSticky, scrollerRef]);\n\n useUntabbableDescendants(slotRef);\n\n // The copy is hidden from assistive technology, so focus that lands in it (from a click) moves to the\n // matching control in the real header. The click itself still reaches the copy.\n const onCopyFocus = (event: React.FocusEvent) => {\n const target = event.target as HTMLElement;\n const copyHeader = copyHeaderRef.current;\n const realHeader = realHeaderRef.current;\n if (copyHeader && realHeader && copyHeader.contains(target)) {\n const realElement = elementAtPath(realHeader, pathFrom(copyHeader, target)) as HTMLElement | null;\n realElement?.focus({ preventScroll: true });\n }\n };\n\n // The real header is covered by the copy, so the copy shows its focus ring. A checkbox or radio draws its\n // ring on the outline next to its hidden input, which is shown only for keyboard focus, like other rings.\n const [focusedHeaderPath, setFocusedHeaderPath] = useState<number[] | null>(null);\n useLayoutEffect(() => {\n const copyElement =\n focusedHeaderPath && copyHeaderRef.current ? elementAtPath(copyHeaderRef.current, focusedHeaderPath) : null;\n const isKeyboardFocus = document.body.hasAttribute('data-awsui-focus-visible');\n const switchOutline =\n isKeyboardFocus && copyElement?.nextElementSibling?.classList.contains(abstractSwitchStyles.outline)\n ? copyElement.nextElementSibling\n : null;\n copyElement?.classList.add(styles['sticky-copy-focus']);\n switchOutline?.classList.add(abstractSwitchStyles['show-outline']);\n return () => {\n copyElement?.classList.remove(styles['sticky-copy-focus']);\n switchOutline?.classList.remove(abstractSwitchStyles['show-outline']);\n };\n });\n\n const getMouseDownTarget = useMouseDownTarget();\n const onScrollerFocus = (event: React.FocusEvent) => {\n const target = event.target as HTMLElement;\n const realHeader = realHeaderRef.current;\n if (!isSticky) {\n return;\n }\n if (realHeader?.contains(target)) {\n setFocusedHeaderPath(pathFrom(realHeader, target));\n return;\n }\n // Keeps a focused body row from scrolling under the copy. Skipped for clicks: moving the row\n // between mouse down and mouse up would stop the click reaching its target.\n const row = target.closest('tr');\n if (row && !row.contains(getMouseDownTarget())) {\n scrollToRow(row);\n }\n };\n const onScrollerBlur = () => setFocusedHeaderPath(null);\n\n return {\n isSticky,\n isStuck,\n stickyStyles,\n slotRef,\n copyScrollerRef,\n realTableRef,\n copyTableRef,\n onCopyFocus,\n onScrollerFocus,\n onScrollerBlur,\n };\n}\n"]}
|
|
@@ -20,6 +20,9 @@ class HeaderWrapper extends dom_1.ComponentWrapper {
|
|
|
20
20
|
findActions() {
|
|
21
21
|
return this.findByClassName(styles_selectors_js_1.default.actions);
|
|
22
22
|
}
|
|
23
|
+
findSecondaryContent() {
|
|
24
|
+
return this.findByClassName(styles_selectors_js_1.default['secondary-content']);
|
|
25
|
+
}
|
|
23
26
|
}
|
|
24
27
|
HeaderWrapper.rootSelector = styles_selectors_js_1.default.root;
|
|
25
28
|
exports.default = HeaderWrapper;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/test-utils/dom/header/index.ts"],"names":[],"mappings":";;AAAA,qEAAqE;AACrE,sCAAsC;AACtC,gEAA0F;AAE1F,6EAAyD;AAEzD,MAAqB,aAAc,SAAQ,sBAAgB;IAGzD,eAAe;QACb,OAAO,IAAI,CAAC,eAAe,CAAC,6BAAM,CAAC,cAAc,CAAC,CAAE,CAAC;IACvD,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,eAAe,CAAC,6BAAM,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,eAAe,CAAC,6BAAM,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,eAAe,CAAC,6BAAM,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,eAAe,CAAC,6BAAM,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/test-utils/dom/header/index.ts"],"names":[],"mappings":";;AAAA,qEAAqE;AACrE,sCAAsC;AACtC,gEAA0F;AAE1F,6EAAyD;AAEzD,MAAqB,aAAc,SAAQ,sBAAgB;IAGzD,eAAe;QACb,OAAO,IAAI,CAAC,eAAe,CAAC,6BAAM,CAAC,cAAc,CAAC,CAAE,CAAC;IACvD,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,eAAe,CAAC,6BAAM,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,eAAe,CAAC,6BAAM,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,eAAe,CAAC,6BAAM,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,eAAe,CAAC,6BAAM,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,oBAAoB;QAClB,OAAO,IAAI,CAAC,eAAe,CAAC,6BAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAC3D,CAAC;;AAxBM,0BAAY,GAAW,6BAAM,CAAC,IAAI,CAAC;kBADvB,aAAa"}
|
|
@@ -58,6 +58,7 @@ import MixedLineBarChartWrapper from './mixed-line-bar-chart';
|
|
|
58
58
|
import ModalWrapper from './modal';
|
|
59
59
|
import MultiselectWrapper from './multiselect';
|
|
60
60
|
import NavigableGroupWrapper from './navigable-group';
|
|
61
|
+
import OptionListWrapper from './option-list';
|
|
61
62
|
import PaginationWrapper from './pagination';
|
|
62
63
|
import PanelLayoutWrapper from './panel-layout';
|
|
63
64
|
import PieChartWrapper from './pie-chart';
|
|
@@ -160,6 +161,7 @@ export { MixedLineBarChartWrapper };
|
|
|
160
161
|
export { ModalWrapper };
|
|
161
162
|
export { MultiselectWrapper };
|
|
162
163
|
export { NavigableGroupWrapper };
|
|
164
|
+
export { OptionListWrapper };
|
|
163
165
|
export { PaginationWrapper };
|
|
164
166
|
export { PanelLayoutWrapper };
|
|
165
167
|
export { PieChartWrapper };
|
|
@@ -1714,6 +1716,32 @@ declare module '@cloudscape-design/test-utils-core/dist/dom' {
|
|
|
1714
1716
|
* @returns {NavigableGroupWrapper | null}
|
|
1715
1717
|
*/
|
|
1716
1718
|
findClosestNavigableGroup(): NavigableGroupWrapper | null;
|
|
1719
|
+
/**
|
|
1720
|
+
* Returns the wrapper of the first OptionList that matches the specified CSS selector.
|
|
1721
|
+
* If no CSS selector is specified, returns the wrapper of the first OptionList.
|
|
1722
|
+
* If no matching OptionList is found, returns `null`.
|
|
1723
|
+
*
|
|
1724
|
+
* @param {string} [selector] CSS Selector
|
|
1725
|
+
* @returns {OptionListWrapper | null}
|
|
1726
|
+
*/
|
|
1727
|
+
findOptionList(selector?: string): OptionListWrapper | null;
|
|
1728
|
+
/**
|
|
1729
|
+
* Returns an array of OptionList wrapper that matches the specified CSS selector.
|
|
1730
|
+
* If no CSS selector is specified, returns all of the OptionLists inside the current wrapper.
|
|
1731
|
+
* If no matching OptionList is found, returns an empty array.
|
|
1732
|
+
*
|
|
1733
|
+
* @param {string} [selector] CSS Selector
|
|
1734
|
+
* @returns {Array<OptionListWrapper>}
|
|
1735
|
+
*/
|
|
1736
|
+
findAllOptionLists(selector?: string): Array<OptionListWrapper>;
|
|
1737
|
+
/**
|
|
1738
|
+
* Returns the wrapper of the closest parent OptionList for the current element,
|
|
1739
|
+
* or the element itself if it is an instance of OptionList.
|
|
1740
|
+
* If no OptionList is found, returns `null`.
|
|
1741
|
+
*
|
|
1742
|
+
* @returns {OptionListWrapper | null}
|
|
1743
|
+
*/
|
|
1744
|
+
findClosestOptionList(): OptionListWrapper | null;
|
|
1717
1745
|
/**
|
|
1718
1746
|
* Returns the wrapper of the first Pagination that matches the specified CSS selector.
|
|
1719
1747
|
* If no CSS selector is specified, returns the wrapper of the first Pagination.
|
package/test-utils/dom/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ItemCardWrapper = exports.InputWrapper = exports.IconWrapper = exports.HotspotWrapper = exports.HelpPanelWrapper = exports.HeaderWrapper = exports.GridWrapper = exports.FormFieldWrapper = exports.FormWrapper = exports.FlashbarWrapper = exports.FileUploadWrapper = exports.FileTokenGroupWrapper = exports.FileInputWrapper = exports.FileDropzoneWrapper = exports.ExpandableSectionWrapper = exports.ErrorBoundaryWrapper = exports.DropdownWrapper = exports.DrawerWrapper = exports.DividerWrapper = exports.DialogWrapper = exports.DateRangePickerWrapper = exports.DatePickerWrapper = exports.DateInputWrapper = exports.CopyToClipboardWrapper = exports.ControlGroupWrapper = exports.ContentLayoutWrapper = exports.ContainerWrapper = exports.ColumnLayoutWrapper = exports.CollectionPreferencesWrapper = exports.CodeEditorWrapper = exports.CheckboxWrapper = exports.CardsWrapper = exports.CalendarWrapper = exports.ButtonGroupWrapper = exports.ButtonDropdownWrapper = exports.ButtonWrapper = exports.BreadcrumbGroupWrapper = exports.BoxWrapper = exports.BarChartWrapper = exports.BadgeWrapper = exports.AutosuggestWrapper = exports.AttributeEditorWrapper = exports.AreaChartWrapper = exports.AppLayoutToolbarWrapper = exports.AppLayoutWrapper = exports.AnnotationWrapper = exports.AnchorNavigationWrapper = exports.AlertWrapper = exports.ActionCardWrapper = exports.ElementWrapper = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
exports.WizardWrapper = exports.TutorialPanelWrapper = exports.TruncatedTextWrapper = void 0;
|
|
4
|
+
exports.TopNavigationWrapper = exports.TooltipWrapper = exports.TokenGroupWrapper = exports.TokenWrapper = exports.ToggleButtonWrapper = exports.ToggleWrapper = exports.TimeInputWrapper = exports.TilesWrapper = exports.TextareaWrapper = exports.TextFilterWrapper = exports.TextContentWrapper = exports.TagEditorWrapper = exports.TabsWrapper = exports.TableRowWrapper = exports.TableRootWrapper = exports.TableHeaderCellWrapper = exports.TableHeadWrapper = exports.TableBodyCellWrapper = exports.TableBodyWrapper = exports.TableWrapper = exports.StepsWrapper = exports.StatusIndicatorWrapper = exports.SplitPanelWrapper = exports.SpinnerWrapper = exports.SpaceBetweenWrapper = exports.SliderWrapper = exports.SkeletonWrapper = exports.SideNavigationWrapper = exports.SelectWrapper = exports.SegmentedControlWrapper = exports.S3ResourceSelectorWrapper = exports.RadioGroupWrapper = exports.RadioButtonWrapper = exports.PropertyFilterWrapper = exports.PromptInputWrapper = exports.ProgressBarWrapper = exports.PopoverWrapper = exports.PieChartWrapper = exports.PanelLayoutWrapper = exports.PaginationWrapper = exports.OptionListWrapper = exports.NavigableGroupWrapper = exports.MultiselectWrapper = exports.ModalWrapper = exports.MixedLineBarChartWrapper = exports.LiveRegionWrapper = exports.ListWrapper = exports.LinkWrapper = exports.LineChartWrapper = exports.KeyValuePairsWrapper = void 0;
|
|
5
|
+
exports.WizardWrapper = exports.TutorialPanelWrapper = exports.TruncatedTextWrapper = exports.TreeViewWrapper = void 0;
|
|
6
6
|
exports.default = wrapper;
|
|
7
7
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -125,6 +125,8 @@ const multiselect_1 = require("./multiselect");
|
|
|
125
125
|
exports.MultiselectWrapper = multiselect_1.default;
|
|
126
126
|
const navigable_group_1 = require("./navigable-group");
|
|
127
127
|
exports.NavigableGroupWrapper = navigable_group_1.default;
|
|
128
|
+
const option_list_1 = require("./option-list");
|
|
129
|
+
exports.OptionListWrapper = option_list_1.default;
|
|
128
130
|
const pagination_1 = require("./pagination");
|
|
129
131
|
exports.PaginationWrapper = pagination_1.default;
|
|
130
132
|
const panel_layout_1 = require("./panel-layout");
|
|
@@ -909,6 +911,18 @@ dom_1.ElementWrapper.prototype.findNavigableGroup = function (selector) {
|
|
|
909
911
|
dom_1.ElementWrapper.prototype.findAllNavigableGroups = function (selector) {
|
|
910
912
|
return this.findAllComponents(navigable_group_1.default, selector);
|
|
911
913
|
};
|
|
914
|
+
dom_1.ElementWrapper.prototype.findOptionList = function (selector) {
|
|
915
|
+
let rootSelector = `.${option_list_1.default.rootSelector}`;
|
|
916
|
+
if ("legacyRootSelector" in option_list_1.default && option_list_1.default.legacyRootSelector) {
|
|
917
|
+
rootSelector = `:is(.${option_list_1.default.rootSelector}, .${option_list_1.default.legacyRootSelector})`;
|
|
918
|
+
}
|
|
919
|
+
// casting to 'any' is needed to avoid this issue with generics
|
|
920
|
+
// https://github.com/microsoft/TypeScript/issues/29132
|
|
921
|
+
return this.findComponent(selector ? (0, utils_1.appendSelector)(selector, rootSelector) : rootSelector, option_list_1.default);
|
|
922
|
+
};
|
|
923
|
+
dom_1.ElementWrapper.prototype.findAllOptionLists = function (selector) {
|
|
924
|
+
return this.findAllComponents(option_list_1.default, selector);
|
|
925
|
+
};
|
|
912
926
|
dom_1.ElementWrapper.prototype.findPagination = function (selector) {
|
|
913
927
|
let rootSelector = `.${pagination_1.default.rootSelector}`;
|
|
914
928
|
if ("legacyRootSelector" in pagination_1.default && pagination_1.default.legacyRootSelector) {
|
|
@@ -1727,6 +1741,11 @@ dom_1.ElementWrapper.prototype.findClosestNavigableGroup = function () {
|
|
|
1727
1741
|
// https://github.com/microsoft/TypeScript/issues/29132
|
|
1728
1742
|
return this.findClosestComponent(navigable_group_1.default);
|
|
1729
1743
|
};
|
|
1744
|
+
dom_1.ElementWrapper.prototype.findClosestOptionList = function () {
|
|
1745
|
+
// casting to 'any' is needed to avoid this issue with generics
|
|
1746
|
+
// https://github.com/microsoft/TypeScript/issues/29132
|
|
1747
|
+
return this.findClosestComponent(option_list_1.default);
|
|
1748
|
+
};
|
|
1730
1749
|
dom_1.ElementWrapper.prototype.findClosestPagination = function () {
|
|
1731
1750
|
// casting to 'any' is needed to avoid this issue with generics
|
|
1732
1751
|
// https://github.com/microsoft/TypeScript/issues/29132
|