@adaptabletools/adaptable 13.0.0-canary.4 → 13.0.0-canary.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable",
3
- "version": "13.0.0-canary.4",
3
+ "version": "13.0.0-canary.6",
4
4
  "description": "Powerful data-agnostic HTML5 datagrid add-on that sits on top of an underlying grid component and provides all the rich functionality that advanced users expect from their DataGrids and Data Tables",
5
5
  "keywords": [
6
6
  "web-components",
@@ -1,2 +1,2 @@
1
- declare const _default: 1663256074117;
1
+ declare const _default: 1663306050735;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = 1663256074117;
3
+ exports.default = 1663306050735;
@@ -245,4 +245,9 @@ export interface FormatColumnApi {
245
245
  node: RowNode;
246
246
  value: any;
247
247
  }): boolean;
248
+ /**
249
+ * Retrieves all Format Columns which have an Expression
250
+ * @returns Format Columns with Expression
251
+ */
252
+ getFormatColumnsWithExpression(): FormatColumn[] | undefined;
248
253
  }
@@ -67,4 +67,5 @@ export declare class FormatColumnApiImpl extends ApiBase implements FormatColumn
67
67
  private evaluatePredicate;
68
68
  private shouldRunStyle;
69
69
  private evaluateExpression;
70
+ getFormatColumnsWithExpression(): FormatColumn[] | undefined;
70
71
  }
@@ -435,5 +435,8 @@ class FormatColumnApiImpl extends ApiBase_1.ApiBase {
435
435
  .getQueryLanguageService()
436
436
  .evaluateBooleanExpression(formatColumn.Rule.BooleanExpression, ModuleConstants.FormatColumnModuleId, node));
437
437
  }
438
+ getFormatColumnsWithExpression() {
439
+ return this.getAllFormatColumn().filter((fc) => { var _a; return !!((_a = fc.Rule) === null || _a === void 0 ? void 0 : _a.BooleanExpression); });
440
+ }
438
441
  }
439
442
  exports.FormatColumnApiImpl = FormatColumnApiImpl;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { FlexProps } from 'rebass';
3
- import type { AdaptablePredicate, AdaptablePredicateDef, AdaptableScope, AdaptableApi, AdaptableModule } from '../../../types';
3
+ import type { AdaptableApi, AdaptableModule, AdaptablePredicate, AdaptablePredicateDef, AdaptableScope } from '../../../types';
4
4
  import type { XOR } from '../../../Utilities/Extensions/TypeExtensions';
5
5
  import { AdaptableQuery } from '../../../PredefinedConfig/Common/AdaptableQuery';
6
6
  import { OnePageAdaptableWizardContextType } from '../../Wizard/OnePageAdaptableWizard';
