refine-mantine 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -141,6 +141,7 @@ const DeleteButton = ({ resource, recordItemId, mutationMode, invalidates, child
|
|
|
141
141
|
withinPortal: false,
|
|
142
142
|
withOverlay: true,
|
|
143
143
|
disabled,
|
|
144
|
+
trapFocus: true,
|
|
144
145
|
...popoverProps,
|
|
145
146
|
children: [/* @__PURE__ */ jsx(Popover.Target, { children: hideText ? /* @__PURE__ */ jsx(ActionIcon, {
|
|
146
147
|
color: "red",
|
|
@@ -190,7 +191,6 @@ const DeleteButton = ({ resource, recordItemId, mutationMode, invalidates, child
|
|
|
190
191
|
}), /* @__PURE__ */ jsx(Button, {
|
|
191
192
|
color: "red",
|
|
192
193
|
onClick: handleConfirm,
|
|
193
|
-
autoFocus: true,
|
|
194
194
|
size: "xs",
|
|
195
195
|
children: confirmOkText ?? defaultConfirmOkLabel
|
|
196
196
|
})]
|
|
@@ -720,8 +720,6 @@ const Show = (props) => {
|
|
|
720
720
|
} : void 0;
|
|
721
721
|
const editButtonProps = isEditButtonVisible ? {
|
|
722
722
|
...isLoading ? { disabled: true } : {},
|
|
723
|
-
color: void 0,
|
|
724
|
-
variant: "filled",
|
|
725
723
|
resource: identifier,
|
|
726
724
|
recordItemId: id
|
|
727
725
|
} : void 0;
|
|
@@ -775,7 +773,6 @@ const Show = (props) => {
|
|
|
775
773
|
gap: "xs",
|
|
776
774
|
children: [buttonBack, /* @__PURE__ */ jsx(Title, {
|
|
777
775
|
order: 3,
|
|
778
|
-
className: RefinePageHeaderClassNames.Title,
|
|
779
776
|
children: title ?? translate(`${identifier}.titles.show`, `Show ${getUserFriendlyName(resource?.meta?.label ?? identifier, "singular")}`)
|
|
780
777
|
})]
|
|
781
778
|
})]
|
|
@@ -879,7 +876,7 @@ const PhoneField = (props) => /* @__PURE__ */ jsx(UrlField, {
|
|
|
879
876
|
//#endregion
|
|
880
877
|
//#region src/components/layout/Layout.tsx
|
|
881
878
|
const Layout = (p) => {
|
|
882
|
-
const [opened, { toggle }] = useDisclosure();
|
|
879
|
+
const [opened, { toggle, close }] = useDisclosure();
|
|
883
880
|
const { title: { icon: defaultIcon, text: defaultText } = {} } = useRefineOptions();
|
|
884
881
|
const { data: identity } = useGetIdentity();
|
|
885
882
|
const menu = useMenu();
|
|
@@ -947,7 +944,8 @@ const Layout = (p) => {
|
|
|
947
944
|
children: p.renderMenu ? p.renderMenu(menu) : menu.menuItems.map((item) => /* @__PURE__ */ jsx(MenuItem, {
|
|
948
945
|
item,
|
|
949
946
|
defaultOpenKeys: menu.defaultOpenKeys,
|
|
950
|
-
selectedKey: menu.selectedKey
|
|
947
|
+
selectedKey: menu.selectedKey,
|
|
948
|
+
onClickLeaf: close
|
|
951
949
|
}, item.key))
|
|
952
950
|
}), /* @__PURE__ */ jsx(AppShell.Section, {
|
|
953
951
|
...p.navbarFooterProps,
|
|
@@ -987,10 +985,12 @@ const MenuItem = (p) => {
|
|
|
987
985
|
defaultOpened: p.defaultOpenKeys.includes(p.item.key ?? ""),
|
|
988
986
|
component: Link,
|
|
989
987
|
to: listUrl(p.item.name),
|
|
988
|
+
onClick: p.item.children.length > 0 ? void 0 : p.onClickLeaf,
|
|
990
989
|
children: p.item.children.length > 0 ? p.item.children.map((child) => /* @__PURE__ */ jsx(MenuItem, {
|
|
991
990
|
item: child,
|
|
992
991
|
defaultOpenKeys: p.defaultOpenKeys,
|
|
993
|
-
selectedKey: p.selectedKey
|
|
992
|
+
selectedKey: p.selectedKey,
|
|
993
|
+
onClickLeaf: p.onClickLeaf
|
|
994
994
|
}, child.key)) : null
|
|
995
995
|
}, p.item.key)
|
|
996
996
|
}, p.item.key);
|
package/package.json
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"exports": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/kruschid/refine-mantine.git"
|
|
9
|
+
},
|
|
6
10
|
"scripts": {
|
|
7
11
|
"build": "tsdown",
|
|
8
12
|
"dev": "vite",
|
|
@@ -34,10 +38,10 @@
|
|
|
34
38
|
"devDependencies": {
|
|
35
39
|
"@commitlint/cli": "^20.1.0",
|
|
36
40
|
"@commitlint/config-conventional": "^20.0.0",
|
|
37
|
-
"@mantine/core": "^8.3.
|
|
38
|
-
"@mantine/form": "^8.3.
|
|
39
|
-
"@mantine/hooks": "^8.3.
|
|
40
|
-
"@mantine/notifications": "^8.3.
|
|
41
|
+
"@mantine/core": "^8.3.10",
|
|
42
|
+
"@mantine/form": "^8.3.10",
|
|
43
|
+
"@mantine/hooks": "^8.3.10",
|
|
44
|
+
"@mantine/notifications": "^8.3.10",
|
|
41
45
|
"@refinedev/core": "^5.0.5",
|
|
42
46
|
"@refinedev/react-router": "^2.0.3",
|
|
43
47
|
"@refinedev/react-table": "^6.0.1",
|
|
@@ -62,7 +66,7 @@
|
|
|
62
66
|
"react-dom": "^19.2.0",
|
|
63
67
|
"react-router": "^7.9.4",
|
|
64
68
|
"react-router-dom": "^7.9.4",
|
|
65
|
-
"semantic-release": "^25.0.
|
|
69
|
+
"semantic-release": "^25.0.2",
|
|
66
70
|
"storybook": "^9.1.15",
|
|
67
71
|
"tsdown": "^0.15.10",
|
|
68
72
|
"typescript": "^5.9.3",
|
|
@@ -89,5 +93,5 @@
|
|
|
89
93
|
"dependencies": {
|
|
90
94
|
"@refinedev/ui-types": "^2.0.1"
|
|
91
95
|
},
|
|
92
|
-
"version": "1.3.
|
|
96
|
+
"version": "1.3.2"
|
|
93
97
|
}
|
|
@@ -93,6 +93,7 @@ export const DeleteButton: React.FC<DeleteButtonProps> = ({
|
|
|
93
93
|
withinPortal={false}
|
|
94
94
|
withOverlay
|
|
95
95
|
disabled={disabled}
|
|
96
|
+
trapFocus
|
|
96
97
|
{...popoverProps}
|
|
97
98
|
>
|
|
98
99
|
<Popover.Target>
|
|
@@ -143,7 +144,6 @@ export const DeleteButton: React.FC<DeleteButtonProps> = ({
|
|
|
143
144
|
<Button
|
|
144
145
|
color="red"
|
|
145
146
|
onClick={handleConfirm}
|
|
146
|
-
autoFocus
|
|
147
147
|
size="xs"
|
|
148
148
|
>
|
|
149
149
|
{confirmOkText ?? defaultConfirmOkLabel}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ButtonGroup, getThemeColor, Text, Title, useMantineTheme } from "@mantine/core";
|
|
2
|
+
import { useShow } from "@refinedev/core";
|
|
3
|
+
import { Meta } from "@storybook/react";
|
|
4
|
+
import { CloneButton } from "../buttons/CloneButton";
|
|
5
|
+
import { DeleteButton } from "../buttons/DeleteButton";
|
|
6
|
+
import { EditButton } from "../buttons/EditButton";
|
|
7
|
+
import { RefreshButton } from "../buttons/RefreshButton";
|
|
8
|
+
import { BooleanField } from "../fields/BooleanField";
|
|
9
|
+
import { EmailField } from "../fields/EmailField";
|
|
10
|
+
import { Show } from "./Show";
|
|
11
|
+
|
|
12
|
+
interface UsersRecord {
|
|
13
|
+
id: number;
|
|
14
|
+
email: string;
|
|
15
|
+
firstName: string,
|
|
16
|
+
lastName: string;
|
|
17
|
+
skills: string[];
|
|
18
|
+
status: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
title: 'Crud/Show',
|
|
23
|
+
component: Show,
|
|
24
|
+
} satisfies Meta<typeof Show>;
|
|
25
|
+
|
|
26
|
+
export const Default = () => {
|
|
27
|
+
const { query } = useShow<UsersRecord>({
|
|
28
|
+
resource: "users",
|
|
29
|
+
id: 1
|
|
30
|
+
});
|
|
31
|
+
const user = query.data?.data;
|
|
32
|
+
|
|
33
|
+
const theme = useMantineTheme();
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Show
|
|
37
|
+
isLoading={query.isPending}
|
|
38
|
+
headerButtons={() =>
|
|
39
|
+
<ButtonGroup>
|
|
40
|
+
<RefreshButton />
|
|
41
|
+
<CloneButton />
|
|
42
|
+
<EditButton />
|
|
43
|
+
<DeleteButton />
|
|
44
|
+
</ButtonGroup>
|
|
45
|
+
}
|
|
46
|
+
>
|
|
47
|
+
{user && (
|
|
48
|
+
<>
|
|
49
|
+
<Title order={5}>
|
|
50
|
+
Email
|
|
51
|
+
</Title>
|
|
52
|
+
<EmailField value={user.email} />
|
|
53
|
+
<Title order={5} mt="sm">
|
|
54
|
+
First name
|
|
55
|
+
</Title>
|
|
56
|
+
<Text>{user.firstName}</Text>
|
|
57
|
+
<Title order={5} mt="sm">
|
|
58
|
+
Last name
|
|
59
|
+
</Title>
|
|
60
|
+
<Text>{user.lastName}</Text>
|
|
61
|
+
<Title order={5} mt="sm">
|
|
62
|
+
Skills
|
|
63
|
+
</Title>
|
|
64
|
+
<Title order={5} mt="sm">
|
|
65
|
+
Status
|
|
66
|
+
</Title>
|
|
67
|
+
<BooleanField
|
|
68
|
+
value={user.status}
|
|
69
|
+
trueLabel="active"
|
|
70
|
+
falseLabel="inactive"
|
|
71
|
+
falseIconProps={{color: getThemeColor("red", theme)}}
|
|
72
|
+
iconProps={{color: getThemeColor("green", theme)}}
|
|
73
|
+
/>
|
|
74
|
+
</>
|
|
75
|
+
)}
|
|
76
|
+
</Show>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
import { Breadcrumb } from "@/components/breadcrumb/Breadcrumb";
|
|
2
|
+
import {
|
|
3
|
+
DeleteButton,
|
|
4
|
+
type DeleteButtonProps,
|
|
5
|
+
} from "@/components/buttons/DeleteButton";
|
|
6
|
+
import {
|
|
7
|
+
EditButton,
|
|
8
|
+
type EditButtonProps,
|
|
9
|
+
} from "@/components/buttons/EditButton";
|
|
10
|
+
import {
|
|
11
|
+
ListButton,
|
|
12
|
+
type ListButtonProps,
|
|
13
|
+
} from "@/components/buttons/ListButton";
|
|
14
|
+
import {
|
|
15
|
+
RefreshButton,
|
|
16
|
+
type RefreshButtonProps,
|
|
17
|
+
} from "@/components/buttons/RefreshButton";
|
|
1
18
|
import {
|
|
2
19
|
ActionIcon,
|
|
3
20
|
Box,
|
|
@@ -19,28 +36,8 @@ import {
|
|
|
19
36
|
useTranslate,
|
|
20
37
|
useUserFriendlyName,
|
|
21
38
|
} from "@refinedev/core";
|
|
22
|
-
import {
|
|
23
|
-
type RefineCrudShowProps,
|
|
24
|
-
RefinePageHeaderClassNames,
|
|
25
|
-
} from "@refinedev/ui-types";
|
|
39
|
+
import type { RefineCrudShowProps } from "@refinedev/ui-types";
|
|
26
40
|
import { IconArrowLeft } from "@tabler/icons-react";
|
|
27
|
-
import { Breadcrumb } from "@/components/breadcrumb/Breadcrumb";
|
|
28
|
-
import {
|
|
29
|
-
DeleteButton,
|
|
30
|
-
type DeleteButtonProps,
|
|
31
|
-
} from "@/components/buttons/DeleteButton";
|
|
32
|
-
import {
|
|
33
|
-
EditButton,
|
|
34
|
-
type EditButtonProps,
|
|
35
|
-
} from "@/components/buttons/EditButton";
|
|
36
|
-
import {
|
|
37
|
-
ListButton,
|
|
38
|
-
type ListButtonProps,
|
|
39
|
-
} from "@/components/buttons/ListButton";
|
|
40
|
-
import {
|
|
41
|
-
RefreshButton,
|
|
42
|
-
type RefreshButtonProps,
|
|
43
|
-
} from "@/components/buttons/RefreshButton";
|
|
44
41
|
|
|
45
42
|
export type ShowProps = RefineCrudShowProps<
|
|
46
43
|
GroupProps,
|
|
@@ -123,8 +120,6 @@ export const Show: React.FC<ShowProps> = (props) => {
|
|
|
123
120
|
const editButtonProps: EditButtonProps | undefined = isEditButtonVisible
|
|
124
121
|
? {
|
|
125
122
|
...(isLoading ? { disabled: true } : {}),
|
|
126
|
-
color: undefined,
|
|
127
|
-
variant: "filled",
|
|
128
123
|
resource: identifier,
|
|
129
124
|
recordItemId: id,
|
|
130
125
|
}
|
|
@@ -195,7 +190,7 @@ export const Show: React.FC<ShowProps> = (props) => {
|
|
|
195
190
|
{breadcrumbComponent}
|
|
196
191
|
<Group gap="xs">
|
|
197
192
|
{buttonBack}
|
|
198
|
-
<Title order={3}
|
|
193
|
+
<Title order={3}>
|
|
199
194
|
{title ??
|
|
200
195
|
translate(
|
|
201
196
|
`${identifier}.titles.show`,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
Text,
|
|
19
19
|
Tooltip,
|
|
20
20
|
useComputedColorScheme,
|
|
21
|
-
useMantineColorScheme
|
|
21
|
+
useMantineColorScheme
|
|
22
22
|
} from "@mantine/core";
|
|
23
23
|
import { useDisclosure } from "@mantine/hooks";
|
|
24
24
|
import {
|
|
@@ -62,7 +62,7 @@ export interface LayoutLocale {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
export const Layout: React.FC<LayoutProps> = (p) => {
|
|
65
|
-
const [opened, { toggle }] = useDisclosure();
|
|
65
|
+
const [opened, { toggle, close }] = useDisclosure();
|
|
66
66
|
const { title: { icon: defaultIcon, text: defaultText } = {} } =
|
|
67
67
|
useRefineOptions();
|
|
68
68
|
const { data: identity } = useGetIdentity();
|
|
@@ -149,6 +149,7 @@ export const Layout: React.FC<LayoutProps> = (p) => {
|
|
|
149
149
|
defaultOpenKeys={menu.defaultOpenKeys}
|
|
150
150
|
key={item.key}
|
|
151
151
|
selectedKey={menu.selectedKey}
|
|
152
|
+
onClickLeaf={close}
|
|
152
153
|
/>
|
|
153
154
|
))
|
|
154
155
|
)}
|
|
@@ -189,6 +190,7 @@ const MenuItem = (p: {
|
|
|
189
190
|
item: TreeMenuItem;
|
|
190
191
|
selectedKey?: string;
|
|
191
192
|
defaultOpenKeys: string[];
|
|
193
|
+
onClickLeaf: () => void;
|
|
192
194
|
}) => {
|
|
193
195
|
const { listUrl } = useNavigation();
|
|
194
196
|
const isSelected = p.item.key === p.selectedKey;
|
|
@@ -210,6 +212,7 @@ const MenuItem = (p: {
|
|
|
210
212
|
defaultOpened={p.defaultOpenKeys.includes(p.item.key ?? "")}
|
|
211
213
|
component={Link as React.FC<{ to: string }>}
|
|
212
214
|
to={listUrl(p.item.name)}
|
|
215
|
+
onClick={p.item.children.length > 0 ? undefined : p.onClickLeaf}
|
|
213
216
|
>
|
|
214
217
|
{p.item.children.length > 0 ? (
|
|
215
218
|
p.item.children.map(child =>
|
|
@@ -218,6 +221,7 @@ const MenuItem = (p: {
|
|
|
218
221
|
item={child}
|
|
219
222
|
defaultOpenKeys={p.defaultOpenKeys}
|
|
220
223
|
selectedKey={p.selectedKey}
|
|
224
|
+
onClickLeaf={p.onClickLeaf}
|
|
221
225
|
/>
|
|
222
226
|
)
|
|
223
227
|
) : null}
|