@gisce/react-ooui 1.4.3 → 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,OAAO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AAU,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.3",
3
+ "version": "2.0.0-rc.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "src",
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();
@@ -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 => {
@@ -118,23 +128,21 @@ const imageComponent = (value: string): React.ReactElement => {
118
128
  };
119
129
 
120
130
  const TagComponent = (
121
- value: any,
131
+ value: any,
122
132
  key: string,
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 = (
130
- value: any,
140
+ value: any,
131
141
  key: string,
132
142
  ooui: any,
133
143
  context: any
134
144
  ): React.ReactElement => {
135
- return (
136
- <>{ooui.selectionValues.get(value)}</>
137
- );
145
+ return <>{ooui.selectionValues.get(value)}</>;
138
146
  };
139
147
 
140
148
  const referenceComponent = (
@@ -154,9 +162,12 @@ const referenceComponent = (
154
162
  );
155
163
  };
156
164
 
157
- const AvatarFn = (value: any, key:string, ooui: any, context: any): React.ReactElement => (
158
- <Avatar ooui={ooui} value={value} />
159
- )
165
+ const AvatarFn = (
166
+ value: any,
167
+ key: string,
168
+ ooui: any,
169
+ context: any
170
+ ): React.ReactElement => <Avatar ooui={ooui} value={value} />;
160
171
 
161
172
  function Tree(props: Props): React.ReactElement {
162
173
  const {
@@ -204,22 +215,22 @@ function Tree(props: Props): React.ReactElement {
204
215
  const columns = getTableColumns(
205
216
  treeOoui.current,
206
217
  {
207
- boolean: booleanComponentFn,
208
- many2one: many2OneComponentFn,
209
- text: textComponentFn,
210
- one2many: one2ManyComponentFn,
211
- many2many: one2ManyComponentFn,
212
- progressbar: progressBarComponentFn,
213
- float_time: floatTimeComponent,
214
- 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,
215
226
  integer: numberComponent,
216
227
  float: numberComponent,
217
- reference: referenceComponent,
218
- tag: TagComponent,
219
- selection: SelectionComponent,
220
- date: dateComponentFn,
221
- datetime: dateTimeComponentFn,
222
- avatar: AvatarFn,
228
+ reference: numberComponent,
229
+ tag: numberComponent,
230
+ selection: numberComponent,
231
+ date: numberComponent,
232
+ datetime: numberComponent,
233
+ avatar: numberComponent,
223
234
  },
224
235
  context
225
236
  );
@@ -308,9 +319,7 @@ function Tree(props: Props): React.ReactElement {
308
319
  summary.push(`${sumField.label}: ${Math.round(total * 100) / 100}`);
309
320
  });
310
321
 
311
- return (
312
- <div className="p-1 pb-0 pl-2 mt-2 ">{summary.join(", ")}</div>
313
- );
322
+ return <div className="p-1 pb-0 pl-2 mt-2 ">{summary.join(", ")}</div>;
314
323
  }
315
324
 
316
325
  let dataTable;
@@ -328,6 +337,26 @@ function Tree(props: Props): React.ReactElement {
328
337
  }
329
338
  }
330
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
+
331
360
  return treeOoui.current === null ? (
332
361
  <Spin style={{ padding: "2rem" }} />
333
362
  ) : (
@@ -339,18 +368,8 @@ function Tree(props: Props): React.ReactElement {
339
368
  dataSource={items}
340
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}