bianic-ui 2.1.0-beta.4 → 2.2.0-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/dist/cjs/index.js +128 -124
- package/dist/cjs/lib.css +1 -1
- package/dist/cjs/types/components/Alert/Alert.d.ts +4 -1
- package/dist/cjs/types/components/Badge/Badge.d.ts +1 -0
- package/dist/cjs/types/components/Button/buttonConfigs.d.ts +6 -0
- package/dist/cjs/types/components/Forms/Dropdown/DropdownContainer.d.ts +1 -0
- package/dist/cjs/types/components/Menu/MenuContainer.d.ts +1 -0
- package/dist/cjs/types/components/Popover/PropInterface.d.ts +21 -0
- package/dist/cjs/types/components/Popover/index.d.ts +2 -10
- package/dist/cjs/types/components/Tooltip/PropsInterface.d.ts +6 -2
- package/dist/cjs/types/stories/Alert/Alert.stories.d.ts +1 -0
- package/dist/cjs/types/stories/Button/Button.stories.d.ts +1 -0
- package/dist/esm/index.js +128 -124
- package/dist/esm/lib.css +1 -1
- package/dist/esm/types/components/Alert/Alert.d.ts +4 -1
- package/dist/esm/types/components/Badge/Badge.d.ts +1 -0
- package/dist/esm/types/components/Button/buttonConfigs.d.ts +6 -0
- package/dist/esm/types/components/Forms/Dropdown/DropdownContainer.d.ts +1 -0
- package/dist/esm/types/components/Menu/MenuContainer.d.ts +1 -0
- package/dist/esm/types/components/Popover/PropInterface.d.ts +21 -0
- package/dist/esm/types/components/Popover/index.d.ts +2 -10
- package/dist/esm/types/components/Tooltip/PropsInterface.d.ts +6 -2
- package/dist/esm/types/stories/Alert/Alert.stories.d.ts +1 -0
- package/dist/esm/types/stories/Button/Button.stories.d.ts +1 -0
- package/dist/index.d.ts +17 -6
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -384,7 +384,7 @@ Link.defaultProps = {
|
|
|
384
384
|
};
|
|
385
385
|
|
|
386
386
|
function Alert(_a) {
|
|
387
|
-
var _b = _a.title, title = _b === void 0 ? '' : _b, caption = _a.caption, _c = _a.variant, variant = _c === void 0 ? 'base' : _c, _d = _a.visible, visible = _d === void 0 ? true : _d, _e = _a.setVisible, setVisible = _e === void 0 ? function () { } : _e, _f = _a.visibleIcon, visibleIcon = _f === void 0 ? true : _f, _g = _a.visibleClose, visibleClose = _g === void 0 ? false : _g, children = _a.children;
|
|
387
|
+
var _b = _a.title, title = _b === void 0 ? '' : _b, caption = _a.caption, _c = _a.variant, variant = _c === void 0 ? 'base' : _c, _d = _a.visible, visible = _d === void 0 ? true : _d, _e = _a.setVisible, setVisible = _e === void 0 ? function () { } : _e, _f = _a.visibleIcon, visibleIcon = _f === void 0 ? true : _f, _g = _a.visibleClose, visibleClose = _g === void 0 ? false : _g, customIcon = _a.customIcon, customMiniIcon = _a.customMiniIcon, children = _a.children;
|
|
388
388
|
var validateVariant = validUnion(variant, [
|
|
389
389
|
'base',
|
|
390
390
|
'info',
|
|
@@ -394,6 +394,9 @@ function Alert(_a) {
|
|
|
394
394
|
]);
|
|
395
395
|
var IconComponent = AlertConfig[validateVariant].icon[visibleIcon ? 'true' : 'false'];
|
|
396
396
|
var IconX = AlertConfig[visibleClose ? 'true' : 'false'];
|
|
397
|
+
var iconDisplay = visibleIcon
|
|
398
|
+
? customIcon !== null && customIcon !== void 0 ? customIcon : React.createElement(IconComponent, { size: 20, color: "white" })
|
|
399
|
+
: null;
|
|
397
400
|
var content = children || React.createElement(Text, { variant: "small-text" }, caption);
|
|
398
401
|
return (visible && (React.createElement("div", { className: "alert-container flex w-full flex-col" },
|
|
399
402
|
React.createElement("div", { className: "alert-body w-full ".concat(AlertConfig[validateVariant].bg, " rounded-[5px]") },
|
|
@@ -401,13 +404,14 @@ function Alert(_a) {
|
|
|
401
404
|
React.createElement("div", { className: "alert-accent flex items-center py-[10px]" },
|
|
402
405
|
React.createElement("div", { className: "left-0 h-full w-[3px] ".concat(AlertConfig[validateVariant].vBar, " rounded-r-[10px]") })),
|
|
403
406
|
React.createElement("div", { className: "alert-content flex w-full items-start py-[10px] pe-[10px]" },
|
|
404
|
-
React.createElement("div", { className: "icon-area flex ps-[10px]" }, IconComponent && typeof IconComponent === 'function' && (React.createElement("div", { className: "flex p-[7px] ".concat(AlertConfig[validateVariant].ContainerIcon, " items-center justify-center rounded-radius-full") },
|
|
405
|
-
|
|
406
|
-
React.createElement("div", { className: "content-area flex w-full justify-between" },
|
|
407
|
+
React.createElement("div", { className: "icon-area flex ps-[10px]" }, IconComponent && typeof IconComponent === 'function' && (React.createElement("div", { className: "flex p-[7px] ".concat(AlertConfig[validateVariant].ContainerIcon, " items-center justify-center rounded-radius-full text-bia-white") }, iconDisplay))),
|
|
408
|
+
React.createElement("div", { className: "content-area flex w-full justify-between text-bia-black" },
|
|
407
409
|
React.createElement("div", { className: "text-area text-area flex flex-col ps-[10px] font-segoe text-size-sm font-normal ".concat(visibleClose ? 'mr-[10px]' : '', " ").concat(visibleIcon ? '' : 'ml-[-10px]') },
|
|
408
410
|
React.createElement("div", { className: "flex justify-between" },
|
|
409
411
|
React.createElement(Text, { variant: "normal-text-semibold" }, title)),
|
|
410
|
-
|
|
412
|
+
React.createElement("div", { className: "flex flex-row items-start gap-[5px]" },
|
|
413
|
+
customMiniIcon ? customMiniIcon : null,
|
|
414
|
+
content)),
|
|
411
415
|
IconX && typeof IconX === 'function' && (React.createElement("div", { className: "closable-area flex " },
|
|
412
416
|
React.createElement(IconX, { className: "cursor-pointer ".concat(AlertConfig[validateVariant].hover, " ").concat(AlertConfig[validateVariant].active, " ").concat(AlertConfig[validateVariant].focus, " ").concat(AlertConfig[validateVariant].close), onClick: function () { return setVisible(false); }, tabIndex: 0 }))))))))));
|
|
413
417
|
}
|
|
@@ -458,6 +462,12 @@ var iconOnlySizeConfig$1 = {
|
|
|
458
462
|
sm: 'py-[8px] h-[30px] w-[30px] flex items-center justify-center gap-[5px] ',
|
|
459
463
|
tn: 'py-[4px] h-[22px] w-[22px] flex items-center justify-center gap-[3px]',
|
|
460
464
|
};
|
|
465
|
+
var doubleIconSizeConfig = {
|
|
466
|
+
lg: 'py-[13px] h-[48px] flex items-center justify-center gap-[10px]',
|
|
467
|
+
md: 'py-[11px] h-[40px] flex items-center justify-center gap-[5px]',
|
|
468
|
+
sm: 'py-[8px] h-[30px] flex items-center justify-center gap-[5px] ',
|
|
469
|
+
tn: 'py-[4px] h-[22px] flex items-center justify-center gap-[3px]',
|
|
470
|
+
};
|
|
461
471
|
var shadow = 'shadow-[0px_6px_18px_1px_rgba(188,199,237,0.5)] disabled:shadow-none active:shadow-none';
|
|
462
472
|
var variantConfig$2 = {
|
|
463
473
|
default: "text-primary-black bg-bia-grey active:bg-bia-grey-dark-10 hover:bg-bia-grey-hover disabled:bg-bia-grey-disabled disabled:text-bia-grey-active focus-visible:outline focus-visible:outline-offset-0 focus-visible:outline-bia-blue-light-50 focus-visible:outline-[3px] focus-visible:rounded-md shadow-[0px_6px_18px_1px_#BCC7ED80] ".concat(shadow),
|
|
@@ -517,9 +527,15 @@ var Button = React.forwardRef(function (_a, ref) {
|
|
|
517
527
|
else {
|
|
518
528
|
sizingRules = "".concat(sizeConfig$d[validatedSize], " ").concat(sidePaddingConfig[validatedSize]);
|
|
519
529
|
}
|
|
530
|
+
var hasDoubleIcon = iconRight && iconLeft;
|
|
531
|
+
var isVariantLink = variant.includes('link')
|
|
532
|
+
? ''
|
|
533
|
+
: "".concat(sidePaddingConfig[validatedSize]);
|
|
520
534
|
var sizeClass = label || variant === 'form-group'
|
|
521
535
|
? " ".concat(minWidthRules, " ").concat(sizingRules)
|
|
522
|
-
:
|
|
536
|
+
: hasDoubleIcon
|
|
537
|
+
? "".concat(doubleIconSizeConfig[validatedSize], " ").concat(isVariantLink)
|
|
538
|
+
: "".concat(iconOnlySizeConfig$1[validatedSize], " ").concat(isVariantLink, " ").concat(isVariantLink);
|
|
523
539
|
var classString = "\n ".concat(variantConfig$2[validatedVariant], "\n ").concat(sizeClass, "\n ").concat(radiusConfig$1[validatedRadius][validatedSize], "\n ").concat(className, "\n ");
|
|
524
540
|
return (React.createElement("button", __assign({ ref: ref, type: "button", className: "bianic-button bianic-fgc-target flex items-center justify-center font-semibold ".concat(classString), disabled: disabled }, props),
|
|
525
541
|
childrenElement(iconLeft || left),
|
|
@@ -604,9 +620,9 @@ var typeConfig = {
|
|
|
604
620
|
};
|
|
605
621
|
|
|
606
622
|
function Badge(_a) {
|
|
607
|
-
var
|
|
623
|
+
var _b = _a.type, type = _b === void 0 ? 'standart' : _b, children = _a.children, color = _a.color, isInverted = _a.isInverted, className = _a.className;
|
|
608
624
|
var divRef = React.useRef(null);
|
|
609
|
-
var
|
|
625
|
+
var _c = React.useState(0), fontSize = _c[0], setFontSize = _c[1];
|
|
610
626
|
var typeClasses = typeConfig[type];
|
|
611
627
|
var isStandart = type === 'standart';
|
|
612
628
|
var bgColor = isInverted && isStandart ? '#ffffff' : color || '';
|
|
@@ -621,7 +637,7 @@ function Badge(_a) {
|
|
|
621
637
|
setFontSize(fontSizeStyle);
|
|
622
638
|
}
|
|
623
639
|
}, []);
|
|
624
|
-
return (React.createElement("span", { className: "w-fit
|
|
640
|
+
return (React.createElement("span", { className: "flex w-fit items-center justify-center bg-bia-grey font-segoe font-semibold leading-none text-bia-coolgrey ".concat(typeClasses, " ").concat(className), style: {
|
|
625
641
|
backgroundColor: bgColor,
|
|
626
642
|
color: textColor,
|
|
627
643
|
paddingLeft: horizontalPadding,
|
|
@@ -632,6 +648,7 @@ function Badge(_a) {
|
|
|
632
648
|
React.createElement("span", { ref: divRef, style: { marginTop: contentMarginTop } }, children)));
|
|
633
649
|
}
|
|
634
650
|
Badge.defaultProps = {
|
|
651
|
+
type: 'standart',
|
|
635
652
|
isInverted: false,
|
|
636
653
|
color: undefined,
|
|
637
654
|
};
|
|
@@ -1864,24 +1881,40 @@ var MenuElement = React.forwardRef(function (_a, ref) {
|
|
|
1864
1881
|
})));
|
|
1865
1882
|
});
|
|
1866
1883
|
var MenuContainer = function (props) {
|
|
1867
|
-
var _a = props.isTopFlat, isTopFlat = _a === void 0 ? false : _a, children = props.children, _b = props.open, open = _b === void 0 ? true : _b, _c = props.onClose, onClose = _c === void 0 ? function () { } : _c, _d = props.className, className = _d === void 0 ? '' : _d, _e = props.isWithOverlay, isWithOverlay = _e === void 0 ? true : _e, _f = props.zIndex, zIndex = _f === void 0 ? 100 : _f, _g = props.onClickItem, onClickItem = _g === void 0 ? function () { } : _g, anchorRef = props.anchorRef, restProps = __rest(props, ["isTopFlat", "children", "open", "onClose", "className", "isWithOverlay", "zIndex", "onClickItem", "anchorRef"]);
|
|
1884
|
+
var _a = props.isTopFlat, isTopFlat = _a === void 0 ? false : _a, children = props.children, _b = props.open, open = _b === void 0 ? true : _b, _c = props.onClose, onClose = _c === void 0 ? function () { } : _c, _d = props.className, className = _d === void 0 ? '' : _d, _e = props.isWithOverlay, isWithOverlay = _e === void 0 ? true : _e, _f = props.zIndex, zIndex = _f === void 0 ? 100 : _f, _g = props.onClickItem, onClickItem = _g === void 0 ? function () { } : _g, anchorRef = props.anchorRef, matchAnchorWidth = props.matchAnchorWidth, restProps = __rest(props, ["isTopFlat", "children", "open", "onClose", "className", "isWithOverlay", "zIndex", "onClickItem", "anchorRef", "matchAnchorWidth"]);
|
|
1868
1885
|
if (!open)
|
|
1869
1886
|
return null;
|
|
1870
1887
|
var MenuContainerRef = React.useRef(null);
|
|
1871
1888
|
var positionStyle = usePopupPosition(anchorRef, MenuContainerRef)[0];
|
|
1872
1889
|
var newStyle = React.useMemo(function () {
|
|
1873
|
-
var _a;
|
|
1890
|
+
var _a, _b;
|
|
1874
1891
|
if (!(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)) {
|
|
1875
1892
|
return {};
|
|
1876
1893
|
}
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1894
|
+
var widthStyle = {};
|
|
1895
|
+
switch (matchAnchorWidth) {
|
|
1896
|
+
case 'min':
|
|
1897
|
+
widthStyle = {
|
|
1898
|
+
minWidth: "".concat((_a = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth, "px"),
|
|
1899
|
+
};
|
|
1900
|
+
break;
|
|
1901
|
+
case 'exact':
|
|
1902
|
+
widthStyle = {
|
|
1903
|
+
width: "".concat((_b = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth, "px"),
|
|
1904
|
+
};
|
|
1905
|
+
break;
|
|
1906
|
+
default:
|
|
1907
|
+
widthStyle = { minWidth: '120px' };
|
|
1908
|
+
break;
|
|
1909
|
+
}
|
|
1910
|
+
return __assign(__assign({ zIndex: zIndex + 10 }, widthStyle), positionStyle);
|
|
1880
1911
|
}, [positionStyle]);
|
|
1881
1912
|
var menuElement = (React.createElement(MenuElement, __assign({ isTopFlat: isTopFlat, children: children, className: className, zIndex: zIndex, menuRef: MenuContainerRef, onClose: onClose, onClickItem: onClickItem, style: newStyle }, restProps)));
|
|
1882
1913
|
return (React.createElement(React.Fragment, null,
|
|
1883
1914
|
isWithOverlay && (React.createElement("div", { className: "bianic-menu-overlay fixed left-0 top-0 z-0 h-screen w-screen", onClick: function () { return onClose(); }, style: { zIndex: zIndex } })),
|
|
1884
|
-
(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)
|
|
1915
|
+
(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)
|
|
1916
|
+
? reactDom.createPortal(menuElement, document.body)
|
|
1917
|
+
: menuElement));
|
|
1885
1918
|
};
|
|
1886
1919
|
MenuContainer.defaultProps = {
|
|
1887
1920
|
isTopFlat: false,
|
|
@@ -1956,15 +1989,15 @@ MenuItem.defaultProps = {
|
|
|
1956
1989
|
};
|
|
1957
1990
|
|
|
1958
1991
|
function Tooltip(props) {
|
|
1959
|
-
var children = props.children, content = props.content, delay = props.delay, _a = props.direction, direction = _a === void 0 ? 'top' : _a, _b = props.maxWidth, maxWidth = _b === void 0 ? undefined : _b;
|
|
1992
|
+
var children = props.children, content = props.content, delay = props.delay, _a = props.direction, direction = _a === void 0 ? 'top' : _a, _b = props.maxWidth, maxWidth = _b === void 0 ? undefined : _b, _c = props.zIndex, zIndex = _c === void 0 ? 150 : _c, className = props.className, style = props.style;
|
|
1960
1993
|
var timeout;
|
|
1961
|
-
var
|
|
1994
|
+
var _d = React.useState(false), active = _d[0], setActive = _d[1];
|
|
1962
1995
|
var anchorRef = React.useRef(null);
|
|
1963
1996
|
var tooltipContainerRef = React.useRef(null);
|
|
1964
|
-
var
|
|
1997
|
+
var _e = React.useState({
|
|
1965
1998
|
maxWidth: maxWidth + 'px',
|
|
1966
1999
|
whiteSpace: 'nowrap',
|
|
1967
|
-
}), tooltipContainerStyle =
|
|
2000
|
+
}), tooltipContainerStyle = _e[0], setTooltipContainerStyle = _e[1];
|
|
1968
2001
|
var showTip = function () {
|
|
1969
2002
|
timeout = setTimeout(function () {
|
|
1970
2003
|
setActive(true);
|
|
@@ -2008,12 +2041,12 @@ function Tooltip(props) {
|
|
|
2008
2041
|
}, [content, maxWidth, scrollWidth, offsetHeight]);
|
|
2009
2042
|
return (React.createElement("div", { className: "tooltip-wrapper relative inline-flex h-fit w-fit flex-col", onMouseEnter: showTip, onMouseLeave: hideTip, ref: anchorRef },
|
|
2010
2043
|
children,
|
|
2011
|
-
active && (React.createElement(TooltipItem, { anchorRef: anchorRef, direction: direction, content: content, tooltipContainerRef: tooltipContainerRef, tooltipContainerStyle: tooltipContainerStyle }))));
|
|
2044
|
+
active && (React.createElement(TooltipItem, { anchorRef: anchorRef, direction: direction, content: content, tooltipContainerRef: tooltipContainerRef, tooltipContainerStyle: tooltipContainerStyle, zIndex: zIndex, className: className, style: style }))));
|
|
2012
2045
|
}
|
|
2013
2046
|
var TooltipItem = function (_a) {
|
|
2014
|
-
var anchorRef = _a.anchorRef,
|
|
2047
|
+
var anchorRef = _a.anchorRef, className = _a.className, content = _a.content, direction = _a.direction, style = _a.style, tooltipContainerRef = _a.tooltipContainerRef, tooltipContainerStyle = _a.tooltipContainerStyle, zIndex = _a.zIndex;
|
|
2015
2048
|
var positionStyle = usePopupPosition(anchorRef, tooltipContainerRef, direction)[0];
|
|
2016
|
-
return reactDom.createPortal(React.createElement("div", { className: "tooltip-container break-word absolute
|
|
2049
|
+
return reactDom.createPortal(React.createElement("div", { className: "tooltip-container break-word absolute inline-block break-all rounded-[4px] bg-primary-black px-[7px] py-[4px] text-size-sm text-primary-white ".concat(className), style: __assign(__assign(__assign({ zIndex: zIndex }, positionStyle), tooltipContainerStyle), style), ref: tooltipContainerRef }, content), document.body);
|
|
2017
2050
|
};
|
|
2018
2051
|
Tooltip.defaultProps = {
|
|
2019
2052
|
delay: 400,
|
|
@@ -2361,84 +2394,13 @@ DefaultDropdownItem.defaultProps = {
|
|
|
2361
2394
|
caption: '',
|
|
2362
2395
|
};
|
|
2363
2396
|
|
|
2364
|
-
var containerSizeConfig = {
|
|
2365
|
-
sm: 'min-w-[72px]',
|
|
2366
|
-
md: 'min-w-[96px]',
|
|
2367
|
-
};
|
|
2368
|
-
var itemSizeConfig = {
|
|
2369
|
-
sm: 'min-h-[30px] border-y-[2px] border-bia-white',
|
|
2370
|
-
md: 'min-h-[40px] border-y-[3px] border-bia-white',
|
|
2371
|
-
};
|
|
2372
|
-
var fontConfig = {
|
|
2373
|
-
sm: 'text-[12px] font-[400]',
|
|
2374
|
-
md: 'text-[14px] font-[350]',
|
|
2375
|
-
};
|
|
2376
|
-
|
|
2377
|
-
var DropdownContNoAnchor = React.forwardRef(function DropdownContNoAnchor(propsComp, ref) {
|
|
2378
|
-
var _a = propsComp.isTopFlat, isTopFlat = _a === void 0 ? false : _a, children = propsComp.children, _b = propsComp.open, open = _b === void 0 ? true : _b, _c = propsComp.onClose, onClose = _c === void 0 ? function () { } : _c, _d = propsComp.className, className = _d === void 0 ? '' : _d, _e = propsComp.isWithOverlay, isWithOverlay = _e === void 0 ? true : _e, _f = propsComp.size, size = _f === void 0 ? 'md' : _f, _g = propsComp.onClickItem, onClickItem = _g === void 0 ? function () { } : _g, _h = propsComp.zIndex, zIndex = _h === void 0 ? 100 : _h, restProps = __rest(propsComp, ["isTopFlat", "children", "open", "onClose", "className", "isWithOverlay", "size", "onClickItem", "zIndex"]);
|
|
2379
|
-
var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
|
|
2380
|
-
var sizeClass = containerSizeConfig[size] || containerSizeConfig['md'];
|
|
2381
|
-
var containerClass = "".concat(sizeClass, " ").concat(radiusClass, " ").concat(className);
|
|
2382
|
-
var handleClickDrpdownItem = function (e, val) {
|
|
2383
|
-
onClickItem(e, val);
|
|
2384
|
-
onClose();
|
|
2385
|
-
};
|
|
2386
|
-
return (open && (React.createElement(React.Fragment, null,
|
|
2387
|
-
isWithOverlay && (React.createElement("div", { className: "bianic-dropdown-overlay fixed left-0 top-0 h-screen w-screen", style: { zIndex: zIndex }, onClick: function () { return onClose(); } })),
|
|
2388
|
-
React.createElement("div", __assign({ style: {
|
|
2389
|
-
zIndex: zIndex + 10, // Ensure dropdown is above overlay
|
|
2390
|
-
}, ref: ref, className: "bianic-dropdown-container bg-bia-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] ".concat(containerClass) }, restProps), React.Children.map(children, function (child) {
|
|
2391
|
-
return React.isValidElement(child)
|
|
2392
|
-
? // Kirimkan handleItemClick sebagai props onClick ke setiap DropdownItem
|
|
2393
|
-
React.cloneElement(child, {
|
|
2394
|
-
onClose: function () { return onClose(); },
|
|
2395
|
-
size: size,
|
|
2396
|
-
onClickItem: function (e, val) { return handleClickDrpdownItem(e, val); },
|
|
2397
|
-
zIndex: zIndex + 10,
|
|
2398
|
-
})
|
|
2399
|
-
: child;
|
|
2400
|
-
})))));
|
|
2401
|
-
});
|
|
2402
|
-
DropdownContNoAnchor.defaultProps = {
|
|
2403
|
-
isTopFlat: false,
|
|
2404
|
-
};
|
|
2405
|
-
|
|
2406
2397
|
var sizeUnion$2 = ['md', 'sm'];
|
|
2407
2398
|
function SelectInput(_a) {
|
|
2408
2399
|
var descText = _a.descText, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.size, size = _c === void 0 ? 'md' : _c, id = _a.id, _d = _a.isValid, isValid = _d === void 0 ? null : _d, label = _a.label, _e = _a.options, options = _e === void 0 ? [] : _e, _f = _a.required, required = _f === void 0 ? false : _f, selected = _a.selected, setSelected = _a.setSelected, _g = _a.onClickDropdown, onClickDropdown = _g === void 0 ? function () { } : _g, children = _a.children, _h = _a.dropContProps, _j = _h === void 0 ? {} : _h, _k = _j.className, dropContClassName = _k === void 0 ? '' : _k, restDropContProps = __rest(_j, ["className"]), props = __rest(_a, ["descText", "disabled", "size", "id", "isValid", "label", "options", "required", "selected", "setSelected", "onClickDropdown", "children", "dropContProps"]);
|
|
2409
2400
|
var _l = React.useState(false), isOpen = _l[0], setIsOpen = _l[1];
|
|
2410
|
-
var _m = React.useState(false), isDropUp = _m[0], setIsDropUp = _m[1];
|
|
2411
2401
|
var validatedSize = validUnion(size, sizeUnion$2);
|
|
2412
|
-
var
|
|
2402
|
+
var _m = sizeConfig$8[validatedSize], searchSize = _m.searchSize, iconSize = _m.iconSize;
|
|
2413
2403
|
var inputRef = React.useRef(null);
|
|
2414
|
-
var dropdownContRef = React.useRef(null);
|
|
2415
|
-
var handleOutsideClick = function (e) {
|
|
2416
|
-
if (inputRef.current && !inputRef.current.contains(e.target)) {
|
|
2417
|
-
setIsOpen(false);
|
|
2418
|
-
}
|
|
2419
|
-
};
|
|
2420
|
-
React.useEffect(function () {
|
|
2421
|
-
document.addEventListener('mousedown', handleOutsideClick);
|
|
2422
|
-
return function () {
|
|
2423
|
-
document.removeEventListener('mousedown', handleOutsideClick);
|
|
2424
|
-
};
|
|
2425
|
-
});
|
|
2426
|
-
React.useEffect(function () {
|
|
2427
|
-
var _a, _b;
|
|
2428
|
-
if (inputRef.current) {
|
|
2429
|
-
// Adjust dropdown position to prevent show up out of screen
|
|
2430
|
-
var windowHeight = window.innerHeight;
|
|
2431
|
-
var inputRect = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
2432
|
-
var inputBottom = inputRect === null || inputRect === void 0 ? void 0 : inputRect.bottom;
|
|
2433
|
-
var diff = windowHeight - inputBottom;
|
|
2434
|
-
var dropdownRect = (_b = dropdownContRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
|
|
2435
|
-
var dropdownHeight = (dropdownRect === null || dropdownRect === void 0 ? void 0 : dropdownRect.height) || 0;
|
|
2436
|
-
if (dropdownHeight >= diff)
|
|
2437
|
-
setIsDropUp(true);
|
|
2438
|
-
else
|
|
2439
|
-
setIsDropUp(false);
|
|
2440
|
-
}
|
|
2441
|
-
}, [isOpen]);
|
|
2442
2404
|
var isObjectOptionItem = false;
|
|
2443
2405
|
if (options.every(function (item) { return typeof item === 'object' && item !== null; }))
|
|
2444
2406
|
isObjectOptionItem = true;
|
|
@@ -2446,33 +2408,20 @@ function SelectInput(_a) {
|
|
|
2446
2408
|
? selected.label
|
|
2447
2409
|
: selected;
|
|
2448
2410
|
var optionsRef = React.useRef(null);
|
|
2449
|
-
React.useEffect(function () {
|
|
2450
|
-
if (isOpen && inputRef.current && optionsRef.current) {
|
|
2451
|
-
var selectRect = inputRef.current.getBoundingClientRect();
|
|
2452
|
-
var optionsElement = optionsRef.current;
|
|
2453
|
-
var windowHeight = window.innerHeight;
|
|
2454
|
-
// Cek ruang di bawah
|
|
2455
|
-
var spaceBelow = windowHeight - selectRect.bottom;
|
|
2456
|
-
var maxHeight = void 0;
|
|
2457
|
-
maxHeight = spaceBelow - 10; // Beri margin
|
|
2458
|
-
optionsElement.style.maxHeight = "".concat(Math.max(0, maxHeight), "px");
|
|
2459
|
-
}
|
|
2460
|
-
}, [isOpen]);
|
|
2461
|
-
var dropdownPosition = isDropUp ? 'bottom-full' : 'top-full';
|
|
2462
2411
|
var descColor = 'text-primary-cool';
|
|
2463
2412
|
var isExistValidation = isValid !== null && isValid !== undefined;
|
|
2464
2413
|
if (!disabled && isExistValidation && isValid)
|
|
2465
2414
|
descColor = 'text-bia-green';
|
|
2466
2415
|
if (!disabled && isExistValidation && !isValid)
|
|
2467
2416
|
descColor = 'text-bia-red';
|
|
2468
|
-
return (React.createElement("div", { className: "bianic-fgc-container bianic-text-input-container field-group flex w-full flex-col"
|
|
2417
|
+
return (React.createElement("div", { className: "bianic-fgc-container bianic-text-input-container field-group flex w-full flex-col" },
|
|
2469
2418
|
React.createElement("label", { htmlFor: id, className: "label pb-2 text-xs font-semibold" },
|
|
2470
2419
|
childrenElement(label),
|
|
2471
2420
|
required && React.createElement("span", { className: "p-1 text-bia-red" }, "*")),
|
|
2472
2421
|
React.createElement("div", { className: "group relative w-full" },
|
|
2473
|
-
React.createElement("input", __assign({ className: "bianic-fgc-target field peer w-full cursor-pointer rounded border border-bia-grey-dark-10 bg-primary-white pe-8 focus-visible:outline-none enabled:hover:rounded-b-none enabled:hover:border-b-bia-blue enabled:focus:rounded-b-none enabled:focus:border-b-bia-blue disabled:bg-bia-grey-light-80 disabled:text-bia-coolgrey ".concat(searchSize), onClick: function () { return setIsOpen(!isOpen); }, value: selectedLabel, readOnly: true, id: id, disabled: disabled }, props)),
|
|
2422
|
+
React.createElement("input", __assign({ className: "bianic-fgc-target field peer w-full cursor-pointer rounded border border-bia-grey-dark-10 bg-primary-white pe-8 focus-visible:outline-none enabled:hover:rounded-b-none enabled:hover:border-b-bia-blue enabled:focus:rounded-b-none enabled:focus:border-b-bia-blue disabled:bg-bia-grey-light-80 disabled:text-bia-coolgrey ".concat(searchSize), onClick: function () { return setIsOpen(!isOpen); }, value: selectedLabel, readOnly: true, id: id, disabled: disabled, ref: inputRef }, props)),
|
|
2474
2423
|
React.createElement("div", { className: "pointer-events-none absolute inset-y-0 flex items-center pl-3 text-bia-coolgrey peer-disabled:text-bia-coolgrey-light-50 ".concat(iconSize) }, isOpen ? React.createElement(TbChevronUp, null) : React.createElement(TbChevronDown, null)),
|
|
2475
|
-
children === undefined && isOpen && (React.createElement("div", { className: "absolute z-10 w-full rounded-b-md border border-bia-grey-dark-10 bg-primary-white shadow-lg
|
|
2424
|
+
children === undefined && isOpen && (React.createElement("div", { className: "absolute z-10 w-full rounded-b-md border border-bia-grey-dark-10 bg-primary-white shadow-lg", ref: optionsRef, onClick: onClickDropdown }, options.map(function (option) {
|
|
2476
2425
|
var isSelected = JSON.stringify(option) === JSON.stringify(selected);
|
|
2477
2426
|
var optionLabel = isObjectOptionItem ? option.label : option;
|
|
2478
2427
|
var optionCaption = isObjectOptionItem ? option.caption : '';
|
|
@@ -2484,7 +2433,7 @@ function SelectInput(_a) {
|
|
|
2484
2433
|
setIsOpen(false);
|
|
2485
2434
|
} }));
|
|
2486
2435
|
}))),
|
|
2487
|
-
children && isOpen && (React.createElement(
|
|
2436
|
+
children && isOpen && (React.createElement(DropdownContainer, __assign({ open: isOpen, onClose: function () { return setIsOpen(false); }, size: size, isTopFlat: true, className: "bianic-livesearch-dropdown absolute z-10 mt-1 w-full overflow-hidden rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none ".concat(dropContClassName), anchorRef: inputRef, matchAnchorWidth: "min" }, restDropContProps), React.Children.map(children, function (child) {
|
|
2488
2437
|
if (React.isValidElement(child)) {
|
|
2489
2438
|
return React.cloneElement(child, {
|
|
2490
2439
|
isSelected: selected && selected.id === child.props.value.id,
|
|
@@ -2524,6 +2473,19 @@ var sizeConfig$6 = {
|
|
|
2524
2473
|
},
|
|
2525
2474
|
};
|
|
2526
2475
|
|
|
2476
|
+
var containerSizeConfig = {
|
|
2477
|
+
sm: 'min-w-[72px]',
|
|
2478
|
+
md: 'min-w-[96px]',
|
|
2479
|
+
};
|
|
2480
|
+
var itemSizeConfig = {
|
|
2481
|
+
sm: 'min-h-[30px] border-y-[2px] border-bia-white',
|
|
2482
|
+
md: 'min-h-[40px] border-y-[3px] border-bia-white',
|
|
2483
|
+
};
|
|
2484
|
+
var fontConfig = {
|
|
2485
|
+
sm: 'text-[12px] font-[400]',
|
|
2486
|
+
md: 'text-[14px] font-[350]',
|
|
2487
|
+
};
|
|
2488
|
+
|
|
2527
2489
|
var DropdownElement = React.forwardRef(function (_a, ref) {
|
|
2528
2490
|
var isTopFlat = _a.isTopFlat, children = _a.children, className = _a.className, size = _a.size, zIndex = _a.zIndex, style = _a.style, onClose = _a.onClose, onClickItem = _a.onClickItem, restProps = __rest(_a, ["isTopFlat", "children", "className", "size", "zIndex", "style", "onClose", "onClickItem"]);
|
|
2529
2491
|
var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
|
|
@@ -2545,19 +2507,34 @@ var DropdownElement = React.forwardRef(function (_a, ref) {
|
|
|
2545
2507
|
})));
|
|
2546
2508
|
});
|
|
2547
2509
|
var DropdownContainer = function (propsComp) {
|
|
2548
|
-
var _a = propsComp.isTopFlat, isTopFlat = _a === void 0 ? false : _a, children = propsComp.children, _b = propsComp.open, open = _b === void 0 ? true : _b, _c = propsComp.onClose, onClose = _c === void 0 ? function () { } : _c, _d = propsComp.className, className = _d === void 0 ? '' : _d, _e = propsComp.isWithOverlay, isWithOverlay = _e === void 0 ? true : _e, _f = propsComp.size, size = _f === void 0 ? 'md' : _f, _g = propsComp.onClickItem, onClickItem = _g === void 0 ? function () { } : _g, _h = propsComp.zIndex, zIndex = _h === void 0 ? 100 : _h, anchorRef = propsComp.anchorRef, restProps = __rest(propsComp, ["isTopFlat", "children", "open", "onClose", "className", "isWithOverlay", "size", "onClickItem", "zIndex", "anchorRef"]);
|
|
2510
|
+
var _a = propsComp.isTopFlat, isTopFlat = _a === void 0 ? false : _a, children = propsComp.children, _b = propsComp.open, open = _b === void 0 ? true : _b, _c = propsComp.onClose, onClose = _c === void 0 ? function () { } : _c, _d = propsComp.className, className = _d === void 0 ? '' : _d, _e = propsComp.isWithOverlay, isWithOverlay = _e === void 0 ? true : _e, _f = propsComp.size, size = _f === void 0 ? 'md' : _f, _g = propsComp.onClickItem, onClickItem = _g === void 0 ? function () { } : _g, _h = propsComp.zIndex, zIndex = _h === void 0 ? 100 : _h, anchorRef = propsComp.anchorRef, matchAnchorWidth = propsComp.matchAnchorWidth, restProps = __rest(propsComp, ["isTopFlat", "children", "open", "onClose", "className", "isWithOverlay", "size", "onClickItem", "zIndex", "anchorRef", "matchAnchorWidth"]);
|
|
2549
2511
|
if (!open)
|
|
2550
2512
|
return null;
|
|
2551
2513
|
var dropdownRef = React.useRef(null);
|
|
2552
2514
|
var positionStyle = usePopupPosition(anchorRef, dropdownRef)[0];
|
|
2553
2515
|
var newStyle = React.useMemo(function () {
|
|
2554
|
-
var _a;
|
|
2516
|
+
var _a, _b, _c;
|
|
2555
2517
|
if (!(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)) {
|
|
2556
2518
|
return {};
|
|
2557
2519
|
}
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2520
|
+
var widthStyle = {};
|
|
2521
|
+
switch (matchAnchorWidth) {
|
|
2522
|
+
case 'min':
|
|
2523
|
+
widthStyle = {
|
|
2524
|
+
minWidth: "".concat((_a = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth, "px"),
|
|
2525
|
+
};
|
|
2526
|
+
break;
|
|
2527
|
+
case 'exact':
|
|
2528
|
+
widthStyle = {
|
|
2529
|
+
width: "".concat((_b = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth, "px"),
|
|
2530
|
+
maxWidth: "".concat((_c = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) === null || _c === void 0 ? void 0 : _c.offsetWidth, "px"),
|
|
2531
|
+
};
|
|
2532
|
+
break;
|
|
2533
|
+
default:
|
|
2534
|
+
widthStyle = { width: 'fit-content' };
|
|
2535
|
+
break;
|
|
2536
|
+
}
|
|
2537
|
+
return __assign(__assign({ zIndex: zIndex + 10 }, widthStyle), positionStyle);
|
|
2561
2538
|
}, [positionStyle]);
|
|
2562
2539
|
var dropdownElement = (React.createElement(DropdownElement, __assign({ ref: dropdownRef, isTopFlat: isTopFlat, children: children, className: className, size: size, zIndex: zIndex, onClose: onClose, onClickItem: onClickItem, style: newStyle }, restProps)));
|
|
2563
2540
|
return (React.createElement(React.Fragment, null,
|
|
@@ -2570,6 +2547,35 @@ DropdownContainer.defaultProps = {
|
|
|
2570
2547
|
isTopFlat: false,
|
|
2571
2548
|
};
|
|
2572
2549
|
|
|
2550
|
+
var DropdownContNoAnchor = React.forwardRef(function DropdownContNoAnchor(propsComp, ref) {
|
|
2551
|
+
var _a = propsComp.isTopFlat, isTopFlat = _a === void 0 ? false : _a, children = propsComp.children, _b = propsComp.open, open = _b === void 0 ? true : _b, _c = propsComp.onClose, onClose = _c === void 0 ? function () { } : _c, _d = propsComp.className, className = _d === void 0 ? '' : _d, _e = propsComp.isWithOverlay, isWithOverlay = _e === void 0 ? true : _e, _f = propsComp.size, size = _f === void 0 ? 'md' : _f, _g = propsComp.onClickItem, onClickItem = _g === void 0 ? function () { } : _g, _h = propsComp.zIndex, zIndex = _h === void 0 ? 100 : _h, restProps = __rest(propsComp, ["isTopFlat", "children", "open", "onClose", "className", "isWithOverlay", "size", "onClickItem", "zIndex"]);
|
|
2552
|
+
var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
|
|
2553
|
+
var sizeClass = containerSizeConfig[size] || containerSizeConfig['md'];
|
|
2554
|
+
var containerClass = "".concat(sizeClass, " ").concat(radiusClass, " ").concat(className);
|
|
2555
|
+
var handleClickDrpdownItem = function (e, val) {
|
|
2556
|
+
onClickItem(e, val);
|
|
2557
|
+
onClose();
|
|
2558
|
+
};
|
|
2559
|
+
return (open && (React.createElement(React.Fragment, null,
|
|
2560
|
+
isWithOverlay && (React.createElement("div", { className: "bianic-dropdown-overlay fixed left-0 top-0 h-screen w-screen", style: { zIndex: zIndex }, onClick: function () { return onClose(); } })),
|
|
2561
|
+
React.createElement("div", __assign({ style: {
|
|
2562
|
+
zIndex: zIndex + 10, // Ensure dropdown is above overlay
|
|
2563
|
+
}, ref: ref, className: "bianic-dropdown-container bg-bia-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] ".concat(containerClass) }, restProps), React.Children.map(children, function (child) {
|
|
2564
|
+
return React.isValidElement(child)
|
|
2565
|
+
? // Kirimkan handleItemClick sebagai props onClick ke setiap DropdownItem
|
|
2566
|
+
React.cloneElement(child, {
|
|
2567
|
+
onClose: function () { return onClose(); },
|
|
2568
|
+
size: size,
|
|
2569
|
+
onClickItem: function (e, val) { return handleClickDrpdownItem(e, val); },
|
|
2570
|
+
zIndex: zIndex + 10,
|
|
2571
|
+
})
|
|
2572
|
+
: child;
|
|
2573
|
+
})))));
|
|
2574
|
+
});
|
|
2575
|
+
DropdownContNoAnchor.defaultProps = {
|
|
2576
|
+
isTopFlat: false,
|
|
2577
|
+
};
|
|
2578
|
+
|
|
2573
2579
|
function DropdownItem(_a) {
|
|
2574
2580
|
var children = _a.children, _b = _a.className, className = _b === void 0 ? '' : _b, _c = _a.onClickItem, onClickItem = _c === void 0 ? function () { } : _c, _d = _a.onClose, onClose = _d === void 0 ? function () { } : _d, _e = _a.size, size = _e === void 0 ? 'md' : _e, _f = _a.value, value = _f === void 0 ? '' : _f, content = _a.content, _g = _a.disabled, disabled = _g === void 0 ? false : _g, _h = _a.zIndex, zIndex = _h === void 0 ? 100 : _h, props = __rest(_a, ["children", "className", "onClickItem", "onClose", "size", "value", "content", "disabled", "zIndex"]);
|
|
2575
2581
|
var _j = React.useState(false), isHovered = _j[0], setIsHovered = _j[1];
|
|
@@ -2768,7 +2774,7 @@ function LiveSearch(_a) {
|
|
|
2768
2774
|
setIsOpen(false);
|
|
2769
2775
|
} }));
|
|
2770
2776
|
}))),
|
|
2771
|
-
children && (React.createElement(DropdownContainer, __assign({ open: isOpen, onClose: function () { return setIsOpen(false); }, size: size, isTopFlat: true, zIndex: 10, className: "bianic-livesearch-dropdown absolute w-full overflow-hidden bg-white shadow-lg ".concat(dropContClassName), anchorRef: inputRef }, restDropContProps), hasFilteredResults
|
|
2777
|
+
children && (React.createElement(DropdownContainer, __assign({ open: isOpen, onClose: function () { return setIsOpen(false); }, size: size, isTopFlat: true, zIndex: 10, className: "bianic-livesearch-dropdown absolute w-full overflow-hidden bg-white shadow-lg ".concat(dropContClassName), anchorRef: inputRef, matchAnchorWidth: "min" }, restDropContProps), hasFilteredResults
|
|
2772
2778
|
? renderedChildren
|
|
2773
2779
|
: // If no results and searchTerm is present
|
|
2774
2780
|
searchTerm.length > 0 && (React.createElement(DropdownItem, { content: React.createElement("div", { className: "px-4 py-2 text-gray-500" }, "Tidak ada hasil ditemukan.") }))))),
|
|
@@ -3703,20 +3709,19 @@ var classConfig = {
|
|
|
3703
3709
|
};
|
|
3704
3710
|
|
|
3705
3711
|
function Popover(_a) {
|
|
3706
|
-
var children = _a.children, content = _a.content
|
|
3712
|
+
var className = _a.className, children = _a.children, content = _a.content, _b = _a.direction, direction = _b === void 0 ? 'bottom' : _b; _a.maxWidth; var _c = _a.title, title = _c === void 0 ? '' : _c, style = _a.style, zIndex = _a.zIndex;
|
|
3707
3713
|
var wrapperRef = React.useRef(null);
|
|
3708
|
-
|
|
3709
|
-
var _e = useDetectOutsideClick(wrapperRef, false), isOpen = _e[0], setIsOpen = _e[1];
|
|
3714
|
+
var _d = useDetectOutsideClick(wrapperRef, false), isOpen = _d[0], setIsOpen = _d[1];
|
|
3710
3715
|
return (React.createElement("div", { className: "Bianic-popover-Wrapper relative block h-fit w-fit", role: "button", ref: wrapperRef, onClick: function () { return setIsOpen(true); } },
|
|
3711
3716
|
children,
|
|
3712
|
-
isOpen && (React.createElement(PopoverItem, { title: title, content: content, anchorRef: wrapperRef, direction: direction }))));
|
|
3717
|
+
isOpen && (React.createElement(PopoverItem, { title: title, content: content, anchorRef: wrapperRef, direction: direction, className: className, style: style, zIndex: zIndex }))));
|
|
3713
3718
|
}
|
|
3714
3719
|
var PopoverItem = function (_a) {
|
|
3715
|
-
var title = _a.title, content = _a.content, anchorRef = _a.anchorRef, direction = _a.direction;
|
|
3720
|
+
var title = _a.title, content = _a.content, anchorRef = _a.anchorRef, direction = _a.direction, className = _a.className, style = _a.style, zIndex = _a.zIndex;
|
|
3716
3721
|
var popoverRef = React.useRef(null);
|
|
3717
3722
|
var positionStyle = usePopupPosition(anchorRef, popoverRef, direction)[0];
|
|
3718
3723
|
var _b = classConfig[direction], triangleContainer = _b.triangleContainer, triangleShape = _b.triangleShape;
|
|
3719
|
-
return reactDom.createPortal(React.createElement("div", { ref: popoverRef, style: positionStyle, className: "Bianic-popover-Tip text-bia-sm absolute z-50 w-[245px] space-y-[5px] rounded-[4px] bg-primary-black px-[20px] py-[17.5px] text-primary-white" },
|
|
3724
|
+
return reactDom.createPortal(React.createElement("div", { ref: popoverRef, style: __assign(__assign(__assign({}, positionStyle), style), { zIndex: zIndex }), className: "Bianic-popover-Tip text-bia-sm absolute z-50 w-[245px] space-y-[5px] rounded-[4px] bg-primary-black px-[20px] py-[17.5px] text-primary-white ".concat(className) },
|
|
3720
3725
|
React.createElement("div", { className: "flex flex-col" },
|
|
3721
3726
|
React.createElement("div", { className: "mb-[5px] font-humnst777 text-[16px] font-bold leading-[19.42px]" }, title),
|
|
3722
3727
|
React.createElement("div", { className: "break-words font-segoe text-[12px] font-normal" }, content)),
|
|
@@ -3724,7 +3729,6 @@ var PopoverItem = function (_a) {
|
|
|
3724
3729
|
React.createElement("div", { className: "h-0 w-0 ".concat(triangleShape) }))), document.body);
|
|
3725
3730
|
};
|
|
3726
3731
|
Popover.defaultProps = {
|
|
3727
|
-
delay: 400,
|
|
3728
3732
|
direction: 'top',
|
|
3729
3733
|
title: '',
|
|
3730
3734
|
};
|