@mezzanine-ui/react 0.15.0 → 0.15.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.
@@ -0,0 +1,30 @@
1
+ import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
2
+ export interface AnchorProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'onClick'> {
3
+ /** The current active anchor ID */
4
+ activeAnchorId?: string;
5
+ /** Whether apply ellipsis or not
6
+ * @default false
7
+ */
8
+ ellipsis?: boolean;
9
+ /**
10
+ * Anchor list.
11
+ */
12
+ list: {
13
+ id: string;
14
+ name: string;
15
+ }[];
16
+ /**
17
+ * The maximum width for anchor container. This might be useful when you need to set `ellipsis: true`.
18
+ */
19
+ maxWidth?: number;
20
+ /**
21
+ * Trigger when user click on any anchor.
22
+ */
23
+ onClick?: (nextAnchorId: string) => void;
24
+ }
25
+ /**
26
+ * The react component for `mezzanine` anchor.
27
+ * This component should always be full width of its parent.
28
+ */
29
+ declare const Anchor: import("react").ForwardRefExoticComponent<AnchorProps & import("react").RefAttributes<HTMLDivElement>>;
30
+ export default Anchor;
@@ -0,0 +1,21 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { forwardRef } from 'react';
3
+ import { anchorClasses } from '@mezzanine-ui/core/anchor';
4
+ import Typography from '../Typography/Typography.js';
5
+ import cx from 'clsx';
6
+
7
+ /**
8
+ * The react component for `mezzanine` anchor.
9
+ * This component should always be full width of its parent.
10
+ */
11
+ const Anchor = forwardRef(function Anchor(props, ref) {
12
+ const { activeAnchorId, className, children, ellipsis = false, list, maxWidth, onClick, style, ...rest } = props;
13
+ const resolvedStyle = {
14
+ ...(style || {}),
15
+ ...(maxWidth ? { maxWidth: `${maxWidth}px` } : {}),
16
+ };
17
+ return (jsxs("div", { ref: ref, className: cx(anchorClasses.host, className), style: resolvedStyle, ...rest, children: [jsx("div", { className: anchorClasses.bar }), list.map((anchor) => (jsx("button", { type: "button", onClick: () => onClick === null || onClick === void 0 ? void 0 : onClick(anchor.id), className: cx(anchorClasses.anchor, activeAnchorId === anchor.id && anchorClasses.anchorActive), children: jsx(Typography, { variant: "input3", color: "inherit", ellipsis: ellipsis, children: anchor.name }) }, anchor.id)))] }));
18
+ });
19
+ var Anchor$1 = Anchor;
20
+
21
+ export { Anchor$1 as default };
@@ -0,0 +1 @@
1
+ export { AnchorProps, default } from './Anchor';
@@ -0,0 +1 @@
1
+ export { default } from './Anchor.js';
package/index.d.ts CHANGED
@@ -87,6 +87,10 @@ export { PopconfirmProps, default as Popconfirm } from './Popconfirm';
87
87
  export { NotificationData, NotificationSeverity, default as Notification, } from './Notification';
88
88
  export { ProgressProps, ProgressType, ProgressStatus, ProgressTypes, ProgressStatuses, default as Progress, } from './Progress';
89
89
  export { SkeletonProps, default as Skeleton } from './Skeleton';
90
+ /**
91
+ * Others
92
+ */
93
+ export { AnchorProps, default as Anchor } from './Anchor';
90
94
  /**
91
95
  * Utility
92
96
  */
package/index.js CHANGED
@@ -131,6 +131,7 @@ export { default as Popconfirm } from './Popconfirm/Popconfirm.js';
131
131
  export { default as Notification } from './Notification/Notification.js';
132
132
  export { default as Progress } from './Progress/Progress.js';
133
133
  export { default as Skeleton } from './Skeleton/Skeleton.js';
134
+ export { default as Anchor } from './Anchor/Anchor.js';
134
135
  export { default as Overlay } from './Overlay/Overlay.js';
135
136
  export { default as Popover } from './Popover/Popover.js';
136
137
  export { default as Popper } from './Popper/Popper.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mezzanine-ui/react",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "React components for mezzanine-ui",
5
5
  "author": "Mezzanine",
6
6
  "repository": {
@@ -29,9 +29,9 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@hello-pangea/dnd": "^16.6.0",
32
- "@mezzanine-ui/core": "^0.15.0",
33
- "@mezzanine-ui/icons": "^0.15.0",
34
- "@mezzanine-ui/system": "^0.15.0",
32
+ "@mezzanine-ui/core": "^0.15.1",
33
+ "@mezzanine-ui/icons": "^0.15.1",
34
+ "@mezzanine-ui/system": "^0.15.1",
35
35
  "@popperjs/core": "^2.11.6",
36
36
  "@types/react-transition-group": "^4.4.8",
37
37
  "clsx": "^2.1.1",
@@ -2,10 +2,10 @@ import { getScrollbarWidth } from './get-scrollbar-width.js';
2
2
 
3
3
  function lockBodyScroll() {
4
4
  const { scrollY } = window;
5
- document.body.style.position = 'fixed';
6
- document.body.style.top = `-${scrollY}px`;
7
5
  // Calculate scroll bar width and use padding-right to remain layout width.
8
6
  const scrollbarWidth = getScrollbarWidth();
7
+ document.body.style.position = 'fixed';
8
+ document.body.style.top = `-${scrollY}px`;
9
9
  document.body.style.paddingRight = `${scrollbarWidth}px`;
10
10
  document.body.style.overflow = 'hidden';
11
11
  }