diff --git a/README.md b/README.md index 7cdfac12..574c9c24 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ release notes before you move the pin. ```json "dependencies": { - "data-explorer-view": "github:mathworks/data-explorer-view#v1.9.0", + "data-explorer-view": "github:mathworks/data-explorer-view#v1.10.0", "data-explorer-core": "github:mathworks/data-explorer-core#v1.59.0", "lit": "^3.2.0" } diff --git a/custom-elements.json b/custom-elements.json index 3c4f3bd7..fac12ebe 100644 --- a/custom-elements.json +++ b/custom-elements.json @@ -8139,7 +8139,7 @@ "declarations": [ { "kind": "class", - "description": "The tree table: a document's rows as a tree, with a search bar, sortable, resizable and\nreorderable columns (the Columns menu shows, hides and orders them, each within its group, and\nadds a column for any property the user names, from the rows' `_props`; a right-click on a\nheader filters on that column), cell editors, row drag and drop, links, matrix glyphs, an\n`+ Add` gallery and virtual scrolling for very large documents. Data comes in by properties\n(`rows` above all) and every user action goes out as a `dex-*` event; it never changes the\ndocument itself. Its defaults are a full editor; `readonly`, `canAdd` and `rowDrag` turn parts\nof that off.", + "description": "The tree table: a document's rows as a tree, with a search bar, sortable, resizable and\nreorderable columns (the Columns menu shows, hides and orders them, each within its group, by\ndrag or Alt+↑/↓, folds each group and shows or hides it whole, and adds a column for any\nproperty the user names, from the rows' `_props`; a right-click on a header filters on that\ncolumn), cell editors, row drag and drop, links, matrix glyphs, an\n`+ Add` gallery and virtual scrolling for very large documents. Data comes in by properties\n(`rows` above all) and every user action goes out as a `dex-*` event; it never changes the\ndocument itself. Its defaults are a full editor; `readonly`, `canAdd` and `rowDrag` turn parts\nof that off.", "name": "DexTreeTable", "members": [ { @@ -8187,7 +8187,7 @@ "text": "Record | null" }, "default": "null", - "description": "The group heading each column sits under in the Columns menu, by column key. The columns are\nshown group by group, and the user moves a column within its group only, in the menu and by\nits header. Default null: no headings. Property only." + "description": "The group heading each column sits under in the Columns menu, by column key. The columns are\nshown group by group, and the user moves a column within its group only, in the menu (by drag\nor Alt+↑/↓) and by its header. Each heading folds its group, opening expanded when the group\nshows a column, and its box shows or hides the group's columns at once. Default null: no\nheadings. Property only." }, { "kind": "field", diff --git a/dist/model/rows/propertyCells.js b/dist/model/rows/propertyCells.js index ef204b88..5961482c 100644 --- a/dist/model/rows/propertyCells.js +++ b/dist/model/rows/propertyCells.js @@ -13,7 +13,10 @@ // derived from one), each top-level property by its name, where the value is one a property // column shows: text, a number, a logical, a list of those, or a typed scalar (MATLAB's rule // for these columns). Not a nested object (`CoderInfo`, `LoggingInfo`), whose own properties -// are not columns, nor a `*_internal` or envelope key. +// are not columns, nor a `*_internal` or envelope key; +// - and, for a name the bag has no top-level property of, the attribute of that name of the +// object's storage class (`CoderInfo.CustomAttributes.GetFunction` as `GetFunction`), as the +// in-MATLAB data explorer reads a custom column (its design's G8). // // A property the row already has a cell for (Value, Description, `complexity` for `Complexity`) // is left out: the menu shows that column for its name instead, so its text here would be a @@ -62,9 +65,47 @@ export function propertyCells(n, row) { if (text !== null) put(name, text); } + // Then its storage class's attributes, each by its short name, for a name the object has no + // top-level property of: a top-level property of the name wins whatever its value, an object + // one included, and a built-in column's name never reads one (MATLAB's G8). + const attributes = customAttributes(bag); + if (attributes) { + for (const name of Object.keys(attributes)) { + if (!PROPERTY_NAME.test(name) || name.endsWith('_internal') || name in bag || BUILT_IN_DATA.has(name)) + continue; + const text = primitiveText(attributes[name]); + if (text !== null) + put(name, text); + } + } } return props; } +// The built-in data columns, by the property each shows, which never read a storage class +// attribute of the same name, even on an object that lacks the property: MATLAB's list +// (COLUMN_CUSTOMIZATION_DESIGN.md 11.7), with this table's own code-generation columns. +const BUILT_IN_DATA = new Set([ + 'Value', 'DataType', 'Description', 'Dimensions', 'DimensionsMode', 'Complexity', 'Min', 'Max', 'Unit', + 'StorageClass', 'HeaderFile', 'Alignment', 'DefinitionFile', 'PreStatement', 'PostStatement', 'Qualifier', +]); +// The attributes of the object's storage class, `CoderInfo.CustomAttributes`, or null. +function customAttributes(bag) { + const coderInfo = objectProperties(bag.CoderInfo); + return coderInfo ? objectProperties(coderInfo.CustomAttributes) : null; +} +// A nested object's own properties, or null. A text dictionary keeps them as the object's +// `_properties`; a binary one keeps the object as a 1x1 object array, whose one element has them. +function objectProperties(v) { + if (!isPlainObject(v)) + return null; + if (isPlainObject(v._properties)) + return v._properties; + const elements = v._elements; + if (Array.isArray(elements) && elements.length === 1 && isPlainObject(elements[0]) && isPlainObject(elements[0]._properties)) { + return elements[0]._properties; + } + return null; +} // A MATLAB property name: a letter, then letters, digits and underscores. const PROPERTY_NAME = /^[A-Za-z][A-Za-z0-9_]*$/; // Whether the row has a cell for `name`: under its own key, or under the lower-camel key a schema diff --git a/dist/model/version.js b/dist/model/version.js index cd90b835..e17d631e 100644 --- a/dist/model/version.js +++ b/dist/model/version.js @@ -1,4 +1,4 @@ // Copyright 2026 The MathWorks, Inc. // GENERATED by scripts/gen-version.mjs from package.json. Do not edit. /** This package's version, as its package.json says: what an app's About shows for data-explorer-view. */ -export const VIEW_VERSION = '1.9.0'; +export const VIEW_VERSION = '1.10.0'; diff --git a/dist/widgets/tree-table/dex-tree-table.d.ts b/dist/widgets/tree-table/dex-tree-table.d.ts index 55f1fcc7..096e2d36 100644 --- a/dist/widgets/tree-table/dex-tree-table.d.ts +++ b/dist/widgets/tree-table/dex-tree-table.d.ts @@ -112,9 +112,10 @@ export interface TableScrolledDetail { } /** * The tree table: a document's rows as a tree, with a search bar, sortable, resizable and - * reorderable columns (the Columns menu shows, hides and orders them, each within its group, and - * adds a column for any property the user names, from the rows' `_props`; a right-click on a - * header filters on that column), cell editors, row drag and drop, links, matrix glyphs, an + * reorderable columns (the Columns menu shows, hides and orders them, each within its group, by + * drag or Alt+↑/↓, folds each group and shows or hides it whole, and adds a column for any + * property the user names, from the rows' `_props`; a right-click on a header filters on that + * column), cell editors, row drag and drop, links, matrix glyphs, an * `+ Add` gallery and virtual scrolling for very large documents. Data comes in by properties * (`rows` above all) and every user action goes out as a `dex-*` event; it never changes the * document itself. Its defaults are a full editor; `readonly`, `canAdd` and `rowDrag` turn parts @@ -150,8 +151,10 @@ export declare class DexTreeTable extends LitElement { columnLabels: Record | null; /** * The group heading each column sits under in the Columns menu, by column key. The columns are - * shown group by group, and the user moves a column within its group only, in the menu and by - * its header. Default null: no headings. Property only. + * shown group by group, and the user moves a column within its group only, in the menu (by drag + * or Alt+↑/↓) and by its header. Each heading folds its group, opening expanded when the group + * shows a column, and its box shows or hides the group's columns at once. Default null: no + * headings. Property only. */ columnGroups: Record | null; /** @@ -367,6 +370,7 @@ export declare class DexTreeTable extends LitElement { private _columnMenuX; private _columnMenuY; private _columnMenuMaxHeight; + private _columnMenuAnnouncement; private _menuDragCol; private _menuDragOverCol; private _menuDragOverSide; @@ -443,6 +447,17 @@ export declare class DexTreeTable extends LitElement { */ beginRename(rowId: string): boolean; private _onColumnsButtonClick; + private _focusColumnMenu; + private _columnMenuRuns; + private _columnMenuGroups; + private _groupStateKey; + private _isGroupExpanded; + private _keepGroupsExpanded; + private _toggleGroupFold; + private _checkGroup; + private _onMenuItemKeyDown; + private _menuRunOf; + private _onColumnMenuKeyDown; private _openColumnFilter; private _onHeaderContextMenu; private _onFunnelClick; @@ -634,6 +649,7 @@ export declare class DexTreeTable extends LitElement { private _renderColumnsButton; private _renderColumnFilterPopup; private _renderColumnMenu; + private _renderColumnMenuGroupHeader; private _renderColumnMenuItem; } /** diff --git a/dist/widgets/tree-table/dex-tree-table.js b/dist/widgets/tree-table/dex-tree-table.js index 2e6e65a2..235dcbaf 100644 --- a/dist/widgets/tree-table/dex-tree-table.js +++ b/dist/widgets/tree-table/dex-tree-table.js @@ -10,6 +10,7 @@ import { property, state, query } from 'lit/decorators.js'; import { defineElement } from '../shared/define.js'; import { hiddenStyles } from '../shared/hidden.styles.js'; import { highContrastStyles } from '../shared/high-contrast.styles.js'; +import { live } from 'lit/directives/live.js'; import { styleProps } from '../shared/styleProps.js'; import { dragModeFromModifiers } from '../shared/dragMode.js'; import { hasLineBreak, withHeldLineBreaks } from '../shared/lineBreaks.js'; @@ -148,9 +149,19 @@ const PROPERTY_GROUP_LABEL = 'Other Properties'; // A name a property column may have: a MATLAB property name (isvarname: a letter, then letters, // digits and underscores, 63 at most). const PROPERTY_NAME = /^[A-Za-z][A-Za-z0-9_]{0,62}$/; +// A typed property name may name a storage class attribute by its path: one leading +// `CoderInfo.CustomAttributes.` is taken off, as the in-MATLAB data explorer takes it off, and +// the column is the attribute's short name (the model's propertyCells reads it so). +const ATTRIBUTE_PATH_PREFIX = 'CoderInfo.CustomAttributes.'; // The Columns menu's least height, and the gap it keeps above the table's bottom edge. const COLUMN_MENU_MIN_HEIGHT = 120; const COLUMN_MENU_BOTTOM_MARGIN = 4; +// Whether each group of the Columns menu is expanded, by the table's storageKey and the group's +// key. The window's, as the in-MATLAB data explorer keeps it: every table of one storageKey +// shares it, and it is never saved. A group not in it is expanded when it shows a column; opening +// the menu writes that down for each group with columns, so a group does not fold away while +// its columns are being unchecked. +const columnGroupExpanded = new Map(); function isPropertyColumn(col) { return col.startsWith(PROPERTY_COLUMN_PREFIX); } @@ -269,9 +280,10 @@ const OP_WORD_TEXT = { }; /** * The tree table: a document's rows as a tree, with a search bar, sortable, resizable and - * reorderable columns (the Columns menu shows, hides and orders them, each within its group, and - * adds a column for any property the user names, from the rows' `_props`; a right-click on a - * header filters on that column), cell editors, row drag and drop, links, matrix glyphs, an + * reorderable columns (the Columns menu shows, hides and orders them, each within its group, by + * drag or Alt+↑/↓, folds each group and shows or hides it whole, and adds a column for any + * property the user names, from the rows' `_props`; a right-click on a header filters on that + * column), cell editors, row drag and drop, links, matrix glyphs, an * `+ Add` gallery and virtual scrolling for very large documents. Data comes in by properties * (`rows` above all) and every user action goes out as a `dex-*` event; it never changes the * document itself. Its defaults are a full editor; `readonly`, `canAdd` and `rowDrag` turn parts @@ -308,8 +320,10 @@ export class DexTreeTable extends LitElement { this.columnLabels = null; /** * The group heading each column sits under in the Columns menu, by column key. The columns are - * shown group by group, and the user moves a column within its group only, in the menu and by - * its header. Default null: no headings. Property only. + * shown group by group, and the user moves a column within its group only, in the menu (by drag + * or Alt+↑/↓) and by its header. Each heading folds its group, opening expanded when the group + * shows a column, and its box shows or hides the group's columns at once. Default null: no + * headings. Property only. */ this.columnGroups = null; /** @@ -513,6 +527,8 @@ export class DexTreeTable extends LitElement { this._columnMenuX = 0; this._columnMenuY = 0; this._columnMenuMaxHeight = 0; + // What the menu's live region last said: a column's new place after a move from the keyboard. + this._columnMenuAnnouncement = ''; this._menuDragCol = null; this._menuDragOverCol = null; this._menuDragOverSide = null; @@ -1234,15 +1250,82 @@ export class DexTreeTable extends LitElement { text-overflow: ellipsis; } + /* A group's header lines up with its rows: the toggle in the grips' column, the group's box + in the boxes' column, then its name and, on the right, its count. Its rows are indented + by a box and a gap, so a row's box sits under the group's name. */ .column-menu-group-header { + display: flex; + align-items: center; + gap: 8px; padding: 6px 12px 2px 6px; + user-select: none; + cursor: default; + } + + .column-menu-toggle { + flex: 0 0 auto; + width: 12px; + padding: 0; + border: none; + background: none; + color: var(--dex-color-text-muted, #666); + font: inherit; + line-height: 1; + cursor: pointer; + } + + .column-menu-toggle:hover, + .column-menu-toggle:focus-visible { + color: var(--dex-color-text, #333); + } + + .column-menu-toggle:focus-visible { + outline: 1px solid var(--dex-color-accent, #0078d4); + } + + /* A group with no column has nothing to fold. */ + .column-menu-toggle:disabled { + visibility: hidden; + } + + .column-menu-group-check { + margin: 0; + } + + .column-menu-group-label { + flex: 1 1 auto; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; font-size: 11px; font-weight: 600; color: var(--dex-color-text-muted, #666); text-transform: uppercase; letter-spacing: 0.04em; - user-select: none; - cursor: default; + cursor: pointer; + } + + .column-menu-group-count { + flex: 0 0 auto; + font-size: 11px; + color: var(--dex-color-text-muted, #666); + white-space: nowrap; + } + + .column-menu-group-rows .column-menu-item, + .column-menu-customs .column-menu-item { + padding-left: 27px; + } + + /* Read by a screen reader, not shown. */ + .column-menu-live { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip: rect(0 0 0 0); + white-space: nowrap; } @@ -2758,7 +2841,129 @@ export class DexTreeTable extends LitElement { const bottom = hostBottom > this._columnMenuY ? Math.min(hostBottom, window.innerHeight || hostBottom) : window.innerHeight; this._columnMenuMaxHeight = Math.max(COLUMN_MENU_MIN_HEIGHT, bottom - this._columnMenuY - COLUMN_MENU_BOTTOM_MARGIN); this._propertyNotice = ''; + this._columnMenuAnnouncement = ''; + this._keepGroupsExpanded(); this._columnMenuOpen = true; + void this._focusColumnMenu(); + } + // The focus into the menu just opened: the first column box of an expanded part that takes it + // (Name's does not), else the first group toggle that does, else the property name's field. + async _focusColumnMenu() { + await this.updateComplete; + const menu = this.shadowRoot?.querySelector('.column-menu'); + if (!menu) + return; + const boxes = Array.from(menu.querySelectorAll('.column-menu-item input[type=checkbox]')); + const toggles = Array.from(menu.querySelectorAll('.column-menu-toggle')); + const target = boxes.find((b) => !b.disabled && !b.closest('[hidden]')) ?? + toggles.find((t) => !t.disabled) ?? + menu.querySelector('.column-menu-input'); + target?.focus(); + } + // --- Groups of the Columns menu --- + // The menu's built-in columns as runs of one group each, in display order: a run of columns + // with no host group has no header (key null), as the table's leading columns. + _columnMenuRuns() { + const runs = []; + for (const col of this._orderedBuiltins) { + const key = this._groupOf(col); + const last = runs[runs.length - 1]; + if (last && last.key === key) + last.cols.push(col); + else + runs.push({ key, cols: [col] }); + } + return runs; + } + // Every group of the menu with a header, Other Properties last. + _columnMenuGroups() { + const groups = []; + for (const run of this._columnMenuRuns()) + if (run.key !== null) + groups.push({ key: run.key, label: run.key, cols: run.cols }); + groups.push({ key: PROPERTY_GROUP, label: PROPERTY_GROUP_LABEL, cols: this._propertyColumns.map(propertyColumnKey) }); + return groups; + } + _groupStateKey(key) { + return `${this.storageKey ?? ''}\u0000${key}`; + } + _isGroupExpanded(group) { + const kept = columnGroupExpanded.get(this._groupStateKey(group.key)); + return kept ?? group.cols.some((c) => !this._hiddenColumns.has(c)); + } + // The menu is opening: each group with columns that the window has no state for yet keeps the + // state it opens in. One with none is left out, so a property column added to it shows. + _keepGroupsExpanded() { + for (const group of this._columnMenuGroups()) { + const key = this._groupStateKey(group.key); + if (group.cols.length > 0 && !columnGroupExpanded.has(key)) + columnGroupExpanded.set(key, this._isGroupExpanded(group)); + } + } + // Fold or unfold a group by its toggle or its name. A focus left inside the rows being folded + // goes to the toggle, not to the page. + _toggleGroupFold(group, toggleId) { + const expanded = !this._isGroupExpanded(group); + columnGroupExpanded.set(this._groupStateKey(group.key), expanded); + this.requestUpdate(); + if (expanded) + return; + const root = this.shadowRoot; + const rows = root?.getElementById(`${toggleId}-rows`); + const active = root?.activeElement ?? null; + if (!active || (rows && rows.contains(active))) { + void this.updateComplete.then(() => root?.getElementById(`${toggleId}-toggle`)?.focus()); + } + } + // The group's box, as MATLAB's: on a group that shows every column, it hides every one the user + // may change; on any other, it shows them all. Name stays shown either way. + _checkGroup(group) { + const show = !group.cols.every((c) => !this._hiddenColumns.has(c)); + const hidden = new Set(this._hiddenColumns); + for (const col of group.cols) { + if (col === 'Name') + continue; + if (show) + hidden.delete(col); + else + hidden.add(col); + } + this._hiddenColumns = hidden; + this._persistHidden(); + } + // Alt+↑ / Alt+↓ on a column of the menu: the column moves one place within its group, as a + // drag would, and the live region says where it is now. Never above or onto Name. + _onMenuItemKeyDown(col, e) { + if (!e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || (e.key !== 'ArrowUp' && e.key !== 'ArrowDown')) + return; + e.preventDefault(); + e.stopPropagation(); + const run = this._menuRunOf(col); + const at = run.indexOf(col); + const up = e.key === 'ArrowUp'; + const neighbor = run[up ? at - 1 : at + 1]; + if (col === 'Name' || neighbor === undefined || neighbor === 'Name') + return; + this._moveColumn(col, neighbor, !up); + const moved = this._menuRunOf(col); + this._columnMenuAnnouncement = `${this._columnLabel(col)} moved to position ${moved.indexOf(col) + 1} of ${moved.length}`; + // The rows are drawn by position, so the moved column's box is another element now. + void this.updateComplete.then(() => this.shadowRoot?.querySelector(`.column-menu-item[data-col="${col}"] input[type=checkbox]`)?.focus()); + } + // The columns of `col`'s group, in display order: the run a move of it stays in. + _menuRunOf(col) { + if (isPropertyColumn(col)) + return this._propertyColumns.map(propertyColumnKey); + return this._orderedBuiltins.filter((c) => this._sameGroup(c, col)); + } + // Escape anywhere in the menu closes it, and the focus goes back to the Columns button. + _onColumnMenuKeyDown(e) { + if (e.key !== 'Escape') + return; + e.preventDefault(); + e.stopPropagation(); + this._columnMenuOpen = false; + this.shadowRoot?.querySelector('.columns-button')?.focus(); } // --- Per-column filter popup --- // Right-click, or the funnel button, on a column header. Prefills from the @@ -2866,22 +3071,27 @@ export class DexTreeTable extends LitElement { // The name typed into Other Properties, added: a built-in column's key or label (in any // case, so `storage class` or `DataType`) shows that column; a property name not in the // list becomes a shown property column at the end; one in the list but hidden is shown. - // Anything else says why it was not added (_propertyNotice). Answers whether the name was - // taken, so the field can be emptied. + // A storage class attribute typed by its path (`CoderInfo.CustomAttributes.GetFunction`) is + // the column of its short name. Anything else says why it was not added (_propertyNotice), + // quoting the text as typed. Answers whether the name was taken, so the field can be emptied. _addPropertyColumn(typed) { - const name = typed.trim(); - if (name === '') + const text = typed.trim(); + const name = text.startsWith(ATTRIBUTE_PATH_PREFIX) ? text.slice(ATTRIBUTE_PATH_PREFIX.length).trim() : text; + if (name === '') { + if (text !== '') + this._propertyNotice = `"${text}" is not a valid property name.`; return false; + } const lower = name.toLowerCase(); const builtIn = this._availableColumns.find((c) => c.toLowerCase() === lower || (this.columnLabels?.[c] ?? '').toLowerCase() === lower); const col = builtIn ?? propertyColumnKey(name); if (!builtIn) { if (!PROPERTY_NAME.test(name)) { - this._propertyNotice = `"${name}" is not a valid property name.`; + this._propertyNotice = `"${text}" is not a valid property name.`; return false; } if (this._propertyColumns.includes(name) && !this._hiddenColumns.has(col)) { - this._propertyNotice = `"${name}" is already in the list.`; + this._propertyNotice = `"${text}" is already in the list.`; return false; } if (!this._propertyColumns.includes(name)) { @@ -2889,6 +3099,8 @@ export class DexTreeTable extends LitElement { this._persistPropertyColumns(); this._propertyColumnsChanged(); } + // Other Properties unfolds, so the column added is seen. + columnGroupExpanded.set(this._groupStateKey(PROPERTY_GROUP), true); } this._propertyNotice = ''; if (this._hiddenColumns.has(col)) @@ -5110,12 +5322,18 @@ export class DexTreeTable extends LitElement { // The Columns menu (the in-MATLAB data explorer's Columns dropdown): its title and Reset at the // top, the built-in columns group by group in the middle, which is the part that scrolls, and // Other Properties at the bottom, always in view: the property columns, and the field a - // property's name is typed into. A column moves only within its group. + // property's name is typed into. Each group has a header that folds it, a box that shows or + // hides all its columns, and its count; a column moves only within its group, by drag or by + // Alt+↑/↓, and the live region says where a keyboard move left it. _renderColumnMenu() { if (!this._columnMenuOpen) return nothing; - const builtIns = this._orderedBuiltins; - let lastGroup = null; + const properties = { + key: PROPERTY_GROUP, + label: PROPERTY_GROUP_LABEL, + cols: this._propertyColumns.map(propertyColumnKey), + }; + const propertiesExpanded = this._isGroupExpanded(properties); return html `
0 ? `${this._columnMenuMaxHeight}px` : null, })} + @keydown=${(e) => this._onColumnMenuKeyDown(e)} >
Columns @@ -5140,18 +5359,24 @@ export class DexTreeTable extends LitElement {
- ${builtIns.map((col) => { - const group = this._groupOf(col); - const header = group && group !== lastGroup ? html `
${group}
` : nothing; - lastGroup = group; - return html `${header}${this._renderColumnMenuItem(col)}`; + ${this._columnMenuRuns().map((run, at) => { + if (run.key === null) + return run.cols.map((col) => this._renderColumnMenuItem(col)); + const group = { key: run.key, label: run.key, cols: run.cols }; + const id = `column-menu-group-${at}`; + return html `
+ ${this._renderColumnMenuGroupHeader(group, id)} +
+ ${run.cols.map((col) => this._renderColumnMenuItem(col))} +
+
`; })}
-
-
${PROPERTY_GROUP_LABEL}
- ${this._propertyColumns.length > 0 - ? html `
- ${this._propertyColumns.map((name) => this._renderColumnMenuItem(propertyColumnKey(name)))} +
+ ${this._renderColumnMenuGroupHeader(properties, 'column-menu-properties')} + ${properties.cols.length > 0 + ? html `
+ ${properties.cols.map((col) => this._renderColumnMenuItem(col))}
` : nothing}
@@ -5173,11 +5398,55 @@ export class DexTreeTable extends LitElement { ? html `
${this._propertyNotice}
` : nothing}
+
${this._columnMenuAnnouncement}
`; } + // A group's header, as MATLAB's: the toggle that folds it (▸/▾), the box over its columns + // (checked when all show, mixed when some do), its name, which folds it too and never checks + // it, and "a of b", its shown columns of all. A group with no column has neither toggle nor box + // to use. `id` names the header's parts and the group's rows (`-rows`). + _renderColumnMenuGroupHeader(group, id) { + const expanded = this._isGroupExpanded(group); + const total = group.cols.length; + const shown = group.cols.filter((c) => !this._hiddenColumns.has(c)).length; + const fold = (e) => { + e.stopPropagation(); + this._toggleGroupFold(group, id); + }; + return html `
+ + 0 && shown === total)} + .indeterminate=${live(shown > 0 && shown < total)} + ?disabled=${group.cols.every((c) => c === 'Name')} + @click=${(e) => e.stopPropagation()} + @change=${(e) => { + e.stopPropagation(); + this._checkGroup(group); + }} + /> + ${group.label} + ${shown} of ${total} +
`; + } // One column of the menu: its grip, its box and its name, and a property column's ×. The whole - // row is draggable, within its group. + // row is draggable within its group, and Alt+↑/↓ on it moves it there too. _renderColumnMenuItem(col) { const isName = col === 'Name'; const property = isPropertyColumn(col); @@ -5188,7 +5457,10 @@ export class DexTreeTable extends LitElement { return html `