@richardmcquiston01/dashboard-widgets-toolkit 0.4.1 → 0.6.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.
@@ -385,6 +385,18 @@ interface ResolvedDetailOptions {
385
385
  readonly pageSize: number;
386
386
  readonly mode: DetailMode;
387
387
  }
388
+ /** The `tableControls` setting on a widget definition. `true` means both. */
389
+ interface WidgetTableControls {
390
+ /** A search box over every column. Default true. */
391
+ readonly search?: boolean;
392
+ /** Sortable column headers. Default true. */
393
+ readonly sort?: boolean;
394
+ }
395
+ /** `WidgetTableControls` with every default filled in. */
396
+ interface ResolvedTableControls {
397
+ readonly search: boolean;
398
+ readonly sort: boolean;
399
+ }
388
400
  interface DetailColumn {
389
401
  /** Stable id used by sort, filters and URLs. Unique within the data. */
390
402
  readonly key: string;
@@ -448,6 +460,11 @@ interface DetailPage {
448
460
  }
449
461
  /** Reads `definition.detail` with defaults; undefined when there is none. */
450
462
  declare function resolveDetailOptions(definition: Pick<WidgetDefinition, 'title' | 'detail'>): ResolvedDetailOptions | undefined;
463
+ /**
464
+ * Reads `definition.tableControls` with defaults; undefined when the widget
465
+ * has none (or both are turned off).
466
+ */
467
+ declare function resolveTableControls(definition: Pick<WidgetDefinition, 'tableControls'>): ResolvedTableControls | undefined;
451
468
  /** The first page, unsorted and unfiltered. */
452
469
  declare function defaultDetailQuery(pageSize?: number): DetailQuery;
453
470
  /**
@@ -479,6 +496,11 @@ declare function parseDetailQuery(queryString: string, pageSize?: number, data?:
479
496
  * Reports every problem, naming the column or row and cell.
480
497
  */
481
498
  declare function validateDetailData(data: unknown, subject?: string): Result<DetailData>;
499
+ /**
500
+ * A TABLE's columns and rows as detail data (column keys `c0`, `c1`, ...),
501
+ * footer ignored, so the table can be searched and sorted with `queryRows`.
502
+ */
503
+ declare function tableDetailData(data: TableWidgetData): DetailData;
482
504
  /**
483
505
  * The detail data for a widget whose card payload is already complete, so a
484
506
  * detail view needs no provider: a TABLE without a `footer` (a footer means
@@ -529,6 +551,13 @@ interface WidgetDefinition {
529
551
  * paging. `true` uses defaults. The data comes from a detail provider.
530
552
  */
531
553
  readonly detail?: boolean | WidgetDetailOptions;
554
+ /**
555
+ * TABLE widgets only: a search box and sortable column headers in the card
556
+ * itself, working on the rows the card holds. `true` turns on both. With a
557
+ * `footer` (rows were left out) they only see the rows shown; use `detail`
558
+ * for the full list.
559
+ */
560
+ readonly tableControls?: boolean | WidgetTableControls;
532
561
  /** Fill free space in the row (height, width or both). Default: none. */
533
562
  readonly fill?: WidgetFill;
534
563
  }
@@ -632,4 +661,4 @@ declare function niceDomain(values: readonly number[], tickCount?: number): Nice
632
661
  */
633
662
  declare function labelStride(count: number, maxLabels?: number): number;
634
663
 
