@toolbox-web/grid-react 0.17.2 → 0.17.3
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/features/grouping-columns.js +26 -19
- package/lib/feature-props.d.ts +11 -2
- package/lib/feature-props.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import { GroupingColumnsPlugin as
|
|
2
|
-
import { flushSync as
|
|
3
|
-
import { createRoot as
|
|
4
|
-
import { registerFeature as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { GroupingColumnsPlugin as t } from "@toolbox-web/grid/plugins/grouping-columns";
|
|
2
|
+
import { flushSync as i } from "react-dom";
|
|
3
|
+
import { createRoot as p } from "react-dom/client";
|
|
4
|
+
import { registerFeature as s } from "@toolbox-web/grid/features/registry";
|
|
5
|
+
function u(o) {
|
|
6
|
+
return (e) => {
|
|
7
|
+
const n = document.createElement("div");
|
|
8
|
+
n.style.display = "contents";
|
|
9
|
+
const r = p(n);
|
|
10
|
+
return i(() => {
|
|
11
|
+
r.render(o(e));
|
|
12
|
+
}), n;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
s("groupingColumns", (o) => {
|
|
16
|
+
if (typeof o == "boolean") return new t();
|
|
17
|
+
if (!o) return new t();
|
|
18
|
+
const e = o, n = { ...e };
|
|
19
|
+
if (typeof e.groupHeaderRenderer == "function") {
|
|
20
|
+
const r = e.groupHeaderRenderer;
|
|
21
|
+
n.groupHeaderRenderer = u(r);
|
|
19
22
|
}
|
|
20
|
-
return
|
|
23
|
+
return Array.isArray(e.columnGroups) && (n.columnGroups = e.columnGroups.map((r) => {
|
|
24
|
+
if (typeof r.renderer != "function") return r;
|
|
25
|
+
const c = r.renderer;
|
|
26
|
+
return { ...r, renderer: u(c) };
|
|
27
|
+
})), new t(n);
|
|
21
28
|
});
|
package/lib/feature-props.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ClipboardConfig, ColumnVirtualizationConfig, ContextMenuConfig, ExportConfig, FilterConfig, GroupingColumnsConfig, GroupingRowsConfig, MasterDetailConfig, MultiSortConfig, PinnedRowsConfig, PivotConfig, PrintConfig, ReorderConfig, ResponsivePluginConfig, RowReorderConfig, SelectionConfig, ServerSideConfig, TreeConfig, UndoRedoConfig, VisibilityConfig } from '@toolbox-web/grid/all';
|
|
2
2
|
import { EditingConfig } from '@toolbox-web/grid/plugins/editing';
|
|
3
3
|
import { FilterPanelParams } from '@toolbox-web/grid/plugins/filtering';
|
|
4
|
+
import { ColumnGroupDefinition } from '@toolbox-web/grid/plugins/grouping-columns';
|
|
4
5
|
import { ReactNode } from 'react';
|
|
5
6
|
/**
|
|
6
7
|
* React-specific filter config that allows React components as `filterPanelRenderer`.
|
|
@@ -13,12 +14,20 @@ type ReactFilterConfig<TRow = unknown> = Omit<FilterConfig<TRow>, 'filterPanelRe
|
|
|
13
14
|
filterPanelRenderer?: FilterConfig<TRow>['filterPanelRenderer'] | ((params: FilterPanelParams) => ReactNode);
|
|
14
15
|
};
|
|
15
16
|
/**
|
|
16
|
-
* React-specific
|
|
17
|
+
* React-specific column group definition that allows React render functions as `renderer`.
|
|
18
|
+
*/
|
|
19
|
+
type ReactColumnGroupDefinition = Omit<ColumnGroupDefinition, 'renderer'> & {
|
|
20
|
+
renderer?: ColumnGroupDefinition['renderer'] | ((...args: Parameters<NonNullable<ColumnGroupDefinition['renderer']>>) => ReactNode);
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* React-specific grouping columns config that allows React components as `groupHeaderRenderer`
|
|
24
|
+
* and per-group `renderer` in `columnGroups`.
|
|
17
25
|
*
|
|
18
26
|
* Extends the base GroupingColumnsConfig to accept a React render function
|
|
19
27
|
* returning `ReactNode` instead of only `HTMLElement | string | void`.
|
|
20
28
|
*/
|
|
21
|
-
type ReactGroupingColumnsConfig = Omit<GroupingColumnsConfig, 'groupHeaderRenderer'> & {
|
|
29
|
+
type ReactGroupingColumnsConfig = Omit<GroupingColumnsConfig, 'groupHeaderRenderer' | 'columnGroups'> & {
|
|
30
|
+
columnGroups?: ReactColumnGroupDefinition[];
|
|
22
31
|
groupHeaderRenderer?: GroupingColumnsConfig['groupHeaderRenderer'] | ((...args: Parameters<NonNullable<GroupingColumnsConfig['groupHeaderRenderer']>>) => ReactNode);
|
|
23
32
|
};
|
|
24
33
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-props.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/feature-props.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAC1B,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,aAAa,EACb,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC;;;;;;GAMG;AACH,KAAK,iBAAiB,CAAC,IAAI,GAAG,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,qBAAqB,CAAC,GAAG;IACzF,mBAAmB,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,qBAAqB,CAAC,GAAG,CAAC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