@infomaximum/widget-sdk 4.0.0-beta1 → 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 CHANGED
@@ -33,7 +33,9 @@ declare enum EControlType {
33
33
  displayCondition = "displayCondition",
34
34
  eventsColor = "eventsColor",
35
35
  inputMarkdown = "inputMarkdown",
36
- filter = "filter"
36
+ filter = "filter",
37
+ actionOnClick = "actionOnClick",
38
+ eventsPicker = "eventsPicker"
37
39
  }
38
40
  /** Конфигурация элемента управления настройкой */
39
41
  interface IControlRecord<Settings extends object, Value, ControlType = EControlType> {
@@ -63,6 +65,12 @@ interface ICalculator<Input, Output> {
63
65
  }
64
66
  interface ICalculatorIndicatorInput {
65
67
  alias: string;
68
+ /**
69
+ * Информация о типе данных:
70
+ * - Если тип не передан, не производится дополнительной обработки формулы.
71
+ * - Если передан тип "OTHER", формула дополнительно будет обернута в toString().
72
+ */
73
+ dataType?: ESimpleDataType;
66
74
  displayConditionFormula?: TNullable<string>;
67
75
  }
68
76
  interface ICalculatorIndicatorOutput {
@@ -253,6 +261,7 @@ declare enum EDurationUnit {
253
261
  declare const mapFormulaFilterToCalculatorInput: (filterValue: IFormulaFilterValue | string) => TNullable<ICalculatorFilter>;
254
262
  declare const mapFormulaFiltersToInputs: (filters: (string | IFormulaFilterValue)[]) => ICalculatorFilter[];
255
263
 
264
+ type TSelectivePartial<T, Keys extends keyof T> = Omit<T, Keys> & Partial<Pick<T, Keys>>;
256
265
  declare const formulaFilterMethods: {
257
266
  readonly LAST_TIME: "LAST_TIME";
258
267
  readonly EQUAL_TO: ECalculatorFilterMethods.EQUAL_TO;
@@ -282,6 +291,7 @@ declare enum EProcessFilterNames {
282
291
  /** Длительность перехода */
283
292
  durationOfTransition = "durationOfTransition"
284
293
  }
294
+ /** @deprecated необходимо использовать @see {@link IFormulaFilterValue} */
285
295
  interface IWidgetFormulaFilterValue extends ICalculatorFilter {
286
296
  /**
287
297
  * Название фильтра
@@ -298,16 +308,16 @@ interface IProcessFilterValue {
298
308
  * События, доступные при выборе процесса.
299
309
  * Если параметр не передан, используются все события процесса на основе запроса к вычислителю.
300
310
  */
301
- eventsNamesByProcessGuidMap?: Map<string, (string | null)[]>;
311
+ eventsNamesByProcessNameMap?: Map<string, (string | null)[]>;
302
312
  }
303
313
  interface IProcessEventFilterValue extends IProcessFilterValue {
304
- processGuid: string;
314
+ processName: string;
305
315
  eventName: string;
306
316
  }
307
317
  interface IProcessTransitionFilterValue extends IProcessFilterValue {
308
- startEventProcessGuid: string;
318
+ startEventProcessName: string;
309
319
  startEventName: string;
310
- endEventProcessGuid: string;
320
+ endEventProcessName: string;
311
321
  endEventName: string;
312
322
  }
313
323
  interface IAddPresenceOfEventFilter {
@@ -322,15 +332,6 @@ interface IAddPresenceOfTransitionFilter {
322
332
  interface IAddDurationOfTransitionFilter {
323
333
  (name: EProcessFilterNames.durationOfTransition, value: IProcessTransitionFilterValue): void;
324
334
  }
325
- interface IWidgetFiltration {
326
- /** Значения фильтров, подготовленные для передачи в вычислитель */
327
- preparedFilterValues: ICalculatorFilter[];
328
- /** Добавить фильтр по формуле */
329
- addFormulaFilter(value: IWidgetFormulaFilterValue): void;
330
- /** Удалить фильтр по формуле */
331
- removeFormulaFilter(formula: string): void;
332
- addProcessFilter(...args: Parameters<IAddPresenceOfEventFilter> | Parameters<IAddRepetitionOfEventFilter> | Parameters<IAddPresenceOfTransitionFilter> | Parameters<IAddDurationOfTransitionFilter>): void;
333
- }
334
335
  declare enum EFormulaFilterFieldKeys {
335
336
  date = "date",
336
337
  dateRange = "dateRange",
@@ -354,7 +355,7 @@ interface IFormulaFilterValue {
354
355
  /** Метод фильтрации */
355
356
  filteringMethod: valueof<typeof formulaFilterMethods>;
356
357
  /** Выбранные в списке значения в виде моделей */
357
- checkedValues: string[];
358
+ checkedValues: (string | null)[];
358
359
  /** Значения полей формы редактора */
359
360
  formValues: Partial<{
360
361
  [EFormulaFilterFieldKeys.date]: string | null;
@@ -368,14 +369,41 @@ interface IFormulaFilterValue {
368
369
  [EFormulaFilterFieldKeys.durationUnit]: EDurationUnit;
369
370
  }>;
370
371
  }
371
-
372
- interface IPlacement {
373
- left: number;
374
- top: number;
375
- width: number;
376
- height: number;
377
- zIndex: number;
372
+ interface IStagesFilterItem {
373
+ /** Название этапа */
374
+ name: string;
375
+ /** Формула фильтра этапа */
376
+ formula: string;
377
+ isSelected: boolean;
378
378
  }
379
+ interface IStagesFilterValue {
380
+ /** Ключ виджета */
381
+ widgetKey: string;
382
+ /** Заголовок фильтра */
383
+ name: TNullable<string>;
384
+ /** Этапы */
385
+ stages: IStagesFilterItem[];
386
+ }
387
+ type TWidgetFilterValue = IFormulaFilterValue | IStagesFilterValue | IProcessEventFilterValue | IProcessTransitionFilterValue;
388
+ interface IWidgetFilter {
389
+ filterValue: TWidgetFilterValue;
390
+ preparedFilterValue: ICalculatorFilter;
391
+ }
392
+ interface IWidgetFiltration {
393
+ /** Значения фильтров, подготовленные для передачи в вычислитель */
394
+ preparedFilterValues: ICalculatorFilter[];
395
+ filters: IWidgetFilter[];
396
+ /** Добавить фильтр по формуле */
397
+ addFormulaFilter(value: IWidgetFormulaFilterValue | TSelectivePartial<IFormulaFilterValue, "format" | "formValues">): void;
398
+ /** Удалить фильтр по формуле */
399
+ removeFormulaFilter(formula: string): void;
400
+ addProcessFilter(...args: Parameters<IAddPresenceOfEventFilter> | Parameters<IAddRepetitionOfEventFilter> | Parameters<IAddPresenceOfTransitionFilter> | Parameters<IAddDurationOfTransitionFilter>): void;
401
+ /** Добавить фильтр по этапам */
402
+ addStagesFilter(value: Omit<IStagesFilterValue, "widgetKey">): void;
403
+ /** Удалить фильтр по этапам */
404
+ removeStagesFilter(widgetKey: string): void;
405
+ }
406
+
379
407
  declare enum EWidgetFilterMode {
380
408
  DEFAULT = "DEFAULT",
381
409
  SINGLE = "SINGLE",
@@ -423,7 +451,7 @@ type TDisplayCondition = {
423
451
  formula: TNullable<string>;
424
452
  } | {
425
453
  mode: EDisplayConditionMode.VARIABLE;
426
- variableGuid: TNullable<string>;
454
+ variableName: TNullable<string>;
427
455
  variableValue: TNullable<string>;
428
456
  };
429
457
  interface IRange {
@@ -457,7 +485,7 @@ type TWidgetSortingValue = {
457
485
  formula: string;
458
486
  } | TWidgetSortingValueRelatedWidgetIndicator | {
459
487
  mode: ESortingValueModes.IN_DASHBOARD | ESortingValueModes.IN_WORKSPACE;
460
- guid: string;
488
+ name: string;
461
489
  formula: string;
462
490
  };
463
491
 
@@ -540,7 +568,6 @@ declare enum ESortingValueModes {
540
568
  IN_WORKSPACE = "IN_WORKSPACE"
541
569
  }
542
570
  interface ICommonColumnIndicator {
543
- guid: string;
544
571
  name: string;
545
572
  formula: string;
546
573
  }
@@ -658,8 +685,8 @@ interface IWidgetTableColumn {
658
685
  dataType: ESimpleDataType;
659
686
  }
660
687
  interface IActionScript {
661
- guid: string | undefined;
662
- fieldsGuids: Set<string>;
688
+ name: string | undefined;
689
+ fieldsNames: Set<string>;
663
690
  }
664
691
  interface IWidgetTable {
665
692
  /** Имя таблицы */
@@ -682,8 +709,8 @@ interface IWidgetsContext {
682
709
  /** Переменные отчета */
683
710
  variables: Map<string, TWidgetVariable>;
684
711
  /** Метод установки значения переменной отчета */
685
- setVariableValue(guid: string, value: TNullable<string> | string[]): void;
686
- statesGuids: Set<string>;
712
+ setVariableValue(name: string, value: TNullable<string> | string[]): void;
713
+ statesNames: Set<string>;
687
714
  reportName: string;
688
715
  /**
689
716
  * режим дашборда
@@ -705,13 +732,69 @@ declare enum EWidgetActionInputMode {
705
732
  FORMULA = "FORMULA",
706
733
  MANUALLY = "MANUALLY"
707
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;
708
791
  type TWidgetActionInputValue = {
709
792
  mode: EWidgetActionInputMode.FROM_COLUMN;
710
793
  tableName: string;
711
794
  columnName: string;
712
795
  } | {
713
796
  mode: EWidgetActionInputMode.FROM_VARIABLE;
714
- guid: string;
797
+ name: string;
715
798
  } | {
716
799
  mode: EWidgetActionInputMode.FORMULA;
717
800
  formula: string;
@@ -728,34 +811,22 @@ type TWidgetActionInputValue = {
728
811
  defaultValue: string;
729
812
  };
730
813
  interface IWidgetActionInput {
731
- guid: string;
732
- value: TWidgetActionInputValue;
733
- }
734
- interface IWidgetAction {
735
- id: number;
736
814
  name: string;
737
- description: string;
738
- filters: (IFormulaFilterValue | string)[];
739
- scriptGuid?: string;
740
- /** Поле name необходимо, чтобы показать название скрипта, который был удален */
741
- scriptName?: string;
742
- inputs: IWidgetActionInput[];
743
- shouldRefreshWidgetsAfterExecution: boolean;
815
+ value: TWidgetActionInputValue;
744
816
  }
745
- declare const isActionValid: (action: IWidgetAction, { scripts, tables }: IWidgetsContext) => boolean;
817
+ declare const isActionValid: (action: TActionsOnClick, { scripts, tables, variables }: IWidgetsContext) => boolean;
746
818
 
747
819
  interface IBaseWidgetSettings {
748
820
  apiVersion: string;
749
821
  type: string;
750
822
  header?: string;
751
823
  headerSize?: number;
752
- stateGuid?: string | null;
824
+ stateName?: string | null;
753
825
  filters?: (IFormulaFilterValue | string)[];
754
826
  filterMode?: EWidgetFilterMode;
755
827
  ignoreFilters?: boolean;
756
- placement: IPlacement;
757
828
  sorting?: IWidgetSortingIndicator[];
758
- actions?: IWidgetAction[];
829
+ actions?: TActionsOnClick[];
759
830
  displayCondition?: TDisplayCondition;
760
831
  displayConditionComment?: string;
761
832
  }
@@ -992,7 +1063,7 @@ interface IEdge extends IGraphElement {
992
1063
  endName: string | null;
993
1064
  }
994
1065
  interface IProcessGraphCalculatorInput {
995
- processGuid: string;
1066
+ processName: string;
996
1067
  vertexLimit: number | null;
997
1068
  edgeLimit: number;
998
1069
  vertexMeasures: ICalculatorMeasureInput[];
@@ -1124,6 +1195,8 @@ declare function bindContentWithIndicator<Output extends ICalculatorIndicatorOut
1124
1195
  */
1125
1196
  declare function bindContentsWithIndicators<Output extends ICalculatorIndicatorOutput, Indicator extends IWidgetIndicator>(outputs: Map<string, Output>, indicators: Indicator[]): TBoundedContentWithIndicator<Output, Indicator>[];
1126
1197
 
1198
+ declare const escapeSpecialCharacters: (formula: string) => string;
1199
+
1127
1200
  interface ICalculatorFactory {
1128
1201
  general: () => IGeneralCalculator;
1129
1202
  pie: () => IPieCalculator;
@@ -1144,6 +1217,16 @@ interface IDefinition<WidgetSettings extends IBaseWidgetSettings, GroupSettings
1144
1217
  getMeasures?(settings: WidgetSettings): IWidgetMeasure[];
1145
1218
  }
1146
1219
 
1220
+ type TLaunchActionParams = {
1221
+ action: TActionsOnClick;
1222
+ onSuccess: () => void;
1223
+ filters: ICalculatorFilter[];
1224
+ needConfirmation?: boolean;
1225
+ };
1226
+ type TWidgetContainer = {
1227
+ /** Имеет ли контейнер виджета ограниченную максимальную высоту */
1228
+ isMaxHeightLimited: boolean;
1229
+ };
1147
1230
  interface IWidgetProps<WidgetSettings extends IBaseWidgetSettings = IBaseWidgetSettings> {
1148
1231
  /** guid виджета */
1149
1232
  guid: string;
@@ -1164,14 +1247,12 @@ interface IWidgetProps<WidgetSettings extends IBaseWidgetSettings = IBaseWidgetS
1164
1247
  rootViewContainer: HTMLDivElement;
1165
1248
  /** Объект для управления плейсхолдером */
1166
1249
  placeholder: IWidgetPlaceholderController;
1167
- /** Контекст виджета */
1250
+ /** Контекст виджетов */
1168
1251
  widgetsContext: IWidgetsContext;
1169
- /** Вызывает модальное окно для запуска действия */
1170
- launchAction(params: {
1171
- action: IWidgetAction;
1172
- onSuccess: () => void;
1173
- filters: ICalculatorFilter[];
1174
- }): void;
1252
+ /** Данные о контейнере виджета */
1253
+ widgetContainer: TWidgetContainer;
1254
+ /** Запуск действия */
1255
+ launchAction(params: TLaunchActionParams): void;
1175
1256
  }
1176
1257
  interface ICustomWidgetProps<WidgetSettings extends IBaseWidgetSettings = IBaseWidgetSettings> extends IWidgetProps<WidgetSettings> {
1177
1258
  /** @deprecated - нужно использовать из widgetsContext */
@@ -1327,7 +1408,7 @@ declare const replaceFiltersBySelection: (filters: ICalculatorFilter[], selectio
1327
1408
  * @param {P} [props] - Дополнительные параметры локализации.
1328
1409
  * @returns {string} - Локализованный текст для указанного языка.
1329
1410
  */
1330
- declare const getLocalizedText: <L extends TLocalizationDescription, P extends ILocalizationProps = TExtractLocalizationParams<L>>(language: ELanguages, locObj: L, props?: P | undefined) => string;
1411
+ declare const getLocalizedText: <L extends TLocalizationDescription, P extends ILocalizationProps = TExtractLocalizationParams<L>>(language: ELanguages, locObj: L, props?: P) => string;
1331
1412
 
1332
1413
  type TDefineWidgetOptions = {
1333
1414
  manifest?: Record<string, unknown>;
@@ -1343,4 +1424,4 @@ declare global {
1343
1424
  }
1344
1425
  }
1345
1426
 
1346
- 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 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 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 TProcessIndicatorValue, type TRecordAccessor, type TSortDirection, type TUpdateSelection, type TValuePath, type TWidgetActionInputValue, type TWidgetFiltering, type TWidgetLevelRecord, type TWidgetSortingValue, type TWidgetSortingValueRelatedWidgetDimension, type TWidgetSortingValueRelatedWidgetIndicator, type TWidgetSortingValueRelatedWidgetMeasure, type TWidgetVariable, bindContentWithIndicator, bindContentsWithIndicators, checkDisplayCondition, dimensionTemplateFormulas, 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 };
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,24 +71,51 @@ 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
- var scripts = _a.scripts, tables = _a.tables;
77
- var currentScript = scripts.get((_b = action.scriptGuid) !== null && _b !== void 0 ? _b : "");
100
+ var scripts = _a.scripts, tables = _a.tables, variables = _a.variables;
101
+ if (action.type !== EActionTypes.RUN_SCRIPT) {
102
+ return false;
103
+ }
104
+ var currentScript = scripts.get((_b = action.scriptName) !== null && _b !== void 0 ? _b : "");
78
105
  if (!currentScript) {
79
106
  return false;
80
107
  }
81
- var actionInputsMap = new Map(action.inputs.map(function (input) { return [input.guid, input]; }));
82
- if (actionInputsMap.size < currentScript.fieldsGuids.size) {
108
+ var actionInputsMap = new Map(action.inputs.map(function (input) { return [input.name, input]; }));
109
+ if (actionInputsMap.size < currentScript.fieldsNames.size) {
83
110
  return false;
84
111
  }
85
- return __spreadArray([], __read(currentScript.fieldsGuids), false).every(function (guid) {
86
- var actionInput = actionInputsMap.get(guid !== null && guid !== void 0 ? guid : "");
112
+ return __spreadArray([], __read(currentScript.fieldsNames), false).every(function (name) {
113
+ var actionInput = actionInputsMap.get(name !== null && name !== void 0 ? name : "");
87
114
  if (!actionInput) {
88
115
  return false;
89
116
  }
90
117
  var value = actionInput.value;
91
- if (value.mode === EWidgetActionInputMode.FROM_VARIABLE && !value.guid) {
118
+ if (value.mode === EWidgetActionInputMode.FROM_VARIABLE && !variables.has(value.name)) {
92
119
  return false;
93
120
  }
94
121
  if (value.mode === EWidgetActionInputMode.FORMULA && !value.formula) {
@@ -97,8 +124,7 @@ var isActionValid = function (action, _a) {
97
124
  if (value.mode === EWidgetActionInputMode.DYNAMIC_LIST && !value.formula) {
98
125
  return false;
99
126
  }
100
- if (value.mode === EWidgetActionInputMode.FROM_COLUMN &&
101
- !tables.has(value.tableName)) {
127
+ if (value.mode === EWidgetActionInputMode.FROM_COLUMN && !tables.has(value.tableName)) {
102
128
  return false;
103
129
  }
104
130
  return true;
@@ -123,9 +149,7 @@ var prepareValuesForSql = function (dataType, values) {
123
149
  dataType === ESimpleDataType.BOOLEAN
124
150
  ? values
125
151
  : values.map(function (value) {
126
- return value === null
127
- ? null
128
- : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
152
+ return value === null ? null : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
129
153
  });
130
154
  };
131
155
  var escapeReverseSlash = function (formula) {
@@ -136,7 +160,9 @@ var escapeSingularQuotes = function (formula) {
136
160
  };
137
161
 
138
162
  var compact = function (items) { return ((items === null || items === void 0 ? void 0 : items.filter(Boolean)) || []); };
139
- var compactMap = function (items, f) { return compact(items === null || items === void 0 ? void 0 : items.map(f)); };
163
+ var compactMap = function (items, f) {
164
+ return compact(items === null || items === void 0 ? void 0 : items.map(f));
165
+ };
140
166
  var isNil = function (value) {
141
167
  return value === null || value === undefined;
142
168
  };
@@ -491,8 +517,8 @@ var EDisplayConditionMode;
491
517
  function checkDisplayCondition(displayCondition, variables) {
492
518
  var _a;
493
519
  if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === EDisplayConditionMode.VARIABLE) {
494
- var variableGuid = displayCondition.variableGuid, variableValue = displayCondition.variableValue;
495
- var currentVariableValue = variableGuid && ((_a = variables.get(variableGuid)) === null || _a === void 0 ? void 0 : _a.value);
520
+ var variableName = displayCondition.variableName, variableValue = displayCondition.variableValue;
521
+ var currentVariableValue = variableName && ((_a = variables.get(variableName)) === null || _a === void 0 ? void 0 : _a.value);
496
522
  var isCurrentVariableMatch = Array.isArray(currentVariableValue)
497
523
  ? !!variableValue && (currentVariableValue === null || currentVariableValue === void 0 ? void 0 : currentVariableValue.includes(variableValue))
498
524
  : currentVariableValue === variableValue;
@@ -508,13 +534,21 @@ function getDisplayConditionFormula(displayCondition) {
508
534
  }
509
535
  }
510
536
  var replaceDisplayCondition = function (dimension, displayCondition) {
511
- return isNil(displayCondition)
512
- ? dimension
513
- : __assign(__assign({}, dimension), { displayCondition: displayCondition });
537
+ return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
538
+ };
539
+
540
+ var escapeSpecialCharacters = function (formula) {
541
+ return formula
542
+ .replaceAll("\\", "\\\\")
543
+ .replaceAll('"', '\\"')
544
+ .replaceAll("`", "\\`")
545
+ .replaceAll("-", "\\-");
514
546
  };
515
547
 
516
548
  function generateColumnFormula(tableName, columnName) {
517
- return "\"".concat(tableName, "\".\"").concat(columnName, "\"");
549
+ var preparedTableName = escapeSpecialCharacters(tableName);
550
+ var preparedColumnName = escapeSpecialCharacters(columnName);
551
+ return "\"".concat(preparedTableName, "\".\"").concat(preparedColumnName, "\"");
518
552
  }
519
553
  function fillTemplateString(templateString, params) {
520
554
  return templateString.replace(/\{(.*?)\}/g, function (_, key) { var _a; return (_a = params[key]) !== null && _a !== void 0 ? _a : ""; });
@@ -738,15 +772,14 @@ function mapMeasureToInput(measure, variables, addFormulas) {
738
772
  return {
739
773
  alias: String(measure.id),
740
774
  mainFormula: mainFormula,
775
+ dataType: measure.dataType,
741
776
  displayConditionFormula: getDisplayConditionFormula(measure.displayCondition),
742
777
  additionalFormulas: addFormulas(measure),
743
778
  };
744
779
  }
745
780
  /** Конвертировать меры виджета во входы для вычислителя */
746
781
  function mapMeasuresToInputs(measures, variables, addFormulas) {
747
- return compactMap(measures, function (measure) {
748
- return mapMeasureToInput(measure, variables, addFormulas);
749
- });
782
+ return compactMap(measures, function (measure) { return mapMeasureToInput(measure, variables, addFormulas); });
750
783
  }
751
784
 
752
785
  function mapDimensionToInput(dimension, variables) {
@@ -760,15 +793,14 @@ function mapDimensionToInput(dimension, variables) {
760
793
  return {
761
794
  alias: String(dimension.id),
762
795
  formula: formula,
796
+ dataType: dimension.dataType,
763
797
  hideEmpty: dimension.hideEmptyValues,
764
798
  displayConditionFormula: getDisplayConditionFormula(dimension.displayCondition),
765
799
  };
766
800
  }
767
801
  /** Конвертировать разрезы виджета во входы для вычислителя */
768
802
  function mapDimensionsToInputs(dimensions, variables) {
769
- return compactMap(dimensions, function (dimension) {
770
- return mapDimensionToInput(dimension, variables);
771
- });
803
+ return compactMap(dimensions, function (dimension) { return mapDimensionToInput(dimension, variables); });
772
804
  }
773
805
 
774
806
  function mapTransitionMeasureToInput(indicator, process, variables, addFormulas) {
@@ -783,6 +815,7 @@ function mapTransitionMeasureToInput(indicator, process, variables, addFormulas)
783
815
  return {
784
816
  alias: String(indicator.id),
785
817
  mainFormula: mainFormula,
818
+ dataType: indicator.dataType,
786
819
  displayConditionFormula: getDisplayConditionFormula(indicator.displayCondition),
787
820
  additionalFormulas: addFormulas(indicator),
788
821
  };
@@ -806,6 +839,7 @@ function mapEventMeasureToInput(indicator, process, variables, addFormulas) {
806
839
  return {
807
840
  alias: String(indicator.id),
808
841
  mainFormula: mainFormula,
842
+ dataType: indicator.dataType,
809
843
  displayConditionFormula: getDisplayConditionFormula(indicator.displayCondition),
810
844
  additionalFormulas: addFormulas(indicator),
811
845
  };
@@ -839,7 +873,7 @@ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measur
839
873
  if (value.mode === ESortingValueModes.DIMENSION_IN_WIDGET ||
840
874
  value.mode === ESortingValueModes.HIERARCHY) {
841
875
  var dimension = dimensionsInOriginalOrder[value.index];
842
- return (dimension && { formula: getDimensionFormula(dimension), direction: direction });
876
+ return dimension && { formula: getDimensionFormula(dimension), direction: direction };
843
877
  }
844
878
  if (value.mode === ESortingValueModes.MEASURE_IN_WIDGET) {
845
879
  var measure = measuresInOriginalOrder[value.index];
@@ -867,9 +901,7 @@ function selectDimensionFromHierarchy(_a, filters) {
867
901
  if (!matchedFilter) {
868
902
  return "continue";
869
903
  }
870
- var selectionIndex = matchedFilter.values.length > 1
871
- ? i
872
- : Math.min(i + 1, dimensions.length - 1);
904
+ var selectionIndex = matchedFilter.values.length > 1 ? i : Math.min(i + 1, dimensions.length - 1);
873
905
  return { value: dimensions[selectionIndex] };
874
906
  };
875
907
  for (var i = dimensions.length - 1; i >= 0; i--) {
@@ -884,8 +916,7 @@ var replaceHierarchiesWithDimensions = function (dimensions, filters) {
884
916
  return compactMap(dimensions, function (indicator) {
885
917
  if (isHierarchy(indicator)) {
886
918
  var selectedDimension = selectDimensionFromHierarchy(indicator, filters);
887
- return (selectedDimension &&
888
- replaceDisplayCondition(selectedDimension, indicator.displayCondition));
919
+ return (selectedDimension && replaceDisplayCondition(selectedDimension, indicator.displayCondition));
889
920
  }
890
921
  return indicator;
891
922
  });
@@ -902,9 +933,7 @@ function bindContentWithIndicator(outputs, indicator) {
902
933
  * Массив объектов, каждый из которых содержит показатель и его контент
903
934
  */
904
935
  function bindContentsWithIndicators(outputs, indicators) {
905
- return compactMap(indicators, function (indicator) {
906
- return bindContentWithIndicator(outputs, indicator);
907
- });
936
+ return compactMap(indicators, function (indicator) { return bindContentWithIndicator(outputs, indicator); });
908
937
  }
909
938
 
910
939
  var EControlType;
@@ -926,6 +955,8 @@ var EControlType;
926
955
  EControlType["eventsColor"] = "eventsColor";
927
956
  EControlType["inputMarkdown"] = "inputMarkdown";
928
957
  EControlType["filter"] = "filter";
958
+ EControlType["actionOnClick"] = "actionOnClick";
959
+ EControlType["eventsPicker"] = "eventsPicker";
929
960
  })(EControlType || (EControlType = {}));
930
961
 
931
962
  var ESortDirection;
@@ -1030,4 +1061,4 @@ var getLocalizedText = function (language, locObj, props) {
1030
1061
  return localization.getLocalized(locObj, props);
1031
1062
  };
1032
1063
 
1033
- 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, 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,24 +72,51 @@ 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
- var scripts = _a.scripts, tables = _a.tables;
78
- var currentScript = scripts.get((_b = action.scriptGuid) !== null && _b !== void 0 ? _b : "");
101
+ var scripts = _a.scripts, tables = _a.tables, variables = _a.variables;
102
+ if (action.type !== exports.EActionTypes.RUN_SCRIPT) {
103
+ return false;
104
+ }
105
+ var currentScript = scripts.get((_b = action.scriptName) !== null && _b !== void 0 ? _b : "");
79
106
  if (!currentScript) {
80
107
  return false;
81
108
  }
82
- var actionInputsMap = new Map(action.inputs.map(function (input) { return [input.guid, input]; }));
83
- if (actionInputsMap.size < currentScript.fieldsGuids.size) {
109
+ var actionInputsMap = new Map(action.inputs.map(function (input) { return [input.name, input]; }));
110
+ if (actionInputsMap.size < currentScript.fieldsNames.size) {
84
111
  return false;
85
112
  }
86
- return __spreadArray([], __read(currentScript.fieldsGuids), false).every(function (guid) {
87
- var actionInput = actionInputsMap.get(guid !== null && guid !== void 0 ? guid : "");
113
+ return __spreadArray([], __read(currentScript.fieldsNames), false).every(function (name) {
114
+ var actionInput = actionInputsMap.get(name !== null && name !== void 0 ? name : "");
88
115
  if (!actionInput) {
89
116
  return false;
90
117
  }
91
118
  var value = actionInput.value;
92
- if (value.mode === exports.EWidgetActionInputMode.FROM_VARIABLE && !value.guid) {
119
+ if (value.mode === exports.EWidgetActionInputMode.FROM_VARIABLE && !variables.has(value.name)) {
93
120
  return false;
94
121
  }
95
122
  if (value.mode === exports.EWidgetActionInputMode.FORMULA && !value.formula) {
@@ -98,8 +125,7 @@ var isActionValid = function (action, _a) {
98
125
  if (value.mode === exports.EWidgetActionInputMode.DYNAMIC_LIST && !value.formula) {
99
126
  return false;
100
127
  }
101
- if (value.mode === exports.EWidgetActionInputMode.FROM_COLUMN &&
102
- !tables.has(value.tableName)) {
128
+ if (value.mode === exports.EWidgetActionInputMode.FROM_COLUMN && !tables.has(value.tableName)) {
103
129
  return false;
104
130
  }
105
131
  return true;
@@ -124,9 +150,7 @@ var prepareValuesForSql = function (dataType, values) {
124
150
  dataType === exports.ESimpleDataType.BOOLEAN
125
151
  ? values
126
152
  : values.map(function (value) {
127
- return value === null
128
- ? null
129
- : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
153
+ return value === null ? null : "'".concat(escapeSingularQuotes(escapeReverseSlash(value)), "'");
130
154
  });
131
155
  };
132
156
  var escapeReverseSlash = function (formula) {
@@ -137,7 +161,9 @@ var escapeSingularQuotes = function (formula) {
137
161
  };
138
162
 
139
163
  var compact = function (items) { return ((items === null || items === void 0 ? void 0 : items.filter(Boolean)) || []); };
140
- var compactMap = function (items, f) { return compact(items === null || items === void 0 ? void 0 : items.map(f)); };
164
+ var compactMap = function (items, f) {
165
+ return compact(items === null || items === void 0 ? void 0 : items.map(f));
166
+ };
141
167
  var isNil = function (value) {
142
168
  return value === null || value === undefined;
143
169
  };
@@ -492,8 +518,8 @@ exports.EDisplayConditionMode = void 0;
492
518
  function checkDisplayCondition(displayCondition, variables) {
493
519
  var _a;
494
520
  if ((displayCondition === null || displayCondition === void 0 ? void 0 : displayCondition.mode) === exports.EDisplayConditionMode.VARIABLE) {
495
- var variableGuid = displayCondition.variableGuid, variableValue = displayCondition.variableValue;
496
- var currentVariableValue = variableGuid && ((_a = variables.get(variableGuid)) === null || _a === void 0 ? void 0 : _a.value);
521
+ var variableName = displayCondition.variableName, variableValue = displayCondition.variableValue;
522
+ var currentVariableValue = variableName && ((_a = variables.get(variableName)) === null || _a === void 0 ? void 0 : _a.value);
497
523
  var isCurrentVariableMatch = Array.isArray(currentVariableValue)
498
524
  ? !!variableValue && (currentVariableValue === null || currentVariableValue === void 0 ? void 0 : currentVariableValue.includes(variableValue))
499
525
  : currentVariableValue === variableValue;
@@ -509,13 +535,21 @@ function getDisplayConditionFormula(displayCondition) {
509
535
  }
510
536
  }
511
537
  var replaceDisplayCondition = function (dimension, displayCondition) {
512
- return isNil(displayCondition)
513
- ? dimension
514
- : __assign(__assign({}, dimension), { displayCondition: displayCondition });
538
+ return isNil(displayCondition) ? dimension : __assign(__assign({}, dimension), { displayCondition: displayCondition });
539
+ };
540
+
541
+ var escapeSpecialCharacters = function (formula) {
542
+ return formula
543
+ .replaceAll("\\", "\\\\")
544
+ .replaceAll('"', '\\"')
545
+ .replaceAll("`", "\\`")
546
+ .replaceAll("-", "\\-");
515
547
  };
516
548
 
517
549
  function generateColumnFormula(tableName, columnName) {
518
- return "\"".concat(tableName, "\".\"").concat(columnName, "\"");
550
+ var preparedTableName = escapeSpecialCharacters(tableName);
551
+ var preparedColumnName = escapeSpecialCharacters(columnName);
552
+ return "\"".concat(preparedTableName, "\".\"").concat(preparedColumnName, "\"");
519
553
  }
520
554
  function fillTemplateString(templateString, params) {
521
555
  return templateString.replace(/\{(.*?)\}/g, function (_, key) { var _a; return (_a = params[key]) !== null && _a !== void 0 ? _a : ""; });
@@ -739,15 +773,14 @@ function mapMeasureToInput(measure, variables, addFormulas) {
739
773
  return {
740
774
  alias: String(measure.id),
741
775
  mainFormula: mainFormula,
776
+ dataType: measure.dataType,
742
777
  displayConditionFormula: getDisplayConditionFormula(measure.displayCondition),
743
778
  additionalFormulas: addFormulas(measure),
744
779
  };
745
780
  }
746
781
  /** Конвертировать меры виджета во входы для вычислителя */
747
782
  function mapMeasuresToInputs(measures, variables, addFormulas) {
748
- return compactMap(measures, function (measure) {
749
- return mapMeasureToInput(measure, variables, addFormulas);
750
- });
783
+ return compactMap(measures, function (measure) { return mapMeasureToInput(measure, variables, addFormulas); });
751
784
  }
752
785
 
753
786
  function mapDimensionToInput(dimension, variables) {
@@ -761,15 +794,14 @@ function mapDimensionToInput(dimension, variables) {
761
794
  return {
762
795
  alias: String(dimension.id),
763
796
  formula: formula,
797
+ dataType: dimension.dataType,
764
798
  hideEmpty: dimension.hideEmptyValues,
765
799
  displayConditionFormula: getDisplayConditionFormula(dimension.displayCondition),
766
800
  };
767
801
  }
768
802
  /** Конвертировать разрезы виджета во входы для вычислителя */
769
803
  function mapDimensionsToInputs(dimensions, variables) {
770
- return compactMap(dimensions, function (dimension) {
771
- return mapDimensionToInput(dimension, variables);
772
- });
804
+ return compactMap(dimensions, function (dimension) { return mapDimensionToInput(dimension, variables); });
773
805
  }
774
806
 
775
807
  function mapTransitionMeasureToInput(indicator, process, variables, addFormulas) {
@@ -784,6 +816,7 @@ function mapTransitionMeasureToInput(indicator, process, variables, addFormulas)
784
816
  return {
785
817
  alias: String(indicator.id),
786
818
  mainFormula: mainFormula,
819
+ dataType: indicator.dataType,
787
820
  displayConditionFormula: getDisplayConditionFormula(indicator.displayCondition),
788
821
  additionalFormulas: addFormulas(indicator),
789
822
  };
@@ -807,6 +840,7 @@ function mapEventMeasureToInput(indicator, process, variables, addFormulas) {
807
840
  return {
808
841
  alias: String(indicator.id),
809
842
  mainFormula: mainFormula,
843
+ dataType: indicator.dataType,
810
844
  displayConditionFormula: getDisplayConditionFormula(indicator.displayCondition),
811
845
  additionalFormulas: addFormulas(indicator),
812
846
  };
@@ -840,7 +874,7 @@ function mapSortingToInputs(sortingIndicators, dimensionsInOriginalOrder, measur
840
874
  if (value.mode === exports.ESortingValueModes.DIMENSION_IN_WIDGET ||
841
875
  value.mode === exports.ESortingValueModes.HIERARCHY) {
842
876
  var dimension = dimensionsInOriginalOrder[value.index];
843
- return (dimension && { formula: getDimensionFormula(dimension), direction: direction });
877
+ return dimension && { formula: getDimensionFormula(dimension), direction: direction };
844
878
  }
845
879
  if (value.mode === exports.ESortingValueModes.MEASURE_IN_WIDGET) {
846
880
  var measure = measuresInOriginalOrder[value.index];
@@ -868,9 +902,7 @@ function selectDimensionFromHierarchy(_a, filters) {
868
902
  if (!matchedFilter) {
869
903
  return "continue";
870
904
  }
871
- var selectionIndex = matchedFilter.values.length > 1
872
- ? i
873
- : Math.min(i + 1, dimensions.length - 1);
905
+ var selectionIndex = matchedFilter.values.length > 1 ? i : Math.min(i + 1, dimensions.length - 1);
874
906
  return { value: dimensions[selectionIndex] };
875
907
  };
876
908
  for (var i = dimensions.length - 1; i >= 0; i--) {
@@ -885,8 +917,7 @@ var replaceHierarchiesWithDimensions = function (dimensions, filters) {
885
917
  return compactMap(dimensions, function (indicator) {
886
918
  if (isHierarchy(indicator)) {
887
919
  var selectedDimension = selectDimensionFromHierarchy(indicator, filters);
888
- return (selectedDimension &&
889
- replaceDisplayCondition(selectedDimension, indicator.displayCondition));
920
+ return (selectedDimension && replaceDisplayCondition(selectedDimension, indicator.displayCondition));
890
921
  }
891
922
  return indicator;
892
923
  });
@@ -903,9 +934,7 @@ function bindContentWithIndicator(outputs, indicator) {
903
934
  * Массив объектов, каждый из которых содержит показатель и его контент
904
935
  */
905
936
  function bindContentsWithIndicators(outputs, indicators) {
906
- return compactMap(indicators, function (indicator) {
907
- return bindContentWithIndicator(outputs, indicator);
908
- });
937
+ return compactMap(indicators, function (indicator) { return bindContentWithIndicator(outputs, indicator); });
909
938
  }
910
939
 
911
940
  exports.EControlType = void 0;
@@ -927,6 +956,8 @@ exports.EControlType = void 0;
927
956
  EControlType["eventsColor"] = "eventsColor";
928
957
  EControlType["inputMarkdown"] = "inputMarkdown";
929
958
  EControlType["filter"] = "filter";
959
+ EControlType["actionOnClick"] = "actionOnClick";
960
+ EControlType["eventsPicker"] = "eventsPicker";
930
961
  })(exports.EControlType || (exports.EControlType = {}));
931
962
 
932
963
  exports.ESortDirection = void 0;
@@ -1031,11 +1062,11 @@ var getLocalizedText = function (language, locObj, props) {
1031
1062
  return localization.getLocalized(locObj, props);
1032
1063
  };
1033
1064
 
1034
- Object.defineProperty(exports, 'ELanguages', {
1065
+ Object.defineProperty(exports, "ELanguages", {
1035
1066
  enumerable: true,
1036
1067
  get: function () { return localization$1.ELanguages; }
1037
1068
  });
1038
- Object.defineProperty(exports, 'EFilteringMethodValues', {
1069
+ Object.defineProperty(exports, "EFilteringMethodValues", {
1039
1070
  enumerable: true,
1040
1071
  get: function () { return baseFilter.EFilteringMethodValues; }
1041
1072
  });
@@ -1043,6 +1074,7 @@ exports.bindContentWithIndicator = bindContentWithIndicator;
1043
1074
  exports.bindContentsWithIndicators = bindContentsWithIndicators;
1044
1075
  exports.checkDisplayCondition = checkDisplayCondition;
1045
1076
  exports.dimensionTemplateFormulas = dimensionTemplateFormulas;
1077
+ exports.escapeSpecialCharacters = escapeSpecialCharacters;
1046
1078
  exports.eventMeasureTemplateFormulas = eventMeasureTemplateFormulas;
1047
1079
  exports.fillTemplateString = fillTemplateString;
1048
1080
  exports.formulaFilterMethods = formulaFilterMethods;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infomaximum/widget-sdk",
3
- "version": "4.0.0-beta1",
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.0.3",
27
- "rollup": "4.4.1",
28
+ "prettier": "3.2.5",
29
+ "rollup": "4.14.3",
28
30
  "rollup-plugin-delete": "2.0.0",
29
31
  "rollup-plugin-dts": "6.1.0",
30
32
  "standard-version": "9.5.0",
31
33
  "tslib": "^2.4.1",
32
- "typescript": "5.2.2"
34
+ "typescript": "5.4.5"
33
35
  },
34
36
  "repository": {
35
37
  "type": "git",