@omniumretail/component-library 1.1.13 → 1.1.15

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.
@@ -1,4 +1,5 @@
1
1
  import { Meta, Story } from '@storybook/react';
2
+ import { DropdownButtonProps } from '.';
2
3
  declare const _default: Meta<import("@storybook/react").Args>;
3
4
  export default _default;
4
- export declare const BasicDropdown: Story<any>;
5
+ export declare const BasicDropdown: Story<DropdownButtonProps>;
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
2
  import { DropdownProps } from 'antd';
3
- interface DropdownButtonProps extends DropdownProps {
4
- options: string[];
3
+ export interface DropdownButtonProps extends DropdownProps {
4
+ options: {
5
+ label: string;
6
+ action: () => void;
7
+ }[];
5
8
  buttonText: string;
6
9
  buttonClass?: string;
7
10
  customButton?: React.ReactNode;
8
11
  }
9
12
  export declare const DropdownButton: ({ options, buttonText, buttonClass, customButton, ...props }: DropdownButtonProps) => import("react/jsx-runtime").JSX.Element;
10
- export {};
@@ -7,6 +7,9 @@ export interface NavigationProps {
7
7
  loginOnClickFunction?: () => void;
8
8
  backLinkOnClickFunction?: () => void;
9
9
  homeOnClickFunction?: () => void;
10
- options?: string[];
10
+ options: {
11
+ label: string;
12
+ action: () => void;
13
+ }[];
11
14
  }
12
15
  export declare const Navigation: (props: NavigationProps) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omniumretail/component-library",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "private": false,
5
5
  "main": "dist/bundle.js",
6
6
  "typings": "./dist/types/index",
@@ -1,15 +1,24 @@
1
1
  import React from 'react';
2
2
  import { Meta, Story } from '@storybook/react';
3
- import { DropdownButton } from './index';
3
+ import { DropdownButton, DropdownButtonProps } from '.';
4
4
 
5
5
  export default {
6
6
  title: 'DropdownButton',
7
7
  component: DropdownButton,
8
8
  } as Meta;
9
9
 
10
- const Template: Story<any> = (args) => <DropdownButton {...args} />;
10
+ const onLeft = () => {
11
+ console.log(9);
12
+ };
13
+
14
+ const Template: Story<DropdownButtonProps> = (args) => <DropdownButton {...args} />;
11
15
 
12
16
  export const BasicDropdown = Template.bind({});
13
17
  BasicDropdown.args = {
14
- options: ['Option 1', 'Option 2', 'Option 3'],
18
+ buttonText: 'Dropdown',
19
+ options: [
20
+ { label: 'Option 1', action: () => onLeft() },
21
+ { label: 'Option 2', action: () => alert('Option 2 clicked') },
22
+ { label: 'Option 3', action: () => alert('Option 3 clicked') },
23
+ ],
15
24
  };
@@ -3,8 +3,8 @@ import { Menu, Dropdown, DropdownProps } from 'antd';
3
3
  import classNames from 'classnames';
4
4
  import { Button } from '../Button';
5
5
 
6
- interface DropdownButtonProps extends DropdownProps {
7
- options: string[];
6
+ export interface DropdownButtonProps extends DropdownProps {
7
+ options: { label: string, action: () => void }[];
8
8
  buttonText: string;
9
9
  buttonClass?: string;
10
10
  customButton?: React.ReactNode;
@@ -13,8 +13,8 @@ interface DropdownButtonProps extends DropdownProps {
13
13
  export const DropdownButton = ({ options, buttonText, buttonClass, customButton, ...props }: DropdownButtonProps) => {
14
14
  const menu = (
15
15
  <Menu>
16
- {options.map((option, index) => (
17
- <Menu.Item key={index}>{option}</Menu.Item>
16
+ {options && options.map((option, index) => (
17
+ <Menu.Item key={index} onClick={option.action}>{option.label}</Menu.Item>
18
18
  ))}
19
19
  </Menu>
20
20
  );
@@ -15,5 +15,8 @@ Primary.args = {
15
15
  title: 'Gestão de Aplicações',
16
16
  loginLink: true,
17
17
  userName: "Diogo Silva Coutinho",
18
- options: ['Option 1', 'Option 2', 'Option 3'],
19
- };
18
+ options: [
19
+ { label: 'Option 1', action: () => alert('Option 1 clicked') },
20
+ { label: 'Option 2', action: () => alert('Option 2 clicked') },
21
+ { label: 'Option 3', action: () => alert('Option 3 clicked') },
22
+ ],};
@@ -14,7 +14,7 @@ export interface NavigationProps {
14
14
  loginOnClickFunction?: () => void;
15
15
  backLinkOnClickFunction?: () => void;
16
16
  homeOnClickFunction?: () => void;
17
- options?: string[];
17
+ options: { label: string, action: () => void }[];
18
18
  }
19
19
 
20
20
  const TABLET_MAX_WIDTH = 1000;