@dudousxd/nestjs-catalog-react 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DashboardBoard.js +19 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/ui/button.d.ts +24 -0
- package/dist/ui/button.js +29 -0
- package/dist/ui/tabs.d.ts +10 -3
- package/dist/ui/tabs.js +4 -4
- package/package.json +1 -1
package/dist/DashboardBoard.js
CHANGED
|
@@ -125,9 +125,9 @@ export function DashboardBoard() {
|
|
|
125
125
|
create.mutate();
|
|
126
126
|
}, children: [_jsx("input", { value: name, onChange: (e) => setName(e.target.value), placeholder: "Name", "aria-label": "Dashboard name", className: cn('min-w-0 flex-1 rounded-md border bg-white px-2 py-1 text-xs outline-none dark:bg-zinc-900', RULE) }), _jsx("button", { type: "submit", disabled: name.trim().length === 0, className: "rounded-md bg-zinc-950 px-2 text-xs text-zinc-50 disabled:opacity-40 dark:bg-zinc-100 dark:text-zinc-950", children: "Add" })] })), _jsxs("nav", { className: "min-h-0 flex-1 overflow-y-auto p-2", children: [dashboards.length === 0 && (_jsx("p", { className: cn('px-2 py-4 text-center text-[11px]', MUTED), children: "No dashboards yet." })), dashboards.map((dashboard) => (_jsxs("button", { type: "button", onClick: () => setSelectedId(dashboard.id), className: cn('flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-sm', selected?.id === dashboard.id
|
|
127
127
|
? 'bg-sky-100 dark:bg-sky-950'
|
|
128
|
-
: 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx(LayoutGrid, { size: 12, className: MUTED }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: dashboard.name }), _jsx("span", { className: cn('font-mono text-[10px]', MUTED), children: dashboard.cards.length })] }, dashboard.id)))] }), selected && saved.length > 0 && (_jsxs("div", { className: cn('border-t p-2', RULE), children: [_jsx("div", { className: cn('px-1 pb-1 font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Add a card" }), saved.map((query) => (_jsxs("button", { type: "button", onClick: () => addCard(query.id), className: cn('w-full truncate rounded-md px-2 py-1 text-left text-[11px]', 'transition-all hover:translate-x-0.5 hover:bg-sky-50', 'dark:hover:bg-sky-950/40'), children: ["+ ", query.name] }, query.id)))] }))] }), _jsx("main", { className: "min-w-0 flex-1 overflow-y-auto", children: !selected ? (_jsx("div", { className: "flex h-full items-center justify-center px-6", children: _jsxs("div", { className: "max-w-sm text-center", children: [_jsx("h2", { className: "text-lg font-medium", children: "No dashboard open" }), _jsx("p", { className: cn('mt-1 text-sm', MUTED), children: "Save a query first, then make a dashboard and add it as a card." })] }) })) : (_jsxs("div", { className: "mx-auto max-w-6xl px-8 py-6", children: [_jsxs("div", { className: "flex items-start justify-between gap-4", children: [_jsxs("div", { children: [_jsx("h1", { className: "text-2xl font-semibold tracking-tight", children: selected.name }), _jsxs("p", { className: cn('mt-0.5 font-mono text-[11px]', MUTED), children: [selected.cards.length, " cards \u00B7 by ", selected.createdBy] })] }), _jsxs("button", { type: "button", onClick: () => remove.mutate(selected.id), className: cn('flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs', RULE, MUTED, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx(Trash2, { size: 12 }), "Delete"] })] }), selected.cards.length === 0 ? (_jsx("p", { className: cn('mt-8 rounded-lg border border-dashed px-4 py-12 text-center text-sm', RULE, MUTED), children: "Empty. Add a saved query from the left." })) : (_jsx(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragEnd: onDragEnd, children: _jsx(SortableContext, { items: [...selected.cards]
|
|
128
|
+
: 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx(LayoutGrid, { size: 12, className: MUTED }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: dashboard.name }), _jsx("span", { className: cn('font-mono text-[10px]', MUTED), children: dashboard.cards.length })] }, dashboard.id)))] }), selected && saved.length > 0 && (_jsxs("div", { className: cn('border-t p-2', RULE), children: [_jsx("div", { className: cn('px-1 pb-1 font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Add a card" }), saved.map((query) => (_jsxs("button", { type: "button", onClick: () => addCard(query.id), className: cn('w-full truncate rounded-md px-2 py-1 text-left text-[11px]', 'transition-all hover:translate-x-0.5 hover:bg-sky-50', 'dark:hover:bg-sky-950/40'), children: ["+ ", query.name] }, query.id)))] }))] }), _jsx("main", { className: "@container min-w-0 flex-1 overflow-y-auto", children: !selected ? (_jsx("div", { className: "flex h-full items-center justify-center px-6", children: _jsxs("div", { className: "max-w-sm text-center", children: [_jsx("h2", { className: "text-lg font-medium", children: "No dashboard open" }), _jsx("p", { className: cn('mt-1 text-sm', MUTED), children: "Save a query first, then make a dashboard and add it as a card." })] }) })) : (_jsxs("div", { className: "mx-auto max-w-6xl px-8 py-6", children: [_jsxs("div", { className: "flex items-start justify-between gap-4", children: [_jsxs("div", { children: [_jsx("h1", { className: "text-2xl font-semibold tracking-tight", children: selected.name }), _jsxs("p", { className: cn('mt-0.5 font-mono text-[11px]', MUTED), children: [selected.cards.length, " cards \u00B7 by ", selected.createdBy] })] }), _jsxs("button", { type: "button", onClick: () => remove.mutate(selected.id), className: cn('flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs', RULE, MUTED, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx(Trash2, { size: 12 }), "Delete"] })] }), selected.cards.length === 0 ? (_jsx("p", { className: cn('mt-8 rounded-lg border border-dashed px-4 py-12 text-center text-sm', RULE, MUTED), children: "Empty. Add a saved query from the left." })) : (_jsx(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragEnd: onDragEnd, children: _jsx(SortableContext, { items: [...selected.cards]
|
|
129
129
|
.sort((a, b) => a.position - b.position)
|
|
130
|
-
.map((c) => c.id), strategy: rectSortingStrategy, children: _jsx("div", { className: "mt-6 grid grid-cols-
|
|
130
|
+
.map((c) => c.id), strategy: rectSortingStrategy, children: _jsx("div", { className: "mt-6 grid grid-cols-1 gap-4 @2xl:grid-cols-2 @5xl:grid-cols-4", children: [...selected.cards]
|
|
131
131
|
.sort((a, b) => a.position - b.position)
|
|
132
132
|
.map((card) => (_jsx(SortableCard, { id: card.id, savedQueryId: card.savedQueryId, width: card.width, onRemove: () => removeCard(card.id), onWidth: (w) => setWidth(card.id, w) }, card.id))) }) }) }))] })) })] }) }));
|
|
133
133
|
}
|
|
@@ -142,13 +142,25 @@ function SortableCard({ id, savedQueryId, width, onRemove, onWidth, }) {
|
|
|
142
142
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
|
|
143
143
|
id,
|
|
144
144
|
});
|
|
145
|
-
return (_jsx("div", { ref: setNodeRef, style: { transform: CSS.Transform.toString(transform), transition }, className: cn(SPAN[width] ??
|
|
145
|
+
return (_jsx("div", { ref: setNodeRef, style: { transform: CSS.Transform.toString(transform), transition }, className: cn(SPAN[width] ?? SPAN[2],
|
|
146
|
+
// A grid item defaults to `min-width: auto`, so a chart wider than its
|
|
147
|
+
// column pushes the column out instead of being constrained by it —
|
|
148
|
+
// the same rule that made the nav overflow the page.
|
|
149
|
+
'min-w-0', 'motion-safe:animate-in motion-safe:fade-in motion-safe:zoom-in-95', isDragging && 'z-10 opacity-60 shadow-lg'), children: _jsx(Card, { savedQueryId: savedQueryId, width: width, onRemove: onRemove, onWidth: onWidth, dragHandle: _jsx("button", { type: "button", ...attributes, ...listeners, "aria-label": "Reorder card", className: cn('cursor-grab rounded-sm p-1 active:cursor-grabbing', 'hover:bg-zinc-100 dark:hover:bg-zinc-800', MUTED), children: _jsx(GripVertical, { size: 11 }) }) }) }));
|
|
146
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* The width an operator chose, applied only where there are columns to spend.
|
|
153
|
+
*
|
|
154
|
+
* Below `@5xl` the grid has fewer than four columns, and a `col-span-4` there
|
|
155
|
+
* spans past the end — which is what put a chart's axis labels outside its own
|
|
156
|
+
* card. Every card is full width on a narrow board, two-up in the middle, and
|
|
157
|
+
* only honours the chosen span once four columns exist to divide.
|
|
158
|
+
*/
|
|
147
159
|
const SPAN = {
|
|
148
|
-
1: 'col-span-1',
|
|
149
|
-
2: 'col-span-2',
|
|
150
|
-
3: 'col-span-3',
|
|
151
|
-
4: 'col-span-4',
|
|
160
|
+
1: '@5xl:col-span-1',
|
|
161
|
+
2: '@2xl:col-span-2 @5xl:col-span-2',
|
|
162
|
+
3: '@2xl:col-span-2 @5xl:col-span-3',
|
|
163
|
+
4: '@2xl:col-span-2 @5xl:col-span-4',
|
|
152
164
|
};
|
|
153
165
|
function Card({ savedQueryId, width, onRemove, onWidth, dragHandle, }) {
|
|
154
166
|
const client = useCatalogClient();
|
package/dist/index.d.ts
CHANGED
|
@@ -26,5 +26,6 @@ export { FieldGroup, TextAreaField, TextField } from './ui/field';
|
|
|
26
26
|
export { Select, SelectField, type SelectOption } from './ui/select';
|
|
27
27
|
export { Switch } from './ui/switch';
|
|
28
28
|
export { Sheet } from './ui/sheet';
|
|
29
|
+
export { Button, type ButtonProps, type ButtonSize, type ButtonVariant } from './ui/button';
|
|
29
30
|
export { Tabs, TabsList, TabsPanel, TabsTab } from './ui/tabs';
|
|
30
31
|
export { Tooltip, TooltipProvider } from './ui/tooltip';
|
package/dist/index.js
CHANGED
|
@@ -61,5 +61,6 @@ export { FieldGroup, TextAreaField, TextField } from './ui/field';
|
|
|
61
61
|
export { Select, SelectField } from './ui/select';
|
|
62
62
|
export { Switch } from './ui/switch';
|
|
63
63
|
export { Sheet } from './ui/sheet';
|
|
64
|
+
export { Button } from './ui/button';
|
|
64
65
|
export { Tabs, TabsList, TabsPanel, TabsTab } from './ui/tabs';
|
|
65
66
|
export { Tooltip, TooltipProvider } from './ui/tooltip';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Button, vendored in the shadcn style.
|
|
4
|
+
*
|
|
5
|
+
* Hand-rolled variants rather than `class-variance-authority`, matching how the
|
|
6
|
+
* rest of `ui/` is vendored here: this package already declines the dependency
|
|
7
|
+
* for `select`, `tabs` and `dialog`, and a lookup table is what cva would
|
|
8
|
+
* compile to for a component with no compound variants.
|
|
9
|
+
*
|
|
10
|
+
* What this buys over a `<button>` with classes is the part nobody remembers to
|
|
11
|
+
* write by hand every time: a real focus ring, `disabled` that also stops
|
|
12
|
+
* pointer events, and one place where "what a secondary button looks like"
|
|
13
|
+
* lives. Sixty of those decisions made independently is how a console ends up
|
|
14
|
+
* with four greys.
|
|
15
|
+
*/
|
|
16
|
+
export type ButtonVariant = 'default' | 'secondary' | 'outline' | 'ghost' | 'destructive';
|
|
17
|
+
export type ButtonSize = 'sm' | 'md' | 'icon';
|
|
18
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
19
|
+
variant?: ButtonVariant;
|
|
20
|
+
size?: ButtonSize;
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
ref?: Ref<HTMLButtonElement>;
|
|
23
|
+
}
|
|
24
|
+
export declare function Button({ variant, size, className, type, ...props }: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../cn';
|
|
3
|
+
const BASE = cn('inline-flex shrink-0 items-center justify-center gap-1.5 whitespace-nowrap rounded-md', 'font-medium transition-colors outline-none', 'focus-visible:ring-2 focus-visible:ring-sky-500/40',
|
|
4
|
+
// Both, and deliberately: `disabled` alone still fires hover styles and still
|
|
5
|
+
// shows a pointer, so a dead button looks alive right up until it is clicked.
|
|
6
|
+
'disabled:pointer-events-none disabled:opacity-50');
|
|
7
|
+
const VARIANTS = {
|
|
8
|
+
default: cn('bg-sky-600 text-white hover:bg-sky-500', 'dark:bg-sky-500 dark:text-zinc-950 dark:hover:bg-sky-400'),
|
|
9
|
+
secondary: cn('bg-zinc-100 text-zinc-900 hover:bg-zinc-200', 'dark:bg-zinc-800 dark:text-zinc-100 dark:hover:bg-zinc-700'),
|
|
10
|
+
outline: cn('border border-zinc-200 bg-white text-zinc-900 hover:bg-zinc-50', 'dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-100 dark:hover:bg-zinc-800'),
|
|
11
|
+
ghost: cn('text-zinc-500 hover:bg-zinc-100 hover:text-zinc-950', 'dark:hover:bg-zinc-800 dark:hover:text-zinc-50'),
|
|
12
|
+
// Not red text on a ghost: a destructive action should be identifiable
|
|
13
|
+
// before the pointer reaches it, not on hover.
|
|
14
|
+
destructive: cn('bg-rose-600 text-white hover:bg-rose-500', 'dark:bg-rose-600 dark:hover:bg-rose-500'),
|
|
15
|
+
};
|
|
16
|
+
const SIZES = {
|
|
17
|
+
sm: 'h-7 px-2 text-xs',
|
|
18
|
+
md: 'h-9 px-3 text-sm',
|
|
19
|
+
// Square, so a lone icon is not a lopsided rectangle and a row of them lines
|
|
20
|
+
// up with the text inputs beside it.
|
|
21
|
+
icon: 'h-7 w-7 p-0',
|
|
22
|
+
};
|
|
23
|
+
export function Button({ variant = 'default', size = 'md', className,
|
|
24
|
+
// Defaulted, because the HTML default is `submit`: a button inside any form
|
|
25
|
+
// that forgets this submits it, and the symptom is a page that reloads
|
|
26
|
+
// instead of doing the thing.
|
|
27
|
+
type = 'button', ...props }) {
|
|
28
|
+
return (_jsx("button", { type: type, className: cn(BASE, VARIANTS[variant], SIZES[size], className), ...props }));
|
|
29
|
+
}
|
package/dist/ui/tabs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
1
|
+
import type { ReactNode, Ref } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* Tabs, vendored in the shadcn style on Base UI.
|
|
4
4
|
*
|
|
@@ -15,13 +15,20 @@ export declare function Tabs({ value, onValueChange, children, className, }: {
|
|
|
15
15
|
children: ReactNode;
|
|
16
16
|
className?: string;
|
|
17
17
|
}): import("react/jsx-runtime").JSX.Element;
|
|
18
|
-
export declare function TabsList({ children, className, }: {
|
|
18
|
+
export declare function TabsList({ children, className, ref, }: {
|
|
19
19
|
children: ReactNode;
|
|
20
20
|
className?: string;
|
|
21
|
+
/**
|
|
22
|
+
* For a caller that has to MEASURE the list — a strip narrow enough to
|
|
23
|
+
* scroll needs to know how far it has scrolled to say so.
|
|
24
|
+
*/
|
|
25
|
+
ref?: Ref<HTMLDivElement>;
|
|
21
26
|
}): import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
export declare function TabsTab({ value, children, }: {
|
|
27
|
+
export declare function TabsTab({ value, children, className, }: {
|
|
23
28
|
value: string;
|
|
24
29
|
children: ReactNode;
|
|
30
|
+
/** For a caller whose strip has its own metrics — the console nav is taller. */
|
|
31
|
+
className?: string;
|
|
25
32
|
}): import("react/jsx-runtime").JSX.Element;
|
|
26
33
|
export declare function TabsPanel({ value, children, className, }: {
|
|
27
34
|
value: string;
|
package/dist/ui/tabs.js
CHANGED
|
@@ -21,11 +21,11 @@ export function Tabs({ value, onValueChange, children, className, }) {
|
|
|
21
21
|
onValueChange(next);
|
|
22
22
|
}, className: className, children: children }));
|
|
23
23
|
}
|
|
24
|
-
export function TabsList({ children, className, }) {
|
|
25
|
-
return (_jsx(BaseTabs.List, { className: cn('flex gap-1 border-b border-zinc-200 dark:border-zinc-800', className), children: children }));
|
|
24
|
+
export function TabsList({ children, className, ref, }) {
|
|
25
|
+
return (_jsx(BaseTabs.List, { ref: ref, className: cn('flex gap-1 border-b border-zinc-200 dark:border-zinc-800', className), children: children }));
|
|
26
26
|
}
|
|
27
|
-
export function TabsTab({ value, children, }) {
|
|
28
|
-
return (_jsx(BaseTabs.Tab, { value: value, className: cn('flex items-center gap-1.5 border-b-2 px-3 py-2 text-sm transition-colors outline-none', 'border-transparent text-zinc-500', 'hover:text-zinc-950 dark:hover:text-zinc-50', 'focus-visible:ring-2 focus-visible:ring-sky-500/30', 'data-[selected]:border-sky-600 data-[selected]:text-zinc-950', 'dark:data-[selected]:text-zinc-50'), children: children }));
|
|
27
|
+
export function TabsTab({ value, children, className, }) {
|
|
28
|
+
return (_jsx(BaseTabs.Tab, { value: value, className: cn('flex items-center gap-1.5 border-b-2 px-3 py-2 text-sm transition-colors outline-none', 'border-transparent text-zinc-500', 'hover:text-zinc-950 dark:hover:text-zinc-50', 'focus-visible:ring-2 focus-visible:ring-sky-500/30', 'data-[selected]:border-sky-600 data-[selected]:text-zinc-950', 'dark:data-[selected]:text-zinc-50', className), children: children }));
|
|
29
29
|
}
|
|
30
30
|
export function TabsPanel({ value, children, className, }) {
|
|
31
31
|
// Not `keepMounted`: a panel holding a half-typed connector form should keep
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudousxd/nestjs-catalog-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Ready-made React screens for @dudousxd/nestjs-catalog — a model manager and a generic object explorer you can drop into your own app shell.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Davide Carvalho",
|