@columenlabs/lumen-ui 0.1.21 → 0.1.23
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/lumen-layout.js +12 -4
- package/dist/summary-cards.js +1 -1
- package/dist/view-editor.js +11 -0
- package/package.json +2 -2
package/dist/lumen-layout.js
CHANGED
|
@@ -275,6 +275,10 @@ function ViewLayout({ crumbs, actions, meta, status, intro, cards: extra, lead,
|
|
|
275
275
|
// saves at once.
|
|
276
276
|
const [layout, setLayout] = useState(false);
|
|
277
277
|
const [draft, setDraft] = useState([]);
|
|
278
|
+
// What Edit widget changes on the view itself (formulas, links, frames) while the layout is
|
|
279
|
+
// edited: held with the draft and saved with it, never on its own. A save mid-edit made pages
|
|
280
|
+
// that key on the view's save time remount, which dropped the draft and its new widget.
|
|
281
|
+
const [draftView, setDraftView] = useState({});
|
|
278
282
|
const [adding, setAdding] = useState(false);
|
|
279
283
|
// Any card but the view's own table, edited in the same editor.
|
|
280
284
|
const [editingWidget, setEditingWidget] = useState(null);
|
|
@@ -595,6 +599,7 @@ function ViewLayout({ crumbs, actions, meta, status, intro, cards: extra, lead,
|
|
|
595
599
|
const body = (_jsxs(_Fragment, { children: [intro && (_jsx("div", { "data-slot": "page-intro", className: INTRO, children: intro })), _jsx(LumenGrid, { lead: codeSlots(lead, scope), cards: gridCards, tail: codeSlots(extra?.filter((c) => !c.frame), scope), editing: layout, onPlace: (places, phone) => setDraft((d) => placeCards(d, places, phone)) }), layout && (_jsx(IconButton, { icon: PlusIcon, label: "Add widget", variant: "outline", size: "icon", className: "sticky left-0 h-16 w-(--view-w) border-2 border-dashed text-muted-foreground", onClick: () => setAdding(true) }))] }));
|
|
596
600
|
return (_jsxs(Page, { className: VIEW_PAGE, crumbs: crumbs, meta: layout ? _jsx(LayoutChip, {}) : meta, status: _jsxs(_Fragment, { children: [status, _jsx(OriginLegend, { domain: domain, columns: columns }), _jsx(SourceStatusItems, { sources: joins.sources, actions: joins.actions })] }), actions: actions, layout: layout ? (_jsx(LayoutActions, { onCancel: () => {
|
|
597
601
|
setDraft(saved);
|
|
602
|
+
setDraftView({});
|
|
598
603
|
setLayout(false);
|
|
599
604
|
}, onAdd: () => setAdding(true), onReset: onConfigChange &&
|
|
600
605
|
onReset &&
|
|
@@ -603,10 +608,13 @@ function ViewLayout({ crumbs, actions, meta, status, intro, cards: extra, lead,
|
|
|
603
608
|
onReset();
|
|
604
609
|
}), onSave: () => {
|
|
605
610
|
setLayout(false);
|
|
606
|
-
|
|
607
|
-
|
|
611
|
+
setDraftView({});
|
|
612
|
+
if (JSON.stringify(draft) !== JSON.stringify(saved) ||
|
|
613
|
+
Object.keys(draftView).length > 0)
|
|
614
|
+
onConfigChange?.({ ...config, ...draftView, cards: draft });
|
|
608
615
|
} })) : (onConfigChange && (_jsxs(_Fragment, { children: [changed && saveMode === 'document' && (_jsxs(_Fragment, { children: [_jsx(IconButton, { icon: Undo2Icon, label: "Revert view", onClick: revert }), _jsx(IconButton, { icon: SaveIcon, label: "Save view (chips, sort, group)", variant: "default", onClick: () => onConfigChange?.(heldConfig) })] })), _jsx(IconButton, { icon: LayoutDashboardIcon, label: "Edit layout", onClick: () => {
|
|
609
616
|
setDraft(saved);
|
|
617
|
+
setDraftView({});
|
|
610
618
|
setLayout(true);
|
|
611
619
|
} })] }))), children: [_jsx(LinksProvider, { links: links, children: _jsx(Scroller, { fit: fit, children: body }) }), _jsx(LumenDrawer, { open: open !== null, title: openTitle, onClose: () => setDetails(null), children: open !== null && (_jsx(DetailsBody, { domain: domain, row: open, columns: columns, chips: config.chips ?? [] })) }), onConfigChange && (_jsxs(_Fragment, { children: [_jsx(AddWidgetDialog, { open: adding, onOpenChange: setAdding, domain: domain, cards: cards, name: config.name, onAdd: (c) => {
|
|
612
620
|
setAdding(false);
|
|
@@ -618,13 +626,13 @@ function ViewLayout({ crumbs, actions, meta, status, intro, cards: extra, lead,
|
|
|
618
626
|
setAdding(false);
|
|
619
627
|
if (c.kind !== 'page')
|
|
620
628
|
setEditingWidget(c);
|
|
621
|
-
} }), editingWidget && (_jsx(ViewEditDialog, { open: true, onOpenChange: (o) => !o && setEditingWidget(null), domain: joins.domain, config: config, rows: rows, current: [], card: editingWidget, fields: widgetFields, viewTiles: config.tiles, read: joins.read, onSaveCard: (c, view) => {
|
|
629
|
+
} }), editingWidget && (_jsx(ViewEditDialog, { open: true, onOpenChange: (o) => !o && setEditingWidget(null), domain: joins.domain, config: layout ? { ...config, ...draftView } : config, rows: rows, current: [], card: editingWidget, fields: widgetFields, viewTiles: config.tiles, read: joins.read, onSaveCard: (c, view) => {
|
|
622
630
|
setEditingWidget(null);
|
|
623
631
|
const i = cards.findIndex((x) => x.id === c.id);
|
|
624
632
|
const next = i < 0 ? [...cards, c] : cards.map((x, j) => (j === i ? c : x));
|
|
625
633
|
if (layout) {
|
|
626
634
|
setDraft(next);
|
|
627
|
-
|
|
635
|
+
setDraftView((d) => ({ ...d, ...view }));
|
|
628
636
|
}
|
|
629
637
|
else
|
|
630
638
|
onConfigChange({ ...config, ...view, cards: next });
|
package/dist/summary-cards.js
CHANGED
|
@@ -246,7 +246,7 @@ export function SummaryCardsEditor({ domain, tiles, onChange, rows, fields, prob
|
|
|
246
246
|
? t.label
|
|
247
247
|
: (builtIns.find((w) => w.key === t.key)?.label ?? t.key);
|
|
248
248
|
return (_jsx(CardChip, { id: t.key, selected: current === t.key, onSelect: () => setCurrent(t.key), label: label, value: p.value, how: p.how, problem: !!problems[j], domId: `summary-card-${j}` }, t.key));
|
|
249
|
-
}), takesFormulas(domain) && !(one && tiles.length) && (_jsxs(Button, { variant: "outline", className: "h-auto min-h-16 border-dashed font-normal text-muted-foreground", disabled: ownCount >= MAX_TILES, onClick: add, children: [_jsx(PlusIcon, {}), " Add card"] }))] }) }) }), off.length > 0 && (_jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [_jsx("span", { className: "text-xs text-muted-foreground", children: "Built in:" }), off.map((w) => (_jsxs(Button, { variant: "outline", size: "sm", onClick: () => {
|
|
249
|
+
}), takesFormulas(domain) && !(one && tiles.length) && (_jsxs(Button, { id: "summary-card-add", variant: "outline", className: "h-auto min-h-16 border-dashed font-normal text-muted-foreground", disabled: ownCount >= MAX_TILES, onClick: add, children: [_jsx(PlusIcon, {}), " Add card"] }))] }) }) }), off.length > 0 && (_jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [_jsx("span", { className: "text-xs text-muted-foreground", children: "Built in:" }), off.map((w) => (_jsxs(Button, { variant: "outline", size: "sm", onClick: () => {
|
|
250
250
|
onChange(one ? [{ key: w.key }] : [...tiles, { key: w.key }]);
|
|
251
251
|
setCurrent(w.key);
|
|
252
252
|
}, children: [_jsx(PlusIcon, {}), " ", w.label] }, w.key)))] })), picked && !own && (_jsxs("div", { className: "flex items-center gap-2 rounded-lg border p-3", children: [_jsx(Badge, { variant: "secondary", className: "font-normal", children: "Built in" }), _jsxs("span", { className: "flex-1 text-sm", children: [builtIns.find((w) => w.key === picked.key)?.label ?? picked.key, " works out its own lines."] }), _jsx(IconButton, { icon: Trash2Icon, label: "Remove card", onClick: () => {
|
package/dist/view-editor.js
CHANGED
|
@@ -538,6 +538,17 @@ export function ViewEditDialog({ open, onOpenChange, domain: pageDomain, config,
|
|
|
538
538
|
},
|
|
539
539
|
];
|
|
540
540
|
}),
|
|
541
|
+
// A row of numbers with no card draws nothing (with its header off, not even a frame).
|
|
542
|
+
...(widget && isRowCard(widget) && !(widget.tiles ?? viewTiles ?? []).length
|
|
543
|
+
? [
|
|
544
|
+
{
|
|
545
|
+
where: 'Cards',
|
|
546
|
+
message: 'Add at least one card',
|
|
547
|
+
target: 'summary-card-add',
|
|
548
|
+
reveal: () => open_('settings'),
|
|
549
|
+
},
|
|
550
|
+
]
|
|
551
|
+
: []),
|
|
541
552
|
...cardProblems.flatMap((message, j) => message
|
|
542
553
|
? [
|
|
543
554
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@columenlabs/lumen-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
4
4
|
"description": "Lumen: shared React components (frame, views, widgets, charts, drawers).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@codemirror/lang-javascript": "6.2.5",
|
|
42
42
|
"@codemirror/lang-json": "6.0.2",
|
|
43
43
|
"@codemirror/lang-sql": "6.10.0",
|
|
44
|
-
"@columenlabs/lumen-ui-types": "0.1.
|
|
44
|
+
"@columenlabs/lumen-ui-types": "0.1.23",
|
|
45
45
|
"@dnd-kit/core": "6.3.1",
|
|
46
46
|
"@dnd-kit/sortable": "10.0.0",
|
|
47
47
|
"@dnd-kit/utilities": "3.2.2",
|