@gisce/react-ooui 1.2.0-rc.36 → 1.2.0-rc.38

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":"WidgetFactory.d.ts","sourceRoot":"","sources":["WidgetFactory.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAoH1B,QAAA,MAAM,iBAAiB,UAAW,GAAG,+DAWpC,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"WidgetFactory.d.ts","sourceRoot":"","sources":["WidgetFactory.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAuH1B,QAAA,MAAM,iBAAiB,UAAW,GAAG,+DAWpC,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { WidgetProps } from '../../types';
3
+ export declare const Tag: (props: WidgetProps) => JSX.Element;
4
+ export declare const TagInput: (props: any) => JSX.Element | null;
5
+ //# sourceMappingURL=Tag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tag.d.ts","sourceRoot":"","sources":["Tag.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAKtC,eAAO,MAAM,GAAG,UAAW,WAAW,gBAMrC,CAAC;AAEF,eAAO,MAAM,QAAQ,oCASpB,CAAA"}
@@ -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;AAoB3C,aAAK,KAAK,GAAG;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM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AAC;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,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,CAAC;IACnB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf,CAAC;AA2FF,iBAAS,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,YAAY,CAyM9C;AAED,eAAe,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/react-ooui",
3
- "version": "1.2.0-rc.36",
3
+ "version": "1.2.0-rc.38",
4
4
  "files": [
5
5
  "dist",
6
6
  "src",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@ant-design/plots": "^1.0.9",
39
- "@gisce/ooui": "^0.17.13-rc.0",
39
+ "@gisce/ooui": "^0.17.14-rc.0",
40
40
  "@gisce/react-formiga-components": "^1.0.9-rc.14",
41
41
  "@gisce/react-formiga-table": "^0.5.0",
42
42
  "@monaco-editor/react": "^4.4.5",
@@ -100,17 +100,17 @@ const iconMapping: { [key: string]: string } = {
100
100
  STOCK_PREFERENCES: "Setting",
101
101
  };
102
102
 
103
- export default (key: string) => {
103
+ export default (key: string, className?: any) => {
104
104
  if (key.indexOf("gtk-") !== -1) {
105
105
  const rootIcon = key.replace("gtk-", "").replace(/\-/g, "_");
106
106
  key = `STOCK_${rootIcon.toUpperCase()}`;
107
107
  }
108
108
 
109
109
  if (iconMapping.hasOwnProperty(key)) {
110
- return getIconForKey(iconMapping[key]);
110
+ return getIconForKey(iconMapping[key], className);
111
111
  }
112
112
 
113
- return getIconForKey(key);
113
+ return getIconForKey(key, className);
114
114
  };
115
115
 
116
116
  function toCamelCase(key: string): string {
@@ -125,7 +125,7 @@ function toCamelCase(key: string): string {
125
125
  .join("")}`;
126
126
  }
127
127
 
128
- function getIconForKey(key: string) {
128
+ function getIconForKey(key: string, className?: any) {
129
129
  let IconCamelCase = key.charAt(0).toUpperCase() + key.slice(1); // Capitalize first letter
130
130
  if (IconCamelCase.indexOf("-") !== -1) {
131
131
  IconCamelCase = toCamelCase(IconCamelCase);
@@ -133,7 +133,10 @@ function getIconForKey(key: string) {
133
133
 
134
134
  const antKey: AntKey = `${IconCamelCase}Outlined` as any;
135
135
  if (AntIcons[antKey]) {
136
- return AntIcons[antKey];
136
+ return () =>
137
+ React.createElement(AntIcons[antKey] as any, {
138
+ className,
139
+ });
137
140
  }
138
141
 
139
142
  const tablerKey: TablerKey = `Icon${IconCamelCase}` as any;
@@ -147,6 +150,7 @@ function getIconForKey(key: string) {
147
150
  const CustomIcon = () =>
148
151
  React.createElement(Icon, {
149
152
  component: TablerIcon,
153
+ className,
150
154
  });
151
155
  return CustomIcon;
152
156
  }
@@ -28,7 +28,7 @@ const getTableColumns = (
28
28
 
29
29
  if (component) {
30
30
  render = (item: any) => {
31
- return component(item, key, tree.fields[key], context);
31
+ return component(item, key, column, context);
32
32
  };
33
33
  }
34
34
 
@@ -68,7 +68,7 @@ const getTableItems = (treeOoui: TreeOoui, results: Array<any>): Array<any> => {
68
68
  parsedItem[key] = item[key];
69
69
  } else if (widget instanceof Selection) {
70
70
  const selection = widget;
71
- parsedItem[key] = selection.selectionValues.get(item[key]);
71
+ parsedItem[key] = item[key];
72
72
  } else if (widget instanceof Many2one) {
73
73
  parsedItem[key] = item[key] &&
74
74
  Array.isArray(item[key]) &&
package/src/index.ts CHANGED
@@ -37,6 +37,7 @@ import { Image } from "@/widgets/base/Image";
37
37
  import showConfirmDialog from "@/ui/ConfirmDialog";
38
38
  import Dashboard from "@/widgets/views/Dashboard/Dashboard";
39
39
  import { Tags } from "@/widgets/custom/Tags";
40
+ import { Tag } from "@/widgets/custom/Tag";
40
41
  import { MultiCheckbox } from "./widgets/custom/MultiCheckbox";
41
42
  import { Radio } from "@/widgets/custom/Radio";
42
43
  import { Switch } from "@/widgets/custom/Switch";
@@ -145,6 +146,7 @@ export {
145
146
  DashboardGridItem,
146
147
  DashboardGrid,
147
148
  Tags,
149
+ Tag,
148
150
  MultiCheckbox,
149
151
  Radio,
150
152
  Switch,
@@ -0,0 +1,57 @@
1
+ import React from "react";
2
+
3
+ import { Tag as TagOoui } from "@gisce/ooui";
4
+ import "antd/dist/antd.css";
5
+ import LocaleProvider from "../../context/LocaleContext";
6
+ import { TagInput } from "../../widgets/custom/Tag";
7
+
8
+ export default {
9
+ title: "Components/Widgets/Custom/Tag",
10
+ };
11
+
12
+ export const Default = (): React.ReactElement => {
13
+ const ooui = new TagOoui({
14
+ name: "status",
15
+ string: "Status",
16
+ field: "status",
17
+ selection: [['draft', 'Draft'], ['open', 'Open']],
18
+ widget_props: '{"colors": {"draft": "blue", "open": "green"}}'
19
+ });
20
+
21
+ return (
22
+ <LocaleProvider lang="en_US">
23
+ <TagInput value="draft" ooui={ooui}/>
24
+ </LocaleProvider>
25
+ );
26
+ };
27
+
28
+ export const WithoutColor = (): React.ReactElement => {
29
+ const ooui = new TagOoui({
30
+ name: "status",
31
+ string: "Status",
32
+ field: "status",
33
+ selection: [['draft', 'Draft'], ['open', 'Open']],
34
+ });
35
+
36
+ return (
37
+ <LocaleProvider lang="en_US">
38
+ <TagInput value="draft" ooui={ooui}/>
39
+ </LocaleProvider>
40
+ );
41
+ };
42
+
43
+ export const WithColorAuto = (): React.ReactElement => {
44
+ const ooui = new TagOoui({
45
+ name: "status",
46
+ string: "Status",
47
+ field: "status",
48
+ selection: [['draft', 'Draft'], ['open', 'Open']],
49
+ widget_props: '{"colors": "auto"}'
50
+ });
51
+
52
+ return (
53
+ <LocaleProvider lang="en_US">
54
+ <TagInput value="draft" ooui={ooui}/>
55
+ </LocaleProvider>
56
+ );
57
+ };
@@ -30,7 +30,7 @@ Default.args = {
30
30
  lang: false,
31
31
  name: "AGRI ENERGIA ELECTRICA, S.A.",
32
32
  ref: "0112",
33
- title: false,
33
+ title: "corp",
34
34
  numeric: 30.1,
35
35
  progressbar: 100,
36
36
  },
@@ -41,7 +41,7 @@ Default.args = {
41
41
  lang: false,
42
42
  name: "Agrolait",
43
43
  ref: false,
44
- title: false,
44
+ title: "ltd",
45
45
  numeric: 30.1,
46
46
  progressbar: 70.434331,
47
47
  },
@@ -85,14 +85,14 @@ Default.args = {
85
85
  lang: false,
86
86
  name: "Aragón",
87
87
  ref: "02",
88
- title: false,
88
+ title: "corp",
89
89
  numeric: 30.1,
90
90
  progressbar: 20.01,
91
91
  },
92
92
  ],
93
93
  treeView: {
94
94
  arch:
95
- '<tree string="Partners">\n<field name="numeric" sum="Numeric"/><field name="name"/>\n <field name="title"/>\n <field name="ref"/>\n <field name="city" select="2"/>\n <field name="country" select="2"/>\n <field name="lang"/>\n <field name="progressbar" string="Progress" /> </tree>',
95
+ `<tree string="Partners">\n<field name="numeric" sum="Numeric"/><field name="name"/>\n <field name="title" widget="tag" widget_props="{'colors': {'corp': 'red', 'ltd': 'green'}}"/>\n <field name="ref"/>\n <field name="city" select="2"/>\n <field name="country" select="2"/>\n <field name="lang"/>\n <field name="progressbar" string="Progress" /> </tree>`,
96
96
  fields: {
97
97
  progressbar: {
98
98
  string: "Progress bar",
@@ -149,7 +149,7 @@ Default.args = {
149
149
  },
150
150
  title: {
151
151
  selection: [
152
- ["Corp.", "Corp."],
152
+ ["corp", "Corp."],
153
153
  ["ltd", "Ltd"],
154
154
  ["", ""],
155
155
  ],
@@ -29,6 +29,7 @@ import {
29
29
  Radio,
30
30
  Switch,
31
31
  Steps,
32
+ Tag,
32
33
  CodeEditor,
33
34
  } from "@/index";
34
35
  import { Image } from "./base/Image";
@@ -99,6 +100,8 @@ const getWidgetType = (type: string) => {
99
100
  return Indicator;
100
101
  case "tags":
101
102
  return Tags;
103
+ case "tag":
104
+ return Tag;
102
105
  case "multicheckbox":
103
106
  return MultiCheckbox;
104
107
  case "radio":
@@ -0,0 +1,24 @@
1
+ import Field from "@/common/Field";
2
+ import { WidgetProps } from "@/types";
3
+ import { Tag as AntdTag } from 'antd';
4
+ import { colorFromString } from "@/helpers/formHelper";
5
+
6
+
7
+ export const Tag = (props: WidgetProps) => {
8
+ return (
9
+ <Field {...props}>
10
+ <TagInput {...props}/>
11
+ </Field>
12
+ );
13
+ };
14
+
15
+ export const TagInput = (props) => {
16
+ const {ooui, value} = props;
17
+ if (!value) {
18
+ return null
19
+ }
20
+ const color = ooui.colors === "auto" ? colorFromString(value) : ooui.colors[value]
21
+ return (
22
+ <AntdTag color={color}>{ooui.selectionValues.get(value)}</AntdTag>
23
+ );
24
+ }
@@ -1,5 +1,5 @@
1
1
  import React, { useContext, useEffect, useRef, useState } from "react";
2
- import { Pagination, Checkbox, Space, Row, Col, Spin } from "antd";
2
+ import { Pagination, Checkbox, Space, Row, Col, Spin, Tag } from "antd";
3
3
  import { getTree, getTableColumns, getTableItems } from "@/helpers/treeHelper";
4
4
  import { Tree as TreeOoui } from "@gisce/ooui";
5
5
 
@@ -92,17 +92,41 @@ const imageComponent = (value: string): React.ReactElement => {
92
92
  );
93
93
  };
94
94
 
95
+ const TagComponent = (
96
+ value: any,
97
+ key: string,
98
+ ooui: any,
99
+ context: any
100
+ ): React.ReactElement => {
101
+ return (
102
+ <>
103
+ {value ? <Tag color={ooui.colors[value]}>{ooui.selectionValues.get(value)}</Tag> : null}
104
+ </>
105
+ );
106
+ };
107
+
108
+ const SelectionComponent = (
109
+ value: any,
110
+ key: string,
111
+ ooui: any,
112
+ context: any
113
+ ): React.ReactElement => {
114
+ return (
115
+ <>{ooui.selectionValues.get(value)}</>
116
+ );
117
+ };
118
+
95
119
  const referenceComponent = (
96
120
  value: any,
97
121
  key: string,
98
- fieldDefinitions: any,
122
+ ooui: any,
99
123
  context: any
100
124
  ): React.ReactElement => {
101
125
  return (
102
126
  <>
103
127
  <ReferenceTree
104
128
  value={value}
105
- selectionValues={new Map(fieldDefinitions?.selection)}
129
+ selectionValues={ooui.selectionValues}
106
130
  context={context}
107
131
  />
108
132
  </>
@@ -164,6 +188,8 @@ function Tree(props: Props): React.ReactElement {
164
188
  integer: numberComponent,
165
189
  float: numberComponent,
166
190
  reference: referenceComponent,
191
+ tag: TagComponent,
192
+ selection: SelectionComponent,
167
193
  },
168
194
  context
169
195
  );