@yusufalperendumlu/component-library 0.0.9 → 0.0.10
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/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/package.json +1 -1
- package/src/components/Input/Input.tsx +31 -31
- package/src/components/Toast/Toast.types.ts +1 -1
- package/src/components/Toast/Toastr.tsx +38 -0
- package/src/components/Toast/index.ts +2 -2
- package/src/components/index.ts +1 -1
- package/src/tests/Badge.test.tsx +1 -1
package/dist/index.d.ts
CHANGED
@@ -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
|
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
|
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,
|
96
|
+
export { Autocomplete, Badge, Button, Dialog, Input, Table, Toastr };
|
package/package.json
CHANGED
@@ -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;
|
@@ -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
|
1
|
+
import { Toastr } from "./Toastr";
|
2
2
|
|
3
|
-
export default
|
3
|
+
export default Toastr;
|
package/src/components/index.ts
CHANGED
@@ -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
|
7
|
+
export { default as Toastr } from './Toast';
|
package/src/tests/Badge.test.tsx
CHANGED
@@ -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(
|
27
|
+
expect(html).toMatch(/text-base/);
|
28
28
|
});
|
29
29
|
|
30
30
|
it('merges className prop correctly', () => {
|