Skip to content

Commit

Permalink
Merge branch 'releases/june' into iss5606
Browse files Browse the repository at this point in the history
  • Loading branch information
issa012 authored May 25, 2024
2 parents 43de99b + c4b8761 commit 8807bc5
Show file tree
Hide file tree
Showing 175 changed files with 2,560 additions and 1,100 deletions.
5 changes: 5 additions & 0 deletions .changeset/big-planets-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@refinedev/cli": patch
---

fix: remove hardcoded path prefix from bin resolve for remix run command.
9 changes: 9 additions & 0 deletions .changeset/brave-chicken-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@refinedev/cli": patch
"@refinedev/devtools-server": patch
"@refinedev/devtools-ui": patch
---

fix: capitalize Refine

Capitalized "Refine" in the user-facing texts
7 changes: 7 additions & 0 deletions .changeset/chatty-beds-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@refinedev/cli": patch
---

fix(cli): prevent exit on devtools error

Updated the `dev` command's devtools runner logic to prevent the process from exiting when devtools server fails to start. Previously, the process would exit if devtools server failed to start regardless of the development server's status.
7 changes: 7 additions & 0 deletions .changeset/clever-tigers-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@refinedev/antd": patch
---

chore: unpin `antd` version that was causing build issues

With `antd`'s `5.17.0` version, Next.js apps were stuck in the build process. To prevent this from breaking all Refine apps with Next.js, we've pinned the version to `5.16.5` as a workaround. Since then, the issue has been resolved by updating an internal dependency of `antd`, we no longer need to pin the version.
7 changes: 7 additions & 0 deletions .changeset/curly-files-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@refinedev/antd": patch
---

feat(antd): search form in useTable should work with syncWithLocation

Even though the form is managed by `useTable` hook from `@refinedev/antd`. It wasn't respecting the `syncWithLocation` prop to set values accordingly at initial render when registered fields are matching with the query params. Now it will look for matching fields and set values accordingly from synced filters.
60 changes: 60 additions & 0 deletions .changeset/famous-walls-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
"@refinedev/antd": patch
---

