@aquera/nile-visualization 2.9.43 → 2.9.45

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/README.md CHANGED
@@ -36,6 +36,13 @@ To run a local development server that serves the basic demo located in `demo/in
36
36
 
37
37
  In this section, you can find the updates for each release of `nile-visualization`. It's a good practice to maintain detailed release notes to help users and developers understand what changes have been made from one version to another and how these changes might affect their projects.
38
38
 
39
+ #### Version 2.9.45 (November 19, 2026)
40
+ - Nile Chart: `type: 'grid'` charts take a `columnChooser` option (`true`, or `{ title, tooltip, icon, showCount, showReset, resetLabel, indicator, placement }`). It adds a column-settings icon to the chart header, after any `header-actions` content and before the built-in icons, that opens a `nile-floating-panel` of column checkboxes with a visible/total count and a Reset action; a dot on the icon shows while columns are hidden. Toggles fire the grid's `nile-column-visibility-change`, and a new `config.columnVisibility` re-seeds the panel. Needs `nile-floating-panel`, `nile-checkbox` and `nile-glyph` loaded on the page; column locks need `@aquera/nile-data-grid` 0.9.7. New CSS parts `column-chooser-trigger`, `column-chooser-glyph`, `column-chooser-indicator`. `ChartGridConfigType` and `NileChartColumnChooserConfig` are exported. Off unless set (UIF-1428)
41
+
42
+ #### Version 2.9.44 (November 18, 2026)
43
+ - Nile Charts: Long x-axis labels no longer rotate and shrink the plot. `xAxisLabelMode` (`truncate` by default, or `wrap`), `xAxisLabelMaxWidth` (default 80) and `xAxisLabelRotation` control how they fit, and a clipped label shows its full name in a tooltip (UIF-1426)
44
+ - Nile Charts: Lite tooltips in the charts are capped at `--ng-width-64` (256px) wide and 250px tall and scroll beyond that; the chart header title and subtitle tooltips now use `nile-lite-tooltip`, so they need `@aquera/nile-elements` loaded on the page (UIF-1426)
45
+
39
46
  #### Version 2.9.43 (November 18, 2026)
40
47
  - Nile Chart: The master-detail chart now takes several series and can stack them. Set `series` (`{ name, data, color? }[]`, replaces `data` when non-empty) and `stacking` (`normal` or `percent`) on `type: 'master-detail'` or `<nile-master-detail-chart>`; both panes stack, the detail pane shows a legend and a shared tooltip for 2+ series, and dragging the master selection now zooms every series instead of only the first. Single-series charts are unchanged (UIF-1425)
41
48
 
@@ -6,7 +6,7 @@ export { NileBarChart } from './nile-bar-chart/index.js';
6
6
  export type { BarChartSeriesData } from './nile-bar-chart/index.js';
7
7
  export { NilePieChart } from './nile-pie-chart/index.js';
8
8
  export type { PieChartSeriesData } from './nile-pie-chart/index.js';
9
- export type { LegendConfig, LegendNavigationConfig, LegendTitleConfig, LegendAccessibilityConfig, ChartSpacingConfig, CSSObject, } from './internal/types/index.js';
9
+ export type { LegendConfig, LegendNavigationConfig, LegendTitleConfig, LegendAccessibilityConfig, ChartSpacingConfig, CSSObject, ChartGridConfigType, NileChartColumnChooserConfig, } from './internal/types/index.js';
10
10
  export { NileTrendlineChart } from './nile-trendline-chart/index.js';
11
11
  export type { TrendlineSeriesData, ForecastConfig } from './nile-trendline-chart/index.js';
12
12
  export { NileAnomalyChart } from './nile-anomaly-chart/index.js';
@@ -36,6 +36,28 @@ export interface ChartGridConfigType {
36
36
  columnVisibility?: VisibilityState;
37
37
  rowSelection?: RowSelectionState;
38
38
  columnOrder?: ColumnOrderState;
39
+ /** Adds a column-settings icon to the chart header that opens a show/hide panel for the columns. */
40
+ columnChooser?: boolean | NileChartColumnChooserConfig;
39
41
  height?: string;
40
42
  options?: Options;
41
43
  }
44
+ export interface NileChartColumnChooserConfig {
45
+ /** Defaults to true when the object is given. */
46
+ enabled?: boolean;
47
+ /** Panel heading. Defaults to 'Show columns'. */
48
+ title?: string;
49
+ /** Trigger tooltip and base of its aria-label. Defaults to 'Choose columns'. */
50
+ tooltip?: string;
51
+ /** nile-glyph name for the trigger. Defaults to 'ng-columns-3-cog'. */
52
+ icon?: string;
53
+ /** Shows "visible/total" next to the heading. Defaults to true. */
54
+ showCount?: boolean;
55
+ /** Shows the action that makes every column visible. Defaults to true. */
56
+ showReset?: boolean;
57
+ /** Defaults to 'Reset'. */
58
+ resetLabel?: string;
59
+ /** Shows a dot on the trigger while any column is hidden. Defaults to true. */
60
+ indicator?: boolean;
61
+ /** Defaults to 'bottom-end'. */
62
+ placement?: 'bottom-end' | 'bottom-start' | 'bottom';
63
+ }
@@ -18,6 +18,7 @@ export type { ChartGaugeConfigType } from './chart-gauge-config.type.js';
18
18
  export type { ChartWaterfallConfigType } from './chart-waterfall-config.type.js';
19
19
  export type { ChartClusterConfigType } from './chart-cluster-config.type.js';
20
20
  export type { ChartStackedConfigType } from './chart-stacked-config.type.js';
21
+ export type { ChartGridConfigType, NileChartColumnChooserConfig, } from './chart-grid-config.type.js';
21
22
  export type { ChartHistogramConfigType } from './chart-histogram-config.type.js';
22
23
  export type { ChartBellcurveConfigType } from './chart-bellcurve-config.type.js';
23
24
  export type { ChartBoxplotConfigType } from './chart-boxplot-config.type.js';
@@ -0,0 +1,5 @@
1
+ /** Default size limits for every nile-lite-tooltip the charts render. */
2
+ export declare const LITE_TOOLTIP_MAX_WIDTH = "var(--ng-width-64)";
3
+ export declare const LITE_TOOLTIP_MAX_HEIGHT = 250;
4
+ /** `nile-show` handler: keeps the whole tooltip box within the limits and scrolls any overflow. */
5
+ export declare function limitLiteTooltipHeight(e: Event): void;
@@ -0,0 +1,18 @@
1
+ /** Default size limits for every nile-lite-tooltip the charts render. */
2
+ export const LITE_TOOLTIP_MAX_WIDTH = 'var(--ng-width-64)';
3
+ export const LITE_TOOLTIP_MAX_HEIGHT = 250;
4
+ /** `nile-show` handler: keeps the whole tooltip box within the limits and scrolls any overflow. */
5
+ export function limitLiteTooltipHeight(e) {
6
+ const popper = e.detail?.instance?.popper;
7
+ const box = popper?.querySelector('.tippy-box');
8
+ const content = popper?.querySelector('.tippy-content');
9
+ if (!box || !content)
10
+ return;
11
+ box.style.boxSizing = 'border-box';
12
+ box.style.maxHeight = `${LITE_TOOLTIP_MAX_HEIGHT}px`;
13
+ box.style.display = 'flex';
14
+ box.style.flexDirection = 'column';
15
+ content.style.minHeight = '0';
16
+ content.style.overflowY = 'auto';
17
+ }
18
+ //# sourceMappingURL=lite-tooltip.js.map
@@ -0,0 +1,33 @@
1
+ import type { TemplateResult } from 'lit';
2
+ import type { NileChartColumnChooserConfig } from '../internal/types/chart-grid-config.type.js';
3
+ export type ColumnVisibility = Record<string, boolean>;
4
+ export interface ResolvedColumnChooser {
5
+ title: string;
6
+ tooltip: string;
7
+ icon: string;
8
+ showCount: boolean;
9
+ showReset: boolean;
10
+ resetLabel: string;
11
+ indicator: boolean;
12
+ placement: 'bottom-end' | 'bottom-start' | 'bottom';
13
+ }
14
+ export interface ChooserEntry {
15
+ id: string;
16
+ label: string;
17
+ locked: boolean;
18
+ group: string | null;
19
+ }
20
+ export declare const COLUMN_CHOOSER_PANEL_CLASS = "nile-chart-column-chooser";
21
+ export declare function resolveColumnChooser(option: boolean | NileChartColumnChooserConfig | undefined | null): ResolvedColumnChooser | null;
22
+ export declare function chooserEntries(columns: unknown[], columnOrder?: string[]): ChooserEntry[];
23
+ export declare function isColumnVisible(entry: ChooserEntry, visibility: ColumnVisibility): boolean;
24
+ export interface ColumnChooserRenderOptions {
25
+ chooser: ResolvedColumnChooser;
26
+ entries: ChooserEntry[];
27
+ visibility: ColumnVisibility;
28
+ onToggle: (id: string, visible: boolean) => void;
29
+ onReset: () => void;
30
+ onShow: (e: Event) => void;
31
+ onHide: (e: Event) => void;
32
+ }
33
+ export declare function renderColumnChooser(opts: ColumnChooserRenderOptions): TemplateResult;
@@ -0,0 +1,133 @@
1
+ import { html, nothing } from 'lit';
2
+ export const COLUMN_CHOOSER_PANEL_CLASS = 'nile-chart-column-chooser';
3
+ export function resolveColumnChooser(option) {
4
+ if (!option)
5
+ return null;
6
+ const o = option === true ? {} : option;
7
+ if (o.enabled === false)
8
+ return null;
9
+ return {
10
+ title: o.title ?? 'Show columns',
11
+ tooltip: o.tooltip ?? 'Choose columns',
12
+ icon: o.icon ?? 'ng-columns-3-cog',
13
+ showCount: o.showCount !== false,
14
+ showReset: o.showReset !== false,
15
+ resetLabel: o.resetLabel ?? 'Reset',
16
+ indicator: o.indicator !== false,
17
+ placement: o.placement ?? 'bottom-end',
18
+ };
19
+ }
20
+ function labelOf(col) {
21
+ if (typeof col.header === 'string' && col.header.trim())
22
+ return col.header;
23
+ if (col.chooserLabel)
24
+ return col.chooserLabel;
25
+ return col.id;
26
+ }
27
+ export function chooserEntries(columns, columnOrder = []) {
28
+ const entries = [];
29
+ const walk = (cols, group) => {
30
+ for (const col of cols) {
31
+ if (col.columns?.length) {
32
+ walk(col.columns, labelOf(col));
33
+ }
34
+ else if (col.type !== 'checkbox') {
35
+ entries.push({
36
+ id: col.id,
37
+ label: labelOf(col),
38
+ locked: col.enableHiding === false,
39
+ group,
40
+ });
41
+ }
42
+ }
43
+ };
44
+ walk((columns ?? []), null);
45
+ if (columnOrder.length === 0)
46
+ return entries;
47
+ const rank = new Map(columnOrder.map((id, i) => [id, i]));
48
+ return entries
49
+ .map((e, i) => ({ e, i }))
50
+ .sort((a, b) => (rank.get(a.e.id) ?? columnOrder.length + a.i) -
51
+ (rank.get(b.e.id) ?? columnOrder.length + b.i))
52
+ .map((x) => x.e);
53
+ }
54
+ export function isColumnVisible(entry, visibility) {
55
+ return entry.locked || visibility[entry.id] !== false;
56
+ }
57
+ export function renderColumnChooser(opts) {
58
+ const { chooser, entries, visibility } = opts;
59
+ const shown = entries.filter((e) => isColumnVisible(e, visibility)).length;
60
+ const total = entries.length;
61
+ const label = `${chooser.tooltip} (${shown} of ${total} shown)`;
62
+ const filtered = shown < total;
63
+ let lastGroup = null;
64
+ const rows = entries.map((entry) => {
65
+ const visible = isColumnVisible(entry, visibility);
66
+ const heading = entry.group && entry.group !== lastGroup
67
+ ? html `<div class="nile-chart-column-chooser-group" role="presentation">
68
+ ${entry.group}
69
+ </div>`
70
+ : nothing;
71
+ lastGroup = entry.group;
72
+ const disabled = entry.locked || (visible && shown <= 1);
73
+ return html `${heading}<nile-checkbox
74
+ class="nile-chart-column-chooser-option"
75
+ data-column-id=${entry.id}
76
+ .checked=${visible}
77
+ .disabled=${disabled}
78
+ @nile-change=${(e) => opts.onToggle(entry.id, e.detail.checked)}
79
+ >${entry.label}</nile-checkbox
80
+ >`;
81
+ });
82
+ // nile-floating-panel re-parents its children, so each direct child must be a static element.
83
+ return html `<nile-floating-panel
84
+ class="nile-chart-column-chooser-anchor"
85
+ placement=${chooser.placement}
86
+ arrow="none"
87
+ .distance=${6}
88
+ .panelClass=${COLUMN_CHOOSER_PANEL_CLASS}
89
+ @nile-after-show=${opts.onShow}
90
+ @nile-hide=${opts.onHide}
91
+ >
92
+ <button
93
+ type="button"
94
+ class="nile-chart-menu-trigger nile-chart-column-chooser-trigger"
95
+ part="column-chooser-trigger"
96
+ aria-label=${label}
97
+ title=${label}
98
+ >
99
+ <nile-glyph
100
+ name=${chooser.icon}
101
+ method="stroke"
102
+ size="16"
103
+ color="currentColor"
104
+ part="column-chooser-glyph"
105
+ ></nile-glyph>
106
+ ${chooser.indicator && filtered
107
+ ? html `<span
108
+ class="nile-chart-column-chooser-indicator"
109
+ part="column-chooser-indicator"
110
+ aria-hidden="true"
111
+ ></span>`
112
+ : nothing}
113
+ </button>
114
+ <span slot="title" class="nile-chart-column-chooser-title"
115
+ >${chooser.title}${chooser.showCount
116
+ ? html `<span class="nile-chart-column-chooser-count">${shown}/${total}</span>`
117
+ : nothing}</span
118
+ >
119
+ <button
120
+ type="button"
121
+ slot="action"
122
+ class="nile-chart-column-chooser-reset"
123
+ ?hidden=${!chooser.showReset}
124
+ @click=${opts.onReset}
125
+ >
126
+ ${chooser.resetLabel}
127
+ </button>
128
+ <div class="nile-chart-column-chooser-list" role="group" aria-label=${chooser.title}>
129
+ ${rows}
130
+ </div>
131
+ </nile-floating-panel>`;
132
+ }
133
+ //# sourceMappingURL=nile-chart-column-chooser.js.map
@@ -0,0 +1,2 @@
1
+ import './nile-chart';
2
+ import '@aquera/nile-data-grid';
@@ -0,0 +1,244 @@
1
+ var _a;
2
+ import { expect, fixture, aTimeout, html } from '@open-wc/testing';
3
+ import './nile-chart';
4
+ import '@aquera/nile-data-grid';
5
+ // TanStack Table reads process.env when it builds a table; the test browser has no process.
6
+ (_a = window).process ?? (_a.process = { env: { NODE_ENV: 'production' } });
7
+ const settle = async (el) => {
8
+ await el.updateComplete;
9
+ await el.updateComplete;
10
+ await new Promise(requestAnimationFrame);
11
+ };
12
+ const COLUMNS = [
13
+ { id: 'select', header: '', accessorKey: 'select', type: 'checkbox' },
14
+ { id: 'id', header: 'ID', accessorKey: 'id', enableHiding: false },
15
+ { id: 'name', header: 'Name', accessorKey: 'name', enableHiding: false },
16
+ { id: 'role', header: 'Role', accessorKey: 'role' },
17
+ { id: 'dept', header: 'Dept', accessorKey: 'dept' },
18
+ { id: 'email', header: 'Email', accessorKey: 'email' },
19
+ { id: 'phone', header: 'Phone', accessorKey: 'phone' },
20
+ { id: 'city', header: 'City', accessorKey: 'city' },
21
+ { id: 'status', header: 'Status', accessorKey: 'status' },
22
+ ];
23
+ const DATA = [
24
+ {
25
+ id: 1,
26
+ name: 'Ada',
27
+ role: 'Eng',
28
+ dept: 'R&D',
29
+ email: 'a@x.co',
30
+ phone: '1',
31
+ city: 'NY',
32
+ status: 'on',
33
+ },
34
+ {
35
+ id: 2,
36
+ name: 'Grace',
37
+ role: 'Adm',
38
+ dept: 'Navy',
39
+ email: 'g@x.co',
40
+ phone: '2',
41
+ city: 'DC',
42
+ status: 'off',
43
+ },
44
+ ];
45
+ const gridConfig = (extra = {}) => ({
46
+ type: 'grid',
47
+ data: DATA,
48
+ columns: COLUMNS,
49
+ columnChooser: true,
50
+ ...extra,
51
+ });
52
+ const make = async (config) => {
53
+ const el = await fixture(html `<nile-chart></nile-chart>`);
54
+ if (config)
55
+ el.config = config;
56
+ await settle(el);
57
+ return el;
58
+ };
59
+ const root = (el) => el.shadowRoot;
60
+ const trigger = (el) => root(el).querySelector('button[part~="column-chooser-trigger"]');
61
+ const innerGrid = (el) => root(el).querySelector('nile-data-grid');
62
+ const openPanel = async (el) => {
63
+ trigger(el).click();
64
+ await settle(el);
65
+ await aTimeout(50);
66
+ };
67
+ // nile-floating-panel re-parents its content to document.body on open; in the
68
+ // headless runner it may stay in the chart's shadow root — look in both.
69
+ const panelQueryAll = (el, sel) => {
70
+ const inBody = Array.from(document.querySelectorAll(sel));
71
+ return inBody.length ? inBody : Array.from(root(el).querySelectorAll(sel));
72
+ };
73
+ const panelQuery = (el, sel) => document.querySelector(sel) ?? root(el).querySelector(sel);
74
+ const listedCheckboxes = (el) => panelQueryAll(el, '.nile-chart-column-chooser-list nile-checkbox');
75
+ const checkboxFor = (el, id) => panelQuery(el, `.nile-chart-column-chooser-list nile-checkbox[data-column-id="${id}"]`);
76
+ describe('NileChart column chooser', () => {
77
+ describe('trigger presence', () => {
78
+ it('1. no trigger when columnChooser is absent', async () => {
79
+ const el = await make(gridConfig({ columnChooser: undefined }));
80
+ expect(trigger(el)).to.be.null;
81
+ });
82
+ it('2. no trigger when columnChooser is false', async () => {
83
+ const el = await make(gridConfig({ columnChooser: false }));
84
+ expect(trigger(el)).to.be.null;
85
+ });
86
+ it('3. renders a trigger with glyph when columnChooser is true', async () => {
87
+ const el = await make(gridConfig());
88
+ const btn = trigger(el);
89
+ expect(btn).to.exist;
90
+ expect(btn.querySelector('nile-glyph[part~="column-chooser-glyph"]')).to.exist;
91
+ });
92
+ it('4. ignored for non-grid types', async () => {
93
+ const el = await make({
94
+ type: 'line',
95
+ data: [{ name: 'A', data: [1, 2, 3] }],
96
+ categories: ['x', 'y', 'z'],
97
+ columnChooser: true,
98
+ });
99
+ expect(trigger(el)).to.be.null;
100
+ });
101
+ it('5. trigger lives in the header actions group', async () => {
102
+ const el = await make(gridConfig());
103
+ const actions = root(el).querySelector('.nile-chart-header-actions');
104
+ expect(actions).to.exist;
105
+ expect(actions.contains(trigger(el))).to.be.true;
106
+ });
107
+ it('6. trigger is positioned after the header-actions slot', async () => {
108
+ const el = await make(gridConfig());
109
+ const actions = root(el).querySelector('.nile-chart-header-actions');
110
+ const slot = actions.querySelector('slot[name="header-actions"]');
111
+ const btn = trigger(el);
112
+ expect(slot.compareDocumentPosition(btn) & Node.DOCUMENT_POSITION_FOLLOWING).to.be.greaterThan(0);
113
+ });
114
+ it('7. header renders for the chooser even with no title', async () => {
115
+ const el = await make(gridConfig());
116
+ expect(root(el).querySelector('.nile-chart-header')).to.exist;
117
+ });
118
+ it('8. slotting header-actions content keeps the trigger', async () => {
119
+ const el = await fixture(html `<nile-chart><button slot="header-actions">Export</button></nile-chart>`);
120
+ el.config = gridConfig();
121
+ await settle(el);
122
+ expect(trigger(el)).to.exist;
123
+ });
124
+ });
125
+ describe('floating panel', () => {
126
+ it('9. trigger is wrapped by a floating panel with the chooser panel-class', async () => {
127
+ const el = await make(gridConfig());
128
+ const panels = Array.from(root(el).querySelectorAll('nile-floating-panel'));
129
+ const panel = panels.find((p) => p.contains(trigger(el)));
130
+ expect(panel, 'floating panel wrapping the trigger').to.exist;
131
+ const panelClass = panel.panelClass ?? panel.getAttribute('panel-class');
132
+ expect(panelClass).to.equal('nile-chart-column-chooser');
133
+ });
134
+ it('10. opening lists one checkbox per hideable column', async () => {
135
+ const el = await make(gridConfig());
136
+ await openPanel(el);
137
+ const boxes = listedCheckboxes(el);
138
+ expect(boxes.length).to.equal(8);
139
+ });
140
+ it('11. row-selection (checkbox) columns are not listed', async () => {
141
+ const el = await make(gridConfig());
142
+ await openPanel(el);
143
+ expect(checkboxFor(el, 'select')).to.be.null;
144
+ });
145
+ });
146
+ describe('labels and locked state', () => {
147
+ it('12. function header falls back to chooserLabel', async () => {
148
+ const el = await make(gridConfig({
149
+ columns: [
150
+ { id: 'id', header: 'ID', accessorKey: 'id' },
151
+ { id: 'r', header: () => 'x', accessorKey: 'r', chooserLabel: 'Custom' },
152
+ ],
153
+ }));
154
+ await openPanel(el);
155
+ expect(checkboxFor(el, 'r').textContent).to.contain('Custom');
156
+ });
157
+ it('13. enableHiding:false columns are checked and disabled', async () => {
158
+ const el = await make(gridConfig());
159
+ await openPanel(el);
160
+ const idBox = checkboxFor(el, 'id');
161
+ expect(idBox.checked).to.be.true;
162
+ expect(idBox.disabled).to.be.true;
163
+ });
164
+ it('14. last visible column checkbox is disabled', async () => {
165
+ const el = await make(gridConfig({
166
+ columns: [
167
+ { id: 'only', header: 'Only', accessorKey: 'only' },
168
+ { id: 'b', header: 'B', accessorKey: 'b' },
169
+ ],
170
+ columnVisibility: { b: false },
171
+ }));
172
+ await openPanel(el);
173
+ expect(checkboxFor(el, 'only').disabled).to.be.true;
174
+ });
175
+ });
176
+ describe('count and indicator', () => {
177
+ it('15. count reflects visible / total', async () => {
178
+ const el = await make(gridConfig({ columnVisibility: { role: false, dept: false } }));
179
+ await openPanel(el);
180
+ const count = panelQuery(el, '.nile-chart-column-chooser-count');
181
+ expect(count.textContent.replace(/\s/g, '')).to.equal('6/8');
182
+ });
183
+ it('16. no indicator when nothing is hidden', async () => {
184
+ const el = await make(gridConfig());
185
+ expect(root(el).querySelector('[part~="column-chooser-indicator"]')).to.be.null;
186
+ });
187
+ it('17. indicator shown when a column is hidden', async () => {
188
+ const el = await make(gridConfig({ columnVisibility: { role: false } }));
189
+ expect(root(el).querySelector('[part~="column-chooser-indicator"]')).to.exist;
190
+ });
191
+ it('18. aria-label reports shown / total', async () => {
192
+ const el = await make(gridConfig({ columnVisibility: { role: false, dept: false } }));
193
+ expect(trigger(el).getAttribute('aria-label')).to.equal('Choose columns (6 of 8 shown)');
194
+ });
195
+ });
196
+ describe('toggling', () => {
197
+ it('19. unchecking hides exactly that column and fires one event', async () => {
198
+ const el = await make(gridConfig());
199
+ await openPanel(el);
200
+ let events = 0;
201
+ el.addEventListener('nile-column-visibility-change', () => (events += 1));
202
+ const box = checkboxFor(el, 'role');
203
+ box.checked = false;
204
+ box.dispatchEvent(new CustomEvent('nile-change', {
205
+ detail: { checked: false },
206
+ bubbles: true,
207
+ composed: true,
208
+ }));
209
+ await settle(el);
210
+ expect(innerGrid(el).columnVisibility.role).to.equal(false);
211
+ expect(events).to.equal(1);
212
+ });
213
+ it('20. reset shows all columns and fires one event', async () => {
214
+ const el = await make(gridConfig({ columnVisibility: { role: false, dept: false } }));
215
+ await openPanel(el);
216
+ let events = 0;
217
+ el.addEventListener('nile-column-visibility-change', () => (events += 1));
218
+ const reset = panelQuery(el, 'button.nile-chart-column-chooser-reset');
219
+ reset.click();
220
+ await settle(el);
221
+ const vis = innerGrid(el).columnVisibility;
222
+ expect(Object.values(vis).some((v) => v === false)).to.be.false;
223
+ expect(events).to.equal(1);
224
+ });
225
+ it('21. locked column cannot be hidden from the grid', async () => {
226
+ const el = await make(gridConfig({ columnVisibility: { id: false } }));
227
+ await settle(el);
228
+ expect(innerGrid(el).columnVisibility.id).to.not.equal(undefined);
229
+ await openPanel(el);
230
+ expect(checkboxFor(el, 'id').checked).to.be.true;
231
+ });
232
+ });
233
+ describe('re-seeding', () => {
234
+ it('22. replacing config columnVisibility re-seeds grid and checkboxes', async () => {
235
+ const el = await make(gridConfig());
236
+ el.config = gridConfig({ columnVisibility: { role: false } });
237
+ await settle(el);
238
+ expect(innerGrid(el).columnVisibility.role).to.equal(false);
239
+ await openPanel(el);
240
+ expect(checkboxFor(el, 'role').checked).to.be.false;
241
+ });
242
+ });
243
+ });
244
+ //# sourceMappingURL=nile-chart-column-chooser.test.js.map
@@ -1,11 +1,11 @@
1
1
  import { html, nothing } from 'lit';
2
2
  import { styleMap } from 'lit/directives/style-map.js';
3
3
  import { renderChartGhost } from './nile-chart-skeleton.js';
4
+ import { LITE_TOOLTIP_MAX_WIDTH, limitLiteTooltipHeight } from '../internal/utils/lite-tooltip.js';
4
5
  /** Default empty state for `<nile-chart>`: detection (`isChartEmpty`) and markup (`renderChartEmptyState`). */
5
6
  export const EMPTY_STATE_TITLE = 'No data';
6
7
  export const EMPTY_STATE_DESCRIPTION = 'There is nothing to show for this chart yet. Data will appear here once it is available.';
7
8
  // Tooltip width cap; longer text wraps. The tooltip mounts on <body>, where :root tokens resolve.
8
- const TOOLTIP_MAX_WIDTH = 'var(--ng-width-64)';
9
9
  // Types whose `data` is `[{ name, data: [...] }]`.
10
10
  const SERIES_TYPES = new Set([
11
11
  'bar', 'line', 'area', 'column', 'spline', 'scatter', 'bubble', 'radar',
@@ -207,12 +207,12 @@ export function renderChartEmptyState(opts = {}) {
207
207
  : html `<div class="nile-chart-empty__ghost" part="empty-ghost" aria-hidden="true">