635
- export { MAX_GRAPH_SERIES as $, type AlertListWidgetData as A, type BarListWidgetData as B, type CachedPayload as C, type DashboardWidget as D, type DetailPage as E, type DetailProvider as F, type GraphWidgetData as G, type DetailProviders as H, type DetailSort as I, EMPTY_LAYOUT as J, type KpiWidgetData as K, type Locale as L, type EmptyWidget as M, type NiceDomain as N, type Err as O, type ErrorWidget as P, type FormatOptions as Q, type ResolveOptions as R, type GraphPoint as S, type TableWidgetData as T, type GraphSeries as U, type KpiDelta as V, type WidgetSize as W, type KpiDeltaOptions as X, type LayoutItem as Y, type LoadingWidget as Z, MAX_DETAIL_PAGE_SIZE as _, type WidgetFill as a, sortDefinitions as a$, type Ok as a0, type OkWidget as a1, type ProviderOptions as a2, type ResolvedDetailOptions as a3, type ResolvedWidget as a4, type SortDirection as a5, type TableCell as a6, type TableColumn as a7, VALUE_FORMATS as a8, type ValueFormat as a9, isWidgetKind as aA, isWidgetVisibleTo as aB, kpiDelta as aC, labelStride as aD, loadingWidgets as aE, minimizeWidget as aF, moveWidget as aG, moveWidgetBy as aH, moveWidgetDown as aI, moveWidgetUp as aJ, niceDomain as aK, niceStep as aL, ok as aM, parseDetailQuery as aN, parseLayout as aO, percentChange as aP, pruneLayout as aQ, queryRows as aR, resolveDetailOptions as aS, resolvePayload as aT, resolveWidget as aU, resolveWidgets as aV, restoreWidget as aW, serializeDetailQuery as aX, serializeLayout as aY, shareOf as aZ, showWidget as a_, WIDGET_FILLS as aa, WIDGET_KINDS as ab, WIDGET_SIZES as ac, type WidgetCache as ad, type WidgetDataOf as ae, type WidgetDetailOptions as af, type WidgetEmptyState as ag, type WidgetProvider as ah, type WidgetStatus as ai, cacheKeyFor as aj, defaultDetailQuery as ak, defineWidget as al, deriveDetailData as am, describeUnknownError as an, emptyTextFor as ao, emptyWidget as ap, err as aq, failedWidget as ar, formatCount as as, formatPercentChange as at, formatValue as au, hiddenWidgets as av, hideWidget as aw, isHidden as ax, isMinimized as ay, isWidgetEmptyState as az, type WidgetDefinition as b, toggleHidden as b0, toggleMinimized as b1, validateDetailData as b2, visibleWidgets as b3, widgetsFor as b4, type DetailProviderOptions as c, type DetailData as d, type DetailQuery as e, type DashboardLayout as f, type GaugeWidgetData as g, type TextWidgetData as h, type WidgetData as i, type WidgetContext as j, type WidgetProviders as k, type WidgetKind as l, type Result as m, type WidgetPayload as n, type AlertListItem as o, type BarListItem as p, DEFAULT_COMPARISON_LABEL as q, DEFAULT_CURRENCY as r, DEFAULT_DETAIL_PAGE_SIZE as s, DEFAULT_EMPTY_TEXT as t, DETAIL_MODES as u, type DeltaDirection as v, type DeltaSentiment as w, type DetailCell as x, type DetailColumn as y, type DetailMode as z };
664
+ export { MAX_DETAIL_PAGE_SIZE as $, type AlertListWidgetData as A, type BarListWidgetData as B, type CachedPayload as C, type DashboardWidget as D, type DetailMode as E, type DetailPage as F, type GraphWidgetData as G, type DetailProvider as H, type DetailProviders as I, type DetailSort as J, type KpiWidgetData as K, type Locale as L, EMPTY_LAYOUT as M, type NiceDomain as N, type EmptyWidget as O, type Err as P, type ErrorWidget as Q, type ResolvedTableControls as R, type FormatOptions as S, type TableWidgetData as T, type GraphPoint as U, type GraphSeries as V, type WidgetSize as W, type KpiDelta as X, type KpiDeltaOptions as Y, type LayoutItem as Z, type LoadingWidget as _, type WidgetFill as a, serializeLayout as a$, MAX_GRAPH_SERIES as a0, type Ok as a1, type OkWidget as a2, type ProviderOptions as a3, type ResolvedDetailOptions as a4, type ResolvedWidget as a5, type SortDirection as a6, type TableCell as a7, type TableColumn as a8, VALUE_FORMATS as a9, isMinimized as aA, isWidgetEmptyState as aB, isWidgetKind as aC, isWidgetVisibleTo as aD, kpiDelta as aE, labelStride as aF, loadingWidgets as aG, minimizeWidget as aH, moveWidget as aI, moveWidgetBy as aJ, moveWidgetDown as aK, moveWidgetUp as aL, niceDomain as aM, niceStep as aN, ok as aO, parseDetailQuery as aP, parseLayout as aQ, percentChange as aR, pruneLayout as aS, queryRows as aT, resolveDetailOptions as aU, resolvePayload as aV, resolveTableControls as aW, resolveWidget as aX, resolveWidgets as aY, restoreWidget as aZ, serializeDetailQuery as a_, type ValueFormat as aa, WIDGET_FILLS as ab, WIDGET_KINDS as ac, WIDGET_SIZES as ad, type WidgetCache as ae, type WidgetDataOf as af, type WidgetDetailOptions as ag, type WidgetEmptyState as ah, type WidgetProvider as ai, type WidgetStatus as aj, type WidgetTableControls as ak, cacheKeyFor as al, defaultDetailQuery as am, defineWidget as an, deriveDetailData as ao, describeUnknownError as ap, emptyTextFor as aq, emptyWidget as ar, err as as, failedWidget as at, formatCount as au, formatPercentChange as av, formatValue as aw, hiddenWidgets as ax, hideWidget as ay, isHidden as az, type WidgetDefinition as b, shareOf as b0, showWidget as b1, sortDefinitions as b2, tableDetailData as b3, toggleHidden as b4, toggleMinimized as b5, validateDetailData as b6, visibleWidgets as b7, widgetsFor as b8, type DetailProviderOptions as c, type DetailData as d, type DetailQuery as e, type DashboardLayout as f, type GaugeWidgetData as g, type TextWidgetData as h, type WidgetData as i, type ResolveOptions as j, type WidgetContext as k, type WidgetProviders as l, type WidgetKind as m, type Result as n, type WidgetPayload as o, type AlertListItem as p, type BarListItem as q, DEFAULT_COMPARISON_LABEL as r, DEFAULT_CURRENCY as s, DEFAULT_DETAIL_PAGE_SIZE as t, DEFAULT_EMPTY_TEXT as u, DETAIL_MODES as v, type DeltaDirection as w, type DeltaSentiment as x, type DetailCell as y, type DetailColumn as z };
@@ -385,6 +385,18 @@ interface ResolvedDetailOptions {
385
385
  readonly pageSize: number;
386
386
  readonly mode: DetailMode;
387
387
  }
