fmihel-windeco-components 2.0.0-beta.6 → 2.0.0-beta.8
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/windeco-components.js +1 -1
- package/jsx/NavBar/NavItem.jsx +36 -25
- package/jsx/NavBar/NavLogo.jsx +5 -3
- package/jsx/NavBar.jsx +26 -61
- package/jsx/Table/TBody.jsx +2 -0
- package/jsx/Table/TD.jsx +4 -1
- package/jsx/Table/TH.jsx +2 -1
- package/jsx/Table/THead.jsx +1 -0
- package/jsx/Table/TR.jsx +3 -0
- package/jsx/Table.jsx +3 -0
- package/jsx/TableFixed/Data.jsx +2 -0
- package/jsx/TableFixed/Header.jsx +2 -0
- package/jsx/TableFixed/TD.jsx +1 -1
- package/jsx/TableFixed/TR.jsx +6 -1
- package/jsx/TableFixed.jsx +3 -0
- package/jsx/arch/NavBar/NavItem.jsx +45 -0
- package/jsx/arch/NavBar/NavLogo.jsx +23 -0
- package/jsx/arch/NavBar.jsx +81 -0
- package/package.json +1 -1
- package/style/Container.scss +1 -1
- package/style/NavBar.scss +160 -180
- package/style/arch/NavBar.scss +236 -0
- package/style/vars.scss +76 -23
- /package/jsx/{NavBar → arch/NavBar}/NavMenu.jsx +0 -0
package/jsx/NavBar.jsx
CHANGED
|
@@ -1,72 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
let _collapse = [];
|
|
8
|
-
export const collapse = (p = undefined) => {
|
|
9
|
-
if (p === undefined) {
|
|
10
|
-
_collapse.map((close) => close());
|
|
11
|
-
} else if (p.add) {
|
|
12
|
-
_collapse.push(p.add);
|
|
13
|
-
} else if (p.remove) {
|
|
14
|
-
_collapse = _collapse.filter((it) => it === p.remove);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
1
|
+
/* eslint-disable no-nested-ternary */
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import Collapse from './Collapse.jsx';
|
|
4
|
+
import getId from './Utils/getId.js';
|
|
5
|
+
import DefaultLogo from './NavBar/NavLogo.jsx';
|
|
17
6
|
|
|
18
7
|
function NavBar({
|
|
19
|
-
|
|
8
|
+
id = getId('navbar'),
|
|
20
9
|
className = NavBar.global.className,
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
style = { ...NavBar.global.style },
|
|
11
|
+
Logo = undefined,
|
|
23
12
|
children,
|
|
24
13
|
}) {
|
|
25
|
-
const [
|
|
26
|
-
const
|
|
27
|
-
const toggleMenu = () => {
|
|
28
|
-
setItemsState(itemsState === 'close' ? 'open' : 'close');
|
|
29
|
-
};
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
const close = () => {
|
|
32
|
-
setItemsState('close');
|
|
33
|
-
};
|
|
34
|
-
collapse({ add: close });
|
|
14
|
+
const [collapse, setCollapse] = useState(true);
|
|
15
|
+
const childs = Array.isArray(children) ? children : [children];
|
|
35
16
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
const resize = () => {
|
|
43
|
-
const current = isCompact();
|
|
44
|
-
if (current !== compact) {
|
|
45
|
-
setCompact(current);
|
|
46
|
-
setItemsState('close');
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
const removeResizeScreen = onResizeScreen(resize);
|
|
50
|
-
resize();
|
|
51
|
-
return () => {
|
|
52
|
-
removeResizeScreen();
|
|
53
|
-
};
|
|
54
|
-
}, [compact]);
|
|
55
|
-
//console.log('children',children,Array.isArray(children));
|
|
56
|
-
let childs = Array.isArray(children)?children:[children];
|
|
17
|
+
const navBtnClick = () => {
|
|
18
|
+
setCollapse(!collapse);
|
|
19
|
+
};
|
|
20
|
+
const typeLogo = typeof Logo;
|
|
57
21
|
return (
|
|
58
|
-
<div
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
className={ `${className} ${addClass}`}
|
|
22
|
+
<div navbar=""
|
|
23
|
+
id={id}
|
|
24
|
+
{...className ? { className } : {}}
|
|
62
25
|
style={{ ...NavBar.global.style, ...style }}
|
|
63
26
|
>
|
|
64
|
-
<div
|
|
65
|
-
|
|
66
|
-
|
|
27
|
+
<div nav-panel="">
|
|
28
|
+
{typeLogo === 'string' && <DefaultLogo caption={Logo}/>}
|
|
29
|
+
{typeLogo !== 'string' && Logo && <Logo/>}
|
|
30
|
+
|
|
31
|
+
<div nav-empty=""></div>
|
|
32
|
+
<div nav-btn="" onClick={navBtnClick}>≡</div>
|
|
67
33
|
</div>
|
|
68
|
-
<div
|
|
69
|
-
{childs
|
|
34
|
+
<div nav-menu="" {...(!collapse ? { expand: '' } : {})}>
|
|
35
|
+
{childs}
|
|
70
36
|
</div>
|
|
71
37
|
</div>
|
|
72
38
|
);
|
|
@@ -74,8 +40,7 @@ function NavBar({
|
|
|
74
40
|
|
|
75
41
|
NavBar.global = {
|
|
76
42
|
className: 'wd-navbar',
|
|
77
|
-
addClass: '',
|
|
78
43
|
style: {},
|
|
79
|
-
|
|
80
44
|
};
|
|
45
|
+
|
|
81
46
|
export default NavBar;
|
package/jsx/Table/TBody.jsx
CHANGED
|
@@ -5,6 +5,7 @@ function TBody({
|
|
|
5
5
|
data = [],
|
|
6
6
|
fields = [],
|
|
7
7
|
aliasId = 'ID',
|
|
8
|
+
aliasAttr = '-attr-',
|
|
8
9
|
noData = 'no data',
|
|
9
10
|
footer = 'end',
|
|
10
11
|
select = [],
|
|
@@ -22,6 +23,7 @@ function TBody({
|
|
|
22
23
|
select={aliasId in row && select.findIndex((id) => `${id}` === `${row[aliasId]}`) > -1}
|
|
23
24
|
onClick={onClick}
|
|
24
25
|
aliasId = {aliasId}
|
|
26
|
+
aliasAttr = {aliasAttr}
|
|
25
27
|
/>)}
|
|
26
28
|
{(!haveData && noData !== false) && <tr><td nodata='' colSpan={fields.length}>{noData}</td></tr>}
|
|
27
29
|
{(haveData && footer !== false) && <tr><td footer='' colSpan={fields.length}>{footer}</td></tr>}
|
package/jsx/Table/TD.jsx
CHANGED
package/jsx/Table/TH.jsx
CHANGED
|
@@ -4,6 +4,7 @@ function TH({
|
|
|
4
4
|
data = [],
|
|
5
5
|
fieldName,
|
|
6
6
|
caption,
|
|
7
|
+
title,
|
|
7
8
|
onClick,
|
|
8
9
|
}) {
|
|
9
10
|
const click = () => {
|
|
@@ -13,7 +14,7 @@ function TH({
|
|
|
13
14
|
});
|
|
14
15
|
}
|
|
15
16
|
};
|
|
16
|
-
return (<th onClick={click}>{caption}</th>);
|
|
17
|
+
return (<th id={fieldName} onClick={click} {...(title ? { title } : {})}>{caption}</th>);
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export default TH;
|
package/jsx/Table/THead.jsx
CHANGED
package/jsx/Table/TR.jsx
CHANGED
|
@@ -8,10 +8,12 @@ function TR({
|
|
|
8
8
|
onClick,
|
|
9
9
|
select = false,
|
|
10
10
|
aliasId,
|
|
11
|
+
aliasAttr,
|
|
11
12
|
}) {
|
|
12
13
|
return (
|
|
13
14
|
<tr
|
|
14
15
|
{...(select ? { select: '' } : {})}
|
|
16
|
+
{...row[aliasAttr]}
|
|
15
17
|
>
|
|
16
18
|
{fields.map((field, i) => <TD
|
|
17
19
|
key = {field.name}
|
|
@@ -21,6 +23,7 @@ function TR({
|
|
|
21
23
|
value = {row[field.name]}
|
|
22
24
|
onClick = {onClick}
|
|
23
25
|
aliasId = {aliasId}
|
|
26
|
+
|
|
24
27
|
/>)}
|
|
25
28
|
</tr>
|
|
26
29
|
);
|
package/jsx/Table.jsx
CHANGED
|
@@ -6,6 +6,7 @@ function Table({
|
|
|
6
6
|
id,
|
|
7
7
|
className = Table.global.className,
|
|
8
8
|
aliasId = Table.global.aliasId,
|
|
9
|
+
aliasAttr = Table.global.aliasAttr,
|
|
9
10
|
data = [],
|
|
10
11
|
fields = [],
|
|
11
12
|
header = true, /// / string true false
|
|
@@ -29,6 +30,7 @@ function Table({
|
|
|
29
30
|
data={data}
|
|
30
31
|
fields={fields}
|
|
31
32
|
aliasId={aliasId}
|
|
33
|
+
aliasAttr={aliasAttr}
|
|
32
34
|
noData={noData}
|
|
33
35
|
footer = {footer}
|
|
34
36
|
select={select}
|
|
@@ -43,6 +45,7 @@ function Table({
|
|
|
43
45
|
Table.global = {
|
|
44
46
|
className: 'wd-table',
|
|
45
47
|
aliasId: 'ID',
|
|
48
|
+
aliasAttr: '-attr-',
|
|
46
49
|
header: true, // string true false
|
|
47
50
|
noData: 'no data', // string or false
|
|
48
51
|
footer: 'end', // string ot false
|
package/jsx/TableFixed/Data.jsx
CHANGED
|
@@ -5,6 +5,7 @@ function Data({
|
|
|
5
5
|
id,
|
|
6
6
|
data = [],
|
|
7
7
|
aliasId,
|
|
8
|
+
aliasAttr,
|
|
8
9
|
fields,
|
|
9
10
|
style = {},
|
|
10
11
|
footer = false,
|
|
@@ -26,6 +27,7 @@ function Data({
|
|
|
26
27
|
data={data}
|
|
27
28
|
fields = {fields}
|
|
28
29
|
aliasId={aliasId}
|
|
30
|
+
aliasAttr={aliasAttr}
|
|
29
31
|
select={(select.findIndex((ID) => row[aliasId] == ID) >= 0)}
|
|
30
32
|
onClick={onClick}
|
|
31
33
|
/>
|
|
@@ -18,9 +18,11 @@ function Header({
|
|
|
18
18
|
{(type === 'fields') && fields.map((field, i) => (
|
|
19
19
|
<th
|
|
20
20
|
key={field.name}
|
|
21
|
+
id={field.name}
|
|
21
22
|
style={{
|
|
22
23
|
...(i < widths.length ? { width: widths[i], maxWidth: widths[i] } : {}),
|
|
23
24
|
}}
|
|
25
|
+
{...(field.title ? { title: field.title } : {})}
|
|
24
26
|
>
|
|
25
27
|
{field.caption}
|
|
26
28
|
</th>))
|
package/jsx/TableFixed/TD.jsx
CHANGED
package/jsx/TableFixed/TR.jsx
CHANGED
|
@@ -6,11 +6,16 @@ function TR({
|
|
|
6
6
|
data = [],
|
|
7
7
|
fields = [], // []
|
|
8
8
|
aliasId = 'ID',
|
|
9
|
+
aliasAttr = '-attr-',
|
|
9
10
|
select = false,
|
|
10
11
|
onClick = undefined,
|
|
11
12
|
}) {
|
|
12
13
|
return (
|
|
13
|
-
<tr
|
|
14
|
+
<tr
|
|
15
|
+
id={row[aliasId]}
|
|
16
|
+
{...(select ? { select: 'true' } : {})}
|
|
17
|
+
{...row[aliasAttr]}
|
|
18
|
+
>
|
|
14
19
|
{fields.map((field) => (
|
|
15
20
|
<TD
|
|
16
21
|
key = {field.name}
|
package/jsx/TableFixed.jsx
CHANGED
|
@@ -13,6 +13,7 @@ function TableFixed({
|
|
|
13
13
|
className = TableFixed.global.className,
|
|
14
14
|
|
|
15
15
|
aliasId = TableFixed.global.aliasId,
|
|
16
|
+
aliasAttr = TableFixed.global.aliasAttr,
|
|
16
17
|
data = [],
|
|
17
18
|
fields = [],
|
|
18
19
|
header = true, /// / string true false
|
|
@@ -108,6 +109,7 @@ function TableFixed({
|
|
|
108
109
|
&& <Data
|
|
109
110
|
id={id}
|
|
110
111
|
aliasId={aliasId}
|
|
112
|
+
aliasAttr={aliasAttr}
|
|
111
113
|
data={data}
|
|
112
114
|
fields={fields}
|
|
113
115
|
footer={footer}
|
|
@@ -129,6 +131,7 @@ function TableFixed({
|
|
|
129
131
|
TableFixed.global = {
|
|
130
132
|
className: 'wd-table-fixed',
|
|
131
133
|
aliasId: 'ID',
|
|
134
|
+
aliasAttr: '-attr-',
|
|
132
135
|
header: true, // string true false
|
|
133
136
|
noData: 'no data', // string or false
|
|
134
137
|
footer: 'end', // string ot false
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export function isNavItem(o) {
|
|
4
|
+
return typeof o === 'function' && (o.name === 'NavItem' || o._originalClass === 'NavItem');
|
|
5
|
+
}
|
|
6
|
+
function NavItem({
|
|
7
|
+
caption = undefined,
|
|
8
|
+
link,
|
|
9
|
+
className = NavItem.global.className,
|
|
10
|
+
addClass = NavItem.global.addClass,
|
|
11
|
+
style = NavItem.global.style,
|
|
12
|
+
onClick = undefined,
|
|
13
|
+
children,
|
|
14
|
+
|
|
15
|
+
}) {
|
|
16
|
+
const click = () => {
|
|
17
|
+
if (onClick) onClick({ link });
|
|
18
|
+
};
|
|
19
|
+
const text = () => {
|
|
20
|
+
if (caption) {
|
|
21
|
+
return typeof caption === 'string' ? <span it="cap">{caption}</span> : caption;
|
|
22
|
+
} if (children) {
|
|
23
|
+
return typeof children === 'string' ? <span it="cap">{children}</span> : children;
|
|
24
|
+
}
|
|
25
|
+
return '';
|
|
26
|
+
};
|
|
27
|
+
return (
|
|
28
|
+
<div
|
|
29
|
+
className={ `${className} ${addClass}`}
|
|
30
|
+
style={{ ...NavItem.global.style, ...style }}
|
|
31
|
+
onClick={click}
|
|
32
|
+
>
|
|
33
|
+
{text()}
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
NavItem._originalClass = 'NavItem';
|
|
38
|
+
|
|
39
|
+
NavItem.global = {
|
|
40
|
+
className: 'wd-nav-item',
|
|
41
|
+
addClass: '',
|
|
42
|
+
style: {},
|
|
43
|
+
|
|
44
|
+
};
|
|
45
|
+
export default NavItem;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
function NavLogo({
|
|
4
|
+
className = NavLogo.global.className,
|
|
5
|
+
addClass = NavLogo.global.addClass,
|
|
6
|
+
style = NavLogo.global.style,
|
|
7
|
+
children,
|
|
8
|
+
}) {
|
|
9
|
+
return (
|
|
10
|
+
<div className={ `${className} ${addClass}`}
|
|
11
|
+
style={{ ...NavLogo.global.style, ...style }}
|
|
12
|
+
>
|
|
13
|
+
{children}
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
NavLogo.global = {
|
|
19
|
+
className: 'wd-nav-logo',
|
|
20
|
+
style: {},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default NavLogo;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import NavItem, { isNavItem } from './NavBar/NavItem.jsx';
|
|
3
|
+
import { isNavMenu } from './NavBar/NavMenu.jsx';
|
|
4
|
+
import onResizeScreen from './Utils/onResizeScreen.js';
|
|
5
|
+
import isCompact from './Utils/isCompact.js';
|
|
6
|
+
|
|
7
|
+
let _collapse = [];
|
|
8
|
+
export const collapse = (p = undefined) => {
|
|
9
|
+
if (p === undefined) {
|
|
10
|
+
_collapse.map((close) => close());
|
|
11
|
+
} else if (p.add) {
|
|
12
|
+
_collapse.push(p.add);
|
|
13
|
+
} else if (p.remove) {
|
|
14
|
+
_collapse = _collapse.filter((it) => it === p.remove);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function NavBar({
|
|
19
|
+
Logo = undefined,
|
|
20
|
+
className = NavBar.global.className,
|
|
21
|
+
addClass = NavBar.global.addClass,
|
|
22
|
+
style = NavBar.global.style,
|
|
23
|
+
children,
|
|
24
|
+
}) {
|
|
25
|
+
const [compact, setCompact] = useState(isCompact());
|
|
26
|
+
const [itemsState, setItemsState] = useState('close');
|
|
27
|
+
const toggleMenu = () => {
|
|
28
|
+
setItemsState(itemsState === 'close' ? 'open' : 'close');
|
|
29
|
+
};
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const close = () => {
|
|
32
|
+
setItemsState('close');
|
|
33
|
+
};
|
|
34
|
+
collapse({ add: close });
|
|
35
|
+
|
|
36
|
+
return () => {
|
|
37
|
+
collapse({ remove: close });
|
|
38
|
+
};
|
|
39
|
+
}, []);
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
const resize = () => {
|
|
43
|
+
const current = isCompact();
|
|
44
|
+
if (current !== compact) {
|
|
45
|
+
setCompact(current);
|
|
46
|
+
setItemsState('close');
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const removeResizeScreen = onResizeScreen(resize);
|
|
50
|
+
resize();
|
|
51
|
+
return () => {
|
|
52
|
+
removeResizeScreen();
|
|
53
|
+
};
|
|
54
|
+
}, [compact]);
|
|
55
|
+
//console.log('children',children,Array.isArray(children));
|
|
56
|
+
let childs = Array.isArray(children)?children:[children];
|
|
57
|
+
return (
|
|
58
|
+
<div
|
|
59
|
+
it='navbar'
|
|
60
|
+
state={`${itemsState}`}
|
|
61
|
+
className={ `${className} ${addClass}`}
|
|
62
|
+
style={{ ...NavBar.global.style, ...style }}
|
|
63
|
+
>
|
|
64
|
+
<div it='nav-panel'>
|
|
65
|
+
<div it="nav-logo">{Logo && <Logo/>}</div>
|
|
66
|
+
<div it="nav-btn-close" className="wd-nav-btn" onClick={toggleMenu}>≡</div>
|
|
67
|
+
</div>
|
|
68
|
+
<div it={'nav-items'} className="wd-scrollbar">
|
|
69
|
+
{childs.map((it, key) => ((isNavItem(it.type) || isNavMenu(it.type)) ? it : <NavItem key={key}>{it}</NavItem>))}
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
NavBar.global = {
|
|
76
|
+
className: 'wd-navbar',
|
|
77
|
+
addClass: '',
|
|
78
|
+
style: {},
|
|
79
|
+
|
|
80
|
+
};
|
|
81
|
+
export default NavBar;
|
package/package.json
CHANGED