@grafloria/element 0.4.53 → 0.4.54
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/package.json
CHANGED
|
@@ -411,9 +411,17 @@ export interface DashboardHandle {
|
|
|
411
411
|
/**
|
|
412
412
|
* Add a widget to a view. CREATES the node (you do not pre-build one), wires
|
|
413
413
|
* its metadata, and commits node + membership as ONE undoable step.
|
|
414
|
-
* Auto-positions when the spec names no cell.
|
|
415
|
-
|
|
416
|
-
|
|
414
|
+
* Auto-positions when the spec names no cell. `opts.displaced`: the
|
|
415
|
+
* commands a palette drop handed `onDropIn` for the tiles the placeholder
|
|
416
|
+
* pushed aside — folded into the same step, so the widget lands on the cell
|
|
417
|
+
* the drop showed and undo puts the pushed tiles back with it. Left out,
|
|
418
|
+
* the board is re-read from the model and the push is forgotten: the new
|
|
419
|
+
* widget then auto-positions into whatever hole is left (Quantia's "lands
|
|
420
|
+
* on the cell it was aimed at", element 0.4.54).
|
|
421
|
+
*/
|
|
422
|
+
addWidget(spec: DashboardWidgetSpec, viewId?: string, opts?: {
|
|
423
|
+
displaced?: Command[];
|
|
424
|
+
}): WidgetHandle | undefined;
|
|
417
425
|
/**
|
|
418
426
|
* Re-read every board from the model — call after undo/redo, or any
|
|
419
427
|
* out-of-band mutation, so the grid and the projection agree again.
|
|
@@ -1575,8 +1575,8 @@ export function createDashboardHandle(ctx) {
|
|
|
1575
1575
|
(_a = ctx.apiRef) === null || _a === void 0 ? void 0 : _a.renderNow();
|
|
1576
1576
|
},
|
|
1577
1577
|
getDragHandle: () => { var _a, _b, _c; return (_b = (_a = binders.get(ctx.active)) === null || _a === void 0 ? void 0 : _a.getDragHandle()) !== null && _b !== void 0 ? _b : ((_c = ctx.optionsBase.dragHandle) !== null && _c !== void 0 ? _c : false); },
|
|
1578
|
-
addWidget(spec, viewId) {
|
|
1579
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1578
|
+
addWidget(spec, viewId, opts) {
|
|
1579
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1580
1580
|
const vid = viewId !== null && viewId !== void 0 ? viewId : ctx.active;
|
|
1581
1581
|
// `vid` may name a view OR a container — both are boards with a group,
|
|
1582
1582
|
// a binder and an authored array.
|
|
@@ -1601,10 +1601,15 @@ export function createDashboardHandle(ctx) {
|
|
|
1601
1601
|
const node = existing !== null && existing !== void 0 ? existing : buildWidgetNode(w, ctx.rowHeight);
|
|
1602
1602
|
if (w.pinned)
|
|
1603
1603
|
node.setState({ locked: true });
|
|
1604
|
-
// ONE undoable step, registration included (see AddWidgetCommand).
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1604
|
+
// ONE undoable step, registration included (see AddWidgetCommand). The
|
|
1605
|
+
// tiles a drop pushed aside ride in front of it, in a SEQUENCE: a batch
|
|
1606
|
+
// runs its members across awaits, and the board is re-read right after
|
|
1607
|
+
// this call — the pushed cells must be in the model by then.
|
|
1608
|
+
const add = new AddWidgetCommand(node, group.id, registry, !!existing);
|
|
1609
|
+
const displaced = (_e = opts === null || opts === void 0 ? void 0 : opts.displaced) !== null && _e !== void 0 ? _e : [];
|
|
1610
|
+
execCommand(displaced.length > 0 ? new SequenceCommand('Add widget', [...displaced, add]) : add);
|
|
1611
|
+
(_f = binders.get(vid)) === null || _f === void 0 ? void 0 : _f.sync();
|
|
1612
|
+
(_g = ctx.apiRef) === null || _g === void 0 ? void 0 : _g.renderNow();
|
|
1608
1613
|
return makeWidgetHandle(w.id);
|
|
1609
1614
|
},
|
|
1610
1615
|
refresh() {
|
|
@@ -947,23 +947,38 @@ export function bindDashboardGrid(api, group, options = {}) {
|
|
|
947
947
|
*/
|
|
948
948
|
let pendingDrop = null;
|
|
949
949
|
const onMemberAdded = (id) => {
|
|
950
|
-
var _a, _b;
|
|
950
|
+
var _a, _b, _c;
|
|
951
951
|
if (disposed)
|
|
952
952
|
return;
|
|
953
|
-
|
|
954
|
-
|
|
953
|
+
// The cell a waiting tile held for an arriving member of ANOTHER id. The
|
|
954
|
+
// removal settles the board — the tiles the drop pushed float back into
|
|
955
|
+
// the hole — so the member cannot simply be added there: it collided and
|
|
956
|
+
// auto-positioned to the left edge (Quantia's "lands on the cell it was
|
|
957
|
+
// aimed at"). It enters at the bottom edge instead and takes the cell
|
|
958
|
+
// gatelessly, pushing them down again, all inside this one call.
|
|
959
|
+
let claim = null;
|
|
960
|
+
if (pendingDrop && pendingDrop !== id) {
|
|
961
|
+
const ph = engine.getItem(pendingDrop);
|
|
962
|
+
if (ph && !((_a = group.members) !== null && _a !== void 0 ? _a : new Set()).has(pendingDrop)) {
|
|
963
|
+
claim = { x: ph.x, y: ph.y };
|
|
964
|
+
engine.remove(pendingDrop);
|
|
965
|
+
}
|
|
955
966
|
}
|
|
956
967
|
pendingDrop = null;
|
|
957
968
|
if (!engine.getItem(id)) {
|
|
958
969
|
const item = itemFor(id);
|
|
959
|
-
let placed = engine.add(item);
|
|
970
|
+
let placed = claim ? engine.add(Object.assign(Object.assign({}, item), { x: 0, y: engine.rows(), autoPosition: false })) : engine.add(item);
|
|
971
|
+
if (placed && claim) {
|
|
972
|
+
engine.moveCheck(id, claim.x, claim.y, { gate: false, pushSolid: !!placed.solid });
|
|
973
|
+
placed = (_b = engine.getItem(id)) !== null && _b !== void 0 ? _b : placed;
|
|
974
|
+
}
|
|
960
975
|
if (!placed && capacity !== undefined) {
|
|
961
976
|
// Membership is a document fact (an undo just restored it, say); a
|
|
962
977
|
// bounded board must not strand the node invisible. Lift the capacity
|
|
963
978
|
// for this adoption — it floors at the content on the next refresh.
|
|
964
979
|
capacity = undefined;
|
|
965
980
|
engine = engineFrom([...engine.getItems().map((i) => (Object.assign({}, i))), item]);
|
|
966
|
-
placed = (
|
|
981
|
+
placed = (_c = engine.getItem(id)) !== null && _c !== void 0 ? _c : null;
|
|
967
982
|
refreshCapacity();
|
|
968
983
|
}
|
|
969
984
|
if (placed)
|