diginet-core-ui 1.3.97 → 1.3.98
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/image/default.png +0 -0
- package/components/breadcrumb/index.js +19 -21
- package/components/form-control/date-range-picker/index.js +15 -8
- package/components/form-control/dropdown/index.js +43 -43
- package/components/image/index.js +7 -4
- package/components/modal/modal.js +26 -22
- package/components/popover/index.js +21 -9
- package/components/typography/index.js +29 -41
- package/icons/basic.js +110 -546
- package/icons/effect.js +2 -1
- package/package.json +1 -1
- package/readme.md +10 -0
- package/utils/renderHTML.js +1 -1
|
Binary file
|
|
@@ -87,27 +87,24 @@ const Breadcrumb = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
87
87
|
// <ButtonIcon key="ellipsis" name={'MoreHoriz'} width={24} height={16} onClick={handleClickExpand} />,
|
|
88
88
|
...allItems.slice(allItems.length - itemsAfterCollapse, allItems.length)];
|
|
89
89
|
};
|
|
90
|
-
const allItems = data !== null && data !== void 0 && data.length ? data.map((item, idx) => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
onClick: item === null || item === void 0 ? void 0 : (_item$onClick2 = item.onClick) === null || _item$onClick2 === void 0 ? void 0 : _item$onClick2.call(item)
|
|
109
|
-
}, (item === null || item === void 0 ? void 0 : item.label) || (item === null || item === void 0 ? void 0 : item.name)), (data === null || data === void 0 ? void 0 : data.length) !== idx + 1 ? renderSeparator : null);
|
|
110
|
-
}) : React.Children.toArray(children).filter(child => {
|
|
90
|
+
const allItems = data !== null && data !== void 0 && data.length ? data.map((item, idx) => jsx("li", {
|
|
91
|
+
css: _BreadcrumbLiCSS,
|
|
92
|
+
className: 'DGN-UI-Breadcrumb-li',
|
|
93
|
+
key: `child-${idx}`
|
|
94
|
+
}, item !== null && item !== void 0 && item.icon ? jsx(Icon, {
|
|
95
|
+
className: 'DGN-UI-Breadcrumb-li-icon',
|
|
96
|
+
name: item === null || item === void 0 ? void 0 : item.icon,
|
|
97
|
+
color: color,
|
|
98
|
+
width: sizeIcon,
|
|
99
|
+
height: sizeIcon
|
|
100
|
+
}) : null, jsx(Typography, {
|
|
101
|
+
className: 'DGN-UI-Breadcrumb-li-label',
|
|
102
|
+
type: (data === null || data === void 0 ? void 0 : data.length) === idx + 1 ? sizeTypographyH : sizeTypographyP,
|
|
103
|
+
mapping: 'a',
|
|
104
|
+
color: 'currentColor',
|
|
105
|
+
href: item === null || item === void 0 ? void 0 : item.href,
|
|
106
|
+
onClick: item === null || item === void 0 ? void 0 : item.onClick
|
|
107
|
+
}, (item === null || item === void 0 ? void 0 : item.label) || (item === null || item === void 0 ? void 0 : item.name)), (data === null || data === void 0 ? void 0 : data.length) !== idx + 1 ? renderSeparator : null)) : React.Children.toArray(children).filter(child => {
|
|
111
108
|
return /*#__PURE__*/React.isValidElement(child);
|
|
112
109
|
}).map((child, idx) => {
|
|
113
110
|
var _React$Children$toArr;
|
|
@@ -184,6 +181,7 @@ Breadcrumb.propTypes = {
|
|
|
184
181
|
/** Class for component. */
|
|
185
182
|
data: PropTypes.arrayOf(PropTypes.shape({
|
|
186
183
|
label: PropTypes.string,
|
|
184
|
+
icon: PropTypes.string,
|
|
187
185
|
href: PropTypes.string,
|
|
188
186
|
onClick: PropTypes.func
|
|
189
187
|
})),
|
|
@@ -7,7 +7,7 @@ import locale from "../../../locale";
|
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
9
9
|
import { render } from 'react-dom';
|
|
10
|
-
import { bgColor, borderRadius4px, cursorPointer, displayBlock, displayFlex, displayNone, flexCol, flexRow, invisible, justifyEnd, left, mg, parseHeight, parseMaxWidth, parseMinWidth,
|
|
10
|
+
import { bgColor, borderRadius4px, cursorPointer, displayBlock, displayFlex, displayNone, flexCol, flexRow, invisible, justifyEnd, left, mg, parseHeight, parseMaxWidth, parseMinWidth, pd, pointerEventsNone, positionFixed, textCenter, top, userSelectNone, whiteSpaceNoWrap, z } from "../../../styles/general";
|
|
11
11
|
import { useTheme } from "../../../theme";
|
|
12
12
|
import { capitalizeSentenceCase, classNames, date as moment, isEqual, randomString, updatePosition } from "../../../utils";
|
|
13
13
|
import { generateCalendarCSS, onUpdateNavigator, renderHeader, renderNavigator } from "../calendar/function";
|
|
@@ -123,6 +123,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
123
123
|
const [, setValueFr] = useState(Date.now());
|
|
124
124
|
const [, setValueTo] = useState(Date.now());
|
|
125
125
|
const [, setSelected] = useState(Date.now());
|
|
126
|
+
const [valueState, setValueState] = useState();
|
|
126
127
|
const navigatorFromRefs = {
|
|
127
128
|
doubleLeft: useRef(null),
|
|
128
129
|
doubleRight: useRef(null),
|
|
@@ -332,7 +333,11 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
332
333
|
const timeFr = new Date(times[0]);
|
|
333
334
|
const timeTo = new Date(times[1]);
|
|
334
335
|
const from = new Date(timeFr.getFullYear(), timeFr.getMonth());
|
|
335
|
-
const to = new Date(timeTo.getFullYear(),
|
|
336
|
+
const to = new Date(timeTo.getFullYear(), timeTo.getMonth());
|
|
337
|
+
// const to = new Date(
|
|
338
|
+
// timeTo.getFullYear(),
|
|
339
|
+
// +moment(timeTo).diff(timeFr, 'months') === 0 ? timeTo.getMonth() + 1 : timeTo.getMonth()
|
|
340
|
+
// );
|
|
336
341
|
updateValueFr(from);
|
|
337
342
|
updateValueTo(to);
|
|
338
343
|
};
|
|
@@ -365,8 +370,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
365
370
|
const {
|
|
366
371
|
left,
|
|
367
372
|
height,
|
|
368
|
-
top
|
|
369
|
-
width
|
|
373
|
+
top
|
|
370
374
|
} = anchor instanceof Element ? anchor.getBoundingClientRect() : ref.current.getBoundingClientRect();
|
|
371
375
|
const pickerHeight = innerWidth < 567 ? controls ? 550 : 495 : controls ? 310 : 256;
|
|
372
376
|
let style = {};
|
|
@@ -388,7 +392,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
388
392
|
style.left = (innerWidth - pickerWidth) / 2;
|
|
389
393
|
}
|
|
390
394
|
}
|
|
391
|
-
return pickerCSS.picker(style
|
|
395
|
+
return pickerCSS.picker(style).styles;
|
|
392
396
|
};
|
|
393
397
|
const clearDayHovering = arr => {
|
|
394
398
|
if (values.current.length !== 2) {
|
|
@@ -740,6 +744,7 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
740
744
|
tempValue = formatValue(time, displayFormat);
|
|
741
745
|
}
|
|
742
746
|
el.value = capitalizeSentenceCase(tempValue);
|
|
747
|
+
setValueState(capitalizeSentenceCase(tempValue));
|
|
743
748
|
clearAble && onSwap(false);
|
|
744
749
|
};
|
|
745
750
|
const onClear = () => {
|
|
@@ -932,7 +937,9 @@ const DateRangePicker = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
932
937
|
startIconProps: {
|
|
933
938
|
className: 'non-effect allow-disabled'
|
|
934
939
|
},
|
|
935
|
-
endIcon: endIcon
|
|
940
|
+
endIcon: endIcon,
|
|
941
|
+
value: valueState,
|
|
942
|
+
onClick: onInputFocus
|
|
936
943
|
}), error ? jsx(HelperText, {
|
|
937
944
|
...helperTextProps,
|
|
938
945
|
disabled: disabled
|
|
@@ -1062,10 +1069,10 @@ const pickerCSS = {
|
|
|
1062
1069
|
}
|
|
1063
1070
|
}
|
|
1064
1071
|
`,
|
|
1065
|
-
picker:
|
|
1072
|
+
picker: position => css`
|
|
1066
1073
|
${borderRadius4px};
|
|
1067
1074
|
${positionFixed};
|
|
1068
|
-
${
|
|
1075
|
+
${parseHeight('max-content')};
|
|
1069
1076
|
${parseMinWidth(window.innerWidth <= 633 ? 300 : 633)};
|
|
1070
1077
|
${parseMaxWidth(805)};
|
|
1071
1078
|
${top(position.top)};
|
|
@@ -306,10 +306,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
306
306
|
// }
|
|
307
307
|
// };
|
|
308
308
|
|
|
309
|
-
/**
|
|
310
|
-
* So sánh text đầu vào cáo map với txtSearch
|
|
311
|
-
* @param text
|
|
312
|
-
* @return {boolean}
|
|
309
|
+
/**
|
|
310
|
+
* So sánh text đầu vào cáo map với txtSearch
|
|
311
|
+
* @param text
|
|
312
|
+
* @return {boolean}
|
|
313
313
|
*/
|
|
314
314
|
const handleRenderBySearch = (text = '') => {
|
|
315
315
|
if (!txtSearch || typeof text !== 'string') return true;
|
|
@@ -320,10 +320,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
320
320
|
} else return text.toLowerCase().includes(txtSearch.toLowerCase());
|
|
321
321
|
};
|
|
322
322
|
|
|
323
|
-
/**
|
|
324
|
-
* Chuyển đổi data thành giá trị cần hiện thị dựa vào displayExpr [string, string object {field} - {field}], renderSelectedItem, displayExpr, valueExpr
|
|
325
|
-
* @param data {object} rowData of dataSource
|
|
326
|
-
* @return {string}
|
|
323
|
+
/**
|
|
324
|
+
* Chuyển đổi data thành giá trị cần hiện thị dựa vào displayExpr [string, string object {field} - {field}], renderSelectedItem, displayExpr, valueExpr
|
|
325
|
+
* @param data {object} rowData of dataSource
|
|
326
|
+
* @return {string}
|
|
327
327
|
*/
|
|
328
328
|
const displayValue = data => {
|
|
329
329
|
let text = '';
|
|
@@ -1634,9 +1634,9 @@ Dropdown.propTypes = {
|
|
|
1634
1634
|
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1635
1635
|
/** If `true`, the component is disabled. */
|
|
1636
1636
|
disabled: PropTypes.bool,
|
|
1637
|
-
/** Field name used for text display in dropdown list.<br/>
|
|
1638
|
-
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1639
|
-
* Note: don't use 'id - name', return undefined
|
|
1637
|
+
/** Field name used for text display in dropdown list.<br/>
|
|
1638
|
+
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1639
|
+
* Note: don't use 'id - name', return undefined
|
|
1640
1640
|
*/
|
|
1641
1641
|
displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1642
1642
|
/** Style inline of dropdown items. */
|
|
@@ -1645,14 +1645,14 @@ Dropdown.propTypes = {
|
|
|
1645
1645
|
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
1646
1646
|
/** Props applied to the [HelperText](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) element. */
|
|
1647
1647
|
helperTextProps: PropTypes.object,
|
|
1648
|
-
/** Field name used for icon display.<br/>
|
|
1649
|
-
* Example:<br/>
|
|
1650
|
-
* string: 'icon'<br/>
|
|
1651
|
-
* object: {<br/>
|
|
1652
|
-
* key: 'icon',<br/>
|
|
1653
|
-
* prefix: 'https://imglink.com',<br/>
|
|
1654
|
-
* suffix: '.jpg'<br/>
|
|
1655
|
-
* }
|
|
1648
|
+
/** Field name used for icon display.<br/>
|
|
1649
|
+
* Example:<br/>
|
|
1650
|
+
* string: 'icon'<br/>
|
|
1651
|
+
* object: {<br/>
|
|
1652
|
+
* key: 'icon',<br/>
|
|
1653
|
+
* prefix: 'https://imglink.com',<br/>
|
|
1654
|
+
* suffix: '.jpg'<br/>
|
|
1655
|
+
* }
|
|
1656
1656
|
*/
|
|
1657
1657
|
iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
|
|
1658
1658
|
key: PropTypes.string,
|
|
@@ -1686,8 +1686,8 @@ Dropdown.propTypes = {
|
|
|
1686
1686
|
onChange: PropTypes.func,
|
|
1687
1687
|
/** Callback fired when dropdown closed. */
|
|
1688
1688
|
onClosed: PropTypes.func,
|
|
1689
|
-
/** Callback fired when the input value changes.<br/>
|
|
1690
|
-
* if undefined: the filter function will run (default)
|
|
1689
|
+
/** Callback fired when the input value changes.<br/>
|
|
1690
|
+
* if undefined: the filter function will run (default)
|
|
1691
1691
|
*/
|
|
1692
1692
|
onInput: PropTypes.func,
|
|
1693
1693
|
/** Callback fired when key down input */
|
|
@@ -1698,21 +1698,21 @@ Dropdown.propTypes = {
|
|
|
1698
1698
|
placeholder: PropTypes.string,
|
|
1699
1699
|
/** If `true`, the component is read-only. */
|
|
1700
1700
|
readOnly: PropTypes.bool,
|
|
1701
|
-
/** Function displays items by custom.<br/>
|
|
1702
|
-
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1703
|
-
* --> such as: displayExpr={'name - role'}
|
|
1701
|
+
/** Function displays items by custom.<br/>
|
|
1702
|
+
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1703
|
+
* --> such as: displayExpr={'name - role'}
|
|
1704
1704
|
*/
|
|
1705
1705
|
renderItem: PropTypes.func,
|
|
1706
|
-
/** Function or field name used for display selected items, example:<br/>
|
|
1707
|
-
* renderSelectedItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1706
|
+
/** Function or field name used for display selected items, example:<br/>
|
|
1707
|
+
* renderSelectedItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1708
1708
|
*/
|
|
1709
1709
|
renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
1710
1710
|
/** If `true`, the label will indicate that the input is required. */
|
|
1711
1711
|
required: PropTypes.bool,
|
|
1712
|
-
/**
|
|
1713
|
-
* Duration wait enter search content on search.<br/>
|
|
1714
|
-
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1715
|
-
* If `true`, used default delayOnInput.
|
|
1712
|
+
/**
|
|
1713
|
+
* Duration wait enter search content on search.<br/>
|
|
1714
|
+
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1715
|
+
* If `true`, used default delayOnInput.
|
|
1716
1716
|
*/
|
|
1717
1717
|
searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
|
|
1718
1718
|
/** Specifies a data object's field name or an expression whose value is compared to the search string. */
|
|
@@ -1739,19 +1739,19 @@ Dropdown.propTypes = {
|
|
|
1739
1739
|
valueObjectDefault: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
1740
1740
|
/**The variant to use. */
|
|
1741
1741
|
viewType: PropTypes.oneOf(['underlined', 'outlined', 'none'])
|
|
1742
|
-
/**
|
|
1743
|
-
* ref methods
|
|
1744
|
-
*
|
|
1745
|
-
* how to get component element? ref.current
|
|
1746
|
-
*
|
|
1747
|
-
* how to call method? ref.current.instance.{method}
|
|
1748
|
-
*
|
|
1749
|
-
* * showDropdown(): Show dropdown
|
|
1750
|
-
* * closeDropdown(): Close dropdown
|
|
1751
|
-
* * onClear(): Clear selected value
|
|
1752
|
-
* * setPreviousValue(): Set value to previous value
|
|
1753
|
-
* * setValue(value): Set value of dropdown
|
|
1754
|
-
* * @param {value} - string || number || array
|
|
1742
|
+
/**
|
|
1743
|
+
* ref methods
|
|
1744
|
+
*
|
|
1745
|
+
* how to get component element? ref.current
|
|
1746
|
+
*
|
|
1747
|
+
* how to call method? ref.current.instance.{method}
|
|
1748
|
+
*
|
|
1749
|
+
* * showDropdown(): Show dropdown
|
|
1750
|
+
* * closeDropdown(): Close dropdown
|
|
1751
|
+
* * onClear(): Clear selected value
|
|
1752
|
+
* * setPreviousValue(): Set value to previous value
|
|
1753
|
+
* * setValue(value): Set value of dropdown
|
|
1754
|
+
* * @param {value} - string || number || array
|
|
1755
1755
|
*/
|
|
1756
1756
|
};
|
|
1757
1757
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { css, jsx, keyframes } from '@emotion/core';
|
|
4
|
-
import
|
|
4
|
+
import ImageDefault from "../../assets/image/default.png";
|
|
5
5
|
import OptionWrapper from "../others/option-wrapper";
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { forwardRef, Fragment, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
8
|
-
import { borderRadius, displayInlineFlex, itemsCenter, objectCover, overflowHidden, parseWidthHeight, positionRelative } from "../../styles/general";
|
|
8
|
+
import { animation, borderRadius, displayInlineFlex, itemsCenter, objectCover, overflowHidden, parseWidthHeight, positionRelative } from "../../styles/general";
|
|
9
9
|
import { classNames, useIntersection } from "../../utils";
|
|
10
10
|
const blurKeyframe = keyframes`
|
|
11
11
|
0% { -webkit-filter: blur(4px);}
|
|
@@ -29,7 +29,7 @@ const Image = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
29
29
|
width
|
|
30
30
|
}, reference) => {
|
|
31
31
|
if (!reference) reference = useRef(null);
|
|
32
|
-
if (!defaultSrc) defaultSrc =
|
|
32
|
+
if (!defaultSrc) defaultSrc = ImageDefault;
|
|
33
33
|
const ref = useRef(null);
|
|
34
34
|
const [srcState, setSrcState] = useState(src);
|
|
35
35
|
const [isInView, setIsInView] = useState(false);
|
|
@@ -106,7 +106,10 @@ const ImageCSS = (width, height, circular) => css`
|
|
|
106
106
|
${circular && borderRadius('50%')};
|
|
107
107
|
`;
|
|
108
108
|
const blurAnimationCSS = css`
|
|
109
|
-
|
|
109
|
+
${animation({
|
|
110
|
+
keyframes: blurKeyframe,
|
|
111
|
+
duration: '1s'
|
|
112
|
+
})}
|
|
110
113
|
`;
|
|
111
114
|
Image.defaultProps = {
|
|
112
115
|
circular: false,
|
|
@@ -7,7 +7,7 @@ import { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useS
|
|
|
7
7
|
import { createPortal } from 'react-dom';
|
|
8
8
|
import { animations } from "../../styles/animation";
|
|
9
9
|
import { bgColor, borderRadius, boxBorder, cursorMove, displayFlex, flexCol, flexRow, justifyCenter, left, parseMaxWidthHeight, parseMinWidth, parseWidthHeight, pdt, positionAbsolute, positionRelative, top } from "../../styles/general";
|
|
10
|
-
import { useTheme } from "../../theme";
|
|
10
|
+
import { makeStyles, useTheme } from "../../theme";
|
|
11
11
|
import { classNames, useDelayUnmount } from "../../utils";
|
|
12
12
|
import ModalContext from "./context";
|
|
13
13
|
const {
|
|
@@ -16,6 +16,12 @@ const {
|
|
|
16
16
|
},
|
|
17
17
|
zIndex: zIndexCORE
|
|
18
18
|
} = useTheme();
|
|
19
|
+
const useStyles = makeStyles({
|
|
20
|
+
noScroll: {
|
|
21
|
+
key: props => `DGN-Modal-${props}`,
|
|
22
|
+
overflow: 'hidden'
|
|
23
|
+
}
|
|
24
|
+
});
|
|
19
25
|
const fadeInDown = animations.fadeInDown;
|
|
20
26
|
const fadeOutUp = animations.fadeOutUp;
|
|
21
27
|
const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
@@ -38,7 +44,8 @@ const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
38
44
|
}, reference) => {
|
|
39
45
|
if (!reference) reference = useRef(null);
|
|
40
46
|
const ref = useRef(null);
|
|
41
|
-
|
|
47
|
+
|
|
48
|
+
// const overflow = useRef(null);
|
|
42
49
|
const modalBoxRef = useRef(null);
|
|
43
50
|
const [openState, setOpenState] = useState(open);
|
|
44
51
|
const showModal = useDelayUnmount(openState, 200);
|
|
@@ -48,7 +55,6 @@ const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
48
55
|
setOpenState(true);
|
|
49
56
|
};
|
|
50
57
|
const onCloseModal = () => {
|
|
51
|
-
document.body.style.overflow = overflow.current; // reset overflow of <body /> before open modal
|
|
52
58
|
onClose && onClose();
|
|
53
59
|
setOpenState(false);
|
|
54
60
|
};
|
|
@@ -109,36 +115,34 @@ const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
109
115
|
modalBoxRef.current.style.left = newLeft + 'px';
|
|
110
116
|
};
|
|
111
117
|
};
|
|
112
|
-
useEffect(() => {
|
|
113
|
-
return () => {
|
|
114
|
-
document.body.style.overflow = overflow.current; // reset overflow of <body /> before open modal
|
|
115
|
-
};
|
|
116
|
-
}, []);
|
|
117
118
|
useEffect(() => {
|
|
118
119
|
setOpenState(open);
|
|
119
120
|
}, [open]);
|
|
120
121
|
useEffect(() => {
|
|
121
|
-
if (openState) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
ref.current.focus();
|
|
131
|
-
}
|
|
122
|
+
if (openState && ref.current) {
|
|
123
|
+
const modals = document.querySelectorAll('.DGN-UI-Modal');
|
|
124
|
+
if (!darkTheme && modals && modals.length > 1) {
|
|
125
|
+
ref.current.style.backgroundColor = 'transparent';
|
|
126
|
+
}
|
|
127
|
+
if (autoFocus) {
|
|
128
|
+
if (!ref.current.contains(document.activeElement)) {
|
|
129
|
+
ref.current.tabIndex = -1;
|
|
130
|
+
ref.current.focus();
|
|
132
131
|
}
|
|
133
132
|
}
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
const timestamp = Date.now();
|
|
134
|
+
const classes = useStyles(timestamp);
|
|
135
|
+
const noScrollClass = classes.noScroll.split(' ');
|
|
136
|
+
document.body.classList.add(...noScrollClass);
|
|
137
|
+
// overflow.current = document.body.style.overflow; // overflow of <body /> before open modal
|
|
138
|
+
// document.body.style.overflow = 'hidden';
|
|
136
139
|
// Allow press ESC to close popup
|
|
137
140
|
if (pressESCToClose) {
|
|
138
141
|
document.addEventListener('keydown', pressESCHandler);
|
|
139
142
|
}
|
|
140
143
|
return () => {
|
|
141
|
-
document.body.
|
|
144
|
+
document.body.classList.remove(...noScrollClass);
|
|
145
|
+
// document.body.style.overflow = overflow.current; // reset overflow of <body /> before open modal
|
|
142
146
|
if (pressESCToClose) {
|
|
143
147
|
document.removeEventListener('keydown', pressESCHandler);
|
|
144
148
|
}
|
|
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import React, { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
7
7
|
import { createPortal } from 'react-dom';
|
|
8
8
|
import { bgColor, borderBottom, borderRadius4px, displayFlex, displayNone, flexCol, inset, justifyBetween, overflowAuto, parseMaxWidthHeight, parseMinWidthHeight, parseWidthHeight, pointerEventsInitial, pointerEventsNone, positionAbsolute, positionFixed, positionRelative } from "../../styles/general";
|
|
9
|
-
import { useTheme } from "../../theme";
|
|
9
|
+
import { makeStyles, useTheme } from "../../theme";
|
|
10
10
|
import { classNames, isMobile, refType as ref } from "../../utils";
|
|
11
11
|
const {
|
|
12
12
|
typography: {
|
|
@@ -15,6 +15,12 @@ const {
|
|
|
15
15
|
spacing,
|
|
16
16
|
zIndex: zIndexCORE
|
|
17
17
|
} = useTheme();
|
|
18
|
+
const useStyles = makeStyles({
|
|
19
|
+
noScroll: {
|
|
20
|
+
key: props => `DGN-Popover-${props}`,
|
|
21
|
+
overflow: 'hidden'
|
|
22
|
+
}
|
|
23
|
+
});
|
|
18
24
|
const eventMap = new Map([['click', ['click']], ['hover', ['mouseenter', 'mouseleave']], ['focus', ['focus', 'blur']]]);
|
|
19
25
|
const getArrowPosition = (anchorOrigin, transformOrigin, translate) => {
|
|
20
26
|
if (anchorOrigin.horizontal === 'right' && transformOrigin.horizontal === 'left') {
|
|
@@ -139,7 +145,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
139
145
|
if (isMobile.any() && trigger === 'hover') trigger = 'click';
|
|
140
146
|
const ref = useRef(null);
|
|
141
147
|
const arrowRef = useRef(null);
|
|
142
|
-
const overflow = useRef(null);
|
|
148
|
+
// const overflow = useRef(null);
|
|
143
149
|
const anchorRef = useRef(anchor);
|
|
144
150
|
const [openState, setOpenState] = useState(open);
|
|
145
151
|
const [element, setElement] = useState(null);
|
|
@@ -406,10 +412,14 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
406
412
|
}, [open]);
|
|
407
413
|
useEffect(() => {
|
|
408
414
|
if (openState && ref.current) {
|
|
409
|
-
if (document.body.style.overflow !== 'hidden') {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
}
|
|
415
|
+
// if (document.body.style.overflow !== 'hidden') {
|
|
416
|
+
// overflow.current = document.body.style.overflow; // store overflow of <body /> before open
|
|
417
|
+
// document.body.style.overflow = 'hidden';
|
|
418
|
+
// }
|
|
419
|
+
const timestamp = Date.now();
|
|
420
|
+
const classes = useStyles(timestamp);
|
|
421
|
+
const noScrollClass = classes.noScroll.split(' ');
|
|
422
|
+
document.body.classList.add(...noScrollClass);
|
|
413
423
|
// Position's anchor
|
|
414
424
|
updatePositionPopover();
|
|
415
425
|
|
|
@@ -424,7 +434,8 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
424
434
|
window.addEventListener('resize', updatePositionPopover);
|
|
425
435
|
if (trigger === 'hover') ref.current.addEventListener('mouseleave', handleEventTrigger, false);
|
|
426
436
|
return () => {
|
|
427
|
-
document.body.
|
|
437
|
+
document.body.classList.remove(...noScrollClass);
|
|
438
|
+
// document.body.style.overflow = overflow.current; // reset overflow of <body /> before open
|
|
428
439
|
if (pressESCToClose) {
|
|
429
440
|
document.removeEventListener('keydown', pressESCHandler);
|
|
430
441
|
}
|
|
@@ -432,9 +443,10 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
432
443
|
window.removeEventListener('resize', updatePositionPopover);
|
|
433
444
|
if (trigger === 'hover' && ref.current) ref.current.removeEventListener('mouseleave', handleEventTrigger, false);
|
|
434
445
|
};
|
|
435
|
-
} else if (!openState) {
|
|
436
|
-
document.documentElement.style.overflow = overflow.current;
|
|
437
446
|
}
|
|
447
|
+
// else if (!openState) {
|
|
448
|
+
// document.documentElement.style.overflow = overflow.current;
|
|
449
|
+
// }
|
|
438
450
|
}, [openState]);
|
|
439
451
|
useEffect(() => {
|
|
440
452
|
clickOutsideToClose ? document.addEventListener('click', onClickOutside) : document.removeEventListener('click', onClickOutside);
|
|
@@ -5,24 +5,15 @@ import { Popover } from "./..";
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { forwardRef, Fragment, memo, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
7
7
|
import { breakAll, breakWord, cursorPointer, displayBlock, displayInlineBlock, italic, overflowHidden, parseHeight, parseMaxWidth, parseMinWidth, pd, positionRelative, textCapitalize, textCenter, textColor, textLineThrough, textLowercase, textSentence, textUnderline, textUppercase, whiteSpaceBreakSpaces } from "../../styles/general";
|
|
8
|
-
import {
|
|
8
|
+
import { useTypography as typography } from "../../theme";
|
|
9
9
|
import { classNames, renderHTML } from "../../utils";
|
|
10
|
-
const
|
|
11
|
-
colors: {
|
|
12
|
-
text: {
|
|
13
|
-
main: textMain
|
|
14
|
-
},
|
|
15
|
-
fill: {
|
|
16
|
-
tooltip: fillTooltip
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
} = useTheme();
|
|
20
|
-
const colorMap = new Map([['default', textMain]]);
|
|
10
|
+
const colorMap = new Map([['default', 'text/main']]);
|
|
21
11
|
const formatMap = new Map([['capitalize', textCapitalize], ['uppercase', textUppercase], ['lowercase', textLowercase], ['italic', italic], ['line-through', textLineThrough], ['underline', textUnderline], ['sentence', textSentence]]);
|
|
22
12
|
const isTextClamped = elm => (elm === null || elm === void 0 ? void 0 : elm.scrollHeight) > (elm === null || elm === void 0 ? void 0 : elm.clientHeight);
|
|
23
13
|
const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
24
14
|
action = {},
|
|
25
15
|
capitalize,
|
|
16
|
+
// deprecated
|
|
26
17
|
center,
|
|
27
18
|
children,
|
|
28
19
|
className,
|
|
@@ -37,17 +28,20 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
37
28
|
tooltipDirection,
|
|
38
29
|
type,
|
|
39
30
|
uppercase,
|
|
31
|
+
// deprecated
|
|
40
32
|
...props
|
|
41
33
|
}, reference) => {
|
|
42
34
|
var _ref$current;
|
|
43
35
|
if (!reference) reference = useRef(null);
|
|
44
36
|
const ref = useRef(null);
|
|
45
37
|
const formatCSS = [];
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
if (Array.isArray(format)) {
|
|
39
|
+
format.forEach(item => {
|
|
40
|
+
formatCSS.push(formatMap.get(item));
|
|
41
|
+
});
|
|
42
|
+
}
|
|
49
43
|
const [openTooltip, setOpenTooltip] = useState(false);
|
|
50
|
-
const _TextRootCSS = [TextRootCSS(color, type, lineClamp, onClick, hoverTooltip), ...formatCSS];
|
|
44
|
+
const _TextRootCSS = [TextRootCSS(color, type, lineClamp, onClick, hoverTooltip, center, fullWidth, uppercase, capitalize), ...formatCSS];
|
|
51
45
|
const showTooltip = () => {
|
|
52
46
|
if (!hoverTooltip) return;
|
|
53
47
|
if (isTextClamped(ref.current)) {
|
|
@@ -70,26 +64,26 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
70
64
|
currentRef.instance = _instance;
|
|
71
65
|
return currentRef;
|
|
72
66
|
});
|
|
73
|
-
const classes =
|
|
67
|
+
const classes = classNames('DGN-UI-Typography', `DGN-UI-Typography-${type}`, className);
|
|
74
68
|
const content = Array.isArray(children) && !children.some(node => node && String(node.$$typeof) === 'Symbol(react.element)') ? children.join('') : children;
|
|
75
69
|
const renderTooltip = hoverTooltip ? jsx(Popover, {
|
|
76
|
-
css:
|
|
70
|
+
css: parseMinWidth(300),
|
|
77
71
|
open: openTooltip,
|
|
78
72
|
pressESCToClose: false,
|
|
79
73
|
fullScreen: false,
|
|
80
|
-
bgColor:
|
|
74
|
+
bgColor: 'fill/tooltip',
|
|
81
75
|
anchor: ref,
|
|
82
76
|
width: ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.clientWidth) || 'max-content',
|
|
83
77
|
direction: tooltipDirection
|
|
84
78
|
}, renderHTML(content, mapping, {
|
|
85
79
|
css: [_TextRootCSS, PopoverContentCSS],
|
|
86
|
-
className: classes
|
|
80
|
+
className: classes
|
|
87
81
|
})) : null;
|
|
88
82
|
return useMemo(() => {
|
|
89
83
|
return jsx(Fragment, null, renderHTML(content, mapping, {
|
|
90
84
|
ref: ref,
|
|
91
|
-
css: _TextRootCSS,
|
|
92
|
-
className: classes
|
|
85
|
+
css: [_TextRootCSS, lineClamp && ClampCSS(lineClamp)],
|
|
86
|
+
className: classes,
|
|
93
87
|
onMouseEnter: showTooltip,
|
|
94
88
|
onMouseLeave: hideTooltip,
|
|
95
89
|
onClick: onClick,
|
|
@@ -97,7 +91,7 @@ const Typography = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
97
91
|
}), renderTooltip);
|
|
98
92
|
}, [capitalize, center, children, className, color, format, fullWidth, hoverTooltip, italic, lineClamp, mapping, onClick, props, tooltipDirection, type, uppercase, openTooltip]);
|
|
99
93
|
}));
|
|
100
|
-
const TextRootCSS = (color, type, lineClamp, onClick, hoverTooltip) => css`
|
|
94
|
+
const TextRootCSS = (color, type, lineClamp, onClick, hoverTooltip, center, fullWidth, uppercase, capitalize) => css`
|
|
101
95
|
${displayInlineBlock};
|
|
102
96
|
${positionRelative};
|
|
103
97
|
${onClick && cursorPointer};
|
|
@@ -106,28 +100,22 @@ const TextRootCSS = (color, type, lineClamp, onClick, hoverTooltip) => css`
|
|
|
106
100
|
${textColor(colorMap.get(color) || color)};
|
|
107
101
|
${parseMaxWidth('max-content')};
|
|
108
102
|
${type !== 'inherit' && typography[type]};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
103
|
+
${center && textCenter};
|
|
104
|
+
${uppercase && textUppercase};
|
|
105
|
+
${capitalize && textCapitalize};
|
|
106
|
+
${fullWidth && css`
|
|
113
107
|
${displayBlock};
|
|
114
108
|
${parseMaxWidth('initial')};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
&.DGN-Typography-Clamp {
|
|
123
|
-
${overflowHidden};
|
|
124
|
-
display: -webkit-box;
|
|
125
|
-
-webkit-line-clamp: ${lineClamp};
|
|
126
|
-
-webkit-box-orient: vertical;
|
|
127
|
-
}
|
|
109
|
+
`}
|
|
110
|
+
`;
|
|
111
|
+
const ClampCSS = lineClamp => css`
|
|
112
|
+
${overflowHidden};
|
|
113
|
+
display: -webkit-box;
|
|
114
|
+
-webkit-line-clamp: ${lineClamp};
|
|
115
|
+
-webkit-box-orient: vertical;
|
|
128
116
|
`;
|
|
129
117
|
const PopoverContentCSS = css`
|
|
130
|
-
${textColor('text
|
|
118
|
+
${textColor('text/tooltip')};
|
|
131
119
|
${pd([1, 1.5])};
|
|
132
120
|
${parseHeight('fit-content')};
|
|
133
121
|
`;
|