bianic-ui 1.15.0-alpha.0 → 1.15.0-alpha.2
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 +131 -113
- package/dist/cjs/lib.css +1 -1
- package/dist/esm/index.js +131 -113
- package/dist/esm/lib.css +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -2241,76 +2241,6 @@ var fontConfig = {
|
|
|
2241
2241
|
md: 'text-[14px] font-[350]',
|
|
2242
2242
|
};
|
|
2243
2243
|
|
|
2244
|
-
var getDropdownStyle = function (anchorRef, dropdownRef) {
|
|
2245
|
-
if (!anchorRef.current || !dropdownRef.current) {
|
|
2246
|
-
return { minWidth: 'auto' };
|
|
2247
|
-
}
|
|
2248
|
-
var anchorRect = anchorRef.current.getBoundingClientRect();
|
|
2249
|
-
var dropdownHeight = dropdownRef.current.offsetHeight;
|
|
2250
|
-
var spaceToBottom = window.innerHeight - anchorRect.bottom;
|
|
2251
|
-
var spaceToTop = anchorRect.top;
|
|
2252
|
-
var style = {
|
|
2253
|
-
left: "".concat(anchorRect.left + window.scrollX, "px"),
|
|
2254
|
-
minWidth: "".concat(anchorRect.width, "px"),
|
|
2255
|
-
};
|
|
2256
|
-
// If space below is less than dropdown height,
|
|
2257
|
-
// AND space above is more than space below
|
|
2258
|
-
// then flip up
|
|
2259
|
-
if (spaceToBottom < dropdownHeight && spaceToTop > spaceToBottom) {
|
|
2260
|
-
var topPositionForFlip = anchorRect.top + window.scrollY - dropdownHeight;
|
|
2261
|
-
style.top = "".concat(topPositionForFlip, "px");
|
|
2262
|
-
}
|
|
2263
|
-
else {
|
|
2264
|
-
style.top = "".concat(anchorRect.bottom + window.scrollY, "px");
|
|
2265
|
-
}
|
|
2266
|
-
return style;
|
|
2267
|
-
};
|
|
2268
|
-
var DropdownContainer = function (propsComp) {
|
|
2269
|
-
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"]);
|
|
2270
|
-
if (!open)
|
|
2271
|
-
return null;
|
|
2272
|
-
var _j = React.useState({ minWidth: 'auto' }), positionStyle = _j[0], setPositionStyle = _j[1];
|
|
2273
|
-
var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
|
|
2274
|
-
var sizeClass = containerSizeConfig[size] || containerSizeConfig['md'];
|
|
2275
|
-
var containerClass = "".concat(sizeClass, " ").concat(radiusClass, " ").concat(className);
|
|
2276
|
-
var dropdownRef = React.useRef(null);
|
|
2277
|
-
var handleClickDrpdownItem = function (e, val) {
|
|
2278
|
-
onClickItem(e, val);
|
|
2279
|
-
onClose();
|
|
2280
|
-
};
|
|
2281
|
-
React.useLayoutEffect(function () {
|
|
2282
|
-
if (!(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current))
|
|
2283
|
-
return;
|
|
2284
|
-
var newStyle = getDropdownStyle(anchorRef, dropdownRef);
|
|
2285
|
-
setPositionStyle(newStyle);
|
|
2286
|
-
var handleScrollOrResize = function () {
|
|
2287
|
-
setPositionStyle(getDropdownStyle(anchorRef, dropdownRef));
|
|
2288
|
-
};
|
|
2289
|
-
window.addEventListener('scroll', handleScrollOrResize);
|
|
2290
|
-
window.addEventListener('resize', handleScrollOrResize);
|
|
2291
|
-
return function () {
|
|
2292
|
-
window.removeEventListener('scroll', handleScrollOrResize);
|
|
2293
|
-
window.removeEventListener('resize', handleScrollOrResize);
|
|
2294
|
-
};
|
|
2295
|
-
}, [anchorRef]);
|
|
2296
|
-
return (React.createElement(React.Fragment, null,
|
|
2297
|
-
isWithOverlay && (React.createElement("div", { className: "bianic-dropdown-overlay fixed left-0 top-0 h-screen w-screen", style: { zIndex: zIndex }, onClick: function () { return onClose(); } })),
|
|
2298
|
-
reactDom.createPortal(React.createElement("div", __assign({ ref: dropdownRef, className: "absolute max-w-fit bianic-dropdown-container bg-bia-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] ".concat(containerClass), style: __assign({ zIndex: zIndex + 10 }, positionStyle) }, restProps), React.Children.map(children, function (child) {
|
|
2299
|
-
return React.isValidElement(child)
|
|
2300
|
-
? // Kirimkan handleItemClick sebagai props onClick ke setiap DropdownItem
|
|
2301
|
-
React.cloneElement(child, {
|
|
2302
|
-
onClose: function () { return onClose(); },
|
|
2303
|
-
size: size,
|
|
2304
|
-
onClickItem: function (e, val) { return handleClickDrpdownItem(e, val); },
|
|
2305
|
-
zIndex: zIndex + 10,
|
|
2306
|
-
})
|
|
2307
|
-
: child;
|
|
2308
|
-
})), document.body)));
|
|
2309
|
-
};
|
|
2310
|
-
DropdownContainer.defaultProps = {
|
|
2311
|
-
isTopFlat: false,
|
|
2312
|
-
};
|
|
2313
|
-
|
|
2314
2244
|
var DropdownContNoAnchor = React.forwardRef(function DropdownContNoAnchor(propsComp, ref) {
|
|
2315
2245
|
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"]);
|
|
2316
2246
|
var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
|
|
@@ -2340,54 +2270,15 @@ DropdownContNoAnchor.defaultProps = {
|
|
|
2340
2270
|
isTopFlat: false,
|
|
2341
2271
|
};
|
|
2342
2272
|
|
|
2343
|
-
function DropdownItem(_a) {
|
|
2344
|
-
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"]);
|
|
2345
|
-
var _j = React.useState(false), isHovered = _j[0], setIsHovered = _j[1];
|
|
2346
|
-
var _k = React.useState(false), isLeft = _k[0], setIsLeft = _k[1];
|
|
2347
|
-
var fontClass = fontConfig[size] || fontConfig['md'];
|
|
2348
|
-
var itemSizeClass = itemSizeConfig[size] || itemSizeConfig['md'];
|
|
2349
|
-
var itemClass = "".concat(itemSizeClass, " ").concat(fontClass, " ").concat(className);
|
|
2350
|
-
var chevronSize = size === 'sm' ? 14 : 18;
|
|
2351
|
-
var DropdownContRef = React.useRef(null);
|
|
2352
|
-
React.useEffect(function () {
|
|
2353
|
-
var _a;
|
|
2354
|
-
if (DropdownContRef.current) {
|
|
2355
|
-
// Adjust dropdown position to prevent overflow on the right.
|
|
2356
|
-
var MenuContRect = (_a = DropdownContRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
2357
|
-
var RectRight = MenuContRect === null || MenuContRect === void 0 ? void 0 : MenuContRect.right;
|
|
2358
|
-
var innerWindow = window.innerWidth;
|
|
2359
|
-
if (RectRight > innerWindow)
|
|
2360
|
-
setIsLeft(true);
|
|
2361
|
-
else
|
|
2362
|
-
setIsLeft(false);
|
|
2363
|
-
}
|
|
2364
|
-
}, [isHovered]);
|
|
2365
|
-
var translateClass = isLeft
|
|
2366
|
-
? 'left-0 -translate-x-full'
|
|
2367
|
-
: 'right-0 translate-x-full';
|
|
2368
|
-
var currentZIndex = zIndex + 10;
|
|
2369
|
-
return (React.createElement("div", { className: "bianic-dropdown-item group/main relative cursor-pointer first:rounded-t-radius-sm first:pt-[5px] last:rounded-b-radius-sm last:pb-[5px]", onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); } },
|
|
2370
|
-
React.createElement("button", __assign({ className: "relative flex w-full !min-w-fit items-center justify-start whitespace-nowrap px-[15px] py-[5px] text-left text-bia-black disabled:cursor-not-allowed disabled:text-bia-coolgrey-light-50 hover:[&:not(:disabled)]:bg-bia-blue-pastel ".concat(itemClass), style: {
|
|
2371
|
-
zIndex: isHovered ? currentZIndex : currentZIndex + 15,
|
|
2372
|
-
}, onClick: function (e) {
|
|
2373
|
-
onClickItem(e, value);
|
|
2374
|
-
}, onKeyDown: function () { }, disabled: disabled, type: "button" }, props),
|
|
2375
|
-
content,
|
|
2376
|
-
React.createElement("div", { className: "ml-auto flex items-center" }, children && (React.createElement(TbChevronRight, { className: "ml-[10px] text-bia-coolgrey", size: chevronSize })))),
|
|
2377
|
-
children && (React.createElement(DropdownContNoAnchor, { className: "absolute top-0 bg-primary-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] group-first/main:top-[6px] ".concat(translateClass), onClose: onClose, open: isHovered, onClickItem: function (e, value) { return onClickItem(e, value); }, size: size, ref: DropdownContRef, zIndex: currentZIndex + 10 }, children))));
|
|
2378
|
-
}
|
|
2379
|
-
DropdownItem.defaultProps = {
|
|
2380
|
-
className: '',
|
|
2381
|
-
onClickItem: function () { },
|
|
2382
|
-
};
|
|
2383
|
-
|
|
2384
2273
|
var sizeUnion$2 = ['md', 'sm'];
|
|
2385
2274
|
function SelectInput(_a) {
|
|
2386
2275
|
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, label = _a.label, _d = _a.options, options = _d === void 0 ? [] : _d, _e = _a.required, required = _e === void 0 ? false : _e, selected = _a.selected, setSelected = _a.setSelected, _f = _a.onClickDropdown, onClickDropdown = _f === void 0 ? function () { } : _f, children = _a.children, _g = _a.dropContProps, _h = _g === void 0 ? {} : _g, _j = _h.className, dropContClassName = _j === void 0 ? '' : _j, restDropContProps = __rest(_h, ["className"]), props = __rest(_a, ["descText", "disabled", "size", "id", "label", "options", "required", "selected", "setSelected", "onClickDropdown", "children", "dropContProps"]);
|
|
2387
2276
|
var _k = React.useState(false), isOpen = _k[0], setIsOpen = _k[1];
|
|
2277
|
+
var _l = React.useState(false), isDropUp = _l[0], setIsDropUp = _l[1];
|
|
2388
2278
|
var validatedSize = validUnion(size, sizeUnion$2);
|
|
2389
|
-
var
|
|
2279
|
+
var _m = sizeConfig$8[validatedSize], searchSize = _m.searchSize, iconSize = _m.iconSize;
|
|
2390
2280
|
var inputRef = React.useRef(null);
|
|
2281
|
+
var dropdownContRef = React.useRef(null);
|
|
2391
2282
|
var handleOutsideClick = function (e) {
|
|
2392
2283
|
if (inputRef.current && !inputRef.current.contains(e.target)) {
|
|
2393
2284
|
setIsOpen(false);
|
|
@@ -2399,6 +2290,22 @@ function SelectInput(_a) {
|
|
|
2399
2290
|
document.removeEventListener('mousedown', handleOutsideClick);
|
|
2400
2291
|
};
|
|
2401
2292
|
});
|
|
2293
|
+
React.useEffect(function () {
|
|
2294
|
+
var _a, _b;
|
|
2295
|
+
if (inputRef.current) {
|
|
2296
|
+
// Adjust dropdown position to prevent show up out of screen
|
|
2297
|
+
var windowHeight = window.innerHeight;
|
|
2298
|
+
var inputRect = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
2299
|
+
var inputBottom = inputRect === null || inputRect === void 0 ? void 0 : inputRect.bottom;
|
|
2300
|
+
var diff = windowHeight - inputBottom;
|
|
2301
|
+
var dropdownRect = (_b = dropdownContRef.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
|
|
2302
|
+
var dropdownHeight = (dropdownRect === null || dropdownRect === void 0 ? void 0 : dropdownRect.height) || 0;
|
|
2303
|
+
if (dropdownHeight >= diff)
|
|
2304
|
+
setIsDropUp(true);
|
|
2305
|
+
else
|
|
2306
|
+
setIsDropUp(false);
|
|
2307
|
+
}
|
|
2308
|
+
}, [isOpen]);
|
|
2402
2309
|
var isObjectOptionItem = false;
|
|
2403
2310
|
if (options.every(function (item) { return typeof item === 'object' && item !== null; }))
|
|
2404
2311
|
isObjectOptionItem = true;
|
|
@@ -2418,6 +2325,7 @@ function SelectInput(_a) {
|
|
|
2418
2325
|
optionsElement.style.maxHeight = "".concat(Math.max(0, maxHeight), "px");
|
|
2419
2326
|
}
|
|
2420
2327
|
}, [isOpen]);
|
|
2328
|
+
var dropdownPosition = isDropUp ? 'bottom-full' : 'top-full';
|
|
2421
2329
|
return (React.createElement("div", { className: "field-group flex w-full flex-col", ref: inputRef },
|
|
2422
2330
|
React.createElement("label", { htmlFor: id, className: "label pb-2 text-xs font-semibold" },
|
|
2423
2331
|
childrenElement(label),
|
|
@@ -2437,7 +2345,7 @@ function SelectInput(_a) {
|
|
|
2437
2345
|
setIsOpen(false);
|
|
2438
2346
|
} }));
|
|
2439
2347
|
}))),
|
|
2440
|
-
children && isOpen && (React.createElement(
|
|
2348
|
+
children && isOpen && (React.createElement(DropdownContNoAnchor, __assign({ open: isOpen, onClose: function () { return setIsOpen(false); }, size: size, isTopFlat: true, ref: dropdownContRef, 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(dropdownPosition, " ").concat(dropContClassName) }, restDropContProps), React.Children.map(children, function (child) {
|
|
2441
2349
|
if (React.isValidElement(child)) {
|
|
2442
2350
|
return React.cloneElement(child, {
|
|
2443
2351
|
isSelected: selected && selected.id === child.props.value.id,
|
|
@@ -2477,6 +2385,116 @@ var sizeConfig$6 = {
|
|
|
2477
2385
|
},
|
|
2478
2386
|
};
|
|
2479
2387
|
|
|
2388
|
+
var getDropdownStyle = function (anchorRef, dropdownRef) {
|
|
2389
|
+
if (!anchorRef.current || !dropdownRef.current) {
|
|
2390
|
+
return { minWidth: 'auto' };
|
|
2391
|
+
}
|
|
2392
|
+
var anchorRect = anchorRef.current.getBoundingClientRect();
|
|
2393
|
+
var dropdownHeight = dropdownRef.current.offsetHeight;
|
|
2394
|
+
var spaceToBottom = window.innerHeight - anchorRect.bottom;
|
|
2395
|
+
var spaceToTop = anchorRect.top;
|
|
2396
|
+
var style = {
|
|
2397
|
+
left: "".concat(anchorRect.left + window.scrollX, "px"),
|
|
2398
|
+
minWidth: "".concat(anchorRect.width, "px"),
|
|
2399
|
+
};
|
|
2400
|
+
// If space below is less than dropdown height,
|
|
2401
|
+
// AND space above is more than space below
|
|
2402
|
+
// then flip up
|
|
2403
|
+
if (spaceToBottom < dropdownHeight && spaceToTop > spaceToBottom) {
|
|
2404
|
+
style.bottom = "".concat(window.innerHeight - anchorRect.top, "px");
|
|
2405
|
+
}
|
|
2406
|
+
else {
|
|
2407
|
+
style.top = "".concat(anchorRect.bottom + window.scrollY, "px");
|
|
2408
|
+
}
|
|
2409
|
+
return style;
|
|
2410
|
+
};
|
|
2411
|
+
var DropdownContainer = function (propsComp) {
|
|
2412
|
+
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"]);
|
|
2413
|
+
if (!open)
|
|
2414
|
+
return null;
|
|
2415
|
+
var _j = React.useState({ minWidth: 'auto' }), positionStyle = _j[0], setPositionStyle = _j[1];
|
|
2416
|
+
var radiusClass = "rounded-b-radius-sm ".concat(!isTopFlat && 'rounded-t-radius-sm');
|
|
2417
|
+
var sizeClass = containerSizeConfig[size] || containerSizeConfig['md'];
|
|
2418
|
+
var containerClass = "".concat(sizeClass, " ").concat(radiusClass, " ").concat(className);
|
|
2419
|
+
var dropdownRef = React.useRef(null);
|
|
2420
|
+
var handleClickDrpdownItem = function (e, val) {
|
|
2421
|
+
onClickItem(e, val);
|
|
2422
|
+
onClose();
|
|
2423
|
+
};
|
|
2424
|
+
React.useLayoutEffect(function () {
|
|
2425
|
+
if (!(anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current))
|
|
2426
|
+
return;
|
|
2427
|
+
var newStyle = getDropdownStyle(anchorRef, dropdownRef);
|
|
2428
|
+
setPositionStyle(newStyle);
|
|
2429
|
+
var handleScrollOrResize = function () {
|
|
2430
|
+
setPositionStyle(getDropdownStyle(anchorRef, dropdownRef));
|
|
2431
|
+
};
|
|
2432
|
+
window.addEventListener('scroll', handleScrollOrResize);
|
|
2433
|
+
window.addEventListener('resize', handleScrollOrResize);
|
|
2434
|
+
return function () {
|
|
2435
|
+
window.removeEventListener('scroll', handleScrollOrResize);
|
|
2436
|
+
window.removeEventListener('resize', handleScrollOrResize);
|
|
2437
|
+
};
|
|
2438
|
+
}, [anchorRef]);
|
|
2439
|
+
return (React.createElement(React.Fragment, null,
|
|
2440
|
+
isWithOverlay && (React.createElement("div", { className: "bianic-dropdown-overlay fixed left-0 top-0 h-screen w-screen", style: { zIndex: zIndex }, onClick: function () { return onClose(); } })),
|
|
2441
|
+
reactDom.createPortal(React.createElement("div", __assign({ ref: dropdownRef, className: "absolute max-w-fit bianic-dropdown-container bg-bia-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] ".concat(containerClass), style: __assign({ zIndex: zIndex + 10 }, positionStyle) }, restProps), React.Children.map(children, function (child) {
|
|
2442
|
+
return React.isValidElement(child)
|
|
2443
|
+
? // Kirimkan handleItemClick sebagai props onClick ke setiap DropdownItem
|
|
2444
|
+
React.cloneElement(child, {
|
|
2445
|
+
onClose: function () { return onClose(); },
|
|
2446
|
+
size: size,
|
|
2447
|
+
onClickItem: function (e, val) { return handleClickDrpdownItem(e, val); },
|
|
2448
|
+
zIndex: zIndex + 10,
|
|
2449
|
+
})
|
|
2450
|
+
: child;
|
|
2451
|
+
})), document.body)));
|
|
2452
|
+
};
|
|
2453
|
+
DropdownContainer.defaultProps = {
|
|
2454
|
+
isTopFlat: false,
|
|
2455
|
+
};
|
|
2456
|
+
|
|
2457
|
+
function DropdownItem(_a) {
|
|
2458
|
+
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"]);
|
|
2459
|
+
var _j = React.useState(false), isHovered = _j[0], setIsHovered = _j[1];
|
|
2460
|
+
var _k = React.useState(false), isLeft = _k[0], setIsLeft = _k[1];
|
|
2461
|
+
var fontClass = fontConfig[size] || fontConfig['md'];
|
|
2462
|
+
var itemSizeClass = itemSizeConfig[size] || itemSizeConfig['md'];
|
|
2463
|
+
var itemClass = "".concat(itemSizeClass, " ").concat(fontClass, " ").concat(className);
|
|
2464
|
+
var chevronSize = size === 'sm' ? 14 : 18;
|
|
2465
|
+
var DropdownContRef = React.useRef(null);
|
|
2466
|
+
React.useEffect(function () {
|
|
2467
|
+
var _a;
|
|
2468
|
+
if (DropdownContRef.current) {
|
|
2469
|
+
// Adjust dropdown position to prevent overflow on the right.
|
|
2470
|
+
var MenuContRect = (_a = DropdownContRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
2471
|
+
var RectRight = MenuContRect === null || MenuContRect === void 0 ? void 0 : MenuContRect.right;
|
|
2472
|
+
var innerWindow = window.innerWidth;
|
|
2473
|
+
if (RectRight > innerWindow)
|
|
2474
|
+
setIsLeft(true);
|
|
2475
|
+
else
|
|
2476
|
+
setIsLeft(false);
|
|
2477
|
+
}
|
|
2478
|
+
}, [isHovered]);
|
|
2479
|
+
var translateClass = isLeft
|
|
2480
|
+
? 'left-0 -translate-x-full'
|
|
2481
|
+
: 'right-0 translate-x-full';
|
|
2482
|
+
var currentZIndex = zIndex + 10;
|
|
2483
|
+
return (React.createElement("div", { className: "bianic-dropdown-item group/main relative cursor-pointer first:rounded-t-radius-sm first:pt-[5px] last:rounded-b-radius-sm last:pb-[5px]", onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); } },
|
|
2484
|
+
React.createElement("button", __assign({ className: "relative flex w-full !min-w-fit items-center justify-start whitespace-nowrap px-[15px] py-[5px] text-left text-bia-black disabled:cursor-not-allowed disabled:text-bia-coolgrey-light-50 hover:[&:not(:disabled)]:bg-bia-blue-pastel ".concat(itemClass), style: {
|
|
2485
|
+
zIndex: isHovered ? currentZIndex : currentZIndex + 15,
|
|
2486
|
+
}, onClick: function (e) {
|
|
2487
|
+
onClickItem(e, value);
|
|
2488
|
+
}, onKeyDown: function () { }, disabled: disabled, type: "button" }, props),
|
|
2489
|
+
content,
|
|
2490
|
+
React.createElement("div", { className: "ml-auto flex items-center" }, children && (React.createElement(TbChevronRight, { className: "ml-[10px] text-bia-coolgrey", size: chevronSize })))),
|
|
2491
|
+
children && (React.createElement(DropdownContNoAnchor, { className: "absolute top-0 bg-primary-white shadow-[0px_3px_20px_0px_rgba(0,0,0,0.20)] group-first/main:top-[6px] ".concat(translateClass), onClose: onClose, open: isHovered, onClickItem: function (e, value) { return onClickItem(e, value); }, size: size, ref: DropdownContRef, zIndex: currentZIndex + 10 }, children))));
|
|
2492
|
+
}
|
|
2493
|
+
DropdownItem.defaultProps = {
|
|
2494
|
+
className: '',
|
|
2495
|
+
onClickItem: function () { },
|
|
2496
|
+
};
|
|
2497
|
+
|
|
2480
2498
|
var matchSearchTerm = function (content, term, variant) {
|
|
2481
2499
|
var lowerContent = content.toLowerCase();
|
|
2482
2500
|
var lowerTerm = term.toLowerCase();
|