208
208
  <slot name="empty-ghost">${renderChartGhost(opts.type)}</slot>
209
209
  </div>`}
210
- <nile-lite-tooltip class="nile-chart-empty__tip nile-chart-empty__tip--title" placement="top" .maxWidth=${TOOLTIP_MAX_WIDTH} disabled>
210
+ <nile-lite-tooltip class="nile-chart-empty__tip nile-chart-empty__tip--title" placement="top" .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} disabled>
211
211
  <div class="nile-chart-empty__title" part="empty-title">
212
212
  <span class="nile-chart-empty__badge" part="empty-badge"><slot name="empty-title">${EMPTY_STATE_TITLE}</slot></span>
213
213
  </div>
214
214
  </nile-lite-tooltip>
215
- <nile-lite-tooltip class="nile-chart-empty__tip nile-chart-empty__tip--description" placement="top" .maxWidth=${TOOLTIP_MAX_WIDTH} disabled>
215
+ <nile-lite-tooltip class="nile-chart-empty__tip nile-chart-empty__tip--description" placement="top" .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} disabled>
216
216
  <div class="nile-chart-empty__description" part="empty-description">
217
217
  <slot name="empty-description">${EMPTY_STATE_DESCRIPTION}</slot>
218
218
  </div>
@@ -80,17 +80,77 @@ const MENU_OVERRIDE_CSS = `
80
80
  user-select: none;
