@richardmcquiston01/dashboard-widgets-toolkit 0.14.0 → 0.15.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/dist/core.cjs +418 -6
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +407 -7
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +418 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +407 -7
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +325 -49
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +5 -1
- package/dist/react.d.ts +5 -1
- package/dist/react.js +325 -49
- package/dist/react.js.map +1 -1
- package/dist/{storage-_Eb8Y98-.d.cts → storage-DwJ-vGJg.d.cts} +122 -2
- package/dist/{storage-_Eb8Y98-.d.ts → storage-DwJ-vGJg.d.ts} +122 -2
- package/package.json +1 -1
|
@@ -738,6 +738,112 @@ declare function tableDetailData(data: TableWidgetData): DetailData;
|
|
|
738
738
|
*/
|
|
739
739
|
declare function deriveDetailData(data: WidgetData, locale?: Locale): DetailData | undefined;
|
|
740
740
|
|
|
741
|
+
/**
|
|
742
|
+
* Alternate views: other ways to show the same data. A widget declares
|
|
743
|
+
* `views`, each one built from the widget's own payload by a named,
|
|
744
|
+
* parameterized conversion (data, not functions, so definitions stay JSON).
|
|
745
|
+
* Switching is instant: no second load. Pure functions, no I/O.
|
|
746
|
+
*/
|
|
747
|
+
|
|
748
|
+
/** The key of the widget's own kind, always available as a view. */
|
|
749
|
+
declare const BASE_VIEW_KEY = "base";
|
|
750
|
+
/** Most views one widget may declare, the base view not counted. */
|
|
751
|
+
declare const MAX_WIDGET_VIEWS = 8;
|
|
752
|
+
/** How a view is built from the widget's payload. */
|
|
753
|
+
type ViewConversion = {
|
|
754
|
+
readonly type: 'tableToBarList';
|
|
755
|
+
/** Column index of the bar labels. */
|
|
756
|
+
readonly label: number;
|
|
757
|
+
/** Column index of the bar values (cells need a numeric `value`). */
|
|
758
|
+
readonly value: number;
|
|
759
|
+
} | {
|
|
760
|
+
readonly type: 'tableToGraph';
|
|
761
|
+
/** Column index of the x labels. */
|
|
762
|
+
readonly label: number;
|
|
763
|
+
/** Column indexes of the series (cells need a numeric `value`). */
|
|
764
|
+
readonly values: readonly number[];
|
|
765
|
+
readonly chartType: 'bar' | 'line';
|
|
766
|
+
/** How the numbers read. Default `number`. */
|
|
767
|
+
readonly valueFormat?: ValueFormat;
|
|
768
|
+
readonly currency?: string;
|
|
769
|
+
} | {
|
|
770
|
+
readonly type: 'barListToTable';
|
|
771
|
+
/** Heading of the label column. Default "Name". */
|
|
772
|
+
readonly labelHeading?: string;
|
|
773
|
+
/** Heading of the value column. Default "Value". */
|
|
774
|
+
readonly valueHeading?: string;
|
|
775
|
+
} | {
|
|
776
|
+
readonly type: 'graphToTable';
|
|
777
|
+
} | {
|
|
778
|
+
readonly type: 'barListToGraph';
|
|
779
|
+
readonly chartType: 'bar' | 'line';
|
|
780
|
+
/** Name of the one series. Default "Value". */
|
|
781
|
+
readonly seriesName?: string;
|
|
782
|
+
readonly valueFormat?: ValueFormat;
|
|
783
|
+
readonly currency?: string;
|
|
784
|
+
};
|
|
785
|
+
/** The kinds a conversion reads and produces. */
|
|
786
|
+
declare const VIEW_CONVERSIONS: Readonly<Record<ViewConversion['type'], {
|
|
787
|
+
from: WidgetKind;
|
|
788
|
+
to: WidgetKind;
|
|
789
|
+
}>>;
|
|
790
|
+
/** One alternate way to show a widget. */
|
|
791
|
+
interface WidgetView {
|
|
792
|
+
/** Unique within the widget; not `base`. Stored in the viewer's settings. */
|
|
793
|
+
readonly key: string;
|
|
794
|
+
/** What the viewer sees in the View field, e.g. "Bars". */
|
|
795
|
+
readonly label: string;
|
|
796
|
+
/** What this view renders; must match what the conversion produces. */
|
|
797
|
+
readonly kind: WidgetKind;
|
|
798
|
+
/** Builds this view from the widget's payload. */
|
|
799
|
+
readonly convert: ViewConversion;
|
|
800
|
+
}
|
|
801
|
+
/** What these functions need from a definition. */
|
|
802
|
+
type ViewsItem = Pick<WidgetDefinition, 'key' | 'kind'> & Partial<Pick<WidgetDefinition, 'views' | 'defaultView' | 'baseViewLabel'>>;
|
|
803
|
+
/** A kind's plain name, used for the base view unless `baseViewLabel` is set. */
|
|
804
|
+
declare function kindLabel(kind: WidgetKind): string;
|
|
805
|
+
/** Whether the definition offers a choice of views. */
|
|
806
|
+
declare function hasViews(item: Pick<ViewsItem, 'views'>): boolean;
|
|
807
|
+
/** The view with this key, or undefined (`base` is not a declared view). */
|
|
808
|
+
declare function findView(item: Pick<ViewsItem, 'views'>, key: string): WidgetView | undefined;
|
|
809
|
+
/** Every view a viewer may pick: the base first, then the declared ones. */
|
|
810
|
+
declare function viewChoices(item: ViewsItem): readonly {
|
|
811
|
+
key: string;
|
|
812
|
+
label: string;
|
|
813
|
+
kind: WidgetKind;
|
|
814
|
+
}[];
|
|
815
|
+
/**
|
|
816
|
+
* The view in effect: the viewer's pick when the definition declares it,
|
|
817
|
+
* else `defaultView`, else the base. Always a valid key.
|
|
818
|
+
*/
|
|
819
|
+
declare function effectiveViewKey(item: ViewsItem, chosen: string | undefined): string;
|
|
820
|
+
/** The kind the widget renders as under this view key. */
|
|
821
|
+
declare function viewKind(item: ViewsItem, chosen: string | undefined): WidgetKind;
|
|
822
|
+
/** Options for `convertView`. */
|
|
823
|
+
interface ConvertViewOptions {
|
|
824
|
+
/** Locale for numbers a conversion has to format (graph to table). */
|
|
825
|
+
readonly locale?: Locale;
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Builds a view's payload from the widget's payload. The error names the
|
|
829
|
+
* widget, the view and what to fix, for example `Widget "top-products" view
|
|
830
|
+
* "bars": row 3, column 2 ("Sold") has no numeric value. Add value to the
|
|
831
|
+
* cells.` Never throws.
|
|
832
|
+
*/
|
|
833
|
+
declare function convertView(widgetKey: string, view: Pick<WidgetView, 'key' | 'convert'>, data: WidgetData, options?: ConvertViewOptions): Result<WidgetData>;
|
|
834
|
+
/**
|
|
835
|
+
* What a view keeps of a table, for the dialog: "Shows Name and Sold only."
|
|
836
|
+
* Empty when the view loses nothing worth saying.
|
|
837
|
+
*/
|
|
838
|
+
declare function viewNote(view: WidgetView, data: WidgetData | undefined): string;
|
|
839
|
+
/**
|
|
840
|
+
* The widget as the chosen view shows it: the payload converted and the
|
|
841
|
+
* definition's `kind` set to the view's kind, so renderers work unchanged.
|
|
842
|
+
* A widget that isn't `ok`, or whose view is the base, comes back as is; a
|
|
843
|
+
* failed conversion becomes an `error` widget naming the fix.
|
|
844
|
+
*/
|
|
845
|
+
declare function applyView<W extends DashboardWidget>(widget: W, chosen: string | undefined, options?: ConvertViewOptions): DashboardWidget;
|
|
846
|
+
|
|
741
847
|
/** A size hint for grid layouts; renderers may map it to column spans. */
|
|
742
848
|
declare const WIDGET_SIZES: readonly ["small", "medium", "large", "full"];
|
|
743
849
|
type WidgetSize = (typeof WIDGET_SIZES)[number];
|
|
@@ -815,6 +921,16 @@ interface WidgetDefinition {
|
|
|
815
921
|
* `ProviderOptions.options`. See `options.ts`.
|
|
816
922
|
*/
|
|
817
923
|
readonly options?: readonly WidgetOption[];
|
|
924
|
+
/**
|
|
925
|
+
* Other ways to show this widget, built from its payload by a named
|
|
926
|
+
* conversion (a table as bars or a chart). The widget's own `kind` is
|
|
927
|
+
* always available as the view `base`. See `views.ts`.
|
|
928
|
+
*/
|
|
929
|
+
readonly views?: readonly WidgetView[];
|
|
930
|
+
/** The view shown until a viewer picks another: `base` or a `views` key. Default `base`. */
|
|
931
|
+
readonly defaultView?: string;
|
|
932
|
+
/** What the base view is called in the View field. Default: its kind's name. */
|
|
933
|
+
readonly baseViewLabel?: string;
|
|
818
934
|
}
|
|
819
935
|
/** What a viewer may not do to a locked widget. */
|
|
820
936
|
interface WidgetLock {
|
|
@@ -927,6 +1043,8 @@ interface WidgetViewerSettings {
|
|
|
927
1043
|
readonly flexible?: boolean;
|
|
928
1044
|
/** Values for declared options, by option key. */
|
|
929
1045
|
readonly options?: Readonly<Record<string, OptionValue>>;
|
|
1046
|
+
/** The view to show: `base` or a key from the definition's `views`. */
|
|
1047
|
+
readonly view?: string;
|
|
930
1048
|
}
|
|
931
1049
|
/** Viewer settings by widget key. */
|
|
932
1050
|
type LayoutSettings = Readonly<Record<string, WidgetViewerSettings>>;
|
|
@@ -938,7 +1056,7 @@ declare const MAX_WIDGET_TITLE_LENGTH = 80;
|
|
|
938
1056
|
*/
|
|
939
1057
|
declare const MAX_PARSED_SETTINGS = 500;
|
|
940
1058
|
/** What these functions need from a definition. */
|
|
941
|
-
type SettingsItem = Pick<WidgetDefinition, 'key'> & Partial<Pick<WidgetDefinition, 'title' | 'width' | 'minWidth' | 'maxWidth' | 'fill' | 'locked' | 'options'>>;
|
|
1059
|
+
type SettingsItem = Pick<WidgetDefinition, 'key'> & Partial<Pick<WidgetDefinition, 'title' | 'width' | 'minWidth' | 'maxWidth' | 'fill' | 'locked' | 'options' | 'views' | 'defaultView'>>;
|
|
942
1060
|
/**
|
|
943
1061
|
* Reads the `settings` field of a saved layout. Anything malformed is
|
|
944
1062
|
* dropped (wrong types, titles over the limit are cut, widths outside 2 to
|
|
@@ -999,6 +1117,8 @@ interface WidgetSettingsPatch {
|
|
|
999
1117
|
readonly flexible?: boolean | undefined;
|
|
1000
1118
|
/** Replaces all of the widget's option values (`undefined` clears them). */
|
|
1001
1119
|
readonly options?: Readonly<Record<string, OptionValue>> | undefined;
|
|
1120
|
+
/** The view key (`base` or a declared view); `undefined` clears it. */
|
|
1121
|
+
readonly view?: string | undefined;
|
|
1002
1122
|
}
|
|
1003
1123
|
type LayoutWithSettings<L> = L & {
|
|
1004
1124
|
readonly settings?: LayoutSettings;
|
|
@@ -1471,4 +1591,4 @@ interface LayoutPersistence {
|
|
|
1471
1591
|
*/
|
|
1472
1592
|
declare function createLayoutPersistence(adapter: StorageAdapter, options?: LayoutPersistenceOptions): LayoutPersistence;
|
|
1473
1593
|
|
|
1474
|
-
export { type
|
|
1594
|
+
export { type DateRangeOption as $, type AlertListWidgetData as A, type BarListWidgetData as B, type CachedPayload as C, type DashboardWidget as D, type ColorOption as E, type ColumnsOption as F, type GraphWidgetData as G, type ConflictPolicy as H, type ConvertViewOptions as I, DATE_RANGE_PRESETS as J, type KpiWidgetData as K, type Locale as L, DEFAULT_COMPARISON_LABEL as M, type NiceDomain as N, type OptionValues as O, type PageItem as P, DEFAULT_CURRENCY as Q, type ResolvedTableControls as R, type StoreScope as S, type TableWidgetData as T, DEFAULT_DETAIL_PAGE_SIZE as U, DEFAULT_EMPTY_TEXT as V, type WidgetSize as W, DEFAULT_MAX_LAYOUT_BYTES as X, DEFAULT_PAGE_KEY as Y, DEFAULT_PAGE_ROWS as Z, DETAIL_MODES as _, type WidgetFill as a, type StoreResult as a$, type DateRangePreset as a0, type DeltaDirection as a1, type DeltaSentiment as a2, type DetailCell as a3, type DetailColumn as a4, type DetailMode as a5, type DetailPage as a6, type DetailProvider as a7, type DetailProviders as a8, EMPTY_LAYOUT as a9, MAX_WIDGET_TITLE_LENGTH as aA, MAX_WIDGET_VIEWS as aB, MAX_WIDGET_WIDTH as aC, MIN_WIDGET_WIDTH as aD, type NormalizeSettingsOptions as aE, type NumberOption as aF, OPTION_KEY_PATTERN as aG, type Ok as aH, type OkWidget as aI, type OptionContext as aJ, type OptionValue as aK, type PageOptions as aL, type PageRoom as aM, type PlacedRow as aN, type ProviderOptions as aO, type ResolvedDetailOptions as aP, type ResolvedWidget as aQ, type ResolvedWidgetLock as aR, type RetryOptions as aS, type SaveOptions as aT, type SavedLayout as aU, type SettingsItem as aV, type SortDirection as aW, type SortOption as aX, type StorageAdapter as aY, type StorageLogEvent as aZ, type StoreErrorCode as a_, type EmptyWidget as aa, type EncodingOptions as ab, type EnforceLocksOptions as ac, type Err as ad, type ErrorWidget as ae, type FormatOptions as af, type GraphPoint as ag, type GraphSeries as ah, type GridItem as ai, type KpiDelta as aj, type KpiDeltaOptions as ak, LAYOUT_ENVELOPE_VERSION as al, type LayoutItem as am, type LayoutPage as an, type LayoutPersistenceOptions as ao, type LayoutSettings as ap, type LoadedLayout as aq, type LoadingWidget as ar, MAX_DETAIL_PAGE_SIZE as as, MAX_GRAPH_SERIES as at, MAX_PAGE_ROWS as au, MAX_PAGE_TITLE_LENGTH as av, MAX_PARSED_PAGES as aw, MAX_PARSED_SETTINGS as ax, MAX_TEXT_OPTION_LENGTH as ay, MAX_WIDGET_OPTIONS as az, type WidgetDefinition as b, isFlexible as b$, type StoredValue as b0, type TableCell as b1, type TableColumn as b2, type TextOption as b3, VALUE_FORMATS as b4, VIEW_CONVERSIONS as b5, type ValueFormat as b6, type ViewConversion as b7, type ViewsItem as b8, WIDGET_FILLS as b9, defaultOptionValue as bA, defineWidget as bB, deriveDetailData as bC, describeUnknownError as bD, effectiveDefinitions as bE, effectiveViewKey as bF, emptyTextFor as bG, emptyWidget as bH, enforceLocks as bI, err as bJ, failedWidget as bK, fillColumnSpans as bL, fillWidthSpans as bM, fillsHeight as bN, fillsWidth as bO, finalizeWidget as bP, findView as bQ, fitCount as bR, formatCount as bS, formatPercentChange as bT, formatValue as bU, hasPages as bV, hasViews as bW, hiddenWidgets as bX, hideWidget as bY, isClientApplied as bZ, isColumnKeyFor as b_, WIDGET_KINDS as ba, WIDGET_OPTION_TYPES as bb, WIDGET_SIZES as bc, WIDTH_COLUMNS as bd, type WidgetCache as be, type WidgetDataOf as bf, type WidgetDetailOptions as bg, type WidgetEmptyState as bh, type WidgetLock as bi, type WidgetOption as bj, type WidgetProvider as bk, type WidgetStatus as bl, type WidgetTableControls as bm, type WidgetView as bn, addPage as bo, applyClientOptions as bp, applySettings as bq, applyView as br, assignPages as bs, baseColumnSpan as bt, cacheKeyFor as bu, clearWidgetSettings as bv, coerceOptionValue as bw, convertView as bx, createLayoutPersistence as by, defaultDetailQuery as bz, type DetailProviderOptions as c, setWidgetSettings as c$, isHidden as c0, isIsoInterval as c1, isMinimized as c2, isOptionsLocked as c3, isTitleInUse as c4, isWidgetEmptyState as c5, isWidgetKind as c6, isWidgetVisibleTo as c7, isWidgetWidth as c8, itemWidth as c9, pageWidgets as cA, parseDetailQuery as cB, parseLayout as cC, parseSettings as cD, parseSortValue as cE, percentChange as cF, placeRows as cG, pruneLayout as cH, queryRows as cI, readOnly as cJ, removePage as cK, renamePage as cL, resolveDateRange as cM, resolveDetailOptions as cN, resolveOptionValues as cO, resolvePageKey as cP, resolvePayload as cQ, resolveTableControls as cR, resolveWidget as cS, resolveWidgetLock as cT, resolveWidgetUnapplied as cU, resolveWidgets as cV, restoreWidget as cW, sameOptionValues as cX, serializeDetailQuery as cY, serializeLayout as cZ, serializeSettings as c_, kindLabel as ca, kpiDelta as cb, labelStride as cc, loadingWidgets as cd, memoryAdapter as ce, minimizeWidget as cf, movePage as cg, moveWidget as ch, moveWidgetBy as ci, moveWidgetDown as cj, moveWidgetToPage as ck, moveWidgetUp as cl, nextPageKey as cm, niceDomain as cn, niceStep as co, normalizeLayout as cp, normalizeSettings as cq, normalizeTitle as cr, ok as cs, optionValuesFor as ct, optionValuesFromLayout as cu, optionsCacheSuffix as cv, pageLayout as cw, pageList as cx, pageOf as cy, pageRoom as cz, type DetailData as d, shareOf as d0, showWidget as d1, sortDefinitions as d2, sortFromOptions as d3, tableDetailData as d4, toggleHidden as d5, toggleMinimized as d6, usesWidthColumns as d7, utf8Length as d8, validateDetailData as d9, viewChoices as da, viewKind as db, viewNote as dc, visibleWidgets as dd, widgetOptionValues as de, widgetsFor as df, widthForSize as dg, widthRange as dh, widthShareLabel as di, withEncoding as dj, withFallback as dk, withLogging as dl, withPageLayout as dm, withPrefix as dn, withReadCache as dp, withRetry as dq, type DetailQuery as e, type DashboardLayout as f, type WidgetViewerSettings as g, type WidgetSettingsPatch as h, type GaugeWidgetData as i, type DetailSort as j, type TextWidgetData as k, type WidgetData as l, type LayoutPersistence as m, type NormalizeOptions as n, type ResolveOptions as o, type WidgetContext as p, type WidgetProviders as q, type Result as r, type WidgetKind as s, type WidgetPayload as t, type AddPageOptions as u, type AlertListItem as v, BASE_VIEW_KEY as w, type BarListItem as x, type BooleanOption as y, type ChoiceOption as z };
|
|
@@ -738,6 +738,112 @@ declare function tableDetailData(data: TableWidgetData): DetailData;
|
|
|
738
738
|
*/
|
|
739
739
|
declare function deriveDetailData(data: WidgetData, locale?: Locale): DetailData | undefined;
|
|
740
740
|
|
|
741
|
+
/**
|
|
742
|
+
* Alternate views: other ways to show the same data. A widget declares
|
|
743
|
+
* `views`, each one built from the widget's own payload by a named,
|
|
744
|
+
* parameterized conversion (data, not functions, so definitions stay JSON).
|
|
745
|
+
* Switching is instant: no second load. Pure functions, no I/O.
|
|
746
|
+
*/
|
|
747
|
+
|
|
748
|
+
/** The key of the widget's own kind, always available as a view. */
|
|
749
|
+
declare const BASE_VIEW_KEY = "base";
|
|
750
|
+
/** Most views one widget may declare, the base view not counted. */
|
|
751
|
+
declare const MAX_WIDGET_VIEWS = 8;
|
|
752
|
+
/** How a view is built from the widget's payload. */
|
|
753
|
+
type ViewConversion = {
|
|
754
|
+
readonly type: 'tableToBarList';
|
|
755
|
+
/** Column index of the bar labels. */
|
|
756
|
+
readonly label: number;
|
|
757
|
+
/** Column index of the bar values (cells need a numeric `value`). */
|
|
758
|
+
readonly value: number;
|
|
759
|
+
} | {
|
|
760
|
+
readonly type: 'tableToGraph';
|
|
761
|
+
/** Column index of the x labels. */
|
|
762
|
+
readonly label: number;
|
|
763
|
+
/** Column indexes of the series (cells need a numeric `value`). */
|
|
764
|
+
readonly values: readonly number[];
|
|
765
|
+
readonly chartType: 'bar' | 'line';
|
|
766
|
+
/** How the numbers read. Default `number`. */
|
|
767
|
+
readonly valueFormat?: ValueFormat;
|
|
768
|
+
readonly currency?: string;
|
|
769
|
+
} | {
|
|
770
|
+
readonly type: 'barListToTable';
|
|
771
|
+
/** Heading of the label column. Default "Name". */
|
|
772
|
+
readonly labelHeading?: string;
|
|
773
|
+
/** Heading of the value column. Default "Value". */
|
|
774
|
+
readonly valueHeading?: string;
|
|
775
|
+
} | {
|
|
776
|
+
readonly type: 'graphToTable';
|
|
777
|
+
} | {
|
|
778
|
+
readonly type: 'barListToGraph';
|
|
779
|
+
readonly chartType: 'bar' | 'line';
|
|
780
|
+
/** Name of the one series. Default "Value". */
|
|
781
|
+
readonly seriesName?: string;
|
|
782
|
+
readonly valueFormat?: ValueFormat;
|
|
783
|
+
readonly currency?: string;
|
|
784
|
+
};
|
|
785
|
+
/** The kinds a conversion reads and produces. */
|
|
786
|
+
declare const VIEW_CONVERSIONS: Readonly<Record<ViewConversion['type'], {
|
|
787
|
+
from: WidgetKind;
|
|
788
|
+
to: WidgetKind;
|
|
789
|
+
}>>;
|
|
790
|
+
/** One alternate way to show a widget. */
|
|
791
|
+
interface WidgetView {
|
|
792
|
+
/** Unique within the widget; not `base`. Stored in the viewer's settings. */
|
|
793
|
+
readonly key: string;
|
|
794
|
+
/** What the viewer sees in the View field, e.g. "Bars". */
|
|
795
|
+
readonly label: string;
|
|
796
|
+
/** What this view renders; must match what the conversion produces. */
|
|
797
|
+
readonly kind: WidgetKind;
|
|
798
|
+
/** Builds this view from the widget's payload. */
|
|
799
|
+
readonly convert: ViewConversion;
|
|
800
|
+
}
|
|
801
|
+
/** What these functions need from a definition. */
|
|
802
|
+
type ViewsItem = Pick<WidgetDefinition, 'key' | 'kind'> & Partial<Pick<WidgetDefinition, 'views' | 'defaultView' | 'baseViewLabel'>>;
|
|
803
|
+
/** A kind's plain name, used for the base view unless `baseViewLabel` is set. */
|
|
804
|
+
declare function kindLabel(kind: WidgetKind): string;
|
|
805
|
+
/** Whether the definition offers a choice of views. */
|
|
806
|
+
declare function hasViews(item: Pick<ViewsItem, 'views'>): boolean;
|
|
807
|
+
/** The view with this key, or undefined (`base` is not a declared view). */
|
|
808
|
+
declare function findView(item: Pick<ViewsItem, 'views'>, key: string): WidgetView | undefined;
|
|
809
|
+
/** Every view a viewer may pick: the base first, then the declared ones. */
|
|
810
|
+
declare function viewChoices(item: ViewsItem): readonly {
|
|
811
|
+
key: string;
|
|
812
|
+
label: string;
|
|
813
|
+
kind: WidgetKind;
|
|
814
|
+
}[];
|
|
815
|
+
/**
|
|
816
|
+
* The view in effect: the viewer's pick when the definition declares it,
|
|
817
|
+
* else `defaultView`, else the base. Always a valid key.
|
|
818
|
+
*/
|
|
819
|
+
declare function effectiveViewKey(item: ViewsItem, chosen: string | undefined): string;
|
|
820
|
+
/** The kind the widget renders as under this view key. */
|
|
821
|
+
declare function viewKind(item: ViewsItem, chosen: string | undefined): WidgetKind;
|
|
822
|
+
/** Options for `convertView`. */
|
|
823
|
+
interface ConvertViewOptions {
|
|
824
|
+
/** Locale for numbers a conversion has to format (graph to table). */
|
|
825
|
+
readonly locale?: Locale;
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Builds a view's payload from the widget's payload. The error names the
|
|
829
|
+
* widget, the view and what to fix, for example `Widget "top-products" view
|
|
830
|
+
* "bars": row 3, column 2 ("Sold") has no numeric value. Add value to the
|
|
831
|
+
* cells.` Never throws.
|
|
832
|
+
*/
|
|
833
|
+
declare function convertView(widgetKey: string, view: Pick<WidgetView, 'key' | 'convert'>, data: WidgetData, options?: ConvertViewOptions): Result<WidgetData>;
|
|
834
|
+
/**
|
|
835
|
+
* What a view keeps of a table, for the dialog: "Shows Name and Sold only."
|
|
836
|
+
* Empty when the view loses nothing worth saying.
|
|
837
|
+
*/
|
|
838
|
+
declare function viewNote(view: WidgetView, data: WidgetData | undefined): string;
|
|
839
|
+
/**
|
|
840
|
+
* The widget as the chosen view shows it: the payload converted and the
|
|
841
|
+
* definition's `kind` set to the view's kind, so renderers work unchanged.
|
|
842
|
+
* A widget that isn't `ok`, or whose view is the base, comes back as is; a
|
|
843
|
+
* failed conversion becomes an `error` widget naming the fix.
|
|
844
|
+
*/
|
|
845
|
+
declare function applyView<W extends DashboardWidget>(widget: W, chosen: string | undefined, options?: ConvertViewOptions): DashboardWidget;
|
|
846
|
+
|
|
741
847
|
/** A size hint for grid layouts; renderers may map it to column spans. */
|
|
742
848
|
declare const WIDGET_SIZES: readonly ["small", "medium", "large", "full"];
|
|
743
849
|
type WidgetSize = (typeof WIDGET_SIZES)[number];
|
|
@@ -815,6 +921,16 @@ interface WidgetDefinition {
|
|
|
815
921
|
* `ProviderOptions.options`. See `options.ts`.
|
|
816
922
|
*/
|
|
817
923
|
readonly options?: readonly WidgetOption[];
|
|
924
|
+
/**
|
|
925
|
+
* Other ways to show this widget, built from its payload by a named
|
|
926
|
+
* conversion (a table as bars or a chart). The widget's own `kind` is
|
|
927
|
+
* always available as the view `base`. See `views.ts`.
|
|
928
|
+
*/
|
|
929
|
+
readonly views?: readonly WidgetView[];
|
|
930
|
+
/** The view shown until a viewer picks another: `base` or a `views` key. Default `base`. */
|
|
931
|
+
readonly defaultView?: string;
|
|
932
|
+
/** What the base view is called in the View field. Default: its kind's name. */
|
|
933
|
+
readonly baseViewLabel?: string;
|
|
818
934
|
}
|
|
819
935
|
/** What a viewer may not do to a locked widget. */
|
|
820
936
|
interface WidgetLock {
|
|
@@ -927,6 +1043,8 @@ interface WidgetViewerSettings {
|
|
|
927
1043
|
readonly flexible?: boolean;
|
|
928
1044
|
/** Values for declared options, by option key. */
|
|
929
1045
|
readonly options?: Readonly<Record<string, OptionValue>>;
|
|
1046
|
+
/** The view to show: `base` or a key from the definition's `views`. */
|
|
1047
|
+
readonly view?: string;
|
|
930
1048
|
}
|
|
931
1049
|
/** Viewer settings by widget key. */
|
|
932
1050
|
type LayoutSettings = Readonly<Record<string, WidgetViewerSettings>>;
|
|
@@ -938,7 +1056,7 @@ declare const MAX_WIDGET_TITLE_LENGTH = 80;
|
|
|
938
1056
|
*/
|
|
939
1057
|
declare const MAX_PARSED_SETTINGS = 500;
|
|
940
1058
|
/** What these functions need from a definition. */
|
|
941
|
-
type SettingsItem = Pick<WidgetDefinition, 'key'> & Partial<Pick<WidgetDefinition, 'title' | 'width' | 'minWidth' | 'maxWidth' | 'fill' | 'locked' | 'options'>>;
|
|
1059
|
+
type SettingsItem = Pick<WidgetDefinition, 'key'> & Partial<Pick<WidgetDefinition, 'title' | 'width' | 'minWidth' | 'maxWidth' | 'fill' | 'locked' | 'options' | 'views' | 'defaultView'>>;
|
|
942
1060
|
/**
|
|
943
1061
|
* Reads the `settings` field of a saved layout. Anything malformed is
|
|
944
1062
|
* dropped (wrong types, titles over the limit are cut, widths outside 2 to
|
|
@@ -999,6 +1117,8 @@ interface WidgetSettingsPatch {
|
|
|
999
1117
|
readonly flexible?: boolean | undefined;
|
|
1000
1118
|
/** Replaces all of the widget's option values (`undefined` clears them). */
|
|
1001
1119
|
readonly options?: Readonly<Record<string, OptionValue>> | undefined;
|
|
1120
|
+
/** The view key (`base` or a declared view); `undefined` clears it. */
|
|
1121
|
+
readonly view?: string | undefined;
|
|
1002
1122
|
}
|
|
1003
1123
|
type LayoutWithSettings<L> = L & {
|
|
1004
1124
|
readonly settings?: LayoutSettings;
|
|
@@ -1471,4 +1591,4 @@ interface LayoutPersistence {
|
|
|
1471
1591
|
*/
|
|
1472
1592
|
declare function createLayoutPersistence(adapter: StorageAdapter, options?: LayoutPersistenceOptions): LayoutPersistence;
|
|
1473
1593
|
|
|
1474
|
-
export { type
|
|
1594
|
+
export { type DateRangeOption as $, type AlertListWidgetData as A, type BarListWidgetData as B, type CachedPayload as C, type DashboardWidget as D, type ColorOption as E, type ColumnsOption as F, type GraphWidgetData as G, type ConflictPolicy as H, type ConvertViewOptions as I, DATE_RANGE_PRESETS as J, type KpiWidgetData as K, type Locale as L, DEFAULT_COMPARISON_LABEL as M, type NiceDomain as N, type OptionValues as O, type PageItem as P, DEFAULT_CURRENCY as Q, type ResolvedTableControls as R, type StoreScope as S, type TableWidgetData as T, DEFAULT_DETAIL_PAGE_SIZE as U, DEFAULT_EMPTY_TEXT as V, type WidgetSize as W, DEFAULT_MAX_LAYOUT_BYTES as X, DEFAULT_PAGE_KEY as Y, DEFAULT_PAGE_ROWS as Z, DETAIL_MODES as _, type WidgetFill as a, type StoreResult as a$, type DateRangePreset as a0, type DeltaDirection as a1, type DeltaSentiment as a2, type DetailCell as a3, type DetailColumn as a4, type DetailMode as a5, type DetailPage as a6, type DetailProvider as a7, type DetailProviders as a8, EMPTY_LAYOUT as a9, MAX_WIDGET_TITLE_LENGTH as aA, MAX_WIDGET_VIEWS as aB, MAX_WIDGET_WIDTH as aC, MIN_WIDGET_WIDTH as aD, type NormalizeSettingsOptions as aE, type NumberOption as aF, OPTION_KEY_PATTERN as aG, type Ok as aH, type OkWidget as aI, type OptionContext as aJ, type OptionValue as aK, type PageOptions as aL, type PageRoom as aM, type PlacedRow as aN, type ProviderOptions as aO, type ResolvedDetailOptions as aP, type ResolvedWidget as aQ, type ResolvedWidgetLock as aR, type RetryOptions as aS, type SaveOptions as aT, type SavedLayout as aU, type SettingsItem as aV, type SortDirection as aW, type SortOption as aX, type StorageAdapter as aY, type StorageLogEvent as aZ, type StoreErrorCode as a_, type EmptyWidget as aa, type EncodingOptions as ab, type EnforceLocksOptions as ac, type Err as ad, type ErrorWidget as ae, type FormatOptions as af, type GraphPoint as ag, type GraphSeries as ah, type GridItem as ai, type KpiDelta as aj, type KpiDeltaOptions as ak, LAYOUT_ENVELOPE_VERSION as al, type LayoutItem as am, type LayoutPage as an, type LayoutPersistenceOptions as ao, type LayoutSettings as ap, type LoadedLayout as aq, type LoadingWidget as ar, MAX_DETAIL_PAGE_SIZE as as, MAX_GRAPH_SERIES as at, MAX_PAGE_ROWS as au, MAX_PAGE_TITLE_LENGTH as av, MAX_PARSED_PAGES as aw, MAX_PARSED_SETTINGS as ax, MAX_TEXT_OPTION_LENGTH as ay, MAX_WIDGET_OPTIONS as az, type WidgetDefinition as b, isFlexible as b$, type StoredValue as b0, type TableCell as b1, type TableColumn as b2, type TextOption as b3, VALUE_FORMATS as b4, VIEW_CONVERSIONS as b5, type ValueFormat as b6, type ViewConversion as b7, type ViewsItem as b8, WIDGET_FILLS as b9, defaultOptionValue as bA, defineWidget as bB, deriveDetailData as bC, describeUnknownError as bD, effectiveDefinitions as bE, effectiveViewKey as bF, emptyTextFor as bG, emptyWidget as bH, enforceLocks as bI, err as bJ, failedWidget as bK, fillColumnSpans as bL, fillWidthSpans as bM, fillsHeight as bN, fillsWidth as bO, finalizeWidget as bP, findView as bQ, fitCount as bR, formatCount as bS, formatPercentChange as bT, formatValue as bU, hasPages as bV, hasViews as bW, hiddenWidgets as bX, hideWidget as bY, isClientApplied as bZ, isColumnKeyFor as b_, WIDGET_KINDS as ba, WIDGET_OPTION_TYPES as bb, WIDGET_SIZES as bc, WIDTH_COLUMNS as bd, type WidgetCache as be, type WidgetDataOf as bf, type WidgetDetailOptions as bg, type WidgetEmptyState as bh, type WidgetLock as bi, type WidgetOption as bj, type WidgetProvider as bk, type WidgetStatus as bl, type WidgetTableControls as bm, type WidgetView as bn, addPage as bo, applyClientOptions as bp, applySettings as bq, applyView as br, assignPages as bs, baseColumnSpan as bt, cacheKeyFor as bu, clearWidgetSettings as bv, coerceOptionValue as bw, convertView as bx, createLayoutPersistence as by, defaultDetailQuery as bz, type DetailProviderOptions as c, setWidgetSettings as c$, isHidden as c0, isIsoInterval as c1, isMinimized as c2, isOptionsLocked as c3, isTitleInUse as c4, isWidgetEmptyState as c5, isWidgetKind as c6, isWidgetVisibleTo as c7, isWidgetWidth as c8, itemWidth as c9, pageWidgets as cA, parseDetailQuery as cB, parseLayout as cC, parseSettings as cD, parseSortValue as cE, percentChange as cF, placeRows as cG, pruneLayout as cH, queryRows as cI, readOnly as cJ, removePage as cK, renamePage as cL, resolveDateRange as cM, resolveDetailOptions as cN, resolveOptionValues as cO, resolvePageKey as cP, resolvePayload as cQ, resolveTableControls as cR, resolveWidget as cS, resolveWidgetLock as cT, resolveWidgetUnapplied as cU, resolveWidgets as cV, restoreWidget as cW, sameOptionValues as cX, serializeDetailQuery as cY, serializeLayout as cZ, serializeSettings as c_, kindLabel as ca, kpiDelta as cb, labelStride as cc, loadingWidgets as cd, memoryAdapter as ce, minimizeWidget as cf, movePage as cg, moveWidget as ch, moveWidgetBy as ci, moveWidgetDown as cj, moveWidgetToPage as ck, moveWidgetUp as cl, nextPageKey as cm, niceDomain as cn, niceStep as co, normalizeLayout as cp, normalizeSettings as cq, normalizeTitle as cr, ok as cs, optionValuesFor as ct, optionValuesFromLayout as cu, optionsCacheSuffix as cv, pageLayout as cw, pageList as cx, pageOf as cy, pageRoom as cz, type DetailData as d, shareOf as d0, showWidget as d1, sortDefinitions as d2, sortFromOptions as d3, tableDetailData as d4, toggleHidden as d5, toggleMinimized as d6, usesWidthColumns as d7, utf8Length as d8, validateDetailData as d9, viewChoices as da, viewKind as db, viewNote as dc, visibleWidgets as dd, widgetOptionValues as de, widgetsFor as df, widthForSize as dg, widthRange as dh, widthShareLabel as di, withEncoding as dj, withFallback as dk, withLogging as dl, withPageLayout as dm, withPrefix as dn, withReadCache as dp, withRetry as dq, type DetailQuery as e, type DashboardLayout as f, type WidgetViewerSettings as g, type WidgetSettingsPatch as h, type GaugeWidgetData as i, type DetailSort as j, type TextWidgetData as k, type WidgetData as l, type LayoutPersistence as m, type NormalizeOptions as n, type ResolveOptions as o, type WidgetContext as p, type WidgetProviders as q, type Result as r, type WidgetKind as s, type WidgetPayload as t, type AddPageOptions as u, type AlertListItem as v, BASE_VIEW_KEY as w, type BarListItem as x, type BooleanOption as y, type ChoiceOption as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@richardmcquiston01/dashboard-widgets-toolkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.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",
|