@infomaximum/widget-sdk 3.39.0 → 3.40.1

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
@@ -1094,7 +1094,7 @@ declare function mapEventMeasuresToInputs<T extends IProcessIndicator>(indicator
1094
1094
  * @param measuresInOriginalOrder меры виджета (конкретная мера будет браться по индексу)
1095
1095
  * @returns
1096
1096
  */
1097
- declare function mapSortingToInputs(sortingIndicators: IWidgetSortingIndicator[] | undefined, dimensionsInOriginalOrder: IWidgetDimension[] | undefined, measuresInOriginalOrder: IWidgetMeasure[] | undefined, variables: Map<string, TWidgetVariable>): ISortOrder[];
1097
+ declare function mapSortingToInputs(sortingIndicators: IWidgetSortingIndicator[] | undefined, dimensionsInOriginalOrder: IWidgetDimension[] | undefined, measuresInOriginalOrder: IWidgetMeasure[] | undefined, variables: Map<string, TWidgetVariable>, withDefaultSortOrder?: boolean): ISortOrder[];
1098
1098
 
1099
1099
  /**
1100
1100
  * Выбрать активный разрез иерархии на основе активных фильтров.
package/dist/index.esm.js CHANGED
@@ -841,6 +841,55 @@ function mapEventMeasuresToInputs(indicators, process, variables, addFormulas) {
841
841
  });
842
842
  }
843
843
 
844
+ var ESortDirection;
845
+ (function (ESortDirection) {
846
+ ESortDirection["descend"] = "DESC";
847
+ ESortDirection["ascend"] = "ASC";
848
+ ESortDirection["ASC"] = "ascend";
849
+ ESortDirection["DESC"] = "descend";
850
+ })(ESortDirection || (ESortDirection = {}));
851
+
852
+ var getDefaultSortOrder = function (dimensions, measures) {
853
+ /** Если есть условие отображения, то не делаем автосортировку */
854
+ if (dimensions.some(function (dimension) {
855
+ return dimension.displayCondition &&
856
+ dimension.displayCondition.mode !== EDisplayConditionMode.DISABLED;
857
+ })) {
858
+ return [];
859
+ }
860
+ /** Если есть временной разрез, то автосортировка по первому такому разрезу (по возрастанию) */
861
+ var timeDimension = dimensions.find(function (dimension) {
862
+ return dimension.format &&
863
+ [
864
+ EFormatTypes.DATE,
865
+ EFormatTypes.MONTH,
866
+ EFormatTypes.DATETIME,
867
+ EFormatTypes.DAY_OF_WEEK,
868
+ EFormatTypes.HOUR,
869
+ EFormatTypes.MONTH_YEAR,
870
+ EFormatTypes.YEAR,
871
+ EFormatTypes.QUARTER,
872
+ EFormatTypes.QUARTER_YEAR,
873
+ EFormatTypes.DAY_OF_MONTH,
874
+ EFormatTypes.WEEK,
875
+ ].includes(dimension.format);
876
+ });
877
+ if (timeDimension) {
878
+ return [{ formula: getDimensionFormula(timeDimension), direction: ESortDirection.ascend }];
879
+ }
880
+ if (measures.length > 0) {
881
+ var firstMeasure = measures[0];
882
+ if (firstMeasure) {
883
+ return [
884
+ {
885
+ direction: ESortDirection.descend,
886
+ formula: getMeasureFormula(firstMeasure),
887
+ },
888
+ ];
889
+ }
890
+ }
891
+ return [];
892
+ };
844
893
  /**
845
894
  * Преобразовать объекты сортировок из settings виджета в sortOrders вычислителя
846
895
  * @param sortingIndicators объекты сортировок из settings виджета
@@ -848,11 +897,12 @@ function mapEventMeasuresToInputs(indicators, process, variables, addFormulas) {
848
897
  * @param measuresInOriginalOrder меры виджета (конкретная мера будет браться по индексу)
849
898
  * @returns
850
899
  */
