@infomaximum/widget-sdk 4.0.0-beta4 → 4.0.0-beta40

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/dist/index.esm.js CHANGED
@@ -71,24 +71,51 @@ var EWidgetActionInputMode;
71
71
  EWidgetActionInputMode["FORMULA"] = "FORMULA";
72
72
  EWidgetActionInputMode["MANUALLY"] = "MANUALLY";
73
73
  })(EWidgetActionInputMode || (EWidgetActionInputMode = {}));
74
+ var EActionTypes;
75
+ (function (EActionTypes) {
76
+ EActionTypes["URL"] = "URL";
77
+ EActionTypes["UPDATE_VARIABLE"] = "UPDATE_VARIABLE";
78
+ EActionTypes["RUN_SCRIPT"] = "RUN_SCRIPT";
79
+ EActionTypes["OPEN_VIEW"] = "OPEN_VIEW";
80
+ })(EActionTypes || (EActionTypes = {}));
81
+ var EViewType;
82
+ (function (EViewType) {
83
+ EViewType["CREATED_VIEW"] = "CREATED_VIEW";
84
+ EViewType["GENERATED_BY_SCRIPT"] = "GENERATED_BY_SCRIPT";
85
+ })(EViewType || (EViewType = {}));
86
+ var EOpenViewMode;
87
+ (function (EOpenViewMode) {
88
+ EOpenViewMode["NEW_WINDOW"] = "NEW_WINDOW";
89
+ EOpenViewMode["PLACEHOLDER"] = "PLACEHOLDER";
90
+ EOpenViewMode["MODAL"] = "MODAL";
91
+ EOpenViewMode["DRAWER"] = "DRAWER";
92
+ })(EOpenViewMode || (EOpenViewMode = {}));
93
+ var EDrawerPlacement;
94
+ (function (EDrawerPlacement) {
95
+ EDrawerPlacement["LEFT"] = "LEFT";
96
+ EDrawerPlacement["RIGHT"] = "RIGHT";
97
+ })(EDrawerPlacement || (EDrawerPlacement = {}));
74
98
  var isActionValid = function (action, _a) {
75
99
  var _b;
76
- var scripts = _a.scripts, tables = _a.tables;
77
- var currentScript = scripts.get((_b = action.scriptGuid) !== null && _b !== void 0 ? _b : "");
100
+ var scripts = _a.scripts, tables = _a.tables, variables = _a.variables;
101
+ if (action.type !== EActionTypes.RUN_SCRIPT) {
102
+ return false;
103
+ }
104
+ var currentScript = scripts.get((_b = action.scriptName) !== null && _b !== void 0 ? _b : "");
78
105
  if (!currentScript) {
79
106
  return false;
80
107
  }
81
- var actionInputsMap = new Map(action.inputs.map(function (input) { return [input.guid, input]; }));
82
- if (actionInputsMap.size < currentScript.fieldsGuids.size) {
108
+ var actionInputsMap = new Map(action.inputs.map(function (input) { return [input.name, input]; }));
109
+ if (actionInputsMap.size < currentScript.fieldsNames.size) {
83
110
  return false;
84
111
  }
85
- return __spreadArray([], __read(currentScript.fieldsGuids), false).every(function (guid) {
86
- var actionInput = actionInputsMap.get(guid !== null && guid !== void 0 ? guid : "");
112
+ return __spreadArray([], __read(currentScript.fieldsNames), false).every(function (name) {
113
+ var actionInput = actionInputsMap.get(name !== null && name !== void 0 ? name : "");
87
114
  if (!actionInput) {
88
115
  return false;
89
116
  }
90
117
  var value = actionInput.value;
91
- if (value.mode === EWidgetActionInputMode.FROM_VARIABLE && !value.guid) {
118
+ if (value.mode === EWidgetActionInputMode.FROM_VARIABLE && !variables.has(value.sourceVariable)) {
92
119
  return false;
93
120
  }
94
121
  if (value.mode === EWidgetActionInputMode.FORMULA && !value.formula) {
@@ -97,8 +124,7 @@ var isActionValid = function (action, _a) {
97
124
  if (value.mode === EWidgetActionInputMode.DYNAMIC_LIST && !value.formula) {
98
125
  return false;
99
126
  }
100
- if (value.mode === EWidgetActionInputMode.FROM_COLUMN &&
101
- !tables.has(value.tableName)) {
127
+ if (value.mode === EWidgetActionInputMode.FROM_COLUMN && !tables.has(value.tableName)) {
102
128
  return false;
103
129
  }
104
130
  return true;
@@ -123,9 +149,7 @@ var prepareValuesForSql = function (dataType, values) {
123
149
  dataType === ESimpleDataType.BOOLEAN
124
150
  ? values
125
151
  : values.map(function (value) {
126
- return value === null
127
- ? null
128
- : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
152
+ return value === null ? null : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
129
153
  });
130
154
  };
131
155
  var escapeReverseSlash = function (formula) {
@@ -135,19 +159,6 @@ var escapeSingularQuotes = function (formula) {
135
159
  return formula.replaceAll("'", "\\'");
136
160
  };
137
161
 
138
- var compact = function (items) { return ((items === null || items === void 0 ? void 0 : items.filter(Boolean)) || []); };
139
- var compactMap = function (items, f) { return compact(items === null || items === void 0 ? void 0 : items.map(f)); };
140
- var isNil = function (value) {
141
- return value === null || value === undefined;
142
- };
143
-
144
- function mapVariablesToInputs(variables) {
145
- return new Map(compactMap(__spreadArray([], __read(variables.values()), false), function (_a) {
146
- var name = _a.name, dataType = _a.dataType, value = _a.value;
147
- return !isNil(value) ? [name, { dataType: dataType, value: value }] : null;
148
- }));
149
- }
150
-
151
162
  var ECalculatorFilterMethods;
152
163
  (function (ECalculatorFilterMethods) {
153
164
  ECalculatorFilterMethods["EQUAL_TO"] = "EQUAL_TO";
@@ -193,6 +204,14 @@ var EFormulaFilterFieldKeys;
193
204
  EFormulaFilterFieldKeys["durationUnit"] = "durationUnit";
194
205
  })(EFormulaFilterFieldKeys || (EFormulaFilterFieldKeys = {}));
195
206
 
207
+ var compact = function (items) { return ((items === null || items === void 0 ? void 0 : items.filter(Boolean)) || []); };
208
+ var compactMap = function (items, f) {
209
+ return compact(items === null || items === void 0 ? void 0 : items.map(f));
210
+ };
211
+ var isNil = function (value) {
212
+ return value === null || value === undefined;
213
+ };
214
+
196
215
  var EFormatTypes;
197
216
  (function (EFormatTypes) {
198
217
  /** Дата */
@@ -476,11 +495,25 @@ var EWidgetFilterMode;
476
495
  })(EWidgetFilterMode || (EWidgetFilterMode = {}));
477
496
  var EColorMode;
478
497
  (function (EColorMode) {
498
+ EColorMode["DISABLED"] = "DISABLED";
479
499
  EColorMode["FORMULA"] = "FORMULA";
480
500
  EColorMode["BASE"] = "BASE";
481
501
  EColorMode["GRADIENT"] = "GRADIENT";
482
502
  EColorMode["AUTO"] = "AUTO";
503
+ EColorMode["RULE"] = "RULE";
504
+ EColorMode["VALUES"] = "VALUES";
505
+ EColorMode["BY_DIMENSION"] = "BY_DIMENSION";
483
506
  })(EColorMode || (EColorMode = {}));
507
+ var EColorScope;
508
+ (function (EColorScope) {
509
+ EColorScope["WORKSPACE"] = "WORKSPACE";
510
+ EColorScope["DASHBOARD"] = "DASHBOARD";
511
+ })(EColorScope || (EColorScope = {}));
512
+ var EMarkdownDisplayMode;
513
+ (function (EMarkdownDisplayMode) {
514
+ EMarkdownDisplayMode["NONE"] = "NONE";
515
+ EMarkdownDisplayMode["INDICATOR"] = "INDICATOR";
516
+ })(EMarkdownDisplayMode || (EMarkdownDisplayMode = {}));
484
517
  var EDisplayConditionMode;
485
518
  (function (EDisplayConditionMode) {
486
519
  EDisplayConditionMode["DISABLED"] = "DISABLED";
@@ -491,8 +524,8 @@ var EDisplayConditionMode;
491
524
  function checkDisplayCondition(displayCondition, variables) {
492
525
  var _a;
493
526
  if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === EDisplayConditionMode.VARIABLE) {
494
- var variableGuid = displayCondition.variableGuid, variableValue = displayCondition.variableValue;
495
- var currentVariableValue = variableGuid && ((_a = variables.get(variableGuid)) === null || _a === void 0 ? void 0 : _a.value);
527
+ var variableName = displayCondition.variableName, variableValue = displayCondition.variableValue;
528
+ var currentVariableValue = variableName && ((_a = variables.get(variableName)) === null || _a === void 0 ? void 0 : _a.value);
496
529
  var isCurrentVariableMatch = Array.isArray(currentVariableValue)
497
530
  ? !!variableValue && (currentVariableValue === null || currentVariableValue === void 0 ? void 0 : currentVariableValue.includes(variableValue))
498
531
  : currentVariableValue === variableValue;
@@ -508,17 +541,14 @@ function getDisplayConditionFormula(displayCondition) {
508
541
  }
509
542
  }
510
543
  var replaceDisplayCondition = function (dimension, displayCondition) {
511
- return isNil(displayCondition)
512
- ? dimension
513
- : __assign(__assign({}, dimension), { displayCondition: displayCondition });
544
+ return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
514
545
  };
515
546
 
516
547
  var escapeSpecialCharacters = function (formula) {
517
548
  return formula
518
549
  .replaceAll("\\", "\\\\")
519
550
  .replaceAll('"', '\\"')
520
- .replaceAll("`", "\\`")
521
- .replaceAll("-", "\\-");
551
+ .replaceAll("`", "\\`");
522
552
  };
523
553
 
524
554
  function generateColumnFormula(tableName, columnName) {
@@ -755,12 +785,11 @@ function mapMeasureToInput(measure, variables, addFormulas) {
755
785
  }
756
786
  /** Конвертировать меры виджета во входы для вычислителя */
757
787
  function mapMeasuresToInputs(measures, variables, addFormulas) {
758
- return compactMap(measures, function (measure) {
759
- return mapMeasureToInput(measure, variables, addFormulas);
760
- });
788
+ return compactMap(measures, function (measure) { return mapMeasureToInput(measure, variables, addFormulas); });
761
789
  }
762
790
 
763
- function mapDimensionToInput(dimension, variables) {
791
+ function mapDimensionToInput(dimension, variables, addFormulas) {
792
+ if (addFormulas === void 0) { addFormulas = function () { return new Map(); }; }
764
793
  var formula = getDimensionFormula(dimension);
765
794
  if (!formula) {
766
795
  return null;
@@ -774,12 +803,13 @@ function mapDimensionToInput(dimension, variables) {
774
803
  dataType: dimension.dataType,
775
804
  hideEmpty: dimension.hideEmptyValues,
776
805
  displayConditionFormula: getDisplayConditionFormula(dimension.displayCondition),
806
+ additionalFormulas: addFormulas(dimension),
777
807
  };
778
808
  }
779
809
  /** Конвертировать разрезы виджета во входы для вычислителя */
780
- function mapDimensionsToInputs(dimensions, variables) {
810
+ function mapDimensionsToInputs(dimensions, variables, addFormulas) {
781
811
  return compactMap(dimensions, function (dimension) {
782
- return mapDimensionToInput(dimension, variables);
812
+ return mapDimensionToInput(dimension, variables, addFormulas);
783
813
  });
784
814
  }
785
815
 
@@ -838,11 +868,12 @@ function mapEventMeasuresToInputs(indicators, process, variables, addFormulas) {
838
868
  * @param measuresInOriginalOrder меры виджета (конкретная мера будет браться по индексу)
839
869
  * @returns
840
870
  */
841
- function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder) {
871
+ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder, variables) {
842
872
  if (sortingIndicators === void 0) { sortingIndicators = []; }
843
873
  if (dimensionsInOriginalOrder === void 0) { dimensionsInOriginalOrder = []; }
844
874
  if (measuresInOriginalOrder === void 0) { measuresInOriginalOrder = []; }
845
875
  return compactMap(sortingIndicators, function (_a) {
876
+ var _b;
846
877
  var value = _a.value, direction = _a.direction;
847
878
  if (value.mode === ESortingValueModes.FORMULA ||
848
879
  value.mode === ESortingValueModes.QUANTITY ||
@@ -853,7 +884,20 @@ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measur
853
884
  if (value.mode === ESortingValueModes.DIMENSION_IN_WIDGET ||
854
885
  value.mode === ESortingValueModes.HIERARCHY) {
855
886
  var dimension = dimensionsInOriginalOrder[value.index];
856
- return (dimension && { formula: getDimensionFormula(dimension), direction: direction });
887
+ if (!dimension) {
888
+ return;
889
+ }
890
+ var formula = getDimensionFormula(dimension);
891
+ if (!formula || !checkDisplayCondition(dimension.displayCondition, variables)) {
892
+ return;
893
+ }
894
+ return {
895
+ formula: getDimensionFormula(dimension),
896
+ direction: direction,
897
+ displayCondition: ((_b = dimension.displayCondition) === null || _b === void 0 ? void 0 : _b.mode) === EDisplayConditionMode.FORMULA
898
+ ? dimension.displayCondition.formula
899
+ : undefined,
900
+ };
857
901
  }
858
902
  if (value.mode === ESortingValueModes.MEASURE_IN_WIDGET) {
859
903
  var measure = measuresInOriginalOrder[value.index];
@@ -881,9 +925,7 @@ function selectDimensionFromHierarchy(_a, filters) {
881
925
  if (!matchedFilter) {
882
926
  return "continue";
883
927
  }
884
- var selectionIndex = matchedFilter.values.length > 1
885
- ? i
886
- : Math.min(i + 1, dimensions.length - 1);
928
+ var selectionIndex = matchedFilter.values.length > 1 ? i : Math.min(i + 1, dimensions.length - 1);
887
929
  return { value: dimensions[selectionIndex] };
888
930
  };
889
931
  for (var i = dimensions.length - 1; i >= 0; i--) {
@@ -898,8 +940,7 @@ var replaceHierarchiesWithDimensions = function (dimensions, filters) {
898
940
  return compactMap(dimensions, function (indicator) {
899
941
  if (isHierarchy(indicator)) {
900
942
  var selectedDimension = selectDimensionFromHierarchy(indicator, filters);
901
- return (selectedDimension &&
902
- replaceDisplayCondition(selectedDimension, indicator.displayCondition));
943
+ return (selectedDimension && replaceDisplayCondition(selectedDimension, indicator.displayCondition));
903
944
  }
904
945
  return indicator;
905
946
  });
@@ -916,9 +957,12 @@ function bindContentWithIndicator(outputs, indicator) {
916
957
  * Массив объектов, каждый из которых содержит показатель и его контент
917
958
  */
918
959
  function bindContentsWithIndicators(outputs, indicators) {
919
- return compactMap(indicators, function (indicator) {
920
- return bindContentWithIndicator(outputs, indicator);
921
- });
960
+ return compactMap(indicators, function (indicator) { return bindContentWithIndicator(outputs, indicator); });
961
+ }
962
+
963
+ /** Удалить из строки символы экранирования */
964
+ function unescapeSpecialCharacters(str) {
965
+ return str.replace(/\\(?!\\)/g, "").replace(/\\\\/g, "\\");
922
966
  }
923
967
 
924
968
  var EControlType;
@@ -941,8 +985,23 @@ var EControlType;
941
985
  EControlType["inputMarkdown"] = "inputMarkdown";
942
986
  EControlType["filter"] = "filter";
943
987
  EControlType["actionOnClick"] = "actionOnClick";
988
+ EControlType["eventsPicker"] = "eventsPicker";
944
989
  })(EControlType || (EControlType = {}));
945
990
 
991
+ var ESelectOptionTypes;
992
+ (function (ESelectOptionTypes) {
993
+ ESelectOptionTypes["DIVIDER"] = "DIVIDER";
994
+ ESelectOptionTypes["SYSTEM"] = "SYSTEM";
995
+ ESelectOptionTypes["GROUP"] = "GROUP";
996
+ ESelectOptionTypes["BRANCH"] = "BRANCH";
997
+ ESelectOptionTypes["LEAF"] = "LEAF";
998
+ })(ESelectOptionTypes || (ESelectOptionTypes = {}));
999
+ var ECustomSelectTemplates;
1000
+ (function (ECustomSelectTemplates) {
1001
+ ECustomSelectTemplates["FORMULA"] = "FORMULA";
1002
+ ECustomSelectTemplates["DIMENSION_GROUPS"] = "DIMENSION_GROUPS";
1003
+ })(ECustomSelectTemplates || (ECustomSelectTemplates = {}));
1004
+
946
1005
  var ESortDirection;
947
1006
  (function (ESortDirection) {
948
1007
  ESortDirection["descend"] = "DESC";
@@ -1045,4 +1104,4 @@ var getLocalizedText = function (language, locObj, props) {
1045
1104
  return localization.getLocalized(locObj, props);
1046
1105
  };
1047
1106
 
1048
- export { ECalculatorFilterMethods, EColorMode, EControlType, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDurationUnit, EEventMeasureTemplateNames, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMeasureTemplateNames, EProcessFilterNames, ESimpleDataType, ESortDirection, ESortingValueModes, ETransitionMeasureTemplateNames, EWidgetActionInputMode, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, dimensionTemplateFormulas, escapeSpecialCharacters, eventMeasureTemplateFormulas, fillTemplateString, formulaFilterMethods, generateColumnFormula, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getTransitionMeasureFormula, isActionValid, isHierarchy, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, mapVariablesToInputs, measureTemplateFormulas, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, transitionMeasureTemplateFormulas, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection };
1107
+ export { EActionTypes, ECalculatorFilterMethods, EColorMode, EColorScope, EControlType, ECustomSelectTemplates, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationUnit, EEventMeasureTemplateNames, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, EMeasureTemplateNames, EOpenViewMode, EProcessFilterNames, ESelectOptionTypes, ESimpleDataType, ESortDirection, ESortingValueModes, ETransitionMeasureTemplateNames, EViewType, EWidgetActionInputMode, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, dimensionTemplateFormulas, escapeSpecialCharacters, eventMeasureTemplateFormulas, fillTemplateString, formulaFilterMethods, generateColumnFormula, getDimensionFormula, getDisplayConditionFormula, getEventMeasureFormula, getLocalizedText, getMeasureFormula, getTransitionMeasureFormula, isActionValid, isHierarchy, mapDimensionsToInputs, mapEventMeasuresToInputs, mapFormulaFilterToCalculatorInput, mapFormulaFiltersToInputs, mapMeasuresToInputs, mapSortingToInputs, mapTransitionMeasuresToInputs, measureTemplateFormulas, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, transitionMeasureTemplateFormulas, unescapeSpecialCharacters, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection };
package/dist/index.js CHANGED
@@ -72,24 +72,51 @@ exports.EWidgetActionInputMode = void 0;
72
72
  EWidgetActionInputMode["FORMULA"] = "FORMULA";
73
73
  EWidgetActionInputMode["MANUALLY"] = "MANUALLY";
74
74
  })(exports.EWidgetActionInputMode || (exports.EWidgetActionInputMode = {}));
75
+ exports.EActionTypes = void 0;
76
+ (function (EActionTypes) {
77
+ EActionTypes["URL"] = "URL";
78
+ EActionTypes["UPDATE_VARIABLE"] = "UPDATE_VARIABLE";
79
+ EActionTypes["RUN_SCRIPT"] = "RUN_SCRIPT";
80
+ EActionTypes["OPEN_VIEW"] = "OPEN_VIEW";
81
+ })(exports.EActionTypes || (exports.EActionTypes = {}));
82
+ exports.EViewType = void 0;
83
+ (function (EViewType) {
84
+ EViewType["CREATED_VIEW"] = "CREATED_VIEW";
85
+ EViewType["GENERATED_BY_SCRIPT"] = "GENERATED_BY_SCRIPT";
86
+ })(exports.EViewType || (exports.EViewType = {}));
87
+ exports.EOpenViewMode = void 0;
88
+ (function (EOpenViewMode) {
89
+ EOpenViewMode["NEW_WINDOW"] = "NEW_WINDOW";
90
+ EOpenViewMode["PLACEHOLDER"] = "PLACEHOLDER";
91
+ EOpenViewMode["MODAL"] = "MODAL";
92
+ EOpenViewMode["DRAWER"] = "DRAWER";
93
+ })(exports.EOpenViewMode || (exports.EOpenViewMode = {}));
94
+ exports.EDrawerPlacement = void 0;
95
+ (function (EDrawerPlacement) {
96
+ EDrawerPlacement["LEFT"] = "LEFT";
97
+ EDrawerPlacement["RIGHT"] = "RIGHT";
98
+ })(exports.EDrawerPlacement || (exports.EDrawerPlacement = {}));
75
99
  var isActionValid = function (action, _a) {
76
100
  var _b;
77
- var scripts = _a.scripts, tables = _a.tables;
78
- var currentScript = scripts.get((_b = action.scriptGuid) !== null && _b !== void 0 ? _b : "");
101
+ var scripts = _a.scripts, tables = _a.tables, variables = _a.variables;
102
+ if (action.type !== exports.EActionTypes.RUN_SCRIPT) {
103
+ return false;
104
+ }
105
+ var currentScript = scripts.get((_b = action.scriptName) !== null && _b !== void 0 ? _b : "");
79
106
  if (!currentScript) {
80
107
  return false;
81
108
  }
82
- var actionInputsMap = new Map(action.inputs.map(function (input) { return [input.guid, input]; }));
83
- if (actionInputsMap.size < currentScript.fieldsGuids.size) {
109
+ var actionInputsMap = new Map(action.inputs.map(function (input) { return [input.name, input]; }));
110
+ if (actionInputsMap.size < currentScript.fieldsNames.size) {
84
111
  return false;
85
112
  }
86
- return __spreadArray([], __read(currentScript.fieldsGuids), false).every(function (guid) {
87
- var actionInput = actionInputsMap.get(guid !== null && guid !== void 0 ? guid : "");
113
+ return __spreadArray([], __read(currentScript.fieldsNames), false).every(function (name) {
114
+ var actionInput = actionInputsMap.get(name !== null && name !== void 0 ? name : "");
88
115
  if (!actionInput) {
89
116
  return false;
90
117
  }
91
118
  var value = actionInput.value;
92
- if (value.mode === exports.EWidgetActionInputMode.FROM_VARIABLE && !value.guid) {
119
+ if (value.mode === exports.EWidgetActionInputMode.FROM_VARIABLE && !variables.has(value.sourceVariable)) {
93
120
  return false;
94
121
  }
95
122
  if (value.mode === exports.EWidgetActionInputMode.FORMULA && !value.formula) {
@@ -98,8 +125,7 @@ var isActionValid = function (action, _a) {
98
125
  if (value.mode === exports.EWidgetActionInputMode.DYNAMIC_LIST && !value.formula) {
99
126
  return false;
100
127
  }
101
- if (value.mode === exports.EWidgetActionInputMode.FROM_COLUMN &&
102
- !tables.has(value.tableName)) {
128
+ if (value.mode === exports.EWidgetActionInputMode.FROM_COLUMN && !tables.has(value.tableName)) {
103
129
  return false;
104
130
  }
105
131
  return true;
@@ -124,9 +150,7 @@ var prepareValuesForSql = function (dataType, values) {
124
150
  dataType === exports.ESimpleDataType.BOOLEAN
125
151
  ? values
126
152
  : values.map(function (value) {
127
- return value === null
128
- ? null
129
- : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
153
+ return value === null ? null : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
130
154
  });
131
155
  };
132
156
  var escapeReverseSlash = function (formula) {
@@ -136,19 +160,6 @@ var escapeSingularQuotes = function (formula) {
136
160
  return formula.replaceAll("'", "\\'");
137
161
  };
138
162
 
139
- var compact = function (items) { return ((items === null || items === void 0 ? void 0 : items.filter(Boolean)) || []); };
140
- var compactMap = function (items, f) { return compact(items === null || items === void 0 ? void 0 : items.map(f)); };
141
- var isNil = function (value) {
142
- return value === null || value === undefined;
143
- };
144
-
145
- function mapVariablesToInputs(variables) {
146
- return new Map(compactMap(__spreadArray([], __read(variables.values()), false), function (_a) {
147
- var name = _a.name, dataType = _a.dataType, value = _a.value;
148
- return !isNil(value) ? [name, { dataType: dataType, value: value }] : null;
149
- }));
150
- }
151
-
152
163
  exports.ECalculatorFilterMethods = void 0;
153
164
  (function (ECalculatorFilterMethods) {
154
165
  ECalculatorFilterMethods["EQUAL_TO"] = "EQUAL_TO";
@@ -194,6 +205,14 @@ exports.EFormulaFilterFieldKeys = void 0;
194
205
  EFormulaFilterFieldKeys["durationUnit"] = "durationUnit";
195
206
  })(exports.EFormulaFilterFieldKeys || (exports.EFormulaFilterFieldKeys = {}));
196
207
 
208
+ var compact = function (items) { return ((items === null || items === void 0 ? void 0 : items.filter(Boolean)) || []); };
209
+ var compactMap = function (items, f) {
210
+ return compact(items === null || items === void 0 ? void 0 : items.map(f));
211
+ };
212
+ var isNil = function (value) {
213
+ return value === null || value === undefined;
214
+ };
215
+
197
216
  exports.EFormatTypes = void 0;
198
217
  (function (EFormatTypes) {
199
218
  /** Дата */
@@ -477,11 +496,25 @@ exports.EWidgetFilterMode = void 0;
477
496
  })(exports.EWidgetFilterMode || (exports.EWidgetFilterMode = {}));
478
497
  exports.EColorMode = void 0;
479
498
  (function (EColorMode) {
499
+ EColorMode["DISABLED"] = "DISABLED";
480
500
  EColorMode["FORMULA"] = "FORMULA";
481
501
  EColorMode["BASE"] = "BASE";
482
502
  EColorMode["GRADIENT"] = "GRADIENT";
483
503
  EColorMode["AUTO"] = "AUTO";
504
+ EColorMode["RULE"] = "RULE";
505
+ EColorMode["VALUES"] = "VALUES";
506
+ EColorMode["BY_DIMENSION"] = "BY_DIMENSION";
484
507
  })(exports.EColorMode || (exports.EColorMode = {}));
508
+ exports.EColorScope = void 0;
509
+ (function (EColorScope) {
510
+ EColorScope["WORKSPACE"] = "WORKSPACE";
511
+ EColorScope["DASHBOARD"] = "DASHBOARD";
512
+ })(exports.EColorScope || (exports.EColorScope = {}));
513
+ exports.EMarkdownDisplayMode = void 0;
514
+ (function (EMarkdownDisplayMode) {
515
+ EMarkdownDisplayMode["NONE"] = "NONE";
516
+ EMarkdownDisplayMode["INDICATOR"] = "INDICATOR";
517
+ })(exports.EMarkdownDisplayMode || (exports.EMarkdownDisplayMode = {}));
485
518
  exports.EDisplayConditionMode = void 0;
486
519
  (function (EDisplayConditionMode) {
487
520
  EDisplayConditionMode["DISABLED"] = "DISABLED";
@@ -492,8 +525,8 @@ exports.EDisplayConditionMode = void 0;
492
525
  function checkDisplayCondition(displayCondition, variables) {
493
526
  var _a;
494
527
  if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === exports.EDisplayConditionMode.VARIABLE) {
495
- var variableGuid = displayCondition.variableGuid, variableValue = displayCondition.variableValue;
496
- var currentVariableValue = variableGuid && ((_a = variables.get(variableGuid)) === null || _a === void 0 ? void 0 : _a.value);
528
+ var variableName = displayCondition.variableName, variableValue = displayCondition.variableValue;
529
+ var currentVariableValue = variableName && ((_a = variables.get(variableName)) === null || _a === void 0 ? void 0 : _a.value);
497
530
  var isCurrentVariableMatch = Array.isArray(currentVariableValue)
498
531
  ? !!variableValue && (currentVariableValue === null || currentVariableValue === void 0 ? void 0 : currentVariableValue.includes(variableValue))
499
532
  : currentVariableValue === variableValue;
@@ -509,17 +542,14 @@ function getDisplayConditionFormula(displayCondition) {
509
542
  }
510
543
  }
511
544
  var replaceDisplayCondition = function (dimension, displayCondition) {
512
- return isNil(displayCondition)
513
- ? dimension
514
- : __assign(__assign({}, dimension), { displayCondition: displayCondition });
545
+ return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
515
546
  };
516
547
 
517
548
  var escapeSpecialCharacters = function (formula) {
518
549
  return formula
519
550
  .replaceAll("\\", "\\\\")
520
551
  .replaceAll('"', '\\"')
521
- .replaceAll("`", "\\`")
522
- .replaceAll("-", "\\-");
552
+ .replaceAll("`", "\\`");
523
553
  };
524
554
 
525
555
  function generateColumnFormula(tableName, columnName) {
@@ -756,12 +786,11 @@ function mapMeasureToInput(measure, variables, addFormulas) {
756
786
  }
757
787
  /** Конвертировать меры виджета во входы для вычислителя */
758
788
  function mapMeasuresToInputs(measures, variables, addFormulas) {
759
- return compactMap(measures, function (measure) {
760
- return mapMeasureToInput(measure, variables, addFormulas);
761
- });
789
+ return compactMap(measures, function (measure) { return mapMeasureToInput(measure, variables, addFormulas); });
762
790
  }
763
791
 
764
- function mapDimensionToInput(dimension, variables) {
792
+ function mapDimensionToInput(dimension, variables, addFormulas) {
793
+ if (addFormulas === void 0) { addFormulas = function () { return new Map(); }; }
765
794
  var formula = getDimensionFormula(dimension);
766
795
  if (!formula) {
767
796
  return null;
@@ -775,12 +804,13 @@ function mapDimensionToInput(dimension, variables) {
775
804
  dataType: dimension.dataType,
776
805
  hideEmpty: dimension.hideEmptyValues,
777
806
  displayConditionFormula: getDisplayConditionFormula(dimension.displayCondition),
807
+ additionalFormulas: addFormulas(dimension),
778
808
  };
779
809
  }
780
810
  /** Конвертировать разрезы виджета во входы для вычислителя */
781
- function mapDimensionsToInputs(dimensions, variables) {
811
+ function mapDimensionsToInputs(dimensions, variables, addFormulas) {
782
812
  return compactMap(dimensions, function (dimension) {
783
- return mapDimensionToInput(dimension, variables);
813
+ return mapDimensionToInput(dimension, variables, addFormulas);
784
814
  });
785
815
  }
786
816
 
@@ -839,11 +869,12 @@ function mapEventMeasuresToInputs(indicators, process, variables, addFormulas) {
839
869
  * @param measuresInOriginalOrder меры виджета (конкретная мера будет браться по индексу)
840
870
  * @returns
841
871
  */
842
- function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder) {
872
+ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder, variables) {
843
873
  if (sortingIndicators === void 0) { sortingIndicators = []; }
844
874
  if (dimensionsInOriginalOrder === void 0) { dimensionsInOriginalOrder = []; }
845
875
  if (measuresInOriginalOrder === void 0) { measuresInOriginalOrder = []; }
846
876
  return compactMap(sortingIndicators, function (_a) {
877
+ var _b;
847
878
  var value = _a.value, direction = _a.direction;
848
879
  if (value.mode === exports.ESortingValueModes.FORMULA ||
849
880
  value.mode === exports.ESortingValueModes.QUANTITY ||
@@ -854,7 +885,20 @@ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measur
854
885
  if (value.mode === exports.ESortingValueModes.DIMENSION_IN_WIDGET ||
855
886
  value.mode === exports.ESortingValueModes.HIERARCHY) {
856
887
  var dimension = dimensionsInOriginalOrder[value.index];
857
- return (dimension && { formula: getDimensionFormula(dimension), direction: direction });
888
+ if (!dimension) {
889
+ return;
890
+ }
891
+ var formula = getDimensionFormula(dimension);
892
+ if (!formula || !checkDisplayCondition(dimension.displayCondition, variables)) {
893
+ return;
894
+ }
895
+ return {
896
+ formula: getDimensionFormula(dimension),
897
+ direction: direction,
898
+ displayCondition: ((_b = dimension.displayCondition) === null || _b === void 0 ? void 0 : _b.mode) === exports.EDisplayConditionMode.FORMULA
899
+ ? dimension.displayCondition.formula
900
+ : undefined,
901
+ };
858
902
  }
859
903
  if (value.mode === exports.ESortingValueModes.MEASURE_IN_WIDGET) {
860
904
  var measure = measuresInOriginalOrder[value.index];
@@ -882,9 +926,7 @@ function selectDimensionFromHierarchy(_a, filters) {
882
926
  if (!matchedFilter) {
883
927
  return "continue";
884
928
  }
885
- var selectionIndex = matchedFilter.values.length > 1
886
- ? i
887
- : Math.min(i + 1, dimensions.length - 1);
929
+ var selectionIndex = matchedFilter.values.length > 1 ? i : Math.min(i + 1, dimensions.length - 1);
888
930
  return { value: dimensions[selectionIndex] };
889
931
  };
890
932
  for (var i = dimensions.length - 1; i >= 0; i--) {
@@ -899,8 +941,7 @@ var replaceHierarchiesWithDimensions = function (dimensions, filters) {
899
941
  return compactMap(dimensions, function (indicator) {
900
942
  if (isHierarchy(indicator)) {
901
943
  var selectedDimension = selectDimensionFromHierarchy(indicator, filters);
902
- return (selectedDimension &&
903
- replaceDisplayCondition(selectedDimension, indicator.displayCondition));
944
+ return (selectedDimension && replaceDisplayCondition(selectedDimension, indicator.displayCondition));
904
945
  }
905
946
  return indicator;
906
947
  });
@@ -917,9 +958,12 @@ function bindContentWithIndicator(outputs, indicator) {
917
958
  * Массив объектов, каждый из которых содержит показатель и его контент
918
959
  */
919
960
  function bindContentsWithIndicators(outputs, indicators) {
920
- return compactMap(indicators, function (indicator) {
921
- return bindContentWithIndicator(outputs, indicator);
922
- });
961
+ return compactMap(indicators, function (indicator) { return bindContentWithIndicator(outputs, indicator); });
962
+ }
963
+
964
+ /** Удалить из строки символы экранирования */
965
+ function unescapeSpecialCharacters(str) {
966
+ return str.replace(/\\(?!\\)/g, "").replace(/\\\\/g, "\\");
923
967
  }
924
968
 
925
969
  exports.EControlType = void 0;
@@ -942,8 +986,23 @@ exports.EControlType = void 0;
942
986
  EControlType["inputMarkdown"] = "inputMarkdown";
943
987
  EControlType["filter"] = "filter";
944
988
  EControlType["actionOnClick"] = "actionOnClick";
989
+ EControlType["eventsPicker"] = "eventsPicker";
945
990
  })(exports.EControlType || (exports.EControlType = {}));
946
991
 
992
+ exports.ESelectOptionTypes = void 0;
993
+ (function (ESelectOptionTypes) {
994
+ ESelectOptionTypes["DIVIDER"] = "DIVIDER";
995
+ ESelectOptionTypes["SYSTEM"] = "SYSTEM";
996
+ ESelectOptionTypes["GROUP"] = "GROUP";
997
+ ESelectOptionTypes["BRANCH"] = "BRANCH";
998
+ ESelectOptionTypes["LEAF"] = "LEAF";
999
+ })(exports.ESelectOptionTypes || (exports.ESelectOptionTypes = {}));
1000
+ exports.ECustomSelectTemplates = void 0;
1001
+ (function (ECustomSelectTemplates) {
1002
+ ECustomSelectTemplates["FORMULA"] = "FORMULA";
1003
+ ECustomSelectTemplates["DIMENSION_GROUPS"] = "DIMENSION_GROUPS";
1004
+ })(exports.ECustomSelectTemplates || (exports.ECustomSelectTemplates = {}));
1005
+
947
1006
  exports.ESortDirection = void 0;
948
1007
  (function (ESortDirection) {
949
1008
  ESortDirection["descend"] = "DESC";
@@ -1046,11 +1105,11 @@ var getLocalizedText = function (language, locObj, props) {
1046
1105
  return localization.getLocalized(locObj, props);
1047
1106
  };
1048
1107
 
1049
- Object.defineProperty(exports, 'ELanguages', {
1108
+ Object.defineProperty(exports, "ELanguages", {
1050
1109
  enumerable: true,
1051
1110
  get: function () { return localization$1.ELanguages; }
1052
1111
  });
1053
- Object.defineProperty(exports, 'EFilteringMethodValues', {
1112
+ Object.defineProperty(exports, "EFilteringMethodValues", {
1054
1113
  enumerable: true,
1055
1114
  get: function () { return baseFilter.EFilteringMethodValues; }
1056
1115
  });
@@ -1078,7 +1137,6 @@ exports.mapFormulaFiltersToInputs = mapFormulaFiltersToInputs;
1078
1137
  exports.mapMeasuresToInputs = mapMeasuresToInputs;
1079
1138
  exports.mapSortingToInputs = mapSortingToInputs;
1080
1139
  exports.mapTransitionMeasuresToInputs = mapTransitionMeasuresToInputs;
1081
- exports.mapVariablesToInputs = mapVariablesToInputs;
1082
1140
  exports.measureTemplateFormulas = measureTemplateFormulas;
1083
1141
  exports.prepareValuesForSql = prepareValuesForSql;
1084
1142
  exports.replaceDisplayCondition = replaceDisplayCondition;
@@ -1086,6 +1144,7 @@ exports.replaceFiltersBySelection = replaceFiltersBySelection;
1086
1144
  exports.replaceHierarchiesWithDimensions = replaceHierarchiesWithDimensions;
1087
1145
  exports.selectDimensionFromHierarchy = selectDimensionFromHierarchy;
1088
1146
  exports.transitionMeasureTemplateFormulas = transitionMeasureTemplateFormulas;
1147
+ exports.unescapeSpecialCharacters = unescapeSpecialCharacters;
1089
1148
  exports.updateDefaultModeSelection = updateDefaultModeSelection;
1090
1149
  exports.updateMultiModeSelection = updateMultiModeSelection;
1091
1150
  exports.updateSingleModeSelection = updateSingleModeSelection;