diginet-core-ui 1.3.34 → 1.3.35
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/assets/images/menu/dhr/MHRP09N0032.svg +7 -0
- package/components/avatar/index.js +19 -19
- package/components/badge/index.js +61 -64
- package/components/button/icon.js +21 -21
- package/components/button/index.js +180 -180
- package/components/button/ripple-effect.js +23 -23
- package/components/chart/Pie-v2/index.js +40 -42
- package/components/chip/index.js +129 -134
- package/components/form-control/attachment/index.js +431 -435
- package/components/form-control/calendar/function.js +69 -46
- package/components/form-control/calendar/index.js +12 -3
- package/components/form-control/control/index.js +35 -23
- package/components/form-control/date-picker/index.js +36 -36
- package/components/form-control/date-range-picker/index.js +84 -86
- package/components/form-control/dropdown/index.js +462 -431
- package/components/form-control/dropdown-box/index.js +53 -53
- package/components/form-control/label/index.js +16 -15
- package/components/form-control/money-input/index.js +106 -7
- package/components/form-control/radio/index.js +129 -132
- package/components/form-control/text-input/index.js +25 -28
- package/components/form-control/toggle/index.js +106 -107
- package/components/modal/modal.js +43 -46
- package/components/popover/index.js +27 -29
- package/components/popup/index.js +73 -77
- package/components/popup/proposals_popup.js +46 -48
- package/components/popup/v2/index.js +108 -110
- package/components/progress/circular.js +65 -66
- package/components/tab/tab-container.js +32 -14
- package/components/tab/tab-header.js +81 -56
- package/components/tab/tab-panel.js +46 -17
- package/components/tab/tab.js +105 -87
- package/components/tooltip/index.js +24 -26
- package/components/typography/index.js +10 -10
- package/icons/basic.js +148 -27
- package/icons/effect.js +26 -26
- package/package.json +1 -1
- package/readme.md +17 -0
- package/theme/settings.js +7 -5
- package/utils/number.js +11 -12
|
@@ -57,15 +57,14 @@ const getDimension = size => {
|
|
|
57
57
|
strokeWidth = 8;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
;
|
|
61
60
|
return {
|
|
62
61
|
labelStyle,
|
|
63
62
|
rect,
|
|
64
63
|
strokeWidth
|
|
65
64
|
};
|
|
66
65
|
};
|
|
67
|
-
/**
|
|
68
|
-
* Determinate circular progress
|
|
66
|
+
/**
|
|
67
|
+
* Determinate circular progress
|
|
69
68
|
*/
|
|
70
69
|
|
|
71
70
|
|
|
@@ -114,44 +113,44 @@ const Determinate = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
114
113
|
|
|
115
114
|
return angle;
|
|
116
115
|
};
|
|
117
|
-
/**
|
|
118
|
-
* style
|
|
116
|
+
/**
|
|
117
|
+
* style
|
|
119
118
|
*/
|
|
120
119
|
|
|
121
120
|
|
|
122
121
|
const containerCSS = css`
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
122
|
+
border-radius: 50%;
|
|
123
|
+
height: ${containerW}px;
|
|
124
|
+
overflow: hidden;
|
|
125
|
+
position: relative;
|
|
126
|
+
width: ${containerW}px;
|
|
127
|
+
`;
|
|
129
128
|
const circleBackgroundCSS = css`
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
129
|
+
border-radius: 50%;
|
|
130
|
+
fill: transparent;
|
|
131
|
+
overflow: hidden;
|
|
132
|
+
stroke: ${background};
|
|
133
|
+
stroke-width: ${circleStrokeW}px;
|
|
134
|
+
`;
|
|
136
135
|
const circleMainCSS = css`
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
136
|
+
border-radius: 50%;
|
|
137
|
+
fill: transparent;
|
|
138
|
+
overflow: hidden;
|
|
139
|
+
stroke: ${color};
|
|
140
|
+
stroke-dasharray: ${`${circumference} ${circumference}`};
|
|
141
|
+
stroke-dashoffset: ${circumference - validatePercent(percent) / 100 * circumference};
|
|
142
|
+
stroke-linecap: round;
|
|
143
|
+
stroke-width: ${circleStrokeW}px;
|
|
144
|
+
transform: rotate(${getDirection(direction)}deg);
|
|
145
|
+
transform-origin: 50% 50%;
|
|
146
|
+
transition: stroke-dashoffset ${duration}s cubic-bezier(0.77, 0, 0.175, 1); /* easeInOutQuart */
|
|
147
|
+
`;
|
|
149
148
|
const textCSS = css`
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
149
|
+
fill: ${percentColor ? percentColor : color};
|
|
150
|
+
${dimension.labelStyle}
|
|
151
|
+
text-anchor: middle;
|
|
152
|
+
user-select: none;
|
|
153
|
+
`;
|
|
155
154
|
const CircleBackgroundMemo = useMemo(() => jsx("circle", {
|
|
156
155
|
css: circleBackgroundCSS,
|
|
157
156
|
cx: containerW / 2,
|
|
@@ -217,8 +216,8 @@ Determinate.propTypes = {
|
|
|
217
216
|
width: PropTypes.number
|
|
218
217
|
};
|
|
219
218
|
export const DeterminateCircularProgress = Determinate;
|
|
220
|
-
/**
|
|
221
|
-
* Indeterminate circular progress
|
|
219
|
+
/**
|
|
220
|
+
* Indeterminate circular progress
|
|
222
221
|
*/
|
|
223
222
|
|
|
224
223
|
const Indeterminate = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
@@ -255,40 +254,40 @@ const Indeterminate = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
255
254
|
stroke-dashoffset: -${r * 124 / 200};
|
|
256
255
|
}
|
|
257
256
|
`;
|
|
258
|
-
/**
|
|
259
|
-
* style
|
|
257
|
+
/**
|
|
258
|
+
* style
|
|
260
259
|
*/
|
|
261
260
|
|
|
262
261
|
|
|
263
262
|
const containerCSS = css`
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
263
|
+
animation: ${keyframeRotate} 2s linear infinite;
|
|
264
|
+
border-radius: 50%;
|
|
265
|
+
height: ${containerW}px;
|
|
266
|
+
overflow: hidden;
|
|
267
|
+
position: relative;
|
|
268
|
+
width: ${containerW}px;
|
|
269
|
+
`;
|
|
271
270
|
const circleBackgroundCSS = css`
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
271
|
+
border-radius: 50%;
|
|
272
|
+
fill: transparent;
|
|
273
|
+
overflow: hidden;
|
|
274
|
+
stroke: ${background};
|
|
275
|
+
stroke-linecap: round;
|
|
276
|
+
stroke-width: ${circleStrokeW};
|
|
277
|
+
`;
|
|
279
278
|
const circleMainCSS = css`
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* component
|
|
279
|
+
animation: ${keyframeDash(radiusX10)} 2s ease-in-out infinite;
|
|
280
|
+
border-radius: 50%;
|
|
281
|
+
fill: transparent;
|
|
282
|
+
overflow: hidden;
|
|
283
|
+
stroke: ${color};
|
|
284
|
+
stroke-dasharray: 10, ${radiusX10};
|
|
285
|
+
stroke-dashoffset: 0;
|
|
286
|
+
stroke-linecap: round;
|
|
287
|
+
stroke-width: ${circleStrokeW};
|
|
288
|
+
`;
|
|
289
|
+
/**
|
|
290
|
+
* component
|
|
292
291
|
*/
|
|
293
292
|
|
|
294
293
|
const CircleBackgroundMemo = useMemo(() => jsx("circle", {
|
|
@@ -331,8 +330,8 @@ Indeterminate.propTypes = {
|
|
|
331
330
|
width: PropTypes.number
|
|
332
331
|
};
|
|
333
332
|
export const IndeterminateCircularProgress = Indeterminate;
|
|
334
|
-
/**
|
|
335
|
-
* Circular progress
|
|
333
|
+
/**
|
|
334
|
+
* Circular progress
|
|
336
335
|
*/
|
|
337
336
|
|
|
338
337
|
const CircularProgress = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import React, { forwardRef, useState, memo, useEffect } from 'react';
|
|
4
|
+
import React, { forwardRef, useState, memo, useEffect, useRef, useImperativeHandle } from 'react';
|
|
5
5
|
import { jsx, css } from '@emotion/core';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { randomString } from '../../utils';
|
|
8
8
|
import TabContext from './context';
|
|
9
9
|
import { isNumeric } from '../../utils/type';
|
|
10
10
|
import Typography from '../typography';
|
|
11
|
-
import { flexRow, positionRelative } from '../../styles/general';
|
|
11
|
+
import { flexCol, flexRow, positionRelative, parseWidth } from '../../styles/general';
|
|
12
12
|
const TabContainer = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
13
13
|
children,
|
|
14
14
|
tabIndex,
|
|
@@ -17,7 +17,8 @@ const TabContainer = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
17
17
|
level = 'level1',
|
|
18
18
|
className,
|
|
19
19
|
...props
|
|
20
|
-
},
|
|
20
|
+
}, reference) => {
|
|
21
|
+
const ref = useRef(null);
|
|
21
22
|
const {
|
|
22
23
|
value
|
|
23
24
|
} = props;
|
|
@@ -26,19 +27,22 @@ const TabContainer = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
26
27
|
allowNumber: false,
|
|
27
28
|
allowSymbol: false
|
|
28
29
|
}));
|
|
30
|
+
if (level === 'level1') level = 'h3';
|
|
31
|
+
if (level === 'level2') level = 'p1';
|
|
29
32
|
useEffect(() => {
|
|
30
33
|
if (isNumeric(value)) setTabIndexState(value);else setTabIndexState(tabIndex);
|
|
31
34
|
}, [value, tabIndex]);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
useImperativeHandle(reference, () => {
|
|
36
|
+
const currentRef = ref.current || {};
|
|
37
|
+
const _instance = {}; // methods
|
|
38
|
+
|
|
39
|
+
_instance.__proto__ = {}; // hidden methods
|
|
40
|
+
|
|
41
|
+
currentRef.instance = _instance;
|
|
42
|
+
return currentRef;
|
|
43
|
+
});
|
|
40
44
|
return jsx("div", {
|
|
41
|
-
css:
|
|
45
|
+
css: TabContainerCSS(direction, width),
|
|
42
46
|
className: ['DGN-UI-Tab-Container', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
43
47
|
id: `DGN-${id}-tab-button-container`,
|
|
44
48
|
ref: ref,
|
|
@@ -49,10 +53,17 @@ const TabContainer = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
49
53
|
setTabIndexState,
|
|
50
54
|
direction
|
|
51
55
|
}
|
|
52
|
-
}, React.Children.map(children, child => /*#__PURE__*/React.cloneElement(child, {
|
|
56
|
+
}, React.Children.map(children, child => child && /*#__PURE__*/React.cloneElement(child, {
|
|
53
57
|
level
|
|
54
58
|
}))));
|
|
55
59
|
}));
|
|
60
|
+
|
|
61
|
+
const TabContainerCSS = (direction, width) => css`
|
|
62
|
+
${direction === 'vertical' ? flexRow : flexCol}
|
|
63
|
+
${positionRelative}
|
|
64
|
+
${parseWidth(width)}
|
|
65
|
+
`;
|
|
66
|
+
|
|
56
67
|
TabContainer.defaultProps = {
|
|
57
68
|
width: '100%',
|
|
58
69
|
direction: 'horizontal',
|
|
@@ -80,6 +91,13 @@ TabContainer.propTypes = {
|
|
|
80
91
|
style: PropTypes.object,
|
|
81
92
|
|
|
82
93
|
/** any props else */
|
|
83
|
-
props: PropTypes.any
|
|
94
|
+
props: PropTypes.any,
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* ref methods
|
|
98
|
+
*/
|
|
99
|
+
reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
100
|
+
current: PropTypes.instanceOf(Element)
|
|
101
|
+
})])
|
|
84
102
|
};
|
|
85
103
|
export default TabContainer;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import React, { memo, forwardRef, useContext, useRef, useState } from 'react';
|
|
4
|
+
import React, { memo, forwardRef, useContext, useRef, useState, useImperativeHandle } from 'react';
|
|
5
5
|
import { jsx, css } from '@emotion/core';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { color as colors } from '../../styles/colors';
|
|
8
8
|
import TabContext from './context';
|
|
9
9
|
import ButtonIcon from '../button/icon';
|
|
10
|
-
import { borderBox, flexCol, flexRow, overflowHidden, positionRelative } from '../../styles/general';
|
|
10
|
+
import { borderBox, displayNone, flexCol, flexRow, justifyCenter, overflowHidden, positionRelative, whiteSpaceNoWrap } from '../../styles/general';
|
|
11
11
|
const {
|
|
12
12
|
line: {
|
|
13
13
|
tab
|
|
@@ -19,63 +19,19 @@ const TabHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
19
19
|
className,
|
|
20
20
|
level,
|
|
21
21
|
scrollButtons,
|
|
22
|
+
centered,
|
|
22
23
|
...props
|
|
23
24
|
}, reference) => {
|
|
24
25
|
var _ref$current, _ref$current2;
|
|
25
26
|
|
|
26
|
-
const ref = useRef(null);
|
|
27
27
|
const {
|
|
28
28
|
direction
|
|
29
29
|
} = useContext(TabContext);
|
|
30
|
-
const
|
|
30
|
+
const ref = useRef(null);
|
|
31
31
|
const [scrollLeft, setScrollLeft] = useState(0);
|
|
32
|
+
const isVertical = direction === 'vertical';
|
|
32
33
|
let showScrollLeftButton = !isVertical && scrollLeft > 0;
|
|
33
34
|
let showScrollRightButton = !isVertical && (ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.offsetWidth) + scrollLeft < (ref === null || ref === void 0 ? void 0 : (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.scrollWidth);
|
|
34
|
-
const Container = css`
|
|
35
|
-
${flexRow}
|
|
36
|
-
${overflowHidden}
|
|
37
|
-
${positionRelative}
|
|
38
|
-
${borderBox}
|
|
39
|
-
height: auto;
|
|
40
|
-
min-height: 2.5rem;
|
|
41
|
-
flex-direction: ${isVertical ? 'column' : 'row'};
|
|
42
|
-
max-width: ${isVertical ? 'max-content' : '100%'};
|
|
43
|
-
width: 100%;
|
|
44
|
-
padding: 0;
|
|
45
|
-
${isVertical ? `border-right: solid 1px ${tab}` : `border-bottom: solid 1px ${tab}`};
|
|
46
|
-
`;
|
|
47
|
-
const TabHeader = isVertical ? css`
|
|
48
|
-
${flexCol}
|
|
49
|
-
padding: 0 3px 0 0;
|
|
50
|
-
` : css`
|
|
51
|
-
${flexRow}
|
|
52
|
-
${positionRelative}
|
|
53
|
-
white-space: nowrap;
|
|
54
|
-
margin: 0;
|
|
55
|
-
list-style: none;
|
|
56
|
-
overflow-x: auto;
|
|
57
|
-
scroll-behavior: smooth;
|
|
58
|
-
scroll-snap-type: x mandatory;
|
|
59
|
-
scroll-padding: 50%;
|
|
60
|
-
transition: 0.3s ease-in-out 0.3s;
|
|
61
|
-
&::-webkit-scrollbar {
|
|
62
|
-
display: none;
|
|
63
|
-
}
|
|
64
|
-
`;
|
|
65
|
-
|
|
66
|
-
const scrollButton = scrollPrevious => css`
|
|
67
|
-
overflow: initial;
|
|
68
|
-
width: 24px;
|
|
69
|
-
height: 24px;
|
|
70
|
-
align-self: center;
|
|
71
|
-
margin: ${scrollPrevious ? '0 8px 0 0' : '0 0 0 8px'};
|
|
72
|
-
opacity: ${scrollPrevious && showScrollLeftButton || !scrollPrevious && showScrollRightButton ? '1' : '0'};
|
|
73
|
-
:disabled {
|
|
74
|
-
span {
|
|
75
|
-
cursor: default !important;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
`;
|
|
79
35
|
|
|
80
36
|
const _onClickScrollButton = scrollPrevious => {
|
|
81
37
|
let scrollValue = scrollPrevious ? ref.current.scrollLeft - (ref.current.offsetWidth + 30) : ref.current.scrollLeft + (ref.current.offsetWidth + 30);
|
|
@@ -83,14 +39,23 @@ const TabHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
83
39
|
setScrollLeft(scrollValue);
|
|
84
40
|
};
|
|
85
41
|
|
|
42
|
+
useImperativeHandle(reference, () => {
|
|
43
|
+
const currentRef = ref.current || {};
|
|
44
|
+
const _instance = {}; // methods
|
|
45
|
+
|
|
46
|
+
_instance.__proto__ = {}; // hidden methods
|
|
47
|
+
|
|
48
|
+
currentRef.instance = _instance;
|
|
49
|
+
return currentRef;
|
|
50
|
+
});
|
|
86
51
|
return jsx("div", {
|
|
87
|
-
css:
|
|
52
|
+
css: ContainerCSS(centered, isVertical),
|
|
88
53
|
id: `DGN-control`,
|
|
89
54
|
className: ['DGN-UI-Tab-Header-Container', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
90
55
|
style: style,
|
|
91
56
|
...props
|
|
92
57
|
}, scrollButtons && jsx(ButtonIcon, {
|
|
93
|
-
css:
|
|
58
|
+
css: scrollButtonCSS(true, showScrollLeftButton, showScrollRightButton),
|
|
94
59
|
name: isVertical ? 'ArrowUp' : 'ArrowLeft',
|
|
95
60
|
viewType: 'text',
|
|
96
61
|
size: 'tiny',
|
|
@@ -98,7 +63,7 @@ const TabHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
98
63
|
disabled: !showScrollLeftButton,
|
|
99
64
|
onClick: () => _onClickScrollButton(true)
|
|
100
65
|
}), jsx("div", {
|
|
101
|
-
css:
|
|
66
|
+
css: TabHeaderCSS(isVertical),
|
|
102
67
|
className: 'DGN-UI-Tab-Header',
|
|
103
68
|
ref: ref,
|
|
104
69
|
onScroll: e => {
|
|
@@ -106,10 +71,10 @@ const TabHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
106
71
|
|
|
107
72
|
return scrollButtons && setScrollLeft((e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.scrollLeft) || 0);
|
|
108
73
|
}
|
|
109
|
-
}, React.Children.map(children, child => /*#__PURE__*/React.cloneElement(child, {
|
|
74
|
+
}, React.Children.map(children, child => child && /*#__PURE__*/React.cloneElement(child, {
|
|
110
75
|
level
|
|
111
76
|
}))), scrollButtons && jsx(ButtonIcon, {
|
|
112
|
-
css:
|
|
77
|
+
css: scrollButtonCSS(false, showScrollLeftButton, showScrollRightButton),
|
|
113
78
|
name: isVertical ? 'ArrowDown' : 'ArrowRight',
|
|
114
79
|
viewType: 'text',
|
|
115
80
|
size: 'tiny',
|
|
@@ -118,10 +83,60 @@ const TabHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
118
83
|
onClick: () => _onClickScrollButton(false)
|
|
119
84
|
}));
|
|
120
85
|
}));
|
|
86
|
+
|
|
87
|
+
const ContainerCSS = (centered, isVertical) => css`
|
|
88
|
+
${flexRow}
|
|
89
|
+
${overflowHidden}
|
|
90
|
+
${positionRelative}
|
|
91
|
+
${borderBox}
|
|
92
|
+
${centered && justifyCenter}
|
|
93
|
+
height: auto;
|
|
94
|
+
min-height: 2.5rem;
|
|
95
|
+
flex-direction: ${isVertical ? 'column' : 'row'};
|
|
96
|
+
max-width: ${isVertical ? 'max-content' : '100%'};
|
|
97
|
+
width: 100%;
|
|
98
|
+
padding: 0;
|
|
99
|
+
${isVertical ? `border-right: solid 1px ${tab}` : `border-bottom: solid 1px ${tab}`};
|
|
100
|
+
`;
|
|
101
|
+
|
|
102
|
+
const TabHeaderCSS = isVertical => isVertical ? css`
|
|
103
|
+
${flexCol}
|
|
104
|
+
padding: 0 3px 0 0;
|
|
105
|
+
` : css`
|
|
106
|
+
${flexRow}
|
|
107
|
+
${positionRelative}
|
|
108
|
+
${whiteSpaceNoWrap}
|
|
109
|
+
margin: 0;
|
|
110
|
+
list-style: none;
|
|
111
|
+
overflow-x: auto;
|
|
112
|
+
scroll-behavior: smooth;
|
|
113
|
+
scroll-snap-type: x mandatory;
|
|
114
|
+
scroll-padding: 50%;
|
|
115
|
+
transition: 0.3s ease-in-out 0.3s;
|
|
116
|
+
&::-webkit-scrollbar {
|
|
117
|
+
${displayNone}
|
|
118
|
+
}
|
|
119
|
+
`;
|
|
120
|
+
|
|
121
|
+
const scrollButtonCSS = (scrollPrevious, showScrollLeftButton, showScrollRightButton) => css`
|
|
122
|
+
overflow: initial;
|
|
123
|
+
width: 24px;
|
|
124
|
+
height: 24px;
|
|
125
|
+
align-self: center;
|
|
126
|
+
margin: ${scrollPrevious ? '0 8px 0 0' : '0 0 0 8px'};
|
|
127
|
+
opacity: ${scrollPrevious && showScrollLeftButton || !scrollPrevious && showScrollRightButton ? '1' : '0'};
|
|
128
|
+
:disabled {
|
|
129
|
+
span {
|
|
130
|
+
cursor: default !important;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
|
|
121
135
|
TabHeader.defaultProps = {
|
|
122
136
|
scrollButtons: false,
|
|
123
137
|
className: '',
|
|
124
|
-
style: {}
|
|
138
|
+
style: {},
|
|
139
|
+
centered: false
|
|
125
140
|
};
|
|
126
141
|
TabHeader.propTypes = {
|
|
127
142
|
/** element to display in Tabs (like text) */
|
|
@@ -136,7 +151,17 @@ TabHeader.propTypes = {
|
|
|
136
151
|
/** show scroll buttons if true */
|
|
137
152
|
scrollButtons: PropTypes.bool,
|
|
138
153
|
|
|
154
|
+
/** If true, the tabs are centered */
|
|
155
|
+
centered: PropTypes.bool,
|
|
156
|
+
|
|
139
157
|
/** any props else */
|
|
140
|
-
props: PropTypes.any
|
|
158
|
+
props: PropTypes.any,
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* ref methods
|
|
162
|
+
*/
|
|
163
|
+
reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
164
|
+
current: PropTypes.instanceOf(Element)
|
|
165
|
+
})])
|
|
141
166
|
};
|
|
142
167
|
export default TabHeader;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { memo, forwardRef, useContext } from 'react';
|
|
4
|
+
import { memo, forwardRef, useContext, useRef, useEffect, useState, useImperativeHandle } from 'react';
|
|
5
5
|
import { jsx, css } from '@emotion/core';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { color as colors } from '../../styles/colors';
|
|
8
8
|
import TabContext from './context';
|
|
9
|
-
import { borderBox, positionRelative } from '../../styles/general';
|
|
9
|
+
import { borderBox, displayNone, flexCol, positionRelative } from '../../styles/general';
|
|
10
10
|
const {
|
|
11
11
|
text: {
|
|
12
12
|
main
|
|
@@ -17,25 +17,31 @@ const TabPanel = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
17
17
|
index,
|
|
18
18
|
style,
|
|
19
19
|
className,
|
|
20
|
+
lazyLoading,
|
|
20
21
|
...props
|
|
21
|
-
},
|
|
22
|
+
}, reference) => {
|
|
22
23
|
const {
|
|
23
24
|
tabIndexState,
|
|
24
25
|
direction
|
|
25
26
|
} = useContext(TabContext);
|
|
27
|
+
const [isRendered, setIsRendered] = useState(false);
|
|
28
|
+
const ref = useRef(null);
|
|
26
29
|
const isVertical = direction === 'vertical';
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
const isActive = index === tabIndexState;
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (isRendered) return;else if (index === tabIndexState) setIsRendered(true);
|
|
33
|
+
}, [tabIndexState]);
|
|
34
|
+
useImperativeHandle(reference, () => {
|
|
35
|
+
const currentRef = ref.current || {};
|
|
36
|
+
const _instance = {}; // methods
|
|
37
|
+
|
|
38
|
+
_instance.__proto__ = {}; // hidden methods
|
|
39
|
+
|
|
40
|
+
currentRef.instance = _instance;
|
|
41
|
+
return currentRef;
|
|
42
|
+
});
|
|
37
43
|
return jsx("div", {
|
|
38
|
-
css:
|
|
44
|
+
css: TabPanelCSS(isVertical, isActive),
|
|
39
45
|
"aria-labelledby": `tab-${index}`,
|
|
40
46
|
id: `tab-panel-${index}`,
|
|
41
47
|
className: ['DGN-UI-Tab-Panel', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
@@ -43,11 +49,24 @@ const TabPanel = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
43
49
|
role: 'tab-panel',
|
|
44
50
|
ref: ref,
|
|
45
51
|
...props
|
|
46
|
-
}, children);
|
|
52
|
+
}, isActive || !lazyLoading || isRendered ? children : null);
|
|
47
53
|
}));
|
|
54
|
+
|
|
55
|
+
const TabPanelCSS = (isVertical, isActive) => css`
|
|
56
|
+
${flexCol}
|
|
57
|
+
${borderBox}
|
|
58
|
+
${positionRelative}
|
|
59
|
+
${isActive ? flexCol : displayNone}
|
|
60
|
+
color: ${main};
|
|
61
|
+
height: ${isVertical ? '300px' : '100%'};
|
|
62
|
+
padding: 0px ${isVertical ? '12px' : '10'};
|
|
63
|
+
width: 100%;
|
|
64
|
+
`;
|
|
65
|
+
|
|
48
66
|
TabPanel.defaultProps = {
|
|
49
67
|
className: '',
|
|
50
|
-
style: {}
|
|
68
|
+
style: {},
|
|
69
|
+
lazyLoading: false
|
|
51
70
|
};
|
|
52
71
|
TabPanel.propTypes = {
|
|
53
72
|
/** element to display in Tabs (like text) */
|
|
@@ -62,7 +81,17 @@ TabPanel.propTypes = {
|
|
|
62
81
|
/** style inline of component */
|
|
63
82
|
style: PropTypes.object,
|
|
64
83
|
|
|
84
|
+
/** lazy loading mode */
|
|
85
|
+
lazyLoading: PropTypes.bool,
|
|
86
|
+
|
|
65
87
|
/** any props else */
|
|
66
|
-
props: PropTypes.any
|
|
88
|
+
props: PropTypes.any,
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* ref methods
|
|
92
|
+
*/
|
|
93
|
+
reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
94
|
+
current: PropTypes.instanceOf(Element)
|
|
95
|
+
})])
|
|
67
96
|
};
|
|
68
97
|
export default TabPanel;
|