@@ -13,6 +13,7 @@ export declare const isRuleValid: (abObject: {
13
13
  declare type EntityRulesEditorProps<T> = {
14
14
  data: T;
15
15
  module: AdaptableModule;
16
+ showNoRule?: boolean;
16
17
  showPredicate?: boolean;
17
18
  showObservable?: boolean;
18
19
  showAggregation?: boolean;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EntityRulesEditor = exports.EntityRulesSummary = exports.isRuleValid = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const React = tslib_1.__importStar(require("react"));
6
+ const react_1 = require("react");
6
7
  const rebass_1 = require("rebass");
7
8
  const Tabs_1 = require("../../../components/Tabs");
8
9
  const Radio_1 = tslib_1.__importDefault(require("../../../components/Radio"));
@@ -13,7 +14,6 @@ const AdaptableInput_1 = tslib_1.__importDefault(require("../AdaptableInput"));
13
14
  const AdaptableContext_1 = require("../../AdaptableContext");
14
15
  const ButtonInfo_1 = require("../Buttons/ButtonInfo");
15
16
  const DocumentationLinkConstants_1 = require("../../../Utilities/Constants/DocumentationLinkConstants");
16
- const react_1 = require("react");
17
17
  const PermittedValuesSelector_1 = require("../PermittedValuesSelector");
18
18
  const isRuleValid = (abObject, api, context) => {
19
19
  var _a, _b, _c, _d, _e, _f;
@@ -52,20 +52,26 @@ const EntityRulesSummary = (props) => {
52
52
  };
53
53
  exports.EntityRulesSummary = EntityRulesSummary;
54
54
  const EntityRulesEditor = (props) => {
55
- var _a, _b;
56
- const { data, children, descriptions, predicateDefs, showPredicate = true, showObservable = true, showBoolean = true, showAggregation = true, flexProps, module, } = props;
55
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
56
+ const { data, children, descriptions, predicateDefs, showNoRule = false, showPredicate = true, showObservable = true, showBoolean = true, showAggregation = true, flexProps, module, } = props;
57
57
  const { api } = (0, AdaptableContext_1.useAdaptable)();
58
- const type = data.Rule.BooleanExpression != undefined
59
- ? 'BooleanExpression'
60
- : data.Rule.ObservableExpression != undefined && showObservable
61
- ? 'ObservableExpression'
62
- : data.Rule.AggregatedBooleanExpression != undefined && showAggregation
63
- ? 'AggregatedBooleanExpression'
64
- : 'Predicate';
58
+ const type = data.Rule == undefined
59
+ ? 'NoRule'
60
+ : data.Rule.BooleanExpression != undefined
61
+ ? 'BooleanExpression'
62
+ : data.Rule.ObservableExpression != undefined && showObservable
63
+ ? 'ObservableExpression'
64
+ : data.Rule.AggregatedBooleanExpression != undefined && showAggregation
65
+ ? 'AggregatedBooleanExpression'
66
+ : 'Predicate';
65
67
  const [selectedTab, setSelectedTab] = React.useState(type);
66
68
  const setType = (type) => {
67
69
  setSelectedTab(type);
68
- if (type === 'BooleanExpression' && showBoolean) {
70
+ if (type === 'NoRule' && showNoRule) {
71
+ delete data.Rule;
72
+ props.onChange(Object.assign({}, data));
73
+ }
74
+ else if (type === 'BooleanExpression' && showBoolean) {
69
75
  props.onChange(Object.assign(Object.assign({}, data), { Rule: {
70
76
  BooleanExpression: '',
71
77
  } }));
@@ -88,8 +94,8 @@ const EntityRulesEditor = (props) => {
88
94
  } }));
89
95
  }
90
96
  };
91
- const predicateId = data.Rule.Predicate != undefined ? data.Rule.Predicate.PredicateId : undefined;
92
- const predicateInputs = predicateId ? (_a = data.Rule.Predicate.Inputs) !== null && _a !== void 0 ? _a : [] : [];
97
+ const predicateId = ((_a = data.Rule) === null || _a === void 0 ? void 0 : _a.Predicate) != undefined ? (_b = data.Rule) === null || _b === void 0 ? void 0 : _b.Predicate.PredicateId : undefined;
98
+ const predicateInputs = predicateId ? (_d = (_c = data.Rule) === null || _c === void 0 ? void 0 : _c.Predicate.Inputs) !== null && _d !== void 0 ? _d : [] : [];
93
99
  const currentPredicateDef = api.predicateApi.getPredicateDefById(predicateId);
94
100
  const isValuesPredicateDef = (colDef) => colDef && ['Values', 'ExcludeValues'].includes(colDef.id);
95
101
  const predicateDefsOptions = predicateDefs
@@ -158,6 +164,10 @@ const EntityRulesEditor = (props) => {
158
164
  return (React.createElement(rebass_1.Flex, Object.assign({ flexDirection: "column", padding: 2, pt: 0, pl: 0 }, flexProps, { style: Object.assign({ height: '100%' }, flexProps === null || flexProps === void 0 ? void 0 : flexProps.style) }),
159
165
  children,
160
166
  React.createElement(Tabs_1.Tabs, { onValueChange: setType, value: selectedTab, pt: 2, pl: 2, style: { flex: 1, overflow: 'auto' } },
167
+ showNoRule ? (React.createElement(Tabs_1.Tabs.Tab, { value: 'NoRule', style: { flex: 1 } },
168
+ React.createElement(Radio_1.default, { tabIndex: -1, margin: 0, checked: type === 'NoRule' }, "No Condition"))) : null,
169
+ showNoRule ? (React.createElement(Tabs_1.Tabs.Content, { value: 'NoRule' },
170
+ React.createElement(rebass_1.Text, { fontSize: 2, mb: 2 }, 'Format Column is always applied'))) : null,
161
171
  showPredicate ? (React.createElement(Tabs_1.Tabs.Tab, { value: 'Predicate', style: { flex: 1 } },
162
172
  React.createElement(Radio_1.default, { tabIndex: -1, margin: 0, checked: type === 'Predicate' }, "Predicate"))) : null,
163
173
  showPredicate ? (React.createElement(Tabs_1.Tabs.Content, { value: "Predicate" },
@@ -168,13 +178,13 @@ const EntityRulesEditor = (props) => {
168
178
  overflow: 'hidden',
169
179
  textOverflow: 'ellipsis',
170
180
  maxWidth: 'inherit',
171
- }, placeholder: "Select Rule", showClearButton: !!data.Rule.Predicate, onClear: clearPredicate, items: predicateDefsOptions, columns: ['label'] }, currentPredicateDef ? currentPredicateDef.label : 'Select Rule'), (_b = currentPredicateDef === null || currentPredicateDef === void 0 ? void 0 : currentPredicateDef.inputs) === null || _b === void 0 ? void 0 :
172
- _b.map((predicateDefInput, index) => (React.createElement(rebass_1.Flex, { key: predicateId + index, flexDirection: "column" },
181
+ }, placeholder: "Select Rule", showClearButton: !!((_e = data.Rule) === null || _e === void 0 ? void 0 : _e.Predicate), onClear: clearPredicate, items: predicateDefsOptions, columns: ['label'] }, currentPredicateDef ? currentPredicateDef.label : 'Select Rule'), (_f = currentPredicateDef === null || currentPredicateDef === void 0 ? void 0 : currentPredicateDef.inputs) === null || _f === void 0 ? void 0 :
182
+ _f.map((predicateDefInput, index) => (React.createElement(rebass_1.Flex, { key: predicateId + index, flexDirection: "column" },
173
183
  index > 0 && React.createElement(HelpBlock_1.default, { marginTop: 2 }, "AND"),
174
184
  React.createElement(AdaptableInput_1.default, { marginTop: 2, type: predicateDefInput.type, autoFocus: index === 0, value: predicateInputs[index], onChange: (e) => onPredicateInputChange(e, index) })))),
175
185
  isValuesPredicateDef(currentPredicateDef) &&
176
186
  'ColumnIds' in data.Scope &&
177
- data.Scope.ColumnIds.length === 1 && (React.createElement(PermittedValuesSelector_1.PermitedValuesSelector, { onPredicateValuesChange: onPredicateValuesChange, predicate: data.Rule.Predicate, scope: data.Scope })),
187
+ data.Scope.ColumnIds.length === 1 && (React.createElement(PermittedValuesSelector_1.PermitedValuesSelector, { onPredicateValuesChange: onPredicateValuesChange, predicate: (_g = data.Rule) === null || _g === void 0 ? void 0 : _g.Predicate, scope: data.Scope })),
178
188
  showDocumentationLinks && (React.createElement(HelpBlock_1.default, { "data-name": "query-documentation", mt: 3, mb: 2, style: {
179
189
  fontSize: 'var(--ab-font-size-3)',
180
190
  padding: 0,
@@ -187,12 +197,12 @@ const EntityRulesEditor = (props) => {
187
197
  "See Predicate documentation for more details and examples")))) : null,
188
198
  showBoolean ? React.createElement(QueryTab, { value: "BooleanExpression", type: type, label: "Boolean" }) : null,
189
199
  showBoolean ? (React.createElement(Tabs_1.Tabs.Content, { value: 'BooleanExpression', paddingLeft: 0 },
190
- React.createElement(ExpressionEditor_1.ExpressionEditor, { type: 'boolean', module: module, value: data.Rule.BooleanExpression, onChange: setBooleanExpression, initialData: initialData, columns: api.columnApi.getQueryableColumns(), namedQueries: api.queryApi.getAllNamedQuery(), api: api }))) : null,
200
+ React.createElement(ExpressionEditor_1.ExpressionEditor, { type: 'boolean', module: module, value: (_h = data.Rule) === null || _h === void 0 ? void 0 : _h.BooleanExpression, onChange: setBooleanExpression, initialData: initialData, columns: api.columnApi.getQueryableColumns(), namedQueries: api.queryApi.getAllNamedQuery(), api: api }))) : null,
191
201
  showObservable ? (React.createElement(QueryTab, { value: "ObservableExpression", type: type, label: "Observable" })) : null,
192
202
  showObservable ? (React.createElement(Tabs_1.Tabs.Content, { value: 'ObservableExpression', paddingLeft: 0 },
193
- React.createElement(ExpressionEditor_1.ExpressionEditor, { type: 'observable', module: module, value: data.Rule.ObservableExpression, onChange: setReactiveExpression, initialData: initialData, columns: api.columnApi.getQueryableColumns(), namedQueries: api.queryApi.getAllNamedQuery(), api: api }))) : null,
203
+ React.createElement(ExpressionEditor_1.ExpressionEditor, { type: 'observable', module: module, value: (_j = data.Rule) === null || _j === void 0 ? void 0 : _j.ObservableExpression, onChange: setReactiveExpression, initialData: initialData, columns: api.columnApi.getQueryableColumns(), namedQueries: api.queryApi.getAllNamedQuery(), api: api }))) : null,
194
204
  showAggregation ? (React.createElement(QueryTab, { value: "AggregatedBooleanExpression", type: type, label: "Aggregated Boolean" })) : null,
195
205
  showAggregation ? (React.createElement(Tabs_1.Tabs.Content, { value: 'AggregatedBooleanExpression', paddingLeft: 0 },
196
- React.createElement(ExpressionEditor_1.ExpressionEditor, { type: 'aggregatedBoolean', module: module, value: data.Rule.AggregatedBooleanExpression, onChange: setAggregationExpression, initialData: initialData, columns: api.columnApi.getQueryableColumns(), namedQueries: api.queryApi.getAllNamedQuery(), api: api }))) : null)));
206
+ React.createElement(ExpressionEditor_1.ExpressionEditor, { type: 'aggregatedBoolean', module: module, value: (_k = data.Rule) === null || _k === void 0 ? void 0 : _k.AggregatedBooleanExpression, onChange: setAggregationExpression, initialData: initialData, columns: api.columnApi.getQueryableColumns(), namedQueries: api.queryApi.getAllNamedQuery(), api: api }))) : null)));
197
207
  };
