Skip to content

Commit

Permalink
[useTableState][Breaking Change]: columns prop is removed, since it's…
Browse files Browse the repository at this point in the history
… not needed now. Just remove it from `useTableState` provided props.
  • Loading branch information
AlekseyManetov committed Nov 8, 2024
1 parent 9445a46 commit 4178705
Show file tree
Hide file tree
Showing 12 changed files with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export function MasterDetailedTable() {
const filters = useMemo(() => getFilters<PersonFilters['Person']>(), []);

const tableStateApi = useTableState<PersonTableFilter>({
columns: personColumns,
initialPresets: initialPresets,
onPresetCreate: svc.api.presets.createPreset,
onPresetUpdate: svc.api.presets.updatePreset,
Expand Down
4 changes: 1 addition & 3 deletions app/src/docs/_examples/statusIndicator/WithTable.example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ const personColumns: DataColumnProps<Person, number>[] = [
export default function WithTableExample() {
const { api } = useUuiContext();

const { tableState, setTableState } = useTableState<Person, any>({
columns: personColumns,
});
const { tableState, setTableState } = useTableState<Person, any>({});

const dataSource = useLazyDataSource<Person, number, Person>(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export default function ColumnFiltersTableExample() {
const [value, onValueChange] = useState<DataTableState>({});

const { tableState, setTableState } = useTableState({
columns: personColumns,
filters: filtersConfig,
value: value,
onValueChange: onValueChange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ export default function FiltersPanelExample() {
);

const { tableState, setTableState } = useTableState({
columns: personColumns,
filters: filtersConfig,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ export default function PresetsPanelExample() {
}, [svc.api.presets, uuiModals]);

const tableStateApi = useTableState({
columns: personColumns,
filters: filtersConfig,
initialPresets: initialPresets,
onPresetCreate: svc.api.presets.createPreset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export default function FiltersPanelExample() {
);

const tableStateApi = useTableState({
columns: personColumns,
filters: filtersConfig,
initialPresets: initialPresets,
onPresetCreate: api.presets.createPreset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export default function FiltersPanelExample() {
const tableStateApi = useTableState({
value,
onValueChange,
columns: personColumns,
filters: filtersConfig,
});
const { tableState, setTableState } = tableStateApi;
Expand Down
4 changes: 1 addition & 3 deletions app/src/sandbox/tablePaged/DemoTablePaged.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ export function DemoTablePaged() {
const [isInfoPanelOpened, setIsInfoPanelOpened] = useState(false);
const closeInfoPanel = useCallback(() => setIsInfoPanelOpened(false), []);

const { tableState, setTableState } = useTableState<Person>({
columns: personColumns,
});
const { tableState, setTableState } = useTableState<Person>({});

useEffect(() => {
setTableState({ ...tableState, page: 1, pageSize: 100 });
Expand Down
2 changes: 1 addition & 1 deletion app/src/sandbox/tasks/ProjectTasksDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function ProjectTasksDemo() {
};

// const { tableState, setTableState } = useTableState<any>({ columns });
const { tableState, setTableState } = useTableState({ columns });
const { tableState, setTableState } = useTableState({});

const dataSource = useArrayDataSource<Task, number, DataQueryFilter<Task>>(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export function PaletteTable(props: PaletteTableProps) {
const { tableState, setTableState } = useTableState<TTokensLocalFilter>({
onValueChange,
filters: filtersConfig,
columns: defaultColumns,
value,
});

Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

**What's New**
* [FlexRow][Breaking Change]: Only for `@epam/loveship` package. Now spacing default value works based on `columnGap` props. It shouldn't affect general cases, but previous spacing implementation require additional hack when it was needed to add negative margin value for container to remove corner paddings in multiline case. Now this hack should be removed, since `columnGap` implementation doesn't produce such bug for multiline.
* [useTableState][Breaking Change]: columns prop is removed, since it's not needed now. Just remove it from `useTableState` provided props.
* [Button]: added size `60` to props
* [MultiSwitch]: added size `60` to props
* [TabButton][VerticalTabButton]: decreased paddings, added gaps `3px` between internal items for all sizes according to design
Expand Down
4 changes: 1 addition & 3 deletions uui-core/src/hooks/useTableState/useTableState.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { useCallback, useRef, useState } from 'react';
import isEqual from 'react-fast-compare';
import {
ColumnsConfig, DataColumnProps, DataTableState, FiltersConfig, IEditable, ITablePreset, ITableState, TableFiltersConfig,
ColumnsConfig, DataTableState, FiltersConfig, IEditable, ITablePreset, ITableState, TableFiltersConfig,
} from '../../types';
import { getOrderBetween, orderBy } from '../../helpers';
import { useUuiContext } from '../../services';
import { stateToQueryObject, getValueFromUrl, normalizeTableStateValue, normalizeFilterConfig } from './utils';

interface UseTableStateHookBaseParams<TFilter = Record<string, any>, TViewState = any> {
/** Columns configuration, can be omitted if used without tables */
columns?: DataColumnProps[];
/** Filters configuration, can be omitted if you don't need filters */
filters?: TableFiltersConfig<TFilter>[];
/** Initial presets array */
Expand Down

0 comments on commit 4178705

Please sign in to comment.