@genesislcap/grid-pro 15.13.1 → 15.14.0-FUI-2601.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 (56) hide show
  1. package/dist/custom-elements.json +1988 -563
  2. package/dist/dts/columns-tool-panel/columns-tool-panel.d.ts +98 -0
  3. package/dist/dts/columns-tool-panel/columns-tool-panel.d.ts.map +1 -0
  4. package/dist/dts/columns-tool-panel/columns-tool-panel.styles.d.ts +9 -0
  5. package/dist/dts/columns-tool-panel/columns-tool-panel.styles.d.ts.map +1 -0
  6. package/dist/dts/columns-tool-panel/columns-tool-panel.template.d.ts +12 -0
  7. package/dist/dts/columns-tool-panel/columns-tool-panel.template.d.ts.map +1 -0
  8. package/dist/dts/columns-tool-panel/columns-tool-panel.utils.d.ts +24 -0
  9. package/dist/dts/columns-tool-panel/columns-tool-panel.utils.d.ts.map +1 -0
  10. package/dist/dts/columns-tool-panel/index.d.ts +5 -0
  11. package/dist/dts/columns-tool-panel/index.d.ts.map +1 -0
  12. package/dist/dts/grid-pro-beta.d.ts +39 -4
  13. package/dist/dts/grid-pro-beta.d.ts.map +1 -1
  14. package/dist/dts/grid-pro.d.ts +10 -0
  15. package/dist/dts/grid-pro.d.ts.map +1 -1
  16. package/dist/dts/grid-pro.styles.d.ts.map +1 -1
  17. package/dist/dts/grid-pro.template.d.ts.map +1 -1
  18. package/dist/dts/grid-pro.types.d.ts +10 -0
  19. package/dist/dts/grid-pro.types.d.ts.map +1 -1
  20. package/dist/dts/index.d.ts +2 -0
  21. package/dist/dts/index.d.ts.map +1 -1
  22. package/dist/dts/react.d.ts +24 -4
  23. package/dist/dts/side-bar/index.d.ts +6 -0
  24. package/dist/dts/side-bar/index.d.ts.map +1 -0
  25. package/dist/dts/side-bar/side-bar.d.ts +412 -0
  26. package/dist/dts/side-bar/side-bar.d.ts.map +1 -0
  27. package/dist/dts/side-bar/side-bar.styles.d.ts +19 -0
  28. package/dist/dts/side-bar/side-bar.styles.d.ts.map +1 -0
  29. package/dist/dts/side-bar/side-bar.template.d.ts +11 -0
  30. package/dist/dts/side-bar/side-bar.template.d.ts.map +1 -0
  31. package/dist/dts/side-bar/side-bar.tools.d.ts +12 -0
  32. package/dist/dts/side-bar/side-bar.tools.d.ts.map +1 -0
  33. package/dist/dts/side-bar/side-bar.types.d.ts +77 -0
  34. package/dist/dts/side-bar/side-bar.types.d.ts.map +1 -0
  35. package/dist/esm/columns-tool-panel/columns-tool-panel.js +312 -0
  36. package/dist/esm/columns-tool-panel/columns-tool-panel.styles.js +122 -0
  37. package/dist/esm/columns-tool-panel/columns-tool-panel.template.js +79 -0
  38. package/dist/esm/columns-tool-panel/columns-tool-panel.utils.js +129 -0
  39. package/dist/esm/columns-tool-panel/index.js +4 -0
  40. package/dist/esm/grid-pro-beta.js +89 -3
  41. package/dist/esm/grid-pro.js +24 -1
  42. package/dist/esm/grid-pro.styles.js +4 -0
  43. package/dist/esm/grid-pro.template.js +18 -2
  44. package/dist/esm/grid-pro.types.js +11 -0
  45. package/dist/esm/index.js +2 -0
  46. package/dist/esm/side-bar/index.js +5 -0
  47. package/dist/esm/side-bar/side-bar.js +166 -0
  48. package/dist/esm/side-bar/side-bar.styles.js +154 -0
  49. package/dist/esm/side-bar/side-bar.template.js +48 -0
  50. package/dist/esm/side-bar/side-bar.tools.js +19 -0
  51. package/dist/esm/side-bar/side-bar.types.js +45 -0
  52. package/dist/grid-pro.api.json +8838 -6330
  53. package/dist/grid-pro.d.ts +906 -168
  54. package/dist/react.cjs +17 -3
  55. package/dist/react.mjs +14 -2
  56. package/package.json +14 -14
@@ -11,17 +11,19 @@ import { GridProCell } from './cell';
11
11
  import { DateEditor, MultiselectEditor, NumberEditor, SelectEditor, StringEditor, } from './cell-editors';
12
12
  import { ActionRenderer, ActionsMenuRenderer, BooleanRenderer, EditableRenderer, IconRenderer, SelectRenderer, StatusPillRenderer, } from './cell-renderers';
