Skip to content

Commit

Permalink
Merge pull request #625 from revolist/grouping-plugin
Browse files Browse the repository at this point in the history
feat: Preserver grouping, improved plugin types
  • Loading branch information
m2a2x authored Nov 7, 2024
2 parents b38e7e2 + e8c360f commit d396742
Show file tree
Hide file tree
Showing 15 changed files with 232 additions and 152 deletions.
2 changes: 1 addition & 1 deletion docs
Submodule docs updated 211 files
2 changes: 1 addition & 1 deletion packages/angular
2 changes: 1 addition & 1 deletion packages/react
Submodule react updated 2 files
+1 −1 demo/package.json
+2 −2 package.json
2 changes: 1 addition & 1 deletion packages/svelte
2 changes: 1 addition & 1 deletion packages/vue3
Submodule vue3 updated 2 files
+2 −2 demo/package.json
+2 −2 package.json
3 changes: 1 addition & 2 deletions src/components/revoGrid/revo-grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1267,8 +1267,7 @@ export class RevoGridComponent {
* Grouping
*/
@Watch('grouping') groupingChanged(newVal: GroupingOptions = {}) {
const grPlugin = this.pluginService.getByClass(GroupingRowPlugin);
grPlugin?.setGrouping(newVal || {});
this.pluginService.getByClass(GroupingRowPlugin)?.setGrouping(newVal || {});
}
/**
* Stretch Plugin Apply
Expand Down
15 changes: 8 additions & 7 deletions src/plugins/base.plugin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { h } from '@stencil/core';
import { PluginProviders, PluginBaseComponent } from '..';
import type { PluginProviders, PluginBaseComponent, RevoGridCustomEvent } from '..';

type WatchConfig = { immediate: boolean };

export type WatchConfig = { immediate: boolean };

/**
* Base layer for plugins
Expand All @@ -17,12 +18,12 @@ export class BasePlugin implements PluginBaseComponent {
* @param eventName - event name to subscribe to in revo-grid component (e.g. 'beforeheaderclick')
* @param callback - callback function for event
*/
addEventListener<T = any>(
eventName: string,
callback: (e: CustomEvent<T>) => void,
addEventListener<K extends keyof HTMLRevoGridElementEventMap>(
eventName: K,
callback: (this: BasePlugin, e: RevoGridCustomEvent<HTMLRevoGridElementEventMap[K]>) => void,
) {
this.revogrid.addEventListener(eventName, callback);
this.subscriptions[eventName] = callback;
this.revogrid.addEventListener(eventName as string, callback);
this.subscriptions[eventName as string] = callback;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/groupingRow/grouping.const.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DimensionRows } from '@type';
import { GRID_INTERNALS } from '../../utils/consts';

export const GROUP_DEPTH = `${GRID_INTERNALS}-depth`;
Expand All @@ -6,7 +7,8 @@ export const PSEUDO_GROUP_ITEM_ID = `${GRID_INTERNALS}-id`;
export const PSEUDO_GROUP_ITEM_VALUE = `${GRID_INTERNALS}-value`;
export const PSEUDO_GROUP_COLUMN = `${GRID_INTERNALS}-column`;
export const GROUP_EXPANDED = `${GRID_INTERNALS}-expanded`;
export const GROUP_COLUMN_PROP = `${GRID_INTERNALS}-prop`;
export const GROUP_ORIGINAL_INDEX = `${GRID_INTERNALS}-original-index`;
export const GROUP_EXPAND_BTN = `group-expand`;
export const GROUP_EXPAND_EVENT = `groupexpandclick`;
export const GROUPING_ROW_TYPE = 'rgRow';
export const GROUPING_ROW_TYPE: DimensionRows = 'rgRow';
Loading

0 comments on commit d396742

Please sign in to comment.