refine-mantine 1.3.5 → 1.5.0

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.d.ts CHANGED
@@ -130,7 +130,10 @@ type EditProps = RefineCrudEditProps<SaveButtonProps, DeleteButtonProps, GroupPr
130
130
  declare const Edit: React$1.FC<EditProps>;
131
131
  //#endregion
132
132
  //#region src/components/crud/List.d.ts
133
- type ListProps = RefineCrudListProps<CreateButtonProps, GroupProps, CardProps, GroupProps, BoxProps>;
133
+ type ListProps = RefineCrudListProps<CreateButtonProps, GroupProps, CardProps, GroupProps, BoxProps, ListExtraProps>;
134
+ interface ListExtraProps {
135
+ isLoading?: boolean;
136
+ }
134
137
  declare const List: React$1.FC<ListProps>;
135
138
  //#endregion
136
139
  //#region src/components/crud/Show.d.ts
package/dist/index.js CHANGED
@@ -801,7 +801,7 @@ const Edit = (props) => {
801
801
  //#endregion
802
802
  //#region src/components/crud/List.tsx
803
803
  const List = (props) => {
804
- const { canCreate, children, createButtonProps: createButtonPropsFromProps, resource: resourceFromProps, wrapperProps, contentProps, headerProps, headerButtonProps, headerButtons: headerButtonsFromProps, breadcrumb: breadcrumbFromProps, title } = props;
804
+ const { canCreate, children, createButtonProps: createButtonPropsFromProps, resource: resourceFromProps, wrapperProps, contentProps, headerProps, headerButtonProps, headerButtons: headerButtonsFromProps, breadcrumb: breadcrumbFromProps, title, isLoading } = props;
805
805
  const translate = useTranslate();
806
806
  const { options: { breadcrumb: globalBreadcrumb } = {} } = useRefineContext();
807
807
  const getUserFriendlyName = useUserFriendlyName();
@@ -821,27 +821,34 @@ const List = (props) => {
821
821
  return /* @__PURE__ */ jsxs(Card, {
822
822
  p: "md",
823
823
  ...wrapperProps,
824
- children: [/* @__PURE__ */ jsxs(Group, {
825
- justify: "space-between",
826
- align: "center",
827
- ...headerProps,
828
- children: [/* @__PURE__ */ jsxs(Stack, {
829
- gap: "xs",
830
- children: [breadcrumbComponent, title ?? /* @__PURE__ */ jsx(Title, {
831
- order: 3,
832
- className: RefinePageHeaderClassNames.Title,
833
- children: translate(`${identifier}.titles.list`, getUserFriendlyName(resource?.meta?.label ?? identifier, "plural"))
824
+ children: [
825
+ /* @__PURE__ */ jsx(LoadingOverlay, {
826
+ visible: isLoading ?? false,
827
+ zIndex: 1e3
828
+ }),
829
+ /* @__PURE__ */ jsxs(Group, {
830
+ justify: "space-between",
831
+ align: "center",
832
+ ...headerProps,
833
+ children: [/* @__PURE__ */ jsxs(Stack, {
834
+ gap: "xs",
835
+ children: [breadcrumbComponent, title ?? /* @__PURE__ */ jsx(Title, {
836
+ order: 3,
837
+ className: RefinePageHeaderClassNames.Title,
838
+ children: translate(`${identifier}.titles.list`, getUserFriendlyName(resource?.meta?.label ?? identifier, "plural"))
839
+ })]
840
+ }), /* @__PURE__ */ jsx(Group, {
841
+ gap: "xs",
842
+ ...headerButtonProps,
843
+ children: headerButtons
834
844
  })]
835
- }), /* @__PURE__ */ jsx(Group, {
836
- gap: "xs",
837
- ...headerButtonProps,
838
- children: headerButtons
839
- })]
840
- }), /* @__PURE__ */ jsx(Box, {
841
- pt: "sm",
842
- ...contentProps,
843
- children
844
- })]
845
+ }),
846
+ /* @__PURE__ */ jsx(Box, {
847
+ pt: "sm",
848
+ ...contentProps,
849
+ children
850
+ })
851
+ ]
845
852
  });
846
853
  };
847
854
 
package/package.json CHANGED
@@ -93,5 +93,5 @@
93
93
  "dependencies": {
94
94
  "@refinedev/ui-types": "^2.0.1"
95
95
  },
96
- "version": "1.3.5"
96
+ "version": "1.5.0"
97
97
  }
@@ -0,0 +1,45 @@
1
+ import { Group, Stack, type StackProps, ThemeIcon, type ThemeIconProps, Title } from "@mantine/core";
2
+ import { type TitleProps, useResourceParams, useTranslate, useUserFriendlyName } from "@refinedev/core";
3
+ import { IconGhost3Filled, type ReactNode } from "@tabler/icons-react";
4
+ import { CreateButton, type CreateButtonProps } from "../buttons/CreateButton";
5
+ import { ImportButton, type ImportButtonProps } from "../buttons/ImportButton";
6
+
7
+ interface EmptyProps {
8
+ createButtonProps?: CreateButtonProps;
9
+ icon?: ReactNode;
10
+ themeIconProps?: ThemeIconProps;
11
+ titleProps?: TitleProps;
12
+ importButtonProps?: ImportButtonProps;
13
+ stackProps?: StackProps;
14
+ }
15
+
16
+ export const Empty: React.FC<EmptyProps> = ({
17
+ stackProps,
18
+ icon,
19
+ themeIconProps,
20
+ titleProps,
21
+ createButtonProps,
22
+ importButtonProps,
23
+ }) => {
24
+ const { resource, identifier } = useResourceParams();
25
+ const getUserFriendlyName = useUserFriendlyName();
26
+ const t = useTranslate();
27
+ const resourcePlural = getUserFriendlyName(identifier ?? "resource", "plural");
28
+
29
+ return (
30
+ <Stack align="center" gap="md" {...stackProps}>
31
+ <ThemeIcon variant="light" size="xl" {...themeIconProps}>
32
+ {icon ?? resource?.meta?.icon ?? <IconGhost3Filled />}
33
+ </ThemeIcon>
34
+ <Title order={4} {...titleProps}>
35
+ {t(`${identifier}.titles.list`, `No ${resourcePlural} Yet`)}
36
+ </Title>
37
+ <Group>
38
+ <CreateButton {...createButtonProps} />
39
+ {importButtonProps && (
40
+ <ImportButton {...importButtonProps} />
41
+ )}
42
+ </Group>
43
+ </Stack>
44
+ );
45
+ }
@@ -1,11 +1,12 @@
1
1
  import { ActionIcon, Avatar, Badge, Card, Group, Menu, SimpleGrid, Text } from "@mantine/core";
2
2
  import { useList } from "@refinedev/core";
3
- import { IconDots, IconEye, IconPencil, IconTrash } from "@tabler/icons-react";
4
- import { Default } from "../table/Table.story";
5
- import { List } from "./List";
3
+ import { IconDots } from "@tabler/icons-react";
4
+ import { DeleteButton } from "../buttons/DeleteButton";
6
5
  import { EditButton } from "../buttons/EditButton";
7
6
  import { ShowButton } from "../buttons/ShowButton";
8
- import { DeleteButton } from "../buttons/DeleteButton";
7
+ import { Default as DefaultTableStory } from "../table/Table.story";
8
+ import { Empty } from "./Empty";
9
+ import { List } from "./List";
9
10
 
10
11
  export default {
11
12
  title: 'Crud/List',
@@ -23,7 +24,7 @@ interface UserRecord {
23
24
  }
24
25
 
25
26
  export const Cards = () => {
26
- const { result } = useList<UserRecord>({
27
+ const { result, query: { isLoading } } = useList<UserRecord>({
27
28
  resource: "users",
28
29
  pagination: {
29
30
  pageSize: 100,
@@ -31,7 +32,7 @@ export const Cards = () => {
31
32
  });
32
33
 
33
34
  return (
34
- <List resource="users">
35
+ <List resource="users" isLoading={isLoading}>
35
36
  <SimpleGrid cols={{
36
37
  xs: 1,
37
38
  sm: 3,
@@ -89,5 +90,13 @@ export const Cards = () => {
89
90
  export const Table = () =>
90
91
  // see Tables/Table for further details
91
92
  <List resource="products">
92
- <Default />
93
+ <DefaultTableStory />
94
+ </List>;
95
+
96
+ export const Loading = () =>
97
+ <List resource="products" isLoading />;
98
+
99
+ export const EmptyList = () =>
100
+ <List resource="products">
101
+ <Empty />
93
102
  </List>;
@@ -1,5 +1,5 @@
1
1
  import type { BoxProps, CardProps, GroupProps } from "@mantine/core";
2
- import { Box, Card, Group, Stack, Title } from "@mantine/core";
2
+ import { Box, Card, Group, LoadingOverlay, Stack, Title } from "@mantine/core";
3
3
  import {
4
4
  useRefineContext,
5
5
  useResourceParams,
@@ -22,9 +22,14 @@ export type ListProps = RefineCrudListProps<
22
22
  GroupProps,
23
23
  CardProps,
24
24
  GroupProps,
25
- BoxProps
25
+ BoxProps,
26
+ ListExtraProps
26
27
  >;
27
28
 
29
+ interface ListExtraProps {
30
+ isLoading?: boolean;
31
+ }
32
+
28
33
  export const List: React.FC<ListProps> = (props) => {
29
34
  const {
30
35
  canCreate,
@@ -38,6 +43,7 @@ export const List: React.FC<ListProps> = (props) => {
38
43
  headerButtons: headerButtonsFromProps,
39
44
  breadcrumb: breadcrumbFromProps,
40
45
  title,
46
+ isLoading,
41
47
  } = props;
42
48
  const translate = useTranslate();
43
49
  const { options: { breadcrumb: globalBreadcrumb } = {} } = useRefineContext();
@@ -81,6 +87,7 @@ export const List: React.FC<ListProps> = (props) => {
81
87
 
82
88
  return (
83
89
  <Card p="md" {...wrapperProps}>
90
+ <LoadingOverlay visible={isLoading ?? false} zIndex={1000} />
84
91
  <Group justify="space-between" align="center" {...headerProps}>
85
92
  <Stack gap="xs">
86
93
  {breadcrumbComponent}