@adaptabletools/adaptable 21.0.0-canary.0 → 21.0.0-canary.1

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": "21.0.0-canary.0",
3
+ "version": "21.0.0-canary.1",
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,4 +1,4 @@
1
- import { Layout } from '../AdaptableState/LayoutState';
1
+ import { Layout, PivotLayout, TableLayout } from '../AdaptableState/LayoutState';
2
2
  import { AdaptableObjectTag } from '../AdaptableState/Common/AdaptableObject';
3
3
  import { BaseContext, LayoutExtensionModule, LayoutExtensionObject } from '../../types';
4
4
  /**
@@ -17,6 +17,10 @@ export interface LayoutOptions {
17
17
  * Columns to display in Table that opens when viewing Pivot Cell contents
18
18
  */
19
19
  pivotPreviewColumns?: string[] | ((context: PivotPreviewColumnsContext) => string[]);
20
+ /**
21
+ * Default properties to apply when creating a new Layout (Table or Pivot)
22
+ */
23
+ defaultLayoutProperties?: DefaultLayoutProperties | ((context: DefaultLayoutPropertiesContext) => DefaultTableLayoutProperties | DefaultPivotLayoutProperties);
20
24
  }
21
25
  /**
22
26
  * Options for managing Tags in Layouts (used to enhance Layouts)
@@ -93,3 +97,30 @@ export interface PivotPreviewColumnsContext extends BaseContext {
93
97
  */
94
98
  columnId: string;
95
99
  }
100
+ /**
101
+ * Default properties to apply when creating a new Table Layout
102
+ */
103
+ export type DefaultTableLayoutProperties = Partial<Omit<TableLayout, 'Name'>>;
104
+ /**
105
+ * Default properties to apply when creating a new Pivot Layout
106
+ */
107
+ export type DefaultPivotLayoutProperties = Partial<Omit<PivotLayout, 'Name'>>;
108
+ /**
109
+ * Default properties to apply when creating a new Layout (Table or Pivot)
110
+ */
111
+ export interface DefaultLayoutProperties {
112
+ /**
113
+ * Default properties to apply when creating a new Table Layout
114
+ */
115
+ tableLayout?: DefaultTableLayoutProperties;
116
+ /**
117
+ * Default properties to apply when creating a new Pivot Layout
118
+ */
119
+ pivotLayout?: DefaultPivotLayoutProperties;
120
+ }
121
+ /**
122
+ * Context for `LayoutOptions.defaultLayoutProperties` function
123
+ */
124
+ export interface DefaultLayoutPropertiesContext extends BaseContext {
125
+ layoutType: 'table' | 'pivot';
126
+ }
@@ -2,8 +2,6 @@ import * as LayoutRedux from '../../Redux/ActionsReducers/LayoutRedux';
2
2
  import * as ModuleConstants from '../../Utilities/Constants/ModuleConstants';
3
3
  import { ApiBase } from './ApiBase';
4
4
  import StringExtensions from '../../Utilities/Extensions/StringExtensions';
5
- import ObjectFactory from '../../Utilities/ObjectFactory';
6
- import Helper from '../../Utilities/Helpers/Helper';
7
5
  import { createUuid } from '../../AdaptableState/Uuid';
8
6
  import { PopupShowPrompt } from '../../Redux/ActionsReducers/PopupRedux';
9
7
  import { LayoutInternalApi } from '../Internal/LayoutInternalApi';
@@ -275,7 +273,7 @@ export class LayoutApiImpl extends ApiBase {
275
273
  this.logError("Cannot create layout with the Name: '" + layoutToCreate.Name + "' as it already exists");
276
274
  return false;
277
275
  }
278
- const newLayout = ObjectFactory.CreateEmptyLayout({ ...layoutToCreate });
276
+ const newLayout = this.internalApi.buildInitialLayout(layoutToCreate);
279
277
  this.addUidToAdaptableObject(newLayout);