198
208
  exports.EntityRulesEditor = EntityRulesEditor;
@@ -4,6 +4,5 @@ declare type FormatColumnRuleWizardSectionProps = {
4
4
  onChange: (data: FormatColumn) => void;
5
5
  defaultPredicateId: string;
6
6
  };
7
- export declare function renderFormatColumnRuleSummary(data: FormatColumn): JSX.Element;
8
7
  export declare function FormatColumnRuleWizardSection(props: FormatColumnRuleWizardSectionProps): JSX.Element;
9
8
  export {};
@@ -1,66 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormatColumnRuleWizardSection = exports.renderFormatColumnRuleSummary = void 0;
3
+ exports.FormatColumnRuleWizardSection = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const React = tslib_1.__importStar(require("react"));
6
- const rebass_1 = require("rebass");
7
6
  const OnePageAdaptableWizard_1 = require("../../Wizard/OnePageAdaptableWizard");
8
7
  const EntityRulesEditor_1 = require("../../Components/EntityRulesEditor");
9
- const CodeBlock_1 = require("../../../components/CodeBlock");
10
- const CheckBox_1 = require("../../../components/CheckBox");
11
- const constants_1 = require("./constants");
12
- function renderFormatColumnRuleSummary(data) {
13
- return (React.createElement(EntityRulesEditor_1.EntityRulesSummary, { data: data, renderPredicate: (contents) => {
14
- return (React.createElement(React.Fragment, null,
15
- "Apply Format Column on ",
16
- React.createElement(CodeBlock_1.CodeBlock, null, contents)));
17
- }, renderQueryExpression: (contents) => {
18
- return (React.createElement(React.Fragment, null,
19
- "Apply Format Column when",
20
- ' ',
21
- React.createElement("b", null,
22
- React.createElement(CodeBlock_1.CodeBlock, null, contents))));
23
- } }));
24
- }
25
- exports.renderFormatColumnRuleSummary = renderFormatColumnRuleSummary;
26
8
  function FormatColumnRuleWizardSection(props) {
27
9
  const { data, api, moduleInfo } = (0, OnePageAdaptableWizard_1.useOnePageAdaptableWizardContext)();
28
- const hasRule = Boolean(data.Rule);
29
- const handleRuleToggle = React.useCallback(() => {
30
- const newFormatColumn = Object.assign({}, data);
31
- if (hasRule) {
32
- delete newFormatColumn.Rule;
33
- }
34
- else {
35
- newFormatColumn.Rule = {
36
- Predicate: {
37
- PredicateId: constants_1.DEFAULT_PREDICATE_ID_FOR_FORMAT_COLUMN,
38
- },
39
- };
40
- }
41
- props.onChange(newFormatColumn);
42
- }, [data.Rule]);
43
10
  const hasIncompatibleStyle = Boolean(data.ColumnStyle);
44
- return (React.createElement(rebass_1.Box, null,
45
- React.createElement(rebass_1.Box, { p: 2, mb: 1 },
46
- React.createElement(CheckBox_1.CheckBox, { disabled: hasIncompatibleStyle, checked: hasRule, onClick: handleRuleToggle }, "Enable Condition"),
47
- hasIncompatibleStyle && (React.createElement(rebass_1.Text, { ml: 1 }, "Condition is only available for Standard Style."))),
48
- hasRule && (React.createElement(EntityRulesEditor_1.EntityRulesEditor, { module: moduleInfo.ModuleName, defaultPredicateId: props.defaultPredicateId,
49
- // TODO see what is this
50
- predicateDefs: api.formatColumnApi.getFormatColumnDefsForScope(data.Scope), showAggregation: false, showObservable: false, showPredicate: !api.scopeApi.scopeIsAll(data.Scope), data: data, onChange: (formatColumn) => props.onChange(formatColumn), descriptions: {
51
- selectPredicate: 'Select a Format Column Rule - to be applied when data changes',
52
- useBooleanQuery: (React.createElement(React.Fragment, null,
53
- "Use an BooleanQuery if ",
54
- React.createElement("i", null, "Scope"),
55
- " is 'Whole Row' - so any data change may be evaluated in a complex BooleanExpression")),
56
- useObservableQuery: (React.createElement(React.Fragment, null,
57
- "Use an ObservableQuery if ",
58
- React.createElement("i", null, "Scope"),
59
- " is 'Whole Row' - so any data change may be evaluated in a complex ObservableExpression")),
60
- useAggregationQuery: (React.createElement(React.Fragment, null,
61
- "Use an AggregatedBooleanQuery if ",
62
- React.createElement("i", null, "Scope"),
63
- " is 'Whole Row' - so any data change may be evaluated in a complex AggregatedBooleanExpression")),
64
- } }))));
11
+ return (React.createElement(EntityRulesEditor_1.EntityRulesEditor, { module: moduleInfo.ModuleName, defaultPredicateId: props.defaultPredicateId,
12
+ // TODO see what is this
13
+ predicateDefs: api.formatColumnApi.getFormatColumnDefsForScope(data.Scope), showNoRule: true, showBoolean: !hasIncompatibleStyle, showAggregation: false, showObservable: false, showPredicate: !hasIncompatibleStyle && !api.scopeApi.scopeIsAll(data.Scope), data: data, onChange: (formatColumn) => props.onChange(formatColumn), descriptions: {
14
+ selectPredicate: 'Select a Format Column Rule - to be applied when data changes',
15
+ useBooleanQuery: (React.createElement(React.Fragment, null,
16
+ "Use an BooleanQuery if ",
17
+ React.createElement("i", null, "Scope"),
18
+ " is 'Whole Row' - so any data change may be evaluated in a complex BooleanExpression")),
19
+ useObservableQuery: (React.createElement(React.Fragment, null,
20
+ "Use an ObservableQuery if ",
21
+ React.createElement("i", null, "Scope"),
22
+ " is 'Whole Row' - so any data change may be evaluated in a complex ObservableExpression")),
23
+ useAggregationQuery: (React.createElement(React.Fragment, null,
24
+ "Use an AggregatedBooleanQuery if ",
25
+ React.createElement("i", null, "Scope"),
26
+ " is 'Whole Row' - so any data change may be evaluated in a complex AggregatedBooleanExpression")),
27
+ } }));
65
28
  }
