@gisce/react-ooui 2.0.0-alpha.54 → 2.0.0-alpha.55

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.
@@ -1 +1 @@
1
- {"version":3,"file":"TitleHeader.d.ts","sourceRoot":"","sources":["../../src/ui/TitleHeader.tsx"],"names":[],"mappings":"AAaA,KAAK,KAAK,GAAG;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,CAAC;AAEF,iBAAS,WAAW,CAAC,KAAK,EAAE,KAAK,2CAyFhC;AAED,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"TitleHeader.d.ts","sourceRoot":"","sources":["../../src/ui/TitleHeader.tsx"],"names":[],"mappings":"AAaA,KAAK,KAAK,GAAG;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,CAAC;AAEF,iBAAS,WAAW,CAAC,KAAK,EAAE,KAAK,2CAkGhC;AAED,eAAe,WAAW,CAAC"}
@@ -1,5 +1,5 @@
1
- import React from "react";
2
- import { TreeView } from '../../*/types';
1
+ /// <reference types="react" />
2
+ import { TreeView } from '../../../*/types';
3
3
  type Props = {
4
4
  total?: number;
5
5
  limit: number;
@@ -27,6 +27,6 @@ type Props = {
27
27
  readonly?: boolean;
28
28
  onSelectAllRecords?: () => Promise<void>;
29
29
  };
30
- declare function Tree(props: Props): React.ReactElement;
31
- export default Tree;
30
+ export declare const Tree: import("react").MemoExoticComponent<(props: Props) => import("react/jsx-runtime").JSX.Element>;
31
+ export {};
32
32
  //# sourceMappingURL=Tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tree.d.ts","sourceRoot":"","sources":["../../../../src/widgets/views/Tree/Tree.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAiBnC,KAAK,KAAK,GAAG;IACX,KA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../../../src/widgets/views/Tree/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,131 @@
1
+ import { ReactElement } from "react";
2
+ import { One2manyValue } from "../../base/one2many/One2manyInput";
3
+ export declare const BooleanComponent: ({ value, }: {
4
+ value: boolean;
5
+ }) => ReactElement;
6
+ export declare const Many2OneComponent: ({ value }: {
7
+ value: any;
8
+ }) => ReactElement;
9
+ export declare const TextComponent: ({ value }: {
10
+ value: any;
11
+ }) => ReactElement;
12
+ export declare const DateComponent: ({ value }: {
13
+ value: any;
14
+ }) => ReactElement;
15
+ export declare const DateTimeComponent: ({ value }: {
16
+ value: any;
17
+ }) => ReactElement;
18
+ export declare const One2ManyComponent: ({ value, }: {
19
+ value: One2manyValue;
20
+ }) => ReactElement;
21
+ export declare const ProgressBarComponent: ({ value, }: {
22
+ value: any;
23
+ }) => ReactElement;
24
+ export declare const FloatTimeComponent: ({ value }: {
25
+ value: any;
26
+ }) => ReactElement;
27
+ export declare const NumberComponent: ({ value }: {
28
+ value: number;
29
+ }) => ReactElement;
30
+ export declare const ImageComponent: ({ value }: {
31
+ value: string;
32
+ }) => ReactElement;
33
+ export declare const TagComponent: ({ value, key, ooui, context, }: {
34
+ value: any;
35
+ key: string;
36
+ ooui: any;
37
+ context: any;
38
+ }) => ReactElement;
39
+ export declare const SelectionComponent: ({ value, key, ooui, context, }: {
40
+ value: any;
41
+ key: string;
42
+ ooui: any;
43
+ context: any;
44
+ }) => ReactElement;
45
+ export declare const ReferenceComponent: ({ value, key, ooui, context, }: {
46
+ value: any;
47
+ key: string;
48
+ ooui: any;
49
+ context: any;
50
+ }) => ReactElement;
51
+ export declare const AvatarComponent: ({ value, key, ooui, context, }: {
52
+ value: any;
53
+ key: string;
54
+ ooui: any;
55
+ context: any;
56
+ }) => ReactElement;
57
+ export declare const TagsComponent: ({ value, key, ooui, context, }: {
58
+ value: any;
59
+ key: string;
60
+ ooui: any;
61
+ context: any;
62
+ }) => ReactElement;
63
+ export declare const COLUMN_COMPONENTS: {
64
+ boolean: ({ value, }: {
65
+ value: boolean;
66
+ }) => ReactElement;
67
+ many2one: ({ value }: {
68
+ value: any;
69
+ }) => ReactElement;
70
+ text: ({ value }: {
71
+ value: any;
72
+ }) => ReactElement;
73
+ one2many: ({ value, }: {
74
+ value: One2manyValue;
75
+ }) => ReactElement;
76
+ many2many: ({ value, }: {
77
+ value: One2manyValue;
78
+ }) => ReactElement;
79
+ progressbar: ({ value, }: {
80
+ value: any;
81
+ }) => ReactElement;
82
+ float_time: ({ value }: {
83
+ value: any;
84
+ }) => ReactElement;
85
+ image: ({ value }: {
86
+ value: string;
87
+ }) => ReactElement;
88
+ integer: ({ value }: {
89
+ value: number;
90
+ }) => ReactElement;
91
+ float: ({ value }: {
92
+ value: number;
93
+ }) => ReactElement;
94
+ reference: ({ value, key, ooui, context, }: {
95
+ value: any;
96
+ key: string;
97
+ ooui: any;
98
+ context: any;
99
+ }) => ReactElement;
100
+ tag: ({ value, key, ooui, context, }: {
101
+ value: any;
102
+ key: string;
103
+ ooui: any;
104
+ context: any;
105
+ }) => ReactElement;
106
+ selection: ({ value, key, ooui, context, }: {
107
+ value: any;
108
+ key: string;
109
+ ooui: any;
110
+ context: any;
111
+ }) => ReactElement;
112
+ date: ({ value }: {
113
+ value: any;
114
+ }) => ReactElement;
115
+ datetime: ({ value }: {
116
+ value: any;
117
+ }) => ReactElement;
118
+ avatar: ({ value, key, ooui, context, }: {
119
+ value: any;
120
+ key: string;
121
+ ooui: any;
122
+ context: any;
123
+ }) => ReactElement;
124
+ tags: ({ value, key, ooui, context, }: {
125
+ value: any;
126
+ key: string;
127
+ ooui: any;
128
+ context: any;
129
+ }) => ReactElement;
130
+ };
131
+ //# sourceMappingURL=treeComponents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeComponents.d.ts","sourceRoot":"","sources":["../../../../src/widgets/views/Tree/treeComponents.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,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,aAAa;UAClB,YAAY;;eAUP,GAAG;UACR,YAAY;;eAIuC,GAAG;UAAK,YAAY;;eAWxB,MAAM;UAAK,YAAY;;eAPtB,MAAM;UAAK,YAAY;;eAAvB,MAAM;UAAK,YAAY;;eAqDlE,GAAG;aACL,MAAM;cACL,GAAG;iBACA,GAAG;UACV,YAAY;;eAhCP,GAAG;aACL,MAAM;cACL,GAAG;iBACA,GAAG;UACV,YAAY;;eAUP,GAAG;aACL,MAAM;cACL,GAAG;iBACA,GAAG;UACV,YAAY;;eAzFkC,GAAG;UAAK,YAAY;;eAYhB,GAAG;UAAK,YAAY;;eA8GjE,GAAG;aACL,MAAM;cACL,GAAG;iBACA,GAAG;UACV,YAAY;;eAUP,GAAG;aACL,MAAM;cACL,GAAG;iBACA,GAAG;UACV,YAAY;CAoFf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/react-ooui",
3
- "version": "2.0.0-alpha.54",
3
+ "version": "2.0.0-alpha.55",
4
4
  "engines": {
5
5
  "node": "20.5.0"
6
6
  },
@@ -36,7 +36,7 @@
36
36
  "@gisce/fiber-diagram": "^1.1.0-rc.3",
37
37
  "@gisce/ooui": "1.0.0-alpha.21",
38
38
  "@gisce/react-formiga-components": "^1.0.9-rc.21",
39
- "@gisce/react-formiga-table": "1.0.0-alpha.8",
39
+ "@gisce/react-formiga-table": "1.0.0-alpha.11",
40
40
  "@monaco-editor/react": "^4.4.5",
41
41
  "@tabler/icons-react": "^2.11.0",
42
42
  "antd": "^5.5.2",
@@ -15,6 +15,15 @@ const getTree = (treeView: TreeView): TreeOoui => {
15
15
  return tree;
16
16
  };
17
17
 
18
+ function isPrimitive(value: any): boolean {
19
+ return (
20
+ typeof value === "number" ||
21
+ typeof value === "string" ||
22
+ typeof value === "boolean" ||
23
+ value === null
24
+ );
25
+ }
26
+
18
27
  const getTableColumns = (
19
28
  tree: TreeOoui,
20
29
  components: any,
@@ -27,8 +36,21 @@ const getTableColumns = (
27
36
  let render;
28
37
 
29
38
  if (component) {
30
- render = (item: any) => {
31
- return component(item, key, column, context);
39
+ render = (value: any) => {
40
+ return component({ value, key, ooui: column, context });
41
+ };
42
+ } else {
43
+ render = (value: any) => {
44
+ return isPrimitive(value) ? (
45
+ value
46
+ ) : (
47
+ <p style={{ color: "red" }}>
48
+ Unsupported widget type for a Tree cell:
49
+ <pre>
50
+ <strong>{type}:</strong>
51
+ </pre>
52
+ </p>
53
+ );
32
54
  };
33
55
  }
34
56
 
@@ -58,7 +80,7 @@ const getTableColumns = (
58
80
  const getTableItems = (treeOoui: TreeOoui, results: any[]): any[] => {
59
81
  const tableItems = results.map((item: any) => {
60
82
  const parsedItem: any = {};
61
- Object.keys(item).map((key) => {
83
+ Object.keys(item).forEach((key) => {
62
84
  if (key === "id") {
63
85
  parsedItem[key] = item[key];
64
86
  } else {
@@ -67,7 +89,6 @@ const getTableItems = (treeOoui: TreeOoui, results: any[]): any[] => {
67
89
  if (widget instanceof Reference) {
68
90
  parsedItem[key] = item[key];
69
91
  } else if (widget instanceof Selection) {
70
- const selection = widget;
71
92
  parsedItem[key] = item[key];
72
93
  } else if (widget instanceof Many2one) {
73
94
  parsedItem[key] = item[key] &&
package/src/index.ts CHANGED
@@ -5,7 +5,7 @@ import { Selection } from "@/widgets/base/Selection";
5
5
  import { Boolean } from "@/widgets/base/Boolean";
6
6
  import { Many2one } from "@/widgets/base/many2one/Many2one";
7
7
  import { One2many } from "@/widgets/base/one2many/One2many";
8
- import Tree from "@/widgets/views/Tree";
8
+ import { Tree } from "@/widgets/views/Tree";
9
9
  import { Float } from "@/widgets/base/Float";
10
10
  import { ProgressBar } from "@/widgets/base/ProgressBar";
11
11
  import { FloatTime } from "@/widgets/base/FloatTime";
@@ -82,13 +82,22 @@ function TitleHeader(props: Props) {
82
82
  return null;
83
83
  }
84
84
  return (
85
- <div style={{ position: "sticky", top: 80, zIndex: 3 }}>
85
+ <div
86
+ style={{
87
+ position: "sticky",
88
+ top: 80,
89
+ zIndex: 3,
90
+ }}
91
+ >
86
92
  <Row
87
93
  className="shadow-md"
88
94
  style={{
89
95
  padding: "1em",
90
96
  borderRadius: token.borderRadius,
91
97
  backgroundColor: token.colorPrimaryBg,
98
+ height: "82px",
99
+ minHeight: "82px",
100
+ maxHeight: "82px",
92
101
  }}
93
102
  align="middle"
94
103
  >
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useState, useRef } from "react";
2
2
  import { Alert, Spin } from "antd";
3
3
 
4
- import Tree from "@/widgets/views/Tree";
4
+ import { Tree } from "@/widgets/views/Tree";
5
5
  import { FormView, TreeView } from "@/types/index";
6
6
  import ConnectionProvider from "@/ConnectionProvider";
7
7
 
@@ -1,4 +1,4 @@
1
- import dayjs from "dayjs";
1
+ import dayjs from "@/helpers/dayjs";
2
2
 
3
3
  const formatter = (graphType: "pie" | "default" | "barGrouped") => {
4
4
  return (object: any) => {
@@ -9,7 +9,7 @@ import React, {
9
9
  import { Alert, Spin } from "antd";
10
10
 
11
11
  import SearchFilter from "@/widgets/views/searchFilter/SearchFilter";
12
- import Tree from "@/widgets/views/Tree";
12
+ import { Tree } from "@/widgets/views/Tree";
13
13
  import { FormView, TreeView } from "@/types/index";
14
14
  import ConnectionProvider from "@/ConnectionProvider";
15
15
 
@@ -284,7 +284,7 @@ function SearchTree(props: Props, ref: any) {
284
284
  if (treeView?.isExpandable) {
285
285
  return height - 160;
286
286
  }
287
- return height - (searchFilterHeight + 210);
287
+ return height - (searchFilterHeight + 240);
288
288
  }
289
289
 
290
290
  const content = () => {
@@ -0,0 +1,298 @@
1
+ import { memo, useContext, useEffect, useMemo, useRef, useState } from "react";
2
+ import { Pagination as AntPagination, Row, Col, Spin, Badge } from "antd";
3
+ import {
4
+ getTree,
5
+ getTableColumns,
6
+ getTableItems,
7
+ hasActualValues,
8
+ } from "@/helpers/treeHelper";
9
+ import { Tree as TreeOoui } from "@gisce/ooui";
10
+ import { TreeView } from "@/types";
11
+ import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
12
+ import { calculateColumnsWidth } from "@/helpers/dynamicColumnsHelper";
13
+ import { Table as GisceTable } from "@gisce/react-formiga-table";
14
+ import {
15
+ PlusSquareOutlined,
16
+ MinusSquareOutlined,
17
+ LoadingOutlined,
18
+ } from "@ant-design/icons";
19
+ import {
20
+ ActionViewContext,
21
+ ActionViewContextType,
22
+ } from "@/context/ActionViewContext";
23
+ import { SelectAllRecordsRow } from "@/common/SelectAllRecordsRow";
24
+ import { COLUMN_COMPONENTS } from "./treeComponents";
25
+ import ErrorBoundary from "antd/es/alert/ErrorBoundary";
26
+
27
+ type Props = {
28
+ total?: number;
29
+ limit: number;
30
+ page?: number;
31
+ loading: boolean;
32
+ treeView: TreeView;
33
+ results: any[];
34
+ showPagination?: boolean;
35
+ onRequestPageChange?: (page: number, pageSize?: number) => void;
36
+ onRowClicked?: (record: any) => void;
37
+ rowSelection?: any;
38
+ scrollY?: number;
39
+ colorsForResults?: { [key: number]: string };
40
+ statusForResults?: { [key: number]: string };
41
+ onChangeSort?: (results: any) => void;
42
+ sorter?: any;
43
+ onFetchChildrenForRecord?: (item: any) => Promise<any[]>;
44
+ childField?: string;
45
+ rootTree?: boolean;
46
+ context?: any;
47
+ readonly?: boolean;
48
+ onSelectAllRecords?: () => Promise<void>;
49
+ };
50
+ export const Tree = memo((props: Props) => {
51
+ const {
52
+ page = 1,
53
+ limit,
54
+ total,
55
+ treeView,
56
+ results,
57
+ onRequestPageChange,
58
+ loading,
59
+ onRowClicked,
60
+ showPagination = true,
61
+ rowSelection,
62
+ scrollY,
63
+ colorsForResults = {},
64
+ statusForResults = {},
65
+ onChangeSort,
66
+ sorter,
67
+ onFetchChildrenForRecord,
68
+ childField,
69
+ rootTree = false,
70
+ context,
71
+ readonly,
72
+ onSelectAllRecords,
73
+ } = props;
74
+
75
+ const [items, setItems] = useState<any[]>([]);
76
+
77
+ const errorInParseColors = useRef<boolean>(false);
78
+
79
+ const [treeOoui, setTreeOoui] = useState<TreeOoui>();
80
+
81
+ const { t } = useContext(LocaleContext) as LocaleContextType;
82
+ const internalLimit = useRef(limit);
83
+
84
+ const actionViewContext = useContext(
85
+ ActionViewContext,
86
+ ) as ActionViewContextType;
87
+ const { title = undefined, setTitle = undefined } =
88
+ (rootTree ? actionViewContext : {}) || {};
89
+
90
+ const columns = useMemo(() => {
91
+ if (!treeOoui) {
92
+ return undefined;
93
+ }
94
+
95
+ return getTableColumns(
96
+ treeOoui,
97
+ {
98
+ ...COLUMN_COMPONENTS,
99
+ },
100
+ context,
101
+ );
102
+ }, [context, treeOoui]);
103
+
104
+ useEffect(() => {
105
+ const treeOoui = getTree(treeView);
106
+ setTreeOoui(treeOoui);
107
+ if (treeOoui.string && title !== treeOoui.string) {
108
+ setTitle?.(treeOoui.string);
109
+ }
110
+ // eslint-disable-next-line react-hooks/exhaustive-deps
111
+ }, [treeView, title]);
112
+
113
+ useEffect(() => {
114
+ if (!treeOoui) {
115
+ return;
116
+ }
117
+ errorInParseColors.current = false;
118
+ const items = getTableItems(treeOoui, results);
119
+ setItems(items);
120
+ // eslint-disable-next-line react-hooks/exhaustive-deps
121
+ }, [results]);
122
+
123
+ useEffect(() => {
124
+ internalLimit.current = limit;
125
+ }, [limit]);
126
+
127
+ const from = (page - 1) * internalLimit.current + 1;
128
+ const to = from - 1 + items.length;
129
+ const summary =
130
+ total === undefined
131
+ ? null
132
+ : total === 0
133
+ ? t("no_results")
134
+ : t("summary")
135
+ .replace("{from}", from?.toString())
136
+ .replace("{to}", to?.toString())
137
+ .replace("{total}", total?.toString());
138
+
139
+ const pagination = useMemo(() => {
140
+ if (!showPagination || treeView.isExpandable) {
141
+ return null;
142
+ }
143
+
144
+ const numberOfVisibleSelectedRows = items?.filter(
145
+ (entry) =>
146
+ rowSelection?.selectedRowKeys &&
147
+ rowSelection?.selectedRowKeys.includes(entry.id),
148
+ ).length;
149
+
150
+ return loading ? null : total === undefined ? (
151
+ <Spin className="pb-4" />
152
+ ) : (
153
+ <Row align="bottom" className="pb-4">
154
+ <Col span={onSelectAllRecords ? 8 : 12}>
155
+ <AntPagination
156
+ total={total}
157
+ pageSize={
158
+ internalLimit.current === 0 ? total : internalLimit.current
159
+ }
160
+ current={page}
161
+ showSizeChanger={false}
162
+ onChange={onRequestPageChange}
163
+ />
164
+ </Col>
165
+ {onSelectAllRecords && (
166
+ <Col span={8} className="text-center">
167
+ <SelectAllRecordsRow
168
+ numberOfVisibleSelectedRows={numberOfVisibleSelectedRows}
169
+ numberOfRealSelectedRows={
170
+ rowSelection?.selectedRowKeys?.length || 0
171
+ }
172
+ numberOfTotalRows={items.length}
173
+ totalRecords={total || 0}
174
+ onSelectAllRecords={onSelectAllRecords}
175
+ />
176
+ </Col>
177
+ )}
178
+ <Col span={onSelectAllRecords ? 8 : 12} className="text-right">
179
+ {summary}
180
+ </Col>
181
+ </Row>
182
+ );
183
+ }, [
184
+ items,
185
+ loading,
186
+ onRequestPageChange,
187
+ onSelectAllRecords,
188
+ page,
189
+ rowSelection?.selectedRowKeys,
190
+ showPagination,
191
+ summary,
192
+ total,
193
+ treeView.isExpandable,
194
+ ]);
195
+
196
+ const sums = useMemo(() => {
197
+ if (!treeOoui) {
198
+ return null;
199
+ }
200
+ const sumFields = treeOoui.columns
201
+ .filter((it) => it.sum !== undefined)
202
+ .map((it) => {
203
+ return { label: it.sum, field: it.id };
204
+ });
205
+
206
+ if (!sumFields || sumFields.length === 0) {
207
+ return null;
208
+ }
209
+
210
+ const summary: string[] = [];
211
+ const sumItems =
212
+ rowSelection?.selectedRowKeys?.length > 0
213
+ ? items.filter((result: any) => {
214
+ return rowSelection?.selectedRowKeys.includes(result.id);
215
+ })
216
+ : items;
217
+
218
+ sumFields.forEach((sumField) => {
219
+ const total = sumItems.reduce((prev, current) => {
220
+ if (current[sumField.field] && !isNaN(current[sumField.field]))
221
+ return prev + current[sumField.field];
222
+ else return prev;
223
+ }, 0);
224
+
225
+ summary.push(`${sumField.label}: ${Math.round(total * 100) / 100}`);
226
+ });
227
+
228
+ return <div className="p-1 pb-0 pl-2 mt-2 ">{summary.join(", ")}</div>;
229
+ }, [items, rowSelection?.selectedRowKeys, treeOoui]);
230
+
231
+ const dataTable = useMemo(() => {
232
+ if (treeOoui !== null && columns && columns.length > 0) {
233
+ const maxWidthPerCell = 600;
234
+ return calculateColumnsWidth(columns, items, maxWidthPerCell);
235
+ }
236
+ return undefined;
237
+ }, [columns, items, treeOoui]);
238
+
239
+ const adjustedHeight = useMemo(() => {
240
+ if (scrollY && treeOoui?.columns.some((it: any) => it.sum !== undefined)) {
241
+ return scrollY - 30;
242
+ }
243
+ return scrollY;
244
+ }, [scrollY, treeOoui?.columns]);
245
+
246
+ if (treeOoui === null || !dataTable || dataTable?.columns?.length === 0) {
247
+ return <Spin style={{ padding: "2rem" }} />;
248
+ }
249
+
250
+ return (
251
+ <ErrorBoundary>
252
+ {pagination}
253
+ <GisceTable
254
+ height={adjustedHeight!}
255
+ columns={dataTable.columns}
256
+ dataSource={items}
257
+ loading={loading}
258
+ loadingComponent={<Spin />}
259
+ onRowStyle={(record: any) => {
260
+ if (colorsForResults![record.id]) {
261
+ return { color: colorsForResults![record.id] };
262
+ }
263
+ return undefined;
264
+ }}
265
+ onRowStatus={
266
+ hasActualValues(statusForResults)
267
+ ? (record: any) => {
268
+ if (statusForResults![record.id]) {
269
+ return <Badge color={statusForResults[record.id]} />;
270
+ }
271
+ return undefined;
272
+ }
273
+ : undefined
274
+ }
275
+ onRowDoubleClick={onRowClicked}
276
+ selectionRowKeys={rowSelection?.selectedRowKeys}
277
+ onRowSelectionChange={rowSelection?.onChange}
278
+ onChangeSort={onChangeSort}
279
+ sorter={sorter}
280
+ readonly={readonly}
281
+ expandableOpts={
282
+ onFetchChildrenForRecord
283
+ ? {
284
+ expandIcon: PlusSquareOutlined,
285
+ collapseIcon: MinusSquareOutlined,
286
+ loadingIcon: LoadingOutlined,
287
+ onFetchChildrenForRecord,
288
+ childField: childField!,
289
+ }
290
+ : undefined
291
+ }
292
+ />
293
+ {sums}
294
+ </ErrorBoundary>
295
+ );
296
+ });
297
+
298
+ Tree.displayName = "Tree";
@@ -0,0 +1 @@
1
+ export * from "./Tree";