@gisce/react-ooui 0.15.1 → 0.17.1

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.
Files changed (41) hide show
  1. package/dist/helpers/iconMapper.js +1 -1
  2. package/dist/index.d.ts +3 -1
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +2 -2
  5. package/dist/index.js.map +1 -1
  6. package/dist/widgets/WidgetFactory.d.ts.map +1 -1
  7. package/dist/widgets/WidgetFactory.js +4 -0
  8. package/dist/widgets/WidgetFactory.js.map +1 -1
  9. package/dist/widgets/custom/CodeEditor.d.ts +9 -0
  10. package/dist/widgets/custom/CodeEditor.d.ts.map +1 -0
  11. package/dist/widgets/custom/CodeEditor.js +53 -0
  12. package/dist/widgets/custom/CodeEditor.js.map +1 -0
  13. package/dist/widgets/custom/MultiCheckbox.js +1 -1
  14. package/dist/widgets/custom/MultiCheckbox.js.map +1 -1
  15. package/dist/widgets/custom/Steps.d.ts +13 -0
  16. package/dist/widgets/custom/Steps.d.ts.map +1 -0
  17. package/dist/widgets/custom/Steps.js +65 -0
  18. package/dist/widgets/custom/Steps.js.map +1 -0
  19. package/dist/widgets/custom/Tags.d.ts +2 -1
  20. package/dist/widgets/custom/Tags.d.ts.map +1 -1
  21. package/dist/widgets/custom/Tags.js +1 -1
  22. package/dist/widgets/custom/Tags.js.map +1 -1
  23. package/dist/widgets/views/Form.d.ts.map +1 -1
  24. package/dist/widgets/views/Form.js +1 -0
  25. package/dist/widgets/views/Form.js.map +1 -1
  26. package/dist/widgets/views/SearchTree.d.ts.map +1 -1
  27. package/dist/widgets/views/SearchTree.js +1 -1
  28. package/dist/widgets/views/SearchTree.js.map +1 -1
  29. package/package.json +3 -2
  30. package/src/helpers/iconMapper.ts +1 -1
  31. package/src/index.ts +4 -0
  32. package/src/stories/custom/CodeEditor.stories.tsx +25 -0
  33. package/src/stories/custom/Steps.stories.tsx +38 -0
  34. package/src/stories/custom/Tags.stories.tsx +18 -2
  35. package/src/widgets/WidgetFactory.tsx +6 -0
  36. package/src/widgets/custom/CodeEditor.tsx +28 -0
  37. package/src/widgets/custom/MultiCheckbox.tsx +1 -1
  38. package/src/widgets/custom/Steps.tsx +55 -0
  39. package/src/widgets/custom/Tags.tsx +3 -2
  40. package/src/widgets/views/Form.tsx +1 -0
  41. package/src/widgets/views/SearchTree.tsx +7 -2
@@ -0,0 +1,38 @@
1
+ import React from "react";
2
+
3
+ import { Steps, StepsInput } from "../../widgets/custom/Steps";
4
+ import { Steps as StepsOoui } from "@gisce/ooui";
5
+ import "antd/dist/antd.css";
6
+ import LocaleProvider from "../../context/LocaleContext";
7
+
8
+ export default {
9
+ title: "Components/Widgets/Custom/Steps",
10
+ };
11
+
12
+ export const Default = (): React.ReactElement => {
13
+ const ooui = new StepsOoui({
14
+ name: "enabled",
15
+ string: "Lorem ipsum",
16
+ selection: [['init', 'Start'], ['second', 'Second'], ['third', 'Third'], ['end', 'End']]
17
+ });
18
+
19
+ return (
20
+ <LocaleProvider lang="en_US">
21
+ <StepsInput ooui={ooui} value="third" />
22
+ </LocaleProvider>
23
+ );
24
+ };
25
+
26
+ export const Many2One = (): React.ReactElement => {
27
+ const ooui = new StepsOoui({
28
+ name: "enabled",
29
+ string: "Lorem ipsum",
30
+ relation: "crm.case.stage",
31
+ });
32
+
33
+ return (
34
+ <LocaleProvider lang="en_US">
35
+ <StepsInput ooui={ooui} value="third" />
36
+ </LocaleProvider>
37
+ );
38
+ };
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
 
