@dudousxd/nestjs-catalog-react 0.3.0 → 0.6.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/CatalogManager.js +86 -9
- package/dist/DashboardBoard.js +38 -11
- package/dist/ObjectExplorer.js +15 -8
- package/dist/QueryConsole.js +22 -37
- package/dist/TransformEditor.js +2 -11
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/ui/button.d.ts +24 -0
- package/dist/ui/button.js +29 -0
- package/dist/ui/code-editor.d.ts +17 -0
- package/dist/ui/code-editor.js +81 -0
- package/dist/ui/data-table.d.ts +92 -0
- package/dist/ui/data-table.js +101 -0
- package/dist/ui/rich-text-field.d.ts +21 -0
- package/dist/ui/rich-text-field.js +133 -0
- package/dist/ui/tabs.d.ts +10 -3
- package/dist/ui/tabs.js +4 -4
- package/package.json +15 -3
package/dist/CatalogManager.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
3
3
|
import { ArrowUpRight, Eye, EyeOff, RotateCcw, Search } from 'lucide-react';
|
|
4
4
|
import { useMemo, useState } from 'react';
|
|
@@ -6,6 +6,8 @@ import { CoverageLedger } from './CoverageLedger';
|
|
|
6
6
|
import { EditableField } from './EditableField';
|
|
7
7
|
import { cn } from './cn';
|
|
8
8
|
import { catalogQueryKeys, useCatalogClient } from './context';
|
|
9
|
+
import { DataTable } from './ui/data-table';
|
|
10
|
+
import { RichTextField } from './ui/rich-text-field';
|
|
9
11
|
import { Tooltip, TooltipProvider } from './ui/tooltip';
|
|
10
12
|
/**
|
|
11
13
|
* Browse and label the model.
|
|
@@ -106,18 +108,93 @@ function Stat({ label, value }) {
|
|
|
106
108
|
}
|
|
107
109
|
function TypeDetail({ type, explorerHref, onPatchType, onPatchProperty, onNavigate, }) {
|
|
108
110
|
const visible = type.properties.filter((p) => !p.hidden).length;
|
|
109
|
-
return (_jsxs("div", { className: "mx-auto max-w-5xl px-8 py-8", children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-4", children: [_jsxs("div", { className: "min-w-0", children: [_jsxs("div", { className: "flex items-baseline gap-2", children: [_jsx("span", { className: "text-2xl leading-none", children: type.icon ?? '◈' }), _jsx(EditableField, { label: "display name", value: type.displayName, onSave: (displayName) => onPatchType({ displayName }), className: "text-2xl font-semibold tracking-tight", inputClassName: "text-2xl font-semibold tracking-tight" })] }), _jsxs("div", { className: cn('mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 pl-1 font-mono text-[11px]', MUTED), children: [_jsx("span", { children: type.name }), _jsx("span", { "aria-hidden": true, children: "\u00B7" }), _jsx("span", { children: type.tableName }), _jsx("span", { "aria-hidden": true, children: "\u00B7" }), _jsxs("span", { children: ["pk ", type.primaryKey.join(', ') || 'none'] }), _jsx("span", { "aria-hidden": true, children: "\u00B7" }), _jsxs("span", { children: [visible, " of ", type.properties.length, " shown"] })] })] }), explorerHref && (_jsxs("a", { href: explorerHref(type.name), className: cn('flex items-center gap-1.5 rounded-md bg-zinc-950 px-3 py-2 text-xs text-zinc-50', 'transition-colors hover:bg-zinc-800 dark:bg-zinc-100 dark:text-zinc-950 dark:hover:bg-zinc-300'), children: ["Open ", type.pluralDisplayName, _jsx(ArrowUpRight, { size: 13 })] }))] }), _jsx("div", { className: "mt-5 border-l-2 border-sky-200 pl-4 dark:border-sky-900", children: _jsx(
|
|
110
|
-
? `Hidden from tables and search. ${property.displayName} is still stored — showing it again needs no migration.`
|
|
111
|
-
: `Shown in tables and search. Hiding it only changes what is displayed; the column is untouched.`, children: _jsx("button", { type: "button", "aria-label": `${property.hidden ? 'Show' : 'Hide'} ${property.displayName}`, onClick: () => onPatchProperty(property.name, {
|
|
112
|
-
hidden: !property.hidden,
|
|
113
|
-
}), className: cn('rounded-sm p-1 hover:bg-zinc-100 dark:hover:bg-zinc-800', MUTED), children: property.hidden ? _jsx(EyeOff, { size: 14 }) : _jsx(Eye, { size: 14 }) }) }) })] }, property.name))) })] }) })] }), _jsxs("section", { className: "mt-10 pb-16", children: [_jsx(SectionHeading, { title: "Links", note: "Read from the foreign keys." }), type.relations.length === 0 ? (_jsxs("p", { className: cn('rounded-lg border border-dashed px-4 py-6 text-center text-sm', RULE, MUTED), children: ["Nothing links to or from ", type.displayName, " yet."] })) : (_jsx("div", { className: "flex flex-wrap gap-2", children: type.relations.map((relation) => (_jsxs("button", { type: "button", onClick: () => onNavigate(relation.targetType), className: cn('group flex items-center gap-2 rounded-md border px-3 py-2 text-left transition-colors', RULE, PANEL, 'hover:border-sky-500 hover:bg-sky-100 dark:hover:bg-sky-950'), children: [_jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-wider', MUTED), children: relation.kind }), _jsx("span", { className: "text-sm", children: relation.displayName }), _jsxs("span", { className: cn('font-mono text-[10px]', MUTED), children: ["\u2192 ", relation.targetType] })] }, relation.name))) }))] })] }));
|
|
111
|
+
return (_jsxs("div", { className: "mx-auto max-w-5xl px-8 py-8", children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-4", children: [_jsxs("div", { className: "min-w-0", children: [_jsxs("div", { className: "flex items-baseline gap-2", children: [_jsx("span", { className: "text-2xl leading-none", children: type.icon ?? '◈' }), _jsx(EditableField, { label: "display name", value: type.displayName, onSave: (displayName) => onPatchType({ displayName }), className: "text-2xl font-semibold tracking-tight", inputClassName: "text-2xl font-semibold tracking-tight" })] }), _jsxs("div", { className: cn('mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 pl-1 font-mono text-[11px]', MUTED), children: [_jsx("span", { children: type.name }), _jsx("span", { "aria-hidden": true, children: "\u00B7" }), _jsx("span", { children: type.tableName }), _jsx("span", { "aria-hidden": true, children: "\u00B7" }), _jsxs("span", { children: ["pk ", type.primaryKey.join(', ') || 'none'] }), _jsx("span", { "aria-hidden": true, children: "\u00B7" }), _jsxs("span", { children: [visible, " of ", type.properties.length, " shown"] })] })] }), explorerHref && (_jsxs("a", { href: explorerHref(type.name), className: cn('flex items-center gap-1.5 rounded-md bg-zinc-950 px-3 py-2 text-xs text-zinc-50', 'transition-colors hover:bg-zinc-800 dark:bg-zinc-100 dark:text-zinc-950 dark:hover:bg-zinc-300'), children: ["Open ", type.pluralDisplayName, _jsx(ArrowUpRight, { size: 13 })] }))] }), _jsx("div", { className: "mt-5 border-l-2 border-sky-200 pl-4 dark:border-sky-900", children: _jsx(RichTextField, { label: "description", value: type.description ?? '', placeholder: "No one has written down what this type means yet.", onSave: (description) => onPatchType({ description }), className: cn('text-sm leading-relaxed', SECONDARY) }) }), _jsxs("div", { className: "mt-4 flex flex-wrap items-center gap-2", children: [_jsx(FieldChip, { label: "Group", value: type.group, onSave: (group) => onPatchType({ group }) }), _jsx(FieldChip, { label: "Plural", value: type.pluralDisplayName, onSave: (pluralDisplayName) => onPatchType({ pluralDisplayName }) }), _jsx(FieldChip, { label: "Icon", value: type.icon ?? '', onSave: (icon) => onPatchType({ icon }) })] }), _jsxs("section", { className: "mt-10", children: [_jsx(SectionHeading, { title: "Properties", note: "The column and its SQL type are read from the ORM. The label, description and unit are yours." }), _jsx("div", { className: cn('overflow-hidden rounded-lg border', RULE, PANEL), children: _jsx(PropertyTable, { properties: type.properties, onPatchProperty: onPatchProperty }) })] }), _jsxs("section", { className: "mt-10 pb-16", children: [_jsx(SectionHeading, { title: "Links", note: "Read from the foreign keys." }), type.relations.length === 0 ? (_jsxs("p", { className: cn('rounded-lg border border-dashed px-4 py-6 text-center text-sm', RULE, MUTED), children: ["Nothing links to or from ", type.displayName, " yet."] })) : (_jsx("div", { className: "flex flex-wrap gap-2", children: type.relations.map((relation) => (_jsxs("button", { type: "button", onClick: () => onNavigate(relation.targetType), className: cn('group flex items-center gap-2 rounded-md border px-3 py-2 text-left transition-colors', RULE, PANEL, 'hover:border-sky-500 hover:bg-sky-100 dark:hover:bg-sky-950'), children: [_jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-wider', MUTED), children: relation.kind }), _jsx("span", { className: "text-sm", children: relation.displayName }), _jsxs("span", { className: cn('font-mono text-[10px]', MUTED), children: ["\u2192 ", relation.targetType] })] }, relation.name))) }))] })] }));
|
|
114
112
|
}
|
|
115
113
|
function SectionHeading({ title, note }) {
|
|
116
114
|
return (_jsxs("div", { className: "mb-3", children: [_jsx("h2", { className: cn('font-mono text-[11px] uppercase tracking-[0.16em]', MUTED), children: title }), _jsx("p", { className: cn('mt-1 text-xs', MUTED), children: note })] }));
|
|
117
115
|
}
|
|
118
|
-
function Th({ children, className, }) {
|
|
119
|
-
return (_jsx("th", { className: cn('px-3 py-2 font-mono text-[10px] font-normal uppercase tracking-[0.12em]', MUTED, className), children: children }));
|
|
120
|
-
}
|
|
121
116
|
function FieldChip({ label, value, onSave, }) {
|
|
122
117
|
return (_jsxs("div", { className: cn('flex items-center gap-1.5 rounded-md border px-2 py-1', RULE, PANEL), children: [_jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-wider', MUTED), children: label }), _jsx(EditableField, { label: label, value: value, placeholder: "\u2014", onSave: onSave, className: "text-xs", inputClassName: "text-xs" })] }));
|
|
123
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* The properties of one type, as a table.
|
|
121
|
+
*
|
|
122
|
+
* Every cell is an editor or a badge, so what TanStack contributes here is not
|
|
123
|
+
* cell rendering but the column model: six columns declared once, with their
|
|
124
|
+
* widths beside their contents instead of in a separate header row that has to
|
|
125
|
+
* be kept in the same order by hand.
|
|
126
|
+
*
|
|
127
|
+
* The widths are fixed rather than content-sized, and that is the point of
|
|
128
|
+
* declaring them at all: these cells contain inputs, and a column that sizes to
|
|
129
|
+
* its content reflows the whole table on every keystroke.
|
|
130
|
+
*/
|
|
131
|
+
function PropertyTable({ properties, onPatchProperty, }) {
|
|
132
|
+
const columns = useMemo(() => [
|
|
133
|
+
{
|
|
134
|
+
id: 'label',
|
|
135
|
+
header: 'Label',
|
|
136
|
+
accessorFn: (p) => p.displayName,
|
|
137
|
+
cell: ({ row }) => (_jsx(PropertyLabelCell, { property: row.original, onPatchProperty: onPatchProperty })),
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
id: 'column',
|
|
141
|
+
header: 'Column',
|
|
142
|
+
accessorFn: (p) => p.columnName,
|
|
143
|
+
cell: ({ row }) => (_jsx("span", { className: cn('font-mono text-[11px]', SECONDARY), children: row.original.columnName })),
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
id: 'type',
|
|
147
|
+
header: 'Type',
|
|
148
|
+
accessorFn: (p) => p.type,
|
|
149
|
+
cell: ({ row }) => (_jsx(ScalarBadge, { type: row.original.type })),
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
id: 'unit',
|
|
153
|
+
header: 'Unit',
|
|
154
|
+
accessorFn: (p) => p.unit ?? '',
|
|
155
|
+
cell: ({ row }) => (_jsx(EditableField, { label: `unit for ${row.original.name}`, value: row.original.unit ?? '', placeholder: "\u2014", onSave: (unit) => onPatchProperty(row.original.name, { unit }), inputClassName: "text-xs", className: "text-xs" })),
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
id: 'meaning',
|
|
159
|
+
header: 'Meaning',
|
|
160
|
+
accessorFn: (p) => p.description ?? '',
|
|
161
|
+
cell: ({ row }) => (_jsx(RichTextField, { label: `description for ${row.original.name}`, value: row.original.description ?? '', placeholder: "\u2014", onSave: (description) => onPatchProperty(row.original.name, { description }), className: cn('text-xs leading-snug', SECONDARY) })),
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
id: 'shown',
|
|
165
|
+
header: 'Shown',
|
|
166
|
+
accessorFn: (p) => !p.hidden,
|
|
167
|
+
cell: ({ row }) => (_jsx(VisibilityToggle, { property: row.original, onPatchProperty: onPatchProperty })),
|
|
168
|
+
},
|
|
169
|
+
], [onPatchProperty]);
|
|
170
|
+
return (_jsx(DataTable, { data: properties, columns: columns, getRowId: (property) => property.name,
|
|
171
|
+
// Dimmed rather than dropped: a hidden property is still stored, and a
|
|
172
|
+
// screen that simply omitted it could not tell you that showing it again
|
|
173
|
+
// needs no migration.
|
|
174
|
+
rowClassName: (property) => (property.hidden ? 'opacity-45' : undefined), columnClassName: (id) => PROPERTY_WIDTHS[id],
|
|
175
|
+
// `align-top`, because two of these cells hold a multi-line editor and a
|
|
176
|
+
// row centred on the tallest one leaves the single-line cells floating.
|
|
177
|
+
cellClassName: () => 'align-top whitespace-normal py-2' }));
|
|
178
|
+
}
|
|
179
|
+
const PROPERTY_WIDTHS = {
|
|
180
|
+
label: 'w-[30%]',
|
|
181
|
+
column: 'w-[22%]',
|
|
182
|
+
type: 'w-[10%]',
|
|
183
|
+
unit: 'w-[12%]',
|
|
184
|
+
meaning: 'w-[20%]',
|
|
185
|
+
shown: 'w-[6%] text-right',
|
|
186
|
+
};
|
|
187
|
+
/** The label cell: the curated name, with the physical name and its constraints beneath. */
|
|
188
|
+
function PropertyLabelCell({ property, onPatchProperty, }) {
|
|
189
|
+
return (_jsxs(_Fragment, { children: [_jsx(EditableField, { label: `label for ${property.name}`, value: property.displayName, onSave: (displayName) => onPatchProperty(property.name, { displayName }), inputClassName: "text-sm" }), _jsxs("div", { className: cn('px-1.5 font-mono text-[10px]', MUTED), children: [property.name, property.primary && (_jsx(Tooltip, { content: "Primary key. Always fetched, even when hidden, so a row keeps a stable identity.", children: _jsx("span", { className: "ml-1.5 cursor-help text-sky-600 dark:text-sky-400", children: "pk" }) })), !property.nullable && !property.primary && (_jsx(Tooltip, { content: "NOT NULL in the database. Read from the ORM, not something this screen can change.", children: _jsx("span", { className: "ml-1.5 cursor-help text-amber-600", children: "required" }) }))] })] }));
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Hiding is presentation, not schema — the tooltip says so on both sides,
|
|
193
|
+
* because "hidden" next to a database column reads as destructive until
|
|
194
|
+
* somebody tells you it is not.
|
|
195
|
+
*/
|
|
196
|
+
function VisibilityToggle({ property, onPatchProperty, }) {
|
|
197
|
+
return (_jsx(Tooltip, { content: property.hidden
|
|
198
|
+
? `Hidden from tables and search. ${property.displayName} is still stored — showing it again needs no migration.`
|
|
199
|
+
: 'Shown in tables and search. Hiding it only changes what is displayed; the column is untouched.', children: _jsx("button", { type: "button", "aria-label": `${property.hidden ? 'Show' : 'Hide'} ${property.displayName}`, onClick: () => onPatchProperty(property.name, { hidden: !property.hidden }), className: cn('rounded-sm p-1 hover:bg-zinc-100 dark:hover:bg-zinc-800', MUTED), children: property.hidden ? _jsx(EyeOff, { size: 14 }) : _jsx(Eye, { size: 14 }) }) }));
|
|
200
|
+
}
|
package/dist/DashboardBoard.js
CHANGED
|
@@ -4,12 +4,13 @@ import { SortableContext, arrayMove, rectSortingStrategy, sortableKeyboardCoordi
|
|
|
4
4
|
import { CSS } from '@dnd-kit/utilities';
|
|
5
5
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
6
6
|
import { Download, GripVertical, LayoutGrid, Plus, RefreshCw, Trash2 } from 'lucide-react';
|
|
7
|
-
import { useState } from 'react';
|
|
7
|
+
import { useMemo, useState } from 'react';
|
|
8
8
|
import { CssBarChart } from './charts/css';
|
|
9
9
|
import { getChartRenderer } from './charts/registry';
|
|
10
10
|
import { ChartEmpty, ChartFailed, ChartSkeleton } from './charts/skeleton';
|
|
11
11
|
import { cn } from './cn';
|
|
12
12
|
import { useCatalogClient } from './context';
|
|
13
|
+
import { DataTable, renderUnknown } from './ui/data-table';
|
|
13
14
|
import { Tooltip, TooltipProvider } from './ui/tooltip';
|
|
14
15
|
const MUTED = 'text-zinc-400 dark:text-zinc-500';
|
|
15
16
|
const RULE = 'border-zinc-200 dark:border-zinc-800';
|
|
@@ -125,9 +126,9 @@ export function DashboardBoard() {
|
|
|
125
126
|
create.mutate();
|
|
126
127
|
}, 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
128
|
? '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]
|
|
129
|
+
: '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
130
|
.sort((a, b) => a.position - b.position)
|
|
130
|
-
.map((c) => c.id), strategy: rectSortingStrategy, children: _jsx("div", { className: "mt-6 grid grid-cols-
|
|
131
|
+
.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
132
|
.sort((a, b) => a.position - b.position)
|
|
132
133
|
.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
134
|
}
|
|
@@ -142,13 +143,25 @@ function SortableCard({ id, savedQueryId, width, onRemove, onWidth, }) {
|
|
|
142
143
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
|
|
143
144
|
id,
|
|
144
145
|
});
|
|
145
|
-
return (_jsx("div", { ref: setNodeRef, style: { transform: CSS.Transform.toString(transform), transition }, className: cn(SPAN[width] ??
|
|
146
|
+
return (_jsx("div", { ref: setNodeRef, style: { transform: CSS.Transform.toString(transform), transition }, className: cn(SPAN[width] ?? SPAN[2],
|
|
147
|
+
// A grid item defaults to `min-width: auto`, so a chart wider than its
|
|
148
|
+
// column pushes the column out instead of being constrained by it —
|
|
149
|
+
// the same rule that made the nav overflow the page.
|
|
150
|
+
'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
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* The width an operator chose, applied only where there are columns to spend.
|
|
154
|
+
*
|
|
155
|
+
* Below `@5xl` the grid has fewer than four columns, and a `col-span-4` there
|
|
156
|
+
* spans past the end — which is what put a chart's axis labels outside its own
|
|
157
|
+
* card. Every card is full width on a narrow board, two-up in the middle, and
|
|
158
|
+
* only honours the chosen span once four columns exist to divide.
|
|
159
|
+
*/
|
|
147
160
|
const SPAN = {
|
|
148
|
-
1: 'col-span-1',
|
|
149
|
-
2: 'col-span-2',
|
|
150
|
-
3: 'col-span-3',
|
|
151
|
-
4: 'col-span-4',
|
|
161
|
+
1: '@5xl:col-span-1',
|
|
162
|
+
2: '@2xl:col-span-2 @5xl:col-span-2',
|
|
163
|
+
3: '@2xl:col-span-2 @5xl:col-span-3',
|
|
164
|
+
4: '@2xl:col-span-2 @5xl:col-span-4',
|
|
152
165
|
};
|
|
153
166
|
function Card({ savedQueryId, width, onRemove, onWidth, dragHandle, }) {
|
|
154
167
|
const client = useCatalogClient();
|
|
@@ -200,7 +213,21 @@ function CardBody({ query, result, }) {
|
|
|
200
213
|
return _jsx(MiniTable, { result: result });
|
|
201
214
|
}
|
|
202
215
|
function MiniTable({ result }) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
216
|
+
// Five columns and six rows, because this is a PREVIEW inside a card — the
|
|
217
|
+
// whole answer lives on the query screen, and a card that tried to show it
|
|
218
|
+
// would be a card you cannot read at a glance, which is the only thing a card
|
|
219
|
+
// is for.
|
|
220
|
+
const shown = useMemo(() => result.columns.slice(0, 5), [result.columns]);
|
|
221
|
+
const columns = useMemo(() => shown.map((column) => ({
|
|
222
|
+
id: column,
|
|
223
|
+
accessorFn: (row) => row[column],
|
|
224
|
+
header: column,
|
|
225
|
+
cell: (context) => renderUnknown(context.getValue()),
|
|
226
|
+
})), [shown]);
|
|
227
|
+
const rows = useMemo(() => result.rows.slice(0, 6), [result.rows]);
|
|
228
|
+
const numericColumns = useMemo(() => {
|
|
229
|
+
const first = rows[0];
|
|
230
|
+
return new Set(first ? shown.filter((column) => typeof first[column] === 'number') : []);
|
|
231
|
+
}, [rows, shown]);
|
|
232
|
+
return (_jsx(DataTable, { data: rows, columns: columns, numeric: (id) => numericColumns.has(id), density: "text-[11px]" }));
|
|
206
233
|
}
|
package/dist/ObjectExplorer.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useQuery } from '@tanstack/react-query';
|
|
3
|
-
import { ArrowLeft, ChevronDown, ChevronLeft, ChevronRight,
|
|
3
|
+
import { ArrowLeft, ChevronDown, ChevronLeft, ChevronRight, Search } from 'lucide-react';
|
|
4
4
|
import { useEffect, useMemo, useState } from 'react';
|
|
5
5
|
import { cn } from './cn';
|
|
6
6
|
import { catalogQueryKeys, useCatalogClient } from './context';
|
|
7
|
+
import { DataTable } from './ui/data-table';
|
|
7
8
|
/**
|
|
8
9
|
* One table for every object type in the catalog.
|
|
9
10
|
*
|
|
@@ -114,6 +115,17 @@ export function ObjectExplorer({ type: typeProp, pageSize = 25, backHref, backLa
|
|
|
114
115
|
placeholderData: (previous) => previous,
|
|
115
116
|
});
|
|
116
117
|
const selectedType = snapshot?.types.find((t) => t.name === typeName);
|
|
118
|
+
// Derived from what the SERVER said the columns are, not from a type this
|
|
119
|
+
// file knows: the explorer renders whatever was published. The second header
|
|
120
|
+
// line is the physical column name, which is what somebody writing SQL
|
|
121
|
+
// against the same table needs and the display name will not give them.
|
|
122
|
+
const columns = useMemo(() => (data?.columns ?? []).map((column) => ({
|
|
123
|
+
id: column.name,
|
|
124
|
+
accessorFn: (row) => row[column.name],
|
|
125
|
+
header: () => (_jsxs(_Fragment, { children: [_jsxs("span", { children: [column.displayName, column.unit && (_jsxs("span", { className: cn('ml-1 font-mono text-[10px]', MUTED), children: ["(", column.unit, ")"] }))] }), _jsx("div", { className: cn('font-mono text-[10px] font-normal', MUTED), children: column.name })] })),
|
|
126
|
+
cell: (context) => formatCell(context.getValue(), column.type),
|
|
127
|
+
})), [data?.columns]);
|
|
128
|
+
const numericColumns = useMemo(() => new Set((data?.columns ?? []).filter((c) => isNumeric(c.type)).map((c) => c.name)), [data?.columns]);
|
|
117
129
|
function toggleSort(column) {
|
|
118
130
|
if (sort === column) {
|
|
119
131
|
setDir((d) => (d === 'asc' ? 'desc' : 'asc'));
|
|
@@ -135,12 +147,7 @@ export function ObjectExplorer({ type: typeProp, pageSize = 25, backHref, backLa
|
|
|
135
147
|
setSearch('');
|
|
136
148
|
}, className: cn('flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm', t.name === typeName
|
|
137
149
|
? 'bg-sky-100 dark:bg-sky-950'
|
|
138
|
-
: 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx("span", { children: t.icon ?? '◈' }), _jsx("span", { className: "flex-1 truncate", children: t.pluralDisplayName }), _jsx("span", { className: cn('font-mono text-[10px]', MUTED), children: t.tableName })] }, t.name))) }))] }), _jsxs("div", { className: "relative", children: [_jsx(Search, { size: 14, className: cn('pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2', MUTED) }), _jsx("input", { type: "text", value: search, onChange: (e) => setSearch(e.target.value), placeholder: `Search ${selectedType?.pluralDisplayName?.toLowerCase() ?? 'objects'}`, "aria-label": "Search objects", className: cn('w-72 rounded-md border bg-zinc-50 py-2 pl-8 pr-3 text-sm outline-none dark:bg-zinc-950', RULE, 'placeholder:text-zinc-400 focus:border-sky-500 focus:ring-2 focus:ring-sky-500/15') })] })] })] }), _jsxs("div", { className: "min-h-0 flex-1 overflow-auto px-8 py-6", children: [_jsxs("div", { className: cn('overflow-hidden rounded-lg border transition-opacity', RULE, PANEL, isFetching && 'opacity-60'), children: [_jsx("div", { className: "
|
|
139
|
-
const active = sort === column.name;
|
|
140
|
-
return (_jsxs("th", { className: cn('whitespace-nowrap px-3 py-2 text-left font-normal', isNumeric(column.type) && 'text-right'), children: [_jsxs("button", { type: "button", onClick: () => toggleSort(column.name), className: cn('group inline-flex items-center gap-1', isNumeric(column.type) && 'flex-row-reverse'), children: [_jsxs("span", { className: cn('text-xs', active
|
|
141
|
-
? 'text-zinc-950 dark:text-zinc-50'
|
|
142
|
-
: 'text-zinc-500 dark:text-zinc-400'), children: [column.displayName, column.unit && (_jsxs("span", { className: cn('ml-1 font-mono text-[10px]', MUTED), children: ["(", column.unit, ")"] }))] }), active ? (dir === 'asc' ? (_jsx(ChevronUp, { size: 12 })) : (_jsx(ChevronDown, { size: 12 }))) : (_jsx(ChevronUp, { size: 12, className: "opacity-0 transition-opacity group-hover:opacity-40" }))] }), _jsx("div", { className: cn('font-mono text-[10px] font-normal', MUTED), children: column.name })] }, column.name));
|
|
143
|
-
}) }) }), _jsx("tbody", { children: data?.rows.map((row, index) => (_jsx("tr", { className: cn('border-b last:border-0 hover:bg-zinc-50 dark:hover:bg-zinc-950', HAIRLINE), children: data.columns.map((column) => (_jsx("td", { className: cn('whitespace-nowrap px-3 py-2', isNumeric(column.type) && 'text-right font-mono tabular-nums', (row[column.name] === null || row[column.name] === undefined) && MUTED), children: formatCell(row[column.name], column.type) }, column.name))) }, String(row[selectedType?.primaryKey[0] ?? 'id'] ?? index)))) })] }) }), data && data.rows.length === 0 && (_jsx(EmptyState, { type: selectedType, search: debouncedSearch, onClear: () => setSearch('') }))] }), data && data.pages > 1 && (_jsxs("div", { className: "mt-4 flex items-center justify-between", children: [_jsxs("p", { className: cn('font-mono text-[11px]', MUTED), children: ["Page ", data.page, " of ", data.pages] }), _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(PageButton, { onClick: () => setPage((p) => Math.max(1, p - 1)), disabled: data.page <= 1, label: "Previous page", children: _jsx(ChevronLeft, { size: 14 }) }), _jsx(PageButton, { onClick: () => setPage((p) => Math.min(data.pages, p + 1)), disabled: data.page >= data.pages, label: "Next page", children: _jsx(ChevronRight, { size: 14 }) })] })] }))] })] }));
|
|
150
|
+
: 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx("span", { children: t.icon ?? '◈' }), _jsx("span", { className: "flex-1 truncate", children: t.pluralDisplayName }), _jsx("span", { className: cn('font-mono text-[10px]', MUTED), children: t.tableName })] }, t.name))) }))] }), _jsxs("div", { className: "relative", children: [_jsx(Search, { size: 14, className: cn('pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2', MUTED) }), _jsx("input", { type: "text", value: search, onChange: (e) => setSearch(e.target.value), placeholder: `Search ${selectedType?.pluralDisplayName?.toLowerCase() ?? 'objects'}`, "aria-label": "Search objects", className: cn('w-72 rounded-md border bg-zinc-50 py-2 pl-8 pr-3 text-sm outline-none dark:bg-zinc-950', RULE, 'placeholder:text-zinc-400 focus:border-sky-500 focus:ring-2 focus:ring-sky-500/15') })] })] })] }), _jsxs("div", { className: "min-h-0 flex-1 overflow-auto px-8 py-6", children: [_jsxs("div", { className: cn('overflow-hidden rounded-lg border transition-opacity', RULE, PANEL, isFetching && 'opacity-60'), children: [_jsx(DataTable, { data: data?.rows ?? [], columns: columns, getRowId: (row, index) => String(row[selectedType?.primaryKey[0] ?? 'id'] ?? index), sort: { by: sort ?? null, dir, onSort: toggleSort }, numeric: (id) => numericColumns.has(id) }), data && data.rows.length === 0 && (_jsx(EmptyState, { type: selectedType, search: debouncedSearch, onClear: () => setSearch('') }))] }), data && data.pages > 1 && (_jsxs("div", { className: "mt-4 flex items-center justify-between", children: [_jsxs("p", { className: cn('font-mono text-[11px]', MUTED), children: ["Page ", data.page, " of ", data.pages] }), _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(PageButton, { onClick: () => setPage((p) => Math.max(1, p - 1)), disabled: data.page <= 1, label: "Previous page", children: _jsx(ChevronLeft, { size: 14 }) }), _jsx(PageButton, { onClick: () => setPage((p) => Math.min(data.pages, p + 1)), disabled: data.page >= data.pages, label: "Next page", children: _jsx(ChevronRight, { size: 14 }) })] })] }))] })] }));
|
|
144
151
|
}
|
|
145
152
|
function EmptyState({ type, search, onClear, }) {
|
|
146
153
|
if (search) {
|
package/dist/QueryConsole.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
3
3
|
import { AlertTriangle, History, Layers, Play, Sparkles, TableIcon } from 'lucide-react';
|
|
4
|
-
import { Highlight, themes } from 'prism-react-renderer';
|
|
5
4
|
import { useMemo, useRef, useState } from 'react';
|
|
6
5
|
import { SavedQueryPanel } from './SavedQueryPanel';
|
|
7
6
|
import { cn } from './cn';
|
|
8
7
|
import { useCatalogClient } from './context';
|
|
8
|
+
import { CodeEditor } from './ui/code-editor';
|
|
9
|
+
import { DataTable, renderUnknown } from './ui/data-table';
|
|
9
10
|
import { Tooltip, TooltipProvider } from './ui/tooltip';
|
|
10
11
|
const MUTED = 'text-zinc-400 dark:text-zinc-500';
|
|
11
12
|
const PANEL = 'bg-white dark:bg-zinc-900';
|
|
@@ -103,42 +104,26 @@ function RelationRow({ relation, onInsert, }) {
|
|
|
103
104
|
* contenteditable would look the same and lose all of it.
|
|
104
105
|
*/
|
|
105
106
|
function SqlEditor({ value, onChange, onKeyDown, textareaRef, }) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
// The outer one is the *only* thing that scrolls. The inner one has no
|
|
111
|
-
// height of its own, so it grows to whatever the highlighted code needs —
|
|
112
|
-
// which is what lets the textarea be `inset-0` and still cover every line
|
|
113
|
-
// rather than only the visible ones.
|
|
114
|
-
//
|
|
115
|
-
// Both used to scroll: the textarea was pinned to the outer box's visible
|
|
116
|
-
// area with `overflow: auto` of its own, so a long query produced two
|
|
117
|
-
// scrollbars, and scrolling the outer one left the caret sitting over the
|
|
118
|
-
// wrong line because the highlight moved and the input did not.
|
|
119
|
-
_jsx("div", { className: cn('relative h-56 shrink-0 overflow-auto border-b', RULE, PANEL), children: _jsxs("div", { className: "relative min-h-full w-full", children: [_jsx(Highlight, { code: value, language: "sql", theme: themes.github, children: ({ tokens, getLineProps, getTokenProps }) => (_jsx("pre", { className: cn(shared, 'pointer-events-none min-h-full'), "aria-hidden": true, children: tokens.map((line, i) => (
|
|
120
|
-
// biome-ignore lint/suspicious/noArrayIndexKey: lines have no id
|
|
121
|
-
_jsx("div", { ...getLineProps({ line }), children: line.map((token, key) => (
|
|
122
|
-
// biome-ignore lint/suspicious/noArrayIndexKey: tokens have no id
|
|
123
|
-
_jsx("span", { ...getTokenProps({ token }) }, key))) }, i))) })) }), _jsx("textarea", { ref: textareaRef, value: value, onChange: (e) => onChange(e.target.value), onKeyDown: onKeyDown, spellCheck: false, "aria-label": "SQL query", className: cn(shared,
|
|
124
|
-
// `overflow-hidden`, not `auto`: this layer is as tall as the code it
|
|
125
|
-
// holds, so it has nothing to scroll — and giving it the option back
|
|
126
|
-
// is what produced the second scrollbar.
|
|
127
|
-
'absolute inset-0 h-full w-full resize-none overflow-hidden bg-transparent', 'text-transparent caret-zinc-900 outline-none dark:caret-zinc-100') })] }) }));
|
|
107
|
+
return (_jsx(CodeEditor, { value: value, onChange: onChange, onKeyDown: onKeyDown, textareaRef: textareaRef, language: "sql", label: "SQL query",
|
|
108
|
+
// Roomier than the transform pane: this is the screen's primary input,
|
|
109
|
+
// not a side panel.
|
|
110
|
+
className: cn('h-56 shrink-0 border-b', RULE, PANEL), padding: "p-4", fontSize: "text-[13px]" }));
|
|
128
111
|
}
|
|
129
112
|
function ResultTable({ result }) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
113
|
+
// Built from the answer, because the answer decides them: a free SQL query
|
|
114
|
+
// returns whatever columns it returns, and there is no type to derive them
|
|
115
|
+
// from ahead of time.
|
|
116
|
+
const columns = useMemo(() => result.columns.map((column) => ({
|
|
117
|
+
id: column,
|
|
118
|
+
accessorFn: (row) => row[column],
|
|
119
|
+
header: column,
|
|
120
|
+
cell: (context) => renderUnknown(context.getValue()),
|
|
121
|
+
})), [result.columns]);
|
|
122
|
+
// Whether a column is numeric is a property of the DATA here, not of a
|
|
123
|
+
// schema — the first row is the only thing available to ask.
|
|
124
|
+
const numericColumns = useMemo(() => {
|
|
125
|
+
const first = result.rows[0];
|
|
126
|
+
return new Set(first ? result.columns.filter((column) => typeof first[column] === 'number') : []);
|
|
127
|
+
}, [result.columns, result.rows]);
|
|
128
|
+
return (_jsxs("div", { className: "p-4", children: [result.truncated && (_jsxs("p", { className: "mb-2 text-[11px] text-amber-600", children: ["Showing the first ", result.rowCount, " rows. Add a LIMIT or an aggregate to see a complete answer."] })), _jsx(DataTable, { data: result.rows, columns: columns, numeric: (id) => numericColumns.has(id), className: cn('rounded-lg border', RULE, PANEL), empty: _jsx("p", { className: cn('p-8 text-center text-sm', MUTED), children: "The query ran and matched nothing." }) })] }));
|
|
144
129
|
}
|
package/dist/TransformEditor.js
CHANGED
|
@@ -2,10 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { isTransformLanguage } from '@dudousxd/nestjs-catalog/client';
|
|
3
3
|
import { useMutation } from '@tanstack/react-query';
|
|
4
4
|
import { ArrowLeft, Play } from 'lucide-react';
|
|
5
|
-
import { Highlight, themes } from 'prism-react-renderer';
|
|
6
5
|
import { useRef, useState } from 'react';
|
|
7
6
|
import { cn } from './cn';
|
|
8
7
|
import { useCatalogClient } from './context';
|
|
8
|
+
import { CodeEditor } from './ui/code-editor';
|
|
9
9
|
import { TextField } from './ui/field';
|
|
10
10
|
import { SelectField } from './ui/select';
|
|
11
11
|
const MUTED = 'text-zinc-400 dark:text-zinc-500';
|
|
@@ -116,14 +116,5 @@ export function TransformEditor({ transform, languages, pythonPackages = [], onC
|
|
|
116
116
|
label: option,
|
|
117
117
|
})) })] }), _jsxs("div", { className: "grid gap-3 lg:grid-cols-2", children: [_jsxs("div", { className: cn('overflow-hidden rounded-lg border', RULE, PANEL), children: [_jsxs("div", { className: cn('flex items-center justify-between border-b px-3 py-1.5', RULE), children: [_jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Code" }), _jsx("span", { className: cn('font-mono text-[10px]', MUTED), children: language === 'python' && pythonPackages.length > 0
|
|
118
118
|
? `imports: ${pythonPackages.join(', ')}`
|
|
119
|
-
: '⌘↵ to try' })] }), _jsx(
|
|
120
|
-
}
|
|
121
|
-
/** A textarea under a highlighted `<pre>`, the same shape the query editor uses. */
|
|
122
|
-
function CodePane({ value, onChange, onKeyDown, language, textareaRef, }) {
|
|
123
|
-
const shared = 'm-0 p-3 font-mono text-[12px] leading-[1.5] whitespace-pre-wrap break-words';
|
|
124
|
-
return (_jsxs("div", { className: "relative h-72 overflow-auto", children: [_jsx(Highlight, { code: value, language: language, theme: themes.github, children: ({ tokens, getLineProps, getTokenProps }) => (_jsx("pre", { className: cn(shared, 'pointer-events-none min-h-full'), "aria-hidden": true, children: tokens.map((line, i) => (
|
|
125
|
-
// biome-ignore lint/suspicious/noArrayIndexKey: lines have no id
|
|
126
|
-
_jsx("div", { ...getLineProps({ line }), children: line.map((token, key) => (
|
|
127
|
-
// biome-ignore lint/suspicious/noArrayIndexKey: tokens have no id
|
|
128
|
-
_jsx("span", { ...getTokenProps({ token }) }, key))) }, i))) })) }), _jsx("textarea", { ref: textareaRef, value: value, onChange: (event) => onChange(event.target.value), onKeyDown: onKeyDown, spellCheck: false, "aria-label": "Transform code", className: cn(shared, 'absolute inset-0 h-full w-full resize-none bg-transparent', 'text-transparent caret-zinc-900 outline-none dark:caret-zinc-100') })] }));
|
|
119
|
+
: '⌘↵ to try' })] }), _jsx(CodeEditor, { value: code, onChange: setCode, onKeyDown: onKeyDown, language: language === 'python' ? 'python' : 'tsx', label: "Transform code", textareaRef: editorRef, className: "h-72" })] }), _jsxs("div", { className: "space-y-3", children: [_jsxs("div", { className: cn('overflow-hidden rounded-lg border', RULE, PANEL), children: [_jsx("div", { className: cn('border-b px-3 py-1.5', RULE), children: _jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Sample records" }) }), _jsx(CodeEditor, { value: sample, onChange: setSample, language: "json", label: "Sample records", className: "h-32" })] }), _jsxs("button", { type: "button", onClick: () => tryIt.mutate(), disabled: tryIt.isPending, className: "flex items-center gap-1.5 rounded-md bg-zinc-950 px-3 py-1.5 text-xs text-zinc-50 disabled:opacity-40 dark:bg-zinc-100 dark:text-zinc-950", children: [_jsx(Play, { size: 12 }), tryIt.isPending ? 'Running…' : 'Try it'] }), _jsxs("div", { className: cn('overflow-hidden rounded-lg border', RULE, PANEL), children: [_jsx("div", { className: cn('border-b px-3 py-1.5', RULE), children: _jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Output" }) }), _jsxs("div", { className: "max-h-64 overflow-auto p-3", children: [tryIt.error && (_jsx("p", { className: "font-mono text-[11px] leading-relaxed text-red-600", children: tryIt.error instanceof Error ? tryIt.error.message : 'It failed.' })), tryIt.data && (_jsxs(_Fragment, { children: [tryIt.data.logs.length > 0 && (_jsx("pre", { className: cn('mb-2 whitespace-pre-wrap font-mono text-[10px]', MUTED), children: tryIt.data.logs.join('\n') })), tryIt.data.rows.length === 0 ? (_jsx("p", { className: "text-[11px] text-amber-600", children: "It ran and returned no rows. A connector using this would commit an empty snapshot." })) : (_jsx("pre", { className: "whitespace-pre-wrap font-mono text-[11px]", children: JSON.stringify(tryIt.data.rows, null, 2) })), _jsxs("p", { className: cn('mt-2 font-mono text-[10px]', MUTED), children: [tryIt.data.rows.length, " rows \u00B7 ", tryIt.data.elapsedMs, "ms"] })] })), !tryIt.data && !tryIt.error && (_jsx("p", { className: cn('py-4 text-center text-[11px]', MUTED), children: "Run it to see what it produces." }))] })] })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("button", { type: "button", onClick: () => save.mutate(), disabled: save.isPending || name.trim().length === 0, className: cn('rounded-md border px-3 py-1.5 text-xs disabled:opacity-40', RULE, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: save.isPending ? 'Saving…' : transform ? 'Save changes' : 'Save transform' }), transform && (_jsxs("span", { className: cn('font-mono text-[10px]', MUTED), children: ["saving new code makes this v", transform.version + 1] })), save.error && (_jsx("span", { className: "text-[11px] text-red-600", children: save.error instanceof Error ? save.error.message : 'Could not save.' }))] })] }));
|
|
129
120
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -26,5 +26,8 @@ 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 { CodeEditor, type CodeEditorProps } from './ui/code-editor';
|
|
30
|
+
export { RichTextField, RichTextView, type RichTextFieldProps, } from './ui/rich-text-field';
|
|
31
|
+
export { Button, type ButtonProps, type ButtonSize, type ButtonVariant } from './ui/button';
|
|
29
32
|
export { Tabs, TabsList, TabsPanel, TabsTab } from './ui/tabs';
|
|
30
33
|
export { Tooltip, TooltipProvider } from './ui/tooltip';
|
package/dist/index.js
CHANGED
|
@@ -61,5 +61,8 @@ 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 { CodeEditor } from './ui/code-editor';
|
|
65
|
+
export { RichTextField, RichTextView, } from './ui/rich-text-field';
|
|
66
|
+
export { Button } from './ui/button';
|
|
64
67
|
export { Tabs, TabsList, TabsPanel, TabsTab } from './ui/tabs';
|
|
65
68
|
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
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { KeyboardEvent, Ref } from 'react';
|
|
2
|
+
export interface CodeEditorProps {
|
|
3
|
+
value: string;
|
|
4
|
+
onChange: (next: string) => void;
|
|
5
|
+
/** Anything Prism knows: `sql`, `json`, `python`, `tsx`, … */
|
|
6
|
+
language: string;
|
|
7
|
+
/** Required. This is an input, and an unlabelled one is unusable by name. */
|
|
8
|
+
label: string;
|
|
9
|
+
onKeyDown?: (event: KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
10
|
+
textareaRef?: Ref<HTMLTextAreaElement>;
|
|
11
|
+
/** Metrics differ by caller — the query box is roomier than a sample pane. */
|
|
12
|
+
className?: string;
|
|
13
|
+
padding?: string;
|
|
14
|
+
fontSize?: string;
|
|
15
|
+
readOnly?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function CodeEditor({ value, onChange, language, label, onKeyDown, textareaRef, className, padding, fontSize, readOnly, }: CodeEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Highlight } from 'prism-react-renderer';
|
|
3
|
+
import { cn } from '../cn';
|
|
4
|
+
/**
|
|
5
|
+
* A code editor: a transparent `<textarea>` over a highlighted `<pre>`.
|
|
6
|
+
*
|
|
7
|
+
* Written out once here because it was written out twice — the query console
|
|
8
|
+
* and the transform editor each carried their own copy, with the same two boxes
|
|
9
|
+
* and the same three comments, and only one of them had been taught about JSON.
|
|
10
|
+
*
|
|
11
|
+
* Not CodeMirror, and that is a decision rather than an omission. A textarea is
|
|
12
|
+
* already the best plain-text input the platform has: it has the caret, the
|
|
13
|
+
* selection, undo, IME, autofill and every accessibility affordance for free,
|
|
14
|
+
* and a controlled editor built on a document model has to reimplement the lot
|
|
15
|
+
* — the classic symptom being a caret that jumps to the end whenever the value
|
|
16
|
+
* is updated from outside. What is missing here is autocomplete and bracket
|
|
17
|
+
* matching, which nothing in this console asks for.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* The palette, from the console's own surface tokens.
|
|
21
|
+
*
|
|
22
|
+
* The previous copies both passed `themes.github`, which is a LIGHT theme — its
|
|
23
|
+
* plain text is near-black. That was invisible for as long as the console was
|
|
24
|
+
* light, and turned the SQL box into dark-on-dark the day the console became
|
|
25
|
+
* dark. So the theme is defined against the same variables the shell sets
|
|
26
|
+
* rather than picked from a list, and the two cannot drift again.
|
|
27
|
+
*/
|
|
28
|
+
const CONSOLE_THEME = {
|
|
29
|
+
plain: { color: 'var(--text, #e7e7ea)', backgroundColor: 'transparent' },
|
|
30
|
+
styles: [
|
|
31
|
+
{ types: ['comment', 'prolog', 'doctype', 'cdata'], style: { color: 'var(--muted, #76767f)' } },
|
|
32
|
+
{ types: ['punctuation'], style: { color: 'var(--muted, #76767f)' } },
|
|
33
|
+
{
|
|
34
|
+
types: ['keyword', 'operator', 'rule', 'important', 'atrule'],
|
|
35
|
+
style: { color: 'var(--accent, #38bdf8)' },
|
|
36
|
+
},
|
|
37
|
+
{ types: ['string', 'char', 'attr-value', 'regex'], style: { color: '#34d399' } },
|
|
38
|
+
{ types: ['number', 'boolean', 'constant', 'symbol'], style: { color: '#fbbf24' } },
|
|
39
|
+
{ types: ['function', 'class-name', 'builtin'], style: { color: '#a78bfa' } },
|
|
40
|
+
{ types: ['variable', 'attr-name', 'property', 'tag'], style: { color: '#7dd3fc' } },
|
|
41
|
+
{ types: ['deleted'], style: { color: '#f87171' } },
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
export function CodeEditor({ value, onChange, language, label, onKeyDown, textareaRef, className, padding = 'p-3', fontSize = 'text-[12px]', readOnly, }) {
|
|
45
|
+
// Every property that affects where a glyph lands has to be identical on both
|
|
46
|
+
// layers, or the caret drifts from the text it is supposed to be inside — one
|
|
47
|
+
// character further off with every line.
|
|
48
|
+
//
|
|
49
|
+
// `leading` comes AFTER `fontSize` deliberately: tailwind-merge knows a
|
|
50
|
+
// `text-{size}` utility can carry a line-height, so a `leading-*` written
|
|
51
|
+
// before it is dropped as superseded — silently, and the browser default
|
|
52
|
+
// applies to both layers instead of 1.5.
|
|
53
|
+
const shared = cn('m-0 font-mono whitespace-pre-wrap break-words', padding, fontSize, 'leading-[1.5]');
|
|
54
|
+
return (
|
|
55
|
+
// Two boxes, and the division between them is the whole point.
|
|
56
|
+
//
|
|
57
|
+
// The outer one is the ONLY thing that scrolls. The inner one has no height
|
|
58
|
+
// of its own, so it grows to whatever the highlighted code needs — which is
|
|
59
|
+
// what lets the textarea be `inset-0` and still cover every line rather than
|
|
60
|
+
// only the visible ones. When both scrolled, a long query produced two
|
|
61
|
+
// scrollbars and scrolling the outer one left the caret over the wrong line,
|
|
62
|
+
// because the highlight moved and the input did not.
|
|
63
|
+
_jsx("div", { className: cn('relative overflow-auto', className), children: _jsxs("div", { className: "relative min-h-full w-full", children: [_jsx(Highlight, { code: value, language: language, theme: CONSOLE_THEME, children: ({ style, tokens, getLineProps, getTokenProps }) => (
|
|
64
|
+
// `style` carries the theme's `plain`, which is what anything Prism
|
|
65
|
+
// did NOT tokenise falls back to. Dropping it leaves that text
|
|
66
|
+
// inheriting from whatever is above, which happens to be right on
|
|
67
|
+
// this console and would not be on another.
|
|
68
|
+
_jsx("pre", { style: style, className: cn(shared, 'pointer-events-none min-h-full'), "aria-hidden": true, children: tokens.map((line, i) => (
|
|
69
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: lines have no id
|
|
70
|
+
_jsx("div", { ...getLineProps({ line }), children: line.map((token, key) => (
|
|
71
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: tokens have no id
|
|
72
|
+
_jsx("span", { ...getTokenProps({ token }) }, key))) }, i))) })) }), _jsx("textarea", { ref: textareaRef, value: value, onChange: (event) => onChange(event.target.value), onKeyDown: onKeyDown, spellCheck: false, readOnly: readOnly, "aria-label": label, className: cn(shared,
|
|
73
|
+
// `overflow-hidden`, not `auto`: this layer is as tall as the code
|
|
74
|
+
// it holds, so it has nothing to scroll — and giving it the option
|
|
75
|
+
// back is what produced the second scrollbar.
|
|
76
|
+
'absolute inset-0 h-full w-full resize-none overflow-hidden bg-transparent',
|
|
77
|
+
// Transparent text over the highlighted copy, but a VISIBLE caret
|
|
78
|
+
// and a visible selection — those are the two things the `<pre>`
|
|
79
|
+
// underneath cannot draw.
|
|
80
|
+
'text-transparent caret-zinc-900 outline-none dark:caret-zinc-100', 'selection:bg-sky-500/30 selection:text-transparent') })] }) }));
|
|
81
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { type RowData, type TableOptions } from '@tanstack/react-table';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* The console's data tables, on TanStack Table v9.
|
|
5
|
+
*
|
|
6
|
+
* Four screens hand-rolled `<table>` markup with the same header row, the same
|
|
7
|
+
* hairlines and the same "numbers go right" rule, each slightly differently.
|
|
8
|
+
* What TanStack owns here is the column model, the header groups and the cell
|
|
9
|
+
* rendering; what it deliberately does NOT own is where the data comes from.
|
|
10
|
+
*
|
|
11
|
+
* **Sorting is a prop, not a row model.** The object explorer sorts, pages and
|
|
12
|
+
* searches on the SERVER — it has to, because it is reading a warehouse table
|
|
13
|
+
* that does not fit in a browser. Handing those columns to
|
|
14
|
+
* `createSortedRowModel` would sort the fifty rows currently on screen and
|
|
15
|
+
* present the result as if it were the whole answer, which is a worse bug than
|
|
16
|
+
* no sorting at all: it looks right. So this component renders the sort
|
|
17
|
+
* affordance and reports clicks, and the caller decides whether that means a
|
|
18
|
+
* refetch or a client-side reorder.
|
|
19
|
+
*/
|
|
20
|
+
/** What a header needs to know to draw and drive a sort indicator. */
|
|
21
|
+
export interface DataTableSort {
|
|
22
|
+
/** Column id currently sorted, or null. */
|
|
23
|
+
by: string | null;
|
|
24
|
+
dir: 'asc' | 'desc';
|
|
25
|
+
/** Called with the column id. The caller decides what sorting means. */
|
|
26
|
+
onSort: (columnId: string) => void;
|
|
27
|
+
/** Column ids that can be sorted. Absent means all of them. */
|
|
28
|
+
sortable?: (columnId: string) => boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface DataTableProps<TData extends RowData> {
|
|
31
|
+
data: TData[];
|
|
32
|
+
/**
|
|
33
|
+
* Typed as exactly what `useTable` accepts for THIS feature set, rather than
|
|
34
|
+
* as a hand-written `ColumnDef<...>`. A literal type here widens `TFeatures`
|
|
35
|
+
* to the full `TableFeatures` union at the call below and stops assigning —
|
|
36
|
+
* v9's column type is parameterised by the features in play, which is the
|
|
37
|
+
* whole point of opting into them.
|
|
38
|
+
*/
|
|
39
|
+
columns: TableOptions<DataTableFeatures, TData>['columns'];
|
|
40
|
+
/** Stable per row. Falls back to the index, which is right for a SQL result. */
|
|
41
|
+
getRowId?: (row: TData, index: number) => string;
|
|
42
|
+
sort?: DataTableSort;
|
|
43
|
+
/** Rendered instead of the body when there are no rows. */
|
|
44
|
+
empty?: ReactNode;
|
|
45
|
+
/** Right-aligns and tabular-nums a column — numbers read down a column badly otherwise. */
|
|
46
|
+
numeric?: (columnId: string) => boolean;
|
|
47
|
+
className?: string;
|
|
48
|
+
/** `text-sm` for a full screen, `text-[11px]` for a card preview. */
|
|
49
|
+
density?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Per-row classes — a hidden property is dimmed rather than removed, so the
|
|
52
|
+
* screen can say "this exists and is not shown" instead of just not saying.
|
|
53
|
+
*/
|
|
54
|
+
rowClassName?: (row: TData) => string | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Per-column classes. Column WIDTH lives here rather than being derived,
|
|
57
|
+
* because a table of editable fields needs the columns to hold still while
|
|
58
|
+
* you type in them — content-sized columns reflow on every keystroke.
|
|
59
|
+
*/
|
|
60
|
+
columnClassName?: (columnId: string) => string | undefined;
|
|
61
|
+
/** Cells, when a column needs `align-top` for multi-line editors. */
|
|
62
|
+
cellClassName?: (columnId: string) => string | undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The v9 feature set, listed once.
|
|
66
|
+
*
|
|
67
|
+
* v9 is opt-in per feature rather than v8's batteries-included table, which is
|
|
68
|
+
* the point of the rewrite — a table that never groups should not ship the
|
|
69
|
+
* grouping code. Everything here is core: this component renders rows and
|
|
70
|
+
* columns and leaves sorting, filtering and pagination to whoever owns the data.
|
|
71
|
+
*/
|
|
72
|
+
declare function featureSet(): {
|
|
73
|
+
coreCellsFeature: import("@tanstack/react-table").TableFeature;
|
|
74
|
+
coreColumnsFeature: import("@tanstack/react-table").TableFeature;
|
|
75
|
+
coreHeadersFeature: import("@tanstack/react-table").TableFeature;
|
|
76
|
+
coreRowModelsFeature: import("@tanstack/react-table").TableFeature;
|
|
77
|
+
coreRowsFeature: import("@tanstack/react-table").TableFeature;
|
|
78
|
+
coreTablesFeature: import("@tanstack/react-table").TableFeature;
|
|
79
|
+
coreRowModel: (table: import("@tanstack/react-table").Table<import("@tanstack/react-table").TableFeatures, RowData>) => () => import("@tanstack/react-table").RowModel<import("@tanstack/react-table").TableFeatures, RowData>;
|
|
80
|
+
};
|
|
81
|
+
export type DataTableFeatures = ReturnType<typeof featureSet>;
|
|
82
|
+
export declare function DataTable<TData extends RowData>({ data, columns, getRowId, sort, empty, numeric, className, density, rowClassName, columnClassName, cellClassName, }: DataTableProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
83
|
+
/**
|
|
84
|
+
* A value from an arbitrary query, as a cell.
|
|
85
|
+
*
|
|
86
|
+
* Exported because two screens render untyped rows and both had their own copy
|
|
87
|
+
* of this ladder — and the interesting case is the one people skip: `null` and
|
|
88
|
+
* `undefined` must render as a visible mark rather than as an empty cell, or
|
|
89
|
+
* "no value" and "a value that happens to be blank" look identical.
|
|
90
|
+
*/
|
|
91
|
+
export declare function renderUnknown(value: unknown): ReactNode;
|
|
92
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { coreCellsFeature, coreColumnsFeature, coreHeadersFeature, coreRowModelsFeature, coreRowsFeature, coreTablesFeature, createCoreRowModel, flexRender, useTable, } from '@tanstack/react-table';
|
|
3
|
+
import { ArrowDown, ArrowUp, ChevronsUpDown } from 'lucide-react';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { cn } from '../cn';
|
|
6
|
+
/**
|
|
7
|
+
* The v9 feature set, listed once.
|
|
8
|
+
*
|
|
9
|
+
* v9 is opt-in per feature rather than v8's batteries-included table, which is
|
|
10
|
+
* the point of the rewrite — a table that never groups should not ship the
|
|
11
|
+
* grouping code. Everything here is core: this component renders rows and
|
|
12
|
+
* columns and leaves sorting, filtering and pagination to whoever owns the data.
|
|
13
|
+
*/
|
|
14
|
+
function featureSet() {
|
|
15
|
+
return {
|
|
16
|
+
coreCellsFeature,
|
|
17
|
+
coreColumnsFeature,
|
|
18
|
+
coreHeadersFeature,
|
|
19
|
+
coreRowModelsFeature,
|
|
20
|
+
coreRowsFeature,
|
|
21
|
+
coreTablesFeature,
|
|
22
|
+
// Built here rather than at module scope, and per table rather than once:
|
|
23
|
+
// a row model factory carries a cache, and one shared across every table on
|
|
24
|
+
// the screen is a cache keyed by nothing.
|
|
25
|
+
coreRowModel: createCoreRowModel(),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const RULE = 'border-zinc-200 dark:border-zinc-800';
|
|
29
|
+
const MUTED = 'text-zinc-400 dark:text-zinc-500';
|
|
30
|
+
export function DataTable({ data, columns, getRowId, sort, empty, numeric, className, density = 'text-sm', rowClassName, columnClassName, cellClassName, }) {
|
|
31
|
+
// Explicit type arguments rather than inference: `columns` and `data` are
|
|
32
|
+
// two inference sites for the same pair, and with a third parameter
|
|
33
|
+
// (`TFeatures`) in play TS gives up and falls back to the constraints —
|
|
34
|
+
// `TableFeatures`/`RowData` — which then refuse the narrower columns.
|
|
35
|
+
const features = useMemo(featureSet, []);
|
|
36
|
+
const table = useTable({
|
|
37
|
+
// The row model factories live INSIDE `features`, not in a sibling option.
|
|
38
|
+
// v9 folded them in so a feature and the row model it needs are registered
|
|
39
|
+
// together; a separate `rowModels` option does not typecheck and would be
|
|
40
|
+
// ignored at runtime.
|
|
41
|
+
features,
|
|
42
|
+
data,
|
|
43
|
+
columns,
|
|
44
|
+
...(getRowId ? { getRowId } : {}),
|
|
45
|
+
});
|
|
46
|
+
const rows = table.getRowModel().rows;
|
|
47
|
+
if (rows.length === 0 && empty)
|
|
48
|
+
return _jsx(_Fragment, { children: empty });
|
|
49
|
+
return (_jsx("div", { className: cn('overflow-x-auto', className), children: _jsxs("table", { className: cn('w-full min-w-max', density), children: [_jsx("thead", { children: table.getHeaderGroups().map((group) => (_jsx("tr", { className: cn('border-b bg-zinc-50 dark:bg-zinc-950', RULE), children: group.headers.map((header) => (_jsx(HeaderCell, { id: header.column.id, label: flexRender(header.column.columnDef.header, header.getContext()), sort: sort, isNumeric: numeric?.(header.column.id) ?? false, className: columnClassName?.(header.column.id) }, header.id))) }, group.id))) }), _jsx("tbody", { children: rows.map((row) => (_jsx("tr", { className: cn('border-b border-zinc-100 last:border-0 dark:border-zinc-900', rowClassName?.(row.original)), children: row.getAllCells().map((cell) => (_jsx("td", { className: cn('whitespace-nowrap px-3 py-1.5', cellClassName?.(cell.column.id),
|
|
50
|
+
// `tabular-nums` so digits line up down the column; without
|
|
51
|
+
// it a proportional font makes 1,111 narrower than 8,888 and
|
|
52
|
+
// the eye cannot compare magnitudes at a glance.
|
|
53
|
+
(numeric?.(cell.column.id) ?? false) && 'text-right font-mono tabular-nums'), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id))) })] }) }));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Three states, not two.
|
|
57
|
+
*
|
|
58
|
+
* A sortable column that is not currently sorted shows a neutral glyph on hover
|
|
59
|
+
* rather than nothing: a header that looks inert until you click it is one
|
|
60
|
+
* people do not think to click.
|
|
61
|
+
*/
|
|
62
|
+
function SortIcon({ active, dir }) {
|
|
63
|
+
if (!active) {
|
|
64
|
+
return _jsx(ChevronsUpDown, { size: 11, className: cn('opacity-0 group-hover:opacity-100', MUTED) });
|
|
65
|
+
}
|
|
66
|
+
return dir === 'asc' ? _jsx(ArrowUp, { size: 11 }) : _jsx(ArrowDown, { size: 11 });
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A value from an arbitrary query, as a cell.
|
|
70
|
+
*
|
|
71
|
+
* Exported because two screens render untyped rows and both had their own copy
|
|
72
|
+
* of this ladder — and the interesting case is the one people skip: `null` and
|
|
73
|
+
* `undefined` must render as a visible mark rather than as an empty cell, or
|
|
74
|
+
* "no value" and "a value that happens to be blank" look identical.
|
|
75
|
+
*/
|
|
76
|
+
export function renderUnknown(value) {
|
|
77
|
+
if (value === null || value === undefined) {
|
|
78
|
+
return _jsx("span", { className: MUTED, children: "\u2014" });
|
|
79
|
+
}
|
|
80
|
+
if (typeof value === 'object')
|
|
81
|
+
return JSON.stringify(value);
|
|
82
|
+
return String(value);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* One column header, sortable or not.
|
|
86
|
+
*
|
|
87
|
+
* Its own component because the two shapes barely overlap: a sortable header is
|
|
88
|
+
* a button carrying the label and an indicator, and a plain one is a mono
|
|
89
|
+
* caption. Inlined, the branch pushed `DataTable` past the complexity the lint
|
|
90
|
+
* allows — which was a fair reading, not a technicality.
|
|
91
|
+
*/
|
|
92
|
+
function HeaderCell({ id, label, sort, isNumeric, className, }) {
|
|
93
|
+
const canSort = sort ? (sort.sortable?.(id) ?? true) : false;
|
|
94
|
+
const active = sort?.by === id;
|
|
95
|
+
return (_jsx("th", { ...(canSort && active && sort
|
|
96
|
+
? { 'aria-sort': sort.dir === 'asc' ? 'ascending' : 'descending' }
|
|
97
|
+
: {}), className: cn('whitespace-nowrap px-3 py-2 text-left font-normal', isNumeric && 'text-right', className), children: canSort && sort ? (_jsxs("button", { type: "button", onClick: () => sort.onSort(id),
|
|
98
|
+
// The arrow follows the text to the edge it is aligned to, rather
|
|
99
|
+
// than sitting between the label and the numbers it describes.
|
|
100
|
+
className: cn('group inline-flex items-center gap-1', isNumeric && 'flex-row-reverse'), children: [_jsx("span", { className: cn('text-xs', active ? 'text-zinc-950 dark:text-zinc-50' : 'text-zinc-500 dark:text-zinc-400'), children: label }), _jsx(SortIcon, { active: active, dir: sort.dir })] })) : (_jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-[0.12em]', MUTED), children: label })) }));
|
|
101
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type MarkdownStorage } from 'tiptap-markdown';
|
|
2
|
+
declare module '@tiptap/core' {
|
|
3
|
+
interface Storage {
|
|
4
|
+
markdown: MarkdownStorage;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export interface RichTextFieldProps {
|
|
8
|
+
/** Markdown. Empty string means "nothing written yet". */
|
|
9
|
+
value: string;
|
|
10
|
+
onSave: (markdown: string) => void;
|
|
11
|
+
/** Announced to assistive tech — this control has no visible label. */
|
|
12
|
+
label: string;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function RichTextField({ value, onSave, label, placeholder, className, }: RichTextFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
/** Read-only, through the same editor, so one parser decides what the text means. */
|
|
18
|
+
export declare function RichTextView({ value, className }: {
|
|
19
|
+
value: string;
|
|
20
|
+
className?: string;
|
|
21
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { EditorContent, useEditor } from '@tiptap/react';
|
|
3
|
+
import StarterKit from '@tiptap/starter-kit';
|
|
4
|
+
import { Bold, Check, Code, Italic, List, ListOrdered, X } from 'lucide-react';
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
6
|
+
import { Markdown } from 'tiptap-markdown';
|
|
7
|
+
import { cn } from '../cn';
|
|
8
|
+
import { Button } from './button';
|
|
9
|
+
/**
|
|
10
|
+
* A curated description, edited as rich text and stored as **markdown**.
|
|
11
|
+
*
|
|
12
|
+
* Markdown rather than HTML, and the reason is what happens to everyone who is
|
|
13
|
+
* NOT this editor. `description` is served raw in the `/catalog` snapshot to
|
|
14
|
+
* whatever a host built on top of it, and those consumers were written against
|
|
15
|
+
* plain text. Markdown degrades into something a person can still read —
|
|
16
|
+
* `**bold**` — while HTML degrades into `<strong>bold</strong>`, which is
|
|
17
|
+
* noise, and creates an XSS surface in every consumer that decides to render it
|
|
18
|
+
* after all. One of those failures is cosmetic and the other is a
|
|
19
|
+
* vulnerability.
|
|
20
|
+
*
|
|
21
|
+
* The read view is the same editor with `editable: false` rather than a second
|
|
22
|
+
* markdown renderer. Two parsers for one format is two answers to "what does
|
|
23
|
+
* this text mean", and they diverge on exactly the inputs nobody tests.
|
|
24
|
+
*/
|
|
25
|
+
/** Kept out of the toolbar deliberately — see the docblock on {@link RichTextField}. */
|
|
26
|
+
const EXTENSIONS = [
|
|
27
|
+
StarterKit.configure({
|
|
28
|
+
// No headings inside a field that renders in a table cell and a tooltip:
|
|
29
|
+
// an `<h1>` in a 20%-wide column is a line of enormous text, and the
|
|
30
|
+
// affordance would be there purely because the library offers it.
|
|
31
|
+
heading: false,
|
|
32
|
+
// Nor images or horizontal rules, for the same reason.
|
|
33
|
+
horizontalRule: false,
|
|
34
|
+
}),
|
|
35
|
+
Markdown.configure({
|
|
36
|
+
// Round-trip fidelity over prettiness: this text is read by other programs.
|
|
37
|
+
linkify: false,
|
|
38
|
+
breaks: false,
|
|
39
|
+
transformPastedText: true,
|
|
40
|
+
}),
|
|
41
|
+
];
|
|
42
|
+
/**
|
|
43
|
+
* What the rendered markdown looks like, as utilities rather than as a class
|
|
44
|
+
* the host has to define.
|
|
45
|
+
*
|
|
46
|
+
* A component library that references a `prose-…` class it does not ship is a
|
|
47
|
+
* component library that renders unstyled in somebody else's app — bold text
|
|
48
|
+
* that is not bold, list items with no bullets — and nothing errors, so it
|
|
49
|
+
* reads as a broken component. Arbitrary variants keep the styling inside the
|
|
50
|
+
* class strings Tailwind already scans in `dist`.
|
|
51
|
+
*
|
|
52
|
+
* Deliberately small. These are one-paragraph descriptions in a table cell, not
|
|
53
|
+
* documents.
|
|
54
|
+
*/
|
|
55
|
+
const PROSE = cn('[&_p]:my-0 [&_p+p]:mt-2', '[&_strong]:font-semibold', '[&_em]:italic', '[&_code]:rounded [&_code]:bg-zinc-100 [&_code]:px-1 [&_code]:font-mono [&_code]:text-[0.9em]', 'dark:[&_code]:bg-zinc-800', '[&_ul]:my-1 [&_ul]:list-disc [&_ul]:pl-4', '[&_ol]:my-1 [&_ol]:list-decimal [&_ol]:pl-4', '[&_li]:my-0.5');
|
|
56
|
+
export function RichTextField({ value, onSave, label, placeholder = '—', className, }) {
|
|
57
|
+
const [editing, setEditing] = useState(false);
|
|
58
|
+
if (!editing) {
|
|
59
|
+
return (_jsx("button", { type: "button", onClick: () => setEditing(true), "aria-label": `Edit ${label}`, className: cn('w-full rounded-sm px-1.5 py-0.5 text-left', 'hover:bg-zinc-100 dark:hover:bg-zinc-800', className), children: value ? (_jsx(RichTextView, { value: value })) : (_jsx("span", { className: "text-zinc-400 dark:text-zinc-500", children: placeholder })) }));
|
|
60
|
+
}
|
|
61
|
+
return (_jsx(RichTextEditor, { value: value, label: label, className: className, onCancel: () => setEditing(false), onSave: (markdown) => {
|
|
62
|
+
setEditing(false);
|
|
63
|
+
// Only when it actually changed. A save on every blur turns "I clicked
|
|
64
|
+
// into this field and clicked out" into a write, an audit entry, and a
|
|
65
|
+
// publisher's overlay that now shadows the declared description with an
|
|
66
|
+
// identical string.
|
|
67
|
+
if (markdown !== value)
|
|
68
|
+
onSave(markdown);
|
|
69
|
+
} }));
|
|
70
|
+
}
|
|
71
|
+
/** Read-only, through the same editor, so one parser decides what the text means. */
|
|
72
|
+
export function RichTextView({ value, className }) {
|
|
73
|
+
const editor = useEditor({
|
|
74
|
+
extensions: EXTENSIONS,
|
|
75
|
+
content: value,
|
|
76
|
+
editable: false,
|
|
77
|
+
immediatelyRender: false,
|
|
78
|
+
editorProps: { attributes: { class: cn(PROSE, className) } },
|
|
79
|
+
}, [value]);
|
|
80
|
+
return _jsx(EditorContent, { editor: editor });
|
|
81
|
+
}
|
|
82
|
+
function RichTextEditor({ value, label, className, onSave, onCancel, }) {
|
|
83
|
+
const editor = useEditor({
|
|
84
|
+
extensions: EXTENSIONS,
|
|
85
|
+
content: value,
|
|
86
|
+
// `false` because this renders inside an already-mounted client tree; left
|
|
87
|
+
// on, TipTap renders once during the first paint and React reports a
|
|
88
|
+
// hydration mismatch on any host that server-renders the console shell.
|
|
89
|
+
immediatelyRender: false,
|
|
90
|
+
editorProps: {
|
|
91
|
+
attributes: {
|
|
92
|
+
'aria-label': label,
|
|
93
|
+
class: cn(PROSE, 'min-h-[3lh] rounded-sm border border-sky-500 px-1.5 py-0.5 outline-none', 'ring-2 ring-sky-500/20', className),
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
// Focus on open, so opening the editor and typing is one motion rather than
|
|
98
|
+
// two — the plain-text field it replaces did the same.
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
editor?.commands.focus('end');
|
|
101
|
+
}, [editor]);
|
|
102
|
+
if (!editor)
|
|
103
|
+
return null;
|
|
104
|
+
const markdown = () => editor.storage.markdown.getMarkdown();
|
|
105
|
+
return (_jsxs("div", { onKeyDown: (event) => {
|
|
106
|
+
// Escape abandons, Cmd/Ctrl+Enter commits. Plain Enter is a paragraph
|
|
107
|
+
// break here — this is a rich text field, and stealing Enter would make
|
|
108
|
+
// multi-paragraph descriptions impossible to write.
|
|
109
|
+
if (event.key === 'Escape')
|
|
110
|
+
onCancel();
|
|
111
|
+
if (event.key === 'Enter' && (event.metaKey || event.ctrlKey))
|
|
112
|
+
onSave(markdown());
|
|
113
|
+
}, children: [_jsx(Toolbar, { editor: editor }), _jsx(EditorContent, { editor: editor }), _jsxs("div", { className: "mt-1 flex items-center gap-1", children: [_jsxs(Button, { size: "sm", onClick: () => onSave(markdown()), "aria-label": `Save ${label}`, children: [_jsx(Check, { size: 12 }), " Save"] }), _jsx(Button, { size: "sm", variant: "ghost", onClick: onCancel, "aria-label": `Cancel editing ${label}`, children: _jsx(X, { size: 12 }) }), _jsx("span", { className: "ml-auto font-mono text-[10px] text-zinc-400 dark:text-zinc-500", children: "Stored as markdown" })] })] }));
|
|
114
|
+
}
|
|
115
|
+
/** Editor type is inferred; naming it would pin this file to a TipTap minor. */
|
|
116
|
+
function Toolbar({ editor }) {
|
|
117
|
+
const marks = [
|
|
118
|
+
{ name: 'bold', icon: Bold, run: () => editor.chain().focus().toggleBold().run() },
|
|
119
|
+
{ name: 'italic', icon: Italic, run: () => editor.chain().focus().toggleItalic().run() },
|
|
120
|
+
{ name: 'code', icon: Code, run: () => editor.chain().focus().toggleCode().run() },
|
|
121
|
+
{
|
|
122
|
+
name: 'bulletList',
|
|
123
|
+
icon: List,
|
|
124
|
+
run: () => editor.chain().focus().toggleBulletList().run(),
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'orderedList',
|
|
128
|
+
icon: ListOrdered,
|
|
129
|
+
run: () => editor.chain().focus().toggleOrderedList().run(),
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
return (_jsx("div", { className: "mb-1 flex items-center gap-0.5", children: marks.map(({ name, icon: Icon, run }) => (_jsx(Button, { size: "icon", variant: "ghost", onClick: run, "aria-label": name, "aria-pressed": editor.isActive(name), className: cn(editor.isActive(name) && 'bg-zinc-200 dark:bg-zinc-700'), children: _jsx(Icon, { size: 12 }) }, name))) }));
|
|
133
|
+
}
|
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.6.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",
|
|
@@ -63,7 +63,13 @@
|
|
|
63
63
|
"react": ">=18",
|
|
64
64
|
"react-dom": ">=18",
|
|
65
65
|
"recharts": ">=2.12.0",
|
|
66
|
-
"@dudousxd/nestjs-catalog": ">=0.1.0"
|
|
66
|
+
"@dudousxd/nestjs-catalog": ">=0.1.0",
|
|
67
|
+
"@tanstack/react-table": ">=9",
|
|
68
|
+
"@tiptap/react": ">=3",
|
|
69
|
+
"@tiptap/starter-kit": ">=3",
|
|
70
|
+
"@tiptap/pm": ">=3",
|
|
71
|
+
"tiptap-markdown": ">=0.9",
|
|
72
|
+
"@tiptap/core": ">=3"
|
|
67
73
|
},
|
|
68
74
|
"devDependencies": {
|
|
69
75
|
"@base-ui/react": "1.6.0",
|
|
@@ -94,7 +100,13 @@
|
|
|
94
100
|
"recharts": "2.15.4",
|
|
95
101
|
"tailwind-merge": "3.4.1",
|
|
96
102
|
"typescript": "5.9.3",
|
|
97
|
-
"@
|
|
103
|
+
"@tanstack/react-table": "9.0.0",
|
|
104
|
+
"@tiptap/react": "3.29.2",
|
|
105
|
+
"@tiptap/starter-kit": "3.29.2",
|
|
106
|
+
"@tiptap/pm": "3.29.2",
|
|
107
|
+
"tiptap-markdown": "0.9.0",
|
|
108
|
+
"@tiptap/core": "3.29.2",
|
|
109
|
+
"@dudousxd/nestjs-catalog": "0.4.0"
|
|
98
110
|
},
|
|
99
111
|
"dependencies": {
|
|
100
112
|
"clsx": "2.1.1",
|