@dou-ui/dashboard 0.0.0-stage → 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +10 -2
- package/dist/chart/chart-settings.js +6 -0
- package/dist/chart/chart-settings.js.map +1 -0
- package/dist/chart/chart-settings.vue_vue_type_script_setup_true_lang.js +122 -0
- package/dist/chart/chart-settings.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/chart/chart.js +6 -0
- package/dist/chart/chart.js.map +1 -0
- package/dist/chart/chart.vue_vue_type_script_setup_true_lang.js +99 -0
- package/dist/chart/chart.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/chart/index.js +33 -0
- package/dist/chart/index.js.map +1 -0
- package/dist/collaboration/index.js +281 -0
- package/dist/collaboration/index.js.map +1 -0
- package/dist/collaboration/order.js +88 -0
- package/dist/collaboration/order.js.map +1 -0
- package/dist/core/document.js +128 -0
- package/dist/core/document.js.map +1 -0
- package/dist/core/history.js +66 -0
- package/dist/core/history.js.map +1 -0
- package/dist/core/transaction.js +218 -0
- package/dist/core/transaction.js.map +1 -0
- package/dist/dashboard/dashboard.js +6 -0
- package/dist/dashboard/dashboard.js.map +1 -0
- package/dist/dashboard/dashboard.vue_vue_type_script_setup_true_lang.js +1072 -0
- package/dist/dashboard/dashboard.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/dashboard/export.js +77 -0
- package/dist/dashboard/export.js.map +1 -0
- package/dist/dashboard/filter-bar.js +6 -0
- package/dist/dashboard/filter-bar.js.map +1 -0
- package/dist/dashboard/filter-bar.vue_vue_type_script_setup_true_lang.js +150 -0
- package/dist/dashboard/filter-bar.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/dashboard/frame-context.js +5 -0
- package/dist/dashboard/frame-context.js.map +1 -0
- package/dist/dashboard/observers.js +48 -0
- package/dist/dashboard/observers.js.map +1 -0
- package/dist/dashboard/palette.js +6 -0
- package/dist/dashboard/palette.js.map +1 -0
- package/dist/dashboard/palette.vue_vue_type_script_setup_true_lang.js +54 -0
- package/dist/dashboard/palette.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/dashboard/widget-body.js +6 -0
- package/dist/dashboard/widget-body.js.map +1 -0
- package/dist/dashboard/widget-body.vue_vue_type_script_setup_true_lang.js +96 -0
- package/dist/dashboard/widget-body.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/dashboard/widget-frame.js +6 -0
- package/dist/dashboard/widget-frame.js.map +1 -0
- package/dist/dashboard/widget-frame.vue_vue_type_script_setup_true_lang.js +300 -0
- package/dist/dashboard/widget-frame.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/dashboard/widget-settings.js +6 -0
- package/dist/dashboard/widget-settings.js.map +1 -0
- package/dist/dashboard/widget-settings.vue_vue_type_script_setup_true_lang.js +36 -0
- package/dist/dashboard/widget-settings.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/data/context.js +5 -0
- package/dist/data/context.js.map +1 -0
- package/dist/data/filters.js +31 -0
- package/dist/data/filters.js.map +1 -0
- package/dist/data/store.js +214 -0
- package/dist/data/store.js.map +1 -0
- package/dist/grid/grid-handle.js +6 -0
- package/dist/grid/grid-handle.js.map +1 -0
- package/dist/grid/grid-handle.vue_vue_type_script_setup_true_lang.js +21 -0
- package/dist/grid/grid-handle.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/grid/grid-item.js +80 -0
- package/dist/grid/grid-item.js.map +1 -0
- package/dist/grid/grid-layout.js +6 -0
- package/dist/grid/grid-layout.js.map +1 -0
- package/dist/grid/grid-layout.vue_vue_type_script_setup_true_lang.js +767 -0
- package/dist/grid/grid-layout.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/grid/tiers.js +31 -0
- package/dist/grid/tiers.js.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/layout/engine.js +284 -0
- package/dist/layout/engine.js.map +1 -0
- package/dist/layout/index.js +1 -0
- package/dist/locale.js +245 -0
- package/dist/locale.js.map +1 -0
- package/dist/pivot/index.js +47 -0
- package/dist/pivot/index.js.map +1 -0
- package/dist/pivot/pivot-settings.js +6 -0
- package/dist/pivot/pivot-settings.js.map +1 -0
- package/dist/pivot/pivot-settings.vue_vue_type_script_setup_true_lang.js +64 -0
- package/dist/pivot/pivot-settings.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/pivot/pivot.js +6 -0
- package/dist/pivot/pivot.js.map +1 -0
- package/dist/pivot/pivot.vue_vue_type_script_setup_true_lang.js +76 -0
- package/dist/pivot/pivot.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/style.d.ts +1 -0
- package/dist/style.js +12 -0
- package/dist/types/chart/chart-settings.vue.d.ts +11 -0
- package/dist/types/chart/chart.vue.d.ts +3 -0
- package/dist/types/chart/index.d.ts +9 -0
- package/dist/types/chart/types.d.ts +23 -0
- package/dist/types/collaboration/index.d.ts +53 -0
- package/dist/types/collaboration/order.d.ts +20 -0
- package/dist/types/core/collaboration.d.ts +51 -0
- package/dist/types/core/document.d.ts +35 -0
- package/dist/types/core/history.d.ts +15 -0
- package/dist/types/core/transaction.d.ts +86 -0
- package/dist/types/core/types.d.ts +27 -0
- package/dist/types/dashboard/dashboard.vue.d.ts +33 -0
- package/dist/types/dashboard/export.d.ts +11 -0
- package/dist/types/dashboard/filter-bar.vue.d.ts +19 -0
- package/dist/types/dashboard/frame-context.d.ts +54 -0
- package/dist/types/dashboard/observers.d.ts +15 -0
- package/dist/types/dashboard/palette.vue.d.ts +20 -0
- package/dist/types/dashboard/types.d.ts +190 -0
- package/dist/types/dashboard/widget-body.vue.d.ts +19 -0
- package/dist/types/dashboard/widget-frame.vue.d.ts +6 -0
- package/dist/types/dashboard/widget-settings.vue.d.ts +16 -0
- package/dist/types/data/context.d.ts +18 -0
- package/dist/types/data/filters.d.ts +9 -0
- package/dist/types/data/store.d.ts +48 -0
- package/dist/types/data/types.d.ts +67 -0
- package/dist/types/grid/grid-handle.vue.d.ts +18 -0
- package/dist/types/grid/grid-item.d.ts +78 -0
- package/dist/types/grid/grid-layout.vue.d.ts +46 -0
- package/dist/types/grid/tiers.d.ts +12 -0
- package/dist/types/grid/types.d.ts +113 -0
- package/dist/types/index.d.ts +295 -0
- package/dist/types/layout/engine.d.ts +50 -0
- package/dist/types/layout/index.d.ts +2 -0
- package/dist/types/layout/types.d.ts +39 -0
- package/dist/types/locale.d.ts +117 -0
- package/dist/types/pivot/index.d.ts +14 -0
- package/dist/types/pivot/pivot-settings.vue.d.ts +16 -0
- package/dist/types/pivot/pivot.vue.d.ts +7 -0
- package/dist/types/pivot/types.d.ts +11 -0
- package/dist/types/widget/context.d.ts +91 -0
- package/dist/types/widget/define.d.ts +50 -0
- package/dist/types/widgets/field-select.vue.d.ts +18 -0
- package/dist/types/widgets/index.d.ts +15 -0
- package/dist/types/widgets/settings-field.vue.d.ts +17 -0
- package/dist/types/widgets/shared.d.ts +20 -0
- package/dist/types/widgets/source-field.vue.d.ts +15 -0
- package/dist/types/widgets/stat-settings.vue.d.ts +11 -0
- package/dist/types/widgets/stat.vue.d.ts +3 -0
- package/dist/types/widgets/table-settings.vue.d.ts +11 -0
- package/dist/types/widgets/table.vue.d.ts +3 -0
- package/dist/types/widgets/text-settings.vue.d.ts +11 -0
- package/dist/types/widgets/text.vue.d.ts +3 -0
- package/dist/types/widgets/types.d.ts +38 -0
- package/dist/widget/context.js +88 -0
- package/dist/widget/context.js.map +1 -0
- package/dist/widget/define.js +32 -0
- package/dist/widget/define.js.map +1 -0
- package/dist/widgets/field-select.js +6 -0
- package/dist/widgets/field-select.js.map +1 -0
- package/dist/widgets/field-select.vue_vue_type_script_setup_true_lang.js +54 -0
- package/dist/widgets/field-select.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/widgets/index.js +74 -0
- package/dist/widgets/index.js.map +1 -0
- package/dist/widgets/settings-field.js +6 -0
- package/dist/widgets/settings-field.js.map +1 -0
- package/dist/widgets/settings-field.vue_vue_type_script_setup_true_lang.js +28 -0
- package/dist/widgets/settings-field.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/widgets/shared.js +68 -0
- package/dist/widgets/shared.js.map +1 -0
- package/dist/widgets/source-field.js +6 -0
- package/dist/widgets/source-field.js.map +1 -0
- package/dist/widgets/source-field.vue_vue_type_script_setup_true_lang.js +47 -0
- package/dist/widgets/source-field.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/widgets/stat-settings.js +6 -0
- package/dist/widgets/stat-settings.js.map +1 -0
- package/dist/widgets/stat-settings.vue_vue_type_script_setup_true_lang.js +107 -0
- package/dist/widgets/stat-settings.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/widgets/stat.js +6 -0
- package/dist/widgets/stat.js.map +1 -0
- package/dist/widgets/stat.vue_vue_type_script_setup_true_lang.js +72 -0
- package/dist/widgets/stat.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/widgets/table-settings.js +6 -0
- package/dist/widgets/table-settings.js.map +1 -0
- package/dist/widgets/table-settings.vue_vue_type_script_setup_true_lang.js +90 -0
- package/dist/widgets/table-settings.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/widgets/table.js +6 -0
- package/dist/widgets/table.js.map +1 -0
- package/dist/widgets/table.vue_vue_type_script_setup_true_lang.js +91 -0
- package/dist/widgets/table.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/widgets/text-settings.js +6 -0
- package/dist/widgets/text-settings.js.map +1 -0
- package/dist/widgets/text-settings.vue_vue_type_script_setup_true_lang.js +63 -0
- package/dist/widgets/text-settings.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/widgets/text.js +6 -0
- package/dist/widgets/text.js.map +1 -0
- package/dist/widgets/text.vue_vue_type_script_setup_true_lang.js +16 -0
- package/dist/widgets/text.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/package.json +98 -4
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { collaborationColors } from 'dou-ui';
|
|
2
|
+
import * as Y from 'yjs';
|
|
3
|
+
import type { DashboardCollaboration, DashboardPeer, DashboardPresence } from '../core/collaboration';
|
|
4
|
+
import type { DashboardDocument } from '../core/types';
|
|
5
|
+
/** The part of an `Awareness` (`y-protocols/awareness`) the dashboard uses. */
|
|
6
|
+
export interface AwarenessLike {
|
|
7
|
+
clientID: number;
|
|
8
|
+
getLocalState(): Record<string, unknown> | null;
|
|
9
|
+
setLocalStateField(field: string, value: unknown): void;
|
|
10
|
+
getStates(): Map<number, Record<string, unknown>>;
|
|
11
|
+
on(event: 'change', listener: (...args: unknown[]) => void): void;
|
|
12
|
+
off(event: 'change', listener: (...args: unknown[]) => void): void;
|
|
13
|
+
}
|
|
14
|
+
/** How the people editing together see each other. */
|
|
15
|
+
export interface CollaborationUser {
|
|
16
|
+
name: string;
|
|
17
|
+
/** The color of this user's outlines, any CSS color. Picked from the client id when left out. */
|
|
18
|
+
color?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface CollaborationOptions {
|
|
21
|
+
/** Where the widgets live, e.g. `ydoc.getMap('widgets')`. */
|
|
22
|
+
widgets: Y.Map<unknown>;
|
|
23
|
+
/** Shares which widget each person is at, and what they do there (`y-protocols/awareness`). */
|
|
24
|
+
awareness?: AwarenessLike;
|
|
25
|
+
/** This user, shown to the others. Needs `awareness`. */
|
|
26
|
+
user?: CollaborationUser;
|
|
27
|
+
}
|
|
28
|
+
export { collaborationColors };
|
|
29
|
+
export type { DashboardPeer, DashboardPresence };
|
|
30
|
+
/**
|
|
31
|
+
* Writes a dashboard into an empty map, e.g. when a dashboard so far saved
|
|
32
|
+
* as JSON starts being edited together. Do it once, where the shared
|
|
33
|
+
* document is created; otherwise the first person to open the dashboard
|
|
34
|
+
* brings theirs.
|
|
35
|
+
*/
|
|
36
|
+
export declare function fillMap(map: Y.Map<unknown>, document: DashboardDocument): void;
|
|
37
|
+
/** The dashboard the map holds: its widgets by their order keys (then ids, the same for everyone). */
|
|
38
|
+
export declare function readMap(map: Y.Map<unknown>): DashboardDocument;
|
|
39
|
+
/**
|
|
40
|
+
* Edit a dashboard together through a Yjs document: pass the result to
|
|
41
|
+
* `DouDashboard` as `collaboration`. Each widget lives in `widgets` as its
|
|
42
|
+
* own `Y.Map`, each key on its own and each breakpoint's place on its own,
|
|
43
|
+
* so two people changing different widgets, or different settings of one,
|
|
44
|
+
* both keep their change. When two people move widgets at once, everyone
|
|
45
|
+
* lays the places out the same way, so the dashboards agree. While a widget
|
|
46
|
+
* is dragged, changes from others wait until it is let go. The dashboard's
|
|
47
|
+
* `v-model` only mirrors the shared document: a document set through
|
|
48
|
+
* `v-model` from outside is not written back. Undo only takes back this
|
|
49
|
+
* user's own changes. With `awareness`, each person sees which widget the
|
|
50
|
+
* others are at, outlined in their colors, and whether they are moving,
|
|
51
|
+
* resizing or changing its settings.
|
|
52
|
+
*/
|
|
53
|
+
export declare function collaboration(options: CollaborationOptions): DashboardCollaboration;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Order keys: strings that sort like the widgets they belong to. A key can
|
|
3
|
+
* always be made between two others, so inserting a widget only
|
|
4
|
+
* writes that widget's key, never its neighbours'.
|
|
5
|
+
*/
|
|
6
|
+
/** A key after `a` and before `b`; either may be missing. Needs `a < b`. */
|
|
7
|
+
export declare function keyBetween(a: string | null, b: string | null): string;
|
|
8
|
+
/** `n` keys in order between `a` and `b`, kept short by splitting the range in halves. */
|
|
9
|
+
export declare function keysBetween(a: string | null, b: string | null, n: number): string[];
|
|
10
|
+
/**
|
|
11
|
+
* Which of `keys` (in their wanted order) can stay: the longest strictly
|
|
12
|
+
* increasing run. Missing keys (`null`) never stay. Returns the indexes.
|
|
13
|
+
*/
|
|
14
|
+
export declare function keptIndexes(keys: (string | null)[]): Set<number>;
|
|
15
|
+
/**
|
|
16
|
+
* Order keys for items in their wanted order, given each one's current key
|
|
17
|
+
* (`null` when it has none). The longest run already in order keeps its
|
|
18
|
+
* keys; the others get fresh keys between their kept neighbours.
|
|
19
|
+
*/
|
|
20
|
+
export declare function orderKeys(keys: (string | null)[]): string[];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { DashboardTransaction } from './transaction';
|
|
2
|
+
import type { DashboardDocument } from './types';
|
|
3
|
+
/** What a person is doing to a widget, shared with the others. */
|
|
4
|
+
export type DashboardPresenceAction = 'focus' | 'move' | 'resize' | 'settings';
|
|
5
|
+
/** What this person is doing, shared with the others; `null` when nothing. */
|
|
6
|
+
export interface DashboardPresence {
|
|
7
|
+
widget: string;
|
|
8
|
+
action: DashboardPresenceAction;
|
|
9
|
+
}
|
|
10
|
+
/** Another person at a widget. */
|
|
11
|
+
export interface DashboardPeer {
|
|
12
|
+
/** Their client id, unique among the people editing. */
|
|
13
|
+
client: number;
|
|
14
|
+
name: string;
|
|
15
|
+
/** Any CSS color. */
|
|
16
|
+
color: string;
|
|
17
|
+
action: DashboardPresenceAction;
|
|
18
|
+
}
|
|
19
|
+
/** What the dashboard hands a collaboration. */
|
|
20
|
+
export interface DashboardCollaborationHost {
|
|
21
|
+
/** The document as the dashboard shows it. */
|
|
22
|
+
document: () => DashboardDocument;
|
|
23
|
+
/**
|
|
24
|
+
* Shows a document changed by others (`remote`), or by undo and redo of
|
|
25
|
+
* the collaboration's own history. While a widget is being dragged here
|
|
26
|
+
* nothing changes; once it is let go, the dashboard calls `sync`.
|
|
27
|
+
*/
|
|
28
|
+
apply: (document: DashboardDocument, origin: 'remote' | 'undo' | 'redo') => void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Edits a dashboard together with others, given to `DouDashboard` as
|
|
32
|
+
* `collaboration`; made by `collaboration()` from
|
|
33
|
+
* `@dou-ui/dashboard/collaboration`. The dashboard hands it its changes and
|
|
34
|
+
* uses its undo and redo in place of its own.
|
|
35
|
+
*/
|
|
36
|
+
export interface DashboardCollaboration {
|
|
37
|
+
/** Starts sharing; returns a function that stops. */
|
|
38
|
+
setup: (host: DashboardCollaborationHost) => () => void;
|
|
39
|
+
/** A change made here, after the dashboard showed it. */
|
|
40
|
+
transaction: (tr: DashboardTransaction) => void;
|
|
41
|
+
/** Hands the dashboard the shared document again (through `apply`), e.g. once a drag ends. */
|
|
42
|
+
sync: () => void;
|
|
43
|
+
undo: () => boolean;
|
|
44
|
+
redo: () => boolean;
|
|
45
|
+
canUndo: () => boolean;
|
|
46
|
+
canRedo: () => boolean;
|
|
47
|
+
/** Shares what this person is doing. */
|
|
48
|
+
presence?: (presence: DashboardPresence | null) => void;
|
|
49
|
+
/** The others at a widget (reactive). */
|
|
50
|
+
peers?: (id: string) => readonly DashboardPeer[];
|
|
51
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { DashboardWidgetType } from '../widget/define';
|
|
2
|
+
import type { DashboardDocument, DashboardPlace } from './types';
|
|
3
|
+
/** A dashboard with no widgets, the `v-model` when none is bound. */
|
|
4
|
+
export declare const emptyDocument: () => DashboardDocument;
|
|
5
|
+
export interface DocumentProblem {
|
|
6
|
+
code: 'version' | 'shape' | 'duplicate-id' | 'missing-id' | 'unknown-type' | 'bad-place';
|
|
7
|
+
/** The widget at fault; none for the document's own problems. */
|
|
8
|
+
widgetId?: string;
|
|
9
|
+
/** Where the problem is, e.g. `widgets[2]` or `widgets[2].place.lg`; `version` for the version. */
|
|
10
|
+
path: string;
|
|
11
|
+
/** The id, type or breakpoint at fault, for the editor's message. */
|
|
12
|
+
text: string;
|
|
13
|
+
/** An English description, for logs. */
|
|
14
|
+
message: string;
|
|
15
|
+
}
|
|
16
|
+
export interface CheckDocumentOptions {
|
|
17
|
+
/** The registered widget types; without them, types are not checked. */
|
|
18
|
+
widgets?: readonly DashboardWidgetType<any>[];
|
|
19
|
+
}
|
|
20
|
+
/** Whether `value` is a place on a grid: whole numbers, the size at least 1. */
|
|
21
|
+
export declare function isDashboardPlace(value: unknown): value is DashboardPlace;
|
|
22
|
+
/**
|
|
23
|
+
* The problems of a dashboard document, before it is saved or shown: an
|
|
24
|
+
* unknown version, widgets without an id or sharing one, types nobody
|
|
25
|
+
* registered, and places that are not whole cells.
|
|
26
|
+
*/
|
|
27
|
+
export declare function checkDocument(document: DashboardDocument, options?: CheckDocumentOptions): DocumentProblem[];
|
|
28
|
+
/**
|
|
29
|
+
* Brings a saved document up to the current version, and fills what an
|
|
30
|
+
* older or hand-written one may lack (`version`, `place`). Widgets that are
|
|
31
|
+
* not objects and places that are not whole cells are dropped; anything
|
|
32
|
+
* else is kept as it is. Throws for data that is not an object
|
|
33
|
+
* (an array, `null`, a string) and for a version it does not know.
|
|
34
|
+
*/
|
|
35
|
+
export declare function migrateDocument(input: unknown): DashboardDocument;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DashboardTransaction } from './transaction';
|
|
2
|
+
import type { DashboardDocument } from './types';
|
|
3
|
+
/** Undo and redo of a dashboard: the steps of each transaction and the steps that undo them. */
|
|
4
|
+
export declare class DashboardHistory {
|
|
5
|
+
private depth;
|
|
6
|
+
private done;
|
|
7
|
+
private undone;
|
|
8
|
+
constructor(depth?: number);
|
|
9
|
+
get canUndo(): boolean;
|
|
10
|
+
get canRedo(): boolean;
|
|
11
|
+
record(tr: DashboardTransaction, now?: number): void;
|
|
12
|
+
undo(document: DashboardDocument): DashboardTransaction | null;
|
|
13
|
+
redo(document: DashboardDocument): DashboardTransaction | null;
|
|
14
|
+
clear(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { DashboardDocument, DashboardWidget } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Keys of a widget to set; `undefined` removes the key. `id` and `type`
|
|
4
|
+
* cannot be set: remove the widget and add another instead.
|
|
5
|
+
*/
|
|
6
|
+
export type DashboardWidgetPatch = {
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
} & {
|
|
9
|
+
id?: never;
|
|
10
|
+
type?: never;
|
|
11
|
+
};
|
|
12
|
+
/** One change to a dashboard. `index` is where in `widgets` an added widget goes. */
|
|
13
|
+
export type DashboardStep = {
|
|
14
|
+
type: 'add';
|
|
15
|
+
widget: DashboardWidget;
|
|
16
|
+
index: number;
|
|
17
|
+
} | {
|
|
18
|
+
type: 'remove';
|
|
19
|
+
id: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'update';
|
|
22
|
+
id: string;
|
|
23
|
+
patch: DashboardWidgetPatch;
|
|
24
|
+
};
|
|
25
|
+
export interface DashboardTransactionMeta {
|
|
26
|
+
/** `false` keeps the change out of undo, e.g. a change from another person. */
|
|
27
|
+
history?: boolean;
|
|
28
|
+
/** Changes of the same group within a second become one undo step, e.g. typing in a setting. */
|
|
29
|
+
group?: string;
|
|
30
|
+
/** Where the change came from: `layout`, `menu`, `keyboard`, `settings`, `api`… */
|
|
31
|
+
origin?: string;
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
/** Deep equality of JSON values; key order doesn't matter. */
|
|
35
|
+
export declare function sameValue(a: unknown, b: unknown): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Changes to a dashboard, made step by step and then handed to the
|
|
38
|
+
* dashboard's `dispatch` as one change (one undo step). A step that changes
|
|
39
|
+
* nothing (a widget that isn't there, a patch to the same values, an id
|
|
40
|
+
* already in use) is left out.
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* const tr = dashboard.value.transaction()
|
|
44
|
+
* tr.update('orders', { title: '本周订单' }).remove('memo')
|
|
45
|
+
* dashboard.value.dispatch(tr)
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare class DashboardTransaction {
|
|
49
|
+
/** The document the transaction starts from. */
|
|
50
|
+
readonly before: DashboardDocument;
|
|
51
|
+
/** The document after the steps so far. */
|
|
52
|
+
doc: DashboardDocument;
|
|
53
|
+
readonly steps: DashboardStep[];
|
|
54
|
+
/** The steps that undo the ones so far, last one first. */
|
|
55
|
+
readonly inverse: DashboardStep[];
|
|
56
|
+
readonly meta: DashboardTransactionMeta;
|
|
57
|
+
constructor(
|
|
58
|
+
/** The document the transaction starts from. */
|
|
59
|
+
before: DashboardDocument);
|
|
60
|
+
/** Whether any step was made. */
|
|
61
|
+
get changed(): boolean;
|
|
62
|
+
/** Apply a step as it is. */
|
|
63
|
+
step(step: DashboardStep): this;
|
|
64
|
+
/** Put a widget into the document at `index` (the end by default). */
|
|
65
|
+
add(widget: DashboardWidget, index?: number): this;
|
|
66
|
+
/** Take a widget out. */
|
|
67
|
+
remove(id: string): this;
|
|
68
|
+
/** Set keys of a widget, e.g. `{ title }`, `{ props }` or `{ place }`; `undefined` removes a key. */
|
|
69
|
+
update(id: string, patch: DashboardWidgetPatch): this;
|
|
70
|
+
setMeta(key: string, value: unknown): this;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Applies steps to a document in one go, giving the transaction: its `doc`
|
|
74
|
+
* (unchanged widgets are kept as they are) and the `inverse` steps that
|
|
75
|
+
* undo it. For the server, tests, or saved steps.
|
|
76
|
+
*/
|
|
77
|
+
export declare function applySteps(document: DashboardDocument, steps: readonly DashboardStep[], meta?: DashboardTransactionMeta): DashboardTransaction;
|
|
78
|
+
/** A deep copy of a JSON value (also of a reactive one). */
|
|
79
|
+
export declare const cloneJson: <T>(value: T) => T;
|
|
80
|
+
/**
|
|
81
|
+
* Adds the steps that turn the transaction's document into `next`: widgets
|
|
82
|
+
* that are gone are removed, new ones added, changed keys updated, and the
|
|
83
|
+
* fewest widgets taken out and put back to match the order. Unchanged
|
|
84
|
+
* widgets keep their objects.
|
|
85
|
+
*/
|
|
86
|
+
export declare function replaceWidgets(tr: DashboardTransaction, next: DashboardDocument): DashboardTransaction;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Where a widget sits on one breakpoint's grid, in columns and rows. */
|
|
2
|
+
export interface DashboardPlace {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
w: number;
|
|
6
|
+
h: number;
|
|
7
|
+
}
|
|
8
|
+
/** One widget of a dashboard. Everything in it must survive `JSON.stringify`. */
|
|
9
|
+
export interface DashboardWidget<P extends object = Record<string, unknown>> {
|
|
10
|
+
id: string;
|
|
11
|
+
/** The `type` of a widget registered with `defineDashboardWidget`. */
|
|
12
|
+
type: string;
|
|
13
|
+
/** Shown in the widget's title bar; without one, the type's label is. */
|
|
14
|
+
title?: string;
|
|
15
|
+
/** The widget's own settings, read by its component. */
|
|
16
|
+
props?: P;
|
|
17
|
+
/**
|
|
18
|
+
* Where it sits, by breakpoint name. The widest breakpoint's place is the
|
|
19
|
+
* main one; a narrower breakpoint without one is laid out from it.
|
|
20
|
+
*/
|
|
21
|
+
place: Partial<Record<string, DashboardPlace>>;
|
|
22
|
+
}
|
|
23
|
+
/** A dashboard: a JSON document the app saves and loads itself. */
|
|
24
|
+
export interface DashboardDocument {
|
|
25
|
+
version: 1;
|
|
26
|
+
widgets: DashboardWidget[];
|
|
27
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DashboardTransaction } from '../core/transaction';
|
|
2
|
+
import type { DashboardDocument } from '../core/types';
|
|
3
|
+
import type { DashboardFilters } from '../data/types';
|
|
4
|
+
import type { DashboardWidgetType } from '../widget/define';
|
|
5
|
+
import type { DashboardExportErrorEvent, DashboardExpose, DashboardProps } from './types';
|
|
6
|
+
type __VLS_Props = Omit<DashboardProps, 'modelValue' | 'filters'>;
|
|
7
|
+
type __VLS_ModelProps = {
|
|
8
|
+
modelValue?: DashboardDocument;
|
|
9
|
+
'filters'?: DashboardFilters;
|
|
10
|
+
};
|
|
11
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
12
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, DashboardExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
13
|
+
change: (transaction: DashboardTransaction) => any;
|
|
14
|
+
"update:modelValue": (value: DashboardDocument) => any;
|
|
15
|
+
breakpointChange: (breakpoint: string) => any;
|
|
16
|
+
"update:filters": (value: DashboardFilters) => any;
|
|
17
|
+
exportError: (event: DashboardExportErrorEvent) => any;
|
|
18
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
19
|
+
onChange?: ((transaction: DashboardTransaction) => any) | undefined;
|
|
20
|
+
"onUpdate:modelValue"?: ((value: DashboardDocument) => any) | undefined;
|
|
21
|
+
onBreakpointChange?: ((breakpoint: string) => any) | undefined;
|
|
22
|
+
"onUpdate:filters"?: ((value: DashboardFilters) => any) | undefined;
|
|
23
|
+
onExportError?: ((event: DashboardExportErrorEvent) => any) | undefined;
|
|
24
|
+
}>, {
|
|
25
|
+
columns: number | Record<string, number>;
|
|
26
|
+
breakpoints: Record<string, number>;
|
|
27
|
+
rowHeight: number;
|
|
28
|
+
gap: number | [number, number];
|
|
29
|
+
compact: import("..").GridCompact;
|
|
30
|
+
widgets: DashboardWidgetType<any>[];
|
|
31
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
32
|
+
declare const _default: typeof __VLS_export;
|
|
33
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Options of a dashboard's `exportPNG`. */
|
|
2
|
+
export interface DashboardImageOptions {
|
|
3
|
+
/** Pixels per CSS px. 2 by default, sharp on most screens. */
|
|
4
|
+
pixelRatio?: number;
|
|
5
|
+
/** Fill the background with the page's color. On by default; `false` leaves it clear. */
|
|
6
|
+
background?: boolean;
|
|
7
|
+
/** Room around the dashboard, in px. 16 by default. */
|
|
8
|
+
padding?: number;
|
|
9
|
+
}
|
|
10
|
+
/** Draws an element as it is shown into a PNG image. */
|
|
11
|
+
export declare function elementToPNG(el: HTMLElement, options?: DashboardImageOptions): Promise<Blob>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DashboardFilterField } from '../data/types';
|
|
2
|
+
import type { DashboardFilterBarProps } from './types';
|
|
3
|
+
type __VLS_Slots = {
|
|
4
|
+
/** More controls at the end of the bar, e.g. a refresh button. */
|
|
5
|
+
default?: () => unknown;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_base: import("vue").DefineComponent<DashboardFilterBarProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<DashboardFilterBarProps> & Readonly<{}>, {
|
|
8
|
+
clearable: boolean;
|
|
9
|
+
for: import("./types").DashboardExpose | null;
|
|
10
|
+
fields: DashboardFilterField[];
|
|
11
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
13
|
+
declare const _default: typeof __VLS_export;
|
|
14
|
+
export default _default;
|
|
15
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
16
|
+
new (): {
|
|
17
|
+
$slots: S;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { SheetWorkbook } from '@dou-ui/sheet/core';
|
|
2
|
+
import type { Component, InjectionKey } from 'vue';
|
|
3
|
+
import type { DashboardPeer } from '../core/collaboration';
|
|
4
|
+
import type { DashboardWidget } from '../core/types';
|
|
5
|
+
import type { DashboardLinkedFilter } from '../data/types';
|
|
6
|
+
import type { DashboardMessages } from '../locale';
|
|
7
|
+
import type { DashboardWidgetType } from '../widget/define';
|
|
8
|
+
export type WidgetAction = 'settings' | 'fullscreen' | 'duplicate' | 'remove';
|
|
9
|
+
/** An exporter as the export menu lists it. */
|
|
10
|
+
export interface FrameExporter {
|
|
11
|
+
name: string;
|
|
12
|
+
label: string;
|
|
13
|
+
icon?: Component;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* What a widget's frame reads from its dashboard. The frame looks its widget
|
|
17
|
+
* up by id in a computed of its own, so a change to one widget draws only
|
|
18
|
+
* that widget's frame again, not every frame on the grid.
|
|
19
|
+
*/
|
|
20
|
+
export interface FrameContext {
|
|
21
|
+
widget: (id: string) => DashboardWidget | undefined;
|
|
22
|
+
type: (widget: DashboardWidget) => DashboardWidgetType<any> | undefined;
|
|
23
|
+
title: (widget: DashboardWidget) => string;
|
|
24
|
+
editing: () => boolean;
|
|
25
|
+
messages: () => DashboardMessages;
|
|
26
|
+
/** Whether a frame mounting now is drawn in full at once. */
|
|
27
|
+
eager: (id: string) => boolean;
|
|
28
|
+
/** Whether every widget is drawn in full now, to export or print the dashboard. */
|
|
29
|
+
all: () => boolean;
|
|
30
|
+
setProps: (id: string, patch: Record<string, unknown>, options?: {
|
|
31
|
+
group?: string;
|
|
32
|
+
}) => void;
|
|
33
|
+
action: (id: string, action: WidgetAction) => void;
|
|
34
|
+
rename: (id: string, title: string) => void;
|
|
35
|
+
/** The filters a widget set, shown in its title bar. */
|
|
36
|
+
linked: (id: string) => DashboardLinkedFilter[];
|
|
37
|
+
clearFilter: (key: string) => void;
|
|
38
|
+
/** The others at a widget, when editing together. */
|
|
39
|
+
peers: (id: string) => readonly DashboardPeer[];
|
|
40
|
+
/** How a widget gives its content as a workbook; returns what undoes it. */
|
|
41
|
+
setWorkbook: (id: string, get: () => SheetWorkbook | undefined) => () => void;
|
|
42
|
+
/** The exporters a widget's menu lists: none unless it gives a workbook. */
|
|
43
|
+
exporters: (id: string) => FrameExporter[];
|
|
44
|
+
/** Writes a widget's content with an exporter, by name, and downloads the file. */
|
|
45
|
+
exportTo: (id: string, exporter: string) => void;
|
|
46
|
+
/** Tells whether a widget is drawn in full, not only its title. */
|
|
47
|
+
setDrawn: (id: string, drawn: boolean) => void;
|
|
48
|
+
/** Whether a widget's content is being exported now. */
|
|
49
|
+
exporting: (id: string) => boolean;
|
|
50
|
+
/** Why the last export from a widget's menu failed. */
|
|
51
|
+
exportError: (id: string) => string | undefined;
|
|
52
|
+
clearExportError: (id: string) => void;
|
|
53
|
+
}
|
|
54
|
+
export declare const frameContextKey: InjectionKey<FrameContext>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { InjectionKey } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* One `ResizeObserver` and one `IntersectionObserver` for all the widgets of
|
|
4
|
+
* a dashboard, instead of one per widget: with hundreds of widgets, creating
|
|
5
|
+
* the observers is a large part of mounting them.
|
|
6
|
+
*/
|
|
7
|
+
export interface DashboardObservers {
|
|
8
|
+
/** Calls `callback` with the element's new size; returns a function that stops. */
|
|
9
|
+
size: (el: Element, callback: (entry: ResizeObserverEntry) => void) => () => void;
|
|
10
|
+
/** Calls `callback` once the element comes within two screens of view; returns a function that stops. */
|
|
11
|
+
near: (el: Element, callback: () => void) => () => void;
|
|
12
|
+
dispose: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const observersKey: InjectionKey<DashboardObservers>;
|
|
15
|
+
export declare function createObservers(): DashboardObservers;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DashboardWidgetType } from '../widget/define';
|
|
2
|
+
import type { DashboardPaletteProps } from './types';
|
|
3
|
+
type __VLS_Slots = {
|
|
4
|
+
/** Replaces what a button shows; `type` is the widget type. */
|
|
5
|
+
default?: (props: {
|
|
6
|
+
type: DashboardWidgetType<any>;
|
|
7
|
+
}) => unknown;
|
|
8
|
+
};
|
|
9
|
+
declare const __VLS_base: import("vue").DefineComponent<DashboardPaletteProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<DashboardPaletteProps> & Readonly<{}>, {
|
|
10
|
+
direction: "vertical" | "horizontal";
|
|
11
|
+
for: import("./types").DashboardExpose | null;
|
|
12
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
16
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
17
|
+
new (): {
|
|
18
|
+
$slots: S;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import type { SheetExporterOptionsOf } from '@dou-ui/sheet';
|
|
2
|
+
import type { SheetExporter } from '@dou-ui/sheet/core';
|
|
3
|
+
import type { DashboardCollaboration } from '../core/collaboration';
|
|
4
|
+
import type { DashboardTransaction } from '../core/transaction';
|
|
5
|
+
import type { DashboardDocument, DashboardPlace } from '../core/types';
|
|
6
|
+
import type { DashboardFilterField, DashboardFilters, DashboardLinkedFilter, DashboardSetFilterOptions, DashboardSources } from '../data/types';
|
|
7
|
+
import type { GridCompact } from '../layout/types';
|
|
8
|
+
import type { DashboardMessagesOverride } from '../locale';
|
|
9
|
+
import type { DashboardWidgetType } from '../widget/define';
|
|
10
|
+
import type { DashboardImageOptions } from './export';
|
|
11
|
+
export interface DashboardProps {
|
|
12
|
+
/** The dashboard, bound with `v-model`; a new document object after every change. */
|
|
13
|
+
modelValue?: DashboardDocument;
|
|
14
|
+
/** The kinds of widget it can hold, made with `defineDashboardWidget`. */
|
|
15
|
+
widgets?: DashboardWidgetType<any>[];
|
|
16
|
+
/**
|
|
17
|
+
* Where widgets get their data, by name; a widget names its source in
|
|
18
|
+
* `props.source`. Each source loads once for each set of filters, however
|
|
19
|
+
* many widgets show it. A source replaced by another function (or other
|
|
20
|
+
* options) loads again; define the functions once, not in the template.
|
|
21
|
+
*/
|
|
22
|
+
sources?: DashboardSources;
|
|
23
|
+
/** The filter values, bound with `v-model:filters`; widgets load their sources with them. */
|
|
24
|
+
filters?: DashboardFilters;
|
|
25
|
+
/** Whether widgets can be added, moved, resized, changed and removed. */
|
|
26
|
+
editable?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* How many columns the grid has: one number, or one per breakpoint.
|
|
29
|
+
* Defaults to `{ lg: 12, md: 6, sm: 1 }`.
|
|
30
|
+
*/
|
|
31
|
+
columns?: number | Record<string, number>;
|
|
32
|
+
/** The narrowest width of the dashboard at which each breakpoint applies, in px. Defaults to `{ lg: 1024, md: 640, sm: 0 }`. */
|
|
33
|
+
breakpoints?: Record<string, number>;
|
|
34
|
+
/** The height of a row, in px. Defaults to 80. */
|
|
35
|
+
rowHeight?: number;
|
|
36
|
+
/** The space between widgets, in px: one number, or `[across, down]`. Defaults to 16. */
|
|
37
|
+
gap?: number | [number, number];
|
|
38
|
+
/** `'vertical'` (the default) floats widgets up into gaps; `false` leaves them where they are put. */
|
|
39
|
+
compact?: GridCompact;
|
|
40
|
+
/** The dashboard's accessible name. */
|
|
41
|
+
label?: string;
|
|
42
|
+
/** Overrides of the built-in texts. */
|
|
43
|
+
messages?: DashboardMessagesOverride;
|
|
44
|
+
/** Makes the id of a new widget. Defaults to the type and a few random letters. */
|
|
45
|
+
createId?: (type: string) => string;
|
|
46
|
+
/**
|
|
47
|
+
* Edit together with others: `collaboration()` from
|
|
48
|
+
* `@dou-ui/dashboard/collaboration`. The document then comes from the
|
|
49
|
+
* shared one, and undo only takes back this person's own changes.
|
|
50
|
+
*/
|
|
51
|
+
collaboration?: DashboardCollaboration;
|
|
52
|
+
/**
|
|
53
|
+
* The file types a widget's content can be exported as, from the menu in
|
|
54
|
+
* its title bar: exporters of `@dou-ui/sheet`, such as `csvExporter` or
|
|
55
|
+
* `xlsxExporter` from `@dou-ui/sheet-xlsx`. Only widgets that give their
|
|
56
|
+
* content as a workbook (`setWorkbook`) have the menu: the built-in
|
|
57
|
+
* table, pivot table and chart do. Exporters that draw a sheet's grid,
|
|
58
|
+
* such as PNG, are left out.
|
|
59
|
+
*/
|
|
60
|
+
exporters?: readonly SheetExporter[];
|
|
61
|
+
}
|
|
62
|
+
/** Options of a dashboard's `exportWidget`. */
|
|
63
|
+
export interface DashboardExportOptions<Options = any> {
|
|
64
|
+
/** The exporter's own options, such as `{ bom: false }` for CSV. */
|
|
65
|
+
options?: Options;
|
|
66
|
+
/** Calls the export off. */
|
|
67
|
+
signal?: AbortSignal;
|
|
68
|
+
}
|
|
69
|
+
/** Options of a dashboard's `saveWidget`: `exportWidget`'s, and the file's name. */
|
|
70
|
+
export interface DashboardSaveOptions<Options = any> extends DashboardExportOptions<Options> {
|
|
71
|
+
/** The file's name, with its extension; the widget's title by default. */
|
|
72
|
+
fileName?: string;
|
|
73
|
+
}
|
|
74
|
+
/** A widget's export from its menu failed. */
|
|
75
|
+
export interface DashboardExportErrorEvent {
|
|
76
|
+
/** The widget's id. */
|
|
77
|
+
widget: string;
|
|
78
|
+
/** The exporter's name. */
|
|
79
|
+
exporter: string;
|
|
80
|
+
error: unknown;
|
|
81
|
+
/** What the dashboard shows over the widget's content, unless `preventDefault()` is called. */
|
|
82
|
+
message: string;
|
|
83
|
+
defaultPrevented: boolean;
|
|
84
|
+
/** Says the app tells of the failure itself. */
|
|
85
|
+
preventDefault: () => void;
|
|
86
|
+
}
|
|
87
|
+
export interface DashboardEmits {
|
|
88
|
+
'update:modelValue': [doc: DashboardDocument];
|
|
89
|
+
'update:filters': [filters: DashboardFilters];
|
|
90
|
+
/** After every change, with the steps that made it and those that undo it. */
|
|
91
|
+
change: [transaction: DashboardTransaction];
|
|
92
|
+
breakpointChange: [breakpoint: string];
|
|
93
|
+
/** Exporting a widget from its menu or `saveWidget` failed; the widget tells of it unless prevented. */
|
|
94
|
+
exportError: [event: DashboardExportErrorEvent];
|
|
95
|
+
}
|
|
96
|
+
export interface DashboardAddOptions {
|
|
97
|
+
/** Where on the widest breakpoint; defaults to the first spot it fits. */
|
|
98
|
+
at?: Pick<DashboardPlace, 'x' | 'y'>;
|
|
99
|
+
title?: string;
|
|
100
|
+
/** Merged over the type's `defaultProps`. */
|
|
101
|
+
props?: Record<string, unknown>;
|
|
102
|
+
/** Moves focus to the new widget. Defaults to `true`. */
|
|
103
|
+
focus?: boolean;
|
|
104
|
+
}
|
|
105
|
+
export interface DashboardExpose {
|
|
106
|
+
/** A transaction on the document as it is now: add, remove and update widgets, then `dispatch` it. */
|
|
107
|
+
transaction: () => DashboardTransaction;
|
|
108
|
+
/** Makes the changes of a transaction, as one undo step (or part of one, by `meta.group`). */
|
|
109
|
+
dispatch: (tr: DashboardTransaction) => void;
|
|
110
|
+
undo: () => boolean;
|
|
111
|
+
redo: () => boolean;
|
|
112
|
+
readonly canUndo: boolean;
|
|
113
|
+
readonly canRedo: boolean;
|
|
114
|
+
/** Adds a widget of a registered type; returns its id, or `undefined` for an unknown type. */
|
|
115
|
+
addWidget: (type: string, options?: DashboardAddOptions) => string | undefined;
|
|
116
|
+
removeWidget: (id: string) => void;
|
|
117
|
+
/** Adds a copy of a widget next to it; returns the copy's id. */
|
|
118
|
+
duplicateWidget: (id: string) => string | undefined;
|
|
119
|
+
focusWidget: (id: string) => void;
|
|
120
|
+
/** Opens the settings drawer of a widget (while editing). */
|
|
121
|
+
openSettings: (id: string) => void;
|
|
122
|
+
/** Shows a widget full screen. */
|
|
123
|
+
openFullscreen: (id: string) => void;
|
|
124
|
+
/**
|
|
125
|
+
* Starts dragging a new widget of a type in from outside: call it in that
|
|
126
|
+
* element's `pointerdown`. See `DouGridLayout`'s `startDrop`.
|
|
127
|
+
*/
|
|
128
|
+
startAdd: (event: PointerEvent, type: string) => void;
|
|
129
|
+
/** The registered widget types. */
|
|
130
|
+
readonly types: readonly DashboardWidgetType<any>[];
|
|
131
|
+
/** The breakpoint in use. */
|
|
132
|
+
readonly breakpoint: string;
|
|
133
|
+
readonly editable: boolean;
|
|
134
|
+
/** The document as it is now. */
|
|
135
|
+
readonly document: DashboardDocument;
|
|
136
|
+
/** The filter values in effect. */
|
|
137
|
+
readonly filters: DashboardFilters;
|
|
138
|
+
/** The filters set by widgets, e.g. by clicking a chart. */
|
|
139
|
+
readonly linkedFilters: readonly DashboardLinkedFilter[];
|
|
140
|
+
/** Sets a filter for every widget; an empty value (`undefined`, `null`, `''`, `[]`) clears it. */
|
|
141
|
+
setFilter: (key: string, value: unknown, options?: DashboardSetFilterOptions) => void;
|
|
142
|
+
clearFilters: () => void;
|
|
143
|
+
/** Loads the sources shown again: one by name, or all of them. */
|
|
144
|
+
refresh: (source?: string) => void;
|
|
145
|
+
/**
|
|
146
|
+
* The dashboard as a PNG image, every widget drawn (also those far from
|
|
147
|
+
* the view) once their data is in, without menus and buttons.
|
|
148
|
+
*/
|
|
149
|
+
exportPNG: (options?: DashboardImageOptions) => Promise<Blob>;
|
|
150
|
+
/**
|
|
151
|
+
* A widget's content as a file: the workbook it gives, written by an
|
|
152
|
+
* exporter (its name in `exporters`, or the exporter itself). Waits for
|
|
153
|
+
* the data, and draws the widget first when it is far from the view.
|
|
154
|
+
* Fails with a `SheetFileError` (`code: 'empty'`) for a widget that
|
|
155
|
+
* gives no workbook, such as a chart without its fields.
|
|
156
|
+
*/
|
|
157
|
+
exportWidget: {
|
|
158
|
+
<Name extends string>(id: string, exporter: Name, options?: DashboardExportOptions<SheetExporterOptionsOf<Name>>): Promise<Blob>;
|
|
159
|
+
<Options>(id: string, exporter: SheetExporter<Options>, options?: DashboardExportOptions<Options>): Promise<Blob>;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Exports as `exportWidget` does and saves the file in the downloads, as
|
|
163
|
+
* the widget's menu does. A failure shows over the widget and comes as
|
|
164
|
+
* `exportError`, and the promise rejects.
|
|
165
|
+
*/
|
|
166
|
+
saveWidget: {
|
|
167
|
+
<Name extends string>(id: string, exporter: Name, options?: DashboardSaveOptions<SheetExporterOptionsOf<Name>>): Promise<void>;
|
|
168
|
+
<Options>(id: string, exporter: SheetExporter<Options>, options?: DashboardSaveOptions<Options>): Promise<void>;
|
|
169
|
+
};
|
|
170
|
+
/** Draws every widget, waits for their data, and opens the print dialog. */
|
|
171
|
+
print: () => Promise<void>;
|
|
172
|
+
}
|
|
173
|
+
export interface DashboardPaletteProps {
|
|
174
|
+
/** The dashboard it adds to (its component instance, from a template ref). */
|
|
175
|
+
for?: DashboardExpose | null;
|
|
176
|
+
/** Only these types, in this order; defaults to every registered type. */
|
|
177
|
+
types?: string[];
|
|
178
|
+
/** How the list runs. Defaults to `vertical`. */
|
|
179
|
+
direction?: 'vertical' | 'horizontal';
|
|
180
|
+
}
|
|
181
|
+
export interface DashboardFilterBarProps {
|
|
182
|
+
/** The dashboard whose filters it sets (its component instance, from a template ref). */
|
|
183
|
+
for?: DashboardExpose | null;
|
|
184
|
+
/** The controls, in order. Filters set by widgets show after them, each with a button to clear it. */
|
|
185
|
+
fields?: DashboardFilterField[];
|
|
186
|
+
/** Shows a button clearing every filter while any is set. Defaults to `true`. */
|
|
187
|
+
clearable?: boolean;
|
|
188
|
+
/** Replaces texts of the language pack. */
|
|
189
|
+
messages?: DashboardMessagesOverride;
|
|
190
|
+
}
|