@adaptabletools/adaptable 11.1.10 → 11.1.13

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": "11.1.10",
3
+ "version": "11.1.13",
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: 1651241561437;
1
+ declare const _default: 1651319806713;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = 1651241561437;
3
+ exports.default = 1651319806713;
@@ -41,7 +41,7 @@ export interface ConfigApi {
41
41
  */
42
42
  getPredefinedConfig(): PredefinedConfig | any;
43
43
  /**
44
- * Reloads either existing or supplied Predefined Config; deletes local storage and calls clearState function for remote storage removal
44
+ * Reloads either existing or supplied Predefined Config; clears persistent state by calling `StateOptions.clearState()` function for remote storage removal
45
45
  * @param newPredefinedConfig optional Config to load
46
46
  */
47
47
  reloadPredefinedConfig(newPredefinedConfig?: PredefinedConfig): void;
@@ -79,7 +79,7 @@ class ConfigApiImpl extends ApiBase_1.ApiBase {
79
79
  return Object.values(this.getPersistedState());
80
80
  }
81
81
  loadUserState(state) {
82
- this.dispatchAction(AdaptableStore_1.LoadState(state));
82
+ this.reloadPredefinedConfig(state);
83
83
  }
84
84
  getAdaptableSearchState() {
85
85
  const currentQuery = this.adaptable.api.queryApi.getCurrentQuery();
@@ -1,4 +1,5 @@
1
1
  import { AdaptableButton, ButtonContext } from './AdaptableButton';
2
+ import { AdaptableFormConfig } from '../../components/FormLayout';
2
3
  export declare type AdaptableFormData = Record<string, any>;
3
4
  /**
4
5
  * Defines a form which appears dynamically; used by Alerts & Export Custom Destinations
@@ -15,11 +16,15 @@ export interface AdaptableForm<T extends ButtonContext> {
15
16
  /**
16
17
  * Collection of Dynamic Fields to display
17
18
  */
18
- fields?: AdaptableFormField[];
19
+ fields?: (AdaptableFormField | AdaptableFormField[])[];
19
20
  /**
20
21
  * Buttons to include in the Form
21
22
  */
22
23
  buttons?: AdaptableButton<T>[];
24
+ /**
25
+ * @internal do NOT use this property as it's in an experimental phase
26
+ */
27
+ config?: AdaptableFormConfig;
23
28
  }
24
29
  /**
25
30
  * Defines a Field that appears in an Adaptable Form
@@ -34,9 +39,9 @@ export interface AdaptableFormField {
34
39
  */
35
40
  label: string;
36
41
  /**
37
- * Field Type: text, date, number, checkbox, select
42
+ * Field Type: text, date, number, checkbox, select, textOutput
38
43
  */
39
- fieldType: 'text' | 'select' | 'date' | 'number' | 'checkbox';
44
+ fieldType: 'text' | 'select' | 'date' | 'number' | 'checkbox' | 'textOutput';
40
45
  /**
41
46
  * Field Default Value - can be of type string, boolean, number
42
47
  */
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDefaultAdaptableFormData = void 0;
4
4
  function getDefaultAdaptableFormData(formDef) {
5
- return (formDef.fields || []).reduce((data, field) => {
5
+ return (formDef.fields || []).flat().reduce((data, field) => {
6
6
  var _a;
7
7
  data[field.name] = (_a = field.defaultValue) !== null && _a !== void 0 ? _a : '';
8
8
  return data;
@@ -619,9 +619,14 @@ class Adaptable {
619
619
  ? this.gridOptions.api.gridOptionsWrapper.layoutElements || []
620
620
  : []
621
621
  : [];
622
+ // aggrid 25.3.0 doesn't have layoutElements anymore, so we try to retrieve this element
622
623
  if (!layoutElements.length) {
623
- // aggrid 25.3.0 doesn't have layoutElements anymore, so we try to retrieve this element
624
- layoutElements.push(this.gridOptions.api.gridBodyCon.eGridBody);
624
+ const getGridBodyElement = (gridApi) => {
625
+ // @ts-ignore ctrlsService is private
626
+ const gridBodyCtrl = gridApi.ctrlsService.getGridBodyCtrl();
627
+ return gridBodyCtrl.getGridBodyElement();
628
+ };
629
+ layoutElements.push(getGridBodyElement(this.gridOptions.api));
625
630
  }
626
631
  let agGridContainer;
627
632
  for (let i = 0, len = layoutElements.length; i < len; i++) {
@@ -32,7 +32,7 @@ function AdaptableFormComponentButtons({ formDef, onClick, defaultTone, disabled
32
32
  }
33
33
  exports.AdaptableFormComponentButtons = AdaptableFormComponentButtons;
34
34
  function AdaptableFormComponent({ formDef, data, onChange, onButtonClick, displayTitle, api, context, focusFirstButton, }) {
35
- var _a;
35
+ var _a, _b, _c;
36
36
  const getFieldValue = (key) => data[key];
37
37
  const setFieldValue = (key, value) => {
38
38
  const newData = Object.assign(Object.assign({}, data), { [key]: value });
@@ -43,6 +43,9 @@ function AdaptableFormComponent({ formDef, data, onChange, onButtonClick, displa
43
43
  const isValid = !!button.disabled && !!context ? !button.disabled(button, context) : true;
44
44
  return !isValid;
45
45
  })) !== null && _b !== void 0 ? _b : []; }, [data]);
46
+ const renderLabel = (field) => {
47
+ return (React.createElement(rebass_1.Box, { className: 'ab-FormLayout_column--label', style: { textAlign: 'end' } }, field.label));
48
+ };
46
49
  const renderField = (field) => {
47
50
  var _a;
48
51
  const value = (_a = getFieldValue(field.name)) !== null && _a !== void 0 ? _a : '';
@@ -81,16 +84,35 @@ function AdaptableFormComponent({ formDef, data, onChange, onButtonClick, displa
81
84
  return (React.createElement(Input_1.default, { type: "checkbox", name: field.name, checked: value, onChange: (event) => {
82
85
  setFieldValue(field.name, event.target.checked);
83
86
  } }));
87
+ case 'textOutput':
88
+ return React.createElement(rebass_1.Box, { style: { textAlign: 'center' } }, value);
84
89
  default:
85
90
  return React.createElement("div", null,
86
91
  "Unknown field type: ",
87
92
  field.fieldType);
88
93
  }
89
94
  };
95
+ // by default we have 2 columns: label & input
96
+ const columns = (_b = (_a = formDef.config) === null || _a === void 0 ? void 0 : _a.columns) !== null && _b !== void 0 ? _b : [1, 2];
90
97
  return (React.createElement(React.Fragment, null,
91
98
  displayTitle && formDef.title && (React.createElement(rebass_1.Box, { fontSize: 5, mb: 2, style: { fontWeight: 'bold' } }, formDef.title)),
92
99
  formDef.description && React.createElement(rebass_1.Box, { mb: 3 }, formDef.description),
93
- React.createElement(FormLayout_1.default, null, (_a = formDef.fields) === null || _a === void 0 ? void 0 : _a.map((field) => (React.createElement(FormLayout_1.FormRow, { key: field.name, label: field.label }, renderField(field))))),
100
+ React.createElement(FormLayout_1.default, { columns: columns }, (_c = formDef.fields) === null || _c === void 0 ? void 0 : _c.map((field, index) => {
101
+ if (Array.isArray(field)) {
102
+ const rowFields = {};
103
+ field.map((fieldItem, index) => {
104
+ const rowFieldIndex = 2 * index + 1;
105
+ rowFields[rowFieldIndex] = renderLabel(fieldItem);
106
+ rowFields[rowFieldIndex + 1] = renderField(fieldItem);
107
+ });
108
+ return React.createElement(FormLayout_1.FormRow, Object.assign({ key: index }, rowFields));
109
+ }
110
+ else {
111
+ return (React.createElement(FormLayout_1.FormRow, { key: field.name },
112
+ renderLabel(field),
113
+ renderField(field)));
114
+ }
115
+ })),
94
116
  formDef.buttons ? (React.createElement(rebass_1.Flex, { marginTop: 3, flexDirection: "row", alignItems: "center", justifyContent: "center" },
95
117
  React.createElement(AdaptableFormComponentButtons, { focusFirstButton: focusFirstButton, onClick: onButtonClick, disabledButtons: disabledButtons, defaultTone: "success", formDef: formDef, api: api, context: context }))) : null));
96
118
  }
@@ -837,7 +837,7 @@ exports.ADAPTABLE_METAMODEL = {
837
837
  {
838
838
  "name": "fieldType",
839
839
  "kind": "unknown",
840
- "description": "Field Type: text, date, number, checkbox, select",
840
+ "description": "Field Type: text, date, number, checkbox, select, textOutput",
841
841
  "uiLabel": "Field Type"
842
842
  },
843
843
  {
@@ -3608,7 +3608,7 @@ exports.ADAPTABLE_METAMODEL = {
3608
3608
  {
3609
3609
  "name": "reloadPredefinedConfig",
3610
3610
  "kind": "function",
3611
- "description": "Reloads either existing or supplied Predefined Config; deletes local storage and calls clearState function for remote storage removal",
3611
+ "description": "Reloads either existing or supplied Predefined Config; clears persistent state by calling `StateOptions.clearState()` function for remote storage removal",
3612
3612
  "uiLabel": "Reload Predefined Config"
3613
3613
  },
3614
3614
  {
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "11.1.10";
1
+ declare const _default: "11.1.13";
2
2
  export default _default;
package/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '11.1.10'; // PLEASE DONT UPDATE THIS!!! - will be updated at build time with the correct version
3
+ exports.default = '11.1.13'; // PLEASE DONT UPDATE THIS!!! - will be updated at build time with the correct version