@gisce/react-ooui 1.4.2 → 1.4.3
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.
- package/dist/helpers/formHelper.d.ts +0 -1
- package/dist/helpers/formHelper.d.ts.map +1 -1
- package/dist/react-ooui.es.js +1259 -1270
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +13 -13
- package/dist/react-ooui.umd.js.map +1 -1
- package/dist/widgets/custom/Tag.d.ts +2 -0
- package/dist/widgets/custom/Tag.d.ts.map +1 -1
- package/dist/widgets/custom/Tags.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/helpers/formHelper.ts +0 -8
- package/src/stories/Utils.stories.tsx +16 -0
- package/src/widgets/custom/Tag.tsx +21 -5
- package/src/widgets/custom/Tags.tsx +8 -7
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { WidgetProps } from '../../types';
|
|
3
|
+
import { TagProps } from 'antd';
|
|
3
4
|
export declare const Tag: (props: WidgetProps) => React.JSX.Element;
|
|
4
5
|
export declare const TagInput: (props: any) => React.JSX.Element | null;
|
|
6
|
+
export declare const CustomTag: (props: TagProps) => React.JSX.Element;
|
|
5
7
|
//# sourceMappingURL=Tag.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.d.ts","sourceRoot":"","sources":["Tag.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Tag.d.ts","sourceRoot":"","sources":["Tag.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAkB,QAAQ,EAAE,MAAM,MAAM,CAAC;AAIhD,eAAO,MAAM,GAAG,UAAW,WAAW,sBAMrC,CAAC;AAEF,eAAO,MAAM,QAAQ,UAAW,GAAG,6BAiBlC,CAAA;AAGD,eAAO,MAAM,SAAS,UAAW,QAAQ,sBAaxC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tags.d.ts","sourceRoot":"","sources":["Tags.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+B,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAgB,aAAa,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"Tags.d.ts","sourceRoot":"","sources":["Tags.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+B,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAgB,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAQ7E,aAAK,SAAS,GAAG,WAAW,GAAG;IAC7B,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,aAAK,cAAc,GAAG,SAAS,GAAG;IAChC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEF,eAAO,MAAM,IAAI,UAAW,SAAS,sBAQpC,CAAC;AAEF,eAAO,MAAM,SAAS,UAAW,cAAc,sBAoI9C,CAAC"}
|
package/package.json
CHANGED
|
@@ -295,11 +295,3 @@ export const colorTextFromBackground = (color: string) => {
|
|
|
295
295
|
return getTextColor(color);
|
|
296
296
|
|
|
297
297
|
}
|
|
298
|
-
|
|
299
|
-
export const colorsFromString = (text: string): any => {
|
|
300
|
-
const backgroundColor = colorFromString(text)
|
|
301
|
-
return {
|
|
302
|
-
backgroundColor,
|
|
303
|
-
textColor: colorTextFromBackground(backgroundColor)
|
|
304
|
-
}
|
|
305
|
-
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { CustomTag } from "../widgets/custom/Tag";
|
|
4
|
+
import { colorFromString } from "../helpers/formHelper";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: "Components/Pure",
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export const CustomTagWithColor = (): React.ReactElement => {
|
|
13
|
+
const text = "Hacker";
|
|
14
|
+
const color = colorFromString(text);
|
|
15
|
+
return <CustomTag color={color}>{text}</CustomTag>
|
|
16
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Field from "@/common/Field";
|
|
3
3
|
import { WidgetProps } from "@/types";
|
|
4
|
-
import { Tag as AntdTag } from 'antd';
|
|
5
|
-
import { isPresetStatusColor } from 'antd/lib/_util/colors'
|
|
6
|
-
import { colorFromString
|
|
4
|
+
import { Tag as AntdTag, TagProps } from 'antd';
|
|
5
|
+
import { isPresetStatusColor, isPresetColor } from 'antd/lib/_util/colors'
|
|
6
|
+
import { colorFromString } from "@/helpers/formHelper";
|
|
7
7
|
|
|
8
8
|
export const Tag = (props: WidgetProps) => {
|
|
9
9
|
return (
|
|
@@ -28,6 +28,22 @@ export const TagInput = (props: any) => {
|
|
|
28
28
|
}
|
|
29
29
|
const color = ooui.colors === "auto" ? colorFromString(colorValue) : ooui.colors[colorValue] || colorFromString(colorValue);
|
|
30
30
|
return (
|
|
31
|
-
<
|
|
31
|
+
<CustomTag color={color}>{formattedValue}</CustomTag>
|
|
32
32
|
);
|
|
33
|
-
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
export const CustomTag = (props: TagProps) => {
|
|
37
|
+
let { color } = props;
|
|
38
|
+
let style = {}
|
|
39
|
+
if (!isPresetStatusColor(props.color) && !isPresetColor(props.color)) {
|
|
40
|
+
style = {
|
|
41
|
+
color: color,
|
|
42
|
+
borderColor: color,
|
|
43
|
+
borderStyle: "solid",
|
|
44
|
+
borderWidth: "1px",
|
|
45
|
+
}
|
|
46
|
+
color = `${color}20`;
|
|
47
|
+
}
|
|
48
|
+
return <AntdTag {...props} style={style} color={color}>{props.children}</AntdTag>
|
|
49
|
+
}
|
|
@@ -5,9 +5,10 @@ import { WidgetProps } from "@/types";
|
|
|
5
5
|
import { One2manyItem, One2manyValue } from "../base/one2many/One2manyInput";
|
|
6
6
|
import useDeepCompareEffect from "use-deep-compare-effect";
|
|
7
7
|
import { FormContext, FormContextType } from "@/context/FormContext";
|
|
8
|
-
import { Alert,
|
|
9
|
-
import {
|
|
8
|
+
import { Alert, Select } from "antd";
|
|
9
|
+
import { colorFromString, transformPlainMany2Ones } from "@/helpers/formHelper";
|
|
10
10
|
import ConnectionProvider from "@/ConnectionProvider";
|
|
11
|
+
import { CustomTag } from "@/widgets/custom/Tag";
|
|
11
12
|
|
|
12
13
|
type TagsProps = WidgetProps & {
|
|
13
14
|
ooui: TagsOoui;
|
|
@@ -126,17 +127,17 @@ export const TagsInput = (props: TagsInputProps) => {
|
|
|
126
127
|
event.preventDefault();
|
|
127
128
|
event.stopPropagation();
|
|
128
129
|
};
|
|
129
|
-
const
|
|
130
|
+
const color = colorFromString(label);
|
|
130
131
|
return (
|
|
131
|
-
<
|
|
132
|
-
color={
|
|
132
|
+
<CustomTag
|
|
133
|
+
color={color}
|
|
133
134
|
onMouseDown={onPreventMouseDown}
|
|
134
|
-
style={{ margin: "5px", color: colors.textColor }}
|
|
135
135
|
closable={closable}
|
|
136
136
|
onClose={onClose}
|
|
137
|
+
closeIcon={<span style={{color}}>X</span>}
|
|
137
138
|
>
|
|
138
139
|
{label}
|
|
139
|
-
</
|
|
140
|
+
</CustomTag>
|
|
140
141
|
);
|
|
141
142
|
};
|
|
142
143
|
|