@hed-hog/core 0.0.261 → 0.0.266

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.
@@ -9,17 +9,6 @@
9
9
  role:
10
10
  - where:
11
11
  slug: admin-access
12
- - url: /core/menu
13
- order: 0
14
- icon: menu
15
- name:
16
- en: Menus
17
- pt: Menus
18
- slug: /core/menu
19
- relations:
20
- role:
21
- - where:
22
- slug: admin
23
12
  - order: 1000
24
13
  icon: settings-2
25
14
  name:
@@ -30,6 +19,20 @@
30
19
  role:
31
20
  - where:
32
21
  slug: admin
22
+ - menu_id:
23
+ where:
24
+ slug: /core/management
25
+ url: /core/menu
26
+ order: 0
27
+ icon: menu
28
+ name:
29
+ en: Menus
30
+ pt: Menus
31
+ slug: /core/menu
32
+ relations:
33
+ role:
34
+ - where:
35
+ slug: admin
33
36
  - menu_id:
34
37
  where:
35
38
  slug: /core/management
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import { Card, CardContent } from '@/components/ui/card';
4
- import { PaginatedResult } from '@hed-hog/api-pagination';
4
+ import { PaginatedResult } from '@/types/pagination-result';
5
5
  import { Setting } from '@hed-hog/api-types';
6
6
  import { useApp, useQuery } from '@hed-hog/next-app-provider';
7
7
  import { Loader } from 'lucide-react';
@@ -19,7 +19,7 @@ import {
19
19
  DropdownMenuTrigger,
20
20
  } from '@/components/ui/dropdown-menu';
21
21
  import { cn } from '@/lib/utils';
22
- import { PaginatedResult } from '@hed-hog/api-pagination';
22
+ import { PaginatedResult } from '@/types/pagination-result';
23
23
  import { SettingGroup } from '@hed-hog/api-types';
24
24
  import { useApp, useQuery } from '@hed-hog/next-app-provider';
25
25
  import { Download, MenuIcon, Upload } from 'lucide-react';