280
278
  this.dispatchAction(LayoutRedux.LayoutAdd(newLayout));
281
279
  return newLayout;
@@ -292,9 +290,11 @@ export class LayoutApiImpl extends ApiBase {
292
290
  this.logError("Cannot clone layout with Name: '" + layoutName + "' as other Layout does not exist");
293
291
  return false;
294
292
  }
295
- const newLayout = Helper.cloneObject(layoutToClone);
296
- newLayout.Uuid = createUuid();
297
- newLayout.Name = layoutName;
293
+ const newLayout = {
294
+ ...this.internalApi.cloneLayout(layoutToClone),
295
+ Name: layoutName,
296
+ Uuid: createUuid(),
297
+ };
298
298
  this.dispatchAction(LayoutRedux.LayoutAdd(newLayout));
299
299
  return this.getLayoutById(newLayout.Uuid);
300
300
  }
@@ -32,4 +32,9 @@ export declare class LayoutInternalApi extends ApiBase {
32
32
  setupRowSummaries(): void;
33
33
  refreshLayout(): void;
34
34
  getChangedColumnSorts(oldSorts: LayoutBase['ColumnSorts'], newSorts: LayoutBase['ColumnSorts']): string[];
35
+ buildInitialLayout(providedLayout: Partial<Layout> & {
36
+ Name: string;
37
+ }, type?: 'table' | 'pivot'): Layout;
38
+ private getDefaultLayoutProperties;
39
+ cloneLayout(layoutToClone: Layout): Omit<Layout, 'Name'>;
35
40
  }
@@ -1,7 +1,10 @@
1
1
  import { ColumnFilterModuleId, GridFilterModuleId, } from '../../Utilities/Constants/ModuleConstants';
2
2
  import ArrayExtensions from '../../Utilities/Extensions/ArrayExtensions';
3
3
  import { ApiBase } from '../Implementation/ApiBase';
4
- import { areLayoutsEqual, normalizeLayout } from '../Implementation/LayoutHelpers';
4
+ import { areLayoutsEqual, isPivotLayout, normalizeLayout } from '../Implementation/LayoutHelpers';
5
+ import ObjectFactory from '../../Utilities/ObjectFactory';
6
+ import Helper from '../../Utilities/Helpers/Helper';
7
+ import AdaptableHelper from '../../Utilities/Helpers/AdaptableHelper';
5
8
  export class LayoutInternalApi extends ApiBase {
6
9
  getNormalizedLayout(layout) {
7
10
  return normalizeLayout(layout);
@@ -206,4 +209,44 @@ export class LayoutInternalApi extends ApiBase {
206
209
  });
207
210
  return changedColumnIds;
208
211
  }
212
+ buildInitialLayout(providedLayout, type) {
213
+ const layoutType = type || (isPivotLayout(providedLayout) ? 'pivot' : 'table');
214
+ const providedTableLayout = providedLayout;
215
+ const providedPivotLayout = providedLayout;
216
+ const initialEmptyLayout = layoutType === 'pivot'
217
+ ? ObjectFactory.CreateEmptyPivotLayout({ ...providedPivotLayout })
218
+ : ObjectFactory.CreateEmptyTableLayout({ ...providedTableLayout });
219
+ const defaultLayoutProperties = this.getDefaultLayoutProperties(layoutType);
220
+ const initialLayout = {
221
+ ...initialEmptyLayout,
222
+ ...defaultLayoutProperties,
223
+ };
224
+ return initialLayout;
225
+ }
226
+ getDefaultLayoutProperties(layoutType) {
227
+ const defaultLayoutPropertiesOption = this.getLayoutOptions().defaultLayoutProperties;
228
+ if (typeof defaultLayoutPropertiesOption === 'object') {
229
+ const initialProps = layoutType === 'table'
230
+ ? defaultLayoutPropertiesOption.tableLayout
231
+ : defaultLayoutPropertiesOption.pivotLayout;
232
+ return initialProps;
233
+ }
234
+ if (typeof defaultLayoutPropertiesOption === 'function') {
235
+ const context = {
236
+ layoutType,
237
+ ...this.getAdaptableInternalApi().buildBaseContext(),
238
+ };
239
+ return defaultLayoutPropertiesOption(context);
240
+ }
241
+ return {};
242
+ }
243
+ cloneLayout(layoutToClone) {
244
+ let clonedLayout = Helper.cloneObject(layoutToClone);
245
+ let result = {
246
+ ...this.buildInitialLayout(clonedLayout),
247
+ };
248
+ result = AdaptableHelper.removeAdaptableObjectPrimitivesInlineDeep(result);
249
+ delete result.Name;
250
+ return result;
251
+ }
209
252
  }
