From 417870542e636077713f0e9fc9f9134ad95bf470 Mon Sep 17 00:00:00 2001 From: AlekseyManetov Date: Fri, 8 Nov 2024 13:17:04 +0100 Subject: [PATCH] [useTableState][Breaking Change]: columns prop is removed, since it's not needed now. Just remove it from `useTableState` provided props. --- .../demo/tables/masterDetailedTable/MasterDetailedTable.tsx | 1 - app/src/docs/_examples/statusIndicator/WithTable.example.tsx | 4 +--- app/src/docs/_examples/tables/ColumnFiltersTable.example.tsx | 1 - app/src/docs/_examples/tables/FiltersPanelBasic.example.tsx | 1 - app/src/docs/_examples/tables/PresetsPanelBasic.example.tsx | 1 - .../_examples/tables/useTableState/useTableState.example.tsx | 1 - .../useTableState/useTableStateWithIEditable.example.tsx | 1 - app/src/sandbox/tablePaged/DemoTablePaged.tsx | 4 +--- app/src/sandbox/tasks/ProjectTasksDemo.tsx | 2 +- .../tokens/palette/components/paletteTable/paletteTable.tsx | 1 - changelog.md | 1 + uui-core/src/hooks/useTableState/useTableState.ts | 4 +--- 12 files changed, 5 insertions(+), 17 deletions(-) diff --git a/app/src/demo/tables/masterDetailedTable/MasterDetailedTable.tsx b/app/src/demo/tables/masterDetailedTable/MasterDetailedTable.tsx index 91fc396f21..ba06184ef1 100644 --- a/app/src/demo/tables/masterDetailedTable/MasterDetailedTable.tsx +++ b/app/src/demo/tables/masterDetailedTable/MasterDetailedTable.tsx @@ -25,7 +25,6 @@ export function MasterDetailedTable() { const filters = useMemo(() => getFilters(), []); const tableStateApi = useTableState({ - columns: personColumns, initialPresets: initialPresets, onPresetCreate: svc.api.presets.createPreset, onPresetUpdate: svc.api.presets.updatePreset, diff --git a/app/src/docs/_examples/statusIndicator/WithTable.example.tsx b/app/src/docs/_examples/statusIndicator/WithTable.example.tsx index 45094156c6..cd3f3861fa 100644 --- a/app/src/docs/_examples/statusIndicator/WithTable.example.tsx +++ b/app/src/docs/_examples/statusIndicator/WithTable.example.tsx @@ -55,9 +55,7 @@ const personColumns: DataColumnProps[] = [ export default function WithTableExample() { const { api } = useUuiContext(); - const { tableState, setTableState } = useTableState({ - columns: personColumns, - }); + const { tableState, setTableState } = useTableState({}); const dataSource = useLazyDataSource( { diff --git a/app/src/docs/_examples/tables/ColumnFiltersTable.example.tsx b/app/src/docs/_examples/tables/ColumnFiltersTable.example.tsx index 387420fc9a..a8c5e4cf6e 100644 --- a/app/src/docs/_examples/tables/ColumnFiltersTable.example.tsx +++ b/app/src/docs/_examples/tables/ColumnFiltersTable.example.tsx @@ -99,7 +99,6 @@ export default function ColumnFiltersTableExample() { const [value, onValueChange] = useState({}); const { tableState, setTableState } = useTableState({ - columns: personColumns, filters: filtersConfig, value: value, onValueChange: onValueChange, diff --git a/app/src/docs/_examples/tables/FiltersPanelBasic.example.tsx b/app/src/docs/_examples/tables/FiltersPanelBasic.example.tsx index 9e66c54e44..24fe9e6ca7 100644 --- a/app/src/docs/_examples/tables/FiltersPanelBasic.example.tsx +++ b/app/src/docs/_examples/tables/FiltersPanelBasic.example.tsx @@ -152,7 +152,6 @@ export default function FiltersPanelExample() { ); const { tableState, setTableState } = useTableState({ - columns: personColumns, filters: filtersConfig, }); diff --git a/app/src/docs/_examples/tables/PresetsPanelBasic.example.tsx b/app/src/docs/_examples/tables/PresetsPanelBasic.example.tsx index 3dc1a09ae2..45e43cac28 100644 --- a/app/src/docs/_examples/tables/PresetsPanelBasic.example.tsx +++ b/app/src/docs/_examples/tables/PresetsPanelBasic.example.tsx @@ -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, diff --git a/app/src/docs/_examples/tables/useTableState/useTableState.example.tsx b/app/src/docs/_examples/tables/useTableState/useTableState.example.tsx index 049e525f33..00869cf6ca 100644 --- a/app/src/docs/_examples/tables/useTableState/useTableState.example.tsx +++ b/app/src/docs/_examples/tables/useTableState/useTableState.example.tsx @@ -108,7 +108,6 @@ export default function FiltersPanelExample() { ); const tableStateApi = useTableState({ - columns: personColumns, filters: filtersConfig, initialPresets: initialPresets, onPresetCreate: api.presets.createPreset, diff --git a/app/src/docs/_examples/tables/useTableState/useTableStateWithIEditable.example.tsx b/app/src/docs/_examples/tables/useTableState/useTableStateWithIEditable.example.tsx index 96d04523ee..1deac8e893 100644 --- a/app/src/docs/_examples/tables/useTableState/useTableStateWithIEditable.example.tsx +++ b/app/src/docs/_examples/tables/useTableState/useTableStateWithIEditable.example.tsx @@ -99,7 +99,6 @@ export default function FiltersPanelExample() { const tableStateApi = useTableState({ value, onValueChange, - columns: personColumns, filters: filtersConfig, }); const { tableState, setTableState } = tableStateApi; diff --git a/app/src/sandbox/tablePaged/DemoTablePaged.tsx b/app/src/sandbox/tablePaged/DemoTablePaged.tsx index 0e693fec2b..255674e349 100644 --- a/app/src/sandbox/tablePaged/DemoTablePaged.tsx +++ b/app/src/sandbox/tablePaged/DemoTablePaged.tsx @@ -15,9 +15,7 @@ export function DemoTablePaged() { const [isInfoPanelOpened, setIsInfoPanelOpened] = useState(false); const closeInfoPanel = useCallback(() => setIsInfoPanelOpened(false), []); - const { tableState, setTableState } = useTableState({ - columns: personColumns, - }); + const { tableState, setTableState } = useTableState({}); useEffect(() => { setTableState({ ...tableState, page: 1, pageSize: 100 }); diff --git a/app/src/sandbox/tasks/ProjectTasksDemo.tsx b/app/src/sandbox/tasks/ProjectTasksDemo.tsx index 6fd5de6f17..e86b7fd757 100644 --- a/app/src/sandbox/tasks/ProjectTasksDemo.tsx +++ b/app/src/sandbox/tasks/ProjectTasksDemo.tsx @@ -71,7 +71,7 @@ export function ProjectTasksDemo() { }; // const { tableState, setTableState } = useTableState({ columns }); - const { tableState, setTableState } = useTableState({ columns }); + const { tableState, setTableState } = useTableState({}); const dataSource = useArrayDataSource>( { diff --git a/app/src/sandbox/tokens/palette/components/paletteTable/paletteTable.tsx b/app/src/sandbox/tokens/palette/components/paletteTable/paletteTable.tsx index 6c57cb328b..346a4b7728 100644 --- a/app/src/sandbox/tokens/palette/components/paletteTable/paletteTable.tsx +++ b/app/src/sandbox/tokens/palette/components/paletteTable/paletteTable.tsx @@ -63,7 +63,6 @@ export function PaletteTable(props: PaletteTableProps) { const { tableState, setTableState } = useTableState({ onValueChange, filters: filtersConfig, - columns: defaultColumns, value, }); diff --git a/changelog.md b/changelog.md index caad1ce6d7..fb8f148246 100644 --- a/changelog.md +++ b/changelog.md @@ -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 diff --git a/uui-core/src/hooks/useTableState/useTableState.ts b/uui-core/src/hooks/useTableState/useTableState.ts index e5ebb5b2ba..dcb8f5efeb 100644 --- a/uui-core/src/hooks/useTableState/useTableState.ts +++ b/uui-core/src/hooks/useTableState/useTableState.ts @@ -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, 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[]; /** Initial presets array */