851
- function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder, variables) {
900
+ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder, variables, withDefaultSortOrder) {
852
901
  if (sortingIndicators === void 0) { sortingIndicators = []; }
853
902
  if (dimensionsInOriginalOrder === void 0) { dimensionsInOriginalOrder = []; }
854
903
  if (measuresInOriginalOrder === void 0) { measuresInOriginalOrder = []; }
855
- return compactMap(sortingIndicators, function (_a) {
904
+ if (withDefaultSortOrder === void 0) { withDefaultSortOrder = true; }
905
+ var sortOrder = compactMap(sortingIndicators, function (_a) {
856
906
  var _b;
857
907
  var value = _a.value, direction = _a.direction;
858
908
  if (value.mode === ESortingValueModes.FORMULA ||
@@ -884,6 +934,9 @@ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measur
884
934
  return measure && { formula: getMeasureFormula(measure), direction: direction };
885
935
  }
886
936
  });
937
+ return withDefaultSortOrder && sortOrder.length === 0
938
+ ? getDefaultSortOrder(dimensionsInOriginalOrder, measuresInOriginalOrder)
939
+ : sortOrder;
887
940
  }
888
941
 
889
942
  /**
@@ -977,14 +1030,6 @@ var ECustomSelectTemplates;
977
1030
  ECustomSelectTemplates["DIMENSION_GROUPS"] = "DIMENSION_GROUPS";
978
1031
  })(ECustomSelectTemplates || (ECustomSelectTemplates = {}));
979
1032
 
980
- var ESortDirection;
981
- (function (ESortDirection) {
982
- ESortDirection["descend"] = "DESC";
983
- ESortDirection["ascend"] = "ASC";
984
- ESortDirection["ASC"] = "ascend";
985
- ESortDirection["DESC"] = "descend";
986
- })(ESortDirection || (ESortDirection = {}));
987
-
988
1033
  var findFilterByFormula = function (filters, formula) {
989
1034
  var _a;
990
1035
  return ((_a = filters.find(function (filter) {
package/dist/index.js CHANGED
@@ -842,6 +842,55 @@ function mapEventMeasuresToInputs(indicators, process, variables, addFormulas) {
842
842
  });
843
843
  }
844
844
 
845
+ exports.ESortDirection = void 0;
846
+ (function (ESortDirection) {
847
+ ESortDirection["descend"] = "DESC";
848
+ ESortDirection["ascend"] = "ASC";
849
+ ESortDirection["ASC"] = "ascend";
850
+ ESortDirection["DESC"] = "descend";
851
+ })(exports.ESortDirection || (exports.ESortDirection = {}));
852
+
853
+ var getDefaultSortOrder = function (dimensions, measures) {
854
+ /** Если есть условие отображения, то не делаем автосортировку */
855
+ if (dimensions.some(function (dimension) {
856
+ return dimension.displayCondition &&
857
+ dimension.displayCondition.mode !== exports.EDisplayConditionMode.DISABLED;
858
+ })) {
859
+ return [];
860
+ }
861
+ /** Если есть временной разрез, то автосортировка по первому такому разрезу (по возрастанию) */
862
+ var timeDimension = dimensions.find(function (dimension) {
863
+ return dimension.format &&
864
+ [
865
+ exports.EFormatTypes.DATE,
866
+ exports.EFormatTypes.MONTH,
867
+ exports.EFormatTypes.DATETIME,
868
+ exports.EFormatTypes.DAY_OF_WEEK,
869
+ exports.EFormatTypes.HOUR,
870
+ exports.EFormatTypes.MONTH_YEAR,
871
+ exports.EFormatTypes.YEAR,
872
+ exports.EFormatTypes.QUARTER,
873
+ exports.EFormatTypes.QUARTER_YEAR,
874
+ exports.EFormatTypes.DAY_OF_MONTH,
875
+ exports.EFormatTypes.WEEK,
876
+ ].includes(dimension.format);
877
+ });
878
+ if (timeDimension) {
879
+ return [{ formula: getDimensionFormula(timeDimension), direction: exports.ESortDirection.ascend }];
880
+ }
881
+ if (measures.length > 0) {
882
+ var firstMeasure = measures[0];
883
+ if (firstMeasure) {
884
+ return [
885
+ {
886
+ direction: exports.ESortDirection.descend,
887
+ formula: getMeasureFormula(firstMeasure),
888
+ },
889
+ ];
890
+ }
891
+ }
892
+ return [];
893
+ };
845
894
  /**
846
895
  * Преобразовать объекты сортировок из settings виджета в sortOrders вычислителя
847
896
  * @param sortingIndicators объекты сортировок из settings виджета
@@ -849,11 +898,12 @@ function mapEventMeasuresToInputs(indicators, process, variables, addFormulas) {
849
898
  * @param measuresInOriginalOrder меры виджета (конкретная мера будет браться по индексу)
850
899
  * @returns
851
900
  */
852
- function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder, variables) {
901
+ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder, variables, withDefaultSortOrder) {
853
902
  if (sortingIndicators === void 0) { sortingIndicators = []; }
854
903
  if (dimensionsInOriginalOrder === void 0) { dimensionsInOriginalOrder = []; }
855
904
  if (measuresInOriginalOrder === void 0) { measuresInOriginalOrder = []; }
856
- return compactMap(sortingIndicators, function (_a) {
905
+ if (withDefaultSortOrder === void 0) { withDefaultSortOrder = true; }
906
+ var sortOrder = compactMap(sortingIndicators, function (_a) {
857
907
  var _b;
858
908
  var value = _a.value, direction = _a.direction;
859
909
  if (value.mode === exports.ESortingValueModes.FORMULA ||
@@ -885,6 +935,9 @@ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measur
885
935
  return measure && { formula: getMeasureFormula(measure), direction: direction };
886
936
  }
887
937
  });
938
+ return withDefaultSortOrder && sortOrder.length === 0
939
+ ? getDefaultSortOrder(dimensionsInOriginalOrder, measuresInOriginalOrder)
940
+ : sortOrder;
888
941
  }
889
942
 
890
943
  /**
@@ -978,14 +1031,6 @@ exports.ECustomSelectTemplates = void 0;
978
1031
  ECustomSelectTemplates["DIMENSION_GROUPS"] = "DIMENSION_GROUPS";
979
1032
  })(exports.ECustomSelectTemplates || (exports.ECustomSelectTemplates = {}));
980
1033
 
981
- exports.ESortDirection = void 0;
982
- (function (ESortDirection) {
983
- ESortDirection["descend"] = "DESC";
984
- ESortDirection["ascend"] = "ASC";
985
- ESortDirection["ASC"] = "ascend";
986
- ESortDirection["DESC"] = "descend";
987
- })(exports.ESortDirection || (exports.ESortDirection = {}));
988
-
989
1034
  var findFilterByFormula = function (filters, formula) {
990
1035
  var _a;
991
1036
  return ((_a = filters.find(function (filter) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infomaximum/widget-sdk",
3
- "version": "3.39.0",
3
+ "version": "3.40.1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
@@ -12,8 +12,9 @@
12
12
  "scripts": {
13
13
  "build": "rollup -c",
14
14
  "lint": "tsc --noEmit",
15
- "release": "tsc --noEmit && standard-version && rollup -c",
16
- "format": "prettier --find-config-path --write 'src/**/*'"
15
+ "release": "npm run lint && standard-version && npm run build",
16
+ "format": "prettier --find-config-path --write 'src/**/*'",
17
+ "prepublishOnly": "npm run build"
17
18
  },
18
19
  "dependencies": {
19
20
  "@infomaximum/base-filter": "^1.1.0",
@@ -25,6 +26,7 @@
25
26
  "@rollup/plugin-commonjs": "25.0.7",
26
27
  "@rollup/plugin-node-resolve": "15.2.3",
27
28
  "@rollup/plugin-typescript": "11.1.5",
29
+ "core-js": "^3.38.0",
28
30
  "prettier": "3.2.5",
29
31
  "rollup": "4.14.3",
30
32
  "rollup-plugin-delete": "2.0.0",