@@ -14,6 +14,7 @@ export declare const AdaptableHelper: {
14
14
  addAdaptableObjectPrimitives: typeof addAdaptableObjectPrimitives;
15
15
  removeAdaptableObjectPrimitives: typeof removeAdaptableObjectPrimitives;
16
16
  removeAdaptableObjectPrimitivesInline: typeof removeAdaptableObjectPrimitivesInline;
17
+ removeAdaptableObjectPrimitivesInlineDeep: typeof removeAdaptableObjectPrimitivesInlineDeep;
17
18
  isAdaptableObject: typeof isAdaptableObject;
18
19
  };
19
20
  export default AdaptableHelper;
@@ -106,6 +106,7 @@ export const AdaptableHelper = {
106
106
  addAdaptableObjectPrimitives,
107
107
  removeAdaptableObjectPrimitives,
108
108
  removeAdaptableObjectPrimitivesInline,
109
+ removeAdaptableObjectPrimitivesInlineDeep,
109
110
  isAdaptableObject,
110
111
  };
111
112
  export default AdaptableHelper;
@@ -23,7 +23,7 @@ import { NotificationsOptions } from '../AdaptableOptions/NotificationsOptions';
23
23
  import { CellSummmaryInfo } from '../AdaptableState/Common/CellSummary';
24
24
  import { AdaptableTheme, ChartDefinition, ColumnFilter, CommentThread, CustomDisplayFormatterContext, FlashingCellDefinition, RowDataChangedInfo, SpecialColumnSettings, SystemFilterPredicateId } from '../types';
25
25
  import { IRowNode } from 'ag-grid-enterprise';
26
- import { AdaptableApi, AdaptableComment, BadgeStyleDefinition, CellAddress, NamedQuery, PivotLayout } from '../../types';
26
+ import { AdaptableApi, AdaptableComment, BadgeStyleDefinition, CellAddress, NamedQuery, PivotLayout, TableLayout } from '../../types';
27
27
  import { ToastOptions } from '../components/Toastify';
28
28
  import { StyledColumn } from '../AdaptableState/StyledColumnState';
29
29
  export declare function CreateEmptyCustomSort(): CustomSort;
@@ -51,12 +51,15 @@ export declare function CreateEmptySchedule(): Schedule;
51
51
  export declare function CreateEmptyShortcut(): Shortcut;
52
52
  export declare function CreateEmptyFormatColumn(): FormatColumn;
53
53
  export declare function CreateEmptyFreeTextColumn(defaultSpecialColumnSettings: Partial<SpecialColumnSettings>): FreeTextColumn;
54
- export declare function CreateEmptyPivotLayout(layout?: Partial<PivotLayout> & {
54
+ export declare function CreateEmptyPivotLayout(pivotLayout?: Partial<PivotLayout> & {
55
55
  Name: string;
56
56
  }): PivotLayout;
57
+ export declare function CreateEmptyTableLayout(tableLayout?: Partial<TableLayout> & {
58
+ Name: string;
59
+ }): TableLayout;
57
60
  export declare function CreateEmptyLayout(layout?: Partial<Layout> & {
58
61
  Name: string;
59
- }, adaptableColumns?: AdaptableColumn[]): Layout;
62
+ }): Layout;
60
63
  export declare function CreateEmptyStyle(): AdaptableStyle;