81
81
  }
82
82
  `;
83
- export function injectGlobalChartMenuOverrides() {
84
- if (typeof document === 'undefined')
85
- return;
86
- const STYLE_ID = 'nile-chart-actions-menu-overrides';
87
- if (document.getElementById(STYLE_ID))
83
+ const COLUMN_CHOOSER_CSS = `
84
+ .nile-chart-column-chooser .nile-chart-column-chooser-title {
85
+ display: inline-flex;
86
+ align-items: baseline;
87
+ gap: var(--nile-spacing-xs, var(--ng-spacing-xs, 4px));
88
+ }
89
+
90
+ .nile-chart-column-chooser .nile-chart-column-chooser-count {
91
+ font-weight: var(--nile-font-weight-regular, var(--ng-font-weight-regular));
92
+ color: var(--nile-colors-neutral-500, var(--ng-colors-text-quaternary-500));
93
+ }
94
+
95
+ .nile-chart-column-chooser .nile-chart-column-chooser-list {
96
+ display: flex;
97
+ flex-direction: column;
98
+ gap: var(--nile-spacing-10px, var(--ng-spacing-2-5, 10px));
99
+ width: var(--nile-width-200px, var(--ng-height-200px));
100
+ max-height: 60vh;
101
+ overflow-y: auto;
102
+ /* inset so the checkbox focus ring isn't clipped by the scroll container */
103
+ padding: var(--nile-spacing-xs, var(--ng-spacing-xs, 4px));
104
+ margin: 0 calc(-1 * var(--nile-spacing-xs, var(--ng-spacing-xs, 4px)));
105
+ }
106
+
107
+ .nile-chart-column-chooser .nile-chart-column-chooser-option {
108
+ align-self: flex-start;
109
+ }
110
+
111
+ .nile-chart-column-chooser .nile-chart-column-chooser-group {
112
+ font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
113
+ font-size: var(--nile-type-scale-2, var(--ng-font-size-text-xs));
114
+ font-weight: var(--nile-font-weight-medium, var(--ng-font-weight-medium));
115
+ color: var(--nile-colors-neutral-500, var(--ng-colors-text-tertiary-600));
116
+ padding-top: var(--nile-spacing-xs, var(--ng-spacing-xs, 4px));
117
+ user-select: none;
118
+ }
119
+
120
+ .nile-chart-column-chooser .nile-chart-column-chooser-reset {
121
+ padding: 0;
122
+ border: none;
123
+ background: none;
124
+ cursor: pointer;
125
+ font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
126
+ font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));
127
+ font-weight: var(--nile-font-weight-medium, var(--ng-font-weight-semibold));
128
+ color: var(--nile-colors-primary-600, var(--ng-colors-text-brand-tertiary-600));
129
+ }
130
+
131
+ .nile-chart-column-chooser .nile-chart-column-chooser-reset:focus-visible {
132
+ outline: var(--nile-border-width-2, var(--ng-stroke-width-2)) solid var(--nile-colors-primary-600, var(--ng-colors-fg-brand-primary-600));
133
+ outline-offset: var(--nile-spacing-1px, var(--ng-outline-offset-1));
134
+ }
135
+
136
+ .nile-chart-column-chooser .nile-chart-column-chooser-reset[hidden] {
137
+ display: none;
138
+ }
139
+ `;
140
+ function injectGlobalStyle(id, cssText) {
141
+ if (document.getElementById(id))
88
142
  return;
89
143
  const style = document.createElement('style');
90
- style.id = STYLE_ID;
91
- style.textContent = MENU_OVERRIDE_CSS;
144
+ style.id = id;
145
+ style.textContent = cssText;
92
146
  document.head?.appendChild(style);
93
147
  }
148
+ export function injectGlobalChartMenuOverrides() {
149
+ if (typeof document === 'undefined')
150
+ return;
151
+ injectGlobalStyle('nile-chart-actions-menu-overrides', MENU_OVERRIDE_CSS);
152
+ injectGlobalStyle('nile-chart-column-chooser-styles', COLUMN_CHOOSER_CSS);
153
+ }
94
154
  injectGlobalChartMenuOverrides();
95
155
  export const styles = css `
