@adaptabletools/adaptable 11.1.12 → 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.12",
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: 1651266602932;
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 = 1651266602932;
3
+ exports.default = 1651319806713;
@@ -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;
@@ -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
  {
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "11.1.12";
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.12'; // 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