@gisce/react-ooui 1.1.27-rc.0 → 1.1.27
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gisce/react-ooui",
|
|
3
|
-
"version": "1.1.27
|
|
3
|
+
"version": "1.1.27",
|
|
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.
|
|
39
|
+
"@gisce/ooui": "^0.17.12",
|
|
40
40
|
"@gisce/react-formiga-table": "^0.5.0",
|
|
41
41
|
"@monaco-editor/react": "^4.4.5",
|
|
42
42
|
"@tabler/icons-react": "^2.11.0",
|
|
@@ -2,14 +2,18 @@ import iconMapper from "../helpers/iconMapper";
|
|
|
2
2
|
import * as Icons from "@ant-design/icons";
|
|
3
3
|
|
|
4
4
|
describe("A IconMapper instance", () => {
|
|
5
|
-
test("should return
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
expect(icon).toBe(defaultIcon);
|
|
5
|
+
test("should return undefined when key not found", () => {
|
|
6
|
+
const icon = iconMapper("foo-bar");
|
|
7
|
+
expect(icon).toBe(undefined);
|
|
9
8
|
});
|
|
10
9
|
test("should return proper help icon when requested", () => {
|
|
11
10
|
const helpIcon = Icons.QuestionOutlined;
|
|
12
|
-
const icon = iconMapper("
|
|
11
|
+
const icon = iconMapper("gtk-help");
|
|
13
12
|
expect(icon).toBe(helpIcon);
|
|
14
13
|
});
|
|
14
|
+
test("should replace all - for _", () => {
|
|
15
|
+
const findAndReplaceIcon = Icons.FileSearchOutlined;
|
|
16
|
+
const icon = iconMapper("gtk-find-and-replace");
|
|
17
|
+
expect(icon).toBe(findAndReplaceIcon);
|
|
18
|
+
})
|
|
15
19
|
});
|
|
@@ -102,7 +102,7 @@ const iconMapping: { [key: string]: string } = {
|
|
|
102
102
|
|
|
103
103
|
export default (key: string) => {
|
|
104
104
|
if (key.indexOf("gtk-") !== -1) {
|
|
105
|
-
const rootIcon = key.replace("gtk-", "").replace(
|
|
105
|
+
const rootIcon = key.replace("gtk-", "").replace(/\-/g, "_");
|
|
106
106
|
const newKey = `STOCK_${rootIcon.toUpperCase()}`;
|
|
107
107
|
return getIconForKey(iconMapping[newKey]);
|
|
108
108
|
}
|
|
@@ -114,8 +114,8 @@ export default (key: string) => {
|
|
|
114
114
|
return getIconForKey(key);
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
-
function
|
|
118
|
-
|
|
117
|
+
function toCamelCase(key: string) : string {
|
|
118
|
+
return `${key
|
|
119
119
|
.split("-")
|
|
120
120
|
.map((word) =>
|
|
121
121
|
word.replace(
|
|
@@ -124,6 +124,12 @@ function getIconForKey(key: string) {
|
|
|
124
124
|
)
|
|
125
125
|
)
|
|
126
126
|
.join("")}`;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function getIconForKey(IconCamelCase: string) {
|
|
130
|
+
if (IconCamelCase.indexOf("-") !== -1) {
|
|
131
|
+
IconCamelCase = toCamelCase(IconCamelCase);
|
|
132
|
+
}
|
|
127
133
|
|
|
128
134
|
const antKey: AntKey = `${IconCamelCase}Outlined` as any;
|
|
129
135
|
if (AntIcons[antKey]) {
|