piral-dashboard 1.0.0-pre.2296 → 1.0.1-beta.5640

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 (48) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +34 -10
  3. package/esm/Dashboard.d.ts +5 -1
  4. package/esm/Dashboard.js +13 -10
  5. package/esm/Dashboard.js.map +1 -1
  6. package/esm/actions.js +2 -3
  7. package/esm/actions.js.map +1 -1
  8. package/esm/components.d.ts +3 -4
  9. package/esm/components.js +2 -2
  10. package/esm/components.js.map +1 -1
  11. package/esm/create.d.ts +6 -12
  12. package/esm/create.js +16 -34
  13. package/esm/create.js.map +1 -1
  14. package/esm/default.js +2 -2
  15. package/esm/default.js.map +1 -1
  16. package/esm/helpers.d.ts +11 -0
  17. package/esm/helpers.js +27 -0
  18. package/esm/helpers.js.map +1 -0
  19. package/esm/types.d.ts +26 -4
  20. package/lib/Dashboard.d.ts +5 -1
  21. package/lib/Dashboard.js +17 -13
  22. package/lib/Dashboard.js.map +1 -1
  23. package/lib/actions.js +3 -4
  24. package/lib/actions.js.map +1 -1
  25. package/lib/components.d.ts +3 -4
  26. package/lib/components.js +3 -3
  27. package/lib/components.js.map +1 -1
  28. package/lib/create.d.ts +6 -12
  29. package/lib/create.js +19 -37
  30. package/lib/create.js.map +1 -1
  31. package/lib/default.js +6 -4
  32. package/lib/default.js.map +1 -1
  33. package/lib/helpers.d.ts +11 -0
  34. package/lib/helpers.js +34 -0
  35. package/lib/helpers.js.map +1 -0
  36. package/lib/index.js +1 -1
  37. package/lib/types.d.ts +26 -4
  38. package/package.json +28 -8
  39. package/piral-dashboard.min.js +1 -0
  40. package/src/Dashboard.test.tsx +14 -14
  41. package/src/Dashboard.tsx +5 -1
  42. package/src/actions.test.ts +7 -6
  43. package/src/components.tsx +2 -6
  44. package/src/create.test.ts +7 -3
  45. package/src/create.ts +17 -50
  46. package/src/default.test.tsx +11 -11
  47. package/src/helpers.ts +54 -0
  48. package/src/types.ts +28 -4
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 - 2021 smapiot
3
+ Copyright (c) 2019 - 2023 smapiot
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- [![Piral Logo](https://github.com/smapiot/piral/raw/master/docs/assets/logo.png)](https://piral.io)
1
+ [![Piral Logo](https://github.com/smapiot/piral/raw/main/docs/assets/logo.png)](https://piral.io)
2
2
 
3
- # [Piral Dashboard](https://piral.io) · [![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/smapiot/piral/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/piral-dashboard.svg?style=flat)](https://www.npmjs.com/package/piral-dashboard) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://jestjs.io) [![Gitter Chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/piral-io/community)
3
+ # [Piral Dashboard](https://piral.io) · [![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/smapiot/piral/blob/main/LICENSE) [![npm version](https://img.shields.io/npm/v/piral-dashboard.svg?style=flat)](https://www.npmjs.com/package/piral-dashboard) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://jestjs.io) [![Gitter Chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/piral-io/community)
4
4
 
5
5
  This is plugin that only has a peer dependency to `piral-core`. What `piral-dashboard` brings to the table is a set of Pilet API extensions that can be used with `piral` or `piral-core`.
6
6
 
@@ -10,6 +10,12 @@ Many portal and tool applications come with a dashboard view that easily allows
10
10
 
11
11
  Alternatives: Use extensions to define this generically without the need for a plugin. Place each dashboard in its own extension slot registering components dynamically for these.
12
12
 
13
+ ## Video
14
+
15
+ We also have a video for this plugin:
16
+
17
+ @[youtube](https://youtu.be/ycZLPRaoLAQ)
18
+
13
19
  ## Documentation
14
20
 
15
21
  The following functions are brought to the Pilet API.
@@ -83,7 +89,7 @@ const instance = createInstance({
83
89
  });
84
90
  ```
85
91
 
86
- Via the options the `defaultPreferences` and the global / initially available `tiles` can be defined.
92
+ Via the options the `defaultPreferences` and the global/initially available `tiles` can be defined.
87
93
 
88
94
  Consider for example:
89
95
 
@@ -110,17 +116,35 @@ const instance = createInstance({
110
116
  });
111
117
  ```
112
118
 
113
- To fully integrate the dashboard the `Dashboard` component can be used. It can be part of a page or a page itself:
119
+ By default, the dashboard is located at the homepage (`/`). You can change this via the `routes` setting:
114
120
 
115
- ```jsx
116
- <SetRoute path="/" component={Dashboard} />
121
+ ```ts
122
+ const instance = createInstance({
123
+ // important part
124
+ plugins: [createDashboardApi({
125
+ routes: ['/dashboard'],
126
+ })],
127
+ // ...
128
+ });
117
129
  ```
118
130
 
119
- The `Dashboard` component also comes with a prop called `filter`, which might be handy together with custom options for actually using multiple dashboards.
131
+ Or alternatively, don't use any route for it and just reference the `Dashboard` component on any page or within the layout.
132
+
133
+ ```ts
134
+ // for the instance
135
+ const instance = createInstance({
136
+ // important part
137
+ plugins: [createDashboardApi({
138
+ routes: [],
139
+ })],
140
+ // ...
141
+ });
142
+
143
+
144
+ // in some component, maybe even in the layout
145
+ import { Dashboard } from 'piral-dashboard';
120
146
 
121
- ```jsx
122
- <SetRoute path="/dashboard1" component={props => <Dashboard {...props} filter={tile => tile.preferences.category === 'self'} />} />
123
- <SetRoute path="/dashboard2" component={props => <Dashboard {...props} filter={tile => tile.preferences.category === 'group'} />} />
147
+ // then use: <Dashboard />
124
148
  ```
125
149
 
126
150
  ### Customizing
@@ -1,7 +1,11 @@
1
1
  import * as React from 'react';
2
- import { RouteComponentProps } from 'react-router-dom';
2
+ import type { RouteComponentProps } from 'react-router-dom';
3
3
  import { TileRegistration } from './types';
4
4
  export interface DashboardProps extends RouteComponentProps {
5
5
  filter?(tile: TileRegistration): boolean;
6
6
  }
7
+ /**
8
+ * The dashboard component. Integrate this as a page or in a component
9
+ * where dashboard information (tiles) should be shown.
10
+ */
7
11
  export declare const Dashboard: React.FC<DashboardProps>;
package/esm/Dashboard.js CHANGED
@@ -1,19 +1,22 @@
1
- import { __assign } from "tslib";
2
1
  import * as React from 'react';
3
2
  import { useGlobalState } from 'piral-core';
4
3
  import { PiralDashboardContainer, PiralDashboardTile } from './components';
5
- export var Dashboard = function (props) {
6
- var tiles = useGlobalState(function (s) { return s.registry.tiles; });
7
- var _a = props.filter, filter = _a === void 0 ? function () { return true; } : _a;
8
- var children = Object.keys(tiles)
9
- .filter(function (tile) { return filter(tiles[tile]); })
10
- .map(function (tile) {
11
- var _a = tiles[tile], Component = _a.component, preferences = _a.preferences;
12
- var _b = preferences.initialColumns, initialColumns = _b === void 0 ? 1 : _b, _c = preferences.initialRows, initialRows = _c === void 0 ? 1 : _c, _d = preferences.resizable, resizable = _d === void 0 ? false : _d;
4
+ /**
5
+ * The dashboard component. Integrate this as a page or in a component
6
+ * where dashboard information (tiles) should be shown.
7
+ */
8
+ export const Dashboard = (props) => {
9
+ const tiles = useGlobalState((s) => s.registry.tiles);
10
+ const { filter = () => true } = props;
11
+ const children = Object.keys(tiles)
12
+ .filter((tile) => filter(tiles[tile]))
13
+ .map((tile) => {
14
+ const { component: Component, preferences } = tiles[tile];
15
+ const { initialColumns = 1, initialRows = 1, resizable = false } = preferences;
13
16
  return (React.createElement(PiralDashboardTile, { key: tile, columns: initialColumns, rows: initialRows, resizable: resizable, meta: preferences },
14
17
  React.createElement(Component, { columns: initialColumns, rows: initialRows })));
15
18
  });
16
- return React.createElement(PiralDashboardContainer, __assign({}, props, { children: children }));
19
+ return React.createElement(PiralDashboardContainer, Object.assign({}, props, { children: children }));
17
20
  };
18
21
  Dashboard.displayName = 'Dashboard';
19
22
  //# sourceMappingURL=Dashboard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dashboard.js","sourceRoot":"","sources":["../src/Dashboard.tsx"],"names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AAC,CAAC;IAEL,OAAO,oBAAC,uBAAuB,oBAAK,KAAK,IAAE,QAAQ,EAAE,QAAQ,IAAI,CAAC;AACpE,CAAC,CAAC;AACF,SAAS,CAAC,WAAW,GAAG,WAAW,CAAC"}
package/esm/actions.js CHANGED
@@ -1,9 +1,8 @@
1
- import { __assign } from "tslib";
2
1
  import { withKey, withoutKey } from 'piral-core';
3
2
  export function registerTile(ctx, name, value) {
4
- ctx.dispatch(function (state) { return (__assign(__assign({}, state), { registry: __assign(__assign({}, state.registry), { tiles: withKey(state.registry.tiles, name, value) }) })); });
3
+ ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { registry: Object.assign(Object.assign({}, state.registry), { tiles: withKey(state.registry.tiles, name, value) }) })));
5
4
  }
6
5
  export function unregisterTile(ctx, name) {
7
- ctx.dispatch(function (state) { return (__assign(__assign({}, state), { registry: __assign(__assign({}, state.registry), { tiles: withoutKey(state.registry.tiles, name) }) })); });
6
+ ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { registry: Object.assign(Object.assign({}, state.registry), { tiles: withoutKey(state.registry.tiles, name) }) })));
8
7
  }
9
8
  //# sourceMappingURL=actions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAsB,MAAM,YAAY,CAAC;AAGrE,MAAM,UAAU,YAAY,CAAC,GAAuB,EAAE,IAAY,EAAE,KAAuB;IACzF,GAAG,CAAC,QAAQ,CAAC,UAAC,KAAK,IAAK,OAAA,uBACnB,KAAK,KACR,QAAQ,wBACH,KAAK,CAAC,QAAQ,KACjB,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,OAEnD,EANsB,CAMtB,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAuB,EAAE,IAAY;IAClE,GAAG,CAAC,QAAQ,CAAC,UAAC,KAAK,IAAK,OAAA,uBACnB,KAAK,KACR,QAAQ,wBACH,KAAK,CAAC,QAAQ,KACjB,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,OAE/C,EANsB,CAMtB,CAAC,CAAC;AACN,CAAC"}
1
+ {"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAsB,MAAM,YAAY,CAAC;AAGrE,MAAM,UAAU,YAAY,CAAC,GAAuB,EAAE,IAAY,EAAE,KAAuB;IACzF,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,QAAQ,kCACH,KAAK,CAAC,QAAQ,KACjB,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,OAEnD,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAuB,EAAE,IAAY;IAClE,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,QAAQ,kCACH,KAAK,CAAC,QAAQ,KACjB,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,OAE/C,CAAC,CAAC;AACN,CAAC"}
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
- import { DashboardContainerProps, DashboardTileProps } from './types';
3
- export declare const PiralDashboardContainer: React.ComponentType<DashboardContainerProps>;
4
- export declare const PiralDashboardTile: React.ComponentType<DashboardTileProps>;
1
+ /// <reference types="react" />
2
+ export declare const PiralDashboardContainer: import("react").ComponentType<import("./types").DashboardContainerProps>;
3
+ export declare const PiralDashboardTile: import("react").ComponentType<import("./types").DashboardTileProps>;
package/esm/components.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { getPiralComponent } from 'piral-core';
2
- export var PiralDashboardContainer = getPiralComponent('DashboardContainer');
3
- export var PiralDashboardTile = getPiralComponent('DashboardTile');
2
+ export const PiralDashboardContainer = getPiralComponent('DashboardContainer');
3
+ export const PiralDashboardTile = getPiralComponent('DashboardTile');
4
4
  //# sourceMappingURL=components.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C,MAAM,CAAC,IAAM,uBAAuB,GAAiD,iBAAiB,CACpG,oBAAoB,CACrB,CAAC;AACF,MAAM,CAAC,IAAM,kBAAkB,GAA4C,iBAAiB,CAAC,eAAe,CAAC,CAAC"}
1
+ {"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,CAAC,MAAM,uBAAuB,GAAG,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;AAC/E,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,eAAe,CAAC,CAAC"}
package/esm/create.d.ts CHANGED
@@ -1,20 +1,14 @@
1
- import { ComponentType } from 'react';
2
1
  import { PiralPlugin } from 'piral-core';
3
- import { PiletDashboardApi, TilePreferences, BareTileComponentProps } from './types';
4
- export interface InitialTile {
5
- /**
6
- * Defines the component to be used for the tile.
7
- */
8
- component: ComponentType<BareTileComponentProps>;
9
- /**
10
- * Optionally sets the preferences for the tile.
11
- */
12
- preferences?: TilePreferences;
13
- }
2
+ import { InitialTile, PiletDashboardApi, TilePreferences } from './types';
14
3
  /**
15
4
  * Available configuration options for the dashboard plugin.
16
5
  */
17
6
  export interface DashboardConfig {
7
+ /**
8
+ * Sets the routes where a dashboard should be displayed.
9
+ * @default ['/']
10
+ */
11
+ routes?: Array<string>;
18
12
  /**
19
13
  * Sets the tiles to be given by the app shell.
20
14
  * @default []
package/esm/create.js CHANGED
@@ -1,53 +1,35 @@
1
- import { __assign } from "tslib";
2
1
  import * as actions from './actions';
3
- import { buildName, withApi } from 'piral-core';
4
- import { DefaultTile, DefaultContainer } from './default';
5
- function getPreferences(defaultPreferences, customPreferences) {
6
- if (customPreferences === void 0) { customPreferences = {}; }
7
- return __assign(__assign({}, defaultPreferences), customPreferences);
8
- }
9
- function getTiles(items, defaultPreferences) {
10
- var tiles = {};
11
- var i = 0;
12
- for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
13
- var _a = items_1[_i], component = _a.component, preferences = _a.preferences;
14
- tiles["global-" + i++] = {
15
- pilet: undefined,
16
- component: component,
17
- preferences: getPreferences(defaultPreferences, preferences),
18
- };
19
- }
20
- return tiles;
21
- }
2
+ import { buildName, withApi, withRootExtension, withAll } from 'piral-core';
3
+ import { Dashboard } from './Dashboard';
4
+ import { getPreferences, getTiles, withRoutes, withTiles } from './helpers';
22
5
  /**
23
6
  * Creates the Pilet API extension for activating dashboard support.
24
7
  */
25
- export function createDashboardApi(config) {
26
- if (config === void 0) { config = {}; }
27
- var _a = config.tiles, tiles = _a === void 0 ? [] : _a, _b = config.defaultPreferences, defaultPreferences = _b === void 0 ? {} : _b;
28
- return function (context) {
8
+ export function createDashboardApi(config = {}) {
9
+ const { tiles = [], defaultPreferences = {}, routes = ['/'] } = config;
10
+ return (context) => {
29
11
  context.defineActions(actions);
30
- context.dispatch(function (state) { return (__assign(__assign({}, state), { components: __assign({ DashboardTile: DefaultTile, DashboardContainer: DefaultContainer }, state.components), registry: __assign(__assign({}, state.registry), { tiles: getTiles(tiles, defaultPreferences) }) })); });
31
- return function (api, target) {
32
- var pilet = target.name;
33
- var next = 0;
12
+ context.dispatch(withAll(withTiles(getTiles(tiles, defaultPreferences)), withRootExtension('piral-dashboard', Dashboard), withRoutes(routes)));
13
+ return (api, target) => {
14
+ const pilet = target.name;
15
+ let next = 0;
34
16
  return {
35
- registerTile: function (name, arg, preferences) {
17
+ registerTile(name, arg, preferences) {
36
18
  if (typeof name !== 'string') {
37
19
  preferences = arg;
38
20
  arg = name;
39
21
  name = next++;
40
22
  }
41
- var id = buildName(pilet, name);
23
+ const id = buildName(pilet, name);
42
24
  context.registerTile(id, {
43
- pilet: pilet,
25
+ pilet,
44
26
  component: withApi(context, arg, api, 'tile'),
45
27
  preferences: getPreferences(defaultPreferences, preferences),
46
28
  });
47
- return function () { return api.unregisterTile(name); };
29
+ return () => api.unregisterTile(name);
48
30
  },
49
- unregisterTile: function (name) {
50
- var id = buildName(pilet, name);
31
+ unregisterTile(name) {
32
+ const id = buildName(pilet, name);
51
33
  context.unregisterTile(id);
52
34
  },
53
35
  };
package/esm/create.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAqB,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AA8B1D,SAAS,cAAc,CAAC,kBAAmC,EAAE,iBAAuC;IAAvC,kCAAA,EAAA,sBAAuC;IAClG,6BACK,kBAAkB,GAClB,iBAAiB,EACpB;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,KAAyB,EAAE,kBAAmC;IAC9E,IAAM,KAAK,GAA2B,EAAE,CAAC;IACzC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,KAAyC,UAAK,EAAL,eAAK,EAAL,mBAAK,EAAL,IAAK,EAAE;QAArC,IAAA,gBAA0B,EAAxB,SAAS,eAAA,EAAE,WAAW,iBAAA;QACjC,KAAK,CAAC,YAAU,CAAC,EAAI,CAAC,GAAG;YACvB,KAAK,EAAE,SAAS;YAChB,SAAS,WAAA;YACT,WAAW,EAAE,cAAc,CAAC,kBAAkB,EAAE,WAAW,CAAC;SAC7D,CAAC;KAC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YAEb,OAAO;gBACL,YAAY,CAAC,IAAI,EAAE,GAAG,EAAE,WAAY;oBAClC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;wBAC5B,WAAW,GAAG,GAAG,CAAC;wBAClB,GAAG,GAAG,IAAI,CAAC;wBACX,IAAI,GAAG,IAAI,EAAE,CAAC;qBACf;oBAED,MAAM,EAAE,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;oBAClC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE;wBACvB,KAAK;wBACL,SAAS,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC;wBAC7C,WAAW,EAAE,cAAc,CAAC,kBAAkB,EAAE,WAAW,CAAC;qBAC7D,CAAC,CAAC;oBACH,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;gBACxC,CAAC;gBACD,cAAc,CAAC,IAAI;oBACjB,MAAM,EAAE,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;oBAClC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;gBAC7B,CAAC;aACF,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
package/esm/default.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { ExtensionSlot, defaultRender } from 'piral-core';
3
- export var DefaultContainer = function (props) { return (React.createElement(ExtensionSlot, { name: "dashboard", params: props, empty: function () { return defaultRender(props.children, 'default_dashboard'); } })); };
4
- export var DefaultTile = function (props) { return defaultRender(props.children); };
3
+ export const DefaultContainer = (props) => (React.createElement(ExtensionSlot, { name: "dashboard", params: props, empty: () => defaultRender(props.children, 'default_dashboard') }));
4
+ export const DefaultTile = (props) => defaultRender(props.children);
5
5
  //# sourceMappingURL=default.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"default.js","sourceRoot":"","sources":["../src/default.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG1D,MAAM,CAAC,IAAM,gBAAgB,GAAsC,UAAC,KAAK,IAAK,OAAA,CAC5E,oBAAC,aAAa,IAAC,IAAI,EAAC,WAAW,EAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,cAAM,OAAA,aAAa,CAAC,KAAK,CAAC,QAAQ,EAAE,mBAAmB,CAAC,EAAlD,CAAkD,GAAI,CACnH,EAF6E,CAE7E,CAAC;AAEF,MAAM,CAAC,IAAM,WAAW,GAAiC,UAAC,KAAK,IAAK,OAAA,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,EAA7B,CAA6B,CAAC"}
1
+ {"version":3,"file":"default.js","sourceRoot":"","sources":["../src/default.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG1D,MAAM,CAAC,MAAM,gBAAgB,GAAsC,CAAC,KAAK,EAAE,EAAE,CAAC,CAC5E,oBAAC,aAAa,IAAC,IAAI,EAAC,WAAW,EAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,EAAE,mBAAmB,CAAC,GAAI,CACnH,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAiC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { Dict, GlobalState } from 'piral-core';
2
+ import { InitialTile, TilePreferences, TileRegistration } from './types';
3
+ export declare function getPreferences(defaultPreferences: TilePreferences, customPreferences?: TilePreferences): {
4
+ initialColumns?: number;
5
+ initialRows?: number;
6
+ resizable?: boolean;
7
+ customProperties?: string[];
8
+ };
9
+ export declare function getTiles(items: Array<InitialTile>, defaultPreferences: TilePreferences): Dict<TileRegistration>;
10
+ export declare function withTiles(tiles: Dict<TileRegistration>): (state: GlobalState) => GlobalState;
11
+ export declare function withRoutes(routes: Array<string>): (state: GlobalState) => GlobalState;
package/esm/helpers.js ADDED
@@ -0,0 +1,27 @@
1
+ import { DefaultTile, DefaultContainer } from './default';
2
+ import { Dashboard } from './Dashboard';
3
+ export function getPreferences(defaultPreferences, customPreferences = {}) {
4
+ return Object.assign(Object.assign({}, defaultPreferences), customPreferences);
5
+ }
6
+ export function getTiles(items, defaultPreferences) {
7
+ const tiles = {};
8
+ let i = 0;
9
+ for (const { component, preferences } of items) {
10
+ tiles[`global-${i++}`] = {
11
+ pilet: undefined,
12
+ component,
13
+ preferences: getPreferences(defaultPreferences, preferences),
14
+ };
15
+ }
16
+ return tiles;
17
+ }
18
+ export function withTiles(tiles) {
19
+ return (state) => (Object.assign(Object.assign({}, state), { components: Object.assign({ DashboardTile: DefaultTile, DashboardContainer: DefaultContainer }, state.components), registry: Object.assign(Object.assign({}, state.registry), { tiles }) }));
20
+ }
21
+ export function withRoutes(routes) {
22
+ return (state) => (Object.assign(Object.assign({}, state), { routes: Object.assign(Object.assign({}, state.routes), routes.reduce((newRoutes, route) => {
23
+ newRoutes[route] = Dashboard;
24
+ return newRoutes;
25
+ }, {})) }));
26
+ }
27
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,MAAM,UAAU,cAAc,CAAC,kBAAmC,EAAE,oBAAqC,EAAE;IACzG,uCACK,kBAAkB,GAClB,iBAAiB,EACpB;AACJ,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAyB,EAAE,kBAAmC;IACrF,MAAM,KAAK,GAA2B,EAAE,CAAC;IACzC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,KAAK,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,KAAK,EAAE;QAC9C,KAAK,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG;YACvB,KAAK,EAAE,SAAS;YAChB,SAAS;YACT,WAAW,EAAE,cAAc,CAAC,kBAAkB,EAAE,WAAW,CAAC;SAC7D,CAAC;KACH;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAA6B;IACrD,OAAO,CAAC,KAAkB,EAAe,EAAE,CAAC,iCACvC,KAAK,KACR,UAAU,kBACR,aAAa,EAAE,WAAW,EAC1B,kBAAkB,EAAE,gBAAgB,IACjC,KAAK,CAAC,UAAU,GAErB,QAAQ,kCACH,KAAK,CAAC,QAAQ,KACjB,KAAK,OAEP,CAAC;AACL,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAqB;IAC9C,OAAO,CAAC,KAAkB,EAAe,EAAE,CAAC,iCACvC,KAAK,KACR,MAAM,kCACD,KAAK,CAAC,MAAM,GACZ,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE;YACpC,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;YAC7B,OAAO,SAAS,CAAC;QACnB,CAAC,EAAE,EAAE,CAAC,KAER,CAAC;AACL,CAAC"}
package/esm/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { ComponentType } from 'react';
2
- import { RouteComponentProps } from 'react-router-dom';
3
- import { Dict, WrappedComponent, BaseComponentProps, AnyComponent, BaseRegistration, RegistrationDisposer } from 'piral-core';
1
+ import type { ComponentType, ReactNode } from 'react';
2
+ import type { RouteComponentProps } from 'react-router-dom';
3
+ import type { Dict, WrappedComponent, BaseComponentProps, AnyComponent, BaseRegistration, RegistrationDisposer } from 'piral-core';
4
4
  declare module 'piral-core/lib/types/custom' {
5
5
  interface PiletCustomApi extends PiletDashboardApi {
6
6
  }
@@ -39,7 +39,21 @@ declare module 'piral-core/lib/types/custom' {
39
39
  DashboardTile: ComponentType<DashboardTileProps>;
40
40
  }
41
41
  }
42
+ export interface InitialTile {
43
+ /**
44
+ * Defines the component to be used for the tile.
45
+ */
46
+ component: ComponentType<BareTileComponentProps>;
47
+ /**
48
+ * Optionally sets the preferences for the tile.
49
+ */
50
+ preferences?: TilePreferences;
51
+ }
42
52
  export interface DashboardContainerProps extends RouteComponentProps {
53
+ /**
54
+ * The tiles to display.
55
+ */
56
+ children?: ReactNode;
43
57
  }
44
58
  export interface DashboardTileProps {
45
59
  /**
@@ -58,6 +72,10 @@ export interface DashboardTileProps {
58
72
  * The provided tile preferences.
59
73
  */
60
74
  meta: TilePreferences;
75
+ /**
76
+ * The content of the tile to display.
77
+ */
78
+ children?: ReactNode;
61
79
  }
62
80
  export interface TileErrorInfoProps {
63
81
  /**
@@ -76,6 +94,10 @@ export interface TileErrorInfoProps {
76
94
  * The currently used number of rows.
77
95
  */
78
96
  rows: number;
97
+ /**
98
+ * The name of the pilet emitting the error.
99
+ */
100
+ pilet?: string;
79
101
  }
80
102
  export interface BareTileComponentProps {
81
103
  /**
@@ -87,7 +109,7 @@ export interface BareTileComponentProps {
87
109
  */
88
110
  rows: number;
89
111
  }
90
- export declare type TileComponentProps = BaseComponentProps & BareTileComponentProps;
112
+ export type TileComponentProps = BaseComponentProps & BareTileComponentProps;
91
113
  export interface PiralCustomTilePreferences {
92
114
  }
93
115
  export interface TilePreferences extends PiralCustomTilePreferences {
@@ -1,7 +1,11 @@
1
1
  import * as React from 'react';
2
- import { RouteComponentProps } from 'react-router-dom';
2
+ import type { RouteComponentProps } from 'react-router-dom';
3
3
  import { TileRegistration } from './types';
4
4
  export interface DashboardProps extends RouteComponentProps {
5
5
  filter?(tile: TileRegistration): boolean;
6
6
  }
7
+ /**
8
+ * The dashboard component. Integrate this as a page or in a component
9
+ * where dashboard information (tiles) should be shown.
10
+ */
7
11
  export declare const Dashboard: React.FC<DashboardProps>;
package/lib/Dashboard.js CHANGED
@@ -1,22 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Dashboard = void 0;
4
- var tslib_1 = require("tslib");
5
- var React = require("react");
6
- var piral_core_1 = require("piral-core");
7
- var components_1 = require("./components");
8
- exports.Dashboard = function (props) {
9
- var tiles = piral_core_1.useGlobalState(function (s) { return s.registry.tiles; });
10
- var _a = props.filter, filter = _a === void 0 ? function () { return true; } : _a;
11
- var children = Object.keys(tiles)
12
- .filter(function (tile) { return filter(tiles[tile]); })
13
- .map(function (tile) {
14
- var _a = tiles[tile], Component = _a.component, preferences = _a.preferences;
15
- var _b = preferences.initialColumns, initialColumns = _b === void 0 ? 1 : _b, _c = preferences.initialRows, initialRows = _c === void 0 ? 1 : _c, _d = preferences.resizable, resizable = _d === void 0 ? false : _d;
4
+ const React = require("react");
5
+ const piral_core_1 = require("piral-core");
6
+ const components_1 = require("./components");
7
+ /**
8
+ * The dashboard component. Integrate this as a page or in a component
9
+ * where dashboard information (tiles) should be shown.
10
+ */
11
+ const Dashboard = (props) => {
12
+ const tiles = (0, piral_core_1.useGlobalState)((s) => s.registry.tiles);
13
+ const { filter = () => true } = props;
14
+ const children = Object.keys(tiles)
15
+ .filter((tile) => filter(tiles[tile]))
16
+ .map((tile) => {
17
+ const { component: Component, preferences } = tiles[tile];
18
+ const { initialColumns = 1, initialRows = 1, resizable = false } = preferences;
16
19
  return (React.createElement(components_1.PiralDashboardTile, { key: tile, columns: initialColumns, rows: initialRows, resizable: resizable, meta: preferences },
17
20
  React.createElement(Component, { columns: initialColumns, rows: initialRows })));
18
21
  });
19
- return React.createElement(components_1.PiralDashboardContainer, tslib_1.__assign({}, props, { children: children }));
22
+ return React.createElement(components_1.PiralDashboardContainer, Object.assign({}, props, { children: children }));
20
23
  };
24
+ exports.Dashboard = Dashboard;
21
25
  exports.Dashboard.displayName = 'Dashboard';
22
26
  //# sourceMappingURL=Dashboard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dashboard.js","sourceRoot":"","sources":["../src/Dashboard.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAE/B,yCAA4C;AAC5C,2CAA2E;AAO9D,QAAA,SAAS,GAA6B,UAAC,KAAK;IACvD,IAAM,KAAK,GAAG,2BAAc,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAhB,CAAgB,CAAC,CAAC;IAC9C,IAAA,KAAwB,KAAK,OAAV,EAAnB,MAAM,mBAAG,cAAM,OAAA,IAAI,EAAJ,CAAI,KAAA,CAAW;IACtC,IAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;SAChC,MAAM,CAAC,UAAC,IAAI,IAAK,OAAA,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAnB,CAAmB,CAAC;SACrC,GAAG,CAAC,UAAC,IAAI;QACF,IAAA,KAAwC,KAAK,CAAC,IAAI,CAAC,EAAtC,SAAS,eAAA,EAAE,WAAW,iBAAgB,CAAC;QAClD,IAAA,KAA2D,WAAW,eAApD,EAAlB,cAAc,mBAAG,CAAC,KAAA,EAAE,KAAuC,WAAW,YAAnC,EAAf,WAAW,mBAAG,CAAC,KAAA,EAAE,KAAsB,WAAW,UAAhB,EAAjB,SAAS,mBAAG,KAAK,KAAA,CAAiB;QAC/E,OAAO,CACL,oBAAC,+BAAkB,IACjB,GAAG,EAAE,IAAI,EACT,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,WAAW;YACjB,oBAAC,SAAS,IAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,GAAI,CACtC,CACtB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEL,OAAO,oBAAC,oCAAuB,uBAAK,KAAK,IAAE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AC,CAAC;AArBW,QAAA,SAAS,aAqBpB;AACF,iBAAS,CAAC,WAAW,GAAG,WAAW,CAAC"}
package/lib/actions.js CHANGED
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.unregisterTile = exports.registerTile = void 0;
4
- var tslib_1 = require("tslib");
5
- var piral_core_1 = require("piral-core");
4
+ const piral_core_1 = require("piral-core");
6
5
  function registerTile(ctx, name, value) {
7
- ctx.dispatch(function (state) { return (tslib_1.__assign(tslib_1.__assign({}, state), { registry: tslib_1.__assign(tslib_1.__assign({}, state.registry), { tiles: piral_core_1.withKey(state.registry.tiles, name, value) }) })); });
6
+ ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { registry: Object.assign(Object.assign({}, state.registry), { tiles: (0, piral_core_1.withKey)(state.registry.tiles, name, value) }) })));
8
7
  }
9
8
  exports.registerTile = registerTile;
10
9
  function unregisterTile(ctx, name) {
11
- ctx.dispatch(function (state) { return (tslib_1.__assign(tslib_1.__assign({}, state), { registry: tslib_1.__assign(tslib_1.__assign({}, state.registry), { tiles: piral_core_1.withoutKey(state.registry.tiles, name) }) })); });
10
+ ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { registry: Object.assign(Object.assign({}, state.registry), { tiles: (0, piral_core_1.withoutKey)(state.registry.tiles, name) }) })));
12
11
  }
13
12
  exports.unregisterTile = unregisterTile;
14
13
  //# sourceMappingURL=actions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":";;;;AAAA,yCAAqE;AAGrE,SAAgB,YAAY,CAAC,GAAuB,EAAE,IAAY,EAAE,KAAuB;IACzF,GAAG,CAAC,QAAQ,CAAC,UAAC,KAAK,IAAK,OAAA,uCACnB,KAAK,KACR,QAAQ,wCACH,KAAK,CAAC,QAAQ,KACjB,KAAK,EAAE,oBAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,OAEnD,EANsB,CAMtB,CAAC,CAAC;AACN,CAAC;AARD,oCAQC;AAED,SAAgB,cAAc,CAAC,GAAuB,EAAE,IAAY;IAClE,GAAG,CAAC,QAAQ,CAAC,UAAC,KAAK,IAAK,OAAA,uCACnB,KAAK,KACR,QAAQ,wCACH,KAAK,CAAC,QAAQ,KACjB,KAAK,EAAE,uBAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,OAE/C,EANsB,CAMtB,CAAC,CAAC;AACN,CAAC;AARD,wCAQC"}
1
+ {"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":";;;AAAA,2CAAqE;AAGrE,SAAgB,YAAY,CAAC,GAAuB,EAAE,IAAY,EAAE,KAAuB;IACzF,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,QAAQ,kCACH,KAAK,CAAC,QAAQ,KACjB,KAAK,EAAE,IAAA,oBAAO,EAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,OAEnD,CAAC,CAAC;AACN,CAAC;AARD,oCAQC;AAED,SAAgB,cAAc,CAAC,GAAuB,EAAE,IAAY;IAClE,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,QAAQ,kCACH,KAAK,CAAC,QAAQ,KACjB,KAAK,EAAE,IAAA,uBAAU,EAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,OAE/C,CAAC,CAAC;AACN,CAAC;AARD,wCAQC"}
@@ -1,4 +1,3 @@
1
- import * as React from 'react';
2
- import { DashboardContainerProps, DashboardTileProps } from './types';
3
- export declare const PiralDashboardContainer: React.ComponentType<DashboardContainerProps>;
4
- export declare const PiralDashboardTile: React.ComponentType<DashboardTileProps>;
1
+ /// <reference types="react" />
2
+ export declare const PiralDashboardContainer: import("react").ComponentType<import("./types").DashboardContainerProps>;
3
+ export declare const PiralDashboardTile: import("react").ComponentType<import("./types").DashboardTileProps>;
package/lib/components.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PiralDashboardTile = exports.PiralDashboardContainer = void 0;
4
- var piral_core_1 = require("piral-core");
5
- exports.PiralDashboardContainer = piral_core_1.getPiralComponent('DashboardContainer');
6
- exports.PiralDashboardTile = piral_core_1.getPiralComponent('DashboardTile');
4
+ const piral_core_1 = require("piral-core");
5
+ exports.PiralDashboardContainer = (0, piral_core_1.getPiralComponent)('DashboardContainer');
6
+ exports.PiralDashboardTile = (0, piral_core_1.getPiralComponent)('DashboardTile');
7
7
  //# sourceMappingURL=components.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":";;;AACA,yCAA+C;AAGlC,QAAA,uBAAuB,GAAiD,8BAAiB,CACpG,oBAAoB,CACrB,CAAC;AACW,QAAA,kBAAkB,GAA4C,8BAAiB,CAAC,eAAe,CAAC,CAAC"}
1
+ {"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":";;;AAAA,2CAA+C;AAElC,QAAA,uBAAuB,GAAG,IAAA,8BAAiB,EAAC,oBAAoB,CAAC,CAAC;AAClE,QAAA,kBAAkB,GAAG,IAAA,8BAAiB,EAAC,eAAe,CAAC,CAAC"}
package/lib/create.d.ts CHANGED
@@ -1,20 +1,14 @@
1
- import { ComponentType } from 'react';
2
1
  import { PiralPlugin } from 'piral-core';
3
- import { PiletDashboardApi, TilePreferences, BareTileComponentProps } from './types';
4
- export interface InitialTile {
5
- /**
6
- * Defines the component to be used for the tile.
7
- */
8
- component: ComponentType<BareTileComponentProps>;
9
- /**
10
- * Optionally sets the preferences for the tile.
11
- */
12
- preferences?: TilePreferences;
13
- }
2
+ import { InitialTile, PiletDashboardApi, TilePreferences } from './types';
14
3
  /**
15
4
  * Available configuration options for the dashboard plugin.
16
5
  */
17
6
  export interface DashboardConfig {
7
+ /**
8
+ * Sets the routes where a dashboard should be displayed.
9
+ * @default ['/']
10
+ */
11
+ routes?: Array<string>;
18
12
  /**
19
13
  * Sets the tiles to be given by the app shell.
20
14
  * @default []