@richardmcquiston01/dashboard-widgets-toolkit 0.10.0 → 0.11.1
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 +1222 -17
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +13 -179
- package/dist/core.d.ts +13 -179
- package/dist/core.js +1191 -18
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +1222 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1191 -18
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +593 -32
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +75 -5
- package/dist/react.d.ts +75 -5
- package/dist/react.js +594 -34
- package/dist/react.js.map +1 -1
- package/dist/storage-VaaysVnZ.d.cts +1333 -0
- package/dist/storage-VaaysVnZ.d.ts +1333 -0
- package/package.json +1 -1
- package/dist/scale-N69bo7wo.d.cts +0 -758
- package/dist/scale-N69bo7wo.d.ts +0 -758
package/dist/core.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as WidgetDefinition,
|
|
2
|
-
export {
|
|
1
|
+
import { b as WidgetDefinition, D as DashboardWidget, n as WidgetContext, m as ResolveOptions, o as WidgetProviders, p as WidgetKind, q as Result, r as WidgetPayload } from './storage-VaaysVnZ.cjs';
|
|
2
|
+
export { s as AddPageOptions, t as AlertListItem, A as AlertListWidgetData, u as BarListItem, B as BarListWidgetData, v as BooleanOption, C as CachedPayload, w as ChoiceOption, x as ColorOption, y as ColumnsOption, z as ConflictPolicy, E as DATE_RANGE_PRESETS, F as DEFAULT_COMPARISON_LABEL, H as DEFAULT_CURRENCY, I as DEFAULT_DETAIL_PAGE_SIZE, J as DEFAULT_EMPTY_TEXT, M as DEFAULT_MAX_LAYOUT_BYTES, Q as DEFAULT_PAGE_KEY, U as DEFAULT_PAGE_ROWS, V as DETAIL_MODES, f as DashboardLayout, X as DateRangeOption, Y as DateRangePreset, Z as DeltaDirection, _ as DeltaSentiment, $ as DetailCell, a0 as DetailColumn, d as DetailData, a1 as DetailMode, a2 as DetailPage, a3 as DetailProvider, c as DetailProviderOptions, a4 as DetailProviders, e as DetailQuery, h as DetailSort, a5 as EMPTY_LAYOUT, a6 as EmptyWidget, a7 as EncodingOptions, a8 as EnforceLocksOptions, a9 as Err, aa as ErrorWidget, ab as FormatOptions, g as GaugeWidgetData, ac as GraphPoint, ad as GraphSeries, G as GraphWidgetData, ae as GridItem, af as KpiDelta, ag as KpiDeltaOptions, K as KpiWidgetData, ah as LAYOUT_ENVELOPE_VERSION, ai as LayoutItem, aj as LayoutPage, k as LayoutPersistence, ak as LayoutPersistenceOptions, al as LoadedLayout, am as LoadingWidget, L as Locale, an as MAX_DETAIL_PAGE_SIZE, ao as MAX_GRAPH_SERIES, ap as MAX_PAGE_ROWS, aq as MAX_PAGE_TITLE_LENGTH, ar as MAX_PARSED_PAGES, as as MAX_TEXT_OPTION_LENGTH, at as MAX_WIDGET_OPTIONS, au as MAX_WIDGET_WIDTH, av as MIN_WIDGET_WIDTH, N as NiceDomain, l as NormalizeOptions, aw as NumberOption, ax as OPTION_KEY_PATTERN, ay as Ok, az as OkWidget, aA as OptionContext, aB as OptionValue, O as OptionValues, P as PageItem, aC as PageOptions, aD as PageRoom, aE as PlacedRow, aF as ProviderOptions, aG as ResolvedDetailOptions, R as ResolvedTableControls, aH as ResolvedWidget, aI as ResolvedWidgetLock, aJ as RetryOptions, aK as SaveOptions, aL as SavedLayout, aM as SortDirection, aN as SortOption, aO as StorageAdapter, aP as StorageLogEvent, aQ as StoreErrorCode, aR as StoreResult, S as StoreScope, aS as StoredValue, aT as TableCell, aU as TableColumn, T as TableWidgetData, aV as TextOption, i as TextWidgetData, aW as VALUE_FORMATS, aX as ValueFormat, aY as WIDGET_FILLS, aZ as WIDGET_KINDS, a_ as WIDGET_OPTION_TYPES, a$ as WIDGET_SIZES, b0 as WIDTH_COLUMNS, b1 as WidgetCache, j as WidgetData, b2 as WidgetDataOf, b3 as WidgetDetailOptions, b4 as WidgetEmptyState, a as WidgetFill, b5 as WidgetLock, b6 as WidgetOption, b7 as WidgetProvider, W as WidgetSize, b8 as WidgetStatus, b9 as WidgetTableControls, ba as addPage, bb as applyClientOptions, bc as assignPages, bd as baseColumnSpan, be as cacheKeyFor, bf as coerceOptionValue, bg as createLayoutPersistence, bh as defaultDetailQuery, bi as defaultOptionValue, bj as defineWidget, bk as deriveDetailData, bl as describeUnknownError, bm as emptyTextFor, bn as emptyWidget, bo as enforceLocks, bp as err, bq as failedWidget, br as fillColumnSpans, bs as fillWidthSpans, bt as fillsHeight, bu as fillsWidth, bv as finalizeWidget, bw as fitCount, bx as formatCount, by as formatPercentChange, bz as formatValue, bA as hasPages, bB as hiddenWidgets, bC as hideWidget, bD as isClientApplied, bE as isColumnKeyFor, bF as isHidden, bG as isIsoInterval, bH as isMinimized, bI as isWidgetEmptyState, bJ as isWidgetKind, bK as isWidgetVisibleTo, bL as isWidgetWidth, bM as itemWidth, bN as kpiDelta, bO as labelStride, bP as loadingWidgets, bQ as memoryAdapter, bR as minimizeWidget, bS as movePage, bT as moveWidget, bU as moveWidgetBy, bV as moveWidgetDown, bW as moveWidgetToPage, bX as moveWidgetUp, bY as nextPageKey, bZ as niceDomain, b_ as niceStep, b$ as normalizeLayout, c0 as ok, c1 as optionValuesFor, c2 as optionsCacheSuffix, c3 as pageLayout, c4 as pageList, c5 as pageOf, c6 as pageRoom, c7 as pageWidgets, c8 as parseDetailQuery, c9 as parseLayout, ca as parseSortValue, cb as percentChange, cc as placeRows, cd as pruneLayout, ce as queryRows, cf as readOnly, cg as removePage, ch as renamePage, ci as resolveDateRange, cj as resolveDetailOptions, ck as resolveOptionValues, cl as resolvePageKey, cm as resolvePayload, cn as resolveTableControls, co as resolveWidget, cp as resolveWidgetLock, cq as resolveWidgetUnapplied, cr as resolveWidgets, cs as restoreWidget, ct as sameOptionValues, cu as serializeDetailQuery, cv as serializeLayout, cw as shareOf, cx as showWidget, cy as sortDefinitions, cz as sortFromOptions, cA as tableDetailData, cB as toggleHidden, cC as toggleMinimized, cD as usesWidthColumns, cE as utf8Length, cF as validateDetailData, cG as visibleWidgets, cH as widgetsFor, cI as widthForSize, cJ as withEncoding, cK as withFallback, cL as withLogging, cM as withPageLayout, cN as withPrefix, cO as withReadCache, cP as withRetry } from './storage-VaaysVnZ.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Maker Toolkit compatibility. Its API (`apps/api/src/widgets`) serves
|
|
@@ -33,71 +33,6 @@ interface LegacyWidgetDefinition {
|
|
|
33
33
|
*/
|
|
34
34
|
declare function fromLegacyDefinition(legacy: LegacyWidgetDefinition): WidgetDefinition | null;
|
|
35
35
|
|
|
36
|
-
/** The parts of a widget definition that decide its place in a grid. */
|
|
37
|
-
interface GridItem {
|
|
38
|
-
readonly key: string;
|
|
39
|
-
readonly defaultSize?: WidgetSize;
|
|
40
|
-
readonly fill?: WidgetFill;
|
|
41
|
-
readonly width?: number;
|
|
42
|
-
}
|
|
43
|
-
/** Columns in a grid that uses widget `width`. */
|
|
44
|
-
declare const WIDTH_COLUMNS = 12;
|
|
45
|
-
/** Smallest and largest `width`, in twelfths of a row. */
|
|
46
|
-
declare const MIN_WIDGET_WIDTH = 2;
|
|
47
|
-
declare const MAX_WIDGET_WIDTH = 12;
|
|
48
|
-
/** Whether `value` is a valid widget `width`: an integer from 2 to 12. */
|
|
49
|
-
declare function isWidgetWidth(value: unknown): value is number;
|
|
50
|
-
/** The width (in twelfths) a `defaultSize` stands for. Default `medium`. */
|
|
51
|
-
declare function widthForSize(size: WidgetSize | undefined): number;
|
|
52
|
-
/** The 12-column width of an item: its `width`, else from its size. */
|
|
53
|
-
declare function itemWidth(item: GridItem): number;
|
|
54
|
-
/** Whether a grid of `items` should use 12 columns (any item sets `width`). */
|
|
55
|
-
declare function usesWidthColumns(items: readonly GridItem[]): boolean;
|
|
56
|
-
/** Whether the widget should take the columns left over in its row. */
|
|
57
|
-
declare function fillsWidth(fill: WidgetFill | undefined): boolean;
|
|
58
|
-
/** Whether the widget should stretch to the height of its row. */
|
|
59
|
-
declare function fillsHeight(fill: WidgetFill | undefined): boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Columns a size takes in a grid of `columns` tracks: `large` spans
|
|
62
|
-
* `largeSpan` (default 2), `full` spans every column, anything else one.
|
|
63
|
-
*/
|
|
64
|
-
declare function baseColumnSpan(size: WidgetSize | undefined, columns: number, largeSpan?: number): number;
|
|
65
|
-
/**
|
|
66
|
-
* Places `items` in a grid of `columns` tracks the way a sparse grid
|
|
67
|
-
* auto-places them (left to right, wrapping to a new row when an item does
|
|
68
|
-
* not fit), then gives the columns left over in each row to the items that
|
|
69
|
-
* `fill` their width, shared evenly (earlier items get the remainder).
|
|
70
|
-
*
|
|
71
|
-
* Returns the column span for each width-filling item, keyed by `key`. Items
|
|
72
|
-
* that do not fill width keep their normal size and are not in the map.
|
|
73
|
-
*/
|
|
74
|
-
declare function fillColumnSpans(items: readonly GridItem[], columns: number, largeSpan?: number): Map<string, number>;
|
|
75
|
-
/**
|
|
76
|
-
* Like `fillColumnSpans` for a 12-column grid: each item starts at its
|
|
77
|
-
* `width` (see `itemWidth`) and width-fillers share the leftover twelfths.
|
|
78
|
-
*/
|
|
79
|
-
declare function fillWidthSpans(items: readonly GridItem[]): Map<string, number>;
|
|
80
|
-
/** One row of a placed grid: the widgets in it and their final column spans. */
|
|
81
|
-
interface PlacedRow {
|
|
82
|
-
readonly keys: readonly string[];
|
|
83
|
-
/** Column spans, in `keys` order, after width-fillers took the leftovers. */
|
|
84
|
-
readonly spans: readonly number[];
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* The rows `items` occupy in a 12-column grid, exactly as `fillWidthSpans`
|
|
88
|
-
* places them: left to right, a widget that doesn't fit in the rest of a row
|
|
89
|
-
* starts the next row whole (a widget is never split), and width-fillers then
|
|
90
|
-
* grow into the leftover columns. Growth never changes how many rows there
|
|
91
|
-
* are.
|
|
92
|
-
*/
|
|
93
|
-
declare function placeRows(items: readonly GridItem[]): readonly PlacedRow[];
|
|
94
|
-
/**
|
|
95
|
-
* How many of `items`, in order, fit in `maxRows` rows of a 12-column grid.
|
|
96
|
-
* Placement is left to right, so this is the length of the longest prefix
|
|
97
|
-
* whose rows number at most `maxRows`.
|
|
98
|
-
*/
|
|
99
|
-
declare function fitCount(items: readonly GridItem[], maxRows: number): number;
|
|
100
|
-
|
|
101
36
|
/**
|
|
102
37
|
* Loads widgets one by one, after the first render, and reports each result
|
|
103
38
|
* as it arrives. It is the logic behind the React `useWidgets` hook, kept
|
|
@@ -137,122 +72,21 @@ interface WidgetLoader {
|
|
|
137
72
|
* than the interval would otherwise be restarted forever and never finish).
|
|
138
73
|
*/
|
|
139
74
|
refresh(key?: string, options?: RefreshOptions): void;
|
|
75
|
+
/**
|
|
76
|
+
* Sets the values chosen for a widget's options (all of them: keys left out
|
|
77
|
+
* go back to their defaults). A choice only the toolkit applies (`sort` or
|
|
78
|
+
* `columns` with `apply: 'client'`) re-derives the payload it already has.
|
|
79
|
+
* A choice your provider sees reloads that widget alone: what is shown stays
|
|
80
|
+
* (marked `stale`) until the new data arrives, and an earlier answer for the
|
|
81
|
+
* same choices comes back from the cache. Does nothing when the resolved
|
|
82
|
+
* values don't change.
|
|
83
|
+
*/
|
|
84
|
+
setOptions(key: string, chosen: Readonly<Record<string, unknown>>): void;
|
|
140
85
|
/** Aborts everything in flight and ignores any later result. */
|
|
141
86
|
dispose(): void;
|
|
142
87
|
}
|
|
143
88
|
declare function createWidgetLoader<C extends WidgetContext>(options: WidgetLoaderOptions<C>): WidgetLoader;
|
|
144
89
|
|
|
145
|
-
/**
|
|
146
|
-
* Pages of widgets: a dashboard split into pages, like the home screens of a
|
|
147
|
-
* phone. Each page is a small layout (order, hidden, minimized) with a name
|
|
148
|
-
* and a capacity of `maxRows` rows of 12 columns. Pure functions, in the
|
|
149
|
-
* style of `layout.ts`: inputs are never mutated, a refusal is a `Result`
|
|
150
|
-
* with a specific message, and a no-op returns the same object.
|
|
151
|
-
*
|
|
152
|
-
* A layout without `pages` has one implicit page (`DEFAULT_PAGE_KEY`), so
|
|
153
|
-
* everything here also works on layouts saved before pages existed.
|
|
154
|
-
*/
|
|
155
|
-
|
|
156
|
-
/** The key of the implicit page of a layout that has no `pages`. */
|
|
157
|
-
declare const DEFAULT_PAGE_KEY = "default";
|
|
158
|
-
/** Rows a page holds unless it (or the dashboard) says otherwise. */
|
|
159
|
-
declare const DEFAULT_PAGE_ROWS = 4;
|
|
160
|
-
/** What the page functions need from a widget definition. */
|
|
161
|
-
type PageItem = LayoutItem & GridItem & {
|
|
162
|
-
/** Used in messages; the key stands in when absent. */
|
|
163
|
-
readonly title?: string;
|
|
164
|
-
};
|
|
165
|
-
interface PageOptions {
|
|
166
|
-
/** Rows a page holds when it has no `maxRows` of its own. Default 4. */
|
|
167
|
-
readonly maxRows?: number;
|
|
168
|
-
}
|
|
169
|
-
/** Whether the layout has pages of its own (rather than one implicit page). */
|
|
170
|
-
declare function hasPages(layout: DashboardLayout): boolean;
|
|
171
|
-
/**
|
|
172
|
-
* The layout's pages. A layout without `pages` has one implicit page called
|
|
173
|
-
* "Page 1" made from its top-level lists.
|
|
174
|
-
*/
|
|
175
|
-
declare function pageList(layout: DashboardLayout): readonly LayoutPage[];
|
|
176
|
-
/**
|
|
177
|
-
* One page as an ordinary layout, so every function in `layout.ts` (move,
|
|
178
|
-
* hide, minimize, `visibleWidgets`) works on it unchanged. For a layout with
|
|
179
|
-
* no pages this is the layout itself. Undefined for an unknown page.
|
|
180
|
-
*/
|
|
181
|
-
declare function pageLayout(layout: DashboardLayout, pageKey: string): DashboardLayout | undefined;
|
|
182
|
-
/**
|
|
183
|
-
* Writes a page's layout (changed with the functions in `layout.ts`) back
|
|
184
|
-
* into the whole layout. Returns the same object when nothing changed or the
|
|
185
|
-
* page doesn't exist.
|
|
186
|
-
*/
|
|
187
|
-
declare function withPageLayout(layout: DashboardLayout, pageKey: string, next: DashboardLayout): DashboardLayout;
|
|
188
|
-
/** The key of the page a `page` reference names: a key, else a title. */
|
|
189
|
-
declare function resolvePageKey(layout: DashboardLayout, reference: string | undefined): string | undefined;
|
|
190
|
-
/**
|
|
191
|
-
* Which page each widget shows on: the page that lists it (in its order or
|
|
192
|
-
* hidden list), else its home page (`definition.page`, else the first page).
|
|
193
|
-
* A widget locked against moving always shows on its home page, so a viewer's
|
|
194
|
-
* saved layout can't move it. Definitions keep their input order.
|
|
195
|
-
*/
|
|
196
|
-
declare function assignPages<T extends LayoutItem>(definitions: readonly T[], layout: DashboardLayout): Map<string, T[]>;
|
|
197
|
-
/** The key of the page a widget shows on; undefined if it isn't a definition. */
|
|
198
|
-
declare function pageOf<T extends LayoutItem>(definitions: readonly T[], layout: DashboardLayout, key: string): string | undefined;
|
|
199
|
-
/** A page's visible widgets, in display order (minimized ones included). */
|
|
200
|
-
declare function pageWidgets<T extends LayoutItem>(definitions: readonly T[], layout: DashboardLayout, pageKey: string): T[];
|
|
201
|
-
/** How full a page is. */
|
|
202
|
-
interface PageRoom {
|
|
203
|
-
readonly maxRows: number;
|
|
204
|
-
readonly rowsUsed: number;
|
|
205
|
-
readonly rowsFree: number;
|
|
206
|
-
}
|
|
207
|
-
/** Rows a page allows, uses and has left, as the grid will draw them. */
|
|
208
|
-
declare function pageRoom<T extends PageItem>(definitions: readonly T[], layout: DashboardLayout, pageKey: string, options?: PageOptions): PageRoom | undefined;
|
|
209
|
-
/** The first `page-N` key no page uses. */
|
|
210
|
-
declare function nextPageKey(layout: DashboardLayout): string;
|
|
211
|
-
interface AddPageOptions {
|
|
212
|
-
/** The new page's title. Default: the next free "Page N". */
|
|
213
|
-
readonly title?: string;
|
|
214
|
-
/** The new page's key. Default: the next free `page-N`. */
|
|
215
|
-
readonly key?: string;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Adds an empty page after the last one. A layout without pages gains an
|
|
219
|
-
* explicit first page holding everything it had.
|
|
220
|
-
*/
|
|
221
|
-
declare function addPage(layout: DashboardLayout, options?: AddPageOptions): Result<DashboardLayout>;
|
|
222
|
-
/** Renames a page. The same layout comes back when the title is unchanged. */
|
|
223
|
-
declare function renamePage(layout: DashboardLayout, pageKey: string, title: string): Result<DashboardLayout>;
|
|
224
|
-
/**
|
|
225
|
-
* Moves a page `offset` places (negative is earlier), clamped at the ends.
|
|
226
|
-
* Returns the same layout when nothing moves.
|
|
227
|
-
*/
|
|
228
|
-
declare function movePage(layout: DashboardLayout, pageKey: string, offset: number): DashboardLayout;
|
|
229
|
-
/**
|
|
230
|
-
* Removes a page. Its widgets move to the end of the previous page (the next
|
|
231
|
-
* one when it was first), keeping their hidden and minimized state. Refused
|
|
232
|
-
* for the only page, and when the widgets wouldn't fit on the pages left.
|
|
233
|
-
*/
|
|
234
|
-
declare function removePage<T extends PageItem>(definitions: readonly T[], layout: DashboardLayout, pageKey: string, options?: PageOptions): Result<DashboardLayout>;
|
|
235
|
-
/**
|
|
236
|
-
* Moves a widget to the end of another page, keeping its hidden and
|
|
237
|
-
* minimized state. Refused for an unknown widget or page, for a widget locked
|
|
238
|
-
* against moving, and when a visible widget wouldn't fit in the page's rows.
|
|
239
|
-
*/
|
|
240
|
-
declare function moveWidgetToPage<T extends PageItem>(definitions: readonly T[], layout: DashboardLayout, widgetKey: string, targetKey: string, options?: PageOptions): Result<DashboardLayout>;
|
|
241
|
-
interface NormalizeOptions extends PageOptions {
|
|
242
|
-
/** Skip lock enforcement, for a user who may rearrange locked widgets. */
|
|
243
|
-
readonly overrideLocks?: boolean;
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Repairs a layout so it can be trusted, for the place it is saved: unknown
|
|
247
|
-
* widgets are dropped, locks are enforced, and in a paged layout each widget
|
|
248
|
-
* lives on one page, titles are trimmed, unique and short, widgets no page
|
|
249
|
-
* lists yet are placed (on their home page), and a page that holds too many
|
|
250
|
-
* rows has its overflow moved, in order, to the next page with room or a new
|
|
251
|
-
* page after it. Nothing is hidden or dropped to make room. Idempotent;
|
|
252
|
-
* returns the same object when nothing changes.
|
|
253
|
-
*/
|
|
254
|
-
declare function normalizeLayout<T extends PageItem>(definitions: readonly T[], layout: DashboardLayout, options?: NormalizeOptions): DashboardLayout;
|
|
255
|
-
|
|
256
90
|
/**
|
|
257
91
|
* Link and image URL checks. Payloads often come from an API, so a link is
|
|
258
92
|
* only rendered when it can't run script: http(s), mailto, or a relative
|
|
@@ -290,4 +124,4 @@ declare function validateWidgetData(value: unknown, options?: ValidateWidgetData
|
|
|
290
124
|
*/
|
|
291
125
|
declare function validateWidgetDefinition(value: unknown): Result<WidgetDefinition>;
|
|
292
126
|
|
|
293
|
-
export {
|
|
127
|
+
export { DashboardWidget, type LegacyWidgetDefinition, MAX_REPORTED_PROBLEMS, type RefreshOptions, ResolveOptions, Result, type ValidateWidgetDataOptions, WidgetContext, WidgetDefinition, WidgetKind, type WidgetLoader, type WidgetLoaderOptions, WidgetPayload, WidgetProviders, createWidgetLoader, fromLegacyDefinition, isSafeHref, isSafeImageUrl, upgradeLegacyWidgetData, validateWidgetData, validateWidgetDefinition };
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as WidgetDefinition,
|
|
2
|
-
export {
|
|
1
|
+
import { b as WidgetDefinition, D as DashboardWidget, n as WidgetContext, m as ResolveOptions, o as WidgetProviders, p as WidgetKind, q as Result, r as WidgetPayload } from './storage-VaaysVnZ.js';
|
|
2
|
+
export { s as AddPageOptions, t as AlertListItem, A as AlertListWidgetData, u as BarListItem, B as BarListWidgetData, v as BooleanOption, C as CachedPayload, w as ChoiceOption, x as ColorOption, y as ColumnsOption, z as ConflictPolicy, E as DATE_RANGE_PRESETS, F as DEFAULT_COMPARISON_LABEL, H as DEFAULT_CURRENCY, I as DEFAULT_DETAIL_PAGE_SIZE, J as DEFAULT_EMPTY_TEXT, M as DEFAULT_MAX_LAYOUT_BYTES, Q as DEFAULT_PAGE_KEY, U as DEFAULT_PAGE_ROWS, V as DETAIL_MODES, f as DashboardLayout, X as DateRangeOption, Y as DateRangePreset, Z as DeltaDirection, _ as DeltaSentiment, $ as DetailCell, a0 as DetailColumn, d as DetailData, a1 as DetailMode, a2 as DetailPage, a3 as DetailProvider, c as DetailProviderOptions, a4 as DetailProviders, e as DetailQuery, h as DetailSort, a5 as EMPTY_LAYOUT, a6 as EmptyWidget, a7 as EncodingOptions, a8 as EnforceLocksOptions, a9 as Err, aa as ErrorWidget, ab as FormatOptions, g as GaugeWidgetData, ac as GraphPoint, ad as GraphSeries, G as GraphWidgetData, ae as GridItem, af as KpiDelta, ag as KpiDeltaOptions, K as KpiWidgetData, ah as LAYOUT_ENVELOPE_VERSION, ai as LayoutItem, aj as LayoutPage, k as LayoutPersistence, ak as LayoutPersistenceOptions, al as LoadedLayout, am as LoadingWidget, L as Locale, an as MAX_DETAIL_PAGE_SIZE, ao as MAX_GRAPH_SERIES, ap as MAX_PAGE_ROWS, aq as MAX_PAGE_TITLE_LENGTH, ar as MAX_PARSED_PAGES, as as MAX_TEXT_OPTION_LENGTH, at as MAX_WIDGET_OPTIONS, au as MAX_WIDGET_WIDTH, av as MIN_WIDGET_WIDTH, N as NiceDomain, l as NormalizeOptions, aw as NumberOption, ax as OPTION_KEY_PATTERN, ay as Ok, az as OkWidget, aA as OptionContext, aB as OptionValue, O as OptionValues, P as PageItem, aC as PageOptions, aD as PageRoom, aE as PlacedRow, aF as ProviderOptions, aG as ResolvedDetailOptions, R as ResolvedTableControls, aH as ResolvedWidget, aI as ResolvedWidgetLock, aJ as RetryOptions, aK as SaveOptions, aL as SavedLayout, aM as SortDirection, aN as SortOption, aO as StorageAdapter, aP as StorageLogEvent, aQ as StoreErrorCode, aR as StoreResult, S as StoreScope, aS as StoredValue, aT as TableCell, aU as TableColumn, T as TableWidgetData, aV as TextOption, i as TextWidgetData, aW as VALUE_FORMATS, aX as ValueFormat, aY as WIDGET_FILLS, aZ as WIDGET_KINDS, a_ as WIDGET_OPTION_TYPES, a$ as WIDGET_SIZES, b0 as WIDTH_COLUMNS, b1 as WidgetCache, j as WidgetData, b2 as WidgetDataOf, b3 as WidgetDetailOptions, b4 as WidgetEmptyState, a as WidgetFill, b5 as WidgetLock, b6 as WidgetOption, b7 as WidgetProvider, W as WidgetSize, b8 as WidgetStatus, b9 as WidgetTableControls, ba as addPage, bb as applyClientOptions, bc as assignPages, bd as baseColumnSpan, be as cacheKeyFor, bf as coerceOptionValue, bg as createLayoutPersistence, bh as defaultDetailQuery, bi as defaultOptionValue, bj as defineWidget, bk as deriveDetailData, bl as describeUnknownError, bm as emptyTextFor, bn as emptyWidget, bo as enforceLocks, bp as err, bq as failedWidget, br as fillColumnSpans, bs as fillWidthSpans, bt as fillsHeight, bu as fillsWidth, bv as finalizeWidget, bw as fitCount, bx as formatCount, by as formatPercentChange, bz as formatValue, bA as hasPages, bB as hiddenWidgets, bC as hideWidget, bD as isClientApplied, bE as isColumnKeyFor, bF as isHidden, bG as isIsoInterval, bH as isMinimized, bI as isWidgetEmptyState, bJ as isWidgetKind, bK as isWidgetVisibleTo, bL as isWidgetWidth, bM as itemWidth, bN as kpiDelta, bO as labelStride, bP as loadingWidgets, bQ as memoryAdapter, bR as minimizeWidget, bS as movePage, bT as moveWidget, bU as moveWidgetBy, bV as moveWidgetDown, bW as moveWidgetToPage, bX as moveWidgetUp, bY as nextPageKey, bZ as niceDomain, b_ as niceStep, b$ as normalizeLayout, c0 as ok, c1 as optionValuesFor, c2 as optionsCacheSuffix, c3 as pageLayout, c4 as pageList, c5 as pageOf, c6 as pageRoom, c7 as pageWidgets, c8 as parseDetailQuery, c9 as parseLayout, ca as parseSortValue, cb as percentChange, cc as placeRows, cd as pruneLayout, ce as queryRows, cf as readOnly, cg as removePage, ch as renamePage, ci as resolveDateRange, cj as resolveDetailOptions, ck as resolveOptionValues, cl as resolvePageKey, cm as resolvePayload, cn as resolveTableControls, co as resolveWidget, cp as resolveWidgetLock, cq as resolveWidgetUnapplied, cr as resolveWidgets, cs as restoreWidget, ct as sameOptionValues, cu as serializeDetailQuery, cv as serializeLayout, cw as shareOf, cx as showWidget, cy as sortDefinitions, cz as sortFromOptions, cA as tableDetailData, cB as toggleHidden, cC as toggleMinimized, cD as usesWidthColumns, cE as utf8Length, cF as validateDetailData, cG as visibleWidgets, cH as widgetsFor, cI as widthForSize, cJ as withEncoding, cK as withFallback, cL as withLogging, cM as withPageLayout, cN as withPrefix, cO as withReadCache, cP as withRetry } from './storage-VaaysVnZ.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Maker Toolkit compatibility. Its API (`apps/api/src/widgets`) serves
|
|
@@ -33,71 +33,6 @@ interface LegacyWidgetDefinition {
|
|
|
33
33
|
*/
|
|
34
34
|
declare function fromLegacyDefinition(legacy: LegacyWidgetDefinition): WidgetDefinition | null;
|
|
35
35
|
|
|
36
|
-
/** The parts of a widget definition that decide its place in a grid. */
|
|
37
|
-
interface GridItem {
|
|
38
|
-
readonly key: string;
|
|
39
|
-
readonly defaultSize?: WidgetSize;
|
|
40
|
-
readonly fill?: WidgetFill;
|
|
41
|
-
readonly width?: number;
|
|
42
|
-
}
|
|
43
|
-
/** Columns in a grid that uses widget `width`. */
|
|
44
|
-
declare const WIDTH_COLUMNS = 12;
|
|
45
|
-
/** Smallest and largest `width`, in twelfths of a row. */
|
|
46
|
-
declare const MIN_WIDGET_WIDTH = 2;
|
|
47
|
-
declare const MAX_WIDGET_WIDTH = 12;
|
|
48
|
-
/** Whether `value` is a valid widget `width`: an integer from 2 to 12. */
|
|
49
|
-
declare function isWidgetWidth(value: unknown): value is number;
|
|
50
|
-
/** The width (in twelfths) a `defaultSize` stands for. Default `medium`. */
|
|
51
|
-
declare function widthForSize(size: WidgetSize | undefined): number;
|
|
52
|
-
/** The 12-column width of an item: its `width`, else from its size. */
|
|
53
|
-
declare function itemWidth(item: GridItem): number;
|
|
54
|
-
/** Whether a grid of `items` should use 12 columns (any item sets `width`). */
|
|
55
|
-
declare function usesWidthColumns(items: readonly GridItem[]): boolean;
|
|
56
|
-
/** Whether the widget should take the columns left over in its row. */
|
|
57
|
-
declare function fillsWidth(fill: WidgetFill | undefined): boolean;
|
|
58
|
-
/** Whether the widget should stretch to the height of its row. */
|
|
59
|
-
declare function fillsHeight(fill: WidgetFill | undefined): boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Columns a size takes in a grid of `columns` tracks: `large` spans
|
|
62
|
-
* `largeSpan` (default 2), `full` spans every column, anything else one.
|
|
63
|
-
*/
|
|
64
|
-
declare function baseColumnSpan(size: WidgetSize | undefined, columns: number, largeSpan?: number): number;
|
|
65
|
-
/**
|
|
66
|
-
* Places `items` in a grid of `columns` tracks the way a sparse grid
|
|
67
|
-
* auto-places them (left to right, wrapping to a new row when an item does
|
|
68
|
-
* not fit), then gives the columns left over in each row to the items that
|
|
69
|
-
* `fill` their width, shared evenly (earlier items get the remainder).
|
|
70
|
-
*
|
|
71
|
-
* Returns the column span for each width-filling item, keyed by `key`. Items
|
|
72
|
-
* that do not fill width keep their normal size and are not in the map.
|
|
73
|
-
*/
|
|
74
|
-
declare function fillColumnSpans(items: readonly GridItem[], columns: number, largeSpan?: number): Map<string, number>;
|
|
75
|
-
/**
|
|
76
|
-
* Like `fillColumnSpans` for a 12-column grid: each item starts at its
|
|
77
|
-
* `width` (see `itemWidth`) and width-fillers share the leftover twelfths.
|
|
78
|
-
*/
|
|
79
|
-
declare function fillWidthSpans(items: readonly GridItem[]): Map<string, number>;
|
|
80
|
-
/** One row of a placed grid: the widgets in it and their final column spans. */
|
|
81
|
-
interface PlacedRow {
|
|
82
|
-
readonly keys: readonly string[];
|
|
83
|
-
/** Column spans, in `keys` order, after width-fillers took the leftovers. */
|
|
84
|
-
readonly spans: readonly number[];
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* The rows `items` occupy in a 12-column grid, exactly as `fillWidthSpans`
|
|
88
|
-
* places them: left to right, a widget that doesn't fit in the rest of a row
|
|
89
|
-
* starts the next row whole (a widget is never split), and width-fillers then
|
|
90
|
-
* grow into the leftover columns. Growth never changes how many rows there
|
|
91
|
-
* are.
|
|
92
|
-
*/
|
|
93
|
-
declare function placeRows(items: readonly GridItem[]): readonly PlacedRow[];
|
|
94
|
-
/**
|
|
95
|
-
* How many of `items`, in order, fit in `maxRows` rows of a 12-column grid.
|
|
96
|
-
* Placement is left to right, so this is the length of the longest prefix
|
|
97
|
-
* whose rows number at most `maxRows`.
|
|
98
|
-
*/
|
|
99
|
-
declare function fitCount(items: readonly GridItem[], maxRows: number): number;
|
|
100
|
-
|
|
101
36
|
/**
|
|
102
37
|
* Loads widgets one by one, after the first render, and reports each result
|
|
103
38
|
* as it arrives. It is the logic behind the React `useWidgets` hook, kept
|
|
@@ -137,122 +72,21 @@ interface WidgetLoader {
|
|
|
137
72
|
* than the interval would otherwise be restarted forever and never finish).
|
|
138
73
|
*/
|
|
139
74
|
refresh(key?: string, options?: RefreshOptions): void;
|
|
75
|
+
/**
|
|
76
|
+
* Sets the values chosen for a widget's options (all of them: keys left out
|
|
77
|
+
* go back to their defaults). A choice only the toolkit applies (`sort` or
|
|
78
|
+
* `columns` with `apply: 'client'`) re-derives the payload it already has.
|
|
79
|
+
* A choice your provider sees reloads that widget alone: what is shown stays
|
|
80
|
+
* (marked `stale`) until the new data arrives, and an earlier answer for the
|
|
81
|
+
* same choices comes back from the cache. Does nothing when the resolved
|
|
82
|
+
* values don't change.
|
|
83
|
+
*/
|
|
84
|
+
setOptions(key: string, chosen: Readonly<Record<string, unknown>>): void;
|
|
140
85
|
/** Aborts everything in flight and ignores any later result. */
|
|
141
86
|
dispose(): void;
|
|
142
87
|
}
|
|
143
88
|
declare function createWidgetLoader<C extends WidgetContext>(options: WidgetLoaderOptions<C>): WidgetLoader;
|
|
144
89
|
|
|
145
|
-
/**
|
|
146
|
-
* Pages of widgets: a dashboard split into pages, like the home screens of a
|
|
147
|
-
* phone. Each page is a small layout (order, hidden, minimized) with a name
|
|
148
|
-
* and a capacity of `maxRows` rows of 12 columns. Pure functions, in the
|
|
149
|
-
* style of `layout.ts`: inputs are never mutated, a refusal is a `Result`
|
|
150
|
-
* with a specific message, and a no-op returns the same object.
|
|
151
|
-
*
|
|
152
|
-
* A layout without `pages` has one implicit page (`DEFAULT_PAGE_KEY`), so
|
|
153
|
-
* everything here also works on layouts saved before pages existed.
|
|
154
|
-
*/
|
|
155
|
-
|
|
156
|
-
/** The key of the implicit page of a layout that has no `pages`. */
|
|
157
|
-
declare const DEFAULT_PAGE_KEY = "default";
|
|
158
|
-
/** Rows a page holds unless it (or the dashboard) says otherwise. */
|
|
159
|
-
declare const DEFAULT_PAGE_ROWS = 4;
|
|
160
|
-
/** What the page functions need from a widget definition. */
|
|
161
|
-
type PageItem = LayoutItem & GridItem & {
|
|
162
|
-
/** Used in messages; the key stands in when absent. */
|
|
163
|
-
readonly title?: string;
|
|
164
|
-
};
|
|
165
|
-
interface PageOptions {
|
|
166
|
-
/** Rows a page holds when it has no `maxRows` of its own. Default 4. */
|
|
167
|
-
readonly maxRows?: number;
|
|
168
|
-
}
|
|
169
|
-
/** Whether the layout has pages of its own (rather than one implicit page). */
|
|
170
|
-
declare function hasPages(layout: DashboardLayout): boolean;
|
|
171
|
-
/**
|
|
172
|
-
* The layout's pages. A layout without `pages` has one implicit page called
|
|
173
|
-
* "Page 1" made from its top-level lists.
|
|
174
|
-
*/
|
|
175
|
-
declare function pageList(layout: DashboardLayout): readonly LayoutPage[];
|
|
176
|
-
/**
|
|
177
|
-
* One page as an ordinary layout, so every function in `layout.ts` (move,
|
|
178
|
-
* hide, minimize, `visibleWidgets`) works on it unchanged. For a layout with
|
|
179
|
-
* no pages this is the layout itself. Undefined for an unknown page.
|
|
180
|
-
*/
|
|
181
|
-
declare function pageLayout(layout: DashboardLayout, pageKey: string): DashboardLayout | undefined;
|
|
182
|
-
/**
|
|
183
|
-
* Writes a page's layout (changed with the functions in `layout.ts`) back
|
|
184
|
-
* into the whole layout. Returns the same object when nothing changed or the
|
|
185
|
-
* page doesn't exist.
|
|
186
|
-
*/
|
|
187
|
-
declare function withPageLayout(layout: DashboardLayout, pageKey: string, next: DashboardLayout): DashboardLayout;
|
|
188
|
-
/** The key of the page a `page` reference names: a key, else a title. */
|
|
189
|
-
declare function resolvePageKey(layout: DashboardLayout, reference: string | undefined): string | undefined;
|
|
190
|
-
/**
|
|
191
|
-
* Which page each widget shows on: the page that lists it (in its order or
|
|
192
|
-
* hidden list), else its home page (`definition.page`, else the first page).
|
|
193
|
-
* A widget locked against moving always shows on its home page, so a viewer's
|
|
194
|
-
* saved layout can't move it. Definitions keep their input order.
|
|
195
|
-
*/
|
|
196
|
-
declare function assignPages<T extends LayoutItem>(definitions: readonly T[], layout: DashboardLayout): Map<string, T[]>;
|
|
197
|
-
/** The key of the page a widget shows on; undefined if it isn't a definition. */
|
|
198
|
-
declare function pageOf<T extends LayoutItem>(definitions: readonly T[], layout: DashboardLayout, key: string): string | undefined;
|
|
199
|
-
/** A page's visible widgets, in display order (minimized ones included). */
|
|
200
|
-
declare function pageWidgets<T extends LayoutItem>(definitions: readonly T[], layout: DashboardLayout, pageKey: string): T[];
|
|
201
|
-
/** How full a page is. */
|
|
202
|
-
interface PageRoom {
|
|
203
|
-
readonly maxRows: number;
|
|
204
|
-
readonly rowsUsed: number;
|
|
205
|
-
readonly rowsFree: number;
|
|
206
|
-
}
|
|
207
|
-
/** Rows a page allows, uses and has left, as the grid will draw them. */
|
|
208
|
-
declare function pageRoom<T extends PageItem>(definitions: readonly T[], layout: DashboardLayout, pageKey: string, options?: PageOptions): PageRoom | undefined;
|
|
209
|
-
/** The first `page-N` key no page uses. */
|
|
210
|
-
declare function nextPageKey(layout: DashboardLayout): string;
|
|
211
|
-
interface AddPageOptions {
|
|
212
|
-
/** The new page's title. Default: the next free "Page N". */
|
|
213
|
-
readonly title?: string;
|
|
214
|
-
/** The new page's key. Default: the next free `page-N`. */
|
|
215
|
-
readonly key?: string;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Adds an empty page after the last one. A layout without pages gains an
|
|
219
|
-
* explicit first page holding everything it had.
|
|
220
|
-
*/
|
|
221
|
-
declare function addPage(layout: DashboardLayout, options?: AddPageOptions): Result<DashboardLayout>;
|
|
222
|
-
/** Renames a page. The same layout comes back when the title is unchanged. */
|
|
223
|
-
declare function renamePage(layout: DashboardLayout, pageKey: string, title: string): Result<DashboardLayout>;
|
|
224
|
-
/**
|
|
225
|
-
* Moves a page `offset` places (negative is earlier), clamped at the ends.
|
|
226
|
-
* Returns the same layout when nothing moves.
|
|
227
|
-
*/
|
|
228
|
-
declare function movePage(layout: DashboardLayout, pageKey: string, offset: number): DashboardLayout;
|
|
229
|
-
/**
|
|
230
|
-
* Removes a page. Its widgets move to the end of the previous page (the next
|
|
231
|
-
* one when it was first), keeping their hidden and minimized state. Refused
|
|
232
|
-
* for the only page, and when the widgets wouldn't fit on the pages left.
|
|
233
|
-
*/
|
|
234
|
-
declare function removePage<T extends PageItem>(definitions: readonly T[], layout: DashboardLayout, pageKey: string, options?: PageOptions): Result<DashboardLayout>;
|
|
235
|
-
/**
|
|
236
|
-
* Moves a widget to the end of another page, keeping its hidden and
|
|
237
|
-
* minimized state. Refused for an unknown widget or page, for a widget locked
|
|
238
|
-
* against moving, and when a visible widget wouldn't fit in the page's rows.
|
|
239
|
-
*/
|
|
240
|
-
declare function moveWidgetToPage<T extends PageItem>(definitions: readonly T[], layout: DashboardLayout, widgetKey: string, targetKey: string, options?: PageOptions): Result<DashboardLayout>;
|
|
241
|
-
interface NormalizeOptions extends PageOptions {
|
|
242
|
-
/** Skip lock enforcement, for a user who may rearrange locked widgets. */
|
|
243
|
-
readonly overrideLocks?: boolean;
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Repairs a layout so it can be trusted, for the place it is saved: unknown
|
|
247
|
-
* widgets are dropped, locks are enforced, and in a paged layout each widget
|
|
248
|
-
* lives on one page, titles are trimmed, unique and short, widgets no page
|
|
249
|
-
* lists yet are placed (on their home page), and a page that holds too many
|
|
250
|
-
* rows has its overflow moved, in order, to the next page with room or a new
|
|
251
|
-
* page after it. Nothing is hidden or dropped to make room. Idempotent;
|
|
252
|
-
* returns the same object when nothing changes.
|
|
253
|
-
*/
|
|
254
|
-
declare function normalizeLayout<T extends PageItem>(definitions: readonly T[], layout: DashboardLayout, options?: NormalizeOptions): DashboardLayout;
|
|
255
|
-
|
|
256
90
|
/**
|
|
257
91
|
* Link and image URL checks. Payloads often come from an API, so a link is
|
|
258
92
|
* only rendered when it can't run script: http(s), mailto, or a relative
|
|
@@ -290,4 +124,4 @@ declare function validateWidgetData(value: unknown, options?: ValidateWidgetData
|
|
|
290
124
|
*/
|
|
291
125
|
declare function validateWidgetDefinition(value: unknown): Result<WidgetDefinition>;
|
|
292
126
|
|
|
293
|
-
export {
|
|
127
|
+
export { DashboardWidget, type LegacyWidgetDefinition, MAX_REPORTED_PROBLEMS, type RefreshOptions, ResolveOptions, Result, type ValidateWidgetDataOptions, WidgetContext, WidgetDefinition, WidgetKind, type WidgetLoader, type WidgetLoaderOptions, WidgetPayload, WidgetProviders, createWidgetLoader, fromLegacyDefinition, isSafeHref, isSafeImageUrl, upgradeLegacyWidgetData, validateWidgetData, validateWidgetDefinition };
|