venice-ui 1.1.2 → 1.1.4
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/cjs/Theme/Theme.js +4 -0
- package/dist/cjs/components/Icons/Icon.js +7 -2
- package/dist/cjs/components/Icons/Icon.styles.js +23 -16
- package/dist/cjs/components/Table/Table.js +15 -1
- package/dist/esm/Theme/Theme.js +4 -0
- package/dist/esm/components/Icons/Icon.js +8 -3
- package/dist/esm/components/Icons/Icon.styles.js +23 -16
- package/dist/esm/components/Table/Table.js +15 -1
- package/dist/types/Theme/Theme.d.ts +3 -0
- package/dist/types/components/Icons/Icon.d.ts +1 -0
- package/dist/types/components/Icons/Icon.styles.d.ts +1 -0
- package/package.json +1 -1
package/dist/cjs/Theme/Theme.js
CHANGED
|
@@ -70,6 +70,10 @@ exports.mainTheme = {
|
|
|
70
70
|
buttonInverseHover: (0, polished_1.lighten)(0.3, exports.Theme.colors.primary),
|
|
71
71
|
disabledBackground: exports.Theme.colors.gray_4,
|
|
72
72
|
disabledText: exports.Theme.colors.gray_1,
|
|
73
|
+
//icon
|
|
74
|
+
iconColor: exports.Theme.colors.text,
|
|
75
|
+
iconDisabledColor: exports.Theme.colors.gray_4,
|
|
76
|
+
iconHoverColor: exports.Theme.colors.primary_10,
|
|
73
77
|
//text
|
|
74
78
|
textColor: exports.Theme.colors.text,
|
|
75
79
|
// input
|
|
@@ -8,8 +8,13 @@ const react_1 = __importDefault(require("react"));
|
|
|
8
8
|
const Theme_1 = require("../../Theme/Theme");
|
|
9
9
|
const Icon_styles_1 = require("./Icon.styles");
|
|
10
10
|
const IconsPath_1 = require("./IconsPath");
|
|
11
|
-
const Icon = ({ size = 24, name, right = false, left = false,
|
|
12
|
-
|
|
11
|
+
const Icon = ({ size = 24, name, right = false, left = false, hoverColor = Theme_1.mainTheme.iconHoverColor, active = false, inverseMode = false, onClick, isDisabled = false, color = isDisabled ? Theme_1.mainTheme.iconDisabledColor : Theme_1.mainTheme.iconColor, }) => {
|
|
12
|
+
const handleClick = () => {
|
|
13
|
+
if (!isDisabled && !!onClick) {
|
|
14
|
+
onClick();
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
return (react_1.default.createElement(Icon_styles_1.IconElement, { onClick: handleClick, right: right, left: left, active: active, hoverColor: hoverColor, inverseMode: inverseMode, isDisabled: isDisabled },
|
|
13
18
|
react_1.default.createElement("svg", { width: size, height: size, viewBox: '0 0 24 24', preserveAspectRatio: "xMidYMid meet", x: "0", y: "0", name: name },
|
|
14
19
|
react_1.default.createElement("path", { d: IconsPath_1.iconsPath[name], fill: color }))));
|
|
15
20
|
};
|
|
@@ -15,28 +15,35 @@ exports.IconElement = styled_components_1.default.div `
|
|
|
15
15
|
margin-left: ${(p) => (p.right ? Theme_1.Theme.padding.m : '0')};
|
|
16
16
|
margin-right: ${(p) => (p.left ? Theme_1.Theme.padding.m : '0')};
|
|
17
17
|
padding: 4px;
|
|
18
|
+
|
|
18
19
|
${(p) => p.onClick !== undefined &&
|
|
19
20
|
`
|
|
20
|
-
cursor:pointer;
|
|
21
|
+
cursor: ${(p) => (!p.isDisabled ? 'pointer' : 'not-allowed')};
|
|
21
22
|
path {
|
|
22
|
-
fill
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
fill: ${(p) => (p.color ? p.color : Theme_1.Theme.colors.primary)};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
${!p.isDisabled &&
|
|
27
|
+
`
|
|
28
|
+
&:hover {
|
|
29
|
+
cursor: ${(!p.isDisabled ? 'pointer' : 'not-allowed')};
|
|
30
|
+
${!p.inverseMode
|
|
31
|
+
? `
|
|
32
|
+
background-color: ${p.hoverColor};
|
|
33
|
+
`
|
|
34
|
+
: `
|
|
35
|
+
path {
|
|
36
|
+
fill: ${p.hoverColor};
|
|
37
|
+
}
|
|
38
|
+
`}
|
|
35
39
|
}
|
|
40
|
+
`}
|
|
36
41
|
`}
|
|
37
42
|
|
|
38
43
|
${(p) => p.active &&
|
|
39
44
|
`
|
|
40
|
-
background-color
|
|
41
|
-
|
|
45
|
+
background-color: ${p.hoverColor};
|
|
46
|
+
path {
|
|
47
|
+
}
|
|
48
|
+
`}
|
|
42
49
|
`;
|
|
@@ -58,12 +58,26 @@ hover = true, selectable = true, sortable = true, filtrable = false, sort = {
|
|
|
58
58
|
filters: filters,
|
|
59
59
|
headers: checkHeaders(),
|
|
60
60
|
});
|
|
61
|
+
const isElementsArrayEqual = (arr1, arr2) => {
|
|
62
|
+
if (arr1.length !== arr2.length) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return arr1.every((element, index) => element === arr2[index]);
|
|
66
|
+
};
|
|
61
67
|
(0, react_1.useEffect)(() => {
|
|
62
68
|
setTableProps({
|
|
63
69
|
...tableProps,
|
|
64
70
|
elements: (0, tableHelper_1.setElements)(elements, sort, filters),
|
|
65
71
|
});
|
|
66
72
|
}, [elements]);
|
|
73
|
+
(0, react_1.useEffect)(() => {
|
|
74
|
+
if (!isElementsArrayEqual(elements, tableProps.elements)) {
|
|
75
|
+
setTableProps({
|
|
76
|
+
...tableProps,
|
|
77
|
+
elements: (0, tableHelper_1.setElements)(elements, sort, filters),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
});
|
|
67
81
|
const [selectedRow, setSelectedRow] = (0, react_1.useState)('');
|
|
68
82
|
const handleRowClick = (id) => {
|
|
69
83
|
if (selectable) {
|
|
@@ -115,7 +129,7 @@ hover = true, selectable = true, sortable = true, filtrable = false, sort = {
|
|
|
115
129
|
: 'arrow_drop_up', color: theme.tableCellSortIcon, size: 20 })))))))))),
|
|
116
130
|
react_1.default.createElement("tbody", null, tableProps.elements.map((item) => (react_1.default.createElement(Table_styles_1.TableRow, { key: item.id, hover: hover, active: selectedRow === item.id, selectable: selectable, onClick: () => handleRowClick(item.id) }, tableProps.headers.map((header) => (react_1.default.createElement(react_1.default.Fragment, null, header.action ? (react_1.default.createElement(Table_styles_1.OptionTableCell, null,
|
|
117
131
|
react_1.default.createElement(Table_styles_1.OptionTableCellWrapper, { onClick: (e) => e.stopPropagation() },
|
|
118
|
-
react_1.default.createElement(DropdownMenu_1.DropdownMenu, { options: moreActions, targetID: item.id, iconName:
|
|
132
|
+
react_1.default.createElement(DropdownMenu_1.DropdownMenu, { options: moreActions, targetID: item.id, iconName: "more_vert", color: theme.tableMoreIconColor, iconInverseMode: true })))) : (react_1.default.createElement(Table_styles_1.TableCell, { key: `${item.id}-${header.name}` }, header.date
|
|
119
133
|
? (0, date_fns_1.format)(item[header.valueSource], 'dd-MM-yyyy')
|
|
120
134
|
: item[header.valueSource]))))))))))));
|
|
121
135
|
};
|
package/dist/esm/Theme/Theme.js
CHANGED
|
@@ -67,6 +67,10 @@ export const mainTheme = {
|
|
|
67
67
|
buttonInverseHover: lighten(0.3, Theme.colors.primary),
|
|
68
68
|
disabledBackground: Theme.colors.gray_4,
|
|
69
69
|
disabledText: Theme.colors.gray_1,
|
|
70
|
+
//icon
|
|
71
|
+
iconColor: Theme.colors.text,
|
|
72
|
+
iconDisabledColor: Theme.colors.gray_4,
|
|
73
|
+
iconHoverColor: Theme.colors.primary_10,
|
|
70
74
|
//text
|
|
71
75
|
textColor: Theme.colors.text,
|
|
72
76
|
// input
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { mainTheme } from '../../Theme/Theme';
|
|
3
3
|
import { IconElement } from './Icon.styles';
|
|
4
4
|
import { iconsPath } from './IconsPath';
|
|
5
|
-
export const Icon = ({ size = 24, name, right = false, left = false,
|
|
6
|
-
|
|
5
|
+
export const Icon = ({ size = 24, name, right = false, left = false, hoverColor = mainTheme.iconHoverColor, active = false, inverseMode = false, onClick, isDisabled = false, color = isDisabled ? mainTheme.iconDisabledColor : mainTheme.iconColor, }) => {
|
|
6
|
+
const handleClick = () => {
|
|
7
|
+
if (!isDisabled && !!onClick) {
|
|
8
|
+
onClick();
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
return (React.createElement(IconElement, { onClick: handleClick, right: right, left: left, active: active, hoverColor: hoverColor, inverseMode: inverseMode, isDisabled: isDisabled },
|
|
7
12
|
React.createElement("svg", { width: size, height: size, viewBox: '0 0 24 24', preserveAspectRatio: "xMidYMid meet", x: "0", y: "0", name: name },
|
|
8
13
|
React.createElement("path", { d: iconsPath[name], fill: color }))));
|
|
9
14
|
};
|
|
@@ -9,28 +9,35 @@ export const IconElement = styled.div `
|
|
|
9
9
|
margin-left: ${(p) => (p.right ? Theme.padding.m : '0')};
|
|
10
10
|
margin-right: ${(p) => (p.left ? Theme.padding.m : '0')};
|
|
11
11
|
padding: 4px;
|
|
12
|
+
|
|
12
13
|
${(p) => p.onClick !== undefined &&
|
|
13
14
|
`
|
|
14
|
-
cursor:pointer;
|
|
15
|
+
cursor: ${(p) => (!p.isDisabled ? 'pointer' : 'not-allowed')};
|
|
15
16
|
path {
|
|
16
|
-
fill
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
fill: ${(p) => (p.color ? p.color : Theme.colors.primary)};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
${!p.isDisabled &&
|
|
21
|
+
`
|
|
22
|
+
&:hover {
|
|
23
|
+
cursor: ${(!p.isDisabled ? 'pointer' : 'not-allowed')};
|
|
24
|
+
${!p.inverseMode
|
|
25
|
+
? `
|
|
26
|
+
background-color: ${p.hoverColor};
|
|
27
|
+
`
|
|
28
|
+
: `
|
|
29
|
+
path {
|
|
30
|
+
fill: ${p.hoverColor};
|
|
31
|
+
}
|
|
32
|
+
`}
|
|
29
33
|
}
|
|
34
|
+
`}
|
|
30
35
|
`}
|
|
31
36
|
|
|
32
37
|
${(p) => p.active &&
|
|
33
38
|
`
|
|
34
|
-
background-color
|
|
35
|
-
|
|
39
|
+
background-color: ${p.hoverColor};
|
|
40
|
+
path {
|
|
41
|
+
}
|
|
42
|
+
`}
|
|
36
43
|
`;
|
|
@@ -32,12 +32,26 @@ hover = true, selectable = true, sortable = true, filtrable = false, sort = {
|
|
|
32
32
|
filters: filters,
|
|
33
33
|
headers: checkHeaders(),
|
|
34
34
|
});
|
|
35
|
+
const isElementsArrayEqual = (arr1, arr2) => {
|
|
36
|
+
if (arr1.length !== arr2.length) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return arr1.every((element, index) => element === arr2[index]);
|
|
40
|
+
};
|
|
35
41
|
useEffect(() => {
|
|
36
42
|
setTableProps({
|
|
37
43
|
...tableProps,
|
|
38
44
|
elements: setElements(elements, sort, filters),
|
|
39
45
|
});
|
|
40
46
|
}, [elements]);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!isElementsArrayEqual(elements, tableProps.elements)) {
|
|
49
|
+
setTableProps({
|
|
50
|
+
...tableProps,
|
|
51
|
+
elements: setElements(elements, sort, filters),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
41
55
|
const [selectedRow, setSelectedRow] = useState('');
|
|
42
56
|
const handleRowClick = (id) => {
|
|
43
57
|
if (selectable) {
|
|
@@ -89,7 +103,7 @@ hover = true, selectable = true, sortable = true, filtrable = false, sort = {
|
|
|
89
103
|
: 'arrow_drop_up', color: theme.tableCellSortIcon, size: 20 })))))))))),
|
|
90
104
|
React.createElement("tbody", null, tableProps.elements.map((item) => (React.createElement(TableRow, { key: item.id, hover: hover, active: selectedRow === item.id, selectable: selectable, onClick: () => handleRowClick(item.id) }, tableProps.headers.map((header) => (React.createElement(React.Fragment, null, header.action ? (React.createElement(OptionTableCell, null,
|
|
91
105
|
React.createElement(OptionTableCellWrapper, { onClick: (e) => e.stopPropagation() },
|
|
92
|
-
React.createElement(DropdownMenu, { options: moreActions, targetID: item.id, iconName:
|
|
106
|
+
React.createElement(DropdownMenu, { options: moreActions, targetID: item.id, iconName: "more_vert", color: theme.tableMoreIconColor, iconInverseMode: true })))) : (React.createElement(TableCell, { key: `${item.id}-${header.name}` }, header.date
|
|
93
107
|
? format(item[header.valueSource], 'dd-MM-yyyy')
|
|
94
108
|
: item[header.valueSource]))))))))))));
|
|
95
109
|
};
|
|
@@ -65,6 +65,9 @@ export declare const mainTheme: {
|
|
|
65
65
|
buttonInverseHover: string;
|
|
66
66
|
disabledBackground: string;
|
|
67
67
|
disabledText: string;
|
|
68
|
+
iconColor: string;
|
|
69
|
+
iconDisabledColor: string;
|
|
70
|
+
iconHoverColor: string;
|
|
68
71
|
textColor: string;
|
|
69
72
|
inputDefaultBackground: string;
|
|
70
73
|
inputDefaultBorder: string;
|