3
- import { TagsInput } from "../../widgets/custom/Tags";
3
+ import { TagsInput, Tags } from "../../widgets/custom/Tags";
4
4
  import { Tags as TagsOoui } from "@gisce/ooui";
5
5
  import "antd/dist/antd.css";
6
6
  import LocaleProvider from "../../context/LocaleContext";
@@ -48,4 +48,20 @@ export const Readonly = (): React.ReactElement => {
48
48
  />
49
49
  </LocaleProvider>
50
50
  );
51
- };
51
+ };
52
+
53
+
54
+ export const TagsLabel = (): React.ReactElement => {
55
+ const ooui = new TagsOoui({
56
+ name: "button_field",
57
+ string: "Lorem ipsum",
58
+ field: "name",
59
+ relation: "res.partner.category",
60
+ });
61
+
62
+ return (
63
+ <LocaleProvider lang="en_US">
64
+ <Tags ooui={ooui} showLabel/>
65
+ </LocaleProvider>
66
+ );
67
+ };
@@ -27,6 +27,8 @@ import {
27
27
  MultiCheckbox,
28
28
  Radio,
29
29
  Switch,
30
+ Steps,
31
+ CodeEditor,
30
32
  } from "@/index";
31
33
  import { Image } from "./base/Image";
32
34
  import { FiberGrid } from "./custom/FiberGrid";
@@ -100,6 +102,10 @@ const getWidgetType = (type: string) => {
100
102
  return Radio;
101
103
  case "switch":
102
104
  return Switch;
105
+ case "steps":
106
+ return Steps;
107
+ case "codeeditor":
108
+ return CodeEditor;
103
109
  default:
104
110
  return undefined;
105
111
  }
