From 4967a51944c139d102fcfc04ada5a42c725ed7c2 Mon Sep 17 00:00:00 2001 From: Alican Erdurmaz Date: Wed, 31 Jul 2024 10:05:10 +0300 Subject: [PATCH] feat: `tableQueryResult` name to `tableQuery` (#6172) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ali Emir Şen Co-authored-by: Batuhan Wilhelm --- .changeset/itchy-dancers-walk.md | 18 +++++ .changeset/rich-swans-prove.md | 18 +++++ .changeset/sixty-countries-nail.md | 27 +++++++ .changeset/unlucky-fans-punch.md | 17 ++++ .../blog/2022-03-22-refine-with-react95.md | 2 +- .../blog/2023-01-17-airtable-crud-app.md | 14 ++-- .../blog/2023-04-13-refine-invoicer-4.md | 2 +- .../2023-07-02-refine-tremor-dashboard.md | 14 ++-- .../2023-07-26-refine-primereact-dashboard.md | 72 ++++++++--------- .../blog/2023-09-06-daisy-ui-panel.md | 2 +- .../blog/2023-09-20-next-ui-panel.md | 68 ++++++++-------- documentation/blog/2023-10-31-react-table.md | 4 +- documentation/blog/2024-03-19-ts-shadcn.md | 6 +- .../blog/2024-06-25-next-refine-pwa.md | 10 +-- .../_partial-basic-usage-live-preview.md | 6 +- .../_partial-filtering-live-preview.md | 9 +-- .../_partial-pagination-live-preview.md | 6 +- .../_partial-relational-data-live-preview.md | 6 +- .../_partial-sorting-live-preview.md | 6 +- .../docs/data/hooks/use-table/index.md | 26 +++--- .../docs/data/packages/supabase/index.md | 2 +- .../docs/guides-concepts/faq/index.md | 1 + .../general-concepts/layout/mantine.tsx | 2 +- .../docs/guides-concepts/routing/index.md | 6 +- .../routing/nextjs/use-table-usage.tsx | 4 +- .../routing/react-router/use-table-usage.tsx | 4 +- .../routing/remix/use-table-usage.tsx | 4 +- .../guides-concepts/tables/example/core.tsx | 6 +- .../tables/example/filtering.tsx | 6 +- .../tables/example/pagination.tsx | 6 +- .../tables/example/relationship.tsx | 6 +- .../tables/example/sorting.tsx | 6 +- .../react-hook-form/use-form/index.md | 4 +- .../react-hook-form/use-modal-form/index.md | 18 ++--- .../react-hook-form/use-steps-form/index.md | 6 +- .../_partial-relational-live-preview.md | 2 +- .../tanstack-table/use-table/index.md | 2 +- .../routing/integrations/next-js/index.md | 10 +-- .../docs/routing/integrations/remix/index.md | 6 +- .../hooks/use-editable-table/index.md | 2 +- .../ant-design/hooks/use-simple-list/index.md | 22 +++-- .../ant-design/hooks/use-table/index.md | 42 +++++----- .../chakra-ui/introduction/index.md | 2 +- .../introduction/previews/auth-page.tsx | 2 +- .../introduction/previews/basic-views.tsx | 2 +- .../introduction/previews/example.tsx | 2 +- .../introduction/previews/layout-next-js.tsx | 2 +- .../previews/layout-react-router-dom.tsx | 2 +- .../introduction/previews/layout-remix.tsx | 2 +- .../introduction/previews/theming.tsx | 2 +- .../introduction/previews/usage-next-js.tsx | 2 +- .../previews/usage-react-router-dom.tsx | 2 +- .../introduction/previews/usage-remix.tsx | 2 +- .../mantine/hooks/use-drawer-form/index.md | 4 +- .../mantine/hooks/use-modal-form/index.md | 6 +- .../mantine/hooks/use-steps-form/index.md | 2 +- .../mantine/introduction/index.md | 2 +- .../introduction/previews/auth-page.tsx | 2 +- .../introduction/previews/basic-views.tsx | 2 +- .../mantine/introduction/previews/example.tsx | 2 +- .../introduction/previews/layout-next-js.tsx | 2 +- .../previews/layout-react-router-dom.tsx | 2 +- .../introduction/previews/layout-remix.tsx | 2 +- .../mantine/introduction/previews/theming.tsx | 2 +- .../introduction/previews/usage-next-js.tsx | 2 +- .../previews/usage-react-router-dom.tsx | 2 +- .../introduction/previews/usage-remix.tsx | 2 +- .../components/buttons/delete-button/index.md | 4 +- .../material-ui/hooks/use-data-grid/index.md | 8 +- .../data-provider-integration/index.md | 2 +- .../data-provider-integration/sandpack.tsx | 2 +- .../tutorial/essentials/tables/index.md | 8 +- .../tutorial/essentials/tables/sandpack.tsx | 8 +- .../react-router/index.md | 2 +- .../react-router/sandpack.tsx | 2 +- .../routing/navigation/react-router/index.md | 2 +- .../navigation/react-router/sandpack.tsx | 2 +- .../syncing-state/react-router/index.md | 2 +- .../syncing-state/react-router/sandpack.tsx | 2 +- .../app-crm/src/routes/companies/list.tsx | 2 +- examples/app-crm/src/routes/contacts/list.tsx | 2 +- examples/app-crm/src/routes/quotes/list.tsx | 81 ++++++++++--------- .../src/pages/posts/list.tsx | 2 +- .../auth-chakra-ui/src/pages/posts/list.tsx | 2 +- .../auth-mantine/src/pages/posts/list.tsx | 2 +- .../base-chakra-ui/src/pages/posts/list.tsx | 2 +- .../base-mantine/src/pages/posts/list.tsx | 2 +- examples/blog-ecommerce/pages/index.tsx | 23 +++--- examples/blog-next-refine-pwa/pages/index.tsx | 2 +- .../src/pages/post/list.tsx | 2 +- .../src/components/table/RecentSalesTable.tsx | 2 +- .../src/pages/categories/list.tsx | 2 +- .../src/pages/products/list.tsx | 2 +- .../dashboard/recentSales/index.tsx | 2 +- .../src/pages/categories/list.tsx | 2 +- .../src/pages/products/list.tsx | 2 +- .../src/pages/dashboard/details/index.tsx | 2 +- .../blog-win95/src/pages/categories/list.tsx | 2 +- examples/blog-win95/src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/couriers/list.tsx | 4 +- .../dashboard/orderTimeline/index.tsx | 29 ++++--- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/all-properties.tsx | 2 +- .../src/pages/canvases/featured-list.tsx | 2 +- examples/pixels/src/pages/canvases/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- examples/store/pages/index.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../table-handson/src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/table/index.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/blog-posts/list.tsx | 2 +- .../src/pages/blog-posts/list.tsx | 2 +- .../src/pages/blog-posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../src/components/table-members/index.tsx | 2 +- .../src/routes/video-club/members/list.tsx | 2 +- .../routes/video-club/tapes/select-member.tsx | 2 +- .../routes/video-club/tapes/select-title.tsx | 2 +- .../src/routes/video-club/titles/list.tsx | 2 +- .../src/pages/posts/list.tsx | 2 +- .../list/useSimpleList/useSimpleList.spec.ts | 16 ++++ .../hooks/list/useSimpleList/useSimpleList.ts | 8 +- .../hooks/table/useTable/useTable.spec.tsx | 18 ++++- .../antd/src/hooks/table/useTable/useTable.ts | 2 + packages/codemod/src/index.ts | 8 ++ .../use-simple-list-query-result.ts | 54 +++++++++++++ .../transformations/use-table-query-result.ts | 57 +++++++++++++ .../core/src/hooks/useTable/index.spec.ts | 16 ++++ packages/core/src/hooks/useTable/index.ts | 5 ++ .../mui/src/hooks/useDataGrid/index.spec.ts | 21 +++++ packages/mui/src/hooks/useDataGrid/index.ts | 2 + packages/react-table/src/useTable/index.ts | 2 +- 158 files changed, 688 insertions(+), 384 deletions(-) create mode 100644 .changeset/itchy-dancers-walk.md create mode 100644 .changeset/rich-swans-prove.md create mode 100644 .changeset/sixty-countries-nail.md create mode 100644 .changeset/unlucky-fans-punch.md create mode 100644 packages/codemod/src/transformations/use-simple-list-query-result.ts create mode 100644 packages/codemod/src/transformations/use-table-query-result.ts diff --git a/.changeset/itchy-dancers-walk.md b/.changeset/itchy-dancers-walk.md new file mode 100644 index 000000000000..aac45e61fa9e --- /dev/null +++ b/.changeset/itchy-dancers-walk.md @@ -0,0 +1,18 @@ +--- +"@refinedev/core": minor +--- + +feat: [`useTable`](https://refine.dev/docs/data/hooks/use-table/)'s `tableQueryResult` is deprecated, use `tableQuery` instead. #6169 + +```diff +import { useTable } from '@refinedev/core'; + +- const { tableQueryResult } = useTable(); ++ const { tableQuery } = useTable(); +``` + +> ✨ You can use `@refinedev/codemod` to automatically migrate your codebase. Simply run the following command in your project's root directory: +> +> ```bash +> npx @refinedev/codemod@latest use-table-query-result +> ``` diff --git a/.changeset/rich-swans-prove.md b/.changeset/rich-swans-prove.md new file mode 100644 index 000000000000..1c5b87b9e1f5 --- /dev/null +++ b/.changeset/rich-swans-prove.md @@ -0,0 +1,18 @@ +--- +"@refinedev/mui": minor +--- + +feat: [`useDataGrid`](https://refine.dev/docs/ui-integrations/material-ui/hooks/use-data-grid/)'s `tableQueryResult` is deprecated, use `tableQuery` instead. #6169 + +```diff +import { useDataGrid } from '@refinedev/mui'; + +- const { tableQueryResult } = useDataGrid(); ++ const { tableQuery } = useDataGrid(); +``` + +> ✨ You can use `@refinedev/codemod` to automatically migrate your codebase. Simply run the following command in your project's root directory: +> +> ```bash +> npx @refinedev/codemod@latest use-table-query-result +> ``` diff --git a/.changeset/sixty-countries-nail.md b/.changeset/sixty-countries-nail.md new file mode 100644 index 000000000000..35cba580f266 --- /dev/null +++ b/.changeset/sixty-countries-nail.md @@ -0,0 +1,27 @@ +--- +"@refinedev/antd": minor +--- + +feat: [`useTable`](https://refine.dev/docs/ui-integrations/ant-design/hooks/use-table/)'s `tableQueryResult` is deprecated, use `tableQuery` instead. #6169 + +```diff +import { useTable } from '@refinedev/core'; + +- const { tableQueryResult } = useTable(); ++ const { tableQuery } = useTable(); +``` + +feat: [`useSimpleList`](https://refine.dev/docs/ui-integrations/ant-design/hooks/use-simple-list/)'s `queryResult` is deprecated, use `query` instead. #6169 + +```diff +import { useSimpleList } from '@refinedev/antd'; + +- const { queryResult } = useSimpleList(); ++ const { query } = useSimpleList(); +``` + +> ✨ You can use `@refinedev/codemod` to automatically migrate your codebase. Simply run the following command in your project's root directory: +> +> ```bash +> npx @refinedev/codemod@latest use-simple-list-query-result +> ``` diff --git a/.changeset/unlucky-fans-punch.md b/.changeset/unlucky-fans-punch.md new file mode 100644 index 000000000000..88edcedd4ef8 --- /dev/null +++ b/.changeset/unlucky-fans-punch.md @@ -0,0 +1,17 @@ +--- +"@refinedev/codemod": minor +--- + +feat: added `npx @refinedev/codemod@latest use-table-query-result` to automatically refactor `useTable`'s `tableQueryResult` to `tableQuery` #6163 + +```diff +- const { tableQueryResult } = useTable(); // or useDataGrid ++ const { tableQuery } = useTable(); +``` + +feat: added `npx @refinedev/codemod@latest use-simple-list-query-result` to automatically refactor `useSimpleList`'s `queryResult` to `query` #6163 + +```diff +- const { queryResult } = useSimpleList(); ++ const { query } = useSimpleList() +``` diff --git a/documentation/blog/2022-03-22-refine-with-react95.md b/documentation/blog/2022-03-22-refine-with-react95.md index a432dd519895..363ab0a61aa0 100644 --- a/documentation/blog/2022-03-22-refine-with-react95.md +++ b/documentation/blog/2022-03-22-refine-with-react95.md @@ -1055,7 +1055,7 @@ export const PostList = () => { setPageIndex, setPageSize, refineCore: { - tableQueryResult: { isLoading }, + tableQuery: { isLoading }, }, } = useTable({ columns, diff --git a/documentation/blog/2023-01-17-airtable-crud-app.md b/documentation/blog/2023-01-17-airtable-crud-app.md index 0dd0bf5cfd58..87e432da8da7 100644 --- a/documentation/blog/2023-01-17-airtable-crud-app.md +++ b/documentation/blog/2023-01-17-airtable-crud-app.md @@ -329,7 +329,7 @@ export const Layout: React.FC = ({ children }) => { const { push } = useNavigation(); return ( -
+
@@ -561,7 +561,7 @@ export const PostList: React.FC = () => { {flexRender( header.column.columnDef.header, @@ -580,7 +580,7 @@ export const PostList: React.FC = () => { return ( {flexRender( cell.column.columnDef.cell, @@ -684,7 +684,7 @@ export const PostList: React.FC = () => { getRowModel, setOptions, refineCore: { - tableQueryResult: { data: tableData }, + tableQuery: { data: tableData }, }, } = useTable({ columns }); @@ -726,7 +726,7 @@ export const PostList: React.FC = () => { {flexRender( header.column.columnDef.header, @@ -745,7 +745,7 @@ export const PostList: React.FC = () => { return ( {flexRender( cell.column.columnDef.cell, @@ -1526,7 +1526,7 @@ export const PostList: React.FC = () => { getRowModel, setOptions, refineCore: { - tableQueryResult: { data: tableData }, + tableQuery: { data: tableData }, }, getState, setPageIndex, diff --git a/documentation/blog/2023-04-13-refine-invoicer-4.md b/documentation/blog/2023-04-13-refine-invoicer-4.md index 29559aa22c9c..8d47d06f9aae 100644 --- a/documentation/blog/2023-04-13-refine-invoicer-4.md +++ b/documentation/blog/2023-04-13-refine-invoicer-4.md @@ -867,7 +867,7 @@ Endowed a due patience, we can see this in action among many others in the `@ref ```tsx title="node_modules/@refinedev/antd/src/hooks/table/useTable/useTable.ts" const { - tableQueryResult, + tableQuery, current, setCurrent, pageSize, diff --git a/documentation/blog/2023-07-02-refine-tremor-dashboard.md b/documentation/blog/2023-07-02-refine-tremor-dashboard.md index c56cfb4968c1..4bef0482a22a 100644 --- a/documentation/blog/2023-07-02-refine-tremor-dashboard.md +++ b/documentation/blog/2023-07-02-refine-tremor-dashboard.md @@ -170,7 +170,7 @@ const currencyFormatter = Intl.NumberFormat("en-US", { }); export default () => ( - + Revenue {currencyFormatter.format(3_500)} @@ -597,7 +597,7 @@ export const DashboardPage: React.FC = () => { - +
@@ -842,7 +842,7 @@ export const DashboardPage: React.FC = () => { - + //highlight-start -
+
); @@ -1246,7 +1246,7 @@ export const Details = () => { getHeaderGroups, getRowModel, refineCore: { - tableQueryResult: { data: tableData }, + tableQuery: { data: tableData }, }, getState, setPageIndex, @@ -1402,7 +1402,7 @@ export const Details = () => { { const { value } = e.target; diff --git a/documentation/blog/2023-07-26-refine-primereact-dashboard.md b/documentation/blog/2023-07-26-refine-primereact-dashboard.md index 246545b5e009..3f0c58d209ad 100644 --- a/documentation/blog/2023-07-26-refine-primereact-dashboard.md +++ b/documentation/blog/2023-07-26-refine-primereact-dashboard.md @@ -220,7 +220,7 @@ import { Button } from "primereact/Button"; export const Dashboard = () => { return ( -
+
); @@ -338,14 +338,14 @@ export const KpiCard = ({ if (total < trend) { return (
- +{calc}% + +{calc}%
); } return (
- -{calc}% + -{calc}%
); }; @@ -354,15 +354,15 @@ export const KpiCard = ({ +
- {title} -
+ {title} +
{formatTotal(total)}
@@ -797,7 +797,7 @@ import { IOrder, IOrderStatus } from "../../../interfaces"; export const RecentSales = () => { const { - tableQueryResult, + tableQuery, pageCount, current, pageSize, @@ -814,7 +814,7 @@ export const RecentSales = () => { }, }); - const orders = tableQueryResult?.data?.data; + const orders = tableQuery?.data?.data; const formatCurrency = (value: number) => { return value.toLocaleString("en-US", { @@ -867,7 +867,7 @@ export const RecentSales = () => { }; const header = ( -
+
-
+
@@ -1713,8 +1713,8 @@ export const ProductEdit = () => { -
+
+
-
+
@@ -1941,7 +1941,7 @@ export const ProductShow = () => { +
-
+
@@ -2459,8 +2459,8 @@ export const CategoryEdit = () => { -
+
+
-
+
@@ -2536,7 +2536,7 @@ export const CategoryShow = () => { +
} bottomContent={ -
+
{ {column.header} @@ -1911,7 +1911,7 @@ export const ProductCreate = () => { }} />
-
+
-
+
- +

Product details

@@ -2274,13 +2274,13 @@ export const ProductShow = () => { alt={product.name} /> ) : null} -

Name

+

Name

{product?.name}

-

Price

+

Price

{currencyFormatter.format(product?.price ?? 0)}

-

Category

+

Category

{categoryData?.data.title}

-

Description

+

Description

{product?.description}

@@ -2415,7 +2415,7 @@ const columns = [ export const CategoryList = () => { const { - tableQueryResult, + tableQuery, pageCount, current, pageSize, @@ -2438,13 +2438,13 @@ export const CategoryList = () => { direction: "ascending", }); - const categories = tableQueryResult?.data?.data ?? []; + const categories = tableQuery?.data?.data ?? []; const renderCell = useCallback((columnKey: string, item: IProduct) => { if (columnKey === "actions") { return ( -
+
-
+
{
} bottomContent={ -
+
{ {column.header} @@ -2731,7 +2731,7 @@ export const CategoryCreate = () => { }} />
-
+
-
+
- +

Category details

{category?.cover ? ( {category.title} ) : null} -

Id

+

Id

{category?.id ?? 0}

-

Title

+

Title

{category?.title ?? ""}

@@ -2968,16 +2968,16 @@ export const Menu = () => { const { menuItems } = useMenu(); return (