diginet-core-ui 1.3.80 → 1.3.81
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/components/avatar/index.js +10 -9
- package/components/button/icon.js +7 -4
- package/components/button/index.js +37 -23
- package/components/divider/index.js +56 -55
- package/components/form-control/attachment/index.js +234 -416
- package/components/form-control/date-range-picker/index.js +57 -57
- package/components/index.js +1 -1
- package/components/popover/body.js +9 -9
- package/components/popover/footer.js +7 -7
- package/components/popover/header.js +8 -8
- package/components/popover/index.js +17 -15
- package/components/popup/v2/index.js +122 -144
- package/components/progress/circular.js +1 -1
- package/global/index.js +1 -1
- package/icons/basic.js +52 -0
- package/package.json +1 -1
- package/readme.md +10 -0
- package/components/divider/style.js +0 -12
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { css, jsx } from '@emotion/core';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
6
|
-
import { render } from 'react-dom';
|
|
7
4
|
import { Button, ButtonIcon, Divider, HelperText, InputBase, Label, Typography } from "../..";
|
|
8
5
|
import { getGlobal } from "../../../global";
|
|
9
6
|
import locale from "../../../locale";
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
9
|
+
import { render } from 'react-dom';
|
|
10
10
|
import { alignCenter, borderRadius4px, cursorPointer, displayBlock, displayNone, flexCol, flexRow, justifyEnd, parseHeight, parseMaxWidth, parseMinWidth, parseWidth, parseWidthHeight, pointerEventsNone, positionFixed, textCenter, userSelectNone, whiteSpaceNoWrap } from "../../../styles/general";
|
|
11
11
|
import { useTheme } from "../../../theme";
|
|
12
12
|
import { capitalizeSentenceCase, classNames, date as moment, isEqual, randomString, updatePosition } from "../../../utils";
|
|
@@ -76,7 +76,7 @@ const isAfter = (max, time) => {
|
|
|
76
76
|
const parseDate = day => {
|
|
77
77
|
return Date.parse(new Date(day));
|
|
78
78
|
};
|
|
79
|
-
const
|
|
79
|
+
const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
80
80
|
action = {},
|
|
81
81
|
actionIconAt,
|
|
82
82
|
clearAble,
|
|
@@ -185,7 +185,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
185
185
|
return '';
|
|
186
186
|
};
|
|
187
187
|
const countDay = v => {
|
|
188
|
-
if (v
|
|
188
|
+
if ((v === null || v === void 0 ? void 0 : v.length) === 2) {
|
|
189
189
|
return Number(+moment(v[1]).diff(v[0]) + (startFromZero ? 0 : 1));
|
|
190
190
|
}
|
|
191
191
|
return Number(startFromZero ? 0 : 1);
|
|
@@ -273,7 +273,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
273
273
|
tableData.push(jsx("td", {
|
|
274
274
|
key: `this_month-${i + 1}`,
|
|
275
275
|
"data-time": Date.parse(day),
|
|
276
|
-
className: classNames(unique.table.data, 'this_month', isToday(day), isActive(day), (max
|
|
276
|
+
className: classNames(unique.table.data, 'this_month', isToday(day), isActive(day), (max || min) && isLimit(day, new Date(max).setHours(0, 0, 0, 0), new Date(min).setHours(0, 0, 0, 0)), isBetween(Date.parse(day))),
|
|
277
277
|
onClick: onDayClick
|
|
278
278
|
}, jsx(Typography, {
|
|
279
279
|
className: unique.day.day,
|
|
@@ -421,7 +421,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
421
421
|
};
|
|
422
422
|
const setPrevTime = (e, level, time, type) => {
|
|
423
423
|
if (!valueFr.current || !time) return;
|
|
424
|
-
const firstDayOfMin = min &&
|
|
424
|
+
const firstDayOfMin = min && new Date(new Date(min).setDate(1)).setHours(0, 0, 0, 0);
|
|
425
425
|
const firstDayOfTime = new Date(new Date(time).setDate(1)).setHours(0, 0, 0, 0);
|
|
426
426
|
if (level === 'month') {
|
|
427
427
|
if (firstDayOfMin) {
|
|
@@ -461,7 +461,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
461
461
|
};
|
|
462
462
|
const setNextTime = (e, level, time, type) => {
|
|
463
463
|
if (!valueTo.current || !time) return;
|
|
464
|
-
const firstDayOfMax = max &&
|
|
464
|
+
const firstDayOfMax = max && new Date(new Date(max).setDate(1)).setHours(0, 0, 0, 0);
|
|
465
465
|
const firstDayOfTime = new Date(new Date(time).setDate(1)).setHours(0, 0, 0, 0);
|
|
466
466
|
if (level === 'month') {
|
|
467
467
|
if (firstDayOfMax) {
|
|
@@ -780,8 +780,8 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
780
780
|
};
|
|
781
781
|
}, [onChange]);
|
|
782
782
|
useEffect(() => {
|
|
783
|
-
if (min
|
|
784
|
-
let arr =
|
|
783
|
+
if (min) {
|
|
784
|
+
let arr = [];
|
|
785
785
|
const newMin = new Date(min).setHours(0, 0, 0, 0);
|
|
786
786
|
if (isBefore(newMin, values.current[0])) {
|
|
787
787
|
arr.push(newMin);
|
|
@@ -793,7 +793,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
793
793
|
update(arr);
|
|
794
794
|
}
|
|
795
795
|
}
|
|
796
|
-
if (max
|
|
796
|
+
if (max) {
|
|
797
797
|
let arr = [];
|
|
798
798
|
const newMax = max && new Date(max).setHours(0, 0, 0, 0);
|
|
799
799
|
if (isAfter(newMax, values.current[1])) {
|
|
@@ -822,7 +822,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
822
822
|
// }
|
|
823
823
|
|
|
824
824
|
if (isEnable) {
|
|
825
|
-
iconRef.current.childNodes[0].style.pointerEvents = 'none';
|
|
825
|
+
// iconRef.current.childNodes[0].style.pointerEvents = 'none';
|
|
826
826
|
closePicker();
|
|
827
827
|
}
|
|
828
828
|
return () => {
|
|
@@ -834,9 +834,9 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
834
834
|
// } else {
|
|
835
835
|
// iconRef.current.childNodes[0].style.pointerEvents = null;
|
|
836
836
|
// }
|
|
837
|
-
if (isEnable) {
|
|
838
|
-
|
|
839
|
-
}
|
|
837
|
+
// if (isEnable) {
|
|
838
|
+
// iconRef.current.childNodes[0].style.pointerEvents = null;
|
|
839
|
+
// }
|
|
840
840
|
closePicker();
|
|
841
841
|
};
|
|
842
842
|
}, [actionIconAt, clearAble, controls, disabled, displayFormat, max, min, pressESCToClose, readOnly, startFromZero, unitCount, viewType]);
|
|
@@ -853,7 +853,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
853
853
|
currentRef.instance = _instance;
|
|
854
854
|
return currentRef;
|
|
855
855
|
});
|
|
856
|
-
const iconComp = isEnable
|
|
856
|
+
const iconComp = isEnable ? jsx("div", {
|
|
857
857
|
css: IconAreaCSS,
|
|
858
858
|
ref: iconRef
|
|
859
859
|
}, jsx(ButtonIcon, {
|
|
@@ -868,7 +868,7 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
868
868
|
className: `${unique.icon} ${unique.icon}-cancel`,
|
|
869
869
|
viewBox: true,
|
|
870
870
|
name: 'Close'
|
|
871
|
-
}));
|
|
871
|
+
})) : null;
|
|
872
872
|
const endIcon = actionIconAt === 'end' && iconComp;
|
|
873
873
|
const startIcon = actionIconAt === 'start' && iconComp;
|
|
874
874
|
const footerMemo = jsx("div", {
|
|
@@ -927,18 +927,18 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
927
927
|
height: '226px',
|
|
928
928
|
margin: spacing([4.5, 0.5, 0])
|
|
929
929
|
}
|
|
930
|
-
}), rightCalendarComp), tooltipComp,
|
|
930
|
+
}), rightCalendarComp), tooltipComp, controls ? footerMemo : null);
|
|
931
931
|
return jsx(ControlComp, {
|
|
932
932
|
...props,
|
|
933
933
|
disabled: disabled,
|
|
934
934
|
error: error,
|
|
935
935
|
ref: ref,
|
|
936
936
|
style: style
|
|
937
|
-
},
|
|
937
|
+
}, label ? jsx(Label, {
|
|
938
938
|
...labelProps,
|
|
939
939
|
disabled: disabled,
|
|
940
940
|
required: required
|
|
941
|
-
}, label), jsx(InputBase, {
|
|
941
|
+
}, label) : null, jsx(InputBase, {
|
|
942
942
|
inputProps: {
|
|
943
943
|
placeholder: !readOnly && !disabled ? placeholder : '',
|
|
944
944
|
...inputProps
|
|
@@ -958,49 +958,49 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
958
958
|
className: 'non-effect allow-disabled'
|
|
959
959
|
},
|
|
960
960
|
endIcon: endIcon
|
|
961
|
-
}),
|
|
961
|
+
}), error ? jsx(HelperText, {
|
|
962
962
|
...helperTextProps,
|
|
963
963
|
disabled: disabled
|
|
964
|
-
}, error));
|
|
964
|
+
}, error) : null);
|
|
965
965
|
}));
|
|
966
966
|
const unique = {
|
|
967
967
|
backGr: 'DGN-UI-Portal',
|
|
968
|
-
close: 'DGN-UI-
|
|
969
|
-
cancel: 'DGN-UI-
|
|
970
|
-
confirm: 'DGN-UI-
|
|
971
|
-
divider: 'DGN-UI-
|
|
972
|
-
disabled: 'DGN-UI-
|
|
973
|
-
error: 'DGN-UI-
|
|
974
|
-
focus: 'DGN-UI-
|
|
975
|
-
footer: 'DGN-UI-
|
|
976
|
-
picker: 'DGN-UI-
|
|
968
|
+
close: 'DGN-UI-DateRangePicker-close',
|
|
969
|
+
cancel: 'DGN-UI-DateRangePicker-cancel',
|
|
970
|
+
confirm: 'DGN-UI-DateRangePicker-confirm',
|
|
971
|
+
divider: 'DGN-UI-DateRangePicker-Divider',
|
|
972
|
+
disabled: 'DGN-UI-DateRangePicker-disabled',
|
|
973
|
+
error: 'DGN-UI-DateRangePicker-error',
|
|
974
|
+
focus: 'DGN-UI-DateRangePicker-focus',
|
|
975
|
+
footer: 'DGN-UI-DateRangePicker-Footer',
|
|
976
|
+
picker: 'DGN-UI-DateRangePicker-Picker-' + randomString(6, {
|
|
977
977
|
allowSymbol: false
|
|
978
978
|
}),
|
|
979
|
-
wrapper: 'DGN-UI-
|
|
980
|
-
container: 'DGN-UI-
|
|
981
|
-
icon: 'DGN-UI-
|
|
982
|
-
tooltip: 'DGN-UI-
|
|
979
|
+
wrapper: 'DGN-UI-DateRangePicker-Wrapper',
|
|
980
|
+
container: 'DGN-UI-DateRangePicker',
|
|
981
|
+
icon: 'DGN-UI-DateRangePicker-Icon',
|
|
982
|
+
tooltip: 'DGN-UI-DateRangePicker-Tooltip',
|
|
983
983
|
navigator: {
|
|
984
|
-
navigator: 'DGN-UI-
|
|
985
|
-
around: 'DGN-UI-
|
|
986
|
-
center: 'DGN-UI-
|
|
984
|
+
navigator: 'DGN-UI-DateRangePicker-Navigator',
|
|
985
|
+
around: 'DGN-UI-DateRangePicker-Navigator-Around',
|
|
986
|
+
center: 'DGN-UI-DateRangePicker-Navigator-Center'
|
|
987
987
|
},
|
|
988
988
|
table: {
|
|
989
|
-
container: 'DGN-UI-
|
|
990
|
-
table: 'DGN-UI-
|
|
991
|
-
header: 'DGN-UI-
|
|
992
|
-
raw: 'DGN-UI-
|
|
993
|
-
data: 'DGN-UI-
|
|
989
|
+
container: 'DGN-UI-DateRangePicker-Table-Container',
|
|
990
|
+
table: 'DGN-UI-DateRangePicker-Table-Table',
|
|
991
|
+
header: 'DGN-UI-DateRangePicker-Table-Header',
|
|
992
|
+
raw: 'DGN-UI-DateRangePicker-Table-Raw',
|
|
993
|
+
data: 'DGN-UI-DateRangePicker-Table-Data'
|
|
994
994
|
},
|
|
995
995
|
day: {
|
|
996
|
-
day: 'DGN-UI-
|
|
997
|
-
week: 'DGN-UI-
|
|
998
|
-
today: 'DGN-UI-
|
|
999
|
-
active: 'DGN-UI-
|
|
1000
|
-
limit: 'DGN-UI-
|
|
1001
|
-
from: 'DGN-UI-
|
|
1002
|
-
to: 'DGN-UI-
|
|
1003
|
-
between: 'DGN-UI-
|
|
996
|
+
day: 'DGN-UI-DateRangePicker-Day',
|
|
997
|
+
week: 'DGN-UI-DateRangePicker-Week',
|
|
998
|
+
today: 'DGN-UI-DateRangePicker-Day-today',
|
|
999
|
+
active: 'DGN-UI-DateRangePicker-Day-active',
|
|
1000
|
+
limit: 'DGN-UI-DateRangePicker-Day-limit',
|
|
1001
|
+
from: 'DGN-UI-DateRangePicker-Day-from',
|
|
1002
|
+
to: 'DGN-UI-DateRangePicker-Day-to',
|
|
1003
|
+
between: 'DGN-UI-DateRangePicker-Day-between'
|
|
1004
1004
|
}
|
|
1005
1005
|
};
|
|
1006
1006
|
const hiddenStyle = {
|
|
@@ -1078,10 +1078,10 @@ const pickerCSS = {
|
|
|
1078
1078
|
z-index: ${zIndexCORE(3)};
|
|
1079
1079
|
}
|
|
1080
1080
|
@media only screen and (max-width: 599px) {
|
|
1081
|
-
|
|
1081
|
+
${parseMaxWidth(400)};
|
|
1082
1082
|
.${unique.wrapper} {
|
|
1083
1083
|
flex-direction: column;
|
|
1084
|
-
|
|
1084
|
+
${parseMinWidth(260)};
|
|
1085
1085
|
}
|
|
1086
1086
|
.${unique.divider} {
|
|
1087
1087
|
height: 1px !important;
|
|
@@ -1096,9 +1096,9 @@ const pickerCSS = {
|
|
|
1096
1096
|
${parseWidthHeight(width, 'max-content')};
|
|
1097
1097
|
${parseMinWidth(window.innerWidth <= 633 ? 300 : 633)};
|
|
1098
1098
|
${parseMaxWidth(805)};
|
|
1099
|
+
top: ${position.top}px;
|
|
1099
1100
|
left: ${position.left}px;
|
|
1100
1101
|
opacity: 0;
|
|
1101
|
-
top: ${position.top}px;
|
|
1102
1102
|
transform: scale(0);
|
|
1103
1103
|
transform-origin: ${position.transformOrigin};
|
|
1104
1104
|
transition: opacity 120ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, transform 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
@@ -1114,7 +1114,7 @@ const pickerCSS = {
|
|
|
1114
1114
|
transform: 'scale(0)'
|
|
1115
1115
|
}
|
|
1116
1116
|
};
|
|
1117
|
-
|
|
1117
|
+
DateRangePicker.defaultProps = {
|
|
1118
1118
|
actionIconAt: 'end',
|
|
1119
1119
|
clearAble: false,
|
|
1120
1120
|
controls: false,
|
|
@@ -1131,7 +1131,7 @@ DateRangePickerV2.defaultProps = {
|
|
|
1131
1131
|
unitCount: 'day',
|
|
1132
1132
|
viewType: 'underlined'
|
|
1133
1133
|
};
|
|
1134
|
-
|
|
1134
|
+
DateRangePicker.propTypes = {
|
|
1135
1135
|
/** Position of action icons. */
|
|
1136
1136
|
actionIconAt: PropTypes.oneOf(['end', 'start']),
|
|
1137
1137
|
/** If `true`, display the clear icon. */
|
|
@@ -1187,4 +1187,4 @@ DateRangePickerV2.propTypes = {
|
|
|
1187
1187
|
/** The variant to use. */
|
|
1188
1188
|
viewType: PropTypes.oneOf(['outlined', 'underlined'])
|
|
1189
1189
|
};
|
|
1190
|
-
export default
|
|
1190
|
+
export default DateRangePicker;
|
package/components/index.js
CHANGED
|
@@ -114,7 +114,7 @@ export { default as PopoverBody } from "./popover/body";
|
|
|
114
114
|
export { default as PopoverFooter } from "./popover/footer";
|
|
115
115
|
|
|
116
116
|
// POPUP
|
|
117
|
-
export { default as Popup } from "./popup";
|
|
117
|
+
export { default as Popup } from "./popup/v2";
|
|
118
118
|
export { default as PopupV2 } from "./popup/v2";
|
|
119
119
|
export { default as DangerPopup } from "./popup/danger_popup";
|
|
120
120
|
export { default as ProposalsPopup } from "./popup/proposals_popup";
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import {
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import { jsx, css } from '@emotion/core';
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
6
4
|
import OptionWrapper from "../others/option-wrapper";
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
7
7
|
import { flexCol, overflowAuto, positionRelative } from "../../styles/general";
|
|
8
|
+
import { useTheme } from "../../theme";
|
|
8
9
|
import { classNames } from "../../utils";
|
|
9
|
-
import theme from "../../theme/settings";
|
|
10
10
|
const {
|
|
11
11
|
colors: {
|
|
12
12
|
fill: {
|
|
13
|
-
'scrollbar-rest':
|
|
14
|
-
'scrollbar-active':
|
|
13
|
+
'scrollbar-rest': fillScrollbarRest,
|
|
14
|
+
'scrollbar-active': fillScrollbarActive
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
spacing
|
|
18
|
-
} =
|
|
18
|
+
} = useTheme();
|
|
19
19
|
const PopoverBody = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
20
20
|
action = {},
|
|
21
21
|
children,
|
|
@@ -54,11 +54,11 @@ const PopoverBodyCSS = css`
|
|
|
54
54
|
&::-webkit-scrollbar-thumb {
|
|
55
55
|
border-radius: 10px;
|
|
56
56
|
mix-blend-mode: normal;
|
|
57
|
-
background-color: ${
|
|
57
|
+
background-color: ${fillScrollbarRest};
|
|
58
58
|
background-clip: content-box;
|
|
59
59
|
border: 8px solid transparent;
|
|
60
60
|
:hover {
|
|
61
|
-
background-color: ${
|
|
61
|
+
background-color: ${fillScrollbarActive};
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
`;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import {
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import { jsx, css } from '@emotion/core';
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
6
4
|
import OptionWrapper from "../others/option-wrapper";
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
7
7
|
import { alignCenter, borderBox, flexRow, justifyEnd, parseWidth, positionRelative } from "../../styles/general";
|
|
8
|
+
import { useTheme } from "../../theme";
|
|
8
9
|
import { classNames } from "../../utils";
|
|
9
|
-
import theme from "../../theme/settings";
|
|
10
10
|
const {
|
|
11
11
|
colors: {
|
|
12
12
|
system: {
|
|
13
|
-
white
|
|
13
|
+
white: systemWhite
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
spacing
|
|
17
|
-
} =
|
|
17
|
+
} = useTheme();
|
|
18
18
|
const PopoverFooter = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
19
19
|
action = {},
|
|
20
20
|
boxShadow,
|
|
@@ -52,7 +52,7 @@ const PopoverFooterCSS = boxShadow => css`
|
|
|
52
52
|
${parseWidth('100%')};
|
|
53
53
|
min-height: 56px;
|
|
54
54
|
padding: ${spacing([4])};
|
|
55
|
-
background: ${
|
|
55
|
+
background: ${systemWhite};
|
|
56
56
|
border-radius: 0px 0px 4px 4px;
|
|
57
57
|
box-shadow: ${boxShadow ? '0px -2px 2px rgba(0, 0, 0, 0.1)' : 'none'};
|
|
58
58
|
order: 3;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { jsx, css } from '@emotion/core';
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import { Typography } from "./..";
|
|
6
5
|
import OptionWrapper from "../others/option-wrapper";
|
|
7
|
-
import
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
8
8
|
import { alignCenter, borderBox, flexRow, parseWidthHeight, positionRelative } from "../../styles/general";
|
|
9
|
+
import { useTheme } from "../../theme";
|
|
9
10
|
import { classNames } from "../../utils";
|
|
10
|
-
import theme from "../../theme/settings";
|
|
11
11
|
const {
|
|
12
12
|
colors: {
|
|
13
13
|
fill: {
|
|
14
|
-
headerbar
|
|
14
|
+
headerbar: fillHeaderbar
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
spacing,
|
|
18
18
|
zIndex: zIndexCORE
|
|
19
|
-
} =
|
|
19
|
+
} = useTheme();
|
|
20
20
|
const PopoverHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
21
21
|
action = {},
|
|
22
22
|
children,
|
|
@@ -58,7 +58,7 @@ const PopoverHeaderCSS = css`
|
|
|
58
58
|
${positionRelative};
|
|
59
59
|
${borderBox};
|
|
60
60
|
${parseWidthHeight('100%', 56)};
|
|
61
|
-
background-color: ${
|
|
61
|
+
background-color: ${fillHeaderbar};
|
|
62
62
|
padding: ${spacing([4])};
|
|
63
63
|
border-radius: 4px 4px 0px 0px;
|
|
64
64
|
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.25);
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import
|
|
4
|
-
import { createPortal } from 'react-dom';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
|
-
import { jsx, css } from '@emotion/core';
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
7
4
|
import OptionWrapper from "../others/option-wrapper";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import React, { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
7
|
+
import { createPortal } from 'react-dom';
|
|
8
|
+
import { borderRadius4px, displayBlock, flexCol, justifyBetween, overflowAuto, parseMaxWidthHeight, parseMinWidthHeight, parseWidthHeight, positionAbsolute, positionFixed, positionRelative } from "../../styles/general";
|
|
9
|
+
import { useTheme } from "../../theme";
|
|
10
10
|
import { classNames, isMobile, refType as ref } from "../../utils";
|
|
11
11
|
const {
|
|
12
12
|
colors: {
|
|
13
13
|
system: {
|
|
14
|
-
white
|
|
14
|
+
white: systemWhite
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
typography: {
|
|
@@ -19,7 +19,7 @@ const {
|
|
|
19
19
|
},
|
|
20
20
|
spacing,
|
|
21
21
|
zIndex: zIndexCORE
|
|
22
|
-
} =
|
|
22
|
+
} = useTheme();
|
|
23
23
|
const eventMap = new Map([['click', ['click']], ['hover', ['mouseenter', 'mouseleave']], ['focus', ['focus', 'blur']]]);
|
|
24
24
|
const getArrowPosition = (anchorOrigin, transformOrigin, translate) => {
|
|
25
25
|
if (anchorOrigin.horizontal === 'right' && transformOrigin.horizontal === 'left') {
|
|
@@ -142,6 +142,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
142
142
|
if (isMobile.any() && trigger === 'hover') trigger = 'click';
|
|
143
143
|
const ref = useRef(null);
|
|
144
144
|
const arrowRef = useRef(null);
|
|
145
|
+
const overflow = useRef(null);
|
|
145
146
|
const [openState, setOpenState] = useState(open);
|
|
146
147
|
const [element, setElement] = useState(null);
|
|
147
148
|
const _PortalPopoverCSS = PortalPopoverCSS(zIndex, fullScreen);
|
|
@@ -400,6 +401,8 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
400
401
|
}, [open]);
|
|
401
402
|
useEffect(() => {
|
|
402
403
|
if (openState && ref.current) {
|
|
404
|
+
overflow.current = document.body.style.overflow; // store overflow of <body /> before open
|
|
405
|
+
document.body.style.overflow = 'hidden';
|
|
403
406
|
// Position's anchor
|
|
404
407
|
updatePositionPopover();
|
|
405
408
|
|
|
@@ -414,6 +417,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
414
417
|
window.addEventListener('resize', updatePositionPopover);
|
|
415
418
|
if (trigger === 'hover') ref.current.addEventListener('mouseleave', handleEventTrigger, false);
|
|
416
419
|
return () => {
|
|
420
|
+
document.body.style.overflow = overflow.current; // reset overflow of <body /> before open
|
|
417
421
|
if (pressESCToClose) {
|
|
418
422
|
document.removeEventListener('keydown', pressESCHandler);
|
|
419
423
|
}
|
|
@@ -422,7 +426,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
422
426
|
if (trigger === 'hover' && ref.current) ref.current.removeEventListener('mouseleave', handleEventTrigger, false);
|
|
423
427
|
};
|
|
424
428
|
} else if (!openState) {
|
|
425
|
-
document.documentElement.style.overflow =
|
|
429
|
+
document.documentElement.style.overflow = overflow.current;
|
|
426
430
|
}
|
|
427
431
|
}, [openState]);
|
|
428
432
|
useEffect(() => {
|
|
@@ -503,10 +507,8 @@ const PopoverContainerCSS = (bgColor, width, height) => css`
|
|
|
503
507
|
${borderRadius4px};
|
|
504
508
|
${paragraph1};
|
|
505
509
|
${parseWidthHeight(width, height)};
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
max-width: calc(100% - ${spacing([8])});
|
|
509
|
-
max-height: calc(100% - ${spacing([8])});
|
|
510
|
+
${parseMinWidthHeight(spacing([4]))};
|
|
511
|
+
${parseMaxWidthHeight(`calc(100% - ${spacing([8])})`)};
|
|
510
512
|
transition: opacity 0.3s ease;
|
|
511
513
|
pointer-events: initial;
|
|
512
514
|
opacity: 0;
|
|
@@ -527,10 +529,10 @@ Popover.defaultProps = {
|
|
|
527
529
|
horizontal: 'center'
|
|
528
530
|
},
|
|
529
531
|
arrow: false,
|
|
530
|
-
bgColor:
|
|
532
|
+
bgColor: systemWhite,
|
|
531
533
|
className: '',
|
|
532
534
|
clickOutsideToClose: true,
|
|
533
|
-
fullScreen:
|
|
535
|
+
fullScreen: true,
|
|
534
536
|
height: 'max-content',
|
|
535
537
|
marginThreshold: spacing(4),
|
|
536
538
|
pressESCToClose: true,
|