fmihel-windeco-components 2.0.0-beta.6 → 2.0.0-beta.60
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/copy-to +19 -3
- package/dev-bs/App.jsx +1 -1
- package/dev-bs/style/custom.scss +1 -1
- package/dist/windeco-components.js +2 -4
- package/dist/windeco-components.js.LICENSE.txt +3 -0
- package/jsx/Btn.jsx +9 -7
- package/jsx/BtnIcon.jsx +36 -15
- package/jsx/CheckBox.jsx +9 -8
- package/jsx/Collapse.jsx +2 -7
- package/jsx/ComboBox/ComboItem.jsx +5 -2
- package/jsx/ComboBox/ComboList.jsx +18 -12
- package/jsx/ComboBox.jsx +40 -14
- package/jsx/Container/Cols.jsx +11 -0
- package/jsx/Container/Row.jsx +18 -0
- package/jsx/Container.jsx +25 -5
- package/jsx/Edit.jsx +32 -29
- package/jsx/Gap/Gap.jsx +4 -6
- package/jsx/Group.jsx +8 -9
- package/jsx/Icon.jsx +6 -7
- package/jsx/Label.jsx +13 -11
- package/jsx/List/ListItem.jsx +5 -9
- package/jsx/List/ListNode.jsx +3 -25
- package/jsx/{List/List.jsx → List.jsx} +8 -22
- package/jsx/Modal.jsx +10 -5
- package/jsx/ModalDialog/Header.jsx +0 -0
- package/jsx/ModalDialog/ModalDialogAPI.js +15 -6
- package/jsx/ModalDialog.jsx +47 -28
- package/jsx/NavBar/NavItem.jsx +36 -25
- package/jsx/NavBar/NavLogo.jsx +5 -3
- package/jsx/NavBar.jsx +36 -60
- package/jsx/OnResize.jsx +126 -0
- package/jsx/StaticText.jsx +30 -0
- package/jsx/Table/TBody.jsx +13 -1
- package/jsx/Table/TD.jsx +41 -2
- package/jsx/Table/TH.jsx +12 -1
- package/jsx/Table/THead.jsx +4 -0
- package/jsx/Table/TR.jsx +40 -13
- package/jsx/Table.jsx +48 -27
- package/jsx/TableFixed/Data.jsx +35 -29
- package/jsx/TableFixed/Header.jsx +4 -0
- package/jsx/TableFixed/TD.jsx +27 -1
- package/jsx/TableFixed/TR.jsx +12 -2
- package/jsx/TableFixed/utils.js +1 -1
- package/jsx/TableFixed.jsx +49 -32
- package/jsx/Text.jsx +11 -12
- package/jsx/arch/NavBar/NavItem.jsx +45 -0
- package/jsx/arch/NavBar/NavLogo.jsx +23 -0
- package/jsx/{NavBar → arch/NavBar}/NavMenu.jsx +3 -3
- package/jsx/arch/NavBar.jsx +81 -0
- package/jsx/index.js +27 -18
- package/package.json +8 -7
- package/style/Btn.scss +36 -24
- package/style/BtnIcon.scss +51 -30
- package/style/CheckBox.scss +26 -33
- package/style/ComboBox.scss +70 -56
- package/style/Container.scss +3 -44
- package/style/Edit.scss +48 -33
- package/style/Gap.scss +10 -5
- package/style/Group.scss +51 -75
- package/style/Icon.scss +2 -3
- package/style/Label.scss +31 -14
- package/style/List.scss +22 -35
- package/style/Modal.scss +8 -4
- package/style/ModalDialog.scss +28 -30
- package/style/NavBar.scss +186 -194
- package/style/ScrollBar.scss +28 -42
- package/style/Table.scss +31 -33
- package/style/TableFixed.scss +21 -26
- package/style/Text.scss +1 -51
- package/style/arch/ComboBox.scss +1 -1
- package/style/arch/NavBar.scss +236 -0
- package/style/{utils.scss → arch/utils.scss} +27 -1
- package/style/{vars.scss → arch/vars.scss} +71 -87
- package/style/ctrls.scss +18 -18
- package/style/define/defineThemeVars.scss +3 -0
- package/style/define/get-var.scss +13 -0
- package/style/index.scss +3 -0
- package/style/readme.txt +1 -1
- package/style/theme-dark.scss +38 -0
- package/style/theme-default.scss +191 -0
- package/style/utils/font-family.scss +37 -0
- package/style/utils/getThemingRootClass.scss +3 -0
- package/style/utils/h.scss +34 -0
- package/style/utils/margin.scss +33 -0
- package/style/utils/no-border.scss +10 -0
- package/style/utils/padding.scss +33 -0
- package/style/utils/panel.scss +36 -0
- package/style/utils/screen.scss +139 -0
- package/style/utils/stretch.scss +3 -0
- package/style/utils/text-style.scss +32 -0
- package/style/utils/transition.scss +9 -0
- package/{jsx/Utils → utils}/abs.js +2 -2
- package/{jsx/Collapse → utils}/collapse.js +2 -2
- package/utils/css.js +56 -0
- package/utils/display.js +2 -0
- package/utils/get.js +24 -0
- package/{jsx/Utils → utils}/isCompact.js +1 -1
- package/utils/navbar.js +28 -0
- package/utils/parentDOM.js +21 -0
- package/utils/style.js +15 -0
- package/{jsx/Utils → utils}/theme.js +1 -1
- package/{jsx/Utils → utils}/timer.js +15 -10
- package/jsx/Container/Col.jsx +0 -24
- /package/style/{all.scss → arch/all.scss} +0 -0
- /package/{jsx/Utils → utils}/DOM.js +0 -0
- /package/{jsx/Utils → utils}/areaDOM.js +0 -0
- /package/{jsx/Utils → utils}/childDOM.js +0 -0
- /package/{jsx/Utils → utils}/filter.js +0 -0
- /package/{jsx/Utils → utils}/getId.js +0 -0
- /package/{jsx/Utils → utils}/isMobile.js +0 -0
- /package/{jsx/Utils → utils}/map.js +0 -0
- /package/{jsx/Utils → utils}/mouse.js +0 -0
- /package/{jsx/Utils → utils}/onResizeScreen.js +0 -0
- /package/{jsx/Utils → utils}/screen.js +0 -0
- /package/{jsx/Utils → utils}/size.js +0 -0
- /package/{jsx/Utils → utils}/throttle.js +0 -0
- /package/{jsx/Utils → utils}/translate.js +0 -0
package/jsx/NavBar.jsx
CHANGED
|
@@ -1,81 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import isCompact from './Utils/isCompact.js';
|
|
1
|
+
/* eslint-disable no-nested-ternary */
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import DefaultLogo from './NavBar/NavLogo.jsx';
|
|
4
|
+
import { navbars } from '../utils/navbar.js';
|
|
6
5
|
|
|
7
|
-
|
|
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
|
-
};
|
|
6
|
+
const definingCssClass = 'wd-navbar';
|
|
17
7
|
|
|
18
8
|
function NavBar({
|
|
19
|
-
|
|
9
|
+
id,
|
|
20
10
|
className = NavBar.global.className,
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
style = { ...NavBar.global.style },
|
|
12
|
+
Logo = undefined,
|
|
13
|
+
attr = {},
|
|
23
14
|
children,
|
|
24
15
|
}) {
|
|
25
|
-
const [
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
setItemsState(itemsState === 'close' ? 'open' : 'close');
|
|
29
|
-
};
|
|
16
|
+
const [collapse, setCollapse] = useState(true);
|
|
17
|
+
const childs = Array.isArray(children) ? children : [children];
|
|
18
|
+
const ref = useRef();
|
|
30
19
|
useEffect(() => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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];
|
|
20
|
+
if (id) {
|
|
21
|
+
navbars[`${id}`] = {
|
|
22
|
+
ref, setCollapse, collapse,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}, [ref]);
|
|
26
|
+
const navBtnClick = () => {
|
|
27
|
+
setCollapse(!collapse);
|
|
28
|
+
};
|
|
29
|
+
const typeLogo = typeof Logo;
|
|
57
30
|
return (
|
|
58
31
|
<div
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
className={ `${className} ${addClass}`}
|
|
32
|
+
{...id ? { id } : {}}
|
|
33
|
+
className={`${definingCssClass}${(className ? ` ${className}` : '')}`}
|
|
62
34
|
style={{ ...NavBar.global.style, ...style }}
|
|
35
|
+
ref = {ref}
|
|
36
|
+
{...attr}
|
|
63
37
|
>
|
|
64
|
-
<div
|
|
65
|
-
|
|
66
|
-
|
|
38
|
+
<div nav-panel="">
|
|
39
|
+
{typeLogo === 'string' && <DefaultLogo caption={Logo}/>}
|
|
40
|
+
{typeLogo !== 'string' && Logo && <Logo/>}
|
|
41
|
+
|
|
42
|
+
<div nav-empty=""></div>
|
|
43
|
+
<div nav-btn="" onClick={navBtnClick}>≡</div>
|
|
67
44
|
</div>
|
|
68
|
-
<div
|
|
69
|
-
{childs
|
|
45
|
+
<div nav-menu="" {...(!collapse ? { expand: '' } : {})}>
|
|
46
|
+
{childs}
|
|
70
47
|
</div>
|
|
71
48
|
</div>
|
|
72
49
|
);
|
|
73
50
|
}
|
|
74
51
|
|
|
75
52
|
NavBar.global = {
|
|
76
|
-
className: '
|
|
77
|
-
addClass: '',
|
|
53
|
+
className: '',
|
|
78
54
|
style: {},
|
|
79
|
-
|
|
80
55
|
};
|
|
56
|
+
|
|
81
57
|
export default NavBar;
|
package/jsx/OnResize.jsx
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
useEffect, useRef, useState, forwardRef,
|
|
3
|
+
} from 'react';
|
|
4
|
+
import abs from '../utils/abs';
|
|
5
|
+
|
|
6
|
+
function Debug({
|
|
7
|
+
className,
|
|
8
|
+
currentClass,
|
|
9
|
+
}) {
|
|
10
|
+
const [width, setWidth] = useState(false);
|
|
11
|
+
const [left, setLeft] = useState(0);
|
|
12
|
+
const [top, setTop] = useState(0);
|
|
13
|
+
|
|
14
|
+
const ref = useRef();
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const observ = new ResizeObserver(() => {
|
|
17
|
+
if (ref.current) {
|
|
18
|
+
const pos = abs(ref.current);
|
|
19
|
+
setTop(pos.y);
|
|
20
|
+
setLeft(pos.x);
|
|
21
|
+
setWidth(ref.current.clientWidth);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
observ.observe(ref.current);
|
|
25
|
+
return () => {
|
|
26
|
+
observ.disconnect();
|
|
27
|
+
};
|
|
28
|
+
}, [ref]);
|
|
29
|
+
const style = {
|
|
30
|
+
fontSize: '0.8rem',
|
|
31
|
+
color: 'white',
|
|
32
|
+
backgroundColor: '#993d3c',
|
|
33
|
+
};
|
|
34
|
+
return (
|
|
35
|
+
<>
|
|
36
|
+
<div
|
|
37
|
+
ref = {ref}
|
|
38
|
+
style={{
|
|
39
|
+
...style,
|
|
40
|
+
position: 'relative',
|
|
41
|
+
textAlign: 'center',
|
|
42
|
+
paddingTop: 3,
|
|
43
|
+
paddingBottom: 3,
|
|
44
|
+
borderRadius: 12,
|
|
45
|
+
|
|
46
|
+
}}>
|
|
47
|
+
w:{width} class:{` ${className} ${currentClass}`}
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<div
|
|
51
|
+
style={{
|
|
52
|
+
...style,
|
|
53
|
+
padding: 10,
|
|
54
|
+
left: 10,
|
|
55
|
+
top: 10,
|
|
56
|
+
position: 'absolute',
|
|
57
|
+
zIndex: 1000,
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
<div>w:{width}</div>
|
|
61
|
+
<div>class:{` ${className} ${currentClass}`}</div>
|
|
62
|
+
</div>
|
|
63
|
+
</>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
const OnResize = forwardRef(({
|
|
67
|
+
id = false,
|
|
68
|
+
className = '',
|
|
69
|
+
rules = [], // [{width,className}] [{width:0,className:'def1'},{width:100,className:'def2}] || (({width})=> { return 'className'} )
|
|
70
|
+
debug = false,
|
|
71
|
+
onResize = undefined,
|
|
72
|
+
children,
|
|
73
|
+
}, fRef) => {
|
|
74
|
+
const ref = fRef || useRef();
|
|
75
|
+
const [currentClass, setCurrentClass] = useState('');
|
|
76
|
+
const [opacity, setOpacity] = useState(0);
|
|
77
|
+
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const observ = new ResizeObserver(() => {
|
|
80
|
+
if (ref.current) {
|
|
81
|
+
const width = ref.current.clientWidth;
|
|
82
|
+
// setWidth(ref.current.clientWidth);
|
|
83
|
+
let findClass = false;
|
|
84
|
+
|
|
85
|
+
if (typeof rules === 'function') {
|
|
86
|
+
findClass = rules({ width });
|
|
87
|
+
} else {
|
|
88
|
+
for (let i = 0; i < rules.length; i++) {
|
|
89
|
+
const current = rules[i];
|
|
90
|
+
const next = i < rules.length - 1 ? rules[i + 1] : false;
|
|
91
|
+
if (current.width <= width && (!next || width < next.width)) {
|
|
92
|
+
findClass = current.className;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (findClass !== false) {
|
|
98
|
+
// console.log('currentClass', 'find', findClass);
|
|
99
|
+
setCurrentClass(findClass);
|
|
100
|
+
}
|
|
101
|
+
setOpacity(1);
|
|
102
|
+
if (onResize) {
|
|
103
|
+
onResize({ width });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
observ.observe(ref.current);
|
|
108
|
+
return () => {
|
|
109
|
+
observ.disconnect();
|
|
110
|
+
};
|
|
111
|
+
}, [ref, onResize]);
|
|
112
|
+
return (
|
|
113
|
+
<div
|
|
114
|
+
{...id ? { id } : {}}
|
|
115
|
+
ref = {ref}
|
|
116
|
+
{ ...(className || currentClass) ? { className: `${className} ${currentClass}` } : ''}
|
|
117
|
+
// {...debug ? { style: { border: '1px dashed #993d3c' } } : {}}
|
|
118
|
+
style={{ opacity, ...(debug ? { border: '1px dashed #993d3c' } : {}) } }
|
|
119
|
+
>
|
|
120
|
+
{debug ? <Debug currentClass={currentClass} className={className}/> : undefined}
|
|
121
|
+
{children}
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
export default OnResize;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
const definingCssClass = 'wd-static-text';
|
|
4
|
+
|
|
5
|
+
function StaticText({
|
|
6
|
+
value = '',
|
|
7
|
+
className = StaticText.global.className,
|
|
8
|
+
style = StaticText.global.className,
|
|
9
|
+
attr = {},
|
|
10
|
+
children,
|
|
11
|
+
}) {
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
className={`${definingCssClass}${(className ? ` ${className}` : '')}`}
|
|
15
|
+
style={{
|
|
16
|
+
...StaticText.global.style,
|
|
17
|
+
...style,
|
|
18
|
+
}}
|
|
19
|
+
{...attr}
|
|
20
|
+
>
|
|
21
|
+
{value || children}
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
StaticText.global = {
|
|
27
|
+
className: '',
|
|
28
|
+
style: {},
|
|
29
|
+
};
|
|
30
|
+
export default StaticText;
|
package/jsx/Table/TBody.jsx
CHANGED
|
@@ -5,23 +5,35 @@ function TBody({
|
|
|
5
5
|
data = [],
|
|
6
6
|
fields = [],
|
|
7
7
|
aliasId = 'ID',
|
|
8
|
+
aliasAttr = '-attr-',
|
|
9
|
+
aliasSep = '-sep-',
|
|
8
10
|
noData = 'no data',
|
|
9
11
|
footer = 'end',
|
|
10
12
|
select = [],
|
|
11
13
|
onClick,
|
|
14
|
+
onDoubleClick,
|
|
15
|
+
onMouseUp,
|
|
16
|
+
onDraw,
|
|
17
|
+
disableContextMenu,
|
|
12
18
|
}) {
|
|
13
19
|
const haveData = (Array.isArray(data) && data.length > 0);
|
|
14
20
|
|
|
15
21
|
return (
|
|
16
22
|
<tbody>
|
|
17
23
|
{(haveData) && data.map((row, i) => <TR
|
|
18
|
-
key = {
|
|
24
|
+
key = { aliasId in row ? row[aliasId] : i}
|
|
19
25
|
data = {data}
|
|
20
26
|
row={row}
|
|
21
27
|
fields={fields}
|
|
22
28
|
select={aliasId in row && select.findIndex((id) => `${id}` === `${row[aliasId]}`) > -1}
|
|
23
29
|
onClick={onClick}
|
|
30
|
+
onDoubleClick = {onDoubleClick}
|
|
31
|
+
onMouseUp={onMouseUp}
|
|
32
|
+
onDraw={onDraw}
|
|
24
33
|
aliasId = {aliasId}
|
|
34
|
+
aliasAttr = {aliasAttr}
|
|
35
|
+
aliasSep={ aliasSep }
|
|
36
|
+
disableContextMenu ={disableContextMenu}
|
|
25
37
|
/>)}
|
|
26
38
|
{(!haveData && noData !== false) && <tr><td nodata='' colSpan={fields.length}>{noData}</td></tr>}
|
|
27
39
|
{(haveData && footer !== false) && <tr><td footer='' colSpan={fields.length}>{footer}</td></tr>}
|
package/jsx/Table/TD.jsx
CHANGED
|
@@ -6,7 +6,13 @@ function TD({
|
|
|
6
6
|
fieldName,
|
|
7
7
|
value,
|
|
8
8
|
onClick,
|
|
9
|
+
onDoubleClick,
|
|
10
|
+
onMouseUp,
|
|
11
|
+
onDraw,
|
|
9
12
|
aliasId,
|
|
13
|
+
attrs,
|
|
14
|
+
width,
|
|
15
|
+
disableContextMenu,
|
|
10
16
|
}) {
|
|
11
17
|
const click = () => {
|
|
12
18
|
if (onClick) {
|
|
@@ -15,9 +21,42 @@ function TD({
|
|
|
15
21
|
});
|
|
16
22
|
}
|
|
17
23
|
};
|
|
24
|
+
const doubleClick = () => {
|
|
25
|
+
if (onDoubleClick) {
|
|
26
|
+
onDoubleClick({
|
|
27
|
+
col: fieldName, value, row, data, aliasId,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const mouseUp = (event) => {
|
|
32
|
+
if (onMouseUp) {
|
|
33
|
+
onMouseUp({
|
|
34
|
+
col: fieldName, value, row, data, aliasId, event,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const contextMenu = (e) => {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
return false;
|
|
41
|
+
};
|
|
18
42
|
return (
|
|
19
|
-
<td
|
|
20
|
-
{
|
|
43
|
+
<td
|
|
44
|
+
onClick={click}
|
|
45
|
+
onMouseUp = {mouseUp}
|
|
46
|
+
onDoubleClick= {doubleClick}
|
|
47
|
+
id={fieldName}
|
|
48
|
+
{...(attrs ? { ...attrs } : {})}
|
|
49
|
+
{...(width ? { style: { width } } : {})}
|
|
50
|
+
onContextMenu={disableContextMenu ? contextMenu : undefined}
|
|
51
|
+
>
|
|
52
|
+
{onDraw ? onDraw({
|
|
53
|
+
sender: 'td',
|
|
54
|
+
col: fieldName,
|
|
55
|
+
value,
|
|
56
|
+
row,
|
|
57
|
+
data,
|
|
58
|
+
aliasId,
|
|
59
|
+
}) : value}
|
|
21
60
|
</td>
|
|
22
61
|
);
|
|
23
62
|
}
|
package/jsx/Table/TH.jsx
CHANGED
|
@@ -4,7 +4,10 @@ function TH({
|
|
|
4
4
|
data = [],
|
|
5
5
|
fieldName,
|
|
6
6
|
caption,
|
|
7
|
+
title,
|
|
7
8
|
onClick,
|
|
9
|
+
attrs = false,
|
|
10
|
+
width = undefined,
|
|
8
11
|
}) {
|
|
9
12
|
const click = () => {
|
|
10
13
|
if (onClick) {
|
|
@@ -13,7 +16,15 @@ function TH({
|
|
|
13
16
|
});
|
|
14
17
|
}
|
|
15
18
|
};
|
|
16
|
-
return (<th
|
|
19
|
+
return (<th
|
|
20
|
+
id={fieldName}
|
|
21
|
+
onClick={click}
|
|
22
|
+
{...(title ? { title } : {})}
|
|
23
|
+
{...(attrs ? { ...attrs } : {})}
|
|
24
|
+
{...(width ? { style: { width } } : {})}
|
|
25
|
+
>
|
|
26
|
+
{caption}
|
|
27
|
+
</th>);
|
|
17
28
|
}
|
|
18
29
|
|
|
19
30
|
export default TH;
|
package/jsx/Table/THead.jsx
CHANGED
|
@@ -6,6 +6,7 @@ function THead({
|
|
|
6
6
|
fields = [],
|
|
7
7
|
header,
|
|
8
8
|
onClick,
|
|
9
|
+
aliasAttr = '',
|
|
9
10
|
}) {
|
|
10
11
|
return (
|
|
11
12
|
<thead>
|
|
@@ -16,7 +17,10 @@ function THead({
|
|
|
16
17
|
data = {data}
|
|
17
18
|
fieldName = {field.name}
|
|
18
19
|
caption = {field.caption}
|
|
20
|
+
title = {field.title}
|
|
19
21
|
onClick = {onClick}
|
|
22
|
+
attrs={{ ...(field[aliasAttr] ? { ...field[aliasAttr] } : {}) }}
|
|
23
|
+
width={field.width}
|
|
20
24
|
/>)}
|
|
21
25
|
|
|
22
26
|
{(typeof header === 'string')
|
package/jsx/Table/TR.jsx
CHANGED
|
@@ -6,23 +6,50 @@ function TR({
|
|
|
6
6
|
data = [],
|
|
7
7
|
fields = [],
|
|
8
8
|
onClick,
|
|
9
|
+
onDoubleClick,
|
|
10
|
+
onMouseUp,
|
|
11
|
+
onDraw,
|
|
9
12
|
select = false,
|
|
10
13
|
aliasId,
|
|
14
|
+
aliasAttr,
|
|
15
|
+
aliasSep,
|
|
16
|
+
disableContextMenu,
|
|
11
17
|
}) {
|
|
12
18
|
return (
|
|
13
|
-
|
|
14
|
-
{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
<>
|
|
20
|
+
{(aliasSep in row)
|
|
21
|
+
&& <tr
|
|
22
|
+
{...(aliasId in row ? { id: row[aliasId] } : {})}
|
|
23
|
+
{...row[aliasAttr]}
|
|
24
|
+
sep={''}
|
|
25
|
+
>
|
|
26
|
+
<td colSpan={fields.length}>{row[aliasSep]}</td>
|
|
27
|
+
</tr>
|
|
28
|
+
}
|
|
29
|
+
{!(aliasSep in row)
|
|
30
|
+
&& <tr
|
|
31
|
+
|
|
32
|
+
{...(aliasId in row ? { id: row[aliasId] } : {})}
|
|
33
|
+
{...(select ? { select: '' } : {})}
|
|
34
|
+
{...row[aliasAttr]}
|
|
35
|
+
>
|
|
36
|
+
{fields.map((field, i) => <TD
|
|
37
|
+
key = {field.name}
|
|
38
|
+
data = {data}
|
|
39
|
+
row = {row}
|
|
40
|
+
fieldName = {field.name}
|
|
41
|
+
value = {row[field.name]}
|
|
42
|
+
onClick = {onClick}
|
|
43
|
+
onDoubleClick={onDoubleClick}
|
|
44
|
+
onMouseUp = {onMouseUp}
|
|
45
|
+
onDraw = {onDraw}
|
|
46
|
+
aliasId = {aliasId}
|
|
47
|
+
attrs={{ ...(field[aliasAttr] ? { ...field[aliasAttr] } : {}) }}
|
|
48
|
+
width={field.width}
|
|
49
|
+
disableContextMenu ={disableContextMenu}
|
|
50
|
+
/>)}
|
|
51
|
+
</tr>}
|
|
52
|
+
</>
|
|
26
53
|
);
|
|
27
54
|
}
|
|
28
55
|
|
package/jsx/Table.jsx
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
import THead from './Table/THead.jsx';
|
|
3
3
|
import TBody from './Table/TBody.jsx';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export const definingCssClass = 'wd-table';
|
|
6
|
+
|
|
7
|
+
const Table = forwardRef(({
|
|
6
8
|
id,
|
|
7
9
|
className = Table.global.className,
|
|
8
10
|
aliasId = Table.global.aliasId,
|
|
11
|
+
aliasAttr = Table.global.aliasAttr,
|
|
12
|
+
aliasSep = Table.global.aliasSep,
|
|
9
13
|
data = [],
|
|
10
14
|
fields = [],
|
|
11
15
|
header = true, /// / string true false
|
|
@@ -14,35 +18,52 @@ function Table({
|
|
|
14
18
|
select = [],
|
|
15
19
|
style = { ...Table.global.style },
|
|
16
20
|
onClick = undefined,
|
|
21
|
+
onDoubleClick = undefined,
|
|
22
|
+
onMouseUp = undefined,
|
|
23
|
+
onDraw = undefined,
|
|
24
|
+
disableContextMenu = undefined,
|
|
25
|
+
attr = {},
|
|
26
|
+
|
|
27
|
+
}, fRef) => (
|
|
28
|
+
|
|
29
|
+
<table
|
|
30
|
+
ref = {fRef}
|
|
31
|
+
className={`${definingCssClass}${(className ? ` ${className}` : '')}`}
|
|
32
|
+
{...(id ? { id } : {})}
|
|
33
|
+
style={{ ...Table.global.style, ...style }}
|
|
34
|
+
{...attr}
|
|
35
|
+
>
|
|
36
|
+
{(header !== false)
|
|
37
|
+
&& <THead
|
|
38
|
+
fields={fields}
|
|
39
|
+
header={header}
|
|
40
|
+
aliasAttr={aliasAttr}
|
|
41
|
+
/>}
|
|
42
|
+
{<TBody
|
|
43
|
+
data={data}
|
|
44
|
+
fields={fields}
|
|
45
|
+
aliasId={aliasId}
|
|
46
|
+
aliasAttr={aliasAttr}
|
|
47
|
+
aliasSep={aliasSep}
|
|
48
|
+
noData={noData}
|
|
49
|
+
footer = {footer}
|
|
50
|
+
select={select}
|
|
51
|
+
onClick = {onClick}
|
|
52
|
+
onDoubleClick = {onDoubleClick}
|
|
53
|
+
onMouseUp = {onMouseUp}
|
|
54
|
+
onDraw = {onDraw}
|
|
55
|
+
disableContextMenu ={disableContextMenu}
|
|
56
|
+
/>}
|
|
57
|
+
|
|
58
|
+
</table>
|
|
17
59
|
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
|
|
21
|
-
<table
|
|
22
|
-
type="table"
|
|
23
|
-
{...(className ? { className } : {})}
|
|
24
|
-
{...(id ? { id } : {})}
|
|
25
|
-
style={{ ...Table.global.style, ...style }}
|
|
26
|
-
>
|
|
27
|
-
{(header !== false) && <THead fields={fields} header={header}/>}
|
|
28
|
-
{<TBody
|
|
29
|
-
data={data}
|
|
30
|
-
fields={fields}
|
|
31
|
-
aliasId={aliasId}
|
|
32
|
-
noData={noData}
|
|
33
|
-
footer = {footer}
|
|
34
|
-
select={select}
|
|
35
|
-
onClick = {onClick}
|
|
36
|
-
/>}
|
|
37
|
-
|
|
38
|
-
</table>
|
|
39
|
-
|
|
40
|
-
);
|
|
41
|
-
}
|
|
60
|
+
));
|
|
42
61
|
|
|
43
62
|
Table.global = {
|
|
44
|
-
className: '
|
|
63
|
+
className: '',
|
|
45
64
|
aliasId: 'ID',
|
|
65
|
+
aliasAttr: '-attr-',
|
|
66
|
+
aliasSep: '-sep-',
|
|
46
67
|
header: true, // string true false
|
|
47
68
|
noData: 'no data', // string or false
|
|
48
69
|
footer: 'end', // string ot false
|
package/jsx/TableFixed/Data.jsx
CHANGED
|
@@ -1,42 +1,48 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
import TR from './TR.jsx';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const Data = forwardRef(({
|
|
5
5
|
id,
|
|
6
6
|
data = [],
|
|
7
7
|
aliasId,
|
|
8
|
+
aliasAttr,
|
|
8
9
|
fields,
|
|
9
10
|
style = {},
|
|
10
11
|
footer = false,
|
|
11
12
|
select = [],
|
|
12
13
|
onClick = undefined,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
14
|
+
onDoubleClick = undefined,
|
|
15
|
+
onDraw = undefined,
|
|
16
|
+
|
|
17
|
+
}, ref) => (
|
|
18
|
+
<>
|
|
19
|
+
<table
|
|
20
|
+
id={`table-${id}`}
|
|
21
|
+
style={{ ...style }}
|
|
22
|
+
data=''
|
|
23
|
+
ref = {ref}
|
|
24
|
+
>
|
|
25
|
+
<tbody>
|
|
26
|
+
{data.map((row) => (
|
|
27
|
+
<TR
|
|
28
|
+
key = {row[aliasId]}
|
|
29
|
+
row = {row}
|
|
30
|
+
data={data}
|
|
31
|
+
fields = {fields}
|
|
32
|
+
aliasId={aliasId}
|
|
33
|
+
aliasAttr={aliasAttr}
|
|
34
|
+
select={(select.findIndex((ID) => row[aliasId] == ID) >= 0)}
|
|
35
|
+
onClick={onClick}
|
|
36
|
+
onDoubleClick={onDoubleClick}
|
|
37
|
+
onDraw={onDraw}
|
|
38
|
+
/>
|
|
39
|
+
))}
|
|
40
|
+
</tbody>
|
|
41
|
+
</table>
|
|
42
|
+
{(footer)
|
|
36
43
|
&& <div footer="true">{footer}</div>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
44
|
+
}
|
|
45
|
+
</>
|
|
46
|
+
));
|
|
41
47
|
|
|
42
48
|
export default Data;
|
|
@@ -6,6 +6,7 @@ function Header({
|
|
|
6
6
|
caption,
|
|
7
7
|
fields,
|
|
8
8
|
widths,
|
|
9
|
+
aliasAttr,
|
|
9
10
|
|
|
10
11
|
}) {
|
|
11
12
|
return (
|
|
@@ -18,9 +19,12 @@ function Header({
|
|
|
18
19
|
{(type === 'fields') && fields.map((field, i) => (
|
|
19
20
|
<th
|
|
20
21
|
key={field.name}
|
|
22
|
+
id={field.name}
|
|
21
23
|
style={{
|
|
22
24
|
...(i < widths.length ? { width: widths[i], maxWidth: widths[i] } : {}),
|
|
23
25
|
}}
|
|
26
|
+
{...(field.title ? { title: field.title } : {})}
|
|
27
|
+
{ ...(field[aliasAttr] ? { ...field[aliasAttr] } : {}) }
|
|
24
28
|
>
|
|
25
29
|
{field.caption}
|
|
26
30
|
</th>))
|