refine-mantine 1.2.1 → 1.3.1
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 +58 -14
- package/dist/index.js +82 -2
- package/package.json +3 -1
- package/src/components/fields/BooleanField.story.tsx +38 -0
- package/src/components/fields/BooleanField.tsx +33 -0
- package/src/components/fields/DateField.story.tsx +46 -0
- package/src/components/fields/DateField.tsx +29 -0
- package/src/components/fields/EmailField.story.tsx +84 -0
- package/src/components/fields/EmailField.tsx +9 -0
- package/src/components/fields/FileField.story.tsx +91 -0
- package/src/components/fields/FileField.tsx +8 -0
- package/src/components/fields/PhoneField.story.tsx +96 -0
- package/src/components/fields/PhoneField.tsx +9 -0
- package/src/components/fields/UrlField.story.tsx +96 -0
- package/src/components/fields/UrlField.tsx +47 -0
- package/src/components/table/Table.story.tsx +22 -3
- package/src/components/table/Table.tsx +1 -1
- package/src/index.ts +7 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { ActionIconProps, AppShellFooterProps, AppShellHeaderProps, AppShellMainProps, AppShellNavbarConfiguration, AppShellNavbarProps, AppShellProps, AppShellSectionProps, BadgeProps, BoxProps, BreadcrumbsProps, ButtonProps, CardProps, GroupProps, LoadingOverlayProps, MenuItemProps, NotificationProps, PinInputProps, PopoverProps, ScrollAreaProps, StackProps, TableProps, TextInputProps } from "@mantine/core";
|
|
1
|
+
import { ActionIconProps, AnchorProps, AppShellFooterProps, AppShellHeaderProps, AppShellMainProps, AppShellNavbarConfiguration, AppShellNavbarProps, AppShellProps, AppShellSectionProps, BadgeProps, BoxProps, BreadcrumbsProps, ButtonProps, CardProps, GroupProps, LoadingOverlayProps, MenuItemProps, NotificationProps, PinInputProps, PolymorphicComponentProps, PopoverProps, ScrollAreaProps, StackProps, TableProps, TextInputProps, TextProps } from "@mantine/core";
|
|
2
2
|
import { AuthProvider, AutoSaveIndicatorProps as AutoSaveIndicatorProps$1, BaseRecord, HttpError, LoginFormTypes, NotificationProvider, OAuthProvider, RegisterFormTypes, UseFormProps as UseFormProps$1, UseFormReturnType as UseFormReturnType$1, useMenu, useTranslate } from "@refinedev/core";
|
|
3
|
-
import { IconProps } from "@tabler/icons-react";
|
|
3
|
+
import { IconProps, ReactNode } from "@tabler/icons-react";
|
|
4
4
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
|
-
import React$1, { ReactNode } from "react";
|
|
5
|
+
import React$1, { ReactNode as ReactNode$1 } from "react";
|
|
6
6
|
import { RefineBreadcrumbProps, RefineCreateButtonProps, RefineCrudCreateProps, RefineCrudEditProps, RefineCrudListProps, RefineCrudShowProps, RefineDeleteButtonProps, RefineEditButtonProps, RefineListButtonProps, RefineRefreshButtonProps, RefineSaveButtonProps, RefineShowButtonProps } from "@refinedev/ui-types";
|
|
7
|
+
import { ConfigType } from "dayjs";
|
|
7
8
|
import { FormValidateInput, UseFormInput, UseFormReturnType as UseFormReturnType$2 } from "@mantine/form";
|
|
9
|
+
import { TooltipBaseProps } from "@mantine/core/lib/components/Tooltip/Tooltip.types";
|
|
8
10
|
import { Column } from "@tanstack/table-core";
|
|
9
11
|
import { UseTableReturnType } from "@refinedev/react-table";
|
|
10
12
|
|
|
@@ -102,9 +104,51 @@ declare const List: React$1.FC<ListProps>;
|
|
|
102
104
|
type ShowProps = RefineCrudShowProps<GroupProps, GroupProps, CardProps, GroupProps, BoxProps, {}, EditButtonProps, DeleteButtonProps, RefreshButtonProps, ListButtonProps>;
|
|
103
105
|
declare const Show: React.FC<ShowProps>;
|
|
104
106
|
//#endregion
|
|
107
|
+
//#region src/components/fields/BooleanField.d.ts
|
|
108
|
+
interface BooleanFieldProps {
|
|
109
|
+
value: boolean;
|
|
110
|
+
trueLabel?: string;
|
|
111
|
+
falseLabel?: string;
|
|
112
|
+
trueIcon?: ReactNode;
|
|
113
|
+
falseIcon?: ReactNode;
|
|
114
|
+
trueIconProps?: IconProps;
|
|
115
|
+
falseIconProps?: IconProps;
|
|
116
|
+
tootlipProps?: TooltipBaseProps;
|
|
117
|
+
}
|
|
118
|
+
declare const BooleanField: React.FC<BooleanFieldProps>;
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/components/fields/DateField.d.ts
|
|
121
|
+
interface DateFieldProps {
|
|
122
|
+
value: ConfigType;
|
|
123
|
+
locale?: string;
|
|
124
|
+
format?: string;
|
|
125
|
+
textProps?: TextProps;
|
|
126
|
+
}
|
|
127
|
+
declare const DateField: React.FC<DateFieldProps>;
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/components/fields/UrlField.d.ts
|
|
130
|
+
interface UrlFieldProps {
|
|
131
|
+
value: string;
|
|
132
|
+
children?: ReactNode;
|
|
133
|
+
anchorProps?: PolymorphicComponentProps<"a", AnchorProps>;
|
|
134
|
+
textProps?: TextProps;
|
|
135
|
+
iconProps?: IconProps;
|
|
136
|
+
icon?: React.FC<IconProps>;
|
|
137
|
+
}
|
|
138
|
+
declare const UrlField: React.FC<UrlFieldProps>;
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/components/fields/EmailField.d.ts
|
|
141
|
+
declare const EmailField: React.FC<UrlFieldProps>;
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/components/fields/FileField.d.ts
|
|
144
|
+
declare const FileField: React.FC<UrlFieldProps>;
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/components/fields/PhoneField.d.ts
|
|
147
|
+
declare const PhoneField: React.FC<UrlFieldProps>;
|
|
148
|
+
//#endregion
|
|
105
149
|
//#region src/components/layout/Layout.d.ts
|
|
106
150
|
interface LayoutProps {
|
|
107
|
-
children: ReactNode;
|
|
151
|
+
children: ReactNode$1;
|
|
108
152
|
shellProps?: AppShellProps;
|
|
109
153
|
headerProps?: AppShellHeaderProps;
|
|
110
154
|
navbarProps?: AppShellNavbarProps;
|
|
@@ -113,17 +157,17 @@ interface LayoutProps {
|
|
|
113
157
|
navbarFooterProps?: AppShellSectionProps;
|
|
114
158
|
mainProps?: AppShellMainProps;
|
|
115
159
|
hideNavbar?: boolean;
|
|
116
|
-
footer?: ReactNode;
|
|
160
|
+
footer?: ReactNode$1;
|
|
117
161
|
footerProps?: AppShellFooterProps;
|
|
118
162
|
locales?: LayoutLocale[];
|
|
119
|
-
renderHeader?: (toggle: () => void) => ReactNode;
|
|
120
|
-
renderMenu?: (params: ReturnType<typeof useMenu>) => ReactNode;
|
|
121
|
-
renderIdentity?: <T extends BaseRecord>(identity: T, logout: () => void) => ReactNode;
|
|
163
|
+
renderHeader?: (toggle: () => void) => ReactNode$1;
|
|
164
|
+
renderMenu?: (params: ReturnType<typeof useMenu>) => ReactNode$1;
|
|
165
|
+
renderIdentity?: <T extends BaseRecord>(identity: T, logout: () => void) => ReactNode$1;
|
|
122
166
|
}
|
|
123
167
|
interface LayoutLocale {
|
|
124
168
|
lang: string;
|
|
125
169
|
label: string;
|
|
126
|
-
icon?: ReactNode;
|
|
170
|
+
icon?: ReactNode$1;
|
|
127
171
|
}
|
|
128
172
|
declare const Layout: React.FC<LayoutProps>;
|
|
129
173
|
//#endregion
|
|
@@ -235,8 +279,8 @@ type LoginPageProps = {
|
|
|
235
279
|
otpInputProps?: PinInputProps;
|
|
236
280
|
submitButtonProps?: ButtonProps;
|
|
237
281
|
cancelButtonProps?: ButtonProps;
|
|
238
|
-
icon?: ReactNode;
|
|
239
|
-
title?: ReactNode;
|
|
282
|
+
icon?: ReactNode$1;
|
|
283
|
+
title?: ReactNode$1;
|
|
240
284
|
otpHandler?: OtpHandler;
|
|
241
285
|
} & ({
|
|
242
286
|
method: "oauth";
|
|
@@ -266,8 +310,8 @@ interface RegisterPageProps {
|
|
|
266
310
|
otpInputProps?: PinInputProps;
|
|
267
311
|
submitButtonProps?: ButtonProps;
|
|
268
312
|
cancelButtonProps?: ButtonProps;
|
|
269
|
-
icon?: ReactNode;
|
|
270
|
-
title?: ReactNode;
|
|
313
|
+
icon?: ReactNode$1;
|
|
314
|
+
title?: ReactNode$1;
|
|
271
315
|
}
|
|
272
316
|
interface RegisterForm {
|
|
273
317
|
email: string;
|
|
@@ -282,4 +326,4 @@ declare const authProvider: AuthProvider;
|
|
|
282
326
|
//#region src/providers/notificationProvider.d.ts
|
|
283
327
|
declare const notificationProvider: () => NotificationProvider;
|
|
284
328
|
//#endregion
|
|
285
|
-
export { AutoSaveIndicator, AutoSaveIndicatorProps, Breadcrumb, BreadcrumbProps, ColorSchemeToggle, ColumnFilter, ColumnSorter, Create, CreateButton, CreateButtonProps, CreateProps, DeleteButton, DeleteButtonProps, Edit, EditButton, EditButtonProps, EditProps, Layout, LayoutLocale, List, ListButton, ListButtonProps, ListProps, LoginArgs, LoginPage, LoginPageProps, Message, MessageProps, OAuthProviderMantine, OtpHandler, RefreshButton, RefreshButtonProps, RegisterForm, RegisterPage, RegisterPageProps, SaveButton, SaveButtonProps, Show, ShowButton, ShowButtonProps, ShowProps, Table, TranslateFn, UseFormProps, UseFormReturnType, authProvider, notificationProvider, useForm, useOtp };
|
|
329
|
+
export { AutoSaveIndicator, AutoSaveIndicatorProps, BooleanField, BooleanFieldProps, Breadcrumb, BreadcrumbProps, ColorSchemeToggle, ColumnFilter, ColumnSorter, Create, CreateButton, CreateButtonProps, CreateProps, DateField, DateFieldProps, DeleteButton, DeleteButtonProps, Edit, EditButton, EditButtonProps, EditProps, EmailField, FileField, Layout, LayoutLocale, List, ListButton, ListButtonProps, ListProps, LoginArgs, LoginPage, LoginPageProps, Message, MessageProps, OAuthProviderMantine, OtpHandler, PhoneField, RefreshButton, RefreshButtonProps, RegisterForm, RegisterPage, RegisterPageProps, SaveButton, SaveButtonProps, Show, ShowButton, ShowButtonProps, ShowProps, Table, TranslateFn, UrlField, UrlFieldProps, UseFormProps, UseFormReturnType, authProvider, notificationProvider, useForm, useOtp };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ActionIcon, Anchor, AppShell, Avatar, Badge, Box, Breadcrumbs, Burger, Button, Card, Center, Collapse, Divider, Group, Input, Loader, LoadingOverlay, Menu, NavLink, Notification, Pagination, PinInput, Popover, RingProgress, ScrollArea, Stack, Table as Table$1, Text, TextInput, Title, Tooltip, useComputedColorScheme, useMantineColorScheme } from "@mantine/core";
|
|
2
2
|
import { CanAccess, Link, flattenObjectKeys, matchResourceFromRoute, useBack, useBreadcrumb, useCreateButton, useDeleteButton, useEditButton, useForm as useForm$1, useGetIdentity, useGo, useLink, useListButton, useLogin, useLogout, useMenu, useMutationMode, useNavigation, useRefineContext, useRefineOptions, useRefreshButton, useRegister, useResourceParams, useSaveButton, useShowButton, useToPath, useTranslate, useTranslation, useUserFriendlyName, useWarnAboutChange } from "@refinedev/core";
|
|
3
|
-
import { IconArrowBackUp, IconArrowLeft, IconAt, IconCheck, IconChevronUp, IconCircleCheck, IconDeviceFloppy, IconDots, IconExclamationCircle, IconEye, IconFilter, IconHome, IconLanguage, IconList, IconLockPassword, IconLogout, IconMoon, IconPencil, IconRefresh, IconSelector, IconSquarePlus, IconSun, IconTrash, IconX } from "@tabler/icons-react";
|
|
3
|
+
import { IconArrowBackUp, IconArrowLeft, IconAt, IconCheck, IconChevronUp, IconCircleCheck, IconCircleCheckFilled, IconCircleXFilled, IconDeviceFloppy, IconDots, IconExclamationCircle, IconExternalLink, IconEye, IconFileDownloadFilled, IconFilter, IconHome, IconLanguage, IconList, IconLockPassword, IconLogout, IconMailShare, IconMoon, IconPencil, IconPhoneOutgoing, IconRefresh, IconSelector, IconSquarePlus, IconSun, IconTrash, IconX } from "@tabler/icons-react";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
6
6
|
import { useDebouncedCallback, useDisclosure } from "@mantine/hooks";
|
|
7
7
|
import { RefinePageHeaderClassNames } from "@refinedev/ui-types";
|
|
8
|
+
import dayjs from "dayjs";
|
|
9
|
+
import LocalizedFormat from "dayjs/plugin/localizedFormat";
|
|
8
10
|
import { flexRender } from "@tanstack/react-table";
|
|
9
11
|
import { isEmail, isNotEmpty, useForm as useForm$2 } from "@mantine/form";
|
|
10
12
|
import { hideNotification, showNotification, updateNotification } from "@mantine/notifications";
|
|
@@ -796,6 +798,84 @@ const Show = (props) => {
|
|
|
796
798
|
});
|
|
797
799
|
};
|
|
798
800
|
|
|
801
|
+
//#endregion
|
|
802
|
+
//#region src/components/fields/BooleanField.tsx
|
|
803
|
+
const BooleanField = ({ value, trueLabel = "true", falseLabel = "false", trueIcon, falseIcon, trueIconProps, falseIconProps, tootlipProps }) => /* @__PURE__ */ jsx(Tooltip, {
|
|
804
|
+
label: value ? trueLabel : falseLabel,
|
|
805
|
+
...tootlipProps,
|
|
806
|
+
children: /* @__PURE__ */ jsx("span", { children: value ? trueIcon ?? /* @__PURE__ */ jsx(IconCircleCheckFilled, {
|
|
807
|
+
size: 18,
|
|
808
|
+
...trueIconProps
|
|
809
|
+
}) : falseIcon ?? /* @__PURE__ */ jsx(IconCircleXFilled, {
|
|
810
|
+
size: 18,
|
|
811
|
+
...falseIconProps
|
|
812
|
+
}) })
|
|
813
|
+
});
|
|
814
|
+
|
|
815
|
+
//#endregion
|
|
816
|
+
//#region src/components/fields/DateField.tsx
|
|
817
|
+
dayjs.extend(LocalizedFormat);
|
|
818
|
+
const defaultLocale = dayjs.locale();
|
|
819
|
+
const DateField = ({ value, locale, format: dateFormat = "L", textProps }) => /* @__PURE__ */ jsx(Text, {
|
|
820
|
+
...textProps,
|
|
821
|
+
children: value ? dayjs(value).locale(locale ?? defaultLocale).format(dateFormat) : ""
|
|
822
|
+
});
|
|
823
|
+
|
|
824
|
+
//#endregion
|
|
825
|
+
//#region src/components/fields/UrlField.tsx
|
|
826
|
+
const UrlField = ({ children, value, anchorProps, textProps, icon, iconProps }) => {
|
|
827
|
+
const Icon = icon ?? IconExternalLink;
|
|
828
|
+
return /* @__PURE__ */ jsxs(Anchor, {
|
|
829
|
+
href: value,
|
|
830
|
+
style: {
|
|
831
|
+
display: "inline-flex",
|
|
832
|
+
alignItems: "center"
|
|
833
|
+
},
|
|
834
|
+
...anchorProps,
|
|
835
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
836
|
+
...textProps,
|
|
837
|
+
children: children ?? value
|
|
838
|
+
}), /* @__PURE__ */ jsx(Icon, {
|
|
839
|
+
size: textProps?.size === "xs" ? 12 : textProps?.size === "sm" ? 14 : textProps?.size === "md" ? 16 : textProps?.size === "lg" ? 18 : textProps?.size === "xl" ? 20 : 16,
|
|
840
|
+
style: {
|
|
841
|
+
marginLeft: 4,
|
|
842
|
+
flexShrink: 0
|
|
843
|
+
},
|
|
844
|
+
"aria-hidden": true,
|
|
845
|
+
...iconProps
|
|
846
|
+
})]
|
|
847
|
+
});
|
|
848
|
+
};
|
|
849
|
+
|
|
850
|
+
//#endregion
|
|
851
|
+
//#region src/components/fields/EmailField.tsx
|
|
852
|
+
const EmailField = (props) => /* @__PURE__ */ jsx(UrlField, {
|
|
853
|
+
icon: IconMailShare,
|
|
854
|
+
...props,
|
|
855
|
+
anchorProps: {
|
|
856
|
+
href: `mailto:${props.value}`,
|
|
857
|
+
...props.anchorProps
|
|
858
|
+
}
|
|
859
|
+
});
|
|
860
|
+
|
|
861
|
+
//#endregion
|
|
862
|
+
//#region src/components/fields/FileField.tsx
|
|
863
|
+
const FileField = (props) => /* @__PURE__ */ jsx(UrlField, {
|
|
864
|
+
icon: IconFileDownloadFilled,
|
|
865
|
+
...props
|
|
866
|
+
});
|
|
867
|
+
|
|
868
|
+
//#endregion
|
|
869
|
+
//#region src/components/fields/PhoneField.tsx
|
|
870
|
+
const PhoneField = (props) => /* @__PURE__ */ jsx(UrlField, {
|
|
871
|
+
icon: IconPhoneOutgoing,
|
|
872
|
+
...props,
|
|
873
|
+
anchorProps: {
|
|
874
|
+
href: `tel:${props.value}`,
|
|
875
|
+
...props.anchorProps
|
|
876
|
+
}
|
|
877
|
+
});
|
|
878
|
+
|
|
799
879
|
//#endregion
|
|
800
880
|
//#region src/components/layout/Layout.tsx
|
|
801
881
|
const Layout = (p) => {
|
|
@@ -1650,4 +1730,4 @@ const notificationProvider = () => {
|
|
|
1650
1730
|
};
|
|
1651
1731
|
|
|
1652
1732
|
//#endregion
|
|
1653
|
-
export { AutoSaveIndicator, Breadcrumb, ColorSchemeToggle, ColumnFilter, ColumnSorter, Create, CreateButton, DeleteButton, Edit, EditButton, Layout, List, ListButton, LoginPage, Message, RefreshButton, RegisterPage, SaveButton, Show, ShowButton, Table, notificationProvider, useForm, useOtp };
|
|
1733
|
+
export { AutoSaveIndicator, BooleanField, Breadcrumb, ColorSchemeToggle, ColumnFilter, ColumnSorter, Create, CreateButton, DateField, DeleteButton, Edit, EditButton, EmailField, FileField, Layout, List, ListButton, LoginPage, Message, PhoneField, RefreshButton, RegisterPage, SaveButton, Show, ShowButton, Table, UrlField, notificationProvider, useForm, useOtp };
|
package/package.json
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"@tabler/icons-react": "^3.34.1",
|
|
26
26
|
"@tanstack/react-query": "^5.87.4",
|
|
27
27
|
"@tanstack/react-table": "^8.21.3",
|
|
28
|
+
"dayjs": "^1.11.19",
|
|
28
29
|
"react": "^19.1.1",
|
|
29
30
|
"react-dom": "^19.1.1",
|
|
30
31
|
"react-router": "^7.0.2",
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
"@types/react": "^19.2.2",
|
|
53
54
|
"@types/react-dom": "^19.2.2",
|
|
54
55
|
"@vitejs/plugin-react": "^5.1.0",
|
|
56
|
+
"dayjs": "^1.11.19",
|
|
55
57
|
"husky": "^9.1.7",
|
|
56
58
|
"postcss": "^8.5.6",
|
|
57
59
|
"postcss-preset-mantine": "1.18.0",
|
|
@@ -87,5 +89,5 @@
|
|
|
87
89
|
"dependencies": {
|
|
88
90
|
"@refinedev/ui-types": "^2.0.1"
|
|
89
91
|
},
|
|
90
|
-
"version": "1.
|
|
92
|
+
"version": "1.3.1"
|
|
91
93
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Stack } from "@mantine/core";
|
|
2
|
+
import { Meta } from "@storybook/react";
|
|
3
|
+
import { IconCheck, IconX } from "@tabler/icons-react";
|
|
4
|
+
import { BooleanField } from "./BooleanField";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Fields/BooleanField',
|
|
8
|
+
component: BooleanField,
|
|
9
|
+
decorators: (Story) => (
|
|
10
|
+
<Stack h="100vh" align="center" justify="center">
|
|
11
|
+
<Story />
|
|
12
|
+
</Stack>
|
|
13
|
+
),
|
|
14
|
+
} satisfies Meta<typeof BooleanField>;
|
|
15
|
+
|
|
16
|
+
export const Default = () =>
|
|
17
|
+
<BooleanField value={true} />;
|
|
18
|
+
|
|
19
|
+
export const CustomLabel = () =>
|
|
20
|
+
<BooleanField
|
|
21
|
+
value={false}
|
|
22
|
+
falseLabel="Value not selected"
|
|
23
|
+
trueLabel="Value selected"
|
|
24
|
+
/>;
|
|
25
|
+
|
|
26
|
+
export const CustomIcon = () =>
|
|
27
|
+
<BooleanField
|
|
28
|
+
value={false}
|
|
29
|
+
falseIcon={<IconX />}
|
|
30
|
+
trueIcon={<IconCheck />}
|
|
31
|
+
/>;
|
|
32
|
+
|
|
33
|
+
export const CustomColor = () =>
|
|
34
|
+
<BooleanField
|
|
35
|
+
value={false}
|
|
36
|
+
falseIconProps={{ fill: "red" }}
|
|
37
|
+
trueIconProps={{ fill: "green" }}
|
|
38
|
+
/>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Tooltip } from "@mantine/core";
|
|
2
|
+
import type { TooltipBaseProps } from "@mantine/core/lib/components/Tooltip/Tooltip.types";
|
|
3
|
+
import { IconCircleCheckFilled, IconCircleXFilled, ReactNode, type IconProps } from "@tabler/icons-react";
|
|
4
|
+
|
|
5
|
+
export interface BooleanFieldProps {
|
|
6
|
+
value: boolean;
|
|
7
|
+
trueLabel?: string;
|
|
8
|
+
falseLabel?: string;
|
|
9
|
+
trueIcon?: ReactNode;
|
|
10
|
+
falseIcon?: ReactNode;
|
|
11
|
+
trueIconProps?: IconProps;
|
|
12
|
+
falseIconProps?: IconProps;
|
|
13
|
+
tootlipProps?: TooltipBaseProps;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const BooleanField: React.FC<BooleanFieldProps> = ({
|
|
17
|
+
value,
|
|
18
|
+
trueLabel = "true",
|
|
19
|
+
falseLabel = "false",
|
|
20
|
+
trueIcon,
|
|
21
|
+
falseIcon,
|
|
22
|
+
trueIconProps,
|
|
23
|
+
falseIconProps,
|
|
24
|
+
tootlipProps,
|
|
25
|
+
}) => (
|
|
26
|
+
<Tooltip label={value ? trueLabel : falseLabel} {...tootlipProps}>
|
|
27
|
+
<span>
|
|
28
|
+
{value
|
|
29
|
+
? trueIcon ?? <IconCircleCheckFilled size={18} {...trueIconProps} />
|
|
30
|
+
: falseIcon ?? <IconCircleXFilled size={18} {...falseIconProps} />}
|
|
31
|
+
</span>
|
|
32
|
+
</Tooltip>
|
|
33
|
+
);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Stack } from "@mantine/core";
|
|
2
|
+
import { Meta } from "@storybook/react";
|
|
3
|
+
import "dayjs/locale/de";
|
|
4
|
+
import { DateField } from "./DateField";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Fields/DateField',
|
|
8
|
+
component: DateField,
|
|
9
|
+
decorators: (Story) => (
|
|
10
|
+
<Stack h="100vh" align="center" justify="center">
|
|
11
|
+
<Story />
|
|
12
|
+
</Stack>
|
|
13
|
+
),
|
|
14
|
+
} satisfies Meta<typeof DateField>;
|
|
15
|
+
|
|
16
|
+
export const Default = () =>
|
|
17
|
+
<DateField value="2025-12-05T14:41:31" />;
|
|
18
|
+
|
|
19
|
+
export const Small = () =>
|
|
20
|
+
<DateField
|
|
21
|
+
value="2025-12-05T14:41:31"
|
|
22
|
+
textProps={{size: "xs"}}
|
|
23
|
+
/>;
|
|
24
|
+
|
|
25
|
+
export const Color = () =>
|
|
26
|
+
<DateField
|
|
27
|
+
value="2025-12-05T14:41:31"
|
|
28
|
+
textProps={{ c: "teal" }}
|
|
29
|
+
/>;
|
|
30
|
+
|
|
31
|
+
export const Format = () =>
|
|
32
|
+
<DateField
|
|
33
|
+
value="2025-12-05T14:41:31"
|
|
34
|
+
// https://day.js.org/docs/en/display/format
|
|
35
|
+
format="LLLL"
|
|
36
|
+
/>;
|
|
37
|
+
|
|
38
|
+
export const Locale = () => (
|
|
39
|
+
<DateField
|
|
40
|
+
value="2025-12-05T14:41:31"
|
|
41
|
+
// https://day.js.org/docs/en/display/format
|
|
42
|
+
format="LLLL"
|
|
43
|
+
// importing "dayjs/locale/de" is required to work properly
|
|
44
|
+
locale="de"
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Text, TextProps } from "@mantine/core";
|
|
2
|
+
import type { ConfigType } from "dayjs";
|
|
3
|
+
import dayjs from "dayjs";
|
|
4
|
+
import LocalizedFormat from "dayjs/plugin/localizedFormat";
|
|
5
|
+
|
|
6
|
+
export interface DateFieldProps {
|
|
7
|
+
value: ConfigType;
|
|
8
|
+
locale?: string;
|
|
9
|
+
format?: string;
|
|
10
|
+
textProps?: TextProps;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
dayjs.extend(LocalizedFormat);
|
|
14
|
+
const defaultLocale = dayjs.locale();
|
|
15
|
+
|
|
16
|
+
export const DateField: React.FC<DateFieldProps> = ({
|
|
17
|
+
value,
|
|
18
|
+
locale,
|
|
19
|
+
format: dateFormat = "L",
|
|
20
|
+
textProps,
|
|
21
|
+
}) => (
|
|
22
|
+
<Text {...textProps}>
|
|
23
|
+
{value
|
|
24
|
+
? dayjs(value)
|
|
25
|
+
.locale(locale ?? defaultLocale)
|
|
26
|
+
.format(dateFormat)
|
|
27
|
+
: ""}
|
|
28
|
+
</Text>
|
|
29
|
+
);
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Stack } from "@mantine/core";
|
|
2
|
+
import { Meta } from "@storybook/react";
|
|
3
|
+
import { EmailField } from "./EmailField";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Fields/EmailField',
|
|
7
|
+
component: EmailField,
|
|
8
|
+
decorators: (Story) => (
|
|
9
|
+
<Stack h="100vh" align="center" justify="center">
|
|
10
|
+
<Story />
|
|
11
|
+
</Stack>
|
|
12
|
+
),
|
|
13
|
+
} satisfies Meta<typeof EmailField>;
|
|
14
|
+
|
|
15
|
+
export const Default = () =>
|
|
16
|
+
<EmailField value="test@example.com" />;
|
|
17
|
+
|
|
18
|
+
export const Colors = () =>
|
|
19
|
+
<>
|
|
20
|
+
<EmailField
|
|
21
|
+
value="test@example.com"
|
|
22
|
+
anchorProps={{c: "indigo"}}
|
|
23
|
+
/>
|
|
24
|
+
<EmailField
|
|
25
|
+
value="test@example.com"
|
|
26
|
+
anchorProps={{c: "cyan"}}
|
|
27
|
+
/>
|
|
28
|
+
<EmailField
|
|
29
|
+
value="test@example.com"
|
|
30
|
+
anchorProps={{c: "teal"}}
|
|
31
|
+
/>
|
|
32
|
+
<EmailField
|
|
33
|
+
value="test@example.com"
|
|
34
|
+
anchorProps={{c: "lime"}}
|
|
35
|
+
/>
|
|
36
|
+
</>;
|
|
37
|
+
|
|
38
|
+
export const Sizes = () =>
|
|
39
|
+
<>
|
|
40
|
+
<EmailField
|
|
41
|
+
value="test@example.com"
|
|
42
|
+
textProps={{size: "xs"}}
|
|
43
|
+
/>
|
|
44
|
+
<EmailField
|
|
45
|
+
value="test@example.com"
|
|
46
|
+
textProps={{size: "sm"}}
|
|
47
|
+
/>
|
|
48
|
+
<EmailField
|
|
49
|
+
value="test@example.com"
|
|
50
|
+
textProps={{size: "md"}}
|
|
51
|
+
/>
|
|
52
|
+
<EmailField
|
|
53
|
+
value="test@example.com"
|
|
54
|
+
textProps={{size: "lg"}}
|
|
55
|
+
/>
|
|
56
|
+
<EmailField
|
|
57
|
+
value="test@example.com"
|
|
58
|
+
textProps={{size: "xl"}}
|
|
59
|
+
/>
|
|
60
|
+
</>;
|
|
61
|
+
|
|
62
|
+
export const Truncated = () =>
|
|
63
|
+
<EmailField
|
|
64
|
+
value="firstname.lastname@verylongdomain.tld"
|
|
65
|
+
anchorProps={{maw: 200}}
|
|
66
|
+
textProps={{truncate: "end"}}
|
|
67
|
+
/>;
|
|
68
|
+
|
|
69
|
+
export const Gradient = () =>
|
|
70
|
+
<EmailField
|
|
71
|
+
value="test@example.com"
|
|
72
|
+
anchorProps={{
|
|
73
|
+
variant: "gradient",
|
|
74
|
+
gradient: { from: 'pink', to: 'yellow' }
|
|
75
|
+
}}
|
|
76
|
+
/>;
|
|
77
|
+
|
|
78
|
+
export const HiddenIcon = () =>
|
|
79
|
+
<EmailField
|
|
80
|
+
value="test@example.com"
|
|
81
|
+
iconProps={{
|
|
82
|
+
display: "none",
|
|
83
|
+
}}
|
|
84
|
+
/>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IconMailShare } from "@tabler/icons-react";
|
|
2
|
+
import { UrlField, UrlFieldProps } from "./UrlField";
|
|
3
|
+
|
|
4
|
+
export const EmailField: React.FC<UrlFieldProps> = (props) =>
|
|
5
|
+
<UrlField
|
|
6
|
+
icon={IconMailShare}
|
|
7
|
+
{...props}
|
|
8
|
+
anchorProps={{ href: `mailto:${props.value}`, ...props.anchorProps }}
|
|
9
|
+
/>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Stack } from "@mantine/core";
|
|
2
|
+
import { Meta } from "@storybook/react";
|
|
3
|
+
import { IconPhotoDown } from "@tabler/icons-react";
|
|
4
|
+
import { FileField } from "./FileField";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Fields/FileField',
|
|
8
|
+
component: FileField,
|
|
9
|
+
decorators: (Story) => (
|
|
10
|
+
<Stack h="100vh" align="center" justify="center">
|
|
11
|
+
<Story />
|
|
12
|
+
</Stack>
|
|
13
|
+
),
|
|
14
|
+
} satisfies Meta<typeof FileField>;
|
|
15
|
+
|
|
16
|
+
export const Default = () =>
|
|
17
|
+
<FileField value="https://github.com/kruschid/refine-mantine">refine-mantine</FileField>;
|
|
18
|
+
|
|
19
|
+
export const Colors = () =>
|
|
20
|
+
<>
|
|
21
|
+
<FileField
|
|
22
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
23
|
+
anchorProps={{c: "indigo"}}
|
|
24
|
+
/>
|
|
25
|
+
<FileField
|
|
26
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
27
|
+
anchorProps={{c: "cyan"}}
|
|
28
|
+
/>
|
|
29
|
+
<FileField
|
|
30
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
31
|
+
anchorProps={{c: "teal"}}
|
|
32
|
+
/>
|
|
33
|
+
<FileField
|
|
34
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
35
|
+
anchorProps={{c: "lime"}}
|
|
36
|
+
/>
|
|
37
|
+
</>;
|
|
38
|
+
|
|
39
|
+
export const Sizes = () =>
|
|
40
|
+
<>
|
|
41
|
+
<FileField
|
|
42
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
43
|
+
textProps={{size: "xs"}}
|
|
44
|
+
/>
|
|
45
|
+
<FileField
|
|
46
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
47
|
+
textProps={{size: "sm"}}
|
|
48
|
+
/>
|
|
49
|
+
<FileField
|
|
50
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
51
|
+
textProps={{size: "md"}}
|
|
52
|
+
/>
|
|
53
|
+
<FileField
|
|
54
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
55
|
+
textProps={{size: "lg"}}
|
|
56
|
+
/>
|
|
57
|
+
<FileField
|
|
58
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
59
|
+
textProps={{size: "xl"}}
|
|
60
|
+
/>
|
|
61
|
+
</>;
|
|
62
|
+
|
|
63
|
+
export const Truncated = () =>
|
|
64
|
+
<FileField
|
|
65
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
66
|
+
anchorProps={{maw: 200}}
|
|
67
|
+
textProps={{truncate: "end"}}
|
|
68
|
+
/>;
|
|
69
|
+
|
|
70
|
+
export const Gradient = () =>
|
|
71
|
+
<FileField
|
|
72
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
73
|
+
anchorProps={{
|
|
74
|
+
variant: "gradient",
|
|
75
|
+
gradient: { from: 'pink', to: 'yellow' }
|
|
76
|
+
}}
|
|
77
|
+
/>;
|
|
78
|
+
|
|
79
|
+
export const HiddenIcon = () =>
|
|
80
|
+
<FileField
|
|
81
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
82
|
+
iconProps={{
|
|
83
|
+
display: "none",
|
|
84
|
+
}}
|
|
85
|
+
/>;
|
|
86
|
+
|
|
87
|
+
export const CustomIcon = () =>
|
|
88
|
+
<FileField
|
|
89
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
90
|
+
icon={IconPhotoDown}
|
|
91
|
+
/>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Stack } from "@mantine/core";
|
|
2
|
+
import { Meta } from "@storybook/react";
|
|
3
|
+
import { PhoneField } from "./PhoneField";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Fields/PhoneField',
|
|
7
|
+
component: PhoneField,
|
|
8
|
+
decorators: (Story) => (
|
|
9
|
+
<Stack h="100vh" align="center" justify="center">
|
|
10
|
+
<Story />
|
|
11
|
+
</Stack>
|
|
12
|
+
),
|
|
13
|
+
} satisfies Meta<typeof PhoneField>;
|
|
14
|
+
|
|
15
|
+
export const Default = () =>
|
|
16
|
+
<PhoneField value="+05890000111">0-589-0000111</PhoneField>;
|
|
17
|
+
|
|
18
|
+
export const Colors = () =>
|
|
19
|
+
<>
|
|
20
|
+
<PhoneField
|
|
21
|
+
value="+05890000111"
|
|
22
|
+
anchorProps={{c: "indigo"}}
|
|
23
|
+
/>
|
|
24
|
+
<PhoneField
|
|
25
|
+
value="+05890000111"
|
|
26
|
+
anchorProps={{c: "cyan"}}
|
|
27
|
+
/>
|
|
28
|
+
<PhoneField
|
|
29
|
+
value="+05890000111"
|
|
30
|
+
anchorProps={{c: "teal"}}
|
|
31
|
+
/>
|
|
32
|
+
<PhoneField
|
|
33
|
+
value="+05890000111"
|
|
34
|
+
anchorProps={{c: "lime"}}
|
|
35
|
+
/>
|
|
36
|
+
</>;
|
|
37
|
+
|
|
38
|
+
export const Sizes = () =>
|
|
39
|
+
<>
|
|
40
|
+
<PhoneField
|
|
41
|
+
value="+05890000111"
|
|
42
|
+
textProps={{size: "xs"}}
|
|
43
|
+
/>
|
|
44
|
+
<PhoneField
|
|
45
|
+
value="+05890000111"
|
|
46
|
+
textProps={{size: "sm"}}
|
|
47
|
+
/>
|
|
48
|
+
<PhoneField
|
|
49
|
+
value="+05890000111"
|
|
50
|
+
textProps={{size: "md"}}
|
|
51
|
+
/>
|
|
52
|
+
<PhoneField
|
|
53
|
+
value="+05890000111"
|
|
54
|
+
textProps={{size: "lg"}}
|
|
55
|
+
/>
|
|
56
|
+
<PhoneField
|
|
57
|
+
value="+05890000111"
|
|
58
|
+
textProps={{size: "xl"}}
|
|
59
|
+
/>
|
|
60
|
+
</>
|
|
61
|
+
|
|
62
|
+
export const WithTarget = () =>
|
|
63
|
+
<PhoneField
|
|
64
|
+
value="+05890000111"
|
|
65
|
+
anchorProps={{target: "_blank"}}
|
|
66
|
+
/>;
|
|
67
|
+
|
|
68
|
+
export const Truncated = () =>
|
|
69
|
+
<PhoneField
|
|
70
|
+
value="+05890000111"
|
|
71
|
+
anchorProps={{maw: 200}}
|
|
72
|
+
textProps={{truncate: "end"}}
|
|
73
|
+
/>;
|
|
74
|
+
|
|
75
|
+
export const WithTitle = () =>
|
|
76
|
+
<PhoneField
|
|
77
|
+
value="+05890000111"
|
|
78
|
+
anchorProps={{title: "refine-mantine"}}
|
|
79
|
+
/>;
|
|
80
|
+
|
|
81
|
+
export const Gradient = () =>
|
|
82
|
+
<PhoneField
|
|
83
|
+
value="+05890000111"
|
|
84
|
+
anchorProps={{
|
|
85
|
+
variant: "gradient",
|
|
86
|
+
gradient: { from: 'pink', to: 'yellow' }
|
|
87
|
+
}}
|
|
88
|
+
/>;
|
|
89
|
+
|
|
90
|
+
export const HiddenIcon = () =>
|
|
91
|
+
<PhoneField
|
|
92
|
+
value="+05890000111"
|
|
93
|
+
iconProps={{
|
|
94
|
+
display: "none",
|
|
95
|
+
}}
|
|
96
|
+
/>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IconPhoneOutgoing } from "@tabler/icons-react";
|
|
2
|
+
import { UrlField, UrlFieldProps } from "./UrlField";
|
|
3
|
+
|
|
4
|
+
export const PhoneField: React.FC<UrlFieldProps> = (props) =>
|
|
5
|
+
<UrlField
|
|
6
|
+
icon={IconPhoneOutgoing}
|
|
7
|
+
{...props}
|
|
8
|
+
anchorProps={{ href: `tel:${props.value}`, ...props.anchorProps }}
|
|
9
|
+
/>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Stack } from "@mantine/core";
|
|
2
|
+
import { Meta } from "@storybook/react";
|
|
3
|
+
import { UrlField } from "./UrlField";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Fields/UrlField',
|
|
7
|
+
component: UrlField,
|
|
8
|
+
decorators: (Story) => (
|
|
9
|
+
<Stack h="100vh" align="center" justify="center">
|
|
10
|
+
<Story />
|
|
11
|
+
</Stack>
|
|
12
|
+
),
|
|
13
|
+
} satisfies Meta<typeof UrlField>;
|
|
14
|
+
|
|
15
|
+
export const Default = () =>
|
|
16
|
+
<UrlField value="https://github.com/kruschid/refine-mantine">refine-mantine</UrlField>;
|
|
17
|
+
|
|
18
|
+
export const Colors = () =>
|
|
19
|
+
<>
|
|
20
|
+
<UrlField
|
|
21
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
22
|
+
anchorProps={{c: "indigo"}}
|
|
23
|
+
/>
|
|
24
|
+
<UrlField
|
|
25
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
26
|
+
anchorProps={{c: "cyan"}}
|
|
27
|
+
/>
|
|
28
|
+
<UrlField
|
|
29
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
30
|
+
anchorProps={{c: "teal"}}
|
|
31
|
+
/>
|
|
32
|
+
<UrlField
|
|
33
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
34
|
+
anchorProps={{c: "lime"}}
|
|
35
|
+
/>
|
|
36
|
+
</>;
|
|
37
|
+
|
|
38
|
+
export const Sizes = () =>
|
|
39
|
+
<>
|
|
40
|
+
<UrlField
|
|
41
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
42
|
+
textProps={{size: "xs"}}
|
|
43
|
+
/>
|
|
44
|
+
<UrlField
|
|
45
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
46
|
+
textProps={{size: "sm"}}
|
|
47
|
+
/>
|
|
48
|
+
<UrlField
|
|
49
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
50
|
+
textProps={{size: "md"}}
|
|
51
|
+
/>
|
|
52
|
+
<UrlField
|
|
53
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
54
|
+
textProps={{size: "lg"}}
|
|
55
|
+
/>
|
|
56
|
+
<UrlField
|
|
57
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
58
|
+
textProps={{size: "xl"}}
|
|
59
|
+
/>
|
|
60
|
+
</>
|
|
61
|
+
|
|
62
|
+
export const WithTarget = () =>
|
|
63
|
+
<UrlField
|
|
64
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
65
|
+
anchorProps={{target: "_blank"}}
|
|
66
|
+
/>;
|
|
67
|
+
|
|
68
|
+
export const Truncated = () =>
|
|
69
|
+
<UrlField
|
|
70
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
71
|
+
anchorProps={{maw: 200}}
|
|
72
|
+
textProps={{truncate: "end"}}
|
|
73
|
+
/>;
|
|
74
|
+
|
|
75
|
+
export const WithTitle = () =>
|
|
76
|
+
<UrlField
|
|
77
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
78
|
+
anchorProps={{title: "refine-mantine"}}
|
|
79
|
+
/>;
|
|
80
|
+
|
|
81
|
+
export const Gradient = () =>
|
|
82
|
+
<UrlField
|
|
83
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
84
|
+
anchorProps={{
|
|
85
|
+
variant: "gradient",
|
|
86
|
+
gradient: { from: 'pink', to: 'yellow' }
|
|
87
|
+
}}
|
|
88
|
+
/>;
|
|
89
|
+
|
|
90
|
+
export const HiddenIcon = () =>
|
|
91
|
+
<UrlField
|
|
92
|
+
value="https://github.com/kruschid/refine-mantine"
|
|
93
|
+
iconProps={{
|
|
94
|
+
display: "none",
|
|
95
|
+
}}
|
|
96
|
+
/>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Anchor, AnchorProps, PolymorphicComponentProps, Text, TextProps } from "@mantine/core";
|
|
2
|
+
import { IconExternalLink, IconProps, ReactNode } from "@tabler/icons-react";
|
|
3
|
+
|
|
4
|
+
export interface UrlFieldProps {
|
|
5
|
+
value: string;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
anchorProps?: PolymorphicComponentProps<"a", AnchorProps>;
|
|
8
|
+
textProps?: TextProps;
|
|
9
|
+
iconProps?: IconProps;
|
|
10
|
+
icon?: React.FC<IconProps>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const UrlField: React.FC<UrlFieldProps> = ({
|
|
14
|
+
children,
|
|
15
|
+
value,
|
|
16
|
+
anchorProps,
|
|
17
|
+
textProps,
|
|
18
|
+
icon,
|
|
19
|
+
iconProps,
|
|
20
|
+
}) => {
|
|
21
|
+
const Icon = icon ?? IconExternalLink;
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<Anchor
|
|
25
|
+
href={value}
|
|
26
|
+
style={{display: "inline-flex", alignItems: "center"}}
|
|
27
|
+
{...anchorProps}
|
|
28
|
+
>
|
|
29
|
+
<Text {...textProps}>
|
|
30
|
+
{children ?? value}
|
|
31
|
+
</Text>
|
|
32
|
+
<Icon
|
|
33
|
+
size={
|
|
34
|
+
textProps?.size === "xs" ? 12
|
|
35
|
+
: textProps?.size === "sm" ? 14
|
|
36
|
+
: textProps?.size === "md" ? 16
|
|
37
|
+
: textProps?.size === "lg" ? 18
|
|
38
|
+
: textProps?.size === "xl" ? 20
|
|
39
|
+
: 16
|
|
40
|
+
}
|
|
41
|
+
style={{ marginLeft: 4, flexShrink: 0 }}
|
|
42
|
+
aria-hidden
|
|
43
|
+
{...iconProps}
|
|
44
|
+
/>
|
|
45
|
+
</Anchor>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { Badge, NumberFormatter, Select, Text } from "@mantine/core";
|
|
1
|
+
import { ActionIconGroup, Badge, NumberFormatter, Select, Text } from "@mantine/core";
|
|
2
2
|
import { type CrudOperators, useSelect } from "@refinedev/core";
|
|
3
3
|
import { useTable } from "@refinedev/react-table";
|
|
4
4
|
import type { Meta } from "@storybook/react";
|
|
5
5
|
import type { ColumnDef } from "@tanstack/react-table";
|
|
6
|
-
import {
|
|
6
|
+
import { useCallback, useMemo } from "react";
|
|
7
|
+
import { DeleteButton } from "../buttons/DeleteButton";
|
|
8
|
+
import { EditButton } from "../buttons/EditButton";
|
|
9
|
+
import { ShowButton } from "../buttons/ShowButton";
|
|
7
10
|
import { Table } from "./Table";
|
|
8
11
|
|
|
9
12
|
export default {
|
|
@@ -30,7 +33,7 @@ interface CategoryRecord {
|
|
|
30
33
|
type ProductRecordKey = keyof ProductRecord;
|
|
31
34
|
|
|
32
35
|
const useTableProps = () => {
|
|
33
|
-
const categories = useSelect<CategoryRecord>({
|
|
36
|
+
const categories = useSelect<CategoryRecord>({
|
|
34
37
|
resource: "categories",
|
|
35
38
|
optionLabel: category => category.title,
|
|
36
39
|
optionValue: category => category.id.toString(),
|
|
@@ -117,6 +120,22 @@ const categories = useSelect<CategoryRecord>({
|
|
|
117
120
|
{categoryMap[row.original.category.id] ?? "uncategorized"}
|
|
118
121
|
</Badge>
|
|
119
122
|
},
|
|
123
|
+
{
|
|
124
|
+
id: "id" satisfies ProductRecordKey,
|
|
125
|
+
enableColumnFilter: false,
|
|
126
|
+
enableSorting: false,
|
|
127
|
+
header: "Actions",
|
|
128
|
+
cell: ({ row }) => (
|
|
129
|
+
<ActionIconGroup>
|
|
130
|
+
<ShowButton hideText recordItemId={row.original.id} />
|
|
131
|
+
<EditButton
|
|
132
|
+
hideText
|
|
133
|
+
recordItemId={row.original.id}
|
|
134
|
+
/>
|
|
135
|
+
<DeleteButton hideText recordItemId={row.original.id} />
|
|
136
|
+
</ActionIconGroup>
|
|
137
|
+
),
|
|
138
|
+
},
|
|
120
139
|
],
|
|
121
140
|
[categoryMap, CategoryFilter],
|
|
122
141
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Box, Group, Table as MantineTable, Pagination, TableProps
|
|
1
|
+
import { Box, Group, Table as MantineTable, Pagination, type TableProps } from "@mantine/core";
|
|
2
2
|
import type { BaseRecord, HttpError } from "@refinedev/core";
|
|
3
3
|
import type { UseTableReturnType } from "@refinedev/react-table";
|
|
4
4
|
import { flexRender } from "@tanstack/react-table";
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,13 @@ export * from "@/components/crud/Create";
|
|
|
13
13
|
export * from "@/components/crud/Edit";
|
|
14
14
|
export * from "@/components/crud/List";
|
|
15
15
|
export * from "@/components/crud/Show";
|
|
16
|
+
// fields
|
|
17
|
+
export * from "@/components/fields/BooleanField";
|
|
18
|
+
export * from "@/components/fields/DateField";
|
|
19
|
+
export * from "@/components/fields/EmailField";
|
|
20
|
+
export * from "@/components/fields/FileField";
|
|
21
|
+
export * from "@/components/fields/PhoneField";
|
|
22
|
+
export * from "@/components/fields/UrlField";
|
|
16
23
|
// layout
|
|
17
24
|
export * from "@/components/layout/Layout";
|
|
18
25
|
// notification
|