@infomaximum/widget-sdk 4.0.0-beta10 → 4.0.0-beta11
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 +61 -15
- package/dist/index.esm.js +41 -27
- package/dist/index.js +42 -28
- package/package.json +9 -7
package/dist/index.d.ts
CHANGED
|
@@ -732,6 +732,62 @@ declare enum EWidgetActionInputMode {
|
|
|
732
732
|
FORMULA = "FORMULA",
|
|
733
733
|
MANUALLY = "MANUALLY"
|
|
734
734
|
}
|
|
735
|
+
interface IActionCommon {
|
|
736
|
+
id: number;
|
|
737
|
+
name: string;
|
|
738
|
+
}
|
|
739
|
+
declare enum EActionTypes {
|
|
740
|
+
URL = "URL",
|
|
741
|
+
UPDATE_VARIABLE = "UPDATE_VARIABLE",
|
|
742
|
+
RUN_SCRIPT = "RUN_SCRIPT",
|
|
743
|
+
OPEN_VIEW = "OPEN_VIEW"
|
|
744
|
+
}
|
|
745
|
+
interface IActionGoToUrl extends IActionCommon {
|
|
746
|
+
type: EActionTypes.URL;
|
|
747
|
+
url: string;
|
|
748
|
+
targetBlank: boolean;
|
|
749
|
+
}
|
|
750
|
+
interface IActionScriptField {
|
|
751
|
+
name: string;
|
|
752
|
+
id: number;
|
|
753
|
+
value: TWidgetActionInputValue;
|
|
754
|
+
}
|
|
755
|
+
interface IActionRunScript extends IActionCommon {
|
|
756
|
+
description: string;
|
|
757
|
+
type: EActionTypes.RUN_SCRIPT;
|
|
758
|
+
filters: (IFormulaFilterValue | string)[];
|
|
759
|
+
inputs: IActionScriptField[];
|
|
760
|
+
scriptName: string;
|
|
761
|
+
shouldRefreshWidgetsAfterExecution: boolean;
|
|
762
|
+
}
|
|
763
|
+
interface IActionUpdateVariable extends IActionCommon {
|
|
764
|
+
type: EActionTypes.UPDATE_VARIABLE;
|
|
765
|
+
variables: Array<string>;
|
|
766
|
+
}
|
|
767
|
+
declare enum EViewType {
|
|
768
|
+
CREATED_VIEW = "CREATED_VIEW",
|
|
769
|
+
GENERATED_BY_SCRIPT = "GENERATED_BY_SCRIPT"
|
|
770
|
+
}
|
|
771
|
+
declare enum EOpenViewMode {
|
|
772
|
+
NEW_WINDOW = "NEW_WINDOW",
|
|
773
|
+
PLACEHOLDER = "PLACEHOLDER",
|
|
774
|
+
MODAL = "MODAL",
|
|
775
|
+
DRAWER = "DRAWER"
|
|
776
|
+
}
|
|
777
|
+
declare enum EDrawerPlacement {
|
|
778
|
+
LEFT = "LEFT",
|
|
779
|
+
RIGHT = "RIGHT"
|
|
780
|
+
}
|
|
781
|
+
interface IActionOpenView extends IActionCommon {
|
|
782
|
+
type: EActionTypes.OPEN_VIEW;
|
|
783
|
+
viewName: string;
|
|
784
|
+
viewKey: string;
|
|
785
|
+
openMode: EOpenViewMode;
|
|
786
|
+
viewType: EViewType;
|
|
787
|
+
drawerPlacement: EDrawerPlacement;
|
|
788
|
+
placeholderName: string;
|
|
789
|
+
}
|
|
790
|
+
type TActionsOnClick = IActionGoToUrl | IActionRunScript | IActionUpdateVariable | IActionOpenView;
|
|
735
791
|
type TWidgetActionInputValue = {
|
|
736
792
|
mode: EWidgetActionInputMode.FROM_COLUMN;
|
|
737
793
|
tableName: string;
|
|
@@ -758,17 +814,7 @@ interface IWidgetActionInput {
|
|
|
758
814
|
name: string;
|
|
759
815
|
value: TWidgetActionInputValue;
|
|
760
816
|
}
|
|
761
|
-
|
|
762
|
-
id: number;
|
|
763
|
-
name: string;
|
|
764
|
-
description: string;
|
|
765
|
-
filters: (IFormulaFilterValue | string)[];
|
|
766
|
-
/** Поле name необходимо, чтобы показать название скрипта, который был удален */
|
|
767
|
-
scriptName?: string;
|
|
768
|
-
inputs: IWidgetActionInput[];
|
|
769
|
-
shouldRefreshWidgetsAfterExecution: boolean;
|
|
770
|
-
}
|
|
771
|
-
declare const isActionValid: (action: IWidgetAction, { scripts, tables, variables }: IWidgetsContext) => boolean;
|
|
817
|
+
declare const isActionValid: (action: TActionsOnClick, { scripts, tables, variables }: IWidgetsContext) => boolean;
|
|
772
818
|
|
|
773
819
|
interface IBaseWidgetSettings {
|
|
774
820
|
apiVersion: string;
|
|
@@ -780,7 +826,7 @@ interface IBaseWidgetSettings {
|
|
|
780
826
|
filterMode?: EWidgetFilterMode;
|
|
781
827
|
ignoreFilters?: boolean;
|
|
782
828
|
sorting?: IWidgetSortingIndicator[];
|
|
783
|
-
actions?:
|
|
829
|
+
actions?: TActionsOnClick[];
|
|
784
830
|
displayCondition?: TDisplayCondition;
|
|
785
831
|
displayConditionComment?: string;
|
|
786
832
|
}
|
|
@@ -1172,7 +1218,7 @@ interface IDefinition<WidgetSettings extends IBaseWidgetSettings, GroupSettings
|
|
|
1172
1218
|
}
|
|
1173
1219
|
|
|
1174
1220
|
type TLaunchActionParams = {
|
|
1175
|
-
action:
|
|
1221
|
+
action: TActionsOnClick;
|
|
1176
1222
|
onSuccess: () => void;
|
|
1177
1223
|
filters: ICalculatorFilter[];
|
|
1178
1224
|
needConfirmation?: boolean;
|
|
@@ -1362,7 +1408,7 @@ declare const replaceFiltersBySelection: (filters: ICalculatorFilter[], selectio
|
|
|
1362
1408
|
* @param {P} [props] - Дополнительные параметры локализации.
|
|
1363
1409
|
* @returns {string} - Локализованный текст для указанного языка.
|
|
1364
1410
|
*/
|
|
1365
|
-
declare const getLocalizedText: <L extends TLocalizationDescription, P extends ILocalizationProps = TExtractLocalizationParams<L>>(language: ELanguages, locObj: L, props?: P
|
|
1411
|
+
declare const getLocalizedText: <L extends TLocalizationDescription, P extends ILocalizationProps = TExtractLocalizationParams<L>>(language: ELanguages, locObj: L, props?: P) => string;
|
|
1366
1412
|
|
|
1367
1413
|
type TDefineWidgetOptions = {
|
|
1368
1414
|
manifest?: Record<string, unknown>;
|
|
@@ -1378,4 +1424,4 @@ declare global {
|
|
|
1378
1424
|
}
|
|
1379
1425
|
}
|
|
1380
1426
|
|
|
1381
|
-
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
|
|
1427
|
+
export { EActionTypes, ECalculatorFilterMethods, EColorMode, EControlType, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationUnit, EEventMeasureTemplateNames, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMeasureTemplateNames, EOpenViewMode, EProcessFilterNames, ESimpleDataType, ESortDirection, ESortingValueModes, ETransitionMeasureTemplateNames, EViewType, EWidgetActionInputMode, EWidgetFilterMode, EWidgetIndicatorType, EWidgetIndicatorValueModes, type IActionCommon, type IActionGoToUrl, type IActionOpenView, type IActionRunScript, type IActionScript, type IActionScriptField, type IActionUpdateVariable, 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 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 TActionsOnClick, 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 TWidgetContainer, 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
|
@@ -71,9 +71,36 @@ 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
100
|
var scripts = _a.scripts, tables = _a.tables, variables = _a.variables;
|
|
101
|
+
if (action.type !== EActionTypes.RUN_SCRIPT) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
77
104
|
var currentScript = scripts.get((_b = action.scriptName) !== null && _b !== void 0 ? _b : "");
|
|
78
105
|
if (!currentScript) {
|
|
79
106
|
return false;
|
|
@@ -88,8 +115,7 @@ var isActionValid = function (action, _a) {
|
|
|
88
115
|
return false;
|
|
89
116
|
}
|
|
90
117
|
var value = actionInput.value;
|
|
91
|
-
if (value.mode === EWidgetActionInputMode.FROM_VARIABLE &&
|
|
92
|
-
!variables.has(value.name)) {
|
|
118
|
+
if (value.mode === EWidgetActionInputMode.FROM_VARIABLE && !variables.has(value.name)) {
|
|
93
119
|
return false;
|
|
94
120
|
}
|
|
95
121
|
if (value.mode === EWidgetActionInputMode.FORMULA && !value.formula) {
|
|
@@ -98,8 +124,7 @@ var isActionValid = function (action, _a) {
|
|
|
98
124
|
if (value.mode === EWidgetActionInputMode.DYNAMIC_LIST && !value.formula) {
|
|
99
125
|
return false;
|
|
100
126
|
}
|
|
101
|
-
if (value.mode === EWidgetActionInputMode.FROM_COLUMN &&
|
|
102
|
-
!tables.has(value.tableName)) {
|
|
127
|
+
if (value.mode === EWidgetActionInputMode.FROM_COLUMN && !tables.has(value.tableName)) {
|
|
103
128
|
return false;
|
|
104
129
|
}
|
|
105
130
|
return true;
|
|
@@ -124,9 +149,7 @@ var prepareValuesForSql = function (dataType, values) {
|
|
|
124
149
|
dataType === ESimpleDataType.BOOLEAN
|
|
125
150
|
? values
|
|
126
151
|
: values.map(function (value) {
|
|
127
|
-
return value === null
|
|
128
|
-
? null
|
|
129
|
-
: "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
|
|
152
|
+
return value === null ? null : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
|
|
130
153
|
});
|
|
131
154
|
};
|
|
132
155
|
var escapeReverseSlash = function (formula) {
|
|
@@ -137,7 +160,9 @@ var escapeSingularQuotes = function (formula) {
|
|
|
137
160
|
};
|
|
138
161
|
|
|
139
162
|
var compact = function (items) { return ((items === null || items === void 0 ? void 0 : items.filter(Boolean)) || []); };
|
|
140
|
-
var compactMap = function (items, f) {
|
|
163
|
+
var compactMap = function (items, f) {
|
|
164
|
+
return compact(items === null || items === void 0 ? void 0 : items.map(f));
|
|
165
|
+
};
|
|
141
166
|
var isNil = function (value) {
|
|
142
167
|
return value === null || value === undefined;
|
|
143
168
|
};
|
|
@@ -509,9 +534,7 @@ function getDisplayConditionFormula(displayCondition) {
|
|
|
509
534
|
}
|
|
510
535
|
}
|
|
511
536
|
var replaceDisplayCondition = function (dimension, displayCondition) {
|
|
512
|
-
return isNil(displayCondition)
|
|
513
|
-
? dimension
|
|
514
|
-
: __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
537
|
+
return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
515
538
|
};
|
|
516
539
|
|
|
517
540
|
var escapeSpecialCharacters = function (formula) {
|
|
@@ -756,9 +779,7 @@ function mapMeasureToInput(measure, variables, addFormulas) {
|
|
|
756
779
|
}
|
|
757
780
|
/** Конвертировать меры виджета во входы для вычислителя */
|
|
758
781
|
function mapMeasuresToInputs(measures, variables, addFormulas) {
|
|
759
|
-
return compactMap(measures, function (measure) {
|
|
760
|
-
return mapMeasureToInput(measure, variables, addFormulas);
|
|
761
|
-
});
|
|
782
|
+
return compactMap(measures, function (measure) { return mapMeasureToInput(measure, variables, addFormulas); });
|
|
762
783
|
}
|
|
763
784
|
|
|
764
785
|
function mapDimensionToInput(dimension, variables) {
|
|
@@ -779,9 +800,7 @@ function mapDimensionToInput(dimension, variables) {
|
|
|
779
800
|
}
|
|
780
801
|
/** Конвертировать разрезы виджета во входы для вычислителя */
|
|
781
802
|
function mapDimensionsToInputs(dimensions, variables) {
|
|
782
|
-
return compactMap(dimensions, function (dimension) {
|
|
783
|
-
return mapDimensionToInput(dimension, variables);
|
|
784
|
-
});
|
|
803
|
+
return compactMap(dimensions, function (dimension) { return mapDimensionToInput(dimension, variables); });
|
|
785
804
|
}
|
|
786
805
|
|
|
787
806
|
function mapTransitionMeasureToInput(indicator, process, variables, addFormulas) {
|
|
@@ -854,7 +873,7 @@ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measur
|
|
|
854
873
|
if (value.mode === ESortingValueModes.DIMENSION_IN_WIDGET ||
|
|
855
874
|
value.mode === ESortingValueModes.HIERARCHY) {
|
|
856
875
|
var dimension = dimensionsInOriginalOrder[value.index];
|
|
857
|
-
return
|
|
876
|
+
return dimension && { formula: getDimensionFormula(dimension), direction: direction };
|
|
858
877
|
}
|
|
859
878
|
if (value.mode === ESortingValueModes.MEASURE_IN_WIDGET) {
|
|
860
879
|
var measure = measuresInOriginalOrder[value.index];
|
|
@@ -882,9 +901,7 @@ function selectDimensionFromHierarchy(_a, filters) {
|
|
|
882
901
|
if (!matchedFilter) {
|
|
883
902
|
return "continue";
|
|
884
903
|
}
|
|
885
|
-
var selectionIndex = matchedFilter.values.length > 1
|
|
886
|
-
? i
|
|
887
|
-
: Math.min(i + 1, dimensions.length - 1);
|
|
904
|
+
var selectionIndex = matchedFilter.values.length > 1 ? i : Math.min(i + 1, dimensions.length - 1);
|
|
888
905
|
return { value: dimensions[selectionIndex] };
|
|
889
906
|
};
|
|
890
907
|
for (var i = dimensions.length - 1; i >= 0; i--) {
|
|
@@ -899,8 +916,7 @@ var replaceHierarchiesWithDimensions = function (dimensions, filters) {
|
|
|
899
916
|
return compactMap(dimensions, function (indicator) {
|
|
900
917
|
if (isHierarchy(indicator)) {
|
|
901
918
|
var selectedDimension = selectDimensionFromHierarchy(indicator, filters);
|
|
902
|
-
return (selectedDimension &&
|
|
903
|
-
replaceDisplayCondition(selectedDimension, indicator.displayCondition));
|
|
919
|
+
return (selectedDimension && replaceDisplayCondition(selectedDimension, indicator.displayCondition));
|
|
904
920
|
}
|
|
905
921
|
return indicator;
|
|
906
922
|
});
|
|
@@ -917,9 +933,7 @@ function bindContentWithIndicator(outputs, indicator) {
|
|
|
917
933
|
* Массив объектов, каждый из которых содержит показатель и его контент
|
|
918
934
|
*/
|
|
919
935
|
function bindContentsWithIndicators(outputs, indicators) {
|
|
920
|
-
return compactMap(indicators, function (indicator) {
|
|
921
|
-
return bindContentWithIndicator(outputs, indicator);
|
|
922
|
-
});
|
|
936
|
+
return compactMap(indicators, function (indicator) { return bindContentWithIndicator(outputs, indicator); });
|
|
923
937
|
}
|
|
924
938
|
|
|
925
939
|
var EControlType;
|
|
@@ -1047,4 +1061,4 @@ var getLocalizedText = function (language, locObj, props) {
|
|
|
1047
1061
|
return localization.getLocalized(locObj, props);
|
|
1048
1062
|
};
|
|
1049
1063
|
|
|
1050
|
-
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 };
|
|
1064
|
+
export { EActionTypes, ECalculatorFilterMethods, EColorMode, EControlType, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationUnit, EEventMeasureTemplateNames, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMeasureTemplateNames, EOpenViewMode, EProcessFilterNames, 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, mapVariablesToInputs, measureTemplateFormulas, prepareValuesForSql, replaceDisplayCondition, replaceFiltersBySelection, replaceHierarchiesWithDimensions, selectDimensionFromHierarchy, transitionMeasureTemplateFormulas, updateDefaultModeSelection, updateMultiModeSelection, updateSingleModeSelection };
|
package/dist/index.js
CHANGED
|
@@ -72,9 +72,36 @@ 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
101
|
var scripts = _a.scripts, tables = _a.tables, variables = _a.variables;
|
|
102
|
+
if (action.type !== exports.EActionTypes.RUN_SCRIPT) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
78
105
|
var currentScript = scripts.get((_b = action.scriptName) !== null && _b !== void 0 ? _b : "");
|
|
79
106
|
if (!currentScript) {
|
|
80
107
|
return false;
|
|
@@ -89,8 +116,7 @@ var isActionValid = function (action, _a) {
|
|
|
89
116
|
return false;
|
|
90
117
|
}
|
|
91
118
|
var value = actionInput.value;
|
|
92
|
-
if (value.mode === exports.EWidgetActionInputMode.FROM_VARIABLE &&
|
|
93
|
-
!variables.has(value.name)) {
|
|
119
|
+
if (value.mode === exports.EWidgetActionInputMode.FROM_VARIABLE && !variables.has(value.name)) {
|
|
94
120
|
return false;
|
|
95
121
|
}
|
|
96
122
|
if (value.mode === exports.EWidgetActionInputMode.FORMULA && !value.formula) {
|
|
@@ -99,8 +125,7 @@ var isActionValid = function (action, _a) {
|
|
|
99
125
|
if (value.mode === exports.EWidgetActionInputMode.DYNAMIC_LIST && !value.formula) {
|
|
100
126
|
return false;
|
|
101
127
|
}
|
|
102
|
-
if (value.mode === exports.EWidgetActionInputMode.FROM_COLUMN &&
|
|
103
|
-
!tables.has(value.tableName)) {
|
|
128
|
+
if (value.mode === exports.EWidgetActionInputMode.FROM_COLUMN && !tables.has(value.tableName)) {
|
|
104
129
|
return false;
|
|
105
130
|
}
|
|
106
131
|
return true;
|
|
@@ -125,9 +150,7 @@ var prepareValuesForSql = function (dataType, values) {
|
|
|
125
150
|
dataType === exports.ESimpleDataType.BOOLEAN
|
|
126
151
|
? values
|
|
127
152
|
: values.map(function (value) {
|
|
128
|
-
return value === null
|
|
129
|
-
? null
|
|
130
|
-
: "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
|
|
153
|
+
return value === null ? null : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
|
|
131
154
|
});
|
|
132
155
|
};
|
|
133
156
|
var escapeReverseSlash = function (formula) {
|
|
@@ -138,7 +161,9 @@ var escapeSingularQuotes = function (formula) {
|
|
|
138
161
|
};
|
|
139
162
|
|
|
140
163
|
var compact = function (items) { return ((items === null || items === void 0 ? void 0 : items.filter(Boolean)) || []); };
|
|
141
|
-
var compactMap = function (items, f) {
|
|
164
|
+
var compactMap = function (items, f) {
|
|
165
|
+
return compact(items === null || items === void 0 ? void 0 : items.map(f));
|
|
166
|
+
};
|
|
142
167
|
var isNil = function (value) {
|
|
143
168
|
return value === null || value === undefined;
|
|
144
169
|
};
|
|
@@ -510,9 +535,7 @@ function getDisplayConditionFormula(displayCondition) {
|
|
|
510
535
|
}
|
|
511
536
|
}
|
|
512
537
|
var replaceDisplayCondition = function (dimension, displayCondition) {
|
|
513
|
-
return isNil(displayCondition)
|
|
514
|
-
? dimension
|
|
515
|
-
: __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
538
|
+
return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
516
539
|
};
|
|
517
540
|
|
|
518
541
|
var escapeSpecialCharacters = function (formula) {
|
|
@@ -757,9 +780,7 @@ function mapMeasureToInput(measure, variables, addFormulas) {
|
|
|
757
780
|
}
|
|
758
781
|
/** Конвертировать меры виджета во входы для вычислителя */
|
|
759
782
|
function mapMeasuresToInputs(measures, variables, addFormulas) {
|
|
760
|
-
return compactMap(measures, function (measure) {
|
|
761
|
-
return mapMeasureToInput(measure, variables, addFormulas);
|
|
762
|
-
});
|
|
783
|
+
return compactMap(measures, function (measure) { return mapMeasureToInput(measure, variables, addFormulas); });
|
|
763
784
|
}
|
|
764
785
|
|
|
765
786
|
function mapDimensionToInput(dimension, variables) {
|
|
@@ -780,9 +801,7 @@ function mapDimensionToInput(dimension, variables) {
|
|
|
780
801
|
}
|
|
781
802
|
/** Конвертировать разрезы виджета во входы для вычислителя */
|
|
782
803
|
function mapDimensionsToInputs(dimensions, variables) {
|
|
783
|
-
return compactMap(dimensions, function (dimension) {
|
|
784
|
-
return mapDimensionToInput(dimension, variables);
|
|
785
|
-
});
|
|
804
|
+
return compactMap(dimensions, function (dimension) { return mapDimensionToInput(dimension, variables); });
|
|
786
805
|
}
|
|
787
806
|
|
|
788
807
|
function mapTransitionMeasureToInput(indicator, process, variables, addFormulas) {
|
|
@@ -855,7 +874,7 @@ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measur
|
|
|
855
874
|
if (value.mode === exports.ESortingValueModes.DIMENSION_IN_WIDGET ||
|
|
856
875
|
value.mode === exports.ESortingValueModes.HIERARCHY) {
|
|
857
876
|
var dimension = dimensionsInOriginalOrder[value.index];
|
|
858
|
-
return
|
|
877
|
+
return dimension && { formula: getDimensionFormula(dimension), direction: direction };
|
|
859
878
|
}
|
|
860
879
|
if (value.mode === exports.ESortingValueModes.MEASURE_IN_WIDGET) {
|
|
861
880
|
var measure = measuresInOriginalOrder[value.index];
|
|
@@ -883,9 +902,7 @@ function selectDimensionFromHierarchy(_a, filters) {
|
|
|
883
902
|
if (!matchedFilter) {
|
|
884
903
|
return "continue";
|
|
885
904
|
}
|
|
886
|
-
var selectionIndex = matchedFilter.values.length > 1
|
|
887
|
-
? i
|
|
888
|
-
: Math.min(i + 1, dimensions.length - 1);
|
|
905
|
+
var selectionIndex = matchedFilter.values.length > 1 ? i : Math.min(i + 1, dimensions.length - 1);
|
|
889
906
|
return { value: dimensions[selectionIndex] };
|
|
890
907
|
};
|
|
891
908
|
for (var i = dimensions.length - 1; i >= 0; i--) {
|
|
@@ -900,8 +917,7 @@ var replaceHierarchiesWithDimensions = function (dimensions, filters) {
|
|
|
900
917
|
return compactMap(dimensions, function (indicator) {
|
|
901
918
|
if (isHierarchy(indicator)) {
|
|
902
919
|
var selectedDimension = selectDimensionFromHierarchy(indicator, filters);
|
|
903
|
-
return (selectedDimension &&
|
|
904
|
-
replaceDisplayCondition(selectedDimension, indicator.displayCondition));
|
|
920
|
+
return (selectedDimension && replaceDisplayCondition(selectedDimension, indicator.displayCondition));
|
|
905
921
|
}
|
|
906
922
|
return indicator;
|
|
907
923
|
});
|
|
@@ -918,9 +934,7 @@ function bindContentWithIndicator(outputs, indicator) {
|
|
|
918
934
|
* Массив объектов, каждый из которых содержит показатель и его контент
|
|
919
935
|
*/
|
|
920
936
|
function bindContentsWithIndicators(outputs, indicators) {
|
|
921
|
-
return compactMap(indicators, function (indicator) {
|
|
922
|
-
return bindContentWithIndicator(outputs, indicator);
|
|
923
|
-
});
|
|
937
|
+
return compactMap(indicators, function (indicator) { return bindContentWithIndicator(outputs, indicator); });
|
|
924
938
|
}
|
|
925
939
|
|
|
926
940
|
exports.EControlType = void 0;
|
|
@@ -1048,11 +1062,11 @@ var getLocalizedText = function (language, locObj, props) {
|
|
|
1048
1062
|
return localization.getLocalized(locObj, props);
|
|
1049
1063
|
};
|
|
1050
1064
|
|
|
1051
|
-
Object.defineProperty(exports,
|
|
1065
|
+
Object.defineProperty(exports, "ELanguages", {
|
|
1052
1066
|
enumerable: true,
|
|
1053
1067
|
get: function () { return localization$1.ELanguages; }
|
|
1054
1068
|
});
|
|
1055
|
-
Object.defineProperty(exports,
|
|
1069
|
+
Object.defineProperty(exports, "EFilteringMethodValues", {
|
|
1056
1070
|
enumerable: true,
|
|
1057
1071
|
get: function () { return baseFilter.EFilteringMethodValues; }
|
|
1058
1072
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infomaximum/widget-sdk",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta11",
|
|
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",
|