388
+ /** The `tableControls` setting on a widget definition. `true` means both. */
389
+ interface WidgetTableControls {
390
+ /** A search box over every column. Default true. */
391
+ readonly search?: boolean;
392
+ /** Sortable column headers. Default true. */
393
+ readonly sort?: boolean;
394
+ }
395
+ /** `WidgetTableControls` with every default filled in. */
396
+ interface ResolvedTableControls {
397
+ readonly search: boolean;
398
+ readonly sort: boolean;
399
+ }
388
400
  interface DetailColumn {
389
401
  /** Stable id used by sort, filters and URLs. Unique within the data. */
390
402
  readonly key: string;
@@ -448,6 +460,11 @@ interface DetailPage {
448
460
  }
449
461
  /** Reads `definition.detail` with defaults; undefined when there is none. */
450
462
  declare function resolveDetailOptions(definition: Pick<WidgetDefinition, 'title' | 'detail'>): ResolvedDetailOptions | undefined;
463
+ /**
464
+ * Reads `definition.tableControls` with defaults; undefined when the widget
465
+ * has none (or both are turned off).
466
+ */
467
+ declare function resolveTableControls(definition: Pick<WidgetDefinition, 'tableControls'>): ResolvedTableControls | undefined;
451
468
  /** The first page, unsorted and unfiltered. */
452
469
  declare function defaultDetailQuery(pageSize?: number): DetailQuery;
453
470
  /**
@@ -479,6 +496,11 @@ declare function parseDetailQuery(queryString: string, pageSize?: number, data?:
479
496
  * Reports every problem, naming the column or row and cell.
480
497
  */
481
498
  declare function validateDetailData(data: unknown, subject?: string): Result<DetailData>;
499
+ /**
500
+ * A TABLE's columns and rows as detail data (column keys `c0`, `c1`, ...),
501
+ * footer ignored, so the table can be searched and sorted with `queryRows`.
502
+ */
503
+ declare function tableDetailData(data: TableWidgetData): DetailData;
482
504
  /**
483
505
  * The detail data for a widget whose card payload is already complete, so a
484
506
  * detail view needs no provider: a TABLE without a `footer` (a footer means
@@ -529,6 +551,13 @@ interface WidgetDefinition {
529
551
  * paging. `true` uses defaults. The data comes from a detail provider.
530
552
  */
531
553
  readonly detail?: boolean | WidgetDetailOptions;
554
+ /**
555
+ * TABLE widgets only: a search box and sortable column headers in the card
556
+ * itself, working on the rows the card holds. `true` turns on both. With a
557
+ * `footer` (rows were left out) they only see the rows shown; use `detail`
558
+ * for the full list.
559
+ */
560
+ readonly tableControls?: boolean | WidgetTableControls;
532
561
  /** Fill free space in the row (height, width or both). Default: none. */
533
562
  readonly fill?: WidgetFill;
534
563
  }
