@useblu/ocean-react 1.43.0 → 1.44.0

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/index.js CHANGED
@@ -46248,10 +46248,39 @@ var Breadcrumb = e.forwardRef(function (_a, ref) {
46248
46248
  Breadcrumb.displayName = 'Breadcrumb';
46249
46249
 
46250
46250
  var Drawer = function (_a) {
46251
- var children = _a.children, open = _a.open, onDrawerClose = _a.onDrawerClose, overlayClose = _a.overlayClose, _b = _a.headerIcon, headerIcon = _b === void 0 ? e__default["default"].createElement(ts, null) : _b, _c = _a.iconAlignment, iconAlignment = _c === void 0 ? 'right' : _c;
46252
- return (e__default["default"].createElement(e__default["default"].Fragment, null,
46253
- e__default["default"].createElement("div", { className: classNames('ods-overlay', open && 'ods-overlay--open'), "aria-hidden": "true", onClick: overlayClose }),
46254
- e__default["default"].createElement("div", { className: classNames('ods-drawer', open && 'ods-drawer--open') },
46251
+ var children = _a.children, open = _a.open, onDrawerClose = _a.onDrawerClose, overlayClose = _a.overlayClose, _b = _a.align, align = _b === void 0 ? 'right' : _b, _c = _a.headerIcon, headerIcon = _c === void 0 ? e__default["default"].createElement(ts, null) : _c, _d = _a.iconAlignment, iconAlignment = _d === void 0 ? 'right' : _d, anchorEl = _a.anchorEl;
46252
+ var drawerRef = e.useRef(null);
46253
+ var getAnchorPosition = e.useCallback(function () {
46254
+ if (!(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.current))
46255
+ return null;
46256
+ var position = anchorEl.current.getBoundingClientRect();
46257
+ if (align === 'right') {
46258
+ var size = window.innerWidth - position.left;
46259
+ return {
46260
+ width: "".concat(size, "px"),
46261
+ right: "".concat(size, "px"),
46262
+ left: 'auto'
46263
+ };
46264
+ }
46265
+ return {
46266
+ width: "".concat(position.right, "px"),
46267
+ right: 'auto',
46268
+ left: "".concat(position.right, "px")
46269
+ };
46270
+ }, [align, anchorEl]);
46271
+ var attachDrawer = e.useCallback(function () {
46272
+ var position = getAnchorPosition();
46273
+ if (!drawerRef.current || !position)
46274
+ return;
46275
+ drawerRef.current.style.width = "calc(100% - ".concat(position === null || position === void 0 ? void 0 : position.width, "px)})");
46276
+ drawerRef.current.style.left = position.left;
46277
+ drawerRef.current.style.right = position.right;
46278
+ }, [getAnchorPosition]);
46279
+ e.useEffect(function () {
46280
+ attachDrawer();
46281
+ }, [anchorEl, drawerRef, attachDrawer]);
46282
+ return (e__default["default"].createElement("div", { className: classNames('ods-overlay', open && 'ods-overlay--open'), "aria-hidden": "true", onClick: overlayClose, ref: drawerRef },
46283
+ e__default["default"].createElement("div", { className: classNames('ods-drawer', open && 'ods-drawer--open', "ods-drawer--".concat(align)) },
46255
46284
  e__default["default"].createElement("div", { className: classNames('ods-drawer__content--header', "ods-drawer__content--header--".concat(iconAlignment)) },
46256
46285
  e__default["default"].createElement(Button$1, { type: "button", onClick: onDrawerClose }, headerIcon)),
46257
46286
  children)));