@oliasoft-open-source/react-ui-library 2.3.5 → 2.4.1
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 +2 -1
- package/src/components/drawer/drawer-resize-wrapper.jsx +73 -0
- package/src/components/drawer/drawer-tabs.jsx +1 -0
- package/src/components/drawer/drawer.jsx +58 -47
- package/src/components/drawer/drawer.module.less +54 -11
- package/src/components/drawer/drawer.stories.jsx +141 -1
- package/src/components/layout/flex/flex.stories.jsx +6 -1
- package/src/components/layout/grid/grid.stories.jsx +10 -8
- package/src/components/table/cell/cell.jsx +20 -17
- package/src/components/table/cell/cell.module.less +33 -19
- package/src/components/table/table.stories-data.jsx +92 -0
- package/src/components/table/table.stories.jsx +2 -85
- package/src/components/table/table.variables.less +0 -8
- package/src/style/mixins.less +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oliasoft-open-source/react-ui-library",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "Reusable UI components for React projects",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -126,6 +126,7 @@
|
|
|
126
126
|
"react-icons": "^4.2.0",
|
|
127
127
|
"react-infinite-scroll-component": "^6.1.0",
|
|
128
128
|
"react-laag": "^2.0.3",
|
|
129
|
+
"react-resizable": "^3.0.4",
|
|
129
130
|
"react-router-dom": "^5.3.0",
|
|
130
131
|
"react-svg": "^14.0.12",
|
|
131
132
|
"react-toastify": "^8.0.2",
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Resizable } from 'react-resizable';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import styles from './drawer.module.less';
|
|
5
|
+
|
|
6
|
+
const ResizeHandle = React.forwardRef((props, ref) => {
|
|
7
|
+
const { handleAxis, ...rest } = props;
|
|
8
|
+
return (
|
|
9
|
+
<div
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={styles.resizeHandle}
|
|
12
|
+
{...rest} // eslint-disable-line react/jsx-props-no-spreading
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const DrawerResizeWrapper = ({
|
|
18
|
+
children,
|
|
19
|
+
width,
|
|
20
|
+
minWidth,
|
|
21
|
+
right,
|
|
22
|
+
onResize,
|
|
23
|
+
open,
|
|
24
|
+
}) => {
|
|
25
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
26
|
+
const MINIMUM_OPEN_WIDTH = 100;
|
|
27
|
+
const MAXIMUM_OPEN_WIDTH = window.innerWidth / 2;
|
|
28
|
+
|
|
29
|
+
const handleResize = (event, { node, size, handle }) => {
|
|
30
|
+
if (
|
|
31
|
+
open &&
|
|
32
|
+
size.width > MINIMUM_OPEN_WIDTH &&
|
|
33
|
+
size.width < MAXIMUM_OPEN_WIDTH
|
|
34
|
+
) {
|
|
35
|
+
onResize(size.width);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return onResize ? (
|
|
40
|
+
<Resizable
|
|
41
|
+
width={width}
|
|
42
|
+
height={100} // Arbitrary height value. It's required by react-resizable even if height not adjustable but doesn't actually do anything in this case
|
|
43
|
+
minConstraints={[minWidth, null]}
|
|
44
|
+
onResize={handleResize}
|
|
45
|
+
handle={open ? <ResizeHandle /> : null}
|
|
46
|
+
resizeHandles={right ? ['w'] : ['e']}
|
|
47
|
+
axis="x"
|
|
48
|
+
className={isResizing ? styles.isResizing : ''}
|
|
49
|
+
onResizeStart={() => setIsResizing(true)}
|
|
50
|
+
onResizeStop={() => setIsResizing(false)}
|
|
51
|
+
>
|
|
52
|
+
{children}
|
|
53
|
+
</Resizable>
|
|
54
|
+
) : (
|
|
55
|
+
<>{children}</>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
DrawerResizeWrapper.defaultProps = {
|
|
60
|
+
right: false,
|
|
61
|
+
width: 400,
|
|
62
|
+
minWidth: null,
|
|
63
|
+
children: null,
|
|
64
|
+
onResize: null,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
DrawerResizeWrapper.propTypes = {
|
|
68
|
+
right: PropTypes.bool,
|
|
69
|
+
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
70
|
+
minWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
71
|
+
children: PropTypes.node,
|
|
72
|
+
onResize: PropTypes.func,
|
|
73
|
+
};
|
|
@@ -5,6 +5,7 @@ import { FaChevronLeft, FaChevronRight } from 'react-icons/fa';
|
|
|
5
5
|
import { Button } from '../button/button';
|
|
6
6
|
import { DrawerTabs } from './drawer-tabs';
|
|
7
7
|
import styles from './drawer.module.less';
|
|
8
|
+
import { DrawerResizeWrapper } from './drawer-resize-wrapper';
|
|
8
9
|
|
|
9
10
|
export const Drawer = ({
|
|
10
11
|
background,
|
|
@@ -23,6 +24,7 @@ export const Drawer = ({
|
|
|
23
24
|
tabs,
|
|
24
25
|
defaultTabIndex,
|
|
25
26
|
testId,
|
|
27
|
+
onResize,
|
|
26
28
|
}) => {
|
|
27
29
|
const isStandardButton = button === true;
|
|
28
30
|
const isCustomButton = !isStandardButton && isValidElement(button);
|
|
@@ -30,7 +32,8 @@ export const Drawer = ({
|
|
|
30
32
|
isStandardButton || tabs ? useState(openProp) : [openProp, null];
|
|
31
33
|
const [activeTab, setActiveTab] = useState(open ? defaultTabIndex : null);
|
|
32
34
|
const openWidth = Array.isArray(width) ? width[activeTab] : width;
|
|
33
|
-
const
|
|
35
|
+
const TABS_WIDTH = 38;
|
|
36
|
+
const currentWidth = open ? openWidth : tabs ? TABS_WIDTH : closedWidth;
|
|
34
37
|
|
|
35
38
|
const handleTabClick = (index) => {
|
|
36
39
|
if (activeTab === index) {
|
|
@@ -43,58 +46,64 @@ export const Drawer = ({
|
|
|
43
46
|
};
|
|
44
47
|
|
|
45
48
|
return (
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
)}
|
|
53
|
-
style={{
|
|
54
|
-
top,
|
|
55
|
-
}}
|
|
49
|
+
<DrawerResizeWrapper
|
|
50
|
+
width={currentWidth}
|
|
51
|
+
minWidth={tabs ? TABS_WIDTH : closedWidth}
|
|
52
|
+
onResize={onResize}
|
|
53
|
+
open={open}
|
|
54
|
+
right={right}
|
|
56
55
|
>
|
|
57
56
|
<div
|
|
58
|
-
className={cx(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
width={openWidth}
|
|
64
|
-
testId={testId}
|
|
65
|
-
open={open}
|
|
66
|
-
tabs={tabs}
|
|
67
|
-
activeTab={activeTab}
|
|
68
|
-
background={background}
|
|
69
|
-
handleTabClick={handleTabClick}
|
|
70
|
-
/>
|
|
71
|
-
) : (
|
|
72
|
-
<div style={{ width: openWidth }}>{children}</div>
|
|
57
|
+
className={cx(
|
|
58
|
+
styles.drawer,
|
|
59
|
+
shadow ? styles.shadow : '',
|
|
60
|
+
fixed ? styles.fixed : styles.inline,
|
|
61
|
+
right ? styles.right : styles.left,
|
|
73
62
|
)}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
styles.toggleButton,
|
|
80
|
-
open && (isStandardButton || (isCustomButton && buttonAnimate))
|
|
81
|
-
? styles.toggleButtonOpen
|
|
82
|
-
: '',
|
|
83
|
-
buttonPosition === 'top' ? styles.top : styles.bottom,
|
|
84
|
-
)}
|
|
63
|
+
style={{ top }}
|
|
64
|
+
>
|
|
65
|
+
<div
|
|
66
|
+
className={cx(styles.drawerContent, border && styles.border)}
|
|
67
|
+
style={{ background, borderColor: border, width: currentWidth }}
|
|
85
68
|
>
|
|
86
|
-
{
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
69
|
+
{tabs ? (
|
|
70
|
+
<DrawerTabs
|
|
71
|
+
width={openWidth}
|
|
72
|
+
testId={testId}
|
|
73
|
+
open={open}
|
|
74
|
+
tabs={tabs}
|
|
75
|
+
activeTab={activeTab}
|
|
76
|
+
background={background}
|
|
77
|
+
handleTabClick={handleTabClick}
|
|
93
78
|
/>
|
|
79
|
+
) : (
|
|
80
|
+
<div style={{ width: openWidth }}>{children}</div>
|
|
94
81
|
)}
|
|
95
|
-
</
|
|
96
|
-
|
|
97
|
-
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
{button && (
|
|
85
|
+
<span
|
|
86
|
+
className={cx(
|
|
87
|
+
styles.toggleButton,
|
|
88
|
+
open && (isStandardButton || (isCustomButton && buttonAnimate))
|
|
89
|
+
? styles.toggleButtonOpen
|
|
90
|
+
: '',
|
|
91
|
+
buttonPosition === 'top' ? styles.top : styles.bottom,
|
|
92
|
+
)}
|
|
93
|
+
>
|
|
94
|
+
{isCustomButton ? (
|
|
95
|
+
button
|
|
96
|
+
) : (
|
|
97
|
+
<Button
|
|
98
|
+
onClick={setOpen ? () => setOpen(!open) : null}
|
|
99
|
+
round
|
|
100
|
+
icon={right ? <FaChevronRight /> : <FaChevronLeft />}
|
|
101
|
+
/>
|
|
102
|
+
)}
|
|
103
|
+
</span>
|
|
104
|
+
)}
|
|
105
|
+
</div>
|
|
106
|
+
</DrawerResizeWrapper>
|
|
98
107
|
);
|
|
99
108
|
};
|
|
100
109
|
|
|
@@ -115,6 +124,7 @@ Drawer.defaultProps = {
|
|
|
115
124
|
tabs: null,
|
|
116
125
|
defaultTabIndex: 0,
|
|
117
126
|
testId: undefined,
|
|
127
|
+
onResize: null,
|
|
118
128
|
};
|
|
119
129
|
|
|
120
130
|
Drawer.propTypes = {
|
|
@@ -147,4 +157,5 @@ Drawer.propTypes = {
|
|
|
147
157
|
),
|
|
148
158
|
testId: PropTypes.string,
|
|
149
159
|
defaultTabIndex: PropTypes.number,
|
|
160
|
+
onResize: PropTypes.func,
|
|
150
161
|
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
@import '../../style/variables.less';
|
|
2
2
|
|
|
3
3
|
:root {
|
|
4
|
+
--color-background-drawer-tabs: var(--color-neutral-100);
|
|
4
5
|
--color-background-drawer-tab: #fff9f4;
|
|
5
6
|
--color-background-drawer-tab-hover: white;
|
|
6
7
|
--color-border-drawer-tab: #e4cbb7;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
html[data-theme='dark'] {
|
|
11
|
+
--color-background-drawer-tabs: var(--color-neutral-900);
|
|
10
12
|
--color-background-drawer-tab: var(--color-primary-muted-800);
|
|
11
13
|
--color-background-drawer-tab-hover: var(--color-primary-muted-700);
|
|
12
14
|
--color-border-drawer-tab: var(--color-border);
|
|
@@ -17,10 +19,12 @@ html[data-theme='dark'] {
|
|
|
17
19
|
|
|
18
20
|
&.left {
|
|
19
21
|
order: -1;
|
|
22
|
+
margin-left: -1px;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
&.right {
|
|
23
26
|
order: 9999;
|
|
27
|
+
margin-right: -1px;
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
|
|
@@ -58,9 +62,12 @@ html[data-theme='dark'] {
|
|
|
58
62
|
overflow-y: auto;
|
|
59
63
|
max-height: 100%;
|
|
60
64
|
min-height: 100%;
|
|
61
|
-
|
|
62
65
|
transition: width 0.2s;
|
|
63
66
|
|
|
67
|
+
.isResizing & {
|
|
68
|
+
transition: none;
|
|
69
|
+
}
|
|
70
|
+
|
|
64
71
|
@media print {
|
|
65
72
|
background: transparent !important;
|
|
66
73
|
}
|
|
@@ -81,7 +88,7 @@ html[data-theme='dark'] {
|
|
|
81
88
|
display: inline-block;
|
|
82
89
|
transform: rotate(180deg);
|
|
83
90
|
position: absolute;
|
|
84
|
-
z-index:
|
|
91
|
+
z-index: @zindex_drawer + 3;
|
|
85
92
|
|
|
86
93
|
.left & {
|
|
87
94
|
right: -19px;
|
|
@@ -106,28 +113,30 @@ html[data-theme='dark'] {
|
|
|
106
113
|
|
|
107
114
|
.tabs {
|
|
108
115
|
position: absolute;
|
|
109
|
-
top:
|
|
116
|
+
top: 0;
|
|
117
|
+
bottom: 0;
|
|
118
|
+
background-color: var(--color-background-drawer-tabs);
|
|
119
|
+
padding-top: 20px;
|
|
110
120
|
z-index: @zindex_drawer + 1;
|
|
121
|
+
border-left: 1px solid var(--color-border);
|
|
122
|
+
border-right: 1px solid var(--color-border);
|
|
111
123
|
|
|
112
124
|
.left & {
|
|
113
|
-
|
|
114
|
-
margin-left: -1px;
|
|
125
|
+
right: 0;
|
|
115
126
|
}
|
|
116
127
|
|
|
117
128
|
.right & {
|
|
118
|
-
|
|
119
|
-
margin-right: -1px;
|
|
129
|
+
left: 0;
|
|
120
130
|
}
|
|
121
131
|
|
|
122
132
|
.tab {
|
|
123
|
-
height:
|
|
124
|
-
width:
|
|
133
|
+
height: 38px;
|
|
134
|
+
width: 38px;
|
|
125
135
|
display: flex;
|
|
126
136
|
justify-content: center;
|
|
127
137
|
align-items: center;
|
|
128
|
-
margin-bottom: 1px;
|
|
129
|
-
border-radius: 4px;
|
|
130
138
|
cursor: pointer;
|
|
139
|
+
margin: -1px;
|
|
131
140
|
transition: color 0.3s, background-color 0.3s;
|
|
132
141
|
border: 1px solid var(--color-border-drawer-tab);
|
|
133
142
|
|
|
@@ -165,3 +174,37 @@ html[data-theme='dark'] {
|
|
|
165
174
|
}
|
|
166
175
|
}
|
|
167
176
|
}
|
|
177
|
+
|
|
178
|
+
.tabsContent {
|
|
179
|
+
.left & {
|
|
180
|
+
padding-right: 36px;
|
|
181
|
+
}
|
|
182
|
+
.right & {
|
|
183
|
+
padding-left: 36px;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.resizeHandle {
|
|
188
|
+
position: absolute;
|
|
189
|
+
top: 0;
|
|
190
|
+
bottom: 0;
|
|
191
|
+
width: 4px;
|
|
192
|
+
z-index: @zindex_drawer + 2;
|
|
193
|
+
cursor: ew-resize;
|
|
194
|
+
|
|
195
|
+
&:hover {
|
|
196
|
+
background: rgba(@colorPrimary, 0.25);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
&:active {
|
|
200
|
+
background: @colorPrimary;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.left & {
|
|
204
|
+
right: 0;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.right & {
|
|
208
|
+
left: 0;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
FaCogs,
|
|
6
6
|
FaPenAlt,
|
|
7
7
|
FaQuestion,
|
|
8
|
+
FaTrash,
|
|
9
|
+
FaPlus,
|
|
8
10
|
} from 'react-icons/fa';
|
|
9
11
|
import { Drawer, Button, List, Heading, Flex } from '../../..';
|
|
10
12
|
import { listSubheadingsBadges } from '../list/list.stories-data';
|
|
@@ -29,7 +31,7 @@ export default {
|
|
|
29
31
|
},
|
|
30
32
|
decorators: [
|
|
31
33
|
(story) => (
|
|
32
|
-
<Flex height="400px">
|
|
34
|
+
<Flex height="400px" wrap={false}>
|
|
33
35
|
<div
|
|
34
36
|
style={{
|
|
35
37
|
flexGrow: 1,
|
|
@@ -154,3 +156,141 @@ Tabs.parameters = {
|
|
|
154
156
|
},
|
|
155
157
|
},
|
|
156
158
|
};
|
|
159
|
+
|
|
160
|
+
export const MultipleTabbedDrawers = () => {
|
|
161
|
+
const tabs1 = [
|
|
162
|
+
{
|
|
163
|
+
icon: <FaQuestion />,
|
|
164
|
+
content: (
|
|
165
|
+
<div style={{ padding: 20 }}>
|
|
166
|
+
<Heading top>Help</Heading>
|
|
167
|
+
{'Example content goes here lorem ipsum. '.repeat(500)}
|
|
168
|
+
</div>
|
|
169
|
+
),
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
icon: <FaCogs />,
|
|
173
|
+
content: (
|
|
174
|
+
<div style={{ padding: 20 }}>
|
|
175
|
+
<Heading top>Settings</Heading>
|
|
176
|
+
{'Example content goes here lorem ipsum. '.repeat(500)}
|
|
177
|
+
</div>
|
|
178
|
+
),
|
|
179
|
+
},
|
|
180
|
+
];
|
|
181
|
+
const tabs2 = [
|
|
182
|
+
{
|
|
183
|
+
icon: <FaPenAlt />,
|
|
184
|
+
content: (
|
|
185
|
+
<div style={{ padding: 20 }}>
|
|
186
|
+
<Heading top>Edit</Heading>
|
|
187
|
+
{'Example content goes here lorem ipsum. '.repeat(500)}
|
|
188
|
+
</div>
|
|
189
|
+
),
|
|
190
|
+
},
|
|
191
|
+
];
|
|
192
|
+
return (
|
|
193
|
+
<>
|
|
194
|
+
<Drawer
|
|
195
|
+
right
|
|
196
|
+
background="var(--color-background-raised)"
|
|
197
|
+
tabs={tabs1}
|
|
198
|
+
border
|
|
199
|
+
open
|
|
200
|
+
/>
|
|
201
|
+
<Drawer
|
|
202
|
+
right
|
|
203
|
+
background="var(--color-background-raised)"
|
|
204
|
+
tabs={tabs2}
|
|
205
|
+
border
|
|
206
|
+
open
|
|
207
|
+
/>
|
|
208
|
+
</>
|
|
209
|
+
);
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export const Resizable = () => {
|
|
213
|
+
const [open, setOpen] = useState(true);
|
|
214
|
+
const [listDrawerWidth, setListDrawerWidth] = useState(300);
|
|
215
|
+
const [tabbedDrawerWidth, setTabbedDrawerWidth] = useState(300);
|
|
216
|
+
const tabs = [
|
|
217
|
+
{
|
|
218
|
+
icon: <FaQuestion />,
|
|
219
|
+
content: (
|
|
220
|
+
<div style={{ padding: 20 }}>
|
|
221
|
+
<Heading top>Help</Heading>
|
|
222
|
+
{'Example content goes here lorem ipsum. '.repeat(500)}
|
|
223
|
+
</div>
|
|
224
|
+
),
|
|
225
|
+
},
|
|
226
|
+
];
|
|
227
|
+
return (
|
|
228
|
+
<>
|
|
229
|
+
<Drawer
|
|
230
|
+
button={
|
|
231
|
+
<Button
|
|
232
|
+
onClick={setOpen ? () => setOpen(!open) : null}
|
|
233
|
+
round
|
|
234
|
+
icon={<FaChevronLeft />}
|
|
235
|
+
/>
|
|
236
|
+
}
|
|
237
|
+
open={open}
|
|
238
|
+
background="var(--color-background-raised)"
|
|
239
|
+
border
|
|
240
|
+
width={listDrawerWidth}
|
|
241
|
+
closedWidth={50}
|
|
242
|
+
onResize={(newWidth) => setListDrawerWidth(newWidth)}
|
|
243
|
+
>
|
|
244
|
+
<List
|
|
245
|
+
drawer
|
|
246
|
+
list={{
|
|
247
|
+
name: 'Animals',
|
|
248
|
+
actions: [
|
|
249
|
+
{
|
|
250
|
+
label: 'Add',
|
|
251
|
+
icon: <FaPlus />,
|
|
252
|
+
onClick: () => {},
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
items: [
|
|
256
|
+
{
|
|
257
|
+
id: 1,
|
|
258
|
+
name: 'Aardvark',
|
|
259
|
+
onClick: () => {},
|
|
260
|
+
actions: [
|
|
261
|
+
{
|
|
262
|
+
label: 'Delete',
|
|
263
|
+
icon: <FaTrash />,
|
|
264
|
+
onClick: () => {},
|
|
265
|
+
},
|
|
266
|
+
],
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
id: 2,
|
|
270
|
+
name: 'Kangaroo',
|
|
271
|
+
active: true,
|
|
272
|
+
actions: [
|
|
273
|
+
{
|
|
274
|
+
label: 'Delete',
|
|
275
|
+
icon: <FaTrash />,
|
|
276
|
+
onClick: () => {},
|
|
277
|
+
},
|
|
278
|
+
],
|
|
279
|
+
},
|
|
280
|
+
],
|
|
281
|
+
}}
|
|
282
|
+
narrow={!open}
|
|
283
|
+
/>
|
|
284
|
+
</Drawer>
|
|
285
|
+
<Drawer
|
|
286
|
+
right
|
|
287
|
+
background="var(--color-background-raised)"
|
|
288
|
+
tabs={tabs}
|
|
289
|
+
border
|
|
290
|
+
open
|
|
291
|
+
width={tabbedDrawerWidth}
|
|
292
|
+
onResize={(newWidth) => setTabbedDrawerWidth(newWidth)}
|
|
293
|
+
/>
|
|
294
|
+
</>
|
|
295
|
+
);
|
|
296
|
+
};
|
|
@@ -21,14 +21,16 @@ export default {
|
|
|
21
21
|
},
|
|
22
22
|
args: {
|
|
23
23
|
columns: '1fr 1fr 1fr',
|
|
24
|
-
children:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
children: (
|
|
25
|
+
<>
|
|
26
|
+
<Card>Item 1</Card>
|
|
27
|
+
<Card>Item 2</Card>
|
|
28
|
+
<Card>Item 3</Card>
|
|
29
|
+
<Card>Item 4</Card>
|
|
30
|
+
<Card>Item 5</Card>
|
|
31
|
+
<Card>Item 6</Card>
|
|
32
|
+
</>
|
|
33
|
+
),
|
|
32
34
|
},
|
|
33
35
|
};
|
|
34
36
|
|
|
@@ -227,7 +227,7 @@ const StaticCell = (props) => {
|
|
|
227
227
|
const field = (
|
|
228
228
|
<div
|
|
229
229
|
className={cx(
|
|
230
|
-
styles.
|
|
230
|
+
styles.staticCellContent,
|
|
231
231
|
type === 'Unit' ? styles.unit : '',
|
|
232
232
|
error ? styles.error : warning ? styles.warning : '',
|
|
233
233
|
)}
|
|
@@ -245,22 +245,24 @@ const StaticCell = (props) => {
|
|
|
245
245
|
</div>
|
|
246
246
|
);
|
|
247
247
|
return (
|
|
248
|
-
<
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
248
|
+
<div className={styles.inputWrapper}>
|
|
249
|
+
<Tooltip
|
|
250
|
+
error={!!error}
|
|
251
|
+
warning={!!warning}
|
|
252
|
+
text={tooltip || error || warning}
|
|
253
|
+
enabled={
|
|
254
|
+
(tooltip && isStringNumberOrNode(tooltip)) ||
|
|
255
|
+
(error && isStringNumberOrNode(error)) ||
|
|
256
|
+
(warning && isStringNumberOrNode(warning)) ||
|
|
257
|
+
false
|
|
258
|
+
}
|
|
259
|
+
maxWidth={maxTooltipWidth}
|
|
260
|
+
display="block"
|
|
261
|
+
placement="bottom-center"
|
|
262
|
+
>
|
|
263
|
+
{field}
|
|
264
|
+
</Tooltip>
|
|
265
|
+
</div>
|
|
264
266
|
);
|
|
265
267
|
};
|
|
266
268
|
|
|
@@ -364,6 +366,7 @@ export const Cell = (props) => {
|
|
|
364
366
|
cell.type === 'CheckBox' ? styles.checkBoxCell : '',
|
|
365
367
|
cell.type === 'Actions' ? styles.actionsCell : '',
|
|
366
368
|
cell.type === 'Icon' ? styles.iconCell : '',
|
|
369
|
+
cell.type === 'Static' || !cell.type ? styles.staticCell : '',
|
|
367
370
|
cell.hasSort ? styles.sortingCell : null,
|
|
368
371
|
cellAlignmentStyle,
|
|
369
372
|
cell.breakWord ? styles.breakWord : '',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
@import '../../../style/variables.less';
|
|
2
|
+
@import '../../../style/mixins.less';
|
|
2
3
|
@import '../table.variables.less';
|
|
3
4
|
|
|
4
5
|
.cellWrapper {
|
|
@@ -55,30 +56,43 @@
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
.staticCell {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
border:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
59
|
+
padding: 0 !important;
|
|
60
|
+
|
|
61
|
+
.staticCellContent {
|
|
62
|
+
min-height: 100%;
|
|
63
|
+
.cellWrapperPadding();
|
|
64
|
+
line-height: 17px;
|
|
65
|
+
position: relative;
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
border-radius: inherit;
|
|
69
|
+
|
|
70
|
+
&.error,
|
|
71
|
+
&.warning {
|
|
72
|
+
border: 1px solid transparent;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&.error {
|
|
76
|
+
.inputError();
|
|
77
|
+
}
|
|
78
|
+
&.warning {
|
|
79
|
+
.inputWarning();
|
|
80
|
+
}
|
|
81
|
+
&.unit {
|
|
82
|
+
font-weight: normal;
|
|
83
|
+
}
|
|
72
84
|
}
|
|
73
85
|
}
|
|
74
86
|
|
|
75
87
|
.sortingCell {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
88
|
+
.staticCellContent {
|
|
89
|
+
position: relative;
|
|
90
|
+
padding-right: 45px !important;
|
|
91
|
+
cursor: pointer !important;
|
|
79
92
|
|
|
80
|
-
|
|
81
|
-
|
|
93
|
+
&:hover {
|
|
94
|
+
background-color: rgba(0, 0, 0, 0.05) !important;
|
|
95
|
+
}
|
|
82
96
|
}
|
|
83
97
|
|
|
84
98
|
.sortingCellIcon {
|
|
@@ -764,3 +764,95 @@ export const tableHelpLibraryIcons = {
|
|
|
764
764
|
})),
|
|
765
765
|
})),
|
|
766
766
|
};
|
|
767
|
+
|
|
768
|
+
export const tableOverflowing = {
|
|
769
|
+
columnWidths: [undefined, '100px', '100px', '100px', undefined],
|
|
770
|
+
headers: [
|
|
771
|
+
{
|
|
772
|
+
cells: [
|
|
773
|
+
{ value: 'Name' },
|
|
774
|
+
{ value: 'Weight (kg)' },
|
|
775
|
+
{ value: 'Energy (kcal / 100g)' },
|
|
776
|
+
{ value: 'Origin' },
|
|
777
|
+
{ value: 'Static' },
|
|
778
|
+
],
|
|
779
|
+
},
|
|
780
|
+
],
|
|
781
|
+
rows: [
|
|
782
|
+
{
|
|
783
|
+
cells: [
|
|
784
|
+
{
|
|
785
|
+
breakWord: true,
|
|
786
|
+
value:
|
|
787
|
+
'LoremipsumdolorsitametconsecteturadipiscingelitseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquaUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequatDuisauteiruredolorinreprehenderitinvoluptatevelitessecillumdoloreeullamcolaborisnisiutaliquipexeacommodoconsequatDuisauteiruredolorinreprehenderitinvoluptatevelitessecillumdoloreeufugiatnullapariaturufugiatnullapariatur',
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
type: 'Select',
|
|
791
|
+
native: true,
|
|
792
|
+
options: [
|
|
793
|
+
{ label: 50, value: 50 },
|
|
794
|
+
{ label: 100, value: 100 },
|
|
795
|
+
],
|
|
796
|
+
value: { label: 100, value: 100 },
|
|
797
|
+
onChange: () => {},
|
|
798
|
+
disabled: true,
|
|
799
|
+
},
|
|
800
|
+
{
|
|
801
|
+
type: 'Select',
|
|
802
|
+
options: [
|
|
803
|
+
{ label: 'Vietnam', value: 'Vietnam' },
|
|
804
|
+
{ label: 'Other', value: 'Other' },
|
|
805
|
+
],
|
|
806
|
+
value: { label: 'Vietnam', value: 'Vietnam' },
|
|
807
|
+
onChange: () => {},
|
|
808
|
+
error: 'Error',
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
value: 'Brown rice',
|
|
812
|
+
type: 'Input',
|
|
813
|
+
onChange: () => {},
|
|
814
|
+
testId: 'table-tbody-cell-brown-rice',
|
|
815
|
+
warning: 'Warning message',
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
value: 'Static warning',
|
|
819
|
+
warning: 'Warning message',
|
|
820
|
+
},
|
|
821
|
+
],
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
cells: [
|
|
825
|
+
{ value: 'Buckwheat' },
|
|
826
|
+
{
|
|
827
|
+
type: 'Select',
|
|
828
|
+
native: true,
|
|
829
|
+
options: [
|
|
830
|
+
{ label: 50, value: 50 },
|
|
831
|
+
{ label: 100, value: 100 },
|
|
832
|
+
],
|
|
833
|
+
value: { label: 100, value: 100 },
|
|
834
|
+
onChange: () => {},
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
type: 'Select',
|
|
838
|
+
options: [
|
|
839
|
+
{ label: 'Vietnam', value: 'Vietnam' },
|
|
840
|
+
{ label: 'Other', value: 'Other' },
|
|
841
|
+
],
|
|
842
|
+
value: { label: 'Vietnam', value: 'Vietnam' },
|
|
843
|
+
onChange: () => {},
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
value: 'Brown rice',
|
|
847
|
+
type: 'Input',
|
|
848
|
+
onChange: () => {},
|
|
849
|
+
testId: 'table-tbody-cell-brown-rice',
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
value: 'Static error',
|
|
853
|
+
error: 'Error message',
|
|
854
|
+
},
|
|
855
|
+
],
|
|
856
|
+
},
|
|
857
|
+
],
|
|
858
|
+
};
|
|
@@ -730,88 +730,5 @@ export const OnRowEnter = () => {
|
|
|
730
730
|
);
|
|
731
731
|
};
|
|
732
732
|
|
|
733
|
-
export const OverflowingCells = ()
|
|
734
|
-
|
|
735
|
-
table={{
|
|
736
|
-
fixedWidth: '100%',
|
|
737
|
-
headers: [
|
|
738
|
-
{
|
|
739
|
-
cells: [
|
|
740
|
-
{ value: 'Name' },
|
|
741
|
-
{ value: 'Weight (kg)' },
|
|
742
|
-
{ value: 'Energy (kcal / 100g)' },
|
|
743
|
-
{ value: 'Origin' },
|
|
744
|
-
],
|
|
745
|
-
},
|
|
746
|
-
],
|
|
747
|
-
rows: [
|
|
748
|
-
{
|
|
749
|
-
cells: [
|
|
750
|
-
{
|
|
751
|
-
breakWord: true,
|
|
752
|
-
value:
|
|
753
|
-
'LoremipsumdolorsitametconsecteturadipiscingelitseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquaUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipexeacommodoconsequatDuisauteiruredolorinreprehenderitinvoluptatevelitessecillumdoloreeullamcolaborisnisiutaliquipexeacommodoconsequatDuisauteiruredolorinreprehenderitinvoluptatevelitessecillumdoloreeufugiatnullapariaturufugiatnullapariatur',
|
|
754
|
-
},
|
|
755
|
-
{
|
|
756
|
-
type: 'Select',
|
|
757
|
-
native: true,
|
|
758
|
-
options: [
|
|
759
|
-
{ label: 50, value: 50 },
|
|
760
|
-
{ label: 100, value: 100 },
|
|
761
|
-
],
|
|
762
|
-
value: { label: 100, value: 100 },
|
|
763
|
-
onChange: () => {},
|
|
764
|
-
disabled: true,
|
|
765
|
-
},
|
|
766
|
-
{
|
|
767
|
-
type: 'Select',
|
|
768
|
-
options: [
|
|
769
|
-
{ label: 'Vietnam', value: 'Vietnam' },
|
|
770
|
-
{ label: 'Other', value: 'Other' },
|
|
771
|
-
],
|
|
772
|
-
value: { label: 'Vietnam', value: 'Vietnam' },
|
|
773
|
-
onChange: () => {},
|
|
774
|
-
error: 'Error',
|
|
775
|
-
},
|
|
776
|
-
{
|
|
777
|
-
value: 'Brown rice',
|
|
778
|
-
type: 'Input',
|
|
779
|
-
onChange: () => {},
|
|
780
|
-
testId: 'table-tbody-cell-brown-rice',
|
|
781
|
-
},
|
|
782
|
-
],
|
|
783
|
-
},
|
|
784
|
-
{
|
|
785
|
-
cells: [
|
|
786
|
-
{ value: 'Buckwheat' },
|
|
787
|
-
{
|
|
788
|
-
type: 'Select',
|
|
789
|
-
native: true,
|
|
790
|
-
options: [
|
|
791
|
-
{ label: 50, value: 50 },
|
|
792
|
-
{ label: 100, value: 100 },
|
|
793
|
-
],
|
|
794
|
-
value: { label: 100, value: 100 },
|
|
795
|
-
onChange: () => {},
|
|
796
|
-
},
|
|
797
|
-
{
|
|
798
|
-
type: 'Select',
|
|
799
|
-
options: [
|
|
800
|
-
{ label: 'Vietnam', value: 'Vietnam' },
|
|
801
|
-
{ label: 'Other', value: 'Other' },
|
|
802
|
-
],
|
|
803
|
-
value: { label: 'Vietnam', value: 'Vietnam' },
|
|
804
|
-
onChange: () => {},
|
|
805
|
-
},
|
|
806
|
-
{
|
|
807
|
-
value: 'Brown rice',
|
|
808
|
-
type: 'Input',
|
|
809
|
-
onChange: () => {},
|
|
810
|
-
testId: 'table-tbody-cell-brown-rice',
|
|
811
|
-
},
|
|
812
|
-
],
|
|
813
|
-
},
|
|
814
|
-
],
|
|
815
|
-
}}
|
|
816
|
-
/>
|
|
817
|
-
);
|
|
733
|
+
export const OverflowingCells = Template.bind({});
|
|
734
|
+
OverflowingCells.args = { table: storyData.tableOverflowing };
|
|
@@ -9,11 +9,3 @@
|
|
|
9
9
|
align-items: center;
|
|
10
10
|
justify-content: space-between;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
.cellErrorWarningWrapper {
|
|
14
|
-
margin: (-@input_padding_y - 1) (-@input_padding_x - 1) !important;
|
|
15
|
-
padding: @input_padding_y @input_padding_x !important;
|
|
16
|
-
display: block;
|
|
17
|
-
line-height: 17px;
|
|
18
|
-
position: relative;
|
|
19
|
-
}
|
package/src/style/mixins.less
CHANGED
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
.inputError,
|
|
30
30
|
.inputWarning {
|
|
31
31
|
position: relative;
|
|
32
|
-
z-index: 1;
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
.inputError {
|
|
35
|
+
z-index: 2;
|
|
36
36
|
border-color: var(--color-border-error) !important;
|
|
37
37
|
color: var(--color-text-error) !important;
|
|
38
38
|
background-color: var(--color-background-error);
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
.inputWarning {
|
|
50
|
+
z-index: 1;
|
|
50
51
|
border-color: var(--color-border-warning) !important;
|
|
51
52
|
color: var(--color-text-warning) !important;
|
|
52
53
|
background-color: var(--color-background-warning);
|