13
13
  import { GridProColumn, resolveVisibleColumnFields } from './column';
14
+ import { ColumnsToolPanel, resolveGridProSideBar } from './columns-tool-panel';
14
15
  import { GridProClientSideDatasource, GridProServerSideDatasource } from './datasource';
15
16
  import { baseDatasourceEventNames } from './datasource/base.types';
16
17
  import { GridProGenesisDatasource, gridProGenesisDatasourceEventNames, } from './grid-pro-genesis-datasource';
17
18
  import { datasourceEventNames, } from './grid-pro-genesis-datasource/datasource-events.types';
18
19
  import { AG_PROPERTIES, copyAttributesToGridOptions, DEBOUNCED_RESIZE_TIME, gridProErrorNames, gridProEventNames, } from './grid-pro.definitions';
19
- import { DEFAULT_STATUS_BAR_CONFIG, EDITED_COLUMN_FIELD, ERROR_COLUMN_FIELD, GRID_READY_EVENT, GridOptionsConfig, GridProRendererTypes, GridProStatusBarTypes, } from './grid-pro.types';
20
+ import { DEFAULT_STATUS_BAR_CONFIG, EDITED_COLUMN_FIELD, ERROR_COLUMN_FIELD, GRID_READY_EVENT, GridOptionsConfig, GridProRendererTypes, GridProStatusBarTypes, GridProToolPanelTypes, } from './grid-pro.types';
21
+ import { GRID_PRO_DEFAULT_SIDE_BAR_TOOLS, GridProSideBar, resolveAgSideBarToolPanels, } from './side-bar';
20
22
  import { StatePersistence } from './state-persistence';
21
23
  import { LabelValueStatusBarComponent, LoadMoreStatusBarComponent, ReloadStatusBarComponent, RowCountStatusBarComponent, } from './status-bar-components';
22
24
  import { ErrorTooltip } from './tooltips';
23
25
  import { convertToKebabCase, logger, mergeAndDedupColDefWithColumnState, sanitizeColumnState, } from './utils';
24
- avoidTreeShaking(GridProGenesisDatasource, GridProClientSideDatasource, GridProServerSideDatasource, GridProCell, GridProColumn);
26
+ avoidTreeShaking(GridProGenesisDatasource, GridProClientSideDatasource, GridProServerSideDatasource, GridProCell, GridProColumn, GridProSideBar);
25
27
  ModuleRegistry.registerModules([
26
28
  CsvExportModule,
27
29
  ClientSideRowModelModule,
@@ -91,6 +93,30 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
91
93
  this.gridApi.setGridOption('rowData', rowData);
92
94
  }
93
95
  }
