plmt-constructor-sdk 0.13.13 → 0.13.15

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.
@@ -6,7 +6,8 @@ export declare enum ViewSettingsItemType {
6
6
  Select = "select",
7
7
  ColorPicker = "color-picker",
8
8
  Title = "title",
9
- TextArea = "textArea"
9
+ TextArea = "textArea",
10
+ ConditionalFormatters = "conditions"
10
11
  }
11
12
  export interface ViewSettingsItemValue {
12
13
  type: ViewSettingsItemType;
@@ -10,6 +10,7 @@ var ViewSettingsItemType;
10
10
  ViewSettingsItemType["ColorPicker"] = "color-picker";
11
11
  ViewSettingsItemType["Title"] = "title";
12
12
  ViewSettingsItemType["TextArea"] = "textArea";
13
+ ViewSettingsItemType["ConditionalFormatters"] = "conditions";
13
14
  })(ViewSettingsItemType = exports.ViewSettingsItemType || (exports.ViewSettingsItemType = {}));
14
15
  exports.viewSettingsItemValue = '418d9556-a046-4623-be0b-4f4f69ccb783';
15
16
  function viewSettingsExtract(viewSettings) {
@@ -33,6 +34,7 @@ function valueConversion(type, source) {
33
34
  case ViewSettingsItemType.Select:
34
35
  case ViewSettingsItemType.ColorPicker:
35
36
  case ViewSettingsItemType.TextArea:
37
+ case ViewSettingsItemType.ConditionalFormatters:
36
38
  return source ? String(source) : '';
37
39
  case ViewSettingsItemType.Checkbox:
38
40
  return Boolean(source);
@@ -0,0 +1,2 @@
1
+ import { ColumnType, Condition } from "./constants";
2
+ export declare function isFulfillingCondition(type: ColumnType, cellValue: any, condition: Condition): boolean;
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isFulfillingCondition = void 0;
4
+ const constants_1 = require("./constants");
5
+ function isFulfillingCondition(type, cellValue, condition) {
6
+ const method = condition.condition;
7
+ const conditionValue = condition.value;
8
+ switch (type) {
9
+ case constants_1.ColumnType.String:
10
+ return isFulfillingStringCondition(method, cellValue, conditionValue);
11
+ case constants_1.ColumnType.Number:
12
+ case constants_1.ColumnType.Boolean:
13
+ const value = Array.isArray(conditionValue)
14
+ ? conditionValue.map((item) => Number(item))
15
+ : conditionValue;
16
+ return isFulfillingNumberCondition(method, cellValue, value);
17
+ case constants_1.ColumnType.Date:
18
+ const date = Array.isArray(conditionValue)
19
+ ? conditionValue.map((item) => new Date(item))
20
+ : new Date(conditionValue);
21
+ return isFulfillingDateCondition(method, new Date(cellValue), date);
22
+ default:
23
+ return false;
24
+ }
25
+ }
26
+ exports.isFulfillingCondition = isFulfillingCondition;
27
+ function isFulfillingStringCondition(method, cellValue, conditionValue) {
28
+ switch (method) {
29
+ case constants_1.FilterMethod.Equal:
30
+ return cellValue === conditionValue;
31
+ case constants_1.FilterMethod.NotEqual:
32
+ return cellValue !== conditionValue;
33
+ case constants_1.FilterMethod.Like:
34
+ return cellValue.includes(conditionValue);
35
+ case constants_1.FilterMethod.Like$Not:
36
+ return !cellValue.includes(conditionValue);
37
+ case constants_1.FilterMethod.Like$CaseIgnore:
38
+ return cellValue
39
+ .toUpperCase()
40
+ .includes(conditionValue.toUpperCase());
41
+ case constants_1.FilterMethod.Like$Not$CaseIgnore:
42
+ return !cellValue
43
+ .toUpperCase()
44
+ .includes(conditionValue.toUpperCase());
45
+ case constants_1.FilterMethod.StartsLike:
46
+ return cellValue.startsWith(conditionValue);
47
+ case constants_1.FilterMethod.StartsLike$Not:
48
+ return !cellValue.startsWith(conditionValue);
49
+ case constants_1.FilterMethod.StartsLike$CaseIgnore:
50
+ return cellValue
51
+ .toUpperCase()
52
+ .startsWith(conditionValue.toUpperCase());
53
+ case constants_1.FilterMethod.StartsLike$Not$CaseIgnore:
54
+ return !cellValue
55
+ .toUpperCase()
56
+ .startsWith(conditionValue.toUpperCase());
57
+ case constants_1.FilterMethod.EndsLike:
58
+ return cellValue.endsWith(conditionValue);
59
+ case constants_1.FilterMethod.EndsLike$Not:
60
+ return !cellValue.endsWith(conditionValue);
61
+ case constants_1.FilterMethod.EndsLike$CaseIgnore:
62
+ return cellValue
63
+ .toUpperCase()
64
+ .endsWith(conditionValue.toUpperCase());
65
+ case constants_1.FilterMethod.EndsLike$Not$CaseIgnore:
66
+ return !cellValue
67
+ .toUpperCase()
68
+ .endsWith(conditionValue.toUpperCase());
69
+ default:
70
+ return false;
71
+ }
72
+ }
73
+ function isFulfillingNumberCondition(method, cellValue, conditionValue) {
74
+ if (Array.isArray(conditionValue))
75
+ switch (method) {
76
+ case constants_1.FilterMethod.InList:
77
+ return (cellValue >= conditionValue[0] &&
78
+ cellValue <= conditionValue[1]);
79
+ case constants_1.FilterMethod.NotInList:
80
+ return (cellValue < conditionValue[0] ||
81
+ cellValue > conditionValue[1]);
82
+ default:
83
+ return false;
84
+ }
85
+ else
86
+ switch (method) {
87
+ case constants_1.FilterMethod.Equal:
88
+ return cellValue === conditionValue;
89
+ case constants_1.FilterMethod.NotEqual:
90
+ return cellValue !== conditionValue;
91
+ case constants_1.FilterMethod.GreaterThen:
92
+ return cellValue > conditionValue;
93
+ case constants_1.FilterMethod.GreaterThenOrEqual:
94
+ return cellValue >= conditionValue;
95
+ case constants_1.FilterMethod.LessThen:
96
+ return cellValue < conditionValue;
97
+ case constants_1.FilterMethod.LessThenOrEqual:
98
+ return cellValue <= conditionValue;
99
+ default:
100
+ return false;
101
+ }
102
+ }
103
+ function isFulfillingDateCondition(method, cellValue, conditionValue) {
104
+ if (Array.isArray(conditionValue))
105
+ switch (method) {
106
+ case constants_1.FilterMethod.DateRange:
107
+ return (cellValue >= conditionValue[0] &&
108
+ cellValue <= conditionValue[1]);
109
+ case constants_1.FilterMethod.DateRange$Not:
110
+ return (cellValue < conditionValue[0] ||
111
+ cellValue > conditionValue[1]);
112
+ default:
113
+ return false;
114
+ }
115
+ else
116
+ switch (method) {
117
+ case constants_1.FilterMethod.Equal:
118
+ return cellValue.getTime() === conditionValue.getTime();
119
+ case constants_1.FilterMethod.NotEqual:
120
+ return cellValue.getTime() !== conditionValue.getTime();
121
+ case constants_1.FilterMethod.GreaterThen:
122
+ return cellValue > conditionValue;
123
+ case constants_1.FilterMethod.GreaterThenOrEqual:
124
+ return cellValue >= conditionValue;
125
+ case constants_1.FilterMethod.LessThen:
126
+ return cellValue < conditionValue;
127
+ case constants_1.FilterMethod.LessThenOrEqual:
128
+ return cellValue <= conditionValue;
129
+ default:
130
+ return false;
131
+ }
132
+ }
@@ -0,0 +1,55 @@
1
+ export declare enum ColumnType {
2
+ String = 0,
3
+ Number = 1,
4
+ Date = 2,
5
+ Boolean = 3
6
+ }
7
+ export declare enum FilterMethod {
8
+ Equal = "EQ",
9
+ NotEqual = "NEQ",
10
+ GreaterThen = "GT",
11
+ LessThen = "LT",
12
+ GreaterThenOrEqual = "GTE",
13
+ LessThenOrEqual = "LTE",
14
+ InList = "IN",
15
+ NotInList = "NIN",
16
+ Like = "LIKE",
17
+ Like$CaseIgnore = "LIKE_I",
18
+ Like$Not = "NLIKE",
19
+ Like$Not$CaseIgnore = "NLIKE_I",
20
+ StartsLike = "START_LIKE",
21
+ StartsLike$CaseIgnore = "START_LIKE_I",
22
+ StartsLike$Not = "NSTART_LIKE",
23
+ StartsLike$Not$CaseIgnore = "NSTART_LIKE_I",
24
+ EndsLike = "END_LIKE",
25
+ EndsLike$CaseIgnore = "END_LIKE_I",
26
+ EndsLike$Not = "NEND_LIKE",
27
+ EndsLike$Not$CaseIgnore = "NEND_LIKE_I",
28
+ DateRange = "DATE_RANGE",
29
+ DateRange$Not = "NDATE_RANGE",
30
+ Range = "RANGE",
31
+ Range$Not = "NRANGE"
32
+ }
33
+ export declare const COLOR_STEPS = 128;
34
+ export interface Condition {
35
+ column_id: number;
36
+ condition: FilterMethod;
37
+ value: any;
38
+ }
39
+ export interface ConditionalFormatter {
40
+ id: number;
41
+ name: string;
42
+ gradient: boolean;
43
+ three_tone_gradient: boolean;
44
+ conditions: Condition[];
45
+ column_id: number;
46
+ column_middle: number;
47
+ column_min: number;
48
+ column_max: number;
49
+ color_start: string;
50
+ color_middle: string;
51
+ color_end: string;
52
+ value_start: number;
53
+ value_middle: number;
54
+ value_end: number;
55
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.COLOR_STEPS = exports.FilterMethod = exports.ColumnType = void 0;
4
+ var ColumnType;
5
+ (function (ColumnType) {
6
+ ColumnType[ColumnType["String"] = 0] = "String";
7
+ ColumnType[ColumnType["Number"] = 1] = "Number";
8
+ ColumnType[ColumnType["Date"] = 2] = "Date";
9
+ ColumnType[ColumnType["Boolean"] = 3] = "Boolean";
10
+ })(ColumnType = exports.ColumnType || (exports.ColumnType = {}));
11
+ var FilterMethod;
12
+ (function (FilterMethod) {
13
+ FilterMethod["Equal"] = "EQ";
14
+ FilterMethod["NotEqual"] = "NEQ";
15
+ FilterMethod["GreaterThen"] = "GT";
16
+ FilterMethod["LessThen"] = "LT";
17
+ FilterMethod["GreaterThenOrEqual"] = "GTE";
18
+ FilterMethod["LessThenOrEqual"] = "LTE";
19
+ FilterMethod["InList"] = "IN";
20
+ FilterMethod["NotInList"] = "NIN";
21
+ FilterMethod["Like"] = "LIKE";
22
+ FilterMethod["Like$CaseIgnore"] = "LIKE_I";
23
+ FilterMethod["Like$Not"] = "NLIKE";
24
+ FilterMethod["Like$Not$CaseIgnore"] = "NLIKE_I";
25
+ FilterMethod["StartsLike"] = "START_LIKE";
26
+ FilterMethod["StartsLike$CaseIgnore"] = "START_LIKE_I";
27
+ FilterMethod["StartsLike$Not"] = "NSTART_LIKE";
28
+ FilterMethod["StartsLike$Not$CaseIgnore"] = "NSTART_LIKE_I";
29
+ FilterMethod["EndsLike"] = "END_LIKE";
30
+ FilterMethod["EndsLike$CaseIgnore"] = "END_LIKE_I";
31
+ FilterMethod["EndsLike$Not"] = "NEND_LIKE";
32
+ FilterMethod["EndsLike$Not$CaseIgnore"] = "NEND_LIKE_I";
33
+ FilterMethod["DateRange"] = "DATE_RANGE";
34
+ FilterMethod["DateRange$Not"] = "NDATE_RANGE";
35
+ FilterMethod["Range"] = "RANGE";
36
+ FilterMethod["Range$Not"] = "NRANGE";
37
+ })(FilterMethod = exports.FilterMethod || (exports.FilterMethod = {}));
38
+ exports.COLOR_STEPS = 128;
@@ -0,0 +1,2 @@
1
+ export * from './conditions';
2
+ export * from './constants';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./conditions"), exports);
18
+ __exportStar(require("./constants"), exports);
package/config.d.ts CHANGED
@@ -150,3 +150,4 @@ export declare function colorPicker(params: {
150
150
  defaultValue?: string;
151
151
  }): ViewSettingsItem;
152
152
  export declare function title(label: any): ViewSettingsItem;
153
+ export declare function conditionalFormatters(key: string, label?: Text): ViewSettingsItem;
package/config.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * @module Конфигурация
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.title = exports.colorPicker = exports.select = exports.radio = exports.checkbox = exports.textArea = exports.input = exports.ViewSettingsItem = exports.drilldown = exports.colorize = exports.sort = exports.filter = exports.block = exports.Block = exports.BlockIcon = exports.DataQueryFunction = exports.DataQueryMethod = void 0;
9
+ exports.conditionalFormatters = exports.title = exports.colorPicker = exports.select = exports.radio = exports.checkbox = exports.textArea = exports.input = exports.ViewSettingsItem = exports.drilldown = exports.colorize = exports.sort = exports.filter = exports.block = exports.Block = exports.BlockIcon = exports.DataQueryFunction = exports.DataQueryMethod = void 0;
10
10
  const data_1 = require("./data");
11
11
  const config_1 = require("./__internal__/config");
12
12
  const dataset_1 = require("./__internal__/dataset");
@@ -197,3 +197,14 @@ function title(label) {
197
197
  });
198
198
  }
199
199
  exports.title = title;
200
+ function conditionalFormatters(key, label) {
201
+ return createViewSettingsItem({
202
+ type: view_settings_1.ViewSettingsItemType.ConditionalFormatters,
203
+ key,
204
+ label: label || {
205
+ ru: 'Условия форматирования',
206
+ en: 'Formatting conditions',
207
+ },
208
+ });
209
+ }
210
+ exports.conditionalFormatters = conditionalFormatters;
package/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './declare';
2
2
  export * from './widget';
3
+ export * from './conditional-format';
package/index.js CHANGED
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./declare"), exports);
18
18
  __exportStar(require("./widget"), exports);
19
+ __exportStar(require("./conditional-format"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plmt-constructor-sdk",
3
- "version": "0.13.13",
3
+ "version": "0.13.15",
4
4
  "description": "Набор инструментов для создания виджетов.",
5
5
  "dependencies": {
6
6
  "logical-not": "^1.0.9"