refine-mantine 1.7.0-dev.2 → 1.7.0-dev.4

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
@@ -194,6 +194,31 @@ declare const FileField: React.FC<UrlFieldProps>;
194
194
  declare const PhoneField: React.FC<UrlFieldProps>;
195
195
  //#endregion
196
196
  //#region src/components/layout/Layout.d.ts
197
+ interface LayoutProps$1 {
198
+ children: ReactNode$1;
199
+ shellProps?: AppShellProps;
200
+ headerProps?: AppShellHeaderProps;
201
+ navbarProps?: AppShellNavbarProps;
202
+ navbarConfiguration?: Partial<AppShellNavbarConfiguration>;
203
+ navbarMenuProps?: AppShellSectionProps;
204
+ navbarFooterProps?: AppShellSectionProps;
205
+ mainProps?: AppShellMainProps;
206
+ hideNavbar?: boolean;
207
+ footer?: ReactNode$1;
208
+ footerProps?: AppShellFooterProps;
209
+ locales?: LayoutLocale$1[];
210
+ renderHeader?: (toggle: () => void) => ReactNode$1;
211
+ renderMenu?: (params: ReturnType<typeof useMenu>) => ReactNode$1;
212
+ renderIdentity?: <T extends BaseRecord>(identity: T, logout: () => void) => ReactNode$1;
213
+ }
214
+ interface LayoutLocale$1 {
215
+ lang: string;
216
+ label: string;
217
+ icon?: ReactNode$1;
218
+ }
219
+ declare const Layout: React.FC<LayoutProps$1>;
220
+ //#endregion
221
+ //#region src/components/layout/LayoutMinimal.d.ts
197
222
  interface LayoutProps {
198
223
  children: ReactNode$1;
199
224
  shellProps?: AppShellProps;
@@ -216,7 +241,7 @@ interface LayoutLocale {
216
241
  label: string;
217
242
  icon?: ReactNode$1;
218
243
  }
219
- declare const Layout: React.FC<LayoutProps>;
244
+ declare const LayoutMinimal: React.FC<LayoutProps>;
220
245
  //#endregion
221
246
  //#region src/components/notification/AutoSaveIndicator.d.ts
222
247
  interface AutoSaveIndicatorProps {
@@ -423,4 +448,4 @@ declare const authProvider: AuthProvider;
423
448
  //#region src/providers/notificationProvider.d.ts
424
449
  declare const notificationProvider: () => NotificationProvider;
425
450
  //#endregion
426
- export { AutoSaveIndicator, AutoSaveIndicatorProps, BooleanField, BooleanFieldProps, Breadcrumb, BreadcrumbProps, CloneButton, CloneButtonProps, ColorSchemeToggle, ColumnFilter, ColumnSorter, Create, CreateButton, CreateButtonProps, CreateProps, DateField, DateFieldProps, DeleteButton, DeleteButtonProps, Edit, EditButton, EditButtonProps, EditProps, EmailField, Empty, ExportButton, ExportButtonProps, FileField, ForgotPasswordForm, ForgotPasswordPage, ForgotPasswordPageProps, ImportButton, ImportButtonProps, Layout, LayoutLocale, List, ListButton, ListButtonProps, ListProps, LoginArgs, LoginPage, LoginPageProps, Message, MessageProps, NotFound, OAuthProviderMantine, OtpHandler, PhoneField, RefreshButton, RefreshButtonProps, RegisterForm, RegisterPage, RegisterPageProps, RegistrationVerificationPage, RegistrationVerificationPageProps, SaveButton, SaveButtonProps, Show, ShowButton, ShowButtonProps, ShowProps, Table, TranslateFn, UpdatePasswordPage, UpdatePasswordPageProps, UrlField, UrlFieldProps, UseFormProps, UseFormReturnType, authProvider, notificationProvider, useForm, useOtp };
451
+ export { AutoSaveIndicator, AutoSaveIndicatorProps, BooleanField, BooleanFieldProps, Breadcrumb, BreadcrumbProps, CloneButton, CloneButtonProps, ColorSchemeToggle, ColumnFilter, ColumnSorter, Create, CreateButton, CreateButtonProps, CreateProps, DateField, DateFieldProps, DeleteButton, DeleteButtonProps, Edit, EditButton, EditButtonProps, EditProps, EmailField, Empty, ExportButton, ExportButtonProps, FileField, ForgotPasswordForm, ForgotPasswordPage, ForgotPasswordPageProps, ImportButton, ImportButtonProps, Layout, LayoutMinimal, List, ListButton, ListButtonProps, ListProps, LoginArgs, LoginPage, LoginPageProps, Message, MessageProps, NotFound, OAuthProviderMantine, OtpHandler, PhoneField, RefreshButton, RefreshButtonProps, RegisterForm, RegisterPage, RegisterPageProps, RegistrationVerificationPage, RegistrationVerificationPageProps, SaveButton, SaveButtonProps, Show, ShowButton, ShowButtonProps, ShowProps, Table, TranslateFn, UpdatePasswordPage, UpdatePasswordPageProps, UrlField, UrlFieldProps, UseFormProps, UseFormReturnType, authProvider, notificationProvider, useForm, useOtp };
package/dist/index.js CHANGED
@@ -1103,7 +1103,7 @@ const Layout = (p) => {
1103
1103
  to: "/",
1104
1104
  style: { all: "unset" },
1105
1105
  children: /* @__PURE__ */ jsxs(Group, { children: [defaultIcon, /* @__PURE__ */ jsx(Text, { children: defaultText })] })
1106
- })] }), /* @__PURE__ */ jsxs(Group, { children: [p.locales && /* @__PURE__ */ jsx(Locales, { locales: p.locales }), /* @__PURE__ */ jsx(Tooltip, {
1106
+ })] }), /* @__PURE__ */ jsxs(Group, { children: [p.locales && /* @__PURE__ */ jsx(Locales$1, { locales: p.locales }), /* @__PURE__ */ jsx(Tooltip, {
1107
1107
  label: computedColorScheme === "dark" ? translate("layout.header.lightMode", "Light mode") : translate("layout.header.darkMode", "Dark mode"),
1108
1108
  children: /* @__PURE__ */ jsx(ActionIcon, {
1109
1109
  onClick: () => setColorScheme(computedColorScheme === "light" ? "dark" : "light"),
@@ -1181,7 +1181,7 @@ const MenuItem = (p) => {
1181
1181
  }, p.item.key)
1182
1182
  }, p.item.key);
1183
1183
  };
1184
- const Locales = (p) => {
1184
+ const Locales$1 = (p) => {
1185
1185
  const { changeLocale, getLocale } = useTranslation();
1186
1186
  const locale = getLocale();
1187
1187
  return /* @__PURE__ */ jsxs(Menu, {
@@ -1196,6 +1196,282 @@ const Locales = (p) => {
1196
1196
  });
1197
1197
  };
1198
1198
 
1199
+ //#endregion
1200
+ //#region src/components/layout/LayoutMinimal.tsx
1201
+ const LayoutMinimal = (p) => {
1202
+ const [opened, { toggle, close }] = useDisclosure();
1203
+ const { title: { icon: defaultIcon, text: defaultText } = {} } = useRefineOptions();
1204
+ const { data: identity } = useGetIdentity();
1205
+ const menu = useMenu();
1206
+ const { mutate: logout } = useLogout();
1207
+ const { setColorScheme } = useMantineColorScheme();
1208
+ const computedColorScheme = useComputedColorScheme("light", { getInitialValueInEffect: true });
1209
+ const translate = useTranslate();
1210
+ const languageLabel = translate("layout.navbar.languageLabel", "Language");
1211
+ const colorSchemeLabel = computedColorScheme === "dark" ? translate("layout.header.lightMode", "Light mode") : translate("layout.header.darkMode", "Dark mode");
1212
+ const handleLogout = useCallback(() => {
1213
+ logout();
1214
+ }, [logout]);
1215
+ return /* @__PURE__ */ jsxs(AppShell, {
1216
+ header: { height: {
1217
+ base: 60,
1218
+ sm: 0
1219
+ } },
1220
+ navbar: {
1221
+ width: {
1222
+ base: 260,
1223
+ sm: 80
1224
+ },
1225
+ breakpoint: "sm",
1226
+ collapsed: {
1227
+ mobile: !opened || p.hideNavbar,
1228
+ desktop: p.hideNavbar
1229
+ },
1230
+ ...p.navbarConfiguration
1231
+ },
1232
+ padding: "md",
1233
+ ...p.shellProps,
1234
+ children: [
1235
+ /* @__PURE__ */ jsx(AppShell.Header, {
1236
+ p: "md",
1237
+ ...p.headerProps,
1238
+ hiddenFrom: "sm",
1239
+ children: p.renderHeader ? p.renderHeader(toggle) : /* @__PURE__ */ jsx(Group, {
1240
+ justify: "space-between",
1241
+ children: /* @__PURE__ */ jsxs(Group, { children: [/* @__PURE__ */ jsx(Burger, {
1242
+ opened,
1243
+ onClick: toggle,
1244
+ size: "sm",
1245
+ hidden: p.hideNavbar
1246
+ }), /* @__PURE__ */ jsx(Anchor, {
1247
+ component: Link,
1248
+ to: "/",
1249
+ style: { all: "unset" },
1250
+ children: /* @__PURE__ */ jsxs(Group, { children: [defaultIcon, defaultText ? /* @__PURE__ */ jsx(Text, { children: defaultText }) : null] })
1251
+ })] })
1252
+ })
1253
+ }),
1254
+ /* @__PURE__ */ jsxs(AppShell.Navbar, {
1255
+ ...p.navbarProps,
1256
+ children: [
1257
+ /* @__PURE__ */ jsx(AppShell.Section, {
1258
+ visibleFrom: "sm",
1259
+ p: "md",
1260
+ children: /* @__PURE__ */ jsx(Stack, {
1261
+ align: "center",
1262
+ gap: "xs",
1263
+ children: /* @__PURE__ */ jsx(Tooltip, {
1264
+ label: defaultText ?? translate("layout.navbar.homeLabel", "Home"),
1265
+ position: "right",
1266
+ transitionProps: { duration: 0 },
1267
+ children: /* @__PURE__ */ jsx(Anchor, {
1268
+ component: Link,
1269
+ to: "/",
1270
+ style: { all: "unset" },
1271
+ children: /* @__PURE__ */ jsx(Stack, {
1272
+ align: "center",
1273
+ gap: 2,
1274
+ children: defaultIcon
1275
+ })
1276
+ })
1277
+ })
1278
+ })
1279
+ }),
1280
+ /* @__PURE__ */ jsx(AppShell.Section, {
1281
+ component: ScrollArea,
1282
+ grow: true,
1283
+ mt: "xs",
1284
+ ...p.navbarMenuProps,
1285
+ visibleFrom: "sm",
1286
+ children: p.renderMenu ? p.renderMenu(menu) : /* @__PURE__ */ jsx(Stack, {
1287
+ align: "center",
1288
+ gap: 0,
1289
+ children: menu.menuItems.map((item) => /* @__PURE__ */ jsx(MenuItemIcon, {
1290
+ item,
1291
+ selectedKey: menu.selectedKey,
1292
+ onClick: close
1293
+ }, item.key))
1294
+ })
1295
+ }),
1296
+ /* @__PURE__ */ jsx(AppShell.Section, {
1297
+ component: ScrollArea,
1298
+ grow: true,
1299
+ mt: "xs",
1300
+ ...p.navbarMenuProps,
1301
+ hiddenFrom: "sm",
1302
+ children: p.renderMenu ? p.renderMenu(menu) : /* @__PURE__ */ jsx(Stack, {
1303
+ gap: "xs",
1304
+ children: menu.menuItems.map((item) => /* @__PURE__ */ jsx(MenuItemFull, {
1305
+ item,
1306
+ selectedKey: menu.selectedKey,
1307
+ onClick: close
1308
+ }, item.key))
1309
+ })
1310
+ }),
1311
+ /* @__PURE__ */ jsx(AppShell.Section, {
1312
+ ...p.navbarFooterProps,
1313
+ visibleFrom: "sm",
1314
+ children: p.renderIdentity ? p.renderIdentity(identity, handleLogout) : /* @__PURE__ */ jsxs(Stack, {
1315
+ align: "center",
1316
+ gap: "xs",
1317
+ children: [
1318
+ p.locales && /* @__PURE__ */ jsx(Locales, {
1319
+ locales: p.locales,
1320
+ variant: "icon",
1321
+ label: languageLabel
1322
+ }),
1323
+ /* @__PURE__ */ jsx(Tooltip, {
1324
+ label: colorSchemeLabel,
1325
+ position: "right",
1326
+ transitionProps: { duration: 0 },
1327
+ children: /* @__PURE__ */ jsx(ActionIcon, {
1328
+ onClick: () => setColorScheme(computedColorScheme === "light" ? "dark" : "light"),
1329
+ "aria-label": translate("layout.header.toggleColorScheme", "Toggle color scheme"),
1330
+ variant: "subtle",
1331
+ size: "xl",
1332
+ children: computedColorScheme === "light" ? /* @__PURE__ */ jsx(IconSun, {
1333
+ stroke: 1.5,
1334
+ size: 22
1335
+ }) : /* @__PURE__ */ jsx(IconMoon, {
1336
+ stroke: 1.5,
1337
+ size: 22
1338
+ })
1339
+ })
1340
+ }),
1341
+ /* @__PURE__ */ jsx(Tooltip, {
1342
+ label: translate("layout.navbar.signOutLabel", "Sign out"),
1343
+ position: "right",
1344
+ transitionProps: { duration: 0 },
1345
+ children: /* @__PURE__ */ jsx(ActionIcon, {
1346
+ onClick: handleLogout,
1347
+ "aria-label": translate("layout.navbar.signOutLabel", "Sign out"),
1348
+ variant: "subtle",
1349
+ size: "xl",
1350
+ children: /* @__PURE__ */ jsx(IconLogout, { size: 20 })
1351
+ })
1352
+ })
1353
+ ]
1354
+ })
1355
+ }),
1356
+ /* @__PURE__ */ jsx(AppShell.Section, {
1357
+ ...p.navbarFooterProps,
1358
+ hiddenFrom: "sm",
1359
+ children: /* @__PURE__ */ jsxs(Stack, {
1360
+ gap: "xs",
1361
+ children: [
1362
+ p.locales && /* @__PURE__ */ jsx(Locales, {
1363
+ locales: p.locales,
1364
+ variant: "full",
1365
+ label: languageLabel
1366
+ }),
1367
+ /* @__PURE__ */ jsx(NavLink, {
1368
+ onClick: () => setColorScheme(computedColorScheme === "light" ? "dark" : "light"),
1369
+ leftSection: computedColorScheme === "light" ? /* @__PURE__ */ jsx(IconSun, {
1370
+ stroke: 1.5,
1371
+ size: 18
1372
+ }) : /* @__PURE__ */ jsx(IconMoon, {
1373
+ stroke: 1.5,
1374
+ size: 18
1375
+ }),
1376
+ label: colorSchemeLabel,
1377
+ variant: "subtle"
1378
+ }),
1379
+ p.renderIdentity ? p.renderIdentity(identity, handleLogout) : /* @__PURE__ */ jsx(NavLink, {
1380
+ onClick: handleLogout,
1381
+ leftSection: identity?.avatar ? /* @__PURE__ */ jsx(Avatar, { src: identity.avatar }) : /* @__PURE__ */ jsx(IconLogout, { size: 18 }),
1382
+ label: translate("layout.navbar.signOutLabel", "Sign out"),
1383
+ description: identity?.email ? translate("layout.navbar.signOutDescription", { email: identity.email }, `Signed in as ${identity.email}`) : void 0,
1384
+ variant: "filled",
1385
+ active: true
1386
+ })
1387
+ ]
1388
+ })
1389
+ })
1390
+ ]
1391
+ }),
1392
+ /* @__PURE__ */ jsx(AppShell.Main, {
1393
+ ...p.mainProps,
1394
+ children: p.children
1395
+ }),
1396
+ /* @__PURE__ */ jsx(AppShell.Footer, {
1397
+ ...p.footerProps,
1398
+ children: p.footer
1399
+ })
1400
+ ]
1401
+ });
1402
+ };
1403
+ const MenuItemIcon = (p) => {
1404
+ const { listUrl } = useNavigation();
1405
+ const isSelected = p.item.key === p.selectedKey;
1406
+ const label = p.item.meta?.label ?? p.item.label ?? p.item.name;
1407
+ return /* @__PURE__ */ jsx(CanAccess, {
1408
+ resource: p.item.name,
1409
+ action: "list",
1410
+ params: { resource: p.item },
1411
+ children: /* @__PURE__ */ jsx(Tooltip, {
1412
+ label,
1413
+ position: "right",
1414
+ transitionProps: { duration: 0 },
1415
+ children: /* @__PURE__ */ jsx(ActionIcon, {
1416
+ component: Link,
1417
+ to: listUrl(p.item.name),
1418
+ variant: isSelected ? "filled" : "subtle",
1419
+ size: "xl",
1420
+ mb: "xs",
1421
+ bd: 0,
1422
+ onClick: p.onClick,
1423
+ children: p.item.meta?.icon ?? /* @__PURE__ */ jsx(IconList, { size: 20 })
1424
+ }, p.item.key)
1425
+ })
1426
+ }, p.item.key);
1427
+ };
1428
+ const MenuItemFull = (p) => {
1429
+ const { listUrl } = useNavigation();
1430
+ const isSelected = p.item.key === p.selectedKey;
1431
+ const label = p.item.meta?.label ?? p.item.label ?? p.item.name;
1432
+ return /* @__PURE__ */ jsx(CanAccess, {
1433
+ resource: p.item.name,
1434
+ action: "list",
1435
+ params: { resource: p.item },
1436
+ children: /* @__PURE__ */ jsx(NavLink, {
1437
+ label,
1438
+ leftSection: p.item.meta?.icon ?? /* @__PURE__ */ jsx(IconList, { size: 18 }),
1439
+ active: isSelected,
1440
+ component: Link,
1441
+ to: listUrl(p.item.name),
1442
+ onClick: p.onClick
1443
+ }, p.item.key)
1444
+ }, p.item.key);
1445
+ };
1446
+ const Locales = (p) => {
1447
+ const { changeLocale, getLocale } = useTranslation();
1448
+ const locale = getLocale();
1449
+ return /* @__PURE__ */ jsxs(Menu, {
1450
+ shadow: "md",
1451
+ width: 200,
1452
+ children: [/* @__PURE__ */ jsx(Menu.Target, { children: p.variant === "icon" ? /* @__PURE__ */ jsx(Tooltip, {
1453
+ label: p.label,
1454
+ position: "right",
1455
+ transitionProps: { duration: 0 },
1456
+ children: /* @__PURE__ */ jsx(ActionIcon, {
1457
+ "aria-label": p.label,
1458
+ variant: "subtle",
1459
+ size: "xl",
1460
+ children: /* @__PURE__ */ jsx(IconLanguage, {})
1461
+ })
1462
+ }) : /* @__PURE__ */ jsx(NavLink, {
1463
+ label: p.label,
1464
+ leftSection: /* @__PURE__ */ jsx(IconLanguage, { size: 18 }),
1465
+ component: "button"
1466
+ }) }), /* @__PURE__ */ jsx(Menu.Dropdown, { children: p.locales.map(({ label, lang, icon }) => /* @__PURE__ */ jsx(Menu.Item, {
1467
+ leftSection: icon,
1468
+ onClick: () => changeLocale(lang),
1469
+ rightSection: lang === locale ? /* @__PURE__ */ jsx(IconCheck, { size: 14 }) : void 0,
1470
+ children: label
1471
+ }, lang)) })]
1472
+ });
1473
+ };
1474
+
1199
1475
  //#endregion
1200
1476
  //#region src/components/notification/Message.tsx
1201
1477
  const Message = ({ message, description, undoLabel, undoableTime = 5, undoableTimeout = 0, notificationProps, actioniconProps, buttonProps, onUndo }) => /* @__PURE__ */ jsx(Notification, {
@@ -2140,4 +2416,4 @@ const notificationProvider = () => {
2140
2416
  };
2141
2417
 
2142
2418
  //#endregion
2143
- export { AutoSaveIndicator, BooleanField, Breadcrumb, CloneButton, ColorSchemeToggle, ColumnFilter, ColumnSorter, Create, CreateButton, DateField, DeleteButton, Edit, EditButton, EmailField, Empty, ExportButton, FileField, ForgotPasswordPage, ImportButton, Layout, List, ListButton, LoginPage, Message, NotFound, PhoneField, RefreshButton, RegisterPage, RegistrationVerificationPage, SaveButton, Show, ShowButton, Table, UpdatePasswordPage, UrlField, notificationProvider, useForm, useOtp };
2419
+ export { AutoSaveIndicator, BooleanField, Breadcrumb, CloneButton, ColorSchemeToggle, ColumnFilter, ColumnSorter, Create, CreateButton, DateField, DeleteButton, Edit, EditButton, EmailField, Empty, ExportButton, FileField, ForgotPasswordPage, ImportButton, Layout, LayoutMinimal, List, ListButton, LoginPage, Message, NotFound, PhoneField, RefreshButton, RegisterPage, RegistrationVerificationPage, SaveButton, Show, ShowButton, Table, UpdatePasswordPage, UrlField, notificationProvider, useForm, useOtp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "refine-mantine",
3
- "version": "1.7.0-dev.2",
3
+ "version": "1.7.0-dev.4",
4
4
  "type": "module",
5
5
  "exports": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,6 +1,6 @@
1
1
  import { Image } from "@mantine/core";
2
2
  import type { Meta } from "@storybook/react";
3
- import { Layout as LayoutMinimal } from "./LayoutMinimal";
3
+ import { LayoutMinimal } from "./LayoutMinimal";
4
4
 
5
5
  export default {
6
6
  title: "Components/LayoutMinimal",
@@ -62,7 +62,7 @@ export interface LayoutLocale {
62
62
  icon?: ReactNode;
63
63
  }
64
64
 
65
- export const Layout: React.FC<LayoutProps> = (p) => {
65
+ export const LayoutMinimal: React.FC<LayoutProps> = (p) => {
66
66
  const [opened, { toggle, close }] = useDisclosure();
67
67
  const { title: { icon: defaultIcon, text: defaultText } = {} } =
68
68
  useRefineOptions();
package/src/index.ts CHANGED
@@ -28,6 +28,7 @@ export * from "@/components/fields/PhoneField";
28
28
  export * from "@/components/fields/UrlField";
29
29
  // layout
30
30
  export * from "@/components/layout/Layout";
31
+ export * from "@/components/layout/LayoutMinimal";
31
32
  // notification
32
33
  export * from "@/components/notification/AutoSaveIndicator";
33
34
  export * from "@/components/notification/Message";