61
64
  export declare function CreateSystemStatusMessageInfo(message: string, type: AdaptableMessageType, furtherInfo?: string): SystemStatusMessageInfo;
62
65
  export declare function CreateEmptyCellSummmary(): CellSummmaryInfo;
@@ -100,6 +103,7 @@ export declare const ObjectFactory: {
100
103
  CreateEmptyFreeTextColumn: typeof CreateEmptyFreeTextColumn;
101
104
  CreateEmptyLayout: typeof CreateEmptyLayout;
102
105
  CreateEmptyPivotLayout: typeof CreateEmptyPivotLayout;
106
+ CreateEmptyTableLayout: typeof CreateEmptyTableLayout;
103
107
  CreateColumnFilter: typeof CreateColumnFilter;
104
108
  CreateEmptyStyle: typeof CreateEmptyStyle;
105
109
  CreateEmptyCellSummmary: typeof CreateEmptyCellSummmary;
@@ -246,36 +246,43 @@ export function CreateEmptyFreeTextColumn(defaultSpecialColumnSettings) {
246
246
  },
247
247
  };
248
248
  }
249
- export function CreateEmptyPivotLayout(layout) {
249
+ export function CreateEmptyPivotLayout(pivotLayout) {
250
250
  const result = {
251
- Name: layout.Name,
252
- ColumnSorts: layout.ColumnSorts || [],
253
- ColumnFilters: layout.ColumnFilters || [],
251
+ ...pivotLayout,
254
252
  Uuid: createUuid(),
255
- PivotColumns: layout.PivotColumns || [],
256
- PivotAggregationColumns: layout.PivotAggregationColumns || [],
257
- PivotGroupedColumns: layout.PivotGroupedColumns || [],
258
- ColumnSizing: layout.ColumnSizing || {},
253
+ ColumnSizing: pivotLayout.ColumnSizing || {},
254
+ ColumnHeaders: pivotLayout.ColumnHeaders || {},
255
+ ColumnPinning: pivotLayout.ColumnPinning || {},
256
+ ColumnSorts: pivotLayout.ColumnSorts || [],
257
+ ColumnFilters: pivotLayout.ColumnFilters || [],
258
+ PivotColumns: pivotLayout.PivotColumns || [],
259
+ PivotAggregationColumns: pivotLayout.PivotAggregationColumns || [],
260
+ PivotGroupedColumns: pivotLayout.PivotGroupedColumns || [],
259
261
  };
260
262
  return result;
261
263
  }
262
- export function CreateEmptyLayout(layout, adaptableColumns) {
263
- if (isPivotLayout(layout)) {
264
- return CreateEmptyPivotLayout(layout);
265
- }
266
- const tableLayout = layout;
264
+ export function CreateEmptyTableLayout(tableLayout) {
267
265
  const result = {
268
266
  ...tableLayout,
269
267
  Uuid: createUuid(),
270
- TableColumns: tableLayout.TableColumns || [],
268
+ ColumnSizing: tableLayout.ColumnSizing || {},
269
+ ColumnHeaders: tableLayout.ColumnHeaders || {},
270
+ ColumnPinning: tableLayout.ColumnPinning || {},
271
271
  ColumnSorts: tableLayout.ColumnSorts || [],
272
272
  ColumnFilters: tableLayout.ColumnFilters || [],
273
- ColumnSizing: tableLayout.ColumnSizing || {},
274
- RowGroupedColumns: tableLayout.RowGroupedColumns ||
275
- (adaptableColumns ? adaptableColumns.filter((c) => c.isGrouped).map((c) => c.columnId) : []),
273
+ TableColumns: tableLayout.TableColumns || [],
274
+ RowGroupedColumns: tableLayout.RowGroupedColumns || [],
276
275
  };
277
276
  return result;
278
277
  }
278
+ export function CreateEmptyLayout(layout) {
279
+ if (isPivotLayout(layout)) {
280
+ return CreateEmptyPivotLayout(layout);
281
+ }
282
+ else {
283
+ return CreateEmptyTableLayout(layout);
284
+ }
285
+ }
279
286
  export function CreateEmptyStyle() {
280
287
  return {
281
288
  BackColor: undefined,
@@ -444,6 +451,7 @@ export const ObjectFactory = {
444
451
  CreateEmptyFreeTextColumn,
445
452
  CreateEmptyLayout,
446
453
  CreateEmptyPivotLayout,
454
+ CreateEmptyTableLayout,
447
455
  CreateColumnFilter,
448
456
  CreateEmptyStyle,
449
457
  CreateEmptyCellSummmary,
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import * as LayoutRedux from '../../../Redux/ActionsReducers/LayoutRedux';
3
3
  import { OnePageAdaptableWizard, OnePageWizardSummary } from '../../Wizard/OnePageAdaptableWizard';
4
- import ObjectFactory from '../../../Utilities/ObjectFactory';
5
4
  import { cloneObject } from '../../../Utilities/Helpers/Helper';
6
5
  import { SettingsSection, SettingsSectionSummary } from './sections/SettingsSection';
7
6
  import { Box } from 'rebass';
@@ -29,17 +28,17 @@ export const LayoutWizard = (props) => {
29
28
  if (initialLayout) {
30
29
  preparedLayout = cloneObject(initialLayout);
31
30
  if (props?.popupParams?.action === 'Clone') {
32
- preparedLayout.Name = '';
33
- delete preparedLayout.Uuid;
31
+ preparedLayout = {
32
+ ...adaptable.api.layoutApi.internalApi.cloneLayout(preparedLayout),
33
+ Name: '',
34
+ };
34
35
  }
35
36
  }
36
37
  else {
37
38
  const shouldCreatePivot = props.popupParams?.config?.layoutType === 'pivot' ||
38
39
  props.abObjectType?.name?.toLowerCase().includes('pivot') ||
39
40
  false;
40
- preparedLayout = shouldCreatePivot
41
- ? ObjectFactory.CreateEmptyPivotLayout({ Name: '' })
42
- : ObjectFactory.CreateEmptyLayout({ Name: '' });
41
+ preparedLayout = adaptable.api.layoutApi.internalApi.buildInitialLayout({ Name: '' }, shouldCreatePivot ? 'pivot' : 'table');
43
42
  }
44
43
  if (preparedLayout.SuppressAggFuncInHeader === undefined) {
45
44
  preparedLayout.SuppressAggFuncInHeader =
@@ -62,7 +61,6 @@ export const LayoutWizard = (props) => {
62
61
  break;
63
62
  case 'Clone':
64
63
  const clonedLayout = { ...layout };
65
- delete clonedLayout.Uuid;
66
64
  dispatch(LayoutRedux.LayoutAdd(clonedLayout));
67
65
  dispatch(LayoutRedux.LayoutSelect(clonedLayout.Name));
68
66
  break;
package/src/env.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export default {
2
2
  NEXT_PUBLIC_INFINITE_TABLE_LICENSE_KEY: "StartDate=2021-06-29|EndDate=2030-01-01|Owner=Adaptable|Type=distribution|TS=1624971462479|C=137829811,1004007071,2756196225,1839832928,3994409405,636616862" || '',
3
- PUBLISH_TIMESTAMP: 1756391396935 || Date.now(),
4
- VERSION: "21.0.0-canary.0" || '--current-version--',
3
+ PUBLISH_TIMESTAMP: 1756456060910 || Date.now(),
4
+ VERSION: "21.0.0-canary.1" || '--current-version--',
5
5
  };
@@ -2408,22 +2408,6 @@ export declare const ADAPTABLE_METAMODEL: {
2408
2408
  ref?: undefined;
2409
2409
  })[];
2410
2410
  };
2411
- CustomEditColumnValueInfo: {
2412
- name: string;
2413
- kind: string;
2414
- desc: string;
2415
- props: ({
2416
- name: string;
2417
- kind: string;
2418
- desc: string;
2419
- isOpt: boolean;
2420
- } | {
2421
- name: string;
2422
- kind: string;
2423
- desc: string;
2424
- isOpt?: undefined;
2425
- })[];
2426
- };
2427
2411
  CustomEditColumnValuesContext: {
2428
2412
  name: string;
2429
2413
  kind: string;
@@ -3024,6 +3008,28 @@ export declare const ADAPTABLE_METAMODEL: {
3024
3008
  kind: string;
3025
3009
  desc: string;
3026
3010
  };
3011
+ DefaultLayoutProperties: {
3012
+ name: string;
3013
+ kind: string;
3014
+ desc: string;
3015
+ props: {
3016
+ name: string;
3017
+ kind: string;
3018
+ desc: string;
3019
+ isOpt: boolean;
3020
+ ref: string;
3021
+ }[];
3022
+ };
3023
+ DefaultLayoutPropertiesContext: {
3024
+ name: string;
3025
+ kind: string;
3026
+ desc: string;
3027
+ };
3028
+ DefaultPivotLayoutProperties: {
3029
+ name: string;
3030
+ kind: string;
3031
+ desc: string;
3032
+ };
3027
3033
  DefaultPredicateFilterContext: {
3028
3034
  name: string;
3029
3035
  kind: string;
@@ -3040,6 +3046,11 @@ export declare const ADAPTABLE_METAMODEL: {
3040
3046
  ref: string;
3041
3047
  })[];
3042
3048
  };
3049
+ DefaultTableLayoutProperties: {
3050
+ name: string;
3051
+ kind: string;
3052
+ desc: string;
3053
+ };
3043
3054
  DetailInitContext: {
3044
3055
  name: string;
3045
3056
  kind: string;
@@ -4037,27 +4048,28 @@ export declare const ADAPTABLE_METAMODEL: {
4037
4048
  name: string;
4038
4049
  kind: string;
4039
4050
  desc: string;
4040
- props: {
4051
+ props: ({
4041
4052
  name: string;
4042
4053
  kind: string;
4043
4054
  desc: string;
4044
- }[];
4055
+ isOpt?: undefined;
4056
+ } | {
4057
+ name: string;
4058
+ kind: string;
4059
+ desc: string;
4060
+ isOpt: boolean;
4061
+ })[];
4045
4062
  };
4046
4063
  InFilterValueInfo: {
4047
4064
  name: string;
4048
4065
  kind: string;
4049
4066
  desc: string;
4050
- props: ({
4067
+ props: {
4051
4068
  name: string;
4052
4069
  kind: string;
4053
4070
  desc: string;
4054
4071
  isOpt: boolean;
4055
- } | {
4056
- name: string;
4057
- kind: string;
4058
- desc: string;
4059
- isOpt?: undefined;
4060
- })[];
4072
+ }[];
4061
4073
  };
4062
4074
  InitialState: {
4063
4075
  name: string;
@@ -4244,13 +4256,13 @@ export declare const ADAPTABLE_METAMODEL: {
4244
4256
  kind: string;
4245
4257
  desc: string;
4246
4258
  isOpt: boolean;
4247
- ref: string;
4259
+ ref?: undefined;
4248
4260
  } | {
4249
4261
  name: string;
4250
4262
  kind: string;
4251
4263
  desc: string;
4252
4264
  isOpt: boolean;
4253
- ref?: undefined;
4265
+ ref: string;
4254
4266
  })[];
4255
4267
  };
4256
4268
  LayoutState: {