react-asc 25.2.13 → 25.3.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/Tooltip/Tooltip.d.ts +3 -0
- package/index.es.js +59 -21
- package/index.js +59 -21
- package/package.json +1 -1
|
@@ -2,5 +2,8 @@ import React from 'react';
|
|
|
2
2
|
export interface ITooltipProps extends React.ComponentProps<'div'> {
|
|
3
3
|
placement?: 'top' | 'bottom' | 'right' | 'left';
|
|
4
4
|
text?: string;
|
|
5
|
+
delay?: number;
|
|
6
|
+
isOpen?: boolean;
|
|
7
|
+
isShowClose?: boolean;
|
|
5
8
|
}
|
|
6
9
|
export declare const Tooltip: (props: ITooltipProps) => JSX.Element;
|
package/index.es.js
CHANGED
|
@@ -269,7 +269,7 @@ function useMobileDetect() {
|
|
|
269
269
|
useEffect(() => {
|
|
270
270
|
windowSize && checkIsMobile(windowSize.height, windowSize.width);
|
|
271
271
|
}, [windowSize]);
|
|
272
|
-
return { isMobile };
|
|
272
|
+
return { isMobile: isMobile };
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
const useOnDestroy = (callBack) => {
|
|
@@ -1117,11 +1117,11 @@ const FormInput = (props) => {
|
|
|
1117
1117
|
};
|
|
1118
1118
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1119
1119
|
const handleOnInput = (value, type, name) => {
|
|
1120
|
-
onInput && onInput({ value, type, name });
|
|
1120
|
+
onInput && onInput({ value: value, type: type, name: name });
|
|
1121
1121
|
};
|
|
1122
1122
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1123
1123
|
const handleOnChange = (value, type, name) => {
|
|
1124
|
-
onChange && onChange({ value, type, name });
|
|
1124
|
+
onChange && onChange({ value: value, type: type, name: name });
|
|
1125
1125
|
};
|
|
1126
1126
|
return (React.createElement(React.Fragment, null,
|
|
1127
1127
|
(type === 'text' ||
|
|
@@ -1547,10 +1547,11 @@ styleInject(css_248z$x);
|
|
|
1547
1547
|
|
|
1548
1548
|
const MenuBody = (props) => {
|
|
1549
1549
|
const { parentRef, children, className, shadow = true, menuPosition = 'left', onClickBackdrop } = props;
|
|
1550
|
+
const [popperInstance, setPopperInstance] = useState();
|
|
1550
1551
|
const menuBodyRef = useRef(null);
|
|
1551
1552
|
useEffect(() => {
|
|
1552
1553
|
if (menuBodyRef && parentRef.current && menuBodyRef.current) {
|
|
1553
|
-
createPopper(parentRef.current, menuBodyRef.current, {
|
|
1554
|
+
const popperInstance = createPopper(parentRef.current, menuBodyRef.current, {
|
|
1554
1555
|
placement: `${menuPosition}-start`,
|
|
1555
1556
|
modifiers: [
|
|
1556
1557
|
{
|
|
@@ -1570,6 +1571,10 @@ const MenuBody = (props) => {
|
|
|
1570
1571
|
},
|
|
1571
1572
|
]
|
|
1572
1573
|
});
|
|
1574
|
+
setPopperInstance(popperInstance);
|
|
1575
|
+
}
|
|
1576
|
+
else {
|
|
1577
|
+
popperInstance?.destroy();
|
|
1573
1578
|
}
|
|
1574
1579
|
}, [menuBodyRef]);
|
|
1575
1580
|
const getCssClasses = () => {
|
|
@@ -1582,6 +1587,9 @@ const MenuBody = (props) => {
|
|
|
1582
1587
|
const handleClickBackdrop = () => {
|
|
1583
1588
|
onClickBackdrop && onClickBackdrop();
|
|
1584
1589
|
};
|
|
1590
|
+
useOnDestroy(() => {
|
|
1591
|
+
popperInstance?.destroy();
|
|
1592
|
+
});
|
|
1585
1593
|
return (React.createElement(Portal, { className: 'menu-root' },
|
|
1586
1594
|
React.createElement("div", { ref: menuBodyRef, className: getCssClasses() },
|
|
1587
1595
|
React.createElement(List, null, children)),
|
|
@@ -2019,14 +2027,27 @@ var styles$l = {"tooltipContainer":"Tooltip-module_tooltipContainer__9ZWx3","too
|
|
|
2019
2027
|
styleInject(css_248z$l);
|
|
2020
2028
|
|
|
2021
2029
|
const Tooltip = (props) => {
|
|
2022
|
-
const { children, text, placement = 'bottom' } = props;
|
|
2023
|
-
const [
|
|
2030
|
+
const { children, text, placement = 'bottom', isOpen = false, isShowClose = false, delay = 0 } = props;
|
|
2031
|
+
const [popperInstance, setPopperInstance] = useState();
|
|
2032
|
+
const [debounce, setDebounce] = useState(delay);
|
|
2033
|
+
const [open, setOpen] = useState(isOpen);
|
|
2034
|
+
const [show, setShow] = useState(isOpen);
|
|
2035
|
+
const [showClose, setShowClose] = useState(isShowClose);
|
|
2024
2036
|
const refChild = useRef();
|
|
2025
2037
|
const refTooltip = useRef();
|
|
2038
|
+
useDebounce(() => { setOpen(show); }, debounce, [show]);
|
|
2039
|
+
useEffect(() => {
|
|
2040
|
+
setShow(isOpen);
|
|
2041
|
+
}, [isOpen]);
|
|
2026
2042
|
useEffect(() => {
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2043
|
+
setShowClose(isShowClose);
|
|
2044
|
+
}, [isShowClose]);
|
|
2045
|
+
useEffect(() => {
|
|
2046
|
+
setDebounce(delay);
|
|
2047
|
+
}, [delay]);
|
|
2048
|
+
useEffect(() => {
|
|
2049
|
+
if (open === true && refChild && refChild.current && refTooltip && refTooltip.current) {
|
|
2050
|
+
const popperInstance = createPopper(refChild.current, refTooltip.current, {
|
|
2030
2051
|
placement: placement,
|
|
2031
2052
|
modifiers: [
|
|
2032
2053
|
{
|
|
@@ -2035,22 +2056,39 @@ const Tooltip = (props) => {
|
|
|
2035
2056
|
},
|
|
2036
2057
|
]
|
|
2037
2058
|
});
|
|
2059
|
+
setPopperInstance(popperInstance);
|
|
2038
2060
|
}
|
|
2039
|
-
|
|
2061
|
+
else {
|
|
2062
|
+
popperInstance?.destroy();
|
|
2063
|
+
}
|
|
2064
|
+
}, [open]);
|
|
2040
2065
|
const handleMouseOver = () => {
|
|
2041
2066
|
setShow(true);
|
|
2042
2067
|
};
|
|
2043
2068
|
const handleMouseLeave = () => {
|
|
2044
2069
|
setShow(false);
|
|
2045
2070
|
};
|
|
2071
|
+
const handleFocus = () => {
|
|
2072
|
+
setShow(true);
|
|
2073
|
+
};
|
|
2074
|
+
const handleBlur = () => {
|
|
2075
|
+
setShow(false);
|
|
2076
|
+
};
|
|
2077
|
+
const handleClickClose = () => {
|
|
2078
|
+
setShow(false);
|
|
2079
|
+
};
|
|
2080
|
+
useOnDestroy(() => {
|
|
2081
|
+
popperInstance?.destroy();
|
|
2082
|
+
});
|
|
2046
2083
|
return (React.createElement(React.Fragment, null,
|
|
2047
|
-
React.createElement("div", { className: styles$l.tooltipContainer,
|
|
2048
|
-
|
|
2049
|
-
onMouseLeave: handleMouseLeave,
|
|
2050
|
-
})),
|
|
2051
|
-
show && text &&
|
|
2084
|
+
React.createElement("div", { ref: refChild, className: styles$l.tooltipContainer, onMouseOver: handleMouseOver, onMouseLeave: handleMouseLeave, onFocus: handleFocus, onBlur: handleBlur }, children),
|
|
2085
|
+
open && text &&
|
|
2052
2086
|
React.createElement("div", { className: styles$l.tooltip, ref: refTooltip, id: "tooltip" },
|
|
2053
|
-
|
|
2087
|
+
React.createElement("div", { className: 'd-flex align-items-center' },
|
|
2088
|
+
text,
|
|
2089
|
+
showClose &&
|
|
2090
|
+
React.createElement(Icon, { className: 'ml-1', onClick: handleClickClose },
|
|
2091
|
+
React.createElement(TimesSolidIcon, null))),
|
|
2054
2092
|
React.createElement("div", { id: "arrow", "data-popper-arrow": true }))));
|
|
2055
2093
|
};
|
|
2056
2094
|
|
|
@@ -2498,7 +2536,7 @@ const Step = (props) => {
|
|
|
2498
2536
|
const [hoverRef, isHovered] = useHover();
|
|
2499
2537
|
const handleClick = (event) => {
|
|
2500
2538
|
if (!isDisabled) {
|
|
2501
|
-
onClick && onClick({ event, value });
|
|
2539
|
+
onClick && onClick({ event: event, value: value });
|
|
2502
2540
|
}
|
|
2503
2541
|
};
|
|
2504
2542
|
const getCssClasses = () => {
|
|
@@ -2675,9 +2713,9 @@ const Tabs = (props) => {
|
|
|
2675
2713
|
const [selectedValue, setSelectedValue] = useState('');
|
|
2676
2714
|
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
2677
2715
|
const tabContext = ({
|
|
2678
|
-
selectedValue,
|
|
2679
|
-
setSelectedValue,
|
|
2680
|
-
fixed
|
|
2716
|
+
selectedValue: selectedValue,
|
|
2717
|
+
setSelectedValue: setSelectedValue,
|
|
2718
|
+
fixed: fixed
|
|
2681
2719
|
});
|
|
2682
2720
|
const prevSelectedValueRef = useRef();
|
|
2683
2721
|
useEffect(() => {
|
|
@@ -2724,7 +2762,7 @@ const Tab = (props) => {
|
|
|
2724
2762
|
return cssClasses.filter(css => css).join(' ');
|
|
2725
2763
|
};
|
|
2726
2764
|
const handleClick = (event) => {
|
|
2727
|
-
onClick && onClick({ event, value });
|
|
2765
|
+
onClick && onClick({ event: event, value: value });
|
|
2728
2766
|
setSelectedValue && setSelectedValue(value);
|
|
2729
2767
|
};
|
|
2730
2768
|
return (React.createElement(Button, { className: getCssClasses(), onClick: handleClick, isActive: selectedValue === value, disabled: disabled }, label));
|
package/index.js
CHANGED
|
@@ -278,7 +278,7 @@ function useMobileDetect() {
|
|
|
278
278
|
React.useEffect(() => {
|
|
279
279
|
windowSize && checkIsMobile(windowSize.height, windowSize.width);
|
|
280
280
|
}, [windowSize]);
|
|
281
|
-
return { isMobile };
|
|
281
|
+
return { isMobile: isMobile };
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
const useOnDestroy = (callBack) => {
|
|
@@ -1126,11 +1126,11 @@ const FormInput = (props) => {
|
|
|
1126
1126
|
};
|
|
1127
1127
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1128
1128
|
const handleOnInput = (value, type, name) => {
|
|
1129
|
-
onInput && onInput({ value, type, name });
|
|
1129
|
+
onInput && onInput({ value: value, type: type, name: name });
|
|
1130
1130
|
};
|
|
1131
1131
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1132
1132
|
const handleOnChange = (value, type, name) => {
|
|
1133
|
-
onChange && onChange({ value, type, name });
|
|
1133
|
+
onChange && onChange({ value: value, type: type, name: name });
|
|
1134
1134
|
};
|
|
1135
1135
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
1136
1136
|
(type === 'text' ||
|
|
@@ -1556,10 +1556,11 @@ styleInject(css_248z$x);
|
|
|
1556
1556
|
|
|
1557
1557
|
const MenuBody = (props) => {
|
|
1558
1558
|
const { parentRef, children, className, shadow = true, menuPosition = 'left', onClickBackdrop } = props;
|
|
1559
|
+
const [popperInstance, setPopperInstance] = React.useState();
|
|
1559
1560
|
const menuBodyRef = React.useRef(null);
|
|
1560
1561
|
React.useEffect(() => {
|
|
1561
1562
|
if (menuBodyRef && parentRef.current && menuBodyRef.current) {
|
|
1562
|
-
core.createPopper(parentRef.current, menuBodyRef.current, {
|
|
1563
|
+
const popperInstance = core.createPopper(parentRef.current, menuBodyRef.current, {
|
|
1563
1564
|
placement: `${menuPosition}-start`,
|
|
1564
1565
|
modifiers: [
|
|
1565
1566
|
{
|
|
@@ -1579,6 +1580,10 @@ const MenuBody = (props) => {
|
|
|
1579
1580
|
},
|
|
1580
1581
|
]
|
|
1581
1582
|
});
|
|
1583
|
+
setPopperInstance(popperInstance);
|
|
1584
|
+
}
|
|
1585
|
+
else {
|
|
1586
|
+
popperInstance?.destroy();
|
|
1582
1587
|
}
|
|
1583
1588
|
}, [menuBodyRef]);
|
|
1584
1589
|
const getCssClasses = () => {
|
|
@@ -1591,6 +1596,9 @@ const MenuBody = (props) => {
|
|
|
1591
1596
|
const handleClickBackdrop = () => {
|
|
1592
1597
|
onClickBackdrop && onClickBackdrop();
|
|
1593
1598
|
};
|
|
1599
|
+
useOnDestroy(() => {
|
|
1600
|
+
popperInstance?.destroy();
|
|
1601
|
+
});
|
|
1594
1602
|
return (React__default["default"].createElement(Portal, { className: 'menu-root' },
|
|
1595
1603
|
React__default["default"].createElement("div", { ref: menuBodyRef, className: getCssClasses() },
|
|
1596
1604
|
React__default["default"].createElement(List, null, children)),
|
|
@@ -2028,14 +2036,27 @@ var styles$l = {"tooltipContainer":"Tooltip-module_tooltipContainer__9ZWx3","too
|
|
|
2028
2036
|
styleInject(css_248z$l);
|
|
2029
2037
|
|
|
2030
2038
|
const Tooltip = (props) => {
|
|
2031
|
-
const { children, text, placement = 'bottom' } = props;
|
|
2032
|
-
const [
|
|
2039
|
+
const { children, text, placement = 'bottom', isOpen = false, isShowClose = false, delay = 0 } = props;
|
|
2040
|
+
const [popperInstance, setPopperInstance] = React.useState();
|
|
2041
|
+
const [debounce, setDebounce] = React.useState(delay);
|
|
2042
|
+
const [open, setOpen] = React.useState(isOpen);
|
|
2043
|
+
const [show, setShow] = React.useState(isOpen);
|
|
2044
|
+
const [showClose, setShowClose] = React.useState(isShowClose);
|
|
2033
2045
|
const refChild = React.useRef();
|
|
2034
2046
|
const refTooltip = React.useRef();
|
|
2047
|
+
useDebounce(() => { setOpen(show); }, debounce, [show]);
|
|
2048
|
+
React.useEffect(() => {
|
|
2049
|
+
setShow(isOpen);
|
|
2050
|
+
}, [isOpen]);
|
|
2035
2051
|
React.useEffect(() => {
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2052
|
+
setShowClose(isShowClose);
|
|
2053
|
+
}, [isShowClose]);
|
|
2054
|
+
React.useEffect(() => {
|
|
2055
|
+
setDebounce(delay);
|
|
2056
|
+
}, [delay]);
|
|
2057
|
+
React.useEffect(() => {
|
|
2058
|
+
if (open === true && refChild && refChild.current && refTooltip && refTooltip.current) {
|
|
2059
|
+
const popperInstance = core.createPopper(refChild.current, refTooltip.current, {
|
|
2039
2060
|
placement: placement,
|
|
2040
2061
|
modifiers: [
|
|
2041
2062
|
{
|
|
@@ -2044,22 +2065,39 @@ const Tooltip = (props) => {
|
|
|
2044
2065
|
},
|
|
2045
2066
|
]
|
|
2046
2067
|
});
|
|
2068
|
+
setPopperInstance(popperInstance);
|
|
2047
2069
|
}
|
|
2048
|
-
|
|
2070
|
+
else {
|
|
2071
|
+
popperInstance?.destroy();
|
|
2072
|
+
}
|
|
2073
|
+
}, [open]);
|
|
2049
2074
|
const handleMouseOver = () => {
|
|
2050
2075
|
setShow(true);
|
|
2051
2076
|
};
|
|
2052
2077
|
const handleMouseLeave = () => {
|
|
2053
2078
|
setShow(false);
|
|
2054
2079
|
};
|
|
2080
|
+
const handleFocus = () => {
|
|
2081
|
+
setShow(true);
|
|
2082
|
+
};
|
|
2083
|
+
const handleBlur = () => {
|
|
2084
|
+
setShow(false);
|
|
2085
|
+
};
|
|
2086
|
+
const handleClickClose = () => {
|
|
2087
|
+
setShow(false);
|
|
2088
|
+
};
|
|
2089
|
+
useOnDestroy(() => {
|
|
2090
|
+
popperInstance?.destroy();
|
|
2091
|
+
});
|
|
2055
2092
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2056
|
-
React__default["default"].createElement("div", { className: styles$l.tooltipContainer,
|
|
2057
|
-
|
|
2058
|
-
onMouseLeave: handleMouseLeave,
|
|
2059
|
-
})),
|
|
2060
|
-
show && text &&
|
|
2093
|
+
React__default["default"].createElement("div", { ref: refChild, className: styles$l.tooltipContainer, onMouseOver: handleMouseOver, onMouseLeave: handleMouseLeave, onFocus: handleFocus, onBlur: handleBlur }, children),
|
|
2094
|
+
open && text &&
|
|
2061
2095
|
React__default["default"].createElement("div", { className: styles$l.tooltip, ref: refTooltip, id: "tooltip" },
|
|
2062
|
-
|
|
2096
|
+
React__default["default"].createElement("div", { className: 'd-flex align-items-center' },
|
|
2097
|
+
text,
|
|
2098
|
+
showClose &&
|
|
2099
|
+
React__default["default"].createElement(Icon, { className: 'ml-1', onClick: handleClickClose },
|
|
2100
|
+
React__default["default"].createElement(TimesSolidIcon, null))),
|
|
2063
2101
|
React__default["default"].createElement("div", { id: "arrow", "data-popper-arrow": true }))));
|
|
2064
2102
|
};
|
|
2065
2103
|
|
|
@@ -2507,7 +2545,7 @@ const Step = (props) => {
|
|
|
2507
2545
|
const [hoverRef, isHovered] = useHover();
|
|
2508
2546
|
const handleClick = (event) => {
|
|
2509
2547
|
if (!isDisabled) {
|
|
2510
|
-
onClick && onClick({ event, value });
|
|
2548
|
+
onClick && onClick({ event: event, value: value });
|
|
2511
2549
|
}
|
|
2512
2550
|
};
|
|
2513
2551
|
const getCssClasses = () => {
|
|
@@ -2684,9 +2722,9 @@ const Tabs = (props) => {
|
|
|
2684
2722
|
const [selectedValue, setSelectedValue] = React.useState('');
|
|
2685
2723
|
const [selectedIndex, setSelectedIndex] = React.useState(0);
|
|
2686
2724
|
const tabContext = ({
|
|
2687
|
-
selectedValue,
|
|
2688
|
-
setSelectedValue,
|
|
2689
|
-
fixed
|
|
2725
|
+
selectedValue: selectedValue,
|
|
2726
|
+
setSelectedValue: setSelectedValue,
|
|
2727
|
+
fixed: fixed
|
|
2690
2728
|
});
|
|
2691
2729
|
const prevSelectedValueRef = React.useRef();
|
|
2692
2730
|
React.useEffect(() => {
|
|
@@ -2733,7 +2771,7 @@ const Tab = (props) => {
|
|
|
2733
2771
|
return cssClasses.filter(css => css).join(' ');
|
|
2734
2772
|
};
|
|
2735
2773
|
const handleClick = (event) => {
|
|
2736
|
-
onClick && onClick({ event, value });
|
|
2774
|
+
onClick && onClick({ event: event, value: value });
|
|
2737
2775
|
setSelectedValue && setSelectedValue(value);
|
|
2738
2776
|
};
|
|
2739
2777
|
return (React__default["default"].createElement(Button, { className: getCssClasses(), onClick: handleClick, isActive: selectedValue === value, disabled: disabled }, label));
|