@@ -632,4 +661,4 @@ declare function niceDomain(values: readonly number[], tickCount?: number): Nice
632
661
  */
633
662
  declare function labelStride(count: number, maxLabels?: number): number;
634
663
 
635
- export { MAX_GRAPH_SERIES as $, type AlertListWidgetData as A, type BarListWidgetData as B, type CachedPayload as C, type DashboardWidget as D, type DetailPage as E, type DetailProvider as F, type GraphWidgetData as G, type DetailProviders as H, type DetailSort as I, EMPTY_LAYOUT as J, type KpiWidgetData as K, type Locale as L, type EmptyWidget as M, type NiceDomain as N, type Err as O, type ErrorWidget as P, type FormatOptions as Q, type ResolveOptions as R, type GraphPoint as S, type TableWidgetData as T, type GraphSeries as U, type KpiDelta as V, type WidgetSize as W, type KpiDeltaOptions as X, type LayoutItem as Y, type LoadingWidget as Z, MAX_DETAIL_PAGE_SIZE as _, type WidgetFill as a, sortDefinitions as a$, type Ok as a0, type OkWidget as a1, type ProviderOptions as a2, type ResolvedDetailOptions as a3, type ResolvedWidget as a4, type SortDirection as a5, type TableCell as a6, type TableColumn as a7, VALUE_FORMATS as a8, type ValueFormat as a9, isWidgetKind as aA, isWidgetVisibleTo as aB, kpiDelta as aC, labelStride as aD, loadingWidgets as aE, minimizeWidget as aF, moveWidget as aG, moveWidgetBy as aH, moveWidgetDown as aI, moveWidgetUp as aJ, niceDomain as aK, niceStep as aL, ok as aM, parseDetailQuery as aN, parseLayout as aO, percentChange as aP, pruneLayout as aQ, queryRows as aR, resolveDetailOptions as aS, resolvePayload as aT, resolveWidget as aU, resolveWidgets as aV, restoreWidget as aW, serializeDetailQuery as aX, serializeLayout as aY, shareOf as aZ, showWidget as a_, WIDGET_FILLS as aa, WIDGET_KINDS as ab, WIDGET_SIZES as ac, type WidgetCache as ad, type WidgetDataOf as ae, type WidgetDetailOptions as af, type WidgetEmptyState as ag, type WidgetProvider as ah, type WidgetStatus as ai, cacheKeyFor as aj, defaultDetailQuery as ak, defineWidget as al, deriveDetailData as am, describeUnknownError as an, emptyTextFor as ao, emptyWidget as ap, err as aq, failedWidget as ar, formatCount as as, formatPercentChange as at, formatValue as au, hiddenWidgets as av, hideWidget as aw, isHidden as ax, isMinimized as ay, isWidgetEmptyState as az, type WidgetDefinition as b, toggleHidden as b0, toggleMinimized as b1, validateDetailData as b2, visibleWidgets as b3, widgetsFor as b4, type DetailProviderOptions as c, type DetailData as d, type DetailQuery as e, type DashboardLayout as f, type GaugeWidgetData as g, type TextWidgetData as h, type WidgetData as i, type WidgetContext as j, type WidgetProviders as k, type WidgetKind as l, type Result as m, type WidgetPayload as n, type AlertListItem as o, type BarListItem as p, DEFAULT_COMPARISON_LABEL as q, DEFAULT_CURRENCY as r, DEFAULT_DETAIL_PAGE_SIZE as s, DEFAULT_EMPTY_TEXT as t, DETAIL_MODES as u, type DeltaDirection as v, type DeltaSentiment as w, type DetailCell as x, type DetailColumn as y, type DetailMode as z };
664
+ export { MAX_DETAIL_PAGE_SIZE as $, type AlertListWidgetData as A, type BarListWidgetData as B, type CachedPayload as C, type DashboardWidget as D, type DetailMode as E, type DetailPage as F, type GraphWidgetData as G, type DetailProvider as H, type DetailProviders as I, type DetailSort as J, type KpiWidgetData as K, type Locale as L, EMPTY_LAYOUT as M, type NiceDomain as N, type EmptyWidget as O, type Err as P, type ErrorWidget as Q, type ResolvedTableControls as R, type FormatOptions as S, type TableWidgetData as T, type GraphPoint as U, type GraphSeries as V, type WidgetSize as W, type KpiDelta as X, type KpiDeltaOptions as Y, type LayoutItem as Z, type LoadingWidget as _, type WidgetFill as a, serializeLayout as a$, MAX_GRAPH_SERIES as a0, type Ok as a1, type OkWidget as a2, type ProviderOptions as a3, type ResolvedDetailOptions as a4, type ResolvedWidget as a5, type SortDirection as a6, type TableCell as a7, type TableColumn as a8, VALUE_FORMATS as a9, isMinimized as aA, isWidgetEmptyState as aB, isWidgetKind as aC, isWidgetVisibleTo as aD, kpiDelta as aE, labelStride as aF, loadingWidgets as aG, minimizeWidget as aH, moveWidget as aI, moveWidgetBy as aJ, moveWidgetDown as aK, moveWidgetUp as aL, niceDomain as aM, niceStep as aN, ok as aO, parseDetailQuery as aP, parseLayout as aQ, percentChange as aR, pruneLayout as aS, queryRows as aT, resolveDetailOptions as aU, resolvePayload as aV, resolveTableControls as aW, resolveWidget as aX, resolveWidgets as aY, restoreWidget as aZ, serializeDetailQuery as a_, type ValueFormat as aa, WIDGET_FILLS as ab, WIDGET_KINDS as ac, WIDGET_SIZES as ad, type WidgetCache as ae, type WidgetDataOf as af, type WidgetDetailOptions as ag, type WidgetEmptyState as ah, type WidgetProvider as ai, type WidgetStatus as aj, type WidgetTableControls as ak, cacheKeyFor as al, defaultDetailQuery as am, defineWidget as an, deriveDetailData as ao, describeUnknownError as ap, emptyTextFor as aq, emptyWidget as ar, err as as, failedWidget as at, formatCount as au, formatPercentChange as av, formatValue as aw, hiddenWidgets as ax, hideWidget as ay, isHidden as az, type WidgetDefinition as b, shareOf as b0, showWidget as b1, sortDefinitions as b2, tableDetailData as b3, toggleHidden as b4, toggleMinimized as b5, validateDetailData as b6, visibleWidgets as b7, widgetsFor as b8, type DetailProviderOptions as c, type DetailData as d, type DetailQuery as e, type DashboardLayout as f, type GaugeWidgetData as g, type TextWidgetData as h, type WidgetData as i, type ResolveOptions as j, type WidgetContext as k, type WidgetProviders as l, type WidgetKind as m, type Result as n, type WidgetPayload as o, type AlertListItem as p, type BarListItem as q, DEFAULT_COMPARISON_LABEL as r, DEFAULT_CURRENCY as s, DEFAULT_DETAIL_PAGE_SIZE as t, DEFAULT_EMPTY_TEXT as u, DETAIL_MODES as v, type DeltaDirection as w, type DeltaSentiment as x, type DetailCell as y, type DetailColumn as z };
package/dist/styles.css CHANGED
@@ -700,3 +700,19 @@
700
700
  border-radius: 0;
701
701
  }
702
702
  }
703
+
704
+ :where(.dwt-table-search) {
705
+ margin-block-end: 8px;
706
+ }
707
+
708
+ :where(.dwt-table-search input) {
709
+ box-sizing: border-box;
710
+ inline-size: 100%;
711
+ max-inline-size: 256px;
712
+ font: inherit;
713
+ color: var(--dwt-text);
714
+ background: var(--dwt-surface);
715
+ border: 1px solid var(--dwt-border);
716
+ border-radius: 6px;
717
+ padding: 4px 8px;
718
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@richardmcquiston01/dashboard-widgets-toolkit",
3
- "version": "0.4.1",
3
+ "version": "0.6.0",
4
4
  "description": "Framework-agnostic dashboard widget toolkit: typed widget definitions and data payloads (KPI, gauge, table, bar list, alert list, chart), user layout (order, hide, minimise), and React renderers. Bring your own data providers.",
5
5
  "keywords": [
6
6
  "dashboard",