@adaptabletools/adaptable 12.0.0-canary.1 → 12.0.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.
Files changed (68) hide show
  1. package/bundle.cjs.js +90 -90
  2. package/package.json +1 -1
  3. package/publishTimestamp.d.ts +1 -1
  4. package/publishTimestamp.js +1 -1
  5. package/src/AdaptableInterfaces/AdaptableNoCodeWizard.d.ts +1 -0
  6. package/src/Api/Implementation/FormatColumnApiImpl.js +2 -2
  7. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/ColumnsList.d.ts +8 -3
  8. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/ColumnsList.js +3 -2
  9. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/ConfigurationForm.js +9 -2
  10. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/ConfigurationWizard.d.ts +18 -0
  11. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/ConfigurationWizard.js +87 -0
  12. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/ConfigurationWizardColumnsStep.d.ts +18 -0
  13. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/ConfigurationWizardColumnsStep.js +16 -0
  14. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/index.d.ts +2 -9
  15. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/index.js +2 -75
  16. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/useSelection.d.ts +3 -1
  17. package/src/View/AdaptableWizardView/AdaptableConfigurationDialog/useSelection.js +9 -4
  18. package/src/View/AdaptableWizardView/Utils.d.ts +1 -0
  19. package/src/View/AdaptableWizardView/Utils.js +24 -0
  20. package/src/View/AdaptableWizardView/Wizard.d.ts +54 -0
  21. package/src/View/AdaptableWizardView/Wizard.js +98 -0
  22. package/src/View/AdaptableWizardView/index.d.ts +1 -22
  23. package/src/View/AdaptableWizardView/index.js +2 -103
  24. package/src/View/Alert/Wizard/AlertBehaviourWizardSection.js +1 -1
  25. package/src/View/Alert/Wizard/AlertDisplayWizardSection.js +2 -2
  26. package/src/View/Alert/Wizard/BaseAlertRulesWizardSection.js +1 -1
  27. package/src/View/Alert/Wizard/BaseAlertScopeWizardSection.js +2 -2
  28. package/src/View/CalculatedColumn/Wizard/CalculatedColumnExpressionWizardSection.js +1 -1
  29. package/src/View/CalculatedColumn/Wizard/CalculatedColumnSettingsWizardSection.js +1 -1
  30. package/src/View/ConditionalStyle/Wizard/ConditionalStyleRuleWizardSection.js +1 -1
  31. package/src/View/ConditionalStyle/Wizard/ConditionalStyleScopeWizardSection.js +1 -1
  32. package/src/View/ConditionalStyle/Wizard/ConditionalStyleSettingsWizardSettings.js +1 -1
  33. package/src/View/ConditionalStyle/Wizard/ConditionalStyleStyleWizardSection.js +1 -1
  34. package/src/View/CustomSort/Wizard/CustomSortColumnWizardSection.js +2 -2
  35. package/src/View/CustomSort/Wizard/CustomSortValuesWizardSection.js +1 -1
  36. package/src/View/Export/Wizard/ReportColumnsWizardSection.js +1 -1
  37. package/src/View/Export/Wizard/ReportNameWizardSection.js +1 -1
  38. package/src/View/Export/Wizard/ReportRowsWizardSection.js +1 -1
  39. package/src/View/FlashingCell/Wizard/FlashingCellRulesWizardSection.js +2 -2
  40. package/src/View/FlashingCell/Wizard/FlashingCellScopeWizardSection.js +1 -1
  41. package/src/View/FlashingCell/Wizard/FlashingCellSettingsWizardSection.js +1 -1
  42. package/src/View/FlashingCell/Wizard/FlashingCellStyleWizardSection.js +1 -1
  43. package/src/View/FormatColumn/Wizard/FormatColumnFormatWizardSection.js +1 -1
  44. package/src/View/FormatColumn/Wizard/FormatColumnScopeWizardSection.js +1 -1
  45. package/src/View/FormatColumn/Wizard/FormatColumnSettingsWizardSection.js +1 -1
  46. package/src/View/FormatColumn/Wizard/FormatColumnStyleWizardSection.js +1 -1
  47. package/src/View/FreeTextColumn/Wizard/FreeTextColumnSettingsWizardSection.js +1 -1
  48. package/src/View/PlusMinus/Wizard/PlusMinusRuleWizardSection.js +2 -2
  49. package/src/View/PlusMinus/Wizard/PlusMinusScopeWizardSection.js +1 -1
  50. package/src/View/PlusMinus/Wizard/PlusMinusSettingsWizardSection.js +2 -2
  51. package/src/View/Query/Wizard/NamedQueryExpressionWizardSection.js +1 -1
  52. package/src/View/Query/Wizard/NamedQuerySettingsWizardSection.js +1 -1
  53. package/src/View/Schedule/Wizard/ScheduleScheduleSummary.js +1 -1
  54. package/src/View/Schedule/Wizard/ScheduleScheduleWizard.js +1 -1
  55. package/src/View/Schedule/Wizard/ScheduleSettingsWizard/ScheduleSettingsSummary.js +1 -1
  56. package/src/View/Schedule/Wizard/ScheduleSettingsWizard/ScheduleSettingsWizard.js +1 -1
  57. package/src/View/Shortcut/Wizard/ShortcutScopeWizardSection.js +1 -1
  58. package/src/View/Shortcut/Wizard/ShortcutSettingsWizard.js +2 -2
  59. package/src/View/Wizard/Interface/IAdaptableWizard.d.ts +2 -2
  60. package/src/View/Wizard/ObjectTagsWizardSection.js +1 -1
  61. package/src/View/Wizard/OnePageAdaptableWizard.d.ts +5 -6
  62. package/src/View/Wizard/OnePageAdaptableWizard.js +35 -169
  63. package/src/View/Wizard/OnePageWizards.d.ts +37 -0
  64. package/src/View/Wizard/OnePageWizards.js +187 -0
  65. package/src/View/Wizard/useKeyboardNavigation.d.ts +1 -1
  66. package/src/components/WindowModal/WindowModal.js +13 -7
  67. package/version.d.ts +1 -1
  68. package/version.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable",
