@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/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.44.0](https://github.com/ocean-ds/ocean-web/compare/v1.43.0...v1.44.0) (2023-06-01)
7
+
8
+ ### Features
9
+
10
+ - add attach mode to drawer ([#1067](https://github.com/ocean-ds/ocean-web/issues/1067)) ([2edfd28](https://github.com/ocean-ds/ocean-web/commit/2edfd28eb6ba53242b83d656f8c4f455e2ba5da9))
11
+
6
12
  # [1.43.0](https://github.com/ocean-ds/ocean-web/compare/v1.42.0...v1.43.0) (2023-02-24)
7
13
 
8
14
  ### Features
@@ -1,12 +1,14 @@
1
- import React from 'react';
1
+ import React, { RefObject } from 'react';
2
2
  interface DrawerProps {
3
3
  children: React.ReactNode;
4
4
  open: boolean;
5
5
  onDrawerClose?(event: React.MouseEvent | React.KeyboardEvent): void;
6
6
  overlayClose: () => void;
7
7
  headerIcon?: React.ReactNode;
8
- iconAlignment?: string;
8
+ align?: 'right' | 'left';
9
+ iconAlignment?: 'right' | 'left';
10
+ anchorEl?: RefObject<HTMLDivElement> | null;
9
11
  }
10
- declare const Drawer: ({ children, open, onDrawerClose, overlayClose, headerIcon, iconAlignment, }: DrawerProps) => React.ReactElement;
12
+ declare const Drawer: ({ children, open, onDrawerClose, overlayClose, align, headerIcon, iconAlignment, anchorEl, }: DrawerProps) => React.ReactElement;
11
13
  export default Drawer;
12
14
  //# sourceMappingURL=Drawer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../src/Drawer/Drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,UAAU,WAAW;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,aAAa,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC;IACpE,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,MAAM,gFAOT,WAAW,KAAG,MAAM,YAqBtB,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../src/Drawer/Drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAkC,MAAM,OAAO,CAAC;AAMzE,UAAU,WAAW;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,aAAa,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC;IACpE,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;CAC7C;AAED,QAAA,MAAM,MAAM,iGAST,WAAW,KAAG,MAAM,YAmEtB,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ export interface SimpleDrawerProps {
3
+ children: React.ReactElement;
4
+ open?: boolean;
5
+ align?: 'left' | 'right';
6
+ iconAlignment?: 'left' | 'right';
7
+ }
8
+ declare const SimpleDrawer: ({ children, open, align, iconAlignment, }: SimpleDrawerProps) => React.ReactElement;
9
+ export default SimpleDrawer;
10
+ //# sourceMappingURL=AttachedDrawer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AttachedDrawer.d.ts","sourceRoot":"","sources":["../../../src/Drawer/examples/AttachedDrawer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAKhD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAClC;AAED,QAAA,MAAM,YAAY,8CAKf,iBAAiB,KAAG,MAAM,YAqD5B,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -2,8 +2,9 @@ import React from 'react';
2
2
  export interface SimpleDrawerProps {
3
3
  children: React.ReactElement;
4
4
  open?: boolean;
5
- iconAlignment?: string;
5
+ align?: 'left' | 'right';
6
+ iconAlignment?: 'left' | 'right';
6
7
  }
7
- declare const SimpleDrawer: ({ children, open, iconAlignment, }: SimpleDrawerProps) => React.ReactElement;
8
+ declare const SimpleDrawer: ({ children, open, align, iconAlignment, }: SimpleDrawerProps) => React.ReactElement;
8
9
  export default SimpleDrawer;
9
10
  //# sourceMappingURL=SimpleDrawer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SimpleDrawer.d.ts","sourceRoot":"","sources":["../../../src/Drawer/examples/SimpleDrawer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAKxC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,QAAA,MAAM,YAAY,uCAIf,iBAAiB,KAAG,MAAM,YAsB5B,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"SimpleDrawer.d.ts","sourceRoot":"","sources":["../../../src/Drawer/examples/SimpleDrawer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAKxC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAClC;AAED,QAAA,MAAM,YAAY,8CAKf,iBAAiB,KAAG,MAAM,YAuB5B,CAAC;AAEF,eAAe,YAAY,CAAC"}
package/index.es.js CHANGED
@@ -46239,10 +46239,39 @@ var Breadcrumb = forwardRef(function (_a, ref) {
46239
46239
  Breadcrumb.displayName = 'Breadcrumb';
46240
46240
 
46241
46241
  var Drawer = function (_a) {
46242
- var children = _a.children, open = _a.open, onDrawerClose = _a.onDrawerClose, overlayClose = _a.overlayClose, _b = _a.headerIcon, headerIcon = _b === void 0 ? e.createElement(ts, null) : _b, _c = _a.iconAlignment, iconAlignment = _c === void 0 ? 'right' : _c;
46243
- return (e.createElement(e.Fragment, null,
46244
- e.createElement("div", { className: classNames('ods-overlay', open && 'ods-overlay--open'), "aria-hidden": "true", onClick: overlayClose }),
46245
- e.createElement("div", { className: classNames('ods-drawer', open && 'ods-drawer--open') },
46242
+ 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.createElement(ts, null) : _c, _d = _a.iconAlignment, iconAlignment = _d === void 0 ? 'right' : _d, anchorEl = _a.anchorEl;
46243
+ var drawerRef = useRef(null);
46244
+ var getAnchorPosition = useCallback(function () {
46245
+ if (!(anchorEl === null || anchorEl === void 0 ? void 0 : anchorEl.current))
46246
+ return null;
46247
+ var position = anchorEl.current.getBoundingClientRect();
46248
+ if (align === 'right') {
46249
+ var size = window.innerWidth - position.left;
46250
+ return {
46251
+ width: "".concat(size, "px"),
46252
+ right: "".concat(size, "px"),
46253
+ left: 'auto'
46254
+ };
46255
+ }
46256
+ return {
46257
+ width: "".concat(position.right, "px"),
46258
+ right: 'auto',
46259
+ left: "".concat(position.right, "px")
46260
+ };
46261
+ }, [align, anchorEl]);
46262
+ var attachDrawer = useCallback(function () {
46263
+ var position = getAnchorPosition();
46264
+ if (!drawerRef.current || !position)
46265
+ return;
46266
+ drawerRef.current.style.width = "calc(100% - ".concat(position === null || position === void 0 ? void 0 : position.width, "px)})");
46267
+ drawerRef.current.style.left = position.left;
46268
+ drawerRef.current.style.right = position.right;
46269
+ }, [getAnchorPosition]);
46270
+ useEffect(function () {
46271
+ attachDrawer();
46272
+ }, [anchorEl, drawerRef, attachDrawer]);
46273
+ return (e.createElement("div", { className: classNames('ods-overlay', open && 'ods-overlay--open'), "aria-hidden": "true", onClick: overlayClose, ref: drawerRef },
46274
+ e.createElement("div", { className: classNames('ods-drawer', open && 'ods-drawer--open', "ods-drawer--".concat(align)) },
46246
46275
  e.createElement("div", { className: classNames('ods-drawer__content--header', "ods-drawer__content--header--".concat(iconAlignment)) },
46247
46276
  e.createElement(Button$1, { type: "button", onClick: onDrawerClose }, headerIcon)),
46248
46277
  children)));