@perspective-dev/workspace 4.0.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.
Files changed (44) hide show
  1. package/LICENSE.md +193 -0
  2. package/dist/cdn/perspective-workspace.js +45 -0
  3. package/dist/cdn/perspective-workspace.js.map +7 -0
  4. package/dist/css/pro-dark.css +1 -0
  5. package/dist/css/pro.css +1 -0
  6. package/dist/esm/perspective-workspace.d.ts +181 -0
  7. package/dist/esm/perspective-workspace.js +14 -0
  8. package/dist/esm/perspective-workspace.js.map +7 -0
  9. package/dist/esm/utils/custom_elements.d.ts +14 -0
  10. package/dist/esm/utils/observable_map.d.ts +9 -0
  11. package/dist/esm/workspace/commands.d.ts +3 -0
  12. package/dist/esm/workspace/dockpanel.d.ts +13 -0
  13. package/dist/esm/workspace/index.d.ts +1 -0
  14. package/dist/esm/workspace/menu.d.ts +11 -0
  15. package/dist/esm/workspace/tabbar.d.ts +25 -0
  16. package/dist/esm/workspace/tabbarrenderer.d.ts +19 -0
  17. package/dist/esm/workspace/widget.d.ts +27 -0
  18. package/dist/esm/workspace/workspace.d.ts +123 -0
  19. package/package.json +55 -0
  20. package/src/html/workspace.html +11 -0
  21. package/src/less/dockpanel.less +95 -0
  22. package/src/less/injected.less +14 -0
  23. package/src/less/menu.less +128 -0
  24. package/src/less/tabbar.less +366 -0
  25. package/src/less/viewer.less +86 -0
  26. package/src/less/widget.less +40 -0
  27. package/src/less/workspace.less +70 -0
  28. package/src/svg/bookmark-icon.svg +4 -0
  29. package/src/svg/drag-handle.svg +10 -0
  30. package/src/themes/pro-dark.less +139 -0
  31. package/src/themes/pro.less +93 -0
  32. package/src/ts/external.d.ts +21 -0
  33. package/src/ts/external.js +11 -0
  34. package/src/ts/perspective-workspace.ts +306 -0
  35. package/src/ts/utils/custom_elements.ts +95 -0
  36. package/src/ts/utils/observable_map.ts +39 -0
  37. package/src/ts/workspace/commands.ts +269 -0
  38. package/src/ts/workspace/dockpanel.ts +145 -0
  39. package/src/ts/workspace/index.ts +13 -0
  40. package/src/ts/workspace/menu.ts +213 -0
  41. package/src/ts/workspace/tabbar.ts +237 -0
  42. package/src/ts/workspace/tabbarrenderer.ts +91 -0
  43. package/src/ts/workspace/widget.ts +101 -0
  44. package/src/ts/workspace/workspace.ts +1056 -0
