@ex-grid/pivot 0.2.0-rc.1 → 0.2.0-rc.3
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/index.js +66 -16
- package/dist/index.js.map +2 -2
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3246,9 +3246,62 @@ function reportMatch(row, column, pattern) {
|
|
|
3246
3246
|
if (typeof value === "string") return findMatches2(value, pattern);
|
|
3247
3247
|
throw new TypeError(`Internal: the report column '${column.name}' holds neither a label nor a value.`);
|
|
3248
3248
|
}
|
|
3249
|
+
function reportRowKind(row) {
|
|
3250
|
+
switch (row.role) {
|
|
3251
|
+
case "item":
|
|
3252
|
+
case "pending":
|
|
3253
|
+
return "detail";
|
|
3254
|
+
case "group":
|
|
3255
|
+
return "group";
|
|
3256
|
+
case "subtotal":
|
|
3257
|
+
case "grandTotal":
|
|
3258
|
+
return "total";
|
|
3259
|
+
default:
|
|
3260
|
+
return unreachable(row.role);
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
var rowKeys = /* @__PURE__ */ new WeakMap();
|
|
3249
3264
|
function reportRowKey(row) {
|
|
3250
|
-
|
|
3265
|
+
const held2 = rowKeys.get(row);
|
|
3266
|
+
if (held2 !== void 0) return held2;
|
|
3267
|
+
const key = new PivotRowKey(row.role, row.valueField, row.items).toString();
|
|
3268
|
+
rowKeys.set(row, key);
|
|
3269
|
+
return key;
|
|
3251
3270
|
}
|
|
3271
|
+
var ReportToggles = class {
|
|
3272
|
+
#buttons = /* @__PURE__ */ new WeakMap();
|
|
3273
|
+
/** A button painted for `toggle` on `row`. */
|
|
3274
|
+
painted(button, toggle, row) {
|
|
3275
|
+
this.#buttons.set(button, { toggle, row });
|
|
3276
|
+
}
|
|
3277
|
+
/** A button taken away with its cell. */
|
|
3278
|
+
removed(button) {
|
|
3279
|
+
this.#buttons.delete(button);
|
|
3280
|
+
}
|
|
3281
|
+
/**
|
|
3282
|
+
* Listens on `root`, the report grid's own, until `signal`: a press on a button keeps the keyboard where it was,
|
|
3283
|
+
* as the grid's own buttons do; a click on one toggles its Item on its row; and a double click on one stops
|
|
3284
|
+
* there, since its offsets are the button's (ADR-0063). Taken in the capture phase, before the grid hears the
|
|
3285
|
+
* event, as a listener on the button was.
|
|
3286
|
+
*/
|
|
3287
|
+
listen(root, signal, toggled) {
|
|
3288
|
+
const pressed = (event) => {
|
|
3289
|
+
const { target } = event;
|
|
3290
|
+
const button = target instanceof Element ? target.closest(".ex-pivot-toggle") : null;
|
|
3291
|
+
return button === null ? void 0 : this.#buttons.get(button);
|
|
3292
|
+
};
|
|
3293
|
+
root.addEventListener("mousedown", (event) => {
|
|
3294
|
+
if (pressed(event) !== void 0) event.preventDefault();
|
|
3295
|
+
}, { capture: true, signal });
|
|
3296
|
+
root.addEventListener("click", (event) => {
|
|
3297
|
+
const on = pressed(event);
|
|
3298
|
+
if (on !== void 0) toggled(on.toggle, on.row);
|
|
3299
|
+
}, { capture: true, signal });
|
|
3300
|
+
root.addEventListener("dblclick", (event) => {
|
|
3301
|
+
if (pressed(event) !== void 0) event.stopPropagation();
|
|
3302
|
+
}, { capture: true, signal });
|
|
3303
|
+
}
|
|
3304
|
+
};
|
|
3252
3305
|
function labelTemplate(index, painter) {
|
|
3253
3306
|
return (slot, cell) => {
|
|
3254
3307
|
const label = elementAt(cell.row.labels, index);
|
|
@@ -3256,7 +3309,6 @@ function labelTemplate(index, painter) {
|
|
|
3256
3309
|
const box = document.createElement("span");
|
|
3257
3310
|
box.className = "ex-pivot-label";
|
|
3258
3311
|
if (label.indent > 0) box.style.paddingLeft = `${label.indent * painter.indentPx}px`;
|
|
3259
|
-
const listening = new AbortController();
|
|
3260
3312
|
const { toggle } = label;
|
|
3261
3313
|
let button;
|
|
3262
3314
|
if (toggle !== void 0) {
|
|
@@ -3268,16 +3320,7 @@ function labelTemplate(index, painter) {
|
|
|
3268
3320
|
made.setAttribute("aria-expanded", toggle.isCollapsed ? "false" : "true");
|
|
3269
3321
|
made.setAttribute("aria-label", painter.toggleName(toggle));
|
|
3270
3322
|
made.textContent = toggle.isCollapsed ? "+" : "\u2212";
|
|
3271
|
-
|
|
3272
|
-
made.addEventListener("mousedown", (event) => {
|
|
3273
|
-
event.preventDefault();
|
|
3274
|
-
}, { signal });
|
|
3275
|
-
made.addEventListener("click", () => {
|
|
3276
|
-
painter.toggled(toggle, cell.row);
|
|
3277
|
-
}, { signal });
|
|
3278
|
-
made.addEventListener("dblclick", (event) => {
|
|
3279
|
-
event.stopPropagation();
|
|
3280
|
-
}, { signal });
|
|
3323
|
+
painter.toggles.painted(made, toggle, cell.row);
|
|
3281
3324
|
box.append(made);
|
|
3282
3325
|
button = made;
|
|
3283
3326
|
}
|
|
@@ -3290,7 +3333,7 @@ function labelTemplate(index, painter) {
|
|
|
3290
3333
|
slot.append(box);
|
|
3291
3334
|
if (button !== void 0 && cell.focusRequest !== 0) cell.takeKeyboard(button);
|
|
3292
3335
|
return () => {
|
|
3293
|
-
|
|
3336
|
+
if (button !== void 0) painter.toggles.removed(button);
|
|
3294
3337
|
box.remove();
|
|
3295
3338
|
};
|
|
3296
3339
|
};
|
|
@@ -3876,6 +3919,8 @@ var PivotView = class {
|
|
|
3876
3919
|
#sheet;
|
|
3877
3920
|
#empty;
|
|
3878
3921
|
#gridRoot;
|
|
3922
|
+
// The expand / collapse buttons the label cells paint, heard on the grid's root (PF-2).
|
|
3923
|
+
#toggles = new ReportToggles();
|
|
3879
3924
|
#dropRemove;
|
|
3880
3925
|
#fieldListBox;
|
|
3881
3926
|
#fieldListScroll;
|
|
@@ -4157,6 +4202,9 @@ var PivotView = class {
|
|
|
4157
4202
|
};
|
|
4158
4203
|
this.#gridRoot.addEventListener("pointerdown", gestured, { capture: true, ...listening });
|
|
4159
4204
|
this.#gridRoot.addEventListener("wheel", gestured, { capture: true, passive: true, ...listening });
|
|
4205
|
+
this.#toggles.listen(this.#gridRoot, this.#listening.signal, (toggle, row) => {
|
|
4206
|
+
this.#toggled(toggle, row);
|
|
4207
|
+
});
|
|
4160
4208
|
this.#gridRoot.addEventListener("keydown", (event) => {
|
|
4161
4209
|
if (!event.isComposing && !inertKeys.has(event.key)) gestured();
|
|
4162
4210
|
}, { capture: true, ...listening });
|
|
@@ -4379,9 +4427,7 @@ var PivotView = class {
|
|
|
4379
4427
|
return new ReportColumns(Object.freeze({
|
|
4380
4428
|
indentPx: this.#indentPx,
|
|
4381
4429
|
toggleName: (toggle) => words.fill(toggle.isCollapsed ? "expand-item" : "collapse-item", toggle.itemLabel),
|
|
4382
|
-
|
|
4383
|
-
this.#toggled(toggle, row);
|
|
4384
|
-
}
|
|
4430
|
+
toggles: this.#toggles
|
|
4385
4431
|
}), textOf(options));
|
|
4386
4432
|
}
|
|
4387
4433
|
#localeOf(options) {
|
|
@@ -4872,6 +4918,10 @@ var PivotView = class {
|
|
|
4872
4918
|
// Item order and Hidden Items are the Pivot Layout's, and a report is computed: no column menu, no
|
|
4873
4919
|
// sort, no filter, and every write refused by the grid's own gate, since nobody hears one (ADR-0059).
|
|
4874
4920
|
hideColumnMenu: true,
|
|
4921
|
+
// A press on a header selects its column, as on Excel's PivotTable (PV-2).
|
|
4922
|
+
headerClickSelects: true,
|
|
4923
|
+
// Group rows and totals are set apart as Excel sets them (ADR-0024, PV-2).
|
|
4924
|
+
rowKind: reportRowKind,
|
|
4875
4925
|
onColumnWidthChanged: (change) => {
|
|
4876
4926
|
this.#widthChanged(change);
|
|
4877
4927
|
},
|