@neo4j-ndl/react 0.2.0 → 0.3.0
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/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/progress-bar/ProgressBar.js +2 -2
- package/lib/cjs/progress-bar/ProgressBar.js.map +1 -1
- package/lib/cjs/table/Table.js +124 -0
- package/lib/cjs/table/Table.js.map +1 -0
- package/lib/cjs/table/TableNavigation.js +51 -0
- package/lib/cjs/table/TableNavigation.js.map +1 -0
- package/lib/cjs/table/helpers.js +119 -0
- package/lib/cjs/table/helpers.js.map +1 -0
- package/lib/cjs/table/hooks/hookCallbackTypes.js +23 -0
- package/lib/cjs/table/hooks/hookCallbackTypes.js.map +1 -0
- package/lib/cjs/table/hooks/index.js +40 -0
- package/lib/cjs/table/hooks/index.js.map +1 -0
- package/lib/cjs/table/hooks/useMultiRowSelect.js +84 -0
- package/lib/cjs/table/hooks/useMultiRowSelect.js.map +1 -0
- package/lib/cjs/table/hooks/useSingleRowSelect.js +61 -0
- package/lib/cjs/table/hooks/useSingleRowSelect.js.map +1 -0
- package/lib/cjs/table/index.js +44 -0
- package/lib/cjs/table/index.js.map +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/progress-bar/ProgressBar.js +2 -2
- package/lib/esm/progress-bar/ProgressBar.js.map +1 -1
- package/lib/esm/table/Table.js +117 -0
- package/lib/esm/table/Table.js.map +1 -0
- package/lib/esm/table/TableNavigation.js +44 -0
- package/lib/esm/table/TableNavigation.js.map +1 -0
- package/lib/esm/table/helpers.js +112 -0
- package/lib/esm/table/helpers.js.map +1 -0
- package/lib/esm/table/hooks/hookCallbackTypes.js +22 -0
- package/lib/esm/table/hooks/hookCallbackTypes.js.map +1 -0
- package/lib/esm/table/hooks/index.js +24 -0
- package/lib/esm/table/hooks/index.js.map +1 -0
- package/lib/esm/table/hooks/useMultiRowSelect.js +82 -0
- package/lib/esm/table/hooks/useMultiRowSelect.js.map +1 -0
- package/lib/esm/table/hooks/useSingleRowSelect.js +57 -0
- package/lib/esm/table/hooks/useSingleRowSelect.js.map +1 -0
- package/lib/esm/table/index.js +23 -0
- package/lib/esm/table/index.js.map +1 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/progress-bar/ProgressBar.d.ts +2 -3
- package/lib/types/table/Table.d.ts +78 -0
- package/lib/types/table/TableNavigation.d.ts +39 -0
- package/lib/types/table/helpers.d.ts +51 -0
- package/lib/types/table/hooks/hookCallbackTypes.d.ts +27 -0
- package/lib/types/table/hooks/index.d.ts +23 -0
- package/lib/types/table/hooks/useMultiRowSelect.d.ts +42 -0
- package/lib/types/table/hooks/useSingleRowSelect.d.ts +37 -0
- package/lib/types/table/index.d.ts +22 -0
- package/package.json +6 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/table/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;;;;;AAEH,iCAA2C;AAAlC,+GAAA,OAAO,OAAS;AACzB,0CAAwB"}
|
package/lib/esm/index.js
CHANGED
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
|
|
@@ -33,9 +33,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
33
33
|
import React from 'react';
|
|
34
34
|
import classnames from 'classnames';
|
|
35
35
|
const ProgressBar = React.forwardRef(function ProgressBar(_a, ref) {
|
|
36
|
-
var { heading,
|
|
36
|
+
var { heading, value, barSize = 'small', className } = _a, rest = __rest(_a, ["heading", "value", "barSize", "className"]);
|
|
37
37
|
const classes = classnames('ndl-progress-bar-wrapper', barSize, className);
|
|
38
|
-
return (_jsxs("div", Object.assign({}, rest, { className: classes, ref: ref }, { children: [_jsxs("div", Object.assign({ className: "header" }, { children: [_jsx("span", Object.assign({ className: "heading" }, { children: heading })), _jsx("span", Object.assign({ className: "progress-number" }, { children: value + '%' }))] })), _jsx("div", Object.assign({ className: "progress-bar-container", role: "progressbar", title: "progress bar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": value }, { children: _jsx("div", { className: "progress-bar", style: { width: value + '%' } }) }))
|
|
38
|
+
return (_jsxs("div", Object.assign({}, rest, { className: classes, ref: ref }, { children: [heading && (_jsxs("div", Object.assign({ className: "header" }, { children: [_jsx("span", Object.assign({ className: "heading" }, { children: heading })), _jsx("span", Object.assign({ className: "progress-number" }, { children: value + '%' }))] }))), _jsx("div", Object.assign({ className: "progress-bar-container", role: "progressbar", title: "progress bar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": value }, { children: _jsx("div", { className: "progress-bar", style: { width: value + '%' } }) }))] })));
|
|
39
39
|
});
|
|
40
40
|
export default ProgressBar;
|
|
41
41
|
//# sourceMappingURL=ProgressBar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressBar.js","sourceRoot":"","sources":["../../../src/progress-bar/ProgressBar.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"ProgressBar.js","sourceRoot":"","sources":["../../../src/progress-bar/ProgressBar.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AASpC,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAAC,SAAS,WAAW,CACvD,EAA2E,EAC3E,GAAuC;QADvC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,EAAE,SAAS,OAA6B,EAAxB,IAAI,cAAvD,4CAAyD,CAAF;IAGvD,MAAM,OAAO,GAAG,UAAU,CAAC,0BAA0B,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IAE3E,OAAO,CACL,+BAAS,IAAI,IAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,iBACxC,OAAO,IAAI,CACV,6BAAK,SAAS,EAAC,QAAQ,iBACrB,6BAAM,SAAS,EAAC,SAAS,gBAAE,OAAO,IAAQ,EAC1C,6BAAM,SAAS,EAAC,iBAAiB,gBAAE,KAAK,GAAG,GAAG,IAAQ,KAClD,CACP,EACD,4BACE,SAAS,EAAC,wBAAwB,EAClC,IAAI,EAAC,aAAa,EAClB,KAAK,EAAC,cAAc,mBACL,CAAC,mBACD,GAAG,mBACH,KAAK,gBAEpB,cAAK,SAAS,EAAC,cAAc,EAAC,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,GAAG,EAAE,GAAI,IAC3D,KACF,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
import classNames from 'classnames';
|
|
23
|
+
import { ResizingBar, SortIcon, TableResults } from './helpers';
|
|
24
|
+
import TableNavigation from './TableNavigation';
|
|
25
|
+
/** Table results per page, with the first option being the default */
|
|
26
|
+
const TABLE_RESULTS = {
|
|
27
|
+
DEFAULT: 10,
|
|
28
|
+
values: [10, 25, 50, 100],
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* Small Utilities
|
|
33
|
+
* for table styling and functionality
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
/** For fixed row height tables, we should have a fixed body size */
|
|
37
|
+
export const fixedHeight = (items, height) => ({
|
|
38
|
+
style: { height: `${height * items}px` },
|
|
39
|
+
});
|
|
40
|
+
const DefaultHeader = ({ headerGroups, }) => (_jsx("thead", { children:
|
|
41
|
+
// Loop over the header rows
|
|
42
|
+
headerGroups.map((headerGroup) => (
|
|
43
|
+
// Apply the header row props
|
|
44
|
+
// Key is defined from getHeaderGroupProps so we can ignore the false-negative
|
|
45
|
+
// eslint-disable-next-line react/jsx-key
|
|
46
|
+
_jsx("tr", Object.assign({}, headerGroup.getHeaderGroupProps(), { children:
|
|
47
|
+
// Loop over the headers in each row
|
|
48
|
+
headerGroup.headers.map((column) => {
|
|
49
|
+
const castedColumn = column;
|
|
50
|
+
const sortable = !!castedColumn.getSortByToggleProps;
|
|
51
|
+
// Dont use "group" class inside the @apply component
|
|
52
|
+
// https://github.com/tailwindlabs/tailwindcss/issues/2848#issuecomment-734523233
|
|
53
|
+
const headerClasses = classNames('group', 'table-column-styling', {
|
|
54
|
+
sortable,
|
|
55
|
+
});
|
|
56
|
+
return (
|
|
57
|
+
// Apply the header cell props
|
|
58
|
+
// Key is defined from getHeaderGroupProps so we can ignore the false-negative
|
|
59
|
+
// eslint-disable-next-line react/jsx-key
|
|
60
|
+
_jsxs("th", Object.assign({ style: Object.assign(Object.assign({}, castedColumn.getHeaderProps().style), {
|
|
61
|
+
/** 0.25px */
|
|
62
|
+
letterSpacing: '0.25px' }), scope: "col", className: headerClasses }, { children: [_jsxs("div", Object.assign({ className: "table-header-cell" }, { children: [castedColumn.render('Header'), castedColumn.canSort && (_jsx(SortIcon, Object.assign({}, castedColumn.getSortByToggleProps(), { isSortedDesc: castedColumn.isSortedDesc })))] })), 'canResize' in castedColumn &&
|
|
63
|
+
'getResizerProps' in castedColumn && (_jsx(ResizingBar, Object.assign({}, castedColumn.getResizerProps())))] })));
|
|
64
|
+
}) })))) }));
|
|
65
|
+
const DefaultBody = ({ getTableBodyProps, page, prepareRow, actionsButtons, rows, }) => {
|
|
66
|
+
// Page is defined when using the usePagination plugin, otherwise rows is defined
|
|
67
|
+
const iterable = page !== null && page !== void 0 ? page : rows;
|
|
68
|
+
return (_jsx(_Fragment, { children: iterable.length > 0 ? (_jsx("tbody", Object.assign({}, getTableBodyProps(), { className: "n-bg-light-neutral-bg-weak" }, { children: iterable.length > 0 &&
|
|
69
|
+
iterable.map((row) => {
|
|
70
|
+
prepareRow(row);
|
|
71
|
+
return (
|
|
72
|
+
// Key is defined from getHeaderGroupProps so we can ignore the false-negative
|
|
73
|
+
// eslint-disable-next-line react/jsx-key
|
|
74
|
+
_jsxs("tr", Object.assign({ className: "table-row" }, row.getRowProps(), { children: [row.cells.map((cell) => (
|
|
75
|
+
// Key is defined from getHeaderGroupProps so we can ignore the false-negative
|
|
76
|
+
// eslint-disable-next-line react/jsx-key
|
|
77
|
+
_jsx("td", Object.assign({ className: "table-cell" }, cell.getCellProps(), { children: cell.render('Cell') })))), actionsButtons && actionsButtons(row)] })));
|
|
78
|
+
}) }))) : (_jsx("tr", { children: _jsx("h6", Object.assign({ className: "n-my-5 n-w-full n-text-center n-h-10 n-relative n-left-full n-flex n-justify-center n-items-center" }, { children: "No data present" })) })) }));
|
|
79
|
+
};
|
|
80
|
+
const DefaultNavigation = ({ state, rows, page, canPreviousPage, nextPage, pageOptions, pageCount, gotoPage, canNextPage, previousPage, setPageSize, }) => {
|
|
81
|
+
// Navigation is only needed if pagination exists
|
|
82
|
+
if (!page || state.pageSize === undefined || state.pageIndex === undefined) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
return (_jsxs("div", Object.assign({ className: "n-flex n-flex-row n-flex-wrap n-gap-2 n-justify-between n-items-center n-px-7 n-py-4 n-bg-light-neutral-bg-weak" }, { children: [_jsx(TableResults, { pageIndex: state.pageIndex, rowsLength: rows.length, pageLength: page.length }), _jsxs("div", Object.assign({ className: "n-flex n-flex-row n-flex-wrap n-gap-2 n-justify-between n-items-center n-gap-x-10" }, { children: [pageCount > 1 && (_jsx(TableNavigation, { canPreviousPage: canPreviousPage, canNextPage: canNextPage, onPageClick: gotoPage, previousPage: previousPage, nextPage: nextPage, pageIndex: state.pageIndex, pageOptions: pageOptions })), _jsxs("div", Object.assign({ className: "n-flex n-flex-row n-justify-between n-items-center n-gap-x-4 n-text-light-neutral-text-weaker" }, { children: ["Show", _jsx("select", Object.assign({ onChange: (e) => setPageSize(parseInt(e.target.value, 10)), className: "ndl-table-select", value: state.pageSize, "aria-label": "Select page size" }, { children: [...new Set([...TABLE_RESULTS.values, state.pageSize])]
|
|
86
|
+
.sort((a, b) => a - b)
|
|
87
|
+
.map((option) => (_jsx("option", Object.assign({ value: `${option}` }, { children: option }), `${option}`))) }))] }))] }))] })));
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Table Skeleton to keep most section logic DRY
|
|
91
|
+
*
|
|
92
|
+
* How the table component is divided into sections:
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* +----------------+
|
|
96
|
+
* | Table Controls |
|
|
97
|
+
* | (ex: Search) |
|
|
98
|
+
* +----------------+
|
|
99
|
+
* | Header |
|
|
100
|
+
* +----------------+
|
|
101
|
+
* | Body (data) |
|
|
102
|
+
* +----------------+
|
|
103
|
+
* | Navigation |
|
|
104
|
+
* +----------------+
|
|
105
|
+
*
|
|
106
|
+
*/
|
|
107
|
+
const Table = (props
|
|
108
|
+
// props: any
|
|
109
|
+
) => {
|
|
110
|
+
const { controls, getTableProps, header, body, navigation, styling, className = '', style = {}, role, } = props;
|
|
111
|
+
if (!getTableProps) {
|
|
112
|
+
throw new Error('getTableProps is required');
|
|
113
|
+
}
|
|
114
|
+
return (_jsxs("div", Object.assign({ className: classNames('ndl-table n-rounded-3xl n-overflow-hidden n-flex n-flex-col n-divide-y n-divide-light-neutral-border-weak n-bg-light-neutral-bg-weak n-shadow-l3', className, { 'n-rounded-tl-[0px]': styling === null || styling === void 0 ? void 0 : styling.tabed }), style: style, role: role }, { children: [controls && (_jsx("div", Object.assign({ className: "n-px-7 n-py-6 n-flex n-flex-row n-items-center" }, { children: controls }))), _jsx("div", Object.assign({ className: "n-overflow-x-auto" }, { children: _jsxs("table", Object.assign({}, getTableProps(), { className: "n-w-full n-min-w-full n-divide-y n-divide-light-neutral-border-weak n-bg-light-neutral-bg-weak" }, { children: [header || _jsx(DefaultHeader, Object.assign({}, props)), body || _jsx(DefaultBody, Object.assign({}, props))] })) })), navigation || (_jsx(DefaultNavigation, Object.assign({}, props)))] })));
|
|
115
|
+
};
|
|
116
|
+
export default Table;
|
|
117
|
+
//# sourceMappingURL=Table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Table.js","sourceRoot":"","sources":["../../../src/table/Table.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AAiBpC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAGhD,sEAAsE;AACtE,MAAM,aAAa,GAAG;IACpB,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC;CACjB,CAAC;AAOX;;;;;GAKG;AAEH,oEAAoE;AACpE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,MAAc,EAAE,EAAE,CAAC,CAAC;IAC7D,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK,IAAI,EAAE;CACzC,CAAC,CAAC;AAwBH,MAAM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I,EACJ,UAAU,EACV,OAAO,EACP,SAAS,GAAG,EAAE,EACd,KAAK,GAAG,EAAE,EACV,IAAI,GACL,GAAG,KAAK,CAAC;IAEV,IAAI,CAAC,aAAa,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;KAC9C;IAED,OAAO,CACL,6BACE,SAAS,EAAE,UAAU,CACnB,kJAAkJ,EAClJ,SAAS,EACT,EAAE,oBAAoB,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,EAAE,CACzC,EACD,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,iBAGT,QAAQ,IAAI,CACX,4BAAK,SAAS,EAAC,gDAAgD,gBAC5D,QAAQ,IACL,CACP,EAED,4BAAK,SAAS,EAAC,mBAAmB,gBAEhC,iCACM,aAAa,EAAE,IACnB,SAAS,EAAC,gGAAgG,iBAGzG,MAAM,IAAI,KAAC,aAAa,oBAAM,KAA+B,EAAI,EAEjE,IAAI,IAAI,KAAC,WAAW,oBAAM,KAA6B,EAAI,KACtD,IACJ,EAEL,UAAU,IAAI,CACb,KAAC,iBAAiB,oBAAM,KAAmC,EAAI,CAChE,KACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
import classNames from 'classnames';
|
|
23
|
+
import { userFriendlyPagination } from './helpers';
|
|
24
|
+
import { HeroIcon } from '../icons';
|
|
25
|
+
const NavigationArrowButtonClasses = `
|
|
26
|
+
body-medium n-relative n-inline-flex n-items-center
|
|
27
|
+
n-px-2 n-py-2 n-rounded-xl
|
|
28
|
+
n-text-light-neutral-text-weaker
|
|
29
|
+
hover:n-bg-light-primary-bg-strong hover:n-bg-opacity-10
|
|
30
|
+
`;
|
|
31
|
+
const NavigationIconClasses = `
|
|
32
|
+
n-w-5 n-h-5 n-text-light-neutral-text-weak
|
|
33
|
+
`;
|
|
34
|
+
export const TableNavigation = ({ canPreviousPage, canNextPage, onPageClick, previousPage, nextPage, pageIndex, pageOptions, }) => (_jsxs("nav", Object.assign({ className: "n-relative n-z-0 n-inline-flex n-max-w-min n-rounded-md n-gap-x-2", "aria-label": "Pagination" }, { children: [canPreviousPage ? (_jsx(_Fragment, { children: _jsxs("button", Object.assign({ onClick: () => previousPage(), className: NavigationArrowButtonClasses }, { children: [_jsx("span", Object.assign({ className: "n-sr-only" }, { children: "Previous" })), _jsx(HeroIcon, { iconName: "ChevronLeftIcon", className: NavigationIconClasses })] })) })) : null, userFriendlyPagination(pageIndex + 1, pageOptions.length).map((option, idx) => (_jsx("button", Object.assign({ "data-testid": `table-${option}`, className: classNames('n-relative n-inline-flex n-items-center n-justify-center n-px-3 n-py-0.5 body-medium n-rounded-xl n-leading-8', {
|
|
35
|
+
'n-cursor-pointer hover:n-bg-light-neutral-bg-strong': typeof option === 'number' && option !== pageIndex + 1,
|
|
36
|
+
'n-bg-light-primary-bg-strong n-text-light-neutral-text-inverse': option === pageIndex + 1,
|
|
37
|
+
'n-text-light-neutral-text-weaker': option !== pageIndex + 1,
|
|
38
|
+
}), style: {
|
|
39
|
+
minWidth: '36px',
|
|
40
|
+
maxHeight: '36px',
|
|
41
|
+
minHeight: '36px',
|
|
42
|
+
}, onClick: () => typeof option === 'number' && onPageClick(option - 1) }, { children: option }), `${option}-${idx}`))), canNextPage ? (_jsxs("button", Object.assign({ onClick: () => nextPage(), className: NavigationArrowButtonClasses }, { children: [_jsx("span", Object.assign({ className: "n-sr-only" }, { children: "Next" })), _jsx(HeroIcon, { iconName: "ChevronRightIcon", className: NavigationIconClasses })] }))) : null] })));
|
|
43
|
+
export default TableNavigation;
|
|
44
|
+
//# sourceMappingURL=TableNavigation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableNavigation.js","sourceRoot":"","sources":["../../../src/table/TableNavigation.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAmBpC,MAAM,4BAA4B,GAAG;;;;;CAKpC,CAAC;AAEF,MAAM,qBAAqB,GAAG;;CAE7B,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAC9B,eAAe,EACf,WAAW,EACX,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,WAAW,GACU,EAAE,EAAE,CAAC,CAC1B,6BACE,SAAS,EAAC,mEAAmE,gBAClE,YAAY,iBAEtB,eAAe,CAAC,CAAC,CAAC,CACjB,4BACE,gCACE,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,EAAE,EAC7B,SAAS,EAAE,4BAA4B,iBAEvC,6BAAM,SAAS,EAAC,WAAW,8BAAgB,EAC3C,KAAC,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exOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) "Neo4j"
|
|
16
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
17
|
+
*
|
|
18
|
+
* This file is part of Neo4j.
|
|
19
|
+
*
|
|
20
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
21
|
+
* it under the terms of the GNU General Public License as published by
|
|
22
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
23
|
+
* (at your option) any later version.
|
|
24
|
+
*
|
|
25
|
+
* This program is distributed in the hope that it will be useful,
|
|
26
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
27
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
28
|
+
* GNU General Public License for more details.
|
|
29
|
+
*
|
|
30
|
+
* You should have received a copy of the GNU General Public License
|
|
31
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
32
|
+
*/
|
|
33
|
+
import { HeroIcon } from '../icons';
|
|
34
|
+
import { memo } from 'react';
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* React Table helper to display sorting icon
|
|
38
|
+
* Source:
|
|
39
|
+
* https://react-table.tanstack.com/docs/api/useSortBy#column-properties
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
export const SortIcon = (_a) => {
|
|
43
|
+
var { isSortedDesc } = _a, props = __rest(_a, ["isSortedDesc"]);
|
|
44
|
+
switch (true) {
|
|
45
|
+
case isSortedDesc === true:
|
|
46
|
+
return (_jsx(HeroIcon, Object.assign({}, props, { className: "n-w-4 n-h-4", type: "outline", iconName: "SortDescendingIcon" })));
|
|
47
|
+
case isSortedDesc === false:
|
|
48
|
+
return (_jsx(HeroIcon, Object.assign({}, props, { className: "n-w-4 n-h-4", type: "outline", iconName: "SortAscendingIcon" })));
|
|
49
|
+
default:
|
|
50
|
+
return (_jsx(HeroIcon, Object.assign({}, props, { className: "n-w-4 n-h-4", type: "outline", iconName: "MenuAlt1Icon" })));
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
export const ResizingBar = memo(function ResizingBarMemoed(props) {
|
|
54
|
+
return (_jsx("div", Object.assign({}, props, { className: "table-resizing-bar", style: {
|
|
55
|
+
width: '4px',
|
|
56
|
+
zIndex: 1,
|
|
57
|
+
// prevents from scrolling while dragging on touch devices
|
|
58
|
+
touchAction: 'none',
|
|
59
|
+
} })));
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* The left section of the bottom navigation
|
|
63
|
+
* that is showing the current page and how many results we can see
|
|
64
|
+
*/
|
|
65
|
+
export const TableResults = ({ pageIndex, pageLength, rowsLength, }) => (_jsx("span", Object.assign({ className: "n-text-light-neutral-text-weaker body-medium n-whitespace-nowrap" }, { children: _jsxs("span", { children: ["Showing", ' ', _jsxs("b", { children: [pageIndex * 10, "-", pageIndex * 10 + pageLength] }), ' ', "of ", _jsx("b", { children: rowsLength }), " results"] }) })));
|
|
66
|
+
/**
|
|
67
|
+
* Modified from here: https://gist.github.com/kottenator/9d936eb3e4e3c3e02598
|
|
68
|
+
*
|
|
69
|
+
* @param current Current Index
|
|
70
|
+
* @param max Max Index
|
|
71
|
+
* @returns
|
|
72
|
+
*/
|
|
73
|
+
export const userFriendlyPagination = (current, max) => {
|
|
74
|
+
const last = max;
|
|
75
|
+
const delta = 2;
|
|
76
|
+
const left = current - delta;
|
|
77
|
+
const right = current + delta + 1;
|
|
78
|
+
const range = [];
|
|
79
|
+
const rangeWithDots = [];
|
|
80
|
+
let l;
|
|
81
|
+
for (let i = 1; i <= last; i += 1) {
|
|
82
|
+
if (i === 1 || i === last || (i >= left && i < right)) {
|
|
83
|
+
range.push(i);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
for (let i = 0; i < range.length; i += 1) {
|
|
87
|
+
if (l) {
|
|
88
|
+
if (range[i] - l === 2) {
|
|
89
|
+
rangeWithDots.push(l + 1);
|
|
90
|
+
}
|
|
91
|
+
else if (range[i] - l !== 1) {
|
|
92
|
+
rangeWithDots.push('...');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
rangeWithDots.push(range[i]);
|
|
96
|
+
l = range[i];
|
|
97
|
+
}
|
|
98
|
+
return rangeWithDots;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Small helper to get handle the Checkbox
|
|
102
|
+
* functionality in tables
|
|
103
|
+
*/
|
|
104
|
+
export const toggleRowSelection = (list, idx) => {
|
|
105
|
+
// Removing from the list
|
|
106
|
+
if (list.includes(idx)) {
|
|
107
|
+
return list.filter((o) => o !== idx);
|
|
108
|
+
}
|
|
109
|
+
// Adding to the list
|
|
110
|
+
return [...list, idx];
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/table/helpers.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAG7B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EAKxB,EAAE,EAAE;QALoB,EACvB,YAAY,OAIb,EAHI,KAAK,cAFe,gBAGxB,CADS;IAIR,QAAQ,IAAI,EAAE;QACZ,K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AAC,CAAC,KAAK,GAAG,CAAC,CAAC;KACtC;IACD,qBAAqB;IACrB,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,CAAC;AACxB,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=hookCallbackTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hookCallbackTypes.js","sourceRoot":"","sources":["../../../../src/table/hooks/hookCallbackTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
export * from './useMultiRowSelect';
|
|
22
|
+
export * from './useSingleRowSelect';
|
|
23
|
+
export * from './hookCallbackTypes';
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/table/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
23
|
+
import { useRowSelect, } from 'react-table';
|
|
24
|
+
import { Checkbox } from '../../checkbox';
|
|
25
|
+
/**
|
|
26
|
+
* A react-table plugin to support controlled selected row state for multiple rows
|
|
27
|
+
*
|
|
28
|
+
* Required options provided to useTable:
|
|
29
|
+
*
|
|
30
|
+
* `onAllRowSelect`: A callback that is called when the all rows checkbox is toggled
|
|
31
|
+
* `onRowSelect`: A callback that is called when a rows checkbox is toggled
|
|
32
|
+
*
|
|
33
|
+
* Required fields on `data` provided to useTable:
|
|
34
|
+
*
|
|
35
|
+
* `isSelected`: a boolean that indicates if the row is selected. This key can be changed
|
|
36
|
+
* from `isSelected` to something else by setting the `manualRowSelectedKey` option
|
|
37
|
+
* in the useTable options. See the useRowSelect plugin docs for more details.
|
|
38
|
+
*/
|
|
39
|
+
const useMultiRowSelect = (hooks) => {
|
|
40
|
+
useRowSelect(hooks);
|
|
41
|
+
/*
|
|
42
|
+
Used for the indeterminate
|
|
43
|
+
state of the checkbox
|
|
44
|
+
*/
|
|
45
|
+
hooks.useControlledState.push((state, { instance }) => {
|
|
46
|
+
const { data } = instance;
|
|
47
|
+
const isSelectedKey = 'isSelected';
|
|
48
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
49
|
+
const newState = useMemo(() => (Object.assign(Object.assign({}, state), { selectedRowIds: data.reduce((acc, curr, index) => {
|
|
50
|
+
if (curr[isSelectedKey]) {
|
|
51
|
+
return Object.assign(Object.assign({}, acc), { [index]: true });
|
|
52
|
+
}
|
|
53
|
+
return acc;
|
|
54
|
+
}, {}) })), [state, data, isSelectedKey]);
|
|
55
|
+
return newState;
|
|
56
|
+
});
|
|
57
|
+
hooks.visibleColumns.push((columns, { instance }) => [
|
|
58
|
+
// Let's make a column for selection
|
|
59
|
+
{
|
|
60
|
+
id: 'ndl-checkbox-selection',
|
|
61
|
+
// The header can use the table's getToggleAllRowsSelectedProps method
|
|
62
|
+
// to render a checkbox
|
|
63
|
+
Header: ({ getToggleAllRowsSelectedProps, }) => {
|
|
64
|
+
const checkboxRef = useRef(null);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (checkboxRef && checkboxRef.current) {
|
|
67
|
+
checkboxRef.current.indeterminate =
|
|
68
|
+
getToggleAllRowsSelectedProps().indeterminate || false;
|
|
69
|
+
}
|
|
70
|
+
}, [checkboxRef, getToggleAllRowsSelectedProps]);
|
|
71
|
+
return (_jsx(Checkbox, Object.assign({ "aria-label": "all-rows-select", onClick: () => instance.onAllRowSelect() }, getToggleAllRowsSelectedProps(), { ref: checkboxRef })));
|
|
72
|
+
},
|
|
73
|
+
// The cell can use the individual row's getToggleRowSelectedProps method
|
|
74
|
+
// to the render a checkbox
|
|
75
|
+
Cell: ({ row }) => (_jsx("div", { children: _jsx(Checkbox, Object.assign({ "aria-label": `row-${row.index}`, onClick: () => instance.onRowSelect(row.original, row.index) }, row.getToggleRowSelectedProps())) })),
|
|
76
|
+
},
|
|
77
|
+
...columns,
|
|
78
|
+
]);
|
|
79
|
+
};
|
|
80
|
+
useMultiRowSelect.pluginName = 'useMultiRowSelect';
|
|
81
|
+
export default useMultiRowSelect;
|
|
82
|
+
//# sourceMappingURL=useMultiRowSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMultiRowSelect.js","sourceRoot":"","sources":["../../../../src/table/hooks/useMultiRowSelect.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAIL,YAAY,GAKb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAW1C;;;;;;;;;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AAE,6BAA6B,CAAC,CAAC,CAAC;gBACjD,OAAO,CACL,KAAC,QAAQ,gCACI,iBAAiB,EAC5B,OAAO,EAAE,GAAG,EAAE,CAAE,QAA2B,CAAC,cAAc,EAAE,IACxD,6BAA6B,EAAE,IACnC,GAAG,EAAE,WAAW,IAChB,CACH,CAAC;YACJ,CAAC;YACD,yEAAyE;YACzE,2BAA2B;YAC3B,IAAI,EAAE,CAAC,EAAE,GAAG,EAAW,EAAE,EAAE,CAAC,CAC1B,wBACE,KAAC,QAAQ,gCACK,OAAO,GAAG,CAAC,KAAK,EAAE,EAC9B,OAAO,EAAE,GAAG,EAAE,CACX,QAA2B,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC,IAE9D,GAAW,CAAC,yBAAyB,EAAE,EAC5C,GACE,CACP;SACF;QACD,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,iBAAiB,CAAC,UAAU,GAAG,mBAAmB,CAAC;AAEnD,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
import { useRowSelect } from 'react-table';
|
|
23
|
+
import { Radio } from '../../radio';
|
|
24
|
+
/**
|
|
25
|
+
* A react-table plugin to support controlled selected row state for a single row
|
|
26
|
+
*
|
|
27
|
+
* Required options provided to useTable:
|
|
28
|
+
*
|
|
29
|
+
* `onRowSelect`: A callback that is called when a rows checkbox is toggled
|
|
30
|
+
*
|
|
31
|
+
* Required fields on `data` provided to useTable:
|
|
32
|
+
*
|
|
33
|
+
* `isSelected`: a boolean that indicates if the row is selected. This key can be changed
|
|
34
|
+
* from `isSelected` to something else by setting the `manualRowSelectedKey` option
|
|
35
|
+
* in the useTable options. See the useRowSelect plugin docs for more details.
|
|
36
|
+
* There should only ever be 1 data entry with isSelected set to true
|
|
37
|
+
*/
|
|
38
|
+
export const useSingleRowSelect = (hooks) => {
|
|
39
|
+
useRowSelect(hooks);
|
|
40
|
+
hooks.visibleColumns.push((columns, { instance }) => [
|
|
41
|
+
// Let's make a column for selection
|
|
42
|
+
// This should be definitely unique to avoid collision
|
|
43
|
+
{
|
|
44
|
+
id: 'ndl-radio-selection',
|
|
45
|
+
Header: () => null,
|
|
46
|
+
width: 20,
|
|
47
|
+
// The cell can use the individual row's getToggleRowSelectedProps method
|
|
48
|
+
// to the render a checkbox
|
|
49
|
+
Cell: ({ row }) => {
|
|
50
|
+
return (_jsx(Radio, Object.assign({}, row.getToggleRowSelectedProps(), { onChange: () => instance.onRowSelect(row.original, row.index) })));
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
...columns,
|
|
54
|
+
]);
|
|
55
|
+
};
|
|
56
|
+
export default useSingleRowSelect;
|
|
57
|
+
//# sourceMappingURL=useSingleRowSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSingleRowSelect.js","sourceRoot":"","sources":["../../../../src/table/hooks/useSingleRowSelect.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAe,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,KAAe,EACf,EAAE;IACF,YAAY,CAAC,KAAK,CAAC,CAAC;IAEpB,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;QACnD,oCAAoC;QACpC,sDAAsD;QACtD;YACE,EAAE,EAAE,qBAAqB;YACzB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI;YAClB,KAAK,EAAE,EAAE;YACT,yEAAyE;YACzE,2BAA2B;YAC3B,IAAI,EAAE,CAAC,EAAE,GAAG,EAAW,EAAE,EAAE;gBACzB,OAAO,CACL,KAAC,KAAK,oBACC,GAAW,CAAC,yBAAyB,EAAE,IAC5C,QAAQ,EAAE,GAAG,EAAE,CACZ,QAA2B,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC,IAEnE,CACH,CAAC;YACJ,CAAC;SACF;QACD,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
export { default as Table } from './Table';
|
|
22
|
+
export * from './hooks';
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/table/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,cAAc,SAAS,CAAC"}
|