@zenkigen-inc/component-ui 1.6.4 → 1.7.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/dist/index.esm.js +151 -38
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +151 -38
- package/dist/index.js.map +1 -1
- package/dist/tooltip/tooltip-content.d.ts +11 -0
- package/dist/tooltip/tooltip.d.ts +4 -3
- package/dist/tooltip/tooltip.hook.d.ts +11 -0
- package/dist/tooltip/type.d.ts +10 -0
- package/package.json +4 -4
package/dist/index.esm.js
CHANGED
|
@@ -31210,7 +31210,7 @@ function Dropdown(_ref) {
|
|
|
31210
31210
|
_ref$size = _ref.size,
|
|
31211
31211
|
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
31212
31212
|
_ref$variant = _ref.variant,
|
|
31213
|
-
variant = _ref$variant === void 0 ?
|
|
31213
|
+
variant = _ref$variant === void 0 ? 'outline' : _ref$variant,
|
|
31214
31214
|
title = _ref.title,
|
|
31215
31215
|
_ref$isDisabled = _ref.isDisabled,
|
|
31216
31216
|
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
@@ -31278,13 +31278,19 @@ function Dropdown(_ref) {
|
|
|
31278
31278
|
children: /*#__PURE__*/jsxs("div", {
|
|
31279
31279
|
ref: targetRef,
|
|
31280
31280
|
className: wrapperClasses,
|
|
31281
|
-
children: [target ? /*#__PURE__*/
|
|
31281
|
+
children: [target ? /*#__PURE__*/jsxs("button", {
|
|
31282
31282
|
type: "button",
|
|
31283
31283
|
title: title,
|
|
31284
31284
|
className: childrenButtonClasses,
|
|
31285
31285
|
onClick: handleToggle,
|
|
31286
31286
|
disabled: isDisabled,
|
|
31287
|
-
children: target
|
|
31287
|
+
children: [target, !isArrowHidden && /*#__PURE__*/jsx("div", {
|
|
31288
|
+
className: "ml-2 flex items-center fill-icon-icon01",
|
|
31289
|
+
children: /*#__PURE__*/jsx(Icon, {
|
|
31290
|
+
name: isVisible ? 'angle-small-up' : 'angle-small-down',
|
|
31291
|
+
size: size === 'large' ? 'medium' : 'small'
|
|
31292
|
+
})
|
|
31293
|
+
})]
|
|
31288
31294
|
}) : /*#__PURE__*/jsxs("button", {
|
|
31289
31295
|
type: "button",
|
|
31290
31296
|
title: title,
|
|
@@ -31551,7 +31557,7 @@ function Modal(_ref) {
|
|
|
31551
31557
|
children: /*#__PURE__*/jsx("div", {
|
|
31552
31558
|
className: "fixed left-0 top-0 z-overlay flex h-full w-full items-center justify-center bg-background-backgroundOverlayBlack",
|
|
31553
31559
|
children: /*#__PURE__*/jsx("div", {
|
|
31554
|
-
className: "
|
|
31560
|
+
className: "grid grid-rows-[max-content_1fr_max-content] flex-col rounded-lg bg-background-uiBackground01 shadow-modalShadow",
|
|
31555
31561
|
style: {
|
|
31556
31562
|
width: renderWidth,
|
|
31557
31563
|
height: renderHeight
|
|
@@ -32638,6 +32644,56 @@ function Toggle(_ref) {
|
|
|
32638
32644
|
});
|
|
32639
32645
|
}
|
|
32640
32646
|
|
|
32647
|
+
var useTooltip = function useTooltip() {
|
|
32648
|
+
var calculatePosition = useCallback(function (args) {
|
|
32649
|
+
var _args$maxWidth;
|
|
32650
|
+
var result = {
|
|
32651
|
+
maxWidth: 'none',
|
|
32652
|
+
width: 'auto',
|
|
32653
|
+
left: '0px',
|
|
32654
|
+
top: '0px',
|
|
32655
|
+
bottom: '0px',
|
|
32656
|
+
translateX: '0',
|
|
32657
|
+
translateY: '0'
|
|
32658
|
+
};
|
|
32659
|
+
result.maxWidth = (_args$maxWidth = args.maxWidth) != null ? _args$maxWidth : 'none';
|
|
32660
|
+
var offsetH = args.tooltipSize === 'small' ? 11 : 22;
|
|
32661
|
+
var targetHorizontalCenter = args.dimensions.right - (args.dimensions.right - args.dimensions.left) / 2;
|
|
32662
|
+
var targetLeft = args.dimensions.left;
|
|
32663
|
+
var targetRight = args.dimensions.right;
|
|
32664
|
+
var targetWidth = args.dimensions.width;
|
|
32665
|
+
switch (args.horizontalAlign) {
|
|
32666
|
+
case 'center':
|
|
32667
|
+
result.left = targetHorizontalCenter + "px";
|
|
32668
|
+
result.translateX = '-50%';
|
|
32669
|
+
break;
|
|
32670
|
+
case 'left':
|
|
32671
|
+
result.left = targetLeft - offsetH + "px";
|
|
32672
|
+
result.translateX = targetWidth / 2 + "px";
|
|
32673
|
+
break;
|
|
32674
|
+
case 'right':
|
|
32675
|
+
result.left = targetRight + offsetH + "px";
|
|
32676
|
+
result.translateX = "-" + targetWidth / 2 + "px";
|
|
32677
|
+
break;
|
|
32678
|
+
}
|
|
32679
|
+
switch (args.verticalPosition) {
|
|
32680
|
+
case 'bottom':
|
|
32681
|
+
result.top = args.dimensions.top + args.dimensions.height + window.scrollY + "px";
|
|
32682
|
+
result.bottom = 'unset';
|
|
32683
|
+
break;
|
|
32684
|
+
case 'top':
|
|
32685
|
+
result.top = args.dimensions.top + window.scrollY + "px";
|
|
32686
|
+
result.bottom = 'unset';
|
|
32687
|
+
result.translateY = '-100%';
|
|
32688
|
+
break;
|
|
32689
|
+
}
|
|
32690
|
+
return result;
|
|
32691
|
+
}, []);
|
|
32692
|
+
return {
|
|
32693
|
+
calculatePosition: calculatePosition
|
|
32694
|
+
};
|
|
32695
|
+
};
|
|
32696
|
+
|
|
32641
32697
|
var TailIcon = function TailIcon(props) {
|
|
32642
32698
|
var tailClasses = clsx$1('absolute fill-background-uiBackgroundTooltip', {
|
|
32643
32699
|
'rotate-180': props.verticalPosition === 'bottom',
|
|
@@ -32679,6 +32735,53 @@ var TailIcon = function TailIcon(props) {
|
|
|
32679
32735
|
}
|
|
32680
32736
|
};
|
|
32681
32737
|
|
|
32738
|
+
var TooltipContent = function TooltipContent(_ref) {
|
|
32739
|
+
var content = _ref.content,
|
|
32740
|
+
horizontalAlign = _ref.horizontalAlign,
|
|
32741
|
+
verticalPosition = _ref.verticalPosition,
|
|
32742
|
+
size = _ref.size,
|
|
32743
|
+
tooltipPosition = _ref.tooltipPosition,
|
|
32744
|
+
maxWidth = _ref.maxWidth,
|
|
32745
|
+
isPortal = _ref.isPortal;
|
|
32746
|
+
var tooltipWrapperClasses = clsx$1('absolute z-tooltip m-auto flex', {
|
|
32747
|
+
'top-0': !isPortal && verticalPosition === 'top',
|
|
32748
|
+
'bottom-0': !isPortal && verticalPosition === 'bottom',
|
|
32749
|
+
'justify-start': horizontalAlign === 'left',
|
|
32750
|
+
'justify-center': horizontalAlign === 'center',
|
|
32751
|
+
'justify-end': horizontalAlign === 'right',
|
|
32752
|
+
'w-[24px]': size === 'small',
|
|
32753
|
+
'w-[46px]': size !== 'small'
|
|
32754
|
+
});
|
|
32755
|
+
var tooltipBodyClasses = clsx$1('absolute z-tooltip inline-block w-max rounded bg-background-uiBackgroundTooltip text-text-textOnColor', {
|
|
32756
|
+
'typography-body3regular': size === 'small',
|
|
32757
|
+
'typography-body2regular': size === 'medium',
|
|
32758
|
+
'px-2 pb-1 pt-1.5': size === 'small',
|
|
32759
|
+
'px-4 py-3': size === 'medium',
|
|
32760
|
+
'bottom-2': verticalPosition !== 'bottom' && size === 'small',
|
|
32761
|
+
'bottom-3': verticalPosition !== 'bottom' && size === 'medium',
|
|
32762
|
+
'top-2': verticalPosition === 'bottom' && size === 'small',
|
|
32763
|
+
'top-3': verticalPosition === 'bottom' && size === 'medium'
|
|
32764
|
+
});
|
|
32765
|
+
var tooltipWrapperStyle = isPortal ? _extends({
|
|
32766
|
+
transform: "translate(" + tooltipPosition.translateX + ", " + tooltipPosition.translateY + ")"
|
|
32767
|
+
}, tooltipPosition) : {};
|
|
32768
|
+
return /*#__PURE__*/jsx("div", {
|
|
32769
|
+
className: tooltipWrapperClasses,
|
|
32770
|
+
style: tooltipWrapperStyle,
|
|
32771
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
32772
|
+
className: tooltipBodyClasses,
|
|
32773
|
+
style: {
|
|
32774
|
+
maxWidth: maxWidth
|
|
32775
|
+
},
|
|
32776
|
+
children: [content, /*#__PURE__*/jsx(TailIcon, {
|
|
32777
|
+
size: size,
|
|
32778
|
+
verticalPosition: verticalPosition,
|
|
32779
|
+
horizontalAlign: horizontalAlign
|
|
32780
|
+
})]
|
|
32781
|
+
})
|
|
32782
|
+
});
|
|
32783
|
+
};
|
|
32784
|
+
|
|
32682
32785
|
function Tooltip(_ref) {
|
|
32683
32786
|
var children = _ref.children,
|
|
32684
32787
|
content = _ref.content,
|
|
@@ -32690,10 +32793,24 @@ function Tooltip(_ref) {
|
|
|
32690
32793
|
_ref$horizontalAlign = _ref.horizontalAlign,
|
|
32691
32794
|
horizontalAlign = _ref$horizontalAlign === void 0 ? 'center' : _ref$horizontalAlign,
|
|
32692
32795
|
_ref$isDisabledHover = _ref.isDisabledHover,
|
|
32693
|
-
isDisabledHover = _ref$isDisabledHover === void 0 ? false : _ref$isDisabledHover
|
|
32796
|
+
isDisabledHover = _ref$isDisabledHover === void 0 ? false : _ref$isDisabledHover,
|
|
32797
|
+
portalTargetRef = _ref.portalTargetRef;
|
|
32798
|
+
var _useTooltip = useTooltip(),
|
|
32799
|
+
calculatePosition = _useTooltip.calculatePosition;
|
|
32694
32800
|
var _useState = useState(false),
|
|
32695
32801
|
isVisible = _useState[0],
|
|
32696
32802
|
setIsVisible = _useState[1];
|
|
32803
|
+
var _useState2 = useState({
|
|
32804
|
+
maxWidth: 'none',
|
|
32805
|
+
width: 'auto',
|
|
32806
|
+
left: '0px',
|
|
32807
|
+
top: '0px',
|
|
32808
|
+
bottom: '0px',
|
|
32809
|
+
translateX: '0',
|
|
32810
|
+
translateY: '0'
|
|
32811
|
+
}),
|
|
32812
|
+
tooltipPosition = _useState2[0],
|
|
32813
|
+
setTooltipPosition = _useState2[1];
|
|
32697
32814
|
var targetRef = useRef(null);
|
|
32698
32815
|
var handleMouseOverWrapper = useCallback(function () {
|
|
32699
32816
|
if (isDisabledHover) {
|
|
@@ -32704,44 +32821,40 @@ function Tooltip(_ref) {
|
|
|
32704
32821
|
var handleMouseOutWrapper = useCallback(function () {
|
|
32705
32822
|
setIsVisible(false);
|
|
32706
32823
|
}, []);
|
|
32707
|
-
|
|
32708
|
-
|
|
32709
|
-
|
|
32710
|
-
|
|
32711
|
-
|
|
32712
|
-
|
|
32713
|
-
|
|
32714
|
-
|
|
32715
|
-
|
|
32716
|
-
|
|
32717
|
-
|
|
32718
|
-
|
|
32719
|
-
|
|
32720
|
-
'px-4 py-3': size === 'medium',
|
|
32721
|
-
'bottom-2': verticalPosition !== 'bottom' && size === 'small',
|
|
32722
|
-
'bottom-3': verticalPosition !== 'bottom' && size === 'medium',
|
|
32723
|
-
'top-2': verticalPosition === 'bottom' && size === 'small',
|
|
32724
|
-
'top-3': verticalPosition === 'bottom' && size === 'medium'
|
|
32725
|
-
});
|
|
32824
|
+
useEffect(function () {
|
|
32825
|
+
var _targetRef$current;
|
|
32826
|
+
if (targetRef.current === null) return;
|
|
32827
|
+
var dimensions = (_targetRef$current = targetRef.current) == null ? void 0 : _targetRef$current.getBoundingClientRect();
|
|
32828
|
+
var position = calculatePosition({
|
|
32829
|
+
dimensions: dimensions,
|
|
32830
|
+
maxWidth: maxWidth,
|
|
32831
|
+
verticalPosition: verticalPosition,
|
|
32832
|
+
horizontalAlign: horizontalAlign,
|
|
32833
|
+
tooltipSize: size
|
|
32834
|
+
});
|
|
32835
|
+
setTooltipPosition(position);
|
|
32836
|
+
}, [calculatePosition, horizontalAlign, maxWidth, size, verticalPosition]);
|
|
32726
32837
|
return /*#__PURE__*/jsxs("div", {
|
|
32727
32838
|
ref: targetRef,
|
|
32728
32839
|
className: "relative flex items-center justify-center",
|
|
32729
32840
|
onMouseOver: handleMouseOverWrapper,
|
|
32730
32841
|
onMouseLeave: handleMouseOutWrapper,
|
|
32731
|
-
children: [children, isVisible && /*#__PURE__*/jsx(
|
|
32732
|
-
|
|
32733
|
-
|
|
32734
|
-
|
|
32735
|
-
|
|
32736
|
-
|
|
32737
|
-
|
|
32738
|
-
|
|
32739
|
-
|
|
32740
|
-
|
|
32741
|
-
|
|
32742
|
-
|
|
32743
|
-
|
|
32744
|
-
|
|
32842
|
+
children: [children, isVisible && ((portalTargetRef == null ? void 0 : portalTargetRef.current) == null ? /*#__PURE__*/jsx(TooltipContent, {
|
|
32843
|
+
content: content,
|
|
32844
|
+
size: size,
|
|
32845
|
+
maxWidth: maxWidth,
|
|
32846
|
+
verticalPosition: verticalPosition,
|
|
32847
|
+
horizontalAlign: horizontalAlign,
|
|
32848
|
+
tooltipPosition: tooltipPosition
|
|
32849
|
+
}) : ( /*#__PURE__*/reactDom.createPortal( /*#__PURE__*/jsx(TooltipContent, {
|
|
32850
|
+
isPortal: true,
|
|
32851
|
+
content: content,
|
|
32852
|
+
size: size,
|
|
32853
|
+
maxWidth: maxWidth,
|
|
32854
|
+
verticalPosition: verticalPosition,
|
|
32855
|
+
horizontalAlign: horizontalAlign,
|
|
32856
|
+
tooltipPosition: tooltipPosition
|
|
32857
|
+
}), (portalTargetRef == null ? void 0 : portalTargetRef.current) != null ? portalTargetRef.current : document.body)))]
|
|
32745
32858
|
});
|
|
32746
32859
|
}
|
|
32747
32860
|
|