@qiwi/pijma-desktop-extra 0.1.3 → 0.1.4
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/lib/es5/main/table/index.js +18 -11
- package/lib/es5/test/table.js +24 -1
- package/lib/es6/main/table/index.js +19 -10
- package/lib/es6/test/table.js +24 -1
- package/package.json +1 -1
|
@@ -61,20 +61,27 @@ var Table = function(param) {
|
|
|
61
61
|
data: data
|
|
62
62
|
}), getTableProps = ref.getTableProps, getTableBodyProps = ref.getTableBodyProps, headerGroups = ref.headerGroups, rows = ref.rows, prepareRow = ref.prepareRow;
|
|
63
63
|
// Render the UI for your table
|
|
64
|
+
var headers = [];
|
|
65
|
+
var thead = headerGroups.map(function(headerGroup, i) {
|
|
66
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("tr", _extends({}, headerGroup.getHeaderGroupProps(), {
|
|
67
|
+
children: headerGroup.headers.map(function(column, i) {
|
|
68
|
+
var header = column.render("Header");
|
|
69
|
+
if (typeof header === "string") {
|
|
70
|
+
headers.push(header);
|
|
71
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("th", _extends({}, column.getHeaderProps(), {
|
|
72
|
+
children: header
|
|
73
|
+
}), i);
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
})
|
|
77
|
+
}), i);
|
|
78
|
+
});
|
|
64
79
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(TableWrapper, {
|
|
65
80
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)("table", _extends({}, getTableProps(), {
|
|
66
81
|
children: [
|
|
67
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)("thead", {
|
|
68
|
-
children:
|
|
69
|
-
|
|
70
|
-
children: headerGroup.headers.map(function(column, i) {
|
|
71
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("th", _extends({}, column.getHeaderProps(), {
|
|
72
|
-
children: column.render("Header")
|
|
73
|
-
}), i);
|
|
74
|
-
})
|
|
75
|
-
}), i);
|
|
76
|
-
})
|
|
77
|
-
}),
|
|
82
|
+
headerGroups && headerGroups.length > 0 ? /*#__PURE__*/ (0, _jsxRuntime.jsx)("thead", {
|
|
83
|
+
children: headers.length > 0 ? thead : null
|
|
84
|
+
}) : /*#__PURE__*/ (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {}),
|
|
78
85
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)("tbody", _extends({}, getTableBodyProps(), {
|
|
79
86
|
children: rows.map(function(row, i) {
|
|
80
87
|
prepareRow(row);
|
package/lib/es5/test/table.js
CHANGED
|
@@ -50,7 +50,7 @@ describe("columnFactory", function() {
|
|
|
50
50
|
return (0, _main.columnFactory)();
|
|
51
51
|
}).toThrow("unsupported table column type: undefined");
|
|
52
52
|
});
|
|
53
|
-
it("renders correctly", function() {
|
|
53
|
+
it("renders correctly without header", function() {
|
|
54
54
|
var table = _reactTestRenderer.default.create(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_main.Table, {
|
|
55
55
|
data: [
|
|
56
56
|
{
|
|
@@ -71,4 +71,27 @@ describe("columnFactory", function() {
|
|
|
71
71
|
})).toJSON();
|
|
72
72
|
expect(table).toMatchSnapshot();
|
|
73
73
|
});
|
|
74
|
+
it("renders correctly with header", function() {
|
|
75
|
+
var table = _reactTestRenderer.default.create(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_main.Table, {
|
|
76
|
+
data: [
|
|
77
|
+
{
|
|
78
|
+
name: "qwe",
|
|
79
|
+
value: "qweasd"
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
onSelect: function() {
|
|
83
|
+
/* noop */ },
|
|
84
|
+
columns: [
|
|
85
|
+
{
|
|
86
|
+
accessor: "name",
|
|
87
|
+
Header: "ttest"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
accessor: "value",
|
|
91
|
+
Header: "test"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
})).toJSON();
|
|
95
|
+
expect(table).toMatchSnapshot();
|
|
96
|
+
});
|
|
74
97
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { styled } from '@qiwi/pijma-core';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { useTable } from 'react-table';
|
|
@@ -77,19 +77,28 @@ export const Table = ({ columns , data , onSelect , rowCursor , isActive })=>{
|
|
|
77
77
|
data
|
|
78
78
|
});
|
|
79
79
|
// Render the UI for your table
|
|
80
|
+
const headers = [];
|
|
81
|
+
const thead = headerGroups.map((headerGroup, i)=>/*#__PURE__*/ _jsx("tr", {
|
|
82
|
+
...headerGroup.getHeaderGroupProps(),
|
|
83
|
+
children: headerGroup.headers.map((column, i)=>{
|
|
84
|
+
const header = column.render('Header');
|
|
85
|
+
if (typeof header === 'string') {
|
|
86
|
+
headers.push(header);
|
|
87
|
+
return /*#__PURE__*/ _jsx("th", {
|
|
88
|
+
...column.getHeaderProps(),
|
|
89
|
+
children: header
|
|
90
|
+
}, i);
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
})
|
|
94
|
+
}, i));
|
|
80
95
|
return /*#__PURE__*/ _jsx(TableWrapper, {
|
|
81
96
|
children: /*#__PURE__*/ _jsxs("table", {
|
|
82
97
|
...getTableProps(),
|
|
83
98
|
children: [
|
|
84
|
-
/*#__PURE__*/ _jsx("thead", {
|
|
85
|
-
children:
|
|
86
|
-
|
|
87
|
-
children: headerGroup.headers.map((column, i)=>/*#__PURE__*/ _jsx("th", {
|
|
88
|
-
...column.getHeaderProps(),
|
|
89
|
-
children: column.render('Header')
|
|
90
|
-
}, i))
|
|
91
|
-
}, i))
|
|
92
|
-
}),
|
|
99
|
+
headerGroups && headerGroups.length > 0 ? /*#__PURE__*/ _jsx("thead", {
|
|
100
|
+
children: headers.length > 0 ? thead : null
|
|
101
|
+
}) : /*#__PURE__*/ _jsx(_Fragment, {}),
|
|
93
102
|
/*#__PURE__*/ _jsx("tbody", {
|
|
94
103
|
...getTableBodyProps(),
|
|
95
104
|
children: rows.map((row, i)=>{
|
package/lib/es6/test/table.js
CHANGED
|
@@ -41,7 +41,7 @@ describe('columnFactory', ()=>{
|
|
|
41
41
|
it('throws err otherwise', ()=>{
|
|
42
42
|
expect(()=>columnFactory()).toThrow('unsupported table column type: undefined');
|
|
43
43
|
});
|
|
44
|
-
it('renders correctly', ()=>{
|
|
44
|
+
it('renders correctly without header', ()=>{
|
|
45
45
|
const table = renderer.create(/*#__PURE__*/ _jsx(Table, {
|
|
46
46
|
data: [
|
|
47
47
|
{
|
|
@@ -62,4 +62,27 @@ describe('columnFactory', ()=>{
|
|
|
62
62
|
})).toJSON();
|
|
63
63
|
expect(table).toMatchSnapshot();
|
|
64
64
|
});
|
|
65
|
+
it('renders correctly with header', ()=>{
|
|
66
|
+
const table = renderer.create(/*#__PURE__*/ _jsx(Table, {
|
|
67
|
+
data: [
|
|
68
|
+
{
|
|
69
|
+
name: 'qwe',
|
|
70
|
+
value: 'qweasd'
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
onSelect: ()=>{
|
|
74
|
+
/* noop */ },
|
|
75
|
+
columns: [
|
|
76
|
+
{
|
|
77
|
+
accessor: 'name',
|
|
78
|
+
Header: 'ttest'
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
accessor: 'value',
|
|
82
|
+
Header: 'test'
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
})).toJSON();
|
|
86
|
+
expect(table).toMatchSnapshot();
|
|
87
|
+
});
|
|
65
88
|
});
|