@yusufalperendumlu/component-library 0.0.5 → 0.0.7
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/.storybook/main.ts +1 -1
- package/.storybook/preview.ts +2 -2
- package/dist/cjs/index.css +1 -1
- package/dist/cjs/index.css.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.css +1 -1
- package/dist/esm/index.css.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +63 -7
- package/dist/tailwind.css +1 -1
- package/eslint.config.js +23 -0
- package/jest.config.ts +13 -14
- package/package.json +18 -2
- package/postcss.config.js +6 -6
- package/prettier.config.js +84 -0
- package/src/components/Autocomplete/Autocomplete.stories.tsx +65 -0
- package/src/components/Autocomplete/Autocomplete.tsx +127 -0
- package/src/components/Autocomplete/Autocomplete.types.ts +14 -0
- package/src/components/Autocomplete/index.ts +3 -0
- package/src/components/Button/Button.stories.tsx +52 -52
- package/src/components/Button/Button.tsx +55 -50
- package/src/components/Button/Button.types.ts +7 -7
- package/src/components/Button/index.ts +3 -3
- package/src/components/Dialog/Dialog.stories.tsx +102 -0
- package/src/components/Dialog/Dialog.tsx +90 -0
- package/src/components/Dialog/Dialog.types.ts +7 -0
- package/src/components/Dialog/index.ts +3 -0
- package/src/components/Input/Input.stories.tsx +34 -0
- package/src/components/Input/Input.tsx +31 -9
- package/src/components/Input/Input.types.ts +6 -0
- package/src/components/Input/index.ts +3 -0
- package/src/components/Table/Table.stories.tsx +53 -0
- package/src/components/Table/Table.tsx +104 -0
- package/src/components/Table/Table.types.ts +13 -0
- package/src/components/Table/index.ts +3 -0
- package/src/components/Toast/Toast.stories.tsx +44 -0
- package/src/components/Toast/Toast.tsx +70 -0
- package/src/components/Toast/Toast.types.ts +7 -0
- package/src/components/Toast/icons.tsx +9 -0
- package/src/components/Toast/index.ts +0 -0
- package/src/components/index.ts +5 -2
- package/src/index.ts +3 -3
- package/src/styles/tailwind.css +124 -124
- package/src/tests/Autocomplete.test.tsx +81 -0
- package/src/tests/Button.test.tsx +48 -48
- package/src/tests/Dialog.test.tsx +86 -0
- package/src/tests/Input.test.tsx +42 -0
- package/src/tests/Table.test.tsx +55 -0
- package/src/tests/styleMock.ts +1 -1
- package/tailwind.config.js +3 -2
- package/tsconfig.json +20 -30
- package/src/components/Input/index.tsx +0 -3
@@ -0,0 +1,55 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
3
|
+
import Table from '../components/Table/Table';
|
4
|
+
import { TableColumn } from '../components/Table/Table.types';
|
5
|
+
|
6
|
+
interface TestData {
|
7
|
+
id: number;
|
8
|
+
name: string;
|
9
|
+
age: number;
|
10
|
+
}
|
11
|
+
|
12
|
+
const columns: TableColumn<TestData>[] = [
|
13
|
+
{ key: 'id', label: 'ID', sortable: true },
|
14
|
+
{ key: 'name', label: 'Name', sortable: true },
|
15
|
+
{ key: 'age', label: 'Age' },
|
16
|
+
];
|
17
|
+
|
18
|
+
const data: TestData[] = [
|
19
|
+
{ id: 1, name: 'Alice', age: 28 },
|
20
|
+
{ id: 2, name: 'Bob', age: 34 },
|
21
|
+
{ id: 3, name: 'Charlie', age: 22 },
|
22
|
+
];
|
23
|
+
|
24
|
+
describe('Table Component', () => {
|
25
|
+
it('renders table headers correctly', () => {
|
26
|
+
render(<Table columns={columns} data={data} />);
|
27
|
+
columns.forEach(col => {
|
28
|
+
expect(screen.getByText(col.label)).toBeInTheDocument();
|
29
|
+
});
|
30
|
+
});
|
31
|
+
|
32
|
+
it('renders table rows and cells', () => {
|
33
|
+
render(<Table columns={columns} data={data} />);
|
34
|
+
data.forEach(item => {
|
35
|
+
expect(screen.getByText(item.name)).toBeInTheDocument();
|
36
|
+
expect(screen.getByText(item.age.toString())).toBeInTheDocument();
|
37
|
+
});
|
38
|
+
});
|
39
|
+
|
40
|
+
it('calls onRowClick when a row is clicked', () => {
|
41
|
+
const handleRowClick = jest.fn();
|
42
|
+
render(<Table columns={columns} data={data} onRowClick={handleRowClick} />);
|
43
|
+
const row = screen.getByText('Alice').closest('tr');
|
44
|
+
if (row) fireEvent.click(row);
|
45
|
+
expect(handleRowClick).toHaveBeenCalledWith(data[0]);
|
46
|
+
});
|
47
|
+
|
48
|
+
it('toggles sort order when header is clicked', () => {
|
49
|
+
render(<Table columns={columns} data={data} />);
|
50
|
+
const idHeader = screen.getByText('ID');
|
51
|
+
fireEvent.click(idHeader); // sort asc
|
52
|
+
fireEvent.click(idHeader); // sort desc
|
53
|
+
expect(screen.getByText('3')).toBeInTheDocument(); // highest id
|
54
|
+
});
|
55
|
+
});
|
package/src/tests/styleMock.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
module.exports = {}
|
1
|
+
module.exports = {};
|
package/tailwind.config.js
CHANGED
package/tsconfig.json
CHANGED
@@ -1,30 +1,20 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"target": "esnext",
|
4
|
-
"jsx": "react-jsx",
|
5
|
-
"module": "ESNext",
|
6
|
-
"moduleResolution": "Node",
|
7
|
-
"declaration": true,
|
8
|
-
"emitDeclarationOnly": false,
|
9
|
-
"sourceMap": true,
|
10
|
-
"outDir": "dist",
|
11
|
-
"allowSyntheticDefaultImports": true,
|
12
|
-
"esModuleInterop": true,
|
13
|
-
"forceConsistentCasingInFileNames": true,
|
14
|
-
"strict": true,
|
15
|
-
"skipLibCheck": true,
|
16
|
-
"types": ["node", "jest"]
|
17
|
-
},
|
18
|
-
"include": [
|
19
|
-
|
20
|
-
|
21
|
-
"**/*.test.ts",
|
22
|
-
"**/*.test.tsx",
|
23
|
-
],
|
24
|
-
"exclude": [
|
25
|
-
"node_modules",
|
26
|
-
"dist",
|
27
|
-
"**/*.test.*",
|
28
|
-
"**/*.stories.*"
|
29
|
-
]
|
30
|
-
}
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "esnext",
|
4
|
+
"jsx": "react-jsx",
|
5
|
+
"module": "ESNext",
|
6
|
+
"moduleResolution": "Node",
|
7
|
+
"declaration": true,
|
8
|
+
"emitDeclarationOnly": false,
|
9
|
+
"sourceMap": true,
|
10
|
+
"outDir": "dist",
|
11
|
+
"allowSyntheticDefaultImports": true,
|
12
|
+
"esModuleInterop": true,
|
13
|
+
"forceConsistentCasingInFileNames": true,
|
14
|
+
"strict": true,
|
15
|
+
"skipLibCheck": true,
|
16
|
+
"types": ["node", "jest"]
|
17
|
+
},
|
18
|
+
"include": ["src/**/*", "tests", "**/*.test.ts", "**/*.test.tsx"],
|
19
|
+
"exclude": ["node_modules", "dist", "**/*.test.*", "**/*.stories.*"]
|
20
|
+
}
|