@@ -64,7 +64,7 @@ export default function ConfigurationsLayout({ children }: IProps) {
64
64
  const fileInputRef = useRef<HTMLInputElement>(null);
65
65
 
66
66
  const handleExport = (includeSecrets: boolean) => {
67
- request({
67
+ request<Blob>({
68
68
  url: `/setting/export?secrets=${includeSecrets}`,
69
69
  responseType: 'blob',
70
70
  })
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import { Loading } from '@/components/loading';
4
- import { PaginatedResult } from '@hed-hog/api-pagination';
4
+ import { PaginatedResult } from '@/types/pagination-result';
5
5
  import { SettingGroup } from '@hed-hog/api-types';
6
6
  import { useApp, useQuery } from '@hed-hog/next-app-provider';
7
7
  import { useRouter } from 'next/navigation';
@@ -23,7 +23,7 @@ export default function Page() {
23
23
 
24
24
  useEffect(() => {
25
25
  if ((settingGroups?.data || []).length > 0) {
26
- router.push(`/core/configurations/${settingGroups.data[0].slug}`);
26
+ router.push(`/core/configurations/${settingGroups?.data?.[0]?.slug}`);
27
27
  }
28
28
  }, [settingGroups]);
29
29
 
@@ -35,6 +35,24 @@ interface DraggableGridProps {
35
35
  containerPadding?: [number, number];
36
36
  }
37
37
 
38
+ // Simple compaction function for grid layout
39
+ const compactLayout = (
40
+ layout: RGLLayout,
41
+ cols: number,
42
+ compactType: 'vertical' | 'horizontal' | null
43
+ ): RGLLayout => {
44
+ if (!Array.isArray(layout)) return layout;
45
+
46
+ const sorted = [...layout].sort((a, b) => {
47
+ if (compactType === 'vertical') {
48
+ return a.y - b.y || a.x - b.x;
49
+ }
50
+ return a.x - b.x || a.y - b.y;
51
+ });
52
+
53
+ return sorted as RGLLayout;
54
+ };
55
+
38
56
  export function DraggableGrid({
39
57
  layout,
40
58
  onLayoutChange,
@@ -92,20 +110,28 @@ export function DraggableGrid({
92
110
  <GridLayout
93
111
  className={`layout ${className}`}
94
112
  layout={layout}
95
- cols={cols}
96
- rowHeight={rowHeight}
113
+ gridConfig={{
114
+ cols,
115
+ rowHeight,
116
+ containerPadding,
117
+ margin,
118
+ }}
119
+ dragConfig={{
120
+ enabled: isDraggable,
121
+ handle: '.drag-handle',
122
+ cancel: 'button,.no-drag',
123
+ }}
97
124
  width={containerWidth}
98
- isDraggable={isDraggable}
99
- isResizable={isResizable}
100
- compactType={compactType}
101
- preventCollision={preventCollision}
102
- margin={margin}
103
- containerPadding={containerPadding}
125
+ resizeConfig={{
126
+ enabled: isResizable,
127
+ handles: ['se', 's', 'e', 'sw', 'w', 'n', 'ne', 'nw'],
128
+ }}
129
+ compactor={{
130
+ type: compactType,
131
+ allowOverlap: !preventCollision,
132
+ compact: (layout, cols) => compactLayout(layout, cols, compactType),
133
+ }}
104
134
  onLayoutChange={handleLayoutChange}
105
- useCSSTransforms={true}
106
- draggableHandle=".drag-handle"
107
- resizeHandles={['se', 's', 'e', 'sw', 'w', 'n', 'ne', 'nw']}
108
- draggableCancel="button,.no-drag"
109
135
  >
110
136
  {children}
111
137
  </GridLayout>
@@ -11,7 +11,7 @@ import {
11
11
  SelectTrigger,
12
12
  SelectValue,
13
13
  } from '@/components/ui/select';
14
- import { PaginatedResult } from '@hed-hog/api-pagination';
14
+ import { PaginatedResult } from '@/types/pagination-result';
15
15
  import { Setting, SettingList } from '@hed-hog/api-types';
16
16
  import { useApp, useQuery } from '@hed-hog/next-app-provider';
17
17
  import { zodResolver } from '@hookform/resolvers/zod';
@@ -223,7 +223,7 @@ export default function RolePage() {
223
223
  }
224
224
  };
225
225
 
226
- const handleEdit = async (role: Role) => {
226
+ const handleEdit = async (role: Role & { role_id: number }) => {
227
227
  setEditFormError(null);
228
228
 
229
229
  try {
@@ -426,65 +426,67 @@ export default function RolePage() {
426
426
  <p className="text-sm text-muted-foreground">{t('noRolesFound')}</p>
427
427
  ) : (
428
428
  <div className="grid gap-4 grid-cols-1 lg:grid-cols-2 xl:grid-cols-3">
429
- {rolesResponse?.data?.map((role: Role & { role_id: number }) => (
430
- <Card
431
- key={String(role.role_id)}
432
- onDoubleClick={() => handleEdit(role)}
433
- className="cursor-pointer rounded-md flex flex-col justify-between gap-2 border border-border/60 bg-card p-4 shadow-sm transition hover:border-primary"
434
- >
435
- <CardHeader className="flex items-start justify-between gap-4 p-0">
436
- <div className="flex items-center gap-3 flex-1">
437
- <div className="h-12 w-12 shrink-0 rounded-full bg-primary/10 flex items-center justify-center">
438
- <ShieldCheck className="h-6 w-6 text-primary" />
439
- </div>
440
- <div className="flex-1">
441
- <CardTitle className="text-sm font-semibold">
442
- {role.name}
443
- </CardTitle>
444
- <CardDescription className="text-xs text-muted-foreground">
445
- {role.slug}
446
- </CardDescription>
447
- </div>
448
- </div>
449
- <Button
450
- variant="outline"
451
- size="sm"
452
- onClick={() => handleEdit(role)}
453
- >
454
- {t('buttonEditRole')}
455
- </Button>
456
- </CardHeader>
457
- {role.description && (
458
- <CardContent className="p-0">
459
- <p className="text-xs text-muted-foreground line-clamp-2">
460
- {role.description}
461
- </p>
462
- <div className="text-xs line-clamp-2 flex gap-2 py-2">
463
- <div>
464
- {(role as any).user_count}{' '}
465
- {(role as any).user_count === 1
466
- ? t('user')
467
- : t('users')}
468
- </div>
469
- <div>•</div>
470
- <div>
471
- {(role as any).menu_count}{' '}
472
- {(role as any).menu_count === 1
473
- ? t('menu')
474
- : t('menus')}
429
+ {(rolesResponse?.data as (Role & { role_id: number })[])?.map(
430
+ (role: Role & { role_id: number }) => (
431
+ <Card
432
+ key={String(role.role_id)}
433
+ onDoubleClick={() => handleEdit(role)}
434
+ className="cursor-pointer rounded-md flex flex-col justify-between gap-2 border border-border/60 bg-card p-4 shadow-sm transition hover:border-primary"
435
+ >
436
+ <CardHeader className="flex items-start justify-between gap-4 p-0">
437
+ <div className="flex items-center gap-3 flex-1">
438
+ <div className="h-12 w-12 shrink-0 rounded-full bg-primary/10 flex items-center justify-center">
439
+ <ShieldCheck className="h-6 w-6 text-primary" />
475
440
  </div>
476
- <div>•</div>
477
- <div>
478
- {(role as any).route_count}{' '}
479
- {(role as any).route_count === 1
480
- ? t('route')
481
- : t('routes')}
441
+ <div className="flex-1">
442
+ <CardTitle className="text-sm font-semibold">
443
+ {role.name}
444
+ </CardTitle>
445
+ <CardDescription className="text-xs text-muted-foreground">
446
+ {role.slug}
447
+ </CardDescription>
482
448
  </div>
483
449
  </div>
484
- </CardContent>
485
- )}
486
- </Card>
487
- ))}
450
+ <Button
451
+ variant="outline"
452
+ size="sm"
453
+ onClick={() => handleEdit(role)}
454
+ >
455
+ {t('buttonEditRole')}
456
+ </Button>
457
+ </CardHeader>
458
+ {role.description && (
459
+ <CardContent className="p-0">
460
+ <p className="text-xs text-muted-foreground line-clamp-2">
461
+ {role.description}
462
+ </p>
463
+ <div className="text-xs line-clamp-2 flex gap-2 py-2">
464
+ <div>
465
+ {(role as any).user_count}{' '}
466
+ {(role as any).user_count === 1
467
+ ? t('user')
468
+ : t('users')}
469
+ </div>
470
+ <div>•</div>
471
+ <div>
472
+ {(role as any).menu_count}{' '}
473
+ {(role as any).menu_count === 1
474
+ ? t('menu')
475
+ : t('menus')}
476
+ </div>
477
+ <div>•</div>
478
+ <div>
479
+ {(role as any).route_count}{' '}
480
+ {(role as any).route_count === 1
481
+ ? t('route')
482
+ : t('routes')}
483
+ </div>
484
+ </div>
485
+ </CardContent>
486
+ )}
487
+ </Card>
488
+ )
489
+ )}
488
490
  </div>
489
491
  )}
490
492
 
@@ -41,7 +41,7 @@ import {
41
41
  import { formatDateTime } from '@/lib/format-date';
42
42
  import { getPhotoUrl } from '@/lib/get-photo-url';
43
43
  import { getUserEmail } from '@/lib/get-user-email';
44
- import { PaginatedResult } from '@hed-hog/api-pagination';
44
+ import { PaginatedResult } from '@/types/pagination-result';
45
45
  import { User, UserMfa } from '@hed-hog/api-types';
46
46
  import { useApp, useQuery } from '@hed-hog/next-app-provider';
47
47
  import { zodResolver } from '@hookform/resolvers/zod';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hed-hog/core",
3
- "version": "0.0.261",
3
+ "version": "0.0.266",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "dependencies": {
@@ -30,12 +30,12 @@
30
30
  "sharp": "^0.34.2",
31
31
  "speakeasy": "^2.0.0",
32
32
  "uuid": "^11.1.0",
33
- "@hed-hog/api-mail": "0.0.7",
34
- "@hed-hog/api-pagination": "0.0.5",
35
- "@hed-hog/api-prisma": "0.0.4",
36
- "@hed-hog/api-locale": "0.0.11",
33
+ "@hed-hog/api-pagination": "0.0.6",
34
+ "@hed-hog/api-mail": "0.0.8",
35
+ "@hed-hog/api-locale": "0.0.13",
36
+ "@hed-hog/api-prisma": "0.0.5",
37
37
  "@hed-hog/api-types": "0.0.1",
38
- "@hed-hog/api": "0.0.3"
38
+ "@hed-hog/api": "0.0.4"
39
39
  },
40
40
  "exports": {
41
41
  ".": {