@@ -0,0 +1 @@
1
+ perspective-workspace,perspective-workspace[theme="Pro Dark"],perspective-indicator[theme="Pro Dark"]{--theme-name:"Pro Dark";}perspective-workspace perspective-viewer{--status-bar--height:39px;}perspective-workspace perspective-viewer[settings]{--modal-panel--margin:-4px 0 -4px 0;--status-bar--border-radius:6px 0 0 0;--main-column--margin:3px 0 3px 3px;--main-column--border:1px solid var(--inactive--color);--main-column--border-width:1px 0px 1px 1px;--main-column--border-radius:6px 0 0 6px;--settings-button--margin:10px 0 0 0;}perspective-workspace{font-family:"ui-monospace","SFMono-Regular","SF Mono","Menlo","Consolas","Liberation Mono",monospace;--open-settings-button--content:"expand_more";--close-settings-button--content:"expand_less";--close-button--content:"\2715";--master-divider--background-color:#243136;--menu-maximize--content:"fullscreen";--menu-minimize--content:"fullscreen_exit";--menu-duplicate--content:"call_split";--menu-master--content:"cast";--menu-detail--content:"notes";--menu-export--content:"file_download";--menu-copy--content:"file_copy";--menu-reset--content:"autorenew";--menu-link--content:"link";--menu-unlink--content:"link_off";--menu-newmenu--content:"add";--menu-close--content:"close";--menu-new--content:"description";--menu-newview--content:"file_copy";--workspace-tabbar--border:1px solid var(--inactive--color);--workspace-tabbar--border-width:0px 1px 1px 1px;--workspace-tabbar--border-radius:6px;--workspace-tabbar--border-color:var(--inactive--color);--workspace-tabbar-tab--border-width:1px 1px 0px 1px;--column-drag-handle--mask-image:url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNSIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDUgMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+Cjxj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PSJNMTkgNEwyMSA2TDIzIDQiIHN0cm9rZT0iIzA0MjEyMSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+Cjwvc3ZnPgo=");background-color:#242526;--workspace-split-panel-handle--background-color:#242526;color:white;--icon--color:white;--active--color:#2770a9;--error--color:#ff9485;--inactive--color:#61656e;--inactive--border-color:#4c505b;--plugin--background:#242526;--modal-target--background:rgba(255,255,255,0.05);--active--background:rgba(39,113,170,0.5);--expression--operator-color:#c5c9d0;--expression--function-color:#22a0ce;--expression--error-color:rgb(255,136,136);--calendar--filter:invert(1);--warning--color:#242526;--warning--background:var(--icon--color);--select-arrow--background-image:var(--select-arrow-light--background-image);--select-arrow--hover--background-image:var(--select-arrow-dark--background-image);--code-editor-symbol--color:white;--code-editor-literal--color:#7dc3f0;--code-editor-operator--color:rgb(23,166,123);--code-editor-comment--color:rgb(204,120,48);--code-editor-column--color:#e18ee1;background-color:#000202;color:white;--workspace-tabbar--background-color:#242526;--workspace-secondary--color:#c5c9d0;--workspace-tabbar--border:1px solid var(--inactive--color);--workspace-tabbar--border-width:0px 1px 1px 1px;--workspace-tabbar--border-radius:6px;--workspace-tabbar--border-color:var(--inactive--color);--workspace-tabbar-tab--border-width:1px 1px 0 1px;}perspective-viewer.workspace-master-widget[theme="Pro Dark"]{--plugin--background:#242526;}perspective-workspace-menu{font-family:"ui-monospace","SFMono-Regular","SF Mono","Menlo","Consolas","Liberation Mono",monospace;font-weight:300;background:#2a2c2f!important;color:white!important;border:1px solid#3b3f46!important;}
@@ -0,0 +1 @@
1
+ perspective-workspace,perspective-workspace[theme="Pro Light"],perspective-indicator[theme="Pro Light"]{--theme-name:"Pro Light";}perspective-workspace{font-family:"ui-monospace","SFMono-Regular","SF Mono","Menlo","Consolas","Liberation Mono",monospace;--open-settings-button--content:"expand_more";--close-settings-button--content:"expand_less";--close-button--content:"\2715";--master-divider--background-color:#243136;--menu-maximize--content:"fullscreen";--menu-minimize--content:"fullscreen_exit";--menu-duplicate--content:"call_split";--menu-master--content:"cast";--menu-detail--content:"notes";--menu-export--content:"file_download";--menu-copy--content:"file_copy";--menu-reset--content:"autorenew";--menu-link--content:"link";--menu-unlink--content:"link_off";--menu-newmenu--content:"add";--menu-close--content:"close";--menu-new--content:"description";--menu-newview--content:"file_copy";--workspace-split-panel-handle--background-color:#f2f4f6;--workspace-tabbar--border:1px solid var(--inactive--color);--workspace-tabbar--border-width:0px 1px 1px 1px;--workspace-tabbar--border-radius:6px;--workspace-tabbar--border-color:var(--inactive--color);--workspace-tabbar-tab--border-width:1px 1px 0px 1px;--column-drag-handle--mask-image:url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNSIgaGVpZ2h0PSIxMiIgdmlld0JveD0iMCAwIDUgMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxjaXJjbGUgY3g9IjMuNDk5OTYiIGN5PSIxMS4wMDAxIiByPSIwLjgzMzMzMyIgZmlsbD0iIzZFNkU2RSIvPgo8Y2lyY2xlIGN4PSIwLjgzMzMzMyIgY3k9IjExLjAwMDEiIHI9IjAuODMzMzMzIiBmaWxsPSIjNkU2RTZFIi8+CjxjaXJjbGUgY3g9IjMuNDk5OTYiIGN5PSI3LjY2NjgzIiByPSIwLjgzMzMzMyIgZmlsbD0iIzZFNkU2RSIvPgo8Y2lyY2xlIGN4PSIwLjgzMzMzMyIgY3k9IjcuNjY2ODMiIHI9IjAuODMzMzMzIiBmaWxsPSIjNkU2RTZFIi8+CjxjaXJjbGUgY3g9IjMuNDk5OTYiIGN5PSI0LjMzMzMzIiByPSIwLjgzMzMzMyIgZmlsbD0iIzZFNkU2RSIvPgo8Y2lyY2xlIGN4PSIwLjgzMzMzMyIgY3k9IjQuMzMzMzMiIHI9IjAuODMzMzMzIiBmaWxsPSIjNkU2RTZFIi8+CjxjaXJjbGUgY3g9IjMuNDk5OTYiIGN5PSIxLjAwMDA4IiByPSIwLjgzMzMzMyIgZmlsbD0iIzZFNkU2RSIvPgo8Y2lyY2xlIGN4PSIwLjgzMzMzMyIgY3k9IjEuMDAwMDgiIHI9IjAuODMzMzMzIiBmaWxsPSIjNkU2RTZFIi8+Cjwvc3ZnPgo=");--bookmarks--mask-image:url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMTEiIHZpZXdCb3g9IjAgMCAyNCAxMSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICAgIDxwYXRoIGQ9Ik0zLjY2MjE0IDYuOTY0NzZMMC41IDkuODYzMzhWMC41SDcuNVY5Ljg2MzM4TDQuMzM3ODYgNi45NjQ3Nkw0IDYuNjU1MDVMMy42NjIxNCA2Ljk2NDc2WiIgc3Ryb2tlPSIjMDQyMTIxIi8+CiAgICA8cGF0aCBkPSJNMTkgNEwyMSA2TDIzIDQiIHN0cm9rZT0iIzA0MjEyMSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+Cjwvc3ZnPgo=");color:#161616;background-color:transparent;--icon--color:#161616;--inactive--color:#ababab;--inactive--border-color:#dadada;--root--background:#ffffff;--active--color:#2670a9;--error--color:#ff471e;--plugin--background:#ffffff;--overflow-hint-icon--color:rgba(0,0,0,0.2);--select--background-color:none;--column-drop-container--background:none;--warning--background:#042121;--warning--color:#fdfffd;--select-arrow--background-image:var(--select-arrow-dark--background-image);--select-arrow--hover--background-image:var(--select-arrow-light--background-image);--overflow-hint-icon--color:#fdfffd;background-color:#dadada;}perspective-workspace perspective-viewer[settings]{--modal-panel--margin:-4px 0 -4px 0;--status-bar--border-radius:6px 0 0 0;--main-column--margin:3px 0 3px 3px;--main-column--border:1px solid var(--inactive--color);--main-column--border-width:1px 0px 1px 1px;--main-column--border-radius:6px 0 0 6px;--settings-button--margin:10px 0 0 0;}perspective-workspace perspective-viewer{--status-bar--height:39px;}perspective-viewer.workspace-master-widget[theme="Pro Light"]{background-color:#f2f4f6;--plugin--background:#f2f4f6;}perspective-viewer.workspace-master-widget[theme="Pro Light"] regular-table td,perspective-viewer.workspace-master-widget[theme="Pro Light"] regular-table th{border-color:#e0e4e9;}perspective-workspace-menu{font-family:"ui-monospace","SFMono-Regular","SF Mono","Menlo","Consolas","Liberation Mono",monospace;font-weight:300;color:#161616;}
@@ -0,0 +1,181 @@
1
+ import type * as psp from "@perspective-dev/client";
2
+ export { PerspectiveWorkspace } from "./workspace";
3
+ export { PerspectiveViewerWidget } from "./workspace/widget";
4
+ import "./external";
5
+ import { PerspectiveWorkspaceConfig, ViewerConfigUpdateExt } from "./workspace";
6
+ /**
7
+ * A Custom Element for coordinating a set of `<perspective-viewer>` light DOM
8
+ * children. `<perspective-workspace>` is built on Lumino.js to allow a more
9
+ * app-like experience than `<perspective-viewer>`, providing
10
+ * these features additionally:
11
+ *
12
+ * - Docking, arranging, tabbing and max/min-ing of `<perspective-viewer>`s.
13
+ * - Trivial `<perspective-viewer>` duplication.
14
+ * - Global Filter sidebar, for using selection state of a pivot table to filter
15
+ * siblings.
16
+ * - Total persistence/serializable state and child state.
17
+ * - Easy sharing/ownership of `Table()` among different `<perspective-viewer>`.
18
+ * - A cool DOM-reactive API.
19
+ *
20
+ * There are a few ways to use this Custom Element. In plain HTML, you can
21
+ * express your initial view simply:
22
+ *
23
+ * ```html
24
+ * <perspective-workspace>
25
+ * <perspective-viewer
26
+ * name="View One"
27
+ * table="superstore">
28
+ * </perspective-viewer>
29
+ * <perspective-viewer
30
+ * name="View Two"
31
+ * table="superstore">
32
+ * </perspective-viewer>
33
+ * </perspective-workspace>
34
+ * ```
35
+ *
36
+ * You can also use the DOM API in Javascript:
37
+ *
38
+ * ```javascript
39
+ * const workspace = document.createElement("perspective-workspace");
40
+ * const viewer = document.createElement("perspective-viewer");
41
+ * workspace.appendChild(viewer);
42
+ * document.body.appendChild(workspace);
43
+ * ```
44
+ *
45
+ * This will yield a `<perspective-workspace> with the default layout. To load
46
+ * a `Table()`, add it to `tables` via the `Map()` API where it will be
47
+ * auto-wired into all matching `<perspective-viewer>`s immediately:
48
+ *
49
+ * ```javascript
50
+ * workspace.tables.set("superstore", await worker.table(my_data));
51
+ * ```
52
+ *
53
+ *
54
+ */
55
+ export declare class HTMLPerspectiveWorkspaceElement extends HTMLElement {
56
+ private workspace?;
57
+ private _resize_observer?;
58
+ constructor();
59
+ /***************************************************************************
60
+ *
61
+ * Public
62
+ *
63
+ */
64
+ /**
65
+ * Persists this `<perspective-workspace>` to a token `Object`. This object
66
+ * is JSON serializable and describes the state of the Workspace and it's
67
+ * child `<perspective-viewer>` elements. Some important keys:
68
+ *
69
+ * - `viewers`: The serialized state of `<perspective-viewer>` children,
70
+ * named by `slot`.
71
+ * - `detail`: The main layout.
72
+ * - `master`: The contents of the Global Filter sidebar.
73
+ *
74
+ * While the `table` attribute is persisted for each `perspective-viewer`,
75
+ * `Table`s themselves must be added to the `tables` property `Map()`
76
+ * separately.
77
+ *
78
+ * @return {Object} A configuration token, compatible with
79
+ * `restore(config)`.
80
+ * @example
81
+ * // Save this layout to local storage
82
+ * const workspace = document.querySelector("perspective-workspace");
83
+ * localStorage.set("CONFIG", JSON.stringify(workspace.save()));
84
+ */
85
+ save(): Promise<{
86
+ viewers: Record<string, import("@perspective-dev/viewer").ViewerConfigUpdate>;
87
+ sizes: number[];
88
+ detail: import("@lumino/widgets").DockLayout.ILayoutConfig | undefined;
89
+ master: {
90
+ widgets: string[];
91
+ sizes: number[];
92
+ } | undefined;
93
+ }>;
94
+ /**
95
+ * Restore this `<perspective-workspace>` to a previous state captured by
96
+ * `save()`. Calling this method will completely rewrite this element's
97
+ * `innerHTML`, but may reuse `<perspective-viewer>` children depending
98
+ * on the `slot` attribute names. However, it should always be possible
99
+ * to recreate any given state from within the UI itself, as the attributes
100
+ * on `<perspective-viewer>` itself create immutable views.
101
+ *
102
+ * While the `table` attribute is set for each `perspective-viewer`,
103
+ * `Table`s themselves must be added to the `tables` property `Map()`
104
+ * separately.
105
+ * @param {Object} config A configuration token, as returned by `save()`.
106
+ * @example
107
+ * // Restore this layout from local storage
108
+ * const workspace = document.querySelector("perspective-workspace");
109
+ * workspace.restore(JSON.parse(localStorage.get("CONFIG"));
110
+ *
111
+ * // Add `Table` separately.
112
+ * workspace.tables.set("superstore", await worker.table(data));
113
+ */
114
+ restore(layout: PerspectiveWorkspaceConfig<string>): Promise<void>;
115
+ clear(): Promise<void>;
116
+ /**
117
+ * Await all asynchronous tasks for all viewers in this workspace. This is
118
+ * useful to make sure asynchonous side effects of synchronous methods calls
119
+ * are applied.
120
+ */
121
+ flush(): Promise<void>;
122
+ /**
123
+ * Add a new viewer to the workspace for a given `ViewerConfigUpdateExt`.
124
+ * @param config
125
+ */
126
+ addViewer(config: ViewerConfigUpdateExt): Promise<void>;
127
+ /**
128
+ * Add a new `Table` to the workspace, so that it can be bound by viewers.
129
+ * Each `Table` is identified by a unique `name`.
130
+ */
131
+ addTable(name: string, table: Promise<psp.Table>): Promise<void>;
132
+ /**
133
+ * Deleta a table by name from this workspace
134
+ * @param name
135
+ * @returns
136
+ */
137
+ getTable(name: string): psp.Table | Promise<psp.Table>;
138
+ /**
139
+ * Replace a `Table` by name. As `Table` doe snot guarantee the same
140
+ * structure, this will wipe the viewer's state.
141
+ * @param name
142
+ * @param table
143
+ */
144
+ replaceTable(name: string, table: Promise<psp.Table>): Promise<void>;
145
+ /**
146
+ * Remove a `Table` by name.
147
+ * @param name
148
+ * @returns
149
+ */
150
+ removeTable(name: string): boolean;
151
+ /**
152
+ * A `Map()` of `perspective.Table()` by name. The names set here will auto
153
+ * wire any child `perspective-viewer` elements in this Workspace's subtree,
154
+ * by looking up their respective `table` attribute.
155
+ *
156
+ * Calling methods on this `Map()` may have side-effects, as
157
+ * `PerspectiveViewerHTMLElement.load()` is called when a new `Table()` is
158
+ * set with a name matching an existing child `perspective-viewer`.
159
+ *
160
+ * @readonly
161
+ * @memberof HTMLPerspectiveWorkspaceElement
162
+ */
163
+ get tables(): import("./utils/observable_map").ObservableMap<string, psp.Table | Promise<psp.Table>>;
164
+ /**
165
+ * Invalidate this component's dimensions and recalculate.
166
+ */
167
+ resize(): Promise<void>;
168
+ /**
169
+ * Set whether this workspace element should auto-size itself via a
170
+ * `ResizeObserver`.
171
+ */
172
+ setAutoSize(is_auto_size: boolean): void;
173
+ connectedCallback(): void;
174
+ /***************************************************************************
175
+ *
176
+ * Private
177
+ *
178
+ */
179
+ private _light_dom_changed;
180
+ private _register_light_dom_listener;
181
+ }