@gisce/react-ooui 1.2.0-rc.34 → 1.2.0-rc.36
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/actionbar/TreeActionBar.d.ts.map +1 -1
- package/dist/helpers/iconMapper.d.ts +2 -1
- package/dist/helpers/iconMapper.d.ts.map +1 -1
- package/dist/react-ooui.es.js +9679 -13141
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +43 -43
- package/dist/react-ooui.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/iconMapper.test.ts +20 -5
- package/src/actionbar/TreeActionBar.tsx +16 -17
- package/src/helpers/iconMapper.ts +130 -107
- package/src/stories/containers/Notebook.stories.tsx +27 -0
- package/dist/helpers/icons/antd_icons.d.ts +0 -4
- package/dist/helpers/icons/antd_icons.d.ts.map +0 -1
- package/dist/helpers/icons/tabler_icons.d.ts +0 -4
- package/dist/helpers/icons/tabler_icons.d.ts.map +0 -1
- package/src/helpers/icons/antd_icons.ts +0 -1583
- package/src/helpers/icons/tabler_icons.ts +0 -5367
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gisce/react-ooui",
|
|
3
|
-
"version": "1.2.0-rc.
|
|
3
|
+
"version": "1.2.0-rc.36",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"src",
|
|
@@ -40,7 +40,7 @@
|
|
|
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",
|
|
43
|
-
"@tabler/icons": "^
|
|
43
|
+
"@tabler/icons-react": "^2.11.0",
|
|
44
44
|
"antd": "^4.24.3",
|
|
45
45
|
"buffer": "^6.0.3",
|
|
46
46
|
"fiber-diagram": "github:gisce/fiber-diagram",
|
|
@@ -2,14 +2,29 @@ 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
|
+
})
|
|
19
|
+
test("should return gtk-go", () => {
|
|
20
|
+
const findAndReplaceIcon = Icons.FileSearchOutlined;
|
|
21
|
+
const icon = iconMapper("gtk-find-and-replace");
|
|
22
|
+
expect(icon).toBe(findAndReplaceIcon);
|
|
23
|
+
})
|
|
24
|
+
describe("If key doesn't exist in iconMapper", () => {
|
|
25
|
+
test("should return undefined", () => {
|
|
26
|
+
const icon = iconMapper("gtk-foo-bar");
|
|
27
|
+
expect(icon).toBe(undefined);
|
|
28
|
+
})
|
|
29
|
+
})
|
|
15
30
|
});
|
|
@@ -163,9 +163,24 @@ function TreeActionBar(props: Props) {
|
|
|
163
163
|
}
|
|
164
164
|
}}
|
|
165
165
|
/>
|
|
166
|
+
{!treeExpandable && (
|
|
167
|
+
<ButtonWithBadge
|
|
168
|
+
icon={
|
|
169
|
+
<FilterOutlined
|
|
170
|
+
style={{ color: searchVisible ? "white" : undefined }}
|
|
171
|
+
/>
|
|
172
|
+
}
|
|
173
|
+
tooltip={t("advanced_search")}
|
|
174
|
+
type={searchVisible ? "primary" : "default"}
|
|
175
|
+
onClick={() => {
|
|
176
|
+
setSearchVisible?.(!searchVisible);
|
|
177
|
+
}}
|
|
178
|
+
disabled={duplicatingItem || removingItem || treeIsLoading}
|
|
179
|
+
badgeNumber={searchParams?.length}
|
|
180
|
+
/>
|
|
181
|
+
)}
|
|
166
182
|
{separator()}
|
|
167
183
|
<NewButton disabled={treeIsLoading} />
|
|
168
|
-
{separator()}
|
|
169
184
|
<ActionButton
|
|
170
185
|
icon={<CopyOutlined />}
|
|
171
186
|
tooltip={t("duplicate")}
|
|
@@ -191,22 +206,6 @@ function TreeActionBar(props: Props) {
|
|
|
191
206
|
{separator()}
|
|
192
207
|
</>
|
|
193
208
|
)}
|
|
194
|
-
{!treeExpandable && (
|
|
195
|
-
<ButtonWithBadge
|
|
196
|
-
icon={
|
|
197
|
-
<FilterOutlined
|
|
198
|
-
style={{ color: searchVisible ? "white" : undefined }}
|
|
199
|
-
/>
|
|
200
|
-
}
|
|
201
|
-
tooltip={t("advanced_search")}
|
|
202
|
-
type={searchVisible ? "primary" : "default"}
|
|
203
|
-
onClick={() => {
|
|
204
|
-
setSearchVisible?.(!searchVisible);
|
|
205
|
-
}}
|
|
206
|
-
disabled={duplicatingItem || removingItem || treeIsLoading}
|
|
207
|
-
badgeNumber={searchParams?.length}
|
|
208
|
-
/>
|
|
209
|
-
)}
|
|
210
209
|
<ActionButton
|
|
211
210
|
icon={<InfoCircleOutlined />}
|
|
212
211
|
tooltip={t("showLogs")}
|
|
@@ -1,112 +1,120 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import * as AntIcons from "@ant-design/icons";
|
|
3
|
+
import * as TablerIcons from "@tabler/icons-react";
|
|
2
4
|
import Icon from "@ant-design/icons";
|
|
3
|
-
import { AntIcons as Icons } from "./icons/antd_icons";
|
|
4
|
-
import { TablerIcons } from "./icons/tabler_icons";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"terp-
|
|
11
|
-
"terp-
|
|
12
|
-
"terp-
|
|
13
|
-
"terp-
|
|
14
|
-
"terp-
|
|
15
|
-
"terp-
|
|
16
|
-
"terp-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
6
|
+
type TablerKey = keyof typeof TablerIcons;
|
|
7
|
+
type AntKey = keyof typeof AntIcons;
|
|
8
|
+
|
|
9
|
+
const iconMapping: { [key: string]: string } = {
|
|
10
|
+
"terp-purchase": "ShoppingCart",
|
|
11
|
+
"terp-graph": "PieChart",
|
|
12
|
+
"terp-crm": "Contacts",
|
|
13
|
+
"terp-hr": "Friends",
|
|
14
|
+
"terp-account": "BuildingBank",
|
|
15
|
+
"terp-project": "Checklist",
|
|
16
|
+
"terp-administration": "Adjustments",
|
|
17
|
+
"terp-partner": "Team",
|
|
18
|
+
"terp-mrp": "Build",
|
|
19
|
+
"terp-product": "Shopping",
|
|
20
|
+
STOCK_JUSTIFY_FILL: "UnorderedList",
|
|
21
|
+
STOCK_INDENT: "IndentIncrease",
|
|
22
|
+
STOCK_HELP: "Question",
|
|
23
|
+
STOCK_GO_UP: "ArrowUp",
|
|
24
|
+
STOCK_SORT_DESCENDING: "SortDescending",
|
|
25
|
+
STOCK_ADD: "Plus",
|
|
26
|
+
STOCK_GOTO_LAST: "FastForward",
|
|
27
|
+
STOCK_FIND: "Search",
|
|
28
|
+
STOCK_PROPERTIES: "Control",
|
|
29
|
+
STOCK_DIALOG_INFO: "Info",
|
|
30
|
+
STOCK_FLOPPY: "Usb",
|
|
31
|
+
STOCK_JUSTIFY_CENTER: "AlignCenter",
|
|
32
|
+
STOCK_GO_BACK: "ArrowLeft",
|
|
33
|
+
STOCK_UNDERLINE: "Underline",
|
|
34
|
+
STOCK_BOLD: "Bold",
|
|
35
|
+
STOCK_APPLY: "Check",
|
|
36
|
+
STOCK_ZOOM_OUT: "ZoomOut",
|
|
37
|
+
STOCK_STRIKETHROUGH: "Strikethrough",
|
|
38
|
+
STOCK_MEDIA_REWIND: "Backward",
|
|
39
|
+
STOCK_PRINT: "Printer",
|
|
40
|
+
STOCK_NO: "Close",
|
|
41
|
+
STOCK_GOTO_FIRST: "FastBackward",
|
|
42
|
+
STOCK_CLOSE: "Close",
|
|
43
|
+
STOCK_REMOVE: "Minus",
|
|
44
|
+
STOCK_CUT: "Scissor",
|
|
45
|
+
STOCK_DIALOG_AUTHENTICATION: "Safety",
|
|
46
|
+
STOCK_ZOOM_FIT: "Expand",
|
|
47
|
+
STOCK_JUMP_TO: "Select",
|
|
48
|
+
STOCK_HARDDISK: "Hdd",
|
|
49
|
+
STOCK_SAVE_AS: "Save",
|
|
50
|
+
STOCK_UNDO: "Undo",
|
|
51
|
+
STOCK_JUSTIFY_RIGHT: "AlignRight",
|
|
52
|
+
STOCK_DIALOG_ERROR: "CloseCircle",
|
|
53
|
+
STOCK_INDEX: "Profile",
|
|
54
|
+
STOCK_GOTO_BOTTOM: "VerticalAlignBottom",
|
|
55
|
+
STOCK_MEDIA_NEXT: "StepForward",
|
|
56
|
+
STOCK_REDO: "Redo",
|
|
57
|
+
STOCK_COPY: "Copy",
|
|
58
|
+
STOCK_MEDIA_PAUSE: "Pause",
|
|
59
|
+
STOCK_GO_FORWARD: "ArrowRight",
|
|
60
|
+
STOCK_UNDELETE: "Undo",
|
|
61
|
+
STOCK_EXECUTE: "Setting",
|
|
62
|
+
STOCK_SAVE: "Save",
|
|
63
|
+
STOCK_DIALOG_QUESTION: "QuestionCircle",
|
|
64
|
+
STOCK_SORT_ASCENDING: "SortAscending",
|
|
65
|
+
STOCK_REFRESH: "Reload",
|
|
66
|
+
STOCK_MEDIA_FORWARD: "Forward",
|
|
67
|
+
STOCK_STOP: "Border",
|
|
68
|
+
STOCK_PRINT_PREVIEW: "Printer",
|
|
69
|
+
STOCK_HOME: "Home",
|
|
70
|
+
STOCK_PASTE: "CarryOut",
|
|
71
|
+
STOCK_ZOOM_100: "ZoomIn",
|
|
72
|
+
STOCK_FIND_AND_REPLACE: "FileSearch",
|
|
73
|
+
STOCK_DIALOG_WARNING: "Warning",
|
|
74
|
+
STOCK_ZOOM_IN: "ZoomIn",
|
|
75
|
+
STOCK_CONVERT: "Export",
|
|
76
|
+
STOCK_ITALIC: "Italic",
|
|
77
|
+
STOCK_YES: "Check",
|
|
78
|
+
STOCK_MEDIA_PLAY: "PlayCircle",
|
|
79
|
+
STOCK_MEDIA_RECORD: "VideoCamera",
|
|
80
|
+
STOCK_MEDIA_PREVIOUS: "StepBackward",
|
|
81
|
+
STOCK_NEW: "FileAdd",
|
|
82
|
+
STOCK_CANCEL: "Close",
|
|
83
|
+
STOCK_DISCONNECT: "Api",
|
|
84
|
+
STOCK_JUSTIFY_LEFT: "AlignLeft",
|
|
85
|
+
STOCK_FILE: "File",
|
|
86
|
+
STOCK_QUIT: "Logout",
|
|
87
|
+
STOCK_EDIT: "Edit",
|
|
88
|
+
STOCK_CONNECT: "Api",
|
|
89
|
+
STOCK_GO_DOWN: "CaretDown",
|
|
90
|
+
STOCK_NETWORK: "Apartment",
|
|
91
|
+
STOCK_OK: "Check",
|
|
92
|
+
STOCK_GOTO_TOP: "VerticalAlignTop",
|
|
93
|
+
STOCK_ABOUT: "Star",
|
|
94
|
+
STOCK_COLOR_PICKER: "Aim",
|
|
95
|
+
STOCK_SELECT_FONT: "FontSize",
|
|
96
|
+
STOCK_DELETE: "Delete",
|
|
97
|
+
STOCK_DND: "FileText",
|
|
98
|
+
STOCK_CLEAR: "CloseSquare",
|
|
99
|
+
STOCK_UNINDENT: "AlignLeft",
|
|
100
|
+
STOCK_PREFERENCES: "Setting",
|
|
98
101
|
};
|
|
99
102
|
|
|
100
|
-
export default (key: string)
|
|
103
|
+
export default (key: string) => {
|
|
101
104
|
if (key.indexOf("gtk-") !== -1) {
|
|
102
|
-
const rootIcon = key.replace("gtk-", "").replace(
|
|
103
|
-
|
|
104
|
-
return iconMapping[newKey];
|
|
105
|
+
const rootIcon = key.replace("gtk-", "").replace(/\-/g, "_");
|
|
106
|
+
key = `STOCK_${rootIcon.toUpperCase()}`;
|
|
105
107
|
}
|
|
108
|
+
|
|
106
109
|
if (iconMapping.hasOwnProperty(key)) {
|
|
107
|
-
return iconMapping[key];
|
|
110
|
+
return getIconForKey(iconMapping[key]);
|
|
108
111
|
}
|
|
109
|
-
|
|
112
|
+
|
|
113
|
+
return getIconForKey(key);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
function toCamelCase(key: string): string {
|
|
117
|
+
return `${key
|
|
110
118
|
.split("-")
|
|
111
119
|
.map((word) =>
|
|
112
120
|
word.replace(
|
|
@@ -115,18 +123,33 @@ export default (key: string): React.ElementType | undefined => {
|
|
|
115
123
|
)
|
|
116
124
|
)
|
|
117
125
|
.join("")}`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function getIconForKey(key: string) {
|
|
129
|
+
let IconCamelCase = key.charAt(0).toUpperCase() + key.slice(1); // Capitalize first letter
|
|
130
|
+
if (IconCamelCase.indexOf("-") !== -1) {
|
|
131
|
+
IconCamelCase = toCamelCase(IconCamelCase);
|
|
132
|
+
}
|
|
118
133
|
|
|
119
|
-
const antKey = `${IconCamelCase}Outlined
|
|
120
|
-
if (
|
|
121
|
-
return
|
|
134
|
+
const antKey: AntKey = `${IconCamelCase}Outlined` as any;
|
|
135
|
+
if (AntIcons[antKey]) {
|
|
136
|
+
return AntIcons[antKey];
|
|
122
137
|
}
|
|
123
138
|
|
|
124
|
-
const tablerKey = `Icon${IconCamelCase}
|
|
125
|
-
if (TablerIcons
|
|
139
|
+
const tablerKey: TablerKey = `Icon${IconCamelCase}` as any;
|
|
140
|
+
if (TablerIcons[tablerKey]) {
|
|
141
|
+
const TablerIcon = () =>
|
|
142
|
+
React.createElement(TablerIcons[tablerKey] as any, {
|
|
143
|
+
fill: "transparent",
|
|
144
|
+
height: 17,
|
|
145
|
+
width: 17,
|
|
146
|
+
});
|
|
126
147
|
const CustomIcon = () =>
|
|
127
|
-
React.createElement(Icon, {
|
|
148
|
+
React.createElement(Icon, {
|
|
149
|
+
component: TablerIcon,
|
|
150
|
+
});
|
|
128
151
|
return CustomIcon;
|
|
129
152
|
}
|
|
130
153
|
|
|
131
154
|
return undefined;
|
|
132
|
-
}
|
|
155
|
+
}
|
|
@@ -167,3 +167,30 @@ export const IconTabs = (): React.ReactElement => {
|
|
|
167
167
|
</LocaleProvider>
|
|
168
168
|
);
|
|
169
169
|
};
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
export const IconTablerTabs = (): React.ReactElement => {
|
|
173
|
+
|
|
174
|
+
const arch = `<form>
|
|
175
|
+
<notebook name="notebook">
|
|
176
|
+
<page string="Home" icon="bolt">
|
|
177
|
+
<field name="name" />
|
|
178
|
+
</page>
|
|
179
|
+
<page string="Attributes" icon="address-book">
|
|
180
|
+
<field name="surname" />
|
|
181
|
+
</page>
|
|
182
|
+
</notebook>
|
|
183
|
+
</form>`;
|
|
184
|
+
|
|
185
|
+
const formOoui = new FormOoui(fields);
|
|
186
|
+
formOoui.parse(arch);
|
|
187
|
+
const notebookOoui = formOoui.findById("notebook") as NotebookOoui;
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<LocaleProvider lang="en_US">
|
|
191
|
+
<Form>
|
|
192
|
+
<Notebook ooui={notebookOoui} />
|
|
193
|
+
</Form>
|
|
194
|
+
</LocaleProvider>
|
|
195
|
+
);
|
|
196
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"antd_icons.d.ts","sourceRoot":"","sources":["antd_icons.ts"],"names":[],"mappings":"AAwxBA,eAAO,MAAM,QAAQ,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAsxB1C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tabler_icons.d.ts","sourceRoot":"","sources":["tabler_icons.ts"],"names":[],"mappings":"AA4nFA,eAAO,MAAM,WAAW,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CA0nF7C,CAAC"}
|