@infomaximum/widget-sdk 3.25.1 → 3.26.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.
package/dist/index.d.ts CHANGED
@@ -477,6 +477,7 @@ type TSortDirection = ESortDirection.ascend | ESortDirection.descend;
477
477
  interface ISortOrder {
478
478
  formula: string;
479
479
  direction: TSortDirection;
480
+ displayCondition?: TNullable<string>;
480
481
  }
481
482
  type TWidgetSortingValueRelatedWidgetMeasure = {
482
483
  mode: ESortingValueModes.MEASURE_IN_WIDGET;
@@ -1135,7 +1136,7 @@ declare function mapEventMeasuresToInputs<T extends IProcessIndicator>(indicator
1135
1136
  * @param measuresInOriginalOrder меры виджета (конкретная мера будет браться по индексу)
1136
1137
  * @returns
1137
1138
  */
1138
- declare function mapSortingToInputs(sortingIndicators?: IWidgetSortingIndicator[], dimensionsInOriginalOrder?: IWidgetDimension[], measuresInOriginalOrder?: IWidgetMeasure[]): ISortOrder[];
1139
+ declare function mapSortingToInputs(sortingIndicators: IWidgetSortingIndicator[] | undefined, dimensionsInOriginalOrder: IWidgetDimension[] | undefined, measuresInOriginalOrder: IWidgetMeasure[] | undefined, variables: Map<string, TWidgetVariable>): ISortOrder[];
1139
1140
 
1140
1141
  /**
1141
1142
  * Выбрать активный разрез иерархии на основе активных фильтров.
@@ -1366,7 +1367,7 @@ declare const replaceFiltersBySelection: (filters: ICalculatorFilter[], selectio
1366
1367
  * @param {P} [props] - Дополнительные параметры локализации.
1367
1368
  * @returns {string} - Локализованный текст для указанного языка.
1368
1369
  */
1369
- declare const getLocalizedText: <L extends TLocalizationDescription, P extends ILocalizationProps = TExtractLocalizationParams<L>>(language: ELanguages, locObj: L, props?: P | undefined) => string;
1370
+ declare const getLocalizedText: <L extends TLocalizationDescription, P extends ILocalizationProps = TExtractLocalizationParams<L>>(language: ELanguages, locObj: L, props?: P) => string;
1370
1371
 
1371
1372
  type TDefineWidgetOptions = {
1372
1373
  manifest?: Record<string, unknown>;
package/dist/index.esm.js CHANGED
@@ -88,8 +88,7 @@ var isActionValid = function (action, _a) {
88
88
  return false;
89
89
  }
90
90
  var value = actionInput.value;
91
- if (value.mode === EWidgetActionInputMode.FROM_VARIABLE &&
92
- !variables.has(value.guid)) {
91
+ if (value.mode === EWidgetActionInputMode.FROM_VARIABLE && !variables.has(value.guid)) {
93
92
  return false;
94
93
  }
95
94
  if (value.mode === EWidgetActionInputMode.FORMULA && !value.formula) {
@@ -98,8 +97,7 @@ var isActionValid = function (action, _a) {
98
97
  if (value.mode === EWidgetActionInputMode.DYNAMIC_LIST && !value.formula) {
99
98
  return false;
100
99
  }
101
- if (value.mode === EWidgetActionInputMode.FROM_COLUMN &&
102
- !tables.has(value.tableName)) {
100
+ if (value.mode === EWidgetActionInputMode.FROM_COLUMN && !tables.has(value.tableName)) {
103
101
  return false;
104
102
  }
105
103
  return true;
@@ -124,9 +122,7 @@ var prepareValuesForSql = function (dataType, values) {
124
122
  dataType === ESimpleDataType.BOOLEAN
125
123
  ? values
126
124
  : values.map(function (value) {
127
- return value === null
128
- ? null
129
- : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
125
+ return value === null ? null : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
130
126
  });
131
127
  };
132
128
  var escapeReverseSlash = function (formula) {
@@ -137,7 +133,9 @@ var escapeSingularQuotes = function (formula) {
137
133
  };
138
134
 
139
135
  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)); };
136
+ var compactMap = function (items, f) {
137
+ return compact(items === null || items === void 0 ? void 0 : items.map(f));
138
+ };
141
139
  var isNil = function (value) {
142
140
  return value === null || value === undefined;
143
141
  };
@@ -509,9 +507,7 @@ function getDisplayConditionFormula(displayCondition) {
509
507
  }
510
508
  }
511
509
  var replaceDisplayCondition = function (dimension, displayCondition) {
512
- return isNil(displayCondition)
513
- ? dimension
514
- : __assign(__assign({}, dimension), { displayCondition: displayCondition });
510
+ return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
515
511
  };
516
512
 
517
513
  var escapeSpecialCharacters = function (formula) {
@@ -756,9 +752,7 @@ function mapMeasureToInput(measure, variables, addFormulas) {
756
752
  }
757
753
  /** Конвертировать меры виджета во входы для вычислителя */
758
754
  function mapMeasuresToInputs(measures, variables, addFormulas) {
759
- return compactMap(measures, function (measure) {
760
- return mapMeasureToInput(measure, variables, addFormulas);
761
- });
755
+ return compactMap(measures, function (measure) { return mapMeasureToInput(measure, variables, addFormulas); });
762
756
  }
763
757
 
764
758
  function mapDimensionToInput(dimension, variables) {
@@ -779,9 +773,7 @@ function mapDimensionToInput(dimension, variables) {
779
773
  }
780
774
  /** Конвертировать разрезы виджета во входы для вычислителя */
781
775
  function mapDimensionsToInputs(dimensions, variables) {
782
- return compactMap(dimensions, function (dimension) {
783
- return mapDimensionToInput(dimension, variables);
784
- });
776
+ return compactMap(dimensions, function (dimension) { return mapDimensionToInput(dimension, variables); });
785
777
  }
786
778
 
787
779
  function mapTransitionMeasureToInput(indicator, process, variables, addFormulas) {
@@ -839,11 +831,12 @@ function mapEventMeasuresToInputs(indicators, process, variables, addFormulas) {
839
831
  * @param measuresInOriginalOrder меры виджета (конкретная мера будет браться по индексу)
840
832
  * @returns
841
833
  */
842
- function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder) {
834
+ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder, variables) {
843
835
  if (sortingIndicators === void 0) { sortingIndicators = []; }
844
836
  if (dimensionsInOriginalOrder === void 0) { dimensionsInOriginalOrder = []; }
845
837
  if (measuresInOriginalOrder === void 0) { measuresInOriginalOrder = []; }
846
838
  return compactMap(sortingIndicators, function (_a) {
839
+ var _b;
847
840
  var value = _a.value, direction = _a.direction;
848
841
  if (value.mode === ESortingValueModes.FORMULA ||
849
842
  value.mode === ESortingValueModes.QUANTITY ||
@@ -854,7 +847,20 @@ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measur
854
847
  if (value.mode === ESortingValueModes.DIMENSION_IN_WIDGET ||
855
848
  value.mode === ESortingValueModes.HIERARCHY) {
856
849
  var dimension = dimensionsInOriginalOrder[value.index];
857
- return (dimension && { formula: getDimensionFormula(dimension), direction: direction });
850
+ if (!dimension) {
851
+ return;
852
+ }
853
+ var formula = getDimensionFormula(dimension);
854
+ if (!formula || !checkDisplayCondition(dimension.displayCondition, variables)) {
855
+ return;
856
+ }
857
+ return {
858
+ formula: getDimensionFormula(dimension),
859
+ direction: direction,
860
+ displayCondition: ((_b = dimension.displayCondition) === null || _b === void 0 ? void 0 : _b.mode) === EDisplayConditionMode.FORMULA
861
+ ? dimension.displayCondition.formula
862
+ : undefined,
863
+ };
858
864
  }
859
865
  if (value.mode === ESortingValueModes.MEASURE_IN_WIDGET) {
860
866
  var measure = measuresInOriginalOrder[value.index];
@@ -882,9 +888,7 @@ function selectDimensionFromHierarchy(_a, filters) {
882
888
  if (!matchedFilter) {
883
889
  return "continue";
884
890
  }
885
- var selectionIndex = matchedFilter.values.length > 1
886
- ? i
887
- : Math.min(i + 1, dimensions.length - 1);
891
+ var selectionIndex = matchedFilter.values.length > 1 ? i : Math.min(i + 1, dimensions.length - 1);
888
892
  return { value: dimensions[selectionIndex] };
889
893
  };
890
894
  for (var i = dimensions.length - 1; i >= 0; i--) {
@@ -899,8 +903,7 @@ var replaceHierarchiesWithDimensions = function (dimensions, filters) {
899
903
  return compactMap(dimensions, function (indicator) {
900
904
  if (isHierarchy(indicator)) {
901
905
  var selectedDimension = selectDimensionFromHierarchy(indicator, filters);
902
- return (selectedDimension &&
903
- replaceDisplayCondition(selectedDimension, indicator.displayCondition));
906
+ return (selectedDimension && replaceDisplayCondition(selectedDimension, indicator.displayCondition));
904
907
  }
905
908
  return indicator;
906
909
  });
@@ -917,9 +920,7 @@ function bindContentWithIndicator(outputs, indicator) {
917
920
  * Массив объектов, каждый из которых содержит показатель и его контент
918
921
  */
919
922
  function bindContentsWithIndicators(outputs, indicators) {
920
- return compactMap(indicators, function (indicator) {
921
- return bindContentWithIndicator(outputs, indicator);
922
- });
923
+ return compactMap(indicators, function (indicator) { return bindContentWithIndicator(outputs, indicator); });
923
924
  }
924
925
 
925
926
  var EControlType;
package/dist/index.js CHANGED
@@ -89,8 +89,7 @@ var isActionValid = function (action, _a) {
89
89
  return false;
90
90
  }
91
91
  var value = actionInput.value;
92
- if (value.mode === exports.EWidgetActionInputMode.FROM_VARIABLE &&
93
- !variables.has(value.guid)) {
92
+ if (value.mode === exports.EWidgetActionInputMode.FROM_VARIABLE && !variables.has(value.guid)) {
94
93
  return false;
95
94
  }
96
95
  if (value.mode === exports.EWidgetActionInputMode.FORMULA && !value.formula) {
@@ -99,8 +98,7 @@ var isActionValid = function (action, _a) {
99
98
  if (value.mode === exports.EWidgetActionInputMode.DYNAMIC_LIST && !value.formula) {
100
99
  return false;
101
100
  }
102
- if (value.mode === exports.EWidgetActionInputMode.FROM_COLUMN &&
103
- !tables.has(value.tableName)) {
101
+ if (value.mode === exports.EWidgetActionInputMode.FROM_COLUMN && !tables.has(value.tableName)) {
104
102
  return false;
105
103
  }
106
104
  return true;
@@ -125,9 +123,7 @@ var prepareValuesForSql = function (dataType, values) {
125
123
  dataType === exports.ESimpleDataType.BOOLEAN
126
124
  ? values
127
125
  : values.map(function (value) {
128
- return value === null
129
- ? null
130
- : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
126
+ return value === null ? null : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
131
127
  });
132
128
  };
133
129
  var escapeReverseSlash = function (formula) {
@@ -138,7 +134,9 @@ var escapeSingularQuotes = function (formula) {
138
134
  };
139
135
 
140
136
  var compact = function (items) { return ((items === null || items === void 0 ? void 0 : items.filter(Boolean)) || []); };
141
- var compactMap = function (items, f) { return compact(items === null || items === void 0 ? void 0 : items.map(f)); };
137
+ var compactMap = function (items, f) {
138
+ return compact(items === null || items === void 0 ? void 0 : items.map(f));
139
+ };
142
140
  var isNil = function (value) {
143
141
  return value === null || value === undefined;
144
142
  };
@@ -510,9 +508,7 @@ function getDisplayConditionFormula(displayCondition) {
510
508
  }
511
509
  }
512
510
  var replaceDisplayCondition = function (dimension, displayCondition) {
513
- return isNil(displayCondition)
514
- ? dimension
515
- : __assign(__assign({}, dimension), { displayCondition: displayCondition });
511
+ return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
516
512
  };
517
513
 
518
514
  var escapeSpecialCharacters = function (formula) {
@@ -757,9 +753,7 @@ function mapMeasureToInput(measure, variables, addFormulas) {
757
753
  }
758
754
  /** Конвертировать меры виджета во входы для вычислителя */
759
755
  function mapMeasuresToInputs(measures, variables, addFormulas) {
760
- return compactMap(measures, function (measure) {
761
- return mapMeasureToInput(measure, variables, addFormulas);
762
- });
756
+ return compactMap(measures, function (measure) { return mapMeasureToInput(measure, variables, addFormulas); });
763
757
  }
764
758
 
765
759
  function mapDimensionToInput(dimension, variables) {
@@ -780,9 +774,7 @@ function mapDimensionToInput(dimension, variables) {
780
774
  }
781
775
  /** Конвертировать разрезы виджета во входы для вычислителя */
782
776
  function mapDimensionsToInputs(dimensions, variables) {
783
- return compactMap(dimensions, function (dimension) {
784
- return mapDimensionToInput(dimension, variables);
785
- });
777
+ return compactMap(dimensions, function (dimension) { return mapDimensionToInput(dimension, variables); });
786
778
  }
787
779
 
788
780
  function mapTransitionMeasureToInput(indicator, process, variables, addFormulas) {
@@ -840,11 +832,12 @@ function mapEventMeasuresToInputs(indicators, process, variables, addFormulas) {
840
832
  * @param measuresInOriginalOrder меры виджета (конкретная мера будет браться по индексу)
841
833
  * @returns
842
834
  */
843
- function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder) {
835
+ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder, variables) {
844
836
  if (sortingIndicators === void 0) { sortingIndicators = []; }
845
837
  if (dimensionsInOriginalOrder === void 0) { dimensionsInOriginalOrder = []; }
846
838
  if (measuresInOriginalOrder === void 0) { measuresInOriginalOrder = []; }
847
839
  return compactMap(sortingIndicators, function (_a) {
840
+ var _b;
848
841
  var value = _a.value, direction = _a.direction;
849
842
  if (value.mode === exports.ESortingValueModes.FORMULA ||
850
843
  value.mode === exports.ESortingValueModes.QUANTITY ||
@@ -855,7 +848,20 @@ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measur
855
848
  if (value.mode === exports.ESortingValueModes.DIMENSION_IN_WIDGET ||
856
849
  value.mode === exports.ESortingValueModes.HIERARCHY) {
857
850
  var dimension = dimensionsInOriginalOrder[value.index];
858
- return (dimension && { formula: getDimensionFormula(dimension), direction: direction });
851
+ if (!dimension) {
852
+ return;
853
+ }
854
+ var formula = getDimensionFormula(dimension);
855
+ if (!formula || !checkDisplayCondition(dimension.displayCondition, variables)) {
856
+ return;
857
+ }
858
+ return {
859
+ formula: getDimensionFormula(dimension),
860
+ direction: direction,
861
+ displayCondition: ((_b = dimension.displayCondition) === null || _b === void 0 ? void 0 : _b.mode) === exports.EDisplayConditionMode.FORMULA
862
+ ? dimension.displayCondition.formula
863
+ : undefined,
864
+ };
859
865
  }
860
866
  if (value.mode === exports.ESortingValueModes.MEASURE_IN_WIDGET) {
861
867
  var measure = measuresInOriginalOrder[value.index];
@@ -883,9 +889,7 @@ function selectDimensionFromHierarchy(_a, filters) {
883
889
  if (!matchedFilter) {
884
890
  return "continue";
885
891
  }
886
- var selectionIndex = matchedFilter.values.length > 1
887
- ? i
888
- : Math.min(i + 1, dimensions.length - 1);
892
+ var selectionIndex = matchedFilter.values.length > 1 ? i : Math.min(i + 1, dimensions.length - 1);
889
893
  return { value: dimensions[selectionIndex] };
890
894
  };
891
895
  for (var i = dimensions.length - 1; i >= 0; i--) {
@@ -900,8 +904,7 @@ var replaceHierarchiesWithDimensions = function (dimensions, filters) {
900
904
  return compactMap(dimensions, function (indicator) {
901
905
  if (isHierarchy(indicator)) {
902
906
  var selectedDimension = selectDimensionFromHierarchy(indicator, filters);
903
- return (selectedDimension &&
904
- replaceDisplayCondition(selectedDimension, indicator.displayCondition));
907
+ return (selectedDimension && replaceDisplayCondition(selectedDimension, indicator.displayCondition));
905
908
  }
906
909
  return indicator;
907
910
  });
@@ -918,9 +921,7 @@ function bindContentWithIndicator(outputs, indicator) {
918
921
  * Массив объектов, каждый из которых содержит показатель и его контент
919
922
  */
920
923
  function bindContentsWithIndicators(outputs, indicators) {
921
- return compactMap(indicators, function (indicator) {
922
- return bindContentWithIndicator(outputs, indicator);
923
- });
924
+ return compactMap(indicators, function (indicator) { return bindContentWithIndicator(outputs, indicator); });
924
925
  }
925
926
 
926
927
  exports.EControlType = void 0;
@@ -1048,11 +1049,11 @@ var getLocalizedText = function (language, locObj, props) {
1048
1049
  return localization.getLocalized(locObj, props);
1049
1050
  };
1050
1051
 
1051
- Object.defineProperty(exports, 'ELanguages', {
1052
+ Object.defineProperty(exports, "ELanguages", {
1052
1053
  enumerable: true,
1053
1054
  get: function () { return localization$1.ELanguages; }
1054
1055
  });
1055
- Object.defineProperty(exports, 'EFilteringMethodValues', {
1056
+ Object.defineProperty(exports, "EFilteringMethodValues", {
1056
1057
  enumerable: true,
1057
1058
  get: function () { return baseFilter.EFilteringMethodValues; }
1058
1059
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infomaximum/widget-sdk",
3
- "version": "3.25.1",
3
+ "version": "3.26.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
@@ -12,24 +12,26 @@
12
12
  "scripts": {
13
13
  "build": "rollup -c",
14
14
  "lint": "tsc --noEmit",
15
- "release": "tsc --noEmit && standard-version && rollup -c"
15
+ "release": "tsc --noEmit && standard-version && rollup -c",
16
+ "format": "prettier --find-config-path --write 'src/**/*'"
16
17
  },
17
18
  "dependencies": {
19
+ "@infomaximum/base-filter": "^1.1.0",
18
20
  "@infomaximum/global-types": "^1.2.0",
19
- "@infomaximum/localization": "^1.0.4",
20
- "@infomaximum/base-filter": "^1.1.0"
21
+ "@infomaximum/localization": "^1.0.4"
21
22
  },
22
23
  "devDependencies": {
24
+ "@infomaximum/config": "^2.6.0",
23
25
  "@rollup/plugin-commonjs": "25.0.7",
24
26
  "@rollup/plugin-node-resolve": "15.2.3",
25
27
  "@rollup/plugin-typescript": "11.1.5",
26
- "prettier": "3.0.3",
27
- "rollup": "4.4.1",
28
+ "prettier": "3.2.5",
29
+ "rollup": "4.14.3",
28
30
  "rollup-plugin-delete": "2.0.0",
29
31
  "rollup-plugin-dts": "6.1.0",
30
32
  "standard-version": "9.5.0",
31
33
  "tslib": "^2.4.1",
32
- "typescript": "5.2.2"
34
+ "typescript": "5.4.5"
33
35
  },
34
36
  "repository": {
35
37
  "type": "git",