@vrobots/storybook 0.1.55 → 0.1.57

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vrobots/storybook",
3
3
  "private": false,
4
- "version": "0.1.55",
4
+ "version": "0.1.57",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -1,8 +1,11 @@
1
1
  import { IMenuItemsProps } from "./Menu";
2
+ import React from "react";
2
3
  export interface IAvatarIconMenuProps {
3
4
  src: string;
4
5
  name: string;
5
6
  menu: IMenuItemsProps[];
7
+ onClick: (value: string) => void;
8
+ children?: React.ReactNode;
6
9
  }
7
- export declare const createMenuItem: (item: IMenuItemsProps) => import("react/jsx-runtime").JSX.Element;
8
- export declare const AvatarIconMenu: ({ src, name, menu, }: IAvatarIconMenuProps) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const createMenuItem: (onClick: (value: string) => void) => (item: IMenuItemsProps, key: number) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const AvatarIconMenu: ({ src, name, menu, onClick, children, }: IAvatarIconMenuProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,10 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Avatar, Menu, Portal } from "@chakra-ui/react";
3
- export const createMenuItem = (item) => {
4
- return (_jsx(Menu.Item, { value: item.value, children: item.label }));
3
+ import * as Icons from "react-icons/md";
4
+ import React from "react";
5
+ export const createMenuItem = (onClick) => (item, key) => {
6
+ return (_jsxs(Menu.Item, { value: item.value, onClick: () => onClick(item.value), children: [Icons[item.icon || ''] ? React.createElement(Icons[item.icon]) : null, " ", item.label] }, key + item.value));
5
7
  };
6
- export const AvatarIconMenu = ({ src, name, menu, }) => {
7
- return (_jsxs(Menu.Root, { positioning: { placement: "right-end" }, children: [_jsx(Menu.Trigger, { rounded: "full", focusRing: "outside", children: _jsxs(Avatar.Root, { size: { base: 'xs', md: 'sm' }, children: [_jsx(Avatar.Fallback, { name: name }), _jsx(Avatar.Image, { src: src })] }) }), _jsx(Portal, { children: _jsx(Menu.Positioner, { children: _jsx(Menu.Content, { children: menu.map((item) => createMenuItem(item)) }) }) })] }));
8
+ export const AvatarIconMenu = ({ src, name, menu, onClick, children, }) => {
9
+ return (_jsxs(Menu.Root, { positioning: { placement: "right-end" }, children: [_jsx(Menu.Trigger, { rounded: "full", focusRing: "outside", children: _jsxs(Avatar.Root, { size: { base: 'xs', md: 'sm' }, children: [_jsx(Avatar.Fallback, { name: name }), _jsx(Avatar.Image, { src: src })] }) }), _jsx(Portal, { children: _jsx(Menu.Positioner, { children: _jsxs(Menu.Content, { children: [menu.map(createMenuItem(onClick)), children] }) }) })] }));
8
10
  };
@@ -1,7 +1,9 @@
1
1
  import React from "react";
2
+ import * as Icons from "react-icons/md";
2
3
  export interface IMenuItemsProps {
3
4
  label: string;
4
5
  value: string;
6
+ icon?: keyof typeof Icons;
5
7
  }
6
8
  export interface IMenuProps {
7
9
  menuItems?: IMenuItemsProps[];
@@ -1,11 +1,10 @@
1
1
  import { IBreadcrumb } from "./Breadcrumbs";
2
+ import React from "react";
2
3
  export interface IPageProps {
3
4
  breadcrumbs?: IBreadcrumb[];
4
5
  children: React.ReactNode;
5
6
  }
6
7
  export declare const Page: {
7
8
  ({ breadcrumbs, children }: IPageProps): import("react/jsx-runtime").JSX.Element;
8
- Flex({ children }: {
9
- children: React.ReactNode;
10
- }): import("react/jsx-runtime").JSX.Element;
9
+ Flex({ children, breadcrumbs }: IPageProps): import("react/jsx-runtime").JSX.Element;
11
10
  };
@@ -2,10 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box } from "@chakra-ui/react";
3
3
  import { Breadcrumbs } from "./Breadcrumbs";
4
4
  import { useHeader } from "./Header";
5
+ import React from "react";
5
6
  export const Page = ({ breadcrumbs, children }) => {
6
7
  return (_jsxs(Box, { flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'stretch', overflow: 'hidden', minHeight: '100%', p: 4, children: [_jsx(Breadcrumbs, { breadcrumbs: breadcrumbs }), _jsx(Box, { flex: '1 1 auto', mt: !!breadcrumbs?.length ? 2 : 0, children: children })] }));
7
8
  };
8
- Page.Flex = ({ children }) => {
9
+ Page.Flex = ({ children, breadcrumbs }) => {
9
10
  const { ref: headerRef } = useHeader();
10
- return (_jsx(Box, { display: "flex", justifyContent: "center", alignItems: "center", height: `calc(100vh - ${(headerRef.current?.offsetHeight || 0) * 2}px)`, children: children }));
11
+ const breadcrumbsRef = React.useRef(null);
12
+ return (_jsxs(React.Fragment, { children: [_jsx(Breadcrumbs, { breadcrumbs: breadcrumbs, ref: breadcrumbsRef }), _jsx(Box, { display: "flex", justifyContent: "center", alignItems: "center", height: `calc(100vh - ${((headerRef.current?.offsetHeight || 0) * 2) + (breadcrumbsRef.current?.offsetHeight || 0)}px)`, children: children })] }));
11
13
  };
@@ -2,7 +2,7 @@ import type { StoryObj } from '@storybook/react-vite';
2
2
  import { IMenuItemsProps } from '../components';
3
3
  declare const meta: {
4
4
  title: string;
5
- component: ({ src, name, menu, }: import("../components").IAvatarIconMenuProps) => import("react/jsx-runtime").JSX.Element;
5
+ component: ({ src, name, menu, onClick, children, }: import("../components").IAvatarIconMenuProps) => import("react/jsx-runtime").JSX.Element;
6
6
  tags: string[];
7
7
  parameters: {
8
8
  layout: string;
@@ -23,5 +23,6 @@ export const Component = {
23
23
  name: "Segun Adebayo",
24
24
  src: "https://bit.ly/sage-adebayo",
25
25
  menu,
26
+ onClick: (value) => console.log(value),
26
27
  }
27
28
  };
@@ -18,7 +18,7 @@ const menu = (_jsx(AvatarIconMenu, { name: "Segun Adebayo", src: "https://bit.ly
18
18
  { label: 'Account', value: 'account' },
19
19
  { label: 'Settings', value: 'settings' },
20
20
  { label: 'Logout', value: 'logout' },
21
- ] }));
21
+ ], onClick: (value) => console.log(value) }));
22
22
  const meta = {
23
23
  title: 'Frame/Frame',
24
24
  component: Frame,
@@ -10,7 +10,7 @@ const menu = (_jsx(AvatarIconMenu, { name: "Segun Adebayo", src: "https://bit.ly
10
10
  { label: 'Account', value: 'account' },
11
11
  { label: 'Settings', value: 'settings' },
12
12
  { label: 'Logout', value: 'logout' },
13
- ] }));
13
+ ], onClick: (value) => console.log(value) }));
14
14
  const meta = {
15
15
  title: 'Frame/Header',
16
16
  component: Header,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vrobots/storybook",
3
3
  "private": false,
4
- "version": "0.1.55",
4
+ "version": "0.1.57",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",