polymatica-widget 2.0.9 → 2.0.12

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.
@@ -1,3 +1,4 @@
1
+ import { Column } from '../dataset';
1
2
  import { Locale } from '../locale';
2
3
  import { Theme } from '../theme';
3
4
  import { Dataset, Options } from '../widget';
@@ -12,8 +13,13 @@ export declare enum Output {
12
13
  Ready = "poly.output.ready",
13
14
  Interact = "poly.output.interact"
14
15
  }
15
- export declare type InputDataset = Omit<Dataset, 'interact' | 'events'> & {
16
+ export declare type InputColumn = Omit<Column, 'interact'> & {
17
+ columnId: number;
18
+ };
19
+ export declare type InputDataset = Omit<Dataset, 'columns' | 'columnsByBlock' | 'events'> & {
16
20
  datasetId: number;
21
+ columns: InputColumn[];
22
+ columnsByBlock: Record<string, number[]>;
17
23
  };
18
24
  export interface InputSingleData {
19
25
  readonly dataset: InputDataset;
@@ -45,6 +51,7 @@ export interface OutputParameter extends Record<Output, any> {
45
51
  [Output.Ready]: void;
46
52
  [Output.Interact]: {
47
53
  datasetId: number;
54
+ columnId: number;
48
55
  dataIndex: number;
49
56
  };
50
57
  }
package/dataset.d.ts CHANGED
@@ -13,4 +13,5 @@ export interface Column {
13
13
  type: ColumnType;
14
14
  name: string;
15
15
  path: string;
16
+ interact(rowIndex: number): void;
16
17
  }
package/declare.js CHANGED
@@ -84,13 +84,31 @@ function provideTo(widget, source, token) {
84
84
  }
85
85
  }
86
86
  function transform(source, token) {
87
- const { datasetId } = source, slice = __rest(source, ["datasetId"]);
88
- const dataset = Object.assign(Object.assign({}, slice), { interact(dataIndex) {
89
- output(token, io_1.Output.Interact, {
90
- datasetId,
91
- dataIndex,
92
- });
93
- }, events: {
87
+ const { datasetId, columns: sourceColumns, columnsByBlock: sourceColumnsByBlock } = source, slice = __rest(source, ["datasetId", "columns", "columnsByBlock"]);
88
+ const columnsById = new Map();
89
+ const columns = sourceColumns.map((_a) => {
90
+ var { columnId } = _a, source = __rest(_a, ["columnId"]);
91
+ const column = Object.assign(Object.assign({}, source), { interact(rowIndex) {
92
+ output(token, io_1.Output.Interact, {
93
+ datasetId,
94
+ columnId,
95
+ dataIndex: rowIndex,
96
+ });
97
+ } });
98
+ columnsById.set(columnId, column);
99
+ return column;
100
+ });
101
+ const columnsByBlock = {};
102
+ Object.entries(sourceColumnsByBlock).forEach(([blockKey, columnIds]) => {
103
+ columnsByBlock[blockKey] = [];
104
+ columnIds.forEach(id => {
105
+ const column = columnsById.get(id);
106
+ if (column)
107
+ columnsByBlock[blockKey].push(column);
108
+ });
109
+ });
110
+ const dataset = Object.assign(Object.assign({}, slice), { columns,
111
+ columnsByBlock, events: {
94
112
  onHighlight() { },
95
113
  } });
96
114
  datasetMap.set(datasetId, dataset);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polymatica-widget",
3
- "version": "2.0.9",
3
+ "version": "2.0.12",
4
4
  "description": "SDK для создания виджетов для платформы Polymatica",
5
5
  "keywords": [],
6
6
  "license": "ISC",
@@ -6,11 +6,6 @@ export declare enum DataQueryMethod {
6
6
  Table = "table",
7
7
  PivotTable = "pivot"
8
8
  }
9
- export declare enum PivotTableKey {
10
- Columns = "columns",
11
- Rows = "rows",
12
- Values = "values"
13
- }
14
9
  export interface WidgetConfig {
15
10
  data?: {
16
11
  config: DataConfig | (DataConfig & WithKey)[];
@@ -33,9 +28,9 @@ export interface DataConfig {
33
28
  max?: number;
34
29
  };
35
30
  drilldown?: {
36
- source: string;
31
+ sources: string[];
37
32
  };
38
- heatmap?: boolean | {
33
+ heatmap?: {
39
34
  targets: string[];
40
35
  };
41
36
  }
package/widget-config.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.colorPicker = exports.select = exports.radioButton = exports.radio = exports.checkbox = exports.dateTime = exports.time = exports.date = exports.interval = exports.range = exports.integer = exports.number = exports.text = exports.spacer = exports.label = exports.title = exports.STEP = exports.PivotTableKey = exports.DataQueryMethod = void 0;
3
+ exports.colorPicker = exports.select = exports.radioButton = exports.radio = exports.checkbox = exports.dateTime = exports.time = exports.date = exports.interval = exports.range = exports.integer = exports.number = exports.text = exports.spacer = exports.label = exports.title = exports.STEP = exports.DataQueryMethod = void 0;
4
4
  const widget_options_1 = require("./__internal__/widget-options");
5
5
  // enums
6
6
  var DataQueryMethod;
@@ -9,12 +9,6 @@ var DataQueryMethod;
9
9
  DataQueryMethod["Table"] = "table";
10
10
  DataQueryMethod["PivotTable"] = "pivot";
11
11
  })(DataQueryMethod = exports.DataQueryMethod || (exports.DataQueryMethod = {}));
12
- var PivotTableKey;
13
- (function (PivotTableKey) {
14
- PivotTableKey["Columns"] = "columns";
15
- PivotTableKey["Rows"] = "rows";
16
- PivotTableKey["Values"] = "values";
17
- })(PivotTableKey = exports.PivotTableKey || (exports.PivotTableKey = {}));
18
12
  // widget options
19
13
  exports.STEP = 24;
20
14
  // layout
package/widget.d.ts CHANGED
@@ -33,7 +33,6 @@ export interface Dataset {
33
33
  };
34
34
  rows: DatasetRow[];
35
35
  heatmap: HeatmapItem[];
36
- interact(rowIndex: number): void;
37
36
  events: {
38
37
  onHighlight: (rowIndexArray: number[]) => void;
39
38
  };