fix: Filtering [`<Table />`](https://refine.dev/docs/ui-integrations/ant-design/hooks/use-table/) with [`<FilterDropdown />`](https://refine.dev/docs/ui-integrations/ant-design/components/filter-dropdown) and [`<DatePicker />`](https://ant.design/components/date-picker) doesn't work with `syncWithLocation`. #5933

feat: Added [`rangePickerFilterMapper`](https://refine.dev/docs/ui-integrations/ant-design/components/filter-dropdown/#rangepickerfiltermapper) utility function to convert `selectedKeys` to satisfy both the Refine and [`<DatePicker.RangePicker />`](https://ant.design/components/date-picker).

Usage example:

```tsx
import { getDefaultFilter } from "@refinedev/core";
import {
DateField,
FilterDropdown,
rangePickerFilterMapper,
useTable,
} from "@refinedev/antd";
import { Table, DatePicker } from "antd";

export const Posts = () => {
const { tableProps, filters } = useTable({
filters: {
initial: [
{
field: "created_at",
value: ["2022-01-01", "2022-01-31"],
operator: "between",
},
],
},
});

return (
<Table {...tableProps} rowKey="id">
<Table.Column dataIndex="id" title="ID" />
<Table.Column dataIndex="title" title="Title" />
<Table.Column
dataIndex="createdAt"
title="Created At"
filterDropdown={(props) => (
<FilterDropdown
{...props}
mapValue={(selectedKeys, event) => {
return rangePickerFilterMapper(selectedKeys, event);
}}
>
<DatePicker.RangePicker />
</FilterDropdown>
)}
defaultFilteredValue={getDefaultFilter(
"created_at",
filters,
"between",
)}
/>
</Table>
);
};
```
7 changes: 7 additions & 0 deletions .changeset/few-ads-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@refinedev/core": minor
"@refinedev/supabase": minor
---

Added ina and nina CrudOperators. Added filtering by these operators to Supabase data provider
#5902
7 changes: 7 additions & 0 deletions .changeset/few-sheep-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@refinedev/core": patch
---

fix(core): update default titles

Previously, default titles included lowercase "refine", which was not correct. This commit updates the default titles to include "Refine" instead.
6 changes: 6 additions & 0 deletions .changeset/gorgeous-bugs-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@refinedev/simple-rest": patch
---

fix: "mapOperator" test type error.
Some `CrudOperators` not supported in `operatorMappings` type but still extended from `CrudOperators`. To fix that we use `Partial` type for `operatorMappings` type.
7 changes: 7 additions & 0 deletions .changeset/modern-rings-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@refinedev/hasura": patch
---

fix: [`hasuraFilters`](https://github.com/refinedev/refine/blob/master/packages/hasura/src/utils/generateFilters.ts) object type.

All fields in the [`CrudOperators`](https://github.com/refinedev/refine/blob/master/packages/core/src/contexts/data/types.ts#L218) interface must be used in the [`hasuraFilters`](https://github.com/refinedev/refine/blob/master/packages/hasura/src/utils/generateFilters.ts) object type, but some fields may not be supported by Hasura. To resolve this, the object type has been changed to partial.
7 changes: 7 additions & 0 deletions .changeset/ninety-cameras-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@refinedev/core": patch
---

refactor: omit `to` parameter if at root when unauthenticated

If user is not authenticated, `<Authenticated />` redirects to the provided route and appends the current route to the `to` parameter. With this change, if the current route is the root (`/`), the `to` parameter will be omitted.
7 changes: 7 additions & 0 deletions .changeset/ninety-pots-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@refinedev/mui": patch
---

fix: `transformMuiOperatorToCrudOperator` return type is wrong.

This PR fixes the return type of `transformMuiOperatorToCrudOperator` function. It has return type `Exclude<CrudOperators, "or">` but it also should exclude `and` operator to satisfy `LogicalFilter` type.
7 changes: 7 additions & 0 deletions .changeset/poor-adults-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@refinedev/cli": patch
---

feat(cli): prompt to update all in `update` command

Previously, if users doesn't provide `--all` option, `update` command will display an interactive prompt to pick which packages to update. Now, before displaying the prompt, it will ask if users want to update all packages.
7 changes: 7 additions & 0 deletions .changeset/shiny-cougars-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@refinedev/devtools-shared": patch
---

chore: prevent websocket closing errors in console

When `<DevtoolsProvider />` component is mounted in apps with React's strict mode, it will try to initialize the websocket connection twice and first one will be closed immediately before the connection is established. This PR will delay closing the websocket connection until it's established properly to prevent these errors from appearing in the console.
11 changes: 11 additions & 0 deletions .changeset/smooth-shirts-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@refinedev/core": patch
---

feat: `<GitHubBanner />` has `paddingLeft: 200px` by default to make space for the sidebar. This is not needed when the sidebar is not present.

From on, `<GitHubBanner />` style property can be overridden by passing `containerStyle` prop.

```jsx
<GitHubBanner containerStyle={{ paddingLeft: 0 }} />
```
8 changes: 8 additions & 0 deletions .changeset/stupid-rules-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@refinedev/devtools-server": patch
"@refinedev/devtools-shared": patch
---

refactor: use same port for ws and http servers

This PR merges WebSocket and Http server ports into one (5001) to simplify the configuration and avoid port conflicts. Previously the WebSocket server was running on port 5002 and the Http server on port 5001. Now both servers are running on port 5001.
7 changes: 7 additions & 0 deletions .changeset/tender-hats-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@refinedev/devtools-server": patch
---

chore(devtools-server): customizable exit function

This change allows you to customize the exit function of the devtools server when using it via API.
8 changes: 8 additions & 0 deletions .changeset/wise-dots-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@refinedev/devtools-server": patch
"@refinedev/devtools-ui": patch
---

fix: remove annoying auth error at initial project loads

When users create a new project or their devtools token expires, their console is polluted with network errors due to missing authentication. This PR removes these errors by handling auth requests in a user-friendly way.
6 changes: 6 additions & 0 deletions .changeset/witty-teachers-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@refinedev/nestjsx-crud": patch
---

fix: "mapOperator" test type error.
Some `CrudOperators` not supported in `mapOperator` type but still extended from `CrudOperators`. To fix that we use `Partial` type for `mapOperator` function.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ type CrudOperators =
| "gte"
| "in"
| "nin"
| "ina"
| "nina"
| "contains"
| "ncontains"
| "containss"
Expand Down Expand Up @@ -234,7 +236,7 @@ filter = [
];
```

Here the query will look like:
Here the query will look like:
`"status" == "published" AND ("createdAt" == "2022-01-01" OR "createdAt" == "2022-01-02")`

## Handle filters in a data provider
Expand Down
2 changes: 2 additions & 0 deletions documentation/docs/core/interface-references/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type CrudOperators =
| "gte" // Greater than or equal to
| "in" // Included in an array
| "nin" // Not included in an array
| "ina" // Column contains every element in an array
| "nina" // Column doesn't contain every element in an array
| "contains" // Contains
| "ncontains" // Doesn't contain
| "containss" // Contains, case sensitive
Expand Down
2 changes: 1 addition & 1 deletion documentation/docs/guides-concepts/development/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ As an alternative, you can also install the `@refinedev/devtools-server` package

**Required Ports**

Devtools server will run on port `5001` and also run a WebSocket server on port `5002`. Make sure these ports are available on your machine. Both of these ports are required for devtools to work properly and maintain a connection between your app and the devtools interface.
Devtools server will run on port `5001`. Devtools will serve HTTP and WebSocket connections on this port. Make sure the port is available on your machine.

## Using Inferencer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,18 @@ These are to be passed from [`<Table.Column>`'s filterDropdown](https://ant.desi

### mapValue

Determines the value passed to children. `mapValue` takes `selectedKeys` as an argument.
The `mapValue` function is a utility function used to transform the `selectedKeys` based on certain events.

For example when using `useSelect` for `<Select>` component, in which case, the values must be mapped to `number`s using `mapValue`.
```ts
function mapValue(selectedKeys: React.Key[], event: "onChange" | "value"): any;
```

- `selectedKeys`: The selected keys from the dropdown.
- `event`: The event that triggered the `mapValue` function. It can be either `onChange` or `value`.
- `onChange`: The event that is triggered when the value of the dropdown changes. It is used to map the value to the format that the Refine expects(data provider, syncWithLocation etc.).
- `value`: When the value needs to be mapped for the child component.

For example when using [`useSelect`](/docs/ui-integrations/ant-design/hooks/use-select/) for [`<Select />`](https://ant.design/components/select/) component, in which case, the values must be mapped to `number`s using `mapValue`.

```tsx
import { getDefaultFilter } from "@refinedev/core";
Expand Down Expand Up @@ -137,6 +146,105 @@ const { selectProps: categorySelectProps } = useSelect<ICategory>({
</Table>;
```

#### rangePickerFilterMapper

A more complex example is using a filter dropdown with a date picker.

Imagine you need to filter data based on a date range where Refine's data provider expects dates in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, but Ant Design's [`<DatePicker.RangePicker />`](https://ant.design/components/date-picker) uses Dayjs objects. To solve this, use the `mapValue` and [`rangePickerFilterMapper`](https://github.com/refinedev/refine/blob/master/packages/antd/src/definitions/filter-mappers/index.ts) utility function to convert `selectedKeys` to satisfy both the data provider and `<DatePicker.RangePicker />`.

```tsx
import { getDefaultFilter } from "@refinedev/core";
import {
DateField,
FilterDropdown,
rangePickerFilterMapper,
useTable,
} from "@refinedev/antd";
import { Table, DatePicker } from "antd";

export const Posts = () => {
const { tableProps, filters } = useTable({
filters: {
initial: [
{
field: "created_at",
value: ["2022-01-01", "2022-01-31"],
operator: "between",
},
],
},
});

return (
<Table {...tableProps} rowKey="id">
<Table.Column dataIndex="id" title="ID" />
<Table.Column dataIndex="title" title="Title" />
<Table.Column
dataIndex="createdAt"
title="Created At"
filterDropdown={(props) => (
<FilterDropdown
{...props}
mapValue={(selectedKeys, event) => {
return rangePickerFilterMapper(selectedKeys, event);
}}
>
<DatePicker.RangePicker />
</FilterDropdown>
)}
defaultFilteredValue={getDefaultFilter(
"created_at",
filters,
"between",
)}
/>
</Table>
);
};
```

Let's closer look at the [`rangePickerFilterMapper`](https://github.com/refinedev/refine/blob/master/packages/antd/src/definitions/filter-mappers/index.ts) function source code to understand how it works.

when the `event` is:

- `"value"`: It converts the `selectedKeys` to Dayjs objects to be used in the `<DatePicker.RangePicker />` component.
- `"onChange"`, It converts the Dayjs objects to ISO 8601 string format to be used in the Refine(data-provider, snycWithLocation etc.) filter.

```ts
import type {
FilterDropdownProps,
MapValueEvent,
} from "@components/table/components";
import dayjs from "dayjs";

export const rangePickerFilterMapper = (
selectedKeys: FilterDropdownProps["selectedKeys"],
event: MapValueEvent,
) => {
if (!selectedKeys) {
return selectedKeys;
}

if (event === "value") {
return selectedKeys.map((key) => {
if (typeof key === "string") {
return dayjs(key);
}

return key;
});
}

if (event === "onChange") {
if (selectedKeys.every(dayjs.isDayjs)) {
return selectedKeys.map((date: any) => dayjs(date).toISOString());
}
}

return selectedKeys;
};
```

:::simple Good to know

If [syncWithLocation](/docs/core/refine-component#syncwithlocation) is enabled, on page refresh, the filter values will be type of `string` since they will be parsed from URL. This might produce some incompatibility if data for filter input comes from an API and it's not type of `string`.
Expand Down
2 changes: 1 addition & 1 deletion examples/access-control-casbin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@refinedev/react-router-v6": "^4.5.9",
"@refinedev/simple-rest": "^5.0.6",
"@uiw/react-md-editor": "^3.19.5",
"antd": "5.16.5",
"antd": "^5.17.0",
"casbin": "^5.15.2",
"react": "^18.0.0",
"react-dom": "^18.0.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/access-control-cerbos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@refinedev/react-router-v6": "^4.5.9",
"@refinedev/simple-rest": "^5.0.6",
"@uiw/react-md-editor": "^3.19.5",
"antd": "5.16.5",
"antd": "^5.17.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-dom": "^6.8.1"
Expand Down
2 changes: 1 addition & 1 deletion examples/access-control-permify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@refinedev/react-router-v6": "^4.5.9",
"@refinedev/simple-rest": "^5.0.6",
"@uiw/react-md-editor": "^3.19.5",
"antd": "5.16.5",
"antd": "^5.17.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-dom": "^6.8.1"
Expand Down
Loading

0 comments on commit 8807bc5

Please sign in to comment.