@telamonjs/ui 1.0.1 → 1.0.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/CHANGELOG.md +29 -0
- package/README.md +2 -3
- package/dist/components/data/DataTableActions.js +85 -49
- package/dist/components/forms/admin-form/visibility.js +2 -0
- package/dist/components/utilities/ErrorBoundary.d.ts +1 -1
- package/dist/exports/types-constants.d.ts +1 -1
- package/dist/exports/types-constants.js +1 -1
- package/dist/layouts/ModernSidebar.js +5 -0
- package/dist/queue/components/QueueTabbedDashboard.d.ts +5 -0
- package/dist/queue/components/QueueTabbedDashboard.js +11 -2
- package/dist/queue/components/tabs/TempoRealTab.d.ts +5 -1
- package/dist/queue/components/tabs/TempoRealTab.js +11 -5
- package/dist/queue/hooks/use-queue-events-timeline.d.ts +19 -1
- package/dist/queue/hooks/use-queue-events-timeline.js +23 -3
- package/dist/server/pagination/factory.js +8 -1
- package/dist/server/pagination/types.d.ts +6 -0
- package/dist/server/pagination/utils.d.ts +13 -0
- package/dist/server/pagination/utils.js +27 -16
- package/dist/stores/sidebar-store.js +6 -1
- package/dist/ui/command.d.ts +6 -6
- package/package.json +3 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7177dfb: Server pagination, row actions, queue polling and form-path hardening:
|
|
8
|
+
|
|
9
|
+
- `createPaginatedService`: `baseWhere`, visibility rules and search/filters are now always combined with `AND`. Before, a `baseWhere` with its own `AND` replaced the search conditions, and a visibility rule with a top-level `AND`/`OR` dropped `baseWhere`'s other keys (e.g. `deletedAt: null`), which could show hidden rows.
|
|
10
|
+
- `createPaginatedService`: an invalid `sortOrder` falls back to `defaultOrderDirection` instead of reaching Prisma, and the new optional `sortableFields` option ignores any `sortBy` outside the list (the default sort applies).
|
|
11
|
+
- Row actions in the "…" menu now honour `confirmDialog` (including a standard delete moved to the menu by `display.mode: 'dropdown'`). They used to run straight away.
|
|
12
|
+
- `QueueTabbedDashboard`: the real-time timeline polls only as a 30s safety net while SSE is connected and stops polling while another tab is open. The new optional `pollInterval` prop (default 2000 ms) sets the interval used while SSE is down.
|
|
13
|
+
- Form visibility helpers ignore field paths that go through `__proto__`, `constructor` or `prototype`.
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [a599b51]
|
|
16
|
+
- @telamonjs/logger@1.0.2
|
|
17
|
+
|
|
18
|
+
## 1.0.3
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- `ModernSidebar` no longer causes a hydration mismatch for users who saved the compact sidebar. The sidebar store read the preference from localStorage while being created, so the first client render differed from the server's and Radix ids shifted; it now reads it after hydration.
|
|
23
|
+
|
|
24
|
+
## 1.0.2
|
|
25
|
+
|
|
26
|
+
Tagged but not published to npm: 1.0.3 includes it.
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- `react-grid-layout` is now a dependency instead of an optional peer. The root entry reaches `DashboardGrid`, whose dynamic `import('react-grid-layout')` failed the build ("Module not found") in apps that had not installed it.
|
|
31
|
+
|
|
3
32
|
## 1.0.1
|
|
4
33
|
|
|
5
34
|
First public release of `@telamonjs/ui`. Release notes: [CHANGELOG.md](https://github.com/telamonjs/telamonjs/blob/main/CHANGELOG.md).
|
package/README.md
CHANGED
|
@@ -35,11 +35,10 @@ pnpm add @telamonjs/ui framer-motion jspdf jspdf-autotable next next-auth papapa
|
|
|
35
35
|
| `next-intl` | `^4.14.0` |
|
|
36
36
|
| `@tanstack/react-query` | `^5.90.2` |
|
|
37
37
|
| `@prisma/client` (optional) | `^5.0.0 \|\| ^6.0.0` |
|
|
38
|
-
| `react-grid-layout` (optional) | `^1.5.0 \|\| ^2.0.0` |
|
|
39
38
|
<!-- /generated:peers -->
|
|
40
39
|
|
|
41
|
-
`react-grid-layout`
|
|
42
|
-
`react-grid-layout/css/styles.css`), and `@prisma/client` only for the
|
|
40
|
+
`DashboardGrid` needs the `react-grid-layout` stylesheet
|
|
41
|
+
(`import 'react-grid-layout/css/styles.css'`), and `@prisma/client` is only needed for the
|
|
43
42
|
`./server` pagination helpers. Then load the styles and the Tailwind preset:
|
|
44
43
|
|
|
45
44
|
```tsx
|
|
@@ -81,6 +81,49 @@ async function runAction({
|
|
|
81
81
|
onSettled?.();
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
+
function ConfirmActionDialog({
|
|
85
|
+
action,
|
|
86
|
+
row,
|
|
87
|
+
open,
|
|
88
|
+
onOpenChange,
|
|
89
|
+
onConfirm,
|
|
90
|
+
children
|
|
91
|
+
}) {
|
|
92
|
+
const t = useTelamonjsT();
|
|
93
|
+
const text = useText();
|
|
94
|
+
const confirmConfig = action.confirmDialog === true ? {
|
|
95
|
+
title: t("dialog.confirmActionTitle"),
|
|
96
|
+
description: t("dialog.confirmActionDescription"),
|
|
97
|
+
confirmText: t("common.confirm"),
|
|
98
|
+
cancelText: t("common.cancel"),
|
|
99
|
+
variant: "default"
|
|
100
|
+
} : action.confirmDialog || {};
|
|
101
|
+
return /* @__PURE__ */ jsxs(AlertDialog, { open, onOpenChange, children: [
|
|
102
|
+
children && /* @__PURE__ */ jsx(AlertDialogTrigger, { asChild: true, children }),
|
|
103
|
+
/* @__PURE__ */ jsxs(AlertDialogContent, { children: [
|
|
104
|
+
/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
|
|
105
|
+
/* @__PURE__ */ jsx(AlertDialogTitle, { children: text(
|
|
106
|
+
typeof confirmConfig.title === "function" ? confirmConfig.title(row) : confirmConfig.title
|
|
107
|
+
) }),
|
|
108
|
+
confirmConfig.description && /* @__PURE__ */ jsx(AlertDialogDescription, { children: text(
|
|
109
|
+
typeof confirmConfig.description === "function" ? confirmConfig.description(row) : confirmConfig.description
|
|
110
|
+
) })
|
|
111
|
+
] }),
|
|
112
|
+
/* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
|
|
113
|
+
/* @__PURE__ */ jsx(AlertDialogCancel, { "data-testid": "modal-cancel", children: text(confirmConfig.cancelText) || t("common.cancel") }),
|
|
114
|
+
/* @__PURE__ */ jsx(
|
|
115
|
+
AlertDialogAction,
|
|
116
|
+
{
|
|
117
|
+
"data-testid": "modal-confirm",
|
|
118
|
+
className: confirmConfig.variant === "destructive" ? "bg-red-500 text-white hover:bg-red-600" : "",
|
|
119
|
+
onClick: onConfirm,
|
|
120
|
+
children: text(confirmConfig.confirmText) || t("common.confirm")
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
] })
|
|
124
|
+
] })
|
|
125
|
+
] });
|
|
126
|
+
}
|
|
84
127
|
function ActionButton({
|
|
85
128
|
action,
|
|
86
129
|
row,
|
|
@@ -159,20 +202,6 @@ function ActionButton({
|
|
|
159
202
|
}
|
|
160
203
|
}, [action.confirmDialog, executeAction]);
|
|
161
204
|
if (!isVisible) return null;
|
|
162
|
-
const getConfirmDialogConfig = () => {
|
|
163
|
-
if (!action.confirmDialog) return {};
|
|
164
|
-
if (action.confirmDialog === true) {
|
|
165
|
-
return {
|
|
166
|
-
title: t("dialog.confirmActionTitle"),
|
|
167
|
-
description: t("dialog.confirmActionDescription"),
|
|
168
|
-
confirmText: t("common.confirm"),
|
|
169
|
-
cancelText: t("common.cancel"),
|
|
170
|
-
variant: "default"
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
return action.confirmDialog;
|
|
174
|
-
};
|
|
175
|
-
const confirmConfig = getConfirmDialogConfig();
|
|
176
205
|
const buttonContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
177
206
|
action.icon && !isActionLoading && /* @__PURE__ */ jsx(action.icon, {}),
|
|
178
207
|
resolvedLabel && /* @__PURE__ */ jsx("span", { className: "ml-1.5", children: resolvedLabel }),
|
|
@@ -203,31 +232,17 @@ function ActionButton({
|
|
|
203
232
|
const withDisabledHint = (node) => !isEnabled && tooltipContent ? /* @__PURE__ */ jsx("span", { className: "inline-flex", "data-tooltip-text": tooltipContent, children: node }) : node;
|
|
204
233
|
if (action.confirmDialog) {
|
|
205
234
|
return withDisabledHint(
|
|
206
|
-
/* @__PURE__ */
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
/* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
|
|
218
|
-
/* @__PURE__ */ jsx(AlertDialogCancel, { "data-testid": "modal-cancel", children: text(confirmConfig.cancelText) || t("common.cancel") }),
|
|
219
|
-
/* @__PURE__ */ jsx(
|
|
220
|
-
AlertDialogAction,
|
|
221
|
-
{
|
|
222
|
-
"data-testid": "modal-confirm",
|
|
223
|
-
className: confirmConfig.variant === "destructive" ? "bg-red-500 text-white hover:bg-red-600" : "",
|
|
224
|
-
onClick: executeAction,
|
|
225
|
-
children: text(confirmConfig.confirmText) || t("common.confirm")
|
|
226
|
-
}
|
|
227
|
-
)
|
|
228
|
-
] })
|
|
229
|
-
] })
|
|
230
|
-
] })
|
|
235
|
+
/* @__PURE__ */ jsx(
|
|
236
|
+
ConfirmActionDialog,
|
|
237
|
+
{
|
|
238
|
+
action,
|
|
239
|
+
row,
|
|
240
|
+
open: confirmDialogOpen,
|
|
241
|
+
onOpenChange: setConfirmDialogOpen,
|
|
242
|
+
onConfirm: executeAction,
|
|
243
|
+
children: button
|
|
244
|
+
}
|
|
245
|
+
)
|
|
231
246
|
);
|
|
232
247
|
}
|
|
233
248
|
return withDisabledHint(button);
|
|
@@ -331,6 +346,19 @@ function DataTableActions({
|
|
|
331
346
|
)
|
|
332
347
|
};
|
|
333
348
|
}, [allActions, config.userPermissions]);
|
|
349
|
+
const [pendingConfirm, setPendingConfirm] = useState(null);
|
|
350
|
+
const runMenuAction = useCallback(
|
|
351
|
+
(actionId, action) => void runAction({
|
|
352
|
+
action,
|
|
353
|
+
row: row.original,
|
|
354
|
+
actionId,
|
|
355
|
+
router,
|
|
356
|
+
onActionComplete: handleActionComplete,
|
|
357
|
+
text,
|
|
358
|
+
fallbackError: t("toast.unknownError")
|
|
359
|
+
}),
|
|
360
|
+
[row.original, router, handleActionComplete, text, t]
|
|
361
|
+
);
|
|
334
362
|
const displayMode = config.display?.mode || "inline";
|
|
335
363
|
const maxInline = config.display?.maxInline || 999;
|
|
336
364
|
const spacing = config.display?.spacing || "normal";
|
|
@@ -395,15 +423,11 @@ function DataTableActions({
|
|
|
395
423
|
disabled: !isEnabled,
|
|
396
424
|
onClick: (event) => {
|
|
397
425
|
event.stopPropagation();
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
onActionComplete: handleActionComplete,
|
|
404
|
-
text,
|
|
405
|
-
fallbackError: t("toast.unknownError")
|
|
406
|
-
});
|
|
426
|
+
if (actionConfig.confirmDialog) {
|
|
427
|
+
setPendingConfirm({ id, config: actionConfig });
|
|
428
|
+
} else {
|
|
429
|
+
runMenuAction(id, actionConfig);
|
|
430
|
+
}
|
|
407
431
|
},
|
|
408
432
|
children: [
|
|
409
433
|
actionConfig.icon && /* @__PURE__ */ jsx("span", { className: "mr-2 h-4 w-4 shrink-0 [&_svg]:size-4", children: React.createElement(actionConfig.icon) }),
|
|
@@ -421,7 +445,19 @@ function DataTableActions({
|
|
|
421
445
|
)
|
|
422
446
|
] }, id);
|
|
423
447
|
}) })
|
|
424
|
-
] })
|
|
448
|
+
] }),
|
|
449
|
+
pendingConfirm && /* @__PURE__ */ jsx(
|
|
450
|
+
ConfirmActionDialog,
|
|
451
|
+
{
|
|
452
|
+
action: pendingConfirm.config,
|
|
453
|
+
row: row.original,
|
|
454
|
+
open: true,
|
|
455
|
+
onOpenChange: (open) => {
|
|
456
|
+
if (!open) setPendingConfirm(null);
|
|
457
|
+
},
|
|
458
|
+
onConfirm: () => runMenuAction(pendingConfirm.id, pendingConfirm.config)
|
|
459
|
+
}
|
|
460
|
+
)
|
|
425
461
|
] });
|
|
426
462
|
}
|
|
427
463
|
export {
|
|
@@ -19,8 +19,10 @@ function collectHiddenFieldNames(config, values) {
|
|
|
19
19
|
}
|
|
20
20
|
return hidden;
|
|
21
21
|
}
|
|
22
|
+
var UNSAFE_PATH_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
22
23
|
function deleteAtPath(obj, path) {
|
|
23
24
|
const parts = path.split(".");
|
|
25
|
+
if (parts.some((p) => UNSAFE_PATH_SEGMENTS.has(p))) return;
|
|
24
26
|
let target = obj;
|
|
25
27
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
26
28
|
const next = target[parts[i]];
|
|
@@ -12,7 +12,7 @@ export declare class ErrorBoundary extends Component<Props, State> {
|
|
|
12
12
|
constructor(props: Props);
|
|
13
13
|
static getDerivedStateFromError(error: Error): State;
|
|
14
14
|
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
15
|
-
render(): string | number | bigint | boolean |
|
|
15
|
+
render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
|
16
16
|
}
|
|
17
17
|
interface ErrorFallbackProps {
|
|
18
18
|
error?: Error;
|
|
@@ -7,4 +7,4 @@ export type { ModuleMetadata, ListConfig, CrudColumnDef, FormConfig, QueryConfig
|
|
|
7
7
|
export type { ColorPreset, StatItem, HeaderBadgeConfig, HeaderStatsConfig, DialogHeaderConfig, DialogHeaderProps, StatsGridProps, } from '../types/dialog-header';
|
|
8
8
|
export type { MenuItem, SingleMenuItem, GroupMenuItem, SeparatorMenuItem, MenuItemType, MenuVariant, IconComponent, } from '../types/menu';
|
|
9
9
|
export type { Density, GapSize, DialogSize, DialogHeight, FieldLayout, CardFieldLayout, } from '../utils/spacing';
|
|
10
|
-
export declare const version = "1.0.
|
|
10
|
+
export declare const version = "1.0.4";
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// src/layouts/ModernSidebar.tsx
|
|
4
4
|
import {
|
|
5
5
|
useCallback,
|
|
6
|
+
useEffect,
|
|
6
7
|
useMemo,
|
|
7
8
|
useState
|
|
8
9
|
} from "react";
|
|
@@ -10,6 +11,7 @@ import { usePathname } from "next/navigation";
|
|
|
10
11
|
import { useMediaQuery } from "../hooks/use-mobile.js";
|
|
11
12
|
import { useTelamonjsT, useText } from "../i18n/use-t.js";
|
|
12
13
|
import {
|
|
14
|
+
useSidebarStore,
|
|
13
15
|
useSidebarState,
|
|
14
16
|
useIsMobileOpen,
|
|
15
17
|
useSidebarActions
|
|
@@ -50,6 +52,9 @@ function ModernSidebar({
|
|
|
50
52
|
const text = useText();
|
|
51
53
|
const effectiveSystemName = systemName ?? t("shell.systemName");
|
|
52
54
|
const pathname = usePathname();
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
void useSidebarStore.persist.rehydrate();
|
|
57
|
+
}, []);
|
|
53
58
|
const sidebarState = useSidebarState();
|
|
54
59
|
const isMobileOpen = useIsMobileOpen();
|
|
55
60
|
const menuStack = useMenuStack();
|
|
@@ -15,6 +15,11 @@ export interface QueueTabbedDashboardProps {
|
|
|
15
15
|
moduleIcons?: Record<string, string>;
|
|
16
16
|
/** Enable SSE real-time updates (default: true) */
|
|
17
17
|
enableSSE?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Real-time timeline poll interval in ms while SSE is down (default: 2000).
|
|
20
|
+
* With SSE connected it polls every 30s; off the Real-time tab, not at all.
|
|
21
|
+
*/
|
|
22
|
+
pollInterval?: number;
|
|
18
23
|
/** Callback when tab changes (for URL sync) */
|
|
19
24
|
onTabChange?: (tab: string) => void;
|
|
20
25
|
/** Sync active tab with URL searchParams (default: false) */
|
|
@@ -27,6 +27,7 @@ function QueueTabbedDashboardCore({
|
|
|
27
27
|
icon,
|
|
28
28
|
moduleIcons,
|
|
29
29
|
enableSSE = true,
|
|
30
|
+
pollInterval,
|
|
30
31
|
onTabChange
|
|
31
32
|
}) {
|
|
32
33
|
const t = useTelamonjsT();
|
|
@@ -49,7 +50,15 @@ function QueueTabbedDashboardCore({
|
|
|
49
50
|
label: t("queue.tabs.realtime"),
|
|
50
51
|
shortLabel: t("queue.tabs.realtimeShort"),
|
|
51
52
|
icon: Radio,
|
|
52
|
-
content: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(PageSkeleton.TabContent, {}), children: /* @__PURE__ */ jsx(
|
|
53
|
+
content: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(PageSkeleton.TabContent, {}), children: /* @__PURE__ */ jsx(
|
|
54
|
+
TempoRealTab,
|
|
55
|
+
{
|
|
56
|
+
enableSSE,
|
|
57
|
+
moduleIcons,
|
|
58
|
+
active: activeTab === "tempo-real",
|
|
59
|
+
pollInterval
|
|
60
|
+
}
|
|
61
|
+
) })
|
|
53
62
|
},
|
|
54
63
|
{
|
|
55
64
|
value: "configuracao",
|
|
@@ -73,7 +82,7 @@ function QueueTabbedDashboardCore({
|
|
|
73
82
|
content: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(PageSkeleton.TabContent, {}), children: /* @__PURE__ */ jsx(HistoricoTab, {}) })
|
|
74
83
|
}
|
|
75
84
|
],
|
|
76
|
-
[moduleIcons, enableSSE, t]
|
|
85
|
+
[moduleIcons, enableSSE, pollInterval, activeTab, t]
|
|
77
86
|
);
|
|
78
87
|
const filteredTabs = useMemo(() => {
|
|
79
88
|
if (!visibleTabs) return allTabs;
|
|
@@ -4,6 +4,10 @@ interface TempoRealTabProps {
|
|
|
4
4
|
enableSSE?: boolean;
|
|
5
5
|
/** Module icons for the queues table (module name → emoji) */
|
|
6
6
|
moduleIcons?: Record<string, string>;
|
|
7
|
+
/** This tab is the visible one — visited tabs stay mounted (default: true) */
|
|
8
|
+
active?: boolean;
|
|
9
|
+
/** Timeline poll interval in ms while SSE is down (default: 2000) */
|
|
10
|
+
pollInterval?: number;
|
|
7
11
|
}
|
|
8
|
-
export default function TempoRealTab({ enableSSE, moduleIcons, }: TempoRealTabProps): React.JSX.Element;
|
|
12
|
+
export default function TempoRealTab({ enableSSE, moduleIcons, active, pollInterval, }: TempoRealTabProps): React.JSX.Element;
|
|
9
13
|
export {};
|
|
@@ -391,7 +391,9 @@ var JobDetailPanel = React.memo(function JobDetailPanel2({
|
|
|
391
391
|
});
|
|
392
392
|
function TempoRealTab({
|
|
393
393
|
enableSSE = true,
|
|
394
|
-
moduleIcons
|
|
394
|
+
moduleIcons,
|
|
395
|
+
active = true,
|
|
396
|
+
pollInterval
|
|
395
397
|
}) {
|
|
396
398
|
"use no memo";
|
|
397
399
|
const t = useTelamonjsT();
|
|
@@ -408,7 +410,11 @@ function TempoRealTab({
|
|
|
408
410
|
isError,
|
|
409
411
|
isFetching,
|
|
410
412
|
refetch: refetchTimeline
|
|
411
|
-
} = useQueueEventsTimeline(
|
|
413
|
+
} = useQueueEventsTimeline({
|
|
414
|
+
sseConnected: sseStatus === "connected",
|
|
415
|
+
active,
|
|
416
|
+
pollInterval
|
|
417
|
+
});
|
|
412
418
|
const handleQueueAction = useCallback(
|
|
413
419
|
async (action) => {
|
|
414
420
|
try {
|
|
@@ -448,13 +454,13 @@ function TempoRealTab({
|
|
|
448
454
|
const search = deferredSearch.toLowerCase();
|
|
449
455
|
return job.name.toLowerCase().includes(search) || job.queueName.toLowerCase().includes(search);
|
|
450
456
|
}) : allJobs;
|
|
451
|
-
let
|
|
457
|
+
let active2 = 0, completed = 0, failed = 0;
|
|
452
458
|
for (const job of searchFiltered) {
|
|
453
|
-
if (job.status === "active")
|
|
459
|
+
if (job.status === "active") active2++;
|
|
454
460
|
else if (job.status === "completed") completed++;
|
|
455
461
|
else if (job.status === "failed") failed++;
|
|
456
462
|
}
|
|
457
|
-
return { total: searchFiltered.length, active, completed, failed };
|
|
463
|
+
return { total: searchFiltered.length, active: active2, completed, failed };
|
|
458
464
|
}, [allJobs, deferredSearch]);
|
|
459
465
|
const selectedJob = useMemo(() => {
|
|
460
466
|
if (!selectedJobId) return null;
|
|
@@ -8,6 +8,24 @@ import type { TimelineJob } from '../types';
|
|
|
8
8
|
export interface TimelineData {
|
|
9
9
|
jobs: TimelineJob[];
|
|
10
10
|
}
|
|
11
|
+
export interface QueueEventsTimelineOptions {
|
|
12
|
+
/** SSE stream is live (it already pushes events into this query's cache) */
|
|
13
|
+
sseConnected?: boolean;
|
|
14
|
+
/** The view showing the timeline is the active one (default: true) */
|
|
15
|
+
active?: boolean;
|
|
16
|
+
/** Poll interval in ms while SSE is down (default: 2000) */
|
|
17
|
+
pollInterval?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Poll interval for the timeline: none while hidden or on another tab, a
|
|
21
|
+
* 30s safety net while SSE is live, otherwise `pollInterval` (2s default).
|
|
22
|
+
*/
|
|
23
|
+
export declare function timelinePollInterval({ isVisible, active, sseConnected, pollInterval, }: {
|
|
24
|
+
isVisible: boolean;
|
|
25
|
+
active: boolean;
|
|
26
|
+
sseConnected: boolean;
|
|
27
|
+
pollInterval?: number;
|
|
28
|
+
}): number | false;
|
|
11
29
|
/**
|
|
12
30
|
* Hook for real-time job timeline events.
|
|
13
31
|
*
|
|
@@ -20,4 +38,4 @@ export interface TimelineData {
|
|
|
20
38
|
* const { data: jobs } = useQueueEventsTimeline()
|
|
21
39
|
* ```
|
|
22
40
|
*/
|
|
23
|
-
export declare function useQueueEventsTimeline(): import("@tanstack/react-query").UseQueryResult<TimelineData, Error>;
|
|
41
|
+
export declare function useQueueEventsTimeline({ sseConnected, active, pollInterval, }?: QueueEventsTimelineOptions): import("@tanstack/react-query").UseQueryResult<TimelineData, Error>;
|
|
@@ -3,7 +3,22 @@ import { useQuery } from "@tanstack/react-query";
|
|
|
3
3
|
import { useQueueApi } from "../api/provider.js";
|
|
4
4
|
import { usePageVisibility } from "../../hooks/usePageVisibility.js";
|
|
5
5
|
import { LIB_QUERY_META } from "../../utils/query-meta.js";
|
|
6
|
-
|
|
6
|
+
var SSE_SAFETY_NET_INTERVAL = 3e4;
|
|
7
|
+
var DEFAULT_POLL_INTERVAL = 2e3;
|
|
8
|
+
function timelinePollInterval({
|
|
9
|
+
isVisible,
|
|
10
|
+
active,
|
|
11
|
+
sseConnected,
|
|
12
|
+
pollInterval = DEFAULT_POLL_INTERVAL
|
|
13
|
+
}) {
|
|
14
|
+
if (!isVisible || !active) return false;
|
|
15
|
+
return sseConnected ? SSE_SAFETY_NET_INTERVAL : pollInterval;
|
|
16
|
+
}
|
|
17
|
+
function useQueueEventsTimeline({
|
|
18
|
+
sseConnected = false,
|
|
19
|
+
active = true,
|
|
20
|
+
pollInterval
|
|
21
|
+
} = {}) {
|
|
7
22
|
const api = useQueueApi();
|
|
8
23
|
const isVisible = usePageVisibility();
|
|
9
24
|
return useQuery({
|
|
@@ -94,10 +109,15 @@ function useQueueEventsTimeline() {
|
|
|
94
109
|
};
|
|
95
110
|
},
|
|
96
111
|
staleTime: 1e3,
|
|
97
|
-
|
|
98
|
-
|
|
112
|
+
refetchInterval: timelinePollInterval({
|
|
113
|
+
isVisible,
|
|
114
|
+
active,
|
|
115
|
+
sseConnected,
|
|
116
|
+
pollInterval
|
|
117
|
+
})
|
|
99
118
|
});
|
|
100
119
|
}
|
|
101
120
|
export {
|
|
121
|
+
timelinePollInterval,
|
|
102
122
|
useQueueEventsTimeline
|
|
103
123
|
};
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
buildSearchConditions,
|
|
11
11
|
buildWhereClause,
|
|
12
12
|
getFilterOptionsForField,
|
|
13
|
+
resolveSort,
|
|
13
14
|
sanitizePaginationParams
|
|
14
15
|
} from "./utils.js";
|
|
15
16
|
import { logger } from "../../utils/logger.js";
|
|
@@ -25,6 +26,7 @@ function createPaginationContext(context) {
|
|
|
25
26
|
select,
|
|
26
27
|
defaultOrderBy = "id",
|
|
27
28
|
defaultOrderDirection = "asc",
|
|
29
|
+
sortableFields,
|
|
28
30
|
visibility,
|
|
29
31
|
counts,
|
|
30
32
|
baseWhere,
|
|
@@ -79,7 +81,12 @@ function createPaginationContext(context) {
|
|
|
79
81
|
};
|
|
80
82
|
where = beforeQuery(queryParams, where);
|
|
81
83
|
}
|
|
82
|
-
const
|
|
84
|
+
const sort = resolveSort(sortBy, sortOrder, {
|
|
85
|
+
defaultOrderBy,
|
|
86
|
+
defaultOrderDirection,
|
|
87
|
+
sortableFields
|
|
88
|
+
});
|
|
89
|
+
const orderBy = buildOrderByClause(sort.sortBy, sort.sortOrder);
|
|
83
90
|
const includeClause = buildIncludeClause(include, counts);
|
|
84
91
|
const queryOptions = {
|
|
85
92
|
where,
|
|
@@ -55,6 +55,12 @@ export interface PaginatedServiceConfig<TModel extends string = string> {
|
|
|
55
55
|
select?: Record<string, boolean | Record<string, unknown>>;
|
|
56
56
|
defaultOrderBy?: string | string[];
|
|
57
57
|
defaultOrderDirection?: 'asc' | 'desc';
|
|
58
|
+
/**
|
|
59
|
+
* Fields the client may sort by (as sent in `sortBy`, e.g. `'customer.name'`).
|
|
60
|
+
* When set, any other `sortBy` is ignored and the default sort applies.
|
|
61
|
+
* When absent, any field is accepted.
|
|
62
|
+
*/
|
|
63
|
+
sortableFields?: string[];
|
|
58
64
|
visibility?: (user: AuthUser) => PrismaWhereClause;
|
|
59
65
|
counts?: string[];
|
|
60
66
|
baseWhere?: PrismaWhereClause;
|
|
@@ -20,6 +20,19 @@ export declare function buildFilterConditions(filters: Record<string, FilterValu
|
|
|
20
20
|
* Build complete where clause combining all conditions
|
|
21
21
|
*/
|
|
22
22
|
export declare function buildWhereClause(searchConditions: SearchCondition | undefined, filterConditions: PrismaWhereClause[], baseWhere?: PrismaWhereClause, visibilityWhere?: PrismaWhereClause): PrismaWhereClause;
|
|
23
|
+
/**
|
|
24
|
+
* Sanitize a client-supplied sort: an invalid direction becomes the default
|
|
25
|
+
* one, and with `sortableFields` set, fields outside it are dropped (an empty
|
|
26
|
+
* result falls back to the default sort).
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveSort(sortBy: string | string[] | SortField[], sortOrder: unknown, defaults: {
|
|
29
|
+
defaultOrderBy: string | string[];
|
|
30
|
+
defaultOrderDirection: 'asc' | 'desc';
|
|
31
|
+
sortableFields?: string[];
|
|
32
|
+
}): {
|
|
33
|
+
sortBy: string | string[] | SortField[];
|
|
34
|
+
sortOrder: 'asc' | 'desc';
|
|
35
|
+
};
|
|
23
36
|
/**
|
|
24
37
|
* Build orderBy clause from sortBy and sortOrder
|
|
25
38
|
*/
|
|
@@ -94,23 +94,33 @@ function buildWhereClause(searchConditions, filterConditions, baseWhere, visibil
|
|
|
94
94
|
conditions.push(searchConditions);
|
|
95
95
|
}
|
|
96
96
|
conditions.push(...filterConditions);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
97
|
+
const parts = [
|
|
98
|
+
conditions.length > 0 ? { AND: conditions } : void 0,
|
|
99
|
+
baseWhere,
|
|
100
|
+
visibilityWhere
|
|
101
|
+
].filter(
|
|
102
|
+
(part) => !!part && Object.keys(part).length > 0
|
|
103
|
+
);
|
|
104
|
+
if (parts.length === 0) return {};
|
|
105
|
+
return parts.length === 1 ? parts[0] : { AND: parts };
|
|
106
|
+
}
|
|
107
|
+
var isSortOrder = (value) => value === "asc" || value === "desc";
|
|
108
|
+
function resolveSort(sortBy, sortOrder, defaults) {
|
|
109
|
+
const { defaultOrderBy, defaultOrderDirection, sortableFields } = defaults;
|
|
110
|
+
const fallback = { sortBy: defaultOrderBy, sortOrder: defaultOrderDirection };
|
|
111
|
+
const allowed = (field) => !sortableFields || sortableFields.includes(field);
|
|
112
|
+
const order = isSortOrder(sortOrder) ? sortOrder : defaultOrderDirection;
|
|
113
|
+
if (sortBy === defaultOrderBy) return { sortBy, sortOrder: order };
|
|
114
|
+
if (typeof sortBy === "string") {
|
|
115
|
+
return allowed(sortBy) ? { sortBy, sortOrder: order } : fallback;
|
|
112
116
|
}
|
|
113
|
-
|
|
117
|
+
const fields = sortBy.filter(
|
|
118
|
+
(s) => !!s && typeof s === "object" && typeof s.field === "string" && allowed(s.field)
|
|
119
|
+
).map((s) => ({
|
|
120
|
+
field: s.field,
|
|
121
|
+
order: isSortOrder(s.order) ? s.order : defaultOrderDirection
|
|
122
|
+
}));
|
|
123
|
+
return fields.length > 0 ? { sortBy: fields, sortOrder: order } : fallback;
|
|
114
124
|
}
|
|
115
125
|
function buildOrderByClause(sortBy, sortOrder) {
|
|
116
126
|
if (!sortBy) {
|
|
@@ -193,5 +203,6 @@ export {
|
|
|
193
203
|
buildSearchConditions,
|
|
194
204
|
buildWhereClause,
|
|
195
205
|
getFilterOptionsForField,
|
|
206
|
+
resolveSort,
|
|
196
207
|
sanitizePaginationParams
|
|
197
208
|
};
|
|
@@ -27,7 +27,12 @@ var useSidebarStore = create()(
|
|
|
27
27
|
}),
|
|
28
28
|
{
|
|
29
29
|
name: SIDEBAR_STORAGE_KEY,
|
|
30
|
-
partialize: (state) => ({ sidebarState: state.sidebarState })
|
|
30
|
+
partialize: (state) => ({ sidebarState: state.sidebarState }),
|
|
31
|
+
// localStorage is synchronous, so the store would read the saved
|
|
32
|
+
// preference while being created and the first client render would
|
|
33
|
+
// differ from the server's (hydration mismatch, shifted Radix ids).
|
|
34
|
+
// ModernSidebar calls persist.rehydrate() after mount instead.
|
|
35
|
+
skipHydration: true
|
|
31
36
|
}
|
|
32
37
|
)
|
|
33
38
|
),
|
package/dist/ui/command.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare const Command: React.ForwardRefExoticComponent<Omit<{
|
|
|
6
6
|
ref?: React.Ref<HTMLDivElement>;
|
|
7
7
|
} & {
|
|
8
8
|
asChild?: boolean;
|
|
9
|
-
}, "key" |
|
|
9
|
+
}, "key" | keyof React.HTMLAttributes<HTMLDivElement> | "asChild"> & {
|
|
10
10
|
label?: string;
|
|
11
11
|
shouldFilter?: boolean;
|
|
12
12
|
filter?: (value: string, search: string, keywords?: string[]) => number;
|
|
@@ -32,7 +32,7 @@ declare const CommandList: React.ForwardRefExoticComponent<Omit<{
|
|
|
32
32
|
ref?: React.Ref<HTMLDivElement>;
|
|
33
33
|
} & {
|
|
34
34
|
asChild?: boolean;
|
|
35
|
-
}, "key" |
|
|
35
|
+
}, "key" | keyof React.HTMLAttributes<HTMLDivElement> | "asChild"> & {
|
|
36
36
|
label?: string;
|
|
37
37
|
} & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
38
38
|
declare const CommandEmpty: React.ForwardRefExoticComponent<Omit<{
|
|
@@ -41,14 +41,14 @@ declare const CommandEmpty: React.ForwardRefExoticComponent<Omit<{
|
|
|
41
41
|
ref?: React.Ref<HTMLDivElement>;
|
|
42
42
|
} & {
|
|
43
43
|
asChild?: boolean;
|
|
44
|
-
}, "key" |
|
|
44
|
+
}, "key" | keyof React.HTMLAttributes<HTMLDivElement> | "asChild"> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
45
45
|
declare const CommandGroup: React.ForwardRefExoticComponent<Omit<{
|
|
46
46
|
children?: React.ReactNode;
|
|
47
47
|
} & Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
48
48
|
ref?: React.Ref<HTMLDivElement>;
|
|
49
49
|
} & {
|
|
50
50
|
asChild?: boolean;
|
|
51
|
-
}, "key" |
|
|
51
|
+
}, "key" | keyof React.HTMLAttributes<HTMLDivElement> | "asChild">, "value" | "heading"> & {
|
|
52
52
|
heading?: React.ReactNode;
|
|
53
53
|
value?: string;
|
|
54
54
|
forceMount?: boolean;
|
|
@@ -57,7 +57,7 @@ declare const CommandSeparator: React.ForwardRefExoticComponent<Omit<Pick<Pick<R
|
|
|
57
57
|
ref?: React.Ref<HTMLDivElement>;
|
|
58
58
|
} & {
|
|
59
59
|
asChild?: boolean;
|
|
60
|
-
}, "key" |
|
|
60
|
+
}, "key" | keyof React.HTMLAttributes<HTMLDivElement> | "asChild"> & {
|
|
61
61
|
alwaysRender?: boolean;
|
|
62
62
|
} & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
63
63
|
declare const CommandItem: React.ForwardRefExoticComponent<Omit<{
|
|
@@ -66,7 +66,7 @@ declare const CommandItem: React.ForwardRefExoticComponent<Omit<{
|
|
|
66
66
|
ref?: React.Ref<HTMLDivElement>;
|
|
67
67
|
} & {
|
|
68
68
|
asChild?: boolean;
|
|
69
|
-
}, "key" |
|
|
69
|
+
}, "key" | keyof React.HTMLAttributes<HTMLDivElement> | "asChild">, "value" | "disabled" | "onSelect"> & {
|
|
70
70
|
disabled?: boolean;
|
|
71
71
|
onSelect?: (value: string) => void;
|
|
72
72
|
value?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telamonjs/ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Admin framework for Next.js + React: declarative CRUD (CrudConfig + TanStack Query), 36-type field system, rich dialogs, app shell, dashboards and charts",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -126,6 +126,7 @@
|
|
|
126
126
|
"next-themes": "^0.4.6",
|
|
127
127
|
"react-aria": "^3.44.0",
|
|
128
128
|
"react-day-picker": "^9.11.1",
|
|
129
|
+
"react-grid-layout": "^2.2.4",
|
|
129
130
|
"react-is": "^19.2.0",
|
|
130
131
|
"react-resizable-panels": "^3.0.6",
|
|
131
132
|
"react-stately": "^3.42.0",
|
|
@@ -133,7 +134,7 @@
|
|
|
133
134
|
"tailwind-merge": "^3.3.1",
|
|
134
135
|
"tailwindcss-animate": "^1.0.7",
|
|
135
136
|
"zustand": "^5.0.8",
|
|
136
|
-
"@telamonjs/logger": "^1.0.
|
|
137
|
+
"@telamonjs/logger": "^1.0.2"
|
|
137
138
|
},
|
|
138
139
|
"peerDependencies": {
|
|
139
140
|
"@prisma/client": "^5.0.0 || ^6.0.0",
|
|
@@ -145,7 +146,6 @@
|
|
|
145
146
|
"papaparse": "^5.5.0",
|
|
146
147
|
"react": "^18.0.0 || ^19.0.0",
|
|
147
148
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
148
|
-
"react-grid-layout": "^1.5.0 || ^2.0.0",
|
|
149
149
|
"react-hook-form": "^7.0.0",
|
|
150
150
|
"sonner": "^1.7.1 || ^2.0.7",
|
|
151
151
|
"xlsx": "^0.18.0",
|
|
@@ -156,9 +156,6 @@
|
|
|
156
156
|
"peerDependenciesMeta": {
|
|
157
157
|
"@prisma/client": {
|
|
158
158
|
"optional": true
|
|
159
|
-
},
|
|
160
|
-
"react-grid-layout": {
|
|
161
|
-
"optional": true
|
|
162
159
|
}
|
|
163
160
|
},
|
|
164
161
|
"devDependencies": {
|