UNPKG

@awsui/components-react

Version:

On July 19th, 2022, we launched [Cloudscape Design System](https://cloudscape.design). Cloudscape is an evolution of AWS-UI. It consists of user interface guidelines, front-end components, design resources, and development tools for building intuitive, en

40 lines 1.63 kB
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 import { findUpUntil } from '@awsui/component-toolkit/dom'; import { getLogicalBoundingClientRect } from '@awsui/component-toolkit/internal'; import { getOverflowParents } from '../../internal/utils/scrollable-containers.js'; import tableStyles from '../styles.css.js'; import resizerStyles from './styles.css.js'; export function getResizerElements(resizerElement) { if (!resizerElement) { return null; } const header = findUpUntil(resizerElement, element => element.tagName === 'TH'); if (!header) { return null; } const tableRoot = findUpUntil(header, element => element.className.indexOf(tableStyles.root) > -1); if (!tableRoot) { return null; } const table = tableRoot.querySelector(`table`); if (!table) { return null; } const allHeaders = tableRoot.querySelectorAll(`thead th`); // tracker is rendered inside table wrapper to align with its size const tracker = tableRoot.querySelector(`.${resizerStyles.tracker}`); if (!tracker) { return null; } const scrollParent = getOverflowParents(header)[0]; if (!scrollParent) { return null; } return { header, table, allHeaders, tracker, scrollParent }; } export function getHeaderWidth(resizerElement) { const header = resizerElement && findUpUntil(resizerElement, element => element.tagName.toLowerCase() === 'th'); return header ? getLogicalBoundingClientRect(header).inlineSize : 0; } //# sourceMappingURL=resizer-lookup.js.map