@aquera/nile-visualization 2.9.29 → 2.9.30
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 +4 -0
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.js +1 -0
- package/dist/src/internal/types/chart-forecast-config.type.d.ts +35 -0
- package/dist/src/internal/types/chart-forecast-config.type.js +2 -0
- package/dist/src/internal/types/index.d.ts +1 -0
- package/dist/src/internal/types/primitive-chart-config.type.d.ts +2 -1
- package/dist/src/nile-chart/index.d.ts +1 -1
- package/dist/src/nile-chart/nile-chart-config.d.ts +20 -81
- package/dist/src/nile-chart/nile-chart-skeleton.js +1 -1
- package/dist/src/nile-chart/nile-chart.d.ts +9 -0
- package/dist/src/nile-chart/nile-chart.js +68 -4
- package/dist/src/nile-filter-chart/nile-filter-chart.d.ts +2 -0
- package/dist/src/nile-filter-chart/nile-filter-chart.js +14 -0
- package/dist/src/nile-filter-chart/utils/prompt.js +31 -6
- package/dist/src/nile-filter-chart/utils/types.d.ts +2 -0
- package/dist/src/nile-forecast-chart/index.d.ts +2 -0
- package/dist/src/nile-forecast-chart/index.js +2 -0
- package/dist/src/nile-forecast-chart/nile-forecast-chart.css.d.ts +1 -0
- package/dist/src/nile-forecast-chart/nile-forecast-chart.css.js +46 -0
- package/dist/src/nile-forecast-chart/nile-forecast-chart.d.ts +90 -0
- package/dist/src/nile-forecast-chart/nile-forecast-chart.js +551 -0
- package/package.json +2 -1
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import { html, nothing } from 'lit';
|
|
2
2
|
import { live } from 'lit/directives/live.js';
|
|
3
3
|
import { ref } from 'lit/directives/ref.js';
|
|
4
|
+
import { directive, Directive } from 'lit/directive.js';
|
|
4
5
|
// Per-element ResizeObserver bookkeeping. WeakMap so observers are GC'd
|
|
5
6
|
// alongside their elements when the prompt is unmounted.
|
|
6
7
|
const _fieldObservers = new WeakMap();
|
|
8
|
+
class SyncOpenDirective extends Directive {
|
|
9
|
+
render(_open) {
|
|
10
|
+
return nothing;
|
|
11
|
+
}
|
|
12
|
+
update(part, [open]) {
|
|
13
|
+
const el = part.element;
|
|
14
|
+
if (el.open !== open)
|
|
15
|
+
el.open = open;
|
|
16
|
+
return nothing;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const syncOpen = directive(SyncOpenDirective);
|
|
7
20
|
const PUNCT_TOKENS = new Set(['(', ')', '[', ']', ',']);
|
|
8
21
|
/**
|
|
9
22
|
* Splits the input into the tokens analyzePromptCtx reasons about:
|
|
@@ -369,6 +382,7 @@ export function renderPrompt(host, ctrl) {
|
|
|
369
382
|
// Decide what kind of token comes next, then pre-filter the suggestion list
|
|
370
383
|
// to that context. The combobox's own substring filter is bypassed below
|
|
371
384
|
// (via `getSearchText`) so this pre-filter is the single source of truth.
|
|
385
|
+
const justPicked = host.promptPickedIds.has(ctrl.id);
|
|
372
386
|
const ctx = analyzePromptCtx(value, fieldNames, operatorTokens, connectorTokens);
|
|
373
387
|
const candidates = (() => {
|
|
374
388
|
switch (ctx.position) {
|
|
@@ -515,8 +529,17 @@ export function renderPrompt(host, ctrl) {
|
|
|
515
529
|
const tokens = tokenize(value);
|
|
516
530
|
const onInput = (e) => {
|
|
517
531
|
const inputEl = e.target;
|
|
518
|
-
|
|
532
|
+
let next = inputEl.value;
|
|
519
533
|
const atEnd = () => inputEl.selectionStart === inputEl.value.length;
|
|
534
|
+
if (justPicked) {
|
|
535
|
+
const appended = next.startsWith(value) ? next.slice(value.length) : '';
|
|
536
|
+
if (value.length > 0 && appended.length > 0 && !/^\s/.test(appended)) {
|
|
537
|
+
next = `${value} ${appended}`;
|
|
538
|
+
inputEl.value = next;
|
|
539
|
+
inputEl.setSelectionRange(next.length, next.length);
|
|
540
|
+
}
|
|
541
|
+
host.setPromptPicked(ctrl.id, false);
|
|
542
|
+
}
|
|
520
543
|
if (atEnd()) {
|
|
521
544
|
const s = inputEl.selectionStart ?? next.length;
|
|
522
545
|
inputEl.setSelectionRange(s, s);
|
|
@@ -551,7 +574,7 @@ export function renderPrompt(host, ctrl) {
|
|
|
551
574
|
if (tokenLike) {
|
|
552
575
|
const beforeTrimmed = ctx.before.replace(/\s+$/, '');
|
|
553
576
|
const sep = beforeTrimmed.length > 0 ? ' ' : '';
|
|
554
|
-
next = beforeTrimmed + sep + tokenOf(item)
|
|
577
|
+
next = beforeTrimmed + sep + tokenOf(item);
|
|
555
578
|
}
|
|
556
579
|
else if (item.type === 'value') {
|
|
557
580
|
const beforeTrimmed = ctx.before.replace(/\s+$/, '');
|
|
@@ -568,7 +591,7 @@ export function renderPrompt(host, ctrl) {
|
|
|
568
591
|
const inserted = alreadyQuoted || isNumeric || isLiteral
|
|
569
592
|
? raw
|
|
570
593
|
: `"${raw.replace(/"/g, '\\"')}"`;
|
|
571
|
-
next = beforeTrimmed + sep + inserted
|
|
594
|
+
next = beforeTrimmed + sep + inserted;
|
|
572
595
|
}
|
|
573
596
|
else if (item.type === 'function') {
|
|
574
597
|
const beforeTrimmed = ctx.before.replace(/\s+$/, '');
|
|
@@ -587,6 +610,7 @@ export function renderPrompt(host, ctrl) {
|
|
|
587
610
|
// candidate set should start with no row pre-highlighted. Avoids the
|
|
588
611
|
// confusing "stuck on the old index" state after a pick.
|
|
589
612
|
host.setPromptActiveIndex(ctrl.id, -1);
|
|
613
|
+
host.setPromptPicked(ctrl.id, true);
|
|
590
614
|
// Imperatively sync the input for immediate visual feedback.
|
|
591
615
|
inputEl.value = next;
|
|
592
616
|
// Defer focus + caret-to-end to AFTER Lit's microtask-scheduled re-render.
|
|
@@ -609,7 +633,7 @@ export function renderPrompt(host, ctrl) {
|
|
|
609
633
|
};
|
|
610
634
|
const onKeyDown = (e) => {
|
|
611
635
|
const inputEl = e.currentTarget;
|
|
612
|
-
const len = suggestionData.length;
|
|
636
|
+
const len = dropdownOpen ? suggestionData.length : 0;
|
|
613
637
|
// Read fresh from host (don't rely on the closure-captured `activeIdx`,
|
|
614
638
|
// which is from this render — fine in theory but defensive against any
|
|
615
639
|
// Lit re-binding edge case).
|
|
@@ -689,7 +713,7 @@ export function renderPrompt(host, ctrl) {
|
|
|
689
713
|
host.setPromptFocused(ctrl.id, false);
|
|
690
714
|
};
|
|
691
715
|
const isFocused = host.promptFocusedId === ctrl.id;
|
|
692
|
-
const dropdownOpen = isFiltrexMode && isFocused && suggestionData.length > 0;
|
|
716
|
+
const dropdownOpen = isFiltrexMode && isFocused && suggestionData.length > 0 && !justPicked;
|
|
693
717
|
// Clears the prompt value, fires the existing `nile-change` flow (via
|
|
694
718
|
// submitPrompt → _emitChange) and additionally emits a dedicated
|
|
695
719
|
// `nile-clear` event so consumers can distinguish a user-initiated clear
|
|
@@ -699,6 +723,7 @@ export function renderPrompt(host, ctrl) {
|
|
|
699
723
|
host.handlePromptInput(ctrl, '');
|
|
700
724
|
host.submitPrompt(ctrl);
|
|
701
725
|
host.setPromptActiveIndex(ctrl.id, -1);
|
|
726
|
+
host.setPromptPicked(ctrl.id, false);
|
|
702
727
|
host.emit('nile-clear', { id: ctrl.id, source });
|
|
703
728
|
const target = e.currentTarget;
|
|
704
729
|
const root = (target?.getRootNode() ?? document);
|
|
@@ -720,7 +745,7 @@ export function renderPrompt(host, ctrl) {
|
|
|
720
745
|
placement="bottom-start"
|
|
721
746
|
sync="width"
|
|
722
747
|
distance="6"
|
|
723
|
-
|
|
748
|
+
${syncOpen(dropdownOpen)}
|
|
724
749
|
.noOpenOnClick=${true}
|
|
725
750
|
>
|
|
726
751
|
<div
|
|
@@ -250,6 +250,8 @@ export interface FilterChartHost {
|
|
|
250
250
|
submitPrompt(ctrl: NormalizedFilterControl): void;
|
|
251
251
|
/** Set the highlighted suggestion index. Use -1 to clear the highlight. */
|
|
252
252
|
setPromptActiveIndex(id: string, idx: number): void;
|
|
253
|
+
readonly promptPickedIds: ReadonlySet<string>;
|
|
254
|
+
setPromptPicked(id: string, picked: boolean): void;
|
|
253
255
|
/** Mark a prompt control's input as focused / unfocused. */
|
|
254
256
|
setPromptFocused(id: string, focused: boolean): void;
|
|
255
257
|
/** Pixel width of the bordered prompt field, keyed by control id. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const styles = css `
|
|
3
|
+
:host {
|
|
4
|
+
--nile-chart-min-height: var(--nile-height-200px, var(--ng-height-200px));
|
|
5
|
+
--nile-chart-bg: transparent;
|
|
6
|
+
--nile-chart-border-radius: 0;
|
|
7
|
+
--nile-chart-border: none;
|
|
8
|
+
--nile-chart-shadow: none;
|
|
9
|
+
--nile-chart-padding: 0;
|
|
10
|
+
--nile-chart-loading-color: var(--nile-colors-neutral-700, var(--ng-colors-text-secondary-700));
|
|
11
|
+
--nile-chart-loading-font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));
|
|
12
|
+
--nile-chart-loading-font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
|
|
13
|
+
--nile-chart-loading-bg: transparent;
|
|
14
|
+
display: block;
|
|
15
|
+
width: 100%;
|
|
16
|
+
height: 100%;
|
|
17
|
+
position: relative;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
:host([hidden]) {
|
|
21
|
+
display: none;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.chart-container {
|
|
25
|
+
width: 100%;
|
|
26
|
+
height: 100%;
|
|
27
|
+
min-height: var(--nile-chart-min-height);
|
|
28
|
+
background: var(--nile-chart-bg);
|
|
29
|
+
border-radius: var(--nile-chart-border-radius);
|
|
30
|
+
border: var(--nile-chart-border);
|
|
31
|
+
box-shadow: var(--nile-chart-shadow);
|
|
32
|
+
padding: var(--nile-chart-padding);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.chart-loading {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
min-height: inherit;
|
|
40
|
+
color: var(--nile-chart-loading-color);
|
|
41
|
+
font-family: var(--nile-chart-loading-font-family);
|
|
42
|
+
font-size: var(--nile-chart-loading-font-size);
|
|
43
|
+
background: var(--nile-chart-loading-bg);
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
//# sourceMappingURL=nile-forecast-chart.css.js.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import type Highcharts from 'highcharts';
|
|
3
|
+
import NileElement from '../internal/nile-element.js';
|
|
4
|
+
import type { SeparatedChartConfigInputType } from '../internal/types/separated-chart-config-input.type.js';
|
|
5
|
+
import type { LegendConfig } from '../internal/types/index.js';
|
|
6
|
+
export type ForecastPoint = [number, number];
|
|
7
|
+
export type ForecastSeriesType = 'line' | 'spline' | 'area' | 'areaspline' | 'column';
|
|
8
|
+
export type ForecastDashStyle = Highcharts.DashStyleValue;
|
|
9
|
+
export interface ForecastSeriesData {
|
|
10
|
+
name: string;
|
|
11
|
+
data: ForecastPoint[];
|
|
12
|
+
type?: ForecastSeriesType;
|
|
13
|
+
axis?: 'primary' | 'secondary';
|
|
14
|
+
color?: string;
|
|
15
|
+
forecastColor?: string;
|
|
16
|
+
forecastDashStyle?: ForecastDashStyle;
|
|
17
|
+
valueSuffix?: string;
|
|
18
|
+
lineWidth?: number;
|
|
19
|
+
showMarkers?: boolean;
|
|
20
|
+
fillOpacity?: number;
|
|
21
|
+
}
|
|
22
|
+
export declare const FORECAST_NOW_LINE_COLOR = "var(--nile-colors-primary-600, var(--ng-colors-fg-brand-primary-600))";
|
|
23
|
+
export declare class NileForecastChart extends NileElement {
|
|
24
|
+
static styles: CSSResultGroup;
|
|
25
|
+
private _hc;
|
|
26
|
+
private chart;
|
|
27
|
+
private resizeObserver;
|
|
28
|
+
private chartContainer;
|
|
29
|
+
config: SeparatedChartConfigInputType | null;
|
|
30
|
+
chartTitle: string;
|
|
31
|
+
chartSubtitle: string;
|
|
32
|
+
data: ForecastSeriesData[];
|
|
33
|
+
forecastData: ForecastSeriesData[];
|
|
34
|
+
options: Highcharts.Options;
|
|
35
|
+
loading: boolean;
|
|
36
|
+
height: string;
|
|
37
|
+
forecastStart: number | null;
|
|
38
|
+
forecastDashStyle: ForecastDashStyle;
|
|
39
|
+
showNowLine: boolean;
|
|
40
|
+
nowLabel: string;
|
|
41
|
+
nowLineColor: string;
|
|
42
|
+
forecastBandLabel: string;
|
|
43
|
+
forecastBandColor: string;
|
|
44
|
+
xAxisTitle: string;
|
|
45
|
+
yAxisTitle: string;
|
|
46
|
+
secondaryAxisTitle: string;
|
|
47
|
+
secondaryAxisMin: number | null;
|
|
48
|
+
timezone: string;
|
|
49
|
+
zoom: boolean;
|
|
50
|
+
showLegend: boolean;
|
|
51
|
+
legend: LegendConfig | null;
|
|
52
|
+
chartBg: string;
|
|
53
|
+
chartBorderRadius: string | number;
|
|
54
|
+
chartBorder: string;
|
|
55
|
+
chartShadow: string;
|
|
56
|
+
chartPadding: string | number;
|
|
57
|
+
chartMinHeight: string | number;
|
|
58
|
+
loadingText: string;
|
|
59
|
+
loadingColor: string;
|
|
60
|
+
loadingFontSize: string | number;
|
|
61
|
+
loadingFontFamily: string;
|
|
62
|
+
loadingBg: string;
|
|
63
|
+
private _syncCssVars;
|
|
64
|
+
private applyConfig;
|
|
65
|
+
connectedCallback(): void;
|
|
66
|
+
disconnectedCallback(): void;
|
|
67
|
+
protected firstUpdated(): void;
|
|
68
|
+
protected updated(changedProperties: PropertyValues): void;
|
|
69
|
+
setForecast(series: ForecastSeriesData[], forecastStart?: number | null): void;
|
|
70
|
+
clearForecast(): void;
|
|
71
|
+
private startFromSetForecast;
|
|
72
|
+
private zoomed;
|
|
73
|
+
private setZoomed;
|
|
74
|
+
private xExtremes;
|
|
75
|
+
resetZoom(): void;
|
|
76
|
+
private observedContainer;
|
|
77
|
+
private syncResizeObserver;
|
|
78
|
+
private resolveSeries;
|
|
79
|
+
private lastTimestamp;
|
|
80
|
+
private buildOptions;
|
|
81
|
+
private initInFlight;
|
|
82
|
+
private initChart;
|
|
83
|
+
private destroyChart;
|
|
84
|
+
render(): TemplateResult;
|
|
85
|
+
}
|
|
86
|
+
declare global {
|
|
87
|
+
interface HTMLElementTagNameMap {
|
|
88
|
+
'nile-forecast-chart': NileForecastChart;
|
|
89
|
+
}
|
|
90
|
+
}
|