@gisce/react-ooui 1.4.4-rc.0 → 2.0.0-rc.0

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":"Tree.d.ts","sourceRoot":"","sources":["Tree.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAKvE,OAAO,EAAE,QAAQ,EAAU,MAAM,SAAS,CAAC;AAwB3C,aAAK,KAAK,GAAG;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACrC,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC7C,gBAAgB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC7C,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACtC,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,wBAAwB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE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ACzD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAmHF,iBAAS,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,YAAY,CA6N9C;AAED,eAAe,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/react-ooui",
3
- "version": "1.4.4-rc.0",
3
+ "version": "2.0.0-rc.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "src",
@@ -1,5 +1,5 @@
1
1
  import React, { useContext, useState } from "react";
2
- import { Space, Spin } from "antd";
2
+ import { Space } from "antd";
3
3
  import ChangeViewButton from "./ChangeViewButton";
4
4
  import {
5
5
  ActionViewContext,
@@ -151,13 +151,6 @@ function TreeActionBar(props: Props) {
151
151
 
152
152
  return (
153
153
  <Space wrap={true}>
154
- {treeIsLoading && (
155
- <>
156
- <Spin />
157
- {separator()}
158
- {separator()}
159
- </>
160
- )}
161
154
  {treeExpandable ? null : (
162
155
  <>
163
156
  <SearchBar
@@ -293,7 +293,6 @@ export const useSearch = (opts: UseSearchOpts) => {
293
293
 
294
294
  const changeSort = useCallback(
295
295
  (newSorter: any) => {
296
- if (JSON.stringify(newSorter) === JSON.stringify(sorter)) return;
297
296
  setSorter?.(newSorter);
298
297
  const sortedResults =
299
298
  newSorter !== undefined
package/src/index.ts CHANGED
@@ -81,6 +81,8 @@ import CurrentTabContent from "./views/CurrentTabContent";
81
81
  import ContentRootProvider from "./context/ContentRootContext";
82
82
  import FavouriteButton from "./ui/FavouriteButton";
83
83
  import { ConfigContext } from "./context/ConfigContext";
84
+ import Tab from "./views/tabs/Tab";
85
+ import ActionView from "./views/ActionView";
84
86
 
85
87
  export {
86
88
  Button,
@@ -159,4 +161,6 @@ export {
159
161
  CodeEditor,
160
162
  ExportModal,
161
163
  ConfigContext,
164
+ Tab,
165
+ ActionView,
162
166
  };
@@ -95,7 +95,7 @@ function ActionView(props: Props, ref: any) {
95
95
  useState<boolean>(false);
96
96
  const [searchTreeNameSearch, setSearchTreeNameSearch] = useState<string>();
97
97
 
98
- const { t } = useContext(LocaleContext) as LocaleContextType;
98
+ const { t } = (useContext(LocaleContext) as LocaleContextType) || {};
99
99
 
100
100
  const formRef = useRef();
101
101
  const searchTreeRef = useRef();
@@ -182,9 +182,9 @@ function SearchTree(props: Props, ref: any) {
182
182
  setInitialFetchDone(true);
183
183
  } catch (error) {
184
184
  setInitialError(error);
185
- setTreeIsLoading?.(false);
186
185
  } finally {
187
186
  setIsLoading(false);
187
+ setTreeIsLoading?.(false);
188
188
  }
189
189
  };
190
190
 
@@ -1,4 +1,10 @@
1
- import React, { useContext, useEffect, useRef, useState } from "react";
1
+ import React, {
2
+ useCallback,
3
+ useContext,
4
+ useEffect,
5
+ useRef,
6
+ useState,
7
+ } from "react";
2
8
  import { Pagination, Checkbox, Space, Row, Col, Spin, Tag, Badge } from "antd";
3
9
  import { getTree, getTableColumns, getTableItems } from "@/helpers/treeHelper";
4
10
  import { Tree as TreeOoui } from "@gisce/ooui";
@@ -69,7 +75,11 @@ const many2OneComponentFn = (m2oField: any): React.ReactElement => {
69
75
  };
70
76
 
71
77
  const textComponentFn = (value: any): React.ReactElement => {
72
- return <Interweave content={value?.toString().replace(/(?:\r\n|\r|\n)/g, "<br>")} />;
78
+ return (
79
+ <Interweave
80
+ content={value?.toString().replace(/(?:\r\n|\r|\n)/g, "<br>")}
81
+ />
82
+ );
73
83
  };
74
84
 
75
85
  const dateComponentFn = (value: any): React.ReactElement => {
@@ -104,8 +114,8 @@ const floatTimeComponent = (value: number): React.ReactElement => {
104
114
  return <>{parseFloatToString(value)}</>;
105
115
  };
106
116
 
107
- const numberComponent = (value: number): React.ReactElement => {
108
- return <div style={{ textAlign: "right" }}>{value}</div>;
117
+ const numberComponent = (value: any): React.ReactElement => {
118
+ return <div style={{ textAlign: "right" }}>{JSON.stringify(value)}</div>;
109
119
  };
110
120
 
111
121
  const imageComponent = (value: string): React.ReactElement => {
@@ -123,7 +133,7 @@ const TagComponent = (
123
133
  ooui: any,
124
134
  context: any
125
135
  ): React.ReactElement => {
126
- return <TagInput ooui={ooui} value={value} />
136
+ return <TagInput ooui={ooui} value={value} />;
127
137
  };
128
138
 
129
139
  const SelectionComponent = (
@@ -205,22 +215,22 @@ function Tree(props: Props): React.ReactElement {
205
215
  const columns = getTableColumns(
206
216
  treeOoui.current,
207
217
  {
208
- boolean: booleanComponentFn,
209
- many2one: many2OneComponentFn,
210
- text: textComponentFn,
211
- one2many: one2ManyComponentFn,
212
- many2many: one2ManyComponentFn,
213
- progressbar: progressBarComponentFn,
214
- float_time: floatTimeComponent,
215
- image: imageComponent,
218
+ boolean: numberComponent,
219
+ many2one: numberComponent,
220
+ text: numberComponent,
221
+ one2many: numberComponent,
222
+ many2many: numberComponent,
223
+ progressbar: numberComponent,
224
+ float_time: numberComponent,
225
+ image: numberComponent,
216
226
  integer: numberComponent,
217
227
  float: numberComponent,
218
- reference: referenceComponent,
219
- tag: TagComponent,
220
- selection: SelectionComponent,
221
- date: dateComponentFn,
222
- datetime: dateTimeComponentFn,
223
- avatar: AvatarFn,
228
+ reference: numberComponent,
229
+ tag: numberComponent,
230
+ selection: numberComponent,
231
+ date: numberComponent,
232
+ datetime: numberComponent,
233
+ avatar: numberComponent,
224
234
  },
225
235
  context
226
236
  );
@@ -327,30 +337,39 @@ function Tree(props: Props): React.ReactElement {
327
337
  }
328
338
  }
329
339
 
340
+ const onRowStyle = useCallback(
341
+ (record: any) => {
342
+ if (colorsForResults![record.id]) {
343
+ return { color: colorsForResults![record.id] };
344
+ }
345
+ return undefined;
346
+ },
347
+ [colorsForResults]
348
+ );
349
+
350
+ const onRowStatus = useCallback(
351
+ (record: any) => {
352
+ if (statusForResults![record.id]) {
353
+ return <Badge color={statusForResults[record.id]} />;
354
+ }
355
+ return undefined;
356
+ },
357
+ [statusForResults]
358
+ );
359
+
330
360
  return treeOoui.current === null ? (
331
361
  <Spin style={{ padding: "2rem" }} />
332
362
  ) : (
333
363
  <div>
334
364
  {pagination()}
335
- {loading && <Spin className="pb-4" />}
336
365
  <GisceTable
337
366
  height={adjustedHeight!}
338
367
  columns={dataTable.columns}
339
368
  dataSource={items}
340
- loading={false}
369
+ loading={loading}
341
370
  loadingComponent={<Spin />}
342
- onRowStyle={(record: any) => {
343
- if (colorsForResults![record.id]) {
344
- return { color: colorsForResults![record.id] };
345
- }
346
- return undefined;
347
- }}
348
- onRowStatus={(record: any) => {
349
- if (statusForResults![record.id]) {
350
- return <Badge color={statusForResults[record.id]}/>
351
- }
352
- return undefined
353
- }}
371
+ onRowStyle={onRowStyle}
372
+ onRowStatus={onRowStatus}
354
373
  onRowDoubleClick={onRowClicked}
355
374
  onRowSelectionChange={rowSelection?.onChange}
356
375
  onChangeSort={onChangeSort}