96
+ /**
97
+ * The slot ref binds asynchronously, and the queued `initGrid` skips any run that beats it. FAST
98
+ * calls this the moment the ref lands, so a grid whose options were set BEFORE the view bound
99
+ * still initialises rather than staying blank — closing the one gap that skip would leave.
100
+ *
101
+ * Guarded on `agGridOptions` as well: without options there is nothing to build, and AG Grid
102
+ * would only log "no gridOptions provided to the grid". Those arrive via a grid-options change,
103
+ * which re-runs `initGrid` on its own.
104
+ */
105
+ gridSlotChanged() {
106
+ if (this.gridSlot && !this.initialised && this.agGridOptions) {
107
+ this.initGrid();
108
+ }
109
+ }
110
+ sideBarToolsChanged() {
111
+ if (this.withSideBar && this.initialised && this.gridApi) {
112
+ this.applyCommunitySideBarOptions();
113
+ }
114
+ }
115
+ /** Resolved tools list used by the template. */
116
+ get resolvedSideBarTools() {
117
+ var _a;
118
+ return ((_a = this.sideBarTools) === null || _a === void 0 ? void 0 : _a.length) ? this.sideBarTools : GRID_PRO_DEFAULT_SIDE_BAR_TOOLS;
119
+ }
94
120
  getfilterModel() {
95
121
  return __awaiter(this, void 0, void 0, function* () {
96
122
  if (!this.persistFilterModelKey) {
@@ -154,6 +180,15 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
154
180
  * This requires AG Grid Enterprise module to be available for the status bar to be displayed when enabled.
155
181
  */
156
182
  this.withStatusBar = false;
183
+ /**
184
+ * Community side bar shell (no AG side-bar chrome). Tools come from `sideBarTools`.
185
+ */
186
+ this.withSideBar = false;
187
+ /**
188
+ * Dynamic side-bar tools (Columns, AG Filters, custom `IToolPanelComp`, etc.).
189
+ * Defaults to {@link GRID_PRO_DEFAULT_SIDE_BAR_TOOLS} (Columns only).
190
+ */
191
+ this.sideBarTools = null;
157
192
  this.applyingDatasourceGridOptions = false;
158
193
  this.rehydrationAttempted = false;
159
194
  this.rootEventsListeners = [];
@@ -355,6 +390,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
355
390
  }
356
391
  this.initialised = false;
357
392
  this.resetGridOptionsState();
393
+ this.destroySideBarTools();
358
394
  this.destroyGridInstance();
359
395
  // Only remove datasource listeners on a real teardown. A blocked (reflow) disconnect must
360
396
  // leave them in place, or a grid that survives the reflow stops reacting to datasource
@@ -666,6 +702,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
666
702
  [GridProStatusBarTypes.loadMore]: LoadMoreStatusBarComponent,
667
703
  [GridProStatusBarTypes.reload]: ReloadStatusBarComponent,
668
704
  [GridProStatusBarTypes.rowCount]: RowCountStatusBarComponent,
705
+ [GridProToolPanelTypes.columns]: ColumnsToolPanel,
669
706
  };
670
707
  return Object.assign(Object.assign(Object.assign({}, defaultFoundationAgComponents), gridOptionsComponents), this.gridComponents);
671
708
  }
@@ -998,6 +1035,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
998
1035
  this.restoreColumnState();
999
1036
  this.restoreCachedFilterConfig();
1000
1037
  this.debouncedColumnAutosize();
1038
+ DOM.queueUpdate(() => { var _a; return (_a = this.sideBar) === null || _a === void 0 ? void 0 : _a.mountActiveTool(); });
1001
1039
  }), onFirstDataRendered: (event) => {
1002
1040
  // Safety net: by now the grid columns are populated, so (re)seed the datasource's visible
1003
1041
  // columns in case the initial grid-ready seed ran before columns were available.
@@ -1048,6 +1086,40 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1048
1086
  setLocalGridOptions(derivedOptions) {
1049
1087
  // Merge options with reflected AG properties from attributes
1050
1088
  this.agGridOptions = Object.assign(Object.assign({}, this.agGridOptions), copyAttributesToGridOptions(derivedOptions, this.agAttributes));
1089
+ if (this.withSideBar) {
1090
+ this.applyCommunitySideBarOptions();
1091
+ }
1092
+ else {
1093
+ this.agGridOptions.sideBar = resolveGridProSideBar(this.agGridOptions.sideBar);
1094
+ }
1095
+ }
1096
+ applyCommunitySideBarOptions() {
1097
+ if (!this.agGridOptions) {
1098
+ return;
1099
+ }
1100
+ const toolPanels = resolveAgSideBarToolPanels(this.resolvedSideBarTools);
1101
+ this.agGridOptions.sideBar = toolPanels.length
1102
+ ? {
1103
+ toolPanels,
1104
+ hiddenByDefault: true,
1105
+ hideButtons: true,
1106
+ }
1107
+ : undefined;
1108
+ if (this.gridApi && typeof this.gridApi.setGridOption === 'function') {
1109
+ this.gridApi.setGridOption('sideBar', this.agGridOptions.sideBar);
1110
+ }
1111
+ }
1112
+ /**
1113
+ * Selects a Community side-bar tool. Clicking the active open tool collapses the panel.
1114
+ * @public
1115
+ */
1116
+ selectSideBarTool(tool) {
1117
+ var _a;
1118
+ (_a = this.sideBar) === null || _a === void 0 ? void 0 : _a.selectTool(tool);
1119
+ }
1120
+ destroySideBarTools() {
1121
+ var _a;
1122
+ (_a = this.sideBar) === null || _a === void 0 ? void 0 : _a.destroyTools();
1051
1123
  }
1052
1124
  /**
1053
1125
  * Clears the local grid options, this is used to clear the grid options when the grid is restarted.
@@ -1062,7 +1134,12 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
1062
1134
  }
1063
1135
  initGrid() {
1064
1136
  DOM.queueUpdate(() => {
1065
- if (this.disposed || !this.isConnected) {
1137
+ // `gridSlot` is a template ref, so it is undefined until the view binds, and this task runs
1138
+ // on the shared update queue — an options change can queue it ahead of that binding. Reading
1139
+ // `.firstChild` off it unguarded then throws from INSIDE a queued task, which the runner can
1140
+ // only report against whichever test is running. Same guard as `grid-pro.ts`; both callers
1141
+ // re-run on the next grid-options change, so skipping strands nothing.
1142
+ if (this.disposed || !this.isConnected || !this.gridSlot) {
1066
1143
  return;
1067
1144
  }
1068
1145
  if (this.initialised) {
@@ -1360,6 +1437,15 @@ __decorate([
1360
1437
  __decorate([
1361
1438
  attr({ mode: 'boolean', attribute: 'with-status-bar' })
1362
1439
  ], GridProBeta.prototype, "withStatusBar", void 0);
1440
+ __decorate([
1441
+ attr({ mode: 'boolean', attribute: 'with-side-bar' })
1442
+ ], GridProBeta.prototype, "withSideBar", void 0);
1443
+ __decorate([
1444
+ observable
1445
+ ], GridProBeta.prototype, "sideBarTools", void 0);
1446
+ __decorate([
1447
+ observable
1448
+ ], GridProBeta.prototype, "sideBar", void 0);
1363
1449
  __decorate([
1364
1450
  observable
1365
1451
  ], GridProBeta.prototype, "customErrorHandlerTemplate", void 0);
@@ -59,6 +59,20 @@ export class GridPro extends LifecycleMixin(FoundationElement) {
59
59
  this.classNames = classNames(agThemeTokenMapClassname(newValue), newValue);
60
60
  this.insertFontFace(newValue);
61
61
  }
62
+ /**
63
+ * The slot ref binds asynchronously, and the queued `initGrid` skips any run that beats it. FAST
64
+ * calls this the moment the ref lands, so a grid whose options were set BEFORE the view bound
65
+ * still initialises rather than staying blank — closing the one gap that skip would leave.
66
+ *
67
+ * Guarded on `agGridOptions` as well: without options there is nothing to build, and AG Grid
68
+ * would only log "no gridOptions provided to the grid". Those arrive via a grid-options change,
69
+ * which re-runs `initGrid` on its own.
70
+ */
71
+ gridSlotChanged() {
72
+ if (this.gridSlot && !this.initialised && this.agGridOptions) {
73
+ this.initGrid();
74
+ }
75
+ }
62
76
  getfilterModel() {
63
77
  return __awaiter(this, void 0, void 0, function* () {
64
78
  if (!this.persistFilterModelKey) {
@@ -1092,7 +1106,16 @@ export class GridPro extends LifecycleMixin(FoundationElement) {
1092
1106
  }
1093
1107
  initGrid() {
1094
1108
  DOM.queueUpdate(() => {
1095
- if (this.disposed || !this.isConnected) {
1109
+ // `gridSlot` belongs in this readiness check, not just `disposed`/`isConnected`: it is a
1110
+ // template ref, so it is undefined until the view binds, and this task runs on the shared
1111
+ // update queue — an options change can queue it ahead of the binding that fills the ref.
1112
+ // Every other reader in this file already guards it; these two lines did not, so that
1113
+ // ordering threw `Cannot read properties of undefined (reading 'firstChild')` from INSIDE a
1114
+ // queued task. Such a throw is not attributable to whatever caused it: web-test-runner
1115
+ // reports it as an uncaught page exception against whichever test happens to be running,
1116
+ // which is how it surfaced — as an unrelated datasource test failing only under CI load.
1117
+ // Skipping is safe because both callers re-run on the next grid-options change.
1118
+ if (this.disposed || !this.isConnected || !this.gridSlot) {
1096
1119
  return;
1097
1120
  }
1098
1121
  if (this.initialised) {
@@ -1,6 +1,8 @@
1
1
  import { css } from '@microsoft/fast-element';
2
2
  import { errorHandlerDialogStyles } from './datasource/error-handler.dialog';
3
+ import { columnsToolPanelStyles } from './columns-tool-panel/columns-tool-panel.styles';
3
4
  import { agExternalStockStyles } from './external';
5
+ import { gridProSideBarHostStyles } from './side-bar/side-bar.styles';
4
6
  /**
5
7
  * Workaround for an AG Grid (v36, still present in v36.1.0) drag-ghost positioning bug in
6
8
  * shadow DOM. The row-drag "N rows" ghost is appended to the grid's containing shadow root
@@ -39,6 +41,8 @@ export const foundationGridProStyles = css `
39
41
  ${agExternalStockStyles}
40
42
  ${errorHandlerDialogStyles}
41
43
  ${agDragGhostShadowDomStyles}
44
+ ${gridProSideBarHostStyles}
45
+ ${columnsToolPanelStyles}
42
46
  :host {
43
47
  --datasource-error-background-color: var(--neutral-layer-4);
44
48
  --datasource-error-background-opacity: 0.5;
@@ -1,4 +1,5 @@
1
- import { html, ref } from '@microsoft/fast-element';
1
+ import { html, ref, when } from '@microsoft/fast-element';
2
+ import { classNames } from '@microsoft/fast-web-utilities';
2
3
  import { getErrorHandlerDialogTemplate } from './datasource/error-handler.dialog';
3
4
  /**
4
5
  * Get a Design System prefixed The Grid Pro template.
@@ -8,10 +9,25 @@ import { getErrorHandlerDialogTemplate } from './datasource/error-handler.dialog
8
9
  */
9
10
  export const getGridProTemplate = (prefix = 'foundation') => html `
10
11
  <template>
11
- <span part="grid" data-ag-theme-mode=${(x) => x.themeMode} class="${(x) => x.classNames}">
12
+ <span
13
+ part="grid"
14
+ data-ag-theme-mode=${(x) => x.themeMode}
15
+ class="${(x) => classNames(x.classNames, ['with-side-bar', !!x.withSideBar])}"
16
+ >
12
17
  <slot name="grid" ${ref('gridSlot')}></slot>
13
18
  <slot></slot>
14
19
  </span>
20
+ ${when((x) => !!x.withSideBar, html `
21
+ <grid-pro-side-bar
22
+ class="grid-pro-side-bar"
23
+ part="side-bar"
24
+ data-test-id="grid-pro-side-bar"
25
+ prefix="${() => prefix}"
26
+ ${ref('sideBar')}
27
+ :tools="${(x) => x.resolvedSideBarTools}"
28
+ :gridApi="${(x) => x.gridApi}"
29
+ ></grid-pro-side-bar>
30
+ `)}
15
31
  ${(x) => x.customErrorHandlerTemplate
16
32
  ? x.customErrorHandlerTemplate(prefix, x.gridErrorItems.filter(({ type }) => type === 'datasource'))
17
33
  : getErrorHandlerDialogTemplate(prefix, x.gridErrorItems.filter(({ type }) => type === 'datasource'))}
@@ -152,6 +152,17 @@ export var GridProStatusBarTypes;
152
152
  GridProStatusBarTypes["reload"] = "reload";
153
153
  GridProStatusBarTypes["rowCount"] = "rowCount";
154
154
  })(GridProStatusBarTypes || (GridProStatusBarTypes = {}));
155
+ /**
156
+ * Custom Grid Pro tool panel component names.
157
+ * @public
158
+ * @remarks
159
+ * Registered for AG `sideBar` hosts (`SideBarModule` still required for that path).
160
+ * Prefer `with-side-bar` on {@link GridProBeta} for a Community-only columns UI.
161
+ */
162
+ export var GridProToolPanelTypes;
163
+ (function (GridProToolPanelTypes) {
164
+ GridProToolPanelTypes["columns"] = "gridProColumnsToolPanel";
165
+ })(GridProToolPanelTypes || (GridProToolPanelTypes = {}));
155
166
  /**
156
167
  * Event fired when grid is ready
157
168
  * @public
package/dist/esm/index.js CHANGED
@@ -2,6 +2,7 @@ export * from './cell';
2
2
  export * from './cell-renderers';
3
3
  export * from './cell-editors';
4
4
  export * from './column';
5
+ export * from './columns-tool-panel';
5
6
  export * from './datasource';
6
7
  export * from './external';
7
8
  export * from './grid-components';
@@ -12,6 +13,7 @@ export * from './grid-pro.types';
12
13
  export * from './grid-pro';
13
14
  export * from './grid-pro-genesis-datasource';
14
15
  export * from './multicolumn-dropdown';
16
+ export * from './side-bar';
15
17
  export * from './state-persistence';
16
18
  export * from './status-bar-components';
17
19
  export * from './style';
@@ -0,0 +1,5 @@
1
+ export * from './side-bar.types';
2
+ export * from './side-bar.tools';
3
+ export * from './side-bar.styles';
4
+ export * from './side-bar.template';
5
+ export * from './side-bar';
@@ -0,0 +1,166 @@
1
+ import { __decorate } from "tslib";
2
+ import { insertDocumentCSSRule, LifecycleMixin } from '@genesislcap/foundation-utils';
3
+ import { attr, customElement, observable } from '@microsoft/fast-element';
4
+ import { FoundationElement } from '@microsoft/fast-foundation';
5
+ import { agGridAlpineFontFace } from '../external/fonts';
6
+ import { agThemeFontsId } from '../grid-pro.types';
7
+ import { gridProSideBarChromeStyles } from './side-bar.styles';
8
+ import { getGridProSideBarTemplate } from './side-bar.template';
9
+ import { GRID_PRO_DEFAULT_SIDE_BAR_TOOLS } from './side-bar.tools';
10
+ import { GridProSideBarTool, initLocalSideBarPanel, } from './side-bar.types';
11
+ /**
12
+ * The Grid Pro Side Bar element.
13
+ * @remarks No shadow root — chrome stays in Grid Pro's tree so host CSS still applies.
14
+ * @public
15
+ * @remarks
16
+ * HTML Element: \<grid-pro-side-bar\>
17
+ */
18
+ let GridProSideBar = class GridProSideBar extends LifecycleMixin(FoundationElement) {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.prefix = 'foundation';
22
+ this.tools = GRID_PRO_DEFAULT_SIDE_BAR_TOOLS;
23
+ this.open = false;
24
+ this.activeTool = GridProSideBarTool.columns;
25
+ this.mountedPanels = new Map();
26
+ }
27
+ prefixChanged() {
28
+ if (this.$fastController) {
29
+ this.$fastController.template = getGridProSideBarTemplate(this.prefix || 'foundation');
30
+ }
31
+ }
32
+ toolsChanged() {
33
+ var _a, _b, _c, _d;
34
+ if (!((_a = this.tools) === null || _a === void 0 ? void 0 : _a.some((t) => t.id === this.activeTool))) {
35
+ this.activeTool = (_d = (_c = (_b = this.tools) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : GridProSideBarTool.columns;
36
+ }
37
+ this.mountActiveTool();
38
+ }
39
+ gridApiChanged() {
40
+ this.mountActiveTool();
41
+ }
42
+ panelHostChanged() {
43
+ this.mountActiveTool();
44
+ }
45
+ connectedCallback() {
46
+ super.connectedCallback();
47
+ insertDocumentCSSRule(agGridAlpineFontFace, agThemeFontsId('alpine'));
48
+ }
49
+ disconnectedCallback() {
50
+ this.destroyTools();
51
+ super.disconnectedCallback();
52
+ }
53
+ /**
54
+ * Selects a tool. Clicking the active open tool collapses the panel.
55
+ * @public
56
+ */
57
+ selectTool(tool) {
58
+ var _a;
59
+ if (!((_a = this.tools) === null || _a === void 0 ? void 0 : _a.some((t) => t.id === tool))) {
60
+ return;
61
+ }
62
+ if (this.activeTool === tool && this.open) {
63
+ this.open = false;
64
+ this.closeAgToolPanel();
65
+ return;
66
+ }
67
+ this.activeTool = tool;
68
+ this.open = true;
69
+ this.mountActiveTool();
70
+ }
71
+ /**
72
+ * @internal
73
+ */
74
+ handleToolClick(id) {
75
+ this.selectTool(id);
76
+ }
77
+ /**
78
+ * @public
79
+ */
80
+ mountActiveTool() {
81
+ var _a, _b, _c, _d, _e;
82
+ if (!this.gridApi || !this.panelHost) {
83
+ return;
84
+ }
85
+ if (!this.open) {
86
+ this.closeAgToolPanel();
87
+ return;
88
+ }
89
+ const def = (_a = this.tools) === null || _a === void 0 ? void 0 : _a.find((t) => t.id === this.activeTool);
90
+ if (!def) {
91
+ this.panelHost.replaceChildren();
92
+ return;
93
+ }
94
+ if (def.createPanel) {
95
+ this.closeAgToolPanel();
96
+ let mounted = this.mountedPanels.get(def.id);
97
+ if (!mounted) {
98
+ const panel = initLocalSideBarPanel(def.createPanel(), Object.assign({ api: this.gridApi }, ((_b = def.toolPanelParams) !== null && _b !== void 0 ? _b : {})));
99
+ mounted = { defId: def.id, panel };
100
+ this.mountedPanels.set(def.id, mounted);
101
+ }
102
+ const gui = mounted.panel.getGui();
103
+ if (gui instanceof HTMLElement &&
104
+ gui.tagName.toLowerCase() === 'grid-pro-columns-tool-panel') {
105
+ gui.setAttribute('prefix', this.prefix || 'foundation');
106
+ }
107
+ this.panelHost.replaceChildren(gui);
108
+ (_d = (_c = mounted.panel).refresh) === null || _d === void 0 ? void 0 : _d.call(_c, Object.assign({ api: this.gridApi }, ((_e = def.toolPanelParams) !== null && _e !== void 0 ? _e : {})));
109
+ return;
110
+ }
111
+ if (def.toolPanel != null) {
112
+ this.panelHost.replaceChildren();
113
+ if (typeof this.gridApi.openToolPanel === 'function') {
114
+ this.gridApi.openToolPanel(def.id, this.panelHost);
115
+ }
116
+ return;
117
+ }
118
+ this.panelHost.replaceChildren();
119
+ }
120
+ /**
121
+ * @public
122
+ */
123
+ destroyTools() {
124
+ var _a, _b, _c, _d;
125
+ this.closeAgToolPanel();
126
+ for (const mounted of this.mountedPanels.values()) {
127
+ (_a = mounted.destroy) === null || _a === void 0 ? void 0 : _a.call(mounted);
128
+ (_c = (_b = mounted.panel).destroy) === null || _c === void 0 ? void 0 : _c.call(_b);
129
+ }
130
+ this.mountedPanels.clear();
131
+ (_d = this.panelHost) === null || _d === void 0 ? void 0 : _d.replaceChildren();
132
+ }
133
+ closeAgToolPanel() {
134
+ var _a;
135
+ if (typeof ((_a = this.gridApi) === null || _a === void 0 ? void 0 : _a.closeToolPanel) === 'function') {
136
+ this.gridApi.closeToolPanel();
137
+ }
138
+ }
139
+ };
140
+ __decorate([
141
+ attr
142
+ ], GridProSideBar.prototype, "prefix", void 0);
143
+ __decorate([
144
+ observable
145
+ ], GridProSideBar.prototype, "tools", void 0);
146
+ __decorate([
147
+ observable
148
+ ], GridProSideBar.prototype, "gridApi", void 0);
149
+ __decorate([
150
+ observable
151
+ ], GridProSideBar.prototype, "open", void 0);
152
+ __decorate([
153
+ observable
154
+ ], GridProSideBar.prototype, "activeTool", void 0);
155
+ __decorate([
156
+ observable
157
+ ], GridProSideBar.prototype, "panelHost", void 0);
158
+ GridProSideBar = __decorate([
159
+ customElement({
160
+ name: 'grid-pro-side-bar',
161
+ template: getGridProSideBarTemplate(),
162
+ styles: gridProSideBarChromeStyles,
163
+ shadowOptions: null,
164
+ })
165
+ ], GridProSideBar);
166
+ export { GridProSideBar };
@@ -0,0 +1,154 @@
1
+ import { css } from '@microsoft/fast-element';
2
+ /**
3
+ * Layout on the Grid Pro host when `with-side-bar` is set.
4
+ * @public
5
+ */
6
+ export const gridProSideBarHostStyles = css `
7
+ :host([with-side-bar]) {
8
+ display: flex;
9
+ flex-direction: row;
10
+ min-height: 0;
11
+ }
12
+
13
+ :host([with-side-bar]) [part='grid'] {
14
+ flex: 1 1 auto;
15
+ min-width: 0;
16
+ height: 100%;
17
+ }
18
+ `;
19
+ /**
20
+ * Chrome for {@link GridProSideBar}. Uses class selectors (no `:host`) because the
21
+ * element has no shadow — styles land on Grid Pro's shadow root.
22
+ * @public
23
+ */
24
+ export const gridProSideBarChromeStyles = css `
25
+ .grid-pro-side-bar {
26
+ --ag-icon-font-family: agGridAlpine;
27
+ --ag-icon-size: 16px;
28
+ display: flex;
29
+ flex-direction: row-reverse;
30
+ flex: 0 0 auto;
31
+ min-height: 0;
32
+ height: 100%;
33
+ z-index: 1;
34
+ border-left: 1px solid var(--neutral-stroke-divider-rest, var(--ag-border-color));
35
+ background: var(--neutral-layer-2, var(--ag-control-panel-background-color));
36
+ color: var(--neutral-foreground-rest, var(--ag-foreground-color));
37
+ }
38
+
39
+ .grid-pro-side-bar-buttons {
40
+ display: flex;
41
+ flex-direction: column;
42
+ flex: 0 0 auto;
43
+ border-left: 1px solid var(--neutral-stroke-divider-rest, var(--ag-border-color));
44
+ }
45
+
46
+ .grid-pro-side-bar-button {
47
+ margin: 0;
48
+ height: auto !important;
49
+ min-height: 0;
50
+ border-bottom: 1px solid var(--neutral-stroke-divider-rest, var(--ag-border-color));
51
+ }
52
+
53
+ .grid-pro-side-bar-button::part(control) {
54
+ display: flex;
55
+ flex-direction: column;
56
+ align-items: center;
57
+ padding: 12px 8px;
58
+ border: 0;
59
+ border-radius: 0;
60
+ min-width: 0;
61
+ min-height: 0;
62
+ height: auto;
63
+ white-space: nowrap;
64
+ }
65
+
66
+ .grid-pro-side-bar-button::part(content) {
67
+ display: flex;
68
+ flex-direction: column;
69
+ align-items: center;
70
+ gap: 4px;
71
+ }
72
+
73
+ .grid-pro-side-bar-button-icon {
74
+ display: block;
75
+ font-family: 'agGridAlpine';
76
+ font-size: var(--ag-icon-size, 16px);
77
+ line-height: var(--ag-icon-size, 16px);
78
+ font-style: normal;
79
+ font-weight: normal;
80
+ speak: none;
81
+ -webkit-font-smoothing: antialiased;
82
+ -moz-osx-font-smoothing: grayscale;
83
+ }
84
+
85
+ .grid-pro-side-bar-button-icon::before {
86
+ font-family: 'agGridAlpine';
87
+ background-color: transparent;
88
+ }
89
+
90
+ .grid-pro-side-bar-button-icon.ag-icon-columns::before {
91
+ content: '\\f10a';
92
+ }
93
+
94
+ .grid-pro-side-bar-button-icon.ag-icon-filter::before {
95
+ content: '\\f114';
96
+ }
97
+
98
+ .grid-pro-side-bar-button-icon[hidden] {
99
+ display: none;
100
+ }
101
+
102
+ .grid-pro-side-bar-button-label {
103
+ writing-mode: vertical-rl;
104
+ }
105
+
106
+ .grid-pro-side-bar-button:hover::part(control),
107
+ .grid-pro-side-bar-button[aria-selected='true']::part(control) {
108
+ background: var(--neutral-fill-hover, rgba(255, 255, 255, 0.06));
109
+ }
110
+
111
+ .grid-pro-side-bar-button:hover::part(content)::before {
112
+ background: transparent;
113
+ }
114
+
115
+ .grid-pro-side-bar-panel {
116
+ display: flex;
117
+ flex-direction: column;
118
+ flex: 0 0 auto;
119
+ width: 260px;
120
+ max-width: 40vw;
121
+ min-height: 0;
122
+ }
123
+
124
+ .grid-pro-side-bar-panel[hidden] {
125
+ display: none;
126
+ }
127
+
128
+ .grid-pro-side-bar-panel-host {
129
+ flex: 1 1 auto;
130
+ min-height: 0;
131
+ overflow: auto;
132
+ }
133
+
134
+ .grid-pro-side-bar-panel-host .ag-filter-toolpanel,
135
+ .grid-pro-side-bar-panel-host .ag-tool-panel-wrapper {
136
+ height: 100%;
137
+ width: 100%;
138
+ }
139
+
140
+ .grid-pro-columns-checkbox {
141
+ margin: 0;
142
+
143
+ --design-unit: 3;
144
+ }
145
+ `;
146
+ /**
147
+ * Host + chrome. Prefer {@link gridProSideBarHostStyles} on Grid Pro and
148
+ * {@link gridProSideBarChromeStyles} on the side-bar element.
149
+ * @public
150
+ */
151
+ export const gridProSideBarStyles = css `
152
+ ${gridProSideBarHostStyles}
153
+ ${gridProSideBarChromeStyles}
154
+ `;
@@ -0,0 +1,48 @@
1
+ import { html, ref, repeat } from '@microsoft/fast-element';
2
+ /**
3
+ * Community side bar chrome. Prefix selects DS buttons (`rapid-button`, `zero-button`).
4
+ * @public
5
+ */
6
+ export const getGridProSideBarTemplate = (prefix = 'foundation') => {
7
+ const buttonTag = `${prefix}-button`;
8
+ return html `
9
+ <template>
10
+ <div class="grid-pro-side-bar-buttons" role="tablist" aria-label="Grid tools">
11
+ ${repeat((x) => x.tools, html `
12
+ <${buttonTag}
13
+ appearance="lightweight"
14
+ role="tab"
15
+ class="grid-pro-side-bar-button"
16
+ data-test-id="${(x) => `grid-pro-side-bar-tool-${x.id}`}"
17
+ aria-selected="${(x, c) => c.parent.open &&
18
+ c.parent.activeTool === x.id}"
19
+ @click="${(x, c) => c.parent.handleToolClick(x.id)}"
20
+ >
21
+ <span
22
+ class="ag-icon grid-pro-side-bar-button-icon ${(x) => x.iconKey ? `ag-icon-${x.iconKey}` : ''}"
23
+ aria-hidden="true"
24
+ ?hidden="${(x) => !x.iconKey}"
25
+ ></span>
26
+ <span class="grid-pro-side-bar-button-label">${(x) => x.label}</span>
27
+ </${buttonTag}>
28
+ `)}
29
+ </div>
30
+ <div
31
+ class="grid-pro-side-bar-panel"
32
+ part="side-bar-panel"
33
+ data-test-id="grid-pro-side-bar-panel"
34
+ ?hidden="${(x) => !x.open}"
35
+ >
36
+ <div
37
+ class="grid-pro-side-bar-panel-host"
38
+ data-test-id="grid-pro-side-bar-panel-host"
39
+ ${ref('panelHost')}
40
+ ></div>
41
+ </div>
42
+ </template>
43
+ `;
44
+ };
45
+ /**
46
+ * @public
47
+ */
48
+ export const gridProSideBarTemplate = getGridProSideBarTemplate();
@@ -0,0 +1,19 @@
1
+ import { ColumnsToolPanel } from '../columns-tool-panel';
2
+ import { GridProSideBarTool } from './side-bar.types';
3
+ /**
4
+ * Built-in Columns picker (Community, no AG SideBarModule).
5
+ * @public
6
+ */
7
+ export const gridProSideBarColumnsTool = {
8
+ id: GridProSideBarTool.columns,
9
+ label: 'Columns',
10
+ iconKey: 'columns',
11
+ createPanel: () => new ColumnsToolPanel(),
12
+ };
13
+ /**
14
+ * Default tools when `with-side-bar` is set and `sideBarTools` is not provided.
15
+ * @public
16
+ */
17
+ export const GRID_PRO_DEFAULT_SIDE_BAR_TOOLS = [
18
+ gridProSideBarColumnsTool,
19
+ ];