@infomaximum/widget-sdk 3.26.0-beta → 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 +14 -11
- package/dist/index.esm.js +29 -27
- package/dist/index.js +31 -29
- package/package.json +9 -7
package/dist/index.d.ts
CHANGED
|
@@ -404,6 +404,13 @@ interface IWidgetFiltration {
|
|
|
404
404
|
removeStagesFilter(widgetKey: string): void;
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
+
interface IPlacement {
|
|
408
|
+
left: number;
|
|
409
|
+
top: number;
|
|
410
|
+
width: number;
|
|
411
|
+
height: number;
|
|
412
|
+
zIndex: number;
|
|
413
|
+
}
|
|
407
414
|
declare enum EWidgetFilterMode {
|
|
408
415
|
DEFAULT = "DEFAULT",
|
|
409
416
|
SINGLE = "SINGLE",
|
|
@@ -470,6 +477,7 @@ type TSortDirection = ESortDirection.ascend | ESortDirection.descend;
|
|
|
470
477
|
interface ISortOrder {
|
|
471
478
|
formula: string;
|
|
472
479
|
direction: TSortDirection;
|
|
480
|
+
displayCondition?: TNullable<string>;
|
|
473
481
|
}
|
|
474
482
|
type TWidgetSortingValueRelatedWidgetMeasure = {
|
|
475
483
|
mode: ESortingValueModes.MEASURE_IN_WIDGET;
|
|
@@ -770,7 +778,7 @@ interface IWidgetAction {
|
|
|
770
778
|
inputs: IWidgetActionInput[];
|
|
771
779
|
shouldRefreshWidgetsAfterExecution: boolean;
|
|
772
780
|
}
|
|
773
|
-
declare const isActionValid: (action: IWidgetAction, { scripts, tables }: IWidgetsContext) => boolean;
|
|
781
|
+
declare const isActionValid: (action: IWidgetAction, { scripts, tables, variables }: IWidgetsContext) => boolean;
|
|
774
782
|
|
|
775
783
|
interface IBaseWidgetSettings {
|
|
776
784
|
apiVersion: string;
|
|
@@ -781,6 +789,7 @@ interface IBaseWidgetSettings {
|
|
|
781
789
|
filters?: (IFormulaFilterValue | string)[];
|
|
782
790
|
filterMode?: EWidgetFilterMode;
|
|
783
791
|
ignoreFilters?: boolean;
|
|
792
|
+
placement: IPlacement;
|
|
784
793
|
sorting?: IWidgetSortingIndicator[];
|
|
785
794
|
actions?: IWidgetAction[];
|
|
786
795
|
displayCondition?: TDisplayCondition;
|
|
@@ -1127,7 +1136,7 @@ declare function mapEventMeasuresToInputs<T extends IProcessIndicator>(indicator
|
|
|
1127
1136
|
* @param measuresInOriginalOrder меры виджета (конкретная мера будет браться по индексу)
|
|
1128
1137
|
* @returns
|
|
1129
1138
|
*/
|
|
1130
|
-
declare function mapSortingToInputs(sortingIndicators
|
|
1139
|
+
declare function mapSortingToInputs(sortingIndicators: IWidgetSortingIndicator[] | undefined, dimensionsInOriginalOrder: IWidgetDimension[] | undefined, measuresInOriginalOrder: IWidgetMeasure[] | undefined, variables: Map<string, TWidgetVariable>): ISortOrder[];
|
|
1131
1140
|
|
|
1132
1141
|
/**
|
|
1133
1142
|
* Выбрать активный разрез иерархии на основе активных фильтров.
|
|
@@ -1179,10 +1188,6 @@ type TLaunchActionParams = {
|
|
|
1179
1188
|
filters: ICalculatorFilter[];
|
|
1180
1189
|
needConfirmation?: boolean;
|
|
1181
1190
|
};
|
|
1182
|
-
type TWidgetContainer = {
|
|
1183
|
-
/** Имеет ли контейнер виджета ограниченную максимальную высоту */
|
|
1184
|
-
isMaxHeightLimited: boolean;
|
|
1185
|
-
};
|
|
1186
1191
|
interface IWidgetProps<WidgetSettings extends IBaseWidgetSettings = IBaseWidgetSettings> {
|
|
1187
1192
|
/** guid виджета */
|
|
1188
1193
|
guid: string;
|
|
@@ -1203,10 +1208,8 @@ interface IWidgetProps<WidgetSettings extends IBaseWidgetSettings = IBaseWidgetS
|
|
|
1203
1208
|
rootViewContainer: HTMLDivElement;
|
|
1204
1209
|
/** Объект для управления плейсхолдером */
|
|
1205
1210
|
placeholder: IWidgetPlaceholderController;
|
|
1206
|
-
/** Контекст
|
|
1211
|
+
/** Контекст виджета */
|
|
1207
1212
|
widgetsContext: IWidgetsContext;
|
|
1208
|
-
/** Данные о контейнере виджета */
|
|
1209
|
-
widgetContainer: TWidgetContainer;
|
|
1210
1213
|
/** Запуск действия */
|
|
1211
1214
|
launchAction(params: TLaunchActionParams): void;
|
|
1212
1215
|
}
|
|
@@ -1364,7 +1367,7 @@ declare const replaceFiltersBySelection: (filters: ICalculatorFilter[], selectio
|
|
|
1364
1367
|
* @param {P} [props] - Дополнительные параметры локализации.
|
|
1365
1368
|
* @returns {string} - Локализованный текст для указанного языка.
|
|
1366
1369
|
*/
|
|
1367
|
-
declare const getLocalizedText: <L extends TLocalizationDescription, P extends ILocalizationProps = TExtractLocalizationParams<L>>(language: ELanguages, locObj: L, props?: P
|
|
1370
|
+
declare const getLocalizedText: <L extends TLocalizationDescription, P extends ILocalizationProps = TExtractLocalizationParams<L>>(language: ELanguages, locObj: L, props?: P) => string;
|
|
1368
1371
|
|
|
1369
1372
|
type TDefineWidgetOptions = {
|
|
1370
1373
|
manifest?: Record<string, unknown>;
|
|
@@ -1380,4 +1383,4 @@ declare global {
|
|
|
1380
1383
|
}
|
|
1381
1384
|
}
|
|
1382
1385
|
|
|
1383
|
-
export { ECalculatorFilterMethods, EColorMode, EControlType, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDurationUnit, EEventMeasureTemplateNames, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMeasureTemplateNames, EProcessFilterNames, ESimpleDataType, ESortDirection, ESortingValueModes, ETransitionMeasureTemplateNames, EWidgetActionInputMode, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, type IActionScript, type IAddDurationOfTransitionFilter, type IAddPresenceOfEventFilter, type IAddPresenceOfTransitionFilter, type IAddRepetitionOfEventFilter, type IBaseDimensionsAndMeasuresCalculator, type IBaseDimensionsAndMeasuresCalculatorInput, type IBaseDimensionsAndMeasuresCalculatorOutput, type IBaseWidgetSettings, type ICalculator, type ICalculatorDimensionInput, type ICalculatorDimensionOutput, type ICalculatorFactory, type ICalculatorFilter, type ICalculatorIndicatorInput, type ICalculatorIndicatorOutput, type ICalculatorMeasureInput, type ICalculatorMeasureOutput, type ICalculatorVariable, type ICalculatorVariablesValues, type ICommonColumnIndicator, type IControlRecord, type ICustomAddButtonProps, type ICustomWidgetProps, type IDefinition, type IDimensionSelection, type IDimensionSelectionByFormula, type IDisplayPredicate, type IDivePanelDescription, type IDividerRecord, type IEdge, type IExportColumnOrder, type IFillSettings, type IFormulaFilterValue, type IGeneralCalculator, type IGeneralCalculatorExportInput, type IGeneralCalculatorInput, type IGeneralCalculatorOutput, type IGraphElement, type IGroupSetDescription, type IGroupSetRecord, type IGroupSettings, type IHistogramBin, type IHistogramCalculator, type IHistogramCalculatorInput, type IHistogramCalculatorOutput, type ILens, type IPanelDescription, type IPanelDescriptionCreator, type IPieCalculator, type IPieCalculatorInput, type IPieCalculatorOutput, type IProcessEventFilterValue, type IProcessEventIndicator, type IProcessGraphCalculator, type IProcessGraphCalculatorInput, type IProcessGraphCalculatorOutput, type IProcessIndicator, type IProcessTransitionFilterValue, type IProcessTransitionIndicator, type IRange, type ISelectOption, type ISortOrder, type IStagesFilterValue, type ITwoLimitsCalculator, type ITwoLimitsCalculatorExportInput, type ITwoLimitsCalculatorInput, type ITwoLimitsCalculatorOutput, type ITypeCalculator, type ITypeCalculatorInput, type ITypeCalculatorOutput, type IVertex, type IWidget, type IWidgetAction, type IWidgetActionInput, type IWidgetColumnIndicator, type IWidgetDimension, type IWidgetDimensionHierarchy, type IWidgetEntity, type IWidgetFilter, type IWidgetFiltration, type IWidgetFormatting, type IWidgetFormulaFilterValue, type IWidgetIndicator, type IWidgetMeasure, type IWidgetPlaceholderController, type IWidgetProcess, type IWidgetProps, type IWidgetSortingIndicator, type IWidgetTable, type IWidgetTableColumn, type IWidgetsContext, type TBoundedContentWithIndicator, type TColor, type TColumnIndicatorValue, type TDefineWidgetOptions, type TDisplayCondition, type TDisplayMode, type TEmptyRecord, type TGroupLevelRecord, type TLaunchActionParams, type TProcessIndicatorValue, type TRecordAccessor, type TSelectivePartial, type TSortDirection, type TUpdateSelection, type TValuePath, type TWidgetActionInputValue, type
|
|
1386
|
+
export { ECalculatorFilterMethods, EColorMode, EControlType, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDurationUnit, EEventMeasureTemplateNames, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMeasureTemplateNames, EProcessFilterNames, ESimpleDataType, ESortDirection, ESortingValueModes, ETransitionMeasureTemplateNames, EWidgetActionInputMode, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, type IActionScript, type IAddDurationOfTransitionFilter, type IAddPresenceOfEventFilter, type IAddPresenceOfTransitionFilter, type IAddRepetitionOfEventFilter, type IBaseDimensionsAndMeasuresCalculator, type IBaseDimensionsAndMeasuresCalculatorInput, type IBaseDimensionsAndMeasuresCalculatorOutput, type IBaseWidgetSettings, type ICalculator, type ICalculatorDimensionInput, type ICalculatorDimensionOutput, type ICalculatorFactory, type ICalculatorFilter, type ICalculatorIndicatorInput, type ICalculatorIndicatorOutput, type ICalculatorMeasureInput, type ICalculatorMeasureOutput, type ICalculatorVariable, type ICalculatorVariablesValues, type ICommonColumnIndicator, type IControlRecord, type ICustomAddButtonProps, type ICustomWidgetProps, type IDefinition, type IDimensionSelection, type IDimensionSelectionByFormula, type IDisplayPredicate, type IDivePanelDescription, type IDividerRecord, type IEdge, type IExportColumnOrder, type IFillSettings, type IFormulaFilterValue, type IGeneralCalculator, type IGeneralCalculatorExportInput, type IGeneralCalculatorInput, type IGeneralCalculatorOutput, type IGraphElement, type IGroupSetDescription, type IGroupSetRecord, type IGroupSettings, type IHistogramBin, type IHistogramCalculator, type IHistogramCalculatorInput, type IHistogramCalculatorOutput, type ILens, type IPanelDescription, type IPanelDescriptionCreator, type IPieCalculator, type IPieCalculatorInput, type IPieCalculatorOutput, type IPlacement, type IProcessEventFilterValue, type IProcessEventIndicator, type IProcessGraphCalculator, type IProcessGraphCalculatorInput, type IProcessGraphCalculatorOutput, type IProcessIndicator, type IProcessTransitionFilterValue, type IProcessTransitionIndicator, type IRange, type ISelectOption, type ISortOrder, type IStagesFilterValue, type ITwoLimitsCalculator, type ITwoLimitsCalculatorExportInput, type ITwoLimitsCalculatorInput, type ITwoLimitsCalculatorOutput, type ITypeCalculator, type ITypeCalculatorInput, type ITypeCalculatorOutput, type IVertex, type IWidget, type IWidgetAction, type IWidgetActionInput, type IWidgetColumnIndicator, type IWidgetDimension, type IWidgetDimensionHierarchy, type IWidgetEntity, type IWidgetFilter, type IWidgetFiltration, type IWidgetFormatting, type IWidgetFormulaFilterValue, type IWidgetIndicator, type IWidgetMeasure, type IWidgetPlaceholderController, type IWidgetProcess, type IWidgetProps, type IWidgetSortingIndicator, type IWidgetTable, type IWidgetTableColumn, type IWidgetsContext, type TBoundedContentWithIndicator, type TColor, type TColumnIndicatorValue, type TDefineWidgetOptions, type TDisplayCondition, type TDisplayMode, type TEmptyRecord, type TGroupLevelRecord, type TLaunchActionParams, type TProcessIndicatorValue, type TRecordAccessor, type TSelectivePartial, type TSortDirection, type TUpdateSelection, type TValuePath, type TWidgetActionInputValue, type TWidgetFilterValue, type TWidgetFiltering, type TWidgetLevelRecord, type TWidgetSortingValue, type TWidgetSortingValueRelatedWidgetDimension, type TWidgetSortingValueRelatedWidgetIndicator, type TWidgetSortingValueRelatedWidgetMeasure, type TWidgetVariable, 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 };
|
package/dist/index.esm.js
CHANGED
|
@@ -73,7 +73,7 @@ var EWidgetActionInputMode;
|
|
|
73
73
|
})(EWidgetActionInputMode || (EWidgetActionInputMode = {}));
|
|
74
74
|
var isActionValid = function (action, _a) {
|
|
75
75
|
var _b;
|
|
76
|
-
var scripts = _a.scripts, tables = _a.tables;
|
|
76
|
+
var scripts = _a.scripts, tables = _a.tables, variables = _a.variables;
|
|
77
77
|
var currentScript = scripts.get((_b = action.scriptGuid) !== null && _b !== void 0 ? _b : "");
|
|
78
78
|
if (!currentScript) {
|
|
79
79
|
return false;
|
|
@@ -88,7 +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 && !value.guid) {
|
|
91
|
+
if (value.mode === EWidgetActionInputMode.FROM_VARIABLE && !variables.has(value.guid)) {
|
|
92
92
|
return false;
|
|
93
93
|
}
|
|
94
94
|
if (value.mode === EWidgetActionInputMode.FORMULA && !value.formula) {
|
|
@@ -97,8 +97,7 @@ var isActionValid = function (action, _a) {
|
|
|
97
97
|
if (value.mode === EWidgetActionInputMode.DYNAMIC_LIST && !value.formula) {
|
|
98
98
|
return false;
|
|
99
99
|
}
|
|
100
|
-
if (value.mode === EWidgetActionInputMode.FROM_COLUMN &&
|
|
101
|
-
!tables.has(value.tableName)) {
|
|
100
|
+
if (value.mode === EWidgetActionInputMode.FROM_COLUMN && !tables.has(value.tableName)) {
|
|
102
101
|
return false;
|
|
103
102
|
}
|
|
104
103
|
return true;
|
|
@@ -123,9 +122,7 @@ var prepareValuesForSql = function (dataType, values) {
|
|
|
123
122
|
dataType === ESimpleDataType.BOOLEAN
|
|
124
123
|
? values
|
|
125
124
|
: values.map(function (value) {
|
|
126
|
-
return value === null
|
|
127
|
-
? null
|
|
128
|
-
: "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
|
|
125
|
+
return value === null ? null : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
|
|
129
126
|
});
|
|
130
127
|
};
|
|
131
128
|
var escapeReverseSlash = function (formula) {
|
|
@@ -136,7 +133,9 @@ var escapeSingularQuotes = function (formula) {
|
|
|
136
133
|
};
|
|
137
134
|
|
|
138
135
|
var compact = function (items) { return ((items === null || items === void 0 ? void 0 : items.filter(Boolean)) || []); };
|
|
139
|
-
var compactMap = function (items, f) {
|
|
136
|
+
var compactMap = function (items, f) {
|
|
137
|
+
return compact(items === null || items === void 0 ? void 0 : items.map(f));
|
|
138
|
+
};
|
|
140
139
|
var isNil = function (value) {
|
|
141
140
|
return value === null || value === undefined;
|
|
142
141
|
};
|
|
@@ -508,9 +507,7 @@ function getDisplayConditionFormula(displayCondition) {
|
|
|
508
507
|
}
|
|
509
508
|
}
|
|
510
509
|
var replaceDisplayCondition = function (dimension, displayCondition) {
|
|
511
|
-
return isNil(displayCondition)
|
|
512
|
-
? dimension
|
|
513
|
-
: __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
510
|
+
return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
514
511
|
};
|
|
515
512
|
|
|
516
513
|
var escapeSpecialCharacters = function (formula) {
|
|
@@ -755,9 +752,7 @@ function mapMeasureToInput(measure, variables, addFormulas) {
|
|
|
755
752
|
}
|
|
756
753
|
/** Конвертировать меры виджета во входы для вычислителя */
|
|
757
754
|
function mapMeasuresToInputs(measures, variables, addFormulas) {
|
|
758
|
-
return compactMap(measures, function (measure) {
|
|
759
|
-
return mapMeasureToInput(measure, variables, addFormulas);
|
|
760
|
-
});
|
|
755
|
+
return compactMap(measures, function (measure) { return mapMeasureToInput(measure, variables, addFormulas); });
|
|
761
756
|
}
|
|
762
757
|
|
|
763
758
|
function mapDimensionToInput(dimension, variables) {
|
|
@@ -778,9 +773,7 @@ function mapDimensionToInput(dimension, variables) {
|
|
|
778
773
|
}
|
|
779
774
|
/** Конвертировать разрезы виджета во входы для вычислителя */
|
|
780
775
|
function mapDimensionsToInputs(dimensions, variables) {
|
|
781
|
-
return compactMap(dimensions, function (dimension) {
|
|
782
|
-
return mapDimensionToInput(dimension, variables);
|
|
783
|
-
});
|
|
776
|
+
return compactMap(dimensions, function (dimension) { return mapDimensionToInput(dimension, variables); });
|
|
784
777
|
}
|
|
785
778
|
|
|
786
779
|
function mapTransitionMeasureToInput(indicator, process, variables, addFormulas) {
|
|
@@ -838,11 +831,12 @@ function mapEventMeasuresToInputs(indicators, process, variables, addFormulas) {
|
|
|
838
831
|
* @param measuresInOriginalOrder меры виджета (конкретная мера будет браться по индексу)
|
|
839
832
|
* @returns
|
|
840
833
|
*/
|
|
841
|
-
function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder) {
|
|
834
|
+
function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder, variables) {
|
|
842
835
|
if (sortingIndicators === void 0) { sortingIndicators = []; }
|
|
843
836
|
if (dimensionsInOriginalOrder === void 0) { dimensionsInOriginalOrder = []; }
|
|
844
837
|
if (measuresInOriginalOrder === void 0) { measuresInOriginalOrder = []; }
|
|
845
838
|
return compactMap(sortingIndicators, function (_a) {
|
|
839
|
+
var _b;
|
|
846
840
|
var value = _a.value, direction = _a.direction;
|
|
847
841
|
if (value.mode === ESortingValueModes.FORMULA ||
|
|
848
842
|
value.mode === ESortingValueModes.QUANTITY ||
|
|
@@ -853,7 +847,20 @@ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measur
|
|
|
853
847
|
if (value.mode === ESortingValueModes.DIMENSION_IN_WIDGET ||
|
|
854
848
|
value.mode === ESortingValueModes.HIERARCHY) {
|
|
855
849
|
var dimension = dimensionsInOriginalOrder[value.index];
|
|
856
|
-
|
|
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
|
+
};
|
|
857
864
|
}
|
|
858
865
|
if (value.mode === ESortingValueModes.MEASURE_IN_WIDGET) {
|
|
859
866
|
var measure = measuresInOriginalOrder[value.index];
|
|
@@ -881,9 +888,7 @@ function selectDimensionFromHierarchy(_a, filters) {
|
|
|
881
888
|
if (!matchedFilter) {
|
|
882
889
|
return "continue";
|
|
883
890
|
}
|
|
884
|
-
var selectionIndex = matchedFilter.values.length > 1
|
|
885
|
-
? i
|
|
886
|
-
: Math.min(i + 1, dimensions.length - 1);
|
|
891
|
+
var selectionIndex = matchedFilter.values.length > 1 ? i : Math.min(i + 1, dimensions.length - 1);
|
|
887
892
|
return { value: dimensions[selectionIndex] };
|
|
888
893
|
};
|
|
889
894
|
for (var i = dimensions.length - 1; i >= 0; i--) {
|
|
@@ -898,8 +903,7 @@ var replaceHierarchiesWithDimensions = function (dimensions, filters) {
|
|
|
898
903
|
return compactMap(dimensions, function (indicator) {
|
|
899
904
|
if (isHierarchy(indicator)) {
|
|
900
905
|
var selectedDimension = selectDimensionFromHierarchy(indicator, filters);
|
|
901
|
-
return (selectedDimension &&
|
|
902
|
-
replaceDisplayCondition(selectedDimension, indicator.displayCondition));
|
|
906
|
+
return (selectedDimension && replaceDisplayCondition(selectedDimension, indicator.displayCondition));
|
|
903
907
|
}
|
|
904
908
|
return indicator;
|
|
905
909
|
});
|
|
@@ -916,9 +920,7 @@ function bindContentWithIndicator(outputs, indicator) {
|
|
|
916
920
|
* Массив объектов, каждый из которых содержит показатель и его контент
|
|
917
921
|
*/
|
|
918
922
|
function bindContentsWithIndicators(outputs, indicators) {
|
|
919
|
-
return compactMap(indicators, function (indicator) {
|
|
920
|
-
return bindContentWithIndicator(outputs, indicator);
|
|
921
|
-
});
|
|
923
|
+
return compactMap(indicators, function (indicator) { return bindContentWithIndicator(outputs, indicator); });
|
|
922
924
|
}
|
|
923
925
|
|
|
924
926
|
var EControlType;
|
package/dist/index.js
CHANGED
|
@@ -74,7 +74,7 @@ exports.EWidgetActionInputMode = void 0;
|
|
|
74
74
|
})(exports.EWidgetActionInputMode || (exports.EWidgetActionInputMode = {}));
|
|
75
75
|
var isActionValid = function (action, _a) {
|
|
76
76
|
var _b;
|
|
77
|
-
var scripts = _a.scripts, tables = _a.tables;
|
|
77
|
+
var scripts = _a.scripts, tables = _a.tables, variables = _a.variables;
|
|
78
78
|
var currentScript = scripts.get((_b = action.scriptGuid) !== null && _b !== void 0 ? _b : "");
|
|
79
79
|
if (!currentScript) {
|
|
80
80
|
return false;
|
|
@@ -89,7 +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 && !value.guid) {
|
|
92
|
+
if (value.mode === exports.EWidgetActionInputMode.FROM_VARIABLE && !variables.has(value.guid)) {
|
|
93
93
|
return false;
|
|
94
94
|
}
|
|
95
95
|
if (value.mode === exports.EWidgetActionInputMode.FORMULA && !value.formula) {
|
|
@@ -98,8 +98,7 @@ var isActionValid = function (action, _a) {
|
|
|
98
98
|
if (value.mode === exports.EWidgetActionInputMode.DYNAMIC_LIST && !value.formula) {
|
|
99
99
|
return false;
|
|
100
100
|
}
|
|
101
|
-
if (value.mode === exports.EWidgetActionInputMode.FROM_COLUMN &&
|
|
102
|
-
!tables.has(value.tableName)) {
|
|
101
|
+
if (value.mode === exports.EWidgetActionInputMode.FROM_COLUMN && !tables.has(value.tableName)) {
|
|
103
102
|
return false;
|
|
104
103
|
}
|
|
105
104
|
return true;
|
|
@@ -124,9 +123,7 @@ var prepareValuesForSql = function (dataType, values) {
|
|
|
124
123
|
dataType === exports.ESimpleDataType.BOOLEAN
|
|
125
124
|
? values
|
|
126
125
|
: values.map(function (value) {
|
|
127
|
-
return value === null
|
|
128
|
-
? null
|
|
129
|
-
: "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
|
|
126
|
+
return value === null ? null : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
|
|
130
127
|
});
|
|
131
128
|
};
|
|
132
129
|
var escapeReverseSlash = function (formula) {
|
|
@@ -137,7 +134,9 @@ var escapeSingularQuotes = function (formula) {
|
|
|
137
134
|
};
|
|
138
135
|
|
|
139
136
|
var compact = function (items) { return ((items === null || items === void 0 ? void 0 : items.filter(Boolean)) || []); };
|
|
140
|
-
var compactMap = function (items, f) {
|
|
137
|
+
var compactMap = function (items, f) {
|
|
138
|
+
return compact(items === null || items === void 0 ? void 0 : items.map(f));
|
|
139
|
+
};
|
|
141
140
|
var isNil = function (value) {
|
|
142
141
|
return value === null || value === undefined;
|
|
143
142
|
};
|
|
@@ -509,9 +508,7 @@ function getDisplayConditionFormula(displayCondition) {
|
|
|
509
508
|
}
|
|
510
509
|
}
|
|
511
510
|
var replaceDisplayCondition = function (dimension, displayCondition) {
|
|
512
|
-
return isNil(displayCondition)
|
|
513
|
-
? dimension
|
|
514
|
-
: __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
511
|
+
return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
515
512
|
};
|
|
516
513
|
|
|
517
514
|
var escapeSpecialCharacters = function (formula) {
|
|
@@ -756,9 +753,7 @@ function mapMeasureToInput(measure, variables, addFormulas) {
|
|
|
756
753
|
}
|
|
757
754
|
/** Конвертировать меры виджета во входы для вычислителя */
|
|
758
755
|
function mapMeasuresToInputs(measures, variables, addFormulas) {
|
|
759
|
-
return compactMap(measures, function (measure) {
|
|
760
|
-
return mapMeasureToInput(measure, variables, addFormulas);
|
|
761
|
-
});
|
|
756
|
+
return compactMap(measures, function (measure) { return mapMeasureToInput(measure, variables, addFormulas); });
|
|
762
757
|
}
|
|
763
758
|
|
|
764
759
|
function mapDimensionToInput(dimension, variables) {
|
|
@@ -779,9 +774,7 @@ function mapDimensionToInput(dimension, variables) {
|
|
|
779
774
|
}
|
|
780
775
|
/** Конвертировать разрезы виджета во входы для вычислителя */
|
|
781
776
|
function mapDimensionsToInputs(dimensions, variables) {
|
|
782
|
-
return compactMap(dimensions, function (dimension) {
|
|
783
|
-
return mapDimensionToInput(dimension, variables);
|
|
784
|
-
});
|
|
777
|
+
return compactMap(dimensions, function (dimension) { return mapDimensionToInput(dimension, variables); });
|
|
785
778
|
}
|
|
786
779
|
|
|
787
780
|
function mapTransitionMeasureToInput(indicator, process, variables, addFormulas) {
|
|
@@ -839,11 +832,12 @@ function mapEventMeasuresToInputs(indicators, process, variables, addFormulas) {
|
|
|
839
832
|
* @param measuresInOriginalOrder меры виджета (конкретная мера будет браться по индексу)
|
|
840
833
|
* @returns
|
|
841
834
|
*/
|
|
842
|
-
function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder) {
|
|
835
|
+
function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder, variables) {
|
|
843
836
|
if (sortingIndicators === void 0) { sortingIndicators = []; }
|
|
844
837
|
if (dimensionsInOriginalOrder === void 0) { dimensionsInOriginalOrder = []; }
|
|
845
838
|
if (measuresInOriginalOrder === void 0) { measuresInOriginalOrder = []; }
|
|
846
839
|
return compactMap(sortingIndicators, function (_a) {
|
|
840
|
+
var _b;
|
|
847
841
|
var value = _a.value, direction = _a.direction;
|
|
848
842
|
if (value.mode === exports.ESortingValueModes.FORMULA ||
|
|
849
843
|
value.mode === exports.ESortingValueModes.QUANTITY ||
|
|
@@ -854,7 +848,20 @@ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measur
|
|
|
854
848
|
if (value.mode === exports.ESortingValueModes.DIMENSION_IN_WIDGET ||
|
|
855
849
|
value.mode === exports.ESortingValueModes.HIERARCHY) {
|
|
856
850
|
var dimension = dimensionsInOriginalOrder[value.index];
|
|
857
|
-
|
|
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
|
+
};
|
|
858
865
|
}
|
|
859
866
|
if (value.mode === exports.ESortingValueModes.MEASURE_IN_WIDGET) {
|
|
860
867
|
var measure = measuresInOriginalOrder[value.index];
|
|
@@ -882,9 +889,7 @@ function selectDimensionFromHierarchy(_a, filters) {
|
|
|
882
889
|
if (!matchedFilter) {
|
|
883
890
|
return "continue";
|
|
884
891
|
}
|
|
885
|
-
var selectionIndex = matchedFilter.values.length > 1
|
|
886
|
-
? i
|
|
887
|
-
: Math.min(i + 1, dimensions.length - 1);
|
|
892
|
+
var selectionIndex = matchedFilter.values.length > 1 ? i : Math.min(i + 1, dimensions.length - 1);
|
|
888
893
|
return { value: dimensions[selectionIndex] };
|
|
889
894
|
};
|
|
890
895
|
for (var i = dimensions.length - 1; i >= 0; i--) {
|
|
@@ -899,8 +904,7 @@ var replaceHierarchiesWithDimensions = function (dimensions, filters) {
|
|
|
899
904
|
return compactMap(dimensions, function (indicator) {
|
|
900
905
|
if (isHierarchy(indicator)) {
|
|
901
906
|
var selectedDimension = selectDimensionFromHierarchy(indicator, filters);
|
|
902
|
-
return (selectedDimension &&
|
|
903
|
-
replaceDisplayCondition(selectedDimension, indicator.displayCondition));
|
|
907
|
+
return (selectedDimension && replaceDisplayCondition(selectedDimension, indicator.displayCondition));
|
|
904
908
|
}
|
|
905
909
|
return indicator;
|
|
906
910
|
});
|
|
@@ -917,9 +921,7 @@ function bindContentWithIndicator(outputs, indicator) {
|
|
|
917
921
|
* Массив объектов, каждый из которых содержит показатель и его контент
|
|
918
922
|
*/
|
|
919
923
|
function bindContentsWithIndicators(outputs, indicators) {
|
|
920
|
-
return compactMap(indicators, function (indicator) {
|
|
921
|
-
return bindContentWithIndicator(outputs, indicator);
|
|
922
|
-
});
|
|
924
|
+
return compactMap(indicators, function (indicator) { return bindContentWithIndicator(outputs, indicator); });
|
|
923
925
|
}
|
|
924
926
|
|
|
925
927
|
exports.EControlType = void 0;
|
|
@@ -1047,11 +1049,11 @@ var getLocalizedText = function (language, locObj, props) {
|
|
|
1047
1049
|
return localization.getLocalized(locObj, props);
|
|
1048
1050
|
};
|
|
1049
1051
|
|
|
1050
|
-
Object.defineProperty(exports,
|
|
1052
|
+
Object.defineProperty(exports, "ELanguages", {
|
|
1051
1053
|
enumerable: true,
|
|
1052
1054
|
get: function () { return localization$1.ELanguages; }
|
|
1053
1055
|
});
|
|
1054
|
-
Object.defineProperty(exports,
|
|
1056
|
+
Object.defineProperty(exports, "EFilteringMethodValues", {
|
|
1055
1057
|
enumerable: true,
|
|
1056
1058
|
get: function () { return baseFilter.EFilteringMethodValues; }
|
|
1057
1059
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infomaximum/widget-sdk",
|
|
3
|
-
"version": "3.26.0
|
|
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.
|
|
27
|
-
"rollup": "4.
|
|
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.
|
|
34
|
+
"typescript": "5.4.5"
|
|
33
35
|
},
|
|
34
36
|
"repository": {
|
|
35
37
|
"type": "git",
|