96
156
  :host {
@@ -196,6 +256,18 @@ export const styles = css `
196
256
  flex: 0 1 auto;
197
257
  }
198
258
 
259
+ /* <nile-lite-tooltip> wrappers around the header title / subtitle; they must not break the ellipsis. */
260
+ .nile-chart-header-tip {
261
+ display: block;
262
+ width: 100%;
263
+ min-width: 0;
264
+ }
265
+
266
+ .nile-chart-header-title-row .nile-chart-header-tip {
267
+ width: auto;
268
+ flex: 0 1 auto;
269
+ }
270
+
199
271
  .nile-chart-header-info-tip {
200
272
  display: inline-flex;
201
273
  align-items: center;
@@ -483,6 +555,24 @@ export const styles = css `
483
555
  transition: background var(--nile-transition-duration-short, var(--ng-transition-duration-fast)) ease, color var(--nile-transition-duration-short, var(--ng-transition-duration-fast)) ease;
484
556
  }
485
557
 
558
+ .nile-chart-column-chooser-anchor {
559
+ display: inline-flex;
560
+ }
561
+
562
+ .nile-chart-column-chooser-trigger {
563
+ position: relative;
564
+ }
565
+
566
+ .nile-chart-column-chooser-indicator {
567
+ position: absolute;
568
+ top: var(--nile-spacing-2px, var(--ng-spacing-xxs, 2px));
569
+ right: var(--nile-spacing-2px, var(--ng-spacing-xxs, 2px));
570
+ width: var(--nile-width-6px, var(--ng-height-6px));
571
+ height: var(--nile-height-6px, var(--ng-height-6px));
572
+ border-radius: var(--nile-radius-full, var(--ng-radius-full));
573
+ background: var(--nile-colors-primary-600, var(--ng-colors-fg-brand-primary-600));
574
+ }
575
+
486
576
  .nile-chart-menu-trigger:hover {
487
577
  background: transparent;
488
578
  color: var(--nile-colors-dark-900, var(--ng-colors-text-primary-900));