@integrigo/integrigo-ui 1.6.16-e → 1.6.16-f

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,23 +4,10 @@ declare type OnClickFunctionType = (e: MouseEvent<HTMLDivElement>) => void;
4
4
  export interface ChipProps {
5
5
  iconLeft?: IconType;
6
6
  iconRight?: IconType;
7
- size?: ChipSize;
7
+ size?: 's' | 'm' | 'l' | 'xl';
8
8
  label: React.ReactNode;
9
- variant?: ChipVariant;
9
+ variant?: 'transparent' | 'white' | 'primary' | 'secondary' | 'grey';
10
10
  onClick?: OnClickFunctionType;
11
11
  }
12
- export declare enum ChipVariant {
13
- transparent = "transparent",
14
- white = "white",
15
- primary = "primary",
16
- secondary = "secondary",
17
- grey = "grey"
18
- }
19
- export declare enum ChipSize {
20
- xl = "xl",
21
- l = "l",
22
- m = "m",
23
- s = "s"
24
- }
25
12
  export declare const Chip: FC<ChipProps>;
26
13
  export {};
@@ -1,14 +1,14 @@
1
1
  import { ComponentStory, ComponentMeta } from '@storybook/react';
2
2
  declare const _default: ComponentMeta<import("styled-components").StyledComponent<"div", any, {
3
- variant?: "orange" | "navy" | "white" | undefined;
3
+ variant?: "white" | "orange" | "navy" | undefined;
4
4
  }, never>>;
5
5
  export default _default;
6
6
  export declare const Orange: ComponentStory<import("styled-components").StyledComponent<"div", any, {
7
- variant?: "orange" | "navy" | "white" | undefined;
7
+ variant?: "white" | "orange" | "navy" | undefined;
8
8
  }, never>>;
9
9
  export declare const Navy: ComponentStory<import("styled-components").StyledComponent<"div", any, {
10
- variant?: "orange" | "navy" | "white" | undefined;
10
+ variant?: "white" | "orange" | "navy" | undefined;
11
11
  }, never>>;
12
12
  export declare const White: ComponentStory<import("styled-components").StyledComponent<"div", any, {
13
- variant?: "orange" | "navy" | "white" | undefined;
13
+ variant?: "white" | "orange" | "navy" | undefined;
14
14
  }, never>>;
@@ -1,19 +1,19 @@
1
1
  import React from 'react';
2
2
  import { ComponentStory, ComponentMeta } from '@storybook/react';
3
- declare const _default: ComponentMeta<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "type"> & {
3
+ declare const _default: ComponentMeta<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
4
4
  size?: "s" | "m" | "l" | "xl" | undefined;
5
5
  label?: string | undefined;
6
6
  } & React.RefAttributes<HTMLInputElement>>>;
7
7
  export default _default;
8
- export declare const Basic: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "type"> & {
8
+ export declare const Basic: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
9
9
  size?: "s" | "m" | "l" | "xl" | undefined;
10
10
  label?: string | undefined;
11
11
  } & React.RefAttributes<HTMLInputElement>>>;
12
- export declare const Controlled: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "type"> & {
12
+ export declare const Controlled: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
13
13
  size?: "s" | "m" | "l" | "xl" | undefined;
14
14
  label?: string | undefined;
15
15
  } & React.RefAttributes<HTMLInputElement>>>;
16
- export declare const WithLabel: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "type"> & {
16
+ export declare const WithLabel: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
17
17
  size?: "s" | "m" | "l" | "xl" | undefined;
18
18
  label?: string | undefined;
19
19
  } & React.RefAttributes<HTMLInputElement>>>;
@@ -1,20 +1,20 @@
1
1
  import React from 'react';
2
2
  import { ComponentMeta, ComponentStory } from '@storybook/react';
3
3
  import { Size } from './Radio';
4
- declare const _default: ComponentMeta<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "type"> & {
4
+ declare const _default: ComponentMeta<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
5
5
  size?: Size | undefined;
6
6
  label?: string | undefined;
7
7
  } & React.RefAttributes<HTMLInputElement>>>;
8
8
  export default _default;
9
- export declare const Basic: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "type"> & {
9
+ export declare const Basic: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
10
10
  size?: Size | undefined;
11
11
  label?: string | undefined;
12
12
  } & React.RefAttributes<HTMLInputElement>>>;
13
- export declare const Controlled: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "type"> & {
13
+ export declare const Controlled: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
14
14
  size?: Size | undefined;
15
15
  label?: string | undefined;
16
16
  } & React.RefAttributes<HTMLInputElement>>>;
17
- export declare const WithLabel: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "type"> & {
17
+ export declare const WithLabel: ComponentStory<React.ForwardRefExoticComponent<Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" | "size"> & {
18
18
  size?: Size | undefined;
19
19
  label?: string | undefined;
20
20
  } & React.RefAttributes<HTMLInputElement>>>;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "registry": "https://npm.pkg.github.com/integrigo"
5
5
  },
6
- "version": "1.6.16e",
6
+ "version": "1.6.16f",
7
7
  "main": "lib/index.js",
8
8
  "module": "lib/index.esm.js",
9
9
  "types": "lib/index.d.ts",
@@ -1,18 +1,20 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
- import userEvent from '@testing-library/user-event';
4
- import { Chip, ChipVariant } from './Chip';
1
+ import React from "react";
2
+ import { render, screen } from "@testing-library/react";
3
+ import userEvent from "@testing-library/user-event";
4
+ import { Chip } from "./Chip";
5
5
 
6
- describe('<Chip />', () => {
7
- it('should match snapshot - basic', () => {
6
+ describe("<Chip />", () => {
7
+ it("should match snapshot - basic", () => {
8
8
  const { container } = render(<Chip label="Accept" />);
9
9
  expect(container).toMatchSnapshot();
10
10
  });
11
- it('should match snapshot - icon', () => {
12
- const { container } = render(<Chip label="Accept" variant={ChipVariant.primary} iconLeft="close" />);
11
+ it("should match snapshot - icon", () => {
12
+ const { container } = render(
13
+ <Chip label="Accept" variant="primary" iconLeft="close" />
14
+ );
13
15
  expect(container).toMatchSnapshot();
14
16
  });
15
- it('should call onclick function', async () => {
17
+ it("should call onclick function", async () => {
16
18
  const user = userEvent.setup();
17
19
  const handleClick = jest.fn();
18
20
  render(<Chip label="Accept" onClick={handleClick} />);
@@ -7,27 +7,12 @@ type OnClickFunctionType = (e: MouseEvent<HTMLDivElement>) => void;
7
7
  export interface ChipProps {
8
8
  iconLeft?: IconType;
9
9
  iconRight?: IconType;
10
- size?: ChipSize;
10
+ size?: 's' | 'm' | 'l' | 'xl';
11
11
  label: React.ReactNode;
12
- variant?: ChipVariant;
12
+ variant?: 'transparent' | 'white' | 'primary' | 'secondary' | 'grey';
13
13
  onClick?: OnClickFunctionType;
14
14
  }
15
15
 
16
- export enum ChipVariant {
17
- transparent = "transparent",
18
- white = "white",
19
- primary = "primary",
20
- secondary = "secondary",
21
- grey = "grey",
22
- }
23
-
24
- export enum ChipSize {
25
- xl = "xl",
26
- l = "l",
27
- m = "m",
28
- s = "s",
29
- }
30
-
31
16
  const sizeVariant = {
32
17
  xl: {
33
18
  iconSize: {
@@ -102,8 +87,8 @@ export const Chip: FC<ChipProps> = (props: ChipProps) => {
102
87
  iconLeft,
103
88
  iconRight,
104
89
  label,
105
- size = ChipSize.m,
106
- variant = ChipVariant.primary,
90
+ size = 'm',
91
+ variant = 'primary',
107
92
  onClick,
108
93
  } = props;
109
94
 
@@ -132,9 +117,9 @@ export const Chip: FC<ChipProps> = (props: ChipProps) => {
132
117
  );
133
118
  };
134
119
 
135
- const getVariantStyles = (variant: ChipVariant, clickable: boolean): string => {
120
+ const getVariantStyles = (variant: ChipProps['variant'], clickable: boolean): string => {
136
121
  switch (variant) {
137
- case ChipVariant.secondary:
122
+ case 'secondary':
138
123
  return `
139
124
  background-color: var(--color-white);
140
125
  opacity: 0.9;
@@ -156,7 +141,7 @@ const getVariantStyles = (variant: ChipVariant, clickable: boolean): string => {
156
141
  `
157
142
  }
158
143
  `;
159
- case ChipVariant.transparent:
144
+ case 'transparent':
160
145
  return `
161
146
  ${
162
147
  clickable &&
@@ -171,7 +156,7 @@ const getVariantStyles = (variant: ChipVariant, clickable: boolean): string => {
171
156
  `
172
157
  }
173
158
  `;
174
- case ChipVariant.grey:
159
+ case 'grey':
175
160
  return `
176
161
  background-color: var(--shades-of-grey-20);
177
162
 
@@ -188,7 +173,7 @@ const getVariantStyles = (variant: ChipVariant, clickable: boolean): string => {
188
173
  `
189
174
  }
190
175
  `;
191
- case ChipVariant.white:
176
+ case 'white':
192
177
  return `
193
178
  background-color: var(--color-white);
194
179
  border-color: var(--shades-of-grey-40);
@@ -207,7 +192,7 @@ const getVariantStyles = (variant: ChipVariant, clickable: boolean): string => {
207
192
  `
208
193
  }
209
194
  `;
210
- case ChipVariant.primary:
195
+ case 'primary':
211
196
  default:
212
197
  return `
213
198
  background-color: var(--color-orange);
@@ -233,8 +218,8 @@ const getVariantStyles = (variant: ChipVariant, clickable: boolean): string => {
233
218
  Chip.displayName = "Chip";
234
219
 
235
220
  const ChipWrapper = styled.div<{
236
- size: ChipSize;
237
- variant: ChipVariant;
221
+ size: Exclude<ChipProps['size'], undefined>;
222
+ variant: Exclude<ChipProps['variant'], undefined>;
238
223
  onClick?: OnClickFunctionType;
239
224
  }>`
240
225
  border-radius: 100px;
@@ -264,7 +249,7 @@ const IconWrapper = styled.span`
264
249
  IconWrapper.displayName = "IconWrapper";
265
250
 
266
251
  const Text = styled.span<{
267
- size: ChipSize;
252
+ size: Exclude<ChipProps['size'], undefined>;
268
253
  }>`
269
254
  color: inherit;
270
255
  font-weight: bold;