3
- "version": "12.0.0-canary.1",
3
+ "version": "12.0.0-canary.2",
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: 1654683345204;
1
+ declare const _default: 1654688737709;
2
2
  export default _default;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = 1654683345204;
3
+ exports.default = 1654688737709;
@@ -16,6 +16,7 @@ export interface AdaptableNoCodeWizardOptions {
16
16
  helpText?: React.ReactNode;
17
17
  fileContentsToJSON?: (str: string) => Promise<any> | any;
18
18
  readFile?: (file: File) => Promise<any>;
19
+ skipToWizard?: boolean;
19
20
  loadingMessage?: React.ReactNode;
20
21
  prepareData?: (data: any, file?: File) => {
21
22
  columns: string[];
@@ -275,13 +275,13 @@ class FormatColumnApiImpl extends ApiBase_1.ApiBase {
275
275
  this.adaptable.api.eventApi.emit('CheckboxColumnClicked', checkboxColumnClickedInfo);
276
276
  }
277
277
  applyCustomFormatters(value, options) {
278
- var _a, _b;
278
+ var _a, _b, _c;
279
279
  const columnCustomFormatters = (_a = options === null || options === void 0 ? void 0 : options.CustomDisplayFormats) !== null && _a !== void 0 ? _a : [];
280
280
  if (!(columnCustomFormatters === null || columnCustomFormatters === void 0 ? void 0 : columnCustomFormatters.length)) {
281
281
  return value;
282
282
  }
283
283
  const adaptableOptions = this.adaptable.adaptableOptions;
284
- const customFormattersFromOptions = (_b = adaptableOptions === null || adaptableOptions === void 0 ? void 0 : adaptableOptions.userInterfaceOptions) === null || _b === void 0 ? void 0 : _b.customDisplayFormatters;
284
+ const customFormattersFromOptions = (_c = (_b = adaptableOptions === null || adaptableOptions === void 0 ? void 0 : adaptableOptions.userInterfaceOptions) === null || _b === void 0 ? void 0 : _b.customDisplayFormatters) !== null && _c !== void 0 ? _c : [];
285
285
  // formatters are applied in the order they are defined in the options
286
286
  const customFormatters = customFormattersFromOptions.filter((customFormatterOption) => columnCustomFormatters.includes(customFormatterOption.id));
287
287
  return customFormatters.reduce((acc, formatter) => {
@@ -1,13 +1,18 @@
1
1
  import * as React from 'react';
2
2
  import { ColDef } from '@ag-grid-community/all-modules';
3
- interface Column extends Partial<ColDef> {
3
+ export interface NocodeColumn extends Partial<ColDef> {
4
4
  field?: string;
5
5
  type?: string | string[];
6
6
  caption?: string;
7
7
  }
8
- declare const _default: React.MemoExoticComponent<({ columns: cols, handle, onValidityChange, }: {
8
+ declare const _default: React.MemoExoticComponent<({ columns: cols, handle, onValidityChange, onChange, onSelectionChange, selectedColumns, }: {
9
9
  onValidityChange: (valid: boolean) => any;
10
10
  handle: React.MutableRefObject<any>;
11
- columns: Column[];
11
+ columns: NocodeColumn[];
12
+ onChange?: (columns: NocodeColumn[]) => void;
13
+ onSelectionChange?: (column: any, flag: boolean) => void;
14
+ selectedColumns?: {
15
+ [key: string]: boolean;
16
+ };
12
17
  }) => JSX.Element>;
13
18
  export default _default;
@@ -37,11 +37,12 @@ const useForceRender = () => {
37
37
  setNow(Date.now());
38
38
  };
39
39
  };
40
- const ColumnsList = ({ columns: cols, handle, onValidityChange, }) => {
40
+ const ColumnsList = ({ columns: cols, handle, onValidityChange, onChange, onSelectionChange, selectedColumns, }) => {
41
41
  const rerender = useForceRender();
42
42
  const columnsRef = react_1.useRef(cols);
43
43
  const silentSetColumns = (columns) => {
44
44
  columnsRef.current = columns;
45
+ onChange === null || onChange === void 0 ? void 0 : onChange(columns);
45
46
  };
46
47
  const setColumns = (columns) => {
47
48
  silentSetColumns(columns);
@@ -83,7 +84,7 @@ const ColumnsList = ({ columns: cols, handle, onValidityChange, }) => {
83
84
  setColumns(cols);
84
85
  };
85
86
  const [primaryKeyField, setPrimaryKeyField] = React.useState(columns[0].field);
86
- const { selected: includedColumnsMap, isSelected: isIncludedColumn, isAllSelected: isAllIncludedColumns, isNoneSelected: isNoneIncludedColumns, selectColumn: includeColumn, deselectColumn: excludeColumn, selectAll: includeAllColumns, deselectAll: excludeAllColumns, } = useSelection_1.default(columns, true, null);
87
+ const { selected: includedColumnsMap, isSelected: isIncludedColumn, isAllSelected: isAllIncludedColumns, isNoneSelected: isNoneIncludedColumns, selectColumn: includeColumn, deselectColumn: excludeColumn, selectAll: includeAllColumns, deselectAll: excludeAllColumns, } = useSelection_1.default(columns, selectedColumns !== null && selectedColumns !== void 0 ? selectedColumns : true, null, { onChange: onSelectionChange });
87
88
  handle.current = {
88
89
  getColumns: () => getColumns().filter((col) => isIncludedColumn(col.field)),
89
90
  getPrimaryKey: () => primaryKeyField,
@@ -9,7 +9,7 @@ const Input_1 = tslib_1.__importDefault(require("../../../components/Input"));
9
9
  const rebass_1 = require("rebass");
10
10
  const DefaultAdaptableOptions_1 = require("../../../Utilities/Defaults/DefaultAdaptableOptions");
11
11
  const ConfigurationForm = (props) => {
12
- var _a;
12
+ var _a, _b, _c;
13
13
  let abOptions = props.adaptableOptions;
14
14
  const layoutOptions = Object.assign(Object.assign({}, DefaultAdaptableOptions_1.DefaultAdaptableOptions.layoutOptions), abOptions.layoutOptions);
15
15
  const generalOptions = Object.assign(Object.assign({}, DefaultAdaptableOptions_1.DefaultAdaptableOptions.generalOptions), abOptions.generalOptions);
@@ -20,6 +20,13 @@ const ConfigurationForm = (props) => {
20
20
  // we are 'hard-coding' this to use AG Grid but so does helper so ok for now and we can refactor when Adaptable Grid is ready
21
21
  const gridOptions = Object.assign(Object.assign({}, DefaultAdaptableOptions_1.DefaultAdaptableOptions.gridOptions), abOptions.gridOptions);
22
22
  return (React.createElement(React.Fragment, null,
23
+ React.createElement(HelpBlock_1.default, null, "Base Options"),
24
+ React.createElement(FormLayout_1.default, { margin: 2, columns: [{ name: 'label', style: { textAlign: 'start' } }, { name: 'children' }] },
25
+ React.createElement(FormLayout_1.FormRow, { label: "Adaptable ID" },
26
+ React.createElement(Input_1.default, { value: (_b = (_a = props === null || props === void 0 ? void 0 : props.adaptableOptions) === null || _a === void 0 ? void 0 : _a.adaptableId) !== null && _b !== void 0 ? _b : null, onChange: (event) => {
27
+ var _a;
28
+ props.onChangeadaptableOptions(Object.assign(Object.assign({}, abOptions), { adaptableId: (_a = event.target.value) !== null && _a !== void 0 ? _a : '' }));
29
+ }, style: { minWidth: '20rem' } }))),
23
30
  React.createElement(HelpBlock_1.default, null, "General Options"),
24
31
  React.createElement(FormLayout_1.default, { margin: 2, columns: [{ name: 'children' }, { name: 'label', style: { textAlign: 'start' } }] },
25
32
  React.createElement(FormLayout_1.FormRow, { label: "Show Missing Primary Key Warning" },
@@ -39,7 +46,7 @@ const ConfigurationForm = (props) => {
39
46
  props.onChangeadaptableOptions(abOptions);
40
47
  } })),
41
48
  React.createElement(FormLayout_1.FormRow, { label: "Show Quick Filter" },
42
- React.createElement(CheckBox_1.CheckBox, { checked: (_a = gridOptions.defaultColDef) === null || _a === void 0 ? void 0 : _a.floatingFilter, onChange: (floatingFilter) => {
49
+ React.createElement(CheckBox_1.CheckBox, { checked: (_c = gridOptions.defaultColDef) === null || _c === void 0 ? void 0 : _c.floatingFilter, onChange: (floatingFilter) => {
43
50
  abOptions = Object.assign({}, abOptions);
44
51
  abOptions.gridOptions = Object.assign({}, abOptions.gridOptions);
45
52
  abOptions.gridOptions.defaultColDef = {
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+ import { AdaptableOptions } from '../../../types';
3
+ import { OnePageWizardSection } from '../../Wizard/OnePageWizards';
4
+ import { AdaptableFrameworkComponent } from '../../../../types';
5
+ export interface CustomSection<T> {
6
+ title: OnePageWizardSection<T>['title'];
7
+ details?: AdaptableFrameworkComponent;
8
+ isValid?: OnePageWizardSection<T>['isValid'];
9
+ isVisible?: OnePageWizardSection<T>['isVisible'];
10
+ render: (adaptableOptions: AdaptableOptions, onChange: (newAdaptableOptions: AdaptableOptions) => void) => React.ReactNode;
11
+ }
12
+ export interface ConfigurationWizardProps {
13
+ adaptableOptions: AdaptableOptions;
14
+ onFinish: (adaptableOptions: AdaptableOptions) => void;
15
+ onCancel: () => void;
16
+ startSections?: CustomSection<AdaptableOptions>[];
17
+ }
18
+ export declare const ConfigurationWizard: React.FunctionComponent<ConfigurationWizardProps>;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfigurationWizard = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const React = tslib_1.__importStar(require("react"));
6
+ const react_1 = require("react");
7
+ const StringExtensions_1 = tslib_1.__importDefault(require("../../../Utilities/Extensions/StringExtensions"));
8
+ const OnePageWizards_1 = require("../../Wizard/OnePageWizards");
9
+ const ConfigurationWizardColumnsStep_1 = require("./ConfigurationWizardColumnsStep");
10
+ const ConfigurationForm_1 = tslib_1.__importDefault(require("./ConfigurationForm"));
11
+ exports.ConfigurationWizard = (props) => {
12
+ const [isPrimaryKeySelected, setIsValid] = React.useState(true);
13
+ const [adaptableOptions, setAdaptableOptions] = react_1.useState(props.adaptableOptions);
14
+ const [selectedColumns, setSelectedColumns] = react_1.useState(() => {
15
+ return props.adaptableOptions.gridOptions.columnDefs.reduce((acc, col) => {
16
+ acc[col.field] = true;
17
+ return acc;
18
+ }, {});
19
+ });
20
+ const columnsHandle = React.useRef();
21
+ const handleFinish = () => {
22
+ const newAdaptableOptions = Object.assign({}, adaptableOptions);
23
+ newAdaptableOptions.gridOptions = Object.assign({}, adaptableOptions.gridOptions);
24
+ newAdaptableOptions.gridOptions.columnDefs = columnsHandle
25
+ .current.getColumns()
26
+ .map((column) => {
27
+ const newColumn = Object.assign(Object.assign({}, column), { headerName: column.caption || StringExtensions_1.default.Humanize(column.field) });
28
+ delete newColumn.caption;
29
+ return newColumn;
30
+ });
31
+ newAdaptableOptions.primaryKey = columnsHandle.current.getPrimaryKey();
32
+ setAdaptableOptions(newAdaptableOptions);
33
+ props.onFinish(newAdaptableOptions);
34
+ };
35
+ const handlePrimaryKeyColumnIsNotSelected = React.useCallback((newIsValid) => {
36
+ setIsValid(newIsValid);
37
+ }, []);
38
+ const handleColumnsChange = React.useCallback((columns) => {
39
+ setAdaptableOptions((adaptableOptions) => (Object.assign(Object.assign({}, adaptableOptions), { gridOptions: Object.assign(Object.assign({}, adaptableOptions.gridOptions), { columnDefs: columns }) })));
40
+ }, []);
41
+ const handleColumnSelectionChange = React.useCallback((col, flag) => {
42
+ setSelectedColumns((selectedColumns) => {
43
+ const newSelectedColumns = selectedColumns !== null && selectedColumns !== void 0 ? selectedColumns : {};
44
+ newSelectedColumns[col.field] = flag;
45
+ return newSelectedColumns;
46
+ });
47
+ }, []);
48
+ let sections = [
49
+ {
50
+ title: 'Columns',
51
+ details: 'Configure Adaptable',
52
+ isValid: () => {
53
+ if (!isPrimaryKeySelected) {
54
+ return 'Primary key column must be included';
55
+ }
56
+ return true;
57
+ },
58
+ render: () => (React.createElement(ConfigurationWizardColumnsStep_1.ConfigurationWizardColumnsStep, { adaptableOptions: adaptableOptions, setPrimaryKeyIsNotSelected: handlePrimaryKeyColumnIsNotSelected, onChange: (newAdaptableOptions) => {
59
+ setAdaptableOptions(newAdaptableOptions);
60
+ }, selectedColumns: selectedColumns, onSelectionChange: handleColumnSelectionChange, onColumnChange: handleColumnsChange, columnsHandle: columnsHandle })),
61
+ },
62
+ {
63
+ title: 'Adaptable Options',
64
+ details: 'Configure Adaptable Options',
65
+ isValid: () => (adaptableOptions.adaptableId ? true : 'Adaptable ID is required'),
66
+ render: () => (React.createElement(ConfigurationForm_1.default, { adaptableOptions: adaptableOptions, onChangeadaptableOptions: (abOptions) => {
67
+ setAdaptableOptions(abOptions);
68
+ } })),
69
+ },
70
+ ];
71
+ if (props.startSections) {
72
+ sections = [
73
+ ...props.startSections.map((section) => {
74
+ return {
75
+ title: section.title,
76
+ isValid: section.isValid,
77
+ isVisible: section.isVisible,
78
+ render: () => {
79
+ return section.render(adaptableOptions, setAdaptableOptions);
80
+ },
81
+ };
82
+ }),
83
+ ...sections,
84
+ ];
85
+ }
86
+ return (React.createElement(OnePageWizards_1.OnePageWizard, { data: adaptableOptions, name: "Configure", defaultCurrentSectionName: 'default section name', onHide: () => null, onFinish: handleFinish, sections: sections }));
87
+ };
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+ import { NocodeColumn } from './ColumnsList';
3
+ import { AdaptableOptions } from '../../../types';
4
+ export interface ConfigurationWizardColumnsStepProps {
5
+ adaptableOptions: AdaptableOptions;
6
+ onChange: (newOptions: AdaptableOptions) => void;
7
+ columnsHandle: React.MutableRefObject<{
8
+ getColumns: () => any[];
9
+ getPrimaryKey: () => string;
10
+ }>;
11
+ setPrimaryKeyIsNotSelected: (enabled: boolean) => void;
12
+ onColumnChange: (columns: NocodeColumn[]) => void;
13
+ onSelectionChange: (column: any, flag: boolean) => void;
14
+ selectedColumns: {
15
+ [key: string]: boolean;
16
+ };
17
+ }
18
+ export declare const ConfigurationWizardColumnsStep: React.FunctionComponent<ConfigurationWizardColumnsStepProps>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfigurationWizardColumnsStep = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const React = tslib_1.__importStar(require("react"));
6
+ const Panel_1 = tslib_1.__importDefault(require("../../../components/Panel"));
7
+ const ColumnsList_1 = tslib_1.__importDefault(require("./ColumnsList"));
8
+ exports.ConfigurationWizardColumnsStep = (props) => {
9
+ var _a, _b;
10
+ return (React.createElement(Panel_1.default, { header: '', border: "none", bodyScroll: false, bodyProps: {
11
+ style: { overflow: 'auto', display: 'flex', flexFlow: 'column' },
12
+ }, borderRadius: "none", style: { fontSize: 16, flex: 1 } },
13
+ React.createElement(ColumnsList_1.default, { handle: props.columnsHandle, onValidityChange: (valid) => {
14
+ props.setPrimaryKeyIsNotSelected(valid);
15
+ }, selectedColumns: props.selectedColumns, onChange: props.onColumnChange, onSelectionChange: props.onSelectionChange, columns: (_b = (_a = props.adaptableOptions) === null || _a === void 0 ? void 0 : _a.gridOptions) === null || _b === void 0 ? void 0 : _b.columnDefs })));
16
+ };
@@ -1,9 +1,2 @@
1
- import * as React from 'react';
2
- import { AdaptableOptions } from '../../../types';
3
- interface ConfigurationDialogProps extends React.HTMLProps<HTMLElement> {
4
- adaptableOptions: AdaptableOptions;
5
- onFinish: (adaptableOptions: AdaptableOptions) => void;
6
- onCancel: () => void;
7
- }
8
- declare const ConfigurationDialog: (props: ConfigurationDialogProps) => JSX.Element;
9
- export default ConfigurationDialog;
1
+ import { ConfigurationWizard } from './ConfigurationWizard';
2
+ export default ConfigurationWizard;
@@ -1,77 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const React = tslib_1.__importStar(require("react"));
5
- const rebass_1 = require("rebass");
6
- const react_1 = require("react");
7
- const Dialog_1 = tslib_1.__importDefault(require("../../../components/Dialog"));
8
- const Panel_1 = tslib_1.__importDefault(require("../../../components/Panel"));
9
- const SimpleButton_1 = tslib_1.__importDefault(require("../../../components/SimpleButton"));
10
- const ColumnsList_1 = tslib_1.__importDefault(require("./ColumnsList"));
11
- const FormLayout_1 = tslib_1.__importStar(require("../../../components/FormLayout"));
12
- const Input_1 = tslib_1.__importDefault(require("../../../components/Input"));
13
- const ConfigurationForm_1 = tslib_1.__importDefault(require("./ConfigurationForm"));
14
- const StringExtensions_1 = tslib_1.__importDefault(require("../../../Utilities/Extensions/StringExtensions"));
15
- const ConfigurationDialog = (props) => {
16
- const [abOptions, setABOptions] = react_1.useState(props.adaptableOptions);
17
- const [finishEnabled, setFinishEnabled] = react_1.useState(true);
18
- const [currentStep, setCurrentStep] = react_1.useState(0);
19
- let canFinish = finishEnabled;
20
- if (!abOptions.adaptableId) {
21
- canFinish = false;
22
- }
23
- let canNext = canFinish && currentStep === 0;
24
- const columnsHandle = React.useRef();
25
- const onadaptableIdChange = (event) => {
26
- const newABOptions = Object.assign({}, abOptions);
27
- newABOptions.adaptableId = event.target.value;
28
- setABOptions(newABOptions);
29
- };
30
- const onFinish = () => {
31
- const newABOptions = Object.assign({}, abOptions);
32
- newABOptions.gridOptions = Object.assign({}, abOptions.gridOptions);
33
- newABOptions.gridOptions.columnDefs = columnsHandle.current.getColumns().map((c) => {
34
- const col = Object.assign(Object.assign({}, c), { headerName: c.caption || StringExtensions_1.default.Humanize(c.field) });
35
- delete col.caption;
36
- return col;
37
- });
38
- newABOptions.primaryKey = columnsHandle.current.getPrimaryKey();
39
- setABOptions(newABOptions);
40
- props.onFinish(newABOptions);
41
- };
42
- const onNext = () => {
43
- setCurrentStep(1);
44
- };
45
- const stepOne = (React.createElement(React.Fragment, null,
46
- React.createElement(Panel_1.default, { header: 'Configure AdapTable', border: "none", bodyScroll: false, bodyProps: {
47
- padding: 0,
48
- style: { overflow: 'auto', display: 'flex', flexFlow: 'column' },
49
- }, borderRadius: "none", style: { fontSize: 16, flex: 1 } },
50
- React.createElement(Panel_1.default, { style: { minHeight: 50 }, border: "none" },
51
- React.createElement(FormLayout_1.default, null,
52
- React.createElement(FormLayout_1.FormRow, { label: "AdaptableId" },
53
- React.createElement(Input_1.default, { value: abOptions.adaptableId, onChange: onadaptableIdChange, style: { minWidth: '20rem' } })))),
54
- React.createElement(ColumnsList_1.default, { handle: columnsHandle, onValidityChange: (valid) => {
55
- setFinishEnabled(valid);
56
- }, columns: abOptions.gridOptions.columnDefs }))));
57
- const stepTwo = (React.createElement(React.Fragment, null,
58
- React.createElement(Panel_1.default, { header: 'Configure AdapTable', border: "none", style: { flex: 1, overflow: 'auto' } },
59
- React.createElement(ConfigurationForm_1.default, { adaptableOptions: abOptions, onChangeadaptableOptions: (abOptions) => {
60
- setABOptions(abOptions);
61
- } }))));
62
- return (React.createElement(Dialog_1.default, { modal: true, isOpen: true, showCloseButton: false },
63
- React.createElement(rebass_1.Flex, { flexDirection: "column", style: {
64
- height: '100%',
65
- width: '90vw',
66
- maxWidth: 1000,
67
- maxHeight: '90vh',
68
- } },
69
- currentStep === 0 ? stepOne : stepTwo,
70
- React.createElement(rebass_1.Flex, { flexDirection: "row", padding: 2, backgroundColor: "primary", alignItems: "center" },
71
- React.createElement(SimpleButton_1.default, { tone: "neutral", variant: "text", tooltip: "Cancel configuration ", onClick: props.onCancel }, "Cancel"),
72
- React.createElement("div", { style: { flex: 1 } }),
73
- React.createElement(SimpleButton_1.default, { variant: "outlined", onClick: () => setCurrentStep(0), disabled: currentStep === 0, marginRight: 2, tone: "neutral" }, "Back"),
74
- React.createElement(SimpleButton_1.default, { variant: "outlined", onClick: onNext, disabled: !canNext, marginRight: 2, tone: "neutral" }, "Next"),
75
- React.createElement(SimpleButton_1.default, { tone: "accent", variant: "raised", icon: 'check', onClick: onFinish, disabled: !canFinish }, "Finish")))));
76
- };
77
- exports.default = ConfigurationDialog;
3
+ const ConfigurationWizard_1 = require("./ConfigurationWizard");
4
+ exports.default = ConfigurationWizard_1.ConfigurationWizard;
@@ -1,6 +1,8 @@
1
1
  declare const useSelection: (columns: {
2
2
  [key: string]: any;
3
- }[], defaultValue: boolean, fieldName: string | null, changeListeners?: {
3
+ }[], defaultValue: boolean | {
4
+ [key: string]: boolean;
5
+ }, fieldName: string | null, changeListeners?: {
4
6
  onChange?: (column: any, flag: boolean) => void;
5
7
  onBatchChange?: (flag: boolean) => void;
6
8
  }) => {
@@ -5,10 +5,15 @@ const useSelection = (columns, defaultValue, fieldName, changeListeners) => {
5
5
  changeListeners = changeListeners || {};
6
6
  const onChange = changeListeners.onChange || ((column, flag) => { });
7
7
  const onBatchChange = changeListeners.onBatchChange || ((flag) => { });
8
- const [selected, setSelected] = react_1.useState(columns.reduce((acc, col) => {
9
- acc[col.field] = fieldName ? col[fieldName] : defaultValue;
10
- return acc;
11
- }, {}));
8
+ const [selected, setSelected] = react_1.useState(typeof defaultValue === 'object'
9
+ ? defaultValue
10
+ : columns.reduce((acc, col) => {
11
+ const flag = fieldName ? col[fieldName] : defaultValue;
12
+ if (flag) {
13
+ acc[col.field] = flag;
14
+ }
15
+ return acc;
16
+ }, {}));
12
17
  const getColumn = (field) => columns.filter((c) => c.field === field)[0];
13
18
  const result = {
14
19
  selected,
@@ -0,0 +1 @@
1
+ export declare const validDataSource: (dataSourceInfo: any) => boolean;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validDataSource = void 0;
4
+ exports.validDataSource = (dataSourceInfo) => {
5
+ if (!dataSourceInfo || !Array.isArray(dataSourceInfo.columns)) {
6
+ throw `We can't find any columns in your configuration`;
7
+ }
8
+ if (!dataSourceInfo.columns.length) {
9
+ throw 'You should have at least one column';
10
+ }
11
+ const allStringColumns = dataSourceInfo.columns.reduce((acc, col) => {
12
+ if (!col || typeof col !== 'string') {
13
+ return false;
14
+ }
15
+ return acc;
16
+ }, true);
17
+ if (!allStringColumns) {
18
+ throw `Some of your columns are not strings`;
19
+ }
20
+ if (!Array.isArray(dataSourceInfo.data)) {
21
+ throw `We can't find the data array in your configuration`;
22
+ }
23
+ return true;
24
+ };
@@ -0,0 +1,54 @@
1
+ import * as React from 'react';
2
+ import { Reducer, ReactNode } from 'react';
3
+ import { AdaptableOptions } from '../../types';
4
+ import { ConfigurationWizardProps } from './AdaptableConfigurationDialog/ConfigurationWizard';
5
+ export interface AdaptableWizardViewProps {
6
+ adaptableOptions?: Omit<AdaptableOptions, 'primaryKey'> & {
7
+ primaryKey?: string;
8
+ };
9
+ /**
10
+ * Default true.
11
+ */
12
+ ddEnabled?: boolean;
13
+ /**
14
+ * When true the the configuration wizard will be shown.
15
+ * It will use the available information in adaptableOptions & gridOptions.
16
+ * This mode skips over interpreting data to figure-out columns.
17
+ */
18
+ skipToWizard?: boolean;
19
+ onInit: (adaptableOptions: AdaptableOptions) => any;
20
+ fileContentsToJSON?: (str: string) => Promise<any> | any;
21
+ readFile?: (file: File) => Promise<any>;
22
+ fileAccept?: string;
23
+ helpText?: React.ReactNode;
24
+ loadingMessage?: ReactNode;
25
+ defaultActionMessage?: ReactNode;
26
+ dragOverActionMessage?: ReactNode;
27
+ fetchData?: () => Promise<Record<string, any>[]>;
28
+ showFetchDataWizard?: boolean;
29
+ startSections?: ConfigurationWizardProps['startSections'];
30
+ prepareData?: (data: any, file?: File) => {
31
+ columns: string[];
32
+ data: any[];
33
+ primaryKey?: string;
34
+ };
35
+ }
36
+ export declare const initialState: Partial<WizardState>;
37
+ export declare const reducer: Reducer<WizardState, any>;
38
+ interface WizardState {
39
+ dropped: boolean;
40
+ error: any;
41
+ adaptableOptions: AdaptableOptions;
42
+ }
43
+ /**
44
+ * The wizard in a few modes:
45
+ *
46
+ * 1. Based on data:
47
+ * 1.1 Drag and drop a file
48
+ * 1.2 Fetch data from a url
49
+ *
50
+ * 2. Based on configuration:
51
+ * Provide a schema, on how the data looks like.
52
+ */
53
+ export declare const Wizard: (props: AdaptableWizardViewProps) => JSX.Element;
54
+ export {};
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Wizard = exports.reducer = exports.initialState = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const React = tslib_1.__importStar(require("react"));
6
+ const react_1 = require("react");
7
+ const helper_1 = require("./helper");
8
+ const rebass_1 = require("rebass");
9
+ const AdaptableConfigurationDialog_1 = tslib_1.__importDefault(require("./AdaptableConfigurationDialog"));
10
+ const FileDroppable_1 = tslib_1.__importDefault(require("../../components/FileDroppable"));
11
+ const Utils_1 = require("./Utils");
12
+ exports.initialState = {
13
+ dropped: false,
14
+ };
15
+ exports.reducer = (state, action) => {
16
+ if (action.type === 'DROPPED') {
17
+ return Object.assign(Object.assign({}, state), { adaptableOptions: action.payload, dropped: true, error: null });
18
+ }
19
+ if (action.type === 'ERROR') {
20
+ return Object.assign(Object.assign({}, state), { dropped: false, error: action.payload });
21
+ }
22
+ if (action.type === 'CANCEL') {
23
+ return Object.assign(Object.assign({}, state), { error: null, dropped: false });
24
+ }
25
+ return state;
26
+ };
27
+ /**
28
+ * The wizard in a few modes:
29
+ *
30
+ * 1. Based on data:
31
+ * 1.1 Drag and drop a file
32
+ * 1.2 Fetch data from a url
33
+ *
34
+ * 2. Based on configuration:
35
+ * Provide a schema, on how the data looks like.
36
+ */
37
+ exports.Wizard = (props) => {
38
+ var _a;
39
+ const [state, dispatch] = react_1.useReducer(exports.reducer, Object.assign(Object.assign({}, exports.initialState), { adaptableOptions: props.adaptableOptions }));
40
+ const [droppableKey, setDroppableKey] = react_1.useState(Date.now());
41
+ const [isDataLoading, setIsDataLoading] = react_1.useState(false);
42
+ const handleDataSource = (array, file) => {
43
+ const dataSourceInfo = (props.prepareData || helper_1.prepareDataSource)(array, file);
44
+ try {
45
+ Utils_1.validDataSource(dataSourceInfo);
46
+ }
47
+ catch (err) {
48
+ return dispatch({
49
+ type: 'ERROR',
50
+ payload: `Invalid adaptable configuration - ${err}`,
51
+ });
52
+ }
53
+ const gridOptions = helper_1.prepareGridOptions(dataSourceInfo);
54
+ const adaptableOptions = Object.assign({}, props.adaptableOptions);
55
+ adaptableOptions.adaptableId = adaptableOptions.adaptableId || (file ? file.name : '');
56
+ adaptableOptions.gridOptions = gridOptions;
57
+ if (dataSourceInfo.primaryKey) {
58
+ adaptableOptions.primaryKey = dataSourceInfo.primaryKey;
59
+ }
60
+ const shouldShowWizard = props.fetchData ? Boolean(props.showFetchDataWizard) : true;
61
+ if (shouldShowWizard) {
62
+ dispatch({
63
+ type: 'DROPPED',
64
+ payload: adaptableOptions,
65
+ });
66
+ }
67
+ else {
68
+ props.onInit(adaptableOptions);
69
+ }
70
+ };
71
+ let wizard;
72
+ if (props.skipToWizard || state.dropped) {
73
+ wizard = (React.createElement(AdaptableConfigurationDialog_1.default, { startSections: props.startSections, adaptableOptions: state.adaptableOptions, onCancel: () => {
74
+ // change the file droppable component key
75
+ // so it's remounted and it's in the initial state
76
+ setDroppableKey(Date.now());
77
+ dispatch({
78
+ type: 'CANCEL',
79
+ });
80
+ }, onFinish: (adaptableOptions) => {
81
+ props.onInit(adaptableOptions);
82
+ } }));
83
+ }
84
+ react_1.useEffect(() => {
85
+ if (props.fetchData) {
86
+ setIsDataLoading(true);
87
+ props.fetchData().then((data) => {
88
+ handleDataSource(data);
89
+ setIsDataLoading(false);
90
+ });
91
+ }
92
+ }, []);
93
+ const ddEnabled = (_a = props.ddEnabled) !== null && _a !== void 0 ? _a : !props.fetchData;
94
+ return (React.createElement(React.Fragment, null,
95
+ ddEnabled && (React.createElement(FileDroppable_1.default, { key: droppableKey, className: 'ab-nocode-wizard', toJSON: props.fileContentsToJSON, readFile: props.readFile, fileAccept: props.fileAccept, helpText: props.helpText, message: state.error, defaultText: props.defaultActionMessage, dragOverText: props.dragOverActionMessage, loadingText: props.loadingMessage, onDropSuccess: handleDataSource })),
96
+ isDataLoading && (React.createElement(rebass_1.Flex, { className: 'ab-nocode-wizard', alignItems: "center", justifyContent: "center", flexDirection: "column" }, props.loadingMessage || 'Loading ...')),
97
+ wizard));
98
+ };
@@ -1,25 +1,4 @@
1
1
  import * as React from 'react';
2
- import { ReactNode } from 'react';
3
- import { AdaptableOptions } from '../../AdaptableOptions/AdaptableOptions';
4
- interface AdaptableWizardViewProps {
5
- adaptableOptions?: Omit<AdaptableOptions, 'primaryKey'> & {
6
- primaryKey?: string;
7
- };
8
- onInit: (adaptableOptions: AdaptableOptions) => any;
9
- fileContentsToJSON?: (str: string) => Promise<any> | any;
10
- readFile?: (file: File) => Promise<any>;
11
- fileAccept?: string;
12
- helpText?: React.ReactNode;
13
- loadingMessage?: ReactNode;
14
- defaultActionMessage?: ReactNode;
15
- dragOverActionMessage?: ReactNode;
16
- fetchData?: () => Promise<Record<string, any>[]>;
17
- showFetchDataWizard?: boolean;
18
- prepareData?: (data: any, file?: File) => {
19
- columns: string[];
20
- data: any[];
21
- primaryKey?: string;
22
- };
23
- }
2
+ import { AdaptableWizardViewProps } from './Wizard';
24
3
  declare const AdaptableWizardView: React.FunctionComponent<AdaptableWizardViewProps>;
25
4
  export default AdaptableWizardView;