@akcelik/strct 0.28.0 → 0.29.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akcelik/strct",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "UIStruct — a standalone Angular component library with a tokenised, multi-palette theme system, built for datacenter / infrastructure management UIs.",
5
5
  "author": "Serkan Akcelik <serkan.akcelik@gmail.com>",
6
6
  "license": "MIT",
@@ -2240,7 +2240,8 @@ type StrctChartType = 'line' | 'area' | 'bar';
2240
2240
  type StrctChartCurve = 'smooth' | 'linear' | 'step';
2241
2241
  /** One series in a multi-series chart. */
2242
2242
  interface StrctChartSeries {
2243
- data: number[];
2243
+ /** Values; `null` (or `NaN`) marks a data gap — the line breaks, no interpolation. */
2244
+ data: (number | null)[];
2244
2245
  /** Legend + tooltip name. */
2245
2246
  label?: string;
2246
2247
  /** Per-series color; falls back to the chart's `status`. */
@@ -2255,6 +2256,24 @@ interface StrctChartSeries {
2255
2256
  * custom SVG dasharray string to tune it.
2256
2257
  */
2257
2258
  dash?: boolean | string;
2259
+ /**
2260
+ * Optional per-point lower/upper bound (e.g. min/max per downsampled bucket).
2261
+ * When both are set a soft band is filled between them behind the line, so
2262
+ * within-bucket spikes stay visible; the tooltip shows `avg (min–max)`.
2263
+ */
2264
+ lower?: (number | null)[];
2265
+ upper?: (number | null)[];
2266
+ }
2267
+ /** A vertical event / annotation marker anchored to a data index. */
2268
+ interface StrctChartAnnotation {
2269
+ /** X position as a data index. */
2270
+ index: number;
2271
+ /** Shown near the top of the line and in the tooltip at that index. */
2272
+ label?: string;
2273
+ /** Line color; default 'accent'. */
2274
+ status?: StrctChartStatus;
2275
+ /** Dashed line; default true. */
2276
+ dashed?: boolean;
2258
2277
  }
2259
2278
  /** A horizontal reference / threshold line. */
2260
2279
  interface StrctChartThreshold {
@@ -2274,12 +2293,15 @@ interface SeriesRender {
2274
2293
  label: string;
2275
2294
  area: boolean;
2276
2295
  dash: string | null;
2277
- pts: Pt[];
2296
+ pts: (Pt | null)[];
2278
2297
  path: string;
2279
2298
  areaPath: string;
2299
+ bandPath: string;
2280
2300
  /** Global x-offset (right-aligned) so shorter series line up on the right. */
2281
2301
  offset: number;
2282
- data: number[];
2302
+ data: (number | null)[];
2303
+ lower?: (number | null)[];
2304
+ upper?: (number | null)[];
2283
2305
  }
2284
2306
  /**
2285
2307
  * Single- or multi-series chart (line / area / bar). Dependency-free SVG,
@@ -2297,8 +2319,8 @@ interface SeriesRender {
2297
2319
  * <strct-chart [series]="[{data:inArr,label:'In'},{data:outArr,label:'Out'}]" legend />
2298
2320
  */
2299
2321
  declare class StrctChart {
2300
- /** Single-series data (or use `series`). */
2301
- readonly data: _angular_core.InputSignal<number[]>;
2322
+ /** Single-series data (or use `series`). `null` / `NaN` marks a gap — the line breaks. */
2323
+ readonly data: _angular_core.InputSignal<(number | null)[]>;
2302
2324
  /** Multiple series; when set it takes precedence over `data`. */
2303
2325
  readonly series: _angular_core.InputSignal<StrctChartSeries[] | null>;
2304
2326
  /** Visual type / variant. */
@@ -2355,6 +2377,28 @@ declare class StrctChart {
2355
2377
  * `[valueFormat]="v => v.toFixed(3) + ' %'"`. When null, the raw value is shown.
2356
2378
  */
2357
2379
  readonly valueFormat: _angular_core.InputSignal<((v: number) => string) | null>;
2380
+ /** Vertical event / annotation markers ("alarm raised", "deploy", …). */
2381
+ readonly annotations: _angular_core.InputSignal<StrctChartAnnotation[]>;
2382
+ /**
2383
+ * Drive the crosshair externally (e.g. mirror a sibling chart's hover for a
2384
+ * vCenter-style synced dashboard). A local pointer wins while over this chart.
2385
+ */
2386
+ readonly activeIndex: _angular_core.InputSignal<number | null>;
2387
+ /** Drag-select a range; the selection is emitted through `brushChange`. */
2388
+ readonly brush: _angular_core.InputSignalWithTransform<boolean, unknown>;
2389
+ /**
2390
+ * Drag-select **zooms into** the selected range (implies `brush`).
2391
+ * Double-click, Escape or the reset chip zooms back out.
2392
+ */
2393
+ readonly zoom: _angular_core.InputSignalWithTransform<boolean, unknown>;
2394
+ /** Tooltip text for a gap (null) point. */
2395
+ readonly gapText: _angular_core.InputSignal<string>;
2396
+ /** Accessible label of the reset-zoom chip (localizable). */
2397
+ readonly resetLabel: _angular_core.InputSignal<string>;
2398
+ /** Emits the hovered point index (or null on leave) — wire cross-chart sync with it. */
2399
+ readonly hoverIndex: _angular_core.OutputEmitterRef<number | null>;
2400
+ /** Emits the brushed [startIndex, endIndex] (inclusive), or null when cleared. */
2401
+ readonly brushChange: _angular_core.OutputEmitterRef<[number, number] | null>;
2358
2402
  protected readonly pad: {
2359
2403
  l: number;
2360
2404
  r: number;
@@ -2376,6 +2420,14 @@ declare class StrctChart {
2376
2420
  /** Reactive OS motion preference (tracks live changes, not just first load). */
2377
2421
  private readonly reduceMotion;
2378
2422
  protected readonly hoverIdx: _angular_core.WritableSignal<number | null>;
2423
+ protected readonly dispIdx: _angular_core.Signal<number | null>;
2424
+ private readonly viewRange;
2425
+ protected readonly brushDrag: _angular_core.WritableSignal<{
2426
+ a: number;
2427
+ b: number;
2428
+ } | null>;
2429
+ private readonly brushEnabled;
2430
+ protected readonly zoomed: _angular_core.Signal<boolean>;
2379
2431
  constructor();
2380
2432
  private readonly seriesResolved;
2381
2433
  protected readonly isMulti: _angular_core.Signal<boolean>;
@@ -2384,16 +2436,22 @@ declare class StrctChart {
2384
2436
  protected readonly isEmpty: _angular_core.Signal<boolean>;
2385
2437
  /** Number of x slots. */
2386
2438
  private readonly nx;
2439
+ /** Visible index window: the brush-zoom range, or the full data. */
2440
+ private readonly domain;
2387
2441
  /** Left padding: wider when the y-axis labels are shown. */
2388
2442
  protected readonly pl: _angular_core.Signal<number>;
2389
2443
  private chartW;
2390
2444
  private chartH;
2391
- /** Horizontal gap between two data points, in px. */
2445
+ /** Horizontal gap between two data points, in px (of the visible window). */
2392
2446
  private stepX;
2447
+ /** Real values inside the visible window (multi-aware; bands included). */
2448
+ private readonly visibleValues;
2393
2449
  private readonly yMax;
2394
2450
  private readonly yMin;
2395
2451
  private yOf;
2396
- protected readonly points: _angular_core.Signal<Pt[]>;
2452
+ protected readonly points: _angular_core.Signal<(Pt | null)[]>;
2453
+ /** Non-gap points only (dot rendering). */
2454
+ protected readonly dotPts: _angular_core.Signal<Pt[]>;
2397
2455
  protected readonly head: _angular_core.Signal<Pt | null>;
2398
2456
  private readonly plotPoints;
2399
2457
  protected readonly linePath: _angular_core.Signal<string>;
@@ -2430,17 +2488,19 @@ declare class StrctChart {
2430
2488
  protected readonly hoverX: _angular_core.Signal<number | null>;
2431
2489
  protected readonly hoverPt: _angular_core.Signal<Pt | null>;
2432
2490
  protected readonly hoverValue: _angular_core.Signal<number | "">;
2491
+ /** The hovered slot exists but holds a gap (single-series). */
2492
+ protected readonly hoverGap: _angular_core.Signal<boolean>;
2433
2493
  /** hoverValue run through valueFormat (unit / precision), else the raw value. */
2434
2494
  protected readonly hoverValueText: _angular_core.Signal<string>;
2435
2495
  /** Delta magnitude, formatted the same way so its unit matches the value. */
2436
2496
  protected readonly absDeltaText: _angular_core.Signal<string>;
2437
2497
  protected readonly hoverLabel: _angular_core.Signal<string>;
2438
- /** Change from the previous point (single-series; null at the first point). */
2498
+ /** Change from the previous point (single-series; null at the first point or across a gap). */
2439
2499
  protected readonly hoverDelta: _angular_core.Signal<number | null>;
2440
2500
  protected readonly absDelta: _angular_core.Signal<number>;
2441
2501
  /** Second tooltip line: "Xs ago" while live, else the x label. */
2442
2502
  protected readonly hoverMeta: _angular_core.Signal<string>;
2443
- /** Per-series value at the hovered index (multi-series tooltip). */
2503
+ /** Per-series value at the hovered index (multi-series tooltip; bands as `avg (min–max)`). */
2444
2504
  protected readonly hoverRows: _angular_core.Signal<{
2445
2505
  label: string;
2446
2506
  color: string;
@@ -2453,17 +2513,53 @@ declare class StrctChart {
2453
2513
  y: number;
2454
2514
  color: string;
2455
2515
  }[]>;
2516
+ protected readonly annotationLines: _angular_core.Signal<{
2517
+ x: number;
2518
+ color: string;
2519
+ dashed: boolean;
2520
+ label: string;
2521
+ index: number;
2522
+ }[]>;
2523
+ /** The annotation sitting exactly under the crosshair, if any. */
2524
+ protected readonly annAt: _angular_core.Signal<{
2525
+ x: number;
2526
+ color: string;
2527
+ dashed: boolean;
2528
+ label: string;
2529
+ index: number;
2530
+ } | null>;
2531
+ protected readonly brushRect: _angular_core.Signal<{
2532
+ x: number;
2533
+ w: number;
2534
+ } | null>;
2535
+ /** Zoom back out to the full data window (also emits `brushChange` null). */
2536
+ resetZoom(): void;
2456
2537
  /** Screen-reader summary of the whole chart (role="img" name). */
2457
2538
  protected readonly chartAria: _angular_core.Signal<string>;
2458
2539
  /** aria-live text announcing the hovered / keyboard-selected point. */
2459
2540
  protected readonly srText: _angular_core.Signal<string>;
2460
- /** Pixel x of a data index (shared by the plot and the x-axis labels). */
2541
+ /** Pixel x of a data index (shared by the plot, labels and annotations). */
2461
2542
  protected xOf(i: number): number;
2462
- /** Keyboard access to the crosshair: arrows walk the points. */
2543
+ /** Set the local hover index, emitting `hoverIndex` on change. */
2544
+ private setHover;
2545
+ protected onLeave(): void;
2546
+ /** Keyboard access: arrows walk the points; Escape unwinds brush → zoom → crosshair. */
2463
2547
  protected onKey(event: KeyboardEvent): void;
2548
+ /** Data index under the pointer, clamped to the visible window. */
2549
+ private idxAt;
2550
+ protected onDown(event: PointerEvent): void;
2464
2551
  protected onMove(event: PointerEvent): void;
2552
+ protected onUp(): void;
2553
+ protected onDblClick(): void;
2554
+ /**
2555
+ * The rendered chart as a standalone SVG string — theme colors resolved to
2556
+ * literals, background baked in, y-tick / x-label text included.
2557
+ */
2558
+ toSVG(): string;
2559
+ /** The chart as a PNG data URL at the given scale (default 2×). */
2560
+ toPNG(scale?: number): Promise<string>;
2465
2561
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<StrctChart, never>;
2466
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<StrctChart, "strct-chart", never, { "data": { "alias": "data"; "required": false; "isSignal": true; }; "series": { "alias": "series"; "required": false; "isSignal": true; }; "type": { "alias": "type"; "required": false; "isSignal": true; }; "curve": { "alias": "curve"; "required": false; "isSignal": true; }; "area": { "alias": "area"; "required": false; "isSignal": true; }; "glow": { "alias": "glow"; "required": false; "isSignal": true; }; "live": { "alias": "live"; "required": false; "isSignal": true; }; "interval": { "alias": "interval"; "required": false; "isSignal": true; }; "interactive": { "alias": "interactive"; "required": false; "isSignal": true; }; "strokeWidth": { "alias": "strokeWidth"; "required": false; "isSignal": true; }; "grid": { "alias": "grid"; "required": false; "isSignal": true; }; "dots": { "alias": "dots"; "required": false; "isSignal": true; }; "legend": { "alias": "legend"; "required": false; "isSignal": true; }; "labels": { "alias": "labels"; "required": false; "isSignal": true; }; "xTicks": { "alias": "xTicks"; "required": false; "isSignal": true; }; "xFormat": { "alias": "xFormat"; "required": false; "isSignal": true; }; "status": { "alias": "status"; "required": false; "isSignal": true; }; "height": { "alias": "height"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "yAxis": { "alias": "yAxis"; "required": false; "isSignal": true; }; "yTicks": { "alias": "yTicks"; "required": false; "isSignal": true; }; "axisFormat": { "alias": "axisFormat"; "required": false; "isSignal": true; }; "thresholds": { "alias": "thresholds"; "required": false; "isSignal": true; }; "emptyText": { "alias": "emptyText"; "required": false; "isSignal": true; }; "agoFormat": { "alias": "agoFormat"; "required": false; "isSignal": true; }; "valueFormat": { "alias": "valueFormat"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
2562
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<StrctChart, "strct-chart", never, { "data": { "alias": "data"; "required": false; "isSignal": true; }; "series": { "alias": "series"; "required": false; "isSignal": true; }; "type": { "alias": "type"; "required": false; "isSignal": true; }; "curve": { "alias": "curve"; "required": false; "isSignal": true; }; "area": { "alias": "area"; "required": false; "isSignal": true; }; "glow": { "alias": "glow"; "required": false; "isSignal": true; }; "live": { "alias": "live"; "required": false; "isSignal": true; }; "interval": { "alias": "interval"; "required": false; "isSignal": true; }; "interactive": { "alias": "interactive"; "required": false; "isSignal": true; }; "strokeWidth": { "alias": "strokeWidth"; "required": false; "isSignal": true; }; "grid": { "alias": "grid"; "required": false; "isSignal": true; }; "dots": { "alias": "dots"; "required": false; "isSignal": true; }; "legend": { "alias": "legend"; "required": false; "isSignal": true; }; "labels": { "alias": "labels"; "required": false; "isSignal": true; }; "xTicks": { "alias": "xTicks"; "required": false; "isSignal": true; }; "xFormat": { "alias": "xFormat"; "required": false; "isSignal": true; }; "status": { "alias": "status"; "required": false; "isSignal": true; }; "height": { "alias": "height"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "yAxis": { "alias": "yAxis"; "required": false; "isSignal": true; }; "yTicks": { "alias": "yTicks"; "required": false; "isSignal": true; }; "axisFormat": { "alias": "axisFormat"; "required": false; "isSignal": true; }; "thresholds": { "alias": "thresholds"; "required": false; "isSignal": true; }; "emptyText": { "alias": "emptyText"; "required": false; "isSignal": true; }; "agoFormat": { "alias": "agoFormat"; "required": false; "isSignal": true; }; "valueFormat": { "alias": "valueFormat"; "required": false; "isSignal": true; }; "annotations": { "alias": "annotations"; "required": false; "isSignal": true; }; "activeIndex": { "alias": "activeIndex"; "required": false; "isSignal": true; }; "brush": { "alias": "brush"; "required": false; "isSignal": true; }; "zoom": { "alias": "zoom"; "required": false; "isSignal": true; }; "gapText": { "alias": "gapText"; "required": false; "isSignal": true; }; "resetLabel": { "alias": "resetLabel"; "required": false; "isSignal": true; }; }, { "hoverIndex": "hoverIndex"; "brushChange": "brushChange"; }, never, never, true, never>;
2467
2563
  }
2468
2564
 
2469
2565
  /** A single weighted slice of a donut chart. */
@@ -2819,4 +2915,4 @@ declare class StrctEmptyState {
2819
2915
  }
2820
2916
 
2821
2917
  export { STRCT_ICONS, STRCT_ICON_GROUPS, STRCT_MASKS, STRCT_PALETTES, STRCT_RAW_ICONS, StrctAccordion, StrctAccordionPanel, StrctAlert, StrctAvatar, StrctBadge, StrctBreadcrumb, StrctBreadcrumbItem, StrctButton, StrctButtonGroup, StrctCard, StrctCardBlock, StrctCardFooter, StrctCardHeader, StrctCascadeHost, StrctCascadeNode, StrctCascadeSelect, StrctCellDef, StrctCellStatus, StrctChart, StrctCheckbox, StrctChips, StrctColorPicker, StrctCombobox, StrctCommandPalette, StrctContextMenu, StrctContextMenuTrigger, StrctDatagrid, StrctDatagridActionBar, StrctDatepicker, StrctDesc, StrctDescriptionList, StrctDivider, StrctDonut, StrctDrawer, StrctDrawerFooter, StrctDropdown, StrctDropdownDivider, StrctDropdownItem, StrctEmptyState, StrctField, StrctFile, StrctFlow, StrctFooter, StrctGauge, StrctHeader, StrctHero, StrctIcon, StrctInput, StrctInputMask, StrctInputOtp, StrctKbd, StrctKnob, StrctLogin, StrctMenuPanel, StrctMenuService, StrctMetricTile, StrctModal, StrctNav, StrctNavItem, StrctOverlay, StrctPagination, StrctPassword, StrctProgress, StrctRadio, StrctRadioGroup, StrctRail, StrctRange, StrctRating, StrctRowDetailDef, StrctSectionMenu, StrctSegmented, StrctShell, StrctShellService, StrctSignpost, StrctSkeleton, StrctSparkline, StrctSpeedDial, StrctSpinner, StrctStack, StrctStackItem, StrctStep, StrctSubmenu, StrctTab, StrctTable, StrctTabs, StrctTag, StrctThemeService, StrctThemeSwitcher, StrctTimeline, StrctTimelineItem, StrctToastOutlet, StrctToastService, StrctToggle, StrctTooltip, StrctTree, StrctTreeNode, StrctVerticalNav, StrctWizard, registerStrctIcon, strctValidationIcon, strctValidationTone };
2822
- export type { StrctAlertType, StrctAvatarSize, StrctAvatarStatus, StrctBadgeStatus, StrctButtonSize, StrctButtonVariant, StrctCascadeOption, StrctCellContext, StrctChartCurve, StrctChartSeries, StrctChartStatus, StrctChartThreshold, StrctChartType, StrctColumn, StrctCommandItem, StrctDatagridColumn, StrctDatagridLabels, StrctDescAlign, StrctDescItem, StrctDonutSegment, StrctDrawerSide, StrctDrawerSize, StrctEmptyVariant, StrctFlowDirection, StrctFlowNode, StrctFlowOrientation, StrctIconBadge, StrctKnobStatus, StrctMenuItem, StrctMenuLink, StrctMenuOpenOptions, StrctMenuSection, StrctMetricStatus, StrctModalSize, StrctMode, StrctOption, StrctOverlayPlacement, StrctPalette, StrctPaletteInfo, StrctProgressStatus, StrctRailItem, StrctRailStatus, StrctRow, StrctRowId, StrctSegmentedOption, StrctSegmentedSize, StrctSignpostPosition, StrctSpeedDialDirection, StrctSpinnerSize, StrctStatus, StrctTagStatus, StrctThresholds, StrctTimelineState, StrctToast, StrctToastOptions, StrctToastType, StrctTooltipPosition, StrctTreeMenuEvent, StrctTreeNodeData, StrctTreeNodeMenuFn, StrctValidationState, StrctValidationStatus };
2918
+ export type { StrctAlertType, StrctAvatarSize, StrctAvatarStatus, StrctBadgeStatus, StrctButtonSize, StrctButtonVariant, StrctCascadeOption, StrctCellContext, StrctChartAnnotation, StrctChartCurve, StrctChartSeries, StrctChartStatus, StrctChartThreshold, StrctChartType, StrctColumn, StrctCommandItem, StrctDatagridColumn, StrctDatagridLabels, StrctDescAlign, StrctDescItem, StrctDonutSegment, StrctDrawerSide, StrctDrawerSize, StrctEmptyVariant, StrctFlowDirection, StrctFlowNode, StrctFlowOrientation, StrctIconBadge, StrctKnobStatus, StrctMenuItem, StrctMenuLink, StrctMenuOpenOptions, StrctMenuSection, StrctMetricStatus, StrctModalSize, StrctMode, StrctOption, StrctOverlayPlacement, StrctPalette, StrctPaletteInfo, StrctProgressStatus, StrctRailItem, StrctRailStatus, StrctRow, StrctRowId, StrctSegmentedOption, StrctSegmentedSize, StrctSignpostPosition, StrctSpeedDialDirection, StrctSpinnerSize, StrctStatus, StrctTagStatus, StrctThresholds, StrctTimelineState, StrctToast, StrctToastOptions, StrctToastType, StrctTooltipPosition, StrctTreeMenuEvent, StrctTreeNodeData, StrctTreeNodeMenuFn, StrctValidationState, StrctValidationStatus };