Skip to content

Commit

Permalink
Upgrade EUI to v93.1.1 (elastic#176762)
Browse files Browse the repository at this point in the history
`v93.0.0` ⏩ `v93.1.1`

---

## [`v93.1.1`](https://github.com/elastic/eui/releases/v93.2.0)

**This is a patch release primarily intended for use by Kibana.**

- Added top-level `EuiTreeView.Item` export
([elastic#7526](elastic/eui#7526))

## [`v93.1.0`](https://github.com/elastic/eui/releases/v93.1.0)

- Added `index` glyph to `EuiIcon`
([elastic#7498](elastic/eui#7498))
- Updated `EuiHighlight` to accept an array of `search` strings, which
allows highlighting multiple, separate words within its children. This
new type and behavior *only* works if `highlightAll` is also set to
true. ([elastic#7496](elastic/eui#7496))
- Updated `EuiContextMenu` with a new `panels.items.renderItem`
property, which allows rendering completely custom items next to
standard `EuiContextMenuItem` objects
([elastic#7510](elastic/eui#7510))
- `EuiSuperDatePicker` updates:
- Updated `EuiSuperDatePicker` with a new `refreshIntervalUnits` prop.
Passing this prop allows controlling and overriding the default unit
rounding behavior. ([elastic#7501](elastic/eui#7501))
- Updated `EuiAutoRefresh` and `EuiRefreshInterval` with a new
`intervalUnits` prop. Passing this prop allows controlling and
overriding the default unit rounding behavior.
([elastic#7501](elastic/eui#7501))
- Updated `onRefreshChange` to pass back a new `intervalUnits` key that
contains the current interval unit format (seconds, minutes, or hours).
([elastic#7501](elastic/eui#7501))
- Updated `EuiSuperDatePicker` with a new `canRoundRelativeUnits` prop,
which defaults to true (current behavior). To preserve displaying the
unit that users select for relative time, set this to false.
([elastic#7502](elastic/eui#7502))
- Updated `EuiSuperDatePicker` with a new `refreshMinInterval` prop,
which accepts a minimum number in milliseconds
([elastic#7516](elastic/eui#7516))
- Updated `EuiAutoRefresh` and `EuiRefreshInterval` with a new
`minInterval` prop, which accepts a minimum number in milliseconds
([elastic#7516](elastic/eui#7516))

**Bug fixes**

- Fixed `EuiHighlight` to not parse `search` strings as regexes
([elastic#7496](elastic/eui#7496))
- Fixed `EuiSuperDatePicker` submit bug when used within `<form>`
elements ([elastic#7504](elastic/eui#7504))
- Fixed an `EuiTreeView` bug where `aria-expanded` was being applied to
items without expandable children
([elastic#7513](elastic/eui#7513))

**CSS-in-JS conversions**

- Converted `EuiTreeView` to Emotion. Updates as part of the conversion:
([elastic#7513](elastic/eui#7513))
  - Removed `.euiTreeView__wrapper` div node
  - Enforced consistent `icon` size based on `display` size
  • Loading branch information
cee-chen authored and fkanout committed Mar 4, 2024
1 parent f575266 commit 2b74c27
Show file tree
Hide file tree
Showing 15 changed files with 127 additions and 175 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"@elastic/ecs": "^8.11.1",
"@elastic/elasticsearch": "npm:@elastic/[email protected]",
"@elastic/ems-client": "8.5.1",
"@elastic/eui": "93.0.0",
"@elastic/eui": "93.1.1",
"@elastic/filesaver": "1.1.2",
"@elastic/node-crypto": "1.2.1",
"@elastic/numeral": "^2.5.1",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1737,11 +1737,6 @@ export const getEuiContextMapping = (): EuiTokensObject => {
values: { status, number },
description: 'Screen reader text describing the state of a tour step',
}),
'euiTreeView.ariaLabel': ({ nodeLabel, ariaLabel }: EuiValues) =>
i18n.translate('core.euiTreeView.ariaLabel', {
defaultMessage: '{nodeLabel} child of {ariaLabel}',
values: { nodeLabel, ariaLabel },
}),
'euiTreeView.listNavigationInstructions': i18n.translate(
'core.euiTreeView.listNavigationInstructions',
{
Expand Down
2 changes: 1 addition & 1 deletion src/dev/license_checker/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const LICENSE_OVERRIDES = {
'[email protected]': ['Eclipse Distribution License - v 1.0'], // cf. https://github.com/bjornharrtell/jsts
'@mapbox/[email protected]': ['MIT'], // license in readme https://github.com/tmcw/jsonlint
'@elastic/[email protected]': ['Elastic License 2.0'],
'@elastic/eui@93.0.0': ['SSPL-1.0 OR Elastic License 2.0'],
'@elastic/eui@93.1.1': ['SSPL-1.0 OR Elastic License 2.0'],
'[email protected]': ['CC-BY-4.0'], // retired ODC‑By license https://github.com/mattcg/language-subtag-registry
'[email protected]': ['MIT'], // license in importing module https://www.npmjs.com/package/binary
'@bufbuild/[email protected]': ['Apache-2.0'], // license (Apache-2.0 AND BSD-3-Clause)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export function UnifiedSearchBar({
const onRefreshChange = ({
isPaused,
refreshInterval,
}: OnRefreshChangeProps) => {
}: Partial<OnRefreshChangeProps>) => {
const existingQueryParams = toQuery(location.search);
const updatedQueryParams = {
...existingQueryParams,
Expand Down
6 changes: 6 additions & 0 deletions x-pack/plugins/kubernetes_security/common/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ export const TREE_NAVIGATION_LOADING = i18n.translate(
defaultMessage: 'Loading',
}
);
export const TREE_NAVIGATION_EMPTY = i18n.translate(
'xpack.kubernetesSecurity.treeNavigation.empty',
{
defaultMessage: 'No data available',
}
);
export const TREE_NAVIGATION_SHOW_MORE = (name: string) =>
i18n.translate('xpack.kubernetesSecurity.treeNavigation.loadMore', {
values: { name },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ describe('DynamicTreeView component', () => {
},
},
]}
aria-label="Logical Tree View"
onSelect={(selectionDepth, key, type) => {}}
{...props}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@
* 2.0.
*/

import React, { useEffect, useState, useRef, MouseEvent, KeyboardEvent, useMemo } from 'react';
import React, { useEffect, useState, useRef, KeyboardEvent, useMemo } from 'react';
import {
EuiIcon,
EuiTreeView,
EuiText,
EuiI18n,
EuiScreenReaderOnly,
EuiBadge,
keys,
EuiLoadingSpinner,
EuiToolTip,
useEuiTheme,
} from '@elastic/eui';
// @ts-expect-error style types not defined, but they exist
import { euiTreeViewStyles } from '@elastic/eui/lib/components/tree_view/tree_view.styles';

import {
TREE_NAVIGATION_LOADING,
TREE_NAVIGATION_EMPTY,
TREE_NAVIGATION_SHOW_MORE,
} from '../../../../common/translations';
import { useFetchDynamicTreeView } from './hooks';
Expand Down Expand Up @@ -64,17 +69,17 @@ export const DynamicTreeView = ({
onSelect,
selected = '',
expanded = true,
...props
onKeyDown,
}: DynamicTreeViewProps) => {
const styles = useStyles(depth);
const euiStyles = euiTreeViewStyles(useEuiTheme());
const euiTreeViewCss = [euiStyles.euiTreeView, euiStyles.default];

const { indexPattern, setNoResults, setTreeNavSelection } = useTreeViewContext();

const { data, fetchNextPage, isFetchingNextPage, hasNextPage, isLoading } =
useFetchDynamicTreeView(query, tree[depth].key, indexPattern, expanded);

const ariaLabel = props['aria-label'];

const onLoadMoreKeydown = (event: React.KeyboardEvent) => {
switch (event.key) {
case keys.ARROW_DOWN: {
Expand Down Expand Up @@ -135,17 +140,7 @@ export const DynamicTreeView = ({
}, [data?.pages]);

return (
<EuiText
size="s"
className={`euiTreeView__wrapper ${!expanded ? 'euiTreeView__wrapper--hidden' : ''}`}
css={styles.treeViewWrapper(expanded)}
>
{isLoading && (
<div>
<EuiLoadingSpinner size="s" />
<span css={styles.loadMoreTextLeft}>{TREE_NAVIGATION_LOADING}</span>
</div>
)}
<EuiText size="s" css={styles.euiTreeViewWrapper} hidden={!expanded} onKeyDown={onKeyDown}>
{depth === 0 && (
<EuiI18n
token="euiTreeView.listNavigationInstructions"
Expand All @@ -159,10 +154,24 @@ export const DynamicTreeView = ({
</EuiI18n>
)}
<ul
className="euiTreeView"
css={euiTreeViewCss}
aria-describedby={data?.pages?.length ? 'dynamicTreeViewInstructionId' : undefined}
aria-label={ariaLabel}
>
{isLoading && (
<EuiTreeView.Item
id="dynamicTreeViewLoading"
css={styles.nonInteractiveItem}
icon={<EuiLoadingSpinner size="s" />}
label={TREE_NAVIGATION_LOADING}
/>
)}
{!isLoading && !itemList.length && (
<EuiTreeView.Item
id="dynamicTreeViewEmpty"
css={styles.nonInteractiveItem}
label={TREE_NAVIGATION_EMPTY}
/>
)}
{itemList.map((aggData) => {
const queryFilter = {
...query,
Expand All @@ -179,7 +188,6 @@ export const DynamicTreeView = ({
{({ isExpanded, onToggleExpand }) => (
<DynamicTreeViewItem
aggData={aggData}
aria-label={ariaLabel}
depth={depth}
expanded={expanded}
isExpanded={isExpanded}
Expand All @@ -195,26 +203,25 @@ export const DynamicTreeView = ({
);
})}
{hasNextPage && (
<li key="load_more" className="euiTreeView__node" css={styles.loadMoreButtonWrapper}>
<EuiBadge
css={styles.loadMoreButton}
onClickAriaLabel={TREE_NAVIGATION_SHOW_MORE(tree[depth].namePlural)}
data-test-subj={BUTTON_TEST_ID}
onKeyDown={(event: React.KeyboardEvent) => onLoadMoreKeydown(event)}
onClick={onClickNextPageHandler}
>
<span css={styles.loadMoreText}>
<EuiTreeView.Item
id="dynamicTreeViewLoadMore"
css={styles.loadMoreButton}
aria-label={TREE_NAVIGATION_SHOW_MORE(tree[depth].namePlural)}
data-test-subj={BUTTON_TEST_ID}
onKeyDown={(event: React.KeyboardEvent) => onLoadMoreKeydown(event)}
onClick={onClickNextPageHandler}
label={
<EuiBadge
css={styles.loadMoreBadge}
iconSide="right"
iconType={isFetchingNextPage ? EuiLoadingSpinner : 'arrowDown'}
>
{isFetchingNextPage
? TREE_NAVIGATION_LOADING
: TREE_NAVIGATION_SHOW_MORE(tree[depth].namePlural)}
</span>
{isFetchingNextPage ? (
<EuiLoadingSpinner size="s" />
) : (
<EuiIcon size="s" type="arrowDown" />
)}
</EuiBadge>
</li>
</EuiBadge>
}
/>
)}
</ul>
</EuiText>
Expand All @@ -232,10 +239,8 @@ const DynamicTreeViewItem = ({
selected,
expanded,
query,
...props
}: DynamicTreeViewItemProps) => {
const isLastNode = depth === tree.length - 1;
const styles = useStyles(depth);
const buttonRef = useRef<Record<string, any>>({});

const handleSelect = () => {
Expand All @@ -254,17 +259,10 @@ const DynamicTreeViewItem = ({
};

const onButtonToggle = () => {
if (!isLastNode && !isExpanded) {
onToggleExpand();
}
handleSelect();
};

const onArrowToggle = (event: MouseEvent<SVGElement>) => {
disableEventDefaults(event);
if (!isLastNode) {
onToggleExpand();
}
handleSelect();
};

// Enable keyboard navigation
Expand Down Expand Up @@ -303,73 +301,44 @@ const DynamicTreeViewItem = ({
}
};

const isSelected = useMemo(() => {
return (
selected ===
Object.entries({
...selectionDepth,
[tree[depth].type]: aggData.key,
...(tree[depth].type === 'clusterId' &&
aggData.key_as_string && {
clusterName: aggData.key_as_string,
}),
})
.map(([k, v]) => `${k}.${v}`)
.join()
);
}, [aggData.key, aggData.key_as_string, depth, selected, selectionDepth, tree]);

const clusterLevel = BREADCRUMBS_CLUSTER_TREE_VIEW_LEVELS[tree[depth].type];

return (
<li
className={`euiTreeView__node
${isExpanded ? 'euiTreeView__node--expanded' : ''}
${isSelected ? 'euiTreeView__node--selected' : ''}
`}
>
<button
data-test-subj={expanded ? BUTTON_TEST_ID : ''}
className="euiTreeView__nodeInner euiTreeView__nodeInner--withArrows"
onClick={onButtonToggle}
onKeyDown={onKeyDown}
ref={(el) => (buttonRef.current[aggData.key] = el)}
css={isLastNode ? styles.leafNodeButton : undefined}
>
{!isLastNode && (
<EuiIcon
className="euiTreeView__expansionArrow"
type={isExpanded ? 'arrowDown' : 'arrowRight'}
onClick={onArrowToggle}
/>
)}
<TreeViewIcon {...tree[depth].iconProps} css={styles.labelIcon} />
<EuiToolTip content={`${clusterLevel}: ${aggData.key}`}>
<span className="euiTreeView__nodeLabel">{aggData.key_as_string || aggData.key}</span>
<EuiTreeView.Item
id={aggData.key_as_string || `${aggData.key}`}
hasArrow={!isLastNode}
isExpanded={isExpanded}
onClick={onButtonToggle}
onKeyDown={onKeyDown}
icon={<TreeViewIcon {...tree[depth].iconProps} />}
label={
<EuiToolTip anchorClassName="eui-textTruncate" content={`${clusterLevel}: ${aggData.key}`}>
<span>{aggData.key_as_string || aggData.key}</span>
</EuiToolTip>
</button>
<div
onKeyDown={(event: React.KeyboardEvent) => onChildrenKeydown(event, aggData.key.toString())}
>
{!isLastNode && (
<DynamicTreeView
expanded={isExpanded}
query={query}
depth={depth + 1}
selectionDepth={{
...selectionDepth,
[tree[depth].type]: aggData.key,
...(tree[depth].type === 'clusterId' && {
clusterName: aggData.key_as_string,
}),
}}
tree={tree}
onSelect={onSelect}
selected={selected}
aria-label={`${aggData.key} child of ${props['aria-label']}`}
/>
)}
</div>
</li>
}
buttonRef={(el: HTMLButtonElement) => (buttonRef.current[aggData.key] = el)}
data-test-subj={expanded ? BUTTON_TEST_ID : ''}
>
{!isLastNode && (
<DynamicTreeView
expanded={isExpanded}
query={query}
depth={depth + 1}
selectionDepth={{
...selectionDepth,
[tree[depth].type]: aggData.key,
...(tree[depth].type === 'clusterId' && {
clusterName: aggData.key_as_string,
}),
}}
tree={tree}
onSelect={onSelect}
selected={selected}
onKeyDown={(event: React.KeyboardEvent) =>
onChildrenKeydown(event, aggData.key.toString())
}
/>
)}
</EuiTreeView.Item>
);
};
Loading

0 comments on commit 2b74c27

Please sign in to comment.