@@ -0,0 +1,28 @@
1
+ import React, { useContext } from "react";
2
+ import Editor from "@monaco-editor/react";
3
+ import { FormContext, FormContextType } from "@/context/FormContext";
4
+ import { CodeEditor as CodeEditorOoui } from "@gisce/ooui";
5
+
6
+ import Field from "@/common/Field";
7
+ import { WidgetProps } from "@/types";
8
+
9
+ type CodeEditorProps = WidgetProps & {
10
+ ooui: CodeEditorOoui;
11
+ };
12
+
13
+ export const CodeEditor = (props: CodeEditorProps) => {
14
+ const { ooui } = props;
15
+ const { lang, height } = ooui;
16
+ const formContext = useContext(FormContext) as FormContextType;
17
+ const { elementHasLostFocus } = formContext || {};
18
+
19
+ const onMount = (editor: any) => {
20
+ editor.onDidBlurEditorWidget(elementHasLostFocus)
21
+ }
22
+
23
+ return (
24
+ <Field {...props}>
25
+ <Editor defaultLanguage={lang ? lang : ''} height={height ? height : 300} onMount={onMount}/>
26
+ </Field>
27
+ );
28
+ };
@@ -130,7 +130,7 @@ export const MultiCheckboxInput = (props: MultiCheckboxInputProps) => {
130
130
 
131
131
  return (
132
132
  <>
133
- <div style={{ padding: "1rem" }}>
133
+ <div className="flex flex-row">
134
134
  <Checkbox.Group value={options.length ? itemsToShow : []} disabled={readOnly} onChange={onChangeSelected} style={{width: '100%'}}>
135
135
  <Row>
136
136
  {options.map((option) => (
@@ -0,0 +1,55 @@
1
+ import React, { useContext } from "react";
2
+ import { Steps as AntdSteps } from "antd";
3
+ import { FormContext, FormContextType } from "@/context/FormContext";
4
+ import Field from "@/common/Field";
5
+ import { Steps as StepsOoui } from "@gisce/ooui";
6
+
7
+ type StepsProps = {
8
+ ooui: StepsOoui;
9
+ value: any,
10
+ }
11
+
12
+ type StatusType = 'wait' | 'process' | 'finish' | 'error';
13
+
14
+
15
+ export const Steps = (props: StepsProps) => {
16
+ const { ooui } = props;
17
+ const { required } = ooui;
18
+
19
+ return (
20
+ <Field required={required} type={"any"} {...props}>
21
+ <StepsInput {...props} />
22
+ </Field>
23
+ );
24
+ };
25
+
26
+ type StepsInputProps = StepsProps & {
27
+ value?: any;
28
+ };
29
+
30
+ export const StepsInput = (props: StepsInputProps) => {
31
+ const { ooui, value } = props;
32
+ const { selectionValues, errorField } = ooui as StepsOoui;
33
+ const formContext = useContext(FormContext) as FormContextType;
34
+
35
+ const values = Array.from(selectionValues.entries());
36
+ const current = values.map(val => val[0]).indexOf(value);
37
+ let status: StatusType = "process";
38
+ let error = "";
39
+
40
+ if (errorField) {
41
+ error = formContext.getFieldValue(errorField);
42
+ if (error) {
43
+ status = "error";
44
+ }
45
+ }
46
+
47
+
48
+ return (
49
+ <AntdSteps current={current} status={status}>
50
+ {values.map((val, idx) => (
51
+ <AntdSteps.Step title={val[1]} description={idx === current && status === "error" ? error : null}/>
52
+ ))}
53
+ </AntdSteps>
54
+ );
55
+ };
@@ -1,6 +1,7 @@
1
1
  import React, { useContext, useState } from "react";
2
2
  import { Tags as TagsOoui } from "@gisce/ooui";
3
3
  import Field from "@/common/Field";
4
+ import { WidgetProps } from "@/types";
4
5
  import { One2manyItem, One2manyValue } from "../base/one2many/One2manyInput";
5
6
  import useDeepCompareEffect from "use-deep-compare-effect";
6
7
  import { FormContext, FormContextType } from "@/context/FormContext";
@@ -8,7 +9,7 @@ import { Alert, Tag as AntTag, Select } from "antd";
8
9
  import { colorFromString } from "@/helpers/formHelper";
9
10
  import ConnectionProvider from "@/ConnectionProvider";
10
11
 
11
- type TagsProps = {
12
+ type TagsProps = WidgetProps & {
12
13
  ooui: TagsOoui;
13
14
  };
14
15
 
@@ -140,7 +141,7 @@ export const TagsInput = (props: TagsInputProps) => {
140
141
 
141
142
  return (
142
143
  <>
143
- <div style={{ padding: "1rem" }}>
144
+ <div className="flex flex-row">
144
145
  <Select
145
146
  mode="multiple"
146
147
  value={options.length ? itemsToShow : []}
@@ -698,6 +698,7 @@ function Form(props: FormProps, ref: any) {
698
698
  fields,
699
699
  types: [
700
700
  "text",
701
+ "codeeditor",
701
702
  "email",
702
703
  "url",
703
704
  "char",
@@ -18,7 +18,12 @@ import {
18
18
  ActionViewContext,
19
19
  ActionViewContextType,
20
20
  } from "@/context/ActionViewContext";
21
- import { getColorMap, getTree, sortResults } from "@/helpers/treeHelper";
21
+ import {
22
+ getColorMap,
23
+ getTableItems,
24
+ getTree,
25
+ sortResults,
26
+ } from "@/helpers/treeHelper";
22
27
  import useWindowDimensions from "@/hooks/useWindowDimensions";
23
28
  import Measure from "react-measure";
24
29
  import { mergeSearchFields } from "@/helpers/formHelper";
@@ -337,7 +342,7 @@ function SearchTree(props: Props, ref: any) {
337
342
 
338
343
  setResults([...getResults(), ...children]);
339
344
 
340
- return children;
345
+ return getTableItems(getTree(treeView!), children);
341
346
  }
342
347
 
343
348
  useEffect(() => {