diginet-core-ui 1.3.79-beta.4 → 1.3.80-beta.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/components/button/index.js +2 -4
- package/components/divider/index.js +1 -0
- package/components/form-control/attachment/index.js +3 -4
- 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 +20 -23
- package/components/popup/v2/index.js +122 -144
- package/package.json +1 -1
- package/readme.md +6 -0
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import { CircularProgress, Icon, Typography } from "./..";
|
|
5
|
+
import OptionWrapper from "../others/option-wrapper";
|
|
4
6
|
import PropTypes from 'prop-types';
|
|
5
7
|
import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
6
|
-
import { Typography } from "../";
|
|
7
|
-
import Icon from "../../icons";
|
|
8
8
|
import { detectColor, fade, hexToRGBA, hslToRgb, isColor, isColorName, rgbaToHexA, rgbToHex } from "../../styles/color-helper";
|
|
9
9
|
import * as allColors from "../../styles/colors";
|
|
10
10
|
import { alignCenter, backgroundTransparent, border, borderBox, borderNone, borderRadius4px, cursorPointer, flexRow, inlineFlex, justifyCenter, noBorder, noMargin, noPadding, outlineNone, overflowHidden, parseHeight, parseMinHeight, parseMinWidth, parseMinWidthHeight, parseWidthHeight, pointerEventsNone, positionRelative, userSelectNone } from "../../styles/general";
|
|
11
11
|
import { useColor as colors, useTheme } from "../../theme";
|
|
12
12
|
import { classNames, refType as ref } from "../../utils";
|
|
13
|
-
import OptionWrapper from "../others/option-wrapper";
|
|
14
|
-
import CircularProgress from "../progress/circular";
|
|
15
13
|
import Ripple from "./ripple-effect";
|
|
16
14
|
const {
|
|
17
15
|
colors: {
|
|
@@ -23,6 +23,7 @@ const Divider = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
23
23
|
style,
|
|
24
24
|
width
|
|
25
25
|
}, reference) => {
|
|
26
|
+
if (!reference) reference = useRef(null);
|
|
26
27
|
const ref = useRef(null);
|
|
27
28
|
const _DividerRoot = DividerRoot(color, width, height);
|
|
28
29
|
useImperativeHandle(reference, () => {
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import { ButtonIcon, HelperText, Label, LinearProgress, List, ListItem, ListItemText, ModalSample, Notify, Popover, Popup, ScrollBar, Slider, SliderItem, Typography } from "../..";
|
|
5
|
+
import { getGlobal } from "../../../global";
|
|
6
|
+
import { Another, Compressed, Image, Pdf, Presentation, Sheet, Word } from "../../../icons";
|
|
4
7
|
import PropTypes from 'prop-types';
|
|
5
8
|
import { forwardRef, Fragment, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
6
9
|
import ReactDOM from 'react-dom';
|
|
7
|
-
import { ButtonIcon, HelperText, LinearProgress, List, ListItem, ListItemText, ModalSample, Notify, Popover, Popup, ScrollBar, Slider, SliderItem, Typography } from "../../";
|
|
8
|
-
import { getGlobal } from "../../../global";
|
|
9
|
-
import { Another, Compressed, Image, Pdf, Presentation, Sheet, Word } from "../../../icons";
|
|
10
10
|
import { alignCenter, border, borderBox, borderRadius4px, borderRadius50, breakWord, cursorPointer, displayBlock, displayInlineBlock, displayNone, ellipsis, flexCol, flexRow, flexWrap, justifyBetween, justifyCenter, justifyStart, parseHeight, parseMaxHeight, parseMaxWidth, parseMaxWidthHeight, parseMinHeight, parseMinWidth, parseWidth, parseWidthHeight, pointerEventsNone, positionAbsolute, positionRelative, textCenter, userSelectNone } from "../../../styles/general";
|
|
11
11
|
import { makeStyles, useTheme } from "../../../theme";
|
|
12
12
|
import { classNames, date as moment, getFileType } from "../../../utils";
|
|
13
|
-
import Label from "../label";
|
|
14
13
|
const {
|
|
15
14
|
colors: {
|
|
16
15
|
system: {
|
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,20 +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
|
|
15
|
-
},
|
|
16
|
-
fill: {
|
|
17
|
-
tooltip: fillTooltip
|
|
14
|
+
white: systemWhite
|
|
18
15
|
}
|
|
19
16
|
},
|
|
20
17
|
typography: {
|
|
@@ -22,7 +19,7 @@ const {
|
|
|
22
19
|
},
|
|
23
20
|
spacing,
|
|
24
21
|
zIndex: zIndexCORE
|
|
25
|
-
} =
|
|
22
|
+
} = useTheme();
|
|
26
23
|
const eventMap = new Map([['click', ['click']], ['hover', ['mouseenter', 'mouseleave']], ['focus', ['focus', 'blur']]]);
|
|
27
24
|
const getArrowPosition = (anchorOrigin, transformOrigin, translate) => {
|
|
28
25
|
if (anchorOrigin.horizontal === 'right' && transformOrigin.horizontal === 'left') {
|
|
@@ -120,7 +117,6 @@ const getDirectionPopover = direction => {
|
|
|
120
117
|
};
|
|
121
118
|
}
|
|
122
119
|
};
|
|
123
|
-
const backgroundMap = new Map([['light', white], ['dark', fillTooltip]]);
|
|
124
120
|
const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
125
121
|
action = {},
|
|
126
122
|
anchor,
|
|
@@ -146,6 +142,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
146
142
|
if (isMobile.any() && trigger === 'hover') trigger = 'click';
|
|
147
143
|
const ref = useRef(null);
|
|
148
144
|
const arrowRef = useRef(null);
|
|
145
|
+
const overflow = useRef(null);
|
|
149
146
|
const [openState, setOpenState] = useState(open);
|
|
150
147
|
const [element, setElement] = useState(null);
|
|
151
148
|
const _PortalPopoverCSS = PortalPopoverCSS(zIndex, fullScreen);
|
|
@@ -404,6 +401,8 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
404
401
|
}, [open]);
|
|
405
402
|
useEffect(() => {
|
|
406
403
|
if (openState && ref.current) {
|
|
404
|
+
overflow.current = document.body.style.overflow; // store overflow of <body /> before open
|
|
405
|
+
document.body.style.overflow = 'hidden';
|
|
407
406
|
// Position's anchor
|
|
408
407
|
updatePositionPopover();
|
|
409
408
|
|
|
@@ -418,6 +417,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
418
417
|
window.addEventListener('resize', updatePositionPopover);
|
|
419
418
|
if (trigger === 'hover') ref.current.addEventListener('mouseleave', handleEventTrigger, false);
|
|
420
419
|
return () => {
|
|
420
|
+
document.body.style.overflow = overflow.current; // reset overflow of <body /> before open
|
|
421
421
|
if (pressESCToClose) {
|
|
422
422
|
document.removeEventListener('keydown', pressESCHandler);
|
|
423
423
|
}
|
|
@@ -426,7 +426,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
426
426
|
if (trigger === 'hover' && ref.current) ref.current.removeEventListener('mouseleave', handleEventTrigger, false);
|
|
427
427
|
};
|
|
428
428
|
} else if (!openState) {
|
|
429
|
-
document.documentElement.style.overflow =
|
|
429
|
+
document.documentElement.style.overflow = overflow.current;
|
|
430
430
|
}
|
|
431
431
|
}, [openState]);
|
|
432
432
|
useEffect(() => {
|
|
@@ -507,16 +507,13 @@ const PopoverContainerCSS = (bgColor, width, height) => css`
|
|
|
507
507
|
${borderRadius4px};
|
|
508
508
|
${paragraph1};
|
|
509
509
|
${parseWidthHeight(width, height)};
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
max-width: calc(100% - ${spacing([8])});
|
|
513
|
-
max-height: calc(100% - ${spacing([8])});
|
|
510
|
+
${parseMinWidthHeight(spacing([4]))};
|
|
511
|
+
${parseMaxWidthHeight(`calc(100% - ${spacing([8])})`)};
|
|
514
512
|
transition: opacity 0.3s ease;
|
|
515
513
|
pointer-events: initial;
|
|
516
514
|
opacity: 0;
|
|
517
|
-
background-color: ${
|
|
515
|
+
background-color: ${bgColor};
|
|
518
516
|
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
|
519
|
-
${bgColor === 'dark' && `color: ${white};`}
|
|
520
517
|
`;
|
|
521
518
|
const PopoverArrowCSS = bgColor => css`
|
|
522
519
|
${displayBlock};
|
|
@@ -524,7 +521,7 @@ const PopoverArrowCSS = bgColor => css`
|
|
|
524
521
|
${parseWidthHeight(0)};
|
|
525
522
|
border-left: 6px solid transparent;
|
|
526
523
|
border-right: 6px solid transparent;
|
|
527
|
-
border-bottom: 6px solid ${
|
|
524
|
+
border-bottom: 6px solid ${bgColor};
|
|
528
525
|
`;
|
|
529
526
|
Popover.defaultProps = {
|
|
530
527
|
anchorOrigin: {
|
|
@@ -532,10 +529,10 @@ Popover.defaultProps = {
|
|
|
532
529
|
horizontal: 'center'
|
|
533
530
|
},
|
|
534
531
|
arrow: false,
|
|
535
|
-
bgColor:
|
|
532
|
+
bgColor: systemWhite,
|
|
536
533
|
className: '',
|
|
537
534
|
clickOutsideToClose: true,
|
|
538
|
-
fullScreen:
|
|
535
|
+
fullScreen: true,
|
|
539
536
|
height: 'max-content',
|
|
540
537
|
marginThreshold: spacing(4),
|
|
541
538
|
pressESCToClose: true,
|
|
@@ -566,7 +563,7 @@ Popover.propTypes = {
|
|
|
566
563
|
/** If `true`, arrow is shown. */
|
|
567
564
|
arrow: PropTypes.bool,
|
|
568
565
|
/** Background color of the component. */
|
|
569
|
-
bgColor: PropTypes.
|
|
566
|
+
bgColor: PropTypes.string,
|
|
570
567
|
/** The content of the component. */
|
|
571
568
|
children: PropTypes.node,
|
|
572
569
|
/** Class for component. */
|
|
@@ -1,61 +1,60 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
|
-
import { jsx, css } from '@emotion/core';
|
|
7
|
-
import useDelayUnmount from "../../../utils/useDelayUnmount";
|
|
8
|
-
import Icon from "../../../icons";
|
|
9
|
-
import { Button, ButtonIcon, Typography } from "../../";
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import { Button, ButtonIcon, Icon, Typography } from "../..";
|
|
10
5
|
import { getGlobal } from "../../../global";
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { forwardRef, Fragment, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
8
|
+
import { createPortal } from 'react-dom';
|
|
13
9
|
import { animations } from "../../../styles/animation";
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
10
|
+
import { hexToRGBA } from "../../../styles/color-helper";
|
|
11
|
+
import { alignCenter, border, borderBox, borderRadius4px, borderRadius50, breakWord, cursorPointer, displayBlock, ellipsis, flexCol, flexRow, justifyCenter, justifyEnd, overflowAuto, overflowHidden, parseHeight, parseMaxWidthHeight, parseMinHeight, parseMinWidth, parseWidth, parseWidthHeight, positionFixed, positionRelative } from "../../../styles/general";
|
|
12
|
+
import { useTheme } from "../../../theme";
|
|
13
|
+
import { classNames, refType as ref, useDelayUnmount } from "../../../utils";
|
|
16
14
|
const {
|
|
17
15
|
colors: {
|
|
18
16
|
system: {
|
|
19
|
-
white
|
|
17
|
+
white: systemWhite
|
|
20
18
|
},
|
|
21
19
|
semantic: {
|
|
22
|
-
success,
|
|
23
|
-
warning,
|
|
24
|
-
danger,
|
|
25
|
-
info
|
|
20
|
+
success: semanticSuccess,
|
|
21
|
+
warning: semanticWarning,
|
|
22
|
+
danger: semanticDanger,
|
|
23
|
+
info: semanticInfo
|
|
26
24
|
},
|
|
27
25
|
fill: {
|
|
28
|
-
'scrollbar-tabbar':
|
|
29
|
-
hover
|
|
26
|
+
'scrollbar-tabbar': fillScrollbarTabbar,
|
|
27
|
+
hover: fillHover
|
|
30
28
|
}
|
|
31
29
|
},
|
|
32
30
|
spacing,
|
|
33
31
|
zIndex: zIndexCORE
|
|
34
|
-
} =
|
|
35
|
-
const colorMap = new Map([['yesno',
|
|
32
|
+
} = useTheme();
|
|
33
|
+
const colorMap = new Map([['yesno', semanticInfo], ['success', semanticSuccess], ['warning', semanticWarning], ['danger', semanticDanger], ['info', semanticInfo]]);
|
|
36
34
|
const titleMap = new Map([['yesno', 'notify'], ['success', 'confirm'], ['warning', 'warning'], ['danger', 'error'], ['info', 'notify']]);
|
|
37
35
|
const iconMap = new Map([['yesno', 'Info'], ['success', 'ApprovalFilled'], ['warning', 'Warning'], ['danger', 'Failed'], ['info', 'Info']]);
|
|
38
36
|
const fadeInDown = animations.fadeInDown;
|
|
39
37
|
const fadeOutUp = animations.fadeOutUp;
|
|
40
38
|
const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
icon,
|
|
44
|
-
title,
|
|
45
|
-
subtitle,
|
|
46
|
-
description,
|
|
47
|
-
pressESCToClose,
|
|
39
|
+
action = {},
|
|
40
|
+
cancelProps,
|
|
48
41
|
className,
|
|
49
|
-
|
|
42
|
+
confirmProps,
|
|
43
|
+
description,
|
|
44
|
+
icon,
|
|
45
|
+
noText,
|
|
46
|
+
onCancel,
|
|
50
47
|
onClose,
|
|
51
48
|
onConfirm,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
open,
|
|
50
|
+
pressESCToClose,
|
|
51
|
+
style,
|
|
52
|
+
subtitle,
|
|
53
|
+
title,
|
|
56
54
|
top,
|
|
55
|
+
type,
|
|
56
|
+
width,
|
|
57
57
|
yesText,
|
|
58
|
-
noText,
|
|
59
58
|
...props
|
|
60
59
|
}, reference) => {
|
|
61
60
|
const ref = useRef(null);
|
|
@@ -73,7 +72,6 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
73
72
|
};
|
|
74
73
|
const onShowPopup = (options, cb) => {
|
|
75
74
|
if (options && typeof options === 'object' && Object.keys(options).length) {
|
|
76
|
-
var _newProps$title;
|
|
77
75
|
const newProps = {
|
|
78
76
|
type: options.type !== undefined ? options.type : type,
|
|
79
77
|
title: options.title !== undefined ? options.title : title,
|
|
@@ -86,19 +84,7 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
86
84
|
onCancel: cb ? () => cb(false) : options.onCancel !== undefined ? options.onCancel : onCancel,
|
|
87
85
|
onConfirm: cb ? () => cb(true) : options.onConfirm !== undefined ? options.onConfirm : onConfirm
|
|
88
86
|
};
|
|
89
|
-
const popup = jsx(Fragment, null, jsx("div", {
|
|
90
|
-
className: 'DGN-UI-Popup-Header ' + 'DGN-' + capitalize(newProps.type)
|
|
91
|
-
}, jsx(Typography, {
|
|
92
|
-
className: 'DGN-UI-Popup-Header-Title',
|
|
93
|
-
type: 'h3',
|
|
94
|
-
color: 'inherit'
|
|
95
|
-
}, (_newProps$title = newProps.title) !== null && _newProps$title !== void 0 ? _newProps$title : getGlobal(titleMap.get(newProps.type))), jsx(ButtonIcon, {
|
|
96
|
-
circular: true,
|
|
97
|
-
viewType: 'text',
|
|
98
|
-
color: type === 'yesno' ? 'info' : type,
|
|
99
|
-
name: 'Close',
|
|
100
|
-
onClick: () => onClosePopup('isClose')
|
|
101
|
-
})), jsx("div", {
|
|
87
|
+
const popup = jsx(Fragment, null, PopupHeaderView(newProps.title, newProps.type), jsx("div", {
|
|
102
88
|
className: 'DGN-UI-Popup-Body'
|
|
103
89
|
}, newProps.icon !== false && jsx("div", {
|
|
104
90
|
className: 'DGN-UI-Popup-Body-Icon'
|
|
@@ -111,21 +97,7 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
111
97
|
className: 'DGN-UI-Popup-Body-Description'
|
|
112
98
|
}, jsx(Typography, {
|
|
113
99
|
type: 'p2'
|
|
114
|
-
}, newProps.description))), (newProps.onConfirm
|
|
115
|
-
className: 'DGN-UI-Popup-Action'
|
|
116
|
-
}, (newProps.onConfirm || newProps.type === 'yesno') && jsx(Button, {
|
|
117
|
-
viewType: 'filled',
|
|
118
|
-
label: newProps.yesText || getGlobal('ok').toUpperCase(),
|
|
119
|
-
color: newProps.type,
|
|
120
|
-
onClick: newProps.onConfirm,
|
|
121
|
-
...newProps.confirmProps
|
|
122
|
-
}), (newProps.onCancel || newProps.type === 'yesno') && jsx(Button, {
|
|
123
|
-
viewType: 'outlined',
|
|
124
|
-
label: newProps.noText || getGlobal('cancel').toUpperCase(),
|
|
125
|
-
color: newProps.type,
|
|
126
|
-
onClick: newProps.onCancel,
|
|
127
|
-
...newProps.cancelProps
|
|
128
|
-
})));
|
|
100
|
+
}, newProps.description))), PopupActionView(newProps.onConfirm, newProps.confirmProps, newProps.onCancel, newProps.cancelProps, newProps.type, newProps.yesText, newProps.noText));
|
|
129
101
|
setCustom(popup);
|
|
130
102
|
} else {
|
|
131
103
|
setCustom(false);
|
|
@@ -175,7 +147,8 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
175
147
|
const currentRef = ref.current || {};
|
|
176
148
|
const _instance = {
|
|
177
149
|
show: onShowPopup,
|
|
178
|
-
close: onClosePopup
|
|
150
|
+
close: onClosePopup,
|
|
151
|
+
...action
|
|
179
152
|
}; // methods
|
|
180
153
|
_instance.__proto__ = {}; // hidden methods
|
|
181
154
|
currentRef.instance = _instance;
|
|
@@ -183,77 +156,86 @@ const Popup = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
183
156
|
currentRef.close = onClosePopup;
|
|
184
157
|
return currentRef;
|
|
185
158
|
});
|
|
159
|
+
const PopupHeaderView = (title, type) => {
|
|
160
|
+
return jsx("div", {
|
|
161
|
+
className: 'DGN-UI-Popup-Header'
|
|
162
|
+
}, jsx(Typography, {
|
|
163
|
+
className: 'DGN-UI-Popup-Header-Title',
|
|
164
|
+
type: 'h3',
|
|
165
|
+
color: 'inherit'
|
|
166
|
+
}, title !== null && title !== void 0 ? title : getGlobal(titleMap.get(type))), jsx(ButtonIcon, {
|
|
167
|
+
circular: true,
|
|
168
|
+
viewType: 'text',
|
|
169
|
+
color: type === 'yesno' ? 'info' : type,
|
|
170
|
+
name: 'Close',
|
|
171
|
+
onClick: () => onClosePopup('isClose')
|
|
172
|
+
}));
|
|
173
|
+
};
|
|
174
|
+
const PopupBodyView = (icon, type, subtitle, description) => {
|
|
175
|
+
return jsx("div", {
|
|
176
|
+
className: 'DGN-UI-Popup-Body'
|
|
177
|
+
}, icon !== false && jsx("div", {
|
|
178
|
+
className: 'DGN-UI-Popup-Body-Icon'
|
|
179
|
+
}, jsx(Icon, {
|
|
180
|
+
name: icon === true ? iconMap.get(type) : icon,
|
|
181
|
+
width: 40,
|
|
182
|
+
height: 40,
|
|
183
|
+
color: colorMap.get(type)
|
|
184
|
+
})), jsx("div", {
|
|
185
|
+
className: 'DGN-UI-Popup-Body-Description'
|
|
186
|
+
}, jsx(Typography, {
|
|
187
|
+
type: 'p2'
|
|
188
|
+
}, subtitle && jsx(Typography, {
|
|
189
|
+
className: 'DGN-UI-Popup-Body-Subtitle',
|
|
190
|
+
fullWidth: true
|
|
191
|
+
}, subtitle), jsx(Typography, {
|
|
192
|
+
ref: onRefChange,
|
|
193
|
+
type: 'p2',
|
|
194
|
+
className: 'DGN-UI-Popup-Body-Detail'
|
|
195
|
+
}, description), (subtitle && descriptionLines > 1 || descriptionLines > 3) && jsx("span", {
|
|
196
|
+
className: 'DGN-More-Action',
|
|
197
|
+
onClick: () => setShowMoreDescription(!showMoreDescription)
|
|
198
|
+
}, getGlobal(showMoreDescription ? 'showLess' : 'showMore')))));
|
|
199
|
+
};
|
|
200
|
+
const PopupActionView = (onConfirm, confirmProps, onCancel, cancelProps, type, yesText, noText) => {
|
|
201
|
+
return onConfirm || onCancel || type === 'yesno' ? jsx("div", {
|
|
202
|
+
className: 'DGN-UI-Popup-Action'
|
|
203
|
+
}, onConfirm || type === 'yesno' ? jsx(Button, {
|
|
204
|
+
viewType: 'filled',
|
|
205
|
+
label: yesText || getGlobal('ok').toUpperCase(),
|
|
206
|
+
color: type === 'yesno' ? 'info' : type,
|
|
207
|
+
onClick: () => {
|
|
208
|
+
onClosePopup('isConfirm');
|
|
209
|
+
onConfirm && onConfirm();
|
|
210
|
+
},
|
|
211
|
+
...confirmProps
|
|
212
|
+
}) : null, onCancel || type === 'yesno' ? jsx(Button, {
|
|
213
|
+
viewType: 'outlined',
|
|
214
|
+
label: noText || getGlobal('cancel').toUpperCase(),
|
|
215
|
+
color: type === 'yesno' ? 'info' : type,
|
|
216
|
+
onClick: () => {
|
|
217
|
+
onClosePopup('isCancel');
|
|
218
|
+
onCancel && onCancel();
|
|
219
|
+
},
|
|
220
|
+
...cancelProps
|
|
221
|
+
}) : null) : null;
|
|
222
|
+
};
|
|
186
223
|
return showPopup && /*#__PURE__*/createPortal(jsx("div", {
|
|
187
224
|
css: _PopupRootCSS,
|
|
188
225
|
ref: ref,
|
|
189
226
|
style: style,
|
|
190
|
-
className:
|
|
227
|
+
className: classNames('DGN-UI-Portal DGN-UI-Popup-Portal', className)
|
|
191
228
|
}, jsx("div", {
|
|
192
229
|
className: `DGN-UI-Popup ${openState ? 'DGN-Show' : 'DGN-Hide'}`,
|
|
193
230
|
...props
|
|
194
|
-
}, custom ? custom : jsx(Fragment, null,
|
|
195
|
-
className: 'DGN-UI-Popup-Header ' + 'DGN-' + capitalize(type)
|
|
196
|
-
}, jsx(Typography, {
|
|
197
|
-
className: 'DGN-UI-Popup-Header-Title',
|
|
198
|
-
type: 'h3',
|
|
199
|
-
color: 'inherit'
|
|
200
|
-
}, title !== null && title !== void 0 ? title : getGlobal(titleMap.get(type))), jsx(ButtonIcon, {
|
|
201
|
-
circular: true,
|
|
202
|
-
viewType: 'text',
|
|
203
|
-
color: type === 'yesno' ? 'info' : type,
|
|
204
|
-
name: 'Close',
|
|
205
|
-
onClick: () => onClosePopup('isClose')
|
|
206
|
-
})), jsx("div", {
|
|
207
|
-
className: 'DGN-UI-Popup-Body'
|
|
208
|
-
}, icon !== false && jsx("div", {
|
|
209
|
-
className: 'DGN-UI-Popup-Body-Icon'
|
|
210
|
-
}, jsx(Icon, {
|
|
211
|
-
name: icon === true ? iconMap.get(type) : icon,
|
|
212
|
-
width: 40,
|
|
213
|
-
height: 40,
|
|
214
|
-
color: colorMap.get(type)
|
|
215
|
-
})), jsx("div", {
|
|
216
|
-
className: 'DGN-UI-Popup-Body-Description'
|
|
217
|
-
}, jsx(Typography, {
|
|
218
|
-
type: 'p2'
|
|
219
|
-
}, subtitle && jsx(Typography, {
|
|
220
|
-
className: 'DGN-UI-Popup-Body-Subtitle',
|
|
221
|
-
fullWidth: true
|
|
222
|
-
}, subtitle), jsx(Typography, {
|
|
223
|
-
ref: onRefChange,
|
|
224
|
-
type: 'p2',
|
|
225
|
-
className: 'DGN-UI-Popup-Body-Detail'
|
|
226
|
-
}, description), (subtitle && descriptionLines > 1 || descriptionLines > 3) && jsx("span", {
|
|
227
|
-
className: 'DGN-More-Action',
|
|
228
|
-
onClick: () => setShowMoreDescription(!showMoreDescription)
|
|
229
|
-
}, getGlobal(showMoreDescription ? 'showLess' : 'showMore'))))), (onConfirm || onCancel || type === 'yesno') && jsx("div", {
|
|
230
|
-
className: 'DGN-UI-Popup-Action'
|
|
231
|
-
}, (onConfirm || type === 'yesno') && jsx(Button, {
|
|
232
|
-
viewType: 'filled',
|
|
233
|
-
label: yesText || getGlobal('ok'),
|
|
234
|
-
color: type === 'yesno' ? 'info' : type,
|
|
235
|
-
onClick: () => {
|
|
236
|
-
onClosePopup('isConfirm');
|
|
237
|
-
onConfirm && onConfirm();
|
|
238
|
-
},
|
|
239
|
-
...confirmProps
|
|
240
|
-
}), (onCancel || type === 'yesno') && jsx(Button, {
|
|
241
|
-
viewType: 'outlined',
|
|
242
|
-
label: noText || getGlobal('cancel'),
|
|
243
|
-
color: type === 'yesno' ? 'info' : type,
|
|
244
|
-
onClick: () => {
|
|
245
|
-
onClosePopup('isCancel');
|
|
246
|
-
onCancel && onCancel();
|
|
247
|
-
},
|
|
248
|
-
...cancelProps
|
|
249
|
-
}))))), document.body);
|
|
231
|
+
}, custom ? custom : jsx(Fragment, null, PopupHeaderView(title, type), PopupBodyView(icon, type, subtitle, description), PopupActionView(onConfirm, confirmProps, onCancel, cancelProps, type, yesText, noText)))), document.body);
|
|
250
232
|
}));
|
|
251
233
|
const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescription, descriptionLines) => css`
|
|
252
234
|
${flexRow};
|
|
253
235
|
${positionFixed};
|
|
254
236
|
${justifyCenter};
|
|
255
237
|
${breakWord};
|
|
256
|
-
${parseWidthHeight('100%')}
|
|
238
|
+
${parseWidthHeight('100%')};
|
|
257
239
|
top: 0;
|
|
258
240
|
left: 0;
|
|
259
241
|
inset: 0;
|
|
@@ -263,12 +245,10 @@ const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescripti
|
|
|
263
245
|
${flexCol};
|
|
264
246
|
${borderRadius4px};
|
|
265
247
|
${borderBox};
|
|
266
|
-
${
|
|
267
|
-
|
|
268
|
-
max-width: 80%;
|
|
269
|
-
max-height: 80%;
|
|
248
|
+
${parseWidthHeight(width, 'fit-content')};
|
|
249
|
+
${parseMaxWidthHeight('80%')};
|
|
270
250
|
margin: ${isNaN(top) ? top : top + 'px'} auto auto;
|
|
271
|
-
background-color: ${
|
|
251
|
+
background-color: ${systemWhite};
|
|
272
252
|
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.25);
|
|
273
253
|
&.DGN-Show {
|
|
274
254
|
animation: ${fadeInDown} 0.2s ease;
|
|
@@ -280,13 +260,13 @@ const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescripti
|
|
|
280
260
|
.DGN-UI-Popup-Header {
|
|
281
261
|
${flexRow};
|
|
282
262
|
${alignCenter};
|
|
283
|
-
|
|
263
|
+
${parseMinHeight(40)};
|
|
284
264
|
padding: ${spacing([0, 2, 0, 4])};
|
|
285
265
|
border-radius: 4px 4px 0px 0px;
|
|
286
266
|
.DGN-UI-Popup-Header-Title {
|
|
287
267
|
${flexRow};
|
|
288
268
|
${ellipsis};
|
|
289
|
-
|
|
269
|
+
${parseWidth('calc(100% - 24px)')};
|
|
290
270
|
}
|
|
291
271
|
color: ${colorMap.get(type)};
|
|
292
272
|
background-color: ${hexToRGBA(colorMap.get(type), 0.15)};
|
|
@@ -300,34 +280,34 @@ const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescripti
|
|
|
300
280
|
&::-webkit-scrollbar {
|
|
301
281
|
${borderRadius4px};
|
|
302
282
|
${parseWidth(24)};
|
|
303
|
-
background-color: ${
|
|
283
|
+
background-color: ${systemWhite} !important;
|
|
304
284
|
}
|
|
305
285
|
&::-webkit-scrollbar-thumb {
|
|
306
286
|
${border(8, 'transparent')};
|
|
307
287
|
border-radius: 24px;
|
|
308
288
|
mix-blend-mode: normal;
|
|
309
|
-
background-color: ${
|
|
289
|
+
background-color: ${fillScrollbarTabbar} !important;
|
|
310
290
|
background-clip: content-box;
|
|
311
291
|
}
|
|
312
292
|
&::-webkit-scrollbar-thumb:hover {
|
|
313
293
|
${border(8, 'transparent')};
|
|
314
294
|
border-radius: 24px;
|
|
315
295
|
mix-blend-mode: normal;
|
|
316
|
-
background-color: ${
|
|
296
|
+
background-color: ${fillHover} !important;
|
|
317
297
|
background-clip: content-box;
|
|
318
298
|
}
|
|
319
299
|
.DGN-UI-Popup-Body-Icon {
|
|
320
300
|
${displayBlock};
|
|
301
|
+
${borderRadius50};
|
|
321
302
|
${parseWidth(40)};
|
|
322
303
|
margin-right: ${spacing([4])};
|
|
323
|
-
border-radius: 50%;
|
|
324
304
|
}
|
|
325
305
|
.DGN-UI-Popup-Body-Description {
|
|
326
306
|
${flexRow};
|
|
327
307
|
${positionRelative};
|
|
328
308
|
${alignCenter};
|
|
329
|
-
|
|
330
|
-
|
|
309
|
+
${parseMinHeight(40)};
|
|
310
|
+
${parseHeight('max-content')};
|
|
331
311
|
.DGN-UI-Popup-Body-Subtitle {
|
|
332
312
|
margin-bottom: ${(description === null || description === void 0 ? void 0 : description.length) > 0 ? spacing([2]) : spacing([0])};
|
|
333
313
|
}
|
|
@@ -345,7 +325,7 @@ const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescripti
|
|
|
345
325
|
margin-top: ${spacing([4])};
|
|
346
326
|
margin-bottom: ${type === 'yesno' ? spacing([0]) : spacing([2])};
|
|
347
327
|
text-decoration: underline;
|
|
348
|
-
color: ${
|
|
328
|
+
color: ${semanticInfo};
|
|
349
329
|
}
|
|
350
330
|
}
|
|
351
331
|
}
|
|
@@ -354,8 +334,8 @@ const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescripti
|
|
|
354
334
|
${justifyEnd};
|
|
355
335
|
padding: ${spacing([2, 4, 4, 4])};
|
|
356
336
|
.DGN-UI-Button {
|
|
337
|
+
${parseMinWidth(80)};
|
|
357
338
|
margin: 0;
|
|
358
|
-
min-width: 80px;
|
|
359
339
|
&.filled {
|
|
360
340
|
margin-right: ${spacing([2])};
|
|
361
341
|
}
|
|
@@ -364,14 +344,14 @@ const PopupRootCSS = (width, top, type, description, subtitle, showMoreDescripti
|
|
|
364
344
|
}
|
|
365
345
|
`;
|
|
366
346
|
Popup.defaultProps = {
|
|
347
|
+
className: '',
|
|
348
|
+
icon: true,
|
|
367
349
|
open: false,
|
|
368
350
|
pressESCToClose: false,
|
|
369
|
-
|
|
370
|
-
width: 480,
|
|
351
|
+
style: {},
|
|
371
352
|
top: 56,
|
|
372
353
|
type: 'info',
|
|
373
|
-
|
|
374
|
-
style: {}
|
|
354
|
+
width: 480
|
|
375
355
|
};
|
|
376
356
|
Popup.propTypes = {
|
|
377
357
|
/** If `true`, the component is shown. */
|
|
@@ -383,7 +363,7 @@ Popup.propTypes = {
|
|
|
383
363
|
/** [Props](https://core.diginet.com.vn/ui/?path=/story/button) applied to the confirm `Button`. */
|
|
384
364
|
confirmProps: PropTypes.object,
|
|
385
365
|
/** Details content of the component. */
|
|
386
|
-
description: PropTypes.string,
|
|
366
|
+
description: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
|
|
387
367
|
/** [Icon](https://core.diginet.com.vn/ui/?path=/story/icon-basic) display before content. */
|
|
388
368
|
icon: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
389
369
|
/** Label of cancel button. */
|
|
@@ -422,8 +402,6 @@ Popup.propTypes = {
|
|
|
422
402
|
* * Callback fired after click on button (callback(true) with confirm Button and callback(false) with cancel Button). Alternate both onCancel, onConfirm methods of options
|
|
423
403
|
* * close(): Close popup
|
|
424
404
|
*/
|
|
425
|
-
reference:
|
|
426
|
-
current: PropTypes.instanceOf(Element)
|
|
427
|
-
})])
|
|
405
|
+
reference: ref
|
|
428
406
|
};
|
|
429
407
|
export default Popup;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -38,6 +38,12 @@ npm test
|
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Changelog
|
|
41
|
+
## 1.3.80
|
|
42
|
+
- \[Changed\]: ButtonMore – Update Button More with new design
|
|
43
|
+
- \[Changed\]: BABEL – Add babel-plugin-module-resolver
|
|
44
|
+
- \[Changed\]: NumberInput – Add viewType none
|
|
45
|
+
- \[Changed\]: CircularProgress – Allow prop size accept number value; Optimize code
|
|
46
|
+
|
|
41
47
|
## 1.3.79
|
|
42
48
|
- \[Changed\]: Button – Add prop labelProps; Allow use CUI colors
|
|
43
49
|
- \[Changed\]: InputBase – Add startIcon, endIcon to multiline textarea; Add viewType none; Optimize code
|