@infomaximum/widget-sdk 4.0.0-beta10 → 4.0.0-beta12
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 +126 -23
- package/dist/index.esm.js +74 -28
- package/dist/index.js +75 -29
- package/package.json +9 -7
package/dist/index.d.ts
CHANGED
|
@@ -79,6 +79,9 @@ interface ICalculatorIndicatorOutput {
|
|
|
79
79
|
interface ICalculatorDimensionInput extends ICalculatorIndicatorInput {
|
|
80
80
|
formula: string;
|
|
81
81
|
hideEmpty?: boolean;
|
|
82
|
+
/** Временно поддерживается обратная совместимость с форматом { alias: string; formula: string }[] */
|
|
83
|
+
/** Появилась необходимость в ленточном графике, т.к. разрез длительность используется, как мера */
|
|
84
|
+
additionalFormulas?: Map<string, string>;
|
|
82
85
|
}
|
|
83
86
|
interface ICalculatorDimensionOutput extends ICalculatorIndicatorOutput {
|
|
84
87
|
}
|
|
@@ -418,25 +421,62 @@ type TWidgetFiltering = {
|
|
|
418
421
|
mode: EWidgetFilterMode;
|
|
419
422
|
};
|
|
420
423
|
declare enum EColorMode {
|
|
424
|
+
DISABLED = "DISABLED",
|
|
421
425
|
FORMULA = "FORMULA",
|
|
422
426
|
BASE = "BASE",
|
|
423
427
|
GRADIENT = "GRADIENT",
|
|
424
|
-
AUTO = "AUTO"
|
|
428
|
+
AUTO = "AUTO",
|
|
429
|
+
RULE = "RULE",
|
|
430
|
+
VALUES = "VALUES",
|
|
431
|
+
BY_DIMENSION = "BY_DIMENSION"
|
|
425
432
|
}
|
|
426
|
-
|
|
427
|
-
type TColor = {
|
|
428
|
-
mode: EColorMode.FORMULA;
|
|
429
|
-
formula: string;
|
|
430
|
-
} | {
|
|
433
|
+
type TColorBase = {
|
|
431
434
|
mode: EColorMode.BASE;
|
|
432
435
|
value?: string;
|
|
433
436
|
defaultColor?: string;
|
|
437
|
+
};
|
|
438
|
+
declare enum EColorScope {
|
|
439
|
+
WORKSPACE = "WORKSPACE",
|
|
440
|
+
DASHBOARD = "DASHBOARD"
|
|
441
|
+
}
|
|
442
|
+
type TColorRuleCommon = {
|
|
443
|
+
mode: EColorMode.RULE;
|
|
444
|
+
ruleName: string;
|
|
445
|
+
};
|
|
446
|
+
type TColorRule = ({
|
|
447
|
+
scope: EColorScope.DASHBOARD | null;
|
|
434
448
|
} | {
|
|
449
|
+
scope: EColorScope.WORKSPACE;
|
|
450
|
+
workspaceGroupId: number | null;
|
|
451
|
+
}) & TColorRuleCommon;
|
|
452
|
+
interface IColoredValue {
|
|
453
|
+
value: string;
|
|
454
|
+
color: TColorBase | TColorRule;
|
|
455
|
+
}
|
|
456
|
+
declare enum EMarkdownDisplayMode {
|
|
457
|
+
NONE = "NONE",
|
|
458
|
+
INDICATOR = "INDICATOR"
|
|
459
|
+
}
|
|
460
|
+
/** Настройка цвета */
|
|
461
|
+
type TColor = {
|
|
462
|
+
mode: EColorMode.FORMULA;
|
|
463
|
+
formula: string;
|
|
464
|
+
} | TColorBase | {
|
|
435
465
|
mode: EColorMode.GRADIENT;
|
|
436
466
|
startValue: string;
|
|
437
467
|
endValue: string;
|
|
438
468
|
} | {
|
|
439
469
|
mode: EColorMode.AUTO;
|
|
470
|
+
} | TColorRule | {
|
|
471
|
+
mode: EColorMode.VALUES;
|
|
472
|
+
dimensionFormula: string;
|
|
473
|
+
items: IColoredValue[];
|
|
474
|
+
} | {
|
|
475
|
+
mode: EColorMode.BY_DIMENSION;
|
|
476
|
+
dimensionName: string;
|
|
477
|
+
items: IColoredValue[];
|
|
478
|
+
} | {
|
|
479
|
+
mode: EColorMode.DISABLED;
|
|
440
480
|
};
|
|
441
481
|
declare enum EDisplayConditionMode {
|
|
442
482
|
DISABLED = "DISABLED",
|
|
@@ -470,6 +510,7 @@ type TSortDirection = ESortDirection.ascend | ESortDirection.descend;
|
|
|
470
510
|
interface ISortOrder {
|
|
471
511
|
formula: string;
|
|
472
512
|
direction: TSortDirection;
|
|
513
|
+
displayCondition?: TNullable<string>;
|
|
473
514
|
}
|
|
474
515
|
type TWidgetSortingValueRelatedWidgetMeasure = {
|
|
475
516
|
mode: ESortingValueModes.MEASURE_IN_WIDGET;
|
|
@@ -613,6 +654,10 @@ interface IWidgetDimension extends IWidgetColumnIndicator {
|
|
|
613
654
|
interface IWidgetMeasure extends IWidgetColumnIndicator {
|
|
614
655
|
type: EWidgetIndicatorType.MEASURE;
|
|
615
656
|
}
|
|
657
|
+
interface IMarkdownMeasure extends IWidgetMeasure {
|
|
658
|
+
format: EFormatTypes;
|
|
659
|
+
displayMode: EMarkdownDisplayMode;
|
|
660
|
+
}
|
|
616
661
|
/** Тип показателя */
|
|
617
662
|
declare enum EIndicatorType {
|
|
618
663
|
/** Показатели процесса */
|
|
@@ -700,6 +745,9 @@ interface IWidgetTable {
|
|
|
700
745
|
* full - полный
|
|
701
746
|
*/
|
|
702
747
|
type TDisplayMode = "preview" | "full";
|
|
748
|
+
interface IDisplayRule {
|
|
749
|
+
color: TColor;
|
|
750
|
+
}
|
|
703
751
|
interface IWidgetsContext {
|
|
704
752
|
/** используемый язык в системе */
|
|
705
753
|
language: ELanguages;
|
|
@@ -722,6 +770,8 @@ interface IWidgetsContext {
|
|
|
722
770
|
userLogin: string;
|
|
723
771
|
scripts: Map<string, IActionScript>;
|
|
724
772
|
tables: Set<string>;
|
|
773
|
+
reportDisplayRules: Map<string, IDisplayRule>;
|
|
774
|
+
workspaceDisplayRules: Map<number, Map<string, IDisplayRule>>;
|
|
725
775
|
}
|
|
726
776
|
|
|
727
777
|
declare enum EWidgetActionInputMode {
|
|
@@ -732,6 +782,62 @@ declare enum EWidgetActionInputMode {
|
|
|
732
782
|
FORMULA = "FORMULA",
|
|
733
783
|
MANUALLY = "MANUALLY"
|
|
734
784
|
}
|
|
785
|
+
interface IActionCommon {
|
|
786
|
+
id: number;
|
|
787
|
+
name: string;
|
|
788
|
+
}
|
|
789
|
+
declare enum EActionTypes {
|
|
790
|
+
URL = "URL",
|
|
791
|
+
UPDATE_VARIABLE = "UPDATE_VARIABLE",
|
|
792
|
+
RUN_SCRIPT = "RUN_SCRIPT",
|
|
793
|
+
OPEN_VIEW = "OPEN_VIEW"
|
|
794
|
+
}
|
|
795
|
+
interface IActionGoToUrl extends IActionCommon {
|
|
796
|
+
type: EActionTypes.URL;
|
|
797
|
+
url: string;
|
|
798
|
+
targetBlank: boolean;
|
|
799
|
+
}
|
|
800
|
+
interface IActionScriptField {
|
|
801
|
+
name: string;
|
|
802
|
+
id: number;
|
|
803
|
+
value: TWidgetActionInputValue;
|
|
804
|
+
}
|
|
805
|
+
interface IActionRunScript extends IActionCommon {
|
|
806
|
+
description: string;
|
|
807
|
+
type: EActionTypes.RUN_SCRIPT;
|
|
808
|
+
filters: (IFormulaFilterValue | string)[];
|
|
809
|
+
inputs: IActionScriptField[];
|
|
810
|
+
scriptName: string;
|
|
811
|
+
shouldRefreshWidgetsAfterExecution: boolean;
|
|
812
|
+
}
|
|
813
|
+
interface IActionUpdateVariable extends IActionCommon {
|
|
814
|
+
type: EActionTypes.UPDATE_VARIABLE;
|
|
815
|
+
variables: Array<string>;
|
|
816
|
+
}
|
|
817
|
+
declare enum EViewType {
|
|
818
|
+
CREATED_VIEW = "CREATED_VIEW",
|
|
819
|
+
GENERATED_BY_SCRIPT = "GENERATED_BY_SCRIPT"
|
|
820
|
+
}
|
|
821
|
+
declare enum EOpenViewMode {
|
|
822
|
+
NEW_WINDOW = "NEW_WINDOW",
|
|
823
|
+
PLACEHOLDER = "PLACEHOLDER",
|
|
824
|
+
MODAL = "MODAL",
|
|
825
|
+
DRAWER = "DRAWER"
|
|
826
|
+
}
|
|
827
|
+
declare enum EDrawerPlacement {
|
|
828
|
+
LEFT = "LEFT",
|
|
829
|
+
RIGHT = "RIGHT"
|
|
830
|
+
}
|
|
831
|
+
interface IActionOpenView extends IActionCommon {
|
|
832
|
+
type: EActionTypes.OPEN_VIEW;
|
|
833
|
+
viewName: string;
|
|
834
|
+
viewKey: string;
|
|
835
|
+
openMode: EOpenViewMode;
|
|
836
|
+
viewType: EViewType;
|
|
837
|
+
drawerPlacement: EDrawerPlacement;
|
|
838
|
+
placeholderName: string;
|
|
839
|
+
}
|
|
840
|
+
type TActionsOnClick = IActionGoToUrl | IActionRunScript | IActionUpdateVariable | IActionOpenView;
|
|
735
841
|
type TWidgetActionInputValue = {
|
|
736
842
|
mode: EWidgetActionInputMode.FROM_COLUMN;
|
|
737
843
|
tableName: string;
|
|
@@ -758,17 +864,7 @@ interface IWidgetActionInput {
|
|
|
758
864
|
name: string;
|
|
759
865
|
value: TWidgetActionInputValue;
|
|
760
866
|
}
|
|
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;
|
|
867
|
+
declare const isActionValid: (action: TActionsOnClick, { scripts, tables, variables }: IWidgetsContext) => boolean;
|
|
772
868
|
|
|
773
869
|
interface IBaseWidgetSettings {
|
|
774
870
|
apiVersion: string;
|
|
@@ -776,11 +872,14 @@ interface IBaseWidgetSettings {
|
|
|
776
872
|
header?: string;
|
|
777
873
|
headerSize?: number;
|
|
778
874
|
stateName?: string | null;
|
|
875
|
+
showMarkdown?: boolean;
|
|
876
|
+
markdownMeasures?: IMarkdownMeasure[];
|
|
877
|
+
markdownText?: string;
|
|
779
878
|
filters?: (IFormulaFilterValue | string)[];
|
|
780
879
|
filterMode?: EWidgetFilterMode;
|
|
781
880
|
ignoreFilters?: boolean;
|
|
782
881
|
sorting?: IWidgetSortingIndicator[];
|
|
783
|
-
actions?:
|
|
882
|
+
actions?: TActionsOnClick[];
|
|
784
883
|
displayCondition?: TDisplayCondition;
|
|
785
884
|
displayConditionComment?: string;
|
|
786
885
|
}
|
|
@@ -859,6 +958,10 @@ interface IGroupSetDescription<Settings extends object, GroupSettings extends ob
|
|
|
859
958
|
}
|
|
860
959
|
/** Конфигурация левой панели */
|
|
861
960
|
interface IPanelDescription<Settings extends object, GroupSettings extends IGroupSettings = IGroupSettings> {
|
|
961
|
+
/** Добавить заголовок для виджета */
|
|
962
|
+
useHeader?: boolean;
|
|
963
|
+
/** Добавить описание для виджета */
|
|
964
|
+
useMarkdown?: boolean;
|
|
862
965
|
/** Конфигурация настроек данных виджета */
|
|
863
966
|
dataRecords?: TWidgetLevelRecord<Settings>[];
|
|
864
967
|
/** Конфигурация настроек отображения виджета */
|
|
@@ -1110,7 +1213,7 @@ declare const replaceDisplayCondition: <I extends IWidgetColumnIndicator>(dimens
|
|
|
1110
1213
|
declare function mapMeasuresToInputs<T extends IWidgetMeasure>(measures: T[], variables: Map<string, TWidgetVariable>, addFormulas?: (measure: T) => Map<string, string>): ICalculatorMeasureInput[];
|
|
1111
1214
|
|
|
1112
1215
|
/** Конвертировать разрезы виджета во входы для вычислителя */
|
|
1113
|
-
declare function mapDimensionsToInputs(dimensions:
|
|
1216
|
+
declare function mapDimensionsToInputs<T extends IWidgetDimension>(dimensions: T[], variables: Map<string, TWidgetVariable>, addFormulas?: (dimension: T) => Map<string, string>): ICalculatorDimensionInput[];
|
|
1114
1217
|
|
|
1115
1218
|
/** Конвертировать процессные показатели виджета во входы для вычислителя */
|
|
1116
1219
|
declare function mapTransitionMeasuresToInputs<T extends IProcessIndicator>(indicators: T[], process: IWidgetProcess, variables: Map<string, TWidgetVariable>, addFormulas?: (indicator: T) => Map<string, string>): ICalculatorMeasureInput[];
|
|
@@ -1125,7 +1228,7 @@ declare function mapEventMeasuresToInputs<T extends IProcessIndicator>(indicator
|
|
|
1125
1228
|
* @param measuresInOriginalOrder меры виджета (конкретная мера будет браться по индексу)
|
|
1126
1229
|
* @returns
|
|
1127
1230
|
*/
|
|
1128
|
-
declare function mapSortingToInputs(sortingIndicators
|
|
1231
|
+
declare function mapSortingToInputs(sortingIndicators: IWidgetSortingIndicator[] | undefined, dimensionsInOriginalOrder: IWidgetDimension[] | undefined, measuresInOriginalOrder: IWidgetMeasure[] | undefined, variables: Map<string, TWidgetVariable>): ISortOrder[];
|
|
1129
1232
|
|
|
1130
1233
|
/**
|
|
1131
1234
|
* Выбрать активный разрез иерархии на основе активных фильтров.
|
|
@@ -1172,7 +1275,7 @@ interface IDefinition<WidgetSettings extends IBaseWidgetSettings, GroupSettings
|
|
|
1172
1275
|
}
|
|
1173
1276
|
|
|
1174
1277
|
type TLaunchActionParams = {
|
|
1175
|
-
action:
|
|
1278
|
+
action: TActionsOnClick;
|
|
1176
1279
|
onSuccess: () => void;
|
|
1177
1280
|
filters: ICalculatorFilter[];
|
|
1178
1281
|
needConfirmation?: boolean;
|
|
@@ -1362,7 +1465,7 @@ declare const replaceFiltersBySelection: (filters: ICalculatorFilter[], selectio
|
|
|
1362
1465
|
* @param {P} [props] - Дополнительные параметры локализации.
|
|
1363
1466
|
* @returns {string} - Локализованный текст для указанного языка.
|
|
1364
1467
|
*/
|
|
1365
|
-
declare const getLocalizedText: <L extends TLocalizationDescription, P extends ILocalizationProps = TExtractLocalizationParams<L>>(language: ELanguages, locObj: L, props?: P
|
|
1468
|
+
declare const getLocalizedText: <L extends TLocalizationDescription, P extends ILocalizationProps = TExtractLocalizationParams<L>>(language: ELanguages, locObj: L, props?: P) => string;
|
|
1366
1469
|
|
|
1367
1470
|
type TDefineWidgetOptions = {
|
|
1368
1471
|
manifest?: Record<string, unknown>;
|
|
@@ -1378,4 +1481,4 @@ declare global {
|
|
|
1378
1481
|
}
|
|
1379
1482
|
}
|
|
1380
1483
|
|
|
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
|
|
1484
|
+
export { EActionTypes, ECalculatorFilterMethods, EColorMode, EColorScope, EControlType, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationUnit, EEventMeasureTemplateNames, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, 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 IColoredValue, type ICommonColumnIndicator, type IControlRecord, type ICustomAddButtonProps, type ICustomWidgetProps, type IDefinition, type IDimensionSelection, type IDimensionSelectionByFormula, type IDisplayPredicate, type IDisplayRule, 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 IMarkdownMeasure, 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 TColorRule, 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
|
};
|
|
@@ -477,11 +502,25 @@ var EWidgetFilterMode;
|
|
|
477
502
|
})(EWidgetFilterMode || (EWidgetFilterMode = {}));
|
|
478
503
|
var EColorMode;
|
|
479
504
|
(function (EColorMode) {
|
|
505
|
+
EColorMode["DISABLED"] = "DISABLED";
|
|
480
506
|
EColorMode["FORMULA"] = "FORMULA";
|
|
481
507
|
EColorMode["BASE"] = "BASE";
|
|
482
508
|
EColorMode["GRADIENT"] = "GRADIENT";
|
|
483
509
|
EColorMode["AUTO"] = "AUTO";
|
|
510
|
+
EColorMode["RULE"] = "RULE";
|
|
511
|
+
EColorMode["VALUES"] = "VALUES";
|
|
512
|
+
EColorMode["BY_DIMENSION"] = "BY_DIMENSION";
|
|
484
513
|
})(EColorMode || (EColorMode = {}));
|
|
514
|
+
var EColorScope;
|
|
515
|
+
(function (EColorScope) {
|
|
516
|
+
EColorScope["WORKSPACE"] = "WORKSPACE";
|
|
517
|
+
EColorScope["DASHBOARD"] = "DASHBOARD";
|
|
518
|
+
})(EColorScope || (EColorScope = {}));
|
|
519
|
+
var EMarkdownDisplayMode;
|
|
520
|
+
(function (EMarkdownDisplayMode) {
|
|
521
|
+
EMarkdownDisplayMode["NONE"] = "NONE";
|
|
522
|
+
EMarkdownDisplayMode["INDICATOR"] = "INDICATOR";
|
|
523
|
+
})(EMarkdownDisplayMode || (EMarkdownDisplayMode = {}));
|
|
485
524
|
var EDisplayConditionMode;
|
|
486
525
|
(function (EDisplayConditionMode) {
|
|
487
526
|
EDisplayConditionMode["DISABLED"] = "DISABLED";
|
|
@@ -509,9 +548,7 @@ function getDisplayConditionFormula(displayCondition) {
|
|
|
509
548
|
}
|
|
510
549
|
}
|
|
511
550
|
var replaceDisplayCondition = function (dimension, displayCondition) {
|
|
512
|
-
return isNil(displayCondition)
|
|
513
|
-
? dimension
|
|
514
|
-
: __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
551
|
+
return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
515
552
|
};
|
|
516
553
|
|
|
517
554
|
var escapeSpecialCharacters = function (formula) {
|
|
@@ -756,12 +793,11 @@ function mapMeasureToInput(measure, variables, addFormulas) {
|
|
|
756
793
|
}
|
|
757
794
|
/** Конвертировать меры виджета во входы для вычислителя */
|
|
758
795
|
function mapMeasuresToInputs(measures, variables, addFormulas) {
|
|
759
|
-
return compactMap(measures, function (measure) {
|
|
760
|
-
return mapMeasureToInput(measure, variables, addFormulas);
|
|
761
|
-
});
|
|
796
|
+
return compactMap(measures, function (measure) { return mapMeasureToInput(measure, variables, addFormulas); });
|
|
762
797
|
}
|
|
763
798
|
|
|
764
|
-
function mapDimensionToInput(dimension, variables) {
|
|
799
|
+
function mapDimensionToInput(dimension, variables, addFormulas) {
|
|
800
|
+
if (addFormulas === void 0) { addFormulas = function () { return new Map(); }; }
|
|
765
801
|
var formula = getDimensionFormula(dimension);
|
|
766
802
|
if (!formula) {
|
|
767
803
|
return null;
|
|
@@ -775,12 +811,13 @@ function mapDimensionToInput(dimension, variables) {
|
|
|
775
811
|
dataType: dimension.dataType,
|
|
776
812
|
hideEmpty: dimension.hideEmptyValues,
|
|
777
813
|
displayConditionFormula: getDisplayConditionFormula(dimension.displayCondition),
|
|
814
|
+
additionalFormulas: addFormulas(dimension),
|
|
778
815
|
};
|
|
779
816
|
}
|
|
780
817
|
/** Конвертировать разрезы виджета во входы для вычислителя */
|
|
781
|
-
function mapDimensionsToInputs(dimensions, variables) {
|
|
818
|
+
function mapDimensionsToInputs(dimensions, variables, addFormulas) {
|
|
782
819
|
return compactMap(dimensions, function (dimension) {
|
|
783
|
-
return mapDimensionToInput(dimension, variables);
|
|
820
|
+
return mapDimensionToInput(dimension, variables, addFormulas);
|
|
784
821
|
});
|
|
785
822
|
}
|
|
786
823
|
|
|
@@ -839,11 +876,12 @@ function mapEventMeasuresToInputs(indicators, process, variables, addFormulas) {
|
|
|
839
876
|
* @param measuresInOriginalOrder меры виджета (конкретная мера будет браться по индексу)
|
|
840
877
|
* @returns
|
|
841
878
|
*/
|
|
842
|
-
function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder) {
|
|
879
|
+
function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder, variables) {
|
|
843
880
|
if (sortingIndicators === void 0) { sortingIndicators = []; }
|
|
844
881
|
if (dimensionsInOriginalOrder === void 0) { dimensionsInOriginalOrder = []; }
|
|
845
882
|
if (measuresInOriginalOrder === void 0) { measuresInOriginalOrder = []; }
|
|
846
883
|
return compactMap(sortingIndicators, function (_a) {
|
|
884
|
+
var _b;
|
|
847
885
|
var value = _a.value, direction = _a.direction;
|
|
848
886
|
if (value.mode === ESortingValueModes.FORMULA ||
|
|
849
887
|
value.mode === ESortingValueModes.QUANTITY ||
|
|
@@ -854,7 +892,20 @@ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measur
|
|
|
854
892
|
if (value.mode === ESortingValueModes.DIMENSION_IN_WIDGET ||
|
|
855
893
|
value.mode === ESortingValueModes.HIERARCHY) {
|
|
856
894
|
var dimension = dimensionsInOriginalOrder[value.index];
|
|
857
|
-
|
|
895
|
+
if (!dimension) {
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
var formula = getDimensionFormula(dimension);
|
|
899
|
+
if (!formula || !checkDisplayCondition(dimension.displayCondition, variables)) {
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
return {
|
|
903
|
+
formula: getDimensionFormula(dimension),
|
|
904
|
+
direction: direction,
|
|
905
|
+
displayCondition: ((_b = dimension.displayCondition) === null || _b === void 0 ? void 0 : _b.mode) === EDisplayConditionMode.FORMULA
|
|
906
|
+
? dimension.displayCondition.formula
|
|
907
|
+
: undefined,
|
|
908
|
+
};
|
|
858
909
|
}
|
|
859
910
|
if (value.mode === ESortingValueModes.MEASURE_IN_WIDGET) {
|
|
860
911
|
var measure = measuresInOriginalOrder[value.index];
|
|
@@ -882,9 +933,7 @@ function selectDimensionFromHierarchy(_a, filters) {
|
|
|
882
933
|
if (!matchedFilter) {
|
|
883
934
|
return "continue";
|
|
884
935
|
}
|
|
885
|
-
var selectionIndex = matchedFilter.values.length > 1
|
|
886
|
-
? i
|
|
887
|
-
: Math.min(i + 1, dimensions.length - 1);
|
|
936
|
+
var selectionIndex = matchedFilter.values.length > 1 ? i : Math.min(i + 1, dimensions.length - 1);
|
|
888
937
|
return { value: dimensions[selectionIndex] };
|
|
889
938
|
};
|
|
890
939
|
for (var i = dimensions.length - 1; i >= 0; i--) {
|
|
@@ -899,8 +948,7 @@ var replaceHierarchiesWithDimensions = function (dimensions, filters) {
|
|
|
899
948
|
return compactMap(dimensions, function (indicator) {
|
|
900
949
|
if (isHierarchy(indicator)) {
|
|
901
950
|
var selectedDimension = selectDimensionFromHierarchy(indicator, filters);
|
|
902
|
-
return (selectedDimension &&
|
|
903
|
-
replaceDisplayCondition(selectedDimension, indicator.displayCondition));
|
|
951
|
+
return (selectedDimension && replaceDisplayCondition(selectedDimension, indicator.displayCondition));
|
|
904
952
|
}
|
|
905
953
|
return indicator;
|
|
906
954
|
});
|
|
@@ -917,9 +965,7 @@ function bindContentWithIndicator(outputs, indicator) {
|
|
|
917
965
|
* Массив объектов, каждый из которых содержит показатель и его контент
|
|
918
966
|
*/
|
|
919
967
|
function bindContentsWithIndicators(outputs, indicators) {
|
|
920
|
-
return compactMap(indicators, function (indicator) {
|
|
921
|
-
return bindContentWithIndicator(outputs, indicator);
|
|
922
|
-
});
|
|
968
|
+
return compactMap(indicators, function (indicator) { return bindContentWithIndicator(outputs, indicator); });
|
|
923
969
|
}
|
|
924
970
|
|
|
925
971
|
var EControlType;
|
|
@@ -1047,4 +1093,4 @@ var getLocalizedText = function (language, locObj, props) {
|
|
|
1047
1093
|
return localization.getLocalized(locObj, props);
|
|
1048
1094
|
};
|
|
1049
1095
|
|
|
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 };
|
|
1096
|
+
export { EActionTypes, ECalculatorFilterMethods, EColorMode, EColorScope, EControlType, EDbType, EDimensionTemplateNames, EDisplayConditionMode, EDrawerPlacement, EDurationUnit, EEventMeasureTemplateNames, EFormatTypes, EFormattingPresets, EFormulaFilterFieldKeys, EIndicatorType, ELastTimeUnit, EMarkdownDisplayMode, 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
|
};
|
|
@@ -478,11 +503,25 @@ exports.EWidgetFilterMode = void 0;
|
|
|
478
503
|
})(exports.EWidgetFilterMode || (exports.EWidgetFilterMode = {}));
|
|
479
504
|
exports.EColorMode = void 0;
|
|
480
505
|
(function (EColorMode) {
|
|
506
|
+
EColorMode["DISABLED"] = "DISABLED";
|
|
481
507
|
EColorMode["FORMULA"] = "FORMULA";
|
|
482
508
|
EColorMode["BASE"] = "BASE";
|
|
483
509
|
EColorMode["GRADIENT"] = "GRADIENT";
|
|
484
510
|
EColorMode["AUTO"] = "AUTO";
|
|
511
|
+
EColorMode["RULE"] = "RULE";
|
|
512
|
+
EColorMode["VALUES"] = "VALUES";
|
|
513
|
+
EColorMode["BY_DIMENSION"] = "BY_DIMENSION";
|
|
485
514
|
})(exports.EColorMode || (exports.EColorMode = {}));
|
|
515
|
+
exports.EColorScope = void 0;
|
|
516
|
+
(function (EColorScope) {
|
|
517
|
+
EColorScope["WORKSPACE"] = "WORKSPACE";
|
|
518
|
+
EColorScope["DASHBOARD"] = "DASHBOARD";
|
|
519
|
+
})(exports.EColorScope || (exports.EColorScope = {}));
|
|
520
|
+
exports.EMarkdownDisplayMode = void 0;
|
|
521
|
+
(function (EMarkdownDisplayMode) {
|
|
522
|
+
EMarkdownDisplayMode["NONE"] = "NONE";
|
|
523
|
+
EMarkdownDisplayMode["INDICATOR"] = "INDICATOR";
|
|
524
|
+
})(exports.EMarkdownDisplayMode || (exports.EMarkdownDisplayMode = {}));
|
|
486
525
|
exports.EDisplayConditionMode = void 0;
|
|
487
526
|
(function (EDisplayConditionMode) {
|
|
488
527
|
EDisplayConditionMode["DISABLED"] = "DISABLED";
|
|
@@ -510,9 +549,7 @@ function getDisplayConditionFormula(displayCondition) {
|
|
|
510
549
|
}
|
|
511
550
|
}
|
|
512
551
|
var replaceDisplayCondition = function (dimension, displayCondition) {
|
|
513
|
-
return isNil(displayCondition)
|
|
514
|
-
? dimension
|
|
515
|
-
: __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
552
|
+
return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
|
|
516
553
|
};
|
|
517
554
|
|
|
518
555
|
var escapeSpecialCharacters = function (formula) {
|
|
@@ -757,12 +794,11 @@ function mapMeasureToInput(measure, variables, addFormulas) {
|
|
|
757
794
|
}
|
|
758
795
|
/** Конвертировать меры виджета во входы для вычислителя */
|
|
759
796
|
function mapMeasuresToInputs(measures, variables, addFormulas) {
|
|
760
|
-
return compactMap(measures, function (measure) {
|
|
761
|
-
return mapMeasureToInput(measure, variables, addFormulas);
|
|
762
|
-
});
|
|
797
|
+
return compactMap(measures, function (measure) { return mapMeasureToInput(measure, variables, addFormulas); });
|
|
763
798
|
}
|
|
764
799
|
|
|
765
|
-
function mapDimensionToInput(dimension, variables) {
|
|
800
|
+
function mapDimensionToInput(dimension, variables, addFormulas) {
|
|
801
|
+
if (addFormulas === void 0) { addFormulas = function () { return new Map(); }; }
|
|
766
802
|
var formula = getDimensionFormula(dimension);
|
|
767
803
|
if (!formula) {
|
|
768
804
|
return null;
|
|
@@ -776,12 +812,13 @@ function mapDimensionToInput(dimension, variables) {
|
|
|
776
812
|
dataType: dimension.dataType,
|
|
777
813
|
hideEmpty: dimension.hideEmptyValues,
|
|
778
814
|
displayConditionFormula: getDisplayConditionFormula(dimension.displayCondition),
|
|
815
|
+
additionalFormulas: addFormulas(dimension),
|
|
779
816
|
};
|
|
780
817
|
}
|
|
781
818
|
/** Конвертировать разрезы виджета во входы для вычислителя */
|
|
782
|
-
function mapDimensionsToInputs(dimensions, variables) {
|
|
819
|
+
function mapDimensionsToInputs(dimensions, variables, addFormulas) {
|
|
783
820
|
return compactMap(dimensions, function (dimension) {
|
|
784
|
-
return mapDimensionToInput(dimension, variables);
|
|
821
|
+
return mapDimensionToInput(dimension, variables, addFormulas);
|
|
785
822
|
});
|
|
786
823
|
}
|
|
787
824
|
|
|
@@ -840,11 +877,12 @@ function mapEventMeasuresToInputs(indicators, process, variables, addFormulas) {
|
|
|
840
877
|
* @param measuresInOriginalOrder меры виджета (конкретная мера будет браться по индексу)
|
|
841
878
|
* @returns
|
|
842
879
|
*/
|
|
843
|
-
function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder) {
|
|
880
|
+
function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measuresInOriginalOrder, variables) {
|
|
844
881
|
if (sortingIndicators === void 0) { sortingIndicators = []; }
|
|
845
882
|
if (dimensionsInOriginalOrder === void 0) { dimensionsInOriginalOrder = []; }
|
|
846
883
|
if (measuresInOriginalOrder === void 0) { measuresInOriginalOrder = []; }
|
|
847
884
|
return compactMap(sortingIndicators, function (_a) {
|
|
885
|
+
var _b;
|
|
848
886
|
var value = _a.value, direction = _a.direction;
|
|
849
887
|
if (value.mode === exports.ESortingValueModes.FORMULA ||
|
|
850
888
|
value.mode === exports.ESortingValueModes.QUANTITY ||
|
|
@@ -855,7 +893,20 @@ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measur
|
|
|
855
893
|
if (value.mode === exports.ESortingValueModes.DIMENSION_IN_WIDGET ||
|
|
856
894
|
value.mode === exports.ESortingValueModes.HIERARCHY) {
|
|
857
895
|
var dimension = dimensionsInOriginalOrder[value.index];
|
|
858
|
-
|
|
896
|
+
if (!dimension) {
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
var formula = getDimensionFormula(dimension);
|
|
900
|
+
if (!formula || !checkDisplayCondition(dimension.displayCondition, variables)) {
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
return {
|
|
904
|
+
formula: getDimensionFormula(dimension),
|
|
905
|
+
direction: direction,
|
|
906
|
+
displayCondition: ((_b = dimension.displayCondition) === null || _b === void 0 ? void 0 : _b.mode) === exports.EDisplayConditionMode.FORMULA
|
|
907
|
+
? dimension.displayCondition.formula
|
|
908
|
+
: undefined,
|
|
909
|
+
};
|
|
859
910
|
}
|
|
860
911
|
if (value.mode === exports.ESortingValueModes.MEASURE_IN_WIDGET) {
|
|
861
912
|
var measure = measuresInOriginalOrder[value.index];
|
|
@@ -883,9 +934,7 @@ function selectDimensionFromHierarchy(_a, filters) {
|
|
|
883
934
|
if (!matchedFilter) {
|
|
884
935
|
return "continue";
|
|
885
936
|
}
|
|
886
|
-
var selectionIndex = matchedFilter.values.length > 1
|
|
887
|
-
? i
|
|
888
|
-
: Math.min(i + 1, dimensions.length - 1);
|
|
937
|
+
var selectionIndex = matchedFilter.values.length > 1 ? i : Math.min(i + 1, dimensions.length - 1);
|
|
889
938
|
return { value: dimensions[selectionIndex] };
|
|
890
939
|
};
|
|
891
940
|
for (var i = dimensions.length - 1; i >= 0; i--) {
|
|
@@ -900,8 +949,7 @@ var replaceHierarchiesWithDimensions = function (dimensions, filters) {
|
|
|
900
949
|
return compactMap(dimensions, function (indicator) {
|
|
901
950
|
if (isHierarchy(indicator)) {
|
|
902
951
|
var selectedDimension = selectDimensionFromHierarchy(indicator, filters);
|
|
903
|
-
return (selectedDimension &&
|
|
904
|
-
replaceDisplayCondition(selectedDimension, indicator.displayCondition));
|
|
952
|
+
return (selectedDimension && replaceDisplayCondition(selectedDimension, indicator.displayCondition));
|
|
905
953
|
}
|
|
906
954
|
return indicator;
|
|
907
955
|
});
|
|
@@ -918,9 +966,7 @@ function bindContentWithIndicator(outputs, indicator) {
|
|
|
918
966
|
* Массив объектов, каждый из которых содержит показатель и его контент
|
|
919
967
|
*/
|
|
920
968
|
function bindContentsWithIndicators(outputs, indicators) {
|
|
921
|
-
return compactMap(indicators, function (indicator) {
|
|
922
|
-
return bindContentWithIndicator(outputs, indicator);
|
|
923
|
-
});
|
|
969
|
+
return compactMap(indicators, function (indicator) { return bindContentWithIndicator(outputs, indicator); });
|
|
924
970
|
}
|
|
925
971
|
|
|
926
972
|
exports.EControlType = void 0;
|
|
@@ -1048,11 +1094,11 @@ var getLocalizedText = function (language, locObj, props) {
|
|
|
1048
1094
|
return localization.getLocalized(locObj, props);
|
|
1049
1095
|
};
|
|
1050
1096
|
|
|
1051
|
-
Object.defineProperty(exports,
|
|
1097
|
+
Object.defineProperty(exports, "ELanguages", {
|
|
1052
1098
|
enumerable: true,
|
|
1053
1099
|
get: function () { return localization$1.ELanguages; }
|
|
1054
1100
|
});
|
|
1055
|
-
Object.defineProperty(exports,
|
|
1101
|
+
Object.defineProperty(exports, "EFilteringMethodValues", {
|
|
1056
1102
|
enumerable: true,
|
|
1057
1103
|
get: function () { return baseFilter.EFilteringMethodValues; }
|
|
1058
1104
|
});
|
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-beta12",
|
|
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",
|