@adaptabletools/adaptable 16.1.0-canary.0 → 16.1.0-canary.2

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": "16.1.0-canary.0",
3
+ "version": "16.1.0-canary.2",
4
4
  "description": "Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements",
5
5
  "keywords": [
6
6
  "web-components",
@@ -1,2 +1,2 @@
1
- declare const _default: 1697536428665;
1
+ declare const _default: 1697637650202;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = 1697536428665;
3
+ exports.default = 1697637650202;
@@ -19,6 +19,16 @@ export interface DataImportOptions<T = Record<string, unknown>> {
19
19
  * Function to apply the Import (instead of AdapTable)
20
20
  */
21
21
  applyImport?: (context: DataImportApplyImportContext<T>) => void;
22
+ /**
23
+ * Function to preprocess the data before it is imported
24
+ */
25
+ preprocessData?: (context: PreprocessDataContext<T>) => Record<string, unknown>[];
26
+ }
27
+ export interface PreprocessDataContext<T = Record<string, unknown>> extends BaseContext {
28
+ /**
29
+ * Data which has been imported
30
+ */
31
+ data: T[];
22
32
  }
23
33
  /**
24
34
  * Context used when importing Data
@@ -7,15 +7,19 @@ const ApiBase_1 = require("../Implementation/ApiBase");
7
7
  class DataImportInternalApi extends ApiBase_1.ApiBase {
8
8
  async importData(partialRows) {
9
9
  const dataImportOptions = this.getOptions().dataImportOptions;
10
+ let importData = partialRows;
11
+ if (typeof dataImportOptions.preprocessData === 'function') {
12
+ importData = dataImportOptions.preprocessData(Object.assign({ data: partialRows }, (0, ObjectFactory_1.createBaseContext)(this.getAdaptableApi())));
13
+ }
10
14
  if (dataImportOptions.applyImport) {
11
- dataImportOptions.applyImport(Object.assign({ data: partialRows }, (0, ObjectFactory_1.createBaseContext)(this.getAdaptableApi())));
15
+ dataImportOptions.applyImport(Object.assign({ data: importData }, (0, ObjectFactory_1.createBaseContext)(this.getAdaptableApi())));
12
16
  return;
13
17
  }
14
18
  const gridApi = this.getGridApi();
15
19
  const primaryKey = this.getOptions().primaryKey;
16
20
  let newRows = 0;
17
21
  let updatedRows = 0;
18
- const preparedDataRows = partialRows.map((dataRow) => {
22
+ const preparedDataRows = importData.map((dataRow) => {
19
23
  const node = gridApi.getRowNodeForPrimaryKey(dataRow[primaryKey]);
20
24
  if (!node) {
21
25
  newRows += 1;
@@ -7,6 +7,7 @@ interface ExternalRendererProps {
7
7
  render?: Render;
8
8
  frameworkComponent?: AdaptableFrameworkComponent;
9
9
  onDestroy?: () => void;
10
+ style?: React.CSSProperties;
10
11
  }
11
12
  export declare const ExternalRenderer: React.FunctionComponent<ExternalRendererProps>;
12
13
  export {};
@@ -23,25 +23,29 @@ const WindowPopups = () => {
23
23
  return (React.createElement(React.Fragment, null, windowItems === null || windowItems === void 0 ? void 0 : windowItems.map((windowItem) => {
24
24
  var _a, _b, _c, _d, _e, _f;
25
25
  let Component = (_a = windowFactory_1.windowFactory[windowItem.FactoryId]) !== null && _a !== void 0 ? _a : null;
26
- if (!Component &&
27
- (windowItem.PopupProps.render || windowItem.PopupProps.frameworkComponent)) {
28
- // check if it is custom window
29
- Component = () => (React.createElement(ExternalRenderer_1.ExternalRenderer, { render: windowItem.PopupProps.render, frameworkComponent: windowItem.PopupProps.frameworkComponent, onDestroy: windowItem.PopupProps.onFrameworkComponentDestroyed }));
30
- }
31
- else {
32
- Component = Component !== null && Component !== void 0 ? Component : NoopComponent;
33
- }
34
26
  const _g = (_b = windowItem === null || windowItem === void 0 ? void 0 : windowItem.PopupProps) !== null && _b !== void 0 ? _b : {}, { windowModalProps } = _g, restPopupProps = tslib_1.__rest(_g, ["windowModalProps"]);
35
27
  const handleDismiss = () => {
36
28
  dispatch((0, PopupRedux_1.PopupHideWindow)(windowItem.Id));
37
29
  };
38
30
  const size = (_d = (_c = windowModalSettings === null || windowModalSettings === void 0 ? void 0 : windowModalSettings[windowItem.Id]) === null || _c === void 0 ? void 0 : _c.size) !== null && _d !== void 0 ? _d : (0, Utilities_1.getWindowPopupSize)();
39
31
  const position = (_f = (_e = windowModalSettings === null || windowModalSettings === void 0 ? void 0 : windowModalSettings[windowItem.Id]) === null || _e === void 0 ? void 0 : _e.position) !== null && _f !== void 0 ? _f : (0, Utilities_1.getMiddlePosition)(size);
32
+ let componentNode = null;
33
+ if (!Component &&
34
+ (windowItem.PopupProps.render || windowItem.PopupProps.frameworkComponent)) {
35
+ componentNode = (React.createElement(ExternalRenderer_1.ExternalRenderer
36
+ // TODO AFL: add configurable width&height for custom popups
37
+ , {
38
+ // TODO AFL: add configurable width&height for custom popups
39
+ style: { height: '100%' }, render: windowItem.PopupProps.render, frameworkComponent: windowItem.PopupProps.frameworkComponent, onDestroy: windowItem.PopupProps.onFrameworkComponentDestroyed }));
40
+ }
41
+ else {
42
+ Component = Component !== null && Component !== void 0 ? Component : NoopComponent;
43
+ componentNode = (React.createElement(Component, { api: adaptable.api, onDismiss: handleDismiss, popupProps: restPopupProps }));
44
+ }
40
45
  return (React.createElement(Dialog_1.default, { "data-name": windowItem.Id, style: { height: '100%' }, className: "ab-Window-Modal", key: windowItem.Id, windowModal: true, windowModalProps: Object.assign(Object.assign({}, windowModalProps), { onChange: (settings) => {
41
46
  setWindowModalSettings((settingsMap) => (Object.assign(Object.assign({}, settingsMap), { [windowItem.Id]: settings })));
42
47
  }, handleSelector: '.ab-Window-Modal .ab-Panel__header', size: size, position: position }), fixed: false, padding: 0, onDismiss: handleDismiss, isOpen: true, showCloseButton: true },
43
- React.createElement(PanelWithImage_1.PanelWithImage, { style: { height: '100%' }, bodyProps: { padding: 0, height: '100%' }, header: windowItem.Title, glyphicon: windowItem.Icon, variant: "primary" },
44
- React.createElement(Component, { api: adaptable.api, onDismiss: handleDismiss, popupProps: restPopupProps }))));
48
+ React.createElement(PanelWithImage_1.PanelWithImage, { style: { height: '100%' }, bodyProps: { padding: 0, height: '100%' }, header: windowItem.Title, glyphicon: windowItem.Icon, variant: "primary" }, componentNode)));
45
49
  })));
46
50
  };
47
51
  exports.WindowPopups = WindowPopups;