@taiv/ui 1.10.1 → 1.10.2
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/components/Layout/Table/Table.d.ts +2 -1
- package/dist/components/Layout/Table/Table.d.ts.map +1 -1
- package/dist/components/Layout/Table/Table.js +7 -3
- package/dist/components/Layout/Table/Table.stories.d.ts +1 -0
- package/dist/components/Layout/Table/Table.stories.d.ts.map +1 -1
- package/dist/components/Layout/Table/Table.stories.js +18 -0
- package/package.json +1 -1
|
@@ -11,7 +11,8 @@ interface TableProps<T> {
|
|
|
11
11
|
}>;
|
|
12
12
|
placeholder?: React.ReactNode;
|
|
13
13
|
shadow?: boolean;
|
|
14
|
+
divider?: boolean;
|
|
14
15
|
}
|
|
15
|
-
declare const Table: <T>({ columnConfigs, data, ListItem, placeholder, shadow }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare const Table: <T>({ columnConfigs, data, ListItem, placeholder, shadow, divider }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
16
17
|
export { Table, type ColumnConfig, type TableProps };
|
|
17
18
|
//# sourceMappingURL=Table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/components/Layout/Table/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAqB,MAAM,OAAO,CAAC;AAIhE,UAAU,YAAY;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,UAAU,UAAU,CAAC,CAAC;IACpB,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC;IAC3C,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/components/Layout/Table/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAqB,MAAM,OAAO,CAAC;AAIhE,UAAU,YAAY;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,UAAU,UAAU,CAAC,CAAC;IACpB,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC;IAC3C,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,QAAA,MAAM,KAAK,GAAI,CAAC,EAAG,iEAAgF,UAAU,CAAC,CAAC,CAAC,4CA4E/G,CAAC;AAEF,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useRef } from 'react';
|
|
3
3
|
import { Box } from '../Box/Box';
|
|
4
4
|
import { fontWeight, neutral } from '../../../constants';
|
|
5
|
-
const Table = ({ columnConfigs, data, ListItem, placeholder, shadow = false }) => {
|
|
5
|
+
const Table = ({ columnConfigs, data, ListItem, placeholder, shadow = false, divider = true }) => {
|
|
6
6
|
const tableRef = useRef(null);
|
|
7
7
|
/**
|
|
8
8
|
* Apply column styles to the table cells.
|
|
@@ -17,7 +17,7 @@ const Table = ({ columnConfigs, data, ListItem, placeholder, shadow = false }) =
|
|
|
17
17
|
const rows = tbody.querySelectorAll('tr');
|
|
18
18
|
if (!rows || !rows.length)
|
|
19
19
|
return;
|
|
20
|
-
rows.forEach((row) => {
|
|
20
|
+
rows.forEach((row, rowIndex) => {
|
|
21
21
|
const cells = row.querySelectorAll('td');
|
|
22
22
|
cells.forEach((cell, columnIndex) => {
|
|
23
23
|
var _a;
|
|
@@ -26,8 +26,11 @@ const Table = ({ columnConfigs, data, ListItem, placeholder, shadow = false }) =
|
|
|
26
26
|
Object.assign(cell.style, columnStyle);
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
|
+
const showDivider = divider && rowIndex < rows.length - 1;
|
|
30
|
+
const borderStyle = { borderBottom: showDivider ? `1px solid ${neutral[100]}` : 'none' };
|
|
31
|
+
Object.assign(row.style, borderStyle);
|
|
29
32
|
});
|
|
30
|
-
}, [columnConfigs, data]);
|
|
33
|
+
}, [columnConfigs, data, divider]);
|
|
31
34
|
return (_jsx(Box, { sx: {
|
|
32
35
|
borderTopLeftRadius: '8px',
|
|
33
36
|
borderTopRightRadius: '8px',
|
|
@@ -35,6 +38,7 @@ const Table = ({ columnConfigs, data, ListItem, placeholder, shadow = false }) =
|
|
|
35
38
|
overflow: 'hidden',
|
|
36
39
|
}, children: _jsxs("table", { ref: tableRef, style: {
|
|
37
40
|
width: '100%',
|
|
41
|
+
borderCollapse: 'collapse',
|
|
38
42
|
}, children: [_jsx("thead", { children: _jsx("tr", { children: columnConfigs.map((column, index) => (_jsx("th", { style: {
|
|
39
43
|
backgroundColor: neutral[50],
|
|
40
44
|
color: neutral[300],
|
|
@@ -10,4 +10,5 @@ export declare const StyledColumns: Story;
|
|
|
10
10
|
export declare const TableWithPlaceholder: Story;
|
|
11
11
|
export declare const TableWithoutPlaceholder: Story;
|
|
12
12
|
export declare const TableWithShadow: Story;
|
|
13
|
+
export declare const TableWithoutDivider: Story;
|
|
13
14
|
//# sourceMappingURL=Table.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/Layout/Table/Table.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAUhC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"Table.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/Layout/Table/Table.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAUhC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,KAAK,CA6B5B,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAyPnC,eAAO,MAAM,UAAU,EAAE,KAmBxB,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,KAqBvC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KAoBnC,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAmB3B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,KAsBlC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,KAerC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAa7B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KAajC,CAAC"}
|
|
@@ -31,6 +31,10 @@ const meta = {
|
|
|
31
31
|
control: { type: 'boolean' },
|
|
32
32
|
description: 'Adds shadow to the table',
|
|
33
33
|
},
|
|
34
|
+
divider: {
|
|
35
|
+
control: { type: 'boolean' },
|
|
36
|
+
description: 'Adds divider between rows to the table',
|
|
37
|
+
},
|
|
34
38
|
},
|
|
35
39
|
};
|
|
36
40
|
export default meta;
|
|
@@ -314,3 +318,17 @@ export const TableWithShadow = {
|
|
|
314
318
|
shadow: true,
|
|
315
319
|
},
|
|
316
320
|
};
|
|
321
|
+
export const TableWithoutDivider = {
|
|
322
|
+
args: {
|
|
323
|
+
columnConfigs: [
|
|
324
|
+
{ heading: 'Name', style: { width: '25%', paddingLeft: '20px', fontWeight: '600' } },
|
|
325
|
+
{ heading: 'Email', style: { width: '30%', textAlign: 'left' } },
|
|
326
|
+
{ heading: 'Role', style: { width: '20%', textAlign: 'center' } },
|
|
327
|
+
{ heading: 'Status', style: { width: '15%', textAlign: 'center' } },
|
|
328
|
+
{ heading: 'Last Login', style: { width: '10%', textAlign: 'right', paddingRight: '20px' } },
|
|
329
|
+
],
|
|
330
|
+
data: userData,
|
|
331
|
+
ListItem: UserListItem,
|
|
332
|
+
divider: false,
|
|
333
|
+
},
|
|
334
|
+
};
|