Skip to content

Commit fe2cbdd

Browse files
Merge branch 'master' into fix/filter-bar-show-hide-filter
2 parents 9a1e086 + 5727165 commit fe2cbdd

File tree

4 files changed

+35
-12
lines changed

4 files changed

+35
-12
lines changed

packages/main/src/components/AnalyticalTable/AnalyticalTable.stories.mdx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Title, Subtitle, Primary, Description, Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs/blocks';
1+
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs/blocks';
22
import { AnalyticalTable } from '@ui5/webcomponents-react/lib/AnalyticalTable';
33
import { createSelectArgTypes } from '../../../../../shared/stories/createSelectArgTypes';
44
import { TableScaleWidthMode } from '@ui5/webcomponents-react/lib/TableScaleWidthMode';
@@ -10,19 +10,15 @@ import '@ui5/webcomponents-icons/dist/icons/delete';
1010
import '@ui5/webcomponents-icons/dist/icons/edit';
1111
import '@ui5/webcomponents-icons/dist/icons/settings';
1212
import { Button } from '@ui5/webcomponents-react/lib/Button';
13-
import { Text } from '@ui5/webcomponents-react/lib/Text';
1413
import { FlexBox } from '@ui5/webcomponents-react/lib/FlexBox';
1514
import { TextAlign } from '@ui5/webcomponents-react/lib/TextAlign';
16-
import { FlexBoxAlignItems } from '@ui5/webcomponents-react/lib/FlexBoxAlignItems';
17-
import { FlexBoxJustifyContent } from '@ui5/webcomponents-react/lib/FlexBoxJustifyContent';
1815
import { DefaultLoadingComponent } from './defaults/LoadingComponent';
1916
import { DefaultNoDataComponent } from './defaults/NoDataComponent';
2017

2118
<Meta
2219
title="Components / AnalyticalTable"
2320
component={AnalyticalTable}
2421
args={{
25-
dataTree: generateData(20, true),
2622
data: generateData(1000),
2723
columns: [
2824
{
@@ -109,7 +105,6 @@ import { DefaultNoDataComponent } from './defaults/NoDataComponent';
109105
}}
110106
argTypes={{
111107
ref: { type: null },
112-
dataTree: { type: null },
113108
data: { type: null },
114109
columns: { type: null },
115110
reactTableOptions: { type: null },
@@ -275,12 +270,12 @@ This even works if you resize the browser window!
275270
## Tree Table
276271

277272
<Canvas>
278-
<Story name="Tree Table">
273+
<Story name="Tree Table" args={{ data: generateData(20, true) }}>
279274
{(args) => (
280275
<AnalyticalTable
281276
{...args}
282277
title={args.title}
283-
data={args.dataTree}
278+
data={args.data}
284279
columns={args.columns}
285280
loading={args.loading}
286281
sortable={args.sortable}

packages/main/src/components/AnalyticalTable/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ export interface TableProps extends CommonProps {
9797
groupBy?: string[];
9898
selectionBehavior?: TableSelectionBehavior;
9999
selectionMode?: TableSelectionMode;
100+
/**
101+
* Defines the column growing behaviour. Possible Values:
102+
*
103+
* - **Default**: Every column without fixed width gets the maximum available space of the table.
104+
* - **Smart**: Every column gets the space it needs for displaying the full header text. If all headers need more space than the available table width, horizontal scrolling will be enabled. If there is space left, columns with a long content will get more space until there is no more table space left.
105+
* - **Grow**: Every column gets the space it needs for displaying it's full header text and full content of all cells. If it requires more space than the table has, horizontal scrolling will be enabled.
106+
*
107+
*/
100108
scaleWidthMode?: TableScaleWidthMode;
101109
columnOrder?: string[];
102110
infiniteScroll?: boolean;
@@ -113,7 +121,7 @@ export interface TableProps extends CommonProps {
113121
/**
114122
* Additional options which will be passed to [react-table´s useTable hook](https://react-table.tanstack.com/docs/api/useTable#table-options)
115123
*/
116-
reactTableOptions?: object;
124+
reactTableOptions?: Record<string, unknown>;
117125
tableHooks?: PluginHook<any>[];
118126
subRowsKey?: string;
119127
/**

packages/main/src/components/FilterBar/index.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ const FilterBar: FC<FilterBarPropTypes> = forwardRef((props: FilterBarPropTypes,
232232
return Children.toArray(children) as unknown[];
233233
}, [toggledFilters, children]);
234234

235+
const prevChildren = useRef({});
236+
235237
const renderChildren = useCallback(() => {
236238
const childProps = { considerGroupName, inFB: true } as any;
237239
return safeChildren()
@@ -256,10 +258,28 @@ const FilterBar: FC<FilterBarPropTypes> = forwardRef((props: FilterBarPropTypes,
256258
filterItemProps = filterValue(dialogItemRef, child);
257259
}
258260
}
259-
if (!child.props.children)
261+
if (!child.props.children) {
260262
return cloneElement(child as ReactElement<any>, {
261263
...childProps
262264
});
265+
}
266+
if (
267+
prevChildren.current?.[child.key] &&
268+
//Input
269+
(child.props.children?.props?.value !== prevChildren.current?.[child.key]?.value ||
270+
//Combobox
271+
child.props.children?.props?.filterValue !== prevChildren.current?.[child.key]?.filterValue ||
272+
//Checkbox
273+
child.props.children?.props?.checked !== prevChildren.current?.[child.key]?.checked ||
274+
//Selectable
275+
child.props.children?.props?.children?.map((item) => item.props.selected).join(',') !==
276+
prevChildren?.current?.[child.key]?.children?.map((item) => item.props.selected).join(','))
277+
) {
278+
const { [child.key]: omit, ...rest } = dialogRefs;
279+
setDialogRefs(rest);
280+
}
281+
prevChildren.current[child.key] = child.props.children.props;
282+
263283
return cloneElement(child as ReactElement<any>, {
264284
...childProps,
265285
children: {

packages/main/src/enums/TableScaleWidthMode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export enum TableScaleWidthMode {
22
/*
3-
* Every column without fixed width get's the maximum available space of the table
3+
* Every column without fixed width gets the maximum available space of the table
44
*/
55
Default = 'Default',
66
/*
@@ -10,7 +10,7 @@ export enum TableScaleWidthMode {
1010
*/
1111
Smart = 'Smart',
1212
/*
13-
* Every column get's the space it needs for displaying it's full header text and full content of all cells.
13+
* Every column gets the space it needs for displaying it's full header text and full content of all cells.
1414
* If it requires more space than the table has, horizontal scrolling will be enabled.
1515
*/
1616
Grow = 'Grow'

0 commit comments

Comments
 (0)