-
Notifications
You must be signed in to change notification settings - Fork 0
feat: apply PRs #7501, #7495, #7473 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@refinedev/antd": minor | ||
| --- | ||
|
|
||
| Added `onParse` callback to `useTable` and `useSimpleList` hooks to support custom transformation/mapping of URL-synced filters back into search form fields. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| VITE_CATEGORIES_URL="http://localhost:4002/assets/categories.js" | ||
| VITE_CATEGORIES_URL="http://localhost:4002/remoteEntry.js" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ | |
| "react-router": "^7.0.2" | ||
| }, | ||
| "devDependencies": { | ||
| "@originjs/vite-plugin-federation": "^1.2.3", | ||
| "@module-federation/vite": "^1.16.8", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: This dependency narrows the supported Node 20 range to Prompt for AI agents |
||
| "@types/node": "^20", | ||
| "@types/react": "^19.1.0", | ||
| "@types/react-dom": "^19.1.0", | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,53 +1,60 @@ | ||
| import federation from "@originjs/vite-plugin-federation"; | ||
| import { federation } from "@module-federation/vite"; | ||
| import react from "@vitejs/plugin-react"; | ||
| import * as dns from "dns"; | ||
| import { defineConfig } from "vite"; | ||
| import { defineConfig, loadEnv } from "vite"; | ||
| import tsconfigPaths from "vite-tsconfig-paths"; | ||
|
|
||
| dns.setDefaultResultOrder("verbatim"); | ||
|
|
||
| // https://vitejs.dev/config/ | ||
| export default defineConfig({ | ||
| plugins: [ | ||
| react(), | ||
| federation({ | ||
| name: "host", | ||
| remotes: [ | ||
| { | ||
| export default defineConfig(({ mode }) => { | ||
| const env = loadEnv(mode, __dirname, ""); | ||
|
|
||
| return { | ||
| plugins: [ | ||
| react(), | ||
| federation({ | ||
| name: "host", | ||
| dts: false, | ||
| remotes: { | ||
| blog_posts: { | ||
| external: "http://localhost:4001/assets/blog_posts.js", | ||
| from: "vite", | ||
| externalType: "url", | ||
| type: "module", | ||
| name: "blog_posts", | ||
| entry: "http://localhost:4001/remoteEntry.js", | ||
| entryGlobalName: "blog_posts", | ||
| shareScope: "default", | ||
| }, | ||
| }, | ||
| { | ||
| categories: { | ||
| external: "Promise.resolve(window.categoriesUrl)", | ||
| from: "vite", | ||
| externalType: "promise", | ||
| type: "module", | ||
| name: "categories", | ||
| entry: | ||
| env.VITE_CATEGORIES_URL || "http://localhost:4002/remoteEntry.js", | ||
| entryGlobalName: "categories", | ||
| shareScope: "default", | ||
| }, | ||
| }, | ||
| ], | ||
| shared: [ | ||
| "react", | ||
| "react-dom", | ||
| "react-router-dom", | ||
| "@refinedev/core", | ||
| "@refinedev/antd", | ||
| "antd", | ||
| ], | ||
| }), | ||
| tsconfigPaths({ root: __dirname }), | ||
| ], | ||
| filename: "remoteEntry.js", | ||
| shared: [ | ||
| "react", | ||
| "react-dom", | ||
| "react-router", | ||
| "@refinedev/core", | ||
| "@refinedev/antd", | ||
| "antd", | ||
| ], | ||
| }), | ||
| tsconfigPaths({ root: __dirname }), | ||
| ], | ||
|
|
||
| preview: { | ||
| host: "localhost", | ||
| port: 4000, | ||
| strictPort: true, | ||
| }, | ||
| build: { | ||
| target: "esnext", | ||
| minify: false, | ||
| cssCodeSplit: false, | ||
| }, | ||
| preview: { | ||
| host: "localhost", | ||
| port: 4000, | ||
| strictPort: true, | ||
| }, | ||
| build: { | ||
| target: "esnext", | ||
| minify: false, | ||
| cssCodeSplit: false, | ||
| }, | ||
| }; | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ import type { FilterValue, SorterResult } from "../../../definitions/table"; | |
| export type useTableProps<TQueryFnData, TError, TSearchVariables, TData> = | ||
| useTablePropsCore<TQueryFnData, TError, TData> & { | ||
| onSearch?: (data: TSearchVariables) => CrudFilters | Promise<CrudFilters>; | ||
| onParse?: (filters: CrudFilters) => TSearchVariables; | ||
| }; | ||
|
|
||
| export type useTableReturnType< | ||
|
|
@@ -61,6 +62,7 @@ export const useTable = < | |
| TData extends BaseRecord = TQueryFnData, | ||
| >({ | ||
| onSearch, | ||
| onParse, | ||
| pagination: paginationFromProp, | ||
| filters: filtersFromProp, | ||
| sorters: sortersFromProp, | ||
|
|
@@ -126,28 +128,33 @@ export const useTable = < | |
|
|
||
| React.useEffect(() => { | ||
| if (shouldSyncWithLocation) { | ||
| // get registered fields of form | ||
| const registeredFields = formSF.form.getFieldsValue() as Record< | ||
| string, | ||
| any | ||
| >; | ||
| // map `filters` for registered fields | ||
| const filterFilterMap = Object.keys(registeredFields).reduce( | ||
| (acc, curr) => { | ||
| // find filter for current field | ||
| const filter = filters.find( | ||
| (filter) => "field" in filter && filter.field === curr, | ||
| ); | ||
| // if filter exists, set value to filter value | ||
| if (filter) { | ||
| acc[curr] = filter?.value; | ||
| } | ||
| return acc; | ||
| }, | ||
| {} as Record<string, any>, | ||
| ); | ||
| // set values to form | ||
| formSF.form.setFieldsValue(filterFilterMap as any); | ||
| if (onParse) { | ||
| const parsedValues = onParse(filters); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The parsed search form becomes stale after filters change while Prompt for AI agents |
||
| formSF.form.setFieldsValue(parsedValues as any); | ||
| } else { | ||
| // get registered fields of form | ||
| const registeredFields = formSF.form.getFieldsValue() as Record< | ||
| string, | ||
| any | ||
| >; | ||
| // map `filters` for registered fields | ||
| const filterFilterMap = Object.keys(registeredFields).reduce( | ||
| (acc, curr) => { | ||
| // find filter for current field | ||
| const filter = filters.find( | ||
| (filter) => "field" in filter && filter.field === curr, | ||
| ); | ||
| // if filter exists, set value to filter value | ||
| if (filter) { | ||
| acc[curr] = filter?.value; | ||
| } | ||
| return acc; | ||
| }, | ||
| {} as Record<string, any>, | ||
| ); | ||
| // set values to form | ||
| formSF.form.setFieldsValue(filterFilterMap as any); | ||
| } | ||
| } | ||
| }, [shouldSyncWithLocation]); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: The example's supported Node range is now narrower than its
enginesdeclaration:@module-federation/vite@1.16.8requires^20.19.0 || >=22.12.0, so installs under Node 20.0–20.18 can produce an engine failure (or fail with strict engine checks). Align the app's Node engine/documentation with the dependency or select a plugin version that supports the declared range.Prompt for AI agents