@aquera/nile-visualization 2.9.26 → 2.9.27
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/nile-chart/nile-chart-config.d.ts +1 -0
- package/dist/src/nile-chart/nile-chart.css.js +14 -0
- package/dist/src/nile-chart/nile-chart.d.ts +1 -2
- package/dist/src/nile-chart/nile-chart.js +20 -25
- package/dist/src/nile-filter-chart/nile-filter-chart.css.js +32 -14
- package/dist/src/nile-filter-chart/nile-filter-chart.d.ts +1 -0
- package/dist/src/nile-filter-chart/nile-filter-chart.js +8 -0
- package/dist/src/nile-filter-chart/utils/date-picker.d.ts +3 -0
- package/dist/src/nile-filter-chart/utils/date-picker.js +95 -0
- package/dist/src/nile-filter-chart/utils/types.d.ts +5 -117
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,6 +35,10 @@ To run a local development server that serves the basic demo located in `demo/in
|
|
|
35
35
|
## Release Notes
|
|
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
|
+
#### Version 2.9.27 (July 15, 2026)
|
|
39
|
+
- Nile Filter Chart: Added the `date-picker` control variant — set `variant: 'date-picker'` on a filter control to render a calendar field. Configurable via `selection` (`single` for one date, `multi` for a start/end range), `dateFormat` (default `MM/DD/YYYY`), `dateType` (`absolute` | `relative`), `hideDateTypes` (lock the absolute/relative switcher), `showClearButton`, and `hoist` (switch the popup to `position: fixed` to escape a clipping ancestor). The date-picker fills its container — size it by constraining the wrapping element. See `src/nile-filter-chart/date-picker.md` (UIF-1298)
|
|
40
|
+
- Nile Chart: Added the `noPadding` config option — set `noPadding: true` on the chart config to remove the chart body padding and drop the card's own border/shadow, so the content sits flush to the card edges (the card becomes a transparent, layout-only wrapper); reflected as the `no-padding` attribute (UIF-1298)
|
|
41
|
+
|
|
38
42
|
#### Version 2.9.26 (July 14, 2026)
|
|
39
43
|
- Nile Chart: Exposed CSS `part`s across the chart shell so consumers can style internals via `::part()` — the card (`chart-card`, `chart-body`, `chart-inner`), header (`header`, `header-titles`, `header-title`, `header-subtitle`, `header-actions`), reset-zoom control (`reset-zoom-tooltip`, `reset-zoom`, `reset-zoom-glyph`), AI affordances (`ai-trigger`, `ai-trigger-glyph`, `ai-panel`, `ai-panel-content`), and the actions menu (`menu-anchor`, `menu-trigger`, `menu-trigger-glyph`, `menu`, `menu-separator`, `menu-group-header`, `menu-item-glyph`, and `menu-item` with kind-specific sub-parts `type`, `custom`, `fullscreen`, `print`, `download-png`, `download-svg`, `download-csv`) (UIF-1304)
|
|
40
44
|
|
|
@@ -155,6 +155,7 @@ export interface NileChartConfigBase {
|
|
|
155
155
|
/** Font size for the header subtitle (number → px, or any CSS length string). */
|
|
156
156
|
subtitleFontSize?: string | number;
|
|
157
157
|
noHeader?: boolean;
|
|
158
|
+
noPadding?: boolean;
|
|
158
159
|
height?: string;
|
|
159
160
|
loading?: boolean;
|
|
160
161
|
options?: import('highcharts').Options;
|
|
@@ -87,6 +87,9 @@ export const styles = css `
|
|
|
87
87
|
position: relative;
|
|
88
88
|
container-type: inline-size;
|
|
89
89
|
}
|
|
90
|
+
:host([data-active-type='filter'][data-has-date-picker]) {
|
|
91
|
+
container-type: normal;
|
|
92
|
+
}
|
|
90
93
|
|
|
91
94
|
:host([hidden]) {
|
|
92
95
|
display: none;
|
|
@@ -234,6 +237,17 @@ export const styles = css `
|
|
|
234
237
|
padding-top: 0;
|
|
235
238
|
}
|
|
236
239
|
|
|
240
|
+
:host([no-padding]) .nile-chart-inner {
|
|
241
|
+
padding: 0;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
:host([no-padding]) .nile-chart-card,
|
|
245
|
+
:host([no-padding]) .nile-chart-card:hover {
|
|
246
|
+
border: none;
|
|
247
|
+
box-shadow: none;
|
|
248
|
+
border-radius: 0;
|
|
249
|
+
}
|
|
250
|
+
|
|
237
251
|
/* Grid layout:
|
|
238
252
|
- card uses clip-path (not overflow:hidden) so position:sticky on the header is not broken
|
|
239
253
|
- height goes on nile-data-grid itself so .scroll-container inside shadow DOM scrolls,
|
|
@@ -100,6 +100,7 @@ export declare class NileChart extends NileElement {
|
|
|
100
100
|
*/
|
|
101
101
|
loading: boolean;
|
|
102
102
|
noHeader: boolean;
|
|
103
|
+
noPadding: boolean;
|
|
103
104
|
appearance: string | null;
|
|
104
105
|
/**
|
|
105
106
|
* When set, fills `chart.type` if the config omits it (same values as `chart.type`, e.g. `stacked`, `pie`).
|
|
@@ -151,8 +152,6 @@ export declare class NileChart extends NileElement {
|
|
|
151
152
|
addAiResponse(text: string): void;
|
|
152
153
|
private handleAiSend;
|
|
153
154
|
private switchType;
|
|
154
|
-
/** Single-control filter chart where the in-body label should be promoted to the chart header. */
|
|
155
|
-
private get isPromotableFilter();
|
|
156
155
|
private get headerTitle();
|
|
157
156
|
private get headerSubtitle();
|
|
158
157
|
/** Normalize a numeric (→px) or string dimension to a CSS length. */
|
|
@@ -177,6 +177,7 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
177
177
|
*/
|
|
178
178
|
this.loading = false;
|
|
179
179
|
this.noHeader = false;
|
|
180
|
+
this.noPadding = false;
|
|
180
181
|
this.appearance = null;
|
|
181
182
|
/**
|
|
182
183
|
* When set, fills `chart.type` if the config omits it (same values as `chart.type`, e.g. `stacked`, `pie`).
|
|
@@ -301,9 +302,22 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
301
302
|
const cfgNoHeader = resolved.noHeader === true || minimalFilter;
|
|
302
303
|
if (cfgNoHeader && !this.noHeader)
|
|
303
304
|
this.noHeader = true;
|
|
305
|
+
if (this.noPadding !== (resolved.noPadding === true))
|
|
306
|
+
this.noPadding = resolved.noPadding === true;
|
|
304
307
|
if (resolved.appearance && this.appearance !== resolved.appearance)
|
|
305
308
|
this.appearance = resolved.appearance;
|
|
306
309
|
}
|
|
310
|
+
if (this.activeType) {
|
|
311
|
+
this.setAttribute('data-active-type', this.activeType);
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
this.removeAttribute('data-active-type');
|
|
315
|
+
}
|
|
316
|
+
const cfg = this.activeConfig;
|
|
317
|
+
const hasDatePicker = this.activeType === 'filter'
|
|
318
|
+
&& Array.isArray(cfg?.controls)
|
|
319
|
+
&& cfg.controls.some(c => c?.variant === 'date-picker');
|
|
320
|
+
this.toggleAttribute('data-has-date-picker', hasDatePicker);
|
|
307
321
|
// Keep truncated-title focusability in sync after any re-render.
|
|
308
322
|
this._syncHeaderTruncationA11y();
|
|
309
323
|
}
|
|
@@ -345,32 +359,11 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
345
359
|
config: converted,
|
|
346
360
|
});
|
|
347
361
|
}
|
|
348
|
-
/** Single-control filter chart where the in-body label should be promoted to the chart header. */
|
|
349
|
-
get isPromotableFilter() {
|
|
350
|
-
const cfg = (this.activeConfig ?? this.resolvedConfig);
|
|
351
|
-
return cfg?.type === 'filter'
|
|
352
|
-
&& Array.isArray(cfg?.controls)
|
|
353
|
-
&& cfg.controls.length === 1;
|
|
354
|
-
}
|
|
355
362
|
get headerTitle() {
|
|
356
|
-
|
|
357
|
-
if (explicit)
|
|
358
|
-
return explicit;
|
|
359
|
-
if (this.isPromotableFilter) {
|
|
360
|
-
const cfg = (this.activeConfig ?? this.resolvedConfig);
|
|
361
|
-
return cfg.controls[0]?.label ?? '';
|
|
362
|
-
}
|
|
363
|
-
return '';
|
|
363
|
+
return this.activeConfig?.chartTitle ?? this.resolvedConfig?.chartTitle ?? '';
|
|
364
364
|
}
|
|
365
365
|
get headerSubtitle() {
|
|
366
|
-
|
|
367
|
-
if (explicit)
|
|
368
|
-
return explicit;
|
|
369
|
-
if (this.isPromotableFilter) {
|
|
370
|
-
const cfg = (this.activeConfig ?? this.resolvedConfig);
|
|
371
|
-
return cfg.controls[0]?.description ?? '';
|
|
372
|
-
}
|
|
373
|
-
return '';
|
|
366
|
+
return this.activeConfig?.chartSubtitle ?? this.resolvedConfig?.chartSubtitle ?? '';
|
|
374
367
|
}
|
|
375
368
|
/** Normalize a numeric (→px) or string dimension to a CSS length. */
|
|
376
369
|
static toCssSize(value) {
|
|
@@ -1927,13 +1920,12 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
1927
1920
|
></nile-data-grid>`;
|
|
1928
1921
|
}
|
|
1929
1922
|
case 'filter': {
|
|
1930
|
-
const promote = this.isPromotableFilter;
|
|
1931
1923
|
const filterConfig = this.aiBorder
|
|
1932
1924
|
? { ...config, controls: config.controls.map(c => ({ ...c, aiBorder: c.aiBorder ?? true })) }
|
|
1933
1925
|
: config;
|
|
1934
1926
|
return html `<nile-filter-chart
|
|
1935
1927
|
.config=${{ chart: filterConfig }}
|
|
1936
|
-
?
|
|
1928
|
+
?no-padding=${this.noPadding}
|
|
1937
1929
|
@nile-change="${(e) => this.emit('nile-change', e.detail)}"
|
|
1938
1930
|
></nile-filter-chart>`;
|
|
1939
1931
|
}
|
|
@@ -2005,6 +1997,9 @@ __decorate([
|
|
|
2005
1997
|
__decorate([
|
|
2006
1998
|
property({ type: Boolean, reflect: true, attribute: 'no-header' })
|
|
2007
1999
|
], NileChart.prototype, "noHeader", void 0);
|
|
2000
|
+
__decorate([
|
|
2001
|
+
property({ type: Boolean, reflect: true, attribute: 'no-padding' })
|
|
2002
|
+
], NileChart.prototype, "noPadding", void 0);
|
|
2008
2003
|
__decorate([
|
|
2009
2004
|
property({ type: String, reflect: true })
|
|
2010
2005
|
], NileChart.prototype, "appearance", void 0);
|
|
@@ -84,7 +84,11 @@ export const styles = css `
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
:host([appearance="minimal"]) .fc-control {
|
|
87
|
-
padding: var(--nile-spacing-
|
|
87
|
+
padding: var(--nile-spacing-sm, var(--ng-spacing-sm));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
:host([no-padding]) .fc-control {
|
|
91
|
+
padding: 0;
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
.fc-control__label {
|
|
@@ -116,13 +120,13 @@ export const styles = css `
|
|
|
116
120
|
.fc-badge-group {
|
|
117
121
|
display: flex;
|
|
118
122
|
flex-wrap: wrap;
|
|
119
|
-
gap: var(--nile-spacing-
|
|
123
|
+
gap: var(--nile-spacing-sm, var(--ng-spacing-sm));
|
|
120
124
|
}
|
|
121
125
|
|
|
122
126
|
.fc-badge {
|
|
123
127
|
display: inline-flex;
|
|
124
128
|
align-items: center;
|
|
125
|
-
gap: var(--nile-spacing-
|
|
129
|
+
gap: var(--nile-spacing-sm, var(--ng-spacing-sm));
|
|
126
130
|
padding: var(--nile-spacing-4px, var(--ng-spacing-xs)) var(--nile-spacing-14px, var(--ng-spacing-lg-alt));
|
|
127
131
|
border-radius: var(--nile-radius-full, var(--ng-radius-full));
|
|
128
132
|
font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));
|
|
@@ -157,6 +161,20 @@ export const styles = css `
|
|
|
157
161
|
border: 1.5px solid var(--nile-colors-transparent, var(--ng-color-base-transparent));
|
|
158
162
|
}
|
|
159
163
|
|
|
164
|
+
.fc-cal-dd {
|
|
165
|
+
display: block;
|
|
166
|
+
width: 100%;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.fc-cal-trigger {
|
|
170
|
+
width: 100%;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.fc-cal-trigger__icon {
|
|
174
|
+
color: var(--nile-colors-neutral-700, var(--ng-colors-text-quaternary-500));
|
|
175
|
+
flex-shrink: 0;
|
|
176
|
+
}
|
|
177
|
+
|
|
160
178
|
/* ── Slider ─── */
|
|
161
179
|
.fc-slider-wrap { display: flex; flex-direction: column; gap: var(--nile-spacing-10px, var(--ng-spacing-md-alt)); }
|
|
162
180
|
|
|
@@ -187,7 +205,7 @@ export const styles = css `
|
|
|
187
205
|
|
|
188
206
|
nile-slider::part(range) {
|
|
189
207
|
width: 100%;
|
|
190
|
-
height: var(--nile-spacing-
|
|
208
|
+
height: var(--nile-spacing-sm, var(--ng-spacing-sm));
|
|
191
209
|
}
|
|
192
210
|
|
|
193
211
|
nile-slider::part(range-completed) {
|
|
@@ -242,7 +260,7 @@ export const styles = css `
|
|
|
242
260
|
color: var(--nile-colors-white-base, var(--ng-color-base-white));
|
|
243
261
|
background: var(--nile-colors-neutral-700, var(--ng-color-graylightmode-700));
|
|
244
262
|
border-radius: var(--nile-radius-sm, var(--ng-radius-xs));
|
|
245
|
-
padding: 3px var(--nile-spacing-
|
|
263
|
+
padding: 3px var(--nile-spacing-sm, var(--ng-spacing-sm));
|
|
246
264
|
letter-spacing: 0.05em;
|
|
247
265
|
}
|
|
248
266
|
|
|
@@ -269,7 +287,7 @@ export const styles = css `
|
|
|
269
287
|
.fc-threshold-field {
|
|
270
288
|
display: flex;
|
|
271
289
|
flex-direction: column;
|
|
272
|
-
gap: var(--nile-spacing-
|
|
290
|
+
gap: var(--nile-spacing-sm, var(--ng-spacing-sm));
|
|
273
291
|
}
|
|
274
292
|
|
|
275
293
|
.fc-threshold-field-label {
|
|
@@ -287,7 +305,7 @@ export const styles = css `
|
|
|
287
305
|
.fc-threshold-where {
|
|
288
306
|
flex-shrink: 0;
|
|
289
307
|
align-self: flex-end;
|
|
290
|
-
margin-bottom: var(--nile-spacing-
|
|
308
|
+
margin-bottom: var(--nile-spacing-sm, var(--ng-spacing-sm));
|
|
291
309
|
font-size: 11px;
|
|
292
310
|
font-weight: var(--nile-font-weight-bold, var(--ng-font-weight-700));
|
|
293
311
|
letter-spacing: 0.06em;
|
|
@@ -300,7 +318,7 @@ export const styles = css `
|
|
|
300
318
|
.fc-threshold-preview {
|
|
301
319
|
display: flex;
|
|
302
320
|
align-items: center;
|
|
303
|
-
gap: var(--nile-spacing-
|
|
321
|
+
gap: var(--nile-spacing-sm, var(--ng-spacing-sm));
|
|
304
322
|
padding: var(--nile-spacing-md, var(--ng-spacing-md)) var(--nile-spacing-lg, var(--ng-spacing-lg));
|
|
305
323
|
border-radius: var(--nile-radius-radius-lg, var(--ng-radius-sm));
|
|
306
324
|
background: var(--nile-colors-primary-100, var(--ng-colors-bg-brand-primary));
|
|
@@ -322,7 +340,7 @@ export const styles = css `
|
|
|
322
340
|
.fc-preset-list {
|
|
323
341
|
display: flex;
|
|
324
342
|
flex-direction: column;
|
|
325
|
-
gap: var(--nile-spacing-
|
|
343
|
+
gap: var(--nile-spacing-sm, var(--ng-spacing-sm));
|
|
326
344
|
}
|
|
327
345
|
|
|
328
346
|
.fc-preset-item {
|
|
@@ -423,8 +441,8 @@ export const styles = css `
|
|
|
423
441
|
.fc-prompt__error {
|
|
424
442
|
display: flex;
|
|
425
443
|
align-items: center;
|
|
426
|
-
gap: var(--nile-spacing-
|
|
427
|
-
margin-top: var(--nile-spacing-
|
|
444
|
+
gap: var(--nile-spacing-sm, var(--ng-spacing-sm));
|
|
445
|
+
margin-top: var(--nile-spacing-sm, var(--ng-spacing-sm));
|
|
428
446
|
padding: 0 var(--nile-spacing-2px, var(--ng-spacing-xxs));
|
|
429
447
|
color: var(--ng-colors-text-error-primary-600);
|
|
430
448
|
font-size: var(--nile-type-scale-2, var(--ng-font-size-text-xs));
|
|
@@ -504,7 +522,7 @@ export const styles = css `
|
|
|
504
522
|
padding: 0 var(--nile-spacing-xl, var(--ng-spacing-xl));
|
|
505
523
|
font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));
|
|
506
524
|
letter-spacing: 0.03em;
|
|
507
|
-
gap: var(--nile-spacing-
|
|
525
|
+
gap: var(--nile-spacing-sm, var(--ng-spacing-sm));
|
|
508
526
|
}
|
|
509
527
|
|
|
510
528
|
.fc-prompt__mode-icon {
|
|
@@ -572,7 +590,7 @@ export const styles = css `
|
|
|
572
590
|
min-width: 0;
|
|
573
591
|
display: flex;
|
|
574
592
|
align-items: center;
|
|
575
|
-
gap: var(--nile-spacing-
|
|
593
|
+
gap: var(--nile-spacing-sm, var(--ng-spacing-sm));
|
|
576
594
|
width: 100%;
|
|
577
595
|
}
|
|
578
596
|
.fc-prompt__field-input {
|
|
@@ -752,7 +770,7 @@ export const styles = css `
|
|
|
752
770
|
/* ── Clear icon — nile-button variant="ghost" sibling of the input. ─── */
|
|
753
771
|
.fc-prompt__clear-icon {
|
|
754
772
|
flex-shrink: 0;
|
|
755
|
-
margin-right: var(--nile-spacing-
|
|
773
|
+
margin-right: var(--nile-spacing-sm, var(--ng-spacing-sm));
|
|
756
774
|
line-height: 0;
|
|
757
775
|
}
|
|
758
776
|
|
|
@@ -8,6 +8,7 @@ export declare class NileFilterChart extends NileElement implements FilterChartH
|
|
|
8
8
|
/** When set, the host (e.g. nile-chart) is already rendering the control's label/description
|
|
9
9
|
* in its own header — skip the in-body copies to avoid duplication. */
|
|
10
10
|
hideControlHeaders: boolean;
|
|
11
|
+
noPadding: boolean;
|
|
11
12
|
/**
|
|
12
13
|
* Visual appearance. `'minimal'` collapses control padding to 6px for
|
|
13
14
|
* compact layouts; default (`'default'` or omitted) keeps the standard
|
|
@@ -13,6 +13,7 @@ import { renderSearch } from './utils/search.js';
|
|
|
13
13
|
import { renderComparison } from './utils/comparison.js';
|
|
14
14
|
import { renderThreshold } from './utils/threshold.js';
|
|
15
15
|
import { renderPreset } from './utils/preset.js';
|
|
16
|
+
import { renderDatePicker } from './utils/date-picker.js';
|
|
16
17
|
import { renderPrompt, validatePromptExpression } from './utils/prompt.js';
|
|
17
18
|
// Lowercase + ASCII-safe slug used to derive a control's `id` from its
|
|
18
19
|
// `label` when the author hasn't provided one explicitly.
|
|
@@ -24,6 +25,7 @@ let NileFilterChart = NileFilterChart_1 = class NileFilterChart extends NileElem
|
|
|
24
25
|
/** When set, the host (e.g. nile-chart) is already rendering the control's label/description
|
|
25
26
|
* in its own header — skip the in-body copies to avoid duplication. */
|
|
26
27
|
this.hideControlHeaders = false;
|
|
28
|
+
this.noPadding = false;
|
|
27
29
|
/**
|
|
28
30
|
* Visual appearance. `'minimal'` collapses control padding to 6px for
|
|
29
31
|
* compact layouts; default (`'default'` or omitted) keeps the standard
|
|
@@ -515,6 +517,9 @@ let NileFilterChart = NileFilterChart_1 = class NileFilterChart extends NileElem
|
|
|
515
517
|
case 'preset':
|
|
516
518
|
body = renderPreset(this, ctrl);
|
|
517
519
|
break;
|
|
520
|
+
case 'date-picker':
|
|
521
|
+
body = renderDatePicker(this, ctrl);
|
|
522
|
+
break;
|
|
518
523
|
case 'prompt':
|
|
519
524
|
body = renderPrompt(this, ctrl);
|
|
520
525
|
break;
|
|
@@ -621,6 +626,9 @@ __decorate([
|
|
|
621
626
|
__decorate([
|
|
622
627
|
property({ type: Boolean, attribute: 'hide-control-headers', reflect: true })
|
|
623
628
|
], NileFilterChart.prototype, "hideControlHeaders", void 0);
|
|
629
|
+
__decorate([
|
|
630
|
+
property({ type: Boolean, attribute: 'no-padding', reflect: true })
|
|
631
|
+
], NileFilterChart.prototype, "noPadding", void 0);
|
|
624
632
|
__decorate([
|
|
625
633
|
property({ type: String, reflect: true })
|
|
626
634
|
], NileFilterChart.prototype, "appearance", void 0);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
function formatDate(v) {
|
|
3
|
+
if (v === null || v === undefined || v === '')
|
|
4
|
+
return '';
|
|
5
|
+
const d = v instanceof Date ? v : new Date(v);
|
|
6
|
+
if (Number.isNaN(d.getTime()))
|
|
7
|
+
return typeof v === 'string' ? v : '';
|
|
8
|
+
return `${d.getDate()} ${d.toLocaleString('en-US', { month: 'short' })}`;
|
|
9
|
+
}
|
|
10
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
11
|
+
function toLocalSeed(v) {
|
|
12
|
+
if (v instanceof Date) {
|
|
13
|
+
if (Number.isNaN(v.getTime()))
|
|
14
|
+
return '';
|
|
15
|
+
return `${v.getFullYear()}-${pad(v.getMonth() + 1)}-${pad(v.getDate())}T`
|
|
16
|
+
+ `${pad(v.getHours())}:${pad(v.getMinutes())}:${pad(v.getSeconds())}`;
|
|
17
|
+
}
|
|
18
|
+
return typeof v === 'string' ? v : '';
|
|
19
|
+
}
|
|
20
|
+
function toSingleSeed(v) {
|
|
21
|
+
if (v === null || v === undefined || v === '')
|
|
22
|
+
return '';
|
|
23
|
+
if (typeof v === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(v.trim())) {
|
|
24
|
+
return `${v.trim()}T12:00:00`;
|
|
25
|
+
}
|
|
26
|
+
const d = v instanceof Date ? v : typeof v === 'string' ? new Date(v) : null;
|
|
27
|
+
if (!d || Number.isNaN(d.getTime()))
|
|
28
|
+
return '';
|
|
29
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T12:00:00`;
|
|
30
|
+
}
|
|
31
|
+
const hasRangeShape = (v) => !!v && typeof v === 'object' && ('startDate' in v || 'endDate' in v);
|
|
32
|
+
export function renderDatePicker(host, ctrl) {
|
|
33
|
+
const isRelative = ctrl.dateType === 'relative';
|
|
34
|
+
// relative windows need range=true so nile-calendar renders Apply (its emit path)
|
|
35
|
+
const isRange = ctrl.selection === 'multi' || isRelative;
|
|
36
|
+
const raw = host.selectedValues.get(ctrl.id);
|
|
37
|
+
const range = hasRangeShape(raw) ? raw : {};
|
|
38
|
+
let seed = '';
|
|
39
|
+
if (isRange) {
|
|
40
|
+
const s = toLocalSeed(range.startDate);
|
|
41
|
+
const e = toLocalSeed(range.endDate);
|
|
42
|
+
if (s && e)
|
|
43
|
+
seed = JSON.stringify({ startDate: s, endDate: e });
|
|
44
|
+
}
|
|
45
|
+
else if (!hasRangeShape(raw)) {
|
|
46
|
+
seed = toSingleSeed(raw);
|
|
47
|
+
}
|
|
48
|
+
const label = hasRangeShape(raw)
|
|
49
|
+
? [formatDate(range.startDate), formatDate(range.endDate)].filter(Boolean).join(' - ')
|
|
50
|
+
: formatDate(raw);
|
|
51
|
+
const placeholder = ctrl.placeholders?.[0] ?? (isRange ? 'Select date range…' : 'Select date…');
|
|
52
|
+
const onChange = (e) => {
|
|
53
|
+
e.stopPropagation();
|
|
54
|
+
const d = e.detail ?? {};
|
|
55
|
+
if (isRange || hasRangeShape(d)) {
|
|
56
|
+
host.setValue(ctrl.id, { startDate: d.startDate ?? null, endDate: d.endDate ?? null });
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
host.setValue(ctrl.id, d.value ?? '');
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
return html `
|
|
63
|
+
<nile-date-picker
|
|
64
|
+
part="date-picker"
|
|
65
|
+
class="fc-cal-dd"
|
|
66
|
+
.range="${isRange}"
|
|
67
|
+
.type="${ctrl.dateType ?? 'absolute'}"
|
|
68
|
+
?hideTypes="${ctrl.hideDateTypes ?? false}"
|
|
69
|
+
.allowClear="${ctrl.showClearButton ?? true}"
|
|
70
|
+
.hoist="${ctrl.hoist ?? false}"
|
|
71
|
+
?syncDatePicker="${!isRelative}"
|
|
72
|
+
value="${seed}"
|
|
73
|
+
.dateFormat="${ctrl.dateFormat ?? 'MM/DD/YYYY'}"
|
|
74
|
+
@nile-change="${onChange}"
|
|
75
|
+
@nile-clear="${(e) => {
|
|
76
|
+
e.stopPropagation();
|
|
77
|
+
host.setValue(ctrl.id, isRange ? { startDate: null, endDate: null } : '');
|
|
78
|
+
host.emit('nile-clear', { id: ctrl.id });
|
|
79
|
+
}}"
|
|
80
|
+
>
|
|
81
|
+
<nile-input
|
|
82
|
+
slot="trigger"
|
|
83
|
+
part="calendar-trigger"
|
|
84
|
+
class="fc-cal-trigger${label ? '' : ' fc-cal-trigger--empty'}"
|
|
85
|
+
size="small"
|
|
86
|
+
autocomplete="off"
|
|
87
|
+
.value="${label}"
|
|
88
|
+
placeholder="${placeholder}"
|
|
89
|
+
?readonly="${isRelative}"
|
|
90
|
+
>
|
|
91
|
+
<nile-glyph slot="prefix" class="fc-cal-trigger__icon" name="ng-calendar" size="16" method="stroke" aria-hidden="true"></nile-glyph>
|
|
92
|
+
</nile-input>
|
|
93
|
+
</nile-date-picker>`;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=date-picker.js.map
|
|
@@ -90,34 +90,8 @@ export interface QueryLanguageConfig {
|
|
|
90
90
|
validateOn?: 'change' | 'submit';
|
|
91
91
|
/** Optional hint text shown beneath the input describing the syntax. */
|
|
92
92
|
syntaxHint?: string;
|
|
93
|
-
/**
|
|
94
|
-
* Extra functions registered with filtrex on top of its built-in set
|
|
95
|
-
* (`abs`, `ceil`, `floor`, `log`, `log2`, `log10`, `max`, `min`, `round`,
|
|
96
|
-
* `sqrt`, `exists`, `empty`) and our project additions (`contains`,
|
|
97
|
-
* `startsWith`, `endsWith`, `lower`, `upper`, `len`, `isEmpty`,
|
|
98
|
-
* `isNotEmpty`, `between`, `year`, `month`, `day`, `daysAgo`, `matches`,
|
|
99
|
-
* `coalesce`).
|
|
100
|
-
*
|
|
101
|
-
* Example: `{ daysAgo: (d) => (Date.now() - +new Date(d)) / 86400000 }`
|
|
102
|
-
* Used in expressions like `daysAgo(lastSeen) < 7`.
|
|
103
|
-
*/
|
|
104
93
|
extraFunctions?: Record<string, (...args: any[]) => unknown>;
|
|
105
|
-
/**
|
|
106
|
-
* Constants made available to expressions without polluting the data
|
|
107
|
-
* object. `'pi'` (single-quoted in the expression) escapes the constant
|
|
108
|
-
* to fall back to data access.
|
|
109
|
-
*
|
|
110
|
-
* Example: `{ pi: Math.PI, currentUser: 'Birat' }` →
|
|
111
|
-
* `assignee == currentUser` resolves `currentUser` to `"Birat"`.
|
|
112
|
-
*/
|
|
113
94
|
constants?: Record<string, unknown>;
|
|
114
|
-
/**
|
|
115
|
-
* Override comparison / arithmetic operators. Use this to localise
|
|
116
|
-
* comparisons (e.g. case-insensitive string equality) or to plug in
|
|
117
|
-
* a domain-specific arithmetic.
|
|
118
|
-
*
|
|
119
|
-
* Example: `{ '==': (a, b) => String(a).toLowerCase() === String(b).toLowerCase() }`
|
|
120
|
-
*/
|
|
121
95
|
operators?: Partial<{
|
|
122
96
|
'+': (a: unknown, b: unknown) => unknown;
|
|
123
97
|
'-': (a: unknown, b?: unknown) => unknown;
|
|
@@ -133,37 +107,10 @@ export interface QueryLanguageConfig {
|
|
|
133
107
|
'>': (a: unknown, b: unknown) => boolean;
|
|
134
108
|
'~=': (a: unknown, b: unknown) => boolean;
|
|
135
109
|
}>;
|
|
136
|
-
/**
|
|
137
|
-
* Optional value-getter for accessing row properties. Filtrex calls
|
|
138
|
-
* this for every identifier reference. Default: dotted property
|
|
139
|
-
* access (`row.foo.bar` works out of the box).
|
|
140
|
-
*
|
|
141
|
-
* Override when your data model uses a Map / class / proxy that
|
|
142
|
-
* standard property access can't read. The fourth argument is the
|
|
143
|
-
* lookup type (`'unescaped'` for bare identifiers, `'single-quoted'`
|
|
144
|
-
* for `'foo-bar'` style).
|
|
145
|
-
*/
|
|
146
110
|
customProp?: (name: string, get: (key: string) => unknown, obj: unknown, type?: 'unescaped' | 'single-quoted') => unknown;
|
|
147
|
-
/**
|
|
148
|
-
* Convenience flag — turn on filtrex's bundled `useDotAccessOperator`
|
|
149
|
-
* customProp. Lets users type `foo.bar` instead of `bar of foo`.
|
|
150
|
-
* Mutually exclusive with a custom `customProp`.
|
|
151
|
-
*/
|
|
152
111
|
dotAccess?: boolean;
|
|
153
|
-
/**
|
|
154
|
-
* Convenience flag — turn on filtrex's bundled optional-chaining
|
|
155
|
-
* customProp. `a of b` (or `b.a` with `dotAccess`) returns `null`
|
|
156
|
-
* when the LHS is `null`/`undefined` instead of throwing.
|
|
157
|
-
* Mutually exclusive with a custom `customProp`.
|
|
158
|
-
*/
|
|
159
112
|
optionalChaining?: boolean;
|
|
160
113
|
}
|
|
161
|
-
/**
|
|
162
|
-
* Recursive ESTree-shaped node returned by the AST parser. The shape
|
|
163
|
-
* matches what `jsep` produces — a small, well-known JS-expression AST.
|
|
164
|
-
* Pure JSON: every field is a string, number, boolean, null, or another
|
|
165
|
-
* `QueryNode`, so `JSON.stringify` round-trips cleanly.
|
|
166
|
-
*/
|
|
167
114
|
export type QueryNode = {
|
|
168
115
|
type: 'Identifier';
|
|
169
116
|
name: string;
|
|
@@ -203,104 +150,45 @@ export type QueryNode = {
|
|
|
203
150
|
body: QueryNode[];
|
|
204
151
|
};
|
|
205
152
|
export type QueryJson = {
|
|
206
|
-
/** The exact string the user typed, retained for display / serialization. */
|
|
207
153
|
source: string;
|
|
208
154
|
ast: QueryNode;
|
|
209
155
|
};
|
|
210
|
-
/**
|
|
211
|
-
* Detail emitted with `nile-change`.
|
|
212
|
-
*
|
|
213
|
-
* `filters[id]` shape depends on the variant + (for prompts) the runtime mode:
|
|
214
|
-
* - any non-prompt variant → the variant's natural value
|
|
215
|
-
* - prompt in `'prompt'` mode → plain `string` (raw text)
|
|
216
|
-
* - prompt in `'expression'` mode,
|
|
217
|
-
* parse succeeded → `QueryJson` ({ source, ast }) — JSON-serializable
|
|
218
|
-
* - prompt in `'expression'` mode,
|
|
219
|
-
* pre-validation / parse fail → plain `string` (the typed text)
|
|
220
|
-
*
|
|
221
|
-
* `errors` and `evaluators` are populated for prompt controls in Expression mode.
|
|
222
|
-
*/
|
|
223
156
|
export type FilterChangeDetail = {
|
|
224
157
|
filters: Record<string, unknown>;
|
|
225
|
-
/** Map of control id → human-readable validation message. Present when at least one control failed validation. */
|
|
226
158
|
errors?: Record<string, string>;
|
|
227
|
-
/** Map of control id → compiled filtrex predicate. Present for prompt controls whose expression validated. */
|
|
228
159
|
evaluators?: Record<string, (row: unknown) => unknown>;
|
|
229
160
|
};
|
|
230
161
|
export interface FilterControl {
|
|
231
|
-
/**
|
|
232
|
-
* Unique key under which this control's value is emitted in
|
|
233
|
-
* `nile-change.detail.filters`. Optional — when omitted the component
|
|
234
|
-
* derives one from `label` (slugified) and appends a numeric suffix on
|
|
235
|
-
* collision, falling back to `ctrl_<index>` if `label` is also missing.
|
|
236
|
-
* Provide an explicit `id` when downstream code reads a stable key.
|
|
237
|
-
*/
|
|
238
162
|
id?: string;
|
|
239
163
|
label: string;
|
|
240
|
-
/** Optional subtitle shown below the label. */
|
|
241
164
|
description?: string;
|
|
242
165
|
selection: 'single' | 'multi';
|
|
243
|
-
variant: 'badge' | 'dropdown' | 'segmented' | 'radio' | 'toggle' | 'search' | 'comparison' | 'threshold' | 'preset' | 'prompt' | 'expression' | 'hybrid';
|
|
166
|
+
variant: 'badge' | 'dropdown' | 'segmented' | 'radio' | 'toggle' | 'search' | 'comparison' | 'threshold' | 'preset' | 'date-picker' | 'prompt' | 'expression' | 'hybrid';
|
|
244
167
|
options?: FilterOption[];
|
|
245
168
|
value?: string | string[] | number[] | boolean;
|
|
246
|
-
/**
|
|
247
|
-
* Placeholder text. Always an array — `placeholders[0]` is the initial /
|
|
248
|
-
* static placeholder used by every variant (search, dropdown, prompt).
|
|
249
|
-
* For the `prompt`, `hybrid`, and `expression` variants, additional
|
|
250
|
-
* entries are cycled through with a typewriter effect.
|
|
251
|
-
*
|
|
252
|
-
* For `hybrid`, you can supply mode-specific overrides via
|
|
253
|
-
* `promptPlaceholders` and `expressionPlaceholders`; when present they
|
|
254
|
-
* take precedence over `placeholders` for that mode.
|
|
255
|
-
*/
|
|
256
169
|
placeholders?: string[];
|
|
257
|
-
/**
|
|
258
|
-
* Hybrid variant only. Placeholder phrases used while the toggle is on
|
|
259
|
-
* the Prompt side. Cycled with the typewriter effect when multiple
|
|
260
|
-
* entries are provided. Falls back to `placeholders` when unset.
|
|
261
|
-
*/
|
|
262
170
|
promptPlaceholders?: string[];
|
|
263
|
-
/**
|
|
264
|
-
* Hybrid variant only. Placeholder phrases used while the toggle is on
|
|
265
|
-
* the Expression side. Cycled with the typewriter effect when multiple
|
|
266
|
-
* entries are provided. Falls back to `placeholders` when unset.
|
|
267
|
-
*/
|
|
268
171
|
expressionPlaceholders?: string[];
|
|
269
|
-
/** Typewriter speed in ms per character (default 60). */
|
|
270
172
|
typeSpeedMs?: number;
|
|
271
|
-
/** Pause before deleting a typed phrase (default 1400). */
|
|
272
173
|
pauseBeforeDeleteMs?: number;
|
|
273
|
-
/** Pause between phrases after deletion (default 400). */
|
|
274
174
|
pauseBetweenMs?: number;
|
|
275
175
|
queryLanguage?: QueryLanguageConfig;
|
|
276
176
|
gradientColors?: string[];
|
|
277
177
|
gradientDirection?: string;
|
|
278
178
|
gradientSpeedMs?: number;
|
|
279
179
|
aiBorder?: boolean;
|
|
280
|
-
/**
|
|
281
|
-
* Prompt variant only. Shows the inline clear (×) icon inside the input
|
|
282
|
-
* when the value is non-empty. Defaults to `false` (hidden). Set `true` to
|
|
283
|
-
* opt in.
|
|
284
|
-
*/
|
|
285
180
|
showClearIcon?: boolean;
|
|
286
|
-
/**
|
|
287
|
-
* Prompt variant only. Inline autocomplete suggestions shown below the
|
|
288
|
-
* input when the prompt is focused (Basic mode). Items are filtered
|
|
289
|
-
* client-side by case-insensitive substring match against the current
|
|
290
|
-
* input text.
|
|
291
|
-
*/
|
|
292
181
|
suggestions?: SuggestionItem[];
|
|
293
|
-
/**
|
|
294
|
-
* How a clicked suggestion is inserted into the input value.
|
|
295
|
-
* - `'replace'` (default) → suggestion's `value` replaces the entire input
|
|
296
|
-
* - `'append'` → appends the suggestion to the existing text (space-separated)
|
|
297
|
-
*/
|
|
298
182
|
suggestionInsert?: 'replace' | 'append';
|
|
299
183
|
suggestionTooltip?: boolean;
|
|
300
184
|
showClearButton?: boolean;
|
|
301
185
|
valueB?: string;
|
|
302
186
|
operator?: string;
|
|
303
187
|
thresholdValue?: number | string;
|
|
188
|
+
dateFormat?: string;
|
|
189
|
+
dateType?: 'absolute' | 'relative';
|
|
190
|
+
hideDateTypes?: boolean;
|
|
191
|
+
hoist?: boolean;
|
|
304
192
|
}
|
|
305
193
|
export interface FilterGroup {
|
|
306
194
|
type: 'group';
|