bianic-ui 1.16.0-alpha.6 → 1.16.0-alpha.7
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 +70 -41
- package/dist/cjs/types/components/Forms/Dropdown/DropdownContainer.d.ts +1 -1
- package/dist/cjs/types/components/Menu/MenuContainer.d.ts +2 -2
- package/dist/cjs/types/utility/hooks/usePopupPosition.d.ts +2 -1
- package/dist/esm/index.js +71 -42
- package/dist/esm/types/components/Forms/Dropdown/DropdownContainer.d.ts +1 -1
- package/dist/esm/types/components/Menu/MenuContainer.d.ts +2 -2
- package/dist/esm/types/utility/hooks/usePopupPosition.d.ts +2 -1
- package/dist/index.d.ts +3 -2
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1728,7 +1728,9 @@ var getContextualPopupStyle = function (anchorRef, popupRef, position) {
|
|
|
1728
1728
|
if (!anchorRef.current || !popupRef.current) {
|
|
1729
1729
|
return {};
|
|
1730
1730
|
}
|
|
1731
|
-
var style = {
|
|
1731
|
+
var style = {
|
|
1732
|
+
position: 'absolute',
|
|
1733
|
+
};
|
|
1732
1734
|
var anchorRect = anchorRef.current.getBoundingClientRect();
|
|
1733
1735
|
var popupRect = popupRef.current.getBoundingClientRect();
|
|
1734
1736
|
var popupHeight = popupRect.height;
|
|
@@ -1778,6 +1780,7 @@ var getDropdownStyle = function (anchorRef, popupRef) {
|
|
|
1778
1780
|
var spaceToBottom = window.innerHeight - anchorRect.bottom;
|
|
1779
1781
|
var spaceToTop = anchorRect.top;
|
|
1780
1782
|
var style = {
|
|
1783
|
+
position: 'absolute',
|
|
1781
1784
|
left: "".concat(anchorRect.left + window.scrollX, "px"),
|
|
1782
1785
|
};
|
|
1783
1786
|
// If space below is less than popup height,
|
|
@@ -1795,6 +1798,9 @@ var usePopupPosition = function (anchorRef, popupRef, position) {
|
|
|
1795
1798
|
// In projects where bianic-ui is installed,
|
|
1796
1799
|
// there is a delay in rendering styles,
|
|
1797
1800
|
// which causes popups to lose their position and need to be re-rendered.
|
|
1801
|
+
if (!anchorRef || !popupRef) {
|
|
1802
|
+
return [{}, function () { }];
|
|
1803
|
+
}
|
|
1798
1804
|
var _a = React.useState(0), repeateRender = _a[0], setRepeateRender = _a[1];
|
|
1799
1805
|
var _b = React.useState({}), positionStyle = _b[0], setPositionStyle = _b[1];
|
|
1800
1806
|
var calcPosition = function () {
|
|
@@ -1824,28 +1830,38 @@ var usePopupPosition = function (anchorRef, popupRef, position) {
|
|
|
1824
1830
|
return [positionStyle, calcPosition];
|
|
1825
1831
|
};
|
|
1826
1832
|
|
|
1833
|
+
var MenuElement = React.forwardRef(function (_a, ref) {
|
|
1834
|
+
var isTopFlat = _a.isTopFlat, children = _a.children, className = _a.className, zIndex = _a.zIndex, menuRef = _a.menuRef, onClose = _a.onClose, onClickItem = _a.onClickItem, style = _a.style, restProps = __rest(_a, ["isTopFlat", "children", "className", "zIndex", "menuRef", "onClose", "onClickItem", "style"]);
|
|
1835
|
+
var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
|
|
1836
|
+
return (React.createElement("div", __assign({ ref: menuRef, className: "w-fit bg-bia-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] ".concat(radiusClass, " ").concat(className), style: style }, restProps), React.Children.map(children, function (child) {
|
|
1837
|
+
return React.isValidElement(child)
|
|
1838
|
+
? React.cloneElement(child, {
|
|
1839
|
+
onClose: function () { return onClose(); },
|
|
1840
|
+
zIndex: zIndex + 10,
|
|
1841
|
+
inheritedOnClick: function () { return onClickItem(); },
|
|
1842
|
+
})
|
|
1843
|
+
: child;
|
|
1844
|
+
})));
|
|
1845
|
+
});
|
|
1827
1846
|
var MenuContainer = function (props) {
|
|
1828
|
-
var _a;
|
|
1829
|
-
var _b = props.isTopFlat, isTopFlat = _b === void 0 ? false : _b, children = props.children, _c = props.open, open = _c === void 0 ? true : _c, _d = props.onClose, onClose = _d === void 0 ? function () { } : _d, _e = props.className, className = _e === void 0 ? '' : _e, _f = props.isWithOverlay, isWithOverlay = _f === void 0 ? true : _f, _g = props.zIndex, zIndex = _g === void 0 ? 100 : _g, _h = props.onClickItem, onClickItem = _h === void 0 ? function () { } : _h, anchorRef = props.anchorRef, restProps = __rest(props, ["isTopFlat", "children", "open", "onClose", "className", "isWithOverlay", "zIndex", "onClickItem", "anchorRef"]);
|
|
1847
|
+
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"]);
|
|
1830
1848
|
if (!open)
|
|
1831
1849
|
return null;
|
|
1832
|
-
var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
|
|
1833
1850
|
var MenuContainerRef = React.useRef(null);
|
|
1834
1851
|
var positionStyle = usePopupPosition(anchorRef, MenuContainerRef)[0];
|
|
1852
|
+
var newStyle = React.useMemo(function () {
|
|
1853
|
+
var _a;
|
|
1854
|
+
if (!(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)) {
|
|
1855
|
+
return {};
|
|
1856
|
+
}
|
|
1857
|
+
return __assign({ zIndex: zIndex + 10, minWidth: (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)
|
|
1858
|
+
? (_a = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth
|
|
1859
|
+
: undefined }, positionStyle);
|
|
1860
|
+
}, [positionStyle]);
|
|
1861
|
+
var menuElement = (React.createElement(MenuElement, __assign({ isTopFlat: isTopFlat, children: children, className: className, zIndex: zIndex, menuRef: MenuContainerRef, onClose: onClose, onClickItem: onClickItem, style: newStyle }, restProps)));
|
|
1835
1862
|
return (React.createElement(React.Fragment, null,
|
|
1836
1863
|
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 } })),
|
|
1837
|
-
|
|
1838
|
-
? (_a = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth
|
|
1839
|
-
: undefined }, positionStyle) }, restProps), React.Children.map(children, function (child) {
|
|
1840
|
-
return React.isValidElement(child)
|
|
1841
|
-
? // Kirimkan handleItemClick sebagai props onClick ke setiap MenuItem
|
|
1842
|
-
React.cloneElement(child, {
|
|
1843
|
-
onClose: function () { return onClose(); },
|
|
1844
|
-
zIndex: zIndex + 10,
|
|
1845
|
-
inheritedOnClick: function () { return onClickItem(); },
|
|
1846
|
-
})
|
|
1847
|
-
: child;
|
|
1848
|
-
})), document.body)));
|
|
1864
|
+
(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) ? reactDom.createPortal(menuElement, document.body) : menuElement));
|
|
1849
1865
|
};
|
|
1850
1866
|
MenuContainer.defaultProps = {
|
|
1851
1867
|
isTopFlat: false,
|
|
@@ -2473,34 +2489,47 @@ var sizeConfig$6 = {
|
|
|
2473
2489
|
},
|
|
2474
2490
|
};
|
|
2475
2491
|
|
|
2476
|
-
var
|
|
2477
|
-
var
|
|
2478
|
-
if (!open)
|
|
2479
|
-
return null;
|
|
2492
|
+
var DropdownElement = function (_a) {
|
|
2493
|
+
var isTopFlat = _a.isTopFlat, children = _a.children, className = _a.className, size = _a.size, zIndex = _a.zIndex, dropdownRef = _a.dropdownRef, onClose = _a.onClose, onClickItem = _a.onClickItem, style = _a.style, restProps = __rest(_a, ["isTopFlat", "children", "className", "size", "zIndex", "dropdownRef", "onClose", "onClickItem", "style"]);
|
|
2480
2494
|
var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
|
|
2481
2495
|
var sizeClass = containerSizeConfig[size] || containerSizeConfig['md'];
|
|
2482
2496
|
var containerClass = "".concat(sizeClass, " ").concat(radiusClass, " ").concat(className);
|
|
2483
|
-
var dropdownRef = React.useRef(null);
|
|
2484
|
-
var positionStyle = usePopupPosition(anchorRef, dropdownRef)[0];
|
|
2485
2497
|
var handleClickDrpdownItem = function (e, val) {
|
|
2486
2498
|
onClickItem(e, val);
|
|
2487
2499
|
onClose();
|
|
2488
2500
|
};
|
|
2501
|
+
return (React.createElement("div", __assign({ ref: dropdownRef, className: "bianic-dropdown-container max-w-fit bg-bia-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] ".concat(containerClass), style: style }, restProps), React.Children.map(children, function (child) {
|
|
2502
|
+
return React.isValidElement(child)
|
|
2503
|
+
? React.cloneElement(child, {
|
|
2504
|
+
onClose: function () { return onClose(); },
|
|
2505
|
+
size: size,
|
|
2506
|
+
onClickItem: function (e, val) { return handleClickDrpdownItem(e, val); },
|
|
2507
|
+
zIndex: zIndex + 10,
|
|
2508
|
+
})
|
|
2509
|
+
: child;
|
|
2510
|
+
})));
|
|
2511
|
+
};
|
|
2512
|
+
var DropdownContainer = function (propsComp) {
|
|
2513
|
+
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"]);
|
|
2514
|
+
if (!open)
|
|
2515
|
+
return null;
|
|
2516
|
+
var dropdownRef = React.useRef(null);
|
|
2517
|
+
var positionStyle = usePopupPosition(anchorRef, dropdownRef)[0];
|
|
2518
|
+
var newStyle = React.useMemo(function () {
|
|
2519
|
+
var _a;
|
|
2520
|
+
if (!(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)) {
|
|
2521
|
+
return {};
|
|
2522
|
+
}
|
|
2523
|
+
return __assign({ zIndex: zIndex + 10, minWidth: (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)
|
|
2524
|
+
? (_a = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth
|
|
2525
|
+
: undefined }, positionStyle);
|
|
2526
|
+
}, [positionStyle]);
|
|
2527
|
+
var dropdownElement = (React.createElement(DropdownElement, __assign({ isTopFlat: isTopFlat, children: children, className: className, size: size, zIndex: zIndex, dropdownRef: dropdownRef, onClose: onClose, onClickItem: onClickItem, style: newStyle }, restProps)));
|
|
2489
2528
|
return (React.createElement(React.Fragment, null,
|
|
2490
2529
|
isWithOverlay && (React.createElement("div", { className: "bianic-dropdown-overlay fixed left-0 top-0 h-screen w-screen", style: { zIndex: zIndex }, onClick: function () { return onClose(); } })),
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
return React.isValidElement(child)
|
|
2495
|
-
? // Kirimkan handleItemClick sebagai props onClick ke setiap DropdownItem
|
|
2496
|
-
React.cloneElement(child, {
|
|
2497
|
-
onClose: function () { return onClose(); },
|
|
2498
|
-
size: size,
|
|
2499
|
-
onClickItem: function (e, val) { return handleClickDrpdownItem(e, val); },
|
|
2500
|
-
zIndex: zIndex + 10,
|
|
2501
|
-
})
|
|
2502
|
-
: child;
|
|
2503
|
-
})), document.body)));
|
|
2530
|
+
(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)
|
|
2531
|
+
? reactDom.createPortal(dropdownElement, document.body)
|
|
2532
|
+
: dropdownElement));
|
|
2504
2533
|
};
|
|
2505
2534
|
DropdownContainer.defaultProps = {
|
|
2506
2535
|
isTopFlat: false,
|
|
@@ -2665,20 +2694,20 @@ var useLiveSearch = function (_a) {
|
|
|
2665
2694
|
};
|
|
2666
2695
|
|
|
2667
2696
|
function LiveSearch(_a) {
|
|
2668
|
-
var _b = _a.autoComplete, autoComplete = _b === void 0 ? 'off' : _b, _c = _a.children, children = _c === void 0 ? undefined : _c, descText = _a.descText, _d = _a.disabled, disabled = _d === void 0 ? false : _d,
|
|
2697
|
+
var _b = _a.autoComplete, autoComplete = _b === void 0 ? 'off' : _b, _c = _a.children, children = _c === void 0 ? undefined : _c, descText = _a.descText, _d = _a.disabled, disabled = _d === void 0 ? false : _d, dropContProps = _a.dropContProps, id = _a.id, label = _a.label, _e = _a.onChangeText, onChangeText = _e === void 0 ? function () { } : _e, _f = _a.onClickDropdown, onClickDropdown = _f === void 0 ? function () { } : _f, options = _a.options, placeholder = _a.placeholder, _g = _a.readOnly, readOnly = _g === void 0 ? false : _g, _h = _a.required, required = _h === void 0 ? false : _h, _j = _a.searchVariant, searchVariant = _j === void 0 ? 'include' : _j, setValue = _a.setValue, _k = _a.size, size = _k === void 0 ? 'md' : _k, value = _a.value;
|
|
2669
2698
|
var inputRef = React.useRef(null);
|
|
2670
2699
|
var dropdownContRef = React.useRef(null);
|
|
2671
|
-
var
|
|
2700
|
+
var _l = useLiveSearch({
|
|
2672
2701
|
value: value,
|
|
2673
2702
|
setValue: setValue,
|
|
2674
2703
|
onChangeText: onChangeText,
|
|
2675
2704
|
dropContOnClickItem: dropContProps.onClickItem
|
|
2676
|
-
}), isOpen =
|
|
2677
|
-
var
|
|
2678
|
-
var dropContClassName = dropContProps.className; dropContProps.onClickItem; var restDropContProps = __rest(dropContProps, ["className", "onClickItem"]);
|
|
2705
|
+
}), isOpen = _l.isOpen, setIsOpen = _l.setIsOpen, searchTerm = _l.searchTerm, handleInputChange = _l.handleInputChange, handleDropdownItemClick = _l.handleDropdownItemClick;
|
|
2706
|
+
var _m = sizeConfig$6[size], iconClass = _m.iconClass, iconSize = _m.iconSize, inputClass = _m.inputClass;
|
|
2707
|
+
var dropContClassName = dropContProps.className; dropContProps.onClickItem; dropContProps.anchorRef; var restDropContProps = __rest(dropContProps, ["className", "onClickItem", "anchorRef"]);
|
|
2679
2708
|
var isValueExist = value && value.label !== undefined && value.label !== '';
|
|
2680
2709
|
var filteredOptions = filterOptions(options || [], value.label);
|
|
2681
|
-
var
|
|
2710
|
+
var _o = processRenderedChildren(children, searchTerm, searchVariant, handleDropdownItemClick), renderedChildren = _o.renderedChildren, hasFilteredResults = _o.hasFilteredResults;
|
|
2682
2711
|
return (React.createElement("div", { className: "bianic-livesearch field-group group/form flex w-full flex-col gap-y-2 " },
|
|
2683
2712
|
label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
|
|
2684
2713
|
React.createElement("div", { className: "group relative w-full" },
|
|
@@ -8,7 +8,7 @@ export interface DropdownContainerProps extends ComponentPropsWithRef<'div'> {
|
|
|
8
8
|
isWithOverlay?: boolean;
|
|
9
9
|
size?: 'sm' | 'md';
|
|
10
10
|
zIndex?: number;
|
|
11
|
-
anchorRef
|
|
11
|
+
anchorRef?: React.RefObject<HTMLElement>;
|
|
12
12
|
onClickItem?: (event: React.MouseEvent<HTMLDivElement>, val: string | number | object) => void;
|
|
13
13
|
}
|
|
14
14
|
declare const DropdownContainer: {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef } from 'react';
|
|
2
1
|
interface MenuContainerProps extends ComponentPropsWithRef<'div'> {
|
|
3
2
|
isTopFlat?: boolean;
|
|
4
3
|
children: React.ReactNode | undefined;
|
|
@@ -8,8 +7,9 @@ interface MenuContainerProps extends ComponentPropsWithRef<'div'> {
|
|
|
8
7
|
isWithOverlay?: boolean;
|
|
9
8
|
zIndex?: number;
|
|
10
9
|
onClickItem?: () => void;
|
|
11
|
-
anchorRef
|
|
10
|
+
anchorRef?: React.RefObject<HTMLElement>;
|
|
12
11
|
}
|
|
12
|
+
import React, { ComponentPropsWithRef } from 'react';
|
|
13
13
|
declare const MenuContainer: {
|
|
14
14
|
(props: MenuContainerProps): React.JSX.Element | null;
|
|
15
15
|
defaultProps: {
|
|
@@ -4,6 +4,7 @@ interface PositionStyle {
|
|
|
4
4
|
left?: string;
|
|
5
5
|
right?: string;
|
|
6
6
|
bottom?: string;
|
|
7
|
+
position?: 'absolute' | 'fixed' | 'relative';
|
|
7
8
|
}
|
|
8
|
-
declare const usePopupPosition: (anchorRef
|
|
9
|
+
declare const usePopupPosition: (anchorRef?: RefObject<HTMLElement>, popupRef?: RefObject<HTMLDivElement>, position?: string) => [PositionStyle, () => void] | {}[];
|
|
9
10
|
export default usePopupPosition;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useEffect, forwardRef, useRef, cloneElement, useLayoutEffect, Children, isValidElement, useCallback } from 'react';
|
|
1
|
+
import React, { useState, useEffect, forwardRef, useRef, cloneElement, useLayoutEffect, Children, useMemo, isValidElement, useCallback } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
|
|
4
4
|
function Accordions(_a) {
|
|
@@ -1726,7 +1726,9 @@ var getContextualPopupStyle = function (anchorRef, popupRef, position) {
|
|
|
1726
1726
|
if (!anchorRef.current || !popupRef.current) {
|
|
1727
1727
|
return {};
|
|
1728
1728
|
}
|
|
1729
|
-
var style = {
|
|
1729
|
+
var style = {
|
|
1730
|
+
position: 'absolute',
|
|
1731
|
+
};
|
|
1730
1732
|
var anchorRect = anchorRef.current.getBoundingClientRect();
|
|
1731
1733
|
var popupRect = popupRef.current.getBoundingClientRect();
|
|
1732
1734
|
var popupHeight = popupRect.height;
|
|
@@ -1776,6 +1778,7 @@ var getDropdownStyle = function (anchorRef, popupRef) {
|
|
|
1776
1778
|
var spaceToBottom = window.innerHeight - anchorRect.bottom;
|
|
1777
1779
|
var spaceToTop = anchorRect.top;
|
|
1778
1780
|
var style = {
|
|
1781
|
+
position: 'absolute',
|
|
1779
1782
|
left: "".concat(anchorRect.left + window.scrollX, "px"),
|
|
1780
1783
|
};
|
|
1781
1784
|
// If space below is less than popup height,
|
|
@@ -1793,6 +1796,9 @@ var usePopupPosition = function (anchorRef, popupRef, position) {
|
|
|
1793
1796
|
// In projects where bianic-ui is installed,
|
|
1794
1797
|
// there is a delay in rendering styles,
|
|
1795
1798
|
// which causes popups to lose their position and need to be re-rendered.
|
|
1799
|
+
if (!anchorRef || !popupRef) {
|
|
1800
|
+
return [{}, function () { }];
|
|
1801
|
+
}
|
|
1796
1802
|
var _a = useState(0), repeateRender = _a[0], setRepeateRender = _a[1];
|
|
1797
1803
|
var _b = useState({}), positionStyle = _b[0], setPositionStyle = _b[1];
|
|
1798
1804
|
var calcPosition = function () {
|
|
@@ -1822,28 +1828,38 @@ var usePopupPosition = function (anchorRef, popupRef, position) {
|
|
|
1822
1828
|
return [positionStyle, calcPosition];
|
|
1823
1829
|
};
|
|
1824
1830
|
|
|
1831
|
+
var MenuElement = forwardRef(function (_a, ref) {
|
|
1832
|
+
var isTopFlat = _a.isTopFlat, children = _a.children, className = _a.className, zIndex = _a.zIndex, menuRef = _a.menuRef, onClose = _a.onClose, onClickItem = _a.onClickItem, style = _a.style, restProps = __rest(_a, ["isTopFlat", "children", "className", "zIndex", "menuRef", "onClose", "onClickItem", "style"]);
|
|
1833
|
+
var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
|
|
1834
|
+
return (React.createElement("div", __assign({ ref: menuRef, className: "w-fit bg-bia-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] ".concat(radiusClass, " ").concat(className), style: style }, restProps), Children.map(children, function (child) {
|
|
1835
|
+
return React.isValidElement(child)
|
|
1836
|
+
? cloneElement(child, {
|
|
1837
|
+
onClose: function () { return onClose(); },
|
|
1838
|
+
zIndex: zIndex + 10,
|
|
1839
|
+
inheritedOnClick: function () { return onClickItem(); },
|
|
1840
|
+
})
|
|
1841
|
+
: child;
|
|
1842
|
+
})));
|
|
1843
|
+
});
|
|
1825
1844
|
var MenuContainer = function (props) {
|
|
1826
|
-
var _a;
|
|
1827
|
-
var _b = props.isTopFlat, isTopFlat = _b === void 0 ? false : _b, children = props.children, _c = props.open, open = _c === void 0 ? true : _c, _d = props.onClose, onClose = _d === void 0 ? function () { } : _d, _e = props.className, className = _e === void 0 ? '' : _e, _f = props.isWithOverlay, isWithOverlay = _f === void 0 ? true : _f, _g = props.zIndex, zIndex = _g === void 0 ? 100 : _g, _h = props.onClickItem, onClickItem = _h === void 0 ? function () { } : _h, anchorRef = props.anchorRef, restProps = __rest(props, ["isTopFlat", "children", "open", "onClose", "className", "isWithOverlay", "zIndex", "onClickItem", "anchorRef"]);
|
|
1845
|
+
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"]);
|
|
1828
1846
|
if (!open)
|
|
1829
1847
|
return null;
|
|
1830
|
-
var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
|
|
1831
1848
|
var MenuContainerRef = useRef(null);
|
|
1832
1849
|
var positionStyle = usePopupPosition(anchorRef, MenuContainerRef)[0];
|
|
1850
|
+
var newStyle = useMemo(function () {
|
|
1851
|
+
var _a;
|
|
1852
|
+
if (!(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)) {
|
|
1853
|
+
return {};
|
|
1854
|
+
}
|
|
1855
|
+
return __assign({ zIndex: zIndex + 10, minWidth: (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)
|
|
1856
|
+
? (_a = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth
|
|
1857
|
+
: undefined }, positionStyle);
|
|
1858
|
+
}, [positionStyle]);
|
|
1859
|
+
var menuElement = (React.createElement(MenuElement, __assign({ isTopFlat: isTopFlat, children: children, className: className, zIndex: zIndex, menuRef: MenuContainerRef, onClose: onClose, onClickItem: onClickItem, style: newStyle }, restProps)));
|
|
1833
1860
|
return (React.createElement(React.Fragment, null,
|
|
1834
1861
|
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 } })),
|
|
1835
|
-
|
|
1836
|
-
? (_a = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth
|
|
1837
|
-
: undefined }, positionStyle) }, restProps), Children.map(children, function (child) {
|
|
1838
|
-
return React.isValidElement(child)
|
|
1839
|
-
? // Kirimkan handleItemClick sebagai props onClick ke setiap MenuItem
|
|
1840
|
-
cloneElement(child, {
|
|
1841
|
-
onClose: function () { return onClose(); },
|
|
1842
|
-
zIndex: zIndex + 10,
|
|
1843
|
-
inheritedOnClick: function () { return onClickItem(); },
|
|
1844
|
-
})
|
|
1845
|
-
: child;
|
|
1846
|
-
})), document.body)));
|
|
1862
|
+
(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) ? createPortal(menuElement, document.body) : menuElement));
|
|
1847
1863
|
};
|
|
1848
1864
|
MenuContainer.defaultProps = {
|
|
1849
1865
|
isTopFlat: false,
|
|
@@ -2471,34 +2487,47 @@ var sizeConfig$6 = {
|
|
|
2471
2487
|
},
|
|
2472
2488
|
};
|
|
2473
2489
|
|
|
2474
|
-
var
|
|
2475
|
-
var
|
|
2476
|
-
if (!open)
|
|
2477
|
-
return null;
|
|
2490
|
+
var DropdownElement = function (_a) {
|
|
2491
|
+
var isTopFlat = _a.isTopFlat, children = _a.children, className = _a.className, size = _a.size, zIndex = _a.zIndex, dropdownRef = _a.dropdownRef, onClose = _a.onClose, onClickItem = _a.onClickItem, style = _a.style, restProps = __rest(_a, ["isTopFlat", "children", "className", "size", "zIndex", "dropdownRef", "onClose", "onClickItem", "style"]);
|
|
2478
2492
|
var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
|
|
2479
2493
|
var sizeClass = containerSizeConfig[size] || containerSizeConfig['md'];
|
|
2480
2494
|
var containerClass = "".concat(sizeClass, " ").concat(radiusClass, " ").concat(className);
|
|
2481
|
-
var dropdownRef = useRef(null);
|
|
2482
|
-
var positionStyle = usePopupPosition(anchorRef, dropdownRef)[0];
|
|
2483
2495
|
var handleClickDrpdownItem = function (e, val) {
|
|
2484
2496
|
onClickItem(e, val);
|
|
2485
2497
|
onClose();
|
|
2486
2498
|
};
|
|
2499
|
+
return (React.createElement("div", __assign({ ref: dropdownRef, className: "bianic-dropdown-container max-w-fit bg-bia-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] ".concat(containerClass), style: style }, restProps), Children.map(children, function (child) {
|
|
2500
|
+
return React.isValidElement(child)
|
|
2501
|
+
? cloneElement(child, {
|
|
2502
|
+
onClose: function () { return onClose(); },
|
|
2503
|
+
size: size,
|
|
2504
|
+
onClickItem: function (e, val) { return handleClickDrpdownItem(e, val); },
|
|
2505
|
+
zIndex: zIndex + 10,
|
|
2506
|
+
})
|
|
2507
|
+
: child;
|
|
2508
|
+
})));
|
|
2509
|
+
};
|
|
2510
|
+
var DropdownContainer = function (propsComp) {
|
|
2511
|
+
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"]);
|
|
2512
|
+
if (!open)
|
|
2513
|
+
return null;
|
|
2514
|
+
var dropdownRef = useRef(null);
|
|
2515
|
+
var positionStyle = usePopupPosition(anchorRef, dropdownRef)[0];
|
|
2516
|
+
var newStyle = useMemo(function () {
|
|
2517
|
+
var _a;
|
|
2518
|
+
if (!(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)) {
|
|
2519
|
+
return {};
|
|
2520
|
+
}
|
|
2521
|
+
return __assign({ zIndex: zIndex + 10, minWidth: (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)
|
|
2522
|
+
? (_a = anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth
|
|
2523
|
+
: undefined }, positionStyle);
|
|
2524
|
+
}, [positionStyle]);
|
|
2525
|
+
var dropdownElement = (React.createElement(DropdownElement, __assign({ isTopFlat: isTopFlat, children: children, className: className, size: size, zIndex: zIndex, dropdownRef: dropdownRef, onClose: onClose, onClickItem: onClickItem, style: newStyle }, restProps)));
|
|
2487
2526
|
return (React.createElement(React.Fragment, null,
|
|
2488
2527
|
isWithOverlay && (React.createElement("div", { className: "bianic-dropdown-overlay fixed left-0 top-0 h-screen w-screen", style: { zIndex: zIndex }, onClick: function () { return onClose(); } })),
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
return React.isValidElement(child)
|
|
2493
|
-
? // Kirimkan handleItemClick sebagai props onClick ke setiap DropdownItem
|
|
2494
|
-
cloneElement(child, {
|
|
2495
|
-
onClose: function () { return onClose(); },
|
|
2496
|
-
size: size,
|
|
2497
|
-
onClickItem: function (e, val) { return handleClickDrpdownItem(e, val); },
|
|
2498
|
-
zIndex: zIndex + 10,
|
|
2499
|
-
})
|
|
2500
|
-
: child;
|
|
2501
|
-
})), document.body)));
|
|
2528
|
+
(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current)
|
|
2529
|
+
? createPortal(dropdownElement, document.body)
|
|
2530
|
+
: dropdownElement));
|
|
2502
2531
|
};
|
|
2503
2532
|
DropdownContainer.defaultProps = {
|
|
2504
2533
|
isTopFlat: false,
|
|
@@ -2663,20 +2692,20 @@ var useLiveSearch = function (_a) {
|
|
|
2663
2692
|
};
|
|
2664
2693
|
|
|
2665
2694
|
function LiveSearch(_a) {
|
|
2666
|
-
var _b = _a.autoComplete, autoComplete = _b === void 0 ? 'off' : _b, _c = _a.children, children = _c === void 0 ? undefined : _c, descText = _a.descText, _d = _a.disabled, disabled = _d === void 0 ? false : _d,
|
|
2695
|
+
var _b = _a.autoComplete, autoComplete = _b === void 0 ? 'off' : _b, _c = _a.children, children = _c === void 0 ? undefined : _c, descText = _a.descText, _d = _a.disabled, disabled = _d === void 0 ? false : _d, dropContProps = _a.dropContProps, id = _a.id, label = _a.label, _e = _a.onChangeText, onChangeText = _e === void 0 ? function () { } : _e, _f = _a.onClickDropdown, onClickDropdown = _f === void 0 ? function () { } : _f, options = _a.options, placeholder = _a.placeholder, _g = _a.readOnly, readOnly = _g === void 0 ? false : _g, _h = _a.required, required = _h === void 0 ? false : _h, _j = _a.searchVariant, searchVariant = _j === void 0 ? 'include' : _j, setValue = _a.setValue, _k = _a.size, size = _k === void 0 ? 'md' : _k, value = _a.value;
|
|
2667
2696
|
var inputRef = useRef(null);
|
|
2668
2697
|
var dropdownContRef = useRef(null);
|
|
2669
|
-
var
|
|
2698
|
+
var _l = useLiveSearch({
|
|
2670
2699
|
value: value,
|
|
2671
2700
|
setValue: setValue,
|
|
2672
2701
|
onChangeText: onChangeText,
|
|
2673
2702
|
dropContOnClickItem: dropContProps.onClickItem
|
|
2674
|
-
}), isOpen =
|
|
2675
|
-
var
|
|
2676
|
-
var dropContClassName = dropContProps.className; dropContProps.onClickItem; var restDropContProps = __rest(dropContProps, ["className", "onClickItem"]);
|
|
2703
|
+
}), isOpen = _l.isOpen, setIsOpen = _l.setIsOpen, searchTerm = _l.searchTerm, handleInputChange = _l.handleInputChange, handleDropdownItemClick = _l.handleDropdownItemClick;
|
|
2704
|
+
var _m = sizeConfig$6[size], iconClass = _m.iconClass, iconSize = _m.iconSize, inputClass = _m.inputClass;
|
|
2705
|
+
var dropContClassName = dropContProps.className; dropContProps.onClickItem; dropContProps.anchorRef; var restDropContProps = __rest(dropContProps, ["className", "onClickItem", "anchorRef"]);
|
|
2677
2706
|
var isValueExist = value && value.label !== undefined && value.label !== '';
|
|
2678
2707
|
var filteredOptions = filterOptions(options || [], value.label);
|
|
2679
|
-
var
|
|
2708
|
+
var _o = processRenderedChildren(children, searchTerm, searchVariant, handleDropdownItemClick), renderedChildren = _o.renderedChildren, hasFilteredResults = _o.hasFilteredResults;
|
|
2680
2709
|
return (React.createElement("div", { className: "bianic-livesearch field-group group/form flex w-full flex-col gap-y-2 " },
|
|
2681
2710
|
label && (React.createElement(FormLabel, { htmlFor: id, required: required, readOnly: readOnly }, label)),
|
|
2682
2711
|
React.createElement("div", { className: "group relative w-full" },
|
|
@@ -8,7 +8,7 @@ export interface DropdownContainerProps extends ComponentPropsWithRef<'div'> {
|
|
|
8
8
|
isWithOverlay?: boolean;
|
|
9
9
|
size?: 'sm' | 'md';
|
|
10
10
|
zIndex?: number;
|
|
11
|
-
anchorRef
|
|
11
|
+
anchorRef?: React.RefObject<HTMLElement>;
|
|
12
12
|
onClickItem?: (event: React.MouseEvent<HTMLDivElement>, val: string | number | object) => void;
|
|
13
13
|
}
|
|
14
14
|
declare const DropdownContainer: {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React, { ComponentPropsWithRef } from 'react';
|
|
2
1
|
interface MenuContainerProps extends ComponentPropsWithRef<'div'> {
|
|
3
2
|
isTopFlat?: boolean;
|
|
4
3
|
children: React.ReactNode | undefined;
|
|
@@ -8,8 +7,9 @@ interface MenuContainerProps extends ComponentPropsWithRef<'div'> {
|
|
|
8
7
|
isWithOverlay?: boolean;
|
|
9
8
|
zIndex?: number;
|
|
10
9
|
onClickItem?: () => void;
|
|
11
|
-
anchorRef
|
|
10
|
+
anchorRef?: React.RefObject<HTMLElement>;
|
|
12
11
|
}
|
|
12
|
+
import React, { ComponentPropsWithRef } from 'react';
|
|
13
13
|
declare const MenuContainer: {
|
|
14
14
|
(props: MenuContainerProps): React.JSX.Element | null;
|
|
15
15
|
defaultProps: {
|
|
@@ -4,6 +4,7 @@ interface PositionStyle {
|
|
|
4
4
|
left?: string;
|
|
5
5
|
right?: string;
|
|
6
6
|
bottom?: string;
|
|
7
|
+
position?: 'absolute' | 'fixed' | 'relative';
|
|
7
8
|
}
|
|
8
|
-
declare const usePopupPosition: (anchorRef
|
|
9
|
+
declare const usePopupPosition: (anchorRef?: RefObject<HTMLElement>, popupRef?: RefObject<HTMLDivElement>, position?: string) => [PositionStyle, () => void] | {}[];
|
|
9
10
|
export default usePopupPosition;
|
package/dist/index.d.ts
CHANGED
|
@@ -161,8 +161,9 @@ interface MenuContainerProps extends ComponentPropsWithRef<'div'> {
|
|
|
161
161
|
isWithOverlay?: boolean;
|
|
162
162
|
zIndex?: number;
|
|
163
163
|
onClickItem?: () => void;
|
|
164
|
-
anchorRef
|
|
164
|
+
anchorRef?: React$1.RefObject<HTMLElement>;
|
|
165
165
|
}
|
|
166
|
+
|
|
166
167
|
declare const MenuContainer: {
|
|
167
168
|
(props: MenuContainerProps): React$1.JSX.Element | null;
|
|
168
169
|
defaultProps: {
|
|
@@ -307,7 +308,7 @@ interface DropdownContainerProps extends ComponentPropsWithRef<'div'> {
|
|
|
307
308
|
isWithOverlay?: boolean;
|
|
308
309
|
size?: 'sm' | 'md';
|
|
309
310
|
zIndex?: number;
|
|
310
|
-
anchorRef
|
|
311
|
+
anchorRef?: React$1.RefObject<HTMLElement>;
|
|
311
312
|
onClickItem?: (event: React$1.MouseEvent<HTMLDivElement>, val: string | number | object) => void;
|
|
312
313
|
}
|
|
313
314
|
declare const DropdownContainer: {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"@biaenergi:registry": "https://gitlab.com/api/v4/projects/50905269/packages/npm/"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.0-alpha.
|
|
6
|
+
"version": "1.16.0-alpha.7",
|
|
7
7
|
"description": "Design Language System develop by BIAENERGI",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"rollup": "rollup -c",
|