66
29
  exports.FormatColumnRuleWizardSection = FormatColumnRuleWizardSection;
@@ -123,8 +123,7 @@ function FormatColumnWizard(props) {
123
123
  title: 'Condition',
124
124
  details: 'Build the rules when Format column should be applied',
125
125
  render: () => {
126
- return (React.createElement(rebass_1.Box, { p: 2 },
127
- React.createElement(FormatColumnRuleWizardSection_1.FormatColumnRuleWizardSection, { onChange: setFormatColumn, defaultPredicateId: constants_1.DEFAULT_PREDICATE_ID_FOR_FORMAT_COLUMN })));
126
+ return (React.createElement(FormatColumnRuleWizardSection_1.FormatColumnRuleWizardSection, { onChange: setFormatColumn, defaultPredicateId: constants_1.DEFAULT_PREDICATE_ID_FOR_FORMAT_COLUMN }));
128
127
  },
129
128
  },
130
129
  {
@@ -3733,23 +3733,25 @@ class Adaptable {
3733
3733
  firstInfo.trigger == 'tick' ? this.filterOnTickingDataChange() : this.filterOnEditDataChange();
3734
3734
  }
3735
3735
  getExpressionStylesChanges(dataChangedScope, cellDataChangedInfos) {
3736
- const stylesWithExpression = this.api.conditionalStyleApi.getConditionalStylesWithExpression();
3736
+ const stylesWithExpression = [];
3737
+ stylesWithExpression.push(...this.api.conditionalStyleApi.getConditionalStylesWithExpression());
3738
+ stylesWithExpression.push(...this.api.formatColumnApi.getFormatColumnsWithExpression());
3737
3739
  if (ArrayExtensions_1.ArrayExtensions.IsNullOrEmpty(stylesWithExpression)) {
3738
3740
  return;
3739
3741
  }
3740
3742
  cellDataChangedInfos.forEach((cellDataChangedInfo) => {
3741
3743
  if (!dataChangedScope.wholeRow) {
3742
- stylesWithExpression.forEach((conditionalStyle) => {
3744
+ stylesWithExpression.forEach((styleModule) => {
3743
3745
  if (!dataChangedScope.wholeRow) {
3744
- const columnIds = this.api.queryLanguageApi.getColumnsFromExpression(conditionalStyle.Rule.BooleanExpression);
3746
+ const columnIds = this.api.queryLanguageApi.getColumnsFromExpression(styleModule.Rule.BooleanExpression);
3745
3747
  if (columnIds.includes(cellDataChangedInfo.column.columnId)) {
3746
- if (this.api.scopeApi.scopeIsAll(conditionalStyle.Scope)) {
3748
+ if (this.api.scopeApi.scopeIsAll(styleModule.Scope)) {
3747
3749
  dataChangedScope.wholeRow = true;
3748
3750
  return;
3749
3751
  }
3750
3752
  else {
3751
3753
  this.api.scopeApi
3752
- .getColumnsForScope(conditionalStyle.Scope)
3754
+ .getColumnsForScope(styleModule.Scope)
3753
3755
  .map((c) => c.columnId)
3754
3756
  .forEach((colId) => {
3755
3757
  dataChangedScope.columnIds.add(colId);