@yusufalperendumlu/component-library 0.0.9 → 0.0.11

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/index.d.ts CHANGED
@@ -31,7 +31,7 @@ type IButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
31
31
  variant: 'primary' | 'secondary' | 'outline' | 'danger';
32
32
  size?: 'small' | 'medium' | 'large';
33
33
  border?: 'primary' | 'secondary' | 'outline' | 'danger';
34
- title: string;
34
+ title: string | React.ReactNode;
35
35
  };
36
36
 
37
37
  declare const Button: ({ variant, size, border, title, className, ...props }: IButtonProps) => react_jsx_runtime.JSX.Element;
@@ -82,12 +82,15 @@ declare function Table<T extends Record<string, any>>({ columns, data, onRowClic
82
82
 
83
83
  type ToastProps = {
84
84
  title: string;
85
- description: string;
85
+ description?: string;
86
86
  duration?: number;
87
87
  type: 'success' | 'error';
88
88
  position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
89
89
  };
90
90
 
91
- declare const Toast: React$1.FC<ToastProps>;
91
+ declare const Toastr: {
92
+ success: (title: string, description?: string, duration?: number, position?: ToastProps["position"]) => void;
93
+ error: (title: string, description?: string, duration?: number) => void;
94
+ };
92
95
 
93
- export { Autocomplete, Badge, Button, Dialog, Input, Table, Toast };
96
+ export { Autocomplete, Badge, Button, Dialog, Input, Table, Toastr };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yusufalperendumlu/component-library",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -3,5 +3,5 @@ export type IButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
3
3
  variant: 'primary' | 'secondary' | 'outline' | 'danger';
4
4
  size?: 'small' | 'medium' | 'large';
5
5
  border?: 'primary' | 'secondary' | 'outline' | 'danger';
6
- title: string;
6
+ title: string | React.ReactNode;
7
7
  };
@@ -1,31 +1,31 @@
1
- import { cva } from 'class-variance-authority';
2
- import clsx from 'clsx';
3
- import React from 'react';
4
-
5
- import { InputProps } from './Input.types';
6
-
7
- const inputStyles = cva(
8
- 'outline-none font-inter bg-transparent min-w-[160px] px-4 py-2 placeholder:text-[#3f3f3f] rounded-md border border-[#424242] focus:outline-none transition-colors duration-200 ease-in-out rounded-md disabled:cursor-not-allowed disabled:opacity-50'
9
- );
10
-
11
- const Input: React.FC<InputProps> = ({
12
- placeholder,
13
- type,
14
- className,
15
- label,
16
- ...props
17
- }) => {
18
- return (
19
- <div className={clsx('flex flex-col', className)}>
20
- {label && <label className='mb-1 text-sm text-[#424242]'>{label}</label>}
21
- <input
22
- type={type}
23
- className={clsx(inputStyles(), className)}
24
- placeholder={placeholder}
25
- {...props}
26
- />
27
- </div>
28
- );
29
- };
30
-
31
- export default Input;
1
+ import { cva } from 'class-variance-authority';
2
+ import clsx from 'clsx';
3
+ import React from 'react';
4
+
5
+ import { InputProps } from './Input.types';
6
+
7
+ const inputStyles = cva(
8
+ 'outline-none font-inter bg-transparent min-w-[160px] px-4 py-2 placeholder:text-[#3f3f3f] rounded-md border border-[#424242] focus:outline-none transition-colors duration-200 ease-in-out rounded-md disabled:cursor-not-allowed disabled:opacity-50'
9
+ );
10
+
11
+ const Input: React.FC<InputProps> = ({
12
+ placeholder,
13
+ type,
14
+ className,
15
+ label,
16
+ ...props
17
+ }) => {
18
+ return (
19
+ <div className={clsx('flex flex-col', className)}>
20
+ {label && <label className='mb-1 text-sm text-[#424242]'>{label}</label>}
21
+ <input
22
+ type={type}
23
+ className={clsx(inputStyles(), className)}
24
+ placeholder={placeholder}
25
+ {...props}
26
+ />
27
+ </div>
28
+ );
29
+ };
30
+
31
+ export default Input;
@@ -1,6 +1,6 @@
1
1
  export type ToastProps = {
2
2
  title: string;
3
- description: string;
3
+ description?: string;
4
4
  duration?: number;
5
5
  type: 'success' | 'error';
6
6
  position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom/client';
3
+ import Toast from './Toast';
4
+ import type { ToastProps } from './Toast.types';
5
+
6
+ const showToast = (props: ToastProps) => {
7
+ const container = document.createElement('div');
8
+ document.body.appendChild(container);
9
+
10
+ const root = ReactDOM.createRoot(container);
11
+
12
+ const remove = () => {
13
+ root.unmount();
14
+ container.remove();
15
+ };
16
+
17
+ root.render(<Toast {...props} duration={props.duration ?? 3000} />);
18
+
19
+ setTimeout(remove, props.duration ?? 3000);
20
+ };
21
+
22
+ export const Toastr = {
23
+ success: (
24
+ title: string,
25
+ description?: string,
26
+ duration?: number,
27
+ position: ToastProps['position'] = 'top-right'
28
+ ) => showToast({ type: 'success', title, description, duration, position }),
29
+
30
+ error: (title: string, description?: string, duration?: number) =>
31
+ showToast({
32
+ type: 'error',
33
+ title,
34
+ description,
35
+ duration,
36
+ position: 'top-right',
37
+ }),
38
+ };
@@ -1,3 +1,3 @@
1
- import Toast from "./Toast";
1
+ import { Toastr } from "./Toastr";
2
2
 
3
- export default Toast;
3
+ export default Toastr;
@@ -4,4 +4,4 @@ export { default as Button } from './Button';
4
4
  export { default as Dialog } from './Dialog';
5
5
  export { default as Input } from './Input';
6
6
  export { default as Table } from './Table';
7
- export { default as Toast } from './Toast';
7
+ export { default as Toastr } from './Toast';
@@ -24,7 +24,7 @@ describe('Badge component', () => {
24
24
  const html = ReactDOMServer.renderToStaticMarkup(
25
25
  <Badge size='lg'>Large Badge</Badge>
26
26
  );
27
- expect(html).toMatch('/text-base/');
27
+ expect(html).toMatch(/text-base/);
28
28
  });
29
29
 
30
